libMesh
fem_function_base.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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 // C++ includes
24 
25 
26 
27 // Local Includes
28 #include "libmesh/libmesh_common.h"
29 #include "libmesh/dense_vector.h" // required to instantiate a DenseVector<> below
30 #include "libmesh/auto_ptr.h"
31 #include "libmesh/fem_context.h"
32 
33 namespace libMesh
34 {
35 
36 // Forward Declarations
37 class Point;
38 
47 template <typename Output=Number>
48 class FEMFunctionBase
49 {
50 protected:
51 
56 
57 public:
58 
62  virtual ~FEMFunctionBase () {}
63 
64 
71  virtual void init_context (const FEMContext &) {}
72 
80  virtual UniquePtr<FEMFunctionBase<Output>> clone () const = 0;
81 
88  virtual Output operator() (const FEMContext &,
89  const Point & p,
90  const Real time = 0.) = 0;
91 
96  void operator() (const FEMContext &,
97  const Point & p,
98  DenseVector<Output> & output);
99 
106  virtual void operator() (const FEMContext &,
107  const Point & p,
108  const Real time,
109  DenseVector<Output> & output) = 0;
110 
123  virtual Output component(const FEMContext &,
124  unsigned int i,
125  const Point & p,
126  Real time=0.);
127 };
128 
129 template <typename Output>
130 inline
132  unsigned int i,
133  const Point & p,
134  Real time)
135 {
136  DenseVector<Output> outvec(i+1);
137  (*this)(context, p, time, outvec);
138  return outvec(i);
139 }
140 
141 template <typename Output>
142 inline
144  const Point & p,
145  DenseVector<Output> & output)
146 {
147  // Call the time-dependent function with t=0.
148  this->operator()(context, p, 0., output);
149 }
150 
151 } // namespace libMesh
152 
153 #endif // LIBMESH_FEM_FUNCTION_BASE_H
FEMFunctionBase()
Constructor.
virtual ~FEMFunctionBase()
Destructor.
The libMesh namespace provides an interface to certain functionality in the library.
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
virtual void init_context(const FEMContext &)
Prepares a context object for use.
This class provides all data required for a physics package (e.g.
Definition: fem_context.h:61
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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 UniquePtr< FEMFunctionBase< Output > > clone() const =0
Defines a dense vector for use in Finite Element-type computations.
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38