Line | Branch | Exec | Source |
---|---|---|---|
1 | // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- | ||
2 | // vi: set et ts=4 sw=4 sts=4: | ||
3 | // | ||
4 | // SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder | ||
5 | // SPDX-License-Identifier: GPL-3.0-or-later | ||
6 | // | ||
7 | /*! | ||
8 | * \file | ||
9 | * \ingroup NavierStokesTests | ||
10 | * \brief Stationary test for the staggered grid Navier-Stokes model with periodic BC | ||
11 | */ | ||
12 | |||
13 | #ifndef DUMUX_TEST_FREEFLOW_NAVIERSTOKES_PERIODIC_PROBLEM_HH | ||
14 | #define DUMUX_TEST_FREEFLOW_NAVIERSTOKES_PERIODIC_PROBLEM_HH | ||
15 | |||
16 | #include <dumux/common/parameters.hh> | ||
17 | #include <dumux/common/properties.hh> | ||
18 | |||
19 | namespace Dumux { | ||
20 | |||
21 | /*! | ||
22 | * \ingroup NavierStokesTests | ||
23 | * \brief Periodic test problem for the staggered grid | ||
24 | * | ||
25 | * A two-dimensional Navier-Stokes flow with a periodicity in one direction | ||
26 | * is considered. | ||
27 | */ | ||
28 | template <class TypeTag, class BaseProblem> | ||
29 | 2 | class PeriodicTestProblem : public BaseProblem | |
30 | { | ||
31 | using ParentType = BaseProblem; | ||
32 | using BoundaryTypes = typename ParentType::BoundaryTypes; | ||
33 | using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; | ||
34 | using FVElementGeometry = typename GridGeometry::LocalView; | ||
35 | using SubControlVolume = typename FVElementGeometry::SubControlVolume; | ||
36 | using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace; | ||
37 | using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices; | ||
38 | using InitialValues = typename ParentType::InitialValues; | ||
39 | using Sources = typename ParentType::Sources; | ||
40 | using DirichletValues = typename ParentType::DirichletValues; | ||
41 | using BoundaryFluxes = typename ParentType::BoundaryFluxes; | ||
42 | using Scalar = GetPropType<TypeTag, Properties::Scalar>; | ||
43 | |||
44 | static constexpr auto dimWorld = GridGeometry::GridView::dimensionworld; | ||
45 | using Element = typename FVElementGeometry::Element; | ||
46 | using GlobalPosition = typename Element::Geometry::GlobalCoordinate; | ||
47 | |||
48 | using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>; | ||
49 | |||
50 | public: | ||
51 | 4 | PeriodicTestProblem(std::shared_ptr<const GridGeometry> gridGeometry, std::shared_ptr<CouplingManager> couplingManager) | |
52 |
7/20✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 2 times.
✓ Branch 18 taken 2 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
|
16 | : ParentType(gridGeometry, couplingManager) |
53 | { | ||
54 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
4 | usePressureDifference_ = getParam<bool>("Problem.UsePressureDifference", false); |
55 | 4 | } | |
56 | |||
57 | /*! | ||
58 | * \name Boundary conditions | ||
59 | */ | ||
60 | // \{ | ||
61 | |||
62 | /*! | ||
63 | * \brief Specifies which kind of boundary condition should be | ||
64 | * used for which equation on a given boundary control volume. | ||
65 | * | ||
66 | * \param globalPos The position of the center of the finite volume | ||
67 | */ | ||
68 | ✗ | BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const | |
69 | { | ||
70 |
2/4✓ Branch 0 taken 400 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
|
520 | BoundaryTypes values; |
71 |
2/4✓ Branch 0 taken 400 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
|
520 | values.setAllDirichlet(); |
72 | ✗ | return values; | |
73 | } | ||
74 | |||
75 | /*! | ||
76 | * \brief Returns Dirichlet boundary values at a given position. | ||
77 | * | ||
78 | * \param globalPos The global position | ||
79 | */ | ||
80 | ✗ | DirichletValues dirichletAtPos(const GlobalPosition & globalPos) const | |
81 | 2120 | { return DirichletValues(0.0); } | |
82 | |||
83 | template<class ElementVolumeVariables> | ||
84 | 17280 | Sources source(const Element& element, | |
85 | const FVElementGeometry& fvGeometry, | ||
86 | const ElementVolumeVariables& elemVolVars, | ||
87 | const SubControlVolume& scv) const | ||
88 | { | ||
89 |
1/4✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2000 times.
|
19280 | Sources source; |
90 | |||
91 | if constexpr (ParentType::isMomentumProblem()) | ||
92 | { | ||
93 |
1/14✗ Branch 0 not taken.
✓ Branch 1 taken 8640 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
17280 | if (usePressureDifference_ && scv.dofPosition()[1] < this->gridGeometry().bBoxMin()[1] + eps_) |
94 | { | ||
95 | ✗ | const auto& frontalScvf = (*scvfs(fvGeometry, scv).begin()); | |
96 | ✗ | source[Indices::momentumYBalanceIdx] = 100 * frontalScvf.area() / scv.volume(); | |
97 | } | ||
98 | } | ||
99 | |||
100 | 17280 | return source; | |
101 | } | ||
102 | |||
103 | // \} | ||
104 | |||
105 | /*! | ||
106 | * \name Volume terms | ||
107 | */ | ||
108 | // \{ | ||
109 | |||
110 | //! Enable internal Dirichlet constraints | ||
111 | static constexpr bool enableInternalDirichletConstraints() | ||
112 | { return !ParentType::isMomentumProblem(); } | ||
113 | |||
114 | /*! | ||
115 | * \brief Tag a degree of freedom to carry internal Dirichlet constraints. | ||
116 | * If true is returned for a dof, the equation for this dof is replaced | ||
117 | * by the constraint that its primary variable values must match the | ||
118 | * user-defined values obtained from the function internalDirichlet(), | ||
119 | * which must be defined in the problem. | ||
120 | * | ||
121 | * \param element The finite element | ||
122 | * \param scv The sub-control volume | ||
123 | */ | ||
124 | 1760 | std::bitset<DirichletValues::dimension> hasInternalDirichletConstraint(const Element& element, const SubControlVolume& scv) const | |
125 | { | ||
126 | 1760 | std::bitset<DirichletValues::dimension> values; | |
127 | |||
128 |
5/6✓ Branch 3 taken 1760 times.
✓ Branch 4 taken 7040 times.
✓ Branch 5 taken 7040 times.
✓ Branch 6 taken 1760 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7040 times.
|
24640 | for (const auto& intersection : intersections(this->gridGeometry().gridView(), element)) |
129 | { | ||
130 | 7040 | const auto center = intersection.geometry().center(); | |
131 |
14/14✓ Branch 1 taken 672 times.
✓ Branch 2 taken 6368 times.
✓ Branch 4 taken 352 times.
✓ Branch 5 taken 320 times.
✓ Branch 6 taken 176 times.
✓ Branch 7 taken 176 times.
✓ Branch 8 taken 176 times.
✓ Branch 9 taken 176 times.
✓ Branch 10 taken 176 times.
✓ Branch 11 taken 176 times.
✓ Branch 12 taken 176 times.
✓ Branch 13 taken 176 times.
✓ Branch 14 taken 176 times.
✓ Branch 15 taken 176 times.
|
7040 | if (intersection.boundary() && intersection.neighbor() && center[1] > this->gridGeometry().bBoxMax()[1] - eps_) |
132 | 176 | values.set(0); | |
133 | } | ||
134 | |||
135 | 1760 | return values; | |
136 | } | ||
137 | |||
138 | /*! | ||
139 | * \brief Define the values of internal Dirichlet constraints for a degree of freedom. | ||
140 | * \param element The finite element | ||
141 | * \param scv The sub-control volume | ||
142 | */ | ||
143 | ✗ | DirichletValues internalDirichlet(const Element& element, const SubControlVolume& scv) const | |
144 | { | ||
145 | 200 | return DirichletValues(1.0); | |
146 | } | ||
147 | |||
148 | private: | ||
149 | static constexpr Scalar eps_ = 1e-6; | ||
150 | bool usePressureDifference_; | ||
151 | }; | ||
152 | |||
153 | } // end namespace Dumux | ||
154 | |||
155 | #endif | ||
156 |