GetFEM  5.4.3
getfem::mesh Class Reference

Describe a mesh (collection of convexes (elements) and points). More...

#include <getfem_mesh.h>

Inherits bgeot::basic_mesh, getfem::context_dependencies, dal::static_stored_object, and std::enable_shared_from_this< mesh >.

Inherited by getfem::global_mesh_for_mesh_level_set, getfem::mesh_cache_for_Bank_basic_refine_convex, getfem::mesh_cache_for_Bank_build_green_simplexes, and getfem::torus_mesh.

Public Member Functions

 mesh (const std::string name="")
 Constructor.
 
void update_from_context () const
 this function has to be defined and should update the object when the context is modified.
 
ref_mesh_face_pt_ct points_of_face_of_convex (size_type ic, short_type f) const
 Return a (pseudo)container of points of face of a given convex.
 
ref_convex convex (size_type ic) const
 return a bgeot::convex object for the convex number ic.
 
size_type nb_points () const
 Give the number of geometrical nodes in the mesh.
 
const dal::bit_vector & points_index () const
 Return the points index.
 
void sup_point (size_type i)
 Delete the point of index i from the mesh if it is not linked to a convex.
 
void swap_points (size_type i, size_type j)
 Swap the indexes of points of index i and j in the whole structure.
 
size_type search_point (const base_node &pt, const scalar_type radius=0) const
 Search a point given its coordinates. More...
 
gmm::uint64_type convex_version_number (size_type ic) const
 return the version number of the convex ic.
 
template<class ITER >
size_type add_convex (bgeot::pgeometric_trans pgt, ITER ipts)
 Add a convex to the mesh. More...
 
template<class ITER >
size_type add_convex_by_points (bgeot::pgeometric_trans pgt, ITER ipts, const scalar_type tol=scalar_type(0))
 Add a convex to the mesh, given a geometric transformation and a list of point coordinates. More...
 
template<class ITER >
size_type add_simplex (dim_type di, ITER ipts)
 Add a simplex to the mesh, given its dimension and point numbers.
 
template<class ITER >
size_type add_simplex_by_points (dim_type dim, ITER ipts)
 Add a simplex to the mesh, given its dimension and point coordinates. More...
 
size_type add_segment (size_type a, size_type b)
 Add a segment to the mesh, given the point id of its vertices.
 
size_type add_segment_by_points (const base_node &pt1, const base_node &pt2)
 Add a segment to the mesh, given the coordinates of its vertices.
 
size_type add_triangle (size_type a, size_type b, size_type c)
 Add a triangle to the mesh, given the point id of its vertices.
 
size_type add_triangle_by_points (const base_node &p1, const base_node &p2, const base_node &p3)
 Add a triangle to the mesh, given the coordinates of its vertices.
 
size_type add_tetrahedron (size_type a, size_type b, size_type c, size_type d)
 Add a tetrahedron to the mesh, given the point id of its vertices.
 
size_type add_tetrahedron_by_points (const base_node &p1, const base_node &p2, const base_node &p3, const base_node &p4)
 Add a tetrahedron to the mesh, given the coordinates of its vertices.
 
size_type add_pyramid (size_type a, size_type b, size_type c, size_type d, size_type e)
 Add a pyramid to the mesh, given the point id of its vertices.
 
template<class ITER >
size_type add_parallelepiped (dim_type di, const ITER &ipts)
 Add a parallelepiped to the mesh. More...
 
template<class ITER >
size_type add_parallelepiped_by_points (dim_type di, const ITER &ps)
 Add a parallelepiped to the mesh. More...
 
template<class ITER >
size_type add_prism (dim_type di, const ITER &ipts)
 Add a prism to the mesh. More...
 
template<class ITER >
size_type add_prism_by_points (dim_type di, const ITER &ps)
 Add a prism to the mesh. More...
 
void merge_convexes_from_mesh (const mesh &m, size_type rg=size_type(-1), scalar_type tol=scalar_type(0))
 Merge all convexes from a another mesh, possibly restricted to a mesh region.
 
void sup_convex (size_type ic, bool sup_points=false)
 Delete the convex of index ic from the mesh.
 
void swap_convex (size_type i, size_type j)
 Swap the indexes of the convex of indexes i and j in the whole structure.
 
base_small_vector normal_of_face_of_convex (size_type ic, short_type f, const base_node &pt) const
 Return the normal of the given convex face, evaluated at the point pt. More...
 
base_matrix local_basis_of_face_of_convex (size_type ic, short_type f, const base_node &pt) const
 Return a local basis for the convex face. More...
 
