Search in sources :

Example 1 with StepAdjustment

use of artisynth.core.modelbase.StepAdjustment in project artisynth_core by artisynth.

the class MechSystemSolver method projectPosConstraints.

public void projectPosConstraints(double t) {
    updateStateSizes();
    updateMassMatrix(t);
    VectorNd q = new VectorNd(myActivePosSize);
    VectorNd u = new VectorNd(myActiveVelSize);
    StepAdjustment stepAdjust = new StepAdjustment();
    mySys.updateConstraints(t, stepAdjust, /*flags=*/
    MechSystem.COMPUTE_CONTACTS);
    mySys.getActivePosState(q);
    computePosCorrections(q, u, t);
    mySys.setActivePosState(q);
    // mySys.updateConstraints (
    // t, stepAdjust, /*flags=*/MechSystem.UPDATE_CONTACTS);
    // need to force an update of the mass matrix, since a subsequent
    // call to updateMassMatrix(t) wouldn't work.
    updateMassMatrix(-1);
}
Also used : VectorNd(maspack.matrix.VectorNd) StepAdjustment(artisynth.core.modelbase.StepAdjustment)

Example 2 with StepAdjustment

use of artisynth.core.modelbase.StepAdjustment in project artisynth_core by artisynth.

the class FemCollision method advance.

public synchronized StepAdjustment advance(double t0, double t1, int flags) {
    StepAdjustment adj = super.advance(t0, t1, flags);
    if ((adj == null || adj.getScaling() >= 1)) {
        if (TimeBase.compare(t1 - lastResetTime, 19.0) > 0) {
            reset();
            lastResetTime = t1;
        }
    }
    if (t1 == 2.34) {
        fem1.setIncompressible(FemModel3d.IncompMethod.OFF);
    }
    return adj;
}
Also used : StepAdjustment(artisynth.core.modelbase.StepAdjustment)

Example 3 with StepAdjustment

use of artisynth.core.modelbase.StepAdjustment in project artisynth_core by artisynth.

the class RootModel method advanceModel.

protected void advanceModel(ModelInfo info, double t0, double t1, int flags) {
    double ta = t0;
    if (t0 == 0) {
        applyOutputProbes(info.outputProbes, t0, info);
    }
    while (ta < t1) {
        double s;
        synchronized (this) {
            info.getModelAndControllersState(info.state);
        }
        if (testSaveAndRestoreState) {
            // test save-and-restore of model state
            CompositeState fullState = info.createFullState();
            CompositeState testState = info.createFullState();
            info.getFullState(fullState);
            info.setFullState(fullState);
            info.getFullState(testState);
            if (!testState.equals(fullState)) {
                throw new InternalErrorException("Error: save/restore state test failed");
            }
        }
        double tb = info.getNextAdvanceTime(ta, t1);
        do {
            synchronized (this) {
                StepAdjustment adj;
                // info.model.setDefaultInputs (ta, tb);
                adj = info.model.preadvance(ta, tb, flags);
                s = getRecommendedScaling(adj);
                if (s >= 1) {
                    applyInputProbes(info.inputProbes, tb);
                    applyControllers(info.controllers, ta, tb);
                    adj = info.model.advance(ta, tb, flags);
                    s = getRecommendedScaling(adj);
                }
                if (myAdaptiveStepping && s < 1) {
                    tb = info.reduceAdvanceTime(s, ta, tb, adj.getMessage());
                    info.setModelAndControllersState(info.state);
                    info.model.initialize(ta);
                }
            }
        } while (myAdaptiveStepping && s < 1 && !myStopAdvance);
        if (!(myAdaptiveStepping && s < 1)) {
            // then we have advanced to tb:
            info.updateStepInfo(s);
            applyMonitors(info.monitors, ta, tb);
            applyOutputProbes(info.outputProbes, tb, info);
            ta = tb;
        }
    }
}
Also used : CompositeState(artisynth.core.modelbase.CompositeState) InternalErrorException(maspack.util.InternalErrorException) StepAdjustment(artisynth.core.modelbase.StepAdjustment)

Example 4 with StepAdjustment

use of artisynth.core.modelbase.StepAdjustment in project artisynth_core by artisynth.

the class MechSystemSolver method projectRigidBodyPosConstraints.

public void projectRigidBodyPosConstraints(double t) {
    updateStateSizes();
    updateMassMatrix(t);
    VectorNd q = new VectorNd(myActivePosSize);
    StepAdjustment steppingInfo = new StepAdjustment();
    mySys.updateConstraints(t, steppingInfo, /*flags=*/
    MechSystem.COMPUTE_CONTACTS);
    mySys.getActivePosState(q);
    if (computeRigidBodyPosCorrections(q, t)) {
        mySys.setActivePosState(q);
    // mySys.updateConstraints (
    // t, steppingInfo,  /*flags=*/MechSystem.UPDATE_CONTACTS);
    }
}
Also used : VectorNd(maspack.matrix.VectorNd) StepAdjustment(artisynth.core.modelbase.StepAdjustment)

Example 5 with StepAdjustment

use of artisynth.core.modelbase.StepAdjustment in project artisynth_core by artisynth.

the class RigidBodyCollision method advance.

public synchronized StepAdjustment advance(double t0, double t1, int flags) {
    StepAdjustment adj = super.advance(t0, t1, flags);
    if ((adj == null || adj.getScaling() >= 1) && TimeBase.compare(t1 - lastResetTime, 6) > 0) {
        reset();
        lastResetTime = t1;
    }
    return adj;
}
Also used : StepAdjustment(artisynth.core.modelbase.StepAdjustment)

Aggregations

StepAdjustment (artisynth.core.modelbase.StepAdjustment)5 VectorNd (maspack.matrix.VectorNd)2 CompositeState (artisynth.core.modelbase.CompositeState)1 InternalErrorException (maspack.util.InternalErrorException)1