GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/multidomain/embedded/1d3d/1p2c_richards2c/spatialparams_root.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 17 31 54.8%
Functions: 1 6 16.7%
Branches: 23 56 41.1%

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 EmbeddedTests
10 * \brief The spatial parameters class for root xylem flow.
11 */
12
13 #ifndef DUMUX_ROOT_SPATIALPARAMS_HH
14 #define DUMUX_ROOT_SPATIALPARAMS_HH
15
16 #include <dumux/common/parameters.hh>
17 #include <dumux/io/grid/griddata.hh>
18 #include <dumux/material/components/simpleh2o.hh>
19 #include <dumux/porousmediumflow/fvspatialparams1p.hh>
20
21 namespace Dumux {
22
23 /*!
24 * \ingroup EmbeddedTests
25 * \brief Definition of the spatial parameters for the root xylem flow.
26 */
27 template<class GridGeometry, class Scalar>
28 class RootSpatialParams
29 : public FVPorousMediumFlowSpatialParamsOneP<GridGeometry, Scalar, RootSpatialParams<GridGeometry, Scalar>>
30 {
31 using ThisType = RootSpatialParams<GridGeometry, Scalar>;
32 using ParentType = FVPorousMediumFlowSpatialParamsOneP<GridGeometry, Scalar, ThisType>;
33 using Grid = typename GridGeometry::Grid;
34 using GridView = typename GridGeometry::GridView;
35 using Element = typename GridView::template Codim<0>::Entity;
36 using SubControlVolume = typename GridGeometry::SubControlVolume;
37 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
38
39 //! Indices to access the parameters in the dgf file
40 enum DGFParamIndices {
41 orderIdx = 0,
42 rootIdIdx = 1,
43 surfaceIdx = 2,
44 massIdx = 3,
45 plantIdx = 5
46 };
47
48 public:
49 // export permeability type
50 using PermeabilityType = Scalar;
51
52 1 RootSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry,
53 std::shared_ptr<const GridData<Grid>> gridData)
54
3/12
✓ 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.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
2 : ParentType(gridGeometry), gridData_(gridData)
55 {
56
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 porosity_ = getParam<Scalar>("Root.SpatialParams.Porosity", 0.4);
57
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 constantKx_ = getParam<Scalar>("Root.SpatialParams.Kx", 5.0968e-17);
58
1/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 constantKr_ = getParam<Scalar>("Root.SpatialParams.Kr", 2.04e-13);
59
60 2 const auto& gv = gridGeometry->gridView();
61
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 radii_.resize(gv.size(0));
62
5/6
✓ Branch 1 taken 1738 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1738 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1738 times.
3477 for (const auto& element : elements(gv))
63 {
64
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1738 times.
1738 const auto eIdx = gv.indexSet().index(element);
65 1738 auto level0element = element;
66
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1738 times.
3476 for(auto levelIdx = element.level(); levelIdx != 0; levelIdx--)
67 level0element = level0element.father();
68
2/4
✓ Branch 1 taken 1738 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1738 times.
✗ Branch 5 not taken.
1738 const Scalar rootLength = element.geometry().volume();
69
2/4
✓ Branch 1 taken 1738 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1738 times.
✗ Branch 5 not taken.
3476 const Scalar rootSurface = gridData_->parameters(level0element)[DGFParamIndices::surfaceIdx]/(1 << element.level());
70 3476 radii_[eIdx] = rootSurface / rootLength / 2.0 / M_PI;
71 }
72 1 }
73
74 /*!
75 * \brief Returns the intrinsic permeability for the current sub-control volume in [m^2].
76 *
77 * \note Kx has units [m^4/(Pa*s)] so we have to divide by the cross-section area
78 * and multiply with a characteristic viscosity
79 */
80 template<class ElementSolution>
81 PermeabilityType permeability(const Element& element,
82 const SubControlVolume& scv,
83 const ElementSolution& elemSol) const
84 {
85 const Scalar r = radius(this->gridGeometry().gridView().indexSet().index(element));
86 return constantKx_ / (M_PI*r*r) * Components::SimpleH2O<Scalar>::liquidViscosity(285.15, 1e5);
87 }
88
89 /*!
90 * \brief Returns the radius of the circular pipe for the current sub-control volume in [m].
91 *
92 * \param eIdxGlobal the index of the element
93 */
94 Scalar radius(std::size_t eIdxGlobal) const
95 {
96
4/8
✓ Branch 0 taken 670548 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 670548 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2853484 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2853484 times.
7056804 return radii_[eIdxGlobal];
97 }
98
99 /*!
100 * \brief Returns the radial permeability.
101 *
102 * \param eIdxGlobal the index of the element
103 */
104 Scalar Kr(std::size_t eIdxGlobal) const
105 {
106 return constantKr_;
107 }
108
109 const std::vector<Scalar>& getRadii() const
110
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 { return radii_; }
111
112 /*!
113 * \brief Returns the porosity \f$[-]\f$.
114 *
115 * \param globalPos the scv center
116 */
117 Scalar porosityAtPos(const GlobalPosition& globalPos) const
118 {
119 return porosity_;
120 }
121
122 /*!
123 * \brief Returns the temperature \f$[K]\f$.
124 *
125 * \param globalPos the scv center
126 */
127 Scalar temperatureAtPos(const GlobalPosition& globalPos) const
128 {
129 return 273.15 + 10.0;
130 }
131
132 /*!
133 * \brief Returns how much the domain is extruded at a given sub-control volume.
134 *
135 * The extrusion factor here extrudes the 1d line to a circular tube with
136 * cross-section area pi*r^2.
137 */
138 template<class ElementSolution>
139 Scalar extrusionFactor(const Element &element,
140 const SubControlVolume &scv,
141 const ElementSolution& elemSol) const
142 {
143 const auto eIdx = this->gridGeometry().elementMapper().index(element);
144 const auto r = radius(eIdx);
145 return M_PI*r*r;
146 }
147
148 private:
149 std::shared_ptr<const GridData<Grid>> gridData_;
150 Scalar porosity_, constantKx_, constantKr_;
151 std::vector<Scalar> radii_;
152 };
153
154 } // end namespace Dumux
155
156 #endif
157