volumevariables.hh 7.49 KB
 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- // vi: set et ts=4 sw=4 sts=4: /***************************************************************************** * See the file COPYING for full copying permissions. * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * *****************************************************************************/ /*! * \file  21  * \ingroup OnePModel  22 23 24 25 26  * \brief Quantities required by the one-phase fully implicit model defined on a vertex. */ #ifndef DUMUX_1P_VOLUME_VARIABLES_HH #define DUMUX_1P_VOLUME_VARIABLES_HH  Timo Koch committed Dec 11, 2017 27 #include  Kilian Weishaupt committed Dec 15, 2017 28 #include  Bernd Flemisch committed Jan 22, 2016 29 #include  30   Timo Koch committed Mar 05, 2018 31 namespace Dumux {  32 33 34 35 36  /*! * \ingroup OnePModel * \brief Contains the quantities which are constant within a * finite volume in the one-phase model.  Dennis Gläser committed Apr 15, 2018 37 38  * * \tparam Traits Class encapsulating types to be used by the vol vars  39  */  Dennis Gläser committed Apr 15, 2018 40 41 template class OnePVolumeVariables : public PorousMediumFlowVolumeVariables< Traits, OnePVolumeVariables >  42 {  Dennis Gläser committed Apr 15, 2018 43 44  using ThisType = OnePVolumeVariables; using ParentType = PorousMediumFlowVolumeVariables;  45   Dennis Gläser committed Apr 15, 2018 46 47 48  using Scalar = typename Traits::PrimaryVariables::value_type; using Indices = typename Traits::ModelTraits::Indices; using PermeabilityType = typename Traits::PermeabilityType;  49   Dennis Gläser committed Apr 15, 2018 50 51 52 53 54 public: //! export the underlying fluid system using FluidSystem = typename Traits::FluidSystem; //! export the fluid state type using FluidState = typename Traits::FluidState;  55 56  /*!  Beatrix Becker committed Dec 19, 2017 57 58 59 60 61 62 63  * \brief Update all quantities for a given control volume * * \param elemSol A vector containing all primary variables connected to the element * \param problem The object specifying the problem which ought to * be simulated * \param element An element which contains part of the control volume * \param scv The sub-control volume  64  */  Dennis Gläser committed Apr 15, 2018 65 66  template void update(const ElemSol &elemSol,  67 68  const Problem &problem, const Element &element,  Dennis Gläser committed Apr 15, 2018 69  const Scv& scv)  70  {  Dennis Gläser committed Jan 09, 2017 71  ParentType::update(elemSol, problem, element, scv);  72   Dennis Gläser committed Jan 09, 2017 73  completeFluidState(elemSol, problem, element, scv, fluidState_);  74  // porosity  Dennis Gläser committed Jan 09, 2017 75 76  porosity_ = problem.spatialParams().porosity(element, scv, elemSol); permeability_ = problem.spatialParams().permeability(element, scv, elemSol);  77 78 79  }; /*!  Beatrix Becker committed Dec 19, 2017 80 81 82 83 84 85 86 87  * \brief Set complete fluid state * * \param elemSol A vector containing all primary variables connected to the element * \param problem The object specifying the problem which ought to * be simulated * \param element An element which contains part of the control volume * \param scv The sub-control volume * \param fluidState A container with the current (physical) state of the fluid  88  */  Dennis Gläser committed Apr 15, 2018 89 90  template static void completeFluidState(const ElemSol &elemSol,  91 92  const Problem& problem, const Element& element,  Dennis Gläser committed Apr 15, 2018 93  const Scv& scv,  94 95  FluidState& fluidState) {  Dennis Gläser committed Jan 09, 2017 96 97  Scalar t = ParentType::temperature(elemSol, problem, element, scv);  98 99 100  fluidState.setTemperature(t); fluidState.setSaturation(/*phaseIdx=*/0, 1.);  101  const auto& priVars = ParentType::extractDofPriVars(elemSol, scv);  102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118  fluidState.setPressure(/*phaseIdx=*/0, priVars[Indices::pressureIdx]); // saturation in a single phase is always 1 and thus redundant // to set. But since we use the fluid state shared by the // immiscible multi-phase models, so we have to set it here... fluidState.setSaturation(/*phaseIdx=*/0, 1.0); typename FluidSystem::ParameterCache paramCache; paramCache.updatePhase(fluidState, /*phaseIdx=*/0); Scalar value = FluidSystem::density(fluidState, paramCache, /*phaseIdx=*/0); fluidState.setDensity(/*phaseIdx=*/0, value); value = FluidSystem::viscosity(fluidState, paramCache, /*phaseIdx=*/0); fluidState.setViscosity(/*phaseIdx=*/0, value); // compute and set the enthalpy  Timo Koch committed Nov 23, 2016 119  value = ParentType::enthalpy(fluidState, paramCache, /*phaseIdx=*/0);  120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139  fluidState.setEnthalpy(/*phaseIdx=*/0, value); } /*! * \brief Return temperature \f$\mathrm{[K]}\f$ inside the sub-control volume. * * Note that we assume thermodynamic equilibrium, i.e. the * temperatures of the rock matrix and of all fluid phases are * identical. */ Scalar temperature() const { return fluidState_.temperature(); } /*! * \brief Return the effective pressure \f$\mathrm{[Pa]}\f$ of a given phase within * the control volume. */ Scalar pressure(int phaseIdx = 0) const { return fluidState_.pressure(phaseIdx); }  Timo Koch committed Nov 23, 2016 140 141 142 143 144 145  /*! * \brief Return the saturation */ Scalar saturation(int phaseIdx = 0) const { return 1.0; }  146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177  /*! * \brief Return the mass density \f$\mathrm{[kg/m^3]}\f$ of a given phase within the * control volume. */ Scalar density(int phaseIdx = 0) const { return fluidState_.density(phaseIdx); } /*! * \brief Return the dynamic viscosity \f$\mathrm{[Pa s]}\f$ of the fluid within the * control volume. */ Scalar viscosity(int phaseIdx = 0) const { return fluidState_.viscosity(phaseIdx); } /*! * \brief Returns the mobility \f$\mathrm{[1/(Pa s)]}\f$. * * This function enables the use of ImplicitDarcyFluxVariables * with the 1p fully implicit model, ALTHOUGH the term mobility is * usually not employed in the one phase context. * * \param phaseIdx The phase index */ Scalar mobility(int phaseIdx = 0) const { return 1.0/fluidState_.viscosity(phaseIdx); } /*! * \brief Return the average porosity \f$\mathrm{[-]}\f$ within the control volume. */ Scalar porosity() const { return porosity_; }  Dennis Gläser committed Jan 09, 2017 178 179 180  /*! * \brief Returns the permeability within the control volume in \f$[m^2]\f$. */  Timo Koch committed Jan 27, 2017 181  const PermeabilityType& permeability() const  Dennis Gläser committed Jan 09, 2017 182 183  { return permeability_; }  184 185 186 187 188 189 190 191 192  /*! * \brief Return the fluid state of the control volume. */ const FluidState &fluidState() const { return fluidState_; } protected: FluidState fluidState_; Scalar porosity_;  Dennis Gläser committed Jan 09, 2017 193  PermeabilityType permeability_;  194 195 196 197 198 }; } #endif