Commit Graph

1981 Commits

Author SHA1 Message Date
Jørgen Kvalsvik
6b64796d49 Add char* constructor to string_view
Mostly relevant for testing, this enables string_view to work as
expected with string literals.
2016-05-03 09:16:28 +02:00
Jørgen Kvalsvik
bfa3f799b9 Improved fast path in number parsing
Since string_view uses char* for representation, there is no longer a
need to copy into a local char array for most code paths (only when the
input must be modified due to fortran float formatting).
2016-05-03 09:16:28 +02:00
Jørgen Kvalsvik
b648719513 Base string_view on char*, not string::iterator
By representing string_view as char* instead of
std::string::const_iterator the string_view class bring possibly
slightly lower overhead, but mostly enables some optimisations.
2016-05-03 09:16:27 +02:00
Jørgen Kvalsvik
bda128ee23 front/back support in string_view 2016-05-03 09:16:27 +02:00
Jørgen Kvalsvik
cb29336a44 Remove all non-data before parsing begins
Perform a pre-pass over the input and remove everything that isn't
interesting. Preserves empty lines to provide accurate line number for
diagnostics/error output.
2016-05-03 09:16:27 +02:00
Jørgen Kvalsvik
a1ae0e0067 Updated various functions to accept string_view
To take advantage of parser's internal string_view representation of
keyword names, several signatures have been updated to accept
string_view.
2016-05-03 09:16:27 +02:00
Jørgen Kvalsvik
82b1901841 Parser keyword maps uses string_view for keys
The use of string_view for keys allows comparison with keywords from the
file buffers to be compared directly, instead of having to go via
std::string. This removes the need for a series of (inherently)
unecessary copies.
2016-05-03 09:16:27 +02:00
Jørgen Kvalsvik
a93507087d string_view operator< and operator== support
In order for string_view to be useful as container member and sorting,
it has to support operator< and operator==
2016-05-03 09:16:27 +02:00
Jørgen Kvalsvik
096e843d08 Moved special-casing of TITLE to RawKeyword
Replaces the special-casing of the TITLE keyword where a terminating
slash is added onto the record with a non-mutating version.
2016-05-03 09:16:27 +02:00
Jørgen Kvalsvik
7d29d63bea Replace string with string_view in inner parser
Several inner parser functions modified to use string_view, to reduce
unecessary copying (and indirectly allocationg) related to passing
strings around.
2016-05-03 09:16:27 +02:00
Jørgen Kvalsvik
1edc6887be Replace parser stringstreams with string_view
Replaces the parser's dependence on streams with string_view, which
won't copy to its internal buffers. Involves hand-rolling std::getline
for string_view to preserve stream-like behaviour.
2016-05-03 09:16:27 +02:00
Jørgen Kvalsvik
e5ee6105b7 Remove parseStream support; strict input reading
Replaces the external stream-support by reading the entire contents of
input files at once, rather than lazily through streams. Uses
stringstreams internally, but keeps the entire file in memory through
std::string

openString/File has been renamed to loadString/File
2016-05-03 09:16:27 +02:00
Jørgen Kvalsvik
db6bb58f60 Remove redundant application of uppercase()
When considering if a keyword is valid, the parser procedures convert
the same string to uppercase twice, with copies. This behaviour has been
changed, and ParserKeyword now assumes it will be given a
correctly-formatted keyword to look up.
2016-05-03 09:15:46 +02:00
Jørgen Kvalsvik
4d7f97d322 Refactor ParseState to use explicit stack
Rewrites ParseState to use an explicit stack of open file streams
instead of spawning multiple ParseState objects. While recursion is
*the* most elegant to solve a typical include-file system, the global
nature of eclipse declarations make this clumsy (at best). Instead,
maintain an explicit stack of open files and logically parse the input
as if it was all concatenated into one large file.

