MBSim

Project Page
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes
MBSim::DynamicSystemSolver Class Reference

solver interface for modelling and simulation of dynamic systems More...

#include <dynamic_system_solver.h>

Inheritance diagram for MBSim::DynamicSystemSolver:
MBSim::Group MBSim::DynamicSystem MBSim::Element

List of all members.

Public Types

enum  Solver {
  FixedPointTotal, FixedPointSingle, GaussSeidel, LinearEquations,
  RootFinding
}
 solver for contact equations
enum  Strategy { global, local }
 relaxation strategies in solution of contact equations
enum  LinAlg { LUDecomposition, LevenbergMarquardt, PseudoInverse }
 linear algebra for Newton scheme in solution of contact equations

Public Member Functions

 DynamicSystemSolver (const std::string &name="")
 constructor
virtual ~DynamicSystemSolver ()
 destructor
void initialize ()
 Initialize the system.
void setTruncateSimulationFiles (bool trunc)
void init (InitStage stage)
 plots time series header
virtual int solveConstraintsFixpointSingle ()
 solve contact equations with single step fixed point scheme
virtual int solveImpactsFixpointSingle (double dt=0)
 solve impact equations with single step fixed point scheme on velocity level
virtual int solveConstraintsGaussSeidel ()
 solve contact equations with Gauss-Seidel scheme
virtual int solveImpactsGaussSeidel (double dt=0)
 solve impact equations with Gauss-Seidel scheme on velocity level
virtual int solveConstraintsRootFinding ()
 solve contact equations with Newton scheme
virtual int solveImpactsRootFinding (double dt=0)
 solve impact equations with Newton scheme on velocity level
virtual void checkConstraintsForTermination ()
 validate force laws concerning given tolerances
virtual void checkImpactsForTermination (double dt=0)
 validate force laws concerning given tolerances on velocity level
virtual void updateh (double t, int i=0)
virtual void updateM (double t, int i=0)
virtual void updateStateDependentVariables (double t)
virtual void updater (double t, int j=0)
 update smooth link force law
virtual void updatewb (double t, int j=0)
virtual void updateW (double t, int j=0)
virtual void updateV (double t, int j=0)
virtual std::string getType () const
 DEPRECATED.
virtual void plot (const fmatvec::Vec &z, double t, double dt=1)
virtual void plot2 (const fmatvec::Vec &z, double t, double dt=1)
virtual void closePlot ()
 closes plot file
virtual int solveConstraints ()
 solves prox-functions for contact forces using sparsity structure
virtual int solveImpacts (double dt=0)
 solves prox-functions for impacts on velocity level using sparsity structure
void setConstraintSolver (Solver solver_)
void setImpactSolver (Solver solver_)
const Solver & getConstraintSolver ()
const Solver & getImpactSolver ()
void setTermination (bool term_)
void setStrategy (Strategy strategy_)
void setMaxIter (int iter)
void setHighIter (int iter)
void setNumJacProj (bool numJac_)
void setMaxDampingSteps (int maxDSteps)
void setLevenbergMarquardtParam (double lmParm_)
void setLinAlg (LinAlg linAlg_)
void setUseOldla (bool flag)
void setDecreaseLevels (const fmatvec::VecInt &decreaseLevels_)
void setCheckTermLevels (const fmatvec::VecInt &checkTermLevels_)
void setCheckGSize (bool checkGSize_)
void setLimitGSize (int limitGSize_)
const fmatvec::SparseMat & getGs () const
fmatvec::SparseMat & getGs ()
const fmatvec::SqrMat & getG () const
fmatvec::SqrMat & getG ()
const fmatvec::Vec & getb () const
fmatvec::Vec & getb ()
const fmatvec::SqrMat & getJprox () const
fmatvec::SqrMat & getJprox ()
const fmatvec::Mat & getWParent (int i=0) const
const fmatvec::Mat & getVParent (int i=0) const
const fmatvec::Vec & getlaParent () const
const fmatvec::Vec & getgdParent () const
const fmatvec::Vec & getresParent () const
const fmatvec::Vec & getrFactorParent () const
DynamicSystemSolver * getDynamicSystemSolver ()
bool getIntegratorExitRequest ()
int getMaxIter ()
void computeInitialCondition ()
 compute initial condition for links for event driven integrator
