Search in sources :

Example 6 with MuscleBundle

use of artisynth.core.femmodels.MuscleBundle in project artisynth_core by artisynth.

the class FemMuscleDemo method initializeModel.

protected void initializeModel(int xn) throws IOException {
    double widthX = 0.09;
    double widthY = 0.03;
    double widthZ = 0.03;
    int numX = xn * 9;
    int numY = xn * 3;
    int numZ = xn * 3;
    tissue = new FemMuscleModel("fem");
    FemFactory.createHexGrid(tissue, widthX, widthY, widthZ, numX, numY, numZ);
    tissue.setBounds(new Point3d(-widthX, 0, 0), new Point3d(widthX, 0, 0));
    // XXX fix the leftmost nodes
    double EPS = 1e-9;
    double xmin = Double.POSITIVE_INFINITY;
    for (FemNode3d n : tissue.getNodes()) {
        if (n.getPosition().x < xmin) {
            xmin = n.getPosition().x;
        }
    }
    for (FemNode3d n : tissue.getNodes()) {
        if (Math.abs(n.getPosition().x - xmin) < 1e-10) {
            n.setDynamic(false);
        }
    }
    LinkedList<FemElement3d> topElems = new LinkedList<FemElement3d>();
    LinkedList<FemElement3d> midElems = new LinkedList<FemElement3d>();
    LinkedList<FemElement3d> botElems = new LinkedList<FemElement3d>();
    for (FemElement3d e : tissue.getElements()) {
        if (defaultMidElements == ALL) {
            midElems.add(e);
        }
        for (FemNode3d n : e.getNodes()) {
            if (Math.abs(n.getPosition().z - widthZ / 2) < EPS) {
                topElems.add(e);
                break;
            } else if (Math.abs(n.getPosition().z + widthZ / 2) < EPS) {
                botElems.add(e);
                break;
            } else if (defaultMidElements == MIDDLE && Math.abs(n.getPosition().z - widthZ / (2 * numZ)) < EPS) {
                midElems.add(e);
                break;
            }
        }
    }
    RenderProps.setLineWidth(tissue, 2);
    RenderProps.setLineColor(tissue, Color.PINK);
    RenderProps.setPointStyle(tissue, Renderer.PointStyle.SPHERE);
    RenderProps.setPointRadius(tissue, 0.03);
    RenderProps.setPointColor(tissue, Color.PINK);
    RenderProps.setFaceColor(tissue, Color.PINK.darker());
    GenericMuscle mm = new GenericMuscle();
    mm.setMaxStress(5000);
    BlemkerMuscle bm = new BlemkerMuscle();
    // bm.setMaxStress (5000);
    tissue.setMuscleMaterial(bm);
    MuscleBundle top, mid, bot;
    top = createBundle("top", topElems);
    mid = createBundle("mid", midElems);
    bot = createBundle("bot", botElems);
    int k = 0;
    setBundleRenderProps(top, getMuscleColor(k++));
    if (addMidMuscle) {
        setBundleRenderProps(mid, getMuscleColor(k++));
    }
    setBundleRenderProps(bot, getMuscleColor(k));
    tissue.addMuscleBundle(top);
    if (addMidMuscle) {
        tissue.addMuscleBundle(mid);
    }
    tissue.addMuscleBundle(bot);
    double qt = midQuadTerm;
    addStrand(top, -0.035, -0.005, 0.015, 0.035, -0.005, 0.015, 0, 8);
    addStrand(top, -0.035, 0.005, 0.015, 0.035, 0.005, 0.015, 0, 8);
    if (addMidMuscle) {
        addStrand(mid, -0.035, -0.005, 0.000, 0.035, -0.005, 0.000, qt, 8);
        addStrand(mid, -0.035, 0.005, 0.000, 0.035, 0.005, 0.000, qt, 8);
    }
    addStrand(bot, -0.035, -0.005, -0.015, 0.035, -0.005, -0.015, 0, 8);
    addStrand(bot, -0.035, 0.005, -0.015, 0.035, 0.005, -0.015, 0, 8);
    if (addMidMuscle) {
        if (addMidElementsWithin > 0) {
            mid.addElementsNearFibres(addMidElementsWithin);
        }
        if (autoComputeMidDirections) {
            mid.computeElementDirections();
        }
    }
    tissue.setDirectionRenderLen(0.5);
    RenderProps.setPointRadius(tissue, 0.001);
    tissue.setGravity(0, 0, 0);
    tissue.setDensity(1000);
    tissue.setMaterial(new MooneyRivlinMaterial(1037, 0, 0, 486, 0, 10000));
    // tissue.setPoissonsRatio (0.499);
    // tissue.setYoungsModulus (6912);
    tissue.setParticleDamping(6.22);
    // more stable with 0 stiffness damping ...
    tissue.setStiffnessDamping(0.01);
    // tissue.setMaxStepSize(100*TimeBase.USEC);
    tissue.setMaxStepSize(0.01);
    tissue.setIntegrator(Integrator.ConstrainedBackwardEuler);
    myModel.addModel(tissue);
    addModel(myModel);
    for (MuscleBundle b : tissue.getMuscleBundles()) {
        RenderProps.setVisible(b.getFibres(), false);
    }
    for (FemMarker m : tissue.markers()) {
        RenderProps.setVisible(m, false);
    }
    addProbes(tissue);
    createMusclePanel();
// int numWays = 20;
// double res = 0.1;
// for (int i = 0; i < numWays; i++) {
// addWayPoint (new WayPoint (TimeBase.secondsToTicks ((i + 1) * res)));
// }
}
Also used : FemElement3d(artisynth.core.femmodels.FemElement3d) MooneyRivlinMaterial(artisynth.core.materials.MooneyRivlinMaterial) BlemkerMuscle(artisynth.core.materials.BlemkerMuscle) FemMarker(artisynth.core.femmodels.FemMarker) Point(artisynth.core.mechmodels.Point) LinkedList(java.util.LinkedList) MuscleBundle(artisynth.core.femmodels.MuscleBundle) Point3d(maspack.matrix.Point3d) FemMuscleModel(artisynth.core.femmodels.FemMuscleModel) FemNode3d(artisynth.core.femmodels.FemNode3d) GenericMuscle(artisynth.core.materials.GenericMuscle)

