GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/navierstokes/velocityoutput.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 10 21 47.6%
Functions: 139 199 69.8%
Branches: 0 10 0.0%

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-FileCopyrightInfo: 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 NavierStokesVelocityOutput(const std::string& paramGroup = "")
47 {
48 enableOutput_ = getParamFromGroup<bool>(paramGroup, "Vtk.AddVelocity", true);
49 }
50
51 //! Returns whether to enable the velocity output or not
52 2516600 bool enableOutput() const override { return enableOutput_; }
53
54 //! returns the phase name of a given phase index
55 270 std::string phaseName(int phaseIdx) const override { return FluidSystem::phaseName(phaseIdx); }
56
57 //! returns the number of phases
58 2506604 int numFluidPhases() const override { return VolumeVariables::numFluidPhases(); }
59
60 //! returns the field type
61 798 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 1252624 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 922338 calculateVelocityForStaggeredGrid_(velocity, element, fvGeometry, elemVolVars);
76 else if constexpr (DiscretizationMethods::isCVFE<typename MomGG::DiscretizationMethod>)
77 330286 calculateVelocityForCVFESchemes_(velocity, element, fvGeometry, elemVolVars);
78 else
79 DUNE_THROW(Dune::NotImplemented, "Navier-Stokes velocity output for scheme " << MomGG::discMethod);
80 1252624 }
81
82 private:
83 void calculateVelocityForStaggeredGrid_(VelocityVector& velocity,
84 const Element& element,
85 const FVElementGeometry& fvGeometry,
86 const ElementVolumeVariables& elemVolVars) const
87 {
88 const auto eIdx = fvGeometry.gridGeometry().elementMapper().index(element);
89 2163328 const auto getFaceVelocity = [&](const FVElementGeometry& fvG, const auto& scvf)
90 {
91 3692952 return elemVolVars.gridVolVars().problem().faceVelocity(element, fvGeometry, scvf);
92 };
93
94 velocity[eIdx] = StaggeredVelocityReconstruction::cellCenterVelocity(getFaceVelocity, fvGeometry);
95 }
96
97 void calculateVelocityForCVFESchemes_(VelocityVector& velocity,
98 const Element& element,
99 const FVElementGeometry& fvGeometry,
100 const ElementVolumeVariables& elemVolVars) const
101 {
102 const auto eIdx = fvGeometry.gridGeometry().elementMapper().index(element);
103 velocity[eIdx] = elemVolVars.gridVolVars().problem().elementVelocity(fvGeometry);
104 }
105
106
107 bool enableOutput_;
108 };
109
110 } // end namespace Dumux
111
112 #endif
113