diff --git a/dumux/assembly/staggeredlocalresidual.hh b/dumux/assembly/staggeredlocalresidual.hh index ac744c868d16084a5b6844ab199d7422e40b029f..f67a31efbe241fd062fbf8080d9823ccd90ddd61 100644 --- a/dumux/assembly/staggeredlocalresidual.hh +++ b/dumux/assembly/staggeredlocalresidual.hh @@ -103,7 +103,75 @@ public: /*! * \brief Compute the local residual, i.e. the deviation of the - * equations from zero. + * equations from zero for a stationary problem. + * + * \param element The DUNE Codim<0> entity for which the residual + * ought to be calculated + * \param fvGeometry The finite-volume geometry of the element + * \param prevVolVars The volume averaged variables for all + * sub-control volumes of the element at the previous + * time level + * \param curVolVars The volume averaged variables for all + * sub-control volumes of the element at the current + * time level + * \param bcTypes The types of the boundary conditions for all + * vertices of the element + */ + auto evalCellCenter(const Problem& problem, + const Element &element, + const FVElementGeometry& fvGeometry, + const ElementVolumeVariables& curElemVolVars, + const ElementFaceVariables& curElemFaceVars, + const ElementBoundaryTypes &bcTypes, + const ElementFluxVariablesCache& elemFluxVarsCache) const + { + CellCenterResidual residual(0.0); + + asImp_().evalVolumeTermForCellCenter_(residual, problem, element, fvGeometry, curElemVolVars, curElemFaceVars, bcTypes); + asImp_().evalFluxesForCellCenter_(residual, problem, element, fvGeometry, curElemVolVars, curElemFaceVars, bcTypes, elemFluxVarsCache); + asImp_().evalBoundaryForCellCenter_(residual, problem, element, fvGeometry, curElemVolVars, curElemFaceVars, bcTypes, elemFluxVarsCache); + + return residual; + } + + /*! + * \brief Compute the local residual, i.e. the deviation of the + * equations from zero for a stationary problem. + * + * \param element The DUNE Codim<0> entity for which the residual + * ought to be calculated + * \param fvGeometry The finite-volume geometry of the element + * \param prevVolVars The volume averaged variables for all + * sub-control volumes of the element at the previous + * time level + * \param curVolVars The volume averaged variables for all + * sub-control volumes of the element at the current + * time level + * \param bcTypes The types of the boundary conditions for all + * vertices of the element + */ + auto evalFace(const Problem& problem, + const Element &element, + const FVElementGeometry& fvGeometry, + const SubControlVolumeFace& scvf, + const ElementVolumeVariables& curElemVolVars, + const ElementFaceVariables& curElemFaceVars, + const ElementBoundaryTypes &bcTypes, + const ElementFluxVariablesCache& elemFluxVarsCache, + const bool resizeResidual = false) const + { + FaceResidual residual(0.0); + + asImp_().evalVolumeTermForFace_(residual, problem, element, fvGeometry, scvf, curElemVolVars, curElemFaceVars, bcTypes); + asImp_().evalFluxesForFace_(residual, problem, element, fvGeometry, scvf, curElemVolVars, curElemFaceVars, bcTypes, elemFluxVarsCache); + asImp_().evalBoundaryForFace_(residual, problem, element, fvGeometry, scvf, curElemVolVars, curElemFaceVars, bcTypes, elemFluxVarsCache); + + return residual; + } + + /*! + * \brief Compute the local residual, i.e. the deviation of the + * equations from zero for a transient problem. * * \param element The DUNE Codim<0> entity for which the residual * ought to be calculated @@ -127,10 +195,10 @@ public: const ElementBoundaryTypes &bcTypes, const ElementFluxVariablesCache& elemFluxVarsCache) const { - // reset all terms - CellCenterResidual residual; - residual = 0.0; - // ccStorageTerm_ = 0.0; + assert(timeLoop_ && "no time loop set for storage term evaluation"); + assert(prevSol_ && "no solution set for storage term evaluation"); + + CellCenterResidual residual(0.0); asImp_().evalVolumeTermForCellCenter_(residual, problem, element, fvGeometry, prevElemVolVars, curElemVolVars, prevElemFaceVars, curElemFaceVars, bcTypes); asImp_().evalFluxesForCellCenter_(residual, problem, element, fvGeometry, curElemVolVars, curElemFaceVars, bcTypes, elemFluxVarsCache); @@ -141,7 +209,7 @@ public: /*! * \brief Compute the local residual, i.e. the deviation of the - * equations from zero. + * equations from zero for a transient problem. * * \param element The DUNE Codim<0> entity for which the residual * ought to be calculated @@ -167,7 +235,10 @@ public: const ElementFluxVariablesCache& elemFluxVarsCache, const bool resizeResidual = false) const { - FaceResidual residual; + assert(timeLoop_ && "no time loop set for storage term evaluation"); + assert(prevSol_ && "no solution set for storage term evaluation"); + + FaceResidual residual(0.0); asImp_().evalVolumeTermForFace_(residual, problem, element, fvGeometry, scvf, prevElemVolVars, curElemVolVars, prevElemFaceVars, curElemFaceVars, bcTypes); asImp_().evalFluxesForFace_(residual, problem, element, fvGeometry, scvf, curElemVolVars, curElemFaceVars, bcTypes, elemFluxVarsCache); @@ -201,9 +272,9 @@ public: protected: - /*! - * \brief Evaluate the flux terms for cell center dofs - */ + /*! + * \brief Evaluate the flux terms for cell center dofs + */ void evalFluxesForCellCenter_(CellCenterResidual& residual, const Problem& problem, const Element& element, @@ -220,9 +291,9 @@ protected: } } - /*! - * \brief Evaluate the flux terms for face dofs - */ + /*! + * \brief Evaluate the flux terms for face dofs + */ void evalFluxesForFace_(FaceResidual& residual, const Problem& problem, const Element& element, @@ -237,9 +308,9 @@ protected: residual += asImp_().computeFluxForFace(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, elemFluxVarsCache); } - /*! - * \brief Evaluate boundary conditions - */ + /*! + * \brief Evaluate boundary conditions + */ void evalBoundary_(const Problem& problem, const Element& element, const FVElementGeometry& fvGeometry, @@ -253,20 +324,16 @@ protected: "a evalBoundary_() method."); } - /*! - * \brief Evaluate the volume term for a cell center dof for a stationary problem - */ - template<class P = Problem> - typename std::enable_if<Dumux::Capabilities::isStationary<P>::value, void>::type - evalVolumeTermForCellCenter_(CellCenterResidual& residual, - const Problem& problem, - const Element &element, - const FVElementGeometry& fvGeometry, - const ElementVolumeVariables& prevElemVolVars, - const ElementVolumeVariables& curElemVolVars, - const ElementFaceVariables& prevFaceVars, - const ElementFaceVariables& curFaceVars, - const ElementBoundaryTypes &bcTypes) const + /*! + * \brief Evaluate the volume term for a cell center dof for a stationary problem + */ + void evalVolumeTermForCellCenter_(CellCenterResidual& residual, + const Problem& problem, + const Element &element, + const FVElementGeometry& fvGeometry, + const ElementVolumeVariables& curElemVolVars, + const ElementFaceVariables& curFaceVars, + const ElementBoundaryTypes &bcTypes) const { for(auto&& scv : scvs(fvGeometry)) { @@ -279,21 +346,17 @@ protected: } } - /*! - * \brief Evaluate the volume term for a face dof for a stationary problem - */ - template<class P = Problem> - typename std::enable_if<Dumux::Capabilities::isStationary<P>::value, void>::type - evalVolumeTermForFace_(FaceResidual& residual, - const Problem& problem, - const Element &element, - const FVElementGeometry& fvGeometry, - const SubControlVolumeFace& scvf, - const ElementVolumeVariables& prevElemVolVars, - const ElementVolumeVariables& curElemVolVars, - const ElementFaceVariables& prevFaceVars, - const ElementFaceVariables& curFaceVars, - const ElementBoundaryTypes &bcTypes) const + /*! + * \brief Evaluate the volume term for a face dof for a stationary problem + */ + void evalVolumeTermForFace_(FaceResidual& residual, + const Problem& problem, + const Element &element, + const FVElementGeometry& fvGeometry, + const SubControlVolumeFace& scvf, + const ElementVolumeVariables& curElemVolVars, + const ElementFaceVariables& curFaceVars, + const ElementBoundaryTypes &bcTypes) const { // the source term: auto faceSource = asImp_().computeSourceForFace(problem, scvf, curElemVolVars, curFaceVars); @@ -303,21 +366,22 @@ protected: residual -= faceSource; } - /*! - * \brief Evaluate the volume term for a cell center dof for a transient problem - */ - template<class P = Problem> - typename std::enable_if<!Dumux::Capabilities::isStationary<P>::value, void>::type - evalVolumeTermForCellCenter_(CellCenterResidual& residual, - const Problem& problem, - const Element &element, - const FVElementGeometry& fvGeometry, - const ElementVolumeVariables& prevElemVolVars, - const ElementVolumeVariables& curElemVolVars, - const ElementFaceVariables& prevFaceVars, - const ElementFaceVariables& curFaceVars, - const ElementBoundaryTypes &bcTypes) const + /*! + * \brief Evaluate the volume term for a cell center dof for a transient problem + */ + void evalVolumeTermForCellCenter_(CellCenterResidual& residual, + const Problem& problem, + const Element &element, + const FVElementGeometry& fvGeometry, + const ElementVolumeVariables& prevElemVolVars, + const ElementVolumeVariables& curElemVolVars, + const ElementFaceVariables& prevFaceVars, + const ElementFaceVariables& curFaceVars, + const ElementBoundaryTypes &bcTypes) const { + assert(timeLoop_ && "no time loop set for storage term evaluation"); + assert(prevSol_ && "no solution set for storage term evaluation"); + for(auto&& scv : scvs(fvGeometry)) { const auto& curVolVars = curElemVolVars[scv]; @@ -353,22 +417,23 @@ protected: } } - /*! - * \brief Evaluate the volume term for a face dof for a transient problem - */ - template<class P = Problem> - typename std::enable_if<!Dumux::Capabilities::isStationary<P>::value, void>::type - evalVolumeTermForFace_(FaceResidual& residual, - const Problem& problem, - const Element &element, - const FVElementGeometry& fvGeometry, - const SubControlVolumeFace& scvf, - const ElementVolumeVariables& prevElemVolVars, - const ElementVolumeVariables& curElemVolVars, - const ElementFaceVariables& prevFaceVars, - const ElementFaceVariables& curFaceVars, - const ElementBoundaryTypes &bcTypes) const + /*! + * \brief Evaluate the volume term for a face dof for a transient problem + */ + void evalVolumeTermForFace_(FaceResidual& residual, + const Problem& problem, + const Element &element, + const FVElementGeometry& fvGeometry, + const SubControlVolumeFace& scvf, + const ElementVolumeVariables& prevElemVolVars, + const ElementVolumeVariables& curElemVolVars, + const ElementFaceVariables& prevFaceVars, + const ElementFaceVariables& curFaceVars, + const ElementBoundaryTypes &bcTypes) const { + assert(timeLoop_ && "no time loop set for storage term evaluation"); + assert(prevSol_ && "no solution set for storage term evaluation"); + const auto& scv = fvGeometry.scv(scvf.insideScvIdx()); const auto& curVolVars = curElemVolVars[scv]; const auto& prevVolVars = prevElemVolVars[scv]; diff --git a/test/freeflow/staggered/doneatestproblem.hh b/test/freeflow/staggered/doneatestproblem.hh index a73ae8fab3175abfe4b12d36f0f952d78d681a1b..55b62eefea9b29796878eefe408144f638c180d8 100644 --- a/test/freeflow/staggered/doneatestproblem.hh +++ b/test/freeflow/staggered/doneatestproblem.hh @@ -40,13 +40,6 @@ namespace Dumux template <class TypeTag> class DoneaTestProblem; -namespace Capabilities -{ - template<class TypeTag> - struct isStationary<DoneaTestProblem<TypeTag>> - { static const bool value = true; }; -} - namespace Properties { NEW_TYPE_TAG(DoneaTestProblem, INHERITS_FROM(StaggeredFreeFlowModel, NavierStokes));