artisynth.core.mechmodels
Class MechSystemBase

java.lang.Object
  extended by artisynth.core.modelbase.ModelComponentBase
      extended by artisynth.core.modelbase.ComponentList<ModelComponent>
          extended by artisynth.core.modelbase.ModelBase
              extended by artisynth.core.modelbase.RenderableModelBase
                  extended by artisynth.core.mechmodels.MechSystemBase
All Implemented Interfaces:
MechSystem, MechSystemModel, ComponentChangeListener, ComponentListView<ModelComponent>, CompositeComponent, HasState, IndexedComponentList, Model, ModelComponent, MutableCompositeComponent<ModelComponent>, ParameterizedClass, RenderableComponent, java.lang.Cloneable, java.lang.Iterable<ModelComponent>, java.util.Collection<ModelComponent>, HasProperties, HierarchyNode, GLRenderable, GLSelectable, HasRenderProps, Renderable, Disposable, ListView<ModelComponent>, Scannable
Direct Known Subclasses:
FemModel, MechModel

public abstract class MechSystemBase
extends RenderableModelBase
implements MechSystemModel


Nested Class Summary
 
Nested classes/interfaces inherited from interface artisynth.core.modelbase.ModelComponent
ModelComponent.NavpanelVisibility
 
Nested classes/interfaces inherited from interface artisynth.core.mechmodels.MechSystem
MechSystem.ConstraintInfo, MechSystem.FrictionInfo
 
Nested classes/interfaces inherited from interface artisynth.core.modelbase.CompositeComponent
CompositeComponent.NavpanelDisplay
 
Field Summary
static boolean myParametricsInSystemMatrix
           
static PropertyList myProps
           
 
Fields inherited from class artisynth.core.modelbase.ComponentList
DEFAULT_NAVPANEL_DISPLAY
 
Fields inherited from class artisynth.core.modelbase.ModelComponentBase
enforceUniqueCompositeNames, enforceUniqueNames, myNumber, NULL_OBJ, useCompactPathNames
 
Fields inherited from interface artisynth.core.mechmodels.MechSystem
COMPUTE_CONTACTS, UPDATE_CONTACTS
 
Fields inherited from interface maspack.render.GLRenderable
TRANSLUCENT, TWO_DIMENSIONAL
 
Constructor Summary
MechSystemBase(java.lang.String name)
           
 
Method Summary
 void addActivePosImpulse(VectorNd x, double h, VectorNd v)
          Computes an adjustment to the active positions of the system (stored in the vector q) by applying a velocity u for time h.
 void addAttachmentJacobian(SparseNumberedBlockMatrix S, VectorNd f)
           
 void addAttachmentSolveBlocks(SparseNumberedBlockMatrix S)
           
 void addGeneralSolveBlocks(SparseNumberedBlockMatrix M)
           
 void addPosJacobian(SparseNumberedBlockMatrix S, VectorNd f, double s)
          Adds the current force-position Jacobian, scaled by h, to the matrix S, which should have been previously created with a call to buildSolveMatrix().
 void addVelJacobian(SparseNumberedBlockMatrix S, VectorNd f, double s)
          Adds the current force-velocity Jacobian, scaled by h, to the matrix S, which should have been previously created with a call to buildSolveMatrix().
 void applyAttachmentForces()
           
 boolean buildMassMatrix(SparseBlockMatrix M)
          Builds a mass matrix for this system.
 void buildSolveMatrix(SparseNumberedBlockMatrix S)
          Builds a solve matrix for this system.
 MechSystemBase copy(int flags, java.util.Map<ModelComponent,ModelComponent> copyMap)
           
 ComponentState createState(ComponentState prevState)
          Factory routine to create a state object for this component, which can then be used as an argument for HasState.setState(artisynth.core.modelbase.ComponentState) and HasState.getState(artisynth.core.modelbase.ComponentState).
 SparseBlockMatrix createVelocityJacobian()
           
 void getActiveForces(VectorNd f)
          Returns the generalized forces acting on all the active components in this system.
 void getActivePosDerivative(VectorNd dxdt, double t)
          Gets the current value of the position derivative for all active components.
 void getActivePosState(VectorNd q)
          Gets the current position state for all active components.
 int getActivePosStateSize()
          Returns the size of the position state for all active components.
 SparseBlockMatrix getActiveStiffness()
           
 void getActiveVelState(VectorNd u)
          Gets the current velocity state for all active components.
 int getActiveVelState(VectorNd u, int idx, boolean bodyCoords)
           
 int getActiveVelStateSize()
          Returns the size of the velocity state for all active components.
 SparseBlockMatrix getAttachmentConstraints()
          Returns the transpose of the attachment constraint matrix, along with the vector of derivative offsets.
 VectorNd getAttachmentDerivatives()
           
 void getAuxState(DataBuffer data)
           
 int getBilateralConstraints(SparseBlockMatrix GT, VectorNd dg)
          Obtains the transpose of the current bilateral constraint matrix G for this system.
 void getBilateralConstraintSizes(VectorNi sizes)
           
 void getBilateralImpulses(VectorNd lam)
          Returns from the system the most recently computed bilateral constraint impulses.
 int getBilateralImpulses(VectorNd lam, int idx)
           
 void getBilateralInfo(MechSystem.ConstraintInfo[] ginfo)
          Obtains information for all the constraint directions returned by the most recent call to getBilateralConstraints().
