|
2 | 2 |
|
3 | 3 | #include <Elasticity/component/ElementHyperelasticityFEMForceField.h> |
4 | 4 | #include <Elasticity/impl/Strain.h> |
5 | | -#include <sofa/type/VecView.h> |
6 | 5 | #include <sofa/component/solidmechanics/fem/elastic/impl/VectorTools.h> |
7 | 6 | #include <sofa/core/ObjectFactory.h> |
8 | 7 | #include <sofa/core/behavior/BaseLocalForceFieldMatrix.h> |
@@ -61,7 +60,7 @@ void ElementHyperelasticityFEMForceField<DataTypes, ElementType>::buildStiffness |
61 | 60 | for (sofa::Index n2 = 0; n2 < NumberOfNodesInElement; ++n2) |
62 | 61 | { |
63 | 62 | 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; |
65 | 64 | } |
66 | 65 | } |
67 | 66 | } |
@@ -346,10 +345,16 @@ void ElementHyperelasticityFEMForceField<TDataTypes, TElementType>::computeEleme |
346 | 345 | const auto P = l_material->firstPiolaKirchhoffStress(strain); |
347 | 346 | auto& elementForce = f[elementId]; |
348 | 347 |
|
| 348 | + sofa::type::Vec<trait::spatial_dimensions, sofa::Real_t<DataTypes>> nodeForce { sofa::type::NOINIT }; |
349 | 349 | for (sofa::Size i = 0; i < trait::NumberOfNodesInElement; ++i) |
350 | 350 | { |
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]); |
352 | 353 | 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 | + } |
353 | 358 | } |
354 | 359 | } |
355 | 360 | } |
|
0 commit comments