3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
cctpfa/dispersionflux.hh
Go to the documentation of this file.
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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
25#ifndef DUMUX_DISCRETIZATION_CC_TPFA_DISPERSION_FLUX_HH
26#define DUMUX_DISCRETIZATION_CC_TPFA_DISPERSION_FLUX_HH
27
28#include <dune/common/fvector.hh>
29#include <dune/common/fmatrix.hh>
30
31#include <dumux/common/math.hh>
36#include <dumux/flux/traits.hh>
38
39namespace Dumux {
40
41// forward declaration
42template<class TypeTag, class DiscretizationMethod, ReferenceSystemFormulation referenceSystem>
43class DispersionFluxImplementation;
44
49template <class TypeTag, ReferenceSystemFormulation referenceSystem>
50class DispersionFluxImplementation<TypeTag, DiscretizationMethods::CCTpfa, referenceSystem>
51{
57 using FVElementGeometry = typename GridGeometry::LocalView;
58 using SubControlVolume = typename GridGeometry::SubControlVolume;
59 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
60 using Extrusion = Extrusion_t<GridGeometry>;
61 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
63 using ElementFluxVariablesCache = typename GridFluxVariablesCache::LocalView;
64 using FluxVarCache = typename GridFluxVariablesCache::FluxVariablesCache;
66 using FluxTraits = typename Dumux::FluxTraits<FluxVariables>;
69 using Element = typename GridView::template Codim<0>::Entity;
71 using Indices = typename ModelTraits::Indices;
72
73 enum { dim = GridView::dimension} ;
74 enum { dimWorld = GridView::dimensionworld} ;
75 enum
76 {
77 numPhases = ModelTraits::numFluidPhases(),
78 numComponents = ModelTraits::numFluidComponents()
79 };
80
81 using DimWorldMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
82 using ComponentFluxVector = Dune::FieldVector<Scalar, numComponents>;
83 using HeatFluxScalar = Scalar;
84
85 static constexpr bool stationaryVelocityField = FluxTraits::hasStationaryVelocityField();
86
87public:
88
89 //return the reference system
91 { return referenceSystem; }
92
99 static ComponentFluxVector compositionalDispersionFlux(const Problem& problem,
100 const Element& element,
101 const FVElementGeometry& fvGeometry,
102 const ElementVolumeVariables& elemVolVars,
103 const SubControlVolumeFace& scvf,
104 const int phaseIdx,
105 const ElementFluxVariablesCache& elemFluxVarsCache)
106 {
107 if (scvf.numOutsideScvs() > 1 )
108 DUNE_THROW(Dune::NotImplemented, "\n Dispersion using ccTPFA is only implemented for conforming grids.");
109 if (!stationaryVelocityField)
110 DUNE_THROW(Dune::NotImplemented, "\n Dispersion using ccTPFA is only implemented for problems with stationary velocity fields");
111
112 ComponentFluxVector componentFlux(0.0);
113 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
114 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
115
116 const auto rhoInside = massOrMolarDensity(insideVolVars, referenceSystem, phaseIdx);
117 const auto rhoOutside = massOrMolarDensity(outsideVolVars, referenceSystem, phaseIdx);
118 const Scalar rho = 0.5*(rhoInside + rhoOutside);
119
120 for (int compIdx = 0; compIdx < numComponents; compIdx++)
121 {
122 const auto& dispersionTensor =
123 ModelTraits::CompositionalDispersionModel::compositionalDispersionTensor(problem, scvf, fvGeometry,
124 elemVolVars, elemFluxVarsCache,
125 phaseIdx, compIdx);
126 const auto dij = computeTpfaTransmissibility(fvGeometry, scvf, fvGeometry.scv(scvf.insideScvIdx()), dispersionTensor, insideVolVars.extrusionFactor());
127
128 const auto xInside = massOrMoleFraction(insideVolVars, referenceSystem, phaseIdx, compIdx);
129 const auto xOutide = massOrMoleFraction(outsideVolVars, referenceSystem, phaseIdx, compIdx);
130
131 componentFlux[compIdx] = (rho * (xInside-xOutide) * dij) * scvf.area();
132 }
133 return componentFlux;
134 }
135
140 static HeatFluxScalar thermalDispersionFlux(const Problem& problem,
141 const Element& element,
142 const FVElementGeometry& fvGeometry,
143 const ElementVolumeVariables& elemVolVars,
144 const SubControlVolumeFace& scvf,
145 const int phaseIdx,
146 const ElementFluxVariablesCache& elemFluxVarsCache)
147 {
148 if (scvf.numOutsideScvs() > 1 )
149 DUNE_THROW(Dune::NotImplemented, "\n Dispersion using ccTPFA is only implemented for conforming grids.");
150 if (!stationaryVelocityField)
151 DUNE_THROW(Dune::NotImplemented, "\n Dispersion using ccTPFA is only implemented for problems with stationary velocity fields");
152
153 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
154 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
155
156 const auto& dispersionTensor =
157 ModelTraits::ThermalDispersionModel::thermalDispersionTensor(problem, scvf, fvGeometry,
158 elemVolVars, elemFluxVarsCache,
159 phaseIdx);
160 const auto dij = computeTpfaTransmissibility(scvf, fvGeometry.scv(scvf.insideScvIdx()), dispersionTensor, insideVolVars.extrusionFactor());
161
162 // get the inside/outside temperatures
163 const auto tInside = insideVolVars.temperature();
164 const auto tOutside = outsideVolVars.temperature();
165
166 // compute the heat conduction flux
167 return (tInside-tOutside) * dij * scvf.area();
168 }
169
170};
171
172} // end namespace Dumux
173
174#endif
Define some often used mathematical functions.
Helper classes to compute the integration elements.
The available discretization methods in Dumux.
The reference frameworks and formulations available for splitting total fluxes into a advective and d...
Tensor::field_type computeTpfaTransmissibility(const SubControlVolumeFace &scvf, const SubControlVolume &scv, const Tensor &T, typename SubControlVolume::Traits::Scalar extrusionFactor)
Free function to evaluate the Tpfa transmissibility associated with the flux (in the form of flux = T...
Definition: tpfa/computetransmissibility.hh:48
VolumeVariables::PrimaryVariables::value_type massOrMoleFraction(const VolumeVariables &volVars, ReferenceSystemFormulation referenceSys, const int phaseIdx, const int compIdx)
returns the mass or mole fraction to be used in Fick's law based on the reference system
Definition: referencesystemformulation.hh:66
VolumeVariables::PrimaryVariables::value_type massOrMolarDensity(const VolumeVariables &volVars, ReferenceSystemFormulation referenceSys, const int phaseIdx)
evaluates the density to be used in Fick's law based on the reference system
Definition: referencesystemformulation.hh:55
ReferenceSystemFormulation
The formulations available for Fick's law related to the reference system.
Definition: referencesystemformulation.hh:45
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:251
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:180
Definition: box/dispersionflux.hh:42
static ComponentFluxVector compositionalDispersionFlux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolumeFace &scvf, const int phaseIdx, const ElementFluxVariablesCache &elemFluxVarsCache)
Returns the dispersive fluxes of all components within a fluid phase across the given sub-control vol...
Definition: cctpfa/dispersionflux.hh:99
static constexpr ReferenceSystemFormulation referenceSystemFormulation()
Definition: cctpfa/dispersionflux.hh:90
static HeatFluxScalar thermalDispersionFlux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolumeFace &scvf, const int phaseIdx, const ElementFluxVariablesCache &elemFluxVarsCache)
Returns the thermal dispersive flux across the given sub-control volume face.
Definition: cctpfa/dispersionflux.hh:140
Traits of a flux variables type.
Definition: flux/traits.hh:44
static constexpr bool hasStationaryVelocityField()
Definition: flux/traits.hh:45
Declares all properties used in Dumux.
Free functions to evaluate the transmissibilities associated with flux evaluations across sub-control...
Defines the flux traits.