GetFEM  5.4.2
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  ind_dof_ct ind_basic_dof_of_element(size_type cv) const
102  { return mf.ind_basic_dof_of_element(cv); }
103 
104  const std::vector<size_type> &
105  ind_scalar_basic_dof_of_element(size_type cv) const
106  { return mf.ind_scalar_basic_dof_of_element(cv); }
107 
108  ind_dof_face_ct
110  { return mf.ind_basic_dof_of_face_of_element(cv, f); }
111 
113  { return mf.nb_basic_dof_of_face_of_element(cv, f); }
114 
116  { return mf.nb_basic_dof_of_element(cv); }
117 
118  base_node point_of_basic_dof(size_type cv, size_type i) const
119  { return mf.point_of_basic_dof(cv, i); }
120 
121  base_node point_of_basic_dof(size_type d) const
122  { return mf.point_of_basic_dof(d); }
123 
124  dim_type basic_dof_qdim(size_type d) const
125  { return mf.basic_dof_qdim(d); }
126 
128  { return mf.first_convex_of_basic_dof(d); }
129 
130  const mesh::ind_cv_ct &convex_to_basic_dof(size_type d) const
131  { return mf.convex_to_basic_dof(d); }
132 
133  size_type nb_dof(void) const {
134  context_check();
135  return use_reduction ? gmm::mat_nrows(R_) : mf.nb_dof();
136  }
137 
139  { return mf.nb_basic_dof(); }
140 
141  dal::bit_vector basic_dof_on_region(const mesh_region &b) const
142  { return mf.basic_dof_on_region(b); }
143 
144  // invalid function for a mesh change.
145  // dal::bit_vector retrieve_kept_dofs() const;
146 
147  void read_from_file(std::istream &)
148  { GMM_ASSERT1(false, "You cannot directly read this kind of mesh_fem"); }
149  void write_to_file(std::ostream &ost) const;
150  void write_to_file(const std::string &name, bool with_mesh=false) const;
151 
152  partial_mesh_fem(const mesh_fem &mef);
153  partial_mesh_fem(const mesh_fem *mef);
154 
155  partial_mesh_fem(const partial_mesh_fem&) = delete;
156  partial_mesh_fem& operator = (const partial_mesh_fem&) = delete;
157 
158  };
159 
160  typedef std::shared_ptr<partial_mesh_fem> ppartial_mesh_fem;
161 
162  /**
163  @brief Return a selection of dof who contribute significantly to the
164  mass-matrix that would be computed with mf and the integration method mim.
165 
166  P represents the dimension on what the integration method operates
167  (default mf.linked_mesh().dim()).
168 
169  An example of use can be found in the contrib/xfem_contact/ directory.
170 
171  A more efficient algorithm is now present in gmm_range_basis.h
172  */
173  dal::bit_vector select_dofs_from_im(const mesh_fem &mf, const mesh_im &mim,
174  unsigned P = unsigned(-1));
175 
176 
177 } /* end of namespace getfem. */
178 
179 #endif
180 
getfem::partial_mesh_fem::adapt
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.
Definition: getfem_partial_mesh_fem.cc:41
getfem::partial_mesh_fem
a subclass of mesh_fem which allows to eliminate a number of dof of the original mesh_fem.
Definition: getfem_partial_mesh_fem.h:55
getfem::mesh_fem::get_qdim
virtual dim_type get_qdim() const
Return the Q dimension.
Definition: getfem_mesh_fem.h:312
getfem::partial_mesh_fem::set_qdim
virtual void set_qdim(const bgeot::multi_index &)
Set the dimension for an arbitrary order tensor field.
Definition: getfem_partial_mesh_fem.h:96
getfem::partial_mesh_fem::write_to_file
void write_to_file(std::ostream &ost) const
Write the mesh_fem to a stream.
Definition: getfem_partial_mesh_fem.cc:97
getfem::mesh_fem::convex_to_basic_dof
virtual const mesh::ind_cv_ct & convex_to_basic_dof(size_type d) const
Return the list of convexes attached to the specified dof.
Definition: getfem_mesh_fem.cc:267
getfem::mesh_fem::first_convex_of_basic_dof
virtual size_type first_convex_of_basic_dof(size_type d) const
Shortcut for convex_to_dof(d)[0].
Definition: getfem_mesh_fem.cc:258
bgeot::size_type
size_t size_type
used as the common size type in the library
Definition: bgeot_poly.h:49
getfem::partial_mesh_fem::nb_dof
size_type nb_dof(void) const
Return the total number of degrees of freedom.
Definition: getfem_partial_mesh_fem.h:133
getfem::mesh_fem::basic_dof_qdim
virtual dim_type basic_dof_qdim(size_type d) const
Return the dof component number (0<= x <Qdim)
Definition: getfem_mesh_fem.cc:245
getfem::partial_mesh_fem::first_convex_of_basic_dof
size_type first_convex_of_basic_dof(size_type d) const
Shortcut for convex_to_dof(d)[0].
Definition: getfem_partial_mesh_fem.h:127
getfem::partial_mesh_fem::convex_to_basic_dof
const mesh::ind_cv_ct & convex_to_basic_dof(size_type d) const
Return the list of convexes attached to the specified dof.
Definition: getfem_partial_mesh_fem.h:130
getfem::mesh_fem::fem_of_element
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!...
Definition: getfem_mesh_fem.h:444
getfem::mesh_fem
Describe a finite element method linked to a mesh.
Definition: getfem_mesh_fem.h:148
getfem::mesh_fem::ind_basic_dof_of_face_of_element
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...
Definition: getfem_mesh_fem.h:468
getfem::partial_mesh_fem::point_of_basic_dof
base_node point_of_basic_dof(size_type cv, size_type i) const
Return the geometrical location of a degree of freedom.
Definition: getfem_partial_mesh_fem.h:118
getfem::partial_mesh_fem::set_qdim
virtual void set_qdim(dim_type)
Change the Q dimension.
Definition: getfem_partial_mesh_fem.h:81
bgeot::short_type
gmm::uint16_type short_type
used as the common short type integer in the library
Definition: bgeot_config.h:72
getfem::partial_mesh_fem::nb_basic_dof
size_type nb_basic_dof(void) const
Return the total number of basic degrees of freedom (before the optional reduction).
Definition: getfem_partial_mesh_fem.h:138
getfem
GEneric Tool for Finite Element Methods.
Definition: getfem_accumulated_distro.h:46
getfem::mesh_fem::basic_dof_on_region
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.
Definition: getfem_mesh_fem.cc:77
getfem::partial_mesh_fem::nb_basic_dof_of_face_of_element
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.
Definition: getfem_partial_mesh_fem.h:112
getfem::mesh_fem::nb_basic_dof_of_element
virtual size_type nb_basic_dof_of_element(size_type cv) const
Return the number of degrees of freedom attached to a given convex.
Definition: getfem_mesh_fem.h:494
getfem::mesh_fem::nb_basic_dof
virtual size_type nb_basic_dof() const
Return the total number of basic degrees of freedom (before the optional reduction).
Definition: getfem_mesh_fem.h:556
getfem::partial_mesh_fem::nb_basic_dof_of_element
size_type nb_basic_dof_of_element(size_type cv) const
Return the number of degrees of freedom attached to a given convex.
Definition: getfem_partial_mesh_fem.h:115
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::partial_mesh_fem::set_qdim
virtual void set_qdim(dim_type, dim_type, dim_type, dim_type)
Set the dimension for a fourth order tensor field.
Definition: getfem_partial_mesh_fem.h:91
getfem::select_dofs_from_im
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...
Definition: getfem_partial_mesh_fem.cc:116
getfem::pfem
std::shared_ptr< const getfem::virtual_fem > pfem
type of pointer on a fem description
Definition: getfem_fem.h:244
getfem::partial_mesh_fem::read_from_file
void read_from_file(std::istream &)
Read the mesh_fem from a stream.
Definition: getfem_partial_mesh_fem.h:147
getfem::partial_mesh_fem::basic_dof_on_region
dal::bit_vector basic_dof_on_region(const mesh_region &b) const
Get a list of basic dof lying on a given mesh_region.
Definition: getfem_partial_mesh_fem.h:141
getfem::partial_mesh_fem::get_qdim
virtual dim_type get_qdim() const
Return the Q dimension.
Definition: getfem_partial_mesh_fem.h:73
getfem::partial_mesh_fem::fem_of_element
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!...
Definition: getfem_partial_mesh_fem.h:70
getfem::partial_mesh_fem::ind_basic_dof_of_face_of_element
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...
Definition: getfem_partial_mesh_fem.h:109
getfem::partial_mesh_fem::set_qdim
virtual void set_qdim(dim_type, dim_type)
Set the dimension for a matrix field.
Definition: getfem_partial_mesh_fem.h:86
getfem::mesh_fem::point_of_basic_dof
virtual base_node point_of_basic_dof(size_type cv, size_type i) const
Return the geometrical location of a degree of freedom.
Definition: getfem_mesh_fem.cc:223
getfem::partial_mesh_fem::update_from_context
void update_from_context(void) const
this function has to be defined and should update the object when the context is modified.
Definition: getfem_partial_mesh_fem.h:61
getfem::mesh_fem::ind_basic_dof_of_element
virtual ind_dof_ct ind_basic_dof_of_element(size_type cv) const
Give an array of the dof numbers a of convex.
Definition: getfem_mesh_fem.h:450
getfem::mesh_region
structure used to hold a set of convexes and/or convex faces.
Definition: getfem_mesh_region.h:55
getfem::context_dependencies::context_check
bool context_check() const
return true if update_from_context was called
Definition: getfem_context.h:126
getfem::partial_mesh_fem::ind_basic_dof_of_element
ind_dof_ct ind_basic_dof_of_element(size_type cv) const
Give an array of the dof numbers a of convex.
Definition: getfem_partial_mesh_fem.h:101
getfem::mesh_fem::nb_dof
virtual size_type nb_dof() const
Return the total number of degrees of freedom.
Definition: getfem_mesh_fem.h:562
getfem::mesh_fem::nb_basic_dof_of_face_of_element
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.
Definition: getfem_mesh_fem.h:481
getfem::partial_mesh_fem::basic_dof_qdim
dim_type basic_dof_qdim(size_type d) const
Return the dof component number (0<= x <Qdim)
Definition: getfem_partial_mesh_fem.h:124