@@ -792,7 +792,6 @@ void CFlowOutput::Add_NearfieldInverseDesignOutput(){
792792
793793void CFlowOutput::Set_NearfieldInverseDesign (CSolver *solver, const CGeometry *geometry, const CConfig *config){
794794
795- bool output = true ;
796795 ofstream EquivArea_file, FuncGrad_file;
797796 unsigned short iMarker = 0 ;
798797 su2double Gamma, auxXCoord, auxYCoord, auxZCoord, InverseDesign = 0.0 , DeltaX, Coord_i, Coord_j, jp1Coord, *Coord = nullptr , MeanFuntion,
@@ -820,15 +819,12 @@ void CFlowOutput::Set_NearfieldInverseDesign(CSolver *solver, const CGeometry *g
820819
821820 if (rank == MASTER_NODE) cout << " Writing Equivalent Area files." << endl ;
822821
823-
824- int nProcessor = size;
825-
826822 unsigned long nLocalVertex_NearField = 0 , MaxLocalVertex_NearField = 0 ;
827823 int iProcessor;
828824
829825 vector<unsigned long > Buffer_Receive_nVertex;
830826 if (rank == MASTER_NODE) {
831- Buffer_Receive_nVertex.resize (nProcessor );
827+ Buffer_Receive_nVertex.resize (size );
832828 }
833829
834830 /* --- Compute the total number of points of the near-field ghost nodes ---*/
@@ -867,12 +863,12 @@ void CFlowOutput::Set_NearfieldInverseDesign(CSolver *solver, const CGeometry *g
867863 vector<su2double> Buffer_Receive_FaceArea;
868864
869865 if (rank == MASTER_NODE) {
870- Buffer_Receive_Xcoord.resize (nProcessor *MaxLocalVertex_NearField);
871- Buffer_Receive_Ycoord.resize (nProcessor *MaxLocalVertex_NearField);
872- Buffer_Receive_Zcoord.resize (nProcessor *MaxLocalVertex_NearField);
873- Buffer_Receive_IdPoint.resize (nProcessor *MaxLocalVertex_NearField);
874- Buffer_Receive_Pressure.resize (nProcessor *MaxLocalVertex_NearField);
875- Buffer_Receive_FaceArea.resize (nProcessor *MaxLocalVertex_NearField);
866+ Buffer_Receive_Xcoord.resize (size *MaxLocalVertex_NearField);
867+ Buffer_Receive_Ycoord.resize (size *MaxLocalVertex_NearField);
868+ Buffer_Receive_Zcoord.resize (size *MaxLocalVertex_NearField);
869+ Buffer_Receive_IdPoint.resize (size *MaxLocalVertex_NearField);
870+ Buffer_Receive_Pressure.resize (size *MaxLocalVertex_NearField);
871+ Buffer_Receive_FaceArea.resize (size *MaxLocalVertex_NearField);
876872 }
877873
878874 const auto nBuffer_Xcoord = MaxLocalVertex_NearField;
@@ -930,7 +926,7 @@ void CFlowOutput::Set_NearfieldInverseDesign(CSolver *solver, const CGeometry *g
930926 vector<su2double> Weight (nVertex_NearField);
931927
932928 nVertex_NearField = 0 ;
933- for (iProcessor = 0 ; iProcessor < nProcessor ; iProcessor++)
929+ for (iProcessor = 0 ; iProcessor < size ; iProcessor++)
934930 for (iVertex = 0 ; iVertex < Buffer_Receive_nVertex[iProcessor]; iVertex++) {
935931 Xcoord[nVertex_NearField] = Buffer_Receive_Xcoord[iProcessor*MaxLocalVertex_NearField+iVertex];
936932 Ycoord[nVertex_NearField] = Buffer_Receive_Ycoord[iProcessor*MaxLocalVertex_NearField+iVertex];
@@ -1069,46 +1065,43 @@ void CFlowOutput::Set_NearfieldInverseDesign(CSolver *solver, const CGeometry *g
10691065
10701066 /* --- Create a file with the equivalent area distribution at each azimuthal angle ---*/
10711067
1072- NearFieldEA_file.precision (15 );
1068+ NearFieldEA_file.precision (config-> GetOutput_Precision () );
10731069
1074- if (output) {
1070+ NearFieldEA_file.open (" Equivalent_Area.dat" , ios::out);
1071+ NearFieldEA_file << " TITLE = \" Equivalent Area evaluation at each azimuthal angle\" " << " \n " ;
10751072
1076- NearFieldEA_file.open (" Equivalent_Area.dat" , ios::out);
1077- NearFieldEA_file << " TITLE = \" Equivalent Area evaluation at each azimuthal angle\" " << " \n " ;
1073+ if (config->GetSystemMeasurements () == US)
1074+ NearFieldEA_file << " VARIABLES = \" Height (in) at r=" << R_Plane*12.0 << " in. (cyl. coord. system)\" " ;
1075+ else
1076+ NearFieldEA_file << " VARIABLES = \" Height (m) at r=" << R_Plane << " m. (cylindrical coordinate system)\" " ;
10781077
1078+ for (iPhiAngle = 0 ; iPhiAngle < PhiAngleList.size (); iPhiAngle++) {
10791079 if (config->GetSystemMeasurements () == US)
1080- NearFieldEA_file << " VARIABLES = \" Height (in) at r= " << R_Plane* 12.0 << " in. (cyl. coord. system) \" " ;
1080+ NearFieldEA_file << " , \" Equivalent Area (ft<sup>2</sup>), <greek>F</greek>= " << PhiAngleList[iPhiAngle] << " deg. \" " ;
10811081 else
1082- NearFieldEA_file << " VARIABLES = \" Height (m) at r=" << R_Plane << " m. (cylindrical coordinate system)\" " ;
1083-
1084- for (iPhiAngle = 0 ; iPhiAngle < PhiAngleList.size (); iPhiAngle++) {
1085- if (config->GetSystemMeasurements () == US)
1086- NearFieldEA_file << " , \" Equivalent Area (ft<sup>2</sup>), <greek>F</greek>= " << PhiAngleList[iPhiAngle] << " deg.\" " ;
1087- else
1088- NearFieldEA_file << " , \" Equivalent Area (m<sup>2</sup>), <greek>F</greek>= " << PhiAngleList[iPhiAngle] << " deg.\" " ;
1089- }
1090-
1091- NearFieldEA_file << " \n " ;
1092- for (iVertex = 0 ; iVertex < EquivArea_PhiAngle[0 ].size (); iVertex++) {
1082+ NearFieldEA_file << " , \" Equivalent Area (m<sup>2</sup>), <greek>F</greek>= " << PhiAngleList[iPhiAngle] << " deg.\" " ;
1083+ }
10931084
1094- su2double XcoordRot = Xcoord_PhiAngle[ 0 ][iVertex]* cos (AoA) - Zcoord_PhiAngle[ 0 ][iVertex]* sin (AoA) ;
1095- su2double XcoordRot_init = Xcoord_PhiAngle[ 0 ][ 0 ]* cos (AoA) - Zcoord_PhiAngle [0 ][ 0 ]* sin (AoA);
1085+ NearFieldEA_file << " \n " ;
1086+ for (iVertex = 0 ; iVertex < EquivArea_PhiAngle [0 ]. size (); iVertex++) {
10961087
1097- if (config->GetSystemMeasurements () == US)
1098- NearFieldEA_file << scientific << (XcoordRot - XcoordRot_init) * 12.0 ;
1099- else
1100- NearFieldEA_file << scientific << (XcoordRot - XcoordRot_init);
1088+ su2double XcoordRot = Xcoord_PhiAngle[0 ][iVertex]*cos (AoA) - Zcoord_PhiAngle[0 ][iVertex]*sin (AoA);
1089+ su2double XcoordRot_init = Xcoord_PhiAngle[0 ][0 ]*cos (AoA) - Zcoord_PhiAngle[0 ][0 ]*sin (AoA);
11011090
1102- for (iPhiAngle = 0 ; iPhiAngle < PhiAngleList.size (); iPhiAngle++) {
1103- NearFieldEA_file << scientific << " , " << EquivArea_PhiAngle[iPhiAngle][iVertex];
1104- }
1105-
1106- NearFieldEA_file << " \n " ;
1091+ if (config->GetSystemMeasurements () == US)
1092+ NearFieldEA_file << scientific << (XcoordRot - XcoordRot_init) * 12.0 ;
1093+ else
1094+ NearFieldEA_file << scientific << (XcoordRot - XcoordRot_init);
11071095
1096+ for (iPhiAngle = 0 ; iPhiAngle < PhiAngleList.size (); iPhiAngle++) {
1097+ NearFieldEA_file << scientific << " , " << EquivArea_PhiAngle[iPhiAngle][iVertex];
11081098 }
1109- NearFieldEA_file.close ();
1099+
1100+ NearFieldEA_file << " \n " ;
11101101
11111102 }
1103+ NearFieldEA_file.close ();
1104+
11121105
11131106 /* --- Read target equivalent area from the configuration file,
11141107 this first implementation requires a complete table (same as the original
@@ -1204,66 +1197,59 @@ void CFlowOutput::Set_NearfieldInverseDesign(CSolver *solver, const CGeometry *g
12041197
12051198 /* --- Write the Nearfield pressure at each Azimuthal PhiAngle ---*/
12061199
1207- EquivArea_file.precision (15 );
1208-
1209- if (output) {
1200+ EquivArea_file.precision (config->GetOutput_Precision ());
12101201
1211- EquivArea_file.open (" nearfield_flow.dat" , ios::out);
1212- EquivArea_file << " TITLE = \" Equivalent Area evaluation at each azimuthal angle\" " << " \n " ;
1202+ EquivArea_file.open (" nearfield_flow.dat" , ios::out);
1203+ EquivArea_file << " TITLE = \" Equivalent Area evaluation at each azimuthal angle\" " << " \n " ;
12131204
1214- if (config->GetSystemMeasurements () == US)
1215- EquivArea_file << " VARIABLES = \" Height (in) at r=" << R_Plane*12.0 << " in. (cyl. coord. system)\" ,\" Equivalent Area (ft<sup>2</sup>)\" ,\" Target Equivalent Area (ft<sup>2</sup>)\" ,\" Cp\" " << " \n " ;
1216- else
1217- EquivArea_file << " VARIABLES = \" Height (m) at r=" << R_Plane << " m. (cylindrical coordinate system)\" ,\" Equivalent Area (m<sup>2</sup>)\" ,\" Target Equivalent Area (m<sup>2</sup>)\" ,\" Cp\" " << " \n " ;
1205+ if (config->GetSystemMeasurements () == US)
1206+ EquivArea_file << " VARIABLES = \" Height (in) at r=" << R_Plane*12.0 << " in. (cyl. coord. system)\" ,\" Equivalent Area (ft<sup>2</sup>)\" ,\" Target Equivalent Area (ft<sup>2</sup>)\" ,\" Cp\" " << " \n " ;
1207+ else
1208+ EquivArea_file << " VARIABLES = \" Height (m) at r=" << R_Plane << " m. (cylindrical coordinate system)\" ,\" Equivalent Area (m<sup>2</sup>)\" ,\" Target Equivalent Area (m<sup>2</sup>)\" ,\" Cp\" " << " \n " ;
12181209
1219- for (iPhiAngle = 0 ; iPhiAngle < PhiAngleList.size (); iPhiAngle++) {
1220- EquivArea_file << fixed << " ZONE T= \" <greek>F</greek>=" << PhiAngleList[iPhiAngle] << " deg.\" " << " \n " ;
1221- for (iVertex = 0 ; iVertex < Xcoord_PhiAngle[iPhiAngle].size (); iVertex++) {
1210+ for (iPhiAngle = 0 ; iPhiAngle < PhiAngleList.size (); iPhiAngle++) {
1211+ EquivArea_file << fixed << " ZONE T= \" <greek>F</greek>=" << PhiAngleList[iPhiAngle] << " deg.\" " << " \n " ;
1212+ for (iVertex = 0 ; iVertex < Xcoord_PhiAngle[iPhiAngle].size (); iVertex++) {
12221213
1223- su2double XcoordRot = Xcoord_PhiAngle[0 ][iVertex]*cos (AoA) - Zcoord_PhiAngle[0 ][iVertex]*sin (AoA);
1224- su2double XcoordRot_init = Xcoord_PhiAngle[0 ][0 ]*cos (AoA) - Zcoord_PhiAngle[0 ][0 ]*sin (AoA);
1214+ su2double XcoordRot = Xcoord_PhiAngle[0 ][iVertex]*cos (AoA) - Zcoord_PhiAngle[0 ][iVertex]*sin (AoA);
1215+ su2double XcoordRot_init = Xcoord_PhiAngle[0 ][0 ]*cos (AoA) - Zcoord_PhiAngle[0 ][0 ]*sin (AoA);
12251216
1226- if (config->GetSystemMeasurements () == US)
1227- EquivArea_file << scientific << (XcoordRot - XcoordRot_init) * 12.0 ;
1228- else
1229- EquivArea_file << scientific << (XcoordRot - XcoordRot_init);
1217+ if (config->GetSystemMeasurements () == US)
1218+ EquivArea_file << scientific << (XcoordRot - XcoordRot_init) * 12.0 ;
1219+ else
1220+ EquivArea_file << scientific << (XcoordRot - XcoordRot_init);
12301221
1231- EquivArea_file << scientific << " , " << EquivArea_PhiAngle[iPhiAngle][iVertex]
1232- << " , " << TargetArea_PhiAngle[iPhiAngle][iVertex] << " , " << (Pressure_PhiAngle[iPhiAngle][iVertex]-Pressure_Inf)/Pressure_Inf << " \n " ;
1233- }
1222+ EquivArea_file << scientific << " , " << EquivArea_PhiAngle[iPhiAngle][iVertex]
1223+ << " , " << TargetArea_PhiAngle[iPhiAngle][iVertex] << " , " << (Pressure_PhiAngle[iPhiAngle][iVertex]-Pressure_Inf)/Pressure_Inf << " \n " ;
12341224 }
1225+ }
12351226
1236- EquivArea_file.close ();
1227+ EquivArea_file.close ();
12371228
1238- }
12391229
12401230 /* --- Write Weight file for adjoint computation ---*/
12411231
1242- FuncGrad_file.precision (15 );
1232+ FuncGrad_file.precision (config->GetOutput_Precision ());
1233+
12431234
1244- if (output) {
1235+ FuncGrad_file. open ( " WeightNF.dat " , ios::out);
12451236
1246- FuncGrad_file.open (" WeightNF.dat" , ios::out);
1237+ FuncGrad_file << scientific << " -1.0" ;
1238+ for (iPhiAngle = 0 ; iPhiAngle < PhiAngleList.size (); iPhiAngle++)
1239+ FuncGrad_file << scientific << " \t " << PhiAngleList[iPhiAngle];
1240+ FuncGrad_file << " \n " ;
12471241
1248- FuncGrad_file << scientific << " -1.0" ;
1242+ for (iVertex = 0 ; iVertex < NearFieldWeight_PhiAngle[0 ].size (); iVertex++) {
1243+ su2double XcoordRot = Xcoord_PhiAngle[0 ][iVertex]*cos (AoA) - Zcoord_PhiAngle[0 ][iVertex]*sin (AoA);
1244+ FuncGrad_file << scientific << XcoordRot;
12491245 for (iPhiAngle = 0 ; iPhiAngle < PhiAngleList.size (); iPhiAngle++)
1250- FuncGrad_file << scientific << " \t " << PhiAngleList [iPhiAngle];
1246+ FuncGrad_file << scientific << " \t " << NearFieldWeight_PhiAngle [iPhiAngle][iVertex ];
12511247 FuncGrad_file << " \n " ;
1252-
1253- for (iVertex = 0 ; iVertex < NearFieldWeight_PhiAngle[0 ].size (); iVertex++) {
1254- su2double XcoordRot = Xcoord_PhiAngle[0 ][iVertex]*cos (AoA) - Zcoord_PhiAngle[0 ][iVertex]*sin (AoA);
1255- FuncGrad_file << scientific << XcoordRot;
1256- for (iPhiAngle = 0 ; iPhiAngle < PhiAngleList.size (); iPhiAngle++)
1257- FuncGrad_file << scientific << " \t " << NearFieldWeight_PhiAngle[iPhiAngle][iVertex];
1258- FuncGrad_file << " \n " ;
1259- }
1260- FuncGrad_file.close ();
1261-
12621248 }
1249+ FuncGrad_file.close ();
12631250
12641251 }
12651252
1266-
12671253 /* --- Send the value of the NearField coefficient to all the processors ---*/
12681254
12691255 SU2_MPI::Bcast (&InverseDesign, 1 , MPI_DOUBLE, MASTER_NODE, SU2_MPI::GetComm ());
0 commit comments