def __CreateResponseFunctions( specified_responses, model ): response_functions = {} sho_response_functions = ["plane_based_packaging", "mesh_based_packaging"] csm_response_functions = ["strain_energy", "mass", "eigenfrequency", "adjoint_local_stress", "adjoint_max_stress"] convdiff_response_functions = ["point_temperature"] for (response_id, response_settings) in specified_responses: if response_id in response_functions.keys(): raise NameError("There are multiple response functions with the following identifier: " + response_id) response_type = response_settings["response_type"].GetString() if response_type in csm_response_functions: if csm_response_factory is None: raise RuntimeError("ShapeOpt: {} response function requires StructuralMechanicsApplication.".format(response_type)) response_functions[response_id] = csm_response_factory.CreateResponseFunction(response_id, response_settings, model) elif response_type in convdiff_response_functions: if convdiff_response_factory is None: raise RuntimeError("ShapeOpt: {} response function requires ConvectionDiffusionApplication.".format(response_type)) response_functions[response_id] = convdiff_response_factory.CreateResponseFunction(response_id, response_settings, model) elif response_type in sho_response_functions: response_functions[response_id] = sho_response_factory.CreateResponseFunction(response_id, response_settings, model) else: raise NameError("The response function '{}' of type '{}' is not available.".format(response_id, response_type)) return response_functions
def setUp(self): self.work_folder = "adjoint_diffusion_test" with KratosUnittest.WorkFolderScope(self.work_folder, __file__): with open(self.file_name, 'r') as parameter_file: parameters = KratosMultiphysics.Parameters( parameter_file.read()) # To avoid many prints KratosMultiphysics.Logger.GetDefaultOutput().SetSeverity( KratosMultiphysics.Logger.Severity.WARNING) model = KratosMultiphysics.Model() self.response_function = convection_diffusion_response_function_factory.CreateResponseFunction( "dummy", parameters["response_settings"], model) # call response function self.response_function.Initialize()
def __CreateResponseFunctions(specified_responses, model): response_functions = {} sho_response_functions = [ "plane_based_packaging", "mesh_based_packaging", "surface_normal_shape_change", "face_angle", "airfoil_angle_of_attack", "airfoil_chord_length", "airfoil_perimeter" ] csm_response_functions = [ "strain_energy", "mass", "eigenfrequency", "adjoint_local_stress", "adjoint_max_stress" ] cps_response_functions = [ "adjoint_lift_potential_jump", "stochastic_adjoint_lift_potential_jump" ] convdiff_response_functions = ["point_temperature"] for (response_id, response_settings) in specified_responses: if response_id in response_functions.keys(): raise NameError( "There are multiple response functions with the following identifier: " + response_id) response_type = response_settings["response_type"].GetString() if response_type in csm_response_functions: if csm_response_factory is None: raise RuntimeError( "ShapeOpt: {} response function requires StructuralMechanicsApplication." .format(response_type)) response_functions[ response_id] = csm_response_factory.CreateResponseFunction( response_id, response_settings, model) elif response_type in convdiff_response_functions: if convdiff_response_factory is None: raise RuntimeError( "ShapeOpt: {} response function requires ConvectionDiffusionApplication." .format(response_type)) response_functions[ response_id] = convdiff_response_factory.CreateResponseFunction( response_id, response_settings, model) elif response_type in cps_response_functions: if potential_flow_response_factory is None: raise RuntimeError( "ShapeOpt: {} response function requires CompressiblePotentialFlowApplication." .format(response_type)) response_functions[ response_id] = potential_flow_response_factory.CreateResponseFunction( response_id, response_settings, model) elif response_type in sho_response_functions: response_functions[ response_id] = sho_response_factory.CreateResponseFunction( response_id, response_settings, model) else: raise NameError( "The response function '{}' of type '{}' is not available." .format(response_id, response_type)) return response_functions