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.
set_active_flag_process.hpp
Go to the documentation of this file.
1 //
2 // Project Name: KratosPfemFluidApplication $
3 // Created by: $Author: AFranci $
4 // Last modified by: $Co-Author: $
5 // Date: $Date: August 2017 $
6 // Revision: $Revision: 0.0 $
7 //
8 //
9 
10 #if !defined(KRATOS_SET_ACTIVE_FLAG_PROCESS_H_INCLUDED)
11 #define KRATOS_SET_ACTIVE_FLAG_PROCESS_H_INCLUDED
12 
13 // System includes
14 
15 // External includes
16 
17 // Project includes
18 
20 
23 #include "includes/model_part.h"
24 #include "utilities/openmp_utils.h"
25 #include "utilities/math_utils.h"
27 
29 //Data:
30 //StepData:
31 //Flags: (checked)
32 // (set)
33 // (modified)
34 // (reset)
35 
36 namespace Kratos
37 {
38 
41 
48 
49 typedef GlobalPointersVector<Node> NodeWeakPtrVectorType;
50 typedef GlobalPointersVector<Element> ElementWeakPtrVectorType;
51 
55 
59 
63 
65 
68  : public MesherProcess
69 {
70 public:
73 
76 
80 
83  bool unactivePeakElements,
84  bool unactiveSliverElements,
85  int EchoLevel)
86  : mrModelPart(rModelPart)
87  {
88  mUnactivePeakElements = unactivePeakElements;
89  mUnactiveSliverElements = unactiveSliverElements;
91  }
92 
95  {
96  }
97 
98  void operator()()
99  {
100  Execute();
101  }
102 
106 
107  void Execute() override{
108  KRATOS_TRY
109 #pragma omp parallel
110  {
111  ModelPart::ElementIterator ElemBegin;
114  for (ModelPart::ElementIterator itElem = ElemBegin; itElem != ElemEnd; ++itElem)
115  {
116  if ((itElem)->IsNot(ACTIVE))
117  {
118  unsigned int numNodes = itElem->GetGeometry().size();
119  for (unsigned int i = 0; i < numNodes; i++)
120  {
121  if (itElem->GetGeometry()[i].Is(RIGID) && itElem->GetGeometry()[i].IsNot(SOLID) && itElem->GetGeometry()[i].Is(FREE_SURFACE))
122  {
123  ElementWeakPtrVectorType &neighb_elems = itElem->GetGeometry()[i].GetValue(NEIGHBOUR_ELEMENTS);
124  bool doNotSetNullPressure = false;
125  for (ElementWeakPtrVectorType::iterator ne = neighb_elems.begin(); ne != neighb_elems.end(); ne++)
126  {
127  if ((ne)->Is(ACTIVE))
128  {
129  doNotSetNullPressure = true;
130  break;
131  }
132  }
133  if (doNotSetNullPressure == false)
134  itElem->GetGeometry()[i].FastGetSolutionStepValue(PRESSURE) = 0;
135  }
136  }
137  unsigned int elementRigidNodes = 0;
138  for (unsigned int i = 0; i < numNodes; i++)
139  {
140  if (itElem->GetGeometry()[i].Is(RIGID) && itElem->GetGeometry()[i].IsNot(SOLID))
141  {
142  elementRigidNodes++;
143  }
144  }
145 
146  if (elementRigidNodes == numNodes)
147  {
148  Geometry<Node> wallElementNodes = itElem->GetGeometry();
149  this->SetPressureToIsolatedWallNodes(wallElementNodes);
150  }
151  }
152  (itElem)->Set(ACTIVE, true);
153  }
154 
155 } KRATOS_CATCH(" ")
156 }; // namespace Kratos
157 
161 
165 
169 
173 
175 std::string Info() const override
176 {
177  return "SetActiveFlagProcess";
178 }
179 
181 void PrintInfo(std::ostream &rOStream) const override
182 {
183  rOStream << "SetActiveFlagProcess";
184 }
185 
186 protected:
189 
193 
195 
199 
200 //*******************************************************************************************
201 //*******************************************************************************************
202 
204 {
205  KRATOS_TRY
206  unsigned int numNodes = wallElementNodes.size();
207  double currentPressureForIsolatedWall = 0;
208  double previousPressureForIsolatedWall = 0;
209  unsigned int isolatedWallID = 0;
210  bool foundedIsolatedWall = false;
211  for (unsigned int i = 0; i < numNodes; i++)
212  {
213  NodeWeakPtrVectorType &rN = wallElementNodes[i].GetValue(NEIGHBOUR_NODES);
214  bool localIsolatedWallNode = true;
215  for (unsigned int j = 0; j < rN.size(); j++)
216  {
217  if (rN[j].IsNot(RIGID))
218  {
219  localIsolatedWallNode = false;
220  break;
221  }
222  }
223  if (localIsolatedWallNode == true)
224  {
225  isolatedWallID = i;
226  foundedIsolatedWall = true;
227  }
228  else
229  {
230  if (wallElementNodes[i].FastGetSolutionStepValue(PRESSURE, 0) < currentPressureForIsolatedWall)
231  {
232  currentPressureForIsolatedWall = wallElementNodes[i].FastGetSolutionStepValue(PRESSURE, 0);
233  }
234  if (wallElementNodes[i].FastGetSolutionStepValue(PRESSURE, 1) < previousPressureForIsolatedWall)
235  {
236  previousPressureForIsolatedWall = wallElementNodes[i].FastGetSolutionStepValue(PRESSURE, 1);
237  }
238  }
239  }
240  if (foundedIsolatedWall == true)
241  {
242  wallElementNodes[isolatedWallID].FastGetSolutionStepValue(PRESSURE, 0) = currentPressureForIsolatedWall;
243  wallElementNodes[isolatedWallID].FastGetSolutionStepValue(PRESSURE, 1) = previousPressureForIsolatedWall;
244  }
245 
246  KRATOS_CATCH(" ")
247 };
248 
252 
256 
260 
262 
263 private:
266 
270 
274 
278 
282 
286 
290 
292 SetActiveFlagProcess &operator=(SetActiveFlagProcess const &rOther);
293 
295 //SetActiveFlagProcess(SetActiveFlagProcess const& rOther);
296 
298 }
299 ; // Class SetActiveFlagProcess
300 
302 
305 
309 
311 inline std::istream &operator>>(std::istream &rIStream,
312  SetActiveFlagProcess &rThis);
313 
315 inline std::ostream &operator<<(std::ostream &rOStream,
316  const SetActiveFlagProcess &rThis)
317 {
318  rThis.PrintInfo(rOStream);
319  rOStream << std::endl;
320  rThis.PrintData(rOStream);
321 
322  return rOStream;
323 }
325 
326 } // namespace Kratos.
327 
328 #endif // KRATOS_SET_ACTIVE_FLAG_PROCESS_H_INCLUDED defined
void Set(const Flags ThisFlag)
Definition: flags.cpp:33
bool Is(Flags const &rOther) const
Definition: flags.h:274
bool IsNot(Flags const &rOther) const
Definition: flags.h:291
Geometry base class.
Definition: geometry.h:71
SizeType size() const
Definition: geometry.h:518
PointerVector< TPointType > PointsArrayType
Definition: geometry.h:118
TVariableType::Type & GetValue(const TVariableType &rThisVariable)
Definition: geometry.h:627
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: global_pointers_vector.h:79
iterator begin()
Definition: global_pointers_vector.h:221
size_type size() const
Definition: global_pointers_vector.h:307
iterator end()
Definition: global_pointers_vector.h:229
The base class for processes passed to the solution scheme.
Definition: mesher_process.hpp:37
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: mesher_process.hpp:157
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
MeshType::ElementIterator ElementIterator
Definition: model_part.h:174
static void PartitionedIterators(TVector &rVector, typename TVector::iterator &rBegin, typename TVector::iterator &rEnd)
Generate a partition for an std::vector-like array, providing iterators to the begin and end position...
Definition: openmp_utils.h:179
Short class definition.
Definition: set_active_flag_process.hpp:69
void SetPressureToIsolatedWallNodes(Geometry< Node > &wallElementNodes)
Definition: set_active_flag_process.hpp:203
bool mUnactiveSliverElements
Definition: set_active_flag_process.hpp:198
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: set_active_flag_process.hpp:181
void Execute() override
Execute method is used to execute the MesherProcess algorithms.
Definition: set_active_flag_process.hpp:107
int mEchoLevel
Definition: set_active_flag_process.hpp:196
void operator()()
Definition: set_active_flag_process.hpp:98
SetActiveFlagProcess(ModelPart &rModelPart, bool unactivePeakElements, bool unactiveSliverElements, int EchoLevel)
Default constructor.
Definition: set_active_flag_process.hpp:82
std::string Info() const override
Turn back information as a string.
Definition: set_active_flag_process.hpp:175
bool mUnactivePeakElements
Definition: set_active_flag_process.hpp:197
virtual ~SetActiveFlagProcess()
Destructor.
Definition: set_active_flag_process.hpp:94
ModelPart & mrModelPart
Definition: set_active_flag_process.hpp:194
KRATOS_CLASS_POINTER_DEFINITION(SetActiveFlagProcess)
Pointer definition of SetActiveFlagProcess.
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
GlobalPointersVector< Element > ElementWeakPtrVectorType
Definition: build_model_part_boundary_process.hpp:60
static int EchoLevel
Definition: co_sim_EMPIRE_API.h:42
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
ModelPart::NodesContainerType NodesContainerType
Definition: find_conditions_neighbours_process.h:44
GlobalPointersVector< Node > NodeWeakPtrVectorType
Definition: build_model_part_boundary_process.hpp:59
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
ModelPart::ElementsContainerType ElementsContainerType
Definition: clear_contact_conditions_mesher_process.hpp:43
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
GeometryType::PointsArrayType PointsArrayType
Definition: settle_model_structure_process.hpp:48
int j
Definition: quadrature.py:648
integer i
Definition: TensorModule.f:17