version 3.8
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// 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_STAGGERED_FF_VELOCITYOUTPUT_HH
13#define DUMUX_STAGGERED_FF_VELOCITYOUTPUT_HH
14
17
18namespace Dumux {
19
24template<class GridVariables, class SolutionVector>
26{
28 using GridGeometry = typename GridVariables::GridGeometry;
29 using Scalar = typename GridVariables::Scalar;
30 using FVElementGeometry = typename GridGeometry::LocalView;
31 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
32 using GridVolumeVariables = typename GridVariables::GridVolumeVariables;
33 using ElementVolumeVariables = typename GridVolumeVariables::LocalView;
34 using ElementFluxVarsCache = typename GridVariables::GridFluxVariablesCache::LocalView;
35 using VolumeVariables = typename GridVariables::VolumeVariables;
36 using FluidSystem = typename VolumeVariables::FluidSystem;
37 using GridView = typename GridGeometry::GridView;
38 // TODO: should be possible to get this somehow
39 using Problem = typename std::decay_t<decltype(std::declval<GridVolumeVariables>().problem())>;
40 using Element = typename GridView::template Codim<0>::Entity;
41 using CoordScalar = typename GridView::ctype;
42
43public:
45
52 StaggeredFreeFlowVelocityOutput(const GridVariables& gridVariables, const SolutionVector& sol)
53 : gridVariables_(gridVariables)
54 , sol_(sol)
55 {
56 // check if velocity vectors shall be written to the VTK file
57 // enable per default
58 enableOutput_ = getParamFromGroup<bool>(gridVariables.curGridVolVars().problem().paramGroup(), "Vtk.AddVelocity", true);
59 }
60
62 bool enableOutput() const override { return enableOutput_; }
63
65 std::string phaseName(int phaseIdx) const override { return FluidSystem::phaseName(phaseIdx); }
66
68 int numFluidPhases() const override { return VolumeVariables::numFluidPhases(); }
69
73 const Element& element,
74 const FVElementGeometry& fvGeometry,
75 const ElementVolumeVariables& elemVolVars,
76 const ElementFluxVarsCache& elemFluxVarsCache,
77 int phaseIdx) const override
78 {
79 auto elemFaceVars = localView(gridVariables_.curGridFaceVars());
80 elemFaceVars.bindElement(element, fvGeometry, sol_);
81 for (auto&& scv : scvs(fvGeometry))
82 {
83 auto dofIdxGlobal = scv.dofIndex();
84
85 for (auto&& scvf : scvfs(fvGeometry))
86 {
87 auto dirIdx = scvf.directionIndex();
88 velocity[dofIdxGlobal][dirIdx] += 0.5*elemFaceVars[scvf].velocitySelf();
89 }
90 }
91 }
92
93private:
94 const GridVariables& gridVariables_;
95 const SolutionVector& sol_;
96
97 bool enableOutput_ = true;
98};
99
100} // end namespace Dumux
101
102#endif
Velocity output for staggered free-flow models.
Definition: discretization/staggered/freeflow/velocityoutput.hh:26
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:72
StaggeredFreeFlowVelocityOutput(const GridVariables &gridVariables, const SolutionVector &sol)
Constructor initializes the static data with the initial solution.
Definition: discretization/staggered/freeflow/velocityoutput.hh:52
bool enableOutput() const override
Returns whether to enable the velocity output or not.
Definition: discretization/staggered/freeflow/velocityoutput.hh:62
std::string phaseName(int phaseIdx) const override
returns the phase name of a given phase index
Definition: discretization/staggered/freeflow/velocityoutput.hh:65
int numFluidPhases() const override
returns the number of phases
Definition: discretization/staggered/freeflow/velocityoutput.hh:68
typename ParentType::VelocityVector VelocityVector
Definition: discretization/staggered/freeflow/velocityoutput.hh:44
Velocity output for implicit (porous media) models.
Definition: io/velocityoutput.hh:29
std::vector< Dune::FieldVector< Scalar, dimWorld > > VelocityVector
Definition: io/velocityoutput.hh:38
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:26
Default velocity output policy for porous media models.
Definition: adapt.hh:17
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.