Also adds some convenient ways of accessing the current (and
interesting) top of the stack.
2016-05-03 09:15:46 +02:00
Jørgen Kvalsvik
83555a52a1 Minor restructuring in Parser::getKeyword* 2016-05-03 09:15:46 +02:00
Jørgen Kvalsvik
9ce28fb7ea Restructure addRawRecordString
Redcues indentation slightly and adds multiple return to better
communicate that some conditions actually logically terminate at several
points.
2016-05-03 09:15:45 +02:00
Jørgen Kvalsvik
58489ca571 Restructured control flow of ParserKeyword::equal 2016-05-03 09:15:45 +02:00
Jørgen Kvalsvik
48e741efb6 ParserKeyword::parse restructure control flow
Reduce the number of concurrent branches and remove a seemingly
redundant check.
2016-05-03 09:15:45 +02:00
Jørgen Kvalsvik
3f3cb8c313 validDeckName uses all_of
Favours std::algorithm over hand-written loop.
2016-05-03 09:15:45 +02:00
Jørgen Kvalsvik
76336e2047 getDeckName without boost; uses range copy
Deprecates boost::trim in ParserKeyword and replaces it with range
search and copy.
2016-05-03 09:15:45 +02:00
Jørgen Kvalsvik
d385275c5b Reformulated validInternalName with iterators 2016-05-03 09:15:45 +02:00
Jørgen Kvalsvik
6780202352 Simplify hasDimension 2016-05-03 09:15:45 +02:00
Jørgen Kvalsvik
fb8e8b09c1 Parser::applyUnitsToDeck restructured control flow 2016-05-03 09:15:45 +02:00
Jørgen Kvalsvik
02e9b50df9 Deck::iterator support
Add support for iterators that support mutations, which are useful for
the Deck assembly stage.
2016-05-03 09:15:45 +02:00
Jørgen Kvalsvik
cb8e21de01 Restructure createRawKeyword.
Restructures createRawKeyword to use multiple return statements over
if-else and updating variables, reducing indentation to have fewer
contemporary branches.
2016-05-03 09:15:23 +02:00
Jørgen Kvalsvik
bdce26480a createRawKeyword return on unmet preconditions
Changes the control flow of Parser::createRawKeyword to return on
failing to meet preconditions, rather than if-else block. Reduces
indentation and concurrent code paths.
2016-05-03 09:15:23 +02:00
Jørgen Kvalsvik
1330bfc681 parseState use return over break for control flow
Makes the actual effects of the various condtions more clear by
emphasising the return of the function rather than some possible action
after the loop.
2016-05-03 09:15:23 +02:00
Jørgen Kvalsvik
28f297f854 Reduce indentation in parseState
Restructures the per-iteration check of whether or not to continue
parsing to happen first and be an early-break, instead of this flow
being handled by if-else.
2016-05-03 09:15:23 +02:00
Jørgen Kvalsvik
86a5a89429 ParseState early abort over if-else
A small syntactic change that reduces indentation by a level. Checks the
preconditions first and throws if they aren't met (i.e. stream is
broken).
2016-05-03 09:15:23 +02:00
Jørgen Kvalsvik
033223720a trim_right replaced by trim
Augment trim_right with the dual trim_left and their composition trim
which strips all spaces from either side before the RawKeyword stage
starts.
2016-05-03 09:15:23 +02:00
Jørgen Kvalsvik
4b4d2c02c0 Reimplementation of stripComments
The implementation has been rewritten to use iterators and renamed for
internal use. The public static function still exists for testability
and easy verification, but should be considered an internal part of the
parser.
2016-05-03 09:15:22 +02:00
Jørgen Kvalsvik
bfb7f6ec0c RawRecord internals use ranges over string methods
Rewrites the internal string mainpulation functions of RawRecord to use
std::algorithm and ranges over string methods.
2016-05-03 09:15:22 +02:00
Kjell W. Kongsvik
db7958d439 Return type -> const & 2016-05-02 10:13:28 +02:00
Kjell W. Kongsvik
34dbf826de Support explicit setting of BaseName
Needed when reading deck from string and trying to write to disk.
If this is not set there is no baseName to base the file name on.
2016-04-29 16:04:16 +02:00
Atgeirr Flø Rasmussen
28d6237749 Silence warning in brace-init of std::array. 2016-04-29 13:45:26 +02:00
Joakim Hove
d86343f8a5 Merge pull request #784 from kjellkongsvik/clean_EclipseWriter
Clean eclipse writer
2016-04-29 11:42:41 +02:00
Kjell W. Kongsvik
bedd431b10 Use path of input as default output path
Custom output path can be set explicitly using IOConfig::setOutputDir(path)
2016-04-29 11:24:48 +02:00
Joakim Hove
bc000899c8 Merge pull request #777 from joakim-hove/ignore-skiprest
Ignore skiprest
2016-04-28 22:20:44 +02:00
Kjell W. Kongsvik
65277fcc9f Removed getDeckFileName as the usage of it in EclipseWriter is not needed
Remove in opm-output
2016-04-28 16:19:56 +02:00
Joakim Hove
d32b409c27 Added Eclipse3DProperties PRESSURE, SGAS & SWAT. 2016-04-28 16:03:29 +02:00
Joakim Hove
25ef8781c9 Added ability to set restart parameters. 2016-04-28 16:03:29 +02:00
Joakim Hove
6d0d0280bc Merge pull request #781 from joakim-hove/deck-use-warning
Emit compiler warning when including Deck.hpp
2016-04-28 15:42:09 +02:00
Kjell W. Kongsvik
b3b8cebeff Simplified deck filename handling. Only set filename if successfully opened 2016-04-28 15:42:07 +02:00
Kjell W. Kongsvik
79ab818c3a Default output dir is current active directory
Optionally specify using IOCondig::setOutputDir()
2016-04-28 13:45:09 +02:00
Kjell W. Kongsvik
5fb3a6fc53 Add dataFile to Deck if loaded from file
If loaded from string keep empty
2016-04-28 13:45:08 +02:00
Kjell W. Kongsvik
1640ad0826 Removed meaningless "path" paramater in tests
This parameter will be used in a more meaningful way
2016-04-28 13:45:08 +02:00
Kjell W. Kongsvik
206e16fba5 Added fields to IOConfig so parameters can be removed from EclipseWriter
std::string     m_deck_filename;
bool            m_output_enabled;
std::string     m_output_dir;
2016-04-28 13:45:08 +02:00
Joakim Hove
54579155a1 Merge pull request #782 from jokva/grid-properties-std-function
Refactor GridPropertyInitializers to use std::function
2016-04-28 09:02:25 +02:00
Pål Grønås Drange
e1ab313cb7 Added method getIJK in EclipseGrid 2016-04-27 12:55:14 +02:00
Jørgen Kvalsvik
e7bdb796da Replace boost::lexical_cast with std::to_string 2016-04-27 11:51:45 +02:00