Search in sources :

Example 11 with FemModel3d

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

the class LinearAuxiliaryTest method createHexGrid.

static FemModel3d createHexGrid(double wx, double wy, double wz, int nx, int ny, int nz) {
    FemModel3d fem = FemFactory.createHexGrid(null, wx, wy, wz, nx, ny, nz);
    fem.setDensity(1000);
    fem.setSurfaceRendering(SurfaceRender.Shaded);
    RenderProps.setFaceColor(fem, Color.ORANGE);
    RenderProps.setVisible(fem.getElements(), false);
    double eps = 1e-10;
    for (FemNode3d node : fem.getNodes()) {
        if (node.getPosition().x < -wx / 2 + eps) {
            node.setDynamic(false);
        }
    }
    return fem;
}
Also used : FemModel3d(artisynth.core.femmodels.FemModel3d) FemNode3d(artisynth.core.femmodels.FemNode3d)

Example 12 with FemModel3d

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

the class SimpleCollide method setBottomObject.

private void setBottomObject(Collidable comp, ObjectType type) {
    Renderable rcomp = (Renderable) comp;
    ((TransformableGeometry) comp).transformGeometry(AffineTransform3d.createScaling(myBottomScale));
    switch(type) {
        case FemEllipsoid:
        case FemSphere:
            {
                RenderProps.setPointColor(rcomp, Color.green);
                // fix the lower nodes
                Point3d min = new Point3d();
                RenderableUtils.getBounds(rcomp, min, null);
                FemModel3d fem = (FemModel3d) comp;
                fem.getSurfaceMesh();
                for (FemNode3d n : fem.getNodes()) {
                    if (fem.isSurfaceNode(n) && n.getPosition().z <= (min.z + mySize * 0.5)) {
                        n.setDynamic(false);
                    }
                }
                fem.resetRestPosition();
                break;
            }
        case FemCube:
            {
                RenderProps.setPointColor(rcomp, Color.green);
                // fix the lower nodes
                Point3d min = new Point3d();
                RenderableUtils.getBounds(rcomp, min, null);
                FemModel3d fem = (FemModel3d) comp;
                fem.getSurfaceMesh();
                for (FemNode3d n : fem.getNodes()) {
                    if (fem.isSurfaceNode(n) && n.getPosition().z <= (min.z + mySize * 0.1)) {
                        n.setDynamic(false);
                    }
                }
                // RenderProps.setAlpha (rcomp, 0.3);
                fem.resetRestPosition();
                break;
            }
        case Box:
            {
                ((RigidBody) comp).setDynamic(false);
                ((RigidBody) comp).setDistanceGridRes(new Vector3i(10, 5, 5));
                break;
            }
        case Molar:
            {
                ((RigidBody) comp).setPose(new RigidTransform3d(0, 0, 0, 0, -1, 0, Math.toRadians(172.09)));
                ((RigidBody) comp).setDynamic(false);
                break;
            }
        case Bin:
            {
                ((RigidBody) comp).setPose(new RigidTransform3d(0, 0, 0, 0, 0, 0, 0));
                ((RigidBody) comp).setDynamic(false);
                break;
            }
        case Paw:
        case House:
            {
                ((RigidBody) comp).setDynamic(false);
                break;
            }
        default:
            {
                throw new InternalErrorException("Unimplemented type " + type);
            }
    }
    myBottomObject = comp;
    myBottomType = type;
}
Also used : TransformableGeometry(artisynth.core.modelbase.TransformableGeometry) RigidTransform3d(maspack.matrix.RigidTransform3d) Renderable(maspack.render.Renderable) FemModel3d(artisynth.core.femmodels.FemModel3d) Point3d(maspack.matrix.Point3d) FemNode3d(artisynth.core.femmodels.FemNode3d) Vector3i(maspack.matrix.Vector3i) InternalErrorException(maspack.util.InternalErrorException)

Example 13 with FemModel3d

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

the class SimpleCollide method createFem.

private FemModel3d createFem(String name) {
    FemModel3d fem = new FemModel3d(name);
    fem.setDensity(myDensity);
    fem.setParticleDamping(myParticleDamping);
    fem.setStiffnessDamping(myStiffnessDamping);
    // fem.setPoissonsRatio (myPoissonsRatio);
    // fem.setYoungsModulus (myYoungsModulus);
    fem.setLinearMaterial(myYoungsModulus, myPoissonsRatio, true);
    RenderProps.setPointStyle(fem, Renderer.PointStyle.SPHERE);
    RenderProps.setLineWidth(fem, 0);
    RenderProps.setPointRadius(fem, mySize / 30.0);
    RenderProps.setVisible(fem.getNodes(), false);
    // RenderProps.setPointRadius (fem, 0);
    return fem;
}
Also used : FemModel3d(artisynth.core.femmodels.FemModel3d)

