version 3.10-dev
porousmediumflow/2pnc/iofields.hh
Go to the documentation of this file.
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//
13#ifndef DUMUX_TWOP_NC_IO_FIELDS_HH
14#define DUMUX_TWOP_NC_IO_FIELDS_HH
15
17#include <dumux/io/name.hh>
18
19namespace Dumux
20{
21
27{
28public:
29 template <class OutputModule>
30 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
37
38 // output additional to TwoP output:
39 for (int phaseIdx = 0; phaseIdx < VolumeVariables::numFluidPhases(); ++phaseIdx)
40 {
41 for (int compIdx = 0; compIdx < VolumeVariables::numFluidComponents(); ++compIdx)
42 {
43 out.addVolumeVariable([phaseIdx,compIdx](const auto& v){ return v.moleFraction(phaseIdx,compIdx); },
44 IOName::moleFraction<FluidSystem>(phaseIdx, compIdx));
45 if (VolumeVariables::numFluidComponents() < 3)
46 out.addVolumeVariable([phaseIdx,compIdx](const auto& v){ return v.massFraction(phaseIdx,compIdx); },
47 IOName::massFraction<FluidSystem>(phaseIdx, compIdx));
48 }
49
50 out.addVolumeVariable([phaseIdx](const auto& v){ return v.molarDensity(phaseIdx); },
51 IOName::molarDensity<FluidSystem>(phaseIdx));
52 }
53
54 out.addVolumeVariable([](const auto& v){ return v.priVars().state(); },
56 }
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 {
93 return pvIdx == 0 ? IOName::pressure<FluidSystem>(FluidSystem::phase0Idx)
94 : p0s1SwitchedPvNames[state-1];
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
static void initOutputModule(OutputModule &out)
Definition: porousmediumflow/2p/iofields.hh:30
Adds I/O fields specific to the TwoPNC model.
Definition: porousmediumflow/2pnc/iofields.hh:27
static std::string primaryVariableName(int pvIdx, int state)
Definition: porousmediumflow/2pnc/iofields.hh:59
static void initOutputModule(OutputModule &out)
Definition: porousmediumflow/2pnc/iofields.hh:30
@ p1s0
first phase saturation and second phase pressure as primary variables
@ p0s1
first phase pressure and second phase saturation as primary variables
A collection of input/output field names for common physical quantities.
std::string phasePresence() noexcept
I/O name of phase presence.
Definition: name.hh:135
Definition: adapt.hh:17
Adds I/O fields specific to the two-phase model.