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.
merge_model_parts_process.h
Go to the documentation of this file.
1 //
2 // Project Name: Kratos
3 // Last Modified by: $Author: anonymous $
4 // Date: $Date: 2007-11-06 12:34:26 $
5 // Revision: $Revision: 1.4 $
6 //
7 // this process save structural elements in a separate list
8 
9 #if !defined(KRATOS_MERGE_MODEL_PARTS_PROCESS_INCLUDED )
10 #define KRATOS_MERGE_MODEL_PARTS_PROCESS_INCLUDED
11 
12 
13 
14 // System includes
15 #include <string>
16 #include <iostream>
17 #include <algorithm>
18 
19 // External includes
20 
21 
22 // Project includes
23 #include "includes/define.h"
24 #include "processes/process.h"
25 #include "includes/node.h"
26 #include "includes/element.h"
27 #include "includes/model_part.h"
32 
33 
34 namespace Kratos
35 {
36 
39 
43 
44 
48 
52 
56 
58 
65  : public Process
66 {
67 public:
70 
73 
77 
80  //ModelPart& fluid_model_part, ModelPart& structure_model_part, ModelPart& combined_model_part)
81  //: mr_fluid_model_part(fluid_model_part), mr_structure_model_part(structure_model_part), mr_combined_model_part(combined_model_part)
82  {
83  }
84 
87  {
88  }
89 
90 
94 
95  // void operator()()
96  // {
97  // MergeParts();
98  // }
99 
100 
104 
106  {
107  KRATOS_TRY
108  combined_model_part.Elements().clear();
109  combined_model_part.Nodes();
110  combined_model_part.Nodes().clear();
111 
112  combined_model_part.Nodes()=fluid_model_part.Nodes();
113  combined_model_part.Elements()=fluid_model_part.Elements();
114  combined_model_part.Conditions()=fluid_model_part.Conditions();
115 
116  //sorting and renumbering the fluid elements
117  unsigned int id=1;
118  for(ModelPart::ElementsContainerType::iterator im = combined_model_part.ElementsBegin() ;
119  im != combined_model_part.ElementsEnd() ; ++im)
120  {
121  im->SetId(id);
122 // im->Id() = id;
123  id++;
124  }
125  /* KRATOS_WATCH("Last FLUID ID is");
126  KRATOS_WATCH(id);
127 
128  KRATOS_WATCH("The size of fluid elements container is");
129  KRATOS_WATCH(fluid_model_part.Elements().size());
130  */
131  //adding the structure elements to the combined part
132  //combined_model_part.Elements().push_back(*( structure_model_part.ElementsBegin().base()));
133  id += 1000;
134  for(ModelPart::ElementsContainerType::iterator im = structure_model_part.ElementsBegin() ;
135  im != structure_model_part.ElementsEnd() ; ++im)
136  {
137  im->SetId(id);
138 // im->Id() = id;
139  combined_model_part.Elements().push_back(*(im.base()));
140  id++;
141  }
142  //combined_model_part.Elements().Sort();
143 
144 
145  //renumbering
146  id=1;
147  for(ModelPart::ConditionsContainerType::iterator im = combined_model_part.ConditionsBegin() ;
148  im != combined_model_part.ConditionsEnd() ; ++im)
149  {
150  im->SetId(id);
151 // im->Id() = id;
152  id++;
153  }
154  //adding the structure conditions to the combined part
155  id += 1000;
156  for(ModelPart::ConditionsContainerType::iterator im = structure_model_part.ConditionsBegin() ;
157  im != structure_model_part.ConditionsEnd() ; ++im)
158  {
159  im->SetId(id);
160 // im->Id() = id;
161  combined_model_part.Conditions().push_back(*(im.base()));
162  id++;
163  }
164  //combined_model_part.Conditions().Sort();
165 
166  //renumbering
167  /*
168  unsigned int new_id=1;
169  for(ModelPart::ConditionsContainerType::iterator im = structure_model_part.ConditionsBegin() ;
170  im != structure_model_part.ConditionsEnd() ; ++im)
171  {
172  im->Id() =new_id;
173  new_id++;
174  }
175  */
176  //WE HAVE TO COPY THE ProcessInfo pointer to the new part, otherwise it is empty
177  combined_model_part.SetProcessInfo(fluid_model_part.pGetProcessInfo());
178  combined_model_part.SetProperties(fluid_model_part.pProperties());
179 
180  KRATOS_CATCH("")
181  }
182 
183 
187 
188 
192 
193 
197 
199  std::string Info() const override
200  {
201  return "MergeModelPartsProcess";
202  }
203 
205  void PrintInfo(std::ostream& rOStream) const override
206  {
207  rOStream << "MergeModelPartsProcess";
208  }
209 
211  void PrintData(std::ostream& rOStream) const override
212  {
213  }
214 
215 
219 
220 
222 
223 protected:
226 
227 
231 
232 
236 
237 
241 
242 
246 
247 
251 
252 
256 
257 
259 
260 private:
263 
264 
268  //ModelPart& mr_fluid_model_part;
269  //ModelPart& mr_structure_model_part;
270  //ModelPart& mr_combined_model_part;
271 
275 
276 
280 
281 
285 
286 
290 
291 
295 
297 // MergeModelPartsProcess& operator=(MergeModelPartsProcess const& rOther);
298 
300 // MergeModelPartsProcess(MergeModelPartsProcess const& rOther);
301 
302 
304 
305 }; // Class MergeModelPartsProcess
306 
308 
311 
312 
316 
317 
319 inline std::istream& operator >> (std::istream& rIStream,
320  MergeModelPartsProcess& rThis);
321 
323 inline std::ostream& operator << (std::ostream& rOStream,
324  const MergeModelPartsProcess& rThis)
325 {
326  rThis.PrintInfo(rOStream);
327  rOStream << std::endl;
328  rThis.PrintData(rOStream);
329 
330  return rOStream;
331 }
333 
334 
335 } // namespace Kratos.
336 
337 #endif // KRATOS_MERGE_MODEL_PARTS_PROCESS_INCLUDED defined
338 
339 
Short class definition.
Definition: merge_model_parts_process.h:66
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: merge_model_parts_process.h:211
void MergeParts(ModelPart &fluid_model_part, ModelPart &structure_model_part, ModelPart &combined_model_part)
Definition: merge_model_parts_process.h:105
~MergeModelPartsProcess() override
Destructor.
Definition: merge_model_parts_process.h:86
MergeModelPartsProcess()
Default constructor.
Definition: merge_model_parts_process.h:79
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: merge_model_parts_process.h:205
KRATOS_CLASS_POINTER_DEFINITION(MergeModelPartsProcess)
Pointer definition of PushStructureProcess.
std::string Info() const override
Turn back information as a string.
Definition: merge_model_parts_process.h:199
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
The base class for all processes in Kratos.
Definition: process.h:49
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
im
Definition: GenerateCN.py:100
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
fluid_model_part
Definition: edgebased_PureConvection.py:18
structure_model_part
Definition: script.py:23
combined_model_part
Definition: script.py:24