fem_function_base.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_FEM_FUNCTION_BASE_H
21 #define LIBMESH_FEM_FUNCTION_BASE_H
22 
23 // Local Includes
24 #include "libmesh/libmesh_common.h"
25 #include "libmesh/dense_vector.h" // required to instantiate a DenseVector<> below
26 #include "libmesh/auto_ptr.h" // deprecated
27 #include "libmesh/fem_context.h"
28 
29 // C++ includes
30 #include <memory>
31 
32 namespace libMesh
33 {
34 
35 // Forward Declarations
36 class Point;
37 
46 template <typename Output=Number>
47 class FEMFunctionBase
48 {
49 protected:
50 
54  FEMFunctionBase () = default;
55 
56 public:
57 
61  FEMFunctionBase (FEMFunctionBase &&) = default;
62  FEMFunctionBase (const FEMFunctionBase &) = default;
63  FEMFunctionBase & operator= (const FEMFunctionBase &) = default;
65  virtual ~FEMFunctionBase () = default;
66 
73  virtual void init_context (const FEMContext &) {}
74 
82  virtual std::unique_ptr<FEMFunctionBase<Output>> clone () const = 0;
83 
90  virtual Output operator() (const FEMContext &,
91  const Point & p,
92  const Real time = 0.) = 0;
93 
98  void operator() (const FEMContext &,
99  const Point & p,
100  DenseVector<Output> & output);
101 
108  virtual void operator() (const FEMContext &,
109  const Point & p,
110  const Real time,
111  DenseVector<Output> & output) = 0;
112 
125  virtual Output component(const FEMContext &,
126  unsigned int i,
127  const Point & p,
128  Real time=0.);
129 };
130 
131 template <typename Output>
132 inline
134  unsigned int i,
135  const Point & p,
136  Real time)
137 {
138  DenseVector<Output> outvec(i+1);
139  (*this)(context, p, time, outvec);
140  return outvec(i);
141 }
142 
143 template <typename Output>
144 inline
146  const Point & p,
147  DenseVector<Output> & output)
148 {
149  // Call the time-dependent function with t=0.
150  this->operator()(context, p, 0., output);
151 }
152 
153 } // namespace libMesh
154 
155 #endif // LIBMESH_FEM_FUNCTION_BASE_H
FEMFunctionBase & operator=(const FEMFunctionBase &)=default
virtual void init_context(const FEMContext &)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual ~FEMFunctionBase()=default
virtual Output operator()(const FEMContext &, const Point &p, const Real time=0.)=0
virtual Output component(const FEMContext &, unsigned int i, const Point &p, Real time=0.)
virtual std::unique_ptr< FEMFunctionBase< Output > > clone() const =0
A geometric point in (x,y,z) space.
Definition: point.h:38