OGS
MathLib::ODE::detail::FunctionHandlesImpl< N > Struct Template Referencefinal

Detailed Description

template<unsigned N>
struct MathLib::ODE::detail::FunctionHandlesImpl< N >

Function handles for an ODE system of N equations.

Definition at line 58 of file FunctionHandles.h.

#include <FunctionHandles.h>

Inheritance diagram for MathLib::ODE::detail::FunctionHandlesImpl< N >:
[legend]
Collaboration diagram for MathLib::ODE::detail::FunctionHandlesImpl< N >:
[legend]

Public Member Functions

 FunctionHandlesImpl (Function< N > &f, JacobianFunction< N > &df)
 
bool call (const double t, const double *const y, double *const ydot) override
 
bool callJacobian (const double t, const double *const y, double *const ydot, double *const jac) override
 
bool hasJacobian () const override
 Tells whether a Jacobian function has been set.
 
unsigned getNumberOfEquations () const override
 Returns the number of equations in the ODE system.
 
- Public Member Functions inherited from MathLib::ODE::detail::FunctionHandles
virtual bool call (const double t, double const *const y, double *const ydot)=0
 
virtual bool callJacobian (const double t, double const *const y, double *const ydot, double *const jac)=0
 
virtual bool hasJacobian () const =0
 Tells whether a Jacobian function has been set.
 
virtual unsigned getNumberOfEquations () const =0
 Returns the number of equations in the ODE system.
 
virtual ~FunctionHandles ()=default
 

Public Attributes

Function< N > f
 
JacobianFunction< N > df
 

Constructor & Destructor Documentation

◆ FunctionHandlesImpl()

template<unsigned N>
MathLib::ODE::detail::FunctionHandlesImpl< N >::FunctionHandlesImpl ( Function< N > &  f,
JacobianFunction< N > &  df 
)
inline

Definition at line 60 of file FunctionHandles.h.

Member Function Documentation

◆ call()

template<unsigned N>
bool MathLib::ODE::detail::FunctionHandlesImpl< N >::call ( const double  t,
const double *const  y,
double *const  ydot 
)
inlineoverridevirtual

Calls the stored function f computing \(\dot y\).

The raw pointers passed to this method are wrapped in some Eigen::Map objects before being passed to f. Thereby the information about the size of the vectors is restored. No memory is copied for that.

Returns
true or false indicating whether the function succeeded.

Implements MathLib::ODE::detail::FunctionHandles.

Definition at line 72 of file FunctionHandles.h.

74 {
75 if (f)
76 {
77 MappedVector<N> ydot_mapped{ydot};
78 return f(t, MappedConstVector<N>{y}, ydot_mapped);
79 }
80 return false;
81 }
static const double t

References MathLib::ODE::detail::FunctionHandlesImpl< N >::f, and MathLib::t.

◆ callJacobian()

template<unsigned N>
bool MathLib::ODE::detail::FunctionHandlesImpl< N >::callJacobian ( const double  t,
const double *const  y,
double *const  ydot,
double *const  jac 
)
inlineoverridevirtual

Calls the stored function computing \(\mathtt{jac} := \partial \dot y/\partial y\).

Returns
true or false indicating whether the function succeeded.
See also
call()

Implements MathLib::ODE::detail::FunctionHandles.

Definition at line 89 of file FunctionHandles.h.

91 {
92 if (df)
93 {
94 MappedMatrix<N, N> jac_mapped{jac};
95 return df(t,
96 MappedConstVector<N>{y},
97 MappedConstVector<N>{ydot},
98 jac_mapped);
99 }
100 return false;
101 }

References MathLib::ODE::detail::FunctionHandlesImpl< N >::df, and MathLib::t.

◆ getNumberOfEquations()

template<unsigned N>
unsigned MathLib::ODE::detail::FunctionHandlesImpl< N >::getNumberOfEquations ( ) const
inlineoverridevirtual

Returns the number of equations in the ODE system.

Implements MathLib::ODE::detail::FunctionHandles.

Definition at line 104 of file FunctionHandles.h.

104{ return N; }

◆ hasJacobian()

template<unsigned N>
bool MathLib::ODE::detail::FunctionHandlesImpl< N >::hasJacobian ( ) const
inlineoverridevirtual

Tells whether a Jacobian function has been set.

Implements MathLib::ODE::detail::FunctionHandles.

Definition at line 103 of file FunctionHandles.h.

103{ return df != nullptr; }

References MathLib::ODE::detail::FunctionHandlesImpl< N >::df.

Member Data Documentation

◆ df

◆ f


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