GetFEM  5.4.3
getfem_partial_mesh_fem.h
Go to the documentation of this file.
1 /* -*- c++ -*- (enables emacs c++ mode) */
2 /*===========================================================================
3 
4  Copyright (C) 2006-2020 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, 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 
32 /**@file getfem_partial_mesh_fem.h
33  @author Yves Renard <Yves.Renard@insa-lyon.fr>,
34  @author Julien Pommier <Julien.Pommier@insa-toulouse.fr>
35  @date June 08, 2006.
36  @brief a subclass of getfem::mesh_fem which allows to eliminate a number
37  of dof of the original mesh_fem.
38 
39  This elimination is done via the pseudo-fem getfem::partial_fem,
40  hence it is not very efficient.
41 */
42 
43 #ifndef GETFEM_PARTIAL_MESH_FEM_H__
44 #define GETFEM_PARTIAL_MESH_FEM_H__
45 
46 #include "getfem_mesh_fem.h"
47 #include "getfem_mesh_im.h"
48 
49 
50 namespace getfem {
51  /**
52  a subclass of mesh_fem which allows to eliminate a number of dof
53  of the original mesh_fem.
54  */
55  class partial_mesh_fem : public mesh_fem {
56  protected :
57  const mesh_fem &mf;
58  mutable bool is_adapted;
59 
60  public :
61  void update_from_context(void) const
62  { mf.context_check(); is_adapted = false; }
63 
64  /** build the mesh_fem keeping only the dof of the original
65  mesh_fem which are listed in kept_dof. */
66  void adapt(const dal::bit_vector &kept_dof,
67  const dal::bit_vector &rejected_elt = dal::bit_vector());
68  void clear(void);
69 
71  { return mf.fem_of_element(cv); }
72 
73  virtual dim_type get_qdim() const { return mf.get_qdim(); }
74  virtual const bgeot::multi_index &get_qdims() const
75  { return mf.get_qdims(); }
76 
77  virtual bool is_uniform() const { return mf.is_uniform(); }
78  virtual bool is_uniformly_vectorized() const
79  { return mf.is_uniformly_vectorized(); }
80 
81  virtual void set_qdim(dim_type) {
82  GMM_ASSERT1(false, "The Qdim of a partial_mesh_fem is the same as "
83  "the original fem");
84  }
85 
86  virtual void set_qdim(dim_type, dim_type) {
87  GMM_ASSERT1(false, "The Qdim of a partial_mesh_fem is the same as "
88  "the original fem");
89  }
90 
91  virtual void set_qdim(dim_type, dim_type, dim_type, dim_type) {
92  GMM_ASSERT1(false, "The Qdim of a partial_mesh_fem is the same as "
93  "the original fem");
94  }
95 
96  virtual void set_qdim(const bgeot::multi_index &) {
97  GMM_ASSERT1(false, "The Qdim of a partial_mesh_fem is the same as "
98  "the original fem");
99  }
100 
101  const mesh_fem &linked_mesh_fem() const { return mf; }
102 
103  ind_dof_ct ind_basic_dof_of_element(size_type cv) const
104  { return mf.ind_basic_dof_of_element(cv); }
105 
106  const std::vector<size_type> &
107  ind_scalar_basic_dof_of_element(size_type cv) const
108  { return mf.ind_scalar_basic_dof_of_element(cv); }
109 
110  ind_dof_face_ct
112  { return mf.ind_basic_dof_of_face_of_element(cv, f); }
113 
115  { return mf.nb_basic_dof_of_face_of_element(cv, f); }
116 
118  { return mf.nb_basic_dof_of_element(cv); }
119 
120  base_node point_of_basic_dof(size_type cv, size_type i) const
121  { return mf.point_of_basic_dof(cv, i); }
122 
123  base_node point_of_basic_dof(size_type d) const
124  { return mf.point_of_basic_dof(d); }
125 
126  dim_type basic_dof_qdim(size_type d) const
127  { return mf.basic_dof_qdim(d); }
128 
130  { return mf.first_convex_of_basic_dof(d); }
131 
132  const mesh::ind_cv_ct &convex_to_basic_dof(size_type d) const
133  { return mf.convex_to_basic_dof(d); }
134 
135  size_type nb_dof(void) const {
136  context_check();
137  return use_reduction ? gmm::mat_nrows(R_) : mf.nb_dof();
138  }
139 
141  { return mf.nb_basic_dof(); }
142 
143  dal::bit_vector basic_dof_on_region(const mesh_region &b) const
144  { return mf.basic_dof_on_region(b); }
145 
146  // invalid function for a mesh change.
147  // dal::bit_vector retrieve_kept_dofs() const;
148 
149  void read_from_file(std::istream &)
150  { GMM_ASSERT1(false, "You cannot directly read this kind of mesh_fem"); }
151  void write_to_file(std::ostream &ost) const;
152  void write_to_file(const std::string &name, bool with_mesh=false) const;
153 
154  partial_mesh_fem(const mesh_fem &mef);
155  partial_mesh_fem(const mesh_fem *mef);
156 
157  partial_mesh_fem(const partial_mesh_fem&) = delete;
158  partial_mesh_fem& operator = (const partial_mesh_fem&) = delete;
159 
160  };
161 
162  typedef std::shared_ptr<partial_mesh_fem> ppartial_mesh_fem;
163 
164  /**
165  @brief Return a selection of dof who contribute significantly to the
166  mass-matrix that would be computed with mf and the integration method mim.
167 
168  P represents the dimension on what the integration method operates
169  (default mf.linked_mesh().dim()).
170 
171  An example of use can be found in the contrib/xfem_contact/ directory.
172 
173  A more efficient algorithm is now present in gmm_range_basis.h
174  */
175  dal::bit_vector select_dofs_from_im(const mesh_fem &mf, const mesh_im &mim,
176  unsigned P = unsigned(-1));
177 
178 
179 } /* end of namespace getfem. */
180 
181 #endif
182 
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:244
gmm::uint16_type short_type
used as the common short type integer in the library
Definition: bgeot_config.h:73
size_t size_type
used as the common size type in the library
Definition: bgeot_poly.h:49
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...