GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/multidomain/boundary/freeflowporousmedium/1p_1p/problem_darcy.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 18 25 72.0%
Functions: 2 5 40.0%
Branches: 32 74 43.2%

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 BoundaryTests
10 * \brief A simple Darcy test problem (cell-centered finite volume method).
11 */
12
13 #ifndef DUMUX_DARCY_SUBPROBLEM_HH
14 #define DUMUX_DARCY_SUBPROBLEM_HH
15
16 #include <dumux/common/boundarytypes.hh>
17 #include <dumux/common/numeqvector.hh>
18 #include <dumux/common/properties.hh>
19 #include <dumux/common/parameters.hh>
20
21 #include <dumux/porousmediumflow/problem.hh>
22
23 namespace Dumux {
24
25 template <class TypeTag>
26 class DarcySubProblem : public PorousMediumFlowProblem<TypeTag>
27 {
28 using ParentType = PorousMediumFlowProblem<TypeTag>;
29 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
30 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
31 using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
32 using NumEqVector = Dumux::NumEqVector<GetPropType<TypeTag, Properties::PrimaryVariables>>;
33 using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
34 using VolumeVariables = GetPropType<TypeTag, Properties::VolumeVariables>;
35 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
36 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
37 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
38 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
39
40 using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
41
42 using Element = typename GridView::template Codim<0>::Entity;
43 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
44
45 using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>;
46
47 public:
48 2 DarcySubProblem(std::shared_ptr<const GridGeometry> gridGeometry,
49 std::shared_ptr<CouplingManager> couplingManager)
50
6/18
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✓ Branch 17 taken 2 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
6 : ParentType(gridGeometry, "Darcy"), eps_(1e-7), couplingManager_(couplingManager)
51 {
52
7/22
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 2 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 2 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
2 problemName_ = getParam<std::string>("Vtk.OutputName")
53
2/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
4 + "_" + getParamFromGroup<std::string>(this->paramGroup(), "Problem.Name");
54
55 // determine whether to simulate a vertical or horizontal flow configuration
56 2 verticalFlow_ = problemName_.find("vertical") != std::string::npos;
57 2 }
58
59 /*!
60 * \brief The problem name.
61 */
62 const std::string& name() const
63
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 { return problemName_; }
64
65 /*!
66 * \name Boundary conditions
67 */
68 // \{
69
70 /*!
71 * \brief Specifies which kind of boundary condition should be
72 * used for which equation on a given boundary control volume.
73 *
74 * \param element The element
75 * \param scvf The boundary sub control volume face
76 */
77 1792 BoundaryTypes boundaryTypes(const Element &element, const SubControlVolumeFace &scvf) const
78 {
79 1792 BoundaryTypes values;
80 1792 values.setAllNeumann();
81
82
2/2
✓ Branch 0 taken 680 times.
✓ Branch 1 taken 1112 times.
1792 if (couplingManager().isCoupled(CouplingManager::porousMediumIndex, CouplingManager::freeFlowMassIndex, scvf))
83 values.setAllCouplingNeumann();
84
85
2/2
✓ Branch 0 taken 896 times.
✓ Branch 1 taken 896 times.
1792 if (verticalFlow_)
86 {
87
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 716 times.
896 if (onLowerBoundary_(scvf.center()))
88 values.setAllDirichlet();
89 }
90
91 1792 return values;
92 }
93
94 /*!
95 * \brief Evaluates the boundary conditions for a Dirichlet control volume.
96 *
97 * \param element The element for which the Dirichlet boundary condition is set
98 * \param scvf The boundary sub-control-volume-face
99 */
100 PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const
101 60 { return initial(element); }
102
103 /*!
104 * \brief Evaluates the boundary conditions for a Neumann control volume.
105 *
106 * \param element The element for which the Neumann boundary condition is set
107 * \param fvGeometry The fvGeometry
108 * \param elemVolVars The element volume variables
109 * \param elemFluxVarsCache Flux variables caches for all faces in stencil
110 * \param scvf The boundary sub control volume face
111 */
112 template<class ElementVolumeVariables, class ElementFluxVarsCache>
113 NumEqVector neumann(const Element& element,
114 const FVElementGeometry& fvGeometry,
115 const ElementVolumeVariables& elemVolVars,
116 const ElementFluxVarsCache& elemFluxVarsCache,
117 const SubControlVolumeFace& scvf) const
118 {
119 NumEqVector values(0.0);
120
121 if (couplingManager().isCoupled(CouplingManager::porousMediumIndex, CouplingManager::freeFlowMassIndex, scvf))
122 values[Indices::conti0EqIdx] = couplingManager().massCouplingCondition(
123 CouplingManager::porousMediumIndex, CouplingManager::freeFlowMassIndex,
124 fvGeometry, scvf, elemVolVars
125 );
126
127 return values;
128 }
129
130 // \}
131
132 /*!
133 * \brief Evaluates the initial value for a control volume.
134 * \param element The element
135 */
136 PrimaryVariables initial(const Element &element) const
137 60 { return PrimaryVariables(0.0); }
138
139 // \}
140
141 //! Get the coupling manager
142 const CouplingManager& couplingManager() const
143
0/8
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
3584 { return *couplingManager_; }
144
145 private:
146
147 bool onLowerBoundary_(const GlobalPosition &globalPos) const
148
10/10
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 716 times.
✓ Branch 2 taken 180 times.
✓ Branch 3 taken 716 times.
✓ Branch 4 taken 180 times.
✓ Branch 5 taken 716 times.
✓ Branch 6 taken 180 times.
✓ Branch 7 taken 716 times.
✓ Branch 8 taken 180 times.
✓ Branch 9 taken 716 times.
4480 { return globalPos[1] < this->gridGeometry().bBoxMin()[1] + eps_; }
149
150 Scalar eps_;
151 std::shared_ptr<CouplingManager> couplingManager_;
152 std::string problemName_;
153 bool verticalFlow_;
154 };
155
156 } // end namespace Dumux
157
158 #endif
159