opm-common
Loading...
Searching...
No Matches
GenericSpeciesConfig.hpp
1/*
2 Copyright (C) 2020 Equinor
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 3 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*/
19
20#ifndef GENERIC_SPECIES_CONFIG_HPP
21#define GENERIC_SPECIES_CONFIG_HPP
22
23#include <opm/input/eclipse/EclipseState/Tables/SpeciesVdTable.hpp>
24
25#include <optional>
26#include <string>
27
28namespace Opm {
29
30class Deck;
31class DeckItem;
32class DeckKeyword;
33class InfoLogger;
34
35enum class SpeciesType {
36 SPECIES,
37 MINERAL,
38 IONEX
39};
40
42public:
43 struct SpeciesEntry {
44 std::string name;
45 std::optional<std::vector<double>> concentration;
46 std::optional<SpeciesVdTable> svdp;
47
48 SpeciesEntry() = default;
49
50 SpeciesEntry(const std::string& name_, std::vector<double> concentration_)
51 : name(name_)
52 , concentration(concentration_)
53 {}
54
55 SpeciesEntry(const std::string& name_, SpeciesVdTable svdp_)
56 : name(name_)
57 , svdp(svdp_)
58 {}
59
60 SpeciesEntry(const std::string& name_)
61 : name(name_)
62 {}
63
64 bool operator==(const SpeciesEntry& data) const {
65 return this->name == data.name &&
66 this->concentration == data.concentration &&
67 this->svdp == data.svdp;
68 }
69
70 template<class Serializer>
71 void serializeOp(Serializer& serializer)
72 {
73 serializer(name);
74 serializer(concentration);
75 serializer(svdp);
76 }
77 }; // struct SpeciesEntry
78
79 virtual ~GenericSpeciesConfig() = default;
80
81 static GenericSpeciesConfig serializationTestObject();
82
83 auto size() const { return this->species.size(); };
84 auto empty() const { return this->species.empty(); };
85 auto begin() const { return this->species.begin(); };
86 auto end() const { return this->species.end(); };
87
88 const SpeciesEntry& operator[](const std::string& name) const;
89 const SpeciesEntry& operator[](std::size_t index) const;
90 bool operator==(const GenericSpeciesConfig& data) const;
91
92 template<class Serializer>
93 void serializeOp(Serializer& serializer)
94 {
95 serializer(species);
96 }
97
98protected:
99 void initializeSpeciesType(const DeckItem& item, const Deck& deck, SpeciesType s);
100 void initFromXBLK(const DeckKeyword& sblk_keyword,
101 const std::string& species_name,
102 InfoLogger& logger);
103 void initFromXVDP(const DeckKeyword& svdp_keyword,
104 const std::string& species_name,
105 InfoLogger& logger);
106 void initEmpty(const std::string& species_name);
107 void checkSpeciesName(const std::string& species_name, SpeciesType s);
108
109private:
110 std::vector<SpeciesEntry> species;
111}; // class GenericSpeciesConfig
112
113} // namespec Opm
114#endif
Definition DeckItem.hpp:35
Definition DeckKeyword.hpp:36
Definition Deck.hpp:46
Definition GenericSpeciesConfig.hpp:41
Definition InfoLogger.hpp:34
Class for (de-)serializing.
Definition Serializer.hpp:94
Definition SpeciesVdTable.hpp:27
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Definition GenericSpeciesConfig.hpp:43