Skip to content

Commit

Permalink
Merge #2068
Browse files Browse the repository at this point in the history
  • Loading branch information
loumalouomega committed May 28, 2018
2 parents 79c071a + e97f752 commit 0dcb323
Show file tree
Hide file tree
Showing 8 changed files with 253 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,14 @@ def _CreateSolver(self, external_model_part=None):
if (self.echo_level == 0):
KM.Logger.GetDefaultOutput().SetSeverity(KM.Logger.Severity.WARNING)

## Structure model part definition
main_model_part_name = self.project_parameters["problem_data"]["model_part_name"].GetString()
if self.model.HasModelPart(main_model_part_name):
self.main_model_part = self.model[main_model_part_name]
self.using_external_model_part = True
else:
self.main_model_part = KratosMultiphysics.ModelPart(main_model_part_name)
self.main_model_part.ProcessInfo.SetValue(KratosMultiphysics.DOMAIN_SIZE,
self.project_parameters["problem_data"]["domain_size"].GetInt())
self.using_external_model_part = False

## Solver construction
import python_solvers_wrapper_contact_structural
self.solver = python_solvers_wrapper_contact_structural.CreateSolver(self.main_model_part, self.project_parameters)
self.solver = python_solvers_wrapper_contact_structural.CreateSolver(self.model, self.project_parameters)

## Adds the necessary variables to the model_part only if they don't exist
self.solver.AddVariables()

if not self.using_external_model_part:
## Read the model - note that SetBufferSize is done here
self.solver.ReadModelPart() # TODO move to global instance
self.solver.ImportModelPart() # TODO move to global instance

def _SetUpListOfProcesses(self):
""" Set up the list of processes """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import KratosMultiphysics

def CreateSolver(main_model_part, custom_settings):
def CreateSolver(model, custom_settings):

if (type(main_model_part) != KratosMultiphysics.ModelPart):
raise Exception("input is expected to be provided as a Kratos ModelPart object")
if (type(model) != KratosMultiphysics.Model):
raise Exception("input is expected to be provided as a Kratos Model object")

if (type(custom_settings) != KratosMultiphysics.Parameters):
raise Exception("input is expected to be provided as a Kratos Parameters object")
Expand Down Expand Up @@ -43,6 +43,6 @@ def CreateSolver(main_model_part, custom_settings):
custom_settings["solver_settings"].RemoveValue("time_integration_method") # does not throw even if the value is not existing

solver_module = __import__(solver_module_name)
solver = solver_module.CreateSolver(main_model_part, custom_settings["solver_settings"])
solver = solver_module.CreateSolver(model, custom_settings["solver_settings"])

return solver
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,22 @@ def __init__(self, structure_main_model_part, fluid_main_model_part, project_par
coupling_utility_parameters = self.settings["coupling_solver_settings"]["coupling_strategy"]

# Construct the structure solver
self.structure_solver = python_solvers_wrapper_structural.CreateSolver(self.structure_main_model_part,
self.structure_model = KratosMultiphysics.Model()
structural_solver_settings = project_parameters["structure_solver_settings"]["solver_settings"]
if not structural_solver_settings.Has("time_stepping"):
KratosMultiphysics.Logger.PrintInfo("PartitionedFSIBaseSolver", "Using the old way to pass the time_step, this will be removed!")
time_stepping_params = KratosMultiphysics.Parameters("{}")
time_stepping_params.AddValue("time_step", project_parameters["structure_solver_settings"]["problem_data"]["time_step"])
structural_solver_settings.AddValue("time_stepping", time_stepping_params)
if not structural_solver_settings.Has("domain_size"):
KratosMultiphysics.Logger.PrintInfo("PartitionedFSIBaseSolver", "Using the old way to pass the domain_size, this will be removed!")
structural_solver_settings.AddEmptyValue("domain_size")
structural_solver_settings["domain_size"].SetInt(project_parameters["structure_solver_settings"]["problem_data"]["domain_size"].GetInt())
if not structural_solver_settings.Has("model_part_name"):
KratosMultiphysics.Logger.PrintInfo("PartitionedFSIBaseSolver", "Using the old way to pass the model_part_name, this will be removed!")
structural_solver_settings.AddEmptyValue("model_part_name")
structural_solver_settings["model_part_name"].SetString(project_parameters["structure_solver_settings"]["problem_data"]["model_part_name"].GetString())
self.structure_solver = python_solvers_wrapper_structural.CreateSolver(self.structure_model,
project_parameters["structure_solver_settings"])
print("* Structure solver constructed.")

Expand Down Expand Up @@ -134,6 +149,7 @@ def AddVariables(self):
def ImportModelPart(self):
# Import structure model part
self.structure_solver.ImportModelPart()
self.structure_solver.PrepareModelPart()

# Import fluid model part
self.fluid_solver.ImportModelPart()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,22 @@ def __init__(self, structure_main_model_part, fluid_main_model_part, project_par
self.structure_interface_submodelpart_name = self.settings["coupling_solver_settings"]["structure_interfaces_list"][0].GetString()

# Construct the structure solver
self.structure_solver = python_solvers_wrapper_structural.CreateSolver(self.structure_main_model_part,
self.structure_model = KratosMultiphysics.Model()
structural_solver_settings = project_parameters["structure_solver_settings"]["solver_settings"]
if not structural_solver_settings.Has("time_stepping"):
KratosMultiphysics.Logger.PrintInfo("TrilinosPartitionedFSIBaseSolver", "Using the old way to pass the time_step, this will be removed!")
time_stepping_params = KratosMultiphysics.Parameters("{}")
time_stepping_params.AddValue("time_step", project_parameters["problem_data"]["time_step"])
solver_settings.AddValue("time_stepping", time_stepping_params)
if not structural_solver_settings.Has("domain_size"):
KratosMultiphysics.Logger.PrintInfo("TrilinosPartitionedFSIBaseSolver", "Using the old way to pass the domain_size, this will be removed!")
structural_solver_settings.AddEmptyValue("domain_size")
structural_solver_settings["domain_size"].SetInt(project_parameters["structure_solver_settings"]["problem_data"]["domain_size"].GetInt())
if not structural_solver_settings.Has("model_part_name"):
KratosMultiphysics.Logger.PrintInfo("TrilinosPartitionedFSIBaseSolver", "Using the old way to pass the model_part_name, this will be removed!")
structural_solver_settings.AddEmptyValue("model_part_name")
structural_solver_settings["model_part_name"].SetString(project_parameters["structure_solver_settings"]["problem_data"]["model_part_name"].GetString())
self.structure_solver = python_solvers_wrapper_structural.CreateSolver(self.structure_model,
project_parameters["structure_solver_settings"])
if (KratosMPI.mpi.rank == 0) : print("* Structure solver constructed.")

Expand Down
11 changes: 8 additions & 3 deletions applications/FSIapplication/tests/FSI_problem_emulator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def RunTestCase(self):
"parallel_type" : "OpenMP"
},
"solver_settings" : {
"model_part_name" : "Structure",
"domain_size" : 2,
"solver_type" : "Dynamic",
"echo_level" : 0,
"analysis_type" : "linear",
Expand Down Expand Up @@ -107,17 +109,20 @@ def RunTestCase(self):

with WorkFolderScope(self.work_folder):

self.structure_main_model_part = ModelPart("Structure")
self.structure_main_model_part.ProcessInfo.SetValue(DOMAIN_SIZE, 2)
self.model = Model()

# Construct the structure solver
import python_solvers_wrapper_structural
self.structure_solver = python_solvers_wrapper_structural.CreateSolver(self.structure_main_model_part, StructureSolverSettings)
self.structure_solver = python_solvers_wrapper_structural.CreateSolver(self.model, StructureSolverSettings)

self.structure_solver.AddVariables()

self.structure_solver.ImportModelPart()

self.structure_solver.PrepareModelPart()

self.structure_main_model_part = self.model["Structure"]

self.structure_solver.AddDofs()

self.SetStructureBoundaryConditions()
Expand Down
Loading

0 comments on commit 0dcb323

Please sign in to comment.