oomph::GmshTetMesh< ELEMENT > Class Template Reference

Forward declaration. More...

#include <gmsh_tet_mesh.template.h>

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

Public Member Functions

 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...
 

Protected Attributes

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
 

Private Member Functions

void build_it (TimeStepper *time_stepper_pt, const bool &use_mesh_grading_from_file)
 
void build_from_scaffold (GmshTetScaffoldMesh *tmp_scaffold_mesh_pt, TimeStepper *time_stepper_pt)
 Build unstructured tet gmesh mesh based on output from scaffold. More...
 

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)
 
- 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 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)
 

Detailed Description

template<class ELEMENT>
class oomph::GmshTetMesh< ELEMENT >

Forward declaration.

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

Constructor & Destructor Documentation

◆ GmshTetMesh() [1/2]

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

Constructor.

1667  : Gmsh_parameters_pt(gmsh_parameters_pt)
1668  {
1669  bool use_mesh_grading_from_file = false;
1670  build_it(time_stepper_pt, use_mesh_grading_from_file);
1671  }
GmshParameters * Gmsh_parameters_pt
Parameters.
Definition: gmsh_tet_mesh.template.h:1787
void build_it(TimeStepper *time_stepper_pt, const bool &use_mesh_grading_from_file)
Definition: gmsh_tet_mesh.template.h:1687

References oomph::GmshTetMesh< ELEMENT >::build_it().

◆ GmshTetMesh() [2/2]

template<class ELEMENT >
oomph::GmshTetMesh< ELEMENT >::GmshTetMesh ( 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).

1679  : Gmsh_parameters_pt(gmsh_parameters_pt)
1680  {
1681  build_it(time_stepper_pt, use_mesh_grading_from_file);
1682  }

References oomph::GmshTetMesh< ELEMENT >::build_it().

Member Function Documentation

◆ build_from_scaffold()

template<class ELEMENT >
void oomph::GmshTetMesh< ELEMENT >::build_from_scaffold ( GmshTetScaffoldMesh tmp_scaffold_mesh_pt,
TimeStepper time_stepper_pt 
)
inlineprivate

Build unstructured tet gmesh mesh based on output from scaffold.

1794  {
1795  // Mesh can only be built with 3D Telements.
1796  MeshChecker::assert_geometric_element<TElementGeometricBase, ELEMENT>(3);
1797 
1798  // Create space for elements
1799  unsigned nelem = tmp_scaffold_mesh_pt->nelement();
1800  Element_pt.resize(nelem);
1801 
1802  // Relation between elements pointers and numbers in old mesh
1803  std::map<FiniteElement*, unsigned> scaffold_mesh_element_number;
1804 
1805  // Create space for nodes
1806  unsigned nnode_scaffold = tmp_scaffold_mesh_pt->nnode();
1807  Node_pt.resize(nnode_scaffold);
1808 
1809  // Set number of boundaries
1810  unsigned nbound = tmp_scaffold_mesh_pt->nboundary();
1811  set_nboundary(nbound);
1812 
1813  // Resize boundary info stuff
1814  Boundary_element_pt.resize(nbound); // hierher shouldn't this be a map?
1815  Face_index_at_boundary.resize(nbound); // hierher shouldn't this be a map?
1816  Boundary_region_element_pt.resize(nbound);
1817  Face_index_region_at_boundary.resize(nbound);
1818 
1819  // Build elements
1820  for (unsigned e = 0; e < nelem; e++)
1821  {
1822  Element_pt[e] = new ELEMENT;
1823  }
1824 
1825  // Number of nodes per element
1826  unsigned nnod_el = tmp_scaffold_mesh_pt->finite_element_pt(0)->nnode();
1827 
1828  // Setup map to check the (pseudo-)global node number
1829  // Nodes whose number is zero haven't been copied across
1830  // into the mesh yet.
1831  std::map<Node*, unsigned> global_number;
1832  unsigned global_count = 0;
1833 
1834  // Loop over elements in scaffold mesh, visit their nodes
1835  for (unsigned e = 0; e < nelem; e++)
1836  {
1837  // Setup reverse lookup scheme to decipher lookup schemes from
1838  // scaffold mesh
1839  scaffold_mesh_element_number[tmp_scaffold_mesh_pt->finite_element_pt(
1840  e)] = e;
1841 
1842  // Loop over all nodes in element
1843  for (unsigned j = 0; j < nnod_el; j++)
1844  {
1845  // Pointer to node in the scaffold mesh
1846  Node* scaffold_node_pt =
1847  tmp_scaffold_mesh_pt->finite_element_pt(e)->node_pt(j);
1848 
1849  // Get the (pseudo-)global node number in scaffold mesh
1850  // (It's zero [=default] if not visited this one yet)
1851  unsigned j_global = global_number[scaffold_node_pt];
1852 
1853  // Haven't done this one yet
1854  if (j_global == 0)
1855  {
1856  // Get pointer to set of mesh boundaries that this
1857  // scaffold node occupies; NULL if the node is not on any boundary
1858  std::set<unsigned>* boundaries_pt;
1859  scaffold_node_pt->get_boundaries_pt(boundaries_pt);
1860 
1861  // Is it on boundaries?
1862  if (boundaries_pt != 0)
1863  {
1864  // Create new boundary node
1865  Node* new_node_pt = finite_element_pt(e)->construct_boundary_node(
1866  j, time_stepper_pt);
1867 
1868  // Give it a number (not necessarily the global node
1869  // number in the scaffold mesh -- we just need something
1870  // to keep track...)
1871  global_count++;
1872  global_number[scaffold_node_pt] = global_count;
1873 
1874  // Add to boundaries
1875  for (std::set<unsigned>::iterator it = boundaries_pt->begin();
1876  it != boundaries_pt->end();
1877  ++it)
1878  {
1879  add_boundary_node(*it, new_node_pt);
1880  }
1881  }
1882  // Build normal node
1883  else
1884  {
1885  // Create new normal node
1886  finite_element_pt(e)->construct_node(j, time_stepper_pt);
1887 
1888  // Give it a number (not necessarily the global node
1889  // number in the scaffold mesh -- we just need something
1890  // to keep track...)
1891  global_count++;
1892  global_number[scaffold_node_pt] = global_count;
1893  }
1894 
1895  // Copy new node, created using the NEW element's construct_node
1896  // function into global storage, using the same global
1897  // node number that we've just associated with the
1898  // corresponding node in the scaffold mesh
1899  Node_pt[global_count - 1] = finite_element_pt(e)->node_pt(j);
1900 
1901  // Assign coordinates
1902  Node_pt[global_count - 1]->x(0) = scaffold_node_pt->x(0);
1903  Node_pt[global_count - 1]->x(1) = scaffold_node_pt->x(1);
1904  Node_pt[global_count - 1]->x(2) = scaffold_node_pt->x(2);
1905  }
1906  // This one has already been done: Copy across
1907  else
1908  {
1909  finite_element_pt(e)->node_pt(j) = Node_pt[j_global - 1];
1910  }
1911  }
1912 
1913 
1914  // Now figure out which boundaries the faces are on
1915  FiniteElement* fe_pt = finite_element_pt(e);
1916  for (unsigned f = 0; f < 4; f++)
1917  {
1918  Node* face_node0_pt = 0;
1919  Node* face_node1_pt = 0;
1920  Node* face_node2_pt = 0;
1921 
1922  switch (f)
1923  {
1924  case 0:
1925  face_node0_pt = fe_pt->node_pt(1);
1926  face_node1_pt = fe_pt->node_pt(2);
1927  face_node2_pt = fe_pt->node_pt(3);
1928  break;
1929 
1930  case 1:
1931  face_node0_pt = fe_pt->node_pt(0);
1932  face_node1_pt = fe_pt->node_pt(2);
1933  face_node2_pt = fe_pt->node_pt(3);
1934  break;
1935 
1936  case 2:
1937  face_node0_pt = fe_pt->node_pt(0);
1938  face_node1_pt = fe_pt->node_pt(1);
1939  face_node2_pt = fe_pt->node_pt(3);
1940  break;
1941 
1942  case 3:
1943  face_node0_pt = fe_pt->node_pt(0);
1944  face_node1_pt = fe_pt->node_pt(1);
1945  face_node2_pt = fe_pt->node_pt(2);
1946  break;
1947 
1948  default:
1949 
1950  std::ostringstream error_message;
1951  error_message << "Wrong face number " << f << std::endl;
1952  throw OomphLibError(error_message.str(),
1955  }
1956 
1957  // If any of the boundary sets are empty we don't have
1958  // three nodes on the boundary...
1959  std::set<unsigned>* bc0_pt;
1960  face_node0_pt->get_boundaries_pt(bc0_pt);
1961  if (bc0_pt != 0)
1962  {
1963  std::set<unsigned>* bc1_pt;
1964  face_node1_pt->get_boundaries_pt(bc1_pt);
1965  if (bc1_pt != 0)
1966  {
1967  std::set<unsigned>* bc2_pt;
1968  face_node2_pt->get_boundaries_pt(bc2_pt);
1969  if (bc2_pt != 0)
1970  {
1971  std::set<unsigned> common_bound_0_and_1;
1972  std::set_intersection(
1973  bc0_pt->begin(),
1974  bc0_pt->end(),
1975  bc1_pt->begin(),
1976  bc1_pt->end(),
1977  std::inserter(common_bound_0_and_1,
1978  common_bound_0_and_1.begin()));
1979  std::set<unsigned> common_bound_0_and_1_and_2;
1980  std::set_intersection(
1981  common_bound_0_and_1.begin(),
1982  common_bound_0_and_1.end(),
1983  bc2_pt->begin(),
1984  bc2_pt->end(),
1985  std::inserter(common_bound_0_and_1_and_2,
1986  common_bound_0_and_1_and_2.begin()));
1987  for (std::set<unsigned>::iterator it =
1988  common_bound_0_and_1_and_2.begin();
1989  it != common_bound_0_and_1_and_2.end();
1990  it++)
1991  {
1992  Boundary_element_pt[(*it)].push_back(fe_pt);
1993  Face_index_at_boundary[(*it)].push_back(f);
1994  }
1995  }
1996  }
1997  }
1998  }
1999  }
2000 
2001  // Copy across region information (scaffold mesh is a friend)
2002  unsigned nr = tmp_scaffold_mesh_pt->Region_element_pt.size();
2003  Region_attribute.resize(nr);
2004  Region_element_pt.resize(nr);
2005  for (unsigned i = 0; i < nr; i++)
2006  { //--
2007  Region_attribute[i] = tmp_scaffold_mesh_pt->Region_attribute[i];
2008  unsigned nel = tmp_scaffold_mesh_pt->Region_element_pt[i].size();
2009  Region_element_pt[i].resize(nel);
2010  for (unsigned e = 0; e < nel; e++)
2011  {
2012  FiniteElement* scaff_el_pt =
2013  tmp_scaffold_mesh_pt->Region_element_pt[i][e];
2014  unsigned scaff_el_number = scaffold_mesh_element_number[scaff_el_pt];
2015  Region_element_pt[i][e] =
2016  dynamic_cast<FiniteElement*>(Element_pt[scaff_el_number]);
2017 
2018 
2019  // Now figure out which boundaries the faces are on (again!)
2020  FiniteElement* fe_pt = Region_element_pt[i][e];
2021  for (unsigned f = 0; f < 4; f++)
2022  {
2023  Node* face_node0_pt = 0;
2024  Node* face_node1_pt = 0;
2025  Node* face_node2_pt = 0;
2026 
2027  switch (f)
2028  {
2029  case 0:
2030  face_node0_pt = fe_pt->node_pt(1);
2031  face_node1_pt = fe_pt->node_pt(2);
2032  face_node2_pt = fe_pt->node_pt(3);
2033  break;
2034 
2035  case 1:
2036  face_node0_pt = fe_pt->node_pt(0);
2037  face_node1_pt = fe_pt->node_pt(2);
2038  face_node2_pt = fe_pt->node_pt(3);
2039  break;
2040 
2041  case 2:
2042  face_node0_pt = fe_pt->node_pt(0);
2043  face_node1_pt = fe_pt->node_pt(1);
2044  face_node2_pt = fe_pt->node_pt(3);
2045  break;
2046 
2047  case 3:
2048  face_node0_pt = fe_pt->node_pt(0);
2049  face_node1_pt = fe_pt->node_pt(1);
2050  face_node2_pt = fe_pt->node_pt(2);
2051  break;
2052 
2053  default:
2054  std::ostringstream error_message;
2055  error_message << "Wrong face number " << f << std::endl;
2056  throw OomphLibError(error_message.str(),
2059  }
2060 
2061  // If any of the boundary sets are empty we don't have
2062  // three nodes on the boundary...
2063  std::set<unsigned>* bc0_pt;
2064  face_node0_pt->get_boundaries_pt(bc0_pt);
2065  if (bc0_pt != 0)
2066  {
2067  std::set<unsigned>* bc1_pt;
2068  face_node1_pt->get_boundaries_pt(bc1_pt);
2069  if (bc1_pt != 0)
2070  {
2071  std::set<unsigned>* bc2_pt;
2072  face_node2_pt->get_boundaries_pt(bc2_pt);
2073  if (bc2_pt != 0)
2074  {
2075  std::set<unsigned> common_bound_0_and_1;
2076  std::set_intersection(
2077  bc0_pt->begin(),
2078  bc0_pt->end(),
2079  bc1_pt->begin(),
2080  bc1_pt->end(),
2081  std::inserter(common_bound_0_and_1,
2082  common_bound_0_and_1.begin()));
2083  std::set<unsigned> common_bound_0_and_1_and_2;
2084  std::set_intersection(
2085  common_bound_0_and_1.begin(),
2086  common_bound_0_and_1.end(),
2087  bc2_pt->begin(),
2088  bc2_pt->end(),
2089  std::inserter(common_bound_0_and_1_and_2,
2090  common_bound_0_and_1_and_2.begin()));
2091  for (std::set<unsigned>::iterator it =
2092  common_bound_0_and_1_and_2.begin();
2093  it != common_bound_0_and_1_and_2.end();
2094  it++)
2095  {
2097  .push_back(fe_pt);
2099  .push_back(f);
2100  }
2101  }
2102  }
2103  }
2104  }
2105  }
2106  }
2107 
2108  // Lookup scheme has now been setup
2110 
2111 
2112  // At this point we've created all the elements and
2113  // created their vertex nodes. Now we need to create
2114  // the additional (midside and internal) nodes!
2115 
2116  // Get number of nodes along element edge
2117  unsigned n_node_1d = finite_element_pt(0)->nnode_1d();
2118 
2119  // At the moment we're only able to deal with nnode_1d=2 or 3.
2120  if ((n_node_1d != 2) && (n_node_1d != 3))
2121  {
2122  std::ostringstream error_message;
2123  error_message << "Mesh generation from gmsh currently only works\n";
2124  error_message << "for nnode_1d = 2 or 3. You're trying to use it\n";
2125  error_message << "for nnode_1d=" << n_node_1d << std::endl;
2126  throw OomphLibError(error_message.str(),
2129  }
2130 
2131  // Storage for the local coordinate of the new node
2132  Vector<double> s(3);
2133 
2134  // Map associating edge with midside node
2135  std::map<std::pair<Node*, Node*>, Node*> midside_node_pt;
2136 
2137  // Loop over all elements
2138  for (unsigned e = 0; e < nelem; e++)
2139  {
2140  // Cache pointers to the elements
2141  FiniteElement* const el_pt = this->finite_element_pt(e);
2142  FiniteElement* const simplex_el_pt =
2143  tmp_scaffold_mesh_pt->finite_element_pt(e);
2144 
2145  // Loop over the edges
2146  for (unsigned j = 0; j < 6; ++j)
2147  {
2148  Node* nod0_pt = 0;
2149  Node* nod1_pt = 0;
2150  unsigned new_node_number = 0;
2151  std::pair<Node*, Node*> edge;
2152  switch (j)
2153  {
2154  case 0:
2155  nod0_pt = el_pt->node_pt(0);
2156  nod1_pt = el_pt->node_pt(1);
2157  new_node_number = 4;
2158  break;
2159 
2160  case 1:
2161  nod0_pt = el_pt->node_pt(0);
2162  nod1_pt = el_pt->node_pt(2);
2163  new_node_number = 5;
2164  break;
2165 
2166  case 2:
2167  nod0_pt = el_pt->node_pt(0);
2168  nod1_pt = el_pt->node_pt(3);
2169  new_node_number = 6;
2170  break;
2171 
2172  case 3:
2173  nod0_pt = el_pt->node_pt(1);
2174  nod1_pt = el_pt->node_pt(2);
2175  new_node_number = 7;
2176  break;
2177 
2178  case 4:
2179  nod0_pt = el_pt->node_pt(2);
2180  nod1_pt = el_pt->node_pt(3);
2181  new_node_number = 8;
2182  break;
2183 
2184  case 5:
2185  nod0_pt = el_pt->node_pt(1);
2186  nod1_pt = el_pt->node_pt(3);
2187  new_node_number = 9;
2188  break;
2189 
2190  default:
2191  std::ostringstream error_message;
2192  error_message << "Wrong edge number " << j << std::endl;
2193  throw OomphLibError(error_message.str(),
2196  }
2197 
2198  // Identify existence of node via edge
2199  edge = std::make_pair(std::min(nod0_pt, nod1_pt),
2200  std::max(nod0_pt, nod1_pt));
2201  Node* existing_node_pt = midside_node_pt[edge];
2202  if (existing_node_pt == 0)
2203  {
2204  // If any of the boundary sets are empty we don't have
2205  // two edge nodes on the boundary...
2206  std::set<unsigned> common_bound_0_and_1;
2207  std::set<unsigned>* bc0_pt;
2208  nod0_pt->get_boundaries_pt(bc0_pt);
2209  if (bc0_pt != 0)
2210  {
2211  std::set<unsigned>* bc1_pt;
2212  nod1_pt->get_boundaries_pt(bc1_pt);
2213  if (bc1_pt != 0)
2214  {
2215  std::set_intersection(
2216  bc0_pt->begin(),
2217  bc0_pt->end(),
2218  bc1_pt->begin(),
2219  bc1_pt->end(),
2220  std::inserter(common_bound_0_and_1,
2221  common_bound_0_and_1.begin()));
2222  }
2223  }
2224  // Storage for the new node
2225  Node* new_node_pt = 0;
2226 
2227  // New non-boundary node:
2228  if (common_bound_0_and_1.size() == 0)
2229  {
2230  new_node_pt =
2231  el_pt->construct_node(new_node_number, time_stepper_pt);
2232  }
2233  // New boundary node
2234  else
2235  {
2236  new_node_pt = el_pt->construct_boundary_node(new_node_number,
2237  time_stepper_pt);
2238  for (std::set<unsigned>::iterator it =
2239  common_bound_0_and_1.begin();
2240  it != common_bound_0_and_1.end();
2241  it++)
2242  {
2243  this->add_boundary_node((*it), new_node_pt);
2244  }
2245  }
2246 
2247  // Find the local coordinates of the node
2248  el_pt->local_coordinate_of_node(new_node_number, s);
2249 
2250  // Find the coordinates of the new node from the existing
2251  // and fully-functional element in the scaffold mesh
2252  for (unsigned i = 0; i < 3; i++)
2253  {
2254  new_node_pt->x(i) = simplex_el_pt->interpolated_x(s, i);
2255  }
2256 
2257  // Associate node with edge
2258  midside_node_pt[edge] = new_node_pt;
2259 
2260  // Add node to mesh
2261  Node_pt.push_back(new_node_pt);
2262  }
2263  // Node already exists
2264  else
2265  {
2266  el_pt->node_pt(new_node_number) = existing_node_pt;
2267  }
2268  }
2269  }
2270  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Array< double, 1, 3 > e(1./3., 0.5, 2.)
virtual Node * construct_node(const unsigned &n)
Definition: elements.h:2509
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
Definition: elements.h:2175
virtual unsigned nnode_1d() const
Definition: elements.h:2218
virtual Node * construct_boundary_node(const unsigned &n)
Definition: elements.h:2538
void add_boundary_node(const unsigned &b, Node *const &node_pt)
Add a (pointer to) a node to the b-th boundary.
Definition: mesh.cc:243
Vector< Node * > Node_pt
Vector of pointers to nodes.
Definition: mesh.h:183
Vector< Vector< FiniteElement * > > Boundary_element_pt
Definition: mesh.h:91
bool Lookup_for_elements_next_boundary_is_setup
Definition: mesh.h:87
FiniteElement * finite_element_pt(const unsigned &e) const
Definition: mesh.h:473
Vector< Vector< int > > Face_index_at_boundary
Definition: mesh.h:95
void set_nboundary(const unsigned &nbound)
Set the number of boundaries in the mesh.
Definition: mesh.h:505
Vector< GeneralisedElement * > Element_pt
Vector of pointers to generalised elements.
Definition: mesh.h:186
Vector< double > Region_attribute
Definition: tet_mesh.h:1027
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
static int f(const TensorMap< Tensor< int, 3 > > &tensor)
Definition: cxx11_tensor_map.cpp:237
#define min(a, b)
Definition: datatypes.h:22
#define max(a, b)
Definition: datatypes.h:23
RealScalar s
Definition: level1_cplx_impl.h:130
#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 oomph::Mesh::add_boundary_node(), oomph::Mesh::Boundary_element_pt, oomph::TetMeshBase::Boundary_region_element_pt, oomph::FiniteElement::construct_boundary_node(), oomph::FiniteElement::construct_node(), e(), oomph::Mesh::Element_pt, f(), oomph::Mesh::Face_index_at_boundary, oomph::TetMeshBase::Face_index_region_at_boundary, oomph::Mesh::finite_element_pt(), oomph::Node::get_boundaries_pt(), i, oomph::FiniteElement::interpolated_x(), j, oomph::FiniteElement::local_coordinate_of_node(), oomph::Mesh::Lookup_for_elements_next_boundary_is_setup, max, min, oomph::Mesh::nboundary(), oomph::Mesh::nelement(), oomph::FiniteElement::nnode(), oomph::Mesh::nnode(), oomph::FiniteElement::nnode_1d(), oomph::FiniteElement::node_pt(), oomph::Mesh::Node_pt, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::TetMeshBase::Region_attribute, oomph::TetMeshBase::Region_element_pt, s, oomph::Mesh::set_nboundary(), and oomph::Node::x().

Referenced by oomph::GmshTetMesh< ELEMENT >::build_it().

◆ build_it()

template<class ELEMENT >
void oomph::GmshTetMesh< ELEMENT >::build_it ( TimeStepper time_stepper_pt,
const bool use_mesh_grading_from_file 
)
inlineprivate
1689  {
1690  // Mesh can only be built with 3D Telements.
1691  MeshChecker::assert_geometric_element<TElementGeometricBase, ELEMENT>(3);
1692 
1693  // Transfer data from parameters
1694  TetMeshFacetedClosedSurface* outer_boundary_pt =
1696 
1697  Vector<TetMeshFacetedSurface*> internal_surface_pt =
1699 
1700  // Remember timestepper
1701  Time_stepper_pt = time_stepper_pt;
1702 
1703  // Store the boundary
1704  Outer_boundary_pt = outer_boundary_pt;
1705 
1706  // Setup reverse lookup scheme
1707  {
1708  unsigned n_facet = Outer_boundary_pt->nfacet();
1709  for (unsigned f = 0; f < n_facet; f++)
1710  {
1712  if (b != 0)
1713  {
1716  }
1717  else
1718  {
1719  std::ostringstream error_message;
1720  error_message << "Boundary IDs have to be one-based. Yours is " << b
1721  << "\n";
1722  throw OomphLibError(error_message.str(),
1725  }
1726  }
1727  }
1728 
1729 
1730  // Store the internal boundary
1731  Internal_surface_pt = internal_surface_pt;
1732 
1733  // Setup reverse lookup scheme
1734  {
1735  unsigned n = Internal_surface_pt.size();
1736  for (unsigned i = 0; i < n; i++)
1737  {
1738  unsigned n_facet = Internal_surface_pt[i]->nfacet();
1739  for (unsigned f = 0; f < n_facet; f++)
1740  {
1741  unsigned b = Internal_surface_pt[i]->one_based_facet_boundary_id(f);
1742  if (b != 0)
1743  {
1745  Tet_mesh_facet_pt[b - 1] = Internal_surface_pt[i]->facet_pt(f);
1746  }
1747  else
1748  {
1749  std::ostringstream error_message;
1750  error_message << "Boundary IDs have to be one-based. Yours is "
1751  << b << "\n";
1752  throw OomphLibError(error_message.str(),
1755  }
1756  }
1757  }
1758  }
1759 
1760  // Build scaffold
1761  GmshTetScaffoldMesh* tmp_scaffold_mesh_pt =
1762  new GmshTetScaffoldMesh(Gmsh_parameters_pt, use_mesh_grading_from_file);
1763 
1764  // Convert mesh from scaffold to actual mesh
1765  build_from_scaffold(tmp_scaffold_mesh_pt, time_stepper_pt);
1766 
1767  // Kill the scaffold
1768  delete tmp_scaffold_mesh_pt;
1769  tmp_scaffold_mesh_pt = 0;
1770 
1771  // Setup boundary coordinates
1772  unsigned nb = nboundary();
1773  for (unsigned b = 0; b < nb; b++)
1774  {
1775  bool switch_normal = false;
1776  setup_boundary_coordinates<ELEMENT>(b, switch_normal);
1777  }
1778 
1779  // Now snap onto geometric objects associated with triangular facets
1780  // (if any!)
1782  }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
Scalar * b
Definition: benchVecAdd.cpp:17
Vector< TetMeshFacetedSurface * > & internal_surface_pt()
Internal boundaries.
Definition: gmsh_tet_mesh.template.h:83
TetMeshFacetedClosedSurface *& outer_boundary_pt()
Outer boundary.
Definition: gmsh_tet_mesh.template.h:77
void build_from_scaffold(GmshTetScaffoldMesh *tmp_scaffold_mesh_pt, TimeStepper *time_stepper_pt)
Build unstructured tet gmesh mesh based on output from scaffold.
Definition: gmsh_tet_mesh.template.h:1792
unsigned nboundary() const
Return number of boundaries.
Definition: mesh.h:827
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
std::map< unsigned, TetMeshFacetedSurface * > Tet_mesh_faceted_surface_pt
Definition: tet_mesh.h:1045
Vector< TetMeshFacetedSurface * > Internal_surface_pt
Vector to faceted surfaces that define internal boundaries.
Definition: tet_mesh.h:1041
std::map< unsigned, TetMeshFacet * > Tet_mesh_facet_pt
Definition: tet_mesh.h:1049
TetMeshFacetedClosedSurface * Outer_boundary_pt
Faceted surface that defines outer boundaries.
Definition: tet_mesh.h:1038
unsigned nfacet() const
Number of facets.
Definition: tet_mesh.h:325
unsigned one_based_facet_boundary_id(const unsigned &j) const
One-based boundary id of j-th facet.
Definition: tet_mesh.h:331
TetMeshFacet * facet_pt(const unsigned &j) const
Pointer to j-th facet.
Definition: tet_mesh.h:373
int nb
Definition: level2_impl.h:286

References b, oomph::GmshTetMesh< ELEMENT >::build_from_scaffold(), f(), oomph::TetMeshFacetedSurface::facet_pt(), oomph::GmshTetMesh< ELEMENT >::Gmsh_parameters_pt, i, oomph::TetMeshBase::Internal_surface_pt, oomph::GmshParameters::internal_surface_pt(), n, nb, oomph::Mesh::nboundary(), oomph::TetMeshFacetedSurface::nfacet(), oomph::TetMeshFacetedSurface::one_based_facet_boundary_id(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::TetMeshBase::Outer_boundary_pt, oomph::GmshParameters::outer_boundary_pt(), oomph::TetMeshBase::snap_nodes_onto_geometric_objects(), oomph::TetMeshBase::Tet_mesh_facet_pt, oomph::TetMeshBase::Tet_mesh_faceted_surface_pt, and oomph::TetMeshBase::Time_stepper_pt.

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

Member Data Documentation

◆ Gmsh_parameters_pt

template<class ELEMENT >
GmshParameters* oomph::GmshTetMesh< ELEMENT >::Gmsh_parameters_pt
protected

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