GetFEM++  5.3
getfem_fem_global_function.h
Go to the documentation of this file.
1 /* -*- c++ -*- (enables emacs c++ mode) */
2 /*===========================================================================
3 
4  Copyright (C) 2004-2017 Yves Renard
5  Copyright (C) 2016 Konstantinos Poulios
6 
7  This file is a part of GetFEM++
8 
9  GetFEM++ is free software; you can redistribute it and/or modify it
10  under the terms of the GNU Lesser General Public License as published
11  by the Free Software Foundation; either version 3 of the License, or
12  (at your option) any later version along with the GCC Runtime Library
13  Exception either version 3.1 or (at your option) any later version.
14  This program is distributed in the hope that it will be useful, but
15  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17  License and GCC Runtime Library Exception for more details.
18  You should have received a copy of the GNU Lesser General Public License
19  along with this program; if not, write to the Free Software Foundation,
20  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
21 
22  As a special exception, you may use this file as it is a part of a free
23  software library without restriction. Specifically, if other files
24  instantiate templates or use macros or inline functions from this file,
25  or you compile this file and link it with other files to produce an
26  executable, this file does not by itself cause the resulting executable
27  to be covered by the GNU Lesser General Public License. This exception
28  does not however invalidate any other reasons why the executable file
29  might be covered by the GNU Lesser General Public License.
30 
31 ===========================================================================*/
32 
33 /**@file getfem_fem_global_function.h
34  @author Yves Renard <Yves.Renard@insa-lyon.fr>, J. Pommier
35  @date March, 2005.
36  @brief Define mesh_fem whose base functions are global function given by the user.
37 */
38 #ifndef GETFEM_FEM_GLOBAL_FUNCTION_H__
39 #define GETFEM_FEM_GLOBAL_FUNCTION_H__
40 
41 #include "getfem_fem.h"
42 #include "getfem_mesh_fem.h"
43 #include "getfem_global_function.h"
44 
45 namespace getfem {
46 
47  /// fem object with global basis functions.
49  protected :
50  std::vector<pglobal_function> functions;
51  const mesh &m;
52  const mesh_im &mim;
53  const bool has_mesh_im;
54 
55  mutable std::vector<std::vector<size_type> > index_of_global_dof_;
56  mutable bgeot::pstored_point_tab pspt_override;
57 
58  struct precomp_data { std::vector<base_tensor> val, grad, hess; };
59 
60  class precomp_pool
61  : virtual public dal::static_stored_object,
62  public std::vector< std::map<bgeot::pstored_point_tab,
63  precomp_data > >
64  {};
65 
66  // store values, gradients and hessians of base functions
67  mutable std::shared_ptr<precomp_pool> precomps;
68 
69  DAL_SIMPLE_KEY(precomp_pool_key, std::shared_ptr<precomp_pool>);
70 
71  void init();
72  virtual void update_from_context() const;
73  public :
74  virtual size_type nb_dof(size_type cv) const;
75  virtual size_type index_of_global_dof(size_type cv, size_type i) const;
76  virtual bgeot::pconvex_ref ref_convex(size_type cv) const;
77  virtual const bgeot::convex<base_node> &node_convex(size_type cv) const;
78  virtual bgeot::pstored_point_tab node_tab(size_type) const
79  { return pspt_override; }
80 
81  void base_value(const base_node &, base_tensor &) const;
82  void grad_base_value(const base_node &, base_tensor &) const;
83  void hess_base_value(const base_node &, base_tensor &) const;
84 
86  base_tensor &t, bool = true) const;
88  base_tensor &t, bool = true) const;
90  base_tensor &, bool = true) const;
91 
92  fem_global_function(const std::vector<pglobal_function> &funcs,
93  const mesh &m_);
94  fem_global_function(const std::vector<pglobal_function> &funcs,
95  const mesh_im &mim_);
96  virtual ~fem_global_function()
97  { DAL_STORED_OBJECT_DEBUG_DESTROYED(this, "Global function fem"); }
98  };
99 
100  /** create a new global function FEM.
101  @param funcs is a vector containing all global basis functions.
102  @param m is the mesh to be used for numerical integration in the assembly.
103  */
104  pfem new_fem_global_function(const std::vector<pglobal_function> &funcs,
105  const mesh &m);
106 
107  /** create a new global function FEM.
108  @param funcs is a vector containing all global basis functions.
109  @param mim is the integration method to be used in the assembly.
110  */
111  pfem new_fem_global_function(const std::vector<pglobal_function> &funcs,
112  const mesh_im &mim);
113 
114  /** release a global function FEM */
115  inline void del_fem_global_function(const pfem &pf)
116  { dal::del_stored_object(pf); }
117 
118 
119 } /* end of namespace getfem. */
120 
121 #endif
base class for static stored objects
void real_hess_base_value(const fem_interpolation_context &, base_tensor &, bool=true) const
Give the hessian of all components of the base functions at the current point of the fem_interpolatio...
Definition of global functions to be used as base or enrichment functions in fem. ...
Base class for finite element description.
Definition: getfem_fem.h:250
void del_fem_global_function(const pfem &pf)
release a global function FEM
Define the getfem::mesh_fem class.
Describe a mesh (collection of convexes (elements) and points).
Definition: getfem_mesh.h:95
void del_stored_object(const pstatic_stored_object &o, bool ignore_unstored)
Delete an object and the object which depend on it.
Describe an integration method linked to a mesh.
void base_value(const base_node &, base_tensor &) const
Give the value of all components of the base functions at the point x of the reference element...
void hess_base_value(const base_node &, base_tensor &) const
Give the value of all hessians (on ref.
void real_base_value(const fem_interpolation_context &c, base_tensor &t, bool=true) const
Give the value of all components of the base functions at the current point of the fem_interpolation_...
size_t size_type
used as the common size type in the library
Definition: bgeot_poly.h:49
void real_grad_base_value(const fem_interpolation_context &c, base_tensor &t, bool=true) const
Give the gradient of all components of the base functions at the current point of the fem_interpolati...
structure passed as the argument of fem interpolation functions.
Definition: getfem_fem.h:741
Deal with interdependencies of objects.
GEneric Tool for Finite Element Methods.
std::shared_ptr< const getfem::virtual_fem > pfem
type of pointer on a fem description
Definition: getfem_fem.h:239
virtual const bgeot::convex< base_node > & node_convex(size_type cv) const
Gives the convex representing the nodes on the reference element.
virtual void update_from_context() const
this function has to be defined and should update the object when the context is modified.
virtual bgeot::pconvex_ref ref_convex(size_type cv) const
Return the convex of the reference element.
Definition of the finite element methods.
virtual size_type nb_dof(size_type cv) const
Number of degrees of freedom.
pfem new_fem_global_function(const std::vector< pglobal_function > &funcs, const mesh &m)
create a new global function FEM.
void grad_base_value(const base_node &, base_tensor &) const
Give the value of all gradients (on ref.
fem object with global basis functions.