Exemple #1
0
    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()
Exemple #2
0
    def SetFluidProblem(self):

        ## Set the current mesh case problem info
        if (self.problem_type == "analytical_solution"):
            self.ProjectParameters["problem_data"]["problem_name"].SetString(
                self.input_file_name + "_manufactured")
        else:
            self.ProjectParameters["problem_data"]["problem_name"].SetString(
                self.input_file_name)
        self.ProjectParameters["solver_settings"]["model_import_settings"][
            "input_filename"].SetString(self.input_file_name)

        ## Solver construction
        self.solver = python_solvers_wrapper_fluid.CreateSolver(
            self.model, self.ProjectParameters)

        self.solver.AddVariables()

        ## Read the model - note that SetBufferSize is done here
        self.solver.ImportModelPart()
        self.solver.PrepareModelPart()

        self.main_model_part = self.model.GetModelPart(
            self.ProjectParameters["problem_data"]
            ["model_part_name"].GetString())

        ## Add AddDofs
        self.solver.AddDofs()

        ## Initialize GiD  I/O
        if (self.print_output):
            from gid_output_process import GiDOutputProcess
            self.gid_output = GiDOutputProcess(
                self.solver.GetComputingModelPart(),
                self.ProjectParameters["problem_data"]
                ["problem_name"].GetString(),
                self.ProjectParameters["output_configuration"])

            self.gid_output.ExecuteInitialize()

        ## Solver initialization
        self.solver.Initialize()

        ## Compute and set the nodal area
        self.SetNodalArea()

        ## Set the distance to 1 to have full fluid elements
        if (self.ProjectParameters["solver_settings"]
            ["solver_type"].GetString() == "Embedded"):
            for node in self.main_model_part.Nodes:
                node.SetSolutionStepValue(KratosMultiphysics.DISTANCE, 0, 1.0)

        ## Fix the pressure in one node (bottom left corner)
        for node in self.main_model_part.Nodes:
            if ((node.X < 0.001) and (node.Y < 0.001)):
                node.Fix(KratosMultiphysics.PRESSURE)
                node.SetSolutionStepValue(KratosMultiphysics.PRESSURE, 0, 0.0)
 def _CreateSolver(self):
     return python_solvers_wrapper_fluid.CreateSolver(
         self.model, self.project_parameters)