artisynth.core.mechmodels
Class MechSystemSolver

java.lang.Object
  extended by artisynth.core.mechmodels.MechSystemSolver

public class MechSystemSolver
extends java.lang.Object

Implements implicit integration for MechSystem


Nested Class Summary
static class MechSystemSolver.Integrator
           
static class MechSystemSolver.MatrixSolver
           
static class MechSystemSolver.PosStabilization
          Indicates the method by which positions should be stabilized.
 
Field Summary
static boolean myDefaultHybridSolveP
           
static boolean profileConstraintSolves
           
 boolean profileKKTSolveTime
           
 boolean profileWholeSolve
           
static boolean useFictitousJacobianForces
           
static boolean useGlobalFriction
           
static boolean useVelProjection
           
 
Constructor Summary
MechSystemSolver(MechSystem system)
          Create a new MechSystem solver for a specified MechSystem.
MechSystemSolver(MechSystem system, MechSystemSolver solver)
          Create a new MechSystem solver for a specified MechSystem, with settings imported from an existing MechSystemSolver.
 
Method Summary
 void addActiveMassMatrix(MechSystem sys, SparseBlockMatrix S, double t)
           
 void addMassForces(VectorNd f, double t)
           
 void addSubVector(VectorNd vr, VectorNd v1, int off, int size)
          Computes
 void backwardEuler(double t0, double t1, StepAdjustment stepAdjust)
           
 void computeParametricForces(double h)
           
 void constrainedBackwardEuler(double t0, double t1, StepAdjustment stepAdjust)
           
 SparseBlockMatrix createActiveBilateralMatrix(double t)
           
 SparseBlockMatrix createActiveMassMatrix(double t)
          Creates and returns a sparse block matrix consisting of the current active portion of the mass matrix.
 SparseBlockMatrix createActiveStiffnessMatrix(double h)
           
 void dispose()
           
 void finalize()
           
 void fullBackwardEuler(double t0, double t1, StepAdjustment stepAdjust)
           
 boolean getHybridSolve()
           
 MechSystemSolver.Integrator getIntegrator()
           
 MechSystemSolver.MatrixSolver getMatrixSolver()
           
 int getMaxIterations()
           
 MechSystemSolver.PosStabilization getStabilization()
           
 double getTolerance()
           
 IterativeSolver.ToleranceType getToleranceType()
           
 boolean getUpdateForcesAtStepEnd()
           
 boolean hasMatrixSolver(MechSystemSolver.MatrixSolver solver)
           
 boolean isPardisoAvailable()
           
 void KKTFactorAndSolve(VectorNd vel, VectorNd fpar, VectorNd bf, VectorNd btmp, VectorNd vel0, double t, double h, boolean velocitySolve)
          Solves a KKT system in which the Jacobian augmented M matrix and and force vectors are given by
 void KKTFactorAndSolve(VectorNd vel, VectorNd fpar, VectorNd bf, VectorNd btmp, VectorNd vel0, double t, double h, double a0, double a1, double a2, double a3, boolean velocitySolve)
          Solves a KKT system in which the Jacobian augmented M matrix and and force vectors are given by
 void KKTSolve(VectorNd vel, VectorNd lam, VectorNd the, VectorNd bf)
          Solves the KKT system given a new right hand side bf.
 void mulActiveInertias(VectorNd b, VectorNd v)
           
 void nonDynamicSolve(double t0, double t1, StepAdjustment stepAdjust)
           
 void projectPosConstraints(double t)
           
 void projectRigidBodyPosConstraints(double t)
           
 void setCrsFileName(java.lang.String name)
           
 void setHybridSolve(boolean enable)
           
 void setIntegrator(MechSystemSolver.Integrator integrator)
           
 void setIterativeSolver(IterativeSolver solver)
           
