Skip to content

Commit 2082383

Browse files
committed
fixes and more COptions
1 parent 8772194 commit 2082383

3 files changed

Lines changed: 84 additions & 128 deletions

File tree

Common/include/CConfig.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6598,13 +6598,6 @@ class CConfig {
65986598
*/
65996599
const su2double* GetInlet_Velocity(string val_index) const;
66006600

6601-
/*!
6602-
* \brief Get the mass fraction vector at a supersonic inlet boundary.
6603-
* \param[in] val_index - Index corresponding to the inlet boundary.
6604-
* \return The inlet mass fraction vector - NEMO only.
6605-
*/
6606-
const su2double* GetInlet_MassFrac(string val_index) const;
6607-
66086601
/*!
66096602
* \brief Get the total pressure at an inlet boundary.
66106603
* \param[in] val_index - Index corresponding to the inlet boundary.

Common/include/option_structure.inl

Lines changed: 82 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -811,36 +811,42 @@ public:
811811

812812
class COptionFFDDef : public COptionBase {
813813
string name;
814-
unsigned short & nFFD;
815-
su2double ** & CoordFFD;
816-
string * & FFDTag;
814+
unsigned short& nFFD;
815+
su2double**& CoordFFD;
816+
string*& FFDTag;
817817

818818
public:
819-
COptionFFDDef(string option_field_name, unsigned short & nFFD_field, su2double** & coordFFD_field, string* & FFDTag_field) : nFFD(nFFD_field), CoordFFD(coordFFD_field), FFDTag(FFDTag_field) {
820-
this->name = option_field_name;
821-
}
822-
823-
~COptionFFDDef() override {};
819+
COptionFFDDef(string option_field_name, unsigned short& nFFD_field, su2double**& coordFFD_field, string*& FFDTag_field)
820+
: name(option_field_name),
821+
nFFD(nFFD_field),
822+
CoordFFD(coordFFD_field),
823+
FFDTag(FFDTag_field) {
824+
nFFD = 0;
825+
CoordFFD = nullptr;
826+
FFDTag = nullptr;
827+
}
828+
829+
~COptionFFDDef() {
830+
for (unsigned short i = 0; i < nFFD; ++i) {
831+
delete[] CoordFFD[i];
832+
}
833+
delete[] CoordFFD;
834+
CoordFFD = nullptr;
835+
delete[] FFDTag;
836+
FFDTag = nullptr;
837+
};
824838

825839
string SetValue(const vector<string>& option_value) override {
826840
COptionBase::SetValue(option_value);
827841
if ((option_value.size() == 1) && (option_value[0].compare("NONE") == 0)) {
828-
this->nFFD = 0;
829842
return "";
830843
}
831-
832844
// Cannot have ; at the beginning or the end
833845
if (option_value[0].compare(";") == 0) {
834-
string newstring;
835-
newstring.append(this->name);
836-
newstring.append(": may not have beginning semicolon");
837-
return newstring;
846+
return name + ": may not have beginning semicolon";
838847
}
839848
if (option_value[option_value.size()-1].compare(";") == 0) {
840-
string newstring;
841-
newstring.append(this->name);
842-
newstring.append(": may not have ending semicolon");
843-
return newstring;
849+
return name + ": may not have ending semicolon";
844850
}
845851

846852

@@ -897,45 +903,42 @@ public:
897903
return "";
898904
}
899905

900-
void SetDefault() override {
901-
this->nFFD = 0;
902-
this->CoordFFD = nullptr;
903-
this->FFDTag = nullptr;
904-
}
905-
906+
void SetDefault() override {}
906907
};
907908

908909
class COptionFFDDegree : public COptionBase {
909910
string name;
910-
unsigned short & nFFD;
911-
unsigned short ** & DegreeFFD;
911+
unsigned short& nFFD;
912+
unsigned short**& DegreeFFD;
912913

913914
public:
914-
COptionFFDDegree(string option_field_name, unsigned short & nFFD_field, unsigned short** & degreeFFD_field) : nFFD(nFFD_field), DegreeFFD(degreeFFD_field) {
915-
this->name = option_field_name;
915+
COptionFFDDegree(string option_field_name, unsigned short& nFFD_field, unsigned short**& degreeFFD_field)
916+
: name(option_field_name),
917+
nFFD(nFFD_field),
918+
DegreeFFD(degreeFFD_field) {
919+
nFFD = 0;
920+
DegreeFFD = nullptr;
916921
}
917922

918-
~COptionFFDDegree() override {};
923+
~COptionFFDDegree() {
924+
for (unsigned short i = 0; i < nFFD; ++i) {
925+
delete[] DegreeFFD[i];
926+
}
927+
delete[] DegreeFFD;
928+
DegreeFFD = nullptr;
929+
};
919930

920931
string SetValue(const vector<string>& option_value) override {
921932
COptionBase::SetValue(option_value);
922933
if ((option_value.size() == 1) && (option_value[0].compare("NONE") == 0)) {
923-
this->nFFD = 0;
924934
return "";
925935
}
926-
927936
// Cannot have ; at the beginning or the end
928937
if (option_value[0].compare(";") == 0) {
929-
string newstring;
930-
newstring.append(this->name);
931-
newstring.append(": may not have beginning semicolon");
932-
return newstring;
938+
return name + ": may not have beginning semicolon";
933939
}
934940
if (option_value[option_value.size()-1].compare(";") == 0) {
935-
string newstring;
936-
newstring.append(this->name);
937-
newstring.append(": may not have ending semicolon");
938-
return newstring;
941+
return name + ": may not have ending semicolon";
939942
}
940943

941944

@@ -986,11 +989,7 @@ public:
986989
return "";
987990
}
988991

989-
void SetDefault() override {
990-
this->nFFD = 0;
991-
this->DegreeFFD = nullptr;
992-
}
993-
992+
void SetDefault() override {}
994993
};
995994

996995
class COptionInlet : public COptionBase {
@@ -1498,16 +1497,17 @@ public:
14981497
rot_center(RotCenter),
14991498
rot_angles(RotAngles),
15001499
translation(Translation) {
1500+
size = 0;
15011501
COptionPeriodic::SetDefault();
15021502
}
15031503

15041504
~COptionPeriodic() {
15051505
delete[] marker_bound;
15061506
delete[] marker_donor;
15071507
for (unsigned short i = 0; i < size; ++i) {
1508-
delete[] rot_center;
1509-
delete[] rot_angles;
1510-
delete[] translation;
1508+
delete[] rot_center[i];
1509+
delete[] rot_angles[i];
1510+
delete[] translation[i];
15111511
}
15121512
delete[] rot_center;
15131513
delete[] rot_angles;
@@ -1534,7 +1534,7 @@ public:
15341534
rot_center = new su2double*[nVals];
15351535
rot_angles = new su2double*[nVals];
15361536
translation = new su2double*[nVals];
1537-
for (unsigned long i = 0; i < nVals; i++) {
1537+
for (unsigned short i = 0; i < nVals; i++) {
15381538
rot_center[i] = new su2double[3];
15391539
rot_angles[i] = new su2double[3];
15401540
translation[i] = new su2double[3];
@@ -1585,7 +1585,6 @@ public:
15851585
}
15861586

15871587
void SetDefault() override {
1588-
size = 0;
15891588
marker_bound = nullptr;
15901589
marker_donor = nullptr;
15911590
rot_center = nullptr;
@@ -1764,29 +1763,42 @@ public:
17641763

17651764
class COptionWallFunction : public COptionBase {
17661765
string name; // identifier for the option
1767-
unsigned short &nMarkers;
1768-
string* &markers;
1769-
WALL_FUNCTIONS* &walltype;
1770-
unsigned short** &intInfo;
1771-
su2double** &doubleInfo;
1766+
unsigned short& nMarkers;
1767+
string*& markers;
1768+
WALL_FUNCTIONS*& walltype;
1769+
unsigned short**& intInfo;
1770+
su2double**& doubleInfo;
17721771

17731772
public:
1774-
COptionWallFunction(const string name, unsigned short &nMarker_WF,
1775-
string* &Marker_WF, WALL_FUNCTIONS* &type_WF,
1776-
unsigned short** &intInfo_WF, su2double** &doubleInfo_WF) :
1777-
nMarkers(nMarker_WF), markers(Marker_WF), walltype(type_WF),
1778-
intInfo(intInfo_WF), doubleInfo(doubleInfo_WF) {
1779-
this->name = name;
1773+
COptionWallFunction(const string name_WF, unsigned short& nMarker_WF, string*& Marker_WF, WALL_FUNCTIONS*& type_WF,
1774+
unsigned short**& intInfo_WF, su2double**& doubleInfo_WF)
1775+
: name(name_WF),
1776+
nMarkers(nMarker_WF),
1777+
markers(Marker_WF),
1778+
walltype(type_WF),
1779+
intInfo(intInfo_WF),
1780+
doubleInfo(doubleInfo_WF) {
1781+
nMarkers = 0;
1782+
COptionWallFunction::SetDefault();
1783+
}
1784+
1785+
~COptionWallFunction() {
1786+
delete[] markers;
1787+
delete[] walltype;
1788+
for (unsigned short i = 0; i < nMarkers; ++i) {
1789+
delete[] intInfo[i];
1790+
delete[] doubleInfo[i];
1791+
}
1792+
delete[] intInfo;
1793+
delete[] doubleInfo;
1794+
COptionWallFunction::SetDefault();
17801795
}
17811796

1782-
~COptionWallFunction() override{}
1783-
17841797
string SetValue(const vector<string>& option_value) override {
17851798
COptionBase::SetValue(option_value);
17861799
/*--- First check if NONE is specified. ---*/
1787-
unsigned short totalSize = option_value.size();
1800+
const unsigned short totalSize = option_value.size();
17881801
if ((totalSize == 1) && (option_value[0].compare("NONE") == 0)) {
1789-
this->SetDefault();
17901802
return "";
17911803
}
17921804

@@ -1857,13 +1869,8 @@ public:
18571869
this->nMarkers = nVals;
18581870
this->markers = new string[nVals];
18591871
this->walltype = new WALL_FUNCTIONS[nVals];
1860-
this->intInfo = new unsigned short*[nVals];
1861-
this->doubleInfo = new su2double*[nVals];
1862-
1863-
for (unsigned short i=0; i<nVals; i++) {
1864-
this->intInfo[i] = nullptr;
1865-
this->doubleInfo[i] = nullptr;
1866-
}
1872+
this->intInfo = new unsigned short*[nVals]();
1873+
this->doubleInfo = new su2double*[nVals]();
18671874

18681875
/*--- Loop over the wall markers and store the info in the
18691876
appropriate arrays. ---*/
@@ -1975,10 +1982,9 @@ public:
19751982
}
19761983

