Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
713fb81
Fix const inconsistency between declaration/definition.
jblueh Sep 13, 2022
88bdc9d
Adapt ninja command for builds outside the SU2 directory.
jblueh Sep 13, 2022
4a54740
Ensure to pass killall the correct process name.
jblueh Sep 14, 2022
c372fa2
Fix.
jblueh Sep 14, 2022
11ee7fa
Adapt tutorials.py and vandv.py.
jblueh Sep 16, 2022
2c016a7
Merge branch 'develop' into misc_fixes
jblueh Sep 16, 2022
7cfaf54
Introduce a Command class and tidy up TestCase.py.
jblueh Sep 26, 2022
8026ae9
Update parallel_regression.py, reduce boilerplate.
jblueh Sep 26, 2022
fcfa892
Update parallel_regression_AD.py, reduce boilerplate.
jblueh Sep 26, 2022
f86a4f8
Update hybrid and hybrid AD regression tests.
jblueh Sep 26, 2022
39b8a4e
Update serial_regression.py, reduce boilerplate.
jblueh Sep 26, 2022
a57df4a
Update serial_regression_AD.py, reduce boilerplate.
jblueh Sep 26, 2022
1f15378
Update vandv.py and tutorials.py, reduce boilerplate.
jblueh Sep 26, 2022
36c5698
Ensure that the test script does not kill itself.
jblueh Sep 28, 2022
bf4d162
Make default timeout and tol visible.
jblueh Sep 28, 2022
5e728c9
Timeout and tol defaults for parallel_regression_AD.py.
jblueh Sep 28, 2022
4b151b8
Defaults on the TestCase level can be ambiguous.
jblueh Sep 28, 2022
627f045
Small updates.
jblueh Sep 28, 2022
a239b46
Timeout and tol defaults for serial_regression_AD.py, updates.
jblueh Sep 28, 2022
2c7cd33
Timeout and tol defaults for tutorials.py.
jblueh Sep 28, 2022
94f4b23
Timeout and tol defaults for serial_regression.py.
jblueh Sep 28, 2022
977812c
Timeout and tol defaults for parallel_regression.py.
jblueh Sep 28, 2022
dc6b77d
Filediff tests don't need tolerances.
jblueh Sep 28, 2022
9cced8e
Merge branch 'develop' into misc_fixes
jblueh Sep 28, 2022
79a3bf9
Fix.
jblueh Sep 28, 2022
a6bae1f
Function for repeated code to allow MPI as root.
jblueh Sep 29, 2022
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
2 changes: 1 addition & 1 deletion SU2_CFD/src/fluid/CFluidScalar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include "../../include/fluid/CPolynomialViscosity.hpp"
#include "../../include/fluid/CSutherland.hpp"

