From 3355cd5bb703bd105d71e48dc12a4ba8969f44be Mon Sep 17 00:00:00 2001 From: ncrescenzio Date: Fri, 19 Jul 2024 12:40:23 +0200 Subject: [PATCH 1/3] Change `MPMAnalysis` in `MpmAnalysis` --- .../python_scripts/kratos_main_mpm.py | 6 +++--- .../MPMApplication/python_scripts/mpm_analysis.py | 14 +++++++------- .../python_scripts/particle_mechanics_analysis.py | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/applications/MPMApplication/python_scripts/kratos_main_mpm.py b/applications/MPMApplication/python_scripts/kratos_main_mpm.py index 0796c331bdbb..80af62ef5dfa 100755 --- a/applications/MPMApplication/python_scripts/kratos_main_mpm.py +++ b/applications/MPMApplication/python_scripts/kratos_main_mpm.py @@ -1,10 +1,10 @@ import KratosMultiphysics -from KratosMultiphysics.MPMApplication.mpm_analysis import MPMAnalysis +from KratosMultiphysics.MPMApplication.mpm_analysis import MpmAnalysis """ For user-scripting it is intended that a new class is derived -from MPMAnalysis to do modifications +from MpmAnalysis to do modifications """ if __name__ == "__main__": @@ -13,5 +13,5 @@ parameters = KratosMultiphysics.Parameters(parameter_file.read()) model = KratosMultiphysics.Model() - simulation = MPMAnalysis(model,parameters) + simulation = MpmAnalysis(model,parameters) simulation.Run() diff --git a/applications/MPMApplication/python_scripts/mpm_analysis.py b/applications/MPMApplication/python_scripts/mpm_analysis.py index 0d7aed95a340..b964a3ca2d22 100644 --- a/applications/MPMApplication/python_scripts/mpm_analysis.py +++ b/applications/MPMApplication/python_scripts/mpm_analysis.py @@ -10,7 +10,7 @@ import itertools -class MPMAnalysis(AnalysisStage): +class MpmAnalysis(AnalysisStage): """ This class is the main-script of the MPMApplication put in a class """ @@ -25,14 +25,14 @@ def __init__(self, model, project_parameters): # TODO: the following import lines will be kept here for future reference if (project_parameters["problem_data"]["parallel_type"].GetString() == "MPI"): warn_msg = 'Currently MPI parallelization is not present in MPMApplication!' - KratosMultiphysics.Logger.PrintWarning("MPMAnalysis", warn_msg) + KratosMultiphysics.Logger.PrintWarning("MpmAnalysis", warn_msg) # import KratosMultiphysics.MetisApplication as MetisApplication # import KratosMultiphysics.TrilinosApplication as TrilinosApplication # add auxiliary variables required by friction automatically to the project_parameters self._AddFrictionAuxiliaryVariables(project_parameters) - super(MPMAnalysis, self).__init__(model, project_parameters) + super(MpmAnalysis, self).__init__(model, project_parameters) #### Internal functions #### def _AddFrictionAuxiliaryVariables(self, project_parameters): @@ -67,7 +67,7 @@ def _CreateSolver(self): def _CreateProcesses(self, parameter_name, initialization_order): """Create a list of Processes""" - list_of_processes = super(MPMAnalysis, self)._CreateProcesses(parameter_name, initialization_order) + list_of_processes = super(MpmAnalysis, self)._CreateProcesses(parameter_name, initialization_order) if parameter_name == "processes": processes_block_names = ["constraints_process_list", "loads_process_list", "list_other_processes", "gravity"] @@ -76,7 +76,7 @@ def _CreateProcesses(self, parameter_name, initialization_order): info_msg += "Refer to \"https://github.com/KratosMultiphysics/Kratos/wiki/Common-" info_msg += "Python-Interface-of-Applications-for-Users#analysisstage-usage\" " info_msg += "for a description of the new format" - KratosMultiphysics.Logger.PrintWarning("MPMAnalysis", info_msg) + KratosMultiphysics.Logger.PrintWarning("MpmAnalysis", info_msg) from KratosMultiphysics.process_factory import KratosProcessFactory factory = KratosProcessFactory(self.model) for process_name in processes_block_names: @@ -92,7 +92,7 @@ def _CreateProcesses(self, parameter_name, initialization_order): info_msg += "Refer to \"https://github.com/KratosMultiphysics/Kratos/wiki/Common-" info_msg += "Python-Interface-of-Applications-for-Users#analysisstage-usage\" " info_msg += "for a description of the new format" - KratosMultiphysics.Logger.PrintInfo("MPMAnalysis", info_msg) + KratosMultiphysics.Logger.PrintInfo("MpmAnalysis", info_msg) if self.project_parameters.Has("grid_output_configuration"): grid_gid_output= self._SetUpGiDOutput("grid_output") list_of_processes += [grid_gid_output,] @@ -143,5 +143,5 @@ def _GetSimulationName(self): parameters = KratosMultiphysics.Parameters(parameter_file.read()) model = KratosMultiphysics.Model() - simulation = MPMAnalysis(model, parameters) + simulation = MpmAnalysis(model, parameters) simulation.Run() diff --git a/applications/MPMApplication/python_scripts/particle_mechanics_analysis.py b/applications/MPMApplication/python_scripts/particle_mechanics_analysis.py index ded1ef6f88af..3d7b3f97b3f1 100644 --- a/applications/MPMApplication/python_scripts/particle_mechanics_analysis.py +++ b/applications/MPMApplication/python_scripts/particle_mechanics_analysis.py @@ -1,11 +1,11 @@ import KratosMultiphysics from KratosMultiphysics.kratos_utilities import IssueDeprecationWarning -from KratosMultiphysics.MPMApplication.mpm_analysis import MPMAnalysis +from KratosMultiphysics.MPMApplication.mpm_analysis import MpmAnalysis -class ParticleMechanicsAnalysis(MPMAnalysis): +class ParticleMechanicsAnalysis(MpmAnalysis): def __init__(self, model, project_parameters): - IssueDeprecationWarning("MPMApplication:","`ParticleMechanicsAnalysis` is deprecated and replaced with `MPMAnalysis`") + IssueDeprecationWarning("MPMApplication:","`ParticleMechanicsAnalysis` is deprecated and replaced with `MpmAnalysis`") super().__init__(model, project_parameters) if __name__ == "__main__": From 7036149cc965faed8a146ce34dd322b836d350d4 Mon Sep 17 00:00:00 2001 From: ncrescenzio Date: Fri, 19 Jul 2024 16:26:21 +0200 Subject: [PATCH 2/3] Change `MPMAnalysis` in `MpmAnalysis` in `CoSimulationApplication` --- .../solver_wrappers/kratos/mpm_dirichlet_wrapper.py | 4 ++-- .../solver_wrappers/kratos/mpm_neumann_wrapper.py | 4 ++-- .../kratos/particle_mechanics_dirichlet_wrapper.py | 2 +- .../kratos/particle_mechanics_neumann_wrapper.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/mpm_dirichlet_wrapper.py b/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/mpm_dirichlet_wrapper.py index ca81d418a222..a51e3be4238e 100644 --- a/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/mpm_dirichlet_wrapper.py +++ b/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/mpm_dirichlet_wrapper.py @@ -9,7 +9,7 @@ if not CheckIfApplicationsAvailable("MPMApplication"): raise ImportError("The MPMApplication is not available!") import KratosMultiphysics.MPMApplication as KPM -from KratosMultiphysics.MPMApplication.mpm_analysis import MPMAnalysis +from KratosMultiphysics.MPMApplication.mpm_analysis import MpmAnalysis # Other imports import math @@ -22,7 +22,7 @@ class MPMDirichletWrapper(kratos_base_wrapper.KratosBaseWrapper): """It is designed for the Dirichlet Interface in the MPMApplication""" def _CreateAnalysisStage(self): - return MPMAnalysis(self.model, self.project_parameters) + return MpmAnalysis(self.model, self.project_parameters) def SolveSolutionStep(self): coupling_model_part = self.model.GetModelPart("MPM_Coupling_Dirichlet_Interface") diff --git a/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/mpm_neumann_wrapper.py b/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/mpm_neumann_wrapper.py index 36d8f97b56b0..cb353ce5a1f9 100644 --- a/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/mpm_neumann_wrapper.py +++ b/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/mpm_neumann_wrapper.py @@ -9,7 +9,7 @@ if not CheckIfApplicationsAvailable("MPMApplication"): raise ImportError("The MPMApplication is not available!") import KratosMultiphysics.MPMApplication as KPM -from KratosMultiphysics.MPMApplication.mpm_analysis import MPMAnalysis +from KratosMultiphysics.MPMApplication.mpm_analysis import MpmAnalysis def Create(settings, model, solver_name): return MPMNeumannWrapper(settings, model, solver_name) @@ -19,7 +19,7 @@ class MPMNeumannWrapper(kratos_base_wrapper.KratosBaseWrapper): """It is designed for the Neumann Interface in the MPMApplication""" def _CreateAnalysisStage(self): - return MPMAnalysis(self.model, self.project_parameters) + return MpmAnalysis(self.model, self.project_parameters) def SolveSolutionStep(self): coupling_model_part = self.model.GetModelPart("MPM_Coupling_Neumann_Interface") diff --git a/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/particle_mechanics_dirichlet_wrapper.py b/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/particle_mechanics_dirichlet_wrapper.py index e1e521de104d..842b1f709cda 100644 --- a/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/particle_mechanics_dirichlet_wrapper.py +++ b/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/particle_mechanics_dirichlet_wrapper.py @@ -8,7 +8,7 @@ if not CheckIfApplicationsAvailable("MPMApplication"): raise ImportError("The MPMApplication is not available!") import KratosMultiphysics.MPMApplication as KPM -from KratosMultiphysics.MPMApplication.mpm_analysis import MPMAnalysis +from KratosMultiphysics.MPMApplication.mpm_analysis import MpmAnalysis def Create(settings, model, solver_name): IssueDeprecationWarning('CoSimulationApplication:','"ParticleMechanicsDirichletWrapper" is deprecated and replaced by "MPMDirichletWrapper"') diff --git a/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/particle_mechanics_neumann_wrapper.py b/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/particle_mechanics_neumann_wrapper.py index 4484dd2bfc91..3bd40beeec79 100644 --- a/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/particle_mechanics_neumann_wrapper.py +++ b/applications/CoSimulationApplication/python_scripts/solver_wrappers/kratos/particle_mechanics_neumann_wrapper.py @@ -8,7 +8,7 @@ if not CheckIfApplicationsAvailable("MPMApplication"): raise ImportError("The MPMApplication is not available!") import KratosMultiphysics.MPMApplication as KPM -from KratosMultiphysics.MPMApplication.mpm_analysis import MPMAnalysis +from KratosMultiphysics.MPMApplication.mpm_analysis import MpmAnalysis def Create(settings, model, solver_name): IssueDeprecationWarning('CoSimulationApplication:','"ParticleMechanicsNeumannWrapper" is deprecated and replaced by "MPMNeumannWrapper"') From ce3248d7086ddd8c825a3b370799a623d9a517c8 Mon Sep 17 00:00:00 2001 From: ncrescenzio Date: Mon, 22 Jul 2024 09:00:32 +0200 Subject: [PATCH 3/3] Warning when using `MPMAnalysis` --- .../MPMApplication/python_scripts/mpm_analysis.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/applications/MPMApplication/python_scripts/mpm_analysis.py b/applications/MPMApplication/python_scripts/mpm_analysis.py index b964a3ca2d22..5ce9800c7f1c 100644 --- a/applications/MPMApplication/python_scripts/mpm_analysis.py +++ b/applications/MPMApplication/python_scripts/mpm_analysis.py @@ -8,7 +8,7 @@ # Import utilities import itertools - +from KratosMultiphysics.kratos_utilities import IssueDeprecationWarning class MpmAnalysis(AnalysisStage): """ @@ -122,6 +122,15 @@ def _SetUpGiDOutput(self, parameter_name): def _GetSimulationName(self): return "::[MPM Analysis]:: " + +class MPMAnalysis(MpmAnalysis): + def __init__(self, model, parameters): + wrng_msg = "Class `MPMAnalysis` is deprecated " + wrng_msg += "and replaced by `MpmAnalysis`" + IssueDeprecationWarning("MPMApplication:",wrng_msg) + super().__init__(model, parameters) + + if __name__ == "__main__": from sys import argv