version 3.10-dev
cctpfa/fourierslawnonequilibrium.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//
12#ifndef DUMUX_DISCRETIZATION_CC_TPFA_FOURIERS_LAW_NONEQUILIBRIUM_HH
13#define DUMUX_DISCRETIZATION_CC_TPFA_FOURIERS_LAW_NONEQUILIBRIUM_HH
14
20
21namespace Dumux {
22
23// forward declaration
24template<class TypeTag, class DiscretizationMethod>
25class FouriersLawNonEquilibriumImplementation;
26
31template <class TypeTag>
32class FouriersLawNonEquilibriumImplementation<TypeTag, DiscretizationMethods::CCTpfa>
33{
38 using FVElementGeometry = typename GridGeometry::LocalView;
39 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
40 using Extrusion = Extrusion_t<GridGeometry>;
41 using GridView = typename GridGeometry::GridView;
42 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
43 using Element = typename GridView::template Codim<0>::Entity;
45
46 static constexpr int dim = GridView::dimension;
47 static constexpr int dimWorld = GridView::dimensionworld;
48
50
51 static constexpr auto numEnergyEqSolid = getPropValue<TypeTag, Properties::NumEnergyEqSolid>();
52 static constexpr auto numEnergyEqFluid = getPropValue<TypeTag, Properties::NumEnergyEqFluid>();
53 static constexpr auto numEnergyEq = numEnergyEqSolid + numEnergyEqFluid;
54 static constexpr auto sPhaseIdx = ModelTraits::numFluidPhases();
55
56public:
59 static constexpr DiscretizationMethod discMethod{};
60
62
67 static Scalar flux(const Problem& problem,
68 const Element& element,
69 const FVElementGeometry& fvGeometry,
70 const ElementVolumeVariables& elemVolVars,
71 const SubControlVolumeFace& scvf,
72 const int phaseIdx,
73 const ElementFluxVarsCache& elemFluxVarsCache)
74 {
75 Scalar tInside = 0.0;
76 Scalar tOutside = 0.0;
77 // get the inside/outside temperatures
78 if (phaseIdx < numEnergyEqFluid)
79 {
80 tInside += elemVolVars[scvf.insideScvIdx()].temperatureFluid(phaseIdx);
81 tOutside += elemVolVars[scvf.outsideScvIdx()].temperatureFluid(phaseIdx);
82 }
83 else //temp solid
84 {
85 tInside += elemVolVars[scvf.insideScvIdx()].temperatureSolid();
86 tOutside += elemVolVars[scvf.outsideScvIdx()].temperatureSolid();
87 }
88
89 Scalar tij = calculateTransmissibility(problem, element, fvGeometry, elemVolVars, scvf, phaseIdx);
90 return tij*(tInside - tOutside);
91 }
92
94 static Scalar calculateTransmissibility(const Problem& problem,
95 const Element& element,
96 const FVElementGeometry& fvGeometry,
97 const ElementVolumeVariables& elemVolVars,
98 const SubControlVolumeFace& scvf,
99 const int phaseIdx)
100 {
101 const auto insideScvIdx = scvf.insideScvIdx();
102 const auto& insideScv = fvGeometry.scv(insideScvIdx);
103 const auto& insideVolVars = elemVolVars[insideScvIdx];
104 const auto computeLambda = [&](const auto& v){
105 if constexpr (numEnergyEq == 1)
106 return v.effectiveThermalConductivity();
107 else if constexpr (numEnergyEqFluid == 1)
108 return (phaseIdx != sPhaseIdx)
109 ? v.effectiveFluidThermalConductivity()
110 : v.effectiveSolidThermalConductivity();
111 else
112 return v.effectivePhaseThermalConductivity(phaseIdx);
113 };
114
115 const auto insideLambda = computeLambda(insideVolVars);
116 const Scalar ti = computeTpfaTransmissibility(fvGeometry, scvf, insideScv, insideLambda, insideVolVars.extrusionFactor());
117
118 // for the boundary (dirichlet) or at branching points we only need ti
119 if (scvf.boundary() || scvf.numOutsideScvs() > 1)
120 return Extrusion::area(fvGeometry, scvf)*ti;
121 else // otherwise we compute a tpfa harmonic mean
122 {
123 const auto outsideScvIdx = scvf.outsideScvIdx();
124 const auto& outsideScv = fvGeometry.scv(outsideScvIdx);
125 const auto& outsideVolVars = elemVolVars[outsideScvIdx];
126 const auto outsideLambda = computeLambda(outsideVolVars);
127
128 Scalar tj;
129 if (dim == dimWorld)
130 // assume the normal vector from outside is anti parallel so we save flipping a vector
131 tj = -1.0*computeTpfaTransmissibility(fvGeometry, scvf, outsideScv, outsideLambda, outsideVolVars.extrusionFactor());
132 else
133 tj = computeTpfaTransmissibility(fvGeometry, fvGeometry.flipScvf(scvf.index()), outsideScv, outsideLambda, outsideVolVars.extrusionFactor());
134
135 // check for division by zero!
136 if (ti*tj <= 0.0)
137 return 0.0;
138 else
139 return Extrusion::area(fvGeometry, scvf)*(ti * tj)/(ti + tj);
140 }
141 }
142};
143
144} // end namespace Dumux
145
146#endif
Fourier's law for cell-centered finite volume schemes with two-point flux approximation.
Definition: cctpfa/fourierslawnonequilibrium.hh:33
static Scalar calculateTransmissibility(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolumeFace &scvf, const int phaseIdx)
Compute transmissibilities.
Definition: cctpfa/fourierslawnonequilibrium.hh:94
static Scalar flux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolumeFace &scvf, const int phaseIdx, const ElementFluxVarsCache &elemFluxVarsCache)
Returns the heat flux within a fluid or solid phase (in J/s) across the given sub-control volume face...
Definition: cctpfa/fourierslawnonequilibrium.hh:67
Definition: box/fourierslawnonequilibrium.hh:30
Defines all properties used in Dumux.
Helper classes to compute the integration elements.
Classes related to flux variables caching.
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
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:296
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
Definition: method.hh:25
Definition: fluxvariablescaching.hh:56
Free functions to evaluate the transmissibilities associated with flux evaluations across sub-control...