fmatvec::Vec deltau (const fmatvec::Vec &zParent, double t, double dt)
fmatvec::Vec deltaq (const fmatvec::Vec &zParent, double t, double dt)
fmatvec::Vec deltax (const fmatvec::Vec &zParent, double t, double dt)
 return x-state difference for current time
virtual void initz (fmatvec::Vec &z0)
 initialises state variables
int solveConstraintsLinearEquations ()
 solution of contact equations with Cholesky decomposition
int solveImpactsLinearEquations (double dt=0)
 solution of contact equations with Cholesky decomposition on velocity level
virtual void updateG (double t, int i=0)
 updates mass action matrix
void decreaserFactors ()
 decrease relaxation factors if mass action matrix is not diagonal dominant
void update (const fmatvec::Vec &z, double t, int options=0)
 update of dynamic system for time-stepping integrator
virtual void shift (fmatvec::Vec &z, const fmatvec::VecInt &jsv, double t)
 update for event driven integrator for event
virtual void zdot (const fmatvec::Vec &z, fmatvec::Vec &zd, double t)
 update for event driven integrator during smooth phase
virtual fmatvec::Vec zdot (const fmatvec::Vec &zParent, double t)
 standard invocation of smooth update for event driven integration
virtual void getsv (const fmatvec::Vec &z, fmatvec::Vec &svExt, double t)
 evaluation of stop vector
void getLinkStatus (fmatvec::VecInt &LinkStatusExt, double t)
 brief collect status of all set-valued links
void getLinkStatusReg (fmatvec::VecInt &LinkStatusRegExt, double t)
 brief collect status of all single-valued links
void projectGeneralizedPositions (double t, int mode, bool fullUpdate=false)
 drift projection for positions
void projectGeneralizedVelocities (double t, int mode)
 drift projection for positions
void savela (double dt=1.0)
 save contact force parameter for use as starting value in next time step
void initla (double dt=1.0)
 load contact force parameter for use as starting value
double computeKineticEnergy ()
 compute kinetic energy of entire dynamic system
double computePotentialEnergy ()
 compute potential energy of entire dynamic system change? TODO
void addElement (Element *element_)
Element * getElement (const std::string &name)
std::string getSolverInfo ()
void setStopIfNoConvergence (bool flag, bool dropInfo=false)
void dropContactMatrices ()
 writes a file with relevant matrices for debugging
void setPartialEventDrivenSolver (bool peds_)
void writez (std::string fileName, bool formatH5=true)
 writes state to a file
void readz0 (std::string fileName)
 reads state from a file
virtual void initializeUsingXML (xercesc::DOMElement *element)
virtual xercesc::DOMElement * writeXMLFile (xercesc::DOMNode *element)
void writeXMLFile (const std::string &name)
void writeXMLFile ()
void setProjectionTolerance (double tol)
 set tolerance for projection of generalized position
void setgTol (double tol)
void setgdTol (double tol)
void setgddTol (double tol)
void setlaTol (double tol)
void setLaTol (double tol)
void updatezRef (const fmatvec::Vec &ext)
 references to external state
void setFlushEvery (unsigned int every)
 set the number of plot-routine-calls after which all hdf5-files will be flushed
void setAlwaysConsiderContact (bool alwaysConsiderContact_)
void setInverseKinetics (bool inverseKinetics_)
void setInitialProjection (bool initialProjection_)
fmatvec::Mat dhdq (double t, int lb=0, int ub=0)
fmatvec::Mat dhdu (double t, int lb=0, int ub=0)
fmatvec::Mat dhdx (double t)
fmatvec::Vec dhdt (double t)
void setRootID (int ID)
int getRootID () const
void setq (const fmatvec::Vec &q_)
void setLa (const fmatvec::Vec &la_)

Static Public Member Functions

