Skip to content

[MPM] Compute sum reactions for a given model part#14149

Open
ncrescenzio wants to merge 29 commits intomasterfrom
mpm/compute-sum-reactions
Open

[MPM] Compute sum reactions for a given model part#14149
ncrescenzio wants to merge 29 commits intomasterfrom
mpm/compute-sum-reactions

Conversation

@ncrescenzio
Copy link
Contributor

@ncrescenzio ncrescenzio commented Jan 22, 2026

📝 Description

This PR introduces two new output processes for writing total reaction forces to file:

  • MPMGridConformingReactionOutputProcess: sums the nodal REACTION values across a given model part and writes the total to a file at each output step.
  • MPMNonConformingReactionOutputProcess: sums the MPC_CONTACT_FORCE values across the material point conditions of a given model part and writes the total to a file at each output step.
  • Both processes share a common base class (MPMReactionOutputProcess) that handles file I/O and time-stepping logic, while each subclass provides the specific summation strategy.

🆕 Changelog

  • C++ utility: new ReactionUtilities for summing REACTION across nodes or MPC_CONTACT_FORCE across material point conditions of a given model part.
  • C++ tests: unit tests for the new utility (test_reaction_utilities.cpp).
  • Python processes:
    • MPMReactionOutputProcess: base class handling file output and output control.
    • MPMGridConformingReactionOutputProcess: grid-conforming specialization (nodal reactions).
    • MPMNonConformingReactionOutputProcess: non-conforming specialization (material point contact forces).
  • Python tests: test_mpm_reaction_output_process.py covering both conforming and non-conforming output processes.

@ncrescenzio ncrescenzio marked this pull request as ready for review February 17, 2026 11:47
@ncrescenzio ncrescenzio requested a review from a team as a code owner February 17, 2026 11:47
@ncrescenzio
Copy link
Contributor Author

sorry @roigcarlo can you help me to understand why windows is failing? Unfortunately i do not have a windows machine, so i cannot try to compile it locally (and in any case i have no idea why it is not compiling).

This is the error

D:\a\Kratos\Kratos\applications\MPMApplication\custom_utilities\reaction_utilities.cpp(25,43): error C2220: the following warning is treated as an error [D:\a\Kratos\Kratos\build\Custom\applications\MPMApplication\KratosMPMApplication.vcxproj]
  (compiling source file 'CMakeFiles/KratosMPMApplication.dir/Unity/unity_0_cxx.cxx')
  
D:\a\Kratos\Kratos\applications\MPMApplication\custom_utilities\reaction_utilities.cpp(25,43): warning C4273: 'Kratos::ReactionUtilities::CalculateGridConformingReaction': inconsistent dll linkage [D:\a\Kratos\Kratos\build\Custom\applications\MPMApplication\KratosMPMApplication.vcxproj]
  (compiling source file 'CMakeFiles/KratosMPMApplication.dir/Unity/unity_0_cxx.cxx')
      D:\a\Kratos\Kratos\applications\MPMApplication\custom_utilities\reaction_utilities.h(38,32):
      see previous definition of 'Kratos::ReactionUtilities::CalculateGridConformingReaction'
  
D:\a\Kratos\Kratos\applications\MPMApplication\custom_utilities\reaction_utilities.cpp(29,43): warning C4273: 'Kratos::ReactionUtilities::CalculateNonConformingReaction': inconsistent dll linkage [D:\a\Kratos\Kratos\build\Custom\applications\MPMApplication\KratosMPMApplication.vcxproj]
  (compiling source file 'CMakeFiles/KratosMPMApplication.dir/Unity/unity_0_cxx.cxx')
      D:\a\Kratos\Kratos\applications\MPMApplication\custom_utilities\reaction_utilities.h(46,32):
      see previous definition of 'Kratos::ReactionUtilities::CalculateNonConformingReaction'

Thanks

@roigcarlo
Copy link
Member

@ncrescenzio I've been looking at the code and I see nothing wrong. Please let me check it tomorrow morining :/.

If you want to try something in the meantime, the only thing that smells to me right now is the interaction between a static method only class and the KRATOSA_API, maybe removing it solves the warning...

@roigcarlo
Copy link
Member

@ncrescenzio

There were some problems, I directly fixed them because they do not involved any physics. Mainly the issue was that you were including *.cpp for material_point_generator_utility and reaction_utilities.

This was causing the "core" to compile correctly, but the interface trying to compile again de definitions instead of importing them using decorator in the declaration, hance incosistent linkage.

I've changed the cpp -> h includes, but that arose some unexposed symbols from material_point_generator_utility which I also exposed (both missing function and instances for templated that were not exposed in the source)

Hope it compiles now!

@ncrescenzio
Copy link
Contributor Author

ahh i copied and pasted the last line in the "#include" section and didn’t noticed the extension was wrong… sorry to have bothered you, thanks a lot!!! @roigcarlo

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.

2 participants