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.
add_fixed_velocity_condition.h
Go to the documentation of this file.
1 
2 
3 #if !defined(KRATOS_ADD_FIXED_VELOCITY_CONDITION_UTILITY_INCLUDED )
4 #define KRATOS_ADD_FIXED_VELOCITY_CONDITION_UTILITY_INCLUDED
5 
6 // System includes
7 #include <string>
8 #include <iostream>
9 #include <algorithm>
10 
11 // Project includes
12 #include "includes/define.h"
15 #include "utilities/math_utils.h"
16 #include "utilities/geometry_utilities.h"
18 #include "includes/variables.h"
19 #include "includes/model_part.h"
20 #include "includes/node.h"
21 #include "includes/element.h"
22 #include "includes/condition.h"
23 #include "geometries/point_2d.h"
24 #include "geometries/point_3d.h"
25 
26 
27 namespace Kratos
28 {
29  //this class is to be modified by the user to customize the interpolation process
30  //template< unsigned int TDim>
32  {
33  public:
34 
36 
38  : mr_model_part(model_part)
39  {
40  KRATOS_TRY
41  //std::cout << "Hello, I am the constructor of the Fixed Velocity 2d Utility" << std::endl;
42  KRATOS_CATCH("")
43  }
44 
45 
47  {}
48 
49 
50  void AddThem()
51  {
53 
54  unsigned int condition_number=1;
55  if(mr_model_part.Conditions().size()!=0)
56  {
57  ModelPart::ConditionsContainerType::iterator lastcondition = (mr_model_part.ConditionsEnd()-1);
58  condition_number += lastcondition->Id();
59  }
60 
61  //Condition const& rReferenceCondition = FixedVelocity2D(); //condition type
62  //getting data for the given geometry
63  for(ModelPart::NodesContainerType::iterator inode = mr_model_part.NodesBegin();
64  inode!=mr_model_part.NodesEnd(); inode++)
65  {
66  if ((inode->IsFixed(VELOCITY_X)) || (inode->IsFixed(VELOCITY_Y)) || (inode->IsFixed(VELOCITY_Z)) )
67  {
68  Condition const& rReferenceCondition = KratosComponents<Condition>::Get("FixedVelocity2D"); //condition type
69  Point2D<Node > geometry(Node::Pointer( *inode.base() ));//mr_model_part.Nodes().(inode->Id()));//Node::Pointer( *inode.base() ));
70  Properties::Pointer properties = mr_model_part.GetMesh().pGetProperties(0); //this will allow us later to turn this layer on/off in GID
71  Condition::Pointer p_condition = rReferenceCondition.Create(condition_number, geometry, properties);
72  mr_model_part.Conditions().push_back(p_condition);
73  ++condition_number;
74  }
75  }
76  std::cout << "Finished adding conditions on fixed velocity boundaries" << condition_number << std::endl;
77 
78 
79  KRATOS_CATCH("")
80  }
81 
82 
83  protected:
84 
85 
86  private:
87  ModelPart& mr_model_part;
88 
89  };
90 
91 
92 
93  //for 3D
95  {
96  public:
97 
99 
101  : mr_model_part(model_part)
102  {
103  KRATOS_TRY
104  //std::cout << "Hello, I am the constructor of the Fixed Velocity 3d Utility" << std::endl;
105  KRATOS_CATCH("")
106  }
107 
108 
110  {}
111 
112 
113  void AddThem()
114  {
115  KRATOS_TRY
116 
117  unsigned int condition_number=1;
118  if(mr_model_part.Conditions().size()!=0)
119  {
120  ModelPart::ConditionsContainerType::iterator lastcondition = (mr_model_part.ConditionsEnd()-1);
121  condition_number += lastcondition->Id();
122  }
123 
124  //Condition const& rReferenceCondition = FixedVelocity2D(); //condition type
125  //getting data for the given geometry
126  for(ModelPart::NodesContainerType::iterator inode = mr_model_part.NodesBegin();
127  inode!=mr_model_part.NodesEnd(); inode++)
128  {
129  if ((inode->IsFixed(VELOCITY_X)) || (inode->IsFixed(VELOCITY_Y)) || (inode->IsFixed(VELOCITY_Z)) )
130  {
131  Condition const& rReferenceCondition = KratosComponents<Condition>::Get("FixedVelocity3D"); //condition type
132  Point3D<Node > geometry(Node::Pointer( *inode.base() ));//mr_model_part.Nodes().(inode->Id()));//Node::Pointer( *inode.base() ));
133  Properties::Pointer properties = mr_model_part.GetMesh().pGetProperties(0); //this will allow us later to turn this layer on/off in GID
134  Condition::Pointer p_condition = rReferenceCondition.Create(condition_number, geometry, properties);
135  mr_model_part.Conditions().push_back(p_condition);
136  ++condition_number;
137  }
138  }
139  std::cout << "Finished adding conditions on fixed velocity boundaries" << condition_number << std::endl;
140 
141 
142  KRATOS_CATCH("")
143  }
144 
145 
146  protected:
147 
148 
149  private:
150  ModelPart& mr_model_part;
151 
152  };
153 
154 
155 
156 
157 
159  {
160  public:
161 
163 
165  : mr_model_part(model_part)
166  {
167  KRATOS_TRY
168  //std::cout << "Hello, I am the constructor of the Fixed Pressure 2d Utility" << std::endl;
169  KRATOS_CATCH("")
170  }
171 
172 
174  {}
175 
176 
177  void AddThem()
178  {
179  KRATOS_TRY
180 
181  unsigned int condition_number=1;
182  if(mr_model_part.Conditions().size()!=0)
183  {
184  ModelPart::ConditionsContainerType::iterator lastcondition = (mr_model_part.ConditionsEnd()-1);
185  condition_number += lastcondition->Id();
186  }
187 
188  //Condition const& rReferenceCondition = FixedVelocity2D(); //condition type
189  //getting data for the given geometry
190  for(ModelPart::NodesContainerType::iterator inode = mr_model_part.NodesBegin();
191  inode!=mr_model_part.NodesEnd(); inode++)
192  {
193  if (inode->IsFixed(PRESSURE) && ( (inode->IsFixed(VELOCITY_X))==false || (inode->IsFixed(VELOCITY_Y)) ) )
194  {
195  Condition const& rReferenceCondition = KratosComponents<Condition>::Get("FixedPressure2D"); //condition type
196  Point2D<Node > geometry(Node::Pointer( *inode.base() ));//mr_model_part.Nodes().(inode->Id()));//Node::Pointer( *inode.base() ));
197  Properties::Pointer properties = mr_model_part.GetMesh().pGetProperties(0); //this will allow us later to turn this layer on/off in GID
198  Condition::Pointer p_condition = rReferenceCondition.Create(condition_number, geometry, properties);
199  mr_model_part.Conditions().push_back(p_condition);
200  ++condition_number;
201  }
202  }
203  std::cout << "Finished adding conditions on fixed pressure boundaries" << condition_number << std::endl;
204 
205 
206  KRATOS_CATCH("")
207  }
208 
209 
210  protected:
211 
212 
213  private:
214  ModelPart& mr_model_part;
215 
216  };
217 
218 
219 
220  //for 3D
222  {
223  public:
224 
226 
228  : mr_model_part(model_part)
229  {
230  KRATOS_TRY
231  //std::cout << "Hello, I am the constructor of the Fixed Pressure 3d Utility" << std::endl;
232  KRATOS_CATCH("")
233  }
234 
235 
237  {}
238 
239 
240  void AddThem()
241  {
242  KRATOS_TRY
243 
244  unsigned int condition_number=1;
245  if(mr_model_part.Conditions().size()!=0)
246  {
247  ModelPart::ConditionsContainerType::iterator lastcondition = (mr_model_part.ConditionsEnd()-1);
248  condition_number += lastcondition->Id();
249  }
250 
251  //Condition const& rReferenceCondition = FixedVelocity2D(); //condition type
252  //getting data for the given geometry
253  for(ModelPart::NodesContainerType::iterator inode = mr_model_part.NodesBegin();
254  inode!=mr_model_part.NodesEnd(); inode++)
255  {
256  if (inode->IsFixed(PRESSURE) && ( (inode->IsFixed(VELOCITY_X))==false || (inode->IsFixed(VELOCITY_Y)) || (inode->IsFixed(VELOCITY_Z)) ) )
257  {
258  Condition const& rReferenceCondition = KratosComponents<Condition>::Get("FixedPressure3D"); //condition type
259  Point3D<Node > geometry(Node::Pointer( *inode.base() ));//mr_model_part.Nodes().(inode->Id()));//Node::Pointer( *inode.base() ));
260  Properties::Pointer properties = mr_model_part.GetMesh().pGetProperties(0); //this will allow us later to turn this layer on/off in GID
261  Condition::Pointer p_condition = rReferenceCondition.Create(condition_number, geometry, properties);
262  mr_model_part.Conditions().push_back(p_condition);
263  ++condition_number;
264  }
265  }
266  std::cout << "Finished adding conditions on fixed pressure boundaries" << condition_number << std::endl;
267 
268 
269  KRATOS_CATCH("")
270  }
271 
272 
273  protected:
274 
275 
276  private:
277  ModelPart& mr_model_part;
278 
279  };
280 
281 
283  {
284  public:
285 
287 
289  : mr_model_part(model_part)
290  {
291  KRATOS_TRY
292  //std::cout << "Hello, I am the constructor of the Water Fixed Velocity 2d Utility" << std::endl;
293  KRATOS_CATCH("")
294  }
295 
296 
298  {}
299 
300 
301  void AddThem()
302  {
303  KRATOS_TRY
304 
305  unsigned int condition_number=1;
306  if(mr_model_part.Conditions().size()!=0)
307  {
308  ModelPart::ConditionsContainerType::iterator lastcondition = (mr_model_part.ConditionsEnd()-1);
309  condition_number += lastcondition->Id();
310  }
311 
312  //Condition const& rReferenceCondition = FixedVelocity2D(); //condition type
313  //getting data for the given geometry
314  for(ModelPart::NodesContainerType::iterator inode = mr_model_part.NodesBegin();
315  inode!=mr_model_part.NodesEnd(); inode++)
316  {
317  if ((inode->IsFixed(WATER_VELOCITY_X)) || (inode->IsFixed(WATER_VELOCITY_Y)) || (inode->IsFixed(WATER_VELOCITY_Z)) )
318  {
319  Condition const& rReferenceCondition = KratosComponents<Condition>::Get("WaterFixedVelocity2D"); //condition type
320  Point2D<Node > geometry(Node::Pointer( *inode.base() ));//mr_model_part.Nodes().(inode->Id()));//Node::Pointer( *inode.base() ));
321  Properties::Pointer properties = mr_model_part.GetMesh().pGetProperties(0); //this will allow us later to turn this layer on/off in GID
322  Condition::Pointer p_condition = rReferenceCondition.Create(condition_number, geometry, properties);
323  mr_model_part.Conditions().push_back(p_condition);
324  ++condition_number;
325  }
326  }
327  std::cout << "Finished adding conditions on fixed water velocity boundaries" << condition_number << std::endl;
328 
329 
330  KRATOS_CATCH("")
331  }
332 
333 
334  protected:
335 
336 
337  private:
338  ModelPart& mr_model_part;
339 
340  };
341 
342 
343 } // namespace Kratos.
344 
345 #endif // KRATOS_ADD_FIXED_VELOCITY_CONDITION_UTILITY_INCLUDED defined
346 
347 
Definition: add_fixed_velocity_condition.h:159
~AddFixedPressureCondition2D()
Definition: add_fixed_velocity_condition.h:173
KRATOS_CLASS_POINTER_DEFINITION(AddFixedPressureCondition2D)
AddFixedPressureCondition2D(ModelPart &model_part)
Definition: add_fixed_velocity_condition.h:164
void AddThem()
Definition: add_fixed_velocity_condition.h:177
Definition: add_fixed_velocity_condition.h:222
KRATOS_CLASS_POINTER_DEFINITION(AddFixedPressureCondition3D)
AddFixedPressureCondition3D(ModelPart &model_part)
Definition: add_fixed_velocity_condition.h:227
~AddFixedPressureCondition3D()
Definition: add_fixed_velocity_condition.h:236
void AddThem()
Definition: add_fixed_velocity_condition.h:240
Definition: add_fixed_velocity_condition.h:32
~AddFixedVelocityCondition2D()
Definition: add_fixed_velocity_condition.h:46
void AddThem()
Definition: add_fixed_velocity_condition.h:50
KRATOS_CLASS_POINTER_DEFINITION(AddFixedVelocityCondition2D)
AddFixedVelocityCondition2D(ModelPart &model_part)
Definition: add_fixed_velocity_condition.h:37
Definition: add_fixed_velocity_condition.h:95
KRATOS_CLASS_POINTER_DEFINITION(AddFixedVelocityCondition3D)
~AddFixedVelocityCondition3D()
Definition: add_fixed_velocity_condition.h:109
void AddThem()
Definition: add_fixed_velocity_condition.h:113
AddFixedVelocityCondition3D(ModelPart &model_part)
Definition: add_fixed_velocity_condition.h:100
Definition: add_fixed_velocity_condition.h:283
AddWaterFixedVelocityCondition2D(ModelPart &model_part)
Definition: add_fixed_velocity_condition.h:288
void AddThem()
Definition: add_fixed_velocity_condition.h:301
KRATOS_CLASS_POINTER_DEFINITION(AddWaterFixedVelocityCondition2D)
~AddWaterFixedVelocityCondition2D()
Definition: add_fixed_velocity_condition.h:297
Base class for all Conditions.
Definition: condition.h:59
virtual Pointer Create(IndexType NewId, NodesArrayType const &ThisNodes, PropertiesType::Pointer pProperties) const
It creates a new condition pointer.
Definition: condition.h:205
static const TComponentType & Get(const std::string &rName)
Retrieves a component with the specified name.
Definition: kratos_components.h:114
PropertiesType::Pointer pGetProperties(IndexType PropertiesId)
Definition: mesh.h:394
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
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
MeshType & GetMesh(IndexType ThisIndex=0)
Definition: model_part.h:1791
ConditionIterator ConditionsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1371
Definition: point_2d.h:53
Definition: point_3d.h:53
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
model_part
Definition: face_heat.py:14