GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/test/freeflow/navierstokes/permeabilityupscaling/problem.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 24 25 96.0%
Functions: 7 7 100.0%
Branches: 31 45 68.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-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 Pore flow test for the staggered grid (Navier-)Stokes model.
11 */
12
13 #ifndef DUMUX_TEST_STOKES_PERMEABILITY_UPSCALING_PROBLEM_HH
14 #define DUMUX_TEST_STOKES_PERMEABILITY_UPSCALING_PROBLEM_HH
15
16 #include <dune/common/float_cmp.hh>
17
18 #include <dumux/common/properties.hh>
19 #include <dumux/common/parameters.hh>
20
21 #include <dumux/freeflow/navierstokes/momentum/fluxhelper.hh>
22 #include <dumux/freeflow/navierstokes/scalarfluxhelper.hh>
23 #include <dumux/freeflow/navierstokes/mass/1p/advectiveflux.hh>
24 #include <dumux/discretization/method.hh>
25
26 namespace Dumux {
27
28 /*!
29 * \ingroup NavierStokesTests
30 * \brief Test problem of the pore flow test for permeability upscaling
31 */
32 template <class TypeTag, class BaseProblem>
33 4 class PoreFlowTestProblem : public BaseProblem
34 {
35 using ParentType = BaseProblem;
36
37 using BoundaryTypes = typename ParentType::BoundaryTypes;
38 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
39 using FVElementGeometry = typename GridGeometry::LocalView;
40 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
41 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
42 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
43 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
44 using InitialValues = typename ParentType::InitialValues;
45 using Sources = typename ParentType::Sources;
46 using DirichletValues = typename ParentType::DirichletValues;
47 using BoundaryFluxes = typename ParentType::BoundaryFluxes;
48 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
49 using SolutionVector = GetPropType<TypeTag, Properties::SolutionVector>;
50
51 static constexpr auto dimWorld = GridGeometry::GridView::dimensionworld;
52 using Element = typename FVElementGeometry::Element;
53 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
54
55 using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>;
56
57 public:
58 8 PoreFlowTestProblem(std::shared_ptr<const GridGeometry> gridGeometry,
59 std::shared_ptr<CouplingManager> couplingManager)
60
2/6
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
32 : ParentType(gridGeometry, couplingManager)
61 {
62 // gradP is 1/m
63 8 deltaP_ = (this->gridGeometry().bBoxMax()[0]-this->gridGeometry().bBoxMin()[0]);
64 8 }
65
66 /*!
67 * \brief Specifies which kind of boundary condition should be
68 * used for which equation on a given boundary control volume.
69 *
70 * \param globalPos The position of the center of the finite volume
71 */
72
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 185520 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27756 times.
213276 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
73 {
74
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 185520 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27756 times.
269428 BoundaryTypes values;
75
76 if constexpr (ParentType::isMomentumProblem())
77 {
78 56152 values.setAllDirichlet();
79
4/4
✓ Branch 0 taken 51832 times.
✓ Branch 1 taken 4320 times.
✓ Branch 2 taken 4320 times.
✓ Branch 3 taken 47512 times.
56152 if (isOutlet_(globalPos) || isInlet_(globalPos))
80 56152 values.setAllNeumann();
81 }
82 else
83 values.setNeumann(Indices::conti0EqIdx);
84
85 56152 return values;
86 }
87
88 /*!
89 * \brief Evaluates the boundary conditions for a Dirichlet control volume.
90 * \param globalPos The center of the finite volume which ought to be set.
91 */
92 DirichletValues dirichletAtPos(const GlobalPosition &globalPos) const
93 {
94 // no-flow/no-slip
95
3/5
✓ Branch 0 taken 11718 times.
✓ Branch 1 taken 7812 times.
✓ Branch 2 taken 3906 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
74192 return DirichletValues(0.0);
96 }
97
98 /*!
99 * \brief Evaluates the boundary conditions for a Neumann control volume
100 */
101 template<class ElementVolumeVariables, class ElementFluxVariablesCache>
102 282168 BoundaryFluxes neumann(const Element& element,
103 const FVElementGeometry& fvGeometry,
104 const ElementVolumeVariables& elemVolVars,
105 const ElementFluxVariablesCache& elemFluxVarsCache,
106 const SubControlVolumeFace& scvf) const
107 {
108
3/4
✓ Branch 0 taken 48324 times.
✓ Branch 1 taken 48324 times.
✓ Branch 3 taken 185520 times.
✗ Branch 4 not taken.
282168 BoundaryFluxes values(0.0);
109 282168 const auto& globalPos = scvf.ipGlobal();
110
111 if constexpr (ParentType::isMomentumProblem())
112 {
113
2/2
✓ Branch 0 taken 48324 times.
✓ Branch 1 taken 48324 times.
96648 const auto p = isInlet_(globalPos) ? deltaP_ : 0.0;
114
115 if constexpr (GridGeometry::discMethod == DiscretizationMethods::fcstaggered)
116 {
117 using FluxHelper = NavierStokesMomentumBoundaryFlux<typename GridGeometry::DiscretizationMethod>;
118 81528 values = FluxHelper::fixedPressureMomentumFlux(
119 *this, fvGeometry, scvf, elemVolVars, elemFluxVarsCache, p
120 );
121 }
122 else
123 30240 values.axpy(p, scvf.unitOuterNormal());
124 }
125 else
126 {
127
1/2
✓ Branch 1 taken 185520 times.
✗ Branch 2 not taken.
185520 values = NavierStokesScalarBoundaryFluxHelper<AdvectiveFlux<ModelTraits>>::scalarOutflowFlux(
128 *this, element, fvGeometry, scvf, elemVolVars
129 );
130 }
131
132 185520 return values;
133 }
134
135 private:
136
137
4/4
✓ Branch 0 taken 48324 times.
✓ Branch 1 taken 48324 times.
✓ Branch 2 taken 4320 times.
✓ Branch 3 taken 47512 times.
148480 bool isInlet_(const GlobalPosition& globalPos) const
138
4/4
✓ Branch 0 taken 48324 times.
✓ Branch 1 taken 48324 times.
✓ Branch 2 taken 4320 times.
✓ Branch 3 taken 47512 times.
148480 { return globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_; }
139
140
2/2
✓ Branch 0 taken 51832 times.
✓ Branch 1 taken 4320 times.
56152 bool isOutlet_(const GlobalPosition& globalPos) const
141
2/2
✓ Branch 0 taken 51832 times.
✓ Branch 1 taken 4320 times.
56152 { return globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_; }
142
143 static constexpr Scalar eps_ = 1e-8;
144 Scalar deltaP_;
145 };
146
147 } // end namespace Dumux
148
149 #endif
150