$extrastylesheet
libMesh::WrappedFunction< Output > Class Template Reference

#include <wrapped_function.h>

Inheritance diagram for libMesh::WrappedFunction< Output >:

List of all members.

Public Member Functions

 WrappedFunction (const System &sys, Output fptr(const Point &p, const Parameters &parameters, 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 &parameters, const std::string &sys_name, const std::string &unknown_name)
const Parameters_parameters
unsigned int _varnum
const FunctionBase_master
bool _initialized

Detailed Description

template<typename Output = Number>
class libMesh::WrappedFunction< Output >

Definition at line 44 of file wrapped_function.h.


Constructor & Destructor Documentation

template<typename Output = Number>
libMesh::WrappedFunction< Output >::WrappedFunction ( const System sys,
Output   fptrconst Point &p,const Parameters &parameters,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;
  }

Member Function Documentation

template<typename Output = Number>
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.

{}
template<typename Output >
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));
}
template<typename Output >
Output libMesh::WrappedFunction< Output >::component ( unsigned int  i,
const Point p,
Real  time = 0. 
) [inline, virtual]
Returns:
the vector component 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();
}
template<typename Output = Number>
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.

{}
template<typename Output >
bool libMesh::FunctionBase< Output >::initialized ( ) const [inline, inherited]
Returns:
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);
}
template<typename Output >
Output libMesh::WrappedFunction< Output >::operator() ( const Point p,
const Real  time = 0. 
) [inline, virtual]
Returns:
the scalar value of variable varnum at coordinate p and time time.

Implements libMesh::FunctionBase< Output >.

Definition at line 115 of file wrapped_function.h.

References libMesh::libmesh_assert().

template<typename Output >
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));
        }
    }
}
template<typename Output>
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);
}

Member Data Documentation

template<typename Output = Number>
Output(* libMesh::WrappedFunction< Output >::_fptr)(const Point &p, const Parameters &parameters, const std::string &sys_name, const std::string &unknown_name) [protected]

Definition at line 98 of file wrapped_function.h.

template<typename Output = Number>
bool libMesh::FunctionBase< Output >::_initialized [protected, inherited]
template<typename Output = Number>
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.

template<typename Output = Number>
const Parameters* libMesh::WrappedFunction< Output >::_parameters [protected]
template<typename Output = Number>
const System& libMesh::WrappedFunction< Output >::_sys [protected]

Definition at line 96 of file wrapped_function.h.

template<typename Output = Number>
unsigned int libMesh::WrappedFunction< Output >::_varnum [protected]

Definition at line 105 of file wrapped_function.h.


The documentation for this class was generated from the following file: