GetFEM  5.5
getfem_mat_elem_type.h
Go to the documentation of this file.
1 /* -*- c++ -*- (enables emacs c++ mode) */
2 /*===========================================================================
3 
4  Copyright (C) 2000-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 /**@file getfem_mat_elem_type.h
31  @author Yves Renard <Yves.Renard@insa-lyon.fr>
32  @date December 21, 2000.
33  @brief Build elementary tensors descriptors, used by generic assembly.
34 */
35 
36 #ifndef GETFEM_MAT_ELEM_TYPE_H__
37 #define GETFEM_MAT_ELEM_TYPE_H__
38 
39 #include "getfem_config.h"
40 #include "getfem_integration.h"
41 #include "getfem_fem.h"
42 
43 namespace getfem {
44 
45  enum constituant_type
46  { GETFEM_BASE_, GETFEM_GRAD_, GETFEM_HESSIAN_, GETFEM_NONLINEAR_,
47  GETFEM_UNIT_NORMAL_, GETFEM_GRAD_GEOTRANS_, GETFEM_GRAD_GEOTRANS_INV_ };
48 
49  class mat_elem_type;
50  typedef std::shared_ptr<const mat_elem_type> pmat_elem_type;
51 
52  /**
53  abstract class for integration of non-linear terms into the mat_elem
54  computations
55  the nonlinear term is added into the mat_elem_type via mat_elem_nonlinear
56 
57  When this object is destroyed, its destructor will remove all
58  references to it from its internal structures.
59 
60  The object must depend on one pfem (and may depend on other optional pfem)
61 
62  During elementary computations, the function "prepare" is called
63  for each optional pfem. Then the method "compute" is called with
64  the main fem context.
65  */
67  mutable std::set<pmat_elem_type> melt_list; /* list of melt that will
68  * be destroyed by
69  * ~nonlinear_elem_term */
70  mutable size_type term_num_;
71 
72  public :
73  virtual const bgeot::multi_index &sizes(size_type icv) const = 0;
74  virtual void compute(fem_interpolation_context& /*ctx*/,
75  base_tensor &/*output*/) = 0;
76  virtual void prepare(fem_interpolation_context& /*ctx*/,
77  size_type /*nl_part*/) {}
78  virtual ~nonlinear_elem_term();
79  size_type &term_num(void) const { return term_num_; }
80  void register_mat_elem(pmat_elem_type p) /* internal use */
81  { melt_list.insert(p); }
82  };
83 
85 
86  struct constituant {
87  constituant_type t;
88  pfem pfi;
89  unsigned nl_part; /* only useful with GETFEM_NONLINEAR_ : since the
90  nonlinear term may use more than one pfem, it will
91  be splitted into one "constituant" per fem
92  for (nl_part = 0), the mat_elem_* computations will
93  call nlt->compute,
94  for (nl_part != 0) they will call
95  nlt->prepare(ctx,nl_part)
96  */
98  };
99 
100  /** Description of an elementary matrix. This class
101  * is not to be manipulate by itself. Use pmat_elem_type and
102  * the functions written to produce those descriptions.
103  */
105  : virtual public dal::static_stored_object, public std::vector<constituant> {
106  protected :
107  bgeot::multi_index mi;
108  public :
109  bgeot::multi_index sizes(size_type) const;
110  bgeot::multi_index &get_mi(void) { return mi; }
111  const bgeot::multi_index &get_mi(void) const { return mi; }
112  mat_elem_type() { DAL_STORED_OBJECT_DEBUG_CREATED(this, "Mat elem type"); }
113  mat_elem_type(const mat_elem_type &o)
114  : std::vector<constituant>(o), mi(o.mi)
115  { DAL_STORED_OBJECT_DEBUG_CREATED(this, "Mat elem type"); }
116  ~mat_elem_type()
117  { DAL_STORED_OBJECT_DEBUG_DESTROYED(this, "Mat elem type"); }
118  };
119 
120  /** @name functions on elementary matrix descriptions
121  */
122  //@{
123 
124 
125  /** Give a pointer to the structure describing the elementary matrix
126  * which compute the integral of the basic functions described by pfi.
127  */
128  pmat_elem_type mat_elem_base(pfem pfi);
129  /** Give a pointer to the structure describing the elementary matrix
130  * which compute the integral of the gradient of the basic functions
131  * described by pfi.
132  */
133  pmat_elem_type mat_elem_grad(pfem pfi);
134  /** Give a pointer to the structure describing the elementary matrix
135  * which compute the unit normal on the boundary of the element
136  */
137  pmat_elem_type mat_elem_unit_normal(void);
138  /**
139  Return the gradient of the geometrical transformation ("K" in
140  the getfem++ kernel doc.), or its pseudo-inverse (transposed(B) in the
141  getfem++ kernel doc.).
142  */
143  pmat_elem_type mat_elem_grad_geotrans(bool inverted);
144  /** Give a pointer to the structure describing the elementary matrix
145  * which compute the integral of the hessian of the basic functions
146  * described by pfi.
147  */
148  pmat_elem_type mat_elem_hessian(pfem pfi);
149  /** Give a pointer to the structure describing the elementary
150  matrix which compute the integral of a nonlinear term.
151 
152  The pnonlinear_elem_term must not be destroyed, at any time!
153  vector pfi can not be empty pfi[0] is the main fem for the
154  pnonlinear_term.
155 
156  During computations of elementary tensors in getfem_mat_elem.C,
157  pnonlinear_elem_term->prepare() will be called for each pfi[i>=1],
158  and then
159  pnonlinear_elem_term->compute() will be called for pfi[0]
160  */
162  std::vector<pfem> pfi);
163 
164  /** Give a pointer to the structure describing the elementary matrix
165  * which computes the integral of product described by
166  * *a and *b.
167  */
168  pmat_elem_type mat_elem_product(pmat_elem_type a, pmat_elem_type b);
169 
170  pmat_elem_type mat_elem_empty();
171  //@}
172 
173 } /* end of namespace getfem. */
174 
175 
176 #endif /* GETFEM_PRE_INTERPOLATION_H__ */
base class for static stored objects
structure passed as the argument of fem interpolation functions.
Definition: getfem_fem.h:749
Description of an elementary matrix.
abstract class for integration of non-linear terms into the mat_elem computations the nonlinear term ...
defines and typedefs for namespace getfem
Definition of the finite element methods.
Integration methods (exact and approximated) on convexes.
std::shared_ptr< const getfem::virtual_fem > pfem
type of pointer on a fem description
Definition: getfem_fem.h:243
size_t size_type
used as the common size type in the library
Definition: bgeot_poly.h:48
GEneric Tool for Finite Element Methods.
pmat_elem_type mat_elem_unit_normal(void)
Give a pointer to the structure describing the elementary matrix which compute the unit normal on the...
pmat_elem_type mat_elem_hessian(pfem pfi)
Give a pointer to the structure describing the elementary matrix which compute the integral of the he...
pmat_elem_type mat_elem_nonlinear(pnonlinear_elem_term, std::vector< pfem > pfi)
Give a pointer to the structure describing the elementary matrix which compute the integral of a nonl...
pmat_elem_type mat_elem_base(pfem pfi)
Give a pointer to the structure describing the elementary matrix which compute the integral of the ba...
pmat_elem_type mat_elem_grad_geotrans(bool inverted)
Return the gradient of the geometrical transformation ("K" in the getfem++ kernel doc....
pmat_elem_type mat_elem_product(pmat_elem_type a, pmat_elem_type b)
Give a pointer to the structure describing the elementary matrix which computes the integral of produ...
pmat_elem_type mat_elem_grad(pfem pfi)
Give a pointer to the structure describing the elementary matrix which compute the integral of the gr...