GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/porousmediumflow/velocityoutput.hh
Date: 2024-09-21 20:52:54
Exec Total Coverage
Lines: 14 14 100.0%
Functions: 595 825 72.1%
Branches: 13 28 46.4%

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 PorousmediumflowModels
10 * \brief Velocity output for porous media models.
11 */
12
13 #ifndef DUMUX_POROUSMEDIUMFLOW_VELOCITYOUTPUT_HH
14 #define DUMUX_POROUSMEDIUMFLOW_VELOCITYOUTPUT_HH
15
16 #include <memory>
17 #include <dune/common/float_cmp.hh>
18
19 #include <dumux/common/parameters.hh>
20 #include <dumux/io/velocityoutput.hh>
21 #include <dumux/discretization/method.hh>
22 #include <dumux/discretization/elementsolution.hh>
23 #include <dumux/porousmediumflow/velocity.hh>
24
25 namespace Dumux {
26
27 /*!
28 * \ingroup PorousmediumflowModels
29 * \brief Velocity output policy for implicit (porous media) models.
30 */
31 template<class GridVariables, class FluxVariables>
32
1/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10 class PorousMediumFlowVelocityOutput : public VelocityOutput<GridVariables>
33 {
34 using ParentType = VelocityOutput<GridVariables>;
35 using GridGeometry = typename GridVariables::GridGeometry;
36 using FVElementGeometry = typename GridGeometry::LocalView;
37 using GridView = typename GridGeometry::GridView;
38 using Element = typename GridView::template Codim<0>::Entity;
39 using GridVolumeVariables = typename GridVariables::GridVolumeVariables;
40 using ElementFluxVarsCache = typename GridVariables::GridFluxVariablesCache::LocalView;
41 using VolumeVariables = typename GridVariables::VolumeVariables;
42 using ElementVolumeVariables = typename GridVolumeVariables::LocalView;
43 using FluidSystem = typename VolumeVariables::FluidSystem;
44
45 using VelocityBackend = PorousMediumFlowVelocity<GridVariables, FluxVariables>;
46
47 public:
48 using VelocityVector = typename ParentType::VelocityVector;
49
50 /*!
51 * \brief Constructor initializes the static data with the initial solution.
52 *
53 * \param gridVariables The grid variables
54 */
55 263 PorousMediumFlowVelocityOutput(const GridVariables& gridVariables)
56 263 {
57 // check, if velocity output can be used (works only for cubes so far)
58
3/6
✓ Branch 1 taken 263 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 263 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 108 times.
✗ Branch 8 not taken.
634 enableOutput_ = getParamFromGroup<bool>(gridVariables.curGridVolVars().problem().paramGroup(), "Vtk.AddVelocity");
59
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 171 times.
263 if (enableOutput_)
60
3/6
✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 92 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 92 times.
92 velocityBackend = std::make_unique<VelocityBackend>(gridVariables);
61 263 }
62
63 //! Returns whether or not velocity output is enabled.
64 5837190 bool enableOutput() const override { return enableOutput_; }
65
66 //! Returns the phase name of a given phase index.
67
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
1334 std::string phaseName(int phaseIdx) const override { return FluidSystem::phaseName(phaseIdx); }
68
69 //! Returns the number of phases.
70 2121572 int numFluidPhases() const override { return VolumeVariables::numFluidPhases(); }
71
72 //! Calculates the velocities for the scvs in the element.
73 //! We assume the local containers to be bound to the complete stencil.
74 1087932 void calculateVelocity(VelocityVector& velocity,
75 const Element& element,
76 const FVElementGeometry& fvGeometry,
77 const ElementVolumeVariables& elemVolVars,
78 const ElementFluxVarsCache& elemFluxVarsCache,
79 int phaseIdx) const override
80 {
81
2/4
✓ Branch 0 taken 1087932 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 428 times.
✗ Branch 3 not taken.
1088360 if (enableOutput_)
82
2/4
✓ Branch 3 taken 428 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 428 times.
✗ Branch 7 not taken.
2176720 velocityBackend->calculateVelocity(velocity, element, fvGeometry, elemVolVars, elemFluxVarsCache, phaseIdx);
83 1087932 }
84
85 private:
86 bool enableOutput_;
87 std::unique_ptr<VelocityBackend> velocityBackend;
88 };
89
90 } // end namespace Dumux
91
92 #endif
93