static void sigInterruptHandler (int)
 handler for user interrupt signal
static void sigAbortHandler (int)
 handler for abort signals
static void sigSegfaultHandler (int)
static DynamicSystemSolver * readXMLFile (const std::string &filename)

Public Attributes

int(DynamicSystemSolver::* solveConstraints_ )()
 pointer for election of prox-solver for contact equations
int(DynamicSystemSolver::* solveImpacts_ )(double dt)
 function pointer for election of prox-solver for impact equations on velocity level

Protected Member Functions

void updatezdRef (const fmatvec::Vec &ext)
 references to differentiated external state
virtual void updaterFactors ()
 update relaxation factors for contact equations
void computeConstraintForces (double t)
 compute inverse kinetics constraint forces

Protected Attributes

fmatvec::SymMat MParent [2]
 mass matrix
fmatvec::SymMat LLMParent [2]
 Cholesky decomposition of mass matrix.
fmatvec::Mat TParent
 matrix of linear relation between differentiated positions and velocities
fmatvec::Mat WParent [2]
 contact force directions
fmatvec::Mat VParent [2]
 condensed contact force directions
fmatvec::Vec wbParent
 TODO.
fmatvec::Vec laParent
 contact force parameters
fmatvec::Vec rFactorParent
 relaxation parameters for contact equations
fmatvec::Vec sParent
 TODO.
fmatvec::Vec resParent
 residuum of contact equations
fmatvec::Vec gParent
 relative distances
fmatvec::Vec gdParent
 relative velocities
fmatvec::Vec zdParent
 differentiated state
fmatvec::Vec udParent1
fmatvec::Vec hParent [2]
 smooth, smooth with respect to objects, smooth with respect to links right hand side
fmatvec::Vec rParent [2]
 nonsmooth right hand side
fmatvec::Vec fParent
 right hand side of order one parameters
