GetFEM  5.4.2
getfem_interpolated_fem.h
Go to the documentation of this file.
1 /* -*- c++ -*- (enables emacs c++ mode) */
2 /*===========================================================================
3 
4  Copyright (C) 2004-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 /**@file getfem_interpolated_fem.h
32  @author Yves Renard <Yves.Renard@insa-lyon.fr>
33  @date October 29, 2004.
34  @brief FEM which interpolates a mesh_fem on a different mesh.
35 
36  To be corrected : dependencies. The mesh fem using this fem will
37  not depend on the mesh fem arguments.
38 */
39 
40 
41 #ifndef GETFEM_INTERPOLATED_FEM_H__
42 #define GETFEM_INTERPOLATED_FEM_H__
43 
44 #include "getfem_fem.h"
45 #include "getfem_mesh_fem.h"
46 #include "getfem_mesh_im.h"
47 #include "bgeot_rtree.h"
48 #include "bgeot_geotrans_inv.h"
49 
50 namespace getfem {
51 
52  // Object representing global transformation. To be derived.
53 
54  struct virtual_interpolated_func {
55  virtual void val(const base_node&, base_node &) const
56  { GMM_ASSERT1(false, "this interpolated_func has no value"); }
57  virtual void grad(const base_node&, base_matrix &) const
58  { GMM_ASSERT1(false, "this interpolated_func has no gradient"); }
59  virtual void hess(const base_node&, base_matrix &) const
60  { GMM_ASSERT1(false, "this interpolated_func has no hessian"); }
61  virtual ~virtual_interpolated_func() {}
62  };
63 
64 
65  typedef const virtual_interpolated_func *pinterpolated_func;
66 
67 
68  struct gausspt_interpolation_data {
69  size_type elt; // convex of the interpolated mesh_fem under the gauss point
70  size_type iflags; // flags & 1 : there is an element or not
71  // flags & 2 : base_val is stored
72  // flags & 4 : grad_val is stored
73  base_node ptref; // coords on reference element of mf1 element
74  base_tensor base_val; // optional storage of the base values
75  base_tensor grad_val; // optional storage of the grad base values
76  std::vector<size_type> local_dof; // correspondence between dof of the
77  // mf1 element and dof of the interpolated element.
78  gausspt_interpolation_data() : elt(size_type(-1)), iflags(size_type(-1)) {}
79  };
80 
81  /** FEM which interpolates a mesh_fem on a different mesh.
82 
83  Note that the memory cost of this method is extremely high!
84  */
86 
87  protected :
88 
89  struct elt_interpolation_data {
91  std::vector<gausspt_interpolation_data> gausspt;
92  std::vector<size_type> inddof;
93  pintegration_method pim; // for DEBUG
94  elt_interpolation_data() : nb_dof(0), pim(0) {}
95  };
96 
97  const mesh_fem &mf; // mf represents the original finite element method
98  // to be interpolated.
99  const mesh_im &mim; // mesh on which mf1 is interpolated. contains
100  // also the integration method.
101  pinterpolated_func pif; // optional transformation
102 
103  bool store_values;
104  dal::bit_vector blocked_dof;
105 
106  // auxiliary variables
107  mutable std::vector<elt_interpolation_data> elements;
108  mutable bgeot::rtree boxtree; // Tree containing the bounding box
109  // of mf1 elements
110  mutable std::map<size_type, std::vector<size_type>> box_to_convexes_map;
111  mutable std::vector<size_type> ind_dof; /* all functions using this work
112  array should keep it full of
113  size_type(-1) */
114  mutable size_type cv_stored;
115  mutable bgeot::rtree::pbox_set boxlst;
116  mutable bgeot::geotrans_inv_convex gic;
117  mutable base_tensor taux;
118  mutable fem_interpolation_context fictx;
119  mutable size_type fictx_cv;
120  mutable base_matrix G;
121  mutable bgeot::pstored_point_tab pspt_override;
122  mutable bgeot::multi_index mi2, mi3;
123  mutable base_node ptref;
124  mutable gmm::dense_matrix<scalar_type> trans;
125 
126  void build_rtree(void) const;
127 
128  bool find_a_point(base_node pt, base_node &ptr,
129  size_type &cv) const;
130 
131  virtual void update_from_context(void) const;
132  inline void actualize_fictx(pfem pf, size_type cv,
133  const base_node &ptr) const;
134 
135  public :
136 
137  virtual size_type nb_dof(size_type cv) const;
138  virtual size_type index_of_global_dof(size_type cv, size_type i) const;
139  virtual bgeot::pconvex_ref ref_convex(size_type cv) const;
140  virtual const bgeot::convex<base_node> &node_convex(size_type cv) const;
141  virtual bgeot::pstored_point_tab node_tab(size_type) const
142  { return pspt_override; }
143  void base_value(const base_node &, base_tensor &) const;
144  void grad_base_value(const base_node &, base_tensor &) const;
145  void hess_base_value(const base_node &, base_tensor &) const;
147  base_tensor &t, bool = true) const;
149  base_tensor &t, bool = true) const;
151  base_tensor &, bool = true) const;
152 
153  /** return the list of convexes of the interpolated mesh_fem which
154  * contain at least one gauss point (should be all convexes)! */
155  dal::bit_vector interpolated_convexes() const;
156 
157  /** return the min/max/mean number of gauss points in the convexes
158  * of the interpolated mesh_fem */
159  void gauss_pts_stats(unsigned &ming, unsigned &maxg,
160  scalar_type &meang) const;
161  size_type memsize() const;
162  interpolated_fem(const mesh_fem &mef, const mesh_im &meim,
163  pinterpolated_func pif_ = 0,
164  dal::bit_vector blocked_dof = dal::bit_vector(),
165  bool store_val = true);
166  virtual ~interpolated_fem()
167  { DAL_STORED_OBJECT_DEBUG_DESTROYED(this, "Interpolated fem"); }
168  };
169 
170 
171  /** create a new interpolated FEM.
172  @param mef the mesh_fem that will be interpolated.
173  @param mim the integration method on the final mesh (not the mesh
174  of mef!).
175  @param pif an optional geometric transformation applied to
176  mef.linked_mesh() (used for getfem::spider_fem)
177  @param blocked_dof list of dof of mef which won't be interpolated.
178  @param store_val if true, the values/gradients of interpolated base
179  function are cached at each gauss point (eats much memory).
180  */
181  pfem new_interpolated_fem(const mesh_fem &mef, const mesh_im &mim,
182  pinterpolated_func pif = 0,
183  dal::bit_vector blocked_dof = dal::bit_vector(),
184  bool store_val = true);
185 
186  /** release an interpolated fem */
187  inline void del_interpolated_fem(const pfem &pf)
188  { dal::del_stored_object(pf); }
189 
190 
191 } /* end of namespace getfem. */
192 
193 #endif
194 
getfem::interpolated_fem::gauss_pts_stats
void gauss_pts_stats(unsigned &ming, unsigned &maxg, scalar_type &meang) const
return the min/max/mean number of gauss points in the convexes of the interpolated mesh_fem
Definition: getfem_interpolated_fem.cc:340
bgeot::geotrans_inv_convex
does the inversion of the geometric transformation for a given convex
Definition: bgeot_geotrans_inv.h:64
getfem::interpolated_fem::ref_convex
virtual bgeot::pconvex_ref ref_convex(size_type cv) const
Return the convex of the reference element.
Definition: getfem_interpolated_fem.cc:152
bgeot::size_type
size_t size_type
used as the common size type in the library
Definition: bgeot_poly.h:49
getfem::interpolated_fem::real_base_value
void real_base_value(const fem_interpolation_context &c, base_tensor &t, bool=true) const
Give the value of all components of the base functions at the current point of the fem_interpolation_...
Definition: getfem_interpolated_fem.cc:186
getfem::mesh_im
Describe an integration method linked to a mesh.
Definition: getfem_mesh_im.h:47
bgeot::convex< base_node >
getfem::interpolated_fem::hess_base_value
void hess_base_value(const base_node &, base_tensor &) const
Give the value of all hessians (on ref.
Definition: getfem_interpolated_fem.cc:170
dal::del_stored_object
void del_stored_object(const pstatic_stored_object &o, bool ignore_unstored)
Delete an object and the object which depend on it.
Definition: dal_static_stored_objects.cc:369
getfem::virtual_fem
Base class for finite element description.
Definition: getfem_fem.h:255
getfem::mesh_fem
Describe a finite element method linked to a mesh.
Definition: getfem_mesh_fem.h:148
bgeot::rtree
Balanced tree of n-dimensional rectangles.
Definition: bgeot_rtree.h:98
getfem
GEneric Tool for Finite Element Methods.
Definition: getfem_accumulated_distro.h:46
getfem::fem_interpolation_context
structure passed as the argument of fem interpolation functions.
Definition: getfem_fem.h:749
bgeot_rtree.h
region-tree for window/point search on a set of rectangles.
getfem::interpolated_fem::real_grad_base_value
void real_grad_base_value(const fem_interpolation_context &c, base_tensor &t, bool=true) const
Give the gradient of all components of the base functions at the current point of the fem_interpolati...
Definition: getfem_interpolated_fem.cc:238
getfem::interpolated_fem::grad_base_value
void grad_base_value(const base_node &, base_tensor &) const
Give the value of all gradients (on ref.
Definition: getfem_interpolated_fem.cc:167
getfem_mesh_im.h
Define the getfem::mesh_im class (integration of getfem::mesh_fem).
getfem_mesh_fem.h
Define the getfem::mesh_fem class.
getfem::del_interpolated_fem
void del_interpolated_fem(const pfem &pf)
release an interpolated fem
Definition: getfem_interpolated_fem.h:187
getfem::context_dependencies
Deal with interdependencies of objects.
Definition: getfem_context.h:81
getfem::pfem
std::shared_ptr< const getfem::virtual_fem > pfem
type of pointer on a fem description
Definition: getfem_fem.h:244
getfem::interpolated_fem::node_convex
virtual const bgeot::convex< base_node > & node_convex(size_type cv) const
Gives the convex representing the nodes on the reference element.
Definition: getfem_interpolated_fem.cc:156
getfem::interpolated_fem::real_hess_base_value
void real_hess_base_value(const fem_interpolation_context &, base_tensor &, bool=true) const
Give the hessian of all components of the base functions at the current point of the fem_interpolatio...
Definition: getfem_interpolated_fem.cc:324
bgeot_geotrans_inv.h
Inversion of geometric transformations.
getfem::interpolated_fem::base_value
void base_value(const base_node &, base_tensor &) const
Give the value of all components of the base functions at the point x of the reference element.
Definition: getfem_interpolated_fem.cc:165
getfem::new_interpolated_fem
pfem new_interpolated_fem(const mesh_fem &mef, const mesh_im &mim, pinterpolated_func pif=0, dal::bit_vector blocked_dof=dal::bit_vector(), bool store_val=true)
create a new interpolated FEM.
Definition: getfem_interpolated_fem.cc:394
getfem::interpolated_fem::update_from_context
virtual void update_from_context(void) const
this function has to be defined and should update the object when the context is modified.
Definition: getfem_interpolated_fem.cc:61
getfem::interpolated_fem::nb_dof
virtual size_type nb_dof(size_type cv) const
Number of degrees of freedom.
Definition: getfem_interpolated_fem.cc:141
getfem_fem.h
Definition of the finite element methods.
getfem::interpolated_fem::interpolated_convexes
dal::bit_vector interpolated_convexes() const
return the list of convexes of the interpolated mesh_fem which contain at least one gauss point (shou...
Definition: getfem_interpolated_fem.cc:328
getfem::interpolated_fem
FEM which interpolates a mesh_fem on a different mesh.
Definition: getfem_interpolated_fem.h:85

Rabisu Mirror Service We provide mirrors to support Open source communities. Our mirror server is located in Istanbul/Turkey region.

Please do not hesitate to contact mirror@rabisu.com for new open source mirror submissions.