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.
activation_utilities.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Pooyan Dadvand
11 //
12 //
13 
14 #include "includes/model_part.h"
15 
16 #if !defined(KRATOS_ACTIVATION_UTILITIES )
17 #define KRATOS_ACTIVATION_UTILITIES
18 
19 
20 /* System includes */
21 
22 
23 /* External includes */
24 
25 
26 /* Project includes */
27 #include "utilities/math_utils.h"
28 #include "includes/kratos_flags.h"
29 
30 namespace Kratos
31 {
32 
61 {
62 public:
104  const Variable< double >& rVariable,
105  const double reference_value,
106  bool active_if_lower_than_reference)
107  {
108  KRATOS_TRY
109 
110  //KRATOS_WATCH(rVariable);
113 
114  #pragma omp parallel for
115  for(int i=0; i<static_cast<int>(rmodel_part.Elements().size()); i++)
116  {
118 
119  const Geometry< Node >& geom = it->GetGeometry();
120  it->Set(ACTIVE,false);
121 
122  for(unsigned int k=0; k<geom.size(); k++)
123  {
124  if( geom[k].FastGetSolutionStepValue(rVariable) < reference_value)
125  {
126  it->Set(ACTIVE,true);
127  break;
128  }
129  }
130  }
131 
132  #pragma omp parallel for
133  for(int i=0; i<static_cast<int>(rmodel_part.Conditions().size()); i++)
134  {
136 
137  const Geometry< Node >& geom = it->GetGeometry();
138  it->Set(ACTIVE,false);
139  for(unsigned int k=0; k<geom.size(); k++)
140  {
141  if( geom[k].FastGetSolutionStepValue(rVariable) < reference_value)
142  {
143  it->Set(ACTIVE,true);
144  break;
145  }
146 
147  }
148  }
149 
150  if( active_if_lower_than_reference == false) //flip everything
151  {
152  #pragma omp parallel for
153  for(int i=0; i<static_cast<int>(rmodel_part.Elements().size()); i++)
154  {
156  it->Flip(ACTIVE);
157  }
158 
159  #pragma omp parallel for
160  for(int i=0; i<static_cast<int>(rmodel_part.Conditions().size()); i++)
161  {
163  it->Flip(ACTIVE);
164  }
165  }
166 
167  KRATOS_CATCH("")
168 
169  }
170 
171 
172 
190 private:
223  //ActivationUtilities(void);
224 
225  //ActivationUtilities(ActivationUtilities& rSource);
226 
227 
230 }; /* Class ClassName */
231 
240 } /* namespace Kratos.*/
241 
242 #endif /* KRATOS_ACTIVATION_UTILITIES defined */
243 
Tool to evaluate the normals on nodes based on the normals of a set of surface conditions.
Definition: activation_utilities.h:61
void ActivateElementsAndConditions(ModelPart &rmodel_part, const Variable< double > &rVariable, const double reference_value, bool active_if_lower_than_reference)
Definition: activation_utilities.h:103
ModelPart::NodesContainerType NodesArrayType
Definition: activation_utilities.h:65
ModelPart::ConditionsContainerType ConditionsArrayType
Definition: activation_utilities.h:66
Geometry base class.
Definition: geometry.h:71
SizeType size() const
Definition: geometry.h:518
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
ConditionIterator ConditionsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1361
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.h:72
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: pointer_vector_set.h:95
#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
int k
Definition: quadrature.py:595
integer i
Definition: TensorModule.f:17