$extrastylesheet
#include <wrapped_function.h>

Public Member Functions | |
| WrappedFunction (const System &sys, Output fptr(const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name)=NULL, const Parameters *parameters=NULL, unsigned int varnum=0) | |
| virtual UniquePtr < FunctionBase< Output > > | clone () const |
| virtual Output | operator() (const Point &p, const Real time=0.) |
| virtual void | operator() (const Point &p, const Real time, DenseVector< Output > &output) |
| virtual Output | component (unsigned int i, const Point &p, Real time=0.) |
| virtual void | init () |
| virtual void | clear () |
| void | operator() (const Point &p, DenseVector< Output > &output) |
| bool | initialized () const |
Protected Attributes | |
| const System & | _sys |
| Output(* | _fptr )(const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name) |
| const Parameters * | _parameters |
| unsigned int | _varnum |
| const FunctionBase * | _master |
| bool | _initialized |
Definition at line 44 of file wrapped_function.h.
| libMesh::WrappedFunction< Output >::WrappedFunction | ( | const System & | sys, |
| Output | fptrconst Point &p,const Parameters ¶meters,const std::string &sys_name,const std::string &unknown_name = NULL, |
||
| const Parameters * | parameters = NULL, |
||
| unsigned int | varnum = 0 |
||
| ) | [inline] |
Constructor to wrap scalar-valued function pointers.
Definition at line 51 of file wrapped_function.h.
References libMesh::FunctionBase< Output >::_initialized, libMesh::WrappedFunction< Output >::_parameters, libMesh::System::get_equation_systems(), and libMesh::EquationSystems::parameters.
: _sys(sys), _fptr(fptr), _parameters(parameters), _varnum(varnum) { this->_initialized = true; if (!parameters) _parameters = &sys.get_equation_systems().parameters; }
| virtual void libMesh::FunctionBase< Output >::clear | ( | ) | [inline, virtual, inherited] |
Clears the function.
Reimplemented in libMesh::ParsedFunction< Output, OutputGradient >, libMesh::MeshFunction, and libMesh::AnalyticFunction< Output >.
Definition at line 90 of file function_base.h.
{}
| UniquePtr< FunctionBase< Output > > libMesh::WrappedFunction< Output >::clone | ( | ) | const [inline, virtual] |
Returns a new copy of the function. The new copy should be as ``deep'' as necessary to allow independent destruction and simultaneous evaluations of the copies in different threads.
Implements libMesh::FunctionBase< Output >.
Definition at line 130 of file wrapped_function.h.
{
return UniquePtr<FunctionBase<Output> >
(new WrappedFunction<Output>
(_sys, _fptr, _parameters, _varnum));
}
| Output libMesh::WrappedFunction< Output >::component | ( | unsigned int | i, |
| const Point & | p, | ||
| Real | time = 0. |
||
| ) | [inline, virtual] |
i at coordinate p and time time. Reimplemented from libMesh::FunctionBase< Output >.
Definition at line 190 of file wrapped_function.h.
References libMesh::libmesh_assert(), n_vars, and libMesh::SCALAR.
{
libmesh_assert(_fptr);
libmesh_assert(_parameters);
// Loop over variables, then over each component in
// vector-valued variables.
const unsigned int n_vars = _sys.n_vars();
for (unsigned int v = 0; v != n_vars; ++v)
{
const unsigned int n_components =
_sys.variable(v).n_components();
if (n_components == 1 &&
i == _sys.variable_scalar_number(v,0))
return _fptr(p, *_parameters, _sys.name(), _sys.variable_name(v));
else if (i >= _sys.variable_scalar_number(v,0) &&
i <= _sys.variable_scalar_number(v,n_components-1))
{
// Right now our only non-scalar variable type is the
// SCALAR variables. The irony is priceless.
libmesh_assert_equal_to (_sys.variable(i).type().family, SCALAR);
// We pass the point (j,0,0) to an old-style fptr function
// pointer to distinguish the different scalars within the
// SCALAR variable.
for (unsigned int j=0; j != n_components; ++j)
if (i == _sys.variable_scalar_number(v,j))
return _fptr(Point(j,0,0), *_parameters,
_sys.name(), _sys.variable_name(v));
}
}
libmesh_error_msg("Component index " << i << " not found in system " << _sys.name());
return Output();
}
| virtual void libMesh::FunctionBase< Output >::init | ( | ) | [inline, virtual, inherited] |
The actual initialization process.
Reimplemented in libMesh::ParsedFunction< Output, OutputGradient >, libMesh::MeshFunction, and libMesh::AnalyticFunction< Output >.
Definition at line 85 of file function_base.h.
{}
| bool libMesh::FunctionBase< Output >::initialized | ( | ) | const [inline, inherited] |
true when this object is properly initialized and ready for use, false otherwise. Definition at line 198 of file function_base.h.
{
return (this->_initialized);
}
| Output libMesh::WrappedFunction< Output >::operator() | ( | const Point & | p, |
| const Real | time = 0. |
||
| ) | [inline, virtual] |
p and time time. Implements libMesh::FunctionBase< Output >.
Definition at line 115 of file wrapped_function.h.
References libMesh::libmesh_assert().
{
libmesh_assert(_fptr);
libmesh_assert(_parameters);
return _fptr(p,
*_parameters,
_sys.name(),
_sys.variable_name(_varnum));
}
| void libMesh::WrappedFunction< Output >::operator() | ( | const Point & | p, |
| const Real | time, | ||
| DenseVector< Output > & | output | ||
| ) | [inline, virtual] |
Return function for vectors. Returns in output the values of all system variables at the coordinate p and for time time.
Implements libMesh::FunctionBase< Output >.
Definition at line 145 of file wrapped_function.h.
References libMesh::libmesh_assert(), n_vars, libMesh::SCALAR, and libMesh::DenseVector< T >::size().
{
libmesh_assert(_fptr);
libmesh_assert(_parameters);
// We fill each entry of output with a single scalar component of
// the data in our System
libmesh_assert_equal_to (output.size(), _sys.n_components());
// Loop over variables, then over each component in
// vector-valued variables, evaluating each.
const unsigned int n_vars = _sys.n_vars();
for (unsigned int v = 0; v != n_vars; ++v)
{
const unsigned int n_components =
_sys.variable(v).n_components();
if (n_components == 1)
output(_sys.variable_scalar_number(v,0)) =
_fptr(p, *_parameters, _sys.name(), _sys.variable_name(v));
else
{
// Right now our only non-scalar variable type is the
// SCALAR variables. The irony is priceless.
libmesh_assert_equal_to (_sys.variable(v).type().family, SCALAR);
// We pass the point (j,0,0) to an old-style fptr function
// pointer to distinguish the different scalars within the
// SCALAR variable.
for (unsigned int j=0; j != n_components; ++j)
output(_sys.variable_scalar_number(v,j)) =
_fptr(Point(j,0,0), *_parameters,
_sys.name(), _sys.variable_name(v));
}
}
}
| void libMesh::FunctionBase< Output >::operator() | ( | const Point & | p, |
| DenseVector< Output > & | output | ||
| ) | [inline, inherited] |
Return function for vectors. Returns in output the values of the data at the coordinate p.
Definition at line 220 of file function_base.h.
{
// Call the time-dependent function with t=0.
this->operator()(p, 0., output);
}
Output(* libMesh::WrappedFunction< Output >::_fptr)(const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name) [protected] |
Definition at line 98 of file wrapped_function.h.
bool libMesh::FunctionBase< Output >::_initialized [protected, inherited] |
When init() was called so that everything is ready for calls to operator() (...), then this bool is true.
Definition at line 170 of file function_base.h.
Referenced by libMesh::AnalyticFunction< Output >::AnalyticFunction(), libMesh::ConstFunction< Output >::ConstFunction(), libMesh::ParsedFunction< Output, OutputGradient >::ParsedFunction(), and libMesh::WrappedFunction< Output >::WrappedFunction().
const FunctionBase* libMesh::FunctionBase< Output >::_master [protected, inherited] |
Const pointer to our master, initialized to NULL. There may be cases where multiple functions are required, but to save memory, one master handles some centralized data.
Definition at line 164 of file function_base.h.
const Parameters* libMesh::WrappedFunction< Output >::_parameters [protected] |
Definition at line 103 of file wrapped_function.h.
Referenced by libMesh::WrappedFunction< Output >::WrappedFunction().
const System& libMesh::WrappedFunction< Output >::_sys [protected] |
Definition at line 96 of file wrapped_function.h.
unsigned int libMesh::WrappedFunction< Output >::_varnum [protected] |
Definition at line 105 of file wrapped_function.h.