37 #ifndef GETFEM_MESH_H__
38 #define GETFEM_MESH_H__
52 gmm::uint64_type APIDECL act_counter();
54 class integration_method;
55 typedef std::shared_ptr<const integration_method> pintegration_method;
94 class APIDECL
mesh :
public bgeot::basic_mesh,
97 public std::enable_shared_from_this<mesh>
102 typedef bgeot::mesh_structure::ind_cv_ct ind_cv_ct;
103 typedef bgeot::mesh_structure::ind_set ind_set;
116 mutable std::map<size_type, mesh_region> cvf_sets;
117 mutable dal::bit_vector valid_cvf_sets;
118 void handle_region_refinement(
size_type,
const std::vector<size_type> &,
121 mutable bool cuthill_mckee_uptodate;
123 mutable std::vector<size_type> cmk_order;
126 #if GETFEM_PARA_LEVEL > 1
127 mutable bool modified;
129 mutable std::map<size_type, mesh_region> mpi_sub_region;
131 mutable dal::bit_vector valid_sub_regions;
134 modified =
true; cuthill_mckee_uptodate =
false;
135 context_dependencies::touch();
137 void compute_mpi_region()
const ;
138 void compute_mpi_sub_region(
size_type)
const;
143 {
if (modified) compute_mpi_region();
return mpi_region; }
145 if (modified) compute_mpi_region();
146 if (n ==
size_type(-1))
return mpi_region;
147 if (!(valid_sub_regions.is_in(n))) compute_mpi_sub_region(n);
148 return mpi_sub_region[n];
150 void intersect_with_mpi_region(
mesh_region &rg)
const;
153 { cuthill_mckee_uptodate =
false; context_dependencies::touch(); }
158 if (n ==
size_type(-1))
return get_mpi_region();
161 void intersect_with_mpi_region(
mesh_region &)
const {}
165 explicit mesh(
const std::string name =
"");
166 mesh(
const bgeot::basic_mesh &m,
const std::string name =
"");
170 inline std::string get_name()
const {
return name_;}
173 using basic_mesh::dim;
175 using basic_mesh::points;
176 PT_TAB &points() {
return pts; }
179 using basic_mesh::points_of_convex;
189 {
return ref_convex(structure_of_convex(ic), points_of_convex(ic)); }
191 using basic_mesh::add_point;
202 {
if (i != j) { pts.swap_points(i,j); mesh_structure::swap_points(i,j); } }
209 {
return pts.search_node(pt,radius); }
211 using basic_mesh::trans_of_convex;
215 {
return cvs_v_num[ic]; }
229 gtab[i] = pgt; trans_exists[i] =
true;
230 if (!present) { cvs_v_num[i] = act_counter(); touch(); }
246 const scalar_type tol=scalar_type(0));
252 {
return add_convex(bgeot::simplex_geotrans(di, 1), ipts); }
257 size_type add_simplex_by_points(dim_type dim, ITER ipts);
262 const base_node &pt2) {
265 return add_segment(ipt1, ipt2);
270 size_type add_triangle_by_points(
const base_node &p1,
272 const base_node &p3);
277 size_type add_tetrahedron_by_points(
const base_node &p1,
280 const base_node &p4);
290 size_type add_parallelepiped(dim_type di,
const ITER &ipts);
297 size_type add_parallelepiped_by_points(dim_type di,
const ITER &ps);
314 size_type add_prism(dim_type di,
const ITER &ipts);
322 size_type add_prism_by_points(dim_type di,
const ITER &ps);
325 { GMM_ASSERT1(
false,
"Sorry, to be done"); }
328 { GMM_ASSERT1(
false,
"Sorry, to be done"); }
335 scalar_type tol=scalar_type(0));
338 void sup_convex(
size_type ic,
bool sup_points =
false);
355 const base_node &pt)
const;
375 base_small_vector mean_normal_of_face_of_convex(
size_type ic,
385 const base_node &pt)
const;
406 scalar_type minimal_convex_radius_estimate()
const;
408 scalar_type maximal_convex_radius_estimate()
const;
410 void translation(
const base_small_vector &);
412 void transformation(
const base_matrix &);
414 void bounding_box(base_node& Pmin, base_node &Pmax)
const;
423 else if (!has_region(
id)) {
424 valid_cvf_sets.add(
id);
431 if (!has_region(
id)) {
432 valid_cvf_sets.add(
id);
440 const dal::bit_vector ®ions_index()
const {
return valid_cvf_sets; }
447 if (valid_cvf_sets[b])
448 { cvf_sets[b].clear(); valid_cvf_sets.sup(b); touch(); }
452 void sup_convex_from_regions(
size_type cv);
455 void optimize_structure(
bool with_renumbering =
true);
463 void write_to_file(
const std::string &name)
const;
467 void write_to_file(std::ostream &ost)
const;
472 void read_from_file(
const std::string &name);
477 void read_from_file(std::istream &ist);
479 void copy_from(
const mesh& m);
485 void touch_from_region(
size_type ) { touch(); }
496 struct green_simplex {
498 std::vector<size_type> sub_simplices;
500 std::vector<size_type> ipt_loc;
504 bool operator <(
const edge &e)
const;
508 typedef std::set<edge> edge_set;
510 struct Bank_info_struct {
511 dal::bit_vector is_green_simplex;
512 std::map<size_type, size_type> num_green_simplex;
513 dal::dynamic_tas<green_simplex> green_simplices;
517 std::unique_ptr<Bank_info_struct> Bank_info;
520 void set_name(
const std::string&);
523 std::vector<size_type> &);
524 bool Bank_is_convex_having_points(
size_type,
525 const std::vector<size_type> &);
526 void Bank_sup_convex_from_green(
size_type);
528 void Bank_build_first_mesh(mesh &,
size_type);
529 void Bank_basic_refine_convex(
size_type);
530 void Bank_refine_normal_convex(
size_type);
533 void Bank_build_green_simplexes(
size_type, std::vector<size_type> &);
538 void Bank_refine(dal::bit_vector);
543 const mesh &dummy_mesh();
558 ITER ipts,
const scalar_type tol)
561 std::vector<size_type> ind(nb);
562 for (
short_type i = 0; i < nb; ++ipts, ++i) ind[i] = add_point(*ipts, tol);
572 {
return add_convex(bgeot::parallelepiped_geotrans(di, 1), ipts); }
576 (dim_type di,
const ITER &ps)
581 {
return add_convex(bgeot::prism_geotrans(di, 1), ipts); }
585 (dim_type di,
const ITER &ps)
595 const base_matrix& pts,
596 pintegration_method pim);
601 const base_matrix& pts);
606 const base_matrix& pts);
610 typedef std::vector<convex_face> convex_face_ct;
611 struct APIDECL convex_face {
614 inline bool operator < (
const convex_face &e)
const {
615 if (cv < e.cv)
return true;
616 if (cv > e.cv)
return false;
617 if (f < e.f)
return true;
else if (f > e.f)
return false;
620 bool is_face()
const {
return f !=
short_type(-1); }
630 convex_face_ct &flist);
668 const mesh_region &mr,
669 const base_small_vector &V,
677 const base_node &pt1,
678 const base_node &pt2);
685 const base_node ¢er,
689 select_convexes_in_box(
const mesh &m,
const mesh_region &mr,
690 const base_node &pt1,
691 const base_node &pt2);
693 inline mesh_region APIDECL
694 select_convexes_in_box(
const mesh &m,
695 const base_node &pt1,
696 const base_node &pt2)
697 {
return select_convexes_in_box(m, m.region(-1), pt1, pt2); }
Inversion of geometric transformations.
generic definition of a convex ( bgeot::convex_structure + vertices coordinates )
size_type add_convex(pconvex_structure cs, ITER ipts, bool *present=0)
Insert a new convex in the mesh_structure.
Store a set of points, identifying points that are nearer than a certain very small distance.
base class for static stored objects
Deal with interdependencies of objects.
structure used to hold a set of convexes and/or convex faces.
static mesh_region all_convexes()
provide a default value for the mesh_region parameters of assembly procedures etc.
Describe a mesh (collection of convexes (elements) and points).
const std::vector< size_type > & cuthill_mckee_ordering() const
Return the list of convex IDs for a Cuthill-McKee ordering.
const dal::bit_vector & points_index() const
Return the points index.
size_type nb_points() const
Give the number of geometrical nodes in the mesh.
ref_convex convex(size_type ic) const
return a bgeot::convex object for the convex number ic.
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.
void update_from_context() const
this function has to be defined and should update the object when the context is modified.
size_type search_point(const base_node &pt, const scalar_type radius=0) const
Search a point given its coordinates.
void sup_region(size_type b)
Remove the region of index b.
gmm::uint64_type convex_version_number(size_type ic) const
return the version number of the convex ic.
const mesh_region region(size_type id) const
Return the region of index 'id'.
size_type add_convex(bgeot::pgeometric_trans pgt, ITER ipts)
Add a convex to the mesh.
void sup_point(size_type i)
Delete the point of index i from the mesh if it is not linked to a convex.
bool has_region(size_type s) const
Return true if the region of index 's' exists in the mesh.
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 add_simplex(dim_type di, ITER ipts)
Add a simplex to the mesh, given its dimension and point numbers.
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.
indexed array reference (given a container X, and a set of indexes I, this class provides a pseudo-co...
Deal with interdependencies of objects (getfem::context_dependencies).
region objects (set of convexes and/or convex faces)
scalar_type APIDECL convex_radius_estimate(bgeot::pgeometric_trans pgt, const base_matrix &pts)
rough estimate of the radius of the convex using the largest eigenvalue of the jacobian of the geomet...
scalar_type APIDECL convex_quality_estimate(bgeot::pgeometric_trans pgt, const base_matrix &pts)
rough estimate of the maximum value of the condition number of the jacobian of the geometric transfor...
size_type add_simplex_by_points(dim_type dim, ITER ipts)
Add a simplex to the mesh, given its dimension and point coordinates.
mesh_region APIDECL select_faces_of_normal(const mesh &m, const mesh_region &mr, const base_small_vector &V, scalar_type angle)
Select in the region mr the faces of the mesh m with their unit outward vector having a maximal angle...
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.
mesh_region APIDECL select_faces_in_ball(const mesh &m, const mesh_region &mr, const base_node ¢er, scalar_type radius)
Select in the region mr the faces of the mesh m lying entirely in the ball delimated by pt1 and radiu...
scalar_type APIDECL convex_area_estimate(bgeot::pgeometric_trans pgt, const base_matrix &pts, pintegration_method pim)
rough estimate of the convex area.
size_type add_prism(dim_type di, const ITER &ipts)
Add a prism to the mesh.
size_type add_parallelepiped(dim_type di, const ITER &ipts)
Add a parallelepiped to the mesh.
mesh_region APIDECL inner_faces_of_mesh(const mesh &m, const mesh_region &mr=mesh_region::all_convexes())
Select all the faces sharing at least two element of the given mesh region.
void APIDECL outer_faces_of_mesh(const mesh &m, const dal::bit_vector &cvlst, convex_face_ct &flist)
returns a list of "exterior" faces of a mesh (i.e.
size_type add_parallelepiped_by_points(dim_type di, const ITER &ps)
Add a parallelepiped to the mesh.
size_type add_prism_by_points(dim_type di, const ITER &ps)
Add a prism to the mesh.
mesh_region APIDECL select_faces_in_box(const mesh &m, const mesh_region &mr, const base_node &pt1, const base_node &pt2)
Select in the region mr the faces of the mesh m lying entirely in the box delimated by pt1 and pt2.
void APIDECL extrude(const mesh &in, mesh &out, size_type nb_layers, short_type degree=short_type(1))
build a N+1 dimensions mesh from a N-dimensions mesh by extrusion.
mesh_region APIDECL all_faces_of_mesh(const mesh &m, const mesh_region &mr=mesh_region::all_convexes())
Select all the faces of the given mesh region.
gmm::uint16_type short_type
used as the common short type integer in the library
size_t size_type
used as the common size type in the library
std::shared_ptr< const bgeot::geometric_trans > pgeometric_trans
pointer type for a geometric transformation
GEneric Tool for Finite Element Methods.