31 #ifndef OOMPH_REFINEABLE_TETGEN_MESH_HEADER    32 #define OOMPH_REFINEABLE_TETGEN_MESH_HEADER    36   #include <oomph-lib-config.h>    40 #include "../generic/tetgen_scaffold_mesh.h"    41 #include "../generic/tet_mesh.h"    42 #include "../generic/refineable_mesh.h"    53 template<
class ELEMENT>
    55   public virtual RefineableTetMeshBase
    65     TetMeshFacetedClosedSurface* 
const &outer_boundary_pt,
    66     Vector<TetMeshFacetedSurface*>& internal_closed_surface_pt,
    67     const double &element_volume,
    68     TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper,
    69     const bool &use_attributes = 
false,
    70     const bool& split_corner_elements = 
false) :
    72                         internal_closed_surface_pt,
    90                          tetgenio* 
const &tetgen_io_pt,
    91                          TetMeshFacetedClosedSurface* 
const &outer_boundary_pt,
    92                          Vector<TetMeshFacetedSurface*>& internal_surface_pt,
    93                          TimeStepper* time_stepper_pt=
    94                          &Mesh::Default_TimeStepper,
    95                          const bool &use_attributes=
false)
   104       MeshChecker::assert_geometric_element<TElementGeometricBase,ELEMENT>(3);
   110      this->Time_stepper_pt=time_stepper_pt;
   124      tetgenio *tetgen_input_pt = 
new tetgenio;;
   128      tetgen_input_pt->tetrahedronvolumelist = 
   129       new double[tetgen_input_pt->numberoftetrahedra];
   130      for(
int e=0;e<tetgen_input_pt->numberoftetrahedra;++e)
   132        tetgen_input_pt->tetrahedronvolumelist[e] = target_volume[e];
   136      std::stringstream input_string_stream;
   137      input_string_stream<< 
"Vqra"; 
   140      char tetswitches[100];
   141      sprintf(tetswitches,
"%s",input_string_stream.str().c_str());
   144      tetrahedralize(tetswitches, tetgen_input_pt, this->
Tetgenio_pt);       
   156      delete tetgen_input_pt;
   159      this->Outer_boundary_pt = outer_boundary_pt;
   163       unsigned n_facet=this->Outer_boundary_pt->nfacet();
   164       for (
unsigned f=0;f<n_facet;f++)
   166         unsigned b=this->Outer_boundary_pt->one_based_facet_boundary_id(f);
   169           this->Tet_mesh_faceted_surface_pt[b-1]=this->Outer_boundary_pt;
   170           this->Tet_mesh_facet_pt[b-1]=this->Outer_boundary_pt->facet_pt(f);
   174           std::ostringstream error_message;
   175           error_message << 
"Boundary IDs have to be one-based. Yours is "    177           throw OomphLibError(error_message.str(),
   178                               OOMPH_CURRENT_FUNCTION,
   179                               OOMPH_EXCEPTION_LOCATION);
   185      this->Internal_surface_pt = internal_surface_pt;
   189       unsigned n=this->Internal_surface_pt.size();
   190       for (
unsigned i=0;i<n;i++)
   192         unsigned n_facet=this->Internal_surface_pt[i]->nfacet();
   193         for (
unsigned f=0;f<n_facet;f++)
   195           unsigned b=this->Internal_surface_pt[i]->
   196            one_based_facet_boundary_id(f);
   199             this->Tet_mesh_faceted_surface_pt[b-1]=
   200              this->Internal_surface_pt[i];    
   201             this->Tet_mesh_facet_pt[b-1]=
   202              this->Internal_surface_pt[i]->facet_pt(f);
   206             std::ostringstream error_message;
   207             error_message << 
"Boundary IDs have to be one-based. Yours is "    209             throw OomphLibError(error_message.str(),
   210                                 OOMPH_CURRENT_FUNCTION,
   211                                 OOMPH_EXCEPTION_LOCATION);
   219      unsigned nb=nboundary();
   220      for (
unsigned b=0;b<nb;b++)
   222        this->
template setup_boundary_coordinates<ELEMENT>(b);
   227      this->snap_nodes_onto_geometric_objects();
   241     throw OomphLibError(
"refine_uniformly() not implemented yet",
   242                         OOMPH_CURRENT_FUNCTION,
   243                         OOMPH_EXCEPTION_LOCATION); 
   252     throw OomphLibError(
"unrefine_uniformly() not implemented yet",
   253                         OOMPH_CURRENT_FUNCTION,
   254                         OOMPH_EXCEPTION_LOCATION); 
   260    void adapt(
const Vector<double>& elem_error);
   288     this->Max_element_size=1.0;
   289     this->Min_element_size=0.001;
   290     this->Max_permitted_edge_ratio=2.0;
 
void build_from_scaffold(TimeStepper *time_stepper_pt, const bool &use_attributes)
Build mesh from scaffold. 
 
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 ...
 
TetgenScaffoldMesh * Tmp_mesh_pt
Temporary scaffold mesh. 
 
bool Projection_is_disabled
Disable projection of solution onto new mesh during adaptation. 
 
bool Tetgenio_exists
Boolean to indicate whether a tetgenio representation of the mesh exists. 
 
Unstructured tet mesh based on output from Tetgen: http://wias-berlin.de/software/tetgen/. 
 
void refine_uniformly(DocInfo &doc_info)
Refine mesh uniformly and doc process. 
 
void deep_copy_of_tetgenio(tetgenio *const &input_pt, tetgenio *&output_pt)
 
unsigned unrefine_uniformly()
Unrefine mesh uniformly: Return 0 for success, 1 for failure (if unrefinement has reached the coarses...
 
void adapt(const Vector< double > &elem_error)
Adapt mesh, based on elemental error provided. 
 
bool projection_is_disabled()
Is projection of old solution onto new mesh disabled? 
 
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...
 
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)
Build mesh, based on a TetMeshFacetedClosedSurface that specifies the outer boundary of the domain an...
 
virtual ~RefineableTetgenMesh()
Empty Destructor. 
 
void initialise_adaptation_data()
Helper function to initialise data associated with adaptation. 
 
void enable_projection()
Disable projection of old solution onto new mesh. 
 
void disable_projection()
Disable projection of old solution onto new mesh. 
 
tetgenio * Tetgenio_pt
Tetgen representation of mesh.