diff --git a/changelog-entries/702.md b/changelog-entries/702.md
new file mode 100644
index 000000000..a516e714c
--- /dev/null
+++ b/changelog-entries/702.md
@@ -0,0 +1 @@
+- Changed the run script of solvers with DuMux to compile the case before running, also accept given path to DuMux and adpater.
\ No newline at end of file
diff --git a/free-flow-over-porous-media/README.md b/free-flow-over-porous-media/README.md
index cb1de8b47..e77773408 100644
--- a/free-flow-over-porous-media/README.md
+++ b/free-flow-over-porous-media/README.md
@@ -33,9 +33,7 @@ Both the participants are computed using the simulation code [DuMux](
To solve the flows with the DuMux framework, the necessary DUNE modules need to be downloaded and set up. This is done by running `sh setup-dumux.sh` in the tutorial folder.
-Note that if an existing installation of DUNE modules is detected in a default location, this may lead to problems in running the `setup-dumux.sh` script. The script suppresses the environment variable `DUNE_CONTROL_PATH`.
-
-To only recompile the participants, run `sh compile-dumux-cases.sh` in the tutorial folder.
+If an existing path, containing compiled DUNE modules, DuMux and DuMux-adapter, is to be used for compiling the solvers, the path can be specified by setting the arguments while running the script `run.sh` with `-l ` in each solver folder. The environment variable `DUNE_CONTROL_PATH` is suppressed by the script. The `run.sh` scripts in the DuMux solver folders will first compile the solver if not already compiled, and then run the simulation.
## Running the simulation
@@ -52,7 +50,7 @@ To run the porous-media participant, run:
```bash
cd porous-media-dumux
-./run.sh
+./run.sh -l # use -l to specify existing DUNE installation, no need if setup-dumux.sh was used for setup
```
Participants can be executed only in serial. Parallel execution is not supported. The case takes approximately two minutes to finish.
diff --git a/free-flow-over-porous-media/compile-dumux-cases.sh b/free-flow-over-porous-media/compile-dumux-cases.sh
deleted file mode 100755
index c964ef4e4..000000000
--- a/free-flow-over-porous-media/compile-dumux-cases.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/env sh
-set -e -u
-
-# To compile free-flow-dumux and porous-media-dumux from scratch or recompile them after changes
-./dune-common/bin/dunecontrol --opts=./dumux/cmake.opts --only=free_flow_dumux all
-./dune-common/bin/dunecontrol --opts=./dumux/cmake.opts --only=porous_media_dumux all
-
-# Alternatively, you can manually recompile free-flow-dumux and porous-media-dumux when the `build-cmake` folder is present by uncommenting the following lines:
-# (
-# cd free-flow-dumux/build-cmake/solver-dumux
-# make free_flow_dumux
-# )
-
-# (
-# cd porous-media-dumux/build-cmake/solver-dumux
-# make porous_media_dumux
-# )
-
-# Move free-flow-dumux and porous-media-dumux executables to the participant folder level
-mv free-flow-dumux/build-cmake/solver-dumux/free_flow_dumux free-flow-dumux/
-mv porous-media-dumux/build-cmake/solver-dumux/porous_media_dumux porous-media-dumux/
diff --git a/free-flow-over-porous-media/free-flow-dumux/run.sh b/free-flow-over-porous-media/free-flow-dumux/run.sh
index d151945b6..82752f6cd 100755
--- a/free-flow-over-porous-media/free-flow-dumux/run.sh
+++ b/free-flow-over-porous-media/free-flow-dumux/run.sh
@@ -4,6 +4,43 @@ set -e -u
. ../../tools/log.sh
exec > >(tee --append "$LOGFILE") 2>&1
+
+usage() { echo "Usage: cmd [-l ]" 1>&2; exit 1; }
+
+DUNE_COMMON_PATH_SET=
+DUNE_COMMON_PATH_ARG=
+
+while getopts ":l:" opt; do
+ case ${opt} in
+ l)
+ DUNE_COMMON_PATH_SET=1
+ DUNE_COMMON_PATH_ARG="$OPTARG"
+ ;;
+ *)
+ usage
+ ;;
+ esac
+done
+
+if [ ! -d "build-cmake" ]; then
+ echo "Solver not built. Building now..."
+ CASE_DIR=$(pwd)/..
+
+ if [ -z "$DUNE_COMMON_PATH_SET" ]; then
+ ../dune-common/bin/dunecontrol --opts=../dumux/cmake.opts --only=free_flow_dumux all
+ else
+ export DUNE_CONTROL_PATH=$DUNE_COMMON_PATH_ARG:$CASE_DIR
+ "$DUNE_COMMON_PATH_ARG"/dune-common/bin/dunecontrol --opts="$DUNE_COMMON_PATH_ARG"/dumux/cmake.opts --only=free_flow_dumux all
+ fi
+else
+ echo "build-cmake folder found."
+ cd build-cmake
+ make free_flow_dumux
+ cd ..
+fi
+# Move free_flow_dumux executable to the participant folder level
+mv build-cmake/solver-dumux/free_flow_dumux .
+
./free_flow_dumux params.input
close_log
\ No newline at end of file
diff --git a/free-flow-over-porous-media/porous-media-dumux/run.sh b/free-flow-over-porous-media/porous-media-dumux/run.sh
index 1ccbdb99d..64199d604 100755
--- a/free-flow-over-porous-media/porous-media-dumux/run.sh
+++ b/free-flow-over-porous-media/porous-media-dumux/run.sh
@@ -4,6 +4,43 @@ set -e -u
. ../../tools/log.sh
exec > >(tee --append "$LOGFILE") 2>&1
+
+usage() { echo "Usage: cmd [-l ]" 1>&2; exit 1; }
+
+DUNE_COMMON_PATH_SET=
+DUNE_COMMON_PATH_ARG=
+
+while getopts ":l:" opt; do
+ case ${opt} in
+ l)
+ DUNE_COMMON_PATH_SET=1
+ DUNE_COMMON_PATH_ARG="$OPTARG"
+ ;;
+ *)
+ usage
+ ;;
+ esac
+done
+
+if [ ! -d "build-cmake" ]; then
+ echo "Solver not built. Building now..."
+ CASE_DIR=$(pwd)/..
+
+ if [ -z "$DUNE_COMMON_PATH_SET" ]; then
+ ../dune-common/bin/dunecontrol --opts=../dumux/cmake.opts --only=porous_media_dumux all
+ else
+ export DUNE_CONTROL_PATH=$DUNE_COMMON_PATH_ARG:$CASE_DIR
+ "$DUNE_COMMON_PATH_ARG"/dune-common/bin/dunecontrol --opts="$DUNE_COMMON_PATH_ARG"/dumux/cmake.opts --only=porous_media_dumux all
+ fi
+else
+ echo "build-cmake folder found."
+ cd build-cmake
+ make porous_media_dumux
+ cd ..
+fi
+# Move porous_media_dumux executable to the participant folder level
+mv build-cmake/solver-dumux/porous_media_dumux .
+
./porous_media_dumux params.input
close_log
\ No newline at end of file
diff --git a/free-flow-over-porous-media/setup-dumux.sh b/free-flow-over-porous-media/setup-dumux.sh
index 56fc29fc6..ef1b8a19d 100755
--- a/free-flow-over-porous-media/setup-dumux.sh
+++ b/free-flow-over-porous-media/setup-dumux.sh
@@ -31,5 +31,6 @@ DUNE_CONTROL_PATH=. python3 dumux/bin/installexternal.py spgrid
# Re-build environment
DUNE_CONTROL_PATH=. ./dune-common/bin/dunecontrol --opts=./dumux/cmake.opts all
-# Compile and move macro-dumux and micro-dumux executables to the participant folder level
-./compile-dumux-cases.sh
+# Move solver executables to the participant folder level
+mv free-flow-dumux/build-cmake/solver-dumux/free_flow_dumux free-flow-dumux/
+mv porous-media-dumux/build-cmake/solver-dumux/porous_media_dumux porous-media-dumux/
diff --git a/two-scale-heat-conduction/README.md b/two-scale-heat-conduction/README.md
index 782fec807..85734ac7d 100644
--- a/two-scale-heat-conduction/README.md
+++ b/two-scale-heat-conduction/README.md
@@ -35,7 +35,7 @@ preCICE configuration (image generated using the [precice-config-visualizer](htt
To solve either the macro or micro simulations with the DuMux framework, the necessary DUNE modules need to be downloaded and set up. This is done by running `sh setup-dumux.sh` in the tutorial folder.
-Note that if an existing installation of DUNE modules is detected in a default location, this may lead to problems in running the `setup-dumux.sh` script. The environment variable `DUNE_CONTROL_PATH` is suppressed by the script.
+If an existing path, containing compiled DUNE modules, DuMux and DuMux-adapter, is to be used for compiling the solvers, the path can be specified by setting the arguments while running the script `run.sh` with `-l ` in each solver folder. The environment variable `DUNE_CONTROL_PATH` is suppressed by the script. The `run.sh` scripts in the DuMux solver folders will first compile the solver if not already compiled, and then run the simulation.
## Running the simulation
@@ -55,7 +55,12 @@ cd micro-nutils
./run.sh -s
```
-If you want to use DuMux, use `cd macro-dumux` instead of `cd macro-nutils` and/or `cd micro-dumux` instead of `cd micro-nutils`.
+If you want to use DuMux, use `cd macro-dumux` instead of `cd macro-nutils` and/or `cd micro-dumux` instead of `cd micro-nutils`. For example, to run the macro simulation with DuMux, run:
+
+```bash
+cd macro-dumux
+./run.sh -s -l # to specify existing DUNE installation with -l and run the compiled simulation in serial
+```
## Running the simulation in parallel
diff --git a/two-scale-heat-conduction/compile-dumux-cases.sh b/two-scale-heat-conduction/compile-dumux-cases.sh
deleted file mode 100755
index 390b1c437..000000000
--- a/two-scale-heat-conduction/compile-dumux-cases.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/env sh
-set -e -u
-
-# To compile macro-dumux and micro-dumux from scratch or recompile them after changes
-./dune-common/bin/dunecontrol --opts=./dumux/cmake.opts --only=macro_dumux all
-./dune-common/bin/dunecontrol --opts=./dumux/cmake.opts --only=micro_sim all
-
-# Alternatively, you can manually recompile macro-dumux and micro-dumux when the `build-cmake` folder is present by uncommenting the following lines:
-# (
-# cd macro-dumux/build-cmake/appl
-# make macro_dumux
-# )
-# (
-# cd micro-dumux/build-cmake/appl
-# make micro_sim
-# )
-
-# Move macro-dumux and micro-dumux executables to the participant folder level
-mv macro-dumux/build-cmake/appl/macro_dumux macro-dumux/
-mv micro-dumux/build-cmake/appl/micro_sim.cpython-*.so micro-dumux/
diff --git a/two-scale-heat-conduction/macro-dumux/run.sh b/two-scale-heat-conduction/macro-dumux/run.sh
index 5ec63c7d2..87df2d2b3 100755
--- a/two-scale-heat-conduction/macro-dumux/run.sh
+++ b/two-scale-heat-conduction/macro-dumux/run.sh
@@ -4,21 +4,26 @@ set -e -u
. ../../tools/log.sh
exec > >(tee --append "$LOGFILE") 2>&1
-usage() { echo "Usage: cmd [-s] [-p n]" 1>&2; exit 1; }
+usage() { echo "Usage: cmd [-s] [-p n] [-l ]" 1>&2; exit 1; }
-# Check if no input argument was provided
-if [ -z "$*" ] ; then
- echo "No input argument provided. Macro solver is launched in serial"
- ./macro_dumux params.input
-fi
+SERIAL_RUN=
+PARALLEL_RUN=
+RANK_COUNT=
+DUNE_COMMON_PATH_SET=
+DUNE_COMMON_PATH_ARG=
-while getopts ":sp" opt; do
+while getopts ":sp:l:" opt; do
case ${opt} in
s)
- ./macro_dumux params.input
+ SERIAL_RUN=1
;;
p)
- mpiexec -n "$2" macro_dumux params.input
+ RANK_COUNT="$OPTARG"
+ PARALLEL_RUN=1
+ ;;
+ l)
+ DUNE_COMMON_PATH_SET=1
+ DUNE_COMMON_PATH_ARG="$OPTARG"
;;
*)
usage
@@ -26,4 +31,36 @@ while getopts ":sp" opt; do
esac
done
+if [ ! -d "build-cmake" ]; then
+ echo "Solver not built. Building now..."
+ CASE_DIR=$(pwd)/..
+
+ if [ -z "$DUNE_COMMON_PATH_SET" ]; then
+ ../dune-common/bin/dunecontrol --opts=../dumux/cmake.opts --only=macro_dumux all
+ else
+ export DUNE_CONTROL_PATH=$DUNE_COMMON_PATH_ARG:$CASE_DIR
+ "$DUNE_COMMON_PATH_ARG"/dune-common/bin/dunecontrol --opts="$DUNE_COMMON_PATH_ARG"/dumux/cmake.opts --only=macro_dumux all
+ fi
+else
+ echo "build-cmake folder found."
+ cd build-cmake
+ make macro_dumux
+ cd ..
+fi
+# Move macro-dumux executable to the participant folder level
+mv ./build-cmake/appl/macro_dumux .
+
+if [ -n "$SERIAL_RUN" ] && [ -n "$PARALLEL_RUN" ]; then
+ echo "Cannot run both serial and parallel. Choose one option."
+ usage
+elif [ -z "$SERIAL_RUN" ] && [ -z "$PARALLEL_RUN" ]; then
+ echo "No run option provided. The macro solver is launched in serial."
+fi
+
+if [ -n "$PARALLEL_RUN" ]; then
+ mpiexec -n "$RANK_COUNT" macro_dumux params.input
+else
+ ./macro_dumux params.input
+fi
+
close_log
diff --git a/two-scale-heat-conduction/micro-dumux/run.sh b/two-scale-heat-conduction/micro-dumux/run.sh
index 1f0db55aa..ac4d117cd 100755
--- a/two-scale-heat-conduction/micro-dumux/run.sh
+++ b/two-scale-heat-conduction/micro-dumux/run.sh
@@ -4,21 +4,26 @@ set -e -u
. ../../tools/log.sh
exec > >(tee --append "$LOGFILE") 2>&1
-usage() { echo "Usage: cmd [-s] [-p n]" 1>&2; exit 1; }
+usage() { echo "Usage: cmd [-s] [-p n] [-l ]" 1>&2; exit 1; }
-# Check if no input argument was provided
-if [ -z "$*" ] ; then
- echo "No input argument provided. Micro Manager is launched in serial"
- micro-manager-precice micro-manager-config.json
-fi
+SERIAL_RUN=
+PARALLEL_RUN=
+RANK_COUNT=
+DUNE_COMMON_PATH_SET=
+DUNE_COMMON_PATH_ARG=
-while getopts ":sp" opt; do
+while getopts ":sp:l:" opt; do
case ${opt} in
s)
- micro-manager-precice micro-manager-config.json
+ SERIAL_RUN=1
;;
p)
- mpiexec -n "$2" micro-manager-precice micro-manager-config.json
+ RANK_COUNT="$OPTARG"
+ PARALLEL_RUN=1
+ ;;
+ l)
+ DUNE_COMMON_PATH_SET=1
+ DUNE_COMMON_PATH_ARG="$OPTARG"
;;
*)
usage
@@ -26,4 +31,36 @@ while getopts ":sp" opt; do
esac
done
+if [ ! -d "build-cmake" ]; then
+ echo "Solver not built. Building now..."
+ CASE_DIR=$(pwd)/..
+
+ if [ -z "$DUNE_COMMON_PATH_SET" ]; then
+ ../dune-common/bin/dunecontrol --opts=../dumux/cmake.opts --only=micro_sim all
+ else
+ export DUNE_CONTROL_PATH=$DUNE_COMMON_PATH_ARG:$CASE_DIR
+ "$DUNE_COMMON_PATH_ARG"/dune-common/bin/dunecontrol --opts="$DUNE_COMMON_PATH_ARG"/dumux/cmake.opts --only=micro_sim all
+ fi
+else
+ echo "build-cmake folder found."
+ cd build-cmake
+ make micro_sim
+ cd ..
+fi
+# Move micro_sim executable to the participant folder level
+mv ./build-cmake/appl/micro_sim*.so .
+
+if [ -n "$SERIAL_RUN" ] && [ -n "$PARALLEL_RUN" ]; then
+ echo "Cannot run both serial and parallel. Choose one option."
+ usage
+elif [ -z "$SERIAL_RUN" ] && [ -z "$PARALLEL_RUN" ]; then
+ echo "No run option provided. The macro solver is launched in serial."
+fi
+
+if [ -n "$PARALLEL_RUN" ]; then
+ mpiexec -n "$RANK_COUNT" micro-manager-precice micro-manager-config.json
+else
+ micro-manager-precice micro-manager-config.json
+fi
+
close_log
diff --git a/two-scale-heat-conduction/setup-dumux.sh b/two-scale-heat-conduction/setup-dumux.sh
index bea25a74c..150d5f0ae 100755
--- a/two-scale-heat-conduction/setup-dumux.sh
+++ b/two-scale-heat-conduction/setup-dumux.sh
@@ -34,4 +34,5 @@ DUNE_CONTROL_PATH=. python3 dumux/bin/installexternal.py spgrid
DUNE_CONTROL_PATH=. ./dune-common/bin/dunecontrol --opts=./dumux/cmake.opts all
# Compile and move macro-dumux and micro-dumux executables to the participant folder level
-./compile-dumux-cases.sh
+mv macro-dumux/build-cmake/appl/macro_dumux macro-dumux/
+mv micro-dumux/build-cmake/appl/micro_sim*.so micro-dumux/