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 StaggeredDiscretization | ||
10 | * \copydoc Dumux::StaggeredFreeFlowVelocityOutput | ||
11 | */ | ||
12 | #ifndef DUMUX_STAGGERED_FF_VELOCITYOUTPUT_HH | ||
13 | #define DUMUX_STAGGERED_FF_VELOCITYOUTPUT_HH | ||
14 | |||
15 | #include <dumux/io/velocityoutput.hh> | ||
16 | #include <dumux/common/parameters.hh> | ||
17 | |||
18 | namespace Dumux { | ||
19 | |||
20 | /*! | ||
21 | * \ingroup StaggeredDiscretization | ||
22 | * \brief Velocity output for staggered free-flow models | ||
23 | */ | ||
24 | template<class GridVariables, class SolutionVector> | ||
25 | class StaggeredFreeFlowVelocityOutput : public VelocityOutput<GridVariables> | ||
26 | { | ||
27 | using ParentType = VelocityOutput<GridVariables>; | ||
28 | using GridGeometry = typename GridVariables::GridGeometry; | ||
29 | using Scalar = typename GridVariables::Scalar; | ||
30 | using FVElementGeometry = typename GridGeometry::LocalView; | ||
31 | using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace; | ||
32 | using GridVolumeVariables = typename GridVariables::GridVolumeVariables; | ||
33 | using ElementVolumeVariables = typename GridVolumeVariables::LocalView; | ||
34 | using ElementFluxVarsCache = typename GridVariables::GridFluxVariablesCache::LocalView; | ||
35 | using VolumeVariables = typename GridVariables::VolumeVariables; | ||
36 | using FluidSystem = typename VolumeVariables::FluidSystem; | ||
37 | using GridView = typename GridGeometry::GridView; | ||
38 | // TODO: should be possible to get this somehow | ||
39 | using Problem = typename std::decay_t<decltype(std::declval<GridVolumeVariables>().problem())>; | ||
40 | using Element = typename GridView::template Codim<0>::Entity; | ||
41 | using CoordScalar = typename GridView::ctype; | ||
42 | |||
43 | public: | ||
44 | using VelocityVector = typename ParentType::VelocityVector; | ||
45 | |||
46 | /*! | ||
47 | * \brief Constructor initializes the static data with the initial solution. | ||
48 | * | ||
49 | * \param gridVariables The gridVariables | ||
50 | * \param sol The solution vector | ||
51 | */ | ||
52 | 75 | StaggeredFreeFlowVelocityOutput(const GridVariables& gridVariables, const SolutionVector& sol) | |
53 | 75 | : gridVariables_(gridVariables) | |
54 | 75 | , sol_(sol) | |
55 | { | ||
56 | // check if velocity vectors shall be written to the VTK file | ||
57 | // enable per default | ||
58 | 75 | enableOutput_ = getParamFromGroup<bool>(gridVariables.curGridVolVars().problem().paramGroup(), "Vtk.AddVelocity", true); | |
59 | } | ||
60 | |||
61 | //! Returns whether to enable the velocity output or not | ||
62 | 947030 | bool enableOutput() const override { return enableOutput_; } | |
63 | |||
64 | //! returns the phase name of a given phase index | ||
65 | 1379 | std::string phaseName(int phaseIdx) const override { return FluidSystem::phaseName(phaseIdx); } | |
66 | |||
67 | //! returns the number of phases | ||
68 | 951167 | int numFluidPhases() const override { return VolumeVariables::numFluidPhases(); } | |
69 | |||
70 | //! Calculate the velocities for the scvs in the element | ||
71 | //! We assume the local containers to be bound to the complete stencil | ||
72 | 472136 | void calculateVelocity(VelocityVector& velocity, | |
73 | const Element& element, | ||
74 | const FVElementGeometry& fvGeometry, | ||
75 | const ElementVolumeVariables& elemVolVars, | ||
76 | const ElementFluxVarsCache& elemFluxVarsCache, | ||
77 | int phaseIdx) const override | ||
78 | { | ||
79 | 472136 | auto elemFaceVars = localView(gridVariables_.curGridFaceVars()); | |
80 | 472136 | elemFaceVars.bindElement(element, fvGeometry, sol_); | |
81 |
2/2✓ Branch 0 taken 471536 times.
✓ Branch 1 taken 471536 times.
|
944272 | for (auto&& scv : scvs(fvGeometry)) |
82 | { | ||
83 | 472136 | auto dofIdxGlobal = scv.dofIndex(); | |
84 | |||
85 |
2/2✓ Branch 0 taken 1886144 times.
✓ Branch 1 taken 471536 times.
|
2360680 | for (auto&& scvf : scvfs(fvGeometry)) |
86 | { | ||
87 | 1888544 | auto dirIdx = scvf.directionIndex(); | |
88 | 1888544 | velocity[dofIdxGlobal][dirIdx] += 0.5*elemFaceVars[scvf].velocitySelf(); | |
89 | } | ||
90 | } | ||
91 | 472136 | } | |
92 | |||
93 | private: | ||
94 | const GridVariables& gridVariables_; | ||
95 | const SolutionVector& sol_; | ||
96 | |||
97 | bool enableOutput_ = true; | ||
98 | }; | ||
99 | |||
100 | } // end namespace Dumux | ||
101 | |||
102 | #endif | ||
103 |