Skip to content

Add DuMuX as a participant to the two-scale-heat-conduction tutorial #376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 49 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
3bfa5a8
port two-scale-heat-conduction case with DuMuX-DuMuX
Sep 30, 2023
3906427
Merge branch 'develop' into add-du-du-heat-conduction
IshaanDesai Nov 6, 2023
63117e4
Initial folder restructuring for setting up a DUNE modules environmen…
IshaanDesai Nov 28, 2023
ff74542
Removing unnecessary CMake files
IshaanDesai Dec 12, 2023
3e2cd1d
[two-scale-heat-conduction] add dune module wrapper
mathiskelm Dec 12, 2023
6210ff5
[two-scale-heat-conduction] macro-dumux as dune module
mathiskelm Dec 12, 2023
be16b45
[two-scale-heat-conduction] update macro-dumux to preCICE 3.0 and DuM…
mathiskelm Dec 12, 2023
58eb156
[two-scale-heat-conduction] remove dumux subdirectory
mathiskelm Dec 13, 2023
d0e0b8b
Merge branch 'develop' into add-du-du-heat-conduction
IshaanDesai Dec 13, 2023
f01e486
Remove dune-wrapper folder and restructure macro-dumux
IshaanDesai Dec 13, 2023
ea27ca7
[two-scale-heat-conduction] revert setup script to rebuild modules in…
mathiskelm Dec 14, 2023
b9e0201
[two-scale-heat-conduction][tmp] change branch in dumux-adapter
mathiskelm Dec 14, 2023
856339b
[two-scale-heat-conduction] fix macro participant
mathiskelm Dec 14, 2023
bfbc048
Construct mesh name macro-mesh of 10 characters
IshaanDesai Dec 14, 2023
b6bdf47
[two-scale-heat-conduction] fixes macro-dumux
mathiskelm Dec 15, 2023
1a27462
Merge branch 'develop' into add-du-du-heat-conduction
IshaanDesai Dec 19, 2023
ef68995
Formatting
IshaanDesai Dec 19, 2023
060b37f
Formatting and use string literals
IshaanDesai Dec 19, 2023
dea5bd9
PEP8 formatting
IshaanDesai Dec 19, 2023
7da41c1
Go back to cloning the develop branch of dumux-adapter in setup-dumux.sh
IshaanDesai Dec 21, 2023
794cf9c
Formatting
IshaanDesai Jan 4, 2024
f56ee46
Remove dumux-dumux because all the code in it is now ported
IshaanDesai Jan 12, 2024
ee50b6c
Merge branch 'develop' into add-du-du-heat-conduction
IshaanDesai Jan 12, 2024
1c613a8
Add appropriate run scripts
IshaanDesai Jan 12, 2024
c5bb2ce
Adding correct cleaning scripts and cleaning functions
IshaanDesai Jan 12, 2024
be17a72
Remove unnecessary cleaning script
IshaanDesai Jan 12, 2024
44beacb
Remove all references to clean-example.sh
IshaanDesai Jan 12, 2024
79ccbfe
[two-scale-heat-conduction] update micro-dumux for DuMux 3.7
mathiskelm Jan 19, 2024
3938006
restructured micro-dumux, added run.sh for macro-dumux
Jan 21, 2024
427a75f
repair communication of concentration
Jan 21, 2024
6c655e0
add shebang for cleaning script
Jan 21, 2024
ae0d852
customize cleaning file in micro-dumux
Jan 21, 2024
8284a2c
modify cleaning file to delete log file
Jan 21, 2024
b49d815
add dumux-dumux method in README
Jan 21, 2024
5ae1f23
Merge branch 'develop' into add-du-du-heat-conduction
IshaanDesai Jan 24, 2024
4843f46
Make the execution level of Nutils and DuMuX participants consistent
IshaanDesai Jan 25, 2024
337eb2f
Add DuMuX information to README
IshaanDesai Jan 25, 2024
372eda5
Minor edit in README
IshaanDesai Jan 25, 2024
e534b49
Merge branch 'develop' into add-du-du-heat-conduction
IshaanDesai Jan 25, 2024
96d4e21
Add cleaning script to micro-dumux and add DuMuX cleaning in the tools
IshaanDesai Jan 26, 2024
119b89f
add image of results for dumux-dumux simulation
Jan 29, 2024
778b90f
Add information on which participants can be run in parallel
IshaanDesai Jan 29, 2024
c1475aa
Merge branch 'add-du-du-heat-conduction' of github.com:precice/tutori…
IshaanDesai Jan 29, 2024
f9e8572
Fix linting docs
IshaanDesai Jan 29, 2024
819bff8
image modified
Jan 29, 2024
ef51b6a
image resized
Jan 29, 2024
c811d2b
[two-scale-heat-conduction] cleanup
mathiskelm Jan 29, 2024
6bf903b
[two-scale-heat-conduction] add compile-dumux-cases.sh
mathiskelm Jan 29, 2024
2c76289
Swapping maintainers of macro-dumux and micro-dumux
IshaanDesai Jan 29, 2024
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
12 changes: 12 additions & 0 deletions tools/cleaning-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,15 @@ clean_dune() {
clean_precice_logs .
)
}

