25#ifndef DUMUX_KOVASZNAY_TEST_PROBLEM_HH
26#define DUMUX_KOVASZNAY_TEST_PROBLEM_HH
28#ifndef UPWINDSCHEMEORDER
29#define UPWINDSCHEMEORDER 0
32#include <dune/grid/yaspgrid.hh>
40#include "../l2error.hh"
43template <
class TypeTag>
44class KovasznayTestProblem;
53template<
class TypeTag>
61template<
class TypeTag>
62struct Grid<TypeTag, TTag::KovasznayTest> {
using type = Dune::YaspGrid<2, Dune::EquidistantOffsetCoordinates<GetPropType<TypeTag, Properties::Scalar>, 2> >; };
65template<
class TypeTag>
68template<
class TypeTag>
71template<
class TypeTag>
73template<
class TypeTag>
76template<
class TypeTag>
88template <
class TypeTag>
95 using FVElementGeometry =
typename GridGeometry::LocalView;
96 using SubControlVolume =
typename GridGeometry::SubControlVolume;
105 using Element =
typename GridGeometry::GridView::template Codim<0>::Entity;
106 using GlobalPosition =
typename Element::Geometry::GlobalCoordinate;
107 using VelocityVector = Dune::FieldVector<Scalar, dimWorld>;
109 static constexpr auto upwindSchemeOrder = getPropValue<TypeTag, Properties::UpwindSchemeOrder>();
113 : ParentType(gridGeometry), eps_(1e-6)
115 printL2Error_ = getParam<bool>(
"Problem.PrintL2Error");
116 std::cout<<
"upwindSchemeOrder is: " << GridGeometry::upwindStencilOrder() <<
"\n";
117 kinematicViscosity_ = getParam<Scalar>(
"Component.LiquidKinematicViscosity", 1.0);
118 Scalar reynoldsNumber = 1.0 / kinematicViscosity_;
119 lambda_ = 0.5 * reynoldsNumber
120 - std::sqrt(reynoldsNumber * reynoldsNumber * 0.25 + 4.0 * M_PI * M_PI);
122 createAnalyticalSolution_();
140 const auto l2error = L2Error::calculateL2Error(*
this, curSol);
141 const int numCellCenterDofs = this->gridGeometry().numCellCenterDofs();
142 const int numFaceDofs = this->gridGeometry().numFaceDofs();
143 std::cout << std::setprecision(8) <<
"** L2 error (abs/rel) for "
144 << std::setw(6) << numCellCenterDofs <<
" cc dofs and " << numFaceDofs <<
" face dofs (total: " << numCellCenterDofs + numFaceDofs <<
"): "
146 <<
"L2(p) = " << l2error.first[Indices::pressureIdx] <<
" / " << l2error.second[Indices::pressureIdx]
147 <<
" , L2(vx) = " << l2error.first[Indices::velocityXIdx] <<
" / " << l2error.second[Indices::velocityXIdx]
148 <<
" , L2(vy) = " << l2error.first[Indices::velocityYIdx] <<
" / " << l2error.second[Indices::velocityYIdx]
169 return NumEqVector(0.0);
186 BoundaryTypes values;
189 values.setDirichlet(Indices::velocityXIdx);
190 values.setDirichlet(Indices::velocityYIdx);
204 const FVElementGeometry& fvGeometry,
205 const SubControlVolume& scv,
209 auto isAtLeftBoundary = [&](
const FVElementGeometry& fvGeometry)
211 if (fvGeometry.hasBoundaryScvf())
213 for (
const auto& scvf : scvfs(fvGeometry))
214 if (scvf.boundary() && scvf.center()[0] < this->gridGeometry().bBoxMin()[0] + eps_)
219 return (isAtLeftBoundary(fvGeometry) && pvIdx == Indices::pressureIdx);
240 Scalar x = globalPos[0];
241 Scalar y = globalPos[1];
243 PrimaryVariables values;
244 values[Indices::pressureIdx] = 0.5 * (1.0 - std::exp(2.0 * lambda_ * x));
245 values[Indices::velocityXIdx] = 1.0 - std::exp(lambda_ * x) * std::cos(2.0 * M_PI * y);
246 values[Indices::velocityYIdx] = 0.5 * lambda_ / M_PI * std::exp(lambda_ * x) * std::sin(2.0 * M_PI * y);
265 PrimaryVariables values;
266 values[Indices::pressureIdx] = 0.0;
267 values[Indices::velocityXIdx] = 0.0;
268 values[Indices::velocityYIdx] = 0.0;
278 return analyticalPressure_;
286 return analyticalVelocity_;
294 return analyticalVelocityOnFace_;
304 void createAnalyticalSolution_()
306 analyticalPressure_.resize(this->gridGeometry().numCellCenterDofs());
307 analyticalVelocity_.resize(this->gridGeometry().numCellCenterDofs());
308 analyticalVelocityOnFace_.resize(this->gridGeometry().numFaceDofs());
310 for (
const auto& element : elements(this->gridGeometry().gridView()))
312 auto fvGeometry =
localView(this->gridGeometry());
313 fvGeometry.bindElement(element);
314 for (
auto&& scv : scvs(fvGeometry))
316 auto ccDofIdx = scv.dofIndex();
317 auto ccDofPosition = scv.dofPosition();
321 for (
auto&& scvf : scvfs(fvGeometry))
323 const auto faceDofIdx = scvf.dofIndex();
324 const auto faceDofPosition = scvf.center();
325 const auto dirIdx = scvf.directionIndex();
327 analyticalVelocityOnFace_[faceDofIdx][dirIdx] = analyticalSolutionAtFace[Indices::velocity(dirIdx)];
330 analyticalPressure_[ccDofIdx] = analyticalSolutionAtCc[Indices::pressureIdx];
332 for(
int dirIdx = 0; dirIdx < ModelTraits::dim(); ++dirIdx)
333 analyticalVelocity_[ccDofIdx][dirIdx] = analyticalSolutionAtCc[Indices::velocity(dirIdx)];
340 Scalar kinematicViscosity_;
343 std::vector<Scalar> analyticalPressure_;
344 std::vector<VelocityVector> analyticalVelocity_;
345 std::vector<VelocityVector> analyticalVelocityOnFace_;
Setting constant fluid properties via the input file.
A liquid phase consisting of a single component.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
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
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
Specifies the order of the upwinding scheme (1 == first order, 2 == second order(tvd methods))
Definition: common/properties.hh:305
Navier-Stokes problem base class.
Definition: dumux/freeflow/navierstokes/problem.hh:63
A liquid phase consisting of a single component.
Definition: 1pliquid.hh:46
Test problem for the staggered grid (Kovasznay 1948, )
Definition: test/freeflow/navierstokes/kovasznay/problem.hh:90
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/navierstokes/kovasznay/problem.hh:184
Scalar temperature() const
Returns the temperature within the domain in [K].
Definition: test/freeflow/navierstokes/kovasznay/problem.hh:158
bool shouldWriteRestartFile() const
Definition: test/freeflow/navierstokes/kovasznay/problem.hh:130
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Returns Dirichlet boundary values at a given position.
Definition: test/freeflow/navierstokes/kovasznay/problem.hh:227
void printL2Error(const SolutionVector &curSol) const
Definition: test/freeflow/navierstokes/kovasznay/problem.hh:135
auto & getAnalyticalVelocitySolution() const
Returns the analytical solution for the velocity.
Definition: test/freeflow/navierstokes/kovasznay/problem.hh:284
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/navierstokes/kovasznay/problem.hh:203
auto & getAnalyticalPressureSolution() const
Returns the analytical solution for the pressure.
Definition: test/freeflow/navierstokes/kovasznay/problem.hh:276
KovasznayTestProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/freeflow/navierstokes/kovasznay/problem.hh:112
NumEqVector sourceAtPos(const GlobalPosition &globalPos) const
Returns the sources within the domain.
Definition: test/freeflow/navierstokes/kovasznay/problem.hh:167
auto & getAnalyticalVelocitySolutionOnFace() const
Returns the analytical solution for the velocity at the faces.
Definition: test/freeflow/navierstokes/kovasznay/problem.hh:292
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: test/freeflow/navierstokes/kovasznay/problem.hh:263
PrimaryVariables analyticalSolution(const GlobalPosition &globalPos) const
Returns the analytical solution of the problem at a given position.
Definition: test/freeflow/navierstokes/kovasznay/problem.hh:238
Definition: test/freeflow/navierstokes/kovasznay/problem.hh:49
std::tuple< NavierStokes, StaggeredFreeFlowModel > InheritsFrom
Definition: test/freeflow/navierstokes/kovasznay/problem.hh:49
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/freeflow/navierstokes/kovasznay/problem.hh:56
Dune::YaspGrid< 2, Dune::EquidistantOffsetCoordinates< GetPropType< TypeTag, Properties::Scalar >, 2 > > type
Definition: test/freeflow/navierstokes/kovasznay/problem.hh:62
Routines to calculate the discrete L2 error.
Definition: l2error.hh:38
Defines a type tag and some properties for ree-flow models using the staggered scheme....
A single-phase, isothermal Navier-Stokes model.
#define UPWINDSCHEMEORDER
Definition: test/freeflow/navierstokes/kovasznay/problem.hh:29