GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/porousmediumflow/velocityoutput.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 14 14 100.0%
Functions: 585 815 71.8%
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 265 PorousMediumFlowVelocityOutput(const GridVariables& gridVariables)
56 265 {
57 // check, if velocity output can be used (works only for cubes so far)
58
3/6
✓ Branch 1 taken 265 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 265 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 109 times.
✗ Branch 8 not taken.
639 enableOutput_ = getParamFromGroup<bool>(gridVariables.curGridVolVars().problem().paramGroup(), "Vtk.AddVelocity");
59
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 175 times.
265 if (enableOutput_)
60
3/6
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 90 times.
90 velocityBackend = std::make_unique<VelocityBackend>(gridVariables);
61 265 }
62
63 //! Returns whether or not velocity output is enabled.
64 5814452 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.
1345 std::string phaseName(int phaseIdx) const override { return FluidSystem::phaseName(phaseIdx); }
68
69 //! Returns the number of phases.
70 2083137 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 1069292 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 1069292 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 428 times.
✗ Branch 3 not taken.
1069720 if (enableOutput_)
82
2/4
✓ Branch 3 taken 428 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 428 times.
✗ Branch 7 not taken.
2139440 velocityBackend->calculateVelocity(velocity, element, fvGeometry, elemVolVars, elemFluxVarsCache, phaseIdx);
83 1069292 }
84
85 private:
86 bool enableOutput_;
87 std::unique_ptr<VelocityBackend> velocityBackend;
88 };
89
90 } // end namespace Dumux
91
92 #endif
93