GetFEM++  5.3
bgeot_poly_composite.h
Go to the documentation of this file.
1 /* -*- c++ -*- (enables emacs c++ mode) */
2 /*===========================================================================
3 
4  Copyright (C) 2002-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_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 
47 // TODO : Use of rtree instead of dal::dynamic_tree_sorted<base_node,
48 // imbricated_box_less>
49 
50 
51 namespace bgeot {
52 
53  /// A comparison function for bgeot::base_node
55  : public std::binary_function<base_node, base_node, int>
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 vertexes;
78  std::vector<base_matrix> gtrans;
79  std::vector<scalar_type> det;
80  std::vector<base_node> orgs;
81 
82  const basic_mesh &linked_mesh(void) const { return *msh; }
83  size_type nb_convex(void) const { return gtrans.size(); }
84  dim_type dim(void) const { return msh->dim(); }
85  pgeometric_trans trans_of_convex(size_type ic) const
86  { return msh->trans_of_convex(ic); }
87 
88  mesh_precomposite(const basic_mesh &m);
89  mesh_precomposite(void) : msh(0) {}
90  };
91 
92  typedef const mesh_precomposite *pmesh_precomposite;
93 
94  class polynomial_composite {
95 
96  protected :
97  const mesh_precomposite *mp;
98  std::map<size_type, dal::pstatic_stored_object_key> polytab;
99  bool local_coordinate; // are the polynomials described on the local
100  // coordinates of each sub-element or on global coordinates.
101  base_poly default_poly;
102 
103  public :
104 
105  template <class ITER> scalar_type eval(const ITER &it) const;
106  scalar_type eval(const base_node &pt) const;
107  void derivative(short_type k);
108  void set_poly_of_subelt(size_type l, const base_poly &poly);
109  const base_poly &poly_of_subelt(size_type l) const;
110  size_type nb_subelt() const { return polytab.size(); }
111 
112  polynomial_composite(bool lc = true) : local_coordinate(lc) {}
113  polynomial_composite(const mesh_precomposite &m, bool lc = true);
114 
115  };
116 
117  inline std::ostream &operator <<
118  (std::ostream &o, const polynomial_composite& P) {
119  o << "poly_composite [";
120  for (size_type i = 0; i < P.nb_subelt(); ++i) {
121  if (i != 0) o << ", " << P.poly_of_subelt(i);
122  }
123  o << "]";
124  return o;
125  }
126 
127  template <class ITER>
128  scalar_type polynomial_composite::eval(const ITER &it) const {
129  base_node pt(mp->dim());
130  std::copy(it, it + mp->dim(), pt.begin());
131  return eval(pt);
132  }
133 
134  void structured_mesh_for_convex(pconvex_ref cvr, short_type k,
135  pbasic_mesh &pm, pmesh_precomposite &pmp,
136  bool force_simplexification=false);
137 
138  /** simplexify a convex_ref.
139  @param cvr the convex_ref.
140  @param k the refinement level.
141  @return a pointer to a statically allocated mesh. Do no free it!
142  */
143  const basic_mesh *
144  refined_simplex_mesh_for_convex(pconvex_ref cvr, short_type k);
145 
146  /** simplexify the faces of a convex_ref
147 
148  @param cvr the convex_ref.
149 
150  @param k the refinement level.
151 
152  @return vector of pointers to a statically allocated
153  mesh_structure objects. Do no free them! The point numbers in
154  the mesh_structure refer to the points of the mesh given by
155  refined_simplex_mesh_for_convex.
156  */
157  const std::vector<std::unique_ptr<mesh_structure>>&
159 } /* end of namespace bgeot. */
160 
161 
162 #endif
const basic_mesh * refined_simplex_mesh_for_convex(pconvex_ref cvr, short_type k)
simplexify a convex_ref.
Multivariate polynomials.
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
A comparison function for bgeot::base_node.
size_t size_type
used as the common size type in the library
Definition: bgeot_poly.h:49
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...
int operator()(const base_node &x, const base_node &y) const
comparaison function
gmm::uint16_type short_type
used as the common short type integer in the library
Definition: bgeot_config.h:79
Basic Geometric Tools.
std::shared_ptr< const bgeot::geometric_trans > pgeometric_trans
pointer type for a geometric transformation
Basic mesh definition.