CFluidScalar::CFluidScalar(su2double val_Cp, su2double val_gas_constant, const su2double value_pressure_operating,
CFluidScalar::CFluidScalar(su2double val_Cp, su2double val_gas_constant, su2double value_pressure_operating,
const CConfig* config)
: CFluidModel(),
n_species_mixture(config->GetnSpecies() + 1),
Expand Down
100 changes: 61 additions & 39 deletions TestCases/TestCase.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,40 @@ def print_vals(vals, name="Values"):

class TestCase:

class Command:
""" Split a command into launch part, the executable itself and parameters.

Attributes
----------
launch : str
e.g. "mpirun -n 2", possibly empty
exec : str
e.g. "SU2_CFD", must be suitable to identify the processes started by the command
param : str
e.g. "-t 2", possibly empty
"""

def __init__(self, launch = "", exec = "", param = ""):
self.launch = launch
self.exec = exec
self.param = param

def empty(self):
return self.launch == "" and self.exec == "" and self.param == ""

def assemble(self):
assert self.exec != ""
return " ".join([part for part in [self.launch, self.exec, self.param] if part != ""])

def allow_mpi_as_root(self):
if os.geteuid() == 0:
if self.launch.startswith('mpirun'):
self.launch = self.launch.replace('mpirun', 'mpirun --allow-run-as-root')

def killall(self):
""" Issues a shell command that kills all processes matching self.exec, except this process. """
os.system('pgrep %s | grep -vx %d | xargs kill -9' % (self.exec, os.getpid()))

def __init__(self,tag_in):

self.tag = tag_in # Input, string tag that identifies this run
Expand Down Expand Up @@ -67,11 +101,9 @@ def __init__(self,tag_in):
self.test_vals_aarch64 = []
self.cpu_arch = platform.processor()
self.enabled_on_cpu_arch = ["x86_64", "aarch64"]

# These can be optionally varied
self.su2_exec = "SU2_CFD"
self.timeout = 300
self.tol = 0.001
self.command = self.Command()
self.timeout = 0
self.tol = 0.0

# Options for file-comparison tests
self.reference_file = "of_grad.dat.ref"
Expand All @@ -91,9 +123,7 @@ def run_test(self):
start_solver = True

# if root, add flag to mpirun
if os.geteuid()==0:
if self.su2_exec.startswith('mpirun'):
self.su2_exec = self.su2_exec.replace('mpirun', 'mpirun --allow-run-as-root')
self.command.allow_mpi_as_root()

# Adjust the number of iterations in the config file
if len(self.test_vals) != 0:
Expand All @@ -111,11 +141,9 @@ def run_test(self):

# Check for polar calls
if self.polar:
command = "%s > %s" % (self.su2_exec, logfilename)
shell_command = "%s > %s" % (self.command.assemble(), logfilename)
else:
command = "%s %s > %s 2>&1" % (self.su2_exec,
self.cfg_file,
logfilename)
shell_command = "%s %s > %s 2>&1" % (self.command.assemble(), self.cfg_file, logfilename)

self.adjust_test_data()

Expand All @@ -124,7 +152,7 @@ def run_test(self):
os.chdir(self.cfg_dir)
print(os.getcwd())
start = datetime.datetime.now()
process = subprocess.Popen(command, shell=True) # This line launches SU2
process = subprocess.Popen(shell_command, shell=True) # This line launches SU2

# check for timeout
while process.poll() is None:
Expand All @@ -134,7 +162,7 @@ def run_test(self):
if running_time > self.timeout:
try:
process.kill()
os.system('killall %s' % self.su2_exec) # In case of parallel execution
self.command.killall() # In case of parallel execution
except AttributeError: # popen.kill apparently fails on some versions of subprocess... the killall command should take care of things!
pass
timed_out = True
Expand Down Expand Up @@ -204,7 +232,7 @@ def run_test(self):
print('Output for the failed case')
subprocess.call(['cat', logfilename])

print('execution command: %s'%command)
print('execution command: %s' % shell_command)

if timed_out:
print('ERROR: Execution timed out. timeout=%d'%self.timeout)
Expand Down Expand Up @@ -251,20 +279,18 @@ def run_filediff(self):
self.adjust_test_data()

# if root, add flag to mpirun
if os.geteuid()==0:
if self.su2_exec.startswith('mpirun'):
self.su2_exec = self.su2_exec.replace('mpirun', 'mpirun --allow-run-as-root')
self.command.allow_mpi_as_root()

# Assemble the shell command to run
logfilename = '%s.log' % os.path.splitext(self.cfg_file)[0]
command = "%s %s > %s 2>&1" % (self.su2_exec, self.cfg_file, logfilename)
shell_command = "%s %s > %s 2>&1" % (self.command.assemble(), self.cfg_file, logfilename)

# Run SU2
workdir = os.getcwd()
os.chdir(self.cfg_dir)
print(os.getcwd())
start = datetime.datetime.now()
process = subprocess.Popen(command, shell=True) # This line launches SU2
process = subprocess.Popen(shell_command, shell=True) # This line launches SU2

# check for timeout
while process.poll() is None:
Expand All @@ -274,7 +300,7 @@ def run_filediff(self):
if running_time > self.timeout:
try:
process.kill()
os.system('killall %s' % self.su2_exec) # In case of parallel execution
self.command.killall() # In case of parallel execution
except AttributeError: # popen.kill apparently fails on some versions of subprocess... the killall command should take care of things!
pass
timed_out = True
Expand Down Expand Up @@ -350,14 +376,14 @@ def run_opt(self):

# Assemble the shell command to run SU2
logfilename = '%s.log' % os.path.splitext(self.cfg_file)[0]
command = "%s %s > %s 2>&1" % (self.su2_exec, self.cfg_file, logfilename)
shell_command = "%s %s > %s 2>&1" % (self.command.assemble(), self.cfg_file, logfilename)

# Run SU2
workdir = os.getcwd()
os.chdir(self.cfg_dir)
print(os.getcwd())
start = datetime.datetime.now()
process = subprocess.Popen(command, shell=True) # This line launches SU2
process = subprocess.Popen(shell_command, shell=True) # This line launches SU2

# check for timeout
while process.poll() is None:
Expand All @@ -367,7 +393,7 @@ def run_opt(self):
if running_time > self.timeout:
try:
process.kill()
os.system('killall %s' % self.su2_exec) # In case of parallel execution
self.command.killall() # In case of parallel execution
except AttributeError: # popen.kill apparently fails on some versions of subprocess... the killall command should take care of things!
pass
timed_out = True
Expand Down Expand Up @@ -427,7 +453,7 @@ def run_opt(self):
print('Output for the failed case')
subprocess.call(['cat', logfilename])

print('execution command: %s'%command)
print('execution command: %s' % shell_command)

if timed_out:
print('ERROR: Execution timed out. timeout=%d'%self.timeout)
Expand Down Expand Up @@ -476,20 +502,18 @@ def run_geo(self):
self.adjust_test_data()

# if root, add flag to mpirun
if os.geteuid()==0:
if self.su2_exec.startswith('mpirun'):
self.su2_exec = self.su2_exec.replace('mpirun', 'mpirun --allow-run-as-root')
self.command.allow_mpi_as_root()

# Assemble the shell command to run SU2
logfilename = '%s.log' % os.path.splitext(self.cfg_file)[0]
command = "%s %s > %s 2>&1" % (self.su2_exec, self.cfg_file, logfilename)
shell_command = "%s %s > %s 2>&1" % (self.command.assemble(), self.cfg_file, logfilename)

# Run SU2
workdir = os.getcwd()
os.chdir(self.cfg_dir)
print(os.getcwd())
start = datetime.datetime.now()
process = subprocess.Popen(command, shell=True) # This line launches SU2
process = subprocess.Popen(shell_command, shell=True) # This line launches SU2

# check for timeout
while process.poll() is None:
Expand All @@ -499,7 +523,7 @@ def run_geo(self):
if running_time > self.timeout:
try:
process.kill()
os.system('killall %s' % self.su2_exec) # In case of parallel execution
self.command.killall() # In case of parallel execution
except AttributeError: # popen.kill apparently fails on some versions of subprocess... the killall command should take care of things!
pass
timed_out = True
Expand Down Expand Up @@ -563,7 +587,7 @@ def run_geo(self):
print('Output for the failed case')
subprocess.call(['cat', logfilename])

print('execution command: %s'%command)
print('execution command: %s' % shell_command)

if timed_out:
print('ERROR: Execution timed out. timeout=%d'%self.timeout)
Expand Down Expand Up @@ -605,20 +629,18 @@ def run_def(self):
self.adjust_test_data()

# if root, add flag to mpirun
if os.geteuid()==0:
if self.su2_exec.startswith('mpirun'):
self.su2_exec = self.su2_exec.replace('mpirun', 'mpirun --allow-run-as-root')
self.command.allow_mpi_as_root()

# Assemble the shell command to run SU2
logfilename = '%s.log' % os.path.splitext(self.cfg_file)[0]
command = "%s %s > %s 2>&1" % (self.su2_exec, self.cfg_file, logfilename)
shell_command = "%s %s > %s 2>&1" % (self.command.assemble(), self.cfg_file, logfilename)

# Run SU2
workdir = os.getcwd()
os.chdir(self.cfg_dir)
print(os.getcwd())
start = datetime.datetime.now()
process = subprocess.Popen(command, shell=True) # This line launches SU2
process = subprocess.Popen(shell_command, shell=True) # This line launches SU2

# check for timeout
while process.poll() is None:
Expand All @@ -628,7 +650,7 @@ def run_def(self):
if running_time > self.timeout:
try:
process.kill()
os.system('killall %s' % self.su2_exec) # In case of parallel execution
self.command.killall() # In case of parallel execution
except AttributeError: # popen.kill apparently fails on some versions of subprocess... the killall command should take care of things!
pass
timed_out = True
Expand Down Expand Up @@ -688,7 +710,7 @@ def run_def(self):
print('Output for the failed case')
subprocess.call(['cat', logfilename])

print('execution command: %s'%command)
print('execution command: %s' % shell_command)

if timed_out:
print('ERROR: Execution timed out. timeout=%d sec'%self.timeout)
Expand Down
4 changes: 2 additions & 2 deletions TestCases/hybrid_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ def main():
pywrapper_translating_naca0012 = TestCase('pywrapper_translating_naca0012')
pywrapper_translating_naca0012.cfg_dir = "py_wrapper/translating_NACA0012"
pywrapper_translating_naca0012.cfg_file = "config.cfg"
pywrapper_translating_naca0012.su2_exec = "python run_su2.py"
pywrapper_translating_naca0012.command = TestCase.Command(exec = "python", param = "run_su2.py")
pywrapper_translating_naca0012.timeout = 60
pywrapper_translating_naca0012.reference_file = "forces_0.csv.ref"
pywrapper_translating_naca0012.reference_file_aarch64 = "forces_0_aarch64.csv.ref"
Expand All @@ -778,7 +778,7 @@ def main():
######################################

for test in test_list:
test.su2_exec = "SU2_CFD -t 2"
test.command = TestCase.Command(exec = "SU2_CFD", param = "-t 2")
test.timeout = 600
test.tol = 1e-4
#end
Expand Down
2 changes: 1 addition & 1 deletion TestCases/hybrid_regression_AD.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def main():
######################################

for test in test_list:
test.su2_exec = "SU2_CFD_AD -t 2"
test.command = TestCase.Command(exec = "SU2_CFD_AD", param = "-t 2")
test.timeout = 600
test.tol = 1e-4
#end
Expand Down
Loading