Skip to content

Commit c008fd4

Browse files
authored
Merge pull request #1176 from su2code/stress_penalty
Structural stress penalty function for optimization, fix some CConfig problems
2 parents 0baf91d + 30b2554 commit c008fd4

35 files changed

Lines changed: 502 additions & 832 deletions

File tree

Common/include/CConfig.hpp

Lines changed: 99 additions & 169 deletions
Large diffs are not rendered by default.

Common/include/geometry/elements/CElement.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,13 @@ class CElement {
470470
AD::SetPreaccOut(Mab.data(), nNodes*nNodes);
471471
}
472472

473+
/*!
474+
* \brief Register the dead load as a pre-accumulation output.
475+
*/
476+
inline void SetPreaccOut_FDL_a(void) {
477+
AD::SetPreaccOut(FDL_a.data(), nNodes*nDim);
478+
}
479+
473480
};
474481

475482
/*!

Common/include/option_structure.hpp

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ enum SU2_COMPONENT {
6767
SU2_CFD = 1, /*!< \brief Running the SU2_CFD software. */
6868
SU2_DEF = 2, /*!< \brief Running the SU2_DEF software. */
6969
SU2_DOT = 3, /*!< \brief Running the SU2_DOT software. */
70-
SU2_MSH = 4, /*!< \brief Running the SU2_MSH software. */
7170
SU2_GEO = 5, /*!< \brief Running the SU2_GEO software. */
7271
SU2_SOL = 6 /*!< \brief Running the SU2_SOL software. */
7372
};
@@ -1524,7 +1523,8 @@ enum ENUM_OBJECTIVE {
15241523
REFERENCE_NODE = 61, /*!< \brief Objective function defined as the difference of a particular node respect to a reference position. */
15251524
VOLUME_FRACTION = 62, /*!< \brief Volume average physical density, for material-based topology optimization applications. */
15261525
TOPOL_DISCRETENESS = 63, /*!< \brief Measure of the discreteness of the current topology. */
1527-
TOPOL_COMPLIANCE = 64 /*!< \brief Measure of the discreteness of the current topology. */
1526+
TOPOL_COMPLIANCE = 64, /*!< \brief Measure of the discreteness of the current topology. */
1527+
STRESS_PENALTY = 65, /*!< \brief Penalty function of VM stresses above a maximum value. */
15281528
};
15291529
static const MapType<string, ENUM_OBJECTIVE> Objective_Map = {
15301530
MakePair("DRAG", DRAG_COEFFICIENT)
@@ -1575,6 +1575,7 @@ static const MapType<string, ENUM_OBJECTIVE> Objective_Map = {
15751575
MakePair("VOLUME_FRACTION", VOLUME_FRACTION)
15761576
MakePair("TOPOL_DISCRETENESS", TOPOL_DISCRETENESS)
15771577
MakePair("TOPOL_COMPLIANCE", TOPOL_COMPLIANCE)
1578+
MakePair("STRESS_PENALTY", STRESS_PENALTY)
15781579
};
15791580

15801581
/*!
@@ -1617,40 +1618,6 @@ static const MapType<string, ENUM_SENS> Sens_Map = {
16171618
MakePair("SENS_AOS", SENS_AOS)
16181619
};
16191620

1620-
/*!
1621-
* \brief Types of grid adaptation/refinement
1622-
*/
1623-
enum ENUM_ADAPT {
1624-
NO_ADAPT = 0, /*!< \brief No grid adaptation. */
1625-
FULL = 1, /*!< \brief Do a complete grid refinement of all the computational grids. */
1626-
FULL_FLOW = 2, /*!< \brief Do a complete grid refinement of the flow grid. */
1627-
FULL_ADJOINT = 3, /*!< \brief Do a complete grid refinement of the adjoint grid. */
1628-
GRAD_FLOW = 5, /*!< \brief Do a gradient based grid adaptation of the flow grid. */
1629-
GRAD_ADJOINT = 6, /*!< \brief Do a gradient based grid adaptation of the adjoint grid. */
1630-
GRAD_FLOW_ADJ = 7, /*!< \brief Do a gradient based grid adaptation of the flow and adjoint grid. */
1631-
COMPUTABLE = 9, /*!< \brief Apply a computable error grid adaptation. */
1632-
REMAINING = 10, /*!< \brief Apply a remaining error grid adaptation. */
1633-
WAKE = 12, /*!< \brief Do a grid refinement on the wake. */
1634-
SMOOTHING = 14, /*!< \brief Do a grid smoothing of the geometry. */
1635-
SUPERSONIC_SHOCK = 15, /*!< \brief Do a grid smoothing. */
1636-
PERIODIC = 17 /*!< \brief Add the periodic halo cells. */
1637-
};
1638-
static const MapType<string, ENUM_ADAPT> Adapt_Map = {
1639-
MakePair("NONE", NO_ADAPT)
1640-
MakePair("FULL", FULL)
1641-
MakePair("FULL_FLOW", FULL_FLOW)
1642-
MakePair("FULL_ADJOINT", FULL_ADJOINT)
1643-
MakePair("GRAD_FLOW", GRAD_FLOW)
1644-
MakePair("GRAD_ADJOINT", GRAD_ADJOINT)
1645-
MakePair("GRAD_FLOW_ADJ", GRAD_FLOW_ADJ)
1646-
MakePair("COMPUTABLE", COMPUTABLE)
1647-
MakePair("REMAINING", REMAINING)
1648-
MakePair("WAKE", WAKE)
1649-
MakePair("SMOOTHING", SMOOTHING)
1650-
MakePair("SUPERSONIC_SHOCK", SUPERSONIC_SHOCK)
1651-
MakePair("PERIODIC", PERIODIC)
1652-
};
1653-
16541621
/*!
16551622
* \brief Types of input file formats
16561623
*/

Common/include/option_structure.inl

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -335,25 +335,19 @@ public:
335335
};
336336

