def _CreateSolutionStrategy(self): computing_model_part = self.GetComputingModelPart() epetra_communicator = self._GetEpetraCommunicator() domain_size = computing_model_part.ProcessInfo[ KratosMultiphysics.DOMAIN_SIZE] # Create the pressure and velocity linear solvers # Note that linear_solvers is a tuple. The first item is the pressure # linear solver. The second item is the velocity linear solver. linear_solvers = self._GetLinearSolver() # Create the fractional step settings instance # TODO: next part would be much cleaner if we passed directly the parameters to the c++ if self.settings["consider_periodic_conditions"].GetBool(): fractional_step_settings = TrilinosFluid.TrilinosFractionalStepSettingsPeriodic( epetra_communicator, computing_model_part, domain_size, self.settings["time_order"].GetInt(), self.settings["use_slip_conditions"].GetBool(), self.settings["move_mesh_flag"].GetBool(), self.settings["reform_dofs_at_each_step"].GetBool(), KratosCFD.PATCH_INDEX) else: fractional_step_settings = TrilinosFluid.TrilinosFractionalStepSettings( epetra_communicator, computing_model_part, domain_size, self.settings["time_order"].GetInt(), self.settings["use_slip_conditions"].GetBool(), self.settings["move_mesh_flag"].GetBool(), self.settings["reform_dofs_at_each_step"].GetBool()) # Set the strategy echo level fractional_step_settings.SetEchoLevel( self.settings["echo_level"].GetInt()) # Set the velocity and pressure fractional step strategy settings fractional_step_settings.SetStrategy( TrilinosFluid.TrilinosStrategyLabel.Pressure, linear_solvers[0], self.settings["pressure_tolerance"].GetDouble(), self.settings["maximum_pressure_iterations"].GetInt()) fractional_step_settings.SetStrategy( TrilinosFluid.TrilinosStrategyLabel.Velocity, linear_solvers[1], self.settings["velocity_tolerance"].GetDouble(), self.settings["maximum_velocity_iterations"].GetInt()) # Create the fractional step strategy if self.settings["consider_periodic_conditions"].GetBool(): solution_strategy = TrilinosFluid.TrilinosFractionalStepStrategy( computing_model_part, fractional_step_settings, self.settings["predictor_corrector"].GetBool(), self.settings["compute_reactions"].GetBool(), KratosCFD.PATCH_INDEX) else: solution_strategy = TrilinosFluid.TrilinosFractionalStepStrategy( computing_model_part, fractional_step_settings, self.settings["predictor_corrector"].GetBool(), self.settings["compute_reactions"].GetBool()) return solution_strategy
def Initialize(self): ## Construct the communicator self.EpetraComm = KratosTrilinos.CreateCommunicator() ## Get the computing model part self.computing_model_part = self.GetComputingModelPart() ## If needed, create the estimate time step utility if (self.settings["time_stepping"]["automatic_time_step"].GetBool()): self.EstimateDeltaTimeUtility = self._GetAutomaticTimeSteppingUtility( ) #TODO: next part would be much cleaner if we passed directly the parameters to the c++ if self.settings["consider_periodic_conditions"] == True: self.solver_settings = TrilinosFluid.TrilinosFractionalStepSettingsPeriodic( self.EpetraComm, self.computing_model_part, self.computing_model_part.ProcessInfo[ KratosMultiphysics.DOMAIN_SIZE], self.settings["time_order"].GetInt(), self.settings["use_slip_conditions"].GetBool(), self.settings["move_mesh_flag"].GetBool(), self.settings["reform_dofs_at_each_step]"].GetBool(), KratosFluid.PATCH_INDEX) else: self.solver_settings = TrilinosFluid.TrilinosFractionalStepSettings( self.EpetraComm, self.computing_model_part, self.computing_model_part.ProcessInfo[ KratosMultiphysics.DOMAIN_SIZE], self.settings["time_order"].GetInt(), self.settings["use_slip_conditions"].GetBool(), self.settings["move_mesh_flag"].GetBool(), self.settings["reform_dofs_at_each_step"].GetBool()) self.solver_settings.SetEchoLevel(self.settings["echo_level"].GetInt()) self.solver_settings.SetStrategy( TrilinosFluid.TrilinosStrategyLabel.Velocity, self.velocity_linear_solver, self.settings["velocity_tolerance"].GetDouble(), self.settings["maximum_velocity_iterations"].GetInt()) self.solver_settings.SetStrategy( TrilinosFluid.TrilinosStrategyLabel.Pressure, self.pressure_linear_solver, self.settings["pressure_tolerance"].GetDouble(), self.settings["maximum_pressure_iterations"].GetInt()) self.solver = TrilinosFluid.TrilinosFSStrategy( self.computing_model_part, self.solver_settings, self.settings["predictor_corrector"].GetBool(), KratosFluid.PATCH_INDEX) self.main_model_part.ProcessInfo.SetValue( KratosMultiphysics.DYNAMIC_TAU, self.settings["dynamic_tau"].GetDouble()) self.main_model_part.ProcessInfo.SetValue( KratosMultiphysics.OSS_SWITCH, self.settings["oss_switch"].GetInt()) (self.solver).Initialize() KratosMultiphysics.Logger.PrintInfo( "TrilinosNavierStokesSolverFractionalStep", "Initialization TrilinosNavierStokesSolverFractionalStep finished")