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

Multiline config option values and Paraview vtu default output #996

Merged
merged 8 commits into from
May 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions Common/src/CConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2834,6 +2834,7 @@ void CConfig::SetConfig_Parsing(char case_filename[MAX_STRING_SIZE]) {

int err_count = 0; // How many errors have we found in the config file
int max_err_count = 30; // Maximum number of errors to print before stopping
int line_count = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a short description here


map<string, bool> included_options;

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

PrintingToolbox::trim(text_line);

/*--- Check if there is a line continuation character at the
* end of the current line or somewhere in between (the rest is ignored then).
* If yes, read until there is a line without one or an empty line.
* If there is a statement after a cont. char
* throw an error. ---*/

if (text_line.front() != '%'){
while (text_line.back() == '\\' ||
(PrintingToolbox::split(text_line, '\\').size() > 1)){
string tmp;
getline (config_buffer, tmp);
line_count++;
if (tmp.find_first_of('=') != string::npos){
errorString.append("Line " + to_string(line_count) + ": Statement found after continuation character.\n");
}
PrintingToolbox::trim(tmp);
if (tmp.front() != '%'){
text_line = PrintingToolbox::split(text_line, '\\')[0];
text_line += " " + tmp;
}
}
}

if (TokenizeString(text_line, option_name, option_value)) {

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

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

if (included_options.find(option_name) != included_options.end()) {
string newString;
newString.append(option_name);
newString.append("Line " + to_string(line_count) + " " + option_name);
newString.append(": option appears twice");
newString.append("\n");
errorString.append(newString);
Expand All @@ -2893,6 +2919,7 @@ void CConfig::SetConfig_Parsing(char case_filename[MAX_STRING_SIZE]) {
err_count++;
}
}
line_count++;
}

/*--- See if there were any errors parsing the config file ---*/
Expand Down Expand Up @@ -3152,8 +3179,8 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_
nVolumeOutputFiles = 3;
VolumeOutputFiles = new unsigned short[nVolumeOutputFiles];
VolumeOutputFiles[0] = RESTART_BINARY;
VolumeOutputFiles[1] = PARAVIEW_BINARY;
VolumeOutputFiles[2] = SURFACE_PARAVIEW_BINARY;
VolumeOutputFiles[1] = PARAVIEW_XML;
VolumeOutputFiles[2] = SURFACE_PARAVIEW_XML;
}

/*--- Check if SU2 was build with TecIO support, as that is required for Tecplot Binary output. ---*/
Expand Down
23 changes: 21 additions & 2 deletions SU2_PY/SU2/io/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,29 @@ def read_config(filename):
break

# remove line returns
line = line.strip('\r\n')
line = line.strip('\r\n').strip()

if (len(line) == 0):
continue
# make sure it has useful data
if (not "=" in line) or (line[0] == '%'):
if (line[0] == '%'):
continue

# --- Check if there is a line continuation character at the
# end of the current line or somewhere in between (the rest is ignored then).
# If yes, read until there is a line without one or an empty line.
# If there is a statement after a cont. char
# throw an error. ---*/

while(line[0].endswith('\\') or len(line.split('\\')) > 1):
tmp_line = input_file.readline()
tmp_line = tmp_line.strip()
assert len(tmp_line.split('=')) <= 1, ('Statement found after line '
'continuation character in config file %s' % tmp_line)
if (not tmp_line.startswith('%')):
line = line.split('\\')[0]
line += ' ' + tmp_line

# split across equals sign
line = line.split("=",1)
this_param = line[0].strip()
Expand Down