GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/flux/cctpfa/dispersionflux.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 16 17 94.1%
Functions: 1 1 100.0%
Branches: 4 24 16.7%

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-FileCopyrightInfo: 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 CCTpfaFlux
10 * \brief This file contains the data which is required to calculate
11 * dispersive fluxes.
12 */
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>
20 #include <dumux/common/properties.hh>
21 #include <dumux/discretization/method.hh>
22 #include <dumux/discretization/extrusion.hh>
23 #include <dumux/discretization/cellcentered/tpfa/computetransmissibility.hh>
24 #include <dumux/flux/traits.hh>
25 #include <dumux/flux/referencesystemformulation.hh>
26
27 namespace Dumux {
28
29 // forward declaration
30 template<class TypeTag, class DiscretizationMethod, ReferenceSystemFormulation referenceSystem>
31 class DispersionFluxImplementation;
32
33 /*!
34 * \ingroup CCTpfaFlux
35 * \brief Specialization of a Dispersion flux for the cctpfa method
36 */
37 template <class TypeTag, ReferenceSystemFormulation referenceSystem>
38 class DispersionFluxImplementation<TypeTag, DiscretizationMethods::CCTpfa, referenceSystem>
39 {
40 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
41 using Problem = GetPropType<TypeTag, Properties::Problem>;
42 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
43 using VolumeVariables = GetPropType<TypeTag, Properties::VolumeVariables>;
44 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
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;
50 using GridFluxVariablesCache = GetPropType<TypeTag, Properties::GridFluxVariablesCache>;
51 using ElementFluxVariablesCache = typename GridFluxVariablesCache::LocalView;
52 using FluxVarCache = typename GridFluxVariablesCache::FluxVariablesCache;
53 using FluxVariables = GetPropType<TypeTag, Properties::FluxVariables>;
54 using FluxTraits = typename Dumux::FluxTraits<FluxVariables>;
55 using BalanceEqOpts = GetPropType<TypeTag, Properties::BalanceEqOpts>;
56 using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
57 using Element = typename GridView::template Codim<0>::Entity;
58 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
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
75 public:
76
77 //return the reference system
78 static constexpr ReferenceSystemFormulation referenceSystemFormulation()
79 { return referenceSystem; }
80
81 /*!
82 * \brief Returns the dispersive fluxes of all components within
83 * a fluid phase across the given sub-control volume face.
84 * The computed fluxes are given in mole/s or kg/s, depending
85 * on the template parameter ReferenceSystemFormulation.
86 */
87 989800 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
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 989800 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 989800 times.
1979600 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 989800 ComponentFluxVector componentFlux(0.0);
101 1979600 const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()];
102 1979600 const auto& outsideVolVars = elemVolVars[scvf.outsideScvIdx()];
103
104 989800 const auto rhoInside = massOrMolarDensity(insideVolVars, referenceSystem, phaseIdx);
105 989800 const auto rhoOutside = massOrMolarDensity(outsideVolVars, referenceSystem, phaseIdx);
106 989800 const Scalar rho = 0.5*(rhoInside + rhoOutside);
107
108
2/2
✓ Branch 0 taken 1979600 times.
✓ Branch 1 taken 989800 times.
2969400 for (int compIdx = 0; compIdx < numComponents; compIdx++)
109 {
110 1979600 const auto& dispersionTensor =
111 1979600 ModelTraits::CompositionalDispersionModel::compositionalDispersionTensor(problem, scvf, fvGeometry,
112 elemVolVars, elemFluxVarsCache,
113 phaseIdx, compIdx);
114 5938800 const auto dij = computeTpfaTransmissibility(fvGeometry, scvf, fvGeometry.scv(scvf.insideScvIdx()), dispersionTensor, insideVolVars.extrusionFactor());
115
116 1979600 const auto xInside = massOrMoleFraction(insideVolVars, referenceSystem, phaseIdx, compIdx);
117 1979600 const auto xOutide = massOrMoleFraction(outsideVolVars, referenceSystem, phaseIdx, compIdx);
118
119 3959200 componentFlux[compIdx] = (rho * (xInside-xOutide) * dij) * scvf.area();
120 }
121 989800 return componentFlux;
122 }
123
124 /*!
125 * \brief Returns the thermal dispersive flux
126 * across the given sub-control volume face.
127 */
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
163