24#ifndef DUMUX_PNM_VELOCITYOUTPUT_HH
25#define DUMUX_PNM_VELOCITYOUTPUT_HH
36template<
class Gr
idVariables,
class FluxVariables>
40 using Scalar =
typename GridVariables::Scalar;
41 using GridGeometry =
typename GridVariables::GridGeometry;
42 using ElementVolumeVariables =
typename GridVariables::GridVolumeVariables::LocalView;
43 using VolumeVariables =
typename GridVariables::VolumeVariables;
44 using FluidSystem =
typename VolumeVariables::FluidSystem;
45 using ElementFluxVariablesCache =
typename GridVariables::GridFluxVariablesCache::LocalView;
46 using FVElementGeometry =
typename GridGeometry::LocalView;
47 using SubControlVolumeFace =
typename GridGeometry::SubControlVolumeFace;
48 using Element =
typename GridGeometry::GridView::template Codim<0>::Entity;
55 std::string
phaseName(
int phaseIdx)
const override {
return FluidSystem::phaseName(phaseIdx); }
58 int numFluidPhases()
const override {
return VolumeVariables::numFluidPhases(); }
62 : gridVariables_(gridVariables)
64 velocityOutput_ = getParamFromGroup<bool>(problem_().paramGroup(),
"Vtk.AddVelocity");
69 {
return velocityOutput_; }
74 const Element& element,
75 const FVElementGeometry& fvGeometry,
76 const ElementVolumeVariables& elemVolVars,
77 const ElementFluxVariablesCache& elemFluxVarsCache,
78 int phaseIdx)
const override
83 const auto geometry = element.geometry();
85 auto tmpVelocity = (geometry.corner(1) - geometry.corner(0));
86 tmpVelocity /= tmpVelocity.two_norm();
88 const auto eIdxGlobal = fvGeometry.gridGeometry().elementMapper().index(element);
89 velocity[eIdxGlobal] = 0.0;
91 for (
auto&& scvf : scvfs(fvGeometry))
99 const Scalar flux = getFlux_(element, fvGeometry, scvf, elemVolVars, elemFluxVarsCache, phaseIdx);
102 velocity[eIdxGlobal] = tmpVelocity;
108 Scalar getFlux_(
const Element& element,
109 const FVElementGeometry& fvGeometry,
110 const SubControlVolumeFace& scvf,
111 const ElementVolumeVariables& elemVolVars,
112 const ElementFluxVariablesCache& elemFluxVarsCache,
113 const int phaseIdx)
const
115 const Scalar localArea = elemFluxVarsCache[scvf].throatCrossSectionalArea(phaseIdx);
121 FluxVariables fluxVars;
122 fluxVars.init(problem_(), element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
125 auto upwindTerm = [phaseIdx](
const auto& volVars) {
return volVars.mobility(phaseIdx); };
126 return fluxVars.advectiveFlux(phaseIdx, upwindTerm) / localArea;
132 const auto& problem_()
const {
return gridVariables_.curGridVolVars().problem(); }
134 bool velocityOutput_;
136 const GridVariables& gridVariables_;
Definition: discretization/porenetwork/fvelementgeometry.hh:34
Velocity output for implicit (porous media) models.
Definition: io/velocityoutput.hh:41
std::vector< Dune::FieldVector< Scalar, dimWorld > > VelocityVector
Definition: io/velocityoutput.hh:50
Velocity output for pore-network models.
Definition: porenetwork/common/velocityoutput.hh:38
std::string phaseName(int phaseIdx) const override
Returns the phase name of a given phase index.
Definition: porenetwork/common/velocityoutput.hh:55
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:73
int numFluidPhases() const override
Returns the number of phases.
Definition: porenetwork/common/velocityoutput.hh:58
bool enableOutput() const override
Returns true if velocity output is enabled.
Definition: porenetwork/common/velocityoutput.hh:68
VelocityOutput(const GridVariables &gridVariables)
Constructor.
Definition: porenetwork/common/velocityoutput.hh:61
Default velocity output policy for porous media models.