Commit Graph

207 Commits

Author SHA1 Message Date
Jørgen Kvalsvik
70e7b02043 DeckItem.push_back overload for size = 1
DeckItem.push_back using insert for 1 element turns out to be very
expensive and caused a performance degredation.
2016-11-15 15:33:27 +01:00
Jørgen Kvalsvik
a22196546a ParserItem no longer requires heap alloc
Redesign of ParserItem so that its sum type nature no longer mandates
indirection, but rather a tag check on all operations. Because of this,
ParserRecords can now store ParserItems directly, and iterators are no
longer iterators to pointers, but behave like normal vector iterators.
2016-11-07 12:24:38 +01:00
Jørgen Kvalsvik
fdb772e075 DeckItem without internal inheritance.
Replaces the internal inheritance + unique_ptr scheme to a flat sum type
similar scheme that uses a tag to determine which operations are legal,
rather than using the indirection itself as a tag.
2016-11-07 12:24:38 +01:00
Jørgen Kvalsvik
bf057f157c Deck units no longer unique 2016-10-19 20:38:28 +02:00
Jørgen Kvalsvik
37c04328ca Remove shared_ptr typedefs 2016-10-19 20:38:28 +02:00
Jørgen Kvalsvik
f2e509f59f UnitSystem named constructors with automatic storage 2016-10-19 20:38:28 +02:00
Jørgen Kvalsvik
f9cb516b99 Remove DeckPtr+ParserPtr aliases
Remove the deprecated DeckPtr and ParserPtr aliases and removes
shared_ptr<Deck> and friends from all interfaces.
2016-10-19 20:38:28 +02:00
Jørgen Kvalsvik
c893a92aa6 Make Dimension+UnitSystem no longer use shared_ptr 2016-10-19 20:38:27 +02:00
Arne Morten Kvarving
6433059067 changed: rename function getType
typeof is a semi-reserved symbol in gcc (gcc extension to get typeid)
2016-10-17 10:48:29 +02:00
Jørgen Kvalsvik
f413e5441f Hoist loop variable.
Profiling indicates the size-check isn't hoisted properly. In this case,
manually hoising the loop invariant doesn't negatively impact clarity
nor give any more noise, and slightly improves performance.
2016-08-08 09:40:20 +02:00
Jørgen Kvalsvik
d7ac7ee9b8 Remove SCHEDULE as a special section
SCHEDULESection with its special implementation is a remnant of older
design and largely unnecessary now. The implementation also relied on
shared_ptr for efficiency and was not really used at all.

SCHEDULESection now is no longer special, and uses the same
implementation as SUMMARY, RUNSPEC etc. The one thing that separated it,
looking up keywords within a timestep, was only used once and this
computation has been inlined in the function.
2016-08-05 15:28:29 +02:00
Jørgen Kvalsvik
99570ff72e Add all records to Deck at once
Rather than doing add-item-check-duplicates per DeckItem added to a
record, construct all the items at once, then pass them in full to the
DeckRecord object. The DeckRecord object still check for duplicate
names, but with lower complexity and cost.
2016-08-05 10:45:31 +02:00
Jørgen Kvalsvik
29604ac2af Fix warnings in DeckRecord 2016-07-13 23:39:29 +02:00
Jørgen Kvalsvik
aff1908529 Fix warnings in DeckItem 2016-07-13 23:39:29 +02:00
Jørgen Kvalsvik
2f0f7201eb Fix warnings in Deck 2016-07-13 23:39:29 +02:00
Jørgen Kvalsvik
3696b750cd Remove opm-common dependency
Severs the code dependency on opm-commmon. There was no actual
functional dependency here, with the exception of some enable/disable
warning headers. To properly make opm-parser a stand-alone module the
usage of these headers have been removed and the dependency on
opm-common is gone.
2016-07-08 15:53:40 +02:00
Jørgen Kvalsvik
44cd4868f8 Syntactic cleanup
Fixup of some messy constructors.
2016-07-05 08:22:13 +02:00
Jørgen Kvalsvik
17464851ad Initializer list constructors for Deck
Initializer list support makes some tests much easier to write (and
read) and enables some nifty features for when small, special-purpose
decks are needed.
2016-07-04 12:40:31 +02:00
Liu Ming
cb74ccf589 adapt API changes in ParseContext. 2016-05-14 09:15:27 +02:00
Pål Grønås Drange
3124c9569c Throw now contains name() of deckKeyword 2016-05-10 14:45:35 +02:00
Jørgen Kvalsvik
63fd998e2a Allow Section objects to be empty
Preserves expect Deck-like behaviour by allowing empty sections.
2016-05-09 15:09:43 +02:00
Jørgen Kvalsvik
60c20f8057 Explicitly store loop invariants in assertSIData
Profiling shows that gcc isn't recognising these as loop invariants, so
we help it a little bit by explicitly storing them.
2016-05-03 09:16:28 +02:00
Jørgen Kvalsvik
8a4eb5279c Splitting records with string_view; test updates
The splitting of RawRecords into individual symbols uses string_view.
Also updates tests since RawRecord now assumes that the record string it
receives is complete and does *not* contain the terminating slash.
2016-05-03 09:16:28 +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
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
b3b8cebeff Simplified deck filename handling. Only set filename if successfully opened 2016-04-28 15:42:07 +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
Joakim Hove
01cf268f69 Emit compiler warning when including Deck.hpp
This commit is a first step towards reducing the use of the Deck api
outside of opm-parser. Downstream modules should preferably use the
EclipseState api which is richer in features, and also easier to use
correctly.

