def Initialize(self): ## Construct the communicator self.EpetraCommunicator = 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() ## Creating the Trilinos convergence criteria self.conv_criteria = KratosTrilinos.TrilinosUPCriteria(self.settings["relative_velocity_tolerance"].GetDouble(), self.settings["absolute_velocity_tolerance"].GetDouble(), self.settings["relative_pressure_tolerance"].GetDouble(), self.settings["absolute_pressure_tolerance"].GetDouble(), self.EpetraCommunicator) ## Constructing the BDF process (time coefficients update) self.bdf_process = KratosMultiphysics.ComputeBDFCoefficientsProcess(self.computing_model_part,self.settings["time_order"].GetInt()) ## Creating the Trilinos incremental update time scheme (the time integration is defined within the embedded element) self.time_scheme = KratosTrilinos.TrilinosResidualBasedIncrementalUpdateStaticSchemeSlip(self.main_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE], # Domain size (2,3) self.main_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE]+1) # DOFs (3,4) ## Set the guess_row_size (guess about the number of zero entries) for the Trilinos builder and solver if self.main_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE] == 3: guess_row_size = 20*4 elif self.main_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE] == 2: guess_row_size = 10*3 ## Construct the Trilinos builder and solver if self.settings["consider_periodic_conditions"].GetBool() == True: self.builder_and_solver = KratosTrilinos.TrilinosBlockBuilderAndSolverPeriodic(self.EpetraCommunicator, guess_row_size, self.trilinos_linear_solver, KratosFluid.PATCH_INDEX) else: self.builder_and_solver = KratosTrilinos.TrilinosBlockBuilderAndSolver(self.EpetraCommunicator, guess_row_size, self.trilinos_linear_solver) ## Construct the Trilinos Newton-Raphson strategy self.solver = KratosTrilinos.TrilinosNewtonRaphsonStrategy(self.main_model_part, self.time_scheme, self.trilinos_linear_solver, self.conv_criteria, self.builder_and_solver, self.settings["maximum_iterations"].GetInt(), self.settings["compute_reactions"].GetBool(), self.settings["reform_dofs_at_each_step"].GetBool(), self.settings["move_mesh_flag"].GetBool()) (self.solver).SetEchoLevel(self.settings["echo_level"].GetInt()) (self.solver).Initialize() (self.solver).Check() self.main_model_part.ProcessInfo.SetValue(KratosMultiphysics.DYNAMIC_TAU, self.settings["dynamic_tau"].GetDouble())
def _CreateConvergenceCriterion(self): convergence_criterion = KratosTrilinos.TrilinosUPCriteria( self.settings["relative_velocity_tolerance"].GetDouble(), self.settings["absolute_velocity_tolerance"].GetDouble(), self.settings["relative_pressure_tolerance"].GetDouble(), self.settings["absolute_pressure_tolerance"].GetDouble()) convergence_criterion.SetEchoLevel(self.settings["echo_level"].GetInt()) return convergence_criterion
def _CreateConvergenceCriterion(self): if self.settings["time_scheme"].GetString() == "steady": convergence_criterion = KratosTrilinos.TrilinosResidualCriteria( self.settings["relative_velocity_tolerance"].GetDouble(), self.settings["absolute_velocity_tolerance"].GetDouble()) else: convergence_criterion = KratosTrilinos.TrilinosUPCriteria( self.settings["relative_velocity_tolerance"].GetDouble(), self.settings["absolute_velocity_tolerance"].GetDouble(), self.settings["relative_pressure_tolerance"].GetDouble(), self.settings["absolute_pressure_tolerance"].GetDouble()) convergence_criterion.SetEchoLevel( self.settings["echo_level"].GetInt()) return convergence_criterion
def Initialize(self): ## Construct the communicator self.EpetraCommunicator = 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( ) # Set the time discretization utility to compute the BDF coefficients time_order = self.settings["time_order"].GetInt() if time_order == 2: self.time_discretization = KratosMultiphysics.TimeDiscretization.BDF( time_order) else: raise Exception( "Only \"time_order\" equal to 2 is supported. Provided \"time_order\": " + str(time_order)) ## Creating the Trilinos convergence criteria self.conv_criteria = KratosTrilinos.TrilinosUPCriteria( self.settings["relative_velocity_tolerance"].GetDouble(), self.settings["absolute_velocity_tolerance"].GetDouble(), self.settings["relative_pressure_tolerance"].GetDouble(), self.settings["absolute_pressure_tolerance"].GetDouble()) (self.conv_criteria).SetEchoLevel(self.settings["echo_level"].GetInt()) ## Creating the Trilinos incremental update time scheme (the time integration is defined within the embedded element) self.time_scheme = KratosTrilinos.TrilinosResidualBasedIncrementalUpdateStaticSchemeSlip( self.main_model_part.ProcessInfo[ KratosMultiphysics.DOMAIN_SIZE], # Domain size (2,3) self.main_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE] + 1) # DOFs (3,4) ## Set the guess_row_size (guess about the number of zero entries) for the Trilinos builder and solver if self.main_model_part.ProcessInfo[ KratosMultiphysics.DOMAIN_SIZE] == 3: guess_row_size = 20 * 4 elif self.main_model_part.ProcessInfo[ KratosMultiphysics.DOMAIN_SIZE] == 2: guess_row_size = 10 * 3 ## Construct the Trilinos builder and solver if self.settings["consider_periodic_conditions"].GetBool() == True: self.builder_and_solver = KratosTrilinos.TrilinosBlockBuilderAndSolverPeriodic( self.EpetraCommunicator, guess_row_size, self.trilinos_linear_solver, KratosFluid.PATCH_INDEX) else: self.builder_and_solver = KratosTrilinos.TrilinosBlockBuilderAndSolver( self.EpetraCommunicator, guess_row_size, self.trilinos_linear_solver) ## Construct the Trilinos Newton-Raphson strategy self.solver = KratosTrilinos.TrilinosNewtonRaphsonStrategy( self.main_model_part, self.time_scheme, self.trilinos_linear_solver, self.conv_criteria, self.builder_and_solver, self.settings["maximum_iterations"].GetInt(), self.settings["compute_reactions"].GetBool(), self.settings["reform_dofs_at_each_step"].GetBool(), self.settings["move_mesh_flag"].GetBool()) (self.solver).SetEchoLevel(self.settings["echo_level"].GetInt()) (self.solver).Initialize() # For the primitive Ausas formulation, set the find nodal neighbours process # Recall that the Ausas condition requires the nodal neighbouts. if (self.settings["formulation"]["element_type"].GetString() == "embedded_ausas_navier_stokes"): number_of_avg_elems = 10 number_of_avg_nodes = 10 self.find_nodal_neighbours_process = KratosMultiphysics.FindNodalNeighboursProcess( self.GetComputingModelPart(), number_of_avg_elems, number_of_avg_nodes) KratosMultiphysics.Logger.PrintInfo( "NavierStokesMPIEmbeddedMonolithicSolver", "Solver initialization finished.")
def Initialize(self): ## Construct the communicator self.EpetraCommunicator = 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() ## Creating the Trilinos convergence criteria self.conv_criteria = KratosTrilinos.TrilinosUPCriteria(self.settings["relative_velocity_tolerance"].GetDouble(), self.settings["absolute_velocity_tolerance"].GetDouble(), self.settings["relative_pressure_tolerance"].GetDouble(), self.settings["absolute_pressure_tolerance"].GetDouble()) ## Creating the Trilinos time scheme if (self.settings["turbulence_model"].GetString() == "None"): if self.settings["consider_periodic_conditions"].GetBool() == True: self.time_scheme = KratosTrilinos.TrilinosPredictorCorrectorVelocityBossakSchemeTurbulent(self.settings["alpha"].GetDouble(), self.settings["move_mesh_strategy"].GetInt(), self.computing_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE], KratosCFD.PATCH_INDEX) else: self.time_scheme = KratosTrilinos.TrilinosPredictorCorrectorVelocityBossakSchemeTurbulent(self.settings["alpha"].GetDouble(), self.settings["move_mesh_strategy"].GetInt(), self.computing_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE]) ## Set the guess_row_size (guess about the number of zero entries) for the Trilinos builder and solver if self.main_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE] == 3: guess_row_size = 20*4 elif self.main_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE] == 2: guess_row_size = 10*3 ## Construct the Trilinos builder and solver if self.settings["consider_periodic_conditions"].GetBool() == True: self.builder_and_solver = KratosTrilinos.TrilinosBlockBuilderAndSolverPeriodic(self.EpetraCommunicator, guess_row_size, self.trilinos_linear_solver, KratosCFD.PATCH_INDEX) else: self.builder_and_solver = KratosTrilinos.TrilinosBlockBuilderAndSolver(self.EpetraCommunicator, guess_row_size, self.trilinos_linear_solver) ## Construct the Trilinos Newton-Raphson strategy self.solver = KratosTrilinos.TrilinosNewtonRaphsonStrategy(self.main_model_part, self.time_scheme, self.trilinos_linear_solver, self.conv_criteria, self.builder_and_solver, self.settings["maximum_iterations"].GetInt(), self.settings["compute_reactions"].GetBool(), self.settings["reform_dofs_at_each_step"].GetBool(), self.settings["move_mesh_flag"].GetBool()) (self.solver).SetEchoLevel(self.settings["echo_level"].GetInt()) (self.solver).Initialize() (self.solver).Check() 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()) print ("Monolithic MPI solver initialization finished.")
def Initialize(self): ## Construct the communicator self.EpetraCommunicator = KratosTrilinos.CreateCommunicator() ## Get the computing model part self.computing_model_part = self.GetComputingModelPart() KratosMultiphysics.NormalCalculationUtils().CalculateOnSimplex(self.computing_model_part, self.computing_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE]) self.neighbour_search = KratosMultiphysics.FindNodalNeighboursProcess(self.computing_model_part) (self.neighbour_search).Execute() self.accelerationLimitationUtility = KratosMultiphysics.FluidDynamicsApplication.AccelerationLimitationUtilities(self.computing_model_part, 5.0) ## If needed, create the estimate time step utility if (self.settings["time_stepping"]["automatic_time_step"].GetBool()): self.EstimateDeltaTimeUtility = self._GetAutomaticTimeSteppingUtility() # Set the time discretization utility to compute the BDF coefficients time_order = self.settings["time_order"].GetInt() if time_order == 2: self.time_discretization = KratosMultiphysics.TimeDiscretization.BDF(time_order) else: raise Exception("Only \"time_order\" equal to 2 is supported. Provided \"time_order\": " + str(time_order)) ## Creating the Trilinos convergence criteria self.conv_criteria = KratosTrilinos.TrilinosUPCriteria(self.settings["relative_velocity_tolerance"].GetDouble(), self.settings["absolute_velocity_tolerance"].GetDouble(), self.settings["relative_pressure_tolerance"].GetDouble(), self.settings["absolute_pressure_tolerance"].GetDouble()) (self.conv_criteria).SetEchoLevel(self.settings["echo_level"].GetInt()) #### ADDING NEW PROCESSES : level-set-convection and variational-distance-process self.level_set_convection_process = self._set_level_set_convection_process() self.variational_distance_process = self._set_variational_distance_process() ## Creating the Trilinos incremental update time scheme (the time integration is defined within the TwoFluidNavierStokes element) self.time_scheme = KratosTrilinos.TrilinosResidualBasedIncrementalUpdateStaticSchemeSlip(self.main_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE], # Domain size (2,3) self.main_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE]+1) # DOFs (3,4) ## Set the guess_row_size (guess about the number of zero entries) for the Trilinos builder and solver if self.main_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE] == 3: guess_row_size = 20*4 elif self.main_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE] == 2: guess_row_size = 10*3 ## Construct the Trilinos builder and solver if self.settings["consider_periodic_conditions"].GetBool() == True: self.builder_and_solver = KratosTrilinos.TrilinosBlockBuilderAndSolverPeriodic(self.EpetraCommunicator, guess_row_size, self.trilinos_linear_solver, KratosFluid.PATCH_INDEX) else: self.builder_and_solver = KratosTrilinos.TrilinosBlockBuilderAndSolver(self.EpetraCommunicator, guess_row_size, self.trilinos_linear_solver) ## Construct the Trilinos Newton-Raphson strategy self.solver = KratosTrilinos.TrilinosNewtonRaphsonStrategy(self.main_model_part, self.time_scheme, self.trilinos_linear_solver, self.conv_criteria, self.builder_and_solver, self.settings["maximum_iterations"].GetInt(), self.settings["compute_reactions"].GetBool(), self.settings["reform_dofs_at_each_step"].GetBool(), self.settings["move_mesh_flag"].GetBool()) (self.solver).SetEchoLevel(self.settings["echo_level"].GetInt()) (self.solver).Initialize() (self.solver).Check() self.main_model_part.ProcessInfo.SetValue(KratosMultiphysics.DYNAMIC_TAU, self.settings["formulation"]["dynamic_tau"].GetDouble())
def Initialize(self): ## Construct the communicator self.EpetraCommunicator = 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( ) ## Creating the Trilinos convergence criteria self.conv_criteria = KratosTrilinos.TrilinosUPCriteria( self.settings["relative_velocity_tolerance"].GetDouble(), self.settings["absolute_velocity_tolerance"].GetDouble(), self.settings["relative_pressure_tolerance"].GetDouble(), self.settings["absolute_pressure_tolerance"].GetDouble()) (self.conv_criteria).SetEchoLevel(self.settings["echo_level"].GetInt()) ## Creating the Trilinos time scheme if (self.element_integrates_in_time): # "Fake" scheme for those cases in where the element manages the time integration # It is required to perform the nodal update once the current time step is solved self.time_scheme = KratosTrilinos.TrilinosResidualBasedIncrementalUpdateStaticSchemeSlip( self.computing_model_part.ProcessInfo[ KratosMultiphysics.DOMAIN_SIZE], self.computing_model_part.ProcessInfo[ KratosMultiphysics.DOMAIN_SIZE] + 1) # In case the BDF2 scheme is used inside the element, set the time discretization utility to compute the BDF coefficients if (self.settings["time_scheme"].GetString() == "bdf2"): time_order = self.settings["time_order"].GetInt() if time_order == 2: self.time_discretization = KratosMultiphysics.TimeDiscretization.BDF( time_order) else: raise Exception( "Only \"time_order\" equal to 2 is supported. Provided \"time_order\": " + str(time_order)) else: err_msg = "Requested elemental time scheme " + self.settings[ "time_scheme"].GetString() + " is not available.\n" err_msg += "Available options are: \"bdf2\"" raise Exception(err_msg) else: if (self.settings["turbulence_model"].GetString() == "None"): if self.settings["consider_periodic_conditions"].GetBool( ) == True: self.time_scheme = KratosTrilinos.TrilinosPredictorCorrectorVelocityBossakSchemeTurbulent( self.settings["alpha"].GetDouble(), self.computing_model_part.ProcessInfo[ KratosMultiphysics.DOMAIN_SIZE], KratosCFD.PATCH_INDEX) else: self.time_scheme = KratosTrilinos.TrilinosPredictorCorrectorVelocityBossakSchemeTurbulent( self.settings["alpha"].GetDouble(), self.settings["move_mesh_strategy"].GetInt(), self.computing_model_part.ProcessInfo[ KratosMultiphysics.DOMAIN_SIZE]) ## Set the guess_row_size (guess about the number of zero entries) for the Trilinos builder and solver if self.main_model_part.ProcessInfo[ KratosMultiphysics.DOMAIN_SIZE] == 3: guess_row_size = 20 * 4 elif self.main_model_part.ProcessInfo[ KratosMultiphysics.DOMAIN_SIZE] == 2: guess_row_size = 10 * 3 ## Construct the Trilinos builder and solver if self.settings["consider_periodic_conditions"].GetBool() == True: self.builder_and_solver = KratosTrilinos.TrilinosBlockBuilderAndSolverPeriodic( self.EpetraCommunicator, guess_row_size, self.trilinos_linear_solver, KratosCFD.PATCH_INDEX) else: self.builder_and_solver = KratosTrilinos.TrilinosBlockBuilderAndSolver( self.EpetraCommunicator, guess_row_size, self.trilinos_linear_solver) ## Construct the Trilinos Newton-Raphson strategy self.solver = KratosTrilinos.TrilinosNewtonRaphsonStrategy( self.main_model_part, self.time_scheme, self.trilinos_linear_solver, self.conv_criteria, self.builder_and_solver, self.settings["maximum_iterations"].GetInt(), self.settings["compute_reactions"].GetBool(), self.settings["reform_dofs_at_each_step"].GetBool(), self.settings["move_mesh_flag"].GetBool()) (self.solver).SetEchoLevel(self.settings["echo_level"].GetInt()) self.formulation.SetProcessInfo(self.computing_model_part) (self.solver).Initialize() KratosMultiphysics.Logger.Print( "Monolithic MPI solver initialization finished.")