version 3.11-dev
freeflow/navierstokes/momentum/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-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_FREEFLOW_NAVIERSTOKES_MOMENTUM_VELOCITYOUTPUT_HH
13#define DUMUX_FREEFLOW_NAVIERSTOKES_MOMENTUM_VELOCITYOUTPUT_HH
14
15#include <type_traits>
16#include <dune/common/exceptions.hh>
19#include <dumux/common/concepts/variables_.hh>
22
23namespace Dumux {
24
29template<class GridVariables>
31
32template<Concept::FVGridVariables GridVariables>
33class NavierStokesVelocityOutput<GridVariables> : public VelocityOutput<GridVariables>
34{
36 using GridGeometry = typename GridVariables::GridGeometry;
37 using FVElementGeometry = typename GridGeometry::LocalView;
38 using GridVolumeVariables = typename GridVariables::GridVolumeVariables;
39 using ElementVolumeVariables = typename GridVolumeVariables::LocalView;
40 using ElementFluxVarsCache = typename GridVariables::GridFluxVariablesCache::LocalView;
41 using VolumeVariables = typename GridVariables::VolumeVariables;
42 using FluidSystem = typename VolumeVariables::FluidSystem;
43 using GridView = typename GridGeometry::GridView;
44 using Element = typename GridView::template Codim<0>::Entity;
45 using FieldType = typename ParentType::FieldType;
46
47public:
49
50 NavierStokesVelocityOutput(const std::string& paramGroup = "")
51 {
52 enableOutput_ = getParamFromGroup<bool>(paramGroup, "Vtk.AddVelocity", true);
53 }
54
56 bool enableOutput() const override { return enableOutput_; }
57
59 std::string phaseName(int phaseIdx) const override { return FluidSystem::phaseName(phaseIdx); }
60
62 int numFluidPhases() const override { return VolumeVariables::numFluidPhases(); }
63
65 FieldType fieldType() const override { return FieldType::element; }
66
70 const Element& element,
71 const FVElementGeometry& fvGeometry,
72 const ElementVolumeVariables& elemVolVars,
73 const ElementFluxVarsCache& elemFluxVarsCache,
74 int phaseIdx) const override
75 {
76 using CouplingManager = std::decay_t<decltype(elemVolVars.gridVolVars().problem().couplingManager())>;
77 using MomGG = std::decay_t<decltype(std::declval<CouplingManager>().problem(CouplingManager::freeFlowMomentumIndex).gridGeometry())>;
78 if constexpr (MomGG::discMethod == DiscretizationMethods::fcstaggered)
79 calculateVelocityForStaggeredGrid_(velocity, element, fvGeometry, elemVolVars);
80 else if constexpr (DiscretizationMethods::isCVFE<typename MomGG::DiscretizationMethod>)
81 calculateVelocityForCVFESchemes_(velocity, element, fvGeometry, elemVolVars);
82 else
83 DUNE_THROW(Dune::NotImplemented, "Navier-Stokes velocity output for scheme " << MomGG::discMethod);
84 }
85
86private:
87 void calculateVelocityForStaggeredGrid_(VelocityVector& velocity,
88 const Element& element,
89 const FVElementGeometry& fvGeometry,
90 const ElementVolumeVariables& elemVolVars) const
91 {
92 const auto eIdx = fvGeometry.gridGeometry().elementMapper().index(element);
93 const auto getFaceVelocity = [&](const FVElementGeometry& fvG, const auto& scvf)
94 {
95 return elemVolVars.gridVolVars().problem().faceVelocity(element, fvGeometry, scvf);
96 };
97
98 velocity[eIdx] = StaggeredVelocityReconstruction::cellCenterVelocity(getFaceVelocity, fvGeometry);
99 }
100
101 void calculateVelocityForCVFESchemes_(VelocityVector& velocity,
102 const Element& element,
103 const FVElementGeometry& fvGeometry,
104 const ElementVolumeVariables& elemVolVars) const
105 {
106 const auto eIdx = fvGeometry.gridGeometry().elementMapper().index(element);
107 velocity[eIdx] = elemVolVars.gridVolVars().problem().elementVelocity(fvGeometry);
108 }
109
110
111 bool enableOutput_;
112};
113
114template<Concept::GridVariables GridVariables>
115class NavierStokesVelocityOutput<GridVariables> : public VelocityOutput<GridVariables>
116{
117 using ParentType = VelocityOutput<GridVariables>;
118 using GridGeometry = typename GridVariables::GridGeometry;
119 using FVElementGeometry = typename GridGeometry::LocalView;
120 using GridVariablesCache = typename GridVariables::GridVariablesCache;
121 using ElementVariables = typename GridVariablesCache::LocalView;
122 using Variables = typename ElementVariables::Variables;
123 using FluidSystem = typename Variables::FluidSystem;
124 using GridView = typename GridGeometry::GridView;
125 using Element = typename GridView::template Codim<0>::Entity;
126 using FieldType = typename ParentType::FieldType;
127
128public:
130
131 NavierStokesVelocityOutput(const std::string& paramGroup = "")
132 {
133 enableOutput_ = getParamFromGroup<bool>(paramGroup, "Vtk.AddVelocity", true);
134 }
135
136 bool enableOutput() const override { return enableOutput_; }
137
138 std::string phaseName(int phaseIdx) const override { return FluidSystem::phaseName(phaseIdx); }
139
140 int numFluidPhases() const override { return Variables::numFluidPhases(); }
141
142 FieldType fieldType() const override { return FieldType::element; }
143
145 const Element& element,
146 const FVElementGeometry& fvGeometry,
147 const ElementVariables& elemVars,
148 int phaseIdx) const override
149 {
150 using CouplingManager = std::decay_t<decltype(elemVars.gridVariablesCache().problem().couplingManager())>;
151 using MomGG = std::decay_t<decltype(std::declval<CouplingManager>().problem(CouplingManager::freeFlowMomentumIndex).gridGeometry())>;
152 if constexpr (MomGG::discMethod == DiscretizationMethods::fcstaggered)
153 calculateVelocityForStaggeredGrid_(velocity, element, fvGeometry, elemVars);
154 else if constexpr (DiscretizationMethods::isCVFE<typename MomGG::DiscretizationMethod>)
155 calculateVelocityForCVFESchemes_(velocity, element, fvGeometry, elemVars);
156 else
157 DUNE_THROW(Dune::NotImplemented, "Navier-Stokes velocity output for scheme " << MomGG::discMethod);
158 }
159
160private:
161 void calculateVelocityForStaggeredGrid_(VelocityVector& velocity,
162 const Element& element,
163 const FVElementGeometry& fvGeometry,
164 const ElementVariables& elemVars) const
165 {
166 const auto eIdx = fvGeometry.gridGeometry().elementMapper().index(element);
167 const auto getFaceVelocity = [&](const FVElementGeometry& fvG, const auto& scvf)
168 {
169 return elemVars.gridVariablesCache().problem().faceVelocity(element, fvGeometry, scvf);
170 };
171
172 velocity[eIdx] = StaggeredVelocityReconstruction::cellCenterVelocity(getFaceVelocity, fvGeometry);
173 }
174
175 void calculateVelocityForCVFESchemes_(VelocityVector& velocity,
176 const Element& element,
177 const FVElementGeometry& fvGeometry,
178 const ElementVariables& elemVars) const
179 {
180 const auto eIdx = fvGeometry.gridGeometry().elementMapper().index(element);
181 velocity[eIdx] = elemVars.gridVariablesCache().problem().elementVelocity(fvGeometry);
182 }
183
184 bool enableOutput_;
185};
186
187} // end namespace Dumux
188
189#endif
The interface of the coupling manager for multi domain problems.
Definition: multidomain/couplingmanager.hh:37
const Problem< i > & problem(Dune::index_constant< i > domainIdx) const
Return a reference to the sub problem.
Definition: multidomain/couplingmanager.hh:319
NavierStokesVelocityOutput(const std::string &paramGroup="")
Definition: freeflow/navierstokes/momentum/velocityoutput.hh:50
void calculateVelocity(VelocityVector &velocity, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFluxVarsCache &elemFluxVarsCache, int phaseIdx) const override
Definition: freeflow/navierstokes/momentum/velocityoutput.hh:69
std::string phaseName(int phaseIdx) const override
returns the phase name of a given phase index
Definition: freeflow/navierstokes/momentum/velocityoutput.hh:59
typename ParentType::VelocityVector VelocityVector
Definition: freeflow/navierstokes/momentum/velocityoutput.hh:48
void calculateVelocity(VelocityVector &velocity, const Element &element, const FVElementGeometry &fvGeometry, const ElementVariables &elemVars, int phaseIdx) const override
Definition: freeflow/navierstokes/momentum/velocityoutput.hh:144
bool enableOutput() const override
Returns whether to enable the velocity output or not.
Definition: freeflow/navierstokes/momentum/velocityoutput.hh:56
FieldType fieldType() const override
returns the field type
Definition: freeflow/navierstokes/momentum/velocityoutput.hh:65
int numFluidPhases() const override
returns the number of phases
Definition: freeflow/navierstokes/momentum/velocityoutput.hh:62
Velocity output for staggered free-flow models.
Definition: freeflow/navierstokes/momentum/velocityoutput.hh:30
Definition: io/velocityoutput.hh:31
std::vector< Dune::FieldVector< Scalar, dimWorld > > VelocityVector
Definition: io/velocityoutput.hh:40
FieldType
A container for possible velocity data types.
Definition: io/velocityoutput.hh:46
Velocity output for implicit (porous media) models.
Definition: io/velocityoutput.hh:27
FieldType
Identifier for vtk field types.
Definition: fieldtype.hh:22
Default velocity output policy for porous media models.
The available discretization methods in Dumux.
constexpr FCStaggered fcstaggered
Definition: method.hh:161
static constexpr auto freeFlowMomentumIndex
Definition: multidomain/boundary/freeflowporenetwork/couplingmanager.hh:34
Definition: adapt.hh:17
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
static auto cellCenterVelocity(const VelocityHelper &getFaceVelocity, const FVElementGeometry &fvGeometry)
Return the velocity vector at the center of the primal grid.
Definition: velocityreconstruction.hh:30