Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ namespace sofapython3
matrix.colsValue.data());
}, sofapython3::doc::forceField::assembleKMatrix);

f.def("getPotentialEnergy", [](ForceField<TDOFType>& self) -> SReal
{
return self.getPotentialEnergy(MechanicalParams::defaultInstance());
}, sofapython3::doc::forceField::getPotentialEnergy);

PythonFactory::registerType<ForceField<TDOFType>>([](sofa::core::objectmodel::Base* object)
{
return py::cast(dynamic_cast<ForceField<TDOFType>*>(object));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,11 @@ stiffness_matrix = self.force_field.assembleKMatrix()
Returns:
A scipy.sparse.csr_matrix object representing the stiffness matrix of the force field
)";

static constexpr const char* getPotentialEnergy = R"(
Potential energy of the force field, evaluated at its current positions.

Returns:
The potential energy of the force field, as a float
)";
}
Loading