Example 14 with FemModel3d

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

the class SimpleCollide method removeObject.

private void removeObject(ModelComponent comp, ObjectType type) {
    MechModel mechMod = (MechModel) models().get(0);
    ComponentList<Probe> myProbes = getInputProbes();
    for (Probe p : myProbes) {
        System.out.println("type's name: " + type.name());
        System.out.println("probe's name: " + p.getName());
        if (type.name().equals(p.getName())) {
            removeInputProbe(p);
        }
    }
    switch(type) {
        case FemEllipsoid:
        case FemSphere:
        case FemCube:
            {
                mechMod.removeModel((FemModel3d) comp);
                break;
            }
        case Box:
        case Molar:
        case Bin:
        case Paw:
        case House:
            {
                mechMod.removeRigidBody((RigidBody) comp);
                break;
            }
        default:
            {
                throw new InternalErrorException("Unimplemented type " + type);
            }
    }
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) FemModel3d(artisynth.core.femmodels.FemModel3d) RigidBody(artisynth.core.mechmodels.RigidBody) InternalErrorException(maspack.util.InternalErrorException) Probe(artisynth.core.probes.Probe) NumericInputProbe(artisynth.core.probes.NumericInputProbe)

Example 15 with FemModel3d

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

the class TransverseIsotropyTest method build.

@Override
public void build(String[] args) throws IOException {
    super.build(args);
    MechModel mech = new MechModel("mech");
    addModel(mech);
    double h = 0.1;
    double r = 0.005;
    FemModel3d fem = createCylinder(h, r);
    fem.setName("transverse");
    mech.addModel(fem);
    TransverseLinearMaterial mat = new TransverseLinearMaterial();
    mat.setYoungsModulus(50000, 50000);
    mat.setPoissonsRatio(0.45, 0.45);
    double G = 50000 / (2 * (1 + 0.45));
    mat.setShearModulus(G);
    mat.setCorotated(true);
    fem.setMaterial(mat);
    FemModel3d fem2 = createCylinder(h, r);
    fem2.setName("linear");
    LinearMaterial lmat = new LinearMaterial(50000, 0.45, true);
    fem2.setMaterial(lmat);
    mech.addModel(fem2);
    RigidTransform3d rot = new RigidTransform3d(Vector3d.ZERO, AxisAngle.ROT_Y_90);
    fem.transformGeometry(rot);
    fem2.transformGeometry(rot);
    fem2.transformGeometry(new RigidTransform3d(new Vector3d(0, 2 * r, 0), AxisAngle.IDENTITY));
    RenderProps.setFaceColor(fem2, Color.MAGENTA);
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) RigidTransform3d(maspack.matrix.RigidTransform3d) FemModel3d(artisynth.core.femmodels.FemModel3d) Vector3d(maspack.matrix.Vector3d) TransverseLinearMaterial(artisynth.core.materials.TransverseLinearMaterial) TransverseLinearMaterial(artisynth.core.materials.TransverseLinearMaterial) LinearMaterial(artisynth.core.materials.LinearMaterial)

Aggregations

FemModel3d (artisynth.core.femmodels.FemModel3d)29 MechModel (artisynth.core.mechmodels.MechModel)14 FemNode3d (artisynth.core.femmodels.FemNode3d)12 RigidTransform3d (maspack.matrix.RigidTransform3d)11 RigidBody (artisynth.core.mechmodels.RigidBody)7 InternalErrorException (maspack.util.InternalErrorException)6 LinearMaterial (artisynth.core.materials.LinearMaterial)5 Vector3d (maspack.matrix.Vector3d)5 RevoluteJoint (artisynth.core.mechmodels.RevoluteJoint)3 HexElement (artisynth.core.femmodels.HexElement)2 TransverseLinearMaterial (artisynth.core.materials.TransverseLinearMaterial)2 ModelComponent (artisynth.core.modelbase.ModelComponent)2 TransformableGeometry (artisynth.core.modelbase.TransformableGeometry)2 PolygonalMesh (maspack.geometry.PolygonalMesh)2 Point3d (maspack.matrix.Point3d)2 Renderable (maspack.render.Renderable)2 AuxMaterialBundle (artisynth.core.femmodels.AuxMaterialBundle)1 AuxMaterialElementDesc (artisynth.core.femmodels.AuxMaterialElementDesc)1 FemElement3d (artisynth.core.femmodels.FemElement3d)1 FemElementType (artisynth.core.femmodels.FemFactory.FemElementType)1