mimesis-inria / caribou

Multi-physics computation library
GNU Lesser General Public License v3.0
29 stars 17 forks source link

[SofaCaribou] Adds a method to manually update the stiffness matrix of the HyperelasticForcefield #58

Closed jnbrunet closed 3 years ago

jnbrunet commented 3 years ago

This PR allows one to manually assemble the tangent stiffness matrix of a hyperelastic forcefield using a custom position vector. The following python script is therefore now possible:

import Sofa, SofaRuntime
import SofaCaribou

def createScene(root):
    # (...)
    root.addObject('HyperelasticForcefield', name='ff')
    # (...)

def main():
    root = Sofa.Core.Node()
    createScene(root)
    Sofa.Simulation.init(root)
    x = get_position_vector()
    root.ff.assemble_stiffness(x)
    K = root.ff.K()

The PR also adds a new benchtest that compare the assembly of the stiffness matrix when the F deformation tensor is always computed, against when it is stored during the force vector assembly.