MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / getMassMatrix

Method getMassMatrix

tools/Assembler/ref/Assembler2D.cpp:69–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67}
68
69ZSparseMatrix Assembler2D::getMassMatrix(bool lumped, int repeats) {
70 double p = m_density;
71
72 typedef Eigen::Triplet<double> T;
73 std::vector<T> triplets;
74
75 if (lumped) {
76 for (size_t i=0; i<m_mesh->getNbrElements(); i++) {
77 VectorI idx = m_mesh->getElement(i);
78 assert(idx.size() == 3);
79 double V = m_mesh->getElementVolume(i);
80
81 for (size_t j=0; j<idx.size(); j++)
82 for (size_t l=0; l<repeats; l++)
83 triplets.push_back(T(repeats*idx[j]+l,
84 repeats*idx[j]+l, p*V/3.0));
85 }
86 } else {
87 double coeff_jj = 1.0 / 6.0,
88 coeff_jk = 1.0 / 12.0;
89 for (size_t i=0; i<m_mesh->getNbrElements(); ++i) {
90 VectorI idx = m_mesh->getElement(i);
91 assert(idx.size() == 3);
92 double V = m_mesh->getElementVolume(i);
93
94 for (size_t j=0; j<3; ++j) {
95 for (size_t k=0; k<3; ++k) {
96 if (idx[j] == idx[k]) {
97 for (size_t l=0; l<repeats; ++l)
98 triplets.push_back(
99 T(repeats*idx[j]+l, repeats*idx[k]+l, p*V*coeff_jj));
100 } else {
101 for (size_t l=0; l<repeats; ++l)
102 triplets.push_back(
103 T(repeats*idx[j]+l, repeats*idx[k]+l, p*V*coeff_jk));
104 }
105 }
106 }
107 }
108 }
109
110 Eigen::SparseMatrix<double> M = Eigen::SparseMatrix<double>(
111 repeats*m_mesh->getNbrNodes(), repeats*m_mesh->getNbrNodes());
112 M.setFromTriplets(triplets.begin(), triplets.end());
113 return ZSparseMatrix(M);
114}
115
116ZSparseMatrix Assembler2D::getStiffnessMatrix() {
117 // Elastic modulii

Callers

nothing calls this directly

Calls 8

ZSparseMatrixClass · 0.50
getNbrElementsMethod · 0.45
getElementMethod · 0.45
sizeMethod · 0.45
getElementVolumeMethod · 0.45
getNbrNodesMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected