Search in sources :

Example 26 with FemNode3d

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

the class JointedFemBeams method build.

public void build(String[] args) {
    MechModel mech = new MechModel("mechMod");
    addModel(mech);
    double stiffness = 5000;
    // create first fem beam and fix the leftmost nodes
    FemModel3d fem1 = addFem(mech, 2.4, 0.6, 0.4, stiffness);
    for (FemNode3d n : fem1.getNodes()) {
        if (n.getPosition().x <= -1.2) {
            n.setDynamic(false);
        }
    }
    // create the second fem beam and shift it 1.5 to the right
    FemModel3d fem2 = addFem(mech, 2.4, 0.4, 0.4, 0.1 * stiffness);
    fem2.transformGeometry(new RigidTransform3d(1.5, 0, 0));
    // create a slotted revolute joint that connects the two fem beams
    RigidTransform3d TDW = new RigidTransform3d(0.5, 0, 0, 0, 0, Math.PI / 2);
    SlottedRevoluteJoint joint = new SlottedRevoluteJoint(fem2, fem1, TDW);
    mech.addBodyConnector(joint);
    // set ranges and rendering properties for the joint
    joint.setAxisLength(0.8);
    joint.setMinX(-0.5);
    joint.setMaxX(0.5);
    joint.setSlotWidth(0.61);
    RenderProps.setLineColor(joint, myJointColor);
    RenderProps.setLineWidth(joint, 3);
    RenderProps.setLineRadius(joint, 0.04);
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) RigidTransform3d(maspack.matrix.RigidTransform3d) FemModel3d(artisynth.core.femmodels.FemModel3d) SlottedRevoluteJoint(artisynth.core.mechmodels.SlottedRevoluteJoint) FemNode3d(artisynth.core.femmodels.FemNode3d)

Example 27 with FemNode3d

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

the class FemDisplayProbe method getStrainValue.

// computes strain of a point inside the model based on FEM shape
// function interpolation
private static double getStrainValue(Point3d pnt, FemModel3d model) {
    Point3d loc = new Point3d();
    FemElement3d elem = model.findNearestElement(loc, pnt);
    Vector3d coords = new Vector3d();
    double strain = 0;
    if (elem != null) {
        elem.getNaturalCoordinates(coords, pnt);
        FemNode3d[] nodes = elem.getNodes();
        for (int i = 0; i < elem.numNodes(); i++) {
            strain += elem.getN(i, coords) * nodes[i].getVonMisesStrain();
        }
    }
    return strain;
}
Also used : FemElement3d(artisynth.core.femmodels.FemElement3d) Vector3d(maspack.matrix.Vector3d) Point3d(maspack.matrix.Point3d) FemNode3d(artisynth.core.femmodels.FemNode3d)

Example 28 with FemNode3d

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

the class MFreeFactory method createPartitionedElementsFromPoints.

private static <A extends MFreePoint3d> ArrayList<MFreeElement3d> createPartitionedElementsFromPoints(A[] pnts, HashMap<A, MFreeElement3d> pntMap) {
    ArrayList<MFreeElement3d> elems = new ArrayList<MFreeElement3d>();
    HashMap<FemNode3d, LinkedList<MFreeElement3d>> elemMap = new HashMap<>();
    MFreeShapeFunction fun = new MLSShapeFunction();
    for (A pnt : pnts) {
        FemNode3d[] nodes = pnt.getDependentNodes();
        MFreeElement3d elem = findElem(nodes, elemMap);
        if (elem == null) {
            elem = new MFreeElement3d(fun, Arrays.copyOf(nodes, nodes.length));
            elems.add(elem);
            for (FemNode3d node : nodes) {
                LinkedList<MFreeElement3d> elemList = elemMap.get(node);
                if (elemList == null) {
                    elemList = new LinkedList<>();
                    elemList.add(elem);
                    elemMap.put(node, elemList);
                } else {
                    elemList.add(elem);
                }
            }
        }
        pntMap.put(pnt, elem);
    }
    return elems;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) FemNode3d(artisynth.core.femmodels.FemNode3d)

