GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/compositional/staggered/fluxvariables.hh
Date: 2024-09-21 20:52:54
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 57530926 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 57530926 CellCenterPrimaryVariables flux(0.0);
66
67 57530926 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 63522702 times.
✓ Branch 1 taken 109070076 times.
✓ Branch 2 taken 1630720 times.
174223498 for (int compIdx = 0; compIdx < numComponents; ++compIdx)
72 {
73 350077716 auto upwindTerm = [compIdx](const auto& volVars)
74 {
75 233385144 const auto density = useMoles ? volVars.molarDensity() : volVars.density();
76 233385144 const auto fraction = useMoles ? volVars.moleFraction(compIdx) : volVars.massFraction(compIdx);
77 233385144 return density * fraction;
78 };
79
80
2/2
✓ Branch 1 taken 55900206 times.
✓ Branch 2 taken 55900206 times.
116692572 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 55900206 times.
✓ Branch 1 taken 55900206 times.
✓ Branch 2 taken 55900206 times.
✓ Branch 3 taken 55900206 times.
461878128 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 96555420 times.
✓ Branch 1 taken 48277710 times.
144833130 for (int compIdx = 0; compIdx < numComponents; ++compIdx)
100
4/4
✓ Branch 0 taken 48277710 times.
✓ Branch 1 taken 48277710 times.
✓ Branch 2 taken 48277710 times.
✓ Branch 3 taken 48277710 times.
289666260 totalMassFlux += useMoles ? flux[compIdx]*FluidSystem::molarMass(compIdx) : flux[compIdx];
101
102 96555420 flux[ModelTraits::replaceCompEqIdx()] = totalMassFlux;
103 }
104
105 57530926 return flux;
106 }
107 };
108
109 } // end namespace
110
111 #endif
112