version 3.8
porenetwork/common/velocityoutput.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_PNM_VELOCITYOUTPUT_HH
13#define DUMUX_PNM_VELOCITYOUTPUT_HH
14
15#include <string>
17
18namespace Dumux::PoreNetwork {
19
24template<class GridVariables, class FluxVariables>
25class VelocityOutput : public Dumux::VelocityOutput<GridVariables>
26{
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;
37
38public:
41
43 std::string phaseName(int phaseIdx) const override { return FluidSystem::phaseName(phaseIdx); }
44
46 int numFluidPhases() const override { return VolumeVariables::numFluidPhases(); }
47
49 VelocityOutput(const GridVariables& gridVariables)
50 : gridVariables_(gridVariables)
51 {
52 velocityOutput_ = getParamFromGroup<bool>(problem_().paramGroup(), "Vtk.AddVelocity");
53 }
54
56 bool enableOutput() const override
57 { return velocityOutput_; }
58
62 const Element& element,
63 const FVElementGeometry& fvGeometry,
64 const ElementVolumeVariables& elemVolVars,
65 const ElementFluxVariablesCache& elemFluxVarsCache,
66 int phaseIdx) const override
67 {
68 if (!velocityOutput_)
69 return;
70
71 const auto geometry = element.geometry();
72
73 auto tmpVelocity = (geometry.corner(1) - geometry.corner(0));
74 tmpVelocity /= tmpVelocity.two_norm();
75
76 const auto eIdxGlobal = fvGeometry.gridGeometry().elementMapper().index(element);
77 velocity[eIdxGlobal] = 0.0;
78
79 for (auto&& scvf : scvfs(fvGeometry))
80 {
81 if (scvf.boundary())
82 continue;
83
84 // get the volume flux divided by the area of the
85 // subcontrolvolume face in the reference element
86 // TODO: Divide by extrusion factor!!?
87 const Scalar flux = getFlux_(element, fvGeometry, scvf, elemVolVars, elemFluxVarsCache, phaseIdx);
88
89 tmpVelocity *= flux;
90 velocity[eIdxGlobal] = tmpVelocity;
91 }
92 }
93
94private:
95
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
102 {
103 const Scalar localArea = elemFluxVarsCache[scvf].throatCrossSectionalArea(phaseIdx);
104
105 // make sure the phase is actually present (2p)
106 if (localArea > 0.0)
107 {
108 // instantiate the flux variables
109 FluxVariables fluxVars;
110 fluxVars.init(problem_(), element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
111
112 // the upwind term to be used for the volume flux evaluation
113 auto upwindTerm = [phaseIdx](const auto& volVars) { return volVars.mobility(phaseIdx); };
114 return fluxVars.advectiveFlux(phaseIdx, upwindTerm) / localArea;
115 }
116 else
117 return 0.0;
118 }
119
120 const auto& problem_() const { return gridVariables_.curGridVolVars().problem(); }
121
122 bool velocityOutput_;
123
124 const GridVariables& gridVariables_;
125};
126
127} // end namespace Dumux::PoreNetwork
128
129#endif
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