3.3.0
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
25#ifndef DUMUX_TWOP_NC_IO_FIELDS_HH
26#define DUMUX_TWOP_NC_IO_FIELDS_HH
27
29#include <dumux/io/name.hh>
30
31namespace Dumux
32{
33
39{
40public:
41 template <class OutputModule>
42 static void initOutputModule(OutputModule& out)
43 {
44 using VolumeVariables = typename OutputModule::VolumeVariables;
45 using FluidSystem = typename VolumeVariables::FluidSystem;
46
47 // use default fields from the 2p model
49
50 // output additional to TwoP output:
51 for (int phaseIdx = 0; phaseIdx < VolumeVariables::numFluidPhases(); ++phaseIdx)
52 {
53 for (int compIdx = 0; compIdx < VolumeVariables::numFluidComponents(); ++compIdx)
54 {
55 out.addVolumeVariable([phaseIdx,compIdx](const auto& v){ return v.moleFraction(phaseIdx,compIdx); },
56 IOName::moleFraction<FluidSystem>(phaseIdx, compIdx));
57 if (VolumeVariables::numFluidComponents() < 3)
58 out.addVolumeVariable([phaseIdx,compIdx](const auto& v){ return v.massFraction(phaseIdx,compIdx); },
59 IOName::massFraction<FluidSystem>(phaseIdx, compIdx));
60 }
61
62 out.addVolumeVariable([phaseIdx](const auto& v){ return v.molarDensity(phaseIdx); },
63 IOName::molarDensity<FluidSystem>(phaseIdx));
64 }
65
66 out.addVolumeVariable([](const auto& v){ return v.priVars().state(); },
68 }
69
70 template <class ModelTraits, class FluidSystem, class SolidSystem = void>
71 static std::string primaryVariableName(int pvIdx, int state)
72 {
73 using Indices = typename ModelTraits::Indices;
74 static constexpr auto numStates = 3;
75 using StringVec = std::array<std::string, numStates>;
76
77 int idxSecComps;
78 if (state == Indices::firstPhaseOnly
79 || (state == Indices::bothPhases && ModelTraits::setMoleFractionsForFirstPhase()))
80 idxSecComps = FluidSystem::phase0Idx;
81 else
82 idxSecComps = FluidSystem::phase1Idx;
83
84 if (pvIdx > 1)
85 return ModelTraits::useMoles() ? IOName::moleFraction<FluidSystem>(idxSecComps, pvIdx)
86 : IOName::massFraction<FluidSystem>(idxSecComps, pvIdx);
87
88 static const StringVec p0s1SwitchedPvNames = {
89 ModelTraits::useMoles() ? IOName::moleFraction<FluidSystem>(FluidSystem::phase0Idx, FluidSystem::comp1Idx)
90 : IOName::massFraction<FluidSystem>(FluidSystem::phase0Idx, FluidSystem::comp1Idx),
91 ModelTraits::useMoles() ? IOName::moleFraction<FluidSystem>(FluidSystem::phase1Idx, FluidSystem::comp0Idx)
92 : IOName::massFraction<FluidSystem>(FluidSystem::phase1Idx, FluidSystem::comp0Idx),
93 IOName::saturation<FluidSystem>(FluidSystem::phase1Idx)};
94
95 static const StringVec p1s0SwitchedPvNames = {
96 ModelTraits::useMoles() ? IOName::moleFraction<FluidSystem>(FluidSystem::phase0Idx, FluidSystem::comp1Idx)
97 : IOName::massFraction<FluidSystem>(FluidSystem::phase0Idx, FluidSystem::comp1Idx),
98 ModelTraits::useMoles() ? IOName::moleFraction<FluidSystem>(FluidSystem::phase1Idx, FluidSystem::comp0Idx)
99 : IOName::massFraction<FluidSystem>(FluidSystem::phase1Idx, FluidSystem::comp0Idx),
100 IOName::saturation<FluidSystem>(FluidSystem::phase0Idx)};
101
102 switch (ModelTraits::priVarFormulation())
103 {
105 return pvIdx == 0 ? IOName::pressure<FluidSystem>(FluidSystem::phase0Idx)
106 : p0s1SwitchedPvNames[state-1];
108 return pvIdx == 0 ? IOName::pressure<FluidSystem>(FluidSystem::phase1Idx)
109 : p1s0SwitchedPvNames[state-1];
110 default: DUNE_THROW(Dune::InvalidStateException, "Invalid formulation ");
111 }
112 }
113};
114
115
116} // end namespace Dumux
117
118#endif
A collection of input/output field names for common physical quantities.
@ p1s0
first phase saturation and second phase pressure as primary variables
@ p0s1
first phase pressure and second phase saturation as primary variables
Definition: adapt.hh:29
std::string phasePresence() noexcept
I/O name of phase presence.
Definition: name.hh:147
static void initOutputModule(OutputModule &out)
Definition: porousmediumflow/2p/iofields.hh:42
Adds I/O fields specific to the TwoPNC model.
Definition: porousmediumflow/2pnc/iofields.hh:39
static std::string primaryVariableName(int pvIdx, int state)
Definition: porousmediumflow/2pnc/iofields.hh:71
static void initOutputModule(OutputModule &out)
Definition: porousmediumflow/2pnc/iofields.hh:42
Adds I/O fields specific to the two-phase model.