diff --git a/dumux/discretization/staggered/freeflow/facevariables.hh b/dumux/discretization/staggered/freeflow/facevariables.hh index a4e80fcc88ef95c95fb93930993e652ae4476739..3cb1a10f675d9d5eeb19733feef4011b42c52e9a 100644 --- a/dumux/discretization/staggered/freeflow/facevariables.hh +++ b/dumux/discretization/staggered/freeflow/facevariables.hh @@ -37,80 +37,35 @@ template<class TypeTag> class StaggeredFaceVariables { using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); - using FaceSolutionVector = typename GET_PROP_TYPE(TypeTag, FaceSolutionVector); + using GridView = typename GET_PROP_TYPE(TypeTag, GridView); using FacePrimaryVariables = typename GET_PROP_TYPE(TypeTag, FacePrimaryVariables); using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace); - using GlobalFaceVars = typename GET_PROP_TYPE(TypeTag, GlobalFaceVars); - using FaceSolution = typename GET_PROP_TYPE(TypeTag, StaggeredFaceSolution); - struct SubFaceData - { - Scalar velocityNormalInside; - Scalar velocityNormalOutside; - Scalar velocityParallelInside; - Scalar velocityParallelOutside; - }; + static constexpr int dimWorld = GridView::dimensionworld; + static constexpr int numPairs = (dimWorld == 2) ? 2 : 4; public: - StaggeredFaceVariables() = default; - - StaggeredFaceVariables(const GlobalFaceVars& globalFacesVars) : globalFaceVarsPtr_(&globalFacesVars) {} - - const StaggeredFaceVariables& operator [](const SubControlVolumeFace& scvf) const - { return globalFaceVars().faceVars(scvf.index()); } - - // // operator for the access with an index - // // needed for cc methods for the access to the boundary volume variables - // const StaggeredFaceVariables& operator [](const IndexType scvIdx) const - // { return globalVolVars().volVars(scvIdx); } - void update(const FacePrimaryVariables &facePrivars) { velocitySelf_ = facePrivars; } - void update(const SubControlVolumeFace& scvf, const FaceSolutionVector& sol) - { - velocitySelf_ = sol[scvf.dofIndex()]; - velocityOpposite_ = sol[scvf.dofIndexOpposingFace()]; - - subFaceVelocities_.resize(scvf.pairData().size()); - - - for(int i = 0; i < scvf.pairData().size(); ++i) - { - subFaceVelocities_[i].velocityNormalInside = sol[scvf.pairData(i).normalPair.first]; - - if(scvf.pairData(i).normalPair.second >= 0) - subFaceVelocities_[i].velocityNormalOutside = sol[scvf.pairData(i).normalPair.second]; - - subFaceVelocities_[i].velocityParallelInside = sol[scvf.dofIndex()]; - - if(scvf.pairData(i).outerParallelFaceDofIdx >= 0) - subFaceVelocities_[i].velocityParallelOutside = sol[scvf.pairData(i).outerParallelFaceDofIdx]; - } - - } - - void update(const SubControlVolumeFace& scvf, const FaceSolution& faceSol) + template<class SolVector> + void update(const SubControlVolumeFace& scvf, const SolVector& faceSol) { velocitySelf_ = faceSol[scvf.dofIndex()]; velocityOpposite_ = faceSol[scvf.dofIndexOpposingFace()]; - subFaceVelocities_.resize(scvf.pairData().size()); - for(int i = 0; i < scvf.pairData().size(); ++i) { - subFaceVelocities_[i].velocityNormalInside = faceSol[scvf.pairData(i).normalPair.first]; + velocityNormalInside_[i] = faceSol[scvf.pairData(i).normalPair.first]; if(scvf.pairData(i).normalPair.second >= 0) - subFaceVelocities_[i].velocityNormalOutside = faceSol[scvf.pairData(i).normalPair.second]; - - subFaceVelocities_[i].velocityParallelInside = faceSol[scvf.dofIndex()]; + velocityNormalOutside_[i] = faceSol[scvf.pairData(i).normalPair.second]; if(scvf.pairData(i).outerParallelFaceDofIdx >= 0) - subFaceVelocities_[i].velocityParallelOutside = faceSol[scvf.pairData(i).outerParallelFaceDofIdx]; + velocityParallel_[i] = faceSol[scvf.pairData(i).outerParallelFaceDofIdx]; } } @@ -124,27 +79,27 @@ public: return velocityOpposite_; } - auto& subFaceData() const + Scalar velocityParallel(const int localSubFaceIdx) const { - return subFaceVelocities_; + return velocityParallel_[localSubFaceIdx]; } - auto& subFaceData(const int localSubFaceIdx) const + Scalar velocityNormalInside(const int localSubFaceIdx) const { - return subFaceVelocities_[localSubFaceIdx]; + return velocityNormalInside_[localSubFaceIdx]; } - //! The global volume variables object we are a restriction of - const GlobalFaceVars& globalFaceVars() const - { return *globalFaceVarsPtr_; } - + Scalar velocityNormalOutside(const int localSubFaceIdx) const + { + return velocityNormalOutside_[localSubFaceIdx]; + } private: - const GlobalFaceVars* globalFaceVarsPtr_; - Scalar velocity_; Scalar velocitySelf_; Scalar velocityOpposite_; - std::vector<SubFaceData> subFaceVelocities_; + std::array<Scalar, numPairs> velocityParallel_; + std::array<Scalar, numPairs> velocityNormalInside_; + std::array<Scalar, numPairs> velocityNormalOutside_; }; } // end namespace diff --git a/dumux/freeflow/staggered/fluxvariables.hh b/dumux/freeflow/staggered/fluxvariables.hh index a19d1220c26b92dfe45ddf839ef39bb250d504a4..e8e8bb68690e0a7e82bf440f7c5d1b4c86e9312f 100644 --- a/dumux/freeflow/staggered/fluxvariables.hh +++ b/dumux/freeflow/staggered/fluxvariables.hh @@ -297,7 +297,7 @@ private: const FaceVars& faceVars, const int localSubFaceIdx) { - const Scalar transportingVelocity = faceVars.subFaceData(localSubFaceIdx).velocityNormalInside; + const Scalar transportingVelocity = faceVars.velocityNormalInside(localSubFaceIdx); const auto insideScvIdx = normalFace.insideScvIdx(); const auto outsideScvIdx = normalFace.outsideScvIdx(); @@ -314,12 +314,12 @@ private: Scalar transportedVelocity(0.0); if(innerElementIsUpstream) - transportedVelocity = faceVars.subFaceData(localSubFaceIdx).velocityParallelInside; + transportedVelocity = faceVars.velocitySelf(); else { const int outerDofIdx = scvf.pairData(localSubFaceIdx).outerParallelFaceDofIdx; if(outerDofIdx >= 0) - transportedVelocity = faceVars.subFaceData(localSubFaceIdx).velocityParallelOutside; + transportedVelocity = faceVars.velocityParallel(localSubFaceIdx); else // this is the case when the outer parallal dof would lie outside the domain TODO: discuss which one is better // transportedVelocity = problem.dirichlet(makeGhostFace(subFaceData.virtualOuterParallelFaceDofPos))[faceIdx][scvf.directionIndex()]; transportedVelocity = problem.dirichlet(element, scvf)[faceIdx][scvf.directionIndex()]; @@ -361,10 +361,10 @@ private: // the normal derivative const int outerNormalVelocityIdx = scvf.pairData(localSubFaceIdx).normalPair.second; - const Scalar innerNormalVelocity = faceVars.subFaceData(localSubFaceIdx).velocityNormalInside; + const Scalar innerNormalVelocity = faceVars.velocityNormalInside(localSubFaceIdx); const Scalar outerNormalVelocity = outerNormalVelocityIdx >= 0 ? - faceVars.subFaceData(localSubFaceIdx).velocityNormalOutside : + faceVars.velocityNormalOutside(localSubFaceIdx) : problem.dirichlet(element, makeGhostFace(scvf.pairData(localSubFaceIdx).virtualOuterNormalFaceDofPos))[faceIdx][normalDirIdx]; const Scalar normalDeltaV = scvf.normalInPosCoordDir() ? @@ -375,13 +375,11 @@ private: tangentialDiffusiveFlux -= muAvg * normalDerivative; // the parallel derivative - // const Scalar innerParallelVelocity = velocity(scvf.dofIndex()); - const Scalar innerParallelVelocity = faceVars.subFaceData(localSubFaceIdx).velocityParallelInside; + const Scalar innerParallelVelocity = faceVars.velocitySelf(); const int outerParallelFaceDofIdx = scvf.pairData(localSubFaceIdx).outerParallelFaceDofIdx; const Scalar outerParallelVelocity = outerParallelFaceDofIdx >= 0 ? - faceVars.subFaceData(localSubFaceIdx).velocityParallelOutside : - // velocity(outerParallelFaceDofIdx) : + faceVars.velocityParallel(localSubFaceIdx) : problem.dirichlet(element, makeGhostFace(scvf.pairData(localSubFaceIdx).virtualOuterParallelFaceDofPos))[faceIdx][scvf.directionIndex()]; const Scalar parallelDeltaV = normalFace.normalInPosCoordDir() ?