GetFEM  5.4.3
getfem_mesh_im.h
Go to the documentation of this file.
1 /* -*- c++ -*- (enables emacs c++ mode) */
2 /*===========================================================================
3 
4  Copyright (C) 2005-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 
32 /**@file getfem_mesh_im.h
33  @author Yves Renard <Yves.Renard@insa-lyon.fr>
34  @date January 26, 2005.
35  @brief Define the getfem::mesh_im class (integration of getfem::mesh_fem).
36 */
37 #ifndef GETFEM_MESH_IM_H__
38 #define GETFEM_MESH_IM_H__
39 
40 #include "getfem_integration.h"
41 #include "getfem_fem.h"
42 #include "getfem_mesh.h"
43 
44 namespace getfem {
45 
46  /// Describe an integration method linked to a mesh.
47  class mesh_im : public context_dependencies, virtual public dal::static_stored_object {
48  private :
49  void copy_from(const mesh_im &mim);
50 
51  protected :
52  bool is_lower_dim;
54  dal::bit_vector im_convexes;
55  const mesh *linked_mesh_;
56  mutable gmm::uint64_type v_num_update, v_num;
57  pintegration_method auto_add_elt_pim; /* im for automatic addition */
58  /* of element option. (0 = no automatic addition)*/
59 
60  public :
61  void update_from_context(void) const;
62  gmm::uint64_type version_number(void) const
63  { context_check(); return v_num; }
64 
65  /** Set the im for automatic addition
66  * of element option. pim=0 disables the automatic addition.
67  */
68  void set_auto_add(pintegration_method pim)
69  { auto_add_elt_pim = pim; }
70 
71  /** Get the set of convexes where an integration method has been assigned.
72  */
73  inline const dal::bit_vector &convex_index(void) const
74  { context_check(); return im_convexes; }
75 
76  bool is_lower_dimensional() const { return is_lower_dim; }
77 
78  /// Give a reference to the linked mesh of type mesh.
79  const mesh &linked_mesh() const
80  { return linked_mesh_ ? *linked_mesh_ : dummy_mesh(); }
81  /** Set the integration method of a convex.
82 
83  @param cv the convex number
84 
85  @param pim the integration method, typically obtained with
86  @code getfem::int_method_descriptor("IM_SOMETHING(..)")
87  @endcode
88  */
89  void set_integration_method(size_type cv, pintegration_method pim);
90  /** Set the integration method on all the convexes of indexes in bv,
91  * which is of type dal::bit_vector.
92  */
93  void set_integration_method(const dal::bit_vector &cvs,
94  pintegration_method pim);
95  /** shortcut for
96  @code
97  set_integration_method(linked_mesh().convex_index(),pim);
98  and set_auto_add(pim)
99  @endcode
100  */
101  void set_integration_method(pintegration_method ppi);
102  /** Set an approximate integration method chosen to be exact for
103  polynomials of degree 'im_degree'.
104  */
105  void set_integration_method(const dal::bit_vector &cvs,
106  dim_type im_degree);
107 
108  /** Set an approximate integration method chosen to be exact for
109  polynomials of degree 'im_degree' on the whole mesh.
110  */
111  void set_integration_method(dim_type im_degree);
112 
113  /** return the integration method associated with an element (in
114  no integration is associated, the function will crash! use the
115  convex_index() of the mesh_im to check that a fem is
116  associated to a given convex) */
117  virtual pintegration_method int_method_of_element(size_type cv) const
118  { return ims[cv]; }
119  void clear(void);
120 
121  size_type memsize() const {
122  context_check();
123  return sizeof(mesh_im) + ims.memsize() + im_convexes.memsize();
124  }
125 
126  void init_with_mesh(const mesh &me);
127  mesh_im(const mesh &me);
128  mesh_im();
129  virtual ~mesh_im();
130  mesh_im(const mesh_im &mim);
131  mesh_im &operator=(const mesh_im &mim);
132 
133  /** Read the mesh_im from a stream.
134  @param ist the stream. */
135  void read_from_file(std::istream &ist);
136  /** Read the mesh_im from a file.
137  @param name the file name. */
138  void read_from_file(const std::string &name);
139  /** Write the mesh_im to a stream. */
140  void write_to_file(std::ostream &ost) const;
141  /** Write the mesh_im to a file.
142 
143  @param name the file name
144 
145  @param with_mesh if set, then the linked_mesh() will also be
146  saved to the file.
147  */
148  void write_to_file(const std::string &name, bool with_mesh=false) const;
149  };
150 
151  /** Dummy mesh_im for default parameter of functions. */
152  const mesh_im &dummy_mesh_im();
153 
154 } /* end of namespace getfem. */
155 
156 
157 #endif /* GETFEM_MESH_IM_H__ */
size_type memsize(void) const
Gives the total memory occupied by the array.
Definition: dal_basic.h:279
base class for static stored objects
Deal with interdependencies of objects.
bool context_check() const
return true if update_from_context was called
Describe an integration method linked to a mesh.
void write_to_file(std::ostream &ost) const
Write the mesh_im to a stream.
virtual pintegration_method int_method_of_element(size_type cv) const
return the integration method associated with an element (in no integration is associated,...
void update_from_context(void) const
this function has to be defined and should update the object when the context is modified.
const mesh & linked_mesh() const
Give a reference to the linked mesh of type mesh.
void set_auto_add(pintegration_method pim)
Set the im for automatic addition of element option.
const dal::bit_vector & convex_index(void) const
Get the set of convexes where an integration method has been assigned.
void read_from_file(std::istream &ist)
Read the mesh_im from a stream.
void set_integration_method(size_type cv, pintegration_method pim)
Set the integration method of a convex.
Describe a mesh (collection of convexes (elements) and points).
Definition: getfem_mesh.h:99
Definition of the finite element methods.
Integration methods (exact and approximated) on convexes.
Define a getfem::getfem_mesh object.
size_t size_type
used as the common size type in the library
Definition: bgeot_poly.h:49
GEneric Tool for Finite Element Methods.
const mesh_im & dummy_mesh_im()
Dummy mesh_im for default parameter of functions.