GetFEM++  5.3
bgeot_mesh.h
Go to the documentation of this file.
1 /* -*- c++ -*- (enables emacs c++ mode) */
2 /*===========================================================================
3 
4  Copyright (C) 2006-2017 Yves Renard
5 
6  This file is a part of GetFEM++
7 
8  GetFEM++ is free software; you can redistribute it and/or modify it
9  under the terms of the GNU Lesser General Public License as published
10  by the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version along with the GCC Runtime Library
12  Exception either version 3.1 or (at your option) any later version.
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16  License and GCC Runtime Library Exception for more details.
17  You should have received a copy of the GNU Lesser General Public License
18  along with this program; if not, write to the Free Software Foundation,
19  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20 
21  As a special exception, you may use this file as it is a part of a free
22  software library without restriction. Specifically, if other files
23  instantiate templates or use macros or inline functions from this file,
24  or you compile this file and link it with other files to produce an
25  executable, this file does not by itself cause the resulting executable
26  to be covered by the GNU Lesser General Public License. This exception
27  does not however invalidate any other reasons why the executable file
28  might be covered by the GNU Lesser General Public License.
29 
30 ===========================================================================*/
31 
32 /**@file bgeot_mesh.h
33  @author Yves Renard <Yves.Renard@insa-lyon.fr>
34  @date February 15, 2006.
35  @brief Basic mesh definition
36 */
37 
38 #ifndef BGEOT_MESH_H__
39 #define BGEOT_MESH_H__
40 
41 #include "bgeot_mesh_structure.h"
42 #include "bgeot_geometric_trans.h"
43 #include "bgeot_node_tab.h"
44 
45 namespace bgeot {
46 
47  /** @internal mesh structure + points
48  */
49  class basic_mesh : public bgeot::mesh_structure {
50 
51  public :
52 
53  // typedef basic_mesh_point_comparator pt_comp;
54  typedef bgeot::node_tab PT_TAB;
55  typedef bgeot::mesh_structure::ind_cv_ct ind_cv_ct;
56  typedef bgeot::mesh_structure::ind_set ind_set;
57  typedef bgeot::mesh_structure::ind_pt_face_ct ind_pt_face_ct;
58  typedef bgeot::mesh_structure::point_ct point_ct;
59 
61  <PT_TAB::const_iterator, ind_cv_ct::const_iterator> ref_mesh_pt_ct;
63  <PT_TAB::const_iterator, ind_pt_face_ct::const_iterator>
64  ref_mesh_face_pt_ct;
65 
66 
67  protected :
68 
69  PT_TAB pts;
70 
72  dal::bit_vector trans_exists;
73 
74  public :
75 
76  dim_type dim() const { return pts.dim(); }
77 
78  /** Return the bgeot::geometric_trans attached to a convex.
79  @param ic the convex number.
80  */
81  bgeot::pgeometric_trans trans_of_convex(size_type ic) const {
82  GMM_ASSERT1(trans_exists[ic],
83  "No geometric transformation or nonexisting element");
84  return gtab[ic];
85  }
86 
87  const PT_TAB &points() const { return pts; }
88 
89  /// Return a (pseudo)container of the points of a given convex
90  ref_mesh_pt_ct points_of_convex(size_type ic) const {
91  const ind_cv_ct &rct = ind_points_of_convex(ic);
92  return ref_mesh_pt_ct(pts.begin(), rct.begin(), rct.end());
93  }
94 
95  inline void points_of_convex(size_type ic, base_matrix &G) const {
96  const ind_cv_ct &rct = ind_points_of_convex(ic);
97  size_type N = dim(), Np = rct.size();
98  G.base_resize(N, Np);
99  auto it = G.begin();
100  for (size_type i = 0; i < Np; ++i, it += N) {
101  const base_node &P = pts[rct[i]];
102  std::copy(P.begin(), P.end(), it);
103  }
104  }
105 
106  /** Add the point pt to the mesh and return the index of the
107  point.
108 
109  If the point is too close to an existing point and remove_duplicated_nodes = true,
110  the function does not create a new point, and returns the index of the
111  already existing point.
112  @param pt the point coordinates.
113  */
114  size_type add_point(const base_node &pt,
115  const scalar_type tol=scalar_type(0),
116  bool remove_duplicated_nodes = true) {
117  return pts.add_node(pt, tol, remove_duplicated_nodes);
118  }
119 
120  template<class ITER>
122  bool present;
123  size_type i = mesh_structure::add_convex(pgt->structure(), ipts,
124  &present);
125  gtab[i] = pgt; trans_exists[i] = true;
126  return i;
127  }
128 
129  size_type add_segment(size_type a, size_type b) {
130  size_type ipt[2]; ipt[0] = a; ipt[1] = b;
131  return add_convex(simplex_geotrans(1, 1), &(ipt[0]));
132  }
133 
134  size_type add_triangle(size_type a, size_type b, size_type c) {
135  size_type ipt[3]; ipt[0] = a; ipt[1] = b; ipt[2] = c;
136  return add_convex(simplex_geotrans(2, 1), &(ipt[0]));
137  }
138 
139  size_type add_tetrahedron(size_type a, size_type b,
140  size_type c, size_type d) {
141  size_type ipt[4]; ipt[0] = a; ipt[1] = b; ipt[2] = c; ipt[3] = d;
142  return add_convex(simplex_geotrans(3, 1), &(ipt[0]));
143  }
144  };
145 
146  typedef basic_mesh *pbasic_mesh;
147 
148 }
149 
150 #endif /* BGEOT_MESH_H__ */
Geometric transformations on convexes.
indexed array reference (given a container X, and a set of indexes I, this class provides a pseudo-co...
Definition: gmm_ref.h:289
Structure which dynamically collects points identifying points that are nearer than a certain very sm...
size_t size_type
used as the common size type in the library
Definition: bgeot_poly.h:49
Mesh structure definition.
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...
Mesh structure definition.
Basic Geometric Tools.
const ind_cv_ct & ind_points_of_convex(size_type ic) const
Return a container to the list of points attached to convex ic.
std::shared_ptr< const bgeot::geometric_trans > pgeometric_trans
pointer type for a geometric transformation