static MechSystemSolver.PosStabilization getDefaultStabilization()
           
 boolean getDynamicsEnabled()
           
 void getFrictionConstraints(SparseBlockMatrix DT, MechSystem.FrictionInfo[] finfo)
          Obtains the transpose of the current friction constraint matrix D for this system.
 void getInitialState(ComponentState newstate, ComponentState oldstate)
          Gets an initial state for this component and returns the value in state.
 void getInverseMassMatrix(SparseBlockMatrix Minv, SparseBlockMatrix M)
          Sets Minv to the inverse of the mass matrix M.
 double getMass()
           
 void getMassMatrix(SparseBlockMatrix M, VectorNd f, double t)
          Sets M to the current value of the mass matrix for this system, evaluated at time t.
 int getNumBilateralImpulses()
           
 int getNumUnilateralImpulses()
           
 void getParametricForces(VectorNd f)
          Gets the forces associated with parametric components.
 void getParametricPosState(VectorNd q)
          Gets the current position state for all parametric components.
 int getParametricPosStateSize()
          Returns the size of the position state for all parametric components.
 void getParametricPosTarget(VectorNd q, double s, double h)
          Obtains the desired target position for all parametric components at a particular time.
 void getParametricVelState(VectorNd u)
          Gets the current velocity state for all parametric components.
 int getParametricVelStateSize()
          Returns the size of the velocity state for all parametric components.
 void getParametricVelTarget(VectorNd u, double s, double h)
          Obtains the desired target velocity for all parametric components at a particular time.
 double getPenetrationLimit()
           
 void getSlaveObjectComponents(java.util.List<HasSlaveObjects> comps, int level)
          Should be overridden in subclasses to return all the HasSlaveObjects ' components within this model.
 int getSolveMatrixType()
          Returns information about the solve matrix for this system.
 MechSystemSolver getSolver()
           
 MechSystemSolver.PosStabilization getStabilization()
           
 void getState(ComponentState pstate)
          Get the current state of this component.
 int getStructureVersion()
          Returns the current structure version of this system.
 void getUnilateralConstraints(SparseBlockMatrix NT, VectorNd dn)
          Obtains the transpose of the current unilateral constraint matrix N for this system.
 void getUnilateralConstraintSizes(VectorNi sizes)
           
 void getUnilateralImpulses(VectorNd the)
          Returns from the system the most recently computed unilateral constraint impulses.
 int getUnilateralImpulses(VectorNd the, int idx)
           
 void getUnilateralInfo(MechSystem.ConstraintInfo[] ninfo)
          Obtains information for all the constraint directions returned by the most recent call to getUnilateralConstraints().
 boolean getUpdateForcesAtStepEnd()
           
 boolean hasParameterizedType()
          Returns true if this class explicitly utilizes a parameterized type.
 void initialize(double t)
          Causes this model to initialize itself at time t.
 int maxFrictionConstraintSets()
          Returns that maximum number of friction constraint set that may be added by the method getFrictionConstraints().
 int numActiveComponents()
          Returns the current number of active components in this system.
 int numAttachedComponents()
           
 int numParametricComponents()
          Returns the current number of parametric components in this system.
 StepAdjustment preadvance(double t0, double t1, int flags)
          Prepares this object for advance from time t0 to time t1.
 void printActiveStiffness()
           
 void recursivelyFinalizeAdvance(StepAdjustment stepAdjust, double t0, double t1, int flags, int level)
           
 void recursivelyInitialize(double t, int level)
           
 void reduceVelocityJacobian(SparseBlockMatrix J)
           
 void setActiveForces(VectorNd f)
          Sets the generalized forces acting on all the active components in this system.
 void setActivePosState(VectorNd q)
          Sets the current position state for all active components.
 void setActiveVelState(VectorNd u)
          Sets the current velocity state for all active components.
 void setAuxState(DataBuffer data)
           
 void setBilateralImpulses(VectorNd lam, double h)
          Supplies to the system the most recently computed bilateral constraint impulses.
 int setBilateralImpulses(VectorNd lam, double h, int idx)
           
static void setDefaultStabilization(MechSystemSolver.PosStabilization stablizer)
           
 void setDynamicsEnabled(boolean enable)
           
 void setParametricForces(VectorNd f)
          Sets the forces associated with parametric components.
 void setParametricPosState(VectorNd q)
          Sets the current position state for all parametric components.
 void setParametricVelState(VectorNd q)
          Sets the current velocity state for all parametric components.
 void setPenetrationLimit(double lim)
           
 void setStabilization(MechSystemSolver.PosStabilization stablizer)
           
 void setState(ComponentState pstate)
          Set the state of this component.
 void setUnilateralImpulses(VectorNd the, double h)
          Supplies to the system the most recently computed unilateral constraint impulses.
 int setUnilateralImpulses(VectorNd the, double h, int idx)
           
 void setUpdateForcesAtStepEnd(boolean enable)
           
 void updateAttachmentPos()
           
 void updateAttachmentVel()
           
 void updateConstraints(double t, StepAdjustment stepAdjust, int flags)
          Updates the constraints associated with this system to be consistent with the current position and indicated time.
 void updateForces(double t)
          Updates all internal forces associated with this system to be consistent with the current position and velocity and the indicated time t.
 void updatePosState()
           
 void updateVelState()
           
 void writeBilateralConstraintMatrix(java.lang.String fileName)
           
 void writeMassMatrix(java.lang.String fileName)
           
 void writeStiffnessMatrix(java.lang.String fileName, double h)
           
 
