Commit 79f6307c authored by Bernd Flemisch's avatar Bernd Flemisch
Browse files

[discretization] throw if evalGradients is called with non-uniform phase states

Evaluating gradients inside an element is only correct if all
element vertices have the same phase state, i.e. the same set of
primary variables. Determine if all vertex phase states are the
same. If not, throw. Enable the possibility to ignore the phase
states and enforce the gradient evaluation.
parent 02c18be7
......@@ -25,10 +25,15 @@
#include <dune/localfunctions/lagrange/pqkfactory.hh>
#include <dune/common/exceptions.hh>
#include <dumux/common/typetraits/state.hh>
#include <dumux/common/typetraits/isvalid.hh>
#include <dumux/discretization/box/elementsolution.hh>
#include <dumux/discretization/cellcentered/elementsolution.hh>
#include "evalsolution.hh"
namespace Dumux {
......@@ -50,8 +55,15 @@ auto evalGradients(const Element& element,
const typename Element::Geometry& geometry,
const typename FVElementGeometry::FVGridGeometry& fvGridGeometry,
const BoxElementSolution<FVElementGeometry, PrimaryVariables>& elemSol,
const typename Element::Geometry::GlobalCoordinate& globalPos)
const typename Element::Geometry::GlobalCoordinate& globalPos,
bool ignoreState = false)
// determine if all states are the same at all vertices
using HasState = decltype(isValid(Detail::hasState())(elemSol[0]));
bool allStatesEqual = ignoreState || Detail::allStatesEqual(elemSol, HasState{});
if (allStatesEqual)
using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
// evaluate gradients using the local finite element basis
......@@ -84,6 +96,11 @@ auto evalGradients(const Element& element,
return result;
DUNE_THROW(Dune::NotImplemented, "Element vertices have different phase states. Enforce calculation by setting ignoreState to true.");
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment