version 3.10-dev
initialconditionhelper.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_MPNC_INITIALCONDITION_HELPER_HH
13#define DUMUX_MPNC_INITIALCONDITION_HELPER_HH
14
17
19
20namespace Dumux {
21
22namespace MPNCInitialConditions {
23
26
27} // namespace MPNCInitialConditions
28
29template<class PrimaryVariables, class FluidSystem, class ModelTraits>
31{
32 using Scalar = typename PrimaryVariables::value_type;
35
36public:
37 template<class FluidState>
38 void solve(FluidState& fs, const AllPhasesPresent& allPhases) const
39 {
40 typename FluidSystem::ParameterCache paramCache;
42 paramCache,
43 allPhases.refPhaseIdx);
44 }
45
46 template<class FluidState>
47 void solve(FluidState& fs, const NotAllPhasesPresent& notAllPhases) const
48 {
49 typename FluidSystem::ParameterCache paramCache;
51 paramCache,
52 notAllPhases.refPhaseIdx);
53 }
54
55 template<class FluidState>
56 PrimaryVariables getPrimaryVariables(const FluidState& fs) const
57 {
58 PrimaryVariables priVars(0.0);
59
60 static constexpr auto numComponents = FluidSystem::numComponents;
61 static constexpr auto numPhases = FluidSystem::numPhases;
62 static constexpr auto fug0Idx = ModelTraits::Indices::fug0Idx;
63 static constexpr auto s0Idx = ModelTraits::Indices::s0Idx;
64 static constexpr auto p0Idx = ModelTraits::Indices::p0Idx;
65
66 // all N component fugacities
67 for (int compIdx = 0; compIdx < numComponents; ++compIdx)
68 priVars[fug0Idx + compIdx] = fs.fugacity(0, compIdx);
69
70 // first M - 1 saturations
71 for (int phaseIdx = 0; phaseIdx < numPhases - 1; ++phaseIdx)
72 priVars[s0Idx + phaseIdx] = fs.saturation(phaseIdx);
73
74 static constexpr auto pressureFormulation = ModelTraits::pressureFormulation();
75 if (pressureFormulation == MpNcPressureFormulation::mostWettingFirst)
76 priVars[p0Idx] = fs.pressure(/*phaseIdx=*/0);
77 else if (pressureFormulation == MpNcPressureFormulation::leastWettingFirst)
78 priVars[p0Idx] = fs.pressure(numPhases-1);
79 else
80 DUNE_THROW(Dune::InvalidStateException,"unknown pressure formulation");
81
82 return priVars;
83 }
84};
85
86} // end namespace Dumux
87
88#endif
static void solve(FluidState &fluidState, ParameterCache &paramCache, int refPhaseIdx)
Computes all quantities of a generic fluid state if a reference phase has been specified.
Definition: computefromreferencephase.hh:99
Definition: initialconditionhelper.hh:31
PrimaryVariables getPrimaryVariables(const FluidState &fs) const
Definition: initialconditionhelper.hh:56
void solve(FluidState &fs, const AllPhasesPresent &allPhases) const
Definition: initialconditionhelper.hh:38
void solve(FluidState &fs, const NotAllPhasesPresent &notAllPhases) const
Definition: initialconditionhelper.hh:47
static void solve(FluidState &fluidState, ParameterCache &paramCache, int knownPhaseIdx=0)
Computes the composition of all phases of a N-phase, N-component fluid system assuming that all N pha...
Definition: misciblemultiphasecomposition.hh:69
Computes all quantities of a generic fluid state if a reference phase has been specified.
Computes the composition of all phases of a N-phase, N-component fluid system assuming that all N pha...
Definition: adapt.hh:17
Enumeration of the formulations accepted by the MpNc model.
Definition: initialconditionhelper.hh:24
int refPhaseIdx
Definition: initialconditionhelper.hh:24
Definition: initialconditionhelper.hh:25
int refPhaseIdx
Definition: initialconditionhelper.hh:25