Methods inherited from class artisynth.core.modelbase.RenderableModelBase
createRenderProps, getAllPropertyInfo, getRenderHints, getRenderProps, getSelection, isSelectable, numSelectionQueriesNeeded, prerender, render, setRenderProps, updateBounds
 
Methods inherited from class artisynth.core.modelbase.ModelBase
advance, copy, dispose, getInitialState, getMaxStepSize, hierarchyContainsReferences, setInitialState, setMaxStepSize
 
Methods inherited from class artisynth.core.modelbase.ComponentList
add, add, addAll, addComponents, addFixed, addNumbered, clear, clone, componentChanged, contains, contains, containsAll, ensureCapacity, findComponent, get, get, getByNumber, getChildren, getNavpanelDisplay, getNumberLimit, getShortName, getTypeParameter, hasChildren, indexOf, isEmpty, iterator, nextComponentNumber, numComponents, postscan, remove, remove, removeAll, removeAll, removeComponents, retainAll, scan, setNavpanelDisplay, setNumberingStartAtOne, setShortName, size, toArray, toArray, updateNameMap
 
Methods inherited from class artisynth.core.modelbase.ModelComponentBase
checkFlag, checkName, checkNameUniqueness, clearFlag, connectToHierarchy, createTempFlag, disconnectFromHierarchy, getGrandParent, getHardReferences, getName, getNameRange, getNavpanelVisibility, getNavpanelVisibility, getNumber, getParent, getProperty, getSoftReferences, hasState, isFixed, isMarked, isSelected, isWritable, makeValidName, makeValidName, notifyParentOfChange, printReferences, recursivelyContained, recursivelyContains, removeTempFlag, setFixed, setFlag, setMarked, setName, setNavpanelVisibility, setNavpanelVisibility, setNumber, setParent, setSelected, updateReferences, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface artisynth.core.mechmodels.MechSystemModel
checkVelocityStability, getAttachments, getAuxStateComponents, getCollidables, getConstrainers, getDynamicComponents, getForceEffectors
 
Methods inherited from interface artisynth.core.modelbase.Model
advance, dispose, getMaxStepSize
 
Methods inherited from interface artisynth.core.modelbase.ModelComponent
connectToHierarchy, disconnectFromHierarchy, getHardReferences, getName, getNavpanelVisibility, getNumber, getParent, getSoftReferences, hasState, isFixed, isMarked, isSelected, notifyParentOfChange, postscan, scan, setFixed, setMarked, setName, setNumber, setParent, setSelected, updateReferences
 
Methods inherited from interface maspack.properties.HasProperties
getAllPropertyInfo, getProperty
 
Methods inherited from interface maspack.properties.HierarchyNode
getChildren, hasChildren
 
Methods inherited from interface maspack.util.Scannable
isWritable, write
 
Methods inherited from interface artisynth.core.modelbase.ComponentListView
getName
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Field Detail

myParametricsInSystemMatrix

public static boolean myParametricsInSystemMatrix

myProps

public static PropertyList myProps
Constructor Detail

MechSystemBase

public MechSystemBase(java.lang.String name)
Method Detail

setPenetrationLimit

public void setPenetrationLimit(double lim)

getPenetrationLimit

public double getPenetrationLimit()

getDynamicsEnabled

public boolean getDynamicsEnabled()

setDynamicsEnabled

public void setDynamicsEnabled(boolean enable)

hasParameterizedType

public boolean hasParameterizedType()
Description copied from interface: ParameterizedClass
Returns true if this class explicitly utilizes a parameterized type.

Specified by:
hasParameterizedType in interface ParameterizedClass
Overrides:
hasParameterizedType in class ComponentList<ModelComponent>

getSolver

public MechSystemSolver getSolver()

createVelocityJacobian

public SparseBlockMatrix createVelocityJacobian()

reduceVelocityJacobian

public void reduceVelocityJacobian(SparseBlockMatrix J)

getNumUnilateralImpulses

public int getNumUnilateralImpulses()

getUnilateralConstraintSizes

public void getUnilateralConstraintSizes(VectorNi sizes)

getUnilateralConstraints

public void getUnilateralConstraints(SparseBlockMatrix NT,
                                     VectorNd dn)
Description copied from interface: MechSystem
Obtains the transpose of the current unilateral constraint matrix N for this system. This is built and stored in NT. On input, NT should be empty with zero size; it will be sized appropriately by the system. The derivative term is returned in dn; this is given by
 dn/dt u
 
where u is the current system velocity. dn will also be sized appropriately by the system.

Specified by:
getUnilateralConstraints in interface MechSystem
Parameters:
NT - returns the transpose of N
dn - returns the derivative term for N

