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 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 | 5 | 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 | 293 | PorousMediumFlowVelocityOutput(const GridVariables& gridVariables) | |
56 | 293 | { | |
57 | // check, if velocity output can be used (works only for cubes so far) | ||
58 |
1/2✓ Branch 1 taken 293 times.
✗ Branch 2 not taken.
|
293 | enableOutput_ = getParamFromGroup<bool>(gridVariables.curGridVolVars().problem().paramGroup(), "Vtk.AddVelocity"); |
59 |
2/2✓ Branch 0 taken 94 times.
✓ Branch 1 taken 199 times.
|
293 | if (enableOutput_) |
60 |
1/2✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
|
94 | velocityBackend = std::make_unique<VelocityBackend>(gridVariables); |
61 | 293 | } | |
62 | |||
63 | //! Returns whether or not velocity output is enabled. | ||
64 | 5886180 | 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.
|
1399 | std::string phaseName(int phaseIdx) const override { return FluidSystem::phaseName(phaseIdx); } |
68 | |||
69 | //! Returns the number of phases. | ||
70 | 2145057 | 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 | 1100520 | 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 1100092 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 428 times.
✗ Branch 3 not taken.
|
1100520 | if (enableOutput_) |
82 |
1/2✓ Branch 2 taken 428 times.
✗ Branch 3 not taken.
|
1100520 | velocityBackend->calculateVelocity(velocity, element, fvGeometry, elemVolVars, elemFluxVarsCache, phaseIdx); |
83 | 1100092 | } | |
84 | |||
85 | private: | ||
86 | bool enableOutput_; | ||
87 | std::unique_ptr<VelocityBackend> velocityBackend; | ||
88 | }; | ||
89 | |||
90 | } // end namespace Dumux | ||
91 | |||
92 | #endif | ||
93 |