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 | 44 | 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 | 44 | TwoPIOFields::initOutputModule(out); | |
37 | |||
38 | // output additional to TwoP output: | ||
39 |
2/2✓ Branch 1 taken 88 times.
✓ Branch 2 taken 44 times.
|
132 | for (int phaseIdx = 0; phaseIdx < VolumeVariables::numFluidPhases(); ++phaseIdx) |
40 | { | ||
41 |
2/2✓ Branch 0 taken 206 times.
✓ Branch 1 taken 88 times.
|
294 | for (int compIdx = 0; compIdx < VolumeVariables::numFluidComponents(); ++compIdx) |
42 | { | ||
43 |
5/12✓ Branch 2 taken 206 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 206 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 206 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 14 times.
✓ Branch 10 taken 192 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
|
414 | 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 140 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 140 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 140 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 128 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
|
11784492 | 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 62 times.
✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 62 times.
✓ Branch 6 taken 26 times.
✓ Branch 7 taken 62 times.
✓ Branch 8 taken 26 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 62 times.
✓ Branch 11 taken 26 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
|
219084 | out.addVolumeVariable([phaseIdx](const auto& v){ return v.molarDensity(phaseIdx); }, |
51 | IOName::molarDensity<FluidSystem>(phaseIdx)); | ||
52 | } | ||
53 | |||
54 |
4/12✓ Branch 4 taken 44 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 44 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 44 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 44 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
|
6082632 | out.addVolumeVariable([](const auto& v){ return v.priVars().state(); }, |
55 | IOName::phasePresence()); | ||
56 | 44 | } | |
57 | |||
58 | template <class ModelTraits, class FluidSystem, class SolidSystem = void> | ||
59 | ✗ | 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 | ✗ | if (state == Indices::firstPhaseOnly | |
67 | ✗ | || (state == Indices::bothPhases && ModelTraits::setMoleFractionsForFirstPhase())) | |
68 | idxSecComps = FluidSystem::phase0Idx; | ||
69 | else | ||
70 | ✗ | idxSecComps = FluidSystem::phase1Idx; | |
71 | |||
72 | ✗ | if (pvIdx > 1) | |
73 | return ModelTraits::useMoles() ? IOName::moleFraction<FluidSystem>(idxSecComps, pvIdx) | ||
74 | ✗ | : IOName::massFraction<FluidSystem>(idxSecComps, pvIdx); | |
75 | |||
76 | ✗ | 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 | ✗ | 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 | ✗ | case TwoPFormulation::p1s0: | |
96 | ✗ | return pvIdx == 0 ? IOName::pressure<FluidSystem>(FluidSystem::phase1Idx) | |
97 | ✗ | : p1s0SwitchedPvNames[state-1]; | |
98 | default: DUNE_THROW(Dune::InvalidStateException, "Invalid formulation "); | ||
99 | } | ||
100 | } | ||
101 | }; | ||
102 | |||
103 | |||
104 | } // end namespace Dumux | ||
105 | |||
106 | #endif | ||
107 |