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.
renumbering_model_parts_utility.h
Go to the documentation of this file.
1 //Author: Miguel Angel Celigueta. maceli@cimne.upc.edu
2 
3 #if !defined(KRATOS_RENUMBERING_NODES_UTILITY)
4 #define KRATOS_RENUMBERING_NODES_UTILITY
5 
6 // /* External includes */
7 #ifdef _OPENMP
8 #include <omp.h>
9 #endif
10 
11 // Project includes
12 #include "includes/model_part.h"
13 
14 #include "pybind11/stl.h"
15 
16 
17 namespace Kratos
18 {
20 {
21 
22 public:
23 
25 
27  mListOfModelParts.push_back(&mp1);
28  std::map<int,int> aux_map;
29  mListOfMapsOfIdsNewToOld.push_back(aux_map);
30 }
31 
33  mListOfModelParts.push_back(&mp2);
34  std::map<int,int> aux_map;
35  mListOfMapsOfIdsNewToOld.push_back(aux_map);
36 }
37 
39  mListOfModelParts.push_back(&mp3);
40  std::map<int,int> aux_map;
41  mListOfMapsOfIdsNewToOld.push_back(aux_map);
42 }
43 
45  mListOfModelParts.push_back(&mp4);
46  std::map<int,int> aux_map;
47  mListOfMapsOfIdsNewToOld.push_back(aux_map);
48 }
49 
51  mListOfModelParts.push_back(&mp5);
52  std::map<int,int> aux_map;
53  mListOfMapsOfIdsNewToOld.push_back(aux_map);
54 }
55 
56 
58 
59 void Renumber() {
60  int id = 1;
61  for (int i = 0; i < (int)mListOfModelParts.size(); ++i){
62  ModelPart& mp = *mListOfModelParts[i];
63  std::map<int,int>& new_to_old = mListOfMapsOfIdsNewToOld[i];
64 
65  auto it_node_begin = mp.NodesBegin();
66  for (int j = 0; j < (int)mp.Nodes().size(); j++){
67  auto it = it_node_begin + j;
68  new_to_old[id] = it->Id();
69  it->SetId(id);
70  id++;
71  }
72  }
73 }
74 
75 void UndoRenumber() {
76  for (int i = 0; i < (int)mListOfModelParts.size(); ++i){
77  ModelPart& r_mp = *mListOfModelParts[i];
78  std::map<int, int>& new_to_old = mListOfMapsOfIdsNewToOld[i];
79 
80  auto it_node_begin = r_mp.NodesBegin();
81  for (int j = 0; j < (int)r_mp.Nodes().size(); ++j){
82  auto it = it_node_begin + j;
83  it->SetId(new_to_old[it->Id()]);
84  }
85  }
86 }
87 
89  int id = 1;
90  for (int i = 0; i < (int)mListOfModelParts.size(); ++i){
91  ModelPart& r_mp = *mListOfModelParts[i];
92  std::map<int, int>& new_to_old = mListOfMapsOfIdsNewToOld[i];
93 
94  auto it_elem_begin = r_mp.ElementsBegin();
95  for (int j = 0; j < (int)r_mp.Elements().size(); ++j){
96  auto it = it_elem_begin + j;
97  new_to_old[id] = it->Id();
98  it->SetId(id);
99  id++;
100  }
101  }
102 }
103 
105  for (int i = 0; i < (int)mListOfModelParts.size(); ++i){
106  ModelPart& r_mp = *mListOfModelParts[i];
107  std::map<int, int>& new_to_old = mListOfMapsOfIdsNewToOld[i];
108 
109  auto it_elem_begin = r_mp.ElementsBegin();
110  for (int j = 0; j < (int)r_mp.Elements().size(); ++j){
111  auto it = it_elem_begin + j;
112  it->SetId(new_to_old[it->Id()]);
113  }
114  }
115 }
116 
117 
118 private:
119 
120 std::vector<ModelPart*> mListOfModelParts;
121 std::vector<std::map<int, int>> mListOfMapsOfIdsNewToOld;
122 
123 }; // Class RenumberingNodesUtility
124 
125 } // namespace Kratos.
126 
127 #endif // KRATOS_RENUMBERING_NODES_UTILITY defined
128 
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ElementIterator ElementsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1169
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
Definition: renumbering_model_parts_utility.h:20
void UndoRenumber()
Definition: renumbering_model_parts_utility.h:75
void UndoRenumberElements()
Definition: renumbering_model_parts_utility.h:104
RenumberingNodesUtility(ModelPart &mp1, ModelPart &mp2, ModelPart &mp3, ModelPart &mp4)
Definition: renumbering_model_parts_utility.h:44
KRATOS_CLASS_POINTER_DEFINITION(RenumberingNodesUtility)
virtual ~RenumberingNodesUtility()
Definition: renumbering_model_parts_utility.h:57
RenumberingNodesUtility(ModelPart &mp1, ModelPart &mp2, ModelPart &mp3, ModelPart &mp4, ModelPart &mp5)
Definition: renumbering_model_parts_utility.h:50
RenumberingNodesUtility(ModelPart &mp1, ModelPart &mp2)
Definition: renumbering_model_parts_utility.h:32
RenumberingNodesUtility(ModelPart &mp1)
Definition: renumbering_model_parts_utility.h:26
void Renumber()
Definition: renumbering_model_parts_utility.h:59
void RenumberElements()
Definition: renumbering_model_parts_utility.h:88
RenumberingNodesUtility(ModelPart &mp1, ModelPart &mp2, ModelPart &mp3)
Definition: renumbering_model_parts_utility.h:38
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
REACTION_CHECK_STIFFNESS_FACTOR int
Definition: contact_structural_mechanics_application_variables.h:75
int j
Definition: quadrature.py:648
integer i
Definition: TensorModule.f:17