From 29767641be5cdbd19aa10efaece12fc842f94d1a Mon Sep 17 00:00:00 2001 From: Timo Koch Date: Thu, 2 Nov 2017 21:24:10 +0100 Subject: [PATCH] [elemsol] Introduce separate class to simplify usage of element solution --- dumux/assembly/boxlocalassembler.hh | 17 ++- dumux/discretization/box/elementsolution.hh | 102 ++++++++++++++++++ .../box/elementvolumevariables.hh | 5 +- dumux/discretization/box/properties.hh | 22 ++-- .../cellcentered/elementsolution.hh | 94 ++++++++++++++++ .../mpfa/elementvolumevariables.hh | 12 +-- .../mpfa/globalvolumevariables.hh | 4 +- .../cellcentered/mpfa/properties.hh | 4 + .../tpfa/elementvolumevariables.hh | 8 +- .../cellcentered/tpfa/properties.hh | 4 + dumux/implicit/box/localresidual.hh | 2 +- dumux/implicit/cellcentered/localresidual.hh | 2 +- dumux/implicit/localresidual.hh | 2 +- .../cellcentered/bboxtreecouplingmanager.hh | 2 +- .../bboxtreecouplingmanagersimple.hh | 4 +- .../compositional/primaryvariableswitch.hh | 27 +---- .../privarswitchnewtoncontroller.hh | 6 +- .../implicit/velocityoutput.hh | 33 +----- 18 files changed, 254 insertions(+), 96 deletions(-) create mode 100644 dumux/discretization/box/elementsolution.hh create mode 100644 dumux/discretization/cellcentered/elementsolution.hh diff --git a/dumux/assembly/boxlocalassembler.hh b/dumux/assembly/boxlocalassembler.hh index ff5b21e998..8340995259 100644 --- a/dumux/assembly/boxlocalassembler.hh +++ b/dumux/assembly/boxlocalassembler.hh @@ -50,7 +50,7 @@ class BoxLocalAssembler; using ElementBoundaryTypes = typename GET_PROP_TYPE(TypeTag, ElementBoundaryTypes); using Element = typename GET_PROP_TYPE(TypeTag, GridView)::template Codim<0>::Entity; using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); @@ -245,11 +245,8 @@ private: ElementBoundaryTypes elemBcTypes; elemBcTypes.update(problem, element, fvGeometry); - // get the element solution - const auto numVert = element.subEntities(dim); - ElementSolutionVector elemSol(numVert); - for (const auto& scv : scvs(fvGeometry)) - elemSol[scv.indexInElement()] = curSol[scv.dofIndex()]; + // create the element solution + ElementSolutionVector elemSol(element, curSol, fvGeometry); // the actual element's current residual ElementResidualVector residual(0.0); @@ -297,7 +294,7 @@ private: // calculate derivatives w.r.t to the privars at the dof at hand for (int pvIdx = 0; pvIdx < numEq; pvIdx++) { - ElementSolutionVector partialDeriv(element.subEntities(dim)); + ElementResidualVector partialDeriv(element.subEntities(dim)); Scalar eps = numericEpsilon(volVars.priVar(pvIdx)); Scalar delta = 0; @@ -452,7 +449,7 @@ class BoxLocalAssembler; using ElementBoundaryTypes = typename GET_PROP_TYPE(TypeTag, ElementBoundaryTypes); using Element = typename GET_PROP_TYPE(TypeTag, GridView)::template Codim<0>::Entity; using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); @@ -819,7 +816,7 @@ class BoxLocalAssembler; using ElementBoundaryTypes = typename GET_PROP_TYPE(TypeTag, ElementBoundaryTypes); using Element = typename GET_PROP_TYPE(TypeTag, GridView)::template Codim<0>::Entity; using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); @@ -1131,7 +1128,7 @@ class BoxLocalAssembler; using ElementBoundaryTypes = typename GET_PROP_TYPE(TypeTag, ElementBoundaryTypes); using Element = typename GET_PROP_TYPE(TypeTag, GridView)::template Codim<0>::Entity; using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); diff --git a/dumux/discretization/box/elementsolution.hh b/dumux/discretization/box/elementsolution.hh new file mode 100644 index 0000000000..6921b5cdd9 --- /dev/null +++ b/dumux/discretization/box/elementsolution.hh @@ -0,0 +1,102 @@ +// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// vi: set et ts=4 sw=4 sts=4: +/***************************************************************************** + * See the file COPYING for full copying permissions. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + *****************************************************************************/ +/*! + * \file + * \brief The local element solution class for the box method + */ +#ifndef DUMUX_BOX_ELEMENT_SOLUTION_HH +#define DUMUX_BOX_ELEMENT_SOLUTION_HH + +#include +#include + +namespace Dumux +{ + +/*! + * \ingroup BoxModel + * \brief The element solution vector + */ +template +class BoxElementSolution +{ + using GridView = typename GET_PROP_TYPE(TypeTag, GridView); + using PrimaryVariables = typename GET_PROP_TYPE(TypeTag, PrimaryVariables); + using Element = typename GridView::template Codim<0>::Entity; + using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); + using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); + using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry); + +public: + //! Default constructors + BoxElementSolution() = default; + BoxElementSolution(BoxElementSolution&& other) = default; + BoxElementSolution(const BoxElementSolution& other) = default; + + //! Constructor with element and solution and gridgeometry + BoxElementSolution(const Element& element, const SolutionVector& sol, + const FVGridGeometry& fvGridGeometry) + { + update(element, sol, fvGridGeometry); + } + + //! Constructor with element and solution and elementgeometry (only works for box) + BoxElementSolution(const Element& element, const SolutionVector& sol, + const FVElementGeometry& fvGeometry) + { + update(element, sol, fvGeometry); + } + + //! extract the element solution from the solution vector using a mapper + void update(const Element& element, const SolutionVector& sol, + const FVGridGeometry& fvGridGeometry) + { + const auto numVert = element.subEntities(GridView::dimension); + priVars_.resize(numVert); + for (int vIdx = 0; vIdx < numVert; ++vIdx) + priVars_[vIdx] = sol[fvGridGeometry.vertexMapper().subIndex(element, vIdx, GridView::dimension)]; + } + + //! extract the element solution from the solution vector using a local fv geometry + void update(const Element& element, const SolutionVector& sol, + const FVElementGeometry& fvGeometry) + { + const auto numVert = element.subEntities(GridView::dimension); + priVars_.resize(numVert); + for (const auto& scv : scvs(fvGeometry)) + priVars_[scv.indexInElement()] = sol[scv.dofIndex()]; + } + + //! bracket operator const access + template + const PrimaryVariables& operator [](IndexType i) const + { return priVars_[i]; } + + //! bracket operator access + template + PrimaryVariables& operator [](IndexType i) + { return priVars_[i]; } + +private: + Dune::BlockVector priVars_; +}; + +} // end namespace Dumux + +#endif diff --git a/dumux/discretization/box/elementvolumevariables.hh b/dumux/discretization/box/elementvolumevariables.hh index 90a4bd8f5b..7857a531e6 100644 --- a/dumux/discretization/box/elementvolumevariables.hh +++ b/dumux/discretization/box/elementvolumevariables.hh @@ -128,10 +128,7 @@ public: const SolutionVector& sol) { // get the solution at the dofs of the element - const auto numVert = element.subEntities(dim); - ElementSolutionVector elemSol(numVert); - for (const auto& scv : scvs(fvGeometry)) - elemSol[scv.indexInElement()] = sol[scv.dofIndex()]; + ElementSolutionVector elemSol(element, sol, fvGeometry); // resize volume variables to the required size volumeVariables_.resize(fvGeometry.numScv()); diff --git a/dumux/discretization/box/properties.hh b/dumux/discretization/box/properties.hh index 8fab45d4f3..f284912b1a 100644 --- a/dumux/discretization/box/properties.hh +++ b/dumux/discretization/box/properties.hh @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -55,10 +56,12 @@ SET_PROP(BoxModel, DiscretizationMethod) }; //! Set the default for the FVElementGeometry vector -SET_TYPE_PROP(BoxModel, FVGridGeometry, BoxFVGridGeometry); +SET_TYPE_PROP(BoxModel, FVGridGeometry, BoxFVGridGeometry); //! Set the default for the FVElementGeometry vector -SET_TYPE_PROP(BoxModel, FVElementGeometry, BoxFVElementGeometry); +SET_TYPE_PROP(BoxModel, FVElementGeometry, BoxFVElementGeometry); //! The sub control volume SET_PROP(BoxModel, SubControlVolume) @@ -87,20 +90,27 @@ public: using type = BoxSubControlVolumeFace; }; +//! Set the solution vector type for an element +SET_TYPE_PROP(BoxModel, ElementSolutionVector, BoxElementSolution); + //! Set the default for the ElementBoundaryTypes SET_TYPE_PROP(BoxModel, ElementBoundaryTypes, BoxElementBoundaryTypes); //! The global volume variables vector class -SET_TYPE_PROP(BoxModel, GlobalVolumeVariables, BoxGlobalVolumeVariables); +SET_TYPE_PROP(BoxModel, GlobalVolumeVariables, BoxGlobalVolumeVariables); //! The element volume variables vector class -SET_TYPE_PROP(BoxModel, ElementVolumeVariables, BoxElementVolumeVariables); +SET_TYPE_PROP(BoxModel, ElementVolumeVariables, BoxElementVolumeVariables); //! The global flux variables cache vector class -SET_TYPE_PROP(BoxModel, GlobalFluxVariablesCache, BoxGlobalFluxVariablesCache); +SET_TYPE_PROP(BoxModel, GlobalFluxVariablesCache, BoxGlobalFluxVariablesCache); //! The local flux variables cache vector class -SET_TYPE_PROP(BoxModel, ElementFluxVariablesCache, BoxElementFluxVariablesCache); +SET_TYPE_PROP(BoxModel, ElementFluxVariablesCache, BoxElementFluxVariablesCache); //! Set the BaseLocalResidual to BoxLocalResidual SET_TYPE_PROP(BoxModel, BaseLocalResidual, BoxLocalResidual); diff --git a/dumux/discretization/cellcentered/elementsolution.hh b/dumux/discretization/cellcentered/elementsolution.hh new file mode 100644 index 0000000000..2fac13fd91 --- /dev/null +++ b/dumux/discretization/cellcentered/elementsolution.hh @@ -0,0 +1,94 @@ +// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// vi: set et ts=4 sw=4 sts=4: +/***************************************************************************** + * See the file COPYING for full copying permissions. * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + *****************************************************************************/ +/*! + * \file + * \brief The local element solution class for cell-centered methods + */ +#ifndef DUMUX_CC_ELEMENT_SOLUTION_HH +#define DUMUX_CC_ELEMENT_SOLUTION_HH + +#include +#include + +namespace Dumux +{ + +/*! + * \ingroup CCModel + * \brief The element solution vector + */ +template +class CCElementSolution +{ + using GridView = typename GET_PROP_TYPE(TypeTag, GridView); + using PrimaryVariables = typename GET_PROP_TYPE(TypeTag, PrimaryVariables); + using Element = typename GridView::template Codim<0>::Entity; + using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); + using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); + +public: + //! Default constructors + CCElementSolution() = default; + CCElementSolution(CCElementSolution&& other) = default; + CCElementSolution(const CCElementSolution& other) = default; + + //! Constructor with element and solution + CCElementSolution(const Element& element, const SolutionVector& sol, + const FVGridGeometry& fvGridGeometry) + : CCElementSolution(sol[fvGridGeometry.elementMapper().index(element)]) + {} + + //! Constructor with a primary variable object + CCElementSolution(PrimaryVariables&& priVars) + : priVars_(std::move(priVars)) {} + + //! Constructor with a primary variable object + CCElementSolution(const PrimaryVariables& priVars) + : priVars_(priVars) {} + + //! extract the element solution from the solution vector using a mapper + void update(const Element& element, const SolutionVector& sol, + const FVGridGeometry& fvGridGeometry) + { + priVars_ = sol[fvGridGeometry.elementMapper().index(element)]; + } + + //! bracket operator const access + template + const PrimaryVariables& operator [](IndexType i) const + { + assert(i == 0 && "Index exceeds valid range!"); + return priVars_; + } + + //! bracket operator access + template + PrimaryVariables& operator [](IndexType i) + { + assert(i == 0 && "Index exceeds valid range!"); + return priVars_; + } + +private: + PrimaryVariables priVars_; +}; + +} // end namespace Dumux + +#endif diff --git a/dumux/discretization/cellcentered/mpfa/elementvolumevariables.hh b/dumux/discretization/cellcentered/mpfa/elementvolumevariables.hh index bf55c7bf92..d7285035c6 100644 --- a/dumux/discretization/cellcentered/mpfa/elementvolumevariables.hh +++ b/dumux/discretization/cellcentered/mpfa/elementvolumevariables.hh @@ -129,7 +129,7 @@ public: // update the volume variables of the element at hand const auto& scvI = fvGeometry.scv(globalI); - volumeVariables_[localIdx].update(ElementSolution({sol[globalI]}), + volumeVariables_[localIdx].update(ElementSolution(sol[globalI]), problem, element, scvI); @@ -141,7 +141,7 @@ public: { const auto& elementJ = fvGridGeometry.element(dataJ.globalJ); const auto& scvJ = fvGeometry.scv(dataJ.globalJ); - volumeVariables_[localIdx].update(ElementSolution({sol[dataJ.globalJ]}), + volumeVariables_[localIdx].update(ElementSolution(sol[dataJ.globalJ]), problem, elementJ, scvJ); @@ -170,7 +170,7 @@ public: { // boundary volume variables VolumeVariables dirichletVolVars; - dirichletVolVars.update(ElementSolution({problem.dirichlet(element, scvf)}), + dirichletVolVars.update(ElementSolution(problem.dirichlet(element, scvf)), problem, element, scvI); @@ -222,7 +222,7 @@ public: // const auto& scvJ = fvGeometry.scv(globalJ); // VolumeVariables additionalVolVars; - // additionalVolVars.update(problem.model().elementSolution(elementJ, sol), + // additionalVolVars.update(ElementSolution(elementJ, sol, fvGridGeometry), // problem, // elementJ, // scvJ); @@ -244,7 +244,7 @@ public: // update the volume variables of the element const auto& scv = fvGeometry.scv(eIdx); - volumeVariables_[0].update(ElementSolution({sol[scv.dofIndex()]}), + volumeVariables_[0].update(ElementSolution(sol[scv.dofIndex()]), globalVolVars().problem(), element, scv); @@ -315,7 +315,7 @@ private: // boundary volume variables VolumeVariables dirichletVolVars; const auto& ivScv = fvGeometry.scv(insideScvIdx); - dirichletVolVars.update(ElementSolution({problem.dirichlet(insideElement, ivScvf)}), + dirichletVolVars.update(ElementSolution(problem.dirichlet(insideElement, ivScvf)), problem, insideElement, ivScv); diff --git a/dumux/discretization/cellcentered/mpfa/globalvolumevariables.hh b/dumux/discretization/cellcentered/mpfa/globalvolumevariables.hh index d417f2dfc6..afba9240f8 100644 --- a/dumux/discretization/cellcentered/mpfa/globalvolumevariables.hh +++ b/dumux/discretization/cellcentered/mpfa/globalvolumevariables.hh @@ -55,7 +55,7 @@ class CCMpfaGlobalVolumeVariables using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables); using PrimaryVariables = typename GET_PROP_TYPE(TypeTag, PrimaryVariables); using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables); - using ElementSolutionVector = typename GET_PROP_TYPE(TypeTag, ElementSolutionVector); + using ElementSolution = typename GET_PROP_TYPE(TypeTag, ElementSolutionVector); using SubControlVolume = typename GET_PROP_TYPE(TypeTag, SubControlVolume); using IndexType = typename GridView::IndexSet::IndexType; @@ -95,7 +95,7 @@ public: const auto& insideScv = fvGeometry.scv(insideScvIdx); const auto dirichletPriVars = problem.dirichlet(element, scvf); - volumeVariables_[scvf.outsideScvIdx()].update(ElementSolutionVector({dirichletPriVars}), problem, element, insideScv); + volumeVariables_[scvf.outsideScvIdx()].update(ElementSolutionVector(dirichletPriVars), problem, element, insideScv); } else { diff --git a/dumux/discretization/cellcentered/mpfa/properties.hh b/dumux/discretization/cellcentered/mpfa/properties.hh index 77110bea47..a3973b3f1a 100644 --- a/dumux/discretization/cellcentered/mpfa/properties.hh +++ b/dumux/discretization/cellcentered/mpfa/properties.hh @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -158,6 +159,9 @@ public: typedef Dumux::CCMpfaSubControlVolumeFace, IndexType> type; }; +//! Set the solution vector type for an element +SET_TYPE_PROP(CCMpfaModel, ElementSolutionVector, CCElementSolution); + //! Set the default for the ElementBoundaryTypes SET_TYPE_PROP(CCMpfaModel, ElementBoundaryTypes, CCElementBoundaryTypes); diff --git a/dumux/discretization/cellcentered/tpfa/elementvolumevariables.hh b/dumux/discretization/cellcentered/tpfa/elementvolumevariables.hh index e8dfcb7055..1dbcf075e5 100644 --- a/dumux/discretization/cellcentered/tpfa/elementvolumevariables.hh +++ b/dumux/discretization/cellcentered/tpfa/elementvolumevariables.hh @@ -130,7 +130,7 @@ public: // update the volume variables of the element at hand auto&& scvI = fvGeometry.scv(globalI); - volumeVariables_[localIdx].update(ElementSolution({sol[globalI]}), + volumeVariables_[localIdx].update(ElementSolution(sol[globalI]), problem, element, scvI); @@ -142,7 +142,7 @@ public: { const auto& elementJ = fvGridGeometry.element(dataJ.globalJ); auto&& scvJ = fvGeometry.scv(dataJ.globalJ); - volumeVariables_[localIdx].update(ElementSolution({sol[dataJ.globalJ]}), + volumeVariables_[localIdx].update(ElementSolution(sol[dataJ.globalJ]), problem, elementJ, scvJ); @@ -186,7 +186,7 @@ public: // const auto& elementJ = fvGridGeometry.element(globalJ); // auto&& scvJ = fvGeometry.scv(globalJ); - // volumeVariables_[localIdx].update(ElementSolution({sol[globalJ]}), + // volumeVariables_[localIdx].update(ElementSolution(sol[globalJ]), // problem, // elementJ, // scvJ); @@ -210,7 +210,7 @@ public: // update the volume variables of the element auto&& scv = fvGeometry.scv(eIdx); - volumeVariables_[0].update(ElementSolution({sol[eIdx]}), + volumeVariables_[0].update(ElementSolution(sol[eIdx]), globalVolVars().problem(), element, scv); diff --git a/dumux/discretization/cellcentered/tpfa/properties.hh b/dumux/discretization/cellcentered/tpfa/properties.hh index 33ee3439bf..8df6e56016 100644 --- a/dumux/discretization/cellcentered/tpfa/properties.hh +++ b/dumux/discretization/cellcentered/tpfa/properties.hh @@ -37,6 +37,7 @@ #include #include +#include #include #include #include @@ -97,6 +98,9 @@ public: typedef Dumux::CCTpfaSubControlVolumeFace type; }; +//! Set the solution vector type for an element +SET_TYPE_PROP(CCTpfaModel, ElementSolutionVector, CCElementSolution); + //! Set the default for the ElementBoundaryTypes SET_TYPE_PROP(CCTpfaModel, ElementBoundaryTypes, CCElementBoundaryTypes); diff --git a/dumux/implicit/box/localresidual.hh b/dumux/implicit/box/localresidual.hh index 685a420e7a..daaca77e4a 100644 --- a/dumux/implicit/box/localresidual.hh +++ b/dumux/implicit/box/localresidual.hh @@ -64,7 +64,7 @@ class BoxLocalResidual : public ImplicitLocalResidual using ElementFluxVariablesCache = typename GET_PROP_TYPE(TypeTag, ElementFluxVariablesCache); using FluxVariablesCache = typename GET_PROP_TYPE(TypeTag, FluxVariablesCache); using ResidualVector = typename GET_PROP_TYPE(TypeTag, NumEqVector); - using ElementResidualVector = typename GET_PROP_TYPE(TypeTag, ElementSolutionVector); + using ElementResidualVector = Dune::BlockVector; public: using ParentType::ParentType; diff --git a/dumux/implicit/cellcentered/localresidual.hh b/dumux/implicit/cellcentered/localresidual.hh index ea4e2ef739..faa023a190 100644 --- a/dumux/implicit/cellcentered/localresidual.hh +++ b/dumux/implicit/cellcentered/localresidual.hh @@ -44,7 +44,7 @@ class CCLocalResidual : public ImplicitLocalResidual using ParentType = ImplicitLocalResidual; using Problem = typename GET_PROP_TYPE(TypeTag, Problem); using Element = typename GET_PROP_TYPE(TypeTag, GridView)::template Codim<0>::Entity; - using ElementResidualVector = typename GET_PROP_TYPE(TypeTag, ElementSolutionVector); + using ElementResidualVector = Dune::BlockVector; using ResidualVector = typename GET_PROP_TYPE(TypeTag, NumEqVector); using ElementBoundaryTypes = typename GET_PROP_TYPE(TypeTag, ElementBoundaryTypes); using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables); diff --git a/dumux/implicit/localresidual.hh b/dumux/implicit/localresidual.hh index 63129a174f..3472b9ba36 100644 --- a/dumux/implicit/localresidual.hh +++ b/dumux/implicit/localresidual.hh @@ -54,7 +54,7 @@ class ImplicitLocalResidual using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); using SubControlVolume = typename GET_PROP_TYPE(TypeTag, SubControlVolume); using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace); - using ElementResidualVector = typename GET_PROP_TYPE(TypeTag, ElementSolutionVector); + using ElementResidualVector = Dune::BlockVector; using ResidualVector = typename GET_PROP_TYPE(TypeTag, NumEqVector); using BoundaryTypes = typename GET_PROP_TYPE(TypeTag, BoundaryTypes); using ElementBoundaryTypes = typename GET_PROP_TYPE(TypeTag, ElementBoundaryTypes); diff --git a/dumux/mixeddimension/embedded/cellcentered/bboxtreecouplingmanager.hh b/dumux/mixeddimension/embedded/cellcentered/bboxtreecouplingmanager.hh index a8ed791ae2..29adbfbfee 100644 --- a/dumux/mixeddimension/embedded/cellcentered/bboxtreecouplingmanager.hh +++ b/dumux/mixeddimension/embedded/cellcentered/bboxtreecouplingmanager.hh @@ -492,7 +492,7 @@ public: fvGeometry.bindElement(element); BulkVolumeVariables volVars; - volVars.update(BulkElementSolutionVector({bulkPriVars}), + volVars.update(BulkElementSolutionVector(bulkPriVars), bulkProblem(), element, fvGeometry.scv(data.bulkElementIdx())); diff --git a/dumux/mixeddimension/embedded/cellcentered/bboxtreecouplingmanagersimple.hh b/dumux/mixeddimension/embedded/cellcentered/bboxtreecouplingmanagersimple.hh index 030eec9cfb..4e30e1cd74 100644 --- a/dumux/mixeddimension/embedded/cellcentered/bboxtreecouplingmanagersimple.hh +++ b/dumux/mixeddimension/embedded/cellcentered/bboxtreecouplingmanagersimple.hh @@ -424,7 +424,7 @@ public: fvGeometry.bindElement(element); BulkVolumeVariables volVars; - volVars.update(BulkElementSolutionVector({bulkPriVars}), + volVars.update(BulkElementSolutionVector(bulkPriVars), bulkProblem(), element, fvGeometry.scv(data.bulkElementIdx())); @@ -443,7 +443,7 @@ public: fvGeometry.bindElement(element); LowDimVolumeVariables volVars; - volVars.update(LowDimElementSolutionVector({lowDimPriVars}), + volVars.update(LowDimElementSolutionVector(lowDimPriVars), lowDimProblem(), element, fvGeometry.scv(data.lowDimElementIdx())); diff --git a/dumux/porousmediumflow/compositional/primaryvariableswitch.hh b/dumux/porousmediumflow/compositional/primaryvariableswitch.hh index 6b64f91bfd..e2dde04fc1 100644 --- a/dumux/porousmediumflow/compositional/primaryvariableswitch.hh +++ b/dumux/porousmediumflow/compositional/primaryvariableswitch.hh @@ -113,7 +113,7 @@ public: auto elemVolVars = localView(gridVariables.curGridVolVars()); elemVolVars.bindElement(element, fvGeometry, curSol); - const auto curElemSol = elementSolution(fvGridGeometry, element, curSol); + const ElementSolution curElemSol(element, curSol, fvGridGeometry); for (auto&& scv : scvs(fvGeometry)) { auto dofIdxGlobal = scv.dofIndex(); @@ -176,31 +176,6 @@ private: static typename std::enable_if::type getVolVarAccess(GridVolumeVariables& gridVolVars, ElementVolumeVariables& elemVolVars, const SubControlVolume& scv) { return gridVolVars.volVars(scv); } - - /*! - * \brief Obtains the current solution inside a given element. - * Specialization for the box method. - */ - template - typename std::enable_if::type - elementSolution(const FVGridGeometry& fvGridGeometry, const Element& element, const SolutionVector& sol) const - { - auto numVert = element.subEntities(dim); - ElementSolution elemSol(numVert); - for (int v = 0; v < numVert; ++v) - elemSol[v] = sol[fvGridGeometry.vertexMapper().subIndex(element, v, dim)]; - return elemSol; - } - - /*! - * \brief Obtains the current solution inside a given element. - * Specialization for cell-centered methods. - */ - template - typename std::enable_if::type - elementSolution(const FVGridGeometry& fvGridGeometry, const Element& element, const SolutionVector& sol) const - { return ElementSolution({ sol[fvGridGeometry.elementMapper().index(element)] }); } - }; } // end namespace dumux diff --git a/dumux/porousmediumflow/compositional/privarswitchnewtoncontroller.hh b/dumux/porousmediumflow/compositional/privarswitchnewtoncontroller.hh index 2983c93e1e..18cc33ad92 100644 --- a/dumux/porousmediumflow/compositional/privarswitchnewtoncontroller.hh +++ b/dumux/porousmediumflow/compositional/privarswitchnewtoncontroller.hh @@ -45,7 +45,7 @@ class PriVarSwitchNewtonController : public NewtonController using Communicator = typename GridView::CollectiveCommunication; using NumEqVector = typename GET_PROP_TYPE(TypeTag, NumEqVector); using PrimaryVariableSwitch = typename GET_PROP_TYPE(TypeTag, PrimaryVariableSwitch); - using ElementSolutionVector = typename GET_PROP_TYPE(TypeTag, ElementSolutionVector); + using ElementSolution = typename GET_PROP_TYPE(TypeTag, ElementSolutionVector); static constexpr int numEq = GET_PROP_VALUE(TypeTag, NumEq); @@ -138,7 +138,7 @@ public: if (priVarSwitch_->wasSwitched(dofIdxGlobal)) { const auto eIdx = fvGridGeometry.elementMapper().index(element); - const auto elemSol = this->elementSolution(element, this->curSol()); + const ElementSolution elemSol(element, this->curSol(), fvGridGeometry); this->nonConstCurGlobalVolVars().volVars(eIdx, scv.indexInElement()).update(elemSol, problem, element, @@ -162,7 +162,7 @@ public: { const auto insideScvIdx = scvf.insideScvIdx(); const auto& insideScv = fvGeometry.scv(insideScvIdx); - const auto elemSol = ElementSolutionVector{problem.dirichlet(element, scvf)}; + const ElementSolution elemSol(problem.dirichlet(element, scvf)); this->nonConstCurGlobalVolVars().volVars(scvf.outsideScvIdx(), 0/*indexInElement*/).update(elemSol, problem, element, insideScv); } diff --git a/dumux/porousmediumflow/implicit/velocityoutput.hh b/dumux/porousmediumflow/implicit/velocityoutput.hh index 67e4bb1ad8..c68528f7a2 100644 --- a/dumux/porousmediumflow/implicit/velocityoutput.hh +++ b/dumux/porousmediumflow/implicit/velocityoutput.hh @@ -45,7 +45,7 @@ class ImplicitVelocityOutput using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry); using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace); using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables); - using ElementSolutionVector = typename GET_PROP_TYPE(TypeTag, ElementSolutionVector); + using ElementSolution = typename GET_PROP_TYPE(TypeTag, ElementSolutionVector); using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables); using FluxVariables = typename GET_PROP_TYPE(TypeTag, FluxVariables); using BoundaryTypes = typename GET_PROP_TYPE(TypeTag, BoundaryTypes); @@ -105,31 +105,6 @@ public: bool enableOutput() { return velocityOutput_; } - //TODO: where to put this? Maybe in the solution vector itself? - /*! - * \brief Obtains the current solution inside a given element. - * Specialization for the box method. - */ - template - typename std::enable_if::type - elementSolution(const Element& element, const SolutionVector& sol) const - { - auto numVert = element.subEntities(dofCodim); - ElementSolutionVector elemSol(numVert); - for (int v = 0; v < numVert; ++v) - elemSol[v] = sol[fvGridGeometry_.vertexMapper().subIndex(element, v, dofCodim)]; - return elemSol; - } - - /*! - * \brief Obtains the current solution inside a given element. - * Specialization for cell-centered methods. - */ - template - typename std::enable_if::type - elementSolution(const Element& element, const SolutionVector& sol) const - { return ElementSolutionVector({ sol[fvGridGeometry_.elementMapper().index(element)] }); } - // The following SFINAE enable_if usage allows compilation, even if only a // // boundaryTypes(const Element&, const scv&) @@ -197,7 +172,7 @@ public: Scalar flux = fluxVars.advectiveFlux(phaseIdx, upwindTerm) / localArea; flux /= problem_.extrusionFactor(element, fvGeometry.scv(scvf.insideScvIdx()), - elementSolution(element, sol_)); + ElementSolution(element, sol_, fvGridGeometry_)); tmpVelocity *= flux; const int eIdxGlobal = fvGridGeometry_.elementMapper().index(element); @@ -305,7 +280,7 @@ public: scvfFluxes[scvfIndexInInside[localScvfIdx]] = fluxVars.advectiveFlux(phaseIdx, upwindTerm); scvfFluxes[scvfIndexInInside[localScvfIdx]] /= problem_.extrusionFactor(element, fvGeometry.scv(scvf.insideScvIdx()), - elementSolution(element, sol_)); + ElementSolution(element, sol_, fvGridGeometry_)); } else { @@ -317,7 +292,7 @@ public: scvfFluxes[scvfIndexInInside[localScvfIdx]] = fluxVars.advectiveFlux(phaseIdx, upwindTerm); scvfFluxes[scvfIndexInInside[localScvfIdx]] /= problem_.extrusionFactor(element, fvGeometry.scv(scvf.insideScvIdx()), - elementSolution(element, sol_)); + ElementSolution(element, sol_, fvGridGeometry_)); } } -- GitLab