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.
refine_elements_on_threshold_mesher_process.hpp
Go to the documentation of this file.
1 //
2 // Project Name: KratosDelaunayMeshingApplication $
3 // Created by: $Author: JMCarbonell $
4 // Last modified by: $Co-Author: $
5 // Date: $Date: April 2018 $
6 // Revision: $Revision: 0.0 $
7 //
8 //
9 
10 #if !defined(KRATOS_REFINE_ELEMENTS_ON_THRESHOLD_MESHER_PROCESS_H_INCLUDED )
11 #define KRATOS_REFINE_ELEMENTS_ON_THRESHOLD_MESHER_PROCESS_H_INCLUDED
12 
13 
14 // External includes
15 
16 // System includes
17 
18 // Project includes
21 
22 #include "includes/model_part.h"
26 
28 //Data:
29 //StepData:
30 //Flags: (checked) BOUNDARY
31 // (set) TO_REFINE(nodes)(set)
32 // (modified)
33 // (reset)
34 //(set):=(set in this process)
35 
36 namespace Kratos
37 {
38 
41 
43 
48  : public MesherProcess
49 {
50 public:
53 
56 
60 
64 
67  MesherUtilities::MeshingParameters& rRemeshingParameters,
68  int EchoLevel)
69  : mrModelPart(rModelPart),
70  mrRemesh(rRemeshingParameters)
71  {
72  mEchoLevel = EchoLevel;
73  }
74 
75 
78 
79 
83 
85  void operator()()
86  {
87  Execute();
88  }
89 
90 
94 
95 
97  void Execute() override
98  {
100 
101  if( ( mrRemesh.Refine->RefiningOptions.Is(MesherUtilities::REFINE_ADD_NODES) || mrRemesh.Refine->RefiningOptions.Is(MesherUtilities::REFINE_INSERT_NODES) ) && (mrRemesh.Refine->RefiningOptions.Is(MesherUtilities::REFINE_ELEMENTS_ON_THRESHOLD) ) ){
102 
103  SetNodesToRefine();
104 
105  }
106 
107  KRATOS_CATCH(" ")
108  }
109 
110 
114 
115 
119 
120 
124 
126  std::string Info() const override
127  {
128  return "RefineElementsOnThresholdMesherProcess";
129  }
130 
132  void PrintInfo(std::ostream& rOStream) const override
133  {
134  rOStream << "RefineElementsOnThresholdMesherProcess";
135  }
136 
138  void PrintData(std::ostream& rOStream) const override
139  {
140  }
141 
142 
146 
148 
149 
150 private:
153 
157  ModelPart& mrModelPart;
158 
160 
161  MesherUtilities mMesherUtilities;
162 
163  int mEchoLevel;
164 
168 
169  //**************************************************************************
170  //**************************************************************************
171 
172  void SetNodesToRefine()
173  {
174  KRATOS_TRY
175 
176  ProcessInfo& CurrentProcessInfo = mrModelPart.GetProcessInfo();
177 
178  double max_value = 0;
179  double critical_value = mrRemesh.Refine->ReferenceThreshold;
180 
181  int counter = 0;
182  //set label refine in elements that must be refined due to dissipation
183  for(ModelPart::ElementsContainerType::const_iterator iii = mrModelPart.ElementsBegin();
184  iii != mrModelPart.ElementsEnd(); ++iii)
185  {
186  double variable_value=0;
187  std::vector<double> Value(1);
188 
189  (iii)->CalculateOnIntegrationPoints(mrRemesh.Refine->GetThresholdVariable(),Value,CurrentProcessInfo);
190 
191  //the expected returned value is an "specific" value (per unit of Area) (usually PlasticPower)
192  //variable_value = Value[0] * iii->GetGeometry().Area();
193  variable_value = Value[0] * iii->GetGeometry().DomainSize(); //Area() or Volume()
194 
195 
196 
197  if( variable_value > max_value )
198  max_value = variable_value;
199 
200  // if(variable_value>0)
201  // std::cout<<" Element ["<<iii->Id()<<"] "<<mrRemesh.Refine->GetThresholdVariable()<<": "<<variable_value<<" CriticalValue "<<critical_value<<" Area "<<iii->GetGeometry().DomainSize()<<std::endl;
202 
203  if( variable_value > critical_value )
204  {
205  //std::cout<<" Refine element "<<std::endl;
206  Geometry< Node >& rGeometry = iii->GetGeometry();
207  for(unsigned int i = 0; i<rGeometry.size(); ++i)
208  {
209  if(rGeometry[i].IsNot(BOUNDARY))
210  rGeometry[i].Set(TO_REFINE);
211  }
212  counter ++;
213  }
214 
215  }
216 
217  if( mEchoLevel >= 1 ){
218  if( max_value < critical_value )
219  std::cout<<" Threshold Value not REACHED :: max_value "<< max_value<<std::endl;
220 
221  if( counter > 0 )
222  std::cout<<" Threshold reached "<<counter<<" times "<<std::endl;
223  }
224 
225 
226  if( mEchoLevel >= 1 )
227  std::cout<<" Refine Elements On Threshold [number:"<<counter<<"]"<<std::endl;
228 
229  KRATOS_CATCH( "" )
230 
231  }
232 
235 
236 
238 
239 
241  //Process(Process const& rOther);
242 
243 
245 
246 }; // Class Process
247 
249 
252 
253 
257 
258 
260 inline std::istream& operator >> (std::istream& rIStream,
262 
264 inline std::ostream& operator << (std::ostream& rOStream,
266 {
267  rThis.PrintInfo(rOStream);
268  rOStream << std::endl;
269  rThis.PrintData(rOStream);
270 
271  return rOStream;
272 }
274 
275 
276 } // namespace Kratos.
277 
278 #endif // KRATOS_REFINE_ELEMENTS_ON_THRESHOLD_MESHER_PROCESS_H_INCLUDED defined
Base class for all Conditions.
Definition: condition.h:59
void Set(const Flags ThisFlag)
Definition: flags.cpp:33
bool IsNot(Flags const &rOther) const
Definition: flags.h:291
Geometry base class.
Definition: geometry.h:71
SizeType size() const
Definition: geometry.h:518
The base class for processes passed to the solution scheme.
Definition: mesher_process.hpp:37
Short class definition.
Definition: mesher_utilities.hpp:49
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
Properties encapsulates data shared by different Elements or Conditions. It can store any type of dat...
Definition: properties.h:69
Refine Mesh Elements Process 2D and 3D.
Definition: refine_elements_on_threshold_mesher_process.hpp:49
std::string Info() const override
Turn back information as a string.
Definition: refine_elements_on_threshold_mesher_process.hpp:126
void Execute() override
Execute method is used to execute the Process algorithms.
Definition: refine_elements_on_threshold_mesher_process.hpp:97
ModelPart::ConditionType ConditionType
Definition: refine_elements_on_threshold_mesher_process.hpp:57
void operator()()
This operator is provided to call the process as a function and simply calls the Execute method.
Definition: refine_elements_on_threshold_mesher_process.hpp:85
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: refine_elements_on_threshold_mesher_process.hpp:138
ModelPart::PropertiesType PropertiesType
Definition: refine_elements_on_threshold_mesher_process.hpp:58
virtual ~RefineElementsOnThresholdMesherProcess()
Destructor.
Definition: refine_elements_on_threshold_mesher_process.hpp:77
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: refine_elements_on_threshold_mesher_process.hpp:132
KRATOS_CLASS_POINTER_DEFINITION(RefineElementsOnThresholdMesherProcess)
Pointer definition of Process.
RefineElementsOnThresholdMesherProcess(ModelPart &rModelPart, MesherUtilities::MeshingParameters &rRemeshingParameters, int EchoLevel)
Default constructor.
Definition: refine_elements_on_threshold_mesher_process.hpp:66
ConditionType::GeometryType GeometryType
Definition: refine_elements_on_threshold_mesher_process.hpp:59
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
static int EchoLevel
Definition: co_sim_EMPIRE_API.h:42
pybind11::list CalculateOnIntegrationPoints(TObject &dummy, const Variable< TDataType > &rVariable, const ProcessInfo &rProcessInfo)
Definition: add_mesh_to_python.cpp:142
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
int counter
Definition: script_THERMAL_CORRECT.py:218
integer i
Definition: TensorModule.f:17
Definition: mesher_utilities.hpp:631
RefiningParameters::Pointer Refine
Definition: mesher_utilities.hpp:684