def adjoint(config): """ info = SU2.run.adjoint(config) Runs an adjoint analysis with: SU2.run.decomp() SU2.run.CFD() SU2.run.merge() Assumptions: Does not run Gradient Projection Does not rename restart filename to solution filename Adds 'adjoint' suffix to convergence filename Outputs: info - SU2 State with keys: HISTORY.ADJOINT_NAME FILES.ADJOINT_NAME Updates: config.MATH_PROBLEM Executes in: ./ """ # local copy konfig = copy.deepcopy(config) # setup problem if konfig.get('GRADIENT_METHOD', 'CONTINUOUS_ADJOINT') == 'DISCRETE_ADJOINT': konfig['MATH_PROBLEM'] = 'DISCRETE_ADJOINT' else: konfig['MATH_PROBLEM'] = 'CONTINUOUS_ADJOINT' konfig['CONV_FILENAME'] = konfig['CONV_FILENAME'] + '_adjoint' # Run Solution SU2_CFD(konfig) # merge konfig['SOLUTION_ADJ_FILENAME'] = konfig['RESTART_ADJ_FILENAME'] su2merge(konfig) # filenames plot_format = konfig['OUTPUT_FORMAT'] plot_extension = su2io.get_extension(plot_format) history_filename = konfig['CONV_FILENAME'] + plot_extension special_cases = su2io.get_specialCases(konfig) # get history history = su2io.read_history(history_filename) # update super config config.update({ 'MATH_PROBLEM': konfig['MATH_PROBLEM'], 'OBJECTIVE_FUNCTION': konfig['OBJECTIVE_FUNCTION'] }) # files out objective = konfig['OBJECTIVE_FUNCTION'] adj_title = 'ADJOINT_' + objective suffix = su2io.get_adjointSuffix(objective) restart_name = konfig['RESTART_FLOW_FILENAME'] restart_name = su2io.add_suffix(restart_name, suffix) # info out info = su2io.State() info.FILES[adj_title] = restart_name info.HISTORY[adj_title] = history return info
def direct(config): """ info = SU2.run.direct(config) Runs an adjoint analysis with: SU2.run.decomp() SU2.run.CFD() SU2.run.merge() Assumptions: Redundant decomposition if config.DECOMPOSED == True Does not rename restart filename to solution filename Adds 'direct' suffix to convergence filename Outputs: info - SU2 State with keys: FUNCTIONS HISTORY.DIRECT FILES.DIRECT Updates: config.DECOMPOSED config.MATH_PROBLEM Executes in: ./ """ # local copy konfig = copy.deepcopy(config) # decompose su2decomp(konfig) # setup direct problem konfig['MATH_PROBLEM'] = 'DIRECT' konfig['CONV_FILENAME'] = konfig['CONV_FILENAME'] + '_direct' # Run Solution SU2_CFD(konfig) # merge konfig['SOLUTION_FLOW_FILENAME'] = konfig['RESTART_FLOW_FILENAME'] su2merge(konfig) # filenames plot_format = konfig['OUTPUT_FORMAT'] plot_extension = su2io.get_extension(plot_format) history_filename = konfig['CONV_FILENAME'] + plot_extension special_cases = su2io.get_specialCases(konfig) # averaging final iterations final_avg = config.get('ITER_AVERAGE_OBJ', 0) # get history and objectives history = su2io.read_history(history_filename) aerodynamics = su2io.read_aerodynamics(history_filename, special_cases, final_avg) # update super config config.update({ 'DECOMPOSED': konfig['DECOMPOSED'], 'MATH_PROBLEM': konfig['MATH_PROBLEM'] }) # info out info = su2io.State() info.FUNCTIONS.update(aerodynamics) info.FILES.DIRECT = konfig['RESTART_FLOW_FILENAME'] if 'EQUIV_AREA' in special_cases: info.FILES.WEIGHT_NF = 'WeightNF.dat' if 'INV_DESIGN_CP' in special_cases: info.FILES.TARGET_CP = 'TargetCp.dat' if 'INV_DESIGN_HEATFLUX' in special_cases: info.FILES.TARGET_HEATFLUX = 'TargetHeatFlux.dat' info.HISTORY.DIRECT = history return info