GetFEM  5.5
bgeot_convex_ref.h
Go to the documentation of this file.
1 /* -*- c++ -*- (enables emacs c++ mode) */
2 /*===========================================================================
3 
4  Copyright (C) 2001-2026 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, see https://www.gnu.org/licenses/.
19 
20  As a special exception, you may use this file as it is a part of a free
21  software library without restriction. Specifically, if other files
22  instantiate templates or use macros or inline functions from this file,
23  or you compile this file and link it with other files to produce an
24  executable, this file does not by itself cause the resulting executable
25  to be covered by the GNU Lesser General Public License. This exception
26  does not however invalidate any other reasons why the executable file
27  might be covered by the GNU Lesser General Public License.
28 
29 ===========================================================================*/
30 
31 
32 /**@file bgeot_convex_ref.h
33  @author Yves Renard <Yves.Renard@insa-lyon.fr>
34  @date Septembre 28, 2001.
35  @brief Reference convexes
36 */
37 #ifndef BGEOT_CONVEX_REF_H__
38 #define BGEOT_CONVEX_REF_H__
39 
40 #include "bgeot_convex.h"
41 
42 namespace bgeot {
43 
44  /** @defgroup refconvexes Reference Convexes*/
45  /*@{*/
46 
47  /** Point tab storage. */
49  public std::vector<base_node> {
50  const base_node &operator[](size_type i) const
51  { return std::vector<base_node>::operator [](i); }
52  template <class IT> stored_point_tab(IT it, IT ite)
53  : std::vector<base_node>(it, ite)
54  { DAL_STORED_OBJECT_DEBUG_CREATED(this, "Stored point tab"); }
55  virtual ~stored_point_tab()
56  { DAL_STORED_OBJECT_DEBUG_DESTROYED(this, "Stored point tab"); }
57  };
58 
59  typedef std::shared_ptr<const stored_point_tab> pstored_point_tab;
60 
61  pstored_point_tab store_point_tab(const stored_point_tab& spt);
62 
63  /* store a new (read-only) array of points in stored_point_tab_tab */
64  template<class CONT> pstored_point_tab store_point_tab(const CONT &TAB)
65  { return store_point_tab(stored_point_tab(TAB.begin(), TAB.end())); }
66 
67  class mesh_structure;
68 
69  class convex_of_reference;
70  typedef std::shared_ptr<const convex_of_reference> pconvex_ref;
71 
72  /** Base class for reference convexes.
73 
74  Examples of reference convexes are (the order
75  1 triangle (0,0)-(1,0)-(0,1), the order 2 segment
76  (0)-(.5)-(1.), etc...). This class stores :
77 
78  - a list of points (vertices of the reference convex, plus
79  other points for reference convexes of degree > 1).
80 
81  - a normal for each face of the convex.
82 
83  - a mesh structure defining the smallest simplex partition of
84  the convex.
85 
86  - a pointer to the "basic convex_ref": for a convex_ref of
87  degree k, this is a pointer to the correspounding convex_ref of
88  degree 1.
89  */
91  public convex<base_node> {
92  protected :
93  std::vector<base_small_vector> normals_;
94  pstored_point_tab ppoints;
95  std::shared_ptr<mesh_structure> psimplexified_convex;
96  pconvex_ref basic_convex_ref_;
97  const bool auto_basic;
98  convex_of_reference(pconvex_structure cvs, bool auto_basic);
99 
100  public :
101  /// return a negative or null number if the base_node is in the convex.
102  virtual scalar_type is_in(const base_node &) const = 0;
103  /** return a null (or almost zero) if pt is in the face of the convex.
104  * Does not control if the point is in the convex, but if a point
105  * supposed to be in a convex is in this face. return a negative number
106  * if the point is in the side of the face where the element is and
107  * positive in the other side.
108  */
109  virtual scalar_type is_in_face(short_type, const base_node &) const =0;
110  /** will project any given point lying outside the convex onto the convex
111  outer surface */
112  virtual void project_into(base_node &pt) const {
113  GMM_ASSERT1(!auto_basic, "This method has to be overloaded in every "
114  "basic convex");
115  basic_convex_ref_->project_into(pt);
116  }
117  bool is_basic() const { return auto_basic; }
118  /// return the normal vector for each face.
119  const std::vector<base_small_vector> &normals() const
120  { return normals_; }
121  /// return the vertices of the reference convex.
122  const stored_point_tab &points() const { return *ppoints; }
123  const stored_point_tab &points() { return *ppoints; }
124  pstored_point_tab pspt() const { return ppoints; }
125  virtual ~convex_of_reference()
126  { DAL_STORED_OBJECT_DEBUG_DESTROYED(this, "Convex of reference"); }
127 
128  /** return a mesh structure composed of simplexes whose union
129  is the reference convex. All simplexes have the same (direct)
130  orientation.
131  */
132  const mesh_structure* simplexified_convex() const;
133  friend pconvex_ref basic_convex_ref(pconvex_ref cvr);
134  };
135 
136  /// return the associated order 1 reference convex.
137  inline pconvex_ref basic_convex_ref(pconvex_ref cvr)
138  { return cvr->auto_basic ? cvr : cvr->basic_convex_ref_; }
139 
140  // interface with qhull
141  void qhull_delaunay(const std::vector<base_node> &pts,
142  gmm::dense_matrix<size_type>& simplexes);
143 
144 
145  //@name public functions for obtaining a convex of reference
146  //@{
147 
148  /** returns a simplex of reference of dimension nc and degree k */
149  pconvex_ref simplex_of_reference(dim_type nc, short_type k = 1);
150  /** parallelepiped of reference of dimension nc (and degree 1) */
151  pconvex_ref parallelepiped_of_reference(dim_type nc, dim_type k = 1);
152  /** incomplete Q2 quadrilateral/hexahedral of reference of dimension
153  d = 2 or 3 */
154  pconvex_ref Q2_incomplete_of_reference(dim_type d);
155  /** prism of reference of dimension nc (and degree 1) */
156  pconvex_ref prism_of_reference(dim_type nc);
157  /** incomplete quadratic prism element of reference (15-node) */
158  pconvex_ref prism_incomplete_P2_of_reference();
159  /** pyramidal element of reference of degree k (k = 1 or 2 only) */
160  pconvex_ref pyramid_QK_of_reference(dim_type k);
161  IS_DEPRECATED pconvex_ref inline
162  pyramid_of_reference(dim_type k) { return pyramid_QK_of_reference(k); }
163  /** incomplete quadratic pyramidal element of reference (13-node) */
165  /** tensorial product of two convex ref.
166  in order to ensure unicity, it is required the a->dim() >= b->dim() */
167  pconvex_ref convex_ref_product(pconvex_ref a, pconvex_ref b);
168  /** equilateral simplex (degree 1). used only for mesh quality estimations */
169  pconvex_ref equilateral_simplex_of_reference(dim_type nc);
170 
171  /** generic convex with n global nodes */
172  pconvex_ref generic_dummy_convex_ref(dim_type nc, size_type n, short_type nf);
173  //@}
174 
175  /*@}*/
176 } /* end of namespace bgeot. */
177 
178 
179 #endif /* BGEOT_CONVEX_REF_H__ */
Convex objects (structure + vertices)
Base class for reference convexes.
const stored_point_tab & points() const
return the vertices of the reference convex.
friend pconvex_ref basic_convex_ref(pconvex_ref cvr)
return the associated order 1 reference convex.
const mesh_structure * simplexified_convex() const
return a mesh structure composed of simplexes whose union is the reference convex.
virtual void project_into(base_node &pt) const
will project any given point lying outside the convex onto the convex outer surface
virtual scalar_type is_in(const base_node &) const =0
return a negative or null number if the base_node is in the convex.
const std::vector< base_small_vector > & normals() const
return the normal vector for each face.
virtual scalar_type is_in_face(short_type, const base_node &) const =0
return a null (or almost zero) if pt is in the face of the convex.
generic definition of a convex ( bgeot::convex_structure + vertices coordinates )
Definition: bgeot_convex.h:49
base class for static stored objects
Basic Geometric Tools.
pconvex_ref convex_ref_product(pconvex_ref a, pconvex_ref b)
tensorial product of two convex ref.
gmm::uint16_type short_type
used as the common short type integer in the library
Definition: bgeot_config.h:72
pconvex_ref equilateral_simplex_of_reference(dim_type nc)
equilateral simplex (degree 1).
pconvex_ref pyramid_QK_of_reference(dim_type k)
pyramidal element of reference of degree k (k = 1 or 2 only)
pconvex_ref simplex_of_reference(dim_type nc, short_type K)
returns a simplex of reference of dimension nc and degree k
std::shared_ptr< const convex_structure > pconvex_structure
Pointer on a convex structure description.
pconvex_ref pyramid_Q2_incomplete_of_reference()
incomplete quadratic pyramidal element of reference (13-node)
pconvex_ref prism_incomplete_P2_of_reference()
incomplete quadratic prism element of reference (15-node)
pconvex_ref parallelepiped_of_reference(dim_type nc, dim_type k)
parallelepiped of reference of dimension nc (and degree 1)
pconvex_ref generic_dummy_convex_ref(dim_type nc, size_type n, short_type nf)
generic convex with n global nodes
size_t size_type
used as the common size type in the library
Definition: bgeot_poly.h:48
pconvex_ref Q2_incomplete_of_reference(dim_type nc)
incomplete Q2 quadrilateral/hexahedral of reference of dimension d = 2 or 3
pconvex_ref basic_convex_ref(pconvex_ref cvr)
return the associated order 1 reference convex.
pconvex_ref prism_of_reference(dim_type nc)
prism of reference of dimension nc (and degree 1)
Point tab storage.