this is not supported in older version of boost::filesystem.
furthermore, it was always an experimental feature and
and has been deprecated in newer versions.
generic_string is available in all versions, so use that.
Then we don't have to store copies of the 'formatted' and 'unified'
flags, and are also able to remove the 'prepareStep()' function. We
will reintroduce these features if we decide to add support for
keeping the output stream open between separate restart output
requests (i.e., between calls to EclipseIO::writeTimeStep()).
In particular, make the stream() function into a private detail of
the implementation and add an overload set for outputting keyword
data and messages to the underlying output stream. Update unit test
accordingly.
Suggested by: Atgeirr F. Rasmussen
This commit introduces a new class,
Opm::ecl::OutputStream::Restart
that handles the details of opening restart output streams (all
combinations of formatted/unformatted and unified/separate), as well
as correctly positioning the stream 'put' indicator if we're opening
an existing unified restart file. In most cases, this will be a
simple append operation (std::ios_base::app), but there are some
subtleties that require more precise control. The new class is
befriended by EclOutput and ERst in order to access private member
functions and data members of these classes. That is needed in
order to handle file resize operations since some of the requisite
information is only available in those two classes.
We use Boost.Filesystem to implement file resize, as if by POSIX
function ::truncate(), and also to simplify filename generation.
These calls can be switched to std::filesystem once the project
requires C++17.
Intended use of the Restart class is
Restart rst(resultSet, formatted, unified);
rst.prepareStep(17); // Report step/SEQNUM 17.
rst.write("INTEHEAD", ihead);
// ...
The 'prepareStep' operation opens the file stream (if needed) and
also outputs a SEQNUM record in the case of a unified output stream.
Moreover, the 'resultSet' is a pair of output directory and case's
base name (e.g., "./mpi.np4/2019.05.14.01" and "NORNE_ATW2013") and
the formatted/unified flags are bools wrapped in structures.
The Restart class is intended to take over the role of the
'filename' string parameter of RestartIO::save().
Add a set of unit tests to demontrate usage and abilities of class
Restart.
This commit extends the EclOutput constructor to support letting the
client specify a particular open mode. This in turn prepares using
EclOutput as the basis for a restart file writer. Passing
mode=openmode::out is the common case for a new restart file, while
mode=openmode::app is the common case for an existing restart file.
Specifically, add a member function
EclOutput::message(const std::string&)
that outputs the string as an 'eclArrType::MESS'. This is in order
to support outputting 'STARTSOL' and 'ENDSOL' demarcations in a
restart file.
This commit introduces a new member function,
ERst::restartStepWritePosition(seqnum)
that translates a SEQNUM ID into a std::streampos object pointing to
the start of the data for that SEQNUM ID. Return std::streampos(-1)
if the sequence number exceeds all known sequence numbers in this
restart set.
The member function is private because it is supposed to be called
only by the class itself and a select set of class friends.
This commit introduces a new member function
EclFile::seekPosition(arrayIndex)
that retrieves the file (seek) position of the start of the header
of the arrayIndex-th keyword. The expected use case for this is
seeking to the start of a particular SEQNUM value in a unified
restart file. If the array index exceeds all supported index
values, then we return the position of the file's EOF mark (captured
as the last item in the EclFile constructor).
The member function is protected to be accessible in derived classes
and by friends of derived classes.
With this commit the code to evaluate UDQ values has been extended/refactored in
many ways:
- There is an increased awarenwss of variable type, i.e. a well related UDQ
versus a field related UDQ. The variable type flows through the AST, and it
is verified that the expression to evaluate and the target variable are of
compatible types.
- Have added support for UDQ field variables and UDQ group variables.
- The UDQSet type and the UDQDefine::eval() have been refactored to multiplex
on all the UDQ types, and the specialized UDQWellSet has been removed.
This makes the facility usable for the restart read/write code.
Specifically, import the I/O classes into namespace Opm::ecl, and
place the files in physical location opm/io/eclipse, and move the
test utilities to new top-level directory 'test_util/'. While here,
discontinue the 'testutil' static library since most of its features
are now available in the main 'opmcommon' library. This does entail
compiling a few of the test_util/ CPP files multiple times, and
adding the objects to each executable independently.