FFDLattice.hpp
1 /*---------------------------------------------------------------------------*\
2  *
3  * mimmo
4  *
5  * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6  *
7  * -------------------------------------------------------------------------
8  * License
9  * This file is part of mimmo.
10  *
11  * mimmo is free software: you can redistribute it and/or modify it
12  * under the terms of the GNU Lesser General Public License v3 (LGPL)
13  * as published by the Free Software Foundation.
14  *
15  * mimmo is distributed in the hope that it will be useful, but WITHOUT
16  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18  * License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with mimmo. If not, see <http://www.gnu.org/licenses/>.
22  *
23 \*---------------------------------------------------------------------------*/
24 #ifndef __FFDLATTICE_HPP__
25 #define __FFDLATTICE_HPP__
26 
27 #include "Lattice.hpp"
28 
29 namespace mimmo{
30 
133 class FFDLattice: public Lattice {
134 
135 protected:
144 private:
145  iarray3E m_mapdeg;
146  bool m_globalDispl;
147  std::unordered_map<int, double> m_collect_wg;
148  dmpvector1D m_filter;
149  bool m_bfilter;
151 public:
152  FFDLattice();
153  FFDLattice(const bitpit::Config::Section & rootXML);
154  virtual ~FFDLattice();
155 
156  //copy operators/constructors
157  FFDLattice(const FFDLattice & other);
159 
160  void buildPorts();
161 
162  //clean structure
163  void clearLattice();
164  void clearFilter();
165 
166  //internal methods
170  void returnKnotsStructure( int, dvector1D &, ivector1D &);
174  bool isDisplGlobal();
176 
177  void setDegrees(iarray3E curveDegrees);
178  void setDisplacements(dvecarr3E displacements);
179  void setDisplGlobal(bool flag);
180  void setLattice(darray3E & origin, darray3E & span, ShapeType, iarray3E & dimensions, iarray3E & degrees);
181  void setLattice(darray3E & origin, darray3E & span, ShapeType, dvector1D & spacing, iarray3E & degrees);
182  void setLattice(BasicShape *, iarray3E & dimensions, iarray3E & degrees);
183  void setLattice(BasicShape *, dvector1D & spacing,iarray3E & degrees);
184 
185  void setNodalWeight(double , int );
186  void setNodalWeight(double , int, int, int);
187  void setNodalWeight(dvector1D );
188 
189  void setFilter(dmpvector1D * );
190 
191  //plotting wrappers
192  void plotGrid(std::string directory, std::string filename, int counter, bool binary, bool deformed);
193  void plotCloud(std::string directory, std::string filename, int counter, bool binary, bool deformed);
194 
195 
196  //execute deformation methods
197  void execute();
198  darray3E apply(darray3E & point);
199  dvecarr3E apply(dvecarr3E * point);
200  dvecarr3E apply(livector1D & map);
201 
202  virtual bool build();
203 
204  void apply();
205 
206  virtual void absorbSectionXML(const bitpit::Config::Section & slotXML, std::string name = "");
207  virtual void flushSectionXML(bitpit::Config::Section & slotXML, std::string name= "");
208 
209 protected:
212  void resizeMapDof();
213  virtual void plotOptionalResults();
214  void swap(FFDLattice &) noexcept;
215  void checkFilter();
216 
217 private:
218  //Nurbs Evaluators
219  darray3E nurbsEvaluator(darray3E &);
220  dvecarr3E nurbsEvaluator(livector1D &);
221  double nurbsEvaluatorScalar(darray3E &, int);
222 
223  //Nurbs utilities
224  dvector1D basisITS0(int k, int pos, double coord);
225  dvector1D getNodeSpacing(int dir);
226 
227  //knots mantenaince utilities
228  void clearKnots();
229  void setKnotsStructure();
230  void setKnotsStructure(int dir, CoordType type);
231  int getKnotInterval(double, int);
232  double getKnotValue(int, int);
233  int getKnotIndex(int,int);
234  int getTheoreticalKnotIndex(int,int);
235 
236  //nodal displacement utility
237  dvecarr3E recoverFullGridDispl();
238  dvector1D recoverFullNodeWeights();
239  void setMapNodes(int ind);
240  int accessMapNodes(int,int,int);
241 
242 
243  //dimension utilities
244  void orderDimension();
245 };
246 
253 inline int FFDLattice::accessMapNodes(int i, int j, int k){
254  return(accessPointIndex(m_mapNodes[0][i], m_mapNodes[1][j], m_mapNodes[2][k]));
255 };
256 
257 REGISTER_PORT(M_DISPLS, MC_VECARR3, MD_FLOAT,__FFDLATTICE_HPP__)
258 REGISTER_PORT(M_FILTER, MC_SCALAR, MD_MPVECFLOAT_,__FFDLATTICE_HPP__)
259 REGISTER_PORT(M_DEG, MC_ARRAY3, MD_INT,__FFDLATTICE_HPP__)
260 REGISTER_PORT(M_NURBSWEIGHTS, MC_VECTOR, MD_FLOAT,__FFDLATTICE_HPP__)
263 
264 REGISTER(BaseManipulation, FFDLattice, "mimmo.FFDLattice")
265 }
266 
267 #endif /* __FFDLATTICE_HPP__ */
Abstract Interface class for Elementary Shape Representation.
Definition: BasicShapes.hpp:91
#define M_GDISPLS
std::array< int, 3 > iarray3E
ivector2D m_mapNodes
Definition: FFDLattice.hpp:141
void swap(FFDLattice &) noexcept
Definition: FFDLattice.cpp:97
#define M_DISPLS
FFDLattice & operator=(FFDLattice other)
Definition: FFDLattice.cpp:88
CoordType
Specify type of conditions to distribute NURBS nodes in a given coordinate of the shape.
Definition: BasicShapes.hpp:49
iarray3E getDegrees()
Definition: FFDLattice.cpp:224
#define MC_ARRAY3
#define MD_FLOAT
std::vector< darray3E > dvecarr3E
void returnKnotsStructure(dvector2D &, ivector2D &)
Definition: FFDLattice.cpp:194
void setDisplacements(dvecarr3E displacements)
Definition: FFDLattice.cpp:284
void setDisplGlobal(bool flag)
Definition: FFDLattice.cpp:298
std::vector< long > livector1D
int accessPointIndex(int i, int j, int k)
void setDegrees(iarray3E curveDegrees)
Definition: FFDLattice.cpp:273
dmpvector1D * getFilter()
Definition: FFDLattice.cpp:245
#define MD_COORDT
void setNodalWeight(double, int)
Definition: FFDLattice.cpp:453
dvector1D m_weights
Definition: FFDLattice.hpp:139
#define MC_SCALAR
virtual void flushSectionXML(bitpit::Config::Section &slotXML, std::string name="")
std::vector< int > ivector1D
#define MD_MPVECARR3FLOAT_
#define REGISTER_PORT(Name, Container, Datatype, ManipBlock)
void plotCloud(std::string directory, std::string filename, int counter, bool binary, bool deformed)
Definition: FFDLattice.cpp:546
dmpvecarr3E * getDeformation()
Definition: FFDLattice.cpp:254
void plotGrid(std::string directory, std::string filename, int counter, bool binary, bool deformed)
Definition: FFDLattice.cpp:506
std::vector< double > dvector1D
virtual ~FFDLattice()
Definition: FFDLattice.cpp:65
ShapeType
Identifies the type of elemental shape supported by BasicShape class.
Definition: BasicShapes.hpp:38
#define M_NURBSWEIGHTS
#define MC_VECTOR
ivector2D m_mapEff
Definition: FFDLattice.hpp:138
void setFilter(dmpvector1D *)
Definition: FFDLattice.cpp:489
#define M_DEG
#define M_NURBSCOORDTYPE
dvecarr3E * getDisplacements()
Definition: FFDLattice.cpp:236
std::vector< ivector1D > ivector2D
std::vector< dvector1D > dvector2D
void setLattice(darray3E &origin, darray3E &span, ShapeType, iarray3E &dimensions, iarray3E &degrees)
Definition: FFDLattice.cpp:316
#define MD_MPVECFLOAT_
std::array< double, 3 > darray3E
dmpvecarr3E m_gdispl
Definition: FFDLattice.hpp:142
ivector1D getKnotsDimension()
Definition: FFDLattice.cpp:164
dvecarr3E convertDisplToXYZ()
Definition: FFDLattice.cpp:756
#define MD_INT
Free Form Deformation of a 3D surface and point clouds, with structured lattice.
Definition: FFDLattice.hpp:133
dvector1D getWeights()
Definition: FFDLattice.cpp:184
#define MC_VECARR3
Structured 3D Cartesian Mesh.
Definition: Lattice.hpp:103
virtual void absorbSectionXML(const bitpit::Config::Section &slotXML, std::string name="")
virtual void plotOptionalResults()
#define M_FILTER
#define REGISTER(Base, Derived, name)
Definition: factory.hpp:206
virtual bool build()