Skip to content

Commit

Permalink
Merge pull request #12562 from KratosMultiphysics/mpm/renaming-analys…
Browse files Browse the repository at this point in the history
…is-stage

[MPM] Change `MPMAnalysis` in `MpmAnalysis`
  • Loading branch information
ncrescenzio authored Jul 31, 2024
2 parents d359294 + ce3248d commit fcfc8a3
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"')
Expand Down
6 changes: 3 additions & 3 deletions applications/MPMApplication/python_scripts/kratos_main_mpm.py
Original file line number Diff line number Diff line change
@@ -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__":
Expand All @@ -13,5 +13,5 @@
parameters = KratosMultiphysics.Parameters(parameter_file.read())

model = KratosMultiphysics.Model()
simulation = MPMAnalysis(model,parameters)
simulation = MpmAnalysis(model,parameters)
simulation.Run()
25 changes: 17 additions & 8 deletions applications/MPMApplication/python_scripts/mpm_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

# Import utilities
import itertools
from KratosMultiphysics.kratos_utilities import IssueDeprecationWarning


class MPMAnalysis(AnalysisStage):
class MpmAnalysis(AnalysisStage):
"""
This class is the main-script of the MPMApplication put in a class
"""
Expand All @@ -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):
Expand Down Expand Up @@ -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"]
Expand All @@ -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:
Expand All @@ -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,]
Expand Down Expand Up @@ -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

Expand All @@ -143,5 +152,5 @@ def _GetSimulationName(self):
parameters = KratosMultiphysics.Parameters(parameter_file.read())

model = KratosMultiphysics.Model()
simulation = MPMAnalysis(model, parameters)
simulation = MpmAnalysis(model, parameters)
simulation.Run()
Original file line number Diff line number Diff line change
@@ -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__":
Expand Down

0 comments on commit fcfc8a3

Please sign in to comment.