12#ifndef DUMUX_PNM_VELOCITYOUTPUT_HH
13#define DUMUX_PNM_VELOCITYOUTPUT_HH
24template<
class Gr
idVariables,
class FluxVariables>
28 using Scalar =
typename GridVariables::Scalar;
29 using GridGeometry =
typename GridVariables::GridGeometry;
30 using ElementVolumeVariables =
typename GridVariables::GridVolumeVariables::LocalView;
31 using VolumeVariables =
typename GridVariables::VolumeVariables;
32 using FluidSystem =
typename VolumeVariables::FluidSystem;
33 using ElementFluxVariablesCache =
typename GridVariables::GridFluxVariablesCache::LocalView;
34 using FVElementGeometry =
typename GridGeometry::LocalView;
35 using SubControlVolumeFace =
typename GridGeometry::SubControlVolumeFace;
36 using Element =
typename GridGeometry::GridView::template Codim<0>::Entity;
43 std::string
phaseName(
int phaseIdx)
const override {
return FluidSystem::phaseName(phaseIdx); }
46 int numFluidPhases()
const override {
return VolumeVariables::numFluidPhases(); }
50 : gridVariables_(gridVariables)
52 velocityOutput_ = getParamFromGroup<bool>(problem_().paramGroup(),
"Vtk.AddVelocity");
57 {
return velocityOutput_; }
62 const Element& element,
63 const FVElementGeometry& fvGeometry,
64 const ElementVolumeVariables& elemVolVars,
65 const ElementFluxVariablesCache& elemFluxVarsCache,
66 int phaseIdx)
const override
71 const auto geometry = element.geometry();
73 auto tmpVelocity = (geometry.corner(1) - geometry.corner(0));
74 tmpVelocity /= tmpVelocity.two_norm();
76 const auto eIdxGlobal = fvGeometry.gridGeometry().elementMapper().index(element);
77 velocity[eIdxGlobal] = 0.0;
79 for (
auto&& scvf : scvfs(fvGeometry))
87 const Scalar flux = getFlux_(element, fvGeometry, scvf, elemVolVars, elemFluxVarsCache, phaseIdx);
90 velocity[eIdxGlobal] = tmpVelocity;
96 Scalar getFlux_(
const Element& element,
97 const FVElementGeometry& fvGeometry,
98 const SubControlVolumeFace& scvf,
99 const ElementVolumeVariables& elemVolVars,
100 const ElementFluxVariablesCache& elemFluxVarsCache,
101 const int phaseIdx)
const
103 const Scalar localArea = elemFluxVarsCache[scvf].throatCrossSectionalArea(phaseIdx);
109 FluxVariables fluxVars;
110 fluxVars.init(problem_(), element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
113 auto upwindTerm = [phaseIdx](
const auto& volVars) {
return volVars.mobility(phaseIdx); };
114 return fluxVars.advectiveFlux(phaseIdx, upwindTerm) / localArea;
120 const auto& problem_()
const {
return gridVariables_.curGridVolVars().problem(); }
122 bool velocityOutput_;
124 const GridVariables& gridVariables_;
Velocity output for pore-network models.
Definition: porenetwork/common/velocityoutput.hh:26
std::string phaseName(int phaseIdx) const override
Returns the phase name of a given phase index.
Definition: porenetwork/common/velocityoutput.hh:43
void calculateVelocity(VelocityVector &velocity, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFluxVariablesCache &elemFluxVarsCache, int phaseIdx) const override
Definition: porenetwork/common/velocityoutput.hh:61
int numFluidPhases() const override
Returns the number of phases.
Definition: porenetwork/common/velocityoutput.hh:46
bool enableOutput() const override
Returns true if velocity output is enabled.
Definition: porenetwork/common/velocityoutput.hh:56
VelocityOutput(const GridVariables &gridVariables)
Constructor.
Definition: porenetwork/common/velocityoutput.hh:49
Velocity output for implicit (porous media) models.
Definition: io/velocityoutput.hh:29
std::vector< Dune::FieldVector< Scalar, dimWorld > > VelocityVector
Definition: io/velocityoutput.hh:38
Default velocity output policy for porous media models.
Definition: discretization/porenetwork/fvelementgeometry.hh:24