Example 7 with MuscleBundle

use of artisynth.core.femmodels.MuscleBundle in project artisynth_core by artisynth.

the class HydrostatModel method colorBundles.

public void colorBundles(String[] names, boolean createPanel) {
    for (int i = 0; i < names.length; i++) {
        MuscleBundle b = myMuscleList.get(names[i]);
        if (b != null) {
            RenderProps.setLineColor(b, Color.getHSBColor((float) i / names.length, 1f, 1f));
            labels.add(names[i]);
        }
    }
    if (createPanel)
        createBundlesPanel(names);
}
Also used : MuscleBundle(artisynth.core.femmodels.MuscleBundle) Point(artisynth.core.mechmodels.Point)

Example 8 with MuscleBundle

use of artisynth.core.femmodels.MuscleBundle in project artisynth_core by artisynth.

the class HydrostatModel method setupRenderProps.

public void setupRenderProps() {
    setSurfaceRendering(SurfaceRender.Shaded);
    // RenderProps.setAlpha (this, 0.5);
    RenderProps.setFaceStyle(this, Renderer.FaceStyle.NONE);
    RenderProps.setLineWidth(this, 1);
    RenderProps.setPointSize(getNodes(), 4);
    RenderProps.setPointColor(getNodes(), Color.BLUE);
    for (MuscleBundle b : getMuscleBundles()) {
        RenderProps.setLineStyle(b, Renderer.LineStyle.SPINDLE);
        RenderProps.setLineRadius(b, 0.5);
    }
}
Also used : MuscleBundle(artisynth.core.femmodels.MuscleBundle)

