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;
}
Aggregations