GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/compositional/staggered/fluxvariables.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 14 14 100.0%
Functions: 17 34 50.0%
Branches: 15 15 100.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 FreeflowNCModel
10 * \copydoc Dumux::FreeflowNCFluxVariablesImpl
11 */
12 #ifndef DUMUX_FREEFLOW_NC_STAGGERED_FLUXVARIABLES_HH
13 #define DUMUX_FREEFLOW_NC_STAGGERED_FLUXVARIABLES_HH
14
15 #include <numeric>
16 #include <dumux/common/properties.hh>
17 #include <dumux/flux/fluxvariablesbase.hh>
18 #include <dumux/flux/referencesystemformulation.hh>
19 #include <dumux/discretization/method.hh>
20 #include <dumux/freeflow/navierstokes/fluxvariables.hh>
21
22 namespace Dumux {
23
24 /*!
25 * \ingroup FreeflowNCModel
26 * \brief The flux variables class for the multi-component free-flow model using the staggered grid discretization.
27 */
28
29 // forward declaration
30 template<class TypeTag, class DiscretizationMethod>
31 class FreeflowNCFluxVariablesImpl;
32
33 template<class TypeTag>
34 class FreeflowNCFluxVariablesImpl<TypeTag, DiscretizationMethods::Staggered>
35 : public NavierStokesFluxVariables<TypeTag>
36 {
37 using ParentType = NavierStokesFluxVariables<TypeTag>;
38 using Problem = GetPropType<TypeTag, Properties::Problem>;
39 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
40 using FVElementGeometry = typename GridGeometry::LocalView;
41 using Element = typename GridGeometry::GridView::template Codim<0>::Entity;
42 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
43 using CellCenterPrimaryVariables = GetPropType<TypeTag, Properties::CellCenterPrimaryVariables>;
44 using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
45 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
46 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
47
48 public:
49 static constexpr auto numComponents = ModelTraits::numFluidComponents();
50 static constexpr bool useMoles = ModelTraits::useMoles();
51 using MolecularDiffusionType = GetPropType<TypeTag, Properties::MolecularDiffusionType>;
52
53 /*!
54 * \brief Computes the flux for the cell center residual.
55 */
56 template<class ElementVolumeVariables, class ElementFaceVariables, class FluxVariablesCache>
57 58639176 CellCenterPrimaryVariables computeMassFlux(const Problem& problem,
58 const Element& element,
59 const FVElementGeometry& fvGeometry,
60 const ElementVolumeVariables& elemVolVars,
61 const ElementFaceVariables& elemFaceVars,
62 const SubControlVolumeFace& scvf,
63 const FluxVariablesCache& fluxVarsCache)
64 {
65 58639176 CellCenterPrimaryVariables flux(0.0);
66
67 58639176 const auto diffusiveFluxes = MolecularDiffusionType::flux(problem, element, fvGeometry, elemVolVars, scvf);
68
69 static constexpr auto referenceSystemFormulation = MolecularDiffusionType::referenceSystemFormulation();
70
71
3/3
✓ Branch 0 taken 64630952 times.
✓ Branch 1 taken 111286576 times.
✓ Branch 2 taken 1630720 times.
177548248 for (int compIdx = 0; compIdx < numComponents; ++compIdx)
72 {
73 356727216 auto upwindTerm = [compIdx](const auto& volVars)
74 {
75 237818144 const auto density = useMoles ? volVars.molarDensity() : volVars.density();
76 237818144 const auto fraction = useMoles ? volVars.moleFraction(compIdx) : volVars.massFraction(compIdx);
77 237818144 return density * fraction;
78 };
79
80
2/2
✓ Branch 1 taken 57008456 times.
✓ Branch 2 taken 57008456 times.
118909072 flux[compIdx] = ParentType::advectiveFluxForCellCenter(problem, fvGeometry, elemVolVars, elemFaceVars, scvf, upwindTerm);
81
82 // check for the reference system and adapt units of the diffusive flux accordingly.
83 if (referenceSystemFormulation == ReferenceSystemFormulation::massAveraged)
84 {
85
4/4
✓ Branch 0 taken 57008456 times.
✓ Branch 1 taken 57008456 times.
✓ Branch 2 taken 57008456 times.
✓ Branch 3 taken 57008456 times.
470744128 flux[compIdx] += useMoles ? diffusiveFluxes[compIdx]/FluidSystem::molarMass(compIdx) : diffusiveFluxes[compIdx];
86 }
87 else if (referenceSystemFormulation == ReferenceSystemFormulation::molarAveraged)
88 flux[compIdx] += useMoles ? diffusiveFluxes[compIdx] : diffusiveFluxes[compIdx]*FluidSystem::molarMass(compIdx);
89 else
90 DUNE_THROW(Dune::NotImplemented, "other reference systems than mass and molar averaged are not implemented");
91 }
92
93
94 // in case one balance is substituted by the total mass balance
95 if (ModelTraits::replaceCompEqIdx() < numComponents)
96 {
97 // accumulate fluxes to a total mass based flux
98 Scalar totalMassFlux = 0.0;
99
2/2
✓ Branch 0 taken 98771920 times.
✓ Branch 1 taken 49385960 times.
148157880 for (int compIdx = 0; compIdx < numComponents; ++compIdx)
100
4/4
✓ Branch 0 taken 49385960 times.
✓ Branch 1 taken 49385960 times.
✓ Branch 2 taken 49385960 times.
✓ Branch 3 taken 49385960 times.
296315760 totalMassFlux += useMoles ? flux[compIdx]*FluidSystem::molarMass(compIdx) : flux[compIdx];
101
102 98771920 flux[ModelTraits::replaceCompEqIdx()] = totalMassFlux;
103 }
104
105 58639176 return flux;
106 }
107 };
108
109 } // end namespace
110
111 #endif
112