fmatvec::Vec svParent
 stopvector (rootfunctions for event driven integration
fmatvec::VecInt jsvParent
 boolean evaluation of stopvector
fmatvec::VecInt LinkStatusParent
 status vector of set valued links with piecewise link equation (which piece is valid)
fmatvec::VecInt LinkStatusRegParent
 status vector of single valued links
fmatvec::SparseMat Gs
 sparse mass action matrix
fmatvec::SqrMat Jprox
 JACOBIAN of contact equations for Newton scheme.
fmatvec::SqrMat G
 mass action matrix
fmatvec::Vec b
 TODO.
bool term
 boolean to check for termination of contact equations solution
int maxIter
 maximum number of contact iterations, high number of contact iterations for warnings, maximum number of damping steps for Newton scheme
int highIter
int maxDampingSteps
double lmParm
 Levenberg-Marquard parameter.
Solver contactSolver
 solver for contact equations and impact equations
Solver impactSolver
Strategy strategy
 relaxarion strategy for solution of fixed-point scheme
LinAlg linAlg
 linear system solver used for Newton scheme in contact equations
bool stopIfNoConvergence
 flag if the contact equations should be stopped if there is no convergence
bool dropContactInfo
 flag if contact matrices for debugging should be dropped in no-convergence case
bool useOldla
 flag if contac force parameter of last time step should be used
bool numJac
 flag if Jacobian for Newton scheme should be calculated numerically
fmatvec::VecInt decreaseLevels
 decreasing relaxation factors is done in levels containing the number of contact iterations as condition
fmatvec::VecInt checkTermLevels
 TODO.
bool checkGSize
 boolean if force action matrix should be resized in each step
int limitGSize
 TODO.
int warnLevel
 level for warning output (0-2)
bool peds
 TODO, flag for occuring impact and sticking in event driven solver.
unsigned int driftCount
 TODO, additional stop in event driven solver for drift correction.
unsigned int flushEvery
 flushes all hdf5-files every x-times the plot-routine is called TODO
unsigned int flushCount
 counts plot-calls until files to be flushed TODO
double tolProj
 Tolerance for projection of generalized position.
fmatvec::Vec laInverseKineticsParent
 
    

fmatvec::Mat bInverseKineticsParent
fmatvec::Mat WInverseKineticsParent [2]
 
    

bool alwaysConsiderContact
bool inverseKinetics
bool initialProjection
fmatvec::Vec corrParent
int rootID
double gTol
double gdTol
double gddTol
double laTol
double LaTol

Private Member Functions

void constructor ()
 set plot feature default values
void addToGraph (Graph *graph, fmatvec::SqrMat &A, int i, std::vector< Object * > &objList)
 adds list of objects to tree

Private Attributes

bool integratorExitRequest
 boolean signal evaluation for end integration set by program
bool READZ0
 is a state read from a file
bool truncateSimulationFiles
std::vector< DynamicSystem * > dynamicsystemPreReorganize

Static Private Attributes

static bool exitRequest
 boolean signal evaluation for end integration set by user

Detailed Description

solver interface for modelling and simulation of dynamic systems

Author:
Martin Foerg
Date:
2009-03-31 some comments (Thorsten Schindler)
2009-07-16 splitted link / object right hand side (Thorsten Schindler)
2009-07-27 implicit integration (Thorsten Schindler)
2009-07-28 splitted interfaces (Thorsten Schindler)
2009-08-07 preintegration (Thorsten Schindler)
2009-08-21 reorganize hierarchy (Thorsten Schindler)
2009-12-14 revised inverse kinetics (Martin Foerg)
2010-07-06 modifications for timestepper ssc - e.g LinkStatus (Robert Huber)
2012-05-08 modifications for AutoTimeSteppingSSCIntegrator (Jan Clauberg)
2012-05-08 dhdq and dhdu with lower and upper bound (Jan Clauberg)
2014-09-16 contact forces are calculated on acceleration level (Thorsten Schindler)
Todo:

projectGeneralizedPositions seems to be buggy with at least TimeSteppingIntegrator (see SliderCrank)

RootFinding seems to be buggy (see EdgeMill)


Constructor & Destructor Documentation

MBSim::DynamicSystemSolver::DynamicSystemSolver ( const std::string &  name = "")

constructor

Parameters:
nameof dynamic system

Member Function Documentation

Parameters:
elementto add
Todo:
necessary? TODO
void MBSim::DynamicSystemSolver::addToGraph ( Graph *  graph,
fmatvec::SqrMat &  A,
int  i,
std::vector< Object * > &  objList 
) [private]

adds list of objects to tree

Parameters:
treewhere to add objects
currentnode in the tree
matrixof dependencies
currententry of matrix of dependencies
listof objects

compute inverse kinetics constraint forces

Parameters:
currenttime
fmatvec::Vec MBSim::DynamicSystemSolver::deltaq ( const fmatvec::Vec &  zParent,
double  t,
double  dt 
)
Returns:
position difference for current time
Parameters:
state
time
timestep
fmatvec::Vec MBSim::DynamicSystemSolver::deltau ( const fmatvec::Vec &  zParent,
double  t,
double  dt 
)
Parameters:
state
time
timestep
Returns:
velocity difference for current time
fmatvec::Vec MBSim::DynamicSystemSolver::deltax ( const fmatvec::Vec &  zParent,
double  t,
double  dt 
)

return x-state difference for current time

Parameters:
parentstate
time
timestep
Returns:
dynamic system solver

Reimplemented from MBSim::Element.

Element* MBSim::DynamicSystemSolver::getElement ( const std::string &  name)
Parameters:
nameof the element
Returns:
the pointer to an element
Todo:
not activated TODO
void MBSim::DynamicSystemSolver::getLinkStatus ( fmatvec::VecInt &  LinkStatusExt,
double  t 
)

brief collect status of all set-valued links

Parameters:
resultvector
time
void MBSim::DynamicSystemSolver::getLinkStatusReg ( fmatvec::VecInt &  LinkStatusRegExt,
double  t 
)

brief collect status of all single-valued links

Parameters:
resultvector
time
Returns:
information for solver including strategy and linear algebra
virtual void MBSim::DynamicSystemSolver::getsv ( const fmatvec::Vec &  z,
fmatvec::Vec &  svExt,
double  t 
) [virtual]

evaluation of stop vector

Parameters:
state
TODO
time
void MBSim::DynamicSystemSolver::init ( InitStage  stage) [virtual]

plots time series header

Parameters:
invocingparent class

Reimplemented from MBSim::DynamicSystem.

Initialize the system.

This function calls init(InitStage stage) with all stages defined in the enumeration InitStage, in the order in which they are defined in this enumeration.

The init(InitStage stage) functions of all classes MUST call the init(InitStage stage) functions of all objects for which this class holds as a container. This call is always done at the end of the function independent of the stage.

If the init(InitStage stage) function implements a given stage, the init(InitStage stage) function of the base class should be call or not as expected by the programer for this stage. For all other (not implemented) stages the function of the base call must always be called.

Example for a proper init(InitStage stage) function:

 void MyClass::init(InitStage stage) {
   if(stage==preInit) {
     // do something
     MyBaseClass::init(stage); // base must be called
     // do something
   }
   else if(stage==plot) {
     // do something
     // base need not be called
   }
   else
     MyBaseClass::init(stage);

   for(int i=0; i<container.size(); i++)
     container[i]->init(stage);
 }
void MBSim::DynamicSystemSolver::initla ( double  dt = 1.0)

load contact force parameter for use as starting value

Todo:
put in dynamic system TODO
void MBSim::DynamicSystemSolver::projectGeneralizedPositions ( double  t,
int  mode,
bool  fullUpdate = false 
)

drift projection for positions

Parameters:
time

drift projection for positions

Parameters:
time
void MBSim::DynamicSystemSolver::readz0 ( std::string  fileName)

reads state from a file

Parameters:
nameof the file
void MBSim::DynamicSystemSolver::savela ( double  dt = 1.0)

save contact force parameter for use as starting value in next time step

Todo:
put in dynamic system TODO
void MBSim::DynamicSystemSolver::setFlushEvery ( unsigned int  every) [inline]

set the number of plot-routine-calls after which all hdf5-files will be flushed

Parameters:
flag
void MBSim::DynamicSystemSolver::setgddTol ( double  tol) [inline, virtual]
Parameters:
tolerancefor relative acceleration

Reimplemented from MBSim::DynamicSystem.

void MBSim::DynamicSystemSolver::setgdTol ( double  tol) [inline, virtual]
Parameters:
tolerancefor relative velocity

Reimplemented from MBSim::DynamicSystem.

void MBSim::DynamicSystemSolver::setgTol ( double  tol) [inline, virtual]
Parameters:
tolerancefor relative velocity

Reimplemented from MBSim::DynamicSystem.

void MBSim::DynamicSystemSolver::setlaTol ( double  tol) [inline, virtual]
Parameters:
tolerancefor contact force

Reimplemented from MBSim::DynamicSystem.

void MBSim::DynamicSystemSolver::setLaTol ( double  tol) [inline, virtual]
Parameters:
tolerancefor impact

Reimplemented from MBSim::DynamicSystem.

set tolerance for projection of generalized position

Parameters:
tolerance
void MBSim::DynamicSystemSolver::setStopIfNoConvergence ( bool  flag,
bool  dropInfo = false 
) [inline]
Parameters:
specifywhether time integration should be stopped in case of no convergence of constraint-problem
specifywhether contact informations should be dropped to file
virtual void MBSim::DynamicSystemSolver::shift ( fmatvec::Vec &  z,
const fmatvec::VecInt &  jsv,
double  t 
) [virtual]

update for event driven integrator for event

Parameters:
state(return)
booleanevaluation of stop vector
time

solves prox-functions for contact forces using sparsity structure

Returns:
iterations of solver

solve contact equations with single step fixed point scheme

Returns:
iterations of solver

Reimplemented from MBSim::DynamicSystem.

solve contact equations with Gauss-Seidel scheme

Returns:
iterations of solver

Reimplemented from MBSim::DynamicSystem.

solution of contact equations with Cholesky decomposition

Returns:
iterations of solver
Todo:
put in dynamic system? TODO

solve contact equations with Newton scheme

Returns:
iterations of solver

Reimplemented from MBSim::DynamicSystem.

virtual int MBSim::DynamicSystemSolver::solveImpacts ( double  dt = 0) [virtual]

solves prox-functions for impacts on velocity level using sparsity structure

Parameters:
timestep-size
Returns:
iterations of solver
virtual int MBSim::DynamicSystemSolver::solveImpactsFixpointSingle ( double  dt = 0) [virtual]

solve impact equations with single step fixed point scheme on velocity level

Parameters:
timestep-size
Returns:
iterations of solver

Reimplemented from MBSim::DynamicSystem.

virtual int MBSim::DynamicSystemSolver::solveImpactsGaussSeidel ( double  dt = 0) [virtual]

solve impact equations with Gauss-Seidel scheme on velocity level

Parameters:
timestep-size
Returns:
iterations of solver

Reimplemented from MBSim::DynamicSystem.

solution of contact equations with Cholesky decomposition on velocity level

Parameters:
timestep-size, if 0 non-impulsive contributions vanish
Returns:
iterations of solver
Todo:
put in dynamic system? TODO
virtual int MBSim::DynamicSystemSolver::solveImpactsRootFinding ( double  dt = 0) [virtual]

solve impact equations with Newton scheme on velocity level

Parameters:
timestep-size
Returns:
iterations of solver

Reimplemented from MBSim::DynamicSystem.

void MBSim::DynamicSystemSolver::update ( const fmatvec::Vec &  z,
double  t,
int  options = 0 
)

update of dynamic system for time-stepping integrator

Parameters:
state
time
options= 0 (default) nothing = 1 force updates as if active constraints has changed
virtual void MBSim::DynamicSystemSolver::updateG ( double  t,
int  i = 0 
) [virtual]

updates mass action matrix

Parameters:
time
virtual void MBSim::DynamicSystemSolver::updater ( double  t,
int  j = 0 
) [virtual]

update smooth link force law

for links holding non-smooth contributions $\dd\vLambda$, the respective forces are projected into the minimal coordinate representation of the associated Bodys using the JACOBIAN matrices $\vJ$.

\[ \vr = \vJ\dd\vLambda \]

The JACOBIAN is provided by the connected Frames (which might be user-defined for Joints or internally defined for Contacts).

Parameters:
simulationtime
virtual void MBSim::DynamicSystemSolver::updaterFactors ( ) [protected, virtual]

update relaxation factors for contact equations

Todo:
global not available because of unsymmetric mass action matrix TODO

Reimplemented from MBSim::DynamicSystem.

void MBSim::DynamicSystemSolver::updatezdRef ( const fmatvec::Vec &  ext) [protected]

references to differentiated external state

Parameters:
differentiatedexternal state
void MBSim::DynamicSystemSolver::updatezRef ( const fmatvec::Vec &  ext)

references to external state

Parameters:
externalstate
void MBSim::DynamicSystemSolver::writez ( std::string  fileName,
bool  formatH5 = true 
)

writes state to a file

Parameters:
nameof the file
h5,elseascii
virtual void MBSim::DynamicSystemSolver::zdot ( const fmatvec::Vec &  z,
fmatvec::Vec &  zd,
double  t 
) [virtual]

update for event driven integrator during smooth phase

Parameters:
state
differentiatedstate (return)
time
virtual fmatvec::Vec MBSim::DynamicSystemSolver::zdot ( const fmatvec::Vec &  zParent,
double  t 
) [virtual]

standard invocation of smooth update for event driven integration

Parameters:
state
time

Member Data Documentation

int(DynamicSystemSolver::* MBSim::DynamicSystemSolver::solveConstraints_)()

pointer for election of prox-solver for contact equations

Returns:
iterations of solver
int(DynamicSystemSolver::* MBSim::DynamicSystemSolver::solveImpacts_)(double dt)

function pointer for election of prox-solver for impact equations on velocity level

Parameters:
timestep
Returns:
iterations of solver

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