GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/porousmediumflow/fluxvariablescache.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 8 14 57.1%
Functions: 0 141 0.0%
Branches: 16 24 66.7%

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 PorousmediumflowModels
10 * \brief Base class for the flux variables.
11 */
12 #ifndef DUMUX_POROUSMEDIUM_FLUXVARIABLESCACHE_HH
13 #define DUMUX_POROUSMEDIUM_FLUXVARIABLESCACHE_HH
14
15 #include <dumux/common/properties.hh>
16 #include <dumux/discretization/method.hh>
17 #include <dumux/flux/fluxvariablescaching.hh>
18 #include <dumux/discretization/cvfe/fluxvariablescache.hh>
19
20 namespace Dumux {
21
22 // forward declaration
23 template<class TypeTag, class DiscretizationMethod>
24 class PorousMediumFluxVariablesCacheImplementation;
25
26 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
27 //! The cache is dependent on the active physical processes (advection, diffusion, heat conduction)
28 //! For each type of process there is a base cache storing the data required to compute the respective fluxes
29 //! Specializations of the overall cache are provided for combinations of processes
30 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
31
32 /*!
33 * \ingroup PorousmediumflowModels
34 * \brief The flux variables cache classes for porous media.
35 *
36 * Store data required for flux calculation. For each type of physical process (advection, diffusion, heat conduction)
37 * there is a base cache storing the data required to compute the respective fluxes. Specializations of the overall
38 * cache class are provided for different combinations of processes.
39 */
40 template<class TypeTag>
41 using PorousMediumFluxVariablesCache = PorousMediumFluxVariablesCacheImplementation<TypeTag, typename GetPropType<TypeTag, Properties::GridGeometry>::DiscretizationMethod>;
42
43 //! We only store discretization-related quantities for control-volume finite element methods. Thus, we need no
44 //! physics-dependent specialization and simply inherit from the physics-independent implementation.
45 template<class TypeTag, class DM>
46
0/8
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
57701103 class PorousMediumFluxVariablesCacheImplementation<TypeTag, DiscretizationMethods::CVFE<DM>>
47 : public CVFEFluxVariablesCache<GetPropType<TypeTag, Properties::Scalar>, GetPropType<TypeTag, Properties::GridGeometry>>
48 {
49 public:
50 //! export type used for scalar values
51 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
52 };
53
54 // the following classes choose the cache type: empty if the law disabled and the law's cache if it's enabled
55 // if advections is disabled the advection type is still instantiated if we use std::conditional_t and has to be a full type
56 // in order to prevent that instead of std::conditional_t we use this helper type is only dependent on the advection type
57 // if advection is enabled otherwise its an empty cache type
58 template<class TypeTag, bool EnableAdvection> class AdvectionCacheChooser : public FluxVariablesCaching::EmptyAdvectionCache {};
59 7552 template<class TypeTag> class AdvectionCacheChooser<TypeTag, true> : public GetPropType<TypeTag, Properties::AdvectionType>::Cache {};
60 template<class TypeTag, bool EnableMolecularDiffusion> class DiffusionCacheChooser : public FluxVariablesCaching::EmptyDiffusionCache {};
61 template<class TypeTag> class DiffusionCacheChooser<TypeTag, true> : public GetPropType<TypeTag, Properties::MolecularDiffusionType>::Cache {};
62 template<class TypeTag, bool EnableEnergyBalance> class EnergyCacheChooser : public FluxVariablesCaching::EmptyHeatConductionCache {};
63 template<class TypeTag> class EnergyCacheChooser<TypeTag, true> : public GetPropType<TypeTag, Properties::HeatConductionType>::Cache {};
64
65
66 // specialization for the cell centered tpfa method
67 template<class TypeTag>
68 7552 class PorousMediumFluxVariablesCacheImplementation<TypeTag, DiscretizationMethods::CCTpfa>
69 : public AdvectionCacheChooser<TypeTag, GetPropType<TypeTag, Properties::ModelTraits>::enableAdvection()>
70 , public DiffusionCacheChooser<TypeTag, GetPropType<TypeTag, Properties::ModelTraits>::enableMolecularDiffusion()>
71 , public EnergyCacheChooser<TypeTag, GetPropType<TypeTag, Properties::ModelTraits>::enableEnergyBalance()>
72 {
73 public:
74 //! export type used for scalar values
75 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
76 };
77
78 //! Specialization of the flux variables cache for the cell centered finite volume mpfa scheme.
79 //! Stores data which is commonly used by all the different types of processes.
80 template<class TypeTag>
81 class PorousMediumFluxVariablesCacheImplementation<TypeTag, DiscretizationMethods::CCMpfa>
82 : public AdvectionCacheChooser<TypeTag, GetPropType<TypeTag, Properties::ModelTraits>::enableAdvection()>
83 , public DiffusionCacheChooser<TypeTag, GetPropType<TypeTag, Properties::ModelTraits>::enableMolecularDiffusion()>
84 , public EnergyCacheChooser<TypeTag, GetPropType<TypeTag, Properties::ModelTraits>::enableEnergyBalance()>
85 {
86 using GridIndexType = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView::IndexSet::IndexType;
87
88 using MpfaHelper = typename GetPropType<TypeTag, Properties::GridGeometry>::MpfaHelper;
89 static constexpr bool considerSecondary = MpfaHelper::considerSecondaryIVs();
90 public:
91 //! export type used for scalar values
92 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
93
94 //! Returns whether or not this cache has been updated
95 bool isUpdated() const { return isUpdated_; }
96
97 //! Returns whether or not this cache is associated with a secondary interaction volume
98 //! Specialization for deactivated secondary interaction volumes
99 template< bool doSecondary = considerSecondary, std::enable_if_t<!doSecondary, int> = 0>
100 constexpr bool usesSecondaryIv() const { return false; }
101
102 //! Returns whether or not this cache is associated with a secondary interaction volume
103 //! Specialization for activated secondary interaction volumes
104 template< bool doSecondary = considerSecondary, std::enable_if_t<doSecondary, int> = 0>
105 bool usesSecondaryIv() const { return usesSecondaryIv_; }
106
107 //! Returns the index of the iv (this scvf is embedded in) in its container
108 GridIndexType ivIndexInContainer() const { return ivIndexInContainer_; }
109 //! Returns interaction volume-local face index
110 unsigned int ivLocalFaceIndex() const { return ivLocalFaceIdx_; }
111 //! Returns index of the face among "outside" faces of iv-local "positive" face
112 unsigned int indexInOutsideFaces() const { return idxInOutsideFaces_; }
113
114 //! Sets the update status. When set to true, consecutive updates will be skipped
115
4/4
✓ Branch 0 taken 9526228 times.
✓ Branch 1 taken 12974484 times.
✓ Branch 2 taken 68631250 times.
✓ Branch 3 taken 67581854 times.
688095502 void setUpdateStatus(bool status) { isUpdated_ = status; }
116 //! Sets if this cache is associated with a secondary iv
117
4/4
✓ Branch 0 taken 9526228 times.
✓ Branch 1 taken 12974484 times.
✓ Branch 2 taken 68631250 times.
✓ Branch 3 taken 67581854 times.
372321182 void setSecondaryIvUsage(bool status) { usesSecondaryIv_ = status; }
118 //! Sets the index of the iv (this scvf is embedded in) in its container
119
4/4
✓ Branch 0 taken 9526228 times.
✓ Branch 1 taken 12974484 times.
✓ Branch 2 taken 68631250 times.
✓ Branch 3 taken 67581854 times.
372321182 void setIvIndexInContainer(GridIndexType ivIndex) { ivIndexInContainer_ = ivIndex; }
120 //! Sets the iv-local face index
121
4/4
✓ Branch 0 taken 9526228 times.
✓ Branch 1 taken 12974484 times.
✓ Branch 2 taken 68631250 times.
✓ Branch 3 taken 67581854 times.
372321182 void setIvLocalFaceIndex(unsigned int idx) { ivLocalFaceIdx_ = idx; }
122 //! Sets the index of the face among the "positive" face's outside scvfs
123 78157478 void setIndexInOutsideFaces(unsigned int idx) { idxInOutsideFaces_ = idx; }
124
125 private:
126
127 bool isUpdated_ = false; // returns true if cache has been fully updated
128 bool usesSecondaryIv_ = false; // returns true if scvf is embedded in secondary interaction volume
129
130 GridIndexType ivIndexInContainer_; // index of the iv (this scvf is embedded in) in its container
131 unsigned int ivLocalFaceIdx_; // the interaction volume-local face index of this scvf
132 unsigned int idxInOutsideFaces_; // index of scvf among outside scvfs of iv-local "positive" face (only surface grids)
133 };
134
135 } // end namespace Dumux
136
137 #endif
138