3.2-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
freeflow/compositional/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 *****************************************************************************/
24#ifndef DUMUX_FREEFLOW_NC_IO_FIELDS_HH
25#define DUMUX_FREEFLOW_NC_IO_FIELDS_HH
26
27#include <dumux/io/name.hh>
30
31namespace Dumux {
32
37template<class BaseOutputFields, bool turbulenceModel = false>
39{
41 template <class OutputModule>
42 static void initOutputModule(OutputModule& out)
43 {
44 BaseOutputFields::initOutputModule(out);
45
46 // TODO only output molar density if we use mole fractions
47 out.addVolumeVariable([](const auto& v){ return v.molarDensity(); }, IOName::molarDensity());
48
49 using FluidSystem = typename OutputModule::VolumeVariables::FluidSystem;
50 for (int j = 0; j < FluidSystem::numComponents; ++j)
51 {
52 out.addVolumeVariable([j](const auto& v){ return v.massFraction(j); }, IOName::massFraction<FluidSystem>(0, j));
53 out.addVolumeVariable([j](const auto& v){ return v.moleFraction(j); }, IOName::moleFraction<FluidSystem>(0, j));
54
55 if (j != FluidSystem::getMainComponent(0))
56 {
57 out.addVolumeVariable([j](const auto& v){ return v.diffusionCoefficient(0,0, j); }, "D^" + FluidSystem::componentName(j) + "_" + FluidSystem::phaseName(0));
58
59 // the eddy diffusivity is recalculated for an arbitrary component which is not the phase component
60 if (turbulenceModel)
61 out.addVolumeVariable([j](const auto& v){ return getEffectiveDiffusionCoefficient_(v, 0, j) - v.diffusionCoefficient(0,0, j); }, "D_t^" + FluidSystem::componentName(j) + "_" + FluidSystem::phaseName(0));
62 }
63 }
64 }
65
67 template <class ModelTraits, class FluidSystem>
68 static std::string primaryVariableName(int pvIdx = 0, int state = 0)
69 {
70 // priVars: v_0, ..., v_dim-1, p, x_0, ..., x_numComp-1, otherPv ..., T
71 if (pvIdx > ModelTraits::dim() && pvIdx < ModelTraits::dim() + ModelTraits::numFluidComponents())
72 return ModelTraits::useMoles() ? IOName::moleFraction<FluidSystem>(0, pvIdx - ModelTraits::dim())
73 : IOName::massFraction<FluidSystem>(0, pvIdx - ModelTraits::dim());
74 else
75 return BaseOutputFields::template primaryVariableName<ModelTraits, FluidSystem>(pvIdx, state);
76
77 }
78
79 template<class VolumeVariables>
80 static double getEffectiveDiffusionCoefficient_(const VolumeVariables& volVars, const int phaseIdx, const int compIdx)
81 {
82 if constexpr (Dumux::Deprecated::hasEffDiffCoeff<VolumeVariables>)
83 return volVars.effectiveDiffusionCoefficient(phaseIdx,
84 VolumeVariables::FluidSystem::getMainComponent(phaseIdx), compIdx);
85 else
86 {
87 // TODO: remove this else clause after release 3.2!
88 return volVars.effectiveDiffusivity(phaseIdx, compIdx);
89 }
90 }
91
92
93};
94
95} // end namespace Dumux
96
97#endif
Helpers for deprecation.
A collection of input/output field names for common physical quantities.
Definition: adapt.hh:29
std::string molarDensity(int phaseIdx) noexcept
I/O name of molar density for multiphase systems.
Definition: name.hh:83
Adds I/O fields specific to the FreeflowNC model.
Definition: freeflow/compositional/iofields.hh:39
static std::string primaryVariableName(int pvIdx=0, int state=0)
return the names of the primary variables
Definition: freeflow/compositional/iofields.hh:68
static void initOutputModule(OutputModule &out)
Initialize the FreeflowNC specific output fields.
Definition: freeflow/compositional/iofields.hh:42
static double getEffectiveDiffusionCoefficient_(const VolumeVariables &volVars, const int phaseIdx, const int compIdx)
Definition: freeflow/compositional/iofields.hh:80