337337
class COptionDoubleArray : public COptionBase {
338-
su2double * & field; // Reference to the feildname
339-
string name; // identifier for the option
340-
const int size;
341-
su2double * def;
342-
su2double * vals;
343-
su2double * default_value;
338+
string name; // Identifier for the option
339+
const int size; // Number of elements
340+
su2double* field; // Reference to the fieldname
344341

345342
public:
346-
COptionDoubleArray(string option_field_name, const int list_size, su2double * & option_field, su2double * default_value) : field(option_field), size(list_size) {
347-
this->name = option_field_name;
348-
this->default_value = default_value;
349-
def = nullptr;
350-
vals = nullptr;
343+
COptionDoubleArray(string option_field_name, const int list_size, su2double* option_field) :
344+
name(option_field_name),
345+
size(list_size),
346+
field(option_field) {
351347
}
352348

353-
~COptionDoubleArray() override {
354-
delete [] def;
355-
delete [] vals;
356-
};
349+
~COptionDoubleArray() override {};
350+
357351
string SetValue(vector<string> option_value) override {
358352
COptionBase::SetValue(option_value);
359353
// Check that the size is correct
@@ -371,27 +365,16 @@ public:
371365
newstring.append(" found");
372366
return newstring;
373367
}
374-
vals = new su2double[this->size];
375368
for (int i = 0; i < this->size; i++) {
376369
istringstream is(option_value[i]);
377-
su2double val;
378-
if (!(is >> val)) {
379-
delete [] vals;
370+
if (!(is >> field[i])) {
380371
return badValue(option_value, "su2double array", this->name);
381372
}
382-
vals[i] = val;
383373
}
384-
this->field = vals;
385374
return "";
386375
}
387376

388-
void SetDefault() override {
389-
def = new su2double [size];
390-
for (int i = 0; i < size; i++) {
391-
def[i] = default_value[i];
392-
}
393-
this->field = def;
394-
}
377+
void SetDefault() override {}
395378
};
396379

397380
class COptionDoubleList : public COptionBase {

0 commit comments

Comments
 (0)