GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/test/porousmediumflow/mpnc/thermalnonequilibrium/spatialparams.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 0 40 0.0%
Functions: 0 9 0.0%
Branches: 0 74 0.0%

Line Branch Exec Source
1 //
2 // SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
3 // SPDX-License-Identifier: GPL-3.0-or-later
4 //
5 /*!
6 * \file
7 * \ingroup MPNCTests
8 * \brief Spatialparameters for the combustionproblem1c.
9 *
10 * Parameters for the actual simulation domain and an outflow region are provided.
11 */
12
13 #ifndef DUMUX_COMBUSTION_SPATIALPARAMS_HH
14 #define DUMUX_COMBUSTION_SPATIALPARAMS_HH
15
16 #include <dune/common/parametertreeparser.hh>
17 #include <dune/common/math.hh>
18
19 #include <dumux/porousmediumflow/fvspatialparamsnonequilibrium.hh>
20 #include <dumux/material/fluidmatrixinteractions/2p/heatpipelaw.hh>
21 #include <dumux/material/fluidmatrixinteractions/mp/mpadapter.hh>
22 #include <dumux/material/fluidmatrixinteractions/1pia/fluidsolidinterfacialareashiwang.hh>
23 #include <dumux/porousmediumflow/properties.hh>
24
25 namespace Dumux {
26
27 /**
28 * \brief Definition of the spatial parameters for the one component combustion problem
29 */
30 template<class GridGeometry, class Scalar>
31 class CombustionSpatialParams
32 : public FVPorousMediumFlowSpatialParamsNonEquilibrium<GridGeometry, Scalar,
33 CombustionSpatialParams<GridGeometry, Scalar>>
34 {
35 using GridView = typename GridGeometry::GridView;
36 using FVElementGeometry = typename GridGeometry::LocalView;
37 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
38 using Element = typename GridView::template Codim<0>::Entity;
39 using ThisType = CombustionSpatialParams<GridGeometry, Scalar>;
40 using ParentType = FVPorousMediumFlowSpatialParamsNonEquilibrium<GridGeometry, Scalar, ThisType>;
41
42 enum {dimWorld = GridView::dimensionworld};
43 using GlobalPosition = typename SubControlVolume::GlobalPosition;
44
45 using PcKrSwCurve = FluidMatrix::HeatPipeLaw<Scalar>;
46
47 public:
48 //! Export the type used for the permeability
49 using PermeabilityType = Scalar;
50 using FluidSolidInterfacialAreaFormulation = FluidSolidInterfacialAreaShiWang<Scalar>;
51
52
53 CombustionSpatialParams(std::shared_ptr<const GridGeometry> gridGeometry) : ParentType(gridGeometry)
54 {
55 // this is the parameter value from file part
56 porosity_ = getParam<Scalar>("SpatialParams.PorousMedium.porosity");
57 intrinsicPermeabilityOutFlow_ = getParam<Scalar>("SpatialParams.Outflow.permeabilityOutFlow");
58 porosityOutFlow_ = getParam<Scalar>("SpatialParams.Outflow.porosityOutFlow");
59 interfacialTension_ = getParam<Scalar>("Constants.interfacialTension");
60
61 characteristicLength_ =getParam<Scalar>("SpatialParams.PorousMedium.meanPoreSize");
62
63 using Dune::power;
64 intrinsicPermeability_ = (power(characteristicLength_,2) * power(porosity_, 3)) / (150.0 * power((1.0-porosity_),2)); // 1.69e-10 ; //
65
66 factorEnergyTransfer_ = getParam<Scalar>("SpatialParams.PorousMedium.factorEnergyTransfer");
67 lengthPM_ = getParam<Scalar>("Grid.lengthPM");
68
69 using std::sqrt;
70 const Scalar p0 = sqrt(porosity_/intrinsicPermeability_);
71 const Scalar gamma = interfacialTension_; // interfacial tension of water-air at 100°C
72 typename PcKrSwCurve::Params params(p0, gamma);
73
74 typename PcKrSwCurve::EffToAbsParams effToAbsParams;
75 effToAbsParams.setSwr(getParam<Scalar>("SpatialParams.soil.Swr"));
76 effToAbsParams.setSnr(getParam<Scalar>("SpatialParams.soil.Snr"));
77
78 pcKrSwCurve_ = std::make_unique<PcKrSwCurve>(params, effToAbsParams);
79 }
80
81 template<class ElementSolution>
82 PermeabilityType permeability(const Element& element,
83 const SubControlVolume& scv,
84 const ElementSolution& elemSol) const
85 {
86 const auto& globalPos = scv.dofPosition();
87 if ( inOutFlow(globalPos) )
88 return intrinsicPermeabilityOutFlow_ ;
89 else
90 return intrinsicPermeability_ ;
91 }
92
93 /*!
94 * \brief Function for defining the porosity which is possibly solution dependent.
95 *
96 * \param element The current element
97 * \param scv The sub-control volume inside the element.
98 * \param elemSol The solution at the dofs connected to the element.
99 * \return The porosity
100 */
101 template<class ElementSolution>
102 Scalar porosity(const Element& element,
103 const SubControlVolume& scv,
104 const ElementSolution& elemSol) const
105 {
106 if (inOutFlow(scv.dofPosition()))
107 return porosityOutFlow_;
108 else
109 return porosity_;
110 }
111
112 /*!
113 * \brief Function for defining the porosity which is possibly solution dependent.
114 *
115 * \param element The current element
116 * \param scv The sub-control volume inside the element.
117 * \param elemSol The solution at the dofs connected to the element.
118 * \param compIdx The index of the component
119 * \return The porosity
120 */
121 template<class SolidSystem, class ElementSolution>
122 Scalar inertVolumeFraction(const Element& element,
123 const SubControlVolume& scv,
124 const ElementSolution& elemSol,
125 int compIdx) const
126 {
127 if (compIdx == SolidSystem::comp0Idx)
128 {
129 if (inOutFlow(scv.dofPosition()))
130 return 1.0-porosityOutFlow_;
131 else
132 return 0;
133 }
134 else
135 {
136 if (inOutFlow(scv.dofPosition()))
137 return 0;
138 else
139 return 1.0-porosity_;
140 }
141 }
142
143 /*!
144 * \brief Function for defining which phase is to be considered as the wetting phase.
145 *
146 * \param globalPos The global position
147 * \return The wetting phase index
148 */
149 template<class FluidSystem>
150 int wettingPhaseAtPos(const GlobalPosition& globalPos) const
151 {
152 return FluidSystem::phase0Idx;
153 }
154
155 /*!
156 * \brief Returns the characteristic length for the mass transfer.
157 * \param globalPos The position in global coordinates.
158 */
159 const Scalar characteristicLengthAtPos(const GlobalPosition & globalPos) const
160 { return characteristicLength_ ; }
161
162 /*!
163 * \brief Returns the pre factor the the energy transfer
164 * \param globalPos The position in global coordinates.
165 */
166 const Scalar factorEnergyTransferAtPos(const GlobalPosition & globalPos) const
167 { return factorEnergyTransfer_; }
168
169 //! Returns if the tested position is at the right end of the porous medium.
170 bool inOutFlow(const GlobalPosition & globalPos) const { return globalPos[0] > (lengthPM_ - eps_) ; }
171 //! Returns the length of the porous medium domain
172 Scalar lengthPM() const { return lengthPM_ ; }
173 //! Returns the interfacial tension
174 Scalar interfacialTension() const { return interfacialTension_ ; }
175
176 /*!
177 * \brief Returns the fluid-matrix interaction law at a given location
178 * \param globalPos A global coordinate vector
179 */
180 auto fluidMatrixInteractionAtPos(const GlobalPosition &globalPos) const
181 {
182 return makeFluidMatrixInteraction(FluidMatrix::MPAdapter(*pcKrSwCurve_));
183 }
184
185 private:
186 static constexpr Scalar eps_ = 1e-6;
187
188 // Porous Medium Domain
189 Scalar intrinsicPermeability_ ;
190 Scalar porosity_ ;
191 Scalar factorEnergyTransfer_ ;
192 Scalar characteristicLength_ ;
193
194 // Outflow Domain
195 Scalar intrinsicPermeabilityOutFlow_ ;
196 Scalar porosityOutFlow_ ;
197
198 // solid parameters
199 Scalar interfacialTension_ ;
200
201 // grid
202 Scalar lengthPM_ ;
203
204 std::unique_ptr<PcKrSwCurve> pcKrSwCurve_;
205 };
206
207 }
208
209 #endif
210