3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
porousmediumflow/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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
25#ifndef DUMUX_POROUSMEDIUMFLOW_VELOCITYOUTPUT_HH
26#define DUMUX_POROUSMEDIUMFLOW_VELOCITYOUTPUT_HH
27
28#include <memory>
29#include <dune/common/float_cmp.hh>
30#include <dune/geometry/referenceelements.hh>
31
38
39namespace Dumux {
40
45template<class GridVariables, class FluxVariables>
47{
49 using GridGeometry = typename GridVariables::GridGeometry;
50 using FVElementGeometry = typename GridGeometry::LocalView;
51 using SubControlVolume = typename GridGeometry::SubControlVolume;
52 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
53 using GridView = typename GridGeometry::GridView;
54 using Element = typename GridView::template Codim<0>::Entity;
55 using GridVolumeVariables = typename GridVariables::GridVolumeVariables;
56 using ElementFluxVarsCache = typename GridVariables::GridFluxVariablesCache::LocalView;
57 using VolumeVariables = typename GridVariables::VolumeVariables;
58 using ElementVolumeVariables = typename GridVolumeVariables::LocalView;
59 using FluidSystem = typename VolumeVariables::FluidSystem;
60 using Scalar = typename GridVariables::Scalar;
61
62 static constexpr int dim = GridView::dimension;
63 static constexpr int dimWorld = GridView::dimensionworld;
64 static constexpr bool isBox = GridGeometry::discMethod == DiscretizationMethod::box;
65 static constexpr int dofCodim = isBox ? dim : 0;
66
67 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
68 using ReferenceElements = Dune::ReferenceElements<typename GridView::ctype, dim>;
69
70 using Problem = typename GridVolumeVariables::Problem;
71 using BoundaryTypes = typename Problem::Traits::BoundaryTypes;
73
74public:
76
82 PorousMediumFlowVelocityOutput(const GridVariables& gridVariables)
83 : gridVariables_(gridVariables) // TODO: can be removed after the deprecated calculateVelocity interface is removed
84 {
85 // check, if velocity output can be used (works only for cubes so far)
86 enableOutput_ = getParamFromGroup<bool>(gridVariables.curGridVolVars().problem().paramGroup(), "Vtk.AddVelocity");
87 if (enableOutput_)
88 velocityBackend = std::make_unique<VelocityBackend>(gridVariables);
89 }
90
92 bool enableOutput() const override { return enableOutput_; }
93
95 std::string phaseName(int phaseIdx) const override { return FluidSystem::phaseName(phaseIdx); }
96
98 int numFluidPhases() const override { return VolumeVariables::numFluidPhases(); }
99
102 [[deprecated("Use the new interface signature with elemFluxVarsCache")]]
104 const ElementVolumeVariables& elemVolVars,
105 const FVElementGeometry& fvGeometry,
106 const Element& element,
107 int phaseIdx) const override
108 {
109 auto elemFluxVarsCache = localView(gridVariables_.gridFluxVarsCache());
110 elemFluxVarsCache.bind(element, fvGeometry, elemVolVars);
111 calculateVelocity(velocity, element, fvGeometry, elemVolVars, elemFluxVarsCache, phaseIdx);
112 }
113
117 const Element& element,
118 const FVElementGeometry& fvGeometry,
119 const ElementVolumeVariables& elemVolVars,
120 const ElementFluxVarsCache& elemFluxVarsCache,
121 int phaseIdx) const override
122 {
123 if (enableOutput_)
124 velocityBackend->calculateVelocity(velocity, element, fvGeometry, elemVolVars, elemFluxVarsCache, phaseIdx);
125 }
126
127private:
128 const GridVariables& gridVariables_; // TODO: can be removed after the deprecated calculateVelocity interface is removed
129 bool enableOutput_;
130 std::unique_ptr<VelocityBackend> velocityBackend;
131};
132
133} // end namespace Dumux
134
135#endif
Helpers for deprecation.
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Element solution classes and factory functions.
The available discretization methods in Dumux.
Velocity computation for implicit (porous media) models.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
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 computation for implicit (porous media) models.
Definition: velocity.hh:47
Velocity output policy for implicit (porous media) models.
Definition: porousmediumflow/velocityoutput.hh:47
std::string phaseName(int phaseIdx) const override
Returns the phase name of a given phase index.
Definition: porousmediumflow/velocityoutput.hh:95
bool enableOutput() const override
Returns whether or not velocity output is enabled.
Definition: porousmediumflow/velocityoutput.hh:92
void calculateVelocity(VelocityVector &velocity, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFluxVarsCache &elemFluxVarsCache, int phaseIdx) const override
Definition: porousmediumflow/velocityoutput.hh:116
PorousMediumFlowVelocityOutput(const GridVariables &gridVariables)
Constructor initializes the static data with the initial solution.
Definition: porousmediumflow/velocityoutput.hh:82
int numFluidPhases() const override
Returns the number of phases.
Definition: porousmediumflow/velocityoutput.hh:98
void calculateVelocity(VelocityVector &velocity, const ElementVolumeVariables &elemVolVars, const FVElementGeometry &fvGeometry, const Element &element, int phaseIdx) const override
Definition: porousmediumflow/velocityoutput.hh:103
Default velocity output policy for porous media models.