GetFEM  5.4.3
getfem_mesh_fem_sum.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_mesh_fem_sum.h
32  @author Yves Renard <Yves.Renard@insa-lyon.fr>
33  @author Julien Pommier <Julien.Pommier@insa-toulouse.fr>
34  @date March 18, 2005.
35  @brief Implement a special mesh_fem with merges the FEMs of two
36  (or more) mesh_fems.
37 */
38 
39 #ifndef GETFEM_MESH_SUM_H__
40 #define GETFEM_MESH_SUM_H__
41 
42 #include "getfem_mesh_fem.h"
43 
44 namespace getfem {
45 
46  /** @internal FEM used in mesh_fem_sum objects. */
47  class fem_sum : public virtual_fem {
48  std::vector<pfem> pfems; /* the fems to be summed */
49  bool smart_global_dof_linking_;
50  size_type cv;
51 
52  public:
53 
54  size_type index_of_global_dof(size_type cv_, size_type j) const;
55  fem_sum(const std::vector<pfem> &pfs, size_type i,
56  bool smart_global_dof_linking)
57  : pfems(pfs), smart_global_dof_linking_(smart_global_dof_linking),
58  cv(i) { init(); }
59  void init();
60  void valid();
61  void base_value(const base_node &x, base_tensor &t) const;
62  void grad_base_value(const base_node &x, base_tensor &t) const;
63  void hess_base_value(const base_node &x, base_tensor &t) const;
64 
65  void real_base_value(const fem_interpolation_context& c,
66  base_tensor &t, bool = true) const;
67  void real_grad_base_value(const fem_interpolation_context& c,
68  base_tensor &t, bool = true) const;
69  void real_hess_base_value(const fem_interpolation_context& c,
70  base_tensor &t, bool = true) const;
71  void mat_trans(base_matrix &M, const base_matrix &G,
72  bgeot::pgeometric_trans pgt) const;
73  };
74 
75 
76  /** @brief Implement a special mesh_fem with merges the FEMs of
77  two (or more) mesh_fems.
78  */
79  class mesh_fem_sum : public mesh_fem {
80  protected :
81  std::vector<const mesh_fem *> mfs;
82 
83  mutable std::map< std::vector<pfem>, pfem> situations;
84  mutable std::vector<pfem> build_methods;
85  mutable bool is_adapted;
86  bool smart_global_dof_linking_;
87  void clear_build_methods();
88 
89  public :
90  void adapt();
91  void update_from_context() const { is_adapted = false; }
92  void clear();
93 
94  size_type memsize() const {
95  return mesh_fem::memsize(); // + ... ;
96  }
97 
98  mesh_fem_sum(const mesh &me, bool smart_global_dof_linking = false)
99  : mesh_fem(me), smart_global_dof_linking_(smart_global_dof_linking)
100  { is_adapted = false; }
101  void set_mesh_fems(const std::vector<const mesh_fem *> &mefs)
102  { mfs = mefs; adapt(); }
103  /** enabled "smart" dof linking between the mesh_fems.
104  It was introduced for the point-wise matching part of
105  tests/crack.cc but it does not work with discontinuous global
106  functions...
107  */
109  { smart_global_dof_linking_ = b; }
110  void set_mesh_fems(const mesh_fem &mf1)
111  { mfs.clear(); mfs.push_back(&mf1); adapt(); }
112  void set_mesh_fems(const mesh_fem &mf1, const mesh_fem &mf2)
113  { mfs.clear(); mfs.push_back(&mf1); mfs.push_back(&mf2); adapt(); }
114  void set_mesh_fems(const mesh_fem &mf1, const mesh_fem &mf2,
115  const mesh_fem &mf3) {
116  mfs.clear();
117  mfs.push_back(&mf1); mfs.push_back(&mf2); mfs.push_back(&mf3);
118  adapt();
119  }
120 
121  ~mesh_fem_sum() { clear_build_methods(); }
122  };
123 
124 
125 } /* end of namespace getfem. */
126 
127 #endif
128 
Implement a special mesh_fem with merges the FEMs of two (or more) mesh_fems.
void set_smart_global_dof_linking(bool b)
enabled "smart" dof linking between the mesh_fems.
void update_from_context() const
this function has to be defined and should update the object when the context is modified.
Describe a finite element method linked to a mesh.
Define the getfem::mesh_fem class.
std::shared_ptr< const getfem::virtual_fem > pfem
type of pointer on a fem description
Definition: getfem_fem.h:244
size_t size_type
used as the common size type in the library
Definition: bgeot_poly.h:49
std::shared_ptr< const bgeot::geometric_trans > pgeometric_trans
pointer type for a geometric transformation
GEneric Tool for Finite Element Methods.