3.5-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;
62 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
65 using FluxTraits = typename Dumux::FluxTraits<FluxVariables>;
68 using Element = typename GridView::template Codim<0>::Entity;
70 using Indices = typename ModelTraits::Indices;
71
72 enum { dim = GridView::dimension} ;
73 enum { dimWorld = GridView::dimensionworld} ;
74 enum
75 {
76 numPhases = ModelTraits::numFluidPhases(),
77 numComponents = ModelTraits::numFluidComponents()
78 };
79
80 using DimWorldMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
81 using ComponentFluxVector = Dune::FieldVector<Scalar, numComponents>;
82 using HeatFluxScalar = Scalar;
83
84 static constexpr bool stationaryVelocityField = FluxTraits::hasStationaryVelocityField();
85
86public:
87
88 //return the reference system
90 { return referenceSystem; }
91
98 static ComponentFluxVector compositionalDispersionFlux(const Problem& problem,
99 const Element& element,
100 const FVElementGeometry& fvGeometry,
101 const ElementVolumeVariables& elemVolVars,
102 const SubControlVolumeFace& scvf,
103 const int phaseIdx,
104 const ElementFluxVariablesCache& elemFluxVarsCache)
105 {
106 if (scvf.numOutsideScvs() > 1 )
107 DUNE_THROW(Dune::NotImplemented, "\n Dispersion using ccTPFA is only implemented for conforming grids.");
108 if (!stationaryVelocityField)
109 DUNE_THROW(Dune::NotImplemented, "\n Dispersion using ccTPFA is only implemented for problems with stationary velocity fields");
110
111 ComponentFluxVector componentFlux(0.0);
112 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
113 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
114
115 const auto rhoInside = massOrMolarDensity(insideVolVars, referenceSystem, phaseIdx);
116 const auto rhoOutside = massOrMolarDensity(outsideVolVars, referenceSystem, phaseIdx);
117 const Scalar rho = 0.5*(rhoInside + rhoOutside);
118
119 for (int compIdx = 0; compIdx < numComponents; compIdx++)
120 {
121 const auto& dispersionTensor =
122 ModelTraits::CompositionalDispersionModel::compositionalDispersionTensor(problem, scvf, fvGeometry,
123 elemVolVars, elemFluxVarsCache,
124 phaseIdx, compIdx);
125 const auto dij = computeTpfaTransmissibility(scvf, fvGeometry.scv(scvf.insideScvIdx()), dispersionTensor, insideVolVars.extrusionFactor());
126
127 const auto xInside = massOrMoleFraction(insideVolVars, referenceSystem, phaseIdx, compIdx);
128 const auto xOutide = massOrMoleFraction(outsideVolVars, referenceSystem, phaseIdx, compIdx);
129
130 componentFlux[compIdx] = (rho * (xInside-xOutide) * dij) * scvf.area();
131 }
132 return componentFlux;
133 }
134
139 static HeatFluxScalar thermalDispersionFlux(const Problem& problem,
140 const Element& element,
141 const FVElementGeometry& fvGeometry,
142 const ElementVolumeVariables& elemVolVars,
143 const SubControlVolumeFace& scvf,
144 const int phaseIdx,
145 const ElementFluxVariablesCache& elemFluxVarsCache)
146 {
147 if (scvf.numOutsideScvs() > 1 )
148 DUNE_THROW(Dune::NotImplemented, "\n Dispersion using ccTPFA is only implemented for conforming grids.");
149 if (!stationaryVelocityField)
150 DUNE_THROW(Dune::NotImplemented, "\n Dispersion using ccTPFA is only implemented for problems with stationary velocity fields");
151
152 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
153 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
154
155 const auto& dispersionTensor =
156 ModelTraits::ThermalDispersionModel::thermalDispersionTensor(problem, scvf, fvGeometry,
157 elemVolVars, elemFluxVarsCache,
158 phaseIdx);
159 const auto dij = computeTpfaTransmissibility(scvf, fvGeometry.scv(scvf.insideScvIdx()), dispersionTensor, insideVolVars.extrusionFactor());
160
161 // get the inside/outside temperatures
162 const auto tInside = insideVolVars.temperature();
163 const auto tOutside = outsideVolVars.temperature();
164
165 // compute the heat conduction flux
166 return (tInside-tOutside) * dij * scvf.area();
167 }
168
169};
170
171} // end namespace Dumux
172
173#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:47
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
Definition: adapt.hh:29
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:177
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:150
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:98
static constexpr ReferenceSystemFormulation referenceSystemFormulation()
Definition: cctpfa/dispersionflux.hh:89
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:139
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.