Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error in CGNS writing #2178

Merged
merged 10 commits into from
Dec 5, 2023
20 changes: 10 additions & 10 deletions SU2_CFD/src/output/filewriter/CCGNSFileWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ void CCGNSFileWriter::WriteData(string val_filename) {

/*--- We append the pre-defined suffix (extension) to the filename (prefix) ---*/
val_filename.append(fileExt);

/*--- Open the CGNS file for writing. ---*/
InitializeMeshFile(val_filename);

Expand Down Expand Up @@ -132,15 +131,16 @@ void CCGNSFileWriter::WriteField(int iField, const string& FieldName) {
/*--- Coordinate vector is written in blocks, one for each process. ---*/
cgsize_t nodeBegin = 1;
auto nodeEnd = static_cast<cgsize_t>(nLocalPoints);

if (isCoord) {
int CoordinateNumber;
CallCGNS(cg_coord_partial_write(cgnsFileID, cgnsBase, cgnsZone, dataType, FieldName.c_str(), &nodeBegin, &nodeEnd,
sendBufferField.data(), &CoordinateNumber));
} else {
int fieldNumber;
CallCGNS(cg_field_partial_write(cgnsFileID, cgnsBase, cgnsZone, cgnsFields, dataType, FieldName.c_str(), &nodeBegin,
&nodeEnd, sendBufferField.data(), &fieldNumber));
if (nLocalPoints > 0) {
if (isCoord) {
int CoordinateNumber;
CallCGNS(cg_coord_partial_write(cgnsFileID, cgnsBase, cgnsZone, dataType, FieldName.c_str(), &nodeBegin, &nodeEnd,
sendBufferField.data(), &CoordinateNumber));
} else {
int fieldNumber;
CallCGNS(cg_field_partial_write(cgnsFileID, cgnsBase, cgnsZone, cgnsFields, dataType, FieldName.c_str(), &nodeBegin,
&nodeEnd, sendBufferField.data(), &fieldNumber));
}
}

for (int i = 0; i < size; ++i) {
Expand Down
96 changes: 96 additions & 0 deletions TestCases/cgns_writer/config.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% SU2 configuration file %
% Case description: Subsonic U-Turn %
% Author: Andrea Rausa %
% Institution: Politecnico di Milano %
% Date: 12/2/2023 %
% File Version 8.0.0 "Harrier" %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------%
%
SOLVER= RANS
KIND_TURB_MODEL= SST
MATH_PROBLEM= DIRECT
RESTART_SOL= NO

% -------------------- COMPRESSIBLE FREE-STREAM DEFINITION --------------------%
%
MACH_NUMBER= 0.2
AOA= 0.0
FREESTREAM_TEMPERATURE= 270.0
REYNOLDS_NUMBER= 3.28E6
REYNOLDS_LENGTH= 1
REF_DIMENSIONALIZATION= FREESTREAM_VEL_EQ_MACH

% ---------------------- REFERENCE VALUE DEFINITION ---------------------------%
%
REF_ORIGIN_MOMENT_X = -0.2473
REF_ORIGIN_MOMENT_Y = 0.00
REF_ORIGIN_MOMENT_Z = 0.00
REF_LENGTH= 1
REF_AREA= 1

% -------------------- BOUNDARY CONDITION DEFINITION --------------------------%
%
MARKER_HEATFLUX= ( OuterWall, 0.0, InnerWall, 0.0 )
MARKER_FAR= ( Inlet, Outlet )
MARKER_PLOTTING= ( InnerWall )
MARKER_MONITORING= ( InnerWall )

% ------------------------ LINEAR SOLVER DEFINITION ---------------------------%
%
LINEAR_SOLVER= FGMRES
LINEAR_SOLVER_PREC= ILU
LINEAR_SOLVER_ERROR= 1.0e-6
LINEAR_SOLVER_ITER= 15

% -------------------------- MULTIGRID PARAMETERS -----------------------------%
%
CFL_ADAPT= YES
CFL_NUMBER= 1
CFL_REDUCTION_TURB= 1.0
CFL_ADAPT_PARAM= ( 0.5, 1.01, 1.0, 5, 0.0001)
ITER= 1

% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------%
%
CONV_NUM_METHOD_FLOW= ROE
USE_VECTORIZATION= YES
MUSCL_FLOW= NO
SLOPE_LIMITER_FLOW= VENKATAKRISHNAN
VENKAT_LIMITER_COEFF= 0.03
TIME_DISCRE_FLOW= EULER_IMPLICIT

% -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------%
%
CONV_NUM_METHOD_TURB= SCALAR_UPWIND
MUSCL_TURB= NO
TIME_DISCRE_TURB= EULER_IMPLICIT


% --------------------------- CONVERGENCE PARAMETERS --------------------------%
%
CONV_FIELD= MOMENT_X
CONV_STARTITER= 10
CONV_CAUCHY_ELEMS= 100
CONV_CAUCHY_EPS= 1E-6

% ------------------------- INPUT/OUTPUT INFORMATION --------------------------%
%
MESH_FILENAME= mesh.su2
MESH_FORMAT= SU2
pcarruscag marked this conversation as resolved.
Show resolved Hide resolved
SOLUTION_FILENAME= restart_flow
TABULAR_FORMAT= CSV
CONV_FILENAME= history_First
RESTART_FILENAME= restart_flow
VOLUME_FILENAME= flow
SURFACE_FILENAME= surface_flow
OUTPUT_WRT_FREQ= 100
SCREEN_OUTPUT= (INNER_ITER, WALL_TIME, RMS_DENSITY, LIFT, DRAG, MOMENT_Z)
OUTPUT_FILES= (SURFACE_CGNS)
WRT_FORCES_BREAKDOWN= NO
VOLUME_OUTPUT= (COORDINATES)
HISTORY_OUTPUT= (ITER)
14 changes: 14 additions & 0 deletions TestCases/parallel_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,20 @@ def main():
species3_multizone_restart.multizone = True
test_list.append(species3_multizone_restart)

#####################
## CGNS writer ###
#####################

# CGNS writer
cgns_writer = TestCase('cgns_writer')
cgns_writer.cfg_dir = "cgns_writer"
cgns_writer.cfg_file = "config.cfg"
cgns_writer.test_iter = 1
cgns_writer.test_vals = [-2.974473, 0.665204, 5.068846, -7.003873]
cgns_writer.command = TestCase.Command("mpirun -n 2", "SU2_CFD")
cgns_writer.new_output = True
test_list.append(cgns_writer)

######################################
### RUN TESTS ###
######################################
Expand Down