From c75398899a0d84a9d977a996425fdaea8be17608 Mon Sep 17 00:00:00 2001 From: Kilian Weishaupt <kilian.weishaupt@iws.uni-stuttgart.de> Date: Thu, 2 Aug 2018 11:49:16 +0200 Subject: [PATCH] [freeflow][gridVolVars] Add sanity check for outflow BCs --- .../staggered/freeflow/gridvolumevariables.hh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dumux/discretization/staggered/freeflow/gridvolumevariables.hh b/dumux/discretization/staggered/freeflow/gridvolumevariables.hh index 09d72d437a..2d0a37f1b7 100644 --- a/dumux/discretization/staggered/freeflow/gridvolumevariables.hh +++ b/dumux/discretization/staggered/freeflow/gridvolumevariables.hh @@ -25,6 +25,7 @@ #define DUMUX_DISCRETIZATION_STAGGERED_GRID_VOLUMEVARIABLES_HH #include <dune/common/exceptions.hh> +#include <dune/common/rangeutilities.hh> //! make the local view function available whenever we use this class #include <dumux/discretization/localview.hh> @@ -105,6 +106,18 @@ struct StaggeredGridDefaultGridVolumeVariablesTraits else if(bcTypes.isOutflow(eqIdx) || bcTypes.isSymmetry() || bcTypes.isNeumann(eqIdx)) boundaryPriVars[eqIdx] = sol[scvf.insideScvIdx()][eqIdx - offset]; } + + // make sure that a potential outflow condition is set for all components + std::array<bool, VolumeVariables::numComponents() - 1> isComponentOutflow; + for(int compIdx = 1; compIdx < VolumeVariables::numComponents(); ++compIdx) + { + const auto eqIdx = VolumeVariables::Indices::conti0EqIdx + compIdx; + isComponentOutflow[compIdx -1] = bcTypes.isOutflow(eqIdx); + } + + if(Dune::any_true(isComponentOutflow) && !Dune::all_true(isComponentOutflow)) + DUNE_THROW(Dune::InvalidStateException, "Outflow condition must be set for all components!"); + return boundaryPriVars; } }; -- GitLab