def Initialize(self):

        ## Construct the communicator
        self.EpetraCommunicator = TrilinosApplication.CreateCommunicator()

        ## Get the computing model part
        self.computing_model_part = self.GetComputingModelPart()

        domain_size = self.main_model_part.ProcessInfo[KratosMultiphysics.DOMAIN_SIZE]
        if self.settings["response_function_settings"]["response_type"].GetString() == "drag":
            if (domain_size == 2):
                self.response_function = FluidDynamicsApplication.DragResponseFunction2D(self.settings["response_function_settings"]["custom_settings"], self.main_model_part)
            elif (domain_size == 3):
                self.response_function = FluidDynamicsApplication.DragResponseFunction3D(self.settings["response_function_settings"]["custom_settings"], self.main_model_part)
            else:
                raise Exception("Invalid DOMAIN_SIZE: " + str(domain_size))
        else:
            raise Exception("invalid response_type: " + self.settings["response_function_settings"]["response_type"].GetString())

        self.sensitivity_builder = KratosMultiphysics.SensitivityBuilder(self.settings["sensitivity_settings"], self.main_model_part, self.response_function)

        if self.settings["scheme_settings"]["scheme_type"].GetString() == "bossak":
            self.time_scheme = TrilinosApplication.TrilinosResidualBasedAdjointBossakScheme(self.settings["scheme_settings"], self.response_function)
        elif self.settings["scheme_settings"]["scheme_type"].GetString() == "steady":
            self.time_scheme = TrilinosApplication.TrilinosResidualBasedAdjointSteadyScheme(self.response_function)
        else:
            raise Exception("invalid scheme_type: " + self.settings["scheme_settings"]["scheme_type"].GetString())

        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

        self.builder_and_solver = TrilinosApplication.TrilinosBlockBuilderAndSolver(self.EpetraCommunicator,
                                                                               guess_row_size,
                                                                               self.trilinos_linear_solver)

        self.solver = TrilinosApplication.TrilinosLinearStrategy(self.main_model_part,
                                                                 self.time_scheme,
                                                                 self.trilinos_linear_solver,
                                                                 self.builder_and_solver,
                                                                 False,
                                                                 False,
                                                                 False,
                                                                 False)

        (self.solver).SetEchoLevel(self.settings["echo_level"].GetInt())

        (self.solver).Initialize()
        (self.response_function).Initialize()
        (self.sensitivity_builder).Initialize()

        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())

        if self._IsPrintingRank():
            KratosMultiphysics.Logger.PrintInfo(self.__class__.__name__,"Monolithic MPI solver initialization finished.")
    def GetResponseFunction(self):
        domain_size = self.main_model_part.ProcessInfo[
            KratosMultiphysics.DOMAIN_SIZE]

        if self.settings["response_function_settings"][
                "response_type"].GetString() == "drag":
            if (domain_size == 2):
                return KratosCFD.DragResponseFunction2D(
                    self.settings["response_function_settings"]
                    ["custom_settings"], self.main_model_part)
            elif (domain_size == 3):
                return KratosCFD.DragResponseFunction3D(
                    self.settings["response_function_settings"]
                    ["custom_settings"], self.main_model_part)
            else:
                raise Exception("Invalid DOMAIN_SIZE: " + str(domain_size))
        else:
            raise Exception("invalid response_type: " +
                            self.settings["response_function_settings"]
                            ["response_type"].GetString())
示例#3
0
 def __CreateResponseFunction(self):
     domain_size = self.main_model_part.ProcessInfo[
         KratosMultiphysics.DOMAIN_SIZE]
     response_type = self.settings["response_function_settings"][
         "response_type"].GetString()
     if response_type == "drag":
         if domain_size == 2:
             response_function = KratosCFD.DragResponseFunction2D(
                 self.settings["response_function_settings"]
                 ["custom_settings"], self.main_model_part)
         elif domain_size == 3:
             response_function = KratosCFD.DragResponseFunction3D(
                 self.settings["response_function_settings"]
                 ["custom_settings"], self.main_model_part)
         else:
             raise Exception("Invalid DOMAIN_SIZE: " + str(domain_size))
     else:
         raise Exception("Invalid response_type: " + response_type +
                         ". Available response functions: \'drag\'.")
     return response_function
示例#4
0
    def Initialize(self):

        self.computing_model_part = self.GetComputingModelPart()

        domain_size = self.main_model_part.ProcessInfo[
            KratosMultiphysics.DOMAIN_SIZE]

        if self.settings["response_function_settings"][
                "response_type"].GetString() == "drag":
            if (domain_size == 2):
                self.response_function = KratosCFD.DragResponseFunction2D(
                    self.settings["response_function_settings"]
                    ["custom_settings"], self.main_model_part)
            elif (domain_size == 3):
                self.response_function = KratosCFD.DragResponseFunction3D(
                    self.settings["response_function_settings"]
                    ["custom_settings"], self.main_model_part)
            else:
                raise Exception("Invalid DOMAIN_SIZE: " + str(domain_size))
        else:
            raise Exception("invalid response_type: " +
                            self.settings["response_function_settings"]
                            ["response_type"].GetString())

        self.sensitivity_builder = KratosMultiphysics.SensitivityBuilder(
            self.settings["sensitivity_settings"], self.main_model_part,
            self.response_function)

        if self.settings["scheme_settings"]["scheme_type"].GetString(
        ) == "bossak":
            self.time_scheme = KratosMultiphysics.ResidualBasedAdjointBossakScheme(
                self.settings["scheme_settings"], self.response_function)
        elif self.settings["scheme_settings"]["scheme_type"].GetString(
        ) == "steady":
            self.time_scheme = KratosMultiphysics.ResidualBasedAdjointSteadyScheme(
                self.response_function)
        else:
            raise Exception(
                "invalid scheme_type: " +
                self.settings["scheme_settings"]["scheme_type"].GetString())

        builder_and_solver = KratosMultiphysics.ResidualBasedBlockBuilderAndSolver(
            self.linear_solver)

        self.solver = KratosMultiphysics.ResidualBasedLinearStrategy(
            self.main_model_part, self.time_scheme, self.linear_solver,
            builder_and_solver, False, False, False, False)

        (self.solver).SetEchoLevel(self.settings["echo_level"].GetInt())

        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()
        (self.response_function).Initialize()
        (self.sensitivity_builder).Initialize()
        KratosMultiphysics.Logger.PrintInfo(self.__class__.__name__,
                                            "Solver initialization finished.")