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.
symmetry_utility.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // license: OptimizationApplication/license.txt
9 //
10 // Main authors: Reza Najian Asl, https://github.com/RezaNajian
11 //
12 
13 #ifndef SYMMETRY_UTILITY_H
14 #define SYMMETRY_UTILITY_H
15 
16 // ------------------------------------------------------------------------------
17 // System includes
18 // ------------------------------------------------------------------------------
19 #include <iostream>
20 #include <string>
21 
22 // ------------------------------------------------------------------------------
23 // Project includes
24 // ------------------------------------------------------------------------------
25 #include "includes/model_part.h"
27 
28 // ==============================================================================
29 
30 namespace Kratos
31 {
32 
35 
39 
43 
47 
51 
53 
57 class KRATOS_API(OPTIMIZATION_APPLICATION) SymmetryUtility
58 {
59 public:
62 
63  // Type definitions for better reading later
66  typedef ModelPart::NodeType::Pointer NodeTypePointer;
67  typedef std::vector<NodeTypePointer> NodeVector;
68  typedef std::vector<NodeTypePointer>::iterator NodeVectorIterator;
69  typedef std::vector<double> DoubleVector;
70  typedef std::vector<double>::iterator DoubleVectorIterator;
71 
72  // Type definitions for tree-search
75 
78 
82 
84  SymmetryUtility( std::string Name, ModelPart& rModelPart, Parameters SymmetrySettings );
85 
87  virtual ~SymmetryUtility()
88  {
89  }
90 
92  // point on the plane
94  // normal to the plane
96  //Reflection Matrix
98  // map
99  std::vector<std::pair <NodeTypePointer,NodeTypePointer>> Map;
100  };
101 
103  // point on the axis
105  // angle
106  double Angle;
107  // number of rotational operations
108  int NumRot;
109  // axis
111  // pre-computed rotation matrices
112  std::vector<Matrix> RotationMatrices;
113  // map
114  std::vector<std::pair <NodeTypePointer,NodeVector>> Map;
115  };
116 
117 
121 
122 
126 
127  // ==============================================================================
128  void Initialize();
129  // --------------------------------------------------------------------------
130  void Update();
131  // --------------------------------------------------------------------------
132  void ApplyOnVectorField( const Variable<array_3d> &rNodalVariable );
133  // --------------------------------------------------------------------------
134  void ApplyOnScalarField( const Variable<double> &rNodalVariable );
135  // ==============================================================================
136 
140 
141 
145 
146 
150 
152  virtual std::string Info() const
153  {
154  return "SymmetryUtility";
155  }
156 
158  virtual void PrintInfo(std::ostream& rOStream) const
159  {
160  rOStream << "SymmetryUtility";
161  }
162 
164  virtual void PrintData(std::ostream& rOStream) const
165  {
166  }
167 
169 
170 
171 private:
174 
175 
179 
180  // ==============================================================================
181  // Initialized by class constructor
182  // ==============================================================================
183  std::string mUtilName;
184  ModelPart& mrModelPart;
185  Parameters mSymmetrySettings;
186  bool mAxisSymmetry=false;
187  RotationalSymmetryData mRotationalSymmetryData;
188  bool mPlaneSymmetry=false;
189  PlaneSymmetryData mPlaneSymmetryData;
190 
191  // ==============================================================================
192  // Variables for spatial search
193  // ==============================================================================
194  NodeVector mListOfNodesOfModelPart;
195  KDTree::Pointer mpSearchTree;
196 
200 
201 
205 
206 
210  NodeTypePointer GetRotatedNode(NodeType& rNode, int RotationIndex);
211  NodeTypePointer GetReflectedNode(NodeType& rNode);
212  void GetRotationMatrix(double Angle, Matrix& rRotMat);
213 
214 
216 
217 
218 }; // Class SymmetryUtility
219 
221 
222 
223 } // namespace Kratos.
224 
225 #endif // SYMMETRY_UTILITY_H
Short class definition.
Definition: bucket.h:57
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
Short class definition.
Definition: symmetry_utility.h:58
Bucket< 3, NodeType, NodeVector, NodeTypePointer, NodeVectorIterator, DoubleVectorIterator > BucketType
Definition: symmetry_utility.h:73
virtual std::string Info() const
Turn back information as a string.
Definition: symmetry_utility.h:152
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: symmetry_utility.h:158
std::vector< NodeTypePointer >::iterator NodeVectorIterator
Definition: symmetry_utility.h:68
ModelPart::NodeType::Pointer NodeTypePointer
Definition: symmetry_utility.h:66
std::vector< double >::iterator DoubleVectorIterator
Definition: symmetry_utility.h:70
std::vector< double > DoubleVector
Definition: symmetry_utility.h:69
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: symmetry_utility.h:164
ModelPart::NodeType NodeType
Definition: symmetry_utility.h:65
Tree< KDTreePartition< BucketType > > KDTree
Definition: symmetry_utility.h:74
std::vector< NodeTypePointer > NodeVector
Definition: symmetry_utility.h:67
array_1d< double, 3 > array_3d
Definition: symmetry_utility.h:64
virtual ~SymmetryUtility()
Destructor.
Definition: symmetry_utility.h:87
KRATOS_CLASS_POINTER_DEFINITION(SymmetryUtility)
Pointer definition of SymmetryUtility.
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
static void GetRotationMatrix(const array_1d< double, 3 > &EulerAngles, double rotation_matrix[3][3])
Definition: GeometryFunctions.h:1549
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
Definition: symmetry_utility.h:91
std::vector< std::pair< NodeTypePointer, NodeTypePointer > > Map
Definition: symmetry_utility.h:99
array_1d< double, 3 > Normal
Definition: symmetry_utility.h:95
array_1d< double, 3 > Point
Definition: symmetry_utility.h:93
Matrix ReflectionMatrix
Definition: symmetry_utility.h:97
Definition: symmetry_utility.h:102
array_1d< double, 3 > Point
Definition: symmetry_utility.h:104
double Angle
Definition: symmetry_utility.h:106
array_1d< double, 3 > Axis
Definition: symmetry_utility.h:110
std::vector< std::pair< NodeTypePointer, NodeVector > > Map
Definition: symmetry_utility.h:114
int NumRot
Definition: symmetry_utility.h:108
std::vector< Matrix > RotationMatrices
Definition: symmetry_utility.h:112