Commit 20b2bbcc authored by Timo Koch's avatar Timo Koch
Browse files

[assembly] Replace fluxVarCache by more general elementFluxVarCache objects in interfaces

parent 869c8195
......@@ -58,14 +58,14 @@ class DarcysLawImplementation<TypeTag, DiscretizationMethods::CCTpfa>
using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry);
using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables);
using FluxVarsCache = typename GET_PROP_TYPE(TypeTag, FluxVariablesCache);
using ElementFluxVarsCache = typename GET_PROP_TYPE(TypeTag, ElementFluxVariablesCache);
using Element = typename GridView::template Codim<0>::Entity;
using IndexType = typename GridView::IndexSet::IndexType;
using Stencil = std::vector<IndexType>;
enum { dim = GridView::dimension} ;
enum { dimWorld = GridView::dimensionworld} ;
static const int dim = GridView::dimension;
static const int dimWorld = GridView::dimensionworld;
using DimWorldMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>;
......@@ -78,9 +78,9 @@ public:
const ElementVolumeVariables& elemVolVars,
const SubControlVolumeFace& scvFace,
int phaseIdx,
const FluxVarsCache& fluxVarsCache)
const ElementFluxVarsCache& elemFluxVarsCache)
{
const auto& tij = fluxVarsCache.tij();
const auto& fluxVarsCache = elemFluxVarsCache[scvFace];
// Get the inside and outside volume variables
const auto& insideScv = fvGeometry.scv(scvFace.insideScvIdx());
......@@ -122,7 +122,7 @@ public:
}
}
return tij*(hInside - hOutside);
return fluxVarsCache.tij()*(hInside - hOutside);
}
static Stencil stencil(const Problem& problem,
......
......@@ -45,7 +45,7 @@ class FluxVariablesBase
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 FluxVariablesCache = typename GET_PROP_TYPE(TypeTag, FluxVariablesCache);
using ElementFluxVariablesCache = typename GET_PROP_TYPE(TypeTag, ElementFluxVariablesCache);
public:
......@@ -54,20 +54,16 @@ public:
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
const SubControlVolumeFace &scvFace,
const FluxVariablesCache& fluxVarsCache)
const ElementFluxVariablesCache& elemFluxVarsCache)
{
problemPtr_ = &problem;
elementPtr_ = &element;
scvFacePtr_ = &scvFace;
fvGeometryPtr_ = &fvGeometry;
elemVolVarsPtr_ = &elemVolVars;
fluxVarsCachePtr_ = &fluxVarsCache;
elemFluxVarsCachePtr_ = &elemFluxVarsCache;
}
// get the stencil from the cache class
const Stencil & stencil() const
{ return problem().model().fluxVarsCache(scvFace()).stencil(); }
const Problem& problem() const
{ return *problemPtr_; }
......@@ -83,8 +79,8 @@ public:
const ElementVolumeVariables& elemVolVars() const
{ return *elemVolVarsPtr_; }
const FluxVariablesCache& fluxVarsCache() const
{ return *fluxVarsCachePtr_; }
const ElementFluxVariablesCache& elemFluxVarsCache() const
{ return *elemFluxVarsCachePtr_; }
Stencil computeStencil(const Problem& problem, const Element& element, const SubControlVolumeFace& scvFace)
{ DUNE_THROW(Dune::InvalidStateException, "computeStencil() routine is not provided by the implementation."); }
......@@ -102,7 +98,7 @@ private:
const FVElementGeometry* fvGeometryPtr_;
const SubControlVolumeFace* scvFacePtr_; //! Pointer to the sub control volume face for which the flux variables are created
const ElementVolumeVariables* elemVolVarsPtr_;
const FluxVariablesCache* fluxVarsCachePtr_;
const ElementFluxVariablesCache* elemFluxVarsCachePtr_;
};
} // end namespace
......
......@@ -215,7 +215,7 @@ private:
for (auto fluxVarIdx : assemblyMap_[globalI_][j])
{
auto&& scvf = fvGeometry.scvf(fluxVarIdx);
origFlux[j] += localRes.evalFlux_(elementJ, fvGeometry, curElemVolVars, scvf, elemFluxVarsCache[scvf]);
origFlux[j] += localRes.evalFlux_(elementJ, fvGeometry, curElemVolVars, scvf, elemFluxVarsCache);
}
++j;
......@@ -270,7 +270,7 @@ private:
for (auto fluxVarIdx : assemblyMap_[globalI_][k])
{
auto&& scvf = fvGeometry.scvf(fluxVarIdx);
neighborDeriv[k] += localRes.evalFlux_(neighborElements[k], fvGeometry, curElemVolVars, scvf, elemFluxVarsCache[scvf]);
neighborDeriv[k] += localRes.evalFlux_(neighborElements[k], fvGeometry, curElemVolVars, scvf, elemFluxVarsCache);
}
}
}
......@@ -312,7 +312,7 @@ private:
for (auto fluxVarIdx : assemblyMap_[globalI_][k])
{
auto&& scvf = fvGeometry.scvf(fluxVarIdx);
neighborDeriv[k] -= localRes.evalFlux_(neighborElements[k], fvGeometry, curElemVolVars, scvf, elemFluxVarsCache[scvf]);
neighborDeriv[k] -= localRes.evalFlux_(neighborElements[k], fvGeometry, curElemVolVars, scvf, elemFluxVarsCache);
}
}
}
......
......@@ -77,7 +77,7 @@ protected:
// calculate the mass flux over the scv faces
for (auto&& scvf : scvfs(fvGeometry))
{
this->residual_[0] += this->asImp_().computeFlux_(element, fvGeometry, elemVolVars, scvf, bcTypes, elemFluxVarsCache[scvf]);
this->residual_[0] += this->asImp_().computeFlux_(element, fvGeometry, elemVolVars, scvf, bcTypes, elemFluxVarsCache);
}
}
......@@ -86,10 +86,10 @@ protected:
const ElementVolumeVariables& elemVolVars,
const SubControlVolumeFace &scvf,
const ElementBoundaryTypes& bcTypes,
const FluxVariablesCache& fluxVarsCache)
const ElementFluxVariablesCache& elemFluxVarsCache)
{
if (!scvf.boundary())
return this->asImp_().computeFlux(element, fvGeometry, elemVolVars, scvf, fluxVarsCache);
return this->asImp_().computeFlux(element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
else
return PrimaryVariables(0.0);
......@@ -106,7 +106,7 @@ protected:
if (scvf.boundary())
{
auto bcTypes = this->problem().boundaryTypes(element, scvf);
this->residual_[0] += evalBoundaryFluxes_(element, fvGeometry, elemVolVars, scvf, bcTypes, elemFluxVarsCache[scvf]);
this->residual_[0] += evalBoundaryFluxes_(element, fvGeometry, elemVolVars, scvf, bcTypes, elemFluxVarsCache);
}
}
......@@ -130,7 +130,7 @@ protected:
const ElementVolumeVariables& elemVolVars,
const SubControlVolumeFace &scvf,
const BoundaryTypes& bcTypes,
const FluxVariablesCache& fluxVarsCache)
const ElementFluxVariablesCache& elemFluxVarsCache)
{
// evaluate the Neumann conditions at the boundary face
PrimaryVariables flux(0);
......@@ -143,7 +143,7 @@ protected:
// evaluate the pure Dirichlet conditions at the boundary face
if (bcTypes.hasDirichlet() && !bcTypes.hasNeumann())
flux += this->asImp_().evalDirichletSegment_(element, fvGeometry, elemVolVars, scvf, bcTypes, fluxVarsCache);
flux += this->asImp_().evalDirichletSegment_(element, fvGeometry, elemVolVars, scvf, bcTypes, elemFluxVarsCache);
return flux;
}
......@@ -199,12 +199,12 @@ protected:
const ElementVolumeVariables& elemVolVars,
const SubControlVolumeFace &scvf,
const BoundaryTypes &bcTypes,
const FluxVariablesCache& fluxVarsCache)
const ElementFluxVariablesCache& elemFluxVarsCache)
{
// temporary vector to store the Dirichlet boundary fluxes
PrimaryVariables flux(0);
auto dirichletFlux = this->asImp_().computeFlux(element, fvGeometry, elemVolVars, scvf, fluxVarsCache);
auto dirichletFlux = this->asImp_().computeFlux(element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
// add fluxes to the residual
for (int eqIdx = 0; eqIdx < numEq; ++eqIdx)
......
......@@ -293,7 +293,7 @@ protected:
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
const SubControlVolumeFace& scvf,
const FluxVariablesCache& fluxVarsCache)
const ElementFluxVariablesCache& elemFluxVarsCache)
{
ElementBoundaryTypes bcTypes;
bcTypes.update(problem(), element, fvGeometry);
......@@ -301,7 +301,7 @@ protected:
residual_.resize(fvGeometry.numScv());
residual_ = 0;
return asImp_().computeFlux_(element, fvGeometry, elemVolVars, scvf, bcTypes, fluxVarsCache);
return asImp_().computeFlux_(element, fvGeometry, elemVolVars, scvf, bcTypes, elemFluxVarsCache);
}
/*!
......
......@@ -44,7 +44,7 @@ class ImmiscibleLocalResidual : public GET_PROP_TYPE(TypeTag, BaseLocalResidual)
using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables);
using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables);
using FluxVariables = typename GET_PROP_TYPE(TypeTag, FluxVariables);
using FluxVariablesCache = typename GET_PROP_TYPE(TypeTag, FluxVariablesCache);
using ElementFluxVariablesCache = typename GET_PROP_TYPE(TypeTag, ElementFluxVariablesCache);
using SubControlVolume = typename GET_PROP_TYPE(TypeTag, SubControlVolume);
using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace);
using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry);
......@@ -100,7 +100,7 @@ public:
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
const SubControlVolumeFace& scvf,
const FluxVariablesCache& fluxVarsCache) const
const ElementFluxVariablesCache& elemFluxVarsCache) const
{
FluxVariables fluxVars;
fluxVars.initAndComputeFluxes(this->problem(),
......@@ -108,7 +108,7 @@ public:
fvGeometry,
elemVolVars,
scvf,
fluxVarsCache);
elemFluxVarsCache);
PrimaryVariables flux;
for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
......
......@@ -38,6 +38,7 @@ NEW_PROP_TAG(EnableAdvection);
NEW_PROP_TAG(EnableMolecularDiffusion);
NEW_PROP_TAG(EnableEnergyBalance);
NEW_PROP_TAG(ImplicitMassUpwindWeight);
NEW_PROP_TAG(EnableGlobalElementFluxVariablesCache);
}
// forward declaration
......@@ -73,7 +74,10 @@ class PorousMediumFluxVariablesImpl<TypeTag, true, false, false>
using AdvectionType = typename GET_PROP_TYPE(TypeTag, AdvectionType);
using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables);
using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables);
using FluxVariablesCache = typename GET_PROP_TYPE(TypeTag, FluxVariablesCache);
using ElementFluxVariablesCache = typename GET_PROP_TYPE(TypeTag, ElementFluxVariablesCache);
static const int dim = GridView::dimension;
static const int dimWorld = GridView::dimensionworld;
public:
......@@ -82,9 +86,9 @@ public:
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
const SubControlVolumeFace &scvFace,
const FluxVariablesCache& fluxVarsCache)
const ElementFluxVariablesCache& elemFluxVarsCache)
{
ParentType::init(problem, element, fvGeometry, elemVolVars, scvFace, fluxVarsCache);
ParentType::init(problem, element, fvGeometry, elemVolVars, scvFace, elemFluxVarsCache);
// retrieve the upwind weight for the mass conservation equations. Use the value
// specified via the property system as default, and overwrite
// it by the run-time parameter from the Dune::ParameterTree
......@@ -162,7 +166,7 @@ class PorousMediumFluxVariablesImpl<TypeTag, true, true, false>
using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace);
using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry);
using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables);
using FluxVariablesCache = typename GET_PROP_TYPE(TypeTag, FluxVariablesCache);
using ElementFluxVariablesCache = typename GET_PROP_TYPE(TypeTag, ElementFluxVariablesCache);
using AdvectionType = typename GET_PROP_TYPE(TypeTag, AdvectionType);
using MolecularDiffusionType = typename GET_PROP_TYPE(TypeTag, MolecularDiffusionType);
......@@ -176,10 +180,10 @@ public:
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
const SubControlVolumeFace &scvFace,
const FluxVariablesCache& fluxVarsCache)
const ElementFluxVariablesCache& elemFluxVarsCache)
{
advFluxCached_.reset();
ParentType::init(problem, element, fvGeometry, elemVolVars, scvFace, fluxVarsCache);
ParentType::init(problem, element, fvGeometry, elemVolVars, scvFace, elemFluxVarsCache);
// retrieve the upwind weight for the mass conservation equations. Use the value
// specified via the property system as default, and overwrite
// it by the run-time parameter from the Dune::ParameterTree
......@@ -198,12 +202,10 @@ public:
this->elemVolVars(),
this->scvFace(),
phaseIdx,
this->fluxVarsCache());
this->elemFluxVarsCache());
advFluxCached_.set(phaseIdx, true);
}
const auto& insideScv = this->fvGeometry().scv(this->scvFace().insideScvIdx());
const auto& insideVolVars = this->elemVolVars()[insideScv];
const auto& outsideVolVars = this->elemVolVars()[this->scvFace().outsideScvIdx()];
......@@ -224,7 +226,7 @@ public:
this->elemVolVars(),
this->scvFace(),
phaseIdx, compIdx,
this->fluxVarsCache());
this->elemFluxVarsCache());
return flux;
}
......@@ -272,7 +274,7 @@ class PorousMediumFluxVariablesImpl<TypeTag, true, false, true>
using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace);
using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry);
using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables);
using FluxVariablesCache = typename GET_PROP_TYPE(TypeTag, FluxVariablesCache);
using ElementFluxVariablesCache = typename GET_PROP_TYPE(TypeTag, ElementFluxVariablesCache);
using AdvectionType = typename GET_PROP_TYPE(TypeTag, AdvectionType);
using HeatConductionType = typename GET_PROP_TYPE(TypeTag, HeatConductionType);
......@@ -286,10 +288,10 @@ public:
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
const SubControlVolumeFace &scvFace,
const FluxVariablesCache& fluxVarsCache)
const ElementFluxVariablesCache& elemFluxVarsCache)
{
advFluxCached_.reset();
ParentType::init(problem, element, fvGeometry, elemVolVars, scvFace, fluxVarsCache);
ParentType::init(problem, element, fvGeometry, elemVolVars, scvFace, elemFluxVarsCache);
// retrieve the upwind weight for the mass conservation equations. Use the value
// specified via the property system as default, and overwrite
// it by the run-time parameter from the Dune::ParameterTree
......@@ -308,7 +310,7 @@ public:
this->elemVolVars(),
this->scvFace(),
phaseIdx,
this->fluxVarsCache());
this->elemFluxVarsCache());
advFluxCached_.set(phaseIdx, true);
}
......@@ -333,7 +335,7 @@ public:
this->fvGeometry(),
this->elemVolVars(),
this->scvFace(),
this->fluxVarsCache());
this->elemFluxVarsCache());
return flux;
}
......@@ -382,7 +384,7 @@ class PorousMediumFluxVariablesImpl<TypeTag, true, true, true>
using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace);
using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry);
using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables);
using FluxVariablesCache = typename GET_PROP_TYPE(TypeTag, FluxVariablesCache);
using ElementFluxVariablesCache = typename GET_PROP_TYPE(TypeTag, ElementFluxVariablesCache);
using AdvectionType = typename GET_PROP_TYPE(TypeTag, AdvectionType);
using MolecularDiffusionType = typename GET_PROP_TYPE(TypeTag, MolecularDiffusionType);
......@@ -397,10 +399,10 @@ public:
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
const SubControlVolumeFace &scvFace,
const FluxVariablesCache& fluxVarsCache)
const ElementFluxVariablesCache& elemFluxVarsCache)
{
advFluxCached_.reset();
ParentType::init(problem, element, fvGeometry, elemVolVars, scvFace, fluxVarsCache);
ParentType::init(problem, element, fvGeometry, elemVolVars, scvFace, elemFluxVarsCache);
// retrieve the upwind weight for the mass conservation equations. Use the value
// specified via the property system as default, and overwrite
// it by the run-time parameter from the Dune::ParameterTree
......@@ -419,7 +421,7 @@ public:
this->elemVolVars(),
this->scvFace(),
phaseIdx,
this->fluxVarsCache());
this->elemFluxVarsCache());
advFluxCached_.set(phaseIdx, true);
}
......@@ -445,7 +447,7 @@ public:
this->elemVolVars(),
this->scvFace(),
phaseIdx, compIdx,
this->fluxVarsCache());
this->elemFluxVarsCache());
return flux;
}
......@@ -456,7 +458,7 @@ public:
this->fvGeometry(),
this->elemVolVars(),
this->scvFace(),
this->fluxVarsCache());
this->elemFluxVarsCache());
return flux;
}
......
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