Search in sources :

Example 21 with FemModel3d

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

the class FemModel3dAgent method initializePrototype.

protected void initializePrototype(ModelComponent comp, Class type) {
    if (type == FemModel3d.class) {
        FemModel3d mkr = (FemModel3d) comp;
        RenderProps.setPointRadius(mkr, getDefaultPointRadius());
    } else {
        throw new InternalErrorException("Unimplemented type " + type);
    }
}
Also used : FemModel3d(artisynth.core.femmodels.FemModel3d) InternalErrorException(maspack.util.InternalErrorException)

Example 22 with FemModel3d

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

the class FemModel3dEditor method applyAction.

public void applyAction(String actionCommand, LinkedList<ModelComponent> selection, Rectangle popupBounds) {
    if (containsSingleSelection(selection, FemModel3d.class)) {
        FemModel3d model = (FemModel3d) selection.get(0);
        if (actionCommand == "Add FemMarkers ...") {
            if (myEditManager.acquireEditLock()) {
                Fem3dMarkerAgent agent = new Fem3dMarkerAgent(myMain, model);
                agent.show(popupBounds);
            }
        } else if (actionCommand == "Rebuild surface mesh") {
            rebuildSurfaceMesh(model);
        } else if (actionCommand == "Add new surface mesh") {
            addNewSurfaceMesh(model);
        } else if (actionCommand == "Save surface mesh ...") {
            EditorUtils.saveMesh(model.getSurfaceMesh(), /*Transform= */
            null);
        } else if (actionCommand == "Save mesh as Ansys file...") {
            EditorUtils.saveMeshAsAnsysFile(model);
        } else if (actionCommand == "Attach particles ...") {
            if (myEditManager.acquireEditLock()) {
                // XXX should be more general than this ... what if mechModel
                // is a sub model?
                MechModel mech = (MechModel) model.getGrandParent();
                myMain.getSelectionManager().clearSelections();
                AttachParticleFemAgent agent = new AttachParticleFemAgent(myMain, mech, model);
                agent.show(popupBounds);
            }
        }
    } else if (containsMultipleCommonParentSelection(selection, HexElement.class)) {
        if (actionCommand == "Subdivide elements") {
            FemModel3d mod = (FemModel3d) ComponentUtils.getGrandParent(selection.get(0));
            for (ModelComponent c : selection) {
                mod.subdivideHex((HexElement) c);
            }
        }
    }
    if (actionCommand == "Rebuild surface mesh for selected elements") {
        FemModel3d mod = (FemModel3d) ComponentUtils.getGrandParent(selection.get(0));
        rebuildSurfaceMeshForSelectedElements(mod);
    } else if (actionCommand == "Add new surface mesh for selected elements") {
        FemModel3d mod = (FemModel3d) ComponentUtils.getGrandParent(selection.get(0));
        addNewSurfaceMeshForSelectedElements(mod);
    }
}
Also used : HexElement(artisynth.core.femmodels.HexElement) MechModel(artisynth.core.mechmodels.MechModel) FemModel3d(artisynth.core.femmodels.FemModel3d) ModelComponent(artisynth.core.modelbase.ModelComponent)

Example 23 with FemModel3d

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

the class Cell method readUnstructuredMesh_volume.

public static FemModel3d readUnstructuredMesh_volume(String filename) {
    try {
        FemModel3d fem = new FemModel3d();
        VtkData data = readVTKUnstructuredGrid(filename);
        buildUnstructuredMesh_volume(fem, data);
        return fem;
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
}
Also used : FemModel3d(artisynth.core.femmodels.FemModel3d)

Example 24 with FemModel3d

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

the class TransverseIsotropy 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;
    RigidBody rb = RigidBody.createBox("box", 2 * r, 2 * r, 2 * r, 100, true);
    mech.addRigidBody(rb);
    rb.transformGeometry(new RigidTransform3d(new Vector3d(0, 0, -h / 2 - r), AxisAngle.IDENTITY));
    FemModel3d fem = FemFactory.createCylinder(null, h, r, 24, 40, 4);
    fem.setDensity(1000);
    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);
    fem.setMaterial(mat);
    fem.setName("fem");
    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);
        } else if (node.getPosition().z < -h / 2 + eps) {
            PointAttachment pa = rb.createPointAttachment(node);
            mech.addAttachment(pa);
        }
    }
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) RigidTransform3d(maspack.matrix.RigidTransform3d) FemModel3d(artisynth.core.femmodels.FemModel3d) Vector3d(maspack.matrix.Vector3d) FemNode3d(artisynth.core.femmodels.FemNode3d) RigidBody(artisynth.core.mechmodels.RigidBody) PointAttachment(artisynth.core.mechmodels.PointAttachment) TransverseLinearMaterial(artisynth.core.materials.TransverseLinearMaterial)

Example 25 with FemModel3d

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

