11 #if !defined(KRATOS_TETGEN_PFEM_MODELER_H_INCLUDED )
12 #define KRATOS_TETGEN_PFEM_MODELER_H_INCLUDED
20 #include <boost/timer.hpp>
28 #include "utilities/geometry_utilities.h"
104 Element const& rReferenceElement,
105 Condition const& rReferenceBoundaryCondition,
107 double alpha_param = 1.4,
double h_factor=0.5)
111 if (ThisModelPart.
NodesBegin()->SolutionStepsDataHas(IS_FREE_SURFACE)==
false )
112 KRATOS_THROW_ERROR(std::logic_error,
"Add ----IS_FREE_SURFACE---- variable!!!!!! ERROR",
"");
113 if (ThisModelPart.
NodesBegin()->SolutionStepsDataHas(IS_STRUCTURE)==
false )
114 KRATOS_THROW_ERROR(std::logic_error,
"Add ----IS_STRUCTURE---- variable!!!!!! ERROR",
"");
115 if (ThisModelPart.
NodesBegin()->SolutionStepsDataHas(IS_BOUNDARY)==
false )
116 KRATOS_THROW_ERROR(std::logic_error,
"Add ----IS_BOUNDARY---- variable!!!!!! ERROR",
"");
117 if (ThisModelPart.
NodesBegin()->SolutionStepsDataHas(IS_FLUID)==
false )
120 KRATOS_WATCH(
" ENTERED TETGENMESHSUITE PFEM of Meshing Application")
127 boost::timer auxiliary;
130 typedef Node::Pointer PointPointerType;
132 typedef std::vector<PointType::Pointer>
PointVector;
150 unsigned int bucket_size = 20;
153 unsigned int max_results = 50;
158 Node work_point(0,0.0,0.0,0.0);
165 list_of_nodes.reserve(ThisModelPart.
Nodes().size());
166 for(ModelPart::NodesContainerType::iterator i_node = ThisModelPart.
NodesBegin() ; i_node != ThisModelPart.
NodesEnd() ; i_node++)
168 (list_of_nodes).push_back(*(i_node.base()));
172 kd_tree nodes_tree1(list_of_nodes.begin(),list_of_nodes.end(), bucket_size);
175 unsigned int n_points_in_radius;
179 for(ModelPart::NodesContainerType::const_iterator in = ThisModelPart.
NodesBegin();
180 in != ThisModelPart.
NodesEnd(); in++)
182 radius=h_factor*in->FastGetSolutionStepValue(NODAL_H);
184 work_point[0]=in->
X();
185 work_point[1]=in->
Y();
186 work_point[2]=in->
Z();
188 n_points_in_radius = nodes_tree1.SearchInRadius(work_point,
radius,
res.begin(),res_distances.begin(), max_results);
189 if (n_points_in_radius>1)
191 if (in->FastGetSolutionStepValue(IS_BOUNDARY)==0.0 && in->FastGetSolutionStepValue(IS_STRUCTURE)==0.0 && in->FastGetSolutionStepValue(IS_LAGRANGIAN_INLET)==0.0)
193 in->Set(TO_ERASE,
true);
208 tetgenio in,
out, in2, outnew;
213 in.numberofpoints = ThisModelPart.
Nodes().size();
214 in.pointlist =
new REAL[in.numberofpoints * 3];
217 ModelPart::NodesContainerType::iterator nodes_begin = ThisModelPart.
NodesBegin();
220 for(
unsigned int i = 0;
i<ThisModelPart.
Nodes().size();
i++)
222 (nodes_begin +
i)->SetId(
i+1);
227 for(
unsigned int i = 0;
i<ThisModelPart.
Nodes().size();
i++)
230 in.pointlist[base] = (nodes_begin +
i)->
X();
231 in.pointlist[base+1] = (nodes_begin +
i)->
Y();
232 in.pointlist[base+2] = (nodes_begin +
i)->
Z();
234 char tetgen_options[] =
"SQJ";
237 tetrahedralize(tetgen_options, &in, &
out);
240 double first_part_time = auxiliary.elapsed();
241 std::cout <<
"mesh generation time = " << first_part_time << std::endl;
244 int el_number =
out.numberoftetrahedra;
246 boost::timer alpha_shape_time;
248 std::vector<int> preserved_list(el_number);
251 int number_of_preserved_elems = 0;
252 for(
int el = 0;
el< el_number;
el++)
257 point_base = (
out.tetrahedronlist[base] - 1)*3;
258 x1[0] =
out.pointlist[point_base];
259 x1[1] =
out.pointlist[point_base+1];
260 x1[2] =
out.pointlist[point_base+2];
262 point_base = (
out.tetrahedronlist[base+1] - 1)*3;
263 x2[0] =
out.pointlist[point_base];
264 x2[1] =
out.pointlist[point_base+1];
265 x2[2] =
out.pointlist[point_base+2];
267 point_base = (
out.tetrahedronlist[base+2] - 1)*3;
268 x3[0] =
out.pointlist[point_base];
269 x3[1] =
out.pointlist[point_base+1];
270 x3[2] =
out.pointlist[point_base+2];
272 point_base = (
out.tetrahedronlist[base+3] - 1)*3;
273 x4[0] =
out.pointlist[point_base];
274 x4[1] =
out.pointlist[point_base+1];
275 x4[2] =
out.pointlist[point_base+2];
279 double geometrical_hmin, geometrical_hmax;
282 CalculateElementData(
x1,
x2,x3,x4,vol,
xc,
radius,geometrical_hmin,geometrical_hmax);
285 double prescribed_h = (nodes_begin +
out.tetrahedronlist[base]-1)->FastGetSolutionStepValue(NODAL_H);
286 prescribed_h += (nodes_begin +
out.tetrahedronlist[base+1]-1)->FastGetSolutionStepValue(NODAL_H);
287 prescribed_h += (nodes_begin +
out.tetrahedronlist[base+2]-1)->FastGetSolutionStepValue(NODAL_H);
288 prescribed_h += (nodes_begin +
out.tetrahedronlist[base+3]-1)->FastGetSolutionStepValue(NODAL_H);
289 prescribed_h *= 0.25;
292 int nb =
int( (nodes_begin +
out.tetrahedronlist[base]-1)->FastGetSolutionStepValue(IS_STRUCTURE) );
293 nb +=
int( (nodes_begin +
out.tetrahedronlist[base+1]-1)->FastGetSolutionStepValue(IS_STRUCTURE) );
294 nb +=
int( (nodes_begin +
out.tetrahedronlist[base+2]-1)->FastGetSolutionStepValue(IS_STRUCTURE) );
295 nb +=
int((nodes_begin +
out.tetrahedronlist[base+3]-1)->FastGetSolutionStepValue(IS_STRUCTURE) );
298 int nfs =
int( (nodes_begin +
out.tetrahedronlist[base]-1)->FastGetSolutionStepValue(IS_FREE_SURFACE) );
299 nfs +=
int( (nodes_begin +
out.tetrahedronlist[base+1]-1)->FastGetSolutionStepValue(IS_FREE_SURFACE) );
300 nfs +=
int( (nodes_begin +
out.tetrahedronlist[base+2]-1)->FastGetSolutionStepValue(IS_FREE_SURFACE) );
301 nfs +=
int((nodes_begin +
out.tetrahedronlist[base+3]-1)->FastGetSolutionStepValue(IS_FREE_SURFACE) );
304 int nfluid =
int( (nodes_begin +
out.tetrahedronlist[base]-1)->FastGetSolutionStepValue(IS_FLUID) );
305 nfluid +=
int( (nodes_begin +
out.tetrahedronlist[base+1]-1)->FastGetSolutionStepValue(IS_FLUID) );
306 nfluid +=
int( (nodes_begin +
out.tetrahedronlist[base+2]-1)->FastGetSolutionStepValue(IS_FLUID) );
307 nfluid +=
int((nodes_begin +
out.tetrahedronlist[base+3]-1)->FastGetSolutionStepValue(IS_FLUID) );
309 int n_lag =
int( (nodes_begin +
out.tetrahedronlist[base]-1)->FastGetSolutionStepValue(IS_LAGRANGIAN_INLET) );
310 n_lag +=
int( (nodes_begin +
out.tetrahedronlist[base+1]-1)->FastGetSolutionStepValue(IS_LAGRANGIAN_INLET) );
311 n_lag +=
int( (nodes_begin +
out.tetrahedronlist[base+2]-1)->FastGetSolutionStepValue(IS_LAGRANGIAN_INLET) );
312 n_lag +=
int((nodes_begin +
out.tetrahedronlist[base+3]-1)->FastGetSolutionStepValue(IS_LAGRANGIAN_INLET) );
338 preserved_list[
el] =
false;
344 if (n_lag >= 2 && nb==3 )
346 if(
radius < prescribed_h * 1.5*alpha_param )
349 preserved_list[
el] =
true;
350 number_of_preserved_elems += 1;
354 preserved_list[
el] =
false;
360 if(
radius < prescribed_h * alpha_param )
363 preserved_list[
el] =
true;
364 number_of_preserved_elems += 1;
368 preserved_list[
el] =
false;
374 else if (nfluid < 3.9)
376 if(
radius < prescribed_h * alpha_param )
379 preserved_list[
el] =
true;
380 number_of_preserved_elems += 1;
384 preserved_list[
el] =
false;
391 if(
radius < prescribed_h * alpha_param * 5.0 )
394 preserved_list[
el] =
true;
395 number_of_preserved_elems += 1;
400 preserved_list[
el] =
false;
409 std::cout <<
"time for passing alpha shape" << alpha_shape_time.elapsed() << std::endl;
419 in2.numberofpoints = ThisModelPart.
Nodes().size();
420 in2.pointlist =
new REAL[in2.numberofpoints * 3];
422 for(
unsigned int i = 0;
i<ThisModelPart.
Nodes().size();
i++)
425 in2.pointlist[base] = (nodes_begin +
i)->
X();
426 in2.pointlist[base+1] = (nodes_begin +
i)->
Y();
427 in2.pointlist[base+2] = (nodes_begin +
i)->
Z();
429 std::cout <<
"qui" << std::endl;
430 in2.numberoftetrahedra = number_of_preserved_elems;
431 in2.tetrahedronlist =
new int[in2.numberoftetrahedra * 4];
432 in2.tetrahedronvolumelist =
new double[in2.numberoftetrahedra];
435 for(
int el = 0;
el< el_number;
el++)
437 if( preserved_list[
el] )
442 in2.tetrahedronlist[new_base] =
out.tetrahedronlist[old_base];
443 in2.tetrahedronlist[new_base+1] =
out.tetrahedronlist[old_base+1];
444 in2.tetrahedronlist[new_base+2] =
out.tetrahedronlist[old_base+2];
445 in2.tetrahedronlist[new_base+3] =
out.tetrahedronlist[old_base+3];
448 double prescribed_h = (nodes_begin +
out.tetrahedronlist[old_base]-1)->FastGetSolutionStepValue(NODAL_H);
449 prescribed_h += (nodes_begin +
out.tetrahedronlist[old_base+1]-1)->FastGetSolutionStepValue(NODAL_H);
450 prescribed_h += (nodes_begin +
out.tetrahedronlist[old_base+2]-1)->FastGetSolutionStepValue(NODAL_H);
451 prescribed_h += (nodes_begin +
out.tetrahedronlist[old_base+3]-1)->FastGetSolutionStepValue(NODAL_H);
452 prescribed_h *= 0.25;
459 in2.tetrahedronvolumelist[
counter] = 2000.0*0.217*prescribed_h*prescribed_h*prescribed_h;
494 boost::timer mesh_recreation_time;
506 char mesh_regen_opts[] =
"rQJYYqnS";
507 tetrahedralize(mesh_regen_opts, &in2, &outnew);
512 char mesh_regen_opts[] =
"rQJYnS";
513 tetrahedralize(mesh_regen_opts, &in2, &outnew);
519 std::cout <<
"mesh recreation time" << mesh_recreation_time.elapsed() << std::endl;
549 int n_points_before_refinement = in2.numberofpoints;
551 if (outnew.numberofpoints>n_points_before_refinement)
553 for(
int i = n_points_before_refinement;
i<outnew.numberofpoints;
i++)
557 double&
x= outnew.pointlist[base];
558 double&
y= outnew.pointlist[base+1];
559 double&
z= outnew.pointlist[base+2];
565 list_of_new_nodes.push_back( pnode );
569 for(Node::DofsContainerType::iterator iii = reference_dofs.begin(); iii != reference_dofs.end(); iii++)
574 (p_new_dof)->FreeDof();
580 std::cout <<
"During refinement we added " << outnew.numberofpoints-n_points_before_refinement<<
"nodes " <<std::endl;
622 if(outnew.numberofpoints-n_points_before_refinement > 0)
624 kd_tree nodes_tree2(list_of_new_nodes.begin(),list_of_new_nodes.end(),bucket_size);
628 for(
int el = 0;
el< in2.numberoftetrahedra;
el++)
635 point_base = (in2.tetrahedronlist[base] - 1)*3;
636 x1[0] = in2.pointlist[point_base];
637 x1[1] = in2.pointlist[point_base+1];
638 x1[2] = in2.pointlist[point_base+2];
640 point_base = (in2.tetrahedronlist[base+1] - 1)*3;
641 x2[0] = in2.pointlist[point_base];
642 x2[1] = in2.pointlist[point_base+1];
643 x2[2] = in2.pointlist[point_base+2];
645 point_base = (in2.tetrahedronlist[base+2] - 1)*3;
646 x3[0] = in2.pointlist[point_base];
647 x3[1] = in2.pointlist[point_base+1];
648 x3[2] = in2.pointlist[point_base+2];
650 point_base = (in2.tetrahedronlist[base+3] - 1)*3;
651 x4[0] = in2.pointlist[point_base];
652 x4[1] = in2.pointlist[point_base+1];
653 x4[2] = in2.pointlist[point_base+2];
657 double geometrical_hmin, geometrical_hmax;
666 CalculateElementData(
x1,
x2,x3,x4,vol,
xc,
radius,geometrical_hmin,geometrical_hmax);
670 std::size_t number_of_points_in_radius;
671 work_point.
X() =
xc[0]; work_point.
Y() =
xc[1]; work_point.
Z() =
xc[2];
673 number_of_points_in_radius = nodes_tree2.SearchInRadius(work_point,
radius, results.begin(),results_distances.begin(), max_results);
681 *( (nodes_begin + in2.tetrahedronlist[base]-1).base() ),
682 *( (nodes_begin + in2.tetrahedronlist[base+1]-1).base() ),
683 *( (nodes_begin + in2.tetrahedronlist[base+2]-1).base() ),
684 *( (nodes_begin + in2.tetrahedronlist[base+3]-1).base() )
689 for(
auto it=results.begin(); it!=results.begin() + number_of_points_in_radius; it++)
691 bool is_inside=
false;
693 is_inside = CalculatePosition(
x1[0],
x1[1],
x1[2],
697 (*it)->X(),(*it)->Y(), (*it)->Z(),
N);
699 if(is_inside ==
true)
702 Interpolate( geom,
N, step_data_size, *(it) );
714 for(
auto & list_of_new_node : list_of_new_nodes)
716 const array_1d<double,3>& disp = list_of_new_node->FastGetSolutionStepValue(DISPLACEMENT);
717 list_of_new_node->X0() = list_of_new_node->X() - disp[0];
718 list_of_new_node->Y0() = list_of_new_node->Y() - disp[1];
719 list_of_new_node->Z0() = list_of_new_node->Z() - disp[2];
727 boost::timer adding_elems;
731 (ThisModelPart.
Elements()).reserve(outnew.numberoftetrahedra);
733 for(
int iii = 0; iii< outnew.numberoftetrahedra; iii++)
738 *( (nodes_begin + outnew.tetrahedronlist[base]-1).base() ),
739 *( (nodes_begin + outnew.tetrahedronlist[base+1]-1).base() ),
740 *( (nodes_begin + outnew.tetrahedronlist[base+2]-1).base() ),
741 *( (nodes_begin + outnew.tetrahedronlist[base+3]-1).base() )
747 if( *(ModelNodes).find( outnew.tetrahedronlist[base]).base() == *(ThisModelPart.
Nodes().end()).base() )
749 if( *(ModelNodes).find( outnew.tetrahedronlist[base+1]).base() == *(ThisModelPart.
Nodes().end()).base() )
751 if( *(ModelNodes).find( outnew.tetrahedronlist[base+2]).base() == *(ThisModelPart.
Nodes().end()).base() )
753 if( *(ModelNodes).find( outnew.tetrahedronlist[base+3]).base() == *(ThisModelPart.
Nodes().end()).base() )
757 Element::Pointer p_element = rReferenceElement.
Create(
id, geom, properties);
758 (ThisModelPart.
Elements()).push_back(p_element);
761 std::cout <<
"time for adding elems" << adding_elems.elapsed() << std::endl;;
764 boost::timer adding_neighb;
766 ModelPart::ElementsContainerType::const_iterator el_begin = ThisModelPart.
ElementsBegin();
767 for(ModelPart::ElementsContainerType::const_iterator iii = ThisModelPart.
ElementsBegin();
771 int base = ( iii->Id() - 1 )*4;
773 (iii->GetValue(NEIGHBOUR_ELEMENTS)).resize(4);
776 for(
int i = 0;
i<4;
i++)
778 int index = outnew.neighborlist[base+
i];
782 neighb(
i) = Element::WeakPointer();
785 std::cout <<
"time for adding neigbours" << adding_neighb.elapsed() << std::endl;;
795 for(ModelPart::NodesContainerType::const_iterator in = ThisModelPart.
NodesBegin(); in!=ThisModelPart.
NodesEnd(); in++)
797 in->FastGetSolutionStepValue(IS_BOUNDARY) = 0;
800 std::cout <<
"reset the boundary flag" << adding_neighb.elapsed() << std::endl;;
803 boost::timer adding_faces;
805 (ThisModelPart.
Conditions()).reserve(outnew.numberoftrifaces );
808 for(ModelPart::ElementsContainerType::const_iterator iii = ThisModelPart.
ElementsBegin();
812 int base = ( iii->Id() - 1 )*4;
824 if( outnew.neighborlist[base] == -1)
826 CreateBoundaryFace(1, 2, 3, ThisModelPart, 0, *(iii.base()), rReferenceBoundaryCondition, properties );
829 if( outnew.neighborlist[base+1] == -1)
831 CreateBoundaryFace(0,3,2, ThisModelPart, 1, *(iii.base()), rReferenceBoundaryCondition, properties );
833 if( outnew.neighborlist[base+2] == -1)
836 CreateBoundaryFace(0,1,3, ThisModelPart, 2, *(iii.base()), rReferenceBoundaryCondition, properties );
838 if( outnew.neighborlist[base+3] == -1)
841 CreateBoundaryFace(0,2,1, ThisModelPart, 3, *(iii.base()), rReferenceBoundaryCondition, properties );
845 outnew.deinitialize();
847 std::cout <<
"time for adding faces" << adding_faces.elapsed() << std::endl;;
872 double second_part_time = auxiliary.elapsed();
873 std::cout <<
"second part time = " << second_part_time - first_part_time << std::endl;
894 virtual std::string
Info()
const{
return "";}
955 boost::numeric::ublas::bounded_matrix<double,3,3> mJ;
956 boost::numeric::ublas::bounded_matrix<double,3,3> mJinv;
961 void CreateBoundaryFace(
const int& i1,
const int& i2,
const int& i3,
ModelPart& ThisModelPart,
const int& outer_node_id, Element::Pointer origin_element,
Condition const& rReferenceBoundaryCondition, Properties::Pointer properties)
967 geom[i1].FastGetSolutionStepValue(IS_BOUNDARY) = 1;
968 geom[i2].FastGetSolutionStepValue(IS_BOUNDARY) = 1;
969 geom[i3].FastGetSolutionStepValue(IS_BOUNDARY) = 1;
974 temp.push_back(geom(i1));
975 temp.push_back(geom(i2));
976 temp.push_back(geom(i3));
979 int id = (origin_element->Id()-1)*4;
980 Condition::Pointer p_cond = rReferenceBoundaryCondition.
Create(
id,
temp, properties);
983 (p_cond->GetValue(NEIGHBOUR_NODES)).clear();
984 (p_cond->GetValue(NEIGHBOUR_NODES)).push_back( Node::WeakPointer( geom(outer_node_id) ) );
985 (p_cond->GetValue(NEIGHBOUR_ELEMENTS)).clear();
986 (p_cond->GetValue(NEIGHBOUR_ELEMENTS)).push_back( Element::WeakPointer( origin_element ) );
994 void Interpolate( Tetrahedra3D4<Node >& geom,
const array_1d<double,4>&
N,
995 unsigned int step_data_size,
998 unsigned int buffer_size = pnode->GetBufferSize();
1005 double* step_data = (pnode)->SolutionStepData().Data(
step);
1008 double* node0_data = geom[0].SolutionStepData().Data(
step);
1009 double* node1_data = geom[1].SolutionStepData().Data(
step);
1010 double* node2_data = geom[2].SolutionStepData().Data(
step);
1011 double* node3_data = geom[3].SolutionStepData().Data(
step);
1014 for(
unsigned int j= 0;
j<step_data_size;
j++)
1017 step_data[
j] =
N[0]*node0_data[
j] +
N[1]*node1_data[
j] +
N[2]*node2_data[
j] +
N[3]*node3_data[
j];
1027 pnode->FastGetSolutionStepValue(IS_BOUNDARY)=0.0;
1028 pnode->FastGetSolutionStepValue(IS_STRUCTURE)=0.0;
1029 pnode->FastGetSolutionStepValue(IS_LAGRANGIAN_INLET)=0.0;
1030 pnode->FastGetSolutionStepValue(IS_FREE_SURFACE)=0.0;
1031 pnode->FastGetSolutionStepValue(IS_FLUID)=1.0;
1034 inline double CalculateVol(
const double x0,
const double y0,
const double z0,
1035 const double x1,
const double y1,
const double z1,
1036 const double x2,
const double y2,
const double z2,
1037 const double x3,
const double y3,
const double z3
1040 double x10 =
x1 - x0;
1041 double y10 = y1 - y0;
1042 double z10 = z1 - z0;
1044 double x20 =
x2 - x0;
1045 double y20 = y2 - y0;
1046 double z20 = z2 - z0;
1048 double x30 = x3 - x0;
1049 double y30 = y3 - y0;
1050 double z30 = z3 - z0;
1052 double detJ = x10 * y20 * z30 - x10 * y30 * z20 + y10 * z20 * x30 - y10 * x20 * z30 + z10 * x20 * y30 - z10 * y20 * x30;
1053 return detJ*0.1666666666666666666667;
1058 inline bool CalculatePosition(
const double x0,
const double y0,
const double z0,
1059 const double x1,
const double y1,
const double z1,
1060 const double x2,
const double y2,
const double z2,
1061 const double x3,
const double y3,
const double z3,
1062 const double xc,
const double yc,
const double zc,
1063 array_1d<double,4>&
N
1068 double vol = CalculateVol(x0,y0,z0,
x1,y1,z1,
x2,y2,z2,x3,y3,z3);
1070 double inv_vol = 0.0;
1074 KRATOS_WATCH(
"WARNING!!!!!!!!!! YOU HAVE A SLIVER HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
1079 inv_vol = 1.0 / vol;
1080 N[0] = CalculateVol(
x1,y1,z1,x3,y3,z3,
x2,y2,z2,
xc,
yc,zc) * inv_vol;
1081 N[1] = CalculateVol(x3,y3,z3,x0,y0,z0,
x2,y2,z2,
xc,
yc,zc) * inv_vol;
1082 N[2] = CalculateVol(x3,y3,z3,
x1,y1,z1,x0,y0,z0,
xc,
yc,zc) * inv_vol;
1083 N[3] = CalculateVol(x0,y0,z0,
x1,y1,z1,
x2,y2,z2,
xc,
yc,zc) * inv_vol;
1086 if(
N[0] >= 0.0 &&
N[1] >= 0.0 &&
N[2] >= 0.0 &&
N[3] >=0.0 &&
N[0] <= 1.0 &&
N[1] <= 1.0 &&
N[2] <= 1.0 &&
N[3] <=1.0)
1099 inline void CalculateCenterAndSearchRadius(
const double x0,
const double y0,
const double z0,
1100 const double x1,
const double y1,
const double z1,
1101 const double x2,
const double y2,
const double z2,
1102 const double x3,
const double y3,
const double z3,
1103 double&
xc,
double&
yc,
double& zc,
double&
R
1107 yc = 0.25*(y0+y1+y2+y3);
1108 zc = 0.25*(z0+z1+z2+z3);
1110 double R1 = (
xc-x0)*(
xc-x0) + (
yc-y0)*(
yc-y0) + (zc-z0)*(zc-z0);
1111 double R2 = (
xc-
x1)*(
xc-
x1) + (
yc-y1)*(
yc-y1) + (zc-z1)*(zc-z1);
1112 double R3 = (
xc-
x2)*(
xc-
x2) + (
yc-y2)*(
yc-y2) + (zc-z2)*(zc-z2);
1113 double R4 = (
xc-x3)*(
xc-x3) + (
yc-y3)*(
yc-y3) + (zc-z3)*(zc-z3);
1124 void CalculateElementData(
const array_1d<double,3>& c1,
1125 const array_1d<double,3>& c2,
1126 const array_1d<double,3>& c3,
1127 const array_1d<double,3>& c4,
1129 array_1d<double,3>&
xc,
1136 const double x0 = c1[0];
const double y0 = c1[1];
const double z0 = c1[2];
1137 const double x1 = c2[0];
const double y1 = c2[1];
const double z1 = c2[2];
1138 const double x2 = c3[0];
const double y2 = c3[1];
const double z2 = c3[2];
1139 const double x3 = c4[0];
const double y3 = c4[1];
const double z3 = c4[2];
1155 mJ(0,0) =
x1-x0; mJ(0,1) = y1-y0; mJ(0,2) = z1-z0;
1156 mJ(1,0) =
x2-x0; mJ(1,1) = y2-y0; mJ(1,2) = z2-z0;
1157 mJ(2,0) = x3-x0; mJ(2,1) = y3-y0; mJ(2,2) = z3-z0;
1162 mJinv(0,0) = mJ(1,1)*mJ(2,2) - mJ(1,2)*mJ(2,1);
1163 mJinv(1,0) = -mJ(1,0)*mJ(2,2) + mJ(1,2)*mJ(2,0);
1164 mJinv(2,0) = mJ(1,0)*mJ(2,1) - mJ(1,1)*mJ(2,0);
1166 mJinv(0,1) = -mJ(0,1)*mJ(2,2) + mJ(0,2)*mJ(2,1);
1167 mJinv(1,1) = mJ(0,0)*mJ(2,2) - mJ(0,2)*mJ(2,0);
1168 mJinv(2,1) = -mJ(0,0)*mJ(2,1) + mJ(0,1)*mJ(2,0);
1170 mJinv(0,2) = mJ(0,1)*mJ(1,2) - mJ(0,2)*mJ(1,1);
1171 mJinv(1,2) = -mJ(0,0)*mJ(1,2) + mJ(0,2)*mJ(1,0);
1172 mJinv(2,2) = mJ(0,0)*mJ(1,1) - mJ(0,1)*mJ(1,0);
1176 double detJ = mJ(0,0)*mJinv(0,0)
1177 + mJ(0,1)*mJinv(1,0)
1178 + mJ(0,2)*mJinv(2,0);
1180 volume = detJ * 0.16666666667;
1183 if(
volume < 1
e-3 * hmax*hmax*hmax)
1187 xc[0]=0.0;
xc[1]=0.0;
xc[2]=0.0;
1195 double x0_2 = x0*x0 + y0*y0 + z0*z0;
1196 double x1_2 =
x1*
x1 + y1*y1 + z1*z1;
1197 double x2_2 =
x2*
x2 + y2*y2 + z2*z2;
1198 double x3_2 = x3*x3 + y3*y3 + z3*z3;
1205 mRhs[0] = 0.5*(x1_2 - x0_2);
1206 mRhs[1] = 0.5*(x2_2 - x0_2);
1207 mRhs[2] = 0.5*(x3_2 - x0_2);
1222 template<
class T, std::
size_t dim >
1223 class PointDistance{
1225 double operator()( T
const& p1, T
const& p2 ){
1227 for( std::size_t
i = 0 ;
i <
dim ;
i++){
1228 double tmp = p1[
i] - p2[
i];
1235 template<
class T, std::
size_t dim >
1236 class DistanceCalculator{
1238 double operator()( T
const& p1, T
const& p2 ){
1240 for( std::size_t
i = 0 ;
i <
dim ;
i++){
1241 double tmp = p1[
i] - p2[
i];
1299 rOStream << std::endl;
Short class definition.
Definition: bucket.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
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
This class is a wrapper for a pointer to a data that is located in a different rank.
Definition: global_pointer.h:44
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
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
Short class definition.
Definition: tetgen_pfem_refine.h:67
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: tetgen_pfem_refine.h:897
virtual ~TetGenPfemModeler()=default
Destructor.
TetGenPfemModeler()
Default constructor.
Definition: tetgen_pfem_refine.h:80
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: tetgen_pfem_refine.h:900
void ReGenerateMesh(ModelPart &ThisModelPart, 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.h:102
virtual std::string Info() const
Turn back information as a string.
Definition: tetgen_pfem_refine.h:894
KRATOS_CLASS_POINTER_DEFINITION(TetGenPfemModeler)
Pointer definition of TetGenPfemModeler.
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
AMatrix::MatrixProductExpression< TExpression1Type, TExpression2Type > prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:568
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
REACTION_CHECK_STIFFNESS_FACTOR int
Definition: contact_structural_mechanics_application_variables.h:75
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
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
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