GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/test/multidomain/facet/1pnc_1pnc/problem_bulk.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 34 34 100.0%
Functions: 36 36 100.0%
Branches: 70 89 78.7%

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 FacetTests
10 * \brief The problem for the bulk domain in the 1pnc facet coupling test.
11 */
12 #ifndef DUMUX_TEST_TPFAFACETCOUPLING_ONEPNC_BULKPROBLEM_HH
13 #define DUMUX_TEST_TPFAFACETCOUPLING_ONEPNC_BULKPROBLEM_HH
14
15 #include <dumux/common/properties.hh>
16 #include <dumux/common/parameters.hh>
17 #include <dumux/common/boundarytypes.hh>
18 #include <dumux/common/numeqvector.hh>
19
20 #include <dumux/porousmediumflow/problem.hh>
21
22 // defined in CMakeLists.txt
23 #ifndef USEMIXEDBCS
24 #define USEMIXEDBCS false
25 #endif
26
27 namespace Dumux {
28
29 /*!
30 * \ingroup FacetTests
31 * \brief Test problem for the 1pnc model with
32 * coupling across the bulk grid facets.
33 */
34 template<class TypeTag>
35 class OnePNCBulkProblem : public PorousMediumFlowProblem<TypeTag>
36 {
37 using ParentType = PorousMediumFlowProblem<TypeTag>;
38
39 using GridVariables = GetPropType<TypeTag, Properties::GridVariables>;
40 using PrimaryVariables = typename GridVariables::PrimaryVariables;
41 using Scalar = typename GridVariables::Scalar;
42
43 using GridGeometry = typename GridVariables::GridGeometry;
44 using FVElementGeometry = typename GridGeometry::LocalView;
45 using SubControlVolume = typename GridGeometry::SubControlVolume;
46 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
47 using GridView = typename GridGeometry::GridView;
48 using Element = typename GridView::template Codim<0>::Entity;
49 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
50
51 using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
52 using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>;
53 using NumEqVector = Dumux::NumEqVector<PrimaryVariables>;
54 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
55 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
56
57 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
58 static constexpr bool enableHeatConduction = ModelTraits::enableEnergyBalance();
59
60 enum
61 {
62 // indices of the primary variables
63 pressureIdx = Indices::pressureIdx,
64 H2OIdx = FluidSystem::compIdx(FluidSystem::MultiPhaseFluidSystem::H2OIdx),
65 N2Idx = FluidSystem::compIdx(FluidSystem::MultiPhaseFluidSystem::N2Idx),
66
67 // equation indices
68 contiH2OEqIdx = Indices::conti0EqIdx + H2OIdx
69 };
70
71 public:
72 13 OnePNCBulkProblem(std::shared_ptr<const GridGeometry> gridGeometry,
73 std::shared_ptr<typename ParentType::SpatialParams> spatialParams,
74 std::shared_ptr<CouplingManager> couplingManager,
75 const std::string& paramGroup = "")
76 : ParentType(gridGeometry, spatialParams, paramGroup)
77
4/10
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 13 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 13 times.
✗ Branch 8 not taken.
✓ Branch 11 taken 13 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
39 , couplingManagerPtr_(couplingManager)
78 {
79 //initialize fluid system
80 FluidSystem::init();
81
82 // stating in the console whether mole or mass fractions are used
83 if (!getPropValue<TypeTag, Properties::UseMoles>())
84 DUNE_THROW(Dune::InvalidStateException, "Problem is implemented for molar formulation!");
85
86
3/6
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 13 times.
✗ Branch 8 not taken.
26 problemName_ = getParam<std::string>("Vtk.OutputName") + "_" +
87
1/2
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
13 getParamFromGroup<std::string>(this->paramGroup(), "Problem.Name");
88 13 }
89
90 //! The problem name.
91 13 const std::string& name() const
92
1/2
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
13 { return problemName_; }
93
94 //! Specifies the type of boundary condition at a given position.
95 804464 BoundaryTypes boundaryTypesAtPos(const GlobalPosition& globalPos) const
96 {
97
2/2
✓ Branch 0 taken 2182436 times.
✓ Branch 1 taken 804464 times.
2986900 BoundaryTypes values;
98
2/2
✓ Branch 0 taken 591546 times.
✓ Branch 1 taken 212918 times.
804464 values.setAllNeumann();
99 #if !USEMIXEDBCS
100
4/4
✓ Branch 0 taken 589306 times.
✓ Branch 1 taken 206678 times.
✓ Branch 2 taken 206678 times.
✓ Branch 3 taken 382628 times.
795984 if (globalPos[1] < 1e-6 || globalPos[1] > this->gridGeometry().bBoxMax()[1] - 1e-6)
101 795984 values.setAllDirichlet();
102 #else
103
2/2
✓ Branch 0 taken 2240 times.
✓ Branch 1 taken 6240 times.
8480 if (globalPos[1] < 1e-6)
104
2/2
✓ Branch 0 taken 2240 times.
✓ Branch 1 taken 6240 times.
8480 values.setAllDirichlet();
105
2/2
✓ Branch 0 taken 2240 times.
✓ Branch 1 taken 6240 times.
8480 if (globalPos[1] > this->gridGeometry().bBoxMax()[1] - 1e-6)
106 2240 values.setDirichlet(contiH2OEqIdx);
107 #endif
108 804464 return values;
109 }
110
111 //! Specifies the type of interior boundary condition at a given position.
112 2549988 BoundaryTypes interiorBoundaryTypes(const Element& element, const SubControlVolumeFace& scvf) const
113 {
114
2/2
✓ Branch 0 taken 6887246 times.
✓ Branch 1 taken 2549988 times.
9437234 BoundaryTypes values;
115 2549988 values.setAllNeumann();
116 2549988 return values;
117 }
118
119 //! Evaluates the source term at a given position.
120 8501584 NumEqVector sourceAtPos(const GlobalPosition& globalPos) const
121
2/2
✓ Branch 0 taken 15637440 times.
✓ Branch 1 taken 5212480 times.
32640608 { return NumEqVector(0.0); }
122
123 //! Evaluates the Dirichlet boundary condition for a given position.
124 118128 PrimaryVariables dirichletAtPos(const GlobalPosition& globalPos) const
125 {
126
4/4
✓ Branch 0 taken 45512 times.
✓ Branch 1 taken 45512 times.
✓ Branch 2 taken 13552 times.
✓ Branch 3 taken 13552 times.
118128 auto values = initialAtPos(globalPos);
127
128
4/4
✓ Branch 0 taken 45512 times.
✓ Branch 1 taken 45512 times.
✓ Branch 2 taken 13552 times.
✓ Branch 3 taken 13552 times.
118128 if (globalPos[1] < 1e-6)
129 {
130 27000 values[N2Idx] = 1e-3;
131 if constexpr (enableHeatConduction)
132 {
133 6272 values[Indices::temperatureIdx] += 100; // DeltaT = 100 K
134 }
135 }
136
137 return values;
138 }
139
140 //! Evaluates the initial conditions.
141
4/4
✓ Branch 0 taken 22712 times.
✓ Branch 1 taken 22712 times.
✓ Branch 2 taken 9352 times.
✓ Branch 3 taken 9352 times.
78264 PrimaryVariables initialAtPos(const GlobalPosition& globalPos) const
142 {
143
2/4
✓ Branch 0 taken 6272 times.
✓ Branch 1 taken 6272 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17048 PrimaryVariables values;
144 17048 values[pressureIdx] = 1.0e5;
145 values[N2Idx] = 0.0;
146
147 if constexpr (enableHeatConduction)
148 {
149
4/4
✓ Branch 0 taken 28984 times.
✓ Branch 1 taken 28984 times.
✓ Branch 2 taken 9352 times.
✓ Branch 3 taken 9352 times.
81176 values[Indices::temperatureIdx] = this->spatialParams().temperatureAtPos(globalPos);
150 }
151
152 return values;
153 }
154
155 //! Returns reference to the coupling manager.
156 143907242 const CouplingManager& couplingManager() const
157
25/31
✓ Branch 0 taken 7467644 times.
✓ Branch 1 taken 15516716 times.
✓ Branch 3 taken 8511728 times.
✓ Branch 4 taken 735212 times.
✓ Branch 6 taken 7135028 times.
✓ Branch 7 taken 12654212 times.
✓ Branch 9 taken 5625866 times.
✓ Branch 10 taken 112224 times.
✓ Branch 11 taken 2351976 times.
✓ Branch 12 taken 29965782 times.
✓ Branch 14 taken 1056834 times.
✓ Branch 15 taken 8765788 times.
✓ Branch 17 taken 906810 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 919260 times.
✓ Branch 21 taken 861750 times.
✓ Branch 23 taken 8805580 times.
✗ Branch 24 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 27722 times.
✓ Branch 29 taken 1918830 times.
✓ Branch 30 taken 545088 times.
✓ Branch 31 taken 14917776 times.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✓ Branch 13 taken 3746144 times.
✓ Branch 16 taken 3746144 times.
✓ Branch 19 taken 3746144 times.
✓ Branch 22 taken 294924 times.
✓ Branch 8 taken 1261800 times.
145980986 { return *couplingManagerPtr_; }
158
159 private:
160 std::shared_ptr<CouplingManager> couplingManagerPtr_;
161 std::string problemName_;
162 };
163
164 } // end namespace Dumux
165
166 #endif
167