Example 29 with FemNode3d

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

the class MFreeModel3d method addMarker.

/**
 * Adds a marker to this FemModel. The element to which it belongs is
 * determined automatically. If the marker's current position does not lie
 * within the model and {@code project == true}, it will be projected onto
 * the model's surface.
 *
 * @param pos
 * position to place a marker in the model
 */
public FemMarker addMarker(Point3d pos) {
    FemMarker mkr = new FemMarker();
    Point3d coord = new Point3d();
    VectorNd N = new VectorNd();
    FemNode3d[] nodes = findNaturalCoordinates(pos, coord, N);
    mkr.setPosition(pos);
    double[] wgts = new double[N.size()];
    for (int i = 0; i < N.size(); ++i) {
        wgts[i] = N.get(i);
    }
    mkr.setFromNodes(nodes, wgts);
    addMarker(mkr);
    return mkr;
}
Also used : Point3d(maspack.matrix.Point3d) IntegrationPoint3d(artisynth.core.femmodels.IntegrationPoint3d) VectorNd(maspack.matrix.VectorNd) FemNode3d(artisynth.core.femmodels.FemNode3d) FemMarker(artisynth.core.femmodels.FemMarker) Point(artisynth.core.mechmodels.Point)

Example 30 with FemNode3d

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

the class MFreeModel3d method findDependentNodesAtRest.

/**
 * Finds nodes containing the given point at rest
 * @param pnt point to find nodes for
 * @param out output list of nodes influencing region
 * @return number of nodes found
 */
public int findDependentNodesAtRest(Point3d pnt, List<FemNode3d> out) {
    AABBTree nodeTree = myRestNodeTree;
    if (nodeTree == null) {
        nodeTree = buildRestNodeTree(myNodes);
        myRestNodeTree = nodeTree;
    }
    ArrayList<BVNode> bvNodes = new ArrayList<BVNode>(16);
    nodeTree.intersectPoint(bvNodes, pnt);
    if (bvNodes.size() == 0) {
        return 0;
    }
    int count = 0;
    for (BVNode n : bvNodes) {
        Boundable[] elements = n.getElements();
        for (int i = 0; i < elements.length; i++) {
            RestNode rnode = (RestNode) elements[i];
            FemNode3d node = rnode.getNode();
            if (((MFreeNode3d) node).isInDomain(pnt, 0)) {
                out.add(node);
                ++count;
            }
        }
    }
    return count;
}
Also used : AABBTree(maspack.geometry.AABBTree) BVNode(maspack.geometry.BVNode) ArrayList(java.util.ArrayList) FemNode3d(artisynth.core.femmodels.FemNode3d) Boundable(maspack.geometry.Boundable) Point(artisynth.core.mechmodels.Point)

Aggregations

FemNode3d (artisynth.core.femmodels.FemNode3d)38 FemModel3d (artisynth.core.femmodels.FemModel3d)12 Point3d (maspack.matrix.Point3d)12 RigidTransform3d (maspack.matrix.RigidTransform3d)9 FemElement3d (artisynth.core.femmodels.FemElement3d)8 MechModel (artisynth.core.mechmodels.MechModel)8 Point (artisynth.core.mechmodels.Point)7 RigidBody (artisynth.core.mechmodels.RigidBody)7 Vector3d (maspack.matrix.Vector3d)6 ArrayList (java.util.ArrayList)5 FemMarker (artisynth.core.femmodels.FemMarker)4 IntegrationPoint3d (artisynth.core.femmodels.IntegrationPoint3d)4 VectorNd (maspack.matrix.VectorNd)4 TetElement (artisynth.core.femmodels.TetElement)3 RevoluteJoint (artisynth.core.mechmodels.RevoluteJoint)3 LinkedList (java.util.LinkedList)3 FemNode (artisynth.core.femmodels.FemNode)2 HexElement (artisynth.core.femmodels.HexElement)2 PointFem3dAttachment (artisynth.core.femmodels.PointFem3dAttachment)2 PyramidElement (artisynth.core.femmodels.PyramidElement)2