Public Member Functions | Protected Member Functions

gridripper::odesolver::ODE Class Reference

Ordinary differential equation interface. More...

#include <ODE.h>

List of all members.

Public Member Functions

virtual bool isNumericalConstraintSettingPassedToPDE () const
 Tests whether the constraint condition should be set numerically later by PDE.initConstraints.
virtual bool isConstrainedInInit () const
 Tests whether the initial state is already constrained.
virtual void constrain (tvalarray< GReal_t > &mesh)
 Constrain the field to the hypersurface of constraint conditions.
virtual void eval (const GReal_t *f, int offset, GReal_t x, GReal_t *df)=0
 Evaluates the ODE.
virtual int getMatrixFieldOrder (int i) const
virtual bool hasExactSolution () const
virtual void getExactSolution (tvalarray< GReal_t > &F, GReal_t x) const
virtual GReal_t getMinX () const =0
 Gets the minimum x coordinate.
virtual GReal_t getMaxX () const =0
 Gets the maximum x coordinate.
virtual bool isValid (const GReal_t *F, int nc, GReal_t x) const
 Tests whether the differential equation is still valid for describing the system.
virtual bool dRHS (const GReal_t *f, int offset, GReal_t x, GReal_t *drhs)
 Calculates the derivative matrix of the RHS of the field equation vector.
virtual tvalarray< GReal_tgetInitialValuesForRelaxation (int nx) const
 Gets the initial field values for the relaxation method.
virtual tvalarray< GReal_tgetInitialX () const
 Gets the initial x coordinate(s) for a shooting method.
virtual FieldArray getInitialValuesForShooting () const
 Gets the initial field values for a shooting method.
virtual GReal_t averageShootingResults (int np, int ip, GReal_t x, int ic, GReal_t f0, GReal_t f1) const
 Averages solutions from two shooting method results.
virtual void getPhysicalField (GReal_t x, GReal_t *f) const
 Gets the physical field components.
const PDEgetPDE () const
 Gets the PDE.
const InitCondgetPDEInitCond () const
 Gets the initial condition for the PDE.
void setPDE (const PDE *pde, const InitCond *init)
 Sets the PDE and its initial condition.
virtual void initPDE (GReal_t x, const GReal_t *fode, FieldWrapper &fpde)
 Sets boundary conditions for a PDE to be the solution of this ODE.
virtual void initPDE (GReal_t x, const GReal_t *fode, FieldWrapper &fpde, const GReal_t *data, int ndata)
 Sets boundary conditions for a PDE to be the solution of this ODE.
int getNumComponents () const
 Gets the number of field components.
string getComponentName (int k) const
 Gets the name of a component.

Protected Member Functions

 ODE (int nc, const string *compnames)
 Constructs the ODE.

Detailed Description

Ordinary differential equation interface.

Version:
0.5, 02/27/2009
Since:
GridRipper 0.4, 08/02/2006
Author:
Peter Csizmadia

Constructor & Destructor Documentation

gridripper::odesolver::ODE::ODE ( int  nc,
const string *  compnames 
) [inline, protected]

Constructs the ODE.

Parameters:
nc number of field components
compnames array of component names

Member Function Documentation

virtual GReal_t gridripper::odesolver::ODE::averageShootingResults ( int  np,
int  ip,
GReal_t  x,
int  ic,
GReal_t  f0,
GReal_t  f1 
) const [inline, virtual]

Averages solutions from two shooting method results.

The default implementation returns the arithmetic mean (f0+f1)/2.

Parameters:
np the grid size (number of subdivisions)
ip grid point index
x grid point x coordinate
ic field component index
f0 field value from the first shooting result
f1 field value from the second shooting result
Returns:
the average field value
virtual void gridripper::odesolver::ODE::constrain ( tvalarray< GReal_t > &  mesh  )  [inline, virtual]

Constrain the field to the hypersurface of constraint conditions.

The default implementation does not perform any operation.

Parameters:
mesh the mesh containing the field values
virtual bool gridripper::odesolver::ODE::dRHS ( const GReal_t f,
int  offset,
GReal_t  x,
GReal_t drhs 
) [virtual]

Calculates the derivative matrix of the RHS of the field equation vector.

This method is used by the relaxation method. However, its implementation is not obligatory: if exact derivates are not available, then finite differences are calculated numerically by the relaxation algorithm.

