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