From b1e78cf1958c7695d928f59534f50ad92e311de4 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Tue, 31 Jan 2023 10:43:05 +0100 Subject: [PATCH 01/60] Document minimum version required for OpenFOAM v2212 --- docs/openfoam-support.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/openfoam-support.md b/docs/openfoam-support.md index 79e2caf2..818230de 100644 --- a/docs/openfoam-support.md +++ b/docs/openfoam-support.md @@ -27,6 +27,7 @@ We provide version-specific [release archives](https://github.com/precice/openfo - OpenCFD / ESI (openfoam.com) - main focus: - [OpenFOAM v1812-v2212](https://github.com/precice/openfoam-adapter) or newer + - OpenFOAM v2212 is only supported since v1.2.2 of the adapter. - [OpenFOAM v1612-v1806](https://github.com/precice/openfoam-adapter/tree/OpenFOAMv1806) (not tested) - OpenFOAM Foundation (openfoam.org) - secondary, consider experimental: - [OpenFOAM 10](https://github.com/precice/openfoam-adapter/tree/OpenFOAM10) From efbe339a10c162ac3d03c2706db1ed5c3edd0257 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Tue, 31 Jan 2023 10:46:49 +0100 Subject: [PATCH 02/60] Fix documentation linting --- docs/openfoam-support.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/openfoam-support.md b/docs/openfoam-support.md index 818230de..901aae3d 100644 --- a/docs/openfoam-support.md +++ b/docs/openfoam-support.md @@ -27,7 +27,7 @@ We provide version-specific [release archives](https://github.com/precice/openfo - OpenCFD / ESI (openfoam.com) - main focus: - [OpenFOAM v1812-v2212](https://github.com/precice/openfoam-adapter) or newer - - OpenFOAM v2212 is only supported since v1.2.2 of the adapter. + - OpenFOAM v2212 is only supported since v1.2.2 of the adapter. - [OpenFOAM v1612-v1806](https://github.com/precice/openfoam-adapter/tree/OpenFOAMv1806) (not tested) - OpenFOAM Foundation (openfoam.org) - secondary, consider experimental: - [OpenFOAM 10](https://github.com/precice/openfoam-adapter/tree/OpenFOAM10) From e4a5306339f03b50bdfa5a20ea7a96c379c5c557 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Sat, 18 Feb 2023 23:22:59 +0100 Subject: [PATCH 03/60] Update Actions set-output syntax Based on the deprecation described in https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ --- .github/workflows/build-custom.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-custom.yml b/.github/workflows/build-custom.yml index 2dc6d5fa..86b58bdc 100644 --- a/.github/workflows/build-custom.yml +++ b/.github/workflows/build-custom.yml @@ -82,69 +82,69 @@ jobs: OpenFOAMv2212) wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash sudo apt-get install openfoam2212-dev - echo "::set-output name=openfoam_exec::/usr/bin/openfoam2212";; + echo "{openfoam_exec}={/usr/bin/openfoam2212}" >> $GITHUB_OUTPUT OpenFOAMv2206) wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash sudo apt-get install openfoam2206-dev - echo "::set-output name=openfoam_exec::/usr/bin/openfoam2206";; + echo "{openfoam_exec}={/usr/bin/openfoam2206}" >> $GITHUB_OUTPUT OpenFOAMv2112) wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash sudo apt-get install openfoam2112-dev - echo "::set-output name=openfoam_exec::/usr/bin/openfoam2112";; + echo "{openfoam_exec}={/usr/bin/openfoam2112}" >> $GITHUB_OUTPUT OpenFOAMv2106) wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash sudo apt-get install openfoam2106-dev - echo "::set-output name=openfoam_exec::/usr/bin/openfoam2106";; + echo "{openfoam_exec}={/usr/bin/openfoam2106}" >> $GITHUB_OUTPUT OpenFOAMv2012) wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash sudo apt-get install openfoam2012-dev - echo "::set-output name=openfoam_exec::/usr/bin/openfoam2012";; + echo "{openfoam_exec}={/usr/bin/openfoam2012}" >> $GITHUB_OUTPUT OpenFOAMv2006) wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash sudo apt-get install openfoam2006-dev - echo "::set-output name=openfoam_exec::/usr/bin/openfoam2006";; + echo "{openfoam_exec}={/usr/bin/openfoam2006}" >> $GITHUB_OUTPUT OpenFOAMv1912) wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash sudo apt-get install openfoam1912-dev - echo "::set-output name=openfoam_exec::/usr/bin/openfoam1912";; + echo "{openfoam_exec}={/usr/bin/openfoam1912}" >> $GITHUB_OUTPUT OpenFOAM10) sudo sh -c "wget -O - https://dl.openfoam.org/gpg.key | apt-key add -" sudo add-apt-repository http://dl.openfoam.org/ubuntu sudo apt-get update sudo apt-get -y install openfoam10 - echo "::set-output name=openfoam_exec::. /opt/openfoam10/etc/bashrc &&";; + echo "{openfoam_exec}={. /opt/openfoam10/etc/bashrc &&}" >> $GITHUB_OUTPUT OpenFOAM9) sudo sh -c "wget -O - https://dl.openfoam.org/gpg.key | apt-key add -" sudo add-apt-repository http://dl.openfoam.org/ubuntu sudo apt-get update sudo apt-get -y install openfoam9 - echo "::set-output name=openfoam_exec::. /opt/openfoam9/etc/bashrc &&";; + echo "{openfoam_exec}={. /opt/openfoam9/etc/bashrc &&}" >> $GITHUB_OUTPUT OpenFOAM8) sudo sh -c "wget -O - https://dl.openfoam.org/gpg.key | apt-key add -" sudo add-apt-repository http://dl.openfoam.org/ubuntu sudo apt-get update sudo apt-get -y install openfoam8 - echo "::set-output name=openfoam_exec::. /opt/openfoam8/etc/bashrc &&";; + echo "{openfoam_exec}={. /opt/openfoam8/etc/bashrc &&}" >> $GITHUB_OUTPUT OpenFOAM7) sudo sh -c "wget -O - https://dl.openfoam.org/gpg.key | apt-key add -" sudo add-apt-repository http://dl.openfoam.org/ubuntu sudo apt-get update sudo apt-get -y install openfoam7 - echo "::set-output name=openfoam_exec::. /opt/openfoam7/etc/bashrc &&";; + echo "{openfoam_exec}={. /opt/openfoam7/etc/bashrc &&}" >> $GITHUB_OUTPUT OpenFOAM6) echo "OpenFOAM 6 is only available on Ubuntu 18.04 or older." sudo sh -c "wget -O - https://dl.openfoam.org/gpg.key | apt-key add -" sudo add-apt-repository http://dl.openfoam.org/ubuntu sudo apt-get update sudo apt-get -y install openfoam6 - echo "::set-output name=openfoam_exec::. /opt/openfoam6/etc/bashrc &&";; + echo "{openfoam_exec}={. /opt/openfoam6/etc/bashrc &&}" >> $GITHUB_OUTPUT OpenFOAM5) echo "OpenFOAM 5 is only available on Ubuntu 18.04 or older." sudo sh -c "wget -O - https://dl.openfoam.org/gpg.key | apt-key add -" sudo add-apt-repository http://dl.openfoam.org/ubuntu sudo apt-get update sudo apt-get -y install openfoam5 - echo "::set-output name=openfoam_exec::. /opt/openfoam5/etc/bashrc &&";; + echo "{openfoam_exec}={. /opt/openfoam5/etc/bashrc &&}" >> $GITHUB_OUTPUT *) echo "I cannot find ${{ github.event.inputs.refAdapter }} in my known options." exit 1;; From f594d65462ec617af9339f32bbaad3f3f282ab0a Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Sat, 18 Feb 2023 23:35:20 +0100 Subject: [PATCH 04/60] Fix echo termination --- .github/workflows/build-custom.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-custom.yml b/.github/workflows/build-custom.yml index 86b58bdc..502b49e1 100644 --- a/.github/workflows/build-custom.yml +++ b/.github/workflows/build-custom.yml @@ -82,69 +82,69 @@ jobs: OpenFOAMv2212) wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash sudo apt-get install openfoam2212-dev - echo "{openfoam_exec}={/usr/bin/openfoam2212}" >> $GITHUB_OUTPUT + echo "{openfoam_exec}={/usr/bin/openfoam2212}" >> $GITHUB_OUTPUT;; OpenFOAMv2206) wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash sudo apt-get install openfoam2206-dev - echo "{openfoam_exec}={/usr/bin/openfoam2206}" >> $GITHUB_OUTPUT + echo "{openfoam_exec}={/usr/bin/openfoam2206}" >> $GITHUB_OUTPUT;; OpenFOAMv2112) wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash sudo apt-get install openfoam2112-dev - echo "{openfoam_exec}={/usr/bin/openfoam2112}" >> $GITHUB_OUTPUT + echo "{openfoam_exec}={/usr/bin/openfoam2112}" >> $GITHUB_OUTPUT;; OpenFOAMv2106) wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash sudo apt-get install openfoam2106-dev - echo "{openfoam_exec}={/usr/bin/openfoam2106}" >> $GITHUB_OUTPUT + echo "{openfoam_exec}={/usr/bin/openfoam2106}" >> $GITHUB_OUTPUT;; OpenFOAMv2012) wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash sudo apt-get install openfoam2012-dev - echo "{openfoam_exec}={/usr/bin/openfoam2012}" >> $GITHUB_OUTPUT + echo "{openfoam_exec}={/usr/bin/openfoam2012}" >> $GITHUB_OUTPUT;; OpenFOAMv2006) wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash sudo apt-get install openfoam2006-dev - echo "{openfoam_exec}={/usr/bin/openfoam2006}" >> $GITHUB_OUTPUT + echo "{openfoam_exec}={/usr/bin/openfoam2006}" >> $GITHUB_OUTPUT;; OpenFOAMv1912) wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash sudo apt-get install openfoam1912-dev - echo "{openfoam_exec}={/usr/bin/openfoam1912}" >> $GITHUB_OUTPUT + echo "{openfoam_exec}={/usr/bin/openfoam1912}" >> $GITHUB_OUTPUT;; OpenFOAM10) sudo sh -c "wget -O - https://dl.openfoam.org/gpg.key | apt-key add -" sudo add-apt-repository http://dl.openfoam.org/ubuntu sudo apt-get update sudo apt-get -y install openfoam10 - echo "{openfoam_exec}={. /opt/openfoam10/etc/bashrc &&}" >> $GITHUB_OUTPUT + echo "{openfoam_exec}={. /opt/openfoam10/etc/bashrc &&}" >> $GITHUB_OUTPUT;; OpenFOAM9) sudo sh -c "wget -O - https://dl.openfoam.org/gpg.key | apt-key add -" sudo add-apt-repository http://dl.openfoam.org/ubuntu sudo apt-get update sudo apt-get -y install openfoam9 - echo "{openfoam_exec}={. /opt/openfoam9/etc/bashrc &&}" >> $GITHUB_OUTPUT + echo "{openfoam_exec}={. /opt/openfoam9/etc/bashrc &&}" >> $GITHUB_OUTPUT;; OpenFOAM8) sudo sh -c "wget -O - https://dl.openfoam.org/gpg.key | apt-key add -" sudo add-apt-repository http://dl.openfoam.org/ubuntu sudo apt-get update sudo apt-get -y install openfoam8 - echo "{openfoam_exec}={. /opt/openfoam8/etc/bashrc &&}" >> $GITHUB_OUTPUT + echo "{openfoam_exec}={. /opt/openfoam8/etc/bashrc &&}" >> $GITHUB_OUTPUT;; OpenFOAM7) sudo sh -c "wget -O - https://dl.openfoam.org/gpg.key | apt-key add -" sudo add-apt-repository http://dl.openfoam.org/ubuntu sudo apt-get update sudo apt-get -y install openfoam7 - echo "{openfoam_exec}={. /opt/openfoam7/etc/bashrc &&}" >> $GITHUB_OUTPUT + echo "{openfoam_exec}={. /opt/openfoam7/etc/bashrc &&}" >> $GITHUB_OUTPUT;; OpenFOAM6) echo "OpenFOAM 6 is only available on Ubuntu 18.04 or older." sudo sh -c "wget -O - https://dl.openfoam.org/gpg.key | apt-key add -" sudo add-apt-repository http://dl.openfoam.org/ubuntu sudo apt-get update sudo apt-get -y install openfoam6 - echo "{openfoam_exec}={. /opt/openfoam6/etc/bashrc &&}" >> $GITHUB_OUTPUT + echo "{openfoam_exec}={. /opt/openfoam6/etc/bashrc &&}" >> $GITHUB_OUTPUT;; OpenFOAM5) echo "OpenFOAM 5 is only available on Ubuntu 18.04 or older." sudo sh -c "wget -O - https://dl.openfoam.org/gpg.key | apt-key add -" sudo add-apt-repository http://dl.openfoam.org/ubuntu sudo apt-get update sudo apt-get -y install openfoam5 - echo "{openfoam_exec}={. /opt/openfoam5/etc/bashrc &&}" >> $GITHUB_OUTPUT + echo "{openfoam_exec}={. /opt/openfoam5/etc/bashrc &&}" >> $GITHUB_OUTPUT;; *) echo "I cannot find ${{ github.event.inputs.refAdapter }} in my known options." exit 1;; From 365f01d77318b26a618abb9a6d8a824769e7dae0 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Wed, 22 Feb 2023 17:27:37 +0100 Subject: [PATCH 05/60] Document FFTW linking issues in Troubleshooting --- docs/get.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/get.md b/docs/get.md index a9d32dd4..a00e2a1f 100644 --- a/docs/get.md +++ b/docs/get.md @@ -96,3 +96,14 @@ This is a common problem e.g. when installing dependencies in non-system directo ### Rellocation-related errors Make sure to build both preCICE as a shared library (i.e. `.so`, not `.a`). + +### Undefined symbols from FFTW + +When building the adapter, it may fail to at the very end, reporting the following in the `ldd.log`: + +```text +undefined symbol: fftw_taint (/lib/x86_64-linux-gnu/libfftw3_mpi.so.3) +undefined symbol: fftw_join_taint (/lib/x86_64-linux-gnu/libfftw3_mpi.so.3) +``` + +This seems to always be related to building OpenFOAM from source, while also already having FFTW (an OpenFOAM dependency) installed. Removing FFTW from the `ThirdParty` directory of the OpenFOAM source code, and running `Allwmake` in OpenFOAM (and then also in the adapter) should help. This should also be very fast, as it will only relink, not rebuild. From b490b8d4aa2dc8c4659b5cb37057ee4f9e8713ac Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Wed, 22 Feb 2023 17:31:12 +0100 Subject: [PATCH 06/60] Documentation: Fix linter --- docs/get.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/get.md b/docs/get.md index a00e2a1f..1d7df04e 100644 --- a/docs/get.md +++ b/docs/get.md @@ -102,8 +102,8 @@ Make sure to build both preCICE as a shared library (i.e. `.so`, not `.a`). When building the adapter, it may fail to at the very end, reporting the following in the `ldd.log`: ```text -undefined symbol: fftw_taint (/lib/x86_64-linux-gnu/libfftw3_mpi.so.3) -undefined symbol: fftw_join_taint (/lib/x86_64-linux-gnu/libfftw3_mpi.so.3) +undefined symbol: fftw_taint (/lib/x86_64-linux-gnu/libfftw3_mpi.so.3) +undefined symbol: fftw_join_taint (/lib/x86_64-linux-gnu/libfftw3_mpi.so.3) ``` This seems to always be related to building OpenFOAM from source, while also already having FFTW (an OpenFOAM dependency) installed. Removing FFTW from the `ThirdParty` directory of the OpenFOAM source code, and running `Allwmake` in OpenFOAM (and then also in the adapter) should help. This should also be very fast, as it will only relink, not rebuild. From 62142fdf4e5183158bcf544539edede47f7b89e5 Mon Sep 17 00:00:00 2001 From: Max Hausch Date: Wed, 1 Mar 2023 20:31:12 +0100 Subject: [PATCH 07/60] Fix comment about WM_NCOMPPROCS in Allwmake WM_NCOMP_PROCS -> WM_NCOMPPROCS --- Allwmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Allwmake b/Allwmake index 371c0cb4..707f07bc 100755 --- a/Allwmake +++ b/Allwmake @@ -10,7 +10,7 @@ ADAPTER_PREP_FLAGS="" # Build command and options # In order to compile with multiple threads, set the environment variable WM_NCOMPPROCS, -# e.g., add "export WM_NCOMP_PROCS=4" to your ~/.bashrc +# e.g., add "export WM_NCOMPPROCS=4" to your ~/.bashrc # Make sure that these options are supported by your OpenFOAM version. adapter_build_command(){ wmake libso From 4d64d91df59ab6717fe9563685c0ef57899fdbf1 Mon Sep 17 00:00:00 2001 From: Max Hausch Date: Fri, 10 Mar 2023 15:28:54 +0100 Subject: [PATCH 08/60] Allow overriding of the ADAPTER_PREP_FLAGS variable (#283) * Allow overriding of the ADAPTER_PREP_FLAGS variable Currently the ADAPTER_PREP_FLAGS needs to be changed in the source code. This patch allows users to `export ADAPTER_PREP_FLAGS=` to alter the value of the variable through the environment without having to change the code. * Update docs/get.md --------- Co-authored-by: David Schneider --- Allwmake | 2 +- docs/get.md | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Allwmake b/Allwmake index 707f07bc..d74d9fcd 100755 --- a/Allwmake +++ b/Allwmake @@ -6,7 +6,7 @@ set -e -u # Optional: Preprocessor flags # "-DADAPTER_DEBUG_MODE" enables debug messages # "-DADAPTER_ENABLE_TIMINGS" enables time measurements -ADAPTER_PREP_FLAGS="" +ADAPTER_PREP_FLAGS="${ADAPTER_PREP_FLAGS:-}" # Build command and options # In order to compile with multiple threads, set the environment variable WM_NCOMPPROCS, diff --git a/docs/get.md b/docs/get.md index 1d7df04e..d9c3e708 100644 --- a/docs/get.md +++ b/docs/get.md @@ -16,6 +16,9 @@ To build the adapter, you need to install a few dependencies and then execute th The adapter also requires [pkg-config](https://linux.die.net/man/1/pkg-config) to [link to preCICE](https://precice.org/installation-linking.html). This is a very common dependency on Linux and is usually already installed. +You can set compile flags by either changing the `ADAPTER_PREP_FLAGS` variable in the `Allwmake` script, or directly setting the value of `ADAPTER_PREP_FLAGS` as an environment variable. +To do so, `export ADAPTER_PREP_FLAGS="-D -D"` before compiling the adapter. + Adding the `-DADAPTER_DEBUG_MODE` flag to the `ADAPTER_PREP_FLAGS` activates additional debug messages. You may also change the target directory or specify the number of threads to use for the compilation. See the comments in `Allwmake` for more. Adding the `-DADAPTER_ENABLE_TIMINGS` flag to the `ADAPTER_PREP_FLAGS` activates time measurements for several regions of the adapter, printed at the end of the simulation output (available since v1.2.0). From 97b9f72acfa959c27b940742db003d88548157b2 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Mon, 20 Mar 2023 13:09:35 +0100 Subject: [PATCH 09/60] Add a citation file --- CITATION.cff | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 CITATION.cff diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 00000000..2541a3a4 --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,36 @@ +cff-version: 1.2.0 +message: "If you use this software, please cite it as below." +authors: +- family-names: "Chourdakis" + given-names: "Gerasimos" + orcid: "https://orcid.org/0000-0002-3977-1385" +- family-names: "Schneider" + given-names: "David" + orcid: "https://orcid.org/0000-0002-3487-9688" +- family-names: "Uekermann" + given-names: "Benjamin" + orcid: "https://orcid.org/0000-0002-1314-9969" +title: "OpenFOAM-preCICE: Coupling OpenFOAM with External Solvers for Multi-Physics Simulations" +version: 1.1.0 +doi: 10.51560/ofj.v3.88 +date-released: 2022-02-08 +url: "https://journal.openfoam.com/index.php/ofj/article/view/88" +preferred-citation: + type: article + authors: +- family-names: "Chourdakis" + given-names: "Gerasimos" + orcid: "https://orcid.org/0000-0002-3977-1385" +- family-names: "Schneider" + given-names: "David" + orcid: "https://orcid.org/0000-0002-3487-9688" +- family-names: "Uekermann" + given-names: "Benjamin" + orcid: "https://orcid.org/0000-0002-1314-9969" + doi: "10.51560/ofj.v3.88" + journal: "OpenFOAM$^{\textregistered}$ Journal" + month: 2 + start: 1 # First page number + end: 25 # Last page number + volume: 3 + year: 2023 From bc819fab9cf87497f7b16d31912c3d38c8d3e3fc Mon Sep 17 00:00:00 2001 From: David Schneider Date: Mon, 20 Mar 2023 13:12:56 +0100 Subject: [PATCH 10/60] Fix indentation --- CITATION.cff | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index 2541a3a4..90d1eab4 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -18,15 +18,15 @@ url: "https://journal.openfoam.com/index.php/ofj/article/view/88" preferred-citation: type: article authors: -- family-names: "Chourdakis" - given-names: "Gerasimos" - orcid: "https://orcid.org/0000-0002-3977-1385" -- family-names: "Schneider" - given-names: "David" - orcid: "https://orcid.org/0000-0002-3487-9688" -- family-names: "Uekermann" - given-names: "Benjamin" - orcid: "https://orcid.org/0000-0002-1314-9969" + - family-names: "Chourdakis" + given-names: "Gerasimos" + orcid: "https://orcid.org/0000-0002-3977-1385" + - family-names: "Schneider" + given-names: "David" + orcid: "https://orcid.org/0000-0002-3487-9688" + - family-names: "Uekermann" + given-names: "Benjamin" + orcid: "https://orcid.org/0000-0002-1314-9969" doi: "10.51560/ofj.v3.88" journal: "OpenFOAM$^{\textregistered}$ Journal" month: 2 From 852cda2725a72b1e549294e89490987ad4ade5c8 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Mon, 20 Mar 2023 13:15:32 +0100 Subject: [PATCH 11/60] Experiment with textregistered --- CITATION.cff | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CITATION.cff b/CITATION.cff index 90d1eab4..0c949dd0 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -28,7 +28,7 @@ preferred-citation: given-names: "Benjamin" orcid: "https://orcid.org/0000-0002-1314-9969" doi: "10.51560/ofj.v3.88" - journal: "OpenFOAM$^{\textregistered}$ Journal" + journal: "OpenFOAM Journal" month: 2 start: 1 # First page number end: 25 # Last page number From c2f66dec82e7f0af0fd4f6d92a5f15ee171757c9 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Mon, 20 Mar 2023 13:22:27 +0100 Subject: [PATCH 12/60] Remove preferred citation for experimental purpose --- CITATION.cff | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index 0c949dd0..b727ac69 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -15,22 +15,3 @@ version: 1.1.0 doi: 10.51560/ofj.v3.88 date-released: 2022-02-08 url: "https://journal.openfoam.com/index.php/ofj/article/view/88" -preferred-citation: - type: article - authors: - - family-names: "Chourdakis" - given-names: "Gerasimos" - orcid: "https://orcid.org/0000-0002-3977-1385" - - family-names: "Schneider" - given-names: "David" - orcid: "https://orcid.org/0000-0002-3487-9688" - - family-names: "Uekermann" - given-names: "Benjamin" - orcid: "https://orcid.org/0000-0002-1314-9969" - doi: "10.51560/ofj.v3.88" - journal: "OpenFOAM Journal" - month: 2 - start: 1 # First page number - end: 25 # Last page number - volume: 3 - year: 2023 From 3cbb4dde4b93e97714aca6496bc4e5e92421e924 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Mon, 20 Mar 2023 13:25:14 +0100 Subject: [PATCH 13/60] Use preferred citation with template version --- CITATION.cff | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CITATION.cff b/CITATION.cff index b727ac69..3ba1879e 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -15,3 +15,21 @@ version: 1.1.0 doi: 10.51560/ofj.v3.88 date-released: 2022-02-08 url: "https://journal.openfoam.com/index.php/ofj/article/view/88" +preferred-citation: + type: article + authors: + - family-names: "Lisa" + given-names: "Mona" + orcid: "https://orcid.org/0000-0000-0000-0000" + - family-names: "Bot" + given-names: "Hew" + orcid: "https://orcid.org/0000-0000-0000-0000" + doi: "10.0000/00000" + journal: "Journal Title" + month: 9 + start: 1 # First page number + end: 10 # Last page number + title: "My awesome research software" + issue: 1 + volume: 1 + year: 2021 From 7a8c7e7fb93bbd6e2ea2076c907576b5a7e655b5 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Mon, 20 Mar 2023 13:25:57 +0100 Subject: [PATCH 14/60] Use correct authors --- CITATION.cff | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index 3ba1879e..54f112d5 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -16,14 +16,15 @@ doi: 10.51560/ofj.v3.88 date-released: 2022-02-08 url: "https://journal.openfoam.com/index.php/ofj/article/view/88" preferred-citation: - type: article - authors: - - family-names: "Lisa" - given-names: "Mona" - orcid: "https://orcid.org/0000-0000-0000-0000" - - family-names: "Bot" - given-names: "Hew" - orcid: "https://orcid.org/0000-0000-0000-0000" + - family-names: "Chourdakis" + given-names: "Gerasimos" + orcid: "https://orcid.org/0000-0002-3977-1385" + - family-names: "Schneider" + given-names: "David" + orcid: "https://orcid.org/0000-0002-3487-9688" + - family-names: "Uekermann" + given-names: "Benjamin" + orcid: "https://orcid.org/0000-0002-1314-9969" doi: "10.0000/00000" journal: "Journal Title" month: 9 From c6e5704935c3ba35bdca549ba8dc8f9dcbeda947 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Mon, 20 Mar 2023 13:27:51 +0100 Subject: [PATCH 15/60] Revert changes --- CITATION.cff | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index 54f112d5..f285d81c 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -16,21 +16,16 @@ doi: 10.51560/ofj.v3.88 date-released: 2022-02-08 url: "https://journal.openfoam.com/index.php/ofj/article/view/88" preferred-citation: - - family-names: "Chourdakis" - given-names: "Gerasimos" - orcid: "https://orcid.org/0000-0002-3977-1385" - - family-names: "Schneider" - given-names: "David" - orcid: "https://orcid.org/0000-0002-3487-9688" - - family-names: "Uekermann" - given-names: "Benjamin" - orcid: "https://orcid.org/0000-0002-1314-9969" - doi: "10.0000/00000" - journal: "Journal Title" - month: 9 + - family-names: "Lisa" + given-names: "Mona" + orcid: "https://orcid.org/0000-0000-0000-0000" + - family-names: "Bot" + given-names: "Hew" + orcid: "https://orcid.org/0000-0000-0000-0000" + doi: "10.51560/ofj.v3.88" + journal: "OpenFOAM Journal" + month: 2 start: 1 # First page number - end: 10 # Last page number - title: "My awesome research software" - issue: 1 - volume: 1 - year: 2021 + end: 25 # Last page number + volume: 3 + year: 2023 From dc48737f9939a3022bf230bf9016a7b7ee4f5604 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Mon, 20 Mar 2023 13:32:41 +0100 Subject: [PATCH 16/60] ... --- CITATION.cff | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index f285d81c..ca378a9f 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -16,16 +16,23 @@ doi: 10.51560/ofj.v3.88 date-released: 2022-02-08 url: "https://journal.openfoam.com/index.php/ofj/article/view/88" preferred-citation: - - family-names: "Lisa" - given-names: "Mona" - orcid: "https://orcid.org/0000-0000-0000-0000" - - family-names: "Bot" - given-names: "Hew" - orcid: "https://orcid.org/0000-0000-0000-0000" - doi: "10.51560/ofj.v3.88" - journal: "OpenFOAM Journal" - month: 2 + type: article + authors: + - family-names: "Chourdakis" + given-names: "Gerasimos" + orcid: "https://orcid.org/0000-0002-3977-1385" + - family-names: "Schneider" + given-names: "David" + orcid: "https://orcid.org/0000-0002-3487-9688" + - family-names: "Uekermann" + given-names: "Benjamin" + orcid: "https://orcid.org/0000-0002-1314-9969" + doi: "10.0000/00000" + journal: "Journal Title" + month: 9 start: 1 # First page number - end: 25 # Last page number - volume: 3 - year: 2023 + end: 10 # Last page number + title: "My awesome research software" + issue: 1 + volume: 1 + year: 2021 From 1dc293f422ba65dbf95a92adc79921f550d65cf7 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Mon, 20 Mar 2023 13:35:32 +0100 Subject: [PATCH 17/60] fill correct info --- CITATION.cff | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index ca378a9f..bd41fefb 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -27,12 +27,11 @@ preferred-citation: - family-names: "Uekermann" given-names: "Benjamin" orcid: "https://orcid.org/0000-0002-1314-9969" - doi: "10.0000/00000" - journal: "Journal Title" - month: 9 + doi: "10.51560/ofj.v3.88" + journal: "OpenFOAM® Journal" + month: 2 start: 1 # First page number - end: 10 # Last page number - title: "My awesome research software" - issue: 1 - volume: 1 - year: 2021 + end: 25 # Last page number + title: "OpenFOAM-preCICE: Coupling OpenFOAM with External Solvers for Multi-Physics Simulations" + volume: 3 + year: 2023 From b0c383e3845206eeeaf50bd9ab53d4af1d668ef9 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Tue, 11 Apr 2023 17:51:43 +0300 Subject: [PATCH 18/60] Add citing guidelines in README and docs (#287) Co-authored-by: David Schneider --- README.md | 21 +++++---------------- changelog-entries/287.md | 1 + docs/README.md | 25 +++++++++++++++++-------- 3 files changed, 23 insertions(+), 24 deletions(-) create mode 100644 changelog-entries/287.md diff --git a/README.md b/README.md index c9a186a0..c3d74a66 100644 --- a/README.md +++ b/README.md @@ -15,32 +15,21 @@ See the [adapter documentation](https://precice.org/adapter-openfoam-overview.ht Please [report any issues](https://github.com/precice/openfoam-adapter/issues) here and give us feedback through [one of our community channels](https://precice.org/community-channels.html). +This project is actively maintained on [precice/openfoam-adapter](https://github.com/precice/openfoam-adapter). Current maintainers: [@MakisH](https://github.com/MakisH/) and [@DavidSCN](https://github.com/DavidSCN). + ## Contributing We welcome contributions! Have a look at open [good first issues](https://github.com/precice/openfoam-adapter/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) and [where we need help](https://github.com/precice/openfoam-adapter/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22). Check the file `CONTRIBUTING.md` for a few tips and guidelines. -## History - -This project is actively maintained on [precice/openfoam-adapter](https://github.com/precice/openfoam-adapter). Current maintainers: [@MakisH](https://github.com/MakisH/) and [@DavidSCN](https://github.com/DavidSCN). - -This adapter was developed as part of [Gerasimos Chourdakis' master's thesis](https://mediatum.ub.tum.de/1462269) [1]. -It is based on [previous work](https://github.com/ludcila/CHT-preCICE) by Lucia Cheung ([master's thesis](https://www5.in.tum.de/pub/Cheung2016_Thesis.pdf) [2], in cooperation with [SimScale](https://www.simscale.com/)). +## Citing -The fluid-structure interaction module was developed in close collaboration between Gerasimos Chourdakis and Derek Risseeuw (TU Delft), in the context of the [master's thesis of the latter](http://resolver.tudelft.nl/uuid:70beddde-e870-4c62-9a2f-8758b4e49123) [3]. We would also like to thank David Schneider (Univ. Siegen / TUM) and Maximilian Müller (TU Braunschweig) for sharing the code and experience of their similar previous work. - -The fluid-fluid coupling module was added by Gerasimos Chourdakis, in the context of his dissertation. [#67](https://github.com/precice/openfoam-adapter/pull/67) - -The adapter is [easily extensible](https://precice.org/adapter-openfoam-extend.html). +Whenever using or referring to this adapter in academic publications, please cite it [1]. See the option "Cite this repository" in the "About" section, as well as the [preCICE literature guide](https://precice.org/fundamentals-literature-guide.html) and the [adapter overview page](https://precice.org/adapter-openfoam-overview.html) for more information. ## References -[1] Gerasimos Chourdakis. A general OpenFOAM adapter for the coupling library preCICE. Master's thesis, Department of Informatics, Technical University of Munich, 2017. - -[2] Lucia Cheung Yau. Conjugate heat transfer with the multiphysics coupling library preCICE. Master’s thesis, Department of Informatics, Technical University of Munich, 2016. - -[3] Derek Risseeuw. Fluid Structure Interaction Modelling of Flapping Wings. Master's thesis, Faculty of Aerospace Engineering, Delft University of Technology, 2019. +[1] Chourdakis, G., Schneider, D., & Uekermann, B. (2023). OpenFOAM-preCICE: Coupling OpenFOAM with External Solvers for Multi-Physics Simulations. OpenFOAM® Journal, 3, 1–25. [DOI: 10.51560/ofj.v3.88](https://doi.org/10.51560/ofj.v3.88) ## Disclaimer diff --git a/changelog-entries/287.md b/changelog-entries/287.md new file mode 100644 index 00000000..d4ae9a59 --- /dev/null +++ b/changelog-entries/287.md @@ -0,0 +1 @@ +- Added citing guidelines, referring to the [new reference article at the OpenFOAM Journal](https://doi.org/10.51560/ofj.v3.88). [#287](https://github.com/precice/openfoam-adapter/pull/287) diff --git a/docs/README.md b/docs/README.md index a1a437c5..3010bb7b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -43,21 +43,30 @@ our [training session from the 15th OpenFOAM Workshop](https://mediatum.ub.tum.d ## Cite -We are currently working on an up-to-date reference paper. Until then, please cite this adapter using [1]: +Please cite this adapter using our [reference paper in the OpenFOAM Journal](https://doi.org/10.51560/ofj.v3.88) [1]. See the [preCICE literature guide](https://precice.org/fundamentals-literature-guide.html) for more details. -```text -Gerasimos Chourdakis. A general OpenFOAM adapter for the coupling library preCICE. Master's thesis, Department of Informatics, Technical University of Munich, 2017. -``` +## History -For CHT-specific topics, you may want to additionally look into [2] and for FSI into [3]. +This project is actively maintained on [precice/openfoam-adapter](https://github.com/precice/openfoam-adapter). Current maintainers: [@MakisH](https://github.com/MakisH/) and [@DavidSCN](https://github.com/DavidSCN). + +This adapter was developed as part of [Gerasimos Chourdakis' master's thesis](https://mediatum.ub.tum.de/1462269) [2]. +It is based on [previous work](https://github.com/ludcila/CHT-preCICE) by Lucia Cheung ([master's thesis](https://www5.in.tum.de/pub/Cheung2016_Thesis.pdf) [3], in cooperation with [SimScale](https://www.simscale.com/)). + +The fluid-structure interaction module was developed in close collaboration between Gerasimos Chourdakis and Derek Risseeuw (TU Delft), in the context of the [master's thesis of the latter](http://resolver.tudelft.nl/uuid:70beddde-e870-4c62-9a2f-8758b4e49123) [4]. We would also like to thank David Schneider (Univ. Siegen / TUM) and Maximilian Müller (TU Braunschweig) for sharing the code and experience of their similar previous work. + +The fluid-fluid coupling module was added by Gerasimos Chourdakis, in the context of his dissertation. [#67](https://github.com/precice/openfoam-adapter/pull/67) + +The adapter is [easily extensible](https://precice.org/adapter-openfoam-extend.html). ### Related literature -[1] Gerasimos Chourdakis. [A general OpenFOAM adapter for the coupling library preCICE](https://mediatum.ub.tum.de/1462269). Master's thesis, Department of Informatics, Technical University of Munich, 2017. +[1] Chourdakis, G., Schneider, D., & Uekermann, B. (2023). OpenFOAM-preCICE: Coupling OpenFOAM with External Solvers for Multi-Physics Simulations. OpenFOAM® Journal, 3, 1–25. [DOI: 10.51560/ofj.v3.88](https://doi.org/10.51560/ofj.v3.88) + +[2] Gerasimos Chourdakis. A general OpenFOAM adapter for the coupling library preCICE. Master's thesis, Department of Informatics, Technical University of Munich, 2017. -[2] Lucia Cheung Yau. [Conjugate heat transfer with the multiphysics coupling library preCICE](http://www5.in.tum.de/pub/Cheung2016_Thesis.pdf). Master’s thesis, Department of Informatics, Technical University of Munich, 2016. +[3] Lucia Cheung Yau. Conjugate heat transfer with the multiphysics coupling library preCICE. Master’s thesis, Department of Informatics, Technical University of Munich, 2016. -[3] Derek Risseeuw. [Fluid Structure Interaction Modelling of Flapping Wings](https://repository.tudelft.nl/islandora/object/uuid:70beddde-e870-4c62-9a2f-8758b4e49123). Master's thesis, Faculty of Aerospace Engineering, Delft University of Technology, 2019. +[4] Derek Risseeuw. Fluid Structure Interaction Modelling of Flapping Wings. Master's thesis, Faculty of Aerospace Engineering, Delft University of Technology, 2019. {% disclaimer %} This offering is not approved or endorsed by OpenCFD Limited, producer and distributor of the OpenFOAM software via www.openfoam.com, and owner of the OPENFOAM® and OpenCFD® trade marks. From 846affdd00ea8024cee98f34d8ad4205fdc83c5f Mon Sep 17 00:00:00 2001 From: David Schneider Date: Fri, 19 May 2023 10:14:19 +0200 Subject: [PATCH 19/60] Fix iterator in FSI reader and writer for multiple patches (#289) * Fix iterator in FSI reader and writer for multiple patches * Add changelog entry --- FSI/Displacement.C | 12 +++++++----- FSI/DisplacementDelta.C | 5 +++-- FSI/Force.C | 3 ++- FSI/ForceBase.C | 3 ++- changelog-entries/289.md | 1 + 5 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 changelog-entries/289.md diff --git a/FSI/Displacement.C b/FSI/Displacement.C index a83c0a42..69baf676 100644 --- a/FSI/Displacement.C +++ b/FSI/Displacement.C @@ -48,6 +48,7 @@ void preciceAdapter::FSI::Displacement::write(double* buffer, bool meshConnectiv if (this->locationType_ == LocationType::faceCenters) { + int bufferIndex = 0; // For every boundary patch of the interface for (const label patchID : patchIDs_) { @@ -56,7 +57,7 @@ void preciceAdapter::FSI::Displacement::write(double* buffer, bool meshConnectiv forAll(cellDisplacement_->boundaryField()[patchID], i) { for (unsigned int d = 0; d < dim; ++d) - buffer[i * dim + d] = + buffer[bufferIndex++] = cellDisplacement_->boundaryField()[patchID][i][d]; } } @@ -69,6 +70,7 @@ void preciceAdapter::FSI::Displacement::write(double* buffer, bool meshConnectiv "See https://github.com/precice/openfoam-adapter/issues/153.", "warning")); + int bufferIndex = 0; // For every boundary patch of the interface for (const label patchID : patchIDs_) { @@ -80,7 +82,7 @@ void preciceAdapter::FSI::Displacement::write(double* buffer, bool meshConnectiv mesh_.boundaryMesh()[patchID].meshPoints(); for (unsigned int d = 0; d < dim; ++d) - buffer[i * dim + d] = + buffer[bufferIndex++] = pointDisplacement_->internalField()[meshPoints[i]][d]; } } @@ -91,6 +93,7 @@ void preciceAdapter::FSI::Displacement::write(double* buffer, bool meshConnectiv // return the displacement to use later in the velocity? void preciceAdapter::FSI::Displacement::read(double* buffer, const unsigned int dim) { + int bufferIndex = 0; for (unsigned int j = 0; j < patchIDs_.size(); j++) { // Get the ID of the current patch @@ -98,14 +101,13 @@ void preciceAdapter::FSI::Displacement::read(double* buffer, const unsigned int if (this->locationType_ == LocationType::faceCenters) { - // the boundaryCellDisplacement is a vector and ordered according to the iterator j // and not according to the patchID // First, copy the buffer data into the center based vectorFields on each interface patch forAll(cellDisplacement_->boundaryField()[patchID], i) { for (unsigned int d = 0; d < dim; ++d) - cellDisplacement_->boundaryFieldRef()[patchID][i][d] = buffer[i * dim + d]; + cellDisplacement_->boundaryFieldRef()[patchID][i][d] = buffer[bufferIndex++]; } if (pointDisplacement_ != nullptr) @@ -132,7 +134,7 @@ void preciceAdapter::FSI::Displacement::read(double* buffer, const unsigned int forAll(pointDisplacement_->boundaryFieldRef()[patchID], i) { for (unsigned int d = 0; d < dim; ++d) - pointDisplacementFluidPatch[i][d] = buffer[i * dim + d]; + pointDisplacementFluidPatch[i][d] = buffer[bufferIndex++]; } } } diff --git a/FSI/DisplacementDelta.C b/FSI/DisplacementDelta.C index 53b56240..19c93139 100644 --- a/FSI/DisplacementDelta.C +++ b/FSI/DisplacementDelta.C @@ -49,6 +49,7 @@ void preciceAdapter::FSI::DisplacementDelta::write(double* buffer, bool meshConn // return the displacement to use later in the velocity? void preciceAdapter::FSI::DisplacementDelta::read(double* buffer, const unsigned int dim) { + int bufferIndex = 0; for (unsigned int j = 0; j < patchIDs_.size(); j++) { // Get the ID of the current patch @@ -65,7 +66,7 @@ void preciceAdapter::FSI::DisplacementDelta::read(double* buffer, const unsigned forAll(cellDisplacement_->boundaryField()[patchID], i) { for (unsigned int d = 0; d < dim; ++d) - cellDisplacement_->boundaryFieldRef()[patchID][i][d] = buffer[i * dim + d]; + cellDisplacement_->boundaryFieldRef()[patchID][i][d] = buffer[bufferIndex++]; } // Get a reference to the displacement on the point patch in order to overwrite it vectorField& pointDisplacementFluidPatch( @@ -88,7 +89,7 @@ void preciceAdapter::FSI::DisplacementDelta::read(double* buffer, const unsigned forAll(pointDisplacement_->boundaryFieldRef()[patchID], i) { for (unsigned int d = 0; d < dim; ++d) - pointDisplacementFluidPatch[i][d] += buffer[i * dim + d]; + pointDisplacementFluidPatch[i][d] += buffer[bufferIndex++]; } } } diff --git a/FSI/Force.C b/FSI/Force.C index 5f829645..a1ab6651 100644 --- a/FSI/Force.C +++ b/FSI/Force.C @@ -48,6 +48,7 @@ void preciceAdapter::FSI::Force::read(double* buffer, const unsigned int dim) // Here we assume that a force volVectorField exists, which is used by // the OpenFOAM solver + int bufferIndex = 0; // Set boundary forces for (unsigned int j = 0; j < patchIDs_.size(); j++) { @@ -63,7 +64,7 @@ void preciceAdapter::FSI::Force::read(double* buffer, const unsigned int dim) forAll(force, i) { for (unsigned int d = 0; d < dim; ++d) - force[i][d] = buffer[i * dim + d]; + force[i][d] = buffer[bufferIndex++]; } } else if (this->locationType_ == LocationType::faceNodes) diff --git a/FSI/ForceBase.C b/FSI/ForceBase.C index 57f36875..4e9168b0 100644 --- a/FSI/ForceBase.C +++ b/FSI/ForceBase.C @@ -148,6 +148,7 @@ void preciceAdapter::FSI::ForceBase::writeToBuffer(double* buffer, // Pressure boundary field const auto& pb = mesh_.lookupObject("p").boundaryField(); + int bufferIndex = 0; // For every boundary patch of the interface for (const label patchID : patchIDs_) { @@ -183,7 +184,7 @@ void preciceAdapter::FSI::ForceBase::writeToBuffer(double* buffer, forAll(forceField.boundaryField()[patchID], i) { for (unsigned int d = 0; d < dim; ++d) - buffer[i * dim + d] = + buffer[bufferIndex++] = forceField.boundaryField()[patchID][i][d]; } } diff --git a/changelog-entries/289.md b/changelog-entries/289.md new file mode 100644 index 00000000..71486dd8 --- /dev/null +++ b/changelog-entries/289.md @@ -0,0 +1 @@ +- Fixed incorrect reading and writing of the FSI-related data buffers, if multiple patches are combined in an interface mesh. From f91e2047e23e5924a7bf7f5864376750c198fbc7 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Fri, 19 May 2023 12:15:13 +0300 Subject: [PATCH 20/60] Markdown-lint: Disable MD034 (#290) --- .markdownlint.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.markdownlint.json b/.markdownlint.json index 151ee39b..979cb285 100644 --- a/.markdownlint.json +++ b/.markdownlint.json @@ -1,4 +1,5 @@ { "MD013": false, - "MD033": false -} \ No newline at end of file + "MD033": false, + "MD034": false +} From 25f9798da00eb9ef38d96109fb2dab3eaec310a2 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Sat, 20 May 2023 16:53:35 +0300 Subject: [PATCH 21/60] Add note in docs regarding OpenFOAM9 residualControl name Related to https://github.com/precice/tutorials/pull/337 --- docs/openfoam-support.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/openfoam-support.md b/docs/openfoam-support.md index 901aae3d..7e4d025e 100644 --- a/docs/openfoam-support.md +++ b/docs/openfoam-support.md @@ -35,6 +35,7 @@ We provide version-specific [release archives](https://github.com/precice/openfo - Same limitations as for OpenFOAM 9. - [OpenFOAM 9](https://github.com/precice/openfoam-adapter/tree/OpenFOAM9) - Rename `solver` to `motionSolver` in `constant/dynamicMeshDict`. + - Modify also `residualControl` to `outerCorrectorResidualControl` in `system/fvSolution`. - Limitations in adjustable time step size ([#261](https://github.com/precice/openfoam-adapter/issues/261)). - [OpenFOAM 8](https://github.com/precice/openfoam-adapter/tree/OpenFOAM8) - [OpenFOAM 7](https://github.com/precice/openfoam-adapter/tree/OpenFOAM7) From 98e448f9e421c4759ac6a753fbf2e373d53b18de Mon Sep 17 00:00:00 2001 From: David Schneider Date: Tue, 20 Jun 2023 12:34:49 +0200 Subject: [PATCH 22/60] Re-arrange `if` logic for Pstream initialization (#293) * Skip pstream initialization for OpenFOAM < 2306 * Re-arrange 'if' logic for Pstream init --- preciceAdapterFunctionObject.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/preciceAdapterFunctionObject.C b/preciceAdapterFunctionObject.C index 3dea534a..b13581a9 100644 --- a/preciceAdapterFunctionObject.C +++ b/preciceAdapterFunctionObject.C @@ -51,7 +51,7 @@ Foam::functionObjects::preciceAdapterFunctionObject::preciceAdapterFunctionObjec adapter_(runTime, mesh_) { -#if (defined OPENFOAM_PLUS && (OPENFOAM_PLUS >= 1712)) || (defined OPENFOAM && (OPENFOAM >= 1806)) +#if (defined OPENFOAM && (OPENFOAM >= 1806)) || (defined OPENFOAM_PLUS && (OPENFOAM_PLUS >= 1712)) // Patch for issue #27: warning "MPI was already finalized" while // running in serial. This only affects openfoam.com, while initNull() // does not exist in openfoam.org. From 69f4fd21d2d11c5f129c1b5ddc31a32e99fa6b57 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Tue, 20 Jun 2023 15:13:54 +0200 Subject: [PATCH 23/60] Rectify version specifications for OPENFOAM and OPENFOAM_PLUS - as pointed out in https://github.com/precice/openfoam-adapter/pull/293 --- preciceAdapterFunctionObject.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/preciceAdapterFunctionObject.C b/preciceAdapterFunctionObject.C index b13581a9..92a4cd4e 100644 --- a/preciceAdapterFunctionObject.C +++ b/preciceAdapterFunctionObject.C @@ -51,7 +51,7 @@ Foam::functionObjects::preciceAdapterFunctionObject::preciceAdapterFunctionObjec adapter_(runTime, mesh_) { -#if (defined OPENFOAM && (OPENFOAM >= 1806)) || (defined OPENFOAM_PLUS && (OPENFOAM_PLUS >= 1712)) +#if (defined OPENFOAM && (OPENFOAM >= 1712)) || (defined OPENFOAM_PLUS && (OPENFOAM_PLUS >= 1712)) // Patch for issue #27: warning "MPI was already finalized" while // running in serial. This only affects openfoam.com, while initNull() // does not exist in openfoam.org. From e00bfcda61485328ddf73cddfd72096029cbb262 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Tue, 20 Jun 2023 15:20:02 +0200 Subject: [PATCH 24/60] Bump version from v1.2.3 to v1.2.3 + unreleased changes --- Adapter.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Adapter.C b/Adapter.C index c4c3e988..cab5ae92 100644 --- a/Adapter.C +++ b/Adapter.C @@ -10,7 +10,7 @@ preciceAdapter::Adapter::Adapter(const Time& runTime, const fvMesh& mesh) : runTime_(runTime), mesh_(mesh) { - adapterInfo("Loaded the OpenFOAM-preCICE adapter - v1.2.3.", "info"); + adapterInfo("Loaded the OpenFOAM-preCICE adapter - v1.2.3 + unreleased changes.", "info"); return; } From ff19340cf920534241945d9304180e30621e2d0d Mon Sep 17 00:00:00 2001 From: David Schneider Date: Tue, 20 Jun 2023 17:35:31 +0200 Subject: [PATCH 25/60] Add simple script to create release archives (#294) * Add simple script to create all the release archives * Rename variable * Update tools/create-release-archives.sh Co-authored-by: David Schneider * Update tools/create-release-archives.sh Co-authored-by: David Schneider * Apply suggestions from code review (trial 3) Co-authored-by: Gerasimos Chourdakis --------- Co-authored-by: Gerasimos Chourdakis --- tools/create-release-archives.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 tools/create-release-archives.sh diff --git a/tools/create-release-archives.sh b/tools/create-release-archives.sh new file mode 100755 index 00000000..fb0fc986 --- /dev/null +++ b/tools/create-release-archives.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# Execute this script from the top-level directory (./tools/create-release-archives.sh) + +set -u + +remote_name=origin +adapter_version="v1.2.3" + +# Declare branch names for which archives will be created +declare -a branches=("master" "OpenFOAMv1806" "OpenFOAM10" "OpenFOAM9" "OpenFOAM8" "OpenFOAM7" "OpenFOAM6" "OpenFOAM5" "OpenFOAM4") + +mkdir -p release-archives +for i in "${branches[@]}" + do + archive_name=openefoam-adapter-"${adapter_version}"-"${i}" + git archive --format=tar.gz --prefix="${archive_name}"/ "${remote_name}"/"${i}" >"release-archives/${archive_name}".tar.gz +done From a2362f3435ed31d08454871d0b50f422e320b82b Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Mon, 24 Jul 2023 22:14:44 +0300 Subject: [PATCH 26/60] Bump default OpenFOAM version to v2306 (#296) --- .github/workflows/build-custom.yml | 14 ++++++++++++-- .github/workflows/build.yml | 6 +++--- .github/workflows/install-dependencies.sh | 9 +++++---- README.md | 2 +- changelog-entries/296.md | 1 + docs/openfoam-support.md | 10 +++++----- 6 files changed, 27 insertions(+), 15 deletions(-) create mode 100644 changelog-entries/296.md diff --git a/.github/workflows/build-custom.yml b/.github/workflows/build-custom.yml index 502b49e1..f8eea0a1 100644 --- a/.github/workflows/build-custom.yml +++ b/.github/workflows/build-custom.yml @@ -8,6 +8,7 @@ on: required: true type: choice options: + - ubuntu-22.04 - ubuntu-20.04 - ubuntu-18.04 refAdapter: @@ -19,6 +20,7 @@ on: required: true type: choice options: + - OpenFOAMv2306 - OpenFOAMv2212 - OpenFOAMv2206 - OpenFOAMv2112 @@ -34,7 +36,7 @@ on: - OpenFOAM5 versionpreCICE: description: 'Version of preCICE to build with' - default: '2.3.0' + default: '2.5.0' required: true runTutorialHeatedPlate: description: Run tutorial flow-over-heated-plate @@ -79,6 +81,10 @@ jobs: id: installOpenFOAM run: | case "${{ github.event.inputs.versionOpenFOAM }}" in + OpenFOAMv2306) + wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash + sudo apt-get install openfoam2306-dev + echo "{openfoam_exec}={/usr/bin/openfoam2306}" >> $GITHUB_OUTPUT;; OpenFOAMv2212) wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash sudo apt-get install openfoam2212-dev @@ -151,7 +157,11 @@ jobs: esac - name: Install preCICE (no cache) run: | - if [ "${{ github.event.inputs.virtualEnvironment }}" == "ubuntu-20.04" ] + if [ "${{ github.event.inputs.virtualEnvironment }}" == "ubuntu-22.04" ] + then + wget "https://github.com/precice/precice/releases/download/v${{ github.event.inputs.versionpreCICE }}/libprecice2_${{ github.event.inputs.versionpreCICE }}_jammy.deb" + sudo apt install "./libprecice2_${{ github.event.inputs.versionpreCICE }}_jammy.deb" + elif [ "${{ github.event.inputs.virtualEnvironment }}" == "ubuntu-20.04" ] then wget "https://github.com/precice/precice/releases/download/v${{ github.event.inputs.versionpreCICE }}/libprecice2_${{ github.event.inputs.versionpreCICE }}_focal.deb" sudo apt install "./libprecice2_${{ github.event.inputs.versionpreCICE }}_focal.deb" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fd80140a..5e5c7031 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build with OpenFOAM v2212 +name: Build with OpenFOAM v2306 on: push: branches-ignore: @@ -20,7 +20,7 @@ on: - 'README.md' jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Check out repository uses: actions/checkout@v2 @@ -39,4 +39,4 @@ jobs: snapshot: '/' exclude: '/boot /data /dev /mnt /proc /run /sys' - name: Build OpenFOAM-preCICE adapter - run: /usr/bin/openfoam2212 ./Allwmake + run: /usr/bin/openfoam2306 ./Allwmake diff --git a/.github/workflows/install-dependencies.sh b/.github/workflows/install-dependencies.sh index b670d65c..890b7a41 100755 --- a/.github/workflows/install-dependencies.sh +++ b/.github/workflows/install-dependencies.sh @@ -1,9 +1,10 @@ #!/bin/bash -e -# Install OpenFOAM v2212 +# Install OpenFOAM v2306 wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash -sudo apt-get install openfoam2212-dev +sudo apt-get update +sudo apt-get install openfoam2306-dev # Install preCICE v2.5.0 -wget https://github.com/precice/precice/releases/download/v2.5.0/libprecice2_2.5.0_focal.deb -sudo apt install ./libprecice2_2.5.0_focal.deb +wget https://github.com/precice/precice/releases/download/v2.5.0/libprecice2_2.5.0_jammy.deb +sudo apt install ./libprecice2_2.5.0_jammy.deb diff --git a/README.md b/README.md index c3d74a66..d31a4de9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # OpenFOAM-preCICE adapter -[![Build with OpenFOAM v2212](https://github.com/precice/openfoam-adapter/actions/workflows/build.yml/badge.svg?branch=develop)](https://github.com/precice/openfoam-adapter/actions/workflows/build.yml) +[![Build with OpenFOAM v2306](https://github.com/precice/openfoam-adapter/actions/workflows/build.yml/badge.svg?branch=develop)](https://github.com/precice/openfoam-adapter/actions/workflows/build.yml) [![Changelog](https://img.shields.io/badge/Keep%20a%20Changelog--555.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9IiNmMTVkMzAiIHZpZXdCb3g9IjAgMCAxODcgMTg1Ij48cGF0aCBkPSJNNjIgN2MtMTUgMy0yOCAxMC0zNyAyMmExMjIgMTIyIDAgMDAtMTggOTEgNzQgNzQgMCAwMDE2IDM4YzYgOSAxNCAxNSAyNCAxOGE4OSA4OSAwIDAwMjQgNCA0NSA0NSAwIDAwNiAwbDMtMSAxMy0xYTE1OCAxNTggMCAwMDU1LTE3IDYzIDYzIDAgMDAzNS01MiAzNCAzNCAwIDAwLTEtNWMtMy0xOC05LTMzLTE5LTQ3LTEyLTE3LTI0LTI4LTM4LTM3QTg1IDg1IDAgMDA2MiA3em0zMCA4YzIwIDQgMzggMTQgNTMgMzEgMTcgMTggMjYgMzcgMjkgNTh2MTJjLTMgMTctMTMgMzAtMjggMzhhMTU1IDE1NSAwIDAxLTUzIDE2bC0xMyAyaC0xYTUxIDUxIDAgMDEtMTItMWwtMTctMmMtMTMtNC0yMy0xMi0yOS0yNy01LTEyLTgtMjQtOC0zOWExMzMgMTMzIDAgMDE4LTUwYzUtMTMgMTEtMjYgMjYtMzMgMTQtNyAyOS05IDQ1LTV6TTQwIDQ1YTk0IDk0IDAgMDAtMTcgNTQgNzUgNzUgMCAwMDYgMzJjOCAxOSAyMiAzMSA0MiAzMiAyMSAyIDQxLTIgNjAtMTRhNjAgNjAgMCAwMDIxLTE5IDUzIDUzIDAgMDA5LTI5YzAtMTYtOC0zMy0yMy01MWE0NyA0NyAwIDAwLTUtNWMtMjMtMjAtNDUtMjYtNjctMTgtMTIgNC0yMCA5LTI2IDE4em0xMDggNzZhNTAgNTAgMCAwMS0yMSAyMmMtMTcgOS0zMiAxMy00OCAxMy0xMSAwLTIxLTMtMzAtOS01LTMtOS05LTEzLTE2YTgxIDgxIDAgMDEtNi0zMiA5NCA5NCAwIDAxOC0zNSA5MCA5MCAwIDAxNi0xMmwxLTJjNS05IDEzLTEzIDIzLTE2IDE2LTUgMzItMyA1MCA5IDEzIDggMjMgMjAgMzAgMzYgNyAxNSA3IDI5IDAgNDJ6bS00My03M2MtMTctOC0zMy02LTQ2IDUtMTAgOC0xNiAyMC0xOSAzN2E1NCA1NCAwIDAwNSAzNGM3IDE1IDIwIDIzIDM3IDIyIDIyLTEgMzgtOSA0OC0yNGE0MSA0MSAwIDAwOC0yNCA0MyA0MyAwIDAwLTEtMTJjLTYtMTgtMTYtMzEtMzItMzh6bS0yMyA5MWgtMWMtNyAwLTE0LTItMjEtN2EyNyAyNyAwIDAxLTEwLTEzIDU3IDU3IDAgMDEtNC0yMCA2MyA2MyAwIDAxNi0yNWM1LTEyIDEyLTE5IDI0LTIxIDktMyAxOC0yIDI3IDIgMTQgNiAyMyAxOCAyNyAzM3MtMiAzMS0xNiA0MGMtMTEgOC0yMSAxMS0zMiAxMXptMS0zNHYxNGgtOFY2OGg4djI4bDEwLTEwaDExbC0xNCAxNSAxNyAxOEg5NnoiLz48L3N2Zz4K)](https://github.com/precice/openfoam-adapter/blob/develop/CHANGELOG.md) GNU GPL license diff --git a/changelog-entries/296.md b/changelog-entries/296.md new file mode 100644 index 00000000..34c70abd --- /dev/null +++ b/changelog-entries/296.md @@ -0,0 +1 @@ +- Changed the default OpenFOAM version to v2306 in the documentation and CI diff --git a/docs/openfoam-support.md b/docs/openfoam-support.md index 7e4d025e..72868ff1 100644 --- a/docs/openfoam-support.md +++ b/docs/openfoam-support.md @@ -7,14 +7,14 @@ summary: Recent OpenFOAM.com versions work out-of-the-box. Recent OpenFOAM.org v ## How to get OpenFOAM -The easiest way to start is to get binary packages for your Linux distribution. For example, to [get OpenFOAM v2212 on Ubuntu](https://develop.openfoam.com/Development/openfoam/-/wikis/precompiled/debian#precompiled-packages-debianubuntu): +The easiest way to start is to get binary packages for your Linux distribution. For example, to [get OpenFOAM v2306 on Ubuntu](https://develop.openfoam.com/Development/openfoam/-/wikis/precompiled/debian#precompiled-packages-debianubuntu): ```bash # Add the signing key, add the repository, update: wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash -# Install OpenFOAM v2212: -sudo apt-get install openfoam2212-dev +# Install OpenFOAM v2306: +sudo apt-get install openfoam2306-dev ``` As these steps change your `.profile`, you need to log out and in again to make OpenFOAM fully discoverable. @@ -26,8 +26,8 @@ OpenFOAM is a project with long history and many forks, of which we try to suppo We provide version-specific [release archives](https://github.com/precice/openfoam-adapter/releases/latest) and respective Git branches for: - OpenCFD / ESI (openfoam.com) - main focus: - - [OpenFOAM v1812-v2212](https://github.com/precice/openfoam-adapter) or newer - - OpenFOAM v2212 is only supported since v1.2.2 of the adapter. + - [OpenFOAM v1812-v2306](https://github.com/precice/openfoam-adapter) or newer + - OpenFOAM v2212 and newer is only supported since v1.2.2 of the adapter. - [OpenFOAM v1612-v1806](https://github.com/precice/openfoam-adapter/tree/OpenFOAMv1806) (not tested) - OpenFOAM Foundation (openfoam.org) - secondary, consider experimental: - [OpenFOAM 10](https://github.com/precice/openfoam-adapter/tree/OpenFOAM10) From d573d0da6493184e4915cd0a20fe87acb2086e9b Mon Sep 17 00:00:00 2001 From: David Schneider Date: Thu, 27 Jul 2023 10:58:37 +0200 Subject: [PATCH 27/60] Merge `initializeData` into `initialize` (#262) --- Adapter.C | 13 ++++--------- Adapter.H | 1 - changelog-entries/262.md | 1 + 3 files changed, 5 insertions(+), 10 deletions(-) create mode 100644 changelog-entries/262.md diff --git a/Adapter.C b/Adapter.C index cab5ae92..dd9ba648 100644 --- a/Adapter.C +++ b/Adapter.C @@ -532,10 +532,6 @@ void preciceAdapter::Adapter::initialize() { DEBUG(adapterInfo("Initializing the preCICE solver interface...")); SETUP_TIMER(); - timestepPrecice_ = precice_->initialize(); - ACCUMULATE_TIMER(timeInInitialize_); - - preciceInitialized_ = true; if (precice_->isActionRequired(precice::constants::actionWriteInitialData())) { @@ -544,9 +540,9 @@ void preciceAdapter::Adapter::initialize() } DEBUG(adapterInfo("Initializing preCICE data...")); - REUSE_TIMER(); - precice_->initializeData(); - ACCUMULATE_TIMER(timeInInitializeData_); + timestepPrecice_ = precice_->initialize(); + preciceInitialized_ = true; + ACCUMULATE_TIMER(timeInInitialize_); adapterInfo("preCICE was configured and initialized", "info"); @@ -1660,9 +1656,8 @@ preciceAdapter::Adapter::~Adapter() Info << " (I) writing checkpoints: " << timeInCheckpointingWrite_.str() << nl; Info << " (I) reading checkpoints: " << timeInCheckpointingRead_.str() << nl; Info << " (I) writing OpenFOAM results: " << timeInWriteResults_.str() << " (at the end of converged time windows)" << nl << nl; - Info << "Time exclusively in preCICE: " << (timeInInitialize_ + timeInInitializeData_ + timeInAdvance_ + timeInFinalize_).str() << nl; + Info << "Time exclusively in preCICE: " << (timeInInitialize_ + timeInAdvance_ + timeInFinalize_).str() << nl; Info << " (S) initialize(): " << timeInInitialize_.str() << nl; - Info << " (S) initializeData(): " << timeInInitializeData_.str() << nl; Info << " (I) advance(): " << timeInAdvance_.str() << nl; Info << " (I) finalize(): " << timeInFinalize_.str() << nl; Info << " These times include time waiting for other participants." << nl; diff --git a/Adapter.H b/Adapter.H index f94fd9c5..5dacf841 100644 --- a/Adapter.H +++ b/Adapter.H @@ -54,7 +54,6 @@ private: clockValue timeInPreciceConstruct_; clockValue timeInMeshSetup_; clockValue timeInInitialize_; - clockValue timeInInitializeData_; clockValue timeInCheckpointingSetup_; clockValue timeInWrite_; clockValue timeInAdvance_; diff --git a/changelog-entries/262.md b/changelog-entries/262.md new file mode 100644 index 00000000..7609e361 --- /dev/null +++ b/changelog-entries/262.md @@ -0,0 +1 @@ +- Merged `initializeData` into `initialize` [#262](https://github.com/precice/openfoam-adapter/pull/262). From 0022e330bc8f5d6115c977936948578b2e3753e2 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Mon, 21 Nov 2022 13:55:48 +0100 Subject: [PATCH 28/60] Add changelog --- docs/changelog-entries/262.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/changelog-entries/262.md diff --git a/docs/changelog-entries/262.md b/docs/changelog-entries/262.md new file mode 100644 index 00000000..7609e361 --- /dev/null +++ b/docs/changelog-entries/262.md @@ -0,0 +1 @@ +- Merged `initializeData` into `initialize` [#262](https://github.com/precice/openfoam-adapter/pull/262). From dcc22aa3bc2a9bbde2dcb7b45ddfab99dd678788 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Fri, 9 Dec 2022 15:29:25 +0100 Subject: [PATCH 29/60] Replace actions by explicit calls --- Adapter.C | 35 ++++++++--------------------------- Adapter.H | 10 ++-------- 2 files changed, 10 insertions(+), 35 deletions(-) diff --git a/Adapter.C b/Adapter.C index dd9ba648..bd341dfb 100644 --- a/Adapter.C +++ b/Adapter.C @@ -350,7 +350,7 @@ void preciceAdapter::Adapter::configure() // If checkpointing is required, specify the checkpointed fields // and write the first checkpoint - if (isWriteCheckpointRequired()) + if (requiresWritingCheckpoint()) { checkpointing_ = true; @@ -359,7 +359,6 @@ void preciceAdapter::Adapter::configure() // Write checkpoint (for the first iteration) writeCheckpoint(); - fulfilledWriteCheckpoint(); } // Adjust the timestep for the first iteration, if it is fixed @@ -421,10 +420,9 @@ void preciceAdapter::Adapter::execute() advance(); // Read checkpoint if required - if (isReadCheckpointRequired()) + if (requiresReadingCheckpoint()) { readCheckpoint(); - fulfilledReadCheckpoint(); } // Adjust the timestep, if it is fixed @@ -434,10 +432,9 @@ void preciceAdapter::Adapter::execute() } // Write checkpoint if required - if (isWriteCheckpointRequired()) + if (requiresWritingCheckpoint()) { writeCheckpoint(); - fulfilledWriteCheckpoint(); } // As soon as OpenFOAM writes the results, it will not try to write again @@ -533,11 +530,8 @@ void preciceAdapter::Adapter::initialize() DEBUG(adapterInfo("Initializing the preCICE solver interface...")); SETUP_TIMER(); - if (precice_->isActionRequired(precice::constants::actionWriteInitialData())) - { + if (precice_->requiresInitialData()) writeCouplingData(); - precice_->markActionFulfilled(precice::constants::actionWriteInitialData()); - } DEBUG(adapterInfo("Initializing preCICE data...")); timestepPrecice_ = precice_->initialize(); @@ -704,29 +698,16 @@ bool preciceAdapter::Adapter::isCouplingTimeWindowComplete() return precice_->isTimeWindowComplete(); } -bool preciceAdapter::Adapter::isReadCheckpointRequired() +bool preciceAdapter::Adapter::requiresReadingCheckpoint() { - return precice_->isActionRequired(precice::constants::actionReadIterationCheckpoint()); + return precice_->requiresReadingCheckpoint(); } -bool preciceAdapter::Adapter::isWriteCheckpointRequired() +bool preciceAdapter::Adapter::requiresWritingCheckpoint() { - return precice_->isActionRequired(precice::constants::actionWriteIterationCheckpoint()); + return precice_->requiresWritingCheckpoint(); } -void preciceAdapter::Adapter::fulfilledReadCheckpoint() -{ - precice_->markActionFulfilled(precice::constants::actionReadIterationCheckpoint()); - - return; -} - -void preciceAdapter::Adapter::fulfilledWriteCheckpoint() -{ - precice_->markActionFulfilled(precice::constants::actionWriteIterationCheckpoint()); - - return; -} void preciceAdapter::Adapter::storeCheckpointTime() { diff --git a/Adapter.H b/Adapter.H index 5dacf841..73a05d94 100644 --- a/Adapter.H +++ b/Adapter.H @@ -279,16 +279,10 @@ private: bool isCouplingTimeWindowComplete(); //- Determine if a checkpoint must be read - bool isReadCheckpointRequired(); + bool requiresReadingCheckpoint(); //- Determine if a checkpoint must be written - bool isWriteCheckpointRequired(); - - //- Tell preCICE that the checkpoint has been read - void fulfilledReadCheckpoint(); - - //- Tell preCICE that the checkpoint has been written - void fulfilledWriteCheckpoint(); + bool requiresWritingCheckpoint(); // Methods for checkpointing From f886ed1ebeb50fb7b4dc5708d462a9b750a96be5 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Mon, 20 Mar 2023 15:08:59 +0100 Subject: [PATCH 30/60] Port data and mesh IDs to actual names --- CouplingDataUser.C | 10 ++++------ CouplingDataUser.H | 12 ++++++------ Interface.C | 25 +++++++++++++------------ 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/CouplingDataUser.C b/CouplingDataUser.C index 7e84250d..7aeaf8ad 100644 --- a/CouplingDataUser.C +++ b/CouplingDataUser.C @@ -14,16 +14,14 @@ bool preciceAdapter::CouplingDataUser::hasVectorData() return dataType_ == vector; } -void preciceAdapter::CouplingDataUser::setDataID(int dataID) +void preciceAdapter::CouplingDataUser::setDataName(std::string dataName) { - dataID_ = dataID; - - return; + dataName_ = std::move(dataName); } -int preciceAdapter::CouplingDataUser::dataID() +const std::string& preciceAdapter::CouplingDataUser::dataName() { - return dataID_; + return dataName_; } void preciceAdapter::CouplingDataUser::setPatchIDs(std::vector patchIDs) diff --git a/CouplingDataUser.H b/CouplingDataUser.H index 3c994790..ea69537b 100644 --- a/CouplingDataUser.H +++ b/CouplingDataUser.H @@ -32,8 +32,8 @@ protected: //- OpenFOAM patches that form the interface std::vector patchIDs_; - //- preCICE data ID - int dataID_; + //- data name + std::string dataName_; //- location type of the interface LocationType locationType_ = LocationType::none; @@ -48,11 +48,11 @@ public: //- Returns true if the data are vector bool hasVectorData(); - //- Set the preCICE data ID - void setDataID(int dataID); + //- Set the data name + void setDataName(std::string dataName); - //- Get the preCICE data ID - int dataID(); + //- Get the data name + const std::string& dataName(); //- Set the patch IDs that form the interface void setPatchIDs(std::vector patchIDs); diff --git a/Interface.C b/Interface.C index 694f2b54..34fe7669 100644 --- a/Interface.C +++ b/Interface.C @@ -21,9 +21,6 @@ preciceAdapter::Interface::Interface( meshConnectivity_(meshConnectivity), restartFromDeformed_(restartFromDeformed) { - // Get the meshID from preCICE - meshID_ = precice_.getMeshID(meshName_); - dim_ = precice_.getDimensions(); if (dim_ == 2 && meshConnectivity_ == true) @@ -181,7 +178,7 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh, const std::str } // Pass the mesh vertices information to preCICE - precice_.setMeshVertices(meshID_, numDataLocations_, vertices, vertexIDs_); + precice_.setMeshVertices(meshName_, numDataLocations_, vertices, vertexIDs_); } else if (locationType_ == LocationType::faceNodes) { @@ -242,7 +239,7 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh, const std::str } // Pass the mesh vertices information to preCICE - precice_.setMeshVertices(meshID_, numDataLocations_, vertices, vertexIDs_); + precice_.setMeshVertices(meshName_, numDataLocations_, vertices, vertexIDs_); // meshConnectivity for prototype neglected // Only set the triangles, if necessary @@ -325,8 +322,8 @@ void preciceAdapter::Interface::addCouplingDataWriter( std::string dataName, CouplingDataUser* couplingDataWriter) { - // Set the dataID (from preCICE) - couplingDataWriter->setDataID(precice_.getDataID(dataName, meshID_)); + // Set the data name (from preCICE) + couplingDataWriter->setDataName(dataName); // Set the patchIDs of the patches that form the interface couplingDataWriter->setPatchIDs(patchIDs_); @@ -350,7 +347,7 @@ void preciceAdapter::Interface::addCouplingDataReader( preciceAdapter::CouplingDataUser* couplingDataReader) { // Set the patchIDs of the patches that form the interface - couplingDataReader->setDataID(precice_.getDataID(dataName, meshID_)); + couplingDataReader->setDataName(dataName); // Add the CouplingDataUser to the list of readers couplingDataReader->setPatchIDs(patchIDs_); @@ -426,7 +423,8 @@ void preciceAdapter::Interface::readCouplingData() if (couplingDataReader->hasVectorData()) { precice_.readBlockVectorData( - couplingDataReader->dataID(), + meshName_, + couplingDataReader->dataName(), numDataLocations_, vertexIDs_, dataBuffer_); @@ -434,7 +432,8 @@ void preciceAdapter::Interface::readCouplingData() else { precice_.readBlockScalarData( - couplingDataReader->dataID(), + meshName_, + couplingDataReader->dataName(), numDataLocations_, vertexIDs_, dataBuffer_); @@ -465,7 +464,8 @@ void preciceAdapter::Interface::writeCouplingData() if (couplingDataWriter->hasVectorData()) { precice_.writeBlockVectorData( - couplingDataWriter->dataID(), + meshName_, + couplingDataWriter->dataName(), numDataLocations_, vertexIDs_, dataBuffer_); @@ -473,7 +473,8 @@ void preciceAdapter::Interface::writeCouplingData() else { precice_.writeBlockScalarData( - couplingDataWriter->dataID(), + meshName_, + couplingDataWriter->dataName(), numDataLocations_, vertexIDs_, dataBuffer_); From e920e59165f95b33fca482223bb72d73ef2b177b Mon Sep 17 00:00:00 2001 From: David Schneider Date: Mon, 3 Jul 2023 14:29:35 +0200 Subject: [PATCH 31/60] Latest changes from develop --- Adapter.C | 17 +++++++----- Adapter.H | 6 ++--- Interface.C | 77 ++++++++++++++++------------------------------------- Interface.H | 12 ++++----- 4 files changed, 42 insertions(+), 70 deletions(-) diff --git a/Adapter.C b/Adapter.C index bd341dfb..0835d62b 100644 --- a/Adapter.C +++ b/Adapter.C @@ -246,7 +246,7 @@ void preciceAdapter::Adapter::configure() DEBUG(adapterInfo("Creating the preCICE solver interface...")); DEBUG(adapterInfo(" Number of processes: " + std::to_string(Pstream::nProcs()))); DEBUG(adapterInfo(" MPI rank: " + std::to_string(Pstream::myProcNo()))); - precice_ = new precice::SolverInterface(participantName_, preciceConfigFilename_, Pstream::myProcNo(), Pstream::nProcs()); + precice_ = new precice::Participant(participantName_, preciceConfigFilename_, Pstream::myProcNo(), Pstream::nProcs()); DEBUG(adapterInfo(" preCICE solver interface was created.")); ACCUMULATE_TIMER(timeInPreciceConstruct_); @@ -346,7 +346,7 @@ void preciceAdapter::Adapter::configure() initialize(); // Read the received coupling data - readCouplingData(); + readCouplingData(runTime_.deltaT().value()); // If checkpointing is required, specify the checkpointed fields // and write the first checkpoint @@ -459,7 +459,8 @@ void preciceAdapter::Adapter::execute() ACCUMULATE_TIMER(timeInWriteResults_); // Read the received coupling data from the buffer - readCouplingData(); + // Fits to an implicit Euler + readCouplingData(runTime_.deltaT().value()); // If the coupling is not going to continue, tear down everything // and stop the simulation. @@ -495,14 +496,14 @@ void preciceAdapter::Adapter::adjustTimeStep() return; } -void preciceAdapter::Adapter::readCouplingData() +void preciceAdapter::Adapter::readCouplingData(double relativeReadTime) { SETUP_TIMER(); DEBUG(adapterInfo("Reading coupling data...")); for (uint i = 0; i < interfaces_.size(); i++) { - interfaces_.at(i)->readCouplingData(); + interfaces_.at(i)->readCouplingData(relativeReadTime); } ACCUMULATE_TIMER(timeInRead_); @@ -534,7 +535,8 @@ void preciceAdapter::Adapter::initialize() writeCouplingData(); DEBUG(adapterInfo("Initializing preCICE data...")); - timestepPrecice_ = precice_->initialize(); + precice_->initialize(); + timestepPrecice_ = precice_->getMaxTimeStepSize(); preciceInitialized_ = true; ACCUMULATE_TIMER(timeInInitialize_); @@ -572,7 +574,8 @@ void preciceAdapter::Adapter::advance() DEBUG(adapterInfo("Advancing preCICE...")); SETUP_TIMER(); - timestepPrecice_ = precice_->advance(timestepSolver_); + precice_->advance(timestepSolver_); + timestepPrecice_ = precice_->getMaxTimeStepSize(); ACCUMULATE_TIMER(timeInAdvance_); return; diff --git a/Adapter.H b/Adapter.H index 73a05d94..0f5ef548 100644 --- a/Adapter.H +++ b/Adapter.H @@ -22,7 +22,7 @@ #include "fvMesh.H" // preCICE Solver Interface -#include "precice/SolverInterface.hpp" +#include namespace preciceAdapter { @@ -105,7 +105,7 @@ private: std::vector interfaces_; //- preCICE solver interface - precice::SolverInterface* precice_ = NULL; + precice::Participant* precice_ = NULL; //- preCICE solver interface initialized bool preciceInitialized_ = false; @@ -264,7 +264,7 @@ private: void advance(); //- Read the coupling data at each interface - void readCouplingData(); + void readCouplingData(double relativeReadTime); //- Write the coupling data at each interface void writeCouplingData(); diff --git a/Interface.C b/Interface.C index 34fe7669..d070f63a 100644 --- a/Interface.C +++ b/Interface.C @@ -6,7 +6,7 @@ using namespace Foam; preciceAdapter::Interface::Interface( - precice::SolverInterface& precice, + precice::Participant& precice, const fvMesh& mesh, std::string meshName, std::string locationsType, @@ -21,7 +21,7 @@ preciceAdapter::Interface::Interface( meshConnectivity_(meshConnectivity), restartFromDeformed_(restartFromDeformed) { - dim_ = precice_.getDimensions(); + dim_ = precice_.getMeshDimensions(meshName); if (dim_ == 2 && meshConnectivity_ == true) { @@ -97,11 +97,11 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh, const std::str // Array of the mesh vertices. // One mesh is used for all the patches and each vertex has 3D coordinates. - double vertices[dim_ * numDataLocations_]; + std::vector vertices(dim_ * numDataLocations_); // Array of the indices of the mesh vertices. // Each vertex has one index, but three coordinates. - vertexIDs_ = new int[numDataLocations_]; + vertexIDs_.resize(numDataLocations_); // Initialize the index of the vertices array int verticesIndex = 0; @@ -178,7 +178,7 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh, const std::str } // Pass the mesh vertices information to preCICE - precice_.setMeshVertices(meshName_, numDataLocations_, vertices, vertexIDs_); + precice_.setMeshVertices(meshName_, vertices, vertexIDs_); } else if (locationType_ == LocationType::faceNodes) { @@ -198,11 +198,11 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh, const std::str // Array of the mesh vertices. // One mesh is used for all the patches and each vertex has 3D coordinates. - double vertices[dim_ * numDataLocations_]; + std::vector vertices(dim_ * numDataLocations_); // Array of the indices of the mesh vertices. // Each vertex has one index, but three coordinates. - vertexIDs_ = new int[numDataLocations_]; + vertexIDs_.resize(numDataLocations_); // Initialize the index of the vertices array int verticesIndex = 0; @@ -239,7 +239,7 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh, const std::str } // Pass the mesh vertices information to preCICE - precice_.setMeshVertices(meshName_, numDataLocations_, vertices, vertexIDs_); + precice_.setMeshVertices(meshName_, vertices, vertexIDs_); // meshConnectivity for prototype neglected // Only set the triangles, if necessary @@ -406,10 +406,10 @@ void preciceAdapter::Interface::createBuffer() // scalar and vector coupling data users in an interface. With the current // preCICE implementation, it should work as, when writing scalars, // it should only use the first 1/3 elements of the buffer. - dataBuffer_ = new double[dataBufferSize](); + dataBuffer_.resize(dataBufferSize); } -void preciceAdapter::Interface::readCouplingData() +void preciceAdapter::Interface::readCouplingData(double relativeReadTime) { // Make every coupling data reader read for (uint i = 0; i < couplingDataReaders_.size(); i++) @@ -420,27 +420,15 @@ void preciceAdapter::Interface::readCouplingData() // Make preCICE read vector or scalar data // and fill the adapter's buffer - if (couplingDataReader->hasVectorData()) - { - precice_.readBlockVectorData( - meshName_, - couplingDataReader->dataName(), - numDataLocations_, - vertexIDs_, - dataBuffer_); - } - else - { - precice_.readBlockScalarData( - meshName_, - couplingDataReader->dataName(), - numDataLocations_, - vertexIDs_, - dataBuffer_); - } + precice_.readData( + meshName_, + couplingDataReader->dataName(), + vertexIDs_, + relativeReadTime, + dataBuffer_); // Read the received data from the buffer - couplingDataReader->read(dataBuffer_, dim_); + couplingDataReader->read(dataBuffer_.data(), dim_); } } @@ -458,27 +446,14 @@ void preciceAdapter::Interface::writeCouplingData() couplingDataWriter = couplingDataWriters_.at(i); // Write the data into the adapter's buffer - couplingDataWriter->write(dataBuffer_, meshConnectivity_, dim_); + couplingDataWriter->write(dataBuffer_.data(), meshConnectivity_, dim_); // Make preCICE write vector or scalar data - if (couplingDataWriter->hasVectorData()) - { - precice_.writeBlockVectorData( - meshName_, - couplingDataWriter->dataName(), - numDataLocations_, - vertexIDs_, - dataBuffer_); - } - else - { - precice_.writeBlockScalarData( - meshName_, - couplingDataWriter->dataName(), - numDataLocations_, - vertexIDs_, - dataBuffer_); - } + precice_.writeData( + meshName_, + couplingDataWriter->dataName(), + vertexIDs_, + dataBuffer_); } // } } @@ -498,10 +473,4 @@ preciceAdapter::Interface::~Interface() delete couplingDataWriters_.at(i); } couplingDataWriters_.clear(); - - // Delete the vertexIDs_ - delete[] vertexIDs_; - - // Delete the shared data buffer - delete[] dataBuffer_; } diff --git a/Interface.H b/Interface.H index 3d05329e..27221030 100644 --- a/Interface.H +++ b/Interface.H @@ -5,7 +5,7 @@ #include #include "fvCFD.H" #include "CouplingDataUser.H" -#include "precice/SolverInterface.hpp" +#include #include "pointPatchField.H" @@ -16,7 +16,7 @@ class Interface { protected: //- preCICE solver interface - precice::SolverInterface& precice_; + precice::Participant& precice_; //- Mesh name used in the preCICE configuration std::string meshName_; @@ -37,10 +37,10 @@ protected: int numDataLocations_ = 0; //- Vertex IDs assigned by preCICE - int* vertexIDs_; + std::vector vertexIDs_; //- Buffer for the coupling data - double* dataBuffer_; + std::vector dataBuffer_; //- Vector of CouplingDataReaders std::vector couplingDataReaders_; @@ -66,7 +66,7 @@ protected: public: //- Constructor Interface( - precice::SolverInterface& precice, + precice::Participant& precice, const Foam::fvMesh& mesh, std::string meshName, std::string locationsType, @@ -94,7 +94,7 @@ public: //- Call read() on each registered couplingDataReader to read the coupling // data from the buffer and apply the boundary conditions - void readCouplingData(); + void readCouplingData(double relativeReadTime); //- Call write() on each registered couplingDataWriter to extract the boundary // data and write them into the buffer From dc6d86419d0b5d86f35170b32be3eeb289bccd9b Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 27 Jul 2023 11:03:40 +0200 Subject: [PATCH 32/60] Add changelog entry --- changelog-entries/285.md | 1 + docs/changelog-entries/262.md | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 changelog-entries/285.md delete mode 100644 docs/changelog-entries/262.md diff --git a/changelog-entries/285.md b/changelog-entries/285.md new file mode 100644 index 00000000..e45be422 --- /dev/null +++ b/changelog-entries/285.md @@ -0,0 +1 @@ +- Ported the adapter to preCICE v3. The adapter is not compatible with v2 anymore. [#285](https://github.com/precice/openfoam-adapter/pull/285) diff --git a/docs/changelog-entries/262.md b/docs/changelog-entries/262.md deleted file mode 100644 index 7609e361..00000000 --- a/docs/changelog-entries/262.md +++ /dev/null @@ -1 +0,0 @@ -- Merged `initializeData` into `initialize` [#262](https://github.com/precice/openfoam-adapter/pull/262). From dfb2f63028d570b508d69194fdc3f2a052e1d4e5 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 27 Jul 2023 11:06:25 +0200 Subject: [PATCH 33/60] Update documentation --- docs/get.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/get.md b/docs/get.md index d9c3e708..b2fb53f9 100644 --- a/docs/get.md +++ b/docs/get.md @@ -8,7 +8,7 @@ summary: "Get the code from GitHub and run ./Allwmake. If this fails, look into To build the adapter, you need to install a few dependencies and then execute the `Allwmake` script. 1. Install [a compatible OpenFOAM distribution](https://precice.org/adapter-openfoam-support.html). -2. Install [preCICE](https://precice.org/installation-overview.html). +2. Install [preCICE v3](https://precice.org/installation-overview.html). In case you need preCICE v2, please install an older version of the adapter (v1.2.3 is the latest release to support preCICE v2). 3. [Download the latest release](https://github.com/precice/openfoam-adapter/releases/latest) for your OpenFOAM version. 4. Execute the build script: `./Allwmake`. * See and adjust the configuration in the beginning of the script first, if needed. From 9e41eef571a9b9e44814182ddddfda6dfdb20d79 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 27 Jul 2023 11:08:14 +0200 Subject: [PATCH 34/60] Convert NULL to nullptr --- Adapter.H | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Adapter.H b/Adapter.H index 0f5ef548..2e56e21e 100644 --- a/Adapter.H +++ b/Adapter.H @@ -105,7 +105,7 @@ private: std::vector interfaces_; //- preCICE solver interface - precice::Participant* precice_ = NULL; + precice::Participant* precice_ = nullptr; //- preCICE solver interface initialized bool preciceInitialized_ = false; From a8f19453328ee82f8e50912b223e855f926f79b0 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Mon, 7 Aug 2023 13:31:17 +0300 Subject: [PATCH 35/60] Mesh connectivity for preCICE v3 (#297) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: David Schneider Co-authored-by: Frédéric Simonis --- Interface.C | 48 +++++++++++++++++++++++----------------- changelog-entries/297.md | 1 + 2 files changed, 29 insertions(+), 20 deletions(-) create mode 100644 changelog-entries/297.md diff --git a/Interface.C b/Interface.C index d070f63a..69926525 100644 --- a/Interface.C +++ b/Interface.C @@ -207,6 +207,9 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh, const std::str // Initialize the index of the vertices array int verticesIndex = 0; + // Map between OpenFOAM vertices and preCICE vertex IDs + std::map, int> verticesMap; + // Get the locations of the mesh vertices (here: face nodes) // for all the patches for (uint j = 0; j < patchIDs_.size(); j++) @@ -234,17 +237,30 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh, const std::str // Assign the (x,y,z) locations to the vertices // TODO: Ensure consistent order when writing/reading for (int i = 0; i < faceNodes.size(); i++) + { for (unsigned int d = 0; d < dim_; ++d) + { vertices[verticesIndex++] = faceNodes[i][d]; + } + if (meshConnectivity_) + { + verticesMap.emplace(std::make_tuple(faceNodes[i][0], faceNodes[i][1], faceNodes[i][2]), -1); + } + } } // Pass the mesh vertices information to preCICE precice_.setMeshVertices(meshName_, vertices, vertexIDs_); - // meshConnectivity for prototype neglected - // Only set the triangles, if necessary if (meshConnectivity_) { + // Build the map between OpenFOAM vertices and preCICE vertex IDs + verticesIndex = 0; + for (auto& key : verticesMap) + { + key.second = vertexIDs_[verticesIndex++]; + } + for (uint j = 0; j < patchIDs_.size(); j++) { // Define triangles @@ -263,7 +279,6 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh, const std::str // Define constants const int triaPerQuad = 2; const int nodesPerTria = 3; - const int componentsPerNode = 3; // Get the list of faces and coordinates at the interface patch const List faceField = mesh.boundaryMesh()[patchIDs_.at(j)].localFaces(); @@ -277,41 +292,34 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh, const std::str pointCoords -= resetField; } - // Array to store coordinates in preCICE format - double triCoords[faceField.size() * triaPerQuad * nodesPerTria * componentsPerNode]; - - unsigned int coordIndex = 0; + //Array to store the IDs we get from preCICE + std::vector triVertIDs; + triVertIDs.reserve(faceField.size() * triaPerQuad * nodesPerTria); - // Iterate over faces + // Triangulate all faces and collect set of nodes that form triangles, + // which are used to set mesh triangles in preCICE. forAll(faceField, facei) { const face& faceQuad = faceField[facei]; + // Triangulate the face faceTriangulation faceTri(pointCoords, faceQuad, false); + // Iterate over all triangles generated out of each (quad) face for (uint triIndex = 0; triIndex < triaPerQuad; triIndex++) { + // Get the vertex that corresponds to the x,y,z coordinates of each node of a triangle for (uint nodeIndex = 0; nodeIndex < nodesPerTria; nodeIndex++) { - for (uint xyz = 0; xyz < componentsPerNode; xyz++) - triCoords[coordIndex++] = pointCoords[faceTri[triIndex][nodeIndex]][xyz]; + triVertIDs.push_back(verticesMap.at(std::make_tuple(pointCoords[faceTri[triIndex][nodeIndex]][0], pointCoords[faceTri[triIndex][nodeIndex]][1], pointCoords[faceTri[triIndex][nodeIndex]][2]))); } } } - //Array to store the IDs we get from preCICE - int triVertIDs[faceField.size() * (triaPerQuad * nodesPerTria)]; - - //Get preCICE IDs - precice_.getMeshVertexIDsFromPositions(meshID_, faceField.size() * (triaPerQuad * nodesPerTria), triCoords, triVertIDs); - DEBUG(adapterInfo("Number of triangles: " + std::to_string(faceField.size() * triaPerQuad))); //Set Triangles - for (int facei = 0; facei < faceField.size() * triaPerQuad; facei++) - { - precice_.setMeshTriangleWithEdges(meshID_, triVertIDs[facei * nodesPerTria], triVertIDs[facei * nodesPerTria + 1], triVertIDs[facei * nodesPerTria + 2]); - } + precice_.setMeshTriangles(meshName_, triVertIDs); } } } diff --git a/changelog-entries/297.md b/changelog-entries/297.md new file mode 100644 index 00000000..664eb17e --- /dev/null +++ b/changelog-entries/297.md @@ -0,0 +1 @@ +- Changed the way mesh connectivity (face triangles) are provided to preCICE, adapting to preCICE v3 [#297](https://github.com/precice/openfoam-adapter/pull/297) From 68f3bba06dfa4d86861ec50e0e27539571cc58f7 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 10 Aug 2023 11:09:29 +0300 Subject: [PATCH 36/60] Switch CI to build preCICE from develop (#299) --- .github/workflows/build.yml | 12 ++++++++---- .../{install-dependencies.sh => install-openfoam.sh} | 4 ---- changelog-entries/299.md | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) rename .github/workflows/{install-dependencies.sh => install-openfoam.sh} (50%) create mode 100644 changelog-entries/299.md diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5e5c7031..50569407 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,20 +23,24 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Check out repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup caches - uses: actions/cache@v2 + uses: actions/cache@v3 id: cache-id with: path: ${{ runner.temp }}/cache-directory key: ${{ runner.os }}-cache-dependencies-v1.0 - - name: Install dependencies (considering cache) + - name: Install OpenFOAM (considering cache) uses: airvzxf/cache-anything-new-action@v1.0.1 with: - script: 'install-dependencies.sh' + script: 'install-openfoam.sh' is_cached: ${{ steps.cache-id.outputs.cache-hit }} cache: ${{ runner.temp }}/cache-directory snapshot: '/' exclude: '/boot /data /dev /mnt /proc /run /sys' + - name: Install preCICE + uses: precice/setup-precice-action@main + with: + precice-version: develop - name: Build OpenFOAM-preCICE adapter run: /usr/bin/openfoam2306 ./Allwmake diff --git a/.github/workflows/install-dependencies.sh b/.github/workflows/install-openfoam.sh similarity index 50% rename from .github/workflows/install-dependencies.sh rename to .github/workflows/install-openfoam.sh index 890b7a41..99788a3f 100755 --- a/.github/workflows/install-dependencies.sh +++ b/.github/workflows/install-openfoam.sh @@ -4,7 +4,3 @@ wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash sudo apt-get update sudo apt-get install openfoam2306-dev - -# Install preCICE v2.5.0 -wget https://github.com/precice/precice/releases/download/v2.5.0/libprecice2_2.5.0_jammy.deb -sudo apt install ./libprecice2_2.5.0_jammy.deb diff --git a/changelog-entries/299.md b/changelog-entries/299.md new file mode 100644 index 00000000..ea0e4583 --- /dev/null +++ b/changelog-entries/299.md @@ -0,0 +1 @@ +- The Build CI workflow now relies on the setup-precice-action to install preCICE [#299](https://github.com/precice/openfoam-adapter/pull/299) From cc95becf0e2bcc0ce31833d69a3d494bec7b97f8 Mon Sep 17 00:00:00 2001 From: Tina Vladimirova <56878810+tirgendetwas@users.noreply.github.com> Date: Tue, 15 Aug 2023 19:06:57 +0200 Subject: [PATCH 37/60] Add volume coupling feature (#255) Co-authored-by: ge72fah Co-authored-by: Gerasimos Chourdakis --- Adapter.C | 24 ++++++- Adapter.H | 1 + CHT/HeatFlux.C | 2 +- CHT/HeatTransferCoefficient.C | 2 +- CHT/SinkTemperature.C | 2 +- CHT/Temperature.C | 54 +++++++++++++++- CHT/Temperature.H | 1 + CouplingDataUser.C | 7 ++ CouplingDataUser.H | 9 ++- FF/Pressure.C | 59 ++++++++++++++++- FF/Pressure.H | 1 + FF/Velocity.C | 116 +++++++++++++++++++++++++++++++-- FF/Velocity.H | 1 + Interface.C | 117 ++++++++++++++++++++++++++++++++++ Interface.H | 4 ++ changelog-entries/255.md | 1 + changelog-entries/270.md | 1 + docs/README.md | 12 +++- docs/config.md | 99 +++++++++++++++++++++++++++- 19 files changed, 496 insertions(+), 17 deletions(-) create mode 100644 changelog-entries/255.md create mode 100644 changelog-entries/270.md diff --git a/Adapter.C b/Adapter.C index 0835d62b..f49f8f80 100644 --- a/Adapter.C +++ b/Adapter.C @@ -101,9 +101,9 @@ bool preciceAdapter::Adapter::configFileRead() // By default, assume that no mesh connectivity is required (i.e. no nearest-projection mapping) interfaceConfig.meshConnectivity = interfaceDict.lookupOrDefault("connectivity", false); // Mesh connectivity only makes sense in case of faceNodes, check and raise a warning otherwise - if (interfaceConfig.meshConnectivity && interfaceConfig.locationsType == "faceCenters") + if (interfaceConfig.meshConnectivity && (interfaceConfig.locationsType == "faceCenters" || interfaceConfig.locationsType == "volumeCenters" || interfaceConfig.locationsType == "volumeCentres")) { - DEBUG(adapterInfo("Mesh connectivity is not supported for faceCenters. \n" + DEBUG(adapterInfo("Mesh connectivity is not supported for faceCenters or volumeCenters. \n" "Please configure the desired interface with the locationsType faceNodes. \n" "Have a look in the adapter documentation for detailed information.", "warning")); @@ -119,6 +119,24 @@ bool preciceAdapter::Adapter::configFileRead() DEBUG(adapterInfo(" - " + patch)); } + DEBUG(adapterInfo(" cellSets : ")); + auto cellSets = interfaceDict.lookupOrDefault("cellSets", wordList()); + + for (auto cellSet : cellSets) + { + interfaceConfig.cellSetNames.push_back(cellSet); + DEBUG(adapterInfo(" - " + cellSet)); + } + + if (!interfaceConfig.cellSetNames.empty() && !(interfaceConfig.locationsType == "volumeCenters" || interfaceConfig.locationsType == "volumeCentres")) + { + adapterInfo("Cell sets are not supported for locationType != volumeCenters. \n" + "Please configure the desired interface with the locationsType volumeCenters. \n" + "Have a look in the adapter documentation for detailed information.", + "warning"); + return false; + } + DEBUG(adapterInfo(" writeData : ")); auto writeData = interfaceDict.get("writeData"); for (auto writeDatum : writeData) @@ -260,7 +278,7 @@ void preciceAdapter::Adapter::configure() std::string nameCellDisplacement = FSIenabled_ ? FSI_->getCellDisplacementFieldName() : "default"; bool restartFromDeformed = FSIenabled_ ? FSI_->isRestartingFromDeformed() : false; - Interface* interface = new Interface(*precice_, mesh_, interfacesConfig_.at(i).meshName, interfacesConfig_.at(i).locationsType, interfacesConfig_.at(i).patchNames, interfacesConfig_.at(i).meshConnectivity, restartFromDeformed, namePointDisplacement, nameCellDisplacement); + Interface* interface = new Interface(*precice_, mesh_, interfacesConfig_.at(i).meshName, interfacesConfig_.at(i).locationsType, interfacesConfig_.at(i).patchNames, interfacesConfig_.at(i).cellSetNames, interfacesConfig_.at(i).meshConnectivity, restartFromDeformed, namePointDisplacement, nameCellDisplacement); interfaces_.push_back(interface); DEBUG(adapterInfo("Interface created on mesh " + interfacesConfig_.at(i).meshName)); diff --git a/Adapter.H b/Adapter.H index 2e56e21e..2112898b 100644 --- a/Adapter.H +++ b/Adapter.H @@ -41,6 +41,7 @@ private: std::string locationsType; bool meshConnectivity; std::vector patchNames; + std::vector cellSetNames; std::vector writeData; std::vector readData; }; diff --git a/CHT/HeatFlux.C b/CHT/HeatFlux.C index 27dcfa41..2c7d1fb3 100644 --- a/CHT/HeatFlux.C +++ b/CHT/HeatFlux.C @@ -111,7 +111,7 @@ bool preciceAdapter::CHT::HeatFlux::isLocationTypeSupported(const bool meshConne // always return true and offload the handling to the user. if (meshConnectivity) { - return true; + return (this->locationType_ == LocationType::faceCenters || this->locationType_ == LocationType::faceNodes); // we currently do not support meshConnectivity for volumeCenters } else { diff --git a/CHT/HeatTransferCoefficient.C b/CHT/HeatTransferCoefficient.C index 8da03c09..ccd9bb7b 100644 --- a/CHT/HeatTransferCoefficient.C +++ b/CHT/HeatTransferCoefficient.C @@ -124,7 +124,7 @@ bool preciceAdapter::CHT::HeatTransferCoefficient::isLocationTypeSupported(const // always return true and offload the handling to the user. if (meshConnectivity) { - return true; + return (this->locationType_ == LocationType::faceCenters || this->locationType_ == LocationType::faceNodes); // we currently do not support meshConnectivity for volumeCenters } else { diff --git a/CHT/SinkTemperature.C b/CHT/SinkTemperature.C index f373d650..8d2498a7 100644 --- a/CHT/SinkTemperature.C +++ b/CHT/SinkTemperature.C @@ -101,7 +101,7 @@ bool preciceAdapter::CHT::SinkTemperature::isLocationTypeSupported(const bool me // always return true and offload the handling to the user. if (meshConnectivity) { - return true; + return (this->locationType_ == LocationType::faceCenters || this->locationType_ == LocationType::faceNodes); // we currently do not support meshConnectivity for volumeCenters } else { diff --git a/CHT/Temperature.C b/CHT/Temperature.C index 3756471c..4452da2a 100644 --- a/CHT/Temperature.C +++ b/CHT/Temperature.C @@ -19,6 +19,31 @@ void preciceAdapter::CHT::Temperature::write(double* buffer, bool meshConnectivi { int bufferIndex = 0; + if (this->locationType_ == LocationType::volumeCenters) + { + if (cellSetNames_.empty()) + { + for (const auto& cell : T_->internalField()) + { + buffer[bufferIndex++] = cell; + } + } + else + { + for (const auto& cellSetName : cellSetNames_) + { + cellSet overlapRegion(T_->mesh(), cellSetName); + const labelList& cells = overlapRegion.toc(); + + for (const auto& currentCell : cells) + { + // Copy temperature into the buffer + buffer[bufferIndex++] = T_->internalField()[currentCell]; + } + } + } + } + // For every boundary patch of the interface for (uint j = 0; j < patchIDs_.size(); j++) { @@ -60,6 +85,31 @@ void preciceAdapter::CHT::Temperature::read(double* buffer, const unsigned int d { int bufferIndex = 0; + if (this->locationType_ == LocationType::volumeCenters) + { + if (cellSetNames_.empty()) + { + for (auto& cell : T_->ref()) + { + cell = buffer[bufferIndex++]; + } + } + else + { + for (const auto& cellSetName : cellSetNames_) + { + cellSet overlapRegion(T_->mesh(), cellSetName); + const labelList& cells = overlapRegion.toc(); + + for (const auto& currentCell : cells) + { + // Copy temperature into the buffer + T_->ref()[currentCell] = buffer[bufferIndex++]; + } + } + } + } + // For every boundary patch of the interface for (uint j = 0; j < patchIDs_.size(); j++) { @@ -84,11 +134,11 @@ bool preciceAdapter::CHT::Temperature::isLocationTypeSupported(const bool meshCo // always return true and offload the handling to the user. if (meshConnectivity) { - return true; + return (this->locationType_ == LocationType::faceCenters || this->locationType_ == LocationType::faceNodes); // we currently do not support meshConnectivity for volumeCenters } else { - return (this->locationType_ == LocationType::faceCenters); + return (this->locationType_ == LocationType::faceCenters || this->locationType_ == LocationType::volumeCenters); } } diff --git a/CHT/Temperature.H b/CHT/Temperature.H index d3e17d5b..cd776272 100644 --- a/CHT/Temperature.H +++ b/CHT/Temperature.H @@ -4,6 +4,7 @@ #include "CouplingDataUser.H" #include "fvCFD.H" +#include "cellSet.H" namespace preciceAdapter { diff --git a/CouplingDataUser.C b/CouplingDataUser.C index 7aeaf8ad..f90ef9a0 100644 --- a/CouplingDataUser.C +++ b/CouplingDataUser.C @@ -29,6 +29,11 @@ void preciceAdapter::CouplingDataUser::setPatchIDs(std::vector patchIDs) patchIDs_ = patchIDs; } +void preciceAdapter::CouplingDataUser::setCellSetNames(std::vector cellSetNames) +{ + cellSetNames_ = cellSetNames; +} + void preciceAdapter::CouplingDataUser::setLocationsType(LocationType locationsType) { locationType_ = locationsType; @@ -43,6 +48,8 @@ void preciceAdapter::CouplingDataUser::checkDataLocation(const bool meshConnecti location = "faceCenters"; else if (locationType_ == LocationType::faceNodes) location = "faceNodes"; + else if (locationType_ == LocationType::volumeCenters) + location = "volumeCenters"; adapterInfo("\"locations = " + location + "\" is not supported for the data \"" + getDataName() + "\". Please select a different " diff --git a/CouplingDataUser.H b/CouplingDataUser.H index ea69537b..7ce00d8d 100644 --- a/CouplingDataUser.H +++ b/CouplingDataUser.H @@ -13,7 +13,8 @@ enum class LocationType { none, faceCenters, - faceNodes + faceNodes, + volumeCenters }; class CouplingDataUser @@ -32,6 +33,9 @@ protected: //- OpenFOAM patches that form the interface std::vector patchIDs_; + //- Names of the OpenFOAM cell sets to be coupled (for volume coupling) + std::vector cellSetNames_; + //- data name std::string dataName_; @@ -57,6 +61,9 @@ public: //- Set the patch IDs that form the interface void setPatchIDs(std::vector patchIDs); + //- Set the cellSetNames that form the overlapping cells of the interface + void setCellSetNames(std::vector cellSetNames); + //- Set the locations type of the interface void setLocationsType(LocationType locationsType); diff --git a/FF/Pressure.C b/FF/Pressure.C index 2d8566e5..5429a2fb 100644 --- a/FF/Pressure.C +++ b/FF/Pressure.C @@ -16,6 +16,31 @@ void preciceAdapter::FF::Pressure::write(double* buffer, bool meshConnectivity, { int bufferIndex = 0; + if (this->locationType_ == LocationType::volumeCenters) + { + if (cellSetNames_.empty()) + { + for (const auto& cell : p_->internalField()) + { + buffer[bufferIndex++] = cell; + } + } + else + { + for (const auto& cellSetName : cellSetNames_) + { + cellSet overlapRegion(p_->mesh(), cellSetName); + const labelList& cells = overlapRegion.toc(); + + for (const auto& currentCell : cells) + { + // Copy the pressure into the buffer + buffer[bufferIndex++] = p_->internalField()[currentCell]; + } + } + } + } + // For every boundary patch of the interface for (uint j = 0; j < patchIDs_.size(); j++) { @@ -35,6 +60,31 @@ void preciceAdapter::FF::Pressure::read(double* buffer, const unsigned int dim) { int bufferIndex = 0; + if (this->locationType_ == LocationType::volumeCenters) + { + if (cellSetNames_.empty()) + { + for (auto& cell : p_->ref()) + { + cell = buffer[bufferIndex++]; + } + } + else + { + for (const auto& cellSetName : cellSetNames_) + { + cellSet overlapRegion(p_->mesh(), cellSetName); + const labelList& cells = overlapRegion.toc(); + + for (const auto& currentCell : cells) + { + // Copy the pressure into the buffer + p_->ref()[currentCell] = buffer[bufferIndex++]; + } + } + } + } + // For every boundary patch of the interface for (uint j = 0; j < patchIDs_.size(); j++) { @@ -52,7 +102,14 @@ void preciceAdapter::FF::Pressure::read(double* buffer, const unsigned int dim) bool preciceAdapter::FF::Pressure::isLocationTypeSupported(const bool meshConnectivity) const { - return (this->locationType_ == LocationType::faceCenters); + if (meshConnectivity) + { + return (this->locationType_ == LocationType::faceCenters); + } + else + { + return (this->locationType_ == LocationType::faceCenters || this->locationType_ == LocationType::volumeCenters); + } } std::string preciceAdapter::FF::Pressure::getDataName() const diff --git a/FF/Pressure.H b/FF/Pressure.H index 32993489..1793278f 100644 --- a/FF/Pressure.H +++ b/FF/Pressure.H @@ -4,6 +4,7 @@ #include "CouplingDataUser.H" #include "fvCFD.H" +#include "cellSet.H" namespace preciceAdapter { diff --git a/FF/Velocity.C b/FF/Velocity.C index 747def6f..2af7049e 100644 --- a/FF/Velocity.C +++ b/FF/Velocity.C @@ -5,10 +5,23 @@ using namespace Foam; preciceAdapter::FF::Velocity::Velocity( const Foam::fvMesh& mesh, const std::string nameU) -: U_( - const_cast( - &mesh.lookupObject(nameU))) { + if (mesh.foundObject(nameU)) + { + U_ = const_cast( + &mesh.lookupObject(nameU)); + } + else + { + U_ = new volVectorField( + IOobject( + nameU, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE), + mesh); + } dataType_ = vector; } @@ -16,6 +29,50 @@ void preciceAdapter::FF::Velocity::write(double* buffer, bool meshConnectivity, { int bufferIndex = 0; + if (this->locationType_ == LocationType::volumeCenters) + { + if (cellSetNames_.empty()) + { + for (const auto& cell : U_->internalField()) + { + // x-dimension + buffer[bufferIndex++] = cell.x(); + + // y-dimension + buffer[bufferIndex++] = cell.y(); + + if (dim == 3) + { + // z-dimension + buffer[bufferIndex++] = cell.z(); + } + } + } + else + { + for (const auto& cellSetName : cellSetNames_) + { + cellSet overlapRegion(U_->mesh(), cellSetName); + const labelList& cells = overlapRegion.toc(); + + for (const auto& currentCell : cells) + { + // x-dimension + buffer[bufferIndex++] = U_->internalField()[currentCell].x(); + + // y-dimension + buffer[bufferIndex++] = U_->internalField()[currentCell].y(); + + if (dim == 3) + { + // z-dimension + buffer[bufferIndex++] = U_->internalField()[currentCell].z(); + } + } + } + } + } + // For every boundary patch of the interface for (uint j = 0; j < patchIDs_.size(); j++) { @@ -47,6 +104,50 @@ void preciceAdapter::FF::Velocity::read(double* buffer, const unsigned int dim) { int bufferIndex = 0; + if (this->locationType_ == LocationType::volumeCenters) + { + if (cellSetNames_.empty()) + { + for (auto& cell : U_->ref()) + { + // x-dimension + cell.x() = buffer[bufferIndex++]; + + // y-dimension + cell.y() = buffer[bufferIndex++]; + + if (dim == 3) + { + // z-dimension + cell.z() = buffer[bufferIndex++]; + } + } + } + else + { + for (const auto& cellSetName : cellSetNames_) + { + cellSet overlapRegion(U_->mesh(), cellSetName); + const labelList& cells = overlapRegion.toc(); + + for (const auto& currentCell : cells) + { + // x-dimension + U_->ref()[currentCell].x() = buffer[bufferIndex++]; + + // y-dimension + U_->ref()[currentCell].y() = buffer[bufferIndex++]; + + if (dim == 3) + { + // z-dimension + U_->ref()[currentCell].z() = buffer[bufferIndex++]; + } + } + } + } + } + // For every boundary patch of the interface for (uint j = 0; j < patchIDs_.size(); j++) { @@ -76,7 +177,14 @@ void preciceAdapter::FF::Velocity::read(double* buffer, const unsigned int dim) bool preciceAdapter::FF::Velocity::isLocationTypeSupported(const bool meshConnectivity) const { - return (this->locationType_ == LocationType::faceCenters); + if (meshConnectivity) + { + return (this->locationType_ == LocationType::faceCenters); + } + else + { + return (this->locationType_ == LocationType::faceCenters || this->locationType_ == LocationType::volumeCenters); + } } std::string preciceAdapter::FF::Velocity::getDataName() const diff --git a/FF/Velocity.H b/FF/Velocity.H index 8c5e396b..3c902470 100644 --- a/FF/Velocity.H +++ b/FF/Velocity.H @@ -4,6 +4,7 @@ #include "CouplingDataUser.H" #include "fvCFD.H" +#include "cellSet.H" namespace preciceAdapter { diff --git a/Interface.C b/Interface.C index 69926525..f1ec1d12 100644 --- a/Interface.C +++ b/Interface.C @@ -1,6 +1,7 @@ #include "Interface.H" #include "Utilities.H" #include "faceTriangulation.H" +#include "cellSet.H" using namespace Foam; @@ -11,6 +12,7 @@ preciceAdapter::Interface::Interface( std::string meshName, std::string locationsType, std::vector patchNames, + std::vector cellSetNames, bool meshConnectivity, bool restartFromDeformed, const std::string& namePointDisplacement, @@ -18,6 +20,7 @@ preciceAdapter::Interface::Interface( : precice_(precice), meshName_(meshName), patchNames_(patchNames), + cellSetNames_(cellSetNames), meshConnectivity_(meshConnectivity), restartFromDeformed_(restartFromDeformed) { @@ -39,6 +42,10 @@ preciceAdapter::Interface::Interface( { locationType_ = LocationType::faceNodes; } + else if (locationsType == "volumeCenters" || locationsType == "volumeCentres") + { + locationType_ = LocationType::volumeCenters; + } else { adapterInfo("Interface points location type \"" @@ -323,6 +330,110 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh, const std::str } } } + else if (locationType_ == LocationType::volumeCenters) + { + // The volume coupling implementation considers the mesh points in the volume and + // on the boundary patches in order to take the boundary conditions into account + + // Get the cell labels of the overlapping region + std::vector overlapCells; + + if (!cellSetNames_.empty()) + { + // For every cellSet that participates in the coupling + for (uint j = 0; j < cellSetNames_.size(); j++) + { + // Create a cell set + cellSet overlapRegion(mesh, cellSetNames_[j]); + + // Add the cells IDs to the vector and count how many overlap cells the interface has + overlapCells.push_back(overlapRegion.toc()); + numDataLocations_ += overlapCells[j].size(); + } + } + else + { + numDataLocations_ = mesh.C().size(); + } + + // Count the data locations for all the patches + // and add those to the previously determined number of mesh points in the volume + for (uint j = 0; j < patchIDs_.size(); j++) + { + numDataLocations_ += + mesh.boundaryMesh()[patchIDs_.at(j)].faceCentres().size(); + } + DEBUG(adapterInfo("Number of coupling volumes: " + std::to_string(numDataLocations_))); + + // Array of the mesh vertices. + // One mesh is used for all the patches and each vertex has 3D coordinates. + std::vector vertices(dim_ * numDataLocations_); + + // Array of the indices of the mesh vertices. + // Each vertex has one index, but three coordinates. + vertexIDs_.resize(numDataLocations_); + + // Initialize the index of the vertices array + int verticesIndex = 0; + + if (!cellSetNames_.empty()) + { + // for all the overlapping cells (cellSets) + for (uint j = 0; j < cellSetNames_.size(); j++) + { + // Get the cell centres of the current cellSet. + const labelList& cells = overlapCells.at(j); + + // Get the coordinates of the cells of the current cellSet. + for (int i = 0; i < cells.size(); i++) + { + vertices[verticesIndex++] = mesh.C().internalField()[cells[i]].x(); + vertices[verticesIndex++] = mesh.C().internalField()[cells[i]].y(); + if (dim_ == 3) + { + vertices[verticesIndex++] = mesh.C().internalField()[cells[i]].z(); + } + } + } + } + else + { + const vectorField& CellCenters = mesh.C(); + + for (int i = 0; i < CellCenters.size(); i++) + { + vertices[verticesIndex++] = CellCenters[i].x(); + vertices[verticesIndex++] = CellCenters[i].y(); + if (dim_ == 3) + { + vertices[verticesIndex++] = CellCenters[i].z(); + } + } + } + + // Get the locations of the mesh vertices (here: face centers) + // for all the patches + for (uint j = 0; j < patchIDs_.size(); j++) + { + // Get the face centers of the current patch + const vectorField faceCenters = + mesh.boundaryMesh()[patchIDs_.at(j)].faceCentres(); + + // Assign the (x,y,z) locations to the vertices + for (int i = 0; i < faceCenters.size(); i++) + { + vertices[verticesIndex++] = faceCenters[i].x(); + vertices[verticesIndex++] = faceCenters[i].y(); + if (dim_ == 3) + { + vertices[verticesIndex++] = faceCenters[i].z(); + } + } + } + + // Pass the mesh vertices information to preCICE + precice_.setMeshVertices(meshName_, vertices, vertexIDs_); + } } @@ -336,6 +447,9 @@ void preciceAdapter::Interface::addCouplingDataWriter( // Set the patchIDs of the patches that form the interface couplingDataWriter->setPatchIDs(patchIDs_); + // Set the names of the cell sets to be coupled (for volume coupling) + couplingDataWriter->setCellSetNames(cellSetNames_); + // Set the location type in the CouplingDataUser class couplingDataWriter->setLocationsType(locationType_); @@ -363,6 +477,9 @@ void preciceAdapter::Interface::addCouplingDataReader( // Set the location type in the CouplingDataUser class couplingDataReader->setLocationsType(locationType_); + // Set the names of the cell sets to be coupled (for volume coupling) + couplingDataReader->setCellSetNames(cellSetNames_); + // Check, if the current location type is supported by the data type couplingDataReader->checkDataLocation(meshConnectivity_); diff --git a/Interface.H b/Interface.H index 27221030..885ec9b0 100644 --- a/Interface.H +++ b/Interface.H @@ -33,6 +33,9 @@ protected: //- OpenFOAM patches that form the interface std::vector patchIDs_; + //- Names of the OpenFOAM cell sets to be coupled (for volume coupling) + std::vector cellSetNames_; + //- Number of data points (cell centers) on the interface int numDataLocations_ = 0; @@ -71,6 +74,7 @@ public: std::string meshName, std::string locationsType, std::vector patchNames, + std::vector cellSetNames, bool meshConnectivity, bool restartFromDeformed, const std::string& namePointDisplacement, diff --git a/changelog-entries/255.md b/changelog-entries/255.md new file mode 100644 index 00000000..f7fc3698 --- /dev/null +++ b/changelog-entries/255.md @@ -0,0 +1 @@ +- added a locationType for volume coupling and implemented the respective functionality (over all internal fields) for Pressure and Velocity (FF) and Temperature (FF) \ No newline at end of file diff --git a/changelog-entries/270.md b/changelog-entries/270.md new file mode 100644 index 00000000..ba25bb42 --- /dev/null +++ b/changelog-entries/270.md @@ -0,0 +1 @@ +- Added volume coupling over one or multiple domain regions specified by OpenFOAM cellSets (for Pressure and Velocity (FF) and Temperature (FF)) \ No newline at end of file diff --git a/docs/README.md b/docs/README.md index 3010bb7b..61e65879 100644 --- a/docs/README.md +++ b/docs/README.md @@ -8,11 +8,11 @@ summary: An OpenFOAM function object for CHT, FSI, and fluid-fluid coupled simul ## What is this? -This preCICE adapter is a plug-in (function object) for OpenFOAM, which can work with any recent version of OpenFOAM (.com / .org, see [supported OpenFOAM versions](https://precice.org/adapter-openfoam-support.html)). It supports fluid-structure interaction (fluid part), conjugate heat transfer (fluid and solid parts), and fluid-fluid simulations, while it is also easily extensible. +This preCICE adapter is a plug-in (function object) for OpenFOAM, which can work with any recent version of OpenFOAM (.com / .org, see [supported OpenFOAM versions](https://precice.org/adapter-openfoam-support.html)). It supports fluid-structure interaction (fluid part), conjugate heat transfer (fluid and solid parts), and fluid-fluid simulations, while it is also easily extensible. Besides surface coupling, the adapter also supports volume coupling (overlapping domains). ## What can it do? -This adapter can read/write the following fields: +This adapter can read/write the following fields in a surface coupling setup: - Temperature (read + write) - Heat flux (read + write) @@ -27,6 +27,14 @@ This adapter can read/write the following fields: - Velocity (read + write) - Velocity gradient (read + write) +In addition, the adapter supports the following fields in a volume coupling setup: + +- Temperature (read* + write) +- Pressure (read* + write) +- Velocity (read + write) + +(*) Technical foundation available, the user needs to provide additional, application-specific code for enforcing the source terms. + All features of preCICE are supported, including implicit coupling and nearest-projection mapping. Even though OpenFOAM is 3D, this adapter can also work in the 2D mode of preCICE, defining only one layer of interface nodes (automatically). ## Try diff --git a/docs/config.md b/docs/config.md index 584b458f..78431a34 100644 --- a/docs/config.md +++ b/docs/config.md @@ -69,7 +69,11 @@ The `patches` specifies a list of the names of the OpenFOAM boundary patches tha participating in the coupled simulation. These need to be defined in the files included in the `0/` directory. The names of the interfaces (e.g., `Interface1`) are arbitrary and are not used. -The `locations` field is optional and its default value is `faceCenters` (with `faceCentres` also accepted), signifying that the interface mesh is defined on the cell face centers. The alternative option is `faceNodes`, which defines the mesh on the face nodes and is needed, e.g., for reading displacements in an FSI scenario. +The `locations` field is optional and its default value is `faceCenters` (with `faceCentres` also accepted), signifying that the interface mesh is defined on the cell face centers. An alternative option is `faceNodes`, which defines the mesh on the face nodes and is needed, e.g., for reading displacements in an FSI scenario. +The final type is `volumeCenters` (alternatively `volumeCentres`), which allows the user to couple over a volume using the cell centers of the domain. The user can also specify patches, which will be coupled additionally to the cells using the `faceCenters` mesh. +The `volumeCenters` location is currently implemented for fluid-fluid coupling (`Pressure` and `Velocity`) and conjugate heat transfer (`Temperature`). + +The `cellSets` field can be used to specify one or multiple coupling regions (defined by OpenFOAM `cellSets`) for volume coupling. The field can only be used with the `volumeCenters` location and it is optional. If no `cellSets` are specified, the full domain will be coupled. The values for `readData` and `writeData` for conjugate heat transfer @@ -222,6 +226,99 @@ The FF module is still experimental and the boundary conditions presented here h We already have reasons to believe that a `fixedGradient` can have [side-effects](https://github.com/precice/openfoam-adapter/issues/93) and may not lead to completely accurate results. {% endexperimental %} +### Volume coupling + +Besides surface coupling on the domain boundaries, the OpenFOAM adapter also supports coupling overlapping domains, which can be the complete domain, or regions of it. In contrast to surface coupling, though, reading volume data (source terms) requires a few additional configuration steps compared to writing data. + +In order to write volume data, it is enough to specify `volumeCenters` for the `locations` field. This will couple the whole internal field of the domain. Patches can be specified additionally, for surface coupling, or the list of patch names can be left empty. + +In order to read volume data (enforce source terms), it is necessary to use the [finite volume options](https://www.openfoam.com/documentation/guides/latest/doc/guide-fvoptions.html) (`fvOptions`) feature of OpenFOAM. Without this additional configuration, the values read in OpenFOAM in each time step would later be overwritten by OpenFOAM. +The `fvOptions` construct provides many different options for sources, but the [coded sources](https://www.openfoam.com/documentation/guides/latest/doc/guide-fvoptions-sources-coded.html) is a convenient way to describe source terms in configuration. + +Using a `codedSource` for reading fields and enforcing source terms in OpenFOAM would currently only work for `Velocity`. The adapter internally stores the received data in a separate velocity field, which the source term defined in OpenFOAM uses to update its own velocity field. For this reason, it is necessary to specify an alternative name for `U` in `preciceDict` when reading velocity in a volume-coupled scenario: + +```c++ +FF +{ + nameU U_vol; +}; +``` + +This essentially means two velocity variables are used: `U_vol` is the coupled velocity the adapter uses to carry over the desired value to OpenFOAM, and `U` is the variable OpenFOAM uses for its own velocity. In the `codedSource` you can explicitly set `U` to be equal to `U_vol`. Example from the [volume-coupled flow](https://precice.org/tutorials-volume-coupled-flow.html) tutorial: + +```c++ +// File constant/fvOptions + +codedSource +{ + type vectorCodedSource; + selectionMode cellSet; + cellSet box1; + + fields (U); + name sourceTime; + + codeConstrain //constrain + #{ + return; + #}; + + codeCorrect //correct + #{ + const labelList& cells = this->cells(); + const volVectorField& U_vol = mesh_.lookupObject("U_vol"); + for(auto cell : cells) + { + fld[cell].x() = U_vol[cell].x(); + } + #}; + + codeAddSup // source term + #{ + return; + #}; + + codeAddSupRho + #{ + return; + #}; +} +``` + +{% experimental %} +Reading volume-coupled variables in OpenFOAM is still experimental. This section simply contains suggestions about issues we have encountered and what has been found to work. +{% endexperimental %} + +#### Volume coupling over a domain region + +For reading values only over a region of the domain, we use the OpenFOAM [`cellSet` class](https://www.openfoam.com/documentation/guides/latest/api/classFoam_1_1cellSet.html) to define one or multiple volume coupling regions. You can define one or multiple `cellSets` in the `system/topoSetDict`: + +```C++ +actions +( + { + name box1; + type cellSet; + action new; + source boxToCell; + box (3.0 1.0 0.0) (3.5 1.5 1.0); + } +); +``` + +Additionally, list the `cellSets` you want to couple in the `preciceDict`: + +```C++ +Interface1 +{ + ... + cellSets (box1); + locations volumeCenters; +} +``` + +Before running the solver, and after preparing the mesh, execute [topoSet](https://www.openfoam.com/documentation/guides/latest/man/topoSet.html) to construct the overlapping region. + ### Load the adapter To load this adapter, you must include the following in From 3e660e10901f8d6758f5484dad565dc8b41681d3 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Wed, 16 Aug 2023 09:50:43 +0200 Subject: [PATCH 38/60] Update README.md --- docs/README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/README.md b/docs/README.md index 61e65879..82527395 100644 --- a/docs/README.md +++ b/docs/README.md @@ -29,12 +29,10 @@ This adapter can read/write the following fields in a surface coupling setup: In addition, the adapter supports the following fields in a volume coupling setup: -- Temperature (read* + write) -- Pressure (read* + write) +- Temperature (write) +- Pressure (write) - Velocity (read + write) -(*) Technical foundation available, the user needs to provide additional, application-specific code for enforcing the source terms. - All features of preCICE are supported, including implicit coupling and nearest-projection mapping. Even though OpenFOAM is 3D, this adapter can also work in the 2D mode of preCICE, defining only one layer of interface nodes (automatically). ## Try From 389934a4bba07d700b0004f6e5ab3f647cb0a016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BChlh=C3=A4u=C3=9Fer?= <43962524+thesamriel@users.noreply.github.com> Date: Wed, 16 Aug 2023 15:20:39 +0200 Subject: [PATCH 39/60] Updates to the FF module (#281) --- CHANGELOG.md | 2 +- .../coupledPressureFvPatchField.C | 181 +++++++++++++ .../coupledPressureFvPatchField.H | 249 ++++++++++++++++++ .../coupledVelocityFvPatchField.C | 178 +++++++++++++ .../coupledVelocityFvPatchField.H | 218 +++++++++++++++ FF/FF.C | 44 +++- FF/FF.H | 11 + FF/Pressure.C | 13 +- FF/Temperature.C | 60 +++++ FF/Temperature.H | 42 +++ FF/TemperatureGradient.C | 72 +++++ FF/TemperatureGradient.H | 42 +++ FF/Velocity.C | 44 +++- FF/Velocity.H | 8 +- FF/VelocityGradient.C | 20 +- Make/files | 4 + changelog-entries/281.md | 5 + docs/config.md | 45 +++- 18 files changed, 1217 insertions(+), 21 deletions(-) create mode 100644 FF/BoundaryConditions/coupledPressure/coupledPressureFvPatchField.C create mode 100644 FF/BoundaryConditions/coupledPressure/coupledPressureFvPatchField.H create mode 100644 FF/BoundaryConditions/coupledVelocity/coupledVelocityFvPatchField.C create mode 100644 FF/BoundaryConditions/coupledVelocity/coupledVelocityFvPatchField.H create mode 100644 FF/Temperature.C create mode 100644 FF/Temperature.H create mode 100644 FF/TemperatureGradient.C create mode 100644 FF/TemperatureGradient.H create mode 100644 changelog-entries/281.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fe99340..8e93ee3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ Read more details in the issue [#52: Releases and versioning](https://github.com - Fixed incorrect reading and writing of the FSI-related data buffers, if multiple patches are combined in an interface mesh [commit 846affd](https://github.com/precice/openfoam-adapter/commit/846affdd00ea8024cee98f34d8ad4205fdc83c5f). -## [v1.2.2] 2022-01-03 +## [v1.2.2] 2023-01-03 ### Changed diff --git a/FF/BoundaryConditions/coupledPressure/coupledPressureFvPatchField.C b/FF/BoundaryConditions/coupledPressure/coupledPressureFvPatchField.C new file mode 100644 index 00000000..28d61e8a --- /dev/null +++ b/FF/BoundaryConditions/coupledPressure/coupledPressureFvPatchField.C @@ -0,0 +1,181 @@ +#include "coupledPressureFvPatchField.H" +#include "addToRunTimeSelectionTable.H" +#include "surfaceFields.H" + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::coupledPressureFvPatchField::coupledPressureFvPatchField( + const fvPatch& p, + const DimensionedField& iF) +: fixedFluxExtrapolatedPressureFvPatchScalarField(p, iF), + refValue_(p.size(), Zero), + refGrad_(p.size(), Zero), + valueFraction_(p.size(), Zero) +{ +} + + +Foam::coupledPressureFvPatchField::coupledPressureFvPatchField( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict, + const bool valueRequired) +: fixedFluxExtrapolatedPressureFvPatchScalarField(p, iF, dict), + refValue_("refValue", dict, p.size()), + valueFraction_(p.size(), Zero), + phiName_(dict.getOrDefault("phi", "phi")), + uName_(dict.getOrDefault("U", "U")) +{ + if (dict.found("refGradient")) + { + this->refGrad() = scalarField("refGradient", dict, p.size()); + } + else + { + this->refGrad() = scalarField(p.size(), Zero); + } +} + + +Foam::coupledPressureFvPatchField::coupledPressureFvPatchField( + const coupledPressureFvPatchField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper) +: fixedFluxExtrapolatedPressureFvPatchScalarField(ptf, p, iF, mapper), + refValue_(ptf.refValue_), + refGrad_(ptf.refGrad_), + valueFraction_(ptf.valueFraction_) +{ + if (notNull(iF) && mapper.hasUnmapped()) + { + WarningInFunction + << "On field " << iF.name() << " patch " << p.name() + << " patchField " << this->type() + << " : mapper does not map all values." << nl + << " To avoid this warning fully specify the mapping in derived" + << " patch fields." << endl; + } +} + + +Foam::coupledPressureFvPatchField::coupledPressureFvPatchField( + const coupledPressureFvPatchField& ptf) +: fixedFluxExtrapolatedPressureFvPatchScalarField(ptf), + refValue_(ptf.refValue_), + refGrad_(ptf.refGrad_), + valueFraction_(ptf.valueFraction_) +{ +} + + +Foam::coupledPressureFvPatchField::coupledPressureFvPatchField( + const coupledPressureFvPatchField& ptf, + const DimensionedField& iF) +: fixedFluxExtrapolatedPressureFvPatchScalarField(ptf, iF), + refValue_(ptf.refValue_), + refGrad_(ptf.refGrad_), + valueFraction_(ptf.valueFraction_) +{ +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + + +Foam::tmp +Foam::coupledPressureFvPatchField::snGrad() const +{ + return valueFraction_ + * (refValue_ - this->patchInternalField()) + * this->patch().deltaCoeffs() + + (1.0 - valueFraction_) * refGrad_; +} + +void Foam::coupledPressureFvPatchField::updateCoeffs() +{ + const Foam::surfaceScalarField* phi = &db().lookupObject(phiName_); + const scalarField& phip = phi->boundaryField()[this->patch().index()]; + const Foam::volVectorField* U = &db().lookupObject(uName_); + const vectorField& Up = U->boundaryField()[this->patch().index()]; + const vectorField n = this->patch().nf(); + + int t0 = this->patch().boundaryMesh().mesh().time().startTimeIndex(); + int t = this->patch().boundaryMesh().mesh().time().timeIndex(); + if (t - t0 == 1) + { + this->valueFraction() = pos0(Up & n); + } + else + { + this->valueFraction() = pos0(phip); + } + fixedFluxExtrapolatedPressureFvPatchScalarField::updateCoeffs(); +} + +void Foam::coupledPressureFvPatchField::evaluate(const Pstream::commsTypes) +{ + if (!this->updated()) + { + this->updateCoeffs(); + } + + scalarField::operator=( + valueFraction_* refValue_ + + (1.0 - valueFraction_) + * (this->patchInternalField() + + refGrad_ / this->patch().deltaCoeffs())); + + fvPatchScalarField::evaluate(); +} + +Foam::tmp +Foam::coupledPressureFvPatchField::valueInternalCoeffs( + const tmp&) const +{ + return (pTraits::one) * (1.0 - valueFraction_); +} + + +Foam::tmp +Foam::coupledPressureFvPatchField::valueBoundaryCoeffs( + const tmp&) const +{ + return valueFraction_ * refValue_ + + (1.0 - valueFraction_) * refGrad_ / this->patch().deltaCoeffs(); +} + + +Foam::tmp +Foam::coupledPressureFvPatchField::gradientInternalCoeffs() const +{ + return -(pTraits::one) * valueFraction_ * this->patch().deltaCoeffs(); +} + + +Foam::tmp +Foam::coupledPressureFvPatchField::gradientBoundaryCoeffs() const +{ + return valueFraction_ * this->patch().deltaCoeffs() * refValue_ + + (1.0 - valueFraction_) * refGrad_; +} + + +void Foam::coupledPressureFvPatchField::write(Ostream& os) const +{ + fvPatchScalarField::write(os); + this->writeEntry("value", os); + this->valueFraction().writeEntry("valueFraction", os); + this->refValue().writeEntry("refValue", os); +} + + +// ************************************************************************* // + +namespace Foam +{ +makePatchTypeField( + fixedFluxExtrapolatedPressureFvPatchScalarField, + coupledPressureFvPatchField); +} \ No newline at end of file diff --git a/FF/BoundaryConditions/coupledPressure/coupledPressureFvPatchField.H b/FF/BoundaryConditions/coupledPressure/coupledPressureFvPatchField.H new file mode 100644 index 00000000..da9f875a --- /dev/null +++ b/FF/BoundaryConditions/coupledPressure/coupledPressureFvPatchField.H @@ -0,0 +1,249 @@ +/*---------------------------------------------------------------------------*\ +Class + Foam::coupledPressureFvPatchField + +Description + This boundary condition is a pressure inlet-outlet condition. + It acts as a fixedFluxExtrapolated pressure boundary patch for inflow faces and as a fixedValue at outflow faces. + +Usage + \table + Property | Description | Required | Default value + refValue | reference Pressure values | yes | + refGradient | reference Pressure gradient values | no | uniform 0 + phi | name of flux field | no | "phi" + U | name of velocity field | no | "U" + \endtable + + Example of the boundary condition specification: + \verbatim + + { + type coupledPressure; + refValue uniform 0; // Example for Foam::scalar field usage + } + \endverbatim + +SourceFiles + coupledPressureFvPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef coupledPressureFvPatchField_H +#define coupledPressureFvPatchField_H + +#include "fvPatchField.H" +#include "fixedFluxExtrapolatedPressureFvPatchScalarField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class coupledPressureFvPatchField Declaration +\*---------------------------------------------------------------------------*/ + +class coupledPressureFvPatchField +: public fixedFluxExtrapolatedPressureFvPatchScalarField +{ + +private: + //- Value field + scalarField refValue_; + + //- Normal gradient field + scalarField refGrad_; + + //- Fraction (0-1) of value used for boundary condition + scalarField valueFraction_; + + //- Name of flux field + word phiName_; + + //- Name of velocity field + word uName_; + +public: + //- Runtime type information + TypeName("coupledPressure"); + + + // Constructors + + //- Construct from patch and internal field + coupledPressureFvPatchField( + const fvPatch&, + const DimensionedField&); + + //- Construct from patch, internal field and dictionary + coupledPressureFvPatchField( + const fvPatch&, + const DimensionedField&, + const dictionary&, + const bool valueRequired = true); + + //- Construct by mapping the given coupledPressureFvPatchField + // onto a new patch + coupledPressureFvPatchField( + const coupledPressureFvPatchField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper&); + + //- Construct as copy + coupledPressureFvPatchField( + const coupledPressureFvPatchField&); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp( + new coupledPressureFvPatchField(*this)); + } + + //- Construct as copy setting internal field reference + coupledPressureFvPatchField( + const coupledPressureFvPatchField&, + const DimensionedField&); + + //- Construct and return a clone setting internal field reference + virtual tmp clone( + const DimensionedField& iF) const + { + return tmp( + new coupledPressureFvPatchField(*this, iF)); + } + + + // Member functions + + + // Attributes + + //- Return true if this patch field fixes a value. + // Needed to check if a level has to be specified while solving + // Poissons equations. + virtual bool fixesValue() const + { + return true; + } + + //- Return false: this patch field is not altered by assignment + virtual bool assignable() const + { + return false; + } + + // Evaluation functions + void evaluate(const Pstream::commsTypes commsType = + Pstream::commsTypes::blocking); + //- Return the matrix diagonal coefficients corresponding to the + // evaluation of the value of this patchField with given weights + virtual tmp valueInternalCoeffs( + const tmp&) const; + + //- Return the matrix source coefficients corresponding to the + // evaluation of the value of this patchField with given weights + virtual tmp valueBoundaryCoeffs( + const tmp&) const; + + //- Return the matrix diagonal coefficients corresponding to the + // evaluation of the gradient of this patchField + virtual tmp gradientInternalCoeffs() const; + + //- Return the matrix source coefficients corresponding to the + // evaluation of the gradient of this patchField + virtual tmp gradientBoundaryCoeffs() const; + + // Return defining fields + + virtual Foam::scalarField& refValue() + { + return refValue_; + } + + virtual const Foam::scalarField& refValue() const + { + return refValue_; + } + + virtual Foam::scalarField& refGrad() + { + return refGrad_; + } + + virtual const Foam::scalarField& refGrad() const + { + return refGrad_; + } + + virtual Foam::scalarField& gradient() + { + return refGrad_; + } + + virtual const Foam::scalarField& gradient() const + { + return refGrad_; + } + + virtual scalarField& valueFraction() + { + return valueFraction_; + } + + virtual const scalarField& valueFraction() const + { + return valueFraction_; + } + + //- Return gradient at boundary + virtual tmp snGrad() const; + + + void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; + + + // Member operators + + virtual void operator=(const UList&) {} + + virtual void operator=(const fvPatchScalarField&) {} + virtual void operator+=(const fvPatchScalarField&) {} + virtual void operator-=(const fvPatchScalarField&) {} + virtual void operator*=(const fvPatchScalarField&) {} + virtual void operator/=(const fvPatchScalarField&) {} + + virtual void operator+=(const scalarField&) {} + virtual void operator-=(const scalarField&) {} + + virtual void operator*=(const scalarField&) {} + virtual void operator/=(const scalarField&) {} + + virtual void operator=(const Foam::scalar&) {} + virtual void operator+=(const Foam::scalar&) {} + virtual void operator-=(const Foam::scalar&) {} + virtual void operator*=(const Foam::scalar) {} + virtual void operator/=(const Foam::scalar) {} +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// #ifdef NoRepository +// #include "coupledPressureFvPatchField.C" +// #endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/FF/BoundaryConditions/coupledVelocity/coupledVelocityFvPatchField.C b/FF/BoundaryConditions/coupledVelocity/coupledVelocityFvPatchField.C new file mode 100644 index 00000000..3c51fb92 --- /dev/null +++ b/FF/BoundaryConditions/coupledVelocity/coupledVelocityFvPatchField.C @@ -0,0 +1,178 @@ +#include "coupledVelocityFvPatchField.H" +#include "dictionary.H" +#include "addToRunTimeSelectionTable.H" + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + + +Foam::coupledVelocityFvPatchField::coupledVelocityFvPatchField( + const fvPatch& p, + const DimensionedField& iF) +: fvPatchField(p, iF), + refValue_(p.size(), Zero), + refGrad_(p.size(), Zero), + valueFraction_(p.size(), Zero) +{ +} + + +Foam::coupledVelocityFvPatchField::coupledVelocityFvPatchField( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict) +: fvPatchField(p, iF), + refValue_("refValue", dict, p.size()), + valueFraction_(p.size(), Zero), + phiName_(dict.getOrDefault("phi", "phi")) +{ + if (dict.found("refGradient")) + { + this->refGrad() = vectorField("refGradient", dict, p.size()); + } + else + { + this->refGrad() = vectorField(p.size(), Zero); + } + + vectorField::operator=( + valueFraction_* refValue_ + + (1.0 - valueFraction_) + * (this->patchInternalField() + + refGrad_ / this->patch().deltaCoeffs())); +} + + +Foam::coupledVelocityFvPatchField::coupledVelocityFvPatchField( + const coupledVelocityFvPatchField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper) +: fvPatchField(ptf, p, iF, mapper), + refValue_(ptf.refValue_), + refGrad_(ptf.refGrad_), + valueFraction_(ptf.valueFraction_) +{ +} + + +Foam::coupledVelocityFvPatchField::coupledVelocityFvPatchField( + const coupledVelocityFvPatchField& ptf) +: fvPatchField(ptf), + refValue_(ptf.refValue_), + refGrad_(ptf.refGrad_), + valueFraction_(ptf.valueFraction_) +{ +} + + +Foam::coupledVelocityFvPatchField::coupledVelocityFvPatchField( + const coupledVelocityFvPatchField& ptf, + const DimensionedField& iF) +: fvPatchField(ptf, iF), + refValue_(ptf.refValue_), + refGrad_(ptf.refGrad_), + valueFraction_(ptf.valueFraction_) +{ +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::tmp Foam::coupledVelocityFvPatchField::snGrad() const +{ + return valueFraction_ + * (refValue_ - this->patchInternalField()) + * this->patch().deltaCoeffs() + + (1.0 - valueFraction_) * refGrad_; +} + +void Foam::coupledVelocityFvPatchField::updateCoeffs() +{ + if (this->updated()) + { + return; + } + const Foam::surfaceScalarField* phi = &db().lookupObject(phiName_); + const scalarField& phip = phi->boundaryField()[this->patch().index()]; + const vectorField n = this->patch().nf(); + + int t0 = this->patch().boundaryMesh().mesh().time().startTimeIndex(); + int t = this->patch().boundaryMesh().mesh().time().timeIndex(); + if (t - t0 == 1) + { + this->valueFraction() = 1 - pos0(refValue_ & n); + } + else + { + this->valueFraction() = 1 - pos0(phip); + } + fvPatchVectorField::updateCoeffs(); +} + +void Foam::coupledVelocityFvPatchField::evaluate(const Pstream::commsTypes p) +{ + if (!this->updated()) + { + this->updateCoeffs(); + } + + vectorField::operator=( + valueFraction_* refValue_ + + (1.0 - valueFraction_) + * (this->patchInternalField() + + refGrad_ / this->patch().deltaCoeffs())); + + fvPatchVectorField::evaluate(); +} + + +Foam::tmp> +Foam::coupledVelocityFvPatchField::valueInternalCoeffs( + const tmp&) const +{ + return (pTraits::one) * (1.0 - valueFraction_); +} + + +Foam::tmp> +Foam::coupledVelocityFvPatchField::valueBoundaryCoeffs( + const tmp&) const +{ + return valueFraction_ * refValue_ + + (1.0 - valueFraction_) * refGrad_ / this->patch().deltaCoeffs(); +} + + +Foam::tmp> +Foam::coupledVelocityFvPatchField::gradientInternalCoeffs() const +{ + return -(pTraits::one) * valueFraction_ * this->patch().deltaCoeffs(); +} + + +Foam::tmp> +Foam::coupledVelocityFvPatchField::gradientBoundaryCoeffs() const +{ + return valueFraction_ * this->patch().deltaCoeffs() * refValue_ + + (1.0 - valueFraction_) * refGrad_; +} + + +void Foam::coupledVelocityFvPatchField::write(Ostream& os) const +{ + fvPatchField::write(os); + this->writeEntry("value", os); + this->valueFraction().writeEntry("valueFraction", os); + this->refValue().writeEntry("refValue", os); +} + + +// ************************************************************************* // + +namespace Foam +{ +makePatchTypeField( + fvPatchVectorField, + coupledVelocityFvPatchField); +} \ No newline at end of file diff --git a/FF/BoundaryConditions/coupledVelocity/coupledVelocityFvPatchField.H b/FF/BoundaryConditions/coupledVelocity/coupledVelocityFvPatchField.H new file mode 100644 index 00000000..dadc1f2f --- /dev/null +++ b/FF/BoundaryConditions/coupledVelocity/coupledVelocityFvPatchField.H @@ -0,0 +1,218 @@ +/*---------------------------------------------------------------------------*\ +Class + Foam::coupledVelocityFvPatchField + +Description + This boundary condition is a velocity inlet-outlet. + It acts as a fixedValue boundary patch for inflow faces and as a fixedGradient at outflow faces. + It is essentially a type-specific version of the inletOutlet condition of OpenFOAM. + +Usage + \table + Property | Description | Required | Default value + refValue | reference Velocity values | yes | + refGradient | reference Velocity gradient values | no | uniform (0 0 0) + phi | name of flux field | no | "phi" + \endtable + + Example of the boundary condition specification: + \verbatim + + { + type coupledVelocity; + refValue uniform (0 0 0); + } + \endverbatim + +SourceFiles + coupledVelocityFvPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef coupledVelocityFvPatchField_H +#define coupledVelocityFvPatchField_H + +#include "fvPatchFields.H" +#include "fvCFD.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class coupledVelocityFvPatchField Declaration +\*---------------------------------------------------------------------------*/ + +class coupledVelocityFvPatchField +: public fvPatchVectorField +{ +private: + // Private data + + //- Value field + vectorField refValue_; + + //- Normal gradient field + vectorField refGrad_; + + //- Fraction (0-1) of value used for boundary condition + scalarField valueFraction_; + + //- Name of flux field + word phiName_; + +public: + //- Runtime type information + TypeName("coupledVelocity"); + + + // Constructors + + //- Construct from patch and internal field + coupledVelocityFvPatchField( + const fvPatch&, + const DimensionedField&); + + //- Construct from patch, internal field and dictionary + coupledVelocityFvPatchField( + const fvPatch&, + const DimensionedField&, + const dictionary&); + + //- Construct by mapping the given coupledVelocityFvPatchField + // onto a new patch + coupledVelocityFvPatchField( + const coupledVelocityFvPatchField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper&); + + //- Construct as copy + coupledVelocityFvPatchField( + const coupledVelocityFvPatchField&); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp( + new coupledVelocityFvPatchField(*this)); + } + + //- Construct as copy setting internal field reference + coupledVelocityFvPatchField( + const coupledVelocityFvPatchField&, + const DimensionedField&); + + //- Construct and return a clone setting internal field reference + virtual tmp> clone( + const DimensionedField& iF) const + { + return tmp>( + new coupledVelocityFvPatchField(*this, iF)); + } + + + // Member functions + //- Return true if this patch field fixes a value. + // Needed to check if a level has to be specified while solving + // Poissons equations. + virtual bool fixesValue() const + { + return true; + } + + //- Return false: this patch field is not altered by assignment + virtual bool assignable() const + { + return true; + } + + // Evaluation functions + + //- Return neighbour coupled internal cell data + virtual vectorField& refValue() + { + return refValue_; + } + + virtual const vectorField& refValue() const + { + return refValue_; + } + + virtual vectorField& refGrad() + { + return refGrad_; + } + + virtual const vectorField& refGrad() const + { + return refGrad_; + } + + virtual vectorField& gradient() + { + return refGrad_; + } + + virtual const vectorField& gradient() const + { + return refGrad_; + } + + virtual scalarField& valueFraction() + { + return valueFraction_; + } + + virtual const scalarField& valueFraction() const + { + return valueFraction_; + } + + //- Return gradient at boundary + virtual tmp snGrad() const; + + void updateCoeffs(); + + //- Evaluate the patch field + virtual void evaluate( + const Pstream::commsTypes commsType = + Pstream::commsTypes::blocking); + + //- Return the matrix diagonal coefficients corresponding to the + // evaluation of the value of this patchField with given weights + virtual tmp> valueInternalCoeffs( + const tmp&) const; + + //- Return the matrix source coefficients corresponding to the + // evaluation of the value of this patchField with given weights + virtual tmp> valueBoundaryCoeffs( + const tmp&) const; + + //- Return the matrix diagonal coefficients corresponding to the + // evaluation of the gradient of this patchField + virtual tmp> gradientInternalCoeffs() const; + + //- Return the matrix source coefficients corresponding to the + // evaluation of the gradient of this patchField + virtual tmp> gradientBoundaryCoeffs() const; + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/FF/FF.C b/FF/FF.C index 6bf0476b..439a7281 100644 --- a/FF/FF.C +++ b/FF/FF.C @@ -59,6 +59,18 @@ bool preciceAdapter::FF::FluidFluid::readConfig(const IOdictionary& adapterConfi nameP_ = FFdict.lookupOrDefault("nameP", "p"); DEBUG(adapterInfo(" pressure field name : " + nameP_)); + // Read the name of the temperature field (if different) + nameT_ = FFdict.lookupOrDefault("nameT", "T"); + DEBUG(adapterInfo(" temperature field name : " + nameT_)); + + // Read the name of the face flux field (if different) + namePhi_ = FFdict.lookupOrDefault("namePhi", "phi"); + DEBUG(adapterInfo(" face flux field name : " + namePhi_)); + + // Check whether to enable flux correction for velocity + fluxCorrection_ = FFdict.lookupOrDefault("fluxCorrection", false); + DEBUG(adapterInfo(" flux correction of velocity is set to : " + std::string(fluxCorrection_))); + return true; } @@ -112,7 +124,7 @@ bool preciceAdapter::FF::FluidFluid::addWriters(std::string dataName, Interface* { interface->addCouplingDataWriter( dataName, - new Velocity(mesh_, nameU_)); + new Velocity(mesh_, nameU_, namePhi_, fluxCorrection_)); DEBUG(adapterInfo("Added writer: Velocity.")); } else if (dataName.find("PressureGradient") == 0) @@ -129,6 +141,20 @@ bool preciceAdapter::FF::FluidFluid::addWriters(std::string dataName, Interface* new Pressure(mesh_, nameP_)); DEBUG(adapterInfo("Added writer: Pressure.")); } + else if (dataName.find("FlowTemperatureGradient") == 0) + { + interface->addCouplingDataWriter( + dataName, + new TemperatureGradient(mesh_, nameT_)); + DEBUG(adapterInfo("Added writer: Flow Temperature Gradient.")); + } + else if (dataName.find("FlowTemperature") == 0) + { + interface->addCouplingDataWriter( + dataName, + new Temperature(mesh_, nameT_)); + DEBUG(adapterInfo("Added writer: Flow Temperature.")); + } else { found = false; @@ -158,7 +184,7 @@ bool preciceAdapter::FF::FluidFluid::addReaders(std::string dataName, Interface* { interface->addCouplingDataReader( dataName, - new Velocity(mesh_, nameU_)); + new Velocity(mesh_, nameU_, namePhi_)); DEBUG(adapterInfo("Added reader: Velocity.")); } else if (dataName.find("PressureGradient") == 0) @@ -175,6 +201,20 @@ bool preciceAdapter::FF::FluidFluid::addReaders(std::string dataName, Interface* new Pressure(mesh_, nameP_)); DEBUG(adapterInfo("Added reader: Pressure.")); } + else if (dataName.find("FlowTemperatureGradient") == 0) + { + interface->addCouplingDataReader( + dataName, + new TemperatureGradient(mesh_, nameT_)); + DEBUG(adapterInfo("Added reader: Flow Temperature Gradient.")); + } + else if (dataName.find("FlowTemperature") == 0) + { + interface->addCouplingDataReader( + dataName, + new Temperature(mesh_, nameT_)); + DEBUG(adapterInfo("Added reader: Flow Temperature.")); + } else { found = false; diff --git a/FF/FF.H b/FF/FF.H index ded126e0..fbcee8cb 100644 --- a/FF/FF.H +++ b/FF/FF.H @@ -5,8 +5,10 @@ #include "FF/Velocity.H" #include "FF/Pressure.H" +#include "FF/Temperature.H" #include "FF/PressureGradient.H" #include "FF/VelocityGradient.H" +#include "FF/TemperatureGradient.H" #include "fvCFD.H" @@ -33,6 +35,15 @@ protected: //- Name of the pressure field std::string nameP_ = "p"; + //- Name of the temperature field + std::string nameT_ = "T"; + + //- Name of the face flux field + std::string namePhi_ = "phi"; + + //- Flux correction of velocity + bool fluxCorrection_ = false; + //- Determine the solver type std::string determineSolverType(); diff --git a/FF/Pressure.C b/FF/Pressure.C index 5429a2fb..5c1dc8aa 100644 --- a/FF/Pressure.C +++ b/FF/Pressure.C @@ -1,4 +1,5 @@ #include "Pressure.H" +#include "coupledPressureFvPatchField.H" using namespace Foam; @@ -90,11 +91,21 @@ void preciceAdapter::FF::Pressure::read(double* buffer, const unsigned int dim) { int patchID = patchIDs_.at(j); + // Get the pressure value boundary patch + scalarField* valuePatchPtr = &p_->boundaryFieldRef()[patchID]; + if (isA(p_->boundaryFieldRef()[patchID])) + { + valuePatchPtr = &refCast( + p_->boundaryFieldRef()[patchID]) + .refValue(); + } + scalarField& valuePatch = *valuePatchPtr; + // For every cell of the patch forAll(p_->boundaryFieldRef()[patchID], i) { // Set the pressure as the buffer value - p_->boundaryFieldRef()[patchID][i] = + valuePatch[i] = buffer[bufferIndex++]; } } diff --git a/FF/Temperature.C b/FF/Temperature.C new file mode 100644 index 00000000..62f26476 --- /dev/null +++ b/FF/Temperature.C @@ -0,0 +1,60 @@ +#include "Temperature.H" + +using namespace Foam; + +preciceAdapter::FF::Temperature::Temperature( + const Foam::fvMesh& mesh, + const std::string nameT) +: T_( + const_cast( + &mesh.lookupObject(nameT))) +{ + dataType_ = scalar; +} + +void preciceAdapter::FF::Temperature::write(double* buffer, bool meshConnectivity, const unsigned int dim) +{ + int bufferIndex = 0; + + // For every boundary patch of the interface + for (uint j = 0; j < patchIDs_.size(); j++) + { + int patchID = patchIDs_.at(j); + scalarField gradientPatch((T_->boundaryFieldRef()[patchID]) + .snGrad()); + + // For every cell of the patch + forAll(T_->boundaryFieldRef()[patchID], i) + { + // Copy the pressure into the buffer + buffer[bufferIndex++] = + T_->boundaryFieldRef()[patchID][i]; + } + } +} + +void preciceAdapter::FF::Temperature::read(double* buffer, const unsigned int dim) +{ + int bufferIndex = 0; + + // For every boundary patch of the interface + for (uint j = 0; j < patchIDs_.size(); j++) + { + int patchID = patchIDs_.at(j); + // For every cell of the patch + forAll(T_->boundaryFieldRef()[patchID], i) + { + T_->boundaryFieldRef()[patchID][i] = buffer[bufferIndex++]; + } + } +} + +bool preciceAdapter::FF::Temperature::isLocationTypeSupported(const bool meshConnectivity) const +{ + return (this->locationType_ == LocationType::faceCenters); +} + +std::string preciceAdapter::FF::Temperature::getDataName() const +{ + return "Temperature"; +} diff --git a/FF/Temperature.H b/FF/Temperature.H new file mode 100644 index 00000000..f3a365b7 --- /dev/null +++ b/FF/Temperature.H @@ -0,0 +1,42 @@ +#ifndef FF_TEMPERATURE_H +#define FF_TEMPERATURE_H + +#include "CouplingDataUser.H" + +#include "fvCFD.H" + +namespace preciceAdapter +{ +namespace FF +{ + +//- Class that writes and reads temperature +class Temperature : public CouplingDataUser +{ + +private: + //- Temperature field + Foam::volScalarField* T_; + +public: + //- Constructor + Temperature( + const Foam::fvMesh& mesh, + const std::string nameT); + + //- Write the temperature values into the buffer + void write(double* buffer, bool meshConnectivity, const unsigned int dim); + + //- Read the temperature values from the buffer + void read(double* buffer, const unsigned int dim); + + bool isLocationTypeSupported(const bool meshConnectivity) const override; + + //- Get the name of the current data field + std::string getDataName() const override; +}; + +} +} + +#endif diff --git a/FF/TemperatureGradient.C b/FF/TemperatureGradient.C new file mode 100644 index 00000000..911001b6 --- /dev/null +++ b/FF/TemperatureGradient.C @@ -0,0 +1,72 @@ +#include "TemperatureGradient.H" +#include "mixedFvPatchFields.H" + +using namespace Foam; + +preciceAdapter::FF::TemperatureGradient::TemperatureGradient( + const Foam::fvMesh& mesh, + const std::string nameT) +: T_( + const_cast( + &mesh.lookupObject(nameT))) +{ + dataType_ = scalar; +} + +void preciceAdapter::FF::TemperatureGradient::write(double* buffer, bool meshConnectivity, const unsigned int dim) +{ + int bufferIndex = 0; + + // For every boundary patch of the interface + for (uint j = 0; j < patchIDs_.size(); j++) + { + int patchID = patchIDs_.at(j); + + // Get the Temperature gradient boundary patch + const scalarField gradientPatch((T_->boundaryFieldRef()[patchID]) + .snGrad()); + + // For every cell of the patch + forAll(gradientPatch, i) + { + // Copy the Temperature gradient into the buffer + buffer[bufferIndex++] = + gradientPatch[i]; + } + } +} + +void preciceAdapter::FF::TemperatureGradient::read(double* buffer, const unsigned int dim) +{ + int bufferIndex = 0; + + // For every boundary patch of the interface + for (uint j = 0; j < patchIDs_.size(); j++) + { + int patchID = patchIDs_.at(j); + + // Get the Temperature gradient boundary patch + scalarField& gradientPatch = + refCast( + T_->boundaryFieldRef()[patchID]) + .gradient(); + + // For every cell of the patch + forAll(gradientPatch, i) + { + // Set the Temperature gradient as the buffer value + gradientPatch[i] = + -buffer[bufferIndex++]; + } + } +} + +bool preciceAdapter::FF::TemperatureGradient::isLocationTypeSupported(const bool meshConnectivity) const +{ + return (this->locationType_ == LocationType::faceCenters); +} + +std::string preciceAdapter::FF::TemperatureGradient::getDataName() const +{ + return "TemperatureGradient"; +} diff --git a/FF/TemperatureGradient.H b/FF/TemperatureGradient.H new file mode 100644 index 00000000..6675b647 --- /dev/null +++ b/FF/TemperatureGradient.H @@ -0,0 +1,42 @@ +#ifndef FF_TEMPERATURE_GRADIENT_H +#define FF_TEMPERATURE_GRADIENT_H + +#include "CouplingDataUser.H" + +#include "fvCFD.H" + +namespace preciceAdapter +{ +namespace FF +{ + +//- Class that writes and reads Temperature gradient +class TemperatureGradient : public CouplingDataUser +{ + +private: + //- Temperature field + Foam::volScalarField* T_; + +public: + //- Constructor + TemperatureGradient( + const Foam::fvMesh& mesh, + const std::string nameT); + + //- Write the Temperature gradient values into the buffer + void write(double* buffer, bool meshConnectivity, const unsigned int dim); + + //- Read the Temperature gradient values from the buffer + void read(double* buffer, const unsigned int dim); + + bool isLocationTypeSupported(const bool meshConnectivity) const override; + + //- Get the name of the current data field + std::string getDataName() const override; +}; + +} +} + +#endif diff --git a/FF/Velocity.C b/FF/Velocity.C index 2af7049e..be34d971 100644 --- a/FF/Velocity.C +++ b/FF/Velocity.C @@ -1,10 +1,19 @@ #include "Velocity.H" +#include "coupledVelocityFvPatchField.H" using namespace Foam; preciceAdapter::FF::Velocity::Velocity( const Foam::fvMesh& mesh, - const std::string nameU) + const std::string nameU, + const std::string namePhi, + bool fluxCorrection) +: U_( + const_cast( + &mesh.lookupObject(nameU))), + phi_(const_cast( + &mesh.lookupObject(namePhi))), + fluxCorrection_(fluxCorrection) { if (mesh.foundObject(nameU)) { @@ -78,23 +87,34 @@ void preciceAdapter::FF::Velocity::write(double* buffer, bool meshConnectivity, { int patchID = patchIDs_.at(j); + vectorField UPatch = U_->boundaryField()[patchID]; + + // Correct the velocity by the boundary face flux + if (fluxCorrection_) + { + scalarField phip = phi_->boundaryFieldRef()[patchID]; + vectorField n = U_->boundaryField()[patchID].patch().nf(); + const scalarField& magS = U_->boundaryFieldRef()[patchID].patch().magSf(); + UPatch = UPatch - n * (n & U_->boundaryField()[patchID]) + n * phip / magS; + } + // For every cell of the patch forAll(U_->boundaryFieldRef()[patchID], i) { // Copy the velocity into the buffer // x-dimension buffer[bufferIndex++] = - U_->boundaryFieldRef()[patchID][i].x(); + UPatch[i].x(); // y-dimension buffer[bufferIndex++] = - U_->boundaryFieldRef()[patchID][i].y(); + UPatch[i].y(); if (dim == 3) { // z-dimension buffer[bufferIndex++] = - U_->boundaryFieldRef()[patchID][i].z(); + UPatch[i].z(); } } } @@ -153,22 +173,32 @@ void preciceAdapter::FF::Velocity::read(double* buffer, const unsigned int dim) { int patchID = patchIDs_.at(j); + // Get the velocity value boundary patch + vectorField* valuePatchPtr = &U_->boundaryFieldRef()[patchID]; + if (isA(U_->boundaryFieldRef()[patchID])) + { + valuePatchPtr = &refCast( + U_->boundaryFieldRef()[patchID]) + .refValue(); + } + vectorField& valuePatch = *valuePatchPtr; + // For every cell of the patch forAll(U_->boundaryFieldRef()[patchID], i) { // Set the velocity as the buffer value // x-dimension - U_->boundaryFieldRef()[patchID][i].x() = + valuePatch[i].x() = buffer[bufferIndex++]; // y-dimension - U_->boundaryFieldRef()[patchID][i].y() = + valuePatch[i].y() = buffer[bufferIndex++]; if (dim == 3) { // z-dimension - U_->boundaryFieldRef()[patchID][i].z() = + valuePatch[i].z() = buffer[bufferIndex++]; } } diff --git a/FF/Velocity.H b/FF/Velocity.H index 3c902470..901e3334 100644 --- a/FF/Velocity.H +++ b/FF/Velocity.H @@ -18,12 +18,18 @@ class Velocity : public CouplingDataUser private: //- Velocity field Foam::volVectorField* U_; + //- Face flux field + Foam::surfaceScalarField* phi_; + //- Correct velocity by face flux + bool fluxCorrection_ = false; public: //- Constructor Velocity( const Foam::fvMesh& mesh, - const std::string nameU); + const std::string nameU, + const std::string namePhi, + bool fluxCorrection = false); //- Write the velocity values into the buffer void write(double* buffer, bool meshConnectivity, const unsigned int dim); diff --git a/FF/VelocityGradient.C b/FF/VelocityGradient.C index 8c100602..1536fdbd 100644 --- a/FF/VelocityGradient.C +++ b/FF/VelocityGradient.C @@ -1,4 +1,5 @@ #include "VelocityGradient.H" +#include "coupledVelocityFvPatchField.H" using namespace Foam; @@ -57,10 +58,21 @@ void preciceAdapter::FF::VelocityGradient::read(double* buffer, const unsigned i int patchID = patchIDs_.at(j); // Get the velocity gradient boundary patch - vectorField& gradientPatch = - refCast( - U_->boundaryFieldRef()[patchID]) - .gradient(); + vectorField* gradientPatchPtr; + if (isA(U_->boundaryFieldRef()[patchID])) + { + gradientPatchPtr = &refCast( + U_->boundaryFieldRef()[patchID]) + .refGrad(); + } + else + { + gradientPatchPtr = &refCast( + U_->boundaryFieldRef()[patchID]) + .gradient(); + } + vectorField& gradientPatch = *gradientPatchPtr; + // For every cell of the patch forAll(gradientPatch, i) diff --git a/Make/files b/Make/files index adf8dd18..001f7730 100644 --- a/Make/files +++ b/Make/files @@ -24,6 +24,10 @@ FF/Velocity.C FF/VelocityGradient.C FF/Pressure.C FF/PressureGradient.C +FF/Temperature.C +FF/TemperatureGradient.C +FF/BoundaryConditions/coupledPressure/coupledPressureFvPatchField.C +FF/BoundaryConditions/coupledVelocity/coupledVelocityFvPatchField.C Adapter.C diff --git a/changelog-entries/281.md b/changelog-entries/281.md new file mode 100644 index 00000000..562c79ba --- /dev/null +++ b/changelog-entries/281.md @@ -0,0 +1,5 @@ +### Added + +- Custom inletOutlet boundary conditions for pressure and velocity to the FF module [#281](https://github.com/precice/openfoam-adapter/pull/281). +- Temperature and temperature gradient as coupled data to the FF module. +- Option to write velocity that is corrected by the face flux `phi`. \ No newline at end of file diff --git a/docs/config.md b/docs/config.md index 78431a34..073a1fa9 100644 --- a/docs/config.md +++ b/docs/config.md @@ -217,13 +217,35 @@ solver displacementLaplacian; #### FF -The fluid-fluid coupling module supports reading and writing `Pressure`, `Velocity`, `PressureGradient`, and `VelocityGradient`. +The fluid-fluid coupling module supports reading and writing `Pressure`, `Velocity`, `PressureGradient`, `VelocityGradient`, `FlowTemperature` and `FlowTemperatureGradient`. Similarly to the CHT module, you need a `fixedValue` boundary condition of the respective primary field in order to read and apply values, and a `fixedGradient` boundary condition of the respective gradient field in order to read and apply gradients. +Alternatively, the adapter also ships custom boundary conditions for pressure (`coupledPressure`) and velocity (`coupledVelocity`). These boundary conditions can be set on both sides of the coupling interface and can handle fluid flow in either direction. An initial `refValue` must be supplied to ensure convergence in the first time step. The adapter will overwrite the value afterwards. +If the OpenFOAM fields `phi` and `U` are given different names, they should be supplied to the boundary conditions as well. +The coupled boundary conditions act similar to the [`inletOutlet`](https://www.openfoam.com/documentation/guides/v2112/doc/guide-bcs-outlet-inlet-outlet.html) boundary conditions from OpenFOAM. However, the pressure gradient is calculated by OpenFOAM as for the [`fixedFluxExtrapolatedPressure`](https://www.openfoam.com/documentation/guides/v2112/api/classFoam_1_1fixedFluxExtrapolatedPressureFvPatchScalarField.html) boundary condition and thus no coupling of `PressureGradient` is required when using `coupledPressure`. + +```c++ +// File 0/U +interface +{ + type coupledVelocity; + refvalue uniform (0 0 0); + // phi phiName +} + +// File 0/p +interface +{ + type coupledPressure; + refValue $internalField; + // phi phiName + // U UName +} +``` + {% experimental %} The FF module is still experimental and the boundary conditions presented here have not been rigorously tested. -We already have reasons to believe that a `fixedGradient` can have [side-effects](https://github.com/precice/openfoam-adapter/issues/93) and may not lead to completely accurate results. {% endexperimental %} ### Volume coupling @@ -325,21 +347,21 @@ To load this adapter, you must include the following in the `system/controlDict` configuration file of the case: ```c++ +libs ("libpreciceAdapterFunctionObject.so"); functions { preCICE_Adapter { type preciceAdapterFunctionObject; - libs ("libpreciceAdapterFunctionObject.so"); } } ``` This directs the solver to use the `preciceAdapterFunctionObject` function object, which is part of the `libpreciceAdapterFunctionObject.so` shared library. -The name `preCICE_Adapter` can be arbitrary. +The name `preCICE_Adapter` can be arbitrary. It is important that the library is loaded outside the `functions` dictionary when you want to use the custom boundary conditions that we provide with the FF module. -If you are using other function objects in your simulation, add the preCICE adapter to the end of the list. The adapter will then be executed last, which is important, as the adapter also controls the end of the simulation. When the end of the simulation is detected, the adapter also triggers the `end()` method method of all function objects. +If you are using other function objects in your simulation, add the preCICE adapter to the end of the list. The adapter will then be executed last, which is important, as the adapter also controls the end of the simulation. When the end of the simulation is detected, the adapter also triggers the `end()` method of all function objects. *** @@ -440,6 +462,19 @@ rho rho [1 -3 0 0 0 0 0] 1; Notice that here, in contrast to the `CHT` subdict, we need to provide both the keyword (first `nu`) and the word name (second `nu`). We are working on bringing consistency on this. +#### Fluid-fluid coupling + +The FF module provides an option to correct the written velocity values for the face flux values `phi`. This may provide better mass consistency across the coupling interface when the used mesh is skewed. By default, this option is turned off. + +```c++ +FF +{ + fluxCorrection true; + namePhi phi; +} + +``` + ### Additional parameters in the adapter's configuration file Some optional parameters can allow the adapter to work with more solvers, whose type is not determined automatically, their fields have different names, or they do not work well with some features of the adapter. From b0f4d1ffe99c93db2deaf2bd041ee707766e1337 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Thu, 17 Aug 2023 15:51:37 +0200 Subject: [PATCH 40/60] Fix typo in DEBUG log of FF coupling --- FF/FF.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FF/FF.C b/FF/FF.C index 439a7281..15b2e53b 100644 --- a/FF/FF.C +++ b/FF/FF.C @@ -69,7 +69,7 @@ bool preciceAdapter::FF::FluidFluid::readConfig(const IOdictionary& adapterConfi // Check whether to enable flux correction for velocity fluxCorrection_ = FFdict.lookupOrDefault("fluxCorrection", false); - DEBUG(adapterInfo(" flux correction of velocity is set to : " + std::string(fluxCorrection_))); + DEBUG(adapterInfo(" flux correction of velocity is set to : " + std::to_string(fluxCorrection_))); return true; } From 61e7f6913b4cd980e9e244f08f83407536675a51 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Sun, 3 Sep 2023 19:04:27 +0300 Subject: [PATCH 41/60] Reduce build targets to save building time (#301) --- CHT/ModuleCHT.C | 7 +++++++ FF/ModuleFF.C | 10 ++++++++++ FSI/ModuleFSI.C | 7 +++++++ Make/files | 27 +++------------------------ changelog-entries/301.md | 1 + 5 files changed, 28 insertions(+), 24 deletions(-) create mode 100644 CHT/ModuleCHT.C create mode 100644 FF/ModuleFF.C create mode 100644 FSI/ModuleFSI.C create mode 100644 changelog-entries/301.md diff --git a/CHT/ModuleCHT.C b/CHT/ModuleCHT.C new file mode 100644 index 00000000..2387b077 --- /dev/null +++ b/CHT/ModuleCHT.C @@ -0,0 +1,7 @@ +// Central inlude file to reduce the number of build targets and build time +#include "Temperature.C" +#include "KappaEffective.C" +#include "HeatFlux.C" +#include "HeatTransferCoefficient.C" +#include "SinkTemperature.C" +#include "CHT.C" diff --git a/FF/ModuleFF.C b/FF/ModuleFF.C new file mode 100644 index 00000000..30465704 --- /dev/null +++ b/FF/ModuleFF.C @@ -0,0 +1,10 @@ +// Central inlude file to reduce the number of build targets and build time +#include "FF.C" +#include "Velocity.C" +#include "VelocityGradient.C" +#include "Pressure.C" +#include "PressureGradient.C" +#include "Temperature.C" +#include "TemperatureGradient.C" +#include "BoundaryConditions/coupledPressure/coupledPressureFvPatchField.C" +#include "BoundaryConditions/coupledVelocity/coupledVelocityFvPatchField.C" diff --git a/FSI/ModuleFSI.C b/FSI/ModuleFSI.C new file mode 100644 index 00000000..0eccb26b --- /dev/null +++ b/FSI/ModuleFSI.C @@ -0,0 +1,7 @@ +// Central inlude file to reduce the number of build targets and build time +#include "FSI.C" +#include "ForceBase.C" +#include "Force.C" +#include "Stress.C" +#include "Displacement.C" +#include "DisplacementDelta.C" diff --git a/Make/files b/Make/files index 001f7730..6fae86ae 100644 --- a/Make/files +++ b/Make/files @@ -4,30 +4,9 @@ Interface.C CouplingDataUser.C -CHT/Temperature.C -CHT/KappaEffective.C -CHT/HeatFlux.C -CHT/HeatTransferCoefficient.C -CHT/SinkTemperature.C - -CHT/CHT.C - -FSI/FSI.C -FSI/ForceBase.C -FSI/Force.C -FSI/Stress.C -FSI/Displacement.C -FSI/DisplacementDelta.C - -FF/FF.C -FF/Velocity.C -FF/VelocityGradient.C -FF/Pressure.C -FF/PressureGradient.C -FF/Temperature.C -FF/TemperatureGradient.C -FF/BoundaryConditions/coupledPressure/coupledPressureFvPatchField.C -FF/BoundaryConditions/coupledVelocity/coupledVelocityFvPatchField.C +CHT/ModuleCHT.C +FSI/ModuleFSI.C +FF/ModuleFF.C Adapter.C diff --git a/changelog-entries/301.md b/changelog-entries/301.md new file mode 100644 index 00000000..221bc99a --- /dev/null +++ b/changelog-entries/301.md @@ -0,0 +1 @@ +- Reduced building time by grouping together compilation units of each module [#301](https://github.com/precice/openfoam-adapter/pull/301) From c3968687a9cbaeacc599730681cb266108dd3a71 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Mon, 16 Oct 2023 08:27:55 +0200 Subject: [PATCH 42/60] Pass the correct number of entries to `writeData` (#305) * Change signature of write function to consider size_t * Implement return type for all CouplingDataUsers * Read relevant buffer part only * Indentation with clang-format 11 --- CHT/HeatFlux.C | 3 ++- CHT/HeatFlux.H | 2 +- CHT/HeatTransferCoefficient.C | 3 ++- CHT/HeatTransferCoefficient.H | 2 +- CHT/SinkTemperature.C | 3 ++- CHT/SinkTemperature.H | 2 +- CHT/Temperature.C | 3 ++- CHT/Temperature.H | 2 +- CouplingDataUser.H | 3 ++- FF/Pressure.C | 3 ++- FF/Pressure.H | 2 +- FF/PressureGradient.C | 3 ++- FF/PressureGradient.H | 2 +- FF/Temperature.C | 3 ++- FF/Temperature.H | 2 +- FF/TemperatureGradient.C | 3 ++- FF/TemperatureGradient.H | 2 +- FF/Velocity.C | 3 ++- FF/Velocity.H | 2 +- FF/VelocityGradient.C | 3 ++- FF/VelocityGradient.H | 2 +- FSI/Displacement.C | 6 +++--- FSI/Displacement.H | 2 +- FSI/DisplacementDelta.C | 3 ++- FSI/DisplacementDelta.H | 2 +- FSI/Force.C | 4 ++-- FSI/Force.H | 2 +- FSI/ForceBase.C | 7 ++++--- FSI/ForceBase.H | 6 +++--- FSI/Stress.C | 4 ++-- FSI/Stress.H | 2 +- Interface.C | 10 +++++++--- 32 files changed, 59 insertions(+), 42 deletions(-) diff --git a/CHT/HeatFlux.C b/CHT/HeatFlux.C index 2c7d1fb3..7c63e290 100644 --- a/CHT/HeatFlux.C +++ b/CHT/HeatFlux.C @@ -18,7 +18,7 @@ preciceAdapter::CHT::HeatFlux::HeatFlux( dataType_ = scalar; } -void preciceAdapter::CHT::HeatFlux::write(double* buffer, bool meshConnectivity, const unsigned int dim) +std::size_t preciceAdapter::CHT::HeatFlux::write(double* buffer, bool meshConnectivity, const unsigned int dim) { int bufferIndex = 0; @@ -68,6 +68,7 @@ void preciceAdapter::CHT::HeatFlux::write(double* buffer, bool meshConnectivity, } } } + return bufferIndex; } void preciceAdapter::CHT::HeatFlux::read(double* buffer, const unsigned int dim) diff --git a/CHT/HeatFlux.H b/CHT/HeatFlux.H index ea21eac7..c3c4aa2e 100644 --- a/CHT/HeatFlux.H +++ b/CHT/HeatFlux.H @@ -33,7 +33,7 @@ public: //- Compute heat flux values from the temperature field // and write them into the buffer - void write(double* buffer, bool meshConnectivity, const unsigned int dim) final; + std::size_t write(double* buffer, bool meshConnectivity, const unsigned int dim) final; //- Read heat flux values from the buffer and assign them to // the gradient of the temperature field diff --git a/CHT/HeatTransferCoefficient.C b/CHT/HeatTransferCoefficient.C index ccd9bb7b..68778280 100644 --- a/CHT/HeatTransferCoefficient.C +++ b/CHT/HeatTransferCoefficient.C @@ -20,7 +20,7 @@ preciceAdapter::CHT::HeatTransferCoefficient::HeatTransferCoefficient( } -void preciceAdapter::CHT::HeatTransferCoefficient::write(double* buffer, bool meshConnectivity, const unsigned int dim) +std::size_t preciceAdapter::CHT::HeatTransferCoefficient::write(double* buffer, bool meshConnectivity, const unsigned int dim) { int bufferIndex = 0; @@ -69,6 +69,7 @@ void preciceAdapter::CHT::HeatTransferCoefficient::write(double* buffer, bool me } } } + return bufferIndex; } diff --git a/CHT/HeatTransferCoefficient.H b/CHT/HeatTransferCoefficient.H index c09edd00..bc0b887e 100644 --- a/CHT/HeatTransferCoefficient.H +++ b/CHT/HeatTransferCoefficient.H @@ -35,7 +35,7 @@ public: const std::string nameT); //- Write the heat transfer coefficient values into the buffer - void write(double* buffer, bool meshConnectivity, const unsigned int dim) final; + std::size_t write(double* buffer, bool meshConnectivity, const unsigned int dim) final; //- Read the heat transfer coefficient values from the buffer void read(double* buffer, const unsigned int dim) final; diff --git a/CHT/SinkTemperature.C b/CHT/SinkTemperature.C index 8d2498a7..9ed18244 100644 --- a/CHT/SinkTemperature.C +++ b/CHT/SinkTemperature.C @@ -14,7 +14,7 @@ preciceAdapter::CHT::SinkTemperature::SinkTemperature( dataType_ = scalar; } -void preciceAdapter::CHT::SinkTemperature::write(double* buffer, bool meshConnectivity, const unsigned int dim) +std::size_t preciceAdapter::CHT::SinkTemperature::write(double* buffer, bool meshConnectivity, const unsigned int dim) { int bufferIndex = 0; @@ -63,6 +63,7 @@ void preciceAdapter::CHT::SinkTemperature::write(double* buffer, bool meshConnec // Clear the temporary internal field object patchInternalFieldTmp.clear(); } + return bufferIndex; } void preciceAdapter::CHT::SinkTemperature::read(double* buffer, const unsigned int dim) diff --git a/CHT/SinkTemperature.H b/CHT/SinkTemperature.H index 68493e54..ab15bce7 100644 --- a/CHT/SinkTemperature.H +++ b/CHT/SinkTemperature.H @@ -26,7 +26,7 @@ public: const std::string nameT); //- Write the sink temperature values into the buffer - void write(double* buffer, bool meshConnectivity, const unsigned int dim); + std::size_t write(double* buffer, bool meshConnectivity, const unsigned int dim); //- Read the sink temperature values from the buffer void read(double* buffer, const unsigned int dim); diff --git a/CHT/Temperature.C b/CHT/Temperature.C index 4452da2a..3459e840 100644 --- a/CHT/Temperature.C +++ b/CHT/Temperature.C @@ -15,7 +15,7 @@ preciceAdapter::CHT::Temperature::Temperature( dataType_ = scalar; } -void preciceAdapter::CHT::Temperature::write(double* buffer, bool meshConnectivity, const unsigned int dim) +std::size_t preciceAdapter::CHT::Temperature::write(double* buffer, bool meshConnectivity, const unsigned int dim) { int bufferIndex = 0; @@ -79,6 +79,7 @@ void preciceAdapter::CHT::Temperature::write(double* buffer, bool meshConnectivi } } } + return bufferIndex; } void preciceAdapter::CHT::Temperature::read(double* buffer, const unsigned int dim) diff --git a/CHT/Temperature.H b/CHT/Temperature.H index cd776272..a374d64d 100644 --- a/CHT/Temperature.H +++ b/CHT/Temperature.H @@ -27,7 +27,7 @@ public: const std::string nameT); //- Write the temperature values into the buffer - void write(double* buffer, bool meshConnectivity, const unsigned int dim); + std::size_t write(double* buffer, bool meshConnectivity, const unsigned int dim); //- Read the temperature values from the buffer void read(double* buffer, const unsigned int dim); diff --git a/CouplingDataUser.H b/CouplingDataUser.H index 7ce00d8d..8faab32a 100644 --- a/CouplingDataUser.H +++ b/CouplingDataUser.H @@ -74,7 +74,8 @@ public: virtual void initialize(); //- Write the coupling data to the buffer - virtual void write(double* dataBuffer, bool meshConnectivity, const unsigned int dim) = 0; + // Returns the number of entries that were filles in the buffer (nComp * vertices) + virtual std::size_t write(double* dataBuffer, bool meshConnectivity, const unsigned int dim) = 0; //- Read the coupling data from the buffer virtual void read(double* dataBuffer, const unsigned int dim) = 0; diff --git a/FF/Pressure.C b/FF/Pressure.C index 5c1dc8aa..5e8b94db 100644 --- a/FF/Pressure.C +++ b/FF/Pressure.C @@ -13,7 +13,7 @@ preciceAdapter::FF::Pressure::Pressure( dataType_ = scalar; } -void preciceAdapter::FF::Pressure::write(double* buffer, bool meshConnectivity, const unsigned int dim) +std::size_t preciceAdapter::FF::Pressure::write(double* buffer, bool meshConnectivity, const unsigned int dim) { int bufferIndex = 0; @@ -55,6 +55,7 @@ void preciceAdapter::FF::Pressure::write(double* buffer, bool meshConnectivity, p_->boundaryFieldRef()[patchID][i]; } } + return bufferIndex; } void preciceAdapter::FF::Pressure::read(double* buffer, const unsigned int dim) diff --git a/FF/Pressure.H b/FF/Pressure.H index 1793278f..ecd06a02 100644 --- a/FF/Pressure.H +++ b/FF/Pressure.H @@ -26,7 +26,7 @@ public: const std::string nameP); //- Write the pressure values into the buffer - void write(double* buffer, bool meshConnectivity, const unsigned int dim); + std::size_t write(double* buffer, bool meshConnectivity, const unsigned int dim); //- Read the pressure values from the buffer void read(double* buffer, const unsigned int dim); diff --git a/FF/PressureGradient.C b/FF/PressureGradient.C index ef8dd9ff..ca125179 100644 --- a/FF/PressureGradient.C +++ b/FF/PressureGradient.C @@ -12,7 +12,7 @@ preciceAdapter::FF::PressureGradient::PressureGradient( dataType_ = scalar; } -void preciceAdapter::FF::PressureGradient::write(double* buffer, bool meshConnectivity, const unsigned int dim) +std::size_t preciceAdapter::FF::PressureGradient::write(double* buffer, bool meshConnectivity, const unsigned int dim) { int bufferIndex = 0; @@ -33,6 +33,7 @@ void preciceAdapter::FF::PressureGradient::write(double* buffer, bool meshConnec -gradientPatch[i]; } } + return bufferIndex; } void preciceAdapter::FF::PressureGradient::read(double* buffer, const unsigned int dim) diff --git a/FF/PressureGradient.H b/FF/PressureGradient.H index 95094f3c..47db220e 100644 --- a/FF/PressureGradient.H +++ b/FF/PressureGradient.H @@ -25,7 +25,7 @@ public: const std::string nameP); //- Write the pressure gradient values into the buffer - void write(double* buffer, bool meshConnectivity, const unsigned int dim); + std::size_t write(double* buffer, bool meshConnectivity, const unsigned int dim); //- Read the pressure gradient values from the buffer void read(double* buffer, const unsigned int dim); diff --git a/FF/Temperature.C b/FF/Temperature.C index 62f26476..4aff8611 100644 --- a/FF/Temperature.C +++ b/FF/Temperature.C @@ -12,7 +12,7 @@ preciceAdapter::FF::Temperature::Temperature( dataType_ = scalar; } -void preciceAdapter::FF::Temperature::write(double* buffer, bool meshConnectivity, const unsigned int dim) +std::size_t preciceAdapter::FF::Temperature::write(double* buffer, bool meshConnectivity, const unsigned int dim) { int bufferIndex = 0; @@ -31,6 +31,7 @@ void preciceAdapter::FF::Temperature::write(double* buffer, bool meshConnectivit T_->boundaryFieldRef()[patchID][i]; } } + return bufferIndex; } void preciceAdapter::FF::Temperature::read(double* buffer, const unsigned int dim) diff --git a/FF/Temperature.H b/FF/Temperature.H index f3a365b7..da6daad9 100644 --- a/FF/Temperature.H +++ b/FF/Temperature.H @@ -25,7 +25,7 @@ public: const std::string nameT); //- Write the temperature values into the buffer - void write(double* buffer, bool meshConnectivity, const unsigned int dim); + std::size_t write(double* buffer, bool meshConnectivity, const unsigned int dim); //- Read the temperature values from the buffer void read(double* buffer, const unsigned int dim); diff --git a/FF/TemperatureGradient.C b/FF/TemperatureGradient.C index 911001b6..e9384c7a 100644 --- a/FF/TemperatureGradient.C +++ b/FF/TemperatureGradient.C @@ -13,7 +13,7 @@ preciceAdapter::FF::TemperatureGradient::TemperatureGradient( dataType_ = scalar; } -void preciceAdapter::FF::TemperatureGradient::write(double* buffer, bool meshConnectivity, const unsigned int dim) +std::size_t preciceAdapter::FF::TemperatureGradient::write(double* buffer, bool meshConnectivity, const unsigned int dim) { int bufferIndex = 0; @@ -34,6 +34,7 @@ void preciceAdapter::FF::TemperatureGradient::write(double* buffer, bool meshCon gradientPatch[i]; } } + return bufferIndex; } void preciceAdapter::FF::TemperatureGradient::read(double* buffer, const unsigned int dim) diff --git a/FF/TemperatureGradient.H b/FF/TemperatureGradient.H index 6675b647..c7259a7b 100644 --- a/FF/TemperatureGradient.H +++ b/FF/TemperatureGradient.H @@ -25,7 +25,7 @@ public: const std::string nameT); //- Write the Temperature gradient values into the buffer - void write(double* buffer, bool meshConnectivity, const unsigned int dim); + std::size_t write(double* buffer, bool meshConnectivity, const unsigned int dim); //- Read the Temperature gradient values from the buffer void read(double* buffer, const unsigned int dim); diff --git a/FF/Velocity.C b/FF/Velocity.C index be34d971..28092919 100644 --- a/FF/Velocity.C +++ b/FF/Velocity.C @@ -34,7 +34,7 @@ preciceAdapter::FF::Velocity::Velocity( dataType_ = vector; } -void preciceAdapter::FF::Velocity::write(double* buffer, bool meshConnectivity, const unsigned int dim) +std::size_t preciceAdapter::FF::Velocity::write(double* buffer, bool meshConnectivity, const unsigned int dim) { int bufferIndex = 0; @@ -118,6 +118,7 @@ void preciceAdapter::FF::Velocity::write(double* buffer, bool meshConnectivity, } } } + return bufferIndex; } void preciceAdapter::FF::Velocity::read(double* buffer, const unsigned int dim) diff --git a/FF/Velocity.H b/FF/Velocity.H index 901e3334..c6706821 100644 --- a/FF/Velocity.H +++ b/FF/Velocity.H @@ -32,7 +32,7 @@ public: bool fluxCorrection = false); //- Write the velocity values into the buffer - void write(double* buffer, bool meshConnectivity, const unsigned int dim); + std::size_t write(double* buffer, bool meshConnectivity, const unsigned int dim); //- Read the velocity values from the buffer void read(double* buffer, const unsigned int dim); diff --git a/FF/VelocityGradient.C b/FF/VelocityGradient.C index 1536fdbd..90c685a7 100644 --- a/FF/VelocityGradient.C +++ b/FF/VelocityGradient.C @@ -13,7 +13,7 @@ preciceAdapter::FF::VelocityGradient::VelocityGradient( dataType_ = vector; } -void preciceAdapter::FF::VelocityGradient::write(double* buffer, bool meshConnectivity, const unsigned int dim) +std::size_t preciceAdapter::FF::VelocityGradient::write(double* buffer, bool meshConnectivity, const unsigned int dim) { int bufferIndex = 0; @@ -46,6 +46,7 @@ void preciceAdapter::FF::VelocityGradient::write(double* buffer, bool meshConnec } } } + return bufferIndex; } void preciceAdapter::FF::VelocityGradient::read(double* buffer, const unsigned int dim) diff --git a/FF/VelocityGradient.H b/FF/VelocityGradient.H index 3e1f16da..77430aeb 100644 --- a/FF/VelocityGradient.H +++ b/FF/VelocityGradient.H @@ -25,7 +25,7 @@ public: const std::string nameU); //- Write the velocity gradient values into the buffer - void write(double* buffer, bool meshConnectivity, const unsigned int dim) final; + std::size_t write(double* buffer, bool meshConnectivity, const unsigned int dim) final; //- Read the velocity gradient values from the buffer void read(double* buffer, const unsigned int dim) final; diff --git a/FSI/Displacement.C b/FSI/Displacement.C index 69baf676..4a76e26f 100644 --- a/FSI/Displacement.C +++ b/FSI/Displacement.C @@ -36,7 +36,7 @@ void preciceAdapter::FSI::Displacement::initialize() } -void preciceAdapter::FSI::Displacement::write(double* buffer, bool meshConnectivity, const unsigned int dim) +std::size_t preciceAdapter::FSI::Displacement::write(double* buffer, bool meshConnectivity, const unsigned int dim) { /* TODO: Implement * We need two nested for-loops for each patch, @@ -46,9 +46,9 @@ void preciceAdapter::FSI::Displacement::write(double* buffer, bool meshConnectiv // Copy the displacement field from OpenFOAM to the buffer + int bufferIndex = 0; if (this->locationType_ == LocationType::faceCenters) { - int bufferIndex = 0; // For every boundary patch of the interface for (const label patchID : patchIDs_) { @@ -70,7 +70,6 @@ void preciceAdapter::FSI::Displacement::write(double* buffer, bool meshConnectiv "See https://github.com/precice/openfoam-adapter/issues/153.", "warning")); - int bufferIndex = 0; // For every boundary patch of the interface for (const label patchID : patchIDs_) { @@ -87,6 +86,7 @@ void preciceAdapter::FSI::Displacement::write(double* buffer, bool meshConnectiv } } } + return bufferIndex; } diff --git a/FSI/Displacement.H b/FSI/Displacement.H index 8b7d5216..4339a29b 100644 --- a/FSI/Displacement.H +++ b/FSI/Displacement.H @@ -36,7 +36,7 @@ public: const std::string nameCellDisplacement); //- Write the displacement values into the buffer - void write(double* buffer, bool meshConnectivity, const unsigned int dim) final; + std::size_t write(double* buffer, bool meshConnectivity, const unsigned int dim) final; //- Read the displacement values from the buffer void read(double* buffer, const unsigned int dim) final; diff --git a/FSI/DisplacementDelta.C b/FSI/DisplacementDelta.C index 19c93139..a4bdd730 100644 --- a/FSI/DisplacementDelta.C +++ b/FSI/DisplacementDelta.C @@ -34,7 +34,7 @@ void preciceAdapter::FSI::DisplacementDelta::initialize() } -void preciceAdapter::FSI::DisplacementDelta::write(double* buffer, bool meshConnectivity, const unsigned int dim) +std::size_t preciceAdapter::FSI::DisplacementDelta::write(double* buffer, bool meshConnectivity, const unsigned int dim) { /* TODO: Implement * We need two nested for-loops for each patch, @@ -44,6 +44,7 @@ void preciceAdapter::FSI::DisplacementDelta::write(double* buffer, bool meshConn FatalErrorInFunction << "Writing displacementDeltas is not supported." << exit(FatalError); + return 0; } // return the displacement to use later in the velocity? diff --git a/FSI/DisplacementDelta.H b/FSI/DisplacementDelta.H index 27c57e51..65066b77 100644 --- a/FSI/DisplacementDelta.H +++ b/FSI/DisplacementDelta.H @@ -36,7 +36,7 @@ public: const std::string nameCellDisplacement); //- Write the displacementDelta values into the buffer - void write(double* buffer, bool meshConnectivity, const unsigned int dim) final; + std::size_t write(double* buffer, bool meshConnectivity, const unsigned int dim) final; //- Read the displacementDelta values from the buffer void read(double* buffer, const unsigned int dim) final; diff --git a/FSI/Force.C b/FSI/Force.C index a1ab6651..d8cbad39 100644 --- a/FSI/Force.C +++ b/FSI/Force.C @@ -36,9 +36,9 @@ preciceAdapter::FSI::Force::Force( } } -void preciceAdapter::FSI::Force::write(double* buffer, bool meshConnectivity, const unsigned int dim) +std::size_t preciceAdapter::FSI::Force::write(double* buffer, bool meshConnectivity, const unsigned int dim) { - this->writeToBuffer(buffer, *Force_, dim); + return this->writeToBuffer(buffer, *Force_, dim); } void preciceAdapter::FSI::Force::read(double* buffer, const unsigned int dim) diff --git a/FSI/Force.H b/FSI/Force.H index c528b14d..9e763c10 100644 --- a/FSI/Force.H +++ b/FSI/Force.H @@ -26,7 +26,7 @@ public: const std::string nameForce); //- Write the forces values into the buffer - void write(double* buffer, bool meshConnectivity, const unsigned int dim) final; + std::size_t write(double* buffer, bool meshConnectivity, const unsigned int dim) final; //- Read the forces values from the buffer void read(double* buffer, const unsigned int dim) final; diff --git a/FSI/ForceBase.C b/FSI/ForceBase.C index 4e9168b0..48297cdf 100644 --- a/FSI/ForceBase.C +++ b/FSI/ForceBase.C @@ -130,9 +130,9 @@ Foam::tmp preciceAdapter::FSI::ForceBase::mu() const } } -void preciceAdapter::FSI::ForceBase::writeToBuffer(double* buffer, - volVectorField& forceField, - const unsigned int dim) const +std::size_t preciceAdapter::FSI::ForceBase::writeToBuffer(double* buffer, + volVectorField& forceField, + const unsigned int dim) const { // Compute forces. See the Forces function object. // Stress tensor boundary field @@ -188,6 +188,7 @@ void preciceAdapter::FSI::ForceBase::writeToBuffer(double* buffer, forceField.boundaryField()[patchID][i][d]; } } + return bufferIndex; } void preciceAdapter::FSI::ForceBase::readFromBuffer(double* buffer) const diff --git a/FSI/ForceBase.H b/FSI/ForceBase.H index 38643333..2c53086a 100644 --- a/FSI/ForceBase.H +++ b/FSI/ForceBase.H @@ -39,9 +39,9 @@ public: const Foam::fvMesh& mesh, const std::string solverType); - void writeToBuffer(double* buffer, - Foam::volVectorField& forceField, - const unsigned int dim) const; + std::size_t writeToBuffer(double* buffer, + Foam::volVectorField& forceField, + const unsigned int dim) const; void readFromBuffer(double* buffer) const; diff --git a/FSI/Stress.C b/FSI/Stress.C index c5ba6d10..1194a249 100644 --- a/FSI/Stress.C +++ b/FSI/Stress.C @@ -21,9 +21,9 @@ preciceAdapter::FSI::Stress::Stress( Foam::vector::zero)); } -void preciceAdapter::FSI::Stress::write(double* buffer, bool meshConnectivity, const unsigned int dim) +std::size_t preciceAdapter::FSI::Stress::write(double* buffer, bool meshConnectivity, const unsigned int dim) { - this->writeToBuffer(buffer, *Stress_, dim); + return this->writeToBuffer(buffer, *Stress_, dim); } void preciceAdapter::FSI::Stress::read(double* buffer, const unsigned int dim) diff --git a/FSI/Stress.H b/FSI/Stress.H index 24f62034..331100b4 100644 --- a/FSI/Stress.H +++ b/FSI/Stress.H @@ -27,7 +27,7 @@ public: const std::string solverType); //- Write the stress values into the buffer - void write(double* buffer, bool meshConnectivity, const unsigned int dim) final; + std::size_t write(double* buffer, bool meshConnectivity, const unsigned int dim) final; //- Read the stress values from the buffer void read(double* buffer, const unsigned int dim) final; diff --git a/Interface.C b/Interface.C index f1ec1d12..cd2aa0d5 100644 --- a/Interface.C +++ b/Interface.C @@ -545,12 +545,16 @@ void preciceAdapter::Interface::readCouplingData(double relativeReadTime) // Make preCICE read vector or scalar data // and fill the adapter's buffer + std::size_t nReadData = vertexIDs_.size() * precice_.getDataDimensions(meshName_, couplingDataReader->dataName()); + // We could add a sanity check here + // nReadData == vertexIDs_.size() * (1 + (dim_ - 1) * static_cast(couplingDataReader->hasVectorData())); + precice_.readData( meshName_, couplingDataReader->dataName(), vertexIDs_, relativeReadTime, - dataBuffer_); + {dataBuffer_.data(), nReadData}); // Read the received data from the buffer couplingDataReader->read(dataBuffer_.data(), dim_); @@ -571,14 +575,14 @@ void preciceAdapter::Interface::writeCouplingData() couplingDataWriter = couplingDataWriters_.at(i); // Write the data into the adapter's buffer - couplingDataWriter->write(dataBuffer_.data(), meshConnectivity_, dim_); + auto nWrittenData = couplingDataWriter->write(dataBuffer_.data(), meshConnectivity_, dim_); // Make preCICE write vector or scalar data precice_.writeData( meshName_, couplingDataWriter->dataName(), vertexIDs_, - dataBuffer_); + {dataBuffer_.data(), nWrittenData}); } // } } From 99421f77f85e91262f921cf0bbdc3724d0a9cb20 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Tue, 28 Nov 2023 10:34:05 +0100 Subject: [PATCH 43/60] Re arrange read time according to adjustable dt (#298) Co-authored-by: Gerasimos Chourdakis --- Adapter.C | 30 +++++++++++++++--------------- Adapter.H | 3 ++- changelog-entries/298.md | 1 + 3 files changed, 18 insertions(+), 16 deletions(-) create mode 100644 changelog-entries/298.md diff --git a/Adapter.C b/Adapter.C index f49f8f80..b92f3d00 100644 --- a/Adapter.C +++ b/Adapter.C @@ -363,9 +363,6 @@ void preciceAdapter::Adapter::configure() // Initialize preCICE and exchange the first coupling data initialize(); - // Read the received coupling data - readCouplingData(runTime_.deltaT().value()); - // If checkpointing is required, specify the checkpointed fields // and write the first checkpoint if (requiresWritingCheckpoint()) @@ -382,7 +379,7 @@ void preciceAdapter::Adapter::configure() // Adjust the timestep for the first iteration, if it is fixed if (!adjustableTimestep_) { - adjustSolverTimeStep(); + adjustSolverTimeStepAndReadData(); } // If the solver tries to end before the coupling is complete, @@ -443,12 +440,6 @@ void preciceAdapter::Adapter::execute() readCheckpoint(); } - // Adjust the timestep, if it is fixed - if (!adjustableTimestep_) - { - adjustSolverTimeStep(); - } - // Write checkpoint if required if (requiresWritingCheckpoint()) { @@ -476,9 +467,11 @@ void preciceAdapter::Adapter::execute() } ACCUMULATE_TIMER(timeInWriteResults_); - // Read the received coupling data from the buffer - // Fits to an implicit Euler - readCouplingData(runTime_.deltaT().value()); + // Adjust the timestep, if it is fixed + if (!adjustableTimestep_) + { + adjustSolverTimeStepAndReadData(); + } // If the coupling is not going to continue, tear down everything // and stop the simulation. @@ -507,9 +500,10 @@ void preciceAdapter::Adapter::execute() return; } + void preciceAdapter::Adapter::adjustTimeStep() { - adjustSolverTimeStep(); + adjustSolverTimeStepAndReadData(); return; } @@ -599,7 +593,7 @@ void preciceAdapter::Adapter::advance() return; } -void preciceAdapter::Adapter::adjustSolverTimeStep() +void preciceAdapter::Adapter::adjustSolverTimeStepAndReadData() { DEBUG(adapterInfo("Adjusting the solver's timestep...")); @@ -695,6 +689,12 @@ void preciceAdapter::Adapter::adjustSolverTimeStep() // TODO: Keep this in mind if any relevant problem appears. const_cast(runTime_).setDeltaT(timestepSolver_, false); + DEBUG(adapterInfo("Reading coupling data associated to the calculated time-step size...")); + + // Read the received coupling data from the buffer + // Fits to an implicit Euler + readCouplingData(runTime_.deltaT().value()); + return; } diff --git a/Adapter.H b/Adapter.H index 2112898b..671c947f 100644 --- a/Adapter.H +++ b/Adapter.H @@ -271,7 +271,8 @@ private: void writeCouplingData(); //- Adjust the timestep of the solver according to preCICE - void adjustSolverTimeStep(); + // and read data associated to the calculated time step length + void adjustSolverTimeStepAndReadData(); //- Determine if the coupling is still happening bool isCouplingOngoing(); diff --git a/changelog-entries/298.md b/changelog-entries/298.md new file mode 100644 index 00000000..8163f04b --- /dev/null +++ b/changelog-entries/298.md @@ -0,0 +1 @@ +- Renamed the `adjustSolverTimeStep()` method to `adjustSolverTimeStepAndReadData()`, changing the behavior to always read data at the determined time step size. [#298](https://github.com/precice/openfoam-adapter/pull/298) From a0e5263810ad0f0f550e97da425d72ab316fbba4 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Tue, 23 Jan 2024 15:06:48 +0100 Subject: [PATCH 44/60] Update hint to performance metric files --- Adapter.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Adapter.C b/Adapter.C index b92f3d00..717a871b 100644 --- a/Adapter.C +++ b/Adapter.C @@ -1663,7 +1663,7 @@ preciceAdapter::Adapter::~Adapter() Info << " (I) advance(): " << timeInAdvance_.str() << nl; Info << " (I) finalize(): " << timeInFinalize_.str() << nl; Info << " These times include time waiting for other participants." << nl; - Info << " See also precice--events-summary.log." << nl; + Info << " See also precice-profiling on the website https://precice.org/tooling-performance-analysis.html." << nl; Info << "-------------------------------------------------------------------------------------" << nl;) return; From 1ed787aea1c48deb08b35d651e7c817a1ba9cd78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BChlh=C3=A4u=C3=9Fer?= <43962524+thesamriel@users.noreply.github.com> Date: Wed, 24 Jan 2024 08:42:41 +0100 Subject: [PATCH 45/60] Add phase variable and flux coupling for interFOAM in the FF module (#308) --- FF/Alpha.C | 116 ++++++++++++++++++ FF/Alpha.H | 43 +++++++ FF/AlphaGradient.C | 73 +++++++++++ FF/AlphaGradient.H | 42 +++++++ .../coupledPressureFvPatchField.C | 2 +- .../coupledVelocityFvPatchField.C | 2 +- FF/FF.C | 46 +++++++ FF/FF.H | 6 + FF/ModuleFF.C | 3 + FF/Phi.C | 59 +++++++++ FF/Phi.H | 42 +++++++ changelog-entries/308.md | 1 + docs/README.md | 4 + docs/config.md | 12 +- 14 files changed, 448 insertions(+), 3 deletions(-) create mode 100644 FF/Alpha.C create mode 100644 FF/Alpha.H create mode 100644 FF/AlphaGradient.C create mode 100644 FF/AlphaGradient.H create mode 100644 FF/Phi.C create mode 100644 FF/Phi.H create mode 100644 changelog-entries/308.md diff --git a/FF/Alpha.C b/FF/Alpha.C new file mode 100644 index 00000000..f11d9c2e --- /dev/null +++ b/FF/Alpha.C @@ -0,0 +1,116 @@ +#include "Alpha.H" + +using namespace Foam; + +preciceAdapter::FF::Alpha::Alpha( + const Foam::fvMesh& mesh, + const std::string nameAlpha) +: Alpha_( + const_cast( + &mesh.lookupObject(nameAlpha))) +{ + dataType_ = scalar; +} + +std::size_t preciceAdapter::FF::Alpha::write(double* buffer, bool meshConnectivity, const unsigned int dim) +{ + int bufferIndex = 0; + + if (this->locationType_ == LocationType::volumeCenters) + { + if (cellSetNames_.empty()) + { + for (const auto& cell : Alpha_->internalField()) + { + buffer[bufferIndex++] = cell; + } + } + else + { + for (const auto& cellSetName : cellSetNames_) + { + cellSet overlapRegion(Alpha_->mesh(), cellSetName); + const labelList& cells = overlapRegion.toc(); + + for (const auto& currentCell : cells) + { + // Copy the alpha valus into the buffer + buffer[bufferIndex++] = Alpha_->internalField()[currentCell]; + } + } + } + } + + // For every boundary patch of the interface + for (uint j = 0; j < patchIDs_.size(); j++) + { + int patchID = patchIDs_.at(j); + + // For every cell of the patch + forAll(Alpha_->boundaryFieldRef()[patchID], i) + { + // Copy the Alpha into the buffer + buffer[bufferIndex++] = + Alpha_->boundaryFieldRef()[patchID][i]; + } + } + return bufferIndex; +} + +void preciceAdapter::FF::Alpha::read(double* buffer, const unsigned int dim) +{ + int bufferIndex = 0; + + if (this->locationType_ == LocationType::volumeCenters) + { + if (cellSetNames_.empty()) + { + for (auto& cell : Alpha_->ref()) + { + cell = buffer[bufferIndex++]; + } + } + else + { + for (const auto& cellSetName : cellSetNames_) + { + cellSet overlapRegion(Alpha_->mesh(), cellSetName); + const labelList& cells = overlapRegion.toc(); + + for (const auto& currentCell : cells) + { + // Copy the pressure into the buffer + Alpha_->ref()[currentCell] = buffer[bufferIndex++]; + } + } + } + } + + // For every boundary patch of the interface + for (uint j = 0; j < patchIDs_.size(); j++) + { + int patchID = patchIDs_.at(j); + // For every cell of the patch + forAll(Alpha_->boundaryFieldRef()[patchID], i) + { + Alpha_->boundaryFieldRef()[patchID][i] = buffer[bufferIndex++]; + } + } +} + +bool preciceAdapter::FF::Alpha::isLocationTypeSupported(const bool meshConnectivity) const +{ + if (meshConnectivity) + { + return (this->locationType_ == LocationType::faceCenters); + } + else + { + return (this->locationType_ == LocationType::faceCenters || this->locationType_ == LocationType::volumeCenters); + } +} + +std::string preciceAdapter::FF::Alpha::getDataName() const +{ + return "Alpha"; +} diff --git a/FF/Alpha.H b/FF/Alpha.H new file mode 100644 index 00000000..7e5feb99 --- /dev/null +++ b/FF/Alpha.H @@ -0,0 +1,43 @@ +#ifndef FF_ALPHA_H +#define FF_ALPHA_H + +#include "CouplingDataUser.H" + +#include "fvCFD.H" +#include "cellSet.H" + +namespace preciceAdapter +{ +namespace FF +{ + +//- Class that writes and reads Alpha +class Alpha : public CouplingDataUser +{ + +private: + //- Alpha field + Foam::volScalarField* Alpha_; + +public: + //- Constructor + Alpha( + const Foam::fvMesh& mesh, + const std::string nameAlpha); + + //- Write the Alpha values into the buffer + std::size_t write(double* buffer, bool meshConnectivity, const unsigned int dim); + + //- Read the Alpha values from the buffer + void read(double* buffer, const unsigned int dim); + + bool isLocationTypeSupported(const bool meshConnectivity) const override; + + //- Get the name of the current data field + std::string getDataName() const override; +}; + +} +} + +#endif diff --git a/FF/AlphaGradient.C b/FF/AlphaGradient.C new file mode 100644 index 00000000..00260801 --- /dev/null +++ b/FF/AlphaGradient.C @@ -0,0 +1,73 @@ +#include "AlphaGradient.H" +#include "mixedFvPatchFields.H" + +using namespace Foam; + +preciceAdapter::FF::AlphaGradient::AlphaGradient( + const Foam::fvMesh& mesh, + const std::string nameAlpha) +: Alpha_( + const_cast( + &mesh.lookupObject(nameAlpha))) +{ + dataType_ = scalar; +} + +std::size_t preciceAdapter::FF::AlphaGradient::write(double* buffer, bool meshConnectivity, const unsigned int dim) +{ + int bufferIndex = 0; + + // For every boundary patch of the interface + for (uint j = 0; j < patchIDs_.size(); j++) + { + int patchID = patchIDs_.at(j); + + // Get the Alpha gradient boundary patch + const scalarField gradientPatch((Alpha_->boundaryFieldRef()[patchID]) + .snGrad()); + + // For every cell of the patch + forAll(gradientPatch, i) + { + // Copy the Alpha gradient into the buffer + buffer[bufferIndex++] = + -gradientPatch[i]; + } + } + return bufferIndex; +} + +void preciceAdapter::FF::AlphaGradient::read(double* buffer, const unsigned int dim) +{ + int bufferIndex = 0; + + // For every boundary patch of the interface + for (uint j = 0; j < patchIDs_.size(); j++) + { + int patchID = patchIDs_.at(j); + + // Get the Alpha gradient boundary patch + scalarField& gradientPatch = + refCast( + Alpha_->boundaryFieldRef()[patchID]) + .gradient(); + + // For every cell of the patch + forAll(gradientPatch, i) + { + // Set the Alpha gradient as the buffer value + gradientPatch[i] = + buffer[bufferIndex++]; + } + } +} + +bool preciceAdapter::FF::AlphaGradient::isLocationTypeSupported(const bool meshConnectivity) const +{ + return (this->locationType_ == LocationType::faceCenters); +} + +std::string preciceAdapter::FF::AlphaGradient::getDataName() const +{ + return "AlphaGradient"; +} diff --git a/FF/AlphaGradient.H b/FF/AlphaGradient.H new file mode 100644 index 00000000..b538f009 --- /dev/null +++ b/FF/AlphaGradient.H @@ -0,0 +1,42 @@ +#ifndef FF_ALPHA_GRADIENT_H +#define FF_ALPHA_GRADIENT_H + +#include "CouplingDataUser.H" + +#include "fvCFD.H" + +namespace preciceAdapter +{ +namespace FF +{ + +//- Class that writes and reads Alpha gradient +class AlphaGradient : public CouplingDataUser +{ + +private: + //- Alpha field + Foam::volScalarField* Alpha_; + +public: + //- Constructor + AlphaGradient( + const Foam::fvMesh& mesh, + const std::string nameAlpha); + + //- Write the Alpha gradient values into the buffer + std::size_t write(double* buffer, bool meshConnectivity, const unsigned int dim); + + //- Read the Alpha gradient values from the buffer + void read(double* buffer, const unsigned int dim); + + bool isLocationTypeSupported(const bool meshConnectivity) const override; + + //- Get the name of the current data field + std::string getDataName() const override; +}; + +} +} + +#endif diff --git a/FF/BoundaryConditions/coupledPressure/coupledPressureFvPatchField.C b/FF/BoundaryConditions/coupledPressure/coupledPressureFvPatchField.C index 28d61e8a..320a6ca2 100644 --- a/FF/BoundaryConditions/coupledPressure/coupledPressureFvPatchField.C +++ b/FF/BoundaryConditions/coupledPressure/coupledPressureFvPatchField.C @@ -178,4 +178,4 @@ namespace Foam makePatchTypeField( fixedFluxExtrapolatedPressureFvPatchScalarField, coupledPressureFvPatchField); -} \ No newline at end of file +} diff --git a/FF/BoundaryConditions/coupledVelocity/coupledVelocityFvPatchField.C b/FF/BoundaryConditions/coupledVelocity/coupledVelocityFvPatchField.C index 3c51fb92..1546477c 100644 --- a/FF/BoundaryConditions/coupledVelocity/coupledVelocityFvPatchField.C +++ b/FF/BoundaryConditions/coupledVelocity/coupledVelocityFvPatchField.C @@ -175,4 +175,4 @@ namespace Foam makePatchTypeField( fvPatchVectorField, coupledVelocityFvPatchField); -} \ No newline at end of file +} diff --git a/FF/FF.C b/FF/FF.C index 15b2e53b..2c2144ee 100644 --- a/FF/FF.C +++ b/FF/FF.C @@ -63,6 +63,10 @@ bool preciceAdapter::FF::FluidFluid::readConfig(const IOdictionary& adapterConfi nameT_ = FFdict.lookupOrDefault("nameT", "T"); DEBUG(adapterInfo(" temperature field name : " + nameT_)); + // Read the name of the phase variable field (if different) + nameAlpha_ = FFdict.lookupOrDefault("nameAlpha", "alpha"); + DEBUG(adapterInfo(" phase variable (alpha) field name : " + nameAlpha_)); + // Read the name of the face flux field (if different) namePhi_ = FFdict.lookupOrDefault("namePhi", "phi"); DEBUG(adapterInfo(" face flux field name : " + namePhi_)); @@ -155,6 +159,27 @@ bool preciceAdapter::FF::FluidFluid::addWriters(std::string dataName, Interface* new Temperature(mesh_, nameT_)); DEBUG(adapterInfo("Added writer: Flow Temperature.")); } + else if (dataName.find("AlphaGradient") == 0) + { + interface->addCouplingDataWriter( + dataName, + new AlphaGradient(mesh_, nameAlpha_)); + DEBUG(adapterInfo("Added writer: Alpha Gradient.")); + } + else if (dataName.find("Alpha") == 0) + { + interface->addCouplingDataWriter( + dataName, + new Alpha(mesh_, nameAlpha_)); + DEBUG(adapterInfo("Added writer: Alpha.")); + } + else if (dataName.find("Phi") == 0) + { + interface->addCouplingDataWriter( + dataName, + new Phi(mesh_, namePhi_)); + DEBUG(adapterInfo("Added writer: Phi.")); + } else { found = false; @@ -215,6 +240,27 @@ bool preciceAdapter::FF::FluidFluid::addReaders(std::string dataName, Interface* new Temperature(mesh_, nameT_)); DEBUG(adapterInfo("Added reader: Flow Temperature.")); } + else if (dataName.find("AlphaGradient") == 0) + { + interface->addCouplingDataReader( + dataName, + new AlphaGradient(mesh_, nameAlpha_)); + DEBUG(adapterInfo("Added reader: Alpha Gradient.")); + } + else if (dataName.find("Alpha") == 0) + { + interface->addCouplingDataReader( + dataName, + new Alpha(mesh_, nameAlpha_)); + DEBUG(adapterInfo("Added reader: Alpha.")); + } + else if (dataName.find("Phi") == 0) + { + interface->addCouplingDataReader( + dataName, + new Phi(mesh_, namePhi_)); + DEBUG(adapterInfo("Added reader: Phi.")); + } else { found = false; diff --git a/FF/FF.H b/FF/FF.H index fbcee8cb..77629442 100644 --- a/FF/FF.H +++ b/FF/FF.H @@ -6,9 +6,12 @@ #include "FF/Velocity.H" #include "FF/Pressure.H" #include "FF/Temperature.H" +#include "FF/Alpha.H" #include "FF/PressureGradient.H" #include "FF/VelocityGradient.H" #include "FF/TemperatureGradient.H" +#include "FF/AlphaGradient.H" +#include "FF/Phi.H" #include "fvCFD.H" @@ -38,6 +41,9 @@ protected: //- Name of the temperature field std::string nameT_ = "T"; + //- Name of the phase variable (alpha) field + std::string nameAlpha_ = "alpha"; + //- Name of the face flux field std::string namePhi_ = "phi"; diff --git a/FF/ModuleFF.C b/FF/ModuleFF.C index 30465704..21d191ea 100644 --- a/FF/ModuleFF.C +++ b/FF/ModuleFF.C @@ -6,5 +6,8 @@ #include "PressureGradient.C" #include "Temperature.C" #include "TemperatureGradient.C" +#include "Alpha.C" +#include "AlphaGradient.C" +#include "Phi.C" #include "BoundaryConditions/coupledPressure/coupledPressureFvPatchField.C" #include "BoundaryConditions/coupledVelocity/coupledVelocityFvPatchField.C" diff --git a/FF/Phi.C b/FF/Phi.C new file mode 100644 index 00000000..d2001395 --- /dev/null +++ b/FF/Phi.C @@ -0,0 +1,59 @@ +#include "Phi.H" + +using namespace Foam; + +preciceAdapter::FF::Phi::Phi( + const Foam::fvMesh& mesh, + const std::string namePhi) +: phi_( + const_cast( + &mesh.lookupObject(namePhi))) +{ + dataType_ = scalar; +} + +std::size_t preciceAdapter::FF::Phi::write(double* buffer, bool meshConnectivity, const unsigned int dim) +{ + int bufferIndex = 0; + + // For every boundary patch of the interface + for (uint j = 0; j < patchIDs_.size(); j++) + { + int patchID = patchIDs_.at(j); + + // For every cell of the patch + forAll(phi_->boundaryFieldRef()[patchID], i) + { + // Copy the Phi into the buffer + buffer[bufferIndex++] = + phi_->boundaryFieldRef()[patchID][i]; + } + } + return bufferIndex; +} + +void preciceAdapter::FF::Phi::read(double* buffer, const unsigned int dim) +{ + int bufferIndex = 0; + + // For every boundary patch of the interface + for (uint j = 0; j < patchIDs_.size(); j++) + { + int patchID = patchIDs_.at(j); + + forAll(phi_->boundaryFieldRef()[patchID], i) + { + phi_->boundaryFieldRef()[patchID][i] = -buffer[bufferIndex++]; + } + } +} + +bool preciceAdapter::FF::Phi::isLocationTypeSupported(const bool meshConnectivity) const +{ + return (this->locationType_ == LocationType::faceCenters); +} + +std::string preciceAdapter::FF::Phi::getDataName() const +{ + return "Phi"; +} diff --git a/FF/Phi.H b/FF/Phi.H new file mode 100644 index 00000000..0b42c6ad --- /dev/null +++ b/FF/Phi.H @@ -0,0 +1,42 @@ +#ifndef FF_PHI_H +#define FF_PHI_H + +#include "CouplingDataUser.H" + +#include "fvCFD.H" + +namespace preciceAdapter +{ +namespace FF +{ + +//- Class that writes and reads the flux phi +class Phi : public CouplingDataUser +{ + +private: + //- Phi field + Foam::surfaceScalarField* phi_; + +public: + //- Constructor + Phi( + const Foam::fvMesh& mesh, + const std::string namePhi); + + //- Write the Phi values into the buffer + std::size_t write(double* buffer, bool meshConnectivity, const unsigned int dim); + + //- Read the Phi values from the buffer + void read(double* buffer, const unsigned int dim); + + bool isLocationTypeSupported(const bool meshConnectivity) const override; + + //- Get the name of the current data field + std::string getDataName() const override; +}; + +} +} + +#endif diff --git a/changelog-entries/308.md b/changelog-entries/308.md new file mode 100644 index 00000000..5bcda115 --- /dev/null +++ b/changelog-entries/308.md @@ -0,0 +1 @@ +- Added phase variable and flux coupling for interFOAM in the FF module [#308](https://github.com/precice/openfoam-adapter/pull/308) diff --git a/docs/README.md b/docs/README.md index 82527395..cb5e6671 100644 --- a/docs/README.md +++ b/docs/README.md @@ -15,6 +15,7 @@ This preCICE adapter is a plug-in (function object) for OpenFOAM, which can work This adapter can read/write the following fields in a surface coupling setup: - Temperature (read + write) +- Temperature gradient (read + write) - Heat flux (read + write) - Sink temperature (read + write) - Heat transfer coefficient (read + write) @@ -26,6 +27,9 @@ This adapter can read/write the following fields in a surface coupling setup: - Pressure gradient (read + write) - Velocity (read + write) - Velocity gradient (read + write) +- Phase fraction (alpha) (read + write) +- Phase fraction (alpha) gradient (read + write) +- Phase flux (phi) (read + write) In addition, the adapter supports the following fields in a volume coupling setup: diff --git a/docs/config.md b/docs/config.md index 073a1fa9..7f22c51a 100644 --- a/docs/config.md +++ b/docs/config.md @@ -217,7 +217,7 @@ solver displacementLaplacian; #### FF -The fluid-fluid coupling module supports reading and writing `Pressure`, `Velocity`, `PressureGradient`, `VelocityGradient`, `FlowTemperature` and `FlowTemperatureGradient`. +The fluid-fluid coupling module supports reading and writing `Pressure`, `Velocity`, `PressureGradient`, `VelocityGradient`, `FlowTemperature`, `FlowTemperatureGradient`, `Alpha`, `AlphaGradient` and the face flux `Phi`. Similarly to the CHT module, you need a `fixedValue` boundary condition of the respective primary field in order to read and apply values, and a `fixedGradient` boundary condition of the respective gradient field in order to read and apply gradients. @@ -248,6 +248,10 @@ interface The FF module is still experimental and the boundary conditions presented here have not been rigorously tested. {% endexperimental %} +`Alpha` refers to the phase variable used in e.g. the volume of fluid multiphase solver `interFoam`. + +When coupling face flux `Phi`, usually no specific boundary condition needs to be set. The coupled boundary values are therefore not persistent and may change within a timestep. + ### Volume coupling Besides surface coupling on the domain boundaries, the OpenFOAM adapter also supports coupling overlapping domains, which can be the complete domain, or regions of it. In contrast to surface coupling, though, reading volume data (source terms) requires a few additional configuration steps compared to writing data. @@ -565,6 +569,12 @@ FF nameU U; // Pressure nameP p; + // Face flux (phi for most sovlers) + namePhi phi; + // Temperature + nameT T; + // Multiphase variable + nameAlpha alpha } ``` From 8db7f7599ba7a0427a4a6f4a38c399f29d512b28 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Wed, 24 Jan 2024 08:45:08 +0100 Subject: [PATCH 46/60] Fix connectivity definition in the adapter (#315) --- Interface.C | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Interface.C b/Interface.C index cd2aa0d5..55d59c53 100644 --- a/Interface.C +++ b/Interface.C @@ -249,10 +249,6 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh, const std::str { vertices[verticesIndex++] = faceNodes[i][d]; } - if (meshConnectivity_) - { - verticesMap.emplace(std::make_tuple(faceNodes[i][0], faceNodes[i][1], faceNodes[i][2]), -1); - } } } @@ -261,11 +257,9 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh, const std::str if (meshConnectivity_) { - // Build the map between OpenFOAM vertices and preCICE vertex IDs - verticesIndex = 0; - for (auto& key : verticesMap) + for (std::size_t i = 0; i < vertexIDs_.size(); ++i) { - key.second = vertexIDs_[verticesIndex++]; + verticesMap.emplace(std::make_tuple(vertices[3 * i], vertices[3 * i + 1], vertices[3 * i + 2]), vertexIDs_[i]); } for (uint j = 0; j < patchIDs_.size(); j++) From fa6f48f113b2d8a09b252a658d108814edf38ea1 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Wed, 24 Jan 2024 17:18:50 +0100 Subject: [PATCH 47/60] Introduce tolerances for triggering dt related warnings (#312) * Introduce tolerances for triggering warnings * Use 10^-14 instead of 12 --- Adapter.C | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Adapter.C b/Adapter.C index 717a871b..74b63783 100644 --- a/Adapter.C +++ b/Adapter.C @@ -651,8 +651,8 @@ void preciceAdapter::Adapter::adjustSolverTimeStepAndReadData() If the solver tries to use a bigger timestep, then it needs to use the same timestep as the one determined by preCICE. */ - - if (timestepSolverDetermined < timestepPrecice_) + double tolerance = 1e-14; + if (timestepPrecice_ - timestepSolverDetermined > tolerance) { // Add a bool 'subCycling = true' which is checked in the storeMeshPoints() function. adapterInfo( @@ -668,13 +668,17 @@ void preciceAdapter::Adapter::adjustSolverTimeStepAndReadData() "warning"); } } - else if (timestepSolverDetermined > timestepPrecice_) + else if (timestepSolverDetermined - timestepPrecice_ > tolerance) { - adapterInfo( - "The solver's timestep cannot be larger than the coupling timestep." - " Adjusting from " - + std::to_string(timestepSolverDetermined) + " to " + std::to_string(timestepPrecice_), - "warning"); + // In the last time-step, we adjust to dt = 0, but we don't need to trigger the warning here + if (precice_->isCouplingOngoing()) + { + adapterInfo( + "The solver's timestep cannot be larger than the coupling timestep." + " Adjusting from " + + std::to_string(timestepSolverDetermined) + " to " + std::to_string(timestepPrecice_), + "warning"); + } timestepSolver_ = timestepPrecice_; } else From b831b5caa24698b66ba037cc830677600d48658c Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Wed, 31 Jan 2024 10:35:38 +0100 Subject: [PATCH 48/60] Update release_pull_request_template.md for Spack --- tools/release_pull_request_template.md | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/release_pull_request_template.md b/tools/release_pull_request_template.md index 1e7a2736..c838b823 100644 --- a/tools/release_pull_request_template.md +++ b/tools/release_pull_request_template.md @@ -86,5 +86,6 @@ master <-- OpenFOAM4 <-- OpenFOAM5 <-- OpenFOAM6 <-- OpenFOAM7 <-- ... <-- OpenF - [ ] Update external documentation (tutorials, website), e.g., regarding the adapter or OpenFOAM version. - [ ] Quickstart - [ ] Update the VM provisioning scripts, if needed (e.g., OpenFOAM version) +- [ ] Update the [Spack package](https://github.com/kjrstory/spack/blob/develop/var/spack/repos/builtin/packages/of-precice/package.py) - [ ] Update this release checklist (`tools/release_pull_request_template.md`) - [ ] Advertise and celebrate! :tada: :beers: From 5206e0d71361238f5d787846934d87df80929734 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Fri, 2 Feb 2024 09:34:29 +0100 Subject: [PATCH 49/60] Configure dependabot for version updates --- .github/dependabot.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..0d08e261 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "github-actions" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" From cc75b59aaf11a3eac40eb432a519478946ceb6d4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Feb 2024 08:34:50 +0000 Subject: [PATCH 50/60] Bump actions/cache from 3 to 4 Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 50569407..f49b32b9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,7 +25,7 @@ jobs: - name: Check out repository uses: actions/checkout@v3 - name: Setup caches - uses: actions/cache@v3 + uses: actions/cache@v4 id: cache-id with: path: ${{ runner.temp }}/cache-directory From 5dde77eb83c4aada3a6e6c23d1f4b68c720de3db Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Feb 2024 09:01:27 +0000 Subject: [PATCH 51/60] Bump actions/checkout from 2 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build-custom.yml | 2 +- .github/workflows/build.yml | 2 +- .github/workflows/check-format.yml | 2 +- .github/workflows/check-links.yml | 2 +- .github/workflows/check-markdown.yml | 2 +- .github/workflows/check-shell.yml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-custom.yml b/.github/workflows/build-custom.yml index f8eea0a1..2b817f15 100644 --- a/.github/workflows/build-custom.yml +++ b/.github/workflows/build-custom.yml @@ -74,7 +74,7 @@ jobs: echo "Run tutorial partitioned-pipe: ${{ github.event.inputs.runTutorialPartitionedPipe }}" echo "Tutorials branch: ${{ github.event.inputs.branchTutorials }}" - name: Check out repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: ref: ${{ github.event.inputs.refAdapter }} - name: Install OpenFOAM (no cache) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f49b32b9..ac7c2cce 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Check out repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup caches uses: actions/cache@v4 id: cache-id diff --git a/.github/workflows/check-format.yml b/.github/workflows/check-format.yml index 1ade288c..c765840e 100644 --- a/.github/workflows/check-format.yml +++ b/.github/workflows/check-format.yml @@ -5,7 +5,7 @@ jobs: name: Check formatting (clang-format) runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Run clang-format style check for C/C++ programs. uses: jidicula/clang-format-action@main with: diff --git a/.github/workflows/check-links.yml b/.github/workflows/check-links.yml index f7e0ce61..86870258 100644 --- a/.github/workflows/check-links.yml +++ b/.github/workflows/check-links.yml @@ -5,7 +5,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Check links in markdown files (markdown-link-check) uses: gaurav-nelson/github-action-markdown-link-check@v1 with: diff --git a/.github/workflows/check-markdown.yml b/.github/workflows/check-markdown.yml index 63a0df9a..541a1fd4 100644 --- a/.github/workflows/check-markdown.yml +++ b/.github/workflows/check-markdown.yml @@ -5,7 +5,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Lint markdown files (markdownlint) uses: articulate/actions-markdownlint@v1 with: diff --git a/.github/workflows/check-shell.yml b/.github/workflows/check-shell.yml index f4400ed0..dd5474f8 100644 --- a/.github/workflows/check-shell.yml +++ b/.github/workflows/check-shell.yml @@ -5,6 +5,6 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Lint shell scripts (shellcheck) uses: ludeeus/action-shellcheck@master From b6e860ae79a353d3b9f4eb3faf07aed838658bcc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Feb 2024 08:34:53 +0000 Subject: [PATCH 52/60] Bump actions/upload-artifact from 2 to 4 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 2 to 4. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v2...v4) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build-custom.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-custom.yml b/.github/workflows/build-custom.yml index 2b817f15..28f406cf 100644 --- a/.github/workflows/build-custom.yml +++ b/.github/workflows/build-custom.yml @@ -220,7 +220,7 @@ jobs: wait $PIDfluid fi - name: Archive logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: logs path: | @@ -234,7 +234,7 @@ jobs: tutorials/partitioned-pipe/fluid1-openfoam-pimplefoam/fluid1-openfoam-pimplefoam.log tutorials/partitioned-pipe/fluid2-openfoam-pimplefoam/fluid2-openfoam-pimplefoam.log - name: Archive case files - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: case-files path: | From 3d45c38c5091331906bd32517b400d8cb0786bb1 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Fri, 9 Feb 2024 08:04:15 +0100 Subject: [PATCH 53/60] Update version and changelogs to v1.3.0 --- Adapter.C | 2 +- CHANGELOG.md | 22 ++++++++++++++++++++++ changelog-entries/255.md | 1 - changelog-entries/262.md | 1 - changelog-entries/270.md | 1 - changelog-entries/281.md | 5 ----- changelog-entries/285.md | 1 - changelog-entries/287.md | 1 - changelog-entries/289.md | 1 - changelog-entries/296.md | 1 - changelog-entries/297.md | 1 - changelog-entries/298.md | 1 - changelog-entries/299.md | 1 - changelog-entries/301.md | 1 - changelog-entries/308.md | 1 - 15 files changed, 23 insertions(+), 18 deletions(-) delete mode 100644 changelog-entries/255.md delete mode 100644 changelog-entries/262.md delete mode 100644 changelog-entries/270.md delete mode 100644 changelog-entries/281.md delete mode 100644 changelog-entries/285.md delete mode 100644 changelog-entries/287.md delete mode 100644 changelog-entries/289.md delete mode 100644 changelog-entries/296.md delete mode 100644 changelog-entries/297.md delete mode 100644 changelog-entries/298.md delete mode 100644 changelog-entries/299.md delete mode 100644 changelog-entries/301.md delete mode 100644 changelog-entries/308.md diff --git a/Adapter.C b/Adapter.C index 74b63783..f2296346 100644 --- a/Adapter.C +++ b/Adapter.C @@ -10,7 +10,7 @@ preciceAdapter::Adapter::Adapter(const Time& runTime, const fvMesh& mesh) : runTime_(runTime), mesh_(mesh) { - adapterInfo("Loaded the OpenFOAM-preCICE adapter - v1.2.3 + unreleased changes.", "info"); + adapterInfo("Loaded the OpenFOAM-preCICE adapter - v1.3.0.", "info"); return; } diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e93ee3b..f9dccccf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,28 @@ Read more details in the issue [#52: Releases and versioning](https://github.com +## [v1.3.0] 2024-02-09 + +### Added + +- Added a locationType for volume coupling and implemented the respective functionality (over all internal fields) for Pressure and Velocity (FF) and Temperature (FF) [#255](https://github.com/precice/openfoam-adapter/pull/255). +- Added volume coupling over one or multiple domain regions specified by OpenFOAM cellSets (for Pressure and Velocity (FF) and Temperature (FF))[#270](https://github.com/precice/openfoam-adapter/pull/270). +- Added phase variable and flux coupling for interFOAM in the FF module [#308](https://github.com/precice/openfoam-adapter/pull/308). +- Added custom inletOutlet boundary conditions for pressure and velocity to the FF module [#281](https://github.com/precice/openfoam-adapter/pull/281). +- Temperature and temperature gradient as coupling data to the FF module [#281](https://github.com/precice/openfoam-adapter/pull/281). +- Added option to write velocity that is corrected by the face flux `phi` [#281](https://github.com/precice/openfoam-adapter/pull/281). +- Added citing guidelines, referring to the [new reference article at the OpenFOAM Journal](https://doi.org/10.51560/ofj.v3.88). [#287](https://github.com/precice/openfoam-adapter/pull/287) + +### Changed + +- Ported the adapter to preCICE v3. The adapter is not compatible with v2 anymore. [#285](https://github.com/precice/openfoam-adapter/pull/285). +- Changed the default OpenFOAM version to v2306 in the documentation and CI +- Changed the way mesh connectivity (face triangles) are provided to preCICE, adapting to preCICE v3 [#297](https://github.com/precice/openfoam-adapter/pull/297). +- Merged `initializeData` into `initialize` [#262](https://github.com/precice/openfoam-adapter/pull/262). +- Renamed the `adjustSolverTimeStep()` method to `adjustSolverTimeStepAndReadData()`, changing the behavior to always read data at the determined time step size [#298](https://github.com/precice/openfoam-adapter/pull/298). +- The Build CI workflow now relies on the setup-precice-action to install preCICE [#299](https://github.com/precice/openfoam-adapter/pull/299). +- Reduced building time by grouping together compilation units of each module [#301](https://github.com/precice/openfoam-adapter/pull/301). + ## [v1.2.3] 2023-06-14 ### Fixed diff --git a/changelog-entries/255.md b/changelog-entries/255.md deleted file mode 100644 index f7fc3698..00000000 --- a/changelog-entries/255.md +++ /dev/null @@ -1 +0,0 @@ -- added a locationType for volume coupling and implemented the respective functionality (over all internal fields) for Pressure and Velocity (FF) and Temperature (FF) \ No newline at end of file diff --git a/changelog-entries/262.md b/changelog-entries/262.md deleted file mode 100644 index 7609e361..00000000 --- a/changelog-entries/262.md +++ /dev/null @@ -1 +0,0 @@ -- Merged `initializeData` into `initialize` [#262](https://github.com/precice/openfoam-adapter/pull/262). diff --git a/changelog-entries/270.md b/changelog-entries/270.md deleted file mode 100644 index ba25bb42..00000000 --- a/changelog-entries/270.md +++ /dev/null @@ -1 +0,0 @@ -- Added volume coupling over one or multiple domain regions specified by OpenFOAM cellSets (for Pressure and Velocity (FF) and Temperature (FF)) \ No newline at end of file diff --git a/changelog-entries/281.md b/changelog-entries/281.md deleted file mode 100644 index 562c79ba..00000000 --- a/changelog-entries/281.md +++ /dev/null @@ -1,5 +0,0 @@ -### Added - -- Custom inletOutlet boundary conditions for pressure and velocity to the FF module [#281](https://github.com/precice/openfoam-adapter/pull/281). -- Temperature and temperature gradient as coupled data to the FF module. -- Option to write velocity that is corrected by the face flux `phi`. \ No newline at end of file diff --git a/changelog-entries/285.md b/changelog-entries/285.md deleted file mode 100644 index e45be422..00000000 --- a/changelog-entries/285.md +++ /dev/null @@ -1 +0,0 @@ -- Ported the adapter to preCICE v3. The adapter is not compatible with v2 anymore. [#285](https://github.com/precice/openfoam-adapter/pull/285) diff --git a/changelog-entries/287.md b/changelog-entries/287.md deleted file mode 100644 index d4ae9a59..00000000 --- a/changelog-entries/287.md +++ /dev/null @@ -1 +0,0 @@ -- Added citing guidelines, referring to the [new reference article at the OpenFOAM Journal](https://doi.org/10.51560/ofj.v3.88). [#287](https://github.com/precice/openfoam-adapter/pull/287) diff --git a/changelog-entries/289.md b/changelog-entries/289.md deleted file mode 100644 index 71486dd8..00000000 --- a/changelog-entries/289.md +++ /dev/null @@ -1 +0,0 @@ -- Fixed incorrect reading and writing of the FSI-related data buffers, if multiple patches are combined in an interface mesh. diff --git a/changelog-entries/296.md b/changelog-entries/296.md deleted file mode 100644 index 34c70abd..00000000 --- a/changelog-entries/296.md +++ /dev/null @@ -1 +0,0 @@ -- Changed the default OpenFOAM version to v2306 in the documentation and CI diff --git a/changelog-entries/297.md b/changelog-entries/297.md deleted file mode 100644 index 664eb17e..00000000 --- a/changelog-entries/297.md +++ /dev/null @@ -1 +0,0 @@ -- Changed the way mesh connectivity (face triangles) are provided to preCICE, adapting to preCICE v3 [#297](https://github.com/precice/openfoam-adapter/pull/297) diff --git a/changelog-entries/298.md b/changelog-entries/298.md deleted file mode 100644 index 8163f04b..00000000 --- a/changelog-entries/298.md +++ /dev/null @@ -1 +0,0 @@ -- Renamed the `adjustSolverTimeStep()` method to `adjustSolverTimeStepAndReadData()`, changing the behavior to always read data at the determined time step size. [#298](https://github.com/precice/openfoam-adapter/pull/298) diff --git a/changelog-entries/299.md b/changelog-entries/299.md deleted file mode 100644 index ea0e4583..00000000 --- a/changelog-entries/299.md +++ /dev/null @@ -1 +0,0 @@ -- The Build CI workflow now relies on the setup-precice-action to install preCICE [#299](https://github.com/precice/openfoam-adapter/pull/299) diff --git a/changelog-entries/301.md b/changelog-entries/301.md deleted file mode 100644 index 221bc99a..00000000 --- a/changelog-entries/301.md +++ /dev/null @@ -1 +0,0 @@ -- Reduced building time by grouping together compilation units of each module [#301](https://github.com/precice/openfoam-adapter/pull/301) diff --git a/changelog-entries/308.md b/changelog-entries/308.md deleted file mode 100644 index 5bcda115..00000000 --- a/changelog-entries/308.md +++ /dev/null @@ -1 +0,0 @@ -- Added phase variable and flux coupling for interFOAM in the FF module [#308](https://github.com/precice/openfoam-adapter/pull/308) From 8175b7a7c555576e8869b7ac21a7728ad7e24a4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Simonis?= Date: Sun, 10 Mar 2024 13:53:30 +0100 Subject: [PATCH 54/60] Add pre-commit for liniting docs (#321) --- .github/workflows/check-markdown.yml | 14 ------------- .github/workflows/check-style.yml | 31 ++++++++++++++++++++++++++++ .pre-commit-config.yaml | 15 ++++++++++++++ CONTRIBUTING.md | 5 ++++- 4 files changed, 50 insertions(+), 15 deletions(-) delete mode 100644 .github/workflows/check-markdown.yml create mode 100644 .github/workflows/check-style.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/check-markdown.yml b/.github/workflows/check-markdown.yml deleted file mode 100644 index 541a1fd4..00000000 --- a/.github/workflows/check-markdown.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Lint docs -on: [push, pull_request] -jobs: - check_md: - runs-on: ubuntu-latest - steps: - - name: Check out repository - uses: actions/checkout@v4 - - name: Lint markdown files (markdownlint) - uses: articulate/actions-markdownlint@v1 - with: - config: .markdownlint.json - files: '.' - ignore: changelog-entries diff --git a/.github/workflows/check-style.yml b/.github/workflows/check-style.yml new file mode 100644 index 00000000..c7476502 --- /dev/null +++ b/.github/workflows/check-style.yml @@ -0,0 +1,31 @@ +name: Check code style +on: + push: + branches: + - main + - develop + pull_request: + branches: + - "*" + +jobs: + formatting: + runs-on: ubuntu-latest + steps: + - name: Checkout preCICE + uses: actions/checkout@v4 + - name: Setup python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + check-latest: true + - name: Install pre-commit + run: pip install pre-commit + - name: Run checks + run: pre-commit run -a -v + - name: Git status + if: always() + run: git status + - name: Full diff + if: always() + run: git diff diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..51cd7ebc --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,15 @@ +repos: +# Official repo for default hooks +- repo: https://github.com/precice/precice-pre-commit-hooks + rev: 'v3.3' + hooks: + - id: format-precice-config + - id: check-image-prefix + args: [ --prefix=docs-adapter-openfoam- ] +- repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.30.0 + hooks: + - id: markdownlint + files: "^docs/.*.md" + - id: markdownlint-fix + files: "^docs/.*.md" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ca2cd78a..f48c65ce 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,7 +12,10 @@ merge conflicts and we will merge these files at the time we release a new versi ## Code formatting -You can format all files with clang-format 11 by running `./tools/format-code.sh`. +We use [pre-commit](https://pre-commit.com/) to ensure consistent formatting. +Please install `pre-commit` and then install the hook in this repository with `pre-commit install`. +This ensures correct formatting for future commits. +Run `pre-commit run -va` to apply formatting retrospectively. ## Automatic checks From a35348488cd27efd7da587733320c1ef82051f03 Mon Sep 17 00:00:00 2001 From: Benjamin Rodenberg Date: Sun, 10 Mar 2024 13:55:32 +0100 Subject: [PATCH 55/60] Remove unnecessary timestepPrecice_ member (#322) --- Adapter.C | 12 +++++------- Adapter.H | 3 --- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Adapter.C b/Adapter.C index 74b63783..d172a0f5 100644 --- a/Adapter.C +++ b/Adapter.C @@ -548,7 +548,6 @@ void preciceAdapter::Adapter::initialize() DEBUG(adapterInfo("Initializing preCICE data...")); precice_->initialize(); - timestepPrecice_ = precice_->getMaxTimeStepSize(); preciceInitialized_ = true; ACCUMULATE_TIMER(timeInInitialize_); @@ -587,7 +586,6 @@ void preciceAdapter::Adapter::advance() SETUP_TIMER(); precice_->advance(timestepSolver_); - timestepPrecice_ = precice_->getMaxTimeStepSize(); ACCUMULATE_TIMER(timeInAdvance_); return; @@ -652,7 +650,7 @@ void preciceAdapter::Adapter::adjustSolverTimeStepAndReadData() the same timestep as the one determined by preCICE. */ double tolerance = 1e-14; - if (timestepPrecice_ - timestepSolverDetermined > tolerance) + if (precice_->getMaxTimeStepSize() - timestepSolverDetermined > tolerance) { // Add a bool 'subCycling = true' which is checked in the storeMeshPoints() function. adapterInfo( @@ -668,7 +666,7 @@ void preciceAdapter::Adapter::adjustSolverTimeStepAndReadData() "warning"); } } - else if (timestepSolverDetermined - timestepPrecice_ > tolerance) + else if (timestepSolverDetermined - precice_->getMaxTimeStepSize() > tolerance) { // In the last time-step, we adjust to dt = 0, but we don't need to trigger the warning here if (precice_->isCouplingOngoing()) @@ -676,16 +674,16 @@ void preciceAdapter::Adapter::adjustSolverTimeStepAndReadData() adapterInfo( "The solver's timestep cannot be larger than the coupling timestep." " Adjusting from " - + std::to_string(timestepSolverDetermined) + " to " + std::to_string(timestepPrecice_), + + std::to_string(timestepSolverDetermined) + " to " + std::to_string(precice_->getMaxTimeStepSize()), "warning"); } - timestepSolver_ = timestepPrecice_; + timestepSolver_ = precice_->getMaxTimeStepSize(); } else { DEBUG(adapterInfo("The solver's timestep is the same as the " "coupling timestep.")); - timestepSolver_ = timestepPrecice_; + timestepSolver_ = precice_->getMaxTimeStepSize(); } // Update the solver's timestep (but don't trigger the adjustDeltaT(), diff --git a/Adapter.H b/Adapter.H index 671c947f..2e9cd606 100644 --- a/Adapter.H +++ b/Adapter.H @@ -124,9 +124,6 @@ private: // Timesteps - //- Timestep dictated by preCICE - double timestepPrecice_; - //- Timestep used by the solver double timestepSolver_; From ac79b78e4b094dc354bbbe6850d353f201012c63 Mon Sep 17 00:00:00 2001 From: valentin-seitz Date: Wed, 13 Mar 2024 13:13:36 +0100 Subject: [PATCH 56/60] Added a test workflow (#309) Co-authored-by: Valentin Seitz Co-authored-by: Gerasimos Chourdakis --- .github/workflows/system-tests.yaml | 29 +++++++++++++++++++++++++++++ CONTRIBUTING.md | 10 ++++++++++ 2 files changed, 39 insertions(+) create mode 100644 .github/workflows/system-tests.yaml diff --git a/.github/workflows/system-tests.yaml b/.github/workflows/system-tests.yaml new file mode 100644 index 00000000..d72794aa --- /dev/null +++ b/.github/workflows/system-tests.yaml @@ -0,0 +1,29 @@ +name: System tests + +on: + pull_request: + types: [labeled] + +jobs: + gather-refs: + if: ${{ github.event.label.name == 'trigger-system-tests' }} + runs-on: ubuntu-latest + outputs: + reftutorials: ${{ steps.reftutorials.outputs.shorthash }} + steps: + - id: reftutorials + uses: nmbgeek/github-action-get-latest-commit@main + with: + owner: precice + repo: tutorials + branch: develop + + run-system-tests: + if: ${{ github.event.label.name == 'trigger-system-tests' }} + needs: gather-refs + uses: precice/tutorials/.github/workflows/run_testsuite_workflow.yml@develop + with: + suites: openfoam_adapter_pr + build_args: TUTORIALS_REF:${{ needs.gather-refs.outputs.reftutorials }},PRECICE_REF:v3.0.0,OPENFOAM_EXECUTABLE:openfoam2306,OPENFOAM_ADAPTER_REF:${{ github.event.pull_request.head.sha }} + systests_branch: develop + loglevel: "DEBUG" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f48c65ce..b09fa65b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,3 +27,13 @@ There are also a few additional workflows that can be triggered manually: - `Check links`: checks the links in all markdown files to verify if they are still reachable. Members of the repository can trigger these workflows in the "Actions" tab. + +## System tests + +For non-trivial pull requests, we also need to execute [system regression tests](https://precice.org/dev-docs-system-tests.html), +to ensure that complete simulations still run and give the same results. +Because these take long, run on an external system, and consume significant resources, +we are only triggering these on demand. Add (or ask a maintainer to add) the +`trigger-system-tests` label to the pull request to trigger them. +The tests will only run once, so that further commits don't consume additional +resources: In case you want to re-trigger them, remove and add the label again. From fa8a71d86db4762bd76e59e1ad0c8a561dad8858 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Wed, 20 Mar 2024 22:00:07 +0100 Subject: [PATCH 57/60] Various documentation and CI updates (#325) --- .github/workflows/build-custom.yml | 31 ++++++++++--------- .github/workflows/build.yml | 13 ++++---- .github/workflows/check-links.yml | 14 --------- .github/workflows/install-openfoam.sh | 6 ++-- .../{check-style.yml => pre-commit.yml} | 2 +- .github/workflows/system-tests.yaml | 2 +- .pre-commit-config.yaml | 5 +++ README.md | 10 ++---- docs/get.md | 3 +- docs/openfoam-support.md | 8 ++--- 10 files changed, 42 insertions(+), 52 deletions(-) delete mode 100644 .github/workflows/check-links.yml rename .github/workflows/{check-style.yml => pre-commit.yml} (95%) diff --git a/.github/workflows/build-custom.yml b/.github/workflows/build-custom.yml index 28f406cf..eec2d4ed 100644 --- a/.github/workflows/build-custom.yml +++ b/.github/workflows/build-custom.yml @@ -20,6 +20,7 @@ on: required: true type: choice options: + - OpenFOAMv2312 - OpenFOAMv2306 - OpenFOAMv2212 - OpenFOAMv2206 @@ -36,7 +37,7 @@ on: - OpenFOAM5 versionpreCICE: description: 'Version of preCICE to build with' - default: '2.5.0' + default: 'v3.0.0' required: true runTutorialHeatedPlate: description: Run tutorial flow-over-heated-plate @@ -77,10 +78,18 @@ jobs: uses: actions/checkout@v4 with: ref: ${{ github.event.inputs.refAdapter }} + - name: Install preCICE (no cache) + uses: precice/setup-precice-action@main + with: + precice-version: ${{ github.event.inputs.versionpreCICE }} - name: Install OpenFOAM (no cache) id: installOpenFOAM run: | case "${{ github.event.inputs.versionOpenFOAM }}" in + OpenFOAMv2312) + wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash + sudo apt-get install openfoam2312-dev + echo "{openfoam_exec}={/usr/bin/openfoam2312}" >> $GITHUB_OUTPUT;; OpenFOAMv2306) wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash sudo apt-get install openfoam2306-dev @@ -155,23 +164,15 @@ jobs: echo "I cannot find ${{ github.event.inputs.refAdapter }} in my known options." exit 1;; esac - - name: Install preCICE (no cache) + - name: Sanity check run: | - if [ "${{ github.event.inputs.virtualEnvironment }}" == "ubuntu-22.04" ] - then - wget "https://github.com/precice/precice/releases/download/v${{ github.event.inputs.versionpreCICE }}/libprecice2_${{ github.event.inputs.versionpreCICE }}_jammy.deb" - sudo apt install "./libprecice2_${{ github.event.inputs.versionpreCICE }}_jammy.deb" - elif [ "${{ github.event.inputs.virtualEnvironment }}" == "ubuntu-20.04" ] - then - wget "https://github.com/precice/precice/releases/download/v${{ github.event.inputs.versionpreCICE }}/libprecice2_${{ github.event.inputs.versionpreCICE }}_focal.deb" - sudo apt install "./libprecice2_${{ github.event.inputs.versionpreCICE }}_focal.deb" - elif [ "${{ github.event.inputs.virtualEnvironment }}" == "ubuntu-18.04" ] - then - wget "https://github.com/precice/precice/releases/download/v${{ github.event.inputs.versionpreCICE }}/libprecice2_${{ github.event.inputs.versionpreCICE }}_bionic.deb" - sudo apt install "./libprecice2_${{ github.event.inputs.versionpreCICE }}_bionic.deb" - fi + ls /usr/bin/openfoam* || echo "No /usr/bin/openfoam* directories." + ls /opt/openfoam* || echo "No /opt/openfoam* directories." + echo "GitHub Actions step output openfoam_exec:" + echo ${{steps.installOpenFOAM.outputs.openfoam_exec}} - name: Build OpenFOAM-preCICE adapter run: | + echo "OpenFOAM environment: ${{steps.installOpenFOAM.outputs.openfoam_exec}}" ${{steps.installOpenFOAM.outputs.openfoam_exec}} ./Allwmake - name: Get tutorials run: | diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ac7c2cce..5b6b5927 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build with OpenFOAM v2306 +name: Build with OpenFOAM v2312 on: push: branches-ignore: @@ -21,9 +21,14 @@ on: jobs: build: runs-on: ubuntu-22.04 + container: precice/precice:nightly steps: - name: Check out repository uses: actions/checkout@v4 + - name: Install action dependencies + run: | + apt-get update -qq + apt-get install -qq sudo wget - name: Setup caches uses: actions/cache@v4 id: cache-id @@ -38,9 +43,5 @@ jobs: cache: ${{ runner.temp }}/cache-directory snapshot: '/' exclude: '/boot /data /dev /mnt /proc /run /sys' - - name: Install preCICE - uses: precice/setup-precice-action@main - with: - precice-version: develop - name: Build OpenFOAM-preCICE adapter - run: /usr/bin/openfoam2306 ./Allwmake + run: /usr/bin/openfoam2312 ./Allwmake diff --git a/.github/workflows/check-links.yml b/.github/workflows/check-links.yml deleted file mode 100644 index 86870258..00000000 --- a/.github/workflows/check-links.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Check links (manual) -on: workflow_dispatch -jobs: - check_links: - runs-on: ubuntu-latest - steps: - - name: Check out repository - uses: actions/checkout@v4 - - name: Check links in markdown files (markdown-link-check) - uses: gaurav-nelson/github-action-markdown-link-check@v1 - with: - use-quiet-mode: 'yes' - use-verbose-mode: 'no' - config-file: '.markdown-link-check-config.json' diff --git a/.github/workflows/install-openfoam.sh b/.github/workflows/install-openfoam.sh index 99788a3f..3b132427 100755 --- a/.github/workflows/install-openfoam.sh +++ b/.github/workflows/install-openfoam.sh @@ -1,6 +1,6 @@ #!/bin/bash -e -# Install OpenFOAM v2306 +# Install OpenFOAM v2312 wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash -sudo apt-get update -sudo apt-get install openfoam2306-dev +sudo apt-get update -y +sudo apt-get install -y openfoam2312-dev diff --git a/.github/workflows/check-style.yml b/.github/workflows/pre-commit.yml similarity index 95% rename from .github/workflows/check-style.yml rename to .github/workflows/pre-commit.yml index c7476502..f87390de 100644 --- a/.github/workflows/check-style.yml +++ b/.github/workflows/pre-commit.yml @@ -1,4 +1,4 @@ -name: Check code style +name: Pre-commit hook checks on: push: branches: diff --git a/.github/workflows/system-tests.yaml b/.github/workflows/system-tests.yaml index d72794aa..e6e6145f 100644 --- a/.github/workflows/system-tests.yaml +++ b/.github/workflows/system-tests.yaml @@ -24,6 +24,6 @@ jobs: uses: precice/tutorials/.github/workflows/run_testsuite_workflow.yml@develop with: suites: openfoam_adapter_pr - build_args: TUTORIALS_REF:${{ needs.gather-refs.outputs.reftutorials }},PRECICE_REF:v3.0.0,OPENFOAM_EXECUTABLE:openfoam2306,OPENFOAM_ADAPTER_REF:${{ github.event.pull_request.head.sha }} + build_args: TUTORIALS_REF:${{ needs.gather-refs.outputs.reftutorials }},PRECICE_REF:v3.0.0,OPENFOAM_EXECUTABLE:openfoam2312,OPENFOAM_ADAPTER_REF:${{ github.event.pull_request.head.sha }} systests_branch: develop loglevel: "DEBUG" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 51cd7ebc..f3554f66 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,3 +13,8 @@ repos: files: "^docs/.*.md" - id: markdownlint-fix files: "^docs/.*.md" +- repo: https://github.com/koalaman/shellcheck-precommit + rev: v0.10.0 + hooks: + - id: shellcheck + args: [ --external-sources, --exclude=SC1091 ] diff --git a/README.md b/README.md index d31a4de9..9d6c465e 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,9 @@ # OpenFOAM-preCICE adapter -[![Build with OpenFOAM v2306](https://github.com/precice/openfoam-adapter/actions/workflows/build.yml/badge.svg?branch=develop)](https://github.com/precice/openfoam-adapter/actions/workflows/build.yml) +[![Ask questions in the forum](https://img.shields.io/badge/community-discourse_forum-orange?link=https%3A%2F%2Fprecice.discourse.group%2F)](https://precice.discourse.group/) +[![Build with OpenFOAM v2312](https://github.com/precice/openfoam-adapter/actions/workflows/build.yml/badge.svg?branch=develop)](https://github.com/precice/openfoam-adapter/actions/workflows/build.yml) [![Changelog](https://img.shields.io/badge/Keep%20a%20Changelog--555.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9IiNmMTVkMzAiIHZpZXdCb3g9IjAgMCAxODcgMTg1Ij48cGF0aCBkPSJNNjIgN2MtMTUgMy0yOCAxMC0zNyAyMmExMjIgMTIyIDAgMDAtMTggOTEgNzQgNzQgMCAwMDE2IDM4YzYgOSAxNCAxNSAyNCAxOGE4OSA4OSAwIDAwMjQgNCA0NSA0NSAwIDAwNiAwbDMtMSAxMy0xYTE1OCAxNTggMCAwMDU1LTE3IDYzIDYzIDAgMDAzNS01MiAzNCAzNCAwIDAwLTEtNWMtMy0xOC05LTMzLTE5LTQ3LTEyLTE3LTI0LTI4LTM4LTM3QTg1IDg1IDAgMDA2MiA3em0zMCA4YzIwIDQgMzggMTQgNTMgMzEgMTcgMTggMjYgMzcgMjkgNTh2MTJjLTMgMTctMTMgMzAtMjggMzhhMTU1IDE1NSAwIDAxLTUzIDE2bC0xMyAyaC0xYTUxIDUxIDAgMDEtMTItMWwtMTctMmMtMTMtNC0yMy0xMi0yOS0yNy01LTEyLTgtMjQtOC0zOWExMzMgMTMzIDAgMDE4LTUwYzUtMTMgMTEtMjYgMjYtMzMgMTQtNyAyOS05IDQ1LTV6TTQwIDQ1YTk0IDk0IDAgMDAtMTcgNTQgNzUgNzUgMCAwMDYgMzJjOCAxOSAyMiAzMSA0MiAzMiAyMSAyIDQxLTIgNjAtMTRhNjAgNjAgMCAwMDIxLTE5IDUzIDUzIDAgMDA5LTI5YzAtMTYtOC0zMy0yMy01MWE0NyA0NyAwIDAwLTUtNWMtMjMtMjAtNDUtMjYtNjctMTgtMTIgNC0yMCA5LTI2IDE4em0xMDggNzZhNTAgNTAgMCAwMS0yMSAyMmMtMTcgOS0zMiAxMy00OCAxMy0xMSAwLTIxLTMtMzAtOS01LTMtOS05LTEzLTE2YTgxIDgxIDAgMDEtNi0zMiA5NCA5NCAwIDAxOC0zNSA5MCA5MCAwIDAxNi0xMmwxLTJjNS05IDEzLTEzIDIzLTE2IDE2LTUgMzItMyA1MCA5IDEzIDggMjMgMjAgMzAgMzYgNyAxNSA3IDI5IDAgNDJ6bS00My03M2MtMTctOC0zMy02LTQ2IDUtMTAgOC0xNiAyMC0xOSAzN2E1NCA1NCAwIDAwNSAzNGM3IDE1IDIwIDIzIDM3IDIyIDIyLTEgMzgtOSA0OC0yNGE0MSA0MSAwIDAwOC0yNCA0MyA0MyAwIDAwLTEtMTJjLTYtMTgtMTYtMzEtMzItMzh6bS0yMyA5MWgtMWMtNyAwLTE0LTItMjEtN2EyNyAyNyAwIDAxLTEwLTEzIDU3IDU3IDAgMDEtNC0yMCA2MyA2MyAwIDAxNi0yNWM1LTEyIDEyLTE5IDI0LTIxIDktMyAxOC0yIDI3IDIgMTQgNiAyMyAxOCAyNyAzM3MtMiAzMS0xNiA0MGMtMTEgOC0yMSAxMS0zMiAxMXptMS0zNHYxNGgtOFY2OGg4djI4bDEwLTEwaDExbC0xNCAxNSAxNyAxOEg5NnoiLz48L3N2Zz4K)](https://github.com/precice/openfoam-adapter/blob/develop/CHANGELOG.md) - - GNU GPL license - - +[![License](https://img.shields.io/github/license/precice/openfoam-adapter.svg)](https://github.com/precice/openfoam-adapter/blob/master/LICENSE) ## Start here diff --git a/docs/get.md b/docs/get.md index b2fb53f9..5460106d 100644 --- a/docs/get.md +++ b/docs/get.md @@ -8,7 +8,8 @@ summary: "Get the code from GitHub and run ./Allwmake. If this fails, look into To build the adapter, you need to install a few dependencies and then execute the `Allwmake` script. 1. Install [a compatible OpenFOAM distribution](https://precice.org/adapter-openfoam-support.html). -2. Install [preCICE v3](https://precice.org/installation-overview.html). In case you need preCICE v2, please install an older version of the adapter (v1.2.3 is the latest release to support preCICE v2). +2. Install [preCICE v3](https://precice.org/installation-overview.html). + * In case you need preCICE v2, please install an older version of the adapter ([v1.2.3](https://github.com/precice/openfoam-adapter/releases/tag/v1.2.3) was the last release to support preCICE v2). 3. [Download the latest release](https://github.com/precice/openfoam-adapter/releases/latest) for your OpenFOAM version. 4. Execute the build script: `./Allwmake`. * See and adjust the configuration in the beginning of the script first, if needed. diff --git a/docs/openfoam-support.md b/docs/openfoam-support.md index 72868ff1..fb8fc0df 100644 --- a/docs/openfoam-support.md +++ b/docs/openfoam-support.md @@ -7,14 +7,14 @@ summary: Recent OpenFOAM.com versions work out-of-the-box. Recent OpenFOAM.org v ## How to get OpenFOAM -The easiest way to start is to get binary packages for your Linux distribution. For example, to [get OpenFOAM v2306 on Ubuntu](https://develop.openfoam.com/Development/openfoam/-/wikis/precompiled/debian#precompiled-packages-debianubuntu): +The easiest way to start is to get binary packages for your Linux distribution. For example, to [get OpenFOAM v2312 on Ubuntu](https://develop.openfoam.com/Development/openfoam/-/wikis/precompiled/debian#precompiled-packages-debianubuntu): ```bash # Add the signing key, add the repository, update: wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash -# Install OpenFOAM v2306: -sudo apt-get install openfoam2306-dev +# Install OpenFOAM v2312: +sudo apt-get install openfoam2312-dev ``` As these steps change your `.profile`, you need to log out and in again to make OpenFOAM fully discoverable. @@ -26,7 +26,7 @@ OpenFOAM is a project with long history and many forks, of which we try to suppo We provide version-specific [release archives](https://github.com/precice/openfoam-adapter/releases/latest) and respective Git branches for: - OpenCFD / ESI (openfoam.com) - main focus: - - [OpenFOAM v1812-v2306](https://github.com/precice/openfoam-adapter) or newer + - [OpenFOAM v1812-v2312](https://github.com/precice/openfoam-adapter) or newer - OpenFOAM v2212 and newer is only supported since v1.2.2 of the adapter. - [OpenFOAM v1612-v1806](https://github.com/precice/openfoam-adapter/tree/OpenFOAMv1806) (not tested) - OpenFOAM Foundation (openfoam.org) - secondary, consider experimental: From 6459101e2365ee5e3fdbbb087824b2ee3e264605 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Wed, 20 Mar 2024 23:10:42 +0100 Subject: [PATCH 58/60] Update changelog --- CHANGELOG.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9dccccf..264c5c7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ Read more details in the issue [#52: Releases and versioning](https://github.com -## [v1.3.0] 2024-02-09 +## [v1.3.0] 2024-03-20 ### Added @@ -16,19 +16,20 @@ Read more details in the issue [#52: Releases and versioning](https://github.com - Added volume coupling over one or multiple domain regions specified by OpenFOAM cellSets (for Pressure and Velocity (FF) and Temperature (FF))[#270](https://github.com/precice/openfoam-adapter/pull/270). - Added phase variable and flux coupling for interFOAM in the FF module [#308](https://github.com/precice/openfoam-adapter/pull/308). - Added custom inletOutlet boundary conditions for pressure and velocity to the FF module [#281](https://github.com/precice/openfoam-adapter/pull/281). -- Temperature and temperature gradient as coupling data to the FF module [#281](https://github.com/precice/openfoam-adapter/pull/281). +- Added temperature and temperature gradient as coupling data to the FF module [#281](https://github.com/precice/openfoam-adapter/pull/281). - Added option to write velocity that is corrected by the face flux `phi` [#281](https://github.com/precice/openfoam-adapter/pull/281). +- Added a pre-commit hook to check formatting and linting of various aspects [#321](https://github.com/precice/openfoam-adapter/pull/321). +- Added a workflow for triggering system regression tests [#309](https://github.com/precice/openfoam-adapter/pull/309). - Added citing guidelines, referring to the [new reference article at the OpenFOAM Journal](https://doi.org/10.51560/ofj.v3.88). [#287](https://github.com/precice/openfoam-adapter/pull/287) ### Changed -- Ported the adapter to preCICE v3. The adapter is not compatible with v2 anymore. [#285](https://github.com/precice/openfoam-adapter/pull/285). -- Changed the default OpenFOAM version to v2306 in the documentation and CI +- Changed the preCICE dependency version to v3. The adapter is not compatible with v2 anymore. [#285](https://github.com/precice/openfoam-adapter/pull/285). +- Changed the default OpenFOAM version to v2312 in the documentation and CI. [#325](https://github.com/precice/openfoam-adapter/pull/325). - Changed the way mesh connectivity (face triangles) are provided to preCICE, adapting to preCICE v3 [#297](https://github.com/precice/openfoam-adapter/pull/297). -- Merged `initializeData` into `initialize` [#262](https://github.com/precice/openfoam-adapter/pull/262). - Renamed the `adjustSolverTimeStep()` method to `adjustSolverTimeStepAndReadData()`, changing the behavior to always read data at the determined time step size [#298](https://github.com/precice/openfoam-adapter/pull/298). -- The Build CI workflow now relies on the setup-precice-action to install preCICE [#299](https://github.com/precice/openfoam-adapter/pull/299). -- Reduced building time by grouping together compilation units of each module [#301](https://github.com/precice/openfoam-adapter/pull/301). +- Changed the build CI workflow to use the setup-precice-action to install preCICE [#299](https://github.com/precice/openfoam-adapter/pull/299). +- Improved building time by grouping together compilation units of each module [#301](https://github.com/precice/openfoam-adapter/pull/301). ## [v1.2.3] 2023-06-14 From a760e6542db51a4f6815e92461ff964c27a8257c Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Wed, 20 Mar 2024 23:24:15 +0100 Subject: [PATCH 59/60] Update version in create-release-archives.sh --- tools/create-release-archives.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/create-release-archives.sh b/tools/create-release-archives.sh index fb0fc986..7287ffae 100755 --- a/tools/create-release-archives.sh +++ b/tools/create-release-archives.sh @@ -4,10 +4,10 @@ set -u remote_name=origin -adapter_version="v1.2.3" +adapter_version="v1.3.0" # Declare branch names for which archives will be created -declare -a branches=("master" "OpenFOAMv1806" "OpenFOAM10" "OpenFOAM9" "OpenFOAM8" "OpenFOAM7" "OpenFOAM6" "OpenFOAM5" "OpenFOAM4") +declare -a branches=("master" "OpenFOAMv1806" "OpenFOAM10" "OpenFOAM9" "OpenFOAM8" "OpenFOAM7" "OpenFOAM6" "OpenFOAM5") mkdir -p release-archives for i in "${branches[@]}" From ff087bc5d48a47fedcc0ff32744da04ea5f3dd02 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Wed, 20 Mar 2024 23:31:14 +0100 Subject: [PATCH 60/60] Add link to the preCICE forum --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9d6c465e..b4578250 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ See the [adapter documentation](https://precice.org/adapter-openfoam-overview.html) and related [tutorials](https://precice.org/tutorials.html). -Please [report any issues](https://github.com/precice/openfoam-adapter/issues) here and give us feedback through [one of our community channels](https://precice.org/community-channels.html). +Please [report any issues](https://github.com/precice/openfoam-adapter/issues) here and give us feedback through [one of our community channels](https://precice.org/community-channels.html). Please ask question in the [preCICE forum](https://precice.discourse.group/), not via issues. This project is actively maintained on [precice/openfoam-adapter](https://github.com/precice/openfoam-adapter). Current maintainers: [@MakisH](https://github.com/MakisH/) and [@DavidSCN](https://github.com/DavidSCN).