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_symmetric.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: Armin Geiser, https://github.com/armingeiser
8 //
9 // ==============================================================================
10 
11 #ifndef MAPPER_VERTEX_MORPHING_SYMMETRIC_H
12 #define MAPPER_VERTEX_MORPHING_SYMMETRIC_H
13 
14 // System includes
15 #include <iostream>
16 #include <string>
17 
18 // Project includes
19 #include "includes/define.h"
20 #include "includes/model_part.h"
22 #include "spaces/ublas_space.h"
23 #include "mapper_base.h"
24 #include "custom_utilities/filter_function.h"
25 #include "symmetry_base.h"
26 
27 // ==============================================================================
28 
29 namespace Kratos
30 {
31 
34 
36 
39 class KRATOS_API(SHAPE_OPTIMIZATION_APPLICATION) MapperVertexMorphingSymmetric : public Mapper
40 {
41 public:
44 
45  // Type definitions for better reading later
46  typedef Node NodeType;
47  typedef NodeType::Pointer NodePointerType;
48  typedef std::vector<NodePointerType> NodeVectorType;
49  typedef std::vector<NodePointerType>::iterator NodeIteratorType;
50  typedef std::vector<double>::iterator DoubleVectorIteratorType;
52 
53  // Type definitions for linear algebra including sparse systems
57 
58  // Type definitions for tree-search
61 
64 
68 
70  MapperVertexMorphingSymmetric( ModelPart& rOriginModelPart, ModelPart& rDestinationModelPart, Parameters MapperSettings )
71  : mrOriginModelPart(rOriginModelPart),
72  mrDestinationModelPart(rDestinationModelPart),
73  mMapperSettings(MapperSettings),
74  mFilterRadius(MapperSettings["filter_radius"].GetDouble())
75  {
76  }
77 
80  {
81  }
82 
86 
87  void Initialize() override;
88 
89  void Map( const Variable<array_3d> &rOriginVariable, const Variable<array_3d> &rDestinationVariable) override;
90 
91  void Map( const Variable<double> &rOriginVariable, const Variable<double> &rDestinationVariable) override;
92 
93  void InverseMap( const Variable<array_3d> &rDestinationVariable, const Variable<array_3d> &rOriginVariable) override;
94 
95  void InverseMap(const Variable<double> &rDestinationVariable, const Variable<double> &rOriginVariable) override;
96 
97  void Update() override;
98 
102 
104  virtual std::string Info() const override
105  {
106  return "MapperVertexMorphingSymmetric";
107  }
108 
110  virtual void PrintInfo(std::ostream& rOStream) const override
111  {
112  rOStream << "MapperVertexMorphingSymmetric";
113  }
114 
116  virtual void PrintData(std::ostream& rOStream) const override
117  {
118  }
119 
120 
122 
123 protected:
126 
127  // Initialized by class constructor
132  bool mIsMappingInitialized = false;
133 
137 
138  virtual void InitializeComputationOfMappingMatrix();
139 
141 
142 private:
145 
146  // Variables for spatial search
147  unsigned int mBucketSize = 100;
148  Kratos::unique_ptr<KDTree> mpSearchTree;
149 
150  // Variables for mapping
151  SparseMatrixType mMappingMatrix;
152  double mFilterRadius;
153 
155 
159 
160  void CreateFilterFunction();
161 
162  void InitializeMappingVariables();
163 
164  void AssignMappingIds();
165 
166  void CreateSearchTreeWithAllNodesInOriginModelPart();
167 
168  void ComputeMappingMatrix();
169 
170  void AllocateMatrix();
171 
172  virtual void ComputeWeightForAllNeighbors( const ModelPart::NodeType& destination_node,
173  const NodeVectorType& neighbor_nodes,
174  const unsigned int number_of_neighbors,
175  std::vector<double>& list_of_weights,
176  double& sum_of_weights );
177 
178  void FillMappingMatrixWithWeights( const ModelPart::NodeType& destination_node,
179  const NodeVectorType& neighbor_nodes,
180  const unsigned int number_of_neighbors,
181  const std::vector<double>& list_of_weights,
182  const std::vector<bool>& transform,
183  const double& sum_of_weights );
184 
185  double GetVertexMorphingRadius(const NodeType& rNode) const override
186  {
187  return mFilterRadius;
188  }
189 
190 }; // Class MapperVertexMorphingSymmetric
191 
192 } // namespace Kratos.
193 
194 #endif // MAPPER_VERTEX_MORPHING_SYMMETRIC_H
Short class definition.
Definition: bucket.h:57
Base Class for all Mappers.
Definition: mapper.h:43
Short class definition.
Definition: mapper_vertex_morphing_symmetric.h:40
virtual ~MapperVertexMorphingSymmetric()
Destructor.
Definition: mapper_vertex_morphing_symmetric.h:79
Bucket< 3, NodeType, NodeVectorType, NodePointerType, NodeIteratorType, DoubleVectorIteratorType > BucketType
Definition: mapper_vertex_morphing_symmetric.h:59
TUblasSparseSpace< double > SparseSpaceType
Definition: mapper_vertex_morphing_symmetric.h:54
SparseSpaceType::MatrixType SparseMatrixType
Definition: mapper_vertex_morphing_symmetric.h:55
array_1d< double, 3 > array_3d
Definition: mapper_vertex_morphing_symmetric.h:51
virtual void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: mapper_vertex_morphing_symmetric.h:110
std::vector< double >::iterator DoubleVectorIteratorType
Definition: mapper_vertex_morphing_symmetric.h:50
KRATOS_CLASS_POINTER_DEFINITION(MapperVertexMorphingSymmetric)
Pointer definition of MapperVertexMorphingSymmetric.
SparseSpaceType::VectorType VectorType
Definition: mapper_vertex_morphing_symmetric.h:56
std::vector< NodePointerType > NodeVectorType
Definition: mapper_vertex_morphing_symmetric.h:48
virtual std::string Info() const override
Turn back information as a string.
Definition: mapper_vertex_morphing_symmetric.h:104
MapperVertexMorphingSymmetric(ModelPart &rOriginModelPart, ModelPart &rDestinationModelPart, Parameters MapperSettings)
Default constructor.
Definition: mapper_vertex_morphing_symmetric.h:70
Node NodeType
Definition: mapper_vertex_morphing_symmetric.h:46
Parameters mMapperSettings
Definition: mapper_vertex_morphing_symmetric.h:130
ModelPart & mrOriginModelPart
Definition: mapper_vertex_morphing_symmetric.h:128
Kratos::unique_ptr< FilterFunction > mpFilterFunction
Definition: mapper_vertex_morphing_symmetric.h:131
std::vector< NodePointerType >::iterator NodeIteratorType
Definition: mapper_vertex_morphing_symmetric.h:49
ModelPart & mrDestinationModelPart
Definition: mapper_vertex_morphing_symmetric.h:129
virtual void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: mapper_vertex_morphing_symmetric.h:116
NodeType::Pointer NodePointerType
Definition: mapper_vertex_morphing_symmetric.h:47
Tree< KDTreePartition< BucketType > > KDTree
Definition: mapper_vertex_morphing_symmetric.h:60
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
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
std::unique_ptr< T > unique_ptr
Definition: smart_pointers.h:33