Skip to content

Commit

Permalink
[SofaMiscFem] Remove unnecessary copy/pasted code (#2421)
Browse files Browse the repository at this point in the history
  • Loading branch information
alxbilger authored Oct 21, 2021
1 parent 17a9eef commit 5a3ed53
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 36 deletions.
10 changes: 5 additions & 5 deletions SofaKernel/modules/SofaCore/src/sofa/core/behavior/ForceField.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,20 @@ class ForceField : public BaseForceField
template<class IndexArray, class ElementMat>
void addToMatrix(sofa::defaulttype::BaseMatrix* bm, unsigned offset, const IndexArray& nodeIndex, const ElementMat& em, SReal scale )
{
const unsigned S = DataTypes::deriv_total_size; // size of node blocks
constexpr auto S = DataTypes::deriv_total_size; // size of node blocks
for (unsigned n1=0; n1<nodeIndex.size(); n1++)
{
for(unsigned i=0; i<S; i++)
{
unsigned ROW = offset + S*nodeIndex[n1] + i; // i-th row associated with node n1 in BaseMatrix
unsigned row = S*n1+i; // i-th row associated with node n1 in the element matrix
const unsigned ROW = offset + S*nodeIndex[n1] + i; // i-th row associated with node n1 in BaseMatrix
const unsigned row = S*n1+i; // i-th row associated with node n1 in the element matrix

for (unsigned n2=0; n2<nodeIndex.size(); n2++)
{
for (unsigned j=0; j<S; j++)
{
unsigned COLUMN = offset + S*nodeIndex[n2] +j; // j-th column associated with node n2 in BaseMatrix
unsigned column = S*n2+j; // j-th column associated with node n2 in the element matrix
const unsigned COLUMN = offset + S*nodeIndex[n2] +j; // j-th column associated with node n2 in BaseMatrix
const unsigned column = S*n2+j; // j-th column associated with node n2 in the element matrix
bm->add( ROW,COLUMN, em[row][column]* scale );
}
}
Expand Down
31 changes: 0 additions & 31 deletions modules/SofaMiscFem/src/SofaMiscFem/TriangleFEMForceField.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,37 +164,6 @@ protected :
void computeElementStiffnessMatrix( StiffnessMatrix& S, StiffnessMatrix& SR, const MaterialStiffness &K, const StrainDisplacement &J, const Transformation& Rot );
void addKToMatrix(sofa::defaulttype::BaseMatrix *mat, SReal k, unsigned int &offset) override; // compute and add all the element stiffnesses to the global stiffness matrix

/** Accumulate an element matrix to a global assembly matrix. This is a helper for addKToMatrix, to accumulate each (square) element matrix in the (square) assembled matrix.
\param bm the global assembly matrix
\param offset start index of the local DOFs within the global matrix
\param nodeIndex indices of the nodes of the element within the local nodes, as stored in the topology
\param em element matrix, typically a stiffness, damping, mass, or weighted sum thereof
\param scale weight applied to the matrix, typically ±params->kfactor() for a stiffness matrix
*/
template<class IndexArray, class ElementMat>
void addToMatrix(sofa::defaulttype::BaseMatrix* bm, unsigned offset, const IndexArray& nodeIndex, const ElementMat& em, SReal scale )
{
const unsigned S = DataTypes::deriv_total_size; // size of node blocks
for (unsigned n1=0; n1<nodeIndex.size(); n1++)
{
for(unsigned i=0; i<S; i++)
{
unsigned ROW = offset + S*nodeIndex[n1] + i; // i-th row associated with node n1 in BaseMatrix
unsigned row = S*n1+i; // i-th row associated with node n1 in the element matrix

for (unsigned n2=0; n2<nodeIndex.size(); n2++)
{
for (unsigned j=0; j<S; j++)
{
unsigned COLUMN = offset + S*nodeIndex[n2] +j; // j-th column associated with node n2 in BaseMatrix
unsigned column = 3*n2+j; // j-th column associated with node n2 in the element matrix
bm->add( ROW,COLUMN, em[row][column]* scale );
}
}
}
}
}

type::Mat<3, 3, Real> InvalidTransform;
type::fixed_array <Coord, 3> InvalidCoords;
StrainDisplacement InvalidStrainDisplacement;
Expand Down

0 comments on commit 5a3ed53

Please sign in to comment.