INIT/EPS: Output Sentinel Value if Input Defaulted
This commit extends the previous support for writing scaled end-points (and scaled function values) to outputting the sentinel value -1.0e+20 for those items (cell values) that have been defaulted in the input. This operation does not apply if the simulation run specifies FILLEPS, in which case we always output the actual scaled end-points, whether taken from explicit assignment or derived from table values. The overall approach is to pass an additional flag (needDflt) to function writeDoubleCellProperties(), which then dispatches to two new helper functions writeCellPropertiesWithDefaultFlag() writeCellPropertiesValuesOnly() The former then expects a three-argument callable (lambda), the second of which is the compressed version of the Property<T>::wasDefaulted() value. This is then used to infer for which elements to output the sentinel value. The ValuesOnly() property writer is the previous version of writeDoubleCellProperties() and is mainly used to support the FILLEPS operation.
This commit is contained in:
parent
43a5a153b1
commit
7639dd7e5f
@ -359,10 +359,29 @@ namespace {
|
||||
}
|
||||
|
||||
template <typename T, class WriteVector>
|
||||
void writeCellProperties(const Properties& propList,
|
||||
const ::Opm::GridProperties<T>& propValues,
|
||||
const ::Opm::EclipseGrid& grid,
|
||||
WriteVector&& write)
|
||||
void writeCellPropertiesWithDefaultFlag(const Properties& propList,
|
||||
const ::Opm::GridProperties<T>& propValues,
|
||||
const ::Opm::EclipseGrid& grid,
|
||||
WriteVector&& write)
|
||||
{
|
||||
for (const auto& prop : propList) {
|
||||
if (! propValues.hasKeyword(prop.name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto& opm_property = propValues.getKeyword(prop.name);
|
||||
const auto& dflt = opm_property.wasDefaulted();
|
||||
|
||||
write(prop, grid.compressedVector(dflt),
|
||||
opm_property.compressedCopy(grid));
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, class WriteVector>
|
||||
void writeCellPropertiesValuesOnly(const Properties& propList,
|
||||
const ::Opm::GridProperties<T>& propValues,
|
||||
const ::Opm::EclipseGrid& grid,
|
||||
WriteVector&& write)
|
||||
{
|
||||
for (const auto& prop : propList) {
|
||||
if (! propValues.hasKeyword(prop.name)) {
|
||||
@ -379,15 +398,40 @@ namespace {
|
||||
const ::Opm::GridProperties<double>& propValues,
|
||||
const ::Opm::EclipseGrid& grid,
|
||||
const ::Opm::UnitSystem& units,
|
||||
const bool needDflt,
|
||||
::Opm::EclIO::OutputStream::Init& initFile)
|
||||
{
|
||||
writeCellProperties(propList, propValues, grid,
|
||||
[&units, &initFile](const CellProperty& prop,
|
||||
std::vector<double>&& value)
|
||||
{
|
||||
units.from_si(prop.unit, value);
|
||||
initFile.write(prop.name, singlePrecision(value));
|
||||
});
|
||||
if (needDflt) {
|
||||
writeCellPropertiesWithDefaultFlag(propList, propValues, grid,
|
||||
[&units, &initFile](const CellProperty& prop,
|
||||
std::vector<bool>&& dflt,
|
||||
std::vector<double>&& value)
|
||||
{
|
||||
units.from_si(prop.unit, value);
|
||||
|
||||
for (auto n = dflt.size(), i = decltype(n){}; i < n; ++i) {
|
||||
if (dflt[i]) {
|
||||
// Element defaulted. Output sentinel value
|
||||
// (-1.0e+20) to signify defaulted element.
|
||||
//
|
||||
// Note: Start as float for roundtripping through
|
||||
// function singlePrecision().
|
||||
value[i] = static_cast<double>(-1.0e+20f);
|
||||
}
|
||||
}
|
||||
|
||||
initFile.write(prop.name, singlePrecision(value));
|
||||
});
|
||||
}
|
||||
else {
|
||||
writeCellPropertiesValuesOnly(propList, propValues, grid,
|
||||
[&units, &initFile](const CellProperty& prop,
|
||||
std::vector<double>&& value)
|
||||
{
|
||||
units.from_si(prop.unit, value);
|
||||
initFile.write(prop.name, singlePrecision(value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void writeDoubleCellProperties(const ::Opm::EclipseState& es,
|
||||
@ -410,7 +454,7 @@ namespace {
|
||||
properties.assertKeyword("NTG");
|
||||
|
||||
writeDoubleCellProperties(doubleKeywords, properties,
|
||||
grid, units, initFile);
|
||||
grid, units, false, initFile);
|
||||
}
|
||||
|
||||
void writeIntegerCellProperties(const ::Opm::EclipseState& es,
|
||||
@ -487,7 +531,9 @@ namespace {
|
||||
propValues.assertKeyword(prop.name);
|
||||
}
|
||||
|
||||
writeDoubleCellProperties(propList, propValues, grid, units, initFile);
|
||||
// Don't write sentinel value if input defaulted.
|
||||
writeDoubleCellProperties(propList, propValues, grid,
|
||||
units, false, initFile);
|
||||
}
|
||||
|
||||
void writeSatFuncScaling(const ::Opm::EclipseState& es,
|
||||
@ -503,9 +549,10 @@ namespace {
|
||||
|
||||
if (! es.cfg().init().filleps()) {
|
||||
// No FILLEPS in input deck. Output those endpoint arrays that
|
||||
// exist in the input deck.
|
||||
// exist in the input deck. Write sentinel value if input
|
||||
// defaulted.
|
||||
writeDoubleCellProperties(epsVectors.getVectors(), props,
|
||||
grid, units, initFile);
|
||||
grid, units, true, initFile);
|
||||
}
|
||||
else {
|
||||
// Input deck specified FILLEPS so we should output all endpoint
|
||||
@ -513,7 +560,8 @@ namespace {
|
||||
// However, downstream clients of GridProperties<double> should
|
||||
// not see scaling arrays created for output purposes only, so
|
||||
// make a copy of the properties object and modify that copy in
|
||||
// order to leave the original intact.
|
||||
// order to leave the original intact. Don't write sentinel
|
||||
// value if input defaulted.
|
||||
auto propsCopy = props;
|
||||
writeFilledSatFuncScaling(epsVectors.getVectors(),
|
||||
std::move(propsCopy),
|
||||
|
Loading…
Reference in New Issue
Block a user