Skip to content

[Diffusion] Introduce generic diffusion - #6431

Open
alxbilger wants to merge 3 commits into
sofa-framework:masterfrom
alxbilger:diffusion
Open

alxbilger wants to merge 3 commits into
sofa-framework:masterfrom
alxbilger:diffusion

Conversation

@alxbilger

@alxbilger alxbilger commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

The objective is to provide a diffusion feature to be used for any type of element. It made sense to derive the class FEMForceField. This class is not tight to elasticity. However, it was developed with elasticity in mind and was not adapted to diffusion. For diffusion, we must make the difference between the field to integrate (temperature etc) and the spatial domain. For elasticity both are the same. It is already the case in MeshMatrixMass where there are two template parameters. So I used the same strategy: a new template parameter in FEMForceField class (breaking).

To use FEMForceField, I had to add the dependency to SolidMechanics.FEM.Elastic in Diffusion. In the future, we can think about moving the base class, in order to break this dependency.

The new diffusion force field gives the same result for the scene examples/Component/Diffusion/TetrahedronDiffusionFEMForceField.scn. The legacy force field, specialized for tetras is faster as an optimization specific to linear simplicials is used. To stay generic, the optimization cannot be applied in the generic class introduced in this PR.

Here are two videos of the introduced example. It shows similar results for both types of elements, hexas and tetras:

sofa_video_r60_0001.mp4
sofa_video_r60_0002.mp4

Questions:

  • I added a lot of explicit template instantiations. It may increase the compilation time. Not sure all are necessary. To be discussed.

Note:
Although the PR is not based on any other PR, the example requires the following PRs:


By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).


Reviewers will merge this pull-request only if

  • it builds with SUCCESS for all platforms on the CI.
  • it does not generate new warnings.
  • it does not generate new unit test failures.
  • it does not generate new scene test failures.
  • it does not break API compatibility.
  • it is more than 1 week old (or has fast-merge label).

@alxbilger alxbilger added pr: breaking Change possibly inducing a compilation error pr: status to review To notify reviewers to review this pull-request pr: new feature Implement a new feature pr: highlighted in next release Highlight this contribution in the notes of the upcoming release labels Oct 28, 2026
@alxbilger alxbilger added the pr: AI-aided Label notifying the reviewers that part or all of the PR has been generated with the help of an AI label Oct 28, 2026
@hugtalbot
hugtalbot self-requested a review October 29, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: AI-aided Label notifying the reviewers that part or all of the PR has been generated with the help of an AI pr: breaking Change possibly inducing a compilation error pr: highlighted in next release Highlight this contribution in the notes of the upcoming release pr: new feature Implement a new feature pr: status to review To notify reviewers to review this pull-request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant