oomph::TriangleMeshBase Class Reference

#include <triangle_mesh.h>

+ Inheritance diagram for oomph::TriangleMeshBase:

Public Member Functions

 TriangleMeshBase ()
 Constructor. More...
 
 TriangleMeshBase (const TriangleMeshBase &node)=delete
 Broken copy constructor. More...
 
virtual ~TriangleMeshBase ()
 Broken assignment operator. More...
 
void setup_boundary_element_info ()
 
void setup_boundary_element_info (std::ostream &outfile)
 
virtual void load_balance (const Vector< unsigned > &target_domain_for_local_non_halo_element)
 Virtual function to perform the load balance rutines. More...
 
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...
 
- Public Member Functions inherited from oomph::UnstructuredTwoDMeshGeometryBase
 UnstructuredTwoDMeshGeometryBase ()
 Empty constructor. More...
 
 UnstructuredTwoDMeshGeometryBase (const UnstructuredTwoDMeshGeometryBase &dummy)=delete
 Broken copy constructor. More...
 
void operator= (const UnstructuredTwoDMeshGeometryBase &)=delete
 Broken assignment operator. More...
 
 ~UnstructuredTwoDMeshGeometryBase ()
 Empty destructor. More...
 
unsigned nregion ()
 Return the number of regions specified by attributes. More...
 
unsigned nregion_element (const unsigned &i)
 Return the number of elements in the i-th region. More...
 
FiniteElementregion_element_pt (const unsigned &i, const unsigned &e)
 Return the e-th element in the i-th region. More...
 
unsigned nregion_attribute ()
 Return the number of attributes used in the mesh. More...
 
double region_attribute (const unsigned &i)
 Return the attribute associated with region i. More...
 
GeomObjectboundary_geom_object_pt (const unsigned &b)
 
std::map< unsigned, GeomObject * > & boundary_geom_object_pt ()
 Return direct access to the geometric object storage. More...
 
std::map< unsigned, Vector< double > > & boundary_coordinate_limits ()
 
Vector< double > & boundary_coordinate_limits (const unsigned &b)
 
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...
 
TriangleMeshPolyLineboundary_polyline_pt (const unsigned &b)
 
std::map< unsigned, std::set< Node * > > & nodes_on_boundary_pt ()
 
const bool get_connected_vertex_number_on_destination_polyline (TriangleMeshPolyLine *dst_polyline_pt, Vector< double > &vertex_coordinates, unsigned &vertex_number)
 
void check_contiguousness_on_polylines_helper (Vector< TriangleMeshPolyLine * > &polylines_pt, unsigned &index)
 
void check_contiguousness_on_polylines_helper (Vector< TriangleMeshPolyLine * > &polylines_pt, unsigned &index_halo_start, unsigned &index_halo_end)
 
bool is_point_inside_polygon_helper (Vector< Vector< double >> polygon_vertices, Vector< double > point)
 Helper function that checks if a given point is inside a polygon. More...
 
void enable_automatic_creation_of_vertices_on_boundaries ()
 
void disable_automatic_creation_of_vertices_on_boundaries ()
 
bool is_automatic_creation_of_vertices_on_boundaries_allowed ()
 
template<class ELEMENT >
void setup_boundary_coordinates (const unsigned &b)
 
template<class ELEMENT >
void setup_boundary_coordinates (const unsigned &b, std::ofstream &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)
 
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...
 

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::UnstructuredTwoDMeshGeometryBase
static bool Suppress_warning_about_regions_and_boundaries
 Public static flag to suppress warning; defaults to false. More...
 
- 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::UnstructuredTwoDMeshGeometryBase
void snap_nodes_onto_geometric_objects ()
 
void copy_connection_information (TriangleMeshCurveSection *input_curve_pt, TriangleMeshCurveSection *output_curve_pt)
 
void copy_connection_information_to_sub_polylines (TriangleMeshCurveSection *input_curve_pt, TriangleMeshCurveSection *output_curve_pt)
 
- 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)
 
- Protected Attributes inherited from oomph::UnstructuredTwoDMeshGeometryBase
bool Allow_automatic_creation_of_vertices_on_boundaries
 
std::map< unsigned, Vector< FiniteElement * > > Region_element_pt
 
Vector< doubleRegion_attribute
 Vector of attributes associated with the elements in each region. More...
 
std::map< unsigned, GeomObject * > Boundary_geom_object_pt
 Storage for the geometric objects associated with any boundaries. More...
 
std::map< unsigned, Vector< double > > Boundary_coordinate_limits
 
