11 #if !defined(KRATOS_TETGEN_PFEM_CONTACT_H_INCLUDED )
12 #define KRATOS_TETGEN_PFEM_CONTACT_H_INCLUDED
20 #include <boost/timer.hpp>
28 #include "utilities/geometry_utilities.h"
98 Element const& rReferenceElement,
99 Condition const& rReferenceBoundaryCondition
105 std::vector <int> shell_list;
110 for(ModelPart::ElementsContainerType::iterator elem = ThisModelPart.
ElementsBegin();
117 shell_nodes.push_back(geom(1));
118 shell_nodes.push_back(geom(2));
122 shell_nodes.Unique();
124 ModelPart::NodesContainerType::iterator nodes_begin = shell_nodes.begin();
125 for(
unsigned int ii=0; ii < shell_nodes.size(); ii++)
126 ( nodes_begin + ii ) ->SetId( ii + 1 );
128 for(ModelPart::ElementsContainerType::iterator elem = ThisModelPart.
ElementsBegin();
134 shell_list.push_back(geom[1].Id());
135 shell_list.push_back(geom[2].Id());
139 tetgenio in_shell, out_shell;
141 in_shell.firstnumber = 1;
142 in_shell.numberofpoints = shell_nodes.size();
143 in_shell.pointlist =
new REAL[in_shell.numberofpoints * 3];
147 tetgenio::polygon *
p;
149 for(
unsigned int i = 0;
i<shell_nodes.size();
i++)
152 in_shell.pointlist[base] = (nodes_begin +
i)->
X();
153 in_shell.pointlist[base+1] = (nodes_begin +
i)->
Y();
154 in_shell.pointlist[base+2] = (nodes_begin +
i)->
Z();
161 in_shell.numberoffacets = shell_num;
162 in_shell.facetmarkerlist =
new int[in_shell.numberoffacets];
163 in_shell.facetlist =
new tetgenio::facet[in_shell.numberoffacets];
164 for(
int ii=0; ii<shell_num; ++ii)
166 f = &in_shell.facetlist[ii];
167 f->numberofpolygons = 1;
168 f->polygonlist =
new tetgenio::polygon[
f->numberofpolygons];
169 f->numberofholes = 0;
170 f->holelist =
nullptr;
173 p = &
f->polygonlist[0];
174 p->numberofvertices = 3;
175 p->vertexlist =
new int[
p->numberofvertices];
176 p->vertexlist[0] = shell_list[cnt];
177 p->vertexlist[1] = shell_list[cnt + 1];
178 p->vertexlist[2] = shell_list[cnt + 2];
181 in_shell.facetmarkerlist[ii] = 5;
185 in_shell.numberofholes = 0;
186 in_shell.holelist =
nullptr;
193 char tetgen_options[] =
"pYYJnQ";
197 tetrahedralize(tetgen_options, &in_shell, &out_shell);
205 in_shell.deinitialize();
206 in_shell.initialize();
214 boost::timer adding_elems;
216 (ThisModelPart.
Elements()).reserve(out_shell.numberoftetrahedra);
218 for(
int iii = 0; iii< out_shell.numberoftetrahedra; iii++)
224 *( (nodes_begin + out_shell.tetrahedronlist[base]-1).base() ),
225 *( (nodes_begin + out_shell.tetrahedronlist[base+1]-1).base() ),
226 *( (nodes_begin + out_shell.tetrahedronlist[base+2]-1).base() ),
227 *( (nodes_begin + out_shell.tetrahedronlist[base+3]-1).base() )
231 Element::Pointer p_element = rReferenceElement.
Create(
id, geom, properties);
232 p_element->GetValue(IS_FLUID) = 10;
233 p_element->GetValue(IS_WATER_ELEMENT) = -10.0;
236 (ThisModelPart.
Elements()).push_back(p_element);
244 boost::timer adding_neighb;
246 ModelPart::ElementsContainerType::const_iterator el_begin = ThisModelPart.
ElementsBegin();
247 for(ModelPart::ElementsContainerType::const_iterator iii = ThisModelPart.
ElementsBegin();
251 int base = ( iii->Id() - 1 )*4;
253 (iii->GetValue(NEIGHBOUR_ELEMENTS)).resize(4);
256 for(
int i = 0;
i<4;
i++)
258 int index = out_shell.neighborlist[base+
i];
262 neighb(
i) = Element::WeakPointer();
265 std::cout <<
"time for adding neigbours" << adding_neighb.elapsed() << std::endl;;
326 out_shell.deinitialize();
327 out_shell.initialize();
332 KRATOS_WATCH(
">>>>>>>>>>>>>>>>>>>>< BYE BYE MESHER <<<<<<<<<<<<<<<<<<<<<<<<");
351 virtual std::string
Info()
const
512 rOStream << std::endl;
Base class for all Conditions.
Definition: condition.h:59
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
Geometry base class.
Definition: geometry.h:71
void push_back(PointPointerType x)
Definition: geometry.h:548
This class is a wrapper for a pointer to a data that is located in a different rank.
Definition: global_pointer.h:44
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
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
MeshType & GetMesh(IndexType ThisIndex=0)
Definition: model_part.h:1791
A four node tetrahedra geometry with linear shape functions.
Definition: tetrahedra_3d_4.h:59
#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
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
f
Definition: generate_convection_diffusion_explicit_element.py:112
p
Definition: sensitivityMatrix.py:52
integer i
Definition: TensorModule.f:17