Skip to content

Commit f23b907

Browse files
authored
Merge pull request #1478 from su2code/custom_objective_function
Custom objective function (e.g. 'DRAG + LIFT')
2 parents 85b2b12 + 1ea8b02 commit f23b907

44 files changed

Lines changed: 714 additions & 697 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@
1818
[submodule "externals/opdi"]
1919
path = externals/opdi
2020
url = https://github.com/SciCompKL/OpDiLib
21+
[submodule "externals/mel"]
22+
path = externals/mel
23+
url = https://github.com/pcarruscag/MEL.git

Common/include/CConfig.hpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ class CConfig {
8080
su2double EA_ScaleFactor; /*!< \brief Equivalent Area scaling factor */
8181
su2double AdjointLimit; /*!< \brief Adjoint variable limit */
8282
string* ConvField; /*!< \brief Field used for convergence check.*/
83-
string ConvCriteria; // This option is deprecated. After a grace period until 7.2.0 the usage warning should become an error.
8483

8584
string* WndConvField; /*!< \brief Function where to apply the windowed convergence criteria for the time average of the unsteady (single zone) flow problem. */
8685
unsigned short nConvField; /*!< \brief Number of fields used to monitor convergence.*/
@@ -436,7 +435,7 @@ class CConfig {
436435
Unst_CFL; /*!< \brief Unsteady CFL number. */
437436

438437
bool ReorientElements; /*!< \brief Flag for enabling element reorientation. */
439-
bool AddIndNeighbor; /*!< \brief Include indirect neighbor in the agglomeration process. */
438+
string CustomObjFunc; /*!< \brief User-defined objective function. */
440439
unsigned short nDV, /*!< \brief Number of design variables. */
441440
nObj, nObjW; /*! \brief Number of objective functions. */
442441
unsigned short* nDV_Value; /*!< \brief Number of values for each design variable (might be different than 1 if we allow arbitrary movement). */
@@ -5177,6 +5176,11 @@ class CConfig {
51775176
*/
51785177
void SetWeight_ObjFunc(unsigned short val_obj, su2double val) { Weight_ObjFunc[val_obj] = val; }
51795178

5179+
/*!
5180+
* \brief Get the user expression for the custom objective function.
5181+
*/
5182+
const string& GetCustomObjFunc() const { return CustomObjFunc; }
5183+
51805184
/*!
51815185
* \brief Get the kind of sensitivity smoothing technique.
51825186
* \return Kind of sensitivity smoothing technique.
@@ -5469,12 +5473,6 @@ class CConfig {
54695473
*/
54705474
string GetObjFunc_Extension(string val_filename) const;
54715475

5472-
/*!
5473-
* \brief Get the criteria for structural residual (relative/absolute).
5474-
* \return Relative/Absolute criteria for structural convergence.
5475-
*/
5476-
unsigned short GetResidual_Criteria_FEM(void) const { return Res_FEM_CRIT; }
5477-
54785476
/*!
54795477
* \brief Get functional that is going to be used to evaluate the residual flow convergence.
54805478
* \return Functional that is going to be used to evaluate the residual flow convergence.

Common/include/option_structure.hpp

Lines changed: 12 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,17 +1563,8 @@ enum ENUM_OBJECTIVE {
15631563
SURFACE_SPECIES_0 = 58, /*!< \brief Surface Avg. Species_0 objective function definition. */
15641564
SURFACE_SPECIES_VARIANCE = 59,/*!< \brief Species Variance objective function definition. */
15651565
CUSTOM_OBJFUNC = 31, /*!< \brief Custom objective function definition. */
1566-
TOTAL_PRESSURE_LOSS = 39,
1567-
KINETIC_ENERGY_LOSS = 40,
1568-
TOTAL_EFFICIENCY = 41,
1569-
TOTAL_STATIC_EFFICIENCY = 42,
1570-
EULERIAN_WORK = 43,
1571-
TOTAL_ENTHALPY_IN = 44,
1572-
FLOW_ANGLE_IN = 45,
15731566
FLOW_ANGLE_OUT = 46,
15741567
MASS_FLOW_IN = 47,
1575-
MASS_FLOW_OUT = 48,
1576-
PRESSURE_RATIO = 49,
15771568
ENTROPY_GENERATION = 50,
15781569
REFERENCE_GEOMETRY = 60, /*!< \brief Norm of displacements with respect to target geometry. */
15791570
REFERENCE_NODE = 61, /*!< \brief Objective function defined as the difference of a particular node respect to a reference position. */
@@ -1617,18 +1608,9 @@ static const MapType<std::string, ENUM_OBJECTIVE> Objective_Map = {
16171608
MakePair("SURFACE_SPECIES_0", SURFACE_SPECIES_0)
16181609
MakePair("SURFACE_SPECIES_VARIANCE", SURFACE_SPECIES_VARIANCE)
16191610
MakePair("CUSTOM_OBJFUNC", CUSTOM_OBJFUNC)
1620-
MakePair("TOTAL_EFFICIENCY", TOTAL_EFFICIENCY)
1621-
MakePair("TOTAL_STATIC_EFFICIENCY", TOTAL_STATIC_EFFICIENCY)
1622-
MakePair("TOTAL_PRESSURE_LOSS", TOTAL_PRESSURE_LOSS)
1623-
MakePair("EULERIAN_WORK", EULERIAN_WORK)
1624-
MakePair("TOTAL_ENTHALPY_IN", TOTAL_ENTHALPY_IN)
1625-
MakePair("FLOW_ANGLE_IN", FLOW_ANGLE_IN)
16261611
MakePair("FLOW_ANGLE_OUT", FLOW_ANGLE_OUT)
16271612
MakePair("MASS_FLOW_IN", MASS_FLOW_IN)
1628-
MakePair("MASS_FLOW_OUT", MASS_FLOW_OUT)
1629-
MakePair("PRESSURE_RATIO", PRESSURE_RATIO)
16301613
MakePair("ENTROPY_GENERATION", ENTROPY_GENERATION)
1631-
MakePair("KINETIC_ENERGY_LOSS", KINETIC_ENERGY_LOSS)
16321614
MakePair("REFERENCE_GEOMETRY", REFERENCE_GEOMETRY)
16331615
MakePair("REFERENCE_NODE", REFERENCE_NODE)
16341616
MakePair("VOLUME_FRACTION", VOLUME_FRACTION)
@@ -1637,46 +1619,6 @@ static const MapType<std::string, ENUM_OBJECTIVE> Objective_Map = {
16371619
MakePair("STRESS_PENALTY", STRESS_PENALTY)
16381620
};
16391621

1640-
/*!
1641-
* \brief Types of residual criteria equations
1642-
*/
1643-
enum ENUM_RESIDUAL {
1644-
RHO_RESIDUAL = 1, /*!< \brief Rho equation residual criteria equation. */
1645-
RHO_ENERGY_RESIDUAL = 2 /*!< \brief RhoE equation residual criteria equation. */
1646-
};
1647-
static const MapType<std::string, ENUM_RESIDUAL> Residual_Map = {
1648-
MakePair("RHO", RHO_RESIDUAL)
1649-
MakePair("RHO_ENERGY", RHO_ENERGY_RESIDUAL)
1650-
};
1651-
1652-
/*!
1653-
* \brief Types of residual criteria for structural problems
1654-
*/
1655-
enum ENUM_RESFEM {
1656-
RESFEM_RELATIVE = 1, /*!< \brief Relative criteria: Res/Res0. */
1657-
RESFEM_ABSOLUTE = 2 /*!< \brief Absolute criteria: abs(Res). */
1658-
};
1659-
static const MapType<std::string, ENUM_RESFEM> ResFem_Map = {
1660-
MakePair("RELATIVE", RESFEM_RELATIVE)
1661-
MakePair("ABSOLUTE", RESFEM_ABSOLUTE)
1662-
};
1663-
1664-
/*!
1665-
* \brief Types of sensitivities to compute
1666-
*/
1667-
enum ENUM_SENS {
1668-
SENS_GEOMETRY = 1, /*!< \brief Geometrical sensitivity. */
1669-
SENS_MACH = 2, /*!< \brief Mach number sensitivity. */
1670-
SENS_AOA = 3, /*!< \brief Angle of attack sensitivity. */
1671-
SENS_AOS = 4 /*!< \brief Angle of Sideslip sensitivity. */
1672-
};
1673-
static const MapType<std::string, ENUM_SENS> Sens_Map = {
1674-
MakePair("SENS_GEOMETRY", SENS_GEOMETRY)
1675-
MakePair("SENS_MACH", SENS_MACH)
1676-
MakePair("SENS_AOA", SENS_AOA)
1677-
MakePair("SENS_AOS", SENS_AOS)
1678-
};
1679-
16801622
/*!
16811623
* \brief Types of input file formats
16821624
*/
@@ -1823,32 +1765,6 @@ static const MapType<std::string, MG_CYCLE> MG_Cycle_Map = {
18231765
MakePair("FULLMG_CYCLE", FULLMG_CYCLE)
18241766
};
18251767

1826-
/*!
1827-
* \brief Type of solution output variables
1828-
*/
1829-
enum ENUM_OUTPUT_VARS {
1830-
DENSITY = 1, /*!< \brief Density. */
1831-
VEL_X = 2, /*!< \brief X-component of velocity. */
1832-
VEL_Y = 3, /*!< \brief Y-component of velocity. */
1833-
VEL_Z = 4, /*!< \brief Z-component of velocity. */
1834-
PRESSURE = 5, /*!< \brief Static pressure. */
1835-
MACH = 6, /*!< \brief Mach number. */
1836-
TEMPERATURE = 7, /*!< \brief Temperature. */
1837-
LAM_VISC = 8, /*!< \brief Laminar viscosity. */
1838-
EDDY_VISC = 9 /*!< \brief Eddy viscosity. */
1839-
};
1840-
static const MapType<std::string, ENUM_OUTPUT_VARS> Output_Vars_Map = {
1841-
MakePair("DENSITY", DENSITY)
1842-
MakePair("VEL_X", VEL_X)
1843-
MakePair("VEL_Y", VEL_Y)
1844-
MakePair("VEL_Z", VEL_Z)
1845-
MakePair("PRESSURE", PRESSURE)
1846-
MakePair("MACH", MACH)
1847-
MakePair("TEMPERATURE", TEMPERATURE)
1848-
MakePair("LAM_VISC", LAM_VISC)
1849-
MakePair("EDDY_VISC", EDDY_VISC)
1850-
};
1851-
18521768
/*!
18531769
* \brief Types of design parameterizations
18541770
*/
@@ -2352,35 +2268,35 @@ class COptionBase {
23522268
private:
23532269
std::vector<std::string> value;
23542270
public:
2355-
COptionBase() {};
2356-
virtual ~COptionBase() = 0;
2271+
virtual ~COptionBase() = default;
2272+
2273+
const std::vector<std::string>& GetValue() const {return value;}
23572274

2358-
virtual std::string SetValue(std::vector<std::string> value){this->value = value; return "";}
2359-
std::vector<std::string> GetValue() {return value;}
2275+
virtual std::string SetValue(const std::vector<std::string>& val) {
2276+
value = val;
2277+
return "";
2278+
}
23602279
virtual void SetDefault() = 0;
23612280

2362-
std::string optionCheckMultipleValues(std::vector<std::string> & option_value, std::string type_id, std::string option_name) {
2281+
std::string optionCheckMultipleValues(const std::vector<std::string>& option_value,
2282+
std::string type_id, const std::string& option_name) {
23632283
if (option_value.size() != 1) {
2364-
std::string newString;
2365-
newString.append(option_name);
2284+
std::string newString(option_name);
23662285
newString.append(": multiple values for type ");
23672286
newString.append(type_id);
23682287
return newString;
23692288
}
23702289
return "";
23712290
}
23722291

2373-
std::string badValue(std::vector<std::string> & option_value, std::string type_id, std::string option_name) {
2374-
std::string newString;
2375-
newString.append(option_name);
2292+
std::string badValue(std::string type_id, const std::string& option_name) {
2293+
std::string newString(option_name);
23762294
newString.append(": improper option value for type ");
23772295
newString.append(type_id);
23782296
return newString;
23792297
}
23802298
};
23812299

2382-
inline COptionBase::~COptionBase() {}
2383-
23842300
#ifdef ENABLE_MAPS
23852301
#include "option_structure.inl"
23862302
#endif

0 commit comments

Comments
 (0)