version 3.8
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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_FREEFLOW_NC_IO_FIELDS_HH
13#define DUMUX_FREEFLOW_NC_IO_FIELDS_HH
14
15#include <dumux/io/name.hh>
17
18namespace Dumux {
19
24template<class BaseOutputFields, bool turbulenceModel = false>
26{
28 template <class OutputModule>
29 static void initOutputModule(OutputModule& out)
30 {
31 BaseOutputFields::initOutputModule(out);
32
33 // TODO only output molar density if we use mole fractions
34 out.addVolumeVariable([](const auto& v){ return v.molarDensity(); }, IOName::molarDensity());
35
36 using FluidSystem = typename OutputModule::VolumeVariables::FluidSystem;
37 for (int j = 0; j < FluidSystem::numComponents; ++j)
38 {
39 out.addVolumeVariable([j](const auto& v){ return v.massFraction(j); }, IOName::massFraction<FluidSystem>(0, j));
40 out.addVolumeVariable([j](const auto& v){ return v.moleFraction(j); }, IOName::moleFraction<FluidSystem>(0, j));
41
42 if (j != FluidSystem::getMainComponent(0))
43 {
44 out.addVolumeVariable([j](const auto& v){ return v.diffusionCoefficient(0,0, j); }, "D^" + FluidSystem::componentName(j) + "_" + FluidSystem::phaseName(0));
45
46 // the eddy diffusivity is recalculated for an arbitrary component which is not the phase component
47 if (turbulenceModel)
48 out.addVolumeVariable([j](const auto& v){ return getEffectiveDiffusionCoefficient_(v, 0, j) - v.diffusionCoefficient(0,0, j); }, "D_t^" + FluidSystem::componentName(j) + "_" + FluidSystem::phaseName(0));
49 }
50 }
51 }
52
54 template <class ModelTraits, class FluidSystem>
55 static std::string primaryVariableName(int pvIdx = 0, int state = 0)
56 {
57 // priVars: v_0, ..., v_dim-1, p, x_0, ..., x_numComp-1, otherPv ..., T
58 if (pvIdx > ModelTraits::dim() && pvIdx < ModelTraits::dim() + ModelTraits::numFluidComponents())
59 return ModelTraits::useMoles() ? IOName::moleFraction<FluidSystem>(0, pvIdx - ModelTraits::dim())
60 : IOName::massFraction<FluidSystem>(0, pvIdx - ModelTraits::dim());
61 else
62 return BaseOutputFields::template primaryVariableName<ModelTraits, FluidSystem>(pvIdx, state);
63
64 }
65
66 template<class VolumeVariables>
67 static double getEffectiveDiffusionCoefficient_(const VolumeVariables& volVars, const int phaseIdx, const int compIdx)
68 {
69 return volVars.effectiveDiffusionCoefficient(phaseIdx, VolumeVariables::FluidSystem::getMainComponent(phaseIdx), compIdx);
70 }
71};
72
73} // end namespace Dumux
74
75#endif
A collection of input/output field names for common physical quantities.
std::string molarDensity(int phaseIdx) noexcept
I/O name of molar density for multiphase systems.
Definition: name.hh:71
Definition: adapt.hh:17
Adds I/O fields specific to the FreeflowNC model.
Definition: freeflow/compositional/iofields.hh:26
static std::string primaryVariableName(int pvIdx=0, int state=0)
return the names of the primary variables
Definition: freeflow/compositional/iofields.hh:55
static void initOutputModule(OutputModule &out)
Initialize the FreeflowNC specific output fields.
Definition: freeflow/compositional/iofields.hh:29
static double getEffectiveDiffusionCoefficient_(const VolumeVariables &volVars, const int phaseIdx, const int compIdx)
Definition: freeflow/compositional/iofields.hh:67