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