GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/test/porousmediumflow/1pnc/1p2c/isothermal/saltwaterintrusion/problem.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 18 18 100.0%
Functions: 2 2 100.0%
Branches: 17 26 65.4%

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 OnePNCTests
10 * \brief Definition of a problem involving salt
11 * water intrusion into a fresh water aquifer.
12 */
13
14 #ifndef DUMUX_SALTWATERINTRUSION_TEST_PROBLEM_HH
15 #define DUMUX_SALTWATERINTRUSION_TEST_PROBLEM_HH
16
17 #include <dumux/common/properties.hh>
18 #include <dumux/common/parameters.hh>
19
20 #include <dumux/common/boundarytypes.hh>
21 #include <dumux/porousmediumflow/problem.hh>
22
23 namespace Dumux {
24
25 /*!
26 * \ingroup OnePNCTests
27 * \brief Definition of a problem involving salt water intrusion into a
28 * fresh water aquifer.
29 *
30 * The aquifer is in contact with salt water with a specific salinity on the
31 * right boundary.
32 */
33 template <class TypeTag>
34 1 class SaltWaterIntrusionTestProblem : public PorousMediumFlowProblem<TypeTag>
35 {
36 using ParentType = PorousMediumFlowProblem<TypeTag>;
37
38 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
39 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
40 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
41 using Element = typename GridView::template Codim<0>::Entity;
42 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
43 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
44 using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
45 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
46 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
47
48 // copy pressure index for convenience
49 enum { pressureIdx = Indices::pressureIdx };
50
51 //! The test is defined using mass fractions
52 static_assert(!getPropValue<TypeTag, Properties::UseMoles>(), "This test uses mass fractions!");
53
54 public:
55 1 SaltWaterIntrusionTestProblem(std::shared_ptr<const GridGeometry> gridGeometry)
56
3/6
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
3 : ParentType(gridGeometry)
57 {
58 //initialize fluid system
59 FluidSystem::init();
60 1 }
61
62 /*!
63 * \name Problem parameters
64 */
65 // \{
66
67 // \}
68
69 /*!
70 * \name Boundary conditions
71 */
72 // \{
73
74 /*!
75 * \brief Specifies which kind of boundary condition should be
76 * used for which equation on a given boundary segment.
77 *
78 * \param globalPos The position for which the bc type should be evaluated
79 */
80 9312 BoundaryTypes boundaryTypesAtPos(const GlobalPosition& globalPos) const
81 {
82
2/2
✓ Branch 0 taken 18624 times.
✓ Branch 1 taken 9312 times.
27936 BoundaryTypes values;
83
2/2
✓ Branch 0 taken 8342 times.
✓ Branch 1 taken 970 times.
9312 values.setAllNeumann();
84
85 // use Dirichlet BCs on the left and right boundary
86
4/4
✓ Branch 0 taken 8342 times.
✓ Branch 1 taken 970 times.
✓ Branch 2 taken 970 times.
✓ Branch 3 taken 7372 times.
9312 if(globalPos[0] < eps_ || globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_)
87 9312 values.setAllDirichlet();
88
89 9312 return values;
90 }
91
92 /*!
93 * \brief Evaluates the boundary conditions for a Dirichlet boundary segment.
94 *
95 * \param globalPos The position for which the bc type should be evaluated
96 */
97 1940 PrimaryVariables dirichletAtPos(const GlobalPosition& globalPos) const
98 {
99 1940 PrimaryVariables values = initialAtPos(globalPos);
100
101 // salt water is in contact on the right boundary
102
2/4
✓ Branch 0 taken 970 times.
✓ Branch 1 taken 970 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1940 if (globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_)
103 970 values[FluidSystem::NaClIdx] = 0.035; // 3.5% salinity (sea water)
104
105 return values;
106 }
107
108 // \}
109
110 /*!
111 * \name Volume terms
112 */
113 // \{
114
115 /*!
116 * \brief Evaluates the initial value for a control volume.
117 *
118 * \param globalPos The position for which the initial condition should be evaluated
119 */
120 2066 PrimaryVariables initialAtPos(const GlobalPosition& globalPos) const
121 {
122
2/4
✓ Branch 0 taken 970 times.
✓ Branch 1 taken 970 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1940 const Scalar depth = this->gridGeometry().bBoxMax()[1] - globalPos[1];
123 2066 PrimaryVariables priVars;
124
2/4
✓ Branch 0 taken 970 times.
✓ Branch 1 taken 970 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1940 priVars[pressureIdx] = 1e5 + depth*9.81*1000; // hydrostatic pressure (assume rho_water = 1000.0)
125 priVars[FluidSystem::NaClIdx] = 0.0; // initially only fresh water is present
126 return priVars;
127 }
128
129 // \}
130
131 private:
132 static constexpr Scalar eps_ = 1e-6;
133 };
134
135 } // end namespace Dumux
136
137 #endif
138