19 #ifndef FIELDPROPS_HPP
20 #define FIELDPROPS_HPP
25 #include <unordered_set>
28 #include <opm/input/eclipse/Deck/value_status.hpp>
29 #include <opm/input/eclipse/Deck/DeckSection.hpp>
30 #include <opm/input/eclipse/Units/UnitSystem.hpp>
31 #include <opm/input/eclipse/EclipseState/Grid/Box.hpp>
32 #include <opm/input/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.hpp>
33 #include <opm/input/eclipse/EclipseState/Tables/TableManager.hpp>
34 #include <opm/input/eclipse/EclipseState/Runspec.hpp>
35 #include <opm/input/eclipse/EclipseState/Grid/Keywords.hpp>
36 #include <opm/input/eclipse/EclipseState/Grid/TranCalculator.hpp>
37 #include <opm/input/eclipse/EclipseState/Grid/FieldData.hpp>
43 class NumericalAquifers;
92 inline bool isFipxxx(
const std::string& keyword) {
95 if (keyword.size() < 4 || keyword ==
"FIPOWG") {
98 return keyword[0] ==
'F' && keyword[1] ==
'I' && keyword[2] ==
'P';
117 static const std::unordered_map<std::string, std::string> aliased_keywords = {{
"PERMR",
"PERMX"},
118 {
"PERMTHT",
"PERMY"}};
123 static const std::unordered_map<std::string, keyword_info<double>> double_keywords = {{
"MULTPV", keyword_info<double>{}.init(1.0)},
124 {
"NTG", keyword_info<double>{}.init(1.0)},
125 {
"PORO", keyword_info<double>{}.distribute_top(
true)},
126 {
"PERMX", keyword_info<double>{}.unit_string(
"Permeability").distribute_top(
true)},
127 {
"PERMY", keyword_info<double>{}.unit_string(
"Permeability").distribute_top(
true)},
128 {
"PERMZ", keyword_info<double>{}.unit_string(
"Permeability").distribute_top(
true)},
129 {
"PERMR", keyword_info<double>{}.unit_string(
"Permeability").distribute_top(
true)},
130 {
"PERMTHT", keyword_info<double>{}.unit_string(
"Permeability").distribute_top(
true)},
131 {
"TEMPI", keyword_info<double>{}.unit_string(
"Temperature")},
132 {
"THCONR", keyword_info<double>{}.unit_string(
"Energy/AbsoluteTemperature*Length*Time")},
133 {
"THCONSF", keyword_info<double>{}},
134 {
"THCROCK", keyword_info<double>{}.unit_string(
"Energy/AbsoluteTemperature*Length*Time")},
135 {
"THCOIL", keyword_info<double>{}.unit_string(
"Energy/AbsoluteTemperature*Length*Time")},
136 {
"THCGAS", keyword_info<double>{}.unit_string(
"Energy/AbsoluteTemperature*Length*Time")},
137 {
"THCWATER",keyword_info<double>{}.unit_string(
"Energy/AbsoluteTemperature*Length*Time")},
138 {
"MULTX", keyword_info<double>{}.init(1.0).mult(
true)},
139 {
"MULTX-", keyword_info<double>{}.init(1.0).mult(
true)},
140 {
"MULTY", keyword_info<double>{}.init(1.0).mult(
true)},
141 {
"MULTY-", keyword_info<double>{}.init(1.0).mult(
true)},
142 {
"MULTZ", keyword_info<double>{}.init(1.0).mult(
true).global_kw(
true)},
143 {
"MULTZ-", keyword_info<double>{}.init(1.0).mult(
true)}};
145 static const std::unordered_map<std::string, keyword_info<int>> int_keywords = {{
"ACTNUM", keyword_info<int>{}.init(1)},
146 {
"FLUXNUM", keyword_info<int>{}},
147 {
"ISOLNUM", keyword_info<int>{}.init(1)},
148 {
"MULTNUM", keyword_info<int>{}.init(1)},
149 {
"OPERNUM", keyword_info<int>{}},
150 {
"ROCKNUM", keyword_info<int>{}}};
163 static const std::unordered_map<std::string, keyword_info<double>> double_keywords = {{
"MULTPV", keyword_info<double>{}.init(1.0)},
164 {
"PORV", keyword_info<double>{}.unit_string(
"ReservoirVolume")},
165 {
"MULTX", keyword_info<double>{}.init(1.0).mult(
true)},
166 {
"MULTX-", keyword_info<double>{}.init(1.0).mult(
true)},
167 {
"MULTY", keyword_info<double>{}.init(1.0).mult(
true)},
168 {
"MULTY-", keyword_info<double>{}.init(1.0).mult(
true)},
169 {
"MULTZ", keyword_info<double>{}.init(1.0).mult(
true).global_kw(
true)},
170 {
"MULTZ-", keyword_info<double>{}.init(1.0).mult(
true)}};
172 static const std::unordered_map<std::string, keyword_info<int>> int_keywords = {};
176 static const std::unordered_map<std::string, keyword_info<double>> double_keywords = {{
"SWATINIT", keyword_info<double>{}}};
177 static const std::unordered_map<std::string, keyword_info<int>> int_keywords = {};
179 #define dirfunc(base) base, base "X", base "X-", base "Y", base "Y-", base "Z", base "Z-"
181 static const std::set<std::string> satfunc = {
"SWLPC",
"ISWLPC",
"SGLPC",
"ISGLPC",
217 static const std::map<std::string,std::string> sogcr_shift = {{
"SOGCR",
"SWL"},
219 {
"SOGCRX-",
"SWLX-"},
221 {
"SOGCRY-",
"SWLY-"},
223 {
"SOGCRZ-",
"SWLZ-"},
225 {
"ISOGCRX",
"ISWLX"},
226 {
"ISOGCRX-",
"ISWLX-"},
227 {
"ISOGCRY",
"ISWLY"},
228 {
"ISOGCRY-",
"ISWLY-"},
229 {
"ISOGCRZ",
"ISWLZ"},
230 {
"ISOGCRZ-",
"ISWLZ-"}};
236 static const std::unordered_map<std::string, keyword_info<int>> int_keywords = {{
"ENDNUM", keyword_info<int>{}.init(1)},
237 {
"EQLNUM", keyword_info<int>{}.init(1)},
238 {
"FIPNUM", keyword_info<int>{}.init(1)},
239 {
"IMBNUM", keyword_info<int>{}.init(1)},
240 {
"OPERNUM", keyword_info<int>{}},
241 {
"MISCNUM", keyword_info<int>{}},
242 {
"MISCNUM", keyword_info<int>{}},
243 {
"PVTNUM", keyword_info<int>{}.init(1)},
244 {
"SATNUM", keyword_info<int>{}.init(1)},
245 {
"LWSLTNUM", keyword_info<int>{}},
246 {
"ROCKNUM", keyword_info<int>{}},
247 {
"KRNUMX", keyword_info<int>{}},
248 {
"KRNUMY", keyword_info<int>{}},
249 {
"KRNUMZ", keyword_info<int>{}},
255 static const std::unordered_map<std::string, keyword_info<double>> double_keywords = {{
"PRESSURE", keyword_info<double>{}.unit_string(
"Pressure")},
256 {
"SPOLY", keyword_info<double>{}.unit_string(
"Density")},
257 {
"SPOLYMW", keyword_info<double>{}},
258 {
"SSOL", keyword_info<double>{}},
259 {
"SWAT", keyword_info<double>{}},
260 {
"SGAS", keyword_info<double>{}},
261 {
"SMICR", keyword_info<double>{}.unit_string(
"Density")},
262 {
"SOXYG", keyword_info<double>{}.unit_string(
"Density")},
263 {
"SUREA", keyword_info<double>{}.unit_string(
"Density")},
264 {
"SBIOF", keyword_info<double>{}},
265 {
"SCALC", keyword_info<double>{}},
266 {
"SALTP", keyword_info<double>{}},
267 {
"SALT", keyword_info<double>{}.unit_string(
"Salinity")},
268 {
"TEMPI", keyword_info<double>{}.unit_string(
"Temperature")},
269 {
"RS", keyword_info<double>{}.unit_string(
"GasDissolutionFactor")},
270 {
"RV", keyword_info<double>{}.unit_string(
"OilDissolutionFactor")},
271 {
"RVW", keyword_info<double>{}.unit_string(
"OilDissolutionFactor")}
278 static const std::unordered_map<std::string, keyword_info<double>> double_keywords = {{
"MULTX", keyword_info<double>{}.init(1.0).mult(
true)},
279 {
"MULTX-", keyword_info<double>{}.init(1.0).mult(
true)},
280 {
"MULTY", keyword_info<double>{}.init(1.0).mult(
true)},
281 {
"MULTY-", keyword_info<double>{}.init(1.0).mult(
true)},
282 {
"MULTZ", keyword_info<double>{}.init(1.0).mult(
true).global_kw(
true)},
283 {
"MULTZ-", keyword_info<double>{}.init(1.0).mult(
true)}};
285 static const std::unordered_map<std::string, keyword_info<int>> int_keywords = {{
"ROCKNUM", keyword_info<int>{}}};
289 template <
typename T>
290 keyword_info<T> global_kw_info(
const std::string& name,
bool allow_unsupported =
false);
299 using ScalarOperation = Fieldprops::ScalarOperation;
304 std::string region_name;
315 return this->region_value == other.region_value &&
316 this->multiplier == other.multiplier &&
317 this->region_name == other.region_name;
323 enum class GetStatus {
327 NOT_SUPPPORTED_KEYWORD = 4
334 const std::string& keyword;
337 const Data * data_ptr;
346 void verify_status()
const {
348 case FieldProps::GetStatus::OK:
350 case FieldProps::GetStatus::INVALID_DATA:
351 throw std::runtime_error(
"The keyword: " + keyword +
" has not been fully initialized");
352 case FieldProps::GetStatus::MISSING_KEYWORD:
353 throw std::out_of_range(
"No such keyword in deck: " + keyword);
354 case FieldProps::GetStatus::NOT_SUPPPORTED_KEYWORD:
355 throw std::logic_error(
"The keyword " + keyword +
" is not supported");
359 const std::vector<T>* ptr()
const {
361 return std::addressof(this->data_ptr->data);
366 const std::vector<T>& data()
const {
367 this->verify_status();
368 return this->data_ptr->data;
371 const Data& field_data()
const {
372 this->verify_status();
373 return *this->data_ptr;
377 return (this->status == GetStatus::OK);
389 void reset_actnum(
const std::vector<int>& actnum);
393 const std::string& default_region()
const;
395 std::vector<int> actnum();
396 const std::vector<int>& actnumRaw()
const;
398 template <
typename T>
399 static bool supported(
const std::string& keyword);
401 template <
typename T>
402 bool has(
const std::string& keyword)
const;
404 template <
typename T>
405 std::vector<std::string> keys()
const;
408 template <
typename T>
410 bool allow_unsupported=
false) {
411 if (!allow_unsupported && !FieldProps::supported<T>(keyword))
415 bool has0 = this->has<T>(keyword);
417 field_data = std::addressof(this->init_get<T>(keyword,
418 std::is_same<T,double>::value && allow_unsupported));
419 if (field_data->valid() || allow_unsupported)
423 this->erase<T>(keyword);
427 return FieldDataManager<T>(keyword, GetStatus::INVALID_DATA,
nullptr);
431 template <
typename T>
432 const std::vector<T>& get(
const std::string& keyword) {
433 const auto& data = this->try_get<T>(keyword);
437 template <
typename T>
438 std::vector<T> get_global(
const std::string& keyword) {
439 const auto& managed_field_data = this->try_get<T>(keyword);
440 const auto& field_data = managed_field_data.field_data();
441 const auto& kw_info = Fieldprops::keywords::global_kw_info<T>(keyword);
443 return *field_data.global_data;
445 return this->global_copy(field_data.data, kw_info.scalar_init);
449 template <
typename T>
450 std::vector<T> get_copy(
const std::string& keyword,
bool global) {
451 bool has0 = this->has<T>(keyword);
452 const auto& field_data = this->try_get<T>(keyword).field_data();
456 return this->global_copy(field_data.data, field_data.kw_info.scalar_init);
458 return field_data.data;
461 const auto& kw_info = Fieldprops::keywords::global_kw_info<T>(keyword);
462 return this->global_copy(this->extract<T>(keyword), kw_info.scalar_init);
464 return this->extract<T>(keyword);
469 template <
typename T>
470 std::vector<bool> defaulted(
const std::string& keyword) {
471 const auto& field = this->init_get<T>(keyword);
472 std::vector<bool> def(field.size());
474 for (std::size_t i=0; i < def.size(); i++)
475 def[i] = value::defaulted( field.value_status[i]);
481 template <
typename T>
482 std::vector<T> global_copy(
const std::vector<T>& data,
const std::optional<T>& default_value)
const {
483 T fill_value = default_value.has_value() ? *default_value : 0;
484 std::vector<T> global_data(this->global_size, fill_value);
486 for (std::size_t g = 0; g < this->global_size; g++) {
487 if (this->m_actnum[g]) {
488 global_data[g] = data[i];
495 std::size_t active_size;
496 std::size_t global_size;
498 std::size_t num_int()
const {
499 return this->int_data.size();
502 std::size_t num_double()
const {
503 return this->double_data.size();
506 void handle_schedule_keywords(
const std::vector<DeckKeyword>& keywords);
507 bool tran_active(
const std::string& keyword)
const;
508 void apply_tran(
const std::string& keyword, std::vector<double>& data);
509 bool operator==(
const FieldProps& other)
const;
512 const Fieldprops::TranMap& getTran()
const
518 void scanGRIDSection(
const GRIDSection& grid_section);
519 void scanGRIDSectionOnlyACTNUM(
const GRIDSection& grid_section);
520 void scanEDITSection(
const EDITSection& edit_section);
521 void scanPROPSSection(
const PROPSSection& props_section);
522 void scanREGIONSSection(
const REGIONSSection& regions_section);
523 void scanSOLUTIONSection(
const SOLUTIONSection& solution_section);
524 double getSIValue(
const std::string& keyword,
double raw_value)
const;
525 double getSIValue(ScalarOperation op,
const std::string& keyword,
double raw_value)
const;
526 template <
typename T>
527 void erase(
const std::string& keyword);
529 template <
typename T>
530 std::vector<T> extract(
const std::string& keyword);
532 template <
typename T>
533 void operate(
const DeckRecord& record, Fieldprops::FieldData<T>& target_data,
const Fieldprops::FieldData<T>& src_data,
const std::vector<Box::cell_index>& index_list);
535 template <
typename T>
536 static void apply(ScalarOperation op, std::vector<T>& data, std::vector<value::status>& value_status, T scalar_value,
const std::vector<Box::cell_index>& index_list);
538 template <
typename T>
539 Fieldprops::FieldData<T>& init_get(
const std::string& keyword,
bool allow_unsupported =
false);
541 template <
typename T>
542 Fieldprops::FieldData<T>& init_get(
const std::string& keyword,
const Fieldprops::keywords::keyword_info<T>& kw_info);
544 std::string region_name(
const DeckItem& region_item);
545 std::vector<Box::cell_index> region_index(
const std::string& region_name,
int region_value );
546 void handle_OPERATE(
const DeckKeyword& keyword, Box box);
547 void handle_operation(
const DeckKeyword& keyword, Box box);
548 void handle_region_operation(
const DeckKeyword& keyword);
549 void handle_COPY(
const DeckKeyword& keyword, Box box,
bool region);
550 void distribute_toplayer(Fieldprops::FieldData<double>& field_data,
const std::vector<double>& deck_data,
const Box& box);
551 double get_beta(
const std::string& func_name,
const std::string& target_array,
double raw_beta);
552 double get_alpha(
const std::string& func_name,
const std::string& target_array,
double raw_alpha);
554 void handle_keyword(
const DeckKeyword& keyword, Box& box);
555 void handle_double_keyword(Section section,
const Fieldprops::keywords::keyword_info<double>& kw_info,
const DeckKeyword& keyword,
const std::string& keyword_name,
const Box& box);
556 void handle_double_keyword(Section section,
const Fieldprops::keywords::keyword_info<double>& kw_info,
const DeckKeyword& keyword,
const Box& box);
557 void handle_int_keyword(
const Fieldprops::keywords::keyword_info<int>& kw_info,
const DeckKeyword& keyword,
const Box& box);
558 void init_satfunc(
const std::string& keyword, Fieldprops::FieldData<double>& satfunc);
559 void init_porv(Fieldprops::FieldData<double>& porv);
560 void init_tempi(Fieldprops::FieldData<double>& tempi);
562 const UnitSystem unit_system;
563 std::size_t nx,ny,nz;
565 SatFuncControls m_satfuncctrl;
566 std::vector<int> m_actnum;
567 std::vector<double> cell_volume;
568 std::vector<double> cell_depth;
569 const std::string m_default_region;
570 const EclipseGrid * grid_ptr;
572 std::optional<satfunc::RawTableEndPoints> m_rtep;
573 std::vector<MultregpRecord> multregp;
574 std::unordered_map<std::string, Fieldprops::FieldData<int>> int_data;
575 std::unordered_map<std::string, Fieldprops::FieldData<double>> double_data;
577 Fieldprops::TranMap tran;
About cell information and dimension: The actual grid information is held in a pointer to an ERT ecl_...
Definition: EclipseGrid.hpp:54
Definition: FieldProps.hpp:296
FieldProps(const Deck &deck, const EclipseGrid &grid)
Special case constructor used to process ACTNUM only.
FieldProps(const Deck &deck, const Phases &phases, const EclipseGrid &grid, const TableManager &table_arg)
Normal constructor for FieldProps.
Definition: NumericalAquifers.hpp:36
Definition: Runspec.hpp:57
Definition: TableManager.hpp:65
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29
Definition: FieldProps.hpp:333
Definition: FieldProps.hpp:301
Definition: FieldData.hpp:55