27#ifndef DUMUX_PIPE_LAUFER_PROBLEM_HH
28#define DUMUX_PIPE_LAUFER_PROBLEM_HH
30#include <dune/grid/yaspgrid.hh>
31#include <dune/common/hybridutilities.hh>
52template <
class TypeTag>
53class PipeLauferProblem;
77template<
class TypeTag>
85template<
class TypeTag>
86struct Grid<TypeTag, TTag::RANSModel>
87{
using type = Dune::YaspGrid<2, Dune::TensorProductCoordinates<GetPropType<TypeTag, Properties::Scalar>, 2> >; };
90template<
class TypeTag>
94template<
class TypeTag>
97template<
class TypeTag>
99template<
class TypeTag>
110template <
class TypeTag>
125 using Element =
typename GridGeometry::GridView::template Codim<0>::Entity;
126 using GlobalPosition =
typename Element::Geometry::GlobalCoordinate;
128 using SubControlVolume =
typename FVElementGeometry::SubControlVolume;
129 using SubControlVolumeFace =
typename FVElementGeometry::SubControlVolumeFace;
131 using TimeLoopPtr = std::shared_ptr<CheckPointTimeLoop<Scalar>>;
133 static constexpr auto dimWorld = GridGeometry::GridView::dimensionworld;
139 inletVelocity_ = getParam<Scalar>(
"Problem.InletVelocity");
140 inletTemperature_ = getParam<Scalar>(
"Problem.InletTemperature", 283.15);
141 wallTemperature_ = getParam<Scalar>(
"Problem.WallTemperature", 303.15);
142 sandGrainRoughness_ = getParam<Scalar>(
"Problem.SandGrainRoughness", 0.0);
146 FluidState fluidState;
147 fluidState.setPressure(0, 1e5);
151 Scalar
diameter = this->gridGeometry().bBoxMax()[1] - this->gridGeometry().bBoxMin()[1];
154 viscosityTilde_ = 1e-3 * turbulenceProperties.
viscosityTilde(inletVelocity_,
diameter, kinematicViscosity);
160 dissipation_ = turbulenceProperties.
dissipation(inletVelocity_,
diameter, kinematicViscosity);
163 initializationTime_ = getParam<Scalar>(
"TimeLoop.Initialization", 1.0);
165 initializationTime_ = getParam<Scalar>(
"TimeLoop.Initialization", -1.0);
168 std::cout <<
"Using the "<< turbulenceModelName_ <<
" Turbulence Model. \n";
169 std::cout << std::endl;
179 return globalPos[1] < this->gridGeometry().bBoxMin()[1] + eps_
180 || globalPos[1] > this->gridGeometry().bBoxMax()[1] - eps_;
185 return sandGrainRoughness_;
197 {
return inletTemperature_; }
206 return NumEqVector(0.0);
223 BoundaryTypes values;
226 if(isOutlet_(globalPos))
227 values.setDirichlet(Indices::pressureIdx);
231 values.setDirichlet(Indices::velocityXIdx);
232 values.setDirichlet(Indices::velocityYIdx);
236 if(isOutlet_(globalPos))
237 values.setOutflow(Indices::energyEqIdx);
239 values.setDirichlet(Indices::temperatureIdx);
243 static constexpr auto numEq =
numTurbulenceEq(ModelTraits::turbulenceModel());
244 setBcTypes_(values, globalPos, Dune::index_constant<numEq>{});
257 template<
class Element,
class FVElementGeometry,
class SubControlVolume>
259 const FVElementGeometry& fvGeometry,
260 const SubControlVolume& scv,
263 using IsKOmegaKEpsilon = std::integral_constant<bool, (ModelTraits::turbulenceModel() ==
TurbulenceModel::komega
265 return isDirichletCell_(element, fvGeometry, scv, pvIdx, IsKOmegaKEpsilon{});
275 PrimaryVariables
dirichlet(
const Element& element,
const SubControlVolumeFace& scvf)
const
277 const auto globalPos = scvf.ipGlobal();
281 values[Indices::temperatureIdx] =
isOnWallAtPos(globalPos) ? wallTemperature_ : inletTemperature_;
296 std::enable_if_t<!enable, int> = 0>
297 PrimaryVariables
dirichlet(
const Element& element,
const SubControlVolume& scv)
const
299 const auto globalPos = scv.center();
313 std::enable_if_t<enable, int> = 0>
314 PrimaryVariables
dirichlet(
const Element& element,
const SubControlVolume& scv)
const
316 using SetDirichletCellForBothTurbEq = std::integral_constant<bool, (ModelTraits::turbulenceModel() ==
TurbulenceModel::kepsilon)>;
318 return dirichletTurbulentTwoEq_(element, scv, SetDirichletCellForBothTurbEq{});
329 PrimaryVariables values(0.0);
330 values[Indices::pressureIdx] = 1.0e+5;
331 values[Indices::velocityXIdx] =
time() > initializationTime_
333 :
time() / initializationTime_ * inletVelocity_;
335 values[Indices::velocityXIdx] = 0.0;
338 values[Indices::temperatureIdx] =
isOnWallAtPos(globalPos) ? wallTemperature_ : inletTemperature_;
342 static constexpr auto numEq =
numTurbulenceEq(ModelTraits::turbulenceModel());
343 setInitialAtPos_(values, globalPos, Dune::index_constant<numEq>{});
352 timeLoop_ = timeLoop;
357 return timeLoop_->time();
361 bool isInlet_(
const GlobalPosition& globalPos)
const
363 return globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_;
366 bool isOutlet_(
const GlobalPosition& globalPos)
const
368 return globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_;
372 void setInitialAtPos_(PrimaryVariables& values,
const GlobalPosition &globalPos, Dune::index_constant<0>)
const {}
375 void setInitialAtPos_(PrimaryVariables& values,
const GlobalPosition &globalPos, Dune::index_constant<1>)
const
377 values[Indices::viscosityTildeIdx] = viscosityTilde_;
379 values[Indices::viscosityTildeIdx] = 0.0;
383 void setInitialAtPos_(PrimaryVariables& values,
const GlobalPosition &globalPos, Dune::index_constant<2>)
const
385 values[Indices::turbulentKineticEnergyIdx] = turbulentKineticEnergy_;
386 values[Indices::dissipationIdx] = dissipation_;
389 values[Indices::turbulentKineticEnergyIdx] = 0.0;
390 values[Indices::dissipationIdx] = 0.0;
395 void setBcTypes_(BoundaryTypes& values,
const GlobalPosition& pos, Dune::index_constant<0>)
const {}
398 void setBcTypes_(BoundaryTypes& values,
const GlobalPosition& pos, Dune::index_constant<1>)
const
401 values.setOutflow(Indices::viscosityTildeIdx);
403 values.setDirichlet(Indices::viscosityTildeIdx);
407 void setBcTypes_(BoundaryTypes& values,
const GlobalPosition& pos, Dune::index_constant<2>)
const
411 values.setOutflow(Indices::turbulentKineticEnergyEqIdx);
412 values.setOutflow(Indices::dissipationEqIdx);
417 values.setDirichlet(Indices::turbulentKineticEnergyIdx);
418 values.setDirichlet(Indices::dissipationIdx);
423 template<
class Element,
class FVElementGeometry,
class SubControlVolume>
424 bool isDirichletCell_(
const Element& element,
425 const FVElementGeometry& fvGeometry,
426 const SubControlVolume& scv,
428 std::false_type)
const
430 return ParentType::isDirichletCell(element, fvGeometry, scv, pvIdx);
434 template<
class Element,
class FVElementGeometry,
class SubControlVolume>
435 bool isDirichletCell_(
const Element& element,
436 const FVElementGeometry& fvGeometry,
437 const SubControlVolume& scv,
439 std::true_type)
const
441 using SetDirichletCellForBothTurbEq = std::integral_constant<bool, (ModelTraits::turbulenceModel() ==
TurbulenceModel::kepsilon)>;
442 return isDirichletCellTurbulentTwoEq_(element, fvGeometry, scv, pvIdx, SetDirichletCellForBothTurbEq{});
446 template<
class Element>
447 bool isDirichletCellTurbulentTwoEq_(
const Element& element,
448 const FVElementGeometry& fvGeometry,
449 const SubControlVolume& scv,
451 std::true_type)
const
453 const auto eIdx = this->gridGeometry().elementMapper().index(element);
456 if (this->inNearWallRegion(eIdx))
457 return pvIdx == Indices::turbulentKineticEnergyEqIdx || pvIdx == Indices::dissipationEqIdx;
460 if (this->isMatchingPoint(eIdx))
461 return pvIdx == Indices::dissipationEqIdx;
467 template<
class Element>
468 bool isDirichletCellTurbulentTwoEq_(
const Element& element,
469 const FVElementGeometry& fvGeometry,
470 const SubControlVolume& scv,
472 std::false_type)
const
475 for (
const auto& scvf : scvfs(fvGeometry))
476 if (
isOnWallAtPos(scvf.center()) && pvIdx == Indices::dissipationIdx)
484 template<
class Element,
class SubControlVolume>
485 PrimaryVariables dirichletTurbulentTwoEq_(
const Element& element,
486 const SubControlVolume& scv,
487 std::true_type)
const
489 const auto globalPos = scv.center();
491 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
494 values[Indices::turbulentKineticEnergyEqIdx] = this->turbulentKineticEnergyWallFunction(elementIdx);
497 values[Indices::dissipationEqIdx] = this->dissipationWallFunction(elementIdx);
503 template<
class Element,
class SubControlVolume>
504 PrimaryVariables dirichletTurbulentTwoEq_(
const Element& element,
505 const SubControlVolume& scv,
506 std::false_type)
const
508 const auto globalPos = scv.center();
510 unsigned int elementIdx = this->gridGeometry().elementMapper().index(element);
512 const auto wallDistance = ParentType::wallDistance_[elementIdx];
514 values[Indices::dissipationEqIdx] = 6.0 * ParentType::kinematicViscosity_[elementIdx]
515 / (ParentType::betaOmega() * pow(wallDistance, 2));
520 Scalar inletVelocity_;
521 Scalar inletTemperature_;
522 Scalar wallTemperature_;
523 Scalar sandGrainRoughness_;
524 Scalar initializationTime_;
525 Scalar viscosityTilde_;
526 Scalar turbulentKineticEnergy_;
528 std::string turbulenceModelName_;
529 TimeLoopPtr timeLoop_;
The available free flow turbulence models in Dumux.
This file contains different functions for estimating turbulence properties.
A gaseous phase consisting of a single component.
A simple class for the air fluid properties.
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
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
A gaseous phase consisting of a single component.
Definition: 1pgas.hh:46
Test problem for the one-phase (Navier-) Stokes problem in a channel.
Definition: test/freeflow/rans/problem.hh:112
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/rans/problem.hh:221
bool shouldWriteRestartFile() const
Definition: test/freeflow/rans/problem.hh:188
Scalar sandGrainRoughnessAtPos(const GlobalPosition &globalPos) const
Definition: test/freeflow/rans/problem.hh:183
PipeLauferProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/freeflow/rans/problem.hh:136
PrimaryVariables dirichlet(const Element &element, const SubControlVolume &scv) const
Evaluate the boundary conditions for fixed values at cell centers.
Definition: test/freeflow/rans/problem.hh:297
PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const
Evaluate the boundary conditions for a dirichlet values at the boundary.
Definition: test/freeflow/rans/problem.hh:275
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluate the initial value for a control volume.
Definition: test/freeflow/rans/problem.hh:326
NumEqVector sourceAtPos(const GlobalPosition &globalPos) const
Returns the sources within the domain.
Definition: test/freeflow/rans/problem.hh:204
void setTimeLoop(TimeLoopPtr timeLoop)
Definition: test/freeflow/rans/problem.hh:350
Scalar temperature() const
Returns the temperature [K] within the domain for the isothermal model.
Definition: test/freeflow/rans/problem.hh:196
bool isOnWallAtPos(const GlobalPosition &globalPos) const
Definition: test/freeflow/rans/problem.hh:177
Scalar time() const
Definition: test/freeflow/rans/problem.hh:355
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/rans/problem.hh:258
Definition: test/freeflow/rans/problem.hh:60
std::tuple< StaggeredFreeFlowModel > InheritsFrom
Definition: test/freeflow/rans/problem.hh:60
Definition: test/freeflow/rans/problem.hh:62
std::tuple< RANSModel, ZeroEq > InheritsFrom
Definition: test/freeflow/rans/problem.hh:62
Definition: test/freeflow/rans/problem.hh:63
std::tuple< RANSModel, OneEq > InheritsFrom
Definition: test/freeflow/rans/problem.hh:63
Definition: test/freeflow/rans/problem.hh:64
std::tuple< RANSModel, KOmega > InheritsFrom
Definition: test/freeflow/rans/problem.hh:64
Definition: test/freeflow/rans/problem.hh:65
std::tuple< RANSModel, LowReKEpsilon > InheritsFrom
Definition: test/freeflow/rans/problem.hh:65
Definition: test/freeflow/rans/problem.hh:66
std::tuple< RANSModel, KEpsilon > InheritsFrom
Definition: test/freeflow/rans/problem.hh:66
Definition: test/freeflow/rans/problem.hh:68
std::tuple< RANSModel, ZeroEqNI > InheritsFrom
Definition: test/freeflow/rans/problem.hh:68
Definition: test/freeflow/rans/problem.hh:69
std::tuple< RANSModel, OneEqNI > InheritsFrom
Definition: test/freeflow/rans/problem.hh:69
Definition: test/freeflow/rans/problem.hh:70
std::tuple< RANSModel, KOmegaNI > InheritsFrom
Definition: test/freeflow/rans/problem.hh:70
Definition: test/freeflow/rans/problem.hh:71
std::tuple< RANSModel, LowReKEpsilonNI > InheritsFrom
Definition: test/freeflow/rans/problem.hh:71
Definition: test/freeflow/rans/problem.hh:72
std::tuple< RANSModel, KEpsilonNI > InheritsFrom
Definition: test/freeflow/rans/problem.hh:72
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/freeflow/rans/problem.hh:80
Dune::YaspGrid< 2, Dune::TensorProductCoordinates< GetPropType< TypeTag, Properties::Scalar >, 2 > > type
Definition: test/freeflow/rans/problem.hh:87
Defines a type tag and some properties for ree-flow models using the staggered scheme....
A single-phase, isothermal one-equation turbulence model by Spalart-Allmaras.
A single-phase, isothermal k-epsilon model.
A single-phase, isothermal k-omega 2-Eq. model.
A single-phase, isothermal low-Reynolds k-epsilon model.
A single-phase, isothermal Reynolds-Averaged Navier-Stokes 0-Eq. model.
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.