Search in sources :

Example 1 with LinearMaterial

use of artisynth.core.materials.LinearMaterial in project artisynth_core by artisynth.

the class FemBeamWithFemSphere method build.

public void build(String[] args) throws IOException {
    // Build simple FemBeam
    super.build(args);
    // Create a FEM sphere
    FemModel3d femSphere = new FemModel3d("sphere");
    mech.addModel(femSphere);
    // Read from TetGen file
    TetGenReader.read(femSphere, ArtisynthPath.getSrcRelativePath(FemModel3d.class, "meshes/sphere2.1.node"), ArtisynthPath.getSrcRelativePath(FemModel3d.class, "meshes/sphere2.1.ele"));
    femSphere.scaleDistance(0.22);
    // FEM properties
    femSphere.setDensity(10);
    femSphere.setParticleDamping(2);
    femSphere.setMaterial(new LinearMaterial(4000, 0.33));
    // Reposition FEM to side of beam
    femSphere.transformGeometry(new RigidTransform3d(length / 2 + width / 2, 0, 0));
    // Attach sphere nodes that are inside beam
    for (FemNode3d node : femSphere.getNodes()) {
        // Find element containing node (if exists)
        FemElement3d elem = fem.findContainingElement(node.getPosition());
        // Add attachment if node is inside "fem"
        if (elem != null) {
            mech.attachPoint(node, elem);
        }
    }
    // Set render properties
    setRenderProps(femSphere);
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) LinearMaterial(artisynth.core.materials.LinearMaterial)

Example 2 with LinearMaterial

use of artisynth.core.materials.LinearMaterial in project artisynth_core by artisynth.

the class FemEmbeddedSphere method build.

@Override
public void build(String[] args) throws IOException {
    super.build(args);
    mech = new MechModel("mech");
    addModel(mech);
    fem = new FemModel3d("fem");
    mech.addModel(fem);
    // Build hex beam and set properties
    double[] size = { 0.4, 0.4, 0.4 };
    int[] res = { 4, 4, 4 };
    FemFactory.createHexGrid(fem, size[0], size[1], size[2], res[0], res[1], res[2]);
    fem.setParticleDamping(2);
    fem.setDensity(10);
    fem.setMaterial(new LinearMaterial(4000, 0.33));
    // Add an embedded sphere mesh
    PolygonalMesh sphereSurface = MeshFactory.createOctahedralSphere(0.15, 3);
    sphere = fem.addMesh("sphere", sphereSurface);
    sphere.setCollidable(Collidability.EXTERNAL);
    // Boundary condition: fixed LHS
    for (FemNode3d node : fem.getNodes()) {
        if (node.getPosition().x < -0.49) {
            node.setDynamic(false);
        }
    }
    // Set rendering properties
    setFemRenderProps(fem);
    setMeshRenderProps(sphere);
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) LinearMaterial(artisynth.core.materials.LinearMaterial)

Example 3 with LinearMaterial

use of artisynth.core.materials.LinearMaterial in project artisynth_core by artisynth.

the class FrameFemAttachment method build.

public void build(String[] args) {
    MechModel mech = new MechModel("mech");
    addModel(mech);
    // create and add FEM beam
    FemModel3d fem = FemFactory.createHexGrid(null, 1.0, 0.2, 0.2, 6, 3, 3);
    fem.setMaterial(new LinearMaterial(500000, 0.33));
    RenderProps.setLineColor(fem, Color.BLUE);
    RenderProps.setLineWidth(mech, 2);
    mech.addModel(fem);
    // fix leftmost nodes of the FEM
    for (FemNode3d n : fem.getNodes()) {
        if ((n.getPosition().x - (-0.5)) < 1e-8) {
            n.setDynamic(false);
        }
    }
    // create and add rigid body box
    RigidBody box = RigidBody.createBox("box", 0.25, 0.1, 0.1, /*density=*/
    1000);
    mech.add(box);
    // create a basic frame and and set its pose and axis length
    Frame frame = new Frame();
    frame.setPose(new RigidTransform3d(0.4, 0, 0, 0, Math.PI / 4, 0));
    frame.setAxisLength(0.3);
    mech.addFrame(frame);
    // attach using element-based attachment
    mech.attachFrame(frame, fem);
    // attach the box to the FEM, using all the nodes of elements 31 and 32
    HashSet<FemNode3d> nodes = collectNodes(fem, new int[] { 22, 31 });
    FrameFem3dAttachment attachment = new FrameFem3dAttachment(box);
    attachment.setFromNodes(box.getPose(), nodes);
    mech.addAttachment(attachment);
    // render the attachment nodes for the box as spheres
    for (FemNode n : attachment.getNodes()) {
        RenderProps.setSphericalPoints(n, 0.007, Color.GREEN);
    }
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) LinearMaterial(artisynth.core.materials.LinearMaterial)

