Skip to content

Commit 2c36b3f

Browse files
authored
Merge branch 'develop' into fix_heat_adjointrestart
2 parents 2310c28 + b1a47bb commit 2c36b3f

13 files changed

Lines changed: 449 additions & 16 deletions

File tree

AUTHORS.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ Juan J. Alonso (Stanford University)
1515
The SU2 project is maintained by members of the SU2 Foundation (https://su2foundation.org)
1616

1717
```
18-
Thomas D. Economon - Executive Director - tom@su2foundation.org
19-
Ruben Sanchez - User Director - ruben@su2foundation.org
20-
Tim Albring - Developer Director - tim@su2foundation.org
21-
Juan J. Alonso - Academic Director - juan@su2foundation.org
22-
Eran Arad - Industry Director - eran@su2foundation.org
18+
Thomas D. Economon - Executive Director - tom@su2foundation.org
19+
Tim Albring - Director - tim@su2foundation.org
20+
Juan J. Alonso - Director - juan@su2foundation.org
21+
Eran Arad - Director - eran@su2foundation.org
22+
Piero Colonna - Director - piero@su2foundation.org
23+
Pedro Gomes - Director - pedro@su2foundation.org
24+
Daniel Mayer - Director - daniel@su2foundation.org
2325
```
2426

2527
in collaboration with the following main contributors and research teams:
@@ -63,6 +65,7 @@ Clark Pederson
6365
Daumantas Kavolis
6466
Dave Taflin
6567
Eduardo Molina
68+
Edwin van der Weide
6669
Ethan Alan Hereth
6770
Florian Dittmann
6871
Francisco D. Palacios
@@ -92,7 +95,9 @@ Max Sagebaum
9295
Michele Gaffuri
9396
Mickael Philit
9497
Mladen Banovic
98+
Nat-1
9599
Nicola Fonzi
100+
Nijso Beishuizen
96101
Ole Burghardt
97102
Patrick Mischke
98103
Paul Urbanczyk
@@ -119,8 +124,7 @@ aaronyicongfu
119124
aeroamit
120125
anilvar
121126
band-a-prend
122-
bigfootedrockmidget
123-
bmunguia
127+
baldang
124128
chamsolli
125129
costat
126130
daniel-linton
@@ -136,10 +140,10 @@ jvanoostrom
136140
mcolonno
137141
minkwankim
138142
padronas
143+
snow54
139144
sravya91
140145
srcopela
141146
tobadavid
142-
vdweide
143147
vfrancesmolla
144148
```
145149

Common/include/option_structure.hpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,12 +1650,13 @@ enum ENUM_OUTPUT {
16501650
MESH = 11, /*!< \brief SU2 mesh format. */
16511651
RESTART_BINARY = 12, /*!< \brief SU2 binary restart format. */
16521652
RESTART_ASCII = 13, /*!< \brief SU2 ASCII restart format. */
1653-
CGNS = 14, /*!< \brief CGNS format. */
1654-
STL = 15, /*!< \brief STL ASCII format for surface solution output. */
1655-
STL_BINARY = 16, /*!< \brief STL binary format for surface solution output. Not implemented yet. */
1656-
PARAVIEW_XML = 17, /*!< \brief Paraview XML with binary data format */
1657-
SURFACE_PARAVIEW_XML = 18, /*!< \brief Surface Paraview XML with binary data format */
1658-
PARAVIEW_MULTIBLOCK = 19 /*!< \brief Paraview XML Multiblock */
1653+
STL = 14, /*!< \brief STL ASCII format for surface solution output. */
1654+
STL_BINARY = 15, /*!< \brief STL binary format for surface solution output. Not implemented yet. */
1655+
PARAVIEW_XML = 16, /*!< \brief Paraview XML with binary data format */
1656+
SURFACE_PARAVIEW_XML = 17, /*!< \brief Surface Paraview XML with binary data format */
1657+
PARAVIEW_MULTIBLOCK = 18, /*!< \brief Paraview XML Multiblock */
1658+
CGNS = 19, /*!< \brief CGNS format. */
1659+
SURFACE_CGNS = 20 /*!< \brief CGNS format. */
16591660
};
16601661
static const MapType<std::string, ENUM_OUTPUT> Output_Map = {
16611662
MakePair("TECPLOT_ASCII", TECPLOT)
@@ -1674,6 +1675,7 @@ static const MapType<std::string, ENUM_OUTPUT> Output_Map = {
16741675
MakePair("RESTART_ASCII", RESTART_ASCII)
16751676
MakePair("RESTART", RESTART_BINARY)
16761677
MakePair("CGNS", CGNS)
1678+
MakePair("SURFACE_CGNS", SURFACE_CGNS)
16771679
MakePair("STL", STL)
16781680
MakePair("STL_BINARY", STL_BINARY)
16791681
};

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){
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/*!
2+
* \file CCGNSFileWriter.hpp
3+
* \brief Headers for CGNS file writer class.
4+
* \author G. Baldan
5+
* \version 7.2.0 "Blackbird"
6+
*
7+
* SU2 Project Website: https://su2code.github.io
8+
*
9+
* The SU2 Project is maintained by the SU2 Foundation
10+
* (http://su2foundation.org)
11+
*
12+
* Copyright 2012-2021, SU2 Contributors (cf. AUTHORS.md)
13+
*
14+
* SU2 is free software; you can redistribute it and/or
15+
* modify it under the terms of the GNU Lesser General Public
16+
* License as published by the Free Software Foundation; either
17+
* version 2.1 of the License, or (at your option) any later version.
18+
*
19+
* SU2 is distributed in the hope that it will be useful,
20+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22+
* Lesser General Public License for more details.
23+
*
24+
* You should have received a copy of the GNU Lesser General Public
25+
* License along with SU2. If not, see <http://www.gnu.org/licenses/>.
26+
*/
27+
28+
#pragma once
29+
30+
#ifdef HAVE_CGNS
31+
#include "cgnslib.h"
32+
#endif
33+
34+
#include "CFileWriter.hpp"
35+
36+
class CCGNSFileWriter final : public CFileWriter {
37+
private:
38+
const bool isSurface; /*!< \brief True if surface file. */
39+
40+
#ifdef HAVE_CGNS
41+
int cgnsFileID; /*!< \brief CGNS file identifier. */
42+
int cgnsBase; /*!< \brief CGNS database index. */
43+
int cgnsZone; /*!< \brief CGNS zone index. */
44+
int cgnsFields; /*!< \brief CGNS flow solution index. */
45+
46+
int nZones; /*!< \brief Total number of zones in the CGNS file. */
47+
int nSections; /*!< \brief Total number of sections in the CGNS file. */
48+
49+
unsigned short nDim; /*!< \brief Problem dimension. */
50+
unsigned long nLocalPoints; /*!< \brief Local number of points. */
51+
cgsize_t GlobalPoint; /*!< \brief Total number of points. */
52+
cgsize_t GlobalElem; /*!< \brief Total number of elements. */
53+
54+
typedef float dataPrecision; /*!< \brief Define data precision of output (float or double). */
55+
const DataType_t dataType = RealSingle; /*!< \brief Datatype of fields can be RealSingle or RealDouble. */
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. */
61+
62+
cgsize_t cumulative; /*!< \brief Cumulative number of elements written. */
63+
#endif
64+
public:
65+
/*!
66+
* \brief File extension
67+
*/
68+
const static string fileExt;
69+
70+
/*!
71+
* \brief Construct a file writer using field names and the data sorter.
72+
* \param[in] valFileName - The name of the file.
73+
* \param[in] valDataSorter - The parallel sorted data to write.
74+
* \param[in] isSurf - True if it is a surface file.
75+
*/
76+
CCGNSFileWriter(string valFileName, CParallelDataSorter* valDataSorter, bool isSurf = false);
77+
78+
/*!
79+
* \brief Write sorted data to file in CGNS file format.
80+
*/
81+
void Write_Data() override;
82+
83+
private:
84+
#ifdef HAVE_CGNS
85+
/*!
86+
* \brief Initialize CGNS mesh file.
87+
*/
88+
void InitializeMeshFile();
89+
90+
/*!
91+
* \brief Write i-th coordinate to file in CGNS file format.
92+
* \param[in] iField - the output field ID.
93+
* \param[in] FieldName - Field name in the CGNS.
94+
*/
95+
void WriteField(int iField, const string& FieldName);
96+
97+
/*!
98+
* \brief Write connectivity to file for GEO_TYPE in CGNS file format.
99+
* \param[in] type - GEO_TYPE.
100+
* \param[in] SectionName - Section name in the CGNS file.
101+
*/
102+
void WriteConnectivity(GEO_TYPE type, const string& SectionName);
103+
104+
/*!
105+
* \brief Initialize flow solution in the CGNS file.
106+
*/
107+
void InitializeFields();
108+
109+
/*!
110+
* \brief Call a generic CGNS function.
111+
* \param[in] ier - error value.
112+
*/
113+
static inline void CallCGNS(const int& ier) {
114+
if (ier) cg_error_exit();
115+
}
116+
117+
/*!
118+
* \brief Return the CGNS element type (ElementType_t).
119+
* \param[in] elementType - GEO_TYPE.
120+
*/
121+
static inline ElementType_t GetCGNSType(unsigned short elementType) {
122+
switch (elementType) {
123+
case LINE:
124+
return BAR_2;
125+
case TRIANGLE:
126+
return TRI_3;
127+
case QUADRILATERAL:
128+
return QUAD_4;
129+
case TETRAHEDRON:
130+
return TETRA_4;
131+
case HEXAHEDRON:
132+
return HEXA_8;
133+
case PYRAMID:
134+
return PYRA_5;
135+
case PRISM:
136+
return PENTA_6;
137+
default:
138+
assert(false && "Invalid element type.");
139+
return ElementTypeNull;
140+
}
141+
}
142+
#endif
143+
};

SU2_CFD/obj/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ libSU2Core_sources = ../src/definition_structure.cpp \
134134
../src/output/filewriter/CSU2MeshFileWriter.cpp \
135135
../src/output/filewriter/CTecplotFileWriter.cpp \
136136
../src/output/filewriter/CTecplotBinaryFileWriter.cpp \
137+
../src/output/filewriter/CCGNSFileWriter.cpp \
137138
../src/output/tools/CWindowingTools.cpp \
138139
../src/output/COutput.cpp \
139140
../src/output/output_physics.cpp \

SU2_CFD/src/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ su2_cfd_src += files(['output/COutputFactory.cpp',
4747
'output/filewriter/CParaviewXMLFileWriter.cpp',
4848
'output/filewriter/CParaviewVTMFileWriter.cpp',
4949
'output/filewriter/CSU2MeshFileWriter.cpp',
50+
'output/filewriter/CCGNSFileWriter.cpp',
5051
'output/tools/CWindowingTools.cpp'])
5152

5253
su2_cfd_src += files(['variables/CIncNSVariable.cpp',

SU2_CFD/src/output/COutput.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "../../include/output/COutput.hpp"
2929
#include "../../include/output/filewriter/CFVMDataSorter.hpp"
3030
#include "../../include/output/filewriter/CFEMDataSorter.hpp"
31+
#include "../../include/output/filewriter/CCGNSFileWriter.hpp"
3132
#include "../../include/output/filewriter/CSurfaceFVMDataSorter.hpp"
3233
#include "../../include/output/filewriter/CSurfaceFEMDataSorter.hpp"
3334
#include "../../include/output/filewriter/CParaviewFileWriter.hpp"
@@ -679,6 +680,39 @@ void COutput::WriteToFile(CConfig *config, CGeometry *geometry, unsigned short f
679680

680681
break;
681682

683+
case CGNS:
684+
685+
if (fileName.empty()) fileName = config->GetFilename(volumeFilename, "", curTimeIter);
686+
687+
/*--- Load and sort the output data and connectivity. ---*/
688+
volumeDataSorter->SortConnectivity(config, geometry, true);
689+
690+
/*--- Write CGNS ---*/
691+
if (rank == MASTER_NODE) {
692+
(*fileWritingTable) << "CGNS" << fileName + CCGNSFileWriter::fileExt;
693+
}
694+
695+
fileWriter = new CCGNSFileWriter(fileName, volumeDataSorter);
696+
697+
break;
698+
699+
case SURFACE_CGNS:
700+
701+
if (fileName.empty()) fileName = config->GetFilename(surfaceFilename, "", curTimeIter);
702+
703+
/*--- Load and sort the output data and connectivity. ---*/
704+
surfaceDataSorter->SortConnectivity(config, geometry);
705+
surfaceDataSorter->SortOutputData();
706+
707+
/*--- Write SURFACE_CGNS ---*/
708+
if (rank == MASTER_NODE) {
709+
(*fileWritingTable) << "CGNS surface" << fileName + CCGNSFileWriter::fileExt;
710+
}
711+
712+
fileWriter = new CCGNSFileWriter(fileName, surfaceDataSorter, true);
713+
714+
break;
715+
682716
default:
683717
fileWriter = nullptr;
684718
break;

0 commit comments

Comments
 (0)