15 #if !defined(KRATOS_STRUCTURED_MESH_REFINEMENT_H_INCLUDED )
16 #define KRATOS_STRUCTURED_MESH_REFINEMENT_H_INCLUDED
98 old_elements.swap(rThisModelPart.
Elements());
101 old_conditions.swap(rThisModelPart.
Conditions());
103 const double tolerance = 1
e-9;
109 bins_type nodes_bins(rThisModelPart.
Nodes().ptr_begin(), rThisModelPart.
Nodes().ptr_end());
116 vector<int>& number_of_divisions = i_element->GetValue(STRUCTURED_MESH_DIVISIONS);
120 int start_element_id = 1;
121 if(rThisModelPart.
Elements().size() != 0)
122 start_element_id = rThisModelPart.
Elements().back().Id() + 1;
126 SizeType nodes_vector_size = number_of_divisions[0] + 1;
127 for(
SizeType i = 1 ;
i < number_of_divisions.size() ;
i++)
128 nodes_vector_size *= number_of_divisions[
i] + 1;
130 if(nodes_vector_size > i_element->GetGeometry().size())
134 GenerateNodes(*i_element, nodes_vector, surface_nodes_vector, number_of_divisions);
137 NodeType::Pointer p_node = nodes_vector(
i);
138 if(nodes_bins.SearchInRadius(*p_node, tolerance, founded_nodes.begin(), 1) > 0)
140 nodes_vector(
i) = founded_nodes[0];
145 rThisModelPart.
AddNode(p_node);
146 nodes_bins.AddPoint(p_node);
149 GenerateElements(rThisModelPart, *i_element, nodes_vector, surface_nodes_vector, number_of_divisions, start_element_id);
154 i_element->SetId(start_element_id);
155 rThisModelPart.
Elements().push_back(*(i_element.base()));
163 vector<int>& number_of_divisions = i_condition->GetValue(STRUCTURED_MESH_DIVISIONS);
166 int start_condition_id = rThisModelPart.
Conditions().size() + 1;
168 SizeType nodes_vector_size = number_of_divisions[0] + 1;
169 for(
SizeType i = 1 ;
i < i_condition->GetGeometry().LocalSpaceDimension() ;
i++)
170 nodes_vector_size *= number_of_divisions[
i] + 1;
172 if(nodes_vector_size > i_condition->GetGeometry().size())
176 GenerateNodes(*i_condition, nodes_vector, surface_nodes_vector, number_of_divisions);
179 NodeType::Pointer p_node = nodes_vector(
i);
180 if(nodes_bins.SearchInRadius(*p_node, tolerance, founded_nodes.begin(), 1) > 0)
182 nodes_vector(
i) = founded_nodes[0];
187 rThisModelPart.
AddNode(p_node);
188 nodes_bins.AddPoint(p_node);
191 GenerateConditions(rThisModelPart, *i_condition, nodes_vector, surface_nodes_vector, number_of_divisions, start_condition_id);
196 i_condition->SetId(start_condition_id);
197 rThisModelPart.
Conditions().push_back(*(i_condition.base()));
202 template<
class ComponentType>
205 SizeType local_dimension = rThisComponent.GetGeometry().LocalSpaceDimension();
209 if(local_dimension == 2)
211 for(
int i = 0 ;
i <= number_of_divisions[0] ;
i++)
213 local_coordinates[0] =
double(-1.00) +
double(2.00 *
i) / number_of_divisions[0];
214 for(
int j = 0 ;
j <= number_of_divisions[1] ;
j++)
216 local_coordinates[1] =
double(-1.00) +
double(2.00 *
j) / number_of_divisions[1];
217 GenerateNode(rThisComponent, VolumeNodesVector, SurfaceNodesVector, local_coordinates);
221 if(local_dimension == 3)
223 for(
int i = 0 ;
i <= number_of_divisions[0] ;
i++)
225 local_coordinates[0] =
double(-1.00) +
double(2.00 *
i) / number_of_divisions[0];
226 for(
int j = 0 ;
j <= number_of_divisions[1] ;
j++)
228 local_coordinates[1] =
double(-1.00) +
double(2.00 *
j) / number_of_divisions[1];
229 for(
int k = 0 ;
k <= number_of_divisions[2] ;
k++)
231 local_coordinates[2] =
double(-1.00) +
double(2.00 *
k) / number_of_divisions[2];
232 GenerateNode(rThisComponent, VolumeNodesVector, SurfaceNodesVector, local_coordinates);
239 template<
class ComponentType>
242 SizeType local_dimension = rThisComponent.GetGeometry().LocalSpaceDimension();
247 const SizeType components_nodes_number = r_geometry.size();
249 Vector shape_functions_values(components_nodes_number);
252 for(
SizeType h = 0 ;
h < components_nodes_number ;
h++)
253 shape_functions_values[
h] = r_geometry.ShapeFunctionValue(
h, rLocalCoordinates);
257 r_geometry.GlobalCoordinates(global_coordinates, rLocalCoordinates);
261 SizeType ndoal_data_size = r_geometry[0].SolutionStepData().TotalDataSize() /
sizeof(
double);
265 block_type* nodal_data =
new block_type[ndoal_data_size];
269 nodal_data[
i] = block_type();
271 for(
SizeType i = 0 ;
i < components_nodes_number ;
i++)
273 block_type* p_data = r_geometry[
i].SolutionStepData().Data();
276 nodal_data[
j] += shape_functions_values[
i] * p_data[
j];
281 NodeType::Pointer p_node(
new NodeType(0, global_coordinates[0], global_coordinates[1], global_coordinates[2], r_geometry[0].pGetVariablesList(), nodal_data, r_geometry[0].GetBufferSize()));
283 SizeType number_of_dofs = r_geometry[0].GetDofs().size();
285 for(NodeType::DofsContainerType::iterator i_dof = r_geometry[0].GetDofs().begin() ; i_dof != r_geometry[0].GetDofs().
end() ; i_dof++)
287 VariableData const& r_dof_variable = i_dof->GetVariable();
288 double dof_is_fixed =
double();
290 for(
SizeType i = 0 ;
i < components_nodes_number ;
i++)
292 dof_is_fixed += shape_functions_values[
i] *
static_cast<double>(r_geometry[
i].IsFixed(r_dof_variable));
294 if(dof_is_fixed > 0.999999)
296 p_node->pAddDof(*i_dof)->FixDof();
309 SizeType nodes_number_i = number_of_divisions[0] + 1;
310 SizeType nodes_number_j = number_of_divisions[1] + 1;
311 SizeType nodes_number_k = number_of_divisions[2] + 1;
313 if(local_dimension == 3)
315 for(
int i = 0 ;
i < number_of_divisions[0] ;
i++)
317 for(
int j = 0 ;
j < number_of_divisions[1] ;
j++)
319 for(
int k = 0 ;
k < number_of_divisions[2] ;
k++)
322 SizeType local_id =
i * nodes_number_k * nodes_number_j +
j * nodes_number_k +
k;
323 element_nodes(0) = VolumeNodesVector(local_id);
324 element_nodes(1) = VolumeNodesVector(local_id + nodes_number_j * nodes_number_k);
325 element_nodes(2) = VolumeNodesVector(local_id + nodes_number_j * nodes_number_k + nodes_number_k);
326 element_nodes(3) = VolumeNodesVector(local_id + nodes_number_k);
327 element_nodes(4) = VolumeNodesVector(local_id + 1);
328 element_nodes(5) = VolumeNodesVector(local_id + nodes_number_j * nodes_number_k + 1);
329 element_nodes(6) = VolumeNodesVector(local_id + nodes_number_j * nodes_number_k + nodes_number_k + 1);
330 element_nodes(7) = VolumeNodesVector(local_id + nodes_number_k + 1);
345 SizeType nodes_number_i = number_of_divisions[0] + 1;
346 SizeType nodes_number_j = number_of_divisions[1] + 1;
348 if(local_dimension == 2)
350 for(
int i = 0 ;
i < number_of_divisions[0] ;
i++)
352 for(
int j = 0 ;
j < number_of_divisions[1] ;
j++)
356 condition_nodes(0) = VolumeNodesVector(local_id);
357 condition_nodes(1) = VolumeNodesVector(local_id + nodes_number_j);
358 condition_nodes(2) = VolumeNodesVector(local_id + nodes_number_j + 1);
359 condition_nodes(3) = VolumeNodesVector(local_id + 1);
426 virtual std::string
Info()
const
428 return "StructuredMeshRefinementModeler";
509 double x1 = rGeometry[0][0];
510 double y1 = rGeometry[0][1];
511 double z1 = rGeometry[0][2];
512 double x2 = rGeometry[1][0];
513 double y2 = rGeometry[1][1];
514 double z2 = rGeometry[1][2];
516 double dx = (
x2 -
x1) / NumberOfSegments;
517 double dy = (y2 - y1) / NumberOfSegments;
518 double dz = (z2 - z1) / NumberOfSegments;
520 for(
SizeType i = 1 ;
i < NumberOfSegments - 1 ;
i++)
571 rOStream << std::endl;
A dynamic binning data structure template for organizing and querying points in multi-dimensional spa...
Definition: bins_dynamic.h:57
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
PropertiesType::Pointer pGetProperties()
returns the pointer to the property of the condition. Does not throw an error, to allow copying of co...
Definition: condition.h:964
Base class for all Elements.
Definition: element.h:60
virtual Pointer Create(IndexType NewId, NodesArrayType const &ThisNodes, PropertiesType::Pointer pProperties) const
It creates a new element pointer.
Definition: element.h:202
PropertiesType::Pointer pGetProperties()
returns the pointer to the property of the element. Does not throw an error, to allow copying of elem...
Definition: element.h:1014
GeometryType & GetGeometry()
Returns the reference of the geometry.
Definition: geometrical_object.h:158
Geometry base class.
Definition: geometry.h:71
SizeType size() const
Definition: geometry.h:518
SizeType LocalSpaceDimension() const
Definition: geometry.h:1300
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MeshType::ConditionsContainerType ConditionsContainerType
Condintions container. A vector set of Conditions with their Id's as key.
Definition: model_part.h:183
NodeType::Pointer CreateNewNode(int Id, double x, double y, double z, VariablesList::Pointer pNewVariablesList, IndexType ThisIndex=0)
Definition: model_part.cpp:270
void AddNode(NodeType::Pointer pNewNode, IndexType ThisIndex=0)
Definition: model_part.cpp:211
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
MeshType::ElementIterator ElementIterator
Definition: model_part.h:174
MeshType::ConditionIterator ConditionIterator
Definition: model_part.h:189
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
Modeler to interact with ModelParts.
Definition: modeler.h:39
std::size_t SizeType
Definition: modeler.h:47
This class defines the node.
Definition: node.h:65
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
size_type size() const
Definition: pointer_vector.h:255
void push_back(const TPointerType &x)
Definition: pointer_vector.h:270
Short class definition.
Definition: structured_mesh_refinement_modeler.h:59
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: structured_mesh_refinement_modeler.h:432
Modeler BaseType
Definition: structured_mesh_refinement_modeler.h:67
Node NodeType
Definition: structured_mesh_refinement_modeler.h:69
virtual ~StructuredMeshRefinementModeler()
Destructor.
Definition: structured_mesh_refinement_modeler.h:83
KRATOS_CLASS_POINTER_DEFINITION(StructuredMeshRefinementModeler)
Pointer definition of StructuredMeshRefinementModeler.
PointerVector< NodeType > NodesVectorType
Definition: structured_mesh_refinement_modeler.h:71
void GenerateMesh(ModelPart &rThisModelPart, Element const &rReferenceElement)
Definition: structured_mesh_refinement_modeler.h:95
void GenerateNodes(ComponentType &rThisComponent, NodesVectorType &VolumeNodesVector, NodesVectorType &SurfaceNodesVector, vector< int > &number_of_divisions)
Definition: structured_mesh_refinement_modeler.h:203
std::size_t SizeType
Definition: structured_mesh_refinement_modeler.h:73
void GenerateConditions(ModelPart &rThisModelPart, Condition &rThisCondition, NodesVectorType &VolumeNodesVector, NodesVectorType &SurfaceNodesVector, vector< int > &number_of_divisions, SizeType StartConditionId)
Definition: structured_mesh_refinement_modeler.h:341
virtual std::string Info() const
Turn back information as a string.
Definition: structured_mesh_refinement_modeler.h:426
void GenerateNodes(ModelPart &ThisModelPart, SizeType NumberOfSegments)
Definition: structured_mesh_refinement_modeler.h:368
void GenerateElements(ModelPart &rThisModelPart, Element &rThisElement, NodesVectorType &VolumeNodesVector, NodesVectorType &SurfaceNodesVector, vector< int > &number_of_divisions, SizeType StartElementId)
Definition: structured_mesh_refinement_modeler.h:305
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: structured_mesh_refinement_modeler.h:438
void GenerateNode(ComponentType &rThisComponent, NodesVectorType &VolumeNodesVector, NodesVectorType &SurfaceNodesVector, Element::GeometryType::CoordinatesArrayType &rLocalCoordinates)
Definition: structured_mesh_refinement_modeler.h:240
StructuredMeshRefinementModeler()
Default constructor.
Definition: structured_mesh_refinement_modeler.h:80
This class is the base of variables and variable's components which contains their common data.
Definition: variable_data.h:49
VariablesList::BlockType BlockType
The block type definition.
Definition: variables_list_data_value_container.h:70
Short class definition.
Definition: array_1d.h:61
end
Definition: DEM_benchmarks.py:180
typename Point::CoordinatesArrayType CoordinatesArrayType
Definition: add_geometries_to_python.cpp:63
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
Geometry< Node > GeometryType
The definition of the geometry.
Definition: mortar_classes.h:37
std::size_t SizeType
The definition of the size type.
Definition: mortar_classes.h:43
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
TABLE_NUMBER_ANGULAR_VELOCITY TABLE_NUMBER_MOMENT I33 BEAM_INERTIA_ROT_UNIT_LENGHT_Y KRATOS_DEFINE_APPLICATION_VARIABLE(DEM_APPLICATION, double, BEAM_INERTIA_ROT_UNIT_LENGHT_Z) typedef std double
Definition: DEM_application_variables.h:182
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
x2
Definition: generate_frictional_mortar_condition.py:122
x1
Definition: generate_frictional_mortar_condition.py:121
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
int node_id
Definition: read_stl.py:12
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31
Configure::ContainerType ContainerType
Definition: transfer_utility.h:247