Skip to content

Conversation

@aleblanc30
Copy link
Contributor

As suggested by @alxbilger here

Also adapted from QEnergyStatWidget in Sofa.Qt.

I did not manage to build this yet on my machine, so I haven't tested it.

Copy link
Contributor

@alxbilger alxbilger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thanks

Does it work? Have you tested?

The problem is that not all the components implement the computation of the energies.

@aleblanc30
Copy link
Contributor Author

I haven't tested it yet, I can't build the plugin for some reason. I opened a topic in the forum : sofa-framework/sofa#5554

@aleblanc30
Copy link
Contributor Author

I have managed to build it in-tree. It works great for a simple scene with an object sliding on an incline. Do you happen to know which components may be a problem and need to be tested ?

@alxbilger
Copy link
Contributor

I cannot be specific, but usually, there is a runtime warning such as Method getPotentialEnergy not implemented yet.

For example:

Targets
    Occurrences of 'Method getPotentialEnergy not implemented yet.' in Solution with mask '*.cpp,*.inl,*.h,*.cu'
Found usages  (28 usages found)
      TetrahedronDiffusionFEMForceField.inl  (1 usage found)
          232 msg_warning() <<"Method getPotentialEnergy not implemented yet." ;
      ConicalForceField.h  (1 usage found)
          111 msg_warning() << "Method getPotentialEnergy not implemented yet.";
      EdgePressureForceField.inl  (1 usage found)
          132 msg_warning() << "Method getPotentialEnergy not implemented yet.";
      EllipsoidForceField.inl  (1 usage found)
          189 msg_warning() << "Method getPotentialEnergy not implemented yet.";
      OscillatingTorsionPressureForceField.inl  (1 usage found)
          200 msg_warning() << "Method getPotentialEnergy not implemented yet.";
      PlaneForceField.inl  (1 usage found)
          152 msg_warning() << "Method getPotentialEnergy not implemented yet.";
      QuadPressureForceField.h  (1 usage found)
          121 SReal getPotentialEnergy(const core::MechanicalParams* /*mparams*/, const DataVecCoord&  /* x */) const override { msg_warning() << "Method getPotentialEnergy not implemented yet."; return 0.0; }
      SphereForceField.inl  (1 usage found)
          236 msg_warning() << "Method getPotentialEnergy not implemented yet.";
      SurfacePressureForceField.inl  (1 usage found)
          301 msg_warning() << "Method getPotentialEnergy not implemented yet.";
      TaitSurfacePressureForceField.inl  (1 usage found)
          330 msg_warning() << "Method getPotentialEnergy not implemented yet.";
      TorsionForceField.inl  (1 usage found)
          154 msg_warning() << "Method getPotentialEnergy not implemented yet.";
      TrianglePressureForceField.inl  (1 usage found)
          240 msg_warning() << "Method getPotentialEnergy not implemented yet.";
      BeamFEMForceField.inl  (1 usage found)
          691 msg_warning() << "Method getPotentialEnergy not implemented yet.";
      FastTetrahedralCorotationalForceField.h  (1 usage found)
          146 msg_warning() << "Method getPotentialEnergy not implemented yet.";
      HexahedralFEMForceField.h  (1 usage found)
          151 msg_warning() << "Method getPotentialEnergy not implemented yet.";
      HexahedralFEMForceFieldAndMass.h  (1 usage found)
          93 msg_warning() << "Method getPotentialEnergy not implemented yet.";
      HexahedronFEMForceFieldAndMass.h  (2 usages found)
          102 msg_warning() << "Method getPotentialEnergy not implemented yet.";
          108 msg_warning() << "Method getPotentialEnergy not implemented yet.";
      TetrahedralCorotationalFEMForceField.h  (1 usage found)
          189 msg_warning() << "Method getPotentialEnergy not implemented yet.";
      TriangleFEMForceField.h  (1 usage found)
          109 msg_warning() << "Method getPotentialEnergy not implemented yet.";
      StandardTetrahedralFEMForceField.h  (1 usage found)
          184 msg_warning() << "Method getPotentialEnergy not implemented yet.";
      TetrahedronHyperelasticityFEMForceField.inl  (1 usage found)
          501 msg_warning() << "Method getPotentialEnergy not implemented yet.";
      AngularSpringForceField.h  (1 usage found)
          87 msg_warning() << "Method getPotentialEnergy not implemented yet.";
      RestShapeSpringsForceField.h  (1 usage found)
          109 msg_warning() << "Method getPotentialEnergy not implemented yet.";
      TriangularBiquadraticSpringsForceField.h  (1 usage found)
          158 msg_warning() << "Method getPotentialEnergy not implemented yet.";
      TriangularQuadraticSpringsForceField.h  (1 usage found)
          142 msg_warning() << "Method getPotentialEnergy not implemented yet.";
      TetrahedralTensorMassForceField.h  (1 usage found)
          114 msg_warning() << "Method getPotentialEnergy not implemented yet.";
      TriangularTensorMassForceField.h  (1 usage found)
          143 msg_warning() << "Method getPotentialEnergy not implemented yet.";

@aleblanc30
Copy link
Contributor Author

So from what I read, the methods that are not implemented actually just return 0. So the code will run, produce a warning, and a wrong result. I think this is fine ? Otherwise, I can change the not implemented method to return NaNs instead of 0.

@hugtalbot
Copy link
Contributor

Sounds reasonable to me to return 0
What's your opinion @alxbilger ?

@alxbilger
Copy link
Contributor

So from what I read, the methods that are not implemented actually just return 0. So the code will run, produce a warning, and a wrong result. I think this is fine ?

Yes, it's fine

@hugtalbot hugtalbot merged commit 72ff387 into sofa-framework:master Jun 25, 2025
4 checks passed
@aleblanc30 aleblanc30 deleted the energy branch June 26, 2025 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants