diff --git a/dumux/assembly/staggeredlocalresidual.hh b/dumux/assembly/staggeredlocalresidual.hh index 46a2fac4d8aa57cac71a2c92ab972996e3379f64..2d5b6e4138c7d1acd0fcd7bbb1204e9cc34c5d56 100644 --- a/dumux/assembly/staggeredlocalresidual.hh +++ b/dumux/assembly/staggeredlocalresidual.hh @@ -281,7 +281,7 @@ protected: const ElementBoundaryTypes &bcTypes) const { // the source term: - auto faceSource = asImp_().computeSourceForFace(problem, scvf, curElemVolVars, curFaceVars); + auto faceSource = asImp_().computeSourceForFace(problem, element, fvGeometry, scvf, curElemVolVars, curFaceVars); const auto& scv = fvGeometry.scv(scvf.insideScvIdx()); const auto curExtrusionFactor = curElemVolVars[scv].extrusionFactor(); faceSource *= 0.5*scv.volume()*curExtrusionFactor; @@ -367,10 +367,9 @@ protected: residual -= std::move(prevFaceStorage); residual *= (scv.volume()/2.0); residual /= timeLoop_->timeStepSize(); - // residuals[scvf.localFaceIdx()] += faceStorageTerms_[scvf.localFaceIdx()]; // the source term: - auto faceSource = asImp_().computeSourceForFace(problem, scvf, curElemVolVars, curFaceVars); + auto faceSource = asImp_().computeSourceForFace(problem, element, fvGeometry, scvf, curElemVolVars, curFaceVars); faceSource *= 0.5*scv.volume()*curVolVars.extrusionFactor(); residual -= faceSource; } diff --git a/dumux/common/staggeredfvproblem.hh b/dumux/common/staggeredfvproblem.hh index abb4397e9666155326c4bce8f934cd3baf85e3cd..c66515c0f607e1e2f2b138d778f4c9cd99722301 100644 --- a/dumux/common/staggeredfvproblem.hh +++ b/dumux/common/staggeredfvproblem.hh @@ -52,12 +52,14 @@ class StaggeredFVProblem : public FVProblem<TypeTag> using ParentType = FVProblem<TypeTag>; using Implementation = typename GET_PROP_TYPE(TypeTag, Problem); using GridView = typename GET_PROP_TYPE(TypeTag, GridView); + using Element = typename GridView::template Codim<0>::Entity; using PrimaryVariables = typename GET_PROP_TYPE(TypeTag, PrimaryVariables); using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); using FVElementGeometry = typename FVGridGeometry::LocalView; using SubControlVolume = typename FVElementGeometry::SubControlVolume; using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace; + using NumEqVector = typename GET_PROP_TYPE(TypeTag, NumEqVector); using CoordScalar = typename GridView::ctype; using GlobalPosition = Dune::FieldVector<CoordScalar, GridView::dimensionworld>; @@ -75,6 +77,35 @@ public: : ParentType(fvGridGeometry, paramGroup) { } + /*! + * \brief Evaluate the source term for all phases within a given + * sub-control-volume (-face). + * + * This is the method for the case where the source term is + * potentially solution dependent and requires some quantities that + * are specific to the fully-implicit method. + * + * \param element The finite element + * \param fvGeometry The finite-volume geometry + * \param elemVolVars All volume variables for the element + * \param elementFaceVars All face variables for the element + * \param e The geometrical entity on which the source shall be applied (scv or scvf) + * + * For this method, the return parameter stores the conserved quantity rate + * generated or annihilate per volume unit. Positive values mean + * that the conserved quantity is created, negative ones mean that it vanishes. + */ + template<class ElementVolumeVariables, class ElementFaceVariables, class Entity> + NumEqVector source(const Element &element, + const FVElementGeometry& fvGeometry, + const ElementVolumeVariables& elemVolVars, + const ElementFaceVariables& elementFaceVars, + const Entity &e) const + { + // forward to solution independent, fully-implicit specific interface + return asImp_().sourceAtPos(e.center()); + } + /*! * \brief Evaluate the initial value for a control volume. * diff --git a/dumux/freeflow/navierstokes/staggered/localresidual.hh b/dumux/freeflow/navierstokes/staggered/localresidual.hh index eded3063985b0eab43f51931fa001edc2426a2e1..9c1c37a7fe86a5da12d47d30b4ac21c19eb29daf 100644 --- a/dumux/freeflow/navierstokes/staggered/localresidual.hh +++ b/dumux/freeflow/navierstokes/staggered/localresidual.hh @@ -117,7 +117,7 @@ public: CellCenterPrimaryVariables result(0.0); // get the values from the problem - const auto sourceValues = problem.sourceAtPos(scv.center()); + const auto sourceValues = problem.source(element, fvGeometry, elemVolVars, elemFaceVars, scv); // copy the respective cell center related values to the result for (int i = 0; i < result.size(); ++i) @@ -155,6 +155,8 @@ public: //! Evaluate the source term for the face control volume. FacePrimaryVariables computeSourceForFace(const Problem& problem, + const Element& element, + const FVElementGeometry& fvGeometry, const SubControlVolumeFace& scvf, const ElementVolumeVariables& elemVolVars, const ElementFaceVariables& elementFaceVars) const @@ -163,8 +165,7 @@ public: const auto insideScvIdx = scvf.insideScvIdx(); const auto& insideVolVars = elemVolVars[insideScvIdx]; source += problem.gravity()[scvf.directionIndex()] * insideVolVars.density(); - - source += problem.sourceAtPos(scvf.center())[Indices::velocity(scvf.directionIndex())]; + source += problem.source(element, fvGeometry, elemVolVars, elementFaceVars, scvf)[Indices::velocity(scvf.directionIndex())]; return source; }