GetFEM  5.4.2
getfem_projected_fem.h
Go to the documentation of this file.
1 /* -*- c++ -*- (enables emacs c++ mode) */
2 /*===========================================================================
3 
4  Copyright (C) 2012-2020 Yves Renard, Konstantinos Poulios
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_projected_fem.h
32  @author Konstantinos Poulios <logari81@googlemail.com>
33  @date January 12, 2012.
34  @brief FEM which projects a mesh_fem on a different mesh.
35 */
36 
37 
38 #ifndef GETFEM_PROJECTED_FEM_H__
39 #define GETFEM_PROJECTED_FEM_H__
40 
41 #include "getfem_fem.h"
42 #include "getfem_mesh_fem.h"
43 #include "getfem_mesh_im.h"
44 #include "bgeot_kdtree.h"
45 #include "bgeot_geotrans_inv.h"
46 
47 namespace getfem {
48 
49  struct gausspt_projection_data {
50  size_type cv; // convex of the source mesh_fem opposite to the gauss point
51  short_type f; // convex face of the source mesh_fem opposite to the gauss point
52  size_type iflags; // flags & 1 : there is an element or not
53  // flags & 2 : base_val is stored
54  // flags & 4 : grad_val is stored
55  base_node ptref; // coords on reference element of mf_source element
56  base_node normal; // normal vector at the projected point on the mf_source element
57  scalar_type gap; // gap distance from the gauss point to the projected point
58  base_tensor base_val; // optional storage of the base values
59  base_tensor grad_val; // optional storage of the grad base values
60  std::map<size_type,size_type> local_dof; // correspondence between dof of the
61  // mf_source element and dof of the projected element.
62  gausspt_projection_data() :
63  cv(size_type(-1)), f(short_type(-1)), iflags(size_type(-1)) {}
64  };
65 
66  /** FEM which interpolates the projection of a mesh_fem on a different mesh.
67 
68  Note that the memory cost of this method is extremely high!
69  */
71 
72  protected :
73 
74  struct elt_projection_data {
75  short_type f; // face number on the target mesh
77  std::map<size_type,gausspt_projection_data> gausspt;
78  std::vector<size_type> inddof;
79  pintegration_method pim; // for DEBUG
80  elt_projection_data() : f(short_type(-1)), nb_dof(0), pim(0) {}
81  };
82 
83  const mesh_fem &mf_source; // mf_source represents the original finite
84  // element method to be projected.
85  const mesh_im &mim_target; // mesh on which mf_source is projected.
86  // Contains also the integration method.
87  mesh_region rg_source;
88  mesh_region rg_target;
89 
90  bool store_values;
91  dal::bit_vector blocked_dofs;
92 
93  // auxiliary variables
94  mutable std::map<size_type,elt_projection_data> elements;
95  mutable bgeot::kdtree tree; // Tree containing the nodes of the
96  // projected mf_source dofs
97  mutable std::vector<size_type> ind_dof; /* all functions using this work
98  array should keep it filled
99  with size_type(-1) */
100  mutable bgeot::geotrans_inv_convex gic;
101  mutable base_tensor taux;
102  mutable fem_interpolation_context fictx;
103  mutable size_type fictx_cv;
104  mutable base_matrix G;
105  mutable bgeot::pstored_point_tab pspt_override;
106  mutable bgeot::multi_index mi2, mi3;
107  mutable base_node ptref;
108 
109  void build_kdtree() const;
110 
111  bool find_a_projected_point(const base_node &pt, base_node &ptr_proj,
112  size_type &cv_proj, short_type &fc_proj) const;
113 
114  virtual void update_from_context(void) const;
115  inline void actualize_fictx(pfem pf, size_type cv,
116  const base_node &ptr) const;
117 
118  public :
119 
120  virtual size_type nb_dof(size_type cv) const;
121  virtual size_type index_of_global_dof(size_type cv, size_type i) const;
122  virtual bgeot::pconvex_ref ref_convex(size_type cv) const;
123  virtual const bgeot::convex<base_node> &node_convex(size_type cv) const;
124  virtual bgeot::pstored_point_tab node_tab(size_type) const
125  { return pspt_override; }
126  void base_value(const base_node &, base_tensor &) const;
127  void grad_base_value(const base_node &, base_tensor &) const;
128  void hess_base_value(const base_node &, base_tensor &) const;
130  base_tensor &t, bool = true) const;
132  base_tensor &t, bool = true) const;
134  base_tensor &, bool = true) const;
135 
136  void projection_data(const fem_interpolation_context& c,
137  base_node &normal, scalar_type &gap) const;
138  void projection_data(const base_node &pt,
139  base_node &normal, scalar_type &gap) const;
140 
141  /** return the list of convexes of the projected mesh_fem which
142  * contain at least one gauss point (should be all convexes)! */
143  dal::bit_vector projected_convexes() const;
144 
145  /** faces and convexes from the target region
146  * that contain at least one Gauss point that is projected by the source */
148 
149  /** return the min/max/mean number of gauss points in the convexes
150  * of the projected mesh_fem */
151  void gauss_pts_stats(unsigned &ming, unsigned &maxg,
152  scalar_type &meang) const;
153  size_type memsize() const;
154 
155  projected_fem(const mesh_fem &mf_source_, const mesh_im &mim_target_,
156  size_type rg_source_, size_type rg_target_,
157  dal::bit_vector blocked_dofs_,
158  bool store_val);
159  virtual ~projected_fem()
160  { DAL_STORED_OBJECT_DEBUG_DESTROYED(this, "Projected fem"); }
161  };
162 
163 
164  /** create a new projected FEM.
165  @param mf_source the mesh_fem that will be projected.
166  @param mim_target the integration method on the final mesh (not the mesh
167  of mf_source!).
168  @param blocked_dofs list of dof of mf_source which won't be projected.
169  @param store_val if true, the values/gradients of interpolated base
170  function are cached at each gauss point (eats much memory).
171  */
172  pfem new_projected_fem(const mesh_fem &mf_source, const mesh_im &mim_target,
173  size_type rg_source_ = size_type(-1),
174  size_type rg_target_ = size_type(-1),
175  dal::bit_vector blocked_dofs = dal::bit_vector(),
176  bool store_val = true);
177 
178  /** release a projected fem */
180 
181 
182 } /* end of namespace getfem. */
183 
184 #endif
bgeot_kdtree.h
Simple implementation of a KD-tree.
bgeot::geotrans_inv_convex
does the inversion of the geometric transformation for a given convex
Definition: bgeot_geotrans_inv.h:64
getfem::projected_fem::projected_convexes
dal::bit_vector projected_convexes() const
return the list of convexes of the projected mesh_fem which contain at least one gauss point (should ...
Definition: getfem_projected_fem.cc:785
bgeot::size_type
size_t size_type
used as the common size type in the library
Definition: bgeot_poly.h:49
getfem::mesh_im
Describe an integration method linked to a mesh.
Definition: getfem_mesh_im.h:47
getfem::projected_fem::hess_base_value
void hess_base_value(const base_node &, base_tensor &) const
Give the value of all hessians (on ref.
Definition: getfem_projected_fem.cc:518
getfem::projected_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_projected_fem.cc:627
bgeot::convex< base_node >
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::projected_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_projected_fem.cc:513
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::short_type
gmm::uint16_type short_type
used as the common short type integer in the library
Definition: bgeot_config.h:72
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
getfem::projected_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 projected mesh_fem
Definition: getfem_projected_fem.cc:820
bgeot::kdtree
Balanced tree over a set of points.
Definition: bgeot_kdtree.h:102
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::projected_fem::nb_dof
virtual size_type nb_dof(size_type cv) const
Number of degrees of freedom.
Definition: getfem_projected_fem.cc:483
getfem::projected_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_projected_fem.cc:726
getfem::context_dependencies
Deal with interdependencies of objects.
Definition: getfem_context.h:81
getfem::projected_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_projected_fem.cc:533
getfem::projected_fem::ref_convex
virtual bgeot::pconvex_ref ref_convex(size_type cv) const
Return the convex of the reference element.
Definition: getfem_projected_fem.cc:501
getfem::projected_fem::grad_base_value
void grad_base_value(const base_node &, base_tensor &) const
Give the value of all gradients (on ref.
Definition: getfem_projected_fem.cc:515
getfem::pfem
std::shared_ptr< const getfem::virtual_fem > pfem
type of pointer on a fem description
Definition: getfem_fem.h:244
getfem::projected_fem::projected_target_region
mesh_region projected_target_region() const
faces and convexes from the target region that contain at least one Gauss point that is projected by ...
Definition: getfem_projected_fem.cc:798
bgeot_geotrans_inv.h
Inversion of geometric transformations.
getfem::del_projected_fem
void del_projected_fem(pfem pf)
release a projected fem
Definition: getfem_projected_fem.h:179
getfem::projected_fem
FEM which interpolates the projection of a mesh_fem on a different mesh.
Definition: getfem_projected_fem.h:70
getfem::mesh_region
structure used to hold a set of convexes and/or convex faces.
Definition: getfem_mesh_region.h:55
getfem_fem.h
Definition of the finite element methods.
getfem::projected_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_projected_fem.cc:504
getfem::new_projected_fem
pfem new_projected_fem(const mesh_fem &mf_source, const mesh_im &mim_target, size_type rg_source_=size_type(-1), size_type rg_target_=size_type(-1), dal::bit_vector blocked_dofs=dal::bit_vector(), bool store_val=true)
create a new projected FEM.
Definition: getfem_projected_fem.cc:881
getfem::projected_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_projected_fem.cc:322