CompositionalContainer.hpp
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 This file is part of the Open Porous Media project (OPM).
5
6 OPM 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 2 of the License, or
9 (at your option) any later version.
10
11 OPM 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 OPM. If not, see <http://www.gnu.org/licenses/>.
18 Consult the COPYING file in the top-level source directory of this
19 module for the precise wording of the license and the list of
20 copyright holders.
21*/
26#ifndef OPM_COMPOSITIONAL_CONTAINER_HPP
27#define OPM_COMPOSITIONAL_CONTAINER_HPP
28
29#include <array>
30#include <functional>
31#include <map>
32#include <string>
33#include <vector>
34
35namespace Opm {
36
37namespace data { class Solution; }
38
39template<class FluidSystem>
41{
42 using Scalar = typename FluidSystem::Scalar;
43 using ScalarBuffer = std::vector<Scalar>;
44
45 static constexpr int numComponents = FluidSystem::numComponents;
46
47 static constexpr int numPhases = FluidSystem::numPhases;
48 static constexpr int gasPhaseIdx = FluidSystem::gasPhaseIdx;
49 static constexpr int oilPhaseIdx = FluidSystem::oilPhaseIdx;
50 static constexpr int waterPhaseIdx = FluidSystem::waterPhaseIdx;
51
52public:
53 void allocate(const unsigned bufferSize,
54 std::map<std::string, int>& rstKeywords);
55
56 using AssignFunction = std::function<Scalar(const unsigned)>;
57
58 void assignGasFractions(const unsigned globalDofIdx,
59 const AssignFunction& fractions);
60
61 void assignMoleFractions(const unsigned globalDofIdx,
62 const AssignFunction& fractions);
63
64 void assignOilFractions(const unsigned globalDofIdx,
65 const AssignFunction& fractions);
66
67 void outputRestart(data::Solution& sol,
68 ScalarBuffer& oil_saturation);
69
70 bool allocated() const
71 { return allocated_; }
72
73private:
74 bool allocated_ = false;
75 // total mole fractions for each component
76 std::array<ScalarBuffer, numComponents> moleFractions_;
77 // mole fractions for each component in each phase
78 std::array<std::array<ScalarBuffer, numComponents>, numPhases> phaseMoleFractions_;
79};
80
81} // namespace Opm
82
83#endif // OPM_COMPOSITIONAL_CONTAINER_HPP
Definition: CompositionalContainer.hpp:41
void assignGasFractions(const unsigned globalDofIdx, const AssignFunction &fractions)
std::function< Scalar(const unsigned)> AssignFunction
Definition: CompositionalContainer.hpp:56
void allocate(const unsigned bufferSize, std::map< std::string, int > &rstKeywords)
bool allocated() const
Definition: CompositionalContainer.hpp:70
void outputRestart(data::Solution &sol, ScalarBuffer &oil_saturation)
void assignMoleFractions(const unsigned globalDofIdx, const AssignFunction &fractions)
void assignOilFractions(const unsigned globalDofIdx, const AssignFunction &fractions)
Definition: blackoilboundaryratevector.hh:39