Commit 7cc84da5 authored by Santiago Ospina's avatar Santiago Ospina

Added keyword in inifile to select the dorie executable

Signed-off-by: Santiago Ospina De Los Ríos's avatarSantiago Ospina <santiago.ospina@iup.uni-heidelberg.de>
parent de44584d
...@@ -31,6 +31,20 @@ adding an empty line, make text **bold** or ``monospaced``. ...@@ -31,6 +31,20 @@ adding an empty line, make text **bold** or ``monospaced``.
--> -->
<dorie> <dorie>
<category name="simulation">
<parameter name="mode">
<definition> Sets the simulation mode of DORiE.
(``richards``) mode calculates the matric head and produce water with a
DG scheme and produce water fluxes with Raviart Thomas reconstruction.
(``richards+transport``) mode calculates (``richards``) mode and use
the generated water flux and saturation at each step to calculate the
solute transport model for unsaturated media with a DG scheme.
</definition>
<suggestion> richards </suggestion>
<values> richards, richards+transport </values>
</parameter>
</category>
<category name="output"> <category name="output">
<parameter name="verbose"> <parameter name="verbose">
<definition> Overall verbosity of the program </definition> <definition> Overall verbosity of the program </definition>
......
...@@ -8,8 +8,10 @@ endif() ...@@ -8,8 +8,10 @@ endif()
add_executable("transport" transport.cc) add_executable("transport" transport.cc)
dune_target_link_libraries(transport dorie-impl ${DUNE_LIBS}) dune_target_link_libraries(transport dorie-impl ${DUNE_LIBS})
add_executable("dorie" dorie.cc) add_executable("richards" richards.cc)
dune_target_link_libraries(dorie dorie-impl ${DUNE_LIBS}) dune_target_link_libraries(richards dorie-impl ${DUNE_LIBS})
add_custom_target("dorie" DEPENDS richards transport)
# enable setting operator scheme from config file # enable setting operator scheme from config file
if(EXPERIMENTAL_DG_FEATURES) if(EXPERIMENTAL_DG_FEATURES)
......
...@@ -3,6 +3,8 @@ import sys ...@@ -3,6 +3,8 @@ import sys
import shutil import shutil
import subprocess import subprocess
from dune.testtools.parser import parse_ini_file
try: # Python 2.x compatibility try: # Python 2.x compatibility
input = raw_input input = raw_input
except NameError: except NameError:
...@@ -16,7 +18,8 @@ MPIEXEC_PREFLAG = "" ...@@ -16,7 +18,8 @@ MPIEXEC_PREFLAG = ""
MPIEXEC_POSTFLAGS = "" MPIEXEC_POSTFLAGS = ""
# set some paths # set some paths
DORIE_EXECUTABLE = os.path.join(DORIEDIR, "dune/dorie/dorie") RICHARDS_EXECUTABLE = os.path.join(DORIEDIR, "dune/dorie/richards")
TRANSPORT_EXECUTABLE = os.path.join(DORIEDIR, "dune/dorie/transport")
PARAMETERDIR = os.path.join(DORIEDIR, "doc/default_files") PARAMETERDIR = os.path.join(DORIEDIR, "doc/default_files")
def MPIRUN(nproc,exe,*args,**kwargs): def MPIRUN(nproc,exe,*args,**kwargs):
mpi_flags = kwargs.get("mpi_flags") or [] mpi_flags = kwargs.get("mpi_flags") or []
...@@ -25,16 +28,47 @@ def MPIRUN(nproc,exe,*args,**kwargs): ...@@ -25,16 +28,47 @@ def MPIRUN(nproc,exe,*args,**kwargs):
MPIEXEC_POSTFLAGS] + list(args) if k] MPIEXEC_POSTFLAGS] + list(args) if k]
def run(args): def run(args):
if not os.path.isfile(args["config"]):
raise IOError("Configuration file {} not found".format(args["config"]))
try:
iniinfo = parse_ini_file(args["config"])
if not "simulation.mode" in iniinfo:
raise ValueError("Key simulation.mode has to be given")
dorie_mode = iniinfo["simulation.mode"]
if dorie_mode == "richards":
run_richards(args)
elif dorie_mode == "richards+transport":
run_transport(args)
else:
raise IOError("Key simulation.mode = {} not known".format(dorie_mode))
except subprocess.CalledProcessError:
print("Error while running DORiE in 'richards' mode")
sys.exit(1)
def run_richards(args):
if not os.path.isfile(args["config"]): if not os.path.isfile(args["config"]):
raise IOError("Configuration file {} not found".format(args["config"])) raise IOError("Configuration file {} not found".format(args["config"]))
try: try:
if args["parallel"] == 1: if args["parallel"] == 1:
subprocess.check_call([DORIE_EXECUTABLE, args["config"]]) subprocess.check_call([RICHARDS_EXECUTABLE, args["config"]])
else: else:
subprocess.check_call(MPIRUN(args["parallel"], DORIE_EXECUTABLE, subprocess.check_call(MPIRUN(args["parallel"], RICHARDS_EXECUTABLE,
args["config"], mpi_flags=args["mpi_flags"])) args["config"], mpi_flags=args["mpi_flags"]))
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
print("Error while running DORiE") print("Error while running DORiE in 'richards' mode")
sys.exit(1)
def run_transport(args):
if not os.path.isfile(args["config"]):
raise IOError("Configuration file {} not found".format(args["config"]))
try:
if args["parallel"] == 1:
subprocess.check_call([TRANSPORT_EXECUTABLE, args["config"]])
else:
subprocess.check_call(MPIRUN(args["parallel"], TRANSPORT_EXECUTABLE,
args["config"], mpi_flags=args["mpi_flags"]))
except subprocess.CalledProcessError:
print("Error while running DORiE in 'richards+transport' mode")
sys.exit(1) sys.exit(1)
def create(args): def create(args):
......
...@@ -3,6 +3,8 @@ import sys ...@@ -3,6 +3,8 @@ import sys
import shutil import shutil
import subprocess import subprocess
from dune.testtools.parser import parse_ini_file
try: # Python 2.x compatibility try: # Python 2.x compatibility
input = raw_input input = raw_input
except NameError: except NameError:
...@@ -16,7 +18,8 @@ MPIEXEC_PREFLAG = "@MPIEXEC_PREFLAG@" ...@@ -16,7 +18,8 @@ MPIEXEC_PREFLAG = "@MPIEXEC_PREFLAG@"
MPIEXEC_POSTFLAGS = "@MPIEXEC_POSTFLAGS@" MPIEXEC_POSTFLAGS = "@MPIEXEC_POSTFLAGS@"
# set some paths # set some paths
DORIE_EXECUTABLE = os.path.join(DORIEDIR, "dune/dorie/dorie") RICHARDS_EXECUTABLE = os.path.join(DORIEDIR, "dune/dorie/richards")
TRANSPORT_EXECUTABLE = os.path.join(DORIEDIR, "dune/dorie/transport")
PARAMETERDIR = os.path.join(DORIEDIR, "doc/default_files") PARAMETERDIR = os.path.join(DORIEDIR, "doc/default_files")
def MPIRUN(nproc,exe,*args,**kwargs): def MPIRUN(nproc,exe,*args,**kwargs):
mpi_flags = kwargs.get("mpi_flags") or [] mpi_flags = kwargs.get("mpi_flags") or []
...@@ -25,16 +28,47 @@ def MPIRUN(nproc,exe,*args,**kwargs): ...@@ -25,16 +28,47 @@ def MPIRUN(nproc,exe,*args,**kwargs):
MPIEXEC_POSTFLAGS] + list(args) if k] MPIEXEC_POSTFLAGS] + list(args) if k]
def run(args): def run(args):
if not os.path.isfile(args["config"]):
raise IOError("Configuration file {} not found".format(args["config"]))
try:
iniinfo = parse_ini_file(args["config"])
if not "simulation.mode" in iniinfo:
raise ValueError("Key simulation.mode has to be given")
dorie_mode = iniinfo["simulation.mode"]
if dorie_mode == "richards":
run_richards(args)
elif dorie_mode == "richards+transport":
run_transport(args)
else:
raise IOError("Key simulation.mode = {} not known".format(dorie_mode))
except subprocess.CalledProcessError:
print("Error while running DORiE in 'richards' mode")
sys.exit(1)
def run_richards(args):
if not os.path.isfile(args["config"]): if not os.path.isfile(args["config"]):
raise IOError("Configuration file {} not found".format(args["config"])) raise IOError("Configuration file {} not found".format(args["config"]))
try: try:
if args["parallel"] == 1: if args["parallel"] == 1:
subprocess.check_call([DORIE_EXECUTABLE, args["config"]]) subprocess.check_call([RICHARDS_EXECUTABLE, args["config"]])
else: else:
subprocess.check_call(MPIRUN(args["parallel"], DORIE_EXECUTABLE, subprocess.check_call(MPIRUN(args["parallel"], RICHARDS_EXECUTABLE,
args["config"], mpi_flags=args["mpi_flags"])) args["config"], mpi_flags=args["mpi_flags"]))
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
print("Error while running DORiE") print("Error while running DORiE in 'richards' mode")
sys.exit(1)
def run_transport(args):
if not os.path.isfile(args["config"]):
raise IOError("Configuration file {} not found".format(args["config"]))
try:
if args["parallel"] == 1:
subprocess.check_call([TRANSPORT_EXECUTABLE, args["config"]])
else:
subprocess.check_call(MPIRUN(args["parallel"], TRANSPORT_EXECUTABLE,
args["config"], mpi_flags=args["mpi_flags"]))
except subprocess.CalledProcessError:
print("Error while running DORiE in 'richards+transport' mode")
sys.exit(1) sys.exit(1)
def create(args): def create(args):
......
...@@ -5,6 +5,8 @@ __name = test-transport-layered ...@@ -5,6 +5,8 @@ __name = test-transport-layered
_test_command = run _test_command = run
_asset_path = "${CMAKE_CURRENT_LIST_DIR}" _asset_path = "${CMAKE_CURRENT_LIST_DIR}"
simulation.mode = richards+transport
grid.gridType = rectangular grid.gridType = rectangular
grid.initialLevel = 2 grid.initialLevel = 2
grid.cells = 20 20 grid.cells = 20 20
......
...@@ -5,6 +5,8 @@ __name = test-transport-miller ...@@ -5,6 +5,8 @@ __name = test-transport-miller
_test_command = run _test_command = run
_asset_path = "${CMAKE_CURRENT_LIST_DIR}" _asset_path = "${CMAKE_CURRENT_LIST_DIR}"
simulation.mode = richards+transport
grid.gridType = rectangular grid.gridType = rectangular
grid.initialLevel = 0 grid.initialLevel = 0
grid.cells = 50 50 grid.cells = 50 50
......
...@@ -5,6 +5,8 @@ __name = test-transport-muphi ...@@ -5,6 +5,8 @@ __name = test-transport-muphi
_test_command = run _test_command = run
_asset_path = "${CMAKE_CURRENT_LIST_DIR}" _asset_path = "${CMAKE_CURRENT_LIST_DIR}"
simulation.mode = richards+transport
grid.dimensions = 2 grid.dimensions = 2
grid.initialLevel = 0 grid.initialLevel = 0
grid.gridType = rectangular grid.gridType = rectangular
......
...@@ -5,6 +5,8 @@ __name = test-transport-sand ...@@ -5,6 +5,8 @@ __name = test-transport-sand
_test_command = run _test_command = run
_asset_path = "${CMAKE_CURRENT_LIST_DIR}" _asset_path = "${CMAKE_CURRENT_LIST_DIR}"
simulation.mode = richards+transport
grid.gridType = rectangular grid.gridType = rectangular
grid.initialLevel = 0 grid.initialLevel = 0
grid.cells = 50 50 grid.cells = 50 50
......
...@@ -5,6 +5,8 @@ __name = test-transport-silt ...@@ -5,6 +5,8 @@ __name = test-transport-silt
_test_command = run _test_command = run
_asset_path = "${CMAKE_CURRENT_LIST_DIR}" _asset_path = "${CMAKE_CURRENT_LIST_DIR}"
simulation.mode = richards+transport
grid.gridType = rectangular grid.gridType = rectangular
grid.initialLevel = 0 grid.initialLevel = 0
grid.cells = 50 50 grid.cells = 50 50
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment