GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/test/porousmediumflow/2pnc/fuelcell/spatialparams.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 14 14 100.0%
Functions: 2 2 100.0%
Branches: 8 16 50.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-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 TwoPNCTests
10 * \brief Definition of the spatial parameters for water management in PEM fuel cells.
11 */
12
13 #ifndef DUMUX_FUELCELL_SPATIAL_PARAMS_HH
14 #define DUMUX_FUELCELL_SPATIAL_PARAMS_HH
15
16 #include <dumux/porousmediumflow/properties.hh>
17 #include <dumux/porousmediumflow/fvspatialparamsmp.hh>
18 #include <dumux/material/fluidmatrixinteractions/2p/vangenuchten.hh>
19
20 namespace Dumux {
21 /*!
22 * \ingroup TwoPNCTests
23 * \brief Definition of the spatial parameters for water management in PEM fuel cells.
24 */
25 template<class GridGeometry, class Scalar>
26
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 class FuelCellSpatialParams
27 : public FVPorousMediumFlowSpatialParamsMP<GridGeometry, Scalar,
28 FuelCellSpatialParams<GridGeometry, Scalar>>
29 {
30 using GridView = typename GridGeometry::GridView;
31 using ThisType = FuelCellSpatialParams<GridGeometry, Scalar>;
32 using ParentType = FVPorousMediumFlowSpatialParamsMP<GridGeometry, Scalar, ThisType>;
33
34 static constexpr int dimWorld = GridView::dimensionworld;
35
36 using Element = typename GridGeometry::GridView::template Codim<0>::Entity;
37 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
38
39 using DimWorldMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
40
41 using PcKrSwCurve = FluidMatrix::VanGenuchtenDefault<Scalar>;
42
43 public:
44 using PermeabilityType = DimWorldMatrix;
45
46 3 FuelCellSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry)
47 : ParentType(gridGeometry)
48 6 , K_(0)
49
3/6
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
9 , pcKrSwCurve_("SpatialParams")
50 {
51 // intrinsic permeabilities
52
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 K_[0][0] = 5e-11;
53 3 K_[1][1] = 5e-11;
54
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 temperature_ = getParam<Scalar>("Problem.InitialTemperature");
55 3 }
56
57 /*!
58 * \brief Returns the hydraulic conductivity \f$[m^2]\f$
59 *
60 * \param globalPos The global position
61 */
62 301713 DimWorldMatrix permeabilityAtPos(const GlobalPosition& globalPos) const
63 301713 { return K_; }
64
65 /*!
66 * \brief Defines the porosity \f$[-]\f$ of the spatial parameters
67 *
68 * \param globalPos The global position
69 */
70 Scalar porosityAtPos(const GlobalPosition& globalPos) const
71 { return 0.2; }
72
73 /*!
74 * \brief Returns the fluid-matrix interaction law at a given location
75 * \param globalPos A global coordinate vector
76 */
77 603426 auto fluidMatrixInteractionAtPos(const GlobalPosition &globalPos) const
78 {
79
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 301713 times.
603426 return makeFluidMatrixInteraction(pcKrSwCurve_);
80 }
81
82 /*!
83 * \brief Function for defining which phase is to be considered as the wetting phase.
84 *
85 * \param globalPos The position of the center of the element
86 * \return The wetting phase index
87 * \note We set a hydrophobic material.
88 */
89 template<class FluidSystem>
90 int wettingPhaseAtPos(const GlobalPosition& globalPos) const
91 { return FluidSystem::gasPhaseIdx; }
92
93 /*!
94 * \brief Returns the temperature in the domain at the given position
95 * \param globalPos The position in global coordinates where the temperature should be specified.
96 */
97 164479 Scalar temperatureAtPos(const GlobalPosition& globalPos) const
98 {
99
1/2
✓ Branch 1 taken 630 times.
✗ Branch 2 not taken.
164479 return temperature_;
100 }
101
102 private:
103 DimWorldMatrix K_;
104 static constexpr Scalar eps_ = 1e-6;
105 const PcKrSwCurve pcKrSwCurve_;
106 Scalar temperature_;
107 };
108
109 } // end namespace Dumux
110
111 #endif
112