GetFEM++  5.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-2017 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, public boost::noncopyable {
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 bgeot::mesh_structure::ind_cv_ct &
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  };
156 
157  typedef std::shared_ptr<partial_mesh_fem> ppartial_mesh_fem;
158 
159  /**
160  @brief Return a selection of dof who contribute significantly to the
161  mass-matrix that would be computed with mf and the integration method mim.
162 
163  P represents the dimension on what the integration method operates
164  (default mf.linked_mesh().dim()).
165 
166  An example of use can be found in the contrib/xfem_contact/ directory.
167 
168  A more efficient algorithm is now present in gmm_range_basis.h
169  */
170  dal::bit_vector select_dofs_from_im(const mesh_fem &mf, const mesh_im &mim,
171  unsigned P = unsigned(-1));
172 
173 
174 } /* end of namespace getfem. */
175 
176 #endif
177 
virtual dim_type get_qdim() const
Return the Q dimension.
virtual size_type nb_basic_dof_of_element(size_type cv) const
Return the number of degrees of freedom attached to a given convex.
size_type first_convex_of_basic_dof(size_type d) const
Shortcut for convex_to_dof(d)[0].
void write_to_file(std::ostream &ost) const
Write the mesh_fem to a stream.
virtual size_type nb_dof() const
Return the total number of degrees of freedom.
base_node point_of_basic_dof(size_type cv, size_type i) const
Return the geometrical location of a degree of freedom.
structure used to hold a set of convexes and/or convex faces.
dal::bit_vector basic_dof_on_region(const mesh_region &b) const
Get a list of basic dof lying on a given mesh_region.
void read_from_file(std::istream &)
Read the mesh_fem from a stream.
virtual 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)
Set the dimension for a matrix field.
ind_dof_ct ind_basic_dof_of_element(size_type cv) const
Give an array of the dof numbers a of convex.
Define the getfem::mesh_im class (integration of getfem::mesh_fem).
Define the getfem::mesh_fem class.
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! us...
Describe an integration method linked to a mesh.
virtual const mesh::ind_cv_ct & convex_to_basic_dof(size_type d) const
Return the list of convexes attached to the specified dof.
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! us...
const mesh::ind_cv_ct & convex_to_basic_dof(size_type d) const
Return the list of convexes attached to the specified dof.
size_t size_type
used as the common size type in the library
Definition: bgeot_poly.h:49
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 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 dim_type get_qdim() const
Return the Q dimension.
virtual base_node point_of_basic_dof(size_type cv, size_type i) const
Return the geometrical location of a degree of freedom.
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...
base_node point_of_basic_dof(size_type d) const
Return the geometrical location of a degree of freedom.
GEneric Tool for Finite Element Methods.
virtual void set_qdim(const bgeot::multi_index &)
Set the dimension for an arbitrary order tensor field.
std::shared_ptr< const getfem::virtual_fem > pfem
type of pointer on a fem description
Definition: getfem_fem.h:239
size_type nb_basic_dof(void) const
Return the total number of basic degrees of freedom (before the optional reduction).
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
virtual size_type first_convex_of_basic_dof(size_type d) const
Shortcut for convex_to_dof(d)[0].
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 nb_dof(void) const
Return the total number of degrees of freedom.
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_element(size_type cv) const
Return the number of degrees of freedom attached to a given convex.
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 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...
a subclass of mesh_fem which allows to eliminate a number of dof of the original mesh_fem.
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...
bool context_check() const
return true if update_from_context was called
virtual ind_dof_ct ind_basic_dof_of_element(size_type cv) const
Give an array of the dof numbers a of convex.
dim_type basic_dof_qdim(size_type d) const
Return the dof component number (0<= x <Qdim)
virtual void set_qdim(dim_type)
Change the Q dimension.
virtual void set_qdim(dim_type, dim_type, dim_type, dim_type)
Set the dimension for a fourth order tensor field.