@@ -811,36 +811,42 @@ public:
811811
812812class 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
818818public:
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
908909class COptionFFDDegree : public COptionBase {
909910 string name;
910- unsigned short & nFFD;
911- unsigned short ** & DegreeFFD;
911+ unsigned short & nFFD;
912+ unsigned short ** & DegreeFFD;
912913
913914public:
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
996995class 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
17651764class 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
17731772public:
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};
0 commit comments