KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
mapper_vertex_morphing.h
Go to the documentation of this file.
1 // ==============================================================================
2 // KratosShapeOptimizationApplication
3 //
4 // License: BSD License
5 // license: ShapeOptimizationApplication/license.txt
6 //
7 // Main authors: Baumgaertner Daniel, https://github.com/dbaumgaertner
8 //
9 // ==============================================================================
10 
11 #ifndef MAPPER_VERTEX_MORPHING_H
12 #define MAPPER_VERTEX_MORPHING_H
13 
14 // ------------------------------------------------------------------------------
15 // System includes
16 // ------------------------------------------------------------------------------
17 #include <iostream>
18 #include <string>
19 
20 // ------------------------------------------------------------------------------
21 // Project includes
22 // ------------------------------------------------------------------------------
23 #include "includes/model_part.h"
25 #include "spaces/ublas_space.h"
26 #include "mapper_base.h"
27 #include "custom_utilities/filter_function.h"
28 
29 // ==============================================================================
30 
31 namespace Kratos
32 {
33 
36 
40 
44 
48 
52 
54 
57 class KRATOS_API(SHAPE_OPTIMIZATION_APPLICATION) MapperVertexMorphing : public Mapper
58 {
59 public:
62 
63  // Type definitions for better reading later
64  typedef Node NodeType;
65  typedef Node ::Pointer NodeTypePointer;
66  typedef std::vector<NodeType::Pointer> NodeVector;
67  typedef std::vector<NodeType::Pointer>::iterator NodeIterator;
68  typedef std::vector<double>::iterator DoubleVectorIterator;
71 
72  // Type definitions for linear algebra including sparse systems
76 
77  // Type definitions for tree-search
80 
83 
87 
89  MapperVertexMorphing( ModelPart& rOriginModelPart, ModelPart& rDestinationModelPart, Parameters MapperSettings )
90  : mrOriginModelPart(rOriginModelPart),
91  mrDestinationModelPart(rDestinationModelPart),
92  mMapperSettings(MapperSettings),
93  mFilterRadius(MapperSettings["filter_radius"].GetDouble())
94  {
95  }
96 
99  {
100  }
101 
105 
106 
110 
111  // --------------------------------------------------------------------------
112  void Initialize() override;
113 
114  // --------------------------------------------------------------------------
115  void Map( const Variable<array_3d> &rOriginVariable, const Variable<array_3d> &rDestinationVariable) override;
116 
117  // --------------------------------------------------------------------------
118  void Map( const Variable<double> &rOriginVariable, const Variable<double> &rDestinationVariable) override;
119 
120  // --------------------------------------------------------------------------
121  void InverseMap( const Variable<array_3d> &rDestinationVariable, const Variable<array_3d> &rOriginVariable) override;
122 
123  // --------------------------------------------------------------------------
124  void InverseMap(const Variable<double> &rDestinationVariable, const Variable<double> &rOriginVariable) override;
125 
126  // --------------------------------------------------------------------------
127  void Update() override;
128 
129  // --------------------------------------------------------------------------
130 
134 
135 
139 
140 
144 
146  virtual std::string Info() const override
147  {
148  return "MapperVertexMorphing";
149  }
150 
152  virtual void PrintInfo(std::ostream& rOStream) const override
153  {
154  rOStream << "MapperVertexMorphing";
155  }
156 
158  virtual void PrintData(std::ostream& rOStream) const override
159  {
160  }
161 
162 
166 
167 
169 
170 protected:
173 
174 
178 
179  // Initialized by class constructor
183  FilterFunction::UniquePointer mpFilterFunction;
184  bool mIsMappingInitialized = false;
185 
189 
190 
194 
195  virtual void InitializeComputationOfMappingMatrix();
196 
197  double GetVertexMorphingRadius(const NodeType& rNode) const override
198  {
199  return mFilterRadius;
200  }
201 
205 
206 
210 
211 
215 
216 
218 
219 private:
222 
223 
227 
228  // Variables for spatial search
229  unsigned int mBucketSize = 100;
230  NodeVector mListOfNodesInOriginModelPart;
231  KDTree::Pointer mpSearchTree;
232 
233  // Variables for mapping
234  SparseMatrixType mMappingMatrix;
235  std::vector<Vector> mValuesOrigin;
236  std::vector<Vector> mValuesDestination;
237  double mFilterRadius;
238 
242 
243 
247 
248  // --------------------------------------------------------------------------
249  void CreateListOfNodesInOriginModelPart();
250 
251  // --------------------------------------------------------------------------
252  void CreateFilterFunction();
253 
254  // --------------------------------------------------------------------------
255  void InitializeMappingVariables();
256 
257  // --------------------------------------------------------------------------
258  void AssignMappingIds();
259 
260  // --------------------------------------------------------------------------
261  void CreateSearchTreeWithAllNodesInOriginModelPart();
262 
263  // --------------------------------------------------------------------------
264  void ComputeMappingMatrix();
265 
266  // --------------------------------------------------------------------------
267  virtual void ComputeWeightForAllNeighbors( const ModelPart::NodeType& origin_node,
268  const NodeVector& neighbor_nodes,
269  const unsigned int number_of_neighbors,
270  std::vector<double>& list_of_weights,
271  double& sum_of_weights );
272 
273  // --------------------------------------------------------------------------
274  void FillMappingMatrixWithWeights( ModelPart::NodeType& origin_node,
275  NodeVector& neighbor_nodes,
276  unsigned int number_of_neighbors,
277  std::vector<double>& list_of_weights,
278  double& sum_of_weights );
279 
280  // --------------------------------------------------------------------------
281 
285 
286 
290 
291 
295 
297 // MapperVertexMorphing& operator=(MapperVertexMorphing const& rOther);
298 
300 // MapperVertexMorphing(MapperVertexMorphing const& rOther);
301 
302 
304 
305 }; // Class MapperVertexMorphing
306 
308 
311 
312 
316 
318 
319 
320 } // namespace Kratos.
321 
322 #endif // MAPPER_VERTEX_MORPHING_H
Short class definition.
Definition: bucket.h:57
Base Class for all Mappers.
Definition: mapper.h:43
Short class definition.
Definition: mapper_vertex_morphing.h:58
virtual void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: mapper_vertex_morphing.h:152
KRATOS_CLASS_POINTER_DEFINITION(MapperVertexMorphing)
Pointer definition of MapperVertexMorphing.
virtual std::string Info() const override
Turn back information as a string.
Definition: mapper_vertex_morphing.h:146
std::vector< NodeType::Pointer >::iterator NodeIterator
Definition: mapper_vertex_morphing.h:67
Parameters mMapperSettings
Definition: mapper_vertex_morphing.h:182
ModelPart & mrDestinationModelPart
Definition: mapper_vertex_morphing.h:181
SparseSpaceType::MatrixType SparseMatrixType
Definition: mapper_vertex_morphing.h:74
Tree< KDTreePartition< BucketType > > KDTree
Definition: mapper_vertex_morphing.h:79
ModelPart & mrOriginModelPart
Definition: mapper_vertex_morphing.h:180
Node ::Pointer NodeTypePointer
Definition: mapper_vertex_morphing.h:65
ModelPart::ConditionsContainerType ConditionsArrayType
Definition: mapper_vertex_morphing.h:69
std::vector< NodeType::Pointer > NodeVector
Definition: mapper_vertex_morphing.h:66
double GetVertexMorphingRadius(const NodeType &rNode) const override
Definition: mapper_vertex_morphing.h:197
MapperVertexMorphing(ModelPart &rOriginModelPart, ModelPart &rDestinationModelPart, Parameters MapperSettings)
Default constructor.
Definition: mapper_vertex_morphing.h:89
Node NodeType
Definition: mapper_vertex_morphing.h:64
std::vector< double >::iterator DoubleVectorIterator
Definition: mapper_vertex_morphing.h:68
array_1d< double, 3 > array_3d
Definition: mapper_vertex_morphing.h:70
FilterFunction::UniquePointer mpFilterFunction
Definition: mapper_vertex_morphing.h:183
Bucket< 3, NodeType, NodeVector, NodeTypePointer, NodeIterator, DoubleVectorIterator > BucketType
Definition: mapper_vertex_morphing.h:78
SparseSpaceType::VectorType VectorType
Definition: mapper_vertex_morphing.h:75
UblasSpace< double, CompressedMatrix, Vector > SparseSpaceType
Definition: mapper_vertex_morphing.h:73
virtual void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: mapper_vertex_morphing.h:158
virtual ~MapperVertexMorphing()
Destructor.
Definition: mapper_vertex_morphing.h:98
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MeshType::ConditionsContainerType ConditionsContainerType
Condintions container. A vector set of Conditions with their Id's as key.
Definition: model_part.h:183
This class defines the node.
Definition: node.h:65
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
A generic tree data structure for spatial partitioning.
Definition: tree.h:190
A class template for handling data types, matrices, and vectors in a Ublas space.
Definition: ublas_space.h:121
TMatrixType MatrixType
The matrix type considered.
Definition: ublas_space.h:133
TVectorType VectorType
The vector type considered.
Definition: ublas_space.h:136
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
void ComputeWeightForAllNeighbors(double &rSumOfWeights, std::vector< double > &rListOfWeights, const FilterFunction &rFilterFunction, const DampingFunction &rDampingFunction, const double Radius, const EntityPoint< TEntityType > &rDesignPoint, const std::vector< typename EntityPoint< TEntityType >::Pointer > &rNeighbourNodes, const std::vector< typename EntityPoint< TEntityType >::Pointer > &rDampingNeighbourNodes, const IndexType NumberOfNeighbours, Expression const *const pExpression)
Definition: explicit_filter.cpp:125
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21