GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/porousmediumflow/1p/internaldirichlet/problem.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 14 19 73.7%
Functions: 2 8 25.0%
Branches: 60 100 60.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 OnePTests
10 * \brief A test for internal Dirichlet constraints
11 */
12
13 #ifndef DUMUX_INCOMPRESSIBLE_ONEP_TEST_PROBLEM_INTERNAL_DIRICHLET_HH
14 #define DUMUX_INCOMPRESSIBLE_ONEP_TEST_PROBLEM_INTERNAL_DIRICHLET_HH
15
16 #include <dumux/common/boundarytypes.hh>
17 #include <dumux/common/numeqvector.hh>
18
19 #include <test/porousmediumflow/1p/incompressible/problem.hh>
20
21 namespace Dumux {
22 /*!
23 * \ingroup OnePTests
24 * \brief A test for internal Dirichlet constraints
25 */
26 template<class TypeTag>
27 6 class OnePTestProblemInternalDirichlet : public OnePTestProblem<TypeTag>
28 {
29 using ParentType = OnePTestProblem<TypeTag>;
30 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
31 using Element = typename GridView::template Codim<0>::Entity;
32 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
33 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
34 using NeumannValues = Dumux::NumEqVector<PrimaryVariables>;
35 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
36 using BoundaryTypes = Dumux::BoundaryTypes<ModelTraits::numEq()>;
37 using Indices = typename ModelTraits::Indices;
38 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
39 using SubControlVolume = typename GridGeometry::SubControlVolume;
40 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
41
42 static constexpr auto numEq = ModelTraits::numEq();
43
44 public:
45 2 OnePTestProblemInternalDirichlet(std::shared_ptr<const GridGeometry> gridGeometry)
46
2/6
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2 : ParentType(gridGeometry)
47 2 {}
48
49 /*!
50 * \brief Specifies which kind of boundary condition should be
51 * used for which equation on a given boundary control volume.
52 *
53 * \param globalPos The position of the center of the finite volume
54 */
55 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
56 {
57
4/10
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 120 times.
508 BoundaryTypes values;
58
4/10
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 120 times.
508 values.setAllNeumann();
59 return values;
60 }
61
62 /*!
63 * \brief Evaluate the boundary conditions for a neumann
64 * boundary segment.
65 *
66 * \param globalPos The position of the boundary face's integration point in global coordinates
67 *
68 * Negative values mean influx.
69 * E.g. for the mass balance that would be the mass flux in \f$ [ kg / (m^2 \cdot s)] \f$.
70 */
71 NeumannValues neumannAtPos(const GlobalPosition& globalPos) const
72 {
73
4/6
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 180 times.
✓ Branch 3 taken 60 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
360 const auto& gg = this->gridGeometry();
74
16/24
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 90 times.
✓ Branch 5 taken 30 times.
✓ Branch 6 taken 90 times.
✓ Branch 7 taken 30 times.
✓ Branch 8 taken 180 times.
✓ Branch 9 taken 60 times.
✓ Branch 10 taken 180 times.
✓ Branch 11 taken 60 times.
✓ Branch 12 taken 180 times.
✓ Branch 13 taken 60 times.
✓ Branch 14 taken 180 times.
✓ Branch 15 taken 60 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1440 if (globalPos[0] < gg.bBoxMin()[0] + eps_)
75 return NeumannValues(1e3);
76
16/24
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 60 times.
✓ Branch 5 taken 30 times.
✓ Branch 6 taken 60 times.
✓ Branch 7 taken 30 times.
✓ Branch 8 taken 120 times.
✓ Branch 9 taken 60 times.
✓ Branch 10 taken 120 times.
✓ Branch 11 taken 60 times.
✓ Branch 12 taken 120 times.
✓ Branch 13 taken 60 times.
✓ Branch 14 taken 120 times.
✓ Branch 15 taken 60 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
1080 else if (globalPos[1] < gg.bBoxMin()[1] + eps_)
77 return NeumannValues(-1e3);
78 else
79 180 return NeumannValues(0.0);
80 }
81
82 //! Enable internal Dirichlet constraints
83 static constexpr bool enableInternalDirichletConstraints()
84 { return true; }
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<numEq> hasInternalDirichletConstraint(const Element& element,
97 const SubControlVolume& scv) const
98 {
99 // the pure Neumann problem is only defined up to a constant
100 // we create a well-posed problem by fixing the pressure at one dof in the middle of the domain
101 1500 std::bitset<numEq> values;
102
14/20
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 792 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 794 times.
✓ Branch 4 taken 206 times.
✓ Branch 5 taken 792 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 4 times.
✓ Branch 13 taken 396 times.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 396 times.
✓ Branch 16 taken 4 times.
✓ Branch 17 taken 396 times.
✓ Branch 19 taken 1 times.
✓ Branch 20 taken 99 times.
4500 if (scv.dofIndex() == static_cast<std::size_t>(this->gridGeometry().numDofs()/2))
103 15 values.set(Indices::pressureIdx);
104 return values;
105 }
106
107 /*!
108 * \brief Define the values of internal Dirichlet constraints for a degree of freedom.
109 * \param element The finite element
110 * \param scv The sub-control volume
111 */
112 PrimaryVariables internalDirichlet(const Element& element, const SubControlVolume& scv) const
113 106 { return PrimaryVariables(1e5); }
114
115 private:
116 static constexpr Scalar eps_ = 1.5e-7;
117 };
118
119 } // end namespace Dumux
120
121 #endif
122