Skip to content
Snippets Groups Projects
Commit 2169a267 authored by Kilian Weishaupt's avatar Kilian Weishaupt
Browse files

[staggered] Improve usability of faceVars

parent f4c85a46
No related branches found
No related tags found
3 merge requests!617[WIP] Next,!576Feature/port staggered ff to next next,!571Cleanup/next
...@@ -37,80 +37,35 @@ template<class TypeTag> ...@@ -37,80 +37,35 @@ template<class TypeTag>
class StaggeredFaceVariables class StaggeredFaceVariables
{ {
using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); 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 FacePrimaryVariables = typename GET_PROP_TYPE(TypeTag, FacePrimaryVariables);
using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace); 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 static constexpr int dimWorld = GridView::dimensionworld;
{ static constexpr int numPairs = (dimWorld == 2) ? 2 : 4;
Scalar velocityNormalInside;
Scalar velocityNormalOutside;
Scalar velocityParallelInside;
Scalar velocityParallelOutside;
};
public: 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) void update(const FacePrimaryVariables &facePrivars)
{ {
velocitySelf_ = facePrivars; velocitySelf_ = facePrivars;
} }
void update(const SubControlVolumeFace& scvf, const FaceSolutionVector& sol) template<class SolVector>
{ void update(const SubControlVolumeFace& scvf, const SolVector& faceSol)
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)
{ {
velocitySelf_ = faceSol[scvf.dofIndex()]; velocitySelf_ = faceSol[scvf.dofIndex()];
velocityOpposite_ = faceSol[scvf.dofIndexOpposingFace()]; velocityOpposite_ = faceSol[scvf.dofIndexOpposingFace()];
subFaceVelocities_.resize(scvf.pairData().size());
for(int i = 0; i < scvf.pairData().size(); ++i) 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) if(scvf.pairData(i).normalPair.second >= 0)
subFaceVelocities_[i].velocityNormalOutside = faceSol[scvf.pairData(i).normalPair.second]; velocityNormalOutside_[i] = faceSol[scvf.pairData(i).normalPair.second];
subFaceVelocities_[i].velocityParallelInside = faceSol[scvf.dofIndex()];
if(scvf.pairData(i).outerParallelFaceDofIdx >= 0) 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: ...@@ -124,27 +79,27 @@ public:
return velocityOpposite_; 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 Scalar velocityNormalOutside(const int localSubFaceIdx) const
const GlobalFaceVars& globalFaceVars() const {
{ return *globalFaceVarsPtr_; } return velocityNormalOutside_[localSubFaceIdx];
}
private: private:
const GlobalFaceVars* globalFaceVarsPtr_;
Scalar velocity_;
Scalar velocitySelf_; Scalar velocitySelf_;
Scalar velocityOpposite_; Scalar velocityOpposite_;
std::vector<SubFaceData> subFaceVelocities_; std::array<Scalar, numPairs> velocityParallel_;
std::array<Scalar, numPairs> velocityNormalInside_;
std::array<Scalar, numPairs> velocityNormalOutside_;
}; };
} // end namespace } // end namespace
......
...@@ -297,7 +297,7 @@ private: ...@@ -297,7 +297,7 @@ private:
const FaceVars& faceVars, const FaceVars& faceVars,
const int localSubFaceIdx) const int localSubFaceIdx)
{ {
const Scalar transportingVelocity = faceVars.subFaceData(localSubFaceIdx).velocityNormalInside; const Scalar transportingVelocity = faceVars.velocityNormalInside(localSubFaceIdx);
const auto insideScvIdx = normalFace.insideScvIdx(); const auto insideScvIdx = normalFace.insideScvIdx();
const auto outsideScvIdx = normalFace.outsideScvIdx(); const auto outsideScvIdx = normalFace.outsideScvIdx();
...@@ -314,12 +314,12 @@ private: ...@@ -314,12 +314,12 @@ private:
Scalar transportedVelocity(0.0); Scalar transportedVelocity(0.0);
if(innerElementIsUpstream) if(innerElementIsUpstream)
transportedVelocity = faceVars.subFaceData(localSubFaceIdx).velocityParallelInside; transportedVelocity = faceVars.velocitySelf();
else else
{ {
const int outerDofIdx = scvf.pairData(localSubFaceIdx).outerParallelFaceDofIdx; const int outerDofIdx = scvf.pairData(localSubFaceIdx).outerParallelFaceDofIdx;
if(outerDofIdx >= 0) 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 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(makeGhostFace(subFaceData.virtualOuterParallelFaceDofPos))[faceIdx][scvf.directionIndex()];
transportedVelocity = problem.dirichlet(element, scvf)[faceIdx][scvf.directionIndex()]; transportedVelocity = problem.dirichlet(element, scvf)[faceIdx][scvf.directionIndex()];
...@@ -361,10 +361,10 @@ private: ...@@ -361,10 +361,10 @@ private:
// the normal derivative // the normal derivative
const int outerNormalVelocityIdx = scvf.pairData(localSubFaceIdx).normalPair.second; 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 ? const Scalar outerNormalVelocity = outerNormalVelocityIdx >= 0 ?
faceVars.subFaceData(localSubFaceIdx).velocityNormalOutside : faceVars.velocityNormalOutside(localSubFaceIdx) :
problem.dirichlet(element, makeGhostFace(scvf.pairData(localSubFaceIdx).virtualOuterNormalFaceDofPos))[faceIdx][normalDirIdx]; problem.dirichlet(element, makeGhostFace(scvf.pairData(localSubFaceIdx).virtualOuterNormalFaceDofPos))[faceIdx][normalDirIdx];
const Scalar normalDeltaV = scvf.normalInPosCoordDir() ? const Scalar normalDeltaV = scvf.normalInPosCoordDir() ?
...@@ -375,13 +375,11 @@ private: ...@@ -375,13 +375,11 @@ private:
tangentialDiffusiveFlux -= muAvg * normalDerivative; tangentialDiffusiveFlux -= muAvg * normalDerivative;
// the parallel derivative // the parallel derivative
// const Scalar innerParallelVelocity = velocity(scvf.dofIndex()); const Scalar innerParallelVelocity = faceVars.velocitySelf();
const Scalar innerParallelVelocity = faceVars.subFaceData(localSubFaceIdx).velocityParallelInside;
const int outerParallelFaceDofIdx = scvf.pairData(localSubFaceIdx).outerParallelFaceDofIdx; const int outerParallelFaceDofIdx = scvf.pairData(localSubFaceIdx).outerParallelFaceDofIdx;
const Scalar outerParallelVelocity = outerParallelFaceDofIdx >= 0 ? const Scalar outerParallelVelocity = outerParallelFaceDofIdx >= 0 ?
faceVars.subFaceData(localSubFaceIdx).velocityParallelOutside : faceVars.velocityParallel(localSubFaceIdx) :
// velocity(outerParallelFaceDofIdx) :
problem.dirichlet(element, makeGhostFace(scvf.pairData(localSubFaceIdx).virtualOuterParallelFaceDofPos))[faceIdx][scvf.directionIndex()]; problem.dirichlet(element, makeGhostFace(scvf.pairData(localSubFaceIdx).virtualOuterParallelFaceDofPos))[faceIdx][scvf.directionIndex()];
const Scalar parallelDeltaV = normalFace.normalInPosCoordDir() ? const Scalar parallelDeltaV = normalFace.normalInPosCoordDir() ?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment