Beispiel #1
0
    def Initialize(self):
        """Perform initialization after adding nodal variables and dofs to the main model part. """
        if self.response_function_settings["response_type"].GetString(
        ) == "adjoint_lift_jump_coordinates":
            self.response_function = KCPFApp.AdjointLiftJumpCoordinatesResponseFunction(
                self.main_model_part, self.response_function_settings)
        else:
            raise Exception(
                "invalid response_type: " +
                self.response_function_settings["response_type"].GetString())

        self.sensitivity_builder = KratosMultiphysics.SensitivityBuilder(
            self.sensitivity_settings, self.main_model_part,
            self.response_function)
        self.sensitivity_builder.Initialize()

        scheme = KratosMultiphysics.ResidualBasedAdjointStaticScheme(
            self.response_function)

        builder_and_solver = KratosMultiphysics.ResidualBasedBlockBuilderAndSolver(
            self.linear_solver)
        self.solver = KratosMultiphysics.ResidualBasedLinearStrategy(
            self.main_model_part, scheme, self.linear_solver,
            builder_and_solver, self.settings["compute_reactions"].GetBool(),
            self.settings["reform_dofs_at_each_step"].GetBool(),
            self.settings["calculate_solution_norm"].GetBool(),
            self.settings["move_mesh_flag"].GetBool())

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

        self.response_function.Initialize()

        KratosMultiphysics.Logger.PrintInfo(
            "::[PotentialFlowAdjointSolver]:: ", "Finished initialization.")
 def __CreateResponseFunction(self):
     computing_model_part = self.GetComputingModelPart()
     if self.response_function_settings["response_type"].GetString(
     ) == "adjoint_lift_jump_coordinates":
         response_function = KCPFApp.AdjointLiftJumpCoordinatesResponseFunction(
             computing_model_part, self.response_function_settings)
     else:
         raise Exception(
             "Invalid response_type: " +
             self.response_function_settings["response_type"].GetString())
     return response_function