From 3a4dbd3651edfe2767bdaccbfa3814d8852eefe4 Mon Sep 17 00:00:00 2001 From: Timo Koch <timo.koch@iws.uni-stuttgart.de> Date: Sat, 13 Jan 2018 16:55:09 +0100 Subject: [PATCH] [fvassembly] Use actual type instead of auto return type to improve readability/doc Also fixes related issue hiding the ElementResidualVector alias in the incompressible residual. This was needed to make this work. --- dumux/assembly/fvlocalassemblerbase.hh | 27 +++++++++---------- .../1p/incompressiblelocalresidual.hh | 1 - .../2p/incompressiblelocalresidual.hh | 10 +++---- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/dumux/assembly/fvlocalassemblerbase.hh b/dumux/assembly/fvlocalassemblerbase.hh index 24bc297d29..2659946d05 100644 --- a/dumux/assembly/fvlocalassemblerbase.hh +++ b/dumux/assembly/fvlocalassemblerbase.hh @@ -48,6 +48,7 @@ class FVLocalAssemblerBase { using Problem = typename GET_PROP_TYPE(TypeTag, Problem); using LocalResidual = typename GET_PROP_TYPE(TypeTag, LocalResidual); + using ElementResidualVector = typename LocalResidual::ElementResidualVector; using GridView = typename GET_PROP_TYPE(TypeTag, GridView); using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); using JacobianMatrix = typename GET_PROP_TYPE(TypeTag, JacobianMatrix); @@ -86,16 +87,14 @@ public: * \brief Convenience function to evaluate the complete local residual for the current element. Automatically chooses the the appropriate * element volume variables. */ - auto evalLocalResidual() const + ElementResidualVector evalLocalResidual() const { - if(this->assembler().isStationaryProblem() && !isImplicit) - DUNE_THROW(Dune::InvalidStateException, "Using explicit jacobian assembler with stationary local residual"); + if (!isImplicit) + if (this->assembler().isStationaryProblem()) + DUNE_THROW(Dune::InvalidStateException, "Using explicit jacobian assembler with stationary local residual"); - if(elementIsGhost()) - { - using ResdiualType = decltype(evalLocalResidual(std::declval<ElementVolumeVariables>())); - return ResdiualType(0.0); - } + if (elementIsGhost()) + return ElementResidualVector(0.0); return isImplicit ? evalLocalResidual(curElemVolVars()) : evalLocalResidual(prevElemVolVars()); @@ -105,11 +104,11 @@ public: * \brief Evaluates the complete local residual for the current element. * \param elemVolVars The element volume variables */ - auto evalLocalResidual(const ElementVolumeVariables& elemVolVars) const + ElementResidualVector evalLocalResidual(const ElementVolumeVariables& elemVolVars) const { if (!assembler().isStationaryProblem()) { - auto residual = evalLocalFluxAndSourceResidual(elemVolVars); + ElementResidualVector residual = evalLocalFluxAndSourceResidual(elemVolVars); residual += evalLocalStorageResidual(); return residual; } @@ -122,7 +121,7 @@ public: * of the local residual for the current element. Automatically chooses the the appropriate * element volume variables. */ - auto evalLocalFluxAndSourceResidual() const + ElementResidualVector evalLocalFluxAndSourceResidual() const { return isImplicit ? evalLocalFluxAndSourceResidual(curElemVolVars()) : evalLocalFluxAndSourceResidual(prevElemVolVars()); @@ -134,7 +133,7 @@ public: * * \param elemVolVars The element volume variables */ - auto evalLocalFluxAndSourceResidual(const ElementVolumeVariables& elemVolVars) const + ElementResidualVector evalLocalFluxAndSourceResidual(const ElementVolumeVariables& elemVolVars) const { return localResidual_.evalFluxAndSource(element_, fvGeometry_, elemVolVars, elemFluxVarsCache_, elemBcTypes_); } @@ -144,7 +143,7 @@ public: * of the local residual for the current element. Automatically chooses the the appropriate * element volume variables. */ - auto evalLocalStorageResidual() const + ElementResidualVector evalLocalStorageResidual() const { return localResidual_.evalStorage(element_, fvGeometry_, prevElemVolVars_, curElemVolVars_); } @@ -167,7 +166,7 @@ public: // bind the caches fvGeometry.bind(element); - if(isImplicit) + if (isImplicit) { curElemVolVars.bind(element, fvGeometry, curSol); elemFluxVarsCache.bind(element, fvGeometry, curElemVolVars); diff --git a/dumux/porousmediumflow/1p/incompressiblelocalresidual.hh b/dumux/porousmediumflow/1p/incompressiblelocalresidual.hh index dfdc173f08..1a0f1177ca 100644 --- a/dumux/porousmediumflow/1p/incompressiblelocalresidual.hh +++ b/dumux/porousmediumflow/1p/incompressiblelocalresidual.hh @@ -44,7 +44,6 @@ class OnePIncompressibleLocalResidual : public ImmiscibleLocalResidual<TypeTag> using Problem = typename GET_PROP_TYPE(TypeTag, Problem); using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables); using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables); - using ElementResidualVector = typename GET_PROP_TYPE(TypeTag, ElementSolutionVector); using FluxVariables = typename GET_PROP_TYPE(TypeTag, FluxVariables); using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); using ElementFluxVariablesCache = typename GET_PROP_TYPE(TypeTag, ElementFluxVariablesCache); diff --git a/dumux/porousmediumflow/2p/incompressiblelocalresidual.hh b/dumux/porousmediumflow/2p/incompressiblelocalresidual.hh index 60ee880859..73affdffac 100644 --- a/dumux/porousmediumflow/2p/incompressiblelocalresidual.hh +++ b/dumux/porousmediumflow/2p/incompressiblelocalresidual.hh @@ -47,7 +47,7 @@ class TwoPIncompressibleLocalResidual : public ImmiscibleLocalResidual<TypeTag> using Problem = typename GET_PROP_TYPE(TypeTag, Problem); using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables); using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables); - using ElementResidualVector = typename GET_PROP_TYPE(TypeTag, ElementSolutionVector); + using ElementSolutionVector = typename GET_PROP_TYPE(TypeTag, ElementSolutionVector); using FluxVariables = typename GET_PROP_TYPE(TypeTag, FluxVariables); using ElementFluxVariablesCache = typename GET_PROP_TYPE(TypeTag, ElementFluxVariablesCache); using SubControlVolume = typename GET_PROP_TYPE(TypeTag, SubControlVolume); @@ -188,10 +188,10 @@ public: const auto& outsideVolVars = curElemVolVars[outsideScvIdx]; const auto& insideMaterialParams = problem.spatialParams().materialLawParams(element, insideScv, - ElementResidualVector({insideVolVars.priVars()})); + ElementSolutionVector({insideVolVars.priVars()})); const auto& outsideMaterialParams = problem.spatialParams().materialLawParams(outsideElement, outsideScv, - ElementResidualVector({outsideVolVars.priVars()})); + ElementSolutionVector({outsideVolVars.priVars()})); // get references to the two participating derivative matrices auto& dI_dI = derivativeMatrices[insideScvIdx]; @@ -303,7 +303,7 @@ public: const auto& outsideVolVars = curElemVolVars[outsideScv]; // we need the element solution for the material parameters - ElementResidualVector elemSol(fvGeometry.numScv()); + ElementSolutionVector elemSol(fvGeometry.numScv()); for (const auto& scv : scvs(fvGeometry)) elemSol[scv.indexInElement()] = curElemVolVars[scv].priVars(); const auto& insideMaterialParams = problem.spatialParams().materialLawParams(element, insideScv, elemSol); const auto& outsideMaterialParams = problem.spatialParams().materialLawParams(element, outsideScv, elemSol); @@ -449,7 +449,7 @@ public: const auto& outsideVolVars = curElemVolVars[scvf.outsideScvIdx()]; const auto& insideMaterialParams = problem.spatialParams().materialLawParams(element, insideScv, - ElementResidualVector({insideVolVars.priVars()})); + ElementSolutionVector({insideVolVars.priVars()})); // some quantities to be reused (rho & mu are constant and thus equal for all cells) static const auto rho_w = insideVolVars.density(FluidSystem::wPhaseIdx); -- GitLab