Commit b06ff786 authored by Thomas Fetzer's avatar Thomas Fetzer
Browse files

[freeflow] Remove the atPos functions on the model level

parent f993e36b
......@@ -72,6 +72,7 @@ class FVProblem
using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
static constexpr bool isBox = GET_PROP_TYPE(TypeTag, FVGridGeometry)::discMethod == DiscretizationMethod::box;
static constexpr bool isStaggered = GET_PROP_TYPE(TypeTag, FVGridGeometry)::discMethod == DiscretizationMethod::staggered;
using PointSourceMap = std::map<std::pair<std::size_t, std::size_t>,
std::vector<PointSource> >;
......@@ -206,9 +207,9 @@ public:
PrimaryVariables dirichlet(const Element &element, const SubControlVolume &scv) const
{
// forward it to the method which only takes the global coordinate
if (!isBox)
if (!isBox && !isStaggered)
{
DUNE_THROW(Dune::InvalidStateException, "dirichlet(scv) called for cell-centered method.");
DUNE_THROW(Dune::InvalidStateException, "dirichlet(scv) called for other than box or staggered method.");
}
else
return asImp_().dirichletAtPos(scv.dofPosition());
......
......@@ -130,20 +130,6 @@ public:
return asImp_().neumannAtPos(scvf.ipGlobal());
}
/*!
* \brief Evaluate the initial value for a control volume.
*
* \param globalPos The global position
*/
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
{
// Throw an exception (there is no reasonable default value
// for initial values)
DUNE_THROW(Dune::InvalidStateException,
"The problem does not provide "
"an initial() or an initialAtPos() method.");
}
/*!
* \brief Evaluate the initial value for an element (for cell-centered primary variables)
* or face (for velocities)
......
......@@ -85,7 +85,7 @@ public:
bool isOutflow = false;
if(scvf.boundary())
{
const auto bcTypes = problem.boundaryTypesAtPos(scvf.center());
const auto bcTypes = problem.boundaryTypes(element, scvf);
if(bcTypes.isOutflow(eqIdx))
isOutflow = true;
}
......
......@@ -46,6 +46,9 @@ class FreeflowNCResidualImpl<TypeTag, DiscretizationMethod::staggered>
using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry);
using GridView = typename FVGridGeometry::GridView;
using Element = typename GridView::template Codim<0>::Entity;
using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry)::LocalView;
using SubControlVolume = typename FVElementGeometry::SubControlVolume;
using CellCenterPrimaryVariables = typename GET_PROP_TYPE(TypeTag, CellCenterPrimaryVariables);
......@@ -103,11 +106,12 @@ public:
template<class ElementVolumeVariables, class BoundaryTypes>
void setFixedCell(CellCenterResidual& residual,
const Problem& problem,
const Element& element,
const SubControlVolume& insideScv,
const ElementVolumeVariables& elemVolVars,
const BoundaryTypes& bcTypes) const
{
ParentType::setFixedCell(residual, problem, insideScv, elemVolVars, bcTypes);
ParentType::setFixedCell(residual, problem, element, insideScv, elemVolVars, bcTypes);
for (int compIdx = 0; compIdx < numComponents; ++compIdx)
{
......@@ -119,7 +123,7 @@ public:
{
const auto& insideVolVars = elemVolVars[insideScv];
const Scalar massOrMoleFraction = useMoles ? insideVolVars.moleFraction(compIdx) : insideVolVars.massFraction(compIdx);
residual[eqIdx - cellCenterOffset] = massOrMoleFraction - problem.dirichletAtPos(insideScv.center())[eqIdx];
residual[eqIdx - cellCenterOffset] = massOrMoleFraction - problem.dirichlet(element, insideScv)[eqIdx];
}
}
......
......@@ -145,7 +145,7 @@ public:
// Check if we are on an outflow boundary.
const bool isOutflow = scvf.boundary()
? problem.boundaryTypesAtPos(scvf.center()).isOutflow(Indices::conti0EqIdx)
? problem.boundaryTypes(element, scvf).isOutflow(Indices::conti0EqIdx)
: false;
// Call the generic flux function.
......@@ -242,9 +242,10 @@ public:
// The pressure term.
// If specified, the pressure can be normalized using the initial value on the scfv of interest.
// The scvf is used to normalize by the same value from the left and right side.
// Can potentially help to improve the condition number of the system matrix.
const Scalar pressure = normalizePressure ?
insideVolVars.pressure() - problem.initialAtPos(scvf.center())[Indices::pressureIdx]
insideVolVars.pressure() - problem.initial(scvf)[Indices::pressureIdx]
: insideVolVars.pressure();
// Account for the orientation of the staggered face's normal outer normal vector
......@@ -254,7 +255,7 @@ public:
// Treat outflow conditions.
if(scvf.boundary())
{
if(problem.boundaryTypesAtPos(scvf.center()).isOutflow(Indices::velocity(scvf.directionIndex())))
if(problem.boundaryTypes(element, scvf).isOutflow(Indices::velocity(scvf.directionIndex())))
{
// Treat the staggered half-volume adjacent to the boundary as if it was on the opposite side of the boundary.
// The respective face's outer normal vector will point in the same direction as the scvf's one.
......@@ -559,10 +560,10 @@ private:
outflow += velocitySelf * velocitySelf * upVolVars.density();
}
// Apply a pressure at the boudary.
// Apply a pressure at the boundary.
const Scalar boundaryPressure = normalizePressure
? (problem.dirichlet(element, scvf)[Indices::pressureIdx] -
problem.initialAtPos(scvf.center())[Indices::pressureIdx])
problem.initial(scvf)[Indices::pressureIdx])
: problem.dirichlet(element, scvf)[Indices::pressureIdx];
outflow += boundaryPressure;
......
......@@ -189,6 +189,7 @@ public:
template<class BoundaryTypes>
void setFixedCell(CellCenterResidual& residual,
const Problem& problem,
const Element& element,
const SubControlVolume& insideScv,
const ElementVolumeVariables& elemVolVars,
const BoundaryTypes& bcTypes) const
......@@ -197,7 +198,7 @@ public:
if(bcTypes.isDirichletCell(Indices::conti0EqIdx))
{
const auto& insideVolVars = elemVolVars[insideScv];
residual[Indices::conti0EqIdx - cellCenterOffset] = insideVolVars.pressure() - problem.dirichletAtPos(insideScv.center())[Indices::pressureIdx];
residual[Indices::conti0EqIdx - cellCenterOffset] = insideVolVars.pressure() - problem.dirichlet(element, insideScv)[Indices::pressureIdx];
}
}
......@@ -248,7 +249,7 @@ protected:
// if specified, set a fixed value at the center of a cell at the boundary
const auto& scv = fvGeometry.scv(scvf.insideScvIdx());
asImp_().setFixedCell(residual, problem, scv, elemVolVars, bcTypes);
asImp_().setFixedCell(residual, problem, element, scv, elemVolVars, bcTypes);
}
}
}
......
......@@ -111,7 +111,7 @@ public:
bool isOutflow = false;
if(scvf.boundary())
{
const auto bcTypes = problem.boundaryTypesAtPos(scvf.center());
const auto bcTypes = problem.boundaryTypes(element, scvf);
if(bcTypes.isOutflow(Indices::energyBalanceIdx))
isOutflow = true;
}
......
......@@ -93,7 +93,7 @@ public:
elemVolVars, elemFaceVars, scvf, fluxVarsCache);
// calculate advective flux
const auto bcTypes = problem.boundaryTypesAtPos(scvf.center());
const auto bcTypes = problem.boundaryTypes(element, scvf);
const bool isOutflowK = scvf.boundary() && bcTypes.isOutflow(turbulentKineticEnergyEqIdx);
const bool isOutflowEpsilon = scvf.boundary() && bcTypes.isOutflow(dissipationEqIdx);
auto upwindTermK = [](const auto& volVars)
......
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