19771984
void SetDefault() override {
1978-
this->nMarkers = 0;
1979-
this->markers = nullptr;
1980-
this->walltype = nullptr;
1981-
this->intInfo = nullptr;
1982-
this->doubleInfo = nullptr;
1985+
markers = nullptr;
1986+
walltype = nullptr;
1987+
intInfo = nullptr;
1988+
doubleInfo = nullptr;
19831989
}
19841990
};

Common/src/CConfig.cpp

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ void CConfig::SetPointersNull(void) {
858858

859859
Inlet_Ttotal = nullptr; Inlet_Ptotal = nullptr;
860860
Inlet_FlowDir = nullptr; Inlet_Temperature = nullptr; Inlet_Pressure = nullptr;
861-
Inlet_Velocity = nullptr; Inlet_MassFrac = nullptr;
861+
Inlet_Velocity = nullptr;
862862
Outlet_Pressure = nullptr; Inlet_SpeciesVal = nullptr;
863863

864864
/*--- Engine Boundary Condition settings ---*/
@@ -7607,7 +7607,7 @@ void CConfig::SetSurface_Movement(unsigned short iMarker, unsigned short kind_mo
76077607

76087608
CConfig::~CConfig() {
76097609

7610-
unsigned long iDV, iMarker, iFFD;
7610+
unsigned long iDV, iMarker;
76117611

76127612
/*--- Delete all of the option objects in the global option map ---*/
76137613

@@ -7683,29 +7683,10 @@ CConfig::~CConfig() {
76837683
delete[] Marker_CfgFile_SobolevBC;
76847684
delete[] Marker_All_SobolevBC;
76857685

7686-
delete[] Marker_WallFunctions;
76877686
delete[] Marker_All_SendRecv;
76887687

7689-
delete[] Kind_WallFunctions;
7690-
76917688
delete[] Kind_Wall;
76927689

7693-
if (IntInfo_WallFunctions != nullptr) {
7694-
for (iMarker = 0; iMarker < nMarker_WallFunctions; ++iMarker) {
7695-
if (IntInfo_WallFunctions[iMarker] != nullptr)
7696-
delete[] IntInfo_WallFunctions[iMarker];
7697-
}
7698-
delete[] IntInfo_WallFunctions;
7699-
}
7700-
7701-
if (DoubleInfo_WallFunctions != nullptr) {
7702-
for (iMarker = 0; iMarker < nMarker_WallFunctions; ++iMarker) {
7703-
if (DoubleInfo_WallFunctions[iMarker] != nullptr)
7704-
delete[] DoubleInfo_WallFunctions[iMarker];
7705-
}
7706-
delete[] DoubleInfo_WallFunctions;
7707-
}
7708-
77097690
if (DV_Value != nullptr) {
77107691
for (iDV = 0; iDV < nDV; iDV++) delete[] DV_Value[iDV];
77117692
delete [] DV_Value;
@@ -7716,16 +7697,6 @@ CConfig::~CConfig() {
77167697
delete [] ParamDV;
77177698
}
77187699

7719-
if (CoordFFDBox != nullptr) {
7720-
for (iFFD = 0; iFFD < nFFDBox; iFFD++) delete[] CoordFFDBox[iFFD];
7721-
delete [] CoordFFDBox;
7722-
}
7723-
7724-
if (DegreeFFDBox != nullptr) {
7725-
for (iFFD = 0; iFFD < nFFDBox; iFFD++) delete[] DegreeFFDBox[iFFD];
7726-
delete [] DegreeFFDBox;
7727-
}
7728-
77297700
delete[] Exhaust_Pressure;
77307701
delete[] Exhaust_Temperature;
77317702
delete[] Exhaust_MassFlow;
@@ -7813,12 +7784,6 @@ CConfig::~CConfig() {
78137784
delete[] Surface_IDC_Mach;
78147785
delete[] Surface_IDR;
78157786

7816-
if (Inlet_MassFrac != nullptr) {
7817-
for (iMarker = 0; iMarker < nMarker_Supersonic_Inlet; iMarker++)
7818-
delete [] Inlet_MassFrac[iMarker];
7819-
delete [] Inlet_MassFrac;
7820-
}
7821-
78227787
if (Riemann_FlowDir != nullptr) {
78237788
for (iMarker = 0; iMarker < nMarker_Riemann; iMarker++)
78247789
delete [] Riemann_FlowDir[iMarker];
@@ -7838,7 +7803,6 @@ CConfig::~CConfig() {
78387803

78397804
delete [] FFDTag;
78407805
delete [] nDV_Value;
7841-
delete [] TagFFDBox;
78427806

78437807
delete [] Kind_Data_Riemann;
78447808
delete [] Riemann_Var1;
@@ -8577,13 +8541,6 @@ const su2double* CConfig::GetInlet_Velocity(string val_marker) const {
85778541
return Inlet_Velocity[iMarker_Supersonic_Inlet];
85788542
}
85798543

8580-
const su2double* CConfig::GetInlet_MassFrac(string val_marker) const {
8581-
unsigned short iMarker_Supersonic_Inlet;
8582-
for (iMarker_Supersonic_Inlet = 0; iMarker_Supersonic_Inlet < nMarker_Supersonic_Inlet; iMarker_Supersonic_Inlet++)
8583-
if (Marker_Supersonic_Inlet[iMarker_Supersonic_Inlet] == val_marker) break;
8584-
return Inlet_MassFrac[iMarker_Supersonic_Inlet];
8585-
}
8586-
85878544
const su2double* CConfig::GetInlet_SpeciesVal(string val_marker) const {
85888545
unsigned short iMarker_Inlet_Species;
85898546
for (iMarker_Inlet_Species = 0; iMarker_Inlet_Species < nMarker_Inlet_Species; iMarker_Inlet_Species++)

0 commit comments

Comments
 (0)