GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/porousmediumflow/2pnc/iofields.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 19 23 82.6%
Functions: 50 52 96.2%
Branches: 22 31 71.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-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 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
1/2
✓ Branch 2 taken 216 times.
✗ Branch 3 not taken.
432 out.addVolumeVariable([phaseIdx,compIdx](const auto& v){ return v.moleFraction(phaseIdx,compIdx); },
44 IOName::moleFraction<FluidSystem>(phaseIdx, compIdx));
45 if (VolumeVariables::numFluidComponents() < 3)
46
2/3
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 56 times.
✗ Branch 4 not taken.
11815208 out.addVolumeVariable([phaseIdx,compIdx](const auto& v){ return v.massFraction(phaseIdx,compIdx); },
47 IOName::massFraction<FluidSystem>(phaseIdx, compIdx));
48 }
49
50
2/3
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 28 times.
✗ Branch 4 not taken.
228692 out.addVolumeVariable([phaseIdx](const auto& v){ return v.molarDensity(phaseIdx); },
51 IOName::molarDensity<FluidSystem>(phaseIdx));
52 }
53
54
2/3
✓ Branch 2 taken 44 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
3053844 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 18 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
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 return pvIdx == 0 ? IOName::pressure<FluidSystem>(FluidSystem::phase1Idx)
97 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