Search in sources :

Example 11 with FemElement3d

use of artisynth.core.femmodels.FemElement3d 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 12 with FemElement3d

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

the class MFreeMeshComp method getFaceElement.

public MFreeElement3d getFaceElement(Face face) {
    // Form the intersection of all the element dependencies of all three
    // nodes associated with the face. If the face is on the surface,
    // there should be only one element left.
    HashSet<MFreeNode3d> nodes = new HashSet<MFreeNode3d>();
    HalfEdge he0 = face.firstHalfEdge();
    HalfEdge he = he0;
    do {
        addVertexNodes(nodes, he.getHead());
        he = he.getNext();
    } while (he != he0);
    HashSet<FemElement3d> elems = null;
    for (MFreeNode3d node : nodes) {
        if (elems == null) {
            elems = new HashSet<>(node.getElementDependencies());
        } else {
            elems.retainAll(node.getElementDependencies());
        }
    }
    if (elems.size() != 1) {
        MFreeElement3d[] elemArray = elems.toArray(new MFreeElement3d[0]);
        int[] idxs = face.getVertexIndices();
        System.out.print("Error: couldn't get element for face [ ");
        for (int i = 0; i < idxs.length; i++) {
            System.out.print("" + idxs[i] + " ");
        }
        System.out.println("]");
        System.out.println("Candidate elements are:");
        for (int i = 0; i < elemArray.length; i++) {
            System.out.println(" element " + elemArray[i].getNumber());
        }
        return null;
    // ignore for now ...
    // throw new InternalErrorException (
    // "Face "+face+" associated with "+elems.size()+" elements");
    }
    return (MFreeElement3d) elems.toArray()[0];
}
Also used : FemElement3d(artisynth.core.femmodels.FemElement3d) HalfEdge(maspack.geometry.HalfEdge) ContactPoint(artisynth.core.mechmodels.ContactPoint) Point(artisynth.core.mechmodels.Point) HashSet(java.util.HashSet)

Example 13 with FemElement3d

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

the class MFreeModel3d method findNearestElement.

/**
 * Finds the nearest element and node coordinates
 * @param nearest nearest point
 * @param N shape function evaluation at point
 * @return the nearest element
 */
public FemElement3d findNearestElement(Point3d nearest, Point3d pnt, VectorNd N) {
    BVFeatureQuery query = new BVFeatureQuery();
    NearestIPointCalculator dcalc = new NearestIPointCalculator(pnt);
    query.nearestObject(getElementBVTree(), dcalc);
    FemElement3d elem = dcalc.nearestObject();
    MFreeIntegrationPoint3d ipnt = dcalc.nearestIPoint();
    nearest.set(ipnt.getPosition());
    N.set(ipnt.getShapeWeights());
    return elem;
}
Also used : FemElement3d(artisynth.core.femmodels.FemElement3d) BVFeatureQuery(maspack.geometry.BVFeatureQuery)

Example 14 with FemElement3d

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

the class MFreeModel3d method findNaturalCoordinates.

/**
 * Finds the containing element and node coordinates
 * @param pnt 3D point in world coordinates to find natural coordinates of
 * @param coords natural coordinates
 * @param N shape function values
 * @return the containing element if it exists
 */
public FemNode3d[] findNaturalCoordinates(Point3d pnt, Point3d coords, VectorNd N) {
    BVFeatureQuery query = new BVFeatureQuery();
    NearestIPointCalculator dcalc = new NearestIPointCalculator(pnt);
    query.nearestObject(getElementBVTree(), dcalc);
    FemElement3d elem = dcalc.nearestObject();
    MFreeIntegrationPoint3d ipnt = dcalc.nearestIPoint();
    // try to compute coords
    coords.set(ipnt.getRestPosition());
    int n = ((MFreeElement3d) elem).getNaturalCoordinates(coords, pnt, 1000, N);
    return elem.getNodes();
}
Also used : FemElement3d(artisynth.core.femmodels.FemElement3d) BVFeatureQuery(maspack.geometry.BVFeatureQuery) Point(artisynth.core.mechmodels.Point)

Example 15 with FemElement3d

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

the class MFreeModel3d method computeConsistentMassMatrix.

public SparseMatrixNd computeConsistentMassMatrix() {
    int nNodes = myNodes.size();
    SparseMatrixNd M = new SparseMatrixNd(nNodes, nNodes);
    updateJacobians();
    for (FemElement3d e : myElements) {
        for (int k = 0; k < e.numIntegrationPoints(); k++) {
            IntegrationPoint3d ipnt = e.getIntegrationPoints()[k];
            IntegrationData3d idat = e.getIntegrationData()[k];
            VectorNd shapeCoords = ipnt.getShapeWeights();
            for (int i = 0; i < e.numNodes(); i++) {
                for (int j = i; j < e.numNodes(); j++) {
                    // if (e.isTermActive(i, j)) {
                    int bi = e.getNodes()[i].getNumber();
                    int bj = e.getNodes()[j].getNumber();
                    double m = myDensity * shapeCoords.get(i) * shapeCoords.get(j) * ipnt.getWeight() * ipnt.getDetF() * idat.getDetJ0();
                    M.set(bi, bj, M.get(bi, bj) + m);
                    if (i != j) {
                        M.set(bj, bi, M.get(bj, bi) + m);
                    }
                // }
                }
            }
        }
    }
    return M;
}
Also used : FemElement3d(artisynth.core.femmodels.FemElement3d) SparseMatrixNd(maspack.matrix.SparseMatrixNd) IntegrationPoint3d(artisynth.core.femmodels.IntegrationPoint3d) VectorNd(maspack.matrix.VectorNd) IntegrationData3d(artisynth.core.femmodels.IntegrationData3d) Point(artisynth.core.mechmodels.Point)

Aggregations

FemElement3d (artisynth.core.femmodels.FemElement3d)21 FemNode3d (artisynth.core.femmodels.FemNode3d)8 Point3d (maspack.matrix.Point3d)7 Vector3d (maspack.matrix.Vector3d)7 Point (artisynth.core.mechmodels.Point)6 IntegrationPoint3d (artisynth.core.femmodels.IntegrationPoint3d)4 MuscleBundle (artisynth.core.femmodels.MuscleBundle)4 IntegrationData3d (artisynth.core.femmodels.IntegrationData3d)3 VectorNd (maspack.matrix.VectorNd)3 FemMarker (artisynth.core.femmodels.FemMarker)2 FemMeshComp (artisynth.core.femmodels.FemMeshComp)2 FemMuscleModel (artisynth.core.femmodels.FemMuscleModel)2 LinearMaterial (artisynth.core.materials.LinearMaterial)2 SimpleForceMuscle (artisynth.core.materials.SimpleForceMuscle)2 MechModel (artisynth.core.mechmodels.MechModel)2 ArrayList (java.util.ArrayList)2 BVFeatureQuery (maspack.geometry.BVFeatureQuery)2 PolygonalMesh (maspack.geometry.PolygonalMesh)2 Vertex3d (maspack.geometry.Vertex3d)2 RigidTransform3d (maspack.matrix.RigidTransform3d)2