Line | Branch | Exec | Source |
---|---|---|---|
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 | // | ||
7 | /*! | ||
8 | * \file | ||
9 | * \ingroup NavierStokesModel | ||
10 | * \copydoc Dumux::StaggeredFreeFlowVelocityOutput | ||
11 | */ | ||
12 | #ifndef DUMUX_FREEFLOW_NAVIERSTOKES_VELOCITYOUTPUT_HH | ||
13 | #define DUMUX_FREEFLOW_NAVIERSTOKES_VELOCITYOUTPUT_HH | ||
14 | |||
15 | #include <type_traits> | ||
16 | #include <dune/common/exceptions.hh> | ||
17 | #include <dumux/io/velocityoutput.hh> | ||
18 | #include <dumux/common/parameters.hh> | ||
19 | #include <dumux/discretization/method.hh> | ||
20 | #include <dumux/freeflow/navierstokes/momentum/velocityreconstruction.hh> | ||
21 | |||
22 | namespace Dumux { | ||
23 | |||
24 | /*! | ||
25 | * \ingroup NavierStokesModel | ||
26 | * \brief Velocity output for staggered free-flow models | ||
27 | */ | ||
28 | template<class GridVariables> | ||
29 | class NavierStokesVelocityOutput : public VelocityOutput<GridVariables> | ||
30 | { | ||
31 | using ParentType = VelocityOutput<GridVariables>; | ||
32 | using GridGeometry = typename GridVariables::GridGeometry; | ||
33 | using FVElementGeometry = typename GridGeometry::LocalView; | ||
34 | using GridVolumeVariables = typename GridVariables::GridVolumeVariables; | ||
35 | using ElementVolumeVariables = typename GridVolumeVariables::LocalView; | ||
36 | using ElementFluxVarsCache = typename GridVariables::GridFluxVariablesCache::LocalView; | ||
37 | using VolumeVariables = typename GridVariables::VolumeVariables; | ||
38 | using FluidSystem = typename VolumeVariables::FluidSystem; | ||
39 | using GridView = typename GridGeometry::GridView; | ||
40 | using Element = typename GridView::template Codim<0>::Entity; | ||
41 | using FieldType = typename ParentType::FieldType; | ||
42 | |||
43 | public: | ||
44 | using VelocityVector = typename ParentType::VelocityVector; | ||
45 | |||
46 | 78 | NavierStokesVelocityOutput(const std::string& paramGroup = "") | |
47 | 78 | { | |
48 |
1/2✓ Branch 1 taken 78 times.
✗ Branch 2 not taken.
|
78 | enableOutput_ = getParamFromGroup<bool>(paramGroup, "Vtk.AddVelocity", true); |
49 | } | ||
50 | |||
51 | //! Returns whether to enable the velocity output or not | ||
52 | 2690300 | bool enableOutput() const override { return enableOutput_; } | |
53 | |||
54 | //! returns the phase name of a given phase index | ||
55 | 373 | std::string phaseName(int phaseIdx) const override { return FluidSystem::phaseName(phaseIdx); } | |
56 | |||
57 | //! returns the number of phases | ||
58 | 2680613 | int numFluidPhases() const override { return VolumeVariables::numFluidPhases(); } | |
59 | |||
60 | //! returns the field type | ||
61 | 1107 | FieldType fieldType() const override { return FieldType::element; } | |
62 | |||
63 | //! Calculate the velocities for the scvs in the element | ||
64 | //! We assume the local containers to be bound to the complete stencil | ||
65 | 1339371 | void calculateVelocity(VelocityVector& velocity, | |
66 | const Element& element, | ||
67 | const FVElementGeometry& fvGeometry, | ||
68 | const ElementVolumeVariables& elemVolVars, | ||
69 | const ElementFluxVarsCache& elemFluxVarsCache, | ||
70 | int phaseIdx) const override | ||
71 | { | ||
72 | using CouplingManager = std::decay_t<decltype(elemVolVars.gridVolVars().problem().couplingManager())>; | ||
73 | using MomGG = std::decay_t<decltype(std::declval<CouplingManager>().problem(CouplingManager::freeFlowMomentumIndex).gridGeometry())>; | ||
74 | if constexpr (MomGG::discMethod == DiscretizationMethods::fcstaggered) | ||
75 | 1007199 | calculateVelocityForStaggeredGrid_(velocity, element, fvGeometry, elemVolVars); | |
76 | else if constexpr (DiscretizationMethods::isCVFE<typename MomGG::DiscretizationMethod>) | ||
77 | 332172 | calculateVelocityForCVFESchemes_(velocity, element, fvGeometry, elemVolVars); | |
78 | else | ||
79 | DUNE_THROW(Dune::NotImplemented, "Navier-Stokes velocity output for scheme " << MomGG::discMethod); | ||
80 | 1339371 | } | |
81 | |||
82 | private: | ||
83 | 1007199 | void calculateVelocityForStaggeredGrid_(VelocityVector& velocity, | |
84 | const Element& element, | ||
85 | const FVElementGeometry& fvGeometry, | ||
86 | const ElementVolumeVariables& elemVolVars) const | ||
87 | { | ||
88 | 1007199 | const auto eIdx = fvGeometry.gridGeometry().elementMapper().index(element); | |
89 | 5043367 | const auto getFaceVelocity = [&](const FVElementGeometry& fvG, const auto& scvf) | |
90 | { | ||
91 | 4036168 | return elemVolVars.gridVolVars().problem().faceVelocity(element, fvGeometry, scvf); | |
92 | }; | ||
93 | |||
94 | 1007199 | velocity[eIdx] = StaggeredVelocityReconstruction::cellCenterVelocity(getFaceVelocity, fvGeometry); | |
95 | 1007199 | } | |
96 | |||
97 | 332172 | void calculateVelocityForCVFESchemes_(VelocityVector& velocity, | |
98 | const Element& element, | ||
99 | const FVElementGeometry& fvGeometry, | ||
100 | const ElementVolumeVariables& elemVolVars) const | ||
101 | { | ||
102 | 332172 | const auto eIdx = fvGeometry.gridGeometry().elementMapper().index(element); | |
103 | 332172 | velocity[eIdx] = elemVolVars.gridVolVars().problem().elementVelocity(fvGeometry); | |
104 | 332172 | } | |
105 | |||
106 | |||
107 | bool enableOutput_; | ||
108 | }; | ||
109 | |||
110 | } // end namespace Dumux | ||
111 | |||
112 | #endif | ||
113 |