Vector< TriangleMeshPolygon * > Outer_boundary_pt
 Polygon that defines outer boundaries. More...
 
Vector< TriangleMeshPolygon * > Internal_polygon_pt
 Vector of polygons that define internal polygons. More...
 
Vector< TriangleMeshOpenCurve * > Internal_open_curve_pt
 Vector of open polylines that define internal curves. More...
 
Vector< Vector< double > > Extra_holes_coordinates
 Storage for extra coordinates for holes. More...
 
std::map< unsigned, Vector< double > > Regions_coordinates
 
std::map< unsigned, TriangleMeshCurveSection * > Boundary_curve_section_pt
 
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
 Storage for the face index adjacent to a boundary in a particular region. More...
 
std::map< unsigned, Vector< std::pair< double, double > > > Polygonal_vertex_arclength_info
 
std::map< unsigned, std::set< Node * > > Nodes_on_boundary_pt
 
std::set< TriangleMeshCurveSection * > Free_curve_section_pt
 
std::set< TriangleMeshPolygon * > Free_polygon_pt
 
std::set< TriangleMeshOpenCurve * > Free_open_curve_pt
 
- 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
 

Detailed Description

Base class for triangle meshes (meshes made of 2D triangle elements). Note: we choose to template TriangleMeshBase here because certain functions in UnstructuredTwoDMeshGeometryBase need template parameters and it's much cleaner simply to template the entire class

Constructor & Destructor Documentation

◆ TriangleMeshBase() [1/2]

oomph::TriangleMeshBase::TriangleMeshBase ( )
inline

Constructor.

56  {
57 #ifdef OOMPH_HAS_TRIANGLE_LIB
58  // Initialise the TriangulateIO Data structure
59  TriangleHelper::initialise_triangulateio(Triangulateio);
60 
61  // Enable triangulateio specific parts for dump/restart by default.
62  Use_triangulateio_restart = true;
63 #endif
64  }

◆ TriangleMeshBase() [2/2]

oomph::TriangleMeshBase::TriangleMeshBase ( const TriangleMeshBase node)
delete

Broken copy constructor.

◆ ~TriangleMeshBase()

virtual oomph::TriangleMeshBase::~TriangleMeshBase ( )
inlinevirtual

Broken assignment operator.

Destructor (empty)

79  {
80 #ifdef OOMPH_HAS_TRIANGLE_LIB
81  // Clear the triangulate data structure
82  TriangleHelper::clear_triangulateio(Triangulateio);
83 #endif
84  }

Member Function Documentation

◆ load_balance()

virtual void oomph::TriangleMeshBase::load_balance ( const Vector< unsigned > &  target_domain_for_local_non_halo_element)
inlinevirtual

Virtual function to perform the load balance rutines.