getNumBilateralImpulses

public int getNumBilateralImpulses()

getBilateralConstraintSizes

public void getBilateralConstraintSizes(VectorNi sizes)

getBilateralConstraints

public int getBilateralConstraints(SparseBlockMatrix GT,
                                   VectorNd dg)
Description copied from interface: MechSystem
Obtains the transpose of the current bilateral constraint matrix G for this system. This is built and stored in GT. On input, GT should be empty with zero size; it will be sized appropriately by the system. The derivative term is returned in dg; this is given by
 dG/dt u
 
where u is the current system velocity. dg will also be sized appropriately by the system.

The method returns a version number for the constraint structure. This number should be incremented whenever the block structure of the constraint matrix changes.

Specified by:
getBilateralConstraints in interface MechSystem
Parameters:
GT - returns the transpose of G
dg - returns the derivative term for G
Returns:
constraint structure version number

getBilateralInfo

public void getBilateralInfo(MechSystem.ConstraintInfo[] ginfo)
Description copied from interface: MechSystem
Obtains information for all the constraint directions returned by the most recent call to getBilateralConstraints(). The information is returned in the array ginfo, which should contain preallocated ConstraintInfo structures and should have a length greater or equal to the column size of GT returned by getBilateralConstraints().

Specified by:
getBilateralInfo in interface MechSystem
Parameters:
ginfo - Array of ConstraintInfo objects used to return the constraint information.

setBilateralImpulses

public void setBilateralImpulses(VectorNd lam,
                                 double h)
Description copied from interface: MechSystem
Supplies to the system the most recently computed bilateral constraint impulses. These are supplied by the vector lam, which should have a size greater or equal to the column size of GT returned by getBilateralConstraints().

Specified by:
setBilateralImpulses in interface MechSystem
Parameters:
lam - Bilateral constraint impulses being supplied to the system.
h - Time interval associated with the impulses. Dividing by this should give the average constraint forces.

setBilateralImpulses

public int setBilateralImpulses(VectorNd lam,
                                double h,
                                int idx)

getBilateralImpulses

public void getBilateralImpulses(VectorNd lam)
Description copied from interface: MechSystem
Returns from the system the most recently computed bilateral constraint impulses. These are stored in the vector lam, which should have a size greater or equal to the column size of GT returned by getBilateralConstraints(). For constraints which where present in the previous solve step, the impulse values should equal those which were set by the prevous call to setBilateralImpulses(). Otherwise, values can be estimated from previous impulse values (where appropriate), or supplied as 0.

Specified by:
getBilateralImpulses in interface MechSystem
Parameters:
lam - Bilateral constraint impulses being returned from the system.

getBilateralImpulses

public int getBilateralImpulses(VectorNd lam,
                                int idx)

getUnilateralInfo

public void getUnilateralInfo(MechSystem.ConstraintInfo[] ninfo)
Description copied from interface: MechSystem
Obtains information for all the constraint directions returned by the most recent call to getUnilateralConstraints(). The information is returned in the array ninfo, which should contain preallocated ConstraintInfo structures and should have a length greater or equal to the column size of NT returned by getUnilateralConstraints().

Specified by:
getUnilateralInfo in interface MechSystem
Parameters:
ninfo - Array of ConstraintInfo objects used to return the constraint information.

setUnilateralImpulses

public void setUnilateralImpulses(VectorNd the,
                                  double h)
Description copied from interface: MechSystem
Supplies to the system the most recently computed unilateral constraint impulses. These are supplied by the vector the, which should have a size greater or equal to the column size of NT returned by getUnilateralConstraints().

Specified by:
setUnilateralImpulses in interface MechSystem
Parameters:
the - Unilateral constraint impulses being supplied to the system.
h - Time interval associated with the impulses. Dividing by this should give the average constraint forces.

setUnilateralImpulses

public int setUnilateralImpulses(VectorNd the,
                                 double h,
                                 int idx)

getUnilateralImpulses

public void getUnilateralImpulses(VectorNd the)
Description copied from interface: MechSystem
Returns from the system the most recently computed unilateral constraint impulses. These are stored in the vector the, which should have a size greater or equal to the column size of NT returned by getUnilateralConstraints(). For constraints which where present in the previous solve step, the impulse values should equal those which were set by the prevous call to setUnilateralImpulses(). Otherwise, values can be estimated from previous impulse values (where appropriate), or supplied as 0.

Specified by:
getUnilateralImpulses in interface MechSystem
Parameters:
the - Unilateral constraint impulses being returned from the system.

getUnilateralImpulses

public int getUnilateralImpulses(VectorNd the,
                                 int idx)

maxFrictionConstraintSets

public int maxFrictionConstraintSets()
Description copied from interface: MechSystem
Returns that maximum number of friction constraint set that may be added by the method getFrictionConstraints(). This is used to size the finfo array supplied to that method.

Specified by:
maxFrictionConstraintSets in interface MechSystem
Returns:
maximum friction constraint sets

getFrictionConstraints

public void getFrictionConstraints(SparseBlockMatrix DT,
                                   MechSystem.FrictionInfo[] finfo)
