Commit 33f43cb8 authored by Ned Coltman's avatar Ned Coltman Committed by Timo Koch
Browse files

[fluxvariables][gridfluxvarscache] adapt the fluxvariables to check for...

[fluxvariables][gridfluxvarscache] adapt the fluxvariables to check for higherorder via the gridfluxvarscache, not the problem
parent 0bf3bed6
......@@ -28,6 +28,8 @@
#include <dumux/discretization/localview.hh>
#include <dumux/discretization/staggered/elementfluxvariablescache.hh>
#include <dumux/freeflow/higherorderapproximation.hh>
namespace Dumux {
/*!
......@@ -42,7 +44,6 @@ struct StaggeredDefaultGridFluxVariablesCacheTraits
using Problem = P;
using FluxVariablesCache = FVC;
using FluxVariablesCacheFiller = FVCF;
template<class GridFluxVariablesCache, bool cachingEnabled>
using LocalView = StaggeredElementFluxVariablesCache<GridFluxVariablesCache, cachingEnabled>;
};
......@@ -72,6 +73,7 @@ class StaggeredGridFluxVariablesCache<P, FVC, FVCF, true, Traits>
public:
//! export the flux variable cache type
using FluxVariablesCache = typename Traits::FluxVariablesCache;
using Scalar = typename FluxVariablesCache::Scalar;
//! export the flux variable cache filler type
using FluxVariablesCacheFiller = typename Traits::FluxVariablesCacheFiller;
......@@ -82,7 +84,10 @@ public:
//! export the type of the local view
using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
StaggeredGridFluxVariablesCache(const Problem& problem) : problemPtr_(&problem) {}
StaggeredGridFluxVariablesCache(const Problem& problem, const std::string& paramGroup = "")
: problemPtr_(&problem)
, higherOrderApproximation_(paramGroup)
{}
// When global caching is enabled, precompute transmissibilities and stencils for all the scv faces
template<class FVGridGeometry, class GridVolumeVariables, class SolutionVector>
......@@ -118,6 +123,12 @@ public:
}
}
//! Return the HigherOrderApproximation
const HigherOrderApproximation<Scalar>& higherOrderApproximation() const
{
return higherOrderApproximation_;
}
const Problem& problem() const
{ return *problemPtr_; }
......@@ -130,6 +141,7 @@ public:
private:
const Problem* problemPtr_;
HigherOrderApproximation<Scalar> higherOrderApproximation_;
std::vector<FluxVariablesCache> fluxVarsCache_;
std::vector<std::size_t> globalScvfIndices_;
......@@ -149,6 +161,7 @@ class StaggeredGridFluxVariablesCache<P, FVC, FVCF, false, Traits>
public:
//! export the flux variable cache type
using FluxVariablesCache = typename Traits::FluxVariablesCache;
using Scalar = typename FluxVariablesCache::Scalar;
//! export the flux variable cache filler type
using FluxVariablesCacheFiller = typename Traits::FluxVariablesCacheFiller;
......@@ -159,7 +172,10 @@ public:
//! export the type of the local view
using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
StaggeredGridFluxVariablesCache(const Problem& problem) : problemPtr_(&problem) {}
StaggeredGridFluxVariablesCache(const Problem& problem, const std::string& paramGroup = "")
: problemPtr_(&problem)
, higherOrderApproximation_(paramGroup)
{}
// When global caching is enabled, precompute transmissibilities and stencils for all the scv faces
template<class FVGridGeometry, class GridVolumeVariables, class SolutionVector>
......@@ -171,10 +187,16 @@ public:
const Problem& problem() const
{ return *problemPtr_; }
private:
//! Return the HigherOrderApproximation
const HigherOrderApproximation<Scalar>& higherOrderApproximation() const
{
return higherOrderApproximation_;
}
private:
const Problem* problemPtr_;
HigherOrderApproximation<Scalar> higherOrderApproximation_;
};
} // end namespace Dumux
......
......@@ -59,6 +59,8 @@ class FreeFlowFluxVariablesCacheImplementation<TypeTag, DiscretizationMethod::st
using Element = typename GridView::template Codim<0>::Entity;
public:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
//! Do nothing for the staggered grid specialization.
void update(const Problem& problem,
const Element& element,
......
......@@ -29,8 +29,6 @@
#include <dumux/common/staggeredfvproblem.hh>
#include <dumux/discretization/method.hh>
#include <dumux/freeflow/higherorderapproximation.hh>
#include "model.hh"
namespace Dumux {
......@@ -95,9 +93,8 @@ public:
* \param paramGroup The parameter group in which to look for runtime parameters first (default is "")
*/
NavierStokesProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry, const std::string& paramGroup = "")
: ParentType(fvGridGeometry, paramGroup),
gravity_(0.0),
higherOrderApproximation_(paramGroup)
: ParentType(fvGridGeometry, paramGroup)
, gravity_(0.0)
{
if (getParamFromGroup<bool>(paramGroup, "Problem.EnableGravity"))
gravity_[dim-1] = -9.81;
......@@ -222,12 +219,6 @@ public:
return velocitySelf / (alpha / sqrt(K) * scvf.cellCenteredParallelDistance(localSubFaceIdx,0) + 1.0);
}
//! Return the HigherOrderApproximation
const HigherOrderApproximation<Scalar>& higherOrderApproximation() const
{
return higherOrderApproximation_;
}
private:
//! Returns the implementation of the problem (i.e. static polymorphism)
......@@ -239,7 +230,6 @@ private:
{ return *static_cast<const Implementation *>(this); }
GravityVector gravity_;
HigherOrderApproximation<Scalar> higherOrderApproximation_;
bool enableInertiaTerms_;
};
......
......@@ -163,10 +163,11 @@ public:
const SubControlVolumeFace& scvf,
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
const ElementFaceVariables& elemFaceVars)
const ElementFaceVariables& elemFaceVars,
const GridFluxVariablesCache& gridFluxVarsCache)
{
return computeFrontalMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars) +
computeLateralMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars);
return computeFrontalMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, gridFluxVarsCache) +
computeLateralMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, gridFluxVarsCache);
}
/*!
......@@ -191,7 +192,8 @@ public:
const SubControlVolumeFace& scvf,
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
const ElementFaceVariables& elemFaceVars)
const ElementFaceVariables& elemFaceVars,
const GridFluxVariablesCache& gridFluxVarsCache)
{
FacePrimaryVariables frontalFlux(0.0);
......@@ -227,7 +229,7 @@ public:
// distances[2]: downstream staggered cell size
std::array<Scalar, 3> distances{0.0, 0.0, 0.0};
const auto& highOrder = problem.higherOrderApproximation();
const auto& highOrder = gridFluxVarsCache.higherOrderApproximation();
// If a Tvd approach has been specified and I am not too near to the boundary I can use a second order
// approximation for the velocity. In this frontal flux I use for the density always the value that I have on the scvf.
......@@ -304,7 +306,8 @@ public:
const SubControlVolumeFace& scvf,
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
const ElementFaceVariables& elemFaceVars)
const ElementFaceVariables& elemFaceVars,
const GridFluxVariablesCache& gridFluxVarsCache)
{
FacePrimaryVariables normalFlux(0.0);
auto& faceVars = elemFaceVars[scvf];
......@@ -364,7 +367,7 @@ public:
// If there is no symmetry or Neumann boundary condition for the given sub face, proceed to calculate the tangential momentum flux.
if (problem.enableInertiaTerms())
normalFlux += computeAdvectivePartOfLateralMomentumFlux_(problem, fvGeometry, element, scvf, normalFace, elemVolVars, faceVars, localSubFaceIdx, lateralFaceHasDirichletPressure, lateralFaceHasBJS);
normalFlux += computeAdvectivePartOfLateralMomentumFlux_(problem, fvGeometry, element, scvf, normalFace, elemVolVars, faceVars, gridFluxVarsCache, localSubFaceIdx, lateralFaceHasDirichletPressure, lateralFaceHasBJS);
normalFlux += computeDiffusivePartOfLateralMomentumFlux_(problem, fvGeometry, element, scvf, normalFace, elemVolVars, faceVars, localSubFaceIdx, lateralFaceHasDirichletPressure, lateralFaceHasBJS);
}
......@@ -401,6 +404,7 @@ private:
const SubControlVolumeFace& normalFace,
const ElementVolumeVariables& elemVolVars,
const FaceVariables& faceVars,
const GridFluxVariablesCache& gridFluxVarsCache,
const int localSubFaceIdx,
const bool lateralFaceHasDirichletPressure,
const bool lateralFaceHasBJS)
......@@ -432,7 +436,7 @@ private:
// distances[2]: downstream staggered cell size
std::array<Scalar, 3> distances{0.0, 0.0, 0.0};
const auto& highOrder = problem.higherOrderApproximation();
const auto& highOrder = gridFluxVarsCache.higherOrderApproximation();
// If a Tvd approach has been specified and I am not too near to the boundary I can use a second order approximation.
if (highOrder.tvdApproach() != TvdApproach::none)
......
......@@ -179,7 +179,7 @@ public:
const ElementFluxVariablesCache& elemFluxVarsCache) const
{
FluxVariables fluxVars;
return fluxVars.computeMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars);
return fluxVars.computeMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, elemFluxVarsCache.gridFluxVarsCache());
}
/*!
......
......@@ -184,12 +184,13 @@ public:
const SubControlVolumeFace& scvf,
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
const ElementFaceVariables& elemFaceVars)
const ElementFaceVariables& elemFaceVars,
const GridFluxVariablesCache& gridFluxVarsCache)
{
const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
return ParentType::computeFrontalMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars)
+ ParentType::computeLateralMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars)
return ParentType::computeFrontalMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, gridFluxVarsCache)
+ ParentType::computeLateralMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, gridFluxVarsCache)
+ 2.0 / ModelTraits::dim() * insideVolVars.density() * insideVolVars.turbulentKineticEnergy()
* scvf.area() * scvf.directionSign() * insideVolVars.extrusionFactor();
}
......
......@@ -175,12 +175,13 @@ public:
const SubControlVolumeFace& scvf,
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
const ElementFaceVariables& elemFaceVars)
const ElementFaceVariables& elemFaceVars,
const GridFluxVariablesCache& gridFluxVarsCache)
{
const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
return ParentType::computeFrontalMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars)
+ ParentType::computeLateralMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars)
return ParentType::computeFrontalMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, gridFluxVarsCache)
+ ParentType::computeLateralMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, gridFluxVarsCache)
+ 2.0 / ModelTraits::dim() * insideVolVars.density() * insideVolVars.turbulentKineticEnergy()
* scvf.area() * scvf.directionSign() * insideVolVars.extrusionFactor();
}
......
......@@ -176,12 +176,13 @@ public:
const SubControlVolumeFace& scvf,
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
const ElementFaceVariables& elemFaceVars)
const ElementFaceVariables& elemFaceVars,
const GridFluxVariablesCache& gridFluxVarsCache)
{
const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
return ParentType::computeFrontalMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars)
+ ParentType::computeLateralMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars)
return ParentType::computeFrontalMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, gridFluxVarsCache)
+ ParentType::computeLateralMomentumFlux(problem, element, scvf, fvGeometry, elemVolVars, elemFaceVars, gridFluxVarsCache)
+ 2.0 / ModelTraits::dim() * insideVolVars.density() * insideVolVars.turbulentKineticEnergy()
* scvf.area() * scvf.directionSign() * insideVolVars.extrusionFactor();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment