Commit 90d9de62 authored by Dennis Gläser's avatar Dennis Gläser Committed by Timo Koch
Browse files

[implicit] introduce solutiondependentparams property

Updating the flux var cache is very expensive for mpfa schemes.
We thus introduce a new update() method in the elementfluxvarcaches.
Instead of binding again, the localjacobian calls this method. In the
tpfa case this forwards directly to bind when parameters are solution dependent
as we know we only store the darcy transmissibilities as the others are by default
solution dependent and are calculated on the fly. For mpfa, the fluxvarcachefiller
decides what to update (in case of compositional flow only the diffusive transmissibilities
will be updated when the permeability is not solution dependent).
parent 31ccc3b9
......@@ -68,6 +68,11 @@ public:
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars) {}
// Specialization for the global caching being enabled - do nothing here
void update(const Element& element,
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars) {}
// Specialization for the global caching being enabled - do nothing here
void bindScvf(const Element& element,
const FVElementGeometry& fvGeometry,
......@@ -150,6 +155,21 @@ public:
}
}
// This function updates the transmissibilities after the solution has been deflected during jacobian assembly
void update(const Element& element,
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars)
{
for (auto&& scvf : scvfs(fvGeometry))
(*this)[scvf].setOutdated();
for (auto&& scvf : scvfs(fvGeometry))
{
if (!(*this)[scvf].isUpdated())
FluxVariablesCacheFiller::updateFluxVarCache(globalFluxVarsCache().problem_(), element, fvGeometry, elemVolVars, scvf, *this);
}
}
void bindScvf(const Element& element,
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
......
......@@ -58,6 +58,7 @@ class CCMpfaFluxVariablesCacheFillerImplementation<TypeTag, true, false, false>
using Element = typename GridView::template Codim<0>::Entity;
static const int numEq = GET_PROP_VALUE(TypeTag, NumEq);
static const bool solDependentParams = GET_PROP_VALUE(TypeTag, SolutionDependentParameters);
public:
//! function to fill the flux var caches
......@@ -123,24 +124,40 @@ public:
iv.solveLocalSystem(permFunction);
// update flux variables cache
auto& cache = fluxVarsCache[scvf.index()];
cache.updateInnerAdvection(problem, element, fvGeometry, elemVolVars, scvf, iv);
const auto scvfIdx = scvf.index();
auto& cache = fluxVarsCache[scvfIdx];
cache.updateAdvection(problem, element, fvGeometry, elemVolVars, scvf, iv);
cache.setUpdated();
// update flux variable caches of the other scvfs of the interaction volume
for (const auto& scvfIdx : iv.globalScvfs())
for (const auto scvfIdxJ : iv.globalScvfs())
{
if (scvfIdx != scvf.index())
if (scvfIdxJ != scvfIdx)
{
const auto& scvfJ = fvGeometry.scvf(scvfIdx);
const auto& scvfJ = fvGeometry.scvf(scvfIdxJ);
const auto elementJ = problem.model().globalFvGeometry().element(scvfJ.insideScvIdx());
auto& cacheJ = fluxVarsCache[scvfIdx];
cacheJ.updateInnerAdvection(problem, elementJ, fvGeometry, elemVolVars, scvfJ, iv);
auto& cacheJ = fluxVarsCache[scvfIdxJ];
cacheJ.updateAdvection(problem, elementJ, fvGeometry, elemVolVars, scvfJ, iv);
cacheJ.setUpdated();
}
}
}
}
//! function to update the flux var caches during derivative calculation
template<class FluxVarsCacheVector>
static void updateFluxVarCache(const Problem& problem,
const Element& element,
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
const SubControlVolumeFace& scvf,
FluxVarsCacheVector& fluxVarsCache)
{
if (!solDependentParams)
fluxVarsCache[scvf.index()].setUpdated();
else
fillFluxVarCache(problem, element, fvGeometry, elemVolVars, scvf, fluxVarsCache);
}
};
} // end namespace
......
......@@ -66,6 +66,11 @@ public:
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars) {}
// Specialization for the global caching being enabled - do nothing here
void update(const Element& element,
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars) {}
// Specialization for the global caching being enabled - do nothing here
void bindScvf(const Element& element,
const FVElementGeometry& fvGeometry,
......@@ -101,6 +106,8 @@ class CCTpfaElementFluxVariablesCache<TypeTag, false>
using GlobalFluxVariablesCache = typename GET_PROP_TYPE(TypeTag, GlobalFluxVariablesCache);
using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace);
static const bool solDependentParams = GET_PROP_VALUE(TypeTag, SolutionDependentParameters);
public:
CCTpfaElementFluxVariablesCache(const GlobalFluxVariablesCache& global)
: globalFluxVarsCachePtr_(&global) {}
......@@ -126,6 +133,15 @@ public:
}
}
// This function updates the transmissibilities after the solution has been deflected during jacobian assembly
void update(const Element& element,
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars)
{
if (solDependentParams)
bind(element, fvGeometry, elemVolVars);
}
// This function is called by the CCLocalResidual before flux calculations during assembly.
// Prepares the transmissibilities of the scv faces in the stencil. The FvGeometries are assumed to be bound.
void bind(const Element& element,
......
......@@ -289,9 +289,9 @@ private:
priVars[pvIdx] += eps;
delta += eps;
// update the volume variables and bind the flux var cache again
// update the volume variables and the flux var cache
curVolVars.update(priVars, this->problem_(), element, scv);
elemFluxVarsCache.bind(element, fvGeometry, curElemVolVars);
elemFluxVarsCache.update(element, fvGeometry, curElemVolVars);
if (!isGhost)
{
......@@ -331,9 +331,9 @@ private:
priVars[pvIdx] -= delta + eps;
delta += eps;
// update the volume variables and bind the flux var cache again
// update the volume variables and the flux var cache
curVolVars.update(priVars, this->problem_(), element, scv);
elemFluxVarsCache.bind(element, fvGeometry, curElemVolVars);
elemFluxVarsCache.update(element, fvGeometry, curElemVolVars);
if (!isGhost)
{
......
......@@ -83,7 +83,7 @@ NEW_PROP_TAG(GlobalFluxVariablesCache); //!< The global vector of flux variable
NEW_PROP_TAG(ElementFluxVariablesCache); //!< A local vector of flux variable caches per element
NEW_PROP_TAG(EnableGlobalFluxVariablesCache); //! specifies if data on flux vars should be saved (faster, but more memory consuming)
NEW_PROP_TAG(BoundaryVariables); //!< Data required to calculate fluxes over boundary faces in cc models(outflow)
NEW_PROP_TAG(ConstantBoundaryConditions); //!< boundary data is stored in case the BC are constant
NEW_PROP_TAG(SolutionDependentParameters); //!< specifies if spatial parameters depend on the solution
NEW_PROP_TAG(DiscretizationMethod); //!< Property for the used discretization method
NEW_PROP_TAG(PrimaryVariableSwitch); //!< The primary variable switch needed for compositional models
......
......@@ -152,8 +152,8 @@ SET_BOOL_PROP(ImplicitBase, EnableGlobalVolumeVariablesCache, false);
//! disable flux variables data caching by default
SET_BOOL_PROP(ImplicitBase, EnableGlobalFluxVariablesCache, false);
//! boundary conditions are not stationary by default
SET_BOOL_PROP(ImplicitBase, ConstantBoundaryConditions, false);
//! by default, parameters are solution-dependent
SET_BOOL_PROP(ImplicitBase, SolutionDependentParameters, true);
SET_TYPE_PROP(ImplicitBase, PrimaryVariableSwitch, NoPrimaryVariableSwitch<TypeTag> );
......
......@@ -254,6 +254,11 @@ public:
isUpdated_ = true;
}
void setOutdated()
{
isUpdated_ = false;
}
private:
bool isUpdated_;
Stencil volVarsStencil_;
......
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