Commit 15129c16 authored by Thomas Fetzer's avatar Thomas Fetzer
Browse files

[rans] Fix ID vs. Idx confusion

parent cbc39ecb
......@@ -96,7 +96,7 @@ public:
for (const auto& element : elements(this->fvGridGeometry().gridView()))
{
unsigned int elementID = this->fvGridGeometry().elementMapper().index(element);
unsigned int elementIdx = this->fvGridGeometry().elementMapper().index(element);
auto fvGeometry = localView(this->fvGridGeometry());
fvGeometry.bindElement(element);
......@@ -107,26 +107,26 @@ public:
PrimaryVariables priVars = makePriVarsFromCellCenterPriVars<PrimaryVariables>(cellCenterPriVars);
auto elemSol = elementSolution<typename FVGridGeometry::LocalView>(std::move(priVars));
// NOTE: first update the turbulence quantities
storedViscosityTilde_[elementID] = elemSol[0][Indices::viscosityTildeIdx];
storedViscosityTilde_[elementIdx] = elemSol[0][Indices::viscosityTildeIdx];
// NOTE: then update the volVars
VolumeVariables volVars;
volVars.update(elemSol, asImp_(), element, scv);
storedDynamicEddyViscosity_[elementID] = volVars.calculateEddyViscosity();
storedDynamicEddyViscosity_[elementIdx] = volVars.calculateEddyViscosity();
}
}
// calculate cell-center-averaged velocity gradients, maximum, and minimum values
for (const auto& element : elements(this->fvGridGeometry().gridView()))
{
unsigned int elementID = this->fvGridGeometry().elementMapper().index(element);
unsigned int elementIdx = this->fvGridGeometry().elementMapper().index(element);
for (unsigned int dimIdx = 0; dimIdx < Grid::dimension; ++dimIdx)
{
storedViscosityTildeGradient_[elementID][dimIdx]
= (storedViscosityTilde_[ParentType::neighborID_[elementID][dimIdx][1]]
- storedViscosityTilde_[ParentType::neighborID_[elementID][dimIdx][0]])
/ (ParentType::cellCenter_[ParentType::neighborID_[elementID][dimIdx][1]][dimIdx]
- ParentType::cellCenter_[ParentType::neighborID_[elementID][dimIdx][0]][dimIdx]);
storedViscosityTildeGradient_[elementIdx][dimIdx]
= (storedViscosityTilde_[ParentType::neighborIdx_[elementIdx][dimIdx][1]]
- storedViscosityTilde_[ParentType::neighborIdx_[elementIdx][dimIdx][0]])
/ (ParentType::cellCenter_[ParentType::neighborIdx_[elementIdx][dimIdx][1]][dimIdx]
- ParentType::cellCenter_[ParentType::neighborIdx_[elementIdx][dimIdx][0]][dimIdx]);
}
auto fvGeometry = localView(this->fvGridGeometry());
......@@ -139,13 +139,13 @@ public:
// face Value
Scalar dirichletViscosityTilde = asImp_().dirichlet(element, scvf)[Indices::viscosityTildeIdx];
unsigned int neighborID = ParentType::neighborID_[elementID][normDim][0];
if (scvf.center()[normDim] < ParentType::cellCenter_[elementID][normDim])
neighborID = ParentType::neighborID_[elementID][normDim][1];
unsigned int neighborIdx = ParentType::neighborIdx_[elementIdx][normDim][0];
if (scvf.center()[normDim] < ParentType::cellCenter_[elementIdx][normDim])
neighborIdx = ParentType::neighborIdx_[elementIdx][normDim][1];
storedViscosityTildeGradient_[elementID][normDim]
= (storedViscosityTilde_[neighborID] - dirichletViscosityTilde)
/ (ParentType::cellCenter_[neighborID][normDim] - scvf.center()[normDim]);
storedViscosityTildeGradient_[elementIdx][normDim]
= (storedViscosityTilde_[neighborIdx] - dirichletViscosityTilde)
/ (ParentType::cellCenter_[neighborIdx][normDim] - scvf.center()[normDim]);
}
}
}
......
......@@ -86,12 +86,12 @@ public:
{
RANSParentType::updateRANSProperties(elemSol, problem, element, scv);
viscosityTilde_ = elemSol[0][Indices::viscosityTildeIdx];
storedViscosityTilde_ = problem.storedViscosityTilde_[RANSParentType::elementID()];
storedViscosityTildeGradient_ = problem.storedViscosityTildeGradient_[RANSParentType::elementID()];
stressTensorScalarProduct_ = problem.stressTensorScalarProduct_[RANSParentType::elementID()];
vorticityTensorScalarProduct_ = problem.vorticityTensorScalarProduct_[RANSParentType::elementID()];
storedViscosityTilde_ = problem.storedViscosityTilde_[RANSParentType::elementIdx()];
storedViscosityTildeGradient_ = problem.storedViscosityTildeGradient_[RANSParentType::elementIdx()];
stressTensorScalarProduct_ = problem.stressTensorScalarProduct_[RANSParentType::elementIdx()];
vorticityTensorScalarProduct_ = problem.vorticityTensorScalarProduct_[RANSParentType::elementIdx()];
if (problem.useStoredEddyViscosity_)
RANSParentType::setDynamicEddyViscosity_(problem.storedDynamicEddyViscosity_[RANSParentType::elementID()]);
RANSParentType::setDynamicEddyViscosity_(problem.storedDynamicEddyViscosity_[RANSParentType::elementIdx()]);
else
RANSParentType::setDynamicEddyViscosity_(calculateEddyViscosity());
RANSParentType::calculateEddyDiffusivity(problem);
......
......@@ -92,9 +92,9 @@ public:
calledUpdateStaticWallProperties = true;
// update size and initial values of the global vectors
wallElementID_.resize(this->fvGridGeometry().elementMapper().size());
wallElementIdx_.resize(this->fvGridGeometry().elementMapper().size());
wallDistance_.resize(this->fvGridGeometry().elementMapper().size(), std::numeric_limits<Scalar>::max());
neighborID_.resize(this->fvGridGeometry().elementMapper().size());
neighborIdx_.resize(this->fvGridGeometry().elementMapper().size());
cellCenter_.resize(this->fvGridGeometry().elementMapper().size(), GlobalPosition(0.0));
velocity_.resize(this->fvGridGeometry().elementMapper().size(), DimVector(0.0));
velocityMaximum_.resize(this->fvGridGeometry().elementMapper().size(), DimVector(0.0));
......@@ -141,8 +141,8 @@ public:
// search for shortest distance to wall for each element
for (const auto& element : elements(gridView))
{
unsigned int elementID = this->fvGridGeometry().elementMapper().index(element);
cellCenter_[elementID] = element.geometry().center();
unsigned int elementIdx = this->fvGridGeometry().elementMapper().index(element);
cellCenter_[elementIdx] = element.geometry().center();
for (unsigned int i = 0; i < wallPositions.size(); ++i)
{
static const int problemWallNormalAxis
......@@ -158,26 +158,26 @@ public:
GlobalPosition global = element.geometry().center();
global -= wallPositions[i];
// second and argument ensures to use only aligned elements
if (abs(global[searchAxis]) < wallDistance_[elementID]
if (abs(global[searchAxis]) < wallDistance_[elementIdx]
&& abs(global[searchAxis]) < global.two_norm() + 1e-8
&& abs(global[searchAxis]) > global.two_norm() - 1e-8)
{
wallDistance_[elementID] = abs(global[searchAxis]);
wallElementID_[elementID] = wallElements[i];
wallNormalAxis_[elementID] = searchAxis;
sandGrainRoughness_[elementID] = asImp_().sandGrainRoughnessAtPos(wallPositions[i]);
wallDistance_[elementIdx] = abs(global[searchAxis]);
wallElementIdx_[elementIdx] = wallElements[i];
wallNormalAxis_[elementIdx] = searchAxis;
sandGrainRoughness_[elementIdx] = asImp_().sandGrainRoughnessAtPos(wallPositions[i]);
}
}
}
// search for neighbor IDs
// search for neighbor Idxs
for (const auto& element : elements(gridView))
{
unsigned int elementID = this->fvGridGeometry().elementMapper().index(element);
unsigned int elementIdx = this->fvGridGeometry().elementMapper().index(element);
for (unsigned int dimIdx = 0; dimIdx < dim; ++dimIdx)
{
neighborID_[elementID][dimIdx][0] = elementID;
neighborID_[elementID][dimIdx][1] = elementID;
neighborIdx_[elementIdx][dimIdx][0] = elementIdx;
neighborIdx_[elementIdx][dimIdx][1] = elementIdx;
}
for (const auto& intersection : intersections(gridView, element))
......@@ -185,18 +185,18 @@ public:
if (intersection.boundary())
continue;
unsigned int neighborID = this->fvGridGeometry().elementMapper().index(intersection.outside());
unsigned int neighborIdx = this->fvGridGeometry().elementMapper().index(intersection.outside());
for (unsigned int dimIdx = 0; dimIdx < dim; ++dimIdx)
{
if (abs(cellCenter_[elementID][dimIdx] - cellCenter_[neighborID][dimIdx]) > 1e-8)
if (abs(cellCenter_[elementIdx][dimIdx] - cellCenter_[neighborIdx][dimIdx]) > 1e-8)
{
if (cellCenter_[elementID][dimIdx] > cellCenter_[neighborID][dimIdx])
if (cellCenter_[elementIdx][dimIdx] > cellCenter_[neighborIdx][dimIdx])
{
neighborID_[elementID][dimIdx][0] = neighborID;
neighborIdx_[elementIdx][dimIdx][0] = neighborIdx;
}
if (cellCenter_[elementID][dimIdx] < cellCenter_[neighborID][dimIdx])
if (cellCenter_[elementIdx][dimIdx] < cellCenter_[neighborIdx][dimIdx])
{
neighborID_[elementID][dimIdx][1] = neighborID;
neighborIdx_[elementIdx][dimIdx][1] = neighborIdx;
}
}
}
......@@ -235,7 +235,7 @@ public:
{
auto fvGeometry = localView(this->fvGridGeometry());
fvGeometry.bindElement(element);
unsigned int elementID = this->fvGridGeometry().elementMapper().index(element);
unsigned int elementIdx = this->fvGridGeometry().elementMapper().index(element);
// calculate velocities
DimVector velocityTemp(0.0);
......@@ -246,44 +246,44 @@ public:
velocityTemp[scvf.directionIndex()] += numericalSolutionFace;
}
for (unsigned int dimIdx = 0; dimIdx < dim; ++dimIdx)
velocity_[elementID][dimIdx] = velocityTemp[dimIdx] * 0.5; // faces are equidistant to cell center
velocity_[elementIdx][dimIdx] = velocityTemp[dimIdx] * 0.5; // faces are equidistant to cell center
}
// calculate cell-center-averaged velocity gradients, maximum, and minimum values
for (const auto& element : elements(this->fvGridGeometry().gridView()))
{
unsigned int elementID = this->fvGridGeometry().elementMapper().index(element);
unsigned int wallElementID = wallElementID_[elementID];
unsigned int elementIdx = this->fvGridGeometry().elementMapper().index(element);
unsigned int wallElementIdx = wallElementIdx_[elementIdx];
Scalar maxVelocity = 0.0;
for (unsigned int dimIdx = 0; dimIdx < dim; ++dimIdx)
{
for (unsigned int velIdx = 0; velIdx < dim; ++velIdx)
{
velocityGradients_[elementID][velIdx][dimIdx]
= (velocity_[neighborID_[elementID][dimIdx][1]][velIdx]
- velocity_[neighborID_[elementID][dimIdx][0]][velIdx])
/ (cellCenter_[neighborID_[elementID][dimIdx][1]][dimIdx]
- cellCenter_[neighborID_[elementID][dimIdx][0]][dimIdx]);
velocityGradients_[elementIdx][velIdx][dimIdx]
= (velocity_[neighborIdx_[elementIdx][dimIdx][1]][velIdx]
- velocity_[neighborIdx_[elementIdx][dimIdx][0]][velIdx])
/ (cellCenter_[neighborIdx_[elementIdx][dimIdx][1]][dimIdx]
- cellCenter_[neighborIdx_[elementIdx][dimIdx][0]][dimIdx]);
}
if (abs(velocity_[elementID][dimIdx]) > abs(velocityMaximum_[wallElementID][dimIdx]))
if (abs(velocity_[elementIdx][dimIdx]) > abs(velocityMaximum_[wallElementIdx][dimIdx]))
{
velocityMaximum_[wallElementID][dimIdx] = velocity_[elementID][dimIdx];
velocityMaximum_[wallElementIdx][dimIdx] = velocity_[elementIdx][dimIdx];
}
if (abs(velocity_[elementID][dimIdx]) < abs(velocityMinimum_[wallElementID][dimIdx]))
if (abs(velocity_[elementIdx][dimIdx]) < abs(velocityMinimum_[wallElementIdx][dimIdx]))
{
velocityMinimum_[wallElementID][dimIdx] = velocity_[elementID][dimIdx];
velocityMinimum_[wallElementIdx][dimIdx] = velocity_[elementIdx][dimIdx];
}
if (0 <= flowNormalAxis && flowNormalAxis < dim)
{
flowNormalAxis_[elementID] = flowNormalAxis;
flowNormalAxis_[elementIdx] = flowNormalAxis;
}
else if (abs(maxVelocity) < abs(velocity_[elementID][dimIdx]))
else if (abs(maxVelocity) < abs(velocity_[elementIdx][dimIdx]))
{
maxVelocity = abs(velocity_[elementID][dimIdx]);
flowNormalAxis_[elementID] = dimIdx;
maxVelocity = abs(velocity_[elementIdx][dimIdx]);
flowNormalAxis_[elementIdx] = dimIdx;
}
}
......@@ -302,13 +302,13 @@ public:
Scalar dirichletVelocity = asImp_().dirichlet(element, scvf)[Indices::velocity(velIdx)];
unsigned int neighborID = neighborID_[elementID][scvfNormDim][0];
if (scvf.center()[scvfNormDim] < cellCenter_[elementID][scvfNormDim])
neighborID = neighborID_[elementID][scvfNormDim][1];
unsigned int neighborIdx = neighborIdx_[elementIdx][scvfNormDim][0];
if (scvf.center()[scvfNormDim] < cellCenter_[elementIdx][scvfNormDim])
neighborIdx = neighborIdx_[elementIdx][scvfNormDim][1];
velocityGradients_[elementID][velIdx][scvfNormDim]
= (velocity_[neighborID][velIdx] - dirichletVelocity)
/ (cellCenter_[neighborID][scvfNormDim] - scvf.center()[scvfNormDim]);
velocityGradients_[elementIdx][velIdx][scvfNormDim]
= (velocity_[neighborIdx][velIdx] - dirichletVelocity)
/ (cellCenter_[neighborIdx][scvfNormDim] - scvf.center()[scvfNormDim]);
}
}
......@@ -327,14 +327,14 @@ public:
unsigned int normalNormDim = normalFace.directionIndex();
if (normalFace.boundary() && (asImp_().boundaryTypes(element, normalFace).isBJS(Indices::velocity(velIdx))))
{
unsigned int neighborID = neighborID_[elementID][normalNormDim][0];
if (normalFace.center()[normalNormDim] < cellCenter_[elementID][normalNormDim])
neighborID = neighborID_[elementID][normalNormDim][1];
bjsVelocityAverage[normalNormDim] += ParentType::bjsVelocity(scvf, normalFace, localSubFaceIdx, velocity_[elementID][velIdx]);
if (bjsNumFaces[normalNormDim] > 0 && neighborID != bjsNeighbor[normalNormDim])
DUNE_THROW(Dune::InvalidStateException, "Two different neighborID should not occur");
bjsNeighbor[normalNormDim] = neighborID;
unsigned int neighborIdx = neighborIdx_[elementIdx][normalNormDim][0];
if (normalFace.center()[normalNormDim] < cellCenter_[elementIdx][normalNormDim])
neighborIdx = neighborIdx_[elementIdx][normalNormDim][1];
bjsVelocityAverage[normalNormDim] += ParentType::bjsVelocity(scvf, normalFace, localSubFaceIdx, velocity_[elementIdx][velIdx]);
if (bjsNumFaces[normalNormDim] > 0 && neighborIdx != bjsNeighbor[normalNormDim])
DUNE_THROW(Dune::InvalidStateException, "Two different neighborIdx should not occur");
bjsNeighbor[normalNormDim] = neighborIdx;
normalNormCoordinate[normalNormDim] = normalFace.center()[normalNormDim];
bjsNumFaces[normalNormDim]++;
}
......@@ -344,12 +344,12 @@ public:
if (bjsNumFaces[dirIdx] == 0)
continue;
unsigned int neighborID = bjsNeighbor[dirIdx];
unsigned int neighborIdx = bjsNeighbor[dirIdx];
bjsVelocityAverage[dirIdx] /= bjsNumFaces[dirIdx];
velocityGradients_[elementID][velIdx][dirIdx]
= (velocity_[neighborID][velIdx] - bjsVelocityAverage[dirIdx])
/ (cellCenter_[neighborID][dirIdx] - normalNormCoordinate[dirIdx]);
velocityGradients_[elementIdx][velIdx][dirIdx]
= (velocity_[neighborIdx][velIdx] - bjsVelocityAverage[dirIdx])
/ (cellCenter_[neighborIdx][dirIdx] - normalNormCoordinate[dirIdx]);
}
}
......@@ -358,23 +358,23 @@ public:
// calculate or call all secondary variables
for (const auto& element : elements(this->fvGridGeometry().gridView()))
{
unsigned int elementID = this->fvGridGeometry().elementMapper().index(element);
unsigned int elementIdx = this->fvGridGeometry().elementMapper().index(element);
Dune::FieldMatrix<Scalar, GridView::dimension, GridView::dimension> stressTensor(0.0);
for (unsigned int dimIdx = 0; dimIdx < dim; ++dimIdx)
{
for (unsigned int velIdx = 0; velIdx < dim; ++velIdx)
{
stressTensor[dimIdx][velIdx] = 0.5 * velocityGradients_[elementID][dimIdx][velIdx]
+ 0.5 * velocityGradients_[elementID][velIdx][dimIdx];
stressTensor[dimIdx][velIdx] = 0.5 * velocityGradients_[elementIdx][dimIdx][velIdx]
+ 0.5 * velocityGradients_[elementIdx][velIdx][dimIdx];
}
}
stressTensorScalarProduct_[elementID] = 0.0;
stressTensorScalarProduct_[elementIdx] = 0.0;
for (unsigned int dimIdx = 0; dimIdx < dim; ++dimIdx)
{
for (unsigned int velIdx = 0; velIdx < dim; ++velIdx)
{
stressTensorScalarProduct_[elementID] += stressTensor[dimIdx][velIdx] * stressTensor[dimIdx][velIdx];
stressTensorScalarProduct_[elementIdx] += stressTensor[dimIdx][velIdx] * stressTensor[dimIdx][velIdx];
}
}
......@@ -383,16 +383,16 @@ public:
{
for (unsigned int velIdx = 0; velIdx < dim; ++velIdx)
{
vorticityTensor[dimIdx][velIdx] = 0.5 * velocityGradients_[elementID][dimIdx][velIdx]
- 0.5 * velocityGradients_[elementID][velIdx][dimIdx];
vorticityTensor[dimIdx][velIdx] = 0.5 * velocityGradients_[elementIdx][dimIdx][velIdx]
- 0.5 * velocityGradients_[elementIdx][velIdx][dimIdx];
}
}
vorticityTensorScalarProduct_[elementID] = 0.0;
vorticityTensorScalarProduct_[elementIdx] = 0.0;
for (unsigned int dimIdx = 0; dimIdx < dim; ++dimIdx)
{
for (unsigned int velIdx = 0; velIdx < dim; ++velIdx)
{
vorticityTensorScalarProduct_[elementID] += vorticityTensor[dimIdx][velIdx] * vorticityTensor[dimIdx][velIdx];
vorticityTensorScalarProduct_[elementIdx] += vorticityTensor[dimIdx][velIdx] * vorticityTensor[dimIdx][velIdx];
}
}
......@@ -409,7 +409,7 @@ public:
VolumeVariables volVars;
volVars.update(elemSol, asImp_(), element, scv);
kinematicViscosity_[elementID] = volVars.viscosity() / volVars.density();
kinematicViscosity_[elementIdx] = volVars.viscosity() / volVars.density();
}
}
}
......@@ -466,9 +466,9 @@ public:
public:
bool calledUpdateStaticWallProperties = false;
std::vector<unsigned int> wallElementID_;
std::vector<unsigned int> wallElementIdx_;
std::vector<Scalar> wallDistance_;
std::vector<std::array<std::array<unsigned int, 2>, dim>> neighborID_;
std::vector<std::array<std::array<unsigned int, 2>, dim>> neighborIdx_;
std::vector<GlobalPosition> cellCenter_;
std::vector<DimVector> velocity_;
std::vector<DimVector> velocityMaximum_;
......
......@@ -98,7 +98,7 @@ public:
ParentType::updateStaticWallProperties();
// update size and initial values of the global vectors
matchingPointID_.resize(this->fvGridGeometry().elementMapper().size(), 0);
matchingPointIdx_.resize(this->fvGridGeometry().elementMapper().size(), 0);
storedDensity_.resize(this->fvGridGeometry().elementMapper().size(), 0.0);
storedDissipation_.resize(this->fvGridGeometry().elementMapper().size(), 0.0);
storedTurbulentKineticEnergy_.resize(this->fvGridGeometry().elementMapper().size(), 0.0);
......@@ -118,7 +118,7 @@ public:
// update the stored eddy viscosities
for (const auto& element : elements(this->fvGridGeometry().gridView()))
{
unsigned int elementID = this->fvGridGeometry().elementMapper().index(element);
unsigned int elementIdx = this->fvGridGeometry().elementMapper().index(element);
auto fvGeometry = localView(this->fvGridGeometry());
fvGeometry.bindElement(element);
......@@ -129,13 +129,13 @@ public:
PrimaryVariables priVars = makePriVarsFromCellCenterPriVars<PrimaryVariables>(cellCenterPriVars);
auto elemSol = elementSolution<typename FVGridGeometry::LocalView>(std::move(priVars));
// NOTE: first update the turbulence quantities
storedDissipation_[elementID] = elemSol[0][Indices::dissipationEqIdx];
storedTurbulentKineticEnergy_[elementID] = elemSol[0][Indices::turbulentKineticEnergyEqIdx];
storedDissipation_[elementIdx] = elemSol[0][Indices::dissipationEqIdx];
storedTurbulentKineticEnergy_[elementIdx] = elemSol[0][Indices::turbulentKineticEnergyEqIdx];
// NOTE: then update the volVars
VolumeVariables volVars;
volVars.update(elemSol, asImp_(), element, scv);
storedDynamicEddyViscosity_[elementID] = volVars.calculateEddyViscosity();
storedDensity_[elementID] = volVars.density();
storedDynamicEddyViscosity_[elementIdx] = volVars.calculateEddyViscosity();
storedDensity_[elementIdx] = volVars.density();
}
}
......@@ -143,18 +143,18 @@ public:
unsigned int numElementsInNearWallRegion = 0;
for (const auto& element : elements(this->fvGridGeometry().gridView()))
{
unsigned int elementID = this->fvGridGeometry().elementMapper().index(element);
unsigned int wallNormalAxis = asImp_().wallNormalAxis_[elementID];
unsigned int neighborID0 = asImp_().neighborID_[elementID][wallNormalAxis][0];
unsigned int neighborID1 = asImp_().neighborID_[elementID][wallNormalAxis][1];
numElementsInNearWallRegion = inNearWallRegion(elementID)
unsigned int elementIdx = this->fvGridGeometry().elementMapper().index(element);
unsigned int wallNormalAxis = asImp_().wallNormalAxis_[elementIdx];
unsigned int neighborIdx0 = asImp_().neighborIdx_[elementIdx][wallNormalAxis][0];
unsigned int neighborIdx1 = asImp_().neighborIdx_[elementIdx][wallNormalAxis][1];
numElementsInNearWallRegion = inNearWallRegion(elementIdx)
? numElementsInNearWallRegion + 1
: numElementsInNearWallRegion + 0;
if ((!inNearWallRegion(elementID) && (inNearWallRegion(neighborID0) || inNearWallRegion(neighborID1)))
|| (!inNearWallRegion(elementID) && elementID == asImp_().wallElementID_[elementID])
|| (inNearWallRegion(elementID) && (asImp_().wallElementID_[neighborID0] != asImp_().wallElementID_[neighborID1])))
if ((!inNearWallRegion(elementIdx) && (inNearWallRegion(neighborIdx0) || inNearWallRegion(neighborIdx1)))
|| (!inNearWallRegion(elementIdx) && elementIdx == asImp_().wallElementIdx_[elementIdx])
|| (inNearWallRegion(elementIdx) && (asImp_().wallElementIdx_[neighborIdx0] != asImp_().wallElementIdx_[neighborIdx1])))
{
matchingPointID_[asImp_().wallElementID_[elementID]] = elementID;
matchingPointIdx_[asImp_().wallElementIdx_[elementIdx]] = elementIdx;
}
}
std::cout << "numElementsInNearWallRegion: " << numElementsInNearWallRegion << std::endl;
......@@ -162,8 +162,8 @@ public:
// calculate the potential zeroeq eddy viscosities for two-layer model
for (const auto& element : elements(this->fvGridGeometry().gridView()))
{
unsigned int elementID = this->fvGridGeometry().elementMapper().index(element);
zeroEqDynamicEddyViscosity_[elementID] = zeroEqEddyViscosityModel(elementID);
unsigned int elementIdx = this->fvGridGeometry().elementMapper().index(element);
zeroEqDynamicEddyViscosity_[elementIdx] = zeroEqEddyViscosityModel(elementIdx);
}
// then make them match at the matching point
......@@ -173,24 +173,24 @@ public:
{
for (const auto& element : elements(this->fvGridGeometry().gridView()))
{
unsigned int elementID = this->fvGridGeometry().elementMapper().index(element);
unsigned int matchingPointID = matchingPointID_[asImp_().wallElementID_[elementID]];
unsigned int elementIdx = this->fvGridGeometry().elementMapper().index(element);
unsigned int matchingPointIdx = matchingPointIdx_[asImp_().wallElementIdx_[elementIdx]];
Scalar scalingFactor = storedDynamicEddyViscosity_[matchingPointID]
/ zeroEqDynamicEddyViscosity_[matchingPointID];
if (!isMatchingPoint(elementID)
Scalar scalingFactor = storedDynamicEddyViscosity_[matchingPointIdx]
/ zeroEqDynamicEddyViscosity_[matchingPointIdx];
if (!isMatchingPoint(elementIdx)
&& !std::isnan(scalingFactor) && !std::isinf(scalingFactor))
{
zeroEqDynamicEddyViscosity_[elementID] *= scalingFactor;
zeroEqDynamicEddyViscosity_[elementIdx] *= scalingFactor;
}
}
for (const auto& element : elements(this->fvGridGeometry().gridView()))
{
unsigned int elementID = this->fvGridGeometry().elementMapper().index(element);
unsigned int matchingPointID = matchingPointID_[asImp_().wallElementID_[elementID]];
if (isMatchingPoint(elementID))
unsigned int elementIdx = this->fvGridGeometry().elementMapper().index(element);
unsigned int matchingPointIdx = matchingPointIdx_[asImp_().wallElementIdx_[elementIdx]];
if (isMatchingPoint(elementIdx))
{
zeroEqDynamicEddyViscosity_[matchingPointID] = storedDynamicEddyViscosity_[matchingPointID];
zeroEqDynamicEddyViscosity_[matchingPointIdx] = storedDynamicEddyViscosity_[matchingPointIdx];
}
}
}
......@@ -199,109 +199,109 @@ public:
/*!
* \brief Returns if an element is located in the near-wall region
*/
const bool inNearWallRegion(unsigned int elementID) const
const bool inNearWallRegion(unsigned int elementIdx) const
{
unsigned int wallElementID = asImp_().wallElementID_[elementID];
unsigned int matchingPointID = matchingPointID_[wallElementID];
return wallElementID == matchingPointID ? yPlusNominal(elementID) < yPlusThreshold_
: yPlus(elementID) < yPlusThreshold_;
unsigned int wallElementIdx = asImp_().wallElementIdx_[elementIdx];
unsigned int matchingPointIdx = matchingPointIdx_[wallElementIdx];
return wallElementIdx == matchingPointIdx ? yPlusNominal(elementIdx) < yPlusThreshold_
: yPlus(elementIdx) < yPlusThreshold_;
}
/*!
* \brief Returns if an element is the matching point
*/
const bool isMatchingPoint(unsigned int elementID) const
{ return matchingPointID_[asImp_().wallElementID_[elementID]] == elementID; }
const bool isMatchingPoint(unsigned int elementIdx) const
{ return matchingPointIdx_[asImp_().wallElementIdx_[elementIdx]] == elementIdx; }
/*!
* \brief Returns the \f$ y^+ \f$ value at an element center
*/
const Scalar yPlus(unsigned int elementID) const
const Scalar yPlus(unsigned int elementIdx) const
{
return asImp_().wallDistance_[elementID] * uStar(elementID)
/ asImp_().kinematicViscosity_[elementID];
return asImp_().wallDistance_[elementIdx] * uStar(elementIdx)
/ asImp_().kinematicViscosity_[elementIdx];
}
/*!
* \brief Returns the nominal \f$ y^+ \f$ value at an element center
*/
const Scalar yPlusNominal(unsigned int elementID) const
const Scalar yPlusNominal(unsigned int elementIdx) const
{
return asImp_().wallDistance_[elementID] * uStarNominal(elementID)
/ asImp_().kinematicViscosity_[elementID];
return asImp_().wallDistance_[elementIdx] * uStarNominal(elementIdx)
/ asImp_().kinematicViscosity_[elementIdx];
}
/*!
* \brief Returns the kinematic eddy viscosity of a 0-Eq. model
*/
const Scalar zeroEqEddyViscosityModel(unsigned int elementID) const
const Scalar zeroEqEddyViscosityModel(unsigned int elementIdx) const
{
using std::abs;
using std::exp;
using std::sqrt;
// use VanDriest's model
Scalar yPlusValue = yPlus(elementID);
Scalar yPlusValue = yPlus(elementIdx);
Scalar mixingLength = 0.0;
if (yPlusValue > 0.0)
{
mixingLength = asImp_().karmanConstant() * asImp_().wallDistance_[elementID]
mixingLength = asImp_().karmanConstant() * asImp_().wallDistance_[elementIdx]
* (1.0 - exp(-yPlusValue / 26.0 ))
/ sqrt(1.0 - exp(-0.26 * yPlusValue));
}
unsigned int wallNormalAxis = asImp_().wallNormalAxis_[elementID];
unsigned int flowNormalAxis = asImp_().flowNormalAxis_[elementID];
Scalar velocityGradient = asImp_().velocityGradients_[elementID][flowNormalAxis][wallNormalAxis];
return mixingLength * mixingLength * abs(velocityGradient) * storedDensity_[elementID];
unsigned int wallNormalAxis = asImp_().wallNormalAxis_[elementIdx];
unsigned int flowNormalAxis = asImp_().flowNormalAxis_[elementIdx];
Scalar velocityGradient = asImp_().velocityGradients_[elementIdx][flowNormalAxis][wallNormalAxis];
return mixingLength * mixingLength * abs(velocityGradient) * storedDensity_[elementIdx];
}
//! \brief Returns the wall shear stress velocity
const Scalar uStar(unsigned int elementID) const
const Scalar uStar(unsigned int elementIdx) const
{
using std::abs;
using std::sqrt;
unsigned int wallElementID = asImp_().wallElementID_[elementID];
unsigned int wallNormalAxis = asImp_().wallNormalAxis_[elementID];
unsigned int flowNormalAxis = asImp_().flowNormalAxis_[elementID];
return sqrt(asImp_().kinematicViscosity_[wallElementID]
* abs(asImp_().velocityGradients_[wallElementID][flowNormalAxis][wallNormalAxis]));
unsigned int wallElementIdx = asImp_().wallElementIdx_[elementIdx];