Search in sources :

Example 16 with SparseMatrixNd

use of maspack.matrix.SparseMatrixNd 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

SparseMatrixNd (maspack.matrix.SparseMatrixNd)16 VectorNd (maspack.matrix.VectorNd)8 MatrixNd (maspack.matrix.MatrixNd)4 SparseMatrixCell (maspack.matrix.SparseMatrixCell)4 Point (artisynth.core.mechmodels.Point)2 FileReader (java.io.FileReader)2 IOException (java.io.IOException)2 Random (java.util.Random)2 LUDecomposition (maspack.matrix.LUDecomposition)2 Matrix3d (maspack.matrix.Matrix3d)2 Vector3d (maspack.matrix.Vector3d)2 ReaderTokenizer (maspack.util.ReaderTokenizer)2 FemElement3d (artisynth.core.femmodels.FemElement3d)1 FemNode3d (artisynth.core.femmodels.FemNode3d)1 IntegrationData3d (artisynth.core.femmodels.IntegrationData3d)1 IntegrationPoint3d (artisynth.core.femmodels.IntegrationPoint3d)1 PrintWriter (java.io.PrintWriter)1 SparseVectorCell (maspack.matrix.SparseVectorCell)1 SparseVectorNd (maspack.matrix.SparseVectorNd)1 NumberFormat (maspack.util.NumberFormat)1