From 2504de05defb636f0dc28fa9286c0c311276c7a4 Mon Sep 17 00:00:00 2001 From: Ned Coltman Date: Wed, 26 Jan 2022 15:30:05 +0100 Subject: [PATCH 1/3] [freeflow][rans] Suppress compiler warnings for clang --- dumux/freeflow/rans/problem.hh | 10 ++++++++++ .../rans/twoeq/kepsilon/staggered/fluxvariables.hh | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/dumux/freeflow/rans/problem.hh b/dumux/freeflow/rans/problem.hh index 4f3e74346a..71c9ed013c 100644 --- a/dumux/freeflow/rans/problem.hh +++ b/dumux/freeflow/rans/problem.hh @@ -375,7 +375,16 @@ private: return; } else + { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif // __clang__ noSetWallCompilerWarning_(); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif // __clang__ + } } } @@ -736,6 +745,7 @@ private: "Mark wall boundaries in the rans problems with the setWall() function.")]] void noSetWallCompilerWarning_(){} + const int fixedFlowDirectionAxis_ = getParam("RANS.FlowDirectionAxis", 0); const int fixedWallNormalAxis_ = getParam("RANS.WallNormalAxis", 1); diff --git a/dumux/freeflow/rans/twoeq/kepsilon/staggered/fluxvariables.hh b/dumux/freeflow/rans/twoeq/kepsilon/staggered/fluxvariables.hh index 1598488733..a10bf0abad 100644 --- a/dumux/freeflow/rans/twoeq/kepsilon/staggered/fluxvariables.hh +++ b/dumux/freeflow/rans/twoeq/kepsilon/staggered/fluxvariables.hh @@ -152,7 +152,15 @@ public: // Remove this check after release 3.5. IsOnWall Interface is deprecated if constexpr (Deprecated::hasIsOnWall()) { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif // __clang__ noSetWallCompilerWarning_(); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif // __clang__ + // Remove this part if (!(scvf.boundary() && (bcTypes.isOutflow(Indices::turbulentKineticEnergyEqIdx) || bcTypes.isSymmetry() @@ -224,6 +232,7 @@ private: "Please use the Rans specific boundarytypes. " "Mark wall boundaries in the rans problems with the setWall() function.")]] void noSetWallCompilerWarning_(){} + }; } // end namespace -- GitLab From 1d43cc32a80e28866e36b7127b0c353919f96d2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Gl=C3=A4ser?= Date: Wed, 26 Jan 2022 20:27:52 +0100 Subject: [PATCH 2/3] [rans][deprecation] avoid preprocessor magic in headers --- dumux/common/deprecated.hh | 15 +++++++++++ dumux/freeflow/rans/problem.hh | 25 ++----------------- .../twoeq/kepsilon/staggered/fluxvariables.hh | 11 +------- 3 files changed, 18 insertions(+), 33 deletions(-) diff --git a/dumux/common/deprecated.hh b/dumux/common/deprecated.hh index 8a719f8eed..3ee79495d6 100644 --- a/dumux/common/deprecated.hh +++ b/dumux/common/deprecated.hh @@ -190,6 +190,21 @@ decltype(auto) temperature(const Problem& problem, const Element& element, const return problem.temperatureAtPos(scv.dofPosition()); } +[[deprecated("The isOnWall and IsOnWallAtPos functions in the problem class will be removed after release 3.5. " + "Please use the Rans specific boundarytypes. Mark wall boundaries in the rans problems with the setWall() function.")]] +void noSetWallCompilerWarning() {} + +template +constexpr bool usesOldWallBCs() +{ + if constexpr (hasIsOnWall()) + { + noSetWallCompilerWarning(); + return true; + } + return false; +} + } // end namespace Deprecated #endif diff --git a/dumux/freeflow/rans/problem.hh b/dumux/freeflow/rans/problem.hh index 71c9ed013c..d9ae5025a4 100644 --- a/dumux/freeflow/rans/problem.hh +++ b/dumux/freeflow/rans/problem.hh @@ -368,28 +368,13 @@ private: auto fvGeometry = localView(this->gridGeometry()); fvGeometry.bindElement(element); for (auto&& scvf : scvfs(fvGeometry)) - { - if constexpr (Deprecated::hasHasWallBC()) - { + if constexpr (!Deprecated::usesOldWallBCs()) if (asImp_().boundaryTypes(element, scvf).hasWall()) return; - } - else - { -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" -#endif // __clang__ - noSetWallCompilerWarning_(); -#ifdef __clang__ -#pragma clang diagnostic pop -#endif // __clang__ - } - } } // If reached, no walls were found, throw exception. Remove check after 3.5 - if constexpr (!Deprecated::hasIsOnWall()) + if constexpr (!Deprecated::usesOldWallBCs()) DUNE_THROW(Dune::InvalidStateException, "No walls are are specified with the setWall() function"); } @@ -740,12 +725,6 @@ private: } } - [[deprecated("The isOnWall and IsOnWallAtPos functions will be removed after release 3.5. " - "Please use the Rans specific boundarytypes. " - "Mark wall boundaries in the rans problems with the setWall() function.")]] - void noSetWallCompilerWarning_(){} - - const int fixedFlowDirectionAxis_ = getParam("RANS.FlowDirectionAxis", 0); const int fixedWallNormalAxis_ = getParam("RANS.WallNormalAxis", 1); diff --git a/dumux/freeflow/rans/twoeq/kepsilon/staggered/fluxvariables.hh b/dumux/freeflow/rans/twoeq/kepsilon/staggered/fluxvariables.hh index a10bf0abad..6c8ff27448 100644 --- a/dumux/freeflow/rans/twoeq/kepsilon/staggered/fluxvariables.hh +++ b/dumux/freeflow/rans/twoeq/kepsilon/staggered/fluxvariables.hh @@ -150,17 +150,8 @@ public: const auto bcTypes = problem.boundaryTypes(element, scvf); // Remove this check after release 3.5. IsOnWall Interface is deprecated - if constexpr (Deprecated::hasIsOnWall()) + if constexpr (Deprecated::usesOldWallBCs()) { -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" -#endif // __clang__ - noSetWallCompilerWarning_(); -#ifdef __clang__ -#pragma clang diagnostic pop -#endif // __clang__ - // Remove this part if (!(scvf.boundary() && (bcTypes.isOutflow(Indices::turbulentKineticEnergyEqIdx) || bcTypes.isSymmetry() -- GitLab From 5c332c66256b5a5fb5a048a4ab88c77e26c81bdd Mon Sep 17 00:00:00 2001 From: Ned Coltman Date: Thu, 27 Jan 2022 20:13:20 +0100 Subject: [PATCH 3/3] [rans][wallboundaries] Adjust the deprecation warnings in rans --- dumux/common/deprecated.hh | 39 ++++++++++++------- dumux/freeflow/rans/problem.hh | 4 +- .../twoeq/kepsilon/staggered/fluxvariables.hh | 17 ++++---- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/dumux/common/deprecated.hh b/dumux/common/deprecated.hh index 3ee79495d6..448c72720b 100644 --- a/dumux/common/deprecated.hh +++ b/dumux/common/deprecated.hh @@ -40,6 +40,10 @@ namespace Dumux { // so most likely you don't want to use this in your code namespace Deprecated { +[[deprecated("The isOnWall and IsOnWallAtPos functions in the problem class will be removed after release 3.5. " + "Please use the Rans specific boundarytypes. Mark wall boundaries in the rans problems with the setWall() function.")]] +void ransWallsCompilerWarning() {} + #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" @@ -115,6 +119,27 @@ using HasBaseProblemExtrusionFactorAtPosDetector = decltype(std::declval +constexpr bool usesHasWallBCs() +{ + if constexpr (hasHasWallBC()) + return true; + + ransWallsCompilerWarning(); + return false; +} + +template +constexpr bool usesIsOnWall() +{ + if constexpr (hasIsOnWall()) + { + ransWallsCompilerWarning(); + return true; + } + return false; +} + #ifdef __clang__ #pragma clang diagnostic pop #endif // __clang__ @@ -190,20 +215,6 @@ decltype(auto) temperature(const Problem& problem, const Element& element, const return problem.temperatureAtPos(scv.dofPosition()); } -[[deprecated("The isOnWall and IsOnWallAtPos functions in the problem class will be removed after release 3.5. " - "Please use the Rans specific boundarytypes. Mark wall boundaries in the rans problems with the setWall() function.")]] -void noSetWallCompilerWarning() {} - -template -constexpr bool usesOldWallBCs() -{ - if constexpr (hasIsOnWall()) - { - noSetWallCompilerWarning(); - return true; - } - return false; -} } // end namespace Deprecated #endif diff --git a/dumux/freeflow/rans/problem.hh b/dumux/freeflow/rans/problem.hh index d9ae5025a4..80b99752d1 100644 --- a/dumux/freeflow/rans/problem.hh +++ b/dumux/freeflow/rans/problem.hh @@ -368,13 +368,13 @@ private: auto fvGeometry = localView(this->gridGeometry()); fvGeometry.bindElement(element); for (auto&& scvf : scvfs(fvGeometry)) - if constexpr (!Deprecated::usesOldWallBCs()) + if constexpr (Deprecated::usesHasWallBCs()) if (asImp_().boundaryTypes(element, scvf).hasWall()) return; } // If reached, no walls were found, throw exception. Remove check after 3.5 - if constexpr (!Deprecated::usesOldWallBCs()) + if constexpr (!Deprecated::usesIsOnWall()) DUNE_THROW(Dune::InvalidStateException, "No walls are are specified with the setWall() function"); } diff --git a/dumux/freeflow/rans/twoeq/kepsilon/staggered/fluxvariables.hh b/dumux/freeflow/rans/twoeq/kepsilon/staggered/fluxvariables.hh index 6c8ff27448..920d80fa91 100644 --- a/dumux/freeflow/rans/twoeq/kepsilon/staggered/fluxvariables.hh +++ b/dumux/freeflow/rans/twoeq/kepsilon/staggered/fluxvariables.hh @@ -25,6 +25,7 @@ #define DUMUX_KEPSILON_STAGGERED_FLUXVARIABLES_HH #include +#include #include #include #include @@ -150,7 +151,7 @@ public: const auto bcTypes = problem.boundaryTypes(element, scvf); // Remove this check after release 3.5. IsOnWall Interface is deprecated - if constexpr (Deprecated::usesOldWallBCs()) + if constexpr (Deprecated::hasIsOnWall()) { // Remove this part if (!(scvf.boundary() && (bcTypes.isOutflow(Indices::turbulentKineticEnergyEqIdx) @@ -168,7 +169,7 @@ public: } } } - else + else if constexpr (Deprecated::usesHasWallBCs()) { // Keep this part if (!(scvf.boundary() && (bcTypes.isOutflow(Indices::turbulentKineticEnergyEqIdx) @@ -186,9 +187,12 @@ public: } } } + else + DUNE_THROW(Dune::Exception, "Please use the RANS boundary types to set wall conditions."); + if (!(scvf.boundary() && (bcTypes.isOutflow(Indices::dissipationEqIdx) - || bcTypes.isSymmetry()))) + || bcTypes.isSymmetry()))) { flux[dissipationEqIdx] += coeff_e / distance @@ -217,13 +221,6 @@ public: * Extrusion::area(scvf) * scvf.directionSign() * insideVolVars.extrusionFactor(); } -private: - - [[deprecated("The isOnWall and IsOnWallAtPos functions will be removed after release 3.5. " - "Please use the Rans specific boundarytypes. " - "Mark wall boundaries in the rans problems with the setWall() function.")]] - void noSetWallCompilerWarning_(){} - }; } // end namespace -- GitLab