예제 #1
0
    def __init__(self, model, params):
        Kratos.OutputProcess.__init__(self)

        default_settings = Kratos.Parameters('''{
            "response_type"       : "PLEASE_SPECIFY_RESPONSE_TYPE",
            "model_part_name"     : "PLEASE_SPECIFY_MAIN_MODEL_PART_NAME",
            "response_settings"   : {},
            "output_file_settings": {}
        }''')

        self.model = model
        self.params = params
        self.main_model_part = self.model.GetModelPart(
            self.params["model_part_name"].GetString())
        self.params.ValidateAndAssignDefaults(default_settings)
        self.output_file = None

        response_type = self.params["response_type"].GetString()
        if (response_type == "norm_square"):
            self.response = KratosCFD.VelocityPressureNormSquareResponseFunction(
                self.params["response_settings"], self.model)
        else:
            raise Exception(
                "Unknown response_type = \"" + response_type +
                "\". Supported response types are: \n\t  1. norm_square")
예제 #2
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))
     elif response_type == "norm_square":
         response_function = KratosCFD.VelocityPressureNormSquareResponseFunction(
             self.settings["response_function_settings"]["custom_settings"],
             self.model)
     else:
         raise Exception("Invalid response_type: " + response_type +
                         ". Available response functions: \'drag\'.")
     return response_function