Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog-entries/702.md
Original file line number Diff line number Diff line change
@@ -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.
12 changes: 8 additions & 4 deletions free-flow-over-porous-media/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 [DuMu<sup>x</sup>](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 <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.

## Running the simulation

Expand All @@ -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 <path-to-DUNE-common>
```

Participants can be executed only in serial. Parallel execution is not supported. The case takes approximately two minutes to finish.

## Post-processing
Expand Down
21 changes: 0 additions & 21 deletions free-flow-over-porous-media/compile-dumux-cases.sh

This file was deleted.

37 changes: 37 additions & 0 deletions free-flow-over-porous-media/free-flow-dumux/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,43 @@ set -e -u
. ../../tools/log.sh
exec > >(tee --append "$LOGFILE") 2>&1


usage() { echo "Usage: cmd [-l <path-to-DUNE-common>]" 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
37 changes: 37 additions & 0 deletions free-flow-over-porous-media/porous-media-dumux/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,43 @@ set -e -u
. ../../tools/log.sh
exec > >(tee --append "$LOGFILE") 2>&1


usage() { echo "Usage: cmd [-l <path-to-DUNE-common>]" 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
5 changes: 3 additions & 2 deletions free-flow-over-porous-media/setup-dumux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment thread
IshaanDesai marked this conversation as resolved.

# 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/
25 changes: 18 additions & 7 deletions two-scale-heat-conduction/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 [DuMu<sup>x</sup>](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.

### DuMu<sup>x</sup> setup
### DuMux setup

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

## Running the simulation

Expand All @@ -55,7 +55,18 @@ cd micro-nutils
./run.sh -s
```

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

## Running the simulation in parallel

Expand All @@ -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 DuMu<sup>x</sup>-DuMu<sup>x</sup> combination:
Here are the results from Nutils-Nutils and DuMux-DuMux combination:

<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%/>

Expand All @@ -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 DuMu<sup>x</sup>, 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.
20 changes: 0 additions & 20 deletions two-scale-heat-conduction/compile-dumux-cases.sh

This file was deleted.

55 changes: 46 additions & 9 deletions two-scale-heat-conduction/macro-dumux/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,63 @@ 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 <path-to-DUNE-common>]" 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
;;
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
55 changes: 46 additions & 9 deletions two-scale-heat-conduction/micro-dumux/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,63 @@ 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 <path-to-DUNE-common>]" 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
;;
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
3 changes: 2 additions & 1 deletion two-scale-heat-conduction/setup-dumux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/