Skip to content

Commit b3e36c2

Browse files
authored
Merge branch 'develop' into feature_OptimalPropeller
2 parents 2d66011 + 16620a2 commit b3e36c2

12 files changed

Lines changed: 216 additions & 312 deletions

File tree

SU2_CFD/include/output/filewriter/CSU2FileWriter.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ class CSU2FileWriter final: public CFileWriter{
4444
*/
4545
CSU2FileWriter(string valFileName, CParallelDataSorter* valDataSorter);
4646

47-
/*!
48-
* \brief Destructor
49-
*/
50-
~CSU2FileWriter() override;
51-
5247
/*!
5348
* \brief Write sorted data to file in SU2 ASCII file format
5449
*/

SU2_CFD/include/output/filewriter/CSU2MeshFileWriter.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ class CSU2MeshFileWriter final: public CFileWriter{
5050
CSU2MeshFileWriter(string valFileName, CParallelDataSorter* valDataSorter,
5151
unsigned short valiZone, unsigned short valnZone);
5252

53-
/*!
54-
* \brief Destructor
55-
*/
56-
~CSU2MeshFileWriter() override;
57-
5853
/*!
5954
* \brief Write sorted data to file in SU2 mesh file format
6055
* \param[in] - The name of the file

SU2_CFD/include/solvers/CFVMFlowSolverBase.inl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1963,15 +1963,15 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
19631963

19641964
unsigned long iVertex, iPoint, iPointNormal;
19651965
unsigned short iMarker, iMarker_Monitoring, iDim, jDim;
1966-
unsigned short T_INDEX, TVE_INDEX, VEL_INDEX;
1966+
unsigned short T_INDEX = 0, TVE_INDEX = 0, VEL_INDEX = 0;
19671967
su2double Viscosity = 0.0, div_vel, WallDist[3] = {0.0}, Area, WallShearStress, TauNormal, RefTemp, RefVel2 = 0.0,
19681968
RefDensity = 0.0, GradTemperature, Density = 0.0, WallDistMod, FrictionVel, Mach2Vel, Mach_Motion,
19691969
UnitNormal[3] = {0.0}, TauElem[3] = {0.0}, TauTangent[3] = {0.0}, Tau[3][3] = {{0.0}}, Cp,
1970-
thermal_conductivity, thermal_conductivity_tr, thermal_conductivity_ve,
1970+
thermal_conductivity, thermal_conductivity_tr, thermal_conductivity_ve = 0.0,
19711971
MaxNorm = 8.0, Grad_Vel[3][3] = {{0.0}}, Grad_Temp[3] = {0.0}, AxiFactor,
19721972
delta[3][3] = {{1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}};
19731973
const su2double *Coord = nullptr, *Coord_Normal = nullptr, *Normal = nullptr;
1974-
su2double **Grad_PrimVar, dTn, dTven;
1974+
su2double **Grad_PrimVar = nullptr, dTn, dTven;
19751975

19761976
string Marker_Tag, Monitoring_Tag;
19771977

SU2_CFD/include/solvers/CNEMOEulerSolver.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ class CNEMOEulerSolver : public CFVMFlowSolverBase<CNEMOEulerVariable, COMPRESSI
4343

4444
unsigned short
4545
nSpecies; /*!< \brief Number of species in the gas mixture. */
46-
47-
su2double
46+
47+
su2double
4848
Energy_ve_Inf, /*!< \brief Vib.-el. free stream energy. */
4949
Temperature_ve_Inf; /*!< \brief Vib.-el. free stream temperature. */
5050
const su2double *MassFrac_Inf; /*!< \brief Free stream species mass fraction. */
@@ -83,7 +83,7 @@ class CNEMOEulerSolver : public CFVMFlowSolverBase<CNEMOEulerVariable, COMPRESSI
8383
* \param[in] config - Definition of the particular problem.
8484
*/
8585
void SetMax_Eigenvalue(CGeometry *geometry, CConfig *config);
86-
86+
8787
/*!
8888
* \brief Compute the time step for solving the Euler equations.
8989
* \param[in] geometry - Geometrical definition of the problem.
@@ -176,7 +176,7 @@ class CNEMOEulerSolver : public CFVMFlowSolverBase<CNEMOEulerVariable, COMPRESSI
176176
* \return - The number of non-physical points.
177177
*/
178178
unsigned long SetPrimitive_Variables(CSolver **solver_container,
179-
bool Output);
179+
bool Output);
180180

181181
/*!
182182
* \brief Compute the preconditioner for convergence acceleration by Roe-Turkel method.

SU2_CFD/include/variables/CVariable.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
#include <cstdlib>
3737

3838
#include "../../../Common/include/CConfig.hpp"
39-
#include "../fluid/CFluidModel.hpp"
40-
#include "../fluid/CNEMOGas.hpp"
4139
#include "../../../Common/include/toolboxes/C2DContainer.hpp"
4240

41+
class CFluidModel;
42+
class CNEMOGas;
4343

4444
using namespace std;
4545

SU2_CFD/src/output/filewriter/CSU2FileWriter.cpp

Lines changed: 20 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -32,79 +32,51 @@ const string CSU2FileWriter::fileExt = ".csv";
3232
CSU2FileWriter::CSU2FileWriter(string valFileName, CParallelDataSorter *valDataSorter) :
3333
CFileWriter(std::move(valFileName), valDataSorter, fileExt){}
3434

35-
36-
CSU2FileWriter::~CSU2FileWriter(){
37-
38-
}
39-
4035
void CSU2FileWriter::Write_Data(){
4136

42-
/*--- Local variables ---*/
43-
44-
unsigned short iVar;
45-
unsigned long iPoint;
46-
4737
ofstream restart_file;
48-
49-
int iProcessor;
5038
const vector<string> fieldNames = dataSorter->GetFieldNames();
5139

5240
/*--- Set a timer for the file writing. ---*/
5341

5442
startTime = SU2_MPI::Wtime();
5543

56-
/*--- Only the master node writes the header. ---*/
44+
/*--- Only the FIRST node writes the header (it does not matter if that is the master). ---*/
5745

58-
if (rank == MASTER_NODE) {
59-
restart_file.open(fileName.c_str(), ios::out);
60-
restart_file.precision(15);
46+
if (rank == 0) {
47+
restart_file.open(fileName);
6148
restart_file << "\"PointID\"";
62-
for (iVar = 0; iVar < fieldNames.size()-1; iVar++)
63-
restart_file << ",\"" << fieldNames[iVar] << "\"";
64-
restart_file << ",\"" << fieldNames[fieldNames.size()-1] << "\"" << endl;
49+
for (auto& field : fieldNames) restart_file << ",\"" << field << "\"";
50+
restart_file << "\n";
6551
restart_file.close();
6652
}
6753

68-
#ifdef HAVE_MPI
69-
SU2_MPI::Barrier(MPI_COMM_WORLD);
70-
#endif
71-
72-
/*--- All processors open the file. ---*/
54+
/*--- Serialize the writes to the restart file. ---*/
7355

74-
restart_file.open(fileName.c_str(), ios::out | ios::app);
75-
restart_file.precision(15);
76-
77-
/*--- Write the restart file in parallel, processor by processor. ---*/
78-
79-
unsigned long myPoint = 0, Global_Index;
80-
for (iProcessor = 0; iProcessor < size; iProcessor++) {
56+
for (int iProcessor = 0; iProcessor < size; iProcessor++) {
8157
if (rank == iProcessor) {
82-
for (iPoint = 0; iPoint < dataSorter->GetnPoints(); iPoint++) {
58+
restart_file.open(fileName, ios::app);
59+
restart_file.precision(15);
8360

84-
/*--- Global Index of the current point. (note outer loop over procs) ---*/
61+
for (auto iPoint = 0ul; iPoint < dataSorter->GetnPoints(); iPoint++) {
8562

86-
Global_Index = dataSorter->GetGlobalIndex(iPoint);
63+
/*--- Write global index of the current point. ---*/
8764

88-
/*--- Write global index. (note outer loop over procs) ---*/
65+
restart_file << dataSorter->GetGlobalIndex(iPoint);
8966

90-
restart_file << Global_Index << ", ";
91-
myPoint++;
67+
/*--- Loop over the variables and write the values to file. ---*/
9268

93-
/*--- Loop over the variables and write the values to file ---*/
94-
95-
for (iVar = 0; iVar < fieldNames.size()-1; iVar++) {
96-
restart_file << scientific << dataSorter->GetData(iVar, iPoint) << ", ";
97-
}
98-
restart_file << scientific << dataSorter->GetData(fieldNames.size()-1, iPoint) << "\n";
69+
for (size_t iVar = 0; iVar < fieldNames.size(); iVar++)
70+
restart_file << ", " << scientific << dataSorter->GetData(iVar, iPoint);
71+
restart_file << "\n";
9972
}
10073

74+
restart_file.close();
10175
}
102-
/*--- Flush the file and wait for all processors to arrive. ---*/
103-
restart_file.flush();
104-
#ifdef HAVE_MPI
105-
SU2_MPI::Barrier(MPI_COMM_WORLD);
106-
#endif
10776

77+
/*--- Wait for iProcessor to finish and close the file. ---*/
78+
79+
SU2_MPI::Barrier(MPI_COMM_WORLD);
10880
}
10981

11082
/*--- Compute and store the write time. ---*/
@@ -120,8 +92,4 @@ void CSU2FileWriter::Write_Data(){
12092
/*--- Compute and store the bandwidth ---*/
12193

12294
bandwidth = fileSize/(1.0e6)/usedTime;
123-
124-
/*--- All processors close the file. ---*/
125-
126-
restart_file.close();
12795
}

0 commit comments

Comments
 (0)