Description copied from interface: MechSystem
Obtains the transpose of the current friction constraint matrix D for this system. This is built and stored in DT. On input, DT should be empty with zero size; it will be sized appropriately by the system.

Each column block in DT describes a friction constraint set associated with one unilateral or bilateral constraint. Information about each friction constraint set is returned in the array finfo, which should contain preallocated FrictionInfo structures and should have a length greater or equal to the value returned by FrictionConstraintSets().

Specified by:
getFrictionConstraints in interface MechSystem
Parameters:
DT - returns the transpose of D
finfo - returns information for each friction constraint set

updateConstraints

public void updateConstraints(double t,
                              StepAdjustment stepAdjust,
                              int flags)
Description copied from interface: MechSystem
Updates the constraints associated with this system to be consistent with the current position and indicated time. This method should be called between any change to position values and any call that obtains constraint information (such as getBilateralConstraints().

Because contact computations are expensive, the constraints associated with contact should only be computed if the flags MechSystem.COMPUTE_CONTACTS or MechSystem.UPDATE_CONTACTS are specified. The former calls for contact information to be computed from scratch, while the latter calls for contact information to be modified to reflect changes in body positions, while preserving the general contact state between bodies.

In the process of updating the constraints, the system may determine that a smaller step size is needed. This is particulary true when contact calculations show an unacceptable level of interpenetration. A smaller step size can be recommended If so, it can indicate this through the optional argument stepAdjust, if present.

Specified by:
updateConstraints in interface MechSystem
Parameters:
t - current time
stepAdjust - (optional) can be used to indicate whether the current advance should be redone with a smaller step size.

getStructureVersion

public int getStructureVersion()
Description copied from interface: MechSystem
Returns the current structure version of this system. The structure version should be incremented whenever the number and arrangement of active and parametric components changes, implying that any mass and solve matrices should be be rebuilt.

Specified by:
getStructureVersion in interface MechSystem
Returns:
current structure version number for this system

getSlaveObjectComponents

public void getSlaveObjectComponents(java.util.List<HasSlaveObjects> comps,
                                     int level)
Should be overridden in subclasses to return all the HasSlaveObjects ' components within this model.

Specified by:
getSlaveObjectComponents in interface MechSystemModel
Parameters:
comps - HasSlaveObjects components should be added to this list

getActivePosState

public void getActivePosState(VectorNd q)
Gets the current position state for all active components. This is stored in the vector q (which will be sized appropriately by the system).

Specified by:
getActivePosState in interface MechSystem
Parameters:
q - vector in which the state is stored

getActiveVelState

public void getActiveVelState(VectorNd u)
Gets the current velocity state for all active components. This is stored in the vector u (which will be sized appropriately by the system).

Specified by:
getActiveVelState in interface MechSystem
Parameters:
u - vector in which the state is stored

getActiveVelState

public int getActiveVelState(VectorNd u,
                             int idx,
                             boolean bodyCoords)

setActivePosState

public void setActivePosState(VectorNd q)
Sets the current position state for all active components. This is supplied in the vector q, whose size should be greater than or equal to the value returned by getActivePosStateSize().

Specified by:
setActivePosState in interface MechSystem
Parameters:
q - vector supplying the state information

addActivePosImpulse

public void addActivePosImpulse(VectorNd x,
                                double h,
                                VectorNd v)
Description copied from interface: MechSystem
Computes an adjustment to the active positions of the system (stored in the vector q) by applying a velocity u for time h. Where velocity equals position derivative, this corresponds to computing
 q += h u.
 
In other situations, such as where position is orientation expressed as a quaternion and velocity is angular velocity, the system should perform the analagous computation. q should have a size greater or equal to the value returned by getActivePosStateSize(), and u should have a size greater or equal to the value returned by getActiveVelStateSize().

Specified by:
addActivePosImpulse in interface MechSystem
Parameters:
x - positions to be adjusted
h - length of time to apply velocity
v - velocity to be applied

setActiveVelState

public void setActiveVelState(VectorNd u)
Sets the current velocity state for all active components. This is supplied in the vector u, whose size should be greater than or equal to the value returned by getActiveVelStateSize().

Specified by:
setActiveVelState in interface MechSystem
Parameters:
u - vector supplying the state information

getActivePosStateSize

public int getActivePosStateSize()
Returns the size of the position state for all active components. This should remain unchanged as long as the current structure version (returned by getStructureVersion() remains unchanged.

Specified by:
getActivePosStateSize in interface MechSystem
Returns:
size of the active position state

getActiveVelStateSize

public int getActiveVelStateSize()
Returns the size of the velocity state for all active components. This should remain unchanged as long as the current structure version (returned by getStructureVersion() remains unchanged.

Specified by:
getActiveVelStateSize in interface MechSystem
Returns:
size of the velocity state

getActivePosDerivative

public void getActivePosDerivative(VectorNd dxdt,
                                   double t)
Description copied from interface: MechSystem
Gets the current value of the position derivative for all active components. This is stored in the vector dxdt (which will be sized appropriately by the system).

Specified by:
getActivePosDerivative in interface MechSystem
Parameters:
dxdt - vector in which the derivative is stored
t - current time value

getActiveForces

public void getActiveForces(VectorNd f)
Returns the generalized forces acting on all the active components in this system. This is stored in the vector f (which will be sized appropriately by the system).

Specified by:
getActiveForces in interface MechSystem
Parameters:
f - vector in which the forces are stored

setActiveForces

public void setActiveForces(VectorNd f)
Sets the generalized forces acting on all the active components in this system. The values are specifies in the vector f, whose size should be greater or equal to the value returned by getActiveVelStateSize().

Specified by:
setActiveForces in interface MechSystem
Parameters:
f - vector specifying the forces to be set

getParametricForces

public void getParametricForces(VectorNd f)
Gets the forces associated with parametric components. This is returned in the vector f (which will be sized appropriately by the system).

Specified by:
getParametricForces in interface MechSystem
Parameters:
f - vector in which to return the force information

setParametricForces

public void setParametricForces(VectorNd f)
Sets the forces associated with parametric components. This is supplied in the vector f, whose size should be greater or equal to the value returned by getParametricVelStateSize().

Specified by:
setParametricForces in interface MechSystem
Parameters:
f - vector supplying the force information

preadvance

public StepAdjustment preadvance(double t0,
                                 double t1,
                                 int flags)
Description copied from class: ModelBase
Prepares this object for advance from time t0 to time t1. Often this method does nothing; it is provided in case a model needs to update internal state at the very beginning a step before input probes and controllers are applied.

If the method determines that the step size should be reduced, it can return a StepAdjustment object indicating the recommended reduction. Otherwise, the method may return null

Specified by:
preadvance in interface Model
Overrides:
preadvance in class ModelBase
Parameters:
t0 - current time (seconds)
t1 - new time to advance to (seconds)
flags - reserved for future use
Returns:
null, or a step adjustment recommendation

getAuxState

public void getAuxState(DataBuffer data)

setAuxState

public void setAuxState(DataBuffer data)

createState

public ComponentState createState(ComponentState prevState)
Description copied from class: ModelBase
Factory routine to create a state object for this component, which can then be used as an argument for HasState.setState(artisynth.core.modelbase.ComponentState) and HasState.getState(artisynth.core.modelbase.ComponentState). The state object does not have to be set to the component's current state. If the component does not have any state information, this method should return an instance of EmptyState.

Specified by:
createState in interface HasState
Overrides:
createState in class ModelBase
Parameters:
prevState - If non-null, supplies a previous state that was created by this component and which can be used to provide pre-sizing hints.
Returns:
new object for storing this component's state

setState

public void setState(ComponentState pstate)
Description copied from class: ModelBase
Set the state of this component.

Specified by:
setState in interface HasState
Overrides:
setState in class ModelBase
Parameters:
pstate - state to be copied

getState

public void getState(ComponentState pstate)
Description copied from class: ModelBase
Get the current state of this component.

Specified by:
getState in interface HasState
Overrides:
getState in class ModelBase
Parameters:
pstate - receives the state information

getInitialState

public void getInitialState(ComponentState newstate,
                            ComponentState oldstate)
Description copied from interface: HasState
Gets an initial state for this component and returns the value in state. If prevstate is non-null, then it is assumed to contain a previous initial state value returned by this method, and state should be set to be as consistent with this previous state as possible. For example, suppose that this component currently contains subcomponents A, B, and C, while the prevstate contains the state from a previous time when it had components B, C, and D. Then state should contain substate values for B and C that are taken from prevstate. To facilitate this, the information returned in state should contain additional information such as the identities of all the (current) sub-components.

Specified by:
getInitialState in interface HasState
Overrides:
getInitialState in class ModelBase
Parameters:
newstate - receives the state information
oldstate - previous state information; may be null.

initialize

public void initialize(double t)
Description copied from class: ModelBase
Causes this model to initialize itself at time t. This method will be called at the very beginning of the simulation (with t = 0), or immediately after the model's state has been reset using HasState.setState(artisynth.core.modelbase.ComponentState), in which case t may have an arbitrary value.

Specified by:
initialize in interface Model
Overrides:
initialize in class ModelBase
Parameters:
t - initialization time (seconds)

recursivelyInitialize

public void recursivelyInitialize(double t,
                                  int level)
Specified by:
recursivelyInitialize in interface MechSystemModel

recursivelyFinalizeAdvance

public void recursivelyFinalizeAdvance(StepAdjustment stepAdjust,
                                       double t0,
                                       double t1,
                                       int flags,
                                       int level)
Specified by:
recursivelyFinalizeAdvance in interface MechSystemModel

numActiveComponents

public int numActiveComponents()
Description copied from interface: MechSystem
Returns the current number of active components in this system. This should remain unchanged as long as the current structure version (returned by getStructureVersion() remains unchanged.

Specified by:
numActiveComponents in interface MechSystem
Returns:
number of active components

numParametricComponents

public int numParametricComponents()
Description copied from interface: MechSystem
Returns the current number of parametric components in this system. This should remain unchanged as long as the current structure version (returned by getStructureVersion() remains unchanged.

Specified by:
numParametricComponents in interface MechSystem
Returns:
number of parametric components

numAttachedComponents

public int numAttachedComponents()

getAttachmentConstraints

public SparseBlockMatrix getAttachmentConstraints()
Returns the transpose of the attachment constraint matrix, along with the vector of derivative offsets. This is used only for debugging.


getAttachmentDerivatives

public VectorNd getAttachmentDerivatives()

addAttachmentJacobian

public void addAttachmentJacobian(SparseNumberedBlockMatrix S,
                                  VectorNd f)

addAttachmentSolveBlocks

public void addAttachmentSolveBlocks(SparseNumberedBlockMatrix S)

updateAttachmentPos

public void updateAttachmentPos()

updatePosState

public void updatePosState()

updateVelState

public void updateVelState()

updateAttachmentVel

public void updateAttachmentVel()

applyAttachmentForces

public void applyAttachmentForces()

buildMassMatrix

public boolean buildMassMatrix(SparseBlockMatrix M)
Description copied from interface: MechSystem
Builds a mass matrix for this system. This is done by adding blocks of an appropriate type to the sparse block matrix M. On input, M should be empty with zero size; it will be sized appropriately by the system.

This method returns true if the mass matrix is constant; i.e., does not vary with time. It does not place actual values in the matrix; that must be done by calling getMassMatrix().

A new mass matrix should be built whenever the system's structure version (as returned by getStructureVersion()) changes.

Specified by:
buildMassMatrix in interface MechSystem
Parameters:
M - matrix in which the mass matrix will be built
Returns:
true if the mass matrix is constant.

getMassMatrix

public void getMassMatrix(SparseBlockMatrix M,
                          VectorNd f,
                          double t)
Description copied from interface: MechSystem
Sets M to the current value of the mass matrix for this system, evaluated at time t. M should have been previously created with a call to buildMassMatrix(). The current mass forces are returned in the vector f, which should have a size greater or equal to the size of M. The mass forces (also known as the fictitious forces) are given by
 - dM/dt u
 
where u is the current system velocity. f will be sized appropriately by the system.

Specified by:
getMassMatrix in interface MechSystem
Parameters:
M - returns the mass matrix
f - returns the mass forces
t - current time

getInverseMassMatrix

public void getInverseMassMatrix(SparseBlockMatrix Minv,
                                 SparseBlockMatrix M)
Description copied from interface: MechSystem
Sets Minv to the inverse of the mass matrix M. Minv should have been previously created with a call to buildMassMatrix().

This method assumes that M is block diagonal and hence Minv has the same block structure. Although it is possible to compute Minv by simply inverting each block of M, the special structure of each mass block may permit the system to do this in a highly optimized way.

Specified by:
getInverseMassMatrix in interface MechSystem
Parameters:
Minv - returns the inverted mass matrix
M - mass matrix to invert

buildSolveMatrix

public void buildSolveMatrix(SparseNumberedBlockMatrix S)
Description copied from interface: MechSystem
Builds a solve matrix for this system. This is done by adding blocks of an appropriate type to the sparse block matrix S. On input, S should be empty with zero size; it will be sized appropriately by the system. The resulting matrix should have all the blocks required to store any combination of the mass matrix, the force-position Jacobian, and the force-velocity Jacobian. This method does not place actual values in the matrix; that must be done by adding a mass matrix to it, or by calling addVelJacobian() or addPosJacobian().

A new solve matrix should be built whenever the system's structure version (as returned by getStructureVersion()) changes.

Specified by:
buildSolveMatrix in interface MechSystem
Parameters:
S - matrix in which the solve matrix will be built

getDefaultStabilization

public static MechSystemSolver.PosStabilization getDefaultStabilization()

setDefaultStabilization

public static void setDefaultStabilization(MechSystemSolver.PosStabilization stablizer)

getStabilization

public MechSystemSolver.PosStabilization getStabilization()

setStabilization

public void setStabilization(MechSystemSolver.PosStabilization stablizer)

getUpdateForcesAtStepEnd

public boolean getUpdateForcesAtStepEnd()

setUpdateForcesAtStepEnd

public void setUpdateForcesAtStepEnd(boolean enable)

getParametricPosStateSize

public int getParametricPosStateSize()
Returns the size of the position state for all parametric components. This should remain unchanged as long as the current structure version (returned by getStructureVersion() remains unchanged.

Specified by:
getParametricPosStateSize in interface MechSystem
Returns:
size of the parametric position state

getParametricPosTarget

public void getParametricPosTarget(VectorNd q,
                                   double s,
                                   double h)
Obtains the desired target position for all parametric components at a particular time. This is stored in the vector q (which will be sized appropriately by the system). The system interpolates between the current parametric position values and those desired for the end of the time step, using a parameter s defined on the interval [0,1]. In particular, specifying s = 0 yields the current parametric positions, and s = 1 yields the positions desired for the end of the step. The actual time step size h is also provided, as this may be needed by some interpolation methods.

The interpolation uses the current parametric positions, and possibly the current parametric velocities as well. Hence this method should be called before either of these are changed using setParametricPosState() or setParametricVelState().

Specified by:
getParametricPosTarget in interface MechSystem
Parameters:
q - vector returning the state information
s - specifies time relative to the current time step
h - time step size

getParametricPosState

public void getParametricPosState(VectorNd q)
Gets the current position state for all parametric components. This is stored in the vector q (which will be sized appropriately by the system).

Specified by:
getParametricPosState in interface MechSystem
Parameters:
q - vector in which the state is stored

setParametricPosState

public void setParametricPosState(VectorNd q)
Sets the current position state for all parametric components. This is supplied in the vector q, whose size should be greater than or equal to the value returned by getParametricPosStateSize().

Specified by:
setParametricPosState in interface MechSystem
Parameters:
q - vector supplying the state information

getParametricVelStateSize

public int getParametricVelStateSize()
Returns the size of the velocity state for all parametric components. This should remain unchanged as long as the current structure version (returned by getStructureVersion() remains unchanged.

Specified by:
getParametricVelStateSize in interface MechSystem
Returns:
size of the parametric velocity state

getParametricVelTarget

public void getParametricVelTarget(VectorNd u,
                                   double s,
                                   double h)
Obtains the desired target velocity for all parametric components at a particular time. This is stored in the vector u (which will be sized appropriately by the system). The system interpolates between the current parametric velocity values and those desired for the end of the time step, using a parameter s defined on the interval [0,1]. In particular, specifying s = 0 yields the current parametric velocities, and s = 1 yields the velocities desired for the end of the step. The actual time step size h is also provided, as this may be needed by some interpolation methods.

The interpolation uses the current parametric velocities, and possibly the current parametric positions as well. Hence this method should be called before either of these are changed using setParametricPosState() or setParametricVelState().

Specified by:
getParametricVelTarget in interface MechSystem
Parameters:
u - vector returning the parametric target velocites
s - specifies time relative to the current time step
h - time step size

getParametricVelState

public void getParametricVelState(VectorNd u)
Gets the current velocity state for all parametric components. This is stored in the vector u (which will be sized appropriately by the system).

Specified by:
getParametricVelState in interface MechSystem
Parameters:
u - vector in which state is stored

setParametricVelState

public void setParametricVelState(VectorNd q)
Sets the current velocity state for all parametric components. This is supplied in the vector u, whose size should be greater than or equal to the value returned by getParametricVelStateSize().

Specified by:
setParametricVelState in interface MechSystem
Parameters:
q - vector supplying the state information

copy

public MechSystemBase copy(int flags,
                           java.util.Map<ModelComponent,ModelComponent> copyMap)
Overrides:
copy in class ComponentList<ModelComponent>

printActiveStiffness

public void printActiveStiffness()
                          throws java.io.IOException
Throws:
java.io.IOException

getActiveStiffness

public SparseBlockMatrix getActiveStiffness()

writeStiffnessMatrix

public void writeStiffnessMatrix(java.lang.String fileName,
                                 double h)
                          throws java.io.IOException
Throws:
java.io.IOException

writeMassMatrix

public void writeMassMatrix(java.lang.String fileName)
                     throws java.io.IOException
Throws:
java.io.IOException

writeBilateralConstraintMatrix

public void writeBilateralConstraintMatrix(java.lang.String fileName)
                                    throws java.io.IOException
Throws:
java.io.IOException

updateForces

public void updateForces(double t)
Description copied from interface: MechSystem
Updates all internal forces associated with this system to be consistent with the current position and velocity and the indicated time t. This method should be called between any change to position or velocity values (such as through setActivePosState() or setActiveVelState(), and any call to getActiveForces().

In the process of updating the forces, the system may determine that a smaller step size is needed. If so, it can indicate this through the argument optional stepAdjust, if present.

Specified by:
updateForces in interface MechSystem
Parameters:
t - current time

addPosJacobian

public void addPosJacobian(SparseNumberedBlockMatrix S,
                           VectorNd f,
                           double s)
Description copied from interface: MechSystem
Adds the current force-position Jacobian, scaled by h, to the matrix S, which should have been previously created with a call to buildSolveMatrix(). Addition fictitious forces associated with the Jacobian can be optionally returned in the vector f, which will be sized appropriately by the system.

Specified by:
addPosJacobian in interface MechSystem
Parameters:
S - matrix to which scaled Jacobian is to be added
f - if non-null, returns fictitious forces associated with the Jacobian
s - scale factor for the Jacobian

addVelJacobian

public void addVelJacobian(SparseNumberedBlockMatrix S,
                           VectorNd f,
                           double s)
Description copied from interface: MechSystem
Adds the current force-velocity Jacobian, scaled by h, to the matrix S, which should have been previously created with a call to buildSolveMatrix(). Addition fictitious forces associated with the Jacobian can be optionally returned in the vector f, which will be sized appropriately by the system.

Specified by:
addVelJacobian in interface MechSystem
Parameters:
S - matrix to which scaled Jacobian is to be added
f - if non-null, returns fictitious forces associated with the Jacobian
s - scale factor for the Jacobian

addGeneralSolveBlocks

public void addGeneralSolveBlocks(SparseNumberedBlockMatrix M)

getMass

public double getMass()

getSolveMatrixType

public int getSolveMatrixType()
Description copied from interface: MechSystem
Returns information about the solve matrix for this system. This consists of an or-ed set of flags, including SYMMETRIC or POSITIVE_DEFINITE, which aid in determining the best way to solve the matrix.

Specified by:
getSolveMatrixType in interface MechSystem
Returns:
type information for the solve matrix