232  {
233  std::ostringstream error_stream;
234  error_stream << "Empty default load balancing function called.\n";
235  error_stream << "This should be overloaded in a specific TriangleMesh\n";
236  throw OomphLibError(error_stream.str(),
237  "TriangleMeshBase::load_balance()",
239  }
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61

References OOMPH_EXCEPTION_LOCATION.

◆ reset_boundary_element_info()

virtual void oomph::TriangleMeshBase::reset_boundary_element_info ( Vector< unsigned > &  ntmp_boundary_elements,
Vector< Vector< unsigned >> &  ntmp_boundary_elements_in_region,
Vector< FiniteElement * > &  deleted_elements 
)
inlinevirtual

Virtual function to perform the reset boundary elements info rutines.

Reimplemented from oomph::Mesh.

246  {
247  std::ostringstream error_stream;
248  error_stream << "Empty default reset boundary element info function"
249  << "called.\n";
250  error_stream << "This should be overloaded in a specific "
251  << "TriangleMesh\n";
252  throw OomphLibError(error_stream.str(),
253  "TriangleMeshBase::reset_boundary_element_info()",
255  }

References OOMPH_EXCEPTION_LOCATION.

◆ setup_boundary_element_info() [1/2]

void oomph::TriangleMeshBase::setup_boundary_element_info ( )
inlinevirtual

Setup lookup schemes which establish whic elements are located next to mesh's boundaries (wrapper to suppress doc).

Reimplemented from oomph::Mesh.

89  {
90  std::ofstream outfile;
92  }
void setup_boundary_element_info()
Definition: generic/triangle_mesh.h:88

◆ setup_boundary_element_info() [2/2]

void oomph::TriangleMeshBase::setup_boundary_element_info ( std::ostream &  outfile)
virtual

Setup lookup schemes which establish which elements are located next to mesh's boundaries. Doc in outfile (if it's open).

Setup lookup schemes which establish which elements are located next to which boundaries (Doc to outfile if it's open).

Reimplemented from oomph::Mesh.

401  {
402  // Should we document the output here
403  bool doc = false;
404 
405  if (outfile) doc = true;
406 
407  // Number of boundaries
408  unsigned nbound = nboundary();
409 
410  // Wipe/allocate storage for arrays
411  Boundary_element_pt.clear();
412  Face_index_at_boundary.clear();
413  Boundary_element_pt.resize(nbound);
414  Face_index_at_boundary.resize(nbound);
415 
416  // Temporary vector of vectors of pointers to elements on the boundaries:
417  // This is a vector to ensure that order is strictly preserved
418  Vector<Vector<FiniteElement*>> vector_of_boundary_element_pt;
419  vector_of_boundary_element_pt.resize(nbound);
420 
421  // Matrix map for working out the fixed face for elements on boundary
422  MapMatrixMixed<unsigned, FiniteElement*, int> face_identifier;
423 
424  // Loop over elements
425  //-------------------
426  unsigned nel = nelement();
427 
428  // Get pointer to vector of boundaries that the
429  // node lives on
430  Vector<std::set<unsigned>*> boundaries_pt(3, 0);
431 
432  // Data needed to deal with edges through the
433  // interior of the domain
434  std::map<Edge, unsigned> edge_count;
435  std::map<Edge, TriangleBoundaryHelper::BCInfo> edge_bcinfo;
436  std::map<Edge, TriangleBoundaryHelper::BCInfo> face_info;
437  MapMatrixMixed<unsigned, FiniteElement*, int> face_count;
438  Vector<unsigned> bonus(nbound);
439 
440  // When using internal boundaries, an edge can be related to more than
441  // one element (because of both sides of the internal boundaries)
442  std::map<Edge, Vector<TriangleBoundaryHelper::BCInfo>> edge_internal_bnd;
443 
444  for (unsigned e = 0; e < nel; e++)
445  {
446  // Get pointer to element
447  FiniteElement* fe_pt = finite_element_pt(e);
448 
449  if (doc)
450  {
451  outfile << "Element: " << e << " " << fe_pt << std::endl;
452  }
453 
454  // Only include 2D elements! Some meshes contain interface elements too.
455  if (fe_pt->dim() == 2)
456  {
457  // Loop over the element's nodes and find out which boundaries they're
458  // on
459  // ----------------------------------------------------------------------
460 
461  // We need only loop over the corner nodes
462  for (unsigned i = 0; i < 3; i++)
463  {
464  fe_pt->node_pt(i)->get_boundaries_pt(boundaries_pt[i]);
465  }
466 
467  // Find the common boundaries of each edge
468  Vector<std::set<unsigned>> edge_boundary(3);
469 
470  // Edge 0 connects points 1 and 2
471  //-----------------------------
472 
473  if (boundaries_pt[1] && boundaries_pt[2])
474  {
475  // Create the corresponding edge
476  Edge edge0(fe_pt->node_pt(1), fe_pt->node_pt(2));
477 
478  // Update infos about this edge
479  TriangleBoundaryHelper::BCInfo info;
480  info.Face_id = 0;
481  info.FE_pt = fe_pt;
482 
483  std::set_intersection(boundaries_pt[1]->begin(),
484  boundaries_pt[1]->end(),
485  boundaries_pt[2]->begin(),
486  boundaries_pt[2]->end(),
487  std::insert_iterator<std::set<unsigned>>(
488  edge_boundary[0], edge_boundary[0].begin()));
489  std::set<unsigned>::iterator it0 = edge_boundary[0].begin();
490 
491  // Edge does exist:
492  if (edge_boundary[0].size() > 0)
493  {
494  info.Boundary = *it0;
495 
496  // How many times this edge has been visited
497  edge_count[edge0]++;
498 
499  // Update edge_bcinfo
500  edge_bcinfo.insert(std::make_pair(edge0, info));
501 
502  // ... and also update the info associated with internal bnd
503  edge_internal_bnd[edge0].push_back(info);
504  }
505  }
506 
507  // Edge 1 connects points 0 and 2
508  //-----------------------------
509 
510  if (boundaries_pt[0] && boundaries_pt[2])
511  {
512  std::set_intersection(boundaries_pt[0]->begin(),
513  boundaries_pt[0]->end(),
514  boundaries_pt[2]->begin(),
515  boundaries_pt[2]->end(),
516  std::insert_iterator<std::set<unsigned>>(
517  edge_boundary[1], edge_boundary[1].begin()));
518 
519  // Create the corresponding edge
520  Edge edge1(fe_pt->node_pt(0), fe_pt->node_pt(2));
521 
522  // Update infos about this edge
523  TriangleBoundaryHelper::BCInfo info;
524  info.Face_id = 1;
525  info.FE_pt = fe_pt;
526  std::set<unsigned>::iterator it1 = edge_boundary[1].begin();
527 
528  // Edge does exist:
529  if (edge_boundary[1].size() > 0)
530  {
531  info.Boundary = *it1;
532 
533  // How many times this edge has been visited
534  edge_count[edge1]++;
535 
536  // Update edge_bcinfo
537  edge_bcinfo.insert(std::make_pair(edge1, info));
538 
539  // ... and also update the info associated with internal bnd
540  edge_internal_bnd[edge1].push_back(info);
541  }
542  }
543 
544  // Edge 2 connects points 0 and 1
545  //-----------------------------
546 
547  if (boundaries_pt[0] && boundaries_pt[1])
548  {
549  std::set_intersection(boundaries_pt[0]->begin(),
550  boundaries_pt[0]->end(),
551  boundaries_pt[1]->begin(),
552  boundaries_pt[1]->end(),
553  std::insert_iterator<std::set<unsigned>>(
554  edge_boundary[2], edge_boundary[2].begin()));
555 
556  // Create the corresponding edge
557  Edge edge2(fe_pt->node_pt(0), fe_pt->node_pt(1));
558 
559  // Update infos about this edge
560  TriangleBoundaryHelper::BCInfo info;
561  info.Face_id = 2;
562  info.FE_pt = fe_pt;
563  std::set<unsigned>::iterator it2 = edge_boundary[2].begin();
564 
565  // Edge does exist:
566  if (edge_boundary[2].size() > 0)
567  {
568  info.Boundary = *it2;
569 
570  // How many times this edge has been visited
571  edge_count[edge2]++;
572 
573  // Update edge_bcinfo
574  edge_bcinfo.insert(std::make_pair(edge2, info));
575 
576  // ... and also update the info associated with internal bnd
577  edge_internal_bnd[edge2].push_back(info);
578  }
579  }
580 
581 
582 #ifdef PARANOID
583 
584  // Check if edge is associated with multiple boundaries
585 
586  // We now know whether any edges lay on the boundaries
587  for (unsigned i = 0; i < 3; i++)
588  {
589  // How many boundaries are there
590  unsigned count = 0;
591 
592  // Loop over all the members of the set and add to the count
593  // and set the boundary
594  for (std::set<unsigned>::iterator it = edge_boundary[i].begin();
595  it != edge_boundary[i].end();
596  ++it)
597  {
598  ++count;
599  }
600 
601  // If we're on more than one boundary, this is weird, so die
602  if (count > 1)
603  {
604  std::ostringstream error_stream;
605  error_stream << "Edge " << i << " is located on " << count
606  << " boundaries.\n";
607  error_stream << "This is rather strange, so I'm going to die\n";
608  throw OomphLibError(error_stream.str(),
611  }
612  }
613 
614 #endif
615 
616  // Now we set the pointers to the boundary sets to zero
617  for (unsigned i = 0; i < 3; i++)
618  {
619  boundaries_pt[i] = 0;
620  }
621  }
622  } // end of loop over all elements
623 
624  // Loop over all edges that are located on a boundary
625  typedef std::map<Edge, TriangleBoundaryHelper::BCInfo>::iterator ITE;
626  for (ITE it = edge_bcinfo.begin(); it != edge_bcinfo.end(); it++)
627  {
628  Edge current_edge = it->first;
629  unsigned bound = it->second.Boundary;
630 
631  // If the edge has been visited only once
632  if (edge_count[current_edge] == 1)
633  {
634  // Count the edges that are on the same element and on the same boundary
635  face_count(static_cast<unsigned>(bound), it->second.FE_pt) =
636  face_count(static_cast<unsigned>(bound), it->second.FE_pt) + 1;
637 
638  // If such edges exist, let store the corresponding element
639  if (face_count(bound, it->second.FE_pt) > 1)
640  {
641  // Update edge's infos
642  TriangleBoundaryHelper::BCInfo info;
643  info.Face_id = it->second.Face_id;
644  info.FE_pt = it->second.FE_pt;
645  info.Boundary = it->second.Boundary;
646 
647  // Add it to FIinfo, that stores infos of problematic elements
648  face_info.insert(std::make_pair(current_edge, info));
649 
650  // How many edges on which boundary have to be added
651  bonus[bound]++;
652  }
653  else
654  {
655  // Add element and face to the appropriate vectors
656  // Does the pointer already exits in the vector
657  Vector<FiniteElement*>::iterator b_el_it = std::find(
658  vector_of_boundary_element_pt[static_cast<unsigned>(bound)].begin(),
659  vector_of_boundary_element_pt[static_cast<unsigned>(bound)].end(),
660  it->second.FE_pt);
661 
662  // Only insert if we have not found it (i.e. got to the end)
663  if (b_el_it ==
664  vector_of_boundary_element_pt[static_cast<unsigned>(bound)].end())
665  {
666  vector_of_boundary_element_pt[static_cast<unsigned>(bound)]
667  .push_back(it->second.FE_pt);
668  }
669 
670  // set_of_boundary_element_pt[static_cast<unsigned>(bound)].insert(
671  // it->second.FE_pt);
672  face_identifier(static_cast<unsigned>(bound), it->second.FE_pt) =
673  it->second.Face_id;
674  }
675  }
676 
677  } // End of "adding-boundaries"-loop
678 
679 
680  // Now copy everything across into permanent arrays
681  //-------------------------------------------------
682 
683  // Loop over boundaries
684  for (unsigned i = 0; i < nbound; i++)
685  {
686  // Number of elements on this boundary that have to be added
687  // in addition to other elements
688  unsigned bonus1 = bonus[i];
689 
690  // Number of elements on this boundary
691  unsigned nel = vector_of_boundary_element_pt[i].size() + bonus1;
692 
693  // Allocate storage for the coordinate identifiers
694  Face_index_at_boundary[i].resize(nel);
695 
696  unsigned e_count = 0;
697  typedef Vector<FiniteElement*>::iterator IT;
698  for (IT it = vector_of_boundary_element_pt[i].begin();
699  it != vector_of_boundary_element_pt[i].end();
700  it++)
701  {
702  // Recover pointer to element
703  FiniteElement* fe_pt = *it;
704 
705  // Add to permanent storage
706  Boundary_element_pt[i].push_back(fe_pt);
707 
708  Face_index_at_boundary[i][e_count] = face_identifier(i, fe_pt);
709 
710  // Increment counter
711  e_count++;
712  }
713  // We add the elements that have two or more edges on this boundary
714  for (ITE itt = face_info.begin(); itt != face_info.end(); itt++)
715  {
716  if (itt->second.Boundary == i)
717  {
718  // Add to permanent storage
719  Boundary_element_pt[i].push_back(itt->second.FE_pt);
720 
721  Face_index_at_boundary[i][e_count] = itt->second.Face_id;
722 
723  e_count++;
724  }
725  }
726 
727  } // End of loop over boundaries
728 
729  // Doc?
730  //-----
731  if (doc)
732  {
733  // Loop over boundaries
734  for (unsigned i = 0; i < nbound; i++)
735  {
736  unsigned nel = Boundary_element_pt[i].size();
737  outfile << "Boundary: " << i << " is adjacent to " << nel << " elements"
738  << std::endl;
739 
740  // Loop over elements on given boundary
741  for (unsigned e = 0; e < nel; e++)
742  {
743  FiniteElement* fe_pt = Boundary_element_pt[i][e];
744  outfile << "Boundary element:" << fe_pt
745  << " Face index of boundary is "
746  << Face_index_at_boundary[i][e] << std::endl;
747  }
748  }
749  }
750 
751  // Lookup scheme has now been setup yet
753  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
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
unsigned nboundary() const
Return number of boundaries.
Definition: mesh.h:827
unsigned long nelement() const
Return number of elements in the mesh.
Definition: mesh.h:590
static constexpr lastp1_t end
Definition: IndexedViewHelper.h:79
int info
Definition: level2_cplx_impl.h:39
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86

References oomph::Mesh::Boundary_element_pt, oomph::FiniteElement::dim(), e(), Eigen::placeholders::end, oomph::Mesh::Face_index_at_boundary, oomph::Mesh::finite_element_pt(), oomph::Node::get_boundaries_pt(), i, info, oomph::Mesh::Lookup_for_elements_next_boundary_is_setup, oomph::Mesh::nboundary(), oomph::Mesh::nelement(), oomph::FiniteElement::node_pt(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, and size.


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