Compare commits

...

794 Commits

Author SHA1 Message Date
Bård Skaflestad
3ecf6db2e0 Raise OPM Version to 2020.10 Final 2020-11-17 13:52:05 +01:00
Bård Skaflestad
0a3557a727 Raise OPM Version to 2020.10-rc5 2020-11-06 11:28:43 +01:00
Bård Skaflestad
bf823a4fd4 Merge pull request #2094 from OPM/backport-of-pr-2093
workaround cmake issue
2020-11-06 11:26:05 +01:00
Arne Morten Kvarving
74b4287b6e workaround cmake issue
cmake does not properly interpret the SYSTEM marker in lists of
include directories. this causes issues downstream when using
dunecontrol / the in-tree cmake config files.
2020-11-06 11:23:10 +01:00
Bård Skaflestad
b99dc9b5ec Raise OPM Version to 2020.10-rc4 2020-10-30 17:16:52 +01:00
Bård Skaflestad
fbfeba9b2e Raise OPM Version to 2020.10-rc3 2020-10-29 23:38:57 +01:00
Bård Skaflestad
3448c9c4ec Merge pull request #2061 from OPM/backport-of-pr-2038
[cmake] Use scotch include dir for parmetis bindings of scotch.
2020-10-28 13:57:42 +01:00
Markus Blatt
4bb23ecf5a [cmake] Use scotch include dir for parmetis bindings of scotch.
The parmetis.h distributed via the parmetis binding of scotch
with Ubuntu 18.04 (libscotchparmetis-dev) includes the header
scotch.h located in /usr/include/scotch/. Therefore our check
of the include file failed. With this commit we check the
parmetis.h header another time with the scotch include path added.
Now parmetis is found on my Ubuntu.
2020-10-28 13:48:57 +01:00
Bård Skaflestad
2ba39f875c Merge pull request #2057 from OPM/summary-bugfixes
Summary bugfixes
2020-10-27 14:30:29 +01:00
Bård Skaflestad
705930a5ca Don't Treat WPIL as Completion Keyword
WPIL is the productivity index of liquid (water + oil).
2020-10-27 10:12:13 +01:00
Joakim Hove
465a3447c7 Summary function glir should sum over all argument wells 2020-10-27 10:11:20 +01:00
Bård Skaflestad
a1080f8361 Bump version to 2020.10-rc1 2020-10-19 10:29:03 +02:00
Joakim Hove
6e82f3cb7a Merge pull request #2021 from joakim-hove/no-wells-message
No wells message
2020-10-14 14:23:24 +02:00
Joakim Hove
7f8578ea96 Merge pull request #2020 from joakim-hove/fmwia
Fmwia
2020-10-14 14:22:38 +02:00
Joakim Hove
21d44c09e0 Merge pull request #2019 from joakim-hove/vfpprod-dimension
Dimension string does not accept space
2020-10-14 12:15:49 +02:00
Joakim Hove
e3959c5fa1 Implement number of abondoned injectors: FMWIA 2020-10-14 08:43:03 +02:00
Joakim Hove
2d036144cc Raise OpmInputError for unbalanced quotes 2020-10-14 08:40:10 +02:00
Joakim Hove
2ebc15e8d4 Fix message format for invalid wellname pattern 2020-10-14 08:15:07 +02:00
Joakim Hove
dd34f2d831 Maintain whether a well has ever injected 2020-10-14 00:39:48 +02:00
Joakim Hove
e1698f7be8 Rename test well RFT -> RFTP 2020-10-14 00:12:50 +02:00
Joakim Hove
47c4f5c2e0 Dimension string does not accept space 2020-10-13 22:19:49 +02:00
Joakim Hove
d0416d963d Merge pull request #2017 from joakim-hove/rst-commits
Rst commits
2020-10-13 15:12:21 +02:00
Joakim Hove
53fe0f2d11 Add guide rate delay and damping to rst header class 2020-10-13 13:11:04 +02:00
Joakim Hove
ead5a19209 Extract update of guide rate model into separate function 2020-10-13 09:52:33 +02:00
Joakim Hove
94c697ccd0 Load boolean flag to indicate whether group control is active 2020-10-13 09:52:33 +02:00
Joakim Hove
60c406397b Merge pull request #2015 from bska/record-new-connstructure
Record Event if WellConnections Change
2020-10-12 18:24:54 +02:00
Bård Skaflestad
6f20858d73 Record Event if WellConnections Change
This is different from COMPLETION_CHANGE which is unconditionally
recorded when processing COMPDAT.  This event is recorded only when
the Well's internal WellConnections structure actually changes and
informs clients that they may need to rerun any dynamic WELPI
scaling.  Such scaling will not be automatically forwarded onto the
new WellConnections structure.

This is arguably a hack.
2020-10-12 15:10:28 +02:00
Bård Skaflestad
5852270035 Merge pull request #2014 from bska/fix-oob-indexing
Ensure *HEAD Arrays Have Sufficient Size
2020-10-12 14:52:38 +02:00
Bård Skaflestad
810a93ba87 Ensure *HEAD Arrays Have Sufficient Size
The regression test program depends on this.
2020-10-12 13:49:53 +02:00
Bård Skaflestad
b0b8523b2a Merge pull request #2013 from joakim-hove/schedule-msg
Schedule msg
2020-10-12 11:47:47 +02:00
Bård Skaflestad
6708273616 Merge pull request #2007 from joakim-hove/rst-cmp
Use restart object in regression testing
2020-10-12 11:47:09 +02:00
Joakim Hove
206243c78d Compare string and integere members from well using RestartIO data 2020-10-12 10:11:07 +02:00
Joakim Hove
8f90bf9387 Refactor the log messages emitted while creating the Schedule object
A maximum of N dates keywords are printed to stdout, afterwards logging will
only go to PRT file
2020-10-12 09:59:04 +02:00
Joakim Hove
db052055b2 Merge pull request #2011 from joakim-hove/grid-msg
Grid msg
2020-10-10 10:30:36 +02:00
Joakim Hove
32ac90cb5e Add messages about grid creation 2020-10-10 08:30:48 +02:00
Joakim Hove
36e03cf6b9 Use ParserKeyword::prohibits for COORD / GDFILE / ZCORN 2020-10-10 08:30:48 +02:00
Joakim Hove
fa65ce92d8 Allow loading of RstState for restart files without wells 2020-10-09 15:32:45 +02:00
Bård Skaflestad
79ad189d65 Merge pull request #2008 from joakim-hove/schedule-error-msg
Schedule error msg
2020-10-09 12:30:01 +02:00
Joakim Hove
d3a44ca543 Add proper error message for ill formed dates keyword 2020-10-09 11:40:15 +02:00
Joakim Hove
b273ef389a Make sure strings are joined - remove "," 2020-10-09 11:23:41 +02:00
Joakim Hove
c6068f4e17 Merge pull request #2006 from joakim-hove/keyword-interaction
Keyword interaction
2020-10-08 17:48:28 +02:00
Joakim Hove
a8b510334e Merge pull request #2002 from bska/welpi
Add Support Infrastructure for WELPI Feature
2020-10-08 17:48:03 +02:00
Bård Skaflestad
70ef0858f7 Store WELPI Scaling Eligibility as Per-Connection Flag
Greatly simplifies logic in container class (WellConnection).

Suggested by: [at]joakim-hove
2020-10-08 11:19:04 +02:00
Bård Skaflestad
f384269133 Represent Assigned PI as an optional<>
Suggested by: [at]joakim-hove
2020-10-08 11:19:04 +02:00
Bård Skaflestad
a077847f69 Create Fully Non-Defaulted Serialization Test Objects
Suggested by [at]akva2.
2020-10-08 11:19:03 +02:00
Bård Skaflestad
fa7d8bc28c Add Support Infrastructure for WELPI Feature
This commit adds logic implementing the static parts of the WELPI
keyword.  We internalize the keyword data, record appropriate events
and provide hooks for dynamically adjusting the per-connection
transmissibility factor (Connection::CF()) when those events occur.
We implement support at three levels

  - WellConnections:
    Add new public member functions prepareWellPIScaling and
    applyWellPIScaling which, respectively, creates bookkeeping
    data to track those connections which are subject to CF scaling
    and actually applies that CF scaling.

  - Well:
    Add new data member 'productivity_index' which holds the 'WELPI'
    data value from the input keyword (converted to SI) and new
    member functions updateWellProductivityIndex and
    applyWellProdIndexScaling.  The first follows the 'update*'
    protocol (return 'true' if state change) and assigns new values
    to 'productivity_index' while the second uses the stored PI
    value and a dynamically calculated effective PI value to rescale
    the pertinent connections' CF value.

  - Schedule:
    Add new member function handleWELPI which internalizes the WELPI
    keyword and its data and records WELPI events for subsequent
    playback in the simulator layer.

Also add a set of unit tests to exercise the new features at all
levels.
2020-10-08 11:19:03 +02:00
Bård Skaflestad
de5e3d90cd Miscellaneous Cleanup Changes
In particular, include standard library headers as needed, fix
function declarations (operator<<() for Well::WellProductionProperties),
and make a few helper functions 'static' to avoid warnings of the
form "no previous declaration for".

For the Schedule's keyword handlers, also switch to storing member
function pointers directly instead of std::function objects.  This
saves space and does not incur function pointer conversions.  Use
std::invoke to call those handlers to avoid having to spell out the
'->*' operator.
2020-10-08 11:19:03 +02:00
Bård Skaflestad
36e3a25782 Use Explicit Powers of Two for Events Enumerators
Suggested by [at]joakim-hove
2020-10-08 11:19:03 +02:00
Bård Skaflestad
cc22c3bcf3 Remove Duplicated Logic in filterConnections
The Schedule::filterConnections() member function contained three
copies of the same loop, possibly as a result of earlier conflict
resolution.  Remove two of those loops.
2020-10-08 11:19:03 +02:00
Joakim Hove
732f19d2a2 Merge pull request #2003 from joakim-hove/rst-group2
Establish group <-> group relationship when loading from restartfile
2020-10-08 10:59:15 +02:00
Joakim Hove
7b19d9a20a Add prohibits relation DX <-> DXV and DY <-> DYV 2020-10-08 08:45:23 +02:00
Joakim Hove
bb7941b754 Add keyword requires relationship between TRACERKM and PARTTRAC 2020-10-08 08:40:36 +02:00
Joakim Hove
0dcb31cae5 Use Group constructor when loading from restart file 2020-10-08 08:15:32 +02:00
Joakim Hove
fa24394f69 Establish group <-> group relationship when loading from restartfile 2020-10-08 08:13:17 +02:00
Joakim Hove
cc4f8faa4c Merge pull request #2005 from bska/wellconnections-empty
Add Convenience Predicate WellConnections::empty
2020-10-08 08:05:15 +02:00
Bård Skaflestad
a5a18fea9e Add Convenience Predicate WellConnections::empty
Replace expressions comparing size() to 0 with calls to empty().
2020-10-07 22:29:18 +02:00
Bård Skaflestad
e2da49d028 Merge pull request #2004 from joakim-hove/rst-wellopen
Rst wellopen
2020-10-07 21:37:44 +02:00
Joakim Hove
f02ecb472f Store Value::Shut == -1000 for shut wells in IWEL 2020-10-07 18:38:46 +02:00
Joakim Hove
956dce6be6 rebase fixup 2020-10-07 18:30:38 +02:00
Joakim Hove
00d5421153 Load well status from IWEL when loading restart file 2020-10-07 18:28:11 +02:00
Joakim Hove
a33fd2483f Updates to well control mode reported in IWEL
With this commit the IWEL[ActWCtrl] is assigned a value independently of the
wells OPEN / SHUT status.

With this PR the index enum value Status is used instead of the previously used
item11. Also numerical constants are introduced for eclipse status values for
Shut, Stop, Open and Auto.
2020-10-07 18:28:11 +02:00
Joakim Hove
23faea7b81 Merge pull request #1996 from wito/required-keywords
Required and Prohibited Keywords
2020-10-07 09:06:42 +02:00
Joakim Hove
efbfbaa90c Merge pull request #1999 from joakim-hove/rst-cmode
Rst cmode
2020-10-07 09:05:58 +02:00
Atgeirr Flø Rasmussen
de5e91c80c Merge pull request #2001 from atgeirr/silence-warnings
Fix struct/class warning.
2020-10-06 19:32:35 +02:00
Atgeirr Flø Rasmussen
a56eb48b85 Fix struct/class warning. 2020-10-06 15:54:11 +02:00
Joakim Hove
20e253a27a Merge pull request #1997 from joakim-hove/group-constructor
Add Group constructor based on RstGroup
2020-10-06 14:52:31 +02:00
Bård Skaflestad
7823045b02 Merge pull request #1995 from bska/prepare-dynamic-ctf
Summary/Restart: Get CTF From Simulator
2020-10-06 14:32:07 +02:00
Joakim Hove
1ec834dd71 Add Group constructor based on RstGroup 2020-10-06 13:16:33 +02:00
Williham Williham Totland
90d980a4f6 Adds manipulation of the ParseContext to tests. 2020-10-06 09:58:46 +02:00
Bård Skaflestad
b1abbe831a Merge pull request #2000 from akva2/janitoring
fixed: anonymize globals to avoid shadowing warnings
2020-10-06 08:54:51 +02:00
Arne Morten Kvarving
62c067f462 fixed: anonymize globals to avoid shadowing warnings 2020-10-06 08:23:11 +02:00
Bård Skaflestad
d65b83c28b Rename Top-Level Loop Function
Suggested by [at]joakim-hove
2020-10-05 23:34:01 +02:00
Bård Skaflestad
4956e880a4 Summary/Restart: Get CTF From Simulator
This commit switches to getting the output files' connection
transmissibility factor from Opm::data::Connection instead of
Opm::Connection.  This is in preparation for implementing the WELPI
feature, in which the CTFs are occasionally adjusted based on the
dynamic simulation state.
2020-10-05 23:34:01 +02:00
Bård Skaflestad
e92d6138f8 Refactor Connection Loop Function
In particular, split out the connection loop from the well loop, and
don't make a copy of the wells when we already have a Schedule
object and a "sim_step".
2020-10-05 23:34:01 +02:00
Bård Skaflestad
33d09936c3 Merge pull request #1719 from GitPaean/aquifer_keywords
adding aquifer summary keywords
2020-10-05 22:49:32 +02:00
Kai Bao
5c33c39495 addressing reviewing comments for OPM/opm-common#1719
using std::any_of instead of std::find_if
2020-10-05 20:55:06 +02:00
Joakim Hove
be898b5534 Merge pull request #1989 from wito/tablemanager-exceptions
Implements OpmInputError in TableManager
2020-10-05 17:02:42 +02:00
Joakim Hove
f9a52791a4 Load Water and gas Injection cmode from restart file 2020-10-05 15:23:09 +02:00
Joakim Hove
96fdb150b1 Use named index WInjCMode and GInjCMode 2020-10-05 15:23:02 +02:00
Joakim Hove
001b399d42 Change order of is_field() test 2020-10-05 15:13:37 +02:00
Joakim Hove
acfd917aab Add production control mode for restart group 2020-10-05 15:06:04 +02:00
Joakim Hove
08f41d4fa2 Add named index ProdCMode for IGRP 2020-10-05 15:06:01 +02:00
Williham Williham Totland
91e863e674 Resolves issue where test data was missing for Eclipse300. 2020-10-05 13:52:09 +02:00
Williham Williham Totland
7aba0cd976 Implements required and prohibited keywords. 2020-10-05 13:34:35 +02:00
Bård Skaflestad
fcdc57d92b Merge pull request #1994 from joakim-hove/rst-alq
Small Changes in restart <-> Schedule interaction
2020-10-05 13:07:15 +02:00
Williham Williham Totland
bd3242fe05 Adds getters/setters for required and prohibited keywords. 2020-10-05 11:37:18 +02:00
Williham Williham Totland
f610ce28a2 Adds test data. 2020-10-05 11:20:56 +02:00
Williham Williham Totland
c43600337b Throws exception with nesting, and generalises tests to account for same. 2020-10-05 11:06:19 +02:00
Joakim Hove
b9b55bb9b0 Early return in productionGroup() 2020-10-05 10:44:38 +02:00
Joakim Hove
ce463e6020 Extract functions for production and injection when creating IGRP 2020-10-05 10:44:33 +02:00
Joakim Hove
296538c724 Minor rewrite for checking group type 2020-10-05 09:31:02 +02:00
Williham Williham Totland
d0c5fa042c Adjusts the defaultMessage format string. 2020-10-05 09:26:25 +02:00
Williham Williham Totland
7a8347f1ab Unifies interface of OpmInputError::OpmInputError() 2020-10-05 08:26:51 +02:00
Kai Bao
aa639869be adding the development to test ANALYTICAL_AQUIFERS 2020-10-05 07:37:13 +02:00
Williham Williham Totland
690fa8259c Resolves an issue where the keyword information would not be reflected in the error message. 2020-10-05 07:28:07 +02:00
Williham Williham Totland
fca1764d7a Resolves #1975. 2020-10-05 07:28:07 +02:00
Joakim Hove
0f21752a7e Add test for unsupported keyword in FieldProps operations 2020-10-05 07:28:07 +02:00
Williham Williham Totland
3af6fac35d Adds a standard-format exception message to OpmInputError. 2020-10-05 07:28:07 +02:00
Williham Williham Totland
65f45b60a8 Extends OpmInputError to support multiple KeywordLocations. 2020-10-05 07:28:07 +02:00
Williham Williham Totland
0f8dec9ac3 Changes TableManager to throw OpmInputError where context permits. 2020-10-05 07:28:07 +02:00
Kai Bao
31e5c494a8 adding aquifer keywords to the summary_ALL test in SummaryConfigTests 2020-10-05 00:28:11 +02:00
Kai Bao
995316e97c handling unknown aquifer in SUMMARY section 2020-10-05 00:27:28 +02:00
Joakim Hove
47715ae7ae Move function in source file 2020-10-04 16:01:37 +02:00
Joakim Hove
f8d988d1dd Rename variable gseqIndex -> insert_index 2020-10-04 16:01:22 +02:00
Joakim Hove
aa54bc67de Load group->parent_group when loading from restart file 2020-10-04 16:00:50 +02:00
Joakim Hove
5b3a76172b Store parent_group index when loading restart group 2020-10-04 16:00:15 +02:00
Joakim Hove
c2522fd5ce Create symbol for IGRP parent group index 2020-10-04 15:59:53 +02:00
Joakim Hove
007ef0e94f Load well alq value when loading from restart file 2020-10-04 15:33:20 +02:00
Joakim Hove
528548ebce Set predictionMode for Injection and Production objects 2020-10-04 15:33:18 +02:00
Joakim Hove
00cb2c195d Merge pull request #1993 from alfbr/remove-supported
Remove confusing message
2020-10-04 09:34:03 +02:00
Alf Birger Rustad
2dee1070ef Remove confusing message 2020-10-03 17:17:13 +02:00
Kai Bao
e86e8796ec adding a small test for aquifer keywords 2020-10-02 22:32:23 +02:00
Kai Bao
2c0456da8a fixing the keyword generation for ALL related to Aquifer keywords 2020-10-02 22:27:47 +02:00
Joakim Hove
b9b6033854 Merge pull request #1987 from joakim-hove/arrraydimchecker-fixup
Fix bug in ArradDimChecker message
2020-10-02 18:20:54 +02:00
Joakim Hove
26bc6cb2ea Merge pull request #1980 from joakim-hove/time-keyword-info-logging
Time keyword info logging
2020-10-02 18:20:12 +02:00
Joakim Hove
574547a824 Merge pull request #1985 from joakim-hove/create-grid-info
Create grid info
2020-10-02 18:19:45 +02:00
Bård Skaflestad
99b2920e5e Merge pull request #1990 from bska/fix-oob-alq-indexing
ALQ Rate: Don't Index Into Empty Vector
2020-10-02 17:41:49 +02:00
Bård Skaflestad
447efffdfa ALQ Rate: Don't Index Into Empty Vector
The list of "schedule" wells is empty in at least one case-when
we're configuring the SMSPEC nodes.  Don't blindly assume that there
is always a non-empty sequence of wells.
2020-10-02 16:30:08 +02:00
Tor Harald Sandve
8210bcde34 Merge pull request #1968 from hakonhagland/wglir
Add support for WGLIR.
2020-10-02 14:48:18 +02:00
Kai Bao
6093a80dff fixing the compilation due to interface change 2020-10-02 14:09:01 +02:00
Kai Bao
fd773423b0 adding the following aquifer summary keywords
AAQR, AAQT, AAQP
2020-10-02 13:18:51 +02:00
Joakim Hove
1529509efb Improve error message: WELLDIMS item 4 can be wells/groups 2020-10-02 12:18:52 +02:00
Joakim Hove
1206570da5 Edit msg 2020-10-02 10:30:37 +02:00
Williham Williham Totland
4c016660d8 Logs simulation time advance information (level: info). 2020-10-02 10:30:37 +02:00
Joakim Hove
b3050cfbf5 Fix bug in ArradDimChecker message 2020-10-02 10:03:45 +02:00
Joakim Hove
0ab50fbc95 Merge pull request #1977 from wito/test-warning-noise-fix
Test Compilation Warning Noise Fix
2020-10-02 07:56:14 +02:00
Markus Blatt
2f96b9404f Merge pull request #1986 from joakim-hove/remove-template-args
Remove leftover template<...>
2020-10-01 21:07:58 +02:00
Joakim Hove
c0336d5eb7 Remove leftover template<...> 2020-10-01 16:59:50 +02:00
Joakim Hove
963ab6515a Add info message for grid creation 2020-10-01 15:30:19 +02:00
Joakim Hove
54088db22f Update warning for MULTREGT in EDIT section 2020-10-01 15:30:19 +02:00
Joakim Hove
3d0ff98865 Add log message for Fault construction 2020-10-01 15:30:19 +02:00
Joakim Hove
5fe9b6476e Use this-> 2020-10-01 15:30:19 +02:00
Joakim Hove
ad993fb82c Add log info message for tracer loading 2020-10-01 15:30:19 +02:00
Joakim Hove
27687ecc9e Initialize tracer configuration in initialization list 2020-10-01 15:30:19 +02:00
Joakim Hove
2d2d25fbec Add log message for Aquifer creation / initialization 2020-10-01 15:30:19 +02:00
Joakim Hove
ac39fa099b Use fmt::format for message 2020-10-01 15:30:19 +02:00
Joakim Hove
96ce078dfd Merge pull request #1983 from joakim-hove/private-fmt
Mkae sure fmtlib is not a dependency in the public api
2020-10-01 15:24:15 +02:00
Joakim Hove
fbf88e8ce1 Merge pull request #1984 from joakim-hove/remove-value
Remove homemade optional - use std::optional
2020-10-01 15:23:55 +02:00
Joakim Hove
6dc84b67df Remove homemade optional - use std::optional 2020-10-01 13:53:58 +02:00
Joakim Hove
0475ccdb77 Merge pull request #1978 from joakim-hove/schedule-skriprest-refactor
Changes in schedule iterate section for restarts
2020-10-01 07:47:50 +02:00
Joakim Hove
5f45f20be6 Merge pull request #1982 from blattms/fix-some-valgrind-warnings
Fix some warnings when running with valgrinds MPI wrapper.
2020-09-30 19:43:30 +02:00
Markus Blatt
d99aa0d497 Fix some warnings when running with valgrinds MPI wrapper.
It warns whenever uninitialized data is sent.
2020-09-30 18:26:48 +02:00
Joakim Hove
8c351440e8 Mkae sure fmtlib is not a dependency in the public api 2020-09-30 18:17:57 +02:00
Joakim Hove
26f91f0ce0 Merge pull request #1981 from akva2/janitoring
Some janitoring
2020-09-30 14:45:11 +02:00
Arne Morten Kvarving
f2d80014ab anonymize unused parameter 2020-09-30 10:09:15 +02:00
Arne Morten Kvarving
27dc014244 remove unused variables 2020-09-30 10:09:08 +02:00
Joakim Hove
42f1278db3 Changes in restart TimeMap and Schedule::iterateSection
This commit changes two aspects of restarts where well and group information is
assembled from the restart file:

 o We require the restart date to be present in the Schedule file as a DATES
   keyword.

 o SKIPREST behavior is implemented unconditionally for restarts with restart
   files, even if the SKIPREST keyword is not present.
2020-09-29 23:00:16 +02:00
Joakim Hove
1ae7026a4b Merge pull request #1946 from joakim-hove/parsecontext-opm-error
Parsecontext opm error
2020-09-29 22:15:04 +02:00
Håkon Hægland
7db5d2fd5c Added WGLIR to SummaryConfigTests.cpp 2020-09-29 15:52:28 +02:00
Joakim Hove
8e247ca6e8 Use new ParseCOntext signature 2020-09-29 15:37:14 +02:00
Joakim Hove
2a812ab7ce Use OpmInputError 2020-09-29 15:37:14 +02:00
Joakim Hove
a44b174b6b Remove info messages from Schedule 2020-09-29 15:37:14 +02:00
Alf Birger Rustad
a86cfd21d8 Shortened reading line to make more space for path 2020-09-29 15:37:14 +02:00
Joakim Hove
0512ab88b4 ParseContext will throw OpmInputError 2020-09-29 15:37:14 +02:00
Håkon Hægland
ce4f2a157b Fixed typo in operator==() 2020-09-29 15:33:59 +02:00
Håkon Hægland
56ab32035a Added support for ALQ in the serialization.
Added support for ALQ in operator==() and Rates::read().
2020-09-29 15:33:59 +02:00
Håkon Hægland
7a4c5cd1c1 Changed "rate" to "gas_surface_rate" 2020-09-29 15:33:59 +02:00
Håkon Hægland
124097abdc Added FGLIR and GGLIR. 2020-09-29 15:33:59 +02:00
Håkon Hægland
ae6ea4699e Added WGLIR to SummaryConfig.cpp 2020-09-29 15:33:59 +02:00
Håkon Hægland
10a9a5707c Add support for WGLIR.
Add support for summary output of WGLIR (lift gas injection rate).
2020-09-29 15:33:59 +02:00
Williham Williham Totland
6d2f8cca5c Adds type information to integer literals. 2020-09-29 13:54:21 +02:00
Joakim Hove
e01400fa18 Add KeywordLocation argument to ParseContext::handleError() 2020-09-29 09:56:07 +02:00
Joakim Hove
94b4c509b1 Add KeywordLocation argument to UDQ parser 2020-09-29 09:56:07 +02:00
Joakim Hove
e8423d3b25 Merge pull request #1969 from wito/keyword-handler-try-catch
Exception Catch and Release
2020-09-29 09:54:41 +02:00
Joakim Hove
751e25ff97 Merge pull request #1963 from joakim-hove/tran-calc-condense
Tran calc condense
2020-09-29 09:34:28 +02:00
Joakim Hove
a8e3ecef7d Merge pull request #1974 from totto82/fixRocktab
Set number of columns in ROCKTAB to three
2020-09-29 06:57:48 +02:00
Bård Skaflestad
d55d05e552 Merge pull request #1884 from goncalvesmachadoc/outputProdEnergy
Add WEPT and WEPR to Summary
2020-09-28 21:52:53 +02:00
Joakim Hove
8848fde48e Collapse multi record operations on TRAN in one operation
The main content of this commit is that for keywords with multiple TRAN
modifications like

  MULTIPLY
     TRANX 1.50 1 10 1 10 1 1 /
     TRANX 2.50 1 10 1 10 2 2 /
  /

The different operations are collapes to one entry in tran calculator.

This commit also explicitly throws a std::logic_error() exception if TRAN
manipulations are attempted with the OPERATE keyword or one of the region
keywords ADDREG, MULTIREG, EQUALREG or OPERATER.
2020-09-28 21:44:21 +02:00
Tor Harald Sandve
fc7ccd1603 Set number of columns in ROCKTAB to three
Throw if unsuppored directional and stress option is used
2020-09-28 20:54:19 +02:00
Joakim Hove
de61bdefff Merge pull request #1972 from asnyv/rtemp
UNTESTED: Added size: 1 to RTEMP and RTEMPA
2020-09-28 18:32:31 +02:00
Joakim Hove
8e8ba14397 Merge pull request #1973 from bska/uconv-static-tables-size-check
Unit Conversion Tables: Add Size Consistency Checking
2020-09-28 18:14:28 +02:00
Joakim Hove
f331add35b Merge pull request #1966 from joakim-hove/tran-calc-init
Tran calc init
2020-09-28 16:55:07 +02:00
Joakim Hove
5fbf725ea8 Merge pull request #1970 from blattms/make-tran-mod-tests-run
Make transmissibility modifier tests run
2020-09-28 16:54:08 +02:00
Williham Williham Totland
f5a3ab2cee Removes (stated) support for named arguments in OpmInputError::format due to UTR test failure. 2020-09-28 16:04:35 +02:00
Cintia Goncalves Machado
76a04c8e48 rebasing 2020-09-28 15:59:20 +02:00
Bård Skaflestad
b7418b419e Unit Conversion Tables: Add Size Consistency Checking
This commit adds a minimum amount of compile-time size checking for
the various arrays that go into defining the conversion factors and
unit strings.  Using static_assert() we guarantee that the arrays at
least have the expected size lest the translation unit fail to
compile.
2020-09-28 15:37:28 +02:00
Asgeir Nyvoll
74c3bf82fb Added size: 1 to RTEMP and RTEMPA 2020-09-28 14:27:22 +02:00
Bård Skaflestad
8d89d277cd Warn about network nodes without networks. 2020-09-28 14:05:40 +02:00
Joakim Hove
4b8b35e0f0 only warn about unknown summary nodes. 2020-09-28 14:04:39 +02:00
Williham Williham Totland
f76a71cbee Simplifies logging of error using formatException(). 2020-09-28 13:30:15 +02:00
Cintia Goncalves Machado
e23e229fda addCumToSummaryState 2020-09-28 13:21:19 +02:00
Cintia Goncalves Machado
4e3f5cd0ca addWTICHEA 2020-09-28 13:21:19 +02:00
Cintia Goncalves Machado
5032d28a0f addWTPCHEA 2020-09-28 13:21:19 +02:00
Cintia Goncalves Machado
af1043612a addWEIs 2020-09-28 13:21:19 +02:00
Cintia Goncalves Machado
72efad2a8f finalizeSummary 2020-09-28 13:21:19 +02:00
Cintia Goncalves Machado
dd4de4130a addEnergyRatetoUnitSystem 2020-09-28 13:21:19 +02:00
Cintia Goncalves Machado
4a721cffbb addWEPTandWEPRtoSummary 2020-09-28 13:21:18 +02:00
Williham Williham Totland
805300dd49 Adds some documentation to OpmInputError.hpp. 2020-09-28 13:16:45 +02:00
Williham Williham Totland
9a66acbb5d Extends OpmInputError to be initialisable from an existing exception. 2020-09-28 13:16:45 +02:00
Williham Williham Totland
742c90cabc Extends Opm::OpmInputError::OpmInputError() to accept additional format arguments. 2020-09-28 13:16:45 +02:00
Williham Williham Totland
7cb15bd64d Adds missing test_OpmInputError_format.cpp 2020-09-28 13:16:44 +02:00
Williham Williham Totland
2900da4489 Allow Opm::OpmInputError::format() to accept additional arguments.
This removes the need to call `fmt::format()` multiple times on a string, thus eliminating error-prone multi-level escapes when formatting strings.
2020-09-28 13:16:44 +02:00
Williham Williham Totland
05c3d997ac Catches and logs exceptions in Opm::Schedule::handleNormalKeyword() 2020-09-28 13:16:44 +02:00
Joakim Hove
3036441c8c Merge pull request #1967 from joakim-hove/throw-opm-error
Throw opm error
2020-09-28 12:50:36 +02:00
Joakim Hove
a4038b3d9e Wrap SummaryConfig construction in try catch 2020-09-28 11:29:27 +02:00
Joakim Hove
5b6e9f7c92 Wrap Schedule construction in try catch 2020-09-28 09:22:56 +02:00
Joakim Hove
1168e616cd Wrap EclipseState construction in try catch 2020-09-27 23:24:30 +02:00
Joakim Hove
c1ea966548 Add static function OpmInputError::format() 2020-09-27 22:14:53 +02:00
Joakim Hove
8c2ed38cf4 Parse differentiates between OpmInputError and std::exception 2020-09-27 22:00:37 +02:00
Joakim Hove
8e55f3138b Add multi record test 2020-09-27 10:16:32 +02:00
Joakim Hove
d57d9ea18f Utility function for operation dependent SI conversion 2020-09-27 10:16:32 +02:00
Joakim Hove
6de1067c45 Make sure to initialize FieldProps::keyword_info for assignment 2020-09-27 10:16:32 +02:00
Joakim Hove
b95fbc4919 Rewrite test to iterate over cartesian coordinates 2020-09-27 10:16:32 +02:00
Joakim Hove
42c711210e Remove stale struct FieldPropsManager::Meminfo 2020-09-27 10:16:32 +02:00
Joakim Hove
6ee4e5ce9a Merge pull request #1962 from wito/schedule-keyword-cleanup
Various Code Consistency Changes in Schedule.
2020-09-27 10:16:10 +02:00
Joakim Hove
66a9138006 Merge pull request #1965 from joakim-hove/rsm-cmp-eps
Increase the epsilon used for comparing summary and rsm files
2020-09-25 23:28:38 +02:00
Joakim Hove
ac4157a66c Increase the epsilon used for comparing summary and rsm files 2020-09-25 22:08:05 +02:00
Bård Skaflestad
83cfe4b50c Merge pull request #1964 from wito/iterator-reference-fix
Range Variable Correction
2020-09-25 18:22:44 +02:00
Williham Williham Totland
6a8f3e16c0 Corrects range variable to a reference. 2020-09-25 16:20:22 +02:00
Williham Williham Totland
2e8e613722 Makes use of braces consistent within if-else sections. 2020-09-25 15:10:23 +02:00
Williham Williham Totland
e8595a6076 Various whitespace fixes. 2020-09-25 15:07:20 +02:00
Williham Williham Totland
24296bf7ee Extracts variables that depend only on record to the outer loop. 2020-09-25 15:06:08 +02:00
Williham Williham Totland
e0344b828d Consts variables. 2020-09-25 15:06:08 +02:00
Williham Williham Totland
29bfdd00bf Extracts access that depend only on record to the outer loop. 2020-09-25 15:06:08 +02:00
Williham Williham Totland
cd93de5e12 Extracts variables that only depend on record to outer loop. 2020-09-25 15:06:08 +02:00
Williham Williham Totland
ad03a50536 Improves consistency of well_names phrase. 2020-09-25 15:06:08 +02:00
Williham Williham Totland
c19221eab8 Removes temporary variable name. 2020-09-25 15:06:08 +02:00
Williham Williham Totland
fab78873f2 Removes extraneous scope block. 2020-09-25 15:06:08 +02:00
Williham Williham Totland
461d8815a0 Normalises all occurences of size_t to std::size_t 2020-09-25 15:06:08 +02:00
Williham Williham Totland
1de3a84a53 Documents use of the keyword handler dispatcher. 2020-09-25 15:06:08 +02:00
Williham Williham Totland
56e8750d9e Removes extraneous scope blocks. 2020-09-25 15:06:08 +02:00
Williham Williham Totland
51a8d35788 Normalises if and for clause whitespace. 2020-09-25 15:06:08 +02:00
Williham Williham Totland
d5cd8cf78e Removes extraneous scope blocks. 2020-09-25 15:06:08 +02:00
Williham Williham Totland
6d6b10a9fa Normalises indentation and whitespace. 2020-09-25 15:06:08 +02:00
Williham Williham Totland
c17824cead Removes using namespace shortcuts. 2020-09-25 15:06:08 +02:00
Williham Williham Totland
0d962fc585 Removes some unnecessary includes. 2020-09-25 15:06:08 +02:00
Atgeirr Flø Rasmussen
fbe723a874 Merge pull request #1952 from joakim-hove/cir-negative
Cir negative
2020-09-25 14:06:22 +02:00
Joakim Hove
ab68722eca Merge pull request #1960 from wito/schedule-keyword-handlers
Moves keyword handlers from Schedule.cpp to KeywordHandlers.cpp
2020-09-25 13:45:05 +02:00
Joakim Hove
629b561f75 Merge pull request #1957 from totto82/salinity
Add keyword SALINITY with unit molality
2020-09-25 12:28:19 +02:00
Williham Williham Totland
86eb1bf94e Renames handleEXIT to applyEXIT. 2020-09-25 10:12:55 +02:00
Williham Williham Totland
5c49832cd1 Extracts keyword handlers into KeywordHandlers.cpp 2020-09-25 10:02:52 +02:00
Joakim Hove
003537ea77 Merge pull request #1959 from akva2/janitoring
add missing initializer to quell warning
2020-09-25 09:52:52 +02:00
Tor Harald Sandve
dfdb844d69 add SALINITY. Unit is molality [mol/kg] for all unit systems 2020-09-25 09:39:11 +02:00
Arne Morten Kvarving
617440485f remove unused variable 2020-09-25 09:21:09 +02:00
Arne Morten Kvarving
99a6fc30a1 throw to avoid no return value warning 2020-09-25 09:20:57 +02:00
Arne Morten Kvarving
50de318947 add missing initializer to quell warning 2020-09-25 09:18:46 +02:00
Joakim Hove
b6f192b7f2 Merge pull request #1958 from joakim-hove/smry-cmp-verbose
Add error message when comparing summary and rsm files
2020-09-25 08:50:32 +02:00
Joakim Hove
2985072083 Add error message when comparing summary and rsm files 2020-09-24 16:45:59 +02:00
Bård Skaflestad
3db68b0731 Merge pull request #1955 from jalvestad/rstfile-imp-v3t
Handle WSEGITER keyword data and WELSEGS keyword item 6 for Eclipse compatible restart file
2020-09-24 14:49:34 +02:00
Jostein Alvestad
1b488037e1 added / changed comments to well.hpp to clarify their meaning 2020-09-24 14:37:10 +02:00
Joakim Hove
b9f95089b9 Merge pull request #1949 from joakim-hove/error-prepare
Error prepare
2020-09-24 07:33:22 +02:00
Joakim Hove
c7d8d17bf0 Merge pull request #1938 from bska/support-nonmonotone-bo
Support Non-Monotonic Saturated Oil FVF in PVTO
2020-09-24 07:19:45 +02:00
Bård Skaflestad
1dd1b71095 PVTO: Switch to Using {fmt} Backend for Formatting
This commit switches the custom diagnostic message formatting based
on std::ostringstream to using a formatter implemented in terms of
the fmt::format function.  This removes the custom indentation from
earlier.  Note that we output at most four records to the console,
including a message limit notification if applicable, and that this
limit is currently not adjustable by the user.  We do on the other
hand output all flipped records to the .PRT file.

New Example Diagnostic Output:

  * To the Console

    Warning: Non-Monotonic Oil Formation Volume Factor Detected in Keyword PVTO, PVTNUM=1
    In /path/to/PVTO.INCL line 6
    Record  9: FVF 1.234 at RS 123.456 is not greater than FVF 2.345 at RS 121.212
    Record 10: FVF 1.233 at RS 123.457 is not greater than FVF 1.234 at RS 123.456
    Record 11: FVF 1.233 at RS 123.460 is not greater than FVF 1.233 at RS 123.457
    Report limit reached, see PRT-file for additional records.

  * In the PRT File (Unlimited Records)

    Warning: Non-Monotonic Oil Formation Volume Factor Detected in Keyword PVTO, PVTNUM=1
    In /path/to/PVTO.INCL line 6
    Record  9: FVF 1.234 at RS 123.456 is not greater than FVF 2.345 at RS 121.212
    Record 10: FVF 1.233 at RS 123.457 is not greater than FVF 1.234 at RS 123.456
    Record 11: FVF 1.233 at RS 123.460 is not greater than FVF 1.233 at RS 123.457
    Record 12: FVF 1.233 at RS 123.461 is not greater than FVF 1.233 at RS 123.460
    Record 13: FVF 1.233 at RS 123.470 is not greater than FVF 1.233 at RS 123.461

The length of each 'Record' line is 78 characters as of this change
(assuming METRIC conventions, FIELD conventions not tested).  The
length of the 'In ...' line depends on the number of characters in
the full filepath.
2020-09-24 00:43:03 +02:00
Bård Skaflestad
db07a19c68 PVTO: Relax Requirement that Saturated FVF be Strictly Increasing
Such cases do happen in real field models and we should diagnose the
existence of non-increasing BO as a function of RS, but we should
not terminate the simulation run.
2020-09-24 00:43:02 +02:00
Bård Skaflestad
1311afb261 PVTO: Add Means of Identifying Non-Monotonic Saturated FVFs
This commit introduces a way of diagnosing an uncommon but possible
issue in the PVTO table.  If the formation volume factor (BO) in the
saturated table (record 1 of each subtable) does not increase
monotonically as a function of the dissolved gas/oil ratio (RS),
then there is a risk that the simulation run will have convergence
problems.

We add a special purpose member function

    PvtoTable::nonMonotonicSaturatedFVF

which checks for this condition and returns a vector records for
which the condition is true.  The new member function

    TableManager::checkPVTOMonotonicity

then collates these records into a formatted string which is printed
to the console and the .PRT file.

Example Diagnostic Output:

    Warning: Non-Monotonic Oil Formation Volume Factor Detected
      * PVTO [PVTNUM = 1]
        Record  9: FVF 1.23 at RS 123 is not greater than FVF 2.34 at RS 120
        Record 10: FVF 1.22 at RS 125 is not greater than FVF 1.23 at RS 123
        Record 11: FVF 1.21 at RS 125 is not greater than FVF 1.22 at RS 125
2020-09-24 00:43:02 +02:00
Bård Skaflestad
b5b1588a17 PVTXTable: Fix Documentation
In particular, refer to "pvtnum" instead of "satnum".  While here,
also include a number of headers that are needed for idempotency.
2020-09-24 00:43:02 +02:00
Joakim Hove
4114302055 Merge pull request #1954 from akva2/mark_libfmt_system
changed: mark libfmt headers as system to avoid warnings
2020-09-23 23:06:45 +02:00
Joakim Hove
2e20dc5d43 Merge pull request #1923 from totto82/co2storage
Add CO2STOR keyword in Runspec section
2020-09-23 14:36:18 +02:00
Joakim Hove
7d226bf600 Merge pull request #1926 from joakim-hove/udq-in-actionx
Udq in actionx
2020-09-23 14:35:01 +02:00
Arne Morten Kvarving
70d13b7427 changed: mark libfmt headers as system to avoid warnings 2020-09-23 14:05:50 +02:00
Joakim Hove
341d14519b Allow negative injection rates for completions 2020-09-23 13:17:55 +02:00
Arne Morten Kvarving
ef412cd759 added: put a GPMaint instance in Group's serializeObject()
now the serialization is tested.
2020-09-23 13:04:10 +02:00
Jostein Alvestad
dc97e71350 various updates of unit tests 2020-09-23 13:03:21 +02:00
Jostein Alvestad
2efa272f6e removed comments 2020-09-23 13:03:19 +02:00
Jostein Alvestad
e8803220ca added changes to account for WSEGITER parameters to the Ecl-rst-file 2020-09-23 13:03:18 +02:00
Jostein Alvestad
772cc7b265 initial changes to add WSEGITER keyw-data to restart file 2020-09-23 13:03:16 +02:00
Jostein Alvestad
9a2410ddb2 corrections to IWEL for pressure loss model and multiphase model 2020-09-23 13:03:14 +02:00
Joakim Hove
6eb9eb8414 Merge pull request #1950 from joakim-hove/deckoutput-dont-split
Special case output of UDQ and ACTIONX keywords - no split
2020-09-23 12:29:42 +02:00
Joakim Hove
9887cc01af Merge pull request #1882 from bska/add-guiderate-restart
Unconditionally Output Guiderates to Restart File
2020-09-23 12:00:27 +02:00
Joakim Hove
aefa3cd9d2 Support defining new UDQ keywords inside ACTIONX block 2020-09-23 11:30:09 +02:00
Joakim Hove
59b59ce3ee Add location member to Welldims class 2020-09-23 11:06:03 +02:00
Bård Skaflestad
7875aedd7f Required Vectors: Simplify Well/Group Loop Bodies
Pass along the set of category-specific "extra" vectors to
'makeEntities' to avoid repeating the "extra" calls at each of the
well, group, and field levels.
2020-09-22 22:23:05 +02:00
Bård Skaflestad
e57c98d475 Output Guiderate Values to Restart File
This commit ensures that we also always output guiderate values to
the restart file.  Always calculating these summary quantities we
leverage the restart output support added in commit 317d1ba14 (i.e.,
in PR #1792).
2020-09-22 22:23:05 +02:00
Markus Blatt
d60a91c3dd Merge pull request #1932 from blattms/tran-calculator-2
Adds a calculator for modifying transmissibilities.
2020-09-22 19:56:12 +02:00
Joakim Hove
b184b0e9e5 Merge pull request #1942 from joakim-hove/opm-error
Opm error
2020-09-22 18:01:14 +02:00
Tor Harald Sandve
f3e209b740 Add CO2STOR keyword in Runspec section 2020-09-22 14:53:35 +02:00
Joakim Hove
0bbcee1cc8 Merge pull request #1944 from bska/nodepress-summary-output-2
Add Support for 'GPR' (Network Node Pressure) Summary Keyword
2020-09-22 14:44:14 +02:00
Joakim Hove
d300e54700 Special case output of UDQ and ACTIONX keywords - no split 2020-09-22 14:22:06 +02:00
Joakim Hove
719af02142 Add custom exception OpmInputError 2020-09-22 13:48:26 +02:00
Joakim Hove
f604f94e89 Document format placeholders in KeywordLocation 2020-09-22 12:38:09 +02:00
Bård Skaflestad
2d3432a9e0 Summary: Add Support for 'GPR' (Network Node Pressure) Keyword
This commit adds an evaluation function for the GPR summary vector.
We assume that the actual value is calculated elsewhere and passed
in unchanged from the caller of Summary::eval().  We therefore need
only convert the value to output units and hook this procedure up to
the table of known output functions.

Add a simple unit test for demonstration.
2020-09-22 10:08:44 +02:00
Bård Skaflestad
d46628e8a1 Summary Config: Recognize Subset of Node-Level Keywords
This commit adds support for recognizing a small subset of the
summary quantities that are reported at the node level of an
extended network--especially the 'GPR' keyword.

Briefly, we add a new 'Node' config category and a processor for
this category which knows about the distinction between nodes and
groups.  It uses member function ExtNetwork::node_names() to produce
configuration nodes whose named entity is the node rather than a
group.  Deriving this list of node names across all timesteps is
potentially expensive, so perform this operation at most once and
pass the result into the processor from the SummaryConfig
constructor.

Add a simple unit test for demonstration purposes.
2020-09-22 10:08:44 +02:00
Bård Skaflestad
4aab3ca7d0 Parse Context: Add Context for Missing Network Node
Will be used in SummaryConfig for reporting the case of node-level
summary output being requested for unknown/missing network nodes.
2020-09-22 10:08:44 +02:00
Joakim Hove
11d5128cbf Use KeywordLocation instead of passing keyword and filename separately 2020-09-22 09:55:45 +02:00
Joakim Hove
fe2f5ee185 Keep track of maximum size of RawRecord 2020-09-22 09:55:45 +02:00
Joakim Hove
0530b9b1a3 Merge pull request #1943 from wito/schedule-keyword-functions
Schedule Keyword Handler Dispatch
2020-09-22 09:32:47 +02:00
Markus Blatt
57dde8051d Merge pull request #1945 from blattms/fix-fmtlib
Also remove fmtlib from opm-common-prereqs.cmake
2020-09-22 07:53:25 +02:00
Williham Williham Totland
7a7920f3e7 Implements a new dispatcher for keywords in Schedule. 2020-09-21 19:22:11 +02:00
Markus Blatt
396bfbbcd2 Also remove fmtlib from opm-common-prereqs.cmake
Otherwise the user still needs to have an installed version on the system
in addition.
2020-09-21 15:46:01 +02:00
Joakim Hove
ee4ac770af Merge pull request #1941 from joakim-hove/rm-sim-container
Remove unused class SimulationDataContainer
2020-09-21 11:15:36 +02:00
Atgeirr Flø Rasmussen
045f527c5d Merge pull request #1940 from bska/nodepress-summary-output
Prepare for Outputting Network Node Pressure to Summary File
2020-09-21 09:21:59 +02:00
Joakim Hove
79ae4c7935 Remove unused class SimulationDataContainer 2020-09-21 08:18:51 +02:00
Bård Skaflestad
dbfd013cf4 Add Means of Retrieving Node Names from Extended Network
This commit adds a new member function

    ExtNetwork::node_names() const

which collects the names (std::string) of all nodes in a network.
The immediate use case is creating summary config nodes for network
level quantities specified without explicit lists of nodes, e.g.,

    GPR
    /

Add a simple unit test for demonstration.
2020-09-20 17:46:01 +02:00
Bård Skaflestad
6ea0e73512 Prepare for Creating Network-Level Summary Output
This commit adds a level of indirection to the existing group-level
data (active controls and guiderates), and adds a new 'NodeData'
level to the 'data::' protocol for transporting values from the
simulator to the output layer.

Update all call sites and users accordingly.
2020-09-20 17:46:01 +02:00
Markus Blatt
9343165bee Move factored out stuff to FieldProps namespace.
- FieldData
- ScalarOperation
- TranCalculator
- keywords
2020-09-18 16:20:33 +02:00
Joakim Hove
ac40c65f64 Merge pull request #1933 from joakim-hove/throw-same
Rethrow the same exception
2020-09-18 15:28:05 +02:00
Joakim Hove
b8c4a2ed83 Merge pull request #1937 from joakim-hove/embed-fmtlib
Embed fmtlib
2020-09-18 15:26:44 +02:00
Joakim Hove
b09db0325d Use fmtlib for string formatting in opmhash 2020-09-18 11:23:43 +02:00
Joakim Hove
4e5aed45d7 Embed fmtlib source code 2020-09-18 11:23:30 +02:00
Joakim Hove
3004e14e9a Remove use fmtlib package from build system 2020-09-18 11:19:41 +02:00
Joakim Hove
f9d43e738a Merge pull request #1936 from akva2/fix_packaging_libfmt
fix packaging files for libfmt
2020-09-18 10:14:05 +02:00
Arne Morten Kvarving
86d166756a fix packaging files for libfmt 2020-09-18 08:21:13 +02:00
Joakim Hove
f51533907f Merge pull request #1935 from bska/final-runsum-only
Don't Write RSM File for Substeps
2020-09-18 07:22:17 +02:00
Bård Skaflestad
50e4f9439b Don't Write RSM File for Substeps
If the last report step happens to be split into multiple substeps
(e.g., convergence problems or TUNING settings &c), then we will
write the RSM file for each substep which will slow down the
process.  This commit explicitly ensures that we don't output the
RSM file unless it is the last substep of the final report step.
2020-09-18 01:43:20 +02:00
Markus Blatt
951bd69522 Allow access to field data assoicated with TranCalculator.
We need this in opm-simulators where we need to query the
FieldProperties associated with the TranCalculator (e.g. TRANX0). Previously,
this were listed by FieldPropertiesManager::keys() but calling
get_int_field_data with the keyword would raise an exception resulting
in a deadlock.

This commit allows passing true as an additional argument to prevent
this (it gets passed to all functions called). This allows for running
with edited transmissibilities in parallel.
2020-09-17 22:20:36 +02:00
Markus Blatt
98f0b36b21 indclude algoritm header in FieldData.hpp
needed for std::find_first_of.
2020-09-17 20:23:58 +02:00
Joakim Hove
629da97d61 Rethrow the same exception 2020-09-17 18:54:31 +02:00
Markus Blatt
d3d91c2a08 Added ADD modifier for TranCalculator. 2020-09-17 16:40:10 +02:00
Markus Blatt
e6893caa89 Added support for MINVALUE to calculator. 2020-09-17 16:33:31 +02:00
Markus Blatt
7bdf49f15e Fixes MAXVALUE modifyer for transmissibility. 2020-09-17 16:26:06 +02:00
Markus Blatt
5ea65651ac Fix test for MAXVALUE. 2020-09-17 16:02:25 +02:00
Joakim Hove
403fd09e69 Merge pull request #1930 from joakim-hove/fmtlib
Add build dependency on fmtlib
2020-09-17 15:40:39 +02:00
Joakim Hove
9e7c808524 Add libfmt dependencies to package specifications 2020-09-17 15:31:16 +02:00
Joakim Hove
bafdbc35cc Add dependency to header only fmtlib 2020-09-17 14:57:40 +02:00
Markus Blatt
6a81e4bb63 Complete checks for TransCalculator. 2020-09-17 12:54:15 +02:00
Markus Blatt
d83790164d make tran_active non-throwing. 2020-09-17 12:54:15 +02:00
Markus Blatt
3a6cd37db1 Make apply_tran and deserialize_tran accessible as free functions.
In the simulator we are using different datastructures to hold them.
Hence we need to be able to apply and deserialize there.
2020-09-17 12:29:37 +02:00
Markus Blatt
e9be39d666 Add access for int and double FieldData.
This is needed for communication in the simulator. Previously,
that just used the data (std::vector), but the TranCaclulator
also needs the value_status to correctly. Hence this needs
to be communicated, too.
2020-09-17 11:46:17 +02:00
Markus Blatt
967f63479d Move FieldData to its own header for usage from simulator.
We need to refactor to make FieldData accessible from the simulator
for running in parallel with the TranCalculator.
2020-09-17 11:46:17 +02:00
Markus Blatt
1bb4c937a2 Move TranCalculator to its own header.
We need to refactor to make FieldData accessible from the simulator
for running in parallel with the TranCalculator.
2020-09-17 11:46:17 +02:00
Markus Blatt
16b946b199 Move keywords to their own header file.
We need to refactor to make FieldData accessible from the simulator
for running in parallel with the TranCalculator.
2020-09-17 11:46:17 +02:00
Joakim Hove
519e65d32c Add documentation 2020-09-17 11:46:17 +02:00
Joakim Hove
8499c9d1cd Add tran_active() query function 2020-09-17 11:46:17 +02:00
Joakim Hove
4bd9b7212f Add serialization of FieldProps TRAN calculators 2020-09-17 11:46:17 +02:00
Joakim Hove
ecee4a7d36 Adds a calculator for modifying field properties in the edit section.
Previously modifications were applied directly to the field
properties. Unfortunately, for unset TRANX this resulted in
modifying 1.0 even if the simulator is calculating
transmissibilities itself. This was one of the reasons
why we got wrong results (others are in the simulator code).

Now these operations recorded in a calculator which can later be
applied to compressed arrays using apply_tran.
2020-09-17 11:40:56 +02:00
Bård Skaflestad
0935aae02c Merge pull request #1929 from bska/capture-raw-sfunc-vals
Saturation Functions: Add Means of Retrieving Select Function Values
2020-09-17 11:02:22 +02:00
Bård Skaflestad
df1f03e4a8 SatFunc: Add Means of Retrieving Select Function Values
This commit introduces a new helper structure, RawFunctionValues,
which collects unscaled saturation function values that are needed
for vertical scaling of saturation functions using keywords such as

    KRO, KRORG, KRGR, PCW

and their hysteretic and directional counterparts.  We also
introduce a new helper function, getRawFunctionValues, which
extracts those values from the function tables in TableManager.

Add a set of unit tests to exercise the new feature.
2020-09-17 08:33:42 +02:00
Bård Skaflestad
07780a793f Field Props Test: Fix Minor Compiler Warnings
In particular, fix a few instances of "signed vs. unsigned"
comparisons, one "no previous declaration for", and include the
<algorithm> header for std::find().
2020-09-17 08:16:37 +02:00
Bård Skaflestad
7a2350bc3c Merge pull request #1922 from joakim-hove/dynamicstate-update-equal
Dynamicstate update equal
2020-09-17 08:03:29 +02:00
Bård Skaflestad
fb93e08ef0 Merge pull request #1928 from hakonhagland/liftopt_4
Add get method for LIFTOPT item 4.
2020-09-17 08:00:51 +02:00
Bård Skaflestad
60f6c26456 Merge pull request #1924 from joakim-hove/keyword-location
Keyword location
2020-09-16 23:35:09 +02:00
Bård Skaflestad
9765ba9d3f Merge pull request #1927 from joakim-hove/add-timestep
Unconditionally add "TIMESTEP" to SummaryState
2020-09-16 23:24:38 +02:00
Håkon Hægland
672eb6e689 Add get method for LIFTOPT item 4. 2020-09-16 21:20:58 +02:00
Joakim Hove
c334245d08 Unconditionally add "TIMESTEP" to SummaryState 2020-09-16 19:33:04 +02:00
Joakim Hove
0d85293fcc Merge pull request #1925 from akva2/fix_nupcol_serialization
fixed: serialization nupcol in Runspec
2020-09-16 17:12:03 +02:00
Joakim Hove
b61f87ddaa Add message function to KeywordLocation 2020-09-16 15:14:44 +02:00
Arne Morten Kvarving
08df29c991 fixed: serialization nupcol in Runspec
also add it to comparison operator
2020-09-16 14:59:26 +02:00
Joakim Hove
d283f1858f Add keyword member to KeyworLocation 2020-09-16 14:24:06 +02:00
Joakim Hove
bef5a4c27b Renamed class Location -> KeywordLocation 2020-09-16 14:06:54 +02:00
Joakim Hove
a023d4b437 DynamicState::find will return std::optional<std::size_t> 2020-09-16 11:59:03 +02:00
Joakim Hove
e03a97b539 DynamicState::update_equal() will return index of next value 2020-09-16 09:55:09 +02:00
Atgeirr Flø Rasmussen
891fda8e79 Merge pull request #1921 from akva2/implement_node_serialize_object
fixed: implement Node::serializeObject
2020-09-16 09:42:10 +02:00
Joakim Hove
ae8dc1a770 Merge pull request #1920 from totto82/scaleAlq
scaling of the Alq values
2020-09-16 09:27:59 +02:00
Arne Morten Kvarving
37fcfe4379 fixed: implement Node::serializeObject 2020-09-16 08:57:06 +02:00
Tor Harald Sandve
ca2dfc6136 scaling of the Alq values 2020-09-16 07:56:05 +02:00
Bård Skaflestad
867fed3288 Merge pull request #1880 from bska/fix-gr-calc
Refactor Damping Factor Implementation
2020-09-15 15:11:36 +02:00
Bård Skaflestad
245a3aa09e GuideRate: Add Test Case for Revised get() Implementation 2020-09-15 10:15:11 +02:00
Bård Skaflestad
8a87914740 Don't Repeatedly Calculate Same Guiderate Value
Doing so works reduces the impact of the damping factor.
2020-09-15 10:15:10 +02:00
Bård Skaflestad
7649df53a2 GuideRate: Revise Damping Factor Implementation
This commit centralises the way we incorporate damping factors (item
10 of the GUIDERAT keyword) into the calculation of group/well guide
rates.  In particular, we create a structure that manages both the
current and the previous (damped) guiderate values and ensures that
the new guiderate value is

    GR_p = f*GR_p' + (1 - f)*GR_p^{n-1}

with GR_p' denoting the "raw" guiderate value calculated directly
from potential rates at the current timelevel (n).  GR_p^{n-1} is
the damped-and previously used-guiderate value from timelevel n-1.
Finally 'f' denotes the damping factor.  This is the same approach
used previously, but with some small changes to exclude zero-valued
guiderates.

We furthermore remove one of the early returns in GuideRate::get().
There is no need to return the nominated phase's guiderate value if
the model phase rate is very low and doing so produces incorrect
water guiderates for the OPL5 well in the MOD4_GRP test case.
2020-09-15 10:15:10 +02:00
Bård Skaflestad
3080b9c7f6 RateVector: Forward 'eval' Calls to GuideRateModel::Target Overload
Avoids having to repeat the implementation for wells and groups.
2020-09-15 10:15:08 +02:00
Bård Skaflestad
a4d07b5c57 Merge pull request #1918 from joakim-hove/internalize-summary-region
Make sure R__xxx keywords are recognized in Summary writer
2020-09-15 09:08:32 +02:00
Joakim Hove
03f9a73f43 Make sure R__xxx keywords are recognized in Summary writer 2020-09-14 23:05:03 +02:00
Bård Skaflestad
98ec42f472 Merge pull request #1874 from totto82/fixwsaltunit
Fix unit for salt concentration in WSALT
2020-09-14 15:40:48 +02:00
Bård Skaflestad
764149182d Merge pull request #1917 from akva2/janitoring
Some janitoring
2020-09-14 13:26:09 +02:00
Arne Morten Kvarving
518c219838 remove unused variable 2020-09-14 12:23:31 +02:00
Arne Morten Kvarving
80b98934c3 add missing initializers 2020-09-14 12:13:04 +02:00
Arne Morten Kvarving
2c2f848c54 remove unused function 2020-09-14 12:05:34 +02:00
Joakim Hove
5557debd9c Merge pull request #1916 from joakim-hove/summary-config-keywords
Add method SummaryConfig::keywords( pattern )
2020-09-14 10:55:27 +02:00
Joakim Hove
791726398e Fix warning 2020-09-14 09:17:53 +02:00
Joakim Hove
db64c858d1 Add method SummaryConfig::keywords( pattern ) 2020-09-14 09:17:53 +02:00
Tor Harald Sandve
02031a00e6 add salinity to unitSystem 2020-09-14 08:22:21 +02:00
Tor Harald Sandve
32a47bf79a Fix unit for salt concentration in WSALT 2020-09-14 08:22:21 +02:00
Joakim Hove
20a6a522dc Merge pull request #1891 from joakim-hove/summary-region
Add basic support for xxx_REG summary keywords
2020-09-10 09:23:33 +02:00
Joakim Hove
c3f94834c3 Add wildcard matching of keywords in SummaryConfig 2020-09-10 08:23:42 +02:00
Joakim Hove
dad067835c RegionCache object can manage multiple fip regions 2020-09-10 08:23:42 +02:00
Joakim Hove
d5a21427b4 Add fip_region to summary context argument 2020-09-10 08:23:42 +02:00
Joakim Hove
3587c0c6b7 Add fip_region member to SummaryNode 2020-09-10 08:23:42 +02:00
Joakim Hove
5976efa953 Add fip regioin name to summaryconfig node 2020-09-10 08:23:42 +02:00
Bård Skaflestad
53ce21cf9e Merge pull request #1911 from joakim-hove/udq-assign
Udq assign
2020-09-09 23:29:09 +02:00
Bård Skaflestad
d4ae7e706d Merge pull request #1905 from joakim-hove/fp-global2
Enable some support for global keywords
2020-09-09 23:26:51 +02:00
Joakim Hove
03d387c12d Enable global storage for keywords 2020-09-09 21:41:08 +02:00
Joakim Hove
5a060910a3 Differentiate better between UDQ ASSIGN and UDQ DEFINE
A quite typical situation is that a UDQ keyword is first initialized with UDQ
ASSIGN statement, and then subsequently a formula for updates every timestep is
entered with UDQ DEFINE:

  UDQ
     ASSIGN FU_VAR1 0 /
     DEFINE FU_VAR1 FU_VAR1 + 1 /
  /

Then the assign statement should be run once, and the define formula should be
evaluated for every subsequent timestep.
2020-09-09 21:39:29 +02:00
Bård Skaflestad
49460edf39 Merge pull request #1914 from joakim-hove/add-timestep
Add TIMESTEP as context variable in summary eval
2020-09-09 21:19:31 +02:00
Joakim Hove
fc1e245ea4 Add TIMESTEP as context variable in summary eval 2020-09-09 19:42:42 +02:00
Bård Skaflestad
5553b36c7d Merge pull request #1912 from joakim-hove/fmwpa
Add functionality for FMWPA - number of abondoned wells
2020-09-09 18:26:43 +02:00
Joakim Hove
a4d8379687 Support abondoned well keyword FMWPA in Summary 2020-09-09 17:10:53 +02:00
Joakim Hove
943e3a656d Request FMWPA output in test deck 2020-09-09 16:44:57 +02:00
Joakim Hove
8c2d74f348 Change to msim: set rates explicitly to zero for closed wells 2020-09-09 16:44:57 +02:00
Bård Skaflestad
eb5787fd54 Merge pull request #1913 from joakim-hove/first-production
First production
2020-09-09 16:15:58 +02:00
Joakim Hove
2f3ba50ca6 Add boolean flag to indicate whether a well has been an open producer 2020-09-09 15:07:55 +02:00
Joakim Hove
660d5ae3a7 Fix error message 2020-09-09 15:06:51 +02:00
Joakim Hove
c82be02ef8 Merge pull request #1910 from joakim-hove/udq-misc
Udq misc
2020-09-08 11:05:21 +02:00
Joakim Hove
fa70d457f3 Merge pull request #1909 from atgeirr/remove-unused-function
The distribute_toplayer() is unused.
2020-09-08 10:58:56 +02:00
Joakim Hove
4a9ec1403e UDQ: get from an unknown summary variable throws std::out_of_range 2020-09-08 08:23:45 +02:00
Joakim Hove
aeb55ec72e Pass global process parameters as mutable value 2020-09-08 08:23:45 +02:00
Joakim Hove
8d11a04033 Add report_step argument to UDQConfig::eval() 2020-09-08 08:23:45 +02:00
Atgeirr Flø Rasmussen
859182f7f0 The distribute_toplayer() is unused.
Note that there is still a member function of the same name.
2020-09-07 15:51:35 +02:00
Bård Skaflestad
b22304b7ba Merge pull request #1906 from joakim-hove/correct-default
Fieldprops: Correct default
2020-09-06 18:30:46 +02:00
Bård Skaflestad
05dde86f55 Merge pull request #1908 from joakim-hove/udq-fixup
Udq fixup
2020-09-06 18:22:12 +02:00
Joakim Hove
7969dfd721 Fix bug with init/create of FIP keywords 2020-09-05 13:54:17 +02:00
Joakim Hove
42fcb4507f FieldProps::get_global<T> will fill with correct default value 2020-09-05 11:52:22 +02:00
Joakim Hove
0a9babfa9a Move get_global functionality down to FieldProps 2020-09-05 11:52:01 +02:00
Joakim Hove
109a87e4ee Update user_defined regexp to allow '?U_?' 2020-09-05 11:46:41 +02:00
Joakim Hove
1bb96ffed2 Set up default stdout logging for msim simulator 2020-09-05 11:33:03 +02:00
Joakim Hove
c7308381d0 Merge pull request #1907 from joakim-hove/remove-designated
Remove use of designated initializer
2020-09-05 11:32:47 +02:00
Joakim Hove
4d29b2921a Remove use of designated initializer 2020-09-05 10:41:52 +02:00
Joakim Hove
1989eac79d Merge pull request #1900 from joakim-hove/fp-global
Reorganize field properties metadata
2020-09-05 08:46:49 +02:00
Joakim Hove
a765cd26ea Reorganised metadata for field properties 2020-09-04 14:31:40 +02:00
Bård Skaflestad
1b7fab4bd1 Merge pull request #1904 from joakim-hove/box-global-list
Box global list
2020-09-03 23:51:08 +02:00
Joakim Hove
ae049a927f Add accessor method for *all* cells in a Box 2020-09-03 21:12:29 +02:00
Joakim Hove
a5bb313394 Remove unused index member from Box class 2020-09-03 16:49:29 +02:00
Bård Skaflestad
da1c2d3c8b Merge pull request #1903 from joakim-hove/change-default
Changed default value of WSEGITER::MAX_WELL_ITERATIONS
2020-09-03 14:14:23 +02:00
Joakim Hove
c54a57d593 Changed default value of WSEGITER::MAX_WELL_ITERATIONS 2020-09-03 13:11:18 +02:00
Atgeirr Flø Rasmussen
1cdebaef30 Merge pull request #1902 from atgeirr/fix-missing-include
Add missing <string> include.
2020-09-03 11:29:22 +02:00
Atgeirr Flø Rasmussen
873ad61e23 Add missing <string> include. 2020-09-03 10:41:20 +02:00
Bård Skaflestad
f8f5987aff Merge pull request #1901 from akva2/missing_boost_include
fixed: add missing include for boost version
2020-09-03 10:02:07 +02:00
Arne Morten Kvarving
40c2c00d58 fixed: add missing include for boost version 2020-09-03 09:20:49 +02:00
Bård Skaflestad
ae91ede665 Merge pull request #1871 from bska/add-guiderate-summary
Add Guiderate Summary Output
2020-09-03 09:20:36 +02:00
Bård Skaflestad
084aa69641 Add Guiderate Summary Output
This commit adds support for outputting the guiderate summary
vectors

    [GW][OGWV]PGR, [GW][GW]IGR

under the assumption that the values are fully calculated at another
level and that we therefore only need to extract the numerical
values and convert the rate units to output conventions.  We assume
that such values are communicated to the summary output layer by
means of a 'GuideRateValue' object.

The assumption of values already being calculated leads to a small
change in the 'need_wells()' function.  We're now able to exclude
guiderate values at the group level from those vectors that require
setting up a well vector.  This is a (tiny) performance improvement.
2020-09-03 01:04:15 +02:00
Bård Skaflestad
746bb15681 Merge pull request #1887 from joakim-hove/udq-undefined
Udq undefined
2020-09-03 00:50:26 +02:00
Joakim Hove
11e70ca779 Handle undefined UDQ expressions 2020-09-02 23:03:03 +02:00
Bård Skaflestad
a74855f74b Merge pull request #1899 from joakim-hove/serialize-empty-string
Handle empty strings in serializer
2020-09-02 09:37:53 +02:00
Joakim Hove
e99e2c5e82 Handle empty strings in serializer 2020-09-02 07:49:04 +02:00
Bård Skaflestad
015d8ff923 Merge pull request #1898 from akva2/janitoring
Some janitoring
2020-09-01 18:02:01 +02:00
Arne Morten Kvarving
efedbffe63 let compiler deal with copy-ellusion 2020-09-01 15:28:12 +02:00
Arne Morten Kvarving
39db643dd3 quell warning with boost >= 1.71
header was relocated
2020-09-01 15:25:44 +02:00
Arne Morten Kvarving
44f29eb4f7 add explicit copy-constructors
implicitly generated copy constructors are deprecated in C++11,
if the class already has an assignment operator.

quells warnings with modern gcc/clang.
2020-09-01 15:25:44 +02:00
Arne Morten Kvarving
acad356e2d remove unused variable 2020-09-01 15:25:44 +02:00
Joakim Hove
076bc3107b Merge pull request #1896 from joakim-hove/add-udq-state
Add UDQState argument to output writer
2020-09-01 15:07:14 +02:00
Joakim Hove
8b23b572cd Merge pull request #1895 from joakim-hove/serializer
Serializer class
2020-09-01 14:15:52 +02:00
Joakim Hove
3b0e795e0b Add UDQState argument to output writer 2020-09-01 13:18:59 +02:00
Joakim Hove
4b3304730c Serializer class: SummaryState & UDQState 2020-09-01 13:15:42 +02:00
Joakim Hove
432f666768 Merge pull request #1897 from joakim-hove/add-wsegiter
Add wsegiter
2020-09-01 13:11:20 +02:00
Joakim Hove
53f78a02fe Internalize WSEGITER settings in Tuning implementation 2020-08-31 18:24:09 +02:00
Joakim Hove
71ba9ae6fd Remove DynamicState<..> access to Tuning class 2020-08-31 17:25:40 +02:00
Joakim Hove
24b66d8bb4 Merge pull request #1889 from joakim-hove/udq-state
Udq state
2020-08-31 07:35:14 +02:00
Bård Skaflestad
bb8c1f192f Merge pull request #1894 from GitPaean/code_compatibility
rewriting a for loop for intel compilers
2020-08-28 12:29:48 +02:00
Kai Bao
1927e305ed rewriting a for loop for intel compilers 2020-08-28 11:37:04 +02:00
Joakim Hove
0161f50255 Add UDQState 2020-08-27 17:25:51 +02:00
Joakim Hove
8b2363b940 Merge pull request #1885 from joakim-hove/udq-uadd
Correctly parse and handle UADD / UMUL / UMIN / UMAX set operations
2020-08-27 17:11:25 +02:00
Joakim Hove
7894a21749 Merge pull request #1892 from joakim-hove/fp-fipxxx
Allow FIPxxx keywords in FieldProps manager
2020-08-27 17:11:05 +02:00
Joakim Hove
8b718ef0e1 Merge pull request #1890 from joakim-hove/extract-udq-eval
Remove call to udq::eval() from Summary::eval()
2020-08-27 17:09:28 +02:00
Joakim Hove
168aa5602d Make sure DEFINE statements are evaluated in input order 2020-08-27 15:24:32 +02:00
Joakim Hove
718e00ca1f Correctly parse and handle UADD / UMUL / UMIN / UMAX set operations 2020-08-27 15:24:32 +02:00
Joakim Hove
1cf069c837 Merge pull request #1886 from joakim-hove/udq-tokens
Fix UDQ parsing for mix of '*' and *
2020-08-27 15:22:25 +02:00
Joakim Hove
76e8805d92 Merge pull request #1893 from joakim-hove/remove-require-fipnum
Remove function SummaryConfig::requireFIPNUM
2020-08-27 13:56:36 +02:00
Joakim Hove
dee69e78c3 Remove function SummaryConfig::requireFIPNUM 2020-08-27 11:55:17 +02:00
Joakim Hove
e00516842c Allow FIPxxx keywords in FieldProps manager 2020-08-26 08:52:12 +02:00
Joakim Hove
b9ca9c3d47 Remove call to udq::eval() from Summary::eval() 2020-08-25 16:27:46 +02:00
Bård Skaflestad
98c9ce7abd Merge pull request #1888 from joakim-hove/udq-scalar-optional
Use std::optional<double> in UDQScalar
2020-08-24 09:35:13 +02:00
Joakim Hove
9ccc9a72e4 Use std::optional<double> in UDQScalar 2020-08-24 06:59:11 +02:00
Joakim Hove
6c2563c5a5 Fix tokenizer bug with mix of '*' and *
The token '*' should be interpreted as all wells/groups for a variable like WOPR
or GGPR, whereas the naked * is a multiplication sign. This commit fixes a bug
where the all wells/groups token '*' would be incorrectly interpreted as a
multiplication sign.
2020-08-23 08:31:15 +02:00
Joakim Hove
f608487772 Merge pull request #1883 from bska/use-wmctl-rstval
Restart Wells: Use IWEL WMCTL Values as Switch Cases
2020-08-20 15:30:57 +02:00
Bård Skaflestad
af362fa4cf Restart Wells: Use IWEL WMCTL Values as Switch Cases
These are (marginally) easier to understand than their raw integer
values.  While here, also insert the missing 'GRUP' case for
producers.
2020-08-20 13:43:12 +02:00
Bård Skaflestad
a92c8ca6e0 Merge pull request #1870 from jalvestad/group-udq-actx_ph2
Corrections and improvements to Eclipse compatible restart file output
2020-08-19 12:30:01 +02:00
Bård Skaflestad
501db1003d Merge pull request #1876 from joakim-hove/rptrst-solution
Correctly handle RPTRST in SOLUTION section
2020-08-18 11:08:31 +02:00
Jostein Alvestad
b624facaf2 minor corrections of comments 2020-08-18 11:07:57 +02:00
Jostein Alvestad
156c934993 minor comment corrections 2020-08-18 11:07:54 +02:00
Jostein Alvestad
c525546489 correct some logical tests determining IGRP 2020-08-18 11:07:52 +02:00
Joakim Hove
106c0881ee Correctly handle RPTRST in SOLUTION section 2020-08-18 10:48:50 +02:00
Joakim Hove
effe70876f Merge pull request #1879 from berland/weconcmf
Add support for parsing E300 kw WECONCMF
2020-08-18 00:10:34 +02:00
Bård Skaflestad
8e1f8099b2 Merge pull request #1878 from berland/wcutback-fix
Add GLR_LIMIT to WCUTBACK

Fixes #1878
2020-08-17 12:56:45 +02:00
Håvard Berland
b1b04d3dec Add GLR_LIMIT to WCUTBACK, solving bug #1877
Also add dimensions to all relevant fields.
2020-08-17 11:41:19 +02:00
Håvard Berland
ab047eca6a Add support for parsing E300 kw WECONCMF 2020-08-17 11:05:09 +02:00
Joakim Hove
c84b95ed85 Merge pull request #1875 from joakim-hove/tlmixpar
Implement TLMIXPAR as dedicated vector of struct - not table
2020-08-14 12:56:39 +02:00
Joakim Hove
d358d94f58 Merge pull request #1806 from goncalvesmachadoc/salt
finalizeSaltTables
2020-08-14 12:55:49 +02:00
Cintia Goncalves Machado
f8c53e0f9b Merge pull request #2 from joakim-hove/salt
Salt
2020-08-14 09:51:33 +02:00
Joakim Hove
748c3975fb Fix salt table tests 2020-08-13 18:44:04 +02:00
Joakim Hove
66ddbd7842 Remove trailing whitespace 2020-08-13 18:44:04 +02:00
Joakim Hove
1b851f03cb Implement TLMIXPAR as dedicated vector of struct - not table 2020-08-12 14:47:21 +02:00
Markus Blatt
c438c58af3 Merge pull request #1873 from blattms/require-compiled-source
Require test source code to compile and fix test for dune-geometry (>2.7)
2020-08-11 10:34:09 +02:00
Markus Blatt
7c30586fde Only compile code if non-empty code was submitted for DUNE/OPM.
Also make the search fail if the compilation fails.
2020-08-11 00:53:45 +02:00
Markus Blatt
d5388ba653 Fix compile check for dune-geometry from DUNE>2.7
Dune::Geometry::makeQuadrilateral() is deprecated since 2.6 and has recently
been removed. We are using now using Dune::GeometryTypes::quadrilateral
2020-08-11 00:25:23 +02:00
Joakim Hove
a0e20e8d3e Merge pull request #1647 from joakim-hove/json
Add build and write functionality to JsonObject
2020-08-10 15:40:56 +02:00
Joakim Hove
747fd8f897 Add build and write functionality to Json object 2020-08-10 09:41:51 +02:00
Joakim Hove
3b352a5d3b Merge pull request #1866 from joakim-hove/use-std-stringview
Use std stringview
2020-08-05 13:10:28 +02:00
Joakim Hove
3e1411bf87 Replace opm implementation of string_view with std::string_view 2020-08-04 11:40:41 +02:00
Joakim Hove
ffe86d361b Merge pull request #1868 from bska/transport-guiderate-values
Output: Transport Guiderate Values to Output Layer
2020-07-31 08:08:40 +02:00
Bård Skaflestad
f55d0fa57c Output: Transport Guiderate Values to Output Layer
This commit introduces datamembers of type

    Opm::data::GuideRateValue

to the Opm::data::Well and Opm::data::GroupData structures.
Collectively, these datamembers enable transporting guiderate values
calculated elsewhere--e.g., in the opm-simulators module--to the
output layer for final processing and output to the summary and/or
the restart files.

We support outputting both production and injection guiderate values
at the group level.  Guiderate values at the well level are
interpreted as production or injection according to the well type.
2020-07-19 19:07:23 +02:00
Joakim Hove
bdd74b33b2 Merge pull request #1867 from joakim-hove/enable-python
Update PYTHONPATH in enable-python.sh
2020-07-15 13:06:32 +02:00
Joakim Hove
52d69dfd0d Update PYTHONPATH in enable-python.sh 2020-07-15 10:16:21 +02:00
Joakim Hove
349e964586 Merge pull request #1865 from bska/add-copyright
GuideRateValue: Insert Copyright Notice
2020-07-10 18:55:39 +02:00
Bård Skaflestad
32fa286f8e GuideRateValue: Insert Copyright Notice
Missed in commit 4f7d41ee1.

Pointy Hat: [at]bska.
2020-07-10 17:52:38 +02:00
Joakim Hove
52801f1e57 Merge pull request #1859 from bska/add-guiderate-value
Output: Add Container for Transporting Guiderate Values
2020-07-10 13:24:02 +02:00
Bård Skaflestad
4f7d41ee10 Output: Add Container for Transporting Guiderate Values
This commit introduces a container

    Opm::data::GuideRateValue

that packages a 'std::array' and 'std::bitset' into that array.
This container is intended as the main vehicle for transporting
per-phase guiderate values (Oil, Gas, Water, and Resvoir Voidage
Volume supported initially) calculated by the simulator to the
output layer.  We support the serialization operations read and
write in order to plug into the collective communications layer used
in the simulator.

Add unit tests to exercise the new container.
2020-07-09 16:44:15 +02:00
Bård Skaflestad
dc3dd89e09 Merge pull request #1864 from joakim-hove/actionx-wlist
Actionx wlist
2020-07-09 15:57:54 +02:00
Joakim Hove
f500adba24 ACTIONX will handle WLIST well arguments 2020-07-09 15:16:33 +02:00
Joakim Hove
f4f993586a Add method WListManager::wells() which can do WLIST wildcards 2020-07-09 15:12:54 +02:00
Joakim Hove
17c61e1853 Add missing compile guards 2020-07-09 15:12:54 +02:00
Bård Skaflestad
3eab28f9b0 Merge pull request #1863 from joakim-hove/WLIST-updates
Update WLIST to handle WLIST and well pattern arguments
2020-07-09 14:58:31 +02:00
Joakim Hove
d096a5fda6 Update WLIST to handle WLIST and well pattern arguments 2020-07-08 08:12:28 +02:00
Bård Skaflestad
643ff6e777 Merge pull request #1857 from joakim-hove/accept-long-keywords
Fix handling of too long 8 characters keywords like GUIDERATE
2020-07-05 19:58:44 +02:00
Bård Skaflestad
1c92fb3fea Merge pull request #1860 from joakim-hove/add-groupvalues-member
Add data::GroupValues member to RestartValue
2020-07-05 19:26:41 +02:00
Joakim Hove
305b2a166a Add data::GroupValues member to RestartValue 2020-07-03 16:40:42 +02:00
Joakim Hove
1019187a4e Merge pull request #1858 from joakim-hove/igrp-fix-refactor
Igrp fix refactor
2020-07-03 09:08:46 +02:00
Joakim Hove
0321c003eb Merge pull request #1853 from bska/prepare-guiderate-smry
Make Structure for Per-Group Summary Data from Simulator
2020-07-02 21:37:33 +02:00
Joakim Hove
4e223eae4a Fix handling of too long 8 characters keywords like GUIDERATE 2020-07-02 14:23:45 +02:00
Joakim Hove
012c1a2b40 Use named constants to look up in INTEHEAD 2020-07-02 11:40:30 +02:00
Bård Skaflestad
68b4f38464 Make Structure for Per-Group Summary Data from Simulator
This commit adds a level of indirection to the current per-group
summary quantities that is directly assigned by the simulator.  In
particular, introduce a new structure named

    GroupData

that contains a 'GroupConstraints' object and make the per-group
values into 'map<string, GroupData>' rather than the current
'map<string, GroupConstraints>'.  This is in preparation of adding
support for reporting group-level production/injection guiderates
(Gx[IP]GR) to the summary file.

Update tests and APIs accordingly.
2020-07-02 10:57:46 +02:00
Joakim Hove
c7b93797b6 Merge pull request #1852 from joakim-hove/python-wellnames
Add python wrapper for Schedule::wellNames( const std::string& )
2020-07-02 09:50:57 +02:00
Joakim Hove
34bc004171 Merge pull request #1854 from bska/remove-unused-variable
UDQDefine: Suppress 'Unused Variable' Warning
2020-07-02 00:55:22 +02:00
Bård Skaflestad
adf90e3410 UDQDefine: Suppress 'Unused Variable' Warning
Assign 'stod' result to a 'std::ignore' object to maintain the
'token_size' side effect without creating an otherwise unused value
of type 'double'.  While here, also put the 'next_token' helper into
an anonymous namespace to avoid generating warnings of the form

    no previous declaration for ...
2020-07-01 22:49:49 +02:00
Joakim Hove
d6a3cdb986 Merge pull request #1832 from CeetronSolutions/python-pypi-cleanup
Python pypi package work
2020-07-01 13:34:26 +02:00
Joakim Hove
ab821b90a5 Add python wrapper for Schedule::wellNames( const std::string& ) 2020-07-01 11:01:12 +02:00
Joakim Hove
29a946eb9a Merge pull request #1846 from joakim-hove/udq-sign-bug
Udq sign bug
2020-07-01 10:47:04 +02:00
Gaute Lindkvist
f7b080b7b6 Fix remaining double use of python/python and opm/opm folders in Python package generation 2020-07-01 03:25:11 -04:00
Bård Skaflestad
0ad97351c6 Merge pull request #1849 from totto82/addBrineOutput
add brine output
2020-06-30 17:08:07 +02:00
Gaute Lindkvist
c24d7f7798 Remove static python flags from generate-pypi script 2020-06-30 10:55:23 -04:00
Tor Harald Sandve
42e55ec342 Add brine output 2020-06-30 16:19:16 +02:00
Joakim Hove
9fd29db2de Add case with literal in scientific form 2020-06-30 13:04:49 +02:00
Joakim Hove
f09b534e1d Hack around UDQ parser which does not accept leading '-' 2020-06-30 13:01:00 +02:00
Joakim Hove
fc4511d365 Fix UDQParsing code to handle numerical values on scientific form 2020-06-30 12:51:59 +02:00
Bård Skaflestad
89cbb9ae24 Merge pull request #1847 from joakim-hove/use-sumstate-group-function
Use SummaryState::has_group_var() / SummaryState::get_group_var()
2020-06-30 11:46:05 +02:00
Joakim Hove
962b6f8150 Use SummaryState::get_group_var() / SummaryState::has_group_var() II 2020-06-30 11:26:08 +02:00
Joakim Hove
c663805694 Refactored UDQ token split code 2020-06-30 10:35:23 +02:00
Joakim Hove
d30b63508d Quote item in error message 2020-06-30 09:48:23 +02:00
Joakim Hove
8ad0c99c1d Make sure UDQ quote_split does not append empty string 2020-06-30 09:37:42 +02:00
Joakim Hove
7fce7a2c9c Bug in UDQ tokenizer 2020-06-30 08:40:06 +02:00
Bård Skaflestad
0c35431a2f Merge pull request #1844 from joakim-hove/use-sumstate-group-function
Use SumState::has_group_var() / SumState::get_group_var()
2020-06-29 21:09:34 +02:00
Bård Skaflestad
64ae1a8dea Merge pull request #1834 from totto82/addPolymerOutput
Add output for polymer production
2020-06-29 17:06:53 +02:00
Joakim Hove
3e828e8578 Use SummaryState::has_group_var() / SummaryState::get_group_var() 2020-06-29 16:18:37 +02:00
Joakim Hove
eb48fb709a Add SummaryState::get_xxx() overloads with a default argument 2020-06-29 14:14:49 +02:00
Tor Harald Sandve
8c14eac213 add polymer density to the unit system 2020-06-29 13:53:42 +02:00
Bård Skaflestad
a067352ce0 Merge pull request #1843 from joakim-hove/restart-recover-udq
Recover UDQ values from restart file
2020-06-25 16:41:20 +02:00
Joakim Hove
1704a35a92 Recover UDQ values from restart file 2020-06-25 16:18:59 +02:00
Gaute Lindkvist
3acc26558b Use file COPY instead of configure for straight copy in CMakeLists.txt 2020-06-25 09:52:43 -04:00
Gaute Lindkvist
a624d6c690 Remove static python flags from generate-pypi script 2020-06-25 09:26:38 -04:00
Gaute Lindkvist
27fdb0654d Revert "Support building Python module statically"
This reverts commit d3b4f41acf.
2020-06-25 09:26:12 -04:00
Joakim Hove
efc2e7aa92 Merge pull request #1841 from joakim-hove/use-restart-groups
Use Schedule::restart_groups()
2020-06-25 14:19:31 +02:00
Joakim Hove
e65880aafb Use Schedule::restart_groups() 2020-06-25 14:18:19 +02:00
Tor Harald Sandve
13f07fdfef Polymer output
Change polymer production output from volume -> mass
Polymer injection rates are read from the simulator and not computed based on the water rate and the polymer injection concentration given in the schedule
2020-06-25 10:57:11 +02:00
Bård Skaflestad
2876751fe2 Merge pull request #1839 from joakim-hove/eval-udq
Eval udq
2020-06-24 14:15:27 +02:00
Bård Skaflestad
1a0b3b418c Merge pull request #1836 from joakim-hove/restartview
Restartview
2020-06-24 14:13:17 +02:00
Bård Skaflestad
c07aec9c68 Merge pull request #1838 from joakim-hove/schedule-restart-group
Schedule restart group
2020-06-24 13:56:32 +02:00
Joakim Hove
cbe9bf2470 RestartView::hasKeyword: fix when <T> is not present at all 2020-06-24 12:59:43 +02:00
Joakim Hove
f6d160db32 Add convenience method Schedule::restart_groups() 2020-06-24 12:53:09 +02:00
Bård Skaflestad
feaadb4f6f Merge pull request #1837 from joakim-hove/udq-named-constant
Udq named constant
2020-06-24 10:58:09 +02:00
Joakim Hove
633bbb6007 Introduce named constant for UDQ default value in restart files 2020-06-24 01:08:36 +02:00
Joakim Hove
c06708ebd0 Add std::string specialization in RestartView 2020-06-24 01:06:15 +02:00
Joakim Hove
ae5c6fe53e Made eval_udq into method UDQConfig::eval() 2020-06-24 01:05:59 +02:00
Joakim Hove
9ed3f223ea Merge pull request #1840 from joakim-hove/udq-whitespace
Remove trailing whitespace
2020-06-24 01:05:21 +02:00
Joakim Hove
ad023d224b Remove trailing whitespace 2020-06-23 15:55:05 +02:00
Tor Harald Sandve
27e6e0735f Add output for polymer production 2020-06-23 09:57:36 +02:00
Atgeirr Flø Rasmussen
e719812e9b Merge pull request #1833 from bska/disable-debug-output
Group Data: Conditionally Enable Debug Output
2020-06-22 22:17:36 +02:00
Bård Skaflestad
8e9e0b0977 Group Data: Conditionally Enable Debug Output
This commit switches the group control debug output to std::cout
into a conditional mode that is controlled by a file-wide PP symbol

    ENABLE_GCNTL_DEBUG_OUTPUT

that we set to zero here.  This allows the developers to turn on
additional debug output when needed without confusing those who are
not actively working on the feature.
2020-06-22 17:35:42 +02:00
Gaute Lindkvist
474d4a90dc Add more metadata to setup.py for pypi page 2020-06-19 14:56:12 +02:00
Atgeirr Flø Rasmussen
3cda13c7a2 Merge pull request #1831 from akva2/fix_missing_config_h_include
fixed: include config.h for HAVE_OPENMP
2020-06-19 14:55:49 +02:00
Gaute Lindkvist
29bb9f05be Add simple pypi howto 2020-06-19 13:38:55 +02:00
Cintia Goncalves Machado
784abc7069 deleteSolidPhasefromPhases 2020-06-19 13:31:33 +02:00
Joakim Hove
ae28999d5b Merge pull request #1829 from akva2/janitoring
Some janitoring
2020-06-19 13:09:12 +02:00
Arne Morten Kvarving
4bc00663ea fixed: include config.h for HAVE_OPENMP 2020-06-19 12:55:04 +02:00
Arne Morten Kvarving
970d6339dd fixed: forward struct as struct 2020-06-19 11:52:12 +02:00
Arne Morten Kvarving
d7bdb448f5 add some trivial checks to avoid unused variable warnings 2020-06-19 09:43:48 +02:00
Arne Morten Kvarving
841124a47d mark variable maybe_unused to avoid compiler warnings
unused without openmp
2020-06-19 09:43:34 +02:00
Atgeirr Flø Rasmussen
146e5930e2 Merge pull request #1828 from joakim-hove/remove-unused
Remove unused variable
2020-06-19 06:54:51 +02:00
Joakim Hove
216a220ee8 Remove unused variable 2020-06-18 22:34:24 +02:00
Arne Morten Kvarving
29010dd7e3 Merge pull request #1823 from joakim-hove/action-state
Add class Action::State to keep track of ACTIONX count
2020-06-18 19:15:17 +02:00
Joakim Hove
dd1591f1a2 Use Action::State object to keep track of actions being run 2020-06-18 16:45:39 +02:00
Joakim Hove
f54245f1ca Add class Action::State to keep track of ACTIONX count 2020-06-18 16:45:39 +02:00
Joakim Hove
7d856b4933 Add id member to ActionX objects 2020-06-18 16:45:39 +02:00
Gaute Lindkvist
16505b421a Rename package to lowercase 'opm' instead of 'Opm' 2020-06-18 10:32:05 -04:00
Gaute Lindkvist
5515422d02 Add docker files and scripts for creating cross-distro PyPI packages 2020-06-18 10:32:05 -04:00
Bård Skaflestad
2123884655 Merge pull request #1408 from jalvestad/extend_udq_actx_rst
Changes to extend and improve the ECL-compatible restart
2020-06-18 16:29:52 +02:00
Cintia Goncalves Machado
6ab09afb0c fixPermFactTest 2020-06-18 16:23:41 +02:00
Bård Skaflestad
35100cc8bb Merge pull request #1827 from akva2/janitoring
anonymize to quell unused parameter warning
2020-06-18 09:50:08 +02:00
Arne Morten Kvarving
8d3680c7b5 anonymize to quell unused parameter warning 2020-06-18 08:27:48 +02:00
Joakim Hove
986f0acad7 Merge pull request #1826 from akva2/add_missing_initializer
fixed: add missing initializer
2020-06-17 15:44:22 +02:00
Joakim Hove
0edc9acc48 Merge pull request #1825 from joakim-hove/gpmaint-serialize-fix
Fix: bug in serializer function for GPMaint class
2020-06-17 15:29:43 +02:00
Arne Morten Kvarving
643b8b179d fixed: add missing initializer 2020-06-17 14:32:42 +02:00
Joakim Hove
3478263de9 Fix: bug in serializer function for GPMaint class 2020-06-17 12:45:23 +02:00
Gaute Lindkvist
cbd23e71ef Add generation of a setup-package.sh script for creating PyPI-packages 2020-06-16 13:08:33 +02:00
Gaute Lindkvist
9ed75f030b Rename python/python folder to python/opm
This makes bdist_wheel find and add the library binary files.
2020-06-16 13:08:33 +02:00
Gaute Lindkvist
e3bb9a3151 README.md file skeleton for Python package 2020-06-16 13:08:33 +02:00
Gaute Lindkvist
85f8c7b37d Add more metadata to Python setup.py 2020-06-16 13:08:33 +02:00
Gaute Lindkvist
6db3ccf36f Add link flags to Python setup.py 2020-06-16 13:08:33 +02:00
Gaute Lindkvist
f67bce1dd8 Add link directories to Python setup.py 2020-06-16 12:52:34 +02:00
Markus Blatt
8c6cd2f10f Merge pull request #1810 from blattms/support-pinch-nogap
Support querying GAP/NOGAP mode for Pinch form EclipseGrid.
2020-06-15 17:27:15 +02:00
Jostein Alvestad
0679d2b233 corrections to SGRP - index error > 0. 2020-06-15 09:55:46 +02:00
Jostein Alvestad
7d3df69416 Corrected an errors and a misprint 2020-06-15 09:55:44 +02:00
Jostein Alvestad
1751120b79 corrected logic error in AggregateWellData.cpp 2020-06-15 09:55:42 +02:00
Jostein Alvestad
c846716044 add variable to hold min value of nonzero uda 2020-06-15 09:55:40 +02:00
Jostein Alvestad
fea794ee17 further corrections of unit tests and code clean up 2020-06-15 09:55:38 +02:00
Jostein Alvestad
862b7b7591 clean up code - correct unit tests 2020-06-15 09:55:36 +02:00
Jostein Alvestad
ec976db684 correction for lift quantity well-data
corrections to IUAD and IUAP

various improvements of E100 compatible restart file

add debug output

additonal debug print

corrected loop placement for active prod/inj wells

remove debug print and clean up code
2020-06-15 09:55:34 +02:00
Joakim Hove
985cb279ff Allow negative rates when evaluating UDA values
corrections to iwel[10] open/shut flag

further corrections SWEL for handling udq-restarts correctly

further changes to get correct SWEL in ECL-Restart file

added comment to clarify change

correction to group sequence and group controls for EclRST-file

changes to correct IGRP[NWGMAX+5]

corrected compile errors/warnings

further minor code corrections

initial changes to include group current Prod/inj Constraint in summary file

further changes to currentsStatusGroupControl to Summary output

further corrections and additions of Field current controls

further corrections for IGRP

minor corrections to code style

corrections for tests

changes to correct test_AggregateWellData

a few more initial changes for next version of igrp/sgrp

changes to igrp & sgrp according to tests

changes to handle special conditions at report step 0

corrections due to changes in Summary.cpp

changes to improve code quality and robustness

Add default value to igrp[nwgmax+5]

corrections and code improvements base on testing

corrections to handling of GCONINJE

further corrections for IGRP

even further corrections IGRP

changes to correct SGRP

correction to IGRP defaults

corrections to SWEL and IGRP

further corrections for IGRP

removed some comments
2020-06-15 09:55:27 +02:00
Bård Skaflestad
88414fd1fc Merge pull request #1822 from joakim-hove/use-hours
Use 'HOURS' as time unit in LAB unit summary files
2020-06-13 12:27:01 +02:00
Joakim Hove
1dc3a67cf1 Use 'HOURS' as time unit in LAB unit summary files 2020-06-13 07:46:47 +02:00
Joakim Hove
84aa2f77f3 Merge pull request #1820 from joakim-hove/udq-nan-values
UDQSet will check for nan values
2020-06-12 13:49:24 +02:00
Joakim Hove
0841e4f398 Merge pull request #1797 from joakim-hove/GPMAINT
Add code to internalize GPMAINT keyword in Group objects
2020-06-12 12:19:20 +02:00
Joakim Hove
10b2b2ac48 Add caching of well and group names in SummaryState 2020-06-12 12:07:04 +02:00
Joakim Hove
082820380d Ensure that all values in UDQSet are finite 2020-06-12 09:12:55 +02:00
Joakim Hove
213c6fb6ad Add function SummaryState::update_udq() to add variables from UDQSet 2020-06-12 09:12:55 +02:00
Joakim Hove
90d1d992e5 Ensure that evaluated UDQSet have the correct name 2020-06-12 09:12:55 +02:00
Joakim Hove
172c0b1aa6 Make sure invalid UDQ values are deleted from SummaryState 2020-06-12 09:12:55 +02:00
Joakim Hove
669918547a Add del() method to SummaryState 2020-06-12 09:12:55 +02:00
Joakim Hove
b07bd377cd Merge pull request #1819 from joakim-hove/aicd
Aicd
2020-06-12 09:12:18 +02:00
Atgeirr Flø Rasmussen
e08a3666e3 Merge pull request #1818 from atgeirr/fix-nupcol-runspec
Handle NUPCOL in RUNSPEC correctly
2020-06-11 20:50:30 +02:00
Bård Skaflestad
be57558804 Merge pull request #1630 from bska/new-rst-tags
New Solution Vector Tag for Restart File Output
2020-06-11 17:09:42 +02:00
Bård Skaflestad
a4a04ebf51 Restart Tag System: Introduce Tag for OPM Extended Vectors
This is intended to supersede the RESTART_AUXILIARY tag.  There is
no practical difference between vectors that are needed for restart
and vectors that are not needed for restart.  They all go into the
SOLUTION section of a restart file.

Vectors tagged as RESTART_OPM_EXTENDED will not be output unless the
user does requests OPM-extended restart files.
2020-06-11 14:31:53 +02:00
Bård Skaflestad
4fcd85526a Solution Output: Refactor Stages Out to Helper Functions
Mostly to reduce the level of complexity of the 'writeSolution'
function.  While here, also ensure that we never write solution data
outside the STARTSOL/ENDSOL demarcations.  Even if we emit vectors
that are not known to ECLIPSE, we should not write them outside of
the SOLUTION section.
2020-06-11 14:31:53 +02:00
Joakim Hove
224911bd10 Add implementation for autonomous ICD: AutoICD 2020-06-11 11:38:29 +02:00
Joakim Hove
73a244ceda Templated internalizing of WSEGSICD keyword 2020-06-11 11:38:29 +02:00
Joakim Hove
4c100d0bd5 Update json scheme to ensure that WSEGSICD is subset of WSEGAICD 2020-06-11 11:38:29 +02:00
Joakim Hove
0f032d6fca Merge pull request #1801 from joakim-hove/icd-variant
Use std::variant<> to hold ICD alternatives
2020-06-11 11:31:58 +02:00
Joakim Hove
6090470045 Add code to internalize GPMAINT keyword in Group objects 2020-06-11 09:40:55 +02:00
Atgeirr Flø Rasmussen
0c6d1c31d7 Implement and use Runspec::nupcol(). 2020-06-11 07:44:49 +02:00
Bård Skaflestad
9396d44379 Merge pull request #1770 from bska/add-tolcrit
Add Support for TOLCRIT to Sat-Func Field Properties
2020-06-10 19:19:07 +02:00
Joakim Hove
dae980ddd5 Hide away templated convert function 2020-06-10 16:36:33 +02:00
Bård Skaflestad
f61882ce69 Critical Saturation: Refactor Helper Functions
In particular, add two new helper functions

    crit_sat_increasing_KR
    crit_sat_decreasing_KR

which identify the critical saturations under the assumption of a
relative permeability curve that increases viz decreases as a
function of the specified phase saturation.  Those helpers in turn
call a wrapper around std::lower_bound() and std::distance() to
affect the actual table scan.

Reimplement the 'critical_*()' helper functions in terms of
crit_sat_*_KR() to remove duplicated logic.
2020-06-10 14:33:01 +02:00
Bård Skaflestad
abec96a387 Sat-Func Initializers: Add TOLCRIT Support
This commit makes the 'critical_*()' helper functions aware of the
TOLCRIT feature.  We now consider a phase to be immobile at a one
saturation value if its relative permeability at that saturation is
less than or equal to TOLCRIT.  TOLCRIT mirrors E100's default value
of 1.0e-6 unless otherwise specified in the PROPS section.

All table scanners are implemented in terms of the expression

    std::lower_bound(begin, end, tolcrit, predicate)

which ultimately returns the first position in [begin, end) for
which

    predicate(*iter, tolcrit)

is false.  Using predicate = std::greater<>{} thus determines the
first position in the sequence for which the elements is less than
or equal to 'tolcrit'.  Similarly, a predicate equivalent to '<='
returns the first position for which the elements is strictly
greater than 'tolcrit'.

Add a set of unit tests to demonstrate and exercise the new feature.
2020-06-10 14:33:01 +02:00
Bård Skaflestad
bcdc8bb119 Table Output: Revise TOLCRIT Interpretation
This commit switches the previous interpretation of notionally zero
relative permeability in Flow's .INIT-file output.  We now treat all
relative permeability values less than *or equal to* TOLCRIT as
zero.

This change is for increased ECLIPSE compatibility.
2020-06-10 14:33:01 +02:00
Bård Skaflestad
83429bf908 Sat-Func Initializers: Pass TOLCRIT to Table-Scanning Layer
This is a pure API change.  The TOLCRIT value is not yet used as
part of determining the critical saturations.

While here, also add a unit test for getRawTableEndPoints() and
update the existing sat-func property unit tests to explicitly pass
TOLCRIT = 0 in preparation of adding actual TOLCRIT support.
2020-06-10 14:33:01 +02:00
Bård Skaflestad
83af852efe Capture SatFunc Controls In FieldProps
This is in preparation of threading the TOLCRIT value-defaulted or
not-through to the end-point scanning code.
2020-06-10 14:33:01 +02:00
Bård Skaflestad
f0f3764b89 Sat-Func Initializers: Expose RawTableEndPoints to Caller
This commit requires that the callers of satfunc::init() calculate
the raw table end-points.  That, in turn, enables callers to cache
those end-point values to avoid repeated calculations.

Add a new member, m_rtep, to FieldProps to act as such a cache to
take advantage of the new ability.
2020-06-10 14:33:01 +02:00
Gaute Lindkvist
d3b4f41acf Support building Python module statically 2020-06-10 14:30:38 +02:00
Gaute Lindkvist
a2d52dcc0b Add versioning to python/setup.py 2020-06-10 14:30:38 +02:00
Gaute Lindkvist
2f6d4a8f84 Improve string comparison in install.py to remove warning 2020-06-10 14:08:38 +02:00
Atgeirr Flø Rasmussen
80f6a5d1ed Add failing test for NUPCOL in RUNSPEC. 2020-06-10 13:17:04 +02:00
Bård Skaflestad
6a742a20fd Merge pull request #1705 from GitPaean/segment_keywords_regreesion_test
attempting to adding segment summary keywords for regression test
2020-06-10 12:40:41 +02:00
Joakim Hove
8320b89d90 Merge pull request #1817 from akva2/disable_warnings_flag
add a cmake flag to disable warnings
2020-06-10 11:13:06 +02:00
Kai Bao
405e3e1add attempting to adding segment summary keywords for regression test 2020-06-10 10:39:45 +02:00
Joakim Hove
afd5c3153a Use value based semantics for Segment -> valve 2020-06-10 06:35:03 +02:00
Joakim Hove
b1250c2f7a Use std::variant<> to hold ICD alternatives 2020-06-10 06:35:03 +02:00
Arne Morten Kvarving
64cbbdde65 add a cmake flag to disable warnings 2020-06-09 15:11:44 +02:00
Joakim Hove
b73f4aa5dc Merge pull request #1811 from joakim-hove/rst-segment-connection-refactor
Reshuffle segments and connections after restart
2020-06-09 07:08:37 +02:00
Joakim Hove
9faa824258 Merge pull request #1814 from OPM/fix/include-required-header
[parser] include required header
2020-06-09 07:04:56 +02:00
Joakim Hove
630a4a85ec Merge pull request #1816 from bska/empty-default-udq-ustr
SMSPEC: Emit Empty Unit String if UDQ Unit Undefined
2020-06-09 07:04:00 +02:00
Bård Skaflestad
adcb9c54b8 SMSPEC: Emit Empty Unit String if UDQ Unit Undefined
This is guided by ECLIPSE.
2020-06-08 23:19:26 +02:00
Bård Skaflestad
e129f74304 Merge pull request #1815 from tskille/issue_with_esmry
fixing invalid write in src/opm/io/eclipse/ESmry.cpp
2020-06-08 22:17:35 +02:00
Torbjørn Skille
947d3fec99 fixing invalid write in src/opm/io/eclipse/ESmry.cpp 2020-06-08 20:33:10 +02:00
Bernd Flemisch
27e310d436 [parser] include required header 2020-06-08 15:23:52 +02:00
Atgeirr Flø Rasmussen
229a619a85 Merge pull request #1812 from akva2/move_timestamp
changed: move build timestamp to separate header
2020-06-08 12:52:19 +02:00
Arne Morten Kvarving
1d3843cef1 changed: move build timestamp to separate header
to avoid rebuilds for things only needing project versions
2020-06-08 10:06:03 +02:00
Joakim Hove
7a88808ccb Add Segment::updateValve() overload which does not take length arg 2020-06-07 09:09:26 +02:00
Joakim Hove
31b6baa676 Reshuffle segments and connections after restart 2020-06-07 09:09:15 +02:00
Joakim Hove
0daac0b9e3 Merge pull request #1804 from joakim-hove/segment-perf-length
Segment perf length
2020-06-05 11:05:24 +02:00
Joakim Hove
5b51c57a5e Update SpiralICD scaling factor during initialization 2020-06-05 08:00:53 +02:00
Joakim Hove
bf3f8e1b08 Merge pull request #1809 from joakim-hove/refactor-compsegs
Refactor COMPSEGS handling
2020-06-04 22:58:01 +02:00
Markus Blatt
23dd41ba38 Support querying GAP/NOGAP mode for Pinch form EclipseGrid.
While we currently only support GAP and do not need this,
we will need it eventually to support NOGAP in the simulator.
2020-06-04 20:19:51 +02:00
Joakim Hove
6b468787c8 Refactor COMPSEGS handling
When handling the COMPSEGS keyword the connections are updated with segment
number and the segments are updated with total perforated length. The new
Compsegs::processCOMPSEGS() function will create new updated copies of both
WellSegments and WellConnections.
2020-06-04 16:57:40 +02:00
Joakim Hove
5b0045d4a5 Merge pull request #1808 from joakim-hove/sicd-refactor-step0
Sicd refactor step0
2020-06-04 15:58:08 +02:00
Joakim Hove
6e60ebfc74 Merge pull request #1807 from akva2/fix_invalid_deref
fixed: reorder logging and update call
2020-06-04 14:50:53 +02:00
Arne Morten Kvarving
c620d392d2 fixed: reorder logging and update call
the update call can invalidate the reference since the underlying
smart pointer is replaced, and when there are no remaining references,
it is deleted.
2020-06-04 13:16:18 +02:00
Cintia Goncalves Machado
628afd7abe finalizeSaltTables 2020-06-04 11:43:59 +02:00
Joakim Hove
1b2fc9a7fa Add new function to calculate total perforated length for segment 2020-06-03 08:28:53 +02:00
Joakim Hove
dcec08767d Add member perf_length to Segment class 2020-06-03 08:28:53 +02:00
Joakim Hove
7b33ab4519 Merge pull request #1805 from hakonhagland/glift_setters
Added some getters for LIFTOPT.
2020-06-02 11:00:54 +02:00
Håkon Hægland
f7d2631a57 Added const keyword to getters.
The access method should be marked as const so to make the compiler
aware that they should not modify the state of the object.
2020-06-02 09:20:54 +02:00
Håkon Hægland
c6d49a4b44 Added some getters for LIFTOPT.
Added getters for gaslift_increment() and min_eco_gradient() in
the Opm::GasLiftOpt class.
2020-06-02 07:21:01 +02:00
Bård Skaflestad
475dde4bb1 Merge pull request #1803 from joakim-hove/all-shut-message
All shut message
2020-06-01 23:37:17 +02:00
Joakim Hove
998b555662 Move message "All connections shut -> shut well" 2020-06-01 20:02:06 +02:00
Joakim Hove
80bd81c892 Remove commented out code 2020-06-01 08:59:38 +02:00
Bård Skaflestad
f7b2bb4a07 Merge pull request #1802 from atgeirr/clang-is-not-gcc
Ensure clang uses the normal standard headers.
2020-05-29 16:26:20 +02:00
Atgeirr Flø Rasmussen
937747323d Ensure clang uses the normal standard headers.
Clang defines __GNUC__ to 4, as that represents its level of
support for the GNU C dialect. The gcc compiler does not provide
a macro indicating the compiler separately from the dialect supported.
We must therefore use the __clang__ macro to avoid false positives.
2020-05-29 14:31:37 +02:00
Atgeirr Flø Rasmussen
1a1bb29a13 Merge pull request #1800 from atgeirr/bump-version
Bump version number
2020-05-29 13:34:28 +02:00
Joakim Hove
ccf3f150f2 Merge pull request #1798 from joakim-hove/aicd
Rename SpiralICD -> SICD
2020-05-29 07:24:38 +02:00
Joakim Hove
4fbfe3b8ec Merge pull request #1799 from joakim-hove/halvor_opm_restart
Halvor opm restart
2020-05-28 17:41:59 +02:00
Atgeirr Flø Rasmussen
f783282f49 Bump version number 2020-05-28 16:50:26 +02:00
Joakim Hove
4e7ac10320 Explicitly mark const overload in Python binding 2020-05-28 16:21:14 +02:00
hnil
7db2cc0c2e add new function to make input and output definitions uniform for example for forward runs 2020-05-28 16:08:34 +02:00
hnil
2c04ada035 added unification of inputoutput 2020-05-28 16:08:34 +02:00
hnil
e3d39a8b64 changes to be able to set request for restart. Also change the parallel restart to read uniform output 2020-05-28 16:08:34 +02:00
Markus Blatt
0352258f22 Merge pull request #1796 from blattms/require-disabled-packages
Send error for required but disabled packages.
2020-05-28 11:48:01 +02:00
Joakim Hove
7df0577a58 Rename SpiralICD -> SICD 2020-05-28 11:03:24 +02:00
Bård Skaflestad
49e2099436 Merge pull request #1795 from bska/thp-restart-support
Add Restart I/O Support for Well's THP
2020-05-20 15:07:56 +02:00
Markus Blatt
9452796c57 Send error for required but disabled packages.
When using CMAKE_DISABLE_FIND_PACKAGE_<name>=ON for a required package
CMake did not issue an errors since we never trigger the find_package
call. With this commit we now check whether such package is required
and send an error.
2020-05-20 14:55:52 +02:00
Bård Skaflestad
c71ffd1415 Add Restart I/O Support for Well's THP
This commit adds support for saving and restoring a well's THP
quantitiy.  We put the THP into the summary facility's list of
"required restart quantities" and pick up the value converted to
output units from the SummaryState.

On restart we restore the THP value to internal (SI) units and
transport the value to the simulator in data::Well::thp.  While
here, also add the THP value to the RstWell object although
currently not strictly needed in that context.
2020-05-19 22:20:55 +02:00
Bård Skaflestad
88f8313568 Merge pull request #1793 from OPM/fix/add-missing-includes
add some missing includes
2020-05-19 21:35:57 +02:00
Bård Skaflestad
7194463033 Merge pull request #1794 from OPM/fix/designated-initializer
avoid designated initializer error
2020-05-19 21:34:44 +02:00
Bernd Flemisch
283da4d2b6 [test] avoid designated initializer error 2020-05-19 13:03:45 +02:00
Bernd Flemisch
54f08156ad add some missing includes 2020-05-19 12:59:22 +02:00
Bård Skaflestad
0d9eda9b76 Merge pull request #1792 from bska/restart-guiderate-locations
Restart: Prepare to Output Well/Group Guide Rates
2020-05-18 23:43:11 +02:00
Bård Skaflestad
317d1ba14e Restart: Prepare to Output Well/Group Guide Rates
This commit identifies vector items in XWEL and XGRP that hold guide
rate values at the well and group levels, and adds functionality to
output those values to the restart file.  We do not identify such
value at the FIELD level.  As with other summary-like quantities, we
expect to pick up the fully converted values from a SummaryState
object.

Calculating and storing the guide rate quantities in SummaryState is
the subject of future work.
2020-05-18 21:56:57 +02:00
Joakim Hove
598f0e9056 Merge pull request #1791 from joakim-hove/group-index-offset
Fix group number used in IUAP restart array
2020-05-18 17:37:52 +02:00
Bård Skaflestad
6f45df5e93 Merge pull request #1790 from joakim-hove/network-vfp0
When defining branch properties: vfp == 0 should delete branch
2020-05-16 00:46:58 +02:00
Joakim Hove
0aa5fd9f09 Fix group number used in IUAP restart array 2020-05-15 16:26:57 +02:00
Bård Skaflestad
5560f43a8c Merge pull request #1782 from hnil/abs_convergence
changed rootfinders to return also when absolute tolerance is less th…
2020-05-15 15:19:33 +02:00
Joakim Hove
66acfb5249 When defining branch properties: vfp == 0 should delete branch 2020-05-15 14:21:44 +02:00
Joakim Hove
d1babffa8b Merge pull request #1789 from joakim-hove/udqactive-gconprod
Make sure the UDQ usage in GCONPROD is recorded
2020-05-15 13:17:02 +02:00
hnil
47df32ef1a fixed the tolerance also in RegulaFalsiBisection 2020-05-15 08:55:38 +02:00
Joakim Hove
fd5a42801f Make sure the UDQ usage in GCONPROD is recorded 2020-05-15 08:27:52 +02:00
Atgeirr Flø Rasmussen
7cff27c801 Merge pull request #1788 from atgeirr/fix-missing-openmp
Let make_lodsmry also work without OpenMP.
2020-05-14 19:11:51 +02:00
Atgeirr Flø Rasmussen
28f3df5259 Let make_lodsmry also work without OpenMP. 2020-05-14 16:58:51 +02:00
Bård Skaflestad
162e0b53cd Merge pull request #1787 from atgeirr/add-missing-include
Add missing <array> include.
2020-05-14 15:43:45 +02:00
Atgeirr Flø Rasmussen
1593df2a32 Add missing <array> include. 2020-05-14 13:45:46 +02:00
Bård Skaflestad
3a8ea856bc Merge pull request #1785 from tskille/lod_esmry
Lod esmry
2020-05-14 10:55:19 +02:00
Torbjørn Skille
c430eeb374 Adding support for LODSMRY file
> implemented for unified and multiple, and for formatted and binary summary files
 > avaliable/used only when loadBaserun is false (default)
2020-05-14 07:39:23 +02:00
Torbjørn Skille
9766e0ebb3 using file handling functions from stdio.h for lod in ESmry
> improved read efficiency compared with fstream routines

Also fixed bug with lod for formatted unified summary when number of vectors larger than max block size
2020-05-11 21:39:57 +02:00
Bård Skaflestad
0756cd93ad Merge pull request #1783 from joakim-hove/fp-operate-maxlim
Fp operate maxlim
2020-05-11 21:21:55 +02:00
Bård Skaflestad
355fb2aabb Merge pull request #1784 from joakim-hove/guderate-def-init
Initialize group production guide_rate to Target::NONE
2020-05-11 19:04:40 +02:00
Joakim Hove
ebdffa2abb Ensure correct SI conversion for the scalar data in OPERATE keyword 2020-05-11 15:45:01 +02:00
Joakim Hove
ce368bb850 Initialize groups GuideRate target to NONE 2020-05-11 12:53:37 +02:00
Joakim Hove
9065bf2390 Remove dummy/unit dimension for NTG 2020-05-11 12:15:09 +02:00
hnil
ded8ef1a66 changed rootfinders to return also when absolute tolerance is less than prescribed, not only when function value is less than tolerance. 2020-05-10 22:32:01 +02:00
Joakim Hove
55620ac254 Merge pull request #1781 from joakim-hove/gtnode-bug
Bug: pointer -> to stack variable - fix with parent *name*
2020-05-08 09:20:52 +02:00
Joakim Hove
64fb589ec6 Use string based parent *name* in GTNode instead of pointer 2020-05-07 20:08:39 +02:00
Joakim Hove
310bd82b8b Merge pull request #1778 from joakim-hove/gas-lift-opt
Internalize keywords for Gas Lift Optimization
2020-05-07 20:07:58 +02:00
Joakim Hove
e05e6f83ea Merge pull request #1772 from atgeirr/fix-starttime-actionx
Fix start-time of ACTIONX actions.
2020-05-07 18:38:26 +02:00
Joakim Hove
18cd60cd86 Merge pull request #1780 from berland/solvdirs-size
Add size to SOLVDIRS json
2020-05-07 16:33:23 +02:00
Joakim Hove
7fe89422e2 Internalize keywords for gas lift optimization 2020-05-07 16:29:42 +02:00
Håvard Berland
8346941b92 Add size to SOLVDIRS json 2020-05-07 15:35:49 +02:00
Joakim Hove
b311cef875 Merge pull request #1776 from joakim-hove/zwel-fix
Make sure the action name is only added to ZWEL when it is true
2020-05-07 11:04:18 +02:00
Bård Skaflestad
3065218e6d Merge pull request #1779 from joakim-hove/fixup-network
Fix: integrate ExtNetwork instance in Schedule serialization
2020-05-07 09:56:00 +02:00
Joakim Hove
ea14bf2298 Fix: integrate ExtNetwork instance in Schedule serialization 2020-05-06 21:10:52 +02:00
Joakim Hove
3c879dd5dc ActionResult will not access wells if overall false 2020-05-06 12:48:38 +02:00
Joakim Hove
dc9ba1dc56 Minor white space cleanup 2020-05-05 19:13:32 +02:00
Joakim Hove
c073ad2d8b Make sure Action result is checked before wells are considered 2020-05-05 19:03:22 +02:00
Joakim Hove
352cc5797b Make sure the action name is only added to ZWEL when it is true 2020-05-05 18:00:29 +02:00
Bård Skaflestad
26cdff10fc Merge pull request #1775 from totto82/fixSolvent
Allow for mixing of SOF2 from familiy 2 and family 1 for 3p + solvent
2020-05-05 15:14:44 +02:00
Tor Harald Sandve
c73c83d317 Allow for mixing of SOF2 from familiy 2 and family 1 for 3p solvent models 2020-05-05 11:52:30 +02:00
Atgeirr Flø Rasmussen
5e985cfaf3 Fix start-time of ACTIONX actions. 2020-05-05 10:09:09 +02:00
Joakim Hove
94ab966c1b Merge pull request #1774 from atgeirr/fix-actionx-testcase
Remove group list in test file
2020-05-05 09:11:44 +02:00
Atgeirr Flø Rasmussen
3cb39f8bd4 We do not handle lists of groups.
Addressed by removing such a list (replace with the single
group matching pattern) in a test case.
2020-05-05 08:28:10 +02:00
Joakim Hove
f8e7c4eee0 Merge pull request #1773 from joakim-hove/group-level-report
Group level report
2020-05-04 21:46:53 +02:00
Williham Williham Totland
5e981cc74b Corrects all_nodes implementation. 2020-05-04 18:29:48 +02:00
Williham Williham Totland
54ced2e368 Implements Group Level report. 2020-05-04 18:29:48 +02:00
Williham Williham Totland
8af0d505cf Implements GTNode::level and GTNode::all_nodes. 2020-05-04 18:29:08 +02:00
Joakim Hove
c22a7e5b46 Merge pull request #1765 from wito/group-hierarchy-report
Implementing Group Hierarchy Report
2020-05-04 18:27:33 +02:00
Joakim Hove
44af497f8a Merge pull request #1771 from joakim-hove/welspecs-report-refactor
Use proper Connection::perf_range() when creating WELSPECS MSW report
2020-05-04 12:19:23 +02:00
Joakim Hove
c8e81f32fb Merge pull request #1763 from joakim-hove/weltarg-uda
Weltarg uda
2020-05-04 11:54:19 +02:00
Joakim Hove
afc7f5d2f2 Use proper Connection::perf_range() when creating WELSPECS MSW report 2020-05-04 10:46:32 +02:00
Joakim Hove
9b370dcad1 Merge pull request #1739 from wito/welspecs-report-refactor
Add Unit System awareness to WELSPECS reports
2020-05-04 10:46:20 +02:00
Joakim Hove
35dc429aa4 Sort IUAD output vectr on UDQ input index 2020-05-04 10:23:16 +02:00
Joakim Hove
5c2a8b9fc4 Update UDQActive when UDA is used in WELTARG 2020-05-04 10:23:00 +02:00
Joakim Hove
9a4c8f754e Change type of new value argument in WELTARG to UDA 2020-05-04 08:29:34 +02:00
Håvard Berland
f6318ee271 WELTARG keyword can have UDA-data in E100 2020-05-04 08:29:34 +02:00
Joakim Hove
ef77be1508 Refactor ScheduleTests to use fixture function 2020-05-04 08:29:34 +02:00
Joakim Hove
4fa0c93ff7 Merge pull request #1759 from joakim-hove/rename-segdist
Connection - Segment interaction implemented with optional pair
2020-05-01 08:52:03 +02:00
Bård Skaflestad
021d946a96 Merge pull request #1769 from joakim-hove/is-udq-regexp
Update regexp to allow for digits in UDQ name
2020-04-30 16:32:17 +02:00
Joakim Hove
8b70e42e0f Connection - Segment interaction implemented with optional pair 2020-04-30 14:54:21 +02:00
Joakim Hove
94defc8a08 Merge pull request #1768 from atgeirr/add-missing-include
Add missing include statement.
2020-04-30 12:28:19 +02:00
Joakim Hove
29dd594d48 Update regexp to allow for digits in UDQ name 2020-04-30 12:10:34 +02:00
Joakim Hove
b8ab03b22b Merge pull request #1767 from joakim-hove/remove-unused-include
Remove #include which is not needed
2020-04-30 12:03:39 +02:00
Atgeirr Flø Rasmussen
b9cdaafed3 Add missing include statement. 2020-04-30 11:55:32 +02:00
Williham Williham Totland
87ca9077ea Implements group hierarchy data subreport. 2020-04-30 10:27:12 +02:00
Joakim Hove
57cfeeb854 Remove #include which is not needed 2020-04-30 10:23:44 +02:00
Joakim Hove
e4c6cc3de0 Merge pull request #1764 from akva2/fix_focal_packaging
changed: remove multiarch-support predepends
2020-04-30 10:21:15 +02:00
Williham Williham Totland
4663e49e23 Group hierarchy report interface. 2020-04-30 09:33:06 +02:00
Arne Morten Kvarving
58269dd675 changed: remove multiarch-support predepends
no longer required in ubuntu bionic, and breaks ubuntu focal,
and in any case it is support by both platforms.
2020-04-30 09:12:50 +02:00
Bård Skaflestad
fc69eb7b72 Merge pull request #1746 from joakim-hove/network
Network
2020-04-29 17:00:54 +02:00
Joakim Hove
c7008d329a Add class ExtNetwork for extended networks 2020-04-29 15:45:18 +02:00
Bård Skaflestad
27b348b013 Merge pull request #1749 from bska/fix-krgr
Fix Default Value Initializers for Field Properties KR*R
2020-04-29 14:32:58 +02:00
Bård Skaflestad
79bb8386d3 Sat-Func Initializers: Add End-Point Unit Tests
Exercises the initializers for SW{L,CR,U}, SO{W,G}CR, SG{L,CR,U}, as
well as the function values KRW, KRWR, KRG, KRGR, KRO, KRORW, KRORG
and capillary pressure function values PCW and PCG.

Example data from region one (1) of

    opm-tests/model1/include/sattab_basemod1.sattab

Example phrased both as family I (S*OF) and as family II (S*FN, SOF3).
2020-04-29 13:33:51 +02:00
Bård Skaflestad
146be0aa21 SOGCR: Pull SGOF Handling Into Initializer
This is in any case needed to calculate correct KRGR default values
in runs using family I saturation function keywords (S*OF) and also
removes the need to apply the special 'subtract_swl' operation in
this case.  Overall this is a simplification of the code since we
now have all saturation end-points available when initializing
saturation function field properties.
2020-04-29 13:33:51 +02:00
Bård Skaflestad
137ef7a17b Sat-Func Initializers: Use RawTableEndPoints for KRGR
This commit reimplements the findKrgr helper function in terms of
the RawTableEndPoints aggregate.  In particular, this commit aims to
underscore the fact that KRGR is the relative permeability of gas at
the displacing saturation

    1 - Socr - Swco

This fact is hopefully more apparent in this revised than the
existing implementation since we now rely explicitly on evaluating
the 'KrgColumn' at an index derived from looking up that saturation
value in the pertinent saturation column.
2020-04-29 13:33:51 +02:00
Bård Skaflestad
c8048021d1 Sat-Func Initializers: Use RawTableEndPoints for KRWR
This commit reimplements the findKrwr helper function in terms of
the RawTableEndPoints aggregate.  In particular, this commit aims to
underscore the fact that KRWR is the relative permeability of water
at the displacing saturation

    1 - Socr - Sgco

This fact is hopefully more apparent in this revised than the
existing implementation since we now rely explicitly on evaluating
the 'KrwColumn' at an index derived from looking up that saturation
value in the pertinent saturation column.
2020-04-29 13:33:51 +02:00
Bård Skaflestad
58764a6ec6 Sat-Func Initializers: Use RawTableEndPoints for KRORW
This commit reimplements the findKrorw helper function in terms of
the RawTableEndPoints aggregate.  In particular, this commit aims to
underscore the fact that KRORW is the relative permeability of oil
in the Oil/Water system at the displacing saturation

    1 - Swcr - Sgco

This fact is hopefully more apparent in this revised than the
existing implementation since we now rely explicitly on evaluating
the 'KrowColumn' at an index derived from looking up that saturation
value in the pertinent saturation column.
2020-04-29 13:33:51 +02:00
Bård Skaflestad
b17b4c1375 Sat-Func Initializers: Use RawTableEndPoints for KRORG
This commit reimplements the findKrorg helper function in terms of
the RawTableEndPoints aggregate.  In particular, this commit aims to
underscore the fact that KRORG is the relative permeability of oil
in the Oil/Gas system at the displacing saturation

    1 - Sgcr - Swco

This fact is hopefully more apparent in this revised than the
existing implementation since we now rely explicitly on evaluating
the 'KrogColumn' at an index derived from looking up that saturation
value in the pertinent saturation column.
2020-04-29 13:33:51 +02:00
Bård Skaflestad
3817524f52 Sat-Func Initializers: Adjust Whitespace and Fix a Variable Name
The name 'max_krw' reflects the actual value better than the
existing name 'krwr'.
2020-04-29 13:33:51 +02:00
Bård Skaflestad
f6cfadd62f Sat-Func Initializers: Use Precalculated Endpoints Where Possible 2020-04-29 13:33:51 +02:00
Bård Skaflestad
af34e083c2 Sat-Func Initializers: Include <algorithm> and <iterator>
Needed to bring in declarations of std::distance, std::reverse, and
std::upper_bound.
2020-04-29 13:33:51 +02:00
Bård Skaflestad
2984cca164 Sat-Func Properties: Provide All Raw Endpoints to All Initializers
This is in preparation of fixing the initializers for the KR*R
properties.  The default values here generally depend on critical
and connate saturations of other phases extracted from the raw input
table values.  This commit therefore creates an aggregate structure

    RawTableEndPoints

that collects the connate gas and water saturations, the full set of
critical saturations, and the maximum gas and water saturations from
all input tables (meaning for all regions and drainage/imbibition
regime designators).  Each *Endpoint() function furthermore gets a
new parameter of this type to preserve a uniform signature.

Note that we currently calculate the complete set of these endpoints
for each call to satfunc::init(), but may choose to expose this
structure to the caller at a later time in order to reduce the
overhead of these repeated calculations.
2020-04-29 13:33:51 +02:00
Bård Skaflestad
6615030fab Sat-Func Region Apply: Remove 'ACTNUM' Pointer
We always call these functions on all active cells so there's no
need to have checks for ACTNUM-like cell subsets.
2020-04-29 13:33:51 +02:00
Bård Skaflestad
a4fc7ab05d Sat-func Region Apply: Split Region ID Check out to Helper
Mostly to reduce cognitive load when reading the *Apply() functions'
implementations.
2020-04-29 13:33:51 +02:00
Bård Skaflestad
8f64405ace Reduce Saturation Function Initialization API
The individual property initialization functions aren't used
directly anymore.  Put them in an anonymous namespace in the
implementation file so that no client can take their address.  This
is in preparation of adding TOLCRIT support.
2020-04-29 13:33:51 +02:00
Markus Blatt
eeb63d8694 Merge pull request #1758 from blattms/mark-openmp-as-prereq
Mark OpenMP as prerequisite for opm-common
2020-04-29 12:57:02 +02:00
Williham Williham Totland
cb8ddfd8aa Minor style consistency tweaks. 2020-04-29 11:30:30 +02:00
Joakim Hove
8201728973 Merge pull request #1760 from joakim-hove/python-package-path
Python files should go in $PREFIX/dist-packages on debian
2020-04-29 10:49:20 +02:00
Williham Williham Totland
77a0ee13ac Implements perf range. 2020-04-29 10:15:23 +02:00
Joakim Hove
512c2e4c1e Python files should go in $PREFIX/dist-packages on debian 2020-04-29 10:03:08 +02:00
Williham Williham Totland
a4111fa672 Projects the unit system from the callsite. 2020-04-29 08:40:17 +02:00
Williham Williham Totland
78c19a3aba Minor style tweaks. 2020-04-29 08:33:26 +02:00
Williham Williham Totland
fbe9d0dec2 Refactors number formatting. 2020-04-29 08:33:26 +02:00
Williham Williham Totland
305b4b21a7 Implements unit conversion for connection factor. 2020-04-29 08:33:26 +02:00
Williham Williham Totland
5e5aadb4ea Adds unit conversions. 2020-04-29 08:33:26 +02:00
Williham Williham Totland
84ff359b64 Minor formatting tweaks. 2020-04-29 08:33:24 +02:00
Williham Williham Totland
40a8651d68 Adds units to table definitions. 2020-04-29 08:32:31 +02:00
Williham Williham Totland
e365ca3f7d Projects the context into header printing. 2020-04-29 08:32:31 +02:00
Williham Williham Totland
a62fdad192 Reworks projection of the unit system. 2020-04-29 08:32:31 +02:00
Joakim Hove
6be2217935 Merge pull request #1757 from joakim-hove/remove-unused-function
Remove unused function from Group output data
2020-04-28 17:18:54 +02:00
Joakim Hove
9956492730 Remove unused function from Group output data 2020-04-28 16:17:43 +02:00
Joakim Hove
ad536b718b Merge pull request #1754 from blattms/find-zoltan-only-with-mpi
[CMake] Find Zoltan only if MPI is available.
2020-04-28 14:50:08 +02:00
Markus Blatt
a87e6f281d Quietly searcg for OpenMP in opm-common-prereqs.cmake 2020-04-28 12:58:39 +02:00
Markus Blatt
bb185a23ce Mark OpenMP as prerequisite for opm-common
to automatically trigger find_package(OpenMP) in downstream
modules (e.g. Dumux)
2020-04-28 11:35:16 +02:00
Joakim Hove
f7bbf92e3a Merge pull request #1752 from joakim-hove/remove-keywords
Suggestion: Remove unsupported E300 keywords
2020-04-27 19:21:15 +02:00
Bård Skaflestad
a89d053cae Merge pull request #1743 from bska/grppot-eff-fac-aware
Summary Output: Make Group Potentials Aware of Efficiency Factors
2020-04-27 16:55:08 +02:00
Joakim Hove
1758439c03 Merge pull request #1753 from blattms/fix-openmp-for-newer-cmake-master
Use OpenMP::OpenMP_CXX taget when linking libopmcommon
2020-04-27 16:08:35 +02:00
Markus Blatt
b6dd398c32 Find Zoltan only if MPI is available.
Otherwise we experience compilation errors if OPM is configured with
deactivated MPI and activated and found dune-alugrid (cpmpile error
that mpi.h is not found). This commit fixes this for me.
2020-04-27 16:00:49 +02:00
Markus Blatt
0ebe62a1d5 Use OpenMP::OpenMP_CXX target when linking libopmcommon
This should allow downstream to automatically use the correct
compile and linke flags for CMake > 3.9. For older versions
we fall back to the old approach.

Closes #1751
2020-04-27 12:54:18 +02:00
Bård Skaflestad
96a2350bf3 Summary Output: Make Group Potentials Aware of Efficiency Factors
As with all rate-like quantities, the *EFAC values affect the group
tree level above the level where the factor is applied
2020-04-27 10:56:48 +02:00
Joakim Hove
41803f5291 Remove unsupported E300 keywords 2020-04-27 10:33:45 +02:00
Joakim Hove
7468499855 Merge pull request #1750 from OPMUSER/master
Update to Water Vaporization Keywords to be Consistent
2020-04-27 09:40:25 +02:00
Bård Skaflestad
0eeb3243fb Merge pull request #1737 from joakim-hove/rsm-fixup
Small fixes to RSM output
2020-04-27 08:53:38 +02:00
OPMUSER
8a0e0c823c Add PVTGW, PVTGWO and RWGSALT
Will also add to Missing Features.
2020-04-27 13:45:35 +08:00
Joakim Hove
fa70f4dce1 Use ESmry::loadData() to preload all summary vectors 2020-04-27 07:04:45 +02:00
Joakim Hove
a92894f4d4 Small fixes to RSM output
- MAI -> MAY
- Update text header with simulation time and flow version
- Make sure the YEARS column is always the first column on page 1
2020-04-27 07:04:45 +02:00
OPMUSER
800d98c038 Update keyword_list.cmake with PERMFACT
Update keyword_list.cmake with PERMFACT
2020-04-27 12:51:55 +08:00
OPMUSER
297f90a88a Rename PERMRED to PERMFACT
As per TNO rename PERMRED to PERMFACT to match documentation.
2020-04-27 12:32:17 +08:00
Bård Skaflestad
67b2d5c185 Merge pull request #1748 from tskille/esmry_improvements
improved efficiency when opening summary files.
2020-04-26 23:03:02 +02:00
Torbjørn Skille
43f1739dfa improved efficiency when opening summary files.
> loading only arrays that is used (DIMENS, RESTART, KEYWORDS, NUMS and UNITS)
 > smspec file now only loading arrays once (twice before)
2020-04-26 18:24:01 +02:00
Bård Skaflestad
a78aa78248 Merge pull request #1747 from akva2/fix_int_abs
fixed: do not use integer abs
2020-04-26 13:39:00 +02:00
Arne Morten Kvarving
751a1c28fa fixed: do not use integer abs 2020-04-26 12:32:27 +02:00
Bård Skaflestad
380f85ed7e Merge pull request #1732 from joakim-hove/welspecs-report-refactor
Welspecs report refactor
2020-04-26 00:09:26 +02:00
Joakim Hove
7a2539b1f2 Merge pull request #1742 from joakim-hove/pr-keywords
Add keyword PRVD
2020-04-25 21:39:36 +02:00
Joakim Hove
c6b367e51e Merge pull request #1745 from bska/wellgraph-handle-dashed-names
Wellgraph: Quote Names to Transparently Handle Dashes
2020-04-25 21:20:14 +02:00
Bård Skaflestad
24ab7e5ff4 Wellgraph: Quote Names to Transparently Handle Dashes
This way, the dot(1) program won't generate errors like

    Badly delimited number 1_ splits into two tokens

when presented with a well name like 'INJE-1_N'.
2020-04-25 16:21:30 +02:00
Bård Skaflestad
775bce0b2f Merge pull request #1744 from atgeirr/add-wellgraph
Add 'wellgraph' utility program.
2020-04-25 14:24:50 +02:00
Atgeirr Flø Rasmussen
3d9a12efcb Add 'wellgraph' utility program. 2020-04-25 12:37:21 +02:00
Joakim Hove
7d2262e022 Merge pull request #1738 from joakim-hove/summary-YEARS
Summary years
2020-04-24 16:34:31 +02:00
Joakim Hove
e0df1cd470 Add keyword PRVD 2020-04-24 14:51:46 +02:00
Joakim Hove
162fcfc73b Merge pull request #1740 from OPMUSER/master
Create HMMULTSG
2020-04-24 14:47:21 +02:00
Joakim Hove
6264bab6b0 Summary compare ESmry and ERsm - looser tolerance 2020-04-24 14:42:42 +02:00
OPMUSER
2189a7efcd Update keyword_list.cmake 2020-04-24 18:53:39 +08:00
OPMUSER
8dff4ecef1 Create HMMULTSG
Create HMMULTSG definition
2020-04-24 17:45:26 +08:00
Joakim Hove
5781350bd4 Unconditionally add YEARS to summary output 2020-04-24 10:19:53 +02:00
Joakim Hove
4f0fa5c21a Introduce time unit ecl_years == 365.25 days 2020-04-24 10:19:53 +02:00
Williham Williham Totland
06f32f3d37 Projects unit type into columns. 2020-04-24 09:49:18 +02:00
Joakim Hove
b6c1e8a27e Refactor WELSPECS reports 2020-04-24 07:34:22 +02:00
Joakim Hove
1e77c1510d Merge pull request #1733 from joakim-hove/branches
Add method WellSegments::branches()
2020-04-23 22:28:51 +02:00
Bård Skaflestad
e57d11fe38 Merge pull request #1735 from joakim-hove/branch-segments-fixup
Segment sorting - check if already in order
2020-04-23 10:22:36 +02:00
Joakim Hove
f3d2b95896 Segment sorting - check if already in order 2020-04-23 06:44:53 +02:00
Bård Skaflestad
cd8b32acac Merge pull request #1734 from joakim-hove/connections-empty
Update connections should hanlde empty list
2020-04-22 20:02:10 +02:00
Joakim Hove
b26b4c2c77 Update connections should hanlde empty list 2020-04-22 17:33:30 +02:00
Joakim Hove
e7f750da83 Add method WellSegments::branches() 2020-04-22 17:03:03 +02:00
458 changed files with 49463 additions and 10936 deletions

View File

@@ -73,8 +73,12 @@ macro (config_hook)
if(NOT cjson_FOUND)
list(APPEND EXTRA_INCLUDES ${PROJECT_SOURCE_DIR}/external/cjson)
endif()
# For this project
add_definitions(-DFMT_HEADER_ONLY)
include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/external/fmtlib/include)
include_directories(${EXTRA_INCLUDES} ${PROJECT_BINARY_DIR}/include)
list(APPEND EXTRA_INCLUDES ${PROJECT_SOURCE_DIR}/external/fmtlib/include)
# For downstreams
list(APPEND EXTRA_INCLUDES ${PROJECT_BINARY_DIR}/include)
@@ -193,11 +197,7 @@ if(ENABLE_ECL_INPUT)
test_util/summary.cpp
)
add_executable(test_esmry_lod
test_util/test_esmry_lod.cpp
)
foreach(target compareECL convertECL summary test_esmry_lod)
foreach(target compareECL convertECL summary)
target_link_libraries(${target} opmcommon)
install(TARGETS ${target} DESTINATION bin)
endforeach()
@@ -247,7 +247,11 @@ install(FILES etc/opm_bash_completion.sh.in DESTINATION share/opm/etc)
if (OPM_ENABLE_PYTHON)
# -------------------------------------------------------------------------
# 1: Wrap C++ functionality in Python
set(PYTHON_PACKAGE_PATH "site-packages")
if (EXISTS "/etc/debian_version")
set(PYTHON_PACKAGE_PATH "dist-packages")
else()
set(PYTHON_PACKAGE_PATH "site-packages")
endif()
set(PYTHON_INSTALL_PREFIX "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/${PYTHON_PACKAGE_PATH}" CACHE STRING "Subdirectory to install Python modules in")
make_directory(${PROJECT_BINARY_DIR}/python)
@@ -255,10 +259,11 @@ if (OPM_ENABLE_PYTHON)
list(APPEND _opmcommon_include_dirs ${_ecl_include_dirs})
string(REPLACE ";" ":" _setup_include_dirs "${_opmcommon_include_dirs}")
get_target_property(_opmcommon_lib_dirs opmcommon LINK_DIRECTORIES)
if (CMAKE_PREFIX_PATH)
set(_opmcommon_lib_dirs ${PROJECT_BINARY_DIR}/lib ${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR})
list(APPEND _opmcommon_lib_dirs ${PROJECT_BINARY_DIR}/lib ${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR})
else()
set(_opmcommon_lib_dirs ${PROJECT_BINARY_DIR}/lib)
list(APPEND _opmcommon_lib_dirs ${PROJECT_BINARY_DIR}/lib)
endif()
string(REPLACE ";" ":" _setup_lib_dirs "${_opmcommon_lib_dirs}")
@@ -284,6 +289,11 @@ if (OPM_ENABLE_PYTHON)
set( _rpath_arg "")
endif()
set(opm-common_PYTHON_PACKAGE_VERSION ${OPM_PYTHON_PACKAGE_VERSION_TAG})
# Generate versioned setup.py
configure_file (${PROJECT_SOURCE_DIR}/python/setup.py.in ${PROJECT_BINARY_DIR}/python/setup.py)
file(COPY ${PROJECT_SOURCE_DIR}/python/README.md DESTINATION ${PROJECT_BINARY_DIR}/python)
execute_process(COMMAND ${PYTHON_EXECUTABLE} target_name.py
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/python
OUTPUT_VARIABLE python_lib_target)
@@ -291,19 +301,19 @@ if (OPM_ENABLE_PYTHON)
add_custom_target(copy_python ALL
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/python/install.py ${PROJECT_SOURCE_DIR}/python ${PROJECT_BINARY_DIR} 0)
add_custom_command(OUTPUT python/python/opm/${python_lib_target}
add_custom_command(OUTPUT python/opm/${python_lib_target}
DEPENDS ${PYTHON_CXX_DEPENDS}
DEPENDS copy_python
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_BINARY_DIR}/python/setup.py
build
build_ext
--build-lib=${PROJECT_BINARY_DIR}/python/python/opm
--build-lib=${PROJECT_BINARY_DIR}/python
--library-dirs=${_setup_lib_dirs}
${_rpath_arg}
--include-dirs=${_setup_include_dirs}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/python
COMMENT "Building python bindings")
add_custom_target(opmcommon_python ALL DEPENDS python/python/opm/${python_lib_target})
COMMENT "Building python bindings at python/opm/${python_lib_target}")
add_custom_target(opmcommon_python ALL DEPENDS python/opm/${python_lib_target})
add_dependencies(opmcommon_python opmcommon)
# The install target is based on manually copying the python file tree to the
@@ -318,7 +328,7 @@ if (OPM_ENABLE_PYTHON)
# setup.py install manually - optionally with the generated script
# setup-install.sh - and completely bypass cmake in the installation phase.
if (OPM_INSTALL_PYTHON)
install( CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_BINARY_DIR}/python/install.py ${PROJECT_BINARY_DIR}/python/python/opm ${DEST_PREFIX}${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX} 1)")
install( CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_BINARY_DIR}/python/install.py ${PROJECT_BINARY_DIR}/python/opm ${DEST_PREFIX}${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX} 1)")
endif()
# Observe that if the opmcommon library has been built as a shared library the
@@ -326,11 +336,11 @@ if (OPM_ENABLE_PYTHON)
# testing.
add_test(NAME python_tests
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/python
COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/lib ${PYTHON_EXECUTABLE} setup.py build_ext --dry-run --build-lib ${PROJECT_BINARY_DIR}/python/python/opm test
COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/lib ${PYTHON_EXECUTABLE} setup.py build_ext --dry-run --build-lib ${PROJECT_BINARY_DIR}/python test
)
set_target_properties(opmcommon PROPERTIES POSITION_INDEPENDENT_CODE ON)
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${PROJECT_BINARY_DIR}/python/python)
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${PROJECT_BINARY_DIR}/python)
# -------------------------------------------------------------------------
# Let cmake configure some small shell scripts which can be used to simplify
@@ -340,6 +350,11 @@ if (OPM_ENABLE_PYTHON)
DESTINATION ${PROJECT_BINARY_DIR}
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE )
configure_file(python/setup-package.sh.in tmp/setup-package.sh)
file( COPY ${PROJECT_BINARY_DIR}/tmp/setup-package.sh
DESTINATION ${PROJECT_BINARY_DIR}
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE )
configure_file(python/setup-test.sh.in tmp/setup-test.sh)
file( COPY ${PROJECT_BINARY_DIR}/tmp/setup-test.sh
DESTINATION ${PROJECT_BINARY_DIR}

View File

@@ -21,7 +21,6 @@
# the library needs it.
list (APPEND MAIN_SOURCE_FILES
src/opm/common/data/SimulationDataContainer.cpp
src/opm/common/OpmLog/CounterLog.cpp
src/opm/common/OpmLog/EclipsePRTLog.cpp
src/opm/common/OpmLog/LogBackend.cpp
@@ -33,6 +32,7 @@ list (APPEND MAIN_SOURCE_FILES
src/opm/common/utility/ActiveGridCells.cpp
src/opm/common/utility/FileSystem.cpp
src/opm/common/utility/numeric/MonotCubicInterpolator.cpp
src/opm/common/utility/OpmInputError.cpp
src/opm/common/utility/parameters/Parameter.cpp
src/opm/common/utility/parameters/ParameterGroup.cpp
src/opm/common/utility/parameters/ParameterTools.cpp
@@ -96,8 +96,12 @@ if(ENABLE_ECL_INPUT)
src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionValue.cpp
src/opm/parser/eclipse/EclipseState/Schedule/Action/ASTNode.cpp
src/opm/parser/eclipse/EclipseState/Schedule/Action/Condition.cpp
src/opm/parser/eclipse/EclipseState/Schedule/Action/State.cpp
src/opm/parser/eclipse/EclipseState/Schedule/ArrayDimChecker.cpp
src/opm/parser/eclipse/EclipseState/Schedule/eval_uda.cpp
src/opm/parser/eclipse/EclipseState/Schedule/Events.cpp
src/opm/parser/eclipse/EclipseState/Schedule/GasLiftOpt.cpp
src/opm/parser/eclipse/EclipseState/Schedule/Group/GPMaint.cpp
src/opm/parser/eclipse/EclipseState/Schedule/Group/Group.cpp
src/opm/parser/eclipse/EclipseState/Schedule/Group/GuideRate.cpp
src/opm/parser/eclipse/EclipseState/Schedule/Group/GuideRateConfig.cpp
@@ -105,15 +109,18 @@ if(ENABLE_ECL_INPUT)
src/opm/parser/eclipse/EclipseState/Schedule/Group/GConSale.cpp
src/opm/parser/eclipse/EclipseState/Schedule/Group/GConSump.cpp
src/opm/parser/eclipse/EclipseState/Schedule/Group/GTNode.cpp
src/opm/parser/eclipse/EclipseState/Schedule/Well/injection.cpp
src/opm/parser/eclipse/EclipseState/Schedule/KeywordHandlers.cpp
src/opm/parser/eclipse/EclipseState/Schedule/MessageLimits.cpp
src/opm/parser/eclipse/EclipseState/Schedule/MSW/icd.cpp
src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp
src/opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.cpp
src/opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.cpp
src/opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.cpp
src/opm/parser/eclipse/EclipseState/Schedule/MSW/SpiralICD.cpp
src/opm/parser/eclipse/EclipseState/Schedule/MSW/AICD.cpp
src/opm/parser/eclipse/EclipseState/Schedule/MSW/SICD.cpp
src/opm/parser/eclipse/EclipseState/Schedule/MSW/Valve.cpp
src/opm/parser/eclipse/EclipseState/Schedule/Network/Branch.cpp
src/opm/parser/eclipse/EclipseState/Schedule/Network/ExtNetwork.cpp
src/opm/parser/eclipse/EclipseState/Schedule/Network/Node.cpp
src/opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.cpp
src/opm/parser/eclipse/EclipseState/Schedule/RFTConfig.cpp
src/opm/parser/eclipse/EclipseState/Schedule/RPTConfig.cpp
@@ -122,7 +129,7 @@ if(ENABLE_ECL_INPUT)
src/opm/parser/eclipse/EclipseState/Schedule/SummaryState.cpp
src/opm/parser/eclipse/EclipseState/Schedule/TimeMap.cpp
src/opm/parser/eclipse/EclipseState/Schedule/Well/Connection.cpp
src/opm/parser/eclipse/EclipseState/Schedule/eval_uda.cpp
src/opm/parser/eclipse/EclipseState/Schedule/Well/injection.cpp
src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp
src/opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.cpp
src/opm/parser/eclipse/EclipseState/Schedule/Well/WList.cpp
@@ -151,6 +158,7 @@ if(ENABLE_ECL_INPUT)
src/opm/parser/eclipse/EclipseState/Tables/TableColumn.cpp
src/opm/parser/eclipse/EclipseState/Tables/TableContainer.cpp
src/opm/parser/eclipse/EclipseState/Tables/TableIndex.cpp
src/opm/parser/eclipse/EclipseState/Tables/TLMixpar.cpp
src/opm/parser/eclipse/EclipseState/Tables/TableManager.cpp
src/opm/parser/eclipse/EclipseState/Tables/TableSchema.cpp
src/opm/parser/eclipse/EclipseState/Tables/Tables.cpp
@@ -158,6 +166,7 @@ if(ENABLE_ECL_INPUT)
src/opm/parser/eclipse/EclipseState/Tables/Rock2dtrTable.cpp
src/opm/parser/eclipse/EclipseState/Tables/PvtwsaltTable.cpp
src/opm/parser/eclipse/EclipseState/Tables/BrineDensityTable.cpp
src/opm/parser/eclipse/EclipseState/Tables/RwgsaltTable.cpp
src/opm/parser/eclipse/EclipseState/Tables/SolventDensityTable.cpp
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQASTNode.cpp
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQParams.cpp
@@ -167,11 +176,13 @@ if(ENABLE_ECL_INPUT)
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQAssign.cpp
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQDefine.cpp
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.cpp
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQToken.cpp
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.cpp
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQContext.cpp
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunction.cpp
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunctionTable.cpp
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQInput.cpp
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQState.cpp
src/opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.cpp
src/opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.cpp
src/opm/parser/eclipse/Parser/ErrorGuard.cpp
@@ -187,7 +198,6 @@ if(ENABLE_ECL_INPUT)
src/opm/parser/eclipse/Units/Dimension.cpp
src/opm/parser/eclipse/Units/UnitSystem.cpp
src/opm/parser/eclipse/Utility/Functional.cpp
src/opm/parser/eclipse/Utility/Stringview.cpp
)
@@ -292,10 +302,10 @@ list (APPEND TEST_SOURCE_FILES
tests/test_cubic.cpp
tests/test_messagelimiter.cpp
tests/test_nonuniformtablelinear.cpp
tests/test_OpmInputError_format.cpp
tests/test_OpmLog.cpp
tests/test_param.cpp
tests/test_RootFinders.cpp
tests/test_SimulationDataContainer.cpp
tests/test_sparsevector.cpp
tests/test_uniformtablelinear.cpp
)
@@ -303,6 +313,7 @@ if(ENABLE_ECL_INPUT)
list(APPEND TEST_SOURCE_FILES
tests/rst_test.cpp
tests/test_ERsm.cpp
tests/test_GuideRate.cpp
tests/parser/ACTIONX.cpp
tests/parser/ADDREGTests.cpp
tests/parser/AquiferTests.cpp
@@ -332,6 +343,7 @@ if(ENABLE_ECL_INPUT)
tests/parser/MultiRegTests.cpp
tests/parser/MultisegmentWellTests.cpp
tests/parser/MULTREGTScannerTests.cpp
tests/parser/NetworkTests.cpp
tests/parser/OrderedMapTests.cpp
tests/parser/ParseContextTests.cpp
tests/parser/ParseContext_EXIT1.cpp
@@ -365,7 +377,6 @@ if(ENABLE_ECL_INPUT)
tests/parser/TuningTests.cpp
tests/parser/UDQTests.cpp
tests/parser/UnitTests.cpp
tests/parser/ValueTests.cpp
tests/parser/WellSolventTests.cpp
tests/parser/WellTracerTests.cpp
tests/parser/WellTests.cpp
@@ -381,6 +392,7 @@ if(ENABLE_ECL_OUTPUT)
tests/test_AggregateConnectionData.cpp
tests/test_AggregateUDQData.cpp
tests/test_ArrayDimChecker.cpp
tests/test_data_GuideRateValue.cpp
tests/test_EclipseIO.cpp
tests/test_DoubHEAD.cpp
tests/test_InteHEAD.cpp
@@ -393,6 +405,7 @@ if(ENABLE_ECL_OUTPUT)
tests/test_RFT.cpp
tests/test_rst.cpp
tests/test_Solution.cpp
tests/test_Serializer.cpp
tests/test_Summary.cpp
tests/test_Summary_Group.cpp
tests/test_Tables.cpp
@@ -407,8 +420,6 @@ list (APPEND TEST_DATA_FILES
)
if(ENABLE_ECL_OUTPUT)
list (APPEND TEST_DATA_FILES
tests/expect-wdims.chldg.err.out
tests/expect-wdims.err.out
tests/BASE_SIM.DATA
tests/BASE_SIM_THPRES.DATA
tests/RESTART_SIM.DATA
@@ -424,6 +435,8 @@ if(ENABLE_ECL_OUTPUT)
tests/SPE1CASE1A.SMSPEC
tests/SPE9_CP_PACKED.DATA
tests/SOFR_TEST.DATA
tests/UDQ_BASE.DATA
tests/UDQ_RESTART.DATA
tests/UDQ_TEST_WCONPROD_IUAD-2.DATA
tests/UDQ_ACTIONX_TEST1.DATA
tests/UDQ_ACTIONX_TEST1_U.DATA
@@ -436,6 +449,7 @@ if(ENABLE_ECL_OUTPUT)
tests/SPE1CASE2_RESTART.DATA
tests/SPE1CASE2.X0060
tests/PYACTION.DATA
tests/0A4_GRCTRL_LRAT_LRAT_GGR_BASE_MODEL2_MSW_ALL.DATA
tests/act1.py
tests/MSW.DATA
tests/EXIT_TEST.DATA
@@ -472,6 +486,8 @@ if(ENABLE_ECL_INPUT)
examples/opmi.cpp
examples/opmpack.cpp
examples/opmhash.cpp
examples/wellgraph.cpp
examples/make_lodsmry.cpp
)
endif()
@@ -484,13 +500,13 @@ if(ENABLE_ECL_INPUT)
examples/opmi.cpp
examples/opmpack.cpp
examples/opmhash.cpp
examples/make_lodsmry.cpp
)
endif()
list( APPEND PUBLIC_HEADER_FILES
opm/common/ErrorMacros.hpp
opm/common/Exceptions.hpp
opm/common/data/SimulationDataContainer.hpp
opm/common/OpmLog/CounterLog.hpp
opm/common/OpmLog/EclipsePRTLog.hpp
opm/common/OpmLog/LogBackend.hpp
@@ -498,12 +514,14 @@ list( APPEND PUBLIC_HEADER_FILES
opm/common/OpmLog/LogUtil.hpp
opm/common/OpmLog/MessageFormatter.hpp
opm/common/OpmLog/MessageLimiter.hpp
opm/common/OpmLog/Location.hpp
opm/common/OpmLog/KeywordLocation.hpp
opm/common/OpmLog/OpmLog.hpp
opm/common/OpmLog/StreamLog.hpp
opm/common/OpmLog/TimerLog.hpp
opm/common/utility/Serializer.hpp
opm/common/utility/ActiveGridCells.hpp
opm/common/utility/FileSystem.hpp
opm/common/utility/OpmInputError.hpp
opm/common/utility/numeric/cmp.hpp
opm/common/utility/platform_dependent/disable_warnings.h
opm/common/utility/platform_dependent/reenable_warnings.h
@@ -530,7 +548,6 @@ if(ENABLE_ECL_INPUT)
list(APPEND PUBLIC_HEADER_FILES
opm/io/eclipse/SummaryNode.hpp
opm/json/JsonObject.hpp
opm/parser/eclipse/Utility/Stringview.hpp
opm/parser/eclipse/Utility/Functional.hpp
opm/parser/eclipse/Utility/Typetools.hpp
opm/parser/eclipse/Generator/KeywordGenerator.hpp
@@ -550,12 +567,14 @@ if(ENABLE_ECL_INPUT)
opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp
opm/parser/eclipse/EclipseState/InitConfig/Equil.hpp
opm/parser/eclipse/EclipseState/InitConfig/FoamConfig.hpp
opm/parser/eclipse/EclipseState/Util/Value.hpp
opm/parser/eclipse/EclipseState/Util/IOrderSet.hpp
opm/parser/eclipse/EclipseState/Util/OrderedMap.hpp
opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp
opm/parser/eclipse/EclipseState/Edit/EDITNNC.hpp
opm/parser/eclipse/EclipseState/Grid/FieldData.hpp
opm/parser/eclipse/EclipseState/Grid/Keywords.hpp
opm/parser/eclipse/EclipseState/Grid/GridDims.hpp
opm/parser/eclipse/EclipseState/Grid/TranCalculator.hpp
opm/parser/eclipse/EclipseState/Grid/TransMult.hpp
opm/parser/eclipse/EclipseState/Grid/PinchMode.hpp
opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.hpp
@@ -586,8 +605,11 @@ if(ENABLE_ECL_INPUT)
opm/parser/eclipse/EclipseState/Tables/SpecrockTable.hpp
opm/parser/eclipse/EclipseState/Tables/PvtwsaltTable.hpp
opm/parser/eclipse/EclipseState/Tables/BrineDensityTable.hpp
opm/parser/eclipse/EclipseState/Tables/SolventDensityTable.hpp
opm/parser/eclipse/EclipseState/Tables/PermfactTable.hpp
opm/parser/eclipse/EclipseState/Tables/RwgsaltTable.hpp
opm/parser/eclipse/EclipseState/Tables/SaltvdTable.hpp
opm/parser/eclipse/EclipseState/Tables/SaltpvdTable.hpp
opm/parser/eclipse/EclipseState/Tables/SolventDensityTable.hpp
opm/parser/eclipse/EclipseState/Tables/PlydhflfTable.hpp
opm/parser/eclipse/EclipseState/Tables/PlymwinjTable.hpp
opm/parser/eclipse/EclipseState/Tables/PlyshlogTable.hpp
@@ -597,6 +619,7 @@ if(ENABLE_ECL_INPUT)
opm/parser/eclipse/EclipseState/Tables/SpecheatTable.hpp
opm/parser/eclipse/EclipseState/Tables/SgcwmisTable.hpp
opm/parser/eclipse/EclipseState/Tables/Sof2Table.hpp
opm/parser/eclipse/EclipseState/Tables/TLMixpar.hpp
opm/parser/eclipse/EclipseState/Tables/TableManager.hpp
opm/parser/eclipse/EclipseState/Tables/SwfnTable.hpp
opm/parser/eclipse/EclipseState/Tables/EnptvdTable.hpp
@@ -606,6 +629,8 @@ if(ENABLE_ECL_INPUT)
opm/parser/eclipse/EclipseState/Tables/JFunc.hpp
opm/parser/eclipse/EclipseState/Tables/TableIndex.hpp
opm/parser/eclipse/EclipseState/Tables/PvtgTable.hpp
opm/parser/eclipse/EclipseState/Tables/PvtgwTable.hpp
opm/parser/eclipse/EclipseState/Tables/PvtgwoTable.hpp
opm/parser/eclipse/EclipseState/Tables/Tabdims.hpp
opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp
opm/parser/eclipse/EclipseState/Tables/RocktabTable.hpp
@@ -662,7 +687,12 @@ if(ENABLE_ECL_INPUT)
opm/parser/eclipse/EclipseState/Schedule/Action/Condition.hpp
opm/parser/eclipse/EclipseState/Schedule/Action/ASTNode.hpp
opm/parser/eclipse/EclipseState/Schedule/Action/PyAction.hpp
opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp
opm/parser/eclipse/EclipseState/Schedule/ArrayDimChecker.hpp
opm/parser/eclipse/EclipseState/Schedule/GasLiftOpt.hpp
opm/parser/eclipse/EclipseState/Schedule/Network/Branch.hpp
opm/parser/eclipse/EclipseState/Schedule/Network/ExtNetwork.hpp
opm/parser/eclipse/EclipseState/Schedule/Network/Node.hpp
opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp
opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp
opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.hpp
@@ -689,6 +719,7 @@ if(ENABLE_ECL_INPUT)
opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp
opm/parser/eclipse/EclipseState/Schedule/ScheduleTypes.hpp
opm/parser/eclipse/EclipseState/Schedule/Tuning.hpp
opm/parser/eclipse/EclipseState/Schedule/Group/GPMaint.hpp
opm/parser/eclipse/EclipseState/Schedule/Group/GTNode.hpp
opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp
opm/parser/eclipse/EclipseState/Schedule/Group/GuideRate.hpp
@@ -704,8 +735,8 @@ if(ENABLE_ECL_INPUT)
opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.hpp
opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.hpp
opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.hpp
opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.hpp
opm/parser/eclipse/EclipseState/Schedule/MSW/SpiralICD.hpp
opm/parser/eclipse/EclipseState/Schedule/MSW/AICD.hpp
opm/parser/eclipse/EclipseState/Schedule/MSW/SICD.hpp
opm/parser/eclipse/EclipseState/SimulationConfig/ThresholdPressure.hpp
opm/parser/eclipse/EclipseState/SimulationConfig/BCConfig.hpp
opm/parser/eclipse/EclipseState/SimulationConfig/RockConfig.hpp
@@ -719,6 +750,7 @@ if(ENABLE_ECL_INPUT)
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQASTNode.hpp
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQDefine.hpp
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQContext.hpp
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQState.hpp
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.hpp
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQParams.hpp
@@ -760,9 +792,10 @@ if(ENABLE_ECL_OUTPUT)
opm/io/eclipse/rst/well.hpp
opm/output/data/Aquifer.hpp
opm/output/data/Cells.hpp
opm/output/data/GuideRateValue.hpp
opm/output/data/Groups.hpp
opm/output/data/Solution.hpp
opm/output/data/Wells.hpp
opm/output/data/Groups.hpp
opm/output/eclipse/VectorItems/aquifer.hpp
opm/output/eclipse/VectorItems/connection.hpp
opm/output/eclipse/VectorItems/group.hpp

View File

@@ -20,7 +20,7 @@ set(genkw_SOURCES src/opm/json/JsonObject.cpp
src/opm/parser/eclipse/Parser/raw/StarToken.cpp
src/opm/parser/eclipse/Units/Dimension.cpp
src/opm/parser/eclipse/Units/UnitSystem.cpp
src/opm/parser/eclipse/Utility/Stringview.cpp
src/opm/common/utility/OpmInputError.cpp
src/opm/common/OpmLog/OpmLog.cpp
src/opm/common/OpmLog/Logger.cpp
src/opm/common/OpmLog/StreamLog.cpp

View File

@@ -60,6 +60,19 @@ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${MPI_C_COMPILE_FLAGS}")
include(CheckIncludeFile)
check_include_file(parmetis.h PARMETIS_FOUND)
if(NOT PARMETIS_FOUND)
# If we are using the ParMETIS bindings of PTScotch, we need
# to use the scotch include path as partmetis.h includes scotch.h
find_package(PTScotch)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${PTSCOTCH_INCLUDE_DIR})
unset(PARMETIS_FOUND CACHE) # force recheck of include file
check_include_file(parmetis.h PARMETIS_FOUND)
if(PARMETIS_FOUND)
set(PARMETIS_SCOTCH_INCLUDE_DIRS ${PTSCOTCH_INCLUDE_DIRS})
endif()
endif()
_search_parmetis_lib(PARMETIS_LIBRARY parmetis "The main ParMETIS library.")
# behave like a CMake module is supposed to behave
@@ -77,7 +90,7 @@ find_package_handle_standard_args(
cmake_pop_check_state()
if(PARMETIS_FOUND)
set(PARMETIS_INCLUDE_DIRS ${PARMETIS_INCLUDE_DIR})
set(PARMETIS_INCLUDE_DIRS ${PARMETIS_INCLUDE_DIR} ${PARMETIS_SCOTCH_INCLUDE_DIRS})
set(PARMETIS_LIBRARIES ${PARMETIS_LIBRARY} ${METIS_LIBRARIES} ${MPI_C_LIBRARIES}
CACHE FILEPATH "All libraries needed to link programs using ParMETIS")
set(PARMETIS_LINK_FLAGS "${DUNE_C_LINK_FLAGS}"

View File

@@ -16,6 +16,9 @@ if(ZOLTAN_ROOT)
set(ZOLTAN_NO_DEFAULT_PATH "NO_DEFAULT_PATH")
endif()
# We only need zoltan with MPI. Otherwise usage of alugrid is broken.
find_package(MPI)
# Make sure we have checked for the underlying partitioners.
find_package(PTScotch)
#find_package(ParMETIS)
@@ -39,20 +42,23 @@ find_library(ZOLTAN_LIBRARIES
${ZOLTAN_NO_DEFAULT_PATH})
set (ZOLTAN_FOUND FALSE)
if (ZOLTAN_INCLUDE_DIRS OR ZOLTAN_LIBRARIES)
set(ZOLTAN_FOUND TRUE)
set (ZOLTAN_CONFIG_VAR HAVE_ZOLTAN)
# print a message to indicate status of this package
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args(ZOLTAN
DEFAULT_MSG
ZOLTAN_LIBRARIES
ZOLTAN_INCLUDE_DIRS
MPI_FOUND
)
if (ZOLTAN_FOUND)
set(HAVE_ZOLTAN 1)
set(ZOLTAN_LIBRARIES ${ZOLTAN_LIBRARIES} ${PARMETIS_LIBRARIES} ${PTSCOTCH_LIBRARIES})
set(ZOLTAN_INCLUDE_DIRS ${ZOLTAN_INCLUDE_DIRS} ${PARMETIS_INCLUDE_DIRS}
${PTSCOTCH_INCLUDE_DIRS})
endif()
set (ZOLTAN_CONFIG_VAR HAVE_ZOLTAN)
# print a message to indicate status of this package
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args(ZOLTAN
DEFAULT_MSG
ZOLTAN_LIBRARIES
ZOLTAN_INCLUDE_DIRS
)

View File

@@ -33,8 +33,7 @@ find_opm_package (
# test program
"#include <dune/geometry/quadraturerules.hh>
int main (void) {
Dune::GeometryType gt;
gt.makeQuadrilateral();
Dune::GeometryType gt = Dune::GeometryTypes::quadrilateral;
Dune::QuadratureRules<double, 2>::rule(gt, 2).size();
return 0;
}

View File

@@ -5,6 +5,8 @@ is_compiler_gcc_compatible ()
include(TestCXXAcceptsFlag)
macro (opm_defaults opm)
message("Processing opm_defaults ${opm}")
# if we are installing a development version (default when checking out of
# VCS), then remember which directories were used when configuring. package
# distribution should disable this option.

View File

@@ -106,8 +106,13 @@ macro (find_and_append_package_to prefix name)
# if we're told not to look for the package, pretend it was never found
if (CMAKE_DISABLE_FIND_PACKAGE_${name})
set (${name}_FOUND FALSE)
set (${NAME}_FOUND FALSE)
# If required send an error
cmake_parse_arguments(FIND "REQUIRED" "" "" ${ARGN} )
set (${name}_FOUND FALSE)
set (${NAME}_FOUND FALSE)
if (FIND_REQUIRED)
message(SEND_ERROR "package ${name} but disable with CMAKE_DISABLE_FIND_PACKAGE_${name}")
endif ()
else ()
# List of components might differ for every module. Therefore we will
# need to research for a library multiple times. _search_components

View File

@@ -62,7 +62,10 @@ include (UseOptimization)
# turn on all warnings; this must be done before adding any
# dependencies, in case they alter the list of warnings
include (UseWarnings)
option(OPM_DISABLE_WARNINGS "Disable warning flags" OFF)
if(NOT OPM_DISABLE_WARNINGS)
include (UseWarnings)
endif()
# parallel programming
include (UseOpenMP)

View File

@@ -115,26 +115,34 @@ macro (find_opm_package module deps header lib defs prog conf)
# without config.h
config_cmd_line (${module}_CMD_CONFIG ${module}_CONFIG_VARS)
# check that we can compile a small test-program
include (CMakePushCheckState)
cmake_push_check_state ()
include (CheckCXXSourceCompiles)
# only add these if they are actually found; otherwise it won't
# compile and the variable won't be set
append_found (${module}_INCLUDE_DIRS CMAKE_REQUIRED_INCLUDES)
append_found (${module}_LIBRARIES CMAKE_REQUIRED_LIBRARIES)
# since we don't have any config.h yet
list (APPEND CMAKE_REQUIRED_DEFINITIONS ${${module}_DEFINITIONS})
list (APPEND CMAKE_REQUIRED_DEFINITIONS ${${module}_CMD_CONFIG})
check_cxx_source_compiles ("${prog}" HAVE_${MODULE})
cmake_pop_check_state ()
if(prog)
# check that we can compile a small test-program
include (CMakePushCheckState)
cmake_push_check_state ()
include (CheckCXXSourceCompiles)
# only add these if they are actually found; otherwise it won't
# compile and the variable won't be set
append_found (${module}_INCLUDE_DIRS CMAKE_REQUIRED_INCLUDES)
append_found (${module}_LIBRARIES CMAKE_REQUIRED_LIBRARIES)
# since we don't have any config.h yet
list (APPEND CMAKE_REQUIRED_DEFINITIONS ${${module}_DEFINITIONS})
list (APPEND CMAKE_REQUIRED_DEFINITIONS ${${module}_CMD_CONFIG})
check_cxx_source_compiles ("${prog}" HAVE_${MODULE})
cmake_pop_check_state ()
else(prog)
if(${module}_FOUND)
# No test code provided, mark compilation as successful
# if module was founf
set(HAVE_${MODULE} 1)
endif(${module}_FOUND)
endif(prog)
# write status message in the same manner as everyone else
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (
${module}
DEFAULT_MSG
${module}_INCLUDE_DIRS ${module}_LIBRARIES ${module}_FOUND ${module}_ALL_PREREQS
${module}_INCLUDE_DIRS ${module}_LIBRARIES ${module}_FOUND ${module}_ALL_PREREQS HAVE_${MODULE}
)
# some genius that coded the FindPackageHandleStandardArgs figured out

View File

@@ -42,7 +42,13 @@ macro (find_openmp opm)
# enabling OpenMP is supposedly enough to make the compiler link with
# the appropriate libraries
find_package (OpenMP ${${opm}_QUIET})
list (APPEND ${opm}_LIBRARIES ${OpenMP_LIBRARIES})
if(OpenMP_CXX_FOUND)
list (APPEND ${opm}_LIBRARIES OpenMP::OpenMP_CXX)
else()
list (APPEND ${opm}_LIBRARIES ${OpenMP_LIBRARIES})
endif()
if (OPENMP_FOUND)
add_options (C ALL_BUILDS "${OpenMP_C_FLAGS}")
add_options (CXX ALL_BUILDS "${OpenMP_CXX_FLAGS}")

View File

@@ -24,9 +24,16 @@ if (cmake_build_type_upper_ MATCHES DEBUG)
"#define PROJECT_VERSION_NAME \"${${project}_LABEL}\"\n"
"#define PROJECT_VERSION_HASH \"debug\"\n"
"#define PROJECT_VERSION \"${${project}_LABEL} (debug)\"\n"
"#define BUILD_TIMESTAMP \"${build_timestamp}\"\n"
"#endif // OPM_GENERATED_OPM_VERSION_HEADER_INCLUDED\n"
)
# Write header file with build timestamp
file (WRITE "${PROJECT_BINARY_DIR}/project-timestamp.h"
"#ifndef OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
"#define OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
"#define BUILD_TIMESTAMP \"${build_timestamp}\"\n"
"#endif // OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
)
else ()
if (NOT GIT_FOUND)
find_package (Git)
@@ -43,9 +50,15 @@ else ()
"#define PROJECT_VERSION_NAME \"${${project}_LABEL}\"\n"
"#define PROJECT_VERSION_HASH \"unknown git version\"\n"
"#define PROJECT_VERSION \"${${project}_LABEL} (unknown git version)\"\n"
"#define BUILD_TIMESTAMP \"${build_timestamp}\"\n"
"#endif // OPM_GENERATED_OPM_VERSION_HEADER_INCLUDED\n"
)
# Write header file with build timestamp
file (WRITE "${PROJECT_BINARY_DIR}/project-timestamp.h"
"#ifndef OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
"#define OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
"#define BUILD_TIMESTAMP \"${build_timestamp}\"\n"
"#endif // OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
)
else ()
add_custom_target (update-version ALL
COMMAND ${CMAKE_COMMAND}

View File

@@ -56,7 +56,6 @@ file (WRITE "${PROJECT_BINARY_DIR}/project-version.tmp"
"#define PROJECT_VERSION_NAME \"${PROJECT_LABEL}\"\n"
"#define PROJECT_VERSION_HASH \"${sha1}\"\n"
"#define PROJECT_VERSION \"${PROJECT_LABEL} (${sha1})\"\n"
"#define BUILD_TIMESTAMP \"${build_timestamp}\"\n"
"#endif // OPM_GENERATED_OPM_VERSION_HEADER_INCLUDED\n"
)
@@ -66,3 +65,11 @@ file (WRITE "${PROJECT_BINARY_DIR}/project-version.tmp"
execute_process (COMMAND
${CMAKE_COMMAND} -E copy_if_different "${PROJECT_BINARY_DIR}/project-version.tmp" "${PROJECT_BINARY_DIR}/project-version.h"
)
# Write header file with build timestamp
file (WRITE "${PROJECT_BINARY_DIR}/project-timestamp.h"
"#ifndef OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
"#define OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
"#define BUILD_TIMESTAMP \"${build_timestamp}\"\n"
"#endif // OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
)

4
debian/control vendored
View File

@@ -16,7 +16,7 @@ Vcs-Browser: https://github.com/OPM/opm-common
Package: libopm-common1
Section: libs
Pre-Depends: ${misc:Pre-Depends}, multiarch-support
Pre-Depends: ${misc:Pre-Depends}
Architecture: any
Multi-Arch: same
Depends: ${shlibs:Depends}, ${misc:Depends}
@@ -56,7 +56,7 @@ Description: OPM common library -- documentation
Package: python3-opm-common
Section: libs
Pre-Depends: ${misc:Pre-Depends}, multiarch-support
Pre-Depends: ${misc:Pre-Depends}
Architecture: any
Multi-Arch: same
Depends: ${shlibs:Depends}, ${misc:Depends}, libopm-common1, python3-numpy, python3-decorator

View File

@@ -5,8 +5,8 @@
Module: opm-common
Description: Open Porous Media Initiative shared infrastructure
Version: 2020.04-pre
Label: 2020.04-pre
Version: 2020.10
Label: 2020.10
Maintainer: opm@opm-project.org
MaintainerName: OPM community
Url: http://opm-project.org

109
examples/make_lodsmry.cpp Normal file
View File

@@ -0,0 +1,109 @@
/*
Copyright 2019 Equinor ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <getopt.h>
#include <string.h>
#include <stdio.h>
#include "config.h"
#if HAVE_OPENMP
#include <omp.h>
#endif
#include <opm/io/eclipse/ESmry.hpp>
#include <opm/io/eclipse/EclUtil.hpp>
#include <opm/common/utility/FileSystem.hpp>
static void printHelp() {
std::cout << "\nThis program create one or more lodsmry files, designed for effective load on the demand. \n"
<< "These files are created with input from the smspec and unsmry file. \n"
<< "\nIn addition, the program takes these options (which must be given before the arguments):\n\n"
<< "-f if LODSMRY file exist, this will be replaced. Default behaviour is that existing file is kept.\n"
<< "-n Maximum number of threads to be used if mulitple files should be created.\n"
<< "-h Print help and exit.\n\n";
}
int main(int argc, char **argv) {
int c = 0;
int max_threads [[maybe_unused]] = -1;
bool force = false;
while ((c = getopt(argc, argv, "fn:h")) != -1) {
switch (c) {
case 'f':
force = true;
break;
case 'h':
printHelp();
return 0;
case 'n':
max_threads = atoi(optarg);
break;
default:
return EXIT_FAILURE;
}
}
int argOffset = optind;
#if HAVE_OPENMP
int available_threads = omp_get_max_threads();
if (max_threads < 0)
max_threads = available_threads-2;
else if (max_threads > (available_threads - 1))
max_threads = available_threads-1;
if (max_threads > (argc-argOffset))
max_threads = argc-argOffset;
omp_set_num_threads(max_threads);
#endif
auto lap0 = std::chrono::system_clock::now();
#pragma omp parallel for
for (int f = argOffset; f < argc; f ++){
Opm::filesystem::path inputFileName = argv[f];
Opm::filesystem::path lodFileName = inputFileName.parent_path() / inputFileName.stem();
lodFileName = lodFileName += ".LODSMRY";
if (Opm::EclIO::fileExists(lodFileName) && (force))
remove (lodFileName);
Opm::EclIO::ESmry smryFile(argv[f]);
if (!smryFile.make_lodsmry_file()){
std::cout << "\n! Warning, smspec already have one lod file, existing kept use option -f to replace this" << std::endl;
}
}
auto lap1 = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds1 = lap1-lap0;
std::cout << "\nruntime for creating " << (argc-argOffset) << " LODSMRY files: " << elapsed_seconds1.count() << " seconds\n" << std::endl;
return 0;
}

View File

@@ -27,6 +27,7 @@
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/msim/msim.hpp>
@@ -38,10 +39,12 @@ int main(int /* argc */, char** argv) {
Opm::ErrorGuard error_guard;
auto python = std::make_shared<Opm::Python>();
Opm::OpmLog::setupSimpleDefaultLogging();
Opm::Deck deck = parser.parseFile(deck_file, parse_context, error_guard);
Opm::EclipseState state(deck);
Opm::Schedule schedule(deck, state, parse_context, error_guard, python);
Opm::SummaryConfig summary_config(deck, schedule, state.getTableManager(), parse_context, error_guard);
Opm::SummaryConfig summary_config(deck, schedule, state.getTableManager(), state.aquifer(),
parse_context, error_guard);
if (error_guard) {
error_guard.dump();

View File

@@ -18,10 +18,10 @@
*/
#include <getopt.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <fmt/format.h>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
@@ -85,12 +85,11 @@ std::size_t deck_hash(const std::vector<keyword>& keywords) {
void print_keywords(const std::vector<keyword>& keywords, bool location_info) {
for (const auto& kw : keywords) {
if (location_info)
std::cout << std::setw(8) << std::left << kw.name << " : " << kw.filename << ":" << kw.line_number << " " << kw.content_hash << std::endl;
fmt::print("{:8s} : {}:{} {} \n", kw.name, kw.filename, kw.line_number, kw.content_hash);
else
std::cout << std::setw(8) << std::left << kw.name << " : " << kw.content_hash << std::endl;
fmt::print("{:8s} : {} \n", kw.name, kw.content_hash);
}
std::cout << std::endl;
std::cout << std::setw(8) << std::left << "Total" << " : " << deck_hash(keywords) << std::endl;
fmt::print("\n{:8s} : {}\n", "Total", deck_hash(keywords));
}

View File

@@ -70,7 +70,8 @@ inline void loadDeck( const char * deck_file) {
std::cout << "creating SummaryConfig .... "; std::cout.flush();
start = std::chrono::system_clock::now();
Opm::SummaryConfig summary( deck, schedule, state.getTableManager( ), parseContext, errors );
Opm::SummaryConfig summary( deck, schedule, state.getTableManager( ), state.aquifer(),
parseContext, errors );
auto summary_time = std::chrono::system_clock::now() - start;
std::cout << "complete." << std::endl << std::endl;

135
examples/wellgraph.cpp Normal file
View File

@@ -0,0 +1,135 @@
/*
Copyright 2013, 2020 Equinor ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <fstream>
#include <iomanip>
#include <chrono>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/Python/Python.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/common/OpmLog/StreamLog.hpp>
#include <opm/common/OpmLog/LogUtil.hpp>
#include <opm/common/utility/FileSystem.hpp>
inline void createDot(const Opm::Schedule& schedule, const std::string& casename)
{
std::cout << "Writing " << casename << ".gv .... "; std::cout.flush();
std::ofstream os(casename + ".gv");
os << "// This file was written by the 'wellgraph' utility from OPM.\n";
os << "// Find the source code at github.com/OPM.\n";
os << "// Convert output to PDF with 'dot -Tpdf " << casename << ".gv > " << casename << ".pdf'\n";
os << "strict digraph \"" << casename << "\"\n{\n";
const auto groupnames = schedule.groupNames();
const std::size_t last = schedule.getTimeMap().last();
// Group -> Group relations.
for (const auto& gn : groupnames) {
const auto& g = schedule.getGroup(gn, last);
const auto& children = g.groups();
if (!children.empty()) {
os << " \"" << gn << "\" -> {";
for (const auto& child : children) {
os << " \"" << child << '"';
}
os << " }\n";
}
}
// Group -> Well relations.
os << " node [shape=box]\n";
for (const auto& gn : groupnames) {
const auto& g = schedule.getGroup(gn, last);
const auto& children = g.wells();
if (!children.empty()) {
os << " \"" << gn << "\" -> {";
for (const auto& child : children) {
os << " \"" << child << '"';
}
os << " }\n";
}
}
// Color wells by injector or producer.
for (const auto& w : schedule.getWellsatEnd()) {
os << " \"" << w.name() << '"';
if (w.isProducer() && w.isInjector()) {
os << " [color=purple]\n";
} else if (w.isProducer()) {
os << " [color=red]\n";
} else {
os << " [color=blue]\n";
}
}
os << "}\n";
std::cout << "complete." << std::endl;
}
inline Opm::Schedule loadSchedule(const std::string& deck_file)
{
Opm::ParseContext parseContext({{Opm::ParseContext::PARSE_RANDOM_SLASH, Opm::InputError::IGNORE},
{Opm::ParseContext::PARSE_MISSING_DIMS_KEYWORD, Opm::InputError::WARN},
{Opm::ParseContext::SUMMARY_UNKNOWN_WELL, Opm::InputError::WARN},
{Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputError::WARN}});
Opm::ErrorGuard errors;
Opm::Parser parser;
auto python = std::make_shared<Opm::Python>();
std::cout << "Loading and parsing deck: " << deck_file << " ..... "; std::cout.flush();
auto deck = parser.parseFile(deck_file, parseContext, errors);
std::cout << "complete.\n";
std::cout << "Creating EclipseState .... "; std::cout.flush();
Opm::EclipseState state( deck );
std::cout << "complete.\n";
std::cout << "Creating Schedule .... "; std::cout.flush();
Opm::Schedule schedule( deck, state, python);
std::cout << "complete." << std::endl;
return schedule;
}
int main(int argc, char** argv)
{
std::ostringstream os;
std::shared_ptr<Opm::StreamLog> string_log = std::make_shared<Opm::StreamLog>(os, Opm::Log::DefaultMessageTypes);
Opm::OpmLog::addBackend( "STRING" , string_log);
try {
for (int iarg = 1; iarg < argc; iarg++) {
const std::string filename = argv[iarg];
const auto sched = loadSchedule(filename);
const auto casename = Opm::filesystem::path(filename).stem();
createDot(sched, casename);
}
} catch (const std::exception& e) {
std::cout << "\n\n***** Caught an exception: " << e.what() << std::endl;
std::cout << "\n\n***** Printing log: "<< std::endl;
std::cout << os.str();
std::cout << "\n\n***** Exiting due to errors." << std::endl;
}
}

27
external/fmtlib/LICENSE.rst vendored Normal file
View File

@@ -0,0 +1,27 @@
Copyright (c) 2012 - present, Victor Zverovich
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--- Optional exception to the license ---
As an exception, if, as a result of your compiling your source code, portions
of this Software are embedded into a machine-executable object form of such
source code, you may redistribute such embedded portions in such object form
without including the above copyright and permission notices.

12
external/fmtlib/README.opm vendored Normal file
View File

@@ -0,0 +1,12 @@
The include/ directory is a copy of the include directory from version 7.0.3 of
the fmtlib distribution. The fmtlib can be found at https://github.com/fmtlib/fmt
The fmtlib code embedded here should be compiled in header only mode, to ensure
that the symbol FMT_HEADER_ONLY must be defined before the the fmt/format.h
header is included:
#define FMT_HEADER_ONLY
#include <fmt/format.h>
....
auto msg = fmt::format("Hello {}", "world");

1123
external/fmtlib/include/fmt/chrono.h vendored Normal file

File diff suppressed because it is too large Load Diff

566
external/fmtlib/include/fmt/color.h vendored Normal file
View File

@@ -0,0 +1,566 @@
// Formatting library for C++ - color support
//
// Copyright (c) 2018 - present, Victor Zverovich and fmt contributors
// All rights reserved.
//
// For the license information refer to format.h.
#ifndef FMT_COLOR_H_
#define FMT_COLOR_H_
#include "format.h"
FMT_BEGIN_NAMESPACE
enum class color : uint32_t {
alice_blue = 0xF0F8FF, // rgb(240,248,255)
antique_white = 0xFAEBD7, // rgb(250,235,215)
aqua = 0x00FFFF, // rgb(0,255,255)
aquamarine = 0x7FFFD4, // rgb(127,255,212)
azure = 0xF0FFFF, // rgb(240,255,255)
beige = 0xF5F5DC, // rgb(245,245,220)
bisque = 0xFFE4C4, // rgb(255,228,196)
black = 0x000000, // rgb(0,0,0)
blanched_almond = 0xFFEBCD, // rgb(255,235,205)
blue = 0x0000FF, // rgb(0,0,255)
blue_violet = 0x8A2BE2, // rgb(138,43,226)
brown = 0xA52A2A, // rgb(165,42,42)
burly_wood = 0xDEB887, // rgb(222,184,135)
cadet_blue = 0x5F9EA0, // rgb(95,158,160)
chartreuse = 0x7FFF00, // rgb(127,255,0)
chocolate = 0xD2691E, // rgb(210,105,30)
coral = 0xFF7F50, // rgb(255,127,80)
cornflower_blue = 0x6495ED, // rgb(100,149,237)
cornsilk = 0xFFF8DC, // rgb(255,248,220)
crimson = 0xDC143C, // rgb(220,20,60)
cyan = 0x00FFFF, // rgb(0,255,255)
dark_blue = 0x00008B, // rgb(0,0,139)
dark_cyan = 0x008B8B, // rgb(0,139,139)
dark_golden_rod = 0xB8860B, // rgb(184,134,11)
dark_gray = 0xA9A9A9, // rgb(169,169,169)
dark_green = 0x006400, // rgb(0,100,0)
dark_khaki = 0xBDB76B, // rgb(189,183,107)
dark_magenta = 0x8B008B, // rgb(139,0,139)
dark_olive_green = 0x556B2F, // rgb(85,107,47)
dark_orange = 0xFF8C00, // rgb(255,140,0)
dark_orchid = 0x9932CC, // rgb(153,50,204)
dark_red = 0x8B0000, // rgb(139,0,0)
dark_salmon = 0xE9967A, // rgb(233,150,122)
dark_sea_green = 0x8FBC8F, // rgb(143,188,143)
dark_slate_blue = 0x483D8B, // rgb(72,61,139)
dark_slate_gray = 0x2F4F4F, // rgb(47,79,79)
dark_turquoise = 0x00CED1, // rgb(0,206,209)
dark_violet = 0x9400D3, // rgb(148,0,211)
deep_pink = 0xFF1493, // rgb(255,20,147)
deep_sky_blue = 0x00BFFF, // rgb(0,191,255)
dim_gray = 0x696969, // rgb(105,105,105)
dodger_blue = 0x1E90FF, // rgb(30,144,255)
fire_brick = 0xB22222, // rgb(178,34,34)
floral_white = 0xFFFAF0, // rgb(255,250,240)
forest_green = 0x228B22, // rgb(34,139,34)
fuchsia = 0xFF00FF, // rgb(255,0,255)
gainsboro = 0xDCDCDC, // rgb(220,220,220)
ghost_white = 0xF8F8FF, // rgb(248,248,255)
gold = 0xFFD700, // rgb(255,215,0)
golden_rod = 0xDAA520, // rgb(218,165,32)
gray = 0x808080, // rgb(128,128,128)
green = 0x008000, // rgb(0,128,0)
green_yellow = 0xADFF2F, // rgb(173,255,47)
honey_dew = 0xF0FFF0, // rgb(240,255,240)
hot_pink = 0xFF69B4, // rgb(255,105,180)
indian_red = 0xCD5C5C, // rgb(205,92,92)
indigo = 0x4B0082, // rgb(75,0,130)
ivory = 0xFFFFF0, // rgb(255,255,240)
khaki = 0xF0E68C, // rgb(240,230,140)
lavender = 0xE6E6FA, // rgb(230,230,250)
lavender_blush = 0xFFF0F5, // rgb(255,240,245)
lawn_green = 0x7CFC00, // rgb(124,252,0)
lemon_chiffon = 0xFFFACD, // rgb(255,250,205)
light_blue = 0xADD8E6, // rgb(173,216,230)
light_coral = 0xF08080, // rgb(240,128,128)
light_cyan = 0xE0FFFF, // rgb(224,255,255)
light_golden_rod_yellow = 0xFAFAD2, // rgb(250,250,210)
light_gray = 0xD3D3D3, // rgb(211,211,211)
light_green = 0x90EE90, // rgb(144,238,144)
light_pink = 0xFFB6C1, // rgb(255,182,193)
light_salmon = 0xFFA07A, // rgb(255,160,122)
light_sea_green = 0x20B2AA, // rgb(32,178,170)
light_sky_blue = 0x87CEFA, // rgb(135,206,250)
light_slate_gray = 0x778899, // rgb(119,136,153)
light_steel_blue = 0xB0C4DE, // rgb(176,196,222)
light_yellow = 0xFFFFE0, // rgb(255,255,224)
lime = 0x00FF00, // rgb(0,255,0)
lime_green = 0x32CD32, // rgb(50,205,50)
linen = 0xFAF0E6, // rgb(250,240,230)
magenta = 0xFF00FF, // rgb(255,0,255)
maroon = 0x800000, // rgb(128,0,0)
medium_aquamarine = 0x66CDAA, // rgb(102,205,170)
medium_blue = 0x0000CD, // rgb(0,0,205)
medium_orchid = 0xBA55D3, // rgb(186,85,211)
medium_purple = 0x9370DB, // rgb(147,112,219)
medium_sea_green = 0x3CB371, // rgb(60,179,113)
medium_slate_blue = 0x7B68EE, // rgb(123,104,238)
medium_spring_green = 0x00FA9A, // rgb(0,250,154)
medium_turquoise = 0x48D1CC, // rgb(72,209,204)
medium_violet_red = 0xC71585, // rgb(199,21,133)
midnight_blue = 0x191970, // rgb(25,25,112)
mint_cream = 0xF5FFFA, // rgb(245,255,250)
misty_rose = 0xFFE4E1, // rgb(255,228,225)
moccasin = 0xFFE4B5, // rgb(255,228,181)
navajo_white = 0xFFDEAD, // rgb(255,222,173)
navy = 0x000080, // rgb(0,0,128)
old_lace = 0xFDF5E6, // rgb(253,245,230)
olive = 0x808000, // rgb(128,128,0)
olive_drab = 0x6B8E23, // rgb(107,142,35)
orange = 0xFFA500, // rgb(255,165,0)
orange_red = 0xFF4500, // rgb(255,69,0)
orchid = 0xDA70D6, // rgb(218,112,214)
pale_golden_rod = 0xEEE8AA, // rgb(238,232,170)
pale_green = 0x98FB98, // rgb(152,251,152)
pale_turquoise = 0xAFEEEE, // rgb(175,238,238)
pale_violet_red = 0xDB7093, // rgb(219,112,147)
papaya_whip = 0xFFEFD5, // rgb(255,239,213)
peach_puff = 0xFFDAB9, // rgb(255,218,185)
peru = 0xCD853F, // rgb(205,133,63)
pink = 0xFFC0CB, // rgb(255,192,203)
plum = 0xDDA0DD, // rgb(221,160,221)
powder_blue = 0xB0E0E6, // rgb(176,224,230)
purple = 0x800080, // rgb(128,0,128)
rebecca_purple = 0x663399, // rgb(102,51,153)
red = 0xFF0000, // rgb(255,0,0)
rosy_brown = 0xBC8F8F, // rgb(188,143,143)
royal_blue = 0x4169E1, // rgb(65,105,225)
saddle_brown = 0x8B4513, // rgb(139,69,19)
salmon = 0xFA8072, // rgb(250,128,114)
sandy_brown = 0xF4A460, // rgb(244,164,96)
sea_green = 0x2E8B57, // rgb(46,139,87)
sea_shell = 0xFFF5EE, // rgb(255,245,238)
sienna = 0xA0522D, // rgb(160,82,45)
silver = 0xC0C0C0, // rgb(192,192,192)
sky_blue = 0x87CEEB, // rgb(135,206,235)
slate_blue = 0x6A5ACD, // rgb(106,90,205)
slate_gray = 0x708090, // rgb(112,128,144)
snow = 0xFFFAFA, // rgb(255,250,250)
spring_green = 0x00FF7F, // rgb(0,255,127)
steel_blue = 0x4682B4, // rgb(70,130,180)
tan = 0xD2B48C, // rgb(210,180,140)
teal = 0x008080, // rgb(0,128,128)
thistle = 0xD8BFD8, // rgb(216,191,216)
tomato = 0xFF6347, // rgb(255,99,71)
turquoise = 0x40E0D0, // rgb(64,224,208)
violet = 0xEE82EE, // rgb(238,130,238)
wheat = 0xF5DEB3, // rgb(245,222,179)
white = 0xFFFFFF, // rgb(255,255,255)
white_smoke = 0xF5F5F5, // rgb(245,245,245)
yellow = 0xFFFF00, // rgb(255,255,0)
yellow_green = 0x9ACD32 // rgb(154,205,50)
}; // enum class color
enum class terminal_color : uint8_t {
black = 30,
red,
green,
yellow,
blue,
magenta,
cyan,
white,
bright_black = 90,
bright_red,
bright_green,
bright_yellow,
bright_blue,
bright_magenta,
bright_cyan,
bright_white
};
enum class emphasis : uint8_t {
bold = 1,
italic = 1 << 1,
underline = 1 << 2,
strikethrough = 1 << 3
};
// rgb is a struct for red, green and blue colors.
// Using the name "rgb" makes some editors show the color in a tooltip.
struct rgb {
FMT_CONSTEXPR rgb() : r(0), g(0), b(0) {}
FMT_CONSTEXPR rgb(uint8_t r_, uint8_t g_, uint8_t b_) : r(r_), g(g_), b(b_) {}
FMT_CONSTEXPR rgb(uint32_t hex)
: r((hex >> 16) & 0xFF), g((hex >> 8) & 0xFF), b(hex & 0xFF) {}
FMT_CONSTEXPR rgb(color hex)
: r((uint32_t(hex) >> 16) & 0xFF),
g((uint32_t(hex) >> 8) & 0xFF),
b(uint32_t(hex) & 0xFF) {}
uint8_t r;
uint8_t g;
uint8_t b;
};
namespace detail {
// color is a struct of either a rgb color or a terminal color.
struct color_type {
FMT_CONSTEXPR color_type() FMT_NOEXCEPT : is_rgb(), value{} {}
FMT_CONSTEXPR color_type(color rgb_color) FMT_NOEXCEPT : is_rgb(true),
value{} {
value.rgb_color = static_cast<uint32_t>(rgb_color);
}
FMT_CONSTEXPR color_type(rgb rgb_color) FMT_NOEXCEPT : is_rgb(true), value{} {
value.rgb_color = (static_cast<uint32_t>(rgb_color.r) << 16) |
(static_cast<uint32_t>(rgb_color.g) << 8) | rgb_color.b;
}
FMT_CONSTEXPR color_type(terminal_color term_color) FMT_NOEXCEPT : is_rgb(),
value{} {
value.term_color = static_cast<uint8_t>(term_color);
}
bool is_rgb;
union color_union {
uint8_t term_color;
uint32_t rgb_color;
} value;
};
} // namespace detail
// Experimental text formatting support.
class text_style {
public:
FMT_CONSTEXPR text_style(emphasis em = emphasis()) FMT_NOEXCEPT
: set_foreground_color(),
set_background_color(),
ems(em) {}
FMT_CONSTEXPR text_style& operator|=(const text_style& rhs) {
if (!set_foreground_color) {
set_foreground_color = rhs.set_foreground_color;
foreground_color = rhs.foreground_color;
} else if (rhs.set_foreground_color) {
if (!foreground_color.is_rgb || !rhs.foreground_color.is_rgb)
FMT_THROW(format_error("can't OR a terminal color"));
foreground_color.value.rgb_color |= rhs.foreground_color.value.rgb_color;
}
if (!set_background_color) {
set_background_color = rhs.set_background_color;
background_color = rhs.background_color;
} else if (rhs.set_background_color) {
if (!background_color.is_rgb || !rhs.background_color.is_rgb)
FMT_THROW(format_error("can't OR a terminal color"));
background_color.value.rgb_color |= rhs.background_color.value.rgb_color;
}
ems = static_cast<emphasis>(static_cast<uint8_t>(ems) |
static_cast<uint8_t>(rhs.ems));
return *this;
}
friend FMT_CONSTEXPR text_style operator|(text_style lhs,
const text_style& rhs) {
return lhs |= rhs;
}
FMT_CONSTEXPR text_style& operator&=(const text_style& rhs) {
if (!set_foreground_color) {
set_foreground_color = rhs.set_foreground_color;
foreground_color = rhs.foreground_color;
} else if (rhs.set_foreground_color) {
if (!foreground_color.is_rgb || !rhs.foreground_color.is_rgb)
FMT_THROW(format_error("can't AND a terminal color"));
foreground_color.value.rgb_color &= rhs.foreground_color.value.rgb_color;
}
if (!set_background_color) {
set_background_color = rhs.set_background_color;
background_color = rhs.background_color;
} else if (rhs.set_background_color) {
if (!background_color.is_rgb || !rhs.background_color.is_rgb)
FMT_THROW(format_error("can't AND a terminal color"));
background_color.value.rgb_color &= rhs.background_color.value.rgb_color;
}
ems = static_cast<emphasis>(static_cast<uint8_t>(ems) &
static_cast<uint8_t>(rhs.ems));
return *this;
}
friend FMT_CONSTEXPR text_style operator&(text_style lhs,
const text_style& rhs) {
return lhs &= rhs;
}
FMT_CONSTEXPR bool has_foreground() const FMT_NOEXCEPT {
return set_foreground_color;
}
FMT_CONSTEXPR bool has_background() const FMT_NOEXCEPT {
return set_background_color;
}
FMT_CONSTEXPR bool has_emphasis() const FMT_NOEXCEPT {
return static_cast<uint8_t>(ems) != 0;
}
FMT_CONSTEXPR detail::color_type get_foreground() const FMT_NOEXCEPT {
FMT_ASSERT(has_foreground(), "no foreground specified for this style");
return foreground_color;
}
FMT_CONSTEXPR detail::color_type get_background() const FMT_NOEXCEPT {
FMT_ASSERT(has_background(), "no background specified for this style");
return background_color;
}
FMT_CONSTEXPR emphasis get_emphasis() const FMT_NOEXCEPT {
FMT_ASSERT(has_emphasis(), "no emphasis specified for this style");
return ems;
}
private:
FMT_CONSTEXPR text_style(bool is_foreground,
detail::color_type text_color) FMT_NOEXCEPT
: set_foreground_color(),
set_background_color(),
ems() {
if (is_foreground) {
foreground_color = text_color;
set_foreground_color = true;
} else {
background_color = text_color;
set_background_color = true;
}
}
friend FMT_CONSTEXPR_DECL text_style fg(detail::color_type foreground)
FMT_NOEXCEPT;
friend FMT_CONSTEXPR_DECL text_style bg(detail::color_type background)
FMT_NOEXCEPT;
detail::color_type foreground_color;
detail::color_type background_color;
bool set_foreground_color;
bool set_background_color;
emphasis ems;
};
FMT_CONSTEXPR text_style fg(detail::color_type foreground) FMT_NOEXCEPT {
return text_style(/*is_foreground=*/true, foreground);
}
FMT_CONSTEXPR text_style bg(detail::color_type background) FMT_NOEXCEPT {
return text_style(/*is_foreground=*/false, background);
}
FMT_CONSTEXPR text_style operator|(emphasis lhs, emphasis rhs) FMT_NOEXCEPT {
return text_style(lhs) | rhs;
}
namespace detail {
template <typename Char> struct ansi_color_escape {
FMT_CONSTEXPR ansi_color_escape(detail::color_type text_color,
const char* esc) FMT_NOEXCEPT {
// If we have a terminal color, we need to output another escape code
// sequence.
if (!text_color.is_rgb) {
bool is_background = esc == detail::data::background_color;
uint32_t value = text_color.value.term_color;
// Background ASCII codes are the same as the foreground ones but with
// 10 more.
if (is_background) value += 10u;
size_t index = 0;
buffer[index++] = static_cast<Char>('\x1b');
buffer[index++] = static_cast<Char>('[');
if (value >= 100u) {
buffer[index++] = static_cast<Char>('1');
value %= 100u;
}
buffer[index++] = static_cast<Char>('0' + value / 10u);
buffer[index++] = static_cast<Char>('0' + value % 10u);
buffer[index++] = static_cast<Char>('m');
buffer[index++] = static_cast<Char>('\0');
return;
}
for (int i = 0; i < 7; i++) {
buffer[i] = static_cast<Char>(esc[i]);
}
rgb color(text_color.value.rgb_color);
to_esc(color.r, buffer + 7, ';');
to_esc(color.g, buffer + 11, ';');
to_esc(color.b, buffer + 15, 'm');
buffer[19] = static_cast<Char>(0);
}
FMT_CONSTEXPR ansi_color_escape(emphasis em) FMT_NOEXCEPT {
uint8_t em_codes[4] = {};
uint8_t em_bits = static_cast<uint8_t>(em);
if (em_bits & static_cast<uint8_t>(emphasis::bold)) em_codes[0] = 1;
if (em_bits & static_cast<uint8_t>(emphasis::italic)) em_codes[1] = 3;
if (em_bits & static_cast<uint8_t>(emphasis::underline)) em_codes[2] = 4;
if (em_bits & static_cast<uint8_t>(emphasis::strikethrough))
em_codes[3] = 9;
size_t index = 0;
for (int i = 0; i < 4; ++i) {
if (!em_codes[i]) continue;
buffer[index++] = static_cast<Char>('\x1b');
buffer[index++] = static_cast<Char>('[');
buffer[index++] = static_cast<Char>('0' + em_codes[i]);
buffer[index++] = static_cast<Char>('m');
}
buffer[index++] = static_cast<Char>(0);
}
FMT_CONSTEXPR operator const Char*() const FMT_NOEXCEPT { return buffer; }
FMT_CONSTEXPR const Char* begin() const FMT_NOEXCEPT { return buffer; }
FMT_CONSTEXPR const Char* end() const FMT_NOEXCEPT {
return buffer + std::char_traits<Char>::length(buffer);
}
private:
Char buffer[7u + 3u * 4u + 1u];
static FMT_CONSTEXPR void to_esc(uint8_t c, Char* out,
char delimiter) FMT_NOEXCEPT {
out[0] = static_cast<Char>('0' + c / 100);
out[1] = static_cast<Char>('0' + c / 10 % 10);
out[2] = static_cast<Char>('0' + c % 10);
out[3] = static_cast<Char>(delimiter);
}
};
template <typename Char>
FMT_CONSTEXPR ansi_color_escape<Char> make_foreground_color(
detail::color_type foreground) FMT_NOEXCEPT {
return ansi_color_escape<Char>(foreground, detail::data::foreground_color);
}
template <typename Char>
FMT_CONSTEXPR ansi_color_escape<Char> make_background_color(
detail::color_type background) FMT_NOEXCEPT {
return ansi_color_escape<Char>(background, detail::data::background_color);
}
template <typename Char>
FMT_CONSTEXPR ansi_color_escape<Char> make_emphasis(emphasis em) FMT_NOEXCEPT {
return ansi_color_escape<Char>(em);
}
template <typename Char>
inline void fputs(const Char* chars, FILE* stream) FMT_NOEXCEPT {
std::fputs(chars, stream);
}
template <>
inline void fputs<wchar_t>(const wchar_t* chars, FILE* stream) FMT_NOEXCEPT {
std::fputws(chars, stream);
}
template <typename Char> inline void reset_color(FILE* stream) FMT_NOEXCEPT {
fputs(detail::data::reset_color, stream);
}
template <> inline void reset_color<wchar_t>(FILE* stream) FMT_NOEXCEPT {
fputs(detail::data::wreset_color, stream);
}
template <typename Char>
inline void reset_color(basic_memory_buffer<Char>& buffer) FMT_NOEXCEPT {
const char* begin = data::reset_color;
const char* end = begin + sizeof(data::reset_color) - 1;
buffer.append(begin, end);
}
template <typename Char>
void vformat_to(basic_memory_buffer<Char>& buf, const text_style& ts,
basic_string_view<Char> format_str,
basic_format_args<buffer_context<Char>> args) {
bool has_style = false;
if (ts.has_emphasis()) {
has_style = true;
auto emphasis = detail::make_emphasis<Char>(ts.get_emphasis());
buf.append(emphasis.begin(), emphasis.end());
}
if (ts.has_foreground()) {
has_style = true;
auto foreground = detail::make_foreground_color<Char>(ts.get_foreground());
buf.append(foreground.begin(), foreground.end());
}
if (ts.has_background()) {
has_style = true;
auto background = detail::make_background_color<Char>(ts.get_background());
buf.append(background.begin(), background.end());
}
detail::vformat_to(buf, format_str, args);
if (has_style) detail::reset_color<Char>(buf);
}
} // namespace detail
template <typename S, typename Char = char_t<S>>
void vprint(std::FILE* f, const text_style& ts, const S& format,
basic_format_args<buffer_context<Char>> args) {
basic_memory_buffer<Char> buf;
detail::vformat_to(buf, ts, to_string_view(format), args);
buf.push_back(Char(0));
detail::fputs(buf.data(), f);
}
/**
Formats a string and prints it to the specified file stream using ANSI
escape sequences to specify text formatting.
Example:
fmt::print(fmt::emphasis::bold | fg(fmt::color::red),
"Elapsed time: {0:.2f} seconds", 1.23);
*/
template <typename S, typename... Args,
FMT_ENABLE_IF(detail::is_string<S>::value)>
void print(std::FILE* f, const text_style& ts, const S& format_str,
const Args&... args) {
detail::check_format_string<Args...>(format_str);
using context = buffer_context<char_t<S>>;
format_arg_store<context, Args...> as{args...};
vprint(f, ts, format_str, basic_format_args<context>(as));
}
/**
Formats a string and prints it to stdout using ANSI escape sequences to
specify text formatting.
Example:
fmt::print(fmt::emphasis::bold | fg(fmt::color::red),
"Elapsed time: {0:.2f} seconds", 1.23);
*/
template <typename S, typename... Args,
FMT_ENABLE_IF(detail::is_string<S>::value)>
void print(const text_style& ts, const S& format_str, const Args&... args) {
return print(stdout, ts, format_str, args...);
}
template <typename S, typename Char = char_t<S>>
inline std::basic_string<Char> vformat(
const text_style& ts, const S& format_str,
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
basic_memory_buffer<Char> buf;
detail::vformat_to(buf, ts, to_string_view(format_str), args);
return fmt::to_string(buf);
}
/**
\rst
Formats arguments and returns the result as a string using ANSI
escape sequences to specify text formatting.
**Example**::
#include <fmt/color.h>
std::string message = fmt::format(fmt::emphasis::bold | fg(fmt::color::red),
"The answer is {}", 42);
\endrst
*/
template <typename S, typename... Args, typename Char = char_t<S>>
inline std::basic_string<Char> format(const text_style& ts, const S& format_str,
const Args&... args) {
return vformat(ts, to_string_view(format_str),
detail::make_args_checked<Args...>(format_str, args...));
}
FMT_END_NAMESPACE
#endif // FMT_COLOR_H_

665
external/fmtlib/include/fmt/compile.h vendored Normal file
View File

@@ -0,0 +1,665 @@
// Formatting library for C++ - experimental format string compilation
//
// Copyright (c) 2012 - present, Victor Zverovich and fmt contributors
// All rights reserved.
//
// For the license information refer to format.h.
#ifndef FMT_COMPILE_H_
#define FMT_COMPILE_H_
#include <vector>
#include "format.h"
FMT_BEGIN_NAMESPACE
namespace detail {
// A compile-time string which is compiled into fast formatting code.
class compiled_string {};
template <typename S>
struct is_compiled_string : std::is_base_of<compiled_string, S> {};
/**
\rst
Converts a string literal *s* into a format string that will be parsed at
compile time and converted into efficient formatting code. Requires C++17
``constexpr if`` compiler support.
**Example**::
// Converts 42 into std::string using the most efficient method and no
// runtime format string processing.
std::string s = fmt::format(FMT_COMPILE("{}"), 42);
\endrst
*/
#define FMT_COMPILE(s) FMT_STRING_IMPL(s, fmt::detail::compiled_string)
template <typename T, typename... Tail>
const T& first(const T& value, const Tail&...) {
return value;
}
// Part of a compiled format string. It can be either literal text or a
// replacement field.
template <typename Char> struct format_part {
enum class kind { arg_index, arg_name, text, replacement };
struct replacement {
arg_ref<Char> arg_id;
dynamic_format_specs<Char> specs;
};
kind part_kind;
union value {
int arg_index;
basic_string_view<Char> str;
replacement repl;
FMT_CONSTEXPR value(int index = 0) : arg_index(index) {}
FMT_CONSTEXPR value(basic_string_view<Char> s) : str(s) {}
FMT_CONSTEXPR value(replacement r) : repl(r) {}
} val;
// Position past the end of the argument id.
const Char* arg_id_end = nullptr;
FMT_CONSTEXPR format_part(kind k = kind::arg_index, value v = {})
: part_kind(k), val(v) {}
static FMT_CONSTEXPR format_part make_arg_index(int index) {
return format_part(kind::arg_index, index);
}
static FMT_CONSTEXPR format_part make_arg_name(basic_string_view<Char> name) {
return format_part(kind::arg_name, name);
}
static FMT_CONSTEXPR format_part make_text(basic_string_view<Char> text) {
return format_part(kind::text, text);
}
static FMT_CONSTEXPR format_part make_replacement(replacement repl) {
return format_part(kind::replacement, repl);
}
};
template <typename Char> struct part_counter {
unsigned num_parts = 0;
FMT_CONSTEXPR void on_text(const Char* begin, const Char* end) {
if (begin != end) ++num_parts;
}
FMT_CONSTEXPR int on_arg_id() { return ++num_parts, 0; }
FMT_CONSTEXPR int on_arg_id(int) { return ++num_parts, 0; }
FMT_CONSTEXPR int on_arg_id(basic_string_view<Char>) {
return ++num_parts, 0;
}
FMT_CONSTEXPR void on_replacement_field(int, const Char*) {}
FMT_CONSTEXPR const Char* on_format_specs(int, const Char* begin,
const Char* end) {
// Find the matching brace.
unsigned brace_counter = 0;
for (; begin != end; ++begin) {
if (*begin == '{') {
++brace_counter;
} else if (*begin == '}') {
if (brace_counter == 0u) break;
--brace_counter;
}
}
return begin;
}
FMT_CONSTEXPR void on_error(const char*) {}
};
// Counts the number of parts in a format string.
template <typename Char>
FMT_CONSTEXPR unsigned count_parts(basic_string_view<Char> format_str) {
part_counter<Char> counter;
parse_format_string<true>(format_str, counter);
return counter.num_parts;
}
template <typename Char, typename PartHandler>
class format_string_compiler : public error_handler {
private:
using part = format_part<Char>;
PartHandler handler_;
part part_;
basic_string_view<Char> format_str_;
basic_format_parse_context<Char> parse_context_;
public:
FMT_CONSTEXPR format_string_compiler(basic_string_view<Char> format_str,
PartHandler handler)
: handler_(handler),
format_str_(format_str),
parse_context_(format_str) {}
FMT_CONSTEXPR void on_text(const Char* begin, const Char* end) {
if (begin != end)
handler_(part::make_text({begin, to_unsigned(end - begin)}));
}
FMT_CONSTEXPR int on_arg_id() {
part_ = part::make_arg_index(parse_context_.next_arg_id());
return 0;
}
FMT_CONSTEXPR int on_arg_id(int id) {
parse_context_.check_arg_id(id);
part_ = part::make_arg_index(id);
return 0;
}
FMT_CONSTEXPR int on_arg_id(basic_string_view<Char> id) {
part_ = part::make_arg_name(id);
return 0;
}
FMT_CONSTEXPR void on_replacement_field(int, const Char* ptr) {
part_.arg_id_end = ptr;
handler_(part_);
}
FMT_CONSTEXPR const Char* on_format_specs(int, const Char* begin,
const Char* end) {
auto repl = typename part::replacement();
dynamic_specs_handler<basic_format_parse_context<Char>> handler(
repl.specs, parse_context_);
auto it = parse_format_specs(begin, end, handler);
if (*it != '}') on_error("missing '}' in format string");
repl.arg_id = part_.part_kind == part::kind::arg_index
? arg_ref<Char>(part_.val.arg_index)
: arg_ref<Char>(part_.val.str);
auto part = part::make_replacement(repl);
part.arg_id_end = begin;
handler_(part);
return it;
}
};
// Compiles a format string and invokes handler(part) for each parsed part.
template <bool IS_CONSTEXPR, typename Char, typename PartHandler>
FMT_CONSTEXPR void compile_format_string(basic_string_view<Char> format_str,
PartHandler handler) {
parse_format_string<IS_CONSTEXPR>(
format_str,
format_string_compiler<Char, PartHandler>(format_str, handler));
}
template <typename OutputIt, typename Context, typename Id>
void format_arg(
basic_format_parse_context<typename Context::char_type>& parse_ctx,
Context& ctx, Id arg_id) {
ctx.advance_to(visit_format_arg(
arg_formatter<OutputIt, typename Context::char_type>(ctx, &parse_ctx),
ctx.arg(arg_id)));
}
// vformat_to is defined in a subnamespace to prevent ADL.
namespace cf {
template <typename Context, typename OutputIt, typename CompiledFormat>
auto vformat_to(OutputIt out, CompiledFormat& cf,
basic_format_args<Context> args) -> typename Context::iterator {
using char_type = typename Context::char_type;
basic_format_parse_context<char_type> parse_ctx(
to_string_view(cf.format_str_));
Context ctx(out, args);
const auto& parts = cf.parts();
for (auto part_it = std::begin(parts); part_it != std::end(parts);
++part_it) {
const auto& part = *part_it;
const auto& value = part.val;
using format_part_t = format_part<char_type>;
switch (part.part_kind) {
case format_part_t::kind::text: {
const auto text = value.str;
auto output = ctx.out();
auto&& it = reserve(output, text.size());
it = std::copy_n(text.begin(), text.size(), it);
ctx.advance_to(output);
break;
}
case format_part_t::kind::arg_index:
advance_to(parse_ctx, part.arg_id_end);
detail::format_arg<OutputIt>(parse_ctx, ctx, value.arg_index);
break;
case format_part_t::kind::arg_name:
advance_to(parse_ctx, part.arg_id_end);
detail::format_arg<OutputIt>(parse_ctx, ctx, value.str);
break;
case format_part_t::kind::replacement: {
const auto& arg_id_value = value.repl.arg_id.val;
const auto arg = value.repl.arg_id.kind == arg_id_kind::index
? ctx.arg(arg_id_value.index)
: ctx.arg(arg_id_value.name);
auto specs = value.repl.specs;
handle_dynamic_spec<width_checker>(specs.width, specs.width_ref, ctx);
handle_dynamic_spec<precision_checker>(specs.precision,
specs.precision_ref, ctx);
error_handler h;
numeric_specs_checker<error_handler> checker(h, arg.type());
if (specs.align == align::numeric) checker.require_numeric_argument();
if (specs.sign != sign::none) checker.check_sign();
if (specs.alt) checker.require_numeric_argument();
if (specs.precision >= 0) checker.check_precision();
advance_to(parse_ctx, part.arg_id_end);
ctx.advance_to(
visit_format_arg(arg_formatter<OutputIt, typename Context::char_type>(
ctx, nullptr, &specs),
arg));
break;
}
}
}
return ctx.out();
}
} // namespace cf
struct basic_compiled_format {};
template <typename S, typename = void>
struct compiled_format_base : basic_compiled_format {
using char_type = char_t<S>;
using parts_container = std::vector<detail::format_part<char_type>>;
parts_container compiled_parts;
explicit compiled_format_base(basic_string_view<char_type> format_str) {
compile_format_string<false>(format_str,
[this](const format_part<char_type>& part) {
compiled_parts.push_back(part);
});
}
const parts_container& parts() const { return compiled_parts; }
};
template <typename Char, unsigned N> struct format_part_array {
format_part<Char> data[N] = {};
FMT_CONSTEXPR format_part_array() = default;
};
template <typename Char, unsigned N>
FMT_CONSTEXPR format_part_array<Char, N> compile_to_parts(
basic_string_view<Char> format_str) {
format_part_array<Char, N> parts;
unsigned counter = 0;
// This is not a lambda for compatibility with older compilers.
struct {
format_part<Char>* parts;
unsigned* counter;
FMT_CONSTEXPR void operator()(const format_part<Char>& part) {
parts[(*counter)++] = part;
}
} collector{parts.data, &counter};
compile_format_string<true>(format_str, collector);
if (counter < N) {
parts.data[counter] =
format_part<Char>::make_text(basic_string_view<Char>());
}
return parts;
}
template <typename T> constexpr const T& constexpr_max(const T& a, const T& b) {
return (a < b) ? b : a;
}
template <typename S>
struct compiled_format_base<S, enable_if_t<is_compile_string<S>::value>>
: basic_compiled_format {
using char_type = char_t<S>;
FMT_CONSTEXPR explicit compiled_format_base(basic_string_view<char_type>) {}
// Workaround for old compilers. Format string compilation will not be
// performed there anyway.
#if FMT_USE_CONSTEXPR
static FMT_CONSTEXPR_DECL const unsigned num_format_parts =
constexpr_max(count_parts(to_string_view(S())), 1u);
#else
static const unsigned num_format_parts = 1;
#endif
using parts_container = format_part<char_type>[num_format_parts];
const parts_container& parts() const {
static FMT_CONSTEXPR_DECL const auto compiled_parts =
compile_to_parts<char_type, num_format_parts>(
detail::to_string_view(S()));
return compiled_parts.data;
}
};
template <typename S, typename... Args>
class compiled_format : private compiled_format_base<S> {
public:
using typename compiled_format_base<S>::char_type;
private:
basic_string_view<char_type> format_str_;
template <typename Context, typename OutputIt, typename CompiledFormat>
friend auto cf::vformat_to(OutputIt out, CompiledFormat& cf,
basic_format_args<Context> args) ->
typename Context::iterator;
public:
compiled_format() = delete;
explicit constexpr compiled_format(basic_string_view<char_type> format_str)
: compiled_format_base<S>(format_str), format_str_(format_str) {}
};
#ifdef __cpp_if_constexpr
template <typename... Args> struct type_list {};
// Returns a reference to the argument at index N from [first, rest...].
template <int N, typename T, typename... Args>
constexpr const auto& get(const T& first, const Args&... rest) {
static_assert(N < 1 + sizeof...(Args), "index is out of bounds");
if constexpr (N == 0)
return first;
else
return get<N - 1>(rest...);
}
template <int N, typename> struct get_type_impl;
template <int N, typename... Args> struct get_type_impl<N, type_list<Args...>> {
using type = remove_cvref_t<decltype(get<N>(std::declval<Args>()...))>;
};
template <int N, typename T>
using get_type = typename get_type_impl<N, T>::type;
template <typename T> struct is_compiled_format : std::false_type {};
template <typename Char> struct text {
basic_string_view<Char> data;
using char_type = Char;
template <typename OutputIt, typename... Args>
OutputIt format(OutputIt out, const Args&...) const {
return write<Char>(out, data);
}
};
template <typename Char>
struct is_compiled_format<text<Char>> : std::true_type {};
template <typename Char>
constexpr text<Char> make_text(basic_string_view<Char> s, size_t pos,
size_t size) {
return {{&s[pos], size}};
}
// A replacement field that refers to argument N.
template <typename Char, typename T, int N> struct field {
using char_type = Char;
template <typename OutputIt, typename... Args>
OutputIt format(OutputIt out, const Args&... args) const {
// This ensures that the argument type is convertile to `const T&`.
const T& arg = get<N>(args...);
return write<Char>(out, arg);
}
};
template <typename Char, typename T, int N>
struct is_compiled_format<field<Char, T, N>> : std::true_type {};
// A replacement field that refers to argument N and has format specifiers.
template <typename Char, typename T, int N> struct spec_field {
using char_type = Char;
mutable formatter<T, Char> fmt;
template <typename OutputIt, typename... Args>
OutputIt format(OutputIt out, const Args&... args) const {
// This ensures that the argument type is convertile to `const T&`.
const T& arg = get<N>(args...);
basic_format_context<OutputIt, Char> ctx(out, {});
return fmt.format(arg, ctx);
}
};
template <typename Char, typename T, int N>
struct is_compiled_format<spec_field<Char, T, N>> : std::true_type {};
template <typename L, typename R> struct concat {
L lhs;
R rhs;
using char_type = typename L::char_type;
template <typename OutputIt, typename... Args>
OutputIt format(OutputIt out, const Args&... args) const {
out = lhs.format(out, args...);
return rhs.format(out, args...);
}
};
template <typename L, typename R>
struct is_compiled_format<concat<L, R>> : std::true_type {};
template <typename L, typename R>
constexpr concat<L, R> make_concat(L lhs, R rhs) {
return {lhs, rhs};
}
struct unknown_format {};
template <typename Char>
constexpr size_t parse_text(basic_string_view<Char> str, size_t pos) {
for (size_t size = str.size(); pos != size; ++pos) {
if (str[pos] == '{' || str[pos] == '}') break;
}
return pos;
}
template <typename Args, size_t POS, int ID, typename S>
constexpr auto compile_format_string(S format_str);
template <typename Args, size_t POS, int ID, typename T, typename S>
constexpr auto parse_tail(T head, S format_str) {
if constexpr (POS !=
basic_string_view<typename S::char_type>(format_str).size()) {
constexpr auto tail = compile_format_string<Args, POS, ID>(format_str);
if constexpr (std::is_same<remove_cvref_t<decltype(tail)>,
unknown_format>())
return tail;
else
return make_concat(head, tail);
} else {
return head;
}
}
template <typename T, typename Char> struct parse_specs_result {
formatter<T, Char> fmt;
size_t end;
};
template <typename T, typename Char>
constexpr parse_specs_result<T, Char> parse_specs(basic_string_view<Char> str,
size_t pos) {
str.remove_prefix(pos);
auto ctx = basic_format_parse_context<Char>(str);
auto f = formatter<T, Char>();
auto end = f.parse(ctx);
return {f, pos + (end - str.data()) + 1};
}
// Compiles a non-empty format string and returns the compiled representation
// or unknown_format() on unrecognized input.
template <typename Args, size_t POS, int ID, typename S>
constexpr auto compile_format_string(S format_str) {
using char_type = typename S::char_type;
constexpr basic_string_view<char_type> str = format_str;
if constexpr (str[POS] == '{') {
if (POS + 1 == str.size())
throw format_error("unmatched '{' in format string");
if constexpr (str[POS + 1] == '{') {
return parse_tail<Args, POS + 2, ID>(make_text(str, POS, 1), format_str);
} else if constexpr (str[POS + 1] == '}') {
using type = get_type<ID, Args>;
return parse_tail<Args, POS + 2, ID + 1>(field<char_type, type, ID>(),
format_str);
} else if constexpr (str[POS + 1] == ':') {
using type = get_type<ID, Args>;
constexpr auto result = parse_specs<type>(str, POS + 2);
return parse_tail<Args, result.end, ID + 1>(
spec_field<char_type, type, ID>{result.fmt}, format_str);
} else {
return unknown_format();
}
} else if constexpr (str[POS] == '}') {
if (POS + 1 == str.size())
throw format_error("unmatched '}' in format string");
return parse_tail<Args, POS + 2, ID>(make_text(str, POS, 1), format_str);
} else {
constexpr auto end = parse_text(str, POS + 1);
return parse_tail<Args, end, ID>(make_text(str, POS, end - POS),
format_str);
}
}
template <typename... Args, typename S,
FMT_ENABLE_IF(is_compile_string<S>::value ||
detail::is_compiled_string<S>::value)>
constexpr auto compile(S format_str) {
constexpr basic_string_view<typename S::char_type> str = format_str;
if constexpr (str.size() == 0) {
return detail::make_text(str, 0, 0);
} else {
constexpr auto result =
detail::compile_format_string<detail::type_list<Args...>, 0, 0>(
format_str);
if constexpr (std::is_same<remove_cvref_t<decltype(result)>,
detail::unknown_format>()) {
return detail::compiled_format<S, Args...>(to_string_view(format_str));
} else {
return result;
}
}
}
#else
template <typename... Args, typename S,
FMT_ENABLE_IF(is_compile_string<S>::value)>
constexpr auto compile(S format_str) -> detail::compiled_format<S, Args...> {
return detail::compiled_format<S, Args...>(to_string_view(format_str));
}
#endif // __cpp_if_constexpr
// Compiles the format string which must be a string literal.
template <typename... Args, typename Char, size_t N>
auto compile(const Char (&format_str)[N])
-> detail::compiled_format<const Char*, Args...> {
return detail::compiled_format<const Char*, Args...>(
basic_string_view<Char>(format_str, N - 1));
}
} // namespace detail
// DEPRECATED! use FMT_COMPILE instead.
template <typename... Args>
FMT_DEPRECATED auto compile(const Args&... args)
-> decltype(detail::compile(args...)) {
return detail::compile(args...);
}
#if FMT_USE_CONSTEXPR
# ifdef __cpp_if_constexpr
template <typename CompiledFormat, typename... Args,
typename Char = typename CompiledFormat::char_type,
FMT_ENABLE_IF(detail::is_compiled_format<CompiledFormat>::value)>
FMT_INLINE std::basic_string<Char> format(const CompiledFormat& cf,
const Args&... args) {
basic_memory_buffer<Char> buffer;
detail::buffer<Char>& base = buffer;
cf.format(std::back_inserter(base), args...);
return to_string(buffer);
}
template <typename OutputIt, typename CompiledFormat, typename... Args,
FMT_ENABLE_IF(detail::is_compiled_format<CompiledFormat>::value)>
OutputIt format_to(OutputIt out, const CompiledFormat& cf,
const Args&... args) {
return cf.format(out, args...);
}
# endif // __cpp_if_constexpr
#endif // FMT_USE_CONSTEXPR
template <typename CompiledFormat, typename... Args,
typename Char = typename CompiledFormat::char_type,
FMT_ENABLE_IF(std::is_base_of<detail::basic_compiled_format,
CompiledFormat>::value)>
std::basic_string<Char> format(const CompiledFormat& cf, const Args&... args) {
basic_memory_buffer<Char> buffer;
using context = buffer_context<Char>;
detail::buffer<Char>& base = buffer;
detail::cf::vformat_to<context>(std::back_inserter(base), cf,
make_format_args<context>(args...));
return to_string(buffer);
}
template <typename S, typename... Args,
FMT_ENABLE_IF(detail::is_compiled_string<S>::value)>
FMT_INLINE std::basic_string<typename S::char_type> format(const S&,
Args&&... args) {
constexpr basic_string_view<typename S::char_type> str = S();
if (str.size() == 2 && str[0] == '{' && str[1] == '}')
return fmt::to_string(detail::first(args...));
constexpr auto compiled = detail::compile<Args...>(S());
return format(compiled, std::forward<Args>(args)...);
}
template <typename OutputIt, typename CompiledFormat, typename... Args,
FMT_ENABLE_IF(std::is_base_of<detail::basic_compiled_format,
CompiledFormat>::value)>
OutputIt format_to(OutputIt out, const CompiledFormat& cf,
const Args&... args) {
using char_type = typename CompiledFormat::char_type;
using context = format_context_t<OutputIt, char_type>;
return detail::cf::vformat_to<context>(out, cf,
make_format_args<context>(args...));
}
template <typename OutputIt, typename S, typename... Args,
FMT_ENABLE_IF(detail::is_compiled_string<S>::value)>
OutputIt format_to(OutputIt out, const S&, const Args&... args) {
constexpr auto compiled = detail::compile<Args...>(S());
return format_to(out, compiled, args...);
}
template <
typename OutputIt, typename CompiledFormat, typename... Args,
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt>::value&& std::is_base_of<
detail::basic_compiled_format, CompiledFormat>::value)>
format_to_n_result<OutputIt> format_to_n(OutputIt out, size_t n,
const CompiledFormat& cf,
const Args&... args) {
auto it =
format_to(detail::truncating_iterator<OutputIt>(out, n), cf, args...);
return {it.base(), it.count()};
}
template <typename CompiledFormat, typename... Args>
size_t formatted_size(const CompiledFormat& cf, const Args&... args) {
return format_to(detail::counting_iterator(), cf, args...).count();
}
FMT_END_NAMESPACE
#endif // FMT_COMPILE_H_

1882
external/fmtlib/include/fmt/core.h vendored Normal file

File diff suppressed because it is too large Load Diff

1453
external/fmtlib/include/fmt/format-inl.h vendored Normal file

File diff suppressed because it is too large Load Diff

3729
external/fmtlib/include/fmt/format.h vendored Normal file

File diff suppressed because it is too large Load Diff

78
external/fmtlib/include/fmt/locale.h vendored Normal file
View File

@@ -0,0 +1,78 @@
// Formatting library for C++ - std::locale support
//
// Copyright (c) 2012 - present, Victor Zverovich
// All rights reserved.
//
// For the license information refer to format.h.
#ifndef FMT_LOCALE_H_
#define FMT_LOCALE_H_
#include <locale>
#include "format.h"
FMT_BEGIN_NAMESPACE
namespace detail {
template <typename Char>
typename buffer_context<Char>::iterator vformat_to(
const std::locale& loc, buffer<Char>& buf,
basic_string_view<Char> format_str,
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
using af = arg_formatter<typename buffer_context<Char>::iterator, Char>;
return vformat_to<af>(std::back_inserter(buf), to_string_view(format_str),
args, detail::locale_ref(loc));
}
template <typename Char>
std::basic_string<Char> vformat(
const std::locale& loc, basic_string_view<Char> format_str,
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
basic_memory_buffer<Char> buffer;
detail::vformat_to(loc, buffer, format_str, args);
return fmt::to_string(buffer);
}
} // namespace detail
template <typename S, typename Char = char_t<S>>
inline std::basic_string<Char> vformat(
const std::locale& loc, const S& format_str,
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
return detail::vformat(loc, to_string_view(format_str), args);
}
template <typename S, typename... Args, typename Char = char_t<S>>
inline std::basic_string<Char> format(const std::locale& loc,
const S& format_str, Args&&... args) {
return detail::vformat(
loc, to_string_view(format_str),
detail::make_args_checked<Args...>(format_str, args...));
}
template <typename S, typename OutputIt, typename... Args,
typename Char = enable_if_t<
detail::is_output_iterator<OutputIt>::value, char_t<S>>>
inline OutputIt vformat_to(
OutputIt out, const std::locale& loc, const S& format_str,
format_args_t<type_identity_t<OutputIt>, Char> args) {
using af = detail::arg_formatter<OutputIt, Char>;
return vformat_to<af>(out, to_string_view(format_str), args,
detail::locale_ref(loc));
}
template <typename OutputIt, typename S, typename... Args,
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt>::value&&
detail::is_string<S>::value)>
inline OutputIt format_to(OutputIt out, const std::locale& loc,
const S& format_str, Args&&... args) {
detail::check_format_string<Args...>(format_str);
using context = format_context_t<OutputIt, char_t<S>>;
format_arg_store<context, Args...> as{args...};
return vformat_to(out, loc, to_string_view(format_str),
basic_format_args<context>(as));
}
FMT_END_NAMESPACE
#endif // FMT_LOCALE_H_

450
external/fmtlib/include/fmt/os.h vendored Normal file
View File

@@ -0,0 +1,450 @@
// Formatting library for C++ - optional OS-specific functionality
//
// Copyright (c) 2012 - present, Victor Zverovich
// All rights reserved.
//
// For the license information refer to format.h.
#ifndef FMT_OS_H_
#define FMT_OS_H_
#if defined(__MINGW32__) || defined(__CYGWIN__)
// Workaround MinGW bug https://sourceforge.net/p/mingw/bugs/2024/.
# undef __STRICT_ANSI__
#endif
#include <cerrno>
#include <clocale> // for locale_t
#include <cstddef>
#include <cstdio>
#include <cstdlib> // for strtod_l
#if defined __APPLE__ || defined(__FreeBSD__)
# include <xlocale.h> // for LC_NUMERIC_MASK on OS X
#endif
#include "format.h"
// UWP doesn't provide _pipe.
#if FMT_HAS_INCLUDE("winapifamily.h")
# include <winapifamily.h>
#endif
#if FMT_HAS_INCLUDE("fcntl.h") && \
(!defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP))
# include <fcntl.h> // for O_RDONLY
# define FMT_USE_FCNTL 1
#else
# define FMT_USE_FCNTL 0
#endif
#ifndef FMT_POSIX
# if defined(_WIN32) && !defined(__MINGW32__)
// Fix warnings about deprecated symbols.
# define FMT_POSIX(call) _##call
# else
# define FMT_POSIX(call) call
# endif
#endif
// Calls to system functions are wrapped in FMT_SYSTEM for testability.
#ifdef FMT_SYSTEM
# define FMT_POSIX_CALL(call) FMT_SYSTEM(call)
#else
# define FMT_SYSTEM(call) ::call
# ifdef _WIN32
// Fix warnings about deprecated symbols.
# define FMT_POSIX_CALL(call) ::_##call
# else
# define FMT_POSIX_CALL(call) ::call
# endif
#endif
// Retries the expression while it evaluates to error_result and errno
// equals to EINTR.
#ifndef _WIN32
# define FMT_RETRY_VAL(result, expression, error_result) \
do { \
(result) = (expression); \
} while ((result) == (error_result) && errno == EINTR)
#else
# define FMT_RETRY_VAL(result, expression, error_result) result = (expression)
#endif
#define FMT_RETRY(result, expression) FMT_RETRY_VAL(result, expression, -1)
FMT_BEGIN_NAMESPACE
/**
\rst
A reference to a null-terminated string. It can be constructed from a C
string or ``std::string``.
You can use one of the following type aliases for common character types:
+---------------+-----------------------------+
| Type | Definition |
+===============+=============================+
| cstring_view | basic_cstring_view<char> |
+---------------+-----------------------------+
| wcstring_view | basic_cstring_view<wchar_t> |
+---------------+-----------------------------+
This class is most useful as a parameter type to allow passing
different types of strings to a function, for example::
template <typename... Args>
std::string format(cstring_view format_str, const Args & ... args);
format("{}", 42);
format(std::string("{}"), 42);
\endrst
*/
template <typename Char> class basic_cstring_view {
private:
const Char* data_;
public:
/** Constructs a string reference object from a C string. */
basic_cstring_view(const Char* s) : data_(s) {}
/**
\rst
Constructs a string reference from an ``std::string`` object.
\endrst
*/
basic_cstring_view(const std::basic_string<Char>& s) : data_(s.c_str()) {}
/** Returns the pointer to a C string. */
const Char* c_str() const { return data_; }
};
using cstring_view = basic_cstring_view<char>;
using wcstring_view = basic_cstring_view<wchar_t>;
// An error code.
class error_code {
private:
int value_;
public:
explicit error_code(int value = 0) FMT_NOEXCEPT : value_(value) {}
int get() const FMT_NOEXCEPT { return value_; }
};
#ifdef _WIN32
namespace detail {
// A converter from UTF-16 to UTF-8.
// It is only provided for Windows since other systems support UTF-8 natively.
class utf16_to_utf8 {
private:
memory_buffer buffer_;
public:
utf16_to_utf8() {}
FMT_API explicit utf16_to_utf8(wstring_view s);
operator string_view() const { return string_view(&buffer_[0], size()); }
size_t size() const { return buffer_.size() - 1; }
const char* c_str() const { return &buffer_[0]; }
std::string str() const { return std::string(&buffer_[0], size()); }
// Performs conversion returning a system error code instead of
// throwing exception on conversion error. This method may still throw
// in case of memory allocation error.
FMT_API int convert(wstring_view s);
};
FMT_API void format_windows_error(buffer<char>& out, int error_code,
string_view message) FMT_NOEXCEPT;
} // namespace detail
/** A Windows error. */
class windows_error : public system_error {
private:
FMT_API void init(int error_code, string_view format_str, format_args args);
public:
/**
\rst
Constructs a :class:`fmt::windows_error` object with the description
of the form
.. parsed-literal::
*<message>*: *<system-message>*
where *<message>* is the formatted message and *<system-message>* is the
system message corresponding to the error code.
*error_code* is a Windows error code as given by ``GetLastError``.
If *error_code* is not a valid error code such as -1, the system message
will look like "error -1".
**Example**::
// This throws a windows_error with the description
// cannot open file 'madeup': The system cannot find the file specified.
// or similar (system message may vary).
const char *filename = "madeup";
LPOFSTRUCT of = LPOFSTRUCT();
HFILE file = OpenFile(filename, &of, OF_READ);
if (file == HFILE_ERROR) {
throw fmt::windows_error(GetLastError(),
"cannot open file '{}'", filename);
}
\endrst
*/
template <typename... Args>
windows_error(int error_code, string_view message, const Args&... args) {
init(error_code, message, make_format_args(args...));
}
};
// Reports a Windows error without throwing an exception.
// Can be used to report errors from destructors.
FMT_API void report_windows_error(int error_code,
string_view message) FMT_NOEXCEPT;
#endif // _WIN32
// A buffered file.
class buffered_file {
private:
FILE* file_;
friend class file;
explicit buffered_file(FILE* f) : file_(f) {}
public:
buffered_file(const buffered_file&) = delete;
void operator=(const buffered_file&) = delete;
// Constructs a buffered_file object which doesn't represent any file.
buffered_file() FMT_NOEXCEPT : file_(nullptr) {}
// Destroys the object closing the file it represents if any.
FMT_API ~buffered_file() FMT_NOEXCEPT;
public:
buffered_file(buffered_file&& other) FMT_NOEXCEPT : file_(other.file_) {
other.file_ = nullptr;
}
buffered_file& operator=(buffered_file&& other) {
close();
file_ = other.file_;
other.file_ = nullptr;
return *this;
}
// Opens a file.
FMT_API buffered_file(cstring_view filename, cstring_view mode);
// Closes the file.
FMT_API void close();
// Returns the pointer to a FILE object representing this file.
FILE* get() const FMT_NOEXCEPT { return file_; }
// We place parentheses around fileno to workaround a bug in some versions
// of MinGW that define fileno as a macro.
FMT_API int(fileno)() const;
void vprint(string_view format_str, format_args args) {
fmt::vprint(file_, format_str, args);
}
template <typename... Args>
inline void print(string_view format_str, const Args&... args) {
vprint(format_str, make_format_args(args...));
}
};
#if FMT_USE_FCNTL
// A file. Closed file is represented by a file object with descriptor -1.
// Methods that are not declared with FMT_NOEXCEPT may throw
// fmt::system_error in case of failure. Note that some errors such as
// closing the file multiple times will cause a crash on Windows rather
// than an exception. You can get standard behavior by overriding the
// invalid parameter handler with _set_invalid_parameter_handler.
class file {
private:
int fd_; // File descriptor.
// Constructs a file object with a given descriptor.
explicit file(int fd) : fd_(fd) {}
public:
// Possible values for the oflag argument to the constructor.
enum {
RDONLY = FMT_POSIX(O_RDONLY), // Open for reading only.
WRONLY = FMT_POSIX(O_WRONLY), // Open for writing only.
RDWR = FMT_POSIX(O_RDWR), // Open for reading and writing.
CREATE = FMT_POSIX(O_CREAT) // Create if the file doesn't exist.
};
// Constructs a file object which doesn't represent any file.
file() FMT_NOEXCEPT : fd_(-1) {}
// Opens a file and constructs a file object representing this file.
FMT_API file(cstring_view path, int oflag);
public:
file(const file&) = delete;
void operator=(const file&) = delete;
file(file&& other) FMT_NOEXCEPT : fd_(other.fd_) { other.fd_ = -1; }
file& operator=(file&& other) FMT_NOEXCEPT {
close();
fd_ = other.fd_;
other.fd_ = -1;
return *this;
}
// Destroys the object closing the file it represents if any.
FMT_API ~file() FMT_NOEXCEPT;
// Returns the file descriptor.
int descriptor() const FMT_NOEXCEPT { return fd_; }
// Closes the file.
FMT_API void close();
// Returns the file size. The size has signed type for consistency with
// stat::st_size.
FMT_API long long size() const;
// Attempts to read count bytes from the file into the specified buffer.
FMT_API size_t read(void* buffer, size_t count);
// Attempts to write count bytes from the specified buffer to the file.
FMT_API size_t write(const void* buffer, size_t count);
// Duplicates a file descriptor with the dup function and returns
// the duplicate as a file object.
FMT_API static file dup(int fd);
// Makes fd be the copy of this file descriptor, closing fd first if
// necessary.
FMT_API void dup2(int fd);
// Makes fd be the copy of this file descriptor, closing fd first if
// necessary.
FMT_API void dup2(int fd, error_code& ec) FMT_NOEXCEPT;
// Creates a pipe setting up read_end and write_end file objects for reading
// and writing respectively.
FMT_API static void pipe(file& read_end, file& write_end);
// Creates a buffered_file object associated with this file and detaches
// this file object from the file.
FMT_API buffered_file fdopen(const char* mode);
};
// Returns the memory page size.
long getpagesize();
class direct_buffered_file;
template <typename S, typename... Args>
void print(direct_buffered_file& f, const S& format_str,
const Args&... args);
// A buffered file with a direct buffer access and no synchronization.
class direct_buffered_file {
private:
file file_;
enum { buffer_size = 4096 };
char buffer_[buffer_size];
int pos_;
void flush() {
if (pos_ == 0) return;
file_.write(buffer_, pos_);
pos_ = 0;
}
int free_capacity() const { return buffer_size - pos_; }
public:
direct_buffered_file(cstring_view path, int oflag)
: file_(path, oflag), pos_(0) {}
~direct_buffered_file() {
flush();
}
void close() {
flush();
file_.close();
}
template <typename S, typename... Args>
friend void print(direct_buffered_file& f, const S& format_str,
const Args&... args) {
// We could avoid double buffering.
auto buf = fmt::memory_buffer();
fmt::format_to(std::back_inserter(buf), format_str, args...);
auto remaining_pos = 0;
auto remaining_size = buf.size();
while (remaining_size > detail::to_unsigned(f.free_capacity())) {
auto size = f.free_capacity();
memcpy(f.buffer_ + f.pos_, buf.data() + remaining_pos, size);
f.pos_ += size;
f.flush();
remaining_pos += size;
remaining_size -= size;
}
memcpy(f.buffer_ + f.pos_, buf.data() + remaining_pos, remaining_size);
f.pos_ += static_cast<int>(remaining_size);
}
};
#endif // FMT_USE_FCNTL
#ifdef FMT_LOCALE
// A "C" numeric locale.
class locale {
private:
# ifdef _WIN32
using locale_t = _locale_t;
static void freelocale(locale_t loc) { _free_locale(loc); }
static double strtod_l(const char* nptr, char** endptr, _locale_t loc) {
return _strtod_l(nptr, endptr, loc);
}
# endif
locale_t locale_;
public:
using type = locale_t;
locale(const locale&) = delete;
void operator=(const locale&) = delete;
locale() {
# ifndef _WIN32
locale_ = FMT_SYSTEM(newlocale(LC_NUMERIC_MASK, "C", nullptr));
# else
locale_ = _create_locale(LC_NUMERIC, "C");
# endif
if (!locale_) FMT_THROW(system_error(errno, "cannot create locale"));
}
~locale() { freelocale(locale_); }
type get() const { return locale_; }
// Converts string to floating-point number and advances str past the end
// of the parsed input.
double strtod(const char*& str) const {
char* end = nullptr;
double result = strtod_l(str, &end, locale_);
str = end;
return result;
}
};
using Locale FMT_DEPRECATED_ALIAS = locale;
#endif // FMT_LOCALE
FMT_END_NAMESPACE
#endif // FMT_OS_H_

167
external/fmtlib/include/fmt/ostream.h vendored Normal file
View File

@@ -0,0 +1,167 @@
// Formatting library for C++ - std::ostream support
//
// Copyright (c) 2012 - present, Victor Zverovich
// All rights reserved.
//
// For the license information refer to format.h.
#ifndef FMT_OSTREAM_H_
#define FMT_OSTREAM_H_
#include <ostream>
#include "format.h"
FMT_BEGIN_NAMESPACE
template <typename Char> class basic_printf_parse_context;
template <typename OutputIt, typename Char> class basic_printf_context;
namespace detail {
template <class Char> class formatbuf : public std::basic_streambuf<Char> {
private:
using int_type = typename std::basic_streambuf<Char>::int_type;
using traits_type = typename std::basic_streambuf<Char>::traits_type;
buffer<Char>& buffer_;
public:
formatbuf(buffer<Char>& buf) : buffer_(buf) {}
protected:
// The put-area is actually always empty. This makes the implementation
// simpler and has the advantage that the streambuf and the buffer are always
// in sync and sputc never writes into uninitialized memory. The obvious
// disadvantage is that each call to sputc always results in a (virtual) call
// to overflow. There is no disadvantage here for sputn since this always
// results in a call to xsputn.
int_type overflow(int_type ch = traits_type::eof()) FMT_OVERRIDE {
if (!traits_type::eq_int_type(ch, traits_type::eof()))
buffer_.push_back(static_cast<Char>(ch));
return ch;
}
std::streamsize xsputn(const Char* s, std::streamsize count) FMT_OVERRIDE {
buffer_.append(s, s + count);
return count;
}
};
template <typename Char> struct test_stream : std::basic_ostream<Char> {
private:
// Hide all operator<< from std::basic_ostream<Char>.
void_t<> operator<<(null<>);
void_t<> operator<<(const Char*);
template <typename T, FMT_ENABLE_IF(std::is_convertible<T, int>::value &&
!std::is_enum<T>::value)>
void_t<> operator<<(T);
};
// Checks if T has a user-defined operator<< (e.g. not a member of
// std::ostream).
template <typename T, typename Char> class is_streamable {
private:
template <typename U>
static bool_constant<!std::is_same<decltype(std::declval<test_stream<Char>&>()
<< std::declval<U>()),
void_t<>>::value>
test(int);
template <typename> static std::false_type test(...);
using result = decltype(test<T>(0));
public:
static const bool value = result::value;
};
// Write the content of buf to os.
template <typename Char>
void write_buffer(std::basic_ostream<Char>& os, buffer<Char>& buf) {
const Char* buf_data = buf.data();
using unsigned_streamsize = std::make_unsigned<std::streamsize>::type;
unsigned_streamsize size = buf.size();
unsigned_streamsize max_size = to_unsigned(max_value<std::streamsize>());
do {
unsigned_streamsize n = size <= max_size ? size : max_size;
os.write(buf_data, static_cast<std::streamsize>(n));
buf_data += n;
size -= n;
} while (size != 0);
}
template <typename Char, typename T>
void format_value(buffer<Char>& buf, const T& value,
locale_ref loc = locale_ref()) {
formatbuf<Char> format_buf(buf);
std::basic_ostream<Char> output(&format_buf);
#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR)
if (loc) output.imbue(loc.get<std::locale>());
#endif
output << value;
output.exceptions(std::ios_base::failbit | std::ios_base::badbit);
buf.resize(buf.size());
}
// Formats an object of type T that has an overloaded ostream operator<<.
template <typename T, typename Char>
struct fallback_formatter<T, Char, enable_if_t<is_streamable<T, Char>::value>>
: private formatter<basic_string_view<Char>, Char> {
FMT_CONSTEXPR auto parse(basic_format_parse_context<Char>& ctx)
-> decltype(ctx.begin()) {
return formatter<basic_string_view<Char>, Char>::parse(ctx);
}
template <typename ParseCtx,
FMT_ENABLE_IF(std::is_same<
ParseCtx, basic_printf_parse_context<Char>>::value)>
auto parse(ParseCtx& ctx) -> decltype(ctx.begin()) {
return ctx.begin();
}
template <typename OutputIt>
auto format(const T& value, basic_format_context<OutputIt, Char>& ctx)
-> OutputIt {
basic_memory_buffer<Char> buffer;
format_value(buffer, value, ctx.locale());
basic_string_view<Char> str(buffer.data(), buffer.size());
return formatter<basic_string_view<Char>, Char>::format(str, ctx);
}
template <typename OutputIt>
auto format(const T& value, basic_printf_context<OutputIt, Char>& ctx)
-> OutputIt {
basic_memory_buffer<Char> buffer;
format_value(buffer, value, ctx.locale());
return std::copy(buffer.begin(), buffer.end(), ctx.out());
}
};
} // namespace detail
template <typename Char>
void vprint(std::basic_ostream<Char>& os, basic_string_view<Char> format_str,
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
basic_memory_buffer<Char> buffer;
detail::vformat_to(buffer, format_str, args);
detail::write_buffer(os, buffer);
}
/**
\rst
Prints formatted data to the stream *os*.
**Example**::
fmt::print(cerr, "Don't {}!", "panic");
\endrst
*/
template <typename S, typename... Args,
typename Char = enable_if_t<detail::is_string<S>::value, char_t<S>>>
void print(std::basic_ostream<Char>& os, const S& format_str, Args&&... args) {
vprint(os, to_string_view(format_str),
detail::make_args_checked<Args...>(format_str, args...));
}
FMT_END_NAMESPACE
#endif // FMT_OSTREAM_H_

2
external/fmtlib/include/fmt/posix.h vendored Normal file
View File

@@ -0,0 +1,2 @@
#include "os.h"
#warning "fmt/posix.h is deprecated; use fmt/os.h instead"

751
external/fmtlib/include/fmt/printf.h vendored Normal file
View File

@@ -0,0 +1,751 @@
// Formatting library for C++ - legacy printf implementation
//
// Copyright (c) 2012 - 2016, Victor Zverovich
// All rights reserved.
//
// For the license information refer to format.h.
#ifndef FMT_PRINTF_H_
#define FMT_PRINTF_H_
#include <algorithm> // std::max
#include <limits> // std::numeric_limits
#include "ostream.h"
FMT_BEGIN_NAMESPACE
namespace detail {
// Checks if a value fits in int - used to avoid warnings about comparing
// signed and unsigned integers.
template <bool IsSigned> struct int_checker {
template <typename T> static bool fits_in_int(T value) {
unsigned max = max_value<int>();
return value <= max;
}
static bool fits_in_int(bool) { return true; }
};
template <> struct int_checker<true> {
template <typename T> static bool fits_in_int(T value) {
return value >= (std::numeric_limits<int>::min)() &&
value <= max_value<int>();
}
static bool fits_in_int(int) { return true; }
};
class printf_precision_handler {
public:
template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
int operator()(T value) {
if (!int_checker<std::numeric_limits<T>::is_signed>::fits_in_int(value))
FMT_THROW(format_error("number is too big"));
return (std::max)(static_cast<int>(value), 0);
}
template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
int operator()(T) {
FMT_THROW(format_error("precision is not integer"));
return 0;
}
};
// An argument visitor that returns true iff arg is a zero integer.
class is_zero_int {
public:
template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
bool operator()(T value) {
return value == 0;
}
template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
bool operator()(T) {
return false;
}
};
template <typename T> struct make_unsigned_or_bool : std::make_unsigned<T> {};
template <> struct make_unsigned_or_bool<bool> { using type = bool; };
template <typename T, typename Context> class arg_converter {
private:
using char_type = typename Context::char_type;
basic_format_arg<Context>& arg_;
char_type type_;
public:
arg_converter(basic_format_arg<Context>& arg, char_type type)
: arg_(arg), type_(type) {}
void operator()(bool value) {
if (type_ != 's') operator()<bool>(value);
}
template <typename U, FMT_ENABLE_IF(std::is_integral<U>::value)>
void operator()(U value) {
bool is_signed = type_ == 'd' || type_ == 'i';
using target_type = conditional_t<std::is_same<T, void>::value, U, T>;
if (const_check(sizeof(target_type) <= sizeof(int))) {
// Extra casts are used to silence warnings.
if (is_signed) {
arg_ = detail::make_arg<Context>(
static_cast<int>(static_cast<target_type>(value)));
} else {
using unsigned_type = typename make_unsigned_or_bool<target_type>::type;
arg_ = detail::make_arg<Context>(
static_cast<unsigned>(static_cast<unsigned_type>(value)));
}
} else {
if (is_signed) {
// glibc's printf doesn't sign extend arguments of smaller types:
// std::printf("%lld", -42); // prints "4294967254"
// but we don't have to do the same because it's a UB.
arg_ = detail::make_arg<Context>(static_cast<long long>(value));
} else {
arg_ = detail::make_arg<Context>(
static_cast<typename make_unsigned_or_bool<U>::type>(value));
}
}
}
template <typename U, FMT_ENABLE_IF(!std::is_integral<U>::value)>
void operator()(U) {} // No conversion needed for non-integral types.
};
// Converts an integer argument to T for printf, if T is an integral type.
// If T is void, the argument is converted to corresponding signed or unsigned
// type depending on the type specifier: 'd' and 'i' - signed, other -
// unsigned).
template <typename T, typename Context, typename Char>
void convert_arg(basic_format_arg<Context>& arg, Char type) {
visit_format_arg(arg_converter<T, Context>(arg, type), arg);
}
// Converts an integer argument to char for printf.
template <typename Context> class char_converter {
private:
basic_format_arg<Context>& arg_;
public:
explicit char_converter(basic_format_arg<Context>& arg) : arg_(arg) {}
template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
void operator()(T value) {
arg_ = detail::make_arg<Context>(
static_cast<typename Context::char_type>(value));
}
template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
void operator()(T) {} // No conversion needed for non-integral types.
};
// An argument visitor that return a pointer to a C string if argument is a
// string or null otherwise.
template <typename Char> struct get_cstring {
template <typename T> const Char* operator()(T) { return nullptr; }
const Char* operator()(const Char* s) { return s; }
};
// Checks if an argument is a valid printf width specifier and sets
// left alignment if it is negative.
template <typename Char> class printf_width_handler {
private:
using format_specs = basic_format_specs<Char>;
format_specs& specs_;
public:
explicit printf_width_handler(format_specs& specs) : specs_(specs) {}
template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
unsigned operator()(T value) {
auto width = static_cast<uint32_or_64_or_128_t<T>>(value);
if (detail::is_negative(value)) {
specs_.align = align::left;
width = 0 - width;
}
unsigned int_max = max_value<int>();
if (width > int_max) FMT_THROW(format_error("number is too big"));
return static_cast<unsigned>(width);
}
template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
unsigned operator()(T) {
FMT_THROW(format_error("width is not integer"));
return 0;
}
};
template <typename Char, typename Context>
void vprintf(buffer<Char>& buf, basic_string_view<Char> format,
basic_format_args<Context> args) {
Context(std::back_inserter(buf), format, args).format();
}
} // namespace detail
// For printing into memory_buffer.
template <typename Char, typename Context>
FMT_DEPRECATED void printf(detail::buffer<Char>& buf,
basic_string_view<Char> format,
basic_format_args<Context> args) {
return detail::vprintf(buf, format, args);
}
using detail::vprintf;
template <typename Char>
class basic_printf_parse_context : public basic_format_parse_context<Char> {
using basic_format_parse_context<Char>::basic_format_parse_context;
};
template <typename OutputIt, typename Char> class basic_printf_context;
/**
\rst
The ``printf`` argument formatter.
\endrst
*/
template <typename OutputIt, typename Char>
class printf_arg_formatter : public detail::arg_formatter_base<OutputIt, Char> {
public:
using iterator = OutputIt;
private:
using char_type = Char;
using base = detail::arg_formatter_base<OutputIt, Char>;
using context_type = basic_printf_context<OutputIt, Char>;
context_type& context_;
void write_null_pointer(char) {
this->specs()->type = 0;
this->write("(nil)");
}
void write_null_pointer(wchar_t) {
this->specs()->type = 0;
this->write(L"(nil)");
}
public:
using format_specs = typename base::format_specs;
/**
\rst
Constructs an argument formatter object.
*buffer* is a reference to the output buffer and *specs* contains format
specifier information for standard argument types.
\endrst
*/
printf_arg_formatter(iterator iter, format_specs& specs, context_type& ctx)
: base(iter, &specs, detail::locale_ref()), context_(ctx) {}
template <typename T, FMT_ENABLE_IF(fmt::detail::is_integral<T>::value)>
iterator operator()(T value) {
// MSVC2013 fails to compile separate overloads for bool and char_type so
// use std::is_same instead.
if (std::is_same<T, bool>::value) {
format_specs& fmt_specs = *this->specs();
if (fmt_specs.type != 's') return base::operator()(value ? 1 : 0);
fmt_specs.type = 0;
this->write(value != 0);
} else if (std::is_same<T, char_type>::value) {
format_specs& fmt_specs = *this->specs();
if (fmt_specs.type && fmt_specs.type != 'c')
return (*this)(static_cast<int>(value));
fmt_specs.sign = sign::none;
fmt_specs.alt = false;
fmt_specs.fill[0] = ' '; // Ignore '0' flag for char types.
// align::numeric needs to be overwritten here since the '0' flag is
// ignored for non-numeric types
if (fmt_specs.align == align::none || fmt_specs.align == align::numeric)
fmt_specs.align = align::right;
return base::operator()(value);
} else {
return base::operator()(value);
}
return this->out();
}
template <typename T, FMT_ENABLE_IF(std::is_floating_point<T>::value)>
iterator operator()(T value) {
return base::operator()(value);
}
/** Formats a null-terminated C string. */
iterator operator()(const char* value) {
if (value)
base::operator()(value);
else if (this->specs()->type == 'p')
write_null_pointer(char_type());
else
this->write("(null)");
return this->out();
}
/** Formats a null-terminated wide C string. */
iterator operator()(const wchar_t* value) {
if (value)
base::operator()(value);
else if (this->specs()->type == 'p')
write_null_pointer(char_type());
else
this->write(L"(null)");
return this->out();
}
iterator operator()(basic_string_view<char_type> value) {
return base::operator()(value);
}
iterator operator()(monostate value) { return base::operator()(value); }
/** Formats a pointer. */
iterator operator()(const void* value) {
if (value) return base::operator()(value);
this->specs()->type = 0;
write_null_pointer(char_type());
return this->out();
}
/** Formats an argument of a custom (user-defined) type. */
iterator operator()(typename basic_format_arg<context_type>::handle handle) {
handle.format(context_.parse_context(), context_);
return this->out();
}
};
template <typename T> struct printf_formatter {
printf_formatter() = delete;
template <typename ParseContext>
auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
return ctx.begin();
}
template <typename FormatContext>
auto format(const T& value, FormatContext& ctx) -> decltype(ctx.out()) {
detail::format_value(detail::get_container(ctx.out()), value);
return ctx.out();
}
};
/**
This template formats data and writes the output through an output iterator.
*/
template <typename OutputIt, typename Char> class basic_printf_context {
public:
/** The character type for the output. */
using char_type = Char;
using iterator = OutputIt;
using format_arg = basic_format_arg<basic_printf_context>;
using parse_context_type = basic_printf_parse_context<Char>;
template <typename T> using formatter_type = printf_formatter<T>;
private:
using format_specs = basic_format_specs<char_type>;
OutputIt out_;
basic_format_args<basic_printf_context> args_;
parse_context_type parse_ctx_;
static void parse_flags(format_specs& specs, const Char*& it,
const Char* end);
// Returns the argument with specified index or, if arg_index is -1, the next
// argument.
format_arg get_arg(int arg_index = -1);
// Parses argument index, flags and width and returns the argument index.
int parse_header(const Char*& it, const Char* end, format_specs& specs);
public:
/**
\rst
Constructs a ``printf_context`` object. References to the arguments are
stored in the context object so make sure they have appropriate lifetimes.
\endrst
*/
basic_printf_context(OutputIt out, basic_string_view<char_type> format_str,
basic_format_args<basic_printf_context> args)
: out_(out), args_(args), parse_ctx_(format_str) {}
OutputIt out() { return out_; }
void advance_to(OutputIt it) { out_ = it; }
detail::locale_ref locale() { return {}; }
format_arg arg(int id) const { return args_.get(id); }
parse_context_type& parse_context() { return parse_ctx_; }
FMT_CONSTEXPR void on_error(const char* message) {
parse_ctx_.on_error(message);
}
/** Formats stored arguments and writes the output to the range. */
template <typename ArgFormatter = printf_arg_formatter<OutputIt, Char>>
OutputIt format();
};
template <typename OutputIt, typename Char>
void basic_printf_context<OutputIt, Char>::parse_flags(format_specs& specs,
const Char*& it,
const Char* end) {
for (; it != end; ++it) {
switch (*it) {
case '-':
specs.align = align::left;
break;
case '+':
specs.sign = sign::plus;
break;
case '0':
specs.fill[0] = '0';
break;
case ' ':
if (specs.sign != sign::plus) {
specs.sign = sign::space;
}
break;
case '#':
specs.alt = true;
break;
default:
return;
}
}
}
template <typename OutputIt, typename Char>
typename basic_printf_context<OutputIt, Char>::format_arg
basic_printf_context<OutputIt, Char>::get_arg(int arg_index) {
if (arg_index < 0)
arg_index = parse_ctx_.next_arg_id();
else
parse_ctx_.check_arg_id(--arg_index);
return detail::get_arg(*this, arg_index);
}
template <typename OutputIt, typename Char>
int basic_printf_context<OutputIt, Char>::parse_header(const Char*& it,
const Char* end,
format_specs& specs) {
int arg_index = -1;
char_type c = *it;
if (c >= '0' && c <= '9') {
// Parse an argument index (if followed by '$') or a width possibly
// preceded with '0' flag(s).
detail::error_handler eh;
int value = parse_nonnegative_int(it, end, eh);
if (it != end && *it == '$') { // value is an argument index
++it;
arg_index = value;
} else {
if (c == '0') specs.fill[0] = '0';
if (value != 0) {
// Nonzero value means that we parsed width and don't need to
// parse it or flags again, so return now.
specs.width = value;
return arg_index;
}
}
}
parse_flags(specs, it, end);
// Parse width.
if (it != end) {
if (*it >= '0' && *it <= '9') {
detail::error_handler eh;
specs.width = parse_nonnegative_int(it, end, eh);
} else if (*it == '*') {
++it;
specs.width = static_cast<int>(visit_format_arg(
detail::printf_width_handler<char_type>(specs), get_arg()));
}
}
return arg_index;
}
template <typename OutputIt, typename Char>
template <typename ArgFormatter>
OutputIt basic_printf_context<OutputIt, Char>::format() {
auto out = this->out();
const Char* start = parse_ctx_.begin();
const Char* end = parse_ctx_.end();
auto it = start;
while (it != end) {
char_type c = *it++;
if (c != '%') continue;
if (it != end && *it == c) {
out = std::copy(start, it, out);
start = ++it;
continue;
}
out = std::copy(start, it - 1, out);
format_specs specs;
specs.align = align::right;
// Parse argument index, flags and width.
int arg_index = parse_header(it, end, specs);
if (arg_index == 0) on_error("argument not found");
// Parse precision.
if (it != end && *it == '.') {
++it;
c = it != end ? *it : 0;
if ('0' <= c && c <= '9') {
detail::error_handler eh;
specs.precision = parse_nonnegative_int(it, end, eh);
} else if (c == '*') {
++it;
specs.precision = static_cast<int>(
visit_format_arg(detail::printf_precision_handler(), get_arg()));
} else {
specs.precision = 0;
}
}
format_arg arg = get_arg(arg_index);
// For d, i, o, u, x, and X conversion specifiers, if a precision is
// specified, the '0' flag is ignored
if (specs.precision >= 0 && arg.is_integral())
specs.fill[0] =
' '; // Ignore '0' flag for non-numeric types or if '-' present.
if (specs.precision >= 0 && arg.type() == detail::type::cstring_type) {
auto str = visit_format_arg(detail::get_cstring<Char>(), arg);
auto str_end = str + specs.precision;
auto nul = std::find(str, str_end, Char());
arg = detail::make_arg<basic_printf_context>(basic_string_view<Char>(
str,
detail::to_unsigned(nul != str_end ? nul - str : specs.precision)));
}
if (specs.alt && visit_format_arg(detail::is_zero_int(), arg))
specs.alt = false;
if (specs.fill[0] == '0') {
if (arg.is_arithmetic() && specs.align != align::left)
specs.align = align::numeric;
else
specs.fill[0] = ' '; // Ignore '0' flag for non-numeric types or if '-'
// flag is also present.
}
// Parse length and convert the argument to the required type.
c = it != end ? *it++ : 0;
char_type t = it != end ? *it : 0;
using detail::convert_arg;
switch (c) {
case 'h':
if (t == 'h') {
++it;
t = it != end ? *it : 0;
convert_arg<signed char>(arg, t);
} else {
convert_arg<short>(arg, t);
}
break;
case 'l':
if (t == 'l') {
++it;
t = it != end ? *it : 0;
convert_arg<long long>(arg, t);
} else {
convert_arg<long>(arg, t);
}
break;
case 'j':
convert_arg<intmax_t>(arg, t);
break;
case 'z':
convert_arg<size_t>(arg, t);
break;
case 't':
convert_arg<std::ptrdiff_t>(arg, t);
break;
case 'L':
// printf produces garbage when 'L' is omitted for long double, no
// need to do the same.
break;
default:
--it;
convert_arg<void>(arg, c);
}
// Parse type.
if (it == end) FMT_THROW(format_error("invalid format string"));
specs.type = static_cast<char>(*it++);
if (arg.is_integral()) {
// Normalize type.
switch (specs.type) {
case 'i':
case 'u':
specs.type = 'd';
break;
case 'c':
visit_format_arg(detail::char_converter<basic_printf_context>(arg),
arg);
break;
}
}
start = it;
// Format argument.
out = visit_format_arg(ArgFormatter(out, specs, *this), arg);
}
return std::copy(start, it, out);
}
template <typename Char>
using basic_printf_context_t =
basic_printf_context<std::back_insert_iterator<detail::buffer<Char>>, Char>;
using printf_context = basic_printf_context_t<char>;
using wprintf_context = basic_printf_context_t<wchar_t>;
using printf_args = basic_format_args<printf_context>;
using wprintf_args = basic_format_args<wprintf_context>;
/**
\rst
Constructs an `~fmt::format_arg_store` object that contains references to
arguments and can be implicitly converted to `~fmt::printf_args`.
\endrst
*/
template <typename... Args>
inline format_arg_store<printf_context, Args...> make_printf_args(
const Args&... args) {
return {args...};
}
/**
\rst
Constructs an `~fmt::format_arg_store` object that contains references to
arguments and can be implicitly converted to `~fmt::wprintf_args`.
\endrst
*/
template <typename... Args>
inline format_arg_store<wprintf_context, Args...> make_wprintf_args(
const Args&... args) {
return {args...};
}
template <typename S, typename Char = char_t<S>>
inline std::basic_string<Char> vsprintf(
const S& format,
basic_format_args<basic_printf_context_t<type_identity_t<Char>>> args) {
basic_memory_buffer<Char> buffer;
vprintf(buffer, to_string_view(format), args);
return to_string(buffer);
}
/**
\rst
Formats arguments and returns the result as a string.
**Example**::
std::string message = fmt::sprintf("The answer is %d", 42);
\endrst
*/
template <typename S, typename... Args,
typename Char = enable_if_t<detail::is_string<S>::value, char_t<S>>>
inline std::basic_string<Char> sprintf(const S& format, const Args&... args) {
using context = basic_printf_context_t<Char>;
return vsprintf(to_string_view(format), make_format_args<context>(args...));
}
template <typename S, typename Char = char_t<S>>
inline int vfprintf(
std::FILE* f, const S& format,
basic_format_args<basic_printf_context_t<type_identity_t<Char>>> args) {
basic_memory_buffer<Char> buffer;
vprintf(buffer, to_string_view(format), args);
size_t size = buffer.size();
return std::fwrite(buffer.data(), sizeof(Char), size, f) < size
? -1
: static_cast<int>(size);
}
/**
\rst
Prints formatted data to the file *f*.
**Example**::
fmt::fprintf(stderr, "Don't %s!", "panic");
\endrst
*/
template <typename S, typename... Args,
typename Char = enable_if_t<detail::is_string<S>::value, char_t<S>>>
inline int fprintf(std::FILE* f, const S& format, const Args&... args) {
using context = basic_printf_context_t<Char>;
return vfprintf(f, to_string_view(format),
make_format_args<context>(args...));
}
template <typename S, typename Char = char_t<S>>
inline int vprintf(
const S& format,
basic_format_args<basic_printf_context_t<type_identity_t<Char>>> args) {
return vfprintf(stdout, to_string_view(format), args);
}
/**
\rst
Prints formatted data to ``stdout``.
**Example**::
fmt::printf("Elapsed time: %.2f seconds", 1.23);
\endrst
*/
template <typename S, typename... Args,
FMT_ENABLE_IF(detail::is_string<S>::value)>
inline int printf(const S& format_str, const Args&... args) {
using context = basic_printf_context_t<char_t<S>>;
return vprintf(to_string_view(format_str),
make_format_args<context>(args...));
}
template <typename S, typename Char = char_t<S>>
inline int vfprintf(
std::basic_ostream<Char>& os, const S& format,
basic_format_args<basic_printf_context_t<type_identity_t<Char>>> args) {
basic_memory_buffer<Char> buffer;
vprintf(buffer, to_string_view(format), args);
detail::write_buffer(os, buffer);
return static_cast<int>(buffer.size());
}
/** Formats arguments and writes the output to the range. */
template <typename ArgFormatter, typename Char,
typename Context =
basic_printf_context<typename ArgFormatter::iterator, Char>>
typename ArgFormatter::iterator vprintf(
detail::buffer<Char>& out, basic_string_view<Char> format_str,
basic_format_args<type_identity_t<Context>> args) {
typename ArgFormatter::iterator iter(out);
Context(iter, format_str, args).template format<ArgFormatter>();
return iter;
}
/**
\rst
Prints formatted data to the stream *os*.
**Example**::
fmt::fprintf(cerr, "Don't %s!", "panic");
\endrst
*/
template <typename S, typename... Args, typename Char = char_t<S>>
inline int fprintf(std::basic_ostream<Char>& os, const S& format_str,
const Args&... args) {
using context = basic_printf_context_t<Char>;
return vfprintf(os, to_string_view(format_str),
make_format_args<context>(args...));
}
FMT_END_NAMESPACE
#endif // FMT_PRINTF_H_

386
external/fmtlib/include/fmt/ranges.h vendored Normal file
View File

@@ -0,0 +1,386 @@
// Formatting library for C++ - experimental range support
//
// Copyright (c) 2012 - present, Victor Zverovich
// All rights reserved.
//
// For the license information refer to format.h.
//
// Copyright (c) 2018 - present, Remotion (Igor Schulz)
// All Rights Reserved
// {fmt} support for ranges, containers and types tuple interface.
#ifndef FMT_RANGES_H_
#define FMT_RANGES_H_
#include <initializer_list>
#include <type_traits>
#include "format.h"
// output only up to N items from the range.
#ifndef FMT_RANGE_OUTPUT_LENGTH_LIMIT
# define FMT_RANGE_OUTPUT_LENGTH_LIMIT 256
#endif
FMT_BEGIN_NAMESPACE
template <typename Char> struct formatting_base {
template <typename ParseContext>
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
return ctx.begin();
}
};
template <typename Char, typename Enable = void>
struct formatting_range : formatting_base<Char> {
static FMT_CONSTEXPR_DECL const size_t range_length_limit =
FMT_RANGE_OUTPUT_LENGTH_LIMIT; // output only up to N items from the
// range.
Char prefix;
Char delimiter;
Char postfix;
formatting_range() : prefix('{'), delimiter(','), postfix('}') {}
static FMT_CONSTEXPR_DECL const bool add_delimiter_spaces = true;
static FMT_CONSTEXPR_DECL const bool add_prepostfix_space = false;
};
template <typename Char, typename Enable = void>
struct formatting_tuple : formatting_base<Char> {
Char prefix;
Char delimiter;
Char postfix;
formatting_tuple() : prefix('('), delimiter(','), postfix(')') {}
static FMT_CONSTEXPR_DECL const bool add_delimiter_spaces = true;
static FMT_CONSTEXPR_DECL const bool add_prepostfix_space = false;
};
namespace detail {
template <typename RangeT, typename OutputIterator>
OutputIterator copy(const RangeT& range, OutputIterator out) {
for (auto it = range.begin(), end = range.end(); it != end; ++it)
*out++ = *it;
return out;
}
template <typename OutputIterator>
OutputIterator copy(const char* str, OutputIterator out) {
while (*str) *out++ = *str++;
return out;
}
template <typename OutputIterator>
OutputIterator copy(char ch, OutputIterator out) {
*out++ = ch;
return out;
}
/// Return true value if T has std::string interface, like std::string_view.
template <typename T> class is_like_std_string {
template <typename U>
static auto check(U* p)
-> decltype((void)p->find('a'), p->length(), (void)p->data(), int());
template <typename> static void check(...);
public:
static FMT_CONSTEXPR_DECL const bool value =
is_string<T>::value || !std::is_void<decltype(check<T>(nullptr))>::value;
};
template <typename Char>
struct is_like_std_string<fmt::basic_string_view<Char>> : std::true_type {};
template <typename... Ts> struct conditional_helper {};
template <typename T, typename _ = void> struct is_range_ : std::false_type {};
#if !FMT_MSC_VER || FMT_MSC_VER > 1800
template <typename T>
struct is_range_<
T, conditional_t<false,
conditional_helper<decltype(std::declval<T>().begin()),
decltype(std::declval<T>().end())>,
void>> : std::true_type {};
#endif
/// tuple_size and tuple_element check.
template <typename T> class is_tuple_like_ {
template <typename U>
static auto check(U* p) -> decltype(std::tuple_size<U>::value, int());
template <typename> static void check(...);
public:
static FMT_CONSTEXPR_DECL const bool value =
!std::is_void<decltype(check<T>(nullptr))>::value;
};
// Check for integer_sequence
#if defined(__cpp_lib_integer_sequence) || FMT_MSC_VER >= 1900
template <typename T, T... N>
using integer_sequence = std::integer_sequence<T, N...>;
template <size_t... N> using index_sequence = std::index_sequence<N...>;
template <size_t N> using make_index_sequence = std::make_index_sequence<N>;
#else
template <typename T, T... N> struct integer_sequence {
using value_type = T;
static FMT_CONSTEXPR size_t size() { return sizeof...(N); }
};
template <size_t... N> using index_sequence = integer_sequence<size_t, N...>;
template <typename T, size_t N, T... Ns>
struct make_integer_sequence : make_integer_sequence<T, N - 1, N - 1, Ns...> {};
template <typename T, T... Ns>
struct make_integer_sequence<T, 0, Ns...> : integer_sequence<T, Ns...> {};
template <size_t N>
using make_index_sequence = make_integer_sequence<size_t, N>;
#endif
template <class Tuple, class F, size_t... Is>
void for_each(index_sequence<Is...>, Tuple&& tup, F&& f) FMT_NOEXCEPT {
using std::get;
// using free function get<I>(T) now.
const int _[] = {0, ((void)f(get<Is>(tup)), 0)...};
(void)_; // blocks warnings
}
template <class T>
FMT_CONSTEXPR make_index_sequence<std::tuple_size<T>::value> get_indexes(
T const&) {
return {};
}
template <class Tuple, class F> void for_each(Tuple&& tup, F&& f) {
const auto indexes = get_indexes(tup);
for_each(indexes, std::forward<Tuple>(tup), std::forward<F>(f));
}
template <typename Arg, FMT_ENABLE_IF(!is_like_std_string<
typename std::decay<Arg>::type>::value)>
FMT_CONSTEXPR const char* format_str_quoted(bool add_space, const Arg&) {
return add_space ? " {}" : "{}";
}
template <typename Arg, FMT_ENABLE_IF(is_like_std_string<
typename std::decay<Arg>::type>::value)>
FMT_CONSTEXPR const char* format_str_quoted(bool add_space, const Arg&) {
return add_space ? " \"{}\"" : "\"{}\"";
}
FMT_CONSTEXPR const char* format_str_quoted(bool add_space, const char*) {
return add_space ? " \"{}\"" : "\"{}\"";
}
FMT_CONSTEXPR const wchar_t* format_str_quoted(bool add_space, const wchar_t*) {
return add_space ? L" \"{}\"" : L"\"{}\"";
}
FMT_CONSTEXPR const char* format_str_quoted(bool add_space, const char) {
return add_space ? " '{}'" : "'{}'";
}
FMT_CONSTEXPR const wchar_t* format_str_quoted(bool add_space, const wchar_t) {
return add_space ? L" '{}'" : L"'{}'";
}
} // namespace detail
template <typename T> struct is_tuple_like {
static FMT_CONSTEXPR_DECL const bool value =
detail::is_tuple_like_<T>::value && !detail::is_range_<T>::value;
};
template <typename TupleT, typename Char>
struct formatter<TupleT, Char, enable_if_t<fmt::is_tuple_like<TupleT>::value>> {
private:
// C++11 generic lambda for format()
template <typename FormatContext> struct format_each {
template <typename T> void operator()(const T& v) {
if (i > 0) {
if (formatting.add_prepostfix_space) {
*out++ = ' ';
}
out = detail::copy(formatting.delimiter, out);
}
out = format_to(out,
detail::format_str_quoted(
(formatting.add_delimiter_spaces && i > 0), v),
v);
++i;
}
formatting_tuple<Char>& formatting;
size_t& i;
typename std::add_lvalue_reference<decltype(
std::declval<FormatContext>().out())>::type out;
};
public:
formatting_tuple<Char> formatting;
template <typename ParseContext>
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
return formatting.parse(ctx);
}
template <typename FormatContext = format_context>
auto format(const TupleT& values, FormatContext& ctx) -> decltype(ctx.out()) {
auto out = ctx.out();
size_t i = 0;
detail::copy(formatting.prefix, out);
detail::for_each(values, format_each<FormatContext>{formatting, i, out});
if (formatting.add_prepostfix_space) {
*out++ = ' ';
}
detail::copy(formatting.postfix, out);
return ctx.out();
}
};
template <typename T, typename Char> struct is_range {
static FMT_CONSTEXPR_DECL const bool value =
detail::is_range_<T>::value && !detail::is_like_std_string<T>::value &&
!std::is_convertible<T, std::basic_string<Char>>::value &&
!std::is_constructible<detail::std_string_view<Char>, T>::value;
};
template <typename RangeT, typename Char>
struct formatter<RangeT, Char,
enable_if_t<fmt::is_range<RangeT, Char>::value>> {
formatting_range<Char> formatting;
template <typename ParseContext>
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
return formatting.parse(ctx);
}
template <typename FormatContext>
typename FormatContext::iterator format(const RangeT& values,
FormatContext& ctx) {
auto out = detail::copy(formatting.prefix, ctx.out());
size_t i = 0;
auto it = values.begin();
auto end = values.end();
for (; it != end; ++it) {
if (i > 0) {
if (formatting.add_prepostfix_space) *out++ = ' ';
out = detail::copy(formatting.delimiter, out);
}
out = format_to(out,
detail::format_str_quoted(
(formatting.add_delimiter_spaces && i > 0), *it),
*it);
if (++i > formatting.range_length_limit) {
out = format_to(out, " ... <other elements>");
break;
}
}
if (formatting.add_prepostfix_space) *out++ = ' ';
return detail::copy(formatting.postfix, out);
}
};
template <typename Char, typename... T> struct tuple_arg_join : detail::view {
const std::tuple<T...>& tuple;
basic_string_view<Char> sep;
tuple_arg_join(const std::tuple<T...>& t, basic_string_view<Char> s)
: tuple{t}, sep{s} {}
};
template <typename Char, typename... T>
struct formatter<tuple_arg_join<Char, T...>, Char> {
template <typename ParseContext>
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
return ctx.begin();
}
template <typename FormatContext>
typename FormatContext::iterator format(
const tuple_arg_join<Char, T...>& value, FormatContext& ctx) {
return format(value, ctx, detail::make_index_sequence<sizeof...(T)>{});
}
private:
template <typename FormatContext, size_t... N>
typename FormatContext::iterator format(
const tuple_arg_join<Char, T...>& value, FormatContext& ctx,
detail::index_sequence<N...>) {
return format_args(value, ctx, std::get<N>(value.tuple)...);
}
template <typename FormatContext>
typename FormatContext::iterator format_args(
const tuple_arg_join<Char, T...>&, FormatContext& ctx) {
// NOTE: for compilers that support C++17, this empty function instantiation
// can be replaced with a constexpr branch in the variadic overload.
return ctx.out();
}
template <typename FormatContext, typename Arg, typename... Args>
typename FormatContext::iterator format_args(
const tuple_arg_join<Char, T...>& value, FormatContext& ctx,
const Arg& arg, const Args&... args) {
using base = formatter<typename std::decay<Arg>::type, Char>;
auto out = ctx.out();
out = base{}.format(arg, ctx);
if (sizeof...(Args) > 0) {
out = std::copy(value.sep.begin(), value.sep.end(), out);
ctx.advance_to(out);
return format_args(value, ctx, args...);
}
return out;
}
};
/**
\rst
Returns an object that formats `tuple` with elements separated by `sep`.
**Example**::
std::tuple<int, char> t = {1, 'a'};
fmt::print("{}", fmt::join(t, ", "));
// Output: "1, a"
\endrst
*/
template <typename... T>
FMT_CONSTEXPR tuple_arg_join<char, T...> join(const std::tuple<T...>& tuple,
string_view sep) {
return {tuple, sep};
}
template <typename... T>
FMT_CONSTEXPR tuple_arg_join<wchar_t, T...> join(const std::tuple<T...>& tuple,
wstring_view sep) {
return {tuple, sep};
}
/**
\rst
Returns an object that formats `initializer_list` with elements separated by
`sep`.
**Example**::
fmt::print("{}", fmt::join({1, 2, 3}, ", "));
// Output: "1, 2, 3"
\endrst
*/
template <typename T>
arg_join<const T*, const T*, char> join(std::initializer_list<T> list,
string_view sep) {
return join(std::begin(list), std::end(list), sep);
}
template <typename T>
arg_join<const T*, const T*, wchar_t> join(std::initializer_list<T> list,
wstring_view sep) {
return join(std::begin(list), std::end(list), sep);
}
FMT_END_NAMESPACE
#endif // FMT_RANGES_H_

View File

@@ -14,6 +14,8 @@
#include <opm/output/data/Solution.hpp>
#include <opm/output/data/Wells.hpp>
#include <opm/output/data/Groups.hpp>
#include <opm/parser/eclipse/Deck/UDAValue.hpp>
namespace Opm {
@@ -23,6 +25,12 @@ class ParseContext;
class Parser;
class Python;
class SummaryState;
class UDQState;
namespace Action {
class State;
}
class msim {
public:
@@ -31,16 +39,18 @@ public:
msim(const EclipseState& state);
Opm::UDAValue uda_val();
void well_rate(const std::string& well, data::Rates::opt rate, std::function<well_rate_function> func);
void solution(const std::string& field, std::function<solution_function> func);
void run(Schedule& schedule, EclipseIO& io, bool report_only);
void post_step(Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step);
void post_step(Schedule& schedule, Action::State& action_state, SummaryState& st, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& group_nwrk_data, size_t report_step);
private:
void run_step(const Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, EclipseIO& io) const;
void run_step(const Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, double dt, EclipseIO& io) const;
void output(SummaryState& st, size_t report_step, bool substep, double seconds_elapsed, const data::Solution& sol, const data::Wells& well_data, EclipseIO& io) const;
void simulate(const Schedule& schedule, const SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, double seconds_elapsed, double time_step) const;
void run_step(const Schedule& schedule, Action::State& action_state, SummaryState& st, UDQState& udq_state, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& group_nwrk_data, size_t report_step, EclipseIO& io) const;
void run_step(const Schedule& schedule, Action::State& action_state, SummaryState& st, UDQState& udq_state, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& group_nwrk_data, size_t report_step, double dt, EclipseIO& io) const;
void output(Action::State& action_state, SummaryState& st, const UDQState& udq_state, size_t report_step, bool substep, double seconds_elapsed, const data::Solution& sol, const data::Wells& well_data, const data::GroupAndNetworkValues& group_data, EclipseIO& io) const;
void simulate(const Schedule& schedule, const SummaryState& st, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& group_nwrk_data, size_t report_step, double seconds_elapsed, double time_step) const;
EclipseState state;
std::map<std::string, std::map<data::Rates::opt, std::function<well_rate_function>>> well_rates;

View File

@@ -29,6 +29,9 @@
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionContext.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
@@ -44,35 +47,42 @@ void msim::run(Schedule& schedule, EclipseIO& io, bool report_only) {
const double week = 7 * 86400;
data::Solution sol;
SummaryState st(std::chrono::system_clock::from_time_t(schedule.getStartTime()));
UDQState udq_state(schedule.getUDQConfig(0).params().undefinedValue());
Action::State action_state;
Python python;
io.writeInitial();
for (size_t report_step = 1; report_step < schedule.size(); report_step++) {
data::Wells well_data;
data::GroupAndNetworkValues group_nwrk_data;
if (report_only)
run_step(schedule, st, sol, well_data, report_step, io);
run_step(schedule, action_state, st, udq_state, sol, well_data, group_nwrk_data, report_step, io);
else {
double time_step = std::min(week, 0.5*schedule.stepLength(report_step - 1));
run_step(schedule, st, sol, well_data, report_step, time_step, io);
run_step(schedule, action_state, st, udq_state, sol, well_data, group_nwrk_data, report_step, time_step, io);
}
post_step(schedule, st, sol, well_data, report_step);
post_step(schedule, action_state, st, sol, well_data, group_nwrk_data, report_step);
const auto& exit_status = schedule.exitStatus();
if (exit_status.has_value())
return;
}
}
UDAValue msim::uda_val() {
return UDAValue();
}
void msim::post_step(Schedule& schedule, SummaryState& st, data::Solution& /* sol */, data::Wells& /* well_data */, size_t report_step) {
void msim::post_step(Schedule& schedule, Action::State& action_state, SummaryState& st, data::Solution& /* sol */, data::Wells& /* well_data */, data::GroupAndNetworkValues& /* grp_nwrk_data */, size_t report_step) {
const auto& actions = schedule.actions(report_step);
if (actions.empty())
return;
Action::Context context( st );
Action::Context context( st , schedule.getWListManager(report_step));
auto sim_time = schedule.simTime(report_step);
for (const auto& action : actions.pending(sim_time)) {
auto result = action->eval(sim_time, context);
for (const auto& action : actions.pending(action_state, sim_time)) {
auto result = action->eval(context);
if (result)
schedule.applyAction(report_step, *action, result);
}
@@ -83,12 +93,12 @@ void msim::post_step(Schedule& schedule, SummaryState& st, data::Solution& /* so
void msim::run_step(const Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, EclipseIO& io) const {
this->run_step(schedule, st, sol, well_data, report_step, schedule.stepLength(report_step - 1), io);
void msim::run_step(const Schedule& schedule, Action::State& action_state, SummaryState& st, UDQState& udq_state, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& grp_nwrk_data, size_t report_step, EclipseIO& io) const {
this->run_step(schedule, action_state, st, udq_state, sol, well_data, grp_nwrk_data, report_step, schedule.stepLength(report_step - 1), io);
}
void msim::run_step(const Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, double dt, EclipseIO& io) const {
void msim::run_step(const Schedule& schedule, Action::State& action_state, SummaryState& st, UDQState& udq_state, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& group_nwrk_data, size_t report_step, double dt, EclipseIO& io) const {
double start_time = schedule.seconds(report_step - 1);
double end_time = schedule.seconds(report_step);
double seconds_elapsed = start_time;
@@ -98,9 +108,7 @@ void msim::run_step(const Schedule& schedule, SummaryState& st, data::Solution&
if ((seconds_elapsed + time_step) > end_time)
time_step = end_time - seconds_elapsed;
this->simulate(schedule, st, sol, well_data, report_step, seconds_elapsed, time_step);
Opm::data::Group group_data;
this->simulate(schedule, st, sol, well_data, group_nwrk_data, report_step, seconds_elapsed, time_step);
seconds_elapsed += time_step;
@@ -110,24 +118,31 @@ void msim::run_step(const Schedule& schedule, SummaryState& st, data::Solution&
this->state,
schedule,
well_data,
group_data,
group_nwrk_data,
{});
this->output(st,
schedule.getUDQConfig( report_step ).eval(report_step, st, udq_state);
this->output(action_state,
st,
udq_state,
report_step,
(seconds_elapsed < end_time),
seconds_elapsed,
sol,
well_data,
group_nwrk_data,
io);
}
}
void msim::output(SummaryState& st, size_t report_step, bool substep, double seconds_elapsed, const data::Solution& sol, const data::Wells& well_data, EclipseIO& io) const {
RestartValue value(sol, well_data);
io.writeTimeStep(st,
void msim::output(Action::State& action_state, SummaryState& st, const UDQState& udq_state, size_t report_step, bool substep, double seconds_elapsed, const data::Solution& sol, const data::Wells& well_data, const data::GroupAndNetworkValues& group_nwrk_data, EclipseIO& io) const {
RestartValue value(sol, well_data, group_nwrk_data);
io.writeTimeStep(action_state,
st,
udq_state,
report_step,
substep,
seconds_elapsed,
@@ -135,7 +150,7 @@ void msim::output(SummaryState& st, size_t report_step, bool substep, double sec
}
void msim::simulate(const Schedule& schedule, const SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, double seconds_elapsed, double time_step) const {
void msim::simulate(const Schedule& schedule, const SummaryState& st, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& /* group_nwrk_data */, size_t report_step, double seconds_elapsed, double time_step) const {
for (const auto& sol_pair : this->solutions) {
auto func = sol_pair.second;
func(this->state, schedule, sol, report_step, seconds_elapsed + time_step);
@@ -144,15 +159,17 @@ void msim::simulate(const Schedule& schedule, const SummaryState& st, data::Solu
for (const auto& well_pair : this->well_rates) {
const std::string& well_name = well_pair.first;
const auto& sched_well = schedule.getWell(well_name, report_step);
if (sched_well.getStatus() != Well::Status::OPEN)
continue;
bool well_open = (sched_well.getStatus() == Well::Status::OPEN);
data::Well& well = well_data[well_name];
for (const auto& rate_pair : well_pair.second) {
auto rate = rate_pair.first;
auto func = rate_pair.second;
well.rates.set(rate, func(this->state, schedule, st, sol, report_step, seconds_elapsed + time_step));
if (well_open)
well.rates.set(rate, func(this->state, schedule, st, sol, report_step, seconds_elapsed + time_step));
else
well.rates.set(rate, 0.0);
}
// This is complete bogus; a temporary fix to pass an assert() in the

View File

@@ -15,6 +15,7 @@ set (opm-common_DEPS
list(APPEND opm-common_DEPS
# various runtime library enhancements
"Boost 1.44.0 COMPONENTS system unit_test_framework REQUIRED"
"OpenMP QUIET"
)
find_package_deps(opm-common)

View File

@@ -17,39 +17,63 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LOCATION_HPP
#define LOCATION_HPP
#ifndef KEYWORD_LOCATION_HPP
#define KEYWORD_LOCATION_HPP
#include <string>
namespace Opm {
class Location {
class KeywordLocation {
public:
/*
Observe that many error messages whcih should print out the name of the
problem keyword along with the location {} placeholders can be used. The
convention is:
{keyword} -> keyword
{file} -> filename
{line} -> lineno
This convention must be adhered to at the call site *creating the output
string*.
*/
std::string keyword;
std::string filename = "<memory string>";
std::size_t lineno = 0;
Location() = default;
Location(std::string fname, std::size_t lno) :
KeywordLocation() = default;
KeywordLocation(std::string kw, std::string fname, std::size_t lno) :
keyword(std::move(kw)),
filename(std::move(fname)),
lineno(lno)
{}
static Location serializeObject()
std::string message() const {
return this->keyword + " in " + this->filename + " at line " + std::to_string(this->lineno);
}
static KeywordLocation serializeObject()
{
Location result;
KeywordLocation result;
result.keyword = "KW";
result.filename = "test";
result.lineno = 1;
return result;
}
bool operator==(const Location& data) const {
return filename == data.filename &&
bool operator==(const KeywordLocation& data) const {
return keyword == data.keyword &&
filename == data.filename &&
lineno == data.lineno;
}
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(keyword);
serializer(filename);
serializer(lineno);
}

View File

@@ -23,7 +23,7 @@
#include <cstdint>
#include <string>
#include <opm/common/OpmLog/Location.hpp>
#include <opm/common/OpmLog/KeywordLocation.hpp>
namespace Opm {
@@ -59,8 +59,8 @@ namespace Log {
bool isPower2(int64_t x);
std::string fileMessage(const Location& location, const std::string& msg);
std::string fileMessage(int64_t messageType , const Location& location , const std::string& msg);
std::string fileMessage(const KeywordLocation& location, const std::string& msg);
std::string fileMessage(int64_t messageType , const KeywordLocation& location , const std::string& msg);
std::string prefixMessage(int64_t messageType , const std::string& msg);
std::string colorCodeMessage(int64_t messageType , const std::string& msg);

View File

@@ -1,191 +0,0 @@
/*
Copyright 2016 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SIMULATION_DATA_CONTAINER_HPP
#define SIMULATION_DATA_CONTAINER_HPP
#include <cstddef>
#include <string>
#include <map>
#include <vector>
namespace Opm {
/// The SimulationDataContainer is a simple container to manage
/// simulation data. The container is instantiated with information
/// of how many cells, faces and phases are present in the
/// reservoirmodel. You can then add data to the container by using the
///
/// registerCellData()
/// registerFaceData()
///
/// functions. The container owns and manages the data, but
/// mutable references are returned with the getCellData() and
/// getFaceData() methods, and the content will typically be
/// modified by external scope.
class SimulationDataContainer
{
public:
/// Main constructor setting the sizes for the contained data
/// types.
/// \param num_cells number of elements in cell data vectors
/// \param num_faces number of elements in face data vectors
/// \param num_phases number of phases, the number of components
/// in any data vector must equal 1 or this
/// number (this behaviour and argument is deprecated).
SimulationDataContainer(size_t num_cells, size_t num_faces, size_t num_phases);
/// Copy constructor.
/// Must be defined explicitly because class contains non-value objects
/// (the reference pointers pressure_ref_ etc.) that should not simply
/// be copied.
SimulationDataContainer(const SimulationDataContainer&);
/// Copy assignment operator.
/// Must be defined explicitly because class contains non-value objects
/// (the reference pointers pressure_ref_ etc.) that should not simply
/// be copied.
SimulationDataContainer& operator=(const SimulationDataContainer&);
/// Efficient O(1) swap.
void swap(SimulationDataContainer& other);
size_t numPhases() const;
size_t numFaces() const;
size_t numCells() const;
bool hasCellData( const std::string& name ) const;
/// Will register a data vector of size numCells() *
/// components.
void registerCellData( const std::string& name , size_t components , double initialValue = 0.0 );
std::vector<double>& getCellData( const std::string& name );
const std::vector<double>& getCellData( const std::string& name ) const;
bool hasFaceData( const std::string& name ) const;
void registerFaceData( const std::string& name , size_t components , double initialValue = 0.0 );
std::vector<double>& getFaceData( const std::string& name );
const std::vector<double>& getFaceData( const std::string& name ) const;
/// Will return the number of components of the celldata with
/// name @name:
///
/// numCellDataComponents( "PRESSURE" ) -> 1
/// numCellDataComponents( "SATURATION" ) -> 3
///
/// for a three phase model.
size_t numCellDataComponents( const std::string& name ) const;
bool equal(const SimulationDataContainer& other) const;
/// Will set the values of component nr @component in the
/// field @key. All the cells in @cells will be set to the
/// values in @values.
void setCellDataComponent( const std::string& key , size_t component , const std::vector<int>& cells , const std::vector<double>& values);
// Direct explicit field access for certain default fields.
// These methods are all deprecated, and will eventually be moved to
// concrete subclasses.
std::vector<double>& pressure ();
std::vector<double>& temperature ();
std::vector<double>& saturation ();
std::vector<double>& facepressure();
std::vector<double>& faceflux ();
const std::vector<double>& pressure () const;
const std::vector<double>& temperature () const;
const std::vector<double>& saturation () const;
const std::vector<double>& facepressure() const;
const std::vector<double>& faceflux () const;
const std::map<std::string, std::vector<double>>& cellData() const;
std::map<std::string, std::vector<double>>& cellData();
private:
void addDefaultFields();
void setReferencePointers();
size_t m_num_cells;
size_t m_num_faces;
size_t m_num_phases;
std::map< std::string , std::vector<double> > m_cell_data;
std::map< std::string , std::vector<double> > m_face_data;
std::vector<double>* pressure_ref_;
std::vector<double>* temperature_ref_;
std::vector<double>* saturation_ref_;
std::vector<double>* facepressure_ref_;
std::vector<double>* faceflux_ref_;
};
// Inline implementations of the direct accessors required to guarantee
// performance.
inline std::vector<double>& SimulationDataContainer::pressure( ) {
return *pressure_ref_;
}
inline std::vector<double>& SimulationDataContainer::temperature() {
return *temperature_ref_;
}
inline std::vector<double>& SimulationDataContainer::saturation() {
return *saturation_ref_;
}
inline std::vector<double>& SimulationDataContainer::facepressure() {
return *facepressure_ref_;
}
inline std::vector<double>& SimulationDataContainer::faceflux() {
return *faceflux_ref_;
}
inline const std::vector<double>& SimulationDataContainer::pressure( ) const {
return *pressure_ref_;
}
inline const std::vector<double>& SimulationDataContainer::temperature() const {
return *temperature_ref_;
}
inline const std::vector<double>& SimulationDataContainer::saturation() const {
return *saturation_ref_;
}
inline const std::vector<double>& SimulationDataContainer::facepressure() const {
return *facepressure_ref_;
}
inline const std::vector<double>& SimulationDataContainer::faceflux() const {
return *faceflux_ref_;
}
}
#endif

View File

@@ -20,7 +20,7 @@
#define OPM_FILESYSTEM_HPP
#if __cplusplus < 201703L || \
(defined(__GNUC__) && __GNUC__ < 8)
(defined(__GNUC__) && __GNUC__ < 8 && !defined(__clang__))
#include <experimental/filesystem>
#else
#include <filesystem>
@@ -32,7 +32,7 @@
namespace Opm
{
#if __cplusplus < 201703L || \
(defined(__GNUC__) && __GNUC__ < 8)
(defined(__GNUC__) && __GNUC__ < 8 && !defined(__clang__))
namespace filesystem = std::experimental::filesystem;
#else
namespace filesystem = std::filesystem;

View File

@@ -0,0 +1,121 @@
/*
Copyright 2020 Equinor ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_ERROR_HPP
#define OPM_ERROR_HPP
#include <stdexcept>
#include <string>
#include <vector>
#include <opm/common/OpmLog/KeywordLocation.hpp>
namespace Opm {
/*
The OpmInputError is a custom exception class which can be used to signal
errors in input handling. The importance of the OpmInputError exception is
*not* the tecnical functionality it provides, but rather the convention
surrounding it, when and how it should be used.
The OpmInputError should be used in situations which are "close to user
input", the root cause can either be incorrect user input or a bug/limitation
in opm. OpmInputError should only be used in situations where we have a good
understanding of the underlying issue, and can provide a good error message.
The local error handling should be complete when the OpmInputError is
instantiated, it should not be caught and rethrown in order to e.g. add
additional context or log messages. In order to avoid inadvertendly catching
this exception in a catch all block.
*/
class OpmInputError : public std::exception {
public:
/*
The message string will be used as format string in the fmt::format()
function as, and optional {} markers can be used to inject keyword,
filename and linenumber into the final what() message. The placeholders
must use named arguments
{keyword} -> loc.keyword
{file} -> loc.filename
{line} -> loc.lineno
additionally, the message can contain any number of positional
arguments to add further context to the message.
KeywordLocation loc("KW", "file.inc", 100);
OpmInputError("Error at line {line} in file {file} - keyword: {keyword} ignored", location);
OpmInputError("Error at line {line} in file {file} - keyword: {keyword} has invalid argument {}", invalid_argument);
*/
template<typename ... Args>
OpmInputError(const std::string& reason, const KeywordLocation& location, const Args& ...furtherLocations)
: locations { location, furtherLocations... }
, m_what {
locations.size() == 1
? formatSingle(reason, locations[0])
: formatMultiple(reason, locations)
}
{ }
/*
Allows for the initialisation of an OpmInputError from another exception.
Usage:
try {
.
.
.
} catch (const Opm::OpmInputError&) {
throw;
} catch (const std::exception& e) {
std::throw_with_nested(Opm::OpmInputError(e, location));
}
*/
OpmInputError(const std::exception& error, const KeywordLocation& location)
: locations { location }
, m_what { formatException(error, locations[0]) }
{ }
const char * what() const throw()
{
return this->m_what.c_str();
}
static std::string format(const std::string& msg_format, const KeywordLocation& loc);
private:
// The location member is here for debugging; depending on the msg_fmt
// passed in the constructor we might not have captured all the information
// in the location argument passed to the constructor.
std::vector<KeywordLocation> locations;
std::string m_what;
static std::string formatException(const std::exception& e, const KeywordLocation& loc);
static std::string formatSingle(const std::string& reason, const KeywordLocation&);
static std::string formatMultiple(const std::string& reason, const std::vector<KeywordLocation>&);
};
}
#endif

View File

@@ -0,0 +1,118 @@
/*
Copyright 2020 Equinor ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <cstring>
#include <string>
#include <unordered_map>
#include <vector>
#ifndef OPM_SERIALIZER_HPP
#define OPM_SERIALIZER_HPP
namespace Opm {
/*
This is a very basic serialization class used to support serialization of
small state objects from opm common. The main serialization code used in
opm/flow is initiated and controlled from the restart code, and therefor
slightly cumbersome to use for objects which should be serialized not as part
of the restart code.
*/
class Serializer {
public:
Serializer() = default;
explicit Serializer(const std::vector<char>& buffer_arg) :
buffer(buffer_arg)
{}
template <typename T>
void put(const T& value) {
this->pack(std::addressof(value), sizeof(T));
}
template <typename T>
void put(const T* ) {
throw std::logic_error("Serializer can not pack pointers");
}
template <typename T>
T get() {
T value;
std::memcpy(&value, &this->buffer[this->read_pos], sizeof(T));
this->read_pos += sizeof(T);
return value;
}
template<typename K, typename T>
void put(const std::unordered_map<K,T>& values) {
this->put(values.size());
for (const auto& value_pair : values) {
this->put(value_pair.first);
this->put(value_pair.second);
}
}
template<typename K, typename T>
std::unordered_map<K,T> get() {
std::unordered_map<K,T> values;
auto size = this->get<std::size_t>();
for (std::size_t index = 0; index < size; index++) {
auto key = this->get<K>();
auto value = this->get<T>();
values.insert( std::make_pair(key,value) );
}
return values;
}
std::vector<char> buffer;
private:
void pack(const void * ptr, std::size_t value_size) {
std::size_t write_pos = this->buffer.size();
std::size_t new_size = write_pos + value_size;
this->buffer.resize( new_size );
std::memcpy(&this->buffer[write_pos], ptr, value_size);
}
std::size_t read_pos = 0;
};
template <>
void inline Serializer::put(const std::string& value) {
this->put(value.size());
if (value.empty())
return;
this->pack(value.c_str(), value.size());
}
template<>
std::string inline Serializer::get<std::string>() {
std::string::size_type length = this->get<std::string::size_type>();
if (length == 0)
return std::string{};
this->read_pos += length;
return {std::addressof(this->buffer[this->read_pos - length]), length};
}
}
#endif

View File

@@ -43,7 +43,7 @@ namespace Opm
{
OPM_THROW(std::runtime_error, "Maximum number of iterations exceeded: " << maxiter << "\n"
<< "Current interval is [" << std::min(x0, x1) << ", "
<< std::max(x0, x1) << "]");
<< std::max(x0, x1) << "] abs(x0-x1) " << std::abs(x0-x1));
return -1e100; // Never reached.
}
};
@@ -64,7 +64,7 @@ namespace Opm
OPM_REPORT;
std::cerr << "Maximum number of iterations exceeded: " << maxiter
<< ", current interval is [" << std::min(x0, x1) << ", "
<< std::max(x0, x1) << "]";
<< std::max(x0, x1) << "] abs(x0-x1) " << std::abs(x0-x1);
return 0.5*(x0 + x1);
}
};
@@ -124,7 +124,7 @@ namespace Opm
iterations_used = 0;
// In every iteraton, x1 is the last point computed,
// and x0 is the last point computed that makes it a bracket.
while (fabs(x1 - x0) >= 1e-9*eps) {
while (fabs(x1 - x0) >= eps) {
double xnew = regulaFalsiStep(x0, x1, f0, f1);
double fnew = f(xnew);
// cout << "xnew = " << xnew << " fnew = " << fnew << endl;
@@ -221,7 +221,7 @@ namespace Opm
iterations_used = 0;
// In every iteraton, x1 is the last point computed,
// and x0 is the last point computed that makes it a bracket.
while (fabs(x1 - x0) >= 1e-9*eps) {
while (fabs(x1 - x0) >= eps) {
double xnew = regulaFalsiStep(x0, x1, f0, f1);
double fnew = f(xnew);
// cout << "xnew = " << xnew << " fnew = " << fnew << endl;
@@ -327,7 +327,7 @@ namespace Opm
// and x0 is the last point computed that makes it a bracket.
double width = fabs(x1 - x0);
double contraction = 1.0;
while (width >= 1e-9 * eps) {
while (width >= eps) {
// If we are contracting sufficiently to at least halve
// the interval width in two iterations we use regula
// falsi. Otherwise, we take a bisection step to avoid

View File

@@ -57,6 +57,8 @@ public:
void LoadData(const std::vector<std::string>& vectList) const;
void LoadData() const;
bool make_lodsmry_file();
std::chrono::system_clock::time_point startdate() const { return startdat; }
const std::vector<std::string>& keywordList() const;
@@ -65,7 +67,7 @@ public:
int timestepIdxAtReportstepStart(const int reportStep) const;
size_t numberOfTimeSteps() const { return timeStepList.size(); }
size_t numberOfTimeSteps() const { return nTstep; }
const std::string& get_unit(const std::string& name) const;
const std::string& get_unit(const SummaryNode& node) const;
@@ -74,9 +76,11 @@ public:
void write_rsm_file(std::optional<Opm::filesystem::path> = std::nullopt) const;
private:
Opm::filesystem::path inputFileName;
Opm::filesystem::path inputFileName, lodFileName;
int nI, nJ, nK, nSpecFiles;
size_t nVect;
bool fromSingleRun, lodEnabeled;
uint64_t lod_offset, lod_arr_size;
size_t nVect, nTstep;
std::vector<bool> formattedFiles;
std::vector<std::string> dataFileList;
@@ -129,6 +133,9 @@ private:
std::vector<std::tuple <std::string, uint64_t>> getListOfArrays(std::string filename, bool formatted);
std::vector<int> makeKeywPosVector(int speInd) const;
std::string read_string_from_disk(std::fstream& fileH, uint64_t size) const;
void inspect_lodsmry();
void Load_from_lodsmry(const std::vector<int>& keywIndVect) const;
};
}} // namespace Opm::EclIO

View File

@@ -23,6 +23,8 @@
#include <string>
#include <tuple>
#include <vector>
#include <functional>
namespace Opm { namespace EclIO {
@@ -31,6 +33,8 @@ namespace Opm { namespace EclIO {
float flipEndianFloat(float num);
double flipEndianDouble(double num);
bool isEOF(std::fstream* fileH);
bool fileExists(const std::string& filename);
bool isFormatted(const std::string& filename);
std::tuple<int, int> block_size_data_binary(eclArrType arrType);
std::tuple<int, int, int> block_size_data_formatted(eclArrType arrType);
@@ -49,6 +53,25 @@ namespace Opm { namespace EclIO {
void readFormattedHeader(std::fstream& fileH, std::string& arrName,
int64_t &num, Opm::EclIO::eclArrType &arrType);
template<typename T, typename T2>
std::vector<T> readBinaryArray(std::fstream& fileH, const int64_t size, Opm::EclIO::eclArrType type,
std::function<T(T2)>& flip);
std::vector<int> readBinaryInteArray(std::fstream &fileH, const int64_t size);
std::vector<float> readBinaryRealArray(std::fstream& fileH, const int64_t size);
std::vector<double> readBinaryDoubArray(std::fstream& fileH, const int64_t size);
std::vector<bool> readBinaryLogiArray(std::fstream &fileH, const int64_t size);
std::vector<std::string> readBinaryCharArray(std::fstream& fileH, const int64_t size);
template<typename T>
std::vector<T> readFormattedArray(const std::string& file_str, const int size, int64_t fromPos,
std::function<T(const std::string&)>& process);
std::vector<int> readFormattedInteArray(const std::string& file_str, const int64_t size, int64_t fromPos);
std::vector<std::string> readFormattedCharArray(const std::string& file_str, const int64_t size, int64_t fromPos);
std::vector<float> readFormattedRealArray(const std::string& file_str, const int64_t size, int64_t fromPos);
std::vector<bool> readFormattedLogiArray(const std::string& file_str, const int64_t size, int64_t fromPos);
std::vector<double> readFormattedDoubArray(const std::string& file_str, const int64_t size, int64_t fromPos);
}} // namespace Opm::EclIO

View File

@@ -15,7 +15,7 @@
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#ifndef OPM_IO_SUMMARYNODE_HPP
#define OPM_IO_SUMMARYNODE_HPP
@@ -25,11 +25,10 @@
#include <string>
#include <unordered_set>
namespace Opm::EclIO {
namespace Opm { namespace EclIO {
struct SummaryNode {
enum class Category {
Aquifer,
Well,
Group,
Field,
@@ -37,6 +36,8 @@ struct SummaryNode {
Block,
Connection,
Segment,
Aquifer,
Node,
Miscellaneous,
};
@@ -55,6 +56,7 @@ struct SummaryNode {
Type type;
std::string wgname;
int number;
std::string fip_region;
constexpr static int default_number { std::numeric_limits<int>::min() };
@@ -72,6 +74,6 @@ struct SummaryNode {
std::optional<std::string> display_number(number_renderer) const;
};
} // namespace Opm::EclIO
}} // namespace Opm::EclIO
#endif // OPM_IO_SUMMARYNODE_HPP

View File

@@ -32,12 +32,19 @@ struct RstHeader;
struct RstGroup {
RstGroup(const UnitSystem& unit_system,
const RstHeader& header,
const std::string* zwel,
const int * igrp,
const float * sgrp,
const double * xgrp);
std::string name;
int parent_group;
int prod_cmode;
int winj_cmode;
int ginj_cmode;
float oil_rate_limit;
float water_rate_limit;
float gas_rate_limit;

View File

@@ -24,10 +24,12 @@
#include <cstddef>
namespace Opm {
class UnitSystem;
namespace RestartIO {
struct RstHeader {
RstHeader(const std::vector<int>& intehead, const std::vector<bool>& logihead, const std::vector<double>& doubhead);
RstHeader(const UnitSystem& unit_system, const std::vector<int>& intehead, const std::vector<bool>& logihead, const std::vector<double>& doubhead);
int nx;
int ny;
@@ -86,6 +88,7 @@ struct RstHeader {
int ntfreg;
int nplmix;
int ngroup;
int nwgmax;
bool e300_radial;
bool e100_radial;
@@ -100,6 +103,7 @@ struct RstHeader {
bool dir_eps;
bool reversible_eps;
bool alt_eps;
bool group_control_active;
double next_timestep1;
double next_timestep2;
@@ -110,6 +114,8 @@ struct RstHeader {
double guide_rate_d;
double guide_rate_e;
double guide_rate_f;
double guide_rate_delay;
double guide_rate_damping;
double udq_range;
double udq_undefined;
double udq_eps;

View File

@@ -35,6 +35,11 @@ namespace Opm {
namespace RestartIO {
struct RstState {
RstState(const ::Opm::UnitSystem& unit_system,
const std::vector<int>& intehead,
const std::vector<bool>& logihead,
const std::vector<double>& doubhead);
RstState(const ::Opm::UnitSystem& unit_system,
const std::vector<int>& intehead,
const std::vector<bool>& logihead,

View File

@@ -66,6 +66,7 @@ struct RstWell {
std::array<int, 2> ij;
std::pair<int,int> k1k2;
WellType wtype;
int well_status;
int active_control;
int vfp_table;
int pred_requested_control;
@@ -88,12 +89,14 @@ struct RstWell {
float datum_depth;
float drainage_radius;
float efficiency_factor;
float alq_value;
double oil_rate;
double water_rate;
double gas_rate;
double liquid_rate;
double void_rate;
double thp;
double flow_bhp;
double wct;
double gor;

View File

@@ -30,12 +30,26 @@ namespace Json {
class JsonObject {
public:
JsonObject();
explicit JsonObject(const Opm::filesystem::path& jsonFile );
explicit JsonObject(const std::string& inline_json);
explicit JsonObject(const char * inline_json);
explicit JsonObject(cJSON * root);
~JsonObject();
void add(double value);
void add(int value);
void add(const std::string& value);
JsonObject add_array();
JsonObject add_object();
void add_item(const std::string& key, double value);
void add_item(const std::string& key, int value);
void add_item(const std::string& key, const std::string& value);
JsonObject add_array(const std::string& key);
JsonObject add_object(const std::string& key);
std::string dump() const;
bool has_item(const std::string& key) const;
JsonObject get_array_item( size_t index ) const;
JsonObject get_item(const std::string& key) const;

View File

@@ -46,14 +46,31 @@ namespace Opm { namespace data {
struct AquiferData {
int aquiferID; //< One-based ID, range 1..NANAQ
double pressure; //< Aquifer pressure
double fluxRate; //< Aquifer influx rate (liquid aquifer)
// TODO: volume should have a better name, since meaning not clear
double volume; //< Produced liquid volume
double initPressure; //< Aquifer's initial pressure
double datumDepth; //< Aquifer's pressure reference depth
AquiferType type;
std::shared_ptr<FetkovichData> aquFet;
double get(const std::string& key) const
{
if ( key == "AAQR" ) {
return this->fluxRate;
} else if ( key == "AAQT" ) {
return this->volume;
} else if ( key == "AAQP" ) {
return this->pressure;
}
return 0.;
}
};
// TODO: not sure what extension we will need
using Aquifers = std::map<int, AquiferData>;
}} // Opm::data
#endif // OPM_OUTPUT_AQUIFER_HPP

View File

@@ -36,10 +36,10 @@ namespace data {
from the TargetType enum which indicates why they they have been
added to the container - and where they are headed.
RESTART_SOLUTION : Fields which represent primary variables, and
are reqired for restart. Typically pressure and
suturation. WIll end up in the SOLUTION section of the restart
file.
RESTART_SOLUTION : Cell-based quantities that are output to the
SOLUTION section of the restart file. ECLIPSE-compatible names.
Many, but not necessarily all, of these quantities are required
for restarting the simulator.
RESTART_AUXILIARY : Fields with extra information, not required
for restart. Examples of this include fluid in place values or
@@ -52,6 +52,10 @@ namespace data {
will not be output anywhere else.
INIT : Fields which should go to the INIT file.
RESTART_OPM_EXTENDED: Cell-based quantities that are specific to
OPM-Flow. Output only to extended OPM restart files. Specifically
not output to ECLIPSE-compatible restart files.
*/
@@ -60,6 +64,7 @@ namespace data {
RESTART_AUXILIARY,
SUMMARY,
INIT,
RESTART_OPM_EXTENDED,
};
/**

View File

@@ -20,66 +20,173 @@
#ifndef OPM_OUTPUT_GROUPS_HPP
#define OPM_OUTPUT_GROUPS_HPP
#include <algorithm>
#include <cstddef>
#include <initializer_list>
#include <map>
#include <stdexcept>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>
#include <opm/output/data/GuideRateValue.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp>
namespace Opm {
namespace Opm { namespace data {
namespace data {
struct currentGroupConstraints {
struct GroupConstraints {
Opm::Group::ProductionCMode currentProdConstraint;
Opm::Group::InjectionCMode currentGasInjectionConstraint;
Opm::Group::InjectionCMode currentWaterInjectionConstraint;
template <class MessageBufferType>
void write(MessageBufferType& buffer) const;
template <class MessageBufferType>
void read(MessageBufferType& buffer);
inline currentGroupConstraints& set( Opm::Group::ProductionCMode cpc,
Opm::Group::InjectionCMode cgic,
Opm::Group::InjectionCMode cwic);
inline bool has();
bool operator==(const GroupConstraints& other) const
{
return this->currentProdConstraint == other.currentProdConstraint &&
this->currentGasInjectionConstraint == other.currentGasInjectionConstraint &&
this->currentWaterInjectionConstraint == other.currentWaterInjectionConstraint;
}
inline GroupConstraints& set(Opm::Group::ProductionCMode cpc,
Opm::Group::InjectionCMode cgic,
Opm::Group::InjectionCMode cwic);
};
class Group : public std::map<std::string, Opm::data::currentGroupConstraints> {
public:
struct GroupGuideRates {
GuideRateValue production{};
GuideRateValue injection{};
template <class MessageBufferType>
void write(MessageBufferType& buffer) const {
unsigned int size = this->size();
buffer.write(size);
for (const auto& witr : *this) {
const std::string& name = witr.first;
buffer.write(name);
const auto& pi_constr = witr.second;
pi_constr.write(buffer);
}
void write(MessageBufferType& buffer) const
{
this->production.write(buffer);
this->injection .write(buffer);
}
template <class MessageBufferType>
void read(MessageBufferType& buffer) {
unsigned int size;
void read(MessageBufferType& buffer)
{
this->production.read(buffer);
this->injection .read(buffer);
}
bool operator==(const GroupGuideRates& other) const
{
return this->production == other.production
&& this->injection == other.injection;
}
};
struct GroupData {
GroupConstraints currentControl;
GroupGuideRates guideRates{};
template <class MessageBufferType>
void write(MessageBufferType& buffer) const
{
this->currentControl.write(buffer);
this->guideRates .write(buffer);
}
template <class MessageBufferType>
void read(MessageBufferType& buffer)
{
this->currentControl.read(buffer);
this->guideRates .read(buffer);
}
bool operator==(const GroupData& other) const
{
return this->currentControl == other.currentControl
&& this->guideRates == other.guideRates;
}
};
struct NodeData {
double pressure { 0.0 };
template <class MessageBufferType>
void write(MessageBufferType& buffer) const
{
buffer.write(this->pressure);
}
template <class MessageBufferType>
void read(MessageBufferType& buffer)
{
buffer.read(this->pressure);
}
bool operator==(const NodeData& other) const
{
return this->pressure == other.pressure;
}
};
class GroupAndNetworkValues {
public:
std::map<std::string, GroupData> groupData {};
std::map<std::string, NodeData> nodeData {};
template <class MessageBufferType>
void write(MessageBufferType& buffer) const
{
this->writeMap(this->groupData, buffer);
this->writeMap(this->nodeData, buffer);
}
template <class MessageBufferType>
void read(MessageBufferType& buffer)
{
this->readMap(buffer, this->groupData);
this->readMap(buffer, this->nodeData);
}
bool operator==(const GroupAndNetworkValues& other) const
{
return (this->groupData == other.groupData)
&& (this->nodeData == other.nodeData);
}
void clear()
{
this->groupData.clear();
this->nodeData.clear();
}
private:
template <class MessageBufferType, class ValueType>
void writeMap(const std::map<std::string, ValueType>& map,
MessageBufferType& buffer) const
{
const unsigned int size = map.size();
buffer.write(size);
for (const auto& [name, elm] : map) {
buffer.write(name);
elm .write(buffer);
}
}
template <class MessageBufferType, class ValueType>
void readMap(MessageBufferType& buffer,
std::map<std::string, ValueType>& map)
{
unsigned int size;
buffer.read(size);
for (size_t i = 0; i < size; ++i) {
for (std::size_t i = 0; i < size; ++i) {
std::string name;
buffer.read(name);
currentGroupConstraints cgc;
cgc.read(buffer);
this->emplace(name, cgc);
auto elm = ValueType{};
elm.read(buffer);
map.emplace(name, std::move(elm));
}
}
};
@@ -87,35 +194,31 @@ namespace Opm {
/* IMPLEMENTATIONS */
template <class MessageBufferType>
void currentGroupConstraints::write(MessageBufferType& buffer) const {
void GroupConstraints::write(MessageBufferType& buffer) const {
buffer.write(this->currentProdConstraint);
buffer.write(this->currentGasInjectionConstraint);
buffer.write(this->currentWaterInjectionConstraint);
}
template <class MessageBufferType>
void currentGroupConstraints::read(MessageBufferType& buffer) {
void GroupConstraints::read(MessageBufferType& buffer) {
buffer.read(this->currentProdConstraint);
buffer.read(this->currentGasInjectionConstraint);
buffer.read(this->currentWaterInjectionConstraint);
}
inline currentGroupConstraints& currentGroupConstraints::set( Opm::Group::ProductionCMode cpc,
Opm::Group::InjectionCMode cgic,
Opm::Group::InjectionCMode cwic) {
inline GroupConstraints&
GroupConstraints::set(Opm::Group::ProductionCMode cpc,
Opm::Group::InjectionCMode cgic,
Opm::Group::InjectionCMode cwic)
{
this->currentGasInjectionConstraint = cgic;
this->currentWaterInjectionConstraint = cwic;
this->currentProdConstraint = cpc;
return *this;
}
inline bool currentGroupConstraints::has() {
return ((&this->currentGasInjectionConstraint != nullptr) && (&this->currentGasInjectionConstraint != nullptr)
&& (&this->currentProdConstraint != nullptr));
}
}} // Opm::data
#endif //OPM_OUTPUT_GROUPS_HPP

View File

@@ -0,0 +1,156 @@
/*
Copyright (c) 2020 Equinor ASA
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_OUTPUT_DATA_GUIDERATEVALUE_HPP
#define OPM_OUTPUT_DATA_GUIDERATEVALUE_HPP
#include <array>
#include <bitset>
#include <cstddef>
#include <stdexcept>
#include <string>
namespace Opm { namespace data {
class GuideRateValue {
public:
enum class Item : std::size_t {
Oil, Gas, Water, ResV,
// -- Must be last enumerator --
NumItems,
};
void clear()
{
this->mask_.reset();
this->value_.fill(0.0);
}
constexpr bool has(const Item p) const
{
const auto i = this->index(p);
return (i < Size) && this->mask_[i];
}
bool operator==(const GuideRateValue& vec) const
{
return (this->mask_ == vec.mask_)
&& (this->value_ == vec.value_);
}
double get(const Item p) const
{
if (! this->has(p)) {
throw std::invalid_argument {
"Request for Unset Item Value for " + this->itemName(p)
};
}
return this->value_[ this->index(p) ];
}
GuideRateValue& set(const Item p, const double value)
{
const auto i = this->index(p);
if (i >= Size) {
throw std::invalid_argument {
"Cannot Assign Item Value for Unsupported Item '"
+ this->itemName(p) + '\''
};
}
this->mask_.set(i);
this->value_[i] = value;
return *this;
}
GuideRateValue& operator+=(const GuideRateValue& rhs)
{
for (auto i = 0*Size; i < Size; ++i) {
if (rhs.mask_[i]) {
this->mask_.set(i);
this->value_[i] += rhs.value_[i];
}
}
return *this;
}
template <class MessageBufferType>
void write(MessageBufferType& buffer) const
{
auto maskrep = this->mask_.to_ullong();
buffer.write(maskrep);
for (const auto& x : this->value_) {
buffer.write(x);
}
}
template <class MessageBufferType>
void read(MessageBufferType& buffer)
{
this->clear();
{
auto mask = 0ull;
buffer.read(mask);
this->mask_ = std::bitset<Size>(mask);
}
for (auto& x : this->value_) {
buffer.read(x);
}
}
private:
enum { Size = static_cast<std::size_t>(Item::NumItems) };
std::bitset<Size> mask_{};
std::array<double, Size> value_{};
constexpr std::size_t index(const Item p) const noexcept
{
return static_cast<std::size_t>(p);
}
std::string itemName(const Item p) const
{
switch (p) {
case Item::Oil: return "Oil";
case Item::Gas: return "Gas";
case Item::Water: return "Water";
case Item::ResV: return "ResV";
case Item::NumItems:
return "Out of bounds (NumItems)";
}
return "Unknown (" + std::to_string(this->index(p)) + ')';
}
};
}} // namespace Opm::data
#endif // OPM_OUTPUT_DATA_GUIDERATEVALUE_HPP

View File

@@ -30,6 +30,8 @@
#include <unordered_map>
#include <vector>
#include <opm/output/data/GuideRateValue.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp>
namespace Opm {
@@ -66,6 +68,8 @@ namespace Opm {
well_potential_water = (1 << 14),
well_potential_oil = (1 << 15),
well_potential_gas = (1 << 16),
brine = (1 << 17),
alq = (1 << 18)
};
using enum_size = std::underlying_type< opt >::type;
@@ -117,6 +121,8 @@ namespace Opm {
double well_potential_water = 0.0;
double well_potential_oil = 0.0;
double well_potential_gas = 0.0;
double brine = 0.0;
double alq = 0.0;
};
struct Connection {
@@ -131,6 +137,7 @@ namespace Opm {
double cell_saturation_water;
double cell_saturation_gas;
double effective_Kh;
double trans_factor;
bool operator==(const Connection& conn2) const
{
@@ -251,6 +258,7 @@ namespace Opm {
std::vector< Connection > connections;
std::unordered_map<std::size_t, Segment> segments;
CurrentControl current_control;
GuideRateValue guide_rates{};
inline bool flowing() const noexcept;
template <class MessageBufferType>
@@ -291,7 +299,8 @@ namespace Opm {
control == well2.control &&
connections == well2.connections &&
segments == well2.segments &&
current_control == well2.current_control;
current_control == well2.current_control &&
guide_rates == well2.guide_rates;
}
};
@@ -404,7 +413,9 @@ namespace Opm {
productivity_index_oil == rate.productivity_index_oil &&
well_potential_water == rate.well_potential_water &&
well_potential_oil == rate.well_potential_oil &&
well_potential_gas == rate.well_potential_gas;
well_potential_gas == rate.well_potential_gas &&
brine == rate.brine &&
alq == rate.alq;
}
@@ -436,6 +447,8 @@ namespace Opm {
case opt::well_potential_water: return this->well_potential_water;
case opt::well_potential_oil: return this->well_potential_oil;
case opt::well_potential_gas: return this->well_potential_gas;
case opt::brine: return this->brine;
case opt::alq: return this->alq;
}
throw std::invalid_argument(
@@ -482,6 +495,8 @@ namespace Opm {
buffer.write(this->well_potential_water);
buffer.write(this->well_potential_oil);
buffer.write(this->well_potential_gas);
buffer.write(this->brine);
buffer.write(this->alq);
}
template <class MessageBufferType>
@@ -494,6 +509,7 @@ namespace Opm {
buffer.write(this->cell_saturation_water);
buffer.write(this->cell_saturation_gas);
buffer.write(this->effective_Kh);
buffer.write(this->trans_factor);
}
template <class MessageBufferType>
@@ -538,6 +554,7 @@ namespace Opm {
}
this->current_control.write(buffer);
this->guide_rates.write(buffer);
}
template <class MessageBufferType>
@@ -560,6 +577,8 @@ namespace Opm {
buffer.read(this->well_potential_water);
buffer.read(this->well_potential_oil);
buffer.read(this->well_potential_gas);
buffer.read(this->brine);
buffer.read(this->alq);
}
template <class MessageBufferType>
@@ -572,6 +591,7 @@ namespace Opm {
buffer.read(this->cell_saturation_water);
buffer.read(this->cell_saturation_gas);
buffer.read(this->effective_Kh);
buffer.read(this->trans_factor);
}
template <class MessageBufferType>
@@ -629,6 +649,7 @@ namespace Opm {
}
this->current_control.read(buffer);
this->guide_rates.read(buffer);
}
}} // Opm::data

View File

@@ -41,6 +41,10 @@ namespace Opm {
class Schedule;
class UDQInput;
class UDQActive;
namespace Action {
class State;
}
} // Opm
@@ -52,10 +56,11 @@ class AggregateActionxData
public:
explicit AggregateActionxData(const std::vector<int>& actDims);
void captureDeclaredActionxData( const Opm::Schedule& sched,
const Opm::SummaryState& st,
const std::vector<int>& actDims,
const std::size_t simStep);
void captureDeclaredActionxData( const Opm::Schedule& sched,
const Opm::Action::State& action_state,
const Opm::SummaryState& st,
const std::vector<int>& actDims,
const std::size_t simStep);
const std::vector<int>& getIACT() const
{

View File

@@ -74,8 +74,12 @@ public:
"GOPT", "GWPT", "GGPT", "GVPT", "GWIT",
"GGIT", "GVIT",
"GOPTH", "GWPTH", "GGPTH",
"GWITH", "GGITH"};
"GWITH", "GGITH",
"GOPGR", "GWPGR", "GGPGR", "GVPGR",
"GOIGR", "GWIGR", "GGIGR",
};
// Note: guide rates don't exist at the FIELD level.
const std::vector<std::string> restart_field_keys = {"FOPP", "FWPP", "FOPR", "FWPR", "FGPR",
"FVPR", "FWIR", "FGIR", "FWCT", "FGOR",
"FOPT", "FWPT", "FGPT", "FVPT", "FWIT",
@@ -101,6 +105,13 @@ public:
{"GVIT", 17},
{"GOPP", 22},
{"GWPP", 23},
{"GOPGR", 85},
{"GWPGR", 86},
{"GGPGR", 87},
{"GVPGR", 88},
{"GOIGR", 89},
{"GWIGR", 91},
{"GGIGR", 93},
{"GOPTH", 135},
{"GWPTH", 139},
{"GWITH", 140},
@@ -121,6 +132,26 @@ public:
{inj_cmode_enum::SALE, 0},
};
// Note: guide rates don't exist at the FIELD level.
const std::map<int, inj_cmode_enum> ICntlModeToiCMode = {
{0, inj_cmode_enum::NONE},
{1, inj_cmode_enum::RATE},
{2, inj_cmode_enum::RESV},
{3, inj_cmode_enum::REIN},
{4, inj_cmode_enum::VREP}, };
using p_cmode = Opm::Group::ProductionCMode;
const std::map<int, p_cmode> PCntlModeToPCMode = {
{0, p_cmode::NONE},
{1, p_cmode::ORAT},
{2, p_cmode::WRAT},
{3, p_cmode::GRAT},
{4, p_cmode::LRAT},
{9, p_cmode::CRAT},
{5, p_cmode::RESV},
{6, p_cmode::PRBL},
};
const std::map<std::string, size_t> fieldKeyToIndex = {
{"FOPR", 0},
{"FWPR", 1},

View File

@@ -41,6 +41,7 @@ namespace Opm {
class Schedule;
class UDQInput;
class UDQActive;
class UDQState;
} // Opm
namespace Opm { namespace RestartIO { namespace Helpers {
@@ -57,7 +58,7 @@ public:
void captureDeclaredUDQData(const Opm::Schedule& sched,
const std::size_t simStep,
const Opm::SummaryState& st,
const Opm::UDQState& udqState,
const std::vector<int>& inteHead);
const std::vector<int>& getIUDQ() const
@@ -94,12 +95,12 @@ void captureDeclaredUDQData(const Opm::Schedule& sched,
{
return this->dUDW_.data();
}
const std::vector<double>& getDUDG() const
{
return this->dUDG_.data();
}
const std::vector<double>& getDUDF() const
{
return this->dUDF_.data();
@@ -127,10 +128,10 @@ private:
/// Aggregate 'DUDW' array (Double Precision) for all UDQ data. (Dimension = max no wells * noOfUDQ's)
WindowedArray<double> dUDW_;
/// Aggregate 'DUDG' array (Double Precision) for all UDQ data. (Dimension = (max no groups + 1) * noOfUDQ's)
WindowedArray<double> dUDG_;
/// Aggregate 'DUDF' array (Double Precision) for all UDQ data. (Dimension = Number of FU - UDQ's, with value equal to the actual constraint)
WindowedArray<double> dUDF_;

View File

@@ -33,6 +33,9 @@ namespace Opm {
class Schedule;
class SummaryState;
class UnitSystem;
namespace Action {
class State;
}
} // Opm
namespace Opm { namespace data {
@@ -40,22 +43,18 @@ namespace Opm { namespace data {
}} // Opm::data
namespace Opm { namespace RestartIO { namespace Helpers {
struct ActionResStatus {
std::vector<Opm::Action::Result> result;
std::vector<std::string> name;
};
class AggregateWellData
{
public:
explicit AggregateWellData(const std::vector<int>& inteHead);
void captureDeclaredWellData(const Schedule& sched,
const UnitSystem& units,
const std::size_t sim_step,
const ::Opm::SummaryState& smry,
const std::vector<int>& inteHead);
void captureDeclaredWellData(const Schedule& sched,
const UnitSystem& units,
const std::size_t sim_step,
const ::Opm::Action::State& action_state,
const ::Opm::SummaryState& smry,
const std::vector<int>& inteHead);
void captureDynamicWellData(const Opm::Schedule& sched,
const std::size_t sim_step,
@@ -86,8 +85,8 @@ namespace Opm { namespace RestartIO { namespace Helpers {
return this->zWell_.data();
}
private:
/// Aggregate 'IWEL' array (Integer) for all wells.
WindowedArray<int> iWell_;

View File

@@ -45,7 +45,8 @@ class EclipseState;
class Schedule;
class SummaryConfig;
class SummaryState;
class UDQState;
namespace Action { class State; }
/*!
* \brief A class to write the reservoir state and the well state of a
* blackoil simulation to disk using the Eclipse binary format.
@@ -174,7 +175,9 @@ public:
* hardcoded static map misc_units in Summary.cpp.
*/
void writeTimeStep( const SummaryState& st,
void writeTimeStep( const Action::State& action_state,
const SummaryState& st,
const UDQState& udq_state,
int report_step,
bool isSubstep,
double seconds_elapsed,
@@ -220,7 +223,7 @@ public:
missing, if the bool is false missing keywords will be ignored
(there will *not* be an empty vector in the return value).
*/
RestartValue loadRestart(SummaryState& summary_state, const std::vector<RestartKey>& solution_keys, const std::vector<RestartKey>& extra_keys = {}) const;
RestartValue loadRestart(Action::State& action_state, SummaryState& summary_state, const std::vector<RestartKey>& solution_keys, const std::vector<RestartKey>& extra_keys = {}) const;
const out::Summary& summary();
EclipseIO( const EclipseIO& ) = delete;

View File

@@ -86,6 +86,7 @@ namespace RestartIO {
int litmin;
int mxwsit;
int mxwpit;
int wseg_mx_rst;
};
struct Group {

View File

@@ -20,23 +20,25 @@
#ifndef OPM_REGION_CACHE_HPP
#define OPM_REGION_CACHE_HPP
#include <map>
#include <set>
#include <vector>
namespace Opm {
class Schedule;
class EclipseGrid;
class FieldPropsManager;
namespace out {
class RegionCache {
public:
RegionCache() = default;
RegionCache(const std::vector<int>& fipnum, const EclipseGrid& grid, const Schedule& schedule);
const std::vector<std::pair<std::string,size_t>>& connections( int region_id ) const;
RegionCache(const std::set<std::string>& fip_regions, const FieldPropsManager& fp, const EclipseGrid& grid, const Schedule& schedule);
const std::vector<std::pair<std::string,size_t>>& connections( const std::string& region_name, int region_id ) const;
private:
std::vector<std::pair<std::string,size_t>> connections_empty;
std::map<int , std::vector<std::pair<std::string,size_t>>> connection_map;
std::map<std::pair<std::string, int> , std::vector<std::pair<std::string,size_t>>> connection_map;
};
}
}

View File

@@ -26,7 +26,6 @@
#include <opm/output/eclipse/RestartValue.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
#include <string>
#include <utility>
@@ -37,6 +36,8 @@ namespace Opm {
class EclipseGrid;
class EclipseState;
class Schedule;
class UDQState;
class SummaryState;
} // namespace Opm
@@ -46,6 +47,12 @@ namespace Opm { namespace EclIO { namespace OutputStream {
}}}
namespace Opm { namespace Action {
class State;
}}
/*
The two free functions RestartIO::save() and RestartIO::load() can
be used to save and load reservoir and well state from restart
@@ -76,12 +83,15 @@ namespace Opm { namespace RestartIO {
const EclipseState& es,
const EclipseGrid& grid,
const Schedule& schedule,
const Action::State& action_state,
const SummaryState& sumState,
const UDQState& udqState,
bool write_double = false);
RestartValue load(const std::string& filename,
int report_step,
Action::State& action_state,
SummaryState& summary_state,
const std::vector<RestartKey>& solution_keys,
const EclipseState& es,

View File

@@ -28,6 +28,7 @@
#include <opm/output/data/Aquifer.hpp>
#include <opm/output/data/Solution.hpp>
#include <opm/output/data/Wells.hpp>
#include <opm/output/data/Groups.hpp>
namespace Opm {
@@ -70,10 +71,11 @@ namespace Opm {
using ExtraVector = std::vector<std::pair<RestartKey, std::vector<double>>>;
data::Solution solution;
data::Wells wells;
data::GroupAndNetworkValues grp_nwrk;
ExtraVector extra;
std::vector<data::AquiferData> aquifer;
RestartValue(data::Solution sol, data::Wells wells_arg);
RestartValue(data::Solution sol, data::Wells wells_arg, data::GroupAndNetworkValues grpn_nwrk_arg);
RestartValue() {}
@@ -89,6 +91,7 @@ namespace Opm {
{
return solution == val2.solution &&
wells == val2.wells &&
grp_nwrk == val2.grp_nwrk &&
extra == val2.extra;
}
};

View File

@@ -21,6 +21,7 @@
#define OPM_OUTPUT_SUMMARY_HPP
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp>
#include <opm/output/data/Aquifer.hpp>
#include <map>
#include <memory>
@@ -38,7 +39,7 @@ namespace Opm {
namespace Opm { namespace data {
class WellRates;
class Group;
class GroupAndNetworkValues;
}} // namespace Opm::data
namespace Opm { namespace out {
@@ -59,20 +60,21 @@ public:
void add_timestep(const SummaryState& st, const int report_step);
void eval(SummaryState& summary_state,
const int report_step,
const double secs_elapsed,
const EclipseState& es,
const Schedule& schedule,
const data::WellRates& well_solution,
const data::Group& group_solution,
const GlobalProcessParameters& single_values,
const RegionParameters& region_values = {},
const BlockValues& block_values = {}) const;
void eval(SummaryState& summary_state,
const int report_step,
const double secs_elapsed,
const EclipseState& es,
const Schedule& schedule,
const data::WellRates& well_solution,
const data::GroupAndNetworkValues& group_and_nwrk_solution,
GlobalProcessParameters single_values,
const RegionParameters& region_values = {},
const BlockValues& block_values = {},
const data::Aquifers& aquifers_values = {}) const;
void write() const;
private:
class SummaryImplementation;
std::unique_ptr<SummaryImplementation> pImpl_;

View File

@@ -59,6 +59,8 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
TrgFIP = 101,
TrgSFT = 102,
GRpar_damp = 144, // Guiderate parameter damping factor
WsegRedFac = 145, // WSEGITER parameter (item 3) Reduction factor (F_R)
WsegIncFac = 146, // WSEGITER parameter (item 4) Increas factor (F_I)
UdqPar_2 = 212, // UDQPARAM item number 2 (Permitted range (+/-) of user-defined quantities)
UdqPar_3 = 213, // UDQPARAM item number 3 (Value given to undefined elements when outputting data)
UdqPar_4 = 214, // UDQPARAM item number 4 (fractional equality tolerance used in ==, <= etc. functions)

View File

@@ -24,7 +24,7 @@
namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems {
namespace SGroup {
enum prod_index : std::vector<float>::size_type {
OilRateLimit = 6, // Group's oil production target/limit
@@ -32,8 +32,12 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
GasRateLimit = 8, // Group's gas production target/limit
LiqRateLimit = 9, // Group's liquid production target/limit
};
enum inj_index : std::vector<float>::size_type {
oilSurfRateLimit = 10, // Group's oil surface volume injection rate target/limit
oilResRateLimit = 11, // Group's oil reservoir volume injection rate target/limit
oilReinjectionLimit = 12, // Group's oil reinjection fraction target/limit
oilVoidageLimit = 13, // Group's oil voidage injection fraction target/limit
waterSurfRateLimit = 15, //i Group's water surface volume injection rate target/limit
waterResRateLimit = 16, // Group's water reservoir volume injection rate target/limit
waterReinjectionLimit = 17, // Group's water reinjection fraction target/limit
@@ -46,8 +50,17 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
};
} // SGroup
namespace IGroup {
enum index : std::vector<int>::size_type {
ProdCMode = 1,
WInjCMode = 16,
GInjCMode = 21,
ParentGroup = 28,
};
}
namespace XGroup {
enum index : std::vector<double>::size_type {
OilPrRate = 0, // Group's oil production rate
@@ -74,6 +87,26 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
OilPrPot = 22, // Group's oil production potential
WatPrPot = 23, // Group's water production potential
OilPrGuideRate = 85, // Group's producer guide rate for oil.
WatPrGuideRate = 86, // Group's producer guide rate for water.
GasPrGuideRate = 87, // Group's producer guide rate for gas.
VoidPrGuideRate = 88, // Group's producer guide rate for reservoir voidage volume.
OilInjGuideRate = 89, // Group's injection guide rate for oil.
WatInjGuideRate = 91, // Group's injection guide rate for water.
WatInjGuideRate_2 = 92, // Second copy of group's injection guide rate for water.
// Not fully characterised.
GasInjGuideRate = 93, // Groups injection guide rate for gas.
OilPrGuideRate_2 = 127, // Second copy of group's producer guide rate for oil.
// Not fully characterised.
WatPrGuideRate_2 = 128, // Second copy of group's producer guide rate for water.
// Not fully characterised.
GasPrGuideRate_2 = 129, // Second copy of group's producer guide rate for gas.
// Not fully characterised.
VoidPrGuideRate_2 = 130, // Second copy of group's producer guide rate for
// reservoir voidage volume. Not fully characterised.
HistOilPrTotal = 135, // Group's total cumulative oil
// production (observed/historical rates)
HistWatPrTotal = 139, // Group's total cumulative water

View File

@@ -118,6 +118,8 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
IHOURZ = 206, // IHOURZ = current simulation time HH:MM:SS number of hours (HH) (0-23).
IMINTS = 207, // IMINTS = current simulation time HH:MM:SS number of minutes (MM) (0-59).
WSEGITR_IT2 = 208, // NR - maximum no of times that a new iteration cycle with a reduced Wp will be started
MAX_ACT_COND = 245, // Maximum number of conditions pr action
MAX_AN_AQUIFERS = 252, // Maximum number of analytic aquifers

View File

@@ -55,6 +55,8 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
GasFlowFract = 10, // Normalised Gas flow rate fraction
Pressure = 11, // Segment pressure
item31 = 30, // Very close to Normalised Water flow rate fraction - value used pr today
item40 = 39, // Unknown
ValveLength = 40, // Length of valve

View File

@@ -36,14 +36,14 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
ActWCtrl = 7, // Well's active target control mode (constraint).
item9 = 8, // Unknown
item11 = 10, // Unknown
Status = 10, // Well status
VFPTab = 11, // ID (one-based) of well's current VFP table.
PredReqWCtrl = 15, // Well's requested control mode from
// simulation deck (WCONINJE, WCONPROD).
item18 = 17, // Unknown
XFlow = 22,
XFlow = 22,
item25 = 24, // Unknown
item32 = 31, // Unknown
item48 = 47, // Unknown
@@ -58,6 +58,20 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
// Value 0 for regular wells
// Value #segments for MS wells
MSW_PlossMod = 81, // index for Pressure loss model for well segments
// ih value for this index is:
// = 0 for regular wells
// = 0 for MSW wells and HFA (WELSEGS item 6)
// = 1 for MSW wells and HF- (WELSEGS item 6)
// = 2 for MSW wells and H-- (WELSEGS item 6)
MSW_MulPhaseMod = 85, // index for Multiphase flow model for well segments - NOTE DF - model is not implemented yet!!
// ih value for this index is:
// = 0 for regular wells
// = 1 for MSW wells and HO (WELSEGS item 7)
// = 2 for MSW wells and DF (WELSEGS item 7)
CompOrd = 98, // Well's completion ordering scheme.
};
@@ -66,7 +80,6 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
enum WellCtrlMode : int {
WMCtlUnk = -10, // Unknown well control mode (OPM only)
Group = - 1, // Well under group control
Shut = 0, // Well is shut
OilRate = 1, // Well controlled by oil rate
WatRate = 2, // Well controlled by water rate
GasRate = 3, // Well controlled by gas rate
@@ -97,6 +110,29 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
// appearance in simulation model's
// COMPDAT keyword.
};
enum PLossMod : int {
HFA = 0, // Components of pressure loss in MSW model for well (WELSEGS item 6)
// Hydrostatic, Friction, Acceleration
HF_ = 1, // Hydrostatic, Friction,
H__ = 2, // Hydrostatic
};
/*enum MPMod : int {
HO = 1, // Multiphase flow model for MSW well
// Homogeneous flow
DF = 2, // Drift flux model
};*/
enum Status : int {
Shut = -1000,
Stop = 0,
Open = 1,
Auto = 3,
};
} // Value
} // IWell
@@ -113,10 +149,11 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
BHPTarget = 6, // Well's bottom hole pressure target
DatumDepth = 9, // Well's reference depth for BHP
Alq_value = 10, // Well's artificial lift quantity
DrainageRadius = 17, // Well's drainage radius - item 7 from WELSPECS
EfficiencyFactor1 = 24, // Item2 from WEFAC; this value is repeated at two locations.
EfficiencyFactor2 = 31, //
EfficiencyFactor2 = 31, // Item2 from WEFAC
HistLiqRateTarget = 33, // Well's historical/observed liquid
// rate target/limit
@@ -135,7 +172,7 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
GasPrRate = 2, // Well's gas production rate
LiqPrRate = 3, // Well's liquid production rate
VoidPrRate = 4, // Well's reservoir voidage production rate
TubHeadPr = 5, // Well's tubing head pressure
FlowBHP = 6, // Well's flowing/producing bottom hole pressure
WatCut = 7, // Well's producing water cut
GORatio = 8, // Well's producing gas/oil ratio
@@ -157,6 +194,12 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
BHPTarget = 41, // Well's current BHP Target/Limit
PrimGuideRate = 48, // Well's "primary" guide rate (oil for producers,
// preferred phase for injectors)
WatPrGuideRate = 49, // Well's producer guide rate for water
GasPrGuideRate = 50, // Well's producer guide rate for gas
VoidPrGuideRate = 68, // Well's producer guide rate for reservoir voidag volume
HistOilPrTotal = 75, // Well's total cumulative oil production
// (observed/historical rates)
HistWatPrTotal = 76, // Well's total cumulative water
@@ -169,6 +212,15 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
HistGasInjTotal = 82, // Well's total cumulative gas injection
// (observed/historical rates)
PrimGuideRate_2 = 91, // Second copy of well's primary guide rate.
// Not fully characterised.
WatPrGuideRate_2 = 92, // Second copy of well's producer guide rate for water.
// Not fully characterised.
GasPrGuideRate_2 = 93, // Second copy of well's producer guide rate for gas
// Not fully characterised.
VoidPrGuideRate_2 = 94, // Second copy of well's producer guide rate for reservoir voidage
// Not fully characterised.
WatVoidPrRate = 122, // Well's voidage production rate
GasVoidPrRate = 123, // Well's voidage production rate
};

View File

@@ -26,6 +26,7 @@ namespace Opm {
class Schedule;
class EclipseGrid;
class UnitSystem;
namespace RptIO {
@@ -35,12 +36,13 @@ namespace Opm {
unsigned value,
const Schedule& schedule,
const EclipseGrid& grid,
const UnitSystem& unit_system,
std::size_t time_step
);
namespace workers {
void write_WELSPECS(std::ostream&, unsigned, const Schedule&, const EclipseGrid& grid, std::size_t);
void write_WELSPECS(std::ostream&, unsigned, const Schedule&, const EclipseGrid& grid, const UnitSystem&, std::size_t);
} } }
#endif // OPM_WRITE_RPT_HPP

View File

@@ -29,7 +29,7 @@
#include <opm/parser/eclipse/Deck/DeckValue.hpp>
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
#include <opm/parser/eclipse/Deck/value_status.hpp>
#include <opm/common/OpmLog/Location.hpp>
#include <opm/common/OpmLog/KeywordLocation.hpp>
namespace Opm {
class DeckOutput;
@@ -43,7 +43,7 @@ namespace Opm {
DeckKeyword();
explicit DeckKeyword(const ParserKeyword& parserKeyword);
DeckKeyword(const Location& location, const std::string& keywordName);
DeckKeyword(const KeywordLocation& location, const std::string& keywordName);
DeckKeyword(const ParserKeyword& parserKeyword, const std::vector<std::vector<DeckValue>>& record_list, UnitSystem& system_active, UnitSystem& system_default);
DeckKeyword(const ParserKeyword& parserKeyword, const std::vector<int>& data);
DeckKeyword(const ParserKeyword& parserKeyword, const std::vector<double>& data, UnitSystem& system_active, UnitSystem& system_default);
@@ -52,7 +52,7 @@ namespace Opm {
const std::string& name() const;
void setFixedSize();
const Location& location() const;
const KeywordLocation& location() const;
size_t size() const;
@@ -105,7 +105,7 @@ namespace Opm {
private:
std::string m_keywordName;
Location m_location;
KeywordLocation m_location;
std::vector< DeckRecord > m_recordList;
bool m_isDataKeyword;

View File

@@ -34,7 +34,6 @@ namespace Opm {
void start_record( );
void end_record( );
void split_record();
void start_keyword(const std::string& kw);
void end_keyword(bool add_slash);
@@ -53,8 +52,10 @@ namespace Opm {
size_t row_count;
bool record_on;
int org_precision;
bool split_line;
template <typename T> void write_value(const T& value);
void split_record();
void write_sep( );
void set_precision(int precision);
};

View File

@@ -54,6 +54,9 @@ public:
double getSI() const;
bool zero() const;
//epsilon limit = 1.E-20 (~= 0.)
double epsilonLimit() const;
template<typename T>
bool is() const;
@@ -65,6 +68,7 @@ public:
bool operator!=(const UDAValue& other) const;
UDAValue& operator=(double value);
UDAValue& operator=(const std::string& value);
void update_value(const UDAValue& other);
bool is_numeric() { return numeric_value; }

View File

@@ -118,6 +118,8 @@ namespace Opm {
const std::vector<AquiferCT::AQUCT_data>& data() const;
bool operator==(const AquiferCT& other) const;
bool hasAquifer(const int aquID) const;
template<class Serializer>
void serializeOp(Serializer& serializer)
{

View File

@@ -43,6 +43,7 @@ public:
const Aquifetp& fetp() const;
const Aquancon& connections() const;
bool operator==(const AquiferConfig& other);
bool hasAquifer(const int aquID) const;
template<class Serializer>
void serializeOp(Serializer& serializer)

View File

@@ -76,6 +76,8 @@ class Aquifetp {
std::vector<Aquifetp::AQUFETP_data>::const_iterator end() const;
bool operator==(const Aquifetp& other) const;
bool hasAquifer(const int aquID) const;
template<class Serializer>
void serializeOp(Serializer& serializer)
{

View File

@@ -38,9 +38,10 @@ namespace Opm {
static EclipseConfig serializeObject();
const InitConfig& init() const;
InitConfig& init();
IOConfig& io();
const IOConfig& io() const;
const InitConfig& init() const;
const InitConfig& getInitConfig() const;
bool operator==(const EclipseConfig& data) const;

View File

@@ -77,6 +77,8 @@ namespace Opm {
IOConfig& getIOConfig();
const InitConfig& getInitConfig() const;
InitConfig& getInitConfig();
const SimulationConfig& getSimulationConfig() const;
virtual const EclipseGrid& getInputGrid() const;

View File

@@ -21,8 +21,9 @@
#ifndef BOX_HPP_
#define BOX_HPP_
#include <vector>
#include <cstddef>
#include <limits>
#include <vector>
namespace Opm {
class DeckRecord;
@@ -31,17 +32,32 @@ namespace Opm {
class Box {
public:
struct cell_index {
std::size_t global_index;
std::size_t active_index;
std::size_t data_index;
cell_index(std::size_t g,std::size_t a, std::size_t d) :
global_index(g),
active_index(a),
data_index(d)
{}
/*
This constructor should is used by the global_index_list() member
which will return a list of *all* the cells in the box. In this
case the active_index will be set to the global_index. This is a
hack to simplify the treatment of global fields in the FieldProps
implementation.
*/
cell_index(std::size_t g, std::size_t d) :
global_index(g),
active_index(g),
data_index(d)
{}
};
Box(const EclipseGrid& grid);
@@ -53,7 +69,7 @@ namespace Opm {
bool isGlobal() const;
size_t getDim(size_t idim) const;
const std::vector<cell_index>& index_list() const;
const std::vector<size_t>& getIndexList() const;
const std::vector<Box::cell_index>& global_index_list() const;
bool equal(const Box& other) const;
@@ -73,8 +89,8 @@ namespace Opm {
size_t m_offset[3];
bool m_isGlobal;
std::vector<size_t> global_index_list;
std::vector<cell_index> m_index_list;
std::vector<cell_index> m_active_index_list;
std::vector<cell_index> m_global_index_list;
int lower(int dim) const;
int upper(int dim) const;

View File

@@ -22,7 +22,6 @@
#define OPM_PARSER_ECLIPSE_GRID_HPP
#include <opm/parser/eclipse/EclipseState/Util/Value.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/MinpvMode.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/PinchMode.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridDims.hpp>
@@ -32,6 +31,7 @@
#include <array>
#include <memory>
#include <optional>
#include <vector>
namespace Opm {
@@ -110,6 +110,7 @@ namespace Opm {
double getPinchThresholdThickness( ) const;
PinchMode::ModeEnum getPinchOption( ) const;
PinchMode::ModeEnum getMultzOption( ) const;
PinchMode::ModeEnum getPinchGapMode( ) const;
MinpvMode::ModeEnum getMinpvMode() const;
const std::vector<double>& getMinpvVector( ) const;
@@ -193,9 +194,10 @@ namespace Opm {
private:
std::vector<double> m_minpvVector;
MinpvMode::ModeEnum m_minpvMode;
Value<double> m_pinch;
std::optional<double> m_pinch;
PinchMode::ModeEnum m_pinchoutMode;
PinchMode::ModeEnum m_multzMode;
PinchMode::ModeEnum m_pinchGapMode;
bool m_circle = false;

View File

@@ -0,0 +1,146 @@
/*
Copyright 2020 Equinor AS.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FIELD_DATA_HPP
#define FIELD_DATA_HPP
#include <opm/parser/eclipse/EclipseState/Grid/Box.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/Keywords.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/FieldData.hpp>
#include <opm/parser/eclipse/Deck/value_status.hpp>
#include<string>
#include<vector>
#include<optional>
#include<array>
#include<algorithm>
namespace Opm
{
namespace Fieldprops
{
template<typename T>
static void compress(std::vector<T>& data, const std::vector<bool>& active_map) {
std::size_t shift = 0;
for (std::size_t g = 0; g < active_map.size(); g++) {
if (active_map[g] && shift > 0) {
data[g - shift] = data[g];
continue;
}
if (!active_map[g])
shift += 1;
}
data.resize(data.size() - shift);
}
template<typename T>
struct FieldData {
std::vector<T> data;
std::vector<value::status> value_status;
keywords::keyword_info<T> kw_info;
std::optional<std::vector<T>> global_data;
std::optional<std::vector<value::status>> global_value_status;
mutable bool all_set;
FieldData() = default;
FieldData(const keywords::keyword_info<T>& info, std::size_t active_size, std::size_t global_size) :
data(std::vector<T>(active_size)),
value_status(active_size, value::status::uninitialized),
kw_info(info),
all_set(false)
{
if (global_size != 0) {
this->global_data = std::vector<T>(global_size);
this->global_value_status = std::vector<value::status>(global_size, value::status::uninitialized);
}
if (info.scalar_init)
this->default_assign( *info.scalar_init );
}
std::size_t size() const {
return this->data.size();
}
bool valid() const {
if (this->all_set)
return true;
static const std::array<value::status,2> invalid_value = {value::status::uninitialized, value::status::empty_default};
const auto& it = std::find_first_of(this->value_status.begin(), this->value_status.end(), invalid_value.begin(), invalid_value.end());
this->all_set = (it == this->value_status.end());
return this->all_set;
}
void compress(const std::vector<bool>& active_map) {
Fieldprops::compress(this->data, active_map);
Fieldprops::compress(this->value_status, active_map);
}
void copy(const FieldData<T>& src, const std::vector<Box::cell_index>& index_list) {
for (const auto& ci : index_list) {
this->data[ci.active_index] = src.data[ci.active_index];
this->value_status[ci.active_index] = src.value_status[ci.active_index];
}
}
void default_assign(T value) {
std::fill(this->data.begin(), this->data.end(), value);
std::fill(this->value_status.begin(), this->value_status.end(), value::status::valid_default);
if (this->global_data) {
std::fill(this->global_data->begin(), this->global_data->end(), value);
std::fill(this->global_value_status->begin(), this->global_value_status->end(), value::status::valid_default);
}
}
void default_assign(const std::vector<T>& src) {
if (src.size() != this->size())
throw std::invalid_argument("Size mismatch got: " + std::to_string(src.size()) + " expected: " + std::to_string(this->size()));
std::copy(src.begin(), src.end(), this->data.begin());
std::fill(this->value_status.begin(), this->value_status.end(), value::status::valid_default);
}
void default_update(const std::vector<T>& src) {
if (src.size() != this->size())
throw std::invalid_argument("Size mismatch got: " + std::to_string(src.size()) + " expected: " + std::to_string(this->size()));
for (std::size_t i = 0; i < src.size(); i++) {
if (!value::has_value(this->value_status[i])) {
this->value_status[i] = value::status::valid_default;
this->data[i] = src[i];
}
}
}
void update(std::size_t index, T value, value::status status) {
this->data[index] = value;
this->value_status[index] = status;
}
};
} // end namespace Fieldprops
} // end namespace Opm
#endif // FIELD_DATA_HPP

View File

@@ -21,6 +21,9 @@
#include <memory>
#include <vector>
#include <unordered_map>
#include <opm/parser/eclipse/EclipseState/Grid/TranCalculator.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/FieldData.hpp>
namespace Opm {
@@ -32,30 +35,6 @@ class TableManager;
class FieldPropsManager {
struct MemInfo {
std::size_t global_size;
std::size_t active_size;
std::size_t int_fields;
std::size_t double_fields;
std::size_t total;
MemInfo(std::size_t gsize, std::size_t asize, std::size_t num_int, std::size_t num_double) :
global_size(gsize),
active_size(asize),
int_fields(num_int),
double_fields(num_double),
total(asize * sizeof(int) * num_int + // The integer fields like SATNUM and PVTNUM
asize * sizeof(double) * num_double + // The double fields like PORO and SWATINIT
asize * sizeof(double) * 2 + // Depth and volume of all active cells
asize * sizeof(unsigned char) * (num_int + num_double) + // The per cell value status flag
gsize * sizeof(int)) // The global ACTNUM mapping
{
};
};
public:
// The default constructor should be removed when the FieldPropsManager is mandatory
@@ -66,7 +45,6 @@ public:
const std::string& default_region() const;
virtual std::vector<int> actnum() const;
virtual std::vector<double> porv(bool global = false) const;
MemInfo meminfo( ) const;
/*
The number of cells in the fields managed by this FieldPropsManager.
@@ -178,6 +156,14 @@ public:
template <typename T>
std::vector<std::string> keys() const;
const Fieldprops::FieldData<int>&
get_int_field_data(const std::string& keyword) const;
/// \brief Get double field data associated with a keyword
/// \param allow_unsupported If true we deactivate some checks on the
/// keyword and thus allow getting FieldData used by the TranCalculator.
const Fieldprops::FieldData<double>&
get_double_field_data(const std::string& keyword, bool allow_unsupported=false) const;
virtual const std::vector<int>& get_int(const std::string& keyword) const { return this->get<int>(keyword); }
virtual std::vector<int> get_global_int(const std::string& keyword) const { return this->get_global<int>(keyword); }
@@ -187,6 +173,59 @@ public:
virtual bool has_int(const std::string& keyword) const { return this->has<int>(keyword); }
virtual bool has_double(const std::string& keyword) const { return this->has<double>(keyword); }
/*
The transmissibility keywords TRANX, TRANY and TRANZ do not really fit
well in the FieldProps system. The opm codebase is based on a full
internalization in the parse phase, and then passing fully assembled
objects to the simulator. When it comes to the transmissibilities this
model breaks down because the input code in opm-common is not capable of
calculating the transmissibility, that is performed in the simulator.
The EDIT section can have modifiers on TRAN, these must be applied *after*
the initial transmissibilities are calculated. To support this all the
modifiers to the TRAN{XYZ} fields are assembled in "transmissibility
calculators", and then these modifiers can be applied to a TRAN vector
after it has been calculated in the simulator. Usage from the simulator
could look like:
const auto& fp = eclState.fieldProps();
// Calculate transmissibilities using grid and permeability
std::vector<double> tranx = ....
// Check if there are any active TRANX modifiers and apply them
if (fp.tran_active("TRANX"))
fp.apply_tran("TRANX", tranx);
*/
/*
Will check if there are any TRAN{XYZ} modifiers active in the deck.
*/
virtual bool tran_active(const std::string& keyword) const;
/*
Will apply all the TRAN modifiers which are present in the deck on the
already initialized vector tran_data. The vector tran_data should be
organised as the data vectors in the fieldpropsmanager - i.e. one element
for each active cell - in lexicographical order. The operations which are
supported by the transmissibility calculator are those given by the enum
ScalarOperation in FieldProps.hpp.
*/
virtual void apply_tran(const std::string& keyword, std::vector<double>& tran_data) const;
/*
When using MPI the FieldPropsManager is typically only assembled on the
root node and then distributed to the other nodes afterwards. These
methods are support methods for that, the real data used by the
transmissibility calculators is in the form of custom 3D fields, they are
distributed the same way the rest of the 3D fields are distributed.
*/
virtual std::vector<char> serialize_tran() const;
virtual void deserialize_tran(const std::vector<char>& buffer);
private:
/*
Return the keyword values as a std::vector<>. All elements in the return
@@ -217,8 +256,8 @@ private:
/*
This is exactly like the get() method, but the returned vector will have
global cartesian size, where all inactive cells have been filled with
zeros.
global cartesian size. If the field has a default value that value will be
used for filling in in the inactive cells, otherwise zero is used.
*/
template <typename T>
std::vector<T> get_global(const std::string& keyword) const;
@@ -227,6 +266,16 @@ private:
std::shared_ptr<FieldProps> fp;
};
void deserialize_tran(std::unordered_map<std::string, Fieldprops::TranCalculator>& tran,
const std::vector<char>& buffer);
template<class MapType>
void apply_tran(const std::unordered_map<std::string, Fieldprops::TranCalculator>& tran,
const MapType& double_data,
std::size_t active_size,
const std::string& keyword, std::vector<double>& data);
}
#endif

View File

@@ -0,0 +1,67 @@
/*
Copyright 2020 Equinor AS.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_KEYWORDS_HPP
#define OPM_KEYWORDS_HPP
namespace Opm
{
namespace Fieldprops
{
namespace keywords {
template <typename T>
struct keyword_info {
std::optional<std::string> unit = std::nullopt;
std::optional<T> scalar_init = std::nullopt;
bool multiplier = false;
bool top = false;
bool global = false;
keyword_info<T>& init(T init_value) {
this->scalar_init = init_value;
return *this;
}
keyword_info<T>& unit_string(const std::string& unit_string) {
this->unit = unit_string;
return *this;
}
keyword_info<T>& distribute_top(bool dtop) {
this->top = dtop;
return *this;
}
keyword_info<T>& mult(bool m) {
this->multiplier = m;
return *this;
}
keyword_info<T>& global_kw(bool g) {
this->global = g;
return *this;
}
};
} // end namespace Keywords
} // end namespace Fieldprops
} //end namespace Opm
#endif //OPM_KEYWORDS_HPP

View File

@@ -23,7 +23,6 @@
#include <opm/parser/eclipse/EclipseState/Grid/FieldPropsManager.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/FaceDir.hpp>
#include <opm/parser/eclipse/EclipseState/Util/Value.hpp>
namespace Opm {

View File

@@ -28,7 +28,9 @@ namespace Opm {
enum ModeEnum {
ALL = 1,
TOPBOT = 2,
TOP = 3
TOP = 3,
GAP = 4,
NOGAP = 5,
};
const std::string PinchMode2String(const ModeEnum enumValue);

View File

@@ -19,227 +19,147 @@
#ifndef ECLIPSE_SATFUNCPROPERTY_INITIALIZERS_HPP
#define ECLIPSE_SATFUNCPROPERTY_INITIALIZERS_HPP
#include <memory>
#include <string>
#include <vector>
namespace Opm {
class Phases;
class TableManager;
}
namespace satfunc {
namespace Opm { namespace satfunc {
std::vector<double> SGLEndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
/// Collection of unscaled/raw saturation range endpoints extracted
/// directly from tables of tabulated saturation functions.
struct RawTableEndPoints
{
/// Connate saturation endpoints
struct {
/// Connate gas saturation. One value for each saturation region.
/// All zero values unless gas is an active phase.
std::vector<double> gas;
std::vector<double> ISGLEndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
/// Connate water saturation. One value for each saturation region.
/// All zero values unless water is an active phase.
std::vector<double> water;
} connate;
std::vector<double> SGUEndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
/// Critical saturation endpoints
struct {
/// Critical saturation of oil in oil/gas two-phase system. One
/// value for each saturation region. All zero values unless oil
/// is an active phase.
std::vector<double> oil_in_gas;
std::vector<double> ISGUEndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
/// Critical saturation of oil in oil/water two-phase system. One
/// value for each saturation region. All zero values unless oil
/// is an active phase.
std::vector<double> oil_in_water;
std::vector<double> SWLEndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
/// Critical saturation of gas. One value for each saturation
/// region. All zero values unless oil is an active phase.
std::vector<double> gas;
std::vector<double> ISWLEndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
/// Critical saturation of water. One value for each saturation
/// region. All zero values unless oil is an active phase.
std::vector<double> water;
} critical;
std::vector<double> SWUEndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
/// Maximum saturation endpoints
struct {
/// Maximum gas saturation value. One value for each saturation
/// region All zero values unless gas is an active phase.
std::vector<double> gas;
std::vector<double> ISWUEndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
/// Maximum water saturation value. One value for each saturation
/// region All zero values unless gas is an active phase.
std::vector<double> water;
} maximum;
};
std::vector<double> SGCREndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
/// Collection of unscaled/raw saturation function value range endpoints
/// extracted directly from tables of tabulated saturation functions.
struct RawFunctionValues
{
/// Function values for relative permeability of oil.
struct {
/// Maximum relative permeability value of oil in both oil/gas and
/// oil/water two-phase systems. One value for each saturation
/// region. All zero values unless oil is an active phase.
std::vector<double> max;
std::vector<double> ISGCREndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
/// Relative permeability of oil at critical saturation of
/// displacing phase in oil/gas two-phase system. One value for
/// each saturation region. All zero values unless oil is
/// an active phase.
std::vector<double> rg;
std::vector<double> SOWCREndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
/// Relative permeability of oil at critical saturation of
/// displacing phase in oil/water two-phase system. One value
/// for each saturation region. All zero values unless oil is
/// an active phase.
std::vector<double> rw;
} kro;
std::vector<double> ISOWCREndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
/// Function values for relative permeability of gas.
struct {
/// Maximum relative permeability value of gas. One value for
/// each saturation region. All zero values unless gas is
/// an active phase.
std::vector<double> max;
std::vector<double> SOGCREndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
/// Relative permeability of gas at critical saturation of
/// displacing phase. One value for each saturation region.
/// All zero values unless gas is an active phase.
std::vector<double> r;
} krg;
std::vector<double> ISOGCREndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
/// Function values for relative permeability of gas.
struct {
/// Maximum relative permeability value of water. One value for
/// each saturation region. All zero values unless water is
/// an active phase.
std::vector<double> max;
std::vector<double> SWCREndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
/// Relative permeability of water at critical saturation of
/// displacing phase. One value for each saturation region.
/// All zero values unless water is an active phase.
std::vector<double> r;
} krw;
std::vector<double> ISWCREndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
/// Maximum capillary function values.
struct {
/// Maximum gas/oil capillary pressure value (Pg - Po). One
/// value for each saturation region. All zero values unless
/// both gas and oil are active phase.
std::vector<double> g;
std::vector<double> PCWEndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
/// Maximum oil/eater capillary pressure value (Po - Pw). One
/// value for each saturation region. All zero values unless
/// both oil and water are active phase.
std::vector<double> w;
} pc;
};
std::vector<double> IPCWEndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
std::shared_ptr<RawTableEndPoints>
getRawTableEndpoints(const Opm::TableManager& tm,
const Opm::Phases& phases,
const double tolcrit);
std::vector<double> PCGEndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
std::vector<double> IPCGEndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
std::vector<double> KRWEndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
std::vector<double> IKRWEndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
std::vector<double> KRWREndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
std::vector<double> IKRWREndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
std::vector<double> KROEndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
std::vector<double> IKROEndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
std::vector<double> KRORWEndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
std::vector<double> IKRORWEndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
std::vector<double> KRORGEndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
std::vector<double> IKRORGEndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
std::vector<double> KRGEndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
std::vector<double> IKRGEndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
std::vector<double> KRGREndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
std::vector<double> IKRGREndpoint(const TableManager&,
const Phases&,
const std::vector<double>&,
const std::vector<int>&,
const std::vector<int>&);
std::shared_ptr<RawFunctionValues>
getRawFunctionValues(const Opm::TableManager& tm,
const Opm::Phases& phases,
const RawTableEndPoints& ep);
std::vector<double> init(const std::string& kewyord,
const TableManager& tables,
const Phases& phases,
const RawTableEndPoints& ep,
const std::vector<double>& cell_depth,
const std::vector<int>& num,
const std::vector<int>& endnum);
}
}
}} // namespace Opm::satfunc
#endif // ECLIPSE_SATFUNCPROPERTY_INITIALIZERS_HPP

View File

@@ -0,0 +1,107 @@
/*
Copyright 2020 Equinor AS.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TRAN_CALCULATOR_HPP
#define TRAN_CALCULATOR_HPP
#include<string>
#include <opm/parser/eclipse/EclipseState/Grid/Keywords.hpp>
namespace Opm
{
namespace Fieldprops
{
enum class ScalarOperation {
ADD = 1,
EQUAL = 2,
MUL = 3,
MIN = 4,
MAX = 5
};
class TranCalculator {
public:
struct TranAction {
ScalarOperation op;
std::string field;
};
TranCalculator(const std::string& name_arg) :
m_name(name_arg)
{}
std::string next_name() const {
return this->m_name + std::to_string( this->actions.size() );
}
std::vector<TranAction>::const_iterator begin() const {
return this->actions.begin();
}
std::vector<TranAction>::const_iterator end() const {
return this->actions.end();
}
void add_action(ScalarOperation op, const std::string& field) {
this->actions.push_back(TranAction{op, field});
}
std::size_t size() const {
return this->actions.size();
}
const std::string& name() const {
return this->m_name;
}
keywords::keyword_info<double> make_kw_info(ScalarOperation op) {
keywords::keyword_info<double> kw_info;
switch (op) {
case ScalarOperation::MUL:
kw_info.init(1);
break;
case ScalarOperation::ADD:
kw_info.init(0);
break;
case ScalarOperation::MAX:
kw_info.init(std::numeric_limits<double>::max());
break;
case ScalarOperation::MIN:
kw_info.init(std::numeric_limits<double>::lowest());
break;
default:
break;
}
return kw_info;
}
private:
std::string m_name;
std::vector<TranAction> actions;
};
} // namespace Fieldprops
} // end namespace Opm
#endif // TRAN_CALCULATOR_HPP

View File

@@ -165,7 +165,7 @@ namespace Opm {
const std::string& getEclipseInputPath() const;
void overrideNOSIM(bool nosim);
void consistentFileFlags();
std::string getRestartFileName(const std::string& restart_base, int report_step, bool output) const;

View File

@@ -21,7 +21,9 @@
#include <iosfwd>
#include <string>
#include <optional>
#include <opm/common/OpmLog/KeywordLocation.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/Tabdims.hpp>
#include <opm/parser/eclipse/EclipseState/EndpointScaling.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQParams.hpp>
@@ -106,11 +108,17 @@ public:
return this->nWMax;
}
const std::optional<KeywordLocation>& location() const {
return this->m_location;
}
bool operator==(const Welldims& data) const {
return this->maxConnPerWell() == data.maxConnPerWell() &&
this->maxWellsPerGroup() == data.maxWellsPerGroup() &&
this->maxGroupsInField() == data.maxGroupsInField() &&
this->maxWellsInField() == data.maxWellsInField();
this->maxWellsInField() == data.maxWellsInField() &&
this->location() == data.location();
}
template<class Serializer>
@@ -120,6 +128,7 @@ public:
serializer(nCWMax);
serializer(nWGMax);
serializer(nGMax);
serializer(m_location);
}
private:
@@ -127,6 +136,7 @@ private:
int nCWMax { 0 };
int nWGMax { 0 };
int nGMax { 0 };
std::optional<KeywordLocation> m_location;
};
class WellSegmentDims {
@@ -278,6 +288,8 @@ public:
const EclHysterConfig& hysterPar() const noexcept;
const Actdims& actdims() const noexcept;
const SatFuncControls& saturationFunctionControls() const noexcept;
int nupcol() const noexcept;
bool co2Storage() const noexcept;
bool operator==(const Runspec& data) const;
@@ -293,6 +305,8 @@ public:
hystpar.serializeOp(serializer);
m_actdims.serializeOp(serializer);
m_sfuncctrl.serializeOp(serializer);
serializer(m_nupcol);
serializer(m_co2storage);
}
private:
@@ -305,6 +319,8 @@ private:
EclHysterConfig hystpar;
Actdims m_actdims;
SatFuncControls m_sfuncctrl;
int m_nupcol;
bool m_co2storage;
};

View File

@@ -25,6 +25,7 @@
#include <map>
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WListManager.hpp>
namespace Opm {
namespace Action {
@@ -37,7 +38,7 @@ namespace Action {
class Context {
public:
explicit Context(const SummaryState& summary_state);
explicit Context(const SummaryState& summary_state, const WListManager& wlm);
/*
The get methods will first check the internal storage in the 'values' map
@@ -50,9 +51,11 @@ public:
void add(const std::string& func, double value);
std::vector<std::string> wells(const std::string& func) const;
const WListManager& wlist_manager() const;
private:
const SummaryState& summary_state;
const WListManager& wlm;
std::map<std::string, double> values;
};
}

View File

@@ -101,9 +101,9 @@ public:
void add_well(const std::string& well);
Result& operator|=(const Result& other);
Result& operator=(const Result& src);
Result& operator=(const Result& src);
Result& operator&=(const Result& other);
private:
void assign(bool value);
bool result;

View File

@@ -36,6 +36,7 @@ namespace Opm {
class DeckKeyword;
namespace Action {
class State;
/*
The ActionX class internalizes the ACTIONX keyword. This keyword represents a
@@ -71,13 +72,15 @@ public:
static ActionX serializeObject();
void addKeyword(const DeckKeyword& kw);
bool ready(std::time_t sim_time) const;
Action::Result eval(std::time_t sim_time, const Action::Context& context) const;
bool ready(const State& state, std::time_t sim_time) const;
Action::Result eval(const Action::Context& context) const;
std::string name() const { return this->m_name; }
size_t max_run() const { return this->m_max_run; }
double min_wait() const { return this->m_min_wait; }
std::size_t id() const;
void update_id(std::size_t id);
std::time_t start_time() const { return this->m_start_time; }
std::vector<DeckKeyword>::const_iterator begin() const;
std::vector<DeckKeyword>::const_iterator end() const;
@@ -99,11 +102,10 @@ public:
serializer(m_max_run);
serializer(m_min_wait);
serializer(m_start_time);
serializer(m_id);
serializer.vector(keywords);
condition.serializeOp(serializer);
serializer.vector(m_conditions);
serializer(run_count);
serializer(last_run);
}
private:
@@ -111,12 +113,11 @@ private:
size_t m_max_run = 0;
double m_min_wait = 0.0;
std::time_t m_start_time;
std::size_t m_id = 0;
std::vector<DeckKeyword> keywords;
Action::AST condition;
std::vector<Condition> m_conditions;
mutable size_t run_count = 0;
mutable std::time_t last_run = 0;
};
}

View File

@@ -31,6 +31,8 @@
namespace Opm {
namespace Action {
class State;
/*
The Actions class is a container of ACTIONX keywords. The main functionality
is to provide a list of ACTIONX keywords which are ready to be evaluated.
@@ -48,10 +50,10 @@ public:
bool empty() const;
void add(const ActionX& action);
void add(const PyAction& pyaction);
bool ready(std::time_t sim_time) const;
bool ready(const State& state, std::time_t sim_time) const;
const ActionX& get(const std::string& name) const;
const ActionX& get(std::size_t index) const;
std::vector<const ActionX *> pending(std::time_t sim_time) const;
std::vector<const ActionX *> pending(const State& state, std::time_t sim_time) const;
std::vector<const PyAction *> pending_python() const;
std::vector<ActionX>::const_iterator begin() const;

View File

@@ -23,7 +23,7 @@
#include <string>
#include <vector>
#include <opm/common/OpmLog/Location.hpp>
#include <opm/common/OpmLog/KeywordLocation.hpp>
namespace Opm {
@@ -77,7 +77,7 @@ enum class Comparator {
Condition() = default;
Condition(const std::vector<std::string>& tokens, const Location& location);
Condition(const std::vector<std::string>& tokens, const KeywordLocation& location);
Quantity lhs;

View File

@@ -0,0 +1,59 @@
/*
Copyright 2020 Equinor ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ACTION_STATE_HPP
#define ACTION_STATE_HPP
#include <ctime>
#include <map>
namespace Opm {
namespace Action {
class ActionX;
class State {
struct RunState {
RunState(std::time_t sim_time) :
run_count(1),
last_run(sim_time)
{}
void add_run(std::time_t sim_time) {
this->last_run = sim_time;
this->run_count += 1;
}
std::size_t run_count;
std::time_t last_run;
};
public:
void add_run(const ActionX& action, std::time_t sim_time);
std::size_t run_count(const ActionX& action) const;
std::time_t run_time(const ActionX& action) const;
private:
std::map<std::pair<std::string, std::size_t>, RunState> run_state;
};
}
}
#endif

View File

@@ -21,10 +21,11 @@
#ifndef DYNAMICSTATE_HPP_
#define DYNAMICSTATE_HPP_
#include <stdexcept>
#include <vector>
#include <algorithm>
#include <optional>
#include <stdexcept>
#include <utility>
#include <vector>
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
@@ -155,50 +156,49 @@ class DynamicState {
Schedule object, if e.g. a well is initially closed in the interval
[T1,T2] and then opened at time T1 < Tx < T2 then the open should be
applied for all times in the range [Tx,T2].
The return value is the index of the first element different from value,
or an empty optional if there is no such element.
*/
void update_equal(size_t index, const T& value) {
std::optional<std::size_t> update_equal(size_t index, const T& value) {
if (this->m_data.size() <= index)
throw std::out_of_range("Invalid index for update_equal()");
const T prev_value = this->m_data[index];
if (prev_value == value)
return;
//if (prev_value == value)
// return {};
while (true) {
if (this->m_data[index] != prev_value)
break;
return index;
this->m_data[index] = value;
index++;
if (index == this->m_data.size())
break;
return {};
}
}
/// Will return the index of the first occurence of @value, or
/// -1 if @value is not found.
int find(const T& value) const {
/// Will return the index of the first occurence of @value
std::optional<std::size_t> find(const T& value) const {
auto iter = std::find( m_data.begin() , m_data.end() , value);
if( iter == this->m_data.end() ) return -1;
if( iter == this->m_data.end() ) return {};
return std::distance( m_data.begin() , iter );
}
template<typename P>
int find_if(P&& pred) const {
std::optional<std::size_t> find_if(P&& pred) const {
auto iter = std::find_if(m_data.begin(), m_data.end(), std::forward<P>(pred));
if( iter == this->m_data.end() ) return -1;
if( iter == this->m_data.end() ) return {};
return std::distance( m_data.begin() , iter );
}
/// Will return the index of the first value which is != @value, or -1
/// if all values are == @value
int find_not(const T& value) const {
/// Will return the index of the first value which is != @value
std::optional<std::size_t> find_not(const T& value) const {
auto iter = std::find_if_not( m_data.begin() , m_data.end() , [&value] (const T& elm) { return value == elm; });
if( iter == this->m_data.end() ) return -1;
if( iter == this->m_data.end() ) return {};
return std::distance( m_data.begin() , iter );
}

View File

@@ -35,22 +35,22 @@ namespace Opm
the Schedule object the NEW_WELL event is triggered
every time a WELSPECS keyword is encountered.
*/
NEW_WELL = 1,
NEW_WELL = (1 << 0),
/*
WHen the well data is updated with the WELSPECS keyword
this event is triggered. Only applies to individual
wells, and not the global Schedule object.
*/
WELL_WELSPECS_UPDATE = 2,
WELL_WELSPECS_UPDATE = (1 << 1),
//WELL_POLYMER_UPDATE = 4,
//WELL_POLYMER_UPDATE = (1 << 2),
/*
The NEW_GROUP event is triggered by the WELSPECS and
GRUPTREE keywords.
*/
NEW_GROUP = 8,
NEW_GROUP = (1 << 3),
/*
The PRODUCTION_UPDATE event is triggered by the
@@ -59,48 +59,59 @@ namespace Opm
is changed. Quite simlar for INJECTION_UPDATE and
POLYMER_UPDATE.
*/
PRODUCTION_UPDATE = 16,
INJECTION_UPDATE = 32,
//POLYMER_UPDATES = 64,
PRODUCTION_UPDATE = (1 << 4),
INJECTION_UPDATE = (1 << 5),
//POLYMER_UPDATES = (1 << 6),
/*
This event is triggered if the well status is changed
between {OPEN,SHUT,STOP,AUTO}. There are many keywords
which can trigger a well status change.
*/
WELL_STATUS_CHANGE = 128,
WELL_STATUS_CHANGE = (1 << 7),
/*
COMPDAT and WELOPEN
*/
COMPLETION_CHANGE = 256,
COMPLETION_CHANGE = (1 << 8),
/*
The well group topolyg has changed.
*/
GROUP_CHANGE = 512,
GROUP_CHANGE = (1 << 9),
/*
Geology modifier.
*/
GEO_MODIFIER = 1024,
GEO_MODIFIER = (1 << 10),
/*
TUNING has changed
*/
TUNING_CHANGE = 2048,
TUNING_CHANGE = (1 << 11),
/* The VFP tables have changed */
VFPINJ_UPDATE = 4096,
VFPPROD_UPDATE = 8192,
VFPINJ_UPDATE = (1 << 12),
VFPPROD_UPDATE = (1 << 13),
/*
GROUP production or injection targets has changed
*/
GROUP_PRODUCTION_UPDATE = 16384,
GROUP_INJECTION_UPDATE = 32768
GROUP_PRODUCTION_UPDATE = (1 << 14),
GROUP_INJECTION_UPDATE = (1 << 15),
/*
* New explicit well productivity/injectivity assignment.
*/
WELL_PRODUCTIVITY_INDEX = (1 << 16),
/*
* Well's internal WellConnections structure changed.
* Rerun WELPI scaling if applicable.
*/
WELL_CONNECTIONS_UPDATED = (1 << 17),
};
}

Some files were not shown because too many files have changed in this diff Show More