libMesh
wrapped_functor.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_WRAPPED_FUNCTOR_H
21 #define LIBMESH_WRAPPED_FUNCTOR_H
22 
23 // Local Includes
24 #include "libmesh/fem_function_base.h"
25 #include "libmesh/function_base.h"
26 #include "libmesh/point.h"
27 
28 // C++ includes
29 #include <cstddef>
30 
31 namespace libMesh
32 {
33 
43 template <typename Output=Number>
44 class WrappedFunctor : public FEMFunctionBase<Output>
45 {
46 public:
47 
53  : _func(func.clone())
54  { }
55 
56  virtual UniquePtr<FEMFunctionBase<Output>> clone () const libmesh_override
57  {
59  (new WrappedFunctor<Output> (*_func));
60  }
61 
62  virtual Output operator() (const FEMContext &,
63  const Point & p,
64  const Real time = 0.) libmesh_override
65  { return _func->operator()(p, time); }
66 
67  virtual void operator() (const FEMContext &,
68  const Point & p,
69  const Real time,
70  DenseVector<Output> & output) libmesh_override
71  { _func->operator() (p, time, output); }
72 
73  virtual Output component (const FEMContext &,
74  unsigned int i,
75  const Point & p,
76  Real time=0.) libmesh_override
77  { return _func->component(i, p, time); }
78 
79 protected:
80 
82 };
83 
84 
85 
86 } // namespace libMesh
87 
88 #endif // LIBMESH_WRAPPED_FUNCTOR_H
The libMesh namespace provides an interface to certain functionality in the library.
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
This class provides a wrapper with which to evaluate a (libMesh-style) function pointer in a Function...
This class provides all data required for a physics package (e.g.
Definition: fem_context.h:61
virtual UniquePtr< FEMFunctionBase< Output > > clone() const libmesh_override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Output operator()(const FEMContext &, const Point &p, const Real time=0.) libmesh_override
virtual Output component(const FEMContext &, unsigned int i, const Point &p, Real time=0.) libmesh_override
UniquePtr< FunctionBase< Output > > _func
Defines a dense vector for use in Finite Element-type computations.
WrappedFunctor(const FunctionBase< Output > &func)
Constructor to wrap FunctionBase functors in a FEMFunctionBase compatible shim.
This is the base class for functor-like classes.
FEMFunctionBase is a base class from which users can derive in order to define "function-like" object...
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38