Enable Empty Structural Copies of Deck Items and Deck Keywords

This commit adds a new member function,

    X emptyStructuralCopy() const

to the DeckKeyword and DeckItem classes.  This member function will
form a "structural" copy of "*this", thus preserving aspects such as
the currently active "Dimensions", but removing all data values.
This is in preparation of adding low-pressure table expansion for
the gas PVT tables (i.e., keywords 'PVDG' and 'PVTG').
This commit is contained in:
Bård Skaflestad 2023-11-17 11:20:01 +01:00
parent d736136acc
commit 0c168d67fd
4 changed files with 28 additions and 1 deletions

View File

@ -47,6 +47,7 @@ namespace Opm {
DeckItem( const std::string&, double, const std::vector<Dimension>& active_dim, const std::vector<Dimension>& default_dim);
static DeckItem serializationTestObject();
DeckItem emptyStructuralCopy() const;
const std::string& name() const;
@ -151,6 +152,7 @@ namespace Opm {
}
void reserve_additionalRawString(std::size_t);
private:
mutable std::vector< double > dval;
std::vector< int > ival;

View File

@ -51,7 +51,7 @@ namespace Opm {
const std::string& name() const;
void setFixedSize();
const KeywordLocation& location() const;
DeckKeyword emptyStructuralCopy() const;
size_t size() const;
bool empty() const;

View File

@ -130,6 +130,22 @@ DeckItem DeckItem::serializationTestObject()
return result;
}
DeckItem DeckItem::emptyStructuralCopy() const
{
auto ret = *this;
ret.dval .clear();
ret.ival .clear();
ret.sval .clear();
ret.rsval.clear();
ret.uval .clear();
ret.value_status.clear();
ret.raw_data = true;
return ret;
}
const std::string& DeckItem::name() const {
return this->item_name;
}

View File

@ -65,6 +65,15 @@ namespace Opm {
return result;
}
DeckKeyword DeckKeyword::emptyStructuralCopy() const
{
auto ret = *this;
ret.m_recordList.clear();
return ret;
}
namespace {
template <typename T>
void add_deckvalue( DeckItem deck_item, DeckRecord& deck_record, const ParserItem& parser_item, const std::vector<DeckValue>& input_record, size_t j) {