public abstract class MechSystemBase extends RenderableModelBase implements MechSystemModel
| Modifier and Type | Class and Description |
|---|---|
class |
MechSystemBase.ConstraintForceStateSaver
Special class to save/restore constraint forces as state
|
ModelComponent.FilePathSaveType, ModelComponent.NavpanelVisibilityMechSystem.ConstraintInfoCompositeComponent.NavpanelDisplay| Modifier and Type | Field and Description |
|---|---|
static MechSystemSolver.PosStabilization |
DEFAULT_STABILIZATION |
static boolean |
DEFAULT_USE_IMPLICIT_FRICTION |
static boolean |
myParametricsInSystemMatrix |
static PropertyList |
myProps |
static boolean |
mySaveForcesAsState |
static boolean |
useAllDynamicComps |
DEFAULT_MAX_STEP_SIZEDEFAULT_NAVPANEL_DISPLAYenforceUniqueCompositeNames, enforceUniqueNames, myNumber, NULL_OBJ, useCompactPathNamesSTATE_IS_VOLATILECOMPUTE_CONTACTS, UPDATE_CONTACTSTRANSPARENT, TWO_DIMENSIONAL| Constructor and Description |
|---|
MechSystemBase(java.lang.String name) |
| Modifier and Type | Method and Description |
|---|---|
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 |
addGeneralMassBlocks(SparseNumberedBlockMatrix M) |
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(). |
StepAdjustment |
advance(double t0,
double t1,
int flags)
Advances this model from time t0 to time t1.
|
void |
advanceAuxState(double t0,
double t1) |
void |
applyAttachmentForces() |
boolean |
buildMassMatrix(SparseNumberedBlockMatrix M)
Builds a mass matrix for this system.
|
void |
buildSolveMatrix(SparseNumberedBlockMatrix S)
Builds a solve matrix for this system.
|
void |
closePrintStateFile() |
void |
collectInitialForces() |
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() |
SparseBlockMatrix |
getActiveDampingMatrix() |
java.util.ArrayList<DynamicComponent> |
getActiveDynamicComponents()
Returns a list of all the active dynamic components, which
collectively determine the values returned by
getActiveForces(maspack.matrix.VectorNd),
getActivePosState(maspack.matrix.VectorNd), etc. |
void |
getActiveForces(VectorNd f)
Returns the generalized forces acting on all the active components in this
system.
|
double |
getActiveMass() |
SparseBlockMatrix |
getActiveMassMatrix() |
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 |
getActiveStiffnessMatrix() |
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.
|
VectorNd |
getAttachmentDerivatives() |
void |
getAuxAdvanceState(DataBuffer buf) |
void |
getAuxVarDerivative(VectorNd dwdt) |
void |
getAuxVarState(VectorNd w) |
int |
getAuxVarStateSize() |
void |
getBilateralConstraints(SparseBlockMatrix GT,
VectorNd dg)
Obtains the transpose of the current bilateral constraint matrix G for
this system.
|
void |
getBilateralConstraintSizes(VectorNi sizes) |
void |
getBilateralForces(VectorNd lam)
Returns from the system the most recently computed bilateral constraint
forces.
|
int |
getBilateralForces(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 SparseSolverId |
getDefaultMatrixSolver() |
static MechSystemSolver.PosStabilization |
getDefaultStabilization() |
static boolean |
getDefaultUseImplicitFriction() |
java.util.ArrayList<DynamicComponent> |
getDynamicComponents()
Returns a list of the dynamic components in this model.
|
void |
getDynamicDOFs(int[] dofs)
Returns in
sizes the number of (velocity) degrees of freedom
for the dynamic components in the system. |
boolean |
getDynamicsEnabled() |
java.util.ArrayList<ForceEffector> |
getForceEffectors()
Returns a list of the force effectors in this model.
|
void |
getForces(VectorNd f) |
int |
getFrictionConstraints(SparseBlockMatrix DT,
java.util.ArrayList<FrictionInfo> finfo,
boolean prune)
Obtains the transpose of the current friction constraint matrix D for
this system.
|
void |
getFrictionForces(VectorNd phi)
Returns from the system the most recently computed friction constraint
forces.
|
int |
getFrictionForces(VectorNd phi,
int idx) |
void |
getFrictionState(VectorNi state) |
int |
getFrictionState(VectorNi state,
int idx) |
void |
getInitialState(ComponentState newstate,
ComponentState oldstate)
Gets an initial state for this component and returns the value in
state. |
MechSystemSolver.Integrator |
getIntegrator() |
void |
getInverseMassMatrix(SparseBlockMatrix Minv,
SparseBlockMatrix M)
Sets
Minv to the inverse of the mass matrix M. |
void |
getMassMatrix(SparseNumberedBlockMatrix M,
VectorNd f,
double t)
Sets
M to the current value of the mass matrix for this
system, evaluated at time t. |
SparseSolverId |
getMatrixSolver() |
Range |
getMatrixSolverRange() |
int |
getNumBilateralForces() |
int |
getNumUnilateralForces() |
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() |
java.lang.String |
getPrintState() |
boolean |
getProfiling() |
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 |
getUnilateralForces(VectorNd the)
Returns from the system the most recently computed unilateral constraint
forces.
|
int |
getUnilateralForces(VectorNd the,
int idx) |
void |
getUnilateralInfo(MechSystem.ConstraintInfo[] ninfo)
Obtains information for all the constraint directions returned
by the most recent call to
getUnilateralConstraints(). |
void |
getUnilateralState(VectorNi state) |
int |
getUnilateralState(VectorNi state,
int idx) |
boolean |
getUpdateForcesAtStepEnd() |
PropertyMode |
getUpdateForcesAtStepEndMode() |
boolean |
getUseImplicitFriction() |
void |
initialize(double t)
Causes this model to initialize itself at time t.
|
boolean |
isBilateralStructureConstant()
Queries whether or not the matrix structure of the bilateral constraints
returned by this system is constant for a given structure version.
|
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.
|
java.io.PrintWriter |
openPrintStateFile(java.lang.String fileName) |
static void |
placeDynamicComponent(java.util.List<DynamicComponent> active,
java.util.List<DynamicComponent> attached,
java.util.List<DynamicComponent> parametric,
DynamicComponent d) |
StepAdjustment |
preadvance(double t0,
double t1,
int flags)
Prepares this model for advance from time t0 to time t1.
|
void |
printActiveMass() |
void |
printActiveMass(java.lang.String fmtStr) |
void |
printActiveStiffness() |
void |
printActiveStiffness(java.lang.String fmtStr) |
void |
recursivelyFinalizeAdvance(StepAdjustment stepAdjust,
double t0,
double t1,
int flags,
int level) |
void |
recursivelyInitialize(double t,
int level) |
void |
recursivelyPrepareAdvance(double t0,
double t1,
int flags,
int level) |
void |
reduceVelocityJacobian(SparseBlockMatrix J) |
java.io.PrintWriter |
reopenPrintStateFile(java.lang.String fileName) |
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 |
setAuxAdvanceState(DataBuffer buf) |
void |
setAuxVarState(VectorNd w) |
void |
setBilateralForces(VectorNd lam,
double s)
Supplies to the system the most recently computed bilateral constraint
forces.
|
int |
setBilateralForces(VectorNd lam,
double s,
int idx) |
static void |
setDefaultMatrixSolver(SparseSolverId solverType) |
static void |
setDefaultStabilization(MechSystemSolver.PosStabilization stablizer) |
static void |
setDefaultUseImplicitFriction(boolean enable) |
void |
setDynamicsEnabled(boolean enable) |
void |
setForces(VectorNd f) |
void |
setFrictionForces(VectorNd phi,
double s)
Supplies to the system the most recently computed friction constraint
forces.
|
int |
setFrictionForces(VectorNd phi,
double s,
int idx) |
void |
setFrictionState(VectorNi state) |
int |
setFrictionState(VectorNi state,
int idx) |
void |
setIntegrator(MechSystemSolver.Integrator integrator) |
void |
setMatrixSolver(SparseSolverId method) |
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 |
setPrintState(java.lang.String fmt) |
void |
setPrintState(java.lang.String fmt,
double interval) |
void |
setProfiling(boolean enable) |
void |
setStabilization(MechSystemSolver.PosStabilization stablizer) |
void |
setState(ComponentState pstate)
Set the state of this component.
|
void |
setUnilateralForces(VectorNd the,
double s)
Supplies to the system the most recently computed unilateral constraint
forces.
|
int |
setUnilateralForces(VectorNd the,
double s,
int idx) |
void |
setUnilateralState(VectorNi state) |
int |
setUnilateralState(VectorNi state,
int idx) |
void |
setUpdateForcesAtStepEnd(boolean enable) |
void |
setUpdateForcesAtStepEndMode(PropertyMode mode) |
void |
setUseImplicitFriction(boolean enable) |
static MechSystem |
topMechSystem(ModelComponent comp)
Returns the topmost MechSystem, if any, that is associated with
a specific component.
|
void |
updateAttachmentPos() |
void |
updateAttachmentVel() |
boolean |
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 |
updateDynamicComponentLists() |
void |
updateForceComponentList() |
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 |
writeBilateralConstraintMatrix(java.lang.String fileName,
Matrix.WriteFormat matfmt) |
void |
writeMassMatrix(java.lang.String fileName) |
void |
writeMassMatrix(java.lang.String fileName,
Matrix.WriteFormat matfmt) |
void |
writePrintStateHeader(java.lang.String description) |
void |
writeStiffnessMatrix(java.lang.String fileName,
double h) |
void |
writeStiffnessMatrix(java.lang.String fileName,
double h,
Matrix.WriteFormat matfmt) |
createRenderProps, getAllPropertyInfo, getRenderHints, getRenderProps, getSelection, isSelectable, numSelectionQueriesNeeded, prerender, render, setRenderProps, updateBoundsactionPerformed, copy, dispose, getDefaultMaxStepSize, getMaxStepSize, getMenuItems, hasParameterizedType, hierarchyContainsReferences, setDefaultMaxStepSize, setMaxStepSizeadd, add, addAll, addComponents, addFixed, addNumbered, clear, clone, componentChanged, contains, contains, containsAll, ensureCapacity, findComponent, get, get, getByNumber, getChildren, getMinNumber, getNavpanelDisplay, getNumberLimit, getOneBasedNumbering, getParameterType, getShortName, hasChildren, incrementNumbering, indexOf, invalidateNumbers, isEditable, isEmpty, iterator, nextComponentNumber, numComponents, postscan, remove, remove, removeAll, removeAll, removeComponents, resetNumbersToIndices, retainAll, scan, set, setEditable, setNavpanelDisplay, setNumbered, setOneBasedNumbering, setShortName, size, toArray, toArray, updateNameMapcheckFlag, checkName, checkNameUniqueness, clearFlag, connectToHierarchy, createTempFlag, disconnectFromHierarchy, getGrandParent, getHardReferences, getName, getNameRange, getNavpanelVisibility, getNavpanelVisibility, getNumber, getParent, getProperty, getSoftReferences, hasState, isFixed, isMarked, isScanning, isSelected, isWritable, makeValidName, makeValidName, notifyParentOfChange, printReferences, recursivelyContained, recursivelyContains, removeTempFlag, setFixed, setFlag, setMarked, setName, setNavpanelVisibility, setNavpanelVisibility, setNumber, setParent, setScanning, setSelected, setWritable, updateReferences, writeequals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcheckVelocityStability, getAttachments, getAuxStateComponents, getCollidables, getConstrainers, getDynamicComponents, getDynamicComponents, getForceEffectors, getMassMatrixValues, mulInverseMassdispose, getMaxStepSizeconnectToHierarchy, disconnectFromHierarchy, getHardReferences, getName, getNavpanelVisibility, getNumber, getParent, getSoftReferences, hasState, isFixed, isMarked, isSelected, notifyParentOfChange, scan, setFixed, setMarked, setName, setNumber, setParent, setSelected, setWritable, updateReferencesgetAllPropertyInfo, getPropertygetChildren, hasChildrenpostscanisWritable, writegetNameequals, hashCode, parallelStream, removeIf, spliterator, streamrecursivelyFindpublic static boolean mySaveForcesAsState
public static boolean myParametricsInSystemMatrix
public static boolean useAllDynamicComps
public static MechSystemSolver.PosStabilization DEFAULT_STABILIZATION
public static boolean DEFAULT_USE_IMPLICIT_FRICTION
public static PropertyList myProps
public void setPenetrationLimit(double lim)
public double getPenetrationLimit()
public boolean getDynamicsEnabled()
public void setDynamicsEnabled(boolean enable)
public static MechSystem topMechSystem(ModelComponent comp)
comp - component to start withcomp, or
null if there is none.public MechSystemSolver getSolver()
public SparseBlockMatrix createVelocityJacobian()
public void reduceVelocityJacobian(SparseBlockMatrix J)
public int getNumUnilateralForces()
public void getUnilateralConstraintSizes(VectorNi sizes)
public void getUnilateralConstraints(SparseBlockMatrix NT, VectorNd dn)
MechSystemNT. 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 uwhere
u is the current system velocity.
dn will also be sized appropriately by the system.getUnilateralConstraints in interface MechSystemNT - returns the transpose of Ndn - if non-null. returns the derivative term for Npublic int getNumBilateralForces()
public void getBilateralConstraintSizes(VectorNi sizes)
public boolean isBilateralStructureConstant()
isBilateralStructureConstant in interface MechSystemtrue if bilateral constraints have a constant structurepublic void getBilateralConstraints(SparseBlockMatrix GT, VectorNd dg)
MechSystemGT. 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 uwhere
u is the current system velocity.
dg will also be sized appropriately by the system.getBilateralConstraints in interface MechSystemGT - returns the transpose of Gdg - if non-null, returns the derivative term for Gpublic void getBilateralInfo(MechSystem.ConstraintInfo[] ginfo)
MechSystemgetBilateralConstraints().
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().getBilateralInfo in interface MechSystemginfo - Array of
ConstraintInfo
objects used to return the constraint information.public void setBilateralForces(VectorNd lam, double s)
MechSystemlam*s, where lam
is a vector of impulses and s is the inverse of the step size
used in the computation. lam, which should have a size
greater or equal to the column size of GT returned by getBilateralConstraints().setBilateralForces in interface MechSystemlam - When scaled by s, gives the bilateral constraint forces
being supplied to the system.s - Scaling factor to be applied to the lam.public int setBilateralForces(VectorNd lam, double s, int idx)
public void getBilateralForces(VectorNd lam)
MechSystemlam, 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 force values should equal
those which were set by the prevous call to setBilateralForces().
Otherwise, values can be estimated from
previous force values (where appropriate), or supplied as 0.getBilateralForces in interface MechSystemlam - Bilateral constraint forces being returned from the system.public int getBilateralForces(VectorNd lam, int idx)
public void getUnilateralInfo(MechSystem.ConstraintInfo[] ninfo)
MechSystemgetUnilateralConstraints().
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().getUnilateralInfo in interface MechSystemninfo - Array of
ConstraintInfo
objects used to return the constraint information.public void setUnilateralForces(VectorNd the, double s)
MechSystemthe*s, where the
is a vector of impulses and s is the inverse of the step size
used in the computation. the should have a size greater or
equal to the column size of NT returned by getUnilateralConstraints().setUnilateralForces in interface MechSystemthe - When scaled by s, gives the unilateral constraint forces
being supplied to the system.s - Scaling factor to be applied to the the.public int setUnilateralForces(VectorNd the, double s, int idx)
public void getUnilateralForces(VectorNd the)
MechSystemthe, 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
force values should equal those which were set by the previous call to
setUnilateralForces(). Otherwise,
values can be estimated from previous force values (where appropriate),
or supplied as 0.getUnilateralForces in interface MechSystemthe - Unilateral constraint forces being returned from the system.public int getUnilateralForces(VectorNd the, int idx)
public void setUnilateralState(VectorNi state)
public int setUnilateralState(VectorNi state, int idx)
setUnilateralState in interface MechSystempublic void getUnilateralState(VectorNi state)
public int getUnilateralState(VectorNi state, int idx)
getUnilateralState in interface MechSystempublic int maxFrictionConstraintSets()
MechSystemgetFrictionConstraints().
This is used to size the finfo array supplied to that
method.maxFrictionConstraintSets in interface MechSystempublic int getFrictionConstraints(SparseBlockMatrix DT, java.util.ArrayList<FrictionInfo> finfo, boolean prune)
MechSystemDT. 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().
getFrictionConstraints in interface MechSystemDT - returns the transpose of Dfinfo - returns information for each friction constraint setprune - limit DT entries to those for which the corresponding
contact forces are > 0public void setFrictionForces(VectorNd phi, double s)
MechSystemphi*s, where phi
is a vector of impulses and s is the inverse of the step size
used in the computation. phi should have a size greater or
equal to the column size of DT returned by getFrictionConstraints().setFrictionForces in interface MechSystemphi - When scaled by s, gives the friction constraint forces
being supplied to the system.s - Scaling factor to be applied to the phi.public int setFrictionForces(VectorNd phi, double s, int idx)
public void getFrictionForces(VectorNd phi)
MechSystemphi, which should
have a size greater or equal to the column size of DT
returned by getFrictionConstraints().
For constraints which where present in the previous solve step, the force
values should equal those which were set by the previous call to setFrictionForces(). Otherwise, values can be
estimated from previous force values (where appropriate), or supplied as
0.getFrictionForces in interface MechSystemphi - Unilateral constraint forces being returned from the system.public int getFrictionForces(VectorNd phi, int idx)
public void setFrictionState(VectorNi state)
public int setFrictionState(VectorNi state, int idx)
setFrictionState in interface MechSystempublic void getFrictionState(VectorNi state)
public int getFrictionState(VectorNi state, int idx)
getFrictionState in interface MechSystempublic boolean updateConstraints(double t,
StepAdjustment stepAdjust,
int flags)
MechSystemgetBilateralConstraints().
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.
updateConstraints in interface MechSystemt - current timestepAdjust - (optional) can be used to indicate whether the current advance
should be redone with a smaller step size.flags - information flagspublic int getStructureVersion()
MechSystemgetStructureVersion in interface MechSystempublic void getDynamicDOFs(int[] dofs)
sizes the number of (velocity) degrees of freedom
for the dynamic components in the system. The results are arranged
according to each component's solveIndex. If the length of
sizes is less than the number of dynamic components, the
results are truncated.dofs - returns the number of DOFs for each dynamic componentpublic static void placeDynamicComponent(java.util.List<DynamicComponent> active, java.util.List<DynamicComponent> attached, java.util.List<DynamicComponent> parametric, DynamicComponent d)
public java.util.ArrayList<DynamicComponent> getDynamicComponents()
public void updateDynamicComponentLists()
public java.util.ArrayList<ForceEffector> getForceEffectors()
public void updateForceComponentList()
public void getSlaveObjectComponents(java.util.List<HasSlaveObjects> comps, int level)
getSlaveObjectComponents in interface MechSystemModelcomps - HasSlaveObjects components should be added to this listpublic void getActivePosState(VectorNd q)
q (which will be sized appropriately by the
system).getActivePosState in interface MechSystemq - vector in which the state is storedpublic void getActiveVelState(VectorNd u)
u (which will be sized appropriately by the
system).getActiveVelState in interface MechSystemu - vector in which the state is storedpublic int getActiveVelState(VectorNd u, int idx, boolean bodyCoords)
public void setActivePosState(VectorNd q)
q, whose size should be greater than
or equal to the value returned by getActivePosStateSize().setActivePosState in interface MechSystemq - vector supplying the state informationpublic void addActivePosImpulse(VectorNd x, double h, VectorNd v)
MechSystemq) 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().addActivePosImpulse in interface MechSystemx - positions to be adjustedh - length of time to apply velocityv - velocity to be appliedpublic void setActiveVelState(VectorNd u)
u, whose size should be greater than
or equal to the value returned by getActiveVelStateSize().setActiveVelState in interface MechSystemu - vector supplying the state informationpublic int getActivePosStateSize()
getStructureVersion()
remains unchanged.getActivePosStateSize in interface MechSystempublic int getActiveVelStateSize()
getStructureVersion()
remains unchanged.getActiveVelStateSize in interface MechSystempublic void getActivePosDerivative(VectorNd dxdt, double t)
MechSystemdxdt (which will be
sized appropriately by the system).getActivePosDerivative in interface MechSystemdxdt - vector in which the derivative is storedt - current time valuepublic java.util.ArrayList<DynamicComponent> getActiveDynamicComponents()
getActiveForces(maspack.matrix.VectorNd),
getActivePosState(maspack.matrix.VectorNd), etc. The returned list is a copy and
may be modified.public void getActiveForces(VectorNd f)
f (which will be
sized appropriately by the system).getActiveForces in interface MechSystemf - vector in which the forces are storedpublic void setActiveForces(VectorNd f)
f, whose size
should be greater or equal to the value returned by
getActiveVelStateSize().setActiveForces in interface MechSystemf - vector specifying the forces to be setpublic void getForces(VectorNd f)
public void setForces(VectorNd f)
public void getParametricForces(VectorNd f)
f (which will be sized appropriately by the
system).getParametricForces in interface MechSystemf - vector in which to return the force informationpublic void setParametricForces(VectorNd f)
f, whose size should be greater or equal to
the value returned by getParametricVelStateSize().setParametricForces in interface MechSystemf - vector supplying the force informationpublic java.lang.String getPrintState()
public void setPrintState(java.lang.String fmt,
double interval)
public void setPrintState(java.lang.String fmt)
public java.io.PrintWriter openPrintStateFile(java.lang.String fileName)
throws java.io.IOException
java.io.IOExceptionpublic java.io.PrintWriter reopenPrintStateFile(java.lang.String fileName)
throws java.io.IOException
java.io.IOExceptionpublic void closePrintStateFile()
throws java.io.IOException
java.io.IOExceptionpublic void writePrintStateHeader(java.lang.String description)
public StepAdjustment preadvance(double t0, double t1, int flags)
ModelBaseIf 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
The flags argument gives additional information that may
be relevant when advancing the model. Currently implemented
flags include Model.STATE_IS_VOLATILE.
preadvance in interface Modelpreadvance in class ModelBaset0 - current time (seconds)t1 - new time to advance to (seconds)flags - additional information relevant to the advancepublic StepAdjustment advance(double t0, double t1, int flags)
ModelBaseIf 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
The flags argument gives additional information that may
be relevant when advancing the model. Currently implemented
flags include Model.STATE_IS_VOLATILE.
public ComponentState createState(ComponentState prevState)
ModelBaseHasState.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.createState in interface HasStatecreateState in class ModelBaseprevState - If non-null, supplies a previous state that
was created by this component and which can be used to provide
pre-sizing hints.public void setState(ComponentState pstate)
ModelBasepublic void getState(ComponentState pstate)
ModelBasepublic void getInitialState(ComponentState newstate, ComponentState oldstate)
ModelBasestate. 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) subcomponents.getInitialState in interface HasStategetInitialState in class ModelBasenewstate - receives the state informationoldstate - previous state information; may be null.public void initialize(double t)
ModelBaseHasState.setState(artisynth.core.modelbase.ComponentState), in which case t may have an arbitrary value.initialize in interface Modelinitialize in class ModelBaset - initialization time (seconds)public void recursivelyInitialize(double t,
int level)
recursivelyInitialize in interface MechSystemModelpublic void recursivelyPrepareAdvance(double t0,
double t1,
int flags,
int level)
recursivelyPrepareAdvance in interface MechSystemModelpublic void recursivelyFinalizeAdvance(StepAdjustment stepAdjust, double t0, double t1, int flags, int level)
recursivelyFinalizeAdvance in interface MechSystemModelpublic void setProfiling(boolean enable)
public boolean getProfiling()
public static void setDefaultMatrixSolver(SparseSolverId solverType)
public static SparseSolverId getDefaultMatrixSolver()
public void setMatrixSolver(SparseSolverId method)
public SparseSolverId getMatrixSolver()
public Range getMatrixSolverRange()
public void setIntegrator(MechSystemSolver.Integrator integrator)
public boolean getUseImplicitFriction()
public void setUseImplicitFriction(boolean enable)
public static boolean getDefaultUseImplicitFriction()
public static void setDefaultUseImplicitFriction(boolean enable)
public MechSystemSolver.Integrator getIntegrator()
public int numActiveComponents()
MechSystemgetStructureVersion()
remains unchanged.numActiveComponents in interface MechSystempublic int numParametricComponents()
MechSystemgetStructureVersion()
remains unchanged.numParametricComponents in interface MechSystempublic int numAttachedComponents()
public SparseBlockMatrix getAttachmentConstraints()
public VectorNd getAttachmentDerivatives()
public void addAttachmentJacobian(SparseNumberedBlockMatrix S, VectorNd f)
public void addAttachmentSolveBlocks(SparseNumberedBlockMatrix S)
public void updateAttachmentPos()
public void updateAttachmentVel()
public void updatePosState()
public void updateVelState()
public void applyAttachmentForces()
public boolean buildMassMatrix(SparseNumberedBlockMatrix M)
MechSystemM. 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.
buildMassMatrix in interface MechSystemM - matrix in which the mass matrix will be builtpublic void getMassMatrix(SparseNumberedBlockMatrix M, VectorNd f, double t)
MechSystemM 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 uwhere
u is the current system velocity.
f will be sized appropriately by the system.getMassMatrix in interface MechSystemM - returns the mass matrixf - returns the mass forcest - current timepublic void getInverseMassMatrix(SparseBlockMatrix Minv, SparseBlockMatrix M)
MechSystemMinv 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.
getInverseMassMatrix in interface MechSystemMinv - returns the inverted mass matrixM - mass matrix to invertpublic void buildSolveMatrix(SparseNumberedBlockMatrix S)
MechSystemS. 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.
buildSolveMatrix in interface MechSystemS - matrix in which the solve matrix will be builtpublic static MechSystemSolver.PosStabilization getDefaultStabilization()
public static void setDefaultStabilization(MechSystemSolver.PosStabilization stablizer)
public MechSystemSolver.PosStabilization getStabilization()
public void setStabilization(MechSystemSolver.PosStabilization stablizer)
public void setUpdateForcesAtStepEnd(boolean enable)
public boolean getUpdateForcesAtStepEnd()
public void setUpdateForcesAtStepEndMode(PropertyMode mode)
public PropertyMode getUpdateForcesAtStepEndMode()
public int getParametricPosStateSize()
getStructureVersion()
remains unchanged.getParametricPosStateSize in interface MechSystempublic void getParametricPosTarget(VectorNd q, double s, double h)
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().
getParametricPosTarget in interface MechSystemq - vector returning the state informations - specifies time relative to the current time steph - time step sizepublic void getParametricPosState(VectorNd q)
q (which will be sized appropriately by
the system).getParametricPosState in interface MechSystemq - vector in which the state is storedpublic void setParametricPosState(VectorNd q)
q, whose size should be greater than
or equal to the value returned by getParametricPosStateSize().setParametricPosState in interface MechSystemq - vector supplying the state informationpublic int getParametricVelStateSize()
getStructureVersion()
remains unchanged.getParametricVelStateSize in interface MechSystempublic void getParametricVelTarget(VectorNd u, double s, double h)
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().
getParametricVelTarget in interface MechSystemu - vector returning the parametric target velocitess - specifies time relative to the current time steph - time step sizepublic void getParametricVelState(VectorNd u)
u (which will be sized appropriately by
the system).getParametricVelState in interface MechSystemu - vector in which state is storedpublic void setParametricVelState(VectorNd q)
u, whose size should be greater than
or equal to the value returned by getParametricVelStateSize().setParametricVelState in interface MechSystemq - vector supplying the state informationpublic MechSystemBase copy(int flags, java.util.Map<ModelComponent,ModelComponent> copyMap)
copy in class ComponentList<ModelComponent>public void printActiveStiffness()
public void printActiveStiffness(java.lang.String fmtStr)
public SparseBlockMatrix getActiveStiffnessMatrix()
public SparseBlockMatrix getActiveDampingMatrix()
public void printActiveMass()
public void printActiveMass(java.lang.String fmtStr)
public SparseBlockMatrix getActiveMassMatrix()
public void writeStiffnessMatrix(java.lang.String fileName,
double h,
Matrix.WriteFormat matfmt)
throws java.io.IOException
java.io.IOExceptionpublic void writeStiffnessMatrix(java.lang.String fileName,
double h)
throws java.io.IOException
java.io.IOExceptionpublic void writeMassMatrix(java.lang.String fileName,
Matrix.WriteFormat matfmt)
throws java.io.IOException
java.io.IOExceptionpublic void writeMassMatrix(java.lang.String fileName)
throws java.io.IOException
java.io.IOExceptionpublic void writeBilateralConstraintMatrix(java.lang.String fileName,
Matrix.WriteFormat matfmt)
throws java.io.IOException
java.io.IOExceptionpublic void writeBilateralConstraintMatrix(java.lang.String fileName)
throws java.io.IOException
java.io.IOExceptionpublic void collectInitialForces()
public void updateForces(double t)
MechSystemt. 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.
updateForces in interface MechSystemt - current timepublic void addPosJacobian(SparseNumberedBlockMatrix S, VectorNd f, double s)
MechSystemh, 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.addPosJacobian in interface MechSystemS - matrix to which scaled Jacobian is to be addedf - if non-null, returns fictitious forces associated with the Jacobians - scale factor for the Jacobianpublic void addVelJacobian(SparseNumberedBlockMatrix S, VectorNd f, double s)
MechSystemh, 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.addVelJacobian in interface MechSystemS - matrix to which scaled Jacobian is to be addedf - if non-null, returns fictitious forces associated with the Jacobians - scale factor for the Jacobianpublic void addGeneralMassBlocks(SparseNumberedBlockMatrix M)
addGeneralMassBlocks in interface MechSystemModelpublic void addGeneralSolveBlocks(SparseNumberedBlockMatrix M)
public double getActiveMass()
public int getSolveMatrixType()
MechSystemSYMMETRIC or POSITIVE_DEFINITE,
which aid in determining the best way to solve the matrix.getSolveMatrixType in interface MechSystempublic void advanceAuxState(double t0,
double t1)
advanceAuxState in interface MechSystempublic void getAuxAdvanceState(DataBuffer buf)
getAuxAdvanceState in interface MechSystempublic void setAuxAdvanceState(DataBuffer buf)
setAuxAdvanceState in interface MechSystempublic int getAuxVarStateSize()
getAuxVarStateSize in interface MechSystempublic void getAuxVarState(VectorNd w)
getAuxVarState in interface MechSystempublic void setAuxVarState(VectorNd w)
setAuxVarState in interface MechSystempublic void getAuxVarDerivative(VectorNd dwdt)
getAuxVarDerivative in interface MechSystem