// Build the mass matrix (for these variables) scaled by c_a, storing // it in 'storage' sparse matrix, at given column/row offset. // Note, most iterative solvers don't need to know mass matrix explicitly. // Optimized: doesn't fill unneeded elements except mass and 3x3 inertia. void ChVariablesBodySharedMass::Build_M(ChSparseMatrix& storage, int insrow, int inscol, const double c_a) { storage.SetElement(insrow + 0, inscol + 0, c_a * sharedmass->mass); storage.SetElement(insrow + 1, inscol + 1, c_a * sharedmass->mass); storage.SetElement(insrow + 2, inscol + 2, c_a * sharedmass->mass); ChMatrix33<> scaledJ = sharedmass->inertia * c_a; storage.PasteMatrix(scaledJ, insrow + 3, inscol + 3); }
int ChSparseMatrix::DecomposeAndSolve_LDL_forLCP(ChMatrix<>* B, ChMatrix<>* X, double& mdet, int i_D, int i_C, int n_unilaterals, ChUnilateralData constr_data[], int from_eq) { ChSparseMatrix tempM; tempM.CopyFromMatrix(this); // deactivate the non-clamped or not yet considered unilateral constraints for (int nd = 0; nd < n_unilaterals; nd++) { if (constr_data[nd].status != CONSTR_UNILATERAL_ON) tempM.SetElement(i_D+nd, i_D+nd, INFINITE_PIVOT); } tempM.DecomposeAndSolve_LDL(B,X,mdet, from_eq); return TRUE; }
// Build the mass matrix (for these variables) scaled by c_a, storing // it in 'storage' sparse matrix, at given column/row offset. // Note, most iterative solvers don't need to know mass matrix explicitly. // Optimized: doesn't fill unneeded elements except mass. void ChVariablesShaft::Build_M(ChSparseMatrix& storage, int insrow, int inscol, const double c_a) { storage.SetElement(insrow + 0, inscol + 0, c_a * m_inertia); }
// Build the mass matrix (for these variables) scaled by c_a, storing // it in 'storage' sparse matrix, at given column/row offset. // Note, most iterative solvers don't need to know mass matrix explicitly. // Optimized: doesn't fill unneeded elements except mass. void ChVariablesNode::Build_M(ChSparseMatrix& storage, int insrow, int inscol, const double c_a) { double scaledmass = c_a * mass; storage.SetElement(insrow + 0, inscol + 0, scaledmass); storage.SetElement(insrow + 1, inscol + 1, scaledmass); storage.SetElement(insrow + 2, inscol + 2, scaledmass); }