Skip to content

Commit 74ce20b

Browse files
committed
add CGNS import check and clean up code
1 parent 963e7c7 commit 74ce20b

3 files changed

Lines changed: 121 additions & 168 deletions

File tree

Common/src/CConfig.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3237,6 +3237,16 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
32373237
}
32383238
#endif
32393239

3240+
/*--- Check if SU2 was build with CGNS support, as that is required for CGNS output. ---*/
3241+
#ifndef HAVE_CGNS
3242+
for (unsigned short iVolumeFile = 0; iVolumeFile < nVolumeOutputFiles; iVolumeFile++) {
3243+
if (VolumeOutputFiles[iVolumeFile] == CGNS ||
3244+
VolumeOutputFiles[iVolumeFile] == SURFACE_CGNS) {
3245+
SU2_MPI::Error(string("CGNS file requested in option OUTPUT_FILES but SU2 was built without CGNS support.\n"),CURRENT_FUNCTION);
3246+
}
3247+
}
3248+
#endif
3249+
32403250
/*--- STL_BINARY output not implelemted yet, but already a value in option_structure.hpp---*/
32413251
for (unsigned short iVolumeFile = 0; iVolumeFile < nVolumeOutputFiles; iVolumeFile++) {
32423252
if (VolumeOutputFiles[iVolumeFile] == STL_BINARY){

SU2_CFD/include/output/filewriter/CCGNSFileWriter.hpp

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
#include "cgnslib.h"
3232
#endif
3333

34+
/*--- Define data precision of output (float or double). ---*/
35+
typedef float dataPrecision;
36+
3437
#include "CFileWriter.hpp"
3538

3639
class CCGNSFileWriter final : public CFileWriter {
@@ -46,14 +49,20 @@ class CCGNSFileWriter final : public CFileWriter {
4649
int nZones; /*!< \brief Total number of zones in the CGNS file. */
4750
int nSections; /*!< \brief Total number of sections in the CGNS file. */
4851

49-
unsigned short nDim; /*!< \brief Problem dimension. */
50-
int nLocalPoints; /*!< \brief Local number of points. */
51-
int GlobalPoint; /*!< \brief Total number of points. */
52-
int GlobalElem; /*!< \brief Total number of elements. */
52+
unsigned short nDim; /*!< \brief Problem dimension. */
53+
unsigned long nLocalPoints; /*!< \brief Local number of points. */
54+
cgsize_t GlobalPoint; /*!< \brief Total number of points. */
55+
cgsize_t GlobalElem; /*!< \brief Total number of elements. */
56+
57+
vector<cgsize_t> sendBufferConnectivity; /*!< \brief Send buffer for connectivity data. */
58+
vector<cgsize_t> recvBufferConnectivity; /*!< \brief Receive buffer for connectivity data. */
59+
vector<dataPrecision> recvBufferField; /*!< \brief Send buffer for field data. */
60+
vector<dataPrecision> sendBufferField; /*!< \brief Receive buffer for field data. */
5361

5462
cgsize_t cumulative; /*!< \brief Cumulative number of elements written. */
55-
#endif
5663

64+
DataType_t dataType; /*!< \brief Datatype of fields can be RealSingle or RealDouble. */
65+
#endif
5766
public:
5867
/*!
5968
* \brief File extension
@@ -68,11 +77,6 @@ class CCGNSFileWriter final : public CFileWriter {
6877
*/
6978
CCGNSFileWriter(string valFileName, CParallelDataSorter* valDataSorter, bool isSurf = false);
7079

71-
/*!
72-
* \brief Destructor
73-
*/
74-
~CCGNSFileWriter() override;
75-
7680
/*!
7781
* \brief Write sorted data to file in CGNS file format.
7882
*/
@@ -81,14 +85,14 @@ class CCGNSFileWriter final : public CFileWriter {
8185
/*!
8286
* \brief Initialize CGNS mesh file.
8387
*/
84-
void initializeMeshFile();
88+
void InitializeMeshFile();
8589

8690
/*!
8791
* \brief Write i-th coordinate to file in CGNS file format.
88-
* \param[in] CoordinateNumber - Coordinate number according to CGNS.
89-
* \param[in] CoordinateName - Coordinate name according to CGNS.
92+
* \param[in] iField - the output field ID.
93+
* \param[in] FieldName - Field name in the CGNS.
9094
*/
91-
void WriteCoordinate(int CoordinateNumber, const string& CoordinateName);
95+
void WriteField(int iField, const string& FieldName);
9296

9397
/*!
9498
* \brief Write connectivity to file for GEO_TYPE in CGNS file format.
@@ -102,13 +106,6 @@ class CCGNSFileWriter final : public CFileWriter {
102106
*/
103107
void InitializeFields();
104108

105-
/*!
106-
* \brief Write i-th coordinate to file in CGNS file format.
107-
* \param[in] iField - the output field ID.
108-
* \param[in] FieldName - Field name in the CGNS.
109-
*/
110-
void WriteField(int iField, const string& FieldName);
111-
112109
/*!
113110
* \brief Call a generic CGNS function.
114111
* \param[in] ier - error value.

0 commit comments

Comments
 (0)