version 3.8
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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
13#ifndef DUMUX_DISCRETIZATION_CC_TPFA_DISPERSION_FLUX_HH
14#define DUMUX_DISCRETIZATION_CC_TPFA_DISPERSION_FLUX_HH
15
16#include <dune/common/fvector.hh>
17#include <dune/common/fmatrix.hh>
18
19#include <dumux/common/math.hh>
24#include <dumux/flux/traits.hh>
26
27namespace Dumux {
28
29// forward declaration
30template<class TypeTag, class DiscretizationMethod, ReferenceSystemFormulation referenceSystem>
31class DispersionFluxImplementation;
32
37template <class TypeTag, ReferenceSystemFormulation referenceSystem>
38class DispersionFluxImplementation<TypeTag, DiscretizationMethods::CCTpfa, referenceSystem>
39{
45 using FVElementGeometry = typename GridGeometry::LocalView;
46 using SubControlVolume = typename GridGeometry::SubControlVolume;
47 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
48 using Extrusion = Extrusion_t<GridGeometry>;
49 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
51 using ElementFluxVariablesCache = typename GridFluxVariablesCache::LocalView;
52 using FluxVarCache = typename GridFluxVariablesCache::FluxVariablesCache;
54 using FluxTraits = typename Dumux::FluxTraits<FluxVariables>;
57 using Element = typename GridView::template Codim<0>::Entity;
59 using Indices = typename ModelTraits::Indices;
60
61 enum { dim = GridView::dimension} ;
62 enum { dimWorld = GridView::dimensionworld} ;
63 enum
64 {
65 numPhases = ModelTraits::numFluidPhases(),
66 numComponents = ModelTraits::numFluidComponents()
67 };
68
69 using DimWorldMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
70 using ComponentFluxVector = Dune::FieldVector<Scalar, numComponents>;
71 using HeatFluxScalar = Scalar;
72
73 static constexpr bool stationaryVelocityField = FluxTraits::hasStationaryVelocityField();
74
75public:
76
77 //return the reference system
79 { return referenceSystem; }
80
87 static ComponentFluxVector compositionalDispersionFlux(const Problem& problem,
88 const Element& element,
89 const FVElementGeometry& fvGeometry,
90 const ElementVolumeVariables& elemVolVars,
91 const SubControlVolumeFace& scvf,
92 const int phaseIdx,
93 const ElementFluxVariablesCache& elemFluxVarsCache)
94 {
95 if (scvf.numOutsideScvs() > 1 )
96 DUNE_THROW(Dune::NotImplemented, "\n Dispersion using ccTPFA is only implemented for conforming grids.");
97 if (!stationaryVelocityField)
98 DUNE_THROW(Dune::NotImplemented, "\n Dispersion using ccTPFA is only implemented for problems with stationary velocity fields");
99
100 ComponentFluxVector componentFlux(0.0);
101 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
102 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
103
104 const auto rhoInside = massOrMolarDensity(insideVolVars, referenceSystem, phaseIdx);
105 const auto rhoOutside = massOrMolarDensity(outsideVolVars, referenceSystem, phaseIdx);
106 const Scalar rho = 0.5*(rhoInside + rhoOutside);
107
108 for (int compIdx = 0; compIdx < numComponents; compIdx++)
109 {
110 const auto& dispersionTensor =
111 ModelTraits::CompositionalDispersionModel::compositionalDispersionTensor(problem, scvf, fvGeometry,
112 elemVolVars, elemFluxVarsCache,
113 phaseIdx, compIdx);
114 const auto dij = computeTpfaTransmissibility(fvGeometry, scvf, fvGeometry.scv(scvf.insideScvIdx()), dispersionTensor, insideVolVars.extrusionFactor());
115
116 const auto xInside = massOrMoleFraction(insideVolVars, referenceSystem, phaseIdx, compIdx);
117 const auto xOutide = massOrMoleFraction(outsideVolVars, referenceSystem, phaseIdx, compIdx);
118
119 componentFlux[compIdx] = (rho * (xInside-xOutide) * dij) * scvf.area();
120 }
121 return componentFlux;
122 }
123
128 static HeatFluxScalar thermalDispersionFlux(const Problem& problem,
129 const Element& element,
130 const FVElementGeometry& fvGeometry,
131 const ElementVolumeVariables& elemVolVars,
132 const SubControlVolumeFace& scvf,
133 const int phaseIdx,
134 const ElementFluxVariablesCache& elemFluxVarsCache)
135 {
136 if (scvf.numOutsideScvs() > 1 )
137 DUNE_THROW(Dune::NotImplemented, "\n Dispersion using ccTPFA is only implemented for conforming grids.");
138 if (!stationaryVelocityField)
139 DUNE_THROW(Dune::NotImplemented, "\n Dispersion using ccTPFA is only implemented for problems with stationary velocity fields");
140
141 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
142 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
143
144 const auto& dispersionTensor =
145 ModelTraits::ThermalDispersionModel::thermalDispersionTensor(problem, scvf, fvGeometry,
146 elemVolVars, elemFluxVarsCache,
147 phaseIdx);
148 const auto dij = computeTpfaTransmissibility(scvf, fvGeometry.scv(scvf.insideScvIdx()), dispersionTensor, insideVolVars.extrusionFactor());
149
150 // get the inside/outside temperatures
151 const auto tInside = insideVolVars.temperature();
152 const auto tOutside = outsideVolVars.temperature();
153
154 // compute the heat conduction flux
155 return (tInside-tOutside) * dij * scvf.area();
156 }
157
158};
159
160} // end namespace Dumux
161
162#endif
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:87
static constexpr ReferenceSystemFormulation referenceSystemFormulation()
Definition: cctpfa/dispersionflux.hh:78
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:128
Definition: box/dispersionflux.hh:30
Defines all properties used in Dumux.
Helper classes to compute the integration elements.
Defines the flux traits.
Tensor::field_type computeTpfaTransmissibility(const FVElementGeometry &fvGeometry, const typename FVElementGeometry::SubControlVolumeFace &scvf, const typename FVElementGeometry::SubControlVolume &scv, const Tensor &T, typename FVElementGeometry::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:36
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:54
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:43
ReferenceSystemFormulation
The formulations available for Fick's law related to the reference system.
Definition: referencesystemformulation.hh:33
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:296
Define some often used mathematical functions.
The available discretization methods in Dumux.
Definition: adapt.hh:17
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:166
The reference frameworks and formulations available for splitting total fluxes into a advective and d...
Traits of a flux variables type.
Definition: flux/traits.hh:32
static constexpr bool hasStationaryVelocityField()
Definition: flux/traits.hh:33
Free functions to evaluate the transmissibilities associated with flux evaluations across sub-control...