Skip to content
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] Convert two stage line loads test to the orchestrator based analysis and test #13057

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

markelov208
Copy link
Contributor

@markelov208 markelov208 commented Jan 29, 2025

📝 Description
A brief description of the PR.

  • two stage test_line_loads is converted to be used with orchestrator.

Copy link
Contributor

@avdg81 avdg81 left a comment

Choose a reason for hiding this comment

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

Thank you so much for investigating how to convert the original two-stage test to a test that uses the orchestrator. The result of your efforts show clearly what is needed to run multi-stage analysis with this novel approach. Well done!

I have a few suggestions that you may find helpful.

Comment on lines 27 to 29
"VAN_GENUCHTEN_AIR_ENTRY_PRESSURE" : 2.561,
"VAN_GENUCHTEN_GN" : 1.377,
"VAN_GENUCHTEN_GL" : 1.25,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpicking: I believe we don't need these input parameters, since we're not using the Van Genuchten retention law.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

"VAN_GENUCHTEN_GL" : 1.25,
"MINIMUM_RELATIVE_PERMEABILITY" : 0.0001
},
"Tables": {}
Copy link
Contributor

Choose a reason for hiding this comment

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

More nitpicking: I believe we can also get rid of this input parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

@@ -0,0 +1,80 @@
# Test line loads in staged analysis

**Author:** [Anne van de Graaf](https://github.com/avdg81)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please feel free to replace my name with yours. Or, if you feel that is too much, add your name next to mine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added my name because the main part is yours.

Comment on lines 70 to 72
if not Kratos.Registry.HasItem("Stages.KratosMultiphysics.GeoMechanicsApplication.geomechanics_analysis.GeoMechanicsAnalysis"):
Kratos.Registry.AddItem("Stages.KratosMultiphysics.GeoMechanicsApplication.geomechanics_analysis.GeoMechanicsAnalysis.ClassName", "GeoMechanicsAnalysis")
Kratos.Registry.AddItem("Stages.KratosMultiphysics.GeoMechanicsApplication.geomechanics_analysis.GeoMechanicsAnalysis.ModuleName", "KratosMultiphysics.GeoMechanicsApplication.geomechanics_analysis")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering whether these lines should be at test level, or that we should incorporate them elsewhere in the GeoMechanicsApplication code (although I'm not sure exactly where).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed following your suggestion below.

Copy link
Contributor

Choose a reason for hiding this comment

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

This file is a copy of line_loads_in_stages/MaterialParameters.json. Also the file test.mdpa is a copy of the corresponding file in line_loads_in_stages/test.mdpa. I'm wondering whether it would be possible to share these files (i.e. to avoid having any copies)? Perhaps we could have a common subdirectory in line_loads_in_stages, where we move these two files to. And then we could have two more subdirectories in line_loads_in_stages: e.g. legacy and orchestrator. Those two subdirectories then contain the required ProjectParameters.json files. Such a structure also makes it clearer that for the orchestrator-based multi-stage analysis, we can keep the .mdpa and MaterialParameters.json files as-is (compared to the "legacy" approach).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. The structure is done like that

Comment on lines 10 to 12
if not Kratos.Registry.HasItem("Stages.KratosMultiphysics.GeoMechanicsApplication.geomechanics_analysis.GeoMechanicsAnalysis"):
Kratos.Registry.AddItem("Stages.KratosMultiphysics.GeoMechanicsApplication.geomechanics_analysis.GeoMechanicsAnalysis.ClassName", "GeoMechanicsAnalysis")
Kratos.Registry.AddItem("Stages.KratosMultiphysics.GeoMechanicsApplication.geomechanics_analysis.GeoMechanicsAnalysis.ModuleName", "KratosMultiphysics.GeoMechanicsApplication.geomechanics_analysis")
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest to put these lines elsewhere, to avoid that we need to include them in each and every test file. Following along the lines as described in docs/pages/Kratos/For_Developers/General/Registry.md, I have added the following lines to applications/GeoMechanicsApplication/python_scripts/geomechanics_analysis.py (just before the line containing if __name__ == '__main__':):

# For orchestrator-based multi-stage analyses, we need to register our own analysis stage class
Kratos.Registry.AddItem("Stages.KratosMultiphysics.GeoMechanicsApplication.geomechanics_analysis.GeoMechanicsAnalysis.ClassName", "GeoMechanicsAnalysis")
Kratos.Registry.AddItem("Stages.KratosMultiphysics.GeoMechanicsApplication.geomechanics_analysis.GeoMechanicsAnalysis.ModuleName", "KratosMultiphysics.GeoMechanicsApplication.geomechanics_analysis")

Subsequently, I removed the above lines from the test script, rebuilt the Kratos project, and reran the test and it all worked. In this way, we can keep our test scripts cleaner and we don't need to request our end-users to add these lines to their own scripts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the suggestion and checking. Done.

Comment on lines +145 to +149
orchestrator_reg_entry = Kratos.Registry[project.GetSettings()["orchestrator"]["name"].GetString()]
orchestrator_module = importlib.import_module(orchestrator_reg_entry["ModuleName"])
orchestrator_class = getattr(orchestrator_module, orchestrator_reg_entry["ClassName"])
orchestrator_instance = orchestrator_class(project)
orchestrator_instance.Run()
Copy link
Contributor

Choose a reason for hiding this comment

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

We will probably need these lines for any future tests with the orchestrator, too. I can imagine that by then we wrap them in a helper function, which we'll put in test_helper.py. Not for now, but something to keep in mind.

Perhaps the same applies to lines 136 to 142, which essentially creates a Project instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed

@markelov208
Copy link
Contributor Author

Hi @rubenzorrilla , here is our first case with the orchestrator. Please could you have a brief look at it? Perhaps, you may suggest some improvements. Thank you.

@markelov208 markelov208 requested a review from avdg81 January 30, 2025 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants