GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: /builds/dumux-repositories/dumux/dumux/porousmediumflow/2pnc/iofields.hh
Date: 2024-05-04 19:09:25
Exec Total Coverage
Lines: 19 23 82.6%
Functions: 36 169 21.3%
Branches: 37 70 52.9%

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 TwoPNCModel
10 * \brief Adds I/O fields specific to the twop-nc model.
11 */
12
13 #ifndef DUMUX_TWOP_NC_IO_FIELDS_HH
14 #define DUMUX_TWOP_NC_IO_FIELDS_HH
15
16 #include <dumux/porousmediumflow/2p/iofields.hh>
17 #include <dumux/io/name.hh>
18
19 namespace Dumux
20 {
21
22 /*!
23 * \ingroup TwoPNCModel
24 * \brief Adds I/O fields specific to the TwoPNC model.
25 */
26 class TwoPNCIOFields
27 {
28 public:
29 template <class OutputModule>
30 46 static void initOutputModule(OutputModule& out)
31 {
32 using VolumeVariables = typename OutputModule::VolumeVariables;
33 using FluidSystem = typename VolumeVariables::FluidSystem;
34
35 // use default fields from the 2p model
36 46 TwoPIOFields::initOutputModule(out);
37
38 // output additional to TwoP output:
39
2/2
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 46 times.
138 for (int phaseIdx = 0; phaseIdx < VolumeVariables::numFluidPhases(); ++phaseIdx)
40 {
41
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 92 times.
308 for (int compIdx = 0; compIdx < VolumeVariables::numFluidComponents(); ++compIdx)
42 {
43
5/12
✓ Branch 2 taken 216 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 216 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 216 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 14 times.
✓ Branch 10 taken 202 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
434 out.addVolumeVariable([phaseIdx,compIdx](const auto& v){ return v.moleFraction(phaseIdx,compIdx); },
44 IOName::moleFraction<FluidSystem>(phaseIdx, compIdx));
45 if (VolumeVariables::numFluidComponents() < 3)
46
5/12
✓ Branch 3 taken 144 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 144 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 144 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 132 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
11815220 out.addVolumeVariable([phaseIdx,compIdx](const auto& v){ return v.massFraction(phaseIdx,compIdx); },
47 IOName::massFraction<FluidSystem>(phaseIdx, compIdx));
48 }
49
50
8/14
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 28 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 64 times.
✓ Branch 6 taken 28 times.
✓ Branch 7 taken 64 times.
✓ Branch 8 taken 28 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 64 times.
✓ Branch 11 taken 28 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
228692 out.addVolumeVariable([phaseIdx](const auto& v){ return v.molarDensity(phaseIdx); },
51 IOName::molarDensity<FluidSystem>(phaseIdx));
52 }
53
54
4/12
✓ Branch 4 taken 46 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 46 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 46 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 46 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
6107596 out.addVolumeVariable([](const auto& v){ return v.priVars().state(); },
55 IOName::phasePresence());
56 46 }
57
58 template <class ModelTraits, class FluidSystem, class SolidSystem = void>
59 18 static std::string primaryVariableName(int pvIdx, int state)
60 {
61 using Indices = typename ModelTraits::Indices;
62 static constexpr auto numStates = 3;
63 using StringVec = std::array<std::string, numStates>;
64
65 int idxSecComps;
66 36 if (state == Indices::firstPhaseOnly
67
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 || (state == Indices::bothPhases && ModelTraits::setMoleFractionsForFirstPhase()))
68 idxSecComps = FluidSystem::phase0Idx;
69 else
70 idxSecComps = FluidSystem::phase1Idx;
71
72
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 if (pvIdx > 1)
73 return ModelTraits::useMoles() ? IOName::moleFraction<FluidSystem>(idxSecComps, pvIdx)
74 6 : IOName::massFraction<FluidSystem>(idxSecComps, pvIdx);
75
76
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
12 static const StringVec p0s1SwitchedPvNames = {
77 ModelTraits::useMoles() ? IOName::moleFraction<FluidSystem>(FluidSystem::phase0Idx, FluidSystem::comp1Idx)
78 : IOName::massFraction<FluidSystem>(FluidSystem::phase0Idx, FluidSystem::comp1Idx),
79 ModelTraits::useMoles() ? IOName::moleFraction<FluidSystem>(FluidSystem::phase1Idx, FluidSystem::comp0Idx)
80 : IOName::massFraction<FluidSystem>(FluidSystem::phase1Idx, FluidSystem::comp0Idx),
81 IOName::saturation<FluidSystem>(FluidSystem::phase1Idx)};
82
83
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
12 static const StringVec p1s0SwitchedPvNames = {
84 ModelTraits::useMoles() ? IOName::moleFraction<FluidSystem>(FluidSystem::phase0Idx, FluidSystem::comp1Idx)
85 : IOName::massFraction<FluidSystem>(FluidSystem::phase0Idx, FluidSystem::comp1Idx),
86 ModelTraits::useMoles() ? IOName::moleFraction<FluidSystem>(FluidSystem::phase1Idx, FluidSystem::comp0Idx)
87 : IOName::massFraction<FluidSystem>(FluidSystem::phase1Idx, FluidSystem::comp0Idx),
88 IOName::saturation<FluidSystem>(FluidSystem::phase0Idx)};
89
90 switch (ModelTraits::priVarFormulation())
91 {
92 case TwoPFormulation::p0s1:
93 return pvIdx == 0 ? IOName::pressure<FluidSystem>(FluidSystem::phase0Idx)
94 : p0s1SwitchedPvNames[state-1];
95 12 case TwoPFormulation::p1s0:
96 12 return pvIdx == 0 ? IOName::pressure<FluidSystem>(FluidSystem::phase1Idx)
97
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 : p1s0SwitchedPvNames[state-1];
98 default: DUNE_THROW(Dune::InvalidStateException, "Invalid formulation ");
99 }
100 }
101 };
102
103
104 } // end namespace Dumux
105
106 #endif
107