GetFEM  5.4.2
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  { 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  return
123  sizeof(mesh_im) +
124  ims.memsize() + im_convexes.memsize();
125  }
126 
127  void init_with_mesh(const mesh &me);
128  mesh_im(const mesh &me);
129  mesh_im();
130  virtual ~mesh_im();
131  mesh_im(const mesh_im &mim);
132  mesh_im &operator=(const mesh_im &mim);
133 
134  /** Read the mesh_im from a stream.
135  @param ist the stream. */
136  void read_from_file(std::istream &ist);
137  /** Read the mesh_im from a file.
138  @param name the file name. */
139  void read_from_file(const std::string &name);
140  /** Write the mesh_im to a stream. */
141  void write_to_file(std::ostream &ost) const;
142  /** Write the mesh_im to a file.
143 
144  @param name the file name
145 
146  @param with_mesh if set, then the linked_mesh() will also be
147  saved to the file.
148  */
149  void write_to_file(const std::string &name, bool with_mesh=false) const;
150  };
151 
152  /** Dummy mesh_im for default parameter of functions. */
153  const mesh_im &dummy_mesh_im();
154 
155 } /* end of namespace getfem. */
156 
157 
158 #endif /* GETFEM_MESH_IM_H__ */
getfem::mesh_im::convex_index
const dal::bit_vector & convex_index(void) const
Get the set of convexes where an integration method has been assigned.
Definition: getfem_mesh_im.h:73
bgeot::size_type
size_t size_type
used as the common size type in the library
Definition: bgeot_poly.h:49
getfem::mesh_im
Describe an integration method linked to a mesh.
Definition: getfem_mesh_im.h:47
getfem::mesh_im::write_to_file
void write_to_file(std::ostream &ost) const
Write the mesh_im to a stream.
Definition: getfem_mesh_im.cc:205
getfem_integration.h
Integration methods (exact and approximated) on convexes.
getfem::mesh_im::set_auto_add
void set_auto_add(pintegration_method pim)
Set the im for automatic addition of element option.
Definition: getfem_mesh_im.h:68
getfem_mesh.h
Define a getfem::getfem_mesh object.
getfem
GEneric Tool for Finite Element Methods.
Definition: getfem_accumulated_distro.h:46
dal::dynamic_array::memsize
size_type memsize(void) const
Gives the total memory occupied by the array.
Definition: dal_basic.h:273
getfem::context_dependencies
Deal with interdependencies of objects.
Definition: getfem_context.h:81
dal::dynamic_array< pintegration_method >
getfem::dummy_mesh_im
const mesh_im & dummy_mesh_im()
Dummy mesh_im for default parameter of functions.
Definition: getfem_mesh_im.cc:234
dal::static_stored_object
base class for static stored objects
Definition: dal_static_stored_objects.h:206
getfem::mesh
Describe a mesh (collection of convexes (elements) and points).
Definition: getfem_mesh.h:95
getfem::mesh_im::read_from_file
void read_from_file(std::istream &ist)
Read the mesh_im from a stream.
Definition: getfem_mesh_im.cc:154
getfem::mesh_im::linked_mesh
const mesh & linked_mesh() const
Give a reference to the linked mesh of type mesh.
Definition: getfem_mesh_im.h:79
getfem::mesh_im::int_method_of_element
virtual pintegration_method int_method_of_element(size_type cv) const
return the integration method associated with an element (in no integration is associated,...
Definition: getfem_mesh_im.h:117
getfem_fem.h
Definition of the finite element methods.
getfem::context_dependencies::context_check
bool context_check() const
return true if update_from_context was called
Definition: getfem_context.h:126
getfem::mesh_im::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_mesh_im.cc:27
getfem::mesh_im::set_integration_method
void set_integration_method(size_type cv, pintegration_method pim)
Set the integration method of a convex.
Definition: getfem_mesh_im.cc:49