11 #if !defined(KRATOS_TETGEN_PFEM_REFINE_FACE_H_INCLUDED )
12 #define KRATOS_TETGEN_PFEM_REFINE_FACE_H_INCLUDED
20 #include <boost/timer.hpp>
28 #include "utilities/geometry_utilities.h"
103 Element const& rReferenceElement,
104 Condition const& rReferenceBoundaryCondition,
106 double alpha_param = 1.4,
double h_factor=0.5)
113 if (ThisModelPart.
NodesBegin()->SolutionStepsDataHas(IS_FREE_SURFACE)==
false )
114 KRATOS_THROW_ERROR(std::logic_error,
"Add ----IS_FREE_SURFACE---- variable!!!!!! ERROR",
"");
115 if (ThisModelPart.
NodesBegin()->SolutionStepsDataHas(IS_STRUCTURE)==
false )
116 KRATOS_THROW_ERROR(std::logic_error,
"Add ----IS_STRUCTURE---- variable!!!!!! ERROR",
"");
117 if (ThisModelPart.
NodesBegin()->SolutionStepsDataHas(IS_BOUNDARY)==
false )
118 KRATOS_THROW_ERROR(std::logic_error,
"Add ----IS_BOUNDARY---- variable!!!!!! ERROR",
"");
119 if (ThisModelPart.
NodesBegin()->SolutionStepsDataHas(IS_FLUID)==
false )
121 if (ThisModelPart.
NodesBegin()->SolutionStepsDataHas(IS_WATER)==
false )
123 if (ThisModelPart.
NodesBegin()->SolutionStepsDataHas(IS_INTERFACE)==
false )
124 KRATOS_THROW_ERROR(std::logic_error,
"Add ----IS_INTERFACE---- variable!!!!!! ERROR",
"");
132 std::vector <int> mid_face_list;
134 FaceDetecting(ThisModelPart, rElements, mid_face_list, face_num, h_factor);
141 int str_size = rElements.size();
155 boost::timer auxiliary;
158 typedef Node::Pointer PointPointerType;
160 typedef std::vector<PointType::Pointer>
PointVector;
178 unsigned int bucket_size = 64;
181 unsigned int max_results = 8000;
186 Node work_point(0,0.0,0.0,0.0);
192 list_of_nodes.reserve(ThisModelPart.
Nodes().size());
193 for(ModelPart::NodesContainerType::iterator i_node = ThisModelPart.
NodesBegin() ; i_node != ThisModelPart.
NodesEnd() ; i_node++)
195 (list_of_nodes).push_back(*(i_node.base()));
199 kd_tree nodes_tree1(list_of_nodes.begin(),list_of_nodes.end(), bucket_size);
202 unsigned int n_points_in_radius;
206 for(ModelPart::NodesContainerType::const_iterator in = ThisModelPart.
NodesBegin();
207 in != ThisModelPart.
NodesEnd(); in++)
209 radius=h_factor*in->FastGetSolutionStepValue(NODAL_H);
211 work_point[0]=in->
X();
212 work_point[1]=in->
Y();
213 work_point[2]=in->
Z();
215 n_points_in_radius = nodes_tree1.SearchInRadius(work_point,
radius,
res.begin(),res_distances.begin(), max_results);
216 if (n_points_in_radius>1)
218 if (in->FastGetSolutionStepValue(IS_BOUNDARY)==0.0 && in->FastGetSolutionStepValue(IS_STRUCTURE)==0.0&& in->FastGetSolutionStepValue(IS_INTERFACE)==0.0)
221 double erased_nodes = 0;
222 for(
auto i=
res.begin();
i!=
res.begin() + n_points_in_radius ;
i++)
223 erased_nodes += (*i)->Is(TO_ERASE);
226 if( erased_nodes < 1.0)
227 in->Set(TO_ERASE,
true);
247 for(ModelPart::NodesContainerType::const_iterator in = ThisModelPart.
NodesBegin();
248 in != ThisModelPart.
NodesEnd(); in++)
250 if((in)->FastGetSolutionStepValue(IS_INTERFACE) == 1.0 || (in)->FastGetSolutionStepValue(IS_STRUCTURE) == 1.0 || (in)->FastGetSolutionStepValue(FLAG_VARIABLE) == 5.0 )
251 in->Set(TO_ERASE,
false);
266 tetgenio in,
out, in2, outnew;
269 tetgenio::polygon *
p;
274 in.numberofpoints = ThisModelPart.
Nodes().size();
275 in.pointlist =
new REAL[in.numberofpoints * 3];
278 ModelPart::NodesContainerType::iterator nodes_begin = ThisModelPart.
NodesBegin();
280 std::vector <int> reorder_mid_face_list;
282 reorder_mid_face_list.resize(face_num*3,
false);
286 for(
unsigned int i = 0;
i<ThisModelPart.
Nodes().size();
i++)
288 int pr_id = (nodes_begin +
i)->Id();
290 (nodes_begin +
i)->SetId(
i+1);
296 if( (nodes_begin +
i)->FastGetSolutionStepValue(IS_INTERFACE) == 1.0 || (nodes_begin +
i)->FastGetSolutionStepValue(IS_STRUCTURE) == 1.0 )
298 for(
int jj = 0; jj < face_num*3; ++jj)
299 if( mid_face_list[jj] == pr_id)
300 reorder_mid_face_list[jj] = (nodes_begin +
i)->Id();
309 for(
unsigned int i = 0;
i<ThisModelPart.
Nodes().size();
i++)
312 in.pointlist[base] = (nodes_begin +
i)->
X();
313 in.pointlist[base+1] = (nodes_begin +
i)->
Y();
314 in.pointlist[base+2] = (nodes_begin +
i)->
Z();
340 in.numberoffacets = face_num;
341 in.facetmarkerlist =
new int[in.numberoffacets];
342 in.facetlist =
new tetgenio::facet[in.numberoffacets];
343 for(
int ii=0; ii<face_num; ++ii)
345 f = &in.facetlist[ii];
346 f->numberofpolygons = 1;
347 f->polygonlist =
new tetgenio::polygon[
f->numberofpolygons];
348 f->numberofholes = 0;
349 f->holelist =
nullptr;
352 p = &
f->polygonlist[0];
353 p->numberofvertices = 3;
354 p->vertexlist =
new int[
p->numberofvertices];
355 p->vertexlist[0] = reorder_mid_face_list[cnt];
356 p->vertexlist[1] = reorder_mid_face_list[cnt + 1];
357 p->vertexlist[2] = reorder_mid_face_list[cnt + 2];
361 in.facetmarkerlist[ii] = 5;
363 in.facetmarkerlist[ii] = 10;
369 in.numberofholes = 0;
370 in.holelist =
nullptr;
373 in.numberofregions = 1;
374 in.regionlist =
new REAL[in.numberofregions * 5];
376 in.regionlist[0] = 0.0;
377 in.regionlist[1] = 0.137;
378 in.regionlist[2] = 0.0;
380 in.regionlist[3] = -20;
381 in.regionlist[4] = -1;
404 char tetgen_options[] =
"pAYYjQ";
408 tetrahedralize(tetgen_options, &in, &
out);
417 double first_part_time = auxiliary.elapsed();
418 std::cout <<
"mesh generation time = " << first_part_time << std::endl;
421 int el_number =
out.numberoftetrahedra;
423 boost::timer alpha_shape_time;
425 std::vector<int> preserved_list(el_number);
428 int number_of_preserved_elems = 0;
429 int num_of_input = in.numberofpoints;
432 for(
int el = 0;
el< el_number;
el++)
435 if(
out.tetrahedronlist[base] > num_of_input ||
436 out.tetrahedronlist[base + 1] > num_of_input ||
437 out.tetrahedronlist[base + 2] > num_of_input ||
438 out.tetrahedronlist[base + 3] > num_of_input)
439 preserved_list[
el] =
false;
442 preserved_list[
el] =
true;
443 number_of_preserved_elems += 1;
450 std::cout <<
"time for passing alpha shape" << alpha_shape_time.elapsed() << std::endl;
454 in2.numberofpoints = ThisModelPart.
Nodes().size();
455 in2.pointlist =
new REAL[in2.numberofpoints * 3];
457 for(
unsigned int i = 0;
i<ThisModelPart.
Nodes().size();
i++)
460 in2.pointlist[base] = (nodes_begin +
i)->
X();
461 in2.pointlist[base+1] = (nodes_begin +
i)->
Y();
462 in2.pointlist[base+2] = (nodes_begin +
i)->
Z();
464 std::cout <<
"qui" << std::endl;
465 in2.numberoftetrahedra = number_of_preserved_elems;
466 in2.tetrahedronlist =
new int[in2.numberoftetrahedra * 4];
467 in2.tetrahedronvolumelist =
new double[in2.numberoftetrahedra];
469 in2.numberoftetrahedronattributes = 1;
470 in2.tetrahedronattributelist =
new REAL[in2.numberoftetrahedra * in2.numberoftetrahedronattributes ];
474 for(
int el = 0;
el< el_number;
el++)
476 if( preserved_list[
el] )
483 in2.tetrahedronlist[new_base] =
out.tetrahedronlist[old_base];
484 in2.tetrahedronlist[new_base+1] =
out.tetrahedronlist[old_base+1];
485 in2.tetrahedronlist[new_base+2] =
out.tetrahedronlist[old_base+2];
486 in2.tetrahedronlist[new_base+3] =
out.tetrahedronlist[old_base+3];
491 double prescribed_h = (nodes_begin +
out.tetrahedronlist[old_base]-1)->FastGetSolutionStepValue(NODAL_H);
492 prescribed_h += (nodes_begin +
out.tetrahedronlist[old_base+1]-1)->FastGetSolutionStepValue(NODAL_H);
493 prescribed_h += (nodes_begin +
out.tetrahedronlist[old_base+2]-1)->FastGetSolutionStepValue(NODAL_H);
494 prescribed_h += (nodes_begin +
out.tetrahedronlist[old_base+3]-1)->FastGetSolutionStepValue(NODAL_H);
495 prescribed_h *= 0.25;
500 in2.tetrahedronvolumelist[
counter] = 0.217*prescribed_h*prescribed_h*prescribed_h;
504 in2.tetrahedronattributelist[
counter] =
out.tetrahedronattributelist[
el];
531 boost::timer mesh_recreation_time;
546 char mesh_regen_opts[] =
"rMfjYYaq2.5nQ";
547 tetrahedralize(mesh_regen_opts, &in2, &outnew);
552 char mesh_regen_opts[] =
"rjYYnS";
553 tetrahedralize(mesh_regen_opts, &in2, &outnew);
563 std::cout <<
"mesh recreation time" << mesh_recreation_time.elapsed() << std::endl;
593 int n_points_before_refinement = in2.numberofpoints;
595 if (outnew.numberofpoints>n_points_before_refinement)
597 for(
int i = n_points_before_refinement;
i<outnew.numberofpoints;
i++)
601 double&
x= outnew.pointlist[base];
602 double&
y= outnew.pointlist[base+1];
603 double&
z= outnew.pointlist[base+2];
609 list_of_new_nodes.push_back( pnode );
613 for(Node::DofsContainerType::iterator iii = reference_dofs.begin(); iii != reference_dofs.end(); iii++)
618 (p_new_dof)->FreeDof();
636 std::cout <<
"During refinement we added " << outnew.numberofpoints-n_points_before_refinement<<
"nodes " <<std::endl;
642 max_results = list_of_new_nodes.size();
677 unsigned int fined_node_counter = 0;
678 if(outnew.numberofpoints-n_points_before_refinement > 0)
680 kd_tree nodes_tree2(list_of_new_nodes.begin(),list_of_new_nodes.end(),bucket_size);
684 for(
int el = 0;
el< in2.numberoftetrahedra;
el++)
691 point_base = (in2.tetrahedronlist[base] - 1)*3;
692 x1[0] = in2.pointlist[point_base];
693 x1[1] = in2.pointlist[point_base+1];
694 x1[2] = in2.pointlist[point_base+2];
696 point_base = (in2.tetrahedronlist[base+1] - 1)*3;
697 x2[0] = in2.pointlist[point_base];
698 x2[1] = in2.pointlist[point_base+1];
699 x2[2] = in2.pointlist[point_base+2];
701 point_base = (in2.tetrahedronlist[base+2] - 1)*3;
702 x3[0] = in2.pointlist[point_base];
703 x3[1] = in2.pointlist[point_base+1];
704 x3[2] = in2.pointlist[point_base+2];
706 point_base = (in2.tetrahedronlist[base+3] - 1)*3;
707 x4[0] = in2.pointlist[point_base];
708 x4[1] = in2.pointlist[point_base+1];
709 x4[2] = in2.pointlist[point_base+2];
713 double geometrical_hmin, geometrical_hmax;
717 in2_tet_attr = in2.tetrahedronattributelist[
el];
724 CalculateElementData(
x1,
x2,x3,x4,vol,
xc,
radius,geometrical_hmin,geometrical_hmax);
728 std::size_t number_of_points_in_radius;
729 work_point.
X() =
xc[0];
730 work_point.
Y() =
xc[1];
731 work_point.
Z() =
xc[2];
733 number_of_points_in_radius = nodes_tree2.SearchInRadius(work_point,
radius, results.begin(),results_distances.begin(), max_results);
735 if(number_of_points_in_radius == max_results)
736 KRATOS_WATCH(
"HHHHHHHHHHHH number_of_points_in_radius == max_results HHHHHHHHHH ");
742 *( (nodes_begin + in2.tetrahedronlist[base]-1).base() ),
743 *( (nodes_begin + in2.tetrahedronlist[base+1]-1).base() ),
744 *( (nodes_begin + in2.tetrahedronlist[base+2]-1).base() ),
745 *( (nodes_begin + in2.tetrahedronlist[base+3]-1).base() )
750 for(
auto it=results.begin(); it!=results.begin() + number_of_points_in_radius; it++)
752 bool is_inside=
false;
754 is_inside = CalculatePosition(
x1[0],
x1[1],
x1[2],
758 (*it)->X(),(*it)->Y(), (*it)->Z(),
N);
760 if(is_inside ==
true)
763 Interpolate( geom,
N, step_data_size, *(it), in2_tet_attr );
764 fined_node_counter++;
770 KRATOS_WATCH(
"DDDDDDDDDDDDDDDDDDDD AFTER INTERPOLATING ZZZZZZZZZZZZZZZZZZZZZZ");
771 if(list_of_new_nodes.size() > fined_node_counter)
776 KRATOS_WATCH(
"Definitly some nodes are not interpolated");
784 for(
auto & list_of_new_node : list_of_new_nodes)
786 const array_1d<double,3>& disp = list_of_new_node->FastGetSolutionStepValue(DISPLACEMENT);
787 list_of_new_node->X0() = list_of_new_node->X() - disp[0];
788 list_of_new_node->Y0() = list_of_new_node->Y() - disp[1];
789 list_of_new_node->Z0() = list_of_new_node->Z() - disp[2];
791 if(list_of_new_node->FastGetSolutionStepValue(IS_WATER) != 0.0 && list_of_new_node->FastGetSolutionStepValue(IS_WATER) != 1.0)
792 KRATOS_WATCH(
"SSSSSSSSSSSSSSSSSSS a non_interpolated node SSSSSSSSSSSSSSSSSSSSS");
799 boost::timer adding_elems;
805 (ThisModelPart.
Elements()).reserve(outnew.numberoftetrahedra);
807 for(
int iii = 0; iii< outnew.numberoftetrahedra; iii++)
813 *( (nodes_begin + outnew.tetrahedronlist[base]-1).base() ),
814 *( (nodes_begin + outnew.tetrahedronlist[base+1]-1).base() ),
815 *( (nodes_begin + outnew.tetrahedronlist[base+2]-1).base() ),
816 *( (nodes_begin + outnew.tetrahedronlist[base+3]-1).base() )
821 if( *(ModelNodes).find( outnew.tetrahedronlist[base]).base() == *(ThisModelPart.
Nodes().end()).base() )
823 if( *(ModelNodes).find( outnew.tetrahedronlist[base+1]).base() == *(ThisModelPart.
Nodes().end()).base() )
825 if( *(ModelNodes).find( outnew.tetrahedronlist[base+2]).base() == *(ThisModelPart.
Nodes().end()).base() )
827 if( *(ModelNodes).find( outnew.tetrahedronlist[base+3]).base() == *(ThisModelPart.
Nodes().end()).base() )
831 Element::Pointer p_element = rReferenceElement.
Create(
id, geom, properties);
832 (ThisModelPart.
Elements()).push_back(p_element);
834 if(outnew.tetrahedronattributelist[iii] == -20)
835 p_element->GetValue(IS_WATER_ELEMENT) = 0.0;
837 p_element->GetValue(IS_WATER_ELEMENT) = 1.0;
841 std::cout <<
"time for adding elems" << adding_elems.elapsed() << std::endl;;
868 std::cout <<
"time for adding neigbours is zero because n neighbor added"<<std::endl;;
875 for(ModelPart::NodesContainerType::const_iterator in = ThisModelPart.
NodesBegin(); in!=ThisModelPart.
NodesEnd(); in++)
877 in->FastGetSolutionStepValue(IS_BOUNDARY) = 0;
883 boost::timer adding_faces;
885 (ThisModelPart.
Conditions()).reserve(outnew.numberoftrifaces );
888 for(ModelPart::ElementsContainerType::const_iterator iii = ThisModelPart.
ElementsBegin();
892 int base = ( iii->Id() - 1 )*4;
904 if( outnew.neighborlist[base] == -1)
906 CreateBoundaryFace(1, 2, 3, ThisModelPart, 0, *(iii.base()), properties,rReferenceBoundaryCondition );
909 if( outnew.neighborlist[base+1] == -1)
911 CreateBoundaryFace(0,3,2, ThisModelPart, 1, *(iii.base()), properties, rReferenceBoundaryCondition );
913 if( outnew.neighborlist[base+2] == -1)
916 CreateBoundaryFace(0,1,3, ThisModelPart, 2, *(iii.base()), properties, rReferenceBoundaryCondition );
918 if( outnew.neighborlist[base+3] == -1)
921 CreateBoundaryFace(0,2,1, ThisModelPart, 3, *(iii.base()), properties, rReferenceBoundaryCondition );
947 outnew.deinitialize();
954 std::cout <<
"time for adding faces" << adding_faces.elapsed() << std::endl;;
979 double second_part_time = auxiliary.elapsed();
980 std::cout <<
"second part time = " << second_part_time - first_part_time << std::endl;
1065 boost::numeric::ublas::bounded_matrix<double,3,3> mJ;
1066 boost::numeric::ublas::bounded_matrix<double,3,3> mJinv;
1071 void CreateBoundaryFace(
const int& i1,
const int& i2,
const int& i3,
ModelPart& ThisModelPart,
const int& outer_node_id, Element::Pointer origin_element, Properties::Pointer properties,
Condition const& rReferenceBoundaryCondition)
1077 geom[i1].FastGetSolutionStepValue(IS_BOUNDARY) = 1;
1078 geom[i2].FastGetSolutionStepValue(IS_BOUNDARY) = 1;
1079 geom[i3].FastGetSolutionStepValue(IS_BOUNDARY) = 1;
1084 temp.push_back(geom(i1));
1085 temp.push_back(geom(i2));
1086 temp.push_back(geom(i3));
1089 int id = (origin_element->Id()-1)*4;
1092 Condition::Pointer p_cond = rReferenceBoundaryCondition.
Create(
id,
temp, properties);
1094 (p_cond->GetValue(NEIGHBOUR_NODES)).clear();
1095 (p_cond->GetValue(NEIGHBOUR_NODES)).push_back( Node::WeakPointer( geom(outer_node_id) ) );
1096 (p_cond->GetValue(NEIGHBOUR_ELEMENTS)).clear();
1097 (p_cond->GetValue(NEIGHBOUR_ELEMENTS)).push_back( Element::WeakPointer( origin_element ) );
1098 ThisModelPart.
Conditions().push_back(p_cond);
1105 void Interpolate( Tetrahedra3D4<Node >& geom,
const array_1d<double,4>&
N,
1106 unsigned int step_data_size,
1107 Node::Pointer pnode,
int tet_attr)
1109 unsigned int buffer_size = pnode->GetBufferSize();
1118 double* step_data = (pnode)->SolutionStepData().Data(
step);
1121 double* node0_data = geom[0].SolutionStepData().Data(
step);
1122 double* node1_data = geom[1].SolutionStepData().Data(
step);
1123 double* node2_data = geom[2].SolutionStepData().Data(
step);
1124 double* node3_data = geom[3].SolutionStepData().Data(
step);
1127 for(
unsigned int j= 0;
j<step_data_size;
j++)
1130 step_data[
j] =
N[0]*node0_data[
j] +
N[1]*node1_data[
j] +
N[2]*node2_data[
j] +
N[3]*node3_data[
j];
1140 pnode->FastGetSolutionStepValue(IS_BOUNDARY)=0.0;
1141 pnode->FastGetSolutionStepValue(IS_STRUCTURE)=0.0;
1142 pnode->FastGetSolutionStepValue(IS_FREE_SURFACE)=0.0;
1143 pnode->FastGetSolutionStepValue(IS_FLUID)=1.0;
1144 pnode->FastGetSolutionStepValue(IS_INTERFACE)=0.0;
1145 pnode->Set(TO_ERASE,
false);
1147 pnode->FastGetSolutionStepValue(IS_BOUNDARY,1)=0.0;
1148 pnode->FastGetSolutionStepValue(IS_STRUCTURE,1)=0.0;
1149 pnode->FastGetSolutionStepValue(IS_FREE_SURFACE,1)=0.0;
1150 pnode->FastGetSolutionStepValue(IS_FLUID,1)=1.0;
1151 pnode->FastGetSolutionStepValue(IS_INTERFACE,1)=0.0;
1156 if(pnode->FastGetSolutionStepValue(NODAL_H) == 0.0)
1159 mean_h += geom[0].FastGetSolutionStepValue(NODAL_H);
1160 mean_h += geom[1].FastGetSolutionStepValue(NODAL_H);
1161 mean_h += geom[2].FastGetSolutionStepValue(NODAL_H);
1162 mean_h += geom[3].FastGetSolutionStepValue(NODAL_H);
1164 pnode->FastGetSolutionStepValue(NODAL_H) = mean_h/4.0;
1165 pnode->FastGetSolutionStepValue(NODAL_H,1) = mean_h/4.0;
1183 pnode->FastGetSolutionStepValue(IS_WATER) = 0.0;
1184 pnode->FastGetSolutionStepValue(IS_WATER,1) = 0.0;
1191 pnode->FastGetSolutionStepValue(IS_WATER) = 1.0;
1192 pnode->FastGetSolutionStepValue(IS_WATER,1) = 1.0;
1201 inline double CalculateVol(
const double x0,
const double y0,
const double z0,
1202 const double x1,
const double y1,
const double z1,
1203 const double x2,
const double y2,
const double z2,
1204 const double x3,
const double y3,
const double z3
1207 double x10 =
x1 - x0;
1208 double y10 = y1 - y0;
1209 double z10 = z1 - z0;
1211 double x20 =
x2 - x0;
1212 double y20 = y2 - y0;
1213 double z20 = z2 - z0;
1215 double x30 = x3 - x0;
1216 double y30 = y3 - y0;
1217 double z30 = z3 - z0;
1219 double detJ = x10 * y20 * z30 - x10 * y30 * z20 + y10 * z20 * x30 - y10 * x20 * z30 + z10 * x20 * y30 - z10 * y20 * x30;
1220 return detJ*0.1666666666666666666667;
1225 inline bool CalculatePosition(
const double x0,
const double y0,
const double z0,
1226 const double x1,
const double y1,
const double z1,
1227 const double x2,
const double y2,
const double z2,
1228 const double x3,
const double y3,
const double z3,
1229 const double xc,
const double yc,
const double zc,
1230 array_1d<double,4>&
N
1235 double vol = CalculateVol(x0,y0,z0,
x1,y1,z1,
x2,y2,z2,x3,y3,z3);
1237 double inv_vol = 0.0;
1238 if(vol < 0.0000000000000000000000000000000000000000000001)
1246 inv_vol = 1.0 / vol;
1249 N[0] = CalculateVol(
x1,y1,z1,x3,y3,z3,
x2,y2,z2,
xc,
yc,zc) * inv_vol;
1250 N[1] = CalculateVol(x3,y3,z3,x0,y0,z0,
x2,y2,z2,
xc,
yc,zc) * inv_vol;
1251 N[2] = CalculateVol(x3,y3,z3,
x1,y1,z1,x0,y0,z0,
xc,
yc,zc) * inv_vol;
1252 N[3] = CalculateVol(x0,y0,z0,
x1,y1,z1,
x2,y2,z2,
xc,
yc,zc) * inv_vol;
1255 if(
N[0] >= 0.0 &&
N[1] >= 0.0 &&
N[2] >= 0.0 &&
N[3] >=0.0 &&
1256 N[0] <= 1.0 &&
N[1] <= 1.0 &&
N[2] <= 1.0 &&
N[3] <=1.0)
1264 inline void CalculateCenterAndSearchRadius(
const double x0,
const double y0,
const double z0,
1265 const double x1,
const double y1,
const double z1,
1266 const double x2,
const double y2,
const double z2,
1267 const double x3,
const double y3,
const double z3,
1268 double&
xc,
double&
yc,
double& zc,
double&
R
1272 yc = 0.25*(y0+y1+y2+y3);
1273 zc = 0.25*(z0+z1+z2+z3);
1275 double R1 = (
xc-x0)*(
xc-x0) + (
yc-y0)*(
yc-y0) + (zc-z0)*(zc-z0);
1276 double R2 = (
xc-
x1)*(
xc-
x1) + (
yc-y1)*(
yc-y1) + (zc-z1)*(zc-z1);
1277 double R3 = (
xc-
x2)*(
xc-
x2) + (
yc-y2)*(
yc-y2) + (zc-z2)*(zc-z2);
1278 double R4 = (
xc-x3)*(
xc-x3) + (
yc-y3)*(
yc-y3) + (zc-z3)*(zc-z3);
1289 void CalculateElementData(
const array_1d<double,3>& c1,
1290 const array_1d<double,3>& c2,
1291 const array_1d<double,3>& c3,
1292 const array_1d<double,3>& c4,
1294 array_1d<double,3>&
xc,
1301 const double x0 = c1[0];
1302 const double y0 = c1[1];
1303 const double z0 = c1[2];
1304 const double x1 = c2[0];
1305 const double y1 = c2[1];
1306 const double z1 = c2[2];
1307 const double x2 = c3[0];
1308 const double y2 = c3[1];
1309 const double z2 = c3[2];
1310 const double x3 = c4[0];
1311 const double y3 = c4[1];
1312 const double z3 = c4[2];
1326 if(aux<hmin) hmin = aux;
1327 else if(aux>hmax) hmax = aux;
1331 if(aux<hmin) hmin = aux;
1332 else if(aux>hmax) hmax = aux;
1336 if(aux<hmin) hmin = aux;
1337 else if(aux>hmax) hmax = aux;
1341 if(aux<hmin) hmin = aux;
1342 else if(aux>hmax) hmax = aux;
1346 if(aux<hmin) hmin = aux;
1347 else if(aux>hmax) hmax = aux;
1365 mJinv(0,0) = mJ(1,1)*mJ(2,2) - mJ(1,2)*mJ(2,1);
1366 mJinv(1,0) = -mJ(1,0)*mJ(2,2) + mJ(1,2)*mJ(2,0);
1367 mJinv(2,0) = mJ(1,0)*mJ(2,1) - mJ(1,1)*mJ(2,0);
1369 mJinv(0,1) = -mJ(0,1)*mJ(2,2) + mJ(0,2)*mJ(2,1);
1370 mJinv(1,1) = mJ(0,0)*mJ(2,2) - mJ(0,2)*mJ(2,0);
1371 mJinv(2,1) = -mJ(0,0)*mJ(2,1) + mJ(0,1)*mJ(2,0);
1373 mJinv(0,2) = mJ(0,1)*mJ(1,2) - mJ(0,2)*mJ(1,1);
1374 mJinv(1,2) = -mJ(0,0)*mJ(1,2) + mJ(0,2)*mJ(1,0);
1375 mJinv(2,2) = mJ(0,0)*mJ(1,1) - mJ(0,1)*mJ(1,0);
1379 double detJ = mJ(0,0)*mJinv(0,0)
1380 + mJ(0,1)*mJinv(1,0)
1381 + mJ(0,2)*mJinv(2,0);
1383 volume = detJ * 0.16666666667;
1386 if(
volume < 1
e-13 * hmax*hmax*hmax)
1400 double x0_2 = x0*x0 + y0*y0 + z0*z0;
1401 double x1_2 =
x1*
x1 + y1*y1 + z1*z1;
1402 double x2_2 =
x2*
x2 + y2*y2 + z2*z2;
1403 double x3_2 = x3*x3 + y3*y3 + z3*z3;
1410 mRhs[0] = 0.5*(x1_2 - x0_2);
1411 mRhs[1] = 0.5*(x2_2 - x0_2);
1412 mRhs[2] = 0.5*(x3_2 - x0_2);
1416 xc(0) = 0.25*(x0 +
x1 +
x2 + x3);
1417 xc(1) = 0.25*(y0 + y1 + y2 + y3);
1418 xc(2) = 0.25*(z0 + z1 + z2 + z3);
1421 array_1d<double,4> radii;
1423 radii(0) = pow(
xc[0] - x0,2) + pow(
xc[1] - y0,2) + pow(
xc[2] - z0,2);
1424 radii(1) = pow(
xc[0] -
x1,2) + pow(
xc[1] - y1,2) + pow(
xc[2] - z1,2);
1425 radii(2) = pow(
xc[0] -
x2,2) + pow(
xc[1] - y2,2) + pow(
xc[2] - z2,2);
1426 radii(3) = pow(
xc[0] - x3,2) + pow(
xc[1] - y3,2) + pow(
xc[2] - z3,2);
1429 for(
int ii=1; ii<4; ++ii)
1431 double candid = sqrt(radii(ii));
1446 template<
class T, std::
size_t dim >
1450 double operator()( T
const& p1, T
const& p2 )
1453 for( std::size_t
i = 0 ;
i <
dim ;
i++)
1455 double tmp = p1[
i] - p2[
i];
1462 template<
class T, std::
size_t dim >
1463 class DistanceCalculator
1466 double operator()( T
const& p1, T
const& p2 )
1469 for( std::size_t
i = 0 ;
i <
dim ;
i++)
1471 double tmp = p1[
i] - p2[
i];
1505 for(ModelPart::ElementsContainerType::iterator elem = rElements.begin();
1506 elem!=rElements.end(); elem++)
1508 Geometry< Node >& geom = elem->GetGeometry();
1513 face_list.push_back(geom[0].Id());
1514 face_list.push_back(geom[1].Id());
1515 face_list.push_back(geom[2].Id());
1516 geom[0].FastGetSolutionStepValue(IS_INTERFACE) = 1.0;
1517 geom[1].FastGetSolutionStepValue(IS_INTERFACE) = 1.0;
1518 geom[2].FastGetSolutionStepValue(IS_INTERFACE) = 1.0;
1521 for(ModelPart::ElementsContainerType::iterator elem = ThisModelPart.ElementsBegin();
1522 elem!=ThisModelPart.ElementsEnd(); elem++)
1525 if(elem->GetValue(IS_WATER_ELEMENT) == 1.0)
1527 Geometry< Node >& geom = elem->GetGeometry();
1532 for(
int ii=0; ii<4; ++ii)
1534 if(neighbor_els[ii].Id() == elem->Id())
1538 int is_bdr_five = 0;
1539 for(
int jj=0; jj<4; ++jj)
1540 if(geom[jj].FastGetSolutionStepValue(FLAG_VARIABLE) == 5.0)
1543 if(is_bdr_five >= 3.0)
1549 face_list.push_back(geom[2].Id());
1550 face_list.push_back(geom[3].Id());
1558 face_list.push_back(geom[0].Id());
1559 face_list.push_back(geom[2].Id());
1560 face_list.push_back(geom[3].Id());
1569 face_list.push_back(geom[0].Id());
1570 face_list.push_back(geom[1].Id());
1571 face_list.push_back(geom[3].Id());
1580 face_list.push_back(geom[0].Id());
1581 face_list.push_back(geom[1].Id());
1582 face_list.push_back(geom[2].Id());
1600 std::vector <int> shell_list;
1605 for(ModelPart::ElementsContainerType::iterator elem = rElements.begin();
1606 elem!=rElements.end(); elem++)
1608 Geometry< Node >& geom = elem->GetGeometry();
1611 shell_nodes.push_back(geom(1));
1612 shell_nodes.push_back(geom(2));
1616 shell_nodes.Unique();
1618 ModelPart::NodesContainerType::iterator nodes_begin = shell_nodes.begin();
1619 for(
unsigned int ii=0; ii < shell_nodes.size(); ii++)
1620 ( nodes_begin + ii ) ->SetId( ii + 1 );
1622 for(ModelPart::ElementsContainerType::iterator elem = rElements.begin();
1623 elem!=rElements.end(); elem++)
1626 Geometry< Node >& geom = elem->GetGeometry();
1627 shell_list.push_back(geom[0].Id());
1628 shell_list.push_back(geom[1].Id());
1629 shell_list.push_back(geom[2].Id());
1633 tetgenio in_shell, out_shell;
1635 in_shell.firstnumber = 1;
1636 in_shell.numberofpoints = shell_nodes.size();
1637 in_shell.pointlist =
new REAL[in_shell.numberofpoints * 3];
1641 tetgenio::polygon *
p;
1643 for(
unsigned int i = 0;
i<shell_nodes.size();
i++)
1646 in_shell.pointlist[base] = (nodes_begin +
i)->
X();
1647 in_shell.pointlist[base+1] = (nodes_begin +
i)->
Y();
1648 in_shell.pointlist[base+2] = (nodes_begin +
i)->
Z();
1655 in_shell.numberoffacets = shell_num;
1656 in_shell.facetmarkerlist =
new int[in_shell.numberoffacets];
1657 in_shell.facetlist =
new tetgenio::facet[in_shell.numberoffacets];
1658 for(
int ii=0; ii<shell_num; ++ii)
1660 f = &in_shell.facetlist[ii];
1661 f->numberofpolygons = 1;
1662 f->polygonlist =
new tetgenio::polygon[
f->numberofpolygons];
1663 f->numberofholes = 0;
1664 f->holelist =
nullptr;
1667 p = &
f->polygonlist[0];
1668 p->numberofvertices = 3;
1669 p->vertexlist =
new int[
p->numberofvertices];
1670 p->vertexlist[0] = shell_list[cnt];
1671 p->vertexlist[1] = shell_list[cnt + 1];
1672 p->vertexlist[2] = shell_list[cnt + 2];
1675 in_shell.facetmarkerlist[ii] = 5;
1679 in_shell.numberofholes = 0;
1680 in_shell.holelist =
nullptr;
1687 char tetgen_options[] =
"CCVpYYJ";
1691 tetrahedralize(tetgen_options, &in_shell, &out_shell);
1697 in_shell.deinitialize();
1700 in_shell.initialize();
1701 out_shell.deinitialize();
1704 out_shell.initialize();
1753 rOStream << std::endl;
Definition: bins_static.h:35
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
Dof represents a degree of freedom (DoF).
Definition: dof.h:86
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
This process removes the entities from a model part with the flag TO_ERASE.
Definition: entity_erase_process.h:70
void Execute() override
Execute method is used to execute the Process algorithms.
Geometry base class.
Definition: geometry.h:71
void push_back(TPointerType x)
Definition: global_pointers_vector.h:322
Definition: amatrix_interface.h:497
Definition: amatrix_interface.h:530
PropertiesType::Pointer pGetProperties(IndexType PropertiesId)
Definition: mesh.h:394
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
NodeType::Pointer CreateNewNode(int Id, double x, double y, double z, VariablesList::Pointer pNewVariablesList, IndexType ThisIndex=0)
Definition: model_part.cpp:270
SizeType GetNodalSolutionStepDataSize()
Definition: model_part.h:571
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
ElementIterator ElementsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1179
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
MeshType & GetMesh(IndexType ThisIndex=0)
Definition: model_part.h:1791
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
This class defines the node.
Definition: node.h:65
std::vector< std::unique_ptr< Dof< double > >> DofsContainerType
The DoF container type definition.
Definition: node.h:92
double Y() const
Definition: point.h:187
double Z() const
Definition: point.h:193
double X() const
Definition: point.h:181
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
void push_back(TPointerType x)
Adds a pointer to the end of the set.
Definition: pointer_vector_set.h:544
Short class definition.
Definition: tetgen_pfem_refine_face.h:66
TetGenPfemRefineFace()
Default constructor.
Definition: tetgen_pfem_refine_face.h:79
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: tetgen_pfem_refine_face.h:1010
void ReGenerateMesh(ModelPart &ThisModelPart, ModelPart::ElementsContainerType &rElements, Element const &rReferenceElement, Condition const &rReferenceBoundaryCondition, EntitiesEraseProcess< Node > &node_erase, bool rem_nodes=true, bool add_nodes=true, double alpha_param=1.4, double h_factor=0.5)
Definition: tetgen_pfem_refine_face.h:101
virtual std::string Info() const
Turn back information as a string.
Definition: tetgen_pfem_refine_face.h:1001
KRATOS_CLASS_POINTER_DEFINITION(TetGenPfemRefineFace)
Pointer definition of TetGenPfemRefineFace.
virtual ~TetGenPfemRefineFace()=default
Destructor.
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: tetgen_pfem_refine_face.h:1007
A four node tetrahedra geometry with linear shape functions.
Definition: tetrahedra_3d_4.h:59
A generic tree data structure for spatial partitioning.
Definition: tree.h:190
A three node 3D triangle geometry with linear shape functions.
Definition: triangle_3d_3.h:77
#define KRATOS_THROW_ERROR(ExceptionType, ErrorMessage, MoreInfo)
Definition: define.h:77
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_WATCH(variable)
Definition: define.h:806
#define KRATOS_TRY
Definition: define.h:109
#define REAL
Definition: delaunator_utilities.cpp:16
z
Definition: GenerateWind.py:163
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
TExpression1Type::data_type inner_prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:592
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
DistanceVector::iterator DistanceIterator
Definition: internal_variables_interpolation_process.h:56
std::vector< PointTypePointer > PointVector
Definition: internal_variables_interpolation_process.h:53
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
PointVector::iterator PointIterator
Definition: internal_variables_interpolation_process.h:54
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
std::vector< double > DistanceVector
Definition: internal_variables_interpolation_process.h:55
Point PointType
Geometric definitions.
Definition: mortar_classes.h:36
float dist
Definition: edgebased_PureConvection.py:89
int step
Definition: face_heat.py:88
y
Other simbols definition.
Definition: generate_axisymmetric_navier_stokes_element.py:54
res
Definition: generate_convection_diffusion_explicit_element.py:211
f
Definition: generate_convection_diffusion_explicit_element.py:112
x2
Definition: generate_frictional_mortar_condition.py:122
x1
Definition: generate_frictional_mortar_condition.py:121
tuple tmp
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:98
out
Definition: isotropic_damage_automatic_differentiation.py:200
R
Definition: isotropic_damage_automatic_differentiation.py:172
float radius
Definition: mesh_to_mdpa_converter.py:18
int j
Definition: quadrature.py:648
el
Definition: read_stl.py:25
float temp
Definition: rotating_cone.py:85
float xc
Definition: rotating_cone.py:77
float yc
Definition: rotating_cone.py:78
int counter
Definition: script_THERMAL_CORRECT.py:218
add_nodes
Definition: script.py:96
p
Definition: sensitivityMatrix.py:52
N
Definition: sensitivityMatrix.py:29
x
Definition: sensitivityMatrix.py:49
int dim
Definition: sensitivityMatrix.py:25
volume
Definition: sp_statistics.py:15
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31