Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes... #427

Merged
merged 5 commits into from
Aug 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion QuickStart/inv_NACA0012.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ TIME_DISCRE_ADJFLOW= EULER_IMPLICIT
% FFD_CONTROL_POINT, FFD_CAMBER, FFD_THICKNESS, FFD_TWIST
% FFD_CONTROL_POINT_2D, FFD_CAMBER_2D, FFD_THICKNESS_2D, FFD_TWIST_2D,
% HICKS_HENNE, SURFACE_BUMP)
DV_KIND= FFD_SETTING
DV_KIND= HICKS_HENNE
%
% Marker of the surface in which we are going apply the shape deformation
DV_MARKER= ( airfoil )
Expand Down
35 changes: 31 additions & 4 deletions SU2_CFD/include/solver_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6442,6 +6442,7 @@ class CIncEulerSolver : public CSolver {
Total_MaxHeat, /*!< \brief Maximum heat flux on all boundaries. */
Total_CpDiff, /*!< \brief Total Equivalent Area coefficient for all the boundaries. */
Total_HeatFluxDiff, /*!< \brief Total Equivalent Area coefficient for all the boundaries. */
Total_Custom_ObjFunc, /*!< \brief Total custom objective function for all the boundaries. */
Total_MassFlowRate; /*!< \brief Total Mass Flow Rate on monitored boundaries. */
su2double *Surface_CL, /*!< \brief Lift coefficient for each monitoring surface. */
*Surface_CD, /*!< \brief Drag coefficient for each monitoring surface. */
Expand Down Expand Up @@ -6786,10 +6787,16 @@ class CIncEulerSolver : public CSolver {
* \param[in] config - Definition of the particular problem.
*/
void Set_MPI_MaxEigenvalue(CGeometry *geometry, CConfig *config);


/*!
* \author H. Kline
* \brief Compute weighted-sum "combo" objective output
* \param[in] config - Definition of the particular problem.
*/
void Evaluate_ObjFunc(CConfig *config);

/*!
* \author: G.Gori, S.Vitale, M.Pini, A.Guardone, P.Colonna
*
* \brief Impose via the residual the Euler wall boundary condition.
* \param[in] geometry - Geometrical definition of the problem.
* \param[in] solver_container - Container vector with all the solutions.
Expand Down Expand Up @@ -7195,7 +7202,21 @@ class CIncEulerSolver : public CSolver {
* \param[in] val_Total_CLift - Value of the total lift coefficient.
*/
void SetTotal_CLift(su2double val_Total_CLift);


/*!
* \brief Set the value of the custom objective function.
* \param[in] val_Total_Custom_ObjFunc - Value of the total custom objective function.
* \param[in] val_weight - Value of the weight for the custom objective function.
*/
void SetTotal_Custom_ObjFunc(su2double val_total_custom_objfunc, su2double val_weight);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the Custom_ObjFunc to the incompressible solver


/*!
* \brief Add the value of the custom objective function.
* \param[in] val_Total_Custom_ObjFunc - Value of the total custom objective function.
* \param[in] val_weight - Value of the weight for the custom objective function.
*/
void AddTotal_Custom_ObjFunc(su2double val_total_custom_objfunc, su2double val_weight);

/*!
* \brief Provide the total (inviscid + viscous) non dimensional lift coefficient.
* \return Value of the lift coefficient (inviscid + viscous contribution).
Expand Down Expand Up @@ -7311,7 +7332,13 @@ class CIncEulerSolver : public CSolver {
* \return Value of the rotor efficiency coefficient (inviscid + viscous contribution).
*/
su2double GetTotal_CMerit(void);


/*!
* \brief Provide the total custom objective function.
* \return Value of the custom objective function.
*/
su2double GetTotal_Custom_ObjFunc(void);

/*!
* \brief Store the total (inviscid + viscous) non dimensional drag coefficient.
* \param[in] val_Total_CDrag - Value of the total drag coefficient.
Expand Down
6 changes: 6 additions & 0 deletions SU2_CFD/include/solver_structure.inl
Original file line number Diff line number Diff line change
Expand Up @@ -1725,6 +1725,12 @@ inline void CIncEulerSolver::SetTotal_HeatFluxDiff(su2double heat) { Total_HeatF

inline void CIncEulerSolver::SetTotal_CD(su2double val_Total_CD) { Total_CD = val_Total_CD; }

inline su2double CIncEulerSolver::GetTotal_Custom_ObjFunc() { return Total_Custom_ObjFunc; }

inline void CIncEulerSolver::SetTotal_Custom_ObjFunc(su2double val_total_custom_objfunc, su2double val_weight) { Total_Custom_ObjFunc = val_total_custom_objfunc*val_weight; }

inline void CIncEulerSolver::AddTotal_Custom_ObjFunc(su2double val_total_custom_objfunc, su2double val_weight) { Total_Custom_ObjFunc += val_total_custom_objfunc*val_weight; }

inline su2double CIncEulerSolver::GetAllBound_CL_Inv() { return AllBound_CL_Inv; }

inline su2double CIncEulerSolver::GetAllBound_CD_Inv() { return AllBound_CD_Inv; }
Expand Down
2 changes: 1 addition & 1 deletion SU2_CFD/src/solver_adjoint_discrete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,6 @@ void CDiscAdjSolver::SetSurface_Sensitivity(CGeometry *geometry, CConfig *config
unsigned long iVertex, iPoint;
su2double *Normal, Prod, Sens = 0.0, SensDim, Area, Sens_Vertex;
Total_Sens_Geo = 0.0;
su2double *MySens_Geo;
string Monitoring_Tag, Marker_Tag;

for (iMarker = 0; iMarker < nMarker; iMarker++) {
Expand Down Expand Up @@ -527,6 +526,7 @@ void CDiscAdjSolver::SetSurface_Sensitivity(CGeometry *geometry, CConfig *config
}

#ifdef HAVE_MPI
su2double *MySens_Geo;
MySens_Geo = new su2double[config->GetnMarker_Monitoring()];

for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) {
Expand Down
2 changes: 1 addition & 1 deletion SU2_CFD/src/solver_direct_mean.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short
Total_CFx = 0.0; Total_CFy = 0.0; Total_CFz = 0.0;
Total_CT = 0.0; Total_CQ = 0.0; Total_CMerit = 0.0;
Total_MaxHeat = 0.0; Total_Heat = 0.0; Total_ComboObj = 0.0;
Total_CpDiff = 0.0; Total_HeatFluxDiff = 0.0;
Total_CpDiff = 0.0; Total_HeatFluxDiff = 0.0; Total_Custom_ObjFunc=0.0;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

Total_NetCThrust = 0.0; Total_NetCThrust_Prev = 0.0; Total_BCThrust_Prev = 0.0;
Total_Power = 0.0; AoA_Prev = 0.0;
Total_CL_Prev = 0.0; Total_CD_Prev = 0.0;
Expand Down
86 changes: 85 additions & 1 deletion SU2_CFD/src/solver_direct_mean_inc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned
Total_CFx = 0.0; Total_CFy = 0.0; Total_CFz = 0.0;
Total_CT = 0.0; Total_CQ = 0.0; Total_CMerit = 0.0;
Total_MaxHeat = 0.0; Total_Heat = 0.0; Total_ComboObj = 0.0;
Total_CpDiff = 0.0; Total_HeatFluxDiff = 0.0;
Total_CpDiff = 0.0; Total_HeatFluxDiff = 0.0; Total_Custom_ObjFunc=0.0;

/*--- Coefficients for fixed lift mode. ---*/

Expand Down Expand Up @@ -4343,6 +4343,90 @@ void CIncEulerSolver::SetFarfield_AoA(CGeometry *geometry, CSolver **solver_cont

}

void CIncEulerSolver::Evaluate_ObjFunc(CConfig *config) {

unsigned short iMarker_Monitoring;
su2double Weight_ObjFunc;

/*--- Loop over all monitored markers, add to the 'combo' objective ---*/

for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) {

Weight_ObjFunc = config->GetWeight_ObjFunc(iMarker_Monitoring);

switch(config->GetKind_ObjFunc(iMarker_Monitoring)) {
case DRAG_COEFFICIENT:
Total_ComboObj+=Weight_ObjFunc*(Surface_CD[iMarker_Monitoring]);
if (config->GetFixed_CL_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCD_dCL()*(Surface_CL[iMarker_Monitoring]);
if (config->GetFixed_CM_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCD_dCMy()*(Surface_CMy[iMarker_Monitoring]);
break;
case LIFT_COEFFICIENT:
Total_ComboObj+=Weight_ObjFunc*(Surface_CL[iMarker_Monitoring]);
break;
case SIDEFORCE_COEFFICIENT:
Total_ComboObj+=Weight_ObjFunc*(Surface_CSF[iMarker_Monitoring]);
break;
case EFFICIENCY:
Total_ComboObj+=Weight_ObjFunc*(Surface_CEff[iMarker_Monitoring]);
break;
case MOMENT_X_COEFFICIENT:
Total_ComboObj+=Weight_ObjFunc*(Surface_CMx[iMarker_Monitoring]);
if (config->GetFixed_CL_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCMx_dCL()*(Surface_CL[iMarker_Monitoring]);
break;
case MOMENT_Y_COEFFICIENT:
Total_ComboObj+=Weight_ObjFunc*(Surface_CMy[iMarker_Monitoring]);
if (config->GetFixed_CL_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCMy_dCL()*(Surface_CL[iMarker_Monitoring]);
break;
case MOMENT_Z_COEFFICIENT:
Total_ComboObj+=Weight_ObjFunc*(Surface_CMz[iMarker_Monitoring]);
if (config->GetFixed_CL_Mode()) Total_ComboObj -= Weight_ObjFunc*config->GetdCMz_dCL()*(Surface_CL[iMarker_Monitoring]);
break;
case FORCE_X_COEFFICIENT:
Total_ComboObj+=Weight_ObjFunc*Surface_CFx[iMarker_Monitoring];
break;
case FORCE_Y_COEFFICIENT:
Total_ComboObj+=Weight_ObjFunc*Surface_CFy[iMarker_Monitoring];
break;
case FORCE_Z_COEFFICIENT:
Total_ComboObj+=Weight_ObjFunc*Surface_CFz[iMarker_Monitoring];
break;

/*--- The following are not per-surface, and as a result will be
* double-counted iff multiple surfaces are specified as well as multi-objective
* TODO: print a warning to the user about that possibility. ---*/

case INVERSE_DESIGN_PRESSURE:
Total_ComboObj+=Weight_ObjFunc*Total_CpDiff;
break;
case INVERSE_DESIGN_HEATFLUX:
Total_ComboObj+=Weight_ObjFunc*Total_HeatFluxDiff;
break;
case THRUST_COEFFICIENT:
Total_ComboObj+=Weight_ObjFunc*Total_CT;
break;
case TORQUE_COEFFICIENT:
Total_ComboObj+=Weight_ObjFunc*Total_CQ;
break;
case FIGURE_OF_MERIT:
Total_ComboObj+=Weight_ObjFunc*Total_CMerit;
break;
case AVG_TOTAL_PRESSURE:
Total_ComboObj+=Weight_ObjFunc*OneD_TotalPress;
break;
case MASS_FLOW_RATE:
Total_ComboObj+=Weight_ObjFunc*OneD_MassFlowRate;
break;
case CUSTOM_OBJFUNC:
Total_ComboObj+=Weight_ObjFunc*Total_Custom_ObjFunc;
break;
default:
break;

}
}

}

void CIncEulerSolver::BC_Euler_Wall(CGeometry *geometry, CSolver **solver_container,
CNumerics *numerics, CConfig *config, unsigned short val_marker) {

Expand Down
16 changes: 11 additions & 5 deletions SU2_PY/direct_differentiation.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,19 @@ def main():
parser.add_option("-n", "--partitions", dest="partitions", default=1,
help="number of PARTITIONS", metavar="PARTITIONS")
parser.add_option("-q", "--quiet", dest="quiet", default='False',
help="output QUIET to log files", metavar="QUIET")

help="output QUIET to log files", metavar="QUIET")
parser.add_option("-z", "--zones", dest="nzones", default="1",
help="Number of Zones", metavar="ZONES")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the number of zones is now an input of these scripts? I thought it was stored in the mesh information.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have this because the python scripts also need to know the number of zones in order to have to correct file names.


(options, args)=parser.parse_args()
options.partitions = int( options.partitions )
options.quiet = options.quiet.upper() == 'TRUE'
options.nzones = int( options.nzones )

direct_differentiation( options.filename ,
options.partitions ,
options.quiet )
options.quiet ,
options.nzones )
#: def main()


Expand All @@ -65,11 +69,13 @@ def main():
# -------------------------------------------------------------------

def direct_differentiation( filename ,
partitions = 0 ,
quiet = False ):
partitions = 0 ,
quiet = False ,
nzones = 1 ):
# Config
config = SU2.io.Config(filename)
config.NUMBER_PART = partitions
config.NZONES = int(nzones)
config["DIRECT_DIFF"] = 'DESIGN_VARIABLES'

if quiet:
Expand Down
18 changes: 12 additions & 6 deletions SU2_PY/finite_differences.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,19 @@ def main():
parser.add_option("-n", "--partitions", dest="partitions", default=1,
help="number of PARTITIONS", metavar="PARTITIONS")
parser.add_option("-q", "--quiet", dest="quiet", default='False',
help="output QUIET to log files", metavar="QUIET")

help="output QUIET to log files", metavar="QUIET")
parser.add_option("-z", "--zones", dest="nzones", default="1",
help="Number of Zones", metavar="ZONES")

(options, args)=parser.parse_args()
options.partitions = int( options.partitions )
options.quiet = options.quiet.upper() == 'TRUE'

options.nzones = int( options.nzones )

finite_differences( options.filename ,
options.partitions ,
options.quiet )
options.quiet ,
options.nzones )
#: def main()


Expand All @@ -66,11 +70,13 @@ def main():

def finite_differences( filename ,
partitions = 0 ,
quiet = False ):
quiet = False ,
nzones = 1 ):
# Config
config = SU2.io.Config(filename)
config.NUMBER_PART = partitions

config.NZONES = int( nzones )

if quiet:
config.CONSOLE = 'CONCISE'

Expand Down
Loading