13#ifndef DUMUX_TWOP_NC_IO_FIELDS_HH
14#define DUMUX_TWOP_NC_IO_FIELDS_HH
29 template <
class OutputModule>
32 using VolumeVariables =
typename OutputModule::VolumeVariables;
33 using FluidSystem =
typename VolumeVariables::FluidSystem;
39 for (
int phaseIdx = 0; phaseIdx < VolumeVariables::numFluidPhases(); ++phaseIdx)
41 for (
int compIdx = 0; compIdx < VolumeVariables::numFluidComponents(); ++compIdx)
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));
50 out.addVolumeVariable([phaseIdx](
const auto& v){
return v.molarDensity(phaseIdx); },
51 IOName::molarDensity<FluidSystem>(phaseIdx));
54 out.addVolumeVariable([](
const auto& v){
return v.priVars().state(); },
58 template <
class ModelTraits,
class Flu
idSystem,
class Sol
idSystem =
void>
61 using Indices =
typename ModelTraits::Indices;
62 static constexpr auto numStates = 3;
63 using StringVec = std::array<std::string, numStates>;
66 if (state == Indices::firstPhaseOnly
67 || (state == Indices::bothPhases && ModelTraits::setMoleFractionsForFirstPhase()))
68 idxSecComps = FluidSystem::phase0Idx;
70 idxSecComps = FluidSystem::phase1Idx;
73 return ModelTraits::useMoles() ? IOName::moleFraction<FluidSystem>(idxSecComps, pvIdx)
74 : IOName::massFraction<FluidSystem>(idxSecComps, pvIdx);
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)};
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)};
90 switch (ModelTraits::priVarFormulation())
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 ");
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
Adds I/O fields specific to the two-phase model.