static void setLogWriter(java.io.PrintWriter writer)
           
 void setMatrixSolver(MechSystemSolver.MatrixSolver solver)
           
 void setMaxIterations(int max)
           
 void setParametricTargets(double s, double h)
           
 void setStabilization(MechSystemSolver.PosStabilization stabilization)
           
 void setSubVector(VectorNd vr, VectorNd v1, int off, int size)
          Sets
 void setTolerance(double tol)
           
 void setToleranceType(IterativeSolver.ToleranceType type)
           
 void setUpdateForcesAtStepEnd(boolean enable)
           
 void solve(double t0, double t1, StepAdjustment stepAdjust)
           
 void trapezoidal(double t0, double t1, StepAdjustment stepAdjust)
           
 void updateMassMatrix(double t)
           
 void updateStateSizes()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

profileKKTSolveTime

public boolean profileKKTSolveTime

profileWholeSolve

public boolean profileWholeSolve

useVelProjection

public static boolean useVelProjection

useGlobalFriction

public static boolean useGlobalFriction

useFictitousJacobianForces

public static boolean useFictitousJacobianForces

myDefaultHybridSolveP

public static boolean myDefaultHybridSolveP

profileConstraintSolves

public static boolean profileConstraintSolves
Constructor Detail

MechSystemSolver

public MechSystemSolver(MechSystem system)
Create a new MechSystem solver for a specified MechSystem.


MechSystemSolver

public MechSystemSolver(MechSystem system,
                        MechSystemSolver solver)
Create a new MechSystem solver for a specified MechSystem, with settings imported from an existing MechSystemSolver.

Method Detail

setUpdateForcesAtStepEnd

public void setUpdateForcesAtStepEnd(boolean enable)

getUpdateForcesAtStepEnd

public boolean getUpdateForcesAtStepEnd()

getHybridSolve

public boolean getHybridSolve()

setHybridSolve

public void setHybridSolve(boolean enable)

setParametricTargets

public void setParametricTargets(double s,
                                 double h)

computeParametricForces

public void computeParametricForces(double h)

updateMassMatrix

public void updateMassMatrix(double t)

createActiveMassMatrix

public SparseBlockMatrix createActiveMassMatrix(double t)
Creates and returns a sparse block matrix consisting of the current active portion of the mass matrix. Used mainly for exporting information for analysis.

Parameters:
t - current time
Returns:
current active mass matrix

updateStateSizes

public void updateStateSizes()

setIntegrator

public void setIntegrator(MechSystemSolver.Integrator integrator)

setIterativeSolver

public void setIterativeSolver(IterativeSolver solver)

getIntegrator

public MechSystemSolver.Integrator getIntegrator()

getTolerance

public double getTolerance()

setTolerance

public void setTolerance(double tol)

getToleranceType

public IterativeSolver.ToleranceType getToleranceType()

setToleranceType

public void setToleranceType(IterativeSolver.ToleranceType type)

setMaxIterations

public void setMaxIterations(int max)

getMaxIterations

public int getMaxIterations()

setMatrixSolver

public void setMatrixSolver(MechSystemSolver.MatrixSolver solver)

setStabilization

public void setStabilization(MechSystemSolver.PosStabilization stabilization)

getStabilization

public MechSystemSolver.PosStabilization getStabilization()

isPardisoAvailable

public boolean isPardisoAvailable()

hasMatrixSolver

public boolean hasMatrixSolver(MechSystemSolver.MatrixSolver solver)

getMatrixSolver

public MechSystemSolver.MatrixSolver getMatrixSolver()

nonDynamicSolve

public void nonDynamicSolve(double t0,
                            double t1,
                            StepAdjustment stepAdjust)

solve

public void solve(double t0,
                  double t1,
                  StepAdjustment stepAdjust)

mulActiveInertias

public void mulActiveInertias(VectorNd b,
                              VectorNd v)

addActiveMassMatrix

public void addActiveMassMatrix(MechSystem sys,
                                SparseBlockMatrix S,
                                double t)

addMassForces

public void addMassForces(VectorNd f,
                          double t)

addSubVector

public void addSubVector(VectorNd vr,
                         VectorNd v1,
                         int off,
                         int size)
