GetFEM++  5.3
getfem_projected_fem.h
Go to the documentation of this file.
1 /* -*- c++ -*- (enables emacs c++ mode) */
2 /*===========================================================================
3 
4  Copyright (C) 2012-2017 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; // correspondance 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
76  size_type nb_dof;
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 full of
99  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(void) const;
110 
111  bool find_a_projected_point(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;
129  void real_base_value(const fem_interpolation_context& c,
130  base_tensor &t, bool = true) const;
131  void real_grad_base_value(const fem_interpolation_context& c,
132  base_tensor &t, bool = true) const;
133  void real_hess_base_value(const fem_interpolation_context&,
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  /** return the min/max/mean number of gauss points in the convexes
146  * of the projected mesh_fem */
147  void gauss_pts_stats(unsigned &ming, unsigned &maxg,
148  scalar_type &meang) const;
149  size_type memsize() const;
150 
151  projected_fem(const mesh_fem &mf_source_, const mesh_im &mim_target_,
152  size_type rg_source_, size_type rg_target_,
153  dal::bit_vector blocked_dofs_,
154  bool store_val);
155  virtual ~projected_fem()
156  { DAL_STORED_OBJECT_DEBUG_DESTROYED(this, "Projected fem"); }
157  };
158 
159 
160  /** create a new projected FEM.
161  @param mf_source the mesh_fem that will be projected.
162  @param mim_target the integration method on the final mesh (not the mesh
163  of mf_source!).
164  @param blocked_dofs list of dof of mf_source which won't be projected.
165  @param store_val if true, the values/gradients of interpolated base
166  function are cached at each gauss point (eats much memory).
167  */
168  pfem new_projected_fem(const mesh_fem &mf_source, const mesh_im &mim_target,
169  size_type rg_source_ = size_type(-1),
170  size_type rg_target_ = size_type(-1),
171  dal::bit_vector blocked_dofs = dal::bit_vector(),
172  bool store_val = true);
173 
174  /** release a projected fem */
176 
177 
178 } /* end of namespace getfem. */
179 
180 #endif
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.
FEM which interpolates the projection of a mesh_fem on a different mesh.
structure used to hold a set of convexes and/or convex faces.
Base class for finite element description.
Definition: getfem_fem.h:250
Define the getfem::mesh_im class (integration of getfem::mesh_fem).
Define the getfem::mesh_fem class.
does the inversion of the geometric transformation for a given convex
void del_stored_object(const pstatic_stored_object &o, bool ignore_unstored)
Delete an object and the object which depend on it.
Describe an integration method linked to a mesh.
Balanced tree over a set of points.
Definition: bgeot_kdtree.h:103
size_t size_type
used as the common size type in the library
Definition: bgeot_poly.h:49
Inversion of geometric transformations.
structure passed as the argument of fem interpolation functions.
Definition: getfem_fem.h:741
void del_projected_fem(pfem pf)
release a projected fem
Deal with interdependencies of objects.
GEneric Tool for Finite Element Methods.
std::shared_ptr< const getfem::virtual_fem > pfem
type of pointer on a fem description
Definition: getfem_fem.h:239
Describe a finite element method linked to a mesh.
gmm::uint16_type short_type
used as the common short type integer in the library
Definition: bgeot_config.h:79
Definition of the finite element methods.
Simple implementation of a KD-tree.