Skip to content

Commit

Permalink
Merge pull request #569 from su2code/feature_directdiff_obj
Browse files Browse the repository at this point in the history
Feature directdiff obj
  • Loading branch information
economon authored Sep 6, 2018
2 parents db5bb5b + 35a42f7 commit a0ecddf
Show file tree
Hide file tree
Showing 5 changed files with 462 additions and 10 deletions.
29 changes: 25 additions & 4 deletions SU2_CFD/src/output_structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4369,6 +4369,7 @@ void COutput::SetConvHistory_Header(ofstream *ConvHist_file, CConfig *config, un
char d_thermal_coeff[] = ",\"D(HeatFlux_Total)\",\"D(HeatFlux_Maximum)\"";
char d_engine[] = ",\"D(NetThrust)\",\"D(Power)\",\"D(AeroCDrag)\",\"D(SolidCDrag)\",\"D(Radial_Distortion)\",\"D(Circumferential_Distortion)\"";
char d_turbo_coeff[] = ",\"D(TotalPressureLoss_0)\",\"D(FlowAngleOut_0)\",\"D(TotalEfficency)\",\"D(TotalStaticEfficiency)\", \"D(EntropyGen)\"";
char d_surface_outputs[]= ",\"D(Uniformity)\",\"D(Secondary_Strength)\",\"D(Momentum_Distortion)\",\"D(Secondary_Over_Uniformity)\",\"D(Pressure_Drop)\"";

/*--- Find the markers being monitored and create a header for them ---*/

Expand Down Expand Up @@ -4477,6 +4478,7 @@ void COutput::SetConvHistory_Header(ofstream *ConvHist_file, CConfig *config, un
else ConvHist_file[0] << d_turbo_coeff;
if (engine || actuator_disk) ConvHist_file[0] << d_engine;
if (thermal) ConvHist_file[0] << d_thermal_coeff;
if (output_surface) ConvHist_file[0] << d_surface_outputs;
}
if (output_comboObj) ConvHist_file[0] << combo_obj;
ConvHist_file[0] << end;
Expand Down Expand Up @@ -4663,7 +4665,7 @@ void COutput::SetConvHistory_Body(ofstream *ConvHist_file,
adjoint_coeff[1000], flow_resid[1000], adj_flow_resid[1000], turb_resid[1000], trans_resid[1000],
adj_turb_resid[1000], wave_coeff[1000],
begin_fem[1000], fem_coeff[1000], wave_resid[1000], heat_resid[1000], combo_obj[1000],
fem_resid[1000], end[1000], end_fem[1000], surface_outputs[1000], d_direct_coeff[1000], turbo_coeff[10000];
fem_resid[1000], end[1000], end_fem[1000], surface_outputs[1000], d_surface_outputs[1000], d_direct_coeff[1000], turbo_coeff[10000];

su2double dummy = 0.0, *Coord;
unsigned short iVar, iMarker_Monitoring;
Expand Down Expand Up @@ -4752,7 +4754,8 @@ void COutput::SetConvHistory_Body(ofstream *ConvHist_file,
su2double D_Total_CL = 0.0, D_Total_CD = 0.0, D_Total_CSF = 0.0, D_Total_CMx = 0.0, D_Total_CMy = 0.0, D_Total_CMz = 0.0, D_Total_CEff = 0.0, D_Total_CFx = 0.0,
D_Total_CFy = 0.0, D_Total_CFz = 0.0, D_Total_NetThrust = 0.0, D_Total_Power = 0.0, D_Total_AeroCD = 0.0, D_Total_SolidCD = 0.0, D_Total_IDR = 0.0, D_Total_IDC = 0.0, D_Total_Custom_ObjFunc = 0.0, D_Total_Heat = 0.0, D_Total_MaxHeat = 0.0,
D_TotalPressure_Loss = 0.0, D_FlowAngle_Out = 0.0, D_TotalStaticEfficiency = 0.0,
D_TotalTotalEfficiency = 0.0, D_EntropyGen = 0.0;
D_TotalTotalEfficiency = 0.0, D_EntropyGen = 0.0,
D_Surface_Uniformity = 0.0, D_Surface_SecondaryStrength = 0.0, D_Surface_MomentumDistortion = 0.0, D_Surface_SecondOverUniform = 0.0, D_Surface_PressureDrop = 0.0;

/*--- Residual arrays ---*/
su2double *residual_flow = NULL,
Expand Down Expand Up @@ -4989,6 +4992,13 @@ void COutput::SetConvHistory_Body(ofstream *ConvHist_file,
Surface_TotalPressure = config[ZONE_0]->GetSurface_TotalPressure(iMarker_Analyze);
Surface_PressureDrop = config[ZONE_0]->GetSurface_PressureDrop(iMarker_Analyze);

if (direct_diff != NO_DERIVATIVE){
D_Surface_Uniformity = SU2_TYPE::GetDerivative(Surface_Uniformity);
D_Surface_SecondaryStrength = SU2_TYPE::GetDerivative(Surface_SecondaryStrength);
D_Surface_MomentumDistortion = SU2_TYPE::GetDerivative(Surface_MomentumDistortion);
D_Surface_SecondOverUniform = SU2_TYPE::GetDerivative(Surface_SecondOverUniform);
D_Surface_PressureDrop = SU2_TYPE::GetDerivative(Surface_PressureDrop);
}
}

/*--- Flow Residuals ---*/
Expand Down Expand Up @@ -5354,6 +5364,11 @@ void COutput::SetConvHistory_Body(ofstream *ConvHist_file,

if (output_surface) {
SPRINTF( surface_outputs, ", %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e, %14.8e", Surface_MassFlow, Surface_Mach, Surface_Temperature, Surface_Pressure, Surface_Density, Surface_Enthalpy, Surface_NormalVelocity, Surface_Uniformity, Surface_SecondaryStrength, Surface_MomentumDistortion, Surface_SecondOverUniform, Surface_TotalTemperature, Surface_TotalPressure, Surface_PressureDrop);

if (direct_diff != NO_DERIVATIVE) {
SPRINTF( d_surface_outputs, ", %14.8e, %14.8e, %14.8e, %14.8e, %14.8e",
D_Surface_Uniformity, D_Surface_SecondaryStrength, D_Surface_MomentumDistortion, D_Surface_SecondOverUniform, D_Surface_PressureDrop);
}
}

/*--- Transition residual ---*/
Expand Down Expand Up @@ -5928,7 +5943,10 @@ void COutput::SetConvHistory_Body(ofstream *ConvHist_file,
if (aeroelastic) ConvHist_file[0] << aeroelastic_coeff;
if (output_per_surface) ConvHist_file[0] << monitoring_coeff;
if (output_surface) ConvHist_file[0] << surface_outputs;
if (direct_diff != NO_DERIVATIVE) ConvHist_file[0] << d_direct_coeff;
if (direct_diff != NO_DERIVATIVE) {
ConvHist_file[0] << d_direct_coeff;
if (output_surface) ConvHist_file[0] << d_surface_outputs;
}
if (output_comboObj) ConvHist_file[0] << combo_obj;
ConvHist_file[0] << end;
ConvHist_file[0].flush();
Expand Down Expand Up @@ -6019,7 +6037,10 @@ void COutput::SetConvHistory_Body(ofstream *ConvHist_file,
if (aeroelastic) ConvHist_file[0] << aeroelastic_coeff;
if (output_per_surface) ConvHist_file[0] << monitoring_coeff;
if (output_surface) ConvHist_file[0] << surface_outputs;
if (direct_diff != NO_DERIVATIVE) ConvHist_file[0] << d_direct_coeff;
if (direct_diff != NO_DERIVATIVE) {
ConvHist_file[0] << d_direct_coeff;
if (output_surface) ConvHist_file[0] << d_surface_outputs;
}
if (output_comboObj) ConvHist_file[0] << combo_obj;
ConvHist_file[0] << end;
ConvHist_file[0].flush();
Expand Down
7 changes: 3 additions & 4 deletions SU2_PY/SU2/io/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,10 @@ def unpack_dvs(self,dv_new,dv_old=None):
param_dv['PARAM'] = def_dv['PARAM']
param_dv['FFDTAG'] = def_dv['FFDTAG']
param_dv['SIZE'] = def_dv['SIZE']

self.update({ 'DV_MARKER' : def_dv['MARKER'][0] ,
'DV_VALUE_OLD' : dv_old ,
'DV_VALUE_NEW' : dv_new })

self.update({ 'DV_VALUE_OLD' : dv_old ,
'DV_VALUE_NEW' : dv_new })

def __eq__(self,konfig):
return super(Config,self).__eq__(konfig)
def __ne__(self,konfig):
Expand Down
19 changes: 17 additions & 2 deletions SU2_PY/SU2/io/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,12 @@ def get_headerMap(nZones = 1):
"D(MassFlowOut_0)" : "D_MASS_FLOW_OUT" ,
"D(PressureRatio_0)" : "D_PRESSURE_RATIO" ,
"D(EnthalpyOut_0)" : "D_ENTHALPY_OUT" ,
"D(TotalEnthalpy_0)" : "D_TOTAL_ENTHALPY_OUT" }
"D(TotalEnthalpy_0)" : "D_TOTAL_ENTHALPY_OUT" ,
"D(Uniformity)" : "D_SURFACE_UNIFORMITY" ,
"D(Secondary_Strength)" : "D_SURFACE_SECONDARY" ,
"D(Momentum_Distortion)" : "D_SURFACE_MOM_DISTORTION" ,
"D(Secondary_Over_Uniformity)" : "D_SURFACE_SECOND_OVER_UNIFORM" ,
"D(Pressure_Drop)" : "D_SURFACE_PRESSURE_DROP" }

return history_header_map

Expand Down Expand Up @@ -425,7 +430,12 @@ def getTurboPerfIndex(nZones = 1):
"D_MASS_FLOW_OUT",
"D_PRESSURE_RATIO",
"D_ENTHALPY_OUT",
"D_TOTAL_ENTHALPY_OUT"]
"D_TOTAL_ENTHALPY_OUT",
"D_SURFACE_UNIFORMITY",
"D_SURFACE_SECONDARY",
"D_SURFACE_MOM_DISTORTION",
"D_SURFACE_SECOND_OVER_UNIFORM",
"D_SURFACE_PRESSURE_DROP"]

grad_names_map = ordered_bunch()
grad_names_map.MASS_FLOW_IN = "D_MASS_FLOW_IN"
Expand All @@ -452,6 +462,11 @@ def getTurboPerfIndex(nZones = 1):
grad_names_map.CUSTOM_OBJFUNC = "D_CUSTOM_OBJFUNC"
grad_names_map.HEAT = "D_HEAT"
grad_names_map.MAX_HEAT = "D_MAX_HEAT"
grad_names_map.SURFACE_UNIFORMITY = "D_SURFACE_UNIFORMITY"
grad_names_map.SURFACE_SECONDARY = "D_SURFACE_SECONDARY"
grad_names_map.SURFACE_MOM_DISTORTION = "D_SURFACE_MOM_DISTORTION"
grad_names_map.SURFACE_SECOND_OVER_UNIFORM = "D_SURFACE_SECOND_OVER_UNIFORM"
grad_names_map.SURFACE_PRESSURE_DROP = "D_SURFACE_PRESSURE_DROP"

# per-surface functions
per_surface_map = {"LIFT" : "CL" ,
Expand Down
Loading

0 comments on commit a0ecddf

Please sign in to comment.