Computes
 vr += v1(off:off+size-1)
 


setSubVector

public void setSubVector(VectorNd vr,
                         VectorNd v1,
                         int off,
                         int size)
Sets
 vr = v1(off:off+size-1)
 


backwardEuler

public void backwardEuler(double t0,
                          double t1,
                          StepAdjustment stepAdjust)

KKTFactorAndSolve

public void KKTFactorAndSolve(VectorNd vel,
                              VectorNd fpar,
                              VectorNd bf,
                              VectorNd btmp,
                              VectorNd vel0,
                              double t,
                              double h,
                              boolean velocitySolve)
Solves a KKT system in which the Jacobian augmented M matrix and and force vectors are given by
 M' = M - h df/dv - h^2 df/dx 

 bf' = bf + (-h df/dv) vel0
 
When used to solve for velocities in an implicit integrator, then on input, bf is assumed to be given by
 bf = M vel0 + h f
 
where h is the time step and f is the generalized forces, while on output bf is modified to include the Jacobian terms described above. XXX question about which time do we want? t0 or t1? Right now it is set to t1; setting it to t0 seems to cause a small difference in the inverse tongue model.


KKTFactorAndSolve

public void KKTFactorAndSolve(VectorNd vel,
                              VectorNd fpar,
                              VectorNd bf,
                              VectorNd btmp,
                              VectorNd vel0,
                              double t,
                              double h,
                              double a0,
                              double a1,
                              double a2,
                              double a3,
                              boolean velocitySolve)
Solves a KKT system in which the Jacobian augmented M matrix and and force vectors are given by
 M' = M + a0 df/dv + a1 df/dx 

 bf' = bf + (a2 df/dv + a3 df/dx) vel0
 
It is assumed that a0 and a1 are both non-zero. It is also assumed that the a0 = -alpha h, where h is the step size and alpha indicates the propertion of implicitness for the solve; i.e., for regular backward euler, alpha=1, while for trapezoidal solves, alpha = 0.5; When used to solve for velocities in an implicit integrator, then on input, bf is assumed to be given by
 bf = M vel0 + h f
 
where h is the time step and f is the generalized forces, while on output bf is modified to include the Jacobian terms described above.


setCrsFileName

public void setCrsFileName(java.lang.String name)

setLogWriter

public static void setLogWriter(java.io.PrintWriter writer)

KKTSolve

public void KKTSolve(VectorNd vel,
                     VectorNd lam,
                     VectorNd the,
                     VectorNd bf)
Solves the KKT system given a new right hand side bf. It is assumed that KKTFactorAndSolve has already been called once, and that the initial velocity vel0 is unchanged from that call. Recall that on input to KKTFactorAndSolve, bf is assumed to be of the form
 bf = M vel0 + f1
 
while on output it is modified to include Jacobian terms that depend on vel0. Thus if one want to use KKTSolve to compute velocities based on different force values f2, one should use a calling sequence similar to the following:
 bf1 = M vel0 + f1
 KKTFactorAndSolve (vel1, bf1, btmp, vel0, ...)
 bf2 = bf1 - f1 + f2
 KKTSolve (vel2, myLam, the, bf2)
 


projectPosConstraints

public void projectPosConstraints(double t)

projectRigidBodyPosConstraints

public void projectRigidBodyPosConstraints(double t)

constrainedBackwardEuler

public void constrainedBackwardEuler(double t0,
                                     double t1,
                                     StepAdjustment stepAdjust)

fullBackwardEuler

public void fullBackwardEuler(double t0,
                              double t1,
                              StepAdjustment stepAdjust)

trapezoidal

public void trapezoidal(double t0,
                        double t1,
                        StepAdjustment stepAdjust)

createActiveStiffnessMatrix

public SparseBlockMatrix createActiveStiffnessMatrix(double h)

createActiveBilateralMatrix

public SparseBlockMatrix createActiveBilateralMatrix(double t)

dispose

public void dispose()

finalize

public void finalize()
Overrides:
finalize in class java.lang.Object