diff --git a/applications/ShapeOptimizationApplication/python_scripts/mesh_controller_with_solver.py b/applications/ShapeOptimizationApplication/python_scripts/mesh_controller_with_solver.py index 6aae475c9cfc..08491270dddf 100755 --- a/applications/ShapeOptimizationApplication/python_scripts/mesh_controller_with_solver.py +++ b/applications/ShapeOptimizationApplication/python_scripts/mesh_controller_with_solver.py @@ -100,4 +100,40 @@ def UpdateMeshAccordingInputVariable(self, variable): def Finalize(self): self._mesh_moving_analysis.Finalize() + # -------------------------------------------------------------------------- + @staticmethod + def __AddDefaultProblemData(mesh_solver_settings): + problem_data = Parameters("""{ + "echo_level" : 0, + "start_time" : 0.0, + "end_time" : 1.0, + "parallel_type" : "OpenMP" + }""") + + mesh_solver_settings.AddValue("problem_data", problem_data) + + # -------------------------------------------------------------------------- + @staticmethod + def __FixWholeSurface(optimization_model_part, mesh_solver_settings): + optimization_model_part.CreateSubModelPart("auto_surface_nodes") + + auto_process_settings = Parameters( + """ + { + "python_module" : "fix_vector_variable_process", + "kratos_module" : "KratosMultiphysics", + "help" : "This process fixes the selected components of a given vector variable without modifying the value of the variable.", + "process_name" : "FixVectorVariableProcess", + "Parameters" : { + "model_part_name" : \""""+str(optimization_model_part.Name)+""".auto_surface_nodes\", + "variable_name" : "MESH_DISPLACEMENT", + "constrained" : [true,true,true] + } + } + """) + + print("Add automatic process to fix the whole surface to mesh motion solver:") + print(auto_process_settings) + mesh_solver_settings["boundary_conditions_process_list"].Append(auto_process_settings) + # ============================================================================== diff --git a/applications/ShapeOptimizationApplication/python_scripts/model_part_controller_factory.py b/applications/ShapeOptimizationApplication/python_scripts/model_part_controller_factory.py index 912214189308..635fb3d9ba7f 100755 --- a/applications/ShapeOptimizationApplication/python_scripts/model_part_controller_factory.py +++ b/applications/ShapeOptimizationApplication/python_scripts/model_part_controller_factory.py @@ -52,10 +52,7 @@ def __init__(self, model_settings, model): model_part_name = self.model_settings["model_part_name"].GetString() - self.optimization_model_part = ModelPart(model_part_name) - self.model.AddModelPart(self.optimization_model_part) - # TODO use this line after model_v3 is merged: - # self.optimization_model_part = model.CreateModelPart(model_part_name) + self.optimization_model_part = model.CreateModelPart(model_part_name) self.optimization_model_part.ProcessInfo.SetValue(DOMAIN_SIZE, self.model_settings["domain_size"].GetInt())