wrapped_functor.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_WRAPPED_FUNCTOR_H
21 #define LIBMESH_WRAPPED_FUNCTOR_H
22 
23 // Local Includes
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 
60  WrappedFunctor (const WrappedFunctor &) = delete;
61  WrappedFunctor & operator= (const WrappedFunctor &) = delete;
62 
66  WrappedFunctor (WrappedFunctor &&) = default;
68  virtual ~WrappedFunctor () = default;
69 
70  virtual std::unique_ptr<FEMFunctionBase<Output>> clone () const override
71  {
72  return std::unique_ptr<FEMFunctionBase<Output>>
73  (new WrappedFunctor<Output> (*_func));
74  }
75 
76  virtual Output operator() (const FEMContext &,
77  const Point & p,
78  const Real time = 0.) override
79  { return _func->operator()(p, time); }
80 
81  virtual void operator() (const FEMContext &,
82  const Point & p,
83  const Real time,
84  DenseVector<Output> & output) override
85  { _func->operator() (p, time, output); }
86 
87  virtual Output component (const FEMContext &,
88  unsigned int i,
89  const Point & p,
90  Real time=0.) override
91  { return _func->component(i, p, time); }
92 
93 protected:
94 
95  std::unique_ptr<FunctionBase<Output>> _func;
96 };
97 
98 
99 
100 } // namespace libMesh
101 
102 #endif // LIBMESH_WRAPPED_FUNCTOR_H
WrappedFunctor & operator=(const WrappedFunctor &)=delete
virtual Output component(const FEMContext &, unsigned int i, const Point &p, Real time=0.) override
virtual std::unique_ptr< FEMFunctionBase< Output > > clone() const override
virtual Output operator()(const FEMContext &, const Point &p, const Real time=0.) override
std::unique_ptr< FunctionBase< Output > > _func
virtual ~WrappedFunctor()=default
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
WrappedFunctor(const FunctionBase< Output > &func)
Base class for functors that can be evaluated at a point and (optionally) time.
A geometric point in (x,y,z) space.
Definition: point.h:38