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_nodes_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 {
19 class RenumberingNodesUtility
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  for (int j = 0; j < (int)mp.Nodes().size(); j++){
66  auto it = mp.NodesBegin() + j;
67  new_to_old[id] = it->Id();
68  it->SetId(id);
69  id++;
70  }
71  }
72 }
73 
74 void UndoRenumber() {
75  for (int i=0; i<(int)mListOfModelParts.size(); i++){
76  ModelPart& mp = *mListOfModelParts[i];
77  std::map<int,int>& new_to_old = mListOfMapsOfIdsNewToOld[i];
78 
79  for (int j = 0; j < (int)mp.Nodes().size(); j++){
80  auto it = mp.NodesBegin() + j;
81  it->SetId(new_to_old[it->Id()]);
82  }
83  }
84 }
85 
86 
87 
88 private:
89 
90 std::vector<ModelPart*> mListOfModelParts;
91 std::vector<std::map<int,int> > mListOfMapsOfIdsNewToOld;
92 
93 }; // Class RenumberingNodesUtility
94 
95 } // namespace Kratos.
96 
97 #endif // KRATOS_RENUMBERING_NODES_UTILITY defined
98 
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
Definition: renumbering_model_parts_utility.h:20
void UndoRenumber()
Definition: renumbering_nodes_utility.h:74
RenumberingNodesUtility(ModelPart &mp1, ModelPart &mp2, ModelPart &mp3, ModelPart &mp4)
Definition: renumbering_nodes_utility.h:44
KRATOS_CLASS_POINTER_DEFINITION(RenumberingNodesUtility)
virtual ~RenumberingNodesUtility()
Definition: renumbering_nodes_utility.h:57
RenumberingNodesUtility(ModelPart &mp1, ModelPart &mp2, ModelPart &mp3, ModelPart &mp4, ModelPart &mp5)
Definition: renumbering_nodes_utility.h:50
RenumberingNodesUtility(ModelPart &mp1, ModelPart &mp2)
Definition: renumbering_nodes_utility.h:32
RenumberingNodesUtility(ModelPart &mp1)
Definition: renumbering_nodes_utility.h:26
void Renumber()
Definition: renumbering_nodes_utility.h:59
RenumberingNodesUtility(ModelPart &mp1, ModelPart &mp2, ModelPart &mp3)
Definition: renumbering_nodes_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