GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/freeflow/compositional/staggered/localresidual.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 12 13 92.3%
Functions: 0 17 0.0%
Branches: 20 36 55.6%

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::FreeflowNCResidualImpl
11 */
12 #ifndef DUMUX_FREEFLOW_NC_STAGGERED_LOCAL_RESIDUAL_HH
13 #define DUMUX_FREEFLOW_NC_STAGGERED_LOCAL_RESIDUAL_HH
14
15 #include <dumux/common/properties.hh>
16 #include <dumux/discretization/method.hh>
17 #include <dumux/freeflow/navierstokes/localresidual.hh>
18
19 namespace Dumux {
20
21 /*!
22 * \ingroup FreeflowNCModel
23 * \brief Element-wise calculation of the multi-component free-flow residual for models using the staggered discretization
24 */
25
26 // forward declaration
27 template<class TypeTag, class DiscretizationMethod>
28 class FreeflowNCResidualImpl;
29
30 template<class TypeTag>
31 class FreeflowNCResidualImpl<TypeTag, DiscretizationMethods::Staggered>
32 : public NavierStokesResidual<TypeTag>
33 {
34 using ParentType = NavierStokesResidual<TypeTag>;
35
36 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
37 using Problem = GetPropType<TypeTag, Properties::Problem>;
38 using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
39 using GridView = typename GridGeometry::GridView;
40 using Element = typename GridView::template Codim<0>::Entity;
41 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
42 using SubControlVolume = typename FVElementGeometry::SubControlVolume;
43 using CellCenterPrimaryVariables = GetPropType<TypeTag, Properties::CellCenterPrimaryVariables>;
44 using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
45
46 static constexpr int numComponents = ModelTraits::numFluidComponents();
47 static constexpr bool useMoles = getPropValue<TypeTag, Properties::UseMoles>();
48
49 using EnergyLocalResidual = typename ParentType::EnergyLocalResidual;
50
51 public:
52
6/12
✓ Branch 1 taken 409612 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 409612 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 409612 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 409612 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2528 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2528 times.
✗ Branch 15 not taken.
1643504 using ParentType::ParentType;
53
54 //! Evaluate fluxes entering or leaving the cell center control volume.
55 template<class VolumeVariables>
56 CellCenterPrimaryVariables computeStorageForCellCenter(const Problem& problem,
57 const SubControlVolume& scv,
58 const VolumeVariables& volVars) const
59 {
60 5627200 CellCenterPrimaryVariables storage(0.0);
61
62 5627200 const Scalar density = useMoles ? volVars.molarDensity() : volVars.density();
63
64 // compute storage term of all components
65
6/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4279040 times.
✓ Branch 3 taken 1935680 times.
✓ Branch 4 taken 6034880 times.
✓ Branch 5 taken 2813600 times.
✓ Branch 6 taken 1755840 times.
✓ Branch 7 taken 877920 times.
17696960 for (int compIdx = 0; compIdx < numComponents; ++compIdx)
66 {
67 12069760 const int eqIdx = compIdx;
68
69
4/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 877920 times.
✓ Branch 5 taken 877920 times.
✓ Branch 6 taken 877920 times.
✓ Branch 7 taken 877920 times.
12069760 const Scalar massOrMoleFraction = useMoles ? volVars.moleFraction(compIdx) : volVars.massFraction(compIdx);
70 12069760 const Scalar s = density * massOrMoleFraction;
71
72
4/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 877920 times.
✓ Branch 5 taken 877920 times.
✓ Branch 6 taken 877920 times.
✓ Branch 7 taken 877920 times.
3511680 if (eqIdx != ModelTraits::replaceCompEqIdx())
73 20627840 storage[eqIdx] += s;
74 }
75
76 // in case one balance is substituted by the total mass balance (use the mass density)
77 if(ModelTraits::replaceCompEqIdx() < numComponents)
78 3511680 storage[ModelTraits::replaceCompEqIdx()] = volVars.density();
79
80 5627200 EnergyLocalResidual::fluidPhaseStorage(storage, volVars);
81
82 3056000 return storage;
83 }
84 };
85 } // end namespace Dumux
86
87 #endif
88