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_matrix_free.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_MATRIX_FREE_H
12 #define MAPPER_VERTEX_MORPHING_MATRIX_FREE_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 "mapper_base.h"
26 #include "custom_utilities/filter_function.h"
27 
28 // ==============================================================================
29 
30 namespace Kratos
31 {
32 
35 
39 
43 
47 
51 
53 
57 class KRATOS_API(SHAPE_OPTIMIZATION_APPLICATION) MapperVertexMorphingMatrixFree : 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;
70 
71  // Type definitions for tree-search
74 
77 
81 
83  MapperVertexMorphingMatrixFree( ModelPart& rOriginModelPart, ModelPart& rDestinationModelPart, Parameters MapperSettings )
84  : mrOriginModelPart( rOriginModelPart ),
85  mrDestinationModelPart( rDestinationModelPart ),
86  mMapperSettings( MapperSettings ),
87  mFilterRadius( MapperSettings["filter_radius"].GetDouble() ),
88  mMaxNumberOfNeighbors( MapperSettings["max_nodes_in_filter_radius"].GetInt())
89  {
90  }
91 
94  {
95  }
96 
97 
101 
102 
106 
107  // --------------------------------------------------------------------------
108  void Initialize() override;
109 
110  // --------------------------------------------------------------------------
111  void Map( const Variable<array_3d> &rOriginVariable, const Variable<array_3d> &rDestinationVariable ) override;
112 
113  // --------------------------------------------------------------------------
114  void Map( const Variable<double> &rOriginVariable, const Variable<double> &rDestinationVariable ) override;
115 
116  // --------------------------------------------------------------------------
117  void InverseMap( const Variable<array_3d> &rDestinationVariable, const Variable<array_3d> &rOriginVariable ) override;
118 
119  // --------------------------------------------------------------------------
120  void InverseMap( const Variable<double> &rDestinationVariable, const Variable<double> &rOriginVariable ) override;
121 
122  // --------------------------------------------------------------------------
123  void Update() override;
124 
125  // --------------------------------------------------------------------------
126 
130 
131  FilterFunction::UniquePointer mpFilterFunction;
132 
136 
137 
141 
143  virtual std::string Info() const override
144  {
145  return "MapperVertexMorphingMatrixFree";
146  }
147 
149  virtual void PrintInfo(std::ostream& rOStream) const override
150  {
151  rOStream << "MapperVertexMorphingMatrixFree";
152  }
153 
155  virtual void PrintData(std::ostream& rOStream) const override
156  {
157  }
158 
159 
163 
164 
166 
167 protected:
170 
171 
175 
176 
180 
181 
185 
186 
190 
191 
195 
196 
200 
201 
203 
204 private:
207 
208 
212 
213  // Initialized by class constructor
214  ModelPart& mrOriginModelPart;
215  ModelPart& mrDestinationModelPart;
216  Parameters mMapperSettings;
217  double mFilterRadius;
218  unsigned int mMaxNumberOfNeighbors;
219 
220  // Variables for spatial search
221  unsigned int mBucketSize = 100;
222  NodeVector mListOfNodesInOriginModelPart;
223  KDTree::Pointer mpSearchTree;
224 
225  // Variables for mapping
226  std::vector<Vector> mValuesOrigin;
227  std::vector<Vector> mValuesDestination;
228  bool mIsMappingInitialized = false;
229 
233 
234 
238 
239  // --------------------------------------------------------------------------
240  void CreateListOfNodesInOriginModelPart();
241 
242  // --------------------------------------------------------------------------
243  void CreateFilterFunction();
244 
245  // --------------------------------------------------------------------------
246  void InitializeMappingVariables();
247 
248  // --------------------------------------------------------------------------
249  void AssignMappingIds();
250  // --------------------------------------------------------------------------
251  void CreateSearchTreeWithAllNodesInOriginModelPart();
252 
253  // --------------------------------------------------------------------------
254  void ThrowWarningIfNumberOfNeighborsExceedsLimit(ModelPart::NodeType& given_node, unsigned int number_of_neighbors);
255 
256  // --------------------------------------------------------------------------
257  virtual void ComputeWeightForAllNeighbors( const ModelPart::NodeType& design_node,
258  const NodeVector& neighbor_nodes,
259  const unsigned int number_of_neighbors,
260  std::vector<double>& list_of_weights,
261  double& sum_of_weights );
262 
263  // --------------------------------------------------------------------------
264  double GetVertexMorphingRadius(const NodeType& rNode) const override
265  {
266  return mFilterRadius;
267  }
268 
272 
273 
277 
278 
282 
284 // MapperVertexMorphingMatrixFree& operator=(MapperVertexMorphingMatrixFree const& rOther);
285 
287 // MapperVertexMorphingMatrixFree(MapperVertexMorphingMatrixFree const& rOther);
288 
289 
291 
292 }; // Class MapperVertexMorphingMatrixFree
293 
295 
298 
299 
303 
305 
306 
307 } // namespace Kratos.
308 
309 #endif // MAPPER_VERTEX_MORPHING_MATRIX_FREE_H
Short class definition.
Definition: bucket.h:57
Base Class for all Mappers.
Definition: mapper.h:43
Short class definition.
Definition: mapper_vertex_morphing_matrix_free.h:58
virtual std::string Info() const override
Turn back information as a string.
Definition: mapper_vertex_morphing_matrix_free.h:143
virtual void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: mapper_vertex_morphing_matrix_free.h:155
Bucket< 3, NodeType, NodeVector, NodeTypePointer, NodeIterator, DoubleVectorIterator > BucketType
Definition: mapper_vertex_morphing_matrix_free.h:72
ModelPart::ConditionsContainerType ConditionsArrayType
Definition: mapper_vertex_morphing_matrix_free.h:69
std::vector< double >::iterator DoubleVectorIterator
Definition: mapper_vertex_morphing_matrix_free.h:68
std::vector< NodeType::Pointer >::iterator NodeIterator
Definition: mapper_vertex_morphing_matrix_free.h:67
MapperVertexMorphingMatrixFree(ModelPart &rOriginModelPart, ModelPart &rDestinationModelPart, Parameters MapperSettings)
Default constructor.
Definition: mapper_vertex_morphing_matrix_free.h:83
virtual ~MapperVertexMorphingMatrixFree()
Destructor.
Definition: mapper_vertex_morphing_matrix_free.h:93
Tree< KDTreePartition< BucketType > > KDTree
Definition: mapper_vertex_morphing_matrix_free.h:73
std::vector< NodeType::Pointer > NodeVector
Definition: mapper_vertex_morphing_matrix_free.h:66
Node ::Pointer NodeTypePointer
Definition: mapper_vertex_morphing_matrix_free.h:65
Node NodeType
Definition: mapper_vertex_morphing_matrix_free.h:64
FilterFunction::UniquePointer mpFilterFunction
Definition: mapper_vertex_morphing_matrix_free.h:131
KRATOS_CLASS_POINTER_DEFINITION(MapperVertexMorphingMatrixFree)
Pointer definition of MapperVertexMorphingMatrixFree.
virtual void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: mapper_vertex_morphing_matrix_free.h:149
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
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