version 3.11-dev
Loading...
Searching...
No Matches
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>
23
24namespace Dumux {
25
30template<class GridVariables>
32
33template<Concept::FVGridVariables GridVariables>
34class NavierStokesVelocityOutput<GridVariables> : public VelocityOutput<GridVariables>
35{
36 using ParentType = VelocityOutput<GridVariables>;
37 using GridGeometry = typename GridVariables::GridGeometry;
38 using FVElementGeometry = typename GridGeometry::LocalView;
39 using GridVolumeVariables = typename GridVariables::GridVolumeVariables;
40 using ElementVolumeVariables = typename GridVolumeVariables::LocalView;
41 using ElementFluxVarsCache = typename GridVariables::GridFluxVariablesCache::LocalView;
42 using VolumeVariables = typename GridVariables::VolumeVariables;
43 using FluidSystem = typename VolumeVariables::FluidSystem;
44 using GridView = typename GridGeometry::GridView;
45 using Element = typename GridView::template Codim<0>::Entity;
46 using FieldType = typename ParentType::FieldType;
47
48public:
50
51 NavierStokesVelocityOutput(const std::string& paramGroup = "")
52 {
53 enableOutput_ = getParamFromGroup<bool>(paramGroup, "Vtk.AddVelocity", true);
54 }
55
57 bool enableOutput() const override { return enableOutput_; }
58
60 std::string phaseName(int phaseIdx) const override { return FluidSystem::phaseName(phaseIdx); }
61
63 int numFluidPhases() const override { return VolumeVariables::numFluidPhases(); }
64
66 FieldType fieldType() const override { return FieldType::element; }
67
71 const Element& element,
72 const FVElementGeometry& fvGeometry,
73 const ElementVolumeVariables& elemVolVars,
74 const ElementFluxVarsCache& elemFluxVarsCache,
75 int phaseIdx) const override
76 {
77 using CouplingManager = std::decay_t<decltype(elemVolVars.gridVolVars().problem().couplingManager())>;
78 using MomentumProblem = std::decay_t<decltype(std::declval<CouplingManager>().problem(CouplingManager::freeFlowMomentumIndex))>;
80 if constexpr (MomGG::discMethod == DiscretizationMethods::fcstaggered)
81 calculateVelocityForStaggeredGrid_(velocity, element, fvGeometry, elemVolVars);
83 calculateVelocityForCVFESchemes_(velocity, element, fvGeometry, elemVolVars);
84 else
85 DUNE_THROW(Dune::NotImplemented, "Navier-Stokes velocity output for scheme " << MomGG::discMethod);
86 }
87
88private:
89 void calculateVelocityForStaggeredGrid_(VelocityVector& velocity,
90 const Element& element,
91 const FVElementGeometry& fvGeometry,
92 const ElementVolumeVariables& elemVolVars) const
93 {
94 const auto eIdx = fvGeometry.gridGeometry().elementMapper().index(element);
95 const auto getFaceVelocity = [&](const FVElementGeometry& fvG, const auto& scvf)
96 {
97 return elemVolVars.gridVolVars().problem().faceVelocity(element, fvGeometry, scvf);
98 };
99
100 velocity[eIdx] = StaggeredVelocityReconstruction::cellCenterVelocity(getFaceVelocity, fvGeometry);
101 }
102
103 void calculateVelocityForCVFESchemes_(VelocityVector& velocity,
104 const Element& element,
105 const FVElementGeometry& fvGeometry,
106 const ElementVolumeVariables& elemVolVars) const
107 {
108 const auto eIdx = fvGeometry.gridGeometry().elementMapper().index(element);
109 velocity[eIdx] = elemVolVars.gridVolVars().problem().elementVelocity(fvGeometry);
110 }
111
112
113 bool enableOutput_;
114};
115
116template<Concept::GridVariables GridVariables>
117class NavierStokesVelocityOutput<GridVariables> : public VelocityOutput<GridVariables>
118{
119 using ParentType = VelocityOutput<GridVariables>;
120 using GridGeometry = typename GridVariables::GridGeometry;
121 using FVElementGeometry = typename GridGeometry::LocalView;
122 using GridVariablesCache = typename GridVariables::GridVariablesCache;
123 using ElementVariables = typename GridVariablesCache::LocalView;
124 using Variables = typename ElementVariables::Variables;
125 using FluidSystem = typename Variables::FluidSystem;
126 using GridView = typename GridGeometry::GridView;
127 using Element = typename GridView::template Codim<0>::Entity;
128 using FieldType = typename ParentType::FieldType;
129
130public:
132
133 NavierStokesVelocityOutput(const std::string& paramGroup = "")
134 {
135 enableOutput_ = getParamFromGroup<bool>(paramGroup, "Vtk.AddVelocity", true);
136 }
137
138 bool enableOutput() const override { return enableOutput_; }
139
140 std::string phaseName(int phaseIdx) const override { return FluidSystem::phaseName(phaseIdx); }
141
142 int numFluidPhases() const override { return Variables::numFluidPhases(); }
143
144 FieldType fieldType() const override { return FieldType::element; }
145
147 const Element& element,
148 const FVElementGeometry& fvGeometry,
149 const ElementVariables& elemVars,
150 int phaseIdx) const override
151 {
152 using CouplingManager = std::decay_t<decltype(elemVars.gridVariablesCache().problem().couplingManager())>;
153 using MomentumProblem = std::decay_t<decltype(std::declval<CouplingManager>().problem(CouplingManager::freeFlowMomentumIndex))>;
155 if constexpr (MomGG::discMethod == DiscretizationMethods::fcstaggered)
156 calculateVelocityForStaggeredGrid_(velocity, element, fvGeometry, elemVars);
158 calculateVelocityForCVFESchemes_(velocity, element, fvGeometry, elemVars);
159 else
160 DUNE_THROW(Dune::NotImplemented, "Navier-Stokes velocity output for scheme " << MomGG::discMethod);
161 }
162
163private:
164 void calculateVelocityForStaggeredGrid_(VelocityVector& velocity,
165 const Element& element,
166 const FVElementGeometry& fvGeometry,
167 const ElementVariables& elemVars) const
168 {
169 const auto eIdx = fvGeometry.gridGeometry().elementMapper().index(element);
170 const auto getFaceVelocity = [&](const FVElementGeometry& fvG, const auto& scvf)
171 {
172 return elemVars.gridVariablesCache().problem().faceVelocity(element, fvGeometry, scvf);
173 };
174
175 velocity[eIdx] = StaggeredVelocityReconstruction::cellCenterVelocity(getFaceVelocity, fvGeometry);
176 }
177
178 void calculateVelocityForCVFESchemes_(VelocityVector& velocity,
179 const Element& element,
180 const FVElementGeometry& fvGeometry,
181 const ElementVariables& elemVars) const
182 {
183 const auto eIdx = fvGeometry.gridGeometry().elementMapper().index(element);
184 velocity[eIdx] = elemVars.gridVariablesCache().problem().elementVelocity(fvGeometry);
185 }
186
187 bool enableOutput_;
188};
189
190} // end namespace Dumux
191
192#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:318
NavierStokesVelocityOutput(const std::string &paramGroup="")
Definition freeflow/navierstokes/momentum/velocityoutput.hh:51
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:70
std::string phaseName(int phaseIdx) const override
returns the phase name of a given phase index
Definition freeflow/navierstokes/momentum/velocityoutput.hh:60
typename ParentType::VelocityVector VelocityVector
Definition freeflow/navierstokes/momentum/velocityoutput.hh:49
void calculateVelocity(VelocityVector &velocity, const Element &element, const FVElementGeometry &fvGeometry, const ElementVariables &elemVars, int phaseIdx) const override
Definition freeflow/navierstokes/momentum/velocityoutput.hh:146
bool enableOutput() const override
Returns whether to enable the velocity output or not.
Definition freeflow/navierstokes/momentum/velocityoutput.hh:57
FieldType fieldType() const override
returns the field type
Definition freeflow/navierstokes/momentum/velocityoutput.hh:66
int numFluidPhases() const override
returns the number of phases
Definition freeflow/navierstokes/momentum/velocityoutput.hh:63
Velocity output for staggered free-flow models.
Definition freeflow/navierstokes/momentum/velocityoutput.hh:31
FieldType
A container for possible velocity data types.
Definition io/velocityoutput.hh:46
VelocityOutput()=default
Default constructor.
std::vector< Dune::FieldVector< Scalar, dimWorld > > VelocityVector
Definition io/velocityoutput.hh:40
Velocity output for implicit (porous media) models.
Definition io/velocityoutput.hh:27
Type traits for problem classes.
FieldType
Identifier for vtk field types.
Definition fieldtype.hh:22
T getParamFromGroup(Args &&... args)
A free function to get a parameter from the parameter tree singleton with a model group.
Definition parameters.hh:149
Default velocity output policy for porous media models.
The available discretization methods in Dumux.
constexpr bool isCVFE
Definition method.hh:67
constexpr FCStaggered fcstaggered
Definition method.hh:183
Definition adapt.hh:17
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Detail::ProblemGridGeometry< Problem > GridGeometry
Definition common/typetraits/problem.hh:50
static auto cellCenterVelocity(const VelocityHelper &getFaceVelocity, const FVElementGeometry &fvGeometry)
Return the velocity vector at the center of the primal grid.
Definition velocityreconstruction.hh:30
Helper class for reconstructing the velocity.