GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/test/freeflow/navierstokes/periodic/unit/problem.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 23 25 92.0%
Functions: 9 9 100.0%
Branches: 22 38 57.9%

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-FileCopyrightText: 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 6 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 12 PeriodicTestProblem(std::shared_ptr<const GridGeometry> gridGeometry, std::shared_ptr<CouplingManager> couplingManager)
52
2/6
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
48 : ParentType(gridGeometry, couplingManager)
53 {
54
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
12 usePressureDifference_ = getParam<bool>("Problem.UsePressureDifference", false);
55 12 }
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
2/4
✓ Branch 0 taken 4400 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1032 times.
✗ Branch 3 not taken.
5432 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
69 {
70
2/4
✓ Branch 0 taken 4400 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1032 times.
✗ Branch 3 not taken.
8816 BoundaryTypes values;
71 3384 values.setAllDirichlet();
72 3384 return values;
73 }
74
75 /*!
76 * \brief Returns Dirichlet boundary values at a given position.
77 *
78 * \param globalPos The global position
79 */
80
1/2
✓ Branch 1 taken 1032 times.
✗ Branch 2 not taken.
1032 DirichletValues dirichletAtPos(const GlobalPosition & globalPos) const
81 22608 { return DirichletValues(0.0); }
82
83 template<class ElementVolumeVariables>
84 52800 Sources source(const Element& element,
85 const FVElementGeometry& fvGeometry,
86 const ElementVolumeVariables& elemVolVars,
87 const SubControlVolume& scv) const
88 {
89 52800 Sources source;
90
91 if constexpr (ParentType::isMomentumProblem())
92 {
93
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52800 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52800 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 52800 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 10720 std::bitset<DirichletValues::dimension> hasInternalDirichletConstraint(const Element& element, const SubControlVolume& scv) const
125 {
126 10720 std::bitset<DirichletValues::dimension> values;
127
128
8/10
✓ Branch 2 taken 16000 times.
✓ Branch 3 taken 7040 times.
✓ Branch 5 taken 8960 times.
✓ Branch 6 taken 1760 times.
✓ Branch 9 taken 35840 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 35840 times.
✓ Branch 12 taken 8960 times.
✗ Branch 1 not taken.
✓ Branch 4 taken 1760 times.
128640 for (const auto& intersection : intersections(this->gridGeometry().gridView(), element))
129 {
130
1/2
✓ Branch 1 taken 35840 times.
✗ Branch 2 not taken.
49920 const auto center = intersection.geometry().center();
131
4/4
✓ Branch 0 taken 39360 times.
✓ Branch 1 taken 3520 times.
✓ Branch 2 taken 1232 times.
✓ Branch 3 taken 38128 times.
42880 if (intersection.neighbor() && center[1] > this->gridGeometry().bBoxMax()[1] - eps_)
132 1232 values.set(0);
133 }
134
135 10720 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 200 DirichletValues internalDirichlet(const Element& element, const SubControlVolume& scv) const
144 {
145 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