27 #ifndef OOMPH_REFINEABLE_TETGEN_MESH_HEADER
28 #define OOMPH_REFINEABLE_TETGEN_MESH_HEADER
32 #include <oomph-lib-config.h>
36 #include "../generic/tetgen_scaffold_mesh.h"
37 #include "../generic/tet_mesh.h"
38 #include "../generic/refineable_mesh.h"
46 template<
class ELEMENT>
48 public virtual RefineableTetMeshBase
56 TetMeshFacetedClosedSurface*
const& outer_boundary_pt,
57 Vector<TetMeshFacetedSurface*>& internal_closed_surface_pt,
58 const double& element_volume,
59 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper,
60 const bool& use_attributes =
false,
61 const bool& split_corner_elements =
false,
62 Vector<double>*
const& target_element_volume_in_region_pt =
nullptr)
64 internal_closed_surface_pt,
68 split_corner_elements,
69 target_element_volume_in_region_pt),
83 const Vector<double>& target_volume,
84 tetgenio*
const& tetgen_io_pt,
85 TetMeshFacetedClosedSurface*
const& outer_boundary_pt,
86 Vector<TetMeshFacetedSurface*>& internal_surface_pt,
87 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper,
88 const bool& use_attributes =
false)
96 MeshChecker::assert_geometric_element<TElementGeometricBase, ELEMENT>(3);
102 this->Time_stepper_pt = time_stepper_pt;
116 tetgenio* tetgen_input_pt =
new tetgenio;
121 tetgen_input_pt->tetrahedronvolumelist =
122 new double[tetgen_input_pt->numberoftetrahedra];
123 for (
int e = 0; e < tetgen_input_pt->numberoftetrahedra; ++e)
125 tetgen_input_pt->tetrahedronvolumelist[e] = target_volume[e];
129 std::stringstream input_string_stream;
130 input_string_stream <<
"Vqra";
133 char tetswitches[100];
134 sprintf(tetswitches,
"%s", input_string_stream.str().c_str());
137 tetrahedralize(tetswitches, tetgen_input_pt, this->
Tetgenio_pt);
149 delete tetgen_input_pt;
152 this->Outer_boundary_pt = outer_boundary_pt;
155 this->Outer_boundary_pt);
157 this->Internal_surface_pt = internal_surface_pt;
160 unsigned n = this->Internal_surface_pt.size();
161 for (
unsigned i = 0; i < n; i++)
164 this->Internal_surface_pt[i]);
169 unsigned nb = nboundary();
170 for (
unsigned b = 0; b < nb; b++)
172 this->
template setup_boundary_coordinates<ELEMENT>(b);
177 this->snap_nodes_onto_geometric_objects();
189 throw OomphLibError(
"refine_uniformly() not implemented yet",
190 OOMPH_CURRENT_FUNCTION,
191 OOMPH_EXCEPTION_LOCATION);
200 throw OomphLibError(
"unrefine_uniformly() not implemented yet",
201 OOMPH_CURRENT_FUNCTION,
202 OOMPH_EXCEPTION_LOCATION);
208 void adapt(
const Vector<double>& elem_error);
235 this->Max_element_size = 1.0;
236 this->Min_element_size = 0.001;
237 this->Max_permitted_edge_ratio = 2.0;
245 TetMeshFacetedSurface*& faceted_surface_pt);
271 template<
class ELEMENT>
274 public virtual SolidMesh
281 TetMeshFacetedClosedSurface*
const& outer_boundary_pt,
282 Vector<TetMeshFacetedSurface*>& internal_closed_surface_pt,
283 const double& element_volume,
284 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper,
285 const bool& use_attributes =
false,
286 const bool& split_corner_elements =
false)
288 internal_closed_surface_pt,
292 split_corner_elements),
294 internal_closed_surface_pt,
298 split_corner_elements)
302 set_lagrangian_nodal_coordinates();
309 const Vector<double>& target_volume,
310 tetgenio*
const& tetgen_io_pt,
311 TetMeshFacetedClosedSurface*
const& outer_boundary_pt,
312 Vector<TetMeshFacetedSurface*>& internal_surface_pt,
313 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper,
314 const bool& use_attributes =
false)
324 set_lagrangian_nodal_coordinates();
////////////////////////////////////////////////////////////////////////// //////////////////////////...
RefineableSolidTetgenMesh(const Vector< double > &target_volume, tetgenio *const &tetgen_io_pt, TetMeshFacetedClosedSurface *const &outer_boundary_pt, Vector< TetMeshFacetedSurface * > &internal_surface_pt, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper, const bool &use_attributes=false)
Build mesh from specified triangulation and associated target areas for elements in it.
RefineableSolidTetgenMesh(TetMeshFacetedClosedSurface *const &outer_boundary_pt, Vector< TetMeshFacetedSurface * > &internal_closed_surface_pt, const double &element_volume, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper, const bool &use_attributes=false, const bool &split_corner_elements=false)
Build mesh, based on closed curve that specifies the outer boundary of the domain and any number of i...
virtual ~RefineableSolidTetgenMesh()
Empty Destructor.
void surface_remesh_for_inner_hole_boundaries()
Generate a new faceted representation of the inner hole boundaries.
bool Projection_is_disabled
Disable projection of solution onto new mesh during adaptation.
bool projection_is_disabled()
Is projection of old solution onto new mesh disabled?
void update_faceted_surface_using_face_mesh(TetMeshFacetedSurface *&faceted_surface_pt)
Helper function that updates the input faceted surface by using the flattened elements from FaceMesh(...
void refine_uniformly(DocInfo &doc_info)
Refine mesh uniformly and doc process.
bool Corner_elements_must_be_split
Corner elements which have all of their nodes on the outer boundary are to be split into elements whi...
void initialise_adaptation_data()
Helper function to initialise data associated with adaptation.
void enable_projection()
Disable projection of old solution onto new mesh.
RefineableTetgenMesh(TetMeshFacetedClosedSurface *const &outer_boundary_pt, Vector< TetMeshFacetedSurface * > &internal_closed_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)
Build mesh, based on a TetMeshFacetedClosedSurface that specifies the outer boundary of the domain an...
virtual ~RefineableTetgenMesh()
Empty Destructor.
void snap_nodes_onto_boundary(RefineableTetgenMesh< ELEMENT > *&new_mesh_pt, const unsigned &b)
Snap the boundary nodes onto any curvilinear boundaries.
void adapt(const Vector< double > &elem_error)
Adapt mesh, based on elemental error provided.
unsigned unrefine_uniformly()
Unrefine mesh uniformly: Return 0 for success, 1 for failure (if unrefinement has reached the coarses...
RefineableTetgenMesh(const Vector< double > &target_volume, tetgenio *const &tetgen_io_pt, TetMeshFacetedClosedSurface *const &outer_boundary_pt, Vector< TetMeshFacetedSurface * > &internal_surface_pt, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper, const bool &use_attributes=false)
Specialised constructor used during adaptation only. Element sizes are specified by vector tetgen_io ...
void disable_projection()
Disable projection of old solution onto new mesh.
Unstructured tet mesh based on output from Tetgen: http://wias-berlin.de/software/tetgen/.
void build_from_scaffold(TimeStepper *time_stepper_pt, const bool &use_attributes)
Build mesh from scaffold.
tetgenio * Tetgenio_pt
Tetgen representation of mesh.
void setup_reverse_lookup_schemes_for_faceted_surface(TetMeshFacetedSurface *const &faceted_surface_pt)
Function to setup the reverse look-up schemes.
void deep_copy_of_tetgenio(tetgenio *const &input_pt, tetgenio *&output_pt)
Transfer tetgenio data from the input to the output The output is assumed to have been constructed an...
bool Tetgenio_exists
Boolean to indicate whether a tetgenio representation of the mesh exists.
TetgenScaffoldMesh * Tmp_mesh_pt
Temporary scaffold mesh.
////////////////////////////////////////////////////////////////////// //////////////////////////////...