From 8fa39e4322745dd47d4ee6d7b640c717b47f718f Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Fri, 16 Apr 2021 22:16:19 +0200 Subject: [PATCH 01/46] Add GitHub actions: shellcheck (#164) --- .github/workflows/check.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .github/workflows/check.yml diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 00000000..06471c33 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,10 @@ +name: Check +on: [push, pull_request] +jobs: + check: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v2 + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master From 3f256426ca7520b11423cb0fbffcdbcda3da27e9 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Sat, 17 Apr 2021 00:25:43 +0200 Subject: [PATCH 02/46] Add GitHub actions: building (and remove Travis) (#165) * Add a basic building job * Add cache-anything-new-action * Remove Travis (broken, plans to change) * Add building badge * Add changelog entry --- .github/workflows/build.yml | 24 +++++++++++++++++++++++ .github/workflows/install-dependencies.sh | 9 +++++++++ .travis.yml | 13 ------------ CHANGELOG.md | 6 +++++- README.md | 8 +++++--- 5 files changed, 43 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100755 .github/workflows/install-dependencies.sh delete mode 100644 .travis.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..d8de24ce --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,24 @@ +name: Build with OpenFOAM v2012 +on: [push, pull_request] +jobs: + build: + runs-on: ubuntu-20.04 + steps: + - name: Check out repository + uses: actions/checkout@v2 + - name: Setup caches + uses: actions/cache@v2 + id: cache-id + with: + path: ${{ runner.temp }}/cache-directory + key: ${{ runner.os }}-cache-dependencies-v1.0 + - name: Install dependencies (considering cache) + uses: airvzxf/cache-anything-new-action@v1.0.1 + with: + script: 'install-dependencies.sh' + is_cached: ${{ steps.cache-id.outputs.cache-hit }} + cache: ${{ runner.temp }}/cache-directory + snapshot: '/' + exclude: '/boot /data /dev /mnt /proc /run /sys' + - name: Build OpenFOAM-preCICE adapter + run: /usr/bin/openfoam2012 ./Allwmake diff --git a/.github/workflows/install-dependencies.sh b/.github/workflows/install-dependencies.sh new file mode 100755 index 00000000..ffb18ae2 --- /dev/null +++ b/.github/workflows/install-dependencies.sh @@ -0,0 +1,9 @@ +#!/bin/bash -e + +# Install OpenFOAM v2012 +wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash +sudo apt-get install openfoam2012-dev + +# Install preCICE v2.2.0 +wget https://github.com/precice/precice/releases/download/v2.2.0/libprecice2_2.2.0_focal.deb +sudo apt install ./libprecice2_2.2.0_focal.deb \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3ed015b9..00000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -sudo: true -dist: trusty -language: python -python: - - "3.5" -jobs: - include: - # trigger systemtests build only on main branches and not on external prs - - if: fork = false AND ( branch = master OR branch = develop ) - script: - - curl -LO --retry 3 https://raw.githubusercontent.com/precice/systemtests/develop/trigger_systemtests.py - - travis_wait 60 python trigger_systemtests.py --adapter openfoam --wait - diff --git a/CHANGELOG.md b/CHANGELOG.md index 558c220c..8ebc32f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ For more details, look at the [merged pull requests](https://github.com/precice/openfoam-adapter/pulls?q=is%3Apr+is%3Amerged). +## develop + +- Added GitHub actions to build the adapter with OpenFOAM v2012 and to check shell scripts. + ## 2021-04-15 - Moved the wiki pages into the `docs/` folder here. These pages are now rendered in the [new adapter documentation](https://precice.org/adapter-openfoam-overview.html). @@ -27,4 +31,4 @@ This changelog was established in April 2021 and the previous release was on Sep - Added support for computing forces in compressible and turbulent flows. [#64](https://github.com/precice/openfoam-adapter/pull/64) - Added support for fluid-structure interaction (FSI) module. [#56](https://github.com/precice/openfoam-adapter/pull/56) -The first commit to this codebase was on May 28, 2017. \ No newline at end of file +The first commit to this codebase was on May 28, 2017. diff --git a/README.md b/README.md index 3204cca9..d04e597c 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ # OpenFOAM-preCICE adapter - + +[![Build with OpenFOAM v2012](https://github.com/precice/openfoam-adapter/actions/workflows/build.yml/badge.svg?branch=develop)](https://github.com/precice/openfoam-adapter/actions/workflows/build.yml) GNU GPL license + ## Start here From 9efab643ccf3b8fbf2d1110953ae2de9830535c9 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Sat, 17 Apr 2021 00:49:31 +0200 Subject: [PATCH 03/46] Add code of conduct (#166) --- CODE_OF_CONDUCT.md | 128 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..98b7c96e --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +info at precice.org. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. From f538a5030c87bf733012e6ca13cd47400ac82446 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Sat, 17 Apr 2021 09:46:42 +0200 Subject: [PATCH 04/46] Add maintainers, status, and issues in README.md (#167) --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d04e597c..4cbf15f8 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ Build status --> +As of April 2021, `precice/openfoam-adapter` is actively developed. Current maintainers: [@MakisH](https://github.com/MakisH/) and [@DavidSCN](https://github.com/DavidSCN). 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). + ## Start here See the [adapter documentation](https://precice.org/adapter-openfoam-overview.html) and related [tutorials](https://precice.org/tutorials.html). From f0d9ab87d722be8d01b4da0460d74e372cfd7b8a Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Wed, 21 Apr 2021 08:44:49 +0200 Subject: [PATCH 05/46] Adopt the "Keep a changelog" format in CHANGELOG.md (#168) --- CHANGELOG.md | 71 +++++++++++++++++++++++++++++----------- CONTRIBUTING.md | 8 ++++- README.md | 1 + changelog-entries/168.md | 1 + 4 files changed, 61 insertions(+), 20 deletions(-) create mode 100644 changelog-entries/168.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ebc32f5..9d68d7e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,34 +1,67 @@ -# OpenFOAM-preCICE adapter changelog +# Changelog -For more details, look at the [merged pull requests](https://github.com/precice/openfoam-adapter/pulls?q=is%3Apr+is%3Amerged). +All notable changes to this project will be documented in this file. -## develop +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +A fitting versioning scheme for this project is [under discussion](https://github.com/precice/openfoam-adapter/issues/52). -- Added GitHub actions to build the adapter with OpenFOAM v2012 and to check shell scripts. + -## 2021-04-15 +## [Unreleased] + +### Added + +- GitHub actions to build the adapter with OpenFOAM v2012 and to check shell scripts. +- Status of the project in `README.md`: CI badges, license, maintainers, links to issues. + +### Changed + +- This Changelog now follows the [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format. + +## [pre-versioning-0] 2021-04-15 + +### Added + +- Support for reading displacements on face centers and further improved the 2D mode. [#147](https://github.com/precice/openfoam-adapter/pull/147) +- Restrict the user in valid orientation of 2D cases with an assertion. [#155](https://github.com/precice/openfoam-adapter/pull/155) +- New fluid-fluid coupling (FF) module. You can find a new [partitioned pipe tutorial on the website](https://precice.org/tutorials-partitioned-pipe.html). [#67](https://github.com/precice/openfoam-adapter/pull/67) + +### Changed - Moved the wiki pages into the `docs/` folder here. These pages are now rendered in the [new adapter documentation](https://precice.org/adapter-openfoam-overview.html). - Moved all the `tutorials/` to the [tutorials repository](https://github.com/precice/tutorials) and the related documentation to the [preCICE website](https://precice.org/tutorials.html). - Disabled debug messages by default, to reduce visual noise and logs length. [a942c8](https://github.com/precice/openfoam-adapter/commit/a942c8dc6a9f9ec29f0bb1d6625501657cdd8b65) -- Added a fluid-fluid coupling (FF) module. You can find a new [partitioned pipe tutorial on the website](https://precice.org/tutorials-partitioned-pipe.html). [#67](https://github.com/precice/openfoam-adapter/pull/67) -- Added support for reading displacements on face centers and further improved the 2D mode. [#147](https://github.com/precice/openfoam-adapter/pull/147) -- Added an assertion to restrict the user in valid orientation of 2D cases. [#155](https://github.com/precice/openfoam-adapter/pull/155) -- Improved the `Allwmake` and `Allclean` scripts, dropping support for preCICE 1.x. [#157](https://github.com/precice/openfoam-adapter/pull/157) - Added `-j 4` to `wmake` in `Allwmake` to build with four threads by default. Remove this you face any issues (in which case, let us know). [#162](https://github.com/precice/openfoam-adapter/pull/162) - Refactored the `Force` class. [#148](https://github.com/precice/openfoam-adapter/pull/148) + +### Removed + +- Dropped support for preCICE v1.x. [#157](https://github.com/precice/openfoam-adapter/pull/157) + +### Fixed + +- Improved the `Allwmake` and `Allclean` scripts. [#157](https://github.com/precice/openfoam-adapter/pull/157) - Cleaned up a few non-const references to boundary fields. [#132](https://github.com/precice/openfoam-adapter/pull/132) -## Earlier changes +## [ancient-0] 2020-09-02 + +This changelog was established in April 2021 and the previous release was on September 2020. Notable changes before that and since the beginning of the project include, in arbitrary order: + +### Added + +- New fluid-structure interaction (FSI) module. [#56](https://github.com/precice/openfoam-adapter/pull/56) +- Support stress data in FSI. [#125](https://github.com/precice/openfoam-adapter/pull/125) +- Support computing forces in compressible and turbulent flows. [#64](https://github.com/precice/openfoam-adapter/pull/64) +- Support nearest-projection mapping. [#46](https://github.com/precice/openfoam-adapter/pull/46) +- Support preCICE v2. [#117](https://github.com/precice/openfoam-adapter/pull/117) + +### Changed + +- Replaced the YAML-based configuration format with an OpenFOAM dictionary. [#105](https://github.com/precice/openfoam-adapter/pull/105) +- The compressible/incompressible solver type is not determined based on the pressure dimensions. [#124](https://github.com/precice/openfoam-adapter/pull/124) -This changelog was established in April 2021 and the previous release was on September 2020. Notable changes before that include: +### Removed -- Added support for stress data. [#125](https://github.com/precice/openfoam-adapter/pull/125) -- Changed the solver type determination to a dimensions-based one. [#124](https://github.com/precice/openfoam-adapter/pull/124) -- Removed boundary evaluation under checkpointing. [#110](https://github.com/precice/openfoam-adapter/pull/110) -- Updated for preCICE v2. [#117](https://github.com/precice/openfoam-adapter/pull/117) -- Added support for nearest-projection mapping. [#46](https://github.com/precice/openfoam-adapter/pull/46) -- Added support for computing forces in compressible and turbulent flows. [#64](https://github.com/precice/openfoam-adapter/pull/64) -- Added support for fluid-structure interaction (FSI) module. [#56](https://github.com/precice/openfoam-adapter/pull/56) +- Boundary evaluation under checkpointing. [#110](https://github.com/precice/openfoam-adapter/pull/110) -The first commit to this codebase was on May 28, 2017. +The first commit to this codebase was on May 28, 2017 and the adapter has been used by non-developers since 2018. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d5846439..ce494d89 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,4 +2,10 @@ Hi there! Amazing that you want to contribute to this project! Please have a look at the page [contributing to preCICE](https://precice.org/community-contribute-to-precice.html) -and watch out for more specific details in this file. \ No newline at end of file +and watch out for more specific details in this file. + +## Changelog + +Instead of directly editing `CHANGELOG.md`, please add a file `123.md` +in `changelog-entries`, where `123` your pull request number. This helps reduce +merge conflicts and we will merge these files at the time we release a new version. \ No newline at end of file diff --git a/README.md b/README.md index 4cbf15f8..6f21a954 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # OpenFOAM-preCICE adapter [![Build with OpenFOAM v2012](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/168.md b/changelog-entries/168.md new file mode 100644 index 00000000..2d04bbf1 --- /dev/null +++ b/changelog-entries/168.md @@ -0,0 +1 @@ +Adopted the [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format in `CHANGELOG.md`. From 423b76b8e25bf9ff1cb9552928a8a2c1b8b88b2e Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Wed, 21 Apr 2021 15:10:17 +0200 Subject: [PATCH 06/46] Add GitHub actions to lint markdown files and check links (#169) --- .github/workflows/check.yml | 16 ++++++++++++-- .markdown-link-check-config.json | 3 +++ .markdownlint.json | 4 ++++ CODE_OF_CONDUCT.md | 2 ++ CONTRIBUTING.md | 28 ++++++++++++++++++++++++- changelog-entries/169.md | 1 + docs/README.md | 13 ++++++------ docs/config.md | 36 +++++++++++++++++++++++--------- docs/get.md | 15 ++++++------- docs/openfoam-support.md | 1 + 10 files changed, 90 insertions(+), 29 deletions(-) create mode 100644 .markdown-link-check-config.json create mode 100644 .markdownlint.json create mode 100644 changelog-entries/169.md diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 06471c33..f78952da 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -1,4 +1,4 @@ -name: Check +name: Lint scripts and docs on: [push, pull_request] jobs: check: @@ -6,5 +6,17 @@ jobs: steps: - name: Check out repository uses: actions/checkout@v2 - - name: Run ShellCheck + - name: Lint shell scripts (shellcheck) uses: ludeeus/action-shellcheck@master + - name: Lint markdown files (markdownlint) + uses: articulate/actions-markdownlint@v1 + with: + config: .markdownlint.json + files: '.' + ignore: changelog-entries + - 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/.markdown-link-check-config.json b/.markdown-link-check-config.json new file mode 100644 index 00000000..3fff32c2 --- /dev/null +++ b/.markdown-link-check-config.json @@ -0,0 +1,3 @@ +{ + "aliveStatusCodes": [429, 200] +} \ No newline at end of file diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 00000000..151ee39b --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,4 @@ +{ + "MD013": false, + "MD033": false +} \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 98b7c96e..ad39c9fd 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,5 +1,7 @@ # Contributor Covenant Code of Conduct + + ## Our Pledge We as members, contributors, and leaders pledge to make participation in our diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ce494d89..bbb37855 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,4 +8,30 @@ and watch out for more specific details in this file. Instead of directly editing `CHANGELOG.md`, please add a file `123.md` in `changelog-entries`, where `123` your pull request number. This helps reduce -merge conflicts and we will merge these files at the time we release a new version. \ No newline at end of file +merge conflicts and we will merge these files at the time we release a new version. + +## Checking the Markdown files + +Every contribution is automatically checked for issues in the `.md` files. +You can run these tests locally by installing [markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli) +from npm: + +```bash +npm install -g markdownlint-cli +``` + +If you get any permission errors when trying to install from npm, [set the npm prefix to a local directory](https://stackoverflow.com/a/54170648/2254346). + +After installing, you can check all files in the current directory with: + +```bash +markdownlint . +``` + +There are also extensions for many editors that automatically check Markdown files with the same system. + +## Links in the Markdown files + +Please use static links when refering to preCICE resources outside of this repository. While relative paths will also work in the rendered website, they will not work in other contexts. + +We check these links automatically, but you can also check them locally with [markdown-link-check](https://github.com/tcort/markdown-link-check), which works similarly to markdownlint. diff --git a/changelog-entries/169.md b/changelog-entries/169.md new file mode 100644 index 00000000..d36125d9 --- /dev/null +++ b/changelog-entries/169.md @@ -0,0 +1 @@ +Added GitHub actions to check Markdown files, including broken links. [#169](https://github.com/precice/openfoam-adapter/pull/169) diff --git a/docs/README.md b/docs/README.md index d8b73e44..92c60076 100644 --- a/docs/README.md +++ b/docs/README.md @@ -7,11 +7,12 @@ 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](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. ## What can it do? This adapter can read/write the following fields: + - Temperature (read + write) - Heat flux (read + write) - Sink temperature (read + write) @@ -29,7 +30,7 @@ All features of preCICE are supported, including implicit coupling and nearest-p ## Try -Here you will find how to [get the adapter](adapter-openfoam-get.html), how to [configure](adapter-openfoam.config.html) a case, how to [extend the adapter](adapter-openfoam-extend.html) to cover additional features, as well as a few notes on [supported OpenFOAM versions](adapter-openfoam-support.html). +Here you will find how to [get the adapter](https://precice.org/adapter-openfoam-get.html), how to [configure](https://precice.org/adapter-openfoam-config.html) a case, how to [extend the adapter](https://precice.org/adapter-openfoam-extend.html) to cover additional features, as well as a few notes on [supported OpenFOAM versions](https://precice.org/adapter-openfoam-support.html). ## Learn @@ -42,9 +43,11 @@ 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]: -``` + +```text Gerasimos Chourdakis. A general OpenFOAM adapter for the coupling library preCICE. Master's thesis, Department of Informatics, Technical University of Munich, 2017. ``` + For CHT-specific topics, you may want to additionally look into [2] and for FSI into [3]. ### Related literature @@ -55,8 +58,4 @@ For CHT-specific topics, you may want to additionally look into [2] and for FSI [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. - {% include disclaimer.html content="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." %} - - - diff --git a/docs/config.md b/docs/config.md index ecfd2fe1..fdb8a001 100644 --- a/docs/config.md +++ b/docs/config.md @@ -6,17 +6,17 @@ summary: "Write a system/preciceDict, set compatible boundary conditions, and ac --- In order to run a coupled simulation, you need to: -1. prepare a preCICE configuration file (described in the [preCICE configuration](configuration-overview.html)), + +1. prepare a preCICE configuration file (described in the [preCICE configuration](https://www.precice.org/configuration-overview.html)), 2. prepare an adapter's configuration file, 3. set the coupling boundaries in the OpenFOAM case, 4. load the adapter, and 5. start all the solvers normally, from the same directory, e.g. in two different terminals. -If you prefer, you may find an already prepared case in the [tutorials/](https://github.com/precice/openfoam-adapter/tree/master/tutorials) directory. See also the description of this case in our [Tutorial for CHT: Flow over a heated plate](tutorials-flow-over-heated-plate.html). +If you prefer, you may find an already prepared case in our [Tutorial for CHT: Flow over a heated plate](https://precice.org/tutorials-flow-over-heated-plate.html). You may skip the section _"Advanced configuration"_ in the beginning, as it only concerns special cases. You may also find more details in the [Pull Request #105](https://github.com/precice/openfoam-adapter/pull/105), especially for changes regarding the previous, yaml-based configuration format. - ## The adapter's configuration file The adapter is configured via the file `system/preciceDict`. This file is an OpenFOAM dictionary with the following form: @@ -77,6 +77,7 @@ can be `Temperature`, `Heat-Flux`, `Sink-Temperature`, or `Heat-Transfer-Coefficient`. Values like `Sink-Temperature-Domain1` are also allowed. For a Dirichlet-Neumann coupling, the `writeData` and `readData` can be either: + ```c++ readData ( @@ -88,7 +89,9 @@ writeData Temperature ); ``` + or: + ```c++ readData ( @@ -100,7 +103,9 @@ writeData Heat-Flux ); ``` + For a Robin-Robin coupling, we need to write and read both of `Sink-Temperature` and `Heat-Transfer-Coefficient`: + ```c++ readData ( @@ -135,6 +140,7 @@ Read the [OpenFOAM User Guide](https://www.openfoam.com/documentation/user-guide * For `readData(Temperature)`, use `type fixedValue` for the `interface` in `0/T`. OpenFOAM requires that you also give a (redundant) `value`, but the adapter will overwrite it. ParaView uses this value for the initial time. As a placeholder, you can e.g. use the value from the `internalField`. + ```c++ interface { @@ -145,6 +151,7 @@ interface * For `readData(Heat-Flux)`, use `type fixedGradient` for the `interface` in `0/T`. OpenFOAM requires that you also give a (redundant) `gradient`, but the adapter will overwrite it. + ```c++ interface { @@ -152,9 +159,11 @@ interface gradient 0; } ``` + * For `readData(Sink-Temperature)` or `Heat-Transfer-Coefficient`, use `type mixed` for the `interface` in `0/T`. OpenFOAM requires that you also give (redundant) values for `refValue`, `refGradient`, and `valueFraction`, but the adapter will overwrite them. + ```c++ interface { @@ -168,9 +177,9 @@ interface #### FSI * For `readData(Displacement)` or `DisplacementDelta`, you need the following: - * `type movingWallVelocity` for the interface (e.g. `flap`) in `0/U`, - * `type fixedValue` for the interface (e.g. `flap`) in the `0/pointDisplacement`, and - * `solver displacementLaplacian` in the `constant/dynamicMeshDict`. + * `type movingWallVelocity` for the interface (e.g. `flap`) in `0/U`, + * `type fixedValue` for the interface (e.g. `flap`) in the `0/pointDisplacement`, and + * `solver displacementLaplacian` in the `constant/dynamicMeshDict`. ```c++ // File 0/U @@ -193,8 +202,6 @@ motionSolverLibs ("libfvMotionSolvers.so"); solver displacementLaplacian; ``` - - ### Load the adapter To load this adapter, you must include the following in @@ -210,6 +217,7 @@ functions } } ``` + 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. @@ -221,7 +229,8 @@ The name `preCICE_Adapter` can be arbitrary. These additional parameters may only concern some users is special cases. Keep reading if you want to use nearest-projection mapping, an incompressible or basic (e.g. laplacianFoam) solver, if you are using a solver with different variable names (e.g. a multiphase solver) or if you are trying to debug a simulation. ### Nearest-projection mapping -An example for for nearest-projection mapping is provided in the [nearest-projection tutorial case](tutorials-flow-over-heated-plate-nearest-projection.html). The [preCICE documentation](couple-your-code-defining-mesh-connectivity.html) contains a detailed description of nearest-projection mappings in preCICE. In summary, we need to explicitly enable the `connectivity` option to create edges between the interface mesh points and give them to preCICE: + +An example for for nearest-projection mapping is provided in the [nearest-projection tutorial case](https://precice.org/tutorials-flow-over-heated-plate-nearest-projection.html). The [preCICE documentation](https://precice.org/couple-your-code-defining-mesh-connectivity.html) contains a detailed description of nearest-projection mappings in preCICE. In summary, we need to explicitly enable the `connectivity` option to create edges between the interface mesh points and give them to preCICE: ```c++ interfaces @@ -247,6 +256,7 @@ interfaces }; }; ``` + This `connectivity` boolean is optional and defaults to `false`. Note that `connectivity true` can only be used with `locations faceNodes`. Even if the coupling data is associated to `faceCenters` in the solver, we can select `faceNodes` as locations type: the respective data will be interpolated from faces to nodes. Also, connectivity is only needed and supported for `writeData`. Therefore, we need to split the interface in a "read" and a "write" part, as shown above. @@ -254,6 +264,7 @@ Even if the coupling data is associated to `faceCenters` in the solver, we can s More details about the rationale are given in the following section. #### Adapter Implementation + Since OpenFOAM is a finite-volume based solver, data is located in the middle of the cell, or on the cell face centers for a coupling interface. Mesh connectivity can be given to preCICE using the methods `setMeshTriangle` and `setMeshEdge`. Using the face centers as arguments for these methods is cumbersome. The main reason is that, although OpenFOAM decomposes the mesh for parallel simulations and distributes the subdomains to different processes, mesh connectivity needs to be defined over the partitioned mesh boundaries. This problem vanishes if we define mesh connectivity based on the face nodes, since boundary nodes can be shared among processors. Therefore, mesh connectivity can only be provided on the face nodes (not on the face centers). As described already, the data is not stored on the face nodes, but on the face centers. Therefore, we use OpenFOAM functions to interpolate from face centers to face nodes. The following image illustrates the workflow: @@ -275,6 +286,7 @@ Some solvers may not read all the material properties that are required for a co For conjugate heat transfer, the adapter assumes that a solver belongs to one of the following categories: _compressible_, _incompressible_, or _basic_. Most of the solvers belong in the _compressible_ category and do not need any additional information. The other two need one or two extra parameters, in order to compute the heat flux. For **incompressible solvers** (like the buoyantBoussinesqPimpleFoam), you need to add the density and the specific heat in a `CHT` subdictionary of `preciceDict`. For example: + ```c++ CHT { @@ -284,12 +296,14 @@ CHT ``` For **basic solvers** (like the laplacianFoam), you need to add a constant conductivity: + ```c++ CHT { k [ 1 1 -3 -1 0 0 0 ] 100; }; ``` + The value of `k` is connected to the one of `DT` (set in `constant/transportProperties`) and depends on the density (`rho [ 1 -3 0 0 0 0 0 ]`) and heat capacity (`Cp [ 0 2 -2 -1 0 0 0 ]`). The relation between them is `DT = k / rho / Cp`. @@ -298,10 +312,12 @@ and depends on the density (`rho [ 1 -3 0 0 0 0 0 ]`) and heat capacity (`Cp The adapter's FSI functionality supports both compressible and incompressible solvers. For incompressible solvers, it tries to read uniform values for the density and kinematic viscosity (if it is not already available) from the `FSI` subdictionary of `preciceDict`: + ```c++ nu nu [ 0 2 -1 0 0 0 0 ] 1e-03; 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. ### Additional parameters in the adapter's configuration file @@ -355,7 +371,7 @@ CHT The adapter also recognizes a few more parameters, which are mainly used in debugging or development. These are optional and expect a `true` or a `false` value. Some or all of these options may be removed in the future. -The user can toggle debug messages at [build time](adapter-openfoam-get.html). +The user can toggle debug messages at [build time](https://precice.org/adapter-openfoam-get.html). ## Coupling OpenFOAM with 2D solvers diff --git a/docs/get.md b/docs/get.md index c7538c3a..4d287062 100644 --- a/docs/get.md +++ b/docs/get.md @@ -7,13 +7,10 @@ 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. -## Dependencies -1. Install [a compatible OpenFOAM distribution](adapter-openfoam-support.html). -2. Install [preCICE](installation-overview.html) - -## Adapter +1. Install [a compatible OpenFOAM distribution](https://precice.org/adapter-openfoam-support.html). +2. Install [preCICE](https://precice.org/installation-overview.html). 3. [Download](https://github.com/precice/openfoam-adapter/archive/master.zip) the adapter _or_ (better) install [git](https://git-scm.com/) and clone this repository: `git clone https://github.com/precice/openfoam-adapter.git`. - * [Depending on your OpenFOAM version](adapter-openfoam-support.html), you may need to change to a different git branch. + * [Depending on your OpenFOAM version](https://precice.org/adapter-openfoam-support.html), you may need to change to a different git branch. 4. Execute the build script: `./Allwmake`. * See and adjust the configuration in the beginning of the script first, if needed. * Check for any error messages and suggestions at the end. @@ -23,7 +20,7 @@ The `-DADAPTER_DEBUG_MODE` flag inside `ADAPTER_PREP_FLAGS` activates additional In order to upgrade the adapter, or before you build for another OpenFOAM version, run `./Allclean` first. Get the latest version using `git pull`. -Next: [configure and load the adapter](adapter-openfoam-config.html) or [run a tutorial](tutorials.html). +Next: [configure and load the adapter](https://precice.org/adapter-openfoam-config.html) or [run a tutorial](https://precice.org/tutorials.html). ## Troubleshooting @@ -40,7 +37,7 @@ The most important information in these files is the `-I` and `-L` flags used du If in the beginning of the simulation you get the following warning: -``` +```text Starting time loop --> FOAM Warning : @@ -73,7 +70,7 @@ This is an info/warning message that is printed when WMake tries to distinguish ### A header file cannot be found (during compilation) -This is a common problem e.g. when installing dependencies in non-system directories. Have a look in the page [linking to preCICE](installation-linking.html). +This is a common problem e.g. when installing dependencies in non-system directories. Have a look in the page [linking to preCICE](https://precice.org/installation-linking.html). ### Rellocation-related errors diff --git a/docs/openfoam-support.md b/docs/openfoam-support.md index b813a57c..25ad9eb4 100644 --- a/docs/openfoam-support.md +++ b/docs/openfoam-support.md @@ -24,6 +24,7 @@ As these steps change your `.profile`, you need to log out and in again to make OpenFOAM is a project with long history and many forks, of which we try to support as many as possible. Supported versions: + - OpenFOAM (openfoam.com): [v1706](https://www.openfoam.com/releases/openfoam-v1706/) - [v2012](https://www.openfoam.com/releases/openfoam-v2012/) (or newer) - OpenFOAM (openfoam.org): version [5.x](https://openfoam.org/version/5-0/) without changes. You need different branches for the versions [4.0/4.1](https://github.com/precice/openfoam-adapter/tree/OpenFOAM4), [6](https://github.com/precice/openfoam-adapter/tree/OpenFOAM6), [7](https://github.com/precice/openfoam-adapter/tree/OpenFOAM7), [8 (experimental)](https://github.com/precice/openfoam-adapter/pull/130). From d24f56fd07e36387731323978b77520471acd035 Mon Sep 17 00:00:00 2001 From: Benjamin Rodenberg Date: Wed, 21 Apr 2021 18:20:31 +0200 Subject: [PATCH 07/46] Split checks and recommend act for local checks. (#171) * Split checks and recommend act for local checks. * Remove guidelines that are now on precice.org Co-authored-by: Gerasimos Chourdakis --- .../{check.yml => check-markdown.yml} | 6 ++--- .github/workflows/check-shell.yml | 10 +++++++ CONTRIBUTING.md | 26 ------------------- 3 files changed, 12 insertions(+), 30 deletions(-) rename .github/workflows/{check.yml => check-markdown.yml} (82%) create mode 100644 .github/workflows/check-shell.yml diff --git a/.github/workflows/check.yml b/.github/workflows/check-markdown.yml similarity index 82% rename from .github/workflows/check.yml rename to .github/workflows/check-markdown.yml index f78952da..5bdd3d09 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check-markdown.yml @@ -1,13 +1,11 @@ -name: Lint scripts and docs +name: Lint docs and check links on: [push, pull_request] jobs: - check: + check_md: runs-on: ubuntu-latest steps: - name: Check out repository uses: actions/checkout@v2 - - name: Lint shell scripts (shellcheck) - uses: ludeeus/action-shellcheck@master - 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 new file mode 100644 index 00000000..f4400ed0 --- /dev/null +++ b/.github/workflows/check-shell.yml @@ -0,0 +1,10 @@ +name: Lint scripts +on: [push, pull_request] +jobs: + check_shell: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v2 + - name: Lint shell scripts (shellcheck) + uses: ludeeus/action-shellcheck@master diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bbb37855..407ade42 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,29 +9,3 @@ and watch out for more specific details in this file. Instead of directly editing `CHANGELOG.md`, please add a file `123.md` in `changelog-entries`, where `123` your pull request number. This helps reduce merge conflicts and we will merge these files at the time we release a new version. - -## Checking the Markdown files - -Every contribution is automatically checked for issues in the `.md` files. -You can run these tests locally by installing [markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli) -from npm: - -```bash -npm install -g markdownlint-cli -``` - -If you get any permission errors when trying to install from npm, [set the npm prefix to a local directory](https://stackoverflow.com/a/54170648/2254346). - -After installing, you can check all files in the current directory with: - -```bash -markdownlint . -``` - -There are also extensions for many editors that automatically check Markdown files with the same system. - -## Links in the Markdown files - -Please use static links when refering to preCICE resources outside of this repository. While relative paths will also work in the rendered website, they will not work in other contexts. - -We check these links automatically, but you can also check them locally with [markdown-link-check](https://github.com/tcort/markdown-link-check), which works similarly to markdownlint. From 4a1cd2bbde7e352c6e5f8d1c32fa19f0cc057e6a Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 29 Apr 2021 09:13:43 +0200 Subject: [PATCH 08/46] Add .clang-format and reformat the codebase (#173) --- .clang-format | 175 ++++++++ .github/workflows/check-format.yml | 13 + Adapter.C | 688 ++++++++++++----------------- Adapter.H | 411 +++++++++-------- CHT/CHT.C | 153 +++---- CHT/CHT.H | 7 +- CHT/HeatFlux.C | 98 ++-- CHT/HeatFlux.H | 44 +- CHT/HeatTransferCoefficient.C | 121 ++--- CHT/HeatTransferCoefficient.H | 50 +-- CHT/KappaEffective.C | 186 ++++---- CHT/KappaEffective.H | 34 +- CHT/SinkTemperature.C | 69 ++- CHT/SinkTemperature.H | 15 +- CHT/Temperature.C | 71 ++- CHT/Temperature.H | 15 +- CONTRIBUTING.md | 4 + CouplingDataUser.C | 2 +- CouplingDataUser.H | 13 +- FF/FF.C | 105 ++--- FF/FF.H | 12 +- FF/Pressure.C | 30 +- FF/Pressure.H | 14 +- FF/PressureGradient.C | 50 +-- FF/PressureGradient.H | 14 +- FF/Velocity.C | 54 +-- FF/Velocity.H | 14 +- FF/VelocityGradient.C | 74 ++-- FF/VelocityGradient.H | 14 +- FSI/Displacement.C | 96 ++-- FSI/Displacement.H | 20 +- FSI/DisplacementDelta.C | 100 +++-- FSI/DisplacementDelta.H | 20 +- FSI/FSI.C | 114 ++--- FSI/FSI.H | 11 +- FSI/Force.C | 37 +- FSI/Force.H | 14 +- FSI/ForceBase.C | 179 ++++---- FSI/ForceBase.H | 15 +- FSI/Stress.C | 33 +- FSI/Stress.H | 18 +- Interface.C | 247 +++++------ Interface.H | 29 +- Utilities.C | 42 +- changelog-entries/173.md | 1 + preciceAdapterFunctionObject.C | 27 +- preciceAdapterFunctionObject.H | 48 +- tools/format-code.sh | 4 + 48 files changed, 1653 insertions(+), 1952 deletions(-) create mode 100644 .clang-format create mode 100644 .github/workflows/check-format.yml create mode 100644 changelog-entries/173.md create mode 100755 tools/format-code.sh diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..00adea7a --- /dev/null +++ b/.clang-format @@ -0,0 +1,175 @@ +--- +Language: Cpp +# BasedOnStyle: LLVM +# +# Proposed clang-format-11 style for OpenFOAM, trying to follow the OpenFOAM style guide: +# https://develop.openfoam.com/Development/openfoam/-/wikis/coding/style/style +# Configuration developed for the OpenFOAM-preCICE adapter code: +# https://github.com/precice/openfoam-adapter +# Contribute to the discussion at the respective OpenFOAM issue: +# https://develop.openfoam.com/Development/openfoam/-/issues/1634 +# +# Keep `public:` at the first indentation level +AccessModifierOffset: -4 +# Undocumented guideline: align arguments after an open bracket. +AlignAfterOpenBracket: Align +AlignConsecutiveMacros: false +AlignConsecutiveAssignments: false +AlignConsecutiveBitFields: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Right +# Align operands after operators (+,*,<<) (see BreakBeforeBinaryOperators) +AlignOperands: AlignAfterOperator +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true +AllowAllConstructorInitializersOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortEnumsOnASingleLine: true +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Always +AllowShortLoopsOnASingleLine: false +# Guideline: Splitting return type and function name +# (this guideline is apparently not strictly followed in OpenFOAM) +# AlwaysBreakAfterReturnType: All +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: false +BinPackParameters: false +# Covered by "BreakBeforeBraces" +BraceWrapping: + AfterCaseLabel: true + AfterClass: true + AfterControlStatement: Always + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterObjCDeclaration: true + AfterStruct: true + AfterUnion: true + AfterExternBlock: true + BeforeCatch: true + BeforeElse: true + BeforeLambdaBody: true + BeforeWhile: true + IndentBraces: true + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +# Guideline (almost): Splitting long lines at an = sign. Indent after split. +# Guideline (almost): Splitting formulae over several lines. +BreakBeforeBinaryOperators: NonAssignment +# Always break before braces: if, for, functions, classes, etc. +BreakBeforeBraces: Allman +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeColon +# Guideline (almost): Splitting logical tests over several lines. +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +# Undocumented guideline (almost): Have the initializer : in a new line. +BreakConstructorInitializers: BeforeColon +BreakStringLiterals: true +# Here we could set the 80 charactes limit, but that would lead to more aggressive changes. +ColumnLimit: 0 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 0 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DeriveLineEnding: true +DerivePointerAlignment: false +DisableFormat: false +# Undocumented guideline: add line after "public:" etc (since clang-format 12) +# EmptyLineAfterAccessModifier: Always +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: false +# Guideline: Macro loops are like for loops, but without a space. +ForEachMacros: + - forAllIters + - forAllConstIters + - forAllReverseIters + - forAllConstReverseIters + - forAll + - forAllReverse + - forAllIter + - forAllConstIter +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + SortPriority: 0 + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + SortPriority: 0 + - Regex: '.*' + Priority: 1 + SortPriority: 0 +IncludeIsMainRegex: '(Test)?$' +IncludeIsMainSourceRegex: '' +IndentCaseLabels: false +IndentCaseBlocks: false +IndentGotoLabels: true +IndentPPDirectives: None +IndentExternBlock: AfterExternBlock +# Guideline: The normal indentation is 4 spaces per logical level. +IndentWidth: 4 +IndentWrappedFunctionNames: false +InsertTrailingCommas: None +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +# Required to not change code following the guidelines +# "Leave two empty lines between sections" and +# "Use two empty lines between functions" +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: None +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Left +ReflowComments: true +# Do not change the order of include statements (could be catastrophic for OpenFOAM) +SortIncludes: false +SortUsingDeclarations: false +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +# No "template " (guideline already used, but not documented) +SpaceAfterTemplateKeyword: false +SpaceBeforeAssignmentOperators: true +# No a{1} (no guideline) +SpaceBeforeCpp11BracedList: true +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +# Guideline: Spaces in "if ()", "for ()", but not "forAll ()". +SpaceBeforeParens: ControlStatementsExceptForEachMacros +# Guideline: Range-based for should have a space surrounding the ':'. +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInConditionalStatement: false +# No "arr[3] = [ 1, 2, 3 ]" (no guideline). +SpacesInContainerLiterals: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpaceBeforeSquareBrackets: false +# Treat the code as C++11 or later +Standard: Latest +StatementMacros: +TabWidth: 4 +UseCRLF: false +# Guideline: No tab characters - only use spaces for indentation. +UseTab: Never +WhitespaceSensitiveMacros: +... + diff --git a/.github/workflows/check-format.yml b/.github/workflows/check-format.yml new file mode 100644 index 00000000..7140b81c --- /dev/null +++ b/.github/workflows/check-format.yml @@ -0,0 +1,13 @@ +name: Check code formatting +on: [push, pull_request] +jobs: + formatting-check: + name: Check formatting (clang-format) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run clang-format style check for C/C++ programs. + uses: jidicula/clang-format-action@v3.3.0 + with: + clang-format-version: '11' + check-path: '.' diff --git a/Adapter.C b/Adapter.C index 73bd2b4f..bd313979 100644 --- a/Adapter.C +++ b/Adapter.C @@ -7,9 +7,8 @@ using namespace Foam; preciceAdapter::Adapter::Adapter(const Time& runTime, const fvMesh& mesh) -: -runTime_(runTime), -mesh_(mesh) +: runTime_(runTime), + mesh_(mesh) { adapterInfo("The preciceAdapter was loaded.", "info"); @@ -22,168 +21,173 @@ bool preciceAdapter::Adapter::configFileRead() // We need a try-catch here, as if reading preciceDict fails, // the respective exception will be reduced to a warning. // See also comment in preciceAdapter::Adapter::configure(). - try { + try + { adapterInfo("Reading preciceDict...", "info"); // TODO: static is just a quick workaround to be able // to find the dictionary also out of scope (e.g. in KappaEffective). // We need a better solution. - static IOdictionary preciceDict - ( - IOobject - ( + static IOdictionary preciceDict( + IOobject( "preciceDict", runTime_.system(), mesh_, IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE - ) - ); - - // Read and display the preCICE configuration file name - // NOTE: lookupType("name") is deprecated in openfoam.com since v1812, - // which recommends get("name") instead. However, get("name") - // is not implemented in openfoam.org at the moment. - preciceConfigFilename_ = preciceDict.lookupType("preciceConfig"); // We use this deprecated lookupType<>() for backwards compatibility - DEBUG(adapterInfo(" precice-config-file : " + preciceConfigFilename_)); - - // Read and display the participant name - participantName_ = preciceDict.lookupType("participant"); // We use this deprecated lookupType<>() for backwards compatibility - DEBUG(adapterInfo(" participant name : " + participantName_)); - - // Read and display the list of modules - DEBUG(adapterInfo(" modules requested : ")); - wordList modules_ = preciceDict.lookupType("modules"); // We use this deprecated lookupType<>() for backwards compatibility - for (auto module : modules_) - { - DEBUG(adapterInfo(" - " + module + "\n")); - - // Set the modules switches - if (module == "CHT") CHTenabled_ = true; - if (module == "FSI") FSIenabled_ = true; - if (module == "FF") FFenabled_ = true; - } - - // Every interface is a subdictionary of "interfaces", - // each with an arbitrary name. Read all of them and create - // a list (here: pointer) of dictionaries. - const dictionary * interfaceDictPtr = preciceDict.subDictPtr("interfaces"); // We use this deprecated subDictPtr for backwards compatibility - DEBUG(adapterInfo(" interfaces : ")); - - // Check if we found any interfaces - // and get the details of each interface - if (!interfaceDictPtr) - { - adapterInfo(" Empty list of interfaces", "warning"); - return false; - } - else - { - for (const entry& interfaceDictEntry : *interfaceDictPtr) - { - if(interfaceDictEntry.isDict()) - { - dictionary interfaceDict = interfaceDictEntry.dict(); - struct InterfaceConfig interfaceConfig; + IOobject::NO_WRITE)); - interfaceConfig.meshName = interfaceDict.lookupType("mesh"); // We use this deprecated lookupType<>() for backwards compatibility - DEBUG(adapterInfo(" - mesh : " + interfaceConfig.meshName)); + // Read and display the preCICE configuration file name + // NOTE: lookupType("name") is deprecated in openfoam.com since v1812, + // which recommends get("name") instead. However, get("name") + // is not implemented in openfoam.org at the moment. + preciceConfigFilename_ = preciceDict.lookupType("preciceConfig"); // We use this deprecated lookupType<>() for backwards compatibility + DEBUG(adapterInfo(" precice-config-file : " + preciceConfigFilename_)); - // By default, assume "faceCenters" as locationsType - interfaceConfig.locationsType = interfaceDict.lookupOrDefault("locations", "faceCenters"); - DEBUG(adapterInfo(" locations : " + interfaceConfig.locationsType)); + // Read and display the participant name + participantName_ = preciceDict.lookupType("participant"); // We use this deprecated lookupType<>() for backwards compatibility + DEBUG(adapterInfo(" participant name : " + participantName_)); - // 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") - { - DEBUG(adapterInfo("Mesh connectivity is not supported for faceCenters. \n" - "Please configure the desired interface with the locationsType faceNodes. \n" - "Have a look in the adapter documentation for detailed information.", "warning")); - return false; - } - DEBUG(adapterInfo(" connectivity : " + std::to_string(interfaceConfig.meshConnectivity))); - - DEBUG(adapterInfo(" patches : ")); - wordList patches = interfaceDict.lookupType("patches"); // We use this deprecated lookupType<>() for backwards compatibility - for (auto patch : patches) - { - interfaceConfig.patchNames.push_back(patch); - DEBUG(adapterInfo(" - " + patch)); - } - - DEBUG(adapterInfo(" writeData : ")); - wordList writeData = interfaceDict.lookupType("writeData"); // We use this deprecated lookupType<>() for backwards compatibility - for (auto writeDatum : writeData) - { - interfaceConfig.writeData.push_back(writeDatum); - DEBUG(adapterInfo(" - " + writeDatum)); - } + // Read and display the list of modules + DEBUG(adapterInfo(" modules requested : ")); + wordList modules_ = preciceDict.lookupType("modules"); // We use this deprecated lookupType<>() for backwards compatibility + for (auto module : modules_) + { + DEBUG(adapterInfo(" - " + module + "\n")); + + // Set the modules switches + if (module == "CHT") + CHTenabled_ = true; + if (module == "FSI") + FSIenabled_ = true; + if (module == "FF") + FFenabled_ = true; + } + + // Every interface is a subdictionary of "interfaces", + // each with an arbitrary name. Read all of them and create + // a list (here: pointer) of dictionaries. + const dictionary* interfaceDictPtr = preciceDict.subDictPtr("interfaces"); // We use this deprecated subDictPtr for backwards compatibility + DEBUG(adapterInfo(" interfaces : ")); - DEBUG(adapterInfo(" readData : ")); - wordList readData = interfaceDict.lookupType("readData"); // We use this deprecated lookupType<>() for backwards compatibility - for (auto readDatum : readData) + // Check if we found any interfaces + // and get the details of each interface + if (!interfaceDictPtr) + { + adapterInfo(" Empty list of interfaces", "warning"); + return false; + } + else + { + for (const entry& interfaceDictEntry : *interfaceDictPtr) + { + if (interfaceDictEntry.isDict()) { - interfaceConfig.readData.push_back(readDatum); - DEBUG(adapterInfo(" - " + readDatum)); + dictionary interfaceDict = interfaceDictEntry.dict(); + struct InterfaceConfig interfaceConfig; + + interfaceConfig.meshName = interfaceDict.lookupType("mesh"); // We use this deprecated lookupType<>() for backwards compatibility + DEBUG(adapterInfo(" - mesh : " + interfaceConfig.meshName)); + + // By default, assume "faceCenters" as locationsType + interfaceConfig.locationsType = interfaceDict.lookupOrDefault("locations", "faceCenters"); + DEBUG(adapterInfo(" locations : " + interfaceConfig.locationsType)); + + // 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") + { + DEBUG(adapterInfo("Mesh connectivity is not supported for faceCenters. \n" + "Please configure the desired interface with the locationsType faceNodes. \n" + "Have a look in the adapter documentation for detailed information.", + "warning")); + return false; + } + DEBUG(adapterInfo(" connectivity : " + std::to_string(interfaceConfig.meshConnectivity))); + + DEBUG(adapterInfo(" patches : ")); + wordList patches = interfaceDict.lookupType("patches"); // We use this deprecated lookupType<>() for backwards compatibility + for (auto patch : patches) + { + interfaceConfig.patchNames.push_back(patch); + DEBUG(adapterInfo(" - " + patch)); + } + + DEBUG(adapterInfo(" writeData : ")); + wordList writeData = interfaceDict.lookupType("writeData"); // We use this deprecated lookupType<>() for backwards compatibility + for (auto writeDatum : writeData) + { + interfaceConfig.writeData.push_back(writeDatum); + DEBUG(adapterInfo(" - " + writeDatum)); + } + + DEBUG(adapterInfo(" readData : ")); + wordList readData = interfaceDict.lookupType("readData"); // We use this deprecated lookupType<>() for backwards compatibility + for (auto readDatum : readData) + { + interfaceConfig.readData.push_back(readDatum); + DEBUG(adapterInfo(" - " + readDatum)); + } + interfacesConfig_.push_back(interfaceConfig); } - interfacesConfig_.push_back(interfaceConfig); } } - } - // NOTE: set the switch for your new module here + // NOTE: set the switch for your new module here - // If the CHT module is enabled, create it, read the - // CHT-specific options and configure it. - if (CHTenabled_) - { - CHT_ = new CHT::ConjugateHeatTransfer(mesh_); - if (!CHT_->configure(preciceDict)) return false; - } + // If the CHT module is enabled, create it, read the + // CHT-specific options and configure it. + if (CHTenabled_) + { + CHT_ = new CHT::ConjugateHeatTransfer(mesh_); + if (!CHT_->configure(preciceDict)) + return false; + } - // If the FSI module is enabled, create it, read the - // FSI-specific options and configure it. - if (FSIenabled_) - { - // Check for unsupported FSI with meshConnectivity - for (uint i = 0; i < interfacesConfig_.size(); i++) + // If the FSI module is enabled, create it, read the + // FSI-specific options and configure it. + if (FSIenabled_) { - if(interfacesConfig_.at(i).meshConnectivity == true ) + // Check for unsupported FSI with meshConnectivity + for (uint i = 0; i < interfacesConfig_.size(); i++) { - adapterInfo( - "Mesh connectivity is not supported for FSI, as, usually, " - "the Solid participant needs to provide the connectivity information. " - "Therefore, set provideMeshConnectivity = false. " - "Have a look in the adapter documentation for more information. " - ,"warning"); - return false; + if (interfacesConfig_.at(i).meshConnectivity == true) + { + adapterInfo( + "Mesh connectivity is not supported for FSI, as, usually, " + "the Solid participant needs to provide the connectivity information. " + "Therefore, set provideMeshConnectivity = false. " + "Have a look in the adapter documentation for more information. ", + "warning"); + return false; + } } + + FSI_ = new FSI::FluidStructureInteraction(mesh_, runTime_); + if (!FSI_->configure(preciceDict)) + return false; } - FSI_ = new FSI::FluidStructureInteraction(mesh_, runTime_); - if (!FSI_->configure(preciceDict)) return false; - } + if (FFenabled_) + { + FF_ = new FF::FluidFluid(mesh_); + if (!FF_->configure(preciceDict)) + return false; + } - if (FFenabled_) - { - FF_ = new FF::FluidFluid(mesh_); - if (!FF_->configure(preciceDict)) return false; - } + // NOTE: Create your module and read any options specific to it here - // NOTE: Create your module and read any options specific to it here + if (!CHTenabled_ && !FSIenabled_ && !FFenabled_) // NOTE: Add your new switch here + { + adapterInfo("No module is enabled.", "error-deferred"); + return false; + } - if (!CHTenabled_ && !FSIenabled_ && !FFenabled_) // NOTE: Add your new switch here - { - adapterInfo("No module is enabled.", "error-deferred"); - return false; + // TODO: Loading modules should be implemented in more general way, + // in order to avoid code duplication. See issue #16 on GitHub. } - - // TODO: Loading modules should be implemented in more general way, - // in order to avoid code duplication. See issue #16 on GitHub. - - } catch (const Foam::error &e) { + catch (const Foam::error& e) + { adapterInfo(e.message(), "error-deferred"); return false; } @@ -209,14 +213,18 @@ void preciceAdapter::Adapter::configure() return; } - try{ + try + { // Check the timestep type (fixed vs adjustable) DEBUG(adapterInfo("Checking the timestep type (fixed vs adjustable)...")); adjustableTimestep_ = runTime_.controlDict().lookupOrDefault("adjustTimeStep", false); - if (adjustableTimestep_) { + if (adjustableTimestep_) + { DEBUG(adapterInfo(" Timestep type: adjustable.")); - } else { + } + else + { DEBUG(adapterInfo(" Timestep type: fixed.")); } @@ -231,7 +239,7 @@ void preciceAdapter::Adapter::configure() DEBUG(adapterInfo("Creating interfaces...")); for (uint i = 0; i < interfacesConfig_.size(); i++) { - Interface * interface = new Interface(*precice_, mesh_, interfacesConfig_.at(i).meshName, interfacesConfig_.at(i).locationsType, interfacesConfig_.at(i).patchNames, interfacesConfig_.at(i).meshConnectivity); + Interface* interface = new Interface(*precice_, mesh_, interfacesConfig_.at(i).meshName, interfacesConfig_.at(i).locationsType, interfacesConfig_.at(i).patchNames, interfacesConfig_.at(i).meshConnectivity); interfaces_.push_back(interface); DEBUG(adapterInfo("Interface created on mesh " + interfacesConfig_.at(i).meshName)); @@ -251,7 +259,7 @@ void preciceAdapter::Adapter::configure() { FSI_->addWriters(dataName, interface); } - + // Add FF-related coupling data writers if (FFenabled_) { @@ -277,7 +285,7 @@ void preciceAdapter::Adapter::configure() { FSI_->addReaders(dataName, interface); } - + // Add FF-related coupling data readers if (FFenabled_) { @@ -328,17 +336,16 @@ void preciceAdapter::Adapter::configure() // This has the side-effect of not triggering the end() method // in any function object normally. Therefore, we trigger it // when preCICE dictates to stop the coupling. - adapterInfo - ( + adapterInfo( "Setting the solver's endTime to infinity to prevent early exits. " "Only preCICE will control the simulation's endTime. " "Any functionObject's end() method will be triggered by the adapter. " "You may disable this behavior in the adapter's configuration.", - "info" - ); + "info"); const_cast(runTime_).setEndTime(GREAT); - - } catch (const Foam::error &e) { + } + catch (const Foam::error& e) + { adapterInfo(e.message(), "error-deferred"); errorsInConfigure = true; } @@ -352,12 +359,10 @@ void preciceAdapter::Adapter::execute() { // Handle any errors during configure(). // See the comments in configure() for details. - adapterInfo - ( + adapterInfo( "There was a problem while configuring the adapter. " "See the log for details.", - "error" - ); + "error"); } // The solver has already solved the equations for this timestep. @@ -406,12 +411,10 @@ void preciceAdapter::Adapter::execute() // (i.e. the solver wrote results that need to be updated) if (runTime_.timePath().type() == fileName::DIRECTORY) { - adapterInfo - ( + adapterInfo( "The coupling timestep completed. " "Writing the updated results.", - "info" - ); + "info"); const_cast(runTime_).writeNow(); } } @@ -429,12 +432,10 @@ void preciceAdapter::Adapter::execute() // Set the solver's endTime to now. The next evaluation of // runTime.run() will be false and the solver will exit. const_cast(runTime_).setEndTime(runTime_.value()); - adapterInfo - ( + adapterInfo( "The simulation was ended by preCICE. " "Calling the end() methods of any functionObject explicitly.", - "info" - ); + "info"); const_cast(runTime_).functionObjects().end(); } @@ -549,16 +550,14 @@ void preciceAdapter::Adapter::adjustSolverTimeStep() // Show a warning if runTimeModifiable is set if (runTime_.runTimeModifiable()) { - adapterInfo - ( + adapterInfo( "You have enabled 'runTimeModifiable' in the " "controlDict. The preciceAdapter does not yet " "fully support this functionality when " "'adjustableTimestep' is not enabled. " "If you modify the 'deltaT' in the controlDict " "during the simulation, it will not be updated.", - "warning" - ); + "warning"); } // Store the value @@ -588,34 +587,26 @@ void preciceAdapter::Adapter::adjustSolverTimeStep() if (timestepSolverDetermined < timestepPrecice_) { // Add a bool 'subCycling = true' which is checked in the storeMeshPoints() function. - adapterInfo - ( + adapterInfo( "The solver's timestep is smaller than the " "coupling timestep. Subcycling...", - "info" - ); + "info"); timestepSolver_ = timestepSolverDetermined; // TODO subcycling is enabled. For FSI the oldVolumes must be written, which is normally not done. if (FSIenabled_) { - adapterInfo - ( + adapterInfo( "The adapter does not fully support subcycling for FSI and instabilities may occur.", - "warning" - ); + "warning"); } } else if (timestepSolverDetermined > timestepPrecice_) { - adapterInfo - ( + adapterInfo( "The solver's timestep cannot be larger than the coupling timestep." - " Adjusting from " + - std::to_string(timestepSolverDetermined) + - " to " + - std::to_string(timestepPrecice_), - "warning" - ); + " Adjusting from " + + std::to_string(timestepSolverDetermined) + " to " + std::to_string(timestepPrecice_), + "warning"); timestepSolver_ = timestepPrecice_; } else @@ -741,9 +732,9 @@ void preciceAdapter::Adapter::reloadMeshPoints() const_cast(mesh_).movePoints(meshPoints_); DEBUG(adapterInfo("Moved mesh points to their previous locations.")); - + // TODO The if statement can be removed in this case, but it is still included for clarity - if ( meshCheckPointed ) + if (meshCheckPointed) { readMeshCheckpoint(); } @@ -769,21 +760,13 @@ void preciceAdapter::Adapter::setupMeshCheckpointing() DEBUG(adapterInfo("Creating a list of the mesh checkpointed fields...")); // Add meshPhi to the checkpointed fields - addMeshCheckpointField - ( - const_cast - ( - mesh_.phi() - ) - ); + addMeshCheckpointField( + const_cast( + mesh_.phi())); #ifdef ADAPTER_DEBUG_MODE - adapterInfo - ( - "Added " + mesh_.phi().name() + - " in the list of checkpointed fields." - ); + adapterInfo( + "Added " + mesh_.phi().name() + " in the list of checkpointed fields."); #endif - } void preciceAdapter::Adapter::setupMeshVolCheckpointing() @@ -791,34 +774,20 @@ void preciceAdapter::Adapter::setupMeshVolCheckpointing() DEBUG(adapterInfo("Creating a list of the mesh volume checkpointed fields...")); // Add the V0 and the V00 to the list of checkpointed fields. // For V0 - addVolCheckpointField - ( - const_cast - ( - mesh_.V0() - ) - ); + addVolCheckpointField( + const_cast( + mesh_.V0())); #ifdef ADAPTER_DEBUG_MODE - adapterInfo - ( - "Added " + mesh_.V0().name() + - " in the list of checkpointed fields." - ); + adapterInfo( + "Added " + mesh_.V0().name() + " in the list of checkpointed fields."); #endif // For V00 - addVolCheckpointField - ( - const_cast - ( - mesh_.V00() - ) - ); + addVolCheckpointField( + const_cast( + mesh_.V00())); #ifdef ADAPTER_DEBUG_MODE - adapterInfo - ( - "Added " + mesh_.V00().name() + - " in the list of checkpointed fields." - ); + adapterInfo( + "Added " + mesh_.V00().name() + " in the list of checkpointed fields."); #endif // Also add the buffer fields. @@ -831,11 +800,8 @@ void preciceAdapter::Adapter::setupMeshVolCheckpointing() ) ); */ #ifdef ADAPTER_DEBUG_MODE - adapterInfo - ( - "Added " + mesh_.V0().name() + - " in the list of buffer checkpointed fields." - ); + adapterInfo( + "Added " + mesh_.V0().name() + " in the list of buffer checkpointed fields."); #endif // TODO For V00 /* addVolCheckpointFieldBuffer @@ -846,11 +812,8 @@ void preciceAdapter::Adapter::setupMeshVolCheckpointing() ) );*/ #ifdef ADAPTER_DEBUG_MODE - adapterInfo - ( - "Added " + mesh_.V00().name() + - " in the list of buffer checkpointed fields." - ); + adapterInfo( + "Added " + mesh_.V00().name() + " in the list of buffer checkpointed fields."); #endif } @@ -873,19 +836,13 @@ void preciceAdapter::Adapter::setupCheckpointing() { if (mesh_.foundObject(objectNames_[i])) { - addCheckpointField - ( - const_cast - ( - mesh_.lookupObject(objectNames_[i]) - ) - ); + addCheckpointField( + const_cast( + mesh_.lookupObject(objectNames_[i]))); #ifdef ADAPTER_DEBUG_MODE - adapterInfo - ( - "Will be checkpointing " + objectNames_[i] - ); + adapterInfo( + "Will be checkpointing " + objectNames_[i]); #endif } else @@ -907,19 +864,13 @@ void preciceAdapter::Adapter::setupCheckpointing() { if (mesh_.foundObject(objectNames_[i])) { - addCheckpointField - ( - const_cast - ( - mesh_.lookupObject(objectNames_[i]) - ) - ); + addCheckpointField( + const_cast( + mesh_.lookupObject(objectNames_[i]))); #ifdef ADAPTER_DEBUG_MODE - adapterInfo - ( - "Will be checkpointing " + objectNames_[i] - ); + adapterInfo( + "Will be checkpointing " + objectNames_[i]); #endif } else @@ -940,19 +891,13 @@ void preciceAdapter::Adapter::setupCheckpointing() { if (mesh_.foundObject(objectNames_[i])) { - addCheckpointField - ( - const_cast - ( - mesh_.lookupObject(objectNames_[i]) - ) - ); + addCheckpointField( + const_cast( + mesh_.lookupObject(objectNames_[i]))); #ifdef ADAPTER_DEBUG_MODE - adapterInfo - ( - "Will be checkpointing " + objectNames_[i] - ); + adapterInfo( + "Will be checkpointing " + objectNames_[i]); #endif } else @@ -974,19 +919,13 @@ void preciceAdapter::Adapter::setupCheckpointing() { if (mesh_.foundObject(objectNames_[i])) { - addCheckpointField - ( - const_cast - ( - mesh_.lookupObject(objectNames_[i]) - ) - ); + addCheckpointField( + const_cast( + mesh_.lookupObject(objectNames_[i]))); #ifdef ADAPTER_DEBUG_MODE - adapterInfo - ( - "Will be checkpointing " + objectNames_[i] - ); + adapterInfo( + "Will be checkpointing " + objectNames_[i]); #endif } else @@ -1008,19 +947,13 @@ void preciceAdapter::Adapter::setupCheckpointing() { if (mesh_.foundObject(objectNames_[i])) { - addCheckpointField - ( - const_cast - ( - mesh_.lookupObject(objectNames_[i]) - ) - ); + addCheckpointField( + const_cast( + mesh_.lookupObject(objectNames_[i]))); #ifdef ADAPTER_DEBUG_MODE - adapterInfo - ( - "Will be checkpointing " + objectNames_[i] - ); + adapterInfo( + "Will be checkpointing " + objectNames_[i]); #endif } else @@ -1042,19 +975,13 @@ void preciceAdapter::Adapter::setupCheckpointing() { if (mesh_.foundObject(objectNames_[i])) { - addCheckpointField - ( - const_cast - ( - mesh_.lookupObject(objectNames_[i]) - ) - ); + addCheckpointField( + const_cast( + mesh_.lookupObject(objectNames_[i]))); #ifdef ADAPTER_DEBUG_MODE - adapterInfo - ( - "Will be checkpointing " + objectNames_[i] - ); + adapterInfo( + "Will be checkpointing " + objectNames_[i]); #endif } else @@ -1064,7 +991,6 @@ void preciceAdapter::Adapter::setupCheckpointing() } - /* Find and add all the registered objects in the mesh_ of type volTensorField */ @@ -1078,19 +1004,13 @@ void preciceAdapter::Adapter::setupCheckpointing() { if (mesh_.foundObject(objectNames_[i])) { - addCheckpointField - ( - const_cast - ( - mesh_.lookupObject(objectNames_[i]) - ) - ); + addCheckpointField( + const_cast( + mesh_.lookupObject(objectNames_[i]))); #ifdef ADAPTER_DEBUG_MODE - adapterInfo - ( - "Will be checkpointing " + objectNames_[i] - ); + adapterInfo( + "Will be checkpointing " + objectNames_[i]); #endif } else @@ -1100,7 +1020,6 @@ void preciceAdapter::Adapter::setupCheckpointing() } - /* Find and add all the registered objects in the mesh_ of type surfaceTensorField */ @@ -1113,19 +1032,13 @@ void preciceAdapter::Adapter::setupCheckpointing() { if (mesh_.foundObject(objectNames_[i])) { - addCheckpointField - ( - const_cast - ( - mesh_.lookupObject(objectNames_[i]) - ) - ); + addCheckpointField( + const_cast( + mesh_.lookupObject(objectNames_[i]))); #ifdef ADAPTER_DEBUG_MODE - adapterInfo - ( - "Will be checkpointing " + objectNames_[i] - ); + adapterInfo( + "Will be checkpointing " + objectNames_[i]); #endif } else @@ -1146,19 +1059,13 @@ void preciceAdapter::Adapter::setupCheckpointing() { if (mesh_.foundObject(objectNames_[i])) { - addCheckpointField - ( - const_cast - ( - mesh_.lookupObject(objectNames_[i]) - ) - ); + addCheckpointField( + const_cast( + mesh_.lookupObject(objectNames_[i]))); #ifdef ADAPTER_DEBUG_MODE - adapterInfo - ( - "Will be checkpointing " + objectNames_[i] - ); + adapterInfo( + "Will be checkpointing " + objectNames_[i]); #endif } else @@ -1181,19 +1088,13 @@ void preciceAdapter::Adapter::setupCheckpointing() { if (mesh_.foundObject(objectNames_[i])) { - addCheckpointField - ( - const_cast - ( - mesh_.lookupObject(objectNames_[i]) - ) - ); + addCheckpointField( + const_cast( + mesh_.lookupObject(objectNames_[i]))); #ifdef ADAPTER_DEBUG_MODE - adapterInfo - ( - "Will be checkpointing " + objectNames_[i] - ); + adapterInfo( + "Will be checkpointing " + objectNames_[i]); #endif } else @@ -1206,83 +1107,83 @@ void preciceAdapter::Adapter::setupCheckpointing() // All mesh checkpointed fields -void preciceAdapter::Adapter::addMeshCheckpointField(surfaceScalarField & field) +void preciceAdapter::Adapter::addMeshCheckpointField(surfaceScalarField& field) { - surfaceScalarField * copy = new surfaceScalarField(field); + surfaceScalarField* copy = new surfaceScalarField(field); meshSurfaceScalarFields_.push_back(&field); meshSurfaceScalarFieldCopies_.push_back(copy); return; } -void preciceAdapter::Adapter::addMeshCheckpointField(surfaceVectorField & field) +void preciceAdapter::Adapter::addMeshCheckpointField(surfaceVectorField& field) { - surfaceVectorField * copy = new surfaceVectorField(field); + surfaceVectorField* copy = new surfaceVectorField(field); meshSurfaceVectorFields_.push_back(&field); meshSurfaceVectorFieldCopies_.push_back(copy); return; } -void preciceAdapter::Adapter::addMeshCheckpointField(volVectorField & field) +void preciceAdapter::Adapter::addMeshCheckpointField(volVectorField& field) { - volVectorField * copy = new volVectorField(field); + volVectorField* copy = new volVectorField(field); meshVolVectorFields_.push_back(&field); meshVolVectorFieldCopies_.push_back(copy); return; } // TODO Internal field for the V0 (volume old) and V00 (volume old-old) fields -void preciceAdapter::Adapter::addVolCheckpointField(volScalarField::Internal & field) +void preciceAdapter::Adapter::addVolCheckpointField(volScalarField::Internal& field) { - volScalarField::Internal * copy = new volScalarField::Internal(field); + volScalarField::Internal* copy = new volScalarField::Internal(field); volScalarInternalFields_.push_back(&field); volScalarInternalFieldCopies_.push_back(copy); return; } // All checkpointed fields -void preciceAdapter::Adapter::addCheckpointField(volScalarField & field) +void preciceAdapter::Adapter::addCheckpointField(volScalarField& field) { - volScalarField * copy = new volScalarField(field); + volScalarField* copy = new volScalarField(field); volScalarFields_.push_back(&field); volScalarFieldCopies_.push_back(copy); return; } -void preciceAdapter::Adapter::addCheckpointField(volVectorField & field) +void preciceAdapter::Adapter::addCheckpointField(volVectorField& field) { - volVectorField * copy = new volVectorField(field); + volVectorField* copy = new volVectorField(field); volVectorFields_.push_back(&field); volVectorFieldCopies_.push_back(copy); return; } -void preciceAdapter::Adapter::addCheckpointField(surfaceScalarField & field) +void preciceAdapter::Adapter::addCheckpointField(surfaceScalarField& field) { - surfaceScalarField * copy = new surfaceScalarField(field); + surfaceScalarField* copy = new surfaceScalarField(field); surfaceScalarFields_.push_back(&field); surfaceScalarFieldCopies_.push_back(copy); return; } -void preciceAdapter::Adapter::addCheckpointField(surfaceVectorField & field) +void preciceAdapter::Adapter::addCheckpointField(surfaceVectorField& field) { - surfaceVectorField * copy = new surfaceVectorField(field); + surfaceVectorField* copy = new surfaceVectorField(field); surfaceVectorFields_.push_back(&field); surfaceVectorFieldCopies_.push_back(copy); return; } -void preciceAdapter::Adapter::addCheckpointField(pointScalarField & field) +void preciceAdapter::Adapter::addCheckpointField(pointScalarField& field) { - pointScalarField * copy = new pointScalarField(field); + pointScalarField* copy = new pointScalarField(field); pointScalarFields_.push_back(&field); pointScalarFieldCopies_.push_back(copy); return; } -void preciceAdapter::Adapter::addCheckpointField(pointVectorField & field) +void preciceAdapter::Adapter::addCheckpointField(pointVectorField& field) { - pointVectorField * copy = new pointVectorField(field); + pointVectorField* copy = new pointVectorField(field); pointVectorFields_.push_back(&field); pointVectorFieldCopies_.push_back(copy); // TODO: Old time @@ -1292,33 +1193,33 @@ void preciceAdapter::Adapter::addCheckpointField(pointVectorField & field) return; } -void preciceAdapter::Adapter::addCheckpointField(volTensorField & field) +void preciceAdapter::Adapter::addCheckpointField(volTensorField& field) { - volTensorField * copy = new volTensorField(field); + volTensorField* copy = new volTensorField(field); volTensorFields_.push_back(&field); volTensorFieldCopies_.push_back(copy); return; } -void preciceAdapter::Adapter::addCheckpointField(surfaceTensorField & field) +void preciceAdapter::Adapter::addCheckpointField(surfaceTensorField& field) { - surfaceTensorField * copy = new surfaceTensorField(field); + surfaceTensorField* copy = new surfaceTensorField(field); surfaceTensorFields_.push_back(&field); surfaceTensorFieldCopies_.push_back(copy); return; } -void preciceAdapter::Adapter::addCheckpointField(pointTensorField & field) +void preciceAdapter::Adapter::addCheckpointField(pointTensorField& field) { - pointTensorField * copy = new pointTensorField(field); + pointTensorField* copy = new pointTensorField(field); pointTensorFields_.push_back(&field); pointTensorFieldCopies_.push_back(copy); return; } -void preciceAdapter::Adapter::addCheckpointField(volSymmTensorField & field) +void preciceAdapter::Adapter::addCheckpointField(volSymmTensorField& field) { - volSymmTensorField * copy = new volSymmTensorField(field); + volSymmTensorField* copy = new volSymmTensorField(field); volSymmTensorFields_.push_back(&field); volSymmTensorFieldCopies_.push_back(copy); return; @@ -1514,10 +1415,8 @@ void preciceAdapter::Adapter::readCheckpoint() // NOTE: Add here other field types to read, if needed. #ifdef ADAPTER_DEBUG_MODE - adapterInfo - ( - "Checkpoint was read. Time = " + std::to_string(runTime_.value()) - ); + adapterInfo( + "Checkpoint was read. Time = " + std::to_string(runTime_.value())); #endif return; @@ -1599,11 +1498,8 @@ void preciceAdapter::Adapter::writeCheckpoint() // NOTE: Add here other types to write, if needed. #ifdef ADAPTER_DEBUG_MODE - adapterInfo - ( - "Checkpoint for time t = " + std::to_string(runTime_.value()) + - " was stored." - ); + adapterInfo( + "Checkpoint for time t = " + std::to_string(runTime_.value()) + " was stored."); #endif return; @@ -1664,12 +1560,10 @@ void preciceAdapter::Adapter::readMeshCheckpoint() meshVolVectorFields_.at(i)->oldTime().oldTime() == meshVolVectorFieldCopies_.at(i)->oldTime().oldTime(); } } - + #ifdef ADAPTER_DEBUG_MODE - adapterInfo - ( - "Mesh checkpoint was read. Time = " + std::to_string(runTime_.value()) - ); + adapterInfo( + "Mesh checkpoint was read. Time = " + std::to_string(runTime_.value())); #endif return; @@ -1698,17 +1592,14 @@ void preciceAdapter::Adapter::writeMeshCheckpoint() } #ifdef ADAPTER_DEBUG_MODE - adapterInfo - ( - "Mesh checkpoint for time t = " + std::to_string(runTime_.value()) + - " was stored." - ); + adapterInfo( + "Mesh checkpoint for time t = " + std::to_string(runTime_.value()) + " was stored."); #endif return; } -// TODO for the volumes of the mesh, check this part for subcycling. +// TODO for the volumes of the mesh, check this part for subcycling. void preciceAdapter::Adapter::readVolCheckpoint() { DEBUG(adapterInfo("Reading the mesh volumes checkpoint...")); @@ -1722,10 +1613,8 @@ void preciceAdapter::Adapter::readVolCheckpoint() } #ifdef ADAPTER_DEBUG_MODE - adapterInfo - ( - "Mesh volumes were read. Time = " + std::to_string(runTime_.value()) - ); + adapterInfo( + "Mesh volumes were read. Time = " + std::to_string(runTime_.value())); #endif return; @@ -1742,11 +1631,8 @@ void preciceAdapter::Adapter::writeVolCheckpoint() } #ifdef ADAPTER_DEBUG_MODE - adapterInfo - ( - "Mesh volumes checkpoint for time t = " + std::to_string(runTime_.value()) + - " was stored." - ); + adapterInfo( + "Mesh volumes checkpoint for time t = " + std::to_string(runTime_.value()) + " was stored."); #endif return; @@ -1893,7 +1779,7 @@ void preciceAdapter::Adapter::teardown() } // Delete the CHT module - if(NULL != CHT_) + if (NULL != CHT_) { DEBUG(adapterInfo("Destroying the CHT module...")); delete CHT_; @@ -1901,7 +1787,7 @@ void preciceAdapter::Adapter::teardown() } // Delete the FSI module - if(NULL != FSI_) + if (NULL != FSI_) { DEBUG(adapterInfo("Destroying the FSI module...")); delete FSI_; @@ -1909,7 +1795,7 @@ void preciceAdapter::Adapter::teardown() } // Delete the FF module - if(NULL != FF_) + if (NULL != FF_) { DEBUG(adapterInfo("Destroying the FF module...")); delete FF_; diff --git a/Adapter.H b/Adapter.H index ee3dc9e7..ef46ac48 100644 --- a/Adapter.H +++ b/Adapter.H @@ -31,7 +31,6 @@ class Adapter { private: - //- Structure of the configuration of each coupling interface. // Every interface needs to know the coupling mesh, the OpenFOAM // patches that consist the coupling surface and the kinds @@ -57,342 +56,340 @@ private: // Configuration parameters used in the Adapter - //- Remember if there were errors in the read() method - bool errorsInConfigure = false; + //- Remember if there were errors in the read() method + bool errorsInConfigure = false; - //- preCICE configuration file name - Foam::word preciceConfigFilename_; + //- preCICE configuration file name + Foam::word preciceConfigFilename_; - //- preCICE participant name - Foam::word participantName_; + //- preCICE participant name + Foam::word participantName_; - //- Switch for checkpointing - bool checkpointing_ = false; + //- Switch for checkpointing + bool checkpointing_ = false; - //- Type of timestep (fixed, adjustable) - bool adjustableTimestep_; + //- Type of timestep (fixed, adjustable) + bool adjustableTimestep_; - //- Should the (fixed) timestep be stored and used? - bool useStoredTimestep_ = false; + //- Should the (fixed) timestep be stored and used? + bool useStoredTimestep_ = false; - //- Switch to enable the ConjugateHeatTransfer module - bool CHTenabled_ = false; + //- Switch to enable the ConjugateHeatTransfer module + bool CHTenabled_ = false; - //- Switch to enable the FluidStructureInteraction module - bool FSIenabled_ = false; + //- Switch to enable the FluidStructureInteraction module + bool FSIenabled_ = false; - //- Switch to enable the FluidFluid module - bool FFenabled_ = false; + //- Switch to enable the FluidFluid module + bool FFenabled_ = false; - // NOTE: Add a switch for your new module here + // NOTE: Add a switch for your new module here //- Interfaces std::vector interfaces_; //- preCICE solver interface - precice::SolverInterface * precice_ = NULL; + precice::SolverInterface* precice_ = NULL; //- preCICE solver interface initialized bool preciceInitialized_ = false; //- Conjugate Heat Transfer module object - CHT::ConjugateHeatTransfer * CHT_ = NULL; + CHT::ConjugateHeatTransfer* CHT_ = NULL; //- Fluid-Structure Interaction module object - FSI::FluidStructureInteraction * FSI_ = NULL; + FSI::FluidStructureInteraction* FSI_ = NULL; //- Fluid-Fluid module object - FF::FluidFluid * FF_ = NULL; + FF::FluidFluid* FF_ = NULL; // NOTE: Add here a pointer for your new module object // Timesteps - //- Timestep dictated by preCICE - double timestepPrecice_; + //- Timestep dictated by preCICE + double timestepPrecice_; - //- Timestep used by the solver - double timestepSolver_; + //- Timestep used by the solver + double timestepSolver_; - //- Stored (fixed) timestep - double timestepStored_; + //- Stored (fixed) timestep + double timestepStored_; // Checkpointing - //- Checkpointed time (value) - Foam::scalar couplingIterationTimeValue_; + //- Checkpointed time (value) + Foam::scalar couplingIterationTimeValue_; - //- Checkpointed time (index) - Foam::label couplingIterationTimeIndex_; + //- Checkpointed time (index) + Foam::label couplingIterationTimeIndex_; - //- Checkpointed mesh points - Foam::pointField meshPoints_; - Foam::pointField oldMeshPoints_; - bool meshCheckPointed = false; + //- Checkpointed mesh points + Foam::pointField meshPoints_; + Foam::pointField oldMeshPoints_; + bool meshCheckPointed = false; - // TODO: Currently unused, see storeMeshPoints(). - //- Checkpointed mesh volume - // bool oldVolsStored = false; - // Foam::volScalarField::Internal * oldVols_; - // Foam::volScalarField::Internal * oldOldVols_; - // int curTimeIndex_ = 0; + // TODO: Currently unused, see storeMeshPoints(). + //- Checkpointed mesh volume + // bool oldVolsStored = false; + // Foam::volScalarField::Internal * oldVols_; + // Foam::volScalarField::Internal * oldOldVols_; + // int curTimeIndex_ = 0; - // Vectors of pointers to the checkpointed mesh fields and their copies + // Vectors of pointers to the checkpointed mesh fields and their copies - //- Checkpointed surfaceScalarField mesh fields - std::vector meshSurfaceScalarFields_; + //- Checkpointed surfaceScalarField mesh fields + std::vector meshSurfaceScalarFields_; - //- Checkpointed surfaceScalarField mesh fields (copies) - std::vector meshSurfaceScalarFieldCopies_; + //- Checkpointed surfaceScalarField mesh fields (copies) + std::vector meshSurfaceScalarFieldCopies_; - //- Checkpointed surfaceVectorField mesh fields - std::vector meshSurfaceVectorFields_; + //- Checkpointed surfaceVectorField mesh fields + std::vector meshSurfaceVectorFields_; - //- Checkpointed surfaceVectorField mesh fields (copies) - std::vector meshSurfaceVectorFieldCopies_; + //- Checkpointed surfaceVectorField mesh fields (copies) + std::vector meshSurfaceVectorFieldCopies_; - //- Checkpointed volVectorField mesh fields - std::vector meshVolVectorFields_; + //- Checkpointed volVectorField mesh fields + std::vector meshVolVectorFields_; - //- Checkpointed volVectorField mesh fields (copies) - std::vector meshVolVectorFieldCopies_; + //- Checkpointed volVectorField mesh fields (copies) + std::vector meshVolVectorFieldCopies_; - // TODO checkpoint for the V0 (Old volume) and V00 (Old-Old volume) fields. - //- Checkpointed volScalarField mesh fields - std::vector volScalarInternalFields_; + // TODO checkpoint for the V0 (Old volume) and V00 (Old-Old volume) fields. + //- Checkpointed volScalarField mesh fields + std::vector volScalarInternalFields_; - //- Checkpointed volScalarField mesh fields (copies) - std::vector volScalarInternalFieldCopies_; + //- Checkpointed volScalarField mesh fields (copies) + std::vector volScalarInternalFieldCopies_; - // Vectors of pointers to the checkpointed fields and their copies + // Vectors of pointers to the checkpointed fields and their copies - //- Checkpointed volScalarField fields - std::vector volScalarFields_; + //- Checkpointed volScalarField fields + std::vector volScalarFields_; - //- Checkpointed volScalarField fields (copies) - std::vector volScalarFieldCopies_; + //- Checkpointed volScalarField fields (copies) + std::vector volScalarFieldCopies_; - //- Checkpointed volVectorField fields - std::vector volVectorFields_; + //- Checkpointed volVectorField fields + std::vector volVectorFields_; - //- Checkpointed volVectorField fields (copies) - std::vector volVectorFieldCopies_; + //- Checkpointed volVectorField fields (copies) + std::vector volVectorFieldCopies_; - //- Checkpointed surfaceScalarField fields - std::vector surfaceScalarFields_; + //- Checkpointed surfaceScalarField fields + std::vector surfaceScalarFields_; - //- Checkpointed surfaceScalarField fields (copies) - std::vector surfaceScalarFieldCopies_; + //- Checkpointed surfaceScalarField fields (copies) + std::vector surfaceScalarFieldCopies_; - //- Checkpointed surfaceVectorField fields - std::vector surfaceVectorFields_; + //- Checkpointed surfaceVectorField fields + std::vector surfaceVectorFields_; - //- Checkpointed surfaceVectorField fields (copies) - std::vector surfaceVectorFieldCopies_; + //- Checkpointed surfaceVectorField fields (copies) + std::vector surfaceVectorFieldCopies_; - //- Checkpointed pointScalarField fields - std::vector pointScalarFields_; + //- Checkpointed pointScalarField fields + std::vector pointScalarFields_; - //- Checkpointed pointScalarField fields (copies) - std::vector pointScalarFieldCopies_; + //- Checkpointed pointScalarField fields (copies) + std::vector pointScalarFieldCopies_; - //- Checkpointed pointVectorField fields - std::vector pointVectorFields_; + //- Checkpointed pointVectorField fields + std::vector pointVectorFields_; - //- Checkpointed pointVectorField fields (copies) - std::vector pointVectorFieldCopies_; + //- Checkpointed pointVectorField fields (copies) + std::vector pointVectorFieldCopies_; - //- Checkpointed volTensorField fields - std::vector volTensorFields_; + //- Checkpointed volTensorField fields + std::vector volTensorFields_; - //- Checkpointed volTensorField fields (copies) - std::vector volTensorFieldCopies_; + //- Checkpointed volTensorField fields (copies) + std::vector volTensorFieldCopies_; - //- Checkpointed surfaceTensorField fields - std::vector surfaceTensorFields_; + //- Checkpointed surfaceTensorField fields + std::vector surfaceTensorFields_; - //- Checkpointed surfaceTensorField fields (copies) - std::vector surfaceTensorFieldCopies_; + //- Checkpointed surfaceTensorField fields (copies) + std::vector surfaceTensorFieldCopies_; - //- Checkpointed pointTensorField fields - std::vector pointTensorFields_; + //- Checkpointed pointTensorField fields + std::vector pointTensorFields_; - //- Checkpointed pointTensorField fields (copies) - std::vector pointTensorFieldCopies_; + //- Checkpointed pointTensorField fields (copies) + std::vector pointTensorFieldCopies_; - //- Checkpointed volSymmTensorField fields - std::vector volSymmTensorFields_; + //- Checkpointed volSymmTensorField fields + std::vector volSymmTensorFields_; - //- Checkpointed volSymmTensorField fields (copies) - std::vector volSymmTensorFieldCopies_; + //- Checkpointed volSymmTensorField fields (copies) + std::vector volSymmTensorFieldCopies_; - // NOTE: Declare additional vectors for any other types required. + // NOTE: Declare additional vectors for any other types required. // Configuration - //- Read the adapter's configuration file - bool configFileRead(); + //- Read the adapter's configuration file + bool configFileRead(); - //- Check the adapter's configuration file - bool configFileCheck(const std::string adapterConfigFileName); + //- Check the adapter's configuration file + bool configFileCheck(const std::string adapterConfigFileName); // Methods communicating with preCICE - //- Initialize preCICE and exchange the first data - void initialize(); + //- Initialize preCICE and exchange the first data + void initialize(); - //- Finalize and destroy preCICE - void finalize(); + //- Finalize and destroy preCICE + void finalize(); - //- Advance preCICE - void advance(); + //- Advance preCICE + void advance(); - //- Read the coupling data at each interface - void readCouplingData(); + //- Read the coupling data at each interface + void readCouplingData(); - //- Write the coupling data at each interface - void writeCouplingData(); + //- Write the coupling data at each interface + void writeCouplingData(); - //- Adjust the timestep of the solver according to preCICE - void adjustSolverTimeStep(); + //- Adjust the timestep of the solver according to preCICE + void adjustSolverTimeStep(); - //- Determine if the coupling is still happening - bool isCouplingOngoing(); + //- Determine if the coupling is still happening + bool isCouplingOngoing(); - //- Determine if the coupling timestep has been completed - bool isCouplingTimeWindowComplete(); + //- Determine if the coupling timestep has been completed + bool isCouplingTimeWindowComplete(); - //- Determine if a checkpoint must be read - bool isReadCheckpointRequired(); + //- Determine if a checkpoint must be read + bool isReadCheckpointRequired(); - //- Determine if a checkpoint must be written - bool isWriteCheckpointRequired(); + //- 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 read + void fulfilledReadCheckpoint(); - //- Tell preCICE that the checkpoint has been written - void fulfilledWriteCheckpoint(); + //- Tell preCICE that the checkpoint has been written + void fulfilledWriteCheckpoint(); // Methods for checkpointing - //- Configure the mesh checkpointing - void setupMeshCheckpointing(); + //- Configure the mesh checkpointing + void setupMeshCheckpointing(); - //- Configure the mesh checkpointing - void setupMeshVolCheckpointing(); + //- Configure the mesh checkpointing + void setupMeshVolCheckpointing(); - //- Configure the checkpointing - void setupCheckpointing(); + //- Configure the checkpointing + void setupCheckpointing(); - //- Make a copy of the runTime object - void storeCheckpointTime(); + //- Make a copy of the runTime object + void storeCheckpointTime(); - //- Restore the copy of the runTime object - void reloadCheckpointTime(); + //- Restore the copy of the runTime object + void reloadCheckpointTime(); - //- Store the locations of the mesh points - void storeMeshPoints(); + //- Store the locations of the mesh points + void storeMeshPoints(); - //- Restore the locations of the mesh points - void reloadMeshPoints(); + //- Restore the locations of the mesh points + void reloadMeshPoints(); - // Add mesh checkpoint fields, depending on the type - //- Add a surfaceScalarField mesh field - void addMeshCheckpointField(surfaceScalarField & field); + // Add mesh checkpoint fields, depending on the type + //- Add a surfaceScalarField mesh field + void addMeshCheckpointField(surfaceScalarField& field); - //- Add a surfaceVectorField mesh field - void addMeshCheckpointField(surfaceVectorField & field); + //- Add a surfaceVectorField mesh field + void addMeshCheckpointField(surfaceVectorField& field); - //- Add a volVectorField mesh field - void addMeshCheckpointField(volVectorField & field); + //- Add a volVectorField mesh field + void addMeshCheckpointField(volVectorField& field); - // TODO V0 and V00 checkpointed field. - //- Add the V0 and V00 checkpoint fields - void addVolCheckpointField(volScalarField::Internal & field); - // void addVolCheckpointFieldBuffer(volScalarField::Internal & field); + // TODO V0 and V00 checkpointed field. + //- Add the V0 and V00 checkpoint fields + void addVolCheckpointField(volScalarField::Internal& field); + // void addVolCheckpointFieldBuffer(volScalarField::Internal & field); - // Add checkpoint fields, depending on the type + // Add checkpoint fields, depending on the type - //- Add a volScalarField to checkpoint - void addCheckpointField(volScalarField & field); + //- Add a volScalarField to checkpoint + void addCheckpointField(volScalarField& field); - //- Add a volVectorField to checkpoint - void addCheckpointField(volVectorField & field); + //- Add a volVectorField to checkpoint + void addCheckpointField(volVectorField& field); - //- Add a surfaceScalarField to checkpoint - void addCheckpointField(surfaceScalarField & field); + //- Add a surfaceScalarField to checkpoint + void addCheckpointField(surfaceScalarField& field); - //- Add a surfaceVectorField to checkpoint - void addCheckpointField(surfaceVectorField & field); + //- Add a surfaceVectorField to checkpoint + void addCheckpointField(surfaceVectorField& field); - //- Add a pointScalarField to checkpoint - void addCheckpointField(pointScalarField & field); + //- Add a pointScalarField to checkpoint + void addCheckpointField(pointScalarField& field); - //- Add a pointVectorField to checkpoint - void addCheckpointField(pointVectorField & field); + //- Add a pointVectorField to checkpoint + void addCheckpointField(pointVectorField& field); - // NOTE: Add here methods to add other object types to checkpoint, - // if needed. + // NOTE: Add here methods to add other object types to checkpoint, + // if needed. - //- Add a volTensorField to checkpoint - void addCheckpointField(volTensorField & field); + //- Add a volTensorField to checkpoint + void addCheckpointField(volTensorField& field); - //- Add a surfaceTensorField to checkpoint - void addCheckpointField(surfaceTensorField & field); + //- Add a surfaceTensorField to checkpoint + void addCheckpointField(surfaceTensorField& field); - //- Add a pointTensorField to checkpoint - void addCheckpointField(pointTensorField & field); + //- Add a pointTensorField to checkpoint + void addCheckpointField(pointTensorField& field); - //- Add a volSymmTensorField to checkpoint - void addCheckpointField(volSymmTensorField & field); + //- Add a volSymmTensorField to checkpoint + void addCheckpointField(volSymmTensorField& field); - //- Read the checkpoint - restore the mesh fields and time - void readMeshCheckpoint(); + //- Read the checkpoint - restore the mesh fields and time + void readMeshCheckpoint(); - //- Read the checkpoint - restore the fields and time - void readCheckpoint(); + //- Read the checkpoint - restore the fields and time + void readCheckpoint(); - //- Write the checkpoint - store the mesh fields and time - void writeMeshCheckpoint(); + //- Write the checkpoint - store the mesh fields and time + void writeMeshCheckpoint(); - //- Write the checkpoint - store the fields and time - void writeCheckpoint(); + //- Write the checkpoint - store the fields and time + void writeCheckpoint(); - // TODO Probably these can be included to the mesh checkpoints. - //- Read the volume checkpoint - restore the mesh volume fields - void readVolCheckpoint(); + // TODO Probably these can be included to the mesh checkpoints. + //- Read the volume checkpoint - restore the mesh volume fields + void readVolCheckpoint(); - //- Write the volume checkpoint to a buffer - restore the mesh volume fields - void writeVolCheckpoint(); + //- Write the volume checkpoint to a buffer - restore the mesh volume fields + void writeVolCheckpoint(); //- Destroy the preCICE interface and delete the allocated // memory in a proper way. Called by the destructor. void teardown(); public: - // Methods called by the functionObject - //- Constructor - Adapter(const Foam::Time& runTime, const Foam::fvMesh& mesh); - - //- Setup the adapter's configuration - void configure(); + //- Constructor + Adapter(const Foam::Time& runTime, const Foam::fvMesh& mesh); - //- Called by the functionObject's execute() - void execute(); + //- Setup the adapter's configuration + void configure(); - //- Called by the functionObject's adjustTimeStep() - void adjustTimeStep(); + //- Called by the functionObject's execute() + void execute(); - //- Called by the functionObject's end() - void end(); + //- Called by the functionObject's adjustTimeStep() + void adjustTimeStep(); - //- Destructor - ~Adapter(); + //- Called by the functionObject's end() + void end(); + //- Destructor + ~Adapter(); }; } diff --git a/CHT/CHT.C b/CHT/CHT.C index e724e8ed..a44b1700 100644 --- a/CHT/CHT.C +++ b/CHT/CHT.C @@ -4,13 +4,11 @@ using namespace Foam; -preciceAdapter::CHT::ConjugateHeatTransfer::ConjugateHeatTransfer -( - const Foam::fvMesh& mesh -) -: -mesh_(mesh) -{} +preciceAdapter::CHT::ConjugateHeatTransfer::ConjugateHeatTransfer( + const Foam::fvMesh& mesh) +: mesh_(mesh) +{ +} bool preciceAdapter::CHT::ConjugateHeatTransfer::configure(const IOdictionary& adapterConfig) { @@ -24,10 +22,7 @@ bool preciceAdapter::CHT::ConjugateHeatTransfer::configure(const IOdictionary& a // addWriters() and addReaders(). // Check the solver type and determine it if needed if ( - solverType_.compare("compressible") == 0 || - solverType_.compare("incompressible") == 0 || - solverType_.compare("basic") == 0 - ) + solverType_.compare("compressible") == 0 || solverType_.compare("incompressible") == 0 || solverType_.compare("basic") == 0) { DEBUG(adapterInfo("Known solver type: " + solverType_)); } @@ -70,7 +65,7 @@ bool preciceAdapter::CHT::ConjugateHeatTransfer::readConfig(const IOdictionary& DEBUG(adapterInfo(" heat capacity name for incompressible solvers : " + nameCp_)); // Read the name of the Prandtl number parameter for incompressible solvers (if different) - namePr_ = CHTdict.lookupOrDefault("namePr","Pr"); + namePr_ = CHTdict.lookupOrDefault("namePr", "Pr"); DEBUG(adapterInfo(" Prandtl number name for incompressible solvers : " + namePr_)); // Read the name of the turbulent thermal diffusivity field for incompressible solvers (if different) @@ -92,120 +87,104 @@ std::string preciceAdapter::CHT::ConjugateHeatTransfer::determineSolverType() if (mesh_.foundObject("p")) { - volScalarField p_ = mesh_.lookupObject("p"); + volScalarField p_ = mesh_.lookupObject("p"); - if (p_.dimensions() == pressureDimensionsCompressible) - solverType = "compressible"; - else if (p_.dimensions() == pressureDimensionsIncompressible) - solverType = "incompressible"; + if (p_.dimensions() == pressureDimensionsCompressible) + solverType = "compressible"; + else if (p_.dimensions() == pressureDimensionsIncompressible) + solverType = "incompressible"; } if (solverType == "unknown") - adapterInfo("Failed to determine the solver type. " - "Please specify your solver type in the CHT section of the " - "preciceDict. Known solver types for CHT are: " - "basic, incompressible and " - "compressible", - "error"); + adapterInfo("Failed to determine the solver type. " + "Please specify your solver type in the CHT section of the " + "preciceDict. Known solver types for CHT are: " + "basic, incompressible and " + "compressible", + "error"); DEBUG(adapterInfo("Automatically determined solver type : " + solverType)); return solverType; } -void preciceAdapter::CHT::ConjugateHeatTransfer::addWriters(std::string dataName, Interface * interface) +void preciceAdapter::CHT::ConjugateHeatTransfer::addWriters(std::string dataName, Interface* interface) { if (dataName.find("Sink-Temperature") == 0) { - interface->addCouplingDataWriter - ( + interface->addCouplingDataWriter( dataName, - new SinkTemperature(mesh_, nameT_) - ); + new SinkTemperature(mesh_, nameT_)); DEBUG(adapterInfo("Added writer: Sink Temperature.")); } else if (dataName.find("Temperature") == 0) { - interface->addCouplingDataWriter - ( + interface->addCouplingDataWriter( dataName, - new Temperature(mesh_, nameT_) - ); + new Temperature(mesh_, nameT_)); DEBUG(adapterInfo("Added writer: Temperature.")); } else if (dataName.find("Heat-Flux") == 0) { if (solverType_.compare("compressible") == 0) { - interface->addCouplingDataWriter - ( + interface->addCouplingDataWriter( dataName, - new HeatFlux_Compressible(mesh_, nameT_) - ); + new HeatFlux_Compressible(mesh_, nameT_)); DEBUG(adapterInfo("Added writer: Heat Flux for compressible solvers.")); } else if (solverType_.compare("incompressible") == 0) { - interface->addCouplingDataWriter - ( + interface->addCouplingDataWriter( dataName, - new HeatFlux_Incompressible(mesh_, nameT_, nameRho_, nameCp_, namePr_, nameAlphat_) - ); + new HeatFlux_Incompressible(mesh_, nameT_, nameRho_, nameCp_, namePr_, nameAlphat_)); DEBUG(adapterInfo("Added writer: Heat Flux for incompressible solvers. ")); } else if (solverType_.compare("basic") == 0) { - interface->addCouplingDataWriter - ( + interface->addCouplingDataWriter( dataName, - new HeatFlux_Basic(mesh_, nameT_, nameKappa_) - ); + new HeatFlux_Basic(mesh_, nameT_, nameKappa_)); DEBUG(adapterInfo("Added writer: Heat Flux for basic solvers. ")); } else { adapterInfo("Unknown solver type - cannot add heat flux.", - "error"); + "error"); } } else if (dataName.find("Heat-Transfer-Coefficient") == 0) { if (solverType_.compare("compressible") == 0) { - interface->addCouplingDataWriter - ( + interface->addCouplingDataWriter( dataName, - new HeatTransferCoefficient_Compressible(mesh_, nameT_) - ); + new HeatTransferCoefficient_Compressible(mesh_, nameT_)); DEBUG(adapterInfo("Added writer: Heat Transfer Coefficient for compressible solvers.")); } else if (solverType_.compare("incompressible") == 0) { - interface->addCouplingDataWriter - ( + interface->addCouplingDataWriter( dataName, - new HeatTransferCoefficient_Incompressible(mesh_, nameT_, nameRho_, nameCp_, namePr_, nameAlphat_) - ); + new HeatTransferCoefficient_Incompressible(mesh_, nameT_, nameRho_, nameCp_, namePr_, nameAlphat_)); DEBUG(adapterInfo("Added writer: Heat Transfer Coefficient for incompressible solvers. ")); } else if (solverType_.compare("basic") == 0) { - interface->addCouplingDataWriter - ( + interface->addCouplingDataWriter( dataName, - new HeatTransferCoefficient_Basic(mesh_, nameT_, nameKappa_) - ); + new HeatTransferCoefficient_Basic(mesh_, nameT_, nameKappa_)); DEBUG(adapterInfo("Added writer: Heat Transfer Coefficient for basic solvers. ")); } else { adapterInfo("Unknown solver type - cannot add heat transfer coefficient.", - "error"); + "error"); } } else { - adapterInfo("Unknown data type - cannot add " + dataName +".", "error"); + adapterInfo("Unknown data type - cannot add " + dataName + ".", "error"); } // NOTE: If you want to couple another variable, you need @@ -215,99 +194,83 @@ void preciceAdapter::CHT::ConjugateHeatTransfer::addWriters(std::string dataName // the one provided in the adapter's configuration file. } -void preciceAdapter::CHT::ConjugateHeatTransfer::addReaders(std::string dataName, Interface * interface) +void preciceAdapter::CHT::ConjugateHeatTransfer::addReaders(std::string dataName, Interface* interface) { if (dataName.find("Sink-Temperature") == 0) { - interface->addCouplingDataReader - ( + interface->addCouplingDataReader( dataName, - new SinkTemperature(mesh_, nameT_) - ); + new SinkTemperature(mesh_, nameT_)); DEBUG(adapterInfo("Added reader: Sink Temperature.")); } else if (dataName.find("Temperature") == 0) { - interface->addCouplingDataReader - ( + interface->addCouplingDataReader( dataName, - new Temperature(mesh_, nameT_) - ); + new Temperature(mesh_, nameT_)); DEBUG(adapterInfo("Added reader: Temperature.")); } else if (dataName.find("Heat-Flux") == 0) { if (solverType_.compare("compressible") == 0) { - interface->addCouplingDataReader - ( + interface->addCouplingDataReader( dataName, - new HeatFlux_Compressible(mesh_, nameT_) - ); + new HeatFlux_Compressible(mesh_, nameT_)); DEBUG(adapterInfo("Added reader: Heat Flux for compressible solvers.")); } else if (solverType_.compare("incompressible") == 0) { - interface->addCouplingDataReader - ( + interface->addCouplingDataReader( dataName, - new HeatFlux_Incompressible(mesh_, nameT_, nameRho_, nameCp_, namePr_, nameAlphat_) - ); + new HeatFlux_Incompressible(mesh_, nameT_, nameRho_, nameCp_, namePr_, nameAlphat_)); DEBUG(adapterInfo("Added reader: Heat Flux for incompressible solvers. ")); } else if (solverType_.compare("basic") == 0) { - interface->addCouplingDataReader - ( + interface->addCouplingDataReader( dataName, - new HeatFlux_Basic(mesh_, nameT_, nameKappa_) - ); + new HeatFlux_Basic(mesh_, nameT_, nameKappa_)); DEBUG(adapterInfo("Added reader: Heat Flux for basic solvers. ")); } else { adapterInfo("Unknown solver type - cannot add heat flux.", - "error"); + "error"); } } else if (dataName.find("Heat-Transfer-Coefficient") == 0) { if (solverType_.compare("compressible") == 0) { - interface->addCouplingDataReader - ( + interface->addCouplingDataReader( dataName, - new HeatTransferCoefficient_Compressible(mesh_, nameT_) - ); + new HeatTransferCoefficient_Compressible(mesh_, nameT_)); DEBUG(adapterInfo("Added reader: Heat Transfer Coefficient for compressible solvers.")); } else if (solverType_.compare("incompressible") == 0) { - interface->addCouplingDataReader - ( + interface->addCouplingDataReader( dataName, - new HeatTransferCoefficient_Incompressible(mesh_, nameT_, nameRho_, nameCp_, namePr_, nameAlphat_) - ); + new HeatTransferCoefficient_Incompressible(mesh_, nameT_, nameRho_, nameCp_, namePr_, nameAlphat_)); DEBUG(adapterInfo("Added reader: Heat Transfer Coefficient for incompressible solvers. ")); } else if (solverType_.compare("basic") == 0) { - interface->addCouplingDataReader - ( + interface->addCouplingDataReader( dataName, - new HeatTransferCoefficient_Basic(mesh_, nameT_, nameKappa_) - ); + new HeatTransferCoefficient_Basic(mesh_, nameT_, nameKappa_)); DEBUG(adapterInfo("Added reader: Heat Transfer Coefficient for basic solvers. ")); } else { adapterInfo("Unknown solver type - cannot add heat transfer coefficient.", - "error"); + "error"); } } else { - adapterInfo("Unknown data type - cannot add " + dataName +".", "error"); + adapterInfo("Unknown data type - cannot add " + dataName + ".", "error"); } // NOTE: If you want to couple another variable, you need diff --git a/CHT/CHT.H b/CHT/CHT.H index 43437c63..d4bf03fb 100644 --- a/CHT/CHT.H +++ b/CHT/CHT.H @@ -19,7 +19,6 @@ class ConjugateHeatTransfer { protected: - //- OpenFOAM fvMesh object const Foam::fvMesh& mesh_; @@ -47,7 +46,6 @@ protected: std::string nameAlphat_ = "alphat"; protected: - //- Determine the solver type std::string determineSolverType(); @@ -55,7 +53,6 @@ protected: bool readConfig(const IOdictionary& adapterConfig); public: - //- Constructor ConjugateHeatTransfer(const Foam::fvMesh& mesh); @@ -63,10 +60,10 @@ public: bool configure(const IOdictionary& adapterConfig); //- Add coupling data writers - void addWriters(std::string dataName, Interface * interface); + void addWriters(std::string dataName, Interface* interface); //- Add coupling data readers - void addReaders(std::string dataName, Interface * interface); + void addReaders(std::string dataName, Interface* interface); }; } diff --git a/CHT/HeatFlux.C b/CHT/HeatFlux.C index 20839d8a..cdf5fd25 100644 --- a/CHT/HeatFlux.C +++ b/CHT/HeatFlux.C @@ -7,45 +7,36 @@ using namespace Foam; //----- preciceAdapter::CHT::HeatFlux ----------------------------------------- -preciceAdapter::CHT::HeatFlux::HeatFlux -( +preciceAdapter::CHT::HeatFlux::HeatFlux( const Foam::fvMesh& mesh, - const std::string nameT -) -: -T_( - const_cast - ( - &mesh.lookupObject(nameT) - ) -), -mesh_(mesh) + const std::string nameT) +: T_( + const_cast( + &mesh.lookupObject(nameT))), + mesh_(mesh) { dataType_ = scalar; } -void preciceAdapter::CHT::HeatFlux::write(double * buffer, bool meshConnectivity, const unsigned int dim) +void preciceAdapter::CHT::HeatFlux::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++ ) + for (uint j = 0; j < patchIDs_.size(); j++) { int patchID = patchIDs_.at(j); - const scalarField gradientPatch - ( - refCast - ( - T_->boundaryField()[patchID] - ).snGrad() - ); + const scalarField gradientPatch( + refCast( + T_->boundaryField()[patchID]) + .snGrad()); // Extract the effective conductivity on the patch extractKappaEff(patchID, meshConnectivity); // If we use the mesh connectivity, we interpolate from the centres to the nodes - if(meshConnectivity) + if (meshConnectivity) { //Setup Interpolation object primitivePatchInterpolation patchInterpolator(mesh_.boundaryMesh()[patchID]); @@ -61,9 +52,8 @@ void preciceAdapter::CHT::HeatFlux::write(double * buffer, bool meshConnectivity // Copy the heat flux into the buffer // Q = - k * gradient(T) //TODO: Interpolate kappa in case of a turbulent calculation - buffer[bufferIndex++] - = - -getKappaEffAt(i) * gradientPoints[i]; + buffer[bufferIndex++] = + -getKappaEffAt(i) * gradientPoints[i]; } } else @@ -74,15 +64,14 @@ void preciceAdapter::CHT::HeatFlux::write(double * buffer, bool meshConnectivity // Copy the heat flux into the buffer // Q = - k * gradient(T) //TODO: Interpolate kappa in case of a turbulent calculation - buffer[bufferIndex++] - = - -getKappaEffAt(i) * gradientPatch[i]; + buffer[bufferIndex++] = + -getKappaEffAt(i) * gradientPatch[i]; } } } } -void preciceAdapter::CHT::HeatFlux::read(double * buffer, const unsigned int dim) +void preciceAdapter::CHT::HeatFlux::read(double* buffer, const unsigned int dim) { int bufferIndex = 0; @@ -93,16 +82,13 @@ void preciceAdapter::CHT::HeatFlux::read(double * buffer, const unsigned int dim // Extract the effective conductivity on the patch // TODO: At the moment, reading with connectivity is not supported - extractKappaEff(patchID,/*meshConnectivity=*/false); + extractKappaEff(patchID, /*meshConnectivity=*/false); // Get the temperature gradient boundary patch - scalarField & gradientPatch - ( - refCast - ( - T_->boundaryFieldRef()[patchID] - ).gradient() - ); + scalarField& gradientPatch( + refCast( + T_->boundaryFieldRef()[patchID]) + .gradient()); // For every cell of the patch forAll(gradientPatch, i) @@ -111,23 +97,19 @@ void preciceAdapter::CHT::HeatFlux::read(double * buffer, const unsigned int dim // The sign of the heat flux needs to be inversed, // as the buffer contains the flux that enters the boundary: // gradient(T) = -Q / -k - gradientPatch[i] - = - buffer[bufferIndex++] / getKappaEffAt(i); + gradientPatch[i] = + buffer[bufferIndex++] / getKappaEffAt(i); } } } //----- preciceAdapter::CHT::HeatFlux_Compressible ---------------------------- -preciceAdapter::CHT::HeatFlux_Compressible::HeatFlux_Compressible -( +preciceAdapter::CHT::HeatFlux_Compressible::HeatFlux_Compressible( const Foam::fvMesh& mesh, - const std::string nameT -) -: -HeatFlux(mesh, nameT), -Kappa_(new KappaEff_Compressible(mesh)) + const std::string nameT) +: HeatFlux(mesh, nameT), + Kappa_(new KappaEff_Compressible(mesh)) { } @@ -148,18 +130,15 @@ scalar preciceAdapter::CHT::HeatFlux_Compressible::getKappaEffAt(int i) //----- preciceAdapter::CHT::HeatFlux_Incompressible -------------------------- -preciceAdapter::CHT::HeatFlux_Incompressible::HeatFlux_Incompressible -( +preciceAdapter::CHT::HeatFlux_Incompressible::HeatFlux_Incompressible( const Foam::fvMesh& mesh, const std::string nameT, const std::string nameRho, const std::string nameCp, const std::string namePr, - const std::string nameAlphat -) -: -HeatFlux(mesh, nameT), -Kappa_(new KappaEff_Incompressible(mesh, nameRho, nameCp, namePr, nameAlphat)) + const std::string nameAlphat) +: HeatFlux(mesh, nameT), + Kappa_(new KappaEff_Incompressible(mesh, nameRho, nameCp, namePr, nameAlphat)) { } @@ -180,15 +159,12 @@ scalar preciceAdapter::CHT::HeatFlux_Incompressible::getKappaEffAt(int i) //----- preciceAdapter::CHT::HeatFlux_Basic ----------------------------------- -preciceAdapter::CHT::HeatFlux_Basic::HeatFlux_Basic -( +preciceAdapter::CHT::HeatFlux_Basic::HeatFlux_Basic( const Foam::fvMesh& mesh, const std::string nameT, - const std::string nameKappa -) -: -HeatFlux(mesh, nameT), -Kappa_(new KappaEff_Basic(mesh, nameKappa)) + const std::string nameKappa) +: HeatFlux(mesh, nameT), + Kappa_(new KappaEff_Basic(mesh, nameKappa)) { } diff --git a/CHT/HeatFlux.H b/CHT/HeatFlux.H index a6422635..dc000bed 100644 --- a/CHT/HeatFlux.H +++ b/CHT/HeatFlux.H @@ -16,9 +16,8 @@ class HeatFlux : public CouplingDataUser { protected: - //- Temperature field - Foam::volScalarField * T_; + Foam::volScalarField* T_; const Foam::fvMesh& mesh_; @@ -29,21 +28,19 @@ protected: virtual Foam::scalar getKappaEffAt(int i) = 0; public: - //- Constructor HeatFlux(const Foam::fvMesh& mesh, const std::string nameT); //- Compute heat flux values from the temperature field // and write them into the buffer - virtual void write(double * buffer, bool meshConnectivity, const unsigned int dim); + virtual void write(double* buffer, bool meshConnectivity, const unsigned int dim); //- Read heat flux values from the buffer and assign them to // the gradient of the temperature field - virtual void read(double * buffer, const unsigned int dim); + virtual void read(double* buffer, const unsigned int dim); //- Destructor - virtual ~HeatFlux(){}; - + virtual ~HeatFlux() {}; }; //- Implementation of the HeatFlux for compresible, turbulent flow solvers @@ -52,10 +49,9 @@ class HeatFlux_Compressible : public HeatFlux { protected: - // Object that extracts the effective conductivity // (for compressible turbulent flow solvers) - KappaEff_Compressible * Kappa_; + KappaEff_Compressible* Kappa_; //- Wrapper for the extract() method of the corresponding KappaEff class virtual void extractKappaEff(uint patchID, bool meshConnectivity); @@ -64,17 +60,13 @@ protected: virtual Foam::scalar getKappaEffAt(int i); public: - //- Constructor - HeatFlux_Compressible - ( + HeatFlux_Compressible( const Foam::fvMesh& mesh, - const std::string nameT - ); + const std::string nameT); //- Destructor virtual ~HeatFlux_Compressible(); - }; //- Implementation of the HeatFlux for incompresible, turbulent flow solvers @@ -83,10 +75,9 @@ class HeatFlux_Incompressible : public HeatFlux { protected: - // Object that computes the effective conductivity // (for incompressible turbulent flow solvers) - KappaEff_Incompressible * Kappa_; + KappaEff_Incompressible* Kappa_; //- Wrapper for the extract() method of the corresponding KappaEff class virtual void extractKappaEff(uint patchID, bool meshConnectivity); @@ -95,21 +86,17 @@ protected: virtual Foam::scalar getKappaEffAt(int i); public: - //- Constructor - HeatFlux_Incompressible - ( + HeatFlux_Incompressible( const Foam::fvMesh& mesh, const std::string nameT, const std::string nameRho, const std::string nameCp, const std::string namePr, - const std::string nameAlphat - ); + const std::string nameAlphat); //- Destructor virtual ~HeatFlux_Incompressible(); - }; //- Implementation of the HeatFlux for basic solvers @@ -118,10 +105,9 @@ class HeatFlux_Basic : public HeatFlux { protected: - //- Object that extracts the effective conductivity // (for basic solvers) - KappaEff_Basic * Kappa_; + KappaEff_Basic* Kappa_; //- Wrapper for the extract() method of the corresponding KappaEff class virtual void extractKappaEff(uint patchID, bool meshConnectivity); @@ -130,18 +116,14 @@ protected: virtual Foam::scalar getKappaEffAt(int i); public: - //- Constructor - HeatFlux_Basic - ( + HeatFlux_Basic( const Foam::fvMesh& mesh, const std::string nameT, - const std::string nameKappa - ); + const std::string nameKappa); //- Destructor virtual ~HeatFlux_Basic(); - }; } diff --git a/CHT/HeatTransferCoefficient.C b/CHT/HeatTransferCoefficient.C index cd52ecfa..d084f54c 100644 --- a/CHT/HeatTransferCoefficient.C +++ b/CHT/HeatTransferCoefficient.C @@ -8,30 +8,24 @@ using namespace Foam; //----- preciceAdapter::CHT::HeatTransferCoefficient -------------------------- -preciceAdapter::CHT::HeatTransferCoefficient::HeatTransferCoefficient -( +preciceAdapter::CHT::HeatTransferCoefficient::HeatTransferCoefficient( const Foam::fvMesh& mesh, - const std::string nameT -) -: -T_( - const_cast - ( - &mesh.lookupObject(nameT) - ) -), -mesh_(mesh) + const std::string nameT) +: T_( + const_cast( + &mesh.lookupObject(nameT))), + mesh_(mesh) { dataType_ = scalar; } -void preciceAdapter::CHT::HeatTransferCoefficient::write(double * buffer, bool meshConnectivity, const unsigned int dim) +void preciceAdapter::CHT::HeatTransferCoefficient::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++ ) + for (uint j = 0; j < patchIDs_.size(); j++) { int patchID = patchIDs_.at(j); @@ -39,18 +33,16 @@ void preciceAdapter::CHT::HeatTransferCoefficient::write(double * buffer, bool m extractKappaEff(patchID, meshConnectivity); // Get the face-cell distance coefficients on the patch - const scalarField & delta - ( - mesh_.boundary()[patchID].deltaCoeffs() - ); + const scalarField& delta( + mesh_.boundary()[patchID].deltaCoeffs()); //If we use the mesh connectivity, we interpolate from the centres to the nodes - if(meshConnectivity) + if (meshConnectivity) { //Setup Interpolation object primitivePatchInterpolation patchInterpolator(mesh_.boundaryMesh()[patchID]); - scalarField deltaPoints; + scalarField deltaPoints; //Interpolate deltaPoints = patchInterpolator.faceToPointInterpolate(delta); @@ -80,7 +72,7 @@ void preciceAdapter::CHT::HeatTransferCoefficient::write(double * buffer, bool m } -void preciceAdapter::CHT::HeatTransferCoefficient::read(double * buffer, const unsigned int dim) +void preciceAdapter::CHT::HeatTransferCoefficient::read(double* buffer, const unsigned int dim) { int bufferIndex = 0; @@ -91,22 +83,16 @@ void preciceAdapter::CHT::HeatTransferCoefficient::read(double * buffer, const u // Extract the effective conductivity on the patch // TODO: At the moment, reading with connectivity is not supported - extractKappaEff(patchID,/*meshConnectivity=*/false); + extractKappaEff(patchID, /*meshConnectivity=*/false); // Get the face-cell distance coefficients on the patch - const scalarField & delta - ( - mesh_.boundary()[patchID].deltaCoeffs() - ); + const scalarField& delta( + mesh_.boundary()[patchID].deltaCoeffs()); // Get a reference to the temperature on the patch - mixedFvPatchScalarField & TPatch - ( - refCast - ( - T_->boundaryFieldRef()[patchID] - ) - ); + mixedFvPatchScalarField& TPatch( + refCast( + T_->boundaryFieldRef()[patchID])); // For every cell on the patch forAll(TPatch, i) @@ -124,7 +110,7 @@ void preciceAdapter::CHT::HeatTransferCoefficient::read(double * buffer, const u // Set the fraction (0-1) of value for the mixed boundary condition TPatch.valueFraction()[i] = - neighborKappaDelta / (myKappaDelta + neighborKappaDelta); + neighborKappaDelta / (myKappaDelta + neighborKappaDelta); } } } @@ -133,31 +119,28 @@ void preciceAdapter::CHT::HeatTransferCoefficient::read(double * buffer, const u //----- preciceAdapter::CHT::HeatTransferCoefficient_Compressible ------------- preciceAdapter::CHT:: -HeatTransferCoefficient_Compressible::HeatTransferCoefficient_Compressible -( - const Foam::fvMesh& mesh, - const std::string nameT -) -: -HeatTransferCoefficient(mesh, nameT), -Kappa_(new KappaEff_Compressible(mesh)) + HeatTransferCoefficient_Compressible::HeatTransferCoefficient_Compressible( + const Foam::fvMesh& mesh, + const std::string nameT) +: HeatTransferCoefficient(mesh, nameT), + Kappa_(new KappaEff_Compressible(mesh)) { } preciceAdapter::CHT::HeatTransferCoefficient_Compressible:: -~HeatTransferCoefficient_Compressible() + ~HeatTransferCoefficient_Compressible() { delete Kappa_; } void preciceAdapter::CHT::HeatTransferCoefficient_Compressible:: -extractKappaEff(uint patchID, bool meshConnectivity) + extractKappaEff(uint patchID, bool meshConnectivity) { Kappa_->extract(patchID, meshConnectivity); } scalar preciceAdapter::CHT::HeatTransferCoefficient_Compressible:: -getKappaEffAt(int i) + getKappaEffAt(int i) { return Kappa_->getAt(i); } @@ -165,35 +148,32 @@ getKappaEffAt(int i) //----- preciceAdapter::CHT::HeatTransferCoefficient_Incompressible ----------- preciceAdapter::CHT::HeatTransferCoefficient_Incompressible:: -HeatTransferCoefficient_Incompressible -( - const Foam::fvMesh& mesh, - const std::string nameT, - const std::string nameRho, - const std::string nameCp, - const std::string namePr, - const std::string nameAlphat -) -: -HeatTransferCoefficient(mesh, nameT), -Kappa_(new KappaEff_Incompressible(mesh, nameRho, nameCp, namePr, nameAlphat)) + HeatTransferCoefficient_Incompressible( + const Foam::fvMesh& mesh, + const std::string nameT, + const std::string nameRho, + const std::string nameCp, + const std::string namePr, + const std::string nameAlphat) +: HeatTransferCoefficient(mesh, nameT), + Kappa_(new KappaEff_Incompressible(mesh, nameRho, nameCp, namePr, nameAlphat)) { } preciceAdapter::CHT::HeatTransferCoefficient_Incompressible:: -~HeatTransferCoefficient_Incompressible() + ~HeatTransferCoefficient_Incompressible() { delete Kappa_; } void preciceAdapter::CHT::HeatTransferCoefficient_Incompressible:: -extractKappaEff(uint patchID, bool meshConnectivity) + extractKappaEff(uint patchID, bool meshConnectivity) { Kappa_->extract(patchID, meshConnectivity); } scalar preciceAdapter::CHT::HeatTransferCoefficient_Incompressible:: -getKappaEffAt(int i) + getKappaEffAt(int i) { return Kappa_->getAt(i); } @@ -201,32 +181,29 @@ getKappaEffAt(int i) //----- preciceAdapter::CHT::HeatTransferCoefficient_Basic ----------------------------------- preciceAdapter::CHT::HeatTransferCoefficient_Basic:: -HeatTransferCoefficient_Basic -( - const Foam::fvMesh& mesh, - const std::string nameT, - const std::string nameKappa -) -: -HeatTransferCoefficient(mesh, nameT), -Kappa_(new KappaEff_Basic(mesh, nameKappa)) + HeatTransferCoefficient_Basic( + const Foam::fvMesh& mesh, + const std::string nameT, + const std::string nameKappa) +: HeatTransferCoefficient(mesh, nameT), + Kappa_(new KappaEff_Basic(mesh, nameKappa)) { } preciceAdapter::CHT::HeatTransferCoefficient_Basic:: -~HeatTransferCoefficient_Basic() + ~HeatTransferCoefficient_Basic() { delete Kappa_; } void preciceAdapter::CHT::HeatTransferCoefficient_Basic:: -extractKappaEff(uint patchID, bool meshConnectivity) + extractKappaEff(uint patchID, bool meshConnectivity) { Kappa_->extract(patchID, meshConnectivity); } scalar preciceAdapter::CHT::HeatTransferCoefficient_Basic:: -getKappaEffAt(int i) + getKappaEffAt(int i) { return Kappa_->getAt(i); } diff --git a/CHT/HeatTransferCoefficient.H b/CHT/HeatTransferCoefficient.H index bb63d3fe..76660636 100644 --- a/CHT/HeatTransferCoefficient.H +++ b/CHT/HeatTransferCoefficient.H @@ -16,9 +16,8 @@ class HeatTransferCoefficient : public CouplingDataUser { protected: - //- Temperature field - Foam::volScalarField * T_; + Foam::volScalarField* T_; //- OpenFOAM fvMesh object const Foam::fvMesh& mesh_; @@ -30,23 +29,19 @@ protected: virtual Foam::scalar getKappaEffAt(int i) = 0; public: - //- Constructor - HeatTransferCoefficient - ( + HeatTransferCoefficient( const Foam::fvMesh& mesh, - const std::string nameT - ); + const std::string nameT); //- Write the heat transfer coefficient values into the buffer - virtual void write(double * buffer, bool meshConnectivity, const unsigned int dim); + virtual void write(double* buffer, bool meshConnectivity, const unsigned int dim); //- Read the heat transfer coefficient values from the buffer - virtual void read(double * buffer, const unsigned int dim); + virtual void read(double* buffer, const unsigned int dim); //- Destructor - virtual ~HeatTransferCoefficient(){}; - + virtual ~HeatTransferCoefficient() {}; }; //- Implementation of the HeatTransferCoefficient for compresible, turbulent flow solvers @@ -55,10 +50,9 @@ class HeatTransferCoefficient_Compressible : public HeatTransferCoefficient { protected: - // Object that extracts the effective conductivity // (for compressible turbulent flow solvers) - KappaEff_Compressible * Kappa_; + KappaEff_Compressible* Kappa_; //- Wrapper for the extract() method of the corresponding KappaEff class virtual void extractKappaEff(uint patchID, bool meshConnectivity); @@ -67,17 +61,13 @@ protected: virtual Foam::scalar getKappaEffAt(int i); public: - //- Constructor - HeatTransferCoefficient_Compressible - ( + HeatTransferCoefficient_Compressible( const Foam::fvMesh& mesh, - const std::string nameT - ); + const std::string nameT); //- Destructor virtual ~HeatTransferCoefficient_Compressible(); - }; //- Implementation of the HeatTransferCoefficient for incompresible, turbulent flow solvers @@ -86,10 +76,9 @@ class HeatTransferCoefficient_Incompressible : public HeatTransferCoefficient { protected: - // Object that computes the effective conductivity // (for incompressible turbulent flow solvers) - KappaEff_Incompressible * Kappa_; + KappaEff_Incompressible* Kappa_; //- Wrapper for the extract() method of the corresponding KappaEff class virtual void extractKappaEff(uint patchID, bool meshConnectivity); @@ -98,21 +87,17 @@ protected: virtual Foam::scalar getKappaEffAt(int i); public: - //- Constructor - HeatTransferCoefficient_Incompressible - ( + HeatTransferCoefficient_Incompressible( const Foam::fvMesh& mesh, const std::string nameT, const std::string nameRho, const std::string nameCp, const std::string namePr, - const std::string nameAlphat - ); + const std::string nameAlphat); //- Destructor virtual ~HeatTransferCoefficient_Incompressible(); - }; @@ -122,10 +107,9 @@ class HeatTransferCoefficient_Basic : public HeatTransferCoefficient { protected: - //- Object that extracts the effective conductivity // (for basic solvers) - KappaEff_Basic * Kappa_; + KappaEff_Basic* Kappa_; //- Wrapper for the extract() method of the corresponding KappaEff class virtual void extractKappaEff(uint patchID, bool meshConnectivity); @@ -134,18 +118,14 @@ protected: virtual Foam::scalar getKappaEffAt(int i); public: - //- Constructor - HeatTransferCoefficient_Basic - ( + HeatTransferCoefficient_Basic( const Foam::fvMesh& mesh, const std::string nameT, - const std::string nameKappa - ); + const std::string nameKappa); //- Destructor virtual ~HeatTransferCoefficient_Basic(); - }; } diff --git a/CHT/KappaEffective.C b/CHT/KappaEffective.C index 5f8c5479..4425ba24 100644 --- a/CHT/KappaEffective.C +++ b/CHT/KappaEffective.C @@ -7,33 +7,29 @@ using namespace Foam; //----- preciceAdapter::CHT::KappaEff_Compressible ------------------ -preciceAdapter::CHT::KappaEff_Compressible::KappaEff_Compressible -( - const Foam::fvMesh& mesh -) -: -mesh_(mesh), -turbulence_( - mesh.lookupObject(turbulenceModel::propertiesName) -) +preciceAdapter::CHT::KappaEff_Compressible::KappaEff_Compressible( + const Foam::fvMesh& mesh) +: mesh_(mesh), + turbulence_( + mesh.lookupObject(turbulenceModel::propertiesName)) { DEBUG(adapterInfo("Constructed KappaEff_Compressible.")); } void preciceAdapter::CHT::KappaEff_Compressible::extract(uint patchID, bool meshConnectivity) { - if(meshConnectivity) + if (meshConnectivity) { //Create an Interpolation object at the boundary Field primitivePatchInterpolation patchInterpolator(mesh_.boundaryMesh()[patchID]); //Interpolate kappaEff_ from centers to nodes - kappaEff_= patchInterpolator.faceToPointInterpolate(turbulence_.kappaEff() ().boundaryField()[patchID]); + kappaEff_ = patchInterpolator.faceToPointInterpolate(turbulence_.kappaEff()().boundaryField()[patchID]); } else { // Extract kappaEff_ from the turbulence model - kappaEff_ = turbulence_.kappaEff() ().boundaryField()[patchID]; + kappaEff_ = turbulence_.kappaEff()().boundaryField()[patchID]; } } @@ -45,78 +41,65 @@ scalar preciceAdapter::CHT::KappaEff_Compressible::getAt(int i) //----- preciceAdapter::CHT::KappaEff_Incompressible ------------------ -preciceAdapter::CHT::KappaEff_Incompressible::KappaEff_Incompressible -( +preciceAdapter::CHT::KappaEff_Incompressible::KappaEff_Incompressible( const Foam::fvMesh& mesh, const std::string nameRho, const std::string nameCp, const std::string namePr, - const std::string nameAlphat -) -: -mesh_(mesh), -turbulence_( - mesh.lookupObject(turbulenceModel::propertiesName) -), -nameRho_(nameRho), -nameCp_(nameCp), -namePr_(namePr), -nameAlphat_(nameAlphat) + const std::string nameAlphat) +: mesh_(mesh), + turbulence_( + mesh.lookupObject(turbulenceModel::propertiesName)), + nameRho_(nameRho), + nameCp_(nameCp), + namePr_(namePr), + nameAlphat_(nameAlphat) { - DEBUG(adapterInfo("Constructed KappaEff_Incompressible.")); - DEBUG(adapterInfo(" Name of density: " + nameRho_)); - DEBUG(adapterInfo(" Name of heat capacity: " + nameCp_)); - DEBUG(adapterInfo(" Name of Prandl number: " + namePr_)); - DEBUG(adapterInfo(" Name of turbulent thermal diffusivity: " + nameAlphat_)); - - // Get the preciceDict/CHT dictionary - const dictionary CHTDict = - mesh_.lookupObject("preciceDict").subOrEmptyDict("CHT"); - - // Read the Prandtl number - if (!CHTDict.readIfPresent(namePr_, Pr_)) - { - adapterInfo - ( - "Cannot find the Prandtl number in preciceDict/CHT using the name " + - namePr_, - "error" - ); - } - else - { - DEBUG(adapterInfo(" Pr = " + std::to_string(Pr_.value()))); - } - - // Read the density - if (!CHTDict.readIfPresent(nameRho_, rho_)) - { - adapterInfo - ( - "Cannot find the density in preciceDict/CHT using the name " + - nameRho_, - "error" - ); - } - else - { - DEBUG(adapterInfo(" rho = " + std::to_string(rho_.value()))); - } - - // Read the heat capacity - if (!CHTDict.readIfPresent(nameCp_, Cp_)) - { - adapterInfo - ( - "Cannot find the heat capacity in preciceDict/CHT using the name " + - nameCp_, - "error" - ); - } - else - { - DEBUG(adapterInfo(" Cp = " + std::to_string(Cp_.value()))); - } + DEBUG(adapterInfo("Constructed KappaEff_Incompressible.")); + DEBUG(adapterInfo(" Name of density: " + nameRho_)); + DEBUG(adapterInfo(" Name of heat capacity: " + nameCp_)); + DEBUG(adapterInfo(" Name of Prandl number: " + namePr_)); + DEBUG(adapterInfo(" Name of turbulent thermal diffusivity: " + nameAlphat_)); + + // Get the preciceDict/CHT dictionary + const dictionary CHTDict = + mesh_.lookupObject("preciceDict").subOrEmptyDict("CHT"); + + // Read the Prandtl number + if (!CHTDict.readIfPresent(namePr_, Pr_)) + { + adapterInfo( + "Cannot find the Prandtl number in preciceDict/CHT using the name " + namePr_, + "error"); + } + else + { + DEBUG(adapterInfo(" Pr = " + std::to_string(Pr_.value()))); + } + + // Read the density + if (!CHTDict.readIfPresent(nameRho_, rho_)) + { + adapterInfo( + "Cannot find the density in preciceDict/CHT using the name " + nameRho_, + "error"); + } + else + { + DEBUG(adapterInfo(" rho = " + std::to_string(rho_.value()))); + } + + // Read the heat capacity + if (!CHTDict.readIfPresent(nameCp_, Cp_)) + { + adapterInfo( + "Cannot find the heat capacity in preciceDict/CHT using the name " + nameCp_, + "error"); + } + else + { + DEBUG(adapterInfo(" Cp = " + std::to_string(Cp_.value()))); + } } void preciceAdapter::CHT::KappaEff_Incompressible::extract(uint patchID, bool meshConnectivity) @@ -125,10 +108,8 @@ void preciceAdapter::CHT::KappaEff_Incompressible::extract(uint patchID, bool me // Get the laminar viscosity from the turbulence model // TODO: Do we really need turbulence at the end? - const scalarField & nu - ( - turbulence_.nu() ().boundaryField()[patchID] - ); + const scalarField& nu( + turbulence_.nu()().boundaryField()[patchID]); // Compute the effective thermal diffusivity // (alphaEff = alpha + alphat = nu / Pr + nut / Prt) @@ -138,10 +119,8 @@ void preciceAdapter::CHT::KappaEff_Incompressible::extract(uint patchID, bool me // Does the turbulent thermal diffusivity exist in the object registry? if (mesh_.foundObject(nameAlphat_)) { - const scalarField & alphat - ( - mesh_.lookupObject(nameAlphat_).boundaryField()[patchID] - ); + const scalarField& alphat( + mesh_.lookupObject(nameAlphat_).boundaryField()[patchID]); alphaEff = nu / Pr_.value() + alphat; } @@ -158,25 +137,22 @@ void preciceAdapter::CHT::KappaEff_Incompressible::extract(uint patchID, bool me } // Compute the effective thermal conductivity and store it in a temp variable - scalarField kappaEff_temp - ( - alphaEff * rho_.value() * Cp_.value() - ); + scalarField kappaEff_temp( + alphaEff * rho_.value() * Cp_.value()); - if(meshConnectivity) + if (meshConnectivity) { //Create an Interpolation object at the boundary Field primitivePatchInterpolation patchInterpolator(mesh_.boundaryMesh()[patchID]); //Interpolate kappaEff_ from centers to nodes, if desired - kappaEff_= patchInterpolator.faceToPointInterpolate(kappaEff_temp); + kappaEff_ = patchInterpolator.faceToPointInterpolate(kappaEff_temp); } else { // if no interpolation kappaEff_ = kappaEff_temp; } - } scalar preciceAdapter::CHT::KappaEff_Incompressible::getAt(int i) @@ -186,14 +162,11 @@ scalar preciceAdapter::CHT::KappaEff_Incompressible::getAt(int i) //----- preciceAdapter::CHT::KappaEff_Basic --------------------------- -preciceAdapter::CHT::KappaEff_Basic::KappaEff_Basic -( +preciceAdapter::CHT::KappaEff_Basic::KappaEff_Basic( const Foam::fvMesh& mesh, - const std::string nameKappa -) -: -mesh_(mesh), -nameKappa_(nameKappa) + const std::string nameKappa) +: mesh_(mesh), + nameKappa_(nameKappa) { DEBUG(adapterInfo("Constructed KappaEff_Basic.")); DEBUG(adapterInfo(" Name of conductivity: " + nameKappa_)); @@ -205,16 +178,13 @@ nameKappa_(nameKappa) // Read the conductivity if (!CHTDict.readIfPresent(nameKappa_, kappaEff_)) { - adapterInfo - ( - "Cannot find the conductivity in preciceDict/CHT using the name " + - nameKappa_, - "error" - ); + adapterInfo( + "Cannot find the conductivity in preciceDict/CHT using the name " + nameKappa_, + "error"); } else { - DEBUG(adapterInfo( "k = " + std::to_string(kappaEff_.value()))); + DEBUG(adapterInfo("k = " + std::to_string(kappaEff_.value()))); } } diff --git a/CHT/KappaEffective.H b/CHT/KappaEffective.H index 8a16ed3e..17cbf368 100644 --- a/CHT/KappaEffective.H +++ b/CHT/KappaEffective.H @@ -11,10 +11,10 @@ namespace CHT //- Class that extracts the effective conductivity from compressible // turbulent flow solvers. -class KappaEff_Compressible { +class KappaEff_Compressible +{ protected: - //- OpenFOAM fvMesh object const Foam::fvMesh& mesh_; @@ -23,10 +23,9 @@ protected: //- Turbulence (and thermo/transport) model, from which // kappaEff is drawn directly. - const Foam::compressible::turbulenceModel & turbulence_; + const Foam::compressible::turbulenceModel& turbulence_; public: - //- Constructor KappaEff_Compressible(const Foam::fvMesh& mesh); @@ -35,15 +34,14 @@ public: //- Get the value of kappaEff at cell i Foam::scalar getAt(int i); - }; //- Class that extracts the effective conductivity from incompressible // turbulent flow solvers. -class KappaEff_Incompressible { +class KappaEff_Incompressible +{ protected: - //- OpenFOAM fvMesh object const Foam::fvMesh& mesh_; @@ -53,7 +51,7 @@ protected: //- Turbulence (and thermo/transport) model. // The effective thermal diffusivity is drawn from it and // used to compute the effective thermal conductivity. - const Foam::incompressible::turbulenceModel & turbulence_; + const Foam::incompressible::turbulenceModel& turbulence_; //- Name of the user-provided density (in the preciceDict) const std::string nameRho_; @@ -77,32 +75,28 @@ protected: Foam::dimensionedScalar Pr_; public: - //- Constructor - KappaEff_Incompressible - ( + KappaEff_Incompressible( const Foam::fvMesh& mesh, const std::string nameRho, const std::string nameCp, const std::string namePr, - const std::string nameAlphat - ); + const std::string nameAlphat); //- Extract the kappaEff on the specific patch and store it. void extract(uint patchID, bool meshConnectivity); //- Get the value of kappaEff at cell i Foam::scalar getAt(int i); - }; //- Class that extracts the effective conductivity from basic solvers, // which do not have a turbulence/thermophysical model, but read // the required parameters from the preciceDict dictionary. -class KappaEff_Basic { +class KappaEff_Basic +{ protected: - //- OpenFOAM fvMesh object const Foam::fvMesh& mesh_; @@ -113,20 +107,16 @@ protected: const std::string nameKappa_; public: - //- Constructor - KappaEff_Basic - ( + KappaEff_Basic( const Foam::fvMesh& mesh, - const std::string nameKappa - ); + const std::string nameKappa); //- Extract the kappaEff on the specific patch and store it. void extract(uint patchID, bool meshConnectivity); //- Get the value of kappaEff at cell i (returns the same for every i) Foam::scalar getAt(int i); - }; } diff --git a/CHT/SinkTemperature.C b/CHT/SinkTemperature.C index 7f1fa84c..11746875 100644 --- a/CHT/SinkTemperature.C +++ b/CHT/SinkTemperature.C @@ -3,63 +3,52 @@ using namespace Foam; -preciceAdapter::CHT::SinkTemperature::SinkTemperature -( +preciceAdapter::CHT::SinkTemperature::SinkTemperature( const Foam::fvMesh& mesh, - const std::string nameT - ) -: -T_( - const_cast - ( - &mesh.lookupObject(nameT) - ) -), -mesh_(mesh) + const std::string nameT) +: T_( + const_cast( + &mesh.lookupObject(nameT))), + mesh_(mesh) { dataType_ = scalar; } -void preciceAdapter::CHT::SinkTemperature::write(double * buffer, bool meshConnectivity, const unsigned int dim) +void preciceAdapter::CHT::SinkTemperature::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++ ) + for (uint j = 0; j < patchIDs_.size(); j++) { int patchID = patchIDs_.at(j); // Get the boundary field of Temperature on the patch - const fvPatchScalarField & TPatch - ( - refCast - ( - T_->boundaryField()[patchID] - ) - ); + const fvPatchScalarField& TPatch( + refCast( + T_->boundaryField()[patchID])); // Get the internal field next to the patch // TODO: Simplify? tmp patchInternalFieldTmp = TPatch.patchInternalField(); - const scalarField & patchInternalField = patchInternalFieldTmp(); + const scalarField& patchInternalField = patchInternalFieldTmp(); //If we use the mesh connectivity, we interpolate from the centres to the nodes - if(meshConnectivity) + if (meshConnectivity) { //Create an Interpolation object at the boundary Field primitivePatchInterpolation patchInterpolator(mesh_.boundaryMesh()[patchID]); - scalarField patchInternalPointField; + scalarField patchInternalPointField; //Interpolate from centers to nodes - patchInternalPointField= patchInterpolator.faceToPointInterpolate(patchInternalField); + patchInternalPointField = patchInterpolator.faceToPointInterpolate(patchInternalField); // For every point on the patch forAll(patchInternalPointField, i) { // Copy the temperature into the buffer - buffer[bufferIndex++] - = - patchInternalPointField[i]; + buffer[bufferIndex++] = + patchInternalPointField[i]; } } else @@ -68,9 +57,8 @@ void preciceAdapter::CHT::SinkTemperature::write(double * buffer, bool meshConne forAll(TPatch, i) { // Copy the internal field (sink) temperature into the buffer - buffer[bufferIndex++] - = - patchInternalField[i]; + buffer[bufferIndex++] = + patchInternalField[i]; } } @@ -79,7 +67,7 @@ void preciceAdapter::CHT::SinkTemperature::write(double * buffer, bool meshConne } } -void preciceAdapter::CHT::SinkTemperature::read(double * buffer, const unsigned int dim) +void preciceAdapter::CHT::SinkTemperature::read(double* buffer, const unsigned int dim) { int bufferIndex = 0; @@ -89,24 +77,19 @@ void preciceAdapter::CHT::SinkTemperature::read(double * buffer, const unsigned int patchID = patchIDs_.at(j); // Get the boundary field of the temperature on the patch - mixedFvPatchScalarField & TPatch - ( - refCast - ( - T_->boundaryFieldRef()[patchID] - ) - ); + mixedFvPatchScalarField& TPatch( + refCast( + T_->boundaryFieldRef()[patchID])); // Get a reference to the reference value on the patch - scalarField & Tref = TPatch.refValue(); + scalarField& Tref = TPatch.refValue(); // For every cell of the patch forAll(TPatch, i) { // Set the reference value as the buffer value - Tref[i] - = - buffer[bufferIndex++]; + Tref[i] = + buffer[bufferIndex++]; } } } diff --git a/CHT/SinkTemperature.H b/CHT/SinkTemperature.H index 6f782499..5c92b7c6 100644 --- a/CHT/SinkTemperature.H +++ b/CHT/SinkTemperature.H @@ -15,26 +15,21 @@ class SinkTemperature : public CouplingDataUser { private: - //- Temperature field - Foam::volScalarField * T_; + Foam::volScalarField* T_; const Foam::fvMesh& mesh_; public: - //- Constructor - SinkTemperature - ( + SinkTemperature( const Foam::fvMesh& mesh, - const std::string nameT - ); + const std::string nameT); //- Write the sink temperature values into the buffer - void write(double * buffer, bool meshConnectivity, const unsigned int dim); + void 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); - + void read(double* buffer, const unsigned int dim); }; } diff --git a/CHT/Temperature.C b/CHT/Temperature.C index 898beefe..b3ab956a 100644 --- a/CHT/Temperature.C +++ b/CHT/Temperature.C @@ -4,55 +4,44 @@ using namespace Foam; -preciceAdapter::CHT::Temperature::Temperature -( +preciceAdapter::CHT::Temperature::Temperature( const Foam::fvMesh& mesh, - const std::string nameT -) -: -T_( - const_cast - ( - &mesh.lookupObject(nameT) - ) -), -mesh_(mesh) + const std::string nameT) +: T_( + const_cast( + &mesh.lookupObject(nameT))), + mesh_(mesh) { dataType_ = scalar; } -void preciceAdapter::CHT::Temperature::write(double * buffer, bool meshConnectivity, const unsigned int dim) +void preciceAdapter::CHT::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++ ) + for (uint j = 0; j < patchIDs_.size(); j++) { int patchID = patchIDs_.at(j); - const scalarField & TPatch - ( - T_->boundaryField()[patchID] - ); + const scalarField& TPatch( + T_->boundaryField()[patchID]); //If we use the mesh connectivity, we interpolate from the centres to the nodes - if(meshConnectivity) + if (meshConnectivity) { //Create an Interpolation object at the boundary Field primitivePatchInterpolation patchInterpolator(mesh_.boundaryMesh()[patchID]); //Interpolate from centers to nodes - scalarField TPoints - ( - patchInterpolator.faceToPointInterpolate(TPatch) - ); + scalarField TPoints( + patchInterpolator.faceToPointInterpolate(TPatch)); forAll(TPoints, i) { // Copy the temperature into the buffer - buffer[bufferIndex++] - = - TPoints[i]; + buffer[bufferIndex++] = + TPoints[i]; } } else @@ -60,30 +49,28 @@ void preciceAdapter::CHT::Temperature::write(double * buffer, bool meshConnectiv forAll(TPatch, i) { // Copy the temperature into the buffer - buffer[bufferIndex++] - = - TPatch[i]; + buffer[bufferIndex++] = + TPatch[i]; } } } } - void preciceAdapter::CHT::Temperature::read(double * buffer, const unsigned int dim) +void preciceAdapter::CHT::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 bufferIndex = 0; + int patchID = patchIDs_.at(j); - // For every boundary patch of the interface - for (uint j = 0; j < patchIDs_.size(); j++) + // For every cell of the patch + forAll(T_->boundaryField()[patchID], i) { - int patchID = patchIDs_.at(j); - - // For every cell of the patch - forAll(T_->boundaryField()[patchID], i) - { - // Set the temperature as the buffer value - T_->boundaryFieldRef()[patchID][i] - = + // Set the temperature as the buffer value + T_->boundaryFieldRef()[patchID][i] = buffer[bufferIndex++]; - } } } +} diff --git a/CHT/Temperature.H b/CHT/Temperature.H index 6932dd07..722ddb01 100644 --- a/CHT/Temperature.H +++ b/CHT/Temperature.H @@ -15,26 +15,21 @@ class Temperature : public CouplingDataUser { private: - //- Temperature field - Foam::volScalarField * T_; + Foam::volScalarField* T_; const Foam::fvMesh& mesh_; public: - //- Constructor - Temperature - ( + Temperature( const Foam::fvMesh& mesh, - const std::string nameT - ); + const std::string nameT); //- Write the temperature values into the buffer - void write(double * buffer, bool meshConnectivity, const unsigned int dim); + 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); - + void read(double* buffer, const unsigned int dim); }; } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 407ade42..633f8f3e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,3 +9,7 @@ and watch out for more specific details in this file. Instead of directly editing `CHANGELOG.md`, please add a file `123.md` in `changelog-entries`, where `123` your pull request number. This helps reduce merge conflicts and we will merge these files at the time we release a new version. + +## Code formatting + +You can format all files with clang-format 11 by running `./tools/format-code.sh`. diff --git a/CouplingDataUser.C b/CouplingDataUser.C index d9d3b4fd..50997740 100644 --- a/CouplingDataUser.C +++ b/CouplingDataUser.C @@ -39,5 +39,5 @@ void preciceAdapter::CouplingDataUser::setLocationsType(std::string locationsTyp // Dummy implementation which can be overwritten in derived classes if required void preciceAdapter::CouplingDataUser::initialize() { - return; + return; } diff --git a/CouplingDataUser.H b/CouplingDataUser.H index bfb337a9..030635b1 100644 --- a/CouplingDataUser.H +++ b/CouplingDataUser.H @@ -11,8 +11,11 @@ class CouplingDataUser { protected: - - enum DataType {scalar, vector}; + enum DataType + { + scalar, + vector + }; //- Type of the coupling data (scalar or vector) DataType dataType_ = scalar; @@ -27,7 +30,6 @@ protected: std::string locationsType_; public: - //- Constructor CouplingDataUser(); @@ -53,14 +55,13 @@ public: virtual void initialize(); //- Write the coupling data to the buffer - virtual void write(double * dataBuffer, bool meshConnectivity, const unsigned int dim) = 0; + virtual void 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; + virtual void read(double* dataBuffer, const unsigned int dim) = 0; //- Destructor virtual ~CouplingDataUser() {} - }; } diff --git a/FF/FF.C b/FF/FF.C index 6d200dc9..6869070a 100644 --- a/FF/FF.C +++ b/FF/FF.C @@ -4,13 +4,11 @@ using namespace Foam; -preciceAdapter::FF::FluidFluid::FluidFluid -( - const Foam::fvMesh& mesh -) -: -mesh_(mesh) -{} +preciceAdapter::FF::FluidFluid::FluidFluid( + const Foam::fvMesh& mesh) +: mesh_(mesh) +{ +} bool preciceAdapter::FF::FluidFluid::configure(const IOdictionary& adapterConfig) { @@ -24,9 +22,7 @@ bool preciceAdapter::FF::FluidFluid::configure(const IOdictionary& adapterConfig // addWriters() and addReaders(). // Check the solver type and determine it if needed if ( - solverType_.compare("compressible") == 0 || - solverType_.compare("incompressible") == 0 - ) + solverType_.compare("compressible") == 0 || solverType_.compare("incompressible") == 0) { DEBUG(adapterInfo("Known solver type: " + solverType_)); } @@ -47,11 +43,11 @@ bool preciceAdapter::FF::FluidFluid::configure(const IOdictionary& adapterConfig bool preciceAdapter::FF::FluidFluid::readConfig(const IOdictionary& adapterConfig) { const dictionary FFdict = adapterConfig.subOrEmptyDict("FF"); - + // Read the solver type (if not specified, it is determined automatically) solverType_ = FFdict.lookupOrDefault("solverType", ""); DEBUG(adapterInfo(" user-defined solver type : " + solverType_)); - + // Read the name of the velocity field (if different) nameU_ = FFdict.lookupOrDefault("nameU", "U"); DEBUG(adapterInfo(" velocity field name : " + nameU_)); @@ -75,70 +71,62 @@ std::string preciceAdapter::FF::FluidFluid::determineSolverType() if (mesh_.foundObject("p")) { - volScalarField p_ = mesh_.lookupObject("p"); - - if (p_.dimensions() == pressureDimensionsCompressible) - solverType = "compressible"; - else if (p_.dimensions() == pressureDimensionsIncompressible) - solverType = "incompressible"; - // TODO: Add special case for multiphase solvers. - // Currently, interFoam is misclassified as "compressible". + volScalarField p_ = mesh_.lookupObject("p"); + + if (p_.dimensions() == pressureDimensionsCompressible) + solverType = "compressible"; + else if (p_.dimensions() == pressureDimensionsIncompressible) + solverType = "incompressible"; + // TODO: Add special case for multiphase solvers. + // Currently, interFoam is misclassified as "compressible". } if (solverType == "unknown") - adapterInfo("Failed to determine the solver type. " - "Please specify your solver type in the FF section of the " - "preciceDict. Known solver types for FF are: " - "incompressible and " - "compressible", - "error"); + adapterInfo("Failed to determine the solver type. " + "Please specify your solver type in the FF section of the " + "preciceDict. Known solver types for FF are: " + "incompressible and " + "compressible", + "error"); DEBUG(adapterInfo("Automatically determined solver type : " + solverType)); return solverType; } -void preciceAdapter::FF::FluidFluid::addWriters(std::string dataName, Interface * interface) +void preciceAdapter::FF::FluidFluid::addWriters(std::string dataName, Interface* interface) { if (dataName.find("VelocityGradient") == 0) { - interface->addCouplingDataWriter - ( + interface->addCouplingDataWriter( dataName, - new VelocityGradient(mesh_, nameU_) - ); + new VelocityGradient(mesh_, nameU_)); DEBUG(adapterInfo("Added writer: Velocity Gradient.")); } else if (dataName.find("Velocity") == 0) { - interface->addCouplingDataWriter - ( + interface->addCouplingDataWriter( dataName, - new Velocity(mesh_, nameU_) - ); + new Velocity(mesh_, nameU_)); DEBUG(adapterInfo("Added writer: Velocity.")); } else if (dataName.find("PressureGradient") == 0) { - interface->addCouplingDataWriter - ( + interface->addCouplingDataWriter( dataName, - new PressureGradient(mesh_, nameP_) - ); + new PressureGradient(mesh_, nameP_)); DEBUG(adapterInfo("Added writer: Pressure Gradient.")); } else if (dataName.find("Pressure") == 0) { - interface->addCouplingDataWriter - ( + interface->addCouplingDataWriter( dataName, - new Pressure(mesh_, nameP_) - ); + new Pressure(mesh_, nameP_)); DEBUG(adapterInfo("Added writer: Pressure.")); } else { - adapterInfo("Unknown data type - cannot add " + dataName +".", "error"); + adapterInfo("Unknown data type - cannot add " + dataName + ".", "error"); } // NOTE: If you want to couple another variable, you need @@ -148,47 +136,39 @@ void preciceAdapter::FF::FluidFluid::addWriters(std::string dataName, Interface // the one provided in the adapter's configuration file. } -void preciceAdapter::FF::FluidFluid::addReaders(std::string dataName, Interface * interface) +void preciceAdapter::FF::FluidFluid::addReaders(std::string dataName, Interface* interface) { if (dataName.find("VelocityGradient") == 0) { - interface->addCouplingDataReader - ( + interface->addCouplingDataReader( dataName, - new VelocityGradient(mesh_, nameU_) - ); + new VelocityGradient(mesh_, nameU_)); DEBUG(adapterInfo("Added reader: VelocityGradient.")); } else if (dataName.find("Velocity") == 0) { - interface->addCouplingDataReader - ( + interface->addCouplingDataReader( dataName, - new Velocity(mesh_, nameU_) - ); + new Velocity(mesh_, nameU_)); DEBUG(adapterInfo("Added reader: Velocity.")); } else if (dataName.find("PressureGradient") == 0) { - interface->addCouplingDataReader - ( + interface->addCouplingDataReader( dataName, - new PressureGradient(mesh_, nameP_) - ); + new PressureGradient(mesh_, nameP_)); DEBUG(adapterInfo("Added reader: Pressure Gradient.")); } else if (dataName.find("Pressure") == 0) { - interface->addCouplingDataReader - ( + interface->addCouplingDataReader( dataName, - new Pressure(mesh_, nameP_) - ); + new Pressure(mesh_, nameP_)); DEBUG(adapterInfo("Added reader: Pressure.")); } else { - adapterInfo("Unknown data type - cannot add " + dataName +".", "error"); + adapterInfo("Unknown data type - cannot add " + dataName + ".", "error"); } // NOTE: If you want to couple another variable, you need @@ -197,4 +177,3 @@ void preciceAdapter::FF::FluidFluid::addReaders(std::string dataName, Interface // The argument of the dataName.compare() needs to match // the one provided in the adapter's configuration file. } - diff --git a/FF/FF.H b/FF/FF.H index 6c3369d3..a8c65582 100644 --- a/FF/FF.H +++ b/FF/FF.H @@ -19,7 +19,6 @@ class FluidFluid { protected: - //- OpenFOAM fvMesh object const Foam::fvMesh& mesh_; @@ -30,7 +29,7 @@ protected: //- Name of the velocity field std::string nameU_ = "U"; - + //- Name of the pressure field std::string nameP_ = "p"; @@ -41,18 +40,17 @@ protected: bool readConfig(const IOdictionary& adapterConfig); public: - //- Constructor FluidFluid(const Foam::fvMesh& mesh); //- Configure bool configure(const IOdictionary& adapterConfig); - + //- Add coupling data writers - void addWriters(std::string dataName, Interface * interface); - + void addWriters(std::string dataName, Interface* interface); + //- Add coupling data readers - void addReaders(std::string dataName, Interface * interface); + void addReaders(std::string dataName, Interface* interface); }; } diff --git a/FF/Pressure.C b/FF/Pressure.C index aa2b6df4..cf2ec770 100644 --- a/FF/Pressure.C +++ b/FF/Pressure.C @@ -2,23 +2,17 @@ using namespace Foam; -preciceAdapter::FF::Pressure::Pressure -( +preciceAdapter::FF::Pressure::Pressure( const Foam::fvMesh& mesh, - const std::string nameP -) -: -p_( - const_cast - ( - &mesh.lookupObject(nameP) - ) -) + const std::string nameP) +: p_( + const_cast( + &mesh.lookupObject(nameP))) { dataType_ = scalar; } -void preciceAdapter::FF::Pressure::write(double * buffer, bool meshConnectivity, const unsigned int dim) +void preciceAdapter::FF::Pressure::write(double* buffer, bool meshConnectivity, const unsigned int dim) { int bufferIndex = 0; @@ -31,14 +25,13 @@ void preciceAdapter::FF::Pressure::write(double * buffer, bool meshConnectivity, forAll(p_->boundaryFieldRef()[patchID], i) { // Copy the pressure into the buffer - buffer[bufferIndex++] - = - p_->boundaryFieldRef()[patchID][i]; + buffer[bufferIndex++] = + p_->boundaryFieldRef()[patchID][i]; } } } -void preciceAdapter::FF::Pressure::read(double * buffer, const unsigned int dim) +void preciceAdapter::FF::Pressure::read(double* buffer, const unsigned int dim) { int bufferIndex = 0; @@ -51,9 +44,8 @@ void preciceAdapter::FF::Pressure::read(double * buffer, const unsigned int dim) forAll(p_->boundaryFieldRef()[patchID], i) { // Set the pressure as the buffer value - p_->boundaryFieldRef()[patchID][i] - = - buffer[bufferIndex++]; + p_->boundaryFieldRef()[patchID][i] = + buffer[bufferIndex++]; } } } diff --git a/FF/Pressure.H b/FF/Pressure.H index cb52cbde..6d9efd4f 100644 --- a/FF/Pressure.H +++ b/FF/Pressure.H @@ -15,24 +15,20 @@ class Pressure : public CouplingDataUser { private: - //- Pressure field - Foam::volScalarField * p_; + Foam::volScalarField* p_; public: - //- Constructor - Pressure - ( + Pressure( const Foam::fvMesh& mesh, - const std::string nameP - ); + const std::string nameP); //- Write the pressure values into the buffer - void write(double * buffer, bool meshConnectivity, const unsigned int dim); + void write(double* buffer, bool meshConnectivity, const unsigned int dim); //- Read the pressure values from the buffer - void read(double * buffer, const unsigned int dim); + void read(double* buffer, const unsigned int dim); }; } diff --git a/FF/PressureGradient.C b/FF/PressureGradient.C index 955b6842..9d46c1a7 100644 --- a/FF/PressureGradient.C +++ b/FF/PressureGradient.C @@ -2,23 +2,17 @@ using namespace Foam; -preciceAdapter::FF::PressureGradient::PressureGradient -( +preciceAdapter::FF::PressureGradient::PressureGradient( const Foam::fvMesh& mesh, - const std::string nameP -) -: -p_( - const_cast - ( - &mesh.lookupObject(nameP) - ) -) + const std::string nameP) +: p_( + const_cast( + &mesh.lookupObject(nameP))) { dataType_ = scalar; } -void preciceAdapter::FF::PressureGradient::write(double * buffer, bool meshConnectivity, const unsigned int dim) +void preciceAdapter::FF::PressureGradient::write(double* buffer, bool meshConnectivity, const unsigned int dim) { int bufferIndex = 0; @@ -28,25 +22,22 @@ void preciceAdapter::FF::PressureGradient::write(double * buffer, bool meshConne int patchID = patchIDs_.at(j); // Get the pressure gradient boundary patch - scalarField gradientPatch - = - refCast - ( - p_->boundaryFieldRef()[patchID] - ).snGrad(); + scalarField gradientPatch = + refCast( + p_->boundaryFieldRef()[patchID]) + .snGrad(); // For every cell of the patch forAll(gradientPatch, i) { // Copy the pressure gradient into the buffer - buffer[bufferIndex++] - = - -gradientPatch[i]; + buffer[bufferIndex++] = + -gradientPatch[i]; } } } -void preciceAdapter::FF::PressureGradient::read(double * buffer, const unsigned int dim) +void preciceAdapter::FF::PressureGradient::read(double* buffer, const unsigned int dim) { int bufferIndex = 0; @@ -56,20 +47,17 @@ void preciceAdapter::FF::PressureGradient::read(double * buffer, const unsigned int patchID = patchIDs_.at(j); // Get the pressure gradient boundary patch - scalarField & gradientPatch - = - refCast - ( - p_->boundaryFieldRef()[patchID] - ).gradient(); + scalarField& gradientPatch = + refCast( + p_->boundaryFieldRef()[patchID]) + .gradient(); // For every cell of the patch forAll(gradientPatch, i) { // Set the pressure gradient as the buffer value - gradientPatch[i] - = - buffer[bufferIndex++]; + gradientPatch[i] = + buffer[bufferIndex++]; } } } diff --git a/FF/PressureGradient.H b/FF/PressureGradient.H index 5ef87c16..05c5a9f9 100644 --- a/FF/PressureGradient.H +++ b/FF/PressureGradient.H @@ -15,24 +15,20 @@ class PressureGradient : public CouplingDataUser { private: - //- Pressure field - Foam::volScalarField * p_; + Foam::volScalarField* p_; public: - //- Constructor - PressureGradient - ( + PressureGradient( const Foam::fvMesh& mesh, - const std::string nameP - ); + const std::string nameP); //- Write the pressure gradient values into the buffer - void write(double * buffer, bool meshConnectivity, const unsigned int dim); + void 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); + void read(double* buffer, const unsigned int dim); }; } diff --git a/FF/Velocity.C b/FF/Velocity.C index aa6fabfa..f0ca557a 100644 --- a/FF/Velocity.C +++ b/FF/Velocity.C @@ -2,23 +2,17 @@ using namespace Foam; -preciceAdapter::FF::Velocity::Velocity -( +preciceAdapter::FF::Velocity::Velocity( const Foam::fvMesh& mesh, - const std::string nameU -) -: -U_( - const_cast - ( - &mesh.lookupObject(nameU) - ) -) + const std::string nameU) +: U_( + const_cast( + &mesh.lookupObject(nameU))) { dataType_ = vector; } -void preciceAdapter::FF::Velocity::write(double * buffer, bool meshConnectivity, const unsigned int dim) +void preciceAdapter::FF::Velocity::write(double* buffer, bool meshConnectivity, const unsigned int dim) { int bufferIndex = 0; @@ -32,25 +26,22 @@ void preciceAdapter::FF::Velocity::write(double * buffer, bool meshConnectivity, { // Copy the velocity into the buffer // x-dimension - buffer[bufferIndex++] - = - U_->boundaryFieldRef()[patchID][i].x(); + buffer[bufferIndex++] = + U_->boundaryFieldRef()[patchID][i].x(); // y-dimension - buffer[bufferIndex++] - = - U_->boundaryFieldRef()[patchID][i].y(); + buffer[bufferIndex++] = + U_->boundaryFieldRef()[patchID][i].y(); - if(dim == 3) + if (dim == 3) // z-dimension - buffer[bufferIndex++] - = - U_->boundaryFieldRef()[patchID][i].z(); + buffer[bufferIndex++] = + U_->boundaryFieldRef()[patchID][i].z(); } } } -void preciceAdapter::FF::Velocity::read(double * buffer, const unsigned int dim) +void preciceAdapter::FF::Velocity::read(double* buffer, const unsigned int dim) { int bufferIndex = 0; @@ -64,20 +55,17 @@ void preciceAdapter::FF::Velocity::read(double * buffer, const unsigned int dim) { // Set the velocity as the buffer value // x-dimension - U_->boundaryFieldRef()[patchID][i].x() - = - buffer[bufferIndex++]; + U_->boundaryFieldRef()[patchID][i].x() = + buffer[bufferIndex++]; // y-dimension - U_->boundaryFieldRef()[patchID][i].y() - = - buffer[bufferIndex++]; + U_->boundaryFieldRef()[patchID][i].y() = + buffer[bufferIndex++]; - if(dim == 3) + if (dim == 3) // z-dimension - U_->boundaryFieldRef()[patchID][i].z() - = - buffer[bufferIndex++]; + U_->boundaryFieldRef()[patchID][i].z() = + buffer[bufferIndex++]; } } } diff --git a/FF/Velocity.H b/FF/Velocity.H index 0326c130..3d78460b 100644 --- a/FF/Velocity.H +++ b/FF/Velocity.H @@ -15,24 +15,20 @@ class Velocity : public CouplingDataUser { private: - //- Velocity field - Foam::volVectorField * U_; + Foam::volVectorField* U_; public: - //- Constructor - Velocity - ( + Velocity( const Foam::fvMesh& mesh, - const std::string nameU - ); + const std::string nameU); //- Write the velocity values into the buffer - void write(double * buffer, bool meshConnectivity, const unsigned int dim); + void write(double* buffer, bool meshConnectivity, const unsigned int dim); //- Read the velocity values from the buffer - void read(double * buffer, const unsigned int dim); + void read(double* buffer, const unsigned int dim); }; } diff --git a/FF/VelocityGradient.C b/FF/VelocityGradient.C index f8efbbec..99247db0 100644 --- a/FF/VelocityGradient.C +++ b/FF/VelocityGradient.C @@ -2,23 +2,17 @@ using namespace Foam; -preciceAdapter::FF::VelocityGradient::VelocityGradient -( +preciceAdapter::FF::VelocityGradient::VelocityGradient( const Foam::fvMesh& mesh, - const std::string nameU -) -: -U_( - const_cast - ( - &mesh.lookupObject(nameU) - ) -) + const std::string nameU) +: U_( + const_cast( + &mesh.lookupObject(nameU))) { dataType_ = vector; } -void preciceAdapter::FF::VelocityGradient::write(double * buffer, bool meshConnectivity, const unsigned int dim) +void preciceAdapter::FF::VelocityGradient::write(double* buffer, bool meshConnectivity, const unsigned int dim) { int bufferIndex = 0; @@ -28,37 +22,32 @@ void preciceAdapter::FF::VelocityGradient::write(double * buffer, bool meshConne int patchID = patchIDs_.at(j); // Get the velocity gradient boundary patch - vectorField gradientPatch - = - refCast - ( - U_->boundaryFieldRef()[patchID] - ).snGrad(); + vectorField gradientPatch = + refCast( + U_->boundaryFieldRef()[patchID]) + .snGrad(); // For every cell of the patch forAll(gradientPatch, i) { // Copy the velocity into the buffer // x-dimension - buffer[bufferIndex++] - = - -gradientPatch[i].x(); + buffer[bufferIndex++] = + -gradientPatch[i].x(); // y-dimension - buffer[bufferIndex++] - = - -gradientPatch[i].y(); + buffer[bufferIndex++] = + -gradientPatch[i].y(); - if(dim == 3) + if (dim == 3) // z-dimension - buffer[bufferIndex++] - = - -gradientPatch[i].z(); + buffer[bufferIndex++] = + -gradientPatch[i].z(); } } } -void preciceAdapter::FF::VelocityGradient::read(double * buffer, const unsigned int dim) +void preciceAdapter::FF::VelocityGradient::read(double* buffer, const unsigned int dim) { int bufferIndex = 0; @@ -68,32 +57,27 @@ void preciceAdapter::FF::VelocityGradient::read(double * buffer, const unsigned int patchID = patchIDs_.at(j); // Get the velocity gradient boundary patch - vectorField & gradientPatch - = - refCast - ( - U_->boundaryFieldRef()[patchID] - ).gradient(); + vectorField& gradientPatch = + refCast( + U_->boundaryFieldRef()[patchID]) + .gradient(); // For every cell of the patch forAll(gradientPatch, i) { // Set the velocity as the buffer value // x-dimension - gradientPatch[i].x() - = - buffer[bufferIndex++]; + gradientPatch[i].x() = + buffer[bufferIndex++]; // y-dimension - gradientPatch[i].y() - = - buffer[bufferIndex++]; + gradientPatch[i].y() = + buffer[bufferIndex++]; - if(dim == 3) + if (dim == 3) // z-dimension - gradientPatch[i].z() - = - buffer[bufferIndex++]; + gradientPatch[i].z() = + buffer[bufferIndex++]; } } } diff --git a/FF/VelocityGradient.H b/FF/VelocityGradient.H index cd025f8d..1f3e9a84 100644 --- a/FF/VelocityGradient.H +++ b/FF/VelocityGradient.H @@ -15,24 +15,20 @@ class VelocityGradient : public CouplingDataUser { private: - //- Velocity field - Foam::volVectorField * U_; + Foam::volVectorField* U_; public: - //- Constructor - VelocityGradient - ( + VelocityGradient( const Foam::fvMesh& mesh, - const std::string nameU - ); + const std::string nameU); //- Write the velocity gradient values into the buffer - void write(double * buffer, bool meshConnectivity, const unsigned int dim); + void write(double* buffer, bool meshConnectivity, const unsigned int dim); //- Read the velocity gradient values from the buffer - void read(double * buffer, const unsigned int dim); + void read(double* buffer, const unsigned int dim); }; } diff --git a/FSI/Displacement.C b/FSI/Displacement.C index bf39f9be..5dfd44f3 100644 --- a/FSI/Displacement.C +++ b/FSI/Displacement.C @@ -3,16 +3,16 @@ using namespace Foam; preciceAdapter::FSI::Displacement::Displacement( - const Foam::fvMesh &mesh, - const std::string namePointDisplacement, - const std::string nameCellDisplacement) - : pointDisplacement_( - const_cast( - &mesh.lookupObject(namePointDisplacement))), - cellDisplacement_( - const_cast( - &mesh.lookupObject(nameCellDisplacement))), - mesh_(mesh) + const Foam::fvMesh& mesh, + const std::string namePointDisplacement, + const std::string nameCellDisplacement) +: pointDisplacement_( + const_cast( + &mesh.lookupObject(namePointDisplacement))), + cellDisplacement_( + const_cast( + &mesh.lookupObject(nameCellDisplacement))), + mesh_(mesh) { dataType_ = vector; } @@ -21,18 +21,18 @@ preciceAdapter::FSI::Displacement::Displacement( // defined later. Hence, we call this method after the CouplingDaaUser has been configured void preciceAdapter::FSI::Displacement::initialize() { - // Initialize appropriate objects for each interface patch, namely the volField and the interpolation object - // this is only necessary for face based FSI - if (this->locationsType_ == "faceCenters" || this->locationsType_ == "faceCentres") - for (unsigned int j = 0; j < patchIDs_.size(); ++j) { - const unsigned int patchID = patchIDs_.at(j); - interpolationObjects_.emplace_back(new primitivePatchInterpolation(mesh_.boundaryMesh()[patchID])); - } + // Initialize appropriate objects for each interface patch, namely the volField and the interpolation object + // this is only necessary for face based FSI + if (this->locationsType_ == "faceCenters" || this->locationsType_ == "faceCentres") + for (unsigned int j = 0; j < patchIDs_.size(); ++j) + { + const unsigned int patchID = patchIDs_.at(j); + interpolationObjects_.emplace_back(new primitivePatchInterpolation(mesh_.boundaryMesh()[patchID])); + } } - -void preciceAdapter::FSI::Displacement::write(double * buffer, bool meshConnectivity, const unsigned int dim) +void preciceAdapter::FSI::Displacement::write(double* buffer, bool meshConnectivity, const unsigned int dim) { /* TODO: Implement * We need two nested for-loops for each patch, @@ -46,43 +46,47 @@ void preciceAdapter::FSI::Displacement::write(double * buffer, bool meshConnecti // return the displacement to use later in the velocity? -void preciceAdapter::FSI::Displacement::read(double * buffer, const unsigned int dim) +void preciceAdapter::FSI::Displacement::read(double* buffer, const unsigned int dim) { for (unsigned int j = 0; j < patchIDs_.size(); j++) { // Get the ID of the current patch const unsigned int patchID = patchIDs_.at(j); - if (this->locationsType_ == "faceCenters" || this->locationsType_ == "faceCentres") { + if (this->locationsType_ == "faceCenters" || this->locationsType_ == "faceCentres") + { - // 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]; - } - // Get a reference to the displacement on the point patch in order to overwrite it - vectorField &pointDisplacementFluidPatch( - refCast( - pointDisplacement_->boundaryFieldRef()[patchID])); + // 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]; + } + // Get a reference to the displacement on the point patch in order to overwrite it + vectorField& pointDisplacementFluidPatch( + refCast( + pointDisplacement_->boundaryFieldRef()[patchID])); - // Overwrite the node based patch using the interpolation objects and the cell based vector field - // Afterwards, continue as usual - pointDisplacementFluidPatch = interpolationObjects_[j]->faceToPointInterpolate(cellDisplacement_->boundaryField()[patchID]); - - } else if (this->locationsType_ == "faceNodes") { + // Overwrite the node based patch using the interpolation objects and the cell based vector field + // Afterwards, continue as usual + pointDisplacementFluidPatch = interpolationObjects_[j]->faceToPointInterpolate(cellDisplacement_->boundaryField()[patchID]); + } + else if (this->locationsType_ == "faceNodes") + { - // Get the displacement on the patch - fixedValuePointPatchVectorField &pointDisplacementFluidPatch( - refCast( - pointDisplacement_->boundaryFieldRef()[patchID])); + // Get the displacement on the patch + fixedValuePointPatchVectorField& pointDisplacementFluidPatch( + refCast( + pointDisplacement_->boundaryFieldRef()[patchID])); - // Overwrite the nodes on the interface directly - forAll (pointDisplacement_->boundaryFieldRef()[patchID], i) { - for (unsigned int d = 0; d < dim; ++d) - pointDisplacementFluidPatch[i][d] = buffer[i * dim + d]; - } + // Overwrite the nodes on the interface directly + forAll(pointDisplacement_->boundaryFieldRef()[patchID], i) + { + for (unsigned int d = 0; d < dim; ++d) + pointDisplacementFluidPatch[i][d] = buffer[i * dim + d]; + } } } } diff --git a/FSI/Displacement.H b/FSI/Displacement.H index 783a3f2f..a6ce22c3 100644 --- a/FSI/Displacement.H +++ b/FSI/Displacement.H @@ -17,33 +17,29 @@ class Displacement : public CouplingDataUser { private: - // Displacement pointVectorField - Foam::pointVectorField * pointDisplacement_; + Foam::pointVectorField* pointDisplacement_; // cellDisplacement field - Foam::volVectorField *cellDisplacement_; + Foam::volVectorField* cellDisplacement_; const Foam::fvMesh& mesh_; // NOTE: this allocation could be avoided in case we directly write to the // Needs to be a pointer since the class disables assignment and copy constructors - std::vector interpolationObjects_; - - public: + std::vector interpolationObjects_; +public: //- Constructor - Displacement - ( + Displacement( const Foam::fvMesh& mesh, const std::string namePointDisplacement, - const std::string nameCellDisplacement - ); + const std::string nameCellDisplacement); //- Write the displacement values into the buffer - void write(double * buffer, bool meshConnectivity, const unsigned int dim); + void write(double* buffer, bool meshConnectivity, const unsigned int dim); //- Read the displacement values from the buffer - void read(double * buffer, const unsigned int dim); + void read(double* buffer, const unsigned int dim); //- We need to initialize the cell-based vector and the interpolation object // in case we want to use the faceCenter location for the coupling diff --git a/FSI/DisplacementDelta.C b/FSI/DisplacementDelta.C index 813b3119..c9c3c0db 100644 --- a/FSI/DisplacementDelta.C +++ b/FSI/DisplacementDelta.C @@ -3,16 +3,16 @@ using namespace Foam; preciceAdapter::FSI::DisplacementDelta::DisplacementDelta( - const Foam::fvMesh &mesh, - const std::string namePointDisplacement, - const std::string nameCellDisplacement) - : pointDisplacement_( - const_cast( - &mesh.lookupObject(namePointDisplacement))), - cellDisplacement_( - const_cast( - &mesh.lookupObject(nameCellDisplacement))), - mesh_(mesh) + const Foam::fvMesh& mesh, + const std::string namePointDisplacement, + const std::string nameCellDisplacement) +: pointDisplacement_( + const_cast( + &mesh.lookupObject(namePointDisplacement))), + cellDisplacement_( + const_cast( + &mesh.lookupObject(nameCellDisplacement))), + mesh_(mesh) { dataType_ = vector; } @@ -21,18 +21,18 @@ preciceAdapter::FSI::DisplacementDelta::DisplacementDelta( // defined later. Hence, we call this method after the CouplingDaaUser has been configured void preciceAdapter::FSI::DisplacementDelta::initialize() { - // Initialize appropriate objects for each interface patch, namely the volField and the interpolation object - // this is only necessary for face based FSI - if (this->locationsType_ == "faceCenters" || this->locationsType_ == "faceCentres") - for (unsigned int j = 0; j < patchIDs_.size(); ++j) { - const unsigned int patchID = patchIDs_.at(j); - interpolationObjects_.emplace_back(new primitivePatchInterpolation(mesh_.boundaryMesh()[patchID])); - } + // Initialize appropriate objects for each interface patch, namely the volField and the interpolation object + // this is only necessary for face based FSI + if (this->locationsType_ == "faceCenters" || this->locationsType_ == "faceCentres") + for (unsigned int j = 0; j < patchIDs_.size(); ++j) + { + const unsigned int patchID = patchIDs_.at(j); + interpolationObjects_.emplace_back(new primitivePatchInterpolation(mesh_.boundaryMesh()[patchID])); + } } - -void preciceAdapter::FSI::DisplacementDelta::write(double * buffer, bool meshConnectivity, const unsigned int dim) +void preciceAdapter::FSI::DisplacementDelta::write(double* buffer, bool meshConnectivity, const unsigned int dim) { /* TODO: Implement * We need two nested for-loops for each patch, @@ -45,45 +45,49 @@ void preciceAdapter::FSI::DisplacementDelta::write(double * buffer, bool meshCon } // return the displacement to use later in the velocity? -void preciceAdapter::FSI::DisplacementDelta::read(double * buffer, const unsigned int dim) +void preciceAdapter::FSI::DisplacementDelta::read(double* buffer, const unsigned int dim) { for (unsigned int j = 0; j < patchIDs_.size(); j++) { // Get the ID of the current patch const unsigned int patchID = patchIDs_.at(j); - if (this->locationsType_ == "faceCenters" || this->locationsType_ == "faceCentres") { + if (this->locationsType_ == "faceCenters" || this->locationsType_ == "faceCentres") + { - // 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 - // For DisplacementDelta, set absolute values here and sum the interpolated values up to the point field - // since the temporary field in this class is not reloaded in the implicit coupling - forAll (cellDisplacement_->boundaryField()[patchID], i) { - for (unsigned int d = 0; d < dim; ++d) - cellDisplacement_->boundaryFieldRef()[patchID][i][d] = buffer[i * dim + d]; - } - // Get a reference to the displacement on the point patch in order to overwrite it - vectorField &pointDisplacementFluidPatch( - refCast( - pointDisplacement_->boundaryFieldRef()[patchID])); + // 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 + // For DisplacementDelta, set absolute values here and sum the interpolated values up to the point field + // since the temporary field in this class is not reloaded in the implicit coupling + forAll(cellDisplacement_->boundaryField()[patchID], i) + { + for (unsigned int d = 0; d < dim; ++d) + cellDisplacement_->boundaryFieldRef()[patchID][i][d] = buffer[i * dim + d]; + } + // Get a reference to the displacement on the point patch in order to overwrite it + vectorField& pointDisplacementFluidPatch( + refCast( + pointDisplacement_->boundaryFieldRef()[patchID])); - // Overwrite the node based patch using the interpolation objects and the cell based vector field - // Afterwards, continue as usual - pointDisplacementFluidPatch += interpolationObjects_[j]->faceToPointInterpolate(cellDisplacement_->boundaryField()[patchID]); - - } else if (this->locationsType_ == "faceNodes") { + // Overwrite the node based patch using the interpolation objects and the cell based vector field + // Afterwards, continue as usual + pointDisplacementFluidPatch += interpolationObjects_[j]->faceToPointInterpolate(cellDisplacement_->boundaryField()[patchID]); + } + else if (this->locationsType_ == "faceNodes") + { - // Get the displacement on the patch - fixedValuePointPatchVectorField &pointDisplacementFluidPatch( - refCast( - pointDisplacement_->boundaryFieldRef()[patchID])); + // Get the displacement on the patch + fixedValuePointPatchVectorField& pointDisplacementFluidPatch( + refCast( + pointDisplacement_->boundaryFieldRef()[patchID])); - // Overwrite the nodes on the interface directly - forAll (pointDisplacement_->boundaryFieldRef()[patchID], i) { - for (unsigned int d = 0; d < dim; ++d) - pointDisplacementFluidPatch[i][d] += buffer[i * dim + d]; - } + // Overwrite the nodes on the interface directly + forAll(pointDisplacement_->boundaryFieldRef()[patchID], i) + { + for (unsigned int d = 0; d < dim; ++d) + pointDisplacementFluidPatch[i][d] += buffer[i * dim + d]; + } } } } diff --git a/FSI/DisplacementDelta.H b/FSI/DisplacementDelta.H index a271deee..24317de6 100644 --- a/FSI/DisplacementDelta.H +++ b/FSI/DisplacementDelta.H @@ -17,33 +17,29 @@ class DisplacementDelta : public CouplingDataUser { private: - // Displacement pointVectorField - Foam::pointVectorField * pointDisplacement_; + Foam::pointVectorField* pointDisplacement_; // cellDisplacement field - Foam::volVectorField *cellDisplacement_; + Foam::volVectorField* cellDisplacement_; const Foam::fvMesh& mesh_; // NOTE: this allocation could be avoided in case we directly write to the // Needs to be a pointer since the class disables assignment and copy constructors - std::vector interpolationObjects_; - - public: + std::vector interpolationObjects_; +public: //- Constructor - DisplacementDelta - ( + DisplacementDelta( const Foam::fvMesh& mesh, const std::string namePointDisplacement, - const std::string nameCellDisplacement - ); + const std::string nameCellDisplacement); //- Write the displacementDelta values into the buffer - void write(double * buffer, bool meshConnectivity, const unsigned int dim); + void write(double* buffer, bool meshConnectivity, const unsigned int dim); //- Read the displacementDelta values from the buffer - void read(double * buffer, const unsigned int dim); + void read(double* buffer, const unsigned int dim); //- We need to initialize the cell-based vector and the interpolation object // in case we want to use the faceCenter location for the coupling diff --git a/FSI/FSI.C b/FSI/FSI.C index 22ed15a1..85a36de9 100644 --- a/FSI/FSI.C +++ b/FSI/FSI.C @@ -4,15 +4,13 @@ using namespace Foam; -preciceAdapter::FSI::FluidStructureInteraction::FluidStructureInteraction -( +preciceAdapter::FSI::FluidStructureInteraction::FluidStructureInteraction( const Foam::fvMesh& mesh, - const Foam::Time& runTime -) -: -mesh_(mesh), -runTime_(runTime) -{} + const Foam::Time& runTime) +: mesh_(mesh), + runTime_(runTime) +{ +} bool preciceAdapter::FSI::FluidStructureInteraction::configure(const IOdictionary& adapterConfig) { @@ -26,9 +24,7 @@ bool preciceAdapter::FSI::FluidStructureInteraction::configure(const IOdictionar // addWriters() and addReaders(). // Check the solver type and determine it if needed if ( - solverType_.compare("compressible") == 0 || - solverType_.compare("incompressible") == 0 - ) + solverType_.compare("compressible") == 0 || solverType_.compare("incompressible") == 0) { DEBUG(adapterInfo("Known solver type: " + solverType_)); } @@ -49,7 +45,7 @@ bool preciceAdapter::FSI::FluidStructureInteraction::configure(const IOdictionar bool preciceAdapter::FSI::FluidStructureInteraction::readConfig(const IOdictionary& adapterConfig) { const dictionary FSIdict = adapterConfig.subOrEmptyDict("FSI"); - + // Read the solver type (if not specified, it is determined automatically) solverType_ = FSIdict.lookupOrDefault("solverType", ""); DEBUG(adapterInfo(" user-defined solver type : " + solverType_)); @@ -82,21 +78,21 @@ std::string preciceAdapter::FSI::FluidStructureInteraction::determineSolverType( if (mesh_.foundObject("p")) { - volScalarField p_ = mesh_.lookupObject("p"); + volScalarField p_ = mesh_.lookupObject("p"); - if (p_.dimensions() == pressureDimensionsCompressible) - solverType = "compressible"; - else if (p_.dimensions() == pressureDimensionsIncompressible) - solverType = "incompressible"; + if (p_.dimensions() == pressureDimensionsCompressible) + solverType = "compressible"; + else if (p_.dimensions() == pressureDimensionsIncompressible) + solverType = "incompressible"; } if (solverType == "unknown") - adapterInfo("Failed to determine the solver type. " - "Please specify your solver type in the FSI section of the " - "preciceDict. Known solver types for FSI are: " - "incompressible and " - "compressible", - "error"); + adapterInfo("Failed to determine the solver type. " + "Please specify your solver type in the FSI section of the " + "preciceDict. Known solver types for FSI are: " + "incompressible and " + "compressible", + "error"); DEBUG(adapterInfo("Automatically determined solver type : " + solverType)); @@ -104,43 +100,37 @@ std::string preciceAdapter::FSI::FluidStructureInteraction::determineSolverType( } -void preciceAdapter::FSI::FluidStructureInteraction::addWriters(std::string dataName, Interface * interface) +void preciceAdapter::FSI::FluidStructureInteraction::addWriters(std::string dataName, Interface* interface) { if (dataName.find("Force") == 0) - { - interface->addCouplingDataWriter - ( - dataName, - new Force(mesh_, solverType_) /* TODO: Add any other arguments here */ - ); - DEBUG(adapterInfo("Added writer: Force.")); - } - else if (dataName.find("DisplacementDelta") == 0) { - interface->addCouplingDataWriter - ( + interface->addCouplingDataWriter( dataName, - new DisplacementDelta(mesh_, namePointDisplacement_, nameCellDisplacement_) + new Force(mesh_, solverType_) /* TODO: Add any other arguments here */ ); + DEBUG(adapterInfo("Added writer: Force.")); + } + else if (dataName.find("DisplacementDelta") == 0) + { + interface->addCouplingDataWriter( + dataName, + new DisplacementDelta(mesh_, namePointDisplacement_, nameCellDisplacement_)); DEBUG(adapterInfo("Added writer: DisplacementDelta.")); } else if (dataName.find("Displacement") == 0) { - interface->addCouplingDataWriter - ( + interface->addCouplingDataWriter( dataName, - new Displacement(mesh_, namePointDisplacement_, nameCellDisplacement_) - ); + new Displacement(mesh_, namePointDisplacement_, nameCellDisplacement_)); DEBUG(adapterInfo("Added writer: Displacement.")); } - else if(dataName.find("Stress") == 0) + else if (dataName.find("Stress") == 0) { - interface->addCouplingDataWriter - ( - dataName, - new Stress(mesh_, solverType_) /* TODO: Add any other arguments here */ - ); - DEBUG(adapterInfo("Added writer: Stress.")); + interface->addCouplingDataWriter( + dataName, + new Stress(mesh_, solverType_) /* TODO: Add any other arguments here */ + ); + DEBUG(adapterInfo("Added writer: Stress.")); } // NOTE: If you want to couple another variable, you need @@ -150,12 +140,11 @@ void preciceAdapter::FSI::FluidStructureInteraction::addWriters(std::string data // the one provided in the adapter's configuration file. } -void preciceAdapter::FSI::FluidStructureInteraction::addReaders(std::string dataName, Interface * interface) +void preciceAdapter::FSI::FluidStructureInteraction::addReaders(std::string dataName, Interface* interface) { if (dataName.find("Force") == 0) { - interface->addCouplingDataReader - ( + interface->addCouplingDataReader( dataName, new Force(mesh_, solverType_) /* TODO: Add any other arguments here */ ); @@ -163,30 +152,25 @@ void preciceAdapter::FSI::FluidStructureInteraction::addReaders(std::string data } else if (dataName.find("DisplacementDelta") == 0) { - interface->addCouplingDataReader - ( + interface->addCouplingDataReader( dataName, - new DisplacementDelta(mesh_, namePointDisplacement_, nameCellDisplacement_) - ); + new DisplacementDelta(mesh_, namePointDisplacement_, nameCellDisplacement_)); DEBUG(adapterInfo("Added reader: DisplacementDelta.")); } else if (dataName.find("Displacement") == 0) { - interface->addCouplingDataReader - ( + interface->addCouplingDataReader( dataName, - new Displacement(mesh_, namePointDisplacement_, nameCellDisplacement_) - ); + new Displacement(mesh_, namePointDisplacement_, nameCellDisplacement_)); DEBUG(adapterInfo("Added reader: Displacement.")); } - else if(dataName.find("Stress") == 0) + else if (dataName.find("Stress") == 0) { - interface->addCouplingDataReader - ( - dataName, - new Stress(mesh_, solverType_) /* TODO: Add any other arguments here */ - ); - DEBUG(adapterInfo("Added reader: Stress.")); + interface->addCouplingDataReader( + dataName, + new Stress(mesh_, solverType_) /* TODO: Add any other arguments here */ + ); + DEBUG(adapterInfo("Added reader: Stress.")); } // NOTE: If you want to couple another variable, you need diff --git a/FSI/FSI.H b/FSI/FSI.H index 0ff8adc8..237a0a9a 100644 --- a/FSI/FSI.H +++ b/FSI/FSI.H @@ -19,16 +19,15 @@ class FluidStructureInteraction { protected: - //- OpenFOAM fvMesh object const Foam::fvMesh& mesh_; //- OpenFOAM Time object (we need to access the timestep to compute the pointMotionU) const Foam::Time& runTime_; - + //- Solver type std::string solverType_ = "none"; - + //- Name of the pointDisplacement field std::string namePointDisplacement_ = "pointDisplacement"; @@ -42,7 +41,6 @@ protected: */ protected: - //- Determine the solver type std::string determineSolverType(); @@ -50,7 +48,6 @@ protected: bool readConfig(const IOdictionary& adapterConfig); public: - //- Constructor // We need also the runTime to access the timeName and the deltaT FluidStructureInteraction(const Foam::fvMesh& mesh, const Foam::Time& runTime); @@ -59,10 +56,10 @@ public: bool configure(const IOdictionary& adapterConfig); //- Add coupling data writers - void addWriters(std::string dataName, Interface * interface); + void addWriters(std::string dataName, Interface* interface); //- Add coupling data readers - void addReaders(std::string dataName, Interface * interface); + void addReaders(std::string dataName, Interface* interface); }; } diff --git a/FSI/Force.C b/FSI/Force.C index bab8c484..480ba9f1 100644 --- a/FSI/Force.C +++ b/FSI/Force.C @@ -2,48 +2,39 @@ using namespace Foam; -preciceAdapter::FSI::Force::Force -( +preciceAdapter::FSI::Force::Force( const Foam::fvMesh& mesh, - const std::string solverType -) -: -ForceBase(mesh,solverType) + const std::string solverType) +: ForceBase(mesh, solverType) { - Force_ = new volVectorField - ( - IOobject - ( + Force_ = new volVectorField( + IOobject( "Force", mesh_.time().timeName(), mesh, IOobject::NO_READ, - IOobject::AUTO_WRITE - ), + IOobject::AUTO_WRITE), mesh, - dimensionedVector - ( + dimensionedVector( "fdim", - dimensionSet(1,1,-2,0,0,0,0), - Foam::vector::zero - ) - ); + dimensionSet(1, 1, -2, 0, 0, 0, 0), + Foam::vector::zero)); } -void preciceAdapter::FSI::Force::write(double * buffer, bool meshConnectivity, const unsigned int dim) +void preciceAdapter::FSI::Force::write(double* buffer, bool meshConnectivity, const unsigned int dim) { - this->writeToBuffer(buffer, *Force_, dim); + this->writeToBuffer(buffer, *Force_, dim); } -void preciceAdapter::FSI::Force::read(double * buffer, const unsigned int dim) +void preciceAdapter::FSI::Force::read(double* buffer, const unsigned int dim) { this->readFromBuffer(buffer); } vectorField preciceAdapter::FSI::Force::getFaceVectors(const unsigned int patchID) const { - // Normal vectors multiplied by face area - return mesh_.boundary()[patchID].Sf(); + // Normal vectors multiplied by face area + return mesh_.boundary()[patchID].Sf(); } preciceAdapter::FSI::Force::~Force() diff --git a/FSI/Force.H b/FSI/Force.H index 6c6f4583..d18f75a1 100644 --- a/FSI/Force.H +++ b/FSI/Force.H @@ -12,24 +12,20 @@ namespace FSI class Force : public ForceBase { private: - //- Force field - Foam::volVectorField * Force_; + Foam::volVectorField* Force_; public: - //- Constructor - Force - ( + Force( const Foam::fvMesh& mesh, - const std::string solverType - ); + const std::string solverType); //- Write the forces values into the buffer - void write(double * buffer, bool meshConnectivity, const unsigned int dim); + void write(double* buffer, bool meshConnectivity, const unsigned int dim); //- Read the forces values from the buffer - void read(double * buffer, const unsigned int dim); + void read(double* buffer, const unsigned int dim); //- Returns the normal vectors multiplied by the face area Foam::vectorField getFaceVectors(const unsigned int patchID) const override; diff --git a/FSI/ForceBase.C b/FSI/ForceBase.C index 2303e183..13989096 100644 --- a/FSI/ForceBase.C +++ b/FSI/ForceBase.C @@ -3,14 +3,11 @@ using namespace Foam; -preciceAdapter::FSI::ForceBase::ForceBase -( +preciceAdapter::FSI::ForceBase::ForceBase( const Foam::fvMesh& mesh, - const std::string solverType -) -: -mesh_(mesh), -solverType_(solverType) + const std::string solverType) +: mesh_(mesh), + solverType_(solverType) { //What about type "basic"? if (solverType_.compare("incompressible") != 0 && solverType_.compare("compressible") != 0) @@ -33,32 +30,25 @@ Foam::tmp preciceAdapter::FSI::ForceBase::devRhoReff() if (mesh_.foundObject(cmpTurbModel::propertiesName)) { - const cmpTurbModel & turb - ( - mesh_.lookupObject(cmpTurbModel::propertiesName) - ); + const cmpTurbModel& turb( + mesh_.lookupObject(cmpTurbModel::propertiesName)); return turb.devRhoReff(); - } else if (mesh_.foundObject(icoTurbModel::propertiesName)) { - const incompressible::turbulenceModel& turb - ( - mesh_.lookupObject(icoTurbModel::propertiesName) - ); + const incompressible::turbulenceModel& turb( + mesh_.lookupObject(icoTurbModel::propertiesName)); - return rho()*turb.devReff(); + return rho() * turb.devReff(); } else { // For laminar flows get the velocity - const volVectorField & U - ( - mesh_.lookupObject("U") - ); + const volVectorField& U( + mesh_.lookupObject("U")); - return -mu()*dev(twoSymm(fvc::grad(U))); + return -mu() * dev(twoSymm(fvc::grad(U))); } } @@ -77,23 +67,17 @@ Foam::tmp preciceAdapter::FSI::ForceBase::rho() const const dictionary& FSIDict = mesh_.lookupObject("preciceDict").subOrEmptyDict("FSI"); - return tmp - ( - new volScalarField - ( - IOobject - ( + return tmp( + new volScalarField( + IOobject( "rho", mesh_.time().timeName(), mesh_, IOobject::NO_READ, - IOobject::NO_WRITE - ), + IOobject::NO_WRITE), mesh_, dimensionedScalar(FSIDict.lookup("rho")) // We use this deprecated lookup() for backwards compatibility - ) - ); - + )); } else { @@ -114,10 +98,8 @@ Foam::tmp preciceAdapter::FSI::ForceBase::mu() const typedef immiscibleIncompressibleTwoPhaseMixture iitpMixture; if (mesh_.foundObject("mixture")) { - const iitpMixture& mixture - ( - mesh_.lookupObject("mixture") - ); + const iitpMixture& mixture( + mesh_.lookupObject("mixture")); return mixture.mu(); } @@ -129,15 +111,10 @@ Foam::tmp preciceAdapter::FSI::ForceBase::mu() const dimensionedScalar nu(FSIDict.lookup("nu")); // We use this deprecated lookup() for backwards compatibility - return tmp - ( - new volScalarField - ( - nu * rho() - ) - ); + return tmp( + new volScalarField( + nu * rho())); } - } else if (solverType_.compare("compressible") == 0) { @@ -153,69 +130,75 @@ Foam::tmp preciceAdapter::FSI::ForceBase::mu() const } } -void preciceAdapter::FSI::ForceBase::writeToBuffer(double * buffer, - volVectorField & forceField, +void preciceAdapter::FSI::ForceBase::writeToBuffer(double* buffer, + volVectorField& forceField, const unsigned int dim) const { - // Compute forces. See the Forces function object. - // Stress tensor boundary field - tmp tdevRhoReff(devRhoReff()); - const volSymmTensorField::Boundary &devRhoReffb( - tdevRhoReff().boundaryField()); - - // Density boundary field - tmp trho(rho()); - const volScalarField::Boundary &rhob = - trho().boundaryField(); - - // Pressure boundary field - tmp tp = mesh_.lookupObject("p"); - const volScalarField::Boundary &pb( - tp().boundaryField()); - - // For every boundary patch of the interface - for (const label patchID : patchIDs_) { - - const auto &surface = getFaceVectors(patchID); - - // Pressure forces - // FIXME: We need to substract the reference pressure for incompressible calculations - if (solverType_.compare("incompressible") == 0) { - forceField.boundaryFieldRef()[patchID] = - surface * pb[patchID] * rhob[patchID]; - } else if (solverType_.compare("compressible") == 0) { - forceField.boundaryFieldRef()[patchID] = - surface * pb[patchID]; - } else { - FatalErrorInFunction - << "Forces calculation does only support " - << "compressible or incompressible solver type." - << exit(FatalError); - } + // Compute forces. See the Forces function object. + // Stress tensor boundary field + tmp tdevRhoReff(devRhoReff()); + const volSymmTensorField::Boundary& devRhoReffb( + tdevRhoReff().boundaryField()); + + // Density boundary field + tmp trho(rho()); + const volScalarField::Boundary& rhob = + trho().boundaryField(); + + // Pressure boundary field + tmp tp = mesh_.lookupObject("p"); + const volScalarField::Boundary& pb( + tp().boundaryField()); + + // For every boundary patch of the interface + for (const label patchID : patchIDs_) + { - // Viscous forces - forceField.boundaryFieldRef()[patchID] += - surface & devRhoReffb[patchID]; + const auto& surface = getFaceVectors(patchID); - // Write the forces to the preCICE buffer - // For every cell of the patch - forAll(forceField.boundaryField()[patchID], i) - { - for (unsigned int d = 0; d < dim; ++d) - buffer[i * dim + d] = - forceField.boundaryField()[patchID][i][d]; + // Pressure forces + // FIXME: We need to substract the reference pressure for incompressible calculations + if (solverType_.compare("incompressible") == 0) + { + forceField.boundaryFieldRef()[patchID] = + surface * pb[patchID] * rhob[patchID]; + } + else if (solverType_.compare("compressible") == 0) + { + forceField.boundaryFieldRef()[patchID] = + surface * pb[patchID]; + } + else + { + FatalErrorInFunction + << "Forces calculation does only support " + << "compressible or incompressible solver type." + << exit(FatalError); + } + + // Viscous forces + forceField.boundaryFieldRef()[patchID] += + surface & devRhoReffb[patchID]; + + // Write the forces to the preCICE buffer + // For every cell of the patch + forAll(forceField.boundaryField()[patchID], i) + { + for (unsigned int d = 0; d < dim; ++d) + buffer[i * dim + d] = + forceField.boundaryField()[patchID][i][d]; + } } - } } -void preciceAdapter::FSI::ForceBase::readFromBuffer(double *buffer) const +void preciceAdapter::FSI::ForceBase::readFromBuffer(double* buffer) const { - /* TODO: Implement + /* TODO: Implement * We need two nested for-loops for each patch, * the outer for the locations and the inner for the dimensions. * See the preCICE readBlockVectorData() implementation. */ - FatalErrorInFunction - << "Reading forces is not supported." - << exit(FatalError); + FatalErrorInFunction + << "Reading forces is not supported." + << exit(FatalError); } diff --git a/FSI/ForceBase.H b/FSI/ForceBase.H index f8fb47dd..a30c3bb4 100644 --- a/FSI/ForceBase.H +++ b/FSI/ForceBase.H @@ -34,19 +34,16 @@ protected: const std::string solverType_; public: - //- Constructor - ForceBase - ( + ForceBase( const Foam::fvMesh& mesh, - const std::string solverType - ); + const std::string solverType); - void writeToBuffer(double * buffer, - Foam::volVectorField & forceField, - const unsigned int dim) const; + void writeToBuffer(double* buffer, + Foam::volVectorField& forceField, + const unsigned int dim) const; - void readFromBuffer(double *buffer) const; + void readFromBuffer(double* buffer) const; virtual Foam::vectorField getFaceVectors(const unsigned int patchID) const = 0; }; diff --git a/FSI/Stress.C b/FSI/Stress.C index 946b88fb..cec69afe 100644 --- a/FSI/Stress.C +++ b/FSI/Stress.C @@ -2,40 +2,31 @@ using namespace Foam; -preciceAdapter::FSI::Stress::Stress -( +preciceAdapter::FSI::Stress::Stress( const Foam::fvMesh& mesh, - const std::string solverType -) -: -ForceBase(mesh,solverType) + const std::string solverType) +: ForceBase(mesh, solverType) { - Stress_ = new volVectorField - ( - IOobject - ( + Stress_ = new volVectorField( + IOobject( "Stress", mesh_.time().timeName(), mesh, IOobject::NO_READ, - IOobject::AUTO_WRITE - ), + IOobject::AUTO_WRITE), mesh, - dimensionedVector - ( + dimensionedVector( "pdim", - dimensionSet(1,-1,-2,0,0,0,0), - Foam::vector::zero - ) - ); + dimensionSet(1, -1, -2, 0, 0, 0, 0), + Foam::vector::zero)); } -void preciceAdapter::FSI::Stress::write(double * buffer, bool meshConnectivity, const unsigned int dim) +void preciceAdapter::FSI::Stress::write(double* buffer, bool meshConnectivity, const unsigned int dim) { - this->writeToBuffer(buffer, *Stress_, dim); + this->writeToBuffer(buffer, *Stress_, dim); } -void preciceAdapter::FSI::Stress::read(double * buffer, const unsigned int dim) +void preciceAdapter::FSI::Stress::read(double* buffer, const unsigned int dim) { this->readFromBuffer(buffer); } diff --git a/FSI/Stress.H b/FSI/Stress.H index 2a4e6a21..1f93e2af 100644 --- a/FSI/Stress.H +++ b/FSI/Stress.H @@ -13,26 +13,24 @@ namespace FSI // cell face. Thus, a consistent quantity. Calculation concept has been copied // from the force module, but the scaled version here is commonly used in FEM // applications. -class Stress : public ForceBase { +class Stress : public ForceBase +{ private: //- Stress field - Foam::volVectorField * Stress_; + Foam::volVectorField* Stress_; public: - //- Constructor - Stress - ( - const Foam::fvMesh& mesh, - const std::string solverType - ); + Stress( + const Foam::fvMesh& mesh, + const std::string solverType); //- Write the stress values into the buffer - void write(double * buffer, bool meshConnectivity, const unsigned int dim); + void write(double* buffer, bool meshConnectivity, const unsigned int dim); //- Read the stress values from the buffer - void read(double * buffer, const unsigned int dim); + void read(double* buffer, const unsigned int dim); //- Returns the face normal vectors (no multiplication by area) Foam::vectorField getFaceVectors(const unsigned int patchID) const override; diff --git a/Interface.C b/Interface.C index 1a479aef..7bdc4754 100644 --- a/Interface.C +++ b/Interface.C @@ -5,34 +5,32 @@ using namespace Foam; -preciceAdapter::Interface::Interface -( - precice::SolverInterface & precice, +preciceAdapter::Interface::Interface( + precice::SolverInterface& precice, const fvMesh& mesh, std::string meshName, std::string locationsType, std::vector patchNames, - bool meshConnectivity -) -: -precice_(precice), -meshName_(meshName), -locationsType_(locationsType), -patchNames_(patchNames), -meshConnectivity_(meshConnectivity) + bool meshConnectivity) +: precice_(precice), + meshName_(meshName), + locationsType_(locationsType), + patchNames_(patchNames), + meshConnectivity_(meshConnectivity) { // Get the meshID from preCICE meshID_ = precice_.getMeshID(meshName_); dim_ = precice_.getDimensions(); - if( dim_ == 2 && meshConnectivity_ == true) + if (dim_ == 2 && meshConnectivity_ == true) { DEBUG(adapterInfo("meshConnectivity is currently only supported for 3D cases. \n" "You might set up a 3D case and restrict the 3rd dimension by z-dead = true. \n" - "Have a look in the adapter documentation for detailed information.", "warning")); + "Have a look in the adapter documentation for detailed information.", + "warning")); } - + // For every patch that participates in the coupling for (uint j = 0; j < patchNames.size(); j++) { @@ -43,10 +41,10 @@ meshConnectivity_(meshConnectivity) if (patchID == -1) { FatalErrorInFunction - << "ERROR: Patch '" - << patchNames.at(j) - << "' does not exist." - << exit(FatalError); + << "ERROR: Patch '" + << patchNames.at(j) + << "' does not exist." + << exit(FatalError); } // Add the patch in the list @@ -95,42 +93,45 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh) // Assign the (x,y,z) locations to the vertices for (int i = 0; i < faceCenters.size(); i++) - for (unsigned int d = 0; d < dim_; ++d) - vertices[verticesIndex++] = faceCenters[i][d]; + for (unsigned int d = 0; d < dim_; ++d) + vertices[verticesIndex++] = faceCenters[i][d]; // Check if we are in the right layer in case of preCICE dimension 2 // If there is at least one node with a different z-coordinate, then the (2D) geometry is not on the xy-plane, as required. - if (dim_ == 2) { - const pointField faceNodes = - mesh.boundaryMesh()[patchIDs_.at(j)].localPoints(); - //Allocate memory for z-coordinates - std::array z_location({0, 0}); - constexpr unsigned int z_axis = 2; - - // Find out about the existing planes - // Store z-coordinate of the first layer - z_location[0] = faceNodes[0][z_axis]; - // Go through the remaining points until we find the second z-coordinate - // and store it (there are only two allowed in case we are in the xy-layer) - for (int i = 0; i < faceNodes.size(); i++) { - if (z_location[0] == faceNodes[i][z_axis]) - continue; - else { - z_location[1] = faceNodes[i][z_axis]; - break; + if (dim_ == 2) + { + const pointField faceNodes = + mesh.boundaryMesh()[patchIDs_.at(j)].localPoints(); + //Allocate memory for z-coordinates + std::array z_location({0, 0}); + constexpr unsigned int z_axis = 2; + + // Find out about the existing planes + // Store z-coordinate of the first layer + z_location[0] = faceNodes[0][z_axis]; + // Go through the remaining points until we find the second z-coordinate + // and store it (there are only two allowed in case we are in the xy-layer) + for (int i = 0; i < faceNodes.size(); i++) + { + if (z_location[0] == faceNodes[i][z_axis]) + continue; + else + { + z_location[1] = faceNodes[i][z_axis]; + break; + } } - } - - // Check if the z-coordinates of all nodes match the z-coordinates we have collected above - for (int i = 0; i < faceNodes.size(); i++) - if (z_location[0] == faceNodes[i][z_axis] || z_location[1] == faceNodes[i][z_axis]) - continue; - else - FatalErrorInFunction - << "It seems like you are using preCICE in 2D and your geometry is not located int the xy-plane. " - "The OpenFOAM adapter implementation supports preCICE 2D cases only with the z-axis as out-of-plane direction." - "Please rotate your geometry so that the geometry is located in the xy-plane." - << exit(FatalError); + + // Check if the z-coordinates of all nodes match the z-coordinates we have collected above + for (int i = 0; i < faceNodes.size(); i++) + if (z_location[0] == faceNodes[i][z_axis] || z_location[1] == faceNodes[i][z_axis]) + continue; + else + FatalErrorInFunction + << "It seems like you are using preCICE in 2D and your geometry is not located int the xy-plane. " + "The OpenFOAM adapter implementation supports preCICE 2D cases only with the z-axis as out-of-plane direction." + "Please rotate your geometry so that the geometry is located in the xy-plane." + << exit(FatalError); } } @@ -143,7 +144,7 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh) for (uint j = 0; j < patchIDs_.size(); j++) { numDataLocations_ += - mesh.boundaryMesh()[patchIDs_.at(j)].localPoints().size(); + mesh.boundaryMesh()[patchIDs_.at(j)].localPoints().size(); } DEBUG(adapterInfo("Number of face nodes: " + std::to_string(numDataLocations_))); @@ -168,13 +169,13 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh) // TODO: Check if this behaves correctly with multiple, connected patches. // TODO: Maybe this should be a pointVectorField? const pointField faceNodes = - mesh.boundaryMesh()[patchIDs_.at(j)].localPoints(); + mesh.boundaryMesh()[patchIDs_.at(j)].localPoints(); // 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]; + vertices[verticesIndex++] = faceNodes[i][d]; } // Pass the mesh vertices information to preCICE @@ -200,65 +201,66 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh) // interpolated in the data classes (e.g. CHT) // Define constants - const int triaPerQuad = 2; - const int nodesPerTria = 3; + 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(); + const List faceField = mesh.boundaryMesh()[patchIDs_.at(j)].localFaces(); const Field pointCoords = mesh.boundaryMesh()[patchIDs_.at(j)].localPoints(); // Array to store coordiantes in preCICE format - double triCoords[faceField.size()*triaPerQuad*nodesPerTria*componentsPerNode]; + double triCoords[faceField.size() * triaPerQuad * nodesPerTria * componentsPerNode]; - unsigned int coordIndex=0; + unsigned int coordIndex = 0; // Iterate over faces - forAll(faceField,facei){ - const face& faceQuad=faceField[facei]; - - faceTriangulation faceTri(pointCoords,faceQuad,false); - - for(uint triIndex=0; triIndex < triaPerQuad; triIndex++){ - for(uint nodeIndex=0; nodeIndex < nodesPerTria; nodeIndex++){ - for(uint xyz=0; xyz < componentsPerNode; xyz++) - triCoords[coordIndex++]=pointCoords[faceTri[triIndex][nodeIndex]][xyz]; + forAll(faceField, facei) + { + const face& faceQuad = faceField[facei]; + + faceTriangulation faceTri(pointCoords, faceQuad, false); + + for (uint triIndex = 0; triIndex < triaPerQuad; triIndex++) + { + for (uint nodeIndex = 0; nodeIndex < nodesPerTria; nodeIndex++) + { + for (uint xyz = 0; xyz < componentsPerNode; xyz++) + triCoords[coordIndex++] = pointCoords[faceTri[triIndex][nodeIndex]][xyz]; } } } //Array to store the IDs we get from preCICE - int triVertIDs[faceField.size()*(triaPerQuad*nodesPerTria)]; + int triVertIDs[faceField.size() * (triaPerQuad * nodesPerTria)]; //Get preCICE IDs - precice_.getMeshVertexIDsFromPositions(meshID_,faceField.size()*(triaPerQuad*nodesPerTria),triCoords,triVertIDs); + precice_.getMeshVertexIDsFromPositions(meshID_, faceField.size() * (triaPerQuad * nodesPerTria), triCoords, triVertIDs); - DEBUG(adapterInfo("Number of triangles: " + std::to_string(faceField.size()* triaPerQuad))); + DEBUG(adapterInfo("Number of triangles: " + std::to_string(faceField.size() * triaPerQuad))); //Set Triangles - for(int facei=0; faceisetDataID(precice_.getDataID(dataName, meshID_)); @@ -277,11 +279,9 @@ void preciceAdapter::Interface::addCouplingDataWriter } -void preciceAdapter::Interface::addCouplingDataReader -( +void preciceAdapter::Interface::addCouplingDataReader( std::string dataName, - preciceAdapter::CouplingDataUser * couplingDataReader -) + preciceAdapter::CouplingDataUser* couplingDataReader) { // Set the patchIDs of the patches that form the interface couplingDataReader->setDataID(precice_.getDataID(dataName, meshID_)); @@ -326,7 +326,7 @@ void preciceAdapter::Interface::createBuffer() // Set the appropriate buffer size if (needsVectorData) { - dataBufferSize = dim_*numDataLocations_; + dataBufferSize = dim_ * numDataLocations_; } else { @@ -352,30 +352,26 @@ void preciceAdapter::Interface::readCouplingData() for (uint i = 0; i < couplingDataReaders_.size(); i++) { // Pointer to the current reader - preciceAdapter::CouplingDataUser * + preciceAdapter::CouplingDataUser* couplingDataReader = couplingDataReaders_.at(i); // Make preCICE read vector or scalar data // and fill the adapter's buffer if (couplingDataReader->hasVectorData()) { - precice_.readBlockVectorData - ( + precice_.readBlockVectorData( couplingDataReader->dataID(), numDataLocations_, vertexIDs_, - dataBuffer_ - ); + dataBuffer_); } else { - precice_.readBlockScalarData - ( + precice_.readBlockScalarData( couplingDataReader->dataID(), numDataLocations_, vertexIDs_, - dataBuffer_ - ); + dataBuffer_); } // Read the received data from the buffer @@ -390,38 +386,34 @@ void preciceAdapter::Interface::writeCouplingData() // Does the participant need to write data or is it subcycling? // if (precice_.isWriteDataRequired(computedTimestepLength)) // { - // Make every coupling data writer write - for (uint i = 0; i < couplingDataWriters_.size(); i++) - { - // Pointer to the current reader - preciceAdapter::CouplingDataUser * - couplingDataWriter = couplingDataWriters_.at(i); + // Make every coupling data writer write + for (uint i = 0; i < couplingDataWriters_.size(); i++) + { + // Pointer to the current reader + preciceAdapter::CouplingDataUser* + couplingDataWriter = couplingDataWriters_.at(i); - // Write the data into the adapter's buffer - couplingDataWriter->write(dataBuffer_, meshConnectivity_, dim_); + // Write the data into the adapter's buffer + couplingDataWriter->write(dataBuffer_, meshConnectivity_, dim_); - // Make preCICE write vector or scalar data - if (couplingDataWriter->hasVectorData()) - { - precice_.writeBlockVectorData - ( - couplingDataWriter->dataID(), - numDataLocations_, - vertexIDs_, - dataBuffer_ - ); - } - else - { - precice_.writeBlockScalarData - ( - couplingDataWriter->dataID(), - numDataLocations_, - vertexIDs_, - dataBuffer_ - ); - } + // Make preCICE write vector or scalar data + if (couplingDataWriter->hasVectorData()) + { + precice_.writeBlockVectorData( + couplingDataWriter->dataID(), + numDataLocations_, + vertexIDs_, + dataBuffer_); } + else + { + precice_.writeBlockScalarData( + couplingDataWriter->dataID(), + numDataLocations_, + vertexIDs_, + dataBuffer_); + } + } // } } @@ -442,9 +434,8 @@ preciceAdapter::Interface::~Interface() couplingDataWriters_.clear(); // Delete the vertexIDs_ - delete [] vertexIDs_; + delete[] vertexIDs_; // Delete the shared data buffer - delete [] dataBuffer_; - + delete[] dataBuffer_; } diff --git a/Interface.H b/Interface.H index e7c6fd6b..c2713751 100644 --- a/Interface.H +++ b/Interface.H @@ -14,9 +14,8 @@ namespace preciceAdapter class Interface { protected: - //- preCICE solver interface - precice::SolverInterface & precice_; + precice::SolverInterface& precice_; //- Mesh name used in the preCICE configuration std::string meshName_; @@ -37,10 +36,10 @@ protected: int numDataLocations_ = 0; //- Vertex IDs assigned by preCICE - int * vertexIDs_; + int* vertexIDs_; //- Buffer for the coupling data - double * dataBuffer_; + double* dataBuffer_; //- Vector of CouplingDataReaders std::vector couplingDataReaders_; @@ -59,32 +58,25 @@ protected: void configureMesh(const Foam::fvMesh& mesh); public: - //- Constructor - Interface - ( - precice::SolverInterface & precice, + Interface( + precice::SolverInterface& precice, const Foam::fvMesh& mesh, std::string meshName, std::string locationsType, std::vector patchNames, - bool meshConnectivity - ); + bool meshConnectivity); //- Add a CouplingDataUser to read data from the interface - void addCouplingDataReader - ( + void addCouplingDataReader( std::string dataName, - CouplingDataUser * couplingDataReader - ); + CouplingDataUser* couplingDataReader); //- Add a CouplingDataUser to write data on the interface - void addCouplingDataWriter - ( + void addCouplingDataWriter( std::string dataName, - CouplingDataUser * couplingDataWriter - ); + CouplingDataUser* couplingDataWriter); //- Allocate an appropriate buffer for scalar or vector data. // If at least one couplingDataUser has vector data, then @@ -101,7 +93,6 @@ public: //- Destructor ~Interface(); - }; } diff --git a/Utilities.C b/Utilities.C index 81281625..9141a183 100644 --- a/Utilities.C +++ b/Utilities.C @@ -15,13 +15,13 @@ void adapterInfo(const std::string message, const std::string level) { // Produce a warning message with cyan header WarningInFunction - << "\033[36m" // cyan color - << "Warning in the preCICE adapter: " - << "\033[0m" // restore color - << nl - << message.c_str() - << nl - << nl; + << "\033[36m" // cyan color + << "Warning in the preCICE adapter: " + << "\033[0m" // restore color + << nl + << message.c_str() + << nl + << nl; } else if (level.compare("error") == 0) { @@ -30,13 +30,13 @@ void adapterInfo(const std::string message, const std::string level) // It will also exit the simulation, unless it // is called inside the functionObject's read(). FatalErrorInFunction - << "\033[31m" // red color - << "Error in the preCICE adapter: " - << "\033[0m" // restore color - << nl - << message.c_str() - << nl - << exit(FatalError); + << "\033[31m" // red color + << "Error in the preCICE adapter: " + << "\033[0m" // restore color + << nl + << message.c_str() + << nl + << exit(FatalError); } else if (level.compare("error-deferred") == 0) { @@ -48,13 +48,13 @@ void adapterInfo(const std::string message, const std::string level) // but the user still sees that this is the actual // problem. We catch these errors and exit later. WarningInFunction - << "\033[31m" // red color - << "Error (deferred - will exit later) in the preCICE adapter: " - << "\033[0m" // restore color - << nl - << message.c_str() - << nl - << nl; + << "\033[31m" // red color + << "Error (deferred - will exit later) in the preCICE adapter: " + << "\033[0m" // restore color + << nl + << message.c_str() + << nl + << nl; } else if (level.compare("debug") == 0) { diff --git a/changelog-entries/173.md b/changelog-entries/173.md new file mode 100644 index 00000000..02d7694c --- /dev/null +++ b/changelog-entries/173.md @@ -0,0 +1 @@ +Added a clang-format file, a formatting GitHub action, and formatted the codebase. [#173](https://github.com/precice/openfoam-adapter/pull/173) diff --git a/preciceAdapterFunctionObject.C b/preciceAdapterFunctionObject.C index 7db88e6b..bc8e16a6 100644 --- a/preciceAdapterFunctionObject.C +++ b/preciceAdapterFunctionObject.C @@ -35,30 +35,27 @@ namespace Foam { namespace functionObjects { - defineTypeNameAndDebug(preciceAdapterFunctionObject, 0); - addToRunTimeSelectionTable(functionObject, preciceAdapterFunctionObject, dictionary); +defineTypeNameAndDebug(preciceAdapterFunctionObject, 0); +addToRunTimeSelectionTable(functionObject, preciceAdapterFunctionObject, dictionary); } } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::functionObjects::preciceAdapterFunctionObject::preciceAdapterFunctionObject -( +Foam::functionObjects::preciceAdapterFunctionObject::preciceAdapterFunctionObject( const word& name, const Time& runTime, - const dictionary& dict -) -: - fvMeshFunctionObject(name, runTime, dict), - adapter_(runTime, mesh_) + const dictionary& dict) +: fvMeshFunctionObject(name, runTime, dict), + adapter_(runTime, mesh_) { - #if (defined OPENFOAM_PLUS && (OPENFOAM_PLUS >= 1712) ) || (defined OPENFOAM && (OPENFOAM >= 1806)) - // 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. - UPstream::initNull(); - #endif +#if (defined OPENFOAM_PLUS && (OPENFOAM_PLUS >= 1712)) || (defined OPENFOAM && (OPENFOAM >= 1806)) + // 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. + UPstream::initNull(); +#endif read(dict); } diff --git a/preciceAdapterFunctionObject.H b/preciceAdapterFunctionObject.H index 93f1ca83..f60aeb35 100644 --- a/preciceAdapterFunctionObject.H +++ b/preciceAdapterFunctionObject.H @@ -75,38 +75,34 @@ namespace functionObjects \*---------------------------------------------------------------------------*/ class preciceAdapterFunctionObject -: - public fvMeshFunctionObject +: public fvMeshFunctionObject { // Private data - //- Adapter's main class instance - preciceAdapter::Adapter adapter_; + //- Adapter's main class instance + preciceAdapter::Adapter adapter_; // Private Member Functions - //- Disallow default bitwise copy construct - preciceAdapterFunctionObject(const preciceAdapterFunctionObject&); + //- Disallow default bitwise copy construct + preciceAdapterFunctionObject(const preciceAdapterFunctionObject&); - //- Disallow default bitwise assignment - void operator=(const preciceAdapterFunctionObject&); + //- Disallow default bitwise assignment + void operator=(const preciceAdapterFunctionObject&); public: - //- Runtime type information TypeName("preciceAdapterFunctionObject"); // Constructors - //- Construct from Time and dictionary - preciceAdapterFunctionObject - ( - const word& name, - const Time& runTime, - const dictionary& dict - ); + //- Construct from Time and dictionary + preciceAdapterFunctionObject( + const word& name, + const Time& runTime, + const dictionary& dict); //- Destructor @@ -115,20 +111,20 @@ public: // Member Functions - //- Read the preciceAdapterFunctionObject data - virtual bool read(const dictionary&); + //- Read the preciceAdapterFunctionObject data + virtual bool read(const dictionary&); - //- Execute in the beginning of each time-loop, after the first one - virtual bool execute(); + //- Execute in the beginning of each time-loop, after the first one + virtual bool execute(); - //- Execute at the final time-loop, after execute() - virtual bool end(); + //- Execute at the final time-loop, after execute() + virtual bool end(); - //- Write the preciceAdapterFunctionObject - virtual bool write(); + //- Write the preciceAdapterFunctionObject + virtual bool write(); - //- Called at the end of Time::adjustDeltaT() if adjustTime is true - virtual bool adjustTimeStep(); + //- Called at the end of Time::adjustDeltaT() if adjustTime is true + virtual bool adjustTimeStep(); /* // NOTE: If you add a new module that needs to execute methods diff --git a/tools/format-code.sh b/tools/format-code.sh new file mode 100755 index 00000000..af12fdec --- /dev/null +++ b/tools/format-code.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Format all C++ files with clang-format +find . \( -iname "*.H" -o -iname "*.C" \) -exec clang-format -i {} \; \ No newline at end of file From ec9e45453fc0edf4ff78030e92afe83a79828f6c Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 29 Apr 2021 11:32:37 +0200 Subject: [PATCH 09/46] Add curly braces to one-line if blocks (#175) --- Adapter.C | 14 ++++++++++++++ CHT/CHT.C | 12 +++++++++++- FF/FF.C | 5 ++++- FF/Velocity.C | 4 ++++ FF/VelocityGradient.C | 2 ++ FSI/Displacement.C | 2 ++ FSI/DisplacementDelta.C | 2 ++ FSI/FSI.C | 11 ++++++++++- Interface.C | 8 ++++++++ 9 files changed, 57 insertions(+), 3 deletions(-) diff --git a/Adapter.C b/Adapter.C index bd313979..25ecfb04 100644 --- a/Adapter.C +++ b/Adapter.C @@ -56,11 +56,19 @@ bool preciceAdapter::Adapter::configFileRead() // Set the modules switches if (module == "CHT") + { CHTenabled_ = true; + } + if (module == "FSI") + { FSIenabled_ = true; + } + if (module == "FF") + { FFenabled_ = true; + } } // Every interface is a subdictionary of "interfaces", @@ -141,7 +149,9 @@ bool preciceAdapter::Adapter::configFileRead() { CHT_ = new CHT::ConjugateHeatTransfer(mesh_); if (!CHT_->configure(preciceDict)) + { return false; + } } // If the FSI module is enabled, create it, read the @@ -165,14 +175,18 @@ bool preciceAdapter::Adapter::configFileRead() FSI_ = new FSI::FluidStructureInteraction(mesh_, runTime_); if (!FSI_->configure(preciceDict)) + { return false; + } } if (FFenabled_) { FF_ = new FF::FluidFluid(mesh_); if (!FF_->configure(preciceDict)) + { return false; + } } // NOTE: Create your module and read any options specific to it here diff --git a/CHT/CHT.C b/CHT/CHT.C index a44b1700..0c05000d 100644 --- a/CHT/CHT.C +++ b/CHT/CHT.C @@ -15,7 +15,11 @@ bool preciceAdapter::CHT::ConjugateHeatTransfer::configure(const IOdictionary& a DEBUG(adapterInfo("Configuring the CHT module...")); // Read the CHT-specific options from the adapter's configuration file - if (!readConfig(adapterConfig)) return false; + if (!readConfig(adapterConfig)) + { + return false; + } + // NOTE: If you want to add a new solver type, which you can manually // specify in the configuration, add it here. See also the methods @@ -90,18 +94,24 @@ std::string preciceAdapter::CHT::ConjugateHeatTransfer::determineSolverType() volScalarField p_ = mesh_.lookupObject("p"); if (p_.dimensions() == pressureDimensionsCompressible) + { solverType = "compressible"; + } else if (p_.dimensions() == pressureDimensionsIncompressible) + { solverType = "incompressible"; + } } if (solverType == "unknown") + { adapterInfo("Failed to determine the solver type. " "Please specify your solver type in the CHT section of the " "preciceDict. Known solver types for CHT are: " "basic, incompressible and " "compressible", "error"); + } DEBUG(adapterInfo("Automatically determined solver type : " + solverType)); diff --git a/FF/FF.C b/FF/FF.C index 6869070a..5d016e61 100644 --- a/FF/FF.C +++ b/FF/FF.C @@ -15,7 +15,10 @@ bool preciceAdapter::FF::FluidFluid::configure(const IOdictionary& adapterConfig DEBUG(adapterInfo("Configuring the FF module...")); // Read the FF-specific options from the adapter's configuration file - if (!readConfig(adapterConfig)) return false; + if (!readConfig(adapterConfig)) + { + return false; + } // NOTE: If you want to add a new solver type, which you can manually // specify in the configuration, add it here. See also the methods diff --git a/FF/Velocity.C b/FF/Velocity.C index f0ca557a..5ff72395 100644 --- a/FF/Velocity.C +++ b/FF/Velocity.C @@ -34,9 +34,11 @@ void preciceAdapter::FF::Velocity::write(double* buffer, bool meshConnectivity, U_->boundaryFieldRef()[patchID][i].y(); if (dim == 3) + { // z-dimension buffer[bufferIndex++] = U_->boundaryFieldRef()[patchID][i].z(); + } } } } @@ -63,9 +65,11 @@ void preciceAdapter::FF::Velocity::read(double* buffer, const unsigned int dim) buffer[bufferIndex++]; if (dim == 3) + { // z-dimension U_->boundaryFieldRef()[patchID][i].z() = buffer[bufferIndex++]; + } } } } diff --git a/FF/VelocityGradient.C b/FF/VelocityGradient.C index 99247db0..f9b7b3cc 100644 --- a/FF/VelocityGradient.C +++ b/FF/VelocityGradient.C @@ -40,9 +40,11 @@ void preciceAdapter::FF::VelocityGradient::write(double* buffer, bool meshConnec -gradientPatch[i].y(); if (dim == 3) + { // z-dimension buffer[bufferIndex++] = -gradientPatch[i].z(); + } } } } diff --git a/FSI/Displacement.C b/FSI/Displacement.C index 5dfd44f3..543e26c7 100644 --- a/FSI/Displacement.C +++ b/FSI/Displacement.C @@ -24,11 +24,13 @@ void preciceAdapter::FSI::Displacement::initialize() // Initialize appropriate objects for each interface patch, namely the volField and the interpolation object // this is only necessary for face based FSI if (this->locationsType_ == "faceCenters" || this->locationsType_ == "faceCentres") + { for (unsigned int j = 0; j < patchIDs_.size(); ++j) { const unsigned int patchID = patchIDs_.at(j); interpolationObjects_.emplace_back(new primitivePatchInterpolation(mesh_.boundaryMesh()[patchID])); } + } } diff --git a/FSI/DisplacementDelta.C b/FSI/DisplacementDelta.C index c9c3c0db..2629a6d9 100644 --- a/FSI/DisplacementDelta.C +++ b/FSI/DisplacementDelta.C @@ -24,11 +24,13 @@ void preciceAdapter::FSI::DisplacementDelta::initialize() // Initialize appropriate objects for each interface patch, namely the volField and the interpolation object // this is only necessary for face based FSI if (this->locationsType_ == "faceCenters" || this->locationsType_ == "faceCentres") + { for (unsigned int j = 0; j < patchIDs_.size(); ++j) { const unsigned int patchID = patchIDs_.at(j); interpolationObjects_.emplace_back(new primitivePatchInterpolation(mesh_.boundaryMesh()[patchID])); } + } } diff --git a/FSI/FSI.C b/FSI/FSI.C index 85a36de9..46d37915 100644 --- a/FSI/FSI.C +++ b/FSI/FSI.C @@ -17,7 +17,10 @@ bool preciceAdapter::FSI::FluidStructureInteraction::configure(const IOdictionar DEBUG(adapterInfo("Configuring the FSI module...")); // Read the FSI-specific options from the adapter's configuration file - if (!readConfig(adapterConfig)) return false; + if (!readConfig(adapterConfig)) + { + return false; + } // NOTE: If you want to add a new solver type, which you can manually // specify in the configuration, add it here. See also the methods @@ -81,18 +84,24 @@ std::string preciceAdapter::FSI::FluidStructureInteraction::determineSolverType( volScalarField p_ = mesh_.lookupObject("p"); if (p_.dimensions() == pressureDimensionsCompressible) + { solverType = "compressible"; + } else if (p_.dimensions() == pressureDimensionsIncompressible) + { solverType = "incompressible"; + } } if (solverType == "unknown") + { adapterInfo("Failed to determine the solver type. " "Please specify your solver type in the FSI section of the " "preciceDict. Known solver types for FSI are: " "incompressible and " "compressible", "error"); + } DEBUG(adapterInfo("Automatically determined solver type : " + solverType)); diff --git a/Interface.C b/Interface.C index 7bdc4754..7268a23b 100644 --- a/Interface.C +++ b/Interface.C @@ -114,7 +114,9 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh) for (int i = 0; i < faceNodes.size(); i++) { if (z_location[0] == faceNodes[i][z_axis]) + { continue; + } else { z_location[1] = faceNodes[i][z_axis]; @@ -124,14 +126,20 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh) // Check if the z-coordinates of all nodes match the z-coordinates we have collected above for (int i = 0; i < faceNodes.size(); i++) + { if (z_location[0] == faceNodes[i][z_axis] || z_location[1] == faceNodes[i][z_axis]) + { continue; + } else + { FatalErrorInFunction << "It seems like you are using preCICE in 2D and your geometry is not located int the xy-plane. " "The OpenFOAM adapter implementation supports preCICE 2D cases only with the z-axis as out-of-plane direction." "Please rotate your geometry so that the geometry is located in the xy-plane." << exit(FatalError); + } + } } } From 10a8c4daa7d8f95b325b6dbb8c9f2bcc3221d579 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 29 Apr 2021 12:26:16 +0200 Subject: [PATCH 10/46] Replace deprecated lookupType and subDictPtr with get and findDict (#176) * Replace deprecated lookupType and subDictPtr with get and findDict * Update documentation of supported versions and branches --- Adapter.C | 19 ++++++++----------- FSI/ForceBase.C | 5 ++--- docs/openfoam-support.md | 15 +++++++++++---- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/Adapter.C b/Adapter.C index 25ecfb04..bcac9640 100644 --- a/Adapter.C +++ b/Adapter.C @@ -37,19 +37,16 @@ bool preciceAdapter::Adapter::configFileRead() IOobject::NO_WRITE)); // Read and display the preCICE configuration file name - // NOTE: lookupType("name") is deprecated in openfoam.com since v1812, - // which recommends get("name") instead. However, get("name") - // is not implemented in openfoam.org at the moment. - preciceConfigFilename_ = preciceDict.lookupType("preciceConfig"); // We use this deprecated lookupType<>() for backwards compatibility + preciceConfigFilename_ = preciceDict.get("preciceConfig"); DEBUG(adapterInfo(" precice-config-file : " + preciceConfigFilename_)); // Read and display the participant name - participantName_ = preciceDict.lookupType("participant"); // We use this deprecated lookupType<>() for backwards compatibility + participantName_ = preciceDict.get("participant"); DEBUG(adapterInfo(" participant name : " + participantName_)); // Read and display the list of modules DEBUG(adapterInfo(" modules requested : ")); - wordList modules_ = preciceDict.lookupType("modules"); // We use this deprecated lookupType<>() for backwards compatibility + auto modules_ = preciceDict.get("modules"); for (auto module : modules_) { DEBUG(adapterInfo(" - " + module + "\n")); @@ -74,7 +71,7 @@ bool preciceAdapter::Adapter::configFileRead() // Every interface is a subdictionary of "interfaces", // each with an arbitrary name. Read all of them and create // a list (here: pointer) of dictionaries. - const dictionary* interfaceDictPtr = preciceDict.subDictPtr("interfaces"); // We use this deprecated subDictPtr for backwards compatibility + const auto interfaceDictPtr = preciceDict.findDict("interfaces"); DEBUG(adapterInfo(" interfaces : ")); // Check if we found any interfaces @@ -93,7 +90,7 @@ bool preciceAdapter::Adapter::configFileRead() dictionary interfaceDict = interfaceDictEntry.dict(); struct InterfaceConfig interfaceConfig; - interfaceConfig.meshName = interfaceDict.lookupType("mesh"); // We use this deprecated lookupType<>() for backwards compatibility + interfaceConfig.meshName = interfaceDict.get("mesh"); DEBUG(adapterInfo(" - mesh : " + interfaceConfig.meshName)); // By default, assume "faceCenters" as locationsType @@ -114,7 +111,7 @@ bool preciceAdapter::Adapter::configFileRead() DEBUG(adapterInfo(" connectivity : " + std::to_string(interfaceConfig.meshConnectivity))); DEBUG(adapterInfo(" patches : ")); - wordList patches = interfaceDict.lookupType("patches"); // We use this deprecated lookupType<>() for backwards compatibility + auto patches = interfaceDict.get("patches"); for (auto patch : patches) { interfaceConfig.patchNames.push_back(patch); @@ -122,7 +119,7 @@ bool preciceAdapter::Adapter::configFileRead() } DEBUG(adapterInfo(" writeData : ")); - wordList writeData = interfaceDict.lookupType("writeData"); // We use this deprecated lookupType<>() for backwards compatibility + auto writeData = interfaceDict.get("writeData"); for (auto writeDatum : writeData) { interfaceConfig.writeData.push_back(writeDatum); @@ -130,7 +127,7 @@ bool preciceAdapter::Adapter::configFileRead() } DEBUG(adapterInfo(" readData : ")); - wordList readData = interfaceDict.lookupType("readData"); // We use this deprecated lookupType<>() for backwards compatibility + auto readData = interfaceDict.get("readData"); for (auto readDatum : readData) { interfaceConfig.readData.push_back(readDatum); diff --git a/FSI/ForceBase.C b/FSI/ForceBase.C index 13989096..2ef28e6d 100644 --- a/FSI/ForceBase.C +++ b/FSI/ForceBase.C @@ -76,8 +76,7 @@ Foam::tmp preciceAdapter::FSI::ForceBase::rho() const IOobject::NO_READ, IOobject::NO_WRITE), mesh_, - dimensionedScalar(FSIDict.lookup("rho")) // We use this deprecated lookup() for backwards compatibility - )); + dimensionedScalar(FSIDict.get("rho")))); } else { @@ -109,7 +108,7 @@ Foam::tmp preciceAdapter::FSI::ForceBase::mu() const const dictionary& FSIDict = mesh_.lookupObject("preciceDict").subOrEmptyDict("FSI"); - dimensionedScalar nu(FSIDict.lookup("nu")); // We use this deprecated lookup() for backwards compatibility + dimensionedScalar nu(FSIDict.get("nu")); return tmp( new volScalarField( diff --git a/docs/openfoam-support.md b/docs/openfoam-support.md index 25ad9eb4..768e7261 100644 --- a/docs/openfoam-support.md +++ b/docs/openfoam-support.md @@ -23,10 +23,17 @@ As these steps change your `.profile`, you need to log out and in again to make OpenFOAM is a project with long history and many forks, of which we try to support as many as possible. -Supported versions: - -- OpenFOAM (openfoam.com): [v1706](https://www.openfoam.com/releases/openfoam-v1706/) - [v2012](https://www.openfoam.com/releases/openfoam-v2012/) (or newer) -- OpenFOAM (openfoam.org): version [5.x](https://openfoam.org/version/5-0/) without changes. You need different branches for the versions [4.0/4.1](https://github.com/precice/openfoam-adapter/tree/OpenFOAM4), [6](https://github.com/precice/openfoam-adapter/tree/OpenFOAM6), [7](https://github.com/precice/openfoam-adapter/tree/OpenFOAM7), [8 (experimental)](https://github.com/precice/openfoam-adapter/pull/130). +We provide version-specific branches and archives for: + +- OpenCFD / ESI (openfoam.com): + - [OpenFOAM v1812-v2012](https://github.com/precice/openfoam-adapter) or newer (main target) + - [OpenFOAM v1806 or older](https://github.com/precice/openfoam-adapter/tree/OpenFOAMv1806) +- OpenFOAM Foundation (openfoam.org): + - [OpenFOAM 8](https://github.com/precice/openfoam-adapter/pull/130) (experimental). + - [OpenFOAM 7](https://github.com/precice/openfoam-adapter/tree/OpenFOAM7) (experimental). + - [OpenFOAM 6](https://github.com/precice/openfoam-adapter/tree/OpenFOAM6) (experimental). + - [OpenFOAM 4.0/4.1](https://github.com/precice/openfoam-adapter/tree/OpenFOAM4). + - [OpenFOAM 5.x](https://github.com/precice/openfoam-adapter/tree/OpenFOAM5). Known not supported versions: OpenFOAM v1606+ or older, OpenFOAM 3 or older, foam-extend (any version). From 63019d884d6ca41b7b9dca758c2b0a4c9831409a Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 29 Apr 2021 12:44:52 +0200 Subject: [PATCH 11/46] Update pull_request_template.md --- .github/pull_request_template.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index a25b8948..6f98415a 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,3 +1,6 @@ -Please submit your Pull Request to the `develop` branch of the adapter. + -It may help to have a look at the file `CONTRIBUTING.md` for a few hints and guidelines. \ No newline at end of file +TODO list: + +- [ ] Set target branch to `develop` +- [ ] Add changelog entry From e2245e57cc6eb3913110b9b0768496b893114049 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 29 Apr 2021 15:05:22 +0200 Subject: [PATCH 12/46] Update CHANGELOG.md --- CHANGELOG.md | 13 +++++++++++-- changelog-entries/168.md | 1 - changelog-entries/169.md | 1 - changelog-entries/173.md | 1 - 4 files changed, 11 insertions(+), 5 deletions(-) delete mode 100644 changelog-entries/168.md delete mode 100644 changelog-entries/169.md delete mode 100644 changelog-entries/173.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d68d7e9..1dd2cb6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,15 +9,24 @@ A fitting versioning scheme for this project is [under discussion](https://githu ## [Unreleased] +## [v1.0.0] 2021-04-29 + ### Added -- GitHub actions to build the adapter with OpenFOAM v2012 and to check shell scripts. -- Status of the project in `README.md`: CI badges, license, maintainers, links to issues. +- Automatic code formatting with clang-format. [#173](https://github.com/precice/openfoam-adapter/pull/173) +- GitHub actions to build the adapter with OpenFOAM v2012 and to check shell scripts, documentation formatting, and links. [#165](https://github.com/precice/openfoam-adapter/pull/165) [#164](https://github.com/precice/openfoam-adapter/pull/164) [#169](https://github.com/precice/openfoam-adapter/pull/169) [#171](https://github.com/precice/openfoam-adapter/pull/171) +- Status of the project in `README.md`: CI badges, license, maintainers, links to issues. [#167](https://github.com/precice/openfoam-adapter/pull/167) +- Code of conduct, to ensure a safe environment for the community. [#166](https://github.com/precice/openfoam-adapter/pull/166) ### Changed +- Replaced the deprecated `lookupType` and `subDictPtr` calls with `get` and `findDict` (supported in OpenFOAM v1812 and later). [#176](https://github.com/precice/openfoam-adapter/pull/176) - This Changelog now follows the [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format. +### Removed + +- Automatic triggering of system tests with Travis-CI. We will reimplement this later. [#165](https://github.com/precice/openfoam-adapter/pull/165) + ## [pre-versioning-0] 2021-04-15 ### Added diff --git a/changelog-entries/168.md b/changelog-entries/168.md deleted file mode 100644 index 2d04bbf1..00000000 --- a/changelog-entries/168.md +++ /dev/null @@ -1 +0,0 @@ -Adopted the [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format in `CHANGELOG.md`. diff --git a/changelog-entries/169.md b/changelog-entries/169.md deleted file mode 100644 index d36125d9..00000000 --- a/changelog-entries/169.md +++ /dev/null @@ -1 +0,0 @@ -Added GitHub actions to check Markdown files, including broken links. [#169](https://github.com/precice/openfoam-adapter/pull/169) diff --git a/changelog-entries/173.md b/changelog-entries/173.md deleted file mode 100644 index 02d7694c..00000000 --- a/changelog-entries/173.md +++ /dev/null @@ -1 +0,0 @@ -Added a clang-format file, a formatting GitHub action, and formatted the codebase. [#173](https://github.com/precice/openfoam-adapter/pull/173) From 432a7cab6b7f35d3736a40fca0c1c2dd1b28a38b Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 29 Apr 2021 19:52:38 +0200 Subject: [PATCH 13/46] Update Pull Request template --- .github/pull_request_template.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 6f98415a..17ef6078 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -2,5 +2,5 @@ TODO list: -- [ ] Set target branch to `develop` -- [ ] Add changelog entry +- [ ] I updated the documentation in `docs/` +- [ ] I added a changelog entry in `changelog-entries/` (create directory if missing) From 096f4a0bdc8e9dfb920ab8db20634ffabf95681b Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 29 Apr 2021 20:01:49 +0200 Subject: [PATCH 14/46] Add versioning scheme in CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dd2cb6c..78bee3c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). -A fitting versioning scheme for this project is [under discussion](https://github.com/precice/openfoam-adapter/issues/52). +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +Read more details in the issue [#52: Releases and versioning](https://github.com/precice/openfoam-adapter/issues/52). From 8546cf2bc4ebabfdc5ff9f2e417f0ee961ef0fbb Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 29 Apr 2021 20:04:11 +0200 Subject: [PATCH 15/46] Remove [Unreleased] from CHANGELOG.md --- CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78bee3c6..d0393903 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,6 @@ Read more details in the issue [#52: Releases and versioning](https://github.com -## [Unreleased] - ## [v1.0.0] 2021-04-29 ### Added From 0529bb943aa82015e3d9fc715aae4fe0965b9bf5 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 29 Apr 2021 20:17:48 +0200 Subject: [PATCH 16/46] Rearrange README.md --- README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6f21a954..7bb82d4e 100644 --- a/README.md +++ b/README.md @@ -9,16 +9,22 @@ Build status --> -As of April 2021, `precice/openfoam-adapter` is actively developed. Current maintainers: [@MakisH](https://github.com/MakisH/) and [@DavidSCN](https://github.com/DavidSCN). 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). - ## Start here 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 the [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). + +## 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/)). From d6e19449c37e2c7294c2d8bf1a0b6a10b8a22be2 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 29 Apr 2021 19:42:50 +0200 Subject: [PATCH 17/46] Add version message, v1.0.0 --- Adapter.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Adapter.C b/Adapter.C index bcac9640..790ed74a 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("The preciceAdapter was loaded.", "info"); + adapterInfo("Loaded the OpenFOAM-preCICE adapter v1.0.0.", "info"); return; } From 5c9b00a3bc1b1cfc19d611a6571404de4aeedb37 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 29 Apr 2021 20:43:22 +0200 Subject: [PATCH 18/46] Switch version message and changelog to unreleased version --- Adapter.C | 2 +- CHANGELOG.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Adapter.C b/Adapter.C index 790ed74a..fe19e071 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.0.0.", "info"); + adapterInfo("Loaded the OpenFOAM-preCICE adapter - unreleased version.", "info"); return; } diff --git a/CHANGELOG.md b/CHANGELOG.md index d0393903..78bee3c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ Read more details in the issue [#52: Releases and versioning](https://github.com +## [Unreleased] + ## [v1.0.0] 2021-04-29 ### Added From fca5e8770cba964cd9b51ce97ab8d608f5a75ca8 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Tue, 29 Jun 2021 10:49:56 +0200 Subject: [PATCH 19/46] Bump default OpenFOAM version to v2106 (#185) --- .github/workflows/build.yml | 4 ++-- .github/workflows/install-dependencies.sh | 10 +++++----- README.md | 2 +- changelog-entries/185.md | 1 + docs/openfoam-support.md | 8 ++++---- 5 files changed, 13 insertions(+), 12 deletions(-) create mode 100644 changelog-entries/185.md diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d8de24ce..a0df2b3d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build with OpenFOAM v2012 +name: Build with OpenFOAM v2106 on: [push, pull_request] jobs: build: @@ -21,4 +21,4 @@ jobs: snapshot: '/' exclude: '/boot /data /dev /mnt /proc /run /sys' - name: Build OpenFOAM-preCICE adapter - run: /usr/bin/openfoam2012 ./Allwmake + run: /usr/bin/openfoam2106 ./Allwmake diff --git a/.github/workflows/install-dependencies.sh b/.github/workflows/install-dependencies.sh index ffb18ae2..c9975495 100755 --- a/.github/workflows/install-dependencies.sh +++ b/.github/workflows/install-dependencies.sh @@ -1,9 +1,9 @@ #!/bin/bash -e -# Install OpenFOAM v2012 +# Install OpenFOAM v2106 wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash -sudo apt-get install openfoam2012-dev +sudo apt-get install openfoam2106-dev -# Install preCICE v2.2.0 -wget https://github.com/precice/precice/releases/download/v2.2.0/libprecice2_2.2.0_focal.deb -sudo apt install ./libprecice2_2.2.0_focal.deb \ No newline at end of file +# Install preCICE v2.2.1 +wget https://github.com/precice/precice/releases/download/v2.2.1/libprecice2_2.2.1_focal.deb +sudo apt install ./libprecice2_2.2.1_focal.deb diff --git a/README.md b/README.md index 7bb82d4e..e7da4f32 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # OpenFOAM-preCICE adapter -[![Build with OpenFOAM v2012](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 v2106](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/185.md b/changelog-entries/185.md new file mode 100644 index 00000000..e2e15152 --- /dev/null +++ b/changelog-entries/185.md @@ -0,0 +1 @@ +- OpenFOAM version bumped to v2106 in GitHub Actions (including preCICE v2.2.0 --> v2.2.1) and documentation. [#185](https://github.com/precice/openfoam-adapter/pull/185) diff --git a/docs/openfoam-support.md b/docs/openfoam-support.md index fde83ff9..defe5ddb 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 v2012 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 v2106 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 v2012: -sudo apt-get install openfoam2012-dev +# Install OpenFOAM v2106: +sudo apt-get install openfoam2106-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 branches and archives for: - OpenCFD / ESI (openfoam.com): - - [OpenFOAM v1812-v2012](https://github.com/precice/openfoam-adapter) or newer (main target) + - [OpenFOAM v1812-v2106](https://github.com/precice/openfoam-adapter) or newer (main target) - [OpenFOAM v1806 or older](https://github.com/precice/openfoam-adapter/tree/OpenFOAMv1806) - OpenFOAM Foundation (openfoam.org): - [OpenFOAM 8](https://github.com/precice/openfoam-adapter/pull/130) (experimental). From a5c01a0993c34787c146c70368dd01cec37673e0 Mon Sep 17 00:00:00 2001 From: DavidSCN Date: Tue, 13 Jul 2021 14:33:46 +0200 Subject: [PATCH 20/46] Fixed misplaced data reading in advance function --- Adapter.C | 6 +++--- changelog-entries/188.md | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 changelog-entries/188.md diff --git a/Adapter.C b/Adapter.C index fe19e071..111a61ed 100644 --- a/Adapter.C +++ b/Adapter.C @@ -395,9 +395,6 @@ void preciceAdapter::Adapter::execute() fulfilledReadCheckpoint(); } - // Read the received coupling data from the buffer - readCouplingData(); - // Adjust the timestep, if it is fixed if (!adjustableTimestep_) { @@ -430,6 +427,9 @@ void preciceAdapter::Adapter::execute() } } + // Read the received coupling data from the buffer + readCouplingData(); + // If the coupling is not going to continue, tear down everything // and stop the simulation. if (!isCouplingOngoing()) diff --git a/changelog-entries/188.md b/changelog-entries/188.md new file mode 100644 index 00000000..5ebb3871 --- /dev/null +++ b/changelog-entries/188.md @@ -0,0 +1 @@ +- Fixed the misplaced data reading in the adapter 'advance' function [#188](https://github.com/precice/openfoam-adapter/pull/188) From 0c368d717bc5ec0fbd0aa4925c48a8164487fc3f Mon Sep 17 00:00:00 2001 From: David Schneider Date: Thu, 29 Jul 2021 13:07:46 +0200 Subject: [PATCH 21/46] Fix potentially failing pkg-config commands in Allwmake (#192) * Fix potentially failing pkg-config commands in Allwmake * Fix language typo * Extend error message with suggestion * Move pkg-config log closer to the warning Co-authored-by: Gerasimos Chourdakis --- Allwmake | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Allwmake b/Allwmake index 2736191d..3313220b 100755 --- a/Allwmake +++ b/Allwmake @@ -32,11 +32,24 @@ log "Building the OpenFOAM-preCICE adapter..." # Export the environment variables export ADAPTER_PREP_FLAGS export ADAPTER_TARGET_DIR -ADAPTER_PKG_CONFIG_CFLAGS="$(pkg-config --silence-errors --cflags libprecice)" + +if pkg-config libprecice; then + ADAPTER_PKG_CONFIG_CFLAGS="$(pkg-config --silence-errors --cflags libprecice)" + ADAPTER_PKG_CONFIG_LIBS="$(pkg-config --silence-errors --libs libprecice)" +else + log "WARNING: No configuration file 'libprecice.pc' was found in the PKG_CONFIG_PATH." + log "Check the preCICE documentation page 'Linking to preCICE' for more details, or proceed if you know what you are doing." + ADAPTER_PKG_CONFIG_CFLAGS="" + ADAPTER_PKG_CONFIG_LIBS="" +fi export ADAPTER_PKG_CONFIG_CFLAGS -ADAPTER_PKG_CONFIG_LIBS="$(pkg-config --silence-errors --libs libprecice)" export ADAPTER_PKG_CONFIG_LIBS +log "" +log "If not already known by the system, preCICE may be located using:" +log " pkg-config --cflags libprecice = ${ADAPTER_PKG_CONFIG_CFLAGS}" +log " pkg-config --libs libprecice = ${ADAPTER_PKG_CONFIG_LIBS}" + # Check if an OpenFOAM environment is available log "" log "Current OpenFOAM environment:" @@ -66,11 +79,6 @@ log "" log "The adapter will be built into ${ADAPTER_TARGET_DIR}" log "Additional preprocessor/compiler options: ${ADAPTER_PREP_FLAGS}" -log "" -log "If not already known by the system, preCICE may be located using:" -log " pkg-config --cflags libprecice = ${ADAPTER_PKG_CONFIG_CFLAGS}" -log " pkg-config --libs libprecice = ${ADAPTER_PKG_CONFIG_LIBS}" - # Run wmake (build the adapter) and check the exit code log "" log "Building with WMake (see the wmake.log log file)...\n" From 0ce927ba183adfeccf9f7b0ec9bfdccef4444a68 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Mon, 8 Nov 2021 08:25:52 +0100 Subject: [PATCH 22/46] Print DEBUG output on each rank (#201) * Print DEBUG output on each rank * Add a changelog entry --- Utilities.C | 2 +- changelog-entries/201.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelog-entries/201.md diff --git a/Utilities.C b/Utilities.C index 9141a183..2ed0af54 100644 --- a/Utilities.C +++ b/Utilities.C @@ -58,7 +58,7 @@ void adapterInfo(const std::string message, const std::string level) } else if (level.compare("debug") == 0) { - Info << INFO_STR_ADAPTER + Pout << INFO_STR_ADAPTER << "[DEBUG] " << message.c_str() << nl; diff --git a/changelog-entries/201.md b/changelog-entries/201.md new file mode 100644 index 00000000..aa12de56 --- /dev/null +++ b/changelog-entries/201.md @@ -0,0 +1 @@ +- Extended the adapter DEBUG output to print the rank in addition to the message [#201](https://github.com/precice/openfoam-adapter/pull/201) From 3752babc7b0ee911d1eb08f06ef8e65a2f82715f Mon Sep 17 00:00:00 2001 From: David Schneider Date: Mon, 8 Nov 2021 11:19:55 +0100 Subject: [PATCH 23/46] Fix 2D check for parallel cases (#203) * Fix out-of-memory access in 2D check * Add changelog entry * Fix link in changelog entry * Update changelog-entries/203.md Co-authored-by: Gerasimos Chourdakis Co-authored-by: Gerasimos Chourdakis --- Interface.C | 10 +++++++--- changelog-entries/203.md | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 changelog-entries/203.md diff --git a/Interface.C b/Interface.C index 7268a23b..3f5a82c6 100644 --- a/Interface.C +++ b/Interface.C @@ -102,16 +102,20 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh) { const pointField faceNodes = mesh.boundaryMesh()[patchIDs_.at(j)].localPoints(); + const auto faceNodesSize = faceNodes.size(); //Allocate memory for z-coordinates std::array z_location({0, 0}); constexpr unsigned int z_axis = 2; // Find out about the existing planes // Store z-coordinate of the first layer - z_location[0] = faceNodes[0][z_axis]; + if (faceNodesSize > 0) + { + z_location[0] = faceNodes[0][z_axis]; + } // Go through the remaining points until we find the second z-coordinate // and store it (there are only two allowed in case we are in the xy-layer) - for (int i = 0; i < faceNodes.size(); i++) + for (int i = 0; i < faceNodesSize; i++) { if (z_location[0] == faceNodes[i][z_axis]) { @@ -125,7 +129,7 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh) } // Check if the z-coordinates of all nodes match the z-coordinates we have collected above - for (int i = 0; i < faceNodes.size(); i++) + for (int i = 0; i < faceNodesSize; i++) { if (z_location[0] == faceNodes[i][z_axis] || z_location[1] == faceNodes[i][z_axis]) { diff --git a/changelog-entries/203.md b/changelog-entries/203.md new file mode 100644 index 00000000..693707a6 --- /dev/null +++ b/changelog-entries/203.md @@ -0,0 +1 @@ +- Fixed a potential memory access issue in the xy-alignment check for parallel 2D cases [#202](https://github.com/precice/openfoam-adapter/issues/202) From 51fb0b0058b234526d9e7b929c5d09bd0b08fe9e Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 18 Nov 2021 19:20:52 +0100 Subject: [PATCH 24/46] Document pkg-config dependency closes #205. --- docs/get.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/get.md b/docs/get.md index a6270f58..c1167caa 100644 --- a/docs/get.md +++ b/docs/get.md @@ -15,6 +15,8 @@ To build the adapter, you need to install a few dependencies and then execute th * Check for any error messages and suggestions at the end. * Modify the `adapter_build_command` to e.g. build using more threads, e.g. `wmake -j 4 libso`. +The adapter also requires [pkg-config](https://linux.die.net/man/1/pkg-config) to [link to preCICE](installation-linking.html). This is a very common dependency on Linux and is usually already installed. + Adding `-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. Next: [configure and load the adapter](https://precice.org/adapter-openfoam-config.html) or [run a tutorial](https://precice.org/tutorials.html). From af5a840fcf4c91cab88f4e63df2c728e76a3d136 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Fri, 19 Nov 2021 17:54:53 +0100 Subject: [PATCH 25/46] Documentation: Fix link to linking page --- docs/get.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/get.md b/docs/get.md index c1167caa..df30ce74 100644 --- a/docs/get.md +++ b/docs/get.md @@ -15,7 +15,7 @@ To build the adapter, you need to install a few dependencies and then execute th * Check for any error messages and suggestions at the end. * Modify the `adapter_build_command` to e.g. build using more threads, e.g. `wmake -j 4 libso`. -The adapter also requires [pkg-config](https://linux.die.net/man/1/pkg-config) to [link to preCICE](installation-linking.html). This is a very common dependency on Linux and is usually already installed. +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. Adding `-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. From 88be6ae6788471c56d815cbec831387c50d990a2 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Wed, 1 Dec 2021 11:01:16 +0100 Subject: [PATCH 26/46] Add a check for supported data locationType (#206) * Add a check for supported data locationType * Add a getter function for the data name * Add a changelog entry * Fix formatting * Rename locationType variable to singular * Switch error mechanism to adapterInfo * Fix spelling * Add comment for supported locationType with meshConnectivity * Switch to error-deferred mechanism --- CHT/HeatFlux.C | 22 +++++++++++++++++++ CHT/HeatFlux.H | 5 +++++ CHT/HeatTransferCoefficient.C | 22 +++++++++++++++++++ CHT/HeatTransferCoefficient.H | 5 +++++ CHT/SinkTemperature.C | 22 +++++++++++++++++++ CHT/SinkTemperature.H | 5 +++++ CHT/Temperature.C | 22 +++++++++++++++++++ CHT/Temperature.H | 5 +++++ CouplingDataUser.C | 22 +++++++++++++++++-- CouplingDataUser.H | 23 ++++++++++++++++++-- FF/Pressure.C | 10 +++++++++ FF/Pressure.H | 5 +++++ FF/PressureGradient.C | 10 +++++++++ FF/PressureGradient.H | 5 +++++ FF/Velocity.C | 10 +++++++++ FF/Velocity.H | 5 +++++ FF/VelocityGradient.C | 10 +++++++++ FF/VelocityGradient.H | 5 +++++ FSI/Displacement.C | 16 +++++++++++--- FSI/Displacement.H | 5 +++++ FSI/DisplacementDelta.C | 16 +++++++++++--- FSI/DisplacementDelta.H | 5 +++++ FSI/Force.C | 10 +++++++++ FSI/Force.H | 5 +++++ FSI/Stress.C | 10 +++++++++ FSI/Stress.H | 5 +++++ Interface.C | 40 +++++++++++++++++++++++------------ Interface.H | 2 +- changelog-entries/206.md | 1 + 29 files changed, 304 insertions(+), 24 deletions(-) create mode 100644 changelog-entries/206.md diff --git a/CHT/HeatFlux.C b/CHT/HeatFlux.C index cdf5fd25..f9afeb63 100644 --- a/CHT/HeatFlux.C +++ b/CHT/HeatFlux.C @@ -103,6 +103,28 @@ void preciceAdapter::CHT::HeatFlux::read(double* buffer, const unsigned int dim) } } +bool preciceAdapter::CHT::HeatFlux::isLocationTypeSupported(const bool meshConnectivity) const +{ + // For cases with mesh connectivity, we support: + // - face nodes, only for writing + // - face centers, only for reading + // However, since we do not distinguish between reading and writing in the code, we + // always return true and offload the handling to the user. + if (meshConnectivity) + { + return true; + } + else + { + return (this->locationType_ == LocationType::faceCenters); + } +} + +std::string preciceAdapter::CHT::HeatFlux::getDataName() const +{ + return "HeatFlux"; +} + //----- preciceAdapter::CHT::HeatFlux_Compressible ---------------------------- preciceAdapter::CHT::HeatFlux_Compressible::HeatFlux_Compressible( diff --git a/CHT/HeatFlux.H b/CHT/HeatFlux.H index dc000bed..d1e34c0e 100644 --- a/CHT/HeatFlux.H +++ b/CHT/HeatFlux.H @@ -39,6 +39,11 @@ public: // the gradient of the temperature field virtual 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; + //- Destructor virtual ~HeatFlux() {}; }; diff --git a/CHT/HeatTransferCoefficient.C b/CHT/HeatTransferCoefficient.C index d084f54c..8da03c09 100644 --- a/CHT/HeatTransferCoefficient.C +++ b/CHT/HeatTransferCoefficient.C @@ -115,6 +115,28 @@ void preciceAdapter::CHT::HeatTransferCoefficient::read(double* buffer, const un } } +bool preciceAdapter::CHT::HeatTransferCoefficient::isLocationTypeSupported(const bool meshConnectivity) const +{ + // For cases with mesh connectivity, we support: + // - face nodes, only for writing + // - face centers, only for reading + // However, since we do not distinguish between reading and writing in the code, we + // always return true and offload the handling to the user. + if (meshConnectivity) + { + return true; + } + else + { + return (this->locationType_ == LocationType::faceCenters); + } +} + +std::string preciceAdapter::CHT::HeatTransferCoefficient::getDataName() const +{ + return "HeatTransferCoefficient"; +} + //----- preciceAdapter::CHT::HeatTransferCoefficient_Compressible ------------- diff --git a/CHT/HeatTransferCoefficient.H b/CHT/HeatTransferCoefficient.H index 76660636..f0caa2de 100644 --- a/CHT/HeatTransferCoefficient.H +++ b/CHT/HeatTransferCoefficient.H @@ -40,6 +40,11 @@ public: //- Read the heat transfer coefficient values from the buffer virtual 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; + //- Destructor virtual ~HeatTransferCoefficient() {}; }; diff --git a/CHT/SinkTemperature.C b/CHT/SinkTemperature.C index 11746875..8492119c 100644 --- a/CHT/SinkTemperature.C +++ b/CHT/SinkTemperature.C @@ -93,3 +93,25 @@ void preciceAdapter::CHT::SinkTemperature::read(double* buffer, const unsigned i } } } + +bool preciceAdapter::CHT::SinkTemperature::isLocationTypeSupported(const bool meshConnectivity) const +{ + // For cases with mesh connectivity, we support: + // - face nodes, only for writing + // - face centers, only for reading + // However, since we do not distinguish between reading and writing in the code, we + // always return true and offload the handling to the user. + if (meshConnectivity) + { + return true; + } + else + { + return (this->locationType_ == LocationType::faceCenters); + } +} + +std::string preciceAdapter::CHT::SinkTemperature::getDataName() const +{ + return "SinkTemperature"; +} diff --git a/CHT/SinkTemperature.H b/CHT/SinkTemperature.H index 5c92b7c6..8b66896e 100644 --- a/CHT/SinkTemperature.H +++ b/CHT/SinkTemperature.H @@ -30,6 +30,11 @@ public: //- Read the sink 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; }; } diff --git a/CHT/Temperature.C b/CHT/Temperature.C index b3ab956a..3756471c 100644 --- a/CHT/Temperature.C +++ b/CHT/Temperature.C @@ -74,3 +74,25 @@ void preciceAdapter::CHT::Temperature::read(double* buffer, const unsigned int d } } } + +bool preciceAdapter::CHT::Temperature::isLocationTypeSupported(const bool meshConnectivity) const +{ + // For cases with mesh connectivity, we support: + // - face nodes, only for writing + // - face centers, only for reading + // However, since we do not distinguish between reading and writing in the code, we + // always return true and offload the handling to the user. + if (meshConnectivity) + { + return true; + } + else + { + return (this->locationType_ == LocationType::faceCenters); + } +} + +std::string preciceAdapter::CHT::Temperature::getDataName() const +{ + return "Temperature"; +} diff --git a/CHT/Temperature.H b/CHT/Temperature.H index 722ddb01..0ce85a7c 100644 --- a/CHT/Temperature.H +++ b/CHT/Temperature.H @@ -30,6 +30,11 @@ public: //- 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; }; } diff --git a/CouplingDataUser.C b/CouplingDataUser.C index 50997740..7e84250d 100644 --- a/CouplingDataUser.C +++ b/CouplingDataUser.C @@ -31,9 +31,27 @@ void preciceAdapter::CouplingDataUser::setPatchIDs(std::vector patchIDs) patchIDs_ = patchIDs; } -void preciceAdapter::CouplingDataUser::setLocationsType(std::string locationsType) +void preciceAdapter::CouplingDataUser::setLocationsType(LocationType locationsType) { - locationsType_ = locationsType; + locationType_ = locationsType; +} + +void preciceAdapter::CouplingDataUser::checkDataLocation(const bool meshConnectivity) const +{ + if (this->isLocationTypeSupported(meshConnectivity) == false) + { + std::string location("none"); + if (locationType_ == LocationType::faceCenters) + location = "faceCenters"; + else if (locationType_ == LocationType::faceNodes) + location = "faceNodes"; + + adapterInfo("\"locations = " + location + "\" is not supported for the data \"" + + getDataName() + "\". Please select a different " + "location type, a different data set or provide " + "additional connectivity information.", + "error"); + } } // Dummy implementation which can be overwritten in derived classes if required diff --git a/CouplingDataUser.H b/CouplingDataUser.H index 030635b1..3c994790 100644 --- a/CouplingDataUser.H +++ b/CouplingDataUser.H @@ -1,11 +1,20 @@ #ifndef COUPLINGDATAUSER_H #define COUPLINGDATAUSER_H +#include "Utilities.H" #include #include namespace preciceAdapter { +// A small enum to deal with the different locations of the +// coupling interface +enum class LocationType +{ + none, + faceCenters, + faceNodes +}; class CouplingDataUser { @@ -27,7 +36,7 @@ protected: int dataID_; //- location type of the interface - std::string locationsType_; + LocationType locationType_ = LocationType::none; public: //- Constructor @@ -49,7 +58,10 @@ public: void setPatchIDs(std::vector patchIDs); //- Set the locations type of the interface - void setLocationsType(std::string locationsType); + void setLocationsType(LocationType locationsType); + + // Check if the dataset supports this interface nodes location + void checkDataLocation(const bool meshConnectivity) const; //- option to initialize data in derived data classes virtual void initialize(); @@ -60,6 +72,13 @@ public: //- Read the coupling data from the buffer virtual void read(double* dataBuffer, const unsigned int dim) = 0; + //- Given the meshConnectivity, return if the underlying loactionType of the + //- interface nodes is supported by the data set + virtual bool isLocationTypeSupported(const bool meshConnectivity) const = 0; + + //- Get the name of the current data field + virtual std::string getDataName() const = 0; + //- Destructor virtual ~CouplingDataUser() {} }; diff --git a/FF/Pressure.C b/FF/Pressure.C index cf2ec770..2d8566e5 100644 --- a/FF/Pressure.C +++ b/FF/Pressure.C @@ -49,3 +49,13 @@ 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); +} + +std::string preciceAdapter::FF::Pressure::getDataName() const +{ + return "Pressure"; +} diff --git a/FF/Pressure.H b/FF/Pressure.H index 6d9efd4f..5506de53 100644 --- a/FF/Pressure.H +++ b/FF/Pressure.H @@ -29,6 +29,11 @@ public: //- Read the pressure 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; }; } diff --git a/FF/PressureGradient.C b/FF/PressureGradient.C index 9d46c1a7..b4c8ad54 100644 --- a/FF/PressureGradient.C +++ b/FF/PressureGradient.C @@ -61,3 +61,13 @@ void preciceAdapter::FF::PressureGradient::read(double* buffer, const unsigned i } } } + +bool preciceAdapter::FF::PressureGradient::isLocationTypeSupported(const bool meshConnectivity) const +{ + return (this->locationType_ == LocationType::faceCenters); +} + +std::string preciceAdapter::FF::PressureGradient::getDataName() const +{ + return "PressureGradient"; +} diff --git a/FF/PressureGradient.H b/FF/PressureGradient.H index 05c5a9f9..47920b7f 100644 --- a/FF/PressureGradient.H +++ b/FF/PressureGradient.H @@ -29,6 +29,11 @@ public: //- Read the pressure 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; }; } diff --git a/FF/Velocity.C b/FF/Velocity.C index 5ff72395..747def6f 100644 --- a/FF/Velocity.C +++ b/FF/Velocity.C @@ -73,3 +73,13 @@ 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); +} + +std::string preciceAdapter::FF::Velocity::getDataName() const +{ + return "Velocity"; +} diff --git a/FF/Velocity.H b/FF/Velocity.H index 3d78460b..17c0dc19 100644 --- a/FF/Velocity.H +++ b/FF/Velocity.H @@ -29,6 +29,11 @@ public: //- Read the velocity 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; }; } diff --git a/FF/VelocityGradient.C b/FF/VelocityGradient.C index f9b7b3cc..72e150b1 100644 --- a/FF/VelocityGradient.C +++ b/FF/VelocityGradient.C @@ -83,3 +83,13 @@ void preciceAdapter::FF::VelocityGradient::read(double* buffer, const unsigned i } } } + +bool preciceAdapter::FF::VelocityGradient::isLocationTypeSupported(const bool meshConnectivity) const +{ + return (this->locationType_ == LocationType::faceCenters); +} + +std::string preciceAdapter::FF::VelocityGradient::getDataName() const +{ + return "VelocityGradient"; +} diff --git a/FF/VelocityGradient.H b/FF/VelocityGradient.H index 1f3e9a84..d3715efb 100644 --- a/FF/VelocityGradient.H +++ b/FF/VelocityGradient.H @@ -29,6 +29,11 @@ public: //- Read the velocity 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; }; } diff --git a/FSI/Displacement.C b/FSI/Displacement.C index 543e26c7..90a6e2de 100644 --- a/FSI/Displacement.C +++ b/FSI/Displacement.C @@ -23,7 +23,7 @@ void preciceAdapter::FSI::Displacement::initialize() { // Initialize appropriate objects for each interface patch, namely the volField and the interpolation object // this is only necessary for face based FSI - if (this->locationsType_ == "faceCenters" || this->locationsType_ == "faceCentres") + if (this->locationType_ == LocationType::faceCenters) { for (unsigned int j = 0; j < patchIDs_.size(); ++j) { @@ -55,7 +55,7 @@ void preciceAdapter::FSI::Displacement::read(double* buffer, const unsigned int // Get the ID of the current patch const unsigned int patchID = patchIDs_.at(j); - if (this->locationsType_ == "faceCenters" || this->locationsType_ == "faceCentres") + if (this->locationType_ == LocationType::faceCenters) { // the boundaryCellDisplacement is a vector and ordered according to the iterator j @@ -75,7 +75,7 @@ void preciceAdapter::FSI::Displacement::read(double* buffer, const unsigned int // Afterwards, continue as usual pointDisplacementFluidPatch = interpolationObjects_[j]->faceToPointInterpolate(cellDisplacement_->boundaryField()[patchID]); } - else if (this->locationsType_ == "faceNodes") + else if (this->locationType_ == LocationType::faceNodes) { // Get the displacement on the patch @@ -92,3 +92,13 @@ void preciceAdapter::FSI::Displacement::read(double* buffer, const unsigned int } } } + +bool preciceAdapter::FSI::Displacement::isLocationTypeSupported(const bool meshConnectivity) const +{ + return (this->locationType_ == LocationType::faceCenters || this->locationType_ == LocationType::faceNodes); +} + +std::string preciceAdapter::FSI::Displacement::getDataName() const +{ + return "Displacement"; +} diff --git a/FSI/Displacement.H b/FSI/Displacement.H index a6ce22c3..f8b0e213 100644 --- a/FSI/Displacement.H +++ b/FSI/Displacement.H @@ -41,6 +41,11 @@ public: //- Read the displacement 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; + //- We need to initialize the cell-based vector and the interpolation object // in case we want to use the faceCenter location for the coupling void initialize() override; diff --git a/FSI/DisplacementDelta.C b/FSI/DisplacementDelta.C index 2629a6d9..ca4e4c2a 100644 --- a/FSI/DisplacementDelta.C +++ b/FSI/DisplacementDelta.C @@ -23,7 +23,7 @@ void preciceAdapter::FSI::DisplacementDelta::initialize() { // Initialize appropriate objects for each interface patch, namely the volField and the interpolation object // this is only necessary for face based FSI - if (this->locationsType_ == "faceCenters" || this->locationsType_ == "faceCentres") + if (this->locationType_ == LocationType::faceCenters) { for (unsigned int j = 0; j < patchIDs_.size(); ++j) { @@ -54,7 +54,7 @@ void preciceAdapter::FSI::DisplacementDelta::read(double* buffer, const unsigned // Get the ID of the current patch const unsigned int patchID = patchIDs_.at(j); - if (this->locationsType_ == "faceCenters" || this->locationsType_ == "faceCentres") + if (this->locationType_ == LocationType::faceCenters) { // the boundaryCellDisplacement is a vector and ordered according to the iterator j @@ -76,7 +76,7 @@ void preciceAdapter::FSI::DisplacementDelta::read(double* buffer, const unsigned // Afterwards, continue as usual pointDisplacementFluidPatch += interpolationObjects_[j]->faceToPointInterpolate(cellDisplacement_->boundaryField()[patchID]); } - else if (this->locationsType_ == "faceNodes") + else if (this->locationType_ == LocationType::faceNodes) { // Get the displacement on the patch @@ -93,3 +93,13 @@ void preciceAdapter::FSI::DisplacementDelta::read(double* buffer, const unsigned } } } + +bool preciceAdapter::FSI::DisplacementDelta::isLocationTypeSupported(const bool meshConnectivity) const +{ + return (this->locationType_ == LocationType::faceCenters || this->locationType_ == LocationType::faceNodes); +} + +std::string preciceAdapter::FSI::DisplacementDelta::getDataName() const +{ + return "DisplacementDelta"; +} diff --git a/FSI/DisplacementDelta.H b/FSI/DisplacementDelta.H index 24317de6..fbc579ce 100644 --- a/FSI/DisplacementDelta.H +++ b/FSI/DisplacementDelta.H @@ -41,6 +41,11 @@ public: //- Read the displacementDelta 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 + virtual std::string getDataName() const; + //- We need to initialize the cell-based vector and the interpolation object // in case we want to use the faceCenter location for the coupling void initialize() override; diff --git a/FSI/Force.C b/FSI/Force.C index 480ba9f1..c521de05 100644 --- a/FSI/Force.C +++ b/FSI/Force.C @@ -31,6 +31,16 @@ void preciceAdapter::FSI::Force::read(double* buffer, const unsigned int dim) this->readFromBuffer(buffer); } +bool preciceAdapter::FSI::Force::isLocationTypeSupported(const bool meshConnectivity) const +{ + return (this->locationType_ == LocationType::faceCenters); +} + +std::string preciceAdapter::FSI::Force::getDataName() const +{ + return "Force"; +} + vectorField preciceAdapter::FSI::Force::getFaceVectors(const unsigned int patchID) const { // Normal vectors multiplied by face area diff --git a/FSI/Force.H b/FSI/Force.H index d18f75a1..a9c0e38a 100644 --- a/FSI/Force.H +++ b/FSI/Force.H @@ -27,6 +27,11 @@ public: //- Read the forces 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; + //- Returns the normal vectors multiplied by the face area Foam::vectorField getFaceVectors(const unsigned int patchID) const override; diff --git a/FSI/Stress.C b/FSI/Stress.C index cec69afe..dd0ed9b7 100644 --- a/FSI/Stress.C +++ b/FSI/Stress.C @@ -31,6 +31,16 @@ void preciceAdapter::FSI::Stress::read(double* buffer, const unsigned int dim) this->readFromBuffer(buffer); } +bool preciceAdapter::FSI::Stress::isLocationTypeSupported(const bool meshConnectivity) const +{ + return (this->locationType_ == LocationType::faceCenters); +} + +std::string preciceAdapter::FSI::Stress::getDataName() const +{ + return "Stress"; +} + vectorField preciceAdapter::FSI::Stress::getFaceVectors(const unsigned int patchID) const { // face normal vectors diff --git a/FSI/Stress.H b/FSI/Stress.H index 1f93e2af..64e3d2ff 100644 --- a/FSI/Stress.H +++ b/FSI/Stress.H @@ -32,6 +32,11 @@ public: //- Read the stress 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; + //- Returns the face normal vectors (no multiplication by area) Foam::vectorField getFaceVectors(const unsigned int patchID) const override; diff --git a/Interface.C b/Interface.C index 3f5a82c6..c90ab5bc 100644 --- a/Interface.C +++ b/Interface.C @@ -14,7 +14,6 @@ preciceAdapter::Interface::Interface( bool meshConnectivity) : precice_(precice), meshName_(meshName), - locationsType_(locationsType), patchNames_(patchNames), meshConnectivity_(meshConnectivity) { @@ -31,6 +30,23 @@ preciceAdapter::Interface::Interface( "warning")); } + if (locationsType == "faceCenters" || locationsType == "faceCentres") + { + locationType_ = LocationType::faceCenters; + } + else if (locationsType == "faceNodes") + { + locationType_ = LocationType::faceNodes; + } + else + { + adapterInfo("Interface points location type \"" + "locations = " + + locationsType + "\" is invalid.", + "error-deferred"); + } + + // For every patch that participates in the coupling for (uint j = 0; j < patchNames.size(); j++) { @@ -62,7 +78,7 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh) // TODO: Reduce code duplication. In the meantime, take care to update // all the branches. - if (locationsType_ == "faceCenters" || locationsType_ == "faceCentres") + if (locationType_ == LocationType::faceCenters) { // Count the data locations for all the patches for (uint j = 0; j < patchIDs_.size(); j++) @@ -150,7 +166,7 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh) // Pass the mesh vertices information to preCICE precice_.setMeshVertices(meshID_, numDataLocations_, vertices, vertexIDs_); } - else if (locationsType_ == "faceNodes") + else if (locationType_ == LocationType::faceNodes) { // Count the data locations for all the patches for (uint j = 0; j < patchIDs_.size(); j++) @@ -259,14 +275,6 @@ void preciceAdapter::Interface::configureMesh(const fvMesh& mesh) } } } - if (!(locationsType_ == "faceNodes" || locationsType_ == "faceCenters" || locationsType_ == "faceCentres")) - { - FatalErrorInFunction - << "ERROR: interface points location type " - << locationsType_ - << " is invalid." - << exit(FatalError); - } } @@ -281,7 +289,10 @@ void preciceAdapter::Interface::addCouplingDataWriter( couplingDataWriter->setPatchIDs(patchIDs_); // Set the location type in the CouplingDataUser class - couplingDataWriter->setLocationsType(locationsType_); + couplingDataWriter->setLocationsType(locationType_); + + // Set the location type in the CouplingDataUser class + couplingDataWriter->checkDataLocation(meshConnectivity_); // Initilaize class specific data couplingDataWriter->initialize(); @@ -302,7 +313,10 @@ void preciceAdapter::Interface::addCouplingDataReader( couplingDataReader->setPatchIDs(patchIDs_); // Set the location type in the CouplingDataUser class - couplingDataReader->setLocationsType(locationsType_); + couplingDataReader->setLocationsType(locationType_); + + // Check, if the current location type is supported by the data type + couplingDataReader->checkDataLocation(meshConnectivity_); // Initilaize class specific data couplingDataReader->initialize(); diff --git a/Interface.H b/Interface.H index c2713751..bc18134a 100644 --- a/Interface.H +++ b/Interface.H @@ -21,7 +21,7 @@ protected: std::string meshName_; //- Point locations type (faceCenters vs faceNodes) - std::string locationsType_; + LocationType locationType_ {LocationType::none}; //- Mesh ID assigned by preCICE to the interface int meshID_; diff --git a/changelog-entries/206.md b/changelog-entries/206.md new file mode 100644 index 00000000..862d3646 --- /dev/null +++ b/changelog-entries/206.md @@ -0,0 +1 @@ +- added a check for data fields and supported location types of the coupling interface [#206](https://github.com/precice/openfoam-adapter/pull/206) From 49b62673e87fb0ca42267b4ac679e306ef1672b8 Mon Sep 17 00:00:00 2001 From: Max Firmbach <76822743+maxfirmbach@users.noreply.github.com> Date: Fri, 3 Dec 2021 09:14:34 +0100 Subject: [PATCH 27/46] Remove last else-cases in FF and CHT (#197) Fixes a bug that is not allowing more than one module at the same time and adds an error message for the case when a dataset is not known by any or too many modules. Co-authored-by: Gerasimos Chourdakis Co-authored-by: David Schneider --- Adapter.C | 53 ++++++++++++++++++++++++++++------------ CHT/CHT.C | 16 +++++++++--- CHT/CHT.H | 4 +-- FF/FF.C | 16 +++++++++--- FF/FF.H | 4 +-- FSI/FSI.C | 20 +++++++++++++-- FSI/FSI.H | 4 +-- changelog-entries/197.md | 1 + 8 files changed, 86 insertions(+), 32 deletions(-) create mode 100644 changelog-entries/197.md diff --git a/Adapter.C b/Adapter.C index 111a61ed..cd2386d7 100644 --- a/Adapter.C +++ b/Adapter.C @@ -259,22 +259,37 @@ void preciceAdapter::Adapter::configure() { std::string dataName = interfacesConfig_.at(i).writeData.at(j); + unsigned int inModules = 0; + // Add CHT-related coupling data writers - if (CHTenabled_) + if (CHTenabled_ && CHT_->addWriters(dataName, interface)) { - CHT_->addWriters(dataName, interface); + inModules++; } // Add FSI-related coupling data writers - if (FSIenabled_) + if (FSIenabled_ && FSI_->addWriters(dataName, interface)) { - FSI_->addWriters(dataName, interface); + inModules++; } // Add FF-related coupling data writers - if (FFenabled_) + if (FFenabled_ && FF_->addWriters(dataName, interface)) { - FF_->addWriters(dataName, interface); + inModules++; + } + + if (inModules == 0) + { + adapterInfo("I don't know how to write \"" + dataName + + "\". Maybe this is a typo or maybe you need to enable some adapter module?", + "error-deferred"); + } + else if (inModules > 1) + { + adapterInfo("It looks like more than one modules can write \"" + dataName + + "\" and I don't know how to choose. Try disabling one of the modules.", + "error-deferred"); } // NOTE: Add any coupling data writers for your module here. @@ -285,22 +300,28 @@ void preciceAdapter::Adapter::configure() { std::string dataName = interfacesConfig_.at(i).readData.at(j); + unsigned int inModules = 0; + // Add CHT-related coupling data readers - if (CHTenabled_) - { - CHT_->addReaders(dataName, interface); - } + if (CHTenabled_ && CHT_->addReaders(dataName, interface)) inModules++; // Add FSI-related coupling data readers - if (FSIenabled_) - { - FSI_->addReaders(dataName, interface); - } + if (FSIenabled_ && FSI_->addReaders(dataName, interface)) inModules++; // Add FF-related coupling data readers - if (FFenabled_) + if (FFenabled_ && FF_->addReaders(dataName, interface)) inModules++; + + if (inModules == 0) + { + adapterInfo("I don't know how to read \"" + dataName + + "\". Maybe this is a typo or maybe you need to enable some adapter module?", + "error-deferred"); + } + else if (inModules > 1) { - FF_->addReaders(dataName, interface); + adapterInfo("It looks like more than one modules can read \"" + dataName + + "\" and I don't know how to choose. Try disabling one of the modules.", + "error-deferred"); } // NOTE: Add any coupling data readers for your module here. diff --git a/CHT/CHT.C b/CHT/CHT.C index 0c05000d..9204e92b 100644 --- a/CHT/CHT.C +++ b/CHT/CHT.C @@ -118,8 +118,10 @@ std::string preciceAdapter::CHT::ConjugateHeatTransfer::determineSolverType() return solverType; } -void preciceAdapter::CHT::ConjugateHeatTransfer::addWriters(std::string dataName, Interface* interface) +bool preciceAdapter::CHT::ConjugateHeatTransfer::addWriters(std::string dataName, Interface* interface) { + bool found = true; // Set to false later, if needed. + if (dataName.find("Sink-Temperature") == 0) { interface->addCouplingDataWriter( @@ -194,7 +196,7 @@ void preciceAdapter::CHT::ConjugateHeatTransfer::addWriters(std::string dataName } else { - adapterInfo("Unknown data type - cannot add " + dataName + ".", "error"); + found = false; } // NOTE: If you want to couple another variable, you need @@ -202,10 +204,14 @@ void preciceAdapter::CHT::ConjugateHeatTransfer::addWriters(std::string dataName // writer here (and as a reader below). // The argument of the dataName.compare() needs to match // the one provided in the adapter's configuration file. + + return found; } -void preciceAdapter::CHT::ConjugateHeatTransfer::addReaders(std::string dataName, Interface* interface) +bool preciceAdapter::CHT::ConjugateHeatTransfer::addReaders(std::string dataName, Interface* interface) { + bool found = true; // Set to false later, if needed. + if (dataName.find("Sink-Temperature") == 0) { interface->addCouplingDataReader( @@ -280,7 +286,7 @@ void preciceAdapter::CHT::ConjugateHeatTransfer::addReaders(std::string dataName } else { - adapterInfo("Unknown data type - cannot add " + dataName + ".", "error"); + found = false; } // NOTE: If you want to couple another variable, you need @@ -288,4 +294,6 @@ void preciceAdapter::CHT::ConjugateHeatTransfer::addReaders(std::string dataName // reader here (and as a writer above). // The argument of the dataName.compare() needs to match // the one provided in the adapter's configuration file. + + return found; } diff --git a/CHT/CHT.H b/CHT/CHT.H index d4bf03fb..2f0c527f 100644 --- a/CHT/CHT.H +++ b/CHT/CHT.H @@ -60,10 +60,10 @@ public: bool configure(const IOdictionary& adapterConfig); //- Add coupling data writers - void addWriters(std::string dataName, Interface* interface); + bool addWriters(std::string dataName, Interface* interface); //- Add coupling data readers - void addReaders(std::string dataName, Interface* interface); + bool addReaders(std::string dataName, Interface* interface); }; } diff --git a/FF/FF.C b/FF/FF.C index 5d016e61..00c2b695 100644 --- a/FF/FF.C +++ b/FF/FF.C @@ -97,8 +97,10 @@ std::string preciceAdapter::FF::FluidFluid::determineSolverType() return solverType; } -void preciceAdapter::FF::FluidFluid::addWriters(std::string dataName, Interface* interface) +bool preciceAdapter::FF::FluidFluid::addWriters(std::string dataName, Interface* interface) { + bool found = true; // Set to false later, if needed. + if (dataName.find("VelocityGradient") == 0) { interface->addCouplingDataWriter( @@ -129,7 +131,7 @@ void preciceAdapter::FF::FluidFluid::addWriters(std::string dataName, Interface* } else { - adapterInfo("Unknown data type - cannot add " + dataName + ".", "error"); + found = false; } // NOTE: If you want to couple another variable, you need @@ -137,10 +139,14 @@ void preciceAdapter::FF::FluidFluid::addWriters(std::string dataName, Interface* // writer here (and as a reader below). // The argument of the dataName.compare() needs to match // the one provided in the adapter's configuration file. + + return found; } -void preciceAdapter::FF::FluidFluid::addReaders(std::string dataName, Interface* interface) +bool preciceAdapter::FF::FluidFluid::addReaders(std::string dataName, Interface* interface) { + bool found = true; // Set to false later, if needed. + if (dataName.find("VelocityGradient") == 0) { interface->addCouplingDataReader( @@ -171,7 +177,7 @@ void preciceAdapter::FF::FluidFluid::addReaders(std::string dataName, Interface* } else { - adapterInfo("Unknown data type - cannot add " + dataName + ".", "error"); + found = false; } // NOTE: If you want to couple another variable, you need @@ -179,4 +185,6 @@ void preciceAdapter::FF::FluidFluid::addReaders(std::string dataName, Interface* // reader here (and as a writer above). // The argument of the dataName.compare() needs to match // the one provided in the adapter's configuration file. + + return found; } diff --git a/FF/FF.H b/FF/FF.H index a8c65582..ded126e0 100644 --- a/FF/FF.H +++ b/FF/FF.H @@ -47,10 +47,10 @@ public: bool configure(const IOdictionary& adapterConfig); //- Add coupling data writers - void addWriters(std::string dataName, Interface* interface); + bool addWriters(std::string dataName, Interface* interface); //- Add coupling data readers - void addReaders(std::string dataName, Interface* interface); + bool addReaders(std::string dataName, Interface* interface); }; } diff --git a/FSI/FSI.C b/FSI/FSI.C index 46d37915..91571f62 100644 --- a/FSI/FSI.C +++ b/FSI/FSI.C @@ -109,8 +109,10 @@ std::string preciceAdapter::FSI::FluidStructureInteraction::determineSolverType( } -void preciceAdapter::FSI::FluidStructureInteraction::addWriters(std::string dataName, Interface* interface) +bool preciceAdapter::FSI::FluidStructureInteraction::addWriters(std::string dataName, Interface* interface) { + bool found = true; // Set to false later, if needed. + if (dataName.find("Force") == 0) { interface->addCouplingDataWriter( @@ -141,16 +143,24 @@ void preciceAdapter::FSI::FluidStructureInteraction::addWriters(std::string data ); DEBUG(adapterInfo("Added writer: Stress.")); } + else + { + found = false; + } // NOTE: If you want to couple another variable, you need // to add your new coupling data user as a coupling data // writer here (and as a reader below). // The argument of the dataName.compare() needs to match // the one provided in the adapter's configuration file. + + return found; } -void preciceAdapter::FSI::FluidStructureInteraction::addReaders(std::string dataName, Interface* interface) +bool preciceAdapter::FSI::FluidStructureInteraction::addReaders(std::string dataName, Interface* interface) { + bool found = true; // Set to false later, if needed. + if (dataName.find("Force") == 0) { interface->addCouplingDataReader( @@ -181,10 +191,16 @@ void preciceAdapter::FSI::FluidStructureInteraction::addReaders(std::string data ); DEBUG(adapterInfo("Added reader: Stress.")); } + else + { + found = false; + } // NOTE: If you want to couple another variable, you need // to add your new coupling data user as a coupling data // writer here (and as a writer above). // The argument of the dataName.compare() needs to match // the one provided in the adapter's configuration file. + + return found; } diff --git a/FSI/FSI.H b/FSI/FSI.H index 237a0a9a..3e93d77e 100644 --- a/FSI/FSI.H +++ b/FSI/FSI.H @@ -56,10 +56,10 @@ public: bool configure(const IOdictionary& adapterConfig); //- Add coupling data writers - void addWriters(std::string dataName, Interface* interface); + bool addWriters(std::string dataName, Interface* interface); //- Add coupling data readers - void addReaders(std::string dataName, Interface* interface); + bool addReaders(std::string dataName, Interface* interface); }; } diff --git a/changelog-entries/197.md b/changelog-entries/197.md new file mode 100644 index 00000000..b6a532c8 --- /dev/null +++ b/changelog-entries/197.md @@ -0,0 +1 @@ +- Fixed a bug that was not allowing more than one module at the same time and added an error message for the case when a dataset is not known by any or too many modules. [#197](https://github.com/precice/openfoam-adapter/pull/197) From 17d1776a31f96958c5629d0af948675028667f9b Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 13 Dec 2021 16:48:45 +0100 Subject: [PATCH 28/46] Various adjustments (#209) * COMP: avoid tmp ambiguities (clang). Avoid binding const ref to temporary. * COMP: add override for virtual methods (silence clang warnings) * ENH: use const reference (not copy) for subOrEmptyDict * COMP: bind lookupObject to const-ref (not copy) - fix pointer ref, const binding * ENH: code reduction/simplication for adding checkpoint fields * Update preciceAdapterFunctionObject.H Co-authored-by: David Schneider Co-authored-by: Mark Olesen Co-authored-by: David Schneider --- Adapter.C | 454 ++++++++------------------------- Adapter.H | 20 +- CHT/CHT.C | 4 +- CHT/KappaEffective.C | 8 +- FF/FF.C | 4 +- FF/PressureGradient.C | 4 +- FF/VelocityGradient.C | 4 +- FF/VelocityGradient.H | 4 +- FSI/Displacement.H | 4 +- FSI/DisplacementDelta.H | 4 +- FSI/FSI.C | 4 +- FSI/Force.C | 2 +- FSI/Force.H | 6 +- FSI/ForceBase.C | 8 +- FSI/ForceBase.H | 2 +- FSI/Stress.C | 2 +- FSI/Stress.H | 6 +- preciceAdapterFunctionObject.H | 8 +- 18 files changed, 151 insertions(+), 397 deletions(-) diff --git a/Adapter.C b/Adapter.C index cd2386d7..7d8cf6d6 100644 --- a/Adapter.C +++ b/Adapter.C @@ -47,7 +47,7 @@ bool preciceAdapter::Adapter::configFileRead() // Read and display the list of modules DEBUG(adapterInfo(" modules requested : ")); auto modules_ = preciceDict.get("modules"); - for (auto module : modules_) + for (const auto& module : modules_) { DEBUG(adapterInfo(" - " + module + "\n")); @@ -71,7 +71,7 @@ bool preciceAdapter::Adapter::configFileRead() // Every interface is a subdictionary of "interfaces", // each with an arbitrary name. Read all of them and create // a list (here: pointer) of dictionaries. - const auto interfaceDictPtr = preciceDict.findDict("interfaces"); + const auto* interfaceDictPtr = preciceDict.findDict("interfaces"); DEBUG(adapterInfo(" interfaces : ")); // Check if we found any interfaces @@ -87,7 +87,7 @@ bool preciceAdapter::Adapter::configFileRead() { if (interfaceDictEntry.isDict()) { - dictionary interfaceDict = interfaceDictEntry.dict(); + const dictionary& interfaceDict = interfaceDictEntry.dict(); struct InterfaceConfig interfaceConfig; interfaceConfig.meshName = interfaceDict.get("mesh"); @@ -852,411 +852,167 @@ void preciceAdapter::Adapter::setupMeshVolCheckpointing() void preciceAdapter::Adapter::setupCheckpointing() { - // Add fields in the checkpointing list - DEBUG(adapterInfo("Creating a list of checkpointed fields...")); + // Add fields in the checkpointing list - sorted for parallel consistency + DEBUG(adapterInfo("Adding in checkpointed fields...")); - /* Find and add all the registered objects in the mesh_ - of type volScalarField - */ - - // Print the available objects of type volScalarField - DEBUG(adapterInfo("Collecting objects of type volScalarField... ")); - - wordList objectNames_ = mesh_.lookupClass().toc(); - - forAll(objectNames_, i) - { - if (mesh_.foundObject(objectNames_[i])) - { - addCheckpointField( - const_cast( - mesh_.lookupObject(objectNames_[i]))); - -#ifdef ADAPTER_DEBUG_MODE - adapterInfo( - "Will be checkpointing " + objectNames_[i]); -#endif - } - else - { - adapterInfo("Could not checkpoint " + objectNames_[i], "warning"); - } +#undef doLocalCode +#define doLocalCode(GeomField) \ + /* Checkpoint registered GeomField objects */ \ + for (const word& obj : mesh_.sortedNames()) \ + { \ + addCheckpointField(mesh_.thisDb().getObjectPtr(obj)); \ + DEBUG(adapterInfo("Checkpoint " + obj + " : " #GeomField)); \ } - /* Find and add all the registered objects in the mesh_ - of type volVectorField - */ + doLocalCode(volScalarField); + doLocalCode(volVectorField); + doLocalCode(volTensorField); + doLocalCode(volSymmTensorField); - // Print the available objects of type volVectorField - DEBUG(adapterInfo("Collecting objects of type volVectorField... ")); + doLocalCode(surfaceScalarField); + doLocalCode(surfaceVectorField); + doLocalCode(surfaceTensorField); - objectNames_ = mesh_.lookupClass().toc(); - - forAll(objectNames_, i) - { - if (mesh_.foundObject(objectNames_[i])) - { - addCheckpointField( - const_cast( - mesh_.lookupObject(objectNames_[i]))); - -#ifdef ADAPTER_DEBUG_MODE - adapterInfo( - "Will be checkpointing " + objectNames_[i]); -#endif - } - else - { - adapterInfo("Could not checkpoint " + objectNames_[i], "warning"); - } - } - - // Print the available objects of type surfaceScalarField - DEBUG(adapterInfo("Collecting objects of type surfaceScalarField...")); - - /* Find and add all the registered objects in the mesh_ - of type surfaceScalarField - */ - objectNames_ = mesh_.lookupClass().toc(); - - forAll(objectNames_, i) - { - if (mesh_.foundObject(objectNames_[i])) - { - addCheckpointField( - const_cast( - mesh_.lookupObject(objectNames_[i]))); - -#ifdef ADAPTER_DEBUG_MODE - adapterInfo( - "Will be checkpointing " + objectNames_[i]); -#endif - } - else - { - adapterInfo("Could not checkpoint " + objectNames_[i], "warning"); - } - } - - /* Find and add all the registered objects in the mesh_ - of type surfaceVectorField - */ - - // Print the available objects of type surfaceVectorField - DEBUG(adapterInfo("Collecting objects of type surfaceVectorField...")); - - objectNames_ = mesh_.lookupClass().toc(); - - forAll(objectNames_, i) - { - if (mesh_.foundObject(objectNames_[i])) - { - addCheckpointField( - const_cast( - mesh_.lookupObject(objectNames_[i]))); - -#ifdef ADAPTER_DEBUG_MODE - adapterInfo( - "Will be checkpointing " + objectNames_[i]); -#endif - } - else - { - adapterInfo("Could not checkpoint " + objectNames_[i], "warning"); - } - } - - /* Find and add all the registered objects in the mesh_ - of type pointScalarField - */ - - // Print the available objects of type pointScalarField - DEBUG(adapterInfo("Collecting objects of type pointScalarField...")); - - objectNames_ = mesh_.lookupClass().toc(); - - forAll(objectNames_, i) - { - if (mesh_.foundObject(objectNames_[i])) - { - addCheckpointField( - const_cast( - mesh_.lookupObject(objectNames_[i]))); - -#ifdef ADAPTER_DEBUG_MODE - adapterInfo( - "Will be checkpointing " + objectNames_[i]); -#endif - } - else - { - adapterInfo("Could not checkpoint " + objectNames_[i], "warning"); - } - } - - /* Find and add all the registered objects in the mesh_ - of type pointVectorField - */ - - // Print the available objects of type pointVectorField - DEBUG(adapterInfo("Collecting objects of type pointVectorField...")); - - objectNames_ = mesh_.lookupClass().toc(); - - forAll(objectNames_, i) - { - if (mesh_.foundObject(objectNames_[i])) - { - addCheckpointField( - const_cast( - mesh_.lookupObject(objectNames_[i]))); - -#ifdef ADAPTER_DEBUG_MODE - adapterInfo( - "Will be checkpointing " + objectNames_[i]); -#endif - } - else - { - adapterInfo("Could not checkpoint " + objectNames_[i], "warning"); - } - } - - - /* Find and add all the registered objects in the mesh_ - of type volTensorField - */ - - // Print the available objects of type volTensorField - DEBUG(adapterInfo("Collecting objects of type volTensorField...")); - - objectNames_ = mesh_.lookupClass().toc(); - - forAll(objectNames_, i) - { - if (mesh_.foundObject(objectNames_[i])) - { - addCheckpointField( - const_cast( - mesh_.lookupObject(objectNames_[i]))); - -#ifdef ADAPTER_DEBUG_MODE - adapterInfo( - "Will be checkpointing " + objectNames_[i]); -#endif - } - else - { - adapterInfo("Could not checkpoint " + objectNames_[i], "warning"); - } - } - - - /* Find and add all the registered objects in the mesh_ - of type surfaceTensorField - */ - - DEBUG(adapterInfo("Collecting objects of type surfaceTensorField...")); - - objectNames_ = mesh_.lookupClass().toc(); - - forAll(objectNames_, i) - { - if (mesh_.foundObject(objectNames_[i])) - { - addCheckpointField( - const_cast( - mesh_.lookupObject(objectNames_[i]))); - -#ifdef ADAPTER_DEBUG_MODE - adapterInfo( - "Will be checkpointing " + objectNames_[i]); -#endif - } - else - { - adapterInfo("Could not checkpoint " + objectNames_[i], "warning"); - } - } - - /* Find and add all the registered objects in the mesh_ - of type pointTensorField - */ - - DEBUG(adapterInfo("Collecting objects of type pointTensorField...")); - - objectNames_ = mesh_.lookupClass().toc(); - - forAll(objectNames_, i) - { - if (mesh_.foundObject(objectNames_[i])) - { - addCheckpointField( - const_cast( - mesh_.lookupObject(objectNames_[i]))); - -#ifdef ADAPTER_DEBUG_MODE - adapterInfo( - "Will be checkpointing " + objectNames_[i]); -#endif - } - else - { - adapterInfo("Could not checkpoint " + objectNames_[i], "warning"); - } - } + doLocalCode(pointScalarField); + doLocalCode(pointVectorField); + doLocalCode(pointTensorField); // NOTE: Add here other object types to checkpoint, if needed. - /* Find and add all the registered objects in the mesh_ - of type volSymmTensorField - */ - - DEBUG(adapterInfo("Collecting objects of type volSymmTensorField...")); - - objectNames_ = mesh_.lookupClass().toc(); - - forAll(objectNames_, i) - { - if (mesh_.foundObject(objectNames_[i])) - { - addCheckpointField( - const_cast( - mesh_.lookupObject(objectNames_[i]))); - -#ifdef ADAPTER_DEBUG_MODE - adapterInfo( - "Will be checkpointing " + objectNames_[i]); -#endif - } - else - { - adapterInfo("Could not checkpoint " + objectNames_[i], "warning"); - } - } - return; +#undef doLocalCode } // All mesh checkpointed fields + void preciceAdapter::Adapter::addMeshCheckpointField(surfaceScalarField& field) { - surfaceScalarField* copy = new surfaceScalarField(field); - meshSurfaceScalarFields_.push_back(&field); - meshSurfaceScalarFieldCopies_.push_back(copy); - return; + { + meshSurfaceScalarFields_.push_back(&field); + meshSurfaceScalarFieldCopies_.push_back(new surfaceScalarField(field)); + } } void preciceAdapter::Adapter::addMeshCheckpointField(surfaceVectorField& field) { - surfaceVectorField* copy = new surfaceVectorField(field); - meshSurfaceVectorFields_.push_back(&field); - meshSurfaceVectorFieldCopies_.push_back(copy); - return; + { + meshSurfaceVectorFields_.push_back(&field); + meshSurfaceVectorFieldCopies_.push_back(new surfaceVectorField(field)); + } } void preciceAdapter::Adapter::addMeshCheckpointField(volVectorField& field) { - volVectorField* copy = new volVectorField(field); - meshVolVectorFields_.push_back(&field); - meshVolVectorFieldCopies_.push_back(copy); - return; + { + meshVolVectorFields_.push_back(&field); + meshVolVectorFieldCopies_.push_back(new volVectorField(field)); + } } // TODO Internal field for the V0 (volume old) and V00 (volume old-old) fields void preciceAdapter::Adapter::addVolCheckpointField(volScalarField::Internal& field) { - volScalarField::Internal* copy = new volScalarField::Internal(field); - volScalarInternalFields_.push_back(&field); - volScalarInternalFieldCopies_.push_back(copy); - return; + { + volScalarInternalFields_.push_back(&field); + volScalarInternalFieldCopies_.push_back(new volScalarField::Internal(field)); + } } -// All checkpointed fields -void preciceAdapter::Adapter::addCheckpointField(volScalarField& field) + +void preciceAdapter::Adapter::addCheckpointField(volScalarField* field) { - volScalarField* copy = new volScalarField(field); - volScalarFields_.push_back(&field); - volScalarFieldCopies_.push_back(copy); - return; + if (field) + { + volScalarFields_.push_back(field); + volScalarFieldCopies_.push_back(new volScalarField(*field)); + } } -void preciceAdapter::Adapter::addCheckpointField(volVectorField& field) +void preciceAdapter::Adapter::addCheckpointField(volVectorField* field) { - volVectorField* copy = new volVectorField(field); - volVectorFields_.push_back(&field); - volVectorFieldCopies_.push_back(copy); - return; + if (field) + { + volVectorFields_.push_back(field); + volVectorFieldCopies_.push_back(new volVectorField(*field)); + } } -void preciceAdapter::Adapter::addCheckpointField(surfaceScalarField& field) +void preciceAdapter::Adapter::addCheckpointField(surfaceScalarField* field) { - surfaceScalarField* copy = new surfaceScalarField(field); - surfaceScalarFields_.push_back(&field); - surfaceScalarFieldCopies_.push_back(copy); - return; + if (field) + { + surfaceScalarFields_.push_back(field); + surfaceScalarFieldCopies_.push_back(new surfaceScalarField(*field)); + } } -void preciceAdapter::Adapter::addCheckpointField(surfaceVectorField& field) +void preciceAdapter::Adapter::addCheckpointField(surfaceVectorField* field) { - surfaceVectorField* copy = new surfaceVectorField(field); - surfaceVectorFields_.push_back(&field); - surfaceVectorFieldCopies_.push_back(copy); - return; + if (field) + { + surfaceVectorFields_.push_back(field); + surfaceVectorFieldCopies_.push_back(new surfaceVectorField(*field)); + } } -void preciceAdapter::Adapter::addCheckpointField(pointScalarField& field) +void preciceAdapter::Adapter::addCheckpointField(pointScalarField* field) { - pointScalarField* copy = new pointScalarField(field); - pointScalarFields_.push_back(&field); - pointScalarFieldCopies_.push_back(copy); - return; + if (field) + { + pointScalarFields_.push_back(field); + pointScalarFieldCopies_.push_back(new pointScalarField(*field)); + } } -void preciceAdapter::Adapter::addCheckpointField(pointVectorField& field) +void preciceAdapter::Adapter::addCheckpointField(pointVectorField* field) { - pointVectorField* copy = new pointVectorField(field); - pointVectorFields_.push_back(&field); - pointVectorFieldCopies_.push_back(copy); - // TODO: Old time - // pointVectorField * copyOld = new pointVectorField(field.oldTime()); - // pointVectorFieldsOld_.push_back(&(field.oldTime())); - // pointVectorFieldCopiesOld_.push_back(copyOld); - return; + if (field) + { + pointVectorFields_.push_back(field); + pointVectorFieldCopies_.push_back(new pointVectorField(*field)); + // TODO: Old time + // pointVectorFieldsOld_.push_back(const_cast(field->oldTime()))); + // pointVectorFieldCopiesOld_.push_back(new pointVectorField(field->oldTime())); + } } -void preciceAdapter::Adapter::addCheckpointField(volTensorField& field) +void preciceAdapter::Adapter::addCheckpointField(volTensorField* field) { - volTensorField* copy = new volTensorField(field); - volTensorFields_.push_back(&field); - volTensorFieldCopies_.push_back(copy); - return; + if (field) + { + volTensorFields_.push_back(field); + volTensorFieldCopies_.push_back(new volTensorField(*field)); + } } -void preciceAdapter::Adapter::addCheckpointField(surfaceTensorField& field) +void preciceAdapter::Adapter::addCheckpointField(surfaceTensorField* field) { - surfaceTensorField* copy = new surfaceTensorField(field); - surfaceTensorFields_.push_back(&field); - surfaceTensorFieldCopies_.push_back(copy); - return; + if (field) + { + surfaceTensorFields_.push_back(field); + surfaceTensorFieldCopies_.push_back(new surfaceTensorField(*field)); + } } -void preciceAdapter::Adapter::addCheckpointField(pointTensorField& field) +void preciceAdapter::Adapter::addCheckpointField(pointTensorField* field) { - pointTensorField* copy = new pointTensorField(field); - pointTensorFields_.push_back(&field); - pointTensorFieldCopies_.push_back(copy); - return; + if (field) + { + pointTensorFields_.push_back(field); + pointTensorFieldCopies_.push_back(new pointTensorField(*field)); + } } -void preciceAdapter::Adapter::addCheckpointField(volSymmTensorField& field) +void preciceAdapter::Adapter::addCheckpointField(volSymmTensorField* field) { - volSymmTensorField* copy = new volSymmTensorField(field); - volSymmTensorFields_.push_back(&field); - volSymmTensorFieldCopies_.push_back(copy); - return; + if (field) + { + volSymmTensorFields_.push_back(field); + volSymmTensorFieldCopies_.push_back(new volSymmTensorField(*field)); + } } + // NOTE: Add here methods to add other object types to checkpoint, if needed. void preciceAdapter::Adapter::readCheckpoint() diff --git a/Adapter.H b/Adapter.H index ef46ac48..41487151 100644 --- a/Adapter.H +++ b/Adapter.H @@ -315,37 +315,37 @@ private: // Add checkpoint fields, depending on the type //- Add a volScalarField to checkpoint - void addCheckpointField(volScalarField& field); + void addCheckpointField(volScalarField* field); //- Add a volVectorField to checkpoint - void addCheckpointField(volVectorField& field); + void addCheckpointField(volVectorField* field); //- Add a surfaceScalarField to checkpoint - void addCheckpointField(surfaceScalarField& field); + void addCheckpointField(surfaceScalarField* field); //- Add a surfaceVectorField to checkpoint - void addCheckpointField(surfaceVectorField& field); + void addCheckpointField(surfaceVectorField* field); //- Add a pointScalarField to checkpoint - void addCheckpointField(pointScalarField& field); + void addCheckpointField(pointScalarField* field); //- Add a pointVectorField to checkpoint - void addCheckpointField(pointVectorField& field); + void addCheckpointField(pointVectorField* field); // NOTE: Add here methods to add other object types to checkpoint, // if needed. //- Add a volTensorField to checkpoint - void addCheckpointField(volTensorField& field); + void addCheckpointField(volTensorField* field); //- Add a surfaceTensorField to checkpoint - void addCheckpointField(surfaceTensorField& field); + void addCheckpointField(surfaceTensorField* field); //- Add a pointTensorField to checkpoint - void addCheckpointField(pointTensorField& field); + void addCheckpointField(pointTensorField* field); //- Add a volSymmTensorField to checkpoint - void addCheckpointField(volSymmTensorField& field); + void addCheckpointField(volSymmTensorField* field); //- Read the checkpoint - restore the mesh fields and time void readMeshCheckpoint(); diff --git a/CHT/CHT.C b/CHT/CHT.C index 9204e92b..e51342dd 100644 --- a/CHT/CHT.C +++ b/CHT/CHT.C @@ -46,7 +46,7 @@ bool preciceAdapter::CHT::ConjugateHeatTransfer::configure(const IOdictionary& a bool preciceAdapter::CHT::ConjugateHeatTransfer::readConfig(const IOdictionary& adapterConfig) { - const dictionary CHTdict = adapterConfig.subOrEmptyDict("CHT"); + const dictionary& CHTdict = adapterConfig.subOrEmptyDict("CHT"); // Read the solver type (if not specified, it is determined automatically) solverType_ = CHTdict.lookupOrDefault("solverType", ""); @@ -91,7 +91,7 @@ std::string preciceAdapter::CHT::ConjugateHeatTransfer::determineSolverType() if (mesh_.foundObject("p")) { - volScalarField p_ = mesh_.lookupObject("p"); + const volScalarField& p_ = mesh_.lookupObject("p"); if (p_.dimensions() == pressureDimensionsCompressible) { diff --git a/CHT/KappaEffective.C b/CHT/KappaEffective.C index 4425ba24..4ec5963a 100644 --- a/CHT/KappaEffective.C +++ b/CHT/KappaEffective.C @@ -62,7 +62,7 @@ preciceAdapter::CHT::KappaEff_Incompressible::KappaEff_Incompressible( DEBUG(adapterInfo(" Name of turbulent thermal diffusivity: " + nameAlphat_)); // Get the preciceDict/CHT dictionary - const dictionary CHTDict = + const dictionary& CHTDict = mesh_.lookupObject("preciceDict").subOrEmptyDict("CHT"); // Read the Prandtl number @@ -119,8 +119,8 @@ void preciceAdapter::CHT::KappaEff_Incompressible::extract(uint patchID, bool me // Does the turbulent thermal diffusivity exist in the object registry? if (mesh_.foundObject(nameAlphat_)) { - const scalarField& alphat( - mesh_.lookupObject(nameAlphat_).boundaryField()[patchID]); + const scalarField& alphat = + mesh_.lookupObject(nameAlphat_).boundaryField()[patchID]; alphaEff = nu / Pr_.value() + alphat; } @@ -172,7 +172,7 @@ preciceAdapter::CHT::KappaEff_Basic::KappaEff_Basic( DEBUG(adapterInfo(" Name of conductivity: " + nameKappa_)); // Get the preciceDict/CHT dictionary - const dictionary CHTDict = + const dictionary& CHTDict = mesh_.lookupObject("preciceDict").subOrEmptyDict("CHT"); // Read the conductivity diff --git a/FF/FF.C b/FF/FF.C index 00c2b695..6bf0476b 100644 --- a/FF/FF.C +++ b/FF/FF.C @@ -45,7 +45,7 @@ bool preciceAdapter::FF::FluidFluid::configure(const IOdictionary& adapterConfig bool preciceAdapter::FF::FluidFluid::readConfig(const IOdictionary& adapterConfig) { - const dictionary FFdict = adapterConfig.subOrEmptyDict("FF"); + const dictionary& FFdict = adapterConfig.subOrEmptyDict("FF"); // Read the solver type (if not specified, it is determined automatically) solverType_ = FFdict.lookupOrDefault("solverType", ""); @@ -74,7 +74,7 @@ std::string preciceAdapter::FF::FluidFluid::determineSolverType() if (mesh_.foundObject("p")) { - volScalarField p_ = mesh_.lookupObject("p"); + const volScalarField& p_ = mesh_.lookupObject("p"); if (p_.dimensions() == pressureDimensionsCompressible) solverType = "compressible"; diff --git a/FF/PressureGradient.C b/FF/PressureGradient.C index b4c8ad54..9ae3e4b1 100644 --- a/FF/PressureGradient.C +++ b/FF/PressureGradient.C @@ -22,10 +22,10 @@ void preciceAdapter::FF::PressureGradient::write(double* buffer, bool meshConnec int patchID = patchIDs_.at(j); // Get the pressure gradient boundary patch - scalarField gradientPatch = + scalarField gradientPatch( refCast( p_->boundaryFieldRef()[patchID]) - .snGrad(); + .snGrad()); // For every cell of the patch forAll(gradientPatch, i) diff --git a/FF/VelocityGradient.C b/FF/VelocityGradient.C index 72e150b1..4ae599ab 100644 --- a/FF/VelocityGradient.C +++ b/FF/VelocityGradient.C @@ -22,10 +22,10 @@ void preciceAdapter::FF::VelocityGradient::write(double* buffer, bool meshConnec int patchID = patchIDs_.at(j); // Get the velocity gradient boundary patch - vectorField gradientPatch = + vectorField gradientPatch( refCast( U_->boundaryFieldRef()[patchID]) - .snGrad(); + .snGrad()); // For every cell of the patch forAll(gradientPatch, i) diff --git a/FF/VelocityGradient.H b/FF/VelocityGradient.H index d3715efb..c3ce7368 100644 --- a/FF/VelocityGradient.H +++ b/FF/VelocityGradient.H @@ -25,10 +25,10 @@ public: const std::string nameU); //- Write the velocity gradient values into the buffer - void write(double* buffer, bool meshConnectivity, const unsigned int dim); + void write(double* buffer, bool meshConnectivity, const unsigned int dim) override; //- Read the velocity gradient values from the buffer - void read(double* buffer, const unsigned int dim); + void read(double* buffer, const unsigned int dim) override; bool isLocationTypeSupported(const bool meshConnectivity) const override; diff --git a/FSI/Displacement.H b/FSI/Displacement.H index f8b0e213..64631852 100644 --- a/FSI/Displacement.H +++ b/FSI/Displacement.H @@ -36,10 +36,10 @@ public: const std::string nameCellDisplacement); //- Write the displacement values into the buffer - void write(double* buffer, bool meshConnectivity, const unsigned int dim); + void write(double* buffer, bool meshConnectivity, const unsigned int dim) override; //- Read the displacement values from the buffer - void read(double* buffer, const unsigned int dim); + void read(double* buffer, const unsigned int dim) override; bool isLocationTypeSupported(const bool meshConnectivity) const override; diff --git a/FSI/DisplacementDelta.H b/FSI/DisplacementDelta.H index fbc579ce..25f162c5 100644 --- a/FSI/DisplacementDelta.H +++ b/FSI/DisplacementDelta.H @@ -36,10 +36,10 @@ public: const std::string nameCellDisplacement); //- Write the displacementDelta values into the buffer - void write(double* buffer, bool meshConnectivity, const unsigned int dim); + void write(double* buffer, bool meshConnectivity, const unsigned int dim) override; //- Read the displacementDelta values from the buffer - void read(double* buffer, const unsigned int dim); + void read(double* buffer, const unsigned int dim) override; bool isLocationTypeSupported(const bool meshConnectivity) const override; diff --git a/FSI/FSI.C b/FSI/FSI.C index 91571f62..a10e0326 100644 --- a/FSI/FSI.C +++ b/FSI/FSI.C @@ -47,7 +47,7 @@ bool preciceAdapter::FSI::FluidStructureInteraction::configure(const IOdictionar bool preciceAdapter::FSI::FluidStructureInteraction::readConfig(const IOdictionary& adapterConfig) { - const dictionary FSIdict = adapterConfig.subOrEmptyDict("FSI"); + const dictionary& FSIdict = adapterConfig.subOrEmptyDict("FSI"); // Read the solver type (if not specified, it is determined automatically) solverType_ = FSIdict.lookupOrDefault("solverType", ""); @@ -81,7 +81,7 @@ std::string preciceAdapter::FSI::FluidStructureInteraction::determineSolverType( if (mesh_.foundObject("p")) { - volScalarField p_ = mesh_.lookupObject("p"); + const volScalarField& p_ = mesh_.lookupObject("p"); if (p_.dimensions() == pressureDimensionsCompressible) { diff --git a/FSI/Force.C b/FSI/Force.C index c521de05..46c298fb 100644 --- a/FSI/Force.C +++ b/FSI/Force.C @@ -41,7 +41,7 @@ std::string preciceAdapter::FSI::Force::getDataName() const return "Force"; } -vectorField preciceAdapter::FSI::Force::getFaceVectors(const unsigned int patchID) const +Foam::tmp preciceAdapter::FSI::Force::getFaceVectors(const unsigned int patchID) const { // Normal vectors multiplied by face area return mesh_.boundary()[patchID].Sf(); diff --git a/FSI/Force.H b/FSI/Force.H index a9c0e38a..062e42c0 100644 --- a/FSI/Force.H +++ b/FSI/Force.H @@ -22,10 +22,10 @@ public: const std::string solverType); //- Write the forces values into the buffer - void write(double* buffer, bool meshConnectivity, const unsigned int dim); + void write(double* buffer, bool meshConnectivity, const unsigned int dim) override; //- Read the forces values from the buffer - void read(double* buffer, const unsigned int dim); + void read(double* buffer, const unsigned int dim) override; bool isLocationTypeSupported(const bool meshConnectivity) const override; @@ -33,7 +33,7 @@ public: std::string getDataName() const override; //- Returns the normal vectors multiplied by the face area - Foam::vectorField getFaceVectors(const unsigned int patchID) const override; + Foam::tmp getFaceVectors(const unsigned int patchID) const override; //- Destructor ~Force(); diff --git a/FSI/ForceBase.C b/FSI/ForceBase.C index 2ef28e6d..37e1c9e8 100644 --- a/FSI/ForceBase.C +++ b/FSI/ForceBase.C @@ -145,15 +145,13 @@ void preciceAdapter::FSI::ForceBase::writeToBuffer(double* buffer, trho().boundaryField(); // Pressure boundary field - tmp tp = mesh_.lookupObject("p"); - const volScalarField::Boundary& pb( - tp().boundaryField()); + const auto& pb = mesh_.lookupObject("p").boundaryField(); // For every boundary patch of the interface for (const label patchID : patchIDs_) { - - const auto& surface = getFaceVectors(patchID); + tmp tsurface = getFaceVectors(patchID); + const auto& surface = tsurface(); // Pressure forces // FIXME: We need to substract the reference pressure for incompressible calculations diff --git a/FSI/ForceBase.H b/FSI/ForceBase.H index a30c3bb4..38643333 100644 --- a/FSI/ForceBase.H +++ b/FSI/ForceBase.H @@ -45,7 +45,7 @@ public: void readFromBuffer(double* buffer) const; - virtual Foam::vectorField getFaceVectors(const unsigned int patchID) const = 0; + virtual Foam::tmp getFaceVectors(const unsigned int patchID) const = 0; }; } } diff --git a/FSI/Stress.C b/FSI/Stress.C index dd0ed9b7..c5ba6d10 100644 --- a/FSI/Stress.C +++ b/FSI/Stress.C @@ -41,7 +41,7 @@ std::string preciceAdapter::FSI::Stress::getDataName() const return "Stress"; } -vectorField preciceAdapter::FSI::Stress::getFaceVectors(const unsigned int patchID) const +Foam::tmp preciceAdapter::FSI::Stress::getFaceVectors(const unsigned int patchID) const { // face normal vectors return mesh_.boundary()[patchID].nf(); diff --git a/FSI/Stress.H b/FSI/Stress.H index 64e3d2ff..0e82aa34 100644 --- a/FSI/Stress.H +++ b/FSI/Stress.H @@ -27,10 +27,10 @@ public: const std::string solverType); //- Write the stress values into the buffer - void write(double* buffer, bool meshConnectivity, const unsigned int dim); + void write(double* buffer, bool meshConnectivity, const unsigned int dim) override; //- Read the stress values from the buffer - void read(double* buffer, const unsigned int dim); + void read(double* buffer, const unsigned int dim) override; bool isLocationTypeSupported(const bool meshConnectivity) const override; @@ -38,7 +38,7 @@ public: std::string getDataName() const override; //- Returns the face normal vectors (no multiplication by area) - Foam::vectorField getFaceVectors(const unsigned int patchID) const override; + Foam::tmp getFaceVectors(const unsigned int patchID) const override; //- Destructor ~Stress(); diff --git a/preciceAdapterFunctionObject.H b/preciceAdapterFunctionObject.H index f60aeb35..99f9f5fd 100644 --- a/preciceAdapterFunctionObject.H +++ b/preciceAdapterFunctionObject.H @@ -84,11 +84,11 @@ class preciceAdapterFunctionObject // Private Member Functions - //- Disallow default bitwise copy construct - preciceAdapterFunctionObject(const preciceAdapterFunctionObject&); + //- No copy construct + preciceAdapterFunctionObject(const preciceAdapterFunctionObject&) = delete; - //- Disallow default bitwise assignment - void operator=(const preciceAdapterFunctionObject&); + //- No copy assignment + void operator=(const preciceAdapterFunctionObject&) = delete; public: From f34dfd259542f01b623256b31d86819a0f720d0e Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Fri, 14 Jan 2022 08:32:54 +0100 Subject: [PATCH 29/46] Bump versions to OpenFOAM v2112 and preCICE v2.3.0 (#211) * Bump versions to OpenFOAM v2112 and preCICE v2.3.0 * Switch clang-format-action version to main --- .github/workflows/build.yml | 4 ++-- .github/workflows/check-format.yml | 2 +- .github/workflows/install-dependencies.sh | 10 +++++----- README.md | 2 +- changelog-entries/211.md | 1 + docs/openfoam-support.md | 8 ++++---- 6 files changed, 14 insertions(+), 13 deletions(-) create mode 100644 changelog-entries/211.md diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a0df2b3d..c1ecb910 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build with OpenFOAM v2106 +name: Build with OpenFOAM v2112 on: [push, pull_request] jobs: build: @@ -21,4 +21,4 @@ jobs: snapshot: '/' exclude: '/boot /data /dev /mnt /proc /run /sys' - name: Build OpenFOAM-preCICE adapter - run: /usr/bin/openfoam2106 ./Allwmake + run: /usr/bin/openfoam2112 ./Allwmake diff --git a/.github/workflows/check-format.yml b/.github/workflows/check-format.yml index 7140b81c..1ade288c 100644 --- a/.github/workflows/check-format.yml +++ b/.github/workflows/check-format.yml @@ -7,7 +7,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Run clang-format style check for C/C++ programs. - uses: jidicula/clang-format-action@v3.3.0 + uses: jidicula/clang-format-action@main with: clang-format-version: '11' check-path: '.' diff --git a/.github/workflows/install-dependencies.sh b/.github/workflows/install-dependencies.sh index c9975495..3c2f2363 100755 --- a/.github/workflows/install-dependencies.sh +++ b/.github/workflows/install-dependencies.sh @@ -1,9 +1,9 @@ #!/bin/bash -e -# Install OpenFOAM v2106 +# Install OpenFOAM v2112 wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash -sudo apt-get install openfoam2106-dev +sudo apt-get install openfoam2112-dev -# Install preCICE v2.2.1 -wget https://github.com/precice/precice/releases/download/v2.2.1/libprecice2_2.2.1_focal.deb -sudo apt install ./libprecice2_2.2.1_focal.deb +# Install preCICE v2.3.0 +wget https://github.com/precice/precice/releases/download/v2.3.0/libprecice2_2.3.0_focal.deb +sudo apt install ./libprecice2_2.3.0_focal.deb diff --git a/README.md b/README.md index e7da4f32..6602e0ef 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # OpenFOAM-preCICE adapter -[![Build with OpenFOAM v2106](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 v2112](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/211.md b/changelog-entries/211.md new file mode 100644 index 00000000..7131054f --- /dev/null +++ b/changelog-entries/211.md @@ -0,0 +1 @@ +- OpenFOAM version bumped to v2112 in GitHub Actions (including preCICE v2.2.1 --> v2.3.0) and documentation. GitHub Action clang-format-action switched to main branch. [#211](https://github.com/precice/openfoam-adapter/pull/211) diff --git a/docs/openfoam-support.md b/docs/openfoam-support.md index 432826fa..81fe7df2 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 v2106 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 v2112 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 v2106: -sudo apt-get install openfoam2106-dev +# Install OpenFOAM v2112: +sudo apt-get install openfoam2112-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 branches and [release archives](https://github.com/precice/openfoam-adapter/releases/latest) for: - OpenCFD / ESI (openfoam.com) - main focus: - - [OpenFOAM v1812-v2106](https://github.com/precice/openfoam-adapter) or newer + - [OpenFOAM v1812-v2112](https://github.com/precice/openfoam-adapter) or newer - [OpenFOAM v1612-v1806](https://github.com/precice/openfoam-adapter/tree/OpenFOAMv1806) - OpenFOAM Foundation (openfoam.org) - secondary, consider experimental: - [OpenFOAM 8](https://github.com/precice/openfoam-adapter/tree/OpenFOAM8) From cac39b8359afdb27577e3c4c8d2b2ac0b4c7d913 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Mon, 24 Jan 2022 09:05:02 +0100 Subject: [PATCH 30/46] Remove explicit casting of boundary conditions (#195) * Remove explicit casting of boundary conditions * Remove remaining cast's of write functions * Add a changelog entry --- CHT/HeatFlux.C | 3 +-- FF/PressureGradient.C | 6 ++---- FF/VelocityGradient.C | 6 ++---- changelog-entries/195.md | 1 + 4 files changed, 6 insertions(+), 10 deletions(-) create mode 100644 changelog-entries/195.md diff --git a/CHT/HeatFlux.C b/CHT/HeatFlux.C index f9afeb63..27dcfa41 100644 --- a/CHT/HeatFlux.C +++ b/CHT/HeatFlux.C @@ -28,8 +28,7 @@ void preciceAdapter::CHT::HeatFlux::write(double* buffer, bool meshConnectivity, int patchID = patchIDs_.at(j); const scalarField gradientPatch( - refCast( - T_->boundaryField()[patchID]) + (T_->boundaryField()[patchID]) .snGrad()); // Extract the effective conductivity on the patch diff --git a/FF/PressureGradient.C b/FF/PressureGradient.C index 9ae3e4b1..ef8dd9ff 100644 --- a/FF/PressureGradient.C +++ b/FF/PressureGradient.C @@ -22,10 +22,8 @@ void preciceAdapter::FF::PressureGradient::write(double* buffer, bool meshConnec int patchID = patchIDs_.at(j); // Get the pressure gradient boundary patch - scalarField gradientPatch( - refCast( - p_->boundaryFieldRef()[patchID]) - .snGrad()); + const scalarField gradientPatch((p_->boundaryFieldRef()[patchID]) + .snGrad()); // For every cell of the patch forAll(gradientPatch, i) diff --git a/FF/VelocityGradient.C b/FF/VelocityGradient.C index 4ae599ab..8c100602 100644 --- a/FF/VelocityGradient.C +++ b/FF/VelocityGradient.C @@ -22,10 +22,8 @@ void preciceAdapter::FF::VelocityGradient::write(double* buffer, bool meshConnec int patchID = patchIDs_.at(j); // Get the velocity gradient boundary patch - vectorField gradientPatch( - refCast( - U_->boundaryFieldRef()[patchID]) - .snGrad()); + vectorField gradientPatch((U_->boundaryFieldRef()[patchID]) + .snGrad()); // For every cell of the patch forAll(gradientPatch, i) diff --git a/changelog-entries/195.md b/changelog-entries/195.md new file mode 100644 index 00000000..4778bdc4 --- /dev/null +++ b/changelog-entries/195.md @@ -0,0 +1 @@ +- Remove explicit casting of boundary conditions in the adapter's write function in order to allow more boundary conditions to be compatible with the adapter (e.g. groovyBC) [#195](https://github.com/precice/openfoam-adapter/pull/195) From 2f722a741fff766e74cba321cb0d85a43f5d4845 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Wed, 26 Jan 2022 16:51:04 +0100 Subject: [PATCH 31/46] Update changelog for version v1.0.1 (#213) * Update changelog for version 1.0.1 * Apply suggestions from code review --- Adapter.C | 2 +- CHANGELOG.md | 20 ++++++++++++++++++++ changelog-entries/185.md | 1 - changelog-entries/188.md | 1 - changelog-entries/195.md | 1 - changelog-entries/197.md | 1 - changelog-entries/201.md | 1 - changelog-entries/203.md | 1 - changelog-entries/206.md | 1 - changelog-entries/211.md | 1 - 10 files changed, 21 insertions(+), 9 deletions(-) delete mode 100644 changelog-entries/185.md delete mode 100644 changelog-entries/188.md delete mode 100644 changelog-entries/195.md delete mode 100644 changelog-entries/197.md delete mode 100644 changelog-entries/201.md delete mode 100644 changelog-entries/203.md delete mode 100644 changelog-entries/206.md delete mode 100644 changelog-entries/211.md diff --git a/Adapter.C b/Adapter.C index 7d8cf6d6..7f1c90bc 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 - unreleased version.", "info"); + adapterInfo("Loaded the OpenFOAM-preCICE adapter - v1.0.1.", "info"); return; } diff --git a/CHANGELOG.md b/CHANGELOG.md index 78bee3c6..03135813 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,26 @@ Read more details in the issue [#52: Releases and versioning](https://github.com ## [Unreleased] +## [v1.0.1] 2022-01-24 + +### Added + +- Added a check for data fields and supported location types of the coupling interface [#206](https://github.com/precice/openfoam-adapter/pull/206). +- Extended the adapter's DEBUG output to print the rank in addition to the message in parallel runs +[#201](https://github.com/precice/openfoam-adapter/pull/201). + +### Changed + +- Removed explicit casting of boundary conditions in the adapter's write function in order to allow more boundary conditions to be compatible with the adapter (e.g. groovyBC) [#195](https://github.com/precice/openfoam-adapter/pull/195). +- OpenFOAM version bumped to v2112 in GitHub Actions (including preCICE v2.2.1 --> v2.3.0) and documentation. GitHub Action clang-format-action switched to main branch. [#211](https://github.com/precice/openfoam-adapter/pull/211). +- Cleaned-up the handling of adding checkpoint fields and replaced various unnecessary copies by references [#209](https://github.com/precice/openfoam-adapter/pull/209). + +### Fixed + +- Fixed a potential memory access issue in the xy-alignment check for parallel 2D cases [#202](https://github.com/precice/openfoam-adapter/issues/202). +- Fixed a bug that was not allowing more than one module at the same time and added an error message for the case when a dataset is not known by any or too many modules. [#197](https://github.com/precice/openfoam-adapter/pull/197). +- Fixed the misplaced data reading in the adapter 'advance' function [#188](https://github.com/precice/openfoam-adapter/pull/188). + ## [v1.0.0] 2021-04-29 ### Added diff --git a/changelog-entries/185.md b/changelog-entries/185.md deleted file mode 100644 index e2e15152..00000000 --- a/changelog-entries/185.md +++ /dev/null @@ -1 +0,0 @@ -- OpenFOAM version bumped to v2106 in GitHub Actions (including preCICE v2.2.0 --> v2.2.1) and documentation. [#185](https://github.com/precice/openfoam-adapter/pull/185) diff --git a/changelog-entries/188.md b/changelog-entries/188.md deleted file mode 100644 index 5ebb3871..00000000 --- a/changelog-entries/188.md +++ /dev/null @@ -1 +0,0 @@ -- Fixed the misplaced data reading in the adapter 'advance' function [#188](https://github.com/precice/openfoam-adapter/pull/188) diff --git a/changelog-entries/195.md b/changelog-entries/195.md deleted file mode 100644 index 4778bdc4..00000000 --- a/changelog-entries/195.md +++ /dev/null @@ -1 +0,0 @@ -- Remove explicit casting of boundary conditions in the adapter's write function in order to allow more boundary conditions to be compatible with the adapter (e.g. groovyBC) [#195](https://github.com/precice/openfoam-adapter/pull/195) diff --git a/changelog-entries/197.md b/changelog-entries/197.md deleted file mode 100644 index b6a532c8..00000000 --- a/changelog-entries/197.md +++ /dev/null @@ -1 +0,0 @@ -- Fixed a bug that was not allowing more than one module at the same time and added an error message for the case when a dataset is not known by any or too many modules. [#197](https://github.com/precice/openfoam-adapter/pull/197) diff --git a/changelog-entries/201.md b/changelog-entries/201.md deleted file mode 100644 index aa12de56..00000000 --- a/changelog-entries/201.md +++ /dev/null @@ -1 +0,0 @@ -- Extended the adapter DEBUG output to print the rank in addition to the message [#201](https://github.com/precice/openfoam-adapter/pull/201) diff --git a/changelog-entries/203.md b/changelog-entries/203.md deleted file mode 100644 index 693707a6..00000000 --- a/changelog-entries/203.md +++ /dev/null @@ -1 +0,0 @@ -- Fixed a potential memory access issue in the xy-alignment check for parallel 2D cases [#202](https://github.com/precice/openfoam-adapter/issues/202) diff --git a/changelog-entries/206.md b/changelog-entries/206.md deleted file mode 100644 index 862d3646..00000000 --- a/changelog-entries/206.md +++ /dev/null @@ -1 +0,0 @@ -- added a check for data fields and supported location types of the coupling interface [#206](https://github.com/precice/openfoam-adapter/pull/206) diff --git a/changelog-entries/211.md b/changelog-entries/211.md deleted file mode 100644 index 7131054f..00000000 --- a/changelog-entries/211.md +++ /dev/null @@ -1 +0,0 @@ -- OpenFOAM version bumped to v2112 in GitHub Actions (including preCICE v2.2.1 --> v2.3.0) and documentation. GitHub Action clang-format-action switched to main branch. [#211](https://github.com/precice/openfoam-adapter/pull/211) From 114f38c2db2d4e5ada137fef5975758f18906dc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Simonis?= Date: Fri, 28 Jan 2022 01:26:36 +0100 Subject: [PATCH 32/46] Migrate doc notes to blocks (#212) --- docs/README.md | 4 +++- docs/config.md | 9 ++++++--- docs/openfoam-support.md | 4 +++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/README.md b/docs/README.md index 92c60076..36027891 100644 --- a/docs/README.md +++ b/docs/README.md @@ -58,4 +58,6 @@ For CHT-specific topics, you may want to additionally look into [2] and for FSI [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. -{% include disclaimer.html content="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." %} +{% 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. +{% enddisclaimer %} diff --git a/docs/config.md b/docs/config.md index fdb8a001..6371bac7 100644 --- a/docs/config.md +++ b/docs/config.md @@ -122,7 +122,9 @@ writeData For fluid-structure interaction, `writeData` can be `Force` or `Stress`, where `Stress` is essentially a force vector scaled by the cell face in spatial coordinates (with any postfix), thus, a conservative quantity as well.`readData` can be `Displacement` and `DisplacementDelta` (with any postfix). `DisplacementDelta` refers to the last coupling time step, which needs to considered in the case of subcycling. -{% include warning.html content="You will run into problems when you use `Displacement(Delta)` as write data set and execute RBF mappings in parallel. This would affect users who use OpenFOAM and the adapter as the Solid participant in order to compute solid mechanics with OpenFOAM (currently not officially supported at all). Have a look [at this issue on GitHub](https://github.com/precice/openfoam-adapter/issues/153) for details." %} +{% warning %} +You will run into problems when you use `Displacement(Delta)` as write data set and execute RBF mappings in parallel. This would affect users who use OpenFOAM and the adapter as the Solid participant in order to compute solid mechanics with OpenFOAM (currently not officially supported at all). Have a look [at this issue on GitHub](https://github.com/precice/openfoam-adapter/issues/153) for details. +{% endwarning %} ## Configuration of the OpenFOAM case @@ -274,8 +276,9 @@ As described already, the data is not stored on the face nodes, but on the face Data is obtained at the face centers, then interpolated to face nodes. Here, we have provided mesh connectivity and finally, preCICE performs the nearest-projection mapping. It is important to notice that the target data location is again the face center mesh of the coupling partner. In the standard CHT case, where both data sets are exchanged by a nearest-projection mapping, this leads to two interface meshes (centers and nodes) per participant. Having both the centers and nodes defined, we can skip one interpolation step and read data directly to the centers (cf. picture solver B). -{% include note.html content="As already mentioned, the `Fluid` participant does not need to provide the mesh connectivity in case of a standard FSI. Therefore, the `Solid` participant needs to provide it and nothing special needs to be considered compared to other mapping methods. This implementation supports all CHT-related fields, which are mapped with a `consistent` constraint. -" %} +{% note %} +As already mentioned, the `Fluid` participant does not need to provide the mesh connectivity in case of a standard FSI. Therefore, the `Solid` participant needs to provide it and nothing special needs to be considered compared to other mapping methods. This implementation supports all CHT-related fields, which are mapped with a `consistent` constraint. +{% endnote %} ### Additional properties for some solvers diff --git a/docs/openfoam-support.md b/docs/openfoam-support.md index 81fe7df2..bbe3c3c6 100644 --- a/docs/openfoam-support.md +++ b/docs/openfoam-support.md @@ -133,4 +133,6 @@ However, if you set a *fixed timestep* and *runTimeModifiable*, changing the configured timestep *during the simulation* will not affect the timestep used. A warning will be shown in this case. -{% include disclaimer.html content="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." %} +{% 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. +{% enddisclaimer %} From fc55140559319d6e5ccd31daabd4a5e0b021402c Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Tue, 1 Feb 2022 22:12:28 +0100 Subject: [PATCH 33/46] Add a custom build workflow (#214) --- .github/workflows/build-custom.yml | 194 +++++++++++++++++++++++++++++ CHANGELOG.md | 1 + CONTRIBUTING.md | 7 ++ 3 files changed, 202 insertions(+) create mode 100644 .github/workflows/build-custom.yml diff --git a/.github/workflows/build-custom.yml b/.github/workflows/build-custom.yml new file mode 100644 index 00000000..5a4e0387 --- /dev/null +++ b/.github/workflows/build-custom.yml @@ -0,0 +1,194 @@ +name: Custom build (manual) # Unfortunately, we cannot modify the name: https://github.community/t/github-actions-dynamic-name-of-the-workflow-with-workflow-dispatch/150327 +on: + workflow_dispatch: + inputs: + virtualEnvironment: + description: 'Virtual Environment' + default: 'ubuntu-18.04' + required: true + type: choice + options: + - ubuntu-20.04 + - ubuntu-18.04 + refAdapter: + description: 'Ref (branch/tag/commit) of the OpenFOAM adapter to build' + default: 'develop' + required: true + versionOpenFOAM: + description: 'Version of OpenFOAM to build with' + required: true + type: choice + options: + - OpenFOAMv2112 + - OpenFOAMv2106 + - OpenFOAMv2012 + - OpenFOAMv2006 + - OpenFOAMv1912 + - OpenFOAM9 + - OpenFOAM8 + - OpenFOAM7 + - OpenFOAM6 + - OpenFOAM5 + versionpreCICE: + description: 'Version of preCICE to build with' + default: '2.3.0' + required: true + runTutorialHeatedPlate: + description: Run tutorial flow-over-heated-plate + type: boolean + default: true + required: true + runTutorialQuickstart: + description: Run tutorial quickstart + type: boolean + default: true + required: true + branchTutorials: + description: 'Branch of the tutorials to use' + default: 'master' + required: true + +jobs: + build: + runs-on: ${{ github.event.inputs.virtualEnvironment }} + steps: + - name: Report log + run: | + echo "Initiated by: ${{ github.actor }}" + echo "Runs on: ${{ github.event.inputs.virtualEnvironment }}" + echo "Adapter ref (branch/tag/commit): ${{ github.event.inputs.refAdapter }}" + echo "OpenFOAM version: ${{ github.event.inputs.versionOpenFOAM }}" + echo "preCICE version: ${{ github.event.inputs.versionpreCICE }}" + echo "Run tutorial flow-over-heated-plate: ${{ github.event.inputs.runTutorialHeatedPlate }}" + echo "Run tutorial quickstart: ${{ github.event.inputs.runTutorialQuickstart }}" + echo "Tutorials branch: ${{ github.event.inputs.branchTutorials }}" + - name: Check out repository + uses: actions/checkout@v2 + with: + ref: ${{ github.event.inputs.refAdapter }} + - name: Install OpenFOAM (no cache) + id: installOpenFOAM + run: | + case "${{ github.event.inputs.versionOpenFOAM }}" in + 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";; + 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";; + 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";; + 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";; + 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";; + 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 &&";; + 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 &&";; + 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 &&";; + 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 &&";; + 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 "I cannot find ${{ github.event.inputs.refAdapter }} in my known options." + exit 1;; + esac + - name: Install preCICE (no cache) + run: | + if [ "${{ 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 + - name: Build OpenFOAM-preCICE adapter + run: | + ${{steps.installOpenFOAM.outputs.openfoam_exec}} ./Allwmake + - name: Get tutorials + run: | + git clone https://github.com/precice/tutorials.git --branch ${{ github.event.inputs.branchTutorials }} --depth 1 + - name: Run tutorial flow-over-heated-plate + run: | + if ${{ github.event.inputs.runTutorialHeatedPlate }} + then + cd tutorials/flow-over-heated-plate/fluid-openfoam + ${{steps.installOpenFOAM.outputs.openfoam_exec}} ./run.sh | tee fluid-openfoam.log 2>&1 & + PIDfluid=$! + cd ../solid-openfoam + ${{steps.installOpenFOAM.outputs.openfoam_exec}} ./run.sh | tee solid-openfoam.log 2>&1 + wait $PIDfluid + fi + - name: Run tutorial quickstart + run: | + if ${{ github.event.inputs.runTutorialQuickstart }} + then + cd tutorials/quickstart/fluid-openfoam + if [ "${{ github.event.inputs.versionOpenFOAM }}" == "OpenFOAM5" ] + then + echo "Manually changing from pimpleFoam to pimpleDyMFoam for compatibility with OpenFOAM 5." + sed -i 's/pimpleFoam/pimpleDyMFoam/g' system/controlDict + fi + ${{steps.installOpenFOAM.outputs.openfoam_exec}} ./run.sh | tee fluid-openfoam.log 2>&1 & + PIDfluid=$! + cd ../solid-cpp + cmake . && make && ./run.sh | tee solid-cpp.log 2>&1 + wait $PIDfluid + cd ../.. + fi + - name: Archive logs + uses: actions/upload-artifact@v2 + with: + name: logs + path: | + Allwmake.log + wmake.log + ldd.log + tutorials/flow-over-heated-plate/fluid-openfoam/fluid-openfoam.log + tutorials/flow-over-heated-plate/solid-openfoam/solid-openfoam.log + tutorials/quickstart/fluid-openfoam/fluid-openfoam.log + tutorials/quickstart/solid-cpp/solid-cpp.log + - name: Archive case files + uses: actions/upload-artifact@v2 + with: + name: case-files + path: | + tutorials/flow-over-heated-plate/fluid-openfoam/* + tutorials/flow-over-heated-plate/solid-openfoam/* + tutorials/quickstart/fluid-openfoam/* + tutorials/quickstart/solid-cpp/* diff --git a/CHANGELOG.md b/CHANGELOG.md index 03135813..707fb222 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ Read more details in the issue [#52: Releases and versioning](https://github.com - Added a check for data fields and supported location types of the coupling interface [#206](https://github.com/precice/openfoam-adapter/pull/206). - Extended the adapter's DEBUG output to print the rank in addition to the message in parallel runs [#201](https://github.com/precice/openfoam-adapter/pull/201). +- Added a custom build workflow to check building the adapter with any supported OpenFOAM version [#214](https://github.com/precice/openfoam-adapter/pull/214). ### Changed diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 633f8f3e..a96f4c0e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,3 +13,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`. + +## Automatic checks + +We check every contribution with a few GitHub Actions workflows that report at the bottom of each pull request. + +Additionally, there is an "custom build" workflow, which can be triggered manually to build any branch of the repository +with any of the available OpenFOAM versions. Members of the repository can trigger this workflow in the "Actions" tab. From 37067a47815694772e546655a4fbb0ae3c7fa078 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Tue, 1 Feb 2022 22:54:51 +0100 Subject: [PATCH 34/46] Disable automatic links checking (make manual) (#215) --- .github/workflows/check-links.yml | 14 ++++++++++++++ .github/workflows/check-markdown.yml | 8 +------- CHANGELOG.md | 1 + CONTRIBUTING.md | 8 ++++++-- 4 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/check-links.yml diff --git a/.github/workflows/check-links.yml b/.github/workflows/check-links.yml new file mode 100644 index 00000000..f7e0ce61 --- /dev/null +++ b/.github/workflows/check-links.yml @@ -0,0 +1,14 @@ +name: Check links (manual) +on: workflow_dispatch +jobs: + check_links: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v2 + - 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/check-markdown.yml b/.github/workflows/check-markdown.yml index 5bdd3d09..63a0df9a 100644 --- a/.github/workflows/check-markdown.yml +++ b/.github/workflows/check-markdown.yml @@ -1,4 +1,4 @@ -name: Lint docs and check links +name: Lint docs on: [push, pull_request] jobs: check_md: @@ -12,9 +12,3 @@ jobs: config: .markdownlint.json files: '.' ignore: changelog-entries - - 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/CHANGELOG.md b/CHANGELOG.md index 707fb222..c2154071 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ Read more details in the issue [#52: Releases and versioning](https://github.com - Removed explicit casting of boundary conditions in the adapter's write function in order to allow more boundary conditions to be compatible with the adapter (e.g. groovyBC) [#195](https://github.com/precice/openfoam-adapter/pull/195). - OpenFOAM version bumped to v2112 in GitHub Actions (including preCICE v2.2.1 --> v2.3.0) and documentation. GitHub Action clang-format-action switched to main branch. [#211](https://github.com/precice/openfoam-adapter/pull/211). - Cleaned-up the handling of adding checkpoint fields and replaced various unnecessary copies by references [#209](https://github.com/precice/openfoam-adapter/pull/209). +- Disabled automatic checking of links. This is now a manual workflow [#215](https://github.com/precice/openfoam-adapter/pull/215). ### Fixed diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a96f4c0e..ca2cd78a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,5 +18,9 @@ You can format all files with clang-format 11 by running `./tools/format-code.sh We check every contribution with a few GitHub Actions workflows that report at the bottom of each pull request. -Additionally, there is an "custom build" workflow, which can be triggered manually to build any branch of the repository -with any of the available OpenFOAM versions. Members of the repository can trigger this workflow in the "Actions" tab. +There are also a few additional workflows that can be triggered manually: + +- `Custom build`: builds any branch of the repository with any of the available OpenFOAM versions. +- `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. From 66c2af685ba778b0acd7fcb6410b716969f79556 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Wed, 2 Feb 2022 10:43:39 +0100 Subject: [PATCH 35/46] Restrict OpenFOAM v2112 build events --- .github/workflows/build.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c1ecb910..446467a4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,11 @@ name: Build with OpenFOAM v2112 -on: [push, pull_request] +on: + push: + branches-ignore: + - 'OpenFOAM*' + pull_request: + branches-ignore: + - 'OpenFOAM*' jobs: build: runs-on: ubuntu-20.04 From 30b97a3f4dff664c9f79afd0483bb13e6b124a01 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Wed, 2 Feb 2022 20:05:52 +0100 Subject: [PATCH 36/46] Do not run build workflow when only updating docs --- .github/workflows/build.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 446467a4..2a7d3981 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,9 +3,21 @@ on: push: branches-ignore: - 'OpenFOAM*' + paths-ignore: + - 'docs/**' + - 'tools/**' + - 'CHANGELOG.md' + - 'CONTRIBUTING.md' + - 'README.md' pull_request: branches-ignore: - 'OpenFOAM*' + paths-ignore: + - 'docs/**' + - 'tools/**' + - 'CHANGELOG.md' + - 'CONTRIBUTING.md' + - 'README.md' jobs: build: runs-on: ubuntu-20.04 From dc9774920402e736aca5159e33bd74b3e4abfd88 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Thu, 3 Feb 2022 22:32:31 +0100 Subject: [PATCH 37/46] Add partitioned-pipe tutorial to the custom build (#217) This way, we can test also the FF module of the adapter. --- .github/workflows/build-custom.yml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-custom.yml b/.github/workflows/build-custom.yml index 5a4e0387..d1651454 100644 --- a/.github/workflows/build-custom.yml +++ b/.github/workflows/build-custom.yml @@ -43,6 +43,11 @@ on: type: boolean default: true required: true + runTutorialPartitionedPipe: + description: Run tutorial partitioned-pipe + type: boolean + default: true + required: true branchTutorials: description: 'Branch of the tutorials to use' default: 'master' @@ -61,6 +66,7 @@ jobs: echo "preCICE version: ${{ github.event.inputs.versionpreCICE }}" echo "Run tutorial flow-over-heated-plate: ${{ github.event.inputs.runTutorialHeatedPlate }}" echo "Run tutorial quickstart: ${{ github.event.inputs.runTutorialQuickstart }}" + echo "Run tutorial partitioned-pipe: ${{ github.event.inputs.runTutorialPartitionedPipe }}" echo "Tutorials branch: ${{ github.event.inputs.branchTutorials }}" - name: Check out repository uses: actions/checkout@v2 @@ -169,7 +175,17 @@ jobs: cd ../solid-cpp cmake . && make && ./run.sh | tee solid-cpp.log 2>&1 wait $PIDfluid - cd ../.. + fi + - name: Run tutorial partitioned-pipe + run: | + if ${{ github.event.inputs.runTutorialPartitionedPipe }} + then + cd tutorials/partitioned-pipe/fluid1-openfoam-pimplefoam + ${{steps.installOpenFOAM.outputs.openfoam_exec}} ./run.sh | tee fluid1-openfoam-pimplefoam.log 2>&1 & + PIDfluid=$! + cd ../fluid2-openfoam-pimplefoam + ${{steps.installOpenFOAM.outputs.openfoam_exec}} ./run.sh | tee fluid2-openfoam-pimplefoam.log 2>&1 & + wait $PIDfluid fi - name: Archive logs uses: actions/upload-artifact@v2 @@ -183,6 +199,8 @@ jobs: tutorials/flow-over-heated-plate/solid-openfoam/solid-openfoam.log tutorials/quickstart/fluid-openfoam/fluid-openfoam.log tutorials/quickstart/solid-cpp/solid-cpp.log + 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 with: @@ -192,3 +210,5 @@ jobs: tutorials/flow-over-heated-plate/solid-openfoam/* tutorials/quickstart/fluid-openfoam/* tutorials/quickstart/solid-cpp/* + tutorials/partitioned-pipe/fluid1-openfoam-pimplefoam/* + tutorials/partitioned-pipe/fluid2-openfoam-pimplefoam/* From 006c10090a95eba75d2c0222384ca2f44529e3e9 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Sun, 6 Feb 2022 19:30:07 +0100 Subject: [PATCH 38/46] Add pull request template, document versioning (#216) --- Adapter.C | 2 +- CHANGELOG.md | 3 +- docs/get.md | 12 ++++ docs/openfoam-support.md | 8 +-- tools/release_pull_request_template.md | 79 ++++++++++++++++++++++++++ 5 files changed, 98 insertions(+), 6 deletions(-) create mode 100644 tools/release_pull_request_template.md diff --git a/Adapter.C b/Adapter.C index 7f1c90bc..a545c832 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.0.1.", "info"); + adapterInfo("Loaded the OpenFOAM-preCICE adapter - v1.1.0.", "info"); return; } diff --git a/CHANGELOG.md b/CHANGELOG.md index c2154071..0b2fcb89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ Read more details in the issue [#52: Releases and versioning](https://github.com ## [Unreleased] -## [v1.0.1] 2022-01-24 +## [v1.1.0] 2022-02-07 ### Added @@ -18,6 +18,7 @@ Read more details in the issue [#52: Releases and versioning](https://github.com - Extended the adapter's DEBUG output to print the rank in addition to the message in parallel runs [#201](https://github.com/precice/openfoam-adapter/pull/201). - Added a custom build workflow to check building the adapter with any supported OpenFOAM version [#214](https://github.com/precice/openfoam-adapter/pull/214). +- Added a release pull request template and documented the versioning strategy and release artifact names. [#216](https://github.com/precice/openfoam-adapter/pull/216) ### Changed diff --git a/docs/get.md b/docs/get.md index df30ce74..461dd461 100644 --- a/docs/get.md +++ b/docs/get.md @@ -21,6 +21,18 @@ Adding `-DADAPTER_DEBUG_MODE` flag to the `ADAPTER_PREP_FLAGS` activates additio Next: [configure and load the adapter](https://precice.org/adapter-openfoam-config.html) or [run a tutorial](https://precice.org/tutorials.html). +## What does the adapter version mean? + +We use [semantic versioning](https://semver.org/) (MAJOR.MINOR.PATCH), adapted to the nature of an adapter: + +* As "API" we define the tutorial configuration files. If you would need to update your `preciceDict`, `controlDict` or any other configuration file to keep using your simulation cases with the same OpenFOAM version, this would be a new major version. +* If you could run the same cases without any changes, but you would also get new features or modified behavior (non-trivial), then this would be a new minor version. +* If there would be only bugfixes or trivial changes not affecting the configuration or behavior, then this would be a new patch version. + +Note that the OpenFOAM version is not part of the version of the adapter. It is only reflected in the release archives, which target a range of compatible versions. By default, we support the latest OpenFOAM version from OpenCFD (openfoam.com) and we update our release archives or release a new adapter version (including more than compatibility changes) as soon as there is a new OpenFOAM version. + +Read the [discussion that lead to this versioning strategy](https://github.com/precice/openfoam-adapter/issues/52) for more details. + ## Troubleshooting The following are common problems that may appear during building the OpenFOAM adapter if something went wrong in the described steps. Make sure to always check for error messages at every step before continuing to the next. diff --git a/docs/openfoam-support.md b/docs/openfoam-support.md index bbe3c3c6..b341f1ab 100644 --- a/docs/openfoam-support.md +++ b/docs/openfoam-support.md @@ -21,19 +21,19 @@ As these steps change your `.profile`, you need to log out and in again to make ## Supported OpenFOAM versions -OpenFOAM is a project with long history and many forks, of which we try to support as many as possible. +OpenFOAM is a project with long history and many forks, of which we try to support as many as possible. Since several HPC systems only provide older versions, we try to also support a wide range of versions. -We provide version-specific branches and [release archives](https://github.com/precice/openfoam-adapter/releases/latest) for: +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-v2112](https://github.com/precice/openfoam-adapter) or newer - - [OpenFOAM v1612-v1806](https://github.com/precice/openfoam-adapter/tree/OpenFOAMv1806) + - [OpenFOAM v1612-v1806](https://github.com/precice/openfoam-adapter/tree/OpenFOAMv1806) (not tested) - OpenFOAM Foundation (openfoam.org) - secondary, consider experimental: - [OpenFOAM 8](https://github.com/precice/openfoam-adapter/tree/OpenFOAM8) - [OpenFOAM 7](https://github.com/precice/openfoam-adapter/tree/OpenFOAM7) - [OpenFOAM 6](https://github.com/precice/openfoam-adapter/tree/OpenFOAM6) - [OpenFOAM 5.x](https://github.com/precice/openfoam-adapter/tree/OpenFOAM5) - - [OpenFOAM 4.0/4.1](https://github.com/precice/openfoam-adapter/tree/OpenFOAM4) + - [OpenFOAM 4.0/4.1](https://github.com/precice/openfoam-adapter/tree/OpenFOAM4) (not tested) Known not supported versions: OpenFOAM 9 ([issue - contributions welcome](https://github.com/precice/openfoam-adapter/issues/200)), OpenFOAM v1606+ or older, OpenFOAM 3 or older, foam-extend (any version). diff --git a/tools/release_pull_request_template.md b/tools/release_pull_request_template.md new file mode 100644 index 00000000..2d405506 --- /dev/null +++ b/tools/release_pull_request_template.md @@ -0,0 +1,79 @@ +# Release checklist + +Copy this template to the release pull request description. + +## Update workflows + +- [ ] `.github/workflows/build.yml` and `.github/workflows/install-dependencies.sh`: Update the OpenFOAM and preCICE versions, if needed. +- [ ] `build-custom.yml`: Add any new OpenFOAM versions and update the default preCICE version, if needed. + +## Prepare branches + +- [ ] Merge `master` to `develop`, if needed +- [ ] Open a pull request from `develop` to `master`. + - We don't use release branches, unless there are changes we don't want to release, potentially when preparing a major release. +- [ ] Run and fix all workflows + +## Test + +- [ ] Run and check flow-over-heated-plate OpenFOAM-OpenFOAM +- [ ] Run and check quickstart +- [ ] Run and check perpendicular-flap OpenFOAM-deal.II +- [ ] Run and check elastic-tube-3d OpenFOAM-CalculiX +- [ ] Run and check partitioned-pipe sonicLiquidFoam-sonicLiquidFoam + +Until we get automated system tests again, run all the tests manually. + +## Prepare version-specific branches + +- [ ] Rebase `OpenFOAM4` on `develop` and force-push + - `git checkout OpenFOAM4 && git rebase develop` + - Resolve any conflicts. We should have only one commit in the end. + - `git push --force` +- [ ] Rebase `OpenFOAM5` on `OpenFOAM4`, `OpenFOAM6` on `OpenFOAM5`, ... +- [ ] Trigger a custom build for each version + +Overview of branches: + +```text +master <-- OpenFOAM4 <-- OpenFOAM5 <-- OpenFOAM6 <-- OpenFOAM7 <-- OpenFOAM8 <-- OpenFOAMdev +^-- develop ^-- OpenFOAMv1806 +``` + +## Preparing the Changelog + +- [ ] Copy all the changelog entries into `CHANGELOG.md` +- [ ] Delete `changelog-entries/` +- [ ] Draft and discuss release notes + +## Bump the version + +- [ ] Decide on the version using the versioning strategy documented in the user docs (see page "Get the OpenFOAM adapter") +- [ ] Bump the version in `CHANGELOG.md` +- [ ] Bump the version in `Adapter.C` + +## Merge + +- [ ] Review pull request +- [ ] Merge pull request (**not** squash) +- [ ] Merge back from `master` to `develop`. No PR is needed for that. +- [ ] Update the version in `Adapter.C` on `develop` to reflect that this is an unreleased version +- [ ] Rebase the version-specific branches on `master` + +## Release + +- [ ] Create a Release on GitHub +- [ ] Download an archive of the repository (i.e., no `.git/` or `.gitignore`) for each version and attach to the release + - branch `master`: archive `openfoam-adapter_v1.0.0_OpenFOAMv1812-v2112.tar.gz` (adjust `v2112` to the latest supported, and `v1.0.0` to the actual version) + - branch `OpenFOAM4`: archive `openfoam-adapter_v1.0.0_OpenFOAM4_5_v1806.tar.gz` + - branch `OpenFOAM6`: archive `openfoam-adapter_v1.0.0_OpenFOAM6_experimental.tar.gz` + - branch `OpenFOAM7`: archive `openfoam-adapter_v1.0.0_OpenFOAM7_experimental.tar.gz` + - branch `OpenFOAM8`: archive `openfoam-adapter_v1.0.0_OpenFOAM8_experimental.tar.gz` + +## Post-release + +- [ ] Update the git module on the website +- [ ] Update workflows in the tutorials repository, if needed (e.g., OpenFOAM version) +- [ ] Update the VM provisioning, if needed (e.g., OpenFOAM version) +- [ ] Update this release checklist (`tools/release_pull_request_template.md`) +- [ ] Advertise and celebrate! :tada: From cf4eb0f389708a35bea2fd9b762b245a9dc37114 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Mon, 7 Feb 2022 17:48:50 +0100 Subject: [PATCH 39/46] Add a hint to cite the adapter (#218) --- Adapter.C | 4 ++++ CHANGELOG.md | 1 + 2 files changed, 5 insertions(+) diff --git a/Adapter.C b/Adapter.C index a545c832..1d6ef3e9 100644 --- a/Adapter.C +++ b/Adapter.C @@ -468,6 +468,10 @@ void preciceAdapter::Adapter::execute() "The simulation was ended by preCICE. " "Calling the end() methods of any functionObject explicitly.", "info"); + adapterInfo("Great that you are using the OpenFOAM-preCICE adapter! " + "Next to the preCICE library and any other components, please also cite this adapter. " + "Find how on https://precice.org/adapter-openfoam-overview.html.", + "info"); const_cast(runTime_).functionObjects().end(); } diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b2fcb89..8967badf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ Read more details in the issue [#52: Releases and versioning](https://github.com [#201](https://github.com/precice/openfoam-adapter/pull/201). - Added a custom build workflow to check building the adapter with any supported OpenFOAM version [#214](https://github.com/precice/openfoam-adapter/pull/214). - Added a release pull request template and documented the versioning strategy and release artifact names. [#216](https://github.com/precice/openfoam-adapter/pull/216) +- Added a hint to also cite the adapter, at the end of the coupling. [#218](https://github.com/precice/openfoam-adapter/pull/218) ### Changed From 9857f0b2fa143e4665c1581c92024d30fc1100e1 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Tue, 8 Feb 2022 15:10:13 +0100 Subject: [PATCH 40/46] Add a step to specify an unreleased state in the version --- tools/release_pull_request_template.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/release_pull_request_template.md b/tools/release_pull_request_template.md index 2d405506..6c3fd167 100644 --- a/tools/release_pull_request_template.md +++ b/tools/release_pull_request_template.md @@ -50,13 +50,12 @@ master <-- OpenFOAM4 <-- OpenFOAM5 <-- OpenFOAM6 <-- OpenFOAM7 <-- OpenFOAM8 <-- - [ ] Decide on the version using the versioning strategy documented in the user docs (see page "Get the OpenFOAM adapter") - [ ] Bump the version in `CHANGELOG.md` -- [ ] Bump the version in `Adapter.C` +- [ ] Bump the version in `Adapter.C` (removing the ` + unreleased changes` part). ## Merge - [ ] Review pull request - [ ] Merge pull request (**not** squash) -- [ ] Merge back from `master` to `develop`. No PR is needed for that. - [ ] Update the version in `Adapter.C` on `develop` to reflect that this is an unreleased version - [ ] Rebase the version-specific branches on `master` @@ -72,6 +71,8 @@ master <-- OpenFOAM4 <-- OpenFOAM5 <-- OpenFOAM6 <-- OpenFOAM7 <-- OpenFOAM8 <-- ## Post-release +- [ ] Merge back from `master` to `develop`. No PR is needed for that. +- [ ] Modify the adapter version message to `Loaded the OpenFOAM-preCICE adapter v1.0.0 + unreleased changes`. - [ ] Update the git module on the website - [ ] Update workflows in the tutorials repository, if needed (e.g., OpenFOAM version) - [ ] Update the VM provisioning, if needed (e.g., OpenFOAM version) From f405b34dce1a480c4737d78d6e836ead90c3c07d Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Tue, 8 Feb 2022 15:28:25 +0100 Subject: [PATCH 41/46] Celebrate after a release --- tools/release_pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/release_pull_request_template.md b/tools/release_pull_request_template.md index 6c3fd167..5e6e860d 100644 --- a/tools/release_pull_request_template.md +++ b/tools/release_pull_request_template.md @@ -77,4 +77,4 @@ master <-- OpenFOAM4 <-- OpenFOAM5 <-- OpenFOAM6 <-- OpenFOAM7 <-- OpenFOAM8 <-- - [ ] Update workflows in the tutorials repository, if needed (e.g., OpenFOAM version) - [ ] Update the VM provisioning, if needed (e.g., OpenFOAM version) - [ ] Update this release checklist (`tools/release_pull_request_template.md`) -- [ ] Advertise and celebrate! :tada: +- [ ] Advertise and celebrate! :tada: :beers: From 50e54607a79377d0c2aa7c6ca06afa47eae545e8 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Tue, 8 Feb 2022 15:29:41 +0100 Subject: [PATCH 42/46] Fix markdown error --- tools/release_pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/release_pull_request_template.md b/tools/release_pull_request_template.md index 5e6e860d..22ccda98 100644 --- a/tools/release_pull_request_template.md +++ b/tools/release_pull_request_template.md @@ -50,7 +50,7 @@ master <-- OpenFOAM4 <-- OpenFOAM5 <-- OpenFOAM6 <-- OpenFOAM7 <-- OpenFOAM8 <-- - [ ] Decide on the version using the versioning strategy documented in the user docs (see page "Get the OpenFOAM adapter") - [ ] Bump the version in `CHANGELOG.md` -- [ ] Bump the version in `Adapter.C` (removing the ` + unreleased changes` part). +- [ ] Bump the version in `Adapter.C` (removing the `+ unreleased changes` part). ## Merge From cd5430c9541b18b371df7ab6a39e5fe8a83edf8b Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Tue, 8 Feb 2022 15:34:18 +0100 Subject: [PATCH 43/46] Add heat-exchanger in release PR template --- 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 22ccda98..a2d8303c 100644 --- a/tools/release_pull_request_template.md +++ b/tools/release_pull_request_template.md @@ -21,6 +21,7 @@ Copy this template to the release pull request description. - [ ] Run and check perpendicular-flap OpenFOAM-deal.II - [ ] Run and check elastic-tube-3d OpenFOAM-CalculiX - [ ] Run and check partitioned-pipe sonicLiquidFoam-sonicLiquidFoam +- [ ] Run and check heat-exchanger OpenFOAM-CalculiX-OpenFOAM Until we get automated system tests again, run all the tests manually. From 0fa8b5328e4effc634c6eaa19277c63cba9f2e3f Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Tue, 8 Feb 2022 15:40:45 +0100 Subject: [PATCH 44/46] Update CHANGELOG.md --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8967badf..16d551a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,23 +10,23 @@ Read more details in the issue [#52: Releases and versioning](https://github.com ## [Unreleased] -## [v1.1.0] 2022-02-07 +## [v1.1.0] 2022-02-08 ### Added - Added a check for data fields and supported location types of the coupling interface [#206](https://github.com/precice/openfoam-adapter/pull/206). - Extended the adapter's DEBUG output to print the rank in addition to the message in parallel runs [#201](https://github.com/precice/openfoam-adapter/pull/201). -- Added a custom build workflow to check building the adapter with any supported OpenFOAM version [#214](https://github.com/precice/openfoam-adapter/pull/214). +- Added a custom build GitHub workflow to check building the adapter with any supported OpenFOAM version [#214](https://github.com/precice/openfoam-adapter/pull/214). - Added a release pull request template and documented the versioning strategy and release artifact names. [#216](https://github.com/precice/openfoam-adapter/pull/216) - Added a hint to also cite the adapter, at the end of the coupling. [#218](https://github.com/precice/openfoam-adapter/pull/218) ### Changed - Removed explicit casting of boundary conditions in the adapter's write function in order to allow more boundary conditions to be compatible with the adapter (e.g. groovyBC) [#195](https://github.com/precice/openfoam-adapter/pull/195). -- OpenFOAM version bumped to v2112 in GitHub Actions (including preCICE v2.2.1 --> v2.3.0) and documentation. GitHub Action clang-format-action switched to main branch. [#211](https://github.com/precice/openfoam-adapter/pull/211). - Cleaned-up the handling of adding checkpoint fields and replaced various unnecessary copies by references [#209](https://github.com/precice/openfoam-adapter/pull/209). -- Disabled automatic checking of links. This is now a manual workflow [#215](https://github.com/precice/openfoam-adapter/pull/215). +- OpenFOAM version bumped to v2112 in GitHub Actions (including preCICE v2.2.1 --> v2.3.0) and documentation. GitHub Action clang-format-action switched to its main branch. [#211](https://github.com/precice/openfoam-adapter/pull/211). +- Disabled automatic checking of links in GitHub Actions. This is now a manual workflow [#215](https://github.com/precice/openfoam-adapter/pull/215). ### Fixed From f342102ee0b459cc12faf0f2e4864688e5314358 Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Tue, 8 Feb 2022 15:51:30 +0100 Subject: [PATCH 45/46] Add post-release steps to update version --- tools/release_pull_request_template.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/release_pull_request_template.md b/tools/release_pull_request_template.md index a2d8303c..e00afd6c 100644 --- a/tools/release_pull_request_template.md +++ b/tools/release_pull_request_template.md @@ -76,6 +76,7 @@ master <-- OpenFOAM4 <-- OpenFOAM5 <-- OpenFOAM6 <-- OpenFOAM7 <-- OpenFOAM8 <-- - [ ] Modify the adapter version message to `Loaded the OpenFOAM-preCICE adapter v1.0.0 + unreleased changes`. - [ ] Update the git module on the website - [ ] Update workflows in the tutorials repository, if needed (e.g., OpenFOAM version) -- [ ] Update the VM provisioning, if needed (e.g., OpenFOAM version) +- [ ] Update external documentation (tutorials, website), e.g., regarding the adapter or OpenFOAM version. +- [ ] Update the VM provisioning scripts, if needed (e.g., OpenFOAM version) - [ ] Update this release checklist (`tools/release_pull_request_template.md`) - [ ] Advertise and celebrate! :tada: :beers: From e88aca117eb180b3f55ba07ea4d4623cd6fd621e Mon Sep 17 00:00:00 2001 From: Gerasimos Chourdakis Date: Tue, 8 Feb 2022 15:52:48 +0100 Subject: [PATCH 46/46] Remove obsolete release checklist step --- tools/release_pull_request_template.md | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/release_pull_request_template.md b/tools/release_pull_request_template.md index e00afd6c..acbce4f5 100644 --- a/tools/release_pull_request_template.md +++ b/tools/release_pull_request_template.md @@ -57,7 +57,6 @@ master <-- OpenFOAM4 <-- OpenFOAM5 <-- OpenFOAM6 <-- OpenFOAM7 <-- OpenFOAM8 <-- - [ ] Review pull request - [ ] Merge pull request (**not** squash) -- [ ] Update the version in `Adapter.C` on `develop` to reflect that this is an unreleased version - [ ] Rebase the version-specific branches on `master` ## Release