GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/freeflow/compositional/staggered/localresidual.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 13 13 100.0%
Functions: 0 0 -%
Branches: 15 18 83.3%

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 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
3/6
✓ Branch 1 taken 409740 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 409740 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2528 times.
✗ Branch 7 not taken.
822008 using ParentType::ParentType;
53
54 //! Evaluate fluxes entering or leaving the cell center control volume.
55 template<class VolumeVariables>
56 29603880 CellCenterPrimaryVariables computeStorageForCellCenter(const Problem& problem,
57 const SubControlVolume& scv,
58 const VolumeVariables& volVars) const
59 {
60 29603880 CellCenterPrimaryVariables storage(0.0);
61
62 29603880 const Scalar density = useMoles ? volVars.molarDensity() : volVars.density();
63
64 // compute storage term of all components
65
4/4
✓ Branch 0 taken 39829560 times.
✓ Branch 1 taken 19710940 times.
✓ Branch 2 taken 20193560 times.
✓ Branch 3 taken 9892940 times.
79734060 for (int compIdx = 0; compIdx < numComponents; ++compIdx)
66 {
67 60023120 const int eqIdx = compIdx;
68
69
4/4
✓ Branch 0 taken 17396420 times.
✓ Branch 1 taken 17396420 times.
✓ Branch 2 taken 7578420 times.
✓ Branch 3 taken 7578420 times.
60023120 const Scalar massOrMoleFraction = useMoles ? volVars.moleFraction(compIdx) : volVars.massFraction(compIdx);
70 60023120 const Scalar s = density * massOrMoleFraction;
71
72
4/4
✓ Branch 0 taken 17396420 times.
✓ Branch 1 taken 17396420 times.
✓ Branch 2 taken 7578420 times.
✓ Branch 3 taken 7578420 times.
49949680 if (eqIdx != ModelTraits::replaceCompEqIdx())
73 35048280 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 24974840 storage[ModelTraits::replaceCompEqIdx()] = volVars.density();
79
80 13249984 EnergyLocalResidual::fluidPhaseStorage(storage, volVars);
81
82 3059696 return storage;
83 }
84 };
85 } // end namespace Dumux
86
87 #endif
88