Skip to content

Commit 086facf

Browse files
authored
Merge pull request #2178 from su2code/feature_FixCGNS
Fix error in CGNS writing
2 parents 3ee6027 + f457da5 commit 086facf

3 files changed

Lines changed: 120 additions & 10 deletions

File tree

SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ void CCGNSFileWriter::WriteData(string val_filename) {
3838

3939
/*--- We append the pre-defined suffix (extension) to the filename (prefix) ---*/
4040
val_filename.append(fileExt);
41-
4241
/*--- Open the CGNS file for writing. ---*/
4342
InitializeMeshFile(val_filename);
4443

@@ -132,15 +131,16 @@ void CCGNSFileWriter::WriteField(int iField, const string& FieldName) {
132131
/*--- Coordinate vector is written in blocks, one for each process. ---*/
133132
cgsize_t nodeBegin = 1;
134133
auto nodeEnd = static_cast<cgsize_t>(nLocalPoints);
135-
136-
if (isCoord) {
137-
int CoordinateNumber;
138-
CallCGNS(cg_coord_partial_write(cgnsFileID, cgnsBase, cgnsZone, dataType, FieldName.c_str(), &nodeBegin, &nodeEnd,
139-
sendBufferField.data(), &CoordinateNumber));
140-
} else {
141-
int fieldNumber;
142-
CallCGNS(cg_field_partial_write(cgnsFileID, cgnsBase, cgnsZone, cgnsFields, dataType, FieldName.c_str(), &nodeBegin,
143-
&nodeEnd, sendBufferField.data(), &fieldNumber));
134+
if (nLocalPoints > 0) {
135+
if (isCoord) {
136+
int CoordinateNumber;
137+
CallCGNS(cg_coord_partial_write(cgnsFileID, cgnsBase, cgnsZone, dataType, FieldName.c_str(), &nodeBegin, &nodeEnd,
138+
sendBufferField.data(), &CoordinateNumber));
139+
} else {
140+
int fieldNumber;
141+
CallCGNS(cg_field_partial_write(cgnsFileID, cgnsBase, cgnsZone, cgnsFields, dataType, FieldName.c_str(), &nodeBegin,
142+
&nodeEnd, sendBufferField.data(), &fieldNumber));
143+
}
144144
}
145145

146146
for (int i = 0; i < size; ++i) {

TestCases/cgns_writer/config.cfg

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2+
% %
3+
% SU2 configuration file %
4+
% Case description: Subsonic U-Turn %
5+
% Author: Andrea Rausa %
6+
% Institution: Politecnico di Milano %
7+
% Date: 12/2/2023 %
8+
% File Version 8.0.0 "Harrier" %
9+
% %
10+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11+
12+
% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------%
13+
%
14+
SOLVER= RANS
15+
KIND_TURB_MODEL= SST
16+
MATH_PROBLEM= DIRECT
17+
RESTART_SOL= NO
18+
19+
% -------------------- COMPRESSIBLE FREE-STREAM DEFINITION --------------------%
20+
%
21+
MACH_NUMBER= 0.2
22+
AOA= 0.0
23+
FREESTREAM_TEMPERATURE= 270.0
24+
REYNOLDS_NUMBER= 3.28E6
25+
REYNOLDS_LENGTH= 1
26+
REF_DIMENSIONALIZATION= FREESTREAM_VEL_EQ_MACH
27+
28+
% ---------------------- REFERENCE VALUE DEFINITION ---------------------------%
29+
%
30+
REF_ORIGIN_MOMENT_X = -0.2473
31+
REF_ORIGIN_MOMENT_Y = 0.00
32+
REF_ORIGIN_MOMENT_Z = 0.00
33+
REF_LENGTH= 1
34+
REF_AREA= 1
35+
36+
% -------------------- BOUNDARY CONDITION DEFINITION --------------------------%
37+
%
38+
MARKER_HEATFLUX= ( OuterWall, 0.0, InnerWall, 0.0 )
39+
MARKER_FAR= ( Inlet, Outlet )
40+
MARKER_PLOTTING= ( InnerWall )
41+
MARKER_MONITORING= ( InnerWall )
42+
43+
% ------------------------ LINEAR SOLVER DEFINITION ---------------------------%
44+
%
45+
LINEAR_SOLVER= FGMRES
46+
LINEAR_SOLVER_PREC= ILU
47+
LINEAR_SOLVER_ERROR= 1.0e-6
48+
LINEAR_SOLVER_ITER= 15
49+
50+
% -------------------------- MULTIGRID PARAMETERS -----------------------------%
51+
%
52+
CFL_ADAPT= YES
53+
CFL_NUMBER= 1
54+
CFL_REDUCTION_TURB= 1.0
55+
CFL_ADAPT_PARAM= ( 0.5, 1.01, 1.0, 5, 0.0001)
56+
ITER= 1
57+
58+
% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------%
59+
%
60+
CONV_NUM_METHOD_FLOW= ROE
61+
USE_VECTORIZATION= YES
62+
MUSCL_FLOW= NO
63+
SLOPE_LIMITER_FLOW= VENKATAKRISHNAN
64+
VENKAT_LIMITER_COEFF= 0.03
65+
TIME_DISCRE_FLOW= EULER_IMPLICIT
66+
67+
% -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------%
68+
%
69+
CONV_NUM_METHOD_TURB= SCALAR_UPWIND
70+
MUSCL_TURB= NO
71+
TIME_DISCRE_TURB= EULER_IMPLICIT
72+
73+
74+
% --------------------------- CONVERGENCE PARAMETERS --------------------------%
75+
%
76+
CONV_FIELD= MOMENT_X
77+
CONV_STARTITER= 10
78+
CONV_CAUCHY_ELEMS= 100
79+
CONV_CAUCHY_EPS= 1E-6
80+
81+
% ------------------------- INPUT/OUTPUT INFORMATION --------------------------%
82+
%
83+
MESH_FILENAME= mesh.su2
84+
MESH_FORMAT= SU2
85+
SOLUTION_FILENAME= restart_flow
86+
TABULAR_FORMAT= CSV
87+
CONV_FILENAME= history_First
88+
RESTART_FILENAME= restart_flow
89+
VOLUME_FILENAME= flow
90+
SURFACE_FILENAME= surface_flow
91+
OUTPUT_WRT_FREQ= 100
92+
SCREEN_OUTPUT= (INNER_ITER, WALL_TIME, RMS_DENSITY, LIFT, DRAG, MOMENT_Z)
93+
OUTPUT_FILES= (SURFACE_CGNS)
94+
WRT_FORCES_BREAKDOWN= NO
95+
VOLUME_OUTPUT= (COORDINATES)
96+
HISTORY_OUTPUT= (ITER)

TestCases/parallel_regression.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,6 +1555,20 @@ def main():
15551555
species3_multizone_restart.multizone = True
15561556
test_list.append(species3_multizone_restart)
15571557

1558+
#####################
1559+
## CGNS writer ###
1560+
#####################
1561+
1562+
# CGNS writer
1563+
cgns_writer = TestCase('cgns_writer')
1564+
cgns_writer.cfg_dir = "cgns_writer"
1565+
cgns_writer.cfg_file = "config.cfg"
1566+
cgns_writer.test_iter = 1
1567+
cgns_writer.test_vals = [-2.974473, 0.665204, 5.068846, -7.003873]
1568+
cgns_writer.command = TestCase.Command("mpirun -n 2", "SU2_CFD")
1569+
cgns_writer.new_output = True
1570+
test_list.append(cgns_writer)
1571+
15581572
######################################
15591573
### RUN TESTS ###
15601574
######################################

0 commit comments

Comments
 (0)