24#ifndef DUMUX_RANS_NC_TEST_PROBLEM_HH
25#define DUMUX_RANS_NC_TEST_PROBLEM_HH
27#include <dune/grid/yaspgrid.hh>
52template <
class TypeTag>
53class FlatPlateNCTestProblem;
76template<
class TypeTag>
80 static constexpr auto phaseIdx = H2OAir::gasPhaseIdx;
85template<
class TypeTag>
86struct ReplaceCompEqIdx<TypeTag, TTag::RANSNCModel> {
static constexpr int value = 0; };
89template<
class TypeTag>
90struct Grid<TypeTag, TTag::RANSNCModel>
91{
using type = Dune::YaspGrid<2, Dune::TensorProductCoordinates<GetPropType<TypeTag, Properties::Scalar>, 2> >; };
94template<
class TypeTag>
97template<
class TypeTag>
99template<
class TypeTag>
101template<
class TypeTag>
104template<
class TypeTag>
105struct UseMoles<TypeTag, TTag::RANSNCModel> {
static constexpr bool value =
true; };
117template <
class TypeTag>
132 using Element =
typename GridGeometry::GridView::template Codim<0>::Entity;
133 using GlobalPosition =
typename Element::Geometry::GlobalCoordinate;
135 using SubControlVolume =
typename FVElementGeometry::SubControlVolume;
136 using SubControlVolumeFace =
typename FVElementGeometry::SubControlVolumeFace;
138 using TimeLoopPtr = std::shared_ptr<CheckPointTimeLoop<Scalar>>;
141 static constexpr auto transportEqIdx = Indices::conti0EqIdx + 1;
142 static constexpr auto transportCompIdx = Indices::conti0EqIdx + 1;
148 inletVelocity_ = getParam<Scalar>(
"Problem.InletVelocity", 0.1);
149 inletTemperature_ = getParam<Scalar>(
"Problem.InletTemperature", 283.15);
150 wallTemperature_ = getParam<Scalar>(
"Problem.WallTemperature", 313.15);
151 inletMoleFraction_ = getParam<Scalar>(
"Problem.InletMoleFraction", 1e-3);
155 FluidState fluidState;
156 const auto phaseIdx = 0;
157 fluidState.setPressure(phaseIdx, 1e5);
159 fluidState.setMassFraction(phaseIdx, phaseIdx, 1.0);
162 Scalar
diameter = this->gridGeometry().bBoxMax()[1] - this->gridGeometry().bBoxMin()[1];
163 viscosityTilde_ = 1e-3 * turbulenceProperties.
viscosityTilde(inletVelocity_,
diameter, kinematicViscosity);
168 dissipation_ = turbulenceProperties.
dissipation(inletVelocity_,
diameter, kinematicViscosity);
170 std::cout <<
"Using the "<< turbulenceModelName_ <<
" Turbulence Model. \n";
171 std::cout << std::endl;
181 return globalPos[1] < eps_;
196 {
return 273.15 + 10; }
206 return NumEqVector(0.0);
223 BoundaryTypes values;
226 static constexpr auto numEq =
numTurbulenceEq(ModelTraits::turbulenceModel());
227 setBcTypes_(values, globalPos, Dune::index_constant<numEq>{});
229 if(isInlet_(globalPos))
231 values.setDirichlet(Indices::velocityXIdx);
232 values.setDirichlet(Indices::velocityYIdx);
233 values.setDirichlet(transportCompIdx);
235 values.setDirichlet(Indices::temperatureIdx);
238 else if(isOutlet_(globalPos))
240 values.setDirichlet(Indices::pressureIdx);
241 values.setOutflow(transportEqIdx);
243 values.setOutflow(Indices::energyEqIdx);
248 values.setDirichlet(Indices::velocityXIdx);
249 values.setDirichlet(Indices::velocityYIdx);
250 values.setNeumann(transportEqIdx);
252 values.setDirichlet(Indices::temperatureIdx);
256 values.setAllSymmetry();
269 template<
class Element,
class FVElementGeometry,
class SubControlVolume>
271 const FVElementGeometry& fvGeometry,
272 const SubControlVolume& scv,
275 using IsKOmegaKEpsilon = std::integral_constant<bool, (ModelTraits::turbulenceModel() ==
TurbulenceModel::komega
277 return isDirichletCell_(element, fvGeometry, scv, pvIdx, IsKOmegaKEpsilon{});
287 PrimaryVariables
dirichlet(
const Element& element,
const SubControlVolumeFace& scvf)
const
289 const auto globalPos = scvf.ipGlobal();
292 if (isInlet_(globalPos)
293 && globalPos[1] > 0.4 * this->gridGeometry().bBoxMax()[1]
294 && globalPos[1] < 0.6 * this->gridGeometry().bBoxMax()[1])
296 values[transportCompIdx] = (
time() > 10.0) ? inletMoleFraction_ : 0.0;
302 values[Indices::temperatureIdx] = wallTemperature_;
318 std::enable_if_t<!enable, int> = 0>
319 PrimaryVariables
dirichlet(
const Element& element,
const SubControlVolume& scv)
const
321 const auto globalPos = scv.center();
335 std::enable_if_t<enable, int> = 0>
336 PrimaryVariables
dirichlet(
const Element& element,
const SubControlVolume& scv)
const
338 using SetDirichletCellForBothTurbEq = std::integral_constant<bool, (ModelTraits::turbulenceModel() ==
TurbulenceModel::kepsilon)>;
340 return dirichletTurbulentTwoEq_(element, scv, SetDirichletCellForBothTurbEq{});
350 PrimaryVariables values(0.0);
351 values[Indices::pressureIdx] = 1.0e+5;
352 values[transportCompIdx] = 0.0;
358 values[Indices::velocityXIdx] = 0.0;
360 values[Indices::velocityXIdx] = inletVelocity_;
361 values[Indices::velocityYIdx] = 0.0;
364 static constexpr auto numEq =
numTurbulenceEq(ModelTraits::turbulenceModel());
365 setInitialAtPos_(values, globalPos, Dune::index_constant<numEq>{});
374 timeLoop_ = timeLoop;
379 return timeLoop_->time();
383 bool isInlet_(
const GlobalPosition& globalPos)
const
385 return globalPos[0] < eps_;
388 bool isOutlet_(
const GlobalPosition& globalPos)
const
390 return globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_;
394 void setInitialAtPos_(PrimaryVariables& values,
const GlobalPosition &globalPos, Dune::index_constant<0>)
const {}
397 void setInitialAtPos_(PrimaryVariables& values,
const GlobalPosition &globalPos, Dune::index_constant<1>)
const
399 values[Indices::viscosityTildeIdx] = viscosityTilde_;
401 values[Indices::viscosityTildeIdx] = 0.0;
405 void setInitialAtPos_(PrimaryVariables& values,
const GlobalPosition &globalPos, Dune::index_constant<2>)
const
407 values[Indices::turbulentKineticEnergyIdx] = turbulentKineticEnergy_;
408 values[Indices::dissipationIdx] = dissipation_;
411 values[Indices::turbulentKineticEnergyIdx] = 0.0;
412 values[Indices::dissipationIdx] = 0.0;
417 void setBcTypes_(BoundaryTypes& values,
const GlobalPosition& pos, Dune::index_constant<0>)
const {}
420 void setBcTypes_(BoundaryTypes& values,
const GlobalPosition& pos, Dune::index_constant<1>)
const
423 values.setOutflow(Indices::viscosityTildeIdx);
425 values.setDirichlet(Indices::viscosityTildeIdx);
429 void setBcTypes_(BoundaryTypes& values,
const GlobalPosition& pos, Dune::index_constant<2>)
const
433 values.setOutflow(Indices::turbulentKineticEnergyEqIdx);
434 values.setOutflow(Indices::dissipationEqIdx);
439 values.setDirichlet(Indices::turbulentKineticEnergyIdx);
440 values.setDirichlet(Indices::dissipationIdx);
445 template<
class Element,
class FVElementGeometry,
class SubControlVolume>
446 bool isDirichletCell_(
const Element& element,
447 const FVElementGeometry& fvGeometry,
448 const SubControlVolume& scv,
450 std::false_type)
const
452 return ParentType::isDirichletCell(element, fvGeometry, scv, pvIdx);
456 template<
class Element,
class FVElementGeometry,
class SubControlVolume>
457 bool isDirichletCell_(
const Element& element,
458 const FVElementGeometry& fvGeometry,
459 const SubControlVolume& scv,
461 std::true_type)
const
463 using SetDirichletCellForBothTurbEq = std::integral_constant<bool, (ModelTraits::turbulenceModel() ==
TurbulenceModel::kepsilon)>;
464 return isDirichletCellTurbulentTwoEq_(element, fvGeometry, scv, pvIdx, SetDirichletCellForBothTurbEq{});
468 template<
class Element>
469 bool isDirichletCellTurbulentTwoEq_(
const Element& element,
470 const FVElementGeometry& fvGeometry,
471 const SubControlVolume& scv,
473 std::true_type)
const
475 const auto eIdx = this->gridGeometry().elementMapper().index(element);
478 if (this->inNearWallRegion(eIdx))
479 return pvIdx == Indices::turbulentKineticEnergyEqIdx || pvIdx == Indices::dissipationEqIdx;
482 if (this->isMatchingPoint(eIdx))
483 return pvIdx == Indices::dissipationEqIdx;
489 template<
class Element>
490 bool isDirichletCellTurbulentTwoEq_(
const Element& element,
491 const FVElementGeometry& fvGeometry,
492 const SubControlVolume& scv,
494 std::false_type)
const
497 for (
const auto& scvf : scvfs(fvGeometry))
498 if (
isOnWallAtPos(scvf.center()) && pvIdx == Indices::dissipationIdx)
506 template<
class Element,
class SubControlVolume>
507 PrimaryVariables dirichletTurbulentTwoEq_(
const Element& element,
508 const SubControlVolume& scv,
509 std::true_type)
const
511 const auto globalPos = scv.center();
513 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
516 values[Indices::turbulentKineticEnergyEqIdx] = this->turbulentKineticEnergyWallFunction(elementIdx);
519 values[Indices::dissipationEqIdx] = this->dissipationWallFunction(elementIdx);
525 template<
class Element,
class SubControlVolume>
526 PrimaryVariables dirichletTurbulentTwoEq_(
const Element& element,
527 const SubControlVolume& scv,
528 std::false_type)
const
530 const auto globalPos = scv.center();
532 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
534 const auto wallDistance = ParentType::wallDistance_[elementIdx];
536 values[Indices::dissipationEqIdx] = 6.0 * ParentType::kinematicViscosity_[elementIdx]
537 / (ParentType::betaOmega() * pow(wallDistance, 2));
542 Scalar inletVelocity_;
543 Scalar inletMoleFraction_;
544 Scalar inletTemperature_;
545 Scalar wallTemperature_;
546 Scalar viscosityTilde_;
547 Scalar turbulentKineticEnergy_;
549 TimeLoopPtr timeLoop_;
550 std::string turbulenceModelName_;
A single-phase, multi-component k-epsilon model.
A single-phase, multi-component k-omega model.
A single-phase, multi-component low-Re k-epsilon model.
A single-phase, multi-component one-equation model.
A single-phase, multi-component Reynolds-Averaged Navier-Stokes 0-Eq. model.
This file contains different functions for estimating turbulence properties.
An adapter for multi-phase fluid systems to be used with (compositional) one-phase models.
A compositional two-phase fluid system with water and air as components in both, the liquid and the g...
Geometry::ctype diameter(const Geometry &geo)
Computes the longest distance between points of a geometry.
Definition: diameter.hh:36
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
std::string turbulenceModelToString(TurbulenceModel turbulenceModel)
return the name of the Turbulence Model
Definition: turbulencemodel.hh:54
constexpr unsigned int numTurbulenceEq(TurbulenceModel model)
Definition: turbulencemodel.hh:41
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
std::string viscosity(int phaseIdx) noexcept
I/O name of viscosity for multiphase systems.
Definition: name.hh:74
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:65
The DUNE grid type.
Definition: common/properties.hh:57
Property to specify the type of a problem which has to be solved.
Definition: common/properties.hh:69
Property whether to use moles or kg as amount unit for balance equations.
Definition: common/properties.hh:102
The component balance index that should be replaced by the total mass/mole balance.
Definition: common/properties.hh:104
Definition: common/properties.hh:169
If disabled, the volume variables are not stored (reduces memory, but is slower)
Definition: common/properties.hh:178
specifies if data on flux vars should be saved (faster, but more memory consuming)
Definition: common/properties.hh:188
The type of the fluid system to use.
Definition: common/properties.hh:223
forward declare
Definition: dumux/freeflow/rans/problem.hh:41
This class contains different functions for estimating turbulence properties.
Definition: turbulenceproperties.hh:39
Scalar viscosityTilde(const Scalar velocity, const Scalar diameter, const Scalar kinematicViscosity, bool print=verbose) const
Estimates the viscosity tilde based on a formula given in in the ANSYS Fluent user guide .
Definition: turbulenceproperties.hh:205
Scalar turbulentKineticEnergy(const Scalar velocity, const Scalar diameter, const Scalar kinematicViscosity, bool print=verbose) const
Estimates the turbulent kinetic energy based on a formula given in the ANSYS Fluent user guide .
Definition: turbulenceproperties.hh:143
Scalar dissipationRate(const Scalar velocity, const Scalar diameter, const Scalar kinematicViscosity, bool print=verbose) const
Estimates the dissipation rate based on a formula given in the ANSYS Fluent user guide .
Definition: turbulenceproperties.hh:183
Scalar dissipation(const Scalar velocity, const Scalar diameter, const Scalar kinematicViscosity, bool print=verbose) const
Estimates the dissipation based on a formula given in the ANSYS Fluent user guide .
Definition: turbulenceproperties.hh:162
An adapter for multi-phase fluid systems to be used with (compositional) one-phase models.
Definition: 1padapter.hh:46
A compositional two-phase fluid system with water and air as components in both, the liquid and the g...
Definition: h2oair.hh:75
Test problem for the one-phase model.
Definition: test/freeflow/ransnc/problem.hh:119
Scalar temperature() const
Returns the temperature within the domain in [K].
Definition: test/freeflow/ransnc/problem.hh:195
NumEqVector sourceAtPos(const GlobalPosition &globalPos) const
Returns the sources within the domain.
Definition: test/freeflow/ransnc/problem.hh:204
PrimaryVariables dirichlet(const Element &element, const SubControlVolume &scv) const
Evaluate the boundary conditions for fixed values at cell centers.
Definition: test/freeflow/ransnc/problem.hh:319
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: test/freeflow/ransnc/problem.hh:348
FlatPlateNCTestProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/freeflow/ransnc/problem.hh:145
void setTimeLoop(TimeLoopPtr timeLoop)
Definition: test/freeflow/ransnc/problem.hh:372
bool shouldWriteRestartFile() const
Definition: test/freeflow/ransnc/problem.hh:185
bool isOnWallAtPos(const GlobalPosition &globalPos) const
Definition: test/freeflow/ransnc/problem.hh:179
bool isDirichletCell(const Element &element, const FVElementGeometry &fvGeometry, const SubControlVolume &scv, int pvIdx) const
Returns whether a fixed Dirichlet value shall be used at a given cell.
Definition: test/freeflow/ransnc/problem.hh:270
BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
Specifies which kind of boundary condition should be used for which equation on a given boundary cont...
Definition: test/freeflow/ransnc/problem.hh:221
Scalar time() const
Definition: test/freeflow/ransnc/problem.hh:377
PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const
Evaluate the boundary conditions for a dirichlet values at the boundary.
Definition: test/freeflow/ransnc/problem.hh:287
Definition: test/freeflow/ransnc/problem.hh:60
std::tuple< StaggeredFreeFlowModel > InheritsFrom
Definition: test/freeflow/ransnc/problem.hh:60
Definition: test/freeflow/ransnc/problem.hh:62
std::tuple< RANSNCModel, ZeroEqNC > InheritsFrom
Definition: test/freeflow/ransnc/problem.hh:62
Definition: test/freeflow/ransnc/problem.hh:63
std::tuple< RANSNCModel, OneEqNC > InheritsFrom
Definition: test/freeflow/ransnc/problem.hh:63
Definition: test/freeflow/ransnc/problem.hh:64
std::tuple< RANSNCModel, KOmegaNC > InheritsFrom
Definition: test/freeflow/ransnc/problem.hh:64
Definition: test/freeflow/ransnc/problem.hh:65
std::tuple< RANSNCModel, LowReKEpsilonNC > InheritsFrom
Definition: test/freeflow/ransnc/problem.hh:65
Definition: test/freeflow/ransnc/problem.hh:66
std::tuple< RANSNCModel, KEpsilonNC > InheritsFrom
Definition: test/freeflow/ransnc/problem.hh:66
Definition: test/freeflow/ransnc/problem.hh:68
std::tuple< RANSNCModel, ZeroEqNCNI > InheritsFrom
Definition: test/freeflow/ransnc/problem.hh:68
Definition: test/freeflow/ransnc/problem.hh:69
std::tuple< RANSNCModel, OneEqNCNI > InheritsFrom
Definition: test/freeflow/ransnc/problem.hh:69
Definition: test/freeflow/ransnc/problem.hh:70
std::tuple< RANSNCModel, KOmegaNCNI > InheritsFrom
Definition: test/freeflow/ransnc/problem.hh:70
Definition: test/freeflow/ransnc/problem.hh:71
std::tuple< RANSNCModel, LowReKEpsilonNCNI > InheritsFrom
Definition: test/freeflow/ransnc/problem.hh:71
Definition: test/freeflow/ransnc/problem.hh:72
std::tuple< RANSNCModel, KEpsilonNCNI > InheritsFrom
Definition: test/freeflow/ransnc/problem.hh:72
Dune::YaspGrid< 2, Dune::TensorProductCoordinates< GetPropType< TypeTag, Properties::Scalar >, 2 > > type
Definition: test/freeflow/ransnc/problem.hh:91
Defines a type tag and some properties for ree-flow models using the staggered scheme....
One-equation turbulence problem base class.
K-epsilon turbulence problem base class.
K-Omega turbulence model problem base class.
Low-Re k-epsilon turbulence problem base class.
Zero-equation turbulence problem base class.