10 #if !defined(KRATOS_TRIGEN_MODELER_H_INCLUDED )
11 #define KRATOS_TRIGEN_MODELER_H_INCLUDED
35 void triangulate(
char *,
struct triangulateio *,
struct triangulateio *,
struct triangulateio *);
101 Element const& rReferenceElement,
102 Condition const& rReferenceBoundaryCondition,
103 double my_alpha = 1.4)
108 struct triangulateio in;
109 struct triangulateio
out;
110 struct triangulateio vorout;
113 in.numberofpoints = ThisModelPart.
Nodes().size();
114 in.pointlist = (
REAL *) malloc(in.numberofpoints * 2 *
sizeof(
REAL));
117 in.numberofpointattributes = 0;
118 in.pointattributelist = (
REAL *) NULL;
121 in.numberoftriangles = ThisModelPart.
Elements().size();
122 in.trianglelist = (
int *) malloc(in.numberoftriangles * 3 *
sizeof(
int) ];
125 in.trianglearealist =
new REAL[in.numberoftetrahedra];
127 in.pointmarkerlist = (
int *) NULL;
128 in.regionlist = (
REAL *) NULL;
130 out.pointattributelist = (
REAL *) NULL;
131 out.trianglelist = (
int *) NULL;
132 out.triangleattributelist = (
REAL *) NULL;
133 out.neighborlist = (
int *) NULL;
137 ModelPart::NodesContainerType::iterator nodes_begin = ThisModelPart.
NodesBegin();
138 for(
unsigned int i = 0;
i<ThisModelPart.
Nodes().size();
i++)
144 (nodes_begin +
i)->Id() =
i+1;
146 in.pointlist[base] = (nodes_begin +
i)->
X();
147 in.pointlist[base+1] = (nodes_begin +
i)->
Y();
159 in.trianglelist[base] = geom[0]->
Id();
160 in.trianglelist[base+1] = geom[1]->
Id();
161 in.trianglelist[base+2] = geom[2]->
Id();
163 double h = geom[0].FastGetSolutionStepValue(NODAL_H);
164 h += geom[1].FastGetSolutionStepValue(NODAL_H);
165 h += geom[2].FastGetSolutionStepValue(NODAL_H);
166 h *= 0.33333333333333;
169 double desired_area = 0.43301 *
h*
h;
172 in.trianglearealist[
i] = desired_area;
186 unsigned int original_size = ThisModelPart.
Nodes().size();
187 if(
out.numberofpoints > original_size; )
189 for(
unsigned int i = original_size;
i <
out.numberofpoints;
i++)
191 int id = original_size+1
193 double&
x =
out.pointlist[base];
194 double&
y =
out.pointlist[base+1];
195 double&
z =
out.pointlist[base+2];
198 ThisModelPart.
AddNode(
id,
x,
y,
z, attributelist);
206 int el_number =
out.numberoftriangles;
212 for(
int el = 0;
el< el_number;
el++)
219 temp.push_back( *((ModelNodes).find(
out.trianglelist[base]).base() ) );
220 temp.push_back( *((ModelNodes).find(
out.trianglelist[base+1]).base() ) );
221 temp.push_back( *((ModelNodes).find(
out.trianglelist[base+2]).base() ) );
224 Element::Pointer p_element = rReferenceElement.
Create(
id,
temp, properties);
225 ThisModelPart.
Elements().push_back(p_element);
231 for(ModelPart::ElementsContainerType::iterator iii = ThisModelPart.
ElementsBegin(); iii != ThisModelPart.
ElementsEnd(); iii++)
233 int base = ( iii->Id() - 1 )*3;
235 ModelPart::ElementsContainerType::iterator el_neighb;
246 el_neighb = (ThisModelPart.
Elements()).find(
out.neighborlist[base] );
247 if( el_neighb == elements_end )
252 temp.push_back(iii->GetGeometry()(1));
253 temp.push_back(iii->GetGeometry()(2));
257 int id = (iii->Id()-1)*3;
259 Condition::Pointer p_cond =
260 Condition::Pointer(
new Condition(
id, cond, properties) );
268 el_neighb = (ThisModelPart.
Elements()).find(
out.neighborlist[base+1] );
270 if( el_neighb == elements_end )
275 temp.push_back(iii->GetGeometry()(2));
276 temp.push_back(iii->GetGeometry()(0));
280 int id = (iii->Id()-1)*3+1;
282 Condition::Pointer p_cond =
283 Condition::Pointer(
new Condition(
id, cond, properties) );
292 el_neighb = (ThisModelPart.
Elements()).find(
out.neighborlist[base+2] );
293 if( el_neighb == elements_end )
298 temp.push_back(iii->GetGeometry()(0));
299 temp.push_back(iii->GetGeometry()(1));
302 int id = (iii->Id()-1)*3+2;
304 Condition::Pointer p_cond =
305 Condition::Pointer(
new Condition(
id, cond, properties) );
317 free( in.pointlist );
318 free( in.numberoftriangles );
319 free( in.trianglelist );
320 free( in.trianglearealist );
326 free(
out.pointattributelist );
327 free(
out.trianglelist );
329 free(
out.neighborlist );
352 virtual std::string
Info()
const
416 boost::numeric::ublas::bounded_matrix<double,2,2> mJ;
417 boost::numeric::ublas::bounded_matrix<double,2,2> mJinv;
433 double x0 = pgeom[0].X();
434 double x1 = pgeom[1].X();
435 double x2 = pgeom[2].X();
437 double y0 = pgeom[0].Y();
438 double y1 = pgeom[1].Y();
439 double y2 = pgeom[2].Y();
447 double detJ = mJ(0,0)*mJ(1,1)-mJ(0,1)*mJ(1,0);
449 mJinv(0,0) = mJ(1,1);
450 mJinv(0,1) = -mJ(0,1);
451 mJinv(1,0) = -mJ(1,0);
452 mJinv(1,1) = mJ(0,0);
454 bounded_matrix<double,2,2> check;
461 pgeom[0].GetSolutionStepValue(IS_BOUNDARY) = 1;
462 pgeom[1].GetSolutionStepValue(IS_BOUNDARY) = 1;
463 pgeom[2].GetSolutionStepValue(IS_BOUNDARY) = 1;
470 double x0_2 = x0*x0 + y0*y0;
471 double x1_2 =
x1*
x1 + y1*y1;
472 double x2_2 =
x2*
x2 + y2*y2;
478 mRhs[0] = (x1_2 - x0_2);
479 mRhs[1] = (x2_2 - x0_2);
484 double radius = sqrt(pow(mC[0]-x0,2)+pow(mC[1]-y0,2));
488 h = pgeom[0].FastGetSolutionStepValue(NODAL_H);
489 h += pgeom[1].FastGetSolutionStepValue(NODAL_H);
490 h += pgeom[2].FastGetSolutionStepValue(NODAL_H);
553 rOStream << std::endl;
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
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
IndexType const & Id() const
Id of this Geometry.
Definition: geometry.h:964
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
void AddNode(NodeType::Pointer pNewNode, IndexType ThisIndex=0)
Definition: model_part.cpp:211
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
MeshType & GetMesh(IndexType ThisIndex=0)
Definition: model_part.h:1791
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
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: trigen_mesh_suite_refine.h:64
void RefineMesh(ModelPart &ThisModelPart, Element const &rReferenceElement, Condition const &rReferenceBoundaryCondition, double my_alpha=1.4)
Definition: trigen_mesh_suite_refine.h:99
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: trigen_mesh_suite_refine.h:361
virtual std::string Info() const
Turn back information as a string.
Definition: trigen_mesh_suite_refine.h:352
KRATOS_CLASS_POINTER_DEFINITION(TriGenModeler)
Pointer definition of TriGenModeler.
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: trigen_mesh_suite_refine.h:358
virtual ~TriGenModeler()
Destructor.
Definition: trigen_mesh_suite_refine.h:84
TriGenModeler()
Default constructor.
Definition: trigen_mesh_suite_refine.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
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
void triangulate(char *, struct triangulateio *, struct triangulateio *, struct triangulateio *)
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
h
Definition: generate_droplet_dynamics.py:91
x2
Definition: generate_frictional_mortar_condition.py:122
x1
Definition: generate_frictional_mortar_condition.py:121
out
Definition: isotropic_damage_automatic_differentiation.py:200
float radius
Definition: mesh_to_mdpa_converter.py:18
el
Definition: read_stl.py:25
float temp
Definition: rotating_cone.py:85
x
Definition: sensitivityMatrix.py:49
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31