Exemplo n.º 1
0
 def _CreateScheme(self):
     domain_size = self.GetComputingModelPart().ProcessInfo[
         KratosMultiphysics.DOMAIN_SIZE]
     # Cases in which the element manages the time integration
     if self.element_integrates_in_time:
         # Rotation utility for compressible Navier-Stokes formulations
         # A custom rotation util is required as the nodal DOFs differs from the standard incompressible case
         rotation_utility = KratosFluid.CompressibleElementRotationUtility(
             domain_size, KratosMultiphysics.SLIP)
         # "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
         scheme = KratosMultiphysics.ResidualBasedIncrementalUpdateStaticSchemeSlip(
             rotation_utility)
         # In case the BDF2 scheme is used inside the element, the BDF time discretization utility is required to update the BDF coefficients
         if (self.settings["time_scheme"].GetString() == "bdf2"):
             time_order = 2
             self.time_discretization = KratosMultiphysics.TimeDiscretization.BDF(
                 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)
     # Cases in which a time scheme manages the time integration
     else:
         err_msg = "Custom scheme creation is not allowed. Compressible Navier-Stokes elements manage the time integration internally."
         raise Exception(err_msg)
     return scheme
    def Initialize(self):
        self.computing_model_part = self.GetComputingModelPart()

        # If needed, create the estimate time step utility
        if (self.settings["time_stepping"]["automatic_time_step"].GetBool()):
            print("ERROR: _GetAutomaticTimeSteppingUtility out of date")
            #self.EstimateDeltaTimeUtility = self._GetAutomaticTimeSteppingUtility()

        # Creating the solution strategy
        self.conv_criteria = KratosMultiphysics.ResidualCriteria(self.settings["relative_tolerance"].GetDouble(),
                                                                 self.settings["absolute_tolerance"].GetDouble())
        

        #(self.conv_criteria).SetEchoLevel(self.settings["echo_level"].GetInt()
        (self.conv_criteria).SetEchoLevel(3)

        self.bdf_process = KratosMultiphysics.ComputeBDFCoefficientsProcess(self.computing_model_part,
                                                                            self.settings["time_order"].GetInt())
        

        domain_size = self.main_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE]
        rotation_utility = KratosFluid.CompressibleElementRotationUtility(domain_size,KratosMultiphysics.IS_STRUCTURE)
        time_scheme = KratosMultiphysics.ResidualBasedIncrementalUpdateStaticSchemeSlip(rotation_utility)
        #time_scheme = KratosMultiphysics.ResidualBasedIncrementalUpdateStaticScheme() # DOFs (4,5)
        

        builder_and_solver = KratosMultiphysics.ResidualBasedBlockBuilderAndSolver(self.linear_solver)
        

        self.solver = KratosMultiphysics.ResidualBasedNewtonRaphsonStrategy(self.computing_model_part,
                                                                            time_scheme,
                                                                            self.linear_solver,
                                                                            self.conv_criteria,
                                                                            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).SetEchoLevel(1)


        (self.solver).Initialize()
        
        
        (self.solver).Check()
        

        # self.main_model_part.ProcessInfo.SetValue(KratosMultiphysics.DYNAMIC_TAU, self.settings["dynamic_tau"].GetDouble()) # REMEMBER TO CHECK MY STAB CONSTANTS

        print ("Monolithic compressible solver initialization finished.")