Skip to content

Commit 2579210

Browse files
authored
Provide compilation option for existing dumux installation (#702)
1 parent 919bae0 commit 2579210

File tree

11 files changed

+198
-73
lines changed

11 files changed

+198
-73
lines changed

changelog-entries/702.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Changed the run script of solvers with DuMux to compile the case before running, also accept given path to DuMux and adpater.

free-flow-over-porous-media/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,13 @@ preCICE configuration (image generated using the [precice-config-visualizer](htt
2727

2828
## Available solvers
2929

30-
Both the participants are computed using the simulation code [DuMu<sup>x</sup>](https://git.iws.uni-stuttgart.de/dumux-repositories/dumux/).
30+
Both the participants are computed using the simulation code [DuMux](https://git.iws.uni-stuttgart.de/dumux-repositories/dumux/).
3131

3232
## Solver setup
3333

3434
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.
3535

36-
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`.
37-
38-
To only recompile the participants, run `sh compile-dumux-cases.sh` in the tutorial folder.
36+
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 <path-to-DUNE-common>` 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.
3937

4038
## Running the simulation
4139

@@ -55,6 +53,12 @@ cd porous-media-dumux
5553
./run.sh
5654
```
5755

56+
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`:
57+
58+
```bash
59+
./run.sh -l <path-to-DUNE-common>
60+
```
61+
5862
Participants can be executed only in serial. Parallel execution is not supported. The case takes approximately two minutes to finish.
5963

6064
## Post-processing

free-flow-over-porous-media/compile-dumux-cases.sh

Lines changed: 0 additions & 21 deletions
This file was deleted.

free-flow-over-porous-media/free-flow-dumux/run.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,43 @@ set -e -u
44
. ../../tools/log.sh
55
exec > >(tee --append "$LOGFILE") 2>&1
66

7+
8+
usage() { echo "Usage: cmd [-l <path-to-DUNE-common>]" 1>&2; exit 1; }
9+
10+
DUNE_COMMON_PATH_SET=
11+
DUNE_COMMON_PATH_ARG=
12+
13+
while getopts ":l:" opt; do
14+
case ${opt} in
15+
l)
16+
DUNE_COMMON_PATH_SET=1
17+
DUNE_COMMON_PATH_ARG="$OPTARG"
18+
;;
19+
*)
20+
usage
21+
;;
22+
esac
23+
done
24+
25+
if [ ! -d "build-cmake" ]; then
26+
echo "Solver not built. Building now..."
27+
CASE_DIR=$(pwd)/..
28+
29+
if [ -z "$DUNE_COMMON_PATH_SET" ]; then
30+
../dune-common/bin/dunecontrol --opts=../dumux/cmake.opts --only=free_flow_dumux all
31+
else
32+
export DUNE_CONTROL_PATH=$DUNE_COMMON_PATH_ARG:$CASE_DIR
33+
"$DUNE_COMMON_PATH_ARG"/dune-common/bin/dunecontrol --opts="$DUNE_COMMON_PATH_ARG"/dumux/cmake.opts --only=free_flow_dumux all
34+
fi
35+
else
36+
echo "build-cmake folder found."
37+
cd build-cmake
38+
make free_flow_dumux
39+
cd ..
40+
fi
41+
# Move free_flow_dumux executable to the participant folder level
42+
mv build-cmake/solver-dumux/free_flow_dumux .
43+
744
./free_flow_dumux params.input
845

946
close_log

free-flow-over-porous-media/porous-media-dumux/run.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,43 @@ set -e -u
44
. ../../tools/log.sh
55
exec > >(tee --append "$LOGFILE") 2>&1
66

7+
8+
usage() { echo "Usage: cmd [-l <path-to-DUNE-common>]" 1>&2; exit 1; }
9+
10+
DUNE_COMMON_PATH_SET=
11+
DUNE_COMMON_PATH_ARG=
12+
13+
while getopts ":l:" opt; do
14+
case ${opt} in
15+
l)
16+
DUNE_COMMON_PATH_SET=1
17+
DUNE_COMMON_PATH_ARG="$OPTARG"
18+
;;
19+
*)
20+
usage
21+
;;
22+
esac
23+
done
24+
25+
if [ ! -d "build-cmake" ]; then
26+
echo "Solver not built. Building now..."
27+
CASE_DIR=$(pwd)/..
28+
29+
if [ -z "$DUNE_COMMON_PATH_SET" ]; then
30+
../dune-common/bin/dunecontrol --opts=../dumux/cmake.opts --only=porous_media_dumux all
31+
else
32+
export DUNE_CONTROL_PATH=$DUNE_COMMON_PATH_ARG:$CASE_DIR
33+
"$DUNE_COMMON_PATH_ARG"/dune-common/bin/dunecontrol --opts="$DUNE_COMMON_PATH_ARG"/dumux/cmake.opts --only=porous_media_dumux all
34+
fi
35+
else
36+
echo "build-cmake folder found."
37+
cd build-cmake
38+
make porous_media_dumux
39+
cd ..
40+
fi
41+
# Move porous_media_dumux executable to the participant folder level
42+
mv build-cmake/solver-dumux/porous_media_dumux .
43+
744
./porous_media_dumux params.input
845

946
close_log

free-flow-over-porous-media/setup-dumux.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ DUNE_CONTROL_PATH=. python3 dumux/bin/installexternal.py spgrid
3131
# Re-build environment
3232
DUNE_CONTROL_PATH=. ./dune-common/bin/dunecontrol --opts=./dumux/cmake.opts all
3333

34-
# Compile and move macro-dumux and micro-dumux executables to the participant folder level
35-
./compile-dumux-cases.sh
34+
# Move solver executables to the participant folder level
35+
mv free-flow-dumux/build-cmake/solver-dumux/free_flow_dumux free-flow-dumux/
36+
mv porous-media-dumux/build-cmake/solver-dumux/porous_media_dumux porous-media-dumux/

two-scale-heat-conduction/README.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ preCICE configuration (image generated using the [precice-config-visualizer](htt
2727

2828
## Available solvers and dependencies
2929

30-
* 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 [DuMu<sup>x</sup>](https://git.iws.uni-stuttgart.de/dumux-repositories/dumux/).
30+
* 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/).
3131
* 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).
3232
* 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.
3333

34-
### DuMu<sup>x</sup> setup
34+
### DuMux setup
3535

36-
To solve either the macro or micro simulations with the DuMu<sup>x</sup> 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.
36+
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.
3737

38-
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.
38+
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 <path-to-DUNE-common>` 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.
3939

4040
## Running the simulation
4141

@@ -55,7 +55,18 @@ cd micro-nutils
5555
./run.sh -s
5656
```
5757

58-
If you want to use DuMu<sup>x</sup>, use `cd macro-dumux` instead of `cd macro-nutils` and/or `cd micro-dumux` instead of `cd micro-nutils`.
58+
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:
59+
60+
```bash
61+
cd macro-dumux
62+
./run.sh -s
63+
```
64+
65+
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`:
66+
67+
```bash
68+
./run.sh -s -l <path-to-DUNE-common>
69+
```
5970

6071
## Running the simulation in parallel
6172

@@ -74,7 +85,7 @@ Running `micro-dumux` is much faster. A serial simulation takes approximately 2
7485

7586
## Post-processing
7687

77-
Here are the results from Nutils-Nutils and DuMu<sup>x</sup>-DuMu<sup>x</sup> combination:
88+
Here are the results from Nutils-Nutils and DuMux-DuMux combination:
7889

7990
<img class="img-responsive" src="images/tutorials-two-scale-heat-conduction-results.png" alt="Macro and micro data of macro-nutils - micro-nutils simulation" width=50% height=30%/>
8091

@@ -88,4 +99,4 @@ The participant `macro-nutils` outputs `macro-*.vtk` files which can be viewed i
8899

89100
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.
90101

91-
Similar to the output data files from simulation with Nutils, the `VTU` files from macro and micro solvers, that are written in DuMu<sup>x</sup>, could also be rendered and inspected with ParaView with the mentioned method.
102+
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.

two-scale-heat-conduction/compile-dumux-cases.sh

Lines changed: 0 additions & 20 deletions
This file was deleted.

two-scale-heat-conduction/macro-dumux/run.sh

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,63 @@ set -e -u
44
. ../../tools/log.sh
55
exec > >(tee --append "$LOGFILE") 2>&1
66

7-
usage() { echo "Usage: cmd [-s] [-p n]" 1>&2; exit 1; }
7+
usage() { echo "Usage: cmd [-s] [-p n] [-l <path-to-DUNE-common>]" 1>&2; exit 1; }
88

9-
# Check if no input argument was provided
10-
if [ -z "$*" ] ; then
11-
echo "No input argument provided. Macro solver is launched in serial"
12-
./macro_dumux params.input
13-
fi
9+
SERIAL_RUN=
10+
PARALLEL_RUN=
11+
RANK_COUNT=
12+
DUNE_COMMON_PATH_SET=
13+
DUNE_COMMON_PATH_ARG=
1414

15-
while getopts ":sp" opt; do
15+
while getopts ":sp:l:" opt; do
1616
case ${opt} in
1717
s)
18-
./macro_dumux params.input
18+
SERIAL_RUN=1
1919
;;
2020
p)
21-
mpiexec -n "$2" macro_dumux params.input
21+
RANK_COUNT="$OPTARG"
22+
PARALLEL_RUN=1
23+
;;
24+
l)
25+
DUNE_COMMON_PATH_SET=1
26+
DUNE_COMMON_PATH_ARG="$OPTARG"
2227
;;
2328
*)
2429
usage
2530
;;
2631
esac
2732
done
2833

34+
if [ ! -d "build-cmake" ]; then
35+
echo "Solver not built. Building now..."
36+
CASE_DIR=$(pwd)/..
37+
38+
if [ -z "$DUNE_COMMON_PATH_SET" ]; then
39+
../dune-common/bin/dunecontrol --opts=../dumux/cmake.opts --only=macro_dumux all
40+
else
41+
export DUNE_CONTROL_PATH=$DUNE_COMMON_PATH_ARG:$CASE_DIR
42+
"$DUNE_COMMON_PATH_ARG"/dune-common/bin/dunecontrol --opts="$DUNE_COMMON_PATH_ARG"/dumux/cmake.opts --only=macro_dumux all
43+
fi
44+
else
45+
echo "build-cmake folder found."
46+
cd build-cmake
47+
make macro_dumux
48+
cd ..
49+
fi
50+
# Move macro-dumux executable to the participant folder level
51+
mv ./build-cmake/appl/macro_dumux .
52+
53+
if [ -n "$SERIAL_RUN" ] && [ -n "$PARALLEL_RUN" ]; then
54+
echo "Cannot run both serial and parallel. Choose one option."
55+
usage
56+
elif [ -z "$SERIAL_RUN" ] && [ -z "$PARALLEL_RUN" ]; then
57+
echo "No run option provided. The macro solver is launched in serial."
58+
fi
59+
60+
if [ -n "$PARALLEL_RUN" ]; then
61+
mpiexec -n "$RANK_COUNT" macro_dumux params.input
62+
else
63+
./macro_dumux params.input
64+
fi
65+
2966
close_log

two-scale-heat-conduction/micro-dumux/run.sh

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,63 @@ set -e -u
44
. ../../tools/log.sh
55
exec > >(tee --append "$LOGFILE") 2>&1
66

7-
usage() { echo "Usage: cmd [-s] [-p n]" 1>&2; exit 1; }
7+
usage() { echo "Usage: cmd [-s] [-p n] [-l <path-to-DUNE-common>]" 1>&2; exit 1; }
88

9-
# Check if no input argument was provided
10-
if [ -z "$*" ] ; then
11-
echo "No input argument provided. Micro Manager is launched in serial"
12-
micro-manager-precice micro-manager-config.json
13-
fi
9+
SERIAL_RUN=
10+
PARALLEL_RUN=
11+
RANK_COUNT=
12+
DUNE_COMMON_PATH_SET=
13+
DUNE_COMMON_PATH_ARG=
1414

15-
while getopts ":sp" opt; do
15+
while getopts ":sp:l:" opt; do
1616
case ${opt} in
1717
s)
18-
micro-manager-precice micro-manager-config.json
18+
SERIAL_RUN=1
1919
;;
2020
p)
21-
mpiexec -n "$2" micro-manager-precice micro-manager-config.json
21+
RANK_COUNT="$OPTARG"
22+
PARALLEL_RUN=1
23+
;;
24+
l)
25+
DUNE_COMMON_PATH_SET=1
26+
DUNE_COMMON_PATH_ARG="$OPTARG"
2227
;;
2328
*)
2429
usage
2530
;;
2631
esac
2732
done
2833

34+
if [ ! -d "build-cmake" ]; then
35+
echo "Solver not built. Building now..."
36+
CASE_DIR=$(pwd)/..
37+
38+
if [ -z "$DUNE_COMMON_PATH_SET" ]; then
39+
../dune-common/bin/dunecontrol --opts=../dumux/cmake.opts --only=micro_sim all
40+
else
41+
export DUNE_CONTROL_PATH=$DUNE_COMMON_PATH_ARG:$CASE_DIR
42+
"$DUNE_COMMON_PATH_ARG"/dune-common/bin/dunecontrol --opts="$DUNE_COMMON_PATH_ARG"/dumux/cmake.opts --only=micro_sim all
43+
fi
44+
else
45+
echo "build-cmake folder found."
46+
cd build-cmake
47+
make micro_sim
48+
cd ..
49+
fi
50+
# Move micro_sim executable to the participant folder level
51+
mv ./build-cmake/appl/micro_sim*.so .
52+
53+
if [ -n "$SERIAL_RUN" ] && [ -n "$PARALLEL_RUN" ]; then
54+
echo "Cannot run both serial and parallel. Choose one option."
55+
usage
56+
elif [ -z "$SERIAL_RUN" ] && [ -z "$PARALLEL_RUN" ]; then
57+
echo "No run option provided. The macro solver is launched in serial."
58+
fi
59+
60+
if [ -n "$PARALLEL_RUN" ]; then
61+
mpiexec -n "$RANK_COUNT" micro-manager-precice micro-manager-config.json
62+
else
63+
micro-manager-precice micro-manager-config.json
64+
fi
65+
2966
close_log

0 commit comments

Comments
 (0)