-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GeoMechanicsApplication] Re-enable settlement test using the C++ route #12877
Conversation
The test setup creates a clean test directory that contains copies of the Kratos input files.
The new names now clearly indicate that the test covers the Python route.
C++ classes `CustomWorkflowFactory` and `KratosGeoSettlement` are now accessible from Python code.
This new class is intended to be used by the test case for the Python route as well as the one for the C++ route. It will keep common functionality.
One attribute keeps the number of stages to be analyzed, the other the names of the project parameters files.
- Make sure that the heap-allocated settlement API object is properly freed when the test has finished. - Make sure that the GeoMechanicsApplication has been imported prior to running the Python route of the settlement analysis. - The C++ route needs to be tested more thoroughly.
These are currently only being used by the test case for the Python route.
This method is now also used by the test case for the C++ route.
…-cpp-settlement-test
@@ -15,6 +15,7 @@ | |||
#define KRATOS_ADD_UTILITIES_TO_PYTHON_H_INCLUDED | |||
|
|||
// System includes | |||
#include <pybind11/functional.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For those interested, this include is needed such that python (lambda) functions can be converted to C++ ones (since we pass functions to the exported RunStage function)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice we finally have the C++ test running in our pipelines, thanks for getting this done (even though there were quite specific issues on the way). I really like the table-based way of comparing the results! I don't have any blocking comments, just a few questions/minor suggestions
applications/GeoMechanicsApplication/tests/settlement_workflow.py
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/tests/settlement_workflow.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Anne, thank you for the clear and well understandable code. I am still new, so I consulted Copilot. ;) Its conclusion is 'Overall, the code appears to be safe and follows good practices for unit testing in Python.'
applications/GeoMechanicsApplication/tests/settlement_workflow.py
Outdated
Show resolved
Hide resolved
applications/GeoMechanicsApplication/tests/settlement_workflow.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dear Anne,
I don't have comments here that others haven't already raised ( or not even those ). It remains scary to me that a single test changes its environment and has to restore the environment. However that is in a place we do not directly control and you have documented what and why.
Nothing further, I'm happy that now this test will be executed regularly.
Wijtze Pieter
- Renamed a function object. - Clarified a comment. - Removed an unnecessary slicing operation - Used a better way to remove the previous test directory when the test is set up
Thank you for the review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for processing the changes, it's good to go!
📝 Description
Converted a disabled C++ unit test to a Python test. It shouldn't be a C++ unit test, since it tests a complete workflow, not just a single component. The new Python test covers the so-called "C++ route" of the settlement workflow. In other words, it uses the exact same entry point into the code as D-GeoSettlement does.
Since the
KratosGeoSettlement
class owns a localKratosGeoMechanicsApplication
instance, running this new test will deregister all GeoMechanicsApplication components (e.g. geo elements) when that object is destroyed. To avoid that any subsequent tests start failing, we need to reload the relevant Kratos applications at the end of the new test (in itstearDown
method).With these changes, there are now two Python tests that simulate the same problem (a settlement problem), but using different entry points in our code (i.e. the "C++ route" and the "Python route"). Both ways should yield the same results. That is asserted by these tests.