Skip to content

Commit 626be8f

Browse files
authored
Merge pull request #996 from su2code/feature_multiline
Multiline config option values and Paraview vtu default output
2 parents 33adee2 + 0956549 commit 626be8f

2 files changed

Lines changed: 52 additions & 6 deletions

File tree

Common/src/CConfig.cpp

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2834,6 +2834,7 @@ void CConfig::SetConfig_Parsing(char case_filename[MAX_STRING_SIZE]) {
28342834

28352835
int err_count = 0; // How many errors have we found in the config file
28362836
int max_err_count = 30; // Maximum number of errors to print before stopping
2837+
int line_count = 1;
28372838

28382839
map<string, bool> included_options;
28392840

@@ -2848,13 +2849,38 @@ void CConfig::SetConfig_Parsing(char case_filename[MAX_STRING_SIZE]) {
28482849
throw(1);
28492850
}
28502851

2852+
PrintingToolbox::trim(text_line);
2853+
2854+
/*--- Check if there is a line continuation character at the
2855+
* end of the current line or somewhere in between (the rest is ignored then).
2856+
* If yes, read until there is a line without one or an empty line.
2857+
* If there is a statement after a cont. char
2858+
* throw an error. ---*/
2859+
2860+
if (text_line.front() != '%'){
2861+
while (text_line.back() == '\\' ||
2862+
(PrintingToolbox::split(text_line, '\\').size() > 1)){
2863+
string tmp;
2864+
getline (config_buffer, tmp);
2865+
line_count++;
2866+
if (tmp.find_first_of('=') != string::npos){
2867+
errorString.append("Line " + to_string(line_count) + ": Statement found after continuation character.\n");
2868+
}
2869+
PrintingToolbox::trim(tmp);
2870+
if (tmp.front() != '%'){
2871+
text_line = PrintingToolbox::split(text_line, '\\')[0];
2872+
text_line += " " + tmp;
2873+
}
2874+
}
2875+
}
2876+
28512877
if (TokenizeString(text_line, option_name, option_value)) {
28522878

28532879
/*--- See if it's a python option ---*/
28542880

28552881
if (option_map.find(option_name) == option_map.end()) {
28562882
string newString;
2857-
newString.append(option_name);
2883+
newString.append("Line " + to_string(line_count) + " " + option_name);
28582884
newString.append(": invalid option name");
28592885
newString.append(". Check current SU2 options in config_template.cfg.");
28602886
newString.append("\n");
@@ -2870,7 +2896,7 @@ void CConfig::SetConfig_Parsing(char case_filename[MAX_STRING_SIZE]) {
28702896

28712897
if (included_options.find(option_name) != included_options.end()) {
28722898
string newString;
2873-
newString.append(option_name);
2899+
newString.append("Line " + to_string(line_count) + " " + option_name);
28742900
newString.append(": option appears twice");
28752901
newString.append("\n");
28762902
errorString.append(newString);
@@ -2893,6 +2919,7 @@ void CConfig::SetConfig_Parsing(char case_filename[MAX_STRING_SIZE]) {
28932919
err_count++;
28942920
}
28952921
}
2922+
line_count++;
28962923
}
28972924

28982925
/*--- See if there were any errors parsing the config file ---*/
@@ -3152,8 +3179,8 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_
31523179
nVolumeOutputFiles = 3;
31533180
VolumeOutputFiles = new unsigned short[nVolumeOutputFiles];
31543181
VolumeOutputFiles[0] = RESTART_BINARY;
3155-
VolumeOutputFiles[1] = PARAVIEW_BINARY;
3156-
VolumeOutputFiles[2] = SURFACE_PARAVIEW_BINARY;
3182+
VolumeOutputFiles[1] = PARAVIEW_XML;
3183+
VolumeOutputFiles[2] = SURFACE_PARAVIEW_XML;
31573184
}
31583185

31593186
/*--- Check if SU2 was build with TecIO support, as that is required for Tecplot Binary output. ---*/

SU2_PY/SU2/io/config.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,29 @@ def read_config(filename):
340340
break
341341

342342
# remove line returns
343-
line = line.strip('\r\n')
343+
line = line.strip('\r\n').strip()
344+
345+
if (len(line) == 0):
346+
continue
344347
# make sure it has useful data
345-
if (not "=" in line) or (line[0] == '%'):
348+
if (line[0] == '%'):
346349
continue
350+
351+
# --- Check if there is a line continuation character at the
352+
# end of the current line or somewhere in between (the rest is ignored then).
353+
# If yes, read until there is a line without one or an empty line.
354+
# If there is a statement after a cont. char
355+
# throw an error. ---*/
356+
357+
while(line[0].endswith('\\') or len(line.split('\\')) > 1):
358+
tmp_line = input_file.readline()
359+
tmp_line = tmp_line.strip()
360+
assert len(tmp_line.split('=')) <= 1, ('Statement found after line '
361+
'continuation character in config file %s' % tmp_line)
362+
if (not tmp_line.startswith('%')):
363+
line = line.split('\\')[0]
364+
line += ' ' + tmp_line
365+
347366
# split across equals sign
348367
line = line.split("=",1)
349368
this_param = line[0].strip()

0 commit comments

Comments
 (0)