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