3.3.0
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
discretization/staggered/freeflow/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 *****************************************************************************/
24#ifndef DUMUX_STAGGERED_FF_VELOCITYOUTPUT_HH
25#define DUMUX_STAGGERED_FF_VELOCITYOUTPUT_HH
26
29
30namespace Dumux {
31
36template<class GridVariables, class SolutionVector>
38{
40 using GridGeometry = typename GridVariables::GridGeometry;
41 using Scalar = typename GridVariables::Scalar;
42 using FVElementGeometry = typename GridGeometry::LocalView;
43 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
44 using GridVolumeVariables = typename GridVariables::GridVolumeVariables;
45 using ElementVolumeVariables = typename GridVolumeVariables::LocalView;
46 using ElementFluxVarsCache = typename GridVariables::GridFluxVariablesCache::LocalView;
47 using VolumeVariables = typename GridVariables::VolumeVariables;
48 using FluidSystem = typename VolumeVariables::FluidSystem;
49 using GridView = typename GridGeometry::GridView;
50 // TODO: should be possible to get this somehow
51 using Problem = typename std::decay_t<decltype(std::declval<GridVolumeVariables>().problem())>;
52 using Element = typename GridView::template Codim<0>::Entity;
53 using CoordScalar = typename GridView::ctype;
54
55public:
57
64 StaggeredFreeFlowVelocityOutput(const GridVariables& gridVariables, const SolutionVector& sol)
65 : gridVariables_(gridVariables)
66 , sol_(sol)
67 {
68 // check if velocity vectors shall be written to the VTK file
69 // enable per default
70 enableOutput_ = getParamFromGroup<bool>(gridVariables.curGridVolVars().problem().paramGroup(), "Vtk.AddVelocity", true);
71 }
72
74 bool enableOutput() const override { return enableOutput_; }
75
77 std::string phaseName(int phaseIdx) const override { return FluidSystem::phaseName(phaseIdx); }
78
80 int numFluidPhases() const override { return VolumeVariables::numFluidPhases(); }
81
85 const Element& element,
86 const FVElementGeometry& fvGeometry,
87 const ElementVolumeVariables& elemVolVars,
88 const ElementFluxVarsCache& elemFluxVarsCache,
89 int phaseIdx) const override
90 {
91 auto elemFaceVars = localView(gridVariables_.curGridFaceVars());
92 elemFaceVars.bindElement(element, fvGeometry, sol_);
93 for (auto&& scv : scvs(fvGeometry))
94 {
95 auto dofIdxGlobal = scv.dofIndex();
96
97 for (auto&& scvf : scvfs(fvGeometry))
98 {
99 auto dirIdx = scvf.directionIndex();
100 velocity[dofIdxGlobal][dirIdx] += 0.5*elemFaceVars[scvf].velocitySelf();
101 }
102 }
103 }
104
105private:
106 const GridVariables& gridVariables_;
107 const SolutionVector& sol_;
108
109 bool enableOutput_ = true;
110};
111
112} // end namespace Dumux
113
114#endif
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
Definition: adapt.hh:29
Velocity output for staggered free-flow models.
Definition: discretization/staggered/freeflow/velocityoutput.hh:38
void calculateVelocity(VelocityVector &velocity, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFluxVarsCache &elemFluxVarsCache, int phaseIdx) const override
Definition: discretization/staggered/freeflow/velocityoutput.hh:84
StaggeredFreeFlowVelocityOutput(const GridVariables &gridVariables, const SolutionVector &sol)
Constructor initializes the static data with the initial solution.
Definition: discretization/staggered/freeflow/velocityoutput.hh:64
bool enableOutput() const override
Returns whether to enable the velocity output or not.
Definition: discretization/staggered/freeflow/velocityoutput.hh:74
std::string phaseName(int phaseIdx) const override
returns the phase name of a given phase index
Definition: discretization/staggered/freeflow/velocityoutput.hh:77
int numFluidPhases() const override
returns the number of phases
Definition: discretization/staggered/freeflow/velocityoutput.hh:80
typename ParentType::VelocityVector VelocityVector
Definition: discretization/staggered/freeflow/velocityoutput.hh:56
Velocity output for implicit (porous media) models.
Definition: io/velocityoutput.hh:41
std::vector< Dune::FieldVector< Scalar, dimWorld > > VelocityVector
Definition: io/velocityoutput.hh:50
Default velocity output policy for porous media models.