Commit d4b98cc5 authored by Kilian Weishaupt's avatar Kilian Weishaupt
Browse files

[staggered] Do not call sourceAtPos in localRes

parent 27c771a8
......@@ -281,7 +281,7 @@ protected:
const ElementBoundaryTypes &bcTypes) const
{
// the source term:
auto faceSource = asImp_().computeSourceForFace(problem, scvf, curElemVolVars, curFaceVars);
auto faceSource = asImp_().computeSourceForFace(problem, element, fvGeometry, scvf, curElemVolVars, curFaceVars);
const auto& scv = fvGeometry.scv(scvf.insideScvIdx());
const auto curExtrusionFactor = curElemVolVars[scv].extrusionFactor();
faceSource *= 0.5*scv.volume()*curExtrusionFactor;
......@@ -367,10 +367,9 @@ protected:
residual -= std::move(prevFaceStorage);
residual *= (scv.volume()/2.0);
residual /= timeLoop_->timeStepSize();
// residuals[scvf.localFaceIdx()] += faceStorageTerms_[scvf.localFaceIdx()];
// the source term:
auto faceSource = asImp_().computeSourceForFace(problem, scvf, curElemVolVars, curFaceVars);
auto faceSource = asImp_().computeSourceForFace(problem, element, fvGeometry, scvf, curElemVolVars, curFaceVars);
faceSource *= 0.5*scv.volume()*curVolVars.extrusionFactor();
residual -= faceSource;
}
......
......@@ -52,12 +52,14 @@ class StaggeredFVProblem : public FVProblem<TypeTag>
using ParentType = FVProblem<TypeTag>;
using Implementation = typename GET_PROP_TYPE(TypeTag, Problem);
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
using Element = typename GridView::template Codim<0>::Entity;
using PrimaryVariables = typename GET_PROP_TYPE(TypeTag, PrimaryVariables);
using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry);
using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector);
using FVElementGeometry = typename FVGridGeometry::LocalView;
using SubControlVolume = typename FVElementGeometry::SubControlVolume;
using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
using NumEqVector = typename GET_PROP_TYPE(TypeTag, NumEqVector);
using CoordScalar = typename GridView::ctype;
using GlobalPosition = Dune::FieldVector<CoordScalar, GridView::dimensionworld>;
......@@ -75,6 +77,35 @@ public:
: ParentType(fvGridGeometry, paramGroup)
{ }
/*!
* \brief Evaluate the source term for all phases within a given
* sub-control-volume (-face).
*
* This is the method for the case where the source term is
* potentially solution dependent and requires some quantities that
* are specific to the fully-implicit method.
*
* \param element The finite element
* \param fvGeometry The finite-volume geometry
* \param elemVolVars All volume variables for the element
* \param elementFaceVars All face variables for the element
* \param e The geometrical entity on which the source shall be applied (scv or scvf)
*
* For this method, the return parameter stores the conserved quantity rate
* generated or annihilate per volume unit. Positive values mean
* that the conserved quantity is created, negative ones mean that it vanishes.
*/
template<class ElementVolumeVariables, class ElementFaceVariables, class Entity>
NumEqVector source(const Element &element,
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
const ElementFaceVariables& elementFaceVars,
const Entity &e) const
{
// forward to solution independent, fully-implicit specific interface
return asImp_().sourceAtPos(e.center());
}
/*!
* \brief Evaluate the initial value for a control volume.
*
......
......@@ -117,7 +117,7 @@ public:
CellCenterPrimaryVariables result(0.0);
// get the values from the problem
const auto sourceValues = problem.sourceAtPos(scv.center());
const auto sourceValues = problem.source(element, fvGeometry, elemVolVars, elemFaceVars, scv);
// copy the respective cell center related values to the result
for (int i = 0; i < result.size(); ++i)
......@@ -155,6 +155,8 @@ public:
//! Evaluate the source term for the face control volume.
FacePrimaryVariables computeSourceForFace(const Problem& problem,
const Element& element,
const FVElementGeometry& fvGeometry,
const SubControlVolumeFace& scvf,
const ElementVolumeVariables& elemVolVars,
const ElementFaceVariables& elementFaceVars) const
......@@ -163,8 +165,7 @@ public:
const auto insideScvIdx = scvf.insideScvIdx();
const auto& insideVolVars = elemVolVars[insideScvIdx];
source += problem.gravity()[scvf.directionIndex()] * insideVolVars.density();
source += problem.sourceAtPos(scvf.center())[Indices::velocity(scvf.directionIndex())];
source += problem.source(element, fvGeometry, elemVolVars, elementFaceVars, scvf)[Indices::velocity(scvf.directionIndex())];
return source;
}
......
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