base_matrix local_basis_of_face_of_convex (size_type ic, short_type f, size_type n) const
 Return a local basis for the convex face. More...
 
scalar_type convex_quality_estimate (size_type ic) const
 Return an estimate of the convex quality (0 <= Q <= 1).
 
scalar_type convex_area_estimate (size_type ic, size_type degree=2) const
 Return an estimate of the convex area. More...
 
virtual scalar_type convex_radius_estimate (size_type ic) const
 Return an estimate of the convex largest dimension. More...
 
scalar_type minimal_convex_radius_estimate () const
 Return an estimate of the convex smallest dimension. More...
 
scalar_type maximal_convex_radius_estimate () const
 Return an estimate of the convex largest dimension. More...
 
void translation (const base_small_vector &)
 Apply the given translation to each mesh node.
 
void transformation (const base_matrix &)
 apply the given matrix transformation to each mesh node.
 
void bounding_box (base_node &Pmin, base_node &Pmax) const
 Return the bounding box [Pmin - Pmax] of the mesh.
 
const mesh_region region (size_type id) const
 Return the region of index 'id'. More...
 
bool has_region (size_type s) const
 Return true if the region of index 's' exists in the mesh.
 
void sup_region (size_type b)
 Remove the region of index b.
 
void sup_convex_from_regions (size_type cv)
 Remove all references to a convex from all regions stored in the mesh. More...
 
void optimize_structure (bool with_renumbering=true)
 Pack the mesh : renumber convexes and nodes such that there is no holes in their numbering. More...
 
const std::vector< size_type > & cuthill_mckee_ordering () const
 Return the list of convex IDs for a Cuthill-McKee ordering.
 
void clear ()
 Erase the mesh.
 
void write_to_file (const std::string &name) const
 Write the mesh to a file. More...
 
void write_to_file (std::ostream &ost) const
 Write the mesh to a text stream. More...
 
void read_from_file (const std::string &name)
 Load the mesh from a file. More...
 
void read_from_file (std::istream &ist)
 Load the mesh from a text stream. More...
 
void copy_from (const mesh &m)
 Clone a mesh.
 
void Bank_refine (dal::bit_vector)
 Use the Bank strategy to refine some convexes.
 
- Public Member Functions inherited from getfem::context_dependencies
bool context_check () const
 return true if update_from_context was called
 

Detailed Description

Describe a mesh (collection of convexes (elements) and points).

Note that mesh object have no copy constructor, use mesh::copy_from instead. This class inherits from bgeot::mesh<base_node> and bgeot::mesh_structure. Compared to bgeot::mesh, It provides some additional methods for convenience (add_simplex_by_points etc...), and it is able to send "messages" to objects that depend on it (for example getfem::mesh_fem) when something in the mesh has been modified. For example, when a convex is removed from the mesh, the mesh_fem that uses this mesh automagically removes any finite element on the convex, and renumbers the dof.

Points and convex numbering:

The numbering of points and convexes is not dynamical, which means that when a point or a convex has been removed from the mesh, there might be holes in the numbering. To loop over the set of valid points in the mesh, one should use

for (dal::bv_visitor ip(mesh.points_index()); !ip.finished(); ++ip) {
...
}
mesh(const std::string name="")
Constructor.
Definition: getfem_mesh.cc:133

instead of

for (size_type ip = 0; ip < mesh.nb_points(); ++ip) {
}
size_t size_type
used as the common size type in the library
Definition: bgeot_poly.h:49

(same thing for the convexes, always use convex_index()).

Definition at line 95 of file getfem_mesh.h.

Member Function Documentation

◆ search_point()

size_type getfem::mesh::search_point ( const base_node &  pt,
const scalar_type  radius = 0 
) const
inline

Search a point given its coordinates.

Parameters
ptthe point that is searched.
Returns
the point index if pt was found in (or approximatively in) the mesh nodes, size_type(-1) if not found.

Definition at line 209 of file getfem_mesh.h.

◆ add_convex()

template<class ITER >
size_type getfem::mesh::add_convex ( bgeot::pgeometric_trans  pgt,
ITER  ipts 
)
inline

Add a convex to the mesh.

This methods assume that the convex nodes have already been added to the mesh.

Parameters
pgtthe geometric transformation of the convex.
iptsan iterator to a set of point index.
Returns
the number of the new convex.

Definition at line 226 of file getfem_mesh.h.

◆ normal_of_face_of_convex()

base_small_vector getfem::mesh::normal_of_face_of_convex ( size_type  ic,
short_type  f,
const base_node &  pt 
) const

Return the normal of the given convex face, evaluated at the point pt.

Parameters
icthe convex number.
fthe face number.
ptthe point at which the normal is taken, in the reference convex. This point should of course be on the correspounding face of the reference convex, except if the geometric transformation is linear: in that case, the normal constant.
Returns
the face normal.

Definition at line 384 of file getfem_mesh.cc.

◆ local_basis_of_face_of_convex() [1/2]

base_matrix getfem::mesh::local_basis_of_face_of_convex ( size_type  ic,
short_type  f,
const base_node &  pt 
) const

Return a local basis for the convex face.

Parameters
icthe convex number.
fthe face number.
ptthe point coordinates.
Returns
a matrix with the normal vector in its first column, and the tangent vectors in the other columns.

Definition at line 421 of file getfem_mesh.cc.

◆ local_basis_of_face_of_convex() [2/2]

base_matrix getfem::mesh::local_basis_of_face_of_convex ( size_type  ic,
short_type  f,
size_type  n 
) const

Return a local basis for the convex face.

Parameters
icthe convex number.
fthe face number.
nlocal point index in the reference convex, at which the basis will be evaluated – should be faster than the function above since it uses a bgeot::geotrans_precomp .
Returns
a matrix with the normal vector in its first column, and the tangent vectors in the other columns.

Definition at line 430 of file getfem_mesh.cc.

◆ convex_area_estimate()

scalar_type getfem::mesh::convex_area_estimate ( size_type  ic,
size_type  degree = 2 
) const

Return an estimate of the convex area.

Parameters
icthe convex number
degreethe degree of the approximation integration method used to compute the area.

Definition at line 442 of file getfem_mesh.cc.

◆ convex_radius_estimate()

scalar_type getfem::mesh::convex_radius_estimate ( size_type  ic) const
virtual

Return an estimate of the convex largest dimension.

See also
getfem::convex_quality_estimate

Reimplemented in getfem::torus_mesh.

Definition at line 461 of file getfem_mesh.cc.

◆ minimal_convex_radius_estimate()

scalar_type getfem::mesh::minimal_convex_radius_estimate ( ) const

Return an estimate of the convex smallest dimension.

See also
getfem::convex_radius_estimate

Definition at line 467 of file getfem_mesh.cc.

◆ maximal_convex_radius_estimate()

scalar_type getfem::mesh::maximal_convex_radius_estimate ( ) const

Return an estimate of the convex largest dimension.

See also
getfem::convex_radius_estimate

Definition at line 476 of file getfem_mesh.cc.

◆ region()

const mesh_region getfem::mesh::region ( size_type  id) const
inline

Return the region of index 'id'.

Regions stored in mesh are updated when the mesh is modified (i.e. when a convex is removed from the mesh, it is also removed from all regions of the mesh.

Definition at line 421 of file getfem_mesh.h.

◆ sup_convex_from_regions()

void getfem::mesh::sup_convex_from_regions ( size_type  cv)

Remove all references to a convex from all regions stored in the mesh.

Parameters
cvthe convex number.

Definition at line 42 of file getfem_mesh.cc.

◆ optimize_structure()

void getfem::mesh::optimize_structure ( bool  with_renumbering = true)

Pack the mesh : renumber convexes and nodes such that there is no holes in their numbering.

Do NOT do the Cuthill-McKee.

Definition at line 223 of file getfem_mesh.cc.

◆ write_to_file() [1/2]

void getfem::mesh::write_to_file ( const std::string &  name) const

Write the mesh to a file.

The format is getfem-specific.

Parameters
namethe file name.

Definition at line 709 of file getfem_mesh.cc.

◆ write_to_file() [2/2]

void getfem::mesh::write_to_file ( std::ostream &  ost) const

Write the mesh to a text stream.

Parameters
ostthe stream.

Definition at line 685 of file getfem_mesh.cc.

◆ read_from_file() [1/2]

void getfem::mesh::read_from_file ( const std::string &  name)

Load the mesh from a file.

Parameters
namethe file name.
See also
getfem::import_mesh.

Definition at line 655 of file getfem_mesh.cc.

◆ read_from_file() [2/2]

void getfem::mesh::read_from_file ( std::istream &  ist)

Load the mesh from a text stream.

Parameters
istthe text stream.
See also
getfem::import_mesh.

Definition at line 511 of file getfem_mesh.cc.


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