GetFEM  5.5
getfem_partial_mesh_fem.h
Go to the documentation of this file.
1 /* -*- c++ -*- (enables emacs c++ mode) */
2 /*===========================================================================
3 
4  Copyright (C) 2006-2026 Yves Renard, Julien Pommier
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, see https://www.gnu.org/licenses/.
19 
20  As a special exception, you may use this file as it is a part of a free
21  software library without restriction. Specifically, if other files
22  instantiate templates or use macros or inline functions from this file,
23  or you compile this file and link it with other files to produce an
24  executable, this file does not by itself cause the resulting executable
25  to be covered by the GNU Lesser General Public License. This exception
26  does not however invalidate any other reasons why the executable file
27  might be covered by the GNU Lesser General Public License.
28 
29 ===========================================================================*/
30 
31 /**@file getfem_partial_mesh_fem.h
32  @author Yves Renard <Yves.Renard@insa-lyon.fr>,
33  @author Julien Pommier <Julien.Pommier@insa-toulouse.fr>
34  @date June 08, 2006.
35  @brief a subclass of getfem::mesh_fem which allows to eliminate a number
36  of dof of the original mesh_fem.
37 
38  This elimination is done via the pseudo-fem getfem::partial_fem,
39  hence it is not very efficient.
40 */
41 
42 #ifndef GETFEM_PARTIAL_MESH_FEM_H__
43 #define GETFEM_PARTIAL_MESH_FEM_H__
44 
45 #include "getfem_mesh_fem.h"
46 #include "getfem_mesh_im.h"
47 
48 
49 namespace getfem {
50  /**
51  a subclass of mesh_fem which allows to eliminate a number of dof
52  of the original mesh_fem.
53  */
54  class partial_mesh_fem : public mesh_fem {
55  protected :
56  const mesh_fem &mf;
57  mutable bool is_adapted;
58 
59  public :
60  void update_from_context(void) const
61  { mf.context_check(); is_adapted = false; }
62 
63  /** build the mesh_fem keeping only the dof of the original
64  mesh_fem which are listed in kept_dof. */
65  void adapt(const dal::bit_vector &kept_dof,
66  const dal::bit_vector &rejected_elt = dal::bit_vector());
67  void clear(void);
68 
70  { return mf.fem_of_element(cv); }
71 
72  virtual dim_type get_qdim() const { return mf.get_qdim(); }
73  virtual const bgeot::multi_index &get_qdims() const
74  { return mf.get_qdims(); }
75 
76  virtual bool is_uniform() const { return mf.is_uniform(); }
77  virtual bool is_uniformly_vectorized() const
78  { return mf.is_uniformly_vectorized(); }
79 
80  virtual void set_qdim(dim_type) {
81  GMM_ASSERT1(false, "The Qdim of a partial_mesh_fem is the same as "
82  "the original fem");
83  }
84 
85  virtual void set_qdim(dim_type, dim_type) {
86  GMM_ASSERT1(false, "The Qdim of a partial_mesh_fem is the same as "
87  "the original fem");
88  }
89 
90  virtual void set_qdim(dim_type, dim_type, dim_type, dim_type) {
91  GMM_ASSERT1(false, "The Qdim of a partial_mesh_fem is the same as "
92  "the original fem");
93  }
94 
95  virtual void set_qdim(const bgeot::multi_index &) {
96  GMM_ASSERT1(false, "The Qdim of a partial_mesh_fem is the same as "
97  "the original fem");
98  }
99 
100  const mesh_fem &linked_mesh_fem() const { return mf; }
101 
102  ind_dof_ct ind_basic_dof_of_element(size_type cv) const
103  { return mf.ind_basic_dof_of_element(cv); }
104 
105  const std::vector<size_type> &
106  ind_scalar_basic_dof_of_element(size_type cv) const
107  { return mf.ind_scalar_basic_dof_of_element(cv); }
108 
109  ind_dof_face_ct
111  { return mf.ind_basic_dof_of_face_of_element(cv, f); }
112 
114  { return mf.nb_basic_dof_of_face_of_element(cv, f); }
115 
117  { return mf.nb_basic_dof_of_element(cv); }
118 
119  base_node point_of_basic_dof(size_type cv, size_type i) const
120  { return mf.point_of_basic_dof(cv, i); }
121 
122  base_node point_of_basic_dof(size_type d) const
123  { return mf.point_of_basic_dof(d); }
124 
125  dim_type basic_dof_qdim(size_type d) const
126  { return mf.basic_dof_qdim(d); }
127 
129  { return mf.first_convex_of_basic_dof(d); }
130 
131  const mesh::ind_cv_ct &convex_to_basic_dof(size_type d) const
132  { return mf.convex_to_basic_dof(d); }
133 
134  size_type nb_dof(void) const {
135  context_check();
136  return use_reduction ? gmm::mat_nrows(R_) : mf.nb_dof();
137  }
138 
140  { return mf.nb_basic_dof(); }
141 
142  dal::bit_vector basic_dof_on_region(const mesh_region &b) const
143  { return mf.basic_dof_on_region(b); }
144 
145  // invalid function for a mesh change.
146  // dal::bit_vector retrieve_kept_dofs() const;
147 
148  void read_from_file(std::istream &)
149  { GMM_ASSERT1(false, "You cannot directly read this kind of mesh_fem"); }
150  void write_to_file(std::ostream &ost) const;
151  void write_to_file(const std::string &name, bool with_mesh=false) const;
152 
153  partial_mesh_fem(const mesh_fem &mef);
154  partial_mesh_fem(const mesh_fem *mef);
155 
156  partial_mesh_fem(const partial_mesh_fem&) = delete;
157  partial_mesh_fem& operator = (const partial_mesh_fem&) = delete;
158 
159  };
160 
161  typedef std::shared_ptr<partial_mesh_fem> ppartial_mesh_fem;
162 
163  /**
164  @brief Return a selection of dof who contribute significantly to the
165  mass-matrix that would be computed with mf and the integration method mim.
166 
167  P represents the dimension on what the integration method operates
168  (default mf.linked_mesh().dim()).
169 
170  An example of use can be found in the contrib/xfem_contact/ directory.
171 
172  A more efficient algorithm is now present in gmm_range_basis.h
173  */
174  dal::bit_vector select_dofs_from_im(const mesh_fem &mf, const mesh_im &mim,
175  unsigned P = unsigned(-1));
176 
177 
178 } /* end of namespace getfem. */
179 
180 #endif
181 
bool context_check() const
return true if update_from_context was called
Describe a finite element method linked to a mesh.
virtual ind_dof_ct ind_basic_dof_of_element(size_type cv) const
Give an array of the dof numbers a of convex.
virtual size_type first_convex_of_basic_dof(size_type d) const
Shortcut for convex_to_dof(d)[0].
virtual dim_type get_qdim() const
Return the Q dimension.
virtual size_type nb_dof() const
Return the total number of degrees of freedom.
virtual dim_type basic_dof_qdim(size_type d) const
Return the dof component number (0<= x <Qdim)
virtual size_type nb_basic_dof() const
Return the total number of basic degrees of freedom (before the optional reduction).
virtual dal::bit_vector basic_dof_on_region(const mesh_region &b) const
Get a list of basic dof lying on a given mesh_region.
virtual ind_dof_face_ct ind_basic_dof_of_face_of_element(size_type cv, short_type f) const
Give an array of the dof numbers lying of a convex face (all degrees of freedom whose associated base...
virtual base_node point_of_basic_dof(size_type cv, size_type i) const
Return the geometrical location of a degree of freedom.
virtual size_type nb_basic_dof_of_face_of_element(size_type cv, short_type f) const
Return the number of dof lying on the given convex face.
virtual pfem fem_of_element(size_type cv) const
Return the basic fem associated with an element (if no fem is associated, the function will crash!...
virtual size_type nb_basic_dof_of_element(size_type cv) const
Return the number of degrees of freedom attached to a given convex.
virtual const mesh::ind_cv_ct & convex_to_basic_dof(size_type d) const
Return the list of convexes attached to the specified dof.
structure used to hold a set of convexes and/or convex faces.
a subclass of mesh_fem which allows to eliminate a number of dof of the original mesh_fem.
virtual void set_qdim(dim_type)
Change the Q dimension.
size_type nb_basic_dof_of_element(size_type cv) const
Return the number of degrees of freedom attached to a given convex.
dal::bit_vector basic_dof_on_region(const mesh_region &b) const
Get a list of basic dof lying on a given mesh_region.
ind_dof_ct ind_basic_dof_of_element(size_type cv) const
Give an array of the dof numbers a of convex.
void write_to_file(std::ostream &ost) const
Write the mesh_fem to a stream.
void read_from_file(std::istream &)
Read the mesh_fem from a stream.
pfem fem_of_element(size_type cv) const
Return the basic fem associated with an element (if no fem is associated, the function will crash!...
void adapt(const dal::bit_vector &kept_dof, const dal::bit_vector &rejected_elt=dal::bit_vector())
build the mesh_fem keeping only the dof of the original mesh_fem which are listed in kept_dof.
size_type nb_dof(void) const
Return the total number of degrees of freedom.
virtual void set_qdim(dim_type, dim_type)
Set the dimension for a matrix field.
size_type nb_basic_dof(void) const
Return the total number of basic degrees of freedom (before the optional reduction).
const mesh::ind_cv_ct & convex_to_basic_dof(size_type d) const
Return the list of convexes attached to the specified dof.
ind_dof_face_ct ind_basic_dof_of_face_of_element(size_type cv, short_type f) const
Give an array of the dof numbers lying of a convex face (all degrees of freedom whose associated base...
dim_type basic_dof_qdim(size_type d) const
Return the dof component number (0<= x <Qdim)
virtual void set_qdim(dim_type, dim_type, dim_type, dim_type)
Set the dimension for a fourth order tensor field.
void update_from_context(void) const
this function has to be defined and should update the object when the context is modified.
size_type nb_basic_dof_of_face_of_element(size_type cv, short_type f) const
Return the number of dof lying on the given convex face.
size_type first_convex_of_basic_dof(size_type d) const
Shortcut for convex_to_dof(d)[0].
virtual void set_qdim(const bgeot::multi_index &)
Set the dimension for an arbitrary order tensor field.
virtual dim_type get_qdim() const
Return the Q dimension.
base_node point_of_basic_dof(size_type cv, size_type i) const
Return the geometrical location of a degree of freedom.
Define the getfem::mesh_fem class.
Define the getfem::mesh_im class (integration of getfem::mesh_fem).
std::shared_ptr< const getfem::virtual_fem > pfem
type of pointer on a fem description
Definition: getfem_fem.h:243
gmm::uint16_type short_type
used as the common short type integer in the library
Definition: bgeot_config.h:72
size_t size_type
used as the common size type in the library
Definition: bgeot_poly.h:48
GEneric Tool for Finite Element Methods.
dal::bit_vector select_dofs_from_im(const mesh_fem &mf, const mesh_im &mim, unsigned P=unsigned(-1))
Return a selection of dof who contribute significantly to the mass-matrix that would be computed with...