GetFEM  5.4.2
bgeot_poly_composite.h
Go to the documentation of this file.
1 /* -*- c++ -*- (enables emacs c++ mode) */
2 /*===========================================================================
3 
4  Copyright (C) 2002-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_poly_composite.h
33  @author Yves Renard <Yves.Renard@insa-lyon.fr>
34  @date August 26, 2002.
35  @brief Handle composite polynomials.
36 
37  Composite polynomials are used in hierarchical FEM, composite geometric
38  transformations and composite fems.
39 */
40 
41 #ifndef BGEOT_POLY_COMPOSITE_H__
42 #define BGEOT_POLY_COMPOSITE_H__
43 
44 #include "bgeot_poly.h"
45 #include "bgeot_mesh.h"
46 #include "bgeot_rtree.h"
47 
48 // TODO : Use of rtree instead of dal::dynamic_tree_sorted<base_node,
49 // imbricated_box_less>
50 
51 
52 namespace bgeot {
53 
54  /// A comparison function for bgeot::base_node
56  {
57  mutable int exp_max, exp_min;
58  mutable scalar_type c_max;
59  unsigned base;
60 
61  /// comparaison function
62  int operator()(const base_node &x, const base_node &y) const;
63 
64  imbricated_box_less(unsigned ba = 10, int emi = -15, int ema = -2) {
65  base = ba; exp_max = ema; exp_min = emi;
66  c_max = pow(double(base), double(-exp_max));
67  }
68  };
69 
70 
71 
72  struct mesh_precomposite {
73 
74  typedef dal::dynamic_tree_sorted<base_node, imbricated_box_less> PTAB;
75 
76  const basic_mesh *msh;
77  PTAB vertices;
78  rtree box_tree;
79  std::map<size_type, std::vector<size_type>> box_to_convexes_map;
80  std::vector<base_matrix> gtrans, gtransinv;
81  std::vector<scalar_type> det;
82  std::vector<base_node> orgs;
83 
84  const basic_mesh &linked_mesh(void) const { return *msh; }
85  size_type nb_convex(void) const { return gtrans.size(); }
86  dim_type dim(void) const { return msh->dim(); }
87  pgeometric_trans trans_of_convex(size_type ic) const
88  { return msh->trans_of_convex(ic); }
89  void initialise(const basic_mesh &m);
90 
91  mesh_precomposite(const basic_mesh &m);
92  mesh_precomposite(void) : msh(0), box_tree(1e-13) {}
93  };
94 
95  typedef const mesh_precomposite *pmesh_precomposite;
96 
97  struct stored_base_poly : base_poly, public dal::static_stored_object {
98  stored_base_poly(const base_poly &p) : base_poly(p) {}
99  };
100  typedef std::shared_ptr<const stored_base_poly> pstored_base_poly;
101 
102 
103  class polynomial_composite {
104 
105  protected :
106  const mesh_precomposite *mp;
107  std::map<size_type, pstored_base_poly> polytab;
108  bool local_coordinate; // Local coordinates on each sub-element for
109  // polynomials or global coordinates ?
110  bool faces_first; // If true try to evaluate on faces before on the
111  // interior, usefull for HHO elements.
112  std::vector<base_poly> default_polys;
113 
114  public :
115  scalar_type eval(const base_node &p, size_type l) const;
116 
117  template <class ITER> scalar_type eval(const ITER &it,
118  size_type l = -1) const;
119  void derivative(short_type k);
120  void set_poly_of_subelt(size_type l, const base_poly &poly);
121  const base_poly &poly_of_subelt(size_type l) const;
122  size_type nb_subelt() const { return polytab.size(); }
123 
124  polynomial_composite(bool lc = true, bool ff = false)
125  : local_coordinate(lc), faces_first(ff) {}
126  polynomial_composite(const mesh_precomposite &m, bool lc = true,
127  bool ff = false);
128 
129  };
130 
131  inline std::ostream &operator <<
132  (std::ostream &o, const polynomial_composite& P) {
133  o << "poly_composite [";
134  for (size_type i = 0; i < P.nb_subelt(); ++i) {
135  if (i != 0) o << ", " << P.poly_of_subelt(i);
136  }
137  o << "]";
138  return o;
139  }
140 
141  template <class ITER>
142  scalar_type polynomial_composite::eval(const ITER &it, size_type l) const {
143  base_node p(mp->dim());
144  std::copy(it, it+mp->dim(), p.begin());
145  return eval(p,l);
146  }
147 
148  void structured_mesh_for_convex(pconvex_ref cvr, short_type k,
149  pbasic_mesh &pm, pmesh_precomposite &pmp,
150  bool force_simplexification=false);
151 
152  /** simplexify a convex_ref.
153  @param cvr the convex_ref.
154  @param k the refinement level.
155  @return a pointer to a statically allocated mesh. Do no free it!
156  */
157  const basic_mesh *
158  refined_simplex_mesh_for_convex(pconvex_ref cvr, short_type k);
159 
160  /** simplexify the faces of a convex_ref
161 
162  @param cvr the convex_ref.
163 
164  @param k the refinement level.
165 
166  @return vector of pointers to a statically allocated
167  mesh_structure objects. Do no free them! The point numbers in
168  the mesh_structure refer to the points of the mesh given by
169  refined_simplex_mesh_for_convex.
170  */
171  const std::vector<std::unique_ptr<mesh_structure>>&
173 } /* end of namespace bgeot. */
174 
175 
176 #endif
bgeot::imbricated_box_less
A comparison function for bgeot::base_node.
Definition: bgeot_poly_composite.h:55
bgeot::size_type
size_t size_type
used as the common size type in the library
Definition: bgeot_poly.h:49
bgeot::short_type
gmm::uint16_type short_type
used as the common short type integer in the library
Definition: bgeot_config.h:72
bgeot::rtree
Balanced tree of n-dimensional rectangles.
Definition: bgeot_rtree.h:98
bgeot_rtree.h
region-tree for window/point search on a set of rectangles.
bgeot_mesh.h
Basic mesh definition.
bgeot_poly.h
Multivariate polynomials.
bgeot::small_vector< scalar_type >
bgeot::refined_simplex_mesh_for_convex_faces
const std::vector< std::unique_ptr< mesh_structure > > & refined_simplex_mesh_for_convex_faces(pconvex_ref cvr, short_type k)
simplexify the faces of a convex_ref
Definition: bgeot_poly_composite.cc:565
bgeot::refined_simplex_mesh_for_convex
const basic_mesh * refined_simplex_mesh_for_convex(pconvex_ref cvr, short_type k)
simplexify a convex_ref.
Definition: bgeot_poly_composite.cc:558
bgeot::imbricated_box_less::operator()
int operator()(const base_node &x, const base_node &y) const
comparaison function
Definition: bgeot_poly_composite.cc:32
bgeot::structured_mesh_for_convex
void structured_mesh_for_convex(pconvex_ref cvr, short_type k, pbasic_mesh &pm, pmesh_precomposite &pmp, bool force_simplexification)
This function returns a mesh in pm which contains a refinement of the convex cvr if force_simplexific...
Definition: bgeot_poly_composite.cc:499
bgeot
Basic Geometric Tools.
Definition: bgeot_convex_ref.cc:27
dal::static_stored_object
base class for static stored objects
Definition: dal_static_stored_objects.h:206
bgeot::pgeometric_trans
std::shared_ptr< const bgeot::geometric_trans > pgeometric_trans
pointer type for a geometric transformation
Definition: bgeot_geometric_trans.h:186