Parameters:
f n*nc element vector containing the field components
offset index of the first field component in the vector
x the space coordinate
drhs nc*nc output array, it will contain the derivative matrix
Returns:
true if the derivatives were calculated, false if they are not available (default)
virtual void gridripper::odesolver::ODE::eval ( const GReal_t f,
int  offset,
GReal_t  x,
GReal_t df 
) [pure virtual]

Evaluates the ODE.

Parameters:
f vector of field values
offset offset in field vector
x the x coordinate
df output vector for the derivatives
string gridripper::odesolver::ODE::getComponentName ( int  k  )  const [inline]

Gets the name of a component.

Parameters:
k the component index
Returns:
the component name
virtual tvalarray<GReal_t> gridripper::odesolver::ODE::getInitialValuesForRelaxation ( int  nx  )  const [virtual]

Gets the initial field values for the relaxation method.

Parameters:
nx the grid size (number of subdivisions)
Returns:
the array of field values
virtual FieldArray gridripper::odesolver::ODE::getInitialValuesForShooting (  )  const [virtual]

Gets the initial field values for a shooting method.

Returns:
a 1- or 2-element array containing the initial field values
virtual tvalarray<GReal_t> gridripper::odesolver::ODE::getInitialX (  )  const [virtual]

Gets the initial x coordinate(s) for a shooting method.

Returns:
a 1- or 2-element array containing the initial x coordinate(s)
virtual GReal_t gridripper::odesolver::ODE::getMaxX (  )  const [pure virtual]

Gets the maximum x coordinate.

Returns:
the maximum x coordinate
virtual GReal_t gridripper::odesolver::ODE::getMinX (  )  const [pure virtual]

Gets the minimum x coordinate.

Returns:
the minimum x coordinate
int gridripper::odesolver::ODE::getNumComponents (  )  const [inline]

Gets the number of field components.

Returns:
the number of components
const PDE& gridripper::odesolver::ODE::getPDE (  )  const [inline]

Gets the PDE.

Returns:
the PDE or null if there is no PDE
const InitCond& gridripper::odesolver::ODE::getPDEInitCond (  )  const [inline]

Gets the initial condition for the PDE.

Returns:
the initial condition or null if there is no PDE
virtual void gridripper::odesolver::ODE::getPhysicalField ( GReal_t  x,
GReal_t f 
) const [inline, virtual]

Gets the physical field components.

Parameters:
x the coordinate
f the field components (input: values on the grid, output: physical values)
virtual void gridripper::odesolver::ODE::initPDE ( GReal_t  x,
const GReal_t fode,
FieldWrapper fpde,
const GReal_t data,
int  ndata 
) [inline, virtual]

Sets boundary conditions for a PDE to be the solution of this ODE.

Parameters:
x the x coordinate
fode the solution vector of the ODE
fpde output array for the fields appearing in the PDE
data array containing the field values for all grid points
ndata size of the data array
virtual void gridripper::odesolver::ODE::initPDE ( GReal_t  x,
const GReal_t fode,
FieldWrapper fpde 
) [virtual]

Sets boundary conditions for a PDE to be the solution of this ODE.

Parameters:
x the x coordinate
fode the solution vector of the ODE
fpde output array for the fields appearing in the PDE
virtual bool gridripper::odesolver::ODE::isConstrainedInInit (  )  const [inline, virtual]

Tests whether the initial state is already constrained.

Returns:
true if the initial state is constrained, false if constrain must be called
virtual bool gridripper::odesolver::ODE::isNumericalConstraintSettingPassedToPDE (  )  const [inline, virtual]

Tests whether the constraint condition should be set numerically later by PDE.initConstraints.

Returns:
true in the default implementation
virtual bool gridripper::odesolver::ODE::isValid ( const GReal_t F,
int  nc,
GReal_t  x 
) const [inline, virtual]

Tests whether the differential equation is still valid for describing the system.

Shooting method stops immediately when the ODE becomes invalid.

Parameters:
F the field values
nc the number of components
x the space coordinate
void gridripper::odesolver::ODE::setPDE ( const PDE pde,
const InitCond init 
) [inline]

Sets the PDE and its initial condition.

Useful to avoid code duplication; common methods should be implemented in the PDE.

Parameters:
pde the PDE
init the initial condition object

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