From 5651cf8b1973793a0245c4a4dfe038b8749d42a6 Mon Sep 17 00:00:00 2001 From: Jun Chen Date: Tue, 27 Jan 2026 18:03:16 +0100 Subject: [PATCH 1/4] Provide compilation option for existing dumux installation --- free-flow-over-porous-media/README.md | 6 ++-- .../compile-dumux-cases.sh | 21 ------------ .../free-flow-dumux/run.sh | 33 +++++++++++++++++++ .../porous-media-dumux/run.sh | 33 +++++++++++++++++++ free-flow-over-porous-media/setup-dumux.sh | 5 +-- two-scale-heat-conduction/README.md | 9 +++-- .../compile-dumux-cases.sh | 20 ----------- two-scale-heat-conduction/macro-dumux/run.sh | 32 +++++++++++++++++- two-scale-heat-conduction/micro-dumux/run.sh | 32 +++++++++++++++++- two-scale-heat-conduction/setup-dumux.sh | 3 +- 10 files changed, 142 insertions(+), 52 deletions(-) delete mode 100755 free-flow-over-porous-media/compile-dumux-cases.sh delete mode 100755 two-scale-heat-conduction/compile-dumux-cases.sh diff --git a/free-flow-over-porous-media/README.md b/free-flow-over-porous-media/README.md index cb1de8b47..71a1e7c4b 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 installation of DUNE modules and DuMux 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..56bd2e91f 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,39 @@ set -e -u . ../../tools/log.sh exec > >(tee --append "$LOGFILE") 2>&1 + +usage() { echo "Usage: cmd [-l ]" 1>&2; exit 1; } + +if [ ! -d "build-cmake" ]; then + echo "No build-cmake folder found. Compiling micro-dumux." + CASE_DIR=$(pwd)/.. + + while getopts ":l:" opt; do + case ${opt} in + l) + DUNE_COMMON_PATH_ARG=$OPTARG + ;; + *) + usage + ;; + esac + done + if [ -z "$DUNE_COMMON_PATH_ARG" ]; then + ../dune-common/bin/dunecontrol --opts=../dumux/cmake.opts --only=free_flow_dumux all + else + DUNE_COMMON_PATH=$DUNE_COMMON_PATH_ARG + export DUNE_CONTROL_PATH=$DUNE_COMMON_PATH:$CASE_DIR + "$DUNE_COMMON_PATH"/dune-common/bin/dunecontrol --opts="$DUNE_COMMON_PATH"/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..ecf011458 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,39 @@ set -e -u . ../../tools/log.sh exec > >(tee --append "$LOGFILE") 2>&1 + +usage() { echo "Usage: cmd [-l ]" 1>&2; exit 1; } + +if [ ! -d "build-cmake" ]; then + echo "No build-cmake folder found. Compiling micro-dumux." + CASE_DIR=$(pwd)/.. + + while getopts ":l:" opt; do + case ${opt} in + l) + DUNE_COMMON_PATH_ARG=$OPTARG + ;; + *) + usage + ;; + esac + done + if [ -z "$DUNE_COMMON_PATH_ARG" ]; then + ../dune-common/bin/dunecontrol --opts=../dumux/cmake.opts --only=porous_media_dumux all + else + DUNE_COMMON_PATH=$DUNE_COMMON_PATH_ARG + export DUNE_CONTROL_PATH=$DUNE_COMMON_PATH:$CASE_DIR + "$DUNE_COMMON_PATH"/dune-common/bin/dunecontrol --opts="$DUNE_COMMON_PATH"/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..1c0ab750e 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 installation of DUNE modules and DuMux 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..6ddacc0f8 100755 --- a/two-scale-heat-conduction/macro-dumux/run.sh +++ b/two-scale-heat-conduction/macro-dumux/run.sh @@ -4,7 +4,37 @@ 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; } + +if [ ! -d "build-cmake" ]; then + echo "No build-cmake folder found. Compiling macro-dumux." + CASE_DIR=$(pwd)/.. + + while getopts ":l:" opt; do + case ${opt} in + l) + DUNE_COMMON_PATH_ARG=$OPTARG + ;; + *) + usage + ;; + esac + done + if [ -z "$DUNE_COMMON_PATH_ARG" ]; then + ../dune-common/bin/dunecontrol --opts=../dumux/cmake.opts --only=macro_dumux all + else + DUNE_COMMON_PATH=$DUNE_COMMON_PATH_ARG + export DUNE_CONTROL_PATH=$DUNE_COMMON_PATH:$CASE_DIR + "$DUNE_COMMON_PATH"/dune-common/bin/dunecontrol --opts="$DUNE_COMMON_PATH"/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 . # Check if no input argument was provided if [ -z "$*" ] ; then diff --git a/two-scale-heat-conduction/micro-dumux/run.sh b/two-scale-heat-conduction/micro-dumux/run.sh index 1f0db55aa..436e74ee7 100755 --- a/two-scale-heat-conduction/micro-dumux/run.sh +++ b/two-scale-heat-conduction/micro-dumux/run.sh @@ -4,7 +4,37 @@ 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; } + +if [ ! -d "build-cmake" ]; then + echo "No build-cmake folder found. Compiling micro-dumux." + CASE_DIR=$(pwd)/.. + + while getopts ":l:" opt; do + case ${opt} in + l) + DUNE_COMMON_PATH_ARG=$OPTARG + ;; + *) + usage + ;; + esac + done + if [ -z "$DUNE_COMMON_PATH_ARG" ]; then + ../dune-common/bin/dunecontrol --opts=../dumux/cmake.opts --only=micro_sim all + else + DUNE_COMMON_PATH=$DUNE_COMMON_PATH_ARG + export DUNE_CONTROL_PATH=$DUNE_COMMON_PATH:$CASE_DIR + "$DUNE_COMMON_PATH"/dune-common/bin/dunecontrol --opts="$DUNE_COMMON_PATH"/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 . # Check if no input argument was provided if [ -z "$*" ] ; then 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/ From 3164283b16ed26f23b0793eeec7c9e268ff7d233 Mon Sep 17 00:00:00 2001 From: Jun Chen Date: Tue, 3 Feb 2026 12:09:33 +0100 Subject: [PATCH 2/4] Improve readme --- free-flow-over-porous-media/README.md | 2 +- free-flow-over-porous-media/free-flow-dumux/run.sh | 2 +- free-flow-over-porous-media/porous-media-dumux/run.sh | 2 +- two-scale-heat-conduction/README.md | 2 +- two-scale-heat-conduction/macro-dumux/run.sh | 2 +- two-scale-heat-conduction/micro-dumux/run.sh | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/free-flow-over-porous-media/README.md b/free-flow-over-porous-media/README.md index 71a1e7c4b..e77773408 100644 --- a/free-flow-over-porous-media/README.md +++ b/free-flow-over-porous-media/README.md @@ -33,7 +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. -If an existing installation of DUNE modules and DuMux 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. +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 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 56bd2e91f..b64225321 100755 --- a/free-flow-over-porous-media/free-flow-dumux/run.sh +++ b/free-flow-over-porous-media/free-flow-dumux/run.sh @@ -8,7 +8,7 @@ exec > >(tee --append "$LOGFILE") 2>&1 usage() { echo "Usage: cmd [-l ]" 1>&2; exit 1; } if [ ! -d "build-cmake" ]; then - echo "No build-cmake folder found. Compiling micro-dumux." + echo "Solver not built. Building now..." CASE_DIR=$(pwd)/.. while getopts ":l:" opt; do 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 ecf011458..1bdbc48b6 100755 --- a/free-flow-over-porous-media/porous-media-dumux/run.sh +++ b/free-flow-over-porous-media/porous-media-dumux/run.sh @@ -8,7 +8,7 @@ exec > >(tee --append "$LOGFILE") 2>&1 usage() { echo "Usage: cmd [-l ]" 1>&2; exit 1; } if [ ! -d "build-cmake" ]; then - echo "No build-cmake folder found. Compiling micro-dumux." + echo "Solver not built. Building now..." CASE_DIR=$(pwd)/.. while getopts ":l:" opt; do diff --git a/two-scale-heat-conduction/README.md b/two-scale-heat-conduction/README.md index 1c0ab750e..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. -If an existing installation of DUNE modules and DuMux 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. +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 diff --git a/two-scale-heat-conduction/macro-dumux/run.sh b/two-scale-heat-conduction/macro-dumux/run.sh index 6ddacc0f8..08e860924 100755 --- a/two-scale-heat-conduction/macro-dumux/run.sh +++ b/two-scale-heat-conduction/macro-dumux/run.sh @@ -7,7 +7,7 @@ exec > >(tee --append "$LOGFILE") 2>&1 usage() { echo "Usage: cmd [-s] [-p n] [-l ]" 1>&2; exit 1; } if [ ! -d "build-cmake" ]; then - echo "No build-cmake folder found. Compiling macro-dumux." + echo "Solver not built. Building now..." CASE_DIR=$(pwd)/.. while getopts ":l:" opt; do diff --git a/two-scale-heat-conduction/micro-dumux/run.sh b/two-scale-heat-conduction/micro-dumux/run.sh index 436e74ee7..339c95eb0 100755 --- a/two-scale-heat-conduction/micro-dumux/run.sh +++ b/two-scale-heat-conduction/micro-dumux/run.sh @@ -7,7 +7,7 @@ exec > >(tee --append "$LOGFILE") 2>&1 usage() { echo "Usage: cmd [-s] [-p n] [-l ]" 1>&2; exit 1; } if [ ! -d "build-cmake" ]; then - echo "No build-cmake folder found. Compiling micro-dumux." + echo "Solver not built. Building now..." CASE_DIR=$(pwd)/.. while getopts ":l:" opt; do From 918666724dfe56a92dc2ae79c5f81d39dbff7fb5 Mon Sep 17 00:00:00 2001 From: Jun Chen Date: Tue, 3 Feb 2026 18:07:24 +0100 Subject: [PATCH 3/4] Improve arguments parsing --- .../free-flow-dumux/run.sh | 32 +++++---- .../porous-media-dumux/run.sh | 32 +++++---- two-scale-heat-conduction/macro-dumux/run.sh | 69 ++++++++++-------- two-scale-heat-conduction/micro-dumux/run.sh | 71 ++++++++++--------- 4 files changed, 113 insertions(+), 91 deletions(-) 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 b64225321..82752f6cd 100755 --- a/free-flow-over-porous-media/free-flow-dumux/run.sh +++ b/free-flow-over-porous-media/free-flow-dumux/run.sh @@ -7,26 +7,30 @@ 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)/.. - while getopts ":l:" opt; do - case ${opt} in - l) - DUNE_COMMON_PATH_ARG=$OPTARG - ;; - *) - usage - ;; - esac - done - if [ -z "$DUNE_COMMON_PATH_ARG" ]; then + if [ -z "$DUNE_COMMON_PATH_SET" ]; then ../dune-common/bin/dunecontrol --opts=../dumux/cmake.opts --only=free_flow_dumux all else - DUNE_COMMON_PATH=$DUNE_COMMON_PATH_ARG - export DUNE_CONTROL_PATH=$DUNE_COMMON_PATH:$CASE_DIR - "$DUNE_COMMON_PATH"/dune-common/bin/dunecontrol --opts="$DUNE_COMMON_PATH"/dumux/cmake.opts --only=free_flow_dumux all + 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." 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 1bdbc48b6..64199d604 100755 --- a/free-flow-over-porous-media/porous-media-dumux/run.sh +++ b/free-flow-over-porous-media/porous-media-dumux/run.sh @@ -7,26 +7,30 @@ 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)/.. - while getopts ":l:" opt; do - case ${opt} in - l) - DUNE_COMMON_PATH_ARG=$OPTARG - ;; - *) - usage - ;; - esac - done - if [ -z "$DUNE_COMMON_PATH_ARG" ]; then + if [ -z "$DUNE_COMMON_PATH_SET" ]; then ../dune-common/bin/dunecontrol --opts=../dumux/cmake.opts --only=porous_media_dumux all else - DUNE_COMMON_PATH=$DUNE_COMMON_PATH_ARG - export DUNE_CONTROL_PATH=$DUNE_COMMON_PATH:$CASE_DIR - "$DUNE_COMMON_PATH"/dune-common/bin/dunecontrol --opts="$DUNE_COMMON_PATH"/dumux/cmake.opts --only=porous_media_dumux all + 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." diff --git a/two-scale-heat-conduction/macro-dumux/run.sh b/two-scale-heat-conduction/macro-dumux/run.sh index 08e860924..87df2d2b3 100755 --- a/two-scale-heat-conduction/macro-dumux/run.sh +++ b/two-scale-heat-conduction/macro-dumux/run.sh @@ -6,26 +6,40 @@ exec > >(tee --append "$LOGFILE") 2>&1 usage() { echo "Usage: cmd [-s] [-p n] [-l ]" 1>&2; exit 1; } +SERIAL_RUN= +PARALLEL_RUN= +RANK_COUNT= +DUNE_COMMON_PATH_SET= +DUNE_COMMON_PATH_ARG= + +while getopts ":sp:l:" opt; do + case ${opt} in + s) + SERIAL_RUN=1 + ;; + p) + RANK_COUNT="$OPTARG" + PARALLEL_RUN=1 + ;; + 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)/.. - while getopts ":l:" opt; do - case ${opt} in - l) - DUNE_COMMON_PATH_ARG=$OPTARG - ;; - *) - usage - ;; - esac - done - if [ -z "$DUNE_COMMON_PATH_ARG" ]; then + if [ -z "$DUNE_COMMON_PATH_SET" ]; then ../dune-common/bin/dunecontrol --opts=../dumux/cmake.opts --only=macro_dumux all else - DUNE_COMMON_PATH=$DUNE_COMMON_PATH_ARG - export DUNE_CONTROL_PATH=$DUNE_COMMON_PATH:$CASE_DIR - "$DUNE_COMMON_PATH"/dune-common/bin/dunecontrol --opts="$DUNE_COMMON_PATH"/dumux/cmake.opts --only=macro_dumux all + 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." @@ -36,24 +50,17 @@ fi # Move macro-dumux executable to the participant folder level mv ./build-cmake/appl/macro_dumux . -# 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 +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 -while getopts ":sp" opt; do - case ${opt} in - s) - ./macro_dumux params.input - ;; - p) - mpiexec -n "$2" macro_dumux params.input - ;; - *) - usage - ;; - esac -done +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 339c95eb0..ac4d117cd 100755 --- a/two-scale-heat-conduction/micro-dumux/run.sh +++ b/two-scale-heat-conduction/micro-dumux/run.sh @@ -6,26 +6,40 @@ exec > >(tee --append "$LOGFILE") 2>&1 usage() { echo "Usage: cmd [-s] [-p n] [-l ]" 1>&2; exit 1; } +SERIAL_RUN= +PARALLEL_RUN= +RANK_COUNT= +DUNE_COMMON_PATH_SET= +DUNE_COMMON_PATH_ARG= + +while getopts ":sp:l:" opt; do + case ${opt} in + s) + SERIAL_RUN=1 + ;; + p) + RANK_COUNT="$OPTARG" + PARALLEL_RUN=1 + ;; + 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)/.. - while getopts ":l:" opt; do - case ${opt} in - l) - DUNE_COMMON_PATH_ARG=$OPTARG - ;; - *) - usage - ;; - esac - done - if [ -z "$DUNE_COMMON_PATH_ARG" ]; then - ../dune-common/bin/dunecontrol --opts=../dumux/cmake.opts --only=micro_sim all + if [ -z "$DUNE_COMMON_PATH_SET" ]; then + ../dune-common/bin/dunecontrol --opts=../dumux/cmake.opts --only=micro_sim all else - DUNE_COMMON_PATH=$DUNE_COMMON_PATH_ARG - export DUNE_CONTROL_PATH=$DUNE_COMMON_PATH:$CASE_DIR - "$DUNE_COMMON_PATH"/dune-common/bin/dunecontrol --opts="$DUNE_COMMON_PATH"/dumux/cmake.opts --only=micro_sim all + 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." @@ -36,24 +50,17 @@ fi # Move micro_sim executable to the participant folder level mv ./build-cmake/appl/micro_sim*.so . -# 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 +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 -while getopts ":sp" opt; do - case ${opt} in - s) - micro-manager-precice micro-manager-config.json - ;; - p) - mpiexec -n "$2" micro-manager-precice micro-manager-config.json - ;; - *) - usage - ;; - esac -done +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 From 1f28cfd5d0889fa8ec36bfe1c5614b473cecea77 Mon Sep 17 00:00:00 2001 From: Jun Chen Date: Wed, 4 Feb 2026 14:22:19 +0100 Subject: [PATCH 4/4] Add changelog --- changelog-entries/702.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog-entries/702.md 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