13 #if !defined(KRATOS_LOCAL_REFINE_PRISM_MESH)
14 #define KRATOS_LOCAL_REFINE_PRISM_MESH
95 std::vector<int> node_center;
97 int Id_Center = pNodes.size() + 1;
99 ElementsArrayType::iterator it_begin = rElements.ptr_begin();
100 ElementsArrayType::iterator it_end = rElements.ptr_end();
101 for (ElementsArrayType::iterator it = it_begin; it != it_end; ++it)
104 noalias(Coord_Node_1) = geom[0].Coordinates();
105 noalias(Coord_Node_2) = geom[1].Coordinates();
106 noalias(Coord_Node_3) = geom[2].Coordinates();
107 noalias(Coord_Node_4) = geom[3].Coordinates();
108 noalias(Coord_Node_5) = geom[4].Coordinates();
109 noalias(Coord_Node_6) = geom[5].Coordinates();
113 noalias(Coordinate_center_node) = 0.16666666666666666 * (Coord_Node_1 + Coord_Node_2 + Coord_Node_3 +
114 Coord_Node_4 + Coord_Node_5 + Coord_Node_6);
117 Node ::Pointer pnode = this_model_part.
CreateNewNode(Id_Center, Coordinate_center_node[0], Coordinate_center_node[1], Coordinate_center_node[2]);
118 pnode->SetBufferSize(this_model_part.
NodesBegin()->GetBufferSize());
120 pnode->X0() = 0.16666666666666666 * (geom[0].X0() + geom[1].X0() + geom[2].X0() + geom[3].X0() + geom[4].X0() + geom[5].X0());
121 pnode->Y0() = 0.16666666666666666 * (geom[0].Y0() + geom[1].Y0() + geom[2].Y0() + geom[3].Y0() + geom[4].Y0() + geom[5].Y0());
122 pnode->Z0() = 0.16666666666666666 * (geom[0].Z0() + geom[1].Z0() + geom[2].Z0() + geom[3].Z0() + geom[4].Z0() + geom[5].Z0());
124 for (Node ::DofsContainerType::iterator iii = reference_dofs.begin(); iii != reference_dofs.end(); iii++)
127 Node ::DofType::Pointer p_new_dof = pnode->pAddDof(rDof);
128 if (geom[0].IsFixed(rDof.GetVariable()) && geom[1].IsFixed(rDof.GetVariable()) && geom[2].IsFixed(rDof.GetVariable()) && geom[3].IsFixed(rDof.GetVariable())
129 && geom[4].IsFixed(rDof.GetVariable()) && geom[5].IsFixed(rDof.GetVariable()))
131 (p_new_dof)->FixDof();
135 (p_new_dof)->FreeDof();
140 unsigned int buffer_size = pnode->GetBufferSize();
143 double* new_step_data = pnode->SolutionStepData().Data(
step);
146 double* step_data1 = geom[0].SolutionStepData().Data(
step);
147 double* step_data2 = geom[1].SolutionStepData().Data(
step);
148 double* step_data3 = geom[2].SolutionStepData().Data(
step);
151 double* step_data4 = geom[3].SolutionStepData().Data(
step);
152 double* step_data5 = geom[4].SolutionStepData().Data(
step);
153 double* step_data6 = geom[5].SolutionStepData().Data(
step);
156 for (
unsigned int j = 0;
j < step_data_size;
j++)
158 new_step_data[
j] = 0.16666666666666666 * (step_data1[
j] + step_data2[
j] + step_data3[
j] +
159 step_data4[
j] + step_data5[
j] + step_data6[
j]);
180 const compressed_matrix<int>& Coord,
182 bool interpolate_internal_variables
186 ElementsArrayType::iterator it_begin = rElements.ptr_begin();
187 ElementsArrayType::iterator it_end = rElements.ptr_end();
188 unsigned int to_be_deleted = 0;
189 unsigned int large_id = (rElements.end() - 1)->Id() * 10;
190 bool create_element =
false;
194 int splitted_edges = 0;
196 std::vector<int> aux;
200 std::cout <<
"****************** REFINING MESH ******************" << std::endl;
201 std::cout <<
"OLD NUMBER ELEMENTS: " << rElements.size() << std::endl;
203 unsigned int current_id = (rElements.end() - 1)->Id() + 1;
204 for (ElementsArrayType::iterator it = it_begin; it != it_end; ++it)
215 create_element =
Split_Prism(edge_ids,
t, &number_elem, &splitted_edges, &nint);
218 if (create_element ==
true)
221 for (
int i = 0;
i < number_elem;
i++)
223 unsigned int base =
i * 6;
224 unsigned int i0 = aux[
t[base]];
225 unsigned int i1 = aux[
t[base + 1]];
226 unsigned int i2 = aux[
t[base + 2]];
227 unsigned int i3 = aux[
t[base + 3]];
228 unsigned int i4 = aux[
t[base + 4]];
229 unsigned int i5 = aux[
t[base + 5]];
232 this_model_part.
Nodes()(i0),
233 this_model_part.
Nodes()(i1),
234 this_model_part.
Nodes()(i2),
235 this_model_part.
Nodes()(i3),
236 this_model_part.
Nodes()(i4),
237 this_model_part.
Nodes()(i5)
240 Element::Pointer p_element;
241 p_element = it->Create(
current_id, geom, it->pGetProperties());
242 p_element->Initialize(rCurrentProcessInfo);
243 p_element->InitializeSolutionStep(rCurrentProcessInfo);
244 p_element->FinalizeSolutionStep(rCurrentProcessInfo);
247 if (interpolate_internal_variables ==
true)
253 p_element->GetData() = it->GetData();
254 p_element->GetValue(SPLIT_ELEMENT) =
false;
267 rElements.push_back(*(it_new.base()));
274 rElements.erase(this_model_part.
Elements().end() - to_be_deleted, this_model_part.
Elements().end());
276 std::cout <<
"NEW NUMBER ELEMENTS: " << rElements.size() << std::endl;
290 const compressed_matrix<int>& Coord
299 if (rConditions.size() > 0)
301 ConditionsArrayType::iterator it_begin = rConditions.ptr_begin();
302 ConditionsArrayType::iterator it_end = rConditions.ptr_end();
303 unsigned int to_be_deleted = 0;
304 unsigned int large_id = (rConditions.end() - 1)->Id() * 7;
308 unsigned int current_id = (rConditions.end() - 1)->Id() + 1;
310 for (ConditionsArrayType::iterator it = it_begin; it != it_end; ++it)
314 if (geom.
size() == 2)
316 int index_0 = geom[0].
Id() - 1;
317 int index_1 = geom[1].
Id() - 1;
320 if (index_0 > index_1)
322 new_id = Coord(index_1, index_0);
326 new_id = Coord(index_0, index_1);
334 this_model_part.
Nodes()(geom[0].
Id()),
335 this_model_part.
Nodes()(new_id)
339 this_model_part.
Nodes()(new_id),
340 this_model_part.
Nodes()(geom[1].
Id())
343 Condition::Pointer pcond1 = it->Create(
current_id++, newgeom1, it->pGetProperties());
344 Condition::Pointer pcond2 = it->Create(
current_id++, newgeom2, it->pGetProperties());
346 pcond1->GetData() = it->GetData();
347 pcond2->GetData() = it->GetData();
364 unsigned int total_size = this_model_part.
Conditions().size() + New_Conditions.
size();
365 this_model_part.
Conditions().reserve(total_size);
370 it_new->Initialize(rCurrentProcessInfo);
371 it_new->InitializeSolutionStep(rCurrentProcessInfo);
372 it_new->FinalizeSolutionStep(rCurrentProcessInfo);
373 this_model_part.
Conditions().push_back(*(it_new.base()));
377 unsigned int my_index = 1;
380 it->SetId(my_index++);
402 const compressed_matrix<int>& Coord,
404 std::vector<int> & aux
407 aux.resize(12,
false);
414 aux[0] = geom[0].
Id();
415 aux[1] = geom[1].
Id();
416 aux[2] = geom[2].
Id();
423 aux[3] = geom[3].
Id();
424 aux[4] = geom[4].
Id();
425 aux[5] = geom[5].
Id();
430 if (index_0 > index_1)
432 aux[6] = Coord(index_1, index_0);
433 aux[9] = Coord(index_4, index_3);
437 aux[6] = Coord(index_0, index_1);
438 aux[9] = Coord(index_3, index_4);
442 if (index_1 > index_2)
444 aux[7] = Coord(index_2, index_1);
445 aux[10] = Coord(index_5, index_4);
449 aux[7] = Coord(index_1, index_2);
450 aux[10] = Coord(index_4, index_5);
454 if (index_2 > index_0)
456 aux[8] = Coord(index_0, index_2);
457 aux[11] = Coord(index_3, index_5);
461 aux[8] = Coord(index_2, index_0);
462 aux[11] = Coord(index_5, index_3);
470 if (index_0 > index_1)
490 if (index_1 > index_2)
510 if (index_2 > index_0)
Geometry base class.
Definition: geometry.h:71
void push_back(PointPointerType x)
Definition: geometry.h:548
SizeType size() const
Definition: geometry.h:518
IndexType const & Id() const
Id of this Geometry.
Definition: geometry.h:964
An two node 3D line geometry with linear shape functions.
Definition: line_3d_2.h:64
Definition: local_refine_geometry_mesh.hpp:49
ModelPart::NodesContainerType NodesArrayType
Definition: local_refine_geometry_mesh.hpp:54
std::unordered_map< std::size_t, unsigned int > mMapNodeIdToPos
The current refinement level.
Definition: local_refine_geometry_mesh.hpp:240
void InterpolateInteralVariables(const int &number_elem, const TGeometricalObjectPointerType father_elem, TGeometricalObjectPointerType child_elem, const ProcessInfo &rCurrentProcessInfo)
Definition: local_refine_geometry_mesh.hpp:213
ModelPart::ElementsContainerType ElementsArrayType
Definition: local_refine_geometry_mesh.hpp:55
ModelPart::ConditionsContainerType ConditionsArrayType
Definition: local_refine_geometry_mesh.hpp:56
Definition: local_refine_prism_mesh.hpp:47
LocalRefinePrismMesh(ModelPart &model_part)
Default constructors.
Definition: local_refine_prism_mesh.hpp:57
void CalculateEdges(Element::GeometryType &geom, const compressed_matrix< int > &Coord, int *edge_ids, std::vector< int > &aux) override
Definition: local_refine_prism_mesh.hpp:400
void CalculateCoordinateCenterNodeAndInsertNewNodes(ModelPart &this_model_part)
Definition: local_refine_prism_mesh.hpp:80
void EraseOldConditionsAndCreateNew(ModelPart &this_model_part, const compressed_matrix< int > &Coord) override
Definition: local_refine_prism_mesh.hpp:288
void EraseOldElementAndCreateNewElement(ModelPart &this_model_part, const compressed_matrix< int > &Coord, PointerVector< Element > &New_Elements, bool interpolate_internal_variables) override
Definition: local_refine_prism_mesh.hpp:178
~LocalRefinePrismMesh() override=default
Destructor.
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
NodeType::Pointer CreateNewNode(int Id, double x, double y, double z, VariablesList::Pointer pNewVariablesList, IndexType ThisIndex=0)
Definition: model_part.cpp:270
ConditionIterator ConditionsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1361
SizeType GetNodalSolutionStepDataSize()
Definition: model_part.h:571
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
ConditionIterator ConditionsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1371
Dof< double > DofType
Dof type.
Definition: node.h:83
std::vector< std::unique_ptr< Dof< double > >> DofsContainerType
The DoF container type definition.
Definition: node.h:92
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
iterator end()
Definition: pointer_vector.h:177
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: pointer_vector.h:89
iterator begin()
Definition: pointer_vector.h:169
void push_back(const TPointerType &x)
Definition: pointer_vector.h:270
A six node prism geometry with linear shape functions.
Definition: prism_3d_6.h:60
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
#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
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
int step
Definition: face_heat.py:88
model_part
Definition: face_heat.py:14
int t
Definition: ode_solve.py:392
int j
Definition: quadrature.py:648
int current_id
Output settings end ####.
Definition: script.py:194
integer i
Definition: TensorModule.f:17
The class contains three helper functions to ease the splitting: PrismSplitMode, Split_Prism,...
int Split_Prism(const int edges[6], int t[24], int *number_elem, int *splitted_edges, int *nint)
Definition: split_prism.hpp:182