the class Fem3dBlock method build.

public void build(String type, int nz, int nxy, int options) {
    FemModel3d femMod = new FemModel3d("fem");
    femMod.setDensity(myDensity);
    if (type.equals("tet")) {
        FemFactory.createTetGrid(femMod, 0.6, 0.2, 0.2, nz, nxy, nxy);
    } else if (type.equals("hex")) {
        FemFactory.createHexGrid(femMod, 0.6, 0.2, 0.2, nz, nxy, nxy);
    } else if (type.equals("quadtet")) {
        FemFactory.createQuadtetGrid(femMod, 0.6, 0.2, 0.2, nz, nxy, nxy);
    } else if (type.equals("quadhex")) {
        FemFactory.createQuadhexGrid(femMod, 0.6, 0.2, 0.2, nz, nxy, nxy);
    } else {
        throw new UnsupportedOperationException("Unsupported element type " + type);
    }
    femMod.setBounds(new Point3d(-0.6, 0, 0), new Point3d(0.6, 0, 0));
    femMod.setLinearMaterial(200000, 0.4, true);
    femMod.setStiffnessDamping(0.002);
    Renderable elements = femMod.getElements();
    RenderProps.setLineWidth(elements, 2);
    RenderProps.setLineColor(elements, Color.BLUE);
    Renderable nodes = femMod.getNodes();
    RenderProps.setPointStyle(nodes, Renderer.PointStyle.SPHERE);
    RenderProps.setPointRadius(nodes, 0.01);
    RenderProps.setPointColor(nodes, new Color(153, 0, 204));
    // fix the leftmost nodes
    LinkedList<FemNode3d> leftNodes = getLeftNodes(femMod);
    LinkedList<FemNode3d> rightNodes = getRightNodes(femMod);
    myAttachNodes = rightNodes.toArray(new FemNode3d[0]);
    double wx, wy, wz;
    double mass;
    RigidTransform3d X = new RigidTransform3d();
    PolygonalMesh mesh;
    MechModel mechMod = new MechModel("mech");
    // mechMod.setPrintState ("%10.5f");
    wx = 0.1;
    wy = 0.3;
    wz = 0.3;
    RigidBody leftBody = new RigidBody("leftBody");
    mass = wx * wy * wz * myDensity;
    leftBody.setInertia(SpatialInertia.createBoxInertia(mass, wx, wy, wz));
    mesh = MeshFactory.createBox(wx, wy, wz);
    // mesh.setRenderMaterial (Material.createSpecial (Material.GRAY));
    leftBody.setMesh(mesh, /* fileName= */
    null);
    X.R.setIdentity();
    X.p.set(-0.35, 0, 0);
    leftBody.setPose(X);
    leftBody.setDynamic(true);
    mechMod.addRigidBody(leftBody);
    RenderProps.setPointStyle(mechMod, Renderer.PointStyle.SPHERE);
    RigidTransform3d TCW = new RigidTransform3d();
    RigidTransform3d TCA = new RigidTransform3d();
    TCA.p.set(0, 0, wz / 2);
    TCA.R.mulAxisAngle(1, 0, 0, Math.PI / 2);
    TCW.mul(X, TCA);
    RevoluteJoint joint = new RevoluteJoint(leftBody, TCA, TCW);
    RenderProps.setCylindricalLines(joint, 0.01, Color.BLUE);
    joint.setAxisLength(0.5);
    mechMod.addBodyConnector(joint);
    // right box
    RigidBody rightBody = new RigidBody("rightBody");
    rightBody.setInertia(SpatialInertia.createBoxInertia(mass, wx, wy, wz));
    mesh = MeshFactory.createBox(wx, wy, wz);
    // mesh.setRenderMaterial (Material.createSpecial (Material.GRAY));
    rightBody.setMesh(mesh, /* fileName= */
    null);
    X.p.set(0.35, 0, 0);
    rightBody.setPose(X);
    rightBody.setDynamic(true);
    mechMod.addRigidBody(rightBody);
    mechMod.addModel(femMod);
    for (FemNode3d n : leftNodes) {
        mechMod.attachPoint(n, leftBody);
    }
    // femMod.setProfile (true);
    mechMod.setIntegrator(Integrator.BackwardEuler);
    setConnected(true);
    addModel(mechMod);
    // mechMod.setProfiling (true);
    // int numWays = 10;
    // double res = 0.1;
    // for (int i = 0; i < numWays; i++) {
    // addWayPoint (new WayPoint (TimeBase.secondsToTicks ((i + 1) * res)));
    // }
    // addWayPoint (new WayPoint (TimeBase.secondsToTicks (5)));
    // addBreakPoint(5);
    // setupOutputProbes();
    addControlPanel(mechMod, femMod);
}
Also used : FemModel3d(artisynth.core.femmodels.FemModel3d) 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