GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/freeflow/navierstokesnc/maxwellstefan/problem.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 14 32 43.8%
Functions: 2 10 20.0%
Branches: 20 74 27.0%

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 NavierStokesNCTests
10 * \brief Channel flow test for the multi-component staggered grid (Navier-)Stokes model.
11 */
12
13 #ifndef DUMUX_CHANNEL_MAXWELL_STEFAN_TEST_PROBLEM_HH
14 #define DUMUX_CHANNEL_MAXWELL_STEFAN_TEST_PROBLEM_HH
15
16 #include <dumux/common/parameters.hh>
17 #include <dumux/common/properties.hh>
18
19 #include <dumux/freeflow/navierstokes/boundarytypes.hh>
20
21 #include <dumux/freeflow/navierstokes/momentum/fluxhelper.hh>
22 #include <dumux/freeflow/navierstokes/scalarfluxhelper.hh>
23
24 namespace Dumux {
25
26 /*!
27 * \ingroup NavierStokesNCTests
28 * \brief Test problem for the Maxwell-Stefan model
29 */
30 template <class TypeTag, class BaseProblem>
31 2 class MaxwellStefanNCTestProblem : public BaseProblem
32 {
33 using ParentType = BaseProblem;
34
35 using BoundaryTypes = typename ParentType::BoundaryTypes;
36 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
37 using InitialValues = typename ParentType::InitialValues;
38 using Sources = typename ParentType::Sources;
39 using DirichletValues = typename ParentType::DirichletValues;
40 using BoundaryFluxes = typename ParentType::BoundaryFluxes;
41 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
42 using SubControlVolume = typename GridGeometry::SubControlVolume;
43 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
44 using FVElementGeometry = typename GridGeometry::LocalView;
45
46 static constexpr auto dimWorld = GridGeometry::GridView::dimensionworld;
47 using Element = typename FVElementGeometry::Element;
48 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
49
50 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
51 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
52
53 using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>;
54
55 public:
56 4 MaxwellStefanNCTestProblem(std::shared_ptr<const GridGeometry> gridGeometry,
57 std::shared_ptr<CouplingManager> couplingManager)
58
6/18
✓ 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 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
16 : ParentType(gridGeometry, couplingManager)
59 4 {}
60
61 /*!
62 * \brief Specifies which kind of boundary condition should be
63 * used for which equation on a given boundary control volume.
64 *
65 * \param globalPos The position of the center of the finite volume
66 */
67 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
68 {
69 30720 BoundaryTypes values;
70
71 if constexpr (ParentType::isMomentumProblem())
72 {
73 values.setDirichlet(Indices::velocityXIdx);
74 values.setDirichlet(Indices::velocityYIdx);
75 }
76 else
77
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24480 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6240 times.
30720 values.setAllNeumann();
78
79 return values;
80 }
81
82 //! Enable internal Dirichlet constraints
83 static constexpr bool enableInternalDirichletConstraints()
84 { return !ParentType::isMomentumProblem(); }
85
86 /*!
87 * \brief Tag a degree of freedom to carry internal Dirichlet constraints.
88 * If true is returned for a dof, the equation for this dof is replaced
89 * by the constraint that its primary variable values must match the
90 * user-defined values obtained from the function internalDirichlet(),
91 * which must be defined in the problem.
92 *
93 * \param element The finite element
94 * \param scv The sub-control volume
95 */
96 std::bitset<DirichletValues::dimension> hasInternalDirichletConstraint(const Element& element, const SubControlVolume& scv) const
97 {
98 284580 std::bitset<DirichletValues::dimension> values;
99
100 // the pure Neumann problem is only defined up to a constant
101 // we create a well-posed problem by fixing the pressure at one dof
102
12/20
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 61132 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 61132 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 51 times.
✓ Branch 9 taken 45849 times.
✓ Branch 10 taken 51 times.
✓ Branch 11 taken 45849 times.
✓ Branch 12 taken 102 times.
✓ Branch 13 taken 177378 times.
✓ Branch 14 taken 102 times.
✓ Branch 15 taken 177378 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
569160 if (scv.dofIndex() == 0)
103 221 values.set(0);
104
105 return values;
106 }
107
108 /*!
109 * \brief Define the values of internal Dirichlet constraints for a degree of freedom.
110 * \param element The finite element
111 * \param scv The sub-control volume
112 */
113 DirichletValues internalDirichlet(const Element& element, const SubControlVolume& scv) const
114 45900 { return DirichletValues(1.1e5); }
115
116 /*!
117 * \brief Returns Dirichlet boundary values at a given position.
118 *
119 * \param globalPos The global position
120 */
121 DirichletValues dirichletAtPos(const GlobalPosition &globalPos) const
122 { return initialAtPos(globalPos); }
123
124 /*!
125 * \brief Evaluates the boundary conditions for a Neumann control volume.
126 *
127 * \param element The element for which the Neumann boundary condition is set
128 * \param fvGeometry The fvGeometry
129 * \param elemVolVars The element volume variables
130 * \param elemFaceVars The element face variables
131 * \param scvf The boundary sub control volume face
132 */
133 template<class ElementVolumeVariables, class ElementFluxVariablesCache>
134 BoundaryFluxes neumann(const Element& element,
135 const FVElementGeometry& fvGeometry,
136 const ElementVolumeVariables& elemVolVars,
137 const ElementFluxVariablesCache& elemFluxVarsCache,
138 const SubControlVolumeFace& scvf) const
139 48960 { return BoundaryFluxes(0.0); }
140
141 /*!
142 * \brief Evaluates the initial value for a control volume.
143 *
144 * \param globalPos The global position
145 */
146 InitialValues initialAtPos(const GlobalPosition &globalPos) const
147 {
148
0/2
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8220 InitialValues initialValues(0.0);
149
150 if constexpr (!ParentType::isMomentumProblem())
151 {
152 static constexpr auto compTwoIdx = Indices::conti0EqIdx + FluidSystem::N2Idx;
153 static constexpr auto compThreeIdx = Indices::conti0EqIdx + FluidSystem::CO2Idx;
154
155 initialValues[Indices::pressureIdx] = 1.1e+5;
156 if (globalPos[0] < 0.5)
157 {
158 initialValues[compTwoIdx] = 0.50086;
159 initialValues[compThreeIdx] = 0.49914;
160 }
161 else
162 {
163 initialValues[compTwoIdx] = 0.49879;
164 initialValues[compThreeIdx] = 0.0;
165 }
166 }
167 else
168 {
169
0/2
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8220 initialValues[Indices::velocityXIdx] = 0.0;
170
0/4
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
16440 initialValues[Indices::velocityYIdx] = 0.0;
171 }
172
173 return initialValues;
174 }
175
176
177 private:
178 const Scalar eps_{1e-6};
179 };
180 } // end namespace Dumux
181
182 #endif
183