Skip to content

Commit 0889c8f

Browse files
committed
fix wrong sign
1 parent a9f6088 commit 0889c8f

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/Elasticity/component/ElementHyperelasticityFEMForceField.inl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#include <Elasticity/component/ElementHyperelasticityFEMForceField.h>
44
#include <Elasticity/impl/Strain.h>
5-
#include <sofa/type/VecView.h>
65
#include <sofa/component/solidmechanics/fem/elastic/impl/VectorTools.h>
76
#include <sofa/core/ObjectFactory.h>
87
#include <sofa/core/behavior/BaseLocalForceFieldMatrix.h>
@@ -61,7 +60,7 @@ void ElementHyperelasticityFEMForceField<DataTypes, ElementType>::buildStiffness
6160
for (sofa::Index n2 = 0; n2 < NumberOfNodesInElement; ++n2)
6261
{
6362
stiffnessMatrix.getsub(spatial_dimensions * n1, spatial_dimensions * n2, localMatrix); //extract the submatrix corresponding to the coupling of nodes n1 and n2
64-
dfdx(element[n1] * spatial_dimensions, element[n2] * spatial_dimensions) += localMatrix;
63+
dfdx(element[n1] * spatial_dimensions, element[n2] * spatial_dimensions) += -localMatrix;
6564
}
6665
}
6766
}
@@ -346,10 +345,16 @@ void ElementHyperelasticityFEMForceField<TDataTypes, TElementType>::computeEleme
346345
const auto P = l_material->firstPiolaKirchhoffStress(strain);
347346
auto& elementForce = f[elementId];
348347

348+
sofa::type::Vec<trait::spatial_dimensions, sofa::Real_t<DataTypes>> nodeForce { sofa::type::NOINIT };
349349
for (sofa::Size i = 0; i < trait::NumberOfNodesInElement; ++i)
350350
{
351-
sofa::type::VecView<trait::spatial_dimensions, sofa::Real_t<DataTypes>> nodeForce(elementForce, i * trait::spatial_dimensions);
351+
elementForce.getsub(i * trait::spatial_dimensions, nodeForce);
352+
// elementForce.setsub(i * trait::spatial_dimensions, nodeForce + (detJ_Q * weight) * P * dN_dQ[i]);
352353
nodeForce += (detJ_Q * weight) * P * dN_dQ[i];
354+
for (sofa::Size j = 0; j < trait::spatial_dimensions; ++j)
355+
{
356+
elementForce[i * trait::spatial_dimensions + j] = nodeForce[j];
357+
}
353358
}
354359
}
355360
}

0 commit comments

Comments
 (0)