-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12011 from KratosMultiphysics/mpm/change-applicat…
…ion-name [MPM] Change application name
- Loading branch information
Showing
436 changed files
with
2,364 additions
and
2,198 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...ns/CoSimulationApplication/python_scripts/solver_wrappers/kratos/mpm_dirichlet_wrapper.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Importing the Kratos Library | ||
import KratosMultiphysics as KM | ||
from KratosMultiphysics.kratos_utilities import CheckIfApplicationsAvailable | ||
|
||
# Importing the base class | ||
from KratosMultiphysics.CoSimulationApplication.solver_wrappers.kratos import kratos_base_wrapper | ||
|
||
# Importing MPM | ||
if not CheckIfApplicationsAvailable("MPMApplication"): | ||
raise ImportError("The MPMApplication is not available!") | ||
import KratosMultiphysics.MPMApplication as KPM | ||
from KratosMultiphysics.MPMApplication.mpm_analysis import MPMAnalysis | ||
|
||
# Other imports | ||
import math | ||
|
||
def Create(settings, model, solver_name): | ||
return MPMDirichletWrapper(settings, model, solver_name) | ||
|
||
class MPMDirichletWrapper(kratos_base_wrapper.KratosBaseWrapper): | ||
"""This class is the interface to the MPMApplication of Kratos.""" | ||
"""It is designed for the Dirichlet Interface in the MPMApplication""" | ||
|
||
def _CreateAnalysisStage(self): | ||
return MPMAnalysis(self.model, self.project_parameters) | ||
|
||
def SolveSolutionStep(self): | ||
coupling_model_part = self.model.GetModelPart("MPM_Coupling_Dirichlet_Interface") | ||
model_part_name = self.settings["solver_wrapper_settings"]["interface_model_part_name"].GetString() | ||
model_part = self.model.GetModelPart(model_part_name) | ||
|
||
## Transfer information from coupling_mp to mp | ||
for coupling_node in coupling_model_part.Nodes: | ||
coupling_id = coupling_node.Id | ||
|
||
## IMPOSED DISPLACEMENT | ||
total_displacement = coupling_node.GetSolutionStepValue(KM.DISPLACEMENT,0) | ||
old_displacement = model_part.GetCondition(coupling_id).CalculateOnIntegrationPoints(KPM.MPC_DISPLACEMENT, model_part.ProcessInfo)[0] | ||
incremental_displacement = total_displacement - old_displacement | ||
model_part.GetCondition(coupling_id).SetValuesOnIntegrationPoints(KPM.MPC_IMPOSED_DISPLACEMENT, [incremental_displacement], model_part.ProcessInfo) | ||
|
||
## ADD VELOCITY | ||
current_velocity = coupling_node.GetSolutionStepValue(KM.VELOCITY,0) | ||
model_part.GetCondition(coupling_id).SetValuesOnIntegrationPoints(KPM.MPC_VELOCITY, [current_velocity], model_part.ProcessInfo) | ||
|
||
## ADD NORMAL | ||
normal = coupling_node.GetSolutionStepValue(KM.NORMAL,0) | ||
# Check and see whether the normal is not zero | ||
norm_normal = math.sqrt(normal[0]*normal[0] + normal[1]*normal[1] + normal[2]*normal[2]) | ||
if norm_normal > 1.e-10: | ||
model_part.GetCondition(coupling_id).SetValuesOnIntegrationPoints(KPM.MPC_NORMAL, [normal], model_part.ProcessInfo) | ||
|
||
super().SolveSolutionStep() | ||
|
||
### Get contact force from mp to coupling_mp | ||
for mpc in model_part.Conditions: | ||
if (mpc.Is(KM.INTERFACE)): | ||
coupling_id = mpc.Id | ||
contact_force = mpc.CalculateOnIntegrationPoints(KPM.MPC_CONTACT_FORCE, model_part.ProcessInfo)[0] | ||
coupling_model_part.GetNode(coupling_id).SetSolutionStepValue(KM.CONTACT_FORCE,0,contact_force) |
52 changes: 52 additions & 0 deletions
52
...ions/CoSimulationApplication/python_scripts/solver_wrappers/kratos/mpm_neumann_wrapper.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Importing the Kratos Library | ||
import KratosMultiphysics as KM | ||
from KratosMultiphysics.kratos_utilities import CheckIfApplicationsAvailable | ||
|
||
# Importing the base class | ||
from KratosMultiphysics.CoSimulationApplication.solver_wrappers.kratos import kratos_base_wrapper | ||
|
||
# Importing MPM | ||
if not CheckIfApplicationsAvailable("MPMApplication"): | ||
raise ImportError("The MPMApplication is not available!") | ||
import KratosMultiphysics.MPMApplication as KPM | ||
from KratosMultiphysics.MPMApplication.mpm_analysis import MPMAnalysis | ||
|
||
def Create(settings, model, solver_name): | ||
return MPMNeumannWrapper(settings, model, solver_name) | ||
|
||
class MPMNeumannWrapper(kratos_base_wrapper.KratosBaseWrapper): | ||
"""This class is the interface to the MPMApplication of Kratos""" | ||
"""It is designed for the Neumann Interface in the MPMApplication""" | ||
|
||
def _CreateAnalysisStage(self): | ||
return MPMAnalysis(self.model, self.project_parameters) | ||
|
||
def SolveSolutionStep(self): | ||
coupling_model_part = self.model.GetModelPart("MPM_Coupling_Neumann_Interface") | ||
model_part_name = self.settings["solver_wrapper_settings"]["interface_model_part_name"].GetString() | ||
model_part = self.model.GetModelPart(model_part_name) | ||
|
||
## Transfer information from coupling_mp to mp | ||
for coupling_node in coupling_model_part.Nodes: | ||
coupling_id = coupling_node.Id | ||
|
||
## IMPOSED Point load | ||
point_load = coupling_node.GetSolutionStepValue(KM.CONTACT_FORCE) | ||
model_part.GetCondition(coupling_id).SetValuesOnIntegrationPoints(KPM.POINT_LOAD, [point_load], model_part.ProcessInfo) | ||
|
||
super().SolveSolutionStep() | ||
|
||
### Save displacement of mpc in coupling node | ||
for mpc in model_part.Conditions: | ||
if (mpc.Is(KM.INTERFACE)): | ||
coupling_id = mpc.Id | ||
|
||
# Update displacement | ||
delta_x = mpc.CalculateOnIntegrationPoints(KPM.MPC_DELTA_DISPLACEMENT, model_part.ProcessInfo)[0] | ||
displacement = coupling_model_part.GetNode(coupling_id).GetSolutionStepValue(KM.DISPLACEMENT) | ||
displacement += delta_x | ||
coupling_model_part.GetNode(coupling_id).SetSolutionStepValue(KM.DISPLACEMENT,0,displacement) | ||
|
||
# Update velocity | ||
velocity = mpc.CalculateOnIntegrationPoints(KPM.MPC_VELOCITY, model_part.ProcessInfo)[0] | ||
coupling_model_part.GetNode(coupling_id).SetSolutionStepValue(KM.VELOCITY,0,velocity) |
65 changes: 10 additions & 55 deletions
65
...Application/python_scripts/solver_wrappers/kratos/particle_mechanics_dirichlet_wrapper.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,15 @@ | ||
# Importing the Kratos Library | ||
import KratosMultiphysics as KM | ||
import KratosMultiphysics | ||
from KratosMultiphysics.kratos_utilities import CheckIfApplicationsAvailable | ||
from KratosMultiphysics.kratos_utilities import IssueDeprecationWarning | ||
|
||
# Importing the base class | ||
from KratosMultiphysics.CoSimulationApplication.solver_wrappers.kratos import kratos_base_wrapper | ||
from KratosMultiphysics.CoSimulationApplication.solver_wrappers.kratos.mpm_dirichlet_wrapper import MPMDirichletWrapper | ||
|
||
# Importing ParticleMechanics | ||
if not CheckIfApplicationsAvailable("ParticleMechanicsApplication"): | ||
raise ImportError("The ParticleMechanicsApplication is not available!") | ||
import KratosMultiphysics.ParticleMechanicsApplication as KPM | ||
from KratosMultiphysics.ParticleMechanicsApplication.particle_mechanics_analysis import ParticleMechanicsAnalysis | ||
|
||
# Other imports | ||
import math | ||
# Importing MPM | ||
if not CheckIfApplicationsAvailable("MPMApplication"): | ||
raise ImportError("The MPMApplication is not available!") | ||
import KratosMultiphysics.MPMApplication as KPM | ||
from KratosMultiphysics.MPMApplication.mpm_analysis import MPMAnalysis | ||
|
||
def Create(settings, model, solver_name): | ||
return ParticleMechanicsDirichletWrapper(settings, model, solver_name) | ||
|
||
class ParticleMechanicsDirichletWrapper(kratos_base_wrapper.KratosBaseWrapper): | ||
"""This class is the interface to the ParticleMechanicsApplication of Kratos.""" | ||
"""It is designed for the Dirichlet Interface in the ParticleMechanicsApplication""" | ||
|
||
def _CreateAnalysisStage(self): | ||
return ParticleMechanicsAnalysis(self.model, self.project_parameters) | ||
|
||
def SolveSolutionStep(self): | ||
coupling_model_part = self.model.GetModelPart("MPM_Coupling_Dirichlet_Interface") | ||
model_part_name = self.settings["solver_wrapper_settings"]["interface_model_part_name"].GetString() | ||
model_part = self.model.GetModelPart(model_part_name) | ||
|
||
## Transfer information from coupling_mp to mp | ||
for coupling_node in coupling_model_part.Nodes: | ||
coupling_id = coupling_node.Id | ||
|
||
## IMPOSED DISPLACEMENT | ||
total_displacement = coupling_node.GetSolutionStepValue(KM.DISPLACEMENT,0) | ||
old_displacement = model_part.GetCondition(coupling_id).CalculateOnIntegrationPoints(KPM.MPC_DISPLACEMENT, model_part.ProcessInfo)[0] | ||
incremental_displacement = total_displacement - old_displacement | ||
model_part.GetCondition(coupling_id).SetValuesOnIntegrationPoints(KPM.MPC_IMPOSED_DISPLACEMENT, [incremental_displacement], model_part.ProcessInfo) | ||
|
||
## ADD VELOCITY | ||
current_velocity = coupling_node.GetSolutionStepValue(KM.VELOCITY,0) | ||
model_part.GetCondition(coupling_id).SetValuesOnIntegrationPoints(KPM.MPC_VELOCITY, [current_velocity], model_part.ProcessInfo) | ||
|
||
## ADD NORMAL | ||
normal = coupling_node.GetSolutionStepValue(KM.NORMAL,0) | ||
# Check and see whether the normal is not zero | ||
norm_normal = math.sqrt(normal[0]*normal[0] + normal[1]*normal[1] + normal[2]*normal[2]) | ||
if norm_normal > 1.e-10: | ||
model_part.GetCondition(coupling_id).SetValuesOnIntegrationPoints(KPM.MPC_NORMAL, [normal], model_part.ProcessInfo) | ||
|
||
super().SolveSolutionStep() | ||
|
||
### Get contact force from mp to coupling_mp | ||
for mpc in model_part.Conditions: | ||
if (mpc.Is(KM.INTERFACE)): | ||
coupling_id = mpc.Id | ||
contact_force = mpc.CalculateOnIntegrationPoints(KPM.MPC_CONTACT_FORCE, model_part.ProcessInfo)[0] | ||
coupling_model_part.GetNode(coupling_id).SetSolutionStepValue(KM.CONTACT_FORCE,0,contact_force) | ||
IssueDeprecationWarning('CoSimulationApplication:','"ParticleMechanicsDirichletWrapper" is deprecated and replaced by "MPMDirichletWrapper"') | ||
return MPMDirichletWrapper(settings, model, solver_name) |
57 changes: 10 additions & 47 deletions
57
...onApplication/python_scripts/solver_wrappers/kratos/particle_mechanics_neumann_wrapper.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,15 @@ | ||
# Importing the Kratos Library | ||
import KratosMultiphysics as KM | ||
import KratosMultiphysics | ||
from KratosMultiphysics.kratos_utilities import CheckIfApplicationsAvailable | ||
from KratosMultiphysics.kratos_utilities import IssueDeprecationWarning | ||
|
||
# Importing the base class | ||
from KratosMultiphysics.CoSimulationApplication.solver_wrappers.kratos import kratos_base_wrapper | ||
from KratosMultiphysics.CoSimulationApplication.solver_wrappers.kratos.mpm_neumann_wrapper import MPMNeumannWrapper | ||
|
||
# Importing ParticleMechanics | ||
if not CheckIfApplicationsAvailable("ParticleMechanicsApplication"): | ||
raise ImportError("The ParticleMechanicsApplication is not available!") | ||
import KratosMultiphysics.ParticleMechanicsApplication as KPM | ||
from KratosMultiphysics.ParticleMechanicsApplication.particle_mechanics_analysis import ParticleMechanicsAnalysis | ||
# Importing MPM | ||
if not CheckIfApplicationsAvailable("MPMApplication"): | ||
raise ImportError("The MPMApplication is not available!") | ||
import KratosMultiphysics.MPMApplication as KPM | ||
from KratosMultiphysics.MPMApplication.mpm_analysis import MPMAnalysis | ||
|
||
def Create(settings, model, solver_name): | ||
return ParticleMechanicsNeumannWrapper(settings, model, solver_name) | ||
|
||
class ParticleMechanicsNeumannWrapper(kratos_base_wrapper.KratosBaseWrapper): | ||
"""This class is the interface to the ParticleMechanicsApplication of Kratos""" | ||
"""It is designed for the Neumann Interface in the ParticleMechanicsApplication""" | ||
|
||
def _CreateAnalysisStage(self): | ||
return ParticleMechanicsAnalysis(self.model, self.project_parameters) | ||
|
||
def SolveSolutionStep(self): | ||
coupling_model_part = self.model.GetModelPart("MPM_Coupling_Neumann_Interface") | ||
model_part_name = self.settings["solver_wrapper_settings"]["interface_model_part_name"].GetString() | ||
model_part = self.model.GetModelPart(model_part_name) | ||
|
||
## Transfer information from coupling_mp to mp | ||
for coupling_node in coupling_model_part.Nodes: | ||
coupling_id = coupling_node.Id | ||
|
||
## IMPOSED Point load | ||
point_load = coupling_node.GetSolutionStepValue(KM.CONTACT_FORCE) | ||
model_part.GetCondition(coupling_id).SetValuesOnIntegrationPoints(KPM.POINT_LOAD, [point_load], model_part.ProcessInfo) | ||
|
||
super().SolveSolutionStep() | ||
|
||
### Save displacement of mpc in coupling node | ||
for mpc in model_part.Conditions: | ||
if (mpc.Is(KM.INTERFACE)): | ||
coupling_id = mpc.Id | ||
|
||
# Update displacement | ||
delta_x = mpc.CalculateOnIntegrationPoints(KPM.MPC_DELTA_DISPLACEMENT, model_part.ProcessInfo)[0] | ||
displacement = coupling_model_part.GetNode(coupling_id).GetSolutionStepValue(KM.DISPLACEMENT) | ||
displacement += delta_x | ||
coupling_model_part.GetNode(coupling_id).SetSolutionStepValue(KM.DISPLACEMENT,0,displacement) | ||
|
||
# Update velocity | ||
velocity = mpc.CalculateOnIntegrationPoints(KPM.MPC_VELOCITY, model_part.ProcessInfo)[0] | ||
coupling_model_part.GetNode(coupling_id).SetSolutionStepValue(KM.VELOCITY,0,velocity) | ||
IssueDeprecationWarning('CoSimulationApplication:','"ParticleMechanicsNeumannWrapper" is deprecated and replaced by "MPMNeumannWrapper"') | ||
return MPMNeumannWrapper(settings, model, solver_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
applications/CoSimulationApplication/tests/mpm_dem/cosim_mpm_dem_results.json
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.