From 696bbc2768a3d138c26a8a14779e02f005c909e8 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 17 Oct 2022 14:53:08 +0200 Subject: [PATCH 01/28] Update steps in installation and also some paths (#16) * Update steps in installation and also some paths * Incorporate review comments --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 55e682c..dc9e72e 100644 --- a/README.md +++ b/README.md @@ -48,24 +48,24 @@ The DuMuX-preCICE adapter should build fine if DuMuX, preCICE and their dependen - Note that extended features of DuMuX or the DuMuX-preCICE adapter may need additional DUNE modules. -2. Download the DuMuX-preCICE adapter to the same directory as the DUNE modules and the `dumux` folder. At the moment there are no adapter releases, besides an outdated `v0.1` release, such the best way is to checkout the `develop` branch of the adapter. +2. Download the DuMuX-preCICE adapter to the same directory as the DUNE modules and the `dumux` folder. It is recommended to use the latest release of the adapter, which can be found by checking out the relevant release tag. ```text - git clone -b develop https://github.com/precice/dumux-adapter.git + git clone -b v1.0.0 https://github.com/precice/dumux-adapter.git ``` You can also try to clone the repository via SSH: ```text - git clone -b develop git@github.com:precice/dumux-adapter.git + git clone -b v1.0.0 git@github.com:precice/dumux-adapter.git ``` -3. Verify that the `dumux-precice` folder is in the same directory as the DUNE module folders and the `dumux` folder. +3. Verify that the `dumux-adapter` folder is in the same directory as the DUNE module folders and the `dumux` folder. 4. Build and configure the adapter using `dunecontrol`. While being in the directory mentioned in the previous step via calling ```text - dunecontrol --only=dumux-precice all + ./dune-common/bin/dunecontrol --opts=dumux-adapter/dumux-precice all ``` After the build and configure step a new directory `build-cmake` was created inside the `dumux-precice` directory. @@ -73,13 +73,13 @@ The DuMuX-preCICE adapter should build fine if DuMuX, preCICE and their dependen You can configure the build and configuration process using advanced options by manipulating CMake variables. `dunecontrol` allows to pass an options file for that ```bash - dunecontrol --opts=OPTSFILE.opts --only=dumux-precice all + ./dune-common/bin/dunecontrol --opts=OPTSFILE.opts --only=dumux-precice all ``` There is an `opts`-file provided by the adapter that resides in `test/`. You can use it as ```bash - dunecontrol --opts=dumux-precice/test/cmake-test.opts --only=dumux-precice all + ./dune-common/bin/dunecontrol --opts=dumux-precice/test/cmake-test.opts --only=dumux-precice all ``` This provided `cmake-test.opts` file turns off some system-dependent optimizations such that the tests create comparable results on different computers. @@ -89,7 +89,7 @@ The DuMuX-preCICE adapter should build fine if DuMuX, preCICE and their dependen 5. Optional, but recommended: Build all tests to verify the installation. For this navigate in the `build-cmake/` directory and build the `build_tests` target. ```bash - cd dumux-precice/build-cmake + cd dumux-adapter/build-cmake make -j1 build_tests ``` From 8a5b1cc751ac4f740f2297e1753a7d251ed00af9 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Wed, 9 Nov 2022 17:25:13 +0100 Subject: [PATCH 02/28] Fixes incorrect assertion check (#18) --- examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh b/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh index 9513357..6db2c58 100644 --- a/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh +++ b/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh @@ -190,7 +190,7 @@ public: // coupling interface else if (couplingInterface_.isCoupledEntity(faceId)) { // // TODO do preCICE stuff in analogy to heat transfer - assert(dataIdsWereSet_setBeaversJoseph); + assert(dataIdsWereSet_); //TODO What do I want to do here? // values.setCouplingNeumann(Indices::conti0EqIdx); // values.setCouplingNeumann(Indices::momentumYBalanceIdx); From 84bf373439934ce9eb38fe4ee51516035609a2ec Mon Sep 17 00:00:00 2001 From: mathiskelm <114579716+mathiskelm@users.noreply.github.com> Date: Tue, 21 Feb 2023 13:32:50 +0100 Subject: [PATCH 03/28] Fix/ci versions and formatting (#20) * Update and fix versions used in CI * Fix formatting to satisfy clang format * Fix formatting to satisfy markdown linting --- .github/workflows/style-checking.yml | 6 +++--- doc/user/docs/example-usage.md | 2 +- doc/user/docs/installation.md | 2 +- doc/user/docs/overview.md | 2 +- examples/README.md | 1 - examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh | 6 +++++- examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh | 6 +++++- examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh | 6 +++++- examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh | 6 +++++- scripts/format/run-clang-format.sh | 2 +- 10 files changed, 27 insertions(+), 12 deletions(-) diff --git a/.github/workflows/style-checking.yml b/.github/workflows/style-checking.yml index 8324925..e5cc9e9 100644 --- a/.github/workflows/style-checking.yml +++ b/.github/workflows/style-checking.yml @@ -20,9 +20,9 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 with: - python-version: '3.8.10' + python-version: '3.10.10' - name: "Install style checker" - run: pip install --user black + run: pip install --user black~=22.12 - name: "Run style check" run: black --check . cpp_linting: @@ -31,5 +31,5 @@ jobs: - uses: actions/checkout@v2 - name: Run format check run: | - sudo apt-get install clang-format-10 + sudo apt-get install clang-format-14 ./scripts/format/run-clang-format.sh diff --git a/doc/user/docs/example-usage.md b/doc/user/docs/example-usage.md index adc6a34..9c9b06e 100644 --- a/doc/user/docs/example-usage.md +++ b/doc/user/docs/example-usage.md @@ -1,3 +1,3 @@ # Adapter usage -Please check out the examples in the `examples/` directory to get an idea on how to use the adapter. \ No newline at end of file +Please check out the examples in the `examples/` directory to get an idea on how to use the adapter. diff --git a/doc/user/docs/installation.md b/doc/user/docs/installation.md index 68dea37..3450a8f 100644 --- a/doc/user/docs/installation.md +++ b/doc/user/docs/installation.md @@ -81,4 +81,4 @@ The DuMuX-preCICE adapter should build fine if DuMuX, preCICE and their dependen If any tests fails, you should verify if something went wrong with the installation. -There are advanced ways of managing DUNE modules, e.g. using the environment variable `DUNE_CONTROL_PATH`, that are beyond the scope of this short documentation. You can find more information in the [DUNE FAQ](https://www.dune-project.org/doc/installation/#faq). \ No newline at end of file +There are advanced ways of managing DUNE modules, e.g. using the environment variable `DUNE_CONTROL_PATH`, that are beyond the scope of this short documentation. You can find more information in the [DUNE FAQ](https://www.dune-project.org/doc/installation/#faq). diff --git a/doc/user/docs/overview.md b/doc/user/docs/overview.md index 7d0e50c..4fcf684 100644 --- a/doc/user/docs/overview.md +++ b/doc/user/docs/overview.md @@ -8,4 +8,4 @@ Note that the DuMuX-preCICE adapter is a [DUNE module](https://www.dune-project. - `docker/`: A Docker recipe that creates a container with DUNE, DuMuX and preCICE. The recipe is mainly used for the automated tests. Check the `README.md` in the subdirectory for more details. - `dumux-precice/`: The preCICE adapter source code and further code for some of the tests and examples. - `scripts/`: Contains useful scripts to run simulations and for checking the code's formatting. -- `test/`: Contains test cases and reference solutions (`reference-solutions/`). The directory also contains several DUNE configuration files (`.opts` files) for configuring the project. \ No newline at end of file +- `test/`: Contains test cases and reference solutions (`reference-solutions/`). The directory also contains several DUNE configuration files (`.opts` files) for configuring the project. diff --git a/examples/README.md b/examples/README.md index 2019bfa..b198428 100644 --- a/examples/README.md +++ b/examples/README.md @@ -2,4 +2,3 @@ - `dummysolver/` contains a dummy solver similar to the dummy solver provided by preCICE. However, the included dummy solver uses the DuMuX-preCICE adapter. - `ff-pm/` contains examples of coupled free flow (`ff`) and porous medium (`pm`) flow - diff --git a/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh b/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh index 6db2c58..5004204 100644 --- a/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh +++ b/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh @@ -149,7 +149,11 @@ public: * * This problem assumes a temperature of 10 degrees Celsius. */ - Scalar temperature() const { return 273.15 + 10; } // 10°C + Scalar temperature() const + { + // 10°C + return 273.15 + 10; + } #endif /*! diff --git a/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh b/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh index c28ecc7..776eee9 100644 --- a/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh +++ b/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh @@ -139,7 +139,11 @@ public: * \brief Return the temperature within the domain in [K]. * */ - Scalar temperature() const { return 273.15 + 10; } // 10°C + Scalar temperature() const + { + // 10°C + return 273.15 + 10; + } // \} #endif diff --git a/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh b/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh index 5b31c62..c26296e 100644 --- a/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh +++ b/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh @@ -148,7 +148,11 @@ public: * * This problem assumes a temperature of 10 degrees Celsius. */ - Scalar temperature() const { return 273.15 + 10; } // 10°C + Scalar temperature() const + { + // 10°C + return 273.15 + 10; + } #endif /*! diff --git a/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh b/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh index 43af5d3..81775b5 100644 --- a/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh +++ b/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh @@ -139,7 +139,11 @@ public: * \brief Return the temperature within the domain in [K]. * */ - Scalar temperature() const { return 273.15 + 10; } // 10°C + Scalar temperature() const + { + // 10°C + return 273.15 + 10; + } // \} #endif /*! diff --git a/scripts/format/run-clang-format.sh b/scripts/format/run-clang-format.sh index 7fdce5c..b69e41f 100755 --- a/scripts/format/run-clang-format.sh +++ b/scripts/format/run-clang-format.sh @@ -6,7 +6,7 @@ for DIRECTORY in "${DIRECTORIES[@]}"; do #echo "Check files in ${DIRECTORY}" for FILE in $(find "${DIRECTORY}" -regex '.*\.\(cc\|hh\)' ); do #echo "$FILE" - clang-format-10 --dry-run -style=file -Werror -i ${FILE} + clang-format-14 --dry-run -style=file -Werror -i ${FILE} done if [ $? -ne 0 ]; then exit $? From 9249ec2dce400bf4dd28c4abf6760d71838e4aca Mon Sep 17 00:00:00 2001 From: mathiskelm <114579716+mathiskelm@users.noreply.github.com> Date: Tue, 21 Feb 2023 14:24:06 +0100 Subject: [PATCH 04/28] Resolve deprecations in DuMux 3.6 (#19) * Resolve deprecations in DuMux 3.6 Use new problem structure for freeflow model * Reintroduce compatibility with DuMux 3.4/3.5 --------- Co-authored-by: Ishaan Desai --- examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh | 10 ++++++++++ .../ff-pm/flow-over-square-2d/ffproblem-reversed.hh | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh b/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh index 5004204..1687d6e 100644 --- a/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh +++ b/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh @@ -34,7 +34,11 @@ #include #include +#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 6 +#include +#else #include +#endif #include @@ -94,9 +98,15 @@ struct EnableGridVolumeVariablesCache { * \brief The free flow sub problem */ template +#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 6 +class StokesSubProblem : public NavierStokesStaggeredProblem +{ + using ParentType = NavierStokesStaggeredProblem; +#else class StokesSubProblem : public NavierStokesProblem { using ParentType = NavierStokesProblem; +#endif using GridGeometry = GetPropType; using GridView = typename GridGeometry::GridView; diff --git a/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh b/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh index c26296e..b9d23c6 100644 --- a/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh +++ b/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh @@ -33,7 +33,11 @@ #include #include +#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 6 +#include +#else #include +#endif #include @@ -93,9 +97,15 @@ struct EnableGridVolumeVariablesCache { * \brief The free flow sub problem */ template +#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 6 +class StokesSubProblem : public NavierStokesStaggeredProblem +{ + using ParentType = NavierStokesStaggeredProblem; +#else class StokesSubProblem : public NavierStokesProblem { using ParentType = NavierStokesProblem; +#endif using GridGeometry = GetPropType; using GridView = typename GridGeometry::GridView; From 74f5dbdf830e5f35ac7e479c15fa7b637abcc5a5 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Fri, 10 Mar 2023 10:51:14 +0100 Subject: [PATCH 05/28] Fix compile command. Closes #21 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dc9e72e..37699bb 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ The DuMuX-preCICE adapter should build fine if DuMuX, preCICE and their dependen 4. Build and configure the adapter using `dunecontrol`. While being in the directory mentioned in the previous step via calling ```text - ./dune-common/bin/dunecontrol --opts=dumux-adapter/dumux-precice all + ./dune-common/bin/dunecontrol --only=dumux-adapter/dumux-precice all ``` After the build and configure step a new directory `build-cmake` was created inside the `dumux-precice` directory. From 1159c0c142fcaea45748956a1aacd2e671fcb6ad Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Fri, 10 Mar 2023 14:02:56 +0100 Subject: [PATCH 06/28] Point directly to the dumux-precice module in the build command. Closes #21 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 37699bb..f6c7729 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ The DuMuX-preCICE adapter should build fine if DuMuX, preCICE and their dependen 4. Build and configure the adapter using `dunecontrol`. While being in the directory mentioned in the previous step via calling ```text - ./dune-common/bin/dunecontrol --only=dumux-adapter/dumux-precice all + ./dune-common/bin/dunecontrol --only=dumux-precice all ``` After the build and configure step a new directory `build-cmake` was created inside the `dumux-precice` directory. From 554fc5c67b41fe36886baa5e308f52900287b184 Mon Sep 17 00:00:00 2001 From: mathiskelm <114579716+mathiskelm@users.noreply.github.com> Date: Tue, 22 Aug 2023 02:38:58 +0200 Subject: [PATCH 07/28] Draft: Update/dumux 3.7 (#22) * [ci] Use DUNE 2.9 for DuMux 3.7-git * [examples] Include header for UMFPack linear solver * [examples] Use UMFPack from istlsolvers.hh * [examples] cleanup, satisfy clang format * [ci] build docker dune 2.9 with latest precice * [docker] change dune-subgrid source to dune-project.org/extensions * [docker] deactivate DUNE python bindings for testing --- .github/workflows/build-and-test-dumux-master.yml | 4 ++-- .github/workflows/build-docker-containers.yml | 14 +++++++------- docker/checkout_repositories.sh | 2 +- docker/cmake-test.opts | 2 ++ .../ff-pm/flow-over-cube-3d/main_ff-reversed.cc | 13 +++++++++++++ .../ff-pm/flow-over-cube-3d/main_pm-reversed.cc | 15 ++++++++++++++- examples/ff-pm/flow-over-square-2d/main_ff.cc | 13 +++++++++++++ examples/ff-pm/flow-over-square-2d/main_pm.cc | 15 ++++++++++++++- 8 files changed, 66 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-and-test-dumux-master.yml b/.github/workflows/build-and-test-dumux-master.yml index cec69bd..62f4b59 100644 --- a/.github/workflows/build-and-test-dumux-master.yml +++ b/.github/workflows/build-and-test-dumux-master.yml @@ -11,8 +11,8 @@ jobs: strategy: max-parallel: 1 matrix: - precice_version: [2.4.0, 2.5.0] - dune_version: [2.8] + precice_version: [2.5.0] + dune_version: [2.9] container: image: precice/dune-precice:${{ matrix.dune_version }}-${{ matrix.precice_version }} runs-on: ubuntu-latest diff --git a/.github/workflows/build-docker-containers.yml b/.github/workflows/build-docker-containers.yml index 55a3485..c9dc836 100644 --- a/.github/workflows/build-docker-containers.yml +++ b/.github/workflows/build-docker-containers.yml @@ -37,10 +37,10 @@ jobs: file: "./dockerfile.slim" tags: ${{ env.dockerhub_username }}/dumux-precice:${{ matrix.dumux_version }}-${{ matrix.precice_version }} build-args: | - DUNE_VERSION=2.8 + DUNEVERSION=2.8 PRECICEUBUNTU=focal - DUMUX_VERSION=${{ matrix.dumux_version }} - PRECICE_VERSION=${{ matrix.precice_version }} + DUMUXVERSION=${{ matrix.dumux_version }} + PRECICEVERSION=${{ matrix.precice_version }} build-dune-precice: name: Builds a Docker container for testing the DuMuX preCICE adapter (DUNE and preCICE) runs-on: ubuntu-latest @@ -48,8 +48,8 @@ jobs: dockerhub_username: precice strategy: matrix: - dune_version: [2.8] - precice_version: [2.3.0, 2.4.0, 2.5.0] + dune_version: [2.9] + precice_version: [2.5.0] steps: - name: Checkout Repository uses: actions/checkout@v3 @@ -68,6 +68,6 @@ jobs: file: "./dockerfile_dune-precice.slim" tags: ${{ env.dockerhub_username }}/dune-precice:${{ matrix.dune_version }}-${{ matrix.precice_version }} build-args: | - DUNE_VERSION=#{{ matrix.dune_version }} + DUNEVERSION=${{ matrix.dune_version }} PRECICEUBUNTU=focal - PRECICE_VERSION=${{ matrix.precice_version }} + PRECICEVERSION=${{ matrix.precice_version }} diff --git a/docker/checkout_repositories.sh b/docker/checkout_repositories.sh index 9808522..98dddbf 100644 --- a/docker/checkout_repositories.sh +++ b/docker/checkout_repositories.sh @@ -15,7 +15,7 @@ for module in 'common' 'geometry' 'grid' 'localfunctions' 'istl' 'subgrid' do echo "Checking out module: ${module}" if [[ ${module} == 'subgrid' ]]; then - git clone --depth 1 https://git.imp.fu-berlin.de/agnumpde/dune-${module}.git -b releases/$DUNEVERSION + git clone --depth 1 https://gitlab.dune-project.org/extensions/dune-${module}.git -b releases/$DUNEVERSION else git clone --depth 1 https://gitlab.dune-project.org/core/dune-${module}.git -b releases/$DUNEVERSION fi diff --git a/docker/cmake-test.opts b/docker/cmake-test.opts index baa143d..c310d33 100644 --- a/docker/cmake-test.opts +++ b/docker/cmake-test.opts @@ -54,4 +54,6 @@ CMAKE_FLAGS="$SPECIFIC_COMPILER $SPECIFIC_GENERATOR $OPM_FLAGS -DCMAKE_BUILD_TYPE=Release -DENABLE_HEADERCHECK=$DUMUX_ENABLE_HEADERCHECK -DDUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS:BOOL=TRUE +-DDUNE_ENABLE_PYTHONBINDINGS=0 +-DDUNE_PYTHON_USE_VENV=0 " diff --git a/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc b/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc index 8eb87eb..5895a9e 100644 --- a/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc +++ b/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc @@ -40,7 +40,14 @@ #include #include #include + +#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 7 +#include +#include +#include +#else #include +#endif #include #include @@ -408,7 +415,13 @@ try { freeFlowProblem, freeFlowGridGeometry, freeFlowGridVariables); // the linear solver +#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 7 + using LinearSolver = + UMFPackIstlSolver>; +#else using LinearSolver = UMFPackBackend; +#endif auto linearSolver = std::make_shared(); // the non-linear solver diff --git a/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc b/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc index 378ca1e..4bffe08 100644 --- a/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc +++ b/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc @@ -42,7 +42,14 @@ bool printstuff = false; #include #include -#include +#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 7 +#include +#include +#include +#else +#include +#endif + #include #include @@ -449,7 +456,13 @@ try { darcyProblem, darcyGridGeometry, darcyGridVariables); // the linear solver +#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 7 + using LinearSolver = + UMFPackIstlSolver>; +#else using LinearSolver = UMFPackBackend; +#endif auto linearSolver = std::make_shared(); // the non-linear solver diff --git a/examples/ff-pm/flow-over-square-2d/main_ff.cc b/examples/ff-pm/flow-over-square-2d/main_ff.cc index 849e631..a719a1e 100644 --- a/examples/ff-pm/flow-over-square-2d/main_ff.cc +++ b/examples/ff-pm/flow-over-square-2d/main_ff.cc @@ -40,7 +40,14 @@ #include #include #include + +#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 7 +#include +#include +#include +#else #include +#endif #include #include @@ -295,7 +302,13 @@ try { freeFlowProblem, freeFlowGridGeometry, freeFlowGridVariables); // the linear solver +#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 7 + using LinearSolver = + UMFPackIstlSolver>; +#else using LinearSolver = UMFPackBackend; +#endif auto linearSolver = std::make_shared(); // the non-linear solver diff --git a/examples/ff-pm/flow-over-square-2d/main_pm.cc b/examples/ff-pm/flow-over-square-2d/main_pm.cc index 415111b..032b68d 100644 --- a/examples/ff-pm/flow-over-square-2d/main_pm.cc +++ b/examples/ff-pm/flow-over-square-2d/main_pm.cc @@ -42,7 +42,14 @@ bool printstuff = false; #include #include -#include +#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 7 +#include +#include +#include +#else +#include +#endif + #include #include @@ -348,7 +355,13 @@ try { darcyProblem, darcyGridGeometry, darcyGridVariables); // the linear solver +#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 7 + using LinearSolver = + UMFPackIstlSolver>; +#else using LinearSolver = UMFPackBackend; +#endif auto linearSolver = std::make_shared(); // the non-linear solver From 325caf7811bfdfc8ed703679a574e9908f8072c7 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Fri, 15 Sep 2023 14:18:54 -0400 Subject: [PATCH 08/28] Modifying docker container recipes to build with `precice:develop` (#26) * Modifying docker container recipe to work with precice:develop * Removing old preCICE CMake configurations * Remove binprecice md from Docker recipes --- .github/workflows/build-docker-containers.yml | 4 ++-- docker/dockerfile.slim | 7 ++++--- docker/dockerfile_dune-precice.slim | 7 ++++--- docker/rebuild-docker-images.sh | 6 +++--- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-docker-containers.yml b/.github/workflows/build-docker-containers.yml index c9dc836..068ce5d 100644 --- a/.github/workflows/build-docker-containers.yml +++ b/.github/workflows/build-docker-containers.yml @@ -18,7 +18,7 @@ jobs: strategy: matrix: dumux_version: [3.4, 3.5] - precice_version: [2.3.0, 2.4.0, 2.5.0] + precice_version: [develop] steps: - name: Checkout Repository uses: actions/checkout@v3 @@ -49,7 +49,7 @@ jobs: strategy: matrix: dune_version: [2.9] - precice_version: [2.5.0] + precice_version: [develop] steps: - name: Checkout Repository uses: actions/checkout@v3 diff --git a/docker/dockerfile.slim b/docker/dockerfile.slim index cc6b3cc..d62d736 100644 --- a/docker/dockerfile.slim +++ b/docker/dockerfile.slim @@ -30,11 +30,12 @@ ENV DUNE_CONTROL_PATH=${DUMUXINSTALLPATH}/dune-common/dune.module:${DUMUXINSTALL ENV PYTHONPATH ${DUMUXINSTALLPATH}/dumux/bin/testing:${PYTHONPATH} # Compile minmum version of preCICE -ARG PRECICEVERSION=2.4.0 +#ARG PRECICEVERSION=2.4.0 +ARG PRECICEVERSION=develop ARG PRECICEUBUNTU=focal -RUN git clone --depth 1 -b v${PRECICEVERSION} https://github.com/precice/precice.git precice-${PRECICEVERSION} && cd precice-${PRECICEVERSION} && mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=ON -DPRECICE_MPICommunication=OFF -DPRECICE_PETScMapping=OFF -DPRECICE_PythonActions=OFF -DCMAKE_INSTALL_PREFIX=/usr && make -j 4 && make test && make install && cd ../../ && rm -rf precice-${PRECICEVERSION} +RUN git clone --depth 1 -b ${PRECICEVERSION} https://github.com/precice/precice.git precice-${PRECICEVERSION} && cd precice-${PRECICEVERSION} && mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DPRECICE_FEATURE_MPI_COMMUNICATION=OFF -DPRECICE_FEATURE_PETSC_MAPPING=OFF -DPRECICE_FEATURE_PYTHON_ACTIONS=OFF -DCMAKE_INSTALL_PREFIX=/usr && make -j 4 && make test && make install && cd ../../ && rm -rf precice-${PRECICEVERSION} -RUN apt-get purge -y libboost-log-dev libboost-thread-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-test-dev libboost-container-dev libxml2-dev && binprecice md +RUN apt-get purge -y libboost-log-dev libboost-thread-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-test-dev libboost-container-dev libxml2-dev # Cleanup RUN apt-get autoremove -y && apt-get clean diff --git a/docker/dockerfile_dune-precice.slim b/docker/dockerfile_dune-precice.slim index 853ecb9..e452805 100644 --- a/docker/dockerfile_dune-precice.slim +++ b/docker/dockerfile_dune-precice.slim @@ -27,11 +27,12 @@ RUN dunecontrol --opts=cmake-test.opts all ENV DUNE_CONTROL_PATH=${DUMUXINSTALLPATH}/dune-common/dune.module:${DUMUXINSTALLPATH}/dune-geometry/dune.module:${DUMUXINSTALLPATH}/dune-grid/dune.module:${DUMUXINSTALLPATH}/dune-localfunctions/dune.module:${DUMUXINSTALLPATH}/dune-istl/dune.module:${DUMUXINSTALLPATH}/dune-subgrid/dune.module # Compile minmum version of preCICE -ARG PRECICEVERSION=2.4.0 +#ARG PRECICEVERSION=2.4.0 +ARG PRECICEVERSION=develop ARG PRECICEUBUNTU=focal -RUN git clone --depth 1 -b v${PRECICEVERSION} https://github.com/precice/precice.git precice-${PRECICEVERSION} && cd precice-${PRECICEVERSION} && mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=ON -DPRECICE_MPICommunication=OFF -DPRECICE_PETScMapping=OFF -DPRECICE_PythonActions=OFF -DCMAKE_INSTALL_PREFIX=/usr && make -j 4 && make test && make install && cd ../../ && rm -rf precice-${PRECICEVERSION} +RUN git clone --depth 1 -b ${PRECICEVERSION} https://github.com/precice/precice.git precice-${PRECICEVERSION} && cd precice-${PRECICEVERSION} && mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DPRECICE_FEATURE_MPI_COMMUNICATION=OFF -DPRECICE_FEATURE_PETSC_MAPPING=OFF -DPRECICE_FEATURE_PYTHON_ACTIONS=OFF -DCMAKE_INSTALL_PREFIX=/usr && make -j 4 && make test && make install && cd ../../ && rm -rf precice-${PRECICEVERSION} -RUN apt-get purge -y libboost-log-dev libboost-thread-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-test-dev libboost-container-dev libxml2-dev && binprecice md +RUN apt-get purge -y libboost-log-dev libboost-thread-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-test-dev libboost-container-dev libxml2-dev # Cleanup RUN apt-get autoremove -y && apt-get clean diff --git a/docker/rebuild-docker-images.sh b/docker/rebuild-docker-images.sh index 26e457d..3c87767 100755 --- a/docker/rebuild-docker-images.sh +++ b/docker/rebuild-docker-images.sh @@ -2,7 +2,7 @@ DUNE_VERSION="2.8" DUMUX_VERSIONS=("3.4" "3.5") -PRECICE_VERSIONS=("2.4.0" "2.3.0") +PRECICE_VERSIONS=("develop") for dumux_version in ${DUMUX_VERSIONS[@]}; do for precice_version in ${PRECICE_VERSIONS[@]}; do @@ -13,8 +13,8 @@ for dumux_version in ${DUMUX_VERSIONS[@]}; do done done -PRECICE_VERSION="2.4.0" +PRECICE_VERSION="develop" echo "Building dune-precice:${dumux_version}-${precice_version}" docker build --build-arg DUNEVERSION=${DUNE_VERSION} --build-arg PRECICEVERSION=${PRECICE_VERSION} -t precice/dune-precice:${DUNE_VERSION}-${PRECICE_VERSION} --file dockerfile_dune-precice.slim . docker push precice/dune-precice:${DUNE_VERSION}-${PRECICE_VERSION} -yes | docker image prune \ No newline at end of file +yes | docker image prune From 71b7bd88969715119a3f05d3c1f8ee753204ce74 Mon Sep 17 00:00:00 2001 From: June <94080048+Fujikawas@users.noreply.github.com> Date: Tue, 19 Sep 2023 10:13:22 +0200 Subject: [PATCH 09/28] Update the adapter according to preCICE V3 (#25) * Update the adapter according to preCICE V3 * tweaking on the format * improve formatting * Add related item in changelog * Change the required preCICE version from 2.0.0 to 3.0.0 * Tweak the formatting of markdown file * Modify the indentation in changelog * Modify the indentation in changelog * Modify the passed parameter to get rid of change to mesh- and dataName * Modify the examples and an error in the adapter itself * Update the required preCICE version CMakeLists.txt * rename some of the functions * changed the preCICE version required and the test to be run * Changed the preCICE version for build-and-test-dumux-master * Using develop version of preCICE in CI * Use preCICE version develop in build-and-test CI --------- Co-authored-by: Jun Chen Co-authored-by: Ishaan Desai --- .../workflows/build-and-test-dumux-master.yml | 60 +-- .github/workflows/build-and-test.yml | 44 +-- CHANGELOG.md | 3 + CMakeLists.txt | 2 +- doc/user/docs/installation.md | 2 +- dumux-precice/couplingadapter.cc | 357 +++++------------- dumux-precice/couplingadapter.hh | 299 +++++---------- examples/dummysolver/main_dummysolver.cc | 147 ++++---- .../precice-dummy-solver-config.xml | 75 ++-- examples/dummysolver/test.xml | 82 ++-- .../flow-over-cube-3d/ffproblem-reversed.hh | 45 +-- .../flow-over-cube-3d/main_ff-reversed.cc | 143 ++++--- .../flow-over-cube-3d/main_pm-reversed.cc | 160 +++----- .../flow-over-cube-3d/pmproblem-reversed.hh | 36 +- .../flow-over-cube-3d/precice-config.xml | 87 ++--- .../flow-over-square-2d/ffproblem-reversed.hh | 37 +- examples/ff-pm/flow-over-square-2d/main_ff.cc | 88 ++--- examples/ff-pm/flow-over-square-2d/main_pm.cc | 99 +++-- .../flow-over-square-2d/pmproblem-reversed.hh | 29 +- .../flow-over-square-2d/precice-config-pi.xml | 100 +++-- .../precice-config-si-free-flow-first.xml | 98 +++-- .../precice-config-si-free-flow-second.xml | 99 +++-- 22 files changed, 822 insertions(+), 1270 deletions(-) diff --git a/.github/workflows/build-and-test-dumux-master.yml b/.github/workflows/build-and-test-dumux-master.yml index 62f4b59..57680d2 100644 --- a/.github/workflows/build-and-test-dumux-master.yml +++ b/.github/workflows/build-and-test-dumux-master.yml @@ -11,38 +11,38 @@ jobs: strategy: max-parallel: 1 matrix: - precice_version: [2.5.0] + precice_version: [develop] dune_version: [2.9] container: image: precice/dune-precice:${{ matrix.dune_version }}-${{ matrix.precice_version }} runs-on: ubuntu-latest steps: - - name: Print python3 version - run: python3 --version - - name: Print python3 version (/usr/bin/env python3) - run: /usr/bin/env python3 --version - - name: Build DuMuX master - run: | - ls -lah - git clone --depth 1 https://git.iws.uni-stuttgart.de/dumux-repositories/dumux.git -b master - ls -lah - export DUNE_CONTROL_PATH=${DUNE_CONTROL_PATH}:${PWD}/dumux/dune.module - dunecontrol --opts=/opt/DUMUX/cmake-test.opts --only=dumux all - - name: Check out code - uses: actions/checkout@v3 - with: - path: dumux-precice - - name: Build code - run: | - ls -lah - export DUNE_CONTROL_PATH=${PWD}/dumux:${PWD}/dumux-precice:${DUNE_CONTROL_PATH} - echo $DUNE_CONTROL_PATH - dunecontrol --only=dumux-precice --opts=./dumux-precice/test/cmake-test.opts all - cd dumux-precice/build-cmake/ - make -j2 build_tests - - name: Run tests - run: | - export DUNE_CONTROL_PATH=${PWD}/dumux:${PWD}/dumux-precice:${DUNE_CONTROL_PATH} - cd dumux-precice/build-cmake/ - export PYTHONPATH=${PWD}/dumux/bin/testing:${PYTHONPATH} - CTEST_OUTPUT_ON_FAILURE=1 ctest -j1 + - name: Print python3 version + run: python3 --version + - name: Print python3 version (/usr/bin/env python3) + run: /usr/bin/env python3 --version + - name: Build DuMuX master + run: | + ls -lah + git clone --depth 1 https://git.iws.uni-stuttgart.de/dumux-repositories/dumux.git -b master + ls -lah + export DUNE_CONTROL_PATH=${DUNE_CONTROL_PATH}:${PWD}/dumux/dune.module + dunecontrol --opts=/opt/DUMUX/cmake-test.opts --only=dumux all + - name: Check out code + uses: actions/checkout@v3 + with: + path: dumux-precice + - name: Build code + run: | + ls -lah + export DUNE_CONTROL_PATH=${PWD}/dumux:${PWD}/dumux-precice:${DUNE_CONTROL_PATH} + echo $DUNE_CONTROL_PATH + dunecontrol --only=dumux-precice --opts=./dumux-precice/test/cmake-test.opts all + cd dumux-precice/build-cmake/ + make -j2 build_tests + - name: Run tests + run: | + export DUNE_CONTROL_PATH=${PWD}/dumux:${PWD}/dumux-precice:${DUNE_CONTROL_PATH} + cd dumux-precice/build-cmake/ + export PYTHONPATH=${PWD}/dumux/bin/testing:${PYTHONPATH} + CTEST_OUTPUT_ON_FAILURE=1 ctest -j1 diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 85cf3a2..d1637ca 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -12,29 +12,29 @@ jobs: max-parallel: 2 matrix: dumux_version: [3.4, 3.5] - precice_version: [2.3.0, 2.4.0, 2.5.0] + precice_version: [develop] container: image: precice/dumux-precice:${{ matrix.dumux_version }}-${{ matrix.precice_version }} runs-on: ubuntu-latest steps: - - name: Print python3 version - run: python3 --version - - name: Print python3 version (/usr/bin/env python3) - run: /usr/bin/env python3 --version - - name: Check out code - uses: actions/checkout@v3 - with: - path: dumux-precice - - name: Build code - run: | - ls -lah - export DUNE_CONTROL_PATH=${PWD}/dumux-precice:${DUNE_CONTROL_PATH} - echo $DUNE_CONTROL_PATH - dunecontrol --only=dumux-precice --opts=./dumux-precice/test/cmake-test.opts all - cd dumux-precice/build-cmake/ - make -j2 build_tests - - name: Run tests - run: | - export DUNE_CONTROL_PATH=${PWD}/dumux-precice:${DUNE_CONTROL_PATH} - cd dumux-precice/build-cmake/ - CTEST_OUTPUT_ON_FAILURE=1 ctest -j1 + - name: Print python3 version + run: python3 --version + - name: Print python3 version (/usr/bin/env python3) + run: /usr/bin/env python3 --version + - name: Check out code + uses: actions/checkout@v3 + with: + path: dumux-precice + - name: Build code + run: | + ls -lah + export DUNE_CONTROL_PATH=${PWD}/dumux-precice:${DUNE_CONTROL_PATH} + echo $DUNE_CONTROL_PATH + dunecontrol --only=dumux-precice --opts=./dumux-precice/test/cmake-test.opts all + cd dumux-precice/build-cmake/ + make -j2 build_tests + - name: Run tests + run: | + export DUNE_CONTROL_PATH=${PWD}/dumux-precice:${DUNE_CONTROL_PATH} + cd dumux-precice/build-cmake/ + CTEST_OUTPUT_ON_FAILURE=1 ctest -j1 diff --git a/CHANGELOG.md b/CHANGELOG.md index fac7c03..cb7df87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Not released yet +- 2023-08-10: Updated the adapter to align with preCICE V3. Updated the examples accordingly. + ## v1.0.0 - 2022-09-14: The solver dummy has been cleaned up. @@ -47,6 +49,7 @@ - The configuration of tests has been changed such that it is possible to build all tests using the `build_tests` target. For details check out the merge request [!18 Restructure repository and tests](https://git.iws.uni-stuttgart.de/dumux-appl/dumux-precice/-/merge_requests/18) + - 2022-01-10: Add license file. The code is licensed under GPLv3 without template exception. - 2022-01-10: Tests run by the CI on DuMuX `master` are allowed to fail. - 2022-01-10: Added `CHANGELOG.md` to track changes of the adapter. diff --git a/CMakeLists.txt b/CMakeLists.txt index 3bbabec..bf9d28f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ endif() #find dune-common and set the module path find_package(dune-common REQUIRED) # Find preCICE library -find_package(precice 2 REQUIRED CONFIG) +find_package(precice 3.0.0 REQUIRED CONFIG) list(APPEND CMAKE_MODULE_PATH ${dune-common_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/modules") diff --git a/doc/user/docs/installation.md b/doc/user/docs/installation.md index 3450a8f..ffd7e27 100644 --- a/doc/user/docs/installation.md +++ b/doc/user/docs/installation.md @@ -9,7 +9,7 @@ The DuMuX-preCICE adapter is a DUNE module named `dumux-precice` which can be bu - Builds using the current `master` branch of DuMuX might fail. - If you run into trouble with a new DuMuX release, please open an issue in the repository and add the error message that you receive. -- preCICE >=2.0.0 +- preCICE >=3.0.0 - The adapter is build via the DUNE build system that is based on CMake. Thus, the CMake [link instructions for preCICE](https://precice.org/installation-linking.html#cmake) apply. diff --git a/dumux-precice/couplingadapter.cc b/dumux-precice/couplingadapter.cc index d8e70e2..e2db8c1 100644 --- a/dumux-precice/couplingadapter.cc +++ b/dumux-precice/couplingadapter.cc @@ -13,12 +13,8 @@ CouplingAdapter::CouplingAdapter() meshWasCreated_(false), preciceWasInitialized_(false), hasIndexMapper_(false), - meshID_(0), timeStepSize_(0.) { - preciceDataID_.reserve(reserveSize_); - dataNames_.reserve(reserveSize_); - dataVectors_.reserve(reserveSize_); } CouplingAdapter &CouplingAdapter::getInstance() @@ -28,102 +24,73 @@ CouplingAdapter &CouplingAdapter::getInstance() } void CouplingAdapter::announceSolver(const std::string &name, - const std::string configurationFileName, + const std::string &configurationFileName, const int rank, const int size) { assert(precice_ == nullptr); - precice_ = std::make_unique( + precice_ = std::make_unique( name, configurationFileName, rank, size); wasCreated_ = true; } -size_t CouplingAdapter::announceQuantity(const std::string &name, - const QuantityType quantity_type) +void CouplingAdapter::announceQuantity(const precice::string_view &meshName, + const precice::string_view &dataName) { assert(meshWasCreated_); - auto it = std::find(dataNames_.begin(), dataNames_.end(), name); - if (it != dataNames_.end()) { + const std::string key = meshAndDataKey(meshName, dataName); + if (dataMap_.find(key) != dataMap_.end()) { throw(std::runtime_error(" Error! Duplicate quantity announced! ")); } - dataNames_.push_back(name); - preciceDataID_.push_back(precice_->getDataID(name, meshID_)); - const int quantity_dimension = - (quantity_type == QuantityType::Scalar) ? 1 : getDimensions(); - dataVectors_.push_back( - std::vector(vertexIDs_.size() * quantity_dimension)); - return getNumberOfQuantities() - 1; + int dataDimension = precice_->getDataDimensions(meshName, dataName); + std::vector dataValues(vertexIDs_.size() * dataDimension); + dataMap_.insert(std::make_pair(key, dataValues)); } -size_t CouplingAdapter::announceScalarQuantity(const std::string &name) -{ - return announceQuantity(name, QuantityType::Scalar); -} - -size_t CouplingAdapter::announceVectorQuantity(const std::string &name) -{ - return announceQuantity(name, QuantityType::Vector); -} - -int CouplingAdapter::getDimensions() const +int CouplingAdapter::getMeshDimensions( + const precice::string_view &meshName) const { assert(wasCreated_); - return precice_->getDimensions(); -} -/* -void CouplingAdapter::setMeshName(const std::string& meshName) -{ - assert( wasCreated_ ); - meshID_ = precice_->getMeshID(meshName); + return precice_->getMeshDimensions(meshName); } -*/ -void CouplingAdapter::setMesh(const std::string &meshName, - const size_t numPoints, - std::vector &coordinates) +void CouplingAdapter::setMesh(const precice::string_view &meshName, + precice::span positions) { assert(wasCreated_); - assert(numPoints == coordinates.size() / getDimensions()); - meshID_ = precice_->getMeshID(meshName); - vertexIDs_.resize(numPoints); - precice_->setMeshVertices(meshID_, numPoints, coordinates.data(), - vertexIDs_.data()); + vertexIDs_ = + std::vector(positions.size() / getMeshDimensions(meshName)); + vertexIDsSpan_ = precice::span(vertexIDs_); + precice_->setMeshVertices(meshName, positions, vertexIDsSpan_); meshWasCreated_ = true; } -double CouplingAdapter::initialize() +void CouplingAdapter::initialize() { assert(wasCreated_); assert(meshWasCreated_); assert(!preciceWasInitialized_); - timeStepSize_ = precice_->initialize(); + precice_->initialize(); + timeStepSize_ = precice_->getMaxTimeStepSize(); assert(timeStepSize_ > 0); preciceWasInitialized_ = true; - return timeStepSize_; -} - -void CouplingAdapter::createIndexMapping(const std::vector &dumuxFaceIDs) -{ - assert(meshWasCreated_); - indexMapper_.createMapping(dumuxFaceIDs, vertexIDs_); - hasIndexMapper_ = true; + assert(preciceWasInitialized_); } -double CouplingAdapter::setMeshAndInitialize(const std::string &meshName, - const size_t numPoints, - std::vector &coordinates) +double CouplingAdapter::getMaxTimeStepSize() const { - setMesh(meshName, numPoints, coordinates); - return initialize(); + return precice_->getMaxTimeStepSize(); } -void CouplingAdapter::initializeData() +void CouplingAdapter::createIndexMapping( + const std::vector &dumuxFaceIndices) { - assert(preciceWasInitialized_); - precice_->initializeData(); + assert(meshWasCreated_); + indexMapper_.createMapping(dumuxFaceIndices, vertexIDs_); + hasIndexMapper_ = true; } void CouplingAdapter::finalize() @@ -133,10 +100,10 @@ void CouplingAdapter::finalize() precice_->finalize(); } -double CouplingAdapter::advance(const double computedTimeStepLength) +void CouplingAdapter::advance(const double computedTimeStepLength) { assert(wasCreated_); - return precice_->advance(computedTimeStepLength); + precice_->advance(computedTimeStepLength); } bool CouplingAdapter::isCouplingOngoing() @@ -151,8 +118,10 @@ size_t CouplingAdapter::getNumberOfVertices() return vertexIDs_.size(); } -double CouplingAdapter::getScalarQuantityOnFace(const size_t dataID, - const int faceID) const +double CouplingAdapter::getScalarQuantityOnFace( + const precice::string_view &meshName, + const precice::string_view &dataName, + const int faceID) { assert(wasCreated_); assert(hasIndexMapper_); @@ -162,47 +131,16 @@ double CouplingAdapter::getScalarQuantityOnFace(const size_t dataID, "created!"); } const auto idx = indexMapper_.getPreciceId(faceID); - assert(dataID < dataVectors_.size()); - const std::vector &quantityVector = dataVectors_[dataID]; - assert(idx < quantityVector.size()); - return quantityVector[idx]; + std::vector &dataVector = getQuantityVector(meshName, dataName); + assert(idx < dataVector.size()); + return dataVector[idx]; } -// std::vector getVectorQuantityOnFace(const size_t dataID, const int faceID) const -// { -// assert(wasCreated_); -// assert(hasIndexMapper_); -// if (!hasIndexMapper_) { -// throw std::runtime_error( -// "Reading quantity using faceID, but index mapping was not " -// "created!"); -// } -// const auto idx = indexMapper_.getPreciceId(faceID); -// assert(dataID < dataVectors_.size()); -// const std::vector &quantityVector = dataVectors_[dataID]; -// assert(idx+getDimension()-1 < quantityVector.size()); -// std::vector vector_quantity( quantityVector.begin(), quantityVector.begin()+getDimension()-1 ); -// return vector_quantity; -// } -// void getQuantityVector(const size_t dataID, std::vector& quantity_vector) const -// { -// assert(wasCreated_); -// assert(hasIndexMapper_); -// if (!hasIndexMapper_) { -// throw std::runtime_error( -// "Reading quantity using faceID, but index mapping was not " -// "created!"); -// } -// const auto idx = indexMapper_.getPreciceId(faceID); -// const std::vector& data_vector = dataVectors_[dataID]; -// assert(dataID < data_vector.size()); -// quantity_vector.resize( data_vector.size() ); -// std::copy( data_vector.begin(), data_vector.end(), quantity_vector.begin() ); -// } - -void CouplingAdapter::writeScalarQuantityOnFace(const size_t dataID, - const int faceID, - const double value) +void CouplingAdapter::writeScalarQuantityOnFace( + const precice::string_view &meshName, + const precice::string_view &dataName, + const int faceID, + const double value) { assert(wasCreated_); assert(hasIndexMapper_); @@ -212,96 +150,27 @@ void CouplingAdapter::writeScalarQuantityOnFace(const size_t dataID, "created!"); } const auto idx = indexMapper_.getPreciceId(faceID); - assert(dataID < dataVectors_.size()); - std::vector &quantityVector = dataVectors_[dataID]; - assert(idx < quantityVector.size()); - quantityVector[idx] = value; + std::vector &dataVector = getQuantityVector(meshName, dataName); + assert(idx < dataVector.size()); + dataVector[idx] = value; } -//void CouplingAdapter::writeVectorQuantityOnFace(const size_t dataID, -// const int faceID, -// const double* value, -// const size_t size) -//{ -// assert( wasCreated_ ); -// assert( hasIndexMapper_ ); -// assert( size == getDimensions() ); -// if ( !hasIndexMapper_ ) -// { -// throw std::runtime_error("Writing quantity using faceID, but index mapping was not created!"); -// } -// const auto idx = indexMapper_.getPreciceId( faceID ) * size; -// assert( dataID < dataVectors_.size() ); -// std::vector& quantityVector = dataVectors_[ dataID ]; -// assert( idx < quantityVector.size() ); -// //quantityVector[idx] = value; -// std::copy_n( value, size, quantityVector[idx] ); -//} - -std::vector &CouplingAdapter::getQuantityVector(const size_t dataID) +std::vector &CouplingAdapter::getQuantityVector( + const precice::string_view &meshName, + const precice::string_view &dataName) { - assert(wasCreated_); - assert(dataID < dataVectors_.size()); - return dataVectors_[dataID]; -} - -const std::vector &CouplingAdapter::getQuantityVector( - const size_t dataID) const -{ - assert(wasCreated_); - return getQuantityVector(dataID); + std::string key = meshAndDataKey(meshName, dataName); + assert(dataMap_.find(key) != dataMap_.end()); + return dataMap_[key]; } -// void CouplingAdapter::writeScalarQuantityVector(const size_t dataID, -// std::vector &values) -// { -// assert(wasCreated_); -// assert(dataID < dataVectors_.size()); -// assert(dataVectors_[dataID].size() == values.size()); -// dataVectors_[dataID] = values; -// } - -void CouplingAdapter::writeQuantityVector(const size_t dataID, +void CouplingAdapter::writeQuantityVector(const precice::string_view &meshName, + const precice::string_view &dataName, std::vector &values) { - assert(wasCreated_); - assert(dataID < dataVectors_.size()); - assert(dataVectors_[dataID].size() == values.size()); - dataVectors_[dataID] = values; -} - -void CouplingAdapter::writeQuantityToOtherSolver( - const size_t dataID, - const QuantityType quantity_type) -{ - assert(wasCreated_); - assert(dataID < dataVectors_.size()); - assert(dataID < preciceDataID_.size()); - assert(dataID < std::numeric_limits::max()); - writeBlockDataToPrecice(preciceDataID_[dataID], dataVectors_[dataID], - quantity_type); -} - -void CouplingAdapter::readQuantityFromOtherSolver( - const size_t dataID, - const QuantityType quantity_type) -{ - assert(wasCreated_); - assert(dataID < dataVectors_.size()); - assert(dataID < preciceDataID_.size()); - assert(dataID < std::numeric_limits::max()); - readBlockDataFromPrecice(preciceDataID_[dataID], dataVectors_[dataID], - quantity_type); -} - -void CouplingAdapter::writeScalarQuantityToOtherSolver(const size_t dataID) -{ - writeQuantityToOtherSolver(dataID, QuantityType::Scalar); -} - -void CouplingAdapter::readScalarQuantityFromOtherSolver(const size_t dataID) -{ - readQuantityFromOtherSolver(dataID, QuantityType::Scalar); + std::vector &dataVector = getQuantityVector(meshName, dataName); + assert(dataVector.size() == values.size()); + dataVector = values; } bool CouplingAdapter::isCoupledEntity(const int faceID) const @@ -310,23 +179,22 @@ bool CouplingAdapter::isCoupledEntity(const int faceID) const return indexMapper_.isDumuxIdMapped(faceID); } -size_t CouplingAdapter::getIdFromName(const std::string &dataName) const +std::string CouplingAdapter::meshAndDataKey( + const precice::string_view &meshName, + const precice::string_view &dataName) const { assert(wasCreated_); - const auto it = std::find(dataNames_.begin(), dataNames_.end(), dataName); - if (it == dataNames_.end()) { - throw(std::runtime_error(" Error! Name of data not found! ")); + std::string combinedKey; + int length = meshName.size() + 1 + dataName.size(); + for (int i = 0; i < length; i++) { + if (i < meshName.size()) + combinedKey += meshName[i]; + else if (i == meshName.size()) + combinedKey += ":"; + else + combinedKey += dataName[i - meshName.size() - 1]; } - const auto idx = std::distance(dataNames_.begin(), it); - assert(idx > -1); - return size_t(idx); -} - -std::string CouplingAdapter::getNameFromId(const size_t dataID) const -{ - assert(wasCreated_); - assert(dataID < dataNames_.size()); - return dataNames_[dataID]; + return combinedKey; } void CouplingAdapter::print(std::ostream &os) @@ -334,87 +202,40 @@ void CouplingAdapter::print(std::ostream &os) os << indexMapper_; } -bool CouplingAdapter::checkIfActionIsRequired(const std::string &condition) -{ - assert(wasCreated_); - return precice_->isActionRequired(condition); -} - -void CouplingAdapter::actionIsFulfilled(const std::string &condition) -{ - assert(wasCreated_); - precice_->markActionFulfilled(condition); -} - -void CouplingAdapter::readBlockDataFromPrecice(const int dataID, - std::vector &data, - const QuantityType quantity_type) -{ - assert(wasCreated_); - if (quantity_type == QuantityType::Scalar) { - assert(vertexIDs_.size() == data.size()); - precice_->readBlockScalarData(dataID, vertexIDs_.size(), - vertexIDs_.data(), data.data()); - } else { - assert(vertexIDs_.size() * getDimensions() == data.size()); - precice_->readBlockVectorData(dataID, vertexIDs_.size(), - vertexIDs_.data(), data.data()); - } -} - -void CouplingAdapter::writeBlockDataToPrecice(const int dataID, - std::vector &data, - const QuantityType quantity_type) -{ - assert(wasCreated_); - if (quantity_type == QuantityType::Scalar) { - assert(vertexIDs_.size() == data.size()); - precice_->writeBlockScalarData(dataID, vertexIDs_.size(), - vertexIDs_.data(), data.data()); - } else { - assert(vertexIDs_.size() * getDimensions() == data.size()); - precice_->writeBlockVectorData(dataID, vertexIDs_.size(), - vertexIDs_.data(), data.data()); - } -} - -bool CouplingAdapter::hasToWriteInitialData() +void CouplingAdapter::readQuantityFromOtherSolver( + const precice::string_view &meshName, + const precice::string_view &dataName, + double relativeReadTime) { - assert(wasCreated_); - return checkIfActionIsRequired( - precice::constants::actionWriteInitialData()); + precice::span dataValuesSpan(getQuantityVector(meshName, dataName)); + precice_->readData(meshName, dataName, vertexIDsSpan_, relativeReadTime, + dataValuesSpan); } -void CouplingAdapter::announceInitialDataWritten() -{ - assert(wasCreated_); - precice_->markActionFulfilled(precice::constants::actionWriteInitialData()); -} - -bool CouplingAdapter::hasToReadIterationCheckpoint() +void CouplingAdapter::writeQuantityToOtherSolver( + const precice::string_view &meshName, + const precice::string_view &dataName) { - assert(wasCreated_); - return checkIfActionIsRequired( - precice::constants::actionReadIterationCheckpoint()); + precice::span dataValuesSpan( + getQuantityVector(meshName, dataName)); + precice_->writeData(meshName, dataName, vertexIDsSpan_, dataValuesSpan); } -void CouplingAdapter::announceIterationCheckpointRead() +bool CouplingAdapter::requiresToWriteInitialData() { assert(wasCreated_); - actionIsFulfilled(precice::constants::actionReadIterationCheckpoint()); + return precice_->requiresInitialData(); } -bool CouplingAdapter::hasToWriteIterationCheckpoint() +bool CouplingAdapter::requiresToReadCheckpoint() { assert(wasCreated_); - return checkIfActionIsRequired( - precice::constants::actionWriteIterationCheckpoint()); + return precice_->requiresReadingCheckpoint(); } -void CouplingAdapter::announceIterationCheckpointWritten() +bool CouplingAdapter::requiresToWriteCheckpoint() { assert(wasCreated_); - actionIsFulfilled(precice::constants::actionWriteIterationCheckpoint()); + return precice_->requiresWritingCheckpoint(); } - CouplingAdapter::~CouplingAdapter() {} diff --git a/dumux-precice/couplingadapter.hh b/dumux-precice/couplingadapter.hh index 946170d..06c0630 100644 --- a/dumux-precice/couplingadapter.hh +++ b/dumux-precice/couplingadapter.hh @@ -2,7 +2,7 @@ #define PRECICEWRAPPER_HH #include -#include +#include #include #include "dumuxpreciceindexmapper.hh" @@ -13,8 +13,6 @@ */ namespace Dumux::Precice { -enum class QuantityType { Scalar, Vector }; - /*! * @brief A DuMuX-preCICE coupling adapter class * @@ -32,66 +30,23 @@ private: //! True if preCICE instance was initiated bool wasCreated_; //! Pointer to preCICE instance - std::unique_ptr precice_; - //! Constructor - CouplingAdapter(); - /*! - * @brief Checks whether an action predefined by preCICE - * needs to be carried out. - * - * @param[in] condition Name of the action. - * @return true Action must be carried out. - * @return false Action must not be carried out. - */ - bool checkIfActionIsRequired(const std::string &condition); - /*! - * @brief Announce to preCICE that an action was carried out. - * - * @param[in] condition Name of the action. - */ - void actionIsFulfilled(const std::string &condition); - /*! - * @brief Reads full block of data from preCICE. - * - * @param[in] dataID Identifier of dataset to read. - * @param[out] data Vector to store the read data to. - */ - void readBlockDataFromPrecice(const int dataID, - std::vector &data, - const QuantityType quantity_type); - /*! - * @brief Writes full block of data to preCICE. - * - * @param[in] dataID Identifier of dataset to read. - * @param[in] data Vector containing data to write into preCICE's buffer. - */ - void writeBlockDataToPrecice(const int dataID, - std::vector &data, - const QuantityType quantity_type); - /*! - * @brief Gives the number of quantities/datasets defined on coupling interface. - * - * @return size_t Number of quantities defined on the coupling interface. - */ - size_t numberOfQuantities() const { return dataNames_.size(); } + std::unique_ptr precice_; //! True if the coupling mesh was created. bool meshWasCreated_; - //! True if precice::SolverInterface.initialize() has been called. + //! True if precice::Participant.initialize() has been called. bool preciceWasInitialized_; //! True if instance owns an instance of DumuxPreciceIndexMapper. bool hasIndexMapper_; - //! Stores identifier of the coupling mesh provided by preCICE. - int meshID_; //! Time step size. double timeStepSize_; - //! Vector of names of data exchanged over coupling interface. - std::vector dataNames_; - //! Vector of identifiers of data exchanged over coupling interface. - std::vector preciceDataID_; - //! Vector storing data vectors of the data exchanged over the coupling interface. - std::vector > dataVectors_; - //! Vector of identifiers of the vertices of the coupling mesh. + //! Map storing meshName:dataName and data vectors + std::map> dataMap_; + //! Vector of identifiers (in preCICE) of the vertices of the coupling mesh. std::vector vertexIDs_; //should be size_t + //! Span of the precice vertex indices vector vertexIDs_ + precice::span vertexIDsSpan_; + //! Constructor + CouplingAdapter(); /*! * @brief Instance of DumuxPreciceIndexMapper that translates between * DuMuX' identifiers of vertices and preCICE's identifiers. @@ -99,13 +54,11 @@ private: */ Internal::DumuxPreciceIndexMapper indexMapper_; /*! - * @brief Get the of quantities exchanged. + * @brief Get the number of quantities exchanged. * * @return size_t Number of quantities defined on coupling interface. */ - size_t getNumberOfQuantities() const { return dataNames_.size(); } - //! Number of expected quantities on the coupling interface. - static constexpr size_t reserveSize_ = 4; + size_t getNumberOfQuantities() const { return dataMap_.size(); } /*! * @brief Destroy the CouplingAdapter object * @@ -115,7 +68,6 @@ private: public: CouplingAdapter(const CouplingAdapter &) = delete; void operator=(const CouplingAdapter &) = delete; - /*! * @brief Get the instance of the CouplingAdapter * @@ -131,82 +83,63 @@ public: * @param[in] size Total number of processes of the DuMuX solver. */ void announceSolver(const std::string &name, - const std::string configurationFileName, + const std::string &configurationFileName, const int rank, const int size); /*! - * @brief Announces an additional quantity on the coupling interface. + * @brief Announces a quantity on the coupling interface. * * Internally, the quantity is announced to preCICE and the corresponding * data structures are initilized to store information about the quantity. * - * @param[in] name Name of the scalar quantity. - * @param[in] quantity_type Type (Scalar or Vector) of the quantity - * @return size_t Number of currently announced quantities. - */ - size_t announceQuantity(const std::string &name, - const QuantityType quantity_type); - - /*! - * @brief Announces an additional scalar quantity on the coupling interface. - * - * Internally, the scalar quantity is announced to preCICE and the corresponding - * data structures are initilized to store information about the quantity. - * - * @param[in] name Name of the scalar quantity. - * @return size_t Number of currently announced quantities. + * @param[in] meshName Name of the mesh. + * @param[in] dataName Name of the data. */ - size_t announceScalarQuantity(const std::string &name); + void announceQuantity(const precice::string_view &meshName, + const precice::string_view &dataName); /*! - * @brief Announces an additional vector quantity on the coupling interface. - * - * Internally, the vector quantity is announced to preCICE and the corresponding - * data structures are initilized to store information about the quantity. + * @brief Get the number of spatial dimensions * - * @param[in] name Name of the vector quantity. - * @return size_t Number of currently announced quantities. + * @param[in] meshName Name of the mesh + * @return int Number of space dimensions. */ - size_t announceVectorQuantity(const std::string &name); + int getMeshDimensions(const precice::string_view &meshName) const; /*! - * @brief Get the number of spatial dimensions + * @brief Get the maximum time step size from preCICE * - * @return int Number of space dimensions. Legal values are 2 and 3. + * @return double time step size */ - int getDimensions() const; + double getMaxTimeStepSize() const; /*! - * @brief Checks if simulation checkpoint needs to be restored. + * @brief Checks if the participant is required to read an iteration checkpoint. If true, the participant is required to read an iteration checkpoint before calling advance(). * * @return true Simulation checkpoint has to be restored. * @return false No further action is needed. */ - bool hasToReadIterationCheckpoint(); - //! Announce that the simulation checkpoint was read. - void announceIterationCheckpointRead(); + bool requiresToReadCheckpoint(); + /*! - * @brief Checks if simulation checkpoint needs to be saved. + * @brief Checks if the participant is required to write an iteration checkpoint. If true, the participant is required to write an iteration checkpoint before calling advance(). * * @return true Simulation checkpoints needs to be stored. * @return false No further action is needed. */ - bool hasToWriteIterationCheckpoint(); - //! Announce that the simulation checkpoint was written. - void announceIterationCheckpointWritten(); + bool requiresToWriteCheckpoint(); + /*! - * @brief Checks if initial coupling data has to be wrutten. + * @brief Checks if the participant is required to provide initial data. If true, the participant needs to write initial data to defined vertices prior to calling initialize(). * * @return true Initial coupling data has to be provided. * @return false No further action is needed. */ - bool hasToWriteInitialData(); - //! Announce that the initial coupling data has been written. - void announceInitialDataWritten(); + bool requiresToWriteInitialData(); + /*! * @brief Adds mesh for coupling of solvers. * - * @param[in] meshName Name of the mesh. - * @param[in] numPoints Number of points/vertices. - * @param[in] coordinates Coordinates of the points. - * + * @param[in] meshName The name of the mesh to add the vertices to. + * @param[in] positions A span to the coordinates of the vertices. + * * \note The coordinates need to be stored consecutively * according to their spatial coordinates as.\n * Example 2D:\n @@ -214,18 +147,16 @@ public: * Example 3D:\n * [x_1, y_1, z_1, x_2, y_2, z_2,...x_numPoints, y_numPoints, z_numPoints] */ - void setMesh(const std::string &meshName, - const size_t numPoints, - std::vector &coordinates); + void setMesh(const precice::string_view &meshName, + precice::span positions); /*! * @brief Initializes the coupling * * The coupling needs be initialized after all quantities/datasets and coupling meshes * are known. * - * @return double Maximum allowed time step size. */ - double initialize(); + void initialize(); /*! * @brief Creates mapping between DuMuX' face identifiers and preCICE's * vertex identifiers. @@ -236,29 +167,6 @@ public: * passed in setMesh. */ void createIndexMapping(const std::vector &dumuxFaceIDs); - /*! - * @brief Sets the coupling mesh and initializes coupling. - * - * This is a convenience function that sets the coupling mesh using setMesh. - * Afterwards, the coupling is initialized via initialzie. - * - * @param[in] meshName Name of the mesh. - * @param[in] numPoints Number of points/vertices. - * @param[in] coordinates Coordinates of the points. - * @return double Maximum allowed time step size. - */ - double setMeshAndInitialize(const std::string &meshName, - const size_t numPoints, - std::vector &coordinates); - - /*! - * @brief Initializes the coupling data. - * - * If one wants to set non-zero data, one has to write data to the - * corresponding quantities via one of the `write` functions first. - * - */ - void initializeData(); /*! * @brief Destroys the coupling. * @@ -272,7 +180,7 @@ public: * @param[in] computedTimeStepLength Time step lengths of the current simulation stel. * @return double Maximum time step length for successive time steps. */ - double advance(const double computedTimeStepLength); + void advance(const double computedTimeStepLength); /*! * @brief Checks whether the coupling is still ongoing. * @@ -287,97 +195,67 @@ public: */ size_t getNumberOfVertices(); /*! - * @brief Gets value of a scalar quantity. + * @brief Reads full block of data from preCICE. * - * @param[in] dataID Identifier of the quantity. - * @param[in] faceID Identifier of the face according to DuMuX' numbering. - * @return double Value of scalar quantity. + * @param[in] meshName Name of the mesh. + * @param[in] dataName Name of the data. + * @param[in] relativeReadTime The relative time tagged to the data to be read. + */ + void readQuantityFromOtherSolver(const precice::string_view &meshName, + const precice::string_view &dataName, + double relativeReadTime); + /*! + * @brief Writes full block of data to preCICE. + * + * @param[in] meshName Name of the mesh. + * @param[in] dataName Name of the data. */ - double getScalarQuantityOnFace(const size_t dataID, const int faceID) const; - // /*! - // * @brief Gets value of a vector quantity. - // * - // * @param[in] dataID Identifier of the quantity. - // * @param[in] faceID Identifier of the face according to DuMuX' numbering. - // * @return std::vector Value of vector quantity. - // */ - // std::vector getVectorQuantityOnFace(const size_t dataID, const int faceID) const; - // std::vector getVectorQuantity(const size_t dataID) const; + void writeQuantityToOtherSolver(const precice::string_view &meshName, + const precice::string_view &dataName); /*! - * @brief Gets value of a vector quantity. + * @brief Gets value of a scalar quantity on a finite volume face. * - * @param[in] dataID Identifier of the quantity. + * @param[in] meshName Name of the mesh. + * @param[in] dataName Name of the data. * @param[in] faceID Identifier of the face according to DuMuX' numbering. - * @return const std::vector& Value of vector quantity. + * @return double Value of scalar quantity. */ - const std::vector &getVectorScalarQuantityOnFace( - const size_t dataID, - const int faceID) const; + double getScalarQuantityOnFace(const precice::string_view &meshName, + const precice::string_view &dataName, + const int faceID); /*! - * @brief Writes value of scalar quantity on given face. + * @brief Writes value of scalar quantity on a given finite volume face to data map. * - * @param[in] dataID Identifier of the quantity. + * @param[in] meshName Name of the mesh. + * @param[in] dataName Name of the data. * @param[in] faceID Identifier of the face according to DuMuX' numbering. * @param[in] value Value of scalar quantity. */ - void writeScalarQuantityOnFace(const size_t dataID, + void writeScalarQuantityOnFace(const precice::string_view &meshName, + const precice::string_view &dataName, const int faceID, const double value); - /*! - * @brief Returns reference to data vector of quantity with given identifier. + * @brief Gets the quantity value vector from the data map according to the mesh and data name. * - * @param dataID Identifier of the quantity. - * @return[in] std::vector& Reference to data vector. - */ - std::vector &getQuantityVector(const size_t dataID); - /*! - * @brief Returns const reference to data vector of quantity with given identifier. - * - * @param[in] dataID Identifier of the quantity. - * @return std::vector& Const reference to data vector. + * @param[in] meshName Name of the mesh. + * @param[in] dataName Name of the data. + * @return The value vector of the quantity. */ - const std::vector &getQuantityVector(const size_t dataID) const; - + std::vector &getQuantityVector( + const precice::string_view &meshName, + const precice::string_view &dataName); /*! - * @brief Writes value of scalar or vector quantity on all vertices. + * @brief Writes the quantity value vector into the data map. * - * @param[in] dataID Identifier of the quantity. + * @param[in] meshName Name of the mesh. + * @param[in] dataName Name of the data. * @param[in] values Value of the scalar or vector quantity. */ - void writeQuantityVector(const size_t dataID, std::vector &values); - /*! - * @brief Writes data from adapter's buffer into preCICE's communication buffer. - * - * @param[in] dataID Identifier of the quantity to write into communication buffer. - */ - void writeQuantityToOtherSolver(const size_t dataID, - const QuantityType quantity_type); - /*! - * @brief Reads data from preCICE's communication buffer and puts it into adapter's buffer. - * - * @param dataID Identifier of the quantity to read into adapter buffer. - */ - void readQuantityFromOtherSolver(const size_t dataID, - const QuantityType quantity_type); - /*! - * @brief Writes data from adapter's buffer into preCICE's communication buffer. - * - * @param[in] dataID Identifier of the quantity to write into communication buffer. - */ - void writeScalarQuantityToOtherSolver(const size_t dataID); - /*! - * @brief Reads data from preCICE's communication buffer and puts it into adapter's buffer. - * - * @param dataID Identifier of the quantity to read into adapter buffer. - */ - void readScalarQuantityFromOtherSolver(const size_t dataID); - /*! - * @brief Writes data from adapter's buffer into preCICE's communication buffer. - * - * @param[in] dataID Identifier of the quantity to write into communication buffer. - */ - /*! + void writeQuantityVector(const precice::string_view &meshName, + const precice::string_view &dataName, + std::vector &values); + /*! * @brief Checks whether face with given identifier is part of coupling interface. * * @param[in] faceID Identifier of the face according to DuMuX' numbering. @@ -386,19 +264,14 @@ public: */ bool isCoupledEntity(const int faceID) const; /*! - * @brief Get a quantity's numeric identifier from its name. + * @brief Get a quantity's identifier from its name. * + * @param[in] meshName Name of the mesh. * @param[in] dataName Name of the quantity. * @return size_t Numeric identifier of quantity. */ - size_t getIdFromName(const std::string &dataName) const; - /*! - * @brief Get a quantitiy's name from its numeric identifier. - * - * @param dataID Identifier of the quantity to read into adapter buffer. - * @return std::string Name of the quantity. - */ - std::string getNameFromId(const size_t dataID) const; + std::string meshAndDataKey(const precice::string_view &meshName, + const precice::string_view &dataName) const; /*! * @brief Prints status of coupling adapter to given output stream. * diff --git a/examples/dummysolver/main_dummysolver.cc b/examples/dummysolver/main_dummysolver.cc index 5e8808d..a2ff0ff 100644 --- a/examples/dummysolver/main_dummysolver.cc +++ b/examples/dummysolver/main_dummysolver.cc @@ -36,41 +36,41 @@ try { // - Name of solver // - Configuration file name // - Solver rank - const std::string solverName = getParamFromGroup("preCICE", "SolverName"); const std::string preciceConfigFilename = getParamFromGroup("preCICE", "ConfigFileName"); const std::string meshName = getParamFromGroup("preCICE", "MeshName"); + const precice::string_view meshNameView(meshName); - auto &couplingInterface = Dumux::Precice::CouplingAdapter::getInstance(); - couplingInterface.announceSolver(solverName, preciceConfigFilename, - mpiHelper.rank(), mpiHelper.size()); - + auto &couplingParticipant = Dumux::Precice::CouplingAdapter::getInstance(); + couplingParticipant.announceSolver(solverName, preciceConfigFilename, + mpiHelper.rank(), mpiHelper.size()); std::cout << "DUMMY (" << mpiHelper.rank() << "): Running solver dummy with preCICE config file \"" << preciceConfigFilename << "\", participant name \"" << solverName << "\", and mesh name \"" << meshName << "\".\n"; - const int dimensions = couplingInterface.getDimensions(); + const int dimensions = couplingParticipant.getMeshDimensions(meshNameView); assert(dimensions == 3); - const std::string scalarDataWriteName = - (solverName == "SolverOne") ? "scalarDataOne" : "scalarDataTwo"; - const std::string scalarDataReadName = - (solverName == "SolverOne") ? "scalarDataTwo" : "scalarDataOne"; - - const std::string vectorDataWriteName = - (solverName == "SolverOne") ? "vectorDataOne" : "vectorDataTwo"; - const std::string vectorDataReadName = - (solverName == "SolverOne") ? "vectorDataTwo" : "vectorDataOne"; + const precice::string_view scalarDataWriteName = std::string( + (solverName == "SolverOne") ? "scalarDataOne" : "scalarDataTwo"); + const precice::string_view scalarDataReadName = std::string( + (solverName == "SolverOne") ? "scalarDataTwo" : "scalarDataOne"); + const precice::string_view vectorDataWriteName = std::string( + (solverName == "SolverOne") ? "vectorDataOne" : "vectorDataTwo"); + const precice::string_view vectorDataReadName = std::string( + (solverName == "SolverOne") ? "vectorDataTwo" : "vectorDataOne"); const int numberOfVertices = 3; std::vector writeScalarData(numberOfVertices); + std::vector readScalarData(numberOfVertices); std::vector writeVectorData(numberOfVertices * dimensions); - std::vector vertices(numberOfVertices * dimensions); - std::vector preciceVertexIDs(numberOfVertices); + std::vector readVectorData(numberOfVertices * dimensions); + + std::vector vertices(numberOfVertices * dimensions); // coordinates std::vector dumuxVertexIDs(numberOfVertices); for (int i = 0; i < numberOfVertices; i++) { @@ -82,52 +82,53 @@ try { } } + precice::span writeScalarDataSpan(writeScalarData); + precice::span readScalarDataSpan(readScalarData); + precice::span writeVectorDataSpan(writeVectorData); + precice::span readVectorDataSpan(readVectorData); + precice::span dumuxVertexIDsSpan(dumuxVertexIDs); + std::cout << "DUMMY (" << mpiHelper.rank() << "): Initialize preCICE and set mesh\n"; - double preciceDt = couplingInterface.setMeshAndInitialize( - meshName, numberOfVertices, vertices); + couplingParticipant.setMesh(meshNameView, vertices); // Create index mapping between DuMuX's index numbering and preCICE's numbering std::cout << "DUMMY (" << mpiHelper.rank() << "): Create index mapping\n"; - couplingInterface.createIndexMapping(dumuxVertexIDs); - - const int readScalarDataID = - couplingInterface.announceScalarQuantity(scalarDataReadName); - const int writeScalarDataID = - couplingInterface.announceScalarQuantity(scalarDataWriteName); - const int readVectorDataID = - couplingInterface.announceVectorQuantity(vectorDataReadName); - const int writeVectorDataID = - couplingInterface.announceVectorQuantity(vectorDataWriteName); - - if (couplingInterface.hasToWriteInitialData()) { + couplingParticipant.createIndexMapping(dumuxVertexIDs); + + couplingParticipant.announceQuantity(meshNameView, scalarDataWriteName); + couplingParticipant.announceQuantity(meshNameView, scalarDataReadName); + couplingParticipant.announceQuantity(meshNameView, vectorDataWriteName); + couplingParticipant.announceQuantity(meshNameView, vectorDataReadName); + + if (couplingParticipant.requiresToWriteInitialData()) { std::cout << "DUMMY (" << mpiHelper.rank() << "): Writing initial data\n"; - // Scalar data - couplingInterface.writeQuantityVector(writeScalarDataID, - writeScalarData); - couplingInterface.writeScalarQuantityToOtherSolver(writeScalarDataID); - // Vector data - couplingInterface.writeQuantityVector(writeVectorDataID, - writeVectorData); - couplingInterface.writeQuantityToOtherSolver( - writeVectorDataID, Dumux::Precice::QuantityType::Vector); - couplingInterface.announceInitialDataWritten(); + couplingParticipant.writeQuantityVector( + meshNameView, scalarDataWriteName, writeScalarData); + couplingParticipant.writeQuantityToOtherSolver(meshNameView, + scalarDataWriteName); + couplingParticipant.writeQuantityVector( + meshNameView, vectorDataWriteName, writeVectorData); + couplingParticipant.writeQuantityToOtherSolver(meshNameView, + vectorDataWriteName); } std::cout << "DUMMY (" << mpiHelper.rank() << "): Exchange initial\n"; - couplingInterface.initializeData(); + couplingParticipant.initialize(); + double preciceDt = 0; // Check exchanged initial data if (solverName == "SolverOne") { std::cout << "DUMMY (" << mpiHelper.rank() << "): Reading initial data\n"; - couplingInterface.readQuantityFromOtherSolver( - readScalarDataID, Dumux::Precice::QuantityType::Scalar); - couplingInterface.readQuantityFromOtherSolver( - readVectorDataID, Dumux::Precice::QuantityType::Vector); + couplingParticipant.readQuantityFromOtherSolver( + meshNameView, scalarDataReadName, preciceDt); + couplingParticipant.readQuantityFromOtherSolver( + meshNameView, vectorDataReadName, preciceDt); const std::vector &readScalarQuantity = - couplingInterface.getQuantityVector(readScalarDataID); + couplingParticipant.getQuantityVector(meshNameView, + scalarDataReadName); std::cout << "DUMMY (" << mpiHelper.rank() << "): Scalar data\n"; for (const double &value : readScalarQuantity) @@ -135,7 +136,8 @@ try { std::cout << "\n"; const std::vector &readVectorQuantity = - couplingInterface.getQuantityVector(readVectorDataID); + couplingParticipant.getQuantityVector(meshNameView, + vectorDataReadName); std::cout << "DUMMY (" << mpiHelper.rank() << "): Vector data\n"; for (const double &value : readVectorQuantity) @@ -170,28 +172,29 @@ try { int iter = 0; - while (couplingInterface.isCouplingOngoing()) { - if (couplingInterface.hasToWriteIterationCheckpoint()) { + while (couplingParticipant.isCouplingOngoing()) { + if (couplingParticipant.requiresToWriteCheckpoint()) { std::cout << "DUMMY (" << mpiHelper.rank() << "): Writing iteration checkpoint\n"; - couplingInterface.announceIterationCheckpointWritten(); } //Read data std::cout << "DUMMY (" << mpiHelper.rank() << "): Reading data\n"; - couplingInterface.readQuantityFromOtherSolver( - readScalarDataID, Dumux::Precice::QuantityType::Scalar); - couplingInterface.readQuantityFromOtherSolver( - readVectorDataID, Dumux::Precice::QuantityType::Vector); + couplingParticipant.readQuantityFromOtherSolver( + meshNameView, scalarDataReadName, preciceDt); + couplingParticipant.readQuantityFromOtherSolver( + meshNameView, vectorDataReadName, preciceDt); // Check data if (iter > 0) { int offset = (solverName == "SolverOne") ? 0 : 1; - const std::vector &readScalarQuantity = - couplingInterface.getQuantityVector(readScalarDataID); + const std::vector &readScalarQuantity = + couplingParticipant.getQuantityVector(meshNameView, + scalarDataReadName); const std::vector &readVectorQuantity = - couplingInterface.getQuantityVector(readVectorDataID); + couplingParticipant.getQuantityVector(meshNameView, + vectorDataReadName); for (int i = 0; i < numberOfVertices; i++) { if (readScalarQuantity.at(i) != @@ -236,24 +239,23 @@ try { // Write scalar data via DuMuX ID <-> preCICE ID mapping for (int i = 0; i < numberOfVertices; i++) { const double value = i + iter; - couplingInterface.writeScalarQuantityOnFace( - writeScalarDataID, dumuxVertexIDs[i], value); + couplingParticipant.writeScalarQuantityOnFace( + meshNameView, scalarDataWriteName, dumuxVertexIDs[i], value); } - couplingInterface.writeQuantityToOtherSolver( - writeScalarDataID, Dumux::Precice::QuantityType::Scalar); + couplingParticipant.writeQuantityToOtherSolver(meshNameView, + scalarDataWriteName); // Write vector data - couplingInterface.writeQuantityVector(writeVectorDataID, - writeVectorData); - couplingInterface.writeQuantityToOtherSolver( - writeVectorDataID, Dumux::Precice::QuantityType::Vector); - - preciceDt = couplingInterface.advance(preciceDt); - - if (couplingInterface.hasToReadIterationCheckpoint()) { + couplingParticipant.writeQuantityVector( + meshNameView, vectorDataWriteName, writeVectorData); + couplingParticipant.writeQuantityToOtherSolver(meshNameView, + vectorDataWriteName); + preciceDt = couplingParticipant.getMaxTimeStepSize(); + couplingParticipant.advance(preciceDt); + + if (couplingParticipant.requiresToReadCheckpoint()) { std::cout << "DUMMY (" << mpiHelper.rank() << "): Reading iteration checkpoint\n"; - couplingInterface.announceIterationCheckpointRead(); } else { std::cout << "DUMMY (" << mpiHelper.rank() << "): Advancing in time\n"; @@ -263,7 +265,7 @@ try { // finalize, print dumux message to say goodbye //////////////////////////////////////////////////////////// - couplingInterface.finalize(); + couplingParticipant.finalize(); std::cout << "DUMMY (" << mpiHelper.rank() << "): Closing C++ solver dummy...\n"; @@ -275,6 +277,7 @@ try { return 0; } // end main + catch (Dumux::ParameterException &e) { std::cerr << std::endl << e << " ---> Abort!" << std::endl; return 1; diff --git a/examples/dummysolver/precice-dummy-solver-config.xml b/examples/dummysolver/precice-dummy-solver-config.xml index 4cd2a69..52e5c97 100644 --- a/examples/dummysolver/precice-dummy-solver-config.xml +++ b/examples/dummysolver/precice-dummy-solver-config.xml @@ -1,58 +1,55 @@ - + + + - + + - - + + + - - + + + - - - + + + - - - + + + - - - + + - - - + + + + + - - + + + - - - - - + + - - - + + + + + - - - - - - - - - - + @@ -68,6 +65,4 @@ - - diff --git a/examples/dummysolver/test.xml b/examples/dummysolver/test.xml index 4d46857..106fae0 100644 --- a/examples/dummysolver/test.xml +++ b/examples/dummysolver/test.xml @@ -6,47 +6,43 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh b/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh index 1687d6e..e27412b 100644 --- a/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh +++ b/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh @@ -137,15 +137,10 @@ public: StokesSubProblem(std::shared_ptr gridGeometry) : ParentType(gridGeometry, "FreeFlow"), eps_(1e-6), - couplingInterface_(Dumux::Precice::CouplingAdapter::getInstance()), - pressureId_(0), - velocityId_(0), - dataIdsWereSet_(false) + couplingParticipant_(Dumux::Precice::CouplingAdapter::getInstance()) { deltaP_ = getParamFromGroup(this->paramGroup(), "Problem.PressureDifference"); - // pressureId_ = couplingInterface_.getIdFromName( "Pressure" ); - // velocityId_ = couplingInterface_.getIdFromName( "Velocity" ); } /*! @@ -202,16 +197,8 @@ public: values.setDirichlet(Indices::pressureIdx); } // coupling interface - else if (couplingInterface_.isCoupledEntity(faceId)) { - // // TODO do preCICE stuff in analogy to heat transfer - assert(dataIdsWereSet_); - //TODO What do I want to do here? - // values.setCouplingNeumann(Indices::conti0EqIdx); - // values.setCouplingNeumann(Indices::momentumYBalanceIdx); + else if (couplingParticipant_.isCoupledEntity(faceId)) { values.setDirichlet(Indices::velocityYIdx); - - // values.setNeumann(Indices::conti0EqIdx); - // values.setNeumann(Indices::momentumYBalanceIdx); values.setBeaversJoseph(Indices::momentumXBalanceIdx); values.setBeaversJoseph(Indices::momentumZBalanceIdx); } else { @@ -232,13 +219,16 @@ public: PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const { + precice::string_view meshNameView_("FreeFlowMesh", 12); + precice::string_view dataNameView_("Velocity", 8); PrimaryVariables values(0.0); values = initialAtPos(scvf.center()); const auto faceId = scvf.index(); - if (couplingInterface_.isCoupledEntity(faceId)) { + if (couplingParticipant_.isCoupledEntity(faceId)) { values[Indices::velocityYIdx] = - couplingInterface_.getScalarQuantityOnFace(velocityId_, faceId); + couplingParticipant_.getScalarQuantityOnFace( + meshNameView_, dataNameView_, faceId); } return values; @@ -260,11 +250,12 @@ public: const ElementFaceVariables &elemFaceVars, const SubControlVolumeFace &scvf) const { + precice::string_view meshNameView_("FreeFlowMesh", 12); + precice::string_view dataNameView_("Pressure", 8); NumEqVector values(0.0); - assert(dataIdsWereSet_); const auto faceId = scvf.index(); - if (couplingInterface_.isCoupledEntity(faceId)) { + if (couplingParticipant_.isCoupledEntity(faceId)) { const Scalar density = 1000; // TODO how to handle compressible fluids? values[Indices::conti0EqIdx] = density * @@ -272,8 +263,8 @@ public: scvf.directionSign(); values[Indices::momentumYBalanceIdx] = scvf.directionSign() * - (couplingInterface_.getScalarQuantityOnFace(pressureId_, - faceId) - + (couplingParticipant_.getScalarQuantityOnFace( + meshNameView_, dataNameView_, faceId) - initialAtPos(scvf.center())[Indices::pressureIdx]); } return values; @@ -372,13 +363,6 @@ public: return analyticalVelocityX_; } - void updatePreciceDataIds() - { - pressureId_ = couplingInterface_.getIdFromName("Pressure"); - velocityId_ = couplingInterface_.getIdFromName("Velocity"); - dataIdsWereSet_ = true; - } - // \} private: @@ -405,10 +389,7 @@ private: Scalar eps_; Scalar deltaP_; - Dumux::Precice::CouplingAdapter &couplingInterface_; - size_t pressureId_; - size_t velocityId_; - bool dataIdsWereSet_; + Dumux::Precice::CouplingAdapter &couplingParticipant_; mutable std::vector analyticalVelocityX_; }; diff --git a/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc b/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc index 5895a9e..f532b6b 100644 --- a/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc +++ b/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc @@ -54,6 +54,8 @@ #include "ffproblem-reversed.hh" +#include "dumux-precice/couplingadapter.hh" + //TODO // Helper function to put pressure on interface @@ -96,7 +98,9 @@ template void setInterfacePressures(const Problem &problem, const GridVariables &gridVars, - const SolutionVector &sol) + const SolutionVector &sol, + const precice::string_view meshNameView, + const precice::string_view dataNameView) { const auto &gridGeometry = problem.gridGeometry(); auto fvGeometry = localView(gridGeometry); @@ -104,8 +108,7 @@ void setInterfacePressures(const Problem &problem, auto elemFaceVars = localView(gridVars.curGridFaceVars()); auto elemFluxVarsCache = localView(gridVars.gridFluxVarsCache()); - auto &couplingInterface = Dumux::Precice::CouplingAdapter::getInstance(); - const auto pressureId = couplingInterface.getIdFromName("Pressure"); + auto &couplingParticipant = Dumux::Precice::CouplingAdapter::getInstance(); for (const auto &element : elements(gridGeometry.gridView())) { fvGeometry.bind(element); @@ -114,13 +117,13 @@ void setInterfacePressures(const Problem &problem, elemFluxVarsCache.bind(element, fvGeometry, elemVolVars); for (const auto &scvf : scvfs(fvGeometry)) { - if (couplingInterface.isCoupledEntity(scvf.index())) { + if (couplingParticipant.isCoupledEntity(scvf.index())) { //TODO: What to do here? const auto p = pressureAtInterface( problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, elemFluxVarsCache); - couplingInterface.writeScalarQuantityOnFace(pressureId, - scvf.index(), p); + couplingParticipant.writeScalarQuantityOnFace( + meshNameView, dataNameView, scvf.index(), p); } } } @@ -129,15 +132,16 @@ void setInterfacePressures(const Problem &problem, template void setInterfaceVelocities(const Problem &problem, const GridVariables &gridVars, - const SolutionVector &sol) + const SolutionVector &sol, + const precice::string_view meshNameView, + const precice::string_view dataNameView) { const auto &gridGeometry = problem.gridGeometry(); auto fvGeometry = localView(gridGeometry); auto elemVolVars = localView(gridVars.curGridVolVars()); auto elemFaceVars = localView(gridVars.curGridFaceVars()); - auto &couplingInterface = Dumux::Precice::CouplingAdapter::getInstance(); - const auto velocityId = couplingInterface.getIdFromName("Velocity"); + auto &couplingParticipant = Dumux::Precice::CouplingAdapter::getInstance(); for (const auto &element : elements(gridGeometry.gridView())) { fvGeometry.bindElement(element); @@ -145,12 +149,12 @@ void setInterfaceVelocities(const Problem &problem, elemFaceVars.bindElement(element, fvGeometry, sol); for (const auto &scvf : scvfs(fvGeometry)) { - if (couplingInterface.isCoupledEntity(scvf.index())) { + if (couplingParticipant.isCoupledEntity(scvf.index())) { //TODO: What to do here? const auto v = velocityAtInterface(elemFaceVars, scvf)[scvf.directionIndex()]; - couplingInterface.writeScalarQuantityOnFace(velocityId, - scvf.index(), v); + couplingParticipant.writeScalarQuantityOnFace( + meshNameView, dataNameView, scvf.index(), v); } } } @@ -158,6 +162,7 @@ void setInterfaceVelocities(const Problem &problem, template std::tuple writeVelocitiesOnInterfaceToFile( + const precice::string_view &meshNameView, const std::string &filename, const Problem &problem, const GridVariables &gridVars, @@ -168,13 +173,13 @@ std::tuple writeVelocitiesOnInterfaceToFile( auto elemVolVars = localView(gridVars.curGridVolVars()); auto elemFaceVars = localView(gridVars.curGridFaceVars()); - const auto &couplingInterface = + const auto &couplingParticipant = Dumux::Precice::CouplingAdapter::getInstance(); std::ofstream ofs(filename + ".csv", std::ofstream::out | std::ofstream::trunc); ofs << "x,y,"; - if (couplingInterface.getDimensions() == 3) + if (couplingParticipant.getMeshDimensions(meshNameView) == 3) ofs << "z,"; ofs << "velocityY" << "\n"; @@ -188,9 +193,11 @@ std::tuple writeVelocitiesOnInterfaceToFile( elemFaceVars.bindElement(element, fvGeometry, sol); for (const auto &scvf : scvfs(fvGeometry)) { - if (couplingInterface.isCoupledEntity(scvf.index())) { + if (couplingParticipant.isCoupledEntity(scvf.index())) { const auto &pos = scvf.center(); - for (int i = 0; i < couplingInterface.getDimensions(); ++i) { + for (int i = 0; + i < couplingParticipant.getMeshDimensions(meshNameView); + ++i) { ofs << pos[i] << ","; } const double v = problem.dirichlet(element, scvf)[1]; @@ -216,7 +223,8 @@ template -void writePressuresOnInterfaceToFile(const std::string &filename, +void writePressuresOnInterfaceToFile(const precice::string_view &meshNameView, + const std::string &filename, const Problem &problem, const GridVariables &gridVars, const SolutionVector &sol) @@ -227,13 +235,13 @@ void writePressuresOnInterfaceToFile(const std::string &filename, auto elemFaceVars = localView(gridVars.curGridFaceVars()); auto elemFluxVarsCache = localView(gridVars.gridFluxVarsCache()); - const auto &couplingInterface = + const auto &couplingParticipant = Dumux::Precice::CouplingAdapter::getInstance(); std::ofstream ofs(filename + ".csv", std::ofstream::out | std::ofstream::trunc); ofs << "x,y,"; - if (couplingInterface.getDimensions() == 3) + if (couplingParticipant.getMeshDimensions(meshNameView) == 3) ofs << "z,"; ofs << "pressure" << "\n"; @@ -244,9 +252,11 @@ void writePressuresOnInterfaceToFile(const std::string &filename, elemFluxVarsCache.bind(element, fvGeometry, elemVolVars); for (const auto &scvf : scvfs(fvGeometry)) { - if (couplingInterface.isCoupledEntity(scvf.index())) { + if (couplingParticipant.isCoupledEntity(scvf.index())) { const auto &pos = scvf.center(); - for (int i = 0; i < couplingInterface.getDimensions(); ++i) { + for (int i = 0; + i < couplingParticipant.getMeshDimensions(meshNameView); + ++i) { ofs << pos[i] << ","; } const double p = pressureAtInterface( @@ -313,18 +323,19 @@ try { // - Name of solver // - What rank of how many ranks this instance is // Configure preCICE. For now the config file is hardcoded. - //couplingInterface.createInstance( "FreeFlow", mpiHelper.rank(), mpiHelper.size() ); + //couplingParticipant.createInstance( "FreeFlow", mpiHelper.rank(), mpiHelper.size() ); std::string preciceConfigFilename = "precice-config.xml"; // if (argc == 3) // preciceConfigFilename = argv[2]; if (argc > 2) preciceConfigFilename = argv[argc - 1]; - auto &couplingInterface = Dumux::Precice::CouplingAdapter::getInstance(); - couplingInterface.announceSolver("FreeFlow", preciceConfigFilename, - mpiHelper.rank(), mpiHelper.size()); + auto &couplingParticipant = Dumux::Precice::CouplingAdapter::getInstance(); + couplingParticipant.announceSolver("FreeFlow", preciceConfigFilename, + mpiHelper.rank(), mpiHelper.size()); - const int dim = couplingInterface.getDimensions(); + const precice::string_view meshNameView("FreeFlowMesh", 12); + const int dim = couplingParticipant.getMeshDimensions(meshNameView); std::cout << dim << " " << int(FreeFlowGridGeometry::GridView::dimension) << std::endl; if (dim != int(FreeFlowGridGeometry::GridView::dimension)) @@ -356,16 +367,14 @@ try { } const auto numberOfPoints = coords.size() / dim; - const double preciceDt = couplingInterface.setMeshAndInitialize( - "FreeFlowMesh", numberOfPoints, coords); - couplingInterface.createIndexMapping(coupledScvfIndices); - - const auto velocityId = - couplingInterface.announceScalarQuantity("Velocity"); - const auto pressureId = - couplingInterface.announceScalarQuantity("Pressure"); + precice::span coordsSpan(coords); + couplingParticipant.setMesh(meshNameView, coordsSpan); + couplingParticipant.createIndexMapping(coupledScvfIndices); - freeFlowProblem->updatePreciceDataIds(); + const precice::string_view dataNameViewV("Velocity", 8); + const precice::string_view dataNameViewP("Pressure", 8); + couplingParticipant.announceQuantity(meshNameView, dataNameViewV); + couplingParticipant.announceQuantity(meshNameView, dataNameViewP); // apply initial solution for instationary problems freeFlowProblem->applyInitialSolution(sol); @@ -389,24 +398,14 @@ try { using FluxVariables = GetPropType; - if (couplingInterface.hasToWriteInitialData()) { - //TODO - // couplingInterface.writeQuantityVector( pressureId ); - + if (couplingParticipant.requiresToWriteInitialData()) { setInterfacePressures(*freeFlowProblem, - *freeFlowGridVariables, sol); - //For testing - // { - // std::cout << "Pressures to be sent to pm" << std::endl; - // const auto p = couplingInterface.getQuantityVector( pressureId ); - // for (size_t i = 0; i < p.size(); ++i) { - // std::cout << "p[" << i << "]=" <; NewtonSolver nonLinearSolver(assembler, linearSolver); + double preciceDt = couplingParticipant.getMaxTimeStepSize(); auto dt = preciceDt; auto sol_checkpoint = sol; double vtkTime = 1.0; size_t iter = 0; - while (couplingInterface.isCouplingOngoing()) { - if (couplingInterface.hasToWriteIterationCheckpoint()) { + while (couplingParticipant.isCouplingOngoing()) { + if (couplingParticipant.requiresToWriteCheckpoint()) { //DO CHECKPOINTING sol_checkpoint = sol; - couplingInterface.announceIterationCheckpointWritten(); } - // TODO - couplingInterface.readScalarQuantityFromOtherSolver(velocityId); - // // For testing - // { - // const auto v = couplingInterface.getQuantityVector( velocityId ); - // const double sum = std::accumulate( v.begin(), v.end(), 0. ); - // std::cout << "Sum of velocities over boundary to pm: \n" << sum << std::endl; - // } - + couplingParticipant.readQuantityFromOtherSolver(meshNameView, + dataNameViewV, dt); // solve the non-linear system nonLinearSolver.solve(sol); // TODO setInterfacePressures(*freeFlowProblem, - *freeFlowGridVariables, sol); - // For testing - // { - // const auto p = couplingInterface.getQuantityVector( pressureId ); - // const double sum = std::accumulate( p.begin(), p.end(), 0. ); - // std::cout << "Pressures to be sent to pm" << std::endl; - //// for (size_t i = 0; i < p.size(); ++i) { - //// std::cout << "p[" << i << "]=" << p[i] << std::endl; - //// } - // std::cout << "Sum of pressures over boundary to pm: \n" << sum << std::endl; - // } - couplingInterface.writeScalarQuantityToOtherSolver(pressureId); - + *freeFlowGridVariables, sol, + meshNameView, dataNameViewP); + couplingParticipant.writeQuantityToOtherSolver(meshNameView, + dataNameViewP); //Read checkpoint freeFlowVtkWriter.write(vtkTime); vtkTime += 1.; - const double preciceDt = couplingInterface.advance(dt); + couplingParticipant.advance(dt); + preciceDt = couplingParticipant.getMaxTimeStepSize(); dt = std::min(preciceDt, dt); ++iter; - if (couplingInterface.hasToReadIterationCheckpoint()) { + if (couplingParticipant.requiresToReadCheckpoint()) { // //Read checkpoint // freeFlowVtkWriter.write(vtkTime); // vtkTime += 1.; @@ -484,7 +468,6 @@ try { freeFlowGridVariables->update(sol); freeFlowGridVariables->advanceTimeStep(); //freeFlowGridVariables->init(sol); - couplingInterface.announceIterationCheckpointRead(); } else // coupling successful { // write vtk output @@ -495,7 +478,7 @@ try { // finalize, print dumux message to say goodbye //////////////////////////////////////////////////////////// - couplingInterface.finalize(); + couplingParticipant.finalize(); // print dumux end message if (mpiHelper.rank() == 0) { diff --git a/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc b/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc index 4bffe08..e62552f 100644 --- a/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc +++ b/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc @@ -62,6 +62,8 @@ bool printstuff = false; #include "pmproblem-reversed.hh" +#include "dumux-precice/couplingadapter.hh" + /*! * \brief Returns the pressure at the interface using Darcy's law for reconstruction */ @@ -112,15 +114,16 @@ auto pressureAtInterface(const Problem &problem, template void setInterfacePressures(const Problem &problem, const GridVariables &gridVars, - const SolutionVector &sol) + const SolutionVector &sol, + const precice::string_view meshNameView, + const precice::string_view dataNameView) { const auto &gridGeometry = problem.gridGeometry(); auto fvGeometry = localView(gridGeometry); auto elemVolVars = localView(gridVars.curGridVolVars()); auto elemFluxVarsCache = localView(gridVars.gridFluxVarsCache()); - auto &couplingInterface = Dumux::Precice::CouplingAdapter::getInstance(); - const auto pressureId = couplingInterface.getIdFromName("Pressure"); + auto &couplingParticipant = Dumux::Precice::CouplingAdapter::getInstance(); for (const auto &element : elements(gridGeometry.gridView())) { fvGeometry.bindElement(element); @@ -128,13 +131,13 @@ void setInterfacePressures(const Problem &problem, //sstd::cout << "Pressure by reconstruction" << std::endl; for (const auto &scvf : scvfs(fvGeometry)) { - if (couplingInterface.isCoupledEntity(scvf.index())) { + if (couplingParticipant.isCoupledEntity(scvf.index())) { //TODO: What to do here? const double p = pressureAtInterface(problem, element, gridGeometry, elemVolVars, scvf, elemFluxVarsCache); - couplingInterface.writeScalarQuantityOnFace(pressureId, - scvf.index(), p); + couplingParticipant.writeScalarQuantityOnFace( + meshNameView, dataNameView, scvf.index(), p); } } } @@ -175,15 +178,16 @@ template void setInterfaceVelocities(const Problem &problem, const GridVariables &gridVars, - const SolutionVector &sol) + const SolutionVector &sol, + const precice::string_view meshNameView, + const precice::string_view dataNameView) { const auto &gridGeometry = problem.gridGeometry(); auto fvGeometry = localView(gridGeometry); auto elemVolVars = localView(gridVars.curGridVolVars()); auto elemFluxVarsCache = localView(gridVars.gridFluxVarsCache()); - auto &couplingInterface = Dumux::Precice::CouplingAdapter::getInstance(); - const auto velocityId = couplingInterface.getIdFromName("Velocity"); + auto &couplingParticipant = Dumux::Precice::CouplingAdapter::getInstance(); for (const auto &element : elements(gridGeometry.gridView())) { fvGeometry.bind(element); @@ -191,13 +195,13 @@ void setInterfaceVelocities(const Problem &problem, elemFluxVarsCache.bind(element, fvGeometry, elemVolVars); for (const auto &scvf : scvfs(fvGeometry)) { - if (couplingInterface.isCoupledEntity(scvf.index())) { + if (couplingParticipant.isCoupledEntity(scvf.index())) { //TODO: What to do here? const double v = velocityAtInterface( problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache); - couplingInterface.writeScalarQuantityOnFace(velocityId, - scvf.index(), v); + couplingParticipant.writeScalarQuantityOnFace( + meshNameView, dataNameView, scvf.index(), v); } } } @@ -208,6 +212,7 @@ template std::tuple writeVelocitiesOnInterfaceToFile( + const precice::string_view &meshName, const std::string &filename, const Problem &problem, const GridVariables &gridVars, @@ -218,13 +223,13 @@ std::tuple writeVelocitiesOnInterfaceToFile( auto elemVolVars = localView(gridVars.curGridVolVars()); auto elemFluxVarsCache = localView(gridVars.gridFluxVarsCache()); - const auto &couplingInterface = + const auto &couplingParticipant = Dumux::Precice::CouplingAdapter::getInstance(); std::ofstream ofs(filename + ".csv", std::ofstream::out | std::ofstream::trunc); ofs << "x,y,"; - if (couplingInterface.getDimensions() == 3) + if (couplingParticipant.getMeshDimensions(meshName) == 3) ofs << "z,"; ofs << "velocityY" << "\n"; @@ -238,9 +243,10 @@ std::tuple writeVelocitiesOnInterfaceToFile( elemFluxVarsCache.bind(element, fvGeometry, elemVolVars); for (const auto &scvf : scvfs(fvGeometry)) { - if (couplingInterface.isCoupledEntity(scvf.index())) { + if (couplingParticipant.isCoupledEntity(scvf.index())) { const auto &pos = scvf.center(); - for (int i = 0; i < couplingInterface.getDimensions(); ++i) { + for (int i = 0; + i < couplingParticipant.getMeshDimensions(meshName); ++i) { ofs << pos[i] << ","; } const double v = velocityAtInterface( @@ -263,7 +269,8 @@ std::tuple writeVelocitiesOnInterfaceToFile( } template -void writePressuresOnInterfaceToFile(const std::string &filename, +void writePressuresOnInterfaceToFile(const precice::string_view &meshName, + std::string &filename, const Problem &problem, const GridVariables &gridVars, const SolutionVector &sol) @@ -273,13 +280,13 @@ void writePressuresOnInterfaceToFile(const std::string &filename, auto elemVolVars = localView(gridVars.curGridVolVars()); auto elemFluxVarsCache = localView(gridVars.gridFluxVarsCache()); - const auto &couplingInterface = + const auto &couplingParticipant = Dumux::Precice::CouplingAdapter::getInstance(); std::ofstream ofs(filename + ".csv", std::ofstream::out | std::ofstream::trunc); ofs << "x,y,"; - if (couplingInterface.getDimensions() == 3) + if (couplingParticipant.getMeshDimensions(meshName) == 3) ofs << "z,"; ofs << "pressure" << "\n"; @@ -289,9 +296,10 @@ void writePressuresOnInterfaceToFile(const std::string &filename, elemFluxVarsCache.bind(element, fvGeometry, elemVolVars); for (const auto &scvf : scvfs(fvGeometry)) { - if (couplingInterface.isCoupledEntity(scvf.index())) { + if (couplingParticipant.isCoupledEntity(scvf.index())) { const auto &pos = scvf.center(); - for (int i = 0; i < couplingInterface.getDimensions(); ++i) { + for (int i = 0; + i < couplingParticipant.getMeshDimensions(meshName); ++i) { ofs << pos[i] << ","; } const double p = @@ -350,18 +358,19 @@ try { // - Name of solver // - What rank of how many ranks this instance is // Configure preCICE. For now the config file is hardcoded. - //couplingInterface.createInstance( "darcy", mpiHelper.rank(), mpiHelper.size() ); + //couplingParticipant.createInstance( "darcy", mpiHelper.rank(), mpiHelper.size() ); std::string preciceConfigFilename = "precice-config.xml"; // if (argc == 3) // preciceConfigFilename = argv[2]; if (argc > 2) preciceConfigFilename = argv[argc - 1]; - auto &couplingInterface = Dumux::Precice::CouplingAdapter::getInstance(); - couplingInterface.announceSolver("Darcy", preciceConfigFilename, - mpiHelper.rank(), mpiHelper.size()); + auto &couplingParticipant = Dumux::Precice::CouplingAdapter::getInstance(); + couplingParticipant.announceSolver("Darcy", preciceConfigFilename, + mpiHelper.rank(), mpiHelper.size()); - const int dim = couplingInterface.getDimensions(); + const precice::string_view meshNameView("DarcyMesh", 9); + const int dim = couplingParticipant.getMeshDimensions(meshNameView); std::cout << dim << " " << int(DarcyGridGeometry::GridView::dimension) << std::endl; if (dim != int(DarcyGridGeometry::GridView::dimension)) @@ -393,16 +402,14 @@ try { } const auto numberOfPoints = coords.size() / dim; - const double preciceDt = couplingInterface.setMeshAndInitialize( - "DarcyMesh", numberOfPoints, coords); - couplingInterface.createIndexMapping(coupledScvfIndices); - - const auto velocityId = - couplingInterface.announceScalarQuantity("Velocity"); - const auto pressureId = - couplingInterface.announceScalarQuantity("Pressure"); + precice::span coordsSpan(coords); + couplingParticipant.setMesh(meshNameView, coordsSpan); + couplingParticipant.createIndexMapping(coupledScvfIndices); - darcyProblem->updatePreciceDataIds(); + const precice::string_view dataNameViewV("Velocity", 8); + const precice::string_view dataNameViewP("Pressure", 8); + couplingParticipant.announceQuantity(meshNameView, dataNameViewP); + couplingParticipant.announceQuantity(meshNameView, dataNameViewV); darcyProblem->applyInitialSolution(sol); @@ -429,26 +436,15 @@ try { darcyVtkWriter.write(0.0); using FluxVariables = GetPropType; - if (couplingInterface.hasToWriteInitialData()) { + if (couplingParticipant.requiresToWriteInitialData()) { //TODO - //couplingInterface.writeQuantityVector(velocityId); setInterfaceVelocities(*darcyProblem, - *darcyGridVariables, sol); - // For testing - { - const auto v = couplingInterface.getQuantityVector(velocityId); - std::cout << "velocities to be sent to ff" << std::endl; - for (size_t i = 0; i < v.size(); ++i) { - for (size_t d = 0; d < dim; ++d) { - std::cout << coords[i * dim + d] << " "; - } - std::cout << "| v[" << i << "]=" << v[i] << std::endl; - } - } - couplingInterface.writeScalarQuantityToOtherSolver(velocityId); - couplingInterface.announceInitialDataWritten(); + *darcyGridVariables, sol, + meshNameView, dataNameViewV); + couplingParticipant.writeQuantityToOtherSolver(meshNameView, + dataNameViewV); } - couplingInterface.initializeData(); + couplingParticipant.initialize(); // the assembler for a stationary problem using Assembler = FVAssembler; @@ -469,77 +465,43 @@ try { using NewtonSolver = Dumux::NewtonSolver; NewtonSolver nonLinearSolver(assembler, linearSolver); + double preciceDt = couplingParticipant.getMaxTimeStepSize(); auto dt = preciceDt; auto sol_checkpoint = sol; double vtkTime = 1.0; size_t iter = 0; - while (couplingInterface.isCouplingOngoing()) { - if (couplingInterface.hasToWriteIterationCheckpoint()) { + while (couplingParticipant.isCouplingOngoing()) { + if (couplingParticipant.requiresToWriteCheckpoint()) { //DO CHECKPOINTING sol_checkpoint = sol; - couplingInterface.announceIterationCheckpointWritten(); } - // TODO - couplingInterface.readScalarQuantityFromOtherSolver(pressureId); - // For testing - { - const auto p = couplingInterface.getQuantityVector(pressureId); - for (size_t i = 0; i < p.size(); ++i) { - for (size_t d = 0; d < dim; ++d) { - std::cout << coords[i * dim + d] << " "; - } - std::cout << "| p[" << i << "]=" << p[i] << std::endl; - } - const double sum = std::accumulate(p.begin(), p.end(), 0.); - std::cout << "Sum of pressures over boundary to ff: \n" - << sum << std::endl; - std::cout << "Pressure received from ff" << std::endl; - // for (size_t i = 0; i < p.size(); ++i) { - // std::cout << "p[" << i << "]=" << p[i] << std::endl; - // } - } + couplingParticipant.readQuantityFromOtherSolver(meshNameView, + dataNameViewP, dt); // solve the non-linear system nonLinearSolver.solve(sol); setInterfaceVelocities(*darcyProblem, - *darcyGridVariables, sol); - // For testing - { - const auto v = couplingInterface.getQuantityVector(velocityId); - for (size_t i = 0; i < v.size(); ++i) { - for (size_t d = 0; d < dim; ++d) { - std::cout << coords[i * dim + d] << " "; - } - std::cout << "| v[" << i << "]=" << v[i] << std::endl; - } - - const double sum = std::accumulate(v.begin(), v.end(), 0.); - std::cout << "Velocities to be sent to ff" << std::endl; - // for (size_t i = 0; i < v.size(); ++i) { - // std::cout << "v[" << i << "]=" << v[i] << std::endl; - // } - std::cout << "Sum of velocities over boundary to ff: \n" - << sum << std::endl; - } - couplingInterface.writeScalarQuantityToOtherSolver(velocityId); + *darcyGridVariables, sol, + meshNameView, dataNameViewV); + couplingParticipant.writeQuantityToOtherSolver(meshNameView, + dataNameViewV); - const double preciceDt = couplingInterface.advance(dt); + couplingParticipant.advance(dt); + preciceDt = couplingParticipant.getMaxTimeStepSize(); dt = std::min(preciceDt, dt); ++iter; - if (couplingInterface.hasToReadIterationCheckpoint()) { + if (couplingParticipant.requiresToReadCheckpoint()) { //Read checkpoint darcyVtkWriter.write(vtkTime); vtkTime += 1.; sol = sol_checkpoint; darcyGridVariables->update(sol); darcyGridVariables->advanceTimeStep(); - //darcyGridVariables->init(sol); - couplingInterface.announceIterationCheckpointRead(); } else // coupling successful { // write vtk output @@ -549,7 +511,7 @@ try { // write vtk output darcyVtkWriter.write(1.0); - couplingInterface.finalize(); + couplingParticipant.finalize(); //////////////////////////////////////////////////////////// // finalize, print dumux message to say goodbye diff --git a/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh b/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh index 776eee9..21d1c0b 100644 --- a/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh +++ b/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh @@ -122,10 +122,7 @@ public: DarcySubProblem(std::shared_ptr fvGridGeometry) : ParentType(fvGridGeometry, "Darcy"), eps_(1e-7), - couplingInterface_(Dumux::Precice::CouplingAdapter::getInstance()), - pressureId_(0), - velocityId_(0), - dataIdsWereSet_(false) + couplingParticipant_(Dumux::Precice::CouplingAdapter::getInstance()) { } @@ -168,7 +165,7 @@ public: values.setAllNeumann(); const auto faceId = scvf.index(); - if (couplingInterface_.isCoupledEntity(faceId)) + if (couplingParticipant_.isCoupledEntity(faceId)) values.setAllDirichlet(); return values; } @@ -184,14 +181,16 @@ public: PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const { + precice::string_view meshNameView_("DarcyMesh", 9); + precice::string_view dataNameView_("Pressure", 8); // set p = 0 at the bottom PrimaryVariables values(0.0); values = initial(element); const auto faceId = scvf.index(); - if (couplingInterface_.isCoupledEntity(faceId)) - values = - couplingInterface_.getScalarQuantityOnFace(pressureId_, faceId); + if (couplingParticipant_.isCoupledEntity(faceId)) + values = couplingParticipant_.getScalarQuantityOnFace( + meshNameView_, dataNameView_, faceId); return values; } @@ -215,15 +214,6 @@ public: { // no-flow everywhere ... NumEqVector values(0.0); - - // assert( dataIdsWereSet_ ); - // const auto faceId = scvf.index(); - // if ( couplingInterface_.isCoupledEntity(faceId) ) - // { - // const Scalar density = 1000.; - // values[Indices::conti0EqIdx] = density * couplingInterface_.getScalarQuantityOnFace( velocityId_, faceId ); - // std::cout << "pm: values[Indices::conti0EqIdx] = " << values << std::endl; - // } return values; } @@ -280,13 +270,6 @@ public: // \} - void updatePreciceDataIds() - { - pressureId_ = couplingInterface_.getIdFromName("Pressure"); - velocityId_ = couplingInterface_.getIdFromName("Velocity"); - dataIdsWereSet_ = true; - } - private: bool onLeftBoundary_(const GlobalPosition &globalPos) const { @@ -310,10 +293,7 @@ private: Scalar eps_; - Dumux::Precice::CouplingAdapter &couplingInterface_; - size_t pressureId_; - size_t velocityId_; - bool dataIdsWereSet_; + Dumux::Precice::CouplingAdapter &couplingParticipant_; }; } // namespace Dumux diff --git a/examples/ff-pm/flow-over-cube-3d/precice-config.xml b/examples/ff-pm/flow-over-cube-3d/precice-config.xml index 6d4c872..d21621d 100644 --- a/examples/ff-pm/flow-over-cube-3d/precice-config.xml +++ b/examples/ff-pm/flow-over-cube-3d/precice-config.xml @@ -6,55 +6,53 @@ - - - + + - - - - + + + + - - - - + + + + - - - + + + - - + + - - + + + - + + - - + + + - - - + - + + + + - - - - + + + - - - - - - + + - - - - - - - - - + + + + + + + - - + diff --git a/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh b/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh index b9d23c6..14540f2 100644 --- a/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh +++ b/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh @@ -138,10 +138,7 @@ public: StokesSubProblem(std::shared_ptr gridGeometry) : ParentType(gridGeometry, "FreeFlow"), eps_(1e-6), - couplingInterface_(Dumux::Precice::CouplingAdapter::getInstance()), - pressureId_(0), - velocityId_(0), - dataIdsWereSet_(false) + couplingParticipant_(Dumux::Precice::CouplingAdapter::getInstance()) { deltaP_ = getParamFromGroup(this->paramGroup(), "Problem.PressureDifference"); @@ -201,9 +198,7 @@ public: values.setDirichlet(Indices::pressureIdx); } // coupling interface - else if (couplingInterface_.isCoupledEntity(faceId)) { - assert(dataIdsWereSet_); - + else if (couplingParticipant_.isCoupledEntity(faceId)) { values.setDirichlet(Indices::velocityYIdx); values.setBeaversJoseph(Indices::momentumXBalanceIdx); } else { @@ -223,13 +218,16 @@ public: PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const { + precice::string_view meshNameView_("FreeFlowMesh", 12); + precice::string_view dataNameView_("Velocity", 8); PrimaryVariables values(0.0); values = initialAtPos(scvf.center()); const auto faceId = scvf.index(); - if (couplingInterface_.isCoupledEntity(faceId)) { + if (couplingParticipant_.isCoupledEntity(faceId)) { values[Indices::velocityYIdx] = - couplingInterface_.getScalarQuantityOnFace(velocityId_, faceId); + couplingParticipant_.getScalarQuantityOnFace( + meshNameView_, dataNameView_, faceId); } return values; @@ -251,11 +249,12 @@ public: const ElementFaceVariables &elemFaceVars, const SubControlVolumeFace &scvf) const { + precice::string_view meshNameView_("FreeFlowMesh", 12); + precice::string_view dataNameView_("Pressure", 8); NumEqVector values(0.0); - assert(dataIdsWereSet_); const auto faceId = scvf.index(); - if (couplingInterface_.isCoupledEntity(faceId)) { + if (couplingParticipant_.isCoupledEntity(faceId)) { const Scalar density = 1000; // TODO how to handle compressible fluids? values[Indices::conti0EqIdx] = density * @@ -263,8 +262,8 @@ public: scvf.directionSign(); values[Indices::momentumYBalanceIdx] = scvf.directionSign() * - (couplingInterface_.getScalarQuantityOnFace(pressureId_, - faceId) - + (couplingParticipant_.getScalarQuantityOnFace( + meshNameView_, dataNameView_, faceId) - initialAtPos(scvf.center())[Indices::pressureIdx]); } return values; @@ -363,13 +362,6 @@ public: return analyticalVelocityX_; } - void updatePreciceDataIds() - { - pressureId_ = couplingInterface_.getIdFromName("Pressure"); - velocityId_ = couplingInterface_.getIdFromName("Velocity"); - dataIdsWereSet_ = true; - } - // \} private: @@ -396,10 +388,7 @@ private: Scalar eps_; Scalar deltaP_; - Dumux::Precice::CouplingAdapter &couplingInterface_; - size_t pressureId_; - size_t velocityId_; - bool dataIdsWereSet_; + Dumux::Precice::CouplingAdapter &couplingParticipant_; mutable std::vector analyticalVelocityX_; }; diff --git a/examples/ff-pm/flow-over-square-2d/main_ff.cc b/examples/ff-pm/flow-over-square-2d/main_ff.cc index a719a1e..772bd4e 100644 --- a/examples/ff-pm/flow-over-square-2d/main_ff.cc +++ b/examples/ff-pm/flow-over-square-2d/main_ff.cc @@ -98,7 +98,9 @@ template void setInterfacePressures(const Problem &problem, const GridVariables &gridVars, - const SolutionVector &sol) + const SolutionVector &sol, + const precice::string_view meshNameView, + const precice::string_view dataNameView) { const auto &gridGeometry = problem.gridGeometry(); auto fvGeometry = localView(gridGeometry); @@ -106,8 +108,7 @@ void setInterfacePressures(const Problem &problem, auto elemFaceVars = localView(gridVars.curGridFaceVars()); auto elemFluxVarsCache = localView(gridVars.gridFluxVarsCache()); - auto &couplingInterface = Dumux::Precice::CouplingAdapter::getInstance(); - const auto pressureId = couplingInterface.getIdFromName("Pressure"); + auto &couplingParticipant = Dumux::Precice::CouplingAdapter::getInstance(); for (const auto &element : elements(gridGeometry.gridView())) { fvGeometry.bind(element); @@ -116,13 +117,13 @@ void setInterfacePressures(const Problem &problem, elemFluxVarsCache.bind(element, fvGeometry, elemVolVars); for (const auto &scvf : scvfs(fvGeometry)) { - if (couplingInterface.isCoupledEntity(scvf.index())) { + if (couplingParticipant.isCoupledEntity(scvf.index())) { //TODO: What to do here? const auto p = pressureAtInterface( problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, elemFluxVarsCache); - couplingInterface.writeScalarQuantityOnFace(pressureId, - scvf.index(), p); + couplingParticipant.writeScalarQuantityOnFace( + meshNameView, dataNameView, scvf.index(), p); } } } @@ -131,15 +132,16 @@ void setInterfacePressures(const Problem &problem, template void setInterfaceVelocities(const Problem &problem, const GridVariables &gridVars, - const SolutionVector &sol) + const SolutionVector &sol, + const precice::string_view meshNameView, + const precice::string_view dataNameView) { const auto &gridGeometry = problem.gridGeometry(); auto fvGeometry = localView(gridGeometry); auto elemVolVars = localView(gridVars.curGridVolVars()); auto elemFaceVars = localView(gridVars.curGridFaceVars()); - auto &couplingInterface = Dumux::Precice::CouplingAdapter::getInstance(); - const auto velocityId = couplingInterface.getIdFromName("Velocity"); + auto &couplingParticipant = Dumux::Precice::CouplingAdapter::getInstance(); for (const auto &element : elements(gridGeometry.gridView())) { fvGeometry.bindElement(element); @@ -147,12 +149,12 @@ void setInterfaceVelocities(const Problem &problem, elemFaceVars.bindElement(element, fvGeometry, sol); for (const auto &scvf : scvfs(fvGeometry)) { - if (couplingInterface.isCoupledEntity(scvf.index())) { + if (couplingParticipant.isCoupledEntity(scvf.index())) { //TODO: What to do here? const auto v = velocityAtInterface(elemFaceVars, scvf)[scvf.directionIndex()]; - couplingInterface.writeScalarQuantityOnFace(velocityId, - scvf.index(), v); + couplingParticipant.writeScalarQuantityOnFace( + meshNameView, dataNameView, scvf.index(), v); } } } @@ -211,18 +213,19 @@ try { // - Name of solver // - What rank of how many ranks this instance is // Configure preCICE. For now the config file is hardcoded. - //couplingInterface.createInstance( "FreeFlow", mpiHelper.rank(), mpiHelper.size() ); + //couplingParticipant.createInstance( "FreeFlow", mpiHelper.rank(), mpiHelper.size() ); std::string preciceConfigFilename = "precice-config.xml"; // if (argc == 3) // preciceConfigFilename = argv[2]; if (argc > 2) preciceConfigFilename = argv[argc - 1]; - auto &couplingInterface = Dumux::Precice::CouplingAdapter::getInstance(); - couplingInterface.announceSolver("FreeFlow", preciceConfigFilename, - mpiHelper.rank(), mpiHelper.size()); + auto &couplingParticipant = Dumux::Precice::CouplingAdapter::getInstance(); + couplingParticipant.announceSolver("FreeFlow", preciceConfigFilename, + mpiHelper.rank(), mpiHelper.size()); - const int dim = couplingInterface.getDimensions(); + const precice::string_view meshNameView("FreeFlowMesh", 12); // mesh name + const int dim = couplingParticipant.getMeshDimensions(meshNameView); std::cout << dim << " " << int(FreeFlowGridGeometry::GridView::dimension) << std::endl; if (dim != int(FreeFlowGridGeometry::GridView::dimension)) @@ -254,16 +257,14 @@ try { } const auto numberOfPoints = coords.size() / dim; - const double preciceDt = couplingInterface.setMeshAndInitialize( - "FreeFlowMesh", numberOfPoints, coords); - couplingInterface.createIndexMapping(coupledScvfIndices); + precice::span coordsSpan(coords); + couplingParticipant.setMesh(meshNameView, coordsSpan); + couplingParticipant.createIndexMapping(coupledScvfIndices); - const auto velocityId = - couplingInterface.announceScalarQuantity("Velocity"); - const auto pressureId = - couplingInterface.announceScalarQuantity("Pressure"); - - freeFlowProblem->updatePreciceDataIds(); + const precice::string_view dataNameViewV("Velocity", 8); + const precice::string_view dataNameViewP("Pressure", 8); + couplingParticipant.announceQuantity(meshNameView, dataNameViewV); + couplingParticipant.announceQuantity(meshNameView, dataNameViewP); // apply initial solution for instationary problems freeFlowProblem->applyInitialSolution(sol); @@ -287,13 +288,14 @@ try { using FluxVariables = GetPropType; - if (couplingInterface.hasToWriteInitialData()) { + if (couplingParticipant.requiresToWriteInitialData()) { setInterfacePressures(*freeFlowProblem, - *freeFlowGridVariables, sol); - couplingInterface.writeScalarQuantityToOtherSolver(pressureId); - couplingInterface.announceInitialDataWritten(); + *freeFlowGridVariables, sol, + meshNameView, dataNameViewP); + couplingParticipant.writeQuantityToOtherSolver(meshNameView, + dataNameViewP); } - couplingInterface.initializeData(); + couplingParticipant.initialize(); // the assembler for a stationary problem using Assembler = @@ -315,37 +317,40 @@ try { using NewtonSolver = NewtonSolver; NewtonSolver nonLinearSolver(assembler, linearSolver); + double preciceDt = couplingParticipant.getMaxTimeStepSize(); auto dt = preciceDt; auto sol_checkpoint = sol; double vtkTime = 1.0; size_t iter = 0; - while (couplingInterface.isCouplingOngoing()) { - if (couplingInterface.hasToWriteIterationCheckpoint()) { + while (couplingParticipant.isCouplingOngoing()) { + if (couplingParticipant.requiresToWriteCheckpoint()) { //DO CHECKPOINTING sol_checkpoint = sol; - couplingInterface.announceIterationCheckpointWritten(); } - couplingInterface.readScalarQuantityFromOtherSolver(velocityId); + couplingParticipant.readQuantityFromOtherSolver(meshNameView, + dataNameViewV, dt); // solve the non-linear system nonLinearSolver.solve(sol); // TODO setInterfacePressures(*freeFlowProblem, - *freeFlowGridVariables, sol); - couplingInterface.writeScalarQuantityToOtherSolver(pressureId); - + *freeFlowGridVariables, sol, + meshNameView, dataNameViewP); + couplingParticipant.writeQuantityToOtherSolver(meshNameView, + dataNameViewP); //Read checkpoint freeFlowVtkWriter.write(vtkTime); vtkTime += 1.; - const double preciceDt = couplingInterface.advance(dt); + couplingParticipant.advance(dt); + preciceDt = couplingParticipant.getMaxTimeStepSize(); dt = std::min(preciceDt, dt); ++iter; - if (couplingInterface.hasToReadIterationCheckpoint()) { + if (couplingParticipant.requiresToReadCheckpoint()) { // //Read checkpoint // freeFlowVtkWriter.write(vtkTime); // vtkTime += 1.; @@ -353,7 +358,6 @@ try { freeFlowGridVariables->update(sol); freeFlowGridVariables->advanceTimeStep(); //freeFlowGridVariables->init(sol); - couplingInterface.announceIterationCheckpointRead(); } else // coupling successful { // write vtk output @@ -364,7 +368,7 @@ try { // finalize, print dumux message to say goodbye //////////////////////////////////////////////////////////// - couplingInterface.finalize(); + couplingParticipant.finalize(); // print dumux end message if (mpiHelper.rank() == 0) { diff --git a/examples/ff-pm/flow-over-square-2d/main_pm.cc b/examples/ff-pm/flow-over-square-2d/main_pm.cc index 032b68d..938c82d 100644 --- a/examples/ff-pm/flow-over-square-2d/main_pm.cc +++ b/examples/ff-pm/flow-over-square-2d/main_pm.cc @@ -114,15 +114,16 @@ auto pressureAtInterface(const Problem &problem, template void setInterfacePressures(const Problem &problem, const GridVariables &gridVars, - const SolutionVector &sol) + const SolutionVector &sol, + const precice::string_view meshNameView, + const precice::string_view dataNameView) { const auto &gridGeometry = problem.gridGeometry(); auto fvGeometry = localView(gridGeometry); auto elemVolVars = localView(gridVars.curGridVolVars()); auto elemFluxVarsCache = localView(gridVars.gridFluxVarsCache()); - auto &couplingInterface = Dumux::Precice::CouplingAdapter::getInstance(); - const auto pressureId = couplingInterface.getIdFromName("Pressure"); + auto &couplingParticipant = Dumux::Precice::CouplingAdapter::getInstance(); for (const auto &element : elements(gridGeometry.gridView())) { fvGeometry.bindElement(element); @@ -130,13 +131,13 @@ void setInterfacePressures(const Problem &problem, //sstd::cout << "Pressure by reconstruction" << std::endl; for (const auto &scvf : scvfs(fvGeometry)) { - if (couplingInterface.isCoupledEntity(scvf.index())) { + if (couplingParticipant.isCoupledEntity(scvf.index())) { //TODO: What to do here? const double p = pressureAtInterface(problem, element, gridGeometry, elemVolVars, scvf, elemFluxVarsCache); - couplingInterface.writeScalarQuantityOnFace(pressureId, - scvf.index(), p); + couplingParticipant.writeScalarQuantityOnFace( + meshNameView, dataNameView, scvf.index(), p); } } } @@ -177,15 +178,16 @@ template void setInterfaceVelocities(const Problem &problem, const GridVariables &gridVars, - const SolutionVector &sol) + const SolutionVector &sol, + const precice::string_view meshNameView, + const precice::string_view dataNameView) { const auto &gridGeometry = problem.gridGeometry(); auto fvGeometry = localView(gridGeometry); auto elemVolVars = localView(gridVars.curGridVolVars()); auto elemFluxVarsCache = localView(gridVars.gridFluxVarsCache()); - auto &couplingInterface = Dumux::Precice::CouplingAdapter::getInstance(); - const auto velocityId = couplingInterface.getIdFromName("Velocity"); + auto &couplingParticipant = Dumux::Precice::CouplingAdapter::getInstance(); for (const auto &element : elements(gridGeometry.gridView())) { fvGeometry.bind(element); @@ -193,13 +195,13 @@ void setInterfaceVelocities(const Problem &problem, elemFluxVarsCache.bind(element, fvGeometry, elemVolVars); for (const auto &scvf : scvfs(fvGeometry)) { - if (couplingInterface.isCoupledEntity(scvf.index())) { + if (couplingParticipant.isCoupledEntity(scvf.index())) { //TODO: What to do here? const double v = velocityAtInterface( problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache); - couplingInterface.writeScalarQuantityOnFace(velocityId, - scvf.index(), v); + couplingParticipant.writeScalarQuantityOnFace( + meshNameView, dataNameView, scvf.index(), v); } } } @@ -250,18 +252,19 @@ try { // - Name of solver // - What rank of how many ranks this instance is // Configure preCICE. For now the config file is hardcoded. - //couplingInterface.createInstance( "darcy", mpiHelper.rank(), mpiHelper.size() ); + //couplingParticipant.createInstance( "darcy", mpiHelper.rank(), mpiHelper.size() ); std::string preciceConfigFilename = "precice-config.xml"; // if (argc == 3) // preciceConfigFilename = argv[2]; if (argc > 2) preciceConfigFilename = argv[argc - 1]; - auto &couplingInterface = Dumux::Precice::CouplingAdapter::getInstance(); - couplingInterface.announceSolver("Darcy", preciceConfigFilename, - mpiHelper.rank(), mpiHelper.size()); + auto &couplingParticipant = Dumux::Precice::CouplingAdapter::getInstance(); + couplingParticipant.announceSolver("Darcy", preciceConfigFilename, + mpiHelper.rank(), mpiHelper.size()); - const int dim = couplingInterface.getDimensions(); + const precice::string_view meshNameView("DarcyMesh", 9); + const int dim = couplingParticipant.getMeshDimensions(meshNameView); std::cout << dim << " " << int(DarcyGridGeometry::GridView::dimension) << std::endl; if (dim != int(DarcyGridGeometry::GridView::dimension)) @@ -293,16 +296,14 @@ try { } const auto numberOfPoints = coords.size() / dim; - const double preciceDt = couplingInterface.setMeshAndInitialize( - "DarcyMesh", numberOfPoints, coords); - couplingInterface.createIndexMapping(coupledScvfIndices); + precice::span coordsSpan(coords); + couplingParticipant.setMesh(meshNameView, coordsSpan); + couplingParticipant.createIndexMapping(coupledScvfIndices); - const auto velocityId = - couplingInterface.announceScalarQuantity("Velocity"); - const auto pressureId = - couplingInterface.announceScalarQuantity("Pressure"); - - darcyProblem->updatePreciceDataIds(); + const precice::string_view dataNameViewV("Velocity", 8); + const precice::string_view dataNameViewP("Pressure", 8); + couplingParticipant.announceQuantity(meshNameView, dataNameViewP); + couplingParticipant.announceQuantity(meshNameView, dataNameViewV); darcyProblem->applyInitialSolution(sol); @@ -329,25 +330,15 @@ try { darcyVtkWriter.write(0.0); using FluxVariables = GetPropType; - if (couplingInterface.hasToWriteInitialData()) { + if (couplingParticipant.requiresToWriteInitialData()) { //TODO setInterfaceVelocities(*darcyProblem, - *darcyGridVariables, sol); - // For testing - // { - // const auto v = couplingInterface.getQuantityVector(velocityId); - // std::cout << "velocities to be sent to ff" << std::endl; - // for (size_t i = 0; i < v.size(); ++i) { - // for (size_t d = 0; d < dim; ++d) { - // std::cout << coords[i * dim + d] << " "; - // } - // std::cout << "| v[" << i << "]=" << v[i] << std::endl; - // } - // } - couplingInterface.writeScalarQuantityToOtherSolver(velocityId); - couplingInterface.announceInitialDataWritten(); + *darcyGridVariables, sol, + meshNameView, dataNameViewV); + couplingParticipant.writeQuantityToOtherSolver(meshNameView, + dataNameViewV); } - couplingInterface.initializeData(); + couplingParticipant.initialize(); // the assembler for a stationary problem using Assembler = FVAssembler; @@ -368,41 +359,43 @@ try { using NewtonSolver = Dumux::NewtonSolver; NewtonSolver nonLinearSolver(assembler, linearSolver); + double preciceDt = couplingParticipant.getMaxTimeStepSize(); auto dt = preciceDt; auto sol_checkpoint = sol; double vtkTime = 1.0; size_t iter = 0; - while (couplingInterface.isCouplingOngoing()) { - if (couplingInterface.hasToWriteIterationCheckpoint()) { + while (couplingParticipant.isCouplingOngoing()) { + if (couplingParticipant.requiresToWriteCheckpoint()) { //DO CHECKPOINTING sol_checkpoint = sol; - couplingInterface.announceIterationCheckpointWritten(); } - couplingInterface.readScalarQuantityFromOtherSolver(pressureId); + couplingParticipant.readQuantityFromOtherSolver(meshNameView, + dataNameViewP, dt); // solve the non-linear system nonLinearSolver.solve(sol); setInterfaceVelocities(*darcyProblem, - *darcyGridVariables, sol); - couplingInterface.writeScalarQuantityToOtherSolver(velocityId); + *darcyGridVariables, sol, + meshNameView, dataNameViewV); + couplingParticipant.writeQuantityToOtherSolver(meshNameView, + dataNameViewV); - const double preciceDt = couplingInterface.advance(dt); + couplingParticipant.advance(dt); + preciceDt = couplingParticipant.getMaxTimeStepSize(); dt = std::min(preciceDt, dt); ++iter; - if (couplingInterface.hasToReadIterationCheckpoint()) { + if (couplingParticipant.requiresToReadCheckpoint()) { //Read checkpoint darcyVtkWriter.write(vtkTime); vtkTime += 1.; sol = sol_checkpoint; darcyGridVariables->update(sol); darcyGridVariables->advanceTimeStep(); - //darcyGridVariables->init(sol); - couplingInterface.announceIterationCheckpointRead(); } else // coupling successful { // write vtk output @@ -412,7 +405,7 @@ try { // write vtk output darcyVtkWriter.write(1.0); - couplingInterface.finalize(); + couplingParticipant.finalize(); //////////////////////////////////////////////////////////// // finalize, print dumux message to say goodbye diff --git a/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh b/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh index 81775b5..cfc59e0 100644 --- a/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh +++ b/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh @@ -122,10 +122,7 @@ public: DarcySubProblem(std::shared_ptr fvGridGeometry) : ParentType(fvGridGeometry, "Darcy"), eps_(1e-7), - couplingInterface_(Dumux::Precice::CouplingAdapter::getInstance()), - pressureId_(0), - velocityId_(0), - dataIdsWereSet_(false) + couplingParticipant_(Dumux::Precice::CouplingAdapter::getInstance()) { } @@ -167,7 +164,7 @@ public: values.setAllNeumann(); const auto faceId = scvf.index(); - if (couplingInterface_.isCoupledEntity(faceId)) + if (couplingParticipant_.isCoupledEntity(faceId)) values.setAllDirichlet(); return values; } @@ -183,16 +180,16 @@ public: PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const { + precice::string_view meshNameView_("DarcyMesh", 9); + precice::string_view dataNameView_("Pressure", 8); // set p = 0 at the bottom PrimaryVariables values(0.0); values = initial(element); const auto faceId = scvf.index(); - if (couplingInterface_.isCoupledEntity(faceId)) { - values = - couplingInterface_.getScalarQuantityOnFace(pressureId_, faceId); - //std::cout << "Pressure on face " << faceId << " is " << couplingInterface_.getScalarQuantityOnFace(pressureId_, faceId) << std::endl; - } + if (couplingParticipant_.isCoupledEntity(faceId)) + values = couplingParticipant_.getScalarQuantityOnFace( + meshNameView_, dataNameView_, faceId); return values; } @@ -262,13 +259,6 @@ public: // \} - void updatePreciceDataIds() - { - pressureId_ = couplingInterface_.getIdFromName("Pressure"); - velocityId_ = couplingInterface_.getIdFromName("Velocity"); - dataIdsWereSet_ = true; - } - private: bool onLeftBoundary_(const GlobalPosition &globalPos) const { @@ -292,10 +282,7 @@ private: Scalar eps_; - Dumux::Precice::CouplingAdapter &couplingInterface_; - size_t pressureId_; - size_t velocityId_; - bool dataIdsWereSet_; + Dumux::Precice::CouplingAdapter &couplingParticipant_; }; } // namespace Dumux diff --git a/examples/ff-pm/flow-over-square-2d/precice-config-pi.xml b/examples/ff-pm/flow-over-square-2d/precice-config-pi.xml index d72d2ad..853e4ae 100644 --- a/examples/ff-pm/flow-over-square-2d/precice-config-pi.xml +++ b/examples/ff-pm/flow-over-square-2d/precice-config-pi.xml @@ -6,79 +6,75 @@ - - - + + - - - - + + + + - - - - + + + + - - - + + + - - + + - - + + - + - - + + - - - + + + - + - - - - + + + + - - - + + + - - + + - - + + - + - + + + + + + + + + - - - - - - - - - - - - + diff --git a/examples/ff-pm/flow-over-square-2d/precice-config-si-free-flow-first.xml b/examples/ff-pm/flow-over-square-2d/precice-config-si-free-flow-first.xml index ad4fa10..54197b5 100644 --- a/examples/ff-pm/flow-over-square-2d/precice-config-si-free-flow-first.xml +++ b/examples/ff-pm/flow-over-square-2d/precice-config-si-free-flow-first.xml @@ -6,78 +6,74 @@ - - - + + - - - - + + + + - - - - + + + + - - - + + + - - + + - - + + - + - - + + - - - + + + - + - - - - + + + + - - - + + + - - + + - - + + - + - + + + + + + + + - - - - - - - - - - - + diff --git a/examples/ff-pm/flow-over-square-2d/precice-config-si-free-flow-second.xml b/examples/ff-pm/flow-over-square-2d/precice-config-si-free-flow-second.xml index 6e325f9..1d15bd7 100644 --- a/examples/ff-pm/flow-over-square-2d/precice-config-si-free-flow-second.xml +++ b/examples/ff-pm/flow-over-square-2d/precice-config-si-free-flow-second.xml @@ -6,78 +6,73 @@ - + + - - + + + + - - - - + + + + - - - - + + + - - - + + - - + + - - + - + + - - + + + - - - + - + + + + - - - - + + + - - - + + - - + + - - + - + + + + + + + + - - - - - - - - - - - - - + From 336b7bb2c1419332cd138a1a05666a82166d0fc6 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Mon, 11 Dec 2023 16:10:01 +0100 Subject: [PATCH 10/28] Remove unnecessary links from README --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index f6c7729..1aff4f0 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ![build and test develop](https://github.com/precice/dumux-adapter/actions/workflows/build-and-test.yml/badge.svg) ![build and test develop with DuMuX masters](https://github.com/precice/dumux-adapter/actions/workflows/build-and-test-dumux-master.yml/badge.svg) -This repository provides a [DuMuX](https://dumux.org/)-specific adapter to couple to other codes using [preCICE](https://www.precice.org/). You can find the source code of this adapter [on GitHub](https://github.com/precice/dumux-adapter). The source code of the adapter was formerly stored [in a repository on the IWS GitLab](https://git.iws.uni-stuttgart.de/dumux-appl/dumux-precice). +This repository provides a [DuMuX](https://dumux.org/)-specific adapter to couple to other codes using [preCICE](https://www.precice.org/). The source code of the adapter was formerly stored [in a repository on the IWS GitLab](https://git.iws.uni-stuttgart.de/dumux-appl/dumux-precice). ## Structure of the repository @@ -131,4 +131,3 @@ There is no publication related to this code available yet. ### Publications using dumux-precice - Jaust A., Weishaupt K., Mehl M., Flemisch B. (2020) Partitioned Coupling Schemes for Free-Flow and Porous-Media Applications with Sharp Interfaces. In: Klöfkorn R., Keilegavlen E., Radu F., Fuhrmann J. (eds) Finite Volumes for Complex Applications IX - Methods, Theoretical Aspects, Examples. FVCA 2020. Springer Proceedings in Mathematics & Statistics, vol 323. Springer, Cham. - - Code can be found at: From d60b1f4cede6d2f183639febb0038c0f243ecd31 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Tue, 19 Dec 2023 11:17:28 +0100 Subject: [PATCH 11/28] Remove old .gitlab folder (#29) --- .gitlab/issue_templates/template.md | 28 --------------------- .gitlab/merge_request_templates/template.md | 24 ------------------ 2 files changed, 52 deletions(-) delete mode 100644 .gitlab/issue_templates/template.md delete mode 100644 .gitlab/merge_request_templates/template.md diff --git a/.gitlab/issue_templates/template.md b/.gitlab/issue_templates/template.md deleted file mode 100644 index 79b7996..0000000 --- a/.gitlab/issue_templates/template.md +++ /dev/null @@ -1,28 +0,0 @@ -## Description - - - -### Environment - - - -## Steps to reproduce - - - -### Expected behavior - - - -### Actual behavior - - diff --git a/.gitlab/merge_request_templates/template.md b/.gitlab/merge_request_templates/template.md deleted file mode 100644 index 1bd4dd9..0000000 --- a/.gitlab/merge_request_templates/template.md +++ /dev/null @@ -1,24 +0,0 @@ -## Description - - - -## Checklist - - - -- [ ] I made sure that the source files are formatted properly. -- [ ] I added my changes to the changelog (`CHANGELOG.md`) -- [ ] I updated the documentation. - - - -- [ ] I added a test for the new feature. From b2e120f4975e353b4654ded3f8dede959576e964 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Tue, 19 Dec 2023 15:41:52 +0100 Subject: [PATCH 12/28] Revert to use standard library definitions in API functions and examples (#30) * Remove old .gitlab folder * Revert to using std::string and std::vector in adapter API functions * Correct mistake in std:vectpr * Formatting * Revert to using std::string and std:vector instead of precice:: * Use std::string instead of precice::string_view in the dummy solver * Update dumux-precice/couplingadapter.cc Co-authored-by: mathiskelm <114579716+mathiskelm@users.noreply.github.com> * Update examples/dummysolver/main_dummysolver.cc Co-authored-by: mathiskelm <114579716+mathiskelm@users.noreply.github.com> * Clean up dummy solver * Using the correct data types * Further simplifying variable definitions in examples * Formatting * Formatting * Update dumux-precice/couplingadapter.cc Co-authored-by: mathiskelm <114579716+mathiskelm@users.noreply.github.com> * Update dumux-precice/couplingadapter.hh Co-authored-by: mathiskelm <114579716+mathiskelm@users.noreply.github.com> * Update examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc Co-authored-by: mathiskelm <114579716+mathiskelm@users.noreply.github.com> * Update examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc Co-authored-by: mathiskelm <114579716+mathiskelm@users.noreply.github.com> * Removing last traces of _View variables from example codes * Use string literals in adapter API of the problem files (*.hh) --------- Co-authored-by: mathiskelm <114579716+mathiskelm@users.noreply.github.com> --- dumux-precice/couplingadapter.cc | 54 ++++++------- dumux-precice/couplingadapter.hh | 41 +++++----- examples/dummysolver/main_dummysolver.cc | 75 ++++++++----------- .../flow-over-cube-3d/ffproblem-reversed.hh | 8 +- .../flow-over-cube-3d/main_ff-reversed.cc | 62 +++++++-------- .../flow-over-cube-3d/main_pm-reversed.cc | 54 ++++++------- .../flow-over-cube-3d/pmproblem-reversed.hh | 4 +- .../flow-over-square-2d/ffproblem-reversed.hh | 8 +- examples/ff-pm/flow-over-square-2d/main_ff.cc | 48 ++++++------ examples/ff-pm/flow-over-square-2d/main_pm.cc | 48 ++++++------ .../flow-over-square-2d/pmproblem-reversed.hh | 4 +- 11 files changed, 176 insertions(+), 230 deletions(-) diff --git a/dumux-precice/couplingadapter.cc b/dumux-precice/couplingadapter.cc index e2db8c1..d8ed375 100644 --- a/dumux-precice/couplingadapter.cc +++ b/dumux-precice/couplingadapter.cc @@ -34,8 +34,8 @@ void CouplingAdapter::announceSolver(const std::string &name, wasCreated_ = true; } -void CouplingAdapter::announceQuantity(const precice::string_view &meshName, - const precice::string_view &dataName) +void CouplingAdapter::announceQuantity(const std::string &meshName, + const std::string &dataName) { assert(meshWasCreated_); const std::string key = meshAndDataKey(meshName, dataName); @@ -48,15 +48,14 @@ void CouplingAdapter::announceQuantity(const precice::string_view &meshName, dataMap_.insert(std::make_pair(key, dataValues)); } -int CouplingAdapter::getMeshDimensions( - const precice::string_view &meshName) const +int CouplingAdapter::getMeshDimensions(const std::string &meshName) const { assert(wasCreated_); return precice_->getMeshDimensions(meshName); } -void CouplingAdapter::setMesh(const precice::string_view &meshName, - precice::span positions) +void CouplingAdapter::setMesh(const std::string &meshName, + const std::vector &positions) { assert(wasCreated_); vertexIDs_ = @@ -118,10 +117,9 @@ size_t CouplingAdapter::getNumberOfVertices() return vertexIDs_.size(); } -double CouplingAdapter::getScalarQuantityOnFace( - const precice::string_view &meshName, - const precice::string_view &dataName, - const int faceID) +double CouplingAdapter::getScalarQuantityOnFace(const std::string &meshName, + const std::string &dataName, + const int faceID) { assert(wasCreated_); assert(hasIndexMapper_); @@ -136,11 +134,10 @@ double CouplingAdapter::getScalarQuantityOnFace( return dataVector[idx]; } -void CouplingAdapter::writeScalarQuantityOnFace( - const precice::string_view &meshName, - const precice::string_view &dataName, - const int faceID, - const double value) +void CouplingAdapter::writeScalarQuantityOnFace(const std::string &meshName, + const std::string &dataName, + const int faceID, + const double value) { assert(wasCreated_); assert(hasIndexMapper_); @@ -156,17 +153,17 @@ void CouplingAdapter::writeScalarQuantityOnFace( } std::vector &CouplingAdapter::getQuantityVector( - const precice::string_view &meshName, - const precice::string_view &dataName) + const std::string &meshName, + const std::string &dataName) { std::string key = meshAndDataKey(meshName, dataName); assert(dataMap_.find(key) != dataMap_.end()); return dataMap_[key]; } -void CouplingAdapter::writeQuantityVector(const precice::string_view &meshName, - const precice::string_view &dataName, - std::vector &values) +void CouplingAdapter::writeQuantityVector(const std::string &meshName, + const std::string &dataName, + const std::vector &values) { std::vector &dataVector = getQuantityVector(meshName, dataName); assert(dataVector.size() == values.size()); @@ -179,9 +176,8 @@ bool CouplingAdapter::isCoupledEntity(const int faceID) const return indexMapper_.isDumuxIdMapped(faceID); } -std::string CouplingAdapter::meshAndDataKey( - const precice::string_view &meshName, - const precice::string_view &dataName) const +std::string CouplingAdapter::meshAndDataKey(const std::string &meshName, + const std::string &dataName) const { assert(wasCreated_); std::string combinedKey; @@ -202,19 +198,17 @@ void CouplingAdapter::print(std::ostream &os) os << indexMapper_; } -void CouplingAdapter::readQuantityFromOtherSolver( - const precice::string_view &meshName, - const precice::string_view &dataName, - double relativeReadTime) +void CouplingAdapter::readQuantityFromOtherSolver(const std::string &meshName, + const std::string &dataName, + double relativeReadTime) { precice::span dataValuesSpan(getQuantityVector(meshName, dataName)); precice_->readData(meshName, dataName, vertexIDsSpan_, relativeReadTime, dataValuesSpan); } -void CouplingAdapter::writeQuantityToOtherSolver( - const precice::string_view &meshName, - const precice::string_view &dataName) +void CouplingAdapter::writeQuantityToOtherSolver(const std::string &meshName, + const std::string &dataName) { precice::span dataValuesSpan( getQuantityVector(meshName, dataName)); diff --git a/dumux-precice/couplingadapter.hh b/dumux-precice/couplingadapter.hh index 06c0630..7632cf9 100644 --- a/dumux-precice/couplingadapter.hh +++ b/dumux-precice/couplingadapter.hh @@ -95,15 +95,15 @@ public: * @param[in] meshName Name of the mesh. * @param[in] dataName Name of the data. */ - void announceQuantity(const precice::string_view &meshName, - const precice::string_view &dataName); + void announceQuantity(const std::string &meshName, + const std::string &dataName); /*! * @brief Get the number of spatial dimensions * * @param[in] meshName Name of the mesh * @return int Number of space dimensions. */ - int getMeshDimensions(const precice::string_view &meshName) const; + int getMeshDimensions(const std::string &meshName) const; /*! * @brief Get the maximum time step size from preCICE * @@ -147,8 +147,8 @@ public: * Example 3D:\n * [x_1, y_1, z_1, x_2, y_2, z_2,...x_numPoints, y_numPoints, z_numPoints] */ - void setMesh(const precice::string_view &meshName, - precice::span positions); + void setMesh(const std::string &meshName, + const std::vector &positions); /*! * @brief Initializes the coupling * @@ -201,8 +201,8 @@ public: * @param[in] dataName Name of the data. * @param[in] relativeReadTime The relative time tagged to the data to be read. */ - void readQuantityFromOtherSolver(const precice::string_view &meshName, - const precice::string_view &dataName, + void readQuantityFromOtherSolver(const std::string &meshName, + const std::string &dataName, double relativeReadTime); /*! * @brief Writes full block of data to preCICE. @@ -210,8 +210,8 @@ public: * @param[in] meshName Name of the mesh. * @param[in] dataName Name of the data. */ - void writeQuantityToOtherSolver(const precice::string_view &meshName, - const precice::string_view &dataName); + void writeQuantityToOtherSolver(const std::string &meshName, + const std::string &dataName); /*! * @brief Gets value of a scalar quantity on a finite volume face. * @@ -220,8 +220,8 @@ public: * @param[in] faceID Identifier of the face according to DuMuX' numbering. * @return double Value of scalar quantity. */ - double getScalarQuantityOnFace(const precice::string_view &meshName, - const precice::string_view &dataName, + double getScalarQuantityOnFace(const std::string &meshName, + const std::string &dataName, const int faceID); /*! * @brief Writes value of scalar quantity on a given finite volume face to data map. @@ -231,8 +231,8 @@ public: * @param[in] faceID Identifier of the face according to DuMuX' numbering. * @param[in] value Value of scalar quantity. */ - void writeScalarQuantityOnFace(const precice::string_view &meshName, - const precice::string_view &dataName, + void writeScalarQuantityOnFace(const std::string &meshName, + const std::string &dataName, const int faceID, const double value); /*! @@ -242,9 +242,8 @@ public: * @param[in] dataName Name of the data. * @return The value vector of the quantity. */ - std::vector &getQuantityVector( - const precice::string_view &meshName, - const precice::string_view &dataName); + std::vector &getQuantityVector(const std::string &meshName, + const std::string &dataName); /*! * @brief Writes the quantity value vector into the data map. * @@ -252,9 +251,9 @@ public: * @param[in] dataName Name of the data. * @param[in] values Value of the scalar or vector quantity. */ - void writeQuantityVector(const precice::string_view &meshName, - const precice::string_view &dataName, - std::vector &values); + void writeQuantityVector(const std::string &meshName, + const std::string &dataName, + const std::vector &values); /*! * @brief Checks whether face with given identifier is part of coupling interface. * @@ -270,8 +269,8 @@ public: * @param[in] dataName Name of the quantity. * @return size_t Numeric identifier of quantity. */ - std::string meshAndDataKey(const precice::string_view &meshName, - const precice::string_view &dataName) const; + std::string meshAndDataKey(const std::string &meshName, + const std::string &dataName) const; /*! * @brief Prints status of coupling adapter to given output stream. * diff --git a/examples/dummysolver/main_dummysolver.cc b/examples/dummysolver/main_dummysolver.cc index a2ff0ff..e3e8dbc 100644 --- a/examples/dummysolver/main_dummysolver.cc +++ b/examples/dummysolver/main_dummysolver.cc @@ -42,7 +42,6 @@ try { getParamFromGroup("preCICE", "ConfigFileName"); const std::string meshName = getParamFromGroup("preCICE", "MeshName"); - const precice::string_view meshNameView(meshName); auto &couplingParticipant = Dumux::Precice::CouplingAdapter::getInstance(); couplingParticipant.announceSolver(solverName, preciceConfigFilename, @@ -52,16 +51,16 @@ try { << preciceConfigFilename << "\", participant name \"" << solverName << "\", and mesh name \"" << meshName << "\".\n"; - const int dimensions = couplingParticipant.getMeshDimensions(meshNameView); + const int dimensions = couplingParticipant.getMeshDimensions(meshName); assert(dimensions == 3); - const precice::string_view scalarDataWriteName = std::string( - (solverName == "SolverOne") ? "scalarDataOne" : "scalarDataTwo"); - const precice::string_view scalarDataReadName = std::string( - (solverName == "SolverOne") ? "scalarDataTwo" : "scalarDataOne"); - const precice::string_view vectorDataWriteName = std::string( - (solverName == "SolverOne") ? "vectorDataOne" : "vectorDataTwo"); - const precice::string_view vectorDataReadName = std::string( - (solverName == "SolverOne") ? "vectorDataTwo" : "vectorDataOne"); + const std::string scalarDataWriteName = + (solverName == "SolverOne") ? "scalarDataOne" : "scalarDataTwo"; + const std::string scalarDataReadName = + (solverName == "SolverOne") ? "scalarDataTwo" : "scalarDataOne"; + const std::string vectorDataWriteName = + (solverName == "SolverOne") ? "vectorDataOne" : "vectorDataTwo"; + const std::string vectorDataReadName = + (solverName == "SolverOne") ? "vectorDataTwo" : "vectorDataOne"; const int numberOfVertices = 3; @@ -82,35 +81,29 @@ try { } } - precice::span writeScalarDataSpan(writeScalarData); - precice::span readScalarDataSpan(readScalarData); - precice::span writeVectorDataSpan(writeVectorData); - precice::span readVectorDataSpan(readVectorData); - precice::span dumuxVertexIDsSpan(dumuxVertexIDs); - std::cout << "DUMMY (" << mpiHelper.rank() << "): Initialize preCICE and set mesh\n"; - couplingParticipant.setMesh(meshNameView, vertices); + couplingParticipant.setMesh(meshName, vertices); // Create index mapping between DuMuX's index numbering and preCICE's numbering std::cout << "DUMMY (" << mpiHelper.rank() << "): Create index mapping\n"; couplingParticipant.createIndexMapping(dumuxVertexIDs); - couplingParticipant.announceQuantity(meshNameView, scalarDataWriteName); - couplingParticipant.announceQuantity(meshNameView, scalarDataReadName); - couplingParticipant.announceQuantity(meshNameView, vectorDataWriteName); - couplingParticipant.announceQuantity(meshNameView, vectorDataReadName); + couplingParticipant.announceQuantity(meshName, scalarDataWriteName); + couplingParticipant.announceQuantity(meshName, scalarDataReadName); + couplingParticipant.announceQuantity(meshName, vectorDataWriteName); + couplingParticipant.announceQuantity(meshName, vectorDataReadName); if (couplingParticipant.requiresToWriteInitialData()) { std::cout << "DUMMY (" << mpiHelper.rank() << "): Writing initial data\n"; - couplingParticipant.writeQuantityVector( - meshNameView, scalarDataWriteName, writeScalarData); - couplingParticipant.writeQuantityToOtherSolver(meshNameView, + couplingParticipant.writeQuantityVector(meshName, scalarDataWriteName, + writeScalarData); + couplingParticipant.writeQuantityToOtherSolver(meshName, scalarDataWriteName); - couplingParticipant.writeQuantityVector( - meshNameView, vectorDataWriteName, writeVectorData); - couplingParticipant.writeQuantityToOtherSolver(meshNameView, + couplingParticipant.writeQuantityVector(meshName, vectorDataWriteName, + writeVectorData); + couplingParticipant.writeQuantityToOtherSolver(meshName, vectorDataWriteName); } std::cout << "DUMMY (" << mpiHelper.rank() << "): Exchange initial\n"; @@ -122,13 +115,12 @@ try { std::cout << "DUMMY (" << mpiHelper.rank() << "): Reading initial data\n"; couplingParticipant.readQuantityFromOtherSolver( - meshNameView, scalarDataReadName, preciceDt); + meshName, scalarDataReadName, preciceDt); couplingParticipant.readQuantityFromOtherSolver( - meshNameView, vectorDataReadName, preciceDt); + meshName, vectorDataReadName, preciceDt); const std::vector &readScalarQuantity = - couplingParticipant.getQuantityVector(meshNameView, - scalarDataReadName); + couplingParticipant.getQuantityVector(meshName, scalarDataReadName); std::cout << "DUMMY (" << mpiHelper.rank() << "): Scalar data\n"; for (const double &value : readScalarQuantity) @@ -136,8 +128,7 @@ try { std::cout << "\n"; const std::vector &readVectorQuantity = - couplingParticipant.getQuantityVector(meshNameView, - vectorDataReadName); + couplingParticipant.getQuantityVector(meshName, vectorDataReadName); std::cout << "DUMMY (" << mpiHelper.rank() << "): Vector data\n"; for (const double &value : readVectorQuantity) @@ -181,19 +172,19 @@ try { //Read data std::cout << "DUMMY (" << mpiHelper.rank() << "): Reading data\n"; couplingParticipant.readQuantityFromOtherSolver( - meshNameView, scalarDataReadName, preciceDt); + meshName, scalarDataReadName, preciceDt); couplingParticipant.readQuantityFromOtherSolver( - meshNameView, vectorDataReadName, preciceDt); + meshName, vectorDataReadName, preciceDt); // Check data if (iter > 0) { int offset = (solverName == "SolverOne") ? 0 : 1; const std::vector &readScalarQuantity = - couplingParticipant.getQuantityVector(meshNameView, + couplingParticipant.getQuantityVector(meshName, scalarDataReadName); const std::vector &readVectorQuantity = - couplingParticipant.getQuantityVector(meshNameView, + couplingParticipant.getQuantityVector(meshName, vectorDataReadName); for (int i = 0; i < numberOfVertices; i++) { @@ -240,15 +231,15 @@ try { for (int i = 0; i < numberOfVertices; i++) { const double value = i + iter; couplingParticipant.writeScalarQuantityOnFace( - meshNameView, scalarDataWriteName, dumuxVertexIDs[i], value); + meshName, scalarDataWriteName, dumuxVertexIDs[i], value); } - couplingParticipant.writeQuantityToOtherSolver(meshNameView, + couplingParticipant.writeQuantityToOtherSolver(meshName, scalarDataWriteName); // Write vector data - couplingParticipant.writeQuantityVector( - meshNameView, vectorDataWriteName, writeVectorData); - couplingParticipant.writeQuantityToOtherSolver(meshNameView, + couplingParticipant.writeQuantityVector(meshName, vectorDataWriteName, + writeVectorData); + couplingParticipant.writeQuantityToOtherSolver(meshName, vectorDataWriteName); preciceDt = couplingParticipant.getMaxTimeStepSize(); couplingParticipant.advance(preciceDt); diff --git a/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh b/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh index e27412b..df1bce4 100644 --- a/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh +++ b/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh @@ -219,8 +219,6 @@ public: PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const { - precice::string_view meshNameView_("FreeFlowMesh", 12); - precice::string_view dataNameView_("Velocity", 8); PrimaryVariables values(0.0); values = initialAtPos(scvf.center()); @@ -228,7 +226,7 @@ public: if (couplingParticipant_.isCoupledEntity(faceId)) { values[Indices::velocityYIdx] = couplingParticipant_.getScalarQuantityOnFace( - meshNameView_, dataNameView_, faceId); + "FreeFlowMesh", "Velocity", faceId); } return values; @@ -250,8 +248,6 @@ public: const ElementFaceVariables &elemFaceVars, const SubControlVolumeFace &scvf) const { - precice::string_view meshNameView_("FreeFlowMesh", 12); - precice::string_view dataNameView_("Pressure", 8); NumEqVector values(0.0); const auto faceId = scvf.index(); @@ -264,7 +260,7 @@ public: values[Indices::momentumYBalanceIdx] = scvf.directionSign() * (couplingParticipant_.getScalarQuantityOnFace( - meshNameView_, dataNameView_, faceId) - + "FreeFlowMesh", "Pressure", faceId) - initialAtPos(scvf.center())[Indices::pressureIdx]); } return values; diff --git a/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc b/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc index f532b6b..fcab969 100644 --- a/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc +++ b/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc @@ -99,8 +99,8 @@ template void setInterfaceVelocities(const Problem &problem, const GridVariables &gridVars, const SolutionVector &sol, - const precice::string_view meshNameView, - const precice::string_view dataNameView) + const std::string meshName, + const std::string dataName) { const auto &gridGeometry = problem.gridGeometry(); auto fvGeometry = localView(gridGeometry); @@ -154,7 +154,7 @@ void setInterfaceVelocities(const Problem &problem, const auto v = velocityAtInterface(elemFaceVars, scvf)[scvf.directionIndex()]; couplingParticipant.writeScalarQuantityOnFace( - meshNameView, dataNameView, scvf.index(), v); + meshName, dataName, scvf.index(), v); } } } @@ -162,7 +162,7 @@ void setInterfaceVelocities(const Problem &problem, template std::tuple writeVelocitiesOnInterfaceToFile( - const precice::string_view &meshNameView, + const std::string &meshName, const std::string &filename, const Problem &problem, const GridVariables &gridVars, @@ -179,7 +179,7 @@ std::tuple writeVelocitiesOnInterfaceToFile( std::ofstream ofs(filename + ".csv", std::ofstream::out | std::ofstream::trunc); ofs << "x,y,"; - if (couplingParticipant.getMeshDimensions(meshNameView) == 3) + if (couplingParticipant.getMeshDimensions(meshName) == 3) ofs << "z,"; ofs << "velocityY" << "\n"; @@ -196,8 +196,7 @@ std::tuple writeVelocitiesOnInterfaceToFile( if (couplingParticipant.isCoupledEntity(scvf.index())) { const auto &pos = scvf.center(); for (int i = 0; - i < couplingParticipant.getMeshDimensions(meshNameView); - ++i) { + i < couplingParticipant.getMeshDimensions(meshName); ++i) { ofs << pos[i] << ","; } const double v = problem.dirichlet(element, scvf)[1]; @@ -223,7 +222,7 @@ template -void writePressuresOnInterfaceToFile(const precice::string_view &meshNameView, +void writePressuresOnInterfaceToFile(const std::string &meshName, const std::string &filename, const Problem &problem, const GridVariables &gridVars, @@ -241,7 +240,7 @@ void writePressuresOnInterfaceToFile(const precice::string_view &meshNameView, std::ofstream ofs(filename + ".csv", std::ofstream::out | std::ofstream::trunc); ofs << "x,y,"; - if (couplingParticipant.getMeshDimensions(meshNameView) == 3) + if (couplingParticipant.getMeshDimensions(meshName) == 3) ofs << "z,"; ofs << "pressure" << "\n"; @@ -255,8 +254,7 @@ void writePressuresOnInterfaceToFile(const precice::string_view &meshNameView, if (couplingParticipant.isCoupledEntity(scvf.index())) { const auto &pos = scvf.center(); for (int i = 0; - i < couplingParticipant.getMeshDimensions(meshNameView); - ++i) { + i < couplingParticipant.getMeshDimensions(meshName); ++i) { ofs << pos[i] << ","; } const double p = pressureAtInterface( @@ -334,8 +332,8 @@ try { couplingParticipant.announceSolver("FreeFlow", preciceConfigFilename, mpiHelper.rank(), mpiHelper.size()); - const precice::string_view meshNameView("FreeFlowMesh", 12); - const int dim = couplingParticipant.getMeshDimensions(meshNameView); + const std::string meshName("FreeFlowMesh"); + const int dim = couplingParticipant.getMeshDimensions(meshName); std::cout << dim << " " << int(FreeFlowGridGeometry::GridView::dimension) << std::endl; if (dim != int(FreeFlowGridGeometry::GridView::dimension)) @@ -366,15 +364,13 @@ try { } } - const auto numberOfPoints = coords.size() / dim; - precice::span coordsSpan(coords); - couplingParticipant.setMesh(meshNameView, coordsSpan); + couplingParticipant.setMesh(meshName, coords); couplingParticipant.createIndexMapping(coupledScvfIndices); - const precice::string_view dataNameViewV("Velocity", 8); - const precice::string_view dataNameViewP("Pressure", 8); - couplingParticipant.announceQuantity(meshNameView, dataNameViewV); - couplingParticipant.announceQuantity(meshNameView, dataNameViewP); + const std::string dataNameV("Velocity"); + const std::string dataNameP("Pressure"); + couplingParticipant.announceQuantity(meshName, dataNameV); + couplingParticipant.announceQuantity(meshName, dataNameP); // apply initial solution for instationary problems freeFlowProblem->applyInitialSolution(sol); @@ -399,11 +395,9 @@ try { GetPropType; if (couplingParticipant.requiresToWriteInitialData()) { - setInterfacePressures(*freeFlowProblem, - *freeFlowGridVariables, sol, - meshNameView, dataNameViewP); - couplingParticipant.writeQuantityToOtherSolver(meshNameView, - dataNameViewP); + setInterfacePressures( + *freeFlowProblem, *freeFlowGridVariables, sol, meshName, dataNameP); + couplingParticipant.writeQuantityToOtherSolver(meshName, dataNameP); } couplingParticipant.initialize(); @@ -440,17 +434,15 @@ try { sol_checkpoint = sol; } - couplingParticipant.readQuantityFromOtherSolver(meshNameView, - dataNameViewV, dt); + couplingParticipant.readQuantityFromOtherSolver(meshName, dataNameV, + dt); // solve the non-linear system nonLinearSolver.solve(sol); // TODO - setInterfacePressures(*freeFlowProblem, - *freeFlowGridVariables, sol, - meshNameView, dataNameViewP); - couplingParticipant.writeQuantityToOtherSolver(meshNameView, - dataNameViewP); + setInterfacePressures( + *freeFlowProblem, *freeFlowGridVariables, sol, meshName, dataNameP); + couplingParticipant.writeQuantityToOtherSolver(meshName, dataNameP); //Read checkpoint freeFlowVtkWriter.write(vtkTime); vtkTime += 1.; diff --git a/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc b/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc index e62552f..cb49357 100644 --- a/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc +++ b/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc @@ -115,8 +115,8 @@ template void setInterfacePressures(const Problem &problem, const GridVariables &gridVars, const SolutionVector &sol, - const precice::string_view meshNameView, - const precice::string_view dataNameView) + const std::string meshName, + const std::string dataName) { const auto &gridGeometry = problem.gridGeometry(); auto fvGeometry = localView(gridGeometry); @@ -137,7 +137,7 @@ void setInterfacePressures(const Problem &problem, pressureAtInterface(problem, element, gridGeometry, elemVolVars, scvf, elemFluxVarsCache); couplingParticipant.writeScalarQuantityOnFace( - meshNameView, dataNameView, scvf.index(), p); + meshName, dataName, scvf.index(), p); } } } @@ -179,8 +179,8 @@ template std::tuple writeVelocitiesOnInterfaceToFile( - const precice::string_view &meshName, + const std::string &meshName, const std::string &filename, const Problem &problem, const GridVariables &gridVars, @@ -269,8 +269,8 @@ std::tuple writeVelocitiesOnInterfaceToFile( } template -void writePressuresOnInterfaceToFile(const precice::string_view &meshName, - std::string &filename, +void writePressuresOnInterfaceToFile(const std::string &meshName, + const std::string &filename, const Problem &problem, const GridVariables &gridVars, const SolutionVector &sol) @@ -369,8 +369,8 @@ try { couplingParticipant.announceSolver("Darcy", preciceConfigFilename, mpiHelper.rank(), mpiHelper.size()); - const precice::string_view meshNameView("DarcyMesh", 9); - const int dim = couplingParticipant.getMeshDimensions(meshNameView); + const std::string meshName("DarcyMesh"); + const int dim = couplingParticipant.getMeshDimensions(meshName); std::cout << dim << " " << int(DarcyGridGeometry::GridView::dimension) << std::endl; if (dim != int(DarcyGridGeometry::GridView::dimension)) @@ -401,15 +401,13 @@ try { } } - const auto numberOfPoints = coords.size() / dim; - precice::span coordsSpan(coords); - couplingParticipant.setMesh(meshNameView, coordsSpan); + couplingParticipant.setMesh(meshName, coords); couplingParticipant.createIndexMapping(coupledScvfIndices); - const precice::string_view dataNameViewV("Velocity", 8); - const precice::string_view dataNameViewP("Pressure", 8); - couplingParticipant.announceQuantity(meshNameView, dataNameViewP); - couplingParticipant.announceQuantity(meshNameView, dataNameViewV); + const std::string dataNameV("Velocity"); + const std::string dataNameP("Pressure"); + couplingParticipant.announceQuantity(meshName, dataNameP); + couplingParticipant.announceQuantity(meshName, dataNameV); darcyProblem->applyInitialSolution(sol); @@ -438,11 +436,9 @@ try { using FluxVariables = GetPropType; if (couplingParticipant.requiresToWriteInitialData()) { //TODO - setInterfaceVelocities(*darcyProblem, - *darcyGridVariables, sol, - meshNameView, dataNameViewV); - couplingParticipant.writeQuantityToOtherSolver(meshNameView, - dataNameViewV); + setInterfaceVelocities( + *darcyProblem, *darcyGridVariables, sol, meshName, dataNameV); + couplingParticipant.writeQuantityToOtherSolver(meshName, dataNameV); } couplingParticipant.initialize(); @@ -478,16 +474,14 @@ try { sol_checkpoint = sol; } - couplingParticipant.readQuantityFromOtherSolver(meshNameView, - dataNameViewP, dt); + couplingParticipant.readQuantityFromOtherSolver(meshName, dataNameP, + dt); // solve the non-linear system nonLinearSolver.solve(sol); - setInterfaceVelocities(*darcyProblem, - *darcyGridVariables, sol, - meshNameView, dataNameViewV); - couplingParticipant.writeQuantityToOtherSolver(meshNameView, - dataNameViewV); + setInterfaceVelocities( + *darcyProblem, *darcyGridVariables, sol, meshName, dataNameV); + couplingParticipant.writeQuantityToOtherSolver(meshName, dataNameV); couplingParticipant.advance(dt); preciceDt = couplingParticipant.getMaxTimeStepSize(); diff --git a/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh b/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh index 21d1c0b..4413b36 100644 --- a/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh +++ b/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh @@ -181,8 +181,6 @@ public: PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const { - precice::string_view meshNameView_("DarcyMesh", 9); - precice::string_view dataNameView_("Pressure", 8); // set p = 0 at the bottom PrimaryVariables values(0.0); values = initial(element); @@ -190,7 +188,7 @@ public: const auto faceId = scvf.index(); if (couplingParticipant_.isCoupledEntity(faceId)) values = couplingParticipant_.getScalarQuantityOnFace( - meshNameView_, dataNameView_, faceId); + "DarcyMesh", "Pressure", faceId); return values; } diff --git a/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh b/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh index 14540f2..4d6109e 100644 --- a/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh +++ b/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh @@ -218,8 +218,6 @@ public: PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const { - precice::string_view meshNameView_("FreeFlowMesh", 12); - precice::string_view dataNameView_("Velocity", 8); PrimaryVariables values(0.0); values = initialAtPos(scvf.center()); @@ -227,7 +225,7 @@ public: if (couplingParticipant_.isCoupledEntity(faceId)) { values[Indices::velocityYIdx] = couplingParticipant_.getScalarQuantityOnFace( - meshNameView_, dataNameView_, faceId); + "FreeFlowMesh", "Velocity", faceId); } return values; @@ -249,8 +247,6 @@ public: const ElementFaceVariables &elemFaceVars, const SubControlVolumeFace &scvf) const { - precice::string_view meshNameView_("FreeFlowMesh", 12); - precice::string_view dataNameView_("Pressure", 8); NumEqVector values(0.0); const auto faceId = scvf.index(); @@ -263,7 +259,7 @@ public: values[Indices::momentumYBalanceIdx] = scvf.directionSign() * (couplingParticipant_.getScalarQuantityOnFace( - meshNameView_, dataNameView_, faceId) - + "FreeFlowMesh", "Pressure", faceId) - initialAtPos(scvf.center())[Indices::pressureIdx]); } return values; diff --git a/examples/ff-pm/flow-over-square-2d/main_ff.cc b/examples/ff-pm/flow-over-square-2d/main_ff.cc index 772bd4e..7d72f90 100644 --- a/examples/ff-pm/flow-over-square-2d/main_ff.cc +++ b/examples/ff-pm/flow-over-square-2d/main_ff.cc @@ -99,8 +99,8 @@ template void setInterfaceVelocities(const Problem &problem, const GridVariables &gridVars, const SolutionVector &sol, - const precice::string_view meshNameView, - const precice::string_view dataNameView) + const std::string meshName, + const std::string dataName) { const auto &gridGeometry = problem.gridGeometry(); auto fvGeometry = localView(gridGeometry); @@ -154,7 +154,7 @@ void setInterfaceVelocities(const Problem &problem, const auto v = velocityAtInterface(elemFaceVars, scvf)[scvf.directionIndex()]; couplingParticipant.writeScalarQuantityOnFace( - meshNameView, dataNameView, scvf.index(), v); + meshName, dataName, scvf.index(), v); } } } @@ -224,8 +224,8 @@ try { couplingParticipant.announceSolver("FreeFlow", preciceConfigFilename, mpiHelper.rank(), mpiHelper.size()); - const precice::string_view meshNameView("FreeFlowMesh", 12); // mesh name - const int dim = couplingParticipant.getMeshDimensions(meshNameView); + const std::string meshName("FreeFlowMesh"); // mesh name + const int dim = couplingParticipant.getMeshDimensions(meshName); std::cout << dim << " " << int(FreeFlowGridGeometry::GridView::dimension) << std::endl; if (dim != int(FreeFlowGridGeometry::GridView::dimension)) @@ -256,15 +256,13 @@ try { } } - const auto numberOfPoints = coords.size() / dim; - precice::span coordsSpan(coords); - couplingParticipant.setMesh(meshNameView, coordsSpan); + couplingParticipant.setMesh(meshName, coords); couplingParticipant.createIndexMapping(coupledScvfIndices); - const precice::string_view dataNameViewV("Velocity", 8); - const precice::string_view dataNameViewP("Pressure", 8); - couplingParticipant.announceQuantity(meshNameView, dataNameViewV); - couplingParticipant.announceQuantity(meshNameView, dataNameViewP); + const std::string dataNameV("Velocity"); + const std::string dataNameP("Pressure"); + couplingParticipant.announceQuantity(meshName, dataNameV); + couplingParticipant.announceQuantity(meshName, dataNameP); // apply initial solution for instationary problems freeFlowProblem->applyInitialSolution(sol); @@ -289,11 +287,9 @@ try { GetPropType; if (couplingParticipant.requiresToWriteInitialData()) { - setInterfacePressures(*freeFlowProblem, - *freeFlowGridVariables, sol, - meshNameView, dataNameViewP); - couplingParticipant.writeQuantityToOtherSolver(meshNameView, - dataNameViewP); + setInterfacePressures( + *freeFlowProblem, *freeFlowGridVariables, sol, meshName, dataNameP); + couplingParticipant.writeQuantityToOtherSolver(meshName, dataNameP); } couplingParticipant.initialize(); @@ -330,17 +326,15 @@ try { sol_checkpoint = sol; } - couplingParticipant.readQuantityFromOtherSolver(meshNameView, - dataNameViewV, dt); + couplingParticipant.readQuantityFromOtherSolver(meshName, dataNameV, + dt); // solve the non-linear system nonLinearSolver.solve(sol); // TODO - setInterfacePressures(*freeFlowProblem, - *freeFlowGridVariables, sol, - meshNameView, dataNameViewP); - couplingParticipant.writeQuantityToOtherSolver(meshNameView, - dataNameViewP); + setInterfacePressures( + *freeFlowProblem, *freeFlowGridVariables, sol, meshName, dataNameP); + couplingParticipant.writeQuantityToOtherSolver(meshName, dataNameP); //Read checkpoint freeFlowVtkWriter.write(vtkTime); vtkTime += 1.; diff --git a/examples/ff-pm/flow-over-square-2d/main_pm.cc b/examples/ff-pm/flow-over-square-2d/main_pm.cc index 938c82d..29b37cd 100644 --- a/examples/ff-pm/flow-over-square-2d/main_pm.cc +++ b/examples/ff-pm/flow-over-square-2d/main_pm.cc @@ -115,8 +115,8 @@ template void setInterfacePressures(const Problem &problem, const GridVariables &gridVars, const SolutionVector &sol, - const precice::string_view meshNameView, - const precice::string_view dataNameView) + const std::string meshName, + const std::string dataName) { const auto &gridGeometry = problem.gridGeometry(); auto fvGeometry = localView(gridGeometry); @@ -137,7 +137,7 @@ void setInterfacePressures(const Problem &problem, pressureAtInterface(problem, element, gridGeometry, elemVolVars, scvf, elemFluxVarsCache); couplingParticipant.writeScalarQuantityOnFace( - meshNameView, dataNameView, scvf.index(), p); + meshName, dataName, scvf.index(), p); } } } @@ -179,8 +179,8 @@ template coordsSpan(coords); - couplingParticipant.setMesh(meshNameView, coordsSpan); + couplingParticipant.setMesh(meshName, coords); couplingParticipant.createIndexMapping(coupledScvfIndices); - const precice::string_view dataNameViewV("Velocity", 8); - const precice::string_view dataNameViewP("Pressure", 8); - couplingParticipant.announceQuantity(meshNameView, dataNameViewP); - couplingParticipant.announceQuantity(meshNameView, dataNameViewV); + const std::string dataNameV("Velocity"); + const std::string dataNameP("Pressure"); + couplingParticipant.announceQuantity(meshName, dataNameP); + couplingParticipant.announceQuantity(meshName, dataNameV); darcyProblem->applyInitialSolution(sol); @@ -332,11 +330,9 @@ try { using FluxVariables = GetPropType; if (couplingParticipant.requiresToWriteInitialData()) { //TODO - setInterfaceVelocities(*darcyProblem, - *darcyGridVariables, sol, - meshNameView, dataNameViewV); - couplingParticipant.writeQuantityToOtherSolver(meshNameView, - dataNameViewV); + setInterfaceVelocities( + *darcyProblem, *darcyGridVariables, sol, meshName, dataNameV); + couplingParticipant.writeQuantityToOtherSolver(meshName, dataNameV); } couplingParticipant.initialize(); @@ -372,16 +368,14 @@ try { sol_checkpoint = sol; } - couplingParticipant.readQuantityFromOtherSolver(meshNameView, - dataNameViewP, dt); + couplingParticipant.readQuantityFromOtherSolver(meshName, dataNameP, + dt); // solve the non-linear system nonLinearSolver.solve(sol); - setInterfaceVelocities(*darcyProblem, - *darcyGridVariables, sol, - meshNameView, dataNameViewV); - couplingParticipant.writeQuantityToOtherSolver(meshNameView, - dataNameViewV); + setInterfaceVelocities( + *darcyProblem, *darcyGridVariables, sol, meshName, dataNameV); + couplingParticipant.writeQuantityToOtherSolver(meshName, dataNameV); couplingParticipant.advance(dt); preciceDt = couplingParticipant.getMaxTimeStepSize(); diff --git a/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh b/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh index cfc59e0..e21868a 100644 --- a/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh +++ b/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh @@ -180,8 +180,6 @@ public: PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const { - precice::string_view meshNameView_("DarcyMesh", 9); - precice::string_view dataNameView_("Pressure", 8); // set p = 0 at the bottom PrimaryVariables values(0.0); values = initial(element); @@ -189,7 +187,7 @@ public: const auto faceId = scvf.index(); if (couplingParticipant_.isCoupledEntity(faceId)) values = couplingParticipant_.getScalarQuantityOnFace( - meshNameView_, dataNameView_, faceId); + "DarcyMesh", "Pressure", faceId); return values; } From 03334a02fecc9a35345c5d0a031bc32663fb7369 Mon Sep 17 00:00:00 2001 From: mathiskelm <114579716+mathiskelm@users.noreply.github.com> Date: Wed, 20 Dec 2023 16:51:55 +0100 Subject: [PATCH 13/28] Use dune_enable_all_packages to export dumux-precice as module library (#27) * [cmake] use dune_enable_all_packages to export libdumux-precice as module library * [doc] explain usage in separate module * [doc] correct adapter paths * [doc] correct external usage documentation * [cmake] cleanup CMakeLists.txt, remove explicit library link * [doc] clarify instructions for external usage * Update doc/user/docs/installation.md Co-authored-by: Ishaan Desai --------- Co-authored-by: Ishaan Desai --- CMakeLists.txt | 2 +- doc/user/docs/example-usage.md | 2 ++ doc/user/docs/installation.md | 15 +++++++++------ dumux-precice/CMakeLists.txt | 2 +- examples/dummysolver/CMakeLists.txt | 2 -- examples/ff-pm/flow-over-cube-3d/CMakeLists.txt | 12 +----------- examples/ff-pm/flow-over-square-2d/CMakeLists.txt | 3 --- 7 files changed, 14 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bf9d28f..3dd40bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ include(DuneMacros) # start a dune project with information from dune.module dune_project() -dune_enable_all_packages() +dune_enable_all_packages(MODULE_LIBRARIES dumux-precice) # enforce C++-17 dune_require_cxx_standard(MODULE "DuMuX-preCICE" VERSION 17) diff --git a/doc/user/docs/example-usage.md b/doc/user/docs/example-usage.md index 9c9b06e..8cabeb6 100644 --- a/doc/user/docs/example-usage.md +++ b/doc/user/docs/example-usage.md @@ -1,3 +1,5 @@ # Adapter usage Please check out the examples in the `examples/` directory to get an idea on how to use the adapter. + +To use the adapter in a separate DUNE module, call `dune_enable_all_packages()` in the root `CMakeLists.txt` of the application module. If `libdumux-precice` is built as a static library, preCICE needs to be explicitly discovered with `find_package` as done in the root `CMakeLists.txt` of the adapter. To build the adapter library as a dynamic library, use the CMake option `-DBUILD_SHARED_LIBS=ON` to build `dumux-precice` and upstream modules. diff --git a/doc/user/docs/installation.md b/doc/user/docs/installation.md index ffd7e27..a0177c5 100644 --- a/doc/user/docs/installation.md +++ b/doc/user/docs/installation.md @@ -20,7 +20,7 @@ The DuMuX-preCICE adapter should build fine if DuMuX, preCICE and their dependen ## Detailed installation steps -1. Install [DuMuX](https://dumux.org/) and the needed dependencies. The easiest way is to follow [DuMuX's installation instructions](https://dumux.org/installation/). The DuMuX project provides a script that installs and DuMuX and the DUNE modules required by DuMuX. This means, after installing DuMuX via the provided script you should be good to go to use the DuMuX-preCICE adapter. +1. Install [DuMuX](https://dumux.org/) and the needed dependencies. The easiest way is to follow [DuMuX's installation instructions](https://dumux.org/docs/doxygen/master/installation.html). The DuMuX project provides a script that installs and DuMuX and the DUNE modules required by DuMuX. This means, after installing DuMuX via the provided script you should be good to go to use the DuMuX-preCICE adapter. After the installation you should have a root directory that contains the base DUNE modules, i.e. a number of directories named like `dune-common`, `dune-geometry` etc., and a directory called `dumux`. @@ -38,12 +38,12 @@ The DuMuX-preCICE adapter should build fine if DuMuX, preCICE and their dependen git clone -b develop git@github.com:precice/dumux-adapter.git ``` -3. Verify that the `dumux-precice` folder is in the same directory as the DUNE module folders and the `dumux` folder. +3. Verify that the `dumux-adapter` folder is in the same directory as the DUNE module folders and the `dumux` folder. 4. Build and configure the adapter using `dunecontrol`. While being in the directory mentioned in the previous step via calling ```text - dunecontrol --only=dumux-precice all + dune-common/bin/dunecontrol --only=dumux-precice all ``` After the build and configure step a new directory `build-cmake` was created inside the `dumux-precice` directory. @@ -51,23 +51,26 @@ The DuMuX-preCICE adapter should build fine if DuMuX, preCICE and their dependen You can configure the build and configuration process using advanced options by manipulating CMake variables. `dunecontrol` allows to pass an options file for that ```bash - dunecontrol --opts=OPTSFILE.opts --only=dumux-precice all + dune-common/bin/dunecontrol --opts=OPTSFILE.opts --only=dumux-precice all ``` There is an `opts`-file provided by the adapter that resides in `test/`. You can use it as ```bash - dunecontrol --opts=dumux-precice/test/cmake-test.opts --only=dumux-precice all + dune-common/bin/dunecontrol --opts=dumux-adapter/test/cmake-test.opts --only=dumux-precice all ``` This provided `cmake-test.opts` file turns off some system-dependent optimizations such that the tests create comparable results on different computers. + To use the adapter in a separate DUNE module, we recommend building the adapter as a shared library. To do so, use the CMake option `-DBUILD_SHARED_LIBS=ON` to build the adapter and upstream modules. The DuMux install script uses `dumux/cmake.opts`, which already sets this option. + Note that to change this setting it may be required to clear the CMake caches in `build-cmake/CMakeCache.txt`. + For more ways do manipulate/adapt the build and configuration step, please consult the `dunecontrol` documentation. 5. Optional, but recommended: Build all tests to verify the installation. For this navigate in the `build-cmake/` directory and build the `build_tests` target. ```bash - cd dumux-precice/build-cmake + cd dumux-adapter/build-cmake make -j1 build_tests ``` diff --git a/dumux-precice/CMakeLists.txt b/dumux-precice/CMakeLists.txt index 0a4fb70..c1e9dda 100644 --- a/dumux-precice/CMakeLists.txt +++ b/dumux-precice/CMakeLists.txt @@ -2,5 +2,5 @@ install(FILES couplingadapter.hh DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux-precice) -add_library(dumux-precice STATIC couplingadapter.cc dumuxpreciceindexmapper.cc) +dune_library_add_sources(dumux-precice SOURCES couplingadapter.cc dumuxpreciceindexmapper.cc) target_link_libraries(dumux-precice PRIVATE precice::precice) diff --git a/examples/dummysolver/CMakeLists.txt b/examples/dummysolver/CMakeLists.txt index f590201..b6f3d53 100644 --- a/examples/dummysolver/CMakeLists.txt +++ b/examples/dummysolver/CMakeLists.txt @@ -1,7 +1,5 @@ add_executable(dumuxprecice_dummysolver EXCLUDE_FROM_ALL main_dummysolver.cc) -target_link_libraries(dumuxprecice_dummysolver PRIVATE dumux-precice) - dune_symlink_to_source_files(FILES precice-dummy-solver-config.xml) dune_symlink_to_source_files(FILES Allrun.sh) diff --git a/examples/ff-pm/flow-over-cube-3d/CMakeLists.txt b/examples/ff-pm/flow-over-cube-3d/CMakeLists.txt index d341da6..051cfad 100644 --- a/examples/ff-pm/flow-over-cube-3d/CMakeLists.txt +++ b/examples/ff-pm/flow-over-cube-3d/CMakeLists.txt @@ -1,9 +1,6 @@ add_executable(ff_flow_over_cube_3d EXCLUDE_FROM_ALL main_ff-reversed.cc) add_executable(pm_flow_over_cube_3d EXCLUDE_FROM_ALL main_pm-reversed.cc) -target_link_libraries(ff_flow_over_cube_3d PRIVATE dumux-precice) -target_link_libraries(pm_flow_over_cube_3d PRIVATE dumux-precice) - # add a symlink for each input file add_input_file_links() # add a symlink for each preCICE configuration file @@ -19,13 +16,6 @@ dumux_add_test(NAME dummytarget_to_build_pm_flow_over_cube_3d COMMAND ${CMAKE_SOURCE_DIR}/test/return-test-passed.sh ) -#dumux_add_test(NAME dummytarget_to_build_ff_flow_over_cube_3d -# TARGET ff_flow_over_cube_3d -# LABELS freeflow stokes precice darcy 3d -# TIMEOUT 5 -# COMMAND ${CMAKE_SOURCE_DIR}/test/return-test-passed.sh -#) - dumux_add_test(NAME test_ff_pm_flow_over_cube_3d TARGET ff_flow_over_cube_3d @@ -48,4 +38,4 @@ dumux_add_test(NAME test_ff_pm_flow_over_cube_3d --zeroThreshold {"velocity_liq \(m/s\)":1e-14,"p":1e-12} ) set_tests_properties(test_ff_pm_flow_over_cube_3d PROPERTIES - ENVIRONMENT PYTHONPATH=${CMAKE_SOURCE_DIR}/test:$ENV{PYTHONPATH}) \ No newline at end of file + ENVIRONMENT PYTHONPATH=${CMAKE_SOURCE_DIR}/test:$ENV{PYTHONPATH}) diff --git a/examples/ff-pm/flow-over-square-2d/CMakeLists.txt b/examples/ff-pm/flow-over-square-2d/CMakeLists.txt index 7c8db8a..8831104 100644 --- a/examples/ff-pm/flow-over-square-2d/CMakeLists.txt +++ b/examples/ff-pm/flow-over-square-2d/CMakeLists.txt @@ -1,9 +1,6 @@ add_executable(ff_flow_over_square_2d EXCLUDE_FROM_ALL main_ff.cc) add_executable(pm_flow_over_square_2d EXCLUDE_FROM_ALL main_pm.cc) -target_link_libraries(ff_flow_over_square_2d PRIVATE dumux-precice) -target_link_libraries(pm_flow_over_square_2d PRIVATE dumux-precice) - add_input_file_links() add_precice_file_links() From 97d85cb950730d25cef458e7d02c5dc0cbe5fb19 Mon Sep 17 00:00:00 2001 From: June <94080048+Fujikawas@users.noreply.github.com> Date: Tue, 12 Mar 2024 11:19:14 +0100 Subject: [PATCH 14/28] Remove outdated tag in preCICE configuration file (#32) Co-authored-by: Jun Chen --- examples/dummysolver/precice-dummy-solver-config.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/dummysolver/precice-dummy-solver-config.xml b/examples/dummysolver/precice-dummy-solver-config.xml index 52e5c97..ccc88b5 100644 --- a/examples/dummysolver/precice-dummy-solver-config.xml +++ b/examples/dummysolver/precice-dummy-solver-config.xml @@ -56,8 +56,6 @@ - - From dadf1fdf46b171a0ef0fc70712e2f4c788ccc0c7 Mon Sep 17 00:00:00 2001 From: June <94080048+Fujikawas@users.noreply.github.com> Date: Mon, 4 Mar 2024 16:03:37 +0100 Subject: [PATCH 15/28] Update the version in CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb7df87..ddf46c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # DuMuX-preCICE change log -## Not released yet +## v2.0.0 - 2023-08-10: Updated the adapter to align with preCICE V3. Updated the examples accordingly. From 070bbc776ee589c9461d4e733f1ddac487713461 Mon Sep 17 00:00:00 2001 From: June <94080048+Fujikawas@users.noreply.github.com> Date: Mon, 4 Mar 2024 16:05:56 +0100 Subject: [PATCH 16/28] Bump the versions for dune.module building --- dune.module | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dune.module b/dune.module index 694e26c..e3f8732 100644 --- a/dune.module +++ b/dune.module @@ -4,9 +4,9 @@ #Name of the module Module: dumux-precice -Version: 1.0.0 +Version: 2.0.0 Maintainer: ishaan.desai@ipvs.uni-stuttgart.de # Required build dependencies -Depends: dumux (>=3.2) +Depends: dumux (>=3.7) # Optional build dependencies Suggests: dune-subgrid From 6d644ff83431773403ca99ab9b7b4b973ff7d2df Mon Sep 17 00:00:00 2001 From: June <94080048+Fujikawas@users.noreply.github.com> Date: Mon, 4 Mar 2024 16:09:18 +0100 Subject: [PATCH 17/28] Bump versions in README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1aff4f0..7660154 100644 --- a/README.md +++ b/README.md @@ -23,13 +23,13 @@ The DuMuX-preCICE adapter is a DUNE module named `dumux-precice` which can be bu ### Prerequisites -- DuMuX **newer** than 3.2 +- DuMuX **newer** than 3.7 - Builds using the current `master` branch of DuMuX might fail. - If you run into trouble with a new DuMuX release, please open an issue in the repository and add the error message that you receive. - Needs UMFPack (available via SuiteSparse) as solver for linear systems of equations. This is needed to run the examples included in the adapter. Otherwise you can skip UMFPack. -- preCICE >=2.0.0 +- preCICE >=3.0.0 - The adapter is build via the DUNE build system that is based on CMake. Thus, the CMake [link instructions for preCICE](https://precice.org/installation-linking.html#cmake) apply. @@ -51,13 +51,13 @@ The DuMuX-preCICE adapter should build fine if DuMuX, preCICE and their dependen 2. Download the DuMuX-preCICE adapter to the same directory as the DUNE modules and the `dumux` folder. It is recommended to use the latest release of the adapter, which can be found by checking out the relevant release tag. ```text - git clone -b v1.0.0 https://github.com/precice/dumux-adapter.git + git clone -b v2.0.0 https://github.com/precice/dumux-adapter.git ``` You can also try to clone the repository via SSH: ```text - git clone -b v1.0.0 git@github.com:precice/dumux-adapter.git + git clone -b v2.0.0 git@github.com:precice/dumux-adapter.git ``` 3. Verify that the `dumux-adapter` folder is in the same directory as the DUNE module folders and the `dumux` folder. From ea6820eb690c5879e3d30ac056a85551abe096dc Mon Sep 17 00:00:00 2001 From: June <94080048+Fujikawas@users.noreply.github.com> Date: Mon, 4 Mar 2024 16:13:01 +0100 Subject: [PATCH 18/28] Bump dumux version for build-and-test --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index d1637ca..2bc3bc4 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -11,7 +11,7 @@ jobs: strategy: max-parallel: 2 matrix: - dumux_version: [3.4, 3.5] + dumux_version: [3.7, 3.8] precice_version: [develop] container: image: precice/dumux-precice:${{ matrix.dumux_version }}-${{ matrix.precice_version }} From 533a2f12f9abd95b4c1fa6b6a6d95135489caf0e Mon Sep 17 00:00:00 2001 From: June <94080048+Fujikawas@users.noreply.github.com> Date: Mon, 4 Mar 2024 16:15:22 +0100 Subject: [PATCH 19/28] Bump version in build-docker-containers.yml --- .github/workflows/build-docker-containers.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-docker-containers.yml b/.github/workflows/build-docker-containers.yml index 068ce5d..d566409 100644 --- a/.github/workflows/build-docker-containers.yml +++ b/.github/workflows/build-docker-containers.yml @@ -17,7 +17,7 @@ jobs: dockerhub_username: precice strategy: matrix: - dumux_version: [3.4, 3.5] + dumux_version: [3.7, 3.8] precice_version: [develop] steps: - name: Checkout Repository From d63a338019c58552e451e09b3838646fb1807204 Mon Sep 17 00:00:00 2001 From: June <94080048+Fujikawas@users.noreply.github.com> Date: Mon, 4 Mar 2024 16:20:23 +0100 Subject: [PATCH 20/28] Bump version in rebuild-docker-images.sh --- docker/rebuild-docker-images.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/rebuild-docker-images.sh b/docker/rebuild-docker-images.sh index 3c87767..0d86af9 100755 --- a/docker/rebuild-docker-images.sh +++ b/docker/rebuild-docker-images.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -DUNE_VERSION="2.8" -DUMUX_VERSIONS=("3.4" "3.5") +DUNE_VERSION="2.9" +DUMUX_VERSIONS=("3.7" "3.8") PRECICE_VERSIONS=("develop") for dumux_version in ${DUMUX_VERSIONS[@]}; do From 913df3ca40f735a10323abd5d6f241bf7eb4e9e0 Mon Sep 17 00:00:00 2001 From: June <94080048+Fujikawas@users.noreply.github.com> Date: Mon, 4 Mar 2024 16:22:42 +0100 Subject: [PATCH 21/28] Update dune version in build-docker-containers.yml --- .github/workflows/build-docker-containers.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-docker-containers.yml b/.github/workflows/build-docker-containers.yml index d566409..04c7a6c 100644 --- a/.github/workflows/build-docker-containers.yml +++ b/.github/workflows/build-docker-containers.yml @@ -37,7 +37,7 @@ jobs: file: "./dockerfile.slim" tags: ${{ env.dockerhub_username }}/dumux-precice:${{ matrix.dumux_version }}-${{ matrix.precice_version }} build-args: | - DUNEVERSION=2.8 + DUNEVERSION=2.9 PRECICEUBUNTU=focal DUMUXVERSION=${{ matrix.dumux_version }} PRECICEVERSION=${{ matrix.precice_version }} From 8900f1a6cebaf5b7e1253a664ff74095b551d330 Mon Sep 17 00:00:00 2001 From: Jun Chen Date: Tue, 5 Mar 2024 12:47:58 +0100 Subject: [PATCH 22/28] bump version in docker files --- docker/README.md | 4 ++-- docker/dockerfile.base | 4 ++-- docker/dockerfile.large | 4 ++-- docker/dockerfile.slim | 4 ++-- docker/dockerfile_dune-precice.slim | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docker/README.md b/docker/README.md index 0ed0d4c..44e3684 100644 --- a/docker/README.md +++ b/docker/README.md @@ -19,8 +19,8 @@ For more details on what is installed, please check the `Dockerfile`. The versions of the main dependencies can be manipulated when building the Docker image via the arguments with given default values -- `ARG DUNEVERSION=2.7`: DUNE version. Available in all recipes. -- `ARG DUMUXVERSION=3.4`: DuMuX version. Available in all recipes. +- `ARG DUNEVERSION=2.9`: DUNE version. Available in all recipes. +- `ARG DUMUXVERSION=3.7`: DuMuX version. Available in all recipes. - `ARG PRECICEVERSION=2.2.1`: preCICE version. Available only in "large" and "slim" recipes. - `ARG PRECICEUBUNTU=focal`: preCICE target platform (here, Ubuntu Focal Fossa). Available only in "large" recipe. diff --git a/docker/dockerfile.base b/docker/dockerfile.base index a0363d6..93551c7 100644 --- a/docker/dockerfile.base +++ b/docker/dockerfile.base @@ -13,8 +13,8 @@ ARG DUMUXINSTALLPATH=/opt/DUMUX WORKDIR ${DUMUXINSTALLPATH} # Obtain DuMuX and Dune repositories -ARG DUNEVERSION=2.8 -ARG DUMUXVERSION=3.5 +ARG DUNEVERSION=2.9 +ARG DUMUXVERSION=3.7 COPY checkout_repositories.sh . RUN bash checkout_repositories.sh ${DUNEVERSION} ${DUMUXVERSION} diff --git a/docker/dockerfile.large b/docker/dockerfile.large index 0e4c5c6..2903f38 100644 --- a/docker/dockerfile.large +++ b/docker/dockerfile.large @@ -14,8 +14,8 @@ RUN apt-get install -y apt-utils vim htop git RUN apt-get install -y openmpi-bin libopenmpi-dev git gcc g++ wget cmake sudo libboost-all-dev pkg-config python3 # Obtain DuMuX and Dune repositories -ARG DUNEVERSION=2.7 -ARG DUMUXVERSION=3.4 +ARG DUNEVERSION=2.9 +ARG DUMUXVERSION=3.7 COPY checkout_repositories.sh . RUN bash checkout_repositories.sh ${DUNEVERSION} ${DUMUXVERSION} diff --git a/docker/dockerfile.slim b/docker/dockerfile.slim index d62d736..e98c89a 100644 --- a/docker/dockerfile.slim +++ b/docker/dockerfile.slim @@ -13,8 +13,8 @@ ARG DUMUXINSTALLPATH=/opt/DUMUX WORKDIR ${DUMUXINSTALLPATH} # Obtain DuMuX and Dune repositories -ARG DUNEVERSION=2.8 -ARG DUMUXVERSION=3.5 +ARG DUNEVERSION=2.9 +ARG DUMUXVERSION=3.7 COPY checkout_repositories.sh . RUN bash checkout_repositories.sh ${DUNEVERSION} ${DUMUXVERSION} diff --git a/docker/dockerfile_dune-precice.slim b/docker/dockerfile_dune-precice.slim index e452805..005f4dd 100644 --- a/docker/dockerfile_dune-precice.slim +++ b/docker/dockerfile_dune-precice.slim @@ -13,7 +13,7 @@ ARG DUMUXINSTALLPATH=/opt/DUMUX WORKDIR ${DUMUXINSTALLPATH} # Obtain DuMuX and Dune repositories -ARG DUNEVERSION=2.8 +ARG DUNEVERSION=2.9 COPY checkout_repositories.sh . RUN bash checkout_repositories.sh ${DUNEVERSION} none From 5aac3e75455111db2eb129bccfd63a53b0c7916c Mon Sep 17 00:00:00 2001 From: Mathis Kelm Date: Tue, 12 Mar 2024 15:33:04 +0100 Subject: [PATCH 23/28] [examples] remove backwards compatibility for DuMux < 3.7 --- .../flow-over-cube-3d/1pspatialparams.hh | 36 +++++-------------- .../flow-over-cube-3d/ffproblem-reversed.hh | 33 ----------------- .../flow-over-cube-3d/main_ff-reversed.cc | 12 ------- .../flow-over-cube-3d/main_pm-reversed.cc | 12 ------- .../flow-over-cube-3d/pmproblem-reversed.hh | 19 ---------- .../flow-over-square-2d/1pspatialparams.hh | 36 +++++-------------- .../flow-over-square-2d/ffproblem-reversed.hh | 34 +----------------- examples/ff-pm/flow-over-square-2d/main_ff.cc | 12 ------- examples/ff-pm/flow-over-square-2d/main_pm.cc | 12 ------- .../flow-over-square-2d/pmproblem-reversed.hh | 18 ---------- 10 files changed, 17 insertions(+), 207 deletions(-) diff --git a/examples/ff-pm/flow-over-cube-3d/1pspatialparams.hh b/examples/ff-pm/flow-over-cube-3d/1pspatialparams.hh index ef81c28..e7855f2 100644 --- a/examples/ff-pm/flow-over-cube-3d/1pspatialparams.hh +++ b/examples/ff-pm/flow-over-cube-3d/1pspatialparams.hh @@ -24,11 +24,7 @@ #ifndef DUMUX_1P_TEST_SPATIALPARAMS_HH #define DUMUX_1P_TEST_SPATIALPARAMS_HH -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 5 #include -#else -#include -#endif namespace Dumux { @@ -39,30 +35,16 @@ namespace Dumux * 1p cc model */ template -class OnePSpatialParams -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 5 - : public FVPorousMediumFlowSpatialParamsOneP< - FVGridGeometry, - Scalar, - OnePSpatialParams> -#else - : public FVSpatialParamsOneP> -#endif +class OnePSpatialParams : public FVPorousMediumFlowSpatialParamsOneP< + FVGridGeometry, + Scalar, + OnePSpatialParams> { using GridView = typename FVGridGeometry::GridView; - using ParentType = -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 5 - FVPorousMediumFlowSpatialParamsOneP< - FVGridGeometry, - Scalar, - OnePSpatialParams>; -#else - FVSpatialParamsOneP>; -#endif + using ParentType = FVPorousMediumFlowSpatialParamsOneP< + FVGridGeometry, + Scalar, + OnePSpatialParams>; using Element = typename GridView::template Codim<0>::Entity; using GlobalPosition = typename Element::Geometry::GlobalCoordinate; @@ -108,7 +90,6 @@ public: return alphaBJ_; } -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR > 4 /*! * \brief Return the temperature within the domain in [K]. * @@ -118,7 +99,6 @@ public: { return 273.15 + 10; // 10°C } -#endif private: Scalar permeability_; diff --git a/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh b/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh index df1bce4..cc782b6 100644 --- a/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh +++ b/examples/ff-pm/flow-over-cube-3d/ffproblem-reversed.hh @@ -25,20 +25,14 @@ #include -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 4 #include -#endif #include #include #include #include -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 6 #include -#else -#include -#endif #include @@ -98,15 +92,9 @@ struct EnableGridVolumeVariablesCache { * \brief The free flow sub problem */ template -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 6 class StokesSubProblem : public NavierStokesStaggeredProblem { using ParentType = NavierStokesStaggeredProblem; -#else -class StokesSubProblem : public NavierStokesProblem -{ - using ParentType = NavierStokesProblem; -#endif using GridGeometry = GetPropType; using GridView = typename GridGeometry::GridView; @@ -126,11 +114,7 @@ class StokesSubProblem : public NavierStokesProblem using GlobalPosition = typename Element::Geometry::GlobalCoordinate; using PrimaryVariables = GetPropType; -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 4 using NumEqVector = Dumux::NumEqVector; -#else - using NumEqVector = GetPropType; -#endif using FluidSystem = GetPropType; public: @@ -148,19 +132,6 @@ public: */ // \{ -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR < 5 - /*! - * \brief Return the temperature within the domain in [K]. - * - * This problem assumes a temperature of 10 degrees Celsius. - */ - Scalar temperature() const - { - // 10°C - return 273.15 + 10; - } -#endif - /*! * \brief Return the sources within the domain. * @@ -317,11 +288,7 @@ public: using std::sqrt; const Scalar dPdX = -deltaP_ / (this->gridGeometry().bBoxMax()[0] - this->gridGeometry().bBoxMin()[0]); -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR > 4 static const Scalar mu = FluidSystem::viscosity(273.15 + 10, 1e5); -#else - static const Scalar mu = FluidSystem::viscosity(temperature(), 1e5); -#endif static const Scalar alpha = getParam("Darcy.SpatialParams.AlphaBeaversJoseph"); static const Scalar K = diff --git a/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc b/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc index fcab969..8dc80e4 100644 --- a/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc +++ b/examples/ff-pm/flow-over-cube-3d/main_ff-reversed.cc @@ -41,13 +41,9 @@ #include #include -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 7 #include #include #include -#else -#include -#endif #include #include @@ -299,11 +295,7 @@ try { GetPropType; auto freeFlowGridGeometry = std::make_shared(freeFlowGridView); -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 5 freeFlowGridGeometry->update(freeFlowGridManager.grid().leafGridView()); -#else - freeFlowGridGeometry->update(); -#endif // the problem (initial and boundary conditions) using FreeFlowProblem = GetPropType; @@ -408,13 +400,9 @@ try { freeFlowProblem, freeFlowGridGeometry, freeFlowGridVariables); // the linear solver -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 7 using LinearSolver = UMFPackIstlSolver>; -#else - using LinearSolver = UMFPackBackend; -#endif auto linearSolver = std::make_shared(); // the non-linear solver diff --git a/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc b/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc index cb49357..55e0092 100644 --- a/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc +++ b/examples/ff-pm/flow-over-cube-3d/main_pm-reversed.cc @@ -42,13 +42,9 @@ bool printstuff = false; #include #include -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 7 #include #include #include -#else -#include -#endif #include @@ -341,11 +337,7 @@ try { using DarcyGridGeometry = GetPropType; auto darcyGridGeometry = std::make_shared(darcyGridView); -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 5 darcyGridGeometry->update(darcyGridManager.grid().leafGridView()); -#else - darcyGridGeometry->update(); -#endif using DarcyProblem = GetPropType; auto darcyProblem = std::make_shared(darcyGridGeometry); @@ -448,13 +440,9 @@ try { darcyProblem, darcyGridGeometry, darcyGridVariables); // the linear solver -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 7 using LinearSolver = UMFPackIstlSolver>; -#else - using LinearSolver = UMFPackBackend; -#endif auto linearSolver = std::make_shared(); // the non-linear solver diff --git a/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh b/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh index 4413b36..e4e1c5a 100644 --- a/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh +++ b/examples/ff-pm/flow-over-cube-3d/pmproblem-reversed.hh @@ -26,9 +26,7 @@ #include -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 4 #include -#endif #include @@ -97,11 +95,7 @@ class DarcySubProblem : public PorousMediumFlowProblem typename GetPropType::GridView; using Scalar = GetPropType; using PrimaryVariables = GetPropType; -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 4 using NumEqVector = Dumux::NumEqVector; -#else - using NumEqVector = GetPropType; -#endif using BoundaryTypes = Dumux::BoundaryTypes< GetPropType::numEq()>; using VolumeVariables = GetPropType; @@ -131,19 +125,6 @@ public: */ // \{ -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR < 5 - /*! - * \brief Return the temperature within the domain in [K]. - * - */ - Scalar temperature() const - { - // 10°C - return 273.15 + 10; - } - // \} -#endif - /*! * \name Boundary conditions */ diff --git a/examples/ff-pm/flow-over-square-2d/1pspatialparams.hh b/examples/ff-pm/flow-over-square-2d/1pspatialparams.hh index ef81c28..e7855f2 100644 --- a/examples/ff-pm/flow-over-square-2d/1pspatialparams.hh +++ b/examples/ff-pm/flow-over-square-2d/1pspatialparams.hh @@ -24,11 +24,7 @@ #ifndef DUMUX_1P_TEST_SPATIALPARAMS_HH #define DUMUX_1P_TEST_SPATIALPARAMS_HH -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 5 #include -#else -#include -#endif namespace Dumux { @@ -39,30 +35,16 @@ namespace Dumux * 1p cc model */ template -class OnePSpatialParams -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 5 - : public FVPorousMediumFlowSpatialParamsOneP< - FVGridGeometry, - Scalar, - OnePSpatialParams> -#else - : public FVSpatialParamsOneP> -#endif +class OnePSpatialParams : public FVPorousMediumFlowSpatialParamsOneP< + FVGridGeometry, + Scalar, + OnePSpatialParams> { using GridView = typename FVGridGeometry::GridView; - using ParentType = -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 5 - FVPorousMediumFlowSpatialParamsOneP< - FVGridGeometry, - Scalar, - OnePSpatialParams>; -#else - FVSpatialParamsOneP>; -#endif + using ParentType = FVPorousMediumFlowSpatialParamsOneP< + FVGridGeometry, + Scalar, + OnePSpatialParams>; using Element = typename GridView::template Codim<0>::Entity; using GlobalPosition = typename Element::Geometry::GlobalCoordinate; @@ -108,7 +90,6 @@ public: return alphaBJ_; } -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR > 4 /*! * \brief Return the temperature within the domain in [K]. * @@ -118,7 +99,6 @@ public: { return 273.15 + 10; // 10°C } -#endif private: Scalar permeability_; diff --git a/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh b/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh index 4d6109e..4be7f23 100644 --- a/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh +++ b/examples/ff-pm/flow-over-square-2d/ffproblem-reversed.hh @@ -24,20 +24,15 @@ #define DUMUX_STOKES_SUBPROBLEM_HH #include -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 4 + #include -#endif #include #include #include #include -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 6 #include -#else -#include -#endif #include @@ -97,15 +92,9 @@ struct EnableGridVolumeVariablesCache { * \brief The free flow sub problem */ template -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 6 class StokesSubProblem : public NavierStokesStaggeredProblem { using ParentType = NavierStokesStaggeredProblem; -#else -class StokesSubProblem : public NavierStokesProblem -{ - using ParentType = NavierStokesProblem; -#endif using GridGeometry = GetPropType; using GridView = typename GridGeometry::GridView; @@ -126,11 +115,7 @@ class StokesSubProblem : public NavierStokesProblem using PrimaryVariables = GetPropType; -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 4 using NumEqVector = Dumux::NumEqVector; -#else - using NumEqVector = GetPropType; -#endif using FluidSystem = GetPropType; @@ -149,19 +134,6 @@ public: */ // \{ -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR < 5 - /*! - * \brief Return the temperature within the domain in [K]. - * - * This problem assumes a temperature of 10 degrees Celsius. - */ - Scalar temperature() const - { - // 10°C - return 273.15 + 10; - } -#endif - /*! * \brief Return the sources within the domain. * @@ -316,11 +288,7 @@ public: using std::sqrt; const Scalar dPdX = -deltaP_ / (this->gridGeometry().bBoxMax()[0] - this->gridGeometry().bBoxMin()[0]); -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR > 4 static const Scalar mu = FluidSystem::viscosity(273.15 + 10, 1e5); -#else - static const Scalar mu = FluidSystem::viscosity(temperature(), 1e5); -#endif static const Scalar alpha = getParam("Darcy.SpatialParams.AlphaBeaversJoseph"); static const Scalar K = diff --git a/examples/ff-pm/flow-over-square-2d/main_ff.cc b/examples/ff-pm/flow-over-square-2d/main_ff.cc index 7d72f90..042f21e 100644 --- a/examples/ff-pm/flow-over-square-2d/main_ff.cc +++ b/examples/ff-pm/flow-over-square-2d/main_ff.cc @@ -41,13 +41,9 @@ #include #include -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 7 #include #include #include -#else -#include -#endif #include #include @@ -191,11 +187,7 @@ try { GetPropType; auto freeFlowGridGeometry = std::make_shared(freeFlowGridView); -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 5 freeFlowGridGeometry->update(freeFlowGridManager.grid().leafGridView()); -#else - freeFlowGridGeometry->update(); -#endif // the problem (initial and boundary conditions) using FreeFlowProblem = GetPropType; @@ -300,13 +292,9 @@ try { freeFlowProblem, freeFlowGridGeometry, freeFlowGridVariables); // the linear solver -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 7 using LinearSolver = UMFPackIstlSolver>; -#else - using LinearSolver = UMFPackBackend; -#endif auto linearSolver = std::make_shared(); // the non-linear solver diff --git a/examples/ff-pm/flow-over-square-2d/main_pm.cc b/examples/ff-pm/flow-over-square-2d/main_pm.cc index 29b37cd..66d428e 100644 --- a/examples/ff-pm/flow-over-square-2d/main_pm.cc +++ b/examples/ff-pm/flow-over-square-2d/main_pm.cc @@ -42,13 +42,9 @@ bool printstuff = false; #include #include -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 7 #include #include #include -#else -#include -#endif #include @@ -235,11 +231,7 @@ try { using DarcyGridGeometry = GetPropType; auto darcyGridGeometry = std::make_shared(darcyGridView); -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 5 darcyGridGeometry->update(darcyGridManager.grid().leafGridView()); -#else - darcyGridGeometry->update(); -#endif using DarcyProblem = GetPropType; auto darcyProblem = std::make_shared(darcyGridGeometry); @@ -342,13 +334,9 @@ try { darcyProblem, darcyGridGeometry, darcyGridVariables); // the linear solver -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 7 using LinearSolver = UMFPackIstlSolver>; -#else - using LinearSolver = UMFPackBackend; -#endif auto linearSolver = std::make_shared(); // the non-linear solver diff --git a/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh b/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh index e21868a..76bc0d3 100644 --- a/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh +++ b/examples/ff-pm/flow-over-square-2d/pmproblem-reversed.hh @@ -26,9 +26,7 @@ #include -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 4 #include -#endif #include #include @@ -96,11 +94,7 @@ class DarcySubProblem : public PorousMediumFlowProblem using Scalar = GetPropType; using PrimaryVariables = GetPropType; -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR >= 4 using NumEqVector = Dumux::NumEqVector; -#else - using NumEqVector = GetPropType; -#endif using BoundaryTypes = Dumux::BoundaryTypes< GetPropType::numEq()>; @@ -131,18 +125,6 @@ public: */ // \{ -#if DUMUX_VERSION_MAJOR >= 3 & DUMUX_VERSION_MINOR < 5 - /*! - * \brief Return the temperature within the domain in [K]. - * - */ - Scalar temperature() const - { - // 10°C - return 273.15 + 10; - } - // \} -#endif /*! * \name Boundary conditions */ From 04772a3e8371908e1fe71cbd3bcda2e75dcdbd01 Mon Sep 17 00:00:00 2001 From: Mathis Kelm Date: Tue, 12 Mar 2024 15:57:53 +0100 Subject: [PATCH 24/28] [doc] fix documentation --- README.md | 8 ++++---- doc/user/docs/installation.md | 6 +++--- docker/README.md | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 7660154..273d98e 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ The DuMuX-preCICE adapter is a DUNE module named `dumux-precice` which can be bu ### Prerequisites -- DuMuX **newer** than 3.7 +- DuMuX >= than 3.7 - Builds using the current `master` branch of DuMuX might fail. - If you run into trouble with a new DuMuX release, please open an issue in the repository and add the error message that you receive. @@ -42,7 +42,7 @@ The DuMuX-preCICE adapter should build fine if DuMuX, preCICE and their dependen ### Detailed installation steps -1. Install [DuMuX](https://dumux.org/) and the needed dependencies. The easiest way is to follow [DuMuX's installation instructions](https://dumux.org/installation/). The DuMuX project provides a script that installs and DuMuX and the DUNE modules required by DuMuX. This means, after installing DuMuX via the provided script you should be good to go to use the DuMuX-preCICE adapter. +1. Install [DuMuX](https://dumux.org/) and the needed dependencies. The easiest way is to follow [DuMuX's installation instructions](https://dumux.org/docs/doxygen/master/installation.html). The DuMuX project provides a script that installs and DuMuX and the DUNE modules required by DuMuX. This means, after installing DuMuX via the provided script you should be good to go to use the DuMuX-preCICE adapter. After the installation you should have a root directory that contains the base DUNE modules, i.e. a number of directories named like `dune-common`, `dune-geometry` etc., and a directory called `dumux`. @@ -68,7 +68,7 @@ The DuMuX-preCICE adapter should build fine if DuMuX, preCICE and their dependen ./dune-common/bin/dunecontrol --only=dumux-precice all ``` - After the build and configure step a new directory `build-cmake` was created inside the `dumux-precice` directory. + After the build and configure step a new directory `build-cmake` was created inside the `dumux-adapter` directory. You can configure the build and configuration process using advanced options by manipulating CMake variables. `dunecontrol` allows to pass an options file for that @@ -84,7 +84,7 @@ The DuMuX-preCICE adapter should build fine if DuMuX, preCICE and their dependen This provided `cmake-test.opts` file turns off some system-dependent optimizations such that the tests create comparable results on different computers. - For more ways do manipulate/adapt the build and configuration step, please consult the `dunecontrol` documentation. + For more ways to manipulate/adapt the build and configuration step, please consult the `dunecontrol` documentation. 5. Optional, but recommended: Build all tests to verify the installation. For this navigate in the `build-cmake/` directory and build the `build_tests` target. diff --git a/doc/user/docs/installation.md b/doc/user/docs/installation.md index a0177c5..84821b7 100644 --- a/doc/user/docs/installation.md +++ b/doc/user/docs/installation.md @@ -4,7 +4,7 @@ The DuMuX-preCICE adapter is a DUNE module named `dumux-precice` which can be bu ## Prerequisites -- DuMuX **newer** than 3.2 +- DuMuX >= 3.7 - Builds using the current `master` branch of DuMuX might fail. - If you run into trouble with a new DuMuX release, please open an issue in the repository and add the error message that you receive. @@ -46,7 +46,7 @@ The DuMuX-preCICE adapter should build fine if DuMuX, preCICE and their dependen dune-common/bin/dunecontrol --only=dumux-precice all ``` - After the build and configure step a new directory `build-cmake` was created inside the `dumux-precice` directory. + After the build and configure step a new directory `build-cmake` was created inside the `dumux-adapter` directory. You can configure the build and configuration process using advanced options by manipulating CMake variables. `dunecontrol` allows to pass an options file for that @@ -65,7 +65,7 @@ The DuMuX-preCICE adapter should build fine if DuMuX, preCICE and their dependen To use the adapter in a separate DUNE module, we recommend building the adapter as a shared library. To do so, use the CMake option `-DBUILD_SHARED_LIBS=ON` to build the adapter and upstream modules. The DuMux install script uses `dumux/cmake.opts`, which already sets this option. Note that to change this setting it may be required to clear the CMake caches in `build-cmake/CMakeCache.txt`. - For more ways do manipulate/adapt the build and configuration step, please consult the `dunecontrol` documentation. + For more ways to manipulate/adapt the build and configuration step, please consult the `dunecontrol` documentation. 5. Optional, but recommended: Build all tests to verify the installation. For this navigate in the `build-cmake/` directory and build the `build_tests` target. diff --git a/docker/README.md b/docker/README.md index 44e3684..b7e60ea 100644 --- a/docker/README.md +++ b/docker/README.md @@ -21,13 +21,13 @@ The versions of the main dependencies can be manipulated when building the Docke - `ARG DUNEVERSION=2.9`: DUNE version. Available in all recipes. - `ARG DUMUXVERSION=3.7`: DuMuX version. Available in all recipes. -- `ARG PRECICEVERSION=2.2.1`: preCICE version. Available only in "large" and "slim" recipes. +- `ARG PRECICEVERSION=develop`: preCICE version. Available only in "large" and "slim" recipes. - `ARG PRECICEUBUNTU=focal`: preCICE target platform (here, Ubuntu Focal Fossa). Available only in "large" recipe. -If one wants to build a "slim" image using DUNE 2.8, DuMuX from the current master branch and preCICE 2.4.0 one could call it with the following command: +If one wants to build a "slim" image using DUNE 2.9, DuMuX from the current master branch and preCICE 3.0.0 one could call it with the following command: ```text -sudo docker build --build-arg DUNEVERSION=2.8 --build-arg DUMUXVERSION=master --build-arg PRECICEVERSION=2.4.0 -t ajaust/dumux-precice:master-2.4.0 --file dockerfile.slim . +sudo docker build --build-arg DUNEVERSION=2.9 --build-arg DUMUXVERSION=master --build-arg PRECICEVERSION=3.0.0 -t precice/dumux-precice:master-3.0.0 --file dockerfile.slim . ``` The script `rebuild-docker-images.sh` can be used to rebuild the Docker images locally. From d4cb258c89f999a09ab0f7b2fc532a746c103542 Mon Sep 17 00:00:00 2001 From: Mathis Kelm Date: Tue, 12 Mar 2024 16:54:22 +0100 Subject: [PATCH 25/28] [docker] cleanup precice versions --- docker/README.md | 4 ++-- docker/dockerfile.large | 4 ++-- docker/dockerfile.slim | 3 +-- docker/dockerfile_dune-precice.slim | 3 +-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/docker/README.md b/docker/README.md index b7e60ea..4e1557d 100644 --- a/docker/README.md +++ b/docker/README.md @@ -21,13 +21,13 @@ The versions of the main dependencies can be manipulated when building the Docke - `ARG DUNEVERSION=2.9`: DUNE version. Available in all recipes. - `ARG DUMUXVERSION=3.7`: DuMuX version. Available in all recipes. -- `ARG PRECICEVERSION=develop`: preCICE version. Available only in "large" and "slim" recipes. +- `ARG PRECICEVERSION=3.0.0`: preCICE version. Available only in "large" and "slim" (use branch name e.g. "v3.0.0" or "develop") recipes. - `ARG PRECICEUBUNTU=focal`: preCICE target platform (here, Ubuntu Focal Fossa). Available only in "large" recipe. If one wants to build a "slim" image using DUNE 2.9, DuMuX from the current master branch and preCICE 3.0.0 one could call it with the following command: ```text -sudo docker build --build-arg DUNEVERSION=2.9 --build-arg DUMUXVERSION=master --build-arg PRECICEVERSION=3.0.0 -t precice/dumux-precice:master-3.0.0 --file dockerfile.slim . +sudo docker build --build-arg DUNEVERSION=2.9 --build-arg DUMUXVERSION=master --build-arg PRECICEVERSION=v3.0.0 -t precice/dumux-precice:master-v3.0.0 --file dockerfile.slim . ``` The script `rebuild-docker-images.sh` can be used to rebuild the Docker images locally. diff --git a/docker/dockerfile.large b/docker/dockerfile.large index 2903f38..dbedb7d 100644 --- a/docker/dockerfile.large +++ b/docker/dockerfile.large @@ -31,9 +31,9 @@ ENV DUNE_CONTROL_PATH=${USER_HOME}/dune-common/dune.module:${USER_HOME}/dune-geo ENV PYTHONPATH ${USER_HOME}/dumux/bin/testing:${PYTHONPATH} #Install preCICE -ARG PRECICEVERSION=2.2.1 +ARG PRECICEVERSION=3.0.0 ARG PRECICEUBUNTU=focal -RUN wget https://github.com/precice/precice/releases/download/v${PRECICEVERSION}/libprecice2_${PRECICEVERSION}_${PRECICEUBUNTU}.deb -O libprecice${PRECICEVERSION}-${PRECICEUBUNTU}.deb \ +RUN wget https://github.com/precice/precice/releases/download/v${PRECICEVERSION}/libprecice3_${PRECICEVERSION}_${PRECICEUBUNTU}.deb -O libprecice${PRECICEVERSION}-${PRECICEUBUNTU}.deb \ && apt install -y ./libprecice${PRECICEVERSION}-${PRECICEUBUNTU}.deb \ && rm -f ./libprecice${PRECICEVERSION}-${PRECICEUBUNTU}.deb diff --git a/docker/dockerfile.slim b/docker/dockerfile.slim index e98c89a..80a28d8 100644 --- a/docker/dockerfile.slim +++ b/docker/dockerfile.slim @@ -30,8 +30,7 @@ ENV DUNE_CONTROL_PATH=${DUMUXINSTALLPATH}/dune-common/dune.module:${DUMUXINSTALL ENV PYTHONPATH ${DUMUXINSTALLPATH}/dumux/bin/testing:${PYTHONPATH} # Compile minmum version of preCICE -#ARG PRECICEVERSION=2.4.0 -ARG PRECICEVERSION=develop +ARG PRECICEVERSION=v3.0.0 ARG PRECICEUBUNTU=focal RUN git clone --depth 1 -b ${PRECICEVERSION} https://github.com/precice/precice.git precice-${PRECICEVERSION} && cd precice-${PRECICEVERSION} && mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DPRECICE_FEATURE_MPI_COMMUNICATION=OFF -DPRECICE_FEATURE_PETSC_MAPPING=OFF -DPRECICE_FEATURE_PYTHON_ACTIONS=OFF -DCMAKE_INSTALL_PREFIX=/usr && make -j 4 && make test && make install && cd ../../ && rm -rf precice-${PRECICEVERSION} diff --git a/docker/dockerfile_dune-precice.slim b/docker/dockerfile_dune-precice.slim index 005f4dd..10961c8 100644 --- a/docker/dockerfile_dune-precice.slim +++ b/docker/dockerfile_dune-precice.slim @@ -27,8 +27,7 @@ RUN dunecontrol --opts=cmake-test.opts all ENV DUNE_CONTROL_PATH=${DUMUXINSTALLPATH}/dune-common/dune.module:${DUMUXINSTALLPATH}/dune-geometry/dune.module:${DUMUXINSTALLPATH}/dune-grid/dune.module:${DUMUXINSTALLPATH}/dune-localfunctions/dune.module:${DUMUXINSTALLPATH}/dune-istl/dune.module:${DUMUXINSTALLPATH}/dune-subgrid/dune.module # Compile minmum version of preCICE -#ARG PRECICEVERSION=2.4.0 -ARG PRECICEVERSION=develop +ARG PRECICEVERSION=v3.0.0 ARG PRECICEUBUNTU=focal RUN git clone --depth 1 -b ${PRECICEVERSION} https://github.com/precice/precice.git precice-${PRECICEVERSION} && cd precice-${PRECICEVERSION} && mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DPRECICE_FEATURE_MPI_COMMUNICATION=OFF -DPRECICE_FEATURE_PETSC_MAPPING=OFF -DPRECICE_FEATURE_PYTHON_ACTIONS=OFF -DCMAKE_INSTALL_PREFIX=/usr && make -j 4 && make test && make install && cd ../../ && rm -rf precice-${PRECICEVERSION} From 8e21cd2066800ad2a28f38d2ab85c13ba4c2b1c8 Mon Sep 17 00:00:00 2001 From: Mathis Kelm Date: Tue, 12 Mar 2024 17:44:03 +0100 Subject: [PATCH 26/28] [docker] use ubuntu jammy 22.04 --- .github/workflows/build-docker-containers.yml | 4 ++-- docker/README.md | 2 +- docker/dockerfile.base | 2 +- docker/dockerfile.large | 4 ++-- docker/dockerfile.slim | 6 +++--- docker/dockerfile_dune-precice.slim | 6 +++--- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-docker-containers.yml b/.github/workflows/build-docker-containers.yml index 04c7a6c..ab7e16c 100644 --- a/.github/workflows/build-docker-containers.yml +++ b/.github/workflows/build-docker-containers.yml @@ -38,7 +38,7 @@ jobs: tags: ${{ env.dockerhub_username }}/dumux-precice:${{ matrix.dumux_version }}-${{ matrix.precice_version }} build-args: | DUNEVERSION=2.9 - PRECICEUBUNTU=focal + PRECICEUBUNTU=jammy DUMUXVERSION=${{ matrix.dumux_version }} PRECICEVERSION=${{ matrix.precice_version }} build-dune-precice: @@ -69,5 +69,5 @@ jobs: tags: ${{ env.dockerhub_username }}/dune-precice:${{ matrix.dune_version }}-${{ matrix.precice_version }} build-args: | DUNEVERSION=${{ matrix.dune_version }} - PRECICEUBUNTU=focal + PRECICEUBUNTU=jammy PRECICEVERSION=${{ matrix.precice_version }} diff --git a/docker/README.md b/docker/README.md index 4e1557d..2cb2fc6 100644 --- a/docker/README.md +++ b/docker/README.md @@ -22,7 +22,7 @@ The versions of the main dependencies can be manipulated when building the Docke - `ARG DUNEVERSION=2.9`: DUNE version. Available in all recipes. - `ARG DUMUXVERSION=3.7`: DuMuX version. Available in all recipes. - `ARG PRECICEVERSION=3.0.0`: preCICE version. Available only in "large" and "slim" (use branch name e.g. "v3.0.0" or "develop") recipes. -- `ARG PRECICEUBUNTU=focal`: preCICE target platform (here, Ubuntu Focal Fossa). Available only in "large" recipe. +- `ARG PRECICEUBUNTU=jammy`: preCICE target platform (here, Ubuntu Jammy Jellyfish). Available only in "large" recipe. If one wants to build a "slim" image using DUNE 2.9, DuMuX from the current master branch and preCICE 3.0.0 one could call it with the following command: diff --git a/docker/dockerfile.base b/docker/dockerfile.base index 93551c7..26fd30f 100644 --- a/docker/dockerfile.base +++ b/docker/dockerfile.base @@ -1,4 +1,4 @@ -FROM ubuntu:20.04 +FROM ubuntu:22.04 ENV DEBIAN_FRONTEND noninteractive diff --git a/docker/dockerfile.large b/docker/dockerfile.large index dbedb7d..4ad9162 100644 --- a/docker/dockerfile.large +++ b/docker/dockerfile.large @@ -1,4 +1,4 @@ -FROM ubuntu:20.04 +FROM ubuntu:22.04 # Install DUNE and DuMuX in /home/dumux WORKDIR ${USER_HOME} @@ -32,7 +32,7 @@ ENV PYTHONPATH ${USER_HOME}/dumux/bin/testing:${PYTHONPATH} #Install preCICE ARG PRECICEVERSION=3.0.0 -ARG PRECICEUBUNTU=focal +ARG PRECICEUBUNTU=jammy RUN wget https://github.com/precice/precice/releases/download/v${PRECICEVERSION}/libprecice3_${PRECICEVERSION}_${PRECICEUBUNTU}.deb -O libprecice${PRECICEVERSION}-${PRECICEUBUNTU}.deb \ && apt install -y ./libprecice${PRECICEVERSION}-${PRECICEUBUNTU}.deb \ && rm -f ./libprecice${PRECICEVERSION}-${PRECICEUBUNTU}.deb diff --git a/docker/dockerfile.slim b/docker/dockerfile.slim index 80a28d8..0c2ea18 100644 --- a/docker/dockerfile.slim +++ b/docker/dockerfile.slim @@ -1,4 +1,4 @@ -FROM ubuntu:20.04 +FROM ubuntu:22.04 ENV DEBIAN_FRONTEND noninteractive @@ -7,7 +7,7 @@ ADD 01_nodoc /etc/dpkg/dpkg.cfg.d/01_nodoc # Install dependencies from RUN apt-get update -RUN apt-get install -y git gcc g++ gfortran cmake pkg-config libboost-log1.71.0 libboost-thread1.71.0 libboost-system1.71.0 libboost-filesystem1.71.0 libboost-program-options1.71.0 libboost-test1.71.0 libboost-container1.71.0 libeigen3-dev libxml2 libboost-log-dev libboost-thread-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-test-dev libboost-container-dev libeigen3-dev libxml2-dev libsuitesparse-dev python3 +RUN apt-get install -y git gcc g++ gfortran cmake pkg-config libboost-log1.74.0 libboost-thread1.74.0 libboost-system1.74.0 libboost-filesystem1.74.0 libboost-program-options1.74.0 libboost-test1.74.0 libboost-container1.74.0 libeigen3-dev libxml2 libboost-log-dev libboost-thread-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-test-dev libboost-container-dev libeigen3-dev libxml2-dev libsuitesparse-dev python3 ARG DUMUXINSTALLPATH=/opt/DUMUX WORKDIR ${DUMUXINSTALLPATH} @@ -31,7 +31,7 @@ ENV PYTHONPATH ${DUMUXINSTALLPATH}/dumux/bin/testing:${PYTHONPATH} # Compile minmum version of preCICE ARG PRECICEVERSION=v3.0.0 -ARG PRECICEUBUNTU=focal +ARG PRECICEUBUNTU=jammy RUN git clone --depth 1 -b ${PRECICEVERSION} https://github.com/precice/precice.git precice-${PRECICEVERSION} && cd precice-${PRECICEVERSION} && mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DPRECICE_FEATURE_MPI_COMMUNICATION=OFF -DPRECICE_FEATURE_PETSC_MAPPING=OFF -DPRECICE_FEATURE_PYTHON_ACTIONS=OFF -DCMAKE_INSTALL_PREFIX=/usr && make -j 4 && make test && make install && cd ../../ && rm -rf precice-${PRECICEVERSION} RUN apt-get purge -y libboost-log-dev libboost-thread-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-test-dev libboost-container-dev libxml2-dev diff --git a/docker/dockerfile_dune-precice.slim b/docker/dockerfile_dune-precice.slim index 10961c8..8c2d334 100644 --- a/docker/dockerfile_dune-precice.slim +++ b/docker/dockerfile_dune-precice.slim @@ -1,4 +1,4 @@ -FROM ubuntu:20.04 +FROM ubuntu:22.04 ENV DEBIAN_FRONTEND noninteractive @@ -7,7 +7,7 @@ ADD 01_nodoc /etc/dpkg/dpkg.cfg.d/01_nodoc # Install dependencies from RUN apt-get update -RUN apt-get install -y git gcc g++ gfortran cmake pkg-config libboost-log1.71.0 libboost-thread1.71.0 libboost-system1.71.0 libboost-filesystem1.71.0 libboost-program-options1.71.0 libboost-test1.71.0 libboost-container1.71.0 libeigen3-dev libxml2 libboost-log-dev libboost-thread-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-test-dev libboost-container-dev libeigen3-dev libxml2-dev libsuitesparse-dev python3 +RUN apt-get install -y git gcc g++ gfortran cmake pkg-config libboost-log1.74.0 libboost-thread1.74.0 libboost-system1.74.0 libboost-filesystem1.74.0 libboost-program-options1.74.0 libboost-test1.74.0 libboost-container1.74.0 libeigen3-dev libxml2 libboost-log-dev libboost-thread-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-test-dev libboost-container-dev libeigen3-dev libxml2-dev libsuitesparse-dev python3 ARG DUMUXINSTALLPATH=/opt/DUMUX WORKDIR ${DUMUXINSTALLPATH} @@ -28,7 +28,7 @@ ENV DUNE_CONTROL_PATH=${DUMUXINSTALLPATH}/dune-common/dune.module:${DUMUXINSTALL # Compile minmum version of preCICE ARG PRECICEVERSION=v3.0.0 -ARG PRECICEUBUNTU=focal +ARG PRECICEUBUNTU=jammy RUN git clone --depth 1 -b ${PRECICEVERSION} https://github.com/precice/precice.git precice-${PRECICEVERSION} && cd precice-${PRECICEVERSION} && mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DPRECICE_FEATURE_MPI_COMMUNICATION=OFF -DPRECICE_FEATURE_PETSC_MAPPING=OFF -DPRECICE_FEATURE_PYTHON_ACTIONS=OFF -DCMAKE_INSTALL_PREFIX=/usr && make -j 4 && make test && make install && cd ../../ && rm -rf precice-${PRECICEVERSION} RUN apt-get purge -y libboost-log-dev libboost-thread-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-test-dev libboost-container-dev libxml2-dev From 65f259cc81c16eba5486a274208a3c864dafa7fe Mon Sep 17 00:00:00 2001 From: Mathis Kelm Date: Wed, 13 Mar 2024 13:53:46 +0100 Subject: [PATCH 27/28] bump versions in github template --- .github/issue_template.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/issue_template.md b/.github/issue_template.md index 79b7996..c146a9b 100644 --- a/.github/issue_template.md +++ b/.github/issue_template.md @@ -12,12 +12,12 @@ Please provide information about the operating system and relevant versions of the software. Example: -Ubuntu 20.04 LTS, preCICE 2.3.0, DuMuX 3.4, DuMuX-preCICE 0.1 +Ubuntu 22.04 LTS, preCICE 3.0.0, DuMuX 3.7, DuMuX-preCICE 2.0.0 ---> ## Steps to reproduce - + ### Expected behavior From a45ddca938ac283d3071d3c1663f0661773be645 Mon Sep 17 00:00:00 2001 From: Jun Chen Date: Thu, 14 Mar 2024 13:20:04 +0100 Subject: [PATCH 28/28] formatting --- CHANGELOG.md | 2 +- examples/dummysolver/precice-dummy-solver-config.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ddf46c5..964988b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## v2.0.0 -- 2023-08-10: Updated the adapter to align with preCICE V3. Updated the examples accordingly. +- 2023-08-10: Updated the adapter to be compatible with preCICE v3.0.0. Updated the examples too. ## v1.0.0 diff --git a/examples/dummysolver/precice-dummy-solver-config.xml b/examples/dummysolver/precice-dummy-solver-config.xml index ccc88b5..80379d0 100644 --- a/examples/dummysolver/precice-dummy-solver-config.xml +++ b/examples/dummysolver/precice-dummy-solver-config.xml @@ -1,6 +1,6 @@ - +