Welcome to the NetCologne GmbH open source mirroring service!

This machine mirrors various open-source projects. 20 Gbit/s uplink.

If there are any issues or you want another project mirrored, please contact mirror-service -=AT=- netcologne DOT de !

GetFEM: src/getfem/bgeot_mesh.h Source File
GetFEM  5.4.2
bgeot_mesh.h
Go to the documentation of this file.
1 /* -*- c++ -*- (enables emacs c++ mode) */
2 /*===========================================================================
3 
4  Copyright (C) 2006-2020 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_set &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_set &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 within a radius tol from an existing point the
110  function does not create a new point, and returns the index of
111  the already existing point.
112  If tol is negative the check for nearby points is deactivated.
113  The same effect can be achieved by setting the deprecated
114  argument remove_duplicated_nodes to false.
115 
116  @param pt holds the point coordinates.
117  */
118  size_type add_point(const base_node &pt,
119  const scalar_type tol=scalar_type(0),
120  bool remove_duplicated_nodes = true) {
121  return pts.add_node(pt, remove_duplicated_nodes ? tol : -1.);
122  }
123 
124  template<class ITER>
126  bool present;
127  size_type i = mesh_structure::add_convex(pgt->structure(), ipts,
128  &present);
129  gtab[i] = pgt; trans_exists[i] = true;
130  return i;
131  }
132 
133  size_type add_segment(size_type a, size_type b) {
134  size_type ipt[2]; ipt[0] = a; ipt[1] = b;
135  return add_convex(simplex_geotrans(1, 1), &(ipt[0]));
136  }
137 
138  size_type add_triangle(size_type a, size_type b, size_type c) {
139  size_type ipt[3]; ipt[0] = a; ipt[1] = b; ipt[2] = c;
140  return add_convex(simplex_geotrans(2, 1), &(ipt[0]));
141  }
142 
143  size_type add_tetrahedron(size_type a, size_type b,
144  size_type c, size_type d) {
145  size_type ipt[4]; ipt[0] = a; ipt[1] = b; ipt[2] = c; ipt[3] = d;
146  return add_convex(simplex_geotrans(3, 1), &(ipt[0]));
147  }
148  };
149 
150  typedef basic_mesh *pbasic_mesh;
151 
152 }
153 
154 #endif /* BGEOT_MESH_H__ */
bgeot::size_type
size_t size_type
used as the common size type in the library
Definition: bgeot_poly.h:49
bgeot_node_tab.h
Structure which dynamically collects points identifying points that are nearer than a certain very sm...
bgeot::mesh_structure::ind_points_of_convex
const ind_set & ind_points_of_convex(size_type ic) const
Return a container to the list of points attached to convex ic.
Definition: bgeot_mesh_structure.h:107
dal::dynamic_array< ind_cv_ct, 8 >
bgeot_geometric_trans.h
Geometric transformations on convexes.
bgeot::node_tab
Store a set of points, identifying points that are nearer than a certain very small distance.
Definition: bgeot_node_tab.h:52
bgeot_mesh_structure.h
Mesh structure definition.
bgeot::mesh_structure
Mesh structure definition.
Definition: bgeot_mesh_structure.h:73
bgeot
Basic Geometric Tools.
Definition: bgeot_convex_ref.cc:27
bgeot::pgeometric_trans
std::shared_ptr< const bgeot::geometric_trans > pgeometric_trans
pointer type for a geometric transformation
Definition: bgeot_geometric_trans.h:186
bgeot::mesh_structure::add_convex
size_type add_convex(pconvex_structure cs, ITER ipts, bool *present=0)
Insert a new convex in the mesh_structure.
Definition: bgeot_mesh_structure.h:306
gmm::tab_ref_index_ref
indexed array reference (given a container X, and a set of indexes I, this class provides a pseudo-co...
Definition: gmm_ref.h:289