10 #if !defined(KRATOS_TETGEN_VOLUME_MESHER_H_INCLUDED )
11 #define KRATOS_TETGEN_VOLUME_MESHER_H_INCLUDED
26 #include "utilities/geometry_utilities.h"
77 :mrModelPart(rmodel_part)
97 hole_coordinates[0] =
x;
98 hole_coordinates[1] =
y;
99 hole_coordinates[2] =
z;
100 mholes.push_back(hole_coordinates);
118 if(mrModelPart.
Elements().size() != 0)
122 ModelPart::NodesContainerType::iterator nodes_begin = mrModelPart.
NodesBegin();
123 for (
unsigned int i = 0;
i < mrModelPart.
Nodes().size();
i++)
125 (nodes_begin +
i)->SetId(
i + 1);
132 in.numberofpoints = mrModelPart.
Nodes().size();
133 in.pointlist =
new REAL[in.numberofpoints * 3];
137 for (
unsigned int i = 0;
i < mrModelPart.
Nodes().size();
i++)
140 in.pointlist[base] = (nodes_begin +
i)->
X();
141 in.pointlist[base + 1] = (nodes_begin +
i)->
Y();
142 in.pointlist[base + 2] = (nodes_begin +
i)->
Z();
146 in.numberoffacets = mrModelPart.
Conditions().size();
147 in.facetlist =
new tetgenio::facet[in.numberoffacets];
148 in.facetmarkerlist =
new int[in.numberoffacets];
151 ModelPart::ConditionsContainerType::iterator condition_begin = mrModelPart.
ConditionsBegin();
152 for (
unsigned int i = 0;
i < mrModelPart.
Conditions().size();
i++)
154 tetgenio::facet*
f = &in.facetlist[
i];
155 f->numberofpolygons = 1;
156 f->polygonlist =
new tetgenio::polygon[
f->numberofpolygons];
157 f->numberofholes = 0;
158 f->holelist =
nullptr;
159 tetgenio::polygon*
p = &
f->polygonlist[0];
160 p->numberofvertices = 3;
161 p->vertexlist =
new int[
p->numberofvertices];
162 p->vertexlist[0] = (condition_begin +
i)->GetGeometry()[0].Id();
163 p->vertexlist[1] = (condition_begin +
i)->GetGeometry()[1].Id();
164 p->vertexlist[2] = (condition_begin +
i)->GetGeometry()[2].Id();
166 in.facetmarkerlist[
i] =
static_cast<int>( (condition_begin +
i)->
GetValue(FLAG_VARIABLE) );
170 in.numberofholes = mholes.size();
171 in.holelist =
new double[in.numberofholes*3];
172 for (
unsigned int i = 0;
i < mholes.size();
i++)
175 in.holelist[base] = mholes[
i][0];
176 in.holelist[base + 1] = mholes[
i][1];
177 in.holelist[base + 2] = mholes[
i][2];
185 auto tmp=
new char[settings.size()+1];
186 tmp[settings.size()]=0;
187 memcpy(
tmp,settings.c_str(),settings.size());
189 tetrahedralize(
tmp, &in, &
out);
198 for(
int i=in.numberofpoints;
i<
out.numberofpoints;
i++)
201 double x =
out.pointlist[base];
202 double y =
out.pointlist[base+1];
203 double z =
out.pointlist[base+2];
205 Node::Pointer p_new_node = Node::Pointer(
new Node(
i+1,
x,
y,
z));
209 p_new_node->SetBufferSize(mrModelPart.
NodesBegin()->GetBufferSize());
210 for (Node ::DofsContainerType::iterator iii = reference_dofs.begin(); iii != reference_dofs.end(); iii++)
213 Node ::DofType::Pointer p_new_dof = p_new_node->pAddDof(rDof);
214 (p_new_dof)->FreeDof();
217 mrModelPart.
Nodes().push_back(p_new_node);
225 for(
int i=0;
i!=
out.numberoftetrahedra;
i++)
230 *( (nodes_begin +
out.tetrahedronlist[base]-1).base() ),
231 *( (nodes_begin +
out.tetrahedronlist[base+1]-1).base() ),
232 *( (nodes_begin +
out.tetrahedronlist[base+2]-1).base() ),
233 *( (nodes_begin +
out.tetrahedronlist[base+3]-1).base() )
236 Element::Pointer p_element = rReferenceElement.
Create(
i+1, geom, properties);
237 (mrModelPart.
Elements()).push_back(p_element);
274 virtual std::string
Info()
const
276 std::stringstream buffer;
277 buffer <<
"TetgenVolumeMesher";
285 rOStream <<
"TetgenVolumeMesher";
347 std::vector< array_1d<double, 3 > > mholes;
385 mrModelPart(rOther.mrModelPart)
419 rOStream << std::endl;
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
static const TComponentType & Get(const std::string &rName)
Retrieves a component with the specified name.
Definition: kratos_components.h:114
PropertiesType::Pointer pGetProperties(IndexType PropertiesId)
Definition: mesh.h:394
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ConditionIterator ConditionsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1361
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 & GetMesh(IndexType ThisIndex=0)
Definition: model_part.h:1791
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
VariablesList & GetNodalSolutionStepVariablesList()
Definition: model_part.h:549
This class defines the node.
Definition: node.h:65
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
This class performs the (constrained) Delaunay meshing of the internal volume given a surface discret...
Definition: tetgen_volume_mesher.h:62
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: tetgen_volume_mesher.h:290
void AddHole(double x, double y, double z)
Definition: tetgen_volume_mesher.h:94
KRATOS_CLASS_POINTER_DEFINITION(TetgenVolumeMesher)
Pointer definition of TetgenVolumeMesher.
void GenerateMesh(std::string settings, std::string ElementName)
Definition: tetgen_volume_mesher.h:112
virtual std::string Info() const
Turn back information as a string.
Definition: tetgen_volume_mesher.h:274
TetgenVolumeMesher(ModelPart &rmodel_part)
Default constructor.
Definition: tetgen_volume_mesher.h:76
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: tetgen_volume_mesher.h:283
virtual ~TetgenVolumeMesher()=default
Destructor.
A four node tetrahedra geometry with linear shape functions.
Definition: tetrahedra_3d_4.h:59
#define KRATOS_THROW_ERROR(ExceptionType, ErrorMessage, MoreInfo)
Definition: define.h:77
#define REAL
Definition: delaunator_utilities.cpp:16
z
Definition: GenerateWind.py:163
Parameters GetValue(Parameters &rParameters, const std::string &rEntry)
Definition: add_kratos_parameters_to_python.cpp:53
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
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
y
Other simbols definition.
Definition: generate_axisymmetric_navier_stokes_element.py:54
f
Definition: generate_convection_diffusion_explicit_element.py:112
tuple tmp
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:98
out
Definition: isotropic_damage_automatic_differentiation.py:200
p
Definition: sensitivityMatrix.py:52
x
Definition: sensitivityMatrix.py:49
integer i
Definition: TensorModule.f:17