The current form of the code is temporary, in the future we will remove
the OPM_PARSER_DECK_API_WARNING compile guard.
2016-04-26 14:00:03 +02:00
Liu Ming
59c6569a78 Make mutable MessageContainer member, recover the const qualifier for deck. 2016-04-25 16:25:15 +08:00
Liu Ming
52af33c7e0 remove const constrain for Deck. 2016-04-22 16:51:04 +08:00
Liu Ming
7946d0175f remove unused OpmLog headers. 2016-04-13 11:59:29 +08:00
Liu Ming
4eb2208e63 remove shared_ptr 2016-04-12 09:01:33 +08:00
Liu Ming
0dcb776940 Add MessageContainer to Deck. 2016-04-11 11:15:39 +08:00
Jørgen Kvalsvik
f8bab0e703 DeckItemT::SIdata mutable modifier
Replaces const_cast in favour of mutable keyword in order to avoid
undefined behaviour under some conditions.
2016-04-06 15:09:32 +02:00
Jørgen Kvalsvik
135f405e93 InitUnitSystem private; constness managed by .get
The const_cast in Deck::get*UnitSystem are potentially undefined
behaviour under a series of (plausible) conditions, and are deprecated
in favour of mutable members. Removes initUnitSystem from the public
interface, as the initialisation is handled on the first getUnitSystem
anyway, cleaning up the Deck interface slightly.

Adds proper constness to the use of unit systems that don't actually
modify the internal state in any way.
2016-04-06 15:09:32 +02:00
Jørgen Kvalsvik
0da5cadc75 RawRecords auto store, strings moved to RawRecord
The accumulated strings are moved into RawRecords, which reduces
execution time (rough measurements indicates 4-8%). To facilitate this,
RawRecords are stored directly in the vector in favour of via
shared_ptrs.
2016-03-22 08:58:48 +01:00
Jørgen Kvalsvik
e64d9f82a4 DeckItem tag explicit instead of vtable lookup
dynamic_cast turns out to be rather slow, and it is faster to look up an
explicit tag instead.
2016-03-22 08:58:48 +01:00
chflo
f2ed1ba7ea Moved OpmLog from opm-parser to opm-common 2016-03-21 22:07:49 +01:00
Joakim Hove
f0158f6ca3 Merge pull request #718 from jokva/fix-uninitialised-values
Initialisation and memory errors fixed
2016-03-17 13:56:48 +01:00
Liu Ming
12268c7937 rename ParseMode as ParseContext in Deck folder. 2016-03-16 16:36:34 +08:00
Jørgen Kvalsvik
79b1407e23 Default constructed Deck is well-defined
The underlying iterators were default constructed (aka uninitialised)
when a Deck was default constructed, meaning possible invocation of
undefined behaviour.

While the empty Deck typically is only used for testing, this is a
possible bug in production code. This small patch makes sure even
default constructed Decks are well defined.
2016-03-14 16:02:27 +01:00
Jørgen Kvalsvik
1406630aa3 DeckItem constructor takes size hint
Enable preallocation by passing size hints to DeckItem constructor.
2016-03-14 08:29:54 +01:00
Jørgen Kvalsvik
84e245bdb5 DeckRecord preallocation support.
The translation between ParserRecord knows in advance how many DeckItem
entries there are in the resulting DeckRecord. We can use this
information to efficiently preallocate memory in the DeckRecord.
2016-03-14 08:29:54 +01:00
chflo
0db3abab94 Added copyright header to files that were without it 2016-03-04 14:56:18 +01:00
Atgeirr Flø Rasmussen
c4be826212 Silence shadowing warnings. 2016-02-29 10:25:35 +01:00
Jørgen Kvalsvik
a8d7b250ca Simplify DeckRecord::addItem implementation 2016-02-22 10:18:22 +01:00
Jørgen Kvalsvik
7eb52f1023 Removes DeckKeyword's dependency on ParserKeyword
The completely constructed Deck isn't supposed to have any relationship
with the Parser structures (which are completely stateless in terms of
input data), and ParserKeyword in DeckKeyword was an anomaly. With
recent refactorings this lead to subtle lifetime issues.

This patch breaks this dependency and cleans up DeckKeyword accordingly,
while changing checkDeck to now take the parser as an additional
argument, to look up whether or not some DeckKeyword is in the right
section. This now also means that Parser* objects can be destroyed once
the Deck is created.

The Section::checkSectionTopology has been moved to Parser.cpp. It is a
temporary home for the feature to make the project compile nicely (i.e.
createKeywordList can be compiled as before, without introducing a
circular dependency on itself via Parser.cpp), until some proper cleanup
of the parser code has been done. It never really fully belonged in
Section.cpp anyway, so this is a first step in the direction of some
slight renaming.
2016-02-18 13:27:24 +01:00
Jørgen Kvalsvik
f0ae5db131 opm-parser adoption of Deck automatic ownership
Since the Deck* family of classes have changed their interfaces to no
longer use shared_ptr, a lot of code broke. This patch fixes all
problems in tests, other signatures and accesses to now use the new Deck
interfaces.
2016-02-18 13:27:24 +01:00
Jørgen Kvalsvik
9c577d8645 Deck uses automatic memory
The deck no longer exposes shared_ptrs, but uses automatically managed
memory, meaning ownership of DeckKeywords are now obvious and clear.
shared_ptr in the interface has been replaced by references.
2016-02-18 13:26:56 +01:00
Jørgen Kvalsvik
a0a063e386 Split Deck into RO/RW interfaces
This refactoring reflects the ownership semantics of Deck* classes -
Section and Section-derived classes no longer claim ownership over
partial decks, but rather provide a -view- into an already
established Deck.

The Deck class itself is now unique in the sense that it is the only
supporter of write operations, meaning a DeckView derived instance can
never modify the deck it's viewing.
2016-02-18 13:26:56 +01:00