libMesh
include
numerics
wrapped_functor.h
Go to the documentation of this file.
1
// The libMesh Finite Element Library.
2
// Copyright (C) 2002-2019 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
#include "libmesh/auto_ptr.h"
// libmesh_make_unique
28
29
// C++ includes
30
#include <cstddef>
31
32
namespace
libMesh
33
{
34
44
template
<
typename
Output=Number>
45
class
WrappedFunctor
:
public
FEMFunctionBase
<Output>
46
{
47
public
:
48
53
WrappedFunctor
(
const
FunctionBase<Output>
& func)
54
:
_func
(func.
clone
())
55
{ }
56
61
WrappedFunctor
(
const
WrappedFunctor
&) =
delete
;
62
WrappedFunctor
&
operator=
(
const
WrappedFunctor
&) =
delete
;
63
67
WrappedFunctor
(
WrappedFunctor
&&) =
default
;
68
WrappedFunctor
&
operator=
(
WrappedFunctor
&&) =
default
;
69
virtual
~WrappedFunctor
() =
default
;
70
71
virtual
std::unique_ptr<FEMFunctionBase<Output>>
clone
()
const override
72
{
73
return
libmesh_make_unique<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
libMesh::WrappedFunctor
This class provides a wrapper with which to evaluate a (libMesh-style) function pointer in a Function...
Definition:
wrapped_functor.h:45
libMesh::FunctionBase
Base class for functors that can be evaluated at a point and (optionally) time.
Definition:
dirichlet_boundaries.h:44
libMesh::WrappedFunctor::operator()
virtual Output operator()(const FEMContext &, const Point &p, const Real time=0.) override
Definition:
wrapped_functor.h:76
libMesh::FEMFunctionBase
FEMFunctionBase is a base class from which users can derive in order to define "function-like" object...
Definition:
dirichlet_boundaries.h:43
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition:
factoryfunction.C:55
libMesh::WrappedFunctor::WrappedFunctor
WrappedFunctor(const FunctionBase< Output > &func)
Constructor to wrap FunctionBase functors in a FEMFunctionBase compatible shim.
Definition:
wrapped_functor.h:53
libMesh::WrappedFunctor::clone
virtual std::unique_ptr< FEMFunctionBase< Output > > clone() const override
Definition:
wrapped_functor.h:71
libMesh::WrappedFunctor::~WrappedFunctor
virtual ~WrappedFunctor()=default
libMesh::Point
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition:
point.h:38
libMesh::WrappedFunctor::operator=
WrappedFunctor & operator=(const WrappedFunctor &)=delete
libMesh::WrappedFunctor::component
virtual Output component(const FEMContext &, unsigned int i, const Point &p, Real time=0.) override
Definition:
wrapped_functor.h:87
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition:
libmesh_common.h:121
libMesh::DenseVector< Output >
libMesh::WrappedFunctor::_func
std::unique_ptr< FunctionBase< Output > > _func
Definition:
wrapped_functor.h:95
libMesh::FEMContext
This class provides all data required for a physics package (e.g.
Definition:
fem_context.h:62
Generated on Sat Jan 25 2020 12:06:54 for libMesh by
1.8.16