26#ifndef DUMUX_3P3C_LOCAL_RESIDUAL_HH
27#define DUMUX_3P3C_LOCAL_RESIDUAL_HH
39template<
class TypeTag>
46 using SubControlVolume =
typename FVElementGeometry::SubControlVolume;
47 using SubControlVolumeFace =
typename FVElementGeometry::SubControlVolumeFace;
53 using Element =
typename GridView::template Codim<0>::Entity;
63 contiWEqIdx = Indices::conti0EqIdx + FluidSystem::wPhaseIdx,
64 contiNEqIdx = Indices::conti0EqIdx + FluidSystem::nPhaseIdx,
65 contiGEqIdx = Indices::conti0EqIdx + FluidSystem::gPhaseIdx,
67 wPhaseIdx = FluidSystem::wPhaseIdx,
68 nPhaseIdx = FluidSystem::nPhaseIdx,
69 gPhaseIdx = FluidSystem::gPhaseIdx,
71 wCompIdx = FluidSystem::wCompIdx,
72 nCompIdx = FluidSystem::nCompIdx,
73 gCompIdx = FluidSystem::gCompIdx
78 using ParentType::ParentType;
92 const SubControlVolume& scv,
93 const VolumeVariables& volVars)
const
95 NumEqVector storage(0.0);
98 for (
int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
100 for (
int compIdx = 0; compIdx < numComponents; ++compIdx)
102 auto eqIdx = Indices::conti0EqIdx + compIdx;
103 storage[eqIdx] += volVars.porosity()
104 * volVars.saturation(phaseIdx)
105 * volVars.molarDensity(phaseIdx)
106 * volVars.moleFraction(phaseIdx, compIdx);
110 EnergyLocalResidual::fluidPhaseStorage(storage, scv, volVars, phaseIdx);
114 EnergyLocalResidual::solidPhaseStorage(storage, scv, volVars);
131 const Element& element,
132 const FVElementGeometry& fvGeometry,
133 const ElementVolumeVariables& elemVolVars,
134 const SubControlVolumeFace& scvf,
135 const ElementFluxVariablesCache& elemFluxVarsCache)
const
137 FluxVariables fluxVars;
138 fluxVars.init(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
139 static constexpr auto referenceSystemFormulation = FluxVariables::MolecularDiffusionType::referenceSystemFormulation();
142 NumEqVector flux(0.0);
145 for (
int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
147 for (
int compIdx = 0; compIdx < numComponents; ++compIdx)
149 auto upwindTerm = [phaseIdx, compIdx](
const VolumeVariables& volVars)
150 {
return volVars.molarDensity(phaseIdx)*volVars.moleFraction(phaseIdx, compIdx)*volVars.mobility(phaseIdx); };
153 auto eqIdx = Indices::conti0EqIdx + compIdx;
154 flux[eqIdx] += fluxVars.advectiveFlux(phaseIdx, upwindTerm);
158 EnergyLocalResidual::heatConvectionFlux(flux, fluxVars, phaseIdx);
162 EnergyLocalResidual::heatConductionFlux(flux, fluxVars);
165 const auto diffusionFluxesWPhase = fluxVars.molecularDiffusionFlux(wPhaseIdx);
166 Scalar jGW = diffusionFluxesWPhase[gCompIdx];
167 Scalar jNW = diffusionFluxesWPhase[nCompIdx];
172 jGW /= FluidSystem::molarMass(gCompIdx);
173 jNW /= FluidSystem::molarMass(nCompIdx);
175 const Scalar jWW = -(jGW+jNW);
177 const auto diffusionFluxesGPhase = fluxVars.molecularDiffusionFlux(gPhaseIdx);
178 Scalar jWG = diffusionFluxesGPhase[wCompIdx];
179 Scalar jNG = diffusionFluxesGPhase[nCompIdx];
184 jWG /= FluidSystem::molarMass(wCompIdx);
185 jNG /= FluidSystem::molarMass(nCompIdx);
187 const Scalar jGG = -(jWG+jNG);
190 const Scalar jWN = 0.0;
191 const Scalar jGN = 0.0;
192 const Scalar jNN = 0.0;
194 flux[contiWEqIdx] += jWW+jWG+jWN;
195 flux[contiNEqIdx] += jNW+jNG+jNN;
196 flux[contiGEqIdx] += jGW+jGG+jGN;
The reference frameworks and formulations available for splitting total fluxes into a advective and d...
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:149
Element-wise calculation of the Jacobian matrix for problems using the three-phase three-component fu...
Definition: porousmediumflow/3p3c/localresidual.hh:41
NumEqVector computeStorage(const Problem &problem, const SubControlVolume &scv, const VolumeVariables &volVars) const
Evaluates the amount of all conservation quantities (e.g. phase mass) within a sub-control volume.
Definition: porousmediumflow/3p3c/localresidual.hh:91
NumEqVector computeFlux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolumeFace &scvf, const ElementFluxVariablesCache &elemFluxVarsCache) const
Evaluates the total flux of all conservation quantities over a face of a sub-control volume.
Definition: porousmediumflow/3p3c/localresidual.hh:130
Declares all properties used in Dumux.