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.
uniform_refinement_utility.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Miguel Maso Sotomayor
11 //
12 
13 
14 #if !defined( KRATOS_UNIFORM_REFINEMENT_UTILITY_H_INCLUDED )
15 #define KRATOS_UNIFORM_REFINEMENT_UTILITY_H_INCLUDED
16 
17 
18 // System includes
19 #include <string>
20 #include <iostream>
21 #include <unordered_map>
22 
23 
24 // External includes
25 
26 
27 // Project includes
28 #include "includes/key_hash.h"
29 #include "includes/define.h"
30 #include "includes/node.h"
31 #include "includes/element.h"
32 #include "includes/condition.h"
33 #include "includes/model_part.h"
39 
40 
41 namespace Kratos
42 {
45 
48 
52 
56 
60 
64 
83 {
84 public:
87 
91  typedef Node NodeType;
92 
97 
102 
107 
111  typedef std::size_t IndexType;
112 
119 
123  typedef std::pair<IndexType, IndexType> EdgeKeyType;
124  typedef std::array<IndexType, 4> FaceKeyType;
125  typedef std::map<EdgeKeyType, IndexType> NodesInEdgeMapType;
126  typedef std::unordered_map<FaceKeyType, IndexType, KeyHasherRange<FaceKeyType>, KeyComparorRange<FaceKeyType>> NodesInFaceMapType;
127 
131  typedef std::vector<IndexType> IndexVectorType;
132  typedef std::vector<std::string> StringVectorType;
133  typedef std::unordered_map<IndexType, IndexType> IndexIndexMapType;
134  typedef std::unordered_map<IndexType, IndexVectorType> IndexIndexVectorMapType;
135  typedef std::unordered_map<IndexType, StringVectorType> IndexStringVectorMapType;
136 
139 
143 
145  UniformRefinementUtility(ModelPart& rModelPart);
146 
148  virtual ~UniformRefinementUtility();
149 
150 
154 
155 
159 
163  void Refine(int& rFinalRefinementLevel);
164 
171  void SetCustomIds(IndexType& rNodeId, IndexType& rElemId, IndexType& rCondId);
172 
179  void GetLastCreatedIds(IndexType& rNodeId, IndexType& rElemId, IndexType& rCondId);
180 
185  void RemoveRefinedEntities(Flags ThisFlag);
186 
190 
191 
195 
196 
200 
202  virtual std::string Info() const;
203 
205  virtual void PrintInfo(std::ostream& rOStream) const;
206 
208  virtual void PrintData(std::ostream& rOStream) const;
209 
210 
214 
215 
217 
218 protected:
221 
222 
226 
227 
231 
232 
236 
237 
241 
242 
246 
247 
251 
252 
254 
255 private:
258 
259 
263 
264  ModelPart& mrModelPart;
265  IndexType mDimension;
266 
267  IndexType mLastNodeId;
268  IndexType mLastElemId;
269  IndexType mLastCondId;
270  IndexType mStepDataSize;
271  IndexType mBufferSize;
272 
274 
275  NodesInEdgeMapType mNodesMap;
276  NodesInFaceMapType mNodesInFaceMap;
277 
278  IndexIndexMapType mNodesTags;
279  IndexIndexMapType mElementsTags;
280  IndexIndexMapType mConditionsTags;
281  IndexStringVectorMapType mCollections;
282 
286 
287 
291 
300  void ExecuteDivision(
301  const int& rDivision,
302  IndexIndexVectorMapType& rTagNodes,
303  IndexIndexVectorMapType& rTagElems,
304  IndexIndexVectorMapType& rTagConds
305  );
306 
314  typename NodeType::Pointer GetNodeInEdge(
315  const EdgeType& rEdge,
316  const int& rNumberOfDivisions,
317  IndexIndexVectorMapType& rTagNodes,
318  const IndexType& rCollectionTag
319  );
320 
330  typename NodeType::Pointer CreateNodeInEdge(
331  const EdgeType& rEdge,
332  const int& rNumberOfDivisions,
333  const EdgeKeyType& rNodeKey
334  );
335 
343  typename NodeType::Pointer GetNodeInFace(
344  const FaceType& rFace,
345  const int& rNumberOfDivisions,
346  IndexIndexVectorMapType& rTagNodes,
347  const IndexType& rCollectionTag
348  );
349 
358  typename NodeType::Pointer CreateNodeInFace(
359  const FaceType& rFace,
360  const int& rNumberOfDivisions,
361  const FaceKeyType& rNodeKey
362  );
363 
371  typename NodeType::Pointer GetNodeInBody(
372  const BodyType& rBody,
373  const int& rNumberOfDivisions,
374  IndexIndexVectorMapType& rTagNodes,
375  const IndexType& rCollectionTag
376  );
377 
385  void CalculateNodalStepData(
386  NodeType::Pointer pNewNode,
387  const NodeType::Pointer pNode0,
388  const NodeType::Pointer pNode1
389  );
390 
400  void CalculateNodalStepData(
401  NodeType::Pointer pNewNode,
402  const NodeType::Pointer pNode0,
403  const NodeType::Pointer pNode1,
404  const NodeType::Pointer pNode2,
405  const NodeType::Pointer pNode3
406  );
407 
414  void CalculateNodalStepData(
415  NodeType::Pointer pNewNode,
416  const BodyType& rBody
417  );
418 
425  void AddOtherFatherNodes(
426  GlobalPointersVector<NodeType>& rThisFatherNodes,
427  std::vector<double>& rThisFatherWeights,
428  GlobalPointersVector<NodeType>& rOtherFatherNodes,
429  const std::vector<double>& rOtherFatherWeights,
430  const double& rWeight = 0.5
431  );
432 
439  void CreateElement(
440  ElementsArrayType::iterator pOriginElement,
441  PointerVector<NodeType>& rThisNodes,
442  const int& rNumberOfDivisions,
443  IndexIndexVectorMapType& rTagElems
444  );
445 
452  void CreateCondition(
453  ConditionsArrayType::iterator pOriginCondition,
454  PointerVector<NodeType>& rThisNodes,
455  const int& rNumberOfDivisions,
456  IndexIndexVectorMapType& rTagConds
457  );
458 
466  PointerVector<NodeType> GetSubLineNodes(
467  const int Position,
468  const Geometry<NodeType>& rGeom,
469  NodeType::Pointer& rMiddleNode
470  );
471 
480  PointerVector<NodeType> GetSubTriangleNodes(
481  const int Position,
482  const Geometry<NodeType>& rGeom,
483  std::vector<NodeType::Pointer>& rMiddleNodes
484  );
485 
494  PointerVector<NodeType> GetSubQuadrilateralNodes(
495  const int Position,
496  const Geometry<NodeType>& rGeom,
497  std::vector<NodeType::Pointer>& rMiddleNodes
498  );
499 
508 PointerVector<NodeType> GetSubTetrahedraNodes(
509  const int Position,
510  const Geometry<NodeType>& rGeom,
511  std::vector<NodeType::Pointer>& rMiddleNodes
512  );
513 
522 PointerVector<NodeType> GetSubHexahedraNodes(
523  const int Position,
524  const Geometry<NodeType>& rGeom,
525  std::vector<NodeType::Pointer>& rMiddleNodes
526  );
527 
528 
532 
533 
537 
538 
542 
544  //UniformRefinementUtility& operator=(UniformRefinementUtility const& rOther);
545 
548 
549 
551 
552 }; // Class UniformRefinementUtility
553 
555 
558 
559 
563 
564 
566 inline std::istream& operator >> (std::istream& rIStream,
567  UniformRefinementUtility& rThis);
568 
570 inline std::ostream& operator << (std::ostream& rOStream,
571  const UniformRefinementUtility& rThis)
572 {
573  rThis.PrintInfo(rOStream);
574  rOStream << std::endl;
575  rThis.PrintData(rOStream);
576 
577  return rOStream;
578 }
580 
582 
583 } // namespace Kratos.
584 
585 #endif // KRATOS_UNIFORM_REFINEMENT_UTILITY_H_INCLUDED defined
Definition: flags.h:58
Geometry base class.
Definition: geometry.h:71
This class is a vector which stores global pointers.
Definition: global_pointers_vector.h:61
An eight node hexahedra geometry with linear shape functions.
Definition: hexahedra_3d_8.h:55
An two node 3D line geometry with linear shape functions.
Definition: line_3d_2.h:64
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
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
This class defines the node.
Definition: node.h:65
std::vector< std::unique_ptr< Dof< double > >> DofsContainerType
The DoF container type definition.
Definition: node.h:92
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
A four node 3D quadrilateral geometry with bi-linear shape functions.
Definition: quadrilateral_3d_4.h:76
This class splits all the elements until NUMBER_OF_DIVISIONS reaches the desired value @detail A node...
Definition: uniform_refinement_utility.h:83
void SetCustomIds(IndexType &rNodeId, IndexType &rElemId, IndexType &rCondId)
Set the custom ids which will be used to create new entities.
Definition: uniform_refinement_utility.cpp:149
std::pair< IndexType, IndexType > EdgeKeyType
Definition: uniform_refinement_utility.h:123
std::unordered_map< IndexType, StringVectorType > IndexStringVectorMapType
Definition: uniform_refinement_utility.h:135
Node NodeType
Definition: uniform_refinement_utility.h:91
std::vector< std::string > StringVectorType
Definition: uniform_refinement_utility.h:132
void Refine(int &rFinalRefinementLevel)
Execute the refinement until the final refinement is reached.
Definition: uniform_refinement_utility.cpp:96
virtual std::string Info() const
Turn back information as a string.
Definition: uniform_refinement_utility.cpp:77
ModelPart::NodesContainerType NodesArrayType
Definition: uniform_refinement_utility.h:116
KRATOS_CLASS_POINTER_DEFINITION(UniformRefinementUtility)
Pointer definition of UniformRefinementUtility.
Quadrilateral3D4< NodeType > FaceType
Definition: uniform_refinement_utility.h:101
std::unordered_map< FaceKeyType, IndexType, KeyHasherRange< FaceKeyType >, KeyComparorRange< FaceKeyType > > NodesInFaceMapType
Definition: uniform_refinement_utility.h:126
virtual ~UniformRefinementUtility()
Destructor.
Definition: uniform_refinement_utility.cpp:73
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: uniform_refinement_utility.cpp:89
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: uniform_refinement_utility.cpp:83
void GetLastCreatedIds(IndexType &rNodeId, IndexType &rElemId, IndexType &rCondId)
Get the las id of the created nodes, elements and conditions.
Definition: uniform_refinement_utility.cpp:159
void RemoveRefinedEntities(Flags ThisFlag)
RemoveRefinedEntities.
Definition: uniform_refinement_utility.cpp:169
Line3D2< NodeType > EdgeType
Definition: uniform_refinement_utility.h:96
std::unordered_map< IndexType, IndexType > IndexIndexMapType
Definition: uniform_refinement_utility.h:133
std::vector< IndexType > IndexVectorType
Definition: uniform_refinement_utility.h:131
std::size_t IndexType
Definition: uniform_refinement_utility.h:111
UniformRefinementUtility(ModelPart &rModelPart)
Default constructor.
Definition: uniform_refinement_utility.cpp:31
std::array< IndexType, 4 > FaceKeyType
Definition: uniform_refinement_utility.h:124
Hexahedra3D8< NodeType > BodyType
Definition: uniform_refinement_utility.h:106
ModelPart::ElementsContainerType ElementsArrayType
Definition: uniform_refinement_utility.h:117
ModelPart::ConditionsContainerType ConditionsArrayType
Definition: uniform_refinement_utility.h:118
std::unordered_map< IndexType, IndexVectorType > IndexIndexVectorMapType
Definition: uniform_refinement_utility.h:134
std::map< EdgeKeyType, IndexType > NodesInEdgeMapType
Definition: uniform_refinement_utility.h:125
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
This is a key comparer of general pourpose between two classes.
Definition: key_hash.h:100