| 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 OnePNCTests | ||
| 10 | * \brief Test for the OnePNCModel in combination with the NI model with transient boundary conditions. | ||
| 11 | * | ||
| 12 | * The simulation domain is a tube with an elevated temperature on the left hand side. | ||
| 13 | */ | ||
| 14 | #ifndef DUMUX_1P2CNI_TRANSIENT_BC_TEST_PROBLEM_HH | ||
| 15 | #define DUMUX_1P2CNI_TRANSIENT_BC_TEST_PROBLEM_HH | ||
| 16 | |||
| 17 | #include <dumux/common/properties.hh> | ||
| 18 | #include <dumux/common/parameters.hh> | ||
| 19 | |||
| 20 | #include <dumux/common/boundarytypes.hh> | ||
| 21 | #include <dumux/common/numeqvector.hh> | ||
| 22 | #include <dumux/porousmediumflow/problem.hh> | ||
| 23 | #include <dumux/material/components/h2o.hh> | ||
| 24 | |||
| 25 | namespace Dumux { | ||
| 26 | |||
| 27 | /*! | ||
| 28 | * \ingroup OnePNCTests | ||
| 29 | * \brief Test for the OnePTwoCModel in combination with the NI model for a convection problem. | ||
| 30 | * | ||
| 31 | * The simulation domain is a tube where water with an elevated temperature is injected | ||
| 32 | * at a constant rate on the left hand side. | ||
| 33 | * | ||
| 34 | * Initially, the domain is fully saturated with water at a constant temperature. | ||
| 35 | * On the left hand side water is injected at a constant rate and on the right hand side | ||
| 36 | * a Dirichlet boundary with constant pressure, saturation and temperature is applied. | ||
| 37 | * | ||
| 38 | * The results are compared to an analytical solution where a retarded front velocity is calculated as follows: | ||
| 39 | \f[ | ||
| 40 | v_{Front}=\frac{q S_{water}}{\phi S_{total}} | ||
| 41 | \f] | ||
| 42 | * | ||
| 43 | * The result of the analytical solution is written into the vtu files. | ||
| 44 | * | ||
| 45 | * This problem uses the \ref OnePModel and \ref NIModel model. | ||
| 46 | */ | ||
| 47 | |||
| 48 | template <class TypeTag> | ||
| 49 | 6 | class OnePTwoCNITransientBCProblem : public PorousMediumFlowProblem<TypeTag> | |
| 50 | { | ||
| 51 | using ParentType = PorousMediumFlowProblem<TypeTag>; | ||
| 52 | |||
| 53 | using Scalar = GetPropType<TypeTag, Properties::Scalar>; | ||
| 54 | using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices; | ||
| 55 | using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView; | ||
| 56 | using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>; | ||
| 57 | using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>; | ||
| 58 | using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>; | ||
| 59 | using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; | ||
| 60 | using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView; | ||
| 61 | using NumEqVector = Dumux::NumEqVector<PrimaryVariables>; | ||
| 62 | using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView; | ||
| 63 | using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace; | ||
| 64 | using Element = typename GridView::template Codim<0>::Entity; | ||
| 65 | using SolutionVector = GetPropType<TypeTag, Properties::SolutionVector>; | ||
| 66 | using VolumeVariables = GetPropType<TypeTag, Properties::VolumeVariables>; | ||
| 67 | using IapwsH2O = Components::H2O<Scalar>; | ||
| 68 | |||
| 69 | // copy some indices for convenience | ||
| 70 | enum | ||
| 71 | { | ||
| 72 | // indices of the primary variables | ||
| 73 | pressureIdx = Indices::pressureIdx, | ||
| 74 | temperatureIdx = Indices::temperatureIdx, | ||
| 75 | |||
| 76 | // component indices | ||
| 77 | H2OIdx = FluidSystem::compIdx(FluidSystem::MultiPhaseFluidSystem::H2OIdx), | ||
| 78 | N2Idx = FluidSystem::compIdx(FluidSystem::MultiPhaseFluidSystem::N2Idx), | ||
| 79 | |||
| 80 | // indices of the equations | ||
| 81 | contiH2OEqIdx = Indices::conti0EqIdx + H2OIdx, | ||
| 82 | contiN2EqIdx = Indices::conti0EqIdx + N2Idx, | ||
| 83 | energyEqIdx = Indices::energyEqIdx | ||
| 84 | }; | ||
| 85 | |||
| 86 | //! Property that defines whether mole or mass fractions are used | ||
| 87 | static constexpr bool useMoles = getPropValue<TypeTag, Properties::UseMoles>(); | ||
| 88 | static const int dimWorld = GridView::dimensionworld; | ||
| 89 | using GlobalPosition = typename SubControlVolumeFace::GlobalPosition; | ||
| 90 | |||
| 91 | public: | ||
| 92 | 6 | OnePTwoCNITransientBCProblem(std::shared_ptr<const GridGeometry> gridGeometry) | |
| 93 |
3/6✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
|
18 | : ParentType(gridGeometry) |
| 94 | { | ||
| 95 | //initialize fluid system | ||
| 96 | FluidSystem::init(); | ||
| 97 | |||
| 98 | // stating in the console whether mole or mass fractions are used | ||
| 99 | if(useMoles) | ||
| 100 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
6 | std::cout<<"problem uses mole fractions"<<std::endl; |
| 101 | else | ||
| 102 | std::cout<<"problem uses mass fractions"<<std::endl; | ||
| 103 | 6 | } | |
| 104 | |||
| 105 | /*! | ||
| 106 | * \name Boundary conditions | ||
| 107 | */ | ||
| 108 | // \{ | ||
| 109 | |||
| 110 | /*! | ||
| 111 | * \brief Specifies which kind of boundary condition should be | ||
| 112 | * used for which equation on a given boundary segment. | ||
| 113 | * | ||
| 114 | * \param globalPos The position for which the bc type should be evaluated | ||
| 115 | */ | ||
| 116 | 2076996 | BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const | |
| 117 | { | ||
| 118 |
2/2✓ Branch 0 taken 2069914 times.
✓ Branch 1 taken 7082 times.
|
2076996 | BoundaryTypes values; |
| 119 | |||
| 120 |
6/6✓ Branch 0 taken 2069914 times.
✓ Branch 1 taken 7082 times.
✓ Branch 2 taken 7082 times.
✓ Branch 3 taken 2062832 times.
✓ Branch 4 taken 2062832 times.
✓ Branch 5 taken 14164 times.
|
2091160 | if(globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_ || globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_) |
| 121 | 2076996 | values.setAllDirichlet(); | |
| 122 | else | ||
| 123 | 2076996 | values.setAllNeumann(); | |
| 124 | |||
| 125 | 2076996 | return values; | |
| 126 | } | ||
| 127 | |||
| 128 | /*! | ||
| 129 | * \brief Evaluates the boundary conditions for a Dirichlet boundary segment. | ||
| 130 | * | ||
| 131 | * \param globalPos The position for which the bc type should be evaluated | ||
| 132 | */ | ||
| 133 | 4356 | PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const | |
| 134 | { | ||
| 135 |
2/2✓ Branch 0 taken 2178 times.
✓ Branch 1 taken 2178 times.
|
4356 | PrimaryVariables values = initial_(globalPos); |
| 136 | |||
| 137 | // make the BCs on the left border time-dependent | ||
| 138 |
2/2✓ Branch 0 taken 2178 times.
✓ Branch 1 taken 2178 times.
|
4356 | if (globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_) |
| 139 | { | ||
| 140 | 2178 | values[pressureIdx] += time_ * 1.0; | |
| 141 | 2178 | values[N2Idx] += time_ * 1e-8; | |
| 142 | 2178 | values[temperatureIdx] += time_ * 1e-3; | |
| 143 | } | ||
| 144 | |||
| 145 | 4356 | return values; | |
| 146 | } | ||
| 147 | |||
| 148 | /*! | ||
| 149 | * \brief Evaluates the boundary conditions for a Neumann boundary segment. | ||
| 150 | */ | ||
| 151 | 2389080 | NumEqVector neumannAtPos(const GlobalPosition& globalPos) const | |
| 152 | { | ||
| 153 |
2/2✓ Branch 0 taken 333440 times.
✓ Branch 1 taken 232576 times.
|
4778160 | return NumEqVector(0.0); |
| 154 | } | ||
| 155 | |||
| 156 | // \} | ||
| 157 | |||
| 158 | /*! | ||
| 159 | * \name Volume terms | ||
| 160 | */ | ||
| 161 | // \{ | ||
| 162 | |||
| 163 | /*! | ||
| 164 | * \brief Evaluates the source term for all phases within a given | ||
| 165 | * sub-control volume. | ||
| 166 | * | ||
| 167 | * For this method, the \a priVars parameter stores the rate mass | ||
| 168 | * of a component is generated or annihilated per volume | ||
| 169 | * unit. Positive values mean that mass is created, negative ones | ||
| 170 | * mean that it vanishes. | ||
| 171 | * | ||
| 172 | * The units must be according to either using mole or mass fractions (mole/(m^3*s) or kg/(m^3*s)). | ||
| 173 | */ | ||
| 174 | 1488640 | NumEqVector sourceAtPos(const GlobalPosition &globalPos) const | |
| 175 |
2/2✓ Branch 0 taken 4465920 times.
✓ Branch 1 taken 1488640 times.
|
7443200 | { return NumEqVector(0.0); } |
| 176 | |||
| 177 | /*! | ||
| 178 | * \brief Evaluates the initial value for a control volume. | ||
| 179 | * | ||
| 180 | * \param globalPos The position for which the initial condition should be evaluated | ||
| 181 | * | ||
| 182 | * For this method, the \a values parameter stores primary | ||
| 183 | * variables. | ||
| 184 | */ | ||
| 185 | 644 | PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const | |
| 186 | 644 | { return initial_(globalPos); } | |
| 187 | |||
| 188 | /*! | ||
| 189 | * \brief Set the simulation time. | ||
| 190 | * | ||
| 191 | * \param t The current time. | ||
| 192 | */ | ||
| 193 | 264 | void setTime(Scalar t) | |
| 194 |
1/2✓ Branch 1 taken 264 times.
✗ Branch 2 not taken.
|
264 | { time_ = t; } |
| 195 | |||
| 196 | // \} | ||
| 197 | private: | ||
| 198 | |||
| 199 | // the internal method for the initial condition | ||
| 200 | 5000 | PrimaryVariables initial_(const GlobalPosition& globalPos) const | |
| 201 | { | ||
| 202 |
4/4✓ Branch 0 taken 2178 times.
✓ Branch 1 taken 2178 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 640 times.
|
5000 | PrimaryVariables priVars; |
| 203 | |||
| 204 |
4/4✓ Branch 0 taken 2178 times.
✓ Branch 1 taken 2178 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 640 times.
|
5000 | if (globalPos[0] < this->gridGeometry().bBoxMin()[0] + eps_) |
| 205 | { | ||
| 206 | 2182 | priVars[pressureIdx] = 1.1e5; // initial condition for the pressure | |
| 207 | 2182 | priVars[N2Idx] = 2e-10; // initial condition for the N2 molefraction | |
| 208 | 2182 | priVars[temperatureIdx] = 300.00; | |
| 209 | } | ||
| 210 | else | ||
| 211 | { | ||
| 212 | 2818 | priVars[pressureIdx] = 1.0e5; | |
| 213 | priVars[N2Idx] = 0.0; | ||
| 214 | 2818 | priVars[temperatureIdx] = 285.00; | |
| 215 | } | ||
| 216 | return priVars; | ||
| 217 | } | ||
| 218 | |||
| 219 | static constexpr Scalar eps_ = 1e-6; | ||
| 220 | Scalar time_ = 0.0; | ||
| 221 | }; | ||
| 222 | |||
| 223 | } // end namespace Dumux | ||
| 224 | |||
| 225 | #endif | ||
| 226 |