Skip to content

Commit

Permalink
[fix] Make has method has been specialized before it is instantiated.
Browse files Browse the repository at this point in the history
Fixes compilation issue:

```
opm/input/eclipse/EclipseState/Grid/FieldProps.cpp:813:63: error: specialization of ‘bool Opm::FieldProps::has(const std::string&) const [with T = double; std::string = std::__cxx11::basic_string<char>]’ after instantiation
  813 | bool FieldProps::has<double>(const std::string& keyword_name) const {
      |                                                               ^~~~~
```
  • Loading branch information
blattms committed Apr 22, 2024
1 parent ee8d354 commit db24d05
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions opm/input/eclipse/EclipseState/Grid/FieldProps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,45 @@ Fieldprops::FieldData<int>& FieldProps::init_get(const std::string& keyword, boo
}
}


std::vector<Box::cell_index> FieldProps::region_index( const std::string& region_name, int region_value ) {
const auto& region = this->init_get<int>(region_name);
if (!region.valid())
throw std::invalid_argument("Trying to work with invalid region: " + region_name);

std::vector<Box::cell_index> index_list;
std::size_t active_index = 0;
const auto& region_data = region.data;
for (std::size_t g = 0; g < this->m_actnum.size(); g++) {
if (this->m_actnum[g] != 0) {
if (region_data[active_index] == region_value)
index_list.emplace_back( g, active_index, g );
active_index += 1;
}
}
return index_list;
}



std::string FieldProps::region_name(const DeckItem& region_item) {
return region_item.defaultApplied(0) ? this->m_default_region : make_region_name(region_item.get<std::string>(0));
}

template <>
bool FieldProps::has<double>(const std::string& keyword_name) const {
const std::string& keyword = Fieldprops::keywords::get_keyword_from_alias(keyword_name);
return (this->double_data.count(keyword) != 0);
}

template <>
bool FieldProps::has<int>(const std::string& keyword) const {
return Fieldprops::keywords::isFipxxx(keyword)
? this->int_data.count(this->canonical_fipreg_name(keyword)) != 0
: this->int_data.count(keyword) != 0;
}


void FieldProps::apply_multipliers()
{
bool hasPorvBefore = (this->double_data.find(ParserKeywords::PORV::keywordName) == this->double_data.end());
Expand Down Expand Up @@ -784,45 +823,6 @@ void FieldProps::apply_multipliers()
multiplier_kw_infos_.clear();
}


std::vector<Box::cell_index> FieldProps::region_index( const std::string& region_name, int region_value ) {
const auto& region = this->init_get<int>(region_name);
if (!region.valid())
throw std::invalid_argument("Trying to work with invalid region: " + region_name);

std::vector<Box::cell_index> index_list;
std::size_t active_index = 0;
const auto& region_data = region.data;
for (std::size_t g = 0; g < this->m_actnum.size(); g++) {
if (this->m_actnum[g] != 0) {
if (region_data[active_index] == region_value)
index_list.emplace_back( g, active_index, g );
active_index += 1;
}
}
return index_list;
}



std::string FieldProps::region_name(const DeckItem& region_item) {
return region_item.defaultApplied(0) ? this->m_default_region : make_region_name(region_item.get<std::string>(0));
}

template <>
bool FieldProps::has<double>(const std::string& keyword_name) const {
const std::string& keyword = Fieldprops::keywords::get_keyword_from_alias(keyword_name);
return (this->double_data.count(keyword) != 0);
}

template <>
bool FieldProps::has<int>(const std::string& keyword) const {
return Fieldprops::keywords::isFipxxx(keyword)
? this->int_data.count(this->canonical_fipreg_name(keyword)) != 0
: this->int_data.count(keyword) != 0;
}


/*
The ACTNUM and PORV keywords are special cased with quite extensive
postprocessing, and should be access through the special ::porv() and
Expand Down

0 comments on commit db24d05

Please sign in to comment.