clean_dumux() {
(
set -e -u
cd "$1"
echo "--- Cleaning up DuMuX case in $(pwd)"
rm -fv ./*.vtu
rm -fv ./*.pvd
clean_precice_logs .
)

}
6 changes: 6 additions & 0 deletions two-scale-heat-conduction/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dumux/
dumux-phasefield/
dumux-adapter/
dune-*
*/build-cmake/
install*
33 changes: 25 additions & 8 deletions two-scale-heat-conduction/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Two-scale heat conduction
permalink: tutorials-two-scale-heat-conduction.html
keywords: Macro-micro, Micro Manager, Nutils, Heat conduction
keywords: Macro-micro, Micro Manager, Nutils, DuMuX, Heat conduction
summary: We solve a two-scale heat conduction problem with a predefined micro structure of two materials. One macro simulation is coupled to several micro simulations using the Micro Manager.
---

Expand All @@ -21,27 +21,34 @@ At each Gauss point of the macro domain there exists a micro simulation. The mac

## Available solvers and dependencies

* Both the macro and micro simulations are solved using the finite element library [Nutils](https://nutils.org/install.html) v7.
* The macro simulation is written in Python, so it requires the [Python bindings of preCICE](https://precice.org/installation-bindings-python.html)
* 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/).
* 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.
* 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. Run `sh setup-dumux.sh` in the tutorial folder to set up the DUNE modules.

## Running the simulation

You can find the corresponding `run.sh`script for running the case in the folders corresponding to the solvers you want to use.

Run the macro problem:

```bash
cd macro-nutils
./run.sh
```

Check the Micro Manager [configuration](https://precice.org/tooling-micro-manager-configuration.html) and [running](https://precice.org/tooling-micro-manager-running.html) documentation to understand how to set it up and launch it. There is a Python script `run-micro-problems.py` in the tutorial directory to directly run the Micro Manager. This script imports the Micro Manager, and calls its `initialize()` and `solve()` methods. The Micro Manager can be run via this script in serial or parallel. Run it in serial:
Check the Micro Manager [configuration](https://precice.org/tooling-micro-manager-configuration.html) and [running](https://precice.org/tooling-micro-manager-running.html) documentation to understand how to set it up and launch it. There is a Python script `run-micro-problems.py` in the tutorial directory to directly run the Micro Manager. This script imports the Micro Manager, and calls its `solve()` method. The Micro Manager can be run via this script in serial or parallel. Run it in serial:

```bash
cd micro-nutils
./run.sh -s
```

Run it in parallel:
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`.

## Running the simulation in parallel

Only the `micro-nutils` participant can be run in parallel. To run it in parallel, run:

```bash
cd micro-nutils
Expand All @@ -50,14 +57,24 @@ cd micro-nutils

The `num_procs` needs to fit the decomposition specified in the `micro-manager-config.json` (default: two ranks).

Even though the case setup and involved physics is simple, each micro simulation is an instance of Nutils, which usually has a moderately high computation time. If the Micro Manager is run on 2 processors, the total runtime is approximately 25-30 minutes. Do not run the Micro Manager in serial, because the runtime will be several hours.
**NOTE**: When running `micro-nutils`, even though the case setup and involved physics is simple, each micro simulation is an instance of Nutils, which usually has a moderately high computation time. If the Micro Manager is run on 2 processors, the total runtime is approximately 25-30 minutes. Do not run the Micro Manager in serial, because the runtime will be several hours.

Running `micro-dumux` is much faster. A serial simulation takes approximately 2 minutes to finish.

## Post-processing

![Results of two-scale-heat-conduction case](images/tutorials-two-scale-heat-conduction-results.png)
Here are the results from Nutils-Nutils and DuMu<sup>x</sup>-DuMu<sup>x</sup> combination:

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

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

The differences of the fields are mainly introduced in by the different numerical schemes in the two solvers.

The participant `macro-nutils` outputs `macro-*.vtk` files which can be viewed in ParaView to see the macro concentration field. The Micro Manager uses the [export functionality](https://precice.org/configuration-export.html#enabling-exporters) of preCICE to output micro simulation data and [adaptivity related data](https://precice.org/tooling-micro-manager-configuration.html#adding-adaptivity-in-the-precice-xml-configuration) to VTU files which can be viewed in ParaView. To view the data on each micro simulation, create a Glyph on the Micro Manager VTU data. In the figure above, micro-scale porosity is shown. For a lower concentration value, the porosity increases (in the lower left corner).

![Evolving micro simulations](images/tutorials-two-scale-heat-conduction-evolving-micro-simulations.png)
<img src="images/tutorials-two-scale-heat-conduction-evolving-micro-simulations.png" alt="Adaptive mesh refinement in the micro simulation" width=50% height=30%>

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.
12 changes: 12 additions & 0 deletions two-scale-heat-conduction/compile-dumux-cases.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
set -e -u

cd macro-dumux/build-cmake/appl
make macro_dumux
cd ../../../micro-dumux/build-cmake/appl
make
cd ../../../

# 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-310-x86_64-linux-gnu.so micro-dumux/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions two-scale-heat-conduction/macro-dumux/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 3.13)
project(macro-dumux CXX)

if(NOT (dune-common_DIR OR dune-common_ROOT OR
"${CMAKE_PREFIX_PATH}" MATCHES ".*dune-common.*"))
string(REPLACE ${PROJECT_NAME} dune-common dune-common_DIR
${PROJECT_BINARY_DIR})
endif()

#find dune-common and set the module path
find_package(dune-common REQUIRED)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules"
${dune-common_MODULE_PATH})

#include the dune macros
include(DuneMacros)

# start a dune project with information from dune.module
dune_project()

dune_enable_all_packages()

add_subdirectory(doc)
add_subdirectory(cmake/modules)
add_subdirectory(appl)

# finalize the dune project, e.g. generating config.h etc.
finalize_dune_project(GENERATE_CONFIG_H_CMAKE)
7 changes: 7 additions & 0 deletions two-scale-heat-conduction/macro-dumux/appl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
add_executable(macro_dumux main.cc)
target_compile_definitions(macro_dumux PUBLIC "ENABLEMONOLITHIC=0")
target_link_libraries(macro_dumux PRIVATE dumux-precice)
target_compile_definitions(macro_dumux PUBLIC TYPETAG=OnePNIConductionCCTpfa)

# add a symlink for each input file
add_input_file_links()
Loading