From 42d0513f68ebb1019f41c62681eff6bef62c474d Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Wed, 7 Oct 2026 11:37:10 +0200 Subject: [PATCH] adapt Mapping_Trampoline --- .../src/SofaPython3/Sofa/Core/Binding_Mapping.cpp | 11 ++++++++--- .../Sofa/src/SofaPython3/Sofa/Core/Binding_Mapping.h | 6 +++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Mapping.cpp b/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Mapping.cpp index 91f180391..428307f53 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Mapping.cpp +++ b/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Mapping.cpp @@ -96,8 +96,13 @@ namespace sofapython3 PythonFactory::toPython(&out), PythonFactory::toPython(&in)); } - template - void Mapping_Trampoline::applyJ( const MechanicalParams* mparams, OutDataVecDeriv& out, const InDataVecDeriv& in){ + template + void Mapping_Trampoline::doApplyJacobianVectorProduct( + const MechanicalParams *mparams, OutDataVecDeriv &tangentOut, + const InDataVecDeriv &tangentIn, const InDataVecCoord &positionIn) { + + SOFA_UNUSED(positionIn); + PythonEnvironment::gil acquire; // pass bFactor, kFactor, energy @@ -109,7 +114,7 @@ namespace sofapython3 "energy"_a=mparams->energy()); PYBIND11_OVERLOAD_PURE(void, Inherit1, applyJ, mp, - PythonFactory::toPython(&out), PythonFactory::toPython(&in)); + PythonFactory::toPython(&tangentOut), PythonFactory::toPython(&tangentIn)); } template diff --git a/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Mapping.h b/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Mapping.h index 362c20395..ad4c42fd5 100644 --- a/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Mapping.h +++ b/bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Mapping.h @@ -50,7 +50,11 @@ class Mapping_Trampoline : public sofa::core::Mapping { std::string getClassName() const override; void apply( const MechanicalParams* mparams, OutDataVecCoord& out, const InDataVecCoord& in) override; - void applyJ( const MechanicalParams* mparams, OutDataVecDeriv& out, const InDataVecDeriv& in) override; + void doApplyJacobianVectorProduct( + const MechanicalParams* mparams, + OutDataVecDeriv& tangentOut, + const InDataVecDeriv& tangentIn, + const InDataVecCoord& positionIn) override; void applyJT( const MechanicalParams* mparams, InDataVecDeriv& out, const OutDataVecDeriv& in) override; void applyJT( const ConstraintParams* mparams, InDataMatrixDeriv& out, const OutDataMatrixDeriv& in) override;