Line | Branch | Exec | Source |
---|---|---|---|
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 | // | ||
7 | /*! | ||
8 | * \file | ||
9 | * \ingroup MPNCModel | ||
10 | * \brief A helper function to get the correct initial conditions by updating the fluidstate and defining the primary variables needed for equilibrium mpnc models for the MPNC model | ||
11 | */ | ||
12 | #ifndef DUMUX_MPNC_INITIALCONDITION_HELPER_HH | ||
13 | #define DUMUX_MPNC_INITIALCONDITION_HELPER_HH | ||
14 | |||
15 | #include <dumux/material/constraintsolvers/misciblemultiphasecomposition.hh> | ||
16 | #include <dumux/material/constraintsolvers/computefromreferencephase.hh> | ||
17 | |||
18 | #include "pressureformulation.hh" | ||
19 | |||
20 | namespace Dumux { | ||
21 | |||
22 | namespace MPNCInitialConditions { | ||
23 | |||
24 | struct AllPhasesPresent { int refPhaseIdx; }; | ||
25 | struct NotAllPhasesPresent { int refPhaseIdx; }; | ||
26 | |||
27 | } // namespace MPNCInitialConditions | ||
28 | |||
29 | template<class PrimaryVariables, class FluidSystem, class ModelTraits> | ||
30 | class MPNCInitialConditionHelper | ||
31 | { | ||
32 | using Scalar = typename PrimaryVariables::value_type; | ||
33 | using AllPhasesPresent = MPNCInitialConditions::AllPhasesPresent; | ||
34 | using NotAllPhasesPresent = MPNCInitialConditions::NotAllPhasesPresent; | ||
35 | |||
36 | public: | ||
37 | template<class FluidState> | ||
38 | ✗ | void solve(FluidState& fs, const AllPhasesPresent& allPhases) const | |
39 | { | ||
40 | typename FluidSystem::ParameterCache paramCache; | ||
41 | 1399 | MiscibleMultiPhaseComposition<Scalar, FluidSystem>::solve(fs, | |
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; | ||
50 | 1943 | ComputeFromReferencePhase<Scalar, FluidSystem>::solve(fs, | |
51 | paramCache, | ||
52 | ✗ | notAllPhases.refPhaseIdx); | |
53 | ✗ | } | |
54 | |||
55 | template<class FluidState> | ||
56 | ✗ | PrimaryVariables getPrimaryVariables(const FluidState& fs) const | |
57 | { | ||
58 | 3342 | 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 |
2/4✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6684 times.
✓ Branch 3 taken 3342 times.
|
10026 | for (int compIdx = 0; compIdx < numComponents; ++compIdx) |
68 | 20052 | 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 | 10026 | 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 | ||
89 |