Example 4 with LinearMaterial

use of artisynth.core.materials.LinearMaterial in project artisynth_core by artisynth.

the class JointedFemBeams method addFem.

// create an FEM beam  with specified size and stiffness, and add it
// to a mech model
private FemModel3d addFem(MechModel mech, double wx, double wy, double wz, double stiffness) {
    FemModel3d fem = FemFactory.createHexGrid(null, wx, wy, wz, 10, 1, 1);
    fem.setMaterial(new LinearMaterial(stiffness, 0.3));
    fem.setDensity(1.0);
    fem.setMassDamping(1.0);
    RenderProps.setFaceColor(fem, myLinkColor);
    RenderProps.setEdgeColor(fem, myEdgeColor);
    fem.setSurfaceRendering(FemModel3d.SurfaceRender.Shaded);
    mech.addModel(fem);
    return fem;
}
Also used : FemModel3d(artisynth.core.femmodels.FemModel3d) LinearMaterial(artisynth.core.materials.LinearMaterial)

Example 5 with LinearMaterial

use of artisynth.core.materials.LinearMaterial in project artisynth_core by artisynth.

the class FemBeam method build.

public void build(String[] args) throws IOException {
    // Create and add MechModel
    mech = new MechModel("mech");
    addModel(mech);
    // Create and add FemModel
    fem = new FemModel3d("fem");
    mech.add(fem);
    // Build hex beam using factory method
    FemFactory.createHexGrid(fem, length, width, width, /*nx=*/
    6, /*ny=*/
    3, /*nz=*/
    3);
    // Set FEM properties
    fem.setDensity(density);
    fem.setParticleDamping(0.1);
    fem.setMaterial(new LinearMaterial(4000, 0.33));
    // Fix left-hand nodes for boundary condition
    for (FemNode3d n : fem.getNodes()) {
        if (n.getPosition().x <= -length / 2 + EPS) {
            n.setDynamic(false);
        }
    }
    // Set rendering properties
    setRenderProps(fem);
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) FemModel3d(artisynth.core.femmodels.FemModel3d) FemNode3d(artisynth.core.femmodels.FemNode3d) LinearMaterial(artisynth.core.materials.LinearMaterial)

Aggregations

LinearMaterial (artisynth.core.materials.LinearMaterial)14 MechModel (artisynth.core.mechmodels.MechModel)6 RigidTransform3d (maspack.matrix.RigidTransform3d)6 FemModel3d (artisynth.core.femmodels.FemModel3d)5 Vector3d (maspack.matrix.Vector3d)4 IncompNeoHookeanMaterial (artisynth.core.materials.IncompNeoHookeanMaterial)3 Point (java.awt.Point)3 FemElement3d (artisynth.core.femmodels.FemElement3d)2 FemMeshComp (artisynth.core.femmodels.FemMeshComp)2 RigidBody (artisynth.core.mechmodels.RigidBody)2 PolygonalMesh (maspack.geometry.PolygonalMesh)2 AuxMaterialBundle (artisynth.core.femmodels.AuxMaterialBundle)1 AuxMaterialElementDesc (artisynth.core.femmodels.AuxMaterialElementDesc)1 FemMuscleModel (artisynth.core.femmodels.FemMuscleModel)1 FemNode3d (artisynth.core.femmodels.FemNode3d)1 MuscleBundle (artisynth.core.femmodels.MuscleBundle)1 FemMaterial (artisynth.core.materials.FemMaterial)1 MooneyRivlinMaterial (artisynth.core.materials.MooneyRivlinMaterial)1 MuscleMaterial (artisynth.core.materials.MuscleMaterial)1 NullMaterial (artisynth.core.materials.NullMaterial)1