Compare commits

...

769 Commits

Author SHA1 Message Date
Bård Skaflestad
9a0ccfd853
Merge pull request #3784 from bska/fix-ilbr4-ilbs-take-ii
Revise Branch Discovery Order for MSW Output
2023-11-24 16:49:02 +01:00
Bård Skaflestad
2d3fe6061e Revise Branch Discovery Order for MSW Output
This commit places more conditions on the branch discovery order
than the previous work in commit 6d3ee57dd.  In particular, we now
ensure that branches are discovered ("created") in the order of
increasing segment number of the branch outlet segment.
Furthermore, if multiple branches have the same outlet segment, then
we sort those branches on their increasing branch IDs.

To this end, switch from using a std::queue<int> to using a
std::priority_queue<KickOffPoint>, with the KickOffPoint being a
custom structure holding the kick-off segment, the branch outlet
segment, and the branch ID and a custom operator<() to plug into the
priority_queue<> heap mechanism.

This new sort order changes the result of certain unit tests, but
those changes are expected and desired.
2023-11-24 16:01:46 +01:00
Bård Skaflestad
f45eb1afbf
Merge pull request #3793 from akva2/handlercontext_separate
HandlerContext: put in separate compilation unit
2023-11-24 14:18:03 +01:00
Arne Morten Kvarving
32906b5022 HandlerContext: wpimult_global_factor is never nullptr
use a reference instead of a pointer
2023-11-24 13:22:36 +01:00
Arne Morten Kvarving
e334f28cc3 HandlerContext: make target_wellpi private
add a method getWellPI to obtain value for a given well.
protects the potential null pointer
2023-11-24 13:22:29 +01:00
Arne Morten Kvarving
2b56daca05 HandlerContext: make welsegs_wells and compsegs_wells private
to protect the potential nullptr members
2023-11-24 13:22:29 +01:00
Arne Morten Kvarving
23c3ba7475 HandlerContext: introduce a mark_tran_change method
make the sim_update pointer member private so we can centralize
checks for nullptrs
2023-11-24 13:22:29 +01:00
Arne Morten Kvarving
a7f709f9f3 changed: put HandlerContext in separate compile unit 2023-11-24 13:22:29 +01:00
Arne Morten Kvarving
01c1fda1c9 introduce a helper class WelSegsSet
this wraps the set with the custom comparator. this is
just a internal helper class, does not need to be part of public API.
2023-11-24 13:22:29 +01:00
Bård Skaflestad
e8fc282b74
Merge pull request #3794 from akva2/libfmt_fetchcontent_super_build
fixed: downloaded libfmt with a super build
2023-11-24 13:13:50 +01:00
Arne Morten Kvarving
54d895af29 fixed: downloaded libfmt with a super build
have to check that it has not been populated before.
we have to push two variables up to the parent scope
2023-11-24 11:12:04 +01:00
Bård Skaflestad
5a2d3b1f11
Merge pull request #3792 from totto82/mpi_wpimult
serialize wpimult
2023-11-24 11:07:09 +01:00
Tor Harald Sandve
f8ca5ca684 serialize wpimult 2023-11-24 10:09:49 +01:00
Bård Skaflestad
659f4d9a9f
Merge pull request #3788 from totto82/wpimult_wdfac
adapt wdfac for wpimult
2023-11-23 16:27:57 +01:00
Arne Morten Kvarving
e5ee7d931d
Merge pull request #3790 from akva2/janitoring
Schedule::handleKeyword: remove unused list
2023-11-23 16:20:32 +01:00
Arne Morten Kvarving
0469f53056 Schedule::handleKeyword: remove unused list 2023-11-23 15:27:17 +01:00
Tor Harald Sandve
c40efc35f2 adapt wdfac for wpimult 2023-11-23 15:18:45 +01:00
Bård Skaflestad
75a735c6b1
Merge pull request #3786 from akva2/refine_fmt_fetchcontent
fixed: refine the libfmt fetchcontent approach
2023-11-22 16:50:54 +01:00
Arne Morten Kvarving
2497c62f25 fixed: refine the libfmt fetchcontent approach
rather than doing a full MakeAvailable, only download,
prepare then use from source directory
2023-11-22 15:19:49 +01:00
Bård Skaflestad
be048ca063
Merge pull request #3781 from totto82/wdfac_fix
Add return of wdfac type
2023-11-22 14:53:14 +01:00
Tor Harald Sandve
08b41f09d8 Remove trans multiplier from the dake model 2023-11-22 13:59:25 +01:00
Bård Skaflestad
5937ee9a08
Merge pull request #3785 from akva2/vendor_cjson_fetchcontent
changed: vendor cjson using FetchContent
2023-11-22 13:32:54 +01:00
Bård Skaflestad
0419aefd60
Merge pull request #3782 from totto82/cgfrs
Output CGFRF and CGFRS
2023-11-22 12:52:00 +01:00
Arne Morten Kvarving
d9ca8694ae changed: vendor cjson using FetchContent 2023-11-22 10:46:13 +01:00
Tor Harald Sandve
9c680a0dcf Output C[OG]FRF and C[OG]FRS 2023-11-22 10:17:44 +01:00
Tor Harald Sandve
e362e1018d refactoring wdfac getDfactor 2023-11-22 09:17:59 +01:00
Arne Morten Kvarving
5a9d1f84b7
Merge pull request #3783 from akva2/vendor_fmt_fetchcontent
changed: vendor libfmt using FetchContent
2023-11-22 09:06:12 +01:00
Arne Morten Kvarving
76d769960e changed: vendor libfmt using FetchContent 2023-11-22 08:21:05 +01:00
Tor Harald Sandve
98220372eb Add return of wdfac type 2023-11-21 17:49:08 +01:00
Arne Morten Kvarving
fcb438aed4
Merge pull request #3780 from akva2/fix_comma
fixed: erroneous comma placement
2023-11-20 15:55:53 +01:00
Arne Morten Kvarving
d283967f27 fixed: erroneous comma placement 2023-11-20 15:19:11 +01:00
Bård Skaflestad
7502808265
Merge pull request #3778 from akva2/fix_boost_version_check
fixed: adjust boost version check
2023-11-17 14:16:52 +01:00
Bård Skaflestad
a74b146841
Merge pull request #3777 from akva2/fix_perf_range_deref
fixed: pass through perf-range as an optional
2023-11-17 14:02:58 +01:00
Bård Skaflestad
1b435f3af7
Merge pull request #3776 from akva2/esmry_fix_oob
ESmry: fix out-of-bounds vector access
2023-11-17 13:33:38 +01:00
Arne Morten Kvarving
fc5a2fbea6 fixed: adjust boost version check
1.66 already has the boost::fpc scope
2023-11-17 13:01:57 +01:00
Arne Morten Kvarving
a725a5a85c fixed: pass throug perf-range as an optional
we should not dereference it for STDW where it is expected
to be empty
2023-11-17 12:58:37 +01:00
Arne Morten Kvarving
1427275abd avoid copying strings 2023-11-17 12:37:52 +01:00
Arne Morten Kvarving
63a04d14e5 fixed: make sure vector has expected size
this comes from input that can be shorter (e.g. in the test
it only holds day-month-year).
2023-11-17 12:37:05 +01:00
Bård Skaflestad
c9cecb9036
Merge pull request #3773 from totto82/fixWDFAC
Fix for connection D factors
2023-11-17 09:05:36 +01:00
Atgeirr Flø Rasmussen
e0e308ea43
Merge pull request #3737 from daavid00/dispersivity
Support for mechanical dispersion
2023-11-17 08:49:48 +01:00
Atgeirr Flø Rasmussen
5184bdc64e
Merge pull request #3726 from bska/csrgraph-permit-self-connection
Make Self Connection Behaviour Configurable
2023-11-17 08:28:27 +01:00
David Landa Marban
0d993ebd6a Support for mechanical dispersion 2023-11-16 16:54:56 +01:00
Bård Skaflestad
8a4735efcb Make Self Connection Behaviour Configurable
This commit adds a new class template argument,

    bool PermitSelfConnections

with a default value of 'false', that enables client code to
configure whether or not function

    addConnection(v1, v2)

creates a connection from v1 to v2 if v1 == v2.  The default state
preserves the current behaviour which ignores such connections.

Permitting self connections makes the class slightly more general to
uses cases outside inter-region flow accumulation.
2023-11-16 15:10:59 +01:00
Arne Morten Kvarving
003560e00d
Merge pull request #3774 from akva2/pypi_3.11_3.12
pypi: build for python 3.11 and 3.12
2023-11-16 14:11:12 +01:00
Arne Morten Kvarving
65e77738a9 pypi: build for python 3.11 and 3.12 2023-11-16 12:40:53 +01:00
Arne Morten Kvarving
0d69176609
Merge pull request #3671 from akva2/vendor_pybind11_fetchcontent
changed: vendor pybind11 using FetchContent
2023-11-16 11:54:59 +01:00
Tor Harald Sandve
780a0cffbc Support connection D factor
If positive the D factor is threated a well D factor
If negative it is threated as a connction D factor (no scaling)
2023-11-16 11:23:38 +01:00
Arne Morten Kvarving
e2566b1487 changed: vendor pybind11 using FetchContent 2023-11-16 09:49:34 +01:00
Bård Skaflestad
3ff7fffb04
Merge pull request #3738 from vkip/network_restart_use_node_pressures
Facilitate using network node pressures from restart
2023-11-15 09:34:54 +01:00
Vegard Kippe
1d8c5640a2 Resolve test failures 2023-11-14 18:05:40 +01:00
Vegard Kippe
87bdf6381c Apply unit conversion 2023-11-14 15:15:00 +01:00
Vegard Kippe
3d8b7e863e Avoid unused paramter 2023-11-14 13:34:39 +01:00
Markus Blatt
d3b80422e6
Merge pull request #3757 from blattms/man-pages-release
Update and improve man pages for release
2023-11-14 10:06:51 +01:00
Vegard Kippe
a47aee1af5 Resolved test failures (with and without network defined). 2023-11-13 23:26:58 +01:00
Vegard Kippe
9956ef1dfc Facilitate using network node pressures from restart 2023-11-13 23:26:57 +01:00
Tor Harald Sandve
5309471632
Merge pull request #3750 from daavid00/renamingToEnableVapwat
Renaming enableEvaporation to enableVapwat
2023-11-13 15:01:19 +01:00
Kai Bao
d94edc0723
Merge pull request #3702 from vkip/network_multi_root
Support networks with multiple fixed-pressure nodes
2023-11-13 14:38:35 +01:00
Vegard Kippe
d5f4ff90c3 Updating warning comment 2023-11-13 12:24:01 +01:00
Vegard Kippe
aaf61d429d Updating NetworkTests from root() to roots() 2023-11-13 12:24:01 +01:00
Vegard Kippe
7e80ad86aa Rebase fix 2023-11-13 12:24:01 +01:00
Vegard Kippe
3e075ec92d Ensure flow from fixed-pressure node in standard network is propagated up. 2023-11-13 12:24:01 +01:00
Vegard Kippe
97b5bc6209 Support networks with multiple fixed-pressure nodes 2023-11-13 12:24:00 +01:00
Atgeirr Flø Rasmussen
f77a337084
Merge pull request #3698 from vkip/parsecontext_handles_nowellmatch
Let ParseContext handle what happens if no well match is found
2023-11-13 10:57:22 +01:00
Arne Morten Kvarving
cde9209cf3
Merge pull request #3762 from kjetilly/fail_on_missing_damaris
Fail if Damaris is requested and not found
2023-11-10 12:22:13 +01:00
Kjetil Olsen Lye
df80891256
Fail if Damaris is requested and not found
In the current setup, `USE_DAMARIS_LIB` is set to `OFF` by default, but setting it to `ON` does not issue an error if Damaris is not found. This issues an error if `USE_DAMARIS_LIB==ON` and Damaris is not found.
2023-11-10 11:59:08 +01:00
Vegard Kippe
0b2403d59c Let parseContext handle non-matching wells in WLIST (so that --parsing-strictness=low can allow this) 2023-11-10 11:44:59 +01:00
Bård Skaflestad
b640b53d36
Merge pull request #3760 from akva2/fix_build_old_boost
Fix build with older versions of boost
2023-11-10 11:08:55 +01:00
Arne Morten Kvarving
fa670d7042 fixed: earlier boosts did not support command line parameter separation
for older versions we will thus see '--' as argv[1] and the actual
parameter as argv[2].
2023-11-10 10:23:30 +01:00
Arne Morten Kvarving
2fec8a3c16 fixed: adjust compare_at_tolerance namespace for earlier boost 2023-11-10 10:23:30 +01:00
Arne Morten Kvarving
f8781f276e fixed: adjust include path of float_point_comparison for earlier boost 2023-11-10 10:23:30 +01:00
Arne Morten Kvarving
e2c20a6712 fixed: BOOST_DATA_TEST_CASE was added in boost 1.67
use a loop for earlier versions
2023-11-10 10:23:30 +01:00
Arne Morten Kvarving
f1fc44563a fixed: earlier boosts only accepts boost::mpl::list for BOOST_AUTO_TEST_TEMPLATE 2023-11-10 10:23:30 +01:00
Bård Skaflestad
5bc38dab24
Merge pull request #3758 from blattms/fix-segfault-arraylist-without-file
Fix segmentation fault if file name is missing after arraylist command.
2023-11-10 09:51:56 +01:00
Bård Skaflestad
7baccd0318
Merge pull request #3701 from vkip/extra_network_output
Allow output of network pressure based on rates at end of timestep
2023-11-09 23:04:34 +01:00
Markus Blatt
c908561d7f Update and improve man pages for release 2023-11-09 16:31:25 +01:00
Markus Blatt
796a6416ca Fix segmentation fault if file name is missing after arraylist command. 2023-11-09 15:54:11 +01:00
Bård Skaflestad
8b2be3d797
Merge pull request #3756 from akva2/fipconfig_rptsol
EclipseConfig: add FIPConfig for RPTSOL
2023-11-09 14:38:41 +01:00
Arne Morten Kvarving
5e39ab31da added: FIPConfig for RPTSOL in EclipseConfig 2023-11-09 12:11:49 +01:00
Bård Skaflestad
7ba929f1d0
Merge pull request #3753 from akva2/fipconfig
added: FIPConfig class
2023-11-09 12:10:40 +01:00
Arne Morten Kvarving
47122446e6 use strong enum for FIP output fields 2023-11-09 10:44:23 +01:00
Arne Morten Kvarving
3f08071eae added: FIPConfig class
this parses FIP related flags from RPT(SCHED|SOL)
2023-11-09 10:35:21 +01:00
Kai Bao
16c6ee3bbb
Merge pull request #3695 from vkip/grupnet_reroute_hack
Allow rerouting in standard and extended network
2023-11-08 19:58:07 +01:00
Vegard Kippe
d2a34573e3 Better way of getting max number of groups 2023-11-08 17:59:37 +01:00
Bård Skaflestad
552fe8950f
Merge pull request #3755 from bska/usys-const-mem-fn
Make UnitSystem::*_si(string) Const Members
2023-11-08 17:24:25 +01:00
Bård Skaflestad
d9a1d7fe62 Make UnitSystem::*_si(string) Const Members
There is no need for these to require that the UnitSystem be mutable.
2023-11-08 16:10:36 +01:00
Bård Skaflestad
af4b985eb2
Merge pull request #3730 from totto82/addSurfaceDensityOutput
Add info about surface density from CO2STORE model
2023-11-08 14:59:56 +01:00
Vegard Kippe
96b0b09b14 Addressing final comments and test failures. 2023-11-08 11:58:01 +01:00
Vegard Kippe
f8a38064e1 Re-introducing throws on undefined nodes 2023-11-07 23:50:25 +01:00
David Landa Marban
ab2b3faf0a Renaming enableEvaporation to enableVapwat 2023-11-07 18:34:44 +01:00
Bård Skaflestad
980ac2599a
Merge pull request #3747 from akva2/fbhpdef
implement support for FBHPDEF
2023-11-07 14:54:11 +01:00
Vegard Kippe
3519a3a9ab Re-introduced logic_error if node is not defined 2023-11-07 12:09:55 +01:00
Vegard Kippe
0ae1588e00 Addressing review comments, in particular, ensuring that extended network is not updated with a GRUPTREE update. 2023-11-07 11:28:36 +01:00
Vegard Kippe
4192c19d3c Restart fix 2023-11-07 11:28:35 +01:00
Vegard Kippe
01890670da Bugfix + first steps on restart 2023-11-07 11:28:35 +01:00
Vegard Kippe
aa2220979b Working version (but not pretty) 2023-11-07 11:28:35 +01:00
Vegard Kippe
0aa0af9f57 Allow rerouting in standard network 2023-11-07 11:28:35 +01:00
Arne Morten Kvarving
3875736795 implement support for FBHPDEF 2023-11-07 10:32:38 +01:00
Arne Morten Kvarving
33c529652b
Merge pull request #3748 from akva2/schedulestate_avoid_duplicate
ScheduleState: avoid duplicate const/mutable implementation
2023-11-03 14:38:19 +01:00
Bård Skaflestad
5b6b82aa2c
Merge pull request #3743 from bska/dfac-corr-unit
Fix Dimension of D-Factor Correlation 'A' Coefficient
2023-11-03 13:46:15 +01:00
Arne Morten Kvarving
e82875644a ScheduleState: avoid duplicate const/mutable implementation 2023-11-03 13:13:58 +01:00
Bård Skaflestad
5114c6ff9f Fix Dimension of D-Factor Correlation 'A' Coefficient
We were missing the 'Area' component.
2023-11-03 10:36:01 +01:00
Arne Morten Kvarving
3470f41564
Merge pull request #3746 from bska/remove-unused-sparse-schedule-grid
Remove SparseScheduleGrid Component
2023-11-03 07:01:38 +01:00
Bård Skaflestad
a589cf4795
Merge pull request #3741 from blattms/more-support-for-actionx-wlist
Support WLIST for all allowed well keywords in ACTIONX.
2023-11-03 00:13:37 +01:00
Bård Skaflestad
d253d357dd Remove SparseScheduleGrid Component
Introduced in commit 4134b9870, this was never used anywhere and
never connected to the build system.
2023-11-02 22:40:51 +01:00
Arne Morten Kvarving
b27c199cb9
Merge pull request #3742 from daavid00/clang
Fix to linker error in building tests (clang, macOS)
2023-11-01 10:32:18 +01:00
David Landa Marban
9588947ee3 Fix to linker error in building tests (clang, macOS) 2023-11-01 10:04:23 +01:00
Markus Blatt
0f1abcbe7c Support WLIST for all allowed well keywords in ACTIONX.
When first evaluating ACTIONX the WLISTS might not even exist.
In addition they may be empty.

We support WLIST for the following well keywords in ACTIONX:

COMPDAT, COMPLUMP, WCONINJE, WCONPROD, WECON, WEFAC, WELOPEN, WELPI,
WELSPECS, WELTARG, WGRUPCON, WPIMULT, WSEGVALV, WTEST,
WTMULT,  WELSPECS

These keywords that probably allow WLIST, still insist they are never empty:
WELTRAJ, COMPTRAJ, CSKIN, WCONHIST, WCONINJH, WFOAM, WINJMULT,
WINJTEMP, WLIFTOPT, WMICP, WINJCLN, WINJDAM, WINJFCNC, WPMITAB,
WPOLYMER, WSALT, WSEGSICD, WSEGAICD, WSKPTAB, WSOLVENT, WTEMP,
WTRACER, WVFPDP, WVFPEXP, WWPAVE, WPAVEDEP, WRFT, WRFTPLT

These are currently not allowed in ACTIONX.
2023-10-31 20:03:59 +01:00
Bård Skaflestad
e2c8d5536c
Merge pull request #3661 from totto82/addWDFAC
Implement support for keyword WDFAC and WDFACCOR
2023-10-31 17:31:23 +01:00
Tor Harald Sandve
80dd2c33a1 Implement support for keyword WDFAC and WDFACCOR
Implement support for DFactor in COMPDAT

Add output of CDFAC
2023-10-31 14:10:45 +01:00
Tor Harald Sandve
111b74e938
Merge pull request #3739 from svenn-t/fix_wellcon_sattab
Fix well connection rel. perm. parameters for two-phase cases
2023-10-31 13:48:16 +01:00
Svenn Tveit
1eeae5efe4 Set correct parameters in two-phase case 2023-10-31 10:45:08 +01:00
Markus Blatt
a5fb8be683
Merge pull request #3728 from akva2/udt_in_udq
Add support for UDT lookups in UDQs
2023-10-30 13:06:48 +01:00
Arne Morten Kvarving
878f5fa72d SummaryNode: flag TU's as user defined nodes 2023-10-30 11:18:58 +01:00
Arne Morten Kvarving
db0f99de77 UDQ: add UDT support 2023-10-30 11:18:58 +01:00
Vegard Kippe
def88224ac Avoid exception for non-group nodes + fix step 2023-10-26 19:31:48 +02:00
Vegard Kippe
7aabc14523 Output of network pressure based on rates at end of timestep in summary vector NPR:* = GNETPR:* 2023-10-26 19:31:48 +02:00
Markus Blatt
aaa8af923c
Merge pull request #3733 from aritorto/missingHeader
Missing header for g++ 12.2.0
2023-10-26 11:41:10 +02:00
Antonella Ritorto
e89c486c7c Missing header for g++ 12.2.0 2023-10-26 10:17:09 +02:00
Bård Skaflestad
96b3799eee
Merge pull request #3712 from blattms/actionx-condition-errors
Better error handling for problems in conditions of ACTIONX.
2023-10-25 16:22:34 +02:00
Bård Skaflestad
a2d4680fc2
Merge pull request #3731 from bska/rescale-swatinit-pcow-at-restart
Support SWATINIT-Like Rescaling of PCOW at Restart
2023-10-25 15:40:04 +02:00
Markus Blatt
fb8a5b7459 Fixed shadowing variable warning. 2023-10-25 15:30:44 +02:00
Markus Blatt
0c25b18988
Merge pull request #3727 from akva2/add_udt_parsing
Add parsing for UDT
2023-10-25 14:12:46 +02:00
Markus Blatt
257dd12dec Improved the "improved" error message even more. 2023-10-25 14:07:43 +02:00
Markus Blatt
48bbc2dc2b Introduces method parseActionX returning the action and error strings.
This way there is no constructor with an output parameter and we
prevent introducing an additional member in ActionX that is only used
in one constructor.
2023-10-25 14:04:10 +02:00
Markus Blatt
f3668e0a37 Better error handling for problems in conditions of ACTIONX.
When encountering these (e.g. a number instead of an expression on
the left hand side) the simulator would immediately abort with an
error message like:
```
Error: An error occurred while creating the reservoir schedule
Internal error: Extra unhandled data starting with token[0] = 135

Error: Unrecoverable errors while loading input: Extra unhandled data starting with token[0] = 135
```
(The message above is for the number 135 on the left hand side)

With this change we now use the usual way of handling errors and
warnings in the parser and continue parsing.

The error message for the problem above is now
```
Error: condition of action EX1 has the following error: Left side of comparsion (135) has to be an expression!

Error: Problem with keyword ACTIONX
In model.schedule line 562
condition of action EX1 has the following error: Left side of comparsion (135) has to be an expression!

Error: Unrecoverable errors while loading input: Problem with keyword ACTIONX
In model.schedule line 562
condition of action EX1 has the following error: Left side of comparsion (135) has to be an expression!
2023-10-25 14:04:10 +02:00
Bård Skaflestad
b7fed05ca2 Support SWATINIT-Like Rescaling of PCOW at Restart
This commit adds a new, very specialised, operation to the material
law manager,

  void EclMaterialLawManager::applyRestartSwatInit(cell, maxPcow)

This will apply a SWATINIT-like rescaling of the oil/water capillary
pressure curve based on a caller-provided maximum capillary pressure
value.  The primary use case is this maximum value being taken from
the PPCW array in a restart file at simulation restart time.  We
assign the "maxPcow" member of the associate EpsInfo structure and
reinitialise the EpsPoints structure using this new information.
The latter is needed lest the maxPcnw() member function return
incorrect values in restarted simulations.
2023-10-25 10:54:59 +02:00
Arne Morten Kvarving
2a2c59ca26 added: parsing of UDT keyword 2023-10-25 10:02:44 +02:00
Markus Blatt
a606753230
Merge pull request #3703 from bska/welspecs-extension
Support Changing Selected Well Properties Through WELSPECS
2023-10-25 09:51:51 +02:00
Markus Blatt
ef9e171705
Merge pull request #3725 from akva2/add_udt
Prepare for UDT support
2023-10-25 09:50:19 +02:00
Bård Skaflestad
416dadd33f Support Changing Selected Well Properties Through WELSPECS
This commit enables updating individual well properties for one or
more wells using the WELSPECS keyword.  In particular, this revised
logic enables changing the controlling group without affecting any
other well property such as the location of the well head or the
well reference depth.

Defaulted properties do not affect change in Well::update*().  This,
in turn, begets a change to the logic of how we update the reference
depths.  Previously, we always interpreted a defaulted reference
depth item as

    Compute the reference depth from the location of the well's
    reservoir connections

We now alter this interpretation slightly to mean

    Don't recompute the reference depth if the input has already
    assigned a numerical value for this property

If the input has never assigned an explicit numerical value for the
reference depth, then we continue using the original interpretation
of a defaulted reference depth item--e.g., to update the reference
depth as a result of new reservoir connections.

The simulation can request the original interpretation even after
having assigned a numeric reference depth, by entering a new
WELSPECS keyword specifying a negative value for the the reference
depth item.

To this end, introduce a new data member in the Well class,

    bool Well::derive_refdepth_from_conns_

which tracks whether or not the reference depth has been assigned an
explicit numeric value.

As an example, this new WELSPECS behaviour enables using something
like

    ACTIONX
      A  1 /
      WOPR 'P*' < 123.4 /
    /
    WELSPECS
      '?' 'LOWPRESS' /
    /
    ENDACTIO

as a way to move all wells matching the pattern 'P*', and with a low
oil production rate, to the group 'LOWPRESS'.  This could, in turn,
apply a different set of group-level production controls to those
wells.
2023-10-25 09:19:00 +02:00
Bård Skaflestad
da442c5d45 Separate New vs Update WELSPECS Handling out to Helpers
This commit creates new helper functions

    Schedule::welspecsCreateNewWell()
    Schedule::welspecsUpdateExistingWells()

which handle the creation of a new well or the property update of
one or more existing wells, respectively, in the context of
processing records in the WELSPECS keyword.

In preparation of making the WELSPECS keyword useful for changing
the controlling group of a collection of wells, we pass a vector of
well names as an argument to the update function.  Furthermore, we
construct this vector using normal 'wellNames()' processing which
enables using patterns and well list names such as

  * 'P-2'
  * 'PROD-*'
  * '?'
  * '*PROD'

as arguments/well names (item 1).
2023-10-25 09:19:00 +02:00
Arne Morten Kvarving
32271046af
Merge pull request #3710 from blattms/enforce-64bit
Make CMake fail on non-64bit systems.
2023-10-25 08:59:38 +02:00
Markus Blatt
ce7e010010 Use LESS comparison to test if system is at least 64bit.
Indeed this is clearer and better.
2023-10-25 08:17:20 +02:00
Tor Harald Sandve
f415c298c7 Add info about surface density from CO2STORE model 2023-10-24 15:25:09 +02:00
Kai Bao
937336526a
Merge pull request #3729 from GitPaean/adding_output
outputting the maxIterations in the PTFlash failure message
2023-10-24 11:04:01 +02:00
Kai Bao
5c44ebb906 outputting the maxIterations in the PTFlash failure message
adding removing some white spaces in PTFlash.hpp
2023-10-24 10:03:48 +02:00
Arne Morten Kvarving
80b8a7e90a added: put UDTs in UDQContext 2023-10-23 20:29:40 +02:00
Arne Morten Kvarving
9129d91568 added: storage of UDTs in UDQConfig 2023-10-23 20:29:40 +02:00
Arne Morten Kvarving
d1b6c8de12 add class for representing UDTs
this is limited to 1D UDTs for now
2023-10-23 20:29:40 +02:00
Bård Skaflestad
5684387496
Merge pull request #3723 from totto82/addResidualOutput
Add RESIDUAL output to RPTRST
2023-10-23 15:48:09 +02:00
Arne Morten Kvarving
f192961831
Merge pull request #3724 from akva2/lininterp_reformat_use_stl
linearInterpolation.hpp: reformat and use stl
2023-10-23 15:23:58 +02:00
Arne Morten Kvarving
9dbee7920a linearInterpolation: add a helper to get slope and index
and reimplement interpolation functions in terms of this helper
2023-10-23 14:41:35 +02:00
Arne Morten Kvarving
29031c6645 linearInterpolation: reimplement tableIndex using stl 2023-10-23 14:31:36 +02:00
Arne Morten Kvarving
568c06192f linearInterpolation.hpp: reformat 2023-10-23 14:31:36 +02:00
Arne Morten Kvarving
09fc8e2af8
Merge pull request #3722 from akva2/janitoring
changed: sort UDQ headers/sources in alphabetical order
2023-10-23 14:31:12 +02:00
Arne Morten Kvarving
782aa4b17c changed: sort UDQ headers/sources in alphabetical order 2023-10-23 13:17:27 +02:00
Tor Harald Sandve
dd8e7192dd Add RESIDUAL output to RPTRST 2023-10-23 13:16:55 +02:00
Bård Skaflestad
c671d6017f
Merge pull request #3707 from GitPaean/fixing_gecon_welopen
introducing a new event type REQUEST_OPEN_WELL
2023-10-23 08:45:58 +02:00
Kai Bao
b7ab015e9b introducing a new event type REQUEST_OPEN_WELL
Some SCHEDULE keywords can set a well to be OPEN to open a reviouly STOP or SHUT well.
The well is SHUT/STOP due to various causes (SCHEDULE, economical, physical, etc.)
For now, the WELOPEN, WCONPROD and WCONINJE keywords are considered with this event.
In the future, other keywords can be involved if found to have the
similar OPENing functionality.
2023-10-20 13:07:41 +02:00
Atgeirr Flø Rasmussen
b3177a95da
Merge pull request #3660 from bska/extract-csr-graph-helpers
Extract Facility to Form CSR Representations of Graphs
2023-10-18 15:42:27 +02:00
Bård Skaflestad
cc4928dfc7 Extract Facility to Form CSR Representations of Graphs
This commit extracts the internal helpers of class

    InterRegFlowMap

out to a new public helper class template, CSRGraphFromCoordinates.
Client code can, at the expense of one additional data member and
some dynamic memory, elect to track the index pairs.  This enables
O(1) assembly per element when used as part of a CSR matrix with a
value array, SA.

Class CSRGraphFromCoordinates does not track values.  It is purely
for the sake of forming the IA and JA structure arrays.  Upon
calling 'compress()', column indices are sorted per row and
duplicate column indices condensed to a single, unique,
representative.
2023-10-18 13:50:31 +02:00
Bård Skaflestad
2d33b520f1
Merge pull request #3684 from vkip/wsegvalv_uda_item4
Facilitate UDA for WSEGVALV item 4
2023-10-17 15:14:22 +02:00
Bård Skaflestad
0567d9b09b
Merge pull request #3713 from blattms/prevent-segfault-for-actiony-without-condition
[fix] AggregateActionX: Do not assume an ACTIONX condition exists
2023-10-16 17:26:39 +02:00
Markus Blatt
a53d8559a6 [fix] AggregateActionX: Do not assume an ACTIONX condition exists
The rest of the code allows an ACTIONX keyword without any
condition (Such an action will never be evaluated). Yet
AggregateActionXData assumed that there is always at least one
condition. This lead to a segmentation fault if that was not the case.

It seemed like iAC[offset + Ix::FirstGreater] is used nowhere and
therefore we now always use 0 there. I was not brave enouogh to remove
the storage for it, because I fear this might break backwards
compatibility of the output layer.
2023-10-16 15:39:58 +02:00
Kai Bao
9da481e609
Merge pull request #3714 from GitPaean/adding_headerfile_cmake_files
adding ThreeComponentFluidSystem.hh to CMakeLists_files
2023-10-16 12:15:18 +02:00
Kai Bao
1d8d503b69 adding ThreeComponentFluidSystem.hh to CMakeLists_files
to let other modules be able to access it.
2023-10-16 10:39:01 +02:00
Vegard Kippe
078a987124 Post review update 2023-10-16 10:04:20 +02:00
Bård Skaflestad
8f5ec261ec
Merge pull request #3704 from GitPaean/ptflash_simpletest
various correction to prepare for the PTFlash simulation
2023-10-13 17:56:03 +02:00
Bård Skaflestad
49be8698cc
Merge pull request #3705 from daavid00/sgwfnTable
Support for SGWFN sat functions (format type 2)
2023-10-13 10:30:41 +02:00
Markus Blatt
d1cb233b04
Merge pull request #3709 from blattms/bump-version
Bump version to 2024.04
2023-10-13 09:19:18 +02:00
Kai Bao
f807281c15 cleaning up and small corrections related to PTFlash 2023-10-12 15:25:32 +02:00
Kai Bao
c3e061cab1 default max iteration number of SSI to be 100
10 was too small.
2023-10-12 14:04:11 +02:00
Trine Mykkeltvedt
cdae1534de various corrections related to component proerties
and viscosity model.
2023-10-12 14:04:11 +02:00
Markus Blatt
4d7b0bb773
Merge pull request #3708 from bska/dont-reference-non-existent-wgnames
Don't Reference Non-Existent W/G Names From UDQ Set
2023-10-12 12:26:06 +02:00
Bård Skaflestad
39b9689339 Don't Reference Non-Existent W/G Names From UDQ Set
Member function SummaryState::update_udq() did not take into account
the possibility that wells or groups might not yet have come online.
In particular, UDQSet::operator[](const string&) will throw an
exception if the argument string does not name an existing member of
the UDQ set.

This commit makes the call to operator[]() conditional on the named
entity existing and thereby enables updating well and group level
UDQs before these names have been entered in, e.g., WELSPECS or
GRUPTREE.  Missing entities get the 'undefined_value'.
2023-10-12 11:33:00 +02:00
Markus Blatt
b3f4816f07
Merge pull request #3699 from akva2/wlist_in_actionx
Add support for WLIST in ACTIONX
2023-10-12 11:15:23 +02:00
David Landa Marban
5f22fb9bd0 Support for SGWFN sat functions (format type 2) 2023-10-11 23:38:42 +02:00
Markus Blatt
8ec7378dd4 Make CMake fail on non-64bit systems.
Running simulations on those does not make sense as it seriously
limits the time span that can be simulated. In addition the OPM code
neglects 32bit issues at various places as it was written at a time
where 64bit was already ubiquitous.

Currently, we would fail in some regression tests on 32bit
systems. With this change CMake will already check whether it is run
on a 64bit system and already fail if this is not the case.
2023-10-11 21:53:54 +02:00
Markus Blatt
c80ddf4b6f Bump version to 2024.04 2023-10-11 21:20:51 +02:00
Markus Blatt
a4f9fb1dd8
Merge pull request #3706 from blattms/fix-missing-functional-gcc12
Include missing functional header to fix compilation with g++-12
2023-10-11 12:40:09 +02:00
Markus Blatt
f3bd34df71 Sort header includes as requested.
Sorting criteria is not 100% clear to me though. I hope this does not
break anything...
2023-10-11 11:41:40 +02:00
Markus Blatt
a309dbb4d0 Include missing functional header for g++-12
Fixes
```
/opm/input/eclipse/Schedule/Schedule.hpp:241:14: error: ‘function’ in namespace ‘std’ does not name a template type
  241 |         std::function<std::unique_ptr<SegmentMatcher>()> segmentMatcherFactory(std::size_t report_step) const;
      |              ^~~~~~~~
```
2023-10-10 21:12:15 +02:00
Markus Blatt
9e3fa794ce
Merge pull request #3587 from bska/trigger-assign-from-actionx
Track Pending Assignments in UDQ Configuration Object
2023-10-10 12:41:33 +02:00
Bård Skaflestad
09ffacb5bf Track Pending Assignments in UDQ Configuration Object
The existing implementation used the UDQ State object to track
pending ASSIGN operations, mainly in terms of the report step index,
but this implies that the logic implicitly assumes an ASSIGN
operation can run at most once per report step.  That assumption
usually holds, but fails if the ASSIGN operation is triggered from
an ACTIONX block that happens to run multiple times within a report
step.

This commit instead introduces a new data member,

    UDQConfig::pending_assignments_

that keeps track of all ASSIGN operations that have been added for
the current report step.  We clear those pending assignments when
forming a new Schedule block (ScheduleState object), under the
assumption that all pending ASSIGN operations have been affected at
the previous time level (report step).

In effect, this new data member assumes the role of

    UDQState::assignments

and we therefore remove that data member and update the signature of

    UDQState::add_assign()

to account for the fact that the 'report_step' parameter is no
longer needed.
2023-10-09 15:32:48 +02:00
Arne Morten Kvarving
54bdca66e1 added: enable WLIST in ACTIONX 2023-10-09 08:50:46 +02:00
Arne Morten Kvarving
a18b799468 changed: pass matching_wells in handleWLIST 2023-10-09 08:50:46 +02:00
Arne Morten Kvarving
396bc10db4 changed: Schedule::handleWELOPEN
allow operation on empty well lists. in particular
this will be necessary supporting WLIST modifications
by ACTIONX
2023-10-09 08:50:46 +02:00
Arne Morten Kvarving
a7a84f6f2f added: allowEmpty parameter to Schedule::wellNames
allows bypassing exception if there are no matches.
2023-10-09 08:50:46 +02:00
Arne Morten Kvarving
3f40960469 added: utility function Schedule::isWList
checks if the given pattern is the name of a WList
2023-10-09 08:50:46 +02:00
Tor Harald Sandve
8ed1b4c21e
Merge pull request #3656 from svenn-t/co2store_enthalpy_reference
CO2STORE new reference state for enthalpy
2023-10-06 17:52:25 +02:00
Markus Blatt
4c511b788c
Merge pull request #3375 from bska/eval-seg-udq
Compute Segment Level UDQ Values
2023-10-06 15:35:23 +02:00
Bård Skaflestad
2be2063906
Merge pull request #3700 from blattms/prominent-toplevel-topology-errors
Make top level section errors more prominent / Allow global keywords before RUNSPEC
2023-10-06 11:18:07 +02:00
Markus Blatt
4daaf493cb Fix documentation of isGlobalKeyword. 2023-10-06 10:55:03 +02:00
Markus Blatt
3a63c1723b Allow global keywords before RUNSPEC in input file. 2023-10-05 22:33:08 +02:00
Bård Skaflestad
7d16924f06 Defer Bounds Checking to Schedule::operator[]()
We don't need to reimplement logic that's already present and it is
always an error to pass a 'report_step' argument that exceeds
Schedule::size().

Pointed out by: [at]blattms.
2023-10-05 18:25:49 +02:00
Bård Skaflestad
0f1f2f74f0 Highlight Deferred Initialisation in EvalAssign::operator()
The logic and the reasoning behind it was too obtuse.
2023-10-05 18:23:38 +02:00
Bård Skaflestad
c93243f939 Rename Segment Matcher Factory Data Member
Invoking the factory creates a segment matcher object, not a new
factory.

Suggested by: [at]blattms
2023-10-05 18:22:07 +02:00
Markus Blatt
4caa693d71 Make top level section error more prominent to help users.
If there are errors at the top level (e.g. RUNSPEC comes after
NOECHO), we might get very many errors and the user might miss
the relevant ones on top.

To fix this we will now print those errors last just before exiting
the simulator because of these errors.
2023-10-05 17:09:38 +02:00
Bård Skaflestad
381ab825b1 Support Segment Level UDQ ASSIGN Statements
This commit adds parser and evaluation logic necessary to handle
ASSIGN statements for segment level UDQs.  This requires a segment
matching facility in UDQConfig::add_assign() which, in turn, must be
passed from the calling context in Schedule::handleUDQ().  Update
APIs accordingly.

We also split handling segment level UDQ assignments to a new helper
function, UDQConfig::add_enumerated_assign(), which might be
generalised to handle block level UDQs in the future.
2023-10-04 10:44:49 +02:00
Bård Skaflestad
f3245ad88a Refactor Assignment Evaluation Routine
In particular, use a single loop over the 'input_index' instead of
one separate loop for each supported variable type.  This is in
preparation of adding suport for segment level UDQ ASSIGN statements.
2023-10-04 10:44:49 +02:00
Bård Skaflestad
cf9b66d8ec Make Derivation of Enumerated Well Items Public
We need this ability to handle segment level UDQ ASSIGN statements
too, so give the operation a well defined home and call it where
applicable.
2023-10-04 10:44:49 +02:00
Bård Skaflestad
72519e3e1f Add Support for Outputting Segment Level UDQs to Summary
This commit adds logic that enables recognizing segment level UDQs
in the summary output writer.  We calculate all segment level UDQs
and add the values to the summary state for possible use in ACTIONX
too.  The latter is not yet tested.
2023-10-04 10:44:49 +02:00
Bård Skaflestad
adab33ac60 Compute Segment Level UDQ Values
This commit adds support for calculating UDQs at the segment level,
i.e., UDQs named 'SU*'.  This necessitates an API change for the UDQ
context constructor and, transitively, every function that forms UDQ
context objects.  We pass a factory function that will create
segment matcher objects on demand, and provide a default
implementation of this factory function in the Schedule class.
2023-10-04 10:44:49 +02:00
Bård Skaflestad
a8d3dff2a4
Merge pull request #3696 from bska/msw-rst-fixup
Fix Multiple Issues in MSW Output Array Creation Logic
2023-10-04 09:55:02 +02:00
Bård Skaflestad
6d3ee57dd5 Define ILBR/ILBS in Terms of Depth First Traversal
The existing algorithm was a little too fragile and dependent on
branch numbers.  This new version starts at segment 1/branch 1 and
follows Segment::inletSegments() in depth-first order, taking care
to enqueue new branches as they're encountered instead of in
numerical order.  We search to the end of each branch before
switching to the next branch.  This ensures determinism regardless
of branch numbering and input ordering.

While here, switch iLBR_ to a WindowedMatrix<int> to simplify branch
references in the output table.
2023-10-02 14:59:55 +02:00
Bård Skaflestad
d7edd7c2ee Fix ISEG[0] Output Order
The value in ISEG[0] does not necessarily correspond to the search
order of that segment.  Rather, ISEG[0] is the depth-first ordering
of the segment search tree when traversing kick-off branches before
the main stem from which those branches kick off.
2023-10-02 14:25:40 +02:00
Bård Skaflestad
1d5ae49cdc Set ISEG Open/Shut Flag for Valves
Missing in earlier editions of the segment output code.
2023-10-02 14:25:40 +02:00
Bård Skaflestad
d3bf44ce87 Tidy up Implementation of Aggregate MSW Data Module
This is in preparation of revising the algorithm for ILBR/ILBS.
Mostly splitting long lines, adding missing headers, passing scalars
by value, and making three helper structures private to the
implementation file.  There are no external users of these types.
2023-10-02 14:25:40 +02:00
Bård Skaflestad
fea67594b8 Tidy up AggregateMSW Test Code
In preparation of adding more test cases.
2023-10-02 14:25:40 +02:00
Kai Bao
f10399bb77
Merge pull request #3697 from bska/prevent-duplicate-inlet-segments
Prevent Duplicate Inlet Segments
2023-10-02 14:09:39 +02:00
Bård Skaflestad
006b65e054 Prevent Duplicate Inlet Segments
If one WELSEGS keyword does not redefine every existing segment,
then we risk adding the same inlet segment multiple times.  If that
happens, we get a segment structure for which there might appear to
be multiple inlet segments on the same branch which is not possible
in a tree structure.  This commit prevents that situation by only
adding the new segment number if it is not already listed in
'm_inlet_segments'.
2023-10-02 13:20:56 +02:00
Svenn Tveit
4769fa7bd6 Fix errors when Scalar = float 2023-09-29 08:27:52 +02:00
Svenn Tveit
6d300b8d13 Ensure that default reference state is used.
Throw error if STCOND is not default or classes are instantiated with (T, P) other than reference values.
2023-09-29 08:27:51 +02:00
Svenn Tveit
34024bfabe Update unit tests with new reference state.
New reference state (T, P)=(288.71 K, 101325.0 Pa) =(15.56 C, 1 atm).
2023-09-29 08:25:24 +02:00
Svenn Tveit
e690d06b54 Update enthalpy to same reference state.
New reference state (T, P) = (288.71 K, 101325.0 Pa) = (15.56 C, 1 atm).
2023-09-29 08:25:24 +02:00
Atgeirr Flø Rasmussen
8ff141a592
Merge pull request #3692 from hnil/more_timing
More timing
2023-09-28 15:40:33 +02:00
Markus Blatt
f66b713d0c
Merge pull request #3693 from akva2/buildsystem_cleanups
Some buildsystem cleanup
2023-09-28 12:23:46 +02:00
Bård Skaflestad
da793e23fc
Merge pull request #3689 from bska/reg-cache-global-ix
Match Connection-to-Region in Terms of Global Cell Indices
2023-09-28 11:48:56 +02:00
hnil
b6a0821992 added timing on co2store evaluation and new timing macros 2023-09-28 10:42:20 +02:00
Bård Skaflestad
ae2f052b37 Match Connection-to-Region in Terms of Global Cell Indices
The simulator reports data::Connection objects tied to global
Cartesian cell indices whence using the 'active_index' leads to
match failures and incorrect rate attribution at the region level.
In one field case we got region level rates and cumulatives, e.g.,
ROPR and ROPT, of zero reported to the summary file when the
expected values should be non-zero.
2023-09-28 10:36:43 +02:00
Markus Blatt
e3fd90f965
Merge pull request #3680 from bska/support-truncated-region-names-revised
Match Region Sets by Unique Prefix
2023-09-28 10:16:08 +02:00
Bård Skaflestad
9342040dbe Match Region Sets by Unique Prefix
This commit switches the region set tag matching algorithm to using
unique prefixes.  This enables the parser to recognise that the
summary vector

    ROPR_UNI

should match up with the user defined region set 'FIPUNIT'.  In the
current master sources, the above summary vector would produce a
diagnostic message saying that the region set 'FIPUNI' (without the
final 'T') does not exist.

We add a prefix-to-canonical region set name translation table to
the FieldProps class and funnel all FIP-like requests through this
translation table.  In the case of non-unique prefixes-e.g., FIPUNIT
and FIPUNIX, we currently elect to have the last keyword entered in
the simulation model "win".  This behaviour may be altered in the
future if deemed appropriate/necessary.
2023-09-26 15:31:20 +02:00
Arne Morten Kvarving
9d8826c2e5 fixed typo in status message 2023-09-26 14:53:45 +02:00
Arne Morten Kvarving
4041f9cc69 remove prereqs file for opm-vertex
this module is defunct and has been defunct for
10 years by now.
2023-09-26 14:53:45 +02:00
Arne Morten Kvarving
ca864e4be9 changed: remove generation of .pc files
this has been broken for a long time, yielding files
containing cmake target names in the linker lines.
2023-09-26 14:53:45 +02:00
Bård Skaflestad
b8816b474b
Merge pull request #3690 from vkip/msw_no_conn
Allow multi-segment wells with no grid connections
2023-09-26 13:53:08 +02:00
Vegard Kippe
30a92cca1e Updated after review input 2023-09-26 13:30:43 +02:00
Vegard Kippe
776597e00b Allow multi-segment wells with no grid connections - warning is already issued. 2023-09-26 13:30:43 +02:00
Bård Skaflestad
53301b78d4
Merge pull request #3687 from bska/more-summary-vectors
Support More Summary Vectors
2023-09-25 12:44:32 +02:00
Bård Skaflestad
ad9ebd730d Support More Summary Vectors
In particular, add support for outputting the following vectors

  - WOGR  -- Well level oil/gas ratio
  - WWGRH -- Well level water/gas ratio (observed rates)
  - FPRH  -- Field level average pressure (hydrocarbon volume)
  - FHPV  -- Field level total hydrocarbon pore-volume
2023-09-22 10:44:44 +02:00
Bård Skaflestad
44cd3eafe2
Merge pull request #3679 from bska/rsmry-udef-regset
Support Region Set Tags For All Region Level Summary Vectors
2023-09-22 10:39:51 +02:00
Bård Skaflestad
fb37bf5db5
Merge pull request #3682 from bska/region-avgpress-hcvol
Emit Region Level Average Pressure Weighted by HC Volume
2023-09-22 10:39:00 +02:00
Bård Skaflestad
e366a940bf
Merge pull request #3688 from bska/wpix-smry-vectors
Add Support for WPIx Summary Vectors
2023-09-22 10:38:24 +02:00
Vegard Kippe
1594680f35 Take default UDQ value from UDQPARAM 2023-09-21 21:13:47 +02:00
Bård Skaflestad
ecbfd4e9c4 Support Region Set Tags For All Region Level Summary Vectors
This commit switches the existing, somewhat spotty, support for
matching region set tags on region level summary vector keywords.
We leverage the recent support for 'deck_name_regex_suffix' keys in
the JSON keyword model to extend the keyword matching algorithm to
also account for these region set tags.

There is a potential for false positives here, but we'll use this
as an initial proof-of-concept implementation.
2023-09-21 18:26:36 +02:00
Markus Blatt
4f52acdc0f
Merge pull request #3685 from bska/multregt-multiple-regsets
Accumulate Total Multiplier From All Region Sets
2023-09-21 17:37:26 +02:00
Vegard Kippe
cadbcda982 Fixed 1-based indexing in segment summary vector lookup 2023-09-21 13:22:52 +02:00
Vegard Kippe
33a27e4e88 Facilitate UDA for WSEGVALV item 4 2023-09-21 13:20:52 +02:00
Bård Skaflestad
ca7fbea637 Accumulate Total Multiplier From All Region Sets
If multiple records, from different region sets and region
IDs--e.g., both regions 1/2 in 'M' (MULTNUM) and regions 2/3 in 'F'
(FLUXNUM) applies to the same connection as might be the case in

    MULTREGT
      1 2  0.5  1*  'NNC'  'F' /
      2 3  0.1  1*  'NNC'  'M' /
    /

then the total multiplier value is the product of the values from
each record.

This commit revises the region set loop to accumulate the total
multiplier value instead of "just" returning the first match.
2023-09-21 13:04:09 +02:00
Bård Skaflestad
7dd3c344cd Emit Region Level Average Pressure Weighted by HC Volume
The simulator already calculates the requisite values, but due to
the requisite summary keyword RPRH not being listed among the known
region level vectors the output layer did not write the values to
the summary file.  This commit adds the requisite table entry.
2023-09-21 11:53:13 +02:00
Bård Skaflestad
d225901733 Add Support for WPIx Summary Vectors
We calculate these, for now, as

   WPIx = WOPR / (WBPx - WBHP)

but it is possible that we may have to revise this definition,
especially for injectors.
2023-09-21 11:52:47 +02:00
Tor Harald Sandve
8ea35f2d0d
Merge pull request #3683 from svenn-t/h2store_updates
H2STORE updates
2023-09-21 09:19:57 +02:00
Bård Skaflestad
e5bd4129a1
Merge pull request #3686 from vkip/aquifer_celldepths_bugfix
Fixing segfault due to use of uninitialized grid properties
2023-09-19 14:46:01 +02:00
Svenn Tveit
cf4a905660 Fixed compilation warnings 2023-09-18 14:47:35 +02:00
Bård Skaflestad
ef88eb3737
Merge pull request #3681 from svenn-t/cskin
Implementation of CSKIN
2023-09-18 14:11:38 +02:00
Vegard Kippe
6755ff8328 Fixing segfault due to use of uninitialized grid properties 2023-09-18 11:43:33 +02:00
Svenn Tveit
44f6a915fc Check for negative CF before calclating it 2023-09-15 19:06:01 +02:00
Svenn Tveit
a89bac6fdb Test CSKIN with WPIMULT, WELPI and COMPDAT 2023-09-15 18:51:35 +02:00
Svenn Tveit
0f40d2c42c wpimult must be multiplied and not overwritten.
Mulitple WPIMULT and WELPI entries are cumulative on same connections.
2023-09-15 18:49:55 +02:00
Bård Skaflestad
6e0e302796
Merge pull request #3677 from vkip/numaqcell_depth
Ensure numerical aquifer cells get the correct depth
2023-09-15 13:04:33 +02:00
Markus Blatt
bbb46325f0
Merge pull request #3678 from bska/normalise-region-keywords-for-lookup
Normalise Region Level Summary Keywords for Lookup Purposes
2023-09-15 10:35:37 +02:00
Markus Blatt
644c0115a1
Merge pull request #3655 from bska/multregt-item-5
Implement NOAQUNNC Region Multiplier Behaviour in MULTREGT
2023-09-15 10:23:20 +02:00
Bård Skaflestad
07ddc15068 Calculate Multiplier Values for Non-Neighbouring Connections
This is intended as a possibly temporary measure for processing
explicitly assigned NNCs (keywords NNC/EDITNNC/EDITNNCR) along with
those NNCs arising from numerical aquifers, and for which there is
no associate face direction.

Add a set of unit tests to probe the implementation of all MULTREGT
connection behaviours as exhibited by MULTREGTScanner member
functions getRegionMultiplier() and getRegionMultiplierNNC().
2023-09-14 15:29:58 +02:00
Svenn Tveit
ea4aebda5d Test H2-brine PVTs 2023-09-14 12:31:59 +02:00
Svenn Tveit
a11becab76 H2STORE updates.
- Enables use with THERMAL. Note that enthalpy of H2 dissolution process is not included due to lack of published data on this (as far as I have seen).
- Enables use with DIFFCGAS and DIFFCWAT.
- Enables use with dynamic brine module.
- New H2 table made with Coolprop which includes enthalpy data.
2023-09-14 12:31:59 +02:00
Svenn Tveit
338ee8dd4a H2STORE is a OPM only keyword 2023-09-14 12:31:59 +02:00
Svenn Tveit
30cd8b8141 Test CSKIN input 2023-09-14 09:48:55 +02:00
Svenn Tveit
d410d8c232 Recalculate pressure equivalent radius when Kh=0.
Kh is calculated from grid block info and r0 must be consistent with that.
2023-09-14 08:51:01 +02:00
Svenn Tveit
f933b0e113 Implementation of CSKIN keyword.
To work with WPIMULT, the PI scaling factor had to be stored and applied to calculated CF.
2023-09-14 08:51:01 +02:00
Bård Skaflestad
9a3e8dba23 Normalise Region Level Summary Keywords for Lookup Purposes
Region level summary keywords may have suffixes which refer to user
defined region sets ('FIP*' keyword).  This commit prunes those
suffixes when performing function lookup, so that we do not get
false negatives.

To this end, introduce a new helper function

  EclIO::SummaryNode::normalise_region_keyword()

and use this both when determining the summary keyword type (rate,
cumulative, pressure &c) and when looking up evaluation functions
for region level summary vectors.  The new helper could arguably
have been integrated into the existing 'normalise_keyword()' helper
function, but that would have necessitated a different change
elsewhere in the code base.  For now, we keep this helper as a
separate function.
2023-09-13 18:00:01 +02:00
Vegard Kippe
68f6c5f5af .. and renaming the last call to computeCellDepth.. 2023-09-13 15:49:29 +02:00
Vegard Kippe
e23e69d328 Re-introducing another line that somehow was deleted 2023-09-13 15:40:43 +02:00
Vegard Kippe
90b9f30f67 Re-introducing line that somehow was deleted 2023-09-13 15:34:42 +02:00
Vegard Kippe
74d77cfcc4 Renaming as suggested by reviewer 2023-09-13 15:13:58 +02:00
Vegard Kippe
37f62d4b0f Ensure numerical aquifer cells get the correct depth 2023-09-13 13:56:14 +02:00
Bård Skaflestad
51b1cf614d Make Region Multiplier Aware of Aquifer Connections
This commit implements the 'NOAQUNNC' behaviour in member function

    MULTREGTScanner::getRegionMultiplier()

We use the new 'aquifer_cells' data member to identify connections
to and within numerical aquifers and ignore those if the record
stipulates 'NOAQUNNC' behaviour.
2023-09-13 13:42:32 +02:00
Bård Skaflestad
f99ae4b7cc Make MULTREGT Processor Aware of Numerical Aquifers
This commit adds a new data member

    MULTREGTScanner::aquifer_cells

which holds a sorted sequence of Cartesian/global cell indices
corresponding to the cells which comprise the model's numerical
aquifers.  These are needed to properly identify whether or not a
connection--i.e., a cell pair--would constitute a "numerical aquifer
connection" and be subject to 'NOAQUNNC' treatment.

We assign the numerical aquifer cells as part of member function

    EclipseState::conveyNumericalAquiferEffects

which runs at EclipseState construction time.  We know all numerical
aquifers at that point.
2023-09-13 13:42:32 +02:00
Bård Skaflestad
139701b017
Merge pull request #3673 from bska/kw-regex-suffix
Support Regular Expression Suffix for Keyword Matching
2023-09-13 12:49:06 +02:00
Bård Skaflestad
5fc5c86815
Merge pull request #3675 from vkip/bflowijk
Adding support for the summary vectors BFLOW[I|J|K]
2023-09-13 11:54:25 +02:00
Bård Skaflestad
5fc87fa10c Support Regular Expression Suffix for Keyword Matching
This is mostly to have a general solution for matching region level
summary keywords which may reference a user-defined region set (FIP
keyword, e.g., FIPXYZ) through tags like

    RPR__XYZ -- Average pressure in region, FIPXYZ region set
    ROPR_XYZ -- Oil production rate in region, FIPXYZ region set
    RODENXYZ -- Average oil density in region, FIPXYZ region set

The initial approach introduced in commit cfbafc236 was limited to
selected keywords.

To this end, add a new data member

    std::string ParserKeyword::m_matchRegexSuffix

and introduce a new member function

    bool ParserKeyword::matchesDeckNames()

which matches a candidate keyword string against the m_deckNames,
and, if applicable, as a regular expression against m_deckNames when
appended m_matchRegexSuffix.
2023-09-13 11:11:32 +02:00
Kai Bao
0f2a02dc40
Merge pull request #3676 from akva2/add_missing_initialization
fixed: initialize data in ConditionalStorage
2023-09-13 10:59:52 +02:00
Arne Morten Kvarving
9f0ea44f9c fixed: initialize data in ConditionalStorage 2023-09-13 10:04:40 +02:00
Vegard Kippe
42434dd038 Adding support for the summary vectors BFLOWI|J|K 2023-09-13 09:15:03 +02:00
Bård Skaflestad
b1672210ba
Merge pull request #3669 from steink/well_control_access
Utility functions for manipulation of well-controls
2023-09-12 13:33:53 +02:00
Bård Skaflestad
8cde088e19
Merge pull request #3665 from atgeirr/make-wconinjh-invalid-mode-a-warning
Allow invalid WCONINJH control mode
2023-09-12 13:29:03 +02:00
Atgeirr Flø Rasmussen
1e2f23ac03
Merge pull request #3672 from bska/remove-extra-semicolon
Remove Unnecessary Semicolons on Closing Braces
2023-09-11 17:54:20 +02:00
Atgeirr Flø Rasmussen
92a716fa18 Make it a warning instead of an error to specify an invalid control mode in WCONINJH.
Motivated by the need to accept deck output that contain this error,
that is generated by preprocessing tools.
2023-09-11 17:39:48 +02:00
Bård Skaflestad
1261cf2b5c Remove Unnecessary Semicolons on Closing Braces
These generate diagnostic messages from GCC at '-pedantic' levels.
2023-09-07 17:07:35 +02:00
Stein Krogstad
6ecabdbd7b Add access to injection controls 2023-09-07 13:48:09 +02:00
Stein Krogstad
703431ce61 Add functions to enable edit of prod controls 2023-09-07 13:48:09 +02:00
Bård Skaflestad
3411e1e0c6
Merge pull request #3651 from plgbrts/std-netw-gaslift
Adding item 6 (gas lift) to standard network keyword GRUPNET
2023-09-06 14:32:09 +02:00
Paul
ad076fc3c2 removed usage of Deckitem::to_bool() 2023-09-05 13:53:31 +02:00
Atgeirr Flø Rasmussen
5010643b0d
Merge pull request #3654 from bska/tidy-multregt-scanner
Tidy Up MULTREGT Scanner Implementation File
2023-09-04 15:26:55 +02:00
Paul
ee8c0a28a1 changed a comment 2023-09-04 10:58:34 +02:00
Paul
bd878c2312 reverted file 2023-09-04 10:58:34 +02:00
Paul
75e6318474 rebase 2023-09-04 10:58:33 +02:00
Paul
f04bbefaee add gas-lift to standard network 2023-09-04 10:58:33 +02:00
Paul
d1eed2cd4d allow for wildcards 2023-09-04 10:58:32 +02:00
Paul
bf1b2dbef9 fixing unit test 2023-09-04 10:58:32 +02:00
Bård Skaflestad
53e2758649 Ignore Default Regions in MULTREGT
The MULTREGT keyword has an independent way of defining the default
region--the default value of item 6--and does not need the default
GRIDOPTS-base region protocol of the other *REG keywords.
2023-09-04 10:30:36 +02:00
Bård Skaflestad
f6676fcc1a Reorder MULTREGTScanner Implementation File
Mostly to group related functions and have the same order in the
declaration and the implementation files.  While here, replace an
'enum' with a strong enum since the type does not need to support
arithmetic operations.
2023-09-04 10:30:36 +02:00
Bård Skaflestad
383dbf27a9
Merge pull request #3653 from bska/identify-aqunum-cells
Add Method for Identifying Numerical Aquifer Cell IDs
2023-09-04 10:14:06 +02:00
Bård Skaflestad
b84c5f46bf Add Method for Identifying Numerical Aquifer Cell IDs
This commit adds a new, focused, member function

  NumericalAquifers::allAquiferCellIds()

which returns a vector of those Cartesian/global cells that have
been marked as defining the model's numerical aquifers through the
AQUNUM keyword.  We intend to use this to identify those NNCs that
go to numerical aquifers--or between numerical aquifer cells--as
those may need special treatment when processing the MULTREGT
keyword.
2023-09-04 08:52:08 +02:00
Kai Bao
3ab1f65485
Merge pull request #3640 from vkip/top_segment_perfdepth
Avoid top segment perforation depth outside perforated grid cell.
2023-09-01 23:55:37 +02:00
Vegard Kippe
7d7d15e331 Removing unused include 2023-09-01 16:01:20 +02:00
Vegard Kippe
1728d9d310 Addressing test failure in MulgisegmentWellTests + slight change to avoid modifying Connection.cpp 2023-09-01 15:59:28 +02:00
Vegard Kippe
57a70082bc Updated comment 2023-09-01 15:59:28 +02:00
Vegard Kippe
4f74385dc0 Avoid connection depths outside perforated cell. 2023-09-01 15:59:27 +02:00
Tor Harald Sandve
263070f9b4
Merge pull request #3657 from hakonhagland/gecon2
Implement support for GECON keyword
2023-09-01 15:06:36 +02:00
Tor Harald Sandve
1d048e43d2
Merge pull request #3648 from totto82/fix_waghystr
avoid negative C factor
2023-09-01 15:03:02 +02:00
Atgeirr Flø Rasmussen
8dab1ea48a
Merge pull request #3642 from bska/parser-accept-registered-long-keywords
Recognise Extension Keywords Whose Names Exceed Size Limits
2023-09-01 12:42:14 +02:00
Bård Skaflestad
f14621aeba Recognise Extension Keywords Whose Names Exceed Size Limits
This commit adds targeted support for identifying keywords whose
names exceed the maximum compatibility keyword length limit.  This,
in turn, enables seamless recognition of extension keywords such as

  STRESSEQUILNUM

without compromising the parser's ability to identify long keyword
names that match existing keywords in the first eight characters.
For example, the input string 'GUIDERATE' will still match the
keyword 'GUIDERAT' (without the trailing 'E') and will not be
accidentally treated as a SUMMARY section request to output a group
level UDQ vector.
2023-08-30 15:27:06 +02:00
Bård Skaflestad
e179bf87dd Split Keyword Recognition Into Two Parts
The 'base' checks that the input string looks like a valid keyword
and, if so, matches the string against the builtin set of known
keywords.  The full keyword recognition process additionally
includes those keywords that match against keyword collections,
typically the SUMMARY section "meta" keywords in the *_PROBE files.

We will use the 'base' recognition separately to introduce support
for extension keywords with long--more than eight character--names.
2023-08-30 15:27:06 +02:00
Bård Skaflestad
d3a68ff861
Merge pull request #3628 from GitPaean/filtration_summary_keywords
Filtration summary keywords
2023-08-30 13:31:54 +02:00
Kai Bao
63a2c77063 optimizing filtration summary keyword output evaluation 2023-08-29 22:29:41 +02:00
Tor Harald Sandve
0fad30d7cb Fix three phase check in waghystr model. Also check for oil phase 2023-08-29 12:39:46 +02:00
Håkon Hægland
612e4c0e9c Move template implementation to header file 2023-08-29 10:36:54 +02:00
Håkon Hægland
7d1f1b103e Move template implementation to header file 2023-08-29 10:28:42 +02:00
Kai Bao
48b759178c fixing the parallel running and testing related to filtrate 2023-08-29 09:08:45 +02:00
Kai Bao
2d35b1e20c adding support for the filtrate summary keywords 2023-08-29 09:08:45 +02:00
Kai Bao
b2eb44423a adding some OPM-specific Well and Connection Summary keywords
for the development of the filtration modeling during the water
injection.
2023-08-29 09:08:45 +02:00
Håkon Hægland
bec10dbfbe Implement GECON keyword
Implements support for the GECON keyword.
2023-08-29 01:10:21 +02:00
Bård Skaflestad
a0e72a62c4
Merge pull request #3528 from vkip/tuning_max_next_tstep
TUNING/NEXT[STEP]: Facilitate using max time step only when specified
2023-08-28 15:03:31 +02:00
Vegard Kippe
b47324e42f Actually check the TSINIT value in TuningTests.cpp 2023-08-28 11:21:34 +02:00
Vegard Kippe
98adf5a536 Workaround to avoid failing tests, also fixed some tab indenting. 2023-08-28 11:21:34 +02:00
Vegard Kippe
128ba83810 Facilitate using max time step from TUNING/NEXT[STEP] only when specified. Also corrects the persistent behaviour of NEXTSTEP. 2023-08-28 11:21:33 +02:00
Kai Bao
325ee7bbb3
Merge pull request #3652 from GitPaean/remvoing_vfp_group
removing the vfp_table member from Group class
2023-08-25 23:18:36 +02:00
Kai Bao
0c64a142c1 removing the vfp_table member from Group class
after GRUPNET is processed, vfp_table is not useful for GROUP class
anymore.
2023-08-25 00:21:45 +02:00
Kai Bao
b4c30cf93b
Merge pull request #3643 from vkip/avoid_zero_conndepth
Avoid connection depth = 0 when segment is specified without depth in COMPSEGS
2023-08-23 23:53:19 +02:00
Kai Bao
d9278cf053
Merge pull request #3609 from plgbrts/std-network
Enable standard network using GRUPNET
2023-08-23 23:03:12 +02:00
Paul
a90d899bc0 removed repeated line 2023-08-23 16:16:53 +02:00
Paul
7d2083b948 restructuring 2023-08-23 16:16:52 +02:00
Paul
83157a01dd added unit standard network test in NMetworkTests and removed test in GroupTests 2023-08-23 16:16:52 +02:00
Paul
feb9c9c948 added two throws 2023-08-23 16:16:52 +02:00
Paul
1d1bd74cf8 add const for group 2023-08-23 16:16:51 +02:00
Paul
262c325960 Adressing review comments 2023-08-23 16:16:51 +02:00
Paul
dbeb7405ba add_node -> update_node 2023-08-23 16:16:51 +02:00
Paul
7fa0d94e7b code fixes based on review comments 2023-08-23 16:16:50 +02:00
Paul
88b654fb57 allow for wildcards 2023-08-23 16:16:50 +02:00
Paul
f70a0e50e0 Rebasing 2023-08-23 16:16:49 +02:00
Paul
5a342db5a3 removed an include 2023-08-23 16:16:49 +02:00
Paul
4c1ea1f478 Enable standard network using GRUPNET 2023-08-23 16:16:48 +02:00
Markus Blatt
4ab9de18ed
Merge pull request #3649 from GitPaean/fixing_numerical_aquifer
not considering numerical aquifers cells inside reservoir
2023-08-23 15:52:19 +02:00
Kai Bao
06a4d3ef51 not considering numerical aquifers cells inside reservoir
since we forcefully make numerical aquifer cells active. If a connection
cells is neighboring a numerical aquifer cell, we should be able to create
NNC to connection the cell and the nuermical aquifer cell.
2023-08-23 14:24:12 +02:00
Bård Skaflestad
5c09a1ed62
Merge pull request #3614 from GitPaean/udq_winjclcn
handle UDQ value for WINJFCNC
2023-08-23 13:37:18 +02:00
Kai Bao
6a25eadee7 using PPM as the unit for VOL_CONCENTRATION in keyword WINJFCNC 2023-08-23 11:44:13 +02:00
Kai Bao
9a7147bead handle UDQ value for WINJFCNC
restarting related is missing for now
2023-08-23 11:44:13 +02:00
Bård Skaflestad
e8502c2d6d
Merge pull request #3650 from akva2/init_file_restore_order
fixed: restore order of 'standard' fields in init file
2023-08-23 11:29:20 +02:00
Arne Morten Kvarving
0e99224e12 fixed: restore order of 'standard' fields in init file
we want to match the commercial simulator here
2023-08-23 10:46:03 +02:00
Tor Harald Sandve
e08a4efe65 avoid negative C factor 2023-08-22 12:23:38 +02:00
Markus Blatt
45ec2f9c89
Merge pull request #3645 from blattms/fix_esmry-scale-factors
Pevent undefined behavior of ESMry scale factors for values <=0.
2023-08-22 07:21:20 +02:00
Markus Blatt
d9cdfac302
Merge pull request #3639 from bska/multregt-revise-nnc-identification
Use Existing Cartesian-to-IJK Functionality to Determine NNCs in MULTREGT
2023-08-22 07:19:16 +02:00
Markus Blatt
6b194d8758
Merge pull request #3644 from bska/multregt-no-pointers
Switch to Numeric Indices for Record References
2023-08-22 07:18:13 +02:00
Bård Skaflestad
f32ff86638 Use Existing Cartesian-to-IJK Functionality
This commit replaces the data members 'nx', 'ny', and 'nz' with a
copy of the GridDims object passed as an argument to the
constructor.  In turn, this enables using GridDims::getIJK() to
compute the cell's IJK tuple from its global Cartesian index instead
of implementing the same calculation locally (and incorrectly).

While here, also include the layer index (K) in determining whether
or not a connection is an NNC, and do this just once instead of once
for each MULTREGT record.  Cells (I,J,K) and (I,J,K+3) might be
connected across pinched-out layers and for the purposes of MULTREGT
that connection should be treated as an NNC.
2023-08-21 11:41:03 +02:00
Bård Skaflestad
2c74d036d6 Tidy Up MULTREGT Scanner Files
In particular, ensure that we include all requisite headers, hide
type aliases that are not needed outside the class, consistently use
std::size_t, split a few long lines, and switch to range-for in one
location.
2023-08-21 11:41:03 +02:00
Bård Skaflestad
2dc650ff72 Switch to Numeric Indices for Record References
A numeric index serves the same purpose as a pointer in this very
specific instance and also has the benefit of being easily
transferable between processes.  This, in turn, means we can remove
the 'getSearchMap()' and 'constructSearchMap()' member functions.
2023-08-21 11:40:44 +02:00
Markus Blatt
07d1d5f161 Pevent undefined behavior of ESMry scale factors for values <=0.
We use log10 of the value to compute the scale factor. This only makes
sense for positive values. For zero it returns -HUGE_VAL and for
negative values it returns nan where supported.

Unfortunately on some platforms (e.g. mips64el) further operations in
nan resulted in values so large that the scale factors were to large
for the columns. This resulted in invalid_argument exceptions in
strtod which were hard to debug. Out of pure luck on many platforms
the scale factors still were zero in this case.

To fix this we now always use a scale factor 0 for values less or
equal to zero. This fixes e.g. Debian packages on mips64el.

In addition we now make sure that printed scale factors have less
characters than the column width. Otherwise parsing the *.RSM file
might fail because of throwing strtod function.
2023-08-21 07:54:04 +02:00
Vegard Kippe
570666afea Removed commented-out lines 2023-08-18 16:51:09 +02:00
Vegard Kippe
624ff6f771 Perform the connection-depth-from-segments calculations even if the segment number is specified. 2023-08-18 16:47:43 +02:00
Bård Skaflestad
99e3608bf3
Merge pull request #3626 from GitPaean/adding_unit_area
adding unit area
2023-08-17 15:09:49 +02:00
Kai Bao
13eaf8a271 adding unit area 2023-08-17 13:55:33 +02:00
Bård Skaflestad
ddb94c15a3
Merge pull request #3637 from akva2/mech_props
Add field properties used for mechanics
2023-08-17 13:12:15 +02:00
hnil
d157bd627f add THELCOEF field property
this is the thermal expansion coefficient for each cell in a mechanics model
write this to the .INIT file for relevant models
2023-08-17 11:54:18 +02:00
hnil
861be6be91 add THERMEXR field property
this is the thermal expansion ratio for each cell in a mechanics model
write this to the .INIT file for relevant models
2023-08-17 11:54:18 +02:00
hnil
1948dc5d51 add PRATIO field property
this is the Poisson's ratio for each cell in a mechanics model
write this to the .INIT file for relevant models
2023-08-17 11:54:18 +02:00
hnil
27dcd6e246 add POELCOEF field property
this is the coefficient of elasticity for each cell in a mechanics model
write this to the .INIT file for relevant models
2023-08-17 11:54:18 +02:00
hnil
191364d2f3 add BIOTCOEF field property
this is the Biot coefficient for each cell in a mechanics model
write this to the .INIT file for relevant models
2023-08-17 11:54:18 +02:00
hnil
6ed7370db3 add STRESSEQUILNUM field property
this is used to set the stress equilibration region for cells in
mechanics models
2023-08-17 11:54:18 +02:00
hnil
217f8f7b60 add YMODULE field property
this is the Young's modulus for each cell in a mechanics model
write this to the .INIT file for relevant models
2023-08-17 08:34:51 +02:00
hnil
3a66f7c9b6 added: Ymodule dimension in UnitSystem 2023-08-17 08:14:09 +02:00
Bård Skaflestad
e22b0944dd
Merge pull request #3632 from vkip/correct_rft_depths_and_pressures
Make DEPTH and PRESSURE contain the cell values
2023-08-16 17:50:32 +02:00
Bård Skaflestad
58ff8944c4
Merge pull request #3636 from akva2/mech_bc
Add support for MECH boundary conditions
2023-08-16 16:52:21 +02:00
Bård Skaflestad
0c037db51c
Merge pull request #3635 from akva2/add_strequil
Add STREQUIL keyword and internalization
2023-08-16 16:12:19 +02:00
Bård Skaflestad
6e4c37d05f
Merge pull request #3634 from akva2/mech_runspec
-- added MECH to runspec
2023-08-16 16:11:38 +02:00
hnil
614d71666d add mech boundary conditions 2023-08-16 15:56:45 +02:00
hnil
a0ba0be7cc -- added stress equilibrium data for initconfig 2023-08-16 15:13:38 +02:00
Arne Morten Kvarving
111aa44936 changed: refactorize Equil class into a container template over a record type
make Equil a type alias for EquilContainer<EquilRecord>
2023-08-16 15:13:38 +02:00
Arne Morten Kvarving
df6345e15d EquilRecord: add in-class initializers
then we can default the default constructor
2023-08-16 15:13:38 +02:00
Arne Morten Kvarving
a93e285552 changed: add EquilRecord::serializationTestObject
and use this in Equil::serializationTestObject()
2023-08-16 15:13:38 +02:00
Arne Morten Kvarving
89f59e0050 changed: add a DeckRecord constructor for EquilRecord and use this in Equil 2023-08-16 15:13:38 +02:00
Bård Skaflestad
3fd1815078
Merge pull request #3633 from akva2/bcconfig_tests
added: basic tests for BCCON / BCPROP
2023-08-16 15:06:52 +02:00
Vegard Kippe
12c20f4188 Removing unused parameter 2023-08-16 14:44:16 +02:00
hnil
980a160651 -- added MECH to runspec 2023-08-16 14:15:23 +02:00
Arne Morten Kvarving
bd3328b15c added: basic tests for BCCON / BCPROP 2023-08-16 13:58:39 +02:00
Vegard Kippe
c97ef332f0 Removing duplicate lines.. 2023-08-16 13:22:32 +02:00
Vegard Kippe
25cf268b56 Removing unnecessary changes to PLT record (only renaming to conn_depth_ and conn_pressure_ for clarity, as suggested) 2023-08-16 13:20:53 +02:00
Markus Blatt
d23d2288c7
Merge pull request #3629 from bska/reclassify-PCx-keywords
Properly Classify Capillary Pressure Keywords
2023-08-16 10:18:21 +02:00
Vegard Kippe
8031eaf9d0 Make DEPTH and PRESSURE contain the cell values, not the connection values (which are reported in CONDEPTH/CONPRES when PLTs are requested) 2023-08-16 09:41:28 +02:00
Bård Skaflestad
f68fe9b484 Properly Classify Capillary Pressure Keywords
These are not directionally dependent, and they have a unit string
of 'Pressure'.  This didn't use to matter, but upcoming changes
will depend on the unit string being correct.
2023-08-15 17:27:47 +02:00
Bård Skaflestad
5495eca413 Properly Remove 'satfunc' Macro
The macro should not escape the FieldProps.hpp header.
2023-08-15 17:27:47 +02:00
Bård Skaflestad
cda61b46c0 Remove sogcr_shit Helper Array
This array became unused in commit 146be0aa2 and should have been
removed at that time.
2023-08-15 17:27:47 +02:00
Bård Skaflestad
4f3d22f655
Merge pull request #3631 from akva2/tracy_macro_definitions
TimingMacros: add definitions for using tracy
2023-08-15 17:18:42 +02:00
Arne Morten Kvarving
89deeea9d5 TimingMacros: add definitions for using tracy 2023-08-15 15:55:03 +02:00
Atgeirr Flø Rasmussen
ed8489ada6
Merge pull request #3630 from svenn-t/h2store_new_visc
Improved gas viscosity model for hydrogen
2023-08-15 08:31:01 +02:00
Svenn Tveit
c6cd71df08 Improved viscosity model for hydrogen.
Model from Muzney et al., J. Chem. Eng. Data 2013, 58, 4, 969–979 implemented. Same as NIST and Coolprop.
2023-08-14 12:31:01 +02:00
Bård Skaflestad
f95cbea921
Merge pull request #3625 from GitPaean/adding_unit_ppm
adding unit PPM
2023-08-10 16:29:34 +02:00
Kai Bao
22de6c1480 adding unit PPM
Parts per million (ppm). We are not distinguishing PPM volume or PPM
mass, or other forms. Will update when it comes to be necessary.
2023-08-10 15:23:14 +02:00
Bård Skaflestad
0895983ac1
Merge pull request #3619 from bska/field-props-janitor
Preventive Maintenance of FieldProps Class
2023-08-09 17:06:08 +02:00
Bård Skaflestad
3caf79a99a Disambiguate Potentially Dependent Names
It's probably not strictly necessary, but better safe than sorry.
2023-08-09 14:37:57 +02:00
Bård Skaflestad
027c15800a Preventive Maintenance of FieldProps Class
In particular:
  - Order include statements
  - Simplify logic
  - Adjust whitespace

This is in preparation of making FIP* array names unique only up to
the first six characters (i.e., "FIP" + at most three others).
2023-08-09 14:37:57 +02:00
Kai Bao
144faaf645
Merge pull request #3623 from atgeirr/allow-default-network-nodes
Allow implicit creation of production network nodes.
2023-08-09 14:31:50 +02:00
Atgeirr Flø Rasmussen
67c7f858a4 Rename add_node() -> update_node(). 2023-08-09 13:28:24 +02:00
Bård Skaflestad
aab5d1125b
Merge pull request #3584 from svenn-t/unittests
Component unit tests and some minor updates
2023-08-08 18:14:37 +02:00
Bård Skaflestad
40d806987c
Merge pull request #3624 from blattms/move-lambda-prevent-warn
[janitor] Move lambda to prevent warning.
2023-08-08 17:22:19 +02:00
Markus Blatt
ee30e6f42d [janitor] Move lambda to prevent warning.
Fixes the warning introduced by #3605
2023-08-08 16:13:40 +02:00
Atgeirr Flø Rasmussen
508ed49388 Add test for defaulted network nodes. 2023-08-08 16:00:21 +02:00
Atgeirr Flø Rasmussen
f3d1eea2dc Allow implicit creation of nodes.
Nodes with default properties do not need any
NODEPROP entries and can be implicitly created
by being referred to in BRANPROP.
2023-08-08 15:46:57 +02:00
Atgeirr Flø Rasmussen
fb37377324
Merge pull request #3605 from blattms/fatal-section-topology-errors
Register errors concerning section topology in ErrorGuard.
2023-08-08 11:30:02 +02:00
Markus Blatt
395d85fb55
Merge pull request #3618 from bska/ordered-map-string-view
Implement OrderedMap in Terms of String_View
2023-08-08 11:14:45 +02:00
Bård Skaflestad
7533eadb2e Implement OrderedMap in Terms of String_View
We don't need std::string in the hashing operations, so lift those
restrictions.
2023-08-07 17:04:13 +02:00
Atgeirr Flø Rasmussen
e51c5cb4dd
Merge pull request #3616 from GitPaean/removing_duplicated_clang_key
removing duplicated key in .clang-format
2023-08-07 10:09:20 +02:00
Kai Bao
2551050974 removing duplicated key in .clang-format 2023-08-04 15:00:56 +02:00
Bård Skaflestad
f0c5ed5f83
Merge pull request #3613 from akva2/grouptests_raw
GroupTests: use raw string literals
2023-08-01 23:33:31 +02:00
Arne Morten Kvarving
bd59b6caab GroupTests: remove leading whitespace in decks 2023-08-01 14:38:54 +02:00
Arne Morten Kvarving
2ba0caab7f GroupTests: use raw string literals 2023-08-01 14:38:54 +02:00
Atgeirr Flø Rasmussen
9b22346255
Merge pull request #3612 from akva2/janitoring
quell unused parameter warnings
2023-07-31 12:50:02 +02:00
Arne Morten Kvarving
b1cf35168a quell unused parameter warnings 2023-07-31 08:37:58 +02:00
Atgeirr Flø Rasmussen
a50513c971
Merge pull request #3585 from hnil/twophaseFixes
Fixes for two-phase relperm
2023-07-26 15:31:02 +02:00
hnil
6de987eaec fixed after review 2023-07-26 14:09:15 +02:00
Markus Blatt
3eddcb8936
Merge pull request #3607 from blattms/rename-time-step-breakdown
Rename LinearTimeSteppingBreakdown to TimeSteppingBreakdown
2023-07-26 09:49:15 +02:00
Markus Blatt
0a916c4b73 Rename LinearTimeSteppingBreakdown to TimeSteppingBreakdown
Indeed that is more intuitive. I guess the previous name was due to
copy & paste and forgetting to change things afterwards.
2023-07-25 14:56:47 +02:00
Tor Harald Sandve
79137ae882
Merge pull request #3604 from blattms/fix-ptflash
[bugfix] Use numComponents when accessing K_/moleFractions_ in PTFlash.
2023-07-25 12:24:58 +02:00
Markus Blatt
e5c44baf38 Also detect keywords after operate key words in wrong section.
This will find keywords in statements like
MULTIPLY
  'TRANX' 2.0 /
  'TRANY' 2.0 /
 /
2023-07-24 15:59:01 +02:00
Bård Skaflestad
ebd2ab4e59
Merge pull request #3573 from goncalvesmachadoc/collectCarfin
Store Multiple Lgrs
2023-07-21 09:34:48 +02:00
goncalvesmachadoc
946462e377 delete carfin from string 2023-07-20 11:15:23 +02:00
Markus Blatt
016dfa9ea7 Prevent std::exit(1) in tests due to ErrorGuard's destructor.
If ErrorGuard's lists have not been cleared, then it's destructor
will call std::exit(1). As that is quite unfortunate in a test, we
clear it's message stack at the end of the tests.
2023-07-20 10:36:05 +02:00
Markus Blatt
e56e2f4d26 Register errors concerning section topology in ErrorGuard.
That will make those (e.g. EDITNNC in the GRiD section) fatal.
2023-07-19 17:44:59 +02:00
goncalvesmachadoc
d23b045905 delete prefix for testing 2023-07-19 11:18:15 +02:00
goncalvesmachadoc
1c780e78f4 towards serialization 2023-07-18 16:42:11 +02:00
goncalvesmachadoc
5df7a148e9 get lgr by index 2023-07-18 12:02:09 +02:00
goncalvesmachadoc
0c897eb51d update for loops 2023-07-18 11:15:23 +02:00
goncalvesmachadoc
fb2290a07a extra line 2023-07-18 10:32:54 +02:00
goncalvesmachadoc
c0404e798e update tests 2023-07-18 10:32:53 +02:00
goncalvesmachadoc
c5f664650e collectLGRinEclState 2023-07-18 10:32:53 +02:00
goncalvesmachadoc
ca6f232486 expand methods 2023-07-18 10:32:52 +02:00
goncalvesmachadoc
0aa2941150 start for unit tests 2023-07-18 10:32:52 +02:00
goncalvesmachadoc
94e9900d39 small fix class 2023-07-18 10:32:51 +02:00
goncalvesmachadoc
4e7fde0c64 simplify collection 2023-07-18 10:32:51 +02:00
goncalvesmachadoc
22c5965fb5 add carfin collection 2023-07-18 10:32:50 +02:00
Bård Skaflestad
ee44c0fbe5
Merge pull request #3602 from blattms/gcc-13-missing-include
Added missing include of cstdint for GCC-13
2023-07-18 10:21:46 +02:00
Markus Blatt
e694e465e0 Use int type from std namespace. 2023-07-17 12:40:27 +02:00
Bård Skaflestad
d7f1b6bd27
Merge pull request #3601 from plgbrts/gconprod
Enable items, 11, 12 and 13 of GCONPROD
2023-07-14 21:23:23 +02:00
Paul
babf4c590d fix for test GroupTests 2023-07-14 13:18:13 +02:00
Paul
2470cf2ed7 Use bitwise or 2023-07-14 11:26:03 +02:00
Paul
c422724422 Struct for collecting group limit actions 2023-07-14 11:16:29 +02:00
Markus Blatt
063b1f284a [bugfix] Use numComponents when accessing K_/moleFractions_ in PTFlash.
Previously we did read and write out of bounds as num_equations might
be bigger than numComponents. For GCC-13 this even caused endless loops.
2023-07-14 10:18:07 +02:00
Markus Blatt
f284a7e7fb Added missing include of cstdint for GCC13
Without the include compilation fails with
```
/opm/io/eclipse/EclFile.hpp:92:17: error: ‘uint64_t’ was not declared in this scope
   92 |     std::vector<uint64_t> ifStreamPos;
      |                 ^~~~~~~~
In file included from src/opm/io/eclipse/EclOutput.cpp:20:
opm/io/eclipse/EclUtil.hpp:56:5: error: 'uint64_t' does not name a type
   56 |     uint64_t sizeOnDiskBinary(int64_t num, Opm::EclIO::eclArrType arrType, int elementSize);
      |     ^~~~~~~~

```
2023-07-14 08:37:56 +02:00
Paul
f8dac94ac9 some formatting 2023-07-13 13:17:45 +02:00
Markus Blatt
bb94b09c79
Merge pull request #3600 from bska/record-actionx-well-structure-change
Add Facility for Recording ACTIONX Well Structure Changes
2023-07-13 10:27:37 +02:00
Paul
7d6391b1fa added serializer items 2023-07-12 22:12:39 +02:00
Paul
e86f7f2d2d Enable items, 11, 12 and 13 of GCONPROD 2023-07-12 20:45:09 +02:00
Bård Skaflestad
5f0941677a Add Facility for Recording ACTIONX Well Structure Changes
This commit adds a new member, well_structure_change, to the
SimulatorUpdate structure.  The member defaults to 'false', but
will be set to 'true' if an ACTIONX block contains at least one of
a select group of keywords that affect the model's well topology.

In particular, set this member to 'true' if the ACTIONX block has
at least one of the keywords

  - COMPDAT
  - WELOPEN
  - WELSPECS

This will enable adding simulator logic to open or create wells in
the middle of a report step.
2023-07-12 17:31:30 +02:00
Bård Skaflestad
684dbb21b4
Merge pull request #3599 from blattms/exception-time-stepper
Added exception to mark time step being cut too often.
2023-07-12 16:52:28 +02:00
Markus Blatt
7e3eeb34b0 Added exception to mark time step being cut too often.
This is needed for a more user friendly message in the simulator.
2023-07-12 14:17:56 +02:00
Bård Skaflestad
7c6af8584f
Merge pull request #3560 from bska/wbp-emit-values
Emit WBPn Summary Vectors to Summary Result File
2023-07-11 14:15:05 +02:00
Bård Skaflestad
dbaf600fcf Emit WBPn Summary Vectors to Summary Result File
This commit hooks the WBPn result vectors up to the summary file
writing process.
2023-07-11 13:15:43 +02:00
Bård Skaflestad
e549690df4
Merge pull request #3598 from goncalvesmachadoc/gconprod
Make only one json for GCONPROD
2023-07-11 13:09:26 +02:00
goncalvesmachadoc
29cd408d99 one json 2023-07-11 11:49:07 +02:00
Bård Skaflestad
35a99be016
Merge pull request #3597 from bska/use-algorithm-for-keyword-list
Use Algorithm Instead of Raw Loop
2023-07-10 16:06:26 +02:00
Bård Skaflestad
f0d0a87606 Use Algorithm Instead of Raw Loop
Mostly for maintainability.
2023-07-10 14:39:16 +02:00
Bård Skaflestad
264cd13138
Merge pull request #3594 from bska/smry-emit-phase-densities
Add Summary Output of Fluid Densities at Block and Segment Levels
2023-07-10 13:58:47 +02:00
Bård Skaflestad
7f80ae8e2a Add Summary Output of Segment Level Fluid Densities
In particular, recognize the summary vectors

  - SDENx -- Phase density of phase 'x' (segment conditions)
  - SDENM -- Fluid mixture density without flowing fraction exponents
  - SMDEN -- Fluid mixture density with flowing fraction exponents
2023-07-07 16:26:58 +02:00
Bård Skaflestad
6dae660cc9 Add Summary Output for Block Level Phase Densities
In particular, recognize block level summary vectors

    BxDEN, BDENx

for the phase densities of phase 'x' (O, G, W).
2023-07-07 16:26:58 +02:00
Bård Skaflestad
3e6a5cfc2d Push Block Level Unit Conversion to Summary Output
The 'BLOCK_VARIABLES' test was doing manual unit conversion and
there's no need for that.
2023-07-07 13:56:18 +02:00
Bård Skaflestad
2f164e84b2
Merge pull request #3596 from bska/fix-rseg-item-description
Revise Description of Item 7 in RSEG
2023-07-06 12:58:23 +02:00
Bård Skaflestad
6590ea2e78
Merge pull request #3595 from blattms/warn-operations-empty-regions
Issue warning for operations on empty regions.
2023-07-06 12:58:02 +02:00
Bård Skaflestad
8fc1389de0 Revise Description of Item 7 in RSEG
This item is the depth of the node segment, not the depth change
relative to the top segment.  Rename the associate variables
accordingly.
2023-07-06 12:02:45 +02:00
Markus Blatt
267e1b07bd Issue warning for operations on empty regions.
If the user did not set MULTNUM but has e.g.
```
MULTIREG
PORV    0.8     2 /
PORV    0.8     7 /
PORV    0.8   3 /
PORV    0.8   8 /
PORV    1   4 /
PORV    1   9 /
/
```

he at least gets a warning like
```
Warning: MULTNUM region 2 has no active cells when processing operation MULTIREG on keyword PORV.
Please check whether this is on purpose or you missed defining the region properly.
In file /path/to/model/porvmultsny.inc, line 1
```

This should aid him with detecting possible errors.
2023-07-05 17:32:36 +02:00
Markus Blatt
98fe4e4d29
Merge pull request #3524 from verveerpj/fix-table-error-msgs
Fix table-related error messages
2023-07-05 15:12:59 +02:00
Bård Skaflestad
13e4394b45
Merge pull request #3593 from bska/smry-phase-densities
Add Transport Protocol for Segment Level Phase Densities
2023-07-05 12:10:29 +02:00
Bård Skaflestad
e7226d4ca8 Add Transport Protocol for Segment Level Phase Densities
This commit adds the requisite backing storage and parser support
for capturing and transporting simulator-level calculation of phase
and mixture density value for purpose of summary file output.  To
this end, make 'SegmentQuantity' into a template on a set of defined
items and make SegmentPhaseQuantity into a specialisation of this
template.  Add a new specialisation, SegmentPhaseDensity, which
holds phase densities (oil, gas, water), and fluid mixture densities
with and without flowing fraction exponents.

These will be used to transport the values needed to output segment
level summary vectors

    SDENx -- Phase density of phase 'x' (O, G, W)
    SDENM -- Fluid mixture density without flowing fraction exponents
    SMDEN -- Fluid mixture density with flowing fraction exponents
2023-07-05 11:31:10 +02:00
Bård Skaflestad
784faa2b05
Merge pull request #3592 from bska/adjust-smry-whitespace
Group Block Level Summary Vectors by Phase
2023-07-05 11:23:49 +02:00
Bård Skaflestad
5f3e6f9084 Group Block Level Summary Vectors by Phase
Mostly to aid future maintenance.  While here, also re-indent the
other unit tables and add a type alias (UnitTable) to avoid spelling
out the 'unordered_map<>' type repeatedly.
2023-07-05 10:57:53 +02:00
Markus Blatt
c2cc368f42
Merge pull request #3591 from bska/more-segment-smry-vecs
Add More Segment Level Summary Vectors
2023-07-05 10:24:19 +02:00
Bård Skaflestad
5b6f064804 Add More Segment Level Summary Vectors
In particular, add support for

   SxFT  - Cumulative flow of phase 'x'
   SxFV  - Free flow velocity of phase 'x'
   SxHF  - Free flow holdup fraction of phase 'x'
   SxVIS - Phase viscosity of phase 'x'

The last three of these were added to the RFT file in 802a401a8,
but are also useful in the summary output file.  In the interest of
avoiding duplicate logic, refactor the existing segment-related
quantity calculation/extraction in terms of callbacks.
2023-06-30 16:42:53 +02:00
Bård Skaflestad
4fb2a3557b
Merge pull request #3313 from GitPaean/support_cake_filteration
A simple cake model to simulate formation damage due to suspended solids in injection water
2023-06-30 15:51:41 +02:00
Kai Bao
508c123eed addressing the reviewing comments for PR #3313 2023-06-30 11:35:25 +02:00
Svenn Tveit
f3e2960a5c Correct tolerance 2023-06-29 14:28:35 +02:00
Svenn Tveit
945642724e Tests output more useful error messages 2023-06-29 14:23:39 +02:00
Kai Bao
39608fa1ed re-organizing the filter cake related
to address the reviewing comments and improve the code.
2023-06-29 11:42:26 +02:00
Svenn Tveit
5e3a8b0ae1 Get rid of pow() 2023-06-29 11:06:02 +02:00
Tor Harald Sandve
d07d8675ae
Merge pull request #3574 from totto82/fixSalinity
BUGFIX: Use salinity values when salt concentration (BRINE) is not considered
2023-06-29 09:00:28 +02:00
Bård Skaflestad
b76b22b697
Merge pull request #3583 from blattms/file-trailing-ws-error
trim trailing and leading whitespace of paths in INCLUDE
2023-06-28 21:36:33 +02:00
Bård Skaflestad
17f740dab1
Merge pull request #3588 from atgeirr/silence-vsprintf-warning
Fix warning from external code.
2023-06-28 21:34:40 +02:00
Bård Skaflestad
7e31d9605f
Merge pull request #3589 from blattms/file-line-unknown-keyword
Provide file and line for errors because of unknown keywords.
2023-06-28 21:26:08 +02:00
Svenn Tveit
cc34178e59 Adjust unit test to reverted co2tables.inc.
Have to correct for different reference state between test data and co2tables.inc. Took out some enthalpy data due to one data point giving unreasonably large error (probably related to reference state difference).
2023-06-28 19:41:14 +02:00
Markus Blatt
b5f7d9e3f8 Provide file and line for errors because of unknown keywords.
```
Error: Unknown keyword: KEY6

Error: Unrecoverable errors while loading input: Problem with keyword
In <memory string> line 0
Unknown keyword: KEY6
```
does not tell the user where his/her error is.

This is now changed to
```
Error: Unknown keyword: KEY6

Error: Unrecoverable errors while loading input: Problem with keyword NE6
In /path/to/include/grid/file.inc line 7
Unknown keyword: KEY6
```
which gives the user a greater chance of finding out what is wrong.
2023-06-28 18:59:25 +02:00
Svenn Tveit
605115c628 Revert "Expanded T-p domain and included more data points"
This reverts commit d891255ba4.
2023-06-28 18:51:19 +02:00
Svenn Tveit
b469a14598 Corrected path to reference data 2023-06-28 18:07:49 +02:00
Markus Blatt
2fa51c6edb Also cater for trailing/leading ws for GDFILE/IMPORT keywords.
By trimming the strings.
2023-06-28 16:48:55 +02:00
Tor Harald Sandve
adfe24dbcd
Merge pull request #3482 from totto82/bc_schedule
BC in Schedule
2023-06-28 16:27:09 +02:00
Atgeirr Flø Rasmussen
0b930bc45c Fix warning from external code. 2023-06-28 16:10:13 +02:00
Bård Skaflestad
c9b1f01c23
Merge pull request #3586 from bska/fix-msim-report-step
Fix MSIM UDQ Configuration Lookup
2023-06-28 15:24:52 +02:00
Bård Skaflestad
928f37735c
Merge pull request #3582 from vkip/num_pressure_points_equil_default
Changing default value for number of pressure points used in equilibration
2023-06-28 14:53:57 +02:00
Tor Harald Sandve
bf9ca70ff6 Cleanup based on review 2023-06-28 14:07:33 +02:00
Tor Harald Sandve
4b36741f33 Rename BC to BCPROP and add error message for BC 2023-06-28 14:07:33 +02:00
Tor Harald Sandve
c7a7e80698 splitt BC into BCCON in grid section and BC in Schedule 2023-06-28 14:07:33 +02:00
Tor Harald Sandve
ff58ca550f Support BC in Schedule section 2023-06-28 14:07:33 +02:00
Vegard Kippe
0cb4d90494 Changing default value for number of pressure points used in equilibration to be consistent with current implementation. 2023-06-28 14:01:14 +02:00
Bård Skaflestad
ec87ad1f61 Fix MSIM UDQ Configuration Lookup
The MSIM 'report_step' is a one-based index so we must subtract
one before looking up the pertinent Schedule information.
2023-06-28 13:42:16 +02:00
Bård Skaflestad
d6ed5f754c
Merge pull request #3581 from vkip/constexpr_parseritem_defaults
Let int and float parser items have constexpr default values
2023-06-28 13:35:59 +02:00
hnil
3e7f74d384 -- fixes for twophase relperm 2023-06-28 13:09:04 +02:00
Svenn Tveit
0b4f420aaa Added reference data files to cmake list 2023-06-28 10:05:32 +02:00
Svenn Tveit
c1fef5c52a Added unittests for CO2, H2O, brine and H2.
Reference data is located in JSON files.
Some code is commented out due to insufficient reference data, or in the case of CO2, interpolation around saturation curve does not capture the liquid/vapor jump to a reasonable tolerance.
2023-06-28 10:05:32 +02:00
Svenn Tveit
d891255ba4 Expanded T-p domain and included more data points 2023-06-28 10:05:32 +02:00
Svenn Tveit
e7faf82096 Improved enthalpy approximation.
Polynomial fit using Coolprop data.
2023-06-28 10:05:32 +02:00
Vegard Kippe
68173b49a4 Let int and float parser items have constexpr default values 2023-06-27 20:13:04 +02:00
Kai Bao
aafafba4b1 draft version of handling keyword WINJCLN 2023-06-27 15:50:54 +02:00
Kai Bao
781f7f2a96 revising FilterCake class for downstream use 2023-06-27 15:50:54 +02:00
Kai Bao
a335542424 adding accessing function for FilterCake for Connection 2023-06-27 15:50:54 +02:00
Kai Bao
e2a70bfabd fixing the Well and Connection comparison operator
taking into consideration of the parameters related to filter cake
2023-06-27 15:50:54 +02:00
Kai Bao
3bc451ad94 parsing WINJFCNC 2023-06-27 15:50:54 +02:00
Kai Bao
5e1b398550 parsing the keywor WINJDAM 2023-06-27 15:50:54 +02:00
Kai Bao
e94c1aa386 WIP in supporting the keyword WINJDAM 2023-06-27 15:50:54 +02:00
Kai Bao
5710164a7b adding keywords WINJDAM WINJCLN WINJFCNC to keyword_list 2023-06-27 15:50:53 +02:00
Kai Bao
7fc41b99aa adding the definition of keyword WINJCLN 2023-06-27 15:50:53 +02:00
Kai Bao
951e747f32 adding keyword definition for keyword WINJFCNC 2023-06-27 15:50:53 +02:00
Kai Bao
4096468ab3 adding keyword definition WINJDAM 2023-06-27 15:50:53 +02:00
Markus Blatt
4129543457 Trim trailing and leading whitespace from path in INCLUDE directive.
Just like the other simulator. This prevents hard to find input errors
of useers.
2023-06-27 15:34:27 +02:00
Markus Blatt
340b3dc450 Quote file path if file not found to make trailing ws apparent.
For an include directive with a path with trailing whitespace, e.g.

```
INCLUDE
  '/home/model/../include/file_trailing_ws.ext ' /
```
the current error message
```
Error: No such file: /home/model/../include/file_trailing_ws.ext
```
is changed to
```
File '/home/model/../include/file_trailing_ws.ext ' included via
INCLUDE directive does not exist. Note that the file name contains trailing whitespace.
```

This should at least make it easier to spot this error.

An alternative would be to trim the string, but people using quotes
should actually know what they are doing.
2023-06-27 14:25:38 +02:00
Bård Skaflestad
5709708016
Merge pull request #3559 from bska/wbp-compute-values
Reimplement WBPn Calculation Procedure
2023-06-26 15:24:23 +02:00
Bård Skaflestad
d9cfd1288a Reimplement WBPn Calculation Procedure
This commit implements the WPAVE keyword and its associate WBPn
well level report quantities.  We support all valid settings of
WPAVE and WWPAVE.  The various weighted averages are accumulated
through compensated summation of both the numerator and denominator
terms for the inner block, the direct/immediate level 1 neighbours,
and the diagonal level 2 neighbours.  We combine those contributions
to the WBP, WBP4, WBP5, and WBP9 terms when we "commit" the
contributions (Accumulator::commitContributions()), per connection
for values weighted by the connection transmissibility factor, and
per well for values weighted by pore volumes.

We distinguish OPEN from ALL connections through callback functions
in the implementation of accumulateLocalContributions() and the per
connection weighting terms are provided as another set of callback
functions depending on the value of the inner block weighting factor
F1.

Depth correction (NONE, WELL, or RES) is affected through a separate
set of callback functions used in the implementation of
'connectionPressureOffset'.

We discover source locations in a two-step process.  At WBPn
calculation construction time, we exclude only those cells that are
outside the model's dimensions.  The user is then expected to call
member function pruneInactiveWBPCells(), typically at the
CalculatorCollection level, at a later time in order to prune
inactive cells.  This two-step split is necessary because we do not
have a complete global view of the model's active cells in a
parallel run.  It is very possible that the WBPn calculation on one
rank will require source values from another rank and that begets
this extra caution.

The user must call inferBlockAveragePressures() to compute the WBPn
values.  Once completed, the result values may be extracted by
calling member function averagePressures().  We expect that the user
will provide a complete set of up-to-date source values when calling
this member function, both at the reservoir and the well connection
levels.
2023-06-22 16:46:54 +02:00
Bård Skaflestad
d06dff1a83 Add Input Value Santity Checking to WPAVE Keyword Handler
In particular, the inner block weighting factor F1 must not exceed
the value 1.0 and the CTF-vs-PV contribution weighting factor F2
must not be less than 0.0 or greater than 1.0.

Stop input parsing if either of these two conditions are violated.
2023-06-22 16:46:54 +02:00
Bård Skaflestad
c6d4a635e3
Merge pull request #3577 from GitPaean/fixing_winjmult
separating the WINJMULT for well and connections
2023-06-22 12:53:27 +02:00
Kai Bao
9572d5ecf3 addressing the reviewing comments for PR #3577 2023-06-22 11:59:45 +02:00
Arne Morten Kvarving
f8ebecd3b1
Merge pull request #3569 from bska/fix-hist-rates-sumry-output
Don't Generate History Rates for Shut/Stopped Wells
2023-06-21 14:46:11 +02:00
Bård Skaflestad
a4d2674c6d
Merge pull request #3579 from bska/wbp-reformat-pavg
Reformat PAvg Class
2023-06-21 14:36:48 +02:00
Bård Skaflestad
53f946e776 Don't Generate History Rates for Shut/Stopped Wells
The *_history() helper functions assumed that all wells would be
flowing.  This is an incorrect assumption and would lead to, e.g.,
field-level observed rates being non-zero even if all wells were
stopped/shut.

This commit adds a check for non-flowing wells, and omits flow rate
contributions in that case.
2023-06-21 13:54:47 +02:00
Bård Skaflestad
f8d9f74d91 Reformat PAvg Class
Mostly for readability.  While here, also switch to using compiled
item names instead of raw strings to access the DeckItems which
constitute the WPAVE and WWPAVE keywords.
2023-06-21 13:46:28 +02:00
Bård Skaflestad
7614a739ca
Merge pull request #3578 from akva2/extnetwork_serialization_test
ExtNetwork: add serialization test
2023-06-21 13:10:31 +02:00
Kai Bao
68e586bf7a separating the WINJMULT for well and connections
with more testing, it looks like when multiple records are entered. The
records with WREV mode and records with CIRR and CREV modes work
differently in term of overwriting the previous records. So it is
necessary to store them separately.
2023-06-21 11:38:31 +02:00
Arne Morten Kvarving
68ffa2ea1f add serialization test for Network::ExtNetwork 2023-06-21 10:48:39 +02:00
Arne Morten Kvarving
75bd0e915e ExtNetwork: use a non-default instance in serializationTestObject 2023-06-21 10:45:30 +02:00
Arne Morten Kvarving
74acf7080b implement ExtNetwork::operator== 2023-06-21 10:45:18 +02:00
Bård Skaflestad
b7617f9469
Merge pull request #3575 from bska/fix-narrowing
Don't Narrow String Literal to Bool
2023-06-16 17:09:04 +02:00
Bård Skaflestad
35117aa037 Don't Narrow String Literal to Bool
This isn't portable.
2023-06-16 15:54:18 +02:00
Bård Skaflestad
dda3effdb3
Merge pull request #3570 from svenn-t/ppcwmax
Implementation of PPCWMAX
2023-06-16 15:04:03 +02:00
Svenn Tveit
a008c303ab Removed unecessary code 2023-06-16 11:34:34 +02:00
Svenn Tveit
32692b750e Added actual values to serialization test 2023-06-16 11:33:52 +02:00
Tor Harald Sandve
7f33731d19 BUG: Use salinity values when salt concentration (BRINE) is not considered 2023-06-16 10:03:56 +02:00
Bård Skaflestad
30c7110720
Merge pull request #3542 from totto82/wagHysteresis
Wag hysteresis
2023-06-15 16:41:05 +02:00
Svenn Tveit
af3f44423b Changed from std::tuple to std::pair 2023-06-15 14:59:42 +02:00
Tor Harald Sandve
c270dc2ff3 Minor clean-up and fixes of the WAG hysteresis model 2023-06-15 12:31:27 +02:00
Svenn Tveit
89f0b2c31e Changes in docstring and removed include 2023-06-15 12:26:43 +02:00
Ove Sævareid
34a9d9c949 Some support for WAG hysteresis (material). 2023-06-15 11:22:44 +02:00
Ove Sævareid
0fc0b6f4fa Some support for WAG hysteresis (input). 2023-06-15 11:18:58 +02:00
Bård Skaflestad
fdfbecc742
Merge pull request #3572 from hnil/ecldefault
-- added function need to test solver without multiplexer
2023-06-14 16:26:44 +02:00
hnil
3b06ff2757 -- added function need to test solver without multiplexer 2023-06-14 14:37:07 +02:00
Bård Skaflestad
bca989343c
Merge pull request #3161 from GitPaean/support_winjmult
adding the parsing support for keyword WINJMULT
2023-06-14 14:32:00 +02:00
Bård Skaflestad
b7e4f28b95
Merge pull request #3571 from bska/fix-warnings
Fix A Couple of Compiler and Static Code Analysis Warnings
2023-06-14 14:25:28 +02:00
Bård Skaflestad
e6590f2169 Fix A Couple of Compiler and Static Code Analysis Warnings
In particular

  * Tag a single argument constructor as 'explicit',
  * Remove an unused private function
  * Fix mismatched tags (struct vs. class) in forward declaration
  * Return 'false' in an impossible updateHyst() case

While here, also use a real UnitSystem object instead of creating
a METRIC system just to infer unit strings.
2023-06-14 13:31:41 +02:00
Bård Skaflestad
f46b90f5db
Merge pull request #3568 from bska/fix-udq-assign-well-level
Don't Run ASSIGN on Every Report Step
2023-06-14 11:59:22 +02:00
Kai Bao
3b731a3da2 return true for handleWINJMULT() when the mode is changed 2023-06-14 11:56:49 +02:00
Bård Skaflestad
250c8b7a1c
Merge pull request #3458 from hnil/changed_hyst
Changed hyst
2023-06-14 10:34:34 +02:00
Bård Skaflestad
4c2617f537 Don't Run ASSIGN on Every Report Step
Commit 5a060910a distinguished ASSIGN from DEFINE at the field
level, but did not make the same distinction at the well or group
levels.  Passing 'report_step' instead of assign.report_step() as an
argument to UDQState::assign() means we'd be running every ASSIGN
operation on every report step which would reset the state.  That's
a bug if the model defines some sort of cumulative UDQ at the well
or group levels.
2023-06-14 09:46:10 +02:00
Bård Skaflestad
c33b94ca3a Default UDQ Assignments to All Wells in Model
An assignment of the form

    ASSIGN WUPPERTAL 354.572 /

should create a UDQ set of size equal to the number of wells in
the model, not just the wells already flowing-especially if the
assignment happens on the very first report step before any wells
are flowing.
2023-06-14 09:46:10 +02:00
hnil
12da4dbe02 --changed for bska comments. All tests ok locally 2023-06-14 09:31:20 +02:00
Svenn Tveit
de814bc577 Apply PPCWMAX in SWATINIT calculations.
Note that re-calculation of initial water saturation (after PPCWMAX is applied) is currently done in opm-simulators.
2023-06-14 08:33:51 +02:00
Svenn Tveit
5e6dfc1f1a Add Ppcwmax to serialization test 2023-06-14 08:33:51 +02:00
Svenn Tveit
ccc010c8d3 Internalize PPCWMAX as vector of structs 2023-06-14 08:33:51 +02:00
Markus Blatt
90497b745b
Merge pull request #3556 from akva2/multflt_grid_and_edit
fixed: properly combine MULTFLT from GRID and EDIT
2023-06-14 07:16:02 +02:00
Bård Skaflestad
809c9be8dd
Merge pull request #3566 from GitPaean/throw_multiple_segment_abs
we do not support entering multiple segments with ABS type in keyword WELSEGS.
2023-06-13 17:02:34 +02:00
Kai Bao
edd762c084 cleaning up the implementation related to WINJMULT 2023-06-13 15:10:56 +02:00
hnil
b50cef1af2 added fix based on review 2023-06-13 14:39:42 +02:00
hnil
f8d652f758 - fixed missing return after adding change 2023-06-13 14:39:42 +02:00
hnil
d0422bfc74 -- added bool return value of hysteresis update.
-- this make it possible to localy update intensive quanities if something changed.
2023-06-13 14:39:42 +02:00
Peter Verveer
fb4514aa88 Fix table related error messages 2023-06-13 11:21:59 +02:00
Kai Bao
30f0a358f1 we do not support entering multiple segments with ABS type
in keyword WELSEGS.

Before we fix it, we throw here.
2023-06-13 10:44:09 +02:00
Kai Bao
759f0b8449 revising the function handleWINJMULT a little bit 2023-06-12 10:42:15 +02:00
Kai Bao
a8a10bb81f InjMultMode is assigned to per well
not per connection anymore based on new finding in the reference result.
2023-06-12 10:42:15 +02:00
Kai Bao
2f8f019226 updating the WINJMULT keyword with correct dimension 2023-06-12 10:42:15 +02:00
Kai Bao
da17ef3174 adding the parsing support for keyword WINJMULT 2023-06-12 10:42:15 +02:00
Bård Skaflestad
dd34926062
Merge pull request #3558 from bska/wbp-source-values
Add Container for Dynamic WBPn Source Values
2023-06-10 11:36:19 +02:00
Bård Skaflestad
c7d6604d98 Add Container for Dynamic WBPn Source Values
This commit adds a new container class,

    PAvgDynamicSourceData

which wraps a single vector<double> which in turn backs source data
items for

    - pressure values
    - fluid mixture densities
    - dynamic pore-volumes

at a collection of source locations-active cells or well reservoir
connections.  We provide read-only and read-write accessors to the
underlying data items for a single source location through subscript
operator (read only) and named assignment (set(), read-write) member
functions.  The latter is available only when the underlying range
of data values is mutable (e.g., SourceDataSpan<double>) as opposed
to immutable (e.g., SourceDataSpan<const double>).
2023-06-09 15:42:46 +02:00
Bård Skaflestad
46415cebed
Merge pull request #3557 from bska/wbp-comm-api-change
Prepare for Revised Implementation of WBPn
2023-06-09 15:13:35 +02:00
Bård Skaflestad
89bc182876 Prepare for Revised Implementation of WBPn
This initial commit changes the Summary class's API for consuming
block-averaged well level pressure values (summary keywords WBPn).
The former approach was intended to consume a collection of source
values--pressures, densities, and pore-volumes--and then to defer
calculation of the WBPn summary vectors to the Summary class.

This commit introduces a 'WellBlockAvgPress' container class which
holds precomputed WBPn results and the intention is to move the
calculation to the simulator side for greater parallelism.
2023-06-09 13:29:10 +02:00
Tor Harald Sandve
ba0845c5f3
Merge pull request #3526 from plgbrts/well-control
Allow NONE for item 7 in GCONPROD
2023-06-09 10:50:57 +02:00
Arne Morten Kvarving
78c527fb53
Merge pull request #3567 from akva2/embedded_params
fixed: avoid unused parameters when built without embedded python
2023-06-08 12:55:50 +02:00
Arne Morten Kvarving
e4b609c294 fixed: avoid unused parameters when built without embedded python 2023-06-08 12:01:27 +02:00
Arne Morten Kvarving
9cb247058e
Merge pull request #3564 from bska/fix-embedded-python-test
Fix Embedded Python Test
2023-06-08 11:47:18 +02:00
Bård Skaflestad
9cf61a57b4
Merge pull request #3565 from totto82/addFPRP
add missing FPRP and RPRP
2023-06-08 11:29:16 +02:00
Arne Morten Kvarving
ca6cab5c54
Merge pull request #3563 from bska/omit-rsm-version-information
Omit OPM Version Information in RSM File
2023-06-08 10:42:32 +02:00
Tor Harald Sandve
0221ac9932 add missing FPRP and RPRP 2023-06-08 10:23:53 +02:00
Arne Morten Kvarving
b7a888fcfa fixed: properly combine MULTFLT from GRID and EDIT 2023-06-08 10:12:41 +02:00
Bård Skaflestad
1bde14655a Omit OPM Version Information in RSM File
The version information leads to long install times and doesn't
really provide any benefit to the user.
2023-06-08 10:09:23 +02:00
Bård Skaflestad
3e08b187ff Don't Return Constant Objects
There's no longer any reason to return 'const string', since that
inhibits move semantics.  While here, also reorder the include
statements and split a few long lines.
2023-06-08 10:08:22 +02:00
Bård Skaflestad
ff4db11528 Handle Case of Nonexistent NumPy Module
The NumPy module might not be available on the host system.  In that
situation the PYINPUT_BASIC unit test would fail with a segmentation
violation.  Guard against this problem by catching ImportError and
checking if the result deck has 'DX' instead of blindly asserting
that 'DX' exists.
2023-06-08 09:24:27 +02:00
Bård Skaflestad
222e6133b1 Catch Up to Changed Semantics of Certain Member Functions
In particular Python::exec() now returns 'false' instead of throwing
an exception if we don't have 'EMBEDDED_PYTHON'.  Similarly for the
Python::Python constructor when called with an 'Enable::ON' argument.
2023-06-08 09:23:22 +02:00
Bård Skaflestad
45e4762302 Emit Useful Diagnostic Message if Test Fails
While here, also mark a few objects 'const' and reorder the headers.
2023-06-08 09:19:32 +02:00
Bård Skaflestad
7692a5401d
Merge pull request #3561 from hnil/no_python_onemore
Remove throw in normal runs
2023-06-07 11:29:57 +02:00
hnil
dea519c89a -- add config.h 2023-06-07 10:35:13 +02:00
Markus Blatt
cd1831be94
Merge pull request #3509 from blattms/install-co2brinepvt
Also install co2brinepvt as we install the manpage.
2023-06-07 10:29:03 +02:00
hnil
47f6b6ffb2 -- hopefully removed the python throw 2023-06-07 10:24:06 +02:00
Tor Harald Sandve
5a08a17978
Merge pull request #3504 from hakonhagland/wvfpdp
Add support for WVFPDP
2023-06-05 09:13:49 +02:00
Håkon Hægland
5a99e005fb Fixed naming convention 2023-06-02 09:24:59 +02:00
Håkon Hægland
2f260fe90a Fixed SWell indices 2023-06-02 09:24:59 +02:00
Håkon Hægland
0d38acebaf Set correct default value 2023-06-02 09:24:59 +02:00
Håkon Hægland
5463420a85 Add support for WVFPDP 2023-06-02 09:24:59 +02:00
Bård Skaflestad
d036f6aaaa
Merge pull request #3553 from akva2/pvt_set_vappars
added: setters for the vappars in pvt classes
2023-06-01 19:03:48 +02:00
Bård Skaflestad
e30fce2c9f
Merge pull request #3552 from akva2/janitoring
Some janitoring
2023-06-01 18:59:35 +02:00
Arne Morten Kvarving
39006ecd71 added: setters for the vappars in pvt classes 2023-06-01 11:03:20 +02:00
Arne Morten Kvarving
6700e08c84 avoid dead store 2023-06-01 09:38:45 +02:00
Arne Morten Kvarving
f64f587055 mark variable maybe_unused to avoid dead store warnings 2023-06-01 09:38:45 +02:00
Arne Morten Kvarving
237b63e674 reduce scope of variables to avoid dead store warnings 2023-06-01 09:38:45 +02:00
Arne Morten Kvarving
5ab4c3dfa0 initialize variables 2023-06-01 09:38:45 +02:00
Arne Morten Kvarving
19f103db9b check pointer to avoid nullptr dereference sca warning
the assert above is a noop under normal conditions
2023-06-01 09:38:45 +02:00
Arne Morten Kvarving
1492182866 make variable constexpr to avoid dead store warning 2023-06-01 09:38:45 +02:00
Arne Morten Kvarving
ba4d3271c4 remove unnecessary initialization 2023-06-01 09:35:10 +02:00
Bård Skaflestad
03d31409e5
Merge pull request #3550 from akva2/vappars_solution_section
fixed: apply VAPPARS from SOLUTION section
2023-05-31 17:12:47 +02:00
Arne Morten Kvarving
89ce51af81 added: unit test for VAPPARS in SOLUTION section
also revise existing test using SCHEDULE to check
that level 0 is UNDEF
2023-05-31 15:49:23 +02:00
Arne Morten Kvarving
51aecfb2de fixed: apply VAPPARS from SOLUTION section 2023-05-31 15:13:55 +02:00
Bård Skaflestad
24ce7e05a7
Merge pull request #3549 from blattms/fix-string-preplace-empty-dunecommon_CXXFLGAS
[cmake] Make sure that string(REPLACE ...) always has 4 arguments.
2023-05-31 12:51:07 +02:00
Bård Skaflestad
682e6d8763
Merge pull request #3541 from akva2/test_spline_janitoring
test_spline: convert to boost::test
2023-05-30 14:21:47 +02:00
Bård Skaflestad
d61c9c7b99
Merge pull request #3501 from bska/check-wsegdims-consistency
Test Dynamic Segment Dimensions Against WSEGDIMS Limits
2023-05-30 12:39:55 +02:00
Bård Skaflestad
5a79e0f8fb Test Dynamic Segment Dimensions Against WSEGDIMS Limits
In particular, check that

  1. Number of MS wells <= WSEGDIMS(1)
  2. Number of segments per well <= WSEGDIMS(2)
  3. Number of branches per well <= WSEGDIMS(3)

for all report steps in the simulation run.

Example diagnostic message of a case that violates limits 2 and 3:

Error: Problem with keyword WSEGDIMS
  In CASE.DATA line 60
  The case has a multi-segmented well with 246 well segments, but at most 200 are allowed in WSEGDIMS.
  Please increase item 2 of WSEGDIMS to at least 246

Error: Problem with keyword WSEGDIMS
  In CASE.DATA line 60
  The case has a multi-segmented well with 105 lateral branches, but at most 5 are allowed in WSEGDIMS.
  Please increase item 3 of WSEGDIMS to at least 105
2023-05-30 11:47:50 +02:00
Bård Skaflestad
0bc74799ca
Merge pull request #3465 from plgbrts/well-specs-new
adding defaults to json files
2023-05-30 11:43:53 +02:00
Bård Skaflestad
b4ccb9df69
Merge pull request #3548 from akva2/test_ncpflash_janitoring
test_ncpflash: convert to boost::test
2023-05-30 11:09:13 +02:00
Paul
4d5b4aba2b changed return type to reference-to-const 2023-05-30 10:49:52 +02:00
Markus Blatt
083451817d [cmake] Make sure that string(REPACE always has 4 arguments.
This was missing proper quoting for the case that dune-common_CXX_FLAGS
is empty.

Error I got was:
```
-- Version 2.10.0 of dune-common from /home/mblatt/src/dune/opm-master/dune-common/opm-parallel
CMake Error at CMakeLists.txt:369 (string):
  string sub-command REPLACE requires at least four arguments.

-- Configuring incomplete, errors occurred!
```
2023-05-30 10:40:55 +02:00
Arne Morten Kvarving
edeb7679b0 test_ncpflash: convert to boost::test 2023-05-30 10:31:56 +02:00
Tor Harald Sandve
a456c36a31
Merge pull request #3513 from goncalvesmachadoc/gasvisct
Implement GASVISCT for black-oil [Bug fix]
2023-05-30 08:37:46 +02:00
Bård Skaflestad
86a2f856d3
Merge pull request #3547 from akva2/test_fluidmatrixinteractions_janitoring
test_fluidmatrixinteractions: convert to boost::test
2023-05-30 08:36:31 +02:00
Bård Skaflestad
6d60158022
Merge pull request #3546 from akva2/test_eclmateriallawmanager_janitoring
test_eclmateriallawmanager: convert to boost::test
2023-05-30 08:34:51 +02:00
Arne Morten Kvarving
59ce72d04f test_fluidmatrixinteractions: convert to boost::test 2023-05-30 07:23:55 +02:00
Arne Morten Kvarving
98a9367b19 test_eclmateriallawmanager: convert to boost::test 2023-05-30 07:08:56 +02:00
goncalvesmachadoc
b30f297053 add comments on reference values 2023-05-29 13:20:53 +02:00
Bård Skaflestad
4146ce75f3
Merge pull request #3545 from akva2/test_eclblackoilpvt_janitoring
test_eclblackoilpvt: convert to boost::test
2023-05-26 16:25:31 +02:00
Bård Skaflestad
4e1333deda
Merge pull request #3544 from akva2/test_eclblackoilfluidsystem_janitoring
test_eclblackoilfluidsystem: convert to boost::test
2023-05-26 16:10:00 +02:00
Bård Skaflestad
b5f9dd4312
Merge pull request #3543 from akva2/test_blackoilfluidstate_janitoring
test_blackoilfluidstate: convert to boost::test
2023-05-26 16:05:09 +02:00
Arne Morten Kvarving
4eac0243ae test_eclblackoilpvt: convert to boost::test 2023-05-26 15:51:41 +02:00
Arne Morten Kvarving
f424e8ec6e test_eclblackoilfluidsystem: convert to boost::test 2023-05-26 15:28:30 +02:00
Arne Morten Kvarving
492823d8dd test_blackoilfluidstate: convert to boost::test 2023-05-26 15:12:47 +02:00
Arne Morten Kvarving
eb84d95263 test_spline: convert to boost::test 2023-05-26 13:48:43 +02:00
Bård Skaflestad
857f9e39e4
Merge pull request #3540 from akva2/test_threecomponents_ptflash_janitoring
test_threecomponents_ptflash: convert to boost::test
2023-05-26 12:57:43 +02:00
Bård Skaflestad
823788a7c8
Merge pull request #3539 from akva2/test_2dtables_janitoring
test_2dtables: convert to boost::test
2023-05-26 12:57:13 +02:00
Bård Skaflestad
da73e9898e
Merge pull request #3538 from akva2/test_immiscibleflash_janitoring
test_immiscibleflash: convert to boost::test
2023-05-26 12:56:43 +02:00
Arne Morten Kvarving
99035c4400 test_co2brine_ptflash: use stream 2023-05-26 12:37:06 +02:00
Arne Morten Kvarving
949d14d7c7 test_threecomponents_ptflash: convert to boost::test 2023-05-26 12:35:56 +02:00
Arne Morten Kvarving
e650889965 test_2dtables: convert to boost::test 2023-05-26 12:21:53 +02:00
Arne Morten Kvarving
4abfc8115e test_immiscibleflash: convert to boost::test 2023-05-26 12:20:35 +02:00
Bård Skaflestad
9e10a598f1
Merge pull request #3537 from akva2/test_co2brine_ptflash_janitoring
test_co2brine_ptflash: convert to boost::test
2023-05-25 23:25:39 +02:00
Bård Skaflestad
bac38961b7
Merge pull request #3534 from GitPaean/tesiting_summary_ouptut
[testing] update summary quantities even there is no wells associated with it
2023-05-25 23:24:59 +02:00
Arne Morten Kvarving
4bd20c6364 test_co2brine_ptflash: convert to boost::test 2023-05-25 22:53:25 +02:00
Bård Skaflestad
51f21f86bd
Merge pull request #3535 from akva2/test_tabulation_janitoring
test_tabulation: Some janitoring
2023-05-25 22:23:40 +02:00
Bård Skaflestad
621dcad31d
Merge pull request #3533 from akva2/test_fluidsystems_janitoring
test_fluidsystems: Some janitoring
2023-05-25 22:22:42 +02:00
Bård Skaflestad
80bdd0f999
Merge pull request #3532 from akva2/test_co2brinepvt_janitoring
test_co2brinepvt: Some janitoring
2023-05-25 22:21:30 +02:00
Bård Skaflestad
6c053c457a
Merge pull request #3536 from akva2/test_components_janitoring
test_components: Some janitoring
2023-05-25 22:16:11 +02:00
Arne Morten Kvarving
edefd93f38 test_components: convert to boost::test 2023-05-25 21:49:07 +02:00
Arne Morten Kvarving
180f34dea7 checkComponent: improve output
as this is called multiple times for a component
we get duplicate output. improve by also including the
Evaluation template parameters in the output.
2023-05-25 21:49:07 +02:00
Arne Morten Kvarving
0baa0f441a test_tabulation: convert to boost::test 2023-05-25 21:15:38 +02:00
Arne Morten Kvarving
860bc2e7f6 test_tabulation: adjust tolerances so there are no failed comparisons 2023-05-25 21:13:04 +02:00
Markus Blatt
69aaf44fd2
Merge pull request #3531 from vkip/compare_ecl_sign_deviation
Calculate deviation such that different signs are accounted for.
2023-05-25 12:17:15 +02:00
Kai Bao
b16f2ed8be update summary quantities even there is no wells associated with it
then it should get a zero. otherwise, the old values will be used.
2023-05-25 09:10:02 +02:00
Arne Morten Kvarving
174e19c35d test_fluidsystems: convert to Boost::Test 2023-05-24 22:04:39 +02:00
Arne Morten Kvarving
3e4146030e checkFluidSystem: improve output
as this is called multiple times for a fluidsystem
we get duplicate output. improve by also including the
other template parameters in the output.
2023-05-24 22:04:39 +02:00
Arne Morten Kvarving
91d5db381a fixed: avoid dead stores in test_fluidsystems 2023-05-24 22:04:39 +02:00
Arne Morten Kvarving
89b1a95a2d test_co2brinepvt: convert to Boost::Test 2023-05-23 22:31:50 +02:00
Vegard Kippe
22b5d9a568 Calculate deviation such that different signs are accounted for. 2023-05-23 22:30:45 +02:00
Arne Morten Kvarving
38fb67496d fixed: avoid dead stores in test_co2brinepvt 2023-05-23 22:16:47 +02:00
Kai Bao
ca2dbd1c09
Merge pull request #3523 from totto82/foam_solvent
Add Solvent and Water as transport phase for foam model
2023-05-23 12:27:32 +02:00
Paul
7a8fb7b832 improved error message 2023-05-23 10:48:13 +02:00
Tor Harald Sandve
0514ba2e44 remove INSTANCE(11) as it is not needed 2023-05-23 09:28:22 +02:00
Tor Harald Sandve
54dbf3a9ce add solvent and water as transport fluid for foam 2023-05-23 08:52:25 +02:00
Tor Harald Sandve
ec8a76414a compile for evaluation with 11 derivatives 2023-05-23 08:52:25 +02:00
Bård Skaflestad
35264e7ab8
Merge pull request #3530 from akva2/janitoring
Some janitoring
2023-05-22 23:49:47 +02:00
Bård Skaflestad
03e8617ff7
Merge pull request #3529 from akva2/fix_ndebug_build
BrineH2Pvt: include prerequisite headers
2023-05-22 23:28:44 +02:00
Arne Morten Kvarving
553ac0a14c reduce scope of variable
avoids sca warnings
2023-05-22 23:00:30 +02:00
Arne Morten Kvarving
4572a7135f avoid some dead stores 2023-05-22 23:00:20 +02:00
Arne Morten Kvarving
32b526993d changed: mark explicit units constexpr
these constants are known at compile time.
as a bonus, this also quells warnings
emitted by infer due to it not seeing through
the implicit lambda captures
2023-05-22 22:57:14 +02:00
Arne Morten Kvarving
1c7240977c remove pointless increments 2023-05-22 22:12:18 +02:00
Arne Morten Kvarving
b68f5f1226 add arguments by const ref 2023-05-22 22:08:12 +02:00
Arne Morten Kvarving
9ba304f5cf BrineH2Pvt: include prerequisite headers
in particular the missing header broke build with -DNDEBUG
2023-05-22 22:01:54 +02:00
Arne Morten Kvarving
e6280fc80d add override qualifier to virtual methods 2023-05-22 20:53:33 +02:00
Paul
db4c2d7f38 correction of parsing item 7 of GCONPROD 2023-05-22 17:32:46 +02:00
Paul
bc4d7bcb5d fix in unit test 2023-05-22 17:29:56 +02:00
Paul
d0be00d59e fix in unit test 2023-05-22 17:27:20 +02:00
Tor Harald Sandve
005ff3e982
Merge pull request #3445 from svenn-t/h2store
Hydrogen-brine simulations - H2STORE
2023-05-22 11:23:48 +02:00
Bård Skaflestad
c000ad101a
Merge pull request #3517 from totto82/outputhyst
Add method to get trapped saturation for output
2023-05-19 09:56:36 +02:00
Bård Skaflestad
82226cc0b9
Merge pull request #3527 from akva2/explicit_ctors
mark constructors explicit
2023-05-16 12:06:54 +02:00
Arne Morten Kvarving
6553e8d0b7 mark constructors explicit 2023-05-16 10:50:01 +02:00
Bård Skaflestad
4308305421
Merge pull request #3433 from totto82/brine_co2store
Combine brine + co2store
2023-05-16 10:25:32 +02:00
Arne Morten Kvarving
cb394ed19c
Merge pull request #3525 from akva2/fix_cvfVector4_Zero
fixed: do not compare index 2 twice
2023-05-15 13:43:32 +02:00
Arne Morten Kvarving
a428d09ad3 fixed: do not compare index 2 twice 2023-05-15 12:28:07 +02:00
Arne Morten Kvarving
3ae5fa9f80
Merge pull request #3503 from totto82/default_ehystr
Use default values for EHYSTR if not present but Hysteresis is activated by HYST in SATOPTS
2023-05-15 08:48:32 +02:00
Paul
05d59a14f4 add throw in case a well has a non-increasing MD column 2023-05-12 16:14:58 +02:00
Bård Skaflestad
196807d023
Merge pull request #3522 from vkip/tuning_only_update_when_set
Changing TUNING semantics to 'only change when specified'.
2023-05-12 14:22:35 +02:00
Vegard Kippe
899a1176c2 Changing TUNING semantics to 'only change when specified'. No impact on next time step needs to be handled separately. 2023-05-12 13:02:22 +02:00
Arne Morten Kvarving
3702d81011
Merge pull request #3520 from akva2/fix_pypi_static_boost
fixed: build pypi packages using static boost libs
2023-05-12 09:18:56 +02:00
Tor Harald Sandve
1aff5fc604 add test that compares Brine and BrineDynamic 2023-05-12 09:07:55 +02:00
Arne Morten Kvarving
60d79a170e fixed: build pypi packages using static boost libs 2023-05-12 08:39:06 +02:00
Bård Skaflestad
6895568a21
Merge pull request #3507 from akva2/fix_dyneval_format
fixed: handle dynamically sized evaluations in {fmt} formatter
2023-05-11 21:27:32 +02:00
Bård Skaflestad
910cd4cf41
Merge pull request #3516 from goncalvesmachadoc/keywordsummary
Parse compositional summary keywords
2023-05-11 21:18:30 +02:00
Bård Skaflestad
45017090f8
Merge pull request #3518 from totto82/extendRstconfig
Add supported mnemonic to list
2023-05-11 21:08:57 +02:00
Markus Blatt
5657a3109c
Merge pull request #3289 from akva2/thermal_enums_to_class
Convert thermal enums to enum class
2023-05-11 16:58:34 +02:00
Tor Harald Sandve
09b69ae644 Add supported mnemonic to list to avoid warning 2023-05-11 12:00:10 +02:00
Arne Morten Kvarving
d599c6874d EclThermalConductionApproach: convert to enum class 2023-05-11 08:46:25 +02:00
Arne Morten Kvarving
7d38661810 EclSolidEnergyApproach: convert to enum class 2023-05-11 08:40:44 +02:00
Arne Morten Kvarving
644d371026
Merge pull request #3508 from blattms/prevent-crash
Fixes segfaulting PYACTION test with pybind 2.10.3 and python 3.11
2023-05-10 15:49:21 +02:00
Tor Harald Sandve
c3a3d894df Add method to get trapped saturation for output 2023-05-10 15:25:47 +02:00
goncalvesmachadoc
c6421a5b9c parse comp summary keywords 2023-05-10 11:29:25 +02:00
Paul
d6e73df9cf allow NONE for item 7 in GCONPROD 2023-05-10 11:25:05 +02:00
Arne Morten Kvarving
9f07ec68dd
Merge pull request #3514 from akva2/jenkins_no_gpu_tests
jenkins: do not execute GPU tests
2023-05-09 12:47:03 +02:00
Arne Morten Kvarving
134c9641ff jenkins: do not execute GPU tests 2023-05-09 11:53:20 +02:00
Bård Skaflestad
7a22eb4bf3
Merge pull request #3512 from akva2/janitoring
Some janitoring
2023-05-09 11:45:27 +02:00
goncalvesmachadoc
abaa1074ff implement gasvisct 2023-05-09 10:48:25 +02:00
Arne Morten Kvarving
651693e623 avoid unused expression warning 2023-05-09 10:35:40 +02:00
Arne Morten Kvarving
cd4aec3a0b avoid out of bounds deref warning 2023-05-09 10:35:40 +02:00
Arne Morten Kvarving
1c8df58353 avoid uninitialized use warning 2023-05-09 10:35:40 +02:00
Arne Morten Kvarving
a7d77e2ed3 avoid dead store 2023-05-09 10:35:40 +02:00
Arne Morten Kvarving
ad251bb8aa quell unused variable warning
value is only used for WIN32
2023-05-09 10:35:40 +02:00
Atgeirr Flø Rasmussen
1a4a7ec147
Merge pull request #3511 from bska/std-memcmp-2
Use Memcmp From Standard Namespace
2023-05-09 09:23:14 +02:00
Bård Skaflestad
53383fd875 Sort headers in alphabetical order 2023-05-08 22:40:24 +02:00
Bård Skaflestad
b17d618c7b Use memcmp() from namespace std
Don't rely on clients using

    #include <string.h>

before including cmp.hpp .
2023-05-08 22:40:14 +02:00
Markus Blatt
b38cedf113
Merge pull request #3510 from bska/smry-check-cell-ids
Check for Invalid Cells in Block Level Summary Vectors
2023-05-08 09:31:55 +02:00
Bård Skaflestad
991ac2ca84 Check for Invalid Cells in Block Level Summary Vectors
This commit adds sanity checking to the cell references of block
level summary vectors (e.g., BPR or BGSAT).  If the summary vector
references a cell that's outside the models declared dimensions we
issue a warning and ignore that particular summary vector request.
2023-05-07 16:10:42 +02:00
Markus Blatt
dc9b9b719f Also install co2brinepvt as we install the manpage.
This must have been missed when merging opm-material with this module.
2023-05-05 17:27:53 +02:00
Markus Blatt
84aa367b19 Exception type differs beween pybind11 versions, use std::exception. 2023-05-05 16:09:58 +02:00
Markus Blatt
3e5ac55c1b Prevent segmentation faults for exceptions thrown in Python code
If for example pybind11 or python changes the type of exception thrown
and we expect a different (the old one) in our boost test, then the python
of pybind11 is left in an unusable condition and the next attempt of
running might produce hard to debug exception, This happened on Debian
bookworm (pybind 2.10.3, python 3.11) for syntax errors.
2023-05-05 16:03:17 +02:00
Arne Morten Kvarving
392d57d02a fixed: handle dynamically sized evaluations in {fmt} formatter 2023-05-05 11:01:13 +02:00
Tor Harald Sandve
4f3b67fa77 use 58.44 as molar mass of salt 2023-05-04 09:48:03 +02:00
Tor Harald Sandve
46f5558b59 Combine brine and the co2store module
This commit allows for dynamically changes in salinity in the co2 storage module

I.e. It allows for modeling salt precipition for co2 storage cases.
2023-05-03 15:09:06 +02:00
Tor Harald Sandve
8dfc9a12f5 Use default values for EHYSTR if not present but Hysteresis is activated by HYST in SATOPTS 2023-05-03 15:04:16 +02:00
Markus Blatt
7fd9a261f4
Merge pull request #3497 from bska/refactor-array-dims-checker-impl
Split WELLDIMS Error Message Formatting Out to Helper Functions
2023-05-02 22:57:59 +02:00
Bård Skaflestad
d1087f6463 Split WELLDIMS Error Message Formatting Out to Helper Functions
That way, they could become reusable for other keywords and we can
exploit the commonality between MAXWELLS and MAXGROUPS.  Moreover,
we can reduce the visual clutter of the body of each checking
function and fix some singular/plural mismatches in the diagnostic
messages.
2023-05-02 21:33:50 +02:00
Markus Blatt
e4faf011bc
Merge pull request #3498 from bska/dynamic-segdims-restart
Dimension Segment Related Restart Arrays According to Dynamic Size
2023-05-02 20:41:47 +02:00
Bård Skaflestad
9a5b3721cb Dimension Segment Related Restart Arrays According to Dynamic Size
The [IR]SEG and ILB[RS] arrays must be able to accommodate the
maximum number of segments and branches used in the run.  This
commit incorporates the dynamic maximum sizes.  If those sizes
exceed the maximum values entered in WSEGDIMS, then the resulting
restart file will not be fully compatible with other simulation
software.
2023-05-02 09:44:06 +02:00
Arne Morten Kvarving
9a8c018506
Merge pull request #3499 from akva2/fix_python_old_cmake
fixed: conditionally use Development.XXX in python find module
2023-05-02 09:25:51 +02:00
Arne Morten Kvarving
adb0701a57 fixed: conditionally use Development.XXX in python find module
the split into Development.Module and Development.Embed was is introduced in cmake 3.18
2023-05-02 08:57:39 +02:00
Bård Skaflestad
28e057af39
Merge pull request #3488 from goncalvesmachadoc/summary
Add WWGR to summary
2023-04-28 11:35:18 +02:00
Bård Skaflestad
40b2fe3c14
Merge pull request #3496 from akva2/janitoring
Some janitoring
2023-04-28 10:03:24 +02:00
Arne Morten Kvarving
d659aa567f reorder initialization lists 2023-04-28 09:43:02 +02:00
Arne Morten Kvarving
54966e074f add forward declarations for explicit template instantations
causes a clang-tidy warning
2023-04-28 09:43:02 +02:00
Arne Morten Kvarving
bf39554b12 remove unused include 2023-04-28 09:43:02 +02:00
Arne Morten Kvarving
02fc95d0f7 remove trailing semicolon in package dependency list
causes a cmake warning,
"Empty dependency in find module for dune-polygongrid (check for trailing semi-colon)"
2023-04-28 09:43:02 +02:00
Markus Blatt
6a00383cdc
Merge pull request #3494 from akva2/remove_unused_cmake_module
remove unused cmake module
2023-04-28 09:33:40 +02:00
Arne Morten Kvarving
344e920956 remove unused cmake module 2023-04-28 08:26:31 +02:00
Bård Skaflestad
28e030ff80
Merge pull request #3489 from akva2/python_fix_embed
Python: avoid searching from Development.Embed unless required
2023-04-27 13:33:54 +02:00
Arne Morten Kvarving
f76bda06e4
Merge pull request #3490 from akva2/pypi_fix_wheels
changed: build python wheels using skbuild
2023-04-27 13:29:46 +02:00
Arne Morten Kvarving
6316768bbb changed: build python wheels using skbuild
the vanilla setup-tools doesn't get the triplet correctly for some
reason. also use cmake from pip as cmake 3.16 in the image has a bug
in the python find rule
2023-04-27 13:17:19 +02:00
Arne Morten Kvarving
ba14a9e126 fixed: setuptools are no longer required to build the python bindings
only required if building packages for pypi, which is done separately
from the main buildsystem.
2023-04-27 13:03:08 +02:00
Arne Morten Kvarving
33c416b3e8 changed: only search for Development.Module if not building embedded python
the embedding headers are not available on the manylinux2014 containers
used to build the pypi packages. since this is anyways more correct
fix it this way
2023-04-27 13:03:08 +02:00
goncalvesmachadoc
21e4e9d2f1 add_wwgr 2023-04-27 12:03:25 +02:00
Paul
b171cbc3af Calculate headI/headJ from trajectory data when they are defaulted in WELSPECS 2023-04-26 17:30:53 +02:00
Markus Blatt
149fcdc88d
Merge pull request #3481 from bska/rock-with-default-record-copy
Implement Proper Record Copying Behaviour for ROCK
2023-04-26 16:58:47 +02:00
Bård Skaflestad
91bb2b47e7 Use Base Class' serializeOp() Where Possible
Classes which inherit from FlatTableWithCopy and just call the base
class implementation of 'serializeOp()' don't really need a separate
implementation of that member function.

Noticed by: [at]blattms.
2023-04-26 15:29:12 +02:00
Bård Skaflestad
5cdeb6137b Implement Proper Record Copying Behaviour for ROCK
This commit adds the expected behaviour for all-defaulted records in
ROCK, provided the all-defaulted records are not the first of the
keyword.  Similarly to, e.g. PVTW, all-defaulted records are treated as
copies of the immediately preceding record.

In other words, given

    ROCK
    -- REF. PRES   COMPRESSIBILITY
       280.000        5.6E-5 /
    /

the second record is supposed to be a copy of the first.
2023-04-26 14:29:28 +02:00
Markus Blatt
8beebd49e3
Merge pull request #3485 from atgeirr/allow-field-wells
Allow FIELD group as parent for wells
2023-04-26 14:14:33 +02:00
Markus Blatt
f16b433b53
Merge pull request #3484 from akva2/fix_udqdefine_serialize
fixed: missing serialization of tokens in UDQDefine
2023-04-26 12:54:52 +02:00
Markus Blatt
0c64097e05
Merge pull request #3479 from bska/dynamic-rock-size
Implement Full Size Protocol for ROCK Keyword
2023-04-26 12:30:51 +02:00
Atgeirr Flø Rasmussen
a055f11392 Update tests for new behaviour. 2023-04-26 12:02:34 +02:00
Atgeirr Flø Rasmussen
33843346b4 Use ParseContext system to handle well under FIELD situation.
Also downgrade from a throw to a warning.
2023-04-26 11:43:21 +02:00
Arne Morten Kvarving
6ff355a141 fixed: missing serialization of tokens in UDQDefine
this went unnoticed since there are no UDQDefines in the pre-simulation
Schedule broadcast for parallel. however it causes issues for serialized
restarts
2023-04-26 11:35:12 +02:00
Atgeirr Flø Rasmussen
6de95332be Avoid printing "Internal error" for user input problems.
This is done by:
 - splitting the catch(std::exception) in KeywordHandlers.cpp
   in two and catching std::logic_error separately,
 - not adding "Internal error" in the OpmInputError constructor
   taking std::exception.
In addition, two possible user errors related to mixing groups
and wells as children of a single group have been changed to
std::runtime_error.
2023-04-26 11:35:05 +02:00
Bård Skaflestad
ffea242f7e Reimplement Enum->String Conversion in Terms of Array
Improves lookup speed.

Suggested by: [at]blattms.
2023-04-25 19:49:18 +02:00
Bård Skaflestad
0c6aff9b68 Make Diagnostic Message Reflect Reality
We also need to include DOUBLE_SLASH_TERMINATED in the list of
alternatives.
2023-04-25 19:47:02 +02:00
Paul Egberts
26daf8e544 adding defaults to json files 2023-04-24 16:12:00 +02:00
Bård Skaflestad
599194191d Implement Full Size Protocol for ROCK Keyword
This commit adds a special case for handling the dynamic nature of
the number of records in the ROCK keyword.  In particular, if the
ROCKOPTS keyword is NOT entered before ROCK, then the number of
records is NTPVT--item 2 from TABDIMS.  Conversely, when ROCKOPTS is
entered before ROCK, the number of records in the latter depends on
the setting in item 3 of ROCKOPTS.

This interaction cannot be easily captured in our JSON-based models,
so we introduce a special size class, SPECIAL_CASE_ROCK, that only
applies to the ROCK keyword and implement the logic in a dedicated
function in 'Parser.cpp'.  Once we have determined the correct
number of records, we form a RawKeyword of type FIXED and defer
further processing to the existing handling of fixed-sized keywords.

Add a selection of unit tests to exercise the new behaviour.
2023-04-24 12:54:41 +02:00
Bård Skaflestad
2c6f08269d Prefer Data to Logic
Switch if/else chain out in favour of a map-based approach.  This
simplifies adding new enumerators.  While here, also return string
objects instead of constant string objects.
2023-04-24 12:54:41 +02:00
Bård Skaflestad
d5d17bff2f Adjust Whitespace in Preparation of Special New Size Class
In particular, split long lines where appropriate.
2023-04-24 12:54:41 +02:00
Arne Morten Kvarving
4a2cc1a64a
Merge pull request #3478 from blattms/python-development-component-is-mandatory
Always search for Development component of Python.
2023-04-24 08:46:08 +02:00
Markus Blatt
59ca5b1ba8 Always search for Development component of Python.
It is needed as we will call pybind11_add_module which calls
python3_add_library (in recent pybind11 versions). That
function is only there if the development component is searched for
and found.
2023-04-19 15:26:23 +02:00
Bård Skaflestad
b59ecf2d3b
Merge pull request #3476 from GitPaean/remove_canOpen
removing Well::canOpen() function
2023-04-14 12:27:16 +02:00
Kai Bao
909cfdcdb7 removing Well::canOpen() function
which is not needed anymore.
2023-04-14 11:17:28 +02:00
Arne Morten Kvarving
5048b4e9ec
Merge pull request #3467 from akva2/bump_2023.10
bump version to 2023.10-pre
2023-04-13 15:21:42 +02:00
Svenn Tveit
cf185442b9 Accommodate new Rvw input 2023-04-12 14:50:34 +02:00
Svenn Tveit
e8119e7adb Fix narrowing warnings 2023-04-12 14:28:02 +02:00
Svenn Tveit
620008ac06 Throw runtime error and comment out unused input.
Should fix return-type and unused-parameter warnings.
2023-04-12 14:28:02 +02:00
Svenn Tveit
c498234879 Re-added deleted code 2023-04-12 14:28:02 +02:00
Svenn Tveit
451a4d7657 Enable GAS/WATER with DISGASW in H2-brine PVT 2023-04-12 14:28:02 +02:00
Svenn Tveit
6cb0070d8d Bug fix: check for H2STORE keyword not CO2STORE 2023-04-12 14:28:02 +02:00
Svenn Tveit
fb70d31ba0 Update to restructure and latest developments. 2023-04-12 14:28:02 +02:00
Svenn Tveit
423141eb30 Re-add information lost in rebase 2023-04-12 14:28:02 +02:00
Svenn Tveit
9ae33902f1 rsSat=0 when DISGAS is disabled.
See commit: d546a8bb9c2fb4ed1697dab1878b8de3a81a26bc
2023-04-12 14:28:02 +02:00
Svenn Tveit
816300e8f2 Lookup table for density instead of calculating it
Significant speed-up since we don't need to run bisection anymore!
2023-04-12 14:28:02 +02:00
Svenn Tveit
11ff66a4bd Accommodate for Rvw implementation.
See commit: 3a25016eb09b8c87d11ca172d5170b935c675bd2
2023-04-12 14:28:01 +02:00
Svenn Tveit
9d54988d14 Diffusion coefficient for H2.
NOTE: while the diffusion in pure water is based on experimental data, diffusion in brine is dubious at best (no experimental basis).
2023-04-12 14:28:01 +02:00
Svenn Tveit
c2e0ea5721 Accommodate for implementation of vaporized water.
See commit: e74901b63f5e5db938dfa5760c5ed72116d4451e
2023-04-12 14:28:01 +02:00
Svenn Tveit
1fe37f7b60 Correction in volume factor calculations.
See commit: 8c2f3f6f37c57f3d772f0ee4d4332f6a6f19f3bf
2023-04-12 14:28:01 +02:00
Svenn Tveit
066601ae52 Improved H2 property calculations.
Most H2 properties are calculated using Helmholtz free energy EOS.
Moved Helmholtz equations from Brine_H2 to H2 class.
New file with simple H2 property calculations based on ideal gas.
2023-04-12 14:28:01 +02:00
Svenn Tveit
ef94fb8896 Corrected unit errors.
Pressure in MPa and apparent molar volume in m3/mol.
2023-04-12 14:28:01 +02:00
Svenn Tveit
437ff4691d Calculate H2 mole fractions directly.
More robust bisection method to get reduced density.
Erroneous T_red (it was supposed to be the reciprocal red. temp.)
2023-04-12 14:28:01 +02:00
Svenn Tveit
4eaf199dbe Minor fixes to make it compile 2023-04-12 14:28:01 +02:00
Svenn Tveit
fa12917a6c Added missing conversion function 2023-04-12 14:28:01 +02:00
Svenn Tveit
f5d02c8049 Remove duplex gasViscosity 2023-04-12 14:28:01 +02:00
Svenn Tveit
f400b3b189 Brine-H2 PVT model To be used with H2STORE
Mostly copied CO2STORE and added specifications for brine-H2.
2023-04-12 14:28:01 +02:00
Svenn Tveit
337b24de87 Added hydrogen component.
Most of this is copied from Dumux with some additions and modifications.
2023-04-12 14:28:01 +02:00
Svenn Tveit
2502e05a6f Move H2STORE test below CO2STORE tests 2023-04-12 14:28:01 +02:00
Svenn Tveit
c7713c41f5 Added H2STORE keyword.
Activates H2-Brine PVT models in opm-material.
2023-04-12 14:28:01 +02:00
Arne Morten Kvarving
25da109206 bump version to 2023.10-pre 2023-04-12 11:31:55 +02:00
685 changed files with 191107 additions and 104769 deletions

View File

@ -1,6 +1,5 @@
{
BasedOnStyle: WebKit,
AlignAfterOpenBracket: AlwaysBreak,
AlignConsecutiveAssignments: false,
AlignConsecutiveDeclarations: false,
AlignAfterOpenBracket: Align,

View File

@ -72,10 +72,7 @@ if(fmt_FOUND)
# OpmSatellites will not add the library, do it here.
list(APPEND opm-common_LIBRARIES fmt::fmt)
else()
add_definitions(-DFMT_HEADER_ONLY)
include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/external/fmtlib/include)
# Not sure why this is needed.
list(APPEND EXTRA_INCLUDES ${PROJECT_SOURCE_DIR}/external/fmtlib/include)
include(DownloadFmt)
endif()
if(OPM_ENABLE_EMBEDDED_PYTHON AND NOT OPM_ENABLE_PYTHON)
@ -91,10 +88,6 @@ include (CMakeLists_files.cmake)
macro (config_hook)
if(ENABLE_ECL_INPUT)
if(NOT cjson_FOUND)
list(APPEND EXTRA_INCLUDES ${PROJECT_SOURCE_DIR}/external/cjson)
endif()
# For this project
include_directories(${EXTRA_INCLUDES} ${PROJECT_BINARY_DIR}/include)
# For downstreams
@ -133,6 +126,12 @@ macro (prereqs_hook)
endmacro (prereqs_hook)
macro (sources_hook)
if(NOT cjson_FOUND)
include(DownloadCjson)
include_directories(${cjson_SOURCE_DIR})
list(APPEND opm-common_SOURCES ${cjson_SOURCE_DIR}/cJSON.c)
endif()
if(ENABLE_ECL_INPUT)
# Keyword generation
include(GenerateKeywords.cmake)
@ -216,26 +215,25 @@ if (OPM_ENABLE_PYTHON)
if(PYTHON_EXECUTABLE AND NOT Python3_EXECUTABLE)
set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
endif()
if (OPM_ENABLE_EMBEDDED_PYTHON)
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
# We always need to search for Development as we use
# pybind11_add_module even if don't embed Python
if (NOT OPM_ENABLE_EMBEDDED_PYTHON)
if(${CMAKE_VERSION} VERSION_LESS "3.18.0")
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
else()
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
endif()
else()
if(${CMAKE_VERSION} VERSION_LESS "3.18.0")
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
else()
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Embed Development.Module)
endif()
get_target_property(_lib_path Python3::Python IMPORTED_LOCATION)
set(PYTHON_LIBRARY ${_lib_path})
set(PYTHON_LIBRARIES {PYTHON_LIBRARY})
list(APPEND opm-common_LIBRARIES ${PYTHON_LIBRARY})
set(PYTHON_INCLUDE_DIRS ${Python3_INCLUDE_DIRS})
else()
find_package(Python3 REQUIRED COMPONENTS Interpreter)
endif()
# Make sure we fail gracefully here without setuptool
execute_process(COMMAND ${Python3_EXECUTABLE} -c "import setuptools"
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
ERROR_VARIABLE SETUPTOOL_ERROR OUTPUT_VARIABLE SETUPTOOL_OUT
RESULT_VARIABLE SETUPTOOL_RESULT)
if(SETUPTOOL_RESULT GREATER 0)
message(WARNING "Trying to test setuptools resulted in error message: ${SETUPTOOL_ERROR}")
message(SEND_ERROR "To build the python bindings you need to install setuptool. "
"Either use \"apt-get install python3-setuptools\" (on Debian/Ubuntu) "
"or \"pip install setuptools\"")
endif()
if(Python3_VERSION_MINOR LESS 3)
# Python native namespace packages requires python >= 3.3
@ -270,10 +268,7 @@ if (OPM_ENABLE_PYTHON)
endif()
find_package(pybind11 2.2 CONFIG)
if (NOT pybind11_FOUND)
add_subdirectory(python/pybind11)
if (NOT pybind11_INCLUDE_DIRS)
set(pybind11_INCLUDE_DIRS ${PYBIND11_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS})
endif()
include(DownloadPyBind11)
endif()
endif()
@ -367,7 +362,7 @@ endif()
find_package(dune-common REQUIRED)
opm_need_version_of ("dune-common")
target_include_directories(dunecommon INTERFACE ${dune-common_INCLUDE_DIRS})
string(REPLACE " " ";" dflags ${dune-common_CXX_FLAGS})
string(REPLACE " " ";" dflags "${dune-common_CXX_FLAGS}")
target_compile_options(dunecommon INTERFACE ${dflags})
target_compile_definitions(dunecommon INTERFACE DUNE_COMMON_VERSION_MAJOR=${DUNE_COMMON_VERSION_MAJOR})
target_compile_definitions(dunecommon INTERFACE DUNE_COMMON_VERSION_MINOR=${DUNE_COMMON_VERSION_MINOR})
@ -380,6 +375,7 @@ if(Boost_UNIT_TEST_FRAMEWORK_FOUND)
endif()
if(BUILD_EXAMPLES)
target_link_libraries(co2brinepvt dunecommon)
install(TARGETS co2brinepvt DESTINATION bin)
endif()
# Install build system files and documentation

View File

@ -51,6 +51,7 @@ list (APPEND MAIN_SOURCE_FILES
src/opm/material/common/TridiagonalMatrix.cpp
src/opm/material/common/UniformXTabulated2DFunction.cpp
src/opm/material/components/CO2.cpp
src/opm/material/components/H2.cpp
src/opm/material/densead/Evaluation.cpp
src/opm/material/fluidmatrixinteractions/EclEpsScalingPoints.cpp
src/opm/material/fluidsystems/BlackOilFluidSystem.cpp
@ -118,6 +119,7 @@ if(ENABLE_ECL_INPUT)
src/opm/input/eclipse/EclipseState/Grid/BoxManager.cpp
src/opm/input/eclipse/EclipseState/Grid/Carfin.cpp
src/opm/input/eclipse/EclipseState/Grid/CarfinManager.cpp
src/opm/input/eclipse/EclipseState/Grid/LgrCollection.cpp
src/opm/input/eclipse/EclipseState/Grid/EclipseGrid.cpp
src/opm/input/eclipse/EclipseState/Grid/FieldProps.cpp
src/opm/input/eclipse/EclipseState/Grid/FieldPropsManager.cpp
@ -140,11 +142,13 @@ if(ENABLE_ECL_INPUT)
src/opm/input/eclipse/EclipseState/InitConfig/Equil.cpp
src/opm/input/eclipse/EclipseState/InitConfig/FoamConfig.cpp
src/opm/input/eclipse/EclipseState/InitConfig/InitConfig.cpp
src/opm/input/eclipse/EclipseState/IOConfig/FIPConfig.cpp
src/opm/input/eclipse/EclipseState/IOConfig/IOConfig.cpp
src/opm/input/eclipse/EclipseState/Runspec.cpp
src/opm/input/eclipse/EclipseState/Phase.cpp
src/opm/input/eclipse/EclipseState/TracerConfig.cpp
src/opm/input/eclipse/EclipseState/MICPpara.cpp
src/opm/input/eclipse/EclipseState/WagHysteresisConfig.cpp
src/opm/input/eclipse/Schedule/Action/ActionAST.cpp
src/opm/input/eclipse/Schedule/Action/ActionContext.cpp
src/opm/input/eclipse/Schedule/Action/ActionResult.cpp
@ -159,6 +163,7 @@ if(ENABLE_ECL_INPUT)
src/opm/input/eclipse/Schedule/Action/State.cpp
src/opm/input/eclipse/Schedule/Action/WGNames.cpp
src/opm/input/eclipse/Schedule/ArrayDimChecker.cpp
src/opm/input/eclipse/Schedule/BCProp.cpp
src/opm/input/eclipse/Schedule/CompletedCells.cpp
src/opm/input/eclipse/Schedule/eval_uda.cpp
src/opm/input/eclipse/Schedule/Events.cpp
@ -170,7 +175,9 @@ if(ENABLE_ECL_INPUT)
src/opm/input/eclipse/Schedule/Group/GuideRateModel.cpp
src/opm/input/eclipse/Schedule/Group/GConSale.cpp
src/opm/input/eclipse/Schedule/Group/GConSump.cpp
src/opm/input/eclipse/Schedule/Group/GroupEconProductionLimits.cpp
src/opm/input/eclipse/Schedule/Group/GTNode.cpp
src/opm/input/eclipse/Schedule/HandlerContext.cpp
src/opm/input/eclipse/Schedule/KeywordHandlers.cpp
src/opm/input/eclipse/Schedule/MessageLimits.cpp
src/opm/input/eclipse/Schedule/MSW/icd.cpp
@ -178,6 +185,7 @@ if(ENABLE_ECL_INPUT)
src/opm/input/eclipse/Schedule/MSW/Segment.cpp
src/opm/input/eclipse/Schedule/MSW/SegmentMatcher.cpp
src/opm/input/eclipse/Schedule/MSW/WellSegments.cpp
src/opm/input/eclipse/Schedule/MSW/WelSegsSet.cpp
src/opm/input/eclipse/Schedule/MSW/AICD.cpp
src/opm/input/eclipse/Schedule/MSW/SICD.cpp
src/opm/input/eclipse/Schedule/MSW/Valve.cpp
@ -198,11 +206,13 @@ if(ENABLE_ECL_INPUT)
src/opm/input/eclipse/Schedule/Tuning.cpp
src/opm/input/eclipse/Schedule/WriteRestartFileEvents.cpp
src/opm/input/eclipse/Schedule/Well/Connection.cpp
src/opm/input/eclipse/Schedule/Well/FilterCake.cpp
src/opm/input/eclipse/Schedule/Well/injection.cpp
src/opm/input/eclipse/Schedule/Well/NameOrder.cpp
src/opm/input/eclipse/Schedule/Well/PAvg.cpp
src/opm/input/eclipse/Schedule/Well/PAvgCalculator.cpp
src/opm/input/eclipse/Schedule/Well/PAvgCalculatorCollection.cpp
src/opm/input/eclipse/Schedule/Well/PAvgDynamicSourceData.cpp
src/opm/input/eclipse/Schedule/Well/Well.cpp
src/opm/input/eclipse/Schedule/Well/WellConnections.cpp
src/opm/input/eclipse/Schedule/Well/WellMatcher.cpp
@ -218,8 +228,11 @@ if(ENABLE_ECL_INPUT)
src/opm/input/eclipse/Schedule/Well/WellTestState.cpp
src/opm/input/eclipse/Schedule/WellTraj/RigEclipseWellLogExtractor.cpp
src/opm/input/eclipse/Schedule/Well/WellTracerProperties.cpp
src/opm/input/eclipse/Schedule/Well/WINJMULT.cpp
src/opm/input/eclipse/Schedule/Well/WList.cpp
src/opm/input/eclipse/Schedule/Well/WListManager.cpp
src/opm/input/eclipse/Schedule/Well/WDFAC.cpp
src/opm/input/eclipse/Schedule/Well/WVFPDP.cpp
src/opm/input/eclipse/Schedule/Well/WVFPEXP.cpp
src/opm/input/eclipse/Schedule/WellTraj/RigEclipseWellLogExtractor.cpp
src/opm/input/eclipse/EclipseState/SimulationConfig/BCConfig.cpp
@ -242,6 +255,7 @@ if(ENABLE_ECL_INPUT)
src/opm/input/eclipse/EclipseState/Tables/TableContainer.cpp
src/opm/input/eclipse/EclipseState/Tables/TableIndex.cpp
src/opm/input/eclipse/EclipseState/Tables/TLMixpar.cpp
src/opm/input/eclipse/EclipseState/Tables/Ppcwmax.cpp
src/opm/input/eclipse/EclipseState/Tables/TableManager.cpp
src/opm/input/eclipse/EclipseState/Tables/TableSchema.cpp
src/opm/input/eclipse/EclipseState/Tables/Tables.cpp
@ -251,21 +265,22 @@ if(ENABLE_ECL_INPUT)
src/opm/input/eclipse/EclipseState/Tables/BrineDensityTable.cpp
src/opm/input/eclipse/EclipseState/Tables/SolventDensityTable.cpp
src/opm/input/eclipse/EclipseState/Tables/Tabdims.cpp
src/opm/input/eclipse/Schedule/UDQ/UDQASTNode.cpp
src/opm/input/eclipse/Schedule/UDQ/UDQParams.cpp
src/opm/input/eclipse/Schedule/UDQ/UDQParser.cpp
src/opm/input/eclipse/Schedule/UDQ/UDQSet.cpp
src/opm/input/eclipse/Schedule/UDQ/UDQActive.cpp
src/opm/input/eclipse/Schedule/UDQ/UDQAssign.cpp
src/opm/input/eclipse/Schedule/UDQ/UDQDefine.cpp
src/opm/input/eclipse/Schedule/UDQ/UDQEnums.cpp
src/opm/input/eclipse/Schedule/UDQ/UDQToken.cpp
src/opm/input/eclipse/Schedule/UDQ/UDQASTNode.cpp
src/opm/input/eclipse/Schedule/UDQ/UDQConfig.cpp
src/opm/input/eclipse/Schedule/UDQ/UDQContext.cpp
src/opm/input/eclipse/Schedule/UDQ/UDQDefine.cpp
src/opm/input/eclipse/Schedule/UDQ/UDQEnums.cpp
src/opm/input/eclipse/Schedule/UDQ/UDQFunction.cpp
src/opm/input/eclipse/Schedule/UDQ/UDQFunctionTable.cpp
src/opm/input/eclipse/Schedule/UDQ/UDQInput.cpp
src/opm/input/eclipse/Schedule/UDQ/UDQParams.cpp
src/opm/input/eclipse/Schedule/UDQ/UDQParser.cpp
src/opm/input/eclipse/Schedule/UDQ/UDQSet.cpp
src/opm/input/eclipse/Schedule/UDQ/UDQState.cpp
src/opm/input/eclipse/Schedule/UDQ/UDQToken.cpp
src/opm/input/eclipse/Schedule/UDQ/UDT.cpp
src/opm/input/eclipse/Schedule/VFPInjTable.cpp
src/opm/input/eclipse/Schedule/VFPProdTable.cpp
src/opm/input/eclipse/Parser/ErrorGuard.cpp
@ -291,6 +306,8 @@ if(ENABLE_ECL_INPUT)
src/opm/material/fluidmatrixinteractions/EclMaterialLawManagerHystParams.cpp
src/opm/material/fluidsystems/blackoilpvt/BrineCo2Pvt.cpp
src/opm/material/fluidsystems/blackoilpvt/Co2GasPvt.cpp
src/opm/material/fluidsystems/blackoilpvt/BrineH2Pvt.cpp
src/opm/material/fluidsystems/blackoilpvt/H2GasPvt.cpp
src/opm/material/fluidsystems/blackoilpvt/ConstantCompressibilityBrinePvt.cpp
src/opm/material/fluidsystems/blackoilpvt/ConstantCompressibilityOilPvt.cpp
src/opm/material/fluidsystems/blackoilpvt/ConstantCompressibilityWaterPvt.cpp
@ -339,10 +356,6 @@ if(ENABLE_ECL_INPUT)
list( APPEND PYTHON_CXX_DEPENDS ${PYTHON_CXX_SOURCE_FILES}
python/cxx/converters.hpp
python/cxx/export.hpp)
if(NOT cjson_FOUND)
list(APPEND MAIN_SOURCE_FILES external/cjson/cJSON.c)
endif()
endif()
if(ENABLE_ECL_OUTPUT)
list( APPEND MAIN_SOURCE_FILES
@ -451,24 +464,29 @@ if(ENABLE_ECL_INPUT)
tests/rst_test.cpp
tests/test_ActiveGridCells.cpp
tests/test_CopyablePtr.cpp
tests/test_CSRGraphFromCoordinates.cpp
tests/test_ERsm.cpp
tests/test_GuideRate.cpp
tests/test_RestartFileView.cpp
tests/test_EclIO.cpp
tests/test_EGrid.cpp
tests/test_EInit.cpp
tests/test_ERft.cpp
tests/test_ERst.cpp
tests/test_ESmry.cpp
tests/test_EInit.cpp
tests/test_ExtESmry.cpp
tests/test_PAvgCalculator.cpp
tests/test_PAvgDynamicSourceData.cpp
tests/test_Serialization.cpp
tests/material/test_co2brinepvt.cpp
tests/material/test_h2brinepvt.cpp
tests/material/test_eclblackoilfluidsystem.cpp
tests/material/test_eclblackoilpvt.cpp
tests/material/test_eclmateriallawmanager.cpp
tests/parser/ACTIONX.cpp
tests/parser/ADDREGTests.cpp
tests/parser/AquiferTests.cpp
tests/parser/BCConfigTests.cpp
tests/parser/BoxTests.cpp
tests/parser/CarfinTests.cpp
tests/parser/ColumnSchemaTests.cpp
@ -484,6 +502,7 @@ if(ENABLE_ECL_INPUT)
tests/parser/FaceDirTests.cpp
tests/parser/FaultTests.cpp
tests/parser/FieldPropsTests.cpp
tests/parser/FIPConfigTests.cpp
tests/parser/FoamTests.cpp
tests/parser/FunctionalTests.cpp
tests/parser/GeomodifierTests.cpp
@ -491,6 +510,7 @@ if(ENABLE_ECL_INPUT)
tests/parser/ImportTests.cpp
tests/parser/InitConfigTest.cpp
tests/parser/IOConfigTests.cpp
tests/parser/LgrTests.cpp
tests/parser/MICPTests.cpp
tests/parser/MessageLimitTests.cpp
tests/parser/MultiRegTests.cpp
@ -530,6 +550,7 @@ if(ENABLE_ECL_INPUT)
tests/parser/TransMultTests.cpp
tests/parser/TuningTests.cpp
tests/parser/UDQTests.cpp
tests/parser/UDTTests.cpp
tests/parser/UnitTests.cpp
tests/parser/integration/NNCTests.cpp
tests/parser/WellSolventTests.cpp
@ -584,6 +605,13 @@ list(APPEND TEST_SOURCE_FILES ${DUNE_TEST_SOURCE_FILES})
list (APPEND TEST_DATA_FILES
tests/testdata.param
tests/material/brine_unittest.json
tests/material/co2_unittest_part1.json
tests/material/co2_unittest_part2.json
tests/material/co2_unittest_above_sat.json
tests/material/co2_unittest_below_sat.json
tests/material/h2o_unittest.json
tests/material/h2_unittest.json
)
if(ENABLE_ECL_OUTPUT)
list (APPEND TEST_DATA_FILES
@ -732,6 +760,8 @@ list( APPEND PUBLIC_HEADER_FILES
opm/common/OpmLog/StreamLog.hpp
opm/common/OpmLog/TimerLog.hpp
opm/common/utility/ActiveGridCells.hpp
opm/common/utility/CSRGraphFromCoordinates.hpp
opm/common/utility/CSRGraphFromCoordinates_impl.hpp
opm/common/utility/Demangle.hpp
opm/common/utility/FileSystem.hpp
opm/common/utility/OpmInputError.hpp
@ -782,6 +812,7 @@ list( APPEND PUBLIC_HEADER_FILES
opm/material/components/Air.hpp
opm/material/components/C1.hpp
opm/material/components/Brine.hpp
opm/material/components/BrineDynamic.hpp
opm/material/fluidstates/BlackOilFluidState.hpp
opm/material/fluidstates/NonEquilibriumFluidState.hpp
opm/material/fluidstates/FluidStateSaturationModules.hpp
@ -815,6 +846,7 @@ list( APPEND PUBLIC_HEADER_FILES
opm/material/binarycoefficients/H2O_CO2.hpp
opm/material/binarycoefficients/Air_Xylene.hpp
opm/material/binarycoefficients/Brine_CO2.hpp
opm/material/binarycoefficients/Brine_H2.hpp
opm/material/binarycoefficients/HenryIapws.hpp
opm/material/Constants.hpp
opm/material/fluidsystems/NullParameterCache.hpp
@ -838,6 +870,7 @@ list( APPEND PUBLIC_HEADER_FILES
opm/material/fluidsystems/blackoilpvt/WaterPvtThermal.hpp
opm/material/fluidsystems/blackoilpvt/WaterPvtMultiplexer.hpp
opm/material/fluidsystems/blackoilpvt/BrineCo2Pvt.hpp
opm/material/fluidsystems/blackoilpvt/BrineH2Pvt.hpp
opm/material/fluidsystems/blackoilpvt/OilPvtMultiplexer.hpp
opm/material/fluidsystems/blackoilpvt/GasPvtMultiplexer.hpp
opm/material/fluidsystems/blackoilpvt/DryHumidGasPvt.hpp
@ -850,9 +883,11 @@ list( APPEND PUBLIC_HEADER_FILES
opm/material/fluidsystems/blackoilpvt/ConstantCompressibilityBrinePvt.hpp
opm/material/fluidsystems/blackoilpvt/GasPvtThermal.hpp
opm/material/fluidsystems/blackoilpvt/Co2GasPvt.hpp
opm/material/fluidsystems/blackoilpvt/H2GasPvt.hpp
opm/material/fluidsystems/blackoilpvt/ConstantCompressibilityOilPvt.hpp
opm/material/fluidsystems/H2OAirFluidSystem.hpp
opm/material/fluidsystems/H2ON2FluidSystem.hpp
opm/material/fluidsystems/ThreeComponentFluidSystem.hh
opm/material/fluidmatrixinteractions/EclTwoPhaseMaterial.hpp
opm/material/fluidmatrixinteractions/SatCurveMultiplexerParams.hpp
opm/material/fluidmatrixinteractions/EclTwoPhaseMaterialParams.hpp
@ -1068,6 +1103,7 @@ if(ENABLE_ECL_INPUT)
opm/input/eclipse/EclipseState/Grid/Fault.hpp
opm/input/eclipse/EclipseState/Grid/Box.hpp
opm/input/eclipse/EclipseState/Grid/Carfin.hpp
opm/input/eclipse/EclipseState/Grid/LgrCollection.hpp
opm/input/eclipse/EclipseState/Grid/FieldProps.hpp
opm/input/eclipse/EclipseState/Grid/FieldPropsManager.hpp
opm/input/eclipse/EclipseState/Grid/FaultFace.hpp
@ -1081,6 +1117,7 @@ if(ENABLE_ECL_INPUT)
opm/input/eclipse/EclipseState/EndpointScaling.hpp
opm/input/eclipse/EclipseState/TracerConfig.hpp
opm/input/eclipse/EclipseState/MICPpara.hpp
opm/input/eclipse/EclipseState/WagHysteresisConfig.hpp
opm/input/eclipse/EclipseState/Tables/DenT.hpp
opm/input/eclipse/EclipseState/Tables/JouleThomson.hpp
opm/input/eclipse/EclipseState/Tables/SimpleTable.hpp
@ -1112,6 +1149,7 @@ if(ENABLE_ECL_INPUT)
opm/input/eclipse/EclipseState/Tables/SgcwmisTable.hpp
opm/input/eclipse/EclipseState/Tables/Sof2Table.hpp
opm/input/eclipse/EclipseState/Tables/TLMixpar.hpp
opm/input/eclipse/EclipseState/Tables/Ppcwmax.hpp
opm/input/eclipse/EclipseState/Tables/TableManager.hpp
opm/input/eclipse/EclipseState/Tables/SwfnTable.hpp
opm/input/eclipse/EclipseState/Tables/EnptvdTable.hpp
@ -1193,6 +1231,7 @@ if(ENABLE_ECL_INPUT)
opm/input/eclipse/Schedule/Action/State.hpp
opm/input/eclipse/Schedule/Action/WGNames.hpp
opm/input/eclipse/Schedule/ArrayDimChecker.hpp
opm/input/eclipse/Schedule/BCProp.hpp
opm/input/eclipse/Schedule/GasLiftOpt.hpp
opm/input/eclipse/Schedule/Network/Balance.hpp
opm/input/eclipse/Schedule/Network/Branch.hpp
@ -1201,9 +1240,11 @@ if(ENABLE_ECL_INPUT)
opm/input/eclipse/Schedule/VFPInjTable.hpp
opm/input/eclipse/Schedule/VFPProdTable.hpp
opm/input/eclipse/Schedule/Well/Connection.hpp
opm/input/eclipse/Schedule/Well/FilterCake.hpp
opm/input/eclipse/Schedule/Well/PAvg.hpp
opm/input/eclipse/Schedule/Well/PAvgCalculator.hpp
opm/input/eclipse/Schedule/Well/PAvgCalculatorCollection.hpp
opm/input/eclipse/Schedule/Well/PAvgDynamicSourceData.hpp
opm/input/eclipse/Schedule/Well/Well.hpp
opm/input/eclipse/Schedule/Well/WellEnums.hpp
opm/input/eclipse/Schedule/Well/WellInjectionControls.hpp
@ -1218,6 +1259,9 @@ if(ENABLE_ECL_INPUT)
opm/input/eclipse/Schedule/Well/WellMICPProperties.hpp
opm/input/eclipse/Schedule/Well/WellPolymerProperties.hpp
opm/input/eclipse/Schedule/Well/WellTracerProperties.hpp
opm/input/eclipse/Schedule/Well/WINJMULT.hpp
opm/input/eclipse/Schedule/Well/WDFAC.hpp
opm/input/eclipse/Schedule/Well/WVFPDP.hpp
opm/input/eclipse/Schedule/Well/WVFPEXP.hpp
opm/input/eclipse/Schedule/Well/WellTestConfig.hpp
opm/input/eclipse/Schedule/Well/WellTestState.hpp
@ -1240,6 +1284,7 @@ if(ENABLE_ECL_INPUT)
opm/input/eclipse/Schedule/Group/GuideRate.hpp
opm/input/eclipse/Schedule/Group/GConSale.hpp
opm/input/eclipse/Schedule/Group/GConSump.hpp
opm/input/eclipse/Schedule/Group/GroupEconProductionLimits.hpp
opm/input/eclipse/Schedule/Group/GuideRateConfig.hpp
opm/input/eclipse/Schedule/Group/GuideRateModel.hpp
opm/input/eclipse/Schedule/MessageLimits.hpp
@ -1257,24 +1302,26 @@ if(ENABLE_ECL_INPUT)
opm/input/eclipse/EclipseState/SimulationConfig/RockConfig.hpp
opm/input/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp
opm/input/eclipse/Schedule/MSW/Valve.hpp
opm/input/eclipse/EclipseState/IOConfig/FIPConfig.hpp
opm/input/eclipse/EclipseState/IOConfig/IOConfig.hpp
opm/input/eclipse/EclipseState/checkDeck.hpp
opm/input/eclipse/EclipseState/Phase.hpp
opm/input/eclipse/EclipseState/Runspec.hpp
opm/input/eclipse/Schedule/UDQ/UDQActive.hpp
opm/input/eclipse/Schedule/UDQ/UDQAssign.hpp
opm/input/eclipse/Schedule/UDQ/UDQASTNode.hpp
opm/input/eclipse/Schedule/UDQ/UDQDefine.hpp
opm/input/eclipse/Schedule/UDQ/UDQContext.hpp
opm/input/eclipse/Schedule/UDQ/UDQState.hpp
opm/input/eclipse/Schedule/UDQ/UDQConfig.hpp
opm/input/eclipse/Schedule/UDQ/UDQContext.hpp
opm/input/eclipse/Schedule/UDQ/UDQDefine.hpp
opm/input/eclipse/Schedule/UDQ/UDQEnums.hpp
opm/input/eclipse/Schedule/UDQ/UDQParams.hpp
opm/input/eclipse/Schedule/UDQ/UDQInput.hpp
opm/input/eclipse/Schedule/UDQ/UDQActive.hpp
opm/input/eclipse/Schedule/UDQ/UDQSet.hpp
opm/input/eclipse/Schedule/UDQ/UDQToken.hpp
opm/input/eclipse/Schedule/UDQ/UDQFunction.hpp
opm/input/eclipse/Schedule/UDQ/UDQFunctionTable.hpp
opm/input/eclipse/Schedule/UDQ/UDQInput.hpp
opm/input/eclipse/Schedule/UDQ/UDQParams.hpp
opm/input/eclipse/Schedule/UDQ/UDQSet.hpp
opm/input/eclipse/Schedule/UDQ/UDQState.hpp
opm/input/eclipse/Schedule/UDQ/UDQToken.hpp
opm/input/eclipse/Schedule/UDQ/UDT.hpp
opm/input/eclipse/Deck/DeckItem.hpp
opm/input/eclipse/Deck/Deck.hpp
opm/input/eclipse/Deck/DeckView.hpp

View File

@ -33,7 +33,7 @@ set(genkw_SOURCES src/opm/json/JsonObject.cpp
src/opm/common/OpmLog/LogUtil.cpp
)
if(NOT cjson_FOUND)
list(APPEND genkw_SOURCES external/cjson/cJSON.c)
list(APPEND genkw_SOURCES ${cjson_SOURCE_DIR}/cJSON.c)
endif()
add_executable(genkw ${genkw_SOURCES})

View File

@ -0,0 +1,18 @@
include(FetchContent)
FetchContent_Declare(cjson
DOWNLOAD_EXTRACT_TIMESTAMP ON
URL https://github.com/DaveGamble/cJSON/archive/refs/tags/v1.7.16.tar.gz
URL_HASH SHA512=3a894de03c33d89f1e7ee572418d5483c844d38e1e64aa4f6297ddaa01f4111f07601f8d26617b424b5af15d469e3955dae075d9f30b5c25e16ec348fdb06e6f)
FetchContent_Populate(cjson)
# set(ENABLE_CJSON_TEST OFF CACHE BOOL "")
# set(BUILD_SHARED_AND_STATIC_LIBS OFF CACHE BOOL "")
# set(CJSON_BUILD_SHARED_LIBS OFF CACHE BOOL "")
# set(CJSON_OVERRIDE_BUILD_SHARED_LIBS ON CACHE BOOL "")
# add_subdirectory(${cjson_SOURCE_DIR} ${cjson_BINARY_DIR})
# add_library(cjson::cjson STATIC IMPORTED)
# set_target_properties(cjson::cjson PROPERTIES
# INTERFACE_INCLUDE_DIRECTORIES ${cjson_SOURCE_DIR}
# IMPORTED_LOCATION lib/libcjson.a)

View File

@ -0,0 +1,17 @@
include(FetchContent)
if(NOT fmt_POPULATED)
FetchContent_Declare(fmt
DOWNLOAD_EXTRACT_TIMESTAMP ON
URL https://github.com/fmtlib/fmt/archive/refs/tags/10.1.1.tar.gz
URL_HASH SHA512=288c349baac5f96f527d5b1bed0fa5f031aa509b4526560c684281388e91909a280c3262a2474d963b5d1bf7064b1c9930c6677fe54a0d8f86982d063296a54c)
FetchContent_Populate(fmt)
endif()
# We do not want to use the target directly as that means it ends up
# in our depends list for downstream modules and the installation list.
# Instead, we just download and use header only mode.
add_compile_definitions(FMT_HEADER_ONLY)
include_directories(${fmt_SOURCE_DIR}/include)
set(fmt_POPULATED ${fmt_POPULATED} PARENT_SCOPE)
set(fmt_SOURCE_DIR ${fmt_SOURCE_DIR} PARENT_SCOPE)

View File

@ -0,0 +1,6 @@
include(FetchContent)
FetchContent_Declare(pybind11
DOWNLOAD_EXTRACT_TIMESTAMP ON
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.11.1.tar.gz
URL_HASH SHA512=ed1512ff0bca3bc0a45edc2eb8c77f8286ab9389f6ff1d5cb309be24bc608abbe0df6a7f5cb18c8f80a3bfa509058547c13551c3cd6a759af708fd0cdcdd9e95)
FetchContent_MakeAvailable(pybind11)

View File

@ -294,7 +294,7 @@ if(SuiteSparse_FOUND)
string (TOUPPER ${_module} _MODULE)
if(SuiteSparse_${_MODULE}_FOUND)
if(NOT TARGET SuiteSparse::${_module})
message(STATUS "Creating target SuitSparse::${_module}")
message(STATUS "Creating target SuiteSparse::${_module}")
add_library(SuiteSparse::${_module} UNKNOWN IMPORTED GLOBAL)
set_target_properties(SuiteSparse::${_module} PROPERTIES
IMPORTED_LOCATION ${${_MODULE}_LIBRARY}

View File

@ -19,8 +19,7 @@ find_opm_package (
# TODO: we should probe for all the HAVE_* values listed below;
# however, we don't actually use them in our implementation, so
# we just include them to forward here in case anyone else does
"dune-common REQUIRED;
"
"dune-common REQUIRED"
# header to search for
"dune/polygongrid/mesh.hh"

View File

@ -1,200 +0,0 @@
# translate a list of libraries into a command-line that can be passed to the
# compiler/linker. first parameter is the name of the variable that will
# receive this list, the rest is considered the list of libraries
function (linker_cmdline what INTO outvar FROM)
if (NOT (UNIX OR MSYS OR MINGW))
return ()
endif (NOT (UNIX OR MSYS OR MINGW))
# if we are going to put these in regexps, we must escape period
string (REPLACE "." "\\." esc_dl_pref "${CMAKE_SHARED_LIBRARY_PREFIX}")
string (REPLACE "." "\\." esc_dl_suff "${CMAKE_SHARED_LIBRARY_SUFFIX}")
string (REPLACE "." "\\." esc_ar_pref "${CMAKE_STATIC_LIBRARY_PREFIX}")
string (REPLACE "." "\\." esc_ar_suff "${CMAKE_STATIC_LIBRARY_PREFIX}")
# CMake loves absolute paths, whereas libtool won't have any of it!
# (you get an error message about argument not parsed). translate each
# of the libraries into a linker option
set (deplib_list "")
set (deplib_list_tmp "")
foreach (deplib IN LISTS ARGN)
# resolve imported targets
string(FIND ${deplib} "::" _sep)
if (_sep GREATER "-1")
set(_lib "")
# the code below does not really work for imported interface library
# as cmake will error out whene querying IMPORTED_LOCATION, because the
# property is not whitelisted. I have no idea how to determine if
# a library is an imported interface library
# At least it works for resolving OpenMP::OpenMP_CXX
#
# get_property(_def TARGET ${deplib} PROPERTY IMPORTED_LOCATION DEFINED)
# if (_def)
# get_property(_def TARGET ${deplib} PROPERTY IMPORTED_LOCATION SET)
# if (_def)
# get_target_property(_tmp_lib ${deplib} IMPORTED_LOCATION)
# list(APPEND _lib ${_tmp_lib})
# endif()
# endif()
get_property(_def TARGET ${deplib} PROPERTY INTERFACE_LINK_LIBRARIES SET)
if (_def)
get_target_property(_tmp_lib ${deplib} INTERFACE_LINK_LIBRARIES)
list(APPEND _lib ${_tmp_lib})
endif()
set(deplib ${_lib})
endif()
list(APPEND deplib_list_tmp ${deplib})
endforeach()
foreach (deplib IN LISTS deplib_list_tmp)
# starts with a hyphen already? then just add it
string (SUBSTRING ${deplib} 0 1 dash)
if (${dash} STREQUAL "-")
list (APPEND deplib_list ${deplib})
else (${dash} STREQUAL "-")
# otherwise, parse the name into a directory and a name
get_filename_component (deplib_dir ${deplib} PATH)
get_filename_component (deplib_orig ${deplib} NAME)
string (REGEX REPLACE
"^${esc_dl_pref}(.*)${esc_dl_suff}$"
"\\1"
deplib_name
${deplib_orig}
)
string (REGEX REPLACE
"^${esc_ar_pref}(.*)${esc_ar_suff}$"
"\\1"
deplib_name
${deplib_name}
)
# directory and name each on their own; this is somewhat
# unsatisfactory because it may be that a system dir is specified
# by an earlier directory and you start picking up libraries from
# there instead of the "closest" path here. also, the soversion
# is more or less lost. remove system default path, to lessen the
# chance that we pick the wrong library
if (NOT ((deplib_dir STREQUAL "/usr/lib") OR
(deplib_dir STREQUAL "") OR
(deplib_dir STREQUAL "/usr/${CMAKE_INSTALL_LIBDIR}")))
list (APPEND deplib_list "-L${deplib_dir}")
endif ()
# if there was no translation of the name, the library is named
# unconventionally (.so.3gf, I'm looking at you), so pass this
# name unmodified to the linker switch
if (deplib_orig STREQUAL deplib_name AND
NOT deplib_orig STREQUAL "stdc++fs")
list (APPEND deplib_list "-l:${deplib_orig}")
else ()
list (APPEND deplib_list "-l${deplib_name}")
endif (deplib_orig STREQUAL deplib_name AND
NOT deplib_orig STREQUAL "stdc++fs")
endif (${dash} STREQUAL "-")
endforeach (deplib)
# caller determines whether we want it returned as a list or a string
if ("${what}" STREQUAL "LIST")
set (${outvar} ${deplib_list})
else ("${what}" STREQUAL "LIST")
set (${outvar} "${deplib_list}")
string (REPLACE ";" " " ${outvar} "${${outvar}}")
endif ("${what}" STREQUAL "LIST")
set (${outvar} "${${outvar}}" PARENT_SCOPE)
endfunction (linker_cmdline what INTO outvar FROM)
function (configure_la name target)
if (NOT (UNIX OR MSYS OR MINGW))
return ()
endif (NOT (UNIX OR MSYS OR MINGW))
# these generic variables are initialized from the project info
set (current "${${name}_VERSION_MAJOR}")
set (age "${${name}_VERSION_MINOR}")
set (inherited_linker_flags "${${name}_LINKER_FLAGS}")
set (dependency_libs "${${name}_LIBRARIES}")
# translate list of libraries to command line
linker_cmdline (LIST INTO dependency_libs FROM ${dependency_libs})
# convert from CMake list (i.e. semi-colon separated)
string (REPLACE ";" " " inherited_linker_flags "${inherited_linker_flags}")
string (REPLACE ";" " " dependency_libs "${dependency_libs}")
# this is the preferred installation path
set (libdir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
# ${name}_LIBRARY_TYPE is either SHARED or STATIC
if (${name}_LIBRARY_TYPE STREQUAL "SHARED")
set (libprefix "${CMAKE_SHARED_LIBRARY_PREFIX}")
set (libsuffix "${CMAKE_SHARED_LIBRARY_SUFFIX}")
set (libname "${CMAKE_SHARED_LIBRARY_PREFIX}${target}${CMAKE_SHARED_LIBRARY_SUFFIX}")
# only Unix has soversion in library names
if (UNIX)
set (dlname "${libname}.${current}")
set (library_names "${libname}.${current}.${age} ${libname}.${current} ${libname}")
else (UNIX)
set (dlname "${libname}")
set (library_names "${libname}")
endif (UNIX)
set (old_library "")
else (${name}_LIBRARY_TYPE STREQUAL "SHARED")
set (dlname "")
set (library_names "")
set (old_library "${CMAKE_STATIC_LIBRARY_PREFIX}${target}${CMAKE_STATIC_LIBRARY_SUFFIX}")
endif (${name}_LIBRARY_TYPE STREQUAL "SHARED")
# get the version of libtool installed on the system; this is
# necessary because libtool checks that the file contains its own
# signature(!)
if (NOT libtool_MAIN)
find_file (
libtool_MAIN
ltmain.sh
PATHS /usr
PATH_SUFFIXES share/libtool/config/
DOC "Location of libtool"
)
mark_as_advanced (libtool_MAIN)
# notify the user if it not found after we explicitly searched
if (NOT libtool_MAIN)
message (STATUS "Not generating libtool archive (.la) since libtool was not found")
endif (NOT libtool_MAIN)
endif (NOT libtool_MAIN)
if (libtool_MAIN)
file (STRINGS
${libtool_MAIN}
ltversion_STRING
REGEX "^VERSION=\".*\""
)
endif (libtool_MAIN)
if (ltversion_STRING)
string (REGEX REPLACE
"^VERSION=\"?(.*)\"?"
"\\1"
ltversion
${ltversion_STRING}
)
endif (ltversion_STRING)
# assume that we are in cmake/Modules, and that the template have been
# put in cmake/Templates. we cannot use CMAKE_CURRENT_LIST_DIR because
# this is in a function, and we cannot know who's calling us
set (templ_dir "${OPM_MACROS_ROOT}/cmake/Templates")
# only write an .la if libtool is found; otherwise we have no use
# for it.
if (ltversion)
set (la_file "lib${target}.la")
message (STATUS "Writing libtool archive for ${target}")
configure_file (
${templ_dir}/la.in
${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${la_file}
@ONLY@
)
else (ltversion)
set (la_file "")
endif (ltversion)
# return this variable to the caller
if (ARGV2)
set (${ARGV2} "${la_file}" PARENT_SCOPE)
endif (ARGV2)
endfunction (configure_la target)

View File

@ -110,6 +110,10 @@ macro (OpmInitDirVars)
endif (COMMAND dir_hook)
endmacro ()
if("${CMAKE_SIZEOF_VOID_P}" LESS 8)
message(FATAL_ERROR "OPM will only work correctly on 64bit (or higher) systems!")
endif()
OpmInitProjVars ()
OpmInitDirVars ()

View File

@ -1,38 +1,5 @@
# - Helper routines for opm-core like projects
include (LibtoolArchives) # linker_cmdline
# convert a list back to a command-line string
function (unseparate_args var_name prefix value)
separate_arguments (value)
foreach (item IN LISTS value)
set (prefixed_item "${prefix}${item}")
if (${var_name})
set (${var_name} "${${var_name}} ${prefixed_item}")
else (${var_name})
set (${var_name} "${prefixed_item}")
endif (${var_name})
endforeach (item)
set (${var_name} "${${var_name}}" PARENT_SCOPE)
endfunction (unseparate_args var_name prefix value)
# wrapper to set variables in pkg-config file
function (configure_pc_file name source dest prefix libdir includedir)
# escape set of standard strings
unseparate_args (includes "-I" "${${name}_INCLUDE_DIRS}")
unseparate_args (defs "" "${${name}_DEFINITIONS}")
linker_cmdline (STRING INTO libs FROM ${${name}_LIBRARIES})
# necessary to make these variables visible to configure_file
set (name "${${name}_NAME}")
set (description "${${name}_DESCRIPTION}")
set (major "${${name}_VERSION_MAJOR}")
set (minor "${${name}_VERSION_MINOR}")
set (target "${${name}_LIBRARY}")
linker_cmdline (STRING INTO target from ${target})
configure_file (${source} ${dest} @ONLY)
endfunction (configure_pc_file name source dist prefix libdir includedir)
function (configure_cmake_file name variant version)
# declarative list of the variable names that are used in the template
# and that must be defined in the project to be exported
@ -91,16 +58,6 @@ function (opm_cmake_config name)
APPEND "${${name}_CONFIG_VARS}"
)
# config-mode .pc file; use this to find the build tree
configure_pc_file (
${name}
${template_dir}/opm-project.pc.in
${PROJECT_BINARY_DIR}/${${name}_NAME}.pc
${PROJECT_BINARY_DIR}
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
${PROJECT_SOURCE_DIR}
)
# The next replace will result in bogus entries if install directory is
# a subdirectory of source tree,
# and we have existing entries pointing to that install directory.
@ -154,28 +111,4 @@ function (opm_cmake_config name)
FILES ${PROJECT_BINARY_DIR}/${${name}_NAME}-config-version.cmake
DESTINATION share/cmake${${name}_VER_DIR}/${${name}_NAME}
)
# find-mode .pc file; use this to locate system installation
configure_pc_file (
${name}
${template_dir}/opm-project.pc.in
${PROJECT_BINARY_DIR}/${${name}_NAME}-install.pc
${CMAKE_INSTALL_PREFIX}
${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${${name}_VER_DIR}
${CMAKE_INSTALL_PREFIX}/include${${name}_VER_DIR}
)
# put this in the right system location; if we have binaries then it
# should go in the arch-specific lib/ directory, otherwise use the
# common/noarch lib/ directory (these targets come from UseMultiArch)
if (${name}_TARGET)
set (_pkg_dir ${CMAKE_INSTALL_LIBDIR})
else ()
set (_pkg_dir lib)
endif ()
install (
FILES ${PROJECT_BINARY_DIR}/${${name}_NAME}-install.pc
DESTINATION ${CMAKE_INSTALL_PREFIX}/${_pkg_dir}/pkgconfig${${name}_VER_DIR}/
RENAME ${${name}_NAME}.pc
)
endfunction (opm_cmake_config name)

View File

@ -305,7 +305,10 @@ macro(opm_add_test TestName)
target_link_libraries (${CURTEST_EXE_NAME} ${CURTEST_LIBRARIES})
get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
add_static_analysis_tests(CURTEST_SOURCES dirs)
if(HAVE_DYNAMIC_BOOST_TEST)
set_target_properties (${CURTEST_EXE_NAME} PROPERTIES
COMPILE_DEFINITIONS BOOST_TEST_DYN_LINK)
endif()
if(TARGET ${project}_prepare)
add_dependencies("${CURTEST_EXE_NAME}" ${project}_prepare)
endif()

View File

@ -1,103 +0,0 @@
####################################################################
# #
# Setup static targets for all submodules. #
# Useful when building a static benchmark executable #
# #
####################################################################
# Macros
# Clone a git and build it statically
# If ARGN is specified installation is skipped, ARGN0 is
# a build-system target name and the rest of ARGN are build tool parameters
function(opm_from_git repo name revision)
if(ARGN)
list(GET ARGN 0 target)
list(REMOVE_AT ARGN 0)
# This is used for top build of benchmarks.
# Clones the local source tree and builds it against the static libraries,
# skipping the install step. Note that in pricinple URL instead of GIT_REPOSITORY
# could have been used, but externalproject cannot handle build directories
# which are a subdirectory of the source tree, and since that is typically the case
# we work-around by re-cloning the local git.
# The ommision of GIT_TAG ensures that we build the tip of the local git.
set(COMMANDS BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target ${target} -- ${ARGN}
GIT_TAG ${revision}
INSTALL_COMMAND)
else()
# This is used with "normal" static builds.
set(COMMANDS GIT_TAG ${revision})
endif()
externalproject_add(${name}-static
GIT_REPOSITORY ${repo}
PREFIX static/${name}
CONFIGURE_COMMAND PKG_CONFIG_PATH=${CMAKE_BINARY_DIR}/static/installed/lib/pkgconfig:${CMAKE_BINARY_DIR}/static/installed/${CMAKE_INSTALL_LIBDIR}/pkgconfig:$ENV{PKG_CONFIG_PATH}
${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/static/installed
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DBUILD_SHARED_LIBS=0
-DBUILD_TESTING=0 -DBUILD_EXAMPLES=0 <SOURCE_DIR>
-G ${CMAKE_GENERATOR}
${COMMANDS} "")
set_target_properties(${name}-static PROPERTIES EXCLUDE_FROM_ALL 1)
endfunction()
# Convenience macro for adding dependencies without having to include the -static all over
macro(opm_static_add_dependencies target)
foreach(arg ${ARGN})
add_dependencies(${target}-static ${arg}-static)
endforeach()
endmacro()
include(ExternalProject)
include(GNUInstallDirs)
# Defaults to building master
if(NOT OPM_BENCHMARK_VERSION)
set(OPM_BENCHMARK_VERSION "origin/master")
endif()
# ERT
externalproject_add(ert-static
GIT_REPOSITORY https://github.com/Ensembles/ert
PREFIX static/ert
GIT_TAG ${revision}
CONFIGURE_COMMAND ${CMAKE_COMMAND}
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/static/installed
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DBUILD_SHARED_LIBS=0 <SOURCE_DIR>/devel)
set_target_properties(ert-static PROPERTIES EXCLUDE_FROM_ALL 1)
# 2015.04 release used dune v2.3.1
if(OPM_BENCHMARK_VERSION STREQUAL "release/2015.04/final")
set(DUNE_VERSION v2.3.1)
endif()
# Master currently uses dune v2.3.1
if(OPM_BENCHMARK_VERSION STREQUAL "origin/master")
set(DUNE_VERSION v2.3.1)
endif()
# Fallback
if(NOT DUNE_VERSION)
set(DUNE_VERSION v2.3.1)
endif()
# Dune
foreach(dune_repo dune-common dune-geometry dune-grid dune-istl)
opm_from_git(http://git.dune-project.org/repositories/${dune_repo} ${dune_repo} ${DUNE_VERSION})
endforeach()
opm_static_add_dependencies(dune-istl dune-common)
opm_static_add_dependencies(dune-geometry dune-common)
opm_static_add_dependencies(dune-grid dune-geometry)
# OPM
foreach(opm_repo opm-common opm-parser opm-core opm-output opm-grid opm-material
opm-upscaling)
opm_from_git(https://github.com/OPM/${opm_repo} ${opm_repo} ${OPM_BENCHMARK_VERSION})
endforeach()
opm_static_add_dependencies(opm-parser opm-common ert)
opm_static_add_dependencies(opm-core opm-parser dune-istl)
opm_static_add_dependencies(opm-grid opm-core dune-grid)
opm_static_add_dependencies(opm-material opm-core)
opm_static_add_dependencies(opm-upscaling opm-grid opm-material)

View File

@ -18,7 +18,7 @@ if(USE_DAMARIS_LIB AND MPI_FOUND)
message(STATUS "The Damaris library does NOT have Catalyst support")
endif()
else()
message(STATUS "The Damaris library was requested but NOT found")
message(FATAL_ERROR "The Damaris library was requested but NOT found")
endif()
else() # User did not request Damaris support
unset(HAVE_DAMARIS)

View File

@ -1,20 +0,0 @@
# -*- mode: cmake; tab-width: 2; indent-tabs-mode: t; truncate-lines: t; compile-command: "cmake -Wdev" -*-
# vim: set filetype=cmake autoindent tabstop=2 shiftwidth=2 noexpandtab softtabstop=2 nowrap:
# defines that must be present in config.h for our headers
set (opm-verteq_CONFIG_VAR
)
# dependencies
set (opm-verteq_DEPS
# compile with C99 support if available
"C99"
# compile with C++0x/11 support if available
"CXX11Features"
# various runtime library enhancements
"Boost 1.44.0
COMPONENTS date_time filesystem system unit_test_framework REQUIRED"
# OPM dependency
"opm-common;
opm-core REQUIRED"
)

View File

@ -1,6 +1,9 @@
.TH SUMMARY "1" "October 2022" "arraylist 2022.10" "User Commands"
.TH SUMMARY "1" "October 2023" "arraylist 2023.10" "User Commands"
.SH NAME
summary \- Printer for list of arrays in Eclipse summary files
arraylist \- Printer for list of arrays in Eclipse summary files
.SH SYNOPSIS
.B arraylist
[\fI\,OPTIONS\/\fR] \fI\,ECL_DECK_FILENAME\/\fR
.SH DESCRIPTION
List all arrays found in an EclFile specified on the command line.
.PP

View File

@ -1,6 +1,10 @@
.TH CO2BRINEPVT "1" "April 2022" "co2brinepvt" "User Commands"
.TH CO2BRINEPVT "1" "October 2023" "co2brinepvt" "User Commands"
.SH NAME
co2brinepvt \- compute and print pvt properties for co2 with brine
.SH SYNOPSIS
.B co2brinepvt
[\fI\,OPTIONS\/\fR] \fI\,PROPERTY\/\fR \fI\,PHASE\/\fR
\fI\,PRESSURE\/\fR \fI\,TEMPERATURE\/\fR [\fI\,SALINITY\/\fR] [\fI\,RS\/\fR]
.SH DESCRIPTION
co2brinepvt computes PVT properties of a brine/co2 system
for a given phase (oil or brine), pressure, temperature, salinity and rs.

View File

@ -1,6 +1,9 @@
.TH COMPAREECL "1" "October 2022" "compareECL 2022.10" "User Commands"
.TH COMPAREECL "1" "October 2023" "compareECL 2023.10" "User Commands"
.SH NAME
compareECL \- Comparator for Eclipse files
.SH SYNOPSIS
.B convertECL
[\fI\,OPTIONS\/\fR] \fI\,ECL_DECK_FILENAME_1\/\fR \fI\,ECL_DECK_FILENAME_2\/\fR
.SH DESCRIPTION
compareECL compares ECLIPSE files (restart (.RST), unified restart (.UNRST), initial (.INIT), summary (.SMRY), unified summary (.UNSMRY) or .RFT) and gridsizes (from .EGRID or .GRID file) from two simulations.
The program takes four arguments:

View File

@ -1,6 +1,10 @@
.TH CONVERTECL "1" "October 2022" "convertECL 2022.10" "User Commands"
.TH CONVERTECL "1" "October 2023" "convertECL 2023.10" "User Commands"
.SH NAME
convertECL \- Converter for Eclipse files (binary <-> formatted format)
convertECL \- Converter for Eclipse files (binary <-> formatted
format)
.SH SYNOPSIS
.B convertECL
[\fI\,OPTIONS\/\fR] \fI\,ECL_DECK_FILENAME\/\fR
.SH DESCRIPTION
convertECL needs one argument which is the input file to be converted. If this is a binary file the output file will be formatted. If the input file is formatted the output will be binary.
.PP

View File

@ -1,8 +1,11 @@
.TH OPMHASH "1" "October 2022" "opmhash 2022.10" "User Commands"
.TH OPMHASH "1" "October 2023" "opmhash 2023.10" "User Commands"
.SH NAME
opmhash \- Hasher for summary keywords in Eclipse files
.SH SYNOPSIS
.B opmhash
[\fI\,OPTIONS\/\fR] \fI\,ECL_DECK_FILENAME\/\fR
[\fI\,ECL_DECK_FILENAME_2\/\fR] [\fI\,ECL_DECK_FILENAME_3\/\fR] ...
.SH DESCRIPTION
opmhash: invalid option \fB\-\-\fR 'h'
The purpose of the opmhash program is to load a deck and create a summary, by
diffing two such summaries it is simple to determine if two decks are similar.
For each keyword a hash of the normalized content is calculated. The output of

View File

@ -1,6 +1,9 @@
.TH OPMPACK "1" "October 2022" "opmpack 2022.10" "User Commands"
.TH OPMPACK "1" "October 2023" "opmpack 2023.10" "User Commands"
.SH NAME
opmpack \- Validator and printer of deck in Eclipse files without comments
.SH SYNOPSIS
.B opmpack
[\fI\,OPTIONS\/\fR] \fI\,ECL_DECK_FILENAME\/\fR
.SH DESCRIPTION
The opmpack program will load a deck, resolve all include
files and then print it out again on stdout. All comments

View File

@ -1,6 +1,10 @@
.TH RST_DECK: "1" "October 2022" "rst_deck 2022.10" "User Commands"
.TH RST_DECK: "1" "October 2023" "rst_deck 2023.10" "User Commands"
.SH NAME
rst_deck \- Convert simulation deck to a deck ready for restart
.SH SYNOPSIS
.B rst_deck
[\fI\,OPTIONS\/\fR] \fI\,ECL_DECK_FILENAME\/\fR
\fI\,RESTART_SOURCE\/\fR [\fI\,BASENAME_RESTART_DECK\/\fR
.SH DESCRIPTION
The rst_deck program will load a simulation deck and parameters for a restart
and reformat the deck to become a restart deck. Before the updated deck is

View File

@ -1,6 +1,10 @@
.TH SUMMARY "1" "October 2022" "summary 2022.10" "User Commands"
.TH SUMMARY "1" "October 2023" "summary 2023.10" "User Commands"
.SH NAME
summary \- Printer for summary keys in Eclipse summary files
.SH SYNOPSIS
.B summary
[\fI\,OPTIONS\/\fR] \fI\,ECL_DECK_FILENAME\/\fR
\fI\,SUMMARY_KEY1\/\fR [\fI\,SUMMARY_KEY2\/\fR] ...
.SH DESCRIPTION
summary needs a minimum of two arguments. First is smspec filename and then list of vectors
.PP

View File

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

View File

@ -93,7 +93,7 @@ int main(int argc, char **argv)
if (argc > 6)
rs = atof(argv[6]);
const double MmNaCl = 58e-3; // molar mass of NaCl [kg/mol]
const double MmNaCl = 58.44e-3; // molar mass of NaCl [kg/mol]
// convert to mass fraction
std::vector<double> salinity = {0.0};
if (molality > 0.0)

247
external/cjson/README vendored
View File

@ -1,247 +0,0 @@
/*
Copyright (c) 2009 Dave Gamble
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.
*/
Welcome to cJSON.
cJSON aims to be the dumbest possible parser that you can get your job done with.
It's a single file of C, and a single header file.
JSON is described best here: http://www.json.org/
It's like XML, but fat-free. You use it to move data around, store things, or just
generally represent your program's state.
First up, how do I build?
Add cJSON.c to your project, and put cJSON.h somewhere in the header search path.
For example, to build the test app:
gcc cJSON.c test.c -o test -lm
./test
As a library, cJSON exists to take away as much legwork as it can, but not get in your way.
As a point of pragmatism (i.e. ignoring the truth), I'm going to say that you can use it
in one of two modes: Auto and Manual. Let's have a quick run-through.
I lifted some JSON from this page: http://www.json.org/fatfree.html
That page inspired me to write cJSON, which is a parser that tries to share the same
philosophy as JSON itself. Simple, dumb, out of the way.
Some JSON:
{
"name": "Jack (\"Bee\") Nimble",
"format": {
"type": "rect",
"width": 1920,
"height": 1080,
"interlace": false,
"frame rate": 24
}
}
Assume that you got this from a file, a webserver, or magic JSON elves, whatever,
you have a char * to it. Everything is a cJSON struct.
Get it parsed:
cJSON *root = cJSON_Parse(my_json_string);
This is an object. We're in C. We don't have objects. But we do have structs.
What's the framerate?
cJSON *format = cJSON_GetObjectItem(root,"format");
int framerate = cJSON_GetObjectItem(format,"frame rate")->valueint;
Want to change the framerate?
cJSON_GetObjectItem(format,"frame rate")->valueint=25;
Back to disk?
char *rendered=cJSON_Print(root);
Finished? Delete the root (this takes care of everything else).
cJSON_Delete(root);
That's AUTO mode. If you're going to use Auto mode, you really ought to check pointers
before you dereference them. If you want to see how you'd build this struct in code?
cJSON *root,*fmt;
root=cJSON_CreateObject();
cJSON_AddItemToObject(root, "name", cJSON_CreateString("Jack (\"Bee\") Nimble"));
cJSON_AddItemToObject(root, "format", fmt=cJSON_CreateObject());
cJSON_AddStringToObject(fmt,"type", "rect");
cJSON_AddNumberToObject(fmt,"width", 1920);
cJSON_AddNumberToObject(fmt,"height", 1080);
cJSON_AddFalseToObject (fmt,"interlace");
cJSON_AddNumberToObject(fmt,"frame rate", 24);
Hopefully we can agree that's not a lot of code? There's no overhead, no unnecessary setup.
Look at test.c for a bunch of nice examples, mostly all ripped off the json.org site, and
a few from elsewhere.
What about manual mode? First up you need some detail.
Let's cover how the cJSON objects represent the JSON data.
cJSON doesn't distinguish arrays from objects in handling; just type.
Each cJSON has, potentially, a child, siblings, value, a name.
The root object has: Object Type and a Child
The Child has name "name", with value "Jack ("Bee") Nimble", and a sibling:
Sibling has type Object, name "format", and a child.
That child has type String, name "type", value "rect", and a sibling:
Sibling has type Number, name "width", value 1920, and a sibling:
Sibling has type Number, name "height", value 1080, and a sibling:
Sibling hs type False, name "interlace", and a sibling:
Sibling has type Number, name "frame rate", value 24
Here's the structure:
typedef struct cJSON {
struct cJSON *next,*prev;
struct cJSON *child;
int type;
char *valuestring;
int valueint;
double valuedouble;
char *string;
} cJSON;
By default all values are 0 unless set by virtue of being meaningful.
next/prev is a doubly linked list of siblings. next takes you to your sibling,
prev takes you back from your sibling to you.
Only objects and arrays have a "child", and it's the head of the doubly linked list.
A "child" entry will have prev==0, but next potentially points on. The last sibling has next=0.
The type expresses Null/True/False/Number/String/Array/Object, all of which are #defined in
cJSON.h
A Number has valueint and valuedouble. If you're expecting an int, read valueint, if not read
valuedouble.
Any entry which is in the linked list which is the child of an object will have a "string"
which is the "name" of the entry. When I said "name" in the above example, that's "string".
"string" is the JSON name for the 'variable name' if you will.
Now you can trivially walk the lists, recursively, and parse as you please.
You can invoke cJSON_Parse to get cJSON to parse for you, and then you can take
the root object, and traverse the structure (which is, formally, an N-tree),
and tokenise as you please. If you wanted to build a callback style parser, this is how
you'd do it (just an example, since these things are very specific):
void parse_and_callback(cJSON *item,const char *prefix)
{
while (item)
{
char *newprefix=malloc(strlen(prefix)+strlen(item->name)+2);
sprintf(newprefix,"%s/%s",prefix,item->name);
int dorecurse=callback(newprefix, item->type, item);
if (item->child && dorecurse) parse_and_callback(item->child,newprefix);
item=item->next;
free(newprefix);
}
}
The prefix process will build you a separated list, to simplify your callback handling.
The 'dorecurse' flag would let the callback decide to handle sub-arrays on it's own, or
let you invoke it per-item. For the item above, your callback might look like this:
int callback(const char *name,int type,cJSON *item)
{
if (!strcmp(name,"name")) { /* populate name */ }
else if (!strcmp(name,"format/type") { /* handle "rect" */ }
else if (!strcmp(name,"format/width") { /* 800 */ }
else if (!strcmp(name,"format/height") { /* 600 */ }
else if (!strcmp(name,"format/interlace") { /* false */ }
else if (!strcmp(name,"format/frame rate") { /* 24 */ }
return 1;
}
Alternatively, you might like to parse iteratively.
You'd use:
void parse_object(cJSON *item)
{
int i; for (i=0;i<cJSON_GetArraySize(item);i++)
{
cJSON *subitem=cJSON_GetArrayItem(item,i);
// handle subitem.
}
}
Or, for PROPER manual mode:
void parse_object(cJSON *item)
{
cJSON *subitem=item->child;
while (subitem)
{
// handle subitem
if (subitem->child) parse_object(subitem->child);
subitem=subitem->next;
}
}
Of course, this should look familiar, since this is just a stripped-down version
of the callback-parser.
This should cover most uses you'll find for parsing. The rest should be possible
to infer.. and if in doubt, read the source! There's not a lot of it! ;)
In terms of constructing JSON data, the example code above is the right way to do it.
You can, of course, hand your sub-objects to other functions to populate.
Also, if you find a use for it, you can manually build the objects.
For instance, suppose you wanted to build an array of objects?
cJSON *objects[24];
cJSON *Create_array_of_anything(cJSON **items,int num)
{
int i;cJSON *prev, *root=cJSON_CreateArray();
for (i=0;i<24;i++)
{
if (!i) root->child=objects[i];
else prev->next=objects[i], objects[i]->prev=prev;
prev=objects[i];
}
return root;
}
and simply: Create_array_of_anything(objects,24);
cJSON doesn't make any assumptions about what order you create things in.
You can attach the objects, as above, and later add children to each
of those objects.
As soon as you call cJSON_Print, it renders the structure to text.
The test.c code shows how to handle a bunch of typical cases. If you uncomment
the code, it'll load, parse and print a bunch of test files, also from json.org,
which are more complex than I'd care to try and stash into a const char array[].
Enjoy cJSON!
- Dave Gamble, Aug 2009

View File

@ -1,2 +0,0 @@
This directory contains the the 1.7.10 version of the cJSON package from https://github.com/DaveGamble/cJSON

2936
external/cjson/cJSON.c vendored

File diff suppressed because it is too large Load Diff

285
external/cjson/cJSON.h vendored
View File

@ -1,285 +0,0 @@
/*
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
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.
*/
#ifndef cJSON__h
#define cJSON__h
#ifdef __cplusplus
extern "C"
{
#endif
#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
#define __WINDOWS__
#endif
#ifdef __WINDOWS__
/* When compiling for windows, we specify a specific calling convention to avoid issues where we are being called from a project with a different default calling convention. For windows you have 3 define options:
CJSON_HIDE_SYMBOLS - Define this in the case where you don't want to ever dllexport symbols
CJSON_EXPORT_SYMBOLS - Define this on library build when you want to dllexport symbols (default)
CJSON_IMPORT_SYMBOLS - Define this if you want to dllimport symbol
For *nix builds that support visibility attribute, you can define similar behavior by
setting default visibility to hidden by adding
-fvisibility=hidden (for gcc)
or
-xldscope=hidden (for sun cc)
to CFLAGS
then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJSON_EXPORT_SYMBOLS does
*/
#define CJSON_CDECL __cdecl
#define CJSON_STDCALL __stdcall
/* export symbols by default, this is necessary for copy pasting the C and header file */
#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS)
#define CJSON_EXPORT_SYMBOLS
#endif
#if defined(CJSON_HIDE_SYMBOLS)
#define CJSON_PUBLIC(type) type CJSON_STDCALL
#elif defined(CJSON_EXPORT_SYMBOLS)
#define CJSON_PUBLIC(type) __declspec(dllexport) type CJSON_STDCALL
#elif defined(CJSON_IMPORT_SYMBOLS)
#define CJSON_PUBLIC(type) __declspec(dllimport) type CJSON_STDCALL
#endif
#else /* !__WINDOWS__ */
#define CJSON_CDECL
#define CJSON_STDCALL
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type
#else
#define CJSON_PUBLIC(type) type
#endif
#endif
/* project version */
#define CJSON_VERSION_MAJOR 1
#define CJSON_VERSION_MINOR 7
#define CJSON_VERSION_PATCH 10
#include <stddef.h>
/* cJSON Types: */
#define cJSON_Invalid (0)
#define cJSON_False (1 << 0)
#define cJSON_True (1 << 1)
#define cJSON_NULL (1 << 2)
#define cJSON_Number (1 << 3)
#define cJSON_String (1 << 4)
#define cJSON_Array (1 << 5)
#define cJSON_Object (1 << 6)
#define cJSON_Raw (1 << 7) /* raw json */
#define cJSON_IsReference 256
#define cJSON_StringIsConst 512
/* The cJSON structure: */
typedef struct cJSON
{
/* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
struct cJSON *next;
struct cJSON *prev;
/* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
struct cJSON *child;
/* The type of the item, as above. */
int type;
/* The item's string, if type==cJSON_String and type == cJSON_Raw */
char *valuestring;
/* writing to valueint is DEPRECATED, use cJSON_SetNumberValue instead */
int valueint;
/* The item's number, if type==cJSON_Number */
double valuedouble;
/* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
char *string;
} cJSON;
typedef struct cJSON_Hooks
{
/* malloc/free are CDECL on Windows regardless of the default calling convention of the compiler, so ensure the hooks allow passing those functions directly. */
void *(CJSON_CDECL *malloc_fn)(size_t sz);
void (CJSON_CDECL *free_fn)(void *ptr);
} cJSON_Hooks;
typedef int cJSON_bool;
/* Limits how deeply nested arrays/objects can be before cJSON rejects to parse them.
* This is to prevent stack overflows. */
#ifndef CJSON_NESTING_LIMIT
#define CJSON_NESTING_LIMIT 1000
#endif
/* returns the version of cJSON as a string */
CJSON_PUBLIC(const char*) cJSON_Version(void);
/* Supply malloc, realloc and free functions to cJSON */
CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks);
/* Memory Management: the caller is always responsible to free the results from all variants of cJSON_Parse (with cJSON_Delete) and cJSON_Print (with stdlib free, cJSON_Hooks.free_fn, or cJSON_free as appropriate). The exception is cJSON_PrintPreallocated, where the caller has full responsibility of the buffer. */
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. */
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error so will match cJSON_GetErrorPtr(). */
CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated);
/* Render a cJSON entity to text for transfer/storage. */
CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item);
/* Render a cJSON entity to text for transfer/storage without any formatting. */
CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item);
/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt);
/* Render a cJSON entity to text using a buffer already allocated in memory with given length. Returns 1 on success and 0 on failure. */
/* NOTE: cJSON is not always 100% accurate in estimating how much memory it will use, so to be safe allocate 5 bytes more than you actually need */
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format);
/* Delete a cJSON entity and all subentities. */
CJSON_PUBLIC(void) cJSON_Delete(cJSON *c);
/* Returns the number of items in an array (or object). */
CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
/* Retrieve item number "index" from array "array". Returns NULL if unsuccessful. */
CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index);
/* Get item "string" from object. Case insensitive. */
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string);
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string);
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
/* Check if the item is a string and return its valuestring */
CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item);
/* These functions check the type of an item */
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item);
CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item);
/* These calls create a cJSON item of the appropriate type. */
CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void);
CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void);
CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void);
CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean);
CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num);
CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string);
/* raw json */
CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw);
CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void);
CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void);
/* Create a string where valuestring references a string so
* it will not be freed by cJSON_Delete */
CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string);
/* Create an object/arrray that only references it's elements so
* they will not be freed by cJSON_Delete */
CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child);
CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child);
/* These utilities create an Array of count items. */
CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count);
CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count);
CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count);
CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count);
/* Append item to the specified array/object. */
CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item);
CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
/* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object.
* WARNING: When this function was used, make sure to always check that (item->type & cJSON_StringIsConst) is zero before
* writing to `item->string` */
CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
/* Remove/Detatch items from Arrays/Objects. */
CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item);
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which);
CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which);
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string);
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string);
CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string);
CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
/* Update array items. */
CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement);
CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem);
/* Duplicate a cJSON item */
CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
need to be released. With recurse!=0, it will duplicate any children connected to the item.
The item->next and ->prev pointers are always zero on return from Duplicate. */
/* Recursively compare two cJSON items for equality. If either a or b is NULL or invalid, they will be considered unequal.
* case_sensitive determines if object keys are treated case sensitive (1) or case insensitive (0) */
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);
CJSON_PUBLIC(void) cJSON_Minify(char *json);
/* Helper functions for creating and adding items to an object at the same time.
* They return the added item or NULL on failure. */
CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name);
CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name);
CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name);
CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean);
CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number);
CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string);
CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw);
CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name);
CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name);
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
/* helper for the cJSON_SetNumberValue macro */
CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number);
#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
/* Macro for iterating over an array or object */
#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
/* malloc/free objects using the malloc/free functions that have been set with cJSON_InitHooks */
CJSON_PUBLIC(void *) cJSON_malloc(size_t size);
CJSON_PUBLIC(void) cJSON_free(void *object);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,27 +0,0 @@
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.

View File

@ -1,12 +0,0 @@
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");

File diff suppressed because it is too large Load Diff

View File

@ -1,566 +0,0 @@
// 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_

View File

@ -1,665 +0,0 @@
// 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_

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,78 +0,0 @@
// 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_

View File

@ -1,450 +0,0 @@
// 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_

View File

@ -1,167 +0,0 @@
// 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_

View File

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

View File

@ -1,751 +0,0 @@
// 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_

View File

@ -1,386 +0,0 @@
// 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

@ -72,13 +72,13 @@ public:
void assign(const std::vector<T>& data);
void resize(size_t size);
void clear();
inline virtual size_t size() const;
inline size_t size() const override;
inline void set(size_t index, const T& val);
inline void setAll(const T& val);
inline void setConsecutive(const T& startVal);
inline const T& get(size_t index) const;
inline virtual T val(size_t index) const;
inline T val(size_t index) const override;
inline const T* ptr() const;
inline T* ptr();

View File

@ -46,7 +46,9 @@ namespace cvf {
// User actions (interactive responses)
static const int USERACTION_CONTINUE = 0;
#ifdef WIN32
static const int USERACTION_DEBUGBREAK = 1;
#endif
static const int USERACTION_ABORT = 2;
@ -79,7 +81,7 @@ public:
class AssertHandlerConsole : public AssertHandler
{
public:
virtual Assert::FailAction handleAssert(const char* fileName, int lineNumber, const char* expr, const char* msg);
Assert::FailAction handleAssert(const char* fileName, int lineNumber, const char* expr, const char* msg) override;
private:
static void reportToConsole(const char* fileName, int lineNumber, const char* expr, const char* msg);
@ -270,7 +272,7 @@ void AssertHandlerConsole::winCreateConsoleAndRedirectIO(bool redirectInput)
class AssertHandlerWinDialog : public AssertHandler
{
public:
virtual Assert::FailAction handleAssert(const char* fileName, int lineNumber, const char* expr, const char* msg);
Assert::FailAction handleAssert(const char* fileName, int lineNumber, const char* expr, const char* msg) override;
private:
static int handleUsingDialog(const char* fileName, int lineNumber, const char* expr, const char* msg);

View File

@ -112,7 +112,7 @@ public:
Color3f();
Color3f(float r, float g, float b);
Color3f(const Color3f& other);
Color3f(ColorIdent colorIdent);
explicit Color3f(ColorIdent colorIdent);
explicit Color3f(const Color3ub& other);
Color3f& operator=(const Color3f& rhs);
@ -158,7 +158,7 @@ public:
Color3ub();
Color3ub(ubyte r, ubyte g, ubyte b);
Color3ub(const Color3ub& other);
Color3ub(ColorIdent colorIdent);
explicit Color3ub(ColorIdent colorIdent);
explicit Color3ub(const Color3f& other);
Color3ub& operator=(const Color3ub& rhs);

View File

@ -60,7 +60,7 @@ public:
};
public:
DebugTimer(const char* prefix, OperationMode operationMode = NORMAL);
explicit DebugTimer(const char* prefix, OperationMode operationMode = NORMAL);
~DebugTimer();
void restart(const char* msg = NULL);

View File

@ -52,7 +52,7 @@ class Flags
public:
inline Flags();
inline Flags(const Flags& other);
inline Flags(FlagEnum flag);
explicit inline Flags(FlagEnum flag);
inline Flags& operator=(const Flags& rhs);
inline Flags& operator=(FlagEnum flag);

View File

@ -99,7 +99,7 @@ class ref
public:
ref(T* object = NULL);
ref(const ref& other);
template<typename T2> ref(const ref<T2>& other);
template<typename T2> explicit ref(const ref<T2>& other);
~ref();
ref& operator=(T* rhs);
@ -150,7 +150,7 @@ class cref
public:
cref(const T* object = NULL);
cref(const cref& other);
template<typename T2> cref(const cref<T2>& other);
template<typename T2> explicit cref(const cref<T2>& other);
~cref();
cref& operator=(const T* rhs);

View File

@ -374,7 +374,7 @@ bool Plane::intersect(const Plane& other, Vec3d* point, Vec3d* direction) const
CVF_ASSERT(point);
double invdet = UNDEFINED_DOUBLE;
double invdet;
Vec3d normal1 = this->normal();
Vec3d normal2 = other.normal();

View File

@ -72,7 +72,7 @@ namespace cvf {
//--------------------------------------------------------------------------------------------------
/// Write debug text to console, DevStudio output window and file (future)
//--------------------------------------------------------------------------------------------------
void Trace::show(String message)
void Trace::show(const String& message)
{
showTraceOutput(message, true);
}
@ -88,7 +88,7 @@ void Trace::show(const char* format, ...)
va_list argList;
va_start(argList, format);
const int maxFormatLength = 4000;
constexpr int maxFormatLength = 4000;
char temp[maxFormatLength + 1];
#ifdef WIN32
@ -96,7 +96,7 @@ void Trace::show(const char* format, ...)
#elif defined(CVF_ANDROID)
__android_log_print(ANDROID_LOG_DEBUG, "CVF_TAG", format, argList);
#else
vsprintf(temp, format, argList);
vsnprintf(temp, maxFormatLength, format, argList);
#endif
va_end(argList);
@ -124,7 +124,7 @@ void Trace::showFileLineNumber(const String& file, int line, const String& messa
//--------------------------------------------------------------------------------------------------
/// Show the trace output in console and DevStudio output window
//--------------------------------------------------------------------------------------------------
void Trace::showTraceOutput(String text, bool addNewLine)
void Trace::showTraceOutput(const String& text, bool addNewLine)
{
#ifdef WIN32
AllocConsole();

View File

@ -51,12 +51,12 @@ namespace cvf {
class Trace
{
public:
static void show(String message);
static void show(const String& message);
static void show(const char* format, ...);
static void showFileLineNumber(const String& file, int line, const String& message);
private:
static void showTraceOutput(String text, bool addNewLine);
static void showTraceOutput(const String& text, bool addNewLine);
};

View File

@ -22,7 +22,6 @@
//##################################################################################################
#include "cvfBase.h"
#include "cvfVector3.h"
namespace external {

View File

@ -158,6 +158,11 @@ typedef Vector3<int> Vec3i; ///< A vector with int components
typedef Vector3<uint> Vec3ui; ///< A vector with uint components
typedef Vector3<size_t> Vec3st; ///< A vector with size_t components
template<> Vec3d const Vec3d::UNDEFINED;
template<> Vec3f const Vec3f::UNDEFINED;
template<> Vec3i const Vec3i::UNDEFINED;
template<> Vec3st const Vec3st::UNDEFINED;
}
} //namespace external
#include "cvfVector3.inl"

View File

@ -491,7 +491,7 @@ inline void Vector4<S>::setZero()
template<typename S>
inline bool Vector4<S>::isZero() const
{
return (m_v[0] == 0) && (m_v[1] == 0) && (m_v[2] == 0) && (m_v[2] == 0);
return (m_v[0] == 0) && (m_v[1] == 0) && (m_v[2] == 0) && (m_v[3] == 0);
}

View File

@ -243,7 +243,6 @@ int largestComponent(const cvf::Vec3d v)
if (v.z() > maxLength)
{
maxLength = v.z();
idx = 2;
}
@ -787,8 +786,11 @@ void AABBTree::deleteInternalNodesBottomUp(AABBTreeNode* node)
auto internalNode = dynamic_cast<AABBTreeNodeInternal*>(node);
CVF_ASSERT(internalNode);
AABBTree::deleteInternalNodesBottomUp(internalNode->left());
AABBTree::deleteInternalNodesBottomUp(internalNode->right());
if (internalNode)
{
AABBTree::deleteInternalNodesBottomUp(internalNode->left());
AABBTree::deleteInternalNodesBottomUp(internalNode->right());
}
delete internalNode;
}

View File

@ -283,8 +283,8 @@ bool Ray::boxIntersect(const BoundingBox& box, Vec3d* intersectionPoint) const
// Find candidate planes; this loop can be avoided if rays cast all from the eye(assume perpsective view)
bool inside = true;
char quadrant[3];
double candidatePlane[3];
char quadrant[3]{};
double candidatePlane[3] = {0.0, 0.0, 0.0};
Vec3d min = box.min();
Vec3d max = box.max();
@ -320,17 +320,13 @@ bool Ray::boxIntersect(const BoundingBox& box, Vec3d* intersectionPoint) const
}
// Calculate T distances to candidate planes
double maxT[3];
double maxT[3]{-1.0f, -1.0f, -1.0f};
for (i = 0; i < 3; i++)
{
if (quadrant[i] != MIDDLE && m_direction[i] !=0.0f)
{
maxT[i] = (candidatePlane[i] - m_origin[i]) / m_direction[i];
}
else
{
maxT[i] = -1.0f;
}
}
// Get largest of the maxT's for final choice of intersection

View File

@ -30,9 +30,9 @@ namespace external {
//--------------------------------------------------------------------------------------------------
RigWellPath::RigWellPath()
: cvf::Object()
, objectBeingDeleted( this )
, m_hasDatumElevation( false )
, m_datumElevation( 0.0 )
, objectBeingDeleted( this )
, m_uniqueStartIndex( 0u )
, m_uniqueEndIndex( std::numeric_limits<size_t>::max() )
{
@ -43,13 +43,13 @@ RigWellPath::RigWellPath()
//--------------------------------------------------------------------------------------------------
RigWellPath::RigWellPath( const RigWellPath& rhs )
: cvf::Object()
, objectBeingDeleted( this )
, m_wellPathPoints( rhs.m_wellPathPoints )
, m_measuredDepths( rhs.m_measuredDepths )
, m_hasDatumElevation( rhs.m_hasDatumElevation )
, m_datumElevation( rhs.m_datumElevation )
, m_uniqueStartIndex( rhs.m_uniqueStartIndex )
, m_uniqueEndIndex( rhs.m_uniqueEndIndex )
, objectBeingDeleted( this )
{
CVF_ASSERT( m_wellPathPoints.size() == m_measuredDepths.size() );
}
@ -59,12 +59,12 @@ RigWellPath::RigWellPath( const RigWellPath& rhs )
//--------------------------------------------------------------------------------------------------
RigWellPath::RigWellPath( const std::vector<cvf::Vec3d>& wellPathPoints, const std::vector<double>& measuredDepths )
: cvf::Object()
, objectBeingDeleted( this )
, m_wellPathPoints( wellPathPoints )
, m_measuredDepths( measuredDepths )
, m_hasDatumElevation( false )
, m_datumElevation( 0.0 )
, m_uniqueStartIndex( 0u )
, objectBeingDeleted( this )
, m_uniqueEndIndex( std::numeric_limits<size_t>::max() )
{
CVF_ASSERT( m_wellPathPoints.size() == m_measuredDepths.size() );

View File

@ -166,7 +166,7 @@ bool HexGridIntersectionTools::planeTriangleIntersection( const cvf::Plane& plan
if ( onPosSide[2] ) topVx = 3;
// Case 3a: Two negative distances and the last is within tolerance of zero.
if ( sqrSignedDistances[topVx - 1] < sqrDistanceTolerance )
if ( topVx > 0 && sqrSignedDistances[topVx - 1] < sqrDistanceTolerance )
{
return false;
}
@ -178,7 +178,7 @@ bool HexGridIntersectionTools::planeTriangleIntersection( const cvf::Plane& plan
if ( !onPosSide[2] ) topVx = 3;
// Case 3a: Two positive distances and the last is within tolerance of zero.
if ( sqrSignedDistances[topVx - 1] > -sqrDistanceTolerance )
if ( topVx > 0 && sqrSignedDistances[topVx - 1] > -sqrDistanceTolerance )
{
return false;
}
@ -1084,7 +1084,7 @@ int HexGridIntersectionTools::planeHexIntersectionMC( const cvf::Plane& plane
}
cvf::Vec3d edgeIntersections[12];
double normDistAlongEdge[12];
double normDistAlongEdge[12]{};
// Compute vertex coordinates on the edges where we have intersections
if ( cubeIdxToCutEdgeBitfield[cubeIndex] & 1 )

View File

@ -108,7 +108,7 @@ public:
using MemberCallbackAndActiveFlag = std::pair<MemberCallback, bool>;
public:
Signal( const SignalEmitter* emitter )
explicit Signal( const SignalEmitter* emitter )
: m_emitter( emitter )
{
m_emitter->addEmittedSignal( this );

View File

@ -123,9 +123,9 @@ function build_module {
TESTTHREADS=${TESTTHREADS:-1}
if test -z "$CTEST_CONFIGURATION"
then
ctest -T Test --no-compress-output -j$TESTTHREADS
ctest -T Test --no-compress-output -j$TESTTHREADS -LE "gpu_.*"
else
ctest -j$TESTTHREADS -C $CTEST_CONFIGURATION --timeout 5000 -T Test --no-compress-output
ctest -j$TESTTHREADS -C $CTEST_CONFIGURATION --timeout 5000 -T Test --no-compress-output -LE "gpu_.*"
fi
# Convert to junit format

View File

@ -45,7 +45,10 @@ private:
void run_step(WellTestState& wtest_state, UDQState& udq_state, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& group_nwrk_data, size_t report_step, EclipseIO& io);
void run_step(WellTestState& wtest_state, UDQState& udq_state, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& group_nwrk_data, size_t report_step, double dt, EclipseIO& io);
void output(WellTestState& wtest_state, 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);
void output(const WellTestState& wtest_state, 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);
void simulate(data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& group_nwrk_data, size_t report_step, double seconds_elapsed, double time_step);
EclipseState state;

View File

@ -33,7 +33,6 @@
#include <opm/input/eclipse/Schedule/Action/SimulatorUpdate.hpp>
#include <opm/input/eclipse/Schedule/UDQ/UDQState.hpp>
#include <opm/input/eclipse/Schedule/UDQ/UDQConfig.hpp>
#include <opm/input/eclipse/Schedule/Well/PAvgCalculatorCollection.hpp>
#include <opm/input/eclipse/Schedule/Well/Well.hpp>
#include <opm/input/eclipse/Schedule/Well/WellMatcher.hpp>
#include <opm/input/eclipse/Schedule/Well/WellTestState.hpp>
@ -122,13 +121,19 @@ void msim::run_step(WellTestState& wtest_state, UDQState& udq_state, data::Solut
report_step,
seconds_elapsed,
well_data,
/* wbp = */ {},
group_nwrk_data,
{},
{},
{},
{});
/* sing_values = */ {},
/* initial_inplace = */ {},
/* inplace = */ {});
this->schedule.getUDQConfig( report_step ).eval(report_step, schedule.wellMatcher(report_step), this->st, udq_state);
this->schedule.getUDQConfig(report_step - 1)
.eval(report_step,
this->schedule,
this->schedule.wellMatcher(report_step),
this->schedule.segmentMatcherFactory(report_step),
this->st,
udq_state);
this->output(wtest_state,
udq_state,
@ -144,7 +149,10 @@ void msim::run_step(WellTestState& wtest_state, UDQState& udq_state, data::Solut
void msim::output(WellTestState& wtest_state, 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) {
void msim::output(const WellTestState& wtest_state, 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) {
RestartValue value(sol, well_data, group_nwrk_data, {});
io.writeTimeStep(this->action_state,
wtest_state,

View File

@ -66,6 +66,13 @@ public:
: NumericalProblem(message)
{}
};
class TimeSteppingBreakdown : public NumericalProblem
{
public:
explicit TimeSteppingBreakdown(const std::string &message)
: NumericalProblem(message)
{}
};
}
#endif // OPM_EXCEPTIONS_HPP

View File

@ -19,8 +19,27 @@
#ifndef OPM_TIMINGMACROS_HPP
#define OPM_TIMINGMACROS_HPP
// macros used to time blocks for example with tracy
// time block of main part of codes which do not effect performance
// This file defines macros
// OPM_TIMEBLOCK - time block of main part of codes which do not effect performance
// OPM_TIMEFUNCTION - time block of main part of codes which do not effect performance with name from function
// OPM_TIMEBLOCK_LOCAL - detailed timing which may effect performance
// OPM_TIMEFUNCTION_LOCAL - detailed timing which may effect performance with name from function
#ifndef DETAILED_PROFILING
#define DETAILED_PROFILING 0 // set to 1 to enable invasive profiling
#endif
#if USE_TRACY
#define TRACY_ENABLE 1
#include <tracy/Tracy.hpp>
#define OPM_TIMEBLOCK(blockname) ZoneNamedN(blockname, #blockname, true)
#define OPM_TIMEFUNCTION() ZoneNamedN(myname, __func__, true)
#if DETAILED_PROFILING
#define OPM_TIMEBLOCK_LOCAL(blockname) ZoneNamedN(blockname, #blockname, true)
#define OPM_TIMEFUNCTION_LOCAL() ZoneNamedN(myname, __func__, true)
#endif
#endif
#ifndef OPM_TIMEBLOCK
#define OPM_TIMEBLOCK(x)\
do { /* nothing */ } while (false)
@ -32,4 +51,14 @@
do { /* nothing */ } while (false)
#endif
#ifndef OPM_TIMEFUNCTION
#define OPM_TIMEFUNCTION()\
do { /* nothing */ } while (false)
#endif
#ifndef OPM_TIMEFUNCTION_LOCAL
#define OPM_TIMEFUNCTION_LOCAL()\
do { /* nothing */ } while (false)
#endif
#endif // OPM_TIMINGMACROS_HPP

View File

@ -0,0 +1,532 @@
/*
Copyright 2016 SINTEF ICT, Applied Mathematics.
Copyright 2016 Statoil ASA.
Copyright 2022 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_UTILITY_CSRGRAPHFROMCOORDINATES_HPP
#define OPM_UTILITY_CSRGRAPHFROMCOORDINATES_HPP
#include <cstddef>
#include <optional>
#include <type_traits>
#include <utility>
#include <vector>
/// \file
///
/// Facility for converting collection of region ID pairs into a sparse
/// (CSR) adjacency matrix representation of a graph. Supports O(nnz)
/// compression.
namespace Opm { namespace utility {
/// Form CSR adjacency matrix representation of unstructured graphs.
/// Optionally maps vertex pairs to compressed indices to enable O(1)
/// per-element lookup in assembly-like operations.
///
/// \tparam VertexID ID type of an abstract vertex in the graph. Could
/// for instance be used to represent a cell index or a region index.
/// Must be an integral type.
///
/// \tparam TrackCompressedIdx Whether or not to form a mapping relation
/// for vertex pairs to compressed indices. Default value, false,
/// bypasses this mapping relation and conserves memory.
///
/// \tparam PermitSelfConnections Whether or not to allow connections of
/// the form i->i--i.e., diagonal elements. Default value, \c false,
/// does not generate connections from a vertex to itself.
template <typename VertexID = int, bool TrackCompressedIdx = false, bool PermitSelfConnections = false>
class CSRGraphFromCoordinates
{
private:
using BaseVertexID = std::remove_cv_t<VertexID>;
static_assert(std::is_integral_v<BaseVertexID>,
"The VertexID must be an integral type");
public:
/// Representation of neighbouring regions.
using Neighbours = std::vector<BaseVertexID>;
/// Offset into neighbour array.
using Offset = typename Neighbours::size_type;
/// CSR start pointers.
using Start = std::vector<Offset>;
/// Clear all internal buffers, but preserve allocated capacity.
void clear();
/// Add flow rate connection between regions.
///
/// \param[in] v1 First vertex in vertex pair. Used as row index.
///
/// \param[in] v2 Second vertex in vertex pair. Used as column index.
///
/// If both vertex IDs are the same, and class template argument \c
/// PermitSelfConnections is in its default state of \c false, then
/// this function does nothing.
void addConnection(VertexID v1, VertexID v2);
/// Form CSR adjacency matrix representation of input graph from
/// connections established in previous calls to addConnection().
///
/// \param[in] maxNumVertices Number of rows in resulting CSR
/// matrix. If prior calls to addConnection() supply vertex IDs
/// (row indices) greater than or equal to \p maxNumVertices,
/// then method compress() will throw \code
/// std::invalid_argument \endcode.
///
/// \param[in] expandExistingIdxMap Whether or not preserve and
/// update the existing compressed index map. This is
/// potentially useful for the case of adding new connections to
/// an already compressed graph. The default setting, \c false,
/// will disregard any existing index map and create the index
/// map from scratch. This runtime parameter is unused if the
/// class is not configured to track compressed indices through
/// the TrackCompressedIdx class parameter.
void compress(Offset maxNumVertices,
bool expandExistingIdxMap = false);
/// Retrieve number of rows (source entities) in input graph.
/// Corresponds to value of argument passed to compress(). Valid
/// only after calling compress().
Offset numVertices() const;
/// Retrieve number of edges (non-zero matrix elements) in input
/// graph.
Offset numEdges() const;
/// Read-only access to compressed structure's start pointers.
const Start& startPointers() const
{
return this->csr_.startPointers();
}
/// Read-only access to compressed structure's column indices,
/// ascendingly sorted per row.
const Neighbours& columnIndices() const
{
return this->csr_.columnIndices();
}
/// Read-only access to mapping from input order vertex pairs to
/// compressed structure's edge index (location in ja/sa).
///
/// Available only if client code sets TrackCompressedIdx=true.
/// Compiler diagnostic, typically referring to 'enable_if', if
/// client code tries to call this function without setting
/// class parameter TrackCompressedIdx=true.
template <typename Ret = const Start&>
std::enable_if_t<TrackCompressedIdx, Ret> compressedIndexMap() const
{
return this->csr_.compressedIndexMap();
}
// MessageBufferType API should be similar to Dune::MessageBufferIF
template <class MessageBufferType>
void write(MessageBufferType& buffer) const
{
this->csr_.write(buffer);
}
// MessageBufferType API should be similar to Dune::MessageBufferIF
template <class MessageBufferType>
void read(MessageBufferType& buffer)
{
auto other = CSR{};
other.read(buffer);
this->uncompressed_
.add(other.maxRowID(),
other.maxColID(),
other.coordinateFormatRowIndices(),
other.columnIndices());
}
private:
/// Coordinate format representation of individual contributions to
/// inter-region flows.
class Connections
{
public:
/// Add contributions from a single inter-region connection.
///
/// \param[in] r1 Source region. Zero-based region index/ID.
///
/// \param[in] r2 Destination region. Zero-based region index.
void add(VertexID v1, VertexID v2);
/// Add contributions from multiple inter-region connections.
///
/// \param[in] maxRowIdx Maximum row (source region) index
/// across all new inter-region connection contributions.
///
/// \param[in] maxColIdx Maximum column (destination region)
/// index across all new inter-region contributions.
///
/// \param[in] rows Source region indices for all new
/// inter-region connection contributions.
///
/// \param[in] cols Destination region indices for all new
/// inter-region connection contributions.
void add(VertexID maxRowIdx,
VertexID maxColIdx,
const Neighbours& rows,
const Neighbours& cols);
/// Clear internal tables. Preserve allocated capacity.
void clear();
/// Predicate.
///
/// \return Whether or not internal tables are empty.
bool empty() const;
/// Whether or not internal tables meet size consistency
/// requirements.
bool isValid() const;
/// Maximum zero-based row index.
std::optional<BaseVertexID> maxRow() const;
/// Maximum zero-based column index.
std::optional<BaseVertexID> maxCol() const;
/// Number of uncompressed contributions in internal tables.
typename Neighbours::size_type numContributions() const;
/// Read-only access to uncompressed row indices.
const Neighbours& rowIndices() const;
/// Read-only access to uncompressed column indices.
const Neighbours& columnIndices() const;
private:
/// Zero-based row/source region indices.
Neighbours i_{};
/// Zero-based column/destination region indices.
Neighbours j_{};
/// Maximum row index in \code this->i_ \endcode.
std::optional<VertexID> max_i_{};
/// Maximum column index in \code this->j_ \endcode.
std::optional<VertexID> max_j_{};
};
/// Compressed sparse row representation of inter-region flow rates
///
/// Row and column indices are zero-based vertex IDs. Column
/// indices ascendingly sorted per row.
class CSR
{
public:
/// Merge coordinate format into existing CSR map.
///
/// \param[in] conns Coordinate representation of new
/// contributions.
///
/// \param[in] maxNumVertices Maximum number of vertices.
///
/// \param[in] expandExistingIdxMap Whether or not preserve and
/// update the existing compressed index map. This is
/// potentially useful for the case of adding new connections
/// to an already compressed graph. The default setting, \c
/// false, will disregard any existing index map and create
/// the index map from scratch. This runtime parameter is
/// unused if the class is not configured to track compressed
/// indices through the TrackCompressedIdx class parameter.
void merge(const Connections& conns,
const Offset maxNumVertices,
const bool expandExistingIdxMap);
/// Total number of rows in compressed map structure.
Offset numRows() const;
/// Maximum zero-based row index encountered in mapped structure.
BaseVertexID maxRowID() const;
/// Maximum zero-based column index encountered in mapped structure.
BaseVertexID maxColID() const;
/// Read-only access to compressed structure's start pointers.
const Start& startPointers() const;
/// Read-only access to compressed structure's column indices,
/// ascendingly sorted per rwo.
const Neighbours& columnIndices() const;
/// Coordinate format row index vector. Expanded from \code
/// startPointers() \endcode.
Neighbours coordinateFormatRowIndices() const;
template <typename Ret = const Start&>
std::enable_if_t<TrackCompressedIdx, Ret> compressedIndexMap() const
{
return this->compressedIdx_;
}
// MessageBufferType API should be similar to Dune::MessageBufferIF
template <class MessageBufferType>
void write(MessageBufferType& buffer) const
{
this->writeVector(this->ia_, buffer);
this->writeVector(this->ja_, buffer);
if constexpr (TrackCompressedIdx) {
this->writeVector(this->compressedIdx_, buffer);
}
buffer.write(this->numRows_);
buffer.write(this->numCols_);
}
// MessageBufferType API should be similar to Dune::MessageBufferIF
template <class MessageBufferType>
void read(MessageBufferType& buffer)
{
this->readVector(buffer, this->ia_);
this->readVector(buffer, this->ja_);
if constexpr (TrackCompressedIdx) {
this->readVector(buffer, this->compressedIdx_);
}
buffer.read(this->numRows_);
buffer.read(this->numCols_);
}
/// Clear internal tables. Preserve allocated capacity.
void clear();
private:
struct EmptyPlaceHolder {};
/// Start pointers.
Start ia_{};
/// Column indices. Ascendingly sorted per row once structure
/// is fully established.
Neighbours ja_{};
/// Destination index in compressed representation. Vector of
/// size equal to number of \c addConnection() calls if client
/// code requests that compressed indices be tracked (i.e., when
/// parameter TrackCompressedIdx == true); Empty structure
/// otherwise (default setting).
std::conditional_t<TrackCompressedIdx, Start, EmptyPlaceHolder> compressedIdx_{};
/// Number of active rows in compressed map structure.
BaseVertexID numRows_{};
/// Number of active columns in compressed map structure.
/// Tracked as the maximum column index plus one.
BaseVertexID numCols_{};
// ---------------------------------------------------------
// Implementation of read()/write()
// ---------------------------------------------------------
template <typename T, class A, class MessageBufferType>
void writeVector(const std::vector<T,A>& vec,
MessageBufferType& buffer) const
{
const auto n = vec.size();
buffer.write(n);
for (const auto& x : vec) {
buffer.write(x);
}
}
template <class MessageBufferType, typename T, class A>
void readVector(MessageBufferType& buffer,
std::vector<T,A>& vec)
{
auto n = 0 * vec.size();
buffer.read(n);
vec.resize(n);
for (auto& x : vec) {
buffer.read(x);
}
}
// ---------------------------------------------------------
// Implementation of merge()
// ---------------------------------------------------------
/// Incorporate new, coordinate format contributions into
/// existing, possibly empty, CSR mapping structure.
///
/// On exit the ia_ array holds the proper start pointers while
/// ja_ holds the corresponding column indices albeit possibly
/// repeated and unsorted.
///
/// \param[in] rows Row indices of all, possibly repeated,
/// coordinate format input contributions. Start pointers \c
/// ia_ updated to account for new entries.
///
/// \param[in] cols Column index of coordinate format intput
/// structure. Inserted into \c ja_ according to its
/// corresponding row index.
///
/// \param[in] maxRowID Maximum index in \p rows. Needed to
/// ensure proper size of \c ia_.
///
/// \param[in] maxColID Maximum index in \p cols.
///
/// \param[in] expandExistingIdxMap Whether or not preserve and
/// update the existing compressed index map. This is
/// potentially useful for the case of adding new connections
/// to an already compressed graph. The default setting, \c
/// false, will disregard any existing index map and create
/// the index map from scratch. This runtime parameter is
/// unused if the class is not configured to track compressed
/// indices through the TrackCompressedIdx class parameter.
void assemble(const Neighbours& rows,
const Neighbours& cols,
BaseVertexID maxRowID,
BaseVertexID maxColID,
bool expandExistingIdxMap);
/// Sort column indices per row and compress repeated column
/// indices down to a single unique element per row. Sum
/// repeated values
///
/// On exit the \c ia_ and \c ja_ arrays all have their
/// expected, canonical structure.
///
/// \param[in] maxNumVertices Maximum number of vertices
/// supported by final compressed mapping structure. Ignored
/// if less than active number of rows.
void compress(const Offset maxNumVertices);
/// Sort column indices within each mapped row.
///
/// On exit \c ja_ has ascendingly sorted column indices, albeit
/// possibly with repeated entries. This function also updates
/// \c compressedIdx_, if applicable, to account for the new
/// locations of the non-zero elements in the grouped structure.
void sortColumnIndicesPerRow();
/// Condense repeated column indices per row down to a single
/// unique entry for each.
///
/// Assumes that each row has ascendingly sorted column indices
/// in \c ja_ and must therefore be called after member function
/// sortColumnIndicesPerRow(). On exit, \c ja_ has its final
/// canonical structure and \c compressedIdx_, if applicable,
/// knows the final location of each non-zero contribution in
/// the input coordinate format.
void condenseDuplicates();
// ---------------------------------------------------------
// Implementation of assemble()
// ---------------------------------------------------------
/// Position end pointers at start of row to prepare for column
/// index grouping by corresponding row index.
///
/// Also counts total number of non-zero elements, possibly
/// including repetitions, in \code this->ia_[0] \endcode.
///
/// \param[in] numRows Number of rows in final compressed
/// structure. Used to allocate \code this->ia_ \endcode.
///
/// \param[in] rowIdx Row indices of all, possibly repeated,
/// coordinate format input contributions. Needed to count
/// the number of possibly repeated column index entries per
/// row.
void preparePushbackRowGrouping(const int numRows,
const Neighbours& rowIdx);
/// Group column indices by corresponding row index and track
/// grouped location of original coordinate format element
///
/// Appends grouped location to \c compressedIdx_ if needed.
///
/// \param[in] rowIdx Row index of coordinate format input
/// structure. Used as grouping key.
///
/// \param[in] colIdx Column index of coordinate format intput
/// structure. Inserted into \c ja_ according to its
/// corresponding row index.
void groupAndTrackColumnIndicesByRow(const Neighbours& rowIdx,
const Neighbours& colIdx);
// ---------------------------------------------------------
// General utilities
// ---------------------------------------------------------
/// Transpose connectivity structure.
///
/// Essentially swaps the roles of rows and columns. Also used
/// as a basic building block for sortColumnIndicesPerRow().
void transpose();
/// Condense sequences of repeated column indices in a single
/// map row down to a single copy of each unique column index.
///
/// Appends new unique column indices to \code ja_ \endcode
///
/// Assumes that the map row has ascendingly sorted column
/// indices and therefore has the same requirements as
/// std::unique. Will also update the internal compressedIdx_
/// mapping, if needed, to record new compressed locations for
/// the current, uncompressed, non-zero map elements.
///
/// \param[in] begin Start of map row that contains possibly
/// repeated column indices.
///
/// \param[in] end One-past-end of map row that contains
/// possibly repeated column indices.
void condenseAndTrackUniqueColumnsForSingleRow(typename Neighbours::const_iterator begin,
typename Neighbours::const_iterator end);
/// Update \c compressedIdx_ mapping, if needed, to account for
/// column index reshuffling.
///
/// \param[in] compressedIdx New compressed index locations of
/// the non-zero map entries.
///
/// \param[in] numOrigNNZ Number of existing, unique NNZs
/// (edges) in graph. Needed to support calling add() after
/// compress() when TrackCompressedIdx is true.
void remapCompressedIndex(Start&& compressedIdx,
std::optional<typename Start::size_type> numOrigNNZ = std::nullopt);
};
/// Accumulated coordinate format contributions that have not yet
/// been added to the final CSR structure.
Connections uncompressed_;
/// Canonical representation of unique inter-region flow rates.
CSR csr_;
};
}} // namespace Opm::utility
// Actual implementation of member functions in _impl.hpp file.
#include <opm/common/utility/CSRGraphFromCoordinates_impl.hpp>
#endif // OPM_UTILITY_CSRGRAPHFROMCOORDINATES_HPP

View File

@ -0,0 +1,610 @@
/*
Copyright 2016 SINTEF ICT, Applied Mathematics.
Copyright 2016 Statoil ASA.
Copyright 2022 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 <algorithm>
#include <cassert>
#include <exception>
#include <iterator>
#include <optional>
#include <stdexcept>
#include <string>
#include <utility>
#include <vector>
// ---------------------------------------------------------------------
// Class Opm::utility::CSRGraphFromCoordinates::Connections
// ---------------------------------------------------------------------
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
void
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
Connections::add(const VertexID v1, const VertexID v2)
{
this->i_.push_back(v1);
this->j_.push_back(v2);
this->max_i_ = std::max(this->max_i_.value_or(BaseVertexID{}), this->i_.back());
this->max_j_ = std::max(this->max_j_.value_or(BaseVertexID{}), this->j_.back());
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
void
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
Connections::add(VertexID maxRowIdx,
VertexID maxColIdx,
const Neighbours& rows,
const Neighbours& cols)
{
if (cols.size() != rows.size()) {
throw std::invalid_argument {
"Coordinate format column index table size does not match "
"row index table size"
};
}
this->i_.insert(this->i_.end(), rows .begin(), rows .end());
this->j_.insert(this->j_.end(), cols .begin(), cols .end());
this->max_i_ = std::max(this->max_i_.value_or(BaseVertexID{}), maxRowIdx);
this->max_j_ = std::max(this->max_j_.value_or(BaseVertexID{}), maxColIdx);
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
void
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
Connections::clear()
{
this->j_.clear();
this->i_.clear();
this->max_i_.reset();
this->max_j_.reset();
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
bool
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
Connections::empty() const
{
return this->i_.empty();
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
bool
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
Connections::isValid() const
{
return this->i_.size() == this->j_.size();
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
std::optional<typename Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::BaseVertexID>
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
Connections::maxRow() const
{
return this->max_i_;
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
std::optional<typename Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::BaseVertexID>
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
Connections::maxCol() const
{
return this->max_j_;
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
typename Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::Neighbours::size_type
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
Connections::numContributions() const
{
return this->i_.size();
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
const typename Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::Neighbours&
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
Connections::rowIndices() const
{
return this->i_;
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
const typename Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::Neighbours&
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
Connections::columnIndices() const
{
return this->j_;
}
// =====================================================================
// ---------------------------------------------------------------------
// Class Opm::utility::CSRGraphFromCoordinates::CSR
// ---------------------------------------------------------------------
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
void
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
CSR::merge(const Connections& conns,
const Offset maxNumVertices,
const bool expandExistingIdxMap)
{
const auto maxRow = conns.maxRow();
if (maxRow.has_value() &&
(static_cast<Offset>(*maxRow) >= maxNumVertices))
{
throw std::invalid_argument {
"Number of vertices in input graph (" +
std::to_string(*maxRow) + ") "
"exceeds maximum graph size implied by explicit size of "
"adjacency matrix (" + std::to_string(maxNumVertices) + ')'
};
}
this->assemble(conns.rowIndices(), conns.columnIndices(),
maxRow.value_or(BaseVertexID{0}),
conns.maxCol().value_or(BaseVertexID{0}),
expandExistingIdxMap);
this->compress(maxNumVertices);
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
typename Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::Offset
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
CSR::numRows() const
{
return this->startPointers().empty()
? 0 : this->startPointers().size() - 1;
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
typename Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::BaseVertexID
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
CSR::maxRowID() const
{
return this->numRows_ - 1;
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
typename Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::BaseVertexID
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
CSR::maxColID() const
{
return this->numCols_ - 1;
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
const typename Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::Start&
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
CSR::startPointers() const
{
return this->ia_;
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
const typename Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::Neighbours&
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
CSR::columnIndices() const
{
return this->ja_;
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
typename Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::Neighbours
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
CSR::coordinateFormatRowIndices() const
{
auto rowIdx = Neighbours{};
if (this->ia_.empty()) {
return rowIdx;
}
rowIdx.reserve(this->ia_.back());
auto row = BaseVertexID{};
const auto m = this->ia_.size() - 1;
for (auto i = 0*m; i < m; ++i, ++row) {
const auto n = this->ia_[i + 1] - this->ia_[i + 0];
rowIdx.insert(rowIdx.end(), n, row);
}
return rowIdx;
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
void
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
CSR::clear()
{
this->ia_.clear();
this->ja_.clear();
if constexpr (TrackCompressedIdx) {
this->compressedIdx_.clear();
}
this->numRows_ = 0;
this->numCols_ = 0;
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
void
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
CSR::assemble(const Neighbours& rows,
const Neighbours& cols,
const BaseVertexID maxRowIdx,
const BaseVertexID maxColIdx,
[[maybe_unused]] const bool expandExistingIdxMap)
{
[[maybe_unused]] auto compressedIdx = this->compressedIdx_;
[[maybe_unused]] const auto numOrigNNZ = this->ja_.size();
auto i = this->coordinateFormatRowIndices();
i.insert(i.end(), rows.begin(), rows.end());
auto j = this->ja_;
j.insert(j.end(), cols.begin(), cols.end());
const auto thisNumRows = std::max(this->numRows_, maxRowIdx + 1);
const auto thisNumCols = std::max(this->numCols_, maxColIdx + 1);
this->preparePushbackRowGrouping(thisNumRows, i);
this->groupAndTrackColumnIndicesByRow(i, j);
if constexpr (TrackCompressedIdx) {
if (expandExistingIdxMap) {
this->remapCompressedIndex(std::move(compressedIdx), numOrigNNZ);
}
}
this->numRows_ = thisNumRows;
this->numCols_ = thisNumCols;
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
void
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
CSR::compress(const Offset maxNumVertices)
{
if (this->numRows() > maxNumVertices) {
throw std::invalid_argument {
"Number of vertices in input graph (" +
std::to_string(this->numRows()) + ") "
"exceeds maximum graph size implied by explicit size of "
"adjacency matrix (" + std::to_string(maxNumVertices) + ')'
};
}
this->sortColumnIndicesPerRow();
// Must be called *after* sortColumnIndicesPerRow().
this->condenseDuplicates();
const auto nRows = this->startPointers().size() - 1;
if (nRows < maxNumVertices) {
this->ia_.insert(this->ia_.end(),
maxNumVertices - nRows,
this->startPointers().back());
}
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
void
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
CSR::sortColumnIndicesPerRow()
{
// Transposition is, in this context, effectively a linear time (O(nnz))
// bucket insertion procedure. In other words transposing the structure
// twice creates a structure with column indices in (ascendingly) sorted
// order.
this->transpose();
this->transpose();
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
void
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
CSR::condenseDuplicates()
{
// Note: Must be called *after* sortColumnIndicesPerRow().
const auto colIdx = this->ja_;
auto end = colIdx.begin();
this->ja_.clear();
[[maybe_unused]] auto compressedIdx = this->compressedIdx_;
if constexpr (TrackCompressedIdx) {
this->compressedIdx_.clear();
}
const auto numRows = this->ia_.size() - 1;
for (auto row = 0*numRows; row < numRows; ++row) {
auto begin = end;
std::advance(end, this->ia_[row + 1] - this->ia_[row + 0]);
const auto q = this->ja_.size();
this->condenseAndTrackUniqueColumnsForSingleRow(begin, end);
this->ia_[row + 0] = q;
}
if constexpr (TrackCompressedIdx) {
this->remapCompressedIndex(std::move(compressedIdx));
}
// Record final table sizes.
this->ia_.back() = this->ja_.size();
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
void
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
CSR::preparePushbackRowGrouping(const int numRows,
const Neighbours& rowIdx)
{
assert (numRows >= 0);
this->ia_.assign(numRows + 1, 0);
// Count number of neighbouring vertices for each row. Accumulate in
// "next" bin since we're positioning the end pointers.
for (const auto& row : rowIdx) {
this->ia_[row + 1] += 1;
}
// Position "end" pointers.
//
// After this loop, ia_[i + 1] points to the *start* of the range of the
// column indices/neighbouring vertices of vertex 'i'. This, in turn,
// enables using the statement ja_[ia_[i+1]++] = v in groupAndTrack()
// to insert vertex 'v' as a neighbour, at the end of the range of known
// neighbours, *and* advance the end pointer of row/vertex 'i'. We use
// ia_[0] as an accumulator for the total number of neighbouring
// vertices in the graph.
//
// Note index range: 1..numRows inclusive.
for (typename Start::size_type i = 1, n = numRows; i <= n; ++i) {
this->ia_[0] += this->ia_[i];
this->ia_[i] = this->ia_[0] - this->ia_[i];
}
assert (this->ia_[0] == rowIdx.size());
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
void
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
CSR::groupAndTrackColumnIndicesByRow(const Neighbours& rowIdx,
const Neighbours& colIdx)
{
assert (this->ia_[0] == rowIdx.size());
const auto nnz = rowIdx.size();
this->ja_.resize(nnz);
if constexpr (TrackCompressedIdx) {
this->compressedIdx_.clear();
this->compressedIdx_.reserve(nnz);
}
// Group/insert column indices according to their associate vertex/row
// index.
//
// At the start of the loop the end pointers ia_[i+1], formed in
// preparePushback(), are positioned at the *start* of the column index
// range associated to vertex 'i'. After this loop all vertices
// neighbouring vertex 'i' will be placed consecutively, in order of
// appearance, into ja_. Furthermore, the row pointers ia_ will have
// their final position.
//
// The statement ja_[ia_[i+1]++] = v, split into two statements using
// the helper object 'k', inserts 'v' as a neighbouring vertex of vertex
// 'i' *and* advances the end pointer ia_[i+1] of that vertex. We use
// and maintain the invariant that ia_[i+1] at all times records the
// insertion point of the next neighbouring vertex of vertex 'i'. When
// the list of neighbouring vertices for vertex 'i' has been exhausted,
// ia_[i+1] will hold the start position for in ja_ for vertex i+1.
for (auto nz = 0*nnz; nz < nnz; ++nz) {
const auto k = this->ia_[rowIdx[nz] + 1] ++;
this->ja_[k] = colIdx[nz];
if constexpr (TrackCompressedIdx) {
this->compressedIdx_.push_back(k);
}
}
this->ia_[0] = 0;
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
void
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
CSR::transpose()
{
[[maybe_unused]] auto compressedIdx = this->compressedIdx_;
{
const auto rowIdx = this->coordinateFormatRowIndices();
const auto colIdx = this->ja_;
this->preparePushbackRowGrouping(this->numCols_, colIdx);
// Note parameter order. Transposition switches role of rows and
// columns.
this->groupAndTrackColumnIndicesByRow(colIdx, rowIdx);
}
if constexpr (TrackCompressedIdx) {
this->remapCompressedIndex(std::move(compressedIdx));
}
std::swap(this->numRows_, this->numCols_);
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
void
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
CSR::condenseAndTrackUniqueColumnsForSingleRow(typename Neighbours::const_iterator begin,
typename Neighbours::const_iterator end)
{
// We assume that we're only called *after* sortColumnIndicesPerRow()
// whence duplicate elements appear consecutively in [begin, end).
//
// Note: This is essentially the same as std::unique(begin, end) save
// for the return value and the fact that we additionally record the
// 'compressedIdx_' mapping. That mapping enables subsequent, decoupled
// accumulation of the 'sa_' contributions.
while (begin != end) {
// Note: Order of ja_ and compressedIdx_ matters here.
if constexpr (TrackCompressedIdx) {
this->compressedIdx_.push_back(this->ja_.size());
}
this->ja_.push_back(*begin);
auto next_unique =
std::find_if(begin, end, [last = this->ja_.back()]
(const auto j) { return j != last; });
if constexpr (TrackCompressedIdx) {
// Number of duplicate elements in [begin, next_unique).
const auto ndup = std::distance(begin, next_unique);
if (ndup > 1) {
// Insert ndup - 1 copies of .back() to represent the
// duplicate pairs in [begin, next_unique). We subtract one
// to account for .push_back() above representing *begin.
this->compressedIdx_.insert(this->compressedIdx_.end(),
ndup - 1,
this->compressedIdx_.back());
}
}
begin = next_unique;
}
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
void
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::CSR::
remapCompressedIndex([[maybe_unused]] Start&& compressedIdx,
[[maybe_unused]] std::optional<typename Start::size_type> numOrig)
{
if constexpr (TrackCompressedIdx) {
for (auto& i : compressedIdx) {
i = this->compressedIdx_[i];
}
if (numOrig.has_value() && (*numOrig < this->compressedIdx_.size())) {
// Client called add() after compress(). Remap existing portion
// of compressedIdx (above), and append new entries (here).
compressedIdx
.insert(compressedIdx.end(),
this->compressedIdx_.begin() + *numOrig,
this->compressedIdx_.end());
}
this->compressedIdx_.swap(compressedIdx);
}
}
// =====================================================================
// ---------------------------------------------------------------------
// Class Opm::utility::CSRGraphFromCoordinates
// ---------------------------------------------------------------------
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
void Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::clear()
{
this->uncompressed_.clear();
this->csr_.clear();
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
void
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
addConnection(const VertexID v1, const VertexID v2)
{
if ((v1 < 0) || (v2 < 0)) {
throw std::invalid_argument {
"Vertex IDs must be non-negative. Got (v1,v2) = ("
+ std::to_string(v1) + ", " + std::to_string(v2)
+ ')'
};
}
if constexpr (! PermitSelfConnections) {
if (v1 == v2) {
// Ignore self connections.
return;
}
}
this->uncompressed_.add(v1, v2);
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
void
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::
compress(const Offset maxNumVertices, const bool expandExistingIdxMap)
{
if (! this->uncompressed_.isValid()) {
throw std::logic_error {
"Cannot compress invalid connection list"
};
}
this->csr_.merge(this->uncompressed_, maxNumVertices, expandExistingIdxMap);
this->uncompressed_.clear();
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
typename Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::Offset
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::numVertices() const
{
return this->csr_.numRows();
}
template <typename VertexID, bool TrackCompressedIdx, bool PermitSelfConnections>
typename Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::Offset
Opm::utility::CSRGraphFromCoordinates<VertexID, TrackCompressedIdx, PermitSelfConnections>::numEdges() const
{
const auto& ia = this->startPointers();
return ia.empty() ? 0 : ia.back();
}

View File

@ -20,11 +20,12 @@
#ifndef COMMON_UTIL_NUMERIC_CMP
#define COMMON_UTIL_NUMERIC_CMP
#include <cstddef>
#include <vector>
#include <type_traits>
#include <cmath>
#include <algorithm>
#include <cmath>
#include <cstddef>
#include <cstring>
#include <type_traits>
#include <vector>
namespace Opm {
@ -109,7 +110,7 @@ namespace Opm {
template<typename T>
bool array_equal(const T* p1, const T* p2, size_t num_elements, T abs_eps, T rel_eps) {
if (memcmp(p1 , p2 , num_elements * sizeof * p1) == 0)
if (std::memcmp(p1 , p2 , num_elements * sizeof * p1) == 0)
return true;
else {
size_t index;

View File

@ -22,86 +22,80 @@
#define OPM_LINEARINTERPOLATION_HEADER_INCLUDED
#include <vector>
#include <algorithm>
#include <tuple>
#include <vector>
namespace Opm
{
inline int tableIndex(const std::vector<double>& table, double x)
{
// Returns an index in an ordered table such that x is between
// table[j] and table[j+1]. If x is out of range, first or last
// interval is returned; Binary search.
int n = table.size() - 1;
if (n < 2) {
return 0;
}
int jl = 0;
int ju = n;
bool ascend = (table[n] > table[0]);
while (ju - jl > 1) {
int jm = (ju + jl)/2; // Compute a midpoint
if ( (x >= table[jm]) == ascend) {
jl = jm; // Replace lower limit
} else {
ju = jm; // Replace upper limit
}
}
return jl;
}
inline double linearInterpolationDerivative(const std::vector<double>& xv,
const std::vector<double>& yv, double x)
{
// Extrapolates if x is outside xv
int ix1 = tableIndex(xv, x);
int ix2 = ix1 + 1;
return (yv[ix2] - yv[ix1])/(xv[ix2] - xv[ix1]);
}
inline double linearInterpolation(const std::vector<double>& xv,
const std::vector<double>& yv, double x)
{
// Extrapolates if x is outside xv
int ix1 = tableIndex(xv, x);
int ix2 = ix1 + 1;
return (yv[ix2] - yv[ix1])/(xv[ix2] - xv[ix1])*(x - xv[ix1]) + yv[ix1];
}
inline double linearInterpolationNoExtrapolation(const std::vector<double>& xv,
const std::vector<double>& yv, double x)
{
// Return end values if x is outside xv
if (x < xv.front()) {
return yv.front();
}
if (x > xv.back()) {
return yv.back();
}
int ix1 = tableIndex(xv, x);
int ix2 = ix1 + 1;
return (yv[ix2] - yv[ix1])/(xv[ix2] - xv[ix1])*(x - xv[ix1]) + yv[ix1];
}
inline double linearInterpolation(const std::vector<double>& xv,
const std::vector<double>& yv,
double x, int& ix1)
{
// Extrapolates if x is outside xv
ix1 = tableIndex(xv, x);
int ix2 = ix1 + 1;
return (yv[ix2] - yv[ix1])/(xv[ix2] - xv[ix1])*(x - xv[ix1]) + yv[ix1];
//! \brief Returns an index in an ordered table such that x is between
//! table[j] and table[j+1].
//! \details If x is out of bounds, it returns a clamped index
inline int tableIndex(const std::vector<double>& table, double x)
{
if (table.size() < 2)
return 0;
const auto lower = std::lower_bound(table.begin(), table.end(), x);
if (lower == table.end())
return table.size()-2;
else if (lower == table.begin())
return 0;
else
return std::distance(table.begin(), lower)-1;
}
inline std::pair<double, int>
linearInterpolationSlope(const std::vector<double>& xv,
const std::vector<double>& yv,
const double x)
{
const auto i = Opm::tableIndex(xv, x);
return { (yv[i + 1] - yv[i]) / (xv[i + 1] - xv[i]), i };
}
inline double linearInterpolationDerivative(const std::vector<double>& xv,
const std::vector<double>& yv, double x)
{
// Extrapolates if x is outside xv
return linearInterpolationSlope(xv, yv, x).first;
}
inline double linearInterpolation(const std::vector<double>& xv,
const std::vector<double>& yv, double x)
{
// Extrapolates if x is outside xv
const auto& [t, i] = linearInterpolationSlope(xv, yv, x);
return t * (x - xv[i]) + yv[i];
}
inline double linearInterpolationNoExtrapolation(const std::vector<double>& xv,
const std::vector<double>& yv, double x)
{
// Return end values if x is outside xv
if (x < xv.front()) {
return yv.front();
}
if (x > xv.back()) {
return yv.back();
}
return linearInterpolation(xv, yv, x);
}
inline double linearInterpolation(const std::vector<double>& xv,
const std::vector<double>& yv,
double x, int& ix1)
{
// Extrapolates if x is outside xv
double t;
std::tie(t, ix1) = linearInterpolationSlope(xv, yv, x);
return t * (x - xv[ix1]) + yv[ix1];
}
} // namespace Opm
#endif // OPM_LINEARINTERPOLATION_HEADER_INCLUDED

View File

@ -52,7 +52,7 @@ namespace Opm {
/// @brief
/// @todo Doc me!
/// @return
virtual std::string getTag() const {return ID_xmltag__param;}
std::string getTag() const override { return ID_xmltag__param; }
/// @brief
/// @todo Doc me!
/// @param

View File

@ -93,7 +93,7 @@ namespace Opm {
// From ParameterMapItem
virtual ~ParameterGroup();
virtual std::string getTag() const;
std::string getTag() const override;
/// \brief A constructor typically used to initialize a
/// ParameterGroup from command-line arguments.

View File

@ -34,7 +34,7 @@ namespace Opm {
typedef std::vector< DeckItem >::const_iterator const_iterator;
DeckRecord() = default;
DeckRecord( std::vector< DeckItem >&& items, const bool check_for_duplicate_names = true );
explicit DeckRecord( std::vector< DeckItem >&& items, const bool check_for_duplicate_names = true );
static DeckRecord serializationTestObject();

View File

@ -27,6 +27,7 @@
namespace Opm {
class Deck;
class ErrorGuard;
enum class Section {
RUNSPEC,
@ -63,6 +64,7 @@ class DeckSection : public DeckView {
// the right order
static bool checkSectionTopology(const Deck& deck,
const Parser&,
ErrorGuard& errorGuard,
bool ensureKeywordSectionAffiliation = false);

View File

@ -38,7 +38,7 @@ namespace Opm {
class DeckTree {
public:
DeckTree() = default;
DeckTree(const std::string&);
explicit DeckTree(const std::string&);
const std::string& parent(const std::string& fname) const;
bool includes(const std::string& parent_file, const std::string& include_file) const;

View File

@ -33,7 +33,7 @@ public:
struct Iterator : public storage_type::iterator {
Iterator(storage_type::const_iterator inner_iter) :
explicit Iterator(storage_type::const_iterator inner_iter) :
inner(inner_iter)
{}

View File

@ -124,7 +124,7 @@ namespace Opm {
AquiferCT() = default;
AquiferCT(const TableManager& tables, const Deck& deck);
AquiferCT(const std::vector<AquiferCT::AQUCT_data>& data);
explicit AquiferCT(const std::vector<AquiferCT::AQUCT_data>& data);
void loadFromRestart(const RestartIO::RstAquifer& rst,
const TableManager& tables);

View File

@ -20,13 +20,15 @@
#ifndef OPM_NUMERICALAQUIFERS_HPP
#define OPM_NUMERICALAQUIFERS_HPP
#include <opm/input/eclipse/EclipseState/Aquifer/NumericalAquifer/SingleNumericalAquifer.hpp>
#include <cstddef>
#include <map>
#include <unordered_map>
#include <vector>
#include <stddef.h>
#include <opm/input/eclipse/EclipseState/Aquifer/NumericalAquifer/SingleNumericalAquifer.hpp>
namespace Opm {
class Deck;
class EclipseGrid;
@ -46,6 +48,7 @@ namespace Opm {
bool operator==(const NumericalAquifers& other) const;
std::unordered_map<size_t, const NumericalAquiferCell*> allAquiferCells() const;
std::vector<std::size_t> allAquiferCellIds() const;
std::unordered_map<size_t, double> aquiferCellVolumes() const;

View File

@ -21,6 +21,7 @@
#define OPM_ECLIPSE_CONFIG_HPP
#include <opm/input/eclipse/EclipseState/InitConfig/InitConfig.hpp>
#include <opm/input/eclipse/EclipseState/IOConfig/FIPConfig.hpp>
#include <opm/input/eclipse/EclipseState/IOConfig/IOConfig.hpp>
namespace Opm {
@ -32,7 +33,9 @@ namespace Opm {
public:
EclipseConfig() = default;
explicit EclipseConfig(const Deck& deck);
EclipseConfig(const InitConfig& initConfig, const IOConfig& io_conf);
EclipseConfig(const InitConfig& initConfig,
const FIPConfig& fip_conf,
const IOConfig& io_conf);
static EclipseConfig serializationTestObject();
@ -40,6 +43,7 @@ namespace Opm {
IOConfig& io();
const IOConfig& io() const;
const InitConfig& init() const;
const FIPConfig& fip() const;
bool operator==(const EclipseConfig& data) const;
static bool rst_cmp(const EclipseConfig& full_config, const EclipseConfig& rst_config);
@ -47,11 +51,13 @@ namespace Opm {
void serializeOp(Serializer& serializer)
{
serializer(m_initConfig);
serializer(fip_config);
serializer(io_config);
}
private:
InitConfig m_initConfig;
FIPConfig fip_config;
IOConfig io_config;
};
}

View File

@ -23,16 +23,19 @@
#include <cstddef>
#include <memory>
#include <vector>
#include <optional>
#include <opm/input/eclipse/EclipseState/Aquifer/AquiferConfig.hpp>
#include <opm/input/eclipse/EclipseState/EclipseConfig.hpp>
#include <opm/input/eclipse/EclipseState/TracerConfig.hpp>
#include <opm/input/eclipse/EclipseState/MICPpara.hpp>
#include <opm/input/eclipse/EclipseState/WagHysteresisConfig.hpp>
#include <opm/input/eclipse/EclipseState/Grid/FieldPropsManager.hpp>
#include <opm/input/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <opm/input/eclipse/EclipseState/Grid/FaultCollection.hpp>
#include <opm/input/eclipse/EclipseState/Grid/NNC.hpp>
#include <opm/input/eclipse/EclipseState/Grid/TransMult.hpp>
#include <opm/input/eclipse/EclipseState/Grid/LgrCollection.hpp>
#include <opm/input/eclipse/EclipseState/Runspec.hpp>
#include <opm/input/eclipse/EclipseState/Tables/TableManager.hpp>
#include <opm/input/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp>
@ -48,6 +51,7 @@ namespace Opm {
namespace Opm { namespace RestartIO {
class RstAquifer;
class RstNetwork;
}} // namespace Opm::RestartIO
namespace Opm {
@ -94,6 +98,9 @@ namespace Opm {
const EclipseConfig& cfg() const;
const GridDims& gridDims() const;
const LgrCollection& getLgrs() const;
bool hasInputLGR() const;
// the unit system used by the deck. note that it is rarely needed
// to convert units because internally to opm-parser everything is
// represented by SI units.
@ -108,6 +115,7 @@ namespace Opm {
const AquiferConfig& aquifer() const;
const TracerConfig& tracer() const;
const MICPpara& getMICPpara() const;
const WagHysteresisConfig& getWagHysteresis() const;
void reset_actnum(const std::vector<int>& new_actnum);
void pruneDeactivatedAquiferConnections(const std::vector<std::size_t>& deactivated_cells);
@ -118,6 +126,9 @@ namespace Opm {
// When we know and decide to handle the same for AQUFETP and AQUCT, this part will be refactored
void appendAqufluxSchedule(const std::unordered_set<int>& ids);
void loadRestartNetworkPressures(const RestartIO::RstNetwork& network);
const std::optional<std::map<std::string, double> >& getRestartNetworkPressures() const { return this->m_restart_network_pressures; }
template<class Serializer>
void serializeOp(Serializer& serializer)
{
@ -129,6 +140,7 @@ namespace Opm {
serializer(m_deckUnitSystem);
serializer(m_inputNnc);
serializer(m_gridDims);
serializer(m_lgrs);
serializer(m_simulationConfig);
serializer(aquifer_config);
serializer(m_transMult);
@ -136,6 +148,7 @@ namespace Opm {
serializer(m_title);
serializer(tracer_config);
serializer(m_micppara);
serializer(wag_hyst_config);
}
static bool rst_cmp(const EclipseState& full_state, const EclipseState& rst_state);
@ -145,12 +158,13 @@ namespace Opm {
void initIOConfigPostSchedule(const Deck& deck);
void assignRunTitle(const Deck& deck);
void reportNumberOfActivePhases() const;
void initLgrs(const Deck& deck);
void conveyNumericalAquiferEffects();
void applyMULTXYZ();
void initFaults(const Deck& deck);
void initPara(const Deck& deck);
void setMULTFLT(const Opm::DeckSection& section);
void setMULTFLT(const Opm::DeckSection& section, bool edit = false);
void complainAboutAmbiguousKeyword(const Deck& deck,
const std::string& keywordName);
@ -164,14 +178,18 @@ namespace Opm {
NNC m_inputNnc;
GridDims m_gridDims;
FieldPropsManager field_props;
LgrCollection m_lgrs;
SimulationConfig m_simulationConfig;
AquiferConfig aquifer_config;
TransMult m_transMult;
TracerConfig tracer_config;
MICPpara m_micppara;
WagHysteresisConfig wag_hyst_config;
std::string m_title{};
FaultCollection m_faults{};
std::optional<std::map<std::string, double> > m_restart_network_pressures{std::nullopt};
};
} // namespace Opm

View File

@ -55,6 +55,7 @@ namespace Opm
{}
};
Carfin() = default;
explicit Carfin(const GridDims& gridDims,
IsActive isActive,
@ -93,6 +94,15 @@ namespace Opm
int NY() const;
int NZ() const;
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(m_dims);
serializer(m_offset);
serializer(m_end_offset);
serializer(name_grid);
}
private:
GridDims m_globalGridDims_{};
IsActive m_globalIsActive_{};

View File

@ -31,6 +31,7 @@
#include <stdexcept>
#include <unordered_set>
#include <vector>
#include <map>
namespace Opm {
@ -64,7 +65,8 @@ namespace Opm {
EclipseGrid(const EclipseGrid& src, const double* zcorn, const std::vector<int>& actnum);
EclipseGrid(size_t nx, size_t ny, size_t nz,
double dx = 1.0, double dy = 1.0, double dz = 1.0);
double dx = 1.0, double dy = 1.0, double dz = 1.0,
double top = 0.0);
explicit EclipseGrid(const GridDims& gd);
EclipseGrid(const std::array<int, 3>& dims ,
@ -75,7 +77,7 @@ namespace Opm {
/// EclipseGrid ignores ACTNUM in Deck, and therefore needs ACTNUM
/// explicitly. If a null pointer is passed, every cell is active.
EclipseGrid(const Deck& deck, const int * actnum = nullptr);
explicit EclipseGrid(const Deck& deck, const int * actnum = nullptr);
static bool hasGDFILE(const Deck& deck);
static bool hasCylindricalKeywords(const Deck& deck);
@ -254,12 +256,15 @@ namespace Opm {
std::vector<int> m_global_to_active;
// Numerical aquifer cells, needs to be active
std::unordered_set<size_t> m_aquifer_cells;
// Keep track of aquifer cell depths
std::map<size_t, double> m_aquifer_cell_depths;
// Radial grids need this for volume calculations.
std::optional<std::vector<double>> m_thetav;
std::optional<std::vector<double>> m_rv;
void updateNumericalAquiferCells(const Deck&);
double computeCellGeometricDepth(size_t globalIndex) const;
void initGridFromEGridFile(Opm::EclIO::EclFile& egridfile, std::string fileName);
void resetACTNUM( const int* actnum);

View File

@ -19,22 +19,32 @@
#ifndef FIELDPROPS_HPP
#define FIELDPROPS_HPP
#include <limits>
#include <optional>
#include <string>
#include <unordered_set>
#include <vector>
#include <opm/input/eclipse/Deck/value_status.hpp>
#include <opm/input/eclipse/Deck/DeckSection.hpp>
#include <opm/input/eclipse/Units/UnitSystem.hpp>
#include <opm/input/eclipse/EclipseState/Grid/Box.hpp>
#include <opm/input/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.hpp>
#include <opm/input/eclipse/EclipseState/Tables/TableManager.hpp>
#include <opm/input/eclipse/EclipseState/Runspec.hpp>
#include <opm/input/eclipse/EclipseState/Grid/Keywords.hpp>
#include <opm/input/eclipse/EclipseState/Grid/TranCalculator.hpp>
#include <opm/input/eclipse/EclipseState/Grid/FieldData.hpp>
#include <opm/input/eclipse/EclipseState/Grid/Keywords.hpp>
#include <opm/input/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.hpp>
#include <opm/input/eclipse/EclipseState/Grid/TranCalculator.hpp>
#include <opm/input/eclipse/EclipseState/Runspec.hpp>
#include <opm/input/eclipse/EclipseState/Util/OrderedMap.hpp>
#include <opm/input/eclipse/EclipseState/Tables/TableManager.hpp>
#include <opm/input/eclipse/Units/UnitSystem.hpp>
#include <opm/input/eclipse/Deck/DeckSection.hpp>
#include <opm/input/eclipse/Deck/value_status.hpp>
#include <cstddef>
#include <limits>
#include <map>
#include <memory>
#include <optional>
#include <set>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
namespace Opm {
@ -120,7 +130,8 @@ namespace ALIAS {
namespace GRID {
static const std::unordered_map<std::string, keyword_info<double>> double_keywords = {{"MULTPV", keyword_info<double>{}.init(1.0)},
static const std::unordered_map<std::string, keyword_info<double>> double_keywords = {{"DISPERC",keyword_info<double>{}.unit_string("Length")},
{"MULTPV", keyword_info<double>{}.init(1.0)},
{"NTG", keyword_info<double>{}.init(1.0)},
{"PORO", keyword_info<double>{}.distribute_top(true)},
{"PERMX", keyword_info<double>{}.unit_string("Permeability").distribute_top(true)},
@ -137,6 +148,12 @@ static const std::unordered_map<std::string, keyword_info<double>> double_keywor
{"THCOIL", keyword_info<double>{}.unit_string("Energy/AbsoluteTemperature*Length*Time")},
{"THCGAS", keyword_info<double>{}.unit_string("Energy/AbsoluteTemperature*Length*Time")},
{"THCWATER",keyword_info<double>{}.unit_string("Energy/AbsoluteTemperature*Length*Time")},
{"YMODULE", keyword_info<double>{}.unit_string("Giga*Pascal")},
{"PRATIO", keyword_info<double>{}.unit_string("1")},
{"BIOTCOEF", keyword_info<double>{}.unit_string("1")},
{"POELCOEF", keyword_info<double>{}.unit_string("1")},
{"THERMEXR", keyword_info<double>{}.unit_string("1/AbsoluteTemperature")},
{"THELCOEF", keyword_info<double>{}.unit_string("Pressure/AbsoluteTemperature")},
{"MULTX", keyword_info<double>{}.init(1.0).mult(true)},
{"MULTX-", keyword_info<double>{}.init(1.0).mult(true)},
{"MULTY", keyword_info<double>{}.init(1.0).mult(true)},
@ -175,7 +192,11 @@ static const std::unordered_map<std::string, keyword_info<int>> int_keywords = {
}
namespace PROPS {
static const std::unordered_map<std::string, keyword_info<double>> double_keywords = {{"SWATINIT", keyword_info<double>{}}};
static const std::unordered_map<std::string, keyword_info<double>> double_keywords = {{"SWATINIT", keyword_info<double>{}},
{"PCG", keyword_info<double>{}.unit_string("Pressure")},
{"IPCG", keyword_info<double>{}.unit_string("Pressure")},
{"PCW", keyword_info<double>{}.unit_string("Pressure")},
{"IPCW", keyword_info<double>{}.unit_string("Pressure")}};
static const std::unordered_map<std::string, keyword_info<int>> int_keywords = {};
#define dirfunc(base) base, base "X", base "X-", base "Y", base "Y-", base "Z", base "Z-"
@ -197,10 +218,6 @@ static const std::set<std::string> satfunc = {"SWLPC", "ISWLPC", "SGLPC", "ISGLP
dirfunc("ISOGCR"),
dirfunc("SWCR"),
dirfunc("ISWCR"),
dirfunc("PCW"),
dirfunc("IPCW"),
dirfunc("PCG"),
dirfunc("IPCG"),
dirfunc("KRW"),
dirfunc("IKRW"),
dirfunc("KRWR"),
@ -216,21 +233,7 @@ static const std::set<std::string> satfunc = {"SWLPC", "ISWLPC", "SGLPC", "ISGLP
dirfunc("KRGR"),
dirfunc("IKRGR")};
static const std::map<std::string,std::string> sogcr_shift = {{"SOGCR", "SWL"},
{"SOGCRX", "SWLX"},
{"SOGCRX-", "SWLX-"},
{"SOGCRY", "SWLY"},
{"SOGCRY-", "SWLY-"},
{"SOGCRZ", "SWLZ"},
{"SOGCRZ-", "SWLZ-"},
{"ISOGCR", "ISWL"},
{"ISOGCRX", "ISWLX"},
{"ISOGCRX-", "ISWLX-"},
{"ISOGCRY", "ISWLY"},
{"ISOGCRY-", "ISWLY-"},
{"ISOGCRZ", "ISWLZ"},
{"ISOGCRZ-", "ISWLZ-"}};
#undef dirfunc
}
namespace REGIONS {
@ -240,6 +243,7 @@ static const std::unordered_map<std::string, keyword_info<int>> int_keywords = {
{"FIPNUM", keyword_info<int>{}.init(1)},
{"IMBNUM", keyword_info<int>{}.init(1)},
{"OPERNUM", keyword_info<int>{}},
{"STRESSEQUILNUM", keyword_info<int>{}.init(1)},
{"MISCNUM", keyword_info<int>{}},
{"MISCNUM", keyword_info<int>{}},
{"PVTNUM", keyword_info<int>{}.init(1)},
@ -294,6 +298,7 @@ static const std::unordered_map<std::string, keyword_info<int>> int_keywords = {
template <typename T>
keyword_info<T> global_kw_info(const std::string& name, bool allow_unsupported = false);
bool is_oper_keyword(const std::string& name);
} // end namespace keywords
} // end namespace FieldProps
@ -323,8 +328,6 @@ public:
}
};
enum class GetStatus {
OK = 1,
INVALID_DATA = 2, // std::runtime_error
@ -332,8 +335,6 @@ public:
NOT_SUPPPORTED_KEYWORD = 4 // std::logic_error
};
template<typename T>
struct FieldDataManager {
const std::string& keyword;
@ -384,10 +385,9 @@ public:
};
/// Normal constructor for FieldProps.
FieldProps(const Deck& deck, const Phases& phases, const EclipseGrid& grid, const TableManager& table_arg);
/// Special case constructor used to process ACTNUM only.
FieldProps(const Deck& deck, const EclipseGrid& grid);
@ -409,102 +409,121 @@ public:
template <typename T>
std::vector<std::string> keys() const;
template <typename T>
FieldDataManager<T> try_get(const std::string& keyword,
bool allow_unsupported=false) {
if (!allow_unsupported && !FieldProps::supported<T>(keyword))
return FieldDataManager<T>(keyword, GetStatus::NOT_SUPPPORTED_KEYWORD, nullptr);
const Fieldprops::FieldData<T> * field_data;
bool has0 = this->has<T>(keyword);
field_data = std::addressof(this->init_get<T>(keyword,
std::is_same<T,double>::value && allow_unsupported));
if (field_data->valid() || allow_unsupported)
return FieldDataManager<T>(keyword, GetStatus::OK, field_data);
if (!has0) {
this->erase<T>(keyword);
return FieldDataManager<T>(keyword, GetStatus::MISSING_KEYWORD, nullptr);
FieldDataManager<T>
try_get(const std::string& keyword, const bool allow_unsupported = false)
{
if (!allow_unsupported && !FieldProps::template supported<T>(keyword)) {
return { keyword, GetStatus::NOT_SUPPPORTED_KEYWORD, nullptr };
}
return FieldDataManager<T>(keyword, GetStatus::INVALID_DATA, nullptr);
}
const auto has0 = this->template has<T>(keyword);
const auto& field_data =
this->template init_get<T>(keyword, std::is_same<T,double>::value && allow_unsupported);
template <typename T>
const std::vector<T>& get(const std::string& keyword) {
const auto& data = this->try_get<T>(keyword);
return data.data();
if (field_data.valid() || allow_unsupported) {
// Note: FieldDataManager depends on init_get<>() producing a
// long-lived FieldData instance.
return { keyword, GetStatus::OK, &field_data };
}
if (! has0) {
this->template erase<T>(keyword);
return { keyword, GetStatus::MISSING_KEYWORD, nullptr };
}
return { keyword, GetStatus::INVALID_DATA, nullptr };
}
template <typename T>
std::vector<T> get_global(const std::string& keyword) {
const auto& managed_field_data = this->try_get<T>(keyword);
const std::vector<T>& get(const std::string& keyword)
{
return this->template try_get<T>(keyword).data();
}
template <typename T>
std::vector<T> get_global(const std::string& keyword)
{
const auto managed_field_data = this->template try_get<T>(keyword);
const auto& field_data = managed_field_data.field_data();
const auto& kw_info = Fieldprops::keywords::global_kw_info<T>(keyword);
if (kw_info.global)
return *field_data.global_data;
else
return this->global_copy(field_data.data, kw_info.scalar_init);
const auto& kw_info = Fieldprops::keywords::
template global_kw_info<T>(keyword);
return kw_info.global
? *field_data.global_data
: this->global_copy(field_data.data, kw_info.scalar_init);
}
template <typename T>
std::vector<T> get_copy(const std::string& keyword, bool global) {
bool has0 = this->has<T>(keyword);
const auto& field_data = this->try_get<T>(keyword).field_data();
std::vector<T> get_copy(const std::string& keyword, bool global)
{
const auto has0 = this->template has<T>(keyword);
// Recall: FieldDataManager::field_data() will throw various
// exception types if the 'status' is anything other than 'OK'.
//
// Get_copy() depends on this behaviour to not proceed to extracting
// values in such cases. In other words, get_copy() uses exceptions
// for control flow, and we cannot move this try_get() call into the
// 'has0' branch even though the actual 'field_data' object returned
// from try_get() is only needed/used there.
const auto& field_data = this->template try_get<T>(keyword).field_data();
if (has0) {
if (global)
return this->global_copy(field_data.data, field_data.kw_info.scalar_init);
else
return field_data.data;
} else {
if (global) {
const auto& kw_info = Fieldprops::keywords::global_kw_info<T>(keyword);
return this->global_copy(this->extract<T>(keyword), kw_info.scalar_init);
} else
return this->extract<T>(keyword);
return this->get_copy(field_data.data, field_data.kw_info.scalar_init, global);
}
const auto initial_value = Fieldprops::keywords::
template global_kw_info<T>(keyword).scalar_init;
return this->get_copy(this->template extract<T>(keyword), initial_value, global);
}
template <typename T>
std::vector<bool> defaulted(const std::string& keyword) {
const auto& field = this->init_get<T>(keyword);
std::vector<bool> defaulted(const std::string& keyword)
{
const auto& field = this->template init_get<T>(keyword);
std::vector<bool> def(field.size());
for (std::size_t i=0; i < def.size(); i++)
def[i] = value::defaulted( field.value_status[i]);
for (std::size_t i = 0; i < def.size(); ++i) {
def[i] = value::defaulted(field.value_status[i]);
}
return def;
}
template <typename T>
std::vector<T> global_copy(const std::vector<T>& data, const std::optional<T>& default_value) const {
T fill_value = default_value.has_value() ? *default_value : 0;
std::vector<T> global_copy(const std::vector<T>& data,
const std::optional<T>& default_value) const
{
const T fill_value = default_value.has_value() ? *default_value : 0;
std::vector<T> global_data(this->global_size, fill_value);
std::size_t i = 0;
for (std::size_t g = 0; g < this->global_size; g++) {
if (this->m_actnum[g]) {
global_data[g] = data[i];
i++;
++i;
}
}
return global_data;
}
std::size_t active_size;
std::size_t global_size;
std::size_t num_int() const {
std::size_t num_int() const
{
return this->int_data.size();
}
std::size_t num_double() const {
std::size_t num_double() const
{
return this->double_data.size();
}
@ -534,6 +553,22 @@ private:
template <typename T>
std::vector<T> extract(const std::string& keyword);
template <typename T>
std::vector<T> get_copy(const std::vector<T>& x,
const std::optional<T>& initial_value,
const bool global) const
{
return (! global) ? x : this->global_copy(x, initial_value);
}
template <typename T>
std::vector<T> get_copy(std::vector<T>&& x,
const std::optional<T>& initial_value,
const bool global) const
{
return (! global) ? std::move(x) : this->global_copy(x, initial_value);
}
template <typename T>
void operate(const DeckRecord& record, Fieldprops::FieldData<T>& target_data, const Fieldprops::FieldData<T>& src_data, const std::vector<Box::cell_index>& index_list);
@ -563,6 +598,8 @@ private:
void init_satfunc(const std::string& keyword, Fieldprops::FieldData<double>& satfunc);
void init_porv(Fieldprops::FieldData<double>& porv);
void init_tempi(Fieldprops::FieldData<double>& tempi);
std::string canonical_fipreg_name(const std::string& fipreg);
const std::string& canonical_fipreg_name(const std::string& fipreg) const;
const UnitSystem unit_system;
std::size_t nx,ny,nz;
@ -578,6 +615,7 @@ private:
std::vector<MultregpRecord> multregp;
std::unordered_map<std::string, Fieldprops::FieldData<int>> int_data;
std::unordered_map<std::string, Fieldprops::FieldData<double>> double_data;
std::unordered_map<std::string, std::string> fipreg_shortname_translation{};
std::unordered_map<std::string,Fieldprops::TranCalculator> tran;
};

View File

@ -69,6 +69,7 @@ public:
bool operator==(const FieldPropsManager& other) const;
static bool rst_cmp(const FieldPropsManager& full_arg, const FieldPropsManager& rst_arg);
/*
Because the FieldProps class can autocreate properties the semantics of
get() and has() is slightly non intuitve:
@ -136,8 +137,8 @@ public:
contain said keyword, or if the keyword has not been fully initialized. If
you ask for a totally unknown keyword the method will return nullptr.
*/
template <typename T> const std::vector<T>* try_get(const
std::string& keyword) const;
template <typename T>
const std::vector<T>* try_get(const std::string& keyword) const;
/*
You can ask whether the elements in the keyword have a default value -

View File

@ -0,0 +1,65 @@
/*
Copyright (C) 2023 Equinor
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_PARSER_LGR_COLLECTION_HPP
#define OPM_PARSER_LGR_COLLECTION_HPP
#include <string>
#include <opm/input/eclipse/EclipseState/Util/OrderedMap.hpp>
#include <opm/input/eclipse/EclipseState/Grid/CarfinManager.hpp>
#include <opm/input/eclipse/EclipseState/Grid/Carfin.hpp>
#include <opm/input/eclipse/EclipseState/Grid/EclipseGrid.hpp>
namespace Opm {
class DeckRecord;
class GridDims;
class GRIDSection;
class LgrCollection {
public:
LgrCollection();
LgrCollection(const GRIDSection& gridSection, const EclipseGrid& grid);
static LgrCollection serializationTestObject();
explicit LgrCollection(const Deck& deck);
size_t size() const;
bool hasLgr(const std::string& lgrName) const;
Carfin& getLgr(const std::string& lgrName);
const Carfin& getLgr(const std::string& lgrName) const;
Carfin& getLgr(size_t lgrIndex);
const Carfin& getLgr(size_t lgrIndex) const;
void addLgr(const EclipseGrid& grid, const DeckRecord& lgrRecord);
bool operator==(const LgrCollection& data) const;
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(m_lgrs);
}
private:
OrderedMap<Carfin, 8> m_lgrs;
};
}
#endif // OPM_PARSER_LGR_COLLECTION_HPP

View File

@ -17,23 +17,31 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_PARSER_MULTREGTSCANNER_HPP
#define OPM_PARSER_MULTREGTSCANNER_HPP
#include <opm/input/eclipse/EclipseState/Grid/FaceDir.hpp>
#include <opm/input/eclipse/EclipseState/Grid/GridDims.hpp>
#include <cstddef>
#include <map>
#include <string>
#include <utility>
#include <vector>
namespace Opm {
class DeckRecord;
class DeckKeyword;
class FieldPropsManager;
class GridDims;
} // namespace Opm
namespace Opm {
namespace MULTREGT {
enum NNCBehaviourEnum {
enum class NNCBehaviourEnum
{
NNC = 1,
NONNC = 2,
ALL = 3,
@ -42,12 +50,10 @@ namespace Opm {
std::string RegionNameFromDeckValue(const std::string& stringValue);
NNCBehaviourEnum NNCBehaviourFromString(const std::string& stringValue);
}
} // namespace MULTREGT
struct MULTREGTRecord {
struct MULTREGTRecord
{
int src_value;
int target_value;
double trans_mult;
@ -55,13 +61,15 @@ namespace Opm {
MULTREGT::NNCBehaviourEnum nnc_behaviour;
std::string region_name;
bool operator==(const MULTREGTRecord& data) const {
return src_value == data.src_value &&
target_value == data.target_value &&
trans_mult == data.trans_mult &&
directions == data.directions &&
nnc_behaviour == data.nnc_behaviour &&
region_name == data.region_name;
bool operator==(const MULTREGTRecord& data) const
{
return (src_value == data.src_value)
&& (target_value == data.target_value)
&& (trans_mult == data.trans_mult)
&& (directions == data.directions)
&& (nnc_behaviour == data.nnc_behaviour)
&& (region_name == data.region_name)
;
}
template<class Serializer>
@ -76,58 +84,62 @@ namespace Opm {
}
};
typedef std::map< std::pair<int , int> , const MULTREGTRecord * > MULTREGTSearchMap;
typedef std::tuple<size_t , FaceDir::DirEnum , double> MULTREGTConnection;
class MULTREGTScanner {
class MULTREGTScanner
{
public:
using ExternalSearchMap = std::map<std::string, std::map<std::pair<int,int>, int>>;
MULTREGTScanner() = default;
MULTREGTScanner(const MULTREGTScanner& data);
MULTREGTScanner(const GridDims& grid,
const FieldPropsManager* fp_arg,
const std::vector< const DeckKeyword* >& keywords);
const std::vector<const DeckKeyword*>& keywords);
static MULTREGTScanner serializationTestObject();
double getRegionMultiplier(size_t globalCellIdx1, size_t globalCellIdx2, FaceDir::DirEnum faceDir) const;
bool operator==(const MULTREGTScanner& data) const;
MULTREGTScanner& operator=(const MULTREGTScanner& data);
template<class Serializer>
void applyNumericalAquifer(const std::vector<std::size_t>& aquifer_cells);
double getRegionMultiplier(std::size_t globalCellIdx1,
std::size_t globalCellIdx2,
FaceDir::DirEnum faceDir) const;
double getRegionMultiplierNNC(std::size_t globalCellIdx1,
std::size_t globalCellIdx2) const;
template <class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(nx);
serializer(ny);
serializer(nz);
serializer(gridDims);
serializer(m_records);
ExternalSearchMap searchMap = getSearchMap();
serializer(searchMap);
if (m_searchMap.empty())
constructSearchMap(searchMap);
serializer(m_searchMap);
serializer(regions);
serializer(default_region);
serializer(aquifer_cells);
}
private:
ExternalSearchMap getSearchMap() const;
void constructSearchMap(const ExternalSearchMap& searchMap);
using MULTREGTSearchMap = std::map<
std::pair<int, int>,
std::vector<MULTREGTRecord>::size_type
>;
void addKeyword( const DeckKeyword& deckKeyword, const std::string& defaultRegion);
GridDims gridDims{};
const FieldPropsManager* fp{nullptr};
std::vector<MULTREGTRecord> m_records{};
std::map<std::string, MULTREGTSearchMap> m_searchMap{};
std::map<std::string, std::vector<int>> regions{};
std::vector<std::size_t> aquifer_cells{};
void addKeyword(const DeckKeyword& deckKeyword);
void assertKeywordSupported(const DeckKeyword& deckKeyword);
std::size_t nx = 0,ny = 0, nz = 0;
const FieldPropsManager* fp = nullptr;
std::vector< MULTREGTRecord > m_records;
std::map<std::string , MULTREGTSearchMap> m_searchMap;
std::map<std::string, std::vector<int>> regions;
std::string default_region;
bool isAquNNC(std::size_t globalCellIdx1, std::size_t globalCellIdx2) const;
bool isAquCell(std::size_t globalCellIdx) const;
};
}
} // namespace Opm
#endif // OPM_PARSER_MULTREGTSCANNER_HPP

View File

@ -56,9 +56,11 @@ namespace Opm {
double getMultiplier(size_t globalIndex, FaceDir::DirEnum faceDir) const;
double getMultiplier(size_t i , size_t j , size_t k, FaceDir::DirEnum faceDir) const;
double getRegionMultiplier( size_t globalCellIndex1, size_t globalCellIndex2, FaceDir::DirEnum faceDir) const;
double getRegionMultiplierNNC(std::size_t globalCellIndex1, std::size_t globalCellIndex2) const;
void applyMULT(const std::vector<double>& srcMultProp, FaceDir::DirEnum faceDir);
void applyMULTFLT(const FaultCollection& faults);
void applyMULTFLT(const Fault& fault);
void applyNumericalAquifer(const std::vector<std::size_t>& aquifer_cells);
bool operator==(const TransMult& data) const;

View File

@ -0,0 +1,94 @@
/*
Copyright 2023 SINTEF Digital
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_FIP_CONFIG_HPP
#define OPM_FIP_CONFIG_HPP
#include <bitset>
namespace Opm {
class Deck;
class DeckKeyword;
class RPTConfig;
//! \brief Class holding FIP configuration from RPTSOL/RPTSCHED keyword.
class FIPConfig {
public:
//! \brief Enumeration of FIP report outputs.
enum class OutputField {
FIELD = 0, //!< Whole field
FIPNUM = 1, //!< FIPNUM regions
FIP = 2, //!< FIP defined regions
FOAM_FIELD = 3, //!< Foam field report
FOAM_REGION = 4, //!< Foam region report
POLYMER_FIELD = 5, //!< Polymer field report
POLYMER_REGION = 6, //!< Polymer region report
RESV = 7, //!< RESV report
SOLVENT_FIELD = 8, //!< Solvent field report
SOLVENT_REGION = 9, //!< Solvent region report
TEMPERATURE_FIELD = 10, //!< Temperature field report
TEMPERATURE_REGION = 11, //!< Temperature region report
SURF_FIELD = 12, //!< Surfacant field report
SURF_REGION = 13, //!< Surfacant region report
TRACER_FIELD = 14, //!< Tracer field report
TRACER_REGION = 15, //!< Tracer region report
VE = 16, //!< VE (oil, water, gas) zone report
NUM_FIP_REPORT = 17, //!< Number of configuration flags
};
//! \brief Default constructor.
FIPConfig() = default;
//! \brief Construct from RPTSOL keyword if deck holds one.
explicit FIPConfig(const Deck& deck);
//! \brief Construct from given keyword (RPTSOL or RPTSCHED).
explicit FIPConfig(const DeckKeyword& keyword);
//! \brief Construct from given RTPConfig.
explicit FIPConfig(const RPTConfig& rptConfig);
//! \brief Returns a test object used for serialization tests.
static FIPConfig serializationTestObject();
//! \brief (De-)serialization handler.
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(m_flags);
}
//! \brief Query if FIP output is enabled for a given field.
bool output(OutputField field) const;
//! \brief Comparison operator.
bool operator==(const FIPConfig& rhs) const;
private:
//! \brief Initialize flags based on mnemonics in a RPTConfig instance.
void parseRPT(const RPTConfig& rptConfig);
//! \brief Bitset holding enable status for fields
std::bitset<static_cast<int>(OutputField::NUM_FIP_REPORT)> m_flags = {};
};
} //namespace Opm
#endif

View File

@ -6,8 +6,21 @@
namespace Opm {
class DeckKeyword;
class DeckRecord;
class EquilRecord {
public:
EquilRecord() = default;
EquilRecord(double datum_depth_arg, double datum_depth_pc_arg,
double woc_depth, double woc_pc,
double goc_depth, double goc_pc,
bool live_oil_init,
bool wet_gas_init,
int target_accuracy,
bool humid_gas_init);
explicit EquilRecord(const DeckRecord& record);
static EquilRecord serializationTestObject();
double datumDepth() const;
double datumDepthPressure() const;
double waterOilContactDepth() const;
@ -20,10 +33,6 @@ namespace Opm {
int initializationTargetAccuracy() const;
bool humidGasInitConstantRvw() const;
EquilRecord();
EquilRecord( double datum_depth_arg, double datum_depth_pc_arg, double woc_depth, double woc_pc, double goc_depth, double goc_pc, bool live_oil_init, bool wet_gas_init, int target_accuracy, bool humid_gas_init);
bool operator==(const EquilRecord& data) const;
template<class Serializer>
@ -42,29 +51,75 @@ namespace Opm {
}
private:
double datum_depth;
double datum_depth_ps;
double water_oil_contact_depth;
double water_oil_contact_capillary_pressure;
double gas_oil_contact_depth;
double gas_oil_contact_capillary_pressure;
double datum_depth = 0.0;
double datum_depth_ps = 0.0;
double water_oil_contact_depth = 0.0;
double water_oil_contact_capillary_pressure = 0.0;
double gas_oil_contact_depth = 0.0;
double gas_oil_contact_capillary_pressure = 0.0;
bool live_oil_init_proc;
bool wet_gas_init_proc;
int init_target_accuracy;
bool humid_gas_init_proc;
bool live_oil_init_proc = false;
bool wet_gas_init_proc = false;
int init_target_accuracy = 0;
bool humid_gas_init_proc = false;
};
class Equil {
class StressEquilRecord {
public:
using const_iterator = std::vector< EquilRecord >::const_iterator;
StressEquilRecord() = default;
explicit StressEquilRecord(const DeckRecord& record);
Equil() = default;
explicit Equil( const DeckKeyword& );
static StressEquilRecord serializationTestObject();
static Equil serializationTestObject();
bool operator==(const StressEquilRecord& data) const;
const EquilRecord& getRecord( size_t id ) const;
double datumDepth() const;
double datumPosX() const;
double datumPosY() const;
double stressXX() const;
double stressXX_grad() const;
double stressYY() const;
double stressYY_grad() const;
double stressZZ() const;
double stressZZ_grad() const;
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(datum_depth);
serializer(datum_posx);
serializer(datum_posy);
serializer(stress_xx);
serializer(stress_xx_grad);
serializer(stress_yy);
serializer(stress_yy_grad);
serializer(stress_zz);
serializer(stress_zz_grad);
}
private:
double datum_depth = 0.0;
double datum_posx = 0.0;
double datum_posy = 0.0;
double stress_xx = 0.0;
double stress_xx_grad = 0.0;
double stress_yy = 0.0;
double stress_yy_grad = 0.0;
double stress_zz = 0.0;
double stress_zz_grad = 0.0;
};
template<class RecordType>
class EquilContainer {
public:
using const_iterator = typename std::vector<RecordType>::const_iterator;
EquilContainer() = default;
explicit EquilContainer( const DeckKeyword& );
static EquilContainer serializationTestObject();
const RecordType& getRecord(std::size_t id) const;
size_t size() const;
bool empty() const;
@ -72,7 +127,7 @@ namespace Opm {
const_iterator begin() const;
const_iterator end() const;
bool operator==(const Equil& data) const;
bool operator==(const EquilContainer& data) const;
template<class Serializer>
void serializeOp(Serializer& serializer)
@ -81,9 +136,11 @@ namespace Opm {
}
private:
std::vector< EquilRecord > m_records;
std::vector<RecordType> m_records;
};
using Equil = EquilContainer<EquilRecord>;
using StressEquil = EquilContainer<StressEquilRecord>;
}
#endif //OPM_EQUIL_HPP

View File

@ -45,6 +45,9 @@ namespace Opm {
bool hasEquil() const;
const Equil& getEquil() const;
bool hasStressEquil() const;
const StressEquil& getStressEquil() const;
bool hasGravity() const;
bool hasFoamConfig() const;
@ -64,6 +67,7 @@ namespace Opm {
void serializeOp(Serializer& serializer)
{
serializer(equil);
serializer(stress_equil);
serializer(foamconfig);
serializer(m_filleps);
serializer(m_gravity);
@ -74,6 +78,7 @@ namespace Opm {
private:
Equil equil;
StressEquil stress_equil;
FoamConfig foamconfig;
bool m_filleps;
bool m_gravity = true;

View File

@ -31,7 +31,6 @@
#include <string>
namespace Opm {
class Deck;
class Phases {
@ -95,7 +94,8 @@ public:
return this->nDynWlistMax;
}
const std::optional<KeywordLocation>& location() const {
const std::optional<KeywordLocation>& location() const
{
return this->m_location;
}
@ -113,7 +113,6 @@ public:
rst_cmp(*this, data);
}
template<class Serializer>
void serializeOp(Serializer& serializer)
{
@ -143,7 +142,6 @@ public:
static WellSegmentDims serializationTestObject();
int maxSegmentedWells() const
{
return this->nSegWellMax;
@ -159,6 +157,11 @@ public:
return this->nLatBranchMax;
}
const std::optional<KeywordLocation>& location() const
{
return this->location_;
}
bool operator==(const WellSegmentDims& data) const;
template<class Serializer>
@ -167,12 +170,14 @@ public:
serializer(nSegWellMax);
serializer(nSegmentMax);
serializer(nLatBranchMax);
serializer(location_);
}
private:
int nSegWellMax;
int nSegmentMax;
int nLatBranchMax;
std::optional<KeywordLocation> location_;
};
class NetworkDims {
@ -294,6 +299,11 @@ public:
*/
double curvatureCapPrs() const;
/*!
* \brief Wag hysteresis.
*/
bool activeWag() const;
bool operator==(const EclHysterConfig& data) const;
template<class Serializer>
@ -304,6 +314,7 @@ public:
serializer(krHystMod);
serializer(modParamTrappedValue);
serializer(curvatureCapPrsValue);
serializer(activeWagHyst);
}
private:
@ -317,6 +328,9 @@ private:
double modParamTrappedValue { 0.1 };
// curvature parameter for capillary pressure
double curvatureCapPrsValue { 0.1 };
// enable WAG hysteresis
bool activeWagHyst { false };
};
class SatFuncControls {
@ -329,8 +343,9 @@ public:
enum class KeywordFamily {
Family_I, // SGOF, SWOF, SLGOF
Family_II, // SGFN, SOF{2,3}, SWFN
Family_III, // GSF, WSF
Family_II, // SGFN, SOF{2,3}, SWFN, SGWFN
Family_III, // GSF, WSF
Undefined,
};
@ -455,7 +470,9 @@ public:
const Nupcol& nupcol() const noexcept;
const Tracers& tracers() const;
bool co2Storage() const noexcept;
bool h2Storage() const noexcept;
bool micp() const noexcept;
bool mech() const noexcept;
bool operator==(const Runspec& data) const;
static bool rst_cmp(const Runspec& full_state, const Runspec& rst_state);
@ -478,7 +495,9 @@ public:
serializer(m_sfuncctrl);
serializer(m_nupcol);
serializer(m_co2storage);
serializer(m_h2storage);
serializer(m_micp);
serializer(m_mech);
}
private:
@ -498,7 +517,9 @@ private:
Nupcol m_nupcol;
Tracers m_tracers;
bool m_co2storage;
bool m_h2storage;
bool m_micp;
bool m_mech;
};

View File

@ -33,59 +33,34 @@ namespace Opm {
class Deck;
class DeckRecord;
enum class BCType {
RATE,
FREE,
DIRICHLET,
THERMAL
};
enum class BCComponent {
OIL,
GAS,
WATER,
SOLVENT,
POLYMER,
NONE
};
class BCConfig {
public:
struct BCFace {
struct BCRegion {
int index;
int i1,i2;
int j1,j2;
int k1,k2;
BCType bctype;
FaceDir::DirEnum dir;
BCComponent component;
double rate;
std::optional<double> pressure;
std::optional<double> temperature;
BCFace() = default;
explicit BCFace(const DeckRecord& record, const GridDims& grid);
BCRegion() = default;
explicit BCRegion(const DeckRecord& record, const GridDims& grid);
static BCFace serializationTestObject();
static BCRegion serializationTestObject();
bool operator==(const BCFace& other) const;
bool operator==(const BCRegion& other) const;
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(index);
serializer(i1);
serializer(i2);
serializer(j1);
serializer(j2);
serializer(k1);
serializer(k2);
serializer(bctype);
serializer(dir);
serializer(component);
serializer(rate);
serializer(pressure);
serializer(temperature);
}
};
@ -96,8 +71,8 @@ public:
static BCConfig serializationTestObject();
std::size_t size() const;
std::vector<BCFace>::const_iterator begin() const;
std::vector<BCFace>::const_iterator end() const;
std::vector<BCRegion>::const_iterator begin() const;
std::vector<BCRegion>::const_iterator end() const;
bool operator==(const BCConfig& other) const;
template<class Serializer>
@ -107,7 +82,7 @@ public:
}
private:
std::vector<BCFace> m_faces;
std::vector<BCRegion> m_faces;
};
} //namespace Opm

View File

@ -20,6 +20,7 @@
#ifndef OPM_ROCK_CONFIG_HPP
#define OPM_ROCK_CONFIG_HPP
#include <cstddef>
#include <string>
#include <vector>
@ -28,36 +29,36 @@ namespace Opm {
class Deck;
class FieldPropsManager;
class RockConfig {
class RockConfig
{
public:
enum class Hysteresis {
REVERS = 1,
IRREVERS = 2,
HYSTER = 3,
BOBERG = 4,
REVLIMIT = 5,
PALM_MAN = 6,
NONE = 7
};
struct RockComp {
double pref;
double compressibility;
RockComp() = default;
RockComp(double pref_arg, double comp_arg);
bool operator==(const RockComp& other) const;
template<class Serializer>
void serializeOp(Serializer& serializer)
enum class Hysteresis
{
serializer(pref);
serializer(compressibility);
}
};
REVERS = 1,
IRREVERS = 2,
HYSTER = 3,
BOBERG = 4,
REVLIMIT = 5,
PALM_MAN = 6,
NONE = 7,
};
struct RockComp
{
double pref{};
double compressibility{};
RockComp() = default;
RockComp(double pref_arg, double comp_arg);
bool operator==(const RockComp& other) const;
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(pref);
serializer(compressibility);
}
};
RockConfig();
RockConfig(const Deck& deck, const FieldPropsManager& fp);
@ -70,6 +71,7 @@ struct RockComp {
std::size_t num_rock_tables() const;
Hysteresis hysteresis_mode() const;
bool water_compaction() const;
bool dispersion() const;
bool operator==(const RockConfig& other) const;
@ -82,6 +84,7 @@ struct RockComp {
serializer(num_tables);
serializer(m_water_compaction);
serializer(hyst_mode);
serializer(m_dispersion);
}
private:
@ -91,8 +94,9 @@ private:
std::size_t num_tables = 0;
bool m_water_compaction = false;
Hysteresis hyst_mode = Hysteresis::REVERS;
bool m_dispersion = false;
};
} //namespace Opm
#endif
#endif // OPM_ROCK_CONFIG_HPP

View File

@ -96,12 +96,6 @@ struct GravityTable : public FlatTableWithCopy<GRAVITYRecord>
{
return GravityTable({{1.0, 2.0, 3.0}});
}
template <class Serializer>
void serializeOp(Serializer& serializer)
{
FlatTableWithCopy::serializeOp(serializer);
}
};
struct DENSITYRecord {
@ -137,12 +131,6 @@ struct DensityTable : public FlatTableWithCopy<DENSITYRecord>
{
return DensityTable({{1.0, 2.0, 3.0}});
}
template <class Serializer>
void serializeOp(Serializer& serializer)
{
FlatTableWithCopy::serializeOp(serializer);
}
};
struct DiffCoeffRecord {
@ -286,12 +274,6 @@ struct PvtwTable : public FlatTableWithCopy<PVTWRecord>
{
return PvtwTable({{1.0, 2.0, 3.0, 4.0, 5.0}});
}
template <class Serializer>
void serializeOp(Serializer& serializer)
{
FlatTableWithCopy::serializeOp(serializer);
}
};
struct ROCKRecord {
@ -313,8 +295,11 @@ struct ROCKRecord {
}
};
struct RockTable : public FlatTable< ROCKRecord > {
using FlatTable< ROCKRecord >::FlatTable;
struct RockTable : public FlatTableWithCopy<ROCKRecord>
{
RockTable() = default;
explicit RockTable(const DeckKeyword& kw);
explicit RockTable(std::initializer_list<ROCKRecord> records);
static RockTable serializationTestObject()
{

View File

@ -24,15 +24,14 @@
namespace Opm {
class Deck;
class DeckItem;
class GasvisctTable : public SimpleTable {
public:
GasvisctTable( const Deck& deck, const DeckItem& deckItem );
GasvisctTable( const DeckItem& item, const int tableID );
const TableColumn& getTemperatureColumn() const;
const TableColumn& getGasViscosityColumn(size_t compIdx) const;
const TableColumn& getGasViscosityColumn() const;
};
}

View File

@ -28,7 +28,7 @@ namespace Opm {
class PlymaxTable : public SimpleTable {
public:
PlymaxTable( const DeckRecord& record );
explicit PlymaxTable(const DeckRecord& record);
const TableColumn& getPolymerConcentrationColumn() const;
const TableColumn& getMaxPolymerConcentrationColumn() const;

View File

@ -23,13 +23,13 @@
namespace Opm {
class DeckReckord;
class DeckRecord;
class PlyrockTable : public SimpleTable {
public:
// This is not really a table; every column has only one element.
PlyrockTable( const DeckRecord& record );
explicit PlyrockTable(const DeckRecord& record);
// since this keyword is not necessarily monotonic, it cannot be evaluated!
//using SimpleTable::evaluate;

View File

@ -0,0 +1,79 @@
/*
Copyright (C) 2023 Equinor
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 PPCWMAX_HPP
#define PPCWMAX_HPP
#include <cstddef>
#include <vector>
namespace Opm {
class Deck;
struct PpcwmaxRecord {
double max_cap_pres;
bool option;
PpcwmaxRecord() = default;
PpcwmaxRecord(double pres, bool optn) :
max_cap_pres(pres),
option(optn)
{};
bool operator==(const PpcwmaxRecord& other) const {
return this->max_cap_pres == other.max_cap_pres &&
this->option == other.option;
}
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(max_cap_pres);
serializer(option);
}
};
class Ppcwmax {
public:
Ppcwmax() = default;
explicit Ppcwmax(const Deck& deck);
explicit Ppcwmax(std::initializer_list<PpcwmaxRecord> records);
static Ppcwmax serializationTestObject();
std::size_t size() const;
bool empty() const;
std::vector< PpcwmaxRecord >::const_iterator begin() const;
std::vector< PpcwmaxRecord >::const_iterator end() const;
const PpcwmaxRecord& operator[](const std::size_t index) const;
bool operator==(const Ppcwmax& other) const {
return this->data == other.data;
}
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(data);
}
private:
std::vector<PpcwmaxRecord> data;
};
}
#endif

View File

@ -57,6 +57,7 @@
#include <opm/input/eclipse/EclipseState/Tables/Eqldims.hpp>
#include <opm/input/eclipse/EclipseState/Tables/Regdims.hpp>
#include <opm/input/eclipse/EclipseState/Tables/TLMixpar.hpp>
#include <opm/input/eclipse/EclipseState/Tables/Ppcwmax.hpp>
namespace Opm {
@ -78,6 +79,7 @@ namespace Opm {
const Aqudims& getAqudims() const;
const Regdims& getRegdims() const;
const TLMixpar& getTLMixpar() const;
const Ppcwmax& getPpcwmax() const;
/*
WIll return max{ Tabdims::NTFIP , Regdims::NTFIP }.
*/
@ -260,6 +262,7 @@ namespace Opm {
serializer(m_rtemp);
serializer(m_salinity);
serializer(m_tlmixpar);
serializer(m_ppcwmax);
if (!serializer.isSerializing()) {
m_simpleTables = simpleTables;
if (split.plyshMax > 0) {
@ -289,7 +292,6 @@ namespace Opm {
void initRTempTables(const Deck& deck);
void initDims(const Deck& deck);
void initRocktabTables(const Deck& deck);
void initGasvisctTables(const Deck& deck);
void initPlymaxTables(const Deck& deck);
void initPlyrockTables(const Deck& deck);
@ -392,6 +394,7 @@ namespace Opm {
Eqldims m_eqldims;
Aqudims m_aqudims;
TLMixpar m_tlmixpar;
Ppcwmax m_ppcwmax;
bool hasImptvd = false;// if deck has keyword IMPTVD
bool hasEnptvd = false;// if deck has keyword ENPTVD

View File

@ -20,14 +20,19 @@
#ifndef OPM_ORDERED_MAP_HPP
#define OPM_ORDERED_MAP_HPP
#include <unordered_map>
#include <vector>
#include <string>
#include <stdexcept>
#include <algorithm>
#include <cctype>
#include <cstddef>
#include <functional>
#include <iterator>
#include <set>
#include <cctype>
#include <algorithm>
#include <stdexcept>
#include <string>
#include <string_view>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
namespace Opm {
@ -68,11 +73,11 @@ findSimilarStrings(std::string str,
return concatedStr.substr(0, concatedStr.size()-2);
}
template<std::size_t MAX_CHARS>
template<std::string_view::size_type MAX_CHARS>
class TruncatedStringHash
{
public:
std::size_t operator()(const std::string_view& key) const
std::size_t operator()(std::string_view key) const
{
return hasher(key.substr(0, MAX_CHARS));
}
@ -82,13 +87,13 @@ private:
template<>
class TruncatedStringHash<std::string::npos> : public std::hash<std::string_view>
class TruncatedStringHash<std::string_view::npos> : public std::hash<std::string_view>
{};
template<std::size_t MAX_CHARS>
template<std::string_view::size_type MAX_CHARS>
struct TruncatedStringEquals
{
bool operator()(const std::string& str1, const std::string& str2) const
bool operator()(std::string_view str1, std::string_view str2) const
{
return str1.substr(0, MAX_CHARS) == str2.substr(0, MAX_CHARS);
}
@ -102,21 +107,23 @@ struct TruncatedStringEquals<std::string::npos> : public std::equal_to<std::stri
/// \brief A map with iteration in the order of insertion.
///
/// Each entry has an associated index indicating when a value with that key was
/// first inserted. When itering over it's entries values with lower insertion index
/// are traversed before ones with an higher insertion index.
/// Each entry has an associated index indicating when a value with that key
/// was first inserted. When iterating over the entries, elements with a
/// lower insertion index are traversed before elements with a higher
/// insertion index.
///
/// \tparam MAX_CHARS The maximum number of characters that are use a keys. Default is
/// std::string::npos, which honors all characters. Any keys with the
/// \tparam T Element type. The map's value type is \code pair<string, T> \endcode.
///
/// \tparam MAX_CHARS Maximum number of characters used in key comparisons.
/// Default value honors all characters. Keys with the
/// same first MAX_CHARS characters are considered equal.
///
template <typename T, std::size_t MAX_CHARS = std::string::npos>
template <typename T, std::string_view::size_type MAX_CHARS = std::string_view::npos>
class OrderedMap {
public:
using storage_type = typename std::vector<std::pair<std::string,T>>;
using index_type = typename std::unordered_map<std::string,std::size_t,
Opm::OrderedMapDetail::TruncatedStringHash<MAX_CHARS>,
Opm::OrderedMapDetail::TruncatedStringEquals<MAX_CHARS>>;
using storage_type = std::vector<std::pair<std::string, T>>;
using index_type = std::unordered_map<std::string, typename storage_type::size_type,
OrderedMapDetail::TruncatedStringHash<MAX_CHARS>,
OrderedMapDetail::TruncatedStringEquals<MAX_CHARS>>;
using iter_type = typename storage_type::iterator;
using const_iter_type = typename storage_type::const_iterator;

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