10 #if !defined( KRATOS_REFINE_ELEMENTS_ON_SIZE_MESHER_PROCESS_H_INCLUDED )
11 #define KRATOS_REFINE_ELEMENTS_ON_SIZE_MESHER_PROCESS_H_INCLUDED
68 : mrModelPart(rModelPart),
69 mrRemesh(rRemeshingParameters)
100 if( mEchoLevel > 0 ){
101 std::cout<<
" [ SELECT ELEMENTS TO REFINE : "<<std::endl;
107 double size_for_inside_elements = 0.75 * mrRemesh.
Refine->CriticalRadius;
108 double size_for_boundary_elements = 1.50 * mrRemesh.
Refine->CriticalRadius;
110 double nodal_h_refining_factor = 0.75;
111 double nodal_h_non_refining_factor = 2.00;
115 unsigned int refine_on_size = 0;
116 unsigned int refine_on_threshold = 0;
119 if(mrRemesh.
Refine->RefiningOptions.Is(MesherUtilities::REFINE_ELEMENTS)
120 && mrRemesh.
Refine->RefiningOptions.Is(MesherUtilities::REFINE_ADD_NODES) )
123 ModelPart::ElementsContainerType::iterator element_begin = mrModelPart.
ElementsBegin();
125 unsigned int nds = (*element_begin).GetGeometry().size();
139 ModelPart::NodesContainerType::iterator nodes_begin = mrModelPart.
NodesBegin();
144 if(mrRemesh.
Refine->RefiningOptions.IsNot(MesherUtilities::REFINE_BOUNDARY)){
146 for(
unsigned int i = 0;
i<mrModelPart.
Nodes().size();
i++)
156 if ( (nodes_begin +
i)->
Is(BOUNDARY))
158 double & nodal_h=(nodes_begin +
i)->FastGetSolutionStepValue(NODAL_H);
159 nodal_h*=nodal_h_non_refining_factor;
169 mrRemesh.
Info->CriticalElements = 0;
171 for(
int el = 0;
el< OutNumberOfElements;
el++)
176 double prescribed_h = 0;
177 bool dissipative =
false;
178 bool refine_size =
false;
180 unsigned int count_dissipative = 0;
181 unsigned int count_boundary_inserted = 0;
182 unsigned int count_boundary = 0;
183 unsigned int count_contact_boundary = 0;
187 for(
unsigned int pn=0;
pn<nds;
pn++)
190 InElementList[
id*nds+
pn]= OutElementList[
el*nds+
pn];
192 vertices.
push_back(*(nodes_begin + OutElementList[
el*nds+
pn]-1).base());
194 prescribed_h += (nodes_begin + OutElementList[
el*nds+
pn]-1)->FastGetSolutionStepValue(NODAL_H);
196 if((nodes_begin + OutElementList[
el*nds+
pn]-1)->Is(TO_REFINE))
197 count_dissipative+=1;
199 if((nodes_begin + OutElementList[
el*nds+
pn]-1)->Is(BOUNDARY)){
203 if((nodes_begin + OutElementList[
el*nds+
pn]-1)->Is(NEW_ENTITY))
204 count_boundary_inserted+=1;
207 if( (nodes_begin + OutElementList[
el*nds+
pn]-1)->SolutionStepsDataHas(CONTACT_FORCE) ){
208 array_1d<double, 3 > & ContactForceNormal = (nodes_begin + OutElementList[
el*nds+
pn]-1)->FastGetSolutionStepValue(CONTACT_FORCE);
209 if(
norm_2(ContactForceNormal) )
210 count_contact_boundary+=1;
221 bool refine_candidate =
true;
222 if (mrRemesh.
Refine->RefiningBoxSetFlag ==
true ){
223 refine_candidate = mMesherUtilities.
CheckVerticesInBox(vertices,*(mrRemesh.
Refine->RefiningBox),CurrentProcessInfo);
228 double element_size = 0;
233 prescribed_h *= 0.3333;
236 double element_ideal_radius = 0;
238 element_ideal_radius = sqrt(3.0) * 0.25 * (
h *
h );
243 element_ideal_radius = (
h *
h *
h )/( 6.0 * sqrt(2.0) );
249 if( refine_candidate ){
253 if(count_dissipative>=nds-1){
256 mrRemesh.
Info->CriticalElements += 1;
266 double critical_size = size_for_inside_elements;
267 if(count_boundary>=nds-1)
268 critical_size = size_for_boundary_elements;
271 if( element_radius > critical_size ){
277 if(mrRemesh.
Refine->RefiningOptions.Is(MesherUtilities::REFINE_ELEMENTS_ON_THRESHOLD)
278 && mrRemesh.
Refine->RefiningOptions.Is(MesherUtilities::REFINE_ELEMENTS_ON_DISTANCE))
285 if( (dissipative ==
true && refine_size ==
true) )
287 InElementSizeList[id] = nodal_h_refining_factor * element_size;
289 refine_on_threshold += 1;
292 else if (refine_size ==
true)
296 InElementSizeList[id] = element_ideal_radius;
298 if( count_boundary_inserted && count_contact_boundary){
300 InElementSizeList[id] = nodal_h_refining_factor * element_ideal_radius;
302 std::cout<<
" count boundary inserted-contact on "<<std::endl;
311 InElementSizeList[id] = nodal_h_non_refining_factor * element_size;
318 else if(mrRemesh.
Refine->RefiningOptions.Is(MesherUtilities::REFINE_ELEMENTS_ON_DISTANCE))
322 if( refine_size ==
true ){
324 InElementSizeList[id] = nodal_h_refining_factor * element_ideal_radius;
329 InElementSizeList[id] = element_ideal_radius;
336 InElementSizeList[id] = nodal_h_non_refining_factor * element_size;
347 InElementSizeList[id] = nodal_h_non_refining_factor * element_size;
364 if(mrRemesh.
Refine->RefiningOptions.IsNot(MesherUtilities::REFINE_BOUNDARY)){
366 for(
unsigned int i = 0;
i<mrModelPart.
Nodes().size();
i++)
376 if ( (nodes_begin +
i)->Is(BOUNDARY))
378 double & nodal_h=(nodes_begin +
i)->FastGetSolutionStepValue(NODAL_H);
379 nodal_h/=nodal_h_non_refining_factor;
388 ModelPart::ElementsContainerType::iterator element_begin = mrModelPart.
ElementsBegin();
390 unsigned int nds = (*element_begin).GetGeometry().size();
405 ModelPart::NodesContainerType::iterator nodes_begin = mrModelPart.
NodesBegin();
407 for(
int el = 0;
el< OutNumberOfElements;
el++)
412 for(
unsigned int pn=0;
pn<nds;
pn++)
415 InElementList[
id*nds+
pn]= OutElementList[
el*nds+
pn];
416 vertices.
push_back(*(nodes_begin + OutElementList[
el*nds+
pn]-1).base());
419 double element_size = 0;
422 InElementSizeList[id] = nodal_h_non_refining_factor * element_size;
432 if( mEchoLevel > 0 ){
433 std::cout<<
" Visited Elements: "<<
id<<
" [threshold:"<<refine_on_threshold<<
"/size:"<<refine_on_size<<
"]"<<std::endl;
434 std::cout<<
" SELECT ELEMENTS TO REFINE ]; "<<std::endl;
457 std::string
Info()
const override
459 return "RefineElementsOnSizeMesherProcess";
465 rOStream <<
"RefineElementsOnSizeMesherProcess";
539 rOStream << std::endl;
Base class for all Conditions.
Definition: condition.h:59
bool Is(Flags const &rOther) const
Definition: flags.h:274
Geometry base class.
Definition: geometry.h:71
void push_back(PointPointerType x)
Definition: geometry.h:548
The base class for processes passed to the solution scheme.
Definition: mesher_process.hpp:37
Short class definition.
Definition: mesher_utilities.hpp:49
static double CalculateElementRadius(Geometry< Node > &rGeometry)
Definition: mesher_utilities.hpp:1142
bool CheckVerticesInBox(Geometry< Node > &rGeometry, SpatialBoundingBox &rRefiningBox, ProcessInfo &rCurrentProcessInfo)
Definition: mesher_utilities.cpp:1615
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
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
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_size_mesher_process.hpp:48
RefineElementsOnSizeMesherProcess(ModelPart &rModelPart, MesherUtilities::MeshingParameters &rRemeshingParameters, int EchoLevel)
Default constructor.
Definition: refine_elements_on_size_mesher_process.hpp:65
void Execute() override
Execute method is used to execute the Process algorithms.
Definition: refine_elements_on_size_mesher_process.hpp:96
ModelPart::PropertiesType PropertiesType
Definition: refine_elements_on_size_mesher_process.hpp:57
std::string Info() const override
Turn back information as a string.
Definition: refine_elements_on_size_mesher_process.hpp:457
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: refine_elements_on_size_mesher_process.hpp:463
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: refine_elements_on_size_mesher_process.hpp:469
ConditionType::GeometryType GeometryType
Definition: refine_elements_on_size_mesher_process.hpp:58
ModelPart::ConditionType ConditionType
Definition: refine_elements_on_size_mesher_process.hpp:56
KRATOS_CLASS_POINTER_DEFINITION(RefineElementsOnSizeMesherProcess)
Pointer definition of Process.
void operator()()
This operator is provided to call the process as a function and simply calls the Execute method.
Definition: refine_elements_on_size_mesher_process.hpp:84
virtual ~RefineElementsOnSizeMesherProcess()
Destructor.
Definition: refine_elements_on_size_mesher_process.hpp:76
#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
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
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
h
Definition: generate_droplet_dynamics.py:91
pn
Definition: generate_droplet_dynamics.py:65
el
Definition: read_stl.py:25
integer i
Definition: TensorModule.f:17
Definition: mesher_utilities.hpp:149
void CreateElementSizeList(const unsigned int NumberOfElements)
Definition: mesher_utilities.hpp:207
int * GetElementList()
Definition: mesher_utilities.hpp:178
void CreateElementList(const unsigned int NumberOfElements, const unsigned int NumberOfVertices)
Definition: mesher_utilities.hpp:196
int & GetNumberOfElements()
Definition: mesher_utilities.hpp:183
double * GetElementSizeList()
Definition: mesher_utilities.hpp:179
Definition: mesher_utilities.hpp:631
MeshingInfoParameters::Pointer Info
Definition: mesher_utilities.hpp:681
std::vector< int > PreservedElements
Definition: mesher_utilities.hpp:669
RefiningParameters::Pointer Refine
Definition: mesher_utilities.hpp:684
MeshContainer InMesh
Definition: mesher_utilities.hpp:674
MeshContainer OutMesh
Definition: mesher_utilities.hpp:675
double AlphaParameter
Definition: mesher_utilities.hpp:651