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..ca5246ae2 100644
--- a/free-flow-over-porous-media/README.md
+++ b/free-flow-over-porous-media/README.md
@@ -27,15 +27,13 @@ preCICE configuration (image generated using the [precice-config-visualizer](htt
## Available solvers
-Both the participants are computed using the simulation code [DuMux](https://git.iws.uni-stuttgart.de/dumux-repositories/dumux/).
+Both the participants are computed using the simulation code [DuMux](https://git.iws.uni-stuttgart.de/dumux-repositories/dumux/).
## Solver setup
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
@@ -55,6 +53,12 @@ cd porous-media-dumux
./run.sh
```
+This assumes a DuMux and DUNE modules installation in the case folder. You can specify the path to an existing DUNE installation with with `-l`:
+
+```bash
+./run.sh -l
+```
+
Participants can be executed only in serial. Parallel execution is not supported. The case takes approximately two minutes to finish.
## Post-processing
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..38c1602bb 100644
--- a/two-scale-heat-conduction/README.md
+++ b/two-scale-heat-conduction/README.md
@@ -27,15 +27,15 @@ preCICE configuration (image generated using the [precice-config-visualizer](htt
## Available solvers and dependencies
-* Both the macro and micro simulations can be solved using the finite element library [Nutils](https://nutils.org/install.html) v7 or the simulation framework [DuMux](https://git.iws.uni-stuttgart.de/dumux-repositories/dumux/).
+* Both the macro and micro simulations can be solved using the finite element library [Nutils](https://nutils.org/install.html) v7 or the simulation framework [DuMux](https://git.iws.uni-stuttgart.de/dumux-repositories/dumux/).
* While using Nutils, the macro simulation is written in Python, so it requires the [Python bindings of preCICE](https://precice.org/installation-bindings-python.html).
* The [Micro Manager](https://precice.org/tooling-micro-manager-installation.html) controls all micro-simulations and facilitates coupling via preCICE. Use the [develop](https://github.com/precice/micro-manager/tree/develop) branch of the Micro Manager.
-### DuMux setup
+### DuMux setup
-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.
+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,18 @@ 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 in serial (default), run:
+
+```bash
+cd macro-dumux
+./run.sh -s
+```
+
+This assumes a DuMux and DUNE modules installation in the case folder. You can specify the path to an existing DUNE installation with with `-l`:
+
+```bash
+./run.sh -s -l
+```
## Running the simulation in parallel
@@ -74,7 +85,7 @@ Running `micro-dumux` is much faster. A serial simulation takes approximately 2
## Post-processing
-Here are the results from Nutils-Nutils and DuMux-DuMux combination:
+Here are the results from Nutils-Nutils and DuMux-DuMux combination:
@@ -88,4 +99,4 @@ The participant `macro-nutils` outputs `macro-*.vtk` files which can be viewed i
The micro simulations themselves have a circular micro structure which is resolved in every time step. To output VTK files for each micro simulation, uncomment the `output()` function in the file `micro-nutils/micro.py`. The figure above shows the changing phase field used to represent the circular micro structure and the diffuse interface width.
-Similar to the output data files from simulation with Nutils, the `VTU` files from macro and micro solvers, that are written in DuMux, could also be rendered and inspected with ParaView with the mentioned method.
+Similar to the output data files from simulation with Nutils, the `VTU` files from macro and micro solvers, that are written in DuMux, could also be rendered and inspected with ParaView with the mentioned method.
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/