24#ifndef DUMUX_ZEROEQ_PROBLEM_HH
25#define DUMUX_ZEROEQ_PROBLEM_HH
48template<
class TypeTag>
54 using Grid =
typename GridView::Grid;
59 using SubControlVolumeFace =
typename FVElementGeometry::SubControlVolumeFace;
67 dim = Grid::dimension,
69 using DimVector = Dune::FieldVector<Scalar, dim>;
70 using DimMatrix = Dune::FieldMatrix<Scalar, dim, dim>;
78 RANSProblemImpl(std::shared_ptr<const GridGeometry> gridGeometry,
const std::string& paramGroup =
"")
79 : ParentType(gridGeometry, paramGroup)
108 bool printedRangeWarning =
false;
109 for (
const auto& element : elements(this->gridGeometry().gridView()))
111 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
113 auto fvGeometry =
localView(this->gridGeometry());
114 fvGeometry.bindElement(element);
115 for (
auto&& scv : scvs(fvGeometry))
120 const int dofIdx = scv.dofIndex();
123 const auto& cellCenterPriVars = curSol[GridGeometry::cellCenterIdx()][dofIdx];
127 VolumeVariables volVars;
128 volVars.update(elemSol, asImp_(), element, scv);
130 Scalar ksPlus = this->
sandGrainRoughness_[elementIdx] * volVars.uStar() / volVars.kinematicViscosity();
133 DUNE_THROW(Dune::NotImplemented,
"Roughness is not implemented for the Baldwin-Lomax model.");
137 std::cout <<
"info: equivalent sand grain roughness ks+=" << ksPlus <<
" at " << this->
cellCenter_[this->
wallElementIdx_[elementIdx]]
138 <<
" is not in the valid range (ksPlus < 2000),"
139 <<
" for high ksPlus values the roughness function reaches a turning point."<< std::endl;
140 DUNE_THROW(Dune::InvalidStateException,
"Unphysical roughness behavior.");
142 else if (ksPlus > 0.0 && ksPlus < 4.535 && !printedRangeWarning)
144 Dune::dinfo <<
"info: equivalent sand grain roughness ks+=" << ksPlus <<
" at " << this->
cellCenter_[this->
wallElementIdx_[elementIdx]]
145 <<
" is not in the valid range (ksPlus > 4.535) and now set to 0.0"<< std::endl;
147 printedRangeWarning =
true;
150 * (sqrt(ksPlus) - ksPlus * exp(-ksPlus / 6.0));
164 std::vector<Scalar> kinematicEddyViscosityInner(this->gridGeometry().elementMapper().size(), 0.0);
165 std::vector<Scalar> kinematicEddyViscosityOuter(this->gridGeometry().elementMapper().size(), 0.0);
166 std::vector<Scalar> kinematicEddyViscosityDifference(this->gridGeometry().elementMapper().size(), 0.0);
167 std::vector<Scalar> switchingPosition(this->gridGeometry().elementMapper().size(), std::numeric_limits<Scalar>::max());
174 const Scalar aPlus = 26.0;
175 const Scalar k = 0.0168;
176 const Scalar cCP = 1.6;
177 const Scalar cWake = 0.25;
178 const Scalar cKleb = 0.3;
180 std::vector<Scalar> storedFMax;
181 std::vector<Scalar> storedYFMax;
182 storedFMax.resize(this->gridGeometry().elementMapper().size(), 0.0);
183 storedYFMax.resize(this->gridGeometry().elementMapper().size(), 0.0);
186 for (
const auto& element : elements(this->gridGeometry().gridView()))
188 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
194 Scalar omegaAbs = abs(this->
velocityGradients_[elementIdx][flowNormalAxis][wallNormalAxis]
199 Scalar mixingLength = this->
karmanConstant() * wallDistance * (1.0 - exp(-yPlus / aPlus));
200 kinematicEddyViscosityInner[elementIdx] = mixingLength * mixingLength * omegaAbs;
202 Scalar f = wallDistance * omegaAbs * (1.0 - exp(-yPlus / aPlus));
203 if (f > storedFMax[wallElementIdx])
205 storedFMax[wallElementIdx] = f;
206 storedYFMax[wallElementIdx] = wallDistance;
211 for (
const auto& element : elements(this->gridGeometry().gridView()))
213 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
217 Scalar maxVelocityNorm = 0.0;
218 Scalar minVelocityNorm = 0.0;
219 for (
unsigned dimIdx = 0; dimIdx < dim; ++dimIdx)
226 Scalar deltaU = sqrt(maxVelocityNorm) - sqrt(minVelocityNorm);
227 Scalar yFMax = storedYFMax[wallElementIdx];
228 Scalar fMax = storedFMax[wallElementIdx];
229 Scalar fWake = min(yFMax * fMax, cWake * yFMax * deltaU * deltaU / fMax);
230 Scalar fKleb = 1.0 / (1.0 + 5.5 * pow(cKleb * wallDistance / yFMax, 6.0));
231 kinematicEddyViscosityOuter[elementIdx] = k * cCP * fWake * fKleb;
233 kinematicEddyViscosityDifference[elementIdx]
234 = kinematicEddyViscosityInner[elementIdx] - kinematicEddyViscosityOuter[elementIdx];
238 for (
const auto& element : elements(this->gridGeometry().gridView()))
240 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
245 Scalar check = kinematicEddyViscosityDifference[wallElementIdx] * kinematicEddyViscosityDifference[elementIdx];
247 && switchingPosition[wallElementIdx] > wallDistance)
249 switchingPosition[wallElementIdx] = wallDistance;
254 for (
const auto& element : elements(this->gridGeometry().gridView()))
256 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
261 if (wallDistance >= switchingPosition[wallElementIdx])
275 Implementation &asImp_()
276 {
return *
static_cast<Implementation *
>(
this); }
279 const Implementation &asImp_()
const
280 {
return *
static_cast<const Implementation *
>(
this); }
Base class for all staggered fv problems.
Free function to get the local view of a grid cache object.
The available discretization methods in Dumux.
The available free flow turbulence models in Dumux.
TurbulenceModel
The available free flow turbulence models in Dumux.
Definition turbulencemodel.hh:37
@ zeroeq
Definition turbulencemodel.hh:38
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition localview.hh:38
auto elementSolution(const Element &element, const SolutionVector &sol, const GridGeometry &gg) -> std::enable_if_t< GridGeometry::discMethod==DiscretizationMethod::box, BoxElementSolution< typename GridGeometry::LocalView, std::decay_t< decltype(std::declval< SolutionVector >()[0])> > >
Make an element solution for box schemes.
Definition box/elementsolution.hh:115
PrimaryVariables makePriVarsFromCellCenterPriVars(const CellCenterPrimaryVariables &cellCenterPriVars)
Helper function to create a PrimaryVariables object from CellCenterPrimaryVariables.
Definition staggered/elementsolution.hh:41
T getParamFromGroup(Args &&... args)
A free function to get a parameter from the parameter tree singleton with a model group.
Definition parameters.hh:375
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition propertysystem.hh:149
void updateDynamicWallProperties(const SolutionVector &curSol)
Update the dynamic (solution dependent) relations to the walls.
Definition freeflow/rans/problem.hh:225
std::vector< DimVector > velocityMinimum_
Definition freeflow/rans/problem.hh:539
void updateStaticWallProperties()
Update the static (solution independent) relations to the walls.
Definition freeflow/rans/problem.hh:98
std::vector< DimMatrix > velocityGradients_
Definition freeflow/rans/problem.hh:540
std::vector< GlobalPosition > cellCenter_
Definition freeflow/rans/problem.hh:536
std::vector< DimVector > velocityMaximum_
Definition freeflow/rans/problem.hh:538
std::vector< Scalar > sandGrainRoughness_
Definition freeflow/rans/problem.hh:546
std::vector< Scalar > kinematicViscosity_
Definition freeflow/rans/problem.hh:545
std::vector< unsigned int > wallNormalAxis_
Definition freeflow/rans/problem.hh:543
std::vector< Scalar > wallDistance_
Definition freeflow/rans/problem.hh:534
RANSProblemBase(std::shared_ptr< const GridGeometry > gridGeometry, const std::string ¶mGroup="")
The constructor.
Definition freeflow/rans/problem.hh:88
const Scalar karmanConstant() const
Returns the Karman constant.
Definition freeflow/rans/problem.hh:500
std::vector< unsigned int > wallElementIdx_
Definition freeflow/rans/problem.hh:533
std::vector< unsigned int > flowNormalAxis_
Definition freeflow/rans/problem.hh:544
std::vector< Scalar > additionalRoughnessLength_
Definition freeflow/rans/zeroeq/problem.hh:271
RANSProblemImpl(std::shared_ptr< const GridGeometry > gridGeometry, const std::string ¶mGroup="")
The constructor.
Definition freeflow/rans/zeroeq/problem.hh:78
std::string eddyViscosityModel_
Definition freeflow/rans/zeroeq/problem.hh:269
void updateStaticWallProperties()
Correct size of the static (solution independent) wall variables.
Definition freeflow/rans/zeroeq/problem.hh:87
std::vector< Scalar > kinematicEddyViscosity_
Definition freeflow/rans/zeroeq/problem.hh:270
void updateDynamicWallProperties(const SolutionVector &curSol)
Update the dynamic (solution dependent) relations to the walls.
Definition freeflow/rans/zeroeq/problem.hh:103
void updateBaldwinLomaxProperties()
Update the relations and coefficients for the Baldwin-Lomax turbulence model.
Definition freeflow/rans/zeroeq/problem.hh:162
Declares all properties used in Dumux.
A single-phase, isothermal Reynolds-Averaged Navier-Stokes 0-Eq. model.
The local element solution class for staggered methods.
the turbulence-model-specfic RANS problem