Search in sources :

Example 1 with FemModel3d

use of artisynth.core.femmodels.FemModel3d 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 2 with FemModel3d

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

the class TransverseIsotropyTest method createCylinder.

FemModel3d createCylinder(double h, double r) {
    FemModel3d fem = FemFactory.createCylinder(null, h, r, 24, 40, 4);
    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().z < -h / 2 + eps) {
            node.setDynamic(false);
        }
    }
    return fem;
}
Also used : FemModel3d(artisynth.core.femmodels.FemModel3d) FemNode3d(artisynth.core.femmodels.FemNode3d)

Example 3 with FemModel3d

use of artisynth.core.femmodels.FemModel3d 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)

Example 4 with FemModel3d

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

the class FemModel3dEditor method addActions.

public void addActions(EditActionMap actions, SelectionManager selManager) {
    LinkedList<ModelComponent> selection = selManager.getCurrentSelection();
    if (containsSingleSelection(selection, FemModel3d.class)) {
        FemModel3d model = (FemModel3d) selection.get(0);
        actions.add(this, "Add FemMarkers ...", EXCLUSIVE);
        actions.add(this, "Rebuild surface mesh");
        actions.add(this, "Add new surface mesh");
        actions.add(this, "Save surface mesh ...");
        actions.add(this, "Save mesh as Ansys file...");
        if (model.getGrandParent() instanceof MechModel) {
            actions.add(this, "Attach particles ...", EXCLUSIVE);
        }
    } else if (containsMultipleCommonParentSelection(selection, HexElement.class)) {
        actions.add(this, "Subdivide elements");
    }
    if (containsMultipleCommonParentSelection(selection, FemElement3d.class)) {
        actions.add(this, "Rebuild surface mesh for selected elements");
        actions.add(this, "Add new surface mesh for selected elements");
    }
}
Also used : HexElement(artisynth.core.femmodels.HexElement) MechModel(artisynth.core.mechmodels.MechModel) FemModel3d(artisynth.core.femmodels.FemModel3d) ModelComponent(artisynth.core.modelbase.ModelComponent)

Example 5 with FemModel3d

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

the class Fem3dBlock method setConnected.

public synchronized void setConnected(boolean connect) {
    MechModel mechMod = (MechModel) findComponent("models/mech");
    if (mechMod != null) {
        FemModel3d femMod = (FemModel3d) mechMod.findComponent("models/fem");
        LinkedList<FemNode3d> rightNodes = new LinkedList<FemNode3d>();
        for (int i = 0; i < myAttachNodes.length; i++) {
            rightNodes.add(myAttachNodes[i]);
        }
        if (connect && !rightNodes.get(0).isAttached()) {
            RigidBody rightBody = (RigidBody) mechMod.findComponent("rigidBodies/rightBody");
            // position the block so that it lies at the current
            // end of the beam
            Plane plane = new Plane();
            Point3d centroid = new Point3d();
            int numPnts = rightNodes.size();
            Point3d[] pnts = new Point3d[numPnts];
            for (int i = 0; i < numPnts; i++) {
                pnts[i] = rightNodes.get(i).getPosition();
                centroid.add(pnts[i]);
            }
            centroid.scale(1 / (double) numPnts);
            plane.fit(pnts, numPnts);
            Vector3d normal = new Vector3d(plane.getNormal());
            // to determine the appropriate sign of the normal
            for (FemNode3d node : femMod.getNodes()) {
                if (!rightNodes.contains(node)) {
                    Vector3d diff = new Vector3d();
                    diff.sub(node.getPosition(), rightNodes.get(0).getPosition());
                    if (diff.dot(normal) > 0) {
                        normal.negate();
                    }
                    break;
                }
            }
            RigidTransform3d X = new RigidTransform3d();
            X.R.setZDirection(normal);
            X.R.mulAxisAngle(0, 1, 0, -Math.PI / 2);
            X.p.set(centroid);
            X.mulXyz(0.05, 0, 0);
            rightBody.setPose(X);
            rightBody.setVelocity(new Twist());
            for (FemNode3d n : rightNodes) {
                mechMod.attachPoint(n, rightBody);
            }
        } else if (!connect && rightNodes.get(0).isAttached()) {
            for (FemNode3d n : rightNodes) {
                mechMod.detachPoint(n);
            }
        }
    }
    myConnectedP = connect;
}
Also used : FemModel3d(artisynth.core.femmodels.FemModel3d) Point(java.awt.Point) WayPoint(artisynth.core.probes.WayPoint) RevoluteJoint(artisynth.core.mechmodels.RevoluteJoint) MechModel(artisynth.core.mechmodels.MechModel) FemNode3d(artisynth.core.femmodels.FemNode3d) RigidBody(artisynth.core.mechmodels.RigidBody)

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