oomph::RefineableGmshTetMesh< ELEMENT > Class Template Reference

#include <gmsh_tet_mesh.template.h>

+ Inheritance diagram for oomph::RefineableGmshTetMesh< ELEMENT >:

Public Member Functions

 RefineableGmshTetMesh (GmshParameters *gmsh_parameters_pt, const bool &use_mesh_grading_from_file, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
 
 RefineableGmshTetMesh (GmshParameters *gmsh_parameters_pt, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
 Constructor. More...
 
void adapt (const Vector< double > &elem_error)
 Adapt mesh, based on elemental error provided. More...
 
unsigned unrefine_uniformly ()
 Refine uniformly. More...
 
void refine_uniformly (DocInfo &doc_info)
 Unrefine uniformly. More...
 
- Public Member Functions inherited from oomph::GmshTetMesh< ELEMENT >
 GmshTetMesh (GmshParameters *gmsh_parameters_pt, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
 Constructor. More...
 
 GmshTetMesh (GmshParameters *gmsh_parameters_pt, const bool &use_mesh_grading_from_file, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
 
- Public Member Functions inherited from oomph::TetMeshBase
 TetMeshBase ()
 Constructor. More...
 
 TetMeshBase (const TetMeshBase &node)=delete
 Broken copy constructor. More...
 
void operator= (const TetMeshBase &)=delete
 Broken assignment operator. More...
 
virtual ~TetMeshBase ()
 Destructor (empty) More...
 
void assess_mesh_quality (std::ofstream &some_file)
 
template<class ELEMENT >
void setup_boundary_coordinates (const unsigned &b)
 
template<class ELEMENT >
void setup_boundary_coordinates (const unsigned &b, const bool &switch_normal)
 
template<class ELEMENT >
void setup_boundary_coordinates (const unsigned &b, const bool &switch_normal, std::ofstream &outfile)
 
template<class ELEMENT >
void setup_boundary_coordinates (const unsigned &b, std::ofstream &outfile)
 
unsigned nboundary_element_in_region (const unsigned &b, const unsigned &r) const
 Return the number of elements adjacent to boundary b in region r. More...
 
FiniteElementboundary_element_in_region_pt (const unsigned &b, const unsigned &r, const unsigned &e) const
 Return pointer to the e-th element adjacent to boundary b in region r. More...
 
int face_index_at_boundary_in_region (const unsigned &b, const unsigned &r, const unsigned &e) const
 Return face index of the e-th element adjacent to boundary b in region r. More...
 
unsigned nregion ()
 Return the number of regions specified by attributes. More...
 
unsigned nregion_element (const unsigned &r)
 Return the number of elements in region r. More...
 
double region_attribute (const unsigned &i)
 
FiniteElementregion_element_pt (const unsigned &r, const unsigned &e)
 Return the e-th element in the r-th region. More...
 
template<class ELEMENT >
void snap_to_quadratic_surface (const Vector< unsigned > &boundary_id, const std::string &quadratic_surface_file_name, const bool &switch_normal, DocInfo &doc_info)
 
template<class ELEMENT >
void snap_to_quadratic_surface (const Vector< unsigned > &boundary_id, const std::string &quadratic_surface_file_name, const bool &switch_normal)
 
void snap_nodes_onto_geometric_objects ()
 
template<class ELEMENT >
void split_elements_in_corners (TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
 
void setup_boundary_element_info ()
 
void setup_boundary_element_info (std::ostream &outfile)
 
- Public Member Functions inherited from oomph::Mesh
 Mesh ()
 Default constructor. More...
 
 Mesh (const Vector< Mesh * > &sub_mesh_pt)
 
void merge_meshes (const Vector< Mesh * > &sub_mesh_pt)
 
virtual void reset_boundary_element_info (Vector< unsigned > &ntmp_boundary_elements, Vector< Vector< unsigned >> &ntmp_boundary_elements_in_region, Vector< FiniteElement * > &deleted_elements)
 Virtual function to perform the reset boundary elements info rutines. More...
 
template<class BULK_ELEMENT >
void doc_boundary_coordinates (const unsigned &b, std::ofstream &the_file)
 
virtual void scale_mesh (const double &factor)
 
 Mesh (const Mesh &dummy)=delete
 Broken copy constructor. More...
 
void operator= (const Mesh &)=delete
 Broken assignment operator. More...
 
virtual ~Mesh ()
 Virtual Destructor to clean up all memory. More...
 
void flush_element_and_node_storage ()
 
void flush_element_storage ()
 
void flush_node_storage ()
 
Node *& node_pt (const unsigned long &n)
 Return pointer to global node n. More...
 
Nodenode_pt (const unsigned long &n) const
 Return pointer to global node n (const version) More...
 
GeneralisedElement *& element_pt (const unsigned long &e)
 Return pointer to element e. More...
 
GeneralisedElementelement_pt (const unsigned long &e) const
 Return pointer to element e (const version) More...
 
const Vector< GeneralisedElement * > & element_pt () const
 Return reference to the Vector of elements. More...
 
Vector< GeneralisedElement * > & element_pt ()
 Return reference to the Vector of elements. More...
 
FiniteElementfinite_element_pt (const unsigned &e) const
 
Node *& boundary_node_pt (const unsigned &b, const unsigned &n)
 Return pointer to node n on boundary b. More...
 
Nodeboundary_node_pt (const unsigned &b, const unsigned &n) const
 Return pointer to node n on boundary b. More...
 
void set_nboundary (const unsigned &nbound)
 Set the number of boundaries in the mesh. More...
 
void remove_boundary_nodes ()
 Clear all pointers to boundary nodes. More...
 
void remove_boundary_nodes (const unsigned &b)
 
void remove_boundary_node (const unsigned &b, Node *const &node_pt)
 Remove a node from the boundary b. More...
 
void add_boundary_node (const unsigned &b, Node *const &node_pt)
 Add a (pointer to) a node to the b-th boundary. More...
 
void copy_boundary_node_data_from_nodes ()
 
bool boundary_coordinate_exists (const unsigned &i) const
 Indicate whether the i-th boundary has an intrinsic coordinate. More...
 
unsigned long nelement () const
 Return number of elements in the mesh. More...
 
unsigned long nnode () const
 Return number of nodes in the mesh. More...
 
unsigned ndof_types () const
 Return number of dof types in mesh. More...
 
unsigned elemental_dimension () const
 Return number of elemental dimension in mesh. More...
 
unsigned nodal_dimension () const
 Return number of nodal dimension in mesh. More...
 
void add_node_pt (Node *const &node_pt)
 Add a (pointer to a) node to the mesh. More...
 
void add_element_pt (GeneralisedElement *const &element_pt)
 Add a (pointer to) an element to the mesh. More...
 
virtual void node_update (const bool &update_all_solid_nodes=false)
 
virtual void reorder_nodes (const bool &use_old_ordering=true)
 
virtual void get_node_reordering (Vector< Node * > &reordering, const bool &use_old_ordering=true) const
 
template<class BULK_ELEMENT , template< class > class FACE_ELEMENT>
void build_face_mesh (const unsigned &b, Mesh *const &face_mesh_pt)
 
unsigned self_test ()
 Self-test: Check elements and nodes. Return 0 for OK. More...
 
void max_and_min_element_size (double &max_size, double &min_size)
 
double total_size ()
 
void check_inverted_elements (bool &mesh_has_inverted_elements, std::ofstream &inverted_element_file)
 
void check_inverted_elements (bool &mesh_has_inverted_elements)
 
unsigned check_for_repeated_nodes (const double &epsilon=1.0e-12)
 
Vector< Node * > prune_dead_nodes ()
 
unsigned nboundary () const
 Return number of boundaries. More...
 
unsigned long nboundary_node (const unsigned &ibound) const
 Return number of nodes on a particular boundary. More...
 
FiniteElementboundary_element_pt (const unsigned &b, const unsigned &e) const
 Return pointer to e-th finite element on boundary b. More...
 
Nodeget_some_non_boundary_node () const
 
unsigned nboundary_element (const unsigned &b) const
 Return number of finite elements that are adjacent to boundary b. More...
 
int face_index_at_boundary (const unsigned &b, const unsigned &e) const
 
virtual void dump (std::ofstream &dump_file, const bool &use_old_ordering=true) const
 Dump the data in the mesh into a file for restart. More...
 
void dump (const std::string &dump_file_name, const bool &use_old_ordering=true) const
 Dump the data in the mesh into a file for restart. More...
 
virtual void read (std::ifstream &restart_file)
 Read solution from restart file. More...
 
void output_paraview (std::ofstream &file_out, const unsigned &nplot) const
 
void output_fct_paraview (std::ofstream &file_out, const unsigned &nplot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt) const
 
void output_fct_paraview (std::ofstream &file_out, const unsigned &nplot, const double &time, FiniteElement::UnsteadyExactSolutionFctPt exact_soln_pt) const
 
void output (std::ostream &outfile)
 Output for all elements. More...
 
void output (std::ostream &outfile, const unsigned &n_plot)
 Output at f(n_plot) points in each element. More...
 
void output (FILE *file_pt)
 Output for all elements (C-style output) More...
 
void output (FILE *file_pt, const unsigned &nplot)
 Output at f(n_plot) points in each element (C-style output) More...
 
void output (const std::string &output_filename)
 Output for all elements. More...
 
void output (const std::string &output_filename, const unsigned &n_plot)
 Output at f(n_plot) points in each element. More...
 
void output_fct (std::ostream &outfile, const unsigned &n_plot, FiniteElement::SteadyExactSolutionFctPt)
 Output a given Vector function at f(n_plot) points in each element. More...
 
void output_fct (std::ostream &outfile, const unsigned &n_plot, const double &time, FiniteElement::UnsteadyExactSolutionFctPt)
 
void output_boundaries (std::ostream &outfile)
 Output the nodes on the boundaries (into separate tecplot zones) More...
 
void output_boundaries (const std::string &output_filename)
 
void assign_initial_values_impulsive ()
 Assign initial values for an impulsive start. More...
 
void shift_time_values ()
 
void calculate_predictions ()
 
void set_nodal_and_elemental_time_stepper (TimeStepper *const &time_stepper_pt, const bool &preserve_existing_data)
 
virtual void set_mesh_level_time_stepper (TimeStepper *const &time_stepper_pt, const bool &preserve_existing_data)
 
void set_consistent_pinned_values_for_continuation (ContinuationStorageScheme *const &continuation_stepper_pt)
 Set consistent values for pinned data in continuation. More...
 
bool does_pointer_correspond_to_mesh_data (double *const &parameter_pt)
 Does the double pointer correspond to any mesh data. More...
 
void set_nodal_time_stepper (TimeStepper *const &time_stepper_pt, const bool &preserve_existing_data)
 Set the timestepper associated with the nodal data in the mesh. More...
 
void set_elemental_internal_time_stepper (TimeStepper *const &time_stepper_pt, const bool &preserve_existing_data)
 
virtual void compute_norm (double &norm)
 
virtual void compute_norm (Vector< double > &norm)
 
virtual void compute_error (std::ostream &outfile, FiniteElement::UnsteadyExactSolutionFctPt exact_soln_pt, const double &time, double &error, double &norm)
 
virtual void compute_error (std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, double &error, double &norm)
 
virtual void compute_error (FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, double &error, double &norm)
 
virtual void compute_error (FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, Vector< double > &error, Vector< double > &norm)
 
virtual void compute_error (std::ostream &outfile, FiniteElement::UnsteadyExactSolutionFctPt exact_soln_pt, const double &time, Vector< double > &error, Vector< double > &norm)
 
virtual void compute_error (std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, Vector< double > &error, Vector< double > &norm)
 
virtual void compute_error (FiniteElement::UnsteadyExactSolutionFctPt exact_soln_pt, const double &time, double &error, double &norm)
 Returns the norm of the error and that of the exact solution. More...
 
virtual void compute_error (FiniteElement::UnsteadyExactSolutionFctPt exact_soln_pt, const double &time, Vector< double > &error, Vector< double > &norm)
 
bool is_mesh_distributed () const
 Boolean to indicate if Mesh has been distributed. More...
 
OomphCommunicatorcommunicator_pt () const
 
void delete_all_external_storage ()
 Wipe the storage for all externally-based elements. More...
 
- Public Member Functions inherited from oomph::RefineableTetMeshBase
doublemax_element_size ()
 Max element size allowed during adaptation. More...
 
doublemin_element_size ()
 Min element size allowed during adaptation. More...
 
doublemax_permitted_edge_ratio ()
 Min edge ratio before remesh gets triggered. More...
 
void doc_adaptivity_targets (std::ostream &outfile)
 Doc the targets for mesh adaptation. More...
 
double compute_volume_target (const Vector< double > &elem_error, Vector< double > &target_volume)
 
- Public Member Functions inherited from oomph::RefineableMeshBase
bool adapt_flag ()
 
 RefineableMeshBase ()
 
 RefineableMeshBase (const RefineableMeshBase &dummy)=delete
 Broken copy constructor. More...
 
void operator= (const RefineableMeshBase &)=delete
 Broken assignment operator. More...
 
virtual ~RefineableMeshBase ()
 Empty Destructor: More...
 
unsigned nrefined ()
 Access fct for number of elements that were refined. More...
 
unsigned nunrefined ()
 Access fct for number of elements that were unrefined. More...
 
unsignednrefinement_overruled ()
 
unsignedmax_keep_unrefined ()
 
ErrorEstimator *& spatial_error_estimator_pt ()
 Access to spatial error estimator. More...
 
ErrorEstimatorspatial_error_estimator_pt () const
 Access to spatial error estimator (const version. More...
 
doublemin_permitted_error ()
 
doublemax_permitted_error ()
 
doublemin_error ()
 
doublemax_error ()
 
DocInfo *& doc_info_pt ()
 Access fct for pointer to DocInfo. More...
 
void enable_adaptation ()
 Enable adaptation. More...
 
void disable_adaptation ()
 Disable adaptation. More...
 
void enable_p_adaptation ()
 Enable adaptation. More...
 
void disable_p_adaptation ()
 Disable adaptation. More...
 
void enable_additional_synchronisation_of_hanging_nodes ()
 Enable additional synchronisation of hanging nodes. More...
 
void disable_additional_synchronisation_of_hanging_nodes ()
 Disable additional synchronisation of hanging nodes. More...
 
bool is_adaptation_enabled () const
 Return whether the mesh is to be adapted. More...
 
bool is_p_adaptation_enabled () const
 Return whether the mesh is to be adapted. More...
 
bool is_additional_synchronisation_of_hanging_nodes_disabled () const
 Return whether additional synchronisation is enabled. More...
 
DocInfo doc_info ()
 Access fct for DocInfo. More...
 
virtual void p_adapt (const Vector< double > &elemental_error)
 
virtual void refine_uniformly ()
 Refine mesh uniformly. More...
 
virtual void p_refine_uniformly (DocInfo &doc_info)
 p-refine mesh uniformly and doc process More...
 
virtual void p_refine_uniformly ()
 p-refine mesh uniformly More...
 
void p_unrefine_uniformly (DocInfo &doc_info)
 p-unrefine mesh uniformly More...
 

Protected Member Functions

void initialise_adaptation_data ()
 Helper function to initialise data associated with adaptation. More...
 
- Protected Member Functions inherited from oomph::Mesh
unsigned long assign_global_eqn_numbers (Vector< double * > &Dof_pt)
 Assign (global) equation numbers to the nodes. More...
 
void describe_dofs (std::ostream &out, const std::string &current_string) const
 
void describe_local_dofs (std::ostream &out, const std::string &current_string) const
 
void assign_local_eqn_numbers (const bool &store_local_dof_pt)
 Assign local equation numbers in all elements. More...
 
void convert_to_boundary_node (Node *&node_pt, const Vector< FiniteElement * > &finite_element_pt)
 
void convert_to_boundary_node (Node *&node_pt)
 

Additional Inherited Members

- Public Types inherited from oomph::Mesh
typedef void(FiniteElement::* SteadyExactSolutionFctPt) (const Vector< double > &x, Vector< double > &soln)
 
typedef void(FiniteElement::* UnsteadyExactSolutionFctPt) (const double &time, const Vector< double > &x, Vector< double > &soln)
 
- Public Attributes inherited from oomph::RefineableTetMeshBase
double Max_element_size
 Max permitted element size. More...
 
double Min_element_size
 Min permitted element size. More...
 
double Max_permitted_edge_ratio
 Max edge ratio before remesh gets triggered. More...
 
- Static Public Attributes inherited from oomph::TetMeshBase
static double Tolerance_for_boundary_finding = 1.0e-5
 
- Static Public Attributes inherited from oomph::Mesh
static Steady< 0 > Default_TimeStepper
 The Steady Timestepper. More...
 
static bool Suppress_warning_about_empty_mesh_level_time_stepper_function
 Static boolean flag to control warning about mesh level timesteppers. More...
 
- Protected Attributes inherited from oomph::GmshTetMesh< ELEMENT >
GmshParametersGmsh_parameters_pt
 Parameters. More...
 
- Protected Attributes inherited from oomph::TetMeshBase
Vector< Vector< FiniteElement * > > Region_element_pt
 
Vector< doubleRegion_attribute
 
Vector< std::map< unsigned, Vector< FiniteElement * > > > Boundary_region_element_pt
 Storage for elements adjacent to a boundary in a particular region. More...
 
Vector< std::map< unsigned, Vector< int > > > Face_index_region_at_boundary
 
TetMeshFacetedClosedSurfaceOuter_boundary_pt
 Faceted surface that defines outer boundaries. More...
 
Vector< TetMeshFacetedSurface * > Internal_surface_pt
 Vector to faceted surfaces that define internal boundaries. More...
 
std::map< unsigned, TetMeshFacetedSurface * > Tet_mesh_faceted_surface_pt
 
std::map< unsigned, TetMeshFacet * > Tet_mesh_facet_pt
 
std::map< unsigned, Vector< Vector< double > > > Triangular_facet_vertex_boundary_coordinate
 
TimeStepperTime_stepper_pt
 Timestepper used to build nodes. More...
 
- Protected Attributes inherited from oomph::Mesh
Vector< Vector< Node * > > Boundary_node_pt
 
bool Lookup_for_elements_next_boundary_is_setup
 
Vector< Vector< FiniteElement * > > Boundary_element_pt
 
Vector< Vector< int > > Face_index_at_boundary
 
Vector< Node * > Node_pt
 Vector of pointers to nodes. More...
 
Vector< GeneralisedElement * > Element_pt
 Vector of pointers to generalised elements. More...
 
std::vector< boolBoundary_coordinate_exists
 
- Protected Attributes inherited from oomph::RefineableMeshBase
ErrorEstimatorSpatial_error_estimator_pt
 Pointer to spatial error estimator. More...
 
double Max_permitted_error
 Max. error (i.e. split elements if their error is larger) More...
 
double Min_permitted_error
 Min. error (i.e. (try to) merge elements if their error is smaller) More...
 
double Min_error
 Min.actual error. More...
 
double Max_error
 Max. actual error. More...
 
unsigned Nrefined
 Stats: Number of elements that were refined. More...
 
unsigned Nunrefined
 Stats: Number of elements that were unrefined. More...
 
bool Adapt_flag
 Flag that requests adaptation. More...
 
bool P_adapt_flag
 Flag that requests p-adaptation. More...
 
bool Additional_synchronisation_of_hanging_nodes_not_required
 Flag that disables additional synchronisation of hanging nodes. More...
 
DocInfoDoc_info_pt
 Pointer to DocInfo. More...
 
unsigned Max_keep_unrefined
 
unsigned Nrefinement_overruled
 

Detailed Description

template<class ELEMENT>
class oomph::RefineableGmshTetMesh< ELEMENT >

/////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////

Constructor & Destructor Documentation

◆ RefineableGmshTetMesh() [1/2]

template<class ELEMENT >
oomph::RefineableGmshTetMesh< ELEMENT >::RefineableGmshTetMesh ( GmshParameters gmsh_parameters_pt,
const bool use_mesh_grading_from_file,
TimeStepper time_stepper_pt = &Mesh::Default_TimeStepper 
)
inline

Constructor. If boolean is set to true, the target element sizes are read from file (used during adaptation; otherwise uniform target size is used).

2294  : GmshTetMesh<ELEMENT>(
2295  gmsh_parameters_pt, use_mesh_grading_from_file, time_stepper_pt)
2296  {
2298  }
void initialise_adaptation_data()
Helper function to initialise data associated with adaptation.
Definition: gmsh_tet_mesh.template.h:2337

References oomph::RefineableGmshTetMesh< ELEMENT >::initialise_adaptation_data().

◆ RefineableGmshTetMesh() [2/2]

template<class ELEMENT >
oomph::RefineableGmshTetMesh< ELEMENT >::RefineableGmshTetMesh ( GmshParameters gmsh_parameters_pt,
TimeStepper time_stepper_pt = &Mesh::Default_TimeStepper 
)
inline

Constructor.

2304  : GmshTetMesh<ELEMENT>(gmsh_parameters_pt,
2305  false, // Don't read mesh size data from file
2306  // unless explicitly requested.
2307  time_stepper_pt)
2308  {
2310  }

References oomph::RefineableGmshTetMesh< ELEMENT >::initialise_adaptation_data().

Member Function Documentation

◆ adapt()

template<class ELEMENT >
void oomph::RefineableGmshTetMesh< ELEMENT >::adapt ( const Vector< double > &  elem_error)
virtual

Adapt mesh, based on elemental error provided.

Adapt problem based on specified elemental error estimates.

Implements oomph::RefineableMeshBase.

41  {
42  double t_start = 0.0;
43 
44  //###################################
45  t_start = TimingHelpers::timer();
46  //###################################
47 
48  // Get refinement targets
49  Vector<double> target_size(elem_error.size());
50  double max_edge_ratio =
51  this->compute_volume_target(elem_error, target_size);
52  // Get maximum target volume
53  unsigned n = target_size.size();
54  double max_size = 0.0;
55  double min_size = DBL_MAX;
56  for (unsigned e = 0; e < n; e++)
57  {
58  if (target_size[e] > max_size) max_size = target_size[e];
59  if (target_size[e] < min_size) min_size = target_size[e];
60  }
61 
62  oomph_info << "Maximum target size: " << max_size << std::endl;
63  oomph_info << "Minimum target size: " << min_size << std::endl;
64  oomph_info << "Number of elements to be refined " << this->Nrefined
65  << std::endl;
66  oomph_info << "Number of elements to be unrefined " << this->Nunrefined
67  << std::endl;
68  oomph_info << "Max edge ratio " << max_edge_ratio << std::endl;
69 
70  double orig_max_size, orig_min_size;
71  this->max_and_min_element_size(orig_max_size, orig_min_size);
72  oomph_info << "Max/min element size in original mesh: " << orig_max_size
73  << " " << orig_min_size << std::endl;
74 
75  //##################################################################
77  << "adapt: Time for getting volume targets : "
78  << TimingHelpers::timer() - t_start << " sec " << std::endl;
79  //##################################################################
80 
81  // Should we bother to adapt?
82  if ((Nrefined > 0) || (Nunrefined > this->max_keep_unrefined()) ||
83  (max_edge_ratio > this->max_permitted_edge_ratio()))
84  {
85  if (!((Nrefined > 0) || (Nunrefined > max_keep_unrefined())))
86  {
87  oomph_info << "Mesh regeneration triggered by edge ratio criterion\n";
88  }
89 
90 
91  // Are we dealing with a solid mesh?
92  SolidMesh* solid_mesh_pt = dynamic_cast<SolidMesh*>(this);
93 
94 
95  // If the mesh is a solid mesh then do the mapping based on the
96  // Eulerian coordinates
97  bool use_eulerian_coords = false;
98  if (solid_mesh_pt != 0)
99  {
100  use_eulerian_coords = true;
101  }
102 
103  MeshAsGeomObject* mesh_geom_obj_pt = 0;
104 
105 #ifdef OOMPH_HAS_CGAL
106 
107  // Make cgal-based bin
108  CGALSamplePointContainerParameters cgal_params(this);
109  if (use_eulerian_coords)
110  {
111  cgal_params.enable_use_eulerian_coordinates_during_setup();
112  }
113  mesh_geom_obj_pt = new MeshAsGeomObject(&cgal_params);
114 
115 #else
116 
117  std::ostringstream error_message;
118  error_message << "Non-CGAL-based target size transfer not implemented.\n";
119  throw OomphLibError(
120  error_message.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
121 
122  // Do something here...
123 
124 #endif
125 
126  // Set up a map from pointer to element to its number
127  // in the mesh
128  std::map<GeneralisedElement*, unsigned> element_number;
129  unsigned nelem = this->nelement();
130  for (unsigned e = 0; e < nelem; e++)
131  {
132  element_number[this->element_pt(e)] = e;
133  }
134 
135  // Get min/max coordinates
136  Vector<std::pair<double, double>> min_and_max_coordinates =
137  mesh_geom_obj_pt->sample_point_container_pt()
138  ->min_and_max_coordinates();
139 
140  // Setup grid dimensions for size transfer
141  double dx =
142  (min_and_max_coordinates[0].second - min_and_max_coordinates[0].first);
143  double dy =
144  (min_and_max_coordinates[1].second - min_and_max_coordinates[1].first);
145  double dz =
146  (min_and_max_coordinates[2].second - min_and_max_coordinates[2].first);
147 
148  double dx_target =
150  unsigned nx = unsigned(dx / dx_target);
151  unsigned ny = unsigned(dy / dx_target);
152  unsigned nz = unsigned(dz / dx_target);
153 
154  dx /= double(nx);
155  dy /= double(ny);
156  dz /= double(nz);
157 
158 
159  // Size transfer via hard disk -- yikes...
160  std::string target_size_file_name =
162 
163  std::ofstream target_size_file;
164  target_size_file.open(target_size_file_name.c_str());
165  target_size_file << min_and_max_coordinates[0].first << " "
166  << min_and_max_coordinates[1].first << " "
167  << min_and_max_coordinates[2].first << " " << std::endl;
168  target_size_file << dx << " " << dy << " " << dz << std::endl;
169  target_size_file << nx + 1 << " " << ny + 1 << " " << nz + 1 << std::endl;
170 
171 
172  // Doc target areas
173  int counter =
175  std::string stem =
177  std::ofstream latest_sizes_file;
178  bool doc_target_areas = false;
179  if ((stem != "") && (counter >= 0))
180  {
181  doc_target_areas = true;
183  stem + oomph::StringConversion::to_string(counter) + ".dat";
184  latest_sizes_file.open(filename.c_str());
185  latest_sizes_file << "ZONE I=" << nx + 1 << ", J=" << ny + 1
186  << ", K=" << nz + 1 << std::endl;
188  }
189 
190 
191  Vector<double> x(3);
192  for (unsigned i = 0; i <= nx; i++)
193  {
194  x[0] = min_and_max_coordinates[0].first + double(i) * dx;
195  for (unsigned j = 0; j <= ny; j++)
196  {
197  x[1] = min_and_max_coordinates[1].first + double(j) * dy;
198  for (unsigned k = 0; k <= nz; k++)
199  {
200  x[2] = min_and_max_coordinates[2].first + double(k) * dz;
201 
202  // Try the specified number of nearest sample points for Newton
203  // search then just settle on the nearest one
204  Vector<double> s(3);
205  GeomObject* geom_obj_pt = 0;
206  unsigned max_sample_points =
207  this->Gmsh_parameters_pt
209 
210 #ifdef OOMPH_HAS_CGAL
211 
212  dynamic_cast<CGALSamplePointContainer*>(
213  mesh_geom_obj_pt->sample_point_container_pt())
214  ->limited_locate_zeta(x, max_sample_points, geom_obj_pt, s);
215 
216 #else
217 
218  std::ostringstream error_message;
219  error_message
220  << "Non-CGAL-based target size transfer not implemented.\n";
221  throw OomphLibError(error_message.str(),
224 
225  // Do something here...
226 
227 #endif
228 
229 
230 #ifdef PARANOID
231  if (geom_obj_pt == 0)
232  {
233  std::stringstream error_message;
234  error_message << "Limited locate zeta failed for zeta = [ "
235  << x[0] << " " << x[1] << " " << x[2]
236  << " ]. Makes no sense!\n";
237  throw OomphLibError(error_message.str(),
240  }
241  else
242  {
243 #endif
244 
245  FiniteElement* fe_pt = dynamic_cast<FiniteElement*>(geom_obj_pt);
246 
247 #ifdef PARANOID
248  if (fe_pt == 0)
249  {
250  std::stringstream error_message;
251  error_message
252  << "Cast to FE for GeomObject returned by limited "
253  << "locate zeta failed for zeta = [ " << x[0] << " " << x[1]
254  << " " << x[2] << " ]. Makes no sense!\n";
255  throw OomphLibError(error_message.str(),
258  }
259  else
260  {
261 #endif
262 
263  // What's the target size of the element that contains this
264  // point
265  double tg_size =
266  pow(target_size[element_number[fe_pt]], 1.0 / 3.0);
267  target_size_file << tg_size << " ";
268 
269  // Doc?
270  if (doc_target_areas)
271  {
272  latest_sizes_file << x[0] << " " << x[1] << " " << x[2] << " "
273  << tg_size << std::endl;
274  }
275 
276 #ifdef PARANOID
277  }
278  }
279 #endif
280  }
281  target_size_file << std::endl;
282  }
283  }
284  target_size_file.close();
285 
286  if (doc_target_areas)
287  {
288  latest_sizes_file.close();
289  }
290 
291  // Build new mesh, reading area information from file
292  bool use_mesh_grading_from_file = true;
293  RefineableGmshTetMesh<ELEMENT>* new_mesh_pt =
294  new RefineableGmshTetMesh<ELEMENT>(this->Gmsh_parameters_pt,
295  use_mesh_grading_from_file,
296  this->Time_stepper_pt);
297 
298  /* // keep around for debugging */
299  /* unsigned nplot=5; */
300  /* ofstream vtu_file; */
301  /* vtu_file.open("new_mesh.vtu"); */
302  /* new_mesh_pt->output_paraview(vtu_file,nplot); */
303  /* vtu_file.close(); */
304 
305  //###################################
306  t_start = TimingHelpers::timer();
307  //###################################
308 
309  ProjectionProblem<ELEMENT>* project_problem_pt = 0;
310 
311  // Check that the projection step is not disabled
313  {
314  // Project current solution onto new mesh
315  //---------------------------------------
316  project_problem_pt = new ProjectionProblem<ELEMENT>;
317  project_problem_pt->mesh_pt() = new_mesh_pt;
318  project_problem_pt->project(this);
319 
320  oomph_info
321  << "adapt: Time for project soln onto new mesh : "
322  << TimingHelpers::timer() - t_start << " sec " << std::endl;
323  }
324  //###################################
325  t_start = TimingHelpers::timer();
326  //###################################
327 
328  // Flush the old mesh
329  unsigned nnod = nnode();
330  for (unsigned j = nnod; j > 0; j--)
331  {
332  delete Node_pt[j - 1];
333  Node_pt[j - 1] = 0;
334  }
335  unsigned nel = nelement();
336  for (unsigned e = nel; e > 0; e--)
337  {
338  delete Element_pt[e - 1];
339  Element_pt[e - 1] = 0;
340  }
341 
342  // Now copy back to current mesh
343  //------------------------------
344  nnod = new_mesh_pt->nnode();
345  Node_pt.resize(nnod);
346  nel = new_mesh_pt->nelement();
347  Element_pt.resize(nel);
348  for (unsigned j = 0; j < nnod; j++)
349  {
350  Node_pt[j] = new_mesh_pt->node_pt(j);
351  }
352  for (unsigned e = 0; e < nel; e++)
353  {
354  Element_pt[e] = new_mesh_pt->element_pt(e);
355  }
356 
357  // Copy the boundary schemes
358  unsigned nbound = new_mesh_pt->nboundary();
359  Boundary_element_pt.resize(nbound);
360  Face_index_at_boundary.resize(nbound);
361  Boundary_node_pt.resize(nbound);
362  for (unsigned b = 0; b < nbound; b++)
363  {
364  unsigned nel = new_mesh_pt->nboundary_element(b);
365  Boundary_element_pt[b].resize(nel);
366  Face_index_at_boundary[b].resize(nel);
367  for (unsigned e = 0; e < nel; e++)
368  {
369  Boundary_element_pt[b][e] = new_mesh_pt->boundary_element_pt(b, e);
371  new_mesh_pt->face_index_at_boundary(b, e);
372  }
373  unsigned nnod = new_mesh_pt->nboundary_node(b);
374  Boundary_node_pt[b].resize(nnod);
375  for (unsigned j = 0; j < nnod; j++)
376  {
377  Boundary_node_pt[b][j] = new_mesh_pt->boundary_node_pt(b, j);
378  }
379  }
380 
381  // Also copy over the new boundary and region information
382  unsigned n_region = new_mesh_pt->nregion();
383 
384  // Only bother if we have regions
385  if (n_region > 1)
386  {
387  // Deal with the region information first
388  this->Region_element_pt.resize(n_region);
389  this->Region_attribute.resize(n_region);
390  for (unsigned i = 0; i < n_region; i++)
391  {
392  // Copy across region attributes (region ids!)
393  this->Region_attribute[i] = new_mesh_pt->region_attribute(i);
394 
395  // Find the number of elements in the region
396  unsigned r = this->Region_attribute[i];
397  unsigned n_region_element = new_mesh_pt->nregion_element(r);
398  this->Region_element_pt[i].resize(n_region_element);
399  for (unsigned e = 0; e < n_region_element; e++)
400  {
401  this->Region_element_pt[i][e] =
402  new_mesh_pt->region_element_pt(r, e);
403  }
404  }
405 
406  // Now the boundary region information
407  this->Boundary_region_element_pt.resize(nbound);
408  this->Face_index_region_at_boundary.resize(nbound);
409 
410  // Now loop over the boundaries
411  for (unsigned b = 0; b < nbound; ++b)
412  {
413  // Loop over the regions
414  for (unsigned i = 0; i < n_region; ++i)
415  {
416  unsigned r = this->Region_attribute[i];
417 
418  unsigned n_boundary_el_in_region =
419  new_mesh_pt->nboundary_element_in_region(b, r);
420  if (n_boundary_el_in_region > 0)
421  {
422  // Allocate storage in the map
423  this->Boundary_region_element_pt[b][r].resize(
424  n_boundary_el_in_region);
425  this->Face_index_region_at_boundary[b][r].resize(
426  n_boundary_el_in_region);
427 
428  // Copy over the information
429  for (unsigned e = 0; e < n_boundary_el_in_region; ++e)
430  {
431  this->Boundary_region_element_pt[b][r][e] =
432  new_mesh_pt->boundary_element_in_region_pt(b, r, e);
434  new_mesh_pt->face_index_at_boundary_in_region(b, r, e);
435  }
436  }
437  }
438  } // End of loop over boundaries
439 
440  } // End of case when more than one region
441 
442 
443  // Flush the mesh
444  new_mesh_pt->flush_element_and_node_storage();
445 
446  // Delete the mesh and the problem
447  delete new_mesh_pt;
448  delete project_problem_pt;
449 
450  //##################################################################
451  oomph_info
452  << "adapt: Time for moving nodes etc. to actual mesh : "
453  << TimingHelpers::timer() - t_start << " sec " << std::endl;
454  //##################################################################
455 
456 
457  // Solid mesh?
458  if (solid_mesh_pt != 0)
459  {
460  // Warning
461  std::stringstream error_message;
462  error_message
463  << "Lagrangian coordinates are currently not projected but are\n"
464  << "are re-set during adaptation. This is not appropriate for\n"
465  << "real solid mechanics problems!\n";
466  OomphLibWarning(error_message.str(),
469 
470  // Reset Lagrangian coordinates
471  dynamic_cast<SolidMesh*>(this)->set_lagrangian_nodal_coordinates();
472  }
473 
474  double max_area;
475  double min_area;
476  this->max_and_min_element_size(max_area, min_area);
477  oomph_info << "Max/min element size in adapted mesh: " << max_area << " "
478  << min_area << std::endl;
479  }
480  else
481  {
482  oomph_info << "Not enough benefit in adaptation.\n";
483  Nrefined = 0;
484  Nunrefined = 0;
485  }
486  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Scalar * b
Definition: benchVecAdd.cpp:17
std::string & stem_for_filename_gmsh_size_transfer()
Definition: gmsh_tet_mesh.template.h:152
unsigned & max_sample_points_for_limited_locate_zeta_during_target_size_transfer()
Definition: gmsh_tet_mesh.template.h:144
std::string & target_size_file_name()
Definition: gmsh_tet_mesh.template.h:97
bool projection_is_disabled()
Is projection of old solution onto new mesh disabled?
Definition: gmsh_tet_mesh.template.h:166
int & counter_for_filename_gmsh_size_transfer()
Definition: gmsh_tet_mesh.template.h:160
double & dx_for_target_size_transfer()
(Isotropic) grid spacing for target size transfer
Definition: gmsh_tet_mesh.template.h:135
GmshParameters * Gmsh_parameters_pt
Parameters.
Definition: gmsh_tet_mesh.template.h:1787
Vector< Node * > Node_pt
Vector of pointers to nodes.
Definition: mesh.h:183
void max_and_min_element_size(double &max_size, double &min_size)
Definition: mesh.h:692
Vector< Vector< FiniteElement * > > Boundary_element_pt
Definition: mesh.h:91
Vector< Vector< int > > Face_index_at_boundary
Definition: mesh.h:95
unsigned long nnode() const
Return number of nodes in the mesh.
Definition: mesh.h:596
const Vector< GeneralisedElement * > & element_pt() const
Return reference to the Vector of elements.
Definition: mesh.h:460
Vector< Vector< Node * > > Boundary_node_pt
Definition: mesh.h:83
Vector< GeneralisedElement * > Element_pt
Vector of pointers to generalised elements.
Definition: mesh.h:186
unsigned long nelement() const
Return number of elements in the mesh.
Definition: mesh.h:590
unsigned Nrefined
Stats: Number of elements that were refined.
Definition: refineable_mesh.h:338
unsigned & max_keep_unrefined()
Definition: refineable_mesh.h:123
unsigned Nunrefined
Stats: Number of elements that were unrefined.
Definition: refineable_mesh.h:341
double compute_volume_target(const Vector< double > &elem_error, Vector< double > &target_volume)
Definition: refineable_mesh.h:922
double & max_permitted_edge_ratio()
Min edge ratio before remesh gets triggered.
Definition: refineable_mesh.h:896
Vector< double > Region_attribute
Definition: tet_mesh.h:1027
TimeStepper * Time_stepper_pt
Timestepper used to build nodes.
Definition: tet_mesh.h:1057
Vector< std::map< unsigned, Vector< FiniteElement * > > > Boundary_region_element_pt
Storage for elements adjacent to a boundary in a particular region.
Definition: tet_mesh.h:1031
Vector< std::map< unsigned, Vector< int > > > Face_index_region_at_boundary
Definition: tet_mesh.h:1035
Vector< Vector< FiniteElement * > > Region_element_pt
Definition: tet_mesh.h:1022
RealScalar s
Definition: level1_cplx_impl.h:130
char char char int int * k
Definition: level2_impl.h:374
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 pow(const bfloat16 &a, const bfloat16 &b)
Definition: BFloat16.h:625
string filename
Definition: MergeRestartFiles.py:39
const unsigned nz
Definition: ConstraintElementsUnitTest.cpp:32
const unsigned nx
Definition: ConstraintElementsUnitTest.cpp:30
const unsigned ny
Definition: ConstraintElementsUnitTest.cpp:31
r
Definition: UniformPSDSelfTest.py:20
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
std::string to_string(T object, unsigned float_precision=8)
Definition: oomph_utilities.h:189
double timer()
returns the time in seconds after some point in past
Definition: oomph_utilities.cc:1295
OomphInfo oomph_info
Definition: oomph_definitions.cc:319
list x
Definition: plotDoE.py:28
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References b, oomph::TetMeshBase::boundary_element_in_region_pt(), oomph::Mesh::boundary_element_pt(), oomph::Mesh::boundary_node_pt(), e(), oomph::Mesh::element_pt(), oomph::Mesh::face_index_at_boundary(), oomph::TetMeshBase::face_index_at_boundary_in_region(), MergeRestartFiles::filename, oomph::Mesh::flush_element_and_node_storage(), i, j, k, oomph::Problem::mesh_pt(), SamplePointContainer::min_and_max_coordinates(), n, oomph::Mesh::nboundary(), oomph::Mesh::nboundary_element(), oomph::TetMeshBase::nboundary_element_in_region(), oomph::Mesh::nboundary_node(), oomph::Mesh::nelement(), oomph::Mesh::nnode(), oomph::Mesh::node_pt(), oomph::TetMeshBase::nregion(), oomph::TetMeshBase::nregion_element(), Mesh_Parameters::nx, Mesh_Parameters::ny, Mesh_Parameters::nz, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::oomph_info, Eigen::bfloat16_impl::pow(), oomph::ProjectionProblem< PROJECTABLE_ELEMENT >::project(), UniformPSDSelfTest::r, oomph::TetMeshBase::region_attribute(), oomph::TetMeshBase::region_element_pt(), s, oomph::MeshAsGeomObject::sample_point_container_pt(), oomph::Global_string_for_annotation::string(), oomph::TimingHelpers::timer(), oomph::StringConversion::to_string(), and plotDoE::x.

◆ initialise_adaptation_data()

template<class ELEMENT >
void oomph::RefineableGmshTetMesh< ELEMENT >::initialise_adaptation_data ( )
inlineprotected

Helper function to initialise data associated with adaptation.

2338  {
2339  // Set max and min targets for adaptation
2342  this->Max_permitted_edge_ratio =
2344  }
double & min_element_size()
Min. element size during refinement.
Definition: gmsh_tet_mesh.template.h:123
double & max_element_size()
Max. element size during refinement.
Definition: gmsh_tet_mesh.template.h:117
double & max_permitted_edge_ratio()
Max. permitted edge ratio.
Definition: gmsh_tet_mesh.template.h:129
double Max_element_size
Max permitted element size.
Definition: refineable_mesh.h:1046
double Min_element_size
Min permitted element size.
Definition: refineable_mesh.h:1049
double Max_permitted_edge_ratio
Max edge ratio before remesh gets triggered.
Definition: refineable_mesh.h:1052

References oomph::GmshTetMesh< ELEMENT >::Gmsh_parameters_pt, oomph::RefineableTetMeshBase::Max_element_size, oomph::GmshParameters::max_element_size(), oomph::RefineableTetMeshBase::Max_permitted_edge_ratio, oomph::GmshParameters::max_permitted_edge_ratio(), oomph::RefineableTetMeshBase::Min_element_size, and oomph::GmshParameters::min_element_size().

Referenced by oomph::RefineableGmshTetMesh< ELEMENT >::RefineableGmshTetMesh().

◆ refine_uniformly()

template<class ELEMENT >
void oomph::RefineableGmshTetMesh< ELEMENT >::refine_uniformly ( DocInfo doc_info)
inlinevirtual

Unrefine uniformly.

Implements oomph::RefineableMeshBase.

2327  {
2328  // hierher do it!
2329  std::string error_msg("Not written yet...");
2330  throw OomphLibError(
2332  }

References OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, and oomph::Global_string_for_annotation::string().

◆ unrefine_uniformly()

template<class ELEMENT >
unsigned oomph::RefineableGmshTetMesh< ELEMENT >::unrefine_uniformly ( )
inlinevirtual

Refine uniformly.

Implements oomph::RefineableMeshBase.

2318  {
2319  // hierher do it!
2320  std::string error_msg("Not written yet...");
2321  throw OomphLibError(
2323  }

References OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, and oomph::Global_string_for_annotation::string().


The documentation for this class was generated from the following files: