def setUpProblem(self): with UnitTest.WorkFolderScope(self.work_folder, __file__): with open(self.settings, 'r') as parameter_file: self.ProjectParameters = KratosMultiphysics.Parameters(parameter_file.read()) self.model = KratosMultiphysics.Model() ## Solver construction self.solver = python_solvers_wrapper_fluid.CreateSolver(self.model, self.ProjectParameters) ## Set the "is_slip" field in the json settings (to avoid duplication it is set to false in all tests) if self.slip_flag: self.solver.settings["formulation"]["is_slip"].SetBool(True) self.solver.AddVariables() ## Read the model - note that SetBufferSize is done here self.solver.ImportModelPart() self.solver.PrepareModelPart() ## Add AddDofs self.solver.AddDofs() ## Solver initialization self.solver.Initialize() ## Processes construction self.list_of_processes = process_factory.KratosProcessFactory(self.model).ConstructListOfProcesses( self.ProjectParameters["processes"]["gravity"] ) self.list_of_processes += process_factory.KratosProcessFactory(self.model).ConstructListOfProcesses( self.ProjectParameters["processes"]["boundary_conditions_process_list"] ) self.main_model_part = self.model.GetModelPart(self.ProjectParameters["problem_data"]["model_part_name"].GetString()) ## Processes initialization for process in self.list_of_processes: process.ExecuteInitialize()
def PreviousSelfweightProblem(self): # Parsing parmeters of Selfweight Problem self_parameter_file = open("ProjectParametersSelfWeight.json",'r') SelfWeightProjectParameters = KratosMultiphysics.Parameters( self_parameter_file.read()) ## Creating Selfweight model part -------------------------------------------------------------- self.self_weight_model_part = self.model_selfweight.CreateModelPart("SelfWeight") self.self_weight_model_part.ProcessInfo.SetValue(KratosMultiphysics.DOMAIN_SIZE, self.domain_size) self.self_weight_model_part.ProcessInfo.SetValue(KratosMultiphysics.TIME, self.time) self.self_weight_model_part.ProcessInfo.SetValue(KratosMultiphysics.DELTA_TIME, self.delta_time) self.self_weight_model_part.ProcessInfo.SetValue(KratosDam.TIME_UNIT_CONVERTER, self.time_unit_converter) ## Construct the solver for selfweight problem ------------------------------------------------- selfweight_solver_module = __import__(SelfWeightProjectParameters["solver_settings"]["solver_type"].GetString()) selfweight_solver = selfweight_solver_module.CreateSolver(self.self_weight_model_part, SelfWeightProjectParameters["solver_settings"]) selfweight_solver.AddVariables() selfweight_solver.ImportModelPart() selfweight_solver.AddDofs() ## Kratos Selfweight Model --------------------------------------------------------------------- #DamSelfWeightModel = KratosMultiphysics.Model() #DamSelfWeightModel.AddModelPart(self.self_weight_model_part) ## Initialize ---------------------------------------------------------------------------------- # Construct processes to be applied import KratosMultiphysics.process_factory self_list_of_processes = process_factory.KratosProcessFactory(DamSelfWeightModel).ConstructListOfProcesses( SelfWeightProjectParameters["constraints_process_list"] ) self_list_of_processes += process_factory.KratosProcessFactory(DamSelfWeightModel).ConstructListOfProcesses( SelfWeightProjectParameters["loads_process_list"] ) # Initialize processes for process in self_list_of_processes: process.ExecuteInitialize() # Set TIME and DELTA_TIME and fill the previous steps of the buffer with the initial conditions self_time = self.time - (self.buffer_size-1) * self.delta_time self.self_weight_model_part.ProcessInfo.SetValue(KratosMultiphysics.TIME, self.time) for step in range(self.buffer_size-1): self_time = self_time + self.delta_time self.self_weight_model_part.CloneTimeStep(self_time) # Initialize the solver selfweight_solver.Initialize() # ExecuteBeforeSolutionLoop for process in self_list_of_processes: process.ExecuteBeforeSolutionLoop() # Solving selfweight problem selfweight_solver.Solve() # Cleaning selfweight solver selfweight_solver.Clear() # Initialize transfer_selfweight_stress_utility from KratosMultiphysics.DamApplication import transfer_selfweight_stress_utility self.transfer_utility = transfer_selfweight_stress_utility.TransferSelfweightStressToMainModelPartUtility()
def AddMaterials(self): # Assign material to model_parts (if Materials.json exists) if os.path.isfile("Materials.json"): materials_file = open("Materials.json", 'r') MaterialParameters = KratosMultiphysics.Parameters( materials_file.read()) if (MaterialParameters.Has("material_models_list")): ## Get the list of the model_part's in the object Model for i in range(self.ProjectParameters["solver_settings"] ["problem_domain_sub_model_part_list"].size()): part_name = self.ProjectParameters["solver_settings"][ "problem_domain_sub_model_part_list"][i].GetString() if (self.main_model_part.HasSubModelPart(part_name)): self.Model.update({ part_name: self.main_model_part.GetSubModelPart(part_name) }) assign_materials_processes = process_factory.KratosProcessFactory( self.Model).ConstructListOfProcesses( MaterialParameters["material_models_list"]) for process in assign_materials_processes: process.Execute() else: self.KratosPrintInfo(" No Materials.json found ")