27 #ifndef OOMPH_TETGEN_MESH_HEADER
28 #define OOMPH_TETGEN_MESH_HEADER
32 #include <oomph-lib-config.h>
41 #include "../generic/tetgen_scaffold_mesh.h"
42 #include "../generic/tet_mesh.h"
50 template<
class ELEMENT>
58 MeshChecker::assert_geometric_element<TElementGeometricBase, ELEMENT>(3);
66 const bool& use_attributes =
false)
70 MeshChecker::assert_geometric_element<TElementGeometricBase, ELEMENT>(3);
80 node_file_name, element_file_name, face_file_name);
91 for (
unsigned b = 0;
b <
nb;
b++)
93 bool switch_normal =
false;
94 setup_boundary_coordinates<ELEMENT>(
b, switch_normal);
102 const bool& use_attributes =
false)
106 MeshChecker::assert_geometric_element<TElementGeometricBase, ELEMENT>(3);
130 for (
unsigned b = 0;
b <
nb;
b++)
132 bool switch_normal =
false;
133 setup_boundary_coordinates<ELEMENT>(
b, switch_normal);
150 const bool& split_corner_elements,
152 const bool& use_attributes =
false)
156 MeshChecker::assert_geometric_element<TElementGeometricBase, ELEMENT>(3);
170 node_file_name, element_file_name, face_file_name);
180 if (split_corner_elements)
182 split_elements_in_corners<ELEMENT>();
187 for (
unsigned b = 0;
b <
nb;
b++)
189 bool switch_normal =
false;
190 setup_boundary_coordinates<ELEMENT>(
b, switch_normal);
204 const bool& split_corner_elements,
206 const bool& use_attributes =
false)
210 MeshChecker::assert_geometric_element<TElementGeometricBase, ELEMENT>(3);
233 if (split_corner_elements)
235 split_elements_in_corners<ELEMENT>();
240 for (
unsigned b = 0;
b <
nb;
b++)
242 bool switch_normal =
false;
243 setup_boundary_coordinates<ELEMENT>(
b, switch_normal);
256 const double& element_volume,
258 const bool& use_attributes =
false,
259 const bool& split_corner_elements =
false,
260 Vector<double>*
const& target_element_volume_in_region_pt =
nullptr)
263 MeshChecker::assert_geometric_element<TElementGeometricBase, ELEMENT>(3);
280 for (
unsigned i = 0;
i <
n;
i++)
291 target_element_volume_in_region_pt,
306 std::stringstream input_string;
307 input_string <<
"pq2.0aAa" << element_volume;
314 bool can_boundaries_be_split =
317 unsigned n_internal = internal_surface_pt.size();
318 for (
unsigned i = 0;
i < n_internal;
i++)
320 can_boundaries_be_split &=
321 internal_surface_pt[
i]->boundaries_can_be_split_in_tetgen();
326 if (can_boundaries_be_split ==
false)
332 char tetswitches[100];
333 sprintf(tetswitches,
"%s", input_string.str().c_str());
345 bool regions_exist =
false;
347 unsigned n_internal = internal_surface_pt.size();
348 for (
unsigned i = 0;
i < n_internal;
i++)
355 for (
unsigned j = 0;
j < n_int_pts;
j++)
378 if (split_corner_elements)
380 split_elements_in_corners<ELEMENT>();
385 for (
unsigned b = 0;
b <
nb;
b++)
387 bool switch_normal =
false;
388 setup_boundary_coordinates<ELEMENT>(
b, switch_normal);
414 const unsigned n_internal = internal_surface_pt.size();
417 const unsigned n_outer_vertex = outer_boundary_pt->
nvertex();
423 for (
unsigned h = 0; h < n_internal; ++h)
425 n_internal_vertex[h] = internal_surface_pt[h]->nvertex();
433 unsigned counter = 0;
434 for (
unsigned n = 0;
n < n_outer_vertex; ++
n)
436 for (
unsigned i = 0;
i < 3; ++
i)
443 for (
unsigned h = 0; h < n_internal; ++h)
445 const unsigned n_inner = n_internal_vertex[h];
446 for (
unsigned n = 0;
n < n_inner; ++
n)
448 for (
unsigned i = 0;
i < 3; ++
i)
451 internal_surface_pt[h]->vertex_coordinate(
n,
i);
460 for (
unsigned n = 0;
n < n_outer_vertex; ++
n)
466 for (
unsigned h = 0; h < n_internal; ++h)
468 const unsigned n_inner = n_internal_vertex[h];
469 for (
unsigned n = 0;
n < n_inner; ++
n)
472 internal_surface_pt[h]->one_based_vertex_boundary_id(
n);
479 unsigned n_outer_facet = outer_boundary_pt->
nfacet();
482 for (
unsigned h = 0; h < n_internal; ++h)
484 n_inner_facet[h] = internal_surface_pt[h]->nfacet();
493 for (
unsigned n = 0;
n < n_outer_facet; ++
n)
497 f->numberofpolygons = 1;
499 f->numberofholes = 0;
501 p = &
f->polygonlist[0];
505 p->numberofvertices = facet.size();
506 p->vertexlist =
new int[
p->numberofvertices];
507 for (
int i = 0;
i <
p->numberofvertices; ++
i)
510 p->vertexlist[
i] = facet[
i] + 1;
526 for (
unsigned h = 0; h < n_internal; ++h)
528 for (
unsigned n = 0;
n < n_inner_facet[h]; ++
n)
532 f->numberofpolygons = 1;
534 f->numberofholes = 0;
536 p = &
f->polygonlist[0];
539 internal_surface_pt[h]->vertex_index_in_tetgen(
n);
541 p->numberofvertices = facet.size();
542 p->vertexlist =
new int[
p->numberofvertices];
543 for (
int i = 0;
i <
p->numberofvertices; ++
i)
546 p->vertexlist[
i] = facet[
i] + internal_vertex_offset[h] + 1;
550 internal_surface_pt[h]->one_based_facet_boundary_id(
n);
560 for (
unsigned j = 0;
j < n_int_pts;
j++)
583 for (
unsigned h = 0; h < n_internal; ++h)
590 for (
unsigned j = 0;
j < n_int_pts;
j++)
594 for (
unsigned i = 0;
i < 3; ++
i)
610 for (
unsigned h = 0; h < n_internal; ++h)
617 for (
unsigned j = 0;
j < n_int_pts;
j++)
621 for (
unsigned i = 0;
i < 3; ++
i)
632 if (target_element_volume_in_region_pt ==
nullptr)
641 (*target_element_volume_in_region_pt)[
unsigned(counter / 5)];
665 const bool& preserve_existing_data)
706 const bool& use_attributes);
738 template<
class ELEMENT>
748 const bool& split_corner_elements,
750 const bool& use_attributes =
false)
754 split_corner_elements,
768 const bool& split_corner_elements,
769 const bool& switch_normal,
771 const bool& use_attributes =
false)
775 split_corner_elements,
785 for (
unsigned b = 0;
b <
nb;
b++)
787 this->
template setup_boundary_coordinates<ELEMENT>(
b, switch_normal);
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
float * p
Definition: Tutorial_Map_using.cpp:9
Scalar * b
Definition: benchVecAdd.cpp:17
static Steady< 0 > Default_TimeStepper
The Steady Timestepper.
Definition: mesh.h:75
unsigned nboundary() const
Return number of boundaries.
Definition: mesh.h:827
void set_lagrangian_nodal_coordinates()
Definition: mesh.cc:9564
Definition: tetgen_mesh.template.h:741
SolidTetgenMesh(const std::string &node_file_name, const std::string &element_file_name, const std::string &face_file_name, const bool &split_corner_elements, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper, const bool &use_attributes=false)
Definition: tetgen_mesh.template.h:745
SolidTetgenMesh(const std::string &node_file_name, const std::string &element_file_name, const std::string &face_file_name, const bool &split_corner_elements, const bool &switch_normal, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper, const bool &use_attributes=false)
Definition: tetgen_mesh.template.h:765
virtual ~SolidTetgenMesh()
Empty Destructor.
Definition: tetgen_mesh.template.h:792
Base class for tet meshes (meshes made of 3D tet elements).
Definition: tet_mesh.h:661
void snap_nodes_onto_geometric_objects()
Definition: tet_mesh.cc:483
TimeStepper * Time_stepper_pt
Timestepper used to build nodes.
Definition: tet_mesh.h:1057
Vector< TetMeshFacetedSurface * > Internal_surface_pt
Vector to faceted surfaces that define internal boundaries.
Definition: tet_mesh.h:1041
TetMeshFacetedClosedSurface * Outer_boundary_pt
Faceted surface that defines outer boundaries.
Definition: tet_mesh.h:1038
Definition: tet_mesh.h:538
const int & region_id_for_tetgen(const unsigned &j) const
Definition: tet_mesh.h:598
unsigned ninternal_point_for_tetgen()
Definition: tet_mesh.h:591
bool internal_point_identifies_region_for_tetgen(const unsigned &j)
Is j-th internal point for tetgen associated with a region?
Definition: tet_mesh.h:611
bool internal_point_identifies_hole_for_tetgen(const unsigned &j)
Is j-th internal point for tetgen associated with a hole?
Definition: tet_mesh.h:605
const double & internal_point_for_tetgen(const unsigned &j, const unsigned &i) const
i=th coordinate of the j-th internal point for tetgen
Definition: tet_mesh.h:568
Definition: tet_mesh.h:306
unsigned nfacet() const
Number of facets.
Definition: tet_mesh.h:325
bool boundaries_can_be_split_in_tetgen()
Test whether boundary can be split in tetgen.
Definition: tet_mesh.h:355
unsigned one_based_facet_boundary_id(const unsigned &j) const
One-based boundary id of j-th facet.
Definition: tet_mesh.h:331
Vector< unsigned > vertex_index_in_tetgen(const unsigned &f)
Definition: tet_mesh.h:472
double vertex_coordinate(const unsigned &j, const unsigned &i) const
i-th coordinate of j-th vertex
Definition: tet_mesh.h:343
unsigned nvertex() const
Number of vertices.
Definition: tet_mesh.h:319
unsigned one_based_vertex_boundary_id(const unsigned &j) const
First (of possibly multiple) one-based boundary id of j-th vertex.
Definition: tet_mesh.h:337
Definition: tetgen_mesh.template.h:52
tetgenio *& tetgenio_pt()
Access to the triangulateio representation of the mesh.
Definition: tetgen_mesh.template.h:679
TetgenMesh(tetgenio &tetgen_data, const bool &split_corner_elements, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper, const bool &use_attributes=false)
Definition: tetgen_mesh.template.h:203
TetgenMesh(const std::string &node_file_name, const std::string &element_file_name, const std::string &face_file_name, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper, const bool &use_attributes=false)
Constructor with the input files.
Definition: tetgen_mesh.template.h:62
TetgenMesh()
Empty constructor.
Definition: tetgen_mesh.template.h:55
tetgenio * Tetgenio_pt
Tetgen representation of mesh.
Definition: tetgen_mesh.template.h:720
TetgenMesh(TetMeshFacetedClosedSurface *const &outer_boundary_pt, Vector< TetMeshFacetedSurface * > &internal_surface_pt, const double &element_volume, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper, const bool &use_attributes=false, const bool &split_corner_elements=false, Vector< double > *const &target_element_volume_in_region_pt=nullptr)
Definition: tetgen_mesh.template.h:253
TetgenMesh(const std::string &node_file_name, const std::string &element_file_name, const std::string &face_file_name, const bool &split_corner_elements, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper, const bool &use_attributes=false)
Definition: tetgen_mesh.template.h:147
void set_deep_copy_tetgenio_pt(tetgenio *const &tetgenio_pt)
Set the tetgen pointer by a deep copy.
Definition: tetgen_mesh.template.h:685
bool Use_attributes
Definition: tetgen_mesh.template.h:724
void setup_reverse_lookup_schemes_for_faceted_surface(TetMeshFacetedSurface *const &faceted_surface_pt)
Function to setup the reverse look-up schemes.
Definition: tetgen_mesh.template.cc:828
~TetgenMesh()
Empty destructor.
Definition: tetgen_mesh.template.h:653
void set_mesh_level_time_stepper(TimeStepper *const &time_stepper_pt, const bool &preserve_existing_data)
Definition: tetgen_mesh.template.h:664
void build_tetgenio(TetMeshFacetedSurface *const &outer_boundary_pt, Vector< TetMeshFacetedSurface * > &internal_surface_pt, Vector< double > *const &target_element_volume_in_region_pt, tetgenio &tetgen_io)
Build tetgenio object from the TetMeshFacetedSurfaces.
Definition: tetgen_mesh.template.h:397
void deep_copy_of_tetgenio(tetgenio *const &input_pt, tetgenio *&output_pt)
Definition: tetgen_mesh.template.cc:865
bool Tetgenio_exists
Definition: tetgen_mesh.template.h:717
TetgenScaffoldMesh * Tmp_mesh_pt
Temporary scaffold mesh.
Definition: tetgen_mesh.template.h:713
TetgenMesh(tetgenio &tetgen_data, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper, const bool &use_attributes=false)
Constructor with tetgenio data structure.
Definition: tetgen_mesh.template.h:100
bool tetgenio_exists() const
Boolen defining whether tetgenio object has been built or not.
Definition: tetgen_mesh.template.h:672
void build_from_scaffold(TimeStepper *time_stepper_pt, const bool &use_attributes)
Build mesh from scaffold.
Definition: tetgen_mesh.template.cc:48
Definition: tetgen_scaffold_mesh.h:43
Definition: timesteppers.h:231
int numberofregions
Definition: tetgen.h:349
bool useindex
Definition: tetgen.h:291
int * facetmarkerlist
Definition: tetgen.h:332
REAL * holelist
Definition: tetgen.h:338
int numberofpoints
Definition: tetgen.h:306
REAL * pointlist
Definition: tetgen.h:302
REAL * regionlist
Definition: tetgen.h:348
int firstnumber
Definition: tetgen.h:285
int numberofholes
Definition: tetgen.h:339
facet * facetlist
Definition: tetgen.h:331
int numberoffacets
Definition: tetgen.h:333
int * pointmarkerlist
Definition: tetgen.h:305
static int f(const TensorMap< Tensor< int, 3 > > &tensor)
Definition: cxx11_tensor_map.cpp:237
int nb
Definition: level2_impl.h:286
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
void tetrahedralize(tetgenbehavior *b, tetgenio *in, tetgenio *out, tetgenio *addin=NULL, tetgenio *bgmin=NULL)
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2