Example 9 with MuscleBundle

use of artisynth.core.femmodels.MuscleBundle in project artisynth_core by artisynth.

the class HydrostatModel method addTentacleMuscles.

/*
    * testing for tentacle simulations
    */
public void addTentacleMuscles() {
    // don't just create peripheral long fibers
    periphLongP = false;
    for (Axis a : Axis.values()) createMuscles(a, a.getDirName());
    for (Axis a : Axis.values()) {
        MuscleBundle b = new MuscleBundle(a.getDirName());
        for (Muscle m : muscleFibres) {
            if (Math.abs(m.getDir().dot(a.getDir()) - 1.0) < 1e-4) {
                // if (m.getName().startsWith(a.getDirName())) {
                b.addFibre(m);
            }
        }
        addMuscleBundle(b);
        RenderProps.setLineStyle(b, Renderer.LineStyle.SPINDLE);
        RenderProps.setLineColor(b, PlotTraceInfo.getPaletteColors()[b.getNumber()]);
    }
}
Also used : MuscleBundle(artisynth.core.femmodels.MuscleBundle) Muscle(artisynth.core.mechmodels.Muscle) ConstantAxialMuscle(artisynth.core.materials.ConstantAxialMuscle)

Example 10 with MuscleBundle

use of artisynth.core.femmodels.MuscleBundle in project artisynth_core by artisynth.

the class HydrostatModel method addTentacleExciters.

public void addTentacleExciters() {
    for (Axis a : Axis.values()) {
        MuscleBundle b = myMuscleList.get(a.getDirName());
        for (Hemisphere hemi : Hemisphere.values()) {
            if (Math.abs(hemi.getDir().dot(a.getDir())) == 1.0)
                continue;
            MuscleExciter ex = new MuscleExciter(a.getDirName() + "_" + hemi.getName());
            for (Muscle m : b.getFibres()) {
                if (hemi.check(m.getFirstPoint()) && hemi.check(m.getSecondPoint())) {
                    ex.addTarget(m, 1.0);
                }
            }
            addMuscleExciter(ex);
        }
    }
}
Also used : MuscleBundle(artisynth.core.femmodels.MuscleBundle) Muscle(artisynth.core.mechmodels.Muscle) ConstantAxialMuscle(artisynth.core.materials.ConstantAxialMuscle) MuscleExciter(artisynth.core.mechmodels.MuscleExciter)

Aggregations

MuscleBundle (artisynth.core.femmodels.MuscleBundle)25 Muscle (artisynth.core.mechmodels.Muscle)6 FemElement3d (artisynth.core.femmodels.FemElement3d)4 ConstantAxialMuscle (artisynth.core.materials.ConstantAxialMuscle)4 Point3d (maspack.matrix.Point3d)4 FemMuscleModel (artisynth.core.femmodels.FemMuscleModel)3 Point (artisynth.core.mechmodels.Point)3 Color (java.awt.Color)3 DoubleFieldSlider (maspack.widgets.DoubleFieldSlider)3 TrackingController (artisynth.core.inverse.TrackingController)2 SimpleForceMuscle (artisynth.core.materials.SimpleForceMuscle)2 MuscleExciter (artisynth.core.mechmodels.MuscleExciter)2 Point (java.awt.Point)2 LinkedList (java.util.LinkedList)2 RenderProps (maspack.render.RenderProps)2 FemMarker (artisynth.core.femmodels.FemMarker)1 FemMeshComp (artisynth.core.femmodels.FemMeshComp)1 FemNode (artisynth.core.femmodels.FemNode)1 FemNode3d (artisynth.core.femmodels.FemNode3d)1 MuscleElementDesc (artisynth.core.femmodels.MuscleElementDesc)1