From 12d55a8c9b797001fbcec9cb066c254060288274 Mon Sep 17 00:00:00 2001 From: Bodhinanda Chandra Date: Tue, 18 Dec 2018 15:33:50 +0100 Subject: [PATCH 1/6] updating cmakelists --- applications/ParticleMechanicsApplication/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/ParticleMechanicsApplication/CMakeLists.txt b/applications/ParticleMechanicsApplication/CMakeLists.txt index 6f28f9272192..df4467d968df 100644 --- a/applications/ParticleMechanicsApplication/CMakeLists.txt +++ b/applications/ParticleMechanicsApplication/CMakeLists.txt @@ -106,4 +106,4 @@ endif(${INSTALL_PYTHON_FILES} MATCHES ON) # message("TestApplication subdir inc_dirs = ${inc_dirs}") # Add to the KratosMultiphisics Python module -install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/ParticleMechanicsApplication.py" DESTINATION KratosMultiphysics ) +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/ParticleMechanicsApplication.py" DESTINATION "KratosMultiphysics/ParticleMechanicsApplication" RENAME "__init__.py") From 776d50d6ae2692d50f0d151169319575a7332f01 Mon Sep 17 00:00:00 2001 From: Bodhinanda Chandra Date: Tue, 18 Dec 2018 15:34:01 +0100 Subject: [PATCH 2/6] python init is added --- .../ParticleMechanicsApplication.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/ParticleMechanicsApplication/ParticleMechanicsApplication.py b/applications/ParticleMechanicsApplication/ParticleMechanicsApplication.py index f37571402e58..2ee9b34f0515 100644 --- a/applications/ParticleMechanicsApplication/ParticleMechanicsApplication.py +++ b/applications/ParticleMechanicsApplication/ParticleMechanicsApplication.py @@ -5,7 +5,7 @@ application_folder = "ParticleMechanicsApplication" # The following lines are common for all applications -from . import application_importer +from .. import application_importer import inspect caller = inspect.stack()[1] # Information about the file that imported this, to check for unexpected imports -application_importer.ImportApplication(application,application_name,application_folder,caller) +application_importer.ImportApplication(application,application_name,application_folder,caller,__path__) From 45ed1dd6ff55ccf691bebc3c80183d0ef71a6f77 Mon Sep 17 00:00:00 2001 From: Bodhinanda Chandra Date: Tue, 18 Dec 2018 15:34:45 +0100 Subject: [PATCH 3/6] minor --- .../python_scripts/apply_mpm_slip_boundary_process.py | 2 +- .../python_scripts/kratos_main_particle.py | 2 +- .../tests/particle_mechanics_test_factory.py | 2 +- .../tests/test_ParticleMechanicsApplication.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/applications/ParticleMechanicsApplication/python_scripts/apply_mpm_slip_boundary_process.py b/applications/ParticleMechanicsApplication/python_scripts/apply_mpm_slip_boundary_process.py index a34ddf950042..b34350f58f67 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/apply_mpm_slip_boundary_process.py +++ b/applications/ParticleMechanicsApplication/python_scripts/apply_mpm_slip_boundary_process.py @@ -1,5 +1,5 @@ import KratosMultiphysics -import KratosMultiphysics.ParticleMechanicsApplication +import KratosMultiphysics.ParticleMechanicsApplication as KratosParticle def Factory(settings, Model): if(not isinstance(settings, KratosMultiphysics.Parameters)): diff --git a/applications/ParticleMechanicsApplication/python_scripts/kratos_main_particle.py b/applications/ParticleMechanicsApplication/python_scripts/kratos_main_particle.py index e74341f5f798..b0cbe4460fb6 100755 --- a/applications/ParticleMechanicsApplication/python_scripts/kratos_main_particle.py +++ b/applications/ParticleMechanicsApplication/python_scripts/kratos_main_particle.py @@ -1,7 +1,7 @@ from __future__ import print_function, absolute_import, division #makes KratosMultiphysics backward compatible with python 2.6 and 2.7 import KratosMultiphysics -import KratosMultiphysics.ParticleMechanicsApplication +import KratosMultiphysics.ParticleMechanicsApplication as KratosParticle from particle_mechanics_analysis import ParticleMechanicsAnalysis """ diff --git a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py index ff26d24f54e6..8d9f288b04b6 100644 --- a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py +++ b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py @@ -2,7 +2,7 @@ # Importing the Kratos Library import KratosMultiphysics -import KratosMultiphysics.ParticleMechanicsApplication +import KratosMultiphysics.ParticleMechanicsApplication as KratosParticle # Import KratosUnittest import KratosMultiphysics.KratosUnittest as KratosUnittest diff --git a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py index ff64eacd27cd..f083648fc122 100644 --- a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py +++ b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py @@ -1,6 +1,6 @@ # import Kratos import KratosMultiphysics -import KratosMultiphysics.ParticleMechanicsApplication +import KratosMultiphysics.ParticleMechanicsApplication as KratosParticle import run_cpp_unit_tests # Import Kratos "wrapper" for unittests From 35499c1a6a516666be9f0d0e83766f3543864e21 Mon Sep 17 00:00:00 2001 From: Bodhinanda Chandra Date: Tue, 18 Dec 2018 17:50:56 +0100 Subject: [PATCH 4/6] as suggested --- .../python_scripts/apply_mpm_slip_boundary_process.py | 1 - .../python_scripts/kratos_main_particle.py | 3 +-- .../python_scripts/mpm_from_json_check_result_process.py | 3 --- .../python_scripts/mpm_json_output_process.py | 3 --- .../python_scripts/particle_mechanics_analysis.py | 1 - .../tests/particle_mechanics_test_factory.py | 1 - .../tests/test_ParticleMechanicsApplication.py | 1 - 7 files changed, 1 insertion(+), 12 deletions(-) diff --git a/applications/ParticleMechanicsApplication/python_scripts/apply_mpm_slip_boundary_process.py b/applications/ParticleMechanicsApplication/python_scripts/apply_mpm_slip_boundary_process.py index b34350f58f67..987e4d3ea207 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/apply_mpm_slip_boundary_process.py +++ b/applications/ParticleMechanicsApplication/python_scripts/apply_mpm_slip_boundary_process.py @@ -1,5 +1,4 @@ import KratosMultiphysics -import KratosMultiphysics.ParticleMechanicsApplication as KratosParticle def Factory(settings, Model): if(not isinstance(settings, KratosMultiphysics.Parameters)): diff --git a/applications/ParticleMechanicsApplication/python_scripts/kratos_main_particle.py b/applications/ParticleMechanicsApplication/python_scripts/kratos_main_particle.py index b0cbe4460fb6..0c4083b610a7 100755 --- a/applications/ParticleMechanicsApplication/python_scripts/kratos_main_particle.py +++ b/applications/ParticleMechanicsApplication/python_scripts/kratos_main_particle.py @@ -1,8 +1,7 @@ from __future__ import print_function, absolute_import, division #makes KratosMultiphysics backward compatible with python 2.6 and 2.7 import KratosMultiphysics -import KratosMultiphysics.ParticleMechanicsApplication as KratosParticle -from particle_mechanics_analysis import ParticleMechanicsAnalysis +import KratosMultiphysics.ParticleMechanicsApplication.particle_mechanics_analysis import ParticleMechanicsAnalysis """ For user-scripting it is intended that a new class is derived diff --git a/applications/ParticleMechanicsApplication/python_scripts/mpm_from_json_check_result_process.py b/applications/ParticleMechanicsApplication/python_scripts/mpm_from_json_check_result_process.py index 3e725ed1c947..f1a85608d965 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/mpm_from_json_check_result_process.py +++ b/applications/ParticleMechanicsApplication/python_scripts/mpm_from_json_check_result_process.py @@ -9,9 +9,6 @@ from from_json_check_result_process import FromJsonCheckResultProcess from KratosMultiphysics.KratosUnittest import isclose as t_isclose -# Import applications and dependencies -import KratosMultiphysics.ParticleMechanicsApplication as KratosParticle - # Import KratosUnittest import KratosMultiphysics.KratosUnittest as KratosUnittest diff --git a/applications/ParticleMechanicsApplication/python_scripts/mpm_json_output_process.py b/applications/ParticleMechanicsApplication/python_scripts/mpm_json_output_process.py index 264e54a03a01..fadafe72534d 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/mpm_json_output_process.py +++ b/applications/ParticleMechanicsApplication/python_scripts/mpm_json_output_process.py @@ -6,9 +6,6 @@ # Importing the base class from json_output_process import JsonOutputProcess -# Import applications and dependencies -import KratosMultiphysics.ParticleMechanicsApplication as KratosParticle - def Factory(settings, Model): if(type(settings) != KratosMultiphysics.Parameters): raise Exception("Expected input shall be a Parameters object, encapsulating a json string") diff --git a/applications/ParticleMechanicsApplication/python_scripts/particle_mechanics_analysis.py b/applications/ParticleMechanicsApplication/python_scripts/particle_mechanics_analysis.py index 0fb631cdb475..37d60ec48bed 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/particle_mechanics_analysis.py +++ b/applications/ParticleMechanicsApplication/python_scripts/particle_mechanics_analysis.py @@ -2,7 +2,6 @@ # Importing Kratos Core, Applications and Dependencies import KratosMultiphysics -import KratosMultiphysics.ParticleMechanicsApplication as KratosParticle # Importing the solvers (if available) try: diff --git a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py index 8d9f288b04b6..15d419f3ed00 100644 --- a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py +++ b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py @@ -2,7 +2,6 @@ # Importing the Kratos Library import KratosMultiphysics -import KratosMultiphysics.ParticleMechanicsApplication as KratosParticle # Import KratosUnittest import KratosMultiphysics.KratosUnittest as KratosUnittest diff --git a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py index f083648fc122..4bf6545ae419 100644 --- a/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py +++ b/applications/ParticleMechanicsApplication/tests/test_ParticleMechanicsApplication.py @@ -1,6 +1,5 @@ # import Kratos import KratosMultiphysics -import KratosMultiphysics.ParticleMechanicsApplication as KratosParticle import run_cpp_unit_tests # Import Kratos "wrapper" for unittests From bd75313df2583a1cdfc9de4cd725b22fe14a55b2 Mon Sep 17 00:00:00 2001 From: Bodhinanda Chandra Date: Tue, 18 Dec 2018 18:41:44 +0100 Subject: [PATCH 5/6] stupid mistake --- .../python_scripts/kratos_main_particle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/ParticleMechanicsApplication/python_scripts/kratos_main_particle.py b/applications/ParticleMechanicsApplication/python_scripts/kratos_main_particle.py index 0c4083b610a7..0f26028ce22d 100755 --- a/applications/ParticleMechanicsApplication/python_scripts/kratos_main_particle.py +++ b/applications/ParticleMechanicsApplication/python_scripts/kratos_main_particle.py @@ -1,7 +1,7 @@ from __future__ import print_function, absolute_import, division #makes KratosMultiphysics backward compatible with python 2.6 and 2.7 import KratosMultiphysics -import KratosMultiphysics.ParticleMechanicsApplication.particle_mechanics_analysis import ParticleMechanicsAnalysis +from KratosMultiphysics.ParticleMechanicsApplication.particle_mechanics_analysis import ParticleMechanicsAnalysis """ For user-scripting it is intended that a new class is derived From d7ed8284f6e98b0e1197f194a13eef6741fbeade Mon Sep 17 00:00:00 2001 From: Bodhinanda Chandra Date: Wed, 19 Dec 2018 11:03:03 +0100 Subject: [PATCH 6/6] as suggested --- .../python_scripts/particle_mechanics_analysis.py | 6 +++--- .../tests/particle_mechanics_test_factory.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/applications/ParticleMechanicsApplication/python_scripts/particle_mechanics_analysis.py b/applications/ParticleMechanicsApplication/python_scripts/particle_mechanics_analysis.py index 37d60ec48bed..17e445e34d46 100644 --- a/applications/ParticleMechanicsApplication/python_scripts/particle_mechanics_analysis.py +++ b/applications/ParticleMechanicsApplication/python_scripts/particle_mechanics_analysis.py @@ -12,6 +12,7 @@ # Importing the base class from analysis_stage import AnalysisStage +from KratosMultiphysics.ParticleMechanicsApplication.python_solvers_wrapper_particle import CreateSolver class ParticleMechanicsAnalysis(AnalysisStage): """ @@ -98,8 +99,7 @@ def RunSolutionLoop(self): def _CreateSolver(self): """ Create the Solver (and create and import the ModelPart if it is not alread in the model) """ ## Solver construction - import python_solvers_wrapper_particle - return python_solvers_wrapper_particle.CreateSolver(self.model, self.project_parameters) + return CreateSolver(self.model, self.project_parameters) def _CreateProcesses(self, parameter_name, initialization_order): """Create a list of Processes""" @@ -149,7 +149,7 @@ def _SetUpGiDOutput(self, parameter_name): gid_output = OutputProcess(self._GetSolver().GetGridModelPart(), grid_output_file_name, self.project_parameters["grid_output_configuration"]) elif parameter_name == "body_output": - from mpm_gid_output_process import ParticleMPMGiDOutputProcess as OutputProcess + from KratosMultiphysics.ParticleMechanicsApplication.mpm_gid_output_process import ParticleMPMGiDOutputProcess as OutputProcess mp_output_file_name = self.project_parameters["problem_data"]["problem_name"].GetString() + "_Body" gid_output = OutputProcess(self._GetSolver().GetComputingModelPart(), mp_output_file_name, self.project_parameters["body_output_configuration"]) diff --git a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py index 15d419f3ed00..c9e9d62547fb 100644 --- a/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py +++ b/applications/ParticleMechanicsApplication/tests/particle_mechanics_test_factory.py @@ -5,7 +5,7 @@ # Import KratosUnittest import KratosMultiphysics.KratosUnittest as KratosUnittest -import particle_mechanics_analysis +from KratosMultiphysics.ParticleMechanicsApplication.particle_mechanics_analysis import ParticleMechanicsAnalysis # Other imports import os @@ -42,7 +42,7 @@ def setUp(self): # Creating the test model = KratosMultiphysics.Model() - self.test = particle_mechanics_analysis.ParticleMechanicsAnalysis(model, ProjectParameters) + self.test = ParticleMechanicsAnalysis(model, ProjectParameters) self.test.Initialize() def modify_parameters(self, project_parameters):