Compare commits

...

2492 Commits

Author SHA1 Message Date
Arne Morten Kvarving
c4023f7299 Merge pull request #3521 from akva2/backport_PR_3520
Backport #3520 fixed: build pypi packages using static boost libs
2023-05-12 09:20:15 +02:00
Arne Morten Kvarving
86d1fbe521 fixed: build pypi packages using static boost libs 2023-05-12 09:19:31 +02:00
Arne Morten Kvarving
71b1c36ca3 bup version to 2023.04 final 2023-05-02 14:15:16 +02:00
Arne Morten Kvarving
382c624f10 Merge pull request #3500 from akva2/backport_PR_3499
fixed: conditionally use Development.XXX in python find module
2023-05-02 09:27:05 +02:00
Arne Morten Kvarving
d903c61166 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 09:26:16 +02:00
Arne Morten Kvarving
acc1a5145a bump version to 2023.04-rc2 2023-04-27 13:38:25 +02:00
Arne Morten Kvarving
e892d17f74 Merge pull request #3492 from akva2/backport_PR_3489
Backport #3489: Python: avoid searching from Development.Embed unless required
2023-04-27 13:36:30 +02:00
Arne Morten Kvarving
7cd35f4477 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:35:42 +02:00
Arne Morten Kvarving
fb5f40339b 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:35:35 +02:00
Arne Morten Kvarving
0f25bb7386 Merge pull request #3491 from akva2/backport_PR_3490
Backport #3490: changed: build python wheels using skbuild
2023-04-27 13:31:01 +02:00
Arne Morten Kvarving
4952be6990 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:30:23 +02:00
Arne Morten Kvarving
3f3a0c307d Merge pull request #3486 from akva2/backport_PR_3484
Backport #3484: fixed: missing serialization of tokens in UDQDefine
2023-04-26 12:57:13 +02:00
Arne Morten Kvarving
63002dd1a5 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 12:56:19 +02:00
Arne Morten Kvarving
95f62fbf58 Merge pull request #3483 from akva2/backport_PR_3478
Backport #3478: Always search for Development component of Python.
2023-04-24 08:47:30 +02:00
Markus Blatt
f28b6ed05d 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-24 08:46:38 +02:00
Arne Morten Kvarving
c0616be20e bump version to 2023.04-rc1 2023-04-13 14:30:31 +02:00
Arne Morten Kvarving
19c819074f Merge pull request #3473 from blattms/fix-grid-indep-well
Added missing file for grid independent well specification.
2023-04-13 14:20:17 +02:00
Markus Blatt
8a21a8a23f Added missing file for grid independent well specification. 2023-04-13 12:55:30 +02:00
Bård Skaflestad
93a2f71545 Merge pull request #3463 from GitPaean/open_wellopen_zerorate_nocrossflow_wells
not forbidding WELOPEN wells with zero rate and disallowing crossflow
2023-04-13 10:34:41 +02:00
Bård Skaflestad
134a4dbef4 Merge pull request #3459 from blattms/internalize-editnncr
Internalize EDITNNCR keyword and make it available with the other NNC information.
2023-04-13 10:33:49 +02:00
Markus Blatt
f0da305684 Use erase just to make reviewer happy. 2023-04-13 08:05:23 +02:00
Markus Blatt
0ca91f5498 Fixed wrong data file comment. 2023-04-12 17:02:07 +02:00
Markus Blatt
87a961246f Updated copyright. 2023-04-12 16:57:33 +02:00
Markus Blatt
f3767d0f24 Added explicit include of algorithm. 2023-04-12 16:57:11 +02:00
Markus Blatt
e16fd02498 Use deque::assign instead of relying on smart compilers. 2023-04-12 16:50:23 +02:00
Markus Blatt
7187d03f0c Use stable_sort to keep reverse insertion order for same cell pairs 2023-04-12 16:49:29 +02:00
Markus Blatt
83e05e7ba3 Effort to make the code documentation better. 2023-04-12 16:48:48 +02:00
Bård Skaflestad
8473d9b8ec Merge pull request #3469 from GitPaean/reverting_aquct_commit
checking all the instances of AQUCT and AQUFETP keywords
2023-04-12 14:26:15 +02:00
Bård Skaflestad
9bf9f65f63 Merge pull request #3466 from blattms/fix-compiler-warnings
Fix compiler warnings
2023-04-12 14:03:20 +02:00
Kai Bao
32e4384109 checking all the instances of AQUCT and AQUFETP keywords
with master branch, only the last instance will be caught for these two
keywords.
2023-04-12 13:37:18 +02:00
Bård Skaflestad
b9c1b39a61 Merge pull request #3468 from GitPaean/reverting_aquct_commit
Revert "only using the AQUCT and AQUFETP in SOLUTION section"
2023-04-12 13:24:34 +02:00
Kai Bao
0eea937f3f Revert "only using the AQUCT and AQUFETP in SOLUTION section"
This reverts commit a89136f1f2.
2023-04-12 12:39:24 +02:00
Markus Blatt
1bb2cbd646 Addressed review comments. 2023-04-12 12:26:39 +02:00
Markus Blatt
9f6122938d Keep all NNCs when processing EDITNNCR.
Those might still be needed to correctly construct the connections
between cells in the grid. Skipping them will produce wrong grids.
2023-04-12 10:22:35 +02:00
Markus Blatt
1ff9100bdc Fixed NNCTests. 2023-04-12 10:22:35 +02:00
Markus Blatt
5a19bcc4d0 Remove NNC entries that correcpond to EDITNNCR
No need to keep those as they will be overwritten anyway.
2023-04-12 10:22:35 +02:00
Markus Blatt
55a0078b3e Simplify code by keeping track of insertion order of EDITNNCR imlicitly.
std::unique will keep the first occurrence and std::sort will keep
the order of equal elements. Hence we use a deque with the EDITNNCR
entries in reverse order (last one specified comes first). The we sort
this and make unique it unique.
2023-04-12 10:22:34 +02:00
Markus Blatt
f2ffebc814 Internalize EDITNNCR and make it available with the NNC information.
If there is an EDITNNCR entry and a NNC entry for the same cell pair
then the EDITNNCR entry is not be represented inernally but we simply
overwrite the transmissibility of the corresponding NNC entry.

If there is an EDITNNC entry and an EDITNNCR entry for the same cell
pair then the EDITNNC entry is removed while internalizing EDITNNCR.

Order matters for EDITNNCR entries in the sense that later specified
values will overwrite previous entries when we internalize.

Note that similar to EDITNNC only the first 7 options are represented
and the rest is ignored by OPM flow.

Note that EDITNNCR entries for neighboring cells are ignored (like for
EDITNNC).
2023-04-12 10:22:34 +02:00
Markus Blatt
fb3c2ab5a1 Removed unimplemented declaration of NNC::update_nnc. 2023-04-12 10:22:34 +02:00
Markus Blatt
c24aeceb96 Fixed EDITNNCR specification.
Item 7 is of dimension transmissibility.
Also added item numbers to all and comments about being unused where
it seemed appropriate.
2023-04-12 10:22:34 +02:00
Arne Morten Kvarving
dcd5ecf0d1 Merge pull request #3414 from akva2/require_dune_2.7
minimum dune version required is now 2.7
2023-04-12 09:19:14 +02:00
Markus Blatt
888f3644f7 Fixed warning about muliline comment. 2023-04-11 17:42:17 +02:00
Markus Blatt
adc11caf99 Fixes warning about set but unused variable. 2023-04-11 17:42:17 +02:00
Markus Blatt
db1c823cbb Fixes warnings about initialization order. 2023-04-11 17:42:17 +02:00
Markus Blatt
580bb30f8e Fixes shadowed variable warning. 2023-04-11 17:35:13 +02:00
Markus Blatt
24d25f7be7 Merge pull request #3384 from plgbrts/well-traj
Grid independent well specification
2023-04-10 07:40:08 +02:00
Paul Egberts
694bb016a7 Two more small fixes 2023-04-05 15:58:17 +02:00
Kai Bao
9fdcfa3751 not forbidding WELOPEN wells with zero rate and disallowing crossflow
other keywords might change the control to make it openable.
2023-04-04 22:19:52 +02:00
Paul Egberts
e781a99ce4 update of license to only gplv3 2023-04-04 22:02:18 +02:00
Paul Egberts
a6d39275c7 code improvements following suggestions of Markus 2023-04-04 21:49:03 +02:00
Markus Blatt
df4c92a8d7 Merge pull request #3461 from blattms/MINPVFIL
Minpvfi
2023-04-03 17:45:46 +02:00
Markus Blatt
9d995a40e3 Fix ConstructorMINPV.
Exception is now already thrown in createMinpvDefaultCPDeck.
2023-04-03 17:41:22 +02:00
OPMUSER
699f7ad695 Update ConstructorMINPV Test
Update ConstructorMINPV Test for MINPV/MINPORV
2023-04-03 16:37:33 +02:00
OPMUSER
f99e7dbc29 Update keyword_list.cmake
Remove MINPVFIL from keyword_list.cmake.
2023-04-03 16:37:33 +02:00
OPMUSER
1fac541b6e Remove MINPVFIL - WIP
MINPVFIL is an OPM Flow specific keyword that is not used by the simulator,  and thus it should be deleted.

Previously, we moved the checks that only allow either the MINPV or MINPORV keywords to be used in the input deck to the JSON keyword files.  This was done to avoid confusion over which global limits are being applied.

Note that if the MINPVV keyword is also in the input deck then these limits are applied post processing the global limits defined by the MINPV/MINPORV keywords. This behavior is unchanged by this PR.

The PR is marked as WIP to give developers time to object for the removal of MINPVFIL keyword.
2023-04-03 16:37:33 +02:00
Bård Skaflestad
00089a888b Merge pull request #3460 from GitPaean/const_waterReferceDensity
add const for WaterPvtMultiplexer::waterReferenceDensity(unsigned)
2023-04-03 16:00:45 +02:00
Kai Bao
548881395e add const for WaterPvtMultiplexer::waterReferenceDensity(unsigned) 2023-04-03 12:59:43 +02:00
Paul Egberts
7c05ccc553 Merge branch 'well-traj' of https://github.com/blattms/opm-common into well-traj-markus
Use Markus' rebased version
2023-04-03 12:11:47 +02:00
Bård Skaflestad
200b6a2cbc Merge pull request #3456 from blattms/support-pinch-maxgap
EclipseGrid: make option 3 (MAX_EMPTY_GAP) of PINCH available
2023-03-30 15:18:01 +02:00
Markus Blatt
3706aae429 Fixed default initialization of EclipseGrid. 2023-03-30 14:03:01 +02:00
Paul Egberts
22a7a81597 Removal of unused files 2023-03-29 17:24:13 +02:00
Paul Egberts
7b0156f6cc Placed ResInsight code in separate namespace called external 2023-03-29 17:24:13 +02:00
Paul Egberts
b9012d85a3 removal of unused files 2023-03-29 17:24:13 +02:00
Paul Egberts
367ffb1aa2 added missing *.inl files to make file 2023-03-29 17:24:13 +02:00
Paul Egberts
d0fc099d75 explicit listing of header files, removed globbing 2023-03-29 17:24:11 +02:00
Paul Egberts
1d07b6ad9f attempt to fix build error 2023-03-29 17:23:21 +02:00
Paul Egberts
e7e1411146 added resinsight include files in cmake file part 2 2023-03-29 17:23:21 +02:00
Paul Egberts
7ebfb0b86f added resinsight include files in cmake file 2023-03-29 17:23:21 +02:00
Paul Egberts
98f41e2e2e cmake file fix 2023-03-29 17:23:21 +02:00
Paul Egberts
160c5bee10 added #include <string> 2023-03-29 17:23:21 +02:00
Paul Egberts
8091ea73ae repairing cmake file 2023-03-29 17:23:14 +02:00
Paul Egberts
e7ae500032 added test for calculation of CFs and IJK coordinates of intersected cells 2023-03-29 17:20:57 +02:00
Paul Egberts
3ba31d4304 finalizing and cleaning up 2023-03-29 17:20:54 +02:00
Paul Egberts
46f412e60a Processing WELTRAJ/COMPTRAJ; Calculation of intersected cells and CFs 2023-03-29 17:05:39 +02:00
Paul Egberts
88e58ba5d2 finalizing keywords COMPTRAJ and WELTRAJ 2023-03-29 17:05:39 +02:00
Paul Egberts
067e645e22 This is a combination of 5 commits.
Reorganizing and renaming files
2023-03-29 17:05:39 +02:00
Paul Egberts
5c9a59644f well trajectory calculation (re)using resinsight code 2023-03-29 17:05:37 +02:00
Paul Egberts
532b626e56 try out code 2023-03-29 17:03:56 +02:00
Paul Egberts
65eff452e3 reading new tables for grid independent well specification 2023-03-29 17:03:56 +02:00
Bård Skaflestad
0be5bee7c4 Merge pull request #3457 from totto82/addThermalBC
add THERMAL option to BC
2023-03-29 14:07:45 +02:00
Bård Skaflestad
cbb808b579 Merge pull request #3455 from totto82/diffc_co2store
Support DIFFCGAS and DIFFCWAT for the CO2STORE module
2023-03-29 13:41:40 +02:00
Tor Harald Sandve
b8ee8d8652 Merge pull request #3451 from totto82/gaswater_hyst
Enable hysteresis in water gas 2p model
2023-03-28 15:48:59 +02:00
Markus Blatt
ea64c29001 Added missing forward declaration to make TransMult.hpp usable standalone. 2023-03-28 15:40:21 +02:00
Tor Harald Sandve
8c8851039c Add hysteresis in water gas 2p model 2023-03-28 12:39:01 +02:00
Tor Harald Sandve
3cd2539b7a add THERMAL option to BC 2023-03-28 12:04:24 +02:00
Markus Blatt
055547c709 EclipseGrid: make option 3 (MAX_EMPTY_GAP) of PINCH available
This is needed to prevent creation of NNCs if the the empty gap created
by pinched out cells is larger than this threshold.
2023-03-28 11:55:14 +02:00
Tor Harald Sandve
4ca0daf4bb add files 2023-03-27 15:01:55 +02:00
Tor Harald Sandve
bf7cef4ebd Support DIFFCGAS and DIFFCWAT for the CO2STORE module 2023-03-27 10:15:54 +02:00
Bård Skaflestad
070a14d56d Merge pull request #3404 from totto82/addVap2Co2
add vapporized water to gas in co2brine model
2023-03-24 13:56:45 +01:00
Tor Harald Sandve
92b0477a14 cleanup based on review 2023-03-24 12:24:16 +01:00
Tor Harald Sandve
f8a61f537b return gas density directly when no vaporized water to avoid numerical inpresition in division 2023-03-24 12:24:16 +01:00
Tor Harald Sandve
3b43c5bae8 set enable vaporization 2023-03-24 12:24:16 +01:00
Tor Harald Sandve
63340df84e Compute mixture innerEnergy and denisty assuming ideal mixtures 2023-03-24 12:24:16 +01:00
Tor Harald Sandve
a94a84221b compute internal energy not enthalpy 2023-03-24 12:24:16 +01:00
Tor Harald Sandve
dd36c0b558 renaming from Oil to Water 2023-03-24 12:24:16 +01:00
Tor Harald Sandve
8c44873301 bugfix correctly using waterCompIdx when getting molarMass from BrineCo2Pvt module 2023-03-24 12:24:16 +01:00
Tor Harald Sandve
b5ac472f14 add convert XgWToxgW 2023-03-24 12:24:16 +01:00
Tor Harald Sandve
c84c1d54dd Add vapporized water to gas in co2brine model 2023-03-24 12:24:16 +01:00
Tor Harald Sandve
7526a7bb77 Merge pull request #3452 from totto82/fixThermalCO2
Fix thermal + co2
2023-03-22 11:06:52 +01:00
Bård Skaflestad
66bf31051a Merge pull request #3437 from bska/load-aquflux-rst-info
Load Constant Flux Aquifer Objects from Restart File
2023-03-22 09:54:56 +01:00
Bård Skaflestad
303889516f Load Constant Flux Aquifer Objects from Restart File
This commit adds logic and structures for bringing in constant flux
aquifer objects-keyword AQUFLUX-from the restart file and forming
the requisite dynamic objects in the Schedule.

In particular, the 'RstAquifer' gets a new bare-bones representation
of these aquifer types and we add new constant flux aquifer objects
to the pertinent 'ScheduleState' when these exist.  We also add this
aquifer type to 'data::Aquifers' in preparation of reinitialising
the simulator's aquifer container from the restart file.  In
particular, this needs the total produced volume from the aquifer so
far.
2023-03-21 17:50:24 +01:00
Bård Skaflestad
f8f77ff081 Merge pull request #3076 from goncalvesmachadoc/carfinManager
Read CARFIN and create LGR object
2023-03-21 17:46:18 +01:00
goncalvesmachadoc
3e08afeafd delete makeState 2023-03-21 14:24:23 +01:00
Bård Skaflestad
94283ee43e Merge pull request #3453 from hnil/missing_quadinclude
fixed missing include
2023-03-17 18:21:27 +01:00
hnil
352e2a8316 -fixed missing include 2023-03-17 17:06:30 +01:00
goncalvesmachadoc
7c29f6c2a5 test read name 2023-03-17 14:26:26 +01:00
goncalvesmachadoc
4c93e18971 integration test framework 2023-03-17 14:26:26 +01:00
goncalvesmachadoc
ca08609810 rebase 2023-03-17 14:26:25 +01:00
Bård Skaflestad
c5d25fa663 Merge pull request #3436 from hnil/fem-withpolygrid
fixed error if dune-fem is buildt with polygongrid
2023-03-17 13:46:26 +01:00
Bård Skaflestad
fcf02b639a Merge pull request #3447 from bska/enable-inplace-solution-insert
Enable In-Place Element Construction in Insert()
2023-03-16 18:11:41 +01:00
Bård Skaflestad
f1b4ae527a Enable In-Place Element Construction in Insert() 2023-03-16 16:15:41 +01:00
Bård Skaflestad
7f1e56e436 Adjust Whitespace in Data::Solution Implementation
In preparation of enabling in-place construction in insert().
2023-03-16 16:15:41 +01:00
Tor Harald Sandve
5f438d19cc fix sign bug in thermal Brine density calculations 2023-03-16 15:26:54 +01:00
Tor Harald Sandve
94c738538f use mass fraction not mole fractions 2023-03-16 15:26:03 +01:00
Bård Skaflestad
5f55ffe21a Merge pull request #3442 from goncalvesmachadoc/co2store
CO2STORE + GASWAT parsing
2023-03-16 15:22:09 +01:00
Arne Morten Kvarving
9adb6d2586 Merge pull request #3450 from bska/restore-non-default-dune-install-builds
Restore Builds With Dune in Non-Default Installed Locations
2023-03-16 13:00:30 +01:00
Bård Skaflestad
bdf6951e62 Restore Builds With Dune in Non-Default Installed Locations
In general we'd need to link to dune-common ("target_link_library")
to get the appropriate include directories for Dune in that case,
but in this specific instance we can get by with not specialising
Dune's 'className' function if Dune is not available.

Thanks to [at]akva2 for suggesting this workaround.
2023-03-16 12:44:17 +01:00
Bård Skaflestad
32b104f828 Merge pull request #3449 from totto82/output_moles
add moles unit to unitsystem
2023-03-16 12:33:16 +01:00
Bård Skaflestad
e074054a57 Merge pull request #3448 from totto82/convertRsw
add convertRswToXwg
2023-03-16 12:25:54 +01:00
Bård Skaflestad
dec47944e3 Merge pull request #3446 from bska/celldata-ctor
Add Constructors for CellData Objects
2023-03-16 12:22:53 +01:00
Bård Skaflestad
ae29bb9101 Add Constructors for CellData Objects
This enables using in-place construction in Solution::insert().
2023-03-16 12:15:44 +01:00
Bård Skaflestad
553688b73e Merge pull request #3424 from bska/write-aquflux-rst-info
Add Restart File Output Support for Constant Flux Aquifers
2023-03-16 12:04:14 +01:00
goncalvesmachadoc
f6402e2bc8 extra keywords 2023-03-16 10:50:59 +01:00
Bård Skaflestad
0adcc7dd07 Add Restart File Output Support for Constant Flux Aquifers
We support constant flux aquifers (AQUFLUX keyword) entered both in
the SOLUTION and in the SCHEDULE sections.  The primary structural
change is that we have to support analytic aquifers being introduced
dynamically, whence the connection information (xCAQ) must be
captured without knowing the full set of analytic aquifers.  We
therefore allocate those output arrays purely from the maximum sizes
entered in the RUNSPEC section whereas we defer determining the
maximum aquifer ID to the point of capturing the dynamic values.

The xAAQ values for constant flux aquifers amount to a new aquifer
type integer value (=2) in IAAQ[11] and the flux value in SAAQ[0].
2023-03-16 10:32:43 +01:00
Bård Skaflestad
53a7c2343a Split Aquifer Type Handling out to Helper Functions
In preparation of adding support for outputting constant flux
aquifer values.
2023-03-16 10:32:43 +01:00
Arne Morten Kvarving
ff2e8c8333 Merge pull request #3435 from akva2/sync_find_quadmath
sync FindQuadMath with dune
2023-03-16 10:00:33 +01:00
Tor Harald Sandve
932ed862d5 add moles unit to unitsystem 2023-03-16 09:18:39 +01:00
Arne Morten Kvarving
215fdae47d changed: remove explicit option to enable/disable quadmath
not necessary as it is now only used for relevant targets
you can still use the generic -DCMAKE_DISABLE_FIND_PACKAGE_QuadMath=1 if you
so desire
2023-03-16 09:07:13 +01:00
Arne Morten Kvarving
509a018ae7 fixed: fix debug printing with quad
std::to_string(__float128) is not defined
we need to instance the evaluation formatter for __float128
2023-03-16 09:07:13 +01:00
Arne Morten Kvarving
27ecbe5c98 fixed: instance CO2Tables for quad if QuadMath was found 2023-03-16 09:07:13 +01:00
Arne Morten Kvarving
1ef0492763 sync FindQuadMath with dune
while at it, change to FindQuadMath, not FindQuadmath
2023-03-16 09:07:13 +01:00
Tor Harald Sandve
1db6e4d7dd add convertRswToXwg 2023-03-16 08:48:56 +01:00
Arne Morten Kvarving
6b71f3d3c2 Merge pull request #3417 from blattms/fix-hdf5-dune-2.6
Do not use FieldVector::data() mehod as it misses from DUNE 2.6.
2023-03-15 21:10:34 +01:00
goncalvesmachadoc
728d021e3d parse and do nothing, schedule keywords 2023-03-15 18:54:17 +01:00
goncalvesmachadoc
c7b80ccc72 fix parsing 2023-03-15 17:03:52 +01:00
Bård Skaflestad
03ab6356fb Merge pull request #3444 from akva2/fix_no_fortran_flags
fixed: quote in case of no existing flags
2023-03-15 11:32:45 +01:00
Arne Morten Kvarving
d0b6546a38 fixed: quote in case of no existing flags
this can happen for fortran flags as opm is not
using fortran itself (but it's potentially enabled
by BLAS)
2023-03-15 10:26:40 +01:00
goncalvesmachadoc
f32a4d6837 fix the mess 2023-03-14 17:19:56 +01:00
Markus Blatt
b30fe5fc4a Merge pull request #3441 from akva2/build_no_examples
fixed: building without examples
2023-03-14 16:15:57 +01:00
Arne Morten Kvarving
a6b2d2438b fixed: building without examples 2023-03-14 15:01:18 +01:00
Bård Skaflestad
80ce852f15 Merge pull request #3438 from GitPaean/stopped_wells_should_output_wmctl_zero
WMCTL is zero for wells with status STOP
2023-03-14 14:43:57 +01:00
Atgeirr Flø Rasmussen
3b4e5b97f7 Merge pull request #3426 from totto82/fix_gsf_cap
fix cap-press GSF
2023-03-14 14:14:41 +01:00
hnil
29e35211de fixed extra comment 2023-03-14 10:13:13 +01:00
goncalvesmachadoc
863fd0786d parse co2store + gaswat 2023-03-13 19:13:28 +01:00
Bård Skaflestad
b59fe0c068 Merge pull request #3439 from daavid00/fixClangbuild
fix to broken built with clang
2023-03-10 23:28:08 +01:00
David Landa Marban
8cbefba4c5 fix to broken built with clang 2023-03-10 22:33:08 +01:00
Kai Bao
ded3edd3bf WMCTL is zero for wells with status STOP 2023-03-10 15:12:14 +01:00
Paul Egberts
8f90d7fe89 Removal of unused files 2023-03-10 14:20:57 +01:00
Bård Skaflestad
d87ac33791 Merge pull request #3434 from blattms/refactor-parserinit
Reduce g++-12 resource consumptions for generated parser files.
2023-03-10 13:02:07 +01:00
Markus Blatt
3824d45f71 Prevent warnings about shadowing function parameters.
By skipping the parameter and using the class member directly.
2023-03-10 10:27:40 +01:00
Paul Egberts
8467d82eb6 Placed ResInsight code in separate namespace called external 2023-03-10 10:06:04 +01:00
Bård Skaflestad
6f460c3d27 Merge pull request #3409 from bska/revised-active-by-column
Enumerate Columns According to Horizontal Model Dimensions
2023-03-09 12:34:06 +01:00
hnil
8cf9efbcf6 fixed error if dune-fem is buildt with polygongrid 2023-03-09 11:41:04 +01:00
Markus Blatt
995ec609e3 Added missing include to ParserTests.cpp 2023-03-08 22:27:46 +01:00
Markus Blatt
380fd4963e Split Builtin.hpp into multiple compile units for g++-12.
g++-12 needs quite some memory and time to compile it.
We now use several Builtin*.cpp for the imlementations for different
starting letters of eclipse keywords to use less resources for
compiling.
2023-03-08 22:26:34 +01:00
Bård Skaflestad
040f0fddd8 Enumerate Columns According to Horizontal Model Dimensions
The inner loop is always across the model layers while we ensure
that the 'outer' loop always iterates over an index range that is at
least as large as that of the 'middle' loop.  This follows from
recent work on compatibility prompted by real field models with the
constant flux analytic aquifer type.

Thanks to [at]tskille for the additional insight.
2023-03-08 17:57:10 +01:00
Bård Skaflestad
f30cc5e980 Precompute Columnar Index Sorting Criterion
Expend memory to derive IJK triples exactly once for each cell.  The
latter is potentially an expensive operation.
2023-03-08 17:57:10 +01:00
Markus Blatt
b52dc598d3 Refactored ParserInit.cpp to reduce ram needed for compilation 2023-03-08 17:25:35 +01:00
Markus Blatt
a407f57df1 Merge pull request #3431 from akva2/allow_ndebug_reconfigure
fixed: allow reconfiguring with a different WITH_NDEBUG value
2023-03-08 11:31:56 +01:00
Arne Morten Kvarving
d5f895901f fixed: allow reconfiguring with a different WITH_NDEBUG value
in particular we have to make sure to remove the -UNDEBUG value from the
flags, as these are cached so any values previously added will still be
used
2023-03-08 09:40:03 +01:00
Bård Skaflestad
38ed82b2ce Merge pull request #3428 from vkip/use_pvtnum_as_default_rocknum
Using PVTNUM as the default ROCKNUM
2023-03-07 14:57:02 +01:00
Vegard Kippe
576c90d76e Delegating to default constructor, as suggested 2023-03-07 14:08:01 +01:00
Bård Skaflestad
ecac158bb7 Merge pull request #3429 from akva2/avoid_ndebug_warning
MinpvMode: avoid missing return value with NDEBUG
2023-03-07 13:48:18 +01:00
Arne Morten Kvarving
1958e2edf9 MinpvMode: avoid missing return value with NDEBUG 2023-03-07 11:55:59 +01:00
Arne Morten Kvarving
32bcc597e4 add missing include 2023-03-07 11:54:21 +01:00
Vegard Kippe
f48205e5ee Using PVTNUM as the default ROCKNUM 2023-03-06 18:12:05 +01:00
Tor Harald Sandve
351159d772 fix cap-press GSF 2023-03-06 11:45:06 +01:00
Atgeirr Flø Rasmussen
81e15329ee Merge pull request #3421 from hnil/new_property_small
New property
2023-03-05 10:09:17 +01:00
hnil
c0086e7be8 fixed remaining comments 2023-03-03 16:36:50 +01:00
hnil
e8b87af11a removed segment index from old code to avoid extra diffs 2023-03-03 15:03:16 +01:00
hnil
3cd55b5290 - changed materialsparams to not use shared pointers
- added interface of reusing search in tables

- fixed after modifiying files for minimal diffs

fixed NDEBUG things

fixed from review
2023-03-03 14:43:50 +01:00
Bård Skaflestad
1aaab7ce7c Merge pull request #3423 from bska/keep-all-schedule-aquflux-objects
Preserve SCHEDULE Section AQUFLUX Objects Across Report Steps
2023-03-03 13:49:14 +01:00
Bård Skaflestad
325228058b Preserve SCHEDULE Section AQUFLUX Objects Across Report Steps
This is in preparation of adding support for writing those objects
to the restart file.  We need a consistent view of active aquifers
for that purpose.
2023-03-03 11:07:13 +01:00
Bård Skaflestad
7b12d23d5d Merge pull request #3422 from akva2/thresholdpressure_irrevers_accessor
add accessor for m_irreversible in ThresholdPressure
2023-03-03 10:23:39 +01:00
Bård Skaflestad
1a47937b9f Merge pull request #3420 from akva2/disable_sigint_handler
fixed: disable python SIGINT signal handler for the embedded interpreter
2023-03-03 10:22:59 +01:00
Arne Morten Kvarving
bf7171f7c7 fixed: disable python SIGINT signal handler for the embedded interpreter 2023-03-03 09:30:29 +01:00
Arne Morten Kvarving
4d92298724 add accessor for m_irreversible in ThresholdPressure 2023-03-03 09:23:11 +01:00
Bård Skaflestad
4b7cf09b75 Merge pull request #3418 from akva2/split_timing_macros
split out timing macros to separate header
2023-03-01 15:29:49 +01:00
Arne Morten Kvarving
3fddcc0dd8 split out timing macros to separate header 2023-03-01 13:17:00 +01:00
Markus Blatt
393c42cd4c Do not use FieldVector::data() mehod as it misses from DUNE 2.6.
Instead we use the old fashioned way of checking the size and then
either return the address of the first element or a nullptr.

Closes OPM/opm-simulator#4472
2023-02-28 16:46:06 +01:00
Atgeirr Flø Rasmussen
c757fae0a6 Merge pull request #3416 from akva2/restart_serialize_inplace
Inplace: add restart serialization support
2023-02-28 07:50:48 +01:00
Atgeirr Flø Rasmussen
c6b9310922 Merge pull request #3415 from akva2/add_ioconfig_inputdir
added: getInputDir in IOConfig
2023-02-28 07:47:11 +01:00
Arne Morten Kvarving
eaaf02f51f Inplace: add restart serialization support 2023-02-27 13:57:23 +01:00
Arne Morten Kvarving
ca83776c34 added: getInputDir in IOConfig
returns the input directory
2023-02-27 12:15:47 +01:00
Paul Egberts
bfebe538c2 removal of unused files 2023-02-27 09:50:21 +01:00
Arne Morten Kvarving
a9ac9cbd58 minimum dune version required is now 2.7 2023-02-27 09:39:57 +01:00
Bård Skaflestad
1c0ddf1402 Merge pull request #3413 from daavid00/fixMacOSbuild
Fixing the broken build in macOS
2023-02-25 19:33:59 +01:00
David Landa Marban
a91844ecdb Fixing the build in macOS 2023-02-25 17:42:35 +01:00
Bård Skaflestad
762b43cfda Merge pull request #3408 from totto82/summary_co2store
Add WCD, GCDI, GCDM, WIPG, WIPL summary output for Field and Region
2023-02-24 16:44:36 +01:00
Bård Skaflestad
61cec09d0a Merge pull request #3406 from totto82/wsf_gsf
Implement WSF/GSF satfunc familiy for CO2STORE
2023-02-24 16:43:56 +01:00
Tor Harald Sandve
5a3d395482 cleanup and add more logging 2023-02-24 15:34:38 +01:00
Tor Harald Sandve
b5fdf35fbc Implement WSF/GSF satfunc familiy for CO2STORE 2023-02-24 15:07:30 +01:00
Arne Morten Kvarving
da492f8120 Merge pull request #3412 from akva2/serialize_hysteresis
Restart serialization: add hysteresis parameters
2023-02-24 11:41:33 +01:00
Arne Morten Kvarving
59d3619460 EclMaterialLawManager: add restart serialization support 2023-02-24 11:03:02 +01:00
Arne Morten Kvarving
b9a2b3fb86 EclXXXMaterialParams: add restart serialization support 2023-02-24 11:01:55 +01:00
Arne Morten Kvarving
09f1f06404 EclHysteresisTwoPhaseLawParams: add restart serialization support 2023-02-24 10:43:45 +01:00
Arne Morten Kvarving
ce9d8030d6 EclHysteresisTwoPhaseLawParams: header cleanup 2023-02-24 09:59:45 +01:00
Arne Morten Kvarving
11db5ce3af DirectionMaterialLawParams: add missing include
and some reformatting
2023-02-24 09:59:45 +01:00
Atgeirr Flø Rasmussen
60437b94df Merge pull request #3410 from totto82/addMissingHEATprops
Add missing HEATCR and HEATCRT to props
2023-02-24 08:55:29 +01:00
Tor Harald Sandve
89850adb09 Add WCD, GCDI, GCDM, WIPG, WIPL summary for F and R 2023-02-23 09:17:39 +01:00
Tor Harald Sandve
0f163d22bc Add missing HEATCR and HEATCRT to props 2023-02-23 08:36:12 +01:00
Bård Skaflestad
0feefbbd53 Merge pull request #3346 from totto82/add_void_pr_rate
Add WWVIR to VoidPRRate
2023-02-22 23:45:03 +01:00
Bård Skaflestad
945b2c2e8e Merge pull request #3407 from akva2/remove_dupe_symbols
fixed: remove duplicated symbols
2023-02-22 09:40:18 +01:00
Arne Morten Kvarving
3d755ea2a9 fixed: remove duplicated symbols
these were moved to Phase.cpp in f8e0319 but
I forgot to remove them from Runspec.cpp
2023-02-22 08:51:02 +01:00
Bård Skaflestad
4825a76b86 Merge pull request #3378 from GitPaean/support_aquflux
supporting the keyword AQUFLUX
2023-02-21 12:48:03 +01:00
Kai Bao
affdea72eb addressing reviewing comments for PR OPM/opm-common#3378 2023-02-21 10:47:42 +01:00
Kai Bao
1d8e92a262 putting AQUFLUX aquifers in one class 2023-02-17 17:32:24 +01:00
Kai Bao
35b095dfbc treat AQUFLUX keyword in SCHEDULE as individual events
We only check these keywords at the report step that the keywords are
specified.

Not totally sure how it will affect the RESTART, while it is not hard to
switch back.
2023-02-17 15:44:08 +01:00
Kai Bao
d3b629a76e AQUFLUX can run in parallel 2023-02-17 15:44:08 +01:00
Kai Bao
fceb3515b7 let AquiferConfig handle the AQUFLUX aquifer existence
for summary and restart file output.
2023-02-17 15:44:08 +01:00
Kai Bao
00ff5b41de creating dummy AQUFLUX aquifers in AquiferConfig
for the ones that were not specified in the SOLUTION section
2023-02-17 15:44:08 +01:00
Kai Bao
f081ee5826 using AquiferConfig to handle AQUFLUX aquifers 2023-02-17 15:44:08 +01:00
Kai Bao
d412158cf7 WIP in handling the summary output for AQUFLUX
AAQR, AAQP, AAQT works fine while FAQR and FAQT are not handled yet.
2023-02-17 15:44:08 +01:00
Kai Bao
83457f679e prototyping for the AQUFLUX parsing implementation
at the end, SOLUTIONSection() function is used to handle the
keywords in the SOLUTION section.
2023-02-17 15:44:08 +01:00
Kai Bao
1e4b33317b correcting the definition of keyword AQUFLUX 2023-02-17 15:44:08 +01:00
Atgeirr Flø Rasmussen
55efa07fe9 Merge pull request #3403 from totto82/fixJfunc
BUGFIX JFUNC,  use the correct config file when getting the endpoints
2023-02-17 11:49:12 +01:00
Tor Harald Sandve
0c1e891d0a BUGFIX JFUNC, use the correct config file when getting the endpoints 2023-02-17 11:04:47 +01:00
Bård Skaflestad
d439ef9b91 Merge pull request #3402 from akva2/gpmaint_state_comp_op
GPMaint::State: add comparison operator
2023-02-15 20:54:18 +01:00
Arne Morten Kvarving
c5a2807b44 GPMaint::State: add comparison operator
while at it, move some code to cpp file and add missing headers
2023-02-15 20:04:20 +01:00
Bård Skaflestad
708964721d Merge pull request #3400 from hnil/add_timing_block
added timingblocks most important functions
2023-02-15 12:37:03 +01:00
Bård Skaflestad
652713b0ef Merge pull request #3397 from GitPaean/aquct_fetp_not_schedule
throw when AQUCT and AQUFETP are used as SCHEDULE keywords
2023-02-15 11:37:25 +01:00
Kai Bao
812d119363 give error messages for AQUCT and AQUFETP in SCHEDULE section 2023-02-15 10:12:01 +01:00
hnil
a3e025290f added timingblocks most important functions 2023-02-15 09:39:14 +01:00
Bård Skaflestad
63bfa8e47c Merge pull request #3399 from akva2/serialization_test_mark_const
test_Serialization: mark variables const
2023-02-14 14:38:42 +01:00
Arne Morten Kvarving
735bca1d8f test_Serialization: mark variables const 2023-02-14 13:49:51 +01:00
Bård Skaflestad
a8a2e0f317 Merge pull request #3398 from hnil/nicer_comments
Removed unnecessary comment
2023-02-14 12:28:20 +01:00
hnil
502b0df428 Removed unnecessary comment 2023-02-14 11:07:52 +01:00
Kai Bao
a89136f1f2 only using the AQUCT and AQUFETP in SOLUTION section
to generate the aquifers in AquiferConfig.
2023-02-14 10:44:17 +01:00
Bård Skaflestad
093ead5946 Merge pull request #3353 from bska/summary-state-seg-var
Add Separate SummaryState Data Member for Segment Level Values
2023-02-10 16:12:02 +01:00
Bård Skaflestad
93b340cede Store Per-Segment Summary Vectors Separately
Enables easier access for UDQ/ACTIONX purposes.

While here, also move the serializationTestObject() member
function's implementation to the .cpp file.
2023-02-10 15:26:27 +01:00
Bård Skaflestad
a76768cf75 Reorder SummaryState Member Functions
This way the implementation file matches the declared order in the
header file.
2023-02-10 15:26:27 +01:00
Markus Blatt
febb03c9d6 Merge pull request #3395 from akva2/multregp_multiple_record
fixed: process all MULTREGP entries in the deck
2023-02-10 15:03:52 +01:00
Bård Skaflestad
6d93cc7969 Merge pull request #3393 from akva2/guiderate_serialize
GuideRate: add serialization support
2023-02-10 14:56:09 +01:00
Markus Blatt
18db394b34 Merge pull request #3396 from blattms/fix-multiple-boost-searches
[bugfix] Make sure to use CONFIG mode  for subsequent boost searches.
2023-02-10 14:44:34 +01:00
Arne Morten Kvarving
02faaedcfd add serialization support to GuideRate 2023-02-10 14:11:10 +01:00
Bård Skaflestad
f09c42ae17 Merge pull request #3392 from akva2/gpmaint_serialize
GPMaint::State: add serialization support
2023-02-10 12:28:14 +01:00
Bård Skaflestad
335c375c9d Merge pull request #3391 from goncalvesmachadoc/errorMsgTables
Improve Simple Table errros messages
2023-02-10 12:26:33 +01:00
Bård Skaflestad
2171c7afe6 Merge pull request #3389 from hnil/timing_block
Added empty macro which can be used for timing with for example Tracy
2023-02-10 12:22:44 +01:00
hnil
05a7672173 addressed review comments 2023-02-10 11:13:08 +01:00
Markus Blatt
ff08945b4f [bugfix] Make sure to use CONFIG mode for subsequent boost searches.
Otherwise boost components found by previous search will be marked as
not found if a new component is not found in the new search.

This happend for #3381 if regex was not found and made cmake believe
that unit_test_framework was not found either. Even though it was in a
previous search.

Now we make sure to CONFIG mode if boost was found before, which fixes
this problem. Also we only link dunecommon to test if they are
actually built (read unit_test_framework was marked as found).

Closes #3881
2023-02-09 22:18:16 +01:00
goncalvesmachadoc
0a23c63c28 rewrite message 2023-02-09 21:29:55 +01:00
goncalvesmachadoc
b24130aedc update unit tests 2023-02-09 20:51:41 +01:00
goncalvesmachadoc
b2325c7d6d add Table name 2023-02-09 17:18:01 +01:00
goncalvesmachadoc
71fc372ced print order schema 2023-02-09 16:00:56 +01:00
goncalvesmachadoc
f74dd68755 pass by reference 2023-02-09 16:00:12 +01:00
Arne Morten Kvarving
49fb77a339 fixed: process all MULTREGP entries in the deck 2023-02-09 11:00:05 +01:00
goncalvesmachadoc
5c1b6f5dbc msg typo fix 2023-02-09 10:09:30 +01:00
goncalvesmachadoc
599979452a table name to column number throw 2023-02-08 19:32:44 +01:00
Bård Skaflestad
872e7b04ba Merge pull request #3394 from bska/fix-out-of-bounds
Don't Index Out of Bounds in Vector
2023-02-08 15:02:40 +01:00
Bård Skaflestad
e6abb5e3df Don't Index Out of Bounds in Vector
In the admittedly special case that "position" is equal to the
buffer's size() and "n == 0", then the expression

   &buffer[position]

will index out of bounds.  Use the safer expression

   buffer.data() + position

instead since that's valid when position <= size().

Detected by libstdc++'s debug mode (checked iterators).
2023-02-08 12:52:28 +01:00
Arne Morten Kvarving
59393b49f7 add serialization support to GPMaint::State 2023-02-08 12:37:18 +01:00
Bård Skaflestad
182d58e210 Merge pull request #3388 from akva2/evaluation_serialize
Evaluation: add serialization support
2023-02-08 12:35:40 +01:00
Arne Morten Kvarving
1be072adf2 add serialization support to Evaluation 2023-02-08 10:20:30 +01:00
Atgeirr Flø Rasmussen
46d268fba0 Merge pull request #3383 from akva2/mempacker_public
changed: rename the packer used in test_Serialization to MemPacker
2023-02-08 10:19:28 +01:00
goncalvesmachadoc
65535202cc addKeywordName 2023-02-07 18:16:06 +01:00
Markus Blatt
4d39ccd1dc Merge pull request #3338 from bska/parse-segment-selector
Recognise Numbers as Part of UDQ Set Selector
2023-02-07 13:48:40 +01:00
Bård Skaflestad
2109552335 Recognise Numbers as Part of UDQ Set Selector
Needed in order to support segment sets which, potentially, have
both a well name pattern and a segment number.

This change also means that we now support *parsing* block (cell)
UDQ sets like

    BPR 11 22 33

and that, in turn, means we detect unsupported UDQ types later than
we used to.  That also means that the error detection exception type
changes, so update affected unit tests accordingly.
2023-02-07 09:47:46 +01:00
Bård Skaflestad
bd7de87ac2 Pull String Token Normalisation Out to New Helper
This enables constructing UDQDefine::m_tokens in the initialiser
list.
2023-02-03 17:59:10 +01:00
Bård Skaflestad
9161ac9503 Split Scalar Value Scattering Out to Helper Function
In preparation of adding support for segment level UDQs.  While
here, also apply const in a few places.
2023-02-03 17:59:10 +01:00
Bård Skaflestad
b1f3b3b4cf Adjust Whitespace in UDQ Tests Implementation File
In preparation of adding tests for segment level UDQs.
2023-02-03 17:59:10 +01:00
Markus Blatt
b034c91483 Merge pull request #3379 from bska/prepare-udq-assign-segment
Prepare for Handling UDQ ASSIGN for Segments
2023-02-03 17:50:17 +01:00
hnil
9613cdd917 Added empty marco which can be used for timing with forexample Tracy 2023-02-02 14:19:51 +01:00
Paul Egberts
039064dc25 added missing *.inl files to make file 2023-02-02 14:05:30 +01:00
Paul Egberts
306dad84ae explicit listing of header files, removed globbing 2023-02-02 13:42:09 +01:00
Bård Skaflestad
2b2330ab24 Prepare for Handling UDQ ASSIGN for Segments
This commit adds support for constructing UDQ ASSIGN records for
enumerated well items such as those encountered in UDQs at the
segment level, e.g.,

    ASSIGN SUSPECT PROD01    123.456 /
    ASSIGN SUSPECT PROD02 17 654.321 /

We do not support this syntax quite yet, but this is a step on the
way there.
2023-02-02 12:43:16 +01:00
Bård Skaflestad
e67a49b10f Merge pull request #3387 from akva2/aquifer_missing_include
SingleNumericalAquifer: add missing include
2023-02-02 12:29:21 +01:00
Arne Morten Kvarving
2e15535afe SingleNumericalAquifer: add missing include 2023-02-02 11:41:50 +01:00
Paul Egberts
61df4153a7 attempt to fix build error 2023-02-02 11:22:41 +01:00
Bård Skaflestad
f1326bb134 Merge pull request #3224 from daavid00/flres
FLOWS and FLORES support
2023-02-02 10:37:23 +01:00
Arne Morten Kvarving
d04a30592a Serializer: handle Dune::BlockVector as vectors 2023-02-01 14:49:15 +01:00
Arne Morten Kvarving
6ba29b0920 Serializer: allow generic vector classes
needs to adhere to stl's interface
2023-02-01 14:48:39 +01:00
Arne Morten Kvarving
e211a8cbf6 Serializer: handle Dune::FieldVector as arrays 2023-02-01 14:39:32 +01:00
Arne Morten Kvarving
7e6b28317a Serializer.hpp: add missing include 2023-02-01 10:48:48 +01:00
Arne Morten Kvarving
b138598518 changed: rename the packer used in test_Serialization to MemPacker
make it a public header so it can be reused elsewhere.
2023-02-01 10:48:48 +01:00
Atgeirr Flø Rasmussen
59ae098ff8 Merge pull request #3385 from daavid00/fixMacbuild
Fixing broken built in macOS
2023-02-01 10:39:53 +01:00
David Landa Marban
78ed39bd51 Fixing broken built in macOS 2023-02-01 09:56:15 +01:00
Paul Egberts
61c708b1fc added resinsight include files in cmake file part 2 2023-01-31 22:22:51 +01:00
Paul Egberts
eb91e408ed added resinsight include files in cmake file 2023-01-31 21:46:43 +01:00
Paul Egberts
7966248eaa cmake file fix 2023-01-31 16:44:16 +01:00
Paul Egberts
4f737abe7b Merge branch 'master' into well-traj 2023-01-31 14:04:57 +01:00
Paul Egberts
5ddfebc585 added #include <string> 2023-01-31 14:00:10 +01:00
Paul Egberts
3bcfd3ddec repairing cmake file 2023-01-31 13:18:14 +01:00
Paul Egberts
107e7fdec8 added test for calculation of CFs and IJK coordinates of intersected cells 2023-01-30 22:18:32 +01:00
Paul Egberts
83934226aa finalizing and cleaning up 2023-01-30 22:18:32 +01:00
Paul Egberts
c617224adb Processing WELTRAJ/COMPTRAJ; Calculation of intersected cells and CFs 2023-01-30 22:18:31 +01:00
Paul Egberts
6e5f0da06c finalizing keywords COMPTRAJ and WELTRAJ 2023-01-30 22:18:31 +01:00
Paul Egberts
446ab3830c This is a combination of 5 commits.
Reorganizing and renaming files
2023-01-30 22:11:28 +01:00
Tor Harald Sandve
9b3e1f92bf Merge pull request #3364 from hakonhagland/imbnum3
Adds support for directional relative permeabilities with hysteresis
2023-01-30 12:33:36 +01:00
Markus Blatt
b83f10d2d7 Merge pull request #3373 from bska/support-numbered-udq-scalars
Add Numbered Item to UDQ Scalars
2023-01-27 15:49:21 +01:00
Håkon Hægland
5430dc46a4 Compute the oil-water scaled info
We need to compute the oil-water scaled info even if we are running a
two-phase case without water (e.g. gas-oil) since the oil-water scaled
info is used when computing the initial condition
2023-01-24 21:50:43 +01:00
Bård Skaflestad
b3dd728a2e Add Numbered Item to UDQ Scalars
This is in preparation of adding UDQs at the segment level.  We will
probably need to rethink the UDQ scalars and UDQ sets at some point,
since the lookup and assignment operations become more expensive
from adding this piece of information.

While here, also add containers for segment level UDQs to the UDQ
state object.  These are currently unused, but adding them here
simplifies follow-up work.

Finally, add some Doxygen-style documentation to the UDQ set and
scalar types.
2023-01-24 19:45:46 +01:00
Kai Bao
2b2c05d9a1 Merge pull request #3377 from GitPaean/updating_nodal_pressure_schedule
we need to update the nodal pressure when a new NODEPROP is specified in the schedule
2023-01-23 12:36:46 +01:00
Kai Bao
e5bb64fb65 when a new NODEPROP is specified
we need to update the nodal pressure. Master branch uses std::map::insert(), the new
value will not be used if the node exists already.
2023-01-23 11:42:33 +01:00
David Landa-Marbán
37ec6667cf Merge branch 'OPM:master' into flres 2023-01-19 15:11:56 +01:00
Arne Morten Kvarving
0801519f97 Merge pull request #3376 from akva2/restartvalue_move_to_cpp
RestartValue: move some more code to compile unit
2023-01-19 14:28:53 +01:00
Markus Blatt
55a9f44d49 Merge pull request #3374 from akva2/pavgcalculatorcollection.hpp_reduce_hotness
Summary.hpp: forward PAvgCalculatorCollection
2023-01-19 14:05:28 +01:00
Arne Morten Kvarving
eed2a179ca RestartValue: move some more code to compile unit 2023-01-19 13:40:15 +01:00
Arne Morten Kvarving
abce488f3b Summary.hpp: forward PAvgCalculatorCollection 2023-01-19 13:19:27 +01:00
Bård Skaflestad
b82508dd7c Merge pull request #3372 from akva2/summarystate.hpp_reduce_hotness
ActionContext: forward SummaryState
2023-01-18 15:42:44 +01:00
Markus Blatt
00442c2e2e Merge pull request #3371 from akva2/well_enums
Move well enums and controls to separate classes
2023-01-18 14:13:27 +01:00
Markus Blatt
476a65ddae Merge pull request #3370 from bska/udq-config-tidy
Fuse Multiple DEFINE Types Into Single Evaluation Loop
2023-01-18 14:12:16 +01:00
Arne Morten Kvarving
f8eca58408 ActionContext: forward SummaryState 2023-01-18 13:48:46 +01:00
Bård Skaflestad
daa3f8b670 Fuse Multiple DEFINE Types Into Single Evaluation Loop
This commit switches the implementation of eval_define() into a
single loop over UDQConfig::input_index instead of multiple loops
over subsets of the same input index.  While this is more complex
logic, it saves forming multiple intermediate quantities that will
for the most part be discarded.

This is also in preparation of adding support for segment level
UDQs, which would necessitate another loop in the previous control
structure.

While here, also switch to using structured bindings where
appropriate and pruning a few other intermediate objects.
2023-01-18 13:22:23 +01:00
Arne Morten Kvarving
6a23f5d891 Merge pull request #3369 from bska/name-order-tidy
Slight Polish to NameOrder Component
2023-01-18 12:18:16 +01:00
Arne Morten Kvarving
a1892961ca Merge pull request #3368 from bska/udq-func-tidy
Adjust Whitespace And Simplify Logic Slightly
2023-01-18 11:54:48 +01:00
Arne Morten Kvarving
b61f97aeba changed: move ProductionControls to separate header
and make the class member type with a using statement.
allows for forwarding
2023-01-18 11:45:21 +01:00
Arne Morten Kvarving
82093da0bb changed: move InjectionControls to separate header
and make the class member type with a using statement.
allows for forwarding
2023-01-18 11:44:32 +01:00
Arne Morten Kvarving
9ef643345d Schedule.hpp: forward Well 2023-01-18 11:01:41 +01:00
Arne Morten Kvarving
31d83cf0a7 eval_uda.hpp: remove unnecessary Well.hpp include
also remove ScheduleTypes.hpp include, forward Phase and InjectorType
2023-01-18 11:01:41 +01:00
Arne Morten Kvarving
904e879cbe Wells.hpp: include WellEnums.hpp not Well.hpp 2023-01-18 10:32:16 +01:00
Arne Morten Kvarving
33f095d145 ScheduleState.hpp: include WellEnums.hpp instead of Well.hpp
and forward Well
2023-01-18 10:23:45 +01:00
Arne Morten Kvarving
120a56930c GuideRateModel.hpp: forward WellGuideRateTarget 2023-01-18 10:14:01 +01:00
Arne Morten Kvarving
955ef0c2d4 GuideRateConfig.hpp: include WellEnums.hpp not Well.hpp 2023-01-18 10:08:52 +01:00
Arne Morten Kvarving
6f5cb645ff GuideRate.hpp: forward WellGuideRateTarget 2023-01-18 10:04:26 +01:00
Bård Skaflestad
6a3a0dc422 Adjust Whitespace And Simplify Logic Slightly
Mostly for readability and maintainability.
2023-01-18 09:41:32 +01:00
Bård Skaflestad
c859027b86 Slight Polish to NameOrder Component
Mostly whitespace, but one instance of preferring a standard
algorithm over a raw loop.
2023-01-18 09:40:53 +01:00
Arne Morten Kvarving
4d90ab1c72 move string conversion of WellGasInflowEquation to WellEnums.cpp 2023-01-18 09:39:49 +01:00
Arne Morten Kvarving
8e29ef4c07 move string conversion of WellGuideRateTarget to WellEnums.cpp 2023-01-18 09:33:50 +01:00
Arne Morten Kvarving
6565ea0f1f move string conversion of WellWELTARGCMode to WellEnums.cpp 2023-01-18 09:26:34 +01:00
Arne Morten Kvarving
0ef729ba72 move printing of WellProducerCMode to WellEnums.cpp 2023-01-18 09:20:43 +01:00
Arne Morten Kvarving
a540ac54b8 move printing of WellInjectorCMode to WellEnums.cpp 2023-01-18 09:08:27 +01:00
Arne Morten Kvarving
3d0ca8438b move printing of WellStatus to WellEnums.cpp 2023-01-18 08:59:09 +01:00
Arne Morten Kvarving
3c4a64f7f4 move Well enums to separate file
and the class member types are constructed with using statements.
this allows for forwarding of the enums, and for using the enums
without dragging in Well.hpp
2023-01-18 08:58:30 +01:00
Bård Skaflestad
736e1b9f5c Merge pull request #3367 from akva2/eclipsegrid_hpp_cleanup
Some small header cleanups
2023-01-17 13:29:06 +01:00
Arne Morten Kvarving
cf55b176b0 ExtSmryOutput.hpp: forward EclipseState 2023-01-17 12:24:01 +01:00
Arne Morten Kvarving
b57a1d941f Merge pull request #3254 from akva2/eclthermallawmanager_encapsulate
EclThermalLawManager: move code to separate compile unit
2023-01-17 12:23:38 +01:00
Arne Morten Kvarving
ee5b4240be EclThermalLawManager: replace naked throws with OPM_THROW 2023-01-17 11:39:32 +01:00
Arne Morten Kvarving
75a6b603c5 EclThermalLawManager: move code to separate compile unit 2023-01-17 11:39:30 +01:00
Arne Morten Kvarving
0a66661b98 EclipseIO.hpp: forward EclipseGrid 2023-01-17 10:42:32 +01:00
Arne Morten Kvarving
dc309147cb Connection.cpp: remove unnecessary ParseContext.hpp include 2023-01-17 09:53:54 +01:00
Bård Skaflestad
8e16ca04bd Merge pull request #3366 from akva2/welltestconfig.hpp_reduce_hotness
WellTestState: forward WellTestConfig
2023-01-17 09:23:47 +01:00
Arne Morten Kvarving
c9074be104 WellTestState: forward WellTestConfig 2023-01-17 07:00:38 +01:00
Arne Morten Kvarving
06f1b6e8f9 make WellTestConfig::Reason a namespace scoped enum WTest::Reason
and alias it as WellTestConfig::Reason
2023-01-17 07:00:24 +01:00
Arne Morten Kvarving
5382a52649 WellTestState.hpp: remove unnecessary Well.hpp include 2023-01-17 07:00:14 +01:00
Bård Skaflestad
67dbd5baa8 Merge pull request #3365 from akva2/inputerroraction.hpp_reduce_hotness
Schedule.hpp: forward InputErrorAction
2023-01-16 23:27:18 +01:00
Bård Skaflestad
a476068dbd Merge pull request #3362 from akva2/trancalculator.hpp_reduce_hotness
FieldPropsManager.hpp: forward TranCalculator
2023-01-16 22:54:53 +01:00
Arne Morten Kvarving
ddef6302e6 ParseContext: forward InputErrorAction 2023-01-16 22:17:50 +01:00
Arne Morten Kvarving
564943dc84 ParseContext: remove unnecessary OpmLog.hpp include 2023-01-16 22:17:50 +01:00
Arne Morten Kvarving
6397d5c262 ParseContext.hpp: remove default values for parameters 2023-01-16 22:17:50 +01:00
Arne Morten Kvarving
6312bf1189 Schedule.hpp: forward InputErrorAction 2023-01-16 22:17:50 +01:00
Arne Morten Kvarving
edf937e2e5 InputErrorAction: convert to enum class 2023-01-16 22:17:50 +01:00
Arne Morten Kvarving
b617c2af13 remove Fieldprops::TranMap 2023-01-16 21:49:12 +01:00
Håkon Hægland
9c47f8900d Add support for IMBNUM
First stage in adding support for using imbibition for cell faces (IMBNUMX,
IMBNUMY, IMBNUMZ). At the same time, refactors initParamsForElements() in
EclMaterialLawManager.hpp into separate files to more easily add support
for materal law parameters for cell faces.
2023-01-16 21:29:25 +01:00
Arne Morten Kvarving
f1e5ce372b FieldPropsManager.hpp: forward TranCalculator 2023-01-16 20:23:03 +01:00
Bård Skaflestad
e1c0409f42 Merge pull request #3363 from akva2/restartvalue.hpp_reduce_hotness
(Eclipse|Restart)IO: forward Restart(Key|Value)
2023-01-16 17:26:27 +01:00
Arne Morten Kvarving
7468f23875 (Eclipse|Restart)IO: forward Restart(Key|Value) 2023-01-16 15:19:48 +01:00
Bård Skaflestad
a47716e97c Merge pull request #3361 from akva2/fielddata.hpp_reduce_hotness
FieldPropsManager.hpp: forward FieldData
2023-01-16 14:53:17 +01:00
Bård Skaflestad
d281e50cde Merge pull request #3360 from akva2/units.hpp_reduce_hotness
Well.hpp: remove unnecessary Units.hpp include
2023-01-16 13:48:38 +01:00
Bård Skaflestad
2bc2ea372a Merge pull request #3357 from akva2/wvfpexp.hpp_reduce_hotness
Well.hpp: forward WVFPEXP
2023-01-16 13:24:29 +01:00
Bård Skaflestad
ec1bfba848 Merge pull request #3359 from akva2/activegridcells.hpp_reduce_hotness
Well.hpp: remove unnecessary ActiveGridCells.hpp include
2023-01-16 13:14:31 +01:00
Arne Morten Kvarving
6994efa497 FieldPropsManager.hpp: forward FieldData 2023-01-16 13:06:14 +01:00
Arne Morten Kvarving
31b17021a2 Keywords.hpp: add missing string include 2023-01-16 13:05:37 +01:00
Arne Morten Kvarving
b5948efa4f Well.hpp: remove unnecessary Units.hpp include 2023-01-16 12:06:58 +01:00
Arne Morten Kvarving
9daf73f152 Well.hpp: remove unnecessary ActiveGridCells.hpp include 2023-01-16 12:03:19 +01:00
Arne Morten Kvarving
c105b968ad Merge pull request #3358 from atgeirr/silence-struct-class-warnings
Forward declare structs as struct, not class, to silence warnings.
2023-01-16 11:25:26 +01:00
Atgeirr Flø Rasmussen
78d63b422a Forward declare structs as struct, not class, to silence warnings. 2023-01-16 10:33:58 +01:00
Arne Morten Kvarving
f51c065772 Well.hpp: forward WVFPEXP 2023-01-16 09:57:57 +01:00
Bård Skaflestad
402eb8d7ed Merge pull request #3356 from akva2/welleconproductionlimits.hpp_reduce_hotness
Well.hpp: forward WellEconProductionLimits
2023-01-14 12:10:12 +01:00
Arne Morten Kvarving
74098e23cd Well.hpp: forward WellEconProductionLimits 2023-01-13 21:16:06 +01:00
Bård Skaflestad
ff05175732 Merge pull request #3355 from blattms/python-fix-deprecated-asserEquals
Python fix warnings about deprecations and resources in tests.
2023-01-13 20:38:51 +01:00
Markus Blatt
edcd66987a [python] Run unit tests directly and not via setup.py (deprecated).
Thus we get rid of the warning:

WARNING: Testing via this command is deprecated and will be removed in
a future version. Users looking for a generic test entry point
independent of test runner are encouraged to use tox.
2023-01-13 18:15:09 +01:00
Markus Blatt
b007ef345c [python] Prevent "ResourceWarning: unclosed file <_io.TextIOWrapper 2023-01-13 18:14:28 +01:00
Markus Blatt
dd0ac8a669 [python] Use assertEqual instead of deprecated assertEquals-
Prevents warnings like
```
1: test_faults (tests.test_state.TestState2.test_faults) ... /<<PKGBUILDDIR>>/obj-arm-linux-gnueabihf/python/tests/test_state.py:124: DeprecationWarning: Please use assertEqual instead.
1:   self.assertEquals([], self.state.faultNames())
```
On Debian unstable.
2023-01-13 18:14:28 +01:00
Bård Skaflestad
f98180652c Merge pull request #3354 from akva2/wellmicpproperties.hpp_reduce_hotness
Well.hpp: forward WellMICPProperties
2023-01-13 16:21:21 +01:00
Arne Morten Kvarving
c58fc34a71 Well.hpp: forward WellMICPProperties 2023-01-13 15:29:28 +01:00
Bård Skaflestad
39552dd224 Merge pull request #3352 from akva2/wellpolymerproperties.hpp_reduce_hotness
Well.hpp: forward WellPolymerProperties
2023-01-13 15:28:28 +01:00
Bård Skaflestad
2ffe99a149 Merge pull request #3349 from plgbrts/permfact
Permfact table fix
2023-01-13 15:09:25 +01:00
Bård Skaflestad
df232628fd Merge pull request #3351 from bska/user-normal-serialization-for-udq-state
Prefer Standard Serialization Mechanism for UDQState
2023-01-13 14:47:36 +01:00
Arne Morten Kvarving
80dabaea3b Well.hpp: forward WellPolymerProperties 2023-01-13 14:04:12 +01:00
Bård Skaflestad
d94d048872 Merge pull request #3350 from akva2/welltracerproperties.hpp_reduce_hotness
Well.hpp: forward WellTracerProperties
2023-01-13 14:03:47 +01:00
Bård Skaflestad
c2800bed76 Prefer Standard Serialization Mechanism for UDQState
The serialization code handles nested structures out of the box and
does not need dedicated logic anymore.

While here, also move the serializationTestObject member function's
implementation to the .cpp file.
2023-01-13 13:49:04 +01:00
Arne Morten Kvarving
0750cc8cc2 Well.hpp: forward WellTracerProperties 2023-01-13 12:40:04 +01:00
Bård Skaflestad
48c9d29b1f Merge pull request #3348 from akva2/wellbrineproperties.hpp_reduce_hotness
Well.hpp: forward WellBrineProperties
2023-01-13 12:39:44 +01:00
Paul Egberts
7a78aea922 permfact json file fix 2023-01-13 12:10:01 +01:00
Paul Egberts
59dfa6f4b1 permfact table fix 2023-01-13 11:40:36 +01:00
Arne Morten Kvarving
5f6d3176b8 Well.hpp: forward WellBrineProperties 2023-01-13 11:36:00 +01:00
Bård Skaflestad
cd73e44539 Merge pull request #3347 from akva2/wellfoamproperties.hpp_reduce_hotness
Well.hpp: forward WellFoamProperties
2023-01-13 11:35:31 +01:00
Arne Morten Kvarving
253bb22e3c Well.hpp: forward WellFoamProperties 2023-01-13 10:16:37 +01:00
Tor Harald Sandve
ec7c8bceba Add WWVIR to VoidPRRate 2023-01-13 09:31:55 +01:00
Arne Morten Kvarving
608e5cd42b Merge pull request #3345 from bska/expose-segment-set-type
Pull SegmentSet Out to Main OPM Namespace
2023-01-12 17:28:19 +01:00
Bård Skaflestad
70d66b64ee Pull SegmentSet Out to Main OPM Namespace
This way we can forward-declare the class and won't have include the
SegmentMatcher header whenever we need to declare a function that
takes or returns a SegmentSet.

Inspired by recent work by [at]akva2.
2023-01-12 16:51:38 +01:00
Bård Skaflestad
938e0e135b Merge pull request #3344 from akva2/wellsegments.hpp_reduce_hotness
Well.hpp: forward WellSegments
2023-01-12 16:32:36 +01:00
Arne Morten Kvarving
60181dd5f4 WellSegments: make enum forwardable 2023-01-12 14:37:46 +01:00
Arne Morten Kvarving
574407746d Well.hpp: forward WellSegments 2023-01-12 14:37:46 +01:00
Bård Skaflestad
30dc1db44a Merge pull request #3343 from akva2/wellconnections.hpp_reduce_hotness
Well.hpp: forward WellConnections
2023-01-12 13:58:29 +01:00
Arne Morten Kvarving
17e8063caa Well: add hasConnections
this allows user code to query if there are connections without pulling
in the WellConnection class
2023-01-12 12:53:54 +01:00
Arne Morten Kvarving
cc68336d22 Well.hpp: forward WellConnections 2023-01-12 12:24:38 +01:00
Bård Skaflestad
43dbf3f043 Merge pull request #3342 from akva2/rftconfig.hpp_reduce_hotness
ScheduleState.hpp: forward RFTConfig
2023-01-12 11:36:13 +01:00
Arne Morten Kvarving
cb6a0aba4b Merge pull request #3320 from akva2/python_build_cmake
changed: build opm-common python extension using cmake
2023-01-12 11:08:27 +01:00
Arne Morten Kvarving
a1003c648d ScheduleState.hpp: forward RFTConfig 2023-01-12 10:34:22 +01:00
Bård Skaflestad
652ae6757f Merge pull request #3341 from akva2/udqconfig.hpp_reduce_hotness
ScheduleState.hpp: forward UDQConfig
2023-01-12 10:33:04 +01:00
Arne Morten Kvarving
5d854d1d6d changed: build opm-common python extension using cmake
only use setup.py to generate wheels. adjust pypi packaging
accordingly
2023-01-12 10:14:38 +01:00
Arne Morten Kvarving
a8e5fa4d52 ScheduleState.hpp: forward UDQConfig 2023-01-12 09:39:20 +01:00
Bård Skaflestad
85fc610c85 Merge pull request #3340 from akva2/udqactive.hpp_reduce_hotness
ScheduleState.hpp: forward UDQActive
2023-01-11 16:11:56 +01:00
Arne Morten Kvarving
165a22e289 remove trailing semicolons from namespace closure braces 2023-01-11 15:17:55 +01:00
Arne Morten Kvarving
21d60f4eba ScheduleState.hpp: forward UDQActive 2023-01-11 15:17:06 +01:00
Arne Morten Kvarving
f10d7e4fd3 AggregateActionxData.hpp: remove unnecessary UDQActive.hpp include 2023-01-11 15:17:06 +01:00
Bård Skaflestad
0d550ddc3a Merge pull request #3339 from akva2/actions.hpp_reduce_hotness
ScheduleState.hpp: forward Action::Actions
2023-01-11 14:43:15 +01:00
Arne Morten Kvarving
5e74b915b5 ScheduleState.hpp: forward Action::Actions 2023-01-11 13:51:28 +01:00
Markus Blatt
032a9ba291 Merge pull request #3337 from akva2/balance.hpp_reduce_hotness
ScheduleState.hpp: forward Network::Balance
2023-01-11 13:29:17 +01:00
Arne Morten Kvarving
7b938a0115 ScheduleState.hpp: forward Network::Balance 2023-01-11 11:29:27 +01:00
Bård Skaflestad
89957cdbd7 Merge pull request #3335 from akva2/extnetwork.hpp_reduce_hotness
ScheduleState.hpp: forward Network::ExtNetwork
2023-01-11 11:28:48 +01:00
Arne Morten Kvarving
36b196624a ScheduleState.hpp: forward Network::ExtNetwork 2023-01-11 10:36:22 +01:00
Bård Skaflestad
3a0a4885c9 Merge pull request #3334 from akva2/drop_group.hpp_include
AggregateNetworkData.hpp: remove unnecessary Group.hpp include
2023-01-11 10:35:23 +01:00
Bård Skaflestad
340095d5c8 Merge pull request #3333 from akva2/gconsale.hpp_reduce_hotness
ScheduleState.hpp: forward GConSale
2023-01-11 09:59:43 +01:00
Arne Morten Kvarving
cf24cc99f0 AggregateNetworkData.hpp: remove unnecessary Group.hpp include 2023-01-11 09:53:10 +01:00
Arne Morten Kvarving
b843783223 ScheduleState.hpp: forward GConSale 2023-01-11 08:49:09 +01:00
Bård Skaflestad
4ff9f59c7b Merge pull request #3332 from akva2/gconsump.hpp_reduce_hotness
ScheduleState.hpp: forward GConSump
2023-01-10 16:38:30 +01:00
Bård Skaflestad
f247edbab5 Merge pull request #3331 from akva2/remove_empty_headers
Remove some empty headers
2023-01-10 15:45:00 +01:00
Arne Morten Kvarving
89d531e10a ScheduleState.hpp: forward GConSump 2023-01-10 14:59:55 +01:00
Bård Skaflestad
540c1c7abf Merge pull request #3330 from akva2/wlistmanager.hpp_reduce_hotness
ScheduleState.hpp: forward WListManager
2023-01-10 14:57:15 +01:00
Arne Morten Kvarving
0dbfbd10df remove empty header InjectionControls.hpp 2023-01-10 14:50:50 +01:00
Arne Morten Kvarving
235a964ebc remove empty header ProductionControls.hpp 2023-01-10 14:35:50 +01:00
Arne Morten Kvarving
f8680bd6c4 ScheduleState.hpp: forward WListManager 2023-01-10 14:04:52 +01:00
Arne Morten Kvarving
68d85c97bb ActionContext.hpp: forward WListManager 2023-01-10 14:04:45 +01:00
Bård Skaflestad
036aa91fb3 Merge pull request #3329 from akva2/nameorder.hpp_reduce_hotness
ScheduleState.hpp: forward (Group|Name)Order
2023-01-10 14:00:12 +01:00
Arne Morten Kvarving
e272ad5226 ScheduleState.hpp: forward (Group|Name)Order 2023-01-10 13:06:34 +01:00
Bård Skaflestad
f0dfd8200c Merge pull request #3328 from akva2/wellmatcher.hpp_reduce_hotness
UDQContext.hpp: forward WellMatcher
2023-01-10 13:00:26 +01:00
Arne Morten Kvarving
ba2ec8957f UDQContext.hpp: forward WellMatcher
make member a const reference to enable this
2023-01-10 12:25:35 +01:00
Bård Skaflestad
5860553dbd Merge pull request #3327 from akva2/simulatorupdate.hpp_reduce_hotness
Forward SimulatorUpdate in Schedule
2023-01-10 11:17:04 +01:00
Bård Skaflestad
6a490863ef Merge pull request #3323 from akva2/gasliftopt.hpp_reduce_hotness
Schedule.hpp: avoid GasLiftOpt.hpp include
2023-01-10 10:51:39 +01:00
Arne Morten Kvarving
dd48e54b02 Schedule: forward GasLiftOpt 2023-01-10 09:52:50 +01:00
Arne Morten Kvarving
9193868cea changed: rename GasLiftOpt::(Group|Well) to GasLift(Group|Well)
this makes it possible to forward the symbols
2023-01-10 09:51:06 +01:00
Arne Morten Kvarving
67d5c8d86b Schedule.hpp: forward SimulatorUpdate 2023-01-10 09:50:26 +01:00
Arne Morten Kvarving
90ff1c01b2 Schedule: move more code to compile unit 2023-01-10 09:50:26 +01:00
Arne Morten Kvarving
894872d86d SimulatorUpdate.hpp: add missing include 2023-01-10 09:50:26 +01:00
Bård Skaflestad
97d1af732b Merge pull request #3325 from akva2/WellTestConfig.hpp_reduce_hotness
Schedule.hpp: forward WellTestConfig
2023-01-09 16:30:32 +01:00
Bård Skaflestad
eb61a00f94 Merge pull request #3326 from akva2/RPTConfig.hpp_reduce_hotness
Schedule.hpp: forward RPTConfig
2023-01-09 16:07:40 +01:00
Arne Morten Kvarving
aa5c101ca2 Schedule.hpp: forward WellTestConfig 2023-01-09 15:26:09 +01:00
Arne Morten Kvarving
85d1b29a01 Schedule.hpp: forward RPTConfig 2023-01-09 15:23:50 +01:00
Bård Skaflestad
b95da78469 Merge pull request #3324 from akva2/gasliftconfig.hpp_reduce_hotness
Schedule: forward GuideRate(Config|Model)
2023-01-09 15:22:37 +01:00
Arne Morten Kvarving
dcc467cae1 Schedule: forward GuideRate(Config|Model) 2023-01-09 14:36:27 +01:00
Bård Skaflestad
5a8d01a608 Merge pull request #3322 from akva2/python.hpp_reduce_hotness
Schedule: move more code to compile unit
2023-01-09 13:42:19 +01:00
Arne Morten Kvarving
4b86e31cd5 Schedule: move more code to compile unit
we can now forward Opm::Python
2023-01-09 12:48:45 +01:00
Bård Skaflestad
a7531d6b94 Merge pull request #3319 from tskille/update_make_ext_smry
update of make_ext_smry program
2023-01-06 21:10:00 +01:00
Torbjørn Skille
b7b3604a55 update of make_ext_smry program
If opening smspec fails, the program will now print a warning and continue with next summary file.
2023-01-06 18:56:40 +01:00
Bård Skaflestad
e9186a1f1a Merge pull request #3318 from akva2/pinchmode_enum_class
PinchMode: convert to enum class
2023-01-05 16:18:29 +01:00
Arne Morten Kvarving
3808c85edf PinchMode: convert to enum class 2023-01-05 15:28:06 +01:00
Bård Skaflestad
c49f1fc354 Merge pull request #3317 from akva2/minpvmode_enum_class
MinpvMode: convert to enum class
2023-01-05 15:23:22 +01:00
Bård Skaflestad
3e0184f3c0 Merge pull request #3316 from akva2/blackoilfluidsystem_compile_unit
BlackOilFluidSystem: move more code to compile unit
2023-01-05 14:27:15 +01:00
Arne Morten Kvarving
f832c88d76 MinpvMode: convert to enum class 2023-01-05 14:07:30 +01:00
Bård Skaflestad
36d6e4ae67 Merge pull request #3315 from akva2/runspec_improvements
Some Runspec improvements
2023-01-05 14:05:56 +01:00
Arne Morten Kvarving
8f10bb666d BlackOilFluidSystem: move more code to compile unit 2023-01-05 13:34:10 +01:00
Arne Morten Kvarving
118886cb65 replace Runspec.hpp with Phase.hpp where appropriate 2023-01-05 13:10:57 +01:00
Arne Morten Kvarving
8d424407eb remove unnecessary <Runspec.hpp> includes 2023-01-05 12:57:01 +01:00
Arne Morten Kvarving
f8e0319203 added: put Phase and helpers in separate hpp/cpp 2023-01-05 12:57:01 +01:00
Arne Morten Kvarving
e440b6b008 Merge pull request #3314 from akva2/more_cpp_pvt
Move more pvt code to compile units
2023-01-05 10:40:43 +01:00
Arne Morten Kvarving
84b4826909 DeadOilPvt: move some more code to compile unit 2023-01-05 10:06:30 +01:00
Arne Morten Kvarving
1ca88ef280 LiveOilPvt: avoid type alias 2023-01-05 10:06:30 +01:00
Arne Morten Kvarving
2ef18d20ed DryHumidGasPvt: avoid type alias 2023-01-05 10:06:30 +01:00
Arne Morten Kvarving
74845ca5f2 WetHumidGasPvt: move some more code to compile unit 2023-01-05 10:06:30 +01:00
Arne Morten Kvarving
830f6beb40 WetGasPvt: move some more code to compile unit 2023-01-05 10:06:30 +01:00
Arne Morten Kvarving
8e78bec581 SolventPvt: move some more code to compile unit 2023-01-05 10:06:29 +01:00
Arne Morten Kvarving
68336940e6 LiveOilPvt: move some more code to compile unit 2023-01-05 10:06:08 +01:00
Arne Morten Kvarving
cd1e7c0944 DryHumidGasPvt: move some more code to compile unit 2023-01-05 09:24:16 +01:00
Arne Morten Kvarving
cc1e00d35e DryGasPvt: move some more code to compile unit 2023-01-05 09:16:39 +01:00
Arne Morten Kvarving
48c60c0790 Merge pull request #3312 from atgeirr/minor-fixes
Minor fixes
2023-01-04 12:48:39 +01:00
Bård Skaflestad
2ca6b236e4 Merge pull request #3311 from akva2/parameters_streams_cleanup
ParametersXXX: cleanup stream usage
2023-01-04 11:54:38 +01:00
Atgeirr Flø Rasmussen
4bce15a973 Declare instantiations that are in another compile unit.
Silences warning from clang.
2023-01-04 11:24:42 +01:00
Atgeirr Flø Rasmussen
700bd6e174 Use snprintf instead of unsafe and deprecated sprintf. 2023-01-04 11:23:54 +01:00
Bård Skaflestad
08ee1cce33 Merge pull request #3309 from atgeirr/move-material-tests
Move material-related tests to a subdirectory.
2023-01-04 11:23:16 +01:00
Atgeirr Flø Rasmussen
167cfbbfab Silence uninitialized variable warnings.
Also make a more structured approach.
2023-01-04 11:22:59 +01:00
Atgeirr Flø Rasmussen
15b1d7f819 Add missing header include. 2023-01-04 11:22:18 +01:00
Arne Morten Kvarving
26f5c770b5 ParameterRequirement: encapsulate sstream usage 2023-01-04 11:03:33 +01:00
Arne Morten Kvarving
5395e29b5f ParameterGroup_impl: avoid use of sstream 2023-01-04 11:03:33 +01:00
Arne Morten Kvarving
f987a3794c Parameter: move more code to compile unit
in particular this allows encapsulating sstream
2023-01-04 11:03:33 +01:00
Arne Morten Kvarving
e05de9a741 convert files to utf-8 2023-01-04 11:03:33 +01:00
Bård Skaflestad
a6af99d80e Merge pull request #3310 from akva2/use_fmt
EModel: use {fmt}
2023-01-04 09:54:37 +01:00
Atgeirr Flø Rasmussen
58b44d1615 Move material-related tests to a subdirectory.
Note that tests for some of the more general classes from
opm-material (such as Evaluation) have not been moved.
2023-01-04 09:44:40 +01:00
Arne Morten Kvarving
acf4f98bea EModel: use {fmt} to format error messages 2023-01-04 09:21:32 +01:00
Arne Morten Kvarving
beb0e8ec85 remove unnecessary <fstream> includes 2023-01-04 09:21:32 +01:00
Arne Morten Kvarving
4201a24de2 remove unnecessary <sstream> includes 2023-01-04 09:21:32 +01:00
Bård Skaflestad
8241d1b8b4 Merge pull request #3307 from akva2/remove_sstream_in_error_macros
Remove sstream in error macros
2023-01-03 23:29:01 +01:00
Arne Morten Kvarving
a154d8baf4 add compile unit for String.hpp
one less <sstream> in header
2023-01-03 19:06:46 +01:00
Arne Morten Kvarving
fee9925747 remove unnecessary <filesystem> include 2023-01-03 19:06:28 +01:00
Arne Morten Kvarving
d1522761f3 add license header 2023-01-03 19:06:13 +01:00
Arne Morten Kvarving
d135fada0a remove unnecessary <iostream> includes 2023-01-03 16:32:56 +01:00
Arne Morten Kvarving
48b0efefe3 remove unnecessary <fstream> include 2023-01-03 16:32:56 +01:00
Arne Morten Kvarving
b4ee56efed remove unnecessary <sstream> include 2023-01-03 16:32:56 +01:00
Arne Morten Kvarving
c3ba1a35e8 include <ostream> where only ostream is needed 2023-01-03 16:32:56 +01:00
Arne Morten Kvarving
51bebabfcb CompSegs: use {fmt} instead of streams 2023-01-03 16:32:56 +01:00
Arne Morten Kvarving
dbf838ab90 ErrorMacros: remove sstream usage 2023-01-03 16:32:56 +01:00
Paul Egberts
89cd82836b well trajectory calculation (re)using resinsight code 2023-01-03 15:02:25 +01:00
Paul Egberts
4888d8ba9e try out code 2023-01-03 15:02:21 +01:00
Paul Egberts
2da6dba9af reading new tables for grid independent well specification 2023-01-03 15:02:21 +01:00
Arne Morten Kvarving
155ecf6b02 compareECL: use local sstream 2023-01-02 15:54:24 +01:00
Arne Morten Kvarving
e0a8915a7b EclRegressionTest: remove usage of sstream 2023-01-02 15:54:06 +01:00
Arne Morten Kvarving
5caa5bf858 ParameterGroup: remove usage of sstream 2023-01-02 15:53:05 +01:00
Arne Morten Kvarving
1c1140b0c6 SparseVector: remove use of sstream 2023-01-02 15:52:44 +01:00
Arne Morten Kvarving
b3cd20aa69 BrineCo2Pvt: remove use of sstream 2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
cbb3b9da7f DryHumidGasPvt: remove use of sstream 2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
43901d33f0 LiveOilPvt: remove use of sstream 2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
38f58a2beb WetGasPvt: remove use of sstream 2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
b24bf9d339 WetHumidGasPvt: remove use of sstream 2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
c398faad49 H2ON2LiquidPhaseFluidSystem: remove unnecessary <iostream> include 2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
d60f1c9f97 H2ON2FluidSystem: remove unnecessary <iostream> include 2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
da4fe49a3a H2OAirMesityleneFluidSystem: remove unnecessary <iostream> include 2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
5776f97490 H2OAirFluidSystem: remove unnecessary <iostream> include 2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
587ffe4d78 BrineCO2FluidSystem: remove use of sstream 2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
55c5bc68d5 PengRobinson: remove use of sstream 2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
30b408c95f NcpFlash: remove use of sstream 2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
86d233ba96 NcpFlash: remove protected printing method
it is unused and it pulls in iostream.
iostream is still pulled by the dune classes
2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
2769ada1a5 CompositionFromFugacities: remove sstream usage 2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
a885d4de34 ImmiscibleFlash: remove use of sstream 2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
4927a9a58e ImmiscibleFlash: remove protected printing method
it is unused and it pulls in iostream.
iostream is still pulled by the dune classes
2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
83e7e45f2d TabulatedComponent: remove unnecessary <iostream> include 2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
f1ecc0c7cf SimpleHuDuanH2O: avoid use of sstream 2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
f94bdfda44 H2O: avoid use of sstream 2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
c5dd0be166 CO2: remove unnecessary <iostream> include 2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
a03a03af36 Tabulated1DFunction: move stream output to compile unit 2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
cf41f01625 Tabulated1DFunction: avoid using sstream 2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
a631ef7ce9 UniformXTabulated2DFunction: move stream output to compile unit 2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
8aace8e1d5 UniformXTabulated2DFunction: avoid using sstream 2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
7d386d9082 TridiagonalMatrix: move stream output to compile unit 2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
c7d1fb33e7 Spline: move stream output to compile unit 2023-01-02 15:50:41 +01:00
Arne Morten Kvarving
a82ad9e86a IntervalTabulated2DFunction: avoid using sstream 2023-01-02 15:50:41 +01:00
Atgeirr Flø Rasmussen
4ee3f9ed3e Merge pull request #3306 from atgeirr/add-missing-include
Add missing <string> include.
2023-01-02 13:11:39 +01:00
Atgeirr Flø Rasmussen
bb48205767 Add missing <string> include. 2023-01-02 12:12:26 +01:00
Bård Skaflestad
c1bcace20d Merge pull request #3305 from akva2/evaluation_cleanup
Cleanup in evaluations
2022-12-23 15:05:11 +01:00
Arne Morten Kvarving
76892ccd73 EvaluationXXX.hpp: do not include Evaluation.hpp
creates weird circular includes. users should always include
Evaluation.hpp
2022-12-23 13:30:34 +01:00
Arne Morten Kvarving
59d46bbf7e Evaluation: do not include Math.hpp 2022-12-23 13:15:53 +01:00
Arne Morten Kvarving
b487819384 Evaluation: remove unnecessary includes 2022-12-23 13:09:40 +01:00
Arne Morten Kvarving
e9ba866305 Evaluation: do not include valgrind if NDEBUG 2022-12-23 13:02:36 +01:00
Arne Morten Kvarving
9d92514157 Evaluation: move stream operator support to compile unit 2022-12-23 12:58:47 +01:00
Bård Skaflestad
fd2b2ebf52 Merge pull request #3304 from akva2/minimize_dune_dependencies
Minimize dune dependencies
2022-12-23 09:44:59 +01:00
Arne Morten Kvarving
0c596fbb08 test_eclmateriallawmanager: no reason to initialize MPI here
thus we no longer depend on dune-common
2022-12-23 08:49:44 +01:00
Arne Morten Kvarving
00adf562c9 test_eclblackoilpvt: no reason to initialize MPI here
thus we no longer depend on dune-common
2022-12-23 08:49:44 +01:00
Arne Morten Kvarving
d6a15066c5 test_eclblackoilfluidsystem: no reason to initialize MPI here
thus we no longer depend on dune-common
2022-12-23 08:49:44 +01:00
Arne Morten Kvarving
a971ecd4b0 test_threecomponents_ptflash: no reason to initialize MPI here 2022-12-23 08:49:44 +01:00
Arne Morten Kvarving
f790b2bcba test_tabulation: no reason to initialize MPI here
thus we no longer depend on dune-common
2022-12-23 08:49:44 +01:00
Arne Morten Kvarving
45fc048a94 test_spline: no reason to initialize MPI here
thus we no longer depend on dune-common
2022-12-23 08:49:44 +01:00
Arne Morten Kvarving
35b3fd218d test_pengrobinson: no reason to initialize MPI here 2022-12-23 08:49:44 +01:00
Arne Morten Kvarving
b53ea60438 test_ncpflash: no reason to initialize MPI here 2022-12-23 08:49:44 +01:00
Arne Morten Kvarving
6b59969f54 test_co2brine_ptflash: no reason to initialize MPI here 2022-12-23 08:49:44 +01:00
Arne Morten Kvarving
25eb867801 test_immiscibleflash: no reason to initialize MPI here 2022-12-23 08:49:44 +01:00
Arne Morten Kvarving
9c5f863ec1 test_densead: no reason to initialize MPI here
thus we no longer depend on dune-common
2022-12-23 08:49:44 +01:00
Arne Morten Kvarving
7215312bb1 test_fluidsystems: no reason to initialize MPI here
thus we no longer depend on dune-common
2022-12-23 08:49:44 +01:00
Arne Morten Kvarving
9ccee63cac test_fluidmatrixinteractions: no reason to initialize MPI here
thus we no longer depend on dune-common
2022-12-23 08:49:44 +01:00
Arne Morten Kvarving
b782a0360b test_components: no reason to initialize MPI here
thus we no longer depend on dune-common
2022-12-23 08:49:43 +01:00
Arne Morten Kvarving
b81ba96285 test_brineco2pvt: no reason to initialize MPI here
thus we no longer depend on dune-common
2022-12-23 08:49:19 +01:00
Arne Morten Kvarving
6473798cf0 test_blackoilfluidstate: do not include dune mpi helper
thus we no longer depend on dune-common
2022-12-23 08:49:19 +01:00
Arne Morten Kvarving
bffe2b01e8 test_2dtables: no reason to initialize MPI here
and then we no longer depend on dune-common
2022-12-23 08:49:19 +01:00
Arne Morten Kvarving
ea1e8552e7 checkComponent: use Opm::demangle 2022-12-23 08:49:19 +01:00
Arne Morten Kvarving
7b31a45646 BaseFluidSystem: use Opm::demangle 2022-12-23 08:49:19 +01:00
Arne Morten Kvarving
28d160dec3 ThreePhaseParkerVanGenucthenParams: remove fvector include
not used
2022-12-23 08:49:19 +01:00
Arne Morten Kvarving
91b3ecbad0 checkFluidSystem: use Opm::demangle 2022-12-23 08:49:19 +01:00
Arne Morten Kvarving
b125823f92 added: symbol demangling helper
this is trivial enough to carry ourself instead of
relying on dune-common
2022-12-23 08:49:19 +01:00
Arne Morten Kvarving
fd6e793b6a don't include dune traits for Evaluation
unused and it creates an unnecessary dune-common dependency
now test_EvaluationFormat no longer depends on dune-common
2022-12-23 08:49:19 +01:00
Bård Skaflestad
7be5addcf5 Merge pull request #3277 from akva2/waterpvtmultiplexer_encapsulate
WaterPvtMultiplexer: encapsulate EclipseState w/ friends
2022-12-22 19:23:22 +01:00
Arne Morten Kvarving
442f7f599f WaterPvtMultiplexer: put initFromState in separate compile unit
thus encapsulating EclipseState and friends
2022-12-22 18:10:23 +01:00
Arne Morten Kvarving
e867dea639 WaterPvtMultiplexer: remove comparison operator
not used
2022-12-22 18:10:22 +01:00
Bård Skaflestad
92aaa54526 Merge pull request #3285 from akva2/co2_table_encapsulate
CO2: encapsulate CO2Tables
2022-12-22 16:29:09 +01:00
Bård Skaflestad
79cb28f8ca Merge pull request #3276 from akva2/oilpvtmultiplexer_encapsulate
OilPvtMultiplexer: encapsulate EclipseState w/ friends
2022-12-22 16:21:41 +01:00
Arne Morten Kvarving
4e17a57c08 OilPvtMultiplexer: put initFromState in separate compile unit
thus encapsulating EclipseState, Schedule and TableManager
2022-12-22 15:34:14 +01:00
Arne Morten Kvarving
0855259fd7 OilPvtMultiplexer: remove comparison operator
not used
2022-12-22 15:34:14 +01:00
Bård Skaflestad
1bb8e1e70d Merge pull request #3275 from akva2/gaspvtmultiplexer_encapsulate
GasPvtMultiplexer: encapsulate EclipseState w/ friends
2022-12-22 15:33:51 +01:00
Markus Blatt
08ba72213f Merge pull request #3300 from akva2/quadmath_no_cxx_flags
fixed: do not append to flags to CMAKE_CXX_FLAGS
2022-12-22 14:56:16 +01:00
Arne Morten Kvarving
a1126836f5 GasPvtMultiplexer: put initFromState in separate compile unit
thus encapsulating EclipseState and TableManager
2022-12-22 14:47:15 +01:00
Arne Morten Kvarving
b4ed9ae9a0 GasPvtMultiplexer: remove comparison operator
not used
2022-12-22 14:47:15 +01:00
Bård Skaflestad
df17890f7d Merge pull request #3274 from akva2/blackoilfluidsystem_encapsulate
BlackOilFluidSystem: encapsulate EclipseState w/ friends
2022-12-22 14:41:57 +01:00
Bård Skaflestad
4d4415b57f Merge pull request #3272 from akva2/wethumidgaspvt_encapsulate
WetHumidGasPvt: encapsulate EclipseState w/ friends
2022-12-22 13:59:53 +01:00
Arne Morten Kvarving
e392826cd5 BlackOilFluidSystem: replace assert
this is user-provided data. instead throw an exception.
also replace a naked throw with OPM_THROW
2022-12-22 13:36:20 +01:00
Arne Morten Kvarving
77886b1307 BlackOilFluidSystem: put initFromState in separate compile unit
thus encapsulating EclipseState and friends
2022-12-22 13:35:08 +01:00
Arne Morten Kvarving
19a7d04d8d WetHumidGasPvt: some simplifications
drop unused constructors and explicit comparison operator
2022-12-22 13:22:07 +01:00
Arne Morten Kvarving
afc5aa026b WetHumidGasPvt: add missing initialization 2022-12-22 13:22:07 +01:00
Arne Morten Kvarving
262f4d5378 WetHumidGasPvt: replace asserts
this is user-provided data. instead throw exceptions.
also replace a naked throw with OPM_THROW
2022-12-22 13:22:07 +01:00
Arne Morten Kvarving
1ed433cb51 WetHumidGasPvt: put initFromState in separate compile unit
thus encapsulating EclipseState, Schedule and TableManager
2022-12-22 13:22:07 +01:00
Bård Skaflestad
f9228f857c Merge pull request #3271 from akva2/wetgaspvt_encapsulate
WetGasPvt: encapsulate EclipseState w/ friends
2022-12-22 13:21:51 +01:00
Arne Morten Kvarving
dc5d2e76f1 WetGasPvt: some simplifications
drop unused constructors and explicit comparison operator
2022-12-22 12:27:34 +01:00
Arne Morten Kvarving
84336d353e WetGasPvt: replace asserts
this is user-provided data. instead throw exceptions.
also replace a naked throw with OPM_THROW
2022-12-22 12:27:34 +01:00
Arne Morten Kvarving
b75a00c919 WetGasPvt: put initFromState in separate compile unit
thus encapsulating EclipseState, Schedule and TableManager
2022-12-22 12:26:33 +01:00
Bård Skaflestad
e2d18204e7 Merge pull request #3270 from akva2/waterpvtthermal_encapsulate
WaterPvtThermal: encapsulate EclipseState w/ friends
2022-12-22 12:25:29 +01:00
Arne Morten Kvarving
6a4ce88a82 WaterPvtThermal: don't compare isothermal pvts
this operator is not really used and will be removed later.
for now just remove the problematic comparison
2022-12-22 11:46:04 +01:00
Arne Morten Kvarving
8326df9d6c WaterPvtThermal: replace asserts
this is user-provided data. instead throw exceptions.
also replace a naked throw with OPM_THROW
2022-12-22 11:45:48 +01:00
Arne Morten Kvarving
ca3f5ee91c WaterPvtThermal: put initFromState in separate compile unit
thus encapsulating EclipseState and TableManager
2022-12-22 11:41:24 +01:00
Bård Skaflestad
c7a9a1dbfa Merge pull request #3269 from akva2/solventpvt_encapsulate
SolventPvt: encapsulate EclipseState w/ friends
2022-12-22 11:40:40 +01:00
Arne Morten Kvarving
39b0354d54 SolventPvt: some simplifications
drop unused constructors and explicit comparison operator
2022-12-22 11:03:12 +01:00
Arne Morten Kvarving
2c23a4e76a SolventPvt: replace assert
this is user-provided data. instead throw an exception
2022-12-22 11:03:12 +01:00
Arne Morten Kvarving
fa1f7a447f SolventPvt: put initFromState in separate compile unit
thus encapsulating EclipseState and TableManager
2022-12-22 11:03:12 +01:00
Bård Skaflestad
e89f9ddcad Merge pull request #3268 from akva2/oilpvtthermal_encapsulate
OilPvtThermal: encapsulate EclipseState w/ friends
2022-12-22 11:02:03 +01:00
Arne Morten Kvarving
d660b0d080 OilPvtThermal: don't compare isothermal pvts
this operator is not really used and will be removed later.
for now just remove the problematic comparison
2022-12-22 10:26:06 +01:00
Arne Morten Kvarving
cb2e3bfbcd OilPvtThermal: replace asserts
this is user-provided data. instead throw exceptions.
also replace a naked throw with OPM_THROW
2022-12-22 10:25:46 +01:00
Arne Morten Kvarving
744b31587d OilPvtThermal: put initFromState in separate compile unit
thus encapsulating EclipseState and TableManager
2022-12-22 10:20:18 +01:00
Bård Skaflestad
8ab8989cc5 Merge pull request #3266 from akva2/liveoilpvt_encapsulate
LiveOilPvt: encapsulate EclipseState w/ friends
2022-12-22 10:19:10 +01:00
Arne Morten Kvarving
219536d69a LiveOilPvt: some simplifications
drop unused constructors and explicit comparison operator
2022-12-22 09:36:19 +01:00
Arne Morten Kvarving
622abe631c LiveOilPvt: replace assert
this is user-provided data. instead throw an exception
2022-12-22 09:36:19 +01:00
Arne Morten Kvarving
857c5c4bfb LiveOilPvt: put initFromState in separate compile unit
thus encapsulating EclipseState, Schedule and TableManager
2022-12-22 09:36:19 +01:00
Bård Skaflestad
fc6f6e7d1d Merge pull request #3265 from akva2/gaspvtthermal_encapsulate
GasPvtThermal: encapsulate EclipseState w/ friends
2022-12-22 09:34:44 +01:00
Arne Morten Kvarving
01f087b252 don't compare isothermal pvts
this operator is not really used and will be removed later.
for now just remove the problematic comparison
2022-12-22 08:44:32 +01:00
Arne Morten Kvarving
4dbdec2d0b GasPvtThermal: replace assert
this is user-provided data. instead throw an exception
2022-12-22 08:16:34 +01:00
Arne Morten Kvarving
011666367a GasPvtThermal: put initFromState in separate compile unit
thus encapsulating EclipseState and TableManager
2022-12-21 23:50:55 +01:00
Bård Skaflestad
30546dfe1d Merge pull request #3264 from akva2/dryhumidgaspvt_encapsulate
DryHumidGasPvt: encapsulate EclipseState w/ friends
2022-12-21 23:39:53 +01:00
Arne Morten Kvarving
51e44df594 DryHumidGasPvt: some simplifications
drop unused constructors and explicit comparison operator
2022-12-21 22:25:50 +01:00
Arne Morten Kvarving
c84cde4772 DryHumidGasPvt: add missing initialization 2022-12-21 22:25:50 +01:00
Arne Morten Kvarving
43938bf9c3 DryHumidGasPvt: replace assert
this is user-provided data. instead throw an exception
2022-12-21 22:25:50 +01:00
Arne Morten Kvarving
60b61b4647 DryHumidGasPvt: put initFromState in separate compile unit
thus encapsulating EclipseState and TableManager
2022-12-21 22:25:49 +01:00
Bård Skaflestad
5eef4086f0 Merge pull request #3263 from akva2/drygaspvt_encapsulate
DryGasPvt: encapsulate EclipseState w/ friends
2022-12-21 22:01:47 +01:00
Bård Skaflestad
ab9615cf12 Merge pull request #3249 from akva2/small_material_fixes
Some small fixes in material classes
2022-12-21 22:00:35 +01:00
Arne Morten Kvarving
9cf1922d8f DryGasPvt: some simplifications
drop unused constructors and explicit comparison operator
2022-12-21 20:42:55 +01:00
Arne Morten Kvarving
e0c083efe2 DryGasPvt: replace assert
this is user-provided data. instead throw an exception
2022-12-21 20:42:54 +01:00
Arne Morten Kvarving
b0cb3bdb11 DryGasPvt: put initFromState in separate compile unit
thus encapsulating EclipseState and TableManager
2022-12-21 20:42:54 +01:00
Bård Skaflestad
a1d23d42cc Merge pull request #3262 from akva2/deadoilpvt_encapsulate
DeadOilPvt: encapsulate EclipseState w/ friends
2022-12-21 20:37:15 +01:00
Arne Morten Kvarving
f6c3b61502 DeadOilPvt: some simplifications
remove unused constructors and explicit comparison operator
2022-12-21 19:53:31 +01:00
Arne Morten Kvarving
e4814b0ad3 DeadOilPvt: replace assert
this is user-provided data. instead throw an exception
2022-12-21 19:53:31 +01:00
Arne Morten Kvarving
039a7ff35f DeadOilPvt: put initFromState in separate compile unit
thus encapsulating EclipseState and TableManager
2022-12-21 19:53:31 +01:00
Bård Skaflestad
77c79ca6f3 Merge pull request #3261 from akva2/constantcompressibilitywaterpvt_encapsulate
ConstantCompressibilityWaterPvt: encapsulate EclipseState w/ friends
2022-12-21 19:38:24 +01:00
Bård Skaflestad
db7126631f Merge pull request #3303 from akva2/remove_parser_deck_api_warning
remove OPM_PARSER_DECK_API_WARNING
2022-12-21 19:18:27 +01:00
Arne Morten Kvarving
112e377ece remove OPM_PARSER_DECK_API_WARNING 2022-12-21 18:42:17 +01:00
Arne Morten Kvarving
d754d83ea0 ConstantCompressibilityWaterPvt: some simplifications
drop unused constructors and explicit comparison operator
2022-12-21 18:32:14 +01:00
Arne Morten Kvarving
2d386e3e3f ConstantCompressibilityWaterPvt: replace assert
this is user-provided data. instead throw an exception
2022-12-21 18:32:13 +01:00
Arne Morten Kvarving
77f5581e27 ConstantCompressibilityWaterPvt: put initFromState in separate compile unit
thus encapsulating EclipseState, Schedule and TableManager
2022-12-21 18:21:26 +01:00
Bård Skaflestad
ff4fb71cb7 Merge pull request #3258 from akva2/constantcompressibilityoilpvt_encapsulate
ConstantCompressibilityOilPvt: encapsulate EclipseState w/ friends
2022-12-21 17:05:07 +01:00
Arne Morten Kvarving
a26cea5c37 ConstantCompressibilityOilPvt: some simplifications
drop unused constructors and explicit comparison operator
2022-12-21 16:23:11 +01:00
Arne Morten Kvarving
eedeada409 ConstantCompressbilityOilPvt: replace assert
this is user-provided data. instead throw an exception
2022-12-21 16:23:11 +01:00
Arne Morten Kvarving
094a40db41 ConstantCompressibilityOilPvt: put initFromState in separate compile unit
thus encapsulating EclipseState and TableManager
2022-12-21 16:23:11 +01:00
Arne Morten Kvarving
81f0315101 Merge pull request #3257 from akva2/constantcompressibilitybrinepvt_encapsulate
ConstantCompressibilityBrinePvt: encapsulate EclipseState w/ friends
2022-12-21 16:23:01 +01:00
Arne Morten Kvarving
f58d9f12b0 ConstantCompressibilityBrinePvt: some simplifications
drop unused constructors and explicit comparison operator
2022-12-21 15:49:02 +01:00
Arne Morten Kvarving
b91b83f814 ConstantCompressibilityBrinePvt: replace asserts
this is user-provided data. instead throw an exception
also replace a naked throw with OPM_THROW
2022-12-21 15:49:02 +01:00
Arne Morten Kvarving
a09d8496f6 ConstantCompressibilityBrinePvt: put initFromState in separate compile unit
thus encapsulating EclipseState and TableManager
2022-12-21 15:49:01 +01:00
Arne Morten Kvarving
5e03ff6726 Merge pull request #3256 from akva2/co2gaspvt_encapsulate
Co2GasPvt: encapsulate EclipseState w/ friends
2022-12-21 15:48:22 +01:00
Arne Morten Kvarving
12ff60693a Merge pull request #3253 from akva2/eclmateriallawmanager_encapsulate
EclMaterialLawManager: move most code to separate compile unit
2022-12-21 15:13:38 +01:00
Bård Skaflestad
38f5c401a0 Merge pull request #3292 from akva2/brineco2pvt_remove_ctor_comp
BrineCo2Pvt: some cleanups
2022-12-21 14:42:30 +01:00
Arne Morten Kvarving
182f5d3b27 Merge pull request #3302 from akva2/rootfinders_libfmt
RootFinders: avoid stream usage in header
2022-12-21 13:43:30 +01:00
Tor Harald Sandve
ce3b37fe9d Merge pull request #3246 from totto82/addRsw
Add rsw
2022-12-21 13:39:23 +01:00
Arne Morten Kvarving
f235061ee3 RootFinders: avoid stream usage in header
put logging functions in separate compile unit where we use {fmt}
2022-12-21 13:26:56 +01:00
Arne Morten Kvarving
93a32a66f4 Merge pull request #3301 from akva2/avoid_sstream_in_timerlog
TimerLog: avoid sstream in header
2022-12-21 12:06:28 +01:00
Arne Morten Kvarving
ba5add7b86 Merge pull request #3299 from akva2/orderedmap_no_sstream
OrderedMap: avoid sstream usage
2022-12-21 11:44:28 +01:00
Arne Morten Kvarving
b529080fb7 TimerLog: avoid sstream in header 2022-12-21 11:26:33 +01:00
Arne Morten Kvarving
ccfc3d6ac3 fixed: do not append to flags to CMAKE_CXX_FLAGS
this should only be set on the target if using QuadMath.
every time cmake was rerun a build directory new entry was added,
leading to very long compile commands eventually.
2022-12-21 11:03:12 +01:00
Arne Morten Kvarving
fe54e7ccf2 Merge pull request #3298 from akva2/dune_tests_separate_list
changed: put dune-enabled tests in separate list
2022-12-21 10:42:25 +01:00
Arne Morten Kvarving
101bbdfb47 avoid pulling sstream in OrderedMap 2022-12-21 10:34:34 +01:00
Arne Morten Kvarving
a7a8d63961 add missing test to OrderedMapTests
test findSimilarStrings
2022-12-21 10:34:28 +01:00
Arne Morten Kvarving
081715d229 changed: put dune-enabled tests in separate list
more explicit, neater code
2022-12-21 09:54:36 +01:00
Arne Morten Kvarving
680246b1ca Merge pull request #3297 from bska/fix-copy-paste-doc
Fix Copy-Pasted Function Documentation
2022-12-20 17:05:59 +01:00
Bård Skaflestad
1c14b786d0 Fix Copy-Pasted Function Documentation
The enumerated 'segments()' overload takes a well number, not a
well name.

Pointy Hat: [at]bska
2022-12-20 15:58:57 +01:00
Bård Skaflestad
b0ad3a43dc Merge pull request #3295 from bska/additional-dune-common-links
Link New Test to Dune Common
2022-12-20 14:41:34 +01:00
Bård Skaflestad
62022122c9 Merge pull request #3296 from bska/more-verbose-test
Prefer BOOST_CHECK_EQUAL
2022-12-20 14:07:21 +01:00
Bård Skaflestad
beef2ca737 Merge pull request #3293 from blattms/throw-for-missing-compsegs
Abort parser if COMPSEGS is missing for multisegment well.
2022-12-20 13:58:53 +01:00
Markus Blatt
0761d38294 Merge pull request #3235 from bska/segment-matcher-facility
Add Facility For Identifying Specific Well Segments
2022-12-20 13:52:22 +01:00
Bård Skaflestad
6bfa9b6c35 Prefer BOOST_CHECK_EQUAL
That way, we get both strings printed if a test fails.
2022-12-20 13:31:28 +01:00
Bård Skaflestad
fb8cd6f284 Link New Test to Dune Common
Otherwise, we get build failures if the Dune libraries and headers
are outside of the system directories.
2022-12-20 13:14:28 +01:00
Bård Skaflestad
1a1ba1f7a1 Add Facility For Identifying Specific Well Segments
The primary use case is identifying UDQ sets when the model defines
UDQs at the segment level (SU*).  The call site will construct a
SegmentMatcher object backed by a specific ScheduleState, and then
segment-level UDQs will match against this to determine the correct
UDQ set on which to define the quantity.
2022-12-20 12:57:00 +01:00
Markus Blatt
6da02a164d Improve error message for missing COMPSEGS keyword.
Instead of listing a range where the errors are we now list the
location of each corresponding WELSEGS keyword to give the user all
the information that he may need.

Error looks like:

```
unknown location(0): fatal error: in "MissingCOMPSEGS": Opm::OpmInputError: Problem with keyword WELSEGS
In <memory string> line 38
Missing COMPSEGS keyword for the following multisegment well:
    PROD01 in <memory string> at line 38.
```
2022-12-20 12:01:17 +01:00
Bård Skaflestad
c8daba28ad Merge pull request #3294 from akva2/evaluation_fmt
added: fmt formatter for Evaluation
2022-12-20 11:13:07 +01:00
Markus Blatt
f3a4408172 Added test whether parser throws for ms well without COMPSEGS keyword. 2022-12-20 11:11:24 +01:00
Markus Blatt
fd600582f5 Added missig COMPSEGS keywords for multisegment well tests.
No that we are stricter this is needed as otherwise the tests may
fail.

Due to my laziness I descreased the number of connection for the wells.
2022-12-20 10:55:49 +01:00
Arne Morten Kvarving
7f694089a7 added: fmt formatter for Evaluation
and a simple test
2022-12-20 08:45:06 +01:00
Markus Blatt
7d3c688953 Abort parser if COMPSEGS is missing for multisegment well.
This might not be 100% perfect but it will detect completely missing
COMPSEGS keywords for multisegment wells already during file parsing
instead of during the simulation at the report step where the problem
occurs (could be rather late). Hence it improves  OPM/opm-simulators#4329.

We keep track of all the wells that appear in WELSEGS and COMPSEGS and
at the end of each report step parsed, we check that there is entry using
COMPSEGS for each well that was in WELSEGS.

Note that the keyword used for the error is the last one in the report
step, which is a bit misleading. Error message looks like:

```
Error: Problem with keyword WCONPROD
In /tmp/MSW-3D-03.DATA line 2462
Missing COMPSEGS keyword for well PROD01 between <memory string> line 0 and /tmp/MSW-3D-03.DATA line 2462.

Error: Unrecoverable errors while loading input: Problem with keyword WCONPROD
In /tmp/MSW-3D-03.DATA line 2462
Missing COMPSEGS keyword for well PROD01 between <memory string> line 0 and /tmp/MSW-3D-03.DATA line 2462.
```
2022-12-19 22:54:56 +01:00
Tor Harald Sandve
9d583b2293 Add support for dissolved gas in water in the blackoil fluidsystem
If DISGASW is in the input deck gas in allowed to dissolved into water
Currently only works in combination with CO2STORE
For general support assosiated input tables needs to be provided
2022-12-16 13:49:44 +01:00
Arne Morten Kvarving
802bc21246 BrineCo2Pvt: some cleanups
remove unused ctor and explicit comparison operator
2022-12-16 13:38:27 +01:00
David Landa Marban
43c553330b Flows and Flores NNC extra fields 2022-12-15 15:14:24 +01:00
Arne Morten Kvarving
99ebf0bd3d Merge pull request #3286 from akva2/remove_unused_header
remove unused header
2022-12-15 14:23:32 +01:00
Arne Morten Kvarving
a999c06862 remove unused header
it will never be used either as opm requires c++17 now
which means final is always supported
2022-12-15 14:05:44 +01:00
Arne Morten Kvarving
b58c682f62 CO2: encapsulate CO2Tables
this way we don't have to drag 6MB of tables into multiple compile
units. some flexibility is lost (ie the template parameter for the
table), but this is unused in the current code.

comment out some templates that do not instance as they are referring
to non-existent table members.
2022-12-15 13:52:49 +01:00
Arne Morten Kvarving
0aa6fc1edd Co2GasPvt: drop unused constructor and explicit comparison operator 2022-12-15 11:14:33 +01:00
Arne Morten Kvarving
7a44ca3052 Co2GasPvt: replace cerr output with OpmLog::warning 2022-12-15 11:08:42 +01:00
Arne Morten Kvarving
0874e7542e Co2GasPvt: put initFromState in separate compile unit
thus encapsulating EclipseState and TableManager
2022-12-15 11:08:42 +01:00
Bård Skaflestad
9d4b36a891 Merge pull request #3273 from blattms/make-multz--global
Always use MULTZ- as a global array.
2022-12-14 14:40:31 +01:00
Markus Blatt
4f0f64f637 Always use MULTZ- as a global array.
This is needed as it is used when calculating transmissibilities over
pinched out cells. There it needs to behave the same way as MULTZ does.
2022-12-14 10:30:27 +01:00
Bård Skaflestad
86b3c79ff4 Merge pull request #3260 from akva2/remove_math_include
changed: remove include of Math.hpp
2022-12-14 09:30:04 +01:00
Bård Skaflestad
f6546b7fc5 Merge pull request #3259 from akva2/exception_nih_begone
changed: drop exceptions class from material
2022-12-14 09:29:29 +01:00
Arne Morten Kvarving
b889f59145 changed: remove include of Math.hpp
it should be up to instance sites to make every available for
the templates to instance properly, even though we know we are
instancing over Evaluations.
2022-12-13 13:31:18 +01:00
Arne Morten Kvarving
9a77d47c35 changed: drop exceptions class from material
use the opm-common exception classes directly
2022-12-13 12:47:20 +01:00
Arne Morten Kvarving
cbdff5409e EclMaterialLawManager: move (most) code to separate compile unit 2022-12-13 11:38:23 +01:00
Arne Morten Kvarving
3b7c68b3cf WaterPvtThermal: remove watJT() from comparison operator
no such method
2022-12-13 11:15:45 +01:00
Arne Morten Kvarving
1a121a6e71 WaterPvtThermal: fix method name 2022-12-13 11:15:45 +01:00
Arne Morten Kvarving
0b6c7a2d40 OilPvtThermal: fix method name 2022-12-13 11:15:45 +01:00
Arne Morten Kvarving
7eeef002be GasPvtThermal: fix method name 2022-12-13 11:15:45 +01:00
Arne Morten Kvarving
8b64ed89f3 OilPvtMultiplexer: remove \ at end of macro 2022-12-13 11:15:44 +01:00
Arne Morten Kvarving
03ca1fdae4 GasPvtMultiplexer: remove \ at end of macro 2022-12-13 11:14:57 +01:00
Bård Skaflestad
6fcf29fa78 Merge pull request #3255 from akva2/co2brinepvt_encapsulate
Co2BrinePvt: encapsulate EclipseState w/ friends
2022-12-13 11:09:15 +01:00
Arne Morten Kvarving
414a07b1a7 BrineCo2Pvt: replace cerr output with OpmLog::warning 2022-12-13 10:23:51 +01:00
Arne Morten Kvarving
7b844eb8be BrineCo2Pvt: put initFromState in separate compile unit
thus encapsulating EclipseState and TableManager
2022-12-13 10:23:43 +01:00
Bård Skaflestad
9dfedcbd76 Merge pull request #3252 from akva2/enum_reduce_redundancy
Reduce redundancy in some enums
2022-12-12 23:35:03 +01:00
Bård Skaflestad
02cdb98cfc Merge pull request #3251 from akva2/unused_includes
Remove unused includes
2022-12-12 23:29:00 +01:00
Bård Skaflestad
bf1cafb63f Merge pull request #3250 from akva2/janitoring
initialize variable to avoid compiler warnings
2022-12-12 23:28:21 +01:00
Arne Morten Kvarving
119cba9edf GasPvtApproach: reduce redundancy in entries
we already know it's 'pvt'
2022-12-12 19:17:33 +01:00
Arne Morten Kvarving
59cd613747 OilPvtApproach: reduce redundancy in entries
we already know it's 'pvt'
2022-12-12 19:09:13 +01:00
Arne Morten Kvarving
2849651b23 WaterPvtApproach: reduce redundancy in entries
we already know it's 'pvt'
2022-12-12 18:54:24 +01:00
Arne Morten Kvarving
a5d038204e SatCurveMultiplexerApproach: reduce redundancy in entries
we already know it's 'approach'
2022-12-12 18:43:28 +01:00
Arne Morten Kvarving
603ca3476a EclTwoPhaseApproach: reduce redundancy in entries
we already know it's 'ecl and twophase'
2022-12-12 18:30:27 +01:00
Arne Morten Kvarving
ad69ef3ac4 EclMultiplexerApproach: reduce redundancy in entries
we already know it's 'ecl and approach'
2022-12-12 18:30:27 +01:00
Arne Morten Kvarving
afbab4d574 EclHysteresisTwoPhaseLawParams: remove unused include 2022-12-12 17:44:32 +01:00
Arne Morten Kvarving
63fe150194 EclEpsTwoPhaseLawParams: remove unused include 2022-12-12 17:44:32 +01:00
Arne Morten Kvarving
faa384abb6 initialize variable to avoid compiler warnings 2022-12-12 17:36:54 +01:00
Bård Skaflestad
138b97fb6e Merge pull request #3247 from akva2/fix_pypi
pypi: add dune-common dependency
2022-12-12 15:39:40 +01:00
Arne Morten Kvarving
2c8e50fa53 pypi: add dune-common dependency 2022-12-12 13:39:18 +01:00
Bård Skaflestad
00cc1f7f08 Merge pull request #3244 from akva2/epsscalingpoints_encapsulate
EclEpsScalingPoints(Info): put init and print in separate compile unit
2022-12-12 09:45:41 +01:00
Bård Skaflestad
28f3d4cd67 Merge pull request #3245 from akva2/eclhysteresisconfig_encapsulate
changed: put EclHysteresisConfig initFromState in separate compile unit
2022-12-12 09:45:04 +01:00
Arne Morten Kvarving
97d4175aa6 changed: put EclHysteresisConfig initFromState in separate compile unit
in particular this allows to encapsulate the Runspec class usage.
also use class member initialization instead of constructor.
2022-12-10 16:20:29 +01:00
Arne Morten Kvarving
6e1aab5164 EclEpsScalingPoints(Info): put init and print in separate compile unit
this allows to encapsulate EclipseState usage and iostream usage
2022-12-10 00:15:27 +01:00
Bård Skaflestad
1670c80133 Merge pull request #3243 from akva2/epsgridprops_encapsulate
changed: put EclEpsGridProperties constructor in separate compile unit
2022-12-09 23:14:23 +01:00
Arne Morten Kvarving
0986c4a8b0 changed: put EclEpsGridProperties constructor in separate compile unit
in particular this allows to encapsulate the EclipseState class usage.
2022-12-09 22:15:41 +01:00
Bård Skaflestad
cf13cddba9 Merge pull request #3242 from akva2/eclepsconfig_encapsulate
EclEpsConfig: put initFromState in separate compile unit
2022-12-09 16:32:34 +01:00
Arne Morten Kvarving
e1f6a1e636 make EclTwoPhaseSyStemType an enum class
in particular this allows for forwarding which will be useful later
2022-12-09 15:48:14 +01:00
Arne Morten Kvarving
cccc007842 changed: put EclEpsConfig init in separate compile unit
in particular this allows to encapsulate the EclipseState class usage.
also use class member initialization instead of constructor.
2022-12-09 15:48:14 +01:00
Bård Skaflestad
a71877277d Merge pull request #3241 from bska/additional-dune-common-links
Link Additional Targets to Dune Common
2022-12-09 15:25:14 +01:00
Bård Skaflestad
3baeba93c8 Link Additional Targets to Dune Common
While here, also remove a duplicate entry for

    examples/co2brinepvt.cpp
2022-12-09 15:03:21 +01:00
Arne Morten Kvarving
4eadaae69c Merge pull request #3240 from akva2/janitoring
Some janitoring
2022-12-09 14:50:38 +01:00
Arne Morten Kvarving
13dcaf8281 fixed: use std::array to avoid compiler warnings 2022-12-09 14:18:55 +01:00
Arne Morten Kvarving
c96a5a8668 fixed: zero initialize to avoid compiler warnings 2022-12-09 14:18:50 +01:00
Bård Skaflestad
d0f8a73083 Merge pull request #3234 from akva2/import_opm_material
Import opm-material with history
2022-12-09 12:26:16 +01:00
Arne Morten Kvarving
207d280ee4 remove HAVE_OPM_COMMON conditionals 2022-12-08 14:03:15 +01:00
Arne Morten Kvarving
5ed8a439e7 add imported files to build system
and adjust jenkins scripts
2022-12-08 14:03:15 +01:00
Markus Blatt
146c73eae9 Merge pull request #3077 from OPMUSER/MULTFLT
Improve Error Message for MULTFLT
2022-12-08 13:46:18 +01:00
Markus Blatt
c048262f79 Merge pull request #3217 from totto82/co2store_gw
Support CO2STORE with GAS + WATER
2022-12-08 11:17:13 +01:00
Markus Blatt
0291da1cb0 Merge pull request #3238 from akva2/fix_python_clean_tree
fixed: depend on the copy_python target
2022-12-05 10:22:07 +01:00
Tor Harald Sandve
a56496021d add keyword DISGASW to enable dissolution of gas in water 2022-12-02 15:43:22 +01:00
Arne Morten Kvarving
1491d9510e fixed: depend on the copy_python target
the generated python code requires the copy_python target
to setup the directory structure. without this, builds
failed when building a specific target (ie not 'all')
in a clean build tree
2022-12-02 12:57:46 +01:00
Arne Morten Kvarving
8245d17026 Merge pull request #3236 from akva2/flag_error_single_rft
changed: flag an error if just one case has a rft file
2022-12-02 11:05:23 +01:00
Arne Morten Kvarving
3feac9cb62 Merge pull request #3237 from akva2/janitoring
fixed: zero initialize to avoid compiler warnings
2022-12-02 10:12:41 +01:00
Arne Morten Kvarving
913f71557d fixed: zero initialize to avoid compiler warnings 2022-12-02 09:34:54 +01:00
Arne Morten Kvarving
97c03fffe6 changed: flag an error if just one case has a rft file 2022-12-02 09:07:43 +01:00
Arne Morten Kvarving
3710b8df69 Import (filtered) opm-material with history 2022-12-01 12:41:31 +01:00
Bård Skaflestad
b528fd768f Merge pull request #3231 from akva2/fix_no_input_output
Fix build with ENABLE_ECL_INPUT=0
2022-11-30 15:32:02 +01:00
Bård Skaflestad
e1a9466cac Merge pull request #545 from akva2/fix_build_no_ecl_input
fix build without ENABLE_ECL_INPUT
2022-11-30 14:58:08 +01:00
Arne Morten Kvarving
f4627455e5 Merge pull request #3233 from bska/apply-gridunit-to-output-copies
Apply GRIDUNIT Processing to COORD/ZCORN Output Copies
2022-11-30 14:35:14 +01:00
Bård Skaflestad
5faf7fc088 Apply GRIDUNIT Processing to COORD/ZCORN Output Copies
Needed to reflect the GRIDUNIT transformation in the EGRID output.
2022-11-30 14:09:20 +01:00
Arne Morten Kvarving
8478171d76 fix build without ENABLE_ECL_INPUT 2022-11-30 12:48:32 +01:00
Arne Morten Kvarving
4978329b02 disable mocksim tests without HAVE_ECL_INPUT 2022-11-30 12:44:52 +01:00
Arne Morten Kvarving
11fb11d089 fixed: we need fmt even without ENABLE_ECL_INPUT
used in test_OpmInputError_format
2022-11-30 12:44:17 +01:00
Arne Morten Kvarving
0fc73cad04 ActiveGridCells: disable without ENABLE_ECL_INPUT
depends on eclipse data structures
2022-11-30 12:42:25 +01:00
Tor Harald Sandve
5e054cdec9 allow for co2store + gas + water 2022-11-30 11:28:06 +01:00
Bård Skaflestad
52a694f75a Merge pull request #3227 from tskille/fix_egrid
Use input COORD and ZCORN if these are available when writing EGRID f…
2022-11-30 11:28:04 +01:00
Bård Skaflestad
e2ccf95972 Merge pull request #3230 from akva2/remove_unused_class
Remove unused class
2022-11-30 11:21:25 +01:00
Arne Morten Kvarving
41d91c4701 remove unused class 2022-11-30 10:55:21 +01:00
Torbjørn Skille
e470a426a3 Use input COORD and ZCORN if these are available when writing EGRID file. 2022-11-30 08:08:25 +01:00
Arne Morten Kvarving
a154a2a49f Merge pull request #3228 from akva2/remove_rh
remove in-tree redhat packaging
2022-11-29 15:05:43 +01:00
Arne Morten Kvarving
827ac8e02f remove in-tree redhat packaging
now hosted in separate repository
2022-11-29 14:00:38 +01:00
Bård Skaflestad
028ea4c281 Merge pull request #3184 from bska/write-rft-seg-dyndata
Finish Outputting Per Segment Dynamic State to RFT File
2022-11-28 14:26:16 +01:00
Bård Skaflestad
b07b9c714f Extract Common Setup Code to Helper Function
Suggested by [at]blattms
2022-11-28 13:38:56 +01:00
Bård Skaflestad
5749ef1bdc Add Unit Tests for Remaining WRFTPLT SEG Features
In particular, add unit tests for phase velocity, holdup fractions,
and phase viscosities.
2022-11-25 17:46:49 +01:00
Bård Skaflestad
802a401a87 Finish Outputting Per Segment Dynamic State to RFT File
This commit adds support for outputting the flow velocity, the
holdup fraction, and the phase viscosity to the RFT file arrays

  * SEGxVEL
  * SEGxHF
  * SEGxVIS

Values provided directly by simulator so we only need to convert to
output units.
2022-11-25 17:46:49 +01:00
Bård Skaflestad
700d18eb4a Merge pull request #3215 from bska/segment-summary-free-flow-rate
Recognize Additional Per-Segment Summary Vector Keywords
2022-11-25 17:22:25 +01:00
Bård Skaflestad
2b720bef17 Add Unit Tests for New Summary Vectors. 2022-11-25 13:02:27 +01:00
Bård Skaflestad
dbd2acee71 Recognize Additional Per-Segment Summary Vector Keywords
In particular, add parser and summary output support for the free
vs. solution flow rates of gas and oil as well as the dissolved
gas/oil ratio, the vaporised oil/gas ratio, and the water/gas ratio.
2022-11-25 13:02:27 +01:00
Arne Morten Kvarving
9d983cb2f3 Merge pull request #3226 from goncalvesmachadoc/patch-7
Repeated includes
2022-11-25 10:33:37 +01:00
Cíntia Gonçalves Machado
1bd79a9999 Repeated includes 2022-11-25 09:51:25 +01:00
Bård Skaflestad
6c21cbe3e0 Merge pull request #2981 from goncalvesmachadoc/saltdensity
Add solid salt density as input
2022-11-24 16:28:56 +01:00
Bård Skaflestad
de24bb9300 Merge pull request #3225 from akva2/internalize_thpresft
Internalize THPRESFT keyword
2022-11-24 11:53:02 +01:00
Arne Morten Kvarving
8ea4d68e7a ThresholdPressure: internalize THPRESFT keyword 2022-11-24 10:47:10 +01:00
Arne Morten Kvarving
e23feb31f1 RockConfig: add missing include 2022-11-23 12:23:26 +01:00
Arne Morten Kvarving
be90d11b3b BCConfig: add missing include 2022-11-23 12:23:10 +01:00
Markus Blatt
0624a04613 Merge pull request #3220 from bska/reduce-astnode-eval-nesting
Reduce Level of Nesting in UDQASTNode::eval
2022-11-22 22:35:03 +01:00
Bård Skaflestad
8e90acf070 Reduce Level of Nesting in UDQASTNode::eval
In particular, introduce a number of helper functions for evaluating
expressions, well variables, group variables, unary and binary
function expressions, and direct number values.  This also, I
believe, fixes a latent error in one group variable case which
appears not to apply the 'sign' correctly.

While here, also wrap some long lines throughout this component.
This is in preparation of adding support for UDQs at the segment
level.
2022-11-22 16:10:28 +01:00
Markus Blatt
845b00c27a Merge pull request #3218 from totto82/wtemp_all_wells
store temperature for all wells not just injectors
2022-11-22 12:26:17 +01:00
Markus Blatt
5590b3c400 Merge pull request #3173 from bska/write-rft-seg-data
Enable SEG Type RFT File Output
2022-11-22 12:23:32 +01:00
Bård Skaflestad
720a5e0334 Add Unit Tests for Current WRFTPLT SEG Features 2022-11-17 11:36:44 +01:00
Bård Skaflestad
2bacfbb558 Enable SEG Type RFT File Output
We're missing the following quantities

  - Flow velocities (SEGxVEL)
  - Holdup fractions (SEGxHF)
  - Phase viscosity (SEGxVIS)

These require additional dynamic values from the simulator and
will be introduced in upcoming work.
2022-11-17 11:36:44 +01:00
Bård Skaflestad
a592c05766 Expose 'OrderSegments' Sorting Predicate
In preparation of defining branches for SEG-type RFT file output.
2022-11-17 10:34:05 +01:00
Bård Skaflestad
8d24dd9d1e Extract Common Base Class for Phase Quantities
Reimplement 'PLTFlowRate' in terms of base class 'PLTPhaseQuantity'.
This is in preparation of adding other phase quantities, such as
velocity and viscosity, which are needed in SEG output.
2022-11-17 10:34:05 +01:00
Bård Skaflestad
56a53d4bde Add Empty Predicate to WellSegments Collection
Will be useful when deciding whether or not to collect segment
information in the RFT file.
2022-11-17 10:34:05 +01:00
Bård Skaflestad
c7dc6de3b3 Merge pull request #3151 from bska/write-plt-data
Add Basic PLT Information to RFT Output File
2022-11-17 10:27:14 +01:00
Bård Skaflestad
9bb733b69b Add Basic PLT Information to RFT Output File
We support both standard and multisegmented wells, but do not output
every known PLT array.  Notably missing are

  - WELLPLT
  - Brine flow rate (CONSRAT)
  - Phase flow rates through tubing (CONxTUB)

Computing CONNXT for multisegmented wells is somewhat involved, and
requires sorting the connections according to branch number,
segments, and tubing lengths.  We use an ancillary structure, an
array of indices into a WellConnections object, along with a custom
predicate to perform this sorting.

As an implementation detail, we handle PLT data for multisegmented
wells as an extension of the PLT data for regular/standard wells.
This extension is realised through dynamic polymorphism.

Add unit tests to cover PLT data for both well types.
2022-11-17 09:37:54 +01:00
Bård Skaflestad
078b7b2e28 Pull Basic Connection Information Out To Helper
This commit introduces a new helper class, WellConnectionRecord,
which holds the connection IJK and host grid information.  Said
information must be output if the run requests either RFT, PLT, or
both RFT and PLT data and so should not be tied to the RFT writer.

This is in preparation of adding PLT output.
2022-11-17 09:37:54 +01:00
Bård Skaflestad
040e4fd5ef Make 'Setup' Structure Generally Available
In preparation of adding unit tests for PLT data.  While here,
also ensure that we explicitly reference pertinent objects from the
Opm namespace.
2022-11-17 09:37:54 +01:00
Bård Skaflestad
2a1c027296 Split Connection Loop Logic Out to Helper Function
In preparation of adding PLT information.
2022-11-17 09:37:54 +01:00
Bård Skaflestad
4b95d56260 RFT: Pull Connection Depth From Connection Object
We don't need the grid to retrieve this information.
2022-11-17 09:37:54 +01:00
Bård Skaflestad
f08f984db1 Merge pull request #3222 from GitPaean/removing_special_wpolymer
removing SPECIAL from WPOLYMER definition
2022-11-17 00:22:04 +01:00
Markus Blatt
7d6f2084b6 Merge pull request #3219 from akva2/enable_alugrid
enable dune-alugrid on jenkins
2022-11-16 21:35:04 +01:00
Kai Bao
a61eb2732a removing SPECIAL from WPOLYMER definition 2022-11-16 11:51:13 +01:00
Arne Morten Kvarving
3e9ae249c6 enable dune-alugrid 2022-11-14 12:32:50 +01:00
Markus Blatt
dd2999d0af Merge pull request #3212 from totto82/bc_dirichlet_default
use initial pressure and temperature as default in bc dirichlet
2022-11-11 22:22:44 +01:00
Tor Harald Sandve
0a778c6e19 throw if temperature() is called for non-injectors 2022-11-11 15:26:04 +01:00
Tor Harald Sandve
4bdf1091e8 store temperature for all wells not just injectors 2022-11-11 13:15:37 +01:00
Atgeirr Flø Rasmussen
2b437cbd11 Merge pull request #3205 from blattms/skip-compile-checks
Make sure compilation is not tested when searching for DUNE/OPM module
2022-11-07 14:53:26 +01:00
Atgeirr Flø Rasmussen
b20234e59c Merge pull request #3203 from blattms/fix-simple-find-package-calls
[bufix,cmake] Fixes simple find_package(opm-module) calls
2022-11-07 14:48:39 +01:00
Bård Skaflestad
5dc4f7301f Merge pull request #3202 from tskille/fix_esmry_rename
Cleanup when ESMRY renamle fails
2022-11-05 14:17:15 +01:00
Bård Skaflestad
5aca4f9026 Merge pull request #3201 from tskille/convertECL_grdecl
Update convertECL to support conversion to grdecl files
2022-11-05 14:12:51 +01:00
Torbjørn Skille
9bbdcfd7ee Update convertECL to support conversion to grdecl files
option -g will output a grdecl file. Input file should be formatted or unformatted ECL files. The option -o can be used to specify output file name. Option -o only valid together with -g option.
2022-11-05 09:59:10 +01:00
Torbjørn Skille
8f4c0b4e92 Cleanup when ESMRY renamle fails
Temporary ESMRY file name is now includeing simulation root name
Delete temp esmry file when the rename temp ESMRY file to simulation ESMRY file.
2022-11-04 18:46:30 +01:00
Tor Harald Sandve
17d0ccee83 use initial pressure and temperature as default in bc dirichlet 2022-11-04 12:10:06 +01:00
Markus Blatt
75b78bf659 Merge pull request #3185 from totto82/bc_dirichlet
extend BCType with dirichlet
2022-11-02 19:48:09 +01:00
Markus Blatt
87a4017e06 Make sure compilation is not tested.
This is broken for DUNE >= 2.8 and dune module that use  OPM.
2022-11-01 22:10:16 +01:00
Bård Skaflestad
d1a2063520 Merge pull request #3187 from plgbrts/rwgsalt
RWGSALT table implementation based on PvtxTable
2022-11-01 17:16:04 +01:00
Bård Skaflestad
5549df53ea Merge pull request #3204 from GitPaean/unit_wsegvale
using SIDouble when creating Valve from a record
2022-11-01 15:23:38 +01:00
Kai Bao
606d6fd73a using SIDouble when creating Valve from a record
to account for the unit conversion.
2022-11-01 14:59:18 +01:00
Markus Blatt
3abeae485a [bufix,cmake] Fixes simple find_package(opm-module) calls
When not using the OPM CMake build system magic a
find_package(opm-module) did fail in some settings as the
CMAKE_MODULE_PATH did not include the location of OpmPackge.cmake and
the likes.

This fixes this by issuing a find_package(opm-common) for modules that
are not opm-common.
2022-11-01 13:22:56 +01:00
Atgeirr Flø Rasmussen
51366c27db Merge pull request #3198 from blattms/debian-fixes
Spelling fixes and manpage updates from Debian packages
2022-10-31 16:37:37 +01:00
Atgeirr Flø Rasmussen
fae8360d5d Merge pull request #3199 from atgeirr/fix-find-metis
Fix metis-related warnings
2022-10-31 13:28:18 +01:00
Atgeirr Flø Rasmussen
5b90e56e75 The commented-out part seems to be necessary, uncommenting. 2022-10-31 10:47:41 +01:00
Markus Blatt
49f06f0cb7 Fixed spelling eror in compareECL 2022-10-29 00:10:40 +02:00
Markus Blatt
043050a793 Fix typos: spesific -> specific 2022-10-29 00:09:12 +02:00
Markus Blatt
b76c62a2f1 Updated manpages 2022-10-29 00:09:12 +02:00
Markus Blatt
ed757caa8b Merge pull request #3179 from bska/segment-dyn-data
Support Additional Dynamic Phase Quantities Per Segment
2022-10-28 14:40:27 +02:00
Bård Skaflestad
4d9ce5b10c Support Additional Dynamic Phase Quantities Per Segment
In particular, provide a container for holding/communicating the
per-phase, per-segment quantities at local flow conditions

    - Flow velocities
    - Holdup fractions
    - Viscosities
2022-10-28 09:30:16 +02:00
Markus Blatt
492ba7c9dd Merge pull request #3195 from bska/support-max-wlist-zero
Ensure At Least One Well List per Well
2022-10-27 22:45:18 +02:00
Bård Skaflestad
d6a3405549 Ensure At Least One Well List per Well
If the input model sets the maximum number of well lists per well
to zero (or negative), then treat this as if the limit is defaulted
and reset the value to the default (one).
2022-10-27 16:15:24 +02:00
Bård Skaflestad
f6865c08dc Merge pull request #3196 from GitPaean/not_throw_no_connection_aquifer
not throwing for numerical aquifers do not have connections
2022-10-27 16:07:30 +02:00
Kai Bao
85c87fa29a not throwing for numerical aquifers do not have connections 2022-10-27 13:23:07 +02:00
Atgeirr Flø Rasmussen
1bd898824c Merge pull request #3192 from OPMUSER/GASVISCT
Update GASVISCT
2022-10-27 11:38:09 +02:00
Bård Skaflestad
484746f28f Merge pull request #3193 from totto82/mod_bc
change order of direction and type in BC and support default ijk
2022-10-27 09:11:23 +02:00
Tor Harald Sandve
e90ee06e74 change order of directiona and type and support default ijk 2022-10-27 08:30:26 +02:00
OPMUSER
6a9c0884ec Update GASVISCT
Fix GASVISCT JSON definition, based on OILVISCT and WATVISCT
2022-10-26 19:29:30 +08:00
Bård Skaflestad
2bbbef5190 Merge pull request #3191 from akva2/janitoring
Some janitoring
2022-10-26 11:19:29 +02:00
Arne Morten Kvarving
9e92f9750c remove unused captures 2022-10-26 10:52:36 +02:00
Arne Morten Kvarving
6353509ecf remove unused variable 2022-10-26 10:52:31 +02:00
Markus Blatt
120ef99510 Merge pull request #3188 from vkip/fix-time-vector-py
Fix time stamp output from time_vector.py so it is Ecl compatible
2022-10-24 11:45:20 +02:00
Vegard Kippe
2cd0d26dd8 Removing comment. 2022-10-21 10:02:59 +02:00
Vegard Kippe
f30baa45af Fixing time stamp output in time_vector.py so it is compatible with Eclipse 2022-10-21 10:01:32 +02:00
goncalvesmachadoc
d4ac067a94 fixKeyword 2022-10-20 17:23:51 +02:00
goncalvesmachadoc
eac870aae4 add description 2022-10-20 17:23:50 +02:00
goncalvesmachadoc
b2c3c24fe8 add salt density as input 2022-10-20 17:23:50 +02:00
Paul Egberts
6f671236a4 fix test for RWGSALT table 2022-10-20 15:56:49 +02:00
Paul Egberts
58da92b420 added water evaporation as function of pressure and salt concentration 2022-10-20 11:16:37 +02:00
Paul Egberts
d1de06b1e6 RWGSALT table implementation based on PvtxTable 2022-10-20 11:09:46 +02:00
Atgeirr Flø Rasmussen
cc49bd15fa Merge pull request #3186 from atgeirr/fix-damaris-cmake
Use MPI_FOUND not MPI_Found.
2022-10-19 14:29:02 +02:00
Atgeirr Flø Rasmussen
1647bba68c Use MPI_FOUND not MPI_Found. 2022-10-19 13:57:25 +02:00
Tor Harald Sandve
e9c93975cf extend BCType with dirichlet 2022-10-19 09:17:54 +02:00
Arne Morten Kvarving
ade3248265 Merge pull request #3183 from atgeirr/bump-version
Bump version for master branch.
2022-10-19 09:14:17 +02:00
Atgeirr Flø Rasmussen
dcd3d1ca5e Bump version for master branch. 2022-10-18 17:30:42 +02:00
Atgeirr Flø Rasmussen
cc81743dad Merge pull request #3181 from akva2/damaris_fixes
Damaris depends on MPI
2022-10-18 15:22:30 +02:00
Bård Skaflestad
a4995686f3 Merge pull request #3180 from akva2/from_intersection
added: FaceDir::FromIntersectionIndex
2022-10-18 13:30:29 +02:00
Arne Morten Kvarving
bd3aa76268 fixed: damaris depends on MPI 2022-10-18 13:08:34 +02:00
Arne Morten Kvarving
6c740656bb changed: do not output damaris info if damaris is not requested 2022-10-18 13:08:33 +02:00
Arne Morten Kvarving
69839e8766 added: FaceDir::FromIntersectionIndex
this translates from a dune intersection id to a FaceDir::DirEnum
2022-10-17 14:44:13 +02:00
Markus Blatt
f414cdd30e Merge pull request #3178 from bska/velocity-unit
Add Unit for Pipeflow Velocity
2022-10-17 12:11:16 +02:00
Markus Blatt
3f8f4d0362 Merge pull request #3177 from blattms/fix-mult-find-dune-fem
Fixes bug that hit only for multiple find calls.
2022-10-17 11:44:23 +02:00
Bård Skaflestad
cba282bd34 Add Unit for Pipeflow Velocity
Needed for summary and RFT file output of fluid flow velocity in
well segments.
2022-10-14 15:24:21 +02:00
Markus Blatt
2a2a9748a3 Prevent Zoltan vars from growing with multiple find_package. 2022-10-12 22:57:43 +02:00
Markus Blatt
20e3202067 Make sure HAVE_${MODULE} is always defined in all scopes.
1. Was a normal variable if no test program was compiled before.
  that meant HAVE_DUNE_FEM was not defined even if dune-fem was found.
2. The if-statement checking whether there is something to compile was
   wrong as this is macro and hence prog is not a variable. Resorted
   to comparison to empty string.
2022-10-12 22:56:00 +02:00
Atgeirr Flø Rasmussen
6c8120abe6 Merge pull request #3176 from akva2/damaris_cmake_script
add cmake script for damaris handling
2022-10-12 14:39:36 +02:00
Markus Blatt
499663f048 Merge pull request #3175 from blattms/fix-mssing-targets-for-multiple-cmake-runs
[cmake] Search for modules/packages each time a search is triggered.
2022-10-12 13:45:16 +02:00
Arne Morten Kvarving
64964c3afe add cmake script for damaris handling 2022-10-12 11:16:43 +02:00
Tor Harald Sandve
ef7d1a5441 Merge pull request #535 from osae/hysterKillough
Killough's hysteresis model for relperm and cap-pressure.
2022-10-12 07:52:24 +02:00
Tor Harald Sandve
6c735230ba Merge pull request #3170 from osae/hysterKillough
Support for capillary pressure hysteresis.
2022-10-12 07:52:10 +02:00
Markus Blatt
3f8195a839 Merge pull request #3171 from bska/support-lowercase-compdat-direction
Support Lower Case COMPDAT Direction Strings
2022-10-11 21:23:05 +02:00
Markus Blatt
2b87eecd68 Search for modules/packages each time a search is triggered.
This is essential if find package modules define imported
targets (usual for modern Cmake). Without this rerunning Cmake another
time in a non-clean build directory will abort with errors if imported
targets are used. E.g. with
```

CMake Error at /home/mblatt/src/dune/opm-2.9/opm-common/cmake/Modules/OpmSatellites.cmake:320 (add_executable):
  Target "test_mpiutil" links to target "ParMETIS::ParMETIS" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?
Call Stack (most recent call first):
  CMakeLists.txt:308 (opm_add_test)

CMake Error at /home/mblatt/src/dune/opm-2.9/opm-common/cmake/Modules/OpmSatellites.cmake:320 (add_executable):
  Target "test_mpiutil" links to target "QuadMath::QuadMath" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?
Call Stack (most recent call first):
  CMakeLists.txt:308 (opm_add_test)
```

This will result in multiple searches, but this should be rather fast
due their previous results being cached.
2022-10-11 20:50:46 +02:00
Markus Blatt
991ea3cf0d Allow find_package calls for METIS/Quadmath if targets already exists 2022-10-11 20:46:38 +02:00
Ove Sævareid
dae73fa909 Activate cap pressure hysteresis. 2022-10-10 18:16:59 +02:00
Ove Sævareid
bade82f44c Neutral initialisation for no-hysteresis case. 2022-10-10 14:34:36 +02:00
Ove Sævareid
c1d916f66e Neutral initialisation of flags. 2022-10-10 14:17:14 +02:00
Bård Skaflestad
67dbe5c9e7 Support Lower Case COMPDAT Direction Strings
Some models will use lower-case strings to input the direction of
penetration, e.g., 'x' or 'z'.  This commit extends our direction
parser to support such strings.
2022-10-09 18:30:46 +02:00
Ove Sævareid
6268aa6604 Killough's hysteresis model for relperm and cap-pressure. 2022-10-07 15:08:16 +02:00
Markus Blatt
9f02b613e8 Merge pull request #3114 from bska/rst-read-vfpexp
Restore Explicit THP Control Options from Restart File
2022-10-07 09:19:01 +02:00
Ove Sævareid
121a062abe Support for capillary pressure hysteresis. 2022-10-05 14:13:36 +02:00
Bård Skaflestad
00eda12fa0 Restore Explicit THP Control Options from Restart File
In particular, this commit restores all WVFPEXP-related items from
the restart file's IWEL array.
2022-10-05 09:55:03 +02:00
Markus Blatt
0e341ef6e1 Merge pull request #3163 from bska/segment-node-xy
Add XY Coordinates to Segment's Node
2022-10-05 09:52:39 +02:00
Arne Morten Kvarving
8601805d62 Merge pull request #3165 from akva2/add_headers
added: add headers to library definition
2022-10-05 09:52:24 +02:00
Markus Blatt
d410f38e11 Merge pull request #3169 from akva2/fix_python_install_path
fixed: properly export opm-common_PYTHON_COMMON_DIR
2022-10-05 09:44:52 +02:00
Arne Morten Kvarving
57bc9a8f02 added: add headers to library definition
for better IDE integration
2022-10-05 09:18:31 +02:00
Arne Morten Kvarving
ca0246c548 fixed: properly export opm-common_PYTHON_COMMON_DIR
this needs to be different for the in-tree and installed
config files
2022-10-05 08:49:22 +02:00
Bård Skaflestad
4326b8c78e Add XY Coordinates to Segment's Node
These are not used in the simulation, but needed/useful for the SEG
option of the WRFTPLT keyword.
2022-10-04 17:42:38 +02:00
Bård Skaflestad
77676000f7 Merge pull request #3166 from akva2/rename_serialize_object
changed: rename serializeObject to serializationTestObject
2022-10-04 17:04:00 +02:00
Arne Morten Kvarving
fb0f3c451e changed: rename serializeObject to serializationTestObject
makes it more clear what these members are used for.
2022-10-04 14:10:30 +02:00
Bård Skaflestad
1010c81b3d Merge pull request #3162 from tskille/fix_rsm_compare_ecl
additional output from compareECL related to rsm files
2022-10-04 12:03:47 +02:00
Torbjørn Skille
cc6769c1a2 adding new file type RSM to compareECL
When using -t SMRY  the RSM file is not checked
When using -t RSM   the SMRY files is not checked

when running without -t option both RSM and SMRY files are checked together with restart, grid, init and rft file.
2022-10-04 08:51:36 +02:00
Torbjørn Skille
16af572080 additional output from compareECL related to rsm files 2022-10-03 19:16:41 +02:00
Bård Skaflestad
cea1dea368 Merge pull request #3091 from akva2/fix_uninitialized_access
fixed: avoid use of uninitialized SummaryNode::number_
2022-09-30 19:33:36 +02:00
Bård Skaflestad
51ecf87682 fixed: avoid use of uninitialized SummaryNode::number_
SummaryNode::number_ does not have a value for all
summary keywords.
2022-09-30 16:52:34 +02:00
Markus Blatt
a61747eb74 Merge pull request #3154 from tskille/fix_esmry_startd
Fix bug in ExtESmry
2022-09-28 19:57:15 +02:00
Bård Skaflestad
ec7145e817 Merge pull request #3160 from atgeirr/add-item-numbers-netbalan
Add item numbers for NETBALAN.
2022-09-28 18:52:59 +02:00
Atgeirr Flø Rasmussen
e10faa139c Add item numbers for NETBALAN. 2022-09-28 17:39:36 +02:00
Bård Skaflestad
99affa9043 Merge pull request #3110 from bska/rst-read-wgrupcon
Load WGRUPCON Information From Restart File
2022-09-28 15:18:36 +02:00
Bård Skaflestad
f54c3d7480 Load WGRUPCON Information From Restart File 2022-09-28 14:00:11 +02:00
Bård Skaflestad
6af6676d5f Remove Tests Which Only Passed by Accident
There is no reason to expect that, for instance, the dynamic
control mode in a restart file is equal to that of the input file.
2022-09-28 14:00:11 +02:00
Bård Skaflestad
eecb713e00 Pull Helper Functions Out of Opm Namespace
Mostly to more clearly distinguish these from proper library
functions.
2022-09-28 14:00:11 +02:00
Bård Skaflestad
6b05ee2210 Merge pull request #3094 from bska/add-smry-cat-compl
Add New Summary Node Category of Completion
2022-09-28 13:58:21 +02:00
Bård Skaflestad
03a94a7288 Add New Summary Node Category of Completion
This enables detecting the last remaining case that has a valid NUMS
entry despite nominally being a well-level keyword.
2022-09-27 18:16:47 +02:00
Bård Skaflestad
c5158a1c24 Merge pull request #3155 from bska/support-rft-seg-option
Internalise WRFTPLT Segment Option
2022-09-27 18:07:45 +02:00
Bård Skaflestad
1a3166d913 Simplify Erasure From PLT States
Suggested by: [at]blattms
2022-09-27 17:05:53 +02:00
Bård Skaflestad
328ee9b591 Internalise WRFTPLT Segment Option
In preparation of adding RFT file output support for segment data.
2022-09-27 17:05:23 +02:00
Torbjørn Skille
39c1a68f37 Fix bug in ExtESmry
Start date in ESMRY file (format) have 7 elements, last element is milliseconds.
2022-09-27 15:38:24 +02:00
Bård Skaflestad
26a566ef94 Merge pull request #3156 from kjetilly/kjetilly_reserved_keyword_fix
Remove use of reserved identifier in OPM_THROW.
2022-09-27 12:51:42 +02:00
Bård Skaflestad
39c91be4ee Merge pull request #3158 from bska/fix-facedir-switch
Handle All FaceDir Enumerators in Switch Statements
2022-09-27 10:18:42 +02:00
Bård Skaflestad
7a60c4c239 Handle All FaceDir Enumerators in Switch Statements
Forgotten in commit 9e143482c.
2022-09-26 13:19:25 +02:00
Kjetil Olsen Lye
c664a0dfd2 Remove use of reserved identifier in OPM_THROW. 2022-09-26 11:51:37 +02:00
Tor Harald Sandve
8e3efc0458 Merge pull request #532 from hakonhagland/krnum
Add support for directional relative permeabilites
2022-09-26 09:10:10 +02:00
Tor Harald Sandve
7e34f86f42 Merge pull request #3113 from hakonhagland/fieldprops
Add support for directional relative permeabilties
2022-09-26 09:09:52 +02:00
Bård Skaflestad
d609d942db Merge pull request #3152 from OPMUSER/VFPPROD
Update VFPProdTable.cpp
2022-09-23 10:59:33 +02:00
OPMUSER
c67bdf8aeb Update VFPProdTable.cpp
The error message for when VFPPROD tables had non-monotonic entries had the table number and the number of errors reversed. This PR fixes this output discrepancy.
2022-09-23 13:53:29 +08:00
Kai Bao
f0711ad092 Merge pull request #534 from GitPaean/diagnosing_failed_table_search
checking whether the value is finite when findSegmentIndex_ for Tabulated1DFunction.
2022-09-22 21:09:50 +02:00
Kai Bao
c22d8e66be checking whether the value is finite
when findSegmentIndex_ for Tabulated1DFunction.
2022-09-22 15:55:52 +02:00
Håkon Hægland
34ea7f3662 Add one more test 2022-09-21 15:47:41 +02:00
Bård Skaflestad
351a5d7292 Merge pull request #3150 from atgeirr/check-backend-exists
Check that backend exists before logging.
2022-09-21 12:02:39 +02:00
Kai Bao
f1d986e394 Merge pull request #533 from GitPaean/diagnosing_failed_table_search
changing assertions to throw with information output for function findSegmentIndex_ of class Tabulated1DFunction
2022-09-21 11:09:41 +02:00
Kai Bao
3e74c703c0 changing assertions to throw with information output
for function findSegmentIndex_ of class Tabulated1DFunction
2022-09-21 10:32:57 +02:00
Atgeirr Flø Rasmussen
c042c22546 Check that backend exists before logging. 2022-09-21 10:30:47 +02:00
Håkon Hægland
5086d5d74e Add a CopyablePtr class
Adds a template class that wraps a std::unique_ptr and makes it
copyable. See pull #714 in opm-models for a use case.
2022-09-20 01:30:16 +02:00
Bård Skaflestad
1850e45ed5 Merge pull request #3103 from bska/rst-read-wecon
Add Restart Support for Known Well Level Economic Limits
2022-09-19 10:25:07 +02:00
Bård Skaflestad
939b943911 Add Restart Support for Known Well Level Economic Limits
Notably missing are

  - Maximum gas-liquid ratio
  - Maximum temperature
  - Minimum reservoir fluid flow rate
  - Follow-on well

We do not currently write those items to the restart file but will
extend the support as need arises.
2022-09-16 18:32:01 +02:00
Bård Skaflestad
b33d04ebf7 Extract RstState Object Creation to Factory Function
In preparation of adding unit tests for restarted economic limits at
the well level (WECON).
2022-09-16 18:32:01 +02:00
Bård Skaflestad
34ab8d73b0 Tidy Up Implementation of RstWell
In particular, make RstWell::segment() return 'reference-to-const'
instead of an object.  While here, also rewrap the licence blocks
and reorder two data members.  The latter is in preparation of
adding restart support for economic limits (WECON).
2022-09-16 18:32:01 +02:00
Bård Skaflestad
cff70712ca Merge pull request #3149 from akva2/serializer_import
Import serializer code from opm-simulators
2022-09-16 16:02:06 +02:00
Arne Morten Kvarving
d731cd3775 import serializer code from opm-simulators
add tests using a simple memcpy based packer
2022-09-16 15:34:58 +02:00
Bård Skaflestad
95e78f64ad Merge pull request #3148 from akva2/serializer_simplify
changed: only use operator() for the serializer
2022-09-16 13:08:31 +02:00
Håkon Hægland
9e143482cf Add a unknown value to the facedir enum
This is will be used by code in opm-models and opm-simulators to
identify a face direction that is not known or not important.
2022-09-14 23:40:49 +02:00
Håkon Hægland
63f5dbdb81 Add debugging output method to FaceDir 2022-09-14 15:34:33 +02:00
Håkon Hægland
14f9c41613 Add KRNUM to recognized field props 2022-09-14 15:34:33 +02:00
Bård Skaflestad
25daf13909 Merge pull request #3107 from plgbrts/equil
keyword RVWVD to specify vaporized water-gas ratio  vs depth tables
2022-09-14 14:28:45 +02:00
Arne Morten Kvarving
6576370c19 changed: only use operator() for the serializer 2022-09-14 10:33:56 +02:00
Paul Egberts
35cf4761df updated cmake file 2022-09-14 10:27:12 +02:00
Paul Egberts
f55bbefd18 addition of entry in EQUIL keyword for water-gas ratio initialization 2022-09-13 17:58:28 +02:00
Markus Blatt
ff3da8cc79 Merge pull request #3146 from akva2/janitoring
Some janitoring
2022-09-12 12:36:21 +02:00
Tor Harald Sandve
d10ed6c953 Merge pull request #3109 from totto82/tempAquifer
add support for temperature and analytical aquifers
2022-09-12 07:32:49 +02:00
Arne Morten Kvarving
6546b780f8 fixed: respect rule-of-three for EclipseGrid
no need to explicitly declare the cc
2022-09-09 08:06:09 +02:00
Arne Morten Kvarving
1f5b60d651 changed: give variable a name
clang cannot parse the nameless variant for some reason
2022-09-09 07:46:45 +02:00
Arne Morten Kvarving
43c66042da add virtual dtor in class with virtual members 2022-09-09 07:46:18 +02:00
Arne Morten Kvarving
8e2445b4cc fixed: build python bindings on systems without openmp 2022-09-09 07:39:11 +02:00
Bård Skaflestad
b936fe6c0b Merge pull request #3145 from bska/refactor-rft-output
Refactor RFT File Writing Code
2022-09-08 17:05:52 +02:00
Bård Skaflestad
964fdfde12 Refactor RFT File Writing Code
In preparation of supporting new data types (PLT and segment).
Introduce a wrapper class, WellRFTOutputData, which knows about all
supported data types and how to emit the RFT record header.  Defer
specialised data type handling to dedicated record types and, to
this end, rename the existing WellRFT class to RFTRecord.
2022-09-08 16:22:39 +02:00
Bård Skaflestad
b38da649e0 Refactor RFTConfig
Mostly in preparation of adding new data types (e.g., segment),
but also to leverage standard algorithms and to apply 'const' where
possible.
2022-09-08 16:22:39 +02:00
Bård Skaflestad
07b506fc1c Reduce Level of Nesting in WRFT* Keyword Handlers
Mostly by switching from

    if (something) {
        handle case
    }

into

    if (! something) {
        continue;
    }

    handle case

While here, also reduce the length of a couple of very long lines.
2022-09-08 16:22:39 +02:00
Bård Skaflestad
d91608eff3 Rewrap WellConnections Code
Mostly to split long lines and to apply 'const' where possible.
2022-09-08 16:22:39 +02:00
Bård Skaflestad
8395ffd904 Merge pull request #3112 from bska/limit-action-messages
Direct Verbose Action Messages to Debug File

Resolves OPM/opm-simulators#4042
2022-09-08 16:10:24 +02:00
Bård Skaflestad
6b94c5091a Direct Verbose Action Messages to Debug File
While useful for analysis in the case of failure, end users will
typically not care that we "rerun" portions of the SCHEDULE section
in response to triggering an action.  In the cases where we do need
those messages they will be available in the CASE.DBG file instead.
2022-09-08 11:44:27 +02:00
Markus Blatt
d21926a837 Merge pull request #3095 from bska/rst-read-netbalan
Add Restart Support for NETBALAN Keyword
2022-09-08 11:16:34 +02:00
Bård Skaflestad
418173bbcc Add Restart Support for NETBALAN Keyword
This commit loads NETBALAN parameters from the restart file and
forms Network::Balance objects from these parameters.
2022-09-07 13:04:54 +02:00
Bård Skaflestad
1670c217ee Rename NETBALAN Items in INTEHEAD
Mostly to make restart code slightly more self explanatory.
2022-09-07 13:04:54 +02:00
Bård Skaflestad
de13002f2f Prepare for Adding NETBALAN Restart Support
Mostly whitespace and sorting headers.
2022-09-07 13:04:54 +02:00
Bård Skaflestad
541fba174a Merge pull request #3144 from akva2/remove_dead_serialization
Remove dead serialization code
2022-09-07 12:54:35 +02:00
Arne Morten Kvarving
d42481b747 add serializeObject to TranCalculator 2022-09-07 10:31:47 +02:00
Arne Morten Kvarving
ada6853a61 changed: remove unused Serialization class 2022-09-07 10:31:47 +02:00
Arne Morten Kvarving
1573ffb8da SummaryState: remove unused serialization code 2022-09-07 10:31:47 +02:00
Arne Morten Kvarving
0b1280ceec FieldProps(Manager): remove unused serialization code 2022-09-07 10:24:01 +02:00
Arne Morten Kvarving
5eb496c79c PAvgCalculator: remove unused serialization code 2022-09-07 10:24:01 +02:00
Arne Morten Kvarving
08830154b6 UDQScalar/UDQSet: remove unused serialization code 2022-09-07 10:08:54 +02:00
Arne Morten Kvarving
7b903660a0 UDQState: remove unused serialization code 2022-09-07 10:08:54 +02:00
Markus Blatt
f018c2e0d9 Merge pull request #3143 from akva2/tran_serialize
added: support serialization for TranCalculator
2022-09-07 10:04:59 +02:00
Arne Morten Kvarving
0c4492500b added: support serialization for TranCalculator
and some accessors to enable downstream to use it
2022-09-07 09:38:27 +02:00
Bård Skaflestad
1a9713278c Merge pull request #3142 from akva2/drop_friends
drop unused friend declarations
2022-09-07 09:36:14 +02:00
Bård Skaflestad
8a67f6606c Merge pull request #3141 from akva2/summarystate_append
added: append function in SummaryState
2022-09-07 09:35:36 +02:00
Arne Morten Kvarving
9690397cc1 drop unused friend declarations 2022-09-07 08:19:22 +02:00
Arne Morten Kvarving
a2bade84a4 added: append function in SummaryState
this appends information from one instance to another.
needed to handle semantics used in parallel serialization
2022-09-07 08:17:48 +02:00
Håkon Hægland
143ffd0e6f Add method to check for directional relperm
Adds a method that can be used to check if directional relperms are
enabled.
2022-09-06 19:25:13 +02:00
Bård Skaflestad
b1e3774aeb Merge pull request #3140 from akva2/summarystate_serialize
SummaryState: add serializer support
2022-09-06 11:33:05 +02:00
Bård Skaflestad
14c67cdbe6 Merge pull request #3139 from akva2/restartvalue_serialize
RestartValue: add serializer support
2022-09-06 10:41:36 +02:00
Arne Morten Kvarving
a8c0e19424 SummaryState: add serializer support 2022-09-06 10:03:55 +02:00
Arne Morten Kvarving
de7f5a8f69 RestartValue: add serializer support 2022-09-06 10:01:27 +02:00
Bård Skaflestad
e8b9e258b1 Merge pull request #3138 from akva2/aquiferdata_serialize
data::AquiferData: add serializer support
2022-09-06 09:55:29 +02:00
Bård Skaflestad
ae90a27ca1 Merge pull request #3134 from akva2/wells_serialize
data::Wells: add serializer support
2022-09-06 09:28:02 +02:00
Arne Morten Kvarving
64aee42bf1 data::AquiferData: add serializer support 2022-09-06 08:26:32 +02:00
Arne Morten Kvarving
c7329aa527 data::Wells: add serializer support 2022-09-06 08:23:40 +02:00
Bård Skaflestad
f6fa3e9fa5 Merge pull request #3137 from akva2/numericaquiferdata_serialize
data::NumericAquiferData: add serializer support
2022-09-05 16:26:37 +02:00
Bård Skaflestad
016b899ad6 Merge pull request #3136 from akva2/cartertracydata_serialize
data::CarterTracyData: add serializer support
2022-09-05 16:17:34 +02:00
Bård Skaflestad
9da5bbb463 Merge pull request #3135 from akva2/fetkovichdata_serialize
data::FetkovichData: add serializer support
2022-09-05 16:16:59 +02:00
Bård Skaflestad
8d6dbd9a7e Merge pull request #3133 from akva2/well_serialize
data::Well: add serializer support
2022-09-05 16:16:21 +02:00
Bård Skaflestad
6738269487 Merge pull request #3125 from akva2/groupandnetworkvalues_serialize
data::GroupAndNetworkValues: add serializer support
2022-09-05 16:15:49 +02:00
Arne Morten Kvarving
6112a6018b data::NumericAquiferData: add serializer support 2022-09-05 15:21:40 +02:00
Arne Morten Kvarving
1c967f6d70 data::CarterTracyData: add serializer support 2022-09-05 15:15:06 +02:00
Arne Morten Kvarving
1a9e6b3810 data::FetkovichData: add serializer support 2022-09-05 15:08:46 +02:00
Arne Morten Kvarving
bc6d5e38ce data::GroupAndNetworkValues: add serializer support 2022-09-05 14:12:16 +02:00
Bård Skaflestad
231b71a29c Merge pull request #3123 from akva2/groupdata_serialize
data::GroupData: add serializer support
2022-09-05 14:09:21 +02:00
Arne Morten Kvarving
645b3b3eaa data::Well: add serializer support 2022-09-05 13:57:18 +02:00
Arne Morten Kvarving
d68e254811 fixed: missing dynamicStatus in comparison operator 2022-09-05 13:57:18 +02:00
Bård Skaflestad
fbff174cd8 Merge pull request #3131 from akva2/segment_serialize
data::Segment: add serializer support
2022-09-05 13:19:00 +02:00
Arne Morten Kvarving
cb5475d178 data::GroupData: add serializer support 2022-09-05 13:02:47 +02:00
Bård Skaflestad
b05cba5315 Merge pull request #3122 from akva2/groupguiderates_serialize
data::GroupGuideRates: add serializer support
2022-09-05 13:01:15 +02:00
Arne Morten Kvarving
3d36bbcb9c data::Segment: add serializer support 2022-09-05 12:59:17 +02:00
Bård Skaflestad
a90b202b87 Merge pull request #3132 from akva2/currentcontrol_serialize
data::CurrentControl: add serializer support
2022-09-05 12:59:09 +02:00
Bård Skaflestad
0c1186346a Merge pull request #3129 from akva2/connection_serialize
data::Connection: add serializer support
2022-09-05 12:57:30 +02:00
Arne Morten Kvarving
f4af5fd947 data::Connection: add serializer support 2022-09-05 12:22:25 +02:00
Arne Morten Kvarving
ea8f64cb87 data::GroupGuideRates: add serializer support 2022-09-05 12:17:50 +02:00
Bård Skaflestad
524752da63 Merge pull request #3130 from akva2/segmentpressures_serialize
data::SegmentPressures: add serializer support
2022-09-05 12:15:07 +02:00
Bård Skaflestad
6ac5c8127d Merge pull request #3128 from akva2/rates_serialize
data::Rates: add serializer support
2022-09-05 12:14:33 +02:00
Bård Skaflestad
848942317e Merge pull request #3127 from akva2/solution_serialize
data::Solution: add serializer support
2022-09-05 12:14:05 +02:00
Bård Skaflestad
87a736ef84 Merge pull request #3121 from akva2/guideratevalue_serialize
data::GuideRateValue: add serializer support
2022-09-05 12:13:34 +02:00
Bård Skaflestad
6f45c91712 Merge pull request #531 from totto82/co2brineprop_thermal
Add enthalpy and internalEnergy to co2brinepvt
2022-09-05 11:50:16 +02:00
Arne Morten Kvarving
88d3d86dd6 data::CurrentControl: add serializer support 2022-09-05 11:47:20 +02:00
Bård Skaflestad
4faa9634a0 Merge pull request #3126 from akva2/restartkey_serialize
RestartKey: add serializer support
2022-09-05 11:11:35 +02:00
Arne Morten Kvarving
efe759676b data::SegmentPressures: add serializer support 2022-09-05 11:09:25 +02:00
Bård Skaflestad
a7ecd2aaac Merge pull request #3124 from akva2/nodedata_serialize
data::NodeData: add serializer support
2022-09-05 11:06:57 +02:00
Arne Morten Kvarving
e3a961df2b data::Rates: add serializer support 2022-09-05 10:35:51 +02:00
Arne Morten Kvarving
3abfddd088 data::Solution: add serializer support 2022-09-05 10:27:08 +02:00
Arne Morten Kvarving
7670a0c248 RestartKey: add serializer support 2022-09-05 10:19:26 +02:00
Paul Egberts
feb695e1fd new keyword RVWVD to specify vaporized water-gas ratio RVW vs depth tables 2022-09-05 10:06:12 +02:00
Arne Morten Kvarving
c95cae5c63 data::NodeData: add serializer support 2022-09-05 09:57:58 +02:00
Arne Morten Kvarving
883e701a13 data::GuideRateValue: add serializer support 2022-09-05 09:15:20 +02:00
Bård Skaflestad
2a4f62844d Merge pull request #3120 from akva2/serialize_groupconstraints
data::GroupConstraints: add serializer support
2022-09-02 21:44:08 +02:00
Bård Skaflestad
7f50f7e95d Merge pull request #3118 from akva2/serialize_map_change
adjust for map serializer API change
2022-09-02 20:59:07 +02:00
Bård Skaflestad
3dcc3e35b9 Merge pull request #3117 from akva2/serialize_set_change
adjust for set serializer API change
2022-09-02 20:57:36 +02:00
Arne Morten Kvarving
d5830c0aa0 data::GroupConstraints: add serializer support 2022-09-02 18:12:09 +02:00
Bård Skaflestad
3c48148d8b Merge pull request #3119 from akva2/celldata_serialize
data::CellData: add serializer support
2022-09-02 17:24:36 +02:00
Arne Morten Kvarving
d09c275fe4 adjust for map serializer API change 2022-09-02 17:20:14 +02:00
Arne Morten Kvarving
99ea0ee497 adjust for set serializer API change 2022-09-02 17:17:11 +02:00
Bård Skaflestad
e9e70c6eac Merge pull request #3116 from akva2/serialize_vector_change
adjust for vector serializer API change
2022-09-02 17:08:14 +02:00
Bård Skaflestad
93dbf570d6 Merge pull request #3115 from akva2/serialize_array_change
adjust for array serializer API change
2022-09-02 17:07:29 +02:00
Arne Morten Kvarving
a21680cc96 data::CellData: add serializer support 2022-09-02 15:52:11 +02:00
Arne Morten Kvarving
0de1c488d2 adjust for vector serializer API change 2022-09-02 14:39:16 +02:00
Arne Morten Kvarving
fd3f444c80 adjust for array serializer API change 2022-09-02 14:18:15 +02:00
Tor Harald Sandve
4e9dbbdd7f add enthalpy and internalEnergy to co2brinepvt 2022-09-01 15:08:29 +02:00
Bård Skaflestad
17c8b01d4b Merge pull request #3111 from akva2/fix_cell_serialize_object
fixed: initialize dimensions in serializeObject
2022-09-01 13:17:52 +02:00
Tor Harald Sandve
072b8be064 add support for temperature and analytical aquifers 2022-09-01 12:28:22 +02:00
Arne Morten Kvarving
a3a9413ab0 fixed: initialize dimensions in serializeObject
the array is left uninitialized by the constructor
2022-09-01 12:21:58 +02:00
Håkon Hægland
148fa6c8c3 Add support for KRNUM 2022-08-29 11:12:59 +02:00
Bård Skaflestad
1522ee4f4d Merge pull request #3035 from GitPaean/throw_wrong_time_stepping
throw when report steps has start time later than end time
2022-08-26 10:59:33 +02:00
Kai Bao
632f1457b1 throw for an inconsistent DATES setup 2022-08-26 10:07:21 +02:00
Bård Skaflestad
21f21ab8fa Merge pull request #530 from totto82/fixBugSpline
fix bug for assigning from reversed order samples in the Spline.hpp

Resolves #527.
2022-08-26 09:57:41 +02:00
Tor Harald Sandve
d7503a52f0 fix bug for assigning from reversed order samples in the Spline.hpp 2022-08-26 08:35:07 +02:00
Markus Blatt
6479f77340 Merge pull request #3105 from bska/serialize-all-schedule-data
Serialize All Schedule Data Members
2022-08-25 14:54:35 +02:00
Kai Bao
3ffc61e221 throw when a negative TSTEP value is input 2022-08-25 14:38:00 +02:00
Bård Skaflestad
9658257960 Serialize Exit Status
While here, also add missing serialization tests for WGNames and
CompletedCells.
2022-08-25 11:22:59 +02:00
Bård Skaflestad
7ee1fd9ed1 Match Member Order in Schedule Serialization
In particular, in Schedule::seralizeOp(), Schedule::operator==(),
and Schedule::serializeObject().
2022-08-25 11:20:51 +02:00
Bård Skaflestad
da6802e787 Prefer Template Argument Deduction
Don't pass 'Serializer' as an explicit template argument.
2022-08-25 11:14:37 +02:00
Kai Bao
f1986689b5 fixing a schedule test and adding another for PR3035 2022-08-24 16:07:19 +02:00
Kai Bao
b9ed81fe2a throw when report steps has start time later than end time 2022-08-24 16:07:19 +02:00
Atgeirr Flø Rasmussen
ba120652b5 Merge pull request #3104 from atgeirr/fix-packing
Prepare for fixing packing of Rates, fix bug in Connection comparison operator
2022-08-24 15:23:44 +02:00
Atgeirr Flø Rasmussen
6c5e2541bc Do not test equality for unneeded objects.
They are not equal in any case, now that the comparison operator
for Connection is fixed.
2022-08-24 14:50:39 +02:00
Atgeirr Flø Rasmussen
2f7f360563 Bugfix: compare trans_factor in Connection::operator==(). 2022-08-24 14:50:39 +02:00
Atgeirr Flø Rasmussen
8754a59d38 Add friend declarations to enable writing out of class packing functions. 2022-08-24 14:50:39 +02:00
Bård Skaflestad
70d45e74dc Merge pull request #3102 from GitPaean/handling_connection_aquifer_mismatch
Handling connection aquifer mismatch
2022-08-24 09:52:22 +02:00
Kai Bao
61e68dccb6 fixing running when only analytical aquifer connections defined
without this, the restart writer will trigger a segmentation fault
error.

And also, some minor refactoring and function development so that the
simulator can check whether there are valid connections defined for
aquifers with certain id.
2022-08-24 09:31:20 +02:00
Atgeirr Flø Rasmussen
e4346da3ea Merge pull request #3101 from atgeirr/use-portable-timegm
Add and use portable_timegm().
2022-08-18 09:58:06 +02:00
Atgeirr Flø Rasmussen
49262ae96d Add and use portable_timegm().
This function converts a std::tm to a std::time_t, assuming UTC
and not local timezone. This is used instead of relying on
repeated calls to mktime(), which can fail on some system (BSD)
for dates before 1900.
2022-08-18 09:21:52 +02:00
Bård Skaflestad
cbab4e50c0 Merge pull request #3100 from tskille/smspec_bug
fixing bug in IO class ESmry
2022-08-17 17:48:40 +02:00
Torbjørn Skille
94150f1a0c fixing bug in IO class ESmry 2022-08-17 15:54:45 +02:00
Bård Skaflestad
ff13f8c091 Merge pull request #3099 from GitPaean/extend_default_aqutab
extend the range of default AQUTAB table (table 1)
2022-08-17 13:35:43 +02:00
Kai Bao
0dadf54a23 extend the range of default AQUTAB table (table 1)
for better accuracy of the extrapolation
2022-08-16 23:43:43 +02:00
Bård Skaflestad
17a08ddcd9 Merge pull request #3098 from atgeirr/modify-aquancon-inactive-cell-warnings
AQUANCON: Add a summarizing warning stating the number of inactive connection ignored
2022-08-16 18:18:09 +02:00
Atgeirr Flø Rasmussen
8e636f22a1 Add a summarizing warning stating the number of inactive connections ignored.
Also add tags to the Aquancon inactive connection warnings.
2022-08-16 15:39:17 +02:00
Markus Blatt
b2add81973 Merge pull request #529 from akva2/use_std_array
changed: consistently use std::array
2022-08-16 15:07:22 +02:00
Bård Skaflestad
e5fdfb16df Merge pull request #3097 from bska/restore-build
Remove Consistency Checks for SPE10 Models
2022-08-16 14:37:57 +02:00
Bård Skaflestad
cc48ad4632 Remove Consistency Checks for SPE10 Models
The input decks were removed from the opm-tests repository.  We
*may* consider readding them from a new location at a later time.
2022-08-16 14:01:33 +02:00
Arne Morten Kvarving
bb813485ab changed: consistently use std::array 2022-08-16 08:34:04 +02:00
Bård Skaflestad
dacd635c38 Merge pull request #3092 from atgeirr/fix-wpimult-actionx
Enable using WPIMULT in ACTIONX.
2022-08-12 17:56:20 +02:00
Bård Skaflestad
9660189290 Merge pull request #3096 from akva2/remove_empty_well_header
changed: remove (basically) empty Well(Injection|Production)Properties.hpp
2022-08-11 12:55:00 +02:00
Arne Morten Kvarving
5df933460b changed: remove (basically) empty Well(Injection|Production)Properties.hpp 2022-08-11 11:47:54 +02:00
Bård Skaflestad
e4129cf826 Merge pull request #3080 from totto82/add_unit_gas_oil_ratio_rate
add unit gas oil ratio rate for output of drsdt
2022-08-11 11:29:26 +02:00
Tor Harald Sandve
189a043c6d add unit gas oil ratio rate for output of drsdt 2022-08-10 15:42:50 +02:00
Tor Harald Sandve
5c693b7330 Merge pull request #519 from totto82/refdensity_with_salinity
compute reference density with the given salinity
2022-08-10 11:06:52 +02:00
Markus Blatt
dad8bdcdc3 Merge pull request #526 from akva2/blackoil_modernization
Modernization in BlackOil classes
2022-08-09 16:01:53 +02:00
Arne Morten Kvarving
f9d4059071 BlackOilFluidSystem: some modernization
- typedef -> using
- use constexpr where appropriate
2022-08-09 11:03:21 +02:00
Arne Morten Kvarving
bfed02707a BlackOilFluidState: some modernization
- typedef -> using
- use if constexpr where appropriate
2022-08-09 11:03:02 +02:00
Atgeirr Flø Rasmussen
7e8a91b81f Enable using WPIMULT in ACTIONX. 2022-08-04 09:19:44 +02:00
Markus Blatt
6190ab54b1 Merge pull request #523 from akva2/pvt_cleanup
Cleanups and modernization in pvt classes
2022-08-04 09:11:21 +02:00
Arne Morten Kvarving
6a09cc81ef WetHumidGasPvt: some modernization
- typedef -> using
- use constexpr where appropriate
- remove unused includes
2022-08-04 08:20:22 +02:00
Arne Morten Kvarving
c786cc595a WetGasPvt: some modernization
- typedef -> using
- use constexpr where appropriate
- remove unused includes
2022-08-04 08:20:22 +02:00
Arne Morten Kvarving
6e964719c0 WaterPvtThermal: some modernization
- typedef -> using
- use constexpr where appropriate
- remove unused includes
2022-08-04 08:14:28 +02:00
Arne Morten Kvarving
5552e90e8d SolventPvt: some modernization
- typedef -> using
- remove unused includes
2022-08-04 08:14:28 +02:00
Arne Morten Kvarving
6f42fbc0cb OilPvtThermal: some modernization
- typedef -> using
- use constexpr where appropriate
- remove unused includes
2022-08-04 08:14:28 +02:00
Arne Morten Kvarving
22694d96b6 LiveOilPvt: some modernization
- typedef -> using
- use constexpr where appropriate
- remove unused includes
2022-08-04 08:14:28 +02:00
Arne Morten Kvarving
9c155e7b26 GasPvtThermal: some modernization
- typedef -> using
- use constexpr where appropriate
- remove unused includes
2022-08-04 08:14:28 +02:00
Arne Morten Kvarving
01c01b98e0 DryHumidGasPvt: some modernization
- typedef -> using
- use constexpr where appropriate
- remove unused includes
2022-08-04 08:14:28 +02:00
Arne Morten Kvarving
4f2bdbab0b DryGasPvt: some modernization
- typedef -> using
- use constexpr where appropriate
- remove unused includes
2022-08-04 08:14:28 +02:00
Arne Morten Kvarving
7f8602a46b DeadOilPvt: some modernization
- typedef -> using
- remove unused includes
2022-08-04 08:14:28 +02:00
Arne Morten Kvarving
7c401a3bb3 ConstantCompressibilityWaterPvt: remove unused typedefs 2022-08-04 08:14:28 +02:00
Arne Morten Kvarving
dad0ceed43 ConstantCompressibilityOilPvt: remove unused typedefs 2022-08-04 08:14:28 +02:00
Arne Morten Kvarving
6159e1baf0 ConstantCompressbilityBrinePvt: some modernization
- typedef -> using
2022-08-04 08:14:28 +02:00
Arne Morten Kvarving
a67f58da14 Co2GasPvt: some modernization
- typedef -> using
- use constexpr where appropriate
2022-08-04 08:14:28 +02:00
Arne Morten Kvarving
e5c7ee9443 BrineCo2Pvt: some modernization
- typedef -> using
- use constexpr where appropriate
2022-08-04 08:14:28 +02:00
Markus Blatt
ea6bf3e883 Merge pull request #524 from akva2/ecl_cleanup
Cleanup, fixes and modernization in Ecl classes
2022-08-03 16:33:19 +02:00
Arne Morten Kvarving
6691a33c08 NullThermalConductionLaw: some modernization
- typedef -> using
2022-08-03 11:14:05 +02:00
Arne Morten Kvarving
199fe24e71 NullSolidEnergyLaw: some modernization
- typedef -> using
- fix includes
2022-08-03 11:09:31 +02:00
Arne Morten Kvarving
491375aa1d EclThermalLawManager: some modernization
- typedef -> using
- fix includes
2022-08-03 11:04:48 +02:00
Arne Morten Kvarving
a9e78c8c34 EclThermalConductionLawMultiplexer(Params): some modernization
- typedef -> using
- fix includes
2022-08-03 11:00:30 +02:00
Arne Morten Kvarving
38864a4793 EclThconrLaw(Params): some modernization
- typedef -> using
2022-08-03 10:55:47 +02:00
Arne Morten Kvarving
31c7641fac EclThwLaw(Params): some modernization
- typedef -> using
- use constexpr where appropriate
- fix includes
2022-08-03 10:51:40 +02:00
Arne Morten Kvarving
e1db0bbb4c EclSpecrockLaw(Params): some modernization
- typedef -> using
- fix includes
2022-08-03 10:46:29 +02:00
Arne Morten Kvarving
791aad07bd EclSolidEnergyLawMultiplexer(Params): some modernization
- typedef -> using
- fix includes
2022-08-03 10:43:55 +02:00
Arne Morten Kvarving
2a1cb8d9c9 EclHeatcrLaw(Params): some modernization
- typedef -> using
- fix includes
2022-08-03 10:35:43 +02:00
Arne Morten Kvarving
85f5d23966 PiecewiseLinearTwoPhaseMaterial(Params): some modernization
- typedef -> using
- use constexpr where appropriate
- fix includes
2022-08-03 10:21:52 +02:00
Arne Morten Kvarving
a9c26cbd18 TwoPhaseLETCurves(Params): some modernization
- typedef -> using
- use constexpr where appropriate
- fix includes
2022-08-03 10:21:52 +02:00
Arne Morten Kvarving
f4d7b96485 SatCurveMultiplexer(Params): some modernization
- typedef -> using
- use constexpr where appropriate
- fix includes
2022-08-03 10:21:52 +02:00
Arne Morten Kvarving
d9e4bc6aa2 MaterialTraits: some modernization
- typedef -> using
- use constexpr where appropriate
2022-08-03 10:21:52 +02:00
Arne Morten Kvarving
d7fa046d3b EclTwoPhaseMaterial(Params): some modernization
- typedef -> using
- use constexpr where appropriate
- fix includes
2022-08-03 10:21:52 +02:00
Arne Morten Kvarving
1cdadca7cd EclStone2Material(Params): some modernization
- typedef -> using
- use constexpr where appropriate
- fix includes
2022-08-03 10:21:52 +02:00
Arne Morten Kvarving
cfc5ad7061 EclStone1Material(Params): some modernization
- typedef -> using
- use constexpr where appropriate
- fix includes
2022-08-03 10:21:52 +02:00
Arne Morten Kvarving
2a266a5834 EclMultiplexerMaterial(Params): some modernization
- typedef -> using
- use constexpr where appropriate
- fix includes
2022-08-03 10:21:52 +02:00
Arne Morten Kvarving
cb51404dfa EclMaterialLawManager: some modernization
- typedef -> using
- use constexpr where appropriate
2022-08-03 10:21:52 +02:00
Arne Morten Kvarving
8c63ef6f04 EclHysteresisTwoPhaseLaw(Params): some modernization
- typedef -> using
- use constexpr where appropriate
- fix includes
2022-08-03 10:21:52 +02:00
Arne Morten Kvarving
6f75049854 EclHysteresisConfig: fix includes 2022-08-03 10:21:52 +02:00
Arne Morten Kvarving
b8e6353d8f EclEpsTwoPhaseLaw(Params): some modernization
- typedef -> using
- remove unused headers
2022-08-03 10:21:52 +02:00
Arne Morten Kvarving
55c5c4b6fc EclEpsScalingPoints: fix includes 2022-08-03 10:21:52 +02:00
Arne Morten Kvarving
f20d8f56e7 EclEpsGridProperties: fix includes 2022-08-03 10:21:52 +02:00
Arne Morten Kvarving
62bc8f5e54 EclEpsConfig: fix includes 2022-08-03 10:21:52 +02:00
Arne Morten Kvarving
ce2b049d26 EclDefaultMaterial(Params): some modernization
- typedef -> using
- use constexpr where appropriate
- remove unused headers
2022-08-03 10:21:52 +02:00
Markus Blatt
ef6fc32216 Merge pull request #521 from akva2/component_fixes
Fixes in some component classes
2022-08-02 14:21:11 +02:00
Markus Blatt
9bb9caaec3 Merge pull request #522 from akva2/remove_unused
Remove Unused.hpp
2022-08-02 14:19:10 +02:00
Arne Morten Kvarving
6e96bada9b remove now unused Unused.hpp 2022-08-02 10:32:12 +02:00
Arne Morten Kvarving
260a0c2dc3 replace Unused.hpp with [[maybe_unused]] or anonymous variables 2022-08-02 10:32:00 +02:00
Arne Morten Kvarving
cb9f01df4e remove unused includes of Unused.hpp 2022-08-02 10:16:25 +02:00
Arne Morten Kvarving
e96594d32c Valgrind: get rid of Unused.hpp usage 2022-08-02 09:58:30 +02:00
Arne Morten Kvarving
81abc289a5 CO2: avoid use dangling references
using a reference to a temporary is not okay
2022-08-02 09:47:14 +02:00
Arne Morten Kvarving
c7b434d918 CO2: some modernization
- use constexpr
2022-08-02 09:47:14 +02:00
Arne Morten Kvarving
37e7e6a611 Brine: avoid use dangling references
using a reference to a temporary is not okay
2022-08-02 09:47:09 +02:00
Arne Morten Kvarving
e42bb116f8 Brine: some modernization
- use constexpr
2022-08-02 09:47:09 +02:00
Arne Morten Kvarving
b626f0d713 SimpleHuDuanH2O: avoid use of dangling reference
using a reference to a temporary is not okay
2022-08-02 09:47:00 +02:00
Arne Morten Kvarving
f2eadd2ab3 SimpleHuDuanH2O: some modernization
- typedef -> using
- use constexpr
2022-08-02 09:19:50 +02:00
Atgeirr Flø Rasmussen
2e131727a8 Merge pull request #482 from akva2/avoid_manual_mem_management
changed: avoid manual memory management
2022-08-02 08:44:32 +02:00
Bård Skaflestad
eb7476e0cf Merge pull request #3089 from atgeirr/add-missing-include
Add <cstddef> include for std::size_t.
2022-08-01 00:05:10 +02:00
Atgeirr Flø Rasmussen
f96290e1df Add <cstddef> include for std::size_t. 2022-07-31 21:24:30 +02:00
Bård Skaflestad
9af8c785b2 Merge pull request #3085 from akva2/cleanup_schedule
Cleanup Schedule.hpp usage
2022-07-30 00:42:06 +02:00
Arne Morten Kvarving
e82ec7a274 clean up includes in Schedule.hpp 2022-07-29 18:37:57 +02:00
Markus Blatt
6561138236 Merge pull request #3067 from GitPaean/fixing_multiple_wpimult
fixing multiple WPIMULT records
2022-07-29 10:24:50 +02:00
Markus Blatt
26886bf4fa Merge pull request #3087 from akva2/small_buildsys_fixes
Small buildsystem fixes
2022-07-28 09:03:48 +02:00
Bård Skaflestad
9ec5680915 Merge pull request #3086 from akva2/remove_unused
remove unused file
2022-07-28 00:58:29 +02:00
Arne Morten Kvarving
0b0f9cab33 remove faulty brace 2022-07-27 18:08:52 +02:00
Arne Morten Kvarving
90f27b58cd fixed: use proper case in find_package_handle_standard_args 2022-07-27 18:08:52 +02:00
Arne Morten Kvarving
1012e15711 remove unused file 2022-07-27 17:51:17 +02:00
Arne Morten Kvarving
ec57a4d10b changed: remove include of Schedule.hpp in header
and deal with the consequences
2022-07-27 17:13:45 +02:00
Markus Blatt
92ebef3bc9 Merge pull request #3084 from akva2/cleanup_stream_includes
clean up stream includes
2022-07-27 17:08:28 +02:00
Markus Blatt
3e4c0d4370 Merge pull request #520 from akva2/cleanup_deck
remove unnecessary includes
2022-07-27 17:06:37 +02:00
Markus Blatt
5532176af4 Merge pull request #3083 from akva2/cleanup_deck
changed: remove include of Deck.hpp in header
2022-07-27 17:06:26 +02:00
Markus Blatt
c5b0cd6f61 Merge pull request #3082 from akva2/clean_eclipsestate
changed: remove include of EclipseState.hpp in header
2022-07-27 17:03:17 +02:00
Arne Morten Kvarving
068bff1ebc clean up stream includes 2022-07-27 16:05:01 +02:00
Arne Morten Kvarving
ffcd22ebb1 remove unnecessary includes 2022-07-27 15:36:46 +02:00
Arne Morten Kvarving
5e7191c79e changed: remove include of Deck.hpp in header
and deal with the consequences
2022-07-26 18:42:39 +02:00
Arne Morten Kvarving
ef6d448077 changed: remove include of EclipseState.hpp in header
and deal with the consequences
2022-07-26 16:03:52 +02:00
Arne Morten Kvarving
10dcb8945f Merge pull request #3081 from Diullei/patch-1
Fix eclipse SOLWNUM json file
2022-07-25 08:33:08 +02:00
Diullei Gomes
cf0eb66009 Fix eclipse SOLWNUM json file property name 2022-07-24 11:11:29 +02:00
Tor Harald Sandve
f713369ef3 compute reference density with the given salinity 2022-07-21 15:39:43 +02:00
OPMUSER
b4da5d0283 Update EclipseState.cpp
MULTFLT update to improve error reporting.
2022-07-21 20:29:41 +08:00
OPMUSER
f43b6bca75 Improve Error Message for MULTFLT
Improve Error Message for MULTFLT see https://github.com/OPM/opm-common/pull/3062
2022-07-18 15:05:55 +08:00
Bård Skaflestad
247547355c Merge pull request #3074 from OPMUSER/NNC
Update NNC
2022-07-14 14:13:12 +02:00
OPMUSER
1ea89ab140 Update NNC
Remove erroneous warning messages:

  NNC: invalid value '' in record 1 for item 12
  In file: RON-P50-A01-OPM.DATA, line 3387
  NNC(FACE1): not supported use 1* - will continue

For NNC(FACE1) and NNC(FACE2) by deleting the default "" value in the JSON file.

Client model had hundreds of these messages.
2022-07-14 18:20:39 +08:00
Bård Skaflestad
5cca4b0be0 Merge pull request #3071 from OPMUSER/MINPORV
Support MINPORV
2022-07-12 14:12:34 +02:00
OPMUSER
a8a1d140d5 Update EclipseGrid and JSON Definitions
Update EclipseGrid with checks for MINPVFIL. For JSON definitions: remove MINPVFIL check in MINPV and MINPORV, and all checks from MINPVFIL.
2022-07-12 11:07:10 +08:00
OPMUSER
4fe559ba3c Remove C++ Code and Place Conditions in JSON Files
Remove the C++ code checks and instead place the logic in the keyword JSON files. This is a cleaner approach.
Note we force that only one of the keywords is allowed in the deck to avoid confusion on what cut-off is actually being applied.
2022-07-11 15:02:10 +08:00
OPMUSER
a5cfafe4de Support MINPORV
Add support for MINPORV, which is an alias for MINPV. Also added additional checks, such that only one of MINPV, MINPORV and MINPVFIL can be active in the deck
2022-07-11 14:05:34 +08:00
Markus Blatt
bad915fdf5 Merge pull request #3069 from bska/decouple-box-from-grid
Decouple Opm::Box From EclipseGrid
2022-07-06 15:15:51 +02:00
Kai Bao
96ab0e036d addressing some reviewing comments for PR#3067 2022-07-06 14:32:59 +02:00
Atgeirr Flø Rasmussen
d5aa9dd29a Merge pull request #516 from trinemykk/add-chi-flash-trine
PT Flash for multiple components
2022-07-06 08:44:56 +02:00
trinemykk
be186ffffc Merge pull request #6 from GitPaean/add-chi-flash-trine
simplify the updateDerivativeSinglephase
2022-07-05 15:05:06 +02:00
Bård Skaflestad
a79ee15082 Decouple Opm::Box From EclipseGrid
This commit switches to constructing Box instances from a GridDims
and two call-back functions instead of taking an EclipseGrid
directly.  The two call-back functions are a predicate for active
cells and a translation from Cartesian to active cell indices
respectively.

This is intended to simplify working with nested boxes, such as
those that occur for local grid refinement.
2022-07-05 14:27:49 +02:00
Markus Blatt
7dd56d2bde Merge pull request #3070 from bska/simplify-griddims-ijk
Streamline GridDims::getIJK()
2022-07-05 14:23:41 +02:00
Kai Bao
eccce0209c simplify the updateDerivativeSinglephase
and also finishing the singlephase test.
2022-07-05 14:20:59 +02:00
Trine Mykkeltvedt
6da7cab570 WIP: simplified the update of the derivatives for the singlephase, too simple and to much. need to generalize 2022-07-05 12:03:12 +02:00
Trine Mykkeltvedt
dbcede4d76 splitted updateDerivatives for two and singlephasecase 2022-07-05 11:04:24 +02:00
Kai Bao
b87867d144 multple MPIMULT keywords within one report step is handled
and ScheduleTests is updated with tests
2022-07-05 10:52:25 +02:00
Bård Skaflestad
5377ff3442 Streamline GridDims::getIJK()
This commit switches the Cartesian -> IJK decomposition in GridDims
from K->J->I into the I->J->K order.  The latter is simpler.

While here, also consistently use 'std::size_t' instead of 'size_t'.
2022-07-04 15:06:07 +02:00
Bård Skaflestad
336f7a4159 Merge pull request #3064 from bska/refactor-numerical-aquifer-handling
Handle Active Cell/Numerical Aquifers In Constructor Body
2022-07-04 15:04:55 +02:00
Bård Skaflestad
c740b3705d Handle Active Cell/Numerical Aquifers In Constructor Body
The constructor did implicitly assume that no cell in a numerical
aquifer would be declared inactive in ACTNUM, and this restriction
still applies.  Moving numerical aquifer property and connection
processing into the constructor body enables using existing member
functions for non-neighbouring connections and removes a branch that
obscured the fact that we should have ACTNUM be as close to
finalised as possible before creating analytic aquifer connections.
2022-07-04 14:08:11 +02:00
Bård Skaflestad
c951d7ff6e Merge pull request #3068 from goncalvesmachadoc/temp
fix Bug Temp
2022-07-04 14:06:11 +02:00
trinemykk
2b1f08ff43 Merge pull request #5 from svenn-t/add-chi-flash-trine
Changed order of input
2022-07-01 10:17:58 +02:00
Svenn Tveit
1cddf4b5d4 Changed order of input 2022-07-01 09:03:48 +02:00
trinemykk
1204f3c94e Merge pull request #4 from GitPaean/add-chi-flash-trine
some shallow cleaning up
2022-06-30 14:45:17 +02:00
Trine Mykkeltvedt
c1b0d88a89 added a setup for co2 and brine that gives single phase in the flash, need to add a refrence solution for comparison at some point 2022-06-30 14:42:26 +02:00
Kai Bao
0310d25e99 some shallow cleaning up 2022-06-30 14:36:59 +02:00
Trine Mykkeltvedt
1d2db38172 testing all three solution strategies for test_co2brine_ptflash and also, a refrence result comparison is added 2022-06-30 13:56:55 +02:00
goncalvesmachadoc
99702cdf49 fixBugTemp 2022-06-30 13:44:09 +02:00
Kai Bao
ffa12e5d09 adding a test for WPIMULT to test new functionality
from this PR.
2022-06-30 13:30:36 +02:00
trinemykk
dd52b90564 Merge pull request #3 from GitPaean/add-chi-flash-trine
testing all three solution strategies for test_threecomponents_ptflash
2022-06-30 09:32:11 +02:00
Kai Bao
dac57ac2eb testing all three solution strategies for test_threecomponents_ptflash
and also, the reference result comparison is added.
2022-06-29 23:54:00 +02:00
Kai Bao
3f025070fe fixing interpreting multiple WPIMULT records
During a report step, if there are multple records for a well has
defaulted connection and completion information, only the last record
will apply to that well.

But the following record is considered not to have defaulted connection
and completion information.

WMPIMUL
  'WEL' 0.8 0 0 0 /
/
2022-06-29 10:54:20 +02:00
Trine Mykkeltvedt
f0d8a9f3cc renamed and cleaned viscosityfiles 2022-06-28 23:02:24 +02:00
Trine Mykkeltvedt
659ae7e846 fixed some jenkins warnings 2022-06-28 13:28:49 +02:00
Bård Skaflestad
1516b63a39 Merge pull request #3065 from blattms/ordered-map-truncate-key
Use only first 8 characters as fault name when comparing/searching.
2022-06-28 10:22:35 +02:00
Bård Skaflestad
be5996a3ca Merge pull request #517 from akva2/fix_initializer
fixed: wrong value in initialization
2022-06-27 16:04:29 +02:00
Arne Morten Kvarving
12943a3fab Merge pull request #518 from akva2/janitoring
changed: anonymize unused parameters
2022-06-27 15:27:39 +02:00
Arne Morten Kvarving
fdc0ea3436 Merge pull request #3066 from akva2/janitoring
Some janitoring
2022-06-27 15:27:29 +02:00
Arne Morten Kvarving
114753c459 changed: add initializer
harmless and suppresses compiler diagnostics
2022-06-27 14:44:30 +02:00
Arne Morten Kvarving
e2c99a28e7 changed: remove unused lambda captures 2022-06-27 14:44:30 +02:00
Arne Morten Kvarving
b70ac697a3 fixed: wrong value in initialization 2022-06-27 14:43:16 +02:00
Arne Morten Kvarving
91a42c13a2 changed: anonymize unused parameters 2022-06-27 14:41:59 +02:00
Trine Mykkeltvedt
3d8826fc28 some copyright for some new files 2022-06-27 13:11:28 +02:00
Trine Mykkeltvedt
6b62b32da2 added aCache, this probably should be added to ParameterCacheBase at some point 2022-06-27 13:03:37 +02:00
Markus Blatt
80545120b6 Merge pull request #3063 from bska/ensure-correct-initial-actnum
Apply Generalised ACTNUM Handling to All Grid Types
2022-06-27 11:32:48 +02:00
Kai Bao
1728d53371 fxing the warning related to compIdx in PTFlash 2022-06-27 11:19:26 +02:00
Markus Blatt
35029e0313 Only use first 8 characters as fault names when comparing/searching.
Note this is currently done silently as the warnings will probably
need to go to the validation code in opm-simulators.
2022-06-27 11:14:41 +02:00
Markus Blatt
19c58e33c4 Document at least what OrderedMap class is all about. 2022-06-27 11:14:22 +02:00
Markus Blatt
d4cd92ee40 Support ignoring additional characters in key of OrderedMap.
At least for faults we should only look at the first 8 characters.
2022-06-27 11:14:22 +02:00
Kai Bao
41a489c9ad fixing a warning in PTFlash regarding local_res 2022-06-27 11:13:00 +02:00
Kai Bao
79d89bd7ea Merge remote-tracking branch 'trine/add-chi-flash-trine' into add-chi-flash-trine 2022-06-27 10:59:31 +02:00
Trine Mykkeltvedt
6304acb292 fixed test_components for the new actentric factor and criticalVolume 2022-06-27 10:37:17 +02:00
Trine Mykkeltvedt
8d91d3704e removed unused functions and did some renaming in PTFlash 2022-06-27 10:37:17 +02:00
Kai Bao
6f001d8792 adding includes files to test_components
But many components do not have the criticalVolume and acentricFactor
defined. So test_components does not compile.
2022-06-27 10:37:17 +02:00
Kai Bao
30839ee32b renaming ChiFlash to PTFlash 2022-06-27 10:37:17 +02:00
Kai Bao
07b05d5b06 white space cleaning up
no functionality change.
2022-06-27 10:37:17 +02:00
Trine Mykkeltvedt
1565cb1a96 more peng robinson 2022-06-27 10:37:16 +02:00
Kai Bao
13469c63a0 cleaning up FluidStateCompositionModules.hpp a little bit.
mostly removing the twophaselflag_, which is not used anywhere.

not functionality changes.
2022-06-27 10:37:16 +02:00
Trine Mykkeltvedt
7762589cea more peng robinson stuff 2022-06-27 10:37:16 +02:00
Trine Mykkeltvedt
a02a614948 more cleaning in the PengRobinson files 2022-06-27 10:37:16 +02:00
Trine Mykkeltvedt
13cc0a8197 cleaned PengRobinson, uncommented the stuff about extrema in the case of one rott - I think it can just be as it was 2022-06-27 10:37:16 +02:00
Trine Mykkeltvedt
06ef3bdc62 removed some printing in the polynomialsolver 2022-06-27 10:37:16 +02:00
Kai Bao
89ad5a1e81 slightly cleaning up PengRobinsonMixture.hpp a little bit
there are some more trivial cleaning work remains.
2022-06-27 10:37:16 +02:00
Trine Mykkeltvedt
eb3b24b14c cleaned up the viscositymodels, two choises availible: LBC and modified LBC 2022-06-27 10:37:16 +02:00
Trine Mykkeltvedt
647efce497 moved the viscositymodels to a separate folder alongside the fluidsystem, in principle there are two viscositymodels: the standard LBC and the modified LBC. However, there might me some discrepancy between LBC and LBCjulia - this needs to be sorted out before we split this file into two (or three) separte method files 2022-06-27 10:37:16 +02:00
Trine Mykkeltvedt
14a5a37249 moved and renamed fluidsystems and parametercache in chifluid 2022-06-27 10:37:16 +02:00
Trine Mykkeltvedt
afad4d23ad moved the components to opm/material/components, and made subsequent changes for checking of the components 2022-06-27 10:37:16 +02:00
Trine Mykkeltvedt
7c4f2bdcc3 removed unused files and started removing julianame 2022-06-27 10:37:16 +02:00
Kai Bao
314f86d9de removing test_chiflash_scalar and test_chiflashspe5
they are not needed anymore.
2022-06-27 10:37:16 +02:00
Kai Bao
18c9ee7581 fixing the compilation of test_chiflash
one reason is some code does not compile with DUNE2.6. And DUNE2.6 is
still supported by OPM.
2022-06-27 10:37:16 +02:00
Trine Mykkeltvedt
00f831117a added Kais startup cleaning, no functionality change 2022-06-27 10:37:16 +02:00
Trine Mykkeltvedt
ce4201a030 made additional test with co2 and brine working, similar as juliacode 2022-06-27 10:37:16 +02:00
Trine Mykkeltvedt
c386469479 wip co2brine 2022-06-27 10:37:16 +02:00
Trine Mykkeltvedt
54f7e67dcb fixed the derivatives for the single phase case 2022-06-27 10:37:16 +02:00
Trine Mykkeltvedt
b0863ec492 wip coupling to opm-models compositionalflash 2022-06-27 10:37:16 +02:00
Trine Mykkeltvedt
a8e34880c8 updated the fluidState derivatives correctly to be used in intensivequantities 2022-06-27 10:37:16 +02:00
Trine Mykkeltvedt
d210614eab wip copling to opm-models 2022-06-27 10:37:16 +02:00
Trine Mykkeltvedt
7aa1675f8e changes to ChiFlash 2022-06-27 10:37:16 +02:00
Trine Mykkeltvedt
eed51f4d55 added new cubic solver from Svenns old branch, also made a phaseStabilityTestMichelsen_ with the same wrapping as julia code - this does not work with newton right now. BUT the fix of the roots makes the stabilitytest give similar K as Olavs Julia code. Will never be completely equal due to minimization through gibbs (not implemented in opm) which will different choize of roots 2022-06-27 10:37:16 +02:00
Trine Mykkeltvedt
16f7fb8e9d added Svenns cubic solver 2022-06-27 10:37:16 +02:00
Trine Mykkeltvedt
a003b6c35c WIP stabilitutest ++ 2022-06-27 10:37:16 +02:00
Trine Mykkeltvedt
783b5011db added Kais last to commits and took values to fluid_state 2022-06-27 10:37:16 +02:00
Trine Mykkeltvedt
83d4194876 fixed the derivatives in PengRobinsonMixture with a rewrite of a term to get pri_jac correct, also a getValue to get sec_jac equal, did rewriting and printing in ugly way jus t compare with Julia-code values 2022-06-27 10:37:16 +02:00
Trine Mykkeltvedt
756c68042d problems with how ideal gas constant R was defined on mac, David helped me fix it 2022-06-27 10:37:16 +02:00
Kai Bao
2d939a828f WIP in generating the secondary jacobian 2022-06-27 10:37:16 +02:00
Kai Bao
b3b7ded57d wip in updating the derivatives after the two phase solution
it will be a very draft way to do it first, hopefully the results are
okay.

Then looking for better refactorization.
2022-06-27 10:37:16 +02:00
Kai Bao
d78f1ac178 using different forms of flash equations have better convergence
it is the fugacity coefficient equations. It begins with bigger
residual, while converges faster.

origionally,
 newton residual is 24.7536
 newton residual is 11.0045
 newton residual is 5.2655
 newton residual is 2.4048
 newton residual is 0.995777
 newton residual is 0.331732
 newton residual is 0.0663179
 newton residual is 0.00393044
 newton residual is 1.84752e-05
 newton residual is 1.55499e-08
 newton residual is 1.67839e-11

new form,
 newton residual is 694053
 newton residual is 5950.39
 newton residual is 52.1553
 newton residual is 0.470124
 newton residual is 0.00430846
 newton residual is 3.91461e-05
 newton residual is 3.55269e-07
 newton residual is 4.00957e-09
2022-06-27 10:37:16 +02:00
Kai Bao
1ff22fc49d first version of the assembleNewton_ for flash calculation 2022-06-27 10:37:16 +02:00
Kai Bao
68d0801453 cleaning up a little bit. 2022-06-27 10:37:16 +02:00
Kai Bao
5f0fcad220 WIP in getting the derivatives correct after flash calculation 2022-06-27 10:37:16 +02:00
Kai Bao
c38f72e0d6 some refactoring for the Newton flash solver. 2022-06-27 10:37:16 +02:00
Kai Bao
4bbc37358b moving the two phase flash solver to its own function 2022-06-27 10:37:16 +02:00
Kai Bao
e44fb2363f the newton solver for ChiFlash look working
while we need more checking.
2022-06-27 10:37:16 +02:00
Kai Bao
8a41b0c531 WIP in finishing the newton solver.
commiting for saving.
2022-06-27 10:37:16 +02:00
Kai Bao
8c566096e2 making the types for LBCJulia more proper
We will need to handle AD type with this function.
2022-06-27 10:37:16 +02:00
Kai Bao
b73cf5a93a adding a LBC viscosity function translated from Julia code
to make sure we get the same viscosity
2022-06-27 10:37:16 +02:00
Kai Bao
6d8ef5e99f adding compressFactor to FluidStateCompositionModules 2022-06-27 10:37:16 +02:00
Kai Bao
20d6078504 bug fixes. 2022-06-27 10:37:16 +02:00
Kai Bao
e3864e1a90 making the test_chiflash based on AD 2022-06-27 10:37:16 +02:00
Kai Bao
20b93ee3bf small cleaning up. 2022-06-27 10:37:16 +02:00
Kai Bao
96c3462571 making test_chiflash_scalar to be CO2, C10, C1 test 2022-06-27 10:37:16 +02:00
Kai Bao
7c2694bba4 WIP in creating the julia three component system. 2022-06-27 10:37:16 +02:00
Kai Bao
3d9c344d84 further cleaning up 2022-06-27 10:37:16 +02:00
Kai Bao
054a768225 adding the CO2, C1, C10 component with exact Julia properties 2022-06-27 10:37:16 +02:00
Kai Bao
fe42b8a5b3 some cleaning up, no functionality change 2022-06-27 10:37:16 +02:00
Kai Bao
ad4d1bee4f removing the tempalte parameter Evaluation for ChiFlash 2022-06-27 10:37:16 +02:00
Kai Bao
0c9cffbd60 adding the spe5 using chiflash
to compile, you need to change the function name criticalMolarVolume to
criticalVolume in Spe5FluidSystem.

And the commented out code in PengRobinson.hpp looks like needed for
spe5 flash.
2022-06-27 10:37:16 +02:00
Kai Bao
2fb4676fee remvoing unused types for clarity. 2022-06-27 10:37:16 +02:00
hnil
22e79cd97a fixed it 2022-06-27 10:37:16 +02:00
hnil
1637633b21 added a scalar test 2022-06-27 10:37:16 +02:00
Kai Bao
6833b8e434 some small changes, not functionality change. 2022-06-27 10:37:16 +02:00
Kai Bao
df50b67ed3 compiled and running now. 2022-06-27 10:37:16 +02:00
Kai Bao
52f23ec882 using the same types from the co2-compositional
it compiles now. Not sure why the running is terminated due to NaN.
2022-06-27 10:37:16 +02:00
Kai Bao
a205ff502e continuing WIP for the test_chiflash
not compiled but reproducing the same compilation error with much
smaller code.
2022-06-27 10:37:16 +02:00
Kai Bao
fc38c68735 WIP to make the test_chiflash using TwoPhaseThreeComponentFluidSystem 2022-06-27 10:37:16 +02:00
Kai Bao
db5ab02dd2 incoporating K, L, twophaseflag to FluidStateCompositionModules
It was done by Norce in the co2-compositional branch.
It removes some compilation errors.
2022-06-27 10:37:16 +02:00
Atgeirr Flø Rasmussen
261bf56fab [WIP] Add ChiFlash and test. Not compiling. 2022-06-27 10:37:16 +02:00
Trine Mykkeltvedt
070bc5cb1c removed unused functions and did some renaming in PTFlash 2022-06-24 18:04:50 +02:00
Bård Skaflestad
013b279682 Apply Generalised ACTNUM Handling to All Grid Types
Commit eca858335 introduced a more comprehensive way of forming the
initial ACTNUM array used when constructing the EclipseGrid from a
corner-point description.  This commit applies that strategy to all
known grid types.  As an additional benefit this will also cover one
special case that was not handled and would effectively discard the
work done in the generalised initial ACTNUM construction.

Add unit tests to exercise the ACTNUM handling for other grid types.
2022-06-24 14:01:17 +02:00
Markus Blatt
f18ee95574 Merge pull request #3058 from bska/copy-defaulted-pvt-tables
Treat All-Defaulted PVTW Record as Copy of Previous
2022-06-24 13:54:14 +02:00
Bård Skaflestad
254b2e2862 Extract Common Base Class For Flat Tables With Record Copying
This commit introduces a new helper template class,

    FlatTableWithCopy<RecordType>

which wraps a vector<RecordType>, provides constructors from
DeckKeyword and initializer_list<RecordType> and handles copying
tables for all-defaulted records.

We reimplement the PVTW, DENSITY, and GRAVITY tables in terms of
this helper class to reduce duplication.  If the copy behaviour is
generally useful/needed we expect to replace the existing FlatTable
mechanism with the new helper.

Suggested by: Markus Blatt
2022-06-24 12:56:08 +02:00
Markus Blatt
b4eb8fbd4f OrderedMap: Remove template parameter for key type.
It is only used with std::string anyway.
2022-06-24 09:32:10 +02:00
Kai Bao
8fd9168dd1 adding includes files to test_components
But many components do not have the criticalVolume and acentricFactor
defined. So test_components does not compile.
2022-06-24 00:30:55 +02:00
Kai Bao
35321b9825 renaming ChiFlash to PTFlash 2022-06-23 23:55:37 +02:00
Kai Bao
0f8df5cca1 white space cleaning up
no functionality change.
2022-06-23 22:44:20 +02:00
Bård Skaflestad
d35abfddb6 Implement Defaulted Table Copy for DENSITY and GRAVITY
Use the same targeted strategy as for PVTW.
2022-06-23 16:04:50 +02:00
Bård Skaflestad
54ba23d71b Implement Defaulted Table Copy for PVTO and PVTG
The existing mechanism did not handle this case sufficiently well.
It is likely that we will have to polish this approach, but for now
use an explicit table copy to ensure that we have structurally
correct backing table data.
2022-06-23 16:04:50 +02:00
Bård Skaflestad
a066d2b95f Implement Defaulted Table Copy for PVDO and PVDG 2022-06-23 16:04:50 +02:00
Bård Skaflestad
433cc4d649 Treat All-Defaulted PVTW Record as Copy of Previous
A simulation model may choose to give PVTW data as

    PVTW
      1.0 1.0 1.0e-5 0.2 0.0 /
      /  -- record 2 (copied from record 1)

if, for instance, the oil and/or gas tables are different in regions
1 and 2, but the water is the same.  In this case we must properly
copy record 1 into record 2 and essentially recreate the table.

To this end, decouple the 'PvtwTable' from the 'FlatTable' machinery
and make the former into an independent type containing vector<>
instead of inheriting from vector<>.  Implement the default->copy
behaviour in the new PvtwTable::PvtwTable(const DeckKeyword&)
constructor.
2022-06-23 16:04:50 +02:00
Markus Blatt
00ace58e6c Merge pull request #3052 from bska/dont-assume-monotonic-wlist-position-on-restart
Don't Assume Increasing WLIST Position In Restart Files
2022-06-23 15:25:31 +02:00
Trine Mykkeltvedt
16c88d0a02 more peng robinson 2022-06-23 14:59:53 +02:00
Trine Mykkeltvedt
bf89f6747b Merge branch 'add-chi-flash-trine' of github.com:GitPaean/opm-material into add-chi-flash-trine 2022-06-23 14:55:50 +02:00
Trine Mykkeltvedt
fe08002ff5 more peng robinson stuff 2022-06-23 14:54:59 +02:00
Trine Mykkeltvedt
83504883b1 more cleaning in the PengRobinson files 2022-06-23 14:47:50 +02:00
Kai Bao
9a1a41be47 cleaning up FluidStateCompositionModules.hpp a little bit.
mostly removing the twophaselflag_, which is not used anywhere.

not functionality changes.
2022-06-23 14:45:45 +02:00
Trine Mykkeltvedt
bc63cec485 cleaned PengRobinson, uncommented the stuff about extrema in the case of one rott - I think it can just be as it was 2022-06-23 14:35:51 +02:00
Trine Mykkeltvedt
e8d9f6ca0f removed some printing in the polynomialsolver 2022-06-23 14:23:17 +02:00
Kai Bao
991e2f570f slightly cleaning up PengRobinsonMixture.hpp a little bit
there are some more trivial cleaning work remains.
2022-06-23 13:57:30 +02:00
Trine Mykkeltvedt
d57a398b6e cleaned up the viscositymodels, two choises availible: LBC and modified LBC 2022-06-23 11:25:53 +02:00
Bård Skaflestad
042830e860 Don't Assume Increasing WLIST Position In Restart Files
The well list positions for individual wells (i.e,, IWLS) need not,
and typically are not, strictly increasing in the restart files.
Therefore we must only 'resize()' the well name vectors if the
'well_order' is strictly larger than the current size.  Otherwise,
we lose information about which wells are in which well lists.
2022-06-23 10:38:23 +02:00
Atgeirr Flø Rasmussen
5495266115 Merge pull request #3056 from bska/extract-single-record-construction-helper
Extract Helper for Single Table Record Construction
2022-06-23 09:59:20 +02:00
Trine Mykkeltvedt
9e437f64fe moved the viscositymodels to a separate folder alongside the fluidsystem, in principle there are two viscositymodels: the standard LBC and the modified LBC. However, there might me some discrepancy between LBC and LBCjulia - this needs to be sorted out before we split this file into two (or three) separte method files 2022-06-23 09:22:26 +02:00
Bård Skaflestad
4d9387ee23 Extract Helper for Single Table Record Construction
Use case is table copy for PVTW.
2022-06-22 16:50:15 +02:00
Bård Skaflestad
531803eb0a Merge pull request #3061 from ElyesAhmed/alugrid
assert if Alugrid can be initialized from Deck: check format and geometry
2022-06-22 16:36:41 +02:00
Trine Mykkeltvedt
6b6990a7fc moved and renamed fluidsystems and parametercache in chifluid 2022-06-22 14:59:38 +02:00
Trine Mykkeltvedt
7de58ae532 moved the components to opm/material/components, and made subsequent changes for checking of the components 2022-06-22 14:35:55 +02:00
Atgeirr Flø Rasmussen
c07357cdc3 Merge pull request #3060 from bska/xeff-smry
Add Well and Group Level Efficiency Factor Summary Vectors
2022-06-22 13:26:51 +02:00
Bård Skaflestad
0a287ca914 Add Well and Group Level Efficiency Factor Summary Vectors
This commit adds support for the GEFF, WEFF, and WEFFG summary
vectors that report the efficiency factors at the well (WEFAC) and
group (GEFAC) levels.  WEFFG additionally accounts for efficiency
factors in a well's superior groups in the group tree.
2022-06-22 11:52:58 +02:00
Bård Skaflestad
7b31522fdd Merge pull request #3062 from blattms/import-error-fault
Improves error messages on faults when additional chars are used.
2022-06-22 11:48:00 +02:00
Bård Skaflestad
41d0b21463 Merge pull request #3055 from blattms/improve-error-region-op-multz
Improve error message for region operations on multz
2022-06-22 11:47:27 +02:00
Trine Mykkeltvedt
06de60a6fb removed unused files and started removing julianame 2022-06-22 11:36:47 +02:00
Markus Blatt
9e1aaca9e9 Improves error messages on faults when additional chars are used.
Faults are stored in an OrderedMap with the full string used during
construction even if that is longer than 8 characters. When later
these faults are e.g. modified whith MULTFLT using only the first 8
characters, the only message the user got was

```
An error occurred while creating the reservoir properties
Internal error: Key not found:

Unrecoverable errors while loading input: Key not found
```

With this patch we at least add some more context to the error
message:

```
Error:
An error occurred while creating the reservoir properties
Internal error: [/../EclipseState.cpp:362] Could not set fault transmissibility multiplier 5.23166e-10 for fault CFN2_05t: Key ABCD_05q not found. Similar entries are ABCD_05q_extended_width, UABCD_05q_extended_width.
```
2022-06-22 11:35:40 +02:00
Elyes Ahmed
04736dcbd0 removing methods for specific grid 2022-06-22 11:25:31 +02:00
Markus Blatt
6caebad329 Use OpmInputError instead of std::logic_error.
Message now becomes:
```
Error: Problem with keyword MULTIREG
In /path/to/file.inc line 3
region operation on 3D field MULTZ with global storage is not implemented!
```
2022-06-21 16:38:05 +02:00
Kai Bao
e91ea58286 removing test_chiflash_scalar and test_chiflashspe5
they are not needed anymore.
2022-06-21 15:56:02 +02:00
Kai Bao
530157c092 fixing the compilation of test_chiflash
one reason is some code does not compile with DUNE2.6. And DUNE2.6 is
still supported by OPM.
2022-06-21 15:53:25 +02:00
Markus Blatt
a4576d253d Add operation name to error. 2022-06-21 15:42:08 +02:00
Markus Blatt
8611f664cb Improve error message for region operations on MULTZ.
MULTZ is the only keyword that is stored in global representation
(i.e. with values for inactive cells, too) to allow the "PINCH ALL"
processing. This produced errors like:

```
Error:
An error occurred while creating the reservoir properties
Internal error: Region operations on 3D fields with global storage is
not implemented
```

With this change the error message has more information for the user
and might help to work around it:

```
Error:
An error occurred while creating the reservoir properties
Internal error: In file /path/to/file.inc line 3: MULTIREG region operation on 3D field MULTZ with global storage is not implemented!
```
2022-06-21 15:42:08 +02:00
Elyes Ahmed
d0a1101bc8 assert if Alugrid can initialized from Deck: check format and geometry 2022-06-21 14:49:13 +02:00
Bård Skaflestad
4d76351111 Merge pull request #3049 from atgeirr/fix-actnum-equals-manipulation
Fix ACTNUM manipulation with EQUALS
2022-06-21 09:59:33 +02:00
Atgeirr Flø Rasmussen
a97df7c889 Use BOOST_CHECK_EQUAL_COLLECTIONS. 2022-06-21 09:32:31 +02:00
Tor Harald Sandve
694fe3b85c Merge pull request #515 from totto82/fixExtrapolateDiff
Extrapolate gas diffusion in CO2 module
2022-06-21 09:10:24 +02:00
Bård Skaflestad
0d6dc717d3 Merge pull request #3059 from tskille/fix_esmry_load
Prevent data vector loading twice
2022-06-20 20:49:29 +02:00
Atgeirr Flø Rasmussen
02c06e9ae3 Add unit tests for new ACTNUM initialization features. 2022-06-20 17:57:25 +02:00
Atgeirr Flø Rasmussen
90d0b6479a Make new ACTNUM initialization unconditional, simplify. 2022-06-20 17:56:56 +02:00
Atgeirr Flø Rasmussen
0dab2aaf2b If no ACTNUM, default to all active in FieldProps. 2022-06-20 17:56:08 +02:00
Torbjørn Skille
f9bbf34b9a Prevent data vector loading twice
if same vector is defined twice in the vector list
2022-06-20 14:24:15 +02:00
Tor Harald Sandve
dba0fe19c5 Merge pull request #500 from plgbrts/JouleThomson
Adding Joule-Thomson effect in energy calculations
2022-06-20 11:04:15 +02:00
Tor Harald Sandve
f4118ed61d Extrapolate gas diffusion in CO2 module 2022-06-20 10:59:15 +02:00
Trine Mykkeltvedt
82c6bfe610 added Kais startup cleaning, no functionality change 2022-06-20 09:54:15 +02:00
Trine Mykkeltvedt
5b2845bf9a made additional test with co2 and brine working, similar as juliacode 2022-06-20 09:04:17 +02:00
Atgeirr Flø Rasmussen
e568d14a87 Future-proof checking for BOX-related keywords. 2022-06-17 13:02:42 +02:00
Atgeirr Flø Rasmussen
86fe7bbc3f Add moved header to public header list. 2022-06-17 13:02:42 +02:00
Atgeirr Flø Rasmussen
bc966fa32a Get actnum vector as it exists in FieldProps without modification. 2022-06-17 13:02:42 +02:00
Atgeirr Flø Rasmussen
eca8583358 Use new FieldProps constructor to get ACTNUM. 2022-06-17 13:02:42 +02:00
Atgeirr Flø Rasmussen
f5a2f6de74 Add new EclipseGrid contructor with no geometry or actnum info. 2022-06-17 13:02:42 +02:00
Atgeirr Flø Rasmussen
29954fd91f Add new constructor to only find correct ACTNUM. 2022-06-17 13:02:42 +02:00
Bård Skaflestad
194a599303 Merge pull request #3054 from hakonhagland/krnum
Fix typo in KRNUM json file
2022-06-17 12:52:04 +02:00
Håkon Hægland
7867bcb5fd Fix some more typos in keyword JSON files 2022-06-17 10:40:04 +02:00
Håkon Hægland
412a11d92f Fix typo in KRNUM json file 2022-06-16 23:36:23 +02:00
Tor Harald Sandve
fae7b5ccfc Merge pull request #2999 from totto82/rsrvinj
implement item 10 WCONINJE
2022-06-16 08:30:20 +02:00
Bård Skaflestad
dd528b74dd Merge pull request #3051 from Tongdongq/add-header-functional
Include header to compile with g++-8.4.0
2022-06-15 11:57:33 +02:00
Tong Dong Qiu
a058253ece Include header to compile with g++-8.4.0 2022-06-15 11:13:55 +02:00
Bård Skaflestad
d42d437e17 Merge pull request #3048 from goncalvesmachadoc/patch-6
Output FOE
2022-06-13 23:06:41 +02:00
Bård Skaflestad
f5b49a19fe Merge pull request #3047 from akva2/improve_error_logging_tableID
changed: pass table ID into SimpleTable constructors
2022-06-13 20:16:12 +02:00
Arne Morten Kvarving
0d1075daee changed: pass table ID into SimpleTable constructors
use this to improve logging in case of failure
2022-06-13 15:48:57 +02:00
Cintia Goncalves Machado
43dafbc995 Output FOE
Keyword is implemented, but missing in Summary.cpp. Small fix also to be pushed in opm-simulators.
2022-06-13 15:20:33 +02:00
Arne Morten Kvarving
e3f97e45d9 Merge pull request #3045 from akva2/improve_error_logging
Improve error logging
2022-06-13 15:11:02 +02:00
Paul Egberts
0168b7719f added Rvw argument for gas inverseFormationVolumeFactor function 2022-06-13 15:04:40 +02:00
Arne Morten Kvarving
050540525f changed: log keyword location when parsing a table failed 2022-06-13 14:59:05 +02:00
Markus Blatt
4a51cfb707 Merge pull request #3046 from akva2/janitoring
changed: use modern include file path
2022-06-13 14:26:10 +02:00
Trine Mykkeltvedt
4fd4fc7029 wip co2brine 2022-06-13 14:11:08 +02:00
Arne Morten Kvarving
3af1d464eb changed: avoid duplicating code 2022-06-13 13:30:33 +02:00
Arne Morten Kvarving
964f028413 changed: use modern include file path
to avoid deprecation warnings
2022-06-13 12:33:26 +02:00
Paul Egberts
dcc6eb2e0c modified density calculation to include oil vapor and dissolved gas 2022-06-13 11:39:11 +02:00
Paul Egberts
25adfda7d9 adjustments needed for new Joule-Thomson keywords 2022-06-13 11:39:11 +02:00
Paul Egberts
a2aa7b9603 adjusted internal energy calculation to include (optional) Joule-Thomson effect 2022-06-13 11:39:10 +02:00
Paul Egberts
a721fbba1f joule thomson 2022-06-13 11:39:10 +02:00
Bård Skaflestad
d032078634 Merge pull request #3044 from tskille/erft_api_change
API change for I/O classes ERft and ERst
2022-06-10 16:07:09 +02:00
Markus Blatt
b3eddb7061 Merge pull request #3040 from hakonhagland/python_nsp2
Make the Python `opm` package a namespace package
2022-06-10 15:01:07 +02:00
Torbjørn Skille
e778960932 API change of class ERft and ERst
ERft - return false (not throw an exception) if function hasArray( .. ) is used with an
non-existing rftreport.

ERst - new memeber function hasArray ( .. )
2022-06-10 14:27:48 +02:00
Håkon Hægland
046736e45d Make Python opm package a namespace package
Convert the Python opm package from a regular package to a namespace
package such that opm-simulators can contribute to the package from a
different filesystem path. In this way, the two packages opm.simulators
and opm.io (for example) can have a different parent filesystem path.
2022-06-10 09:02:19 +02:00
Markus Blatt
02167f2c2f Merge pull request #3041 from blattms/always-search-superlu
Make sure USE_SUPERLU is defined when calling FindSuperLU.cmake
2022-06-09 16:13:41 +02:00
Trine Mykkeltvedt
d26ea55ef8 fixed the derivatives for the single phase case 2022-06-09 15:10:39 +02:00
Markus Blatt
819a28a94d Make sure USE_SUPERLU is defined when calling FindSuperLU.cmake
Previously, touching CMakeLists.txt after a first compilation would
trigger compile errors as the two CMake runs were done with
inconsistent parameters (first one without USE_SUPERLU defined and
second one with -DUSE_SUPERLU=ON). Of course that meant that the
options would also differ from module to module, which seems like a
recipe for desaster.

This patch fixes this by moving the definition of the USE_SUPERLU
option to OpmInit.cmake which is included very early in the top most
CMakeLists.txt of each module.

Closes OPM/opm-simulators#3908
2022-06-09 12:26:56 +02:00
Trine Mykkeltvedt
150356a0e9 wip coupling to opm-models compositionalflash 2022-06-08 08:46:52 +02:00
Trine Mykkeltvedt
eb918ef3a5 updated the fluidState derivatives correctly to be used in intensivequantities 2022-06-08 08:46:52 +02:00
Trine Mykkeltvedt
ba9457e2f2 wip copling to opm-models 2022-06-08 08:46:52 +02:00
Trine Mykkeltvedt
26a78c9e38 changes to ChiFlash 2022-06-08 08:46:52 +02:00
Trine Mykkeltvedt
59a521d46d added new cubic solver from Svenns old branch, also made a phaseStabilityTestMichelsen_ with the same wrapping as julia code - this does not work with newton right now. BUT the fix of the roots makes the stabilitytest give similar K as Olavs Julia code. Will never be completely equal due to minimization through gibbs (not implemented in opm) which will different choize of roots 2022-06-08 08:46:52 +02:00
Trine Mykkeltvedt
f4e6b700a3 added Svenns cubic solver 2022-06-08 08:46:52 +02:00
Trine Mykkeltvedt
036923af1e WIP stabilitutest ++ 2022-06-08 08:46:52 +02:00
Trine Mykkeltvedt
06a9c9ea1c added Kais last to commits and took values to fluid_state 2022-06-08 08:46:52 +02:00
Trine Mykkeltvedt
03f5a39985 fixed the derivatives in PengRobinsonMixture with a rewrite of a term to get pri_jac correct, also a getValue to get sec_jac equal, did rewriting and printing in ugly way jus t compare with Julia-code values 2022-06-08 08:46:52 +02:00
Trine Mykkeltvedt
03685e5bf2 problems with how ideal gas constant R was defined on mac, David helped me fix it 2022-06-08 08:46:52 +02:00
Kai Bao
eee1f72482 WIP in generating the secondary jacobian 2022-06-08 08:46:52 +02:00
Kai Bao
851366ba50 wip in updating the derivatives after the two phase solution
it will be a very draft way to do it first, hopefully the results are
okay.

Then looking for better refactorization.
2022-06-08 08:46:52 +02:00
Kai Bao
76ad99e458 using different forms of flash equations have better convergence
it is the fugacity coefficient equations. It begins with bigger
residual, while converges faster.

origionally,
 newton residual is 24.7536
 newton residual is 11.0045
 newton residual is 5.2655
 newton residual is 2.4048
 newton residual is 0.995777
 newton residual is 0.331732
 newton residual is 0.0663179
 newton residual is 0.00393044
 newton residual is 1.84752e-05
 newton residual is 1.55499e-08
 newton residual is 1.67839e-11

new form,
 newton residual is 694053
 newton residual is 5950.39
 newton residual is 52.1553
 newton residual is 0.470124
 newton residual is 0.00430846
 newton residual is 3.91461e-05
 newton residual is 3.55269e-07
 newton residual is 4.00957e-09
2022-06-08 08:46:52 +02:00
Kai Bao
55145f8eaf first version of the assembleNewton_ for flash calculation 2022-06-08 08:46:52 +02:00
Kai Bao
e09cf63063 cleaning up a little bit. 2022-06-08 08:46:52 +02:00
Kai Bao
a216d61377 WIP in getting the derivatives correct after flash calculation 2022-06-08 08:46:52 +02:00
Kai Bao
3368256ecc some refactoring for the Newton flash solver. 2022-06-08 08:46:52 +02:00
Kai Bao
6066a8dfa7 moving the two phase flash solver to its own function 2022-06-08 08:46:52 +02:00
Kai Bao
082f9bd2fd the newton solver for ChiFlash look working
while we need more checking.
2022-06-08 08:46:52 +02:00
Kai Bao
bb31ccb8af WIP in finishing the newton solver.
commiting for saving.
2022-06-08 08:46:52 +02:00
Kai Bao
30c0ce7fac making the types for LBCJulia more proper
We will need to handle AD type with this function.
2022-06-08 08:46:52 +02:00
Kai Bao
bb86f443c7 adding a LBC viscosity function translated from Julia code
to make sure we get the same viscosity
2022-06-08 08:46:52 +02:00
Kai Bao
e33600e6b7 adding compressFactor to FluidStateCompositionModules 2022-06-08 08:46:52 +02:00
Kai Bao
ec7a73a118 bug fixes. 2022-06-08 08:46:52 +02:00
Kai Bao
8b9b155d2b making the test_chiflash based on AD 2022-06-08 08:46:52 +02:00
Kai Bao
109a249ad7 small cleaning up. 2022-06-08 08:46:52 +02:00
Kai Bao
ef9a9f9c7b making test_chiflash_scalar to be CO2, C10, C1 test 2022-06-08 08:46:52 +02:00
Kai Bao
61e2f5817d WIP in creating the julia three component system. 2022-06-08 08:46:52 +02:00
Kai Bao
e685864c1f further cleaning up 2022-06-08 08:46:52 +02:00
Kai Bao
a6b04e8cf0 adding the CO2, C1, C10 component with exact Julia properties 2022-06-08 08:46:52 +02:00
Kai Bao
185e02e40d some cleaning up, no functionality change 2022-06-08 08:46:52 +02:00
Kai Bao
280cd720db removing the tempalte parameter Evaluation for ChiFlash 2022-06-08 08:46:52 +02:00
Kai Bao
62b0a03203 adding the spe5 using chiflash
to compile, you need to change the function name criticalMolarVolume to
criticalVolume in Spe5FluidSystem.

And the commented out code in PengRobinson.hpp looks like needed for
spe5 flash.
2022-06-08 08:46:52 +02:00
Kai Bao
e6c029871f remvoing unused types for clarity. 2022-06-08 08:46:52 +02:00
hnil
71d7422756 fixed it 2022-06-08 08:46:52 +02:00
hnil
79603f2bfd added a scalar test 2022-06-08 08:46:52 +02:00
Kai Bao
6abcbf60e2 some small changes, not functionality change. 2022-06-08 08:46:52 +02:00
Kai Bao
e7da7cdad6 compiled and running now. 2022-06-08 08:46:52 +02:00
Kai Bao
c6064aa3e9 using the same types from the co2-compositional
it compiles now. Not sure why the running is terminated due to NaN.
2022-06-08 08:46:52 +02:00
Kai Bao
c4a708e500 continuing WIP for the test_chiflash
not compiled but reproducing the same compilation error with much
smaller code.
2022-06-08 08:46:52 +02:00
Kai Bao
e00be81c90 WIP to make the test_chiflash using TwoPhaseThreeComponentFluidSystem 2022-06-08 08:46:52 +02:00
Kai Bao
871bc77ca1 incoporating K, L, twophaseflag to FluidStateCompositionModules
It was done by Norce in the co2-compositional branch.
It removes some compilation errors.
2022-06-08 08:46:52 +02:00
Atgeirr Flø Rasmussen
7fa4f4796f [WIP] Add ChiFlash and test. Not compiling. 2022-06-08 08:46:52 +02:00
Markus Blatt
dbec8e4466 Merge pull request #3029 from plgbrts/new-jt-table
Joule-Thomson keywords for gas, oil and water phase
2022-06-07 13:17:06 +02:00
Markus Blatt
5a61625768 Merge pull request #3037 from hakonhagland/inst_pyt
WIP: Install the `install.py` script such that it can be reused by opm-simulators
2022-06-07 13:02:09 +02:00
Markus Blatt
3a5b17a070 Merge pull request #3039 from bska/rst-glo-compat
Increase Compatibility of GLO Restart Output
2022-06-07 11:53:31 +02:00
Bård Skaflestad
f6ca3ccaff Increase Compatibility of GLO Restart Output
We need to honour a "small rate threshold" when outputting the lift
gas max supply rate limit and total gas production limit.  This
threshold renders the output discontinuous, but is needed for
compatibility.
2022-06-06 21:18:47 +02:00
Bård Skaflestad
e6d8d59525 Merge pull request #3028 from tskille/esmry_updates
Esmry updates
2022-06-06 21:16:49 +02:00
Håkon Hægland
32c3d9bcb0 Add the python script directory to opm-project-config
Uses GNUInstallDIrs' CMAKE_INSTALL_DATAROOTDIR as top directory for
common python scripts. Also adds that location to
opm-project-config.cmake.in such that other opm modules can
easily lookup the common scripts
2022-06-03 09:03:34 +02:00
Torbjørn Skille
9a97d5c998 updated ExtESmry unit test
Loading summary vector from restart simulation with loadBaseRunData = true and selected summary vector not present in baserun.
Common use case where a new vector added in the restart run.
2022-06-02 19:46:37 +02:00
Torbjørn Skille
1433bc7a55 ExtESmry - support loading when number of time steps have increased (on disk)
The ESMRY file can be updated with more time step data in the time span between opening an ESMRY file
and loading actual summary data from the file. This can happen if the ESMRY is generated by an active
run. Length of summary vectors extracted will be equal to number of time steps on disk when the file was
first opened (with the constructor).
2022-06-02 19:44:20 +02:00
Torbjørn Skille
ab81083e02 Write temporary ESMRY file before renaming this to the actual file name
This increases the availability of the file for other processes. Duration for a
rename file operation is very short relative to writing a new file.
2022-06-02 14:10:17 +02:00
Torbjørn Skille
d34910c27d Minimum time interval between update of ESMRY file
The ESMRY file need a complete rewrite every time this is being updated.
This will makes the file more available for reading by other processes.
2022-06-02 14:10:14 +02:00
Atgeirr Flø Rasmussen
e1e0edba7d Merge pull request #3038 from bska/jfunc-require-endscale
Require ENDSCALE When JFUNC Entered
2022-06-01 08:54:28 +02:00
Bård Skaflestad
4333a69cd4 Require ENDSCALE When JFUNC Entered
We effectively ignore JFUNC data unless end-point scaling is
activated through the ENDSCALE keyword in the RUNSPEC section.
Alert the user to this fact by terminating the simulation run if the
case uses JFUNC without ENDSCALE present in RUNSPEC.  In this case,
issue a diagnostic message of the form

    Error: Unrecoverable errors while loading input: Problem with keyword JFUNC
    In CASE.DATA line 125
    Incompatible keyword combination: JFUNC declared, but ENDSCALE is missing.
2022-05-31 16:56:27 +02:00
Håkon Hægland
89b790d72f Install install.py
Install the install.py python script such that it can be used by
opm-simulators when building against an installed opm-common
2022-05-31 12:19:50 +02:00
Markus Blatt
d278880091 Merge pull request #3032 from bska/netbalan-rst-fixes
Increase Compatibility of NETBALAN Restart Output
2022-05-27 21:46:21 +02:00
Bård Skaflestad
8ff84920ed Increase Compatibility of NETBALAN Restart Output
The current Network::Balance class applies default values a little
too eagerly and this leads to problems for restarted simulation.  We
must take care to preserve the "did this item have a value" state
also in the restart file lest interactions with TUNING be lost
there.

To this end, make the minimum timestep size for network balancing be
an std::optional<> and use std::nullopt to represent "no value set"
in the input file.  While here, also preserve negative balancing
intervals exactly instead of replacing these values by zero.
2022-05-27 17:09:23 +02:00
Markus Blatt
378bd03eef Merge pull request #3033 from tskille/fix_esmry
ESmry and ExtESmry - Prevent loading data multiple times
2022-05-25 15:15:33 +02:00
Bård Skaflestad
fc98447a97 Merge pull request #497 from plgbrts/vapoilwat
Add PVT for combined wet (vaporized oil)  and humid (vaporized water) gas
2022-05-25 15:14:10 +02:00
Torbjørn Skille
607b8e7ebf ESmry and ExtESmry - Prevent loading data multiple times 2022-05-25 12:01:36 +02:00
Bård Skaflestad
4f181ec439 Merge pull request #3021 from bska/wecon-etc-restart-output
Identify Additional IWEL and SWEL Items
2022-05-25 10:54:35 +02:00
Bård Skaflestad
b4cebad6a9 Address Review Comments
In particular, add more unit testing and give names to a number of
index constants.

Thanks to [at]blattms for reviewing the initial version of this
patch.
2022-05-24 18:21:41 +02:00
Bård Skaflestad
188d7802a3 Temporarily Disable Higher-Level Water Injection Control
Instead, just declare that all non-FIELD groups are subject to
higher-level control of the water injection.

This hack is needed for compatibility on a real field case.  We must
revisit this at a later point.
2022-05-24 12:06:57 +02:00
Bård Skaflestad
adb84c15cc Emit Group Control Target of Zero if Explicitly Assigned
If a simulation model explicitly assigns a target or limit of 0.0,
then we must honour that value in the restart file.  Use a more
complete condition to detect whether or not group level targets or
limits are defaulted in GCONPROD and/or GCONINJE.
2022-05-24 12:06:57 +02:00
Bård Skaflestad
b36f415a96 Identify Additional IWEL and SWEL Items
In particular, add entries from WECON, WGRUPCON and, WVFPEXP and fix
an incorrect item attribution for the WTEST 'reason' parameter.

Thanks to [at]tskille for invaluable assistance in identify these
items.
2022-05-24 12:06:57 +02:00
Bård Skaflestad
67b7fe58b3 Don't Assert IWEL[24] == -1 Anymore
This setting is no longer magic.
2022-05-24 12:06:57 +02:00
Bård Skaflestad
6049b6e254 Expose First/Every Reporting
Needed for output to the restart file.
2022-05-24 12:06:57 +02:00
Bård Skaflestad
2aff28dd57 Merge pull request #3002 from bska/bxip-smry-values
Add Support for Block-Level Component-in-Place Summary Values
2022-05-24 12:04:23 +02:00
Bård Skaflestad
c5b9c8ea18 Add Support for Block-Level Component-in-Place Summary Values
This commit outputs the various BxIP* summary output values such as
BOIP (block-level oil-in-place) and BGIPL (block-level gas-in-place
in liquid phase).  While here, also add support for outputting the
block-level dissolved gas-oil-ratio (BRS) and vaporised
oil-gas-ratio (BRV).
2022-05-23 14:51:30 +02:00
Markus Blatt
82a5e7192e Merge pull request #3031 from hakonhagland/python_rates3
Adds a method get_injection_properties() to the Python interface to Opm::Schedule
2022-05-23 14:05:24 +02:00
Håkon Hægland
fa740678e0 Adds a method get_injection_properties()
Adds a method get_injection_properties() to the Python interface to
Opm::Schedule. This method can be used to get information about
Well::WellInjectionProperties for a given report step.

In order to avoid code duplication between opm-simulators and opm-common,
logic in CMakeLists.txt was refactored out into
cmake/Modules/PyInstallPrefix.cmake
2022-05-20 06:27:29 +02:00
Markus Blatt
acd90212d7 Merge pull request #3030 from blattms/bump-version-2022.10
Bump version to 2022.10-pre
2022-05-19 16:52:32 +02:00
Markus Blatt
a036273540 Bump version to 2022.10-pre 2022-05-19 16:46:35 +02:00
Markus Blatt
678114116f Merge pull request #3026 from bska/expose-raw-guiderate-phase
Provide Accessor for WGRUPCON's Raw Phase Value
2022-05-19 15:34:19 +02:00
Markus Blatt
180b7cb664 Merge pull request #3027 from bska/attribute-missing-kw-terminator
Attribute Missing Terminator to Keyword/File/Line
2022-05-19 15:32:44 +02:00
Paul Egberts
d11d7d6ca0 Joule-Thomson keywords for gas, oil and water 2022-05-18 16:16:57 +02:00
Bård Skaflestad
462457fb39 Attribute Missing Terminator to Keyword/File/Line
This will hopefully aid the user in resolving the underlying issue.
2022-05-10 22:01:21 +02:00
Bård Skaflestad
f7ea7674c0 Provide Accessor for WGRUPCON's Raw Phase Value
Needed for restart file compatibility.
2022-05-10 10:03:27 +02:00
Bård Skaflestad
c91bde8182 Merge pull request #3005 from bska/weltarg-uda
Save and Restore UDAs From WELTARG Keyword
2022-05-09 14:09:30 +02:00
Bård Skaflestad
0e2623d6dd List WCONPROD UDAs in Order of Increasing Enum Values
The entries for WRAT and GRAT were listed in reverse order.
2022-05-09 12:24:30 +02:00
Bård Skaflestad
b9e9112c6b Distinguish Well/Group Injection/Production UDA Controls
This avoids add-on logic at the call site to identify UDAs in
WELTARG keywords.

Suggested by: [at]atgeirr
2022-05-09 12:05:28 +02:00
Bård Skaflestad
b9eaa3a6aa Save and Restore UDAs From WELTARG Keyword
This commit hooks the WELTARG UDA support code up to the main path
for saving and reloading the IUAD/IUAP restart arrays.
2022-05-09 11:33:07 +02:00
Bård Skaflestad
f751c46f10 Count Active UDAs From WELTARG Keyword
This commit introduces a new overload of the updateUDQActive member
function of the WellInjectionProperties and WellProductionProperties
classes.  The new overload is specifically targeted at accounting
for any active UDAs in WELTARG records.  It is possible to have
"regular" UDAs introduced in WCONPROD/WCONINJE and also a separate
set of UDAs attributed to WELTARG at the same time so we need to be
able to distinguish the two cases.

Call the new overload from the WELTARG keyword handler.
2022-05-09 11:33:07 +02:00
Bård Skaflestad
14a6a5a4c3 Generate Units of Measurements for WELTARG UDAs
In preparation of loading such UDAs from the restart file.
2022-05-09 11:33:07 +02:00
Bård Skaflestad
25ede43bf7 Implement UDQ::*_control in Terms of UDQ::keyword
This replaces the cost of maintaining sets of switch/case statements
with some additional runtime cost of looking up the corresponding
keyword in a std::map<>, but these functions are not called in inner
loops so the extra cost is justified.
2022-05-09 11:33:07 +02:00
Bård Skaflestad
f4fde15e67 Support Recognizing UDAs in WELTARG Keyword
This commit extends the set of supported UDQ enumators to include
those of the WELTARG keyword.  This is in preparation of adding
restart file support for such cases.
2022-05-09 11:33:07 +02:00
Bård Skaflestad
f467ed7251 Identify More UDA Integer Values
In particular, identify UDA control codes for RESV, BHP, and THP in
WCONPROD as well as BHP and THP in WCONINJE.
2022-05-09 11:33:07 +02:00
Bård Skaflestad
d9ca1fe86f Increase Integer Literal Readability
Use C++14's digit separator character (single quote).
2022-05-09 11:33:07 +02:00
Atgeirr Flø Rasmussen
9a07a5d419 Merge pull request #3024 from atgeirr/use-invoke-result
Use std::invoke and friends instead of the deprecated std::result_of.
2022-05-09 11:31:11 +02:00
Atgeirr Flø Rasmussen
7e9e3e26eb Use std::invoke and friends instead of the deprecated std::result_of. 2022-05-09 10:26:29 +02:00
Markus Blatt
84ef4f6aa3 Merge pull request #3023 from blattms/skip-shared-libs
Do not hard-code shared-libs in package configuration if not needed.
2022-05-06 14:00:38 +02:00
Markus Blatt
cec7cffe7a Do not hard-code shared-libs in package configuration if not needed.
We usually list all libraries that might be needed for linking in the
CMake package configuration files. This is needed when building static
libraries as we do not yet use CMake targets (which would allow to
list them differently). As we are doing this unconditionally and
also including the ones listed in modules that we depend on, changing
a library (e.g. moving from Python 3.9 to 3.10) requires a complete
rebuild of all modules to get rid of the stale dependency on
libpython3.9.

At least when building shared libraries listing the dependencies is
not needed and this patch simply removes all shared libraries form the
list in the CMake package configuration file. Thus we only need to
recompile the modules that have direct dependency on a stale library.
2022-05-06 10:49:46 +02:00
Bård Skaflestad
9a51b6ec7c Merge pull request #3020 from hakonhagland/python_rates
Adds a `get_production_properties()` method to the Python interface to Opm::Schedule
2022-05-05 17:52:46 +02:00
Bård Skaflestad
d345098471 Merge pull request #3019 from blattms/better-actionx-udq-unsupported-message
Improve error message for unsupported categories for UDQ/ACTIONX
2022-05-05 17:23:03 +02:00
Håkon Hægland
d2c778739b Add trailing comma 2022-05-05 17:05:35 +02:00
Markus Blatt
68438e3f79 Improve error message for unsupported categories for UDQ/ACTIONX
We now print
"Keyword category 'Region' (e.g., summary keywords RPR) not supported
by ACTIONX."
instead of
"make_default_nodes does not yet support: RPR"
2022-05-05 15:43:44 +02:00
Håkon Hægland
d2cf59380e Use more compact std::map constructor 2022-05-05 13:58:04 +02:00
Håkon Hægland
dd19213998 Adds get_production_properties()
Adds get_production_properties() to the python interface to Schedule.
This method can be used to get information about
Well::WellProductionProperties for a given report step
2022-05-05 13:04:03 +02:00
Markus Blatt
267f642794 Merge pull request #3018 from totto82/fix_warning_satfunc
fix warning due to  missing else in satfuncs
2022-05-03 15:55:24 +02:00
Tor Harald Sandve
db929b509e fix warning due to missing else in satfuncs 2022-05-03 14:48:13 +02:00
Tor Harald Sandve
d8ed221390 Merge pull request #489 from osae/letRelperm
Saturation functions based on LET-curves.
2022-05-03 13:39:13 +02:00
Tor Harald Sandve
2b53a25ff6 Merge pull request #2917 from osae/LETkeywords
LET-based family-I saturation functions.
2022-05-03 13:37:47 +02:00
Bård Skaflestad
36ceeded74 Merge pull request #505 from totto82/fix_constant_rsrv
only remove duplicated points if there are more than two unique points
2022-05-02 11:04:55 +02:00
Bård Skaflestad
90a451c37d Merge pull request #3016 from goncalvesmachadoc/addBXPV
add Block Pore Volumes
2022-04-30 12:03:39 +02:00
Cintia Goncalves Machado
4f46615caa Delete unnecessary BXPV from required fields 2022-04-30 08:39:05 +02:00
goncalvesmachadoc
1d3cb8b2bb addBXPVs 2022-04-29 20:26:31 +02:00
Markus Blatt
5107d8c401 Merge pull request #3015 from blattms/install-python-bindings-by-default
Install python bindings as default.
2022-04-29 17:12:22 +02:00
Markus Blatt
51b73c1997 Install python bindings as default.
This is for consistency with opm-simulators, which (always)
installs them if they are built.

Closes #2976
2022-04-29 12:13:17 +02:00
Markus Blatt
aeb9ae8e1e Merge pull request #3012 from blattms/make-no-quadmath-just-a-warning
Make not finding Quadmath non-fatal (e.g. not available on arm64)
2022-04-29 11:20:35 +02:00
Markus Blatt
b8ab89591a Make not finding Quadmath non-fatal (e.g. not available on arm64)
Quadmath is usually unused except when a dependency uses it and
explicitly puts QuadMath::QuadMath into their CMake package
configuration file.

On most platforms the compiler has Quadmath available by
default. But on those that don't we should not stop CMake and fail.
Hence now we only print a message that Quadmath is not available.
2022-04-29 09:18:50 +02:00
Bård Skaflestad
612c156013 Merge pull request #2989 from plgbrts/vapoilwat
added vaporized_water rate type
2022-04-28 15:29:34 +02:00
Bård Skaflestad
7990d1571e Merge pull request #510 from blattms/fix-spelling
Fixes spelling (amount -> amount)
2022-04-27 23:22:48 +02:00
Markus Blatt
520a406228 Fixes spelling (amount -> amount) 2022-04-27 22:13:07 +02:00
Markus Blatt
ec7aadd511 Merge pull request #3007 from akva2/avoid_some_float_comps
fixed: avoid direct floating point comparisons in tests
2022-04-27 17:15:33 +02:00
Markus Blatt
410f2ecc34 Merge pull request #3008 from blattms/spelling-fix
Spelling fixes (valied -> valid).
2022-04-27 16:11:19 +02:00
Markus Blatt
7d66ff7c12 Spelling fixes (valied -> valid). 2022-04-27 14:08:53 +02:00
Bård Skaflestad
deffadd92e Merge pull request #3006 from lindjoha/complump_defaults
Added default values for I, J, K1 and K2 in COMPLUMP
2022-04-27 12:40:22 +02:00
Arne Morten Kvarving
4871f618bf fixed: avoid direct floating point comparisons in tests
we want to compare with an epsilon since these have gone
through calculations
2022-04-27 12:24:22 +02:00
Øyvind Lind-Johansen
dff5144d6a Added default values for I, J, K1 and K2 2022-04-27 10:23:29 +02:00
Markus Blatt
caefe67bb0 Merge pull request #507 from blattms/co2brinepvt-man
Added man page for co2brinepvt.
2022-04-26 17:23:54 +02:00
Ove Sævareid
10abd8efa2 Fixup. 2022-04-26 16:27:42 +02:00
Markus Blatt
a9595f80b3 Added man page for co2brinepvt. 2022-04-26 15:56:20 +02:00
Tor Harald Sandve
cb4ec94fcc only remove duplicated points if there are more than two unique points 2022-04-26 10:46:34 +02:00
Tor Harald Sandve
2eb49a451c Merge pull request #3003 from bska/fix-update-uda-weltarg
Update THP Target in Case of THP Control
2022-04-26 08:41:58 +02:00
Bård Skaflestad
bf259a5444 Update THP Target in Case of THP Control
Updating the BHP target appears to have been a copy-paste error.
2022-04-25 12:55:46 +02:00
Tor Harald Sandve
3f34913fb0 implement item 10 WCONINJE 2022-04-21 14:58:44 +02:00
Markus Blatt
3349bac28f Merge pull request #2997 from blattms/update-manpages
Cleanup, update and improve man pages for 2022.04
2022-04-21 11:27:29 +02:00
Markus Blatt
635aafa6f8 Merge pull request #2998 from akva2/jenkins_abs_refs
added: ability to use jenkins build scripts for release test building
2022-04-21 11:19:50 +02:00
Arne Morten Kvarving
9f332b87a4 added: ability to use jenkins build scripts for release test building
we need to be able to specify absolute refs to use for the repos
rather than a pull request number.
2022-04-21 09:51:43 +02:00
Markus Blatt
5dc5cd10b6 Cleanup, update and improve man pages for 2022.04 2022-04-20 22:09:17 +02:00
Markus Blatt
ecde5ebc8c Merge pull request #2995 from blattms/use-dune-buildsystem-defaults
Use dune buildsystem defaults for MPI SuperLU, and Quadmath
2022-04-20 19:43:09 +02:00
Markus Blatt
85837a71a5 Require UMFPack
A direct coarse solver of AMG is needed for good convergence and umfpack
was tested to work better than SuperLU previously. Hence we now require it.
2022-04-20 17:31:24 +02:00
Markus Blatt
2f726690e7 Always build with MPI and search for SuperLU and Quadmath.
Concerning MPI, both DUNE and OPM must be compiled with the
same default. For DUNE that is to used MPI if it is found.
With the previous default Cmake in opm-grid would fail for
DUNE 2.8

Even if SuperLU is found umfpack will be used as the coarse
solver for AMG. But if dune-fem is used  that will need SuperL
if it is on the system otherwise linking will fail for DUNE 2.8

Quadmath is used by dune-fem if it is found and linking of flow
will fail in this case for DUNE 2.8 if we did not search for it.
2022-04-20 17:31:23 +02:00
Ove Sævareid
fff89abd6b Sample let-curves for table output to INIT file. 2022-04-20 17:07:13 +02:00
Ove Sævareid
740beea44a Relocate kw defs. 2022-04-20 17:07:13 +02:00
Ove Sævareid
7496599d41 LET-based family-I saturation functions. New keywords SWOFLET and SGOFLET. 2022-04-20 17:07:13 +02:00
Atgeirr Flø Rasmussen
f0c272f180 Merge pull request #504 from totto82/setEnableDissolution
return rsSat = 0 when dissolution is disabled in co2module
2022-04-20 15:14:44 +02:00
Tor Harald Sandve
1dc3d9b711 return rsSat = 0 when dissolution is disabled 2022-04-20 09:58:21 +02:00
Bård Skaflestad
a5d19c4cf0 Merge pull request #2990 from totto82/rename_ext
rename extrapolate to explicit_lookup in vfpexp
2022-04-20 09:54:25 +02:00
Markus Blatt
1267a246e1 Merge pull request #499 from totto82/co2brinepvt_refPR
Co2brinepvt ref pr
2022-04-19 13:57:07 +02:00
Markus Blatt
1daaa303b0 Merge pull request #501 from goncalvesmachadoc/patch-4
[Release 2022.04] Fix bug WATDENT
2022-04-19 11:02:30 +02:00
Markus Blatt
54dda0b9ca Merge pull request #498 from totto82/co2brine_fix
Fix conversion from density to bo
2022-04-19 10:59:45 +02:00
Cintia Goncalves Machado
1720805f19 Fix division by zero in WATDENT implementation 2022-04-15 19:26:51 +02:00
Paul Egberts
405d435530 added water-gas ratio argument for co2brinepvt properties 2022-04-12 11:34:37 +02:00
Paul Egberts
9375ccd2ea fixed comment 2022-04-12 11:15:23 +02:00
Paul Egberts
7d66a1eef3 added water-gas ratio argument 2022-04-12 11:15:23 +02:00
Paul Egberts
2cc76c5c53 PVT for combined wet(vaporized oil) and humid (vaprized water) gas 2022-04-12 11:15:22 +02:00
Tor Harald Sandve
6130499031 adapt density computations to fix for invB 2022-04-12 10:08:31 +02:00
Tor Harald Sandve
3845e23ba3 Add prop B and diffusionCoefficient to co2brinepvt 2022-04-12 09:55:25 +02:00
Tor Harald Sandve
39712270b5 compute ref densities based on std conditions in co2/brine pvt modules 2022-04-12 09:55:25 +02:00
Tor Harald Sandve
9310f93eaf Fix conversion from density og bo 2022-04-12 09:37:09 +02:00
Tor Harald Sandve
09f80a3da1 rename extrapolate to explicit_loopup in vfpexp 2022-04-12 09:03:29 +02:00
Markus Blatt
d5b6152d6d Merge pull request #494 from totto82/co2brinepvt
add a simple program to access the pvt properties of co2 and brine
2022-04-10 11:08:18 +02:00
Paul Egberts
7956c2d7da added vaporized_water rate type 2022-04-08 21:07:45 +02:00
Ove Sævareid
9b770715ef Some LET related tests. 2022-04-08 11:46:33 +02:00
Ove Sævareid
d464c26e4a LET-based saturation functions. Run-time selection of LET vs tabulated functions. 2022-04-08 11:46:33 +02:00
Tor Harald Sandve
a85b6a3475 Merge pull request #491 from plgbrts/vapwat
Adding PVT for gas without oil-vapor (dry) and  with vaporized water (humid)
2022-04-05 11:33:19 +02:00
Paul Egberts
b50bf7ec22 cleanup 2022-04-04 14:34:16 +02:00
Tor Harald Sandve
38fae4b6de add some more comments 2022-04-04 14:17:47 +02:00
Paul Egberts
396ad6a3db fix of unused argument issue 2022-04-04 14:15:08 +02:00
Tor Harald Sandve
eb27f693bf add a simple interfase to access the pvt properties of co2 and brine 2022-04-01 15:52:24 +02:00
Markus Blatt
d9356d3351 Converted BrineCo2Pvt.hpp to UTF-8 2022-04-01 13:12:21 +02:00
Paul Egberts
70f55cf519 clean up 2022-03-06 17:34:53 +01:00
Paul Egberts
1a0cfe48cd gas density correction for humid gas 2022-03-06 17:26:04 +01:00
Paul Egberts
114e30540e add pvt for dry gas with vaporized water 2022-03-01 16:29:07 +01:00
Paul Egberts
31b08b4512 removed OPM_UNUSED 2022-01-20 11:36:28 +01:00
Tor Harald Sandve
4e76ab742d Merge pull request #490 from plgbrts/saltp
add getSaltSaturation
2022-01-18 12:02:07 +01:00
Paul Egberts
cbaa467104 add getSaltSaturation 2022-01-06 14:40:10 +01:00
Joakim Hove
aaec6ebd80 Merge pull request #487 from joakim-hove/repo-reor
Downstream of opm-common filesystem reorganisation
2022-01-03 10:38:14 +01:00
Joakim Hove
4b8f2f9814 Downstream of opm-common filesystem reorganisation 2022-01-02 14:32:39 +01:00
Atgeirr Flø Rasmussen
50bc945836 Merge pull request #488 from akva2/avoid_vector_shared_ptrs
changed: avoid long vectors of shared ptrs
2021-12-16 09:34:37 +01:00
Arne Morten Kvarving
441fd396ea drop shared_ptr for MaterialLawParameters 2021-12-14 13:49:59 +01:00
Arne Morten Kvarving
dcf4b382d1 fix bug: wrong twophase type passed
no consequence though as the parameter passed is unused,
but let's correct it nontheless
2021-12-14 13:48:20 +01:00
Arne Morten Kvarving
5e2af431b2 avoid shared_ptr for OilWaterScalingInfo 2021-12-14 13:37:27 +01:00
Arne Morten Kvarving
bce2e60133 remove unused member and unused typedefs 2021-12-14 13:29:18 +01:00
Arne Morten Kvarving
2a7084457a changed: avoid long vectors of shared ptrs
this use a lot of memory with many elements
2021-12-14 10:19:44 +01:00
Tor Harald Sandve
4a292455e0 Merge pull request #429 from goncalvesmachadoc/vapwat
Preparation for Water Evaporation and Salt Precipitation
2021-12-09 15:37:24 +01:00
Bård Skaflestad
ac2cc98b32 Merge pull request #486 from totto82/fixOilWaterF2
Fix oil water case SOF2 + SWFN
2021-11-26 14:50:00 +01:00
Tor Harald Sandve
df3973965c Fix oil water case SOF2 + SWFN 2021-11-26 12:33:02 +00:00
Joakim Hove
6013677105 Merge pull request #485 from joakim-hove/update-deck-get
Update deck access api
2021-11-23 14:58:13 +01:00
Joakim Hove
b1e889f619 Update deck access api 2021-11-18 15:12:30 +01:00
Markus Blatt
f62a448c4b Fixes spelling error in EclMaterialLawManager.hpp 2021-11-16 13:06:39 +01:00
Joakim Hove
06a7c51a27 Merge pull request #481 from joakim-hove/equil-debug
Explicitly check for a == b before creating scale_factor = a/b
2021-11-05 09:46:01 +01:00
Arne Morten Kvarving
90a925ff1a changed: avoid manual memory management 2021-11-04 15:33:35 +01:00
Joakim Hove
3e623d4182 Explicitly check for a == b before creating scale_factor = a/b 2021-11-02 16:18:36 +01:00
Arne Morten Kvarving
26a4a38579 Merge pull request #480 from akva2/use_python3
changed: use python3
2021-10-27 08:32:50 +02:00
Arne Morten Kvarving
93543e5f7d changed: use python3 2021-10-27 07:23:24 +02:00
Markus Blatt
cdf32d7b23 Merge pull request #478 from totto82/add_extrapolate
extrapolate in calulateMoleFraction for CO2STORE
2021-10-20 15:27:04 +02:00
Tor Harald Sandve
977c1801cf extrapolate in calulateMoleFraction for CO2STORE 2021-10-20 10:09:17 +02:00
Markus Blatt
b915c359e6 Merge pull request #477 from totto82/extrapolate_binaryCoefficients
extrapolate binary coefficients for co2brine
2021-10-19 19:48:38 +02:00
Tor Harald Sandve
bb8ae243b1 extrapolate binary coefficients for co2brine 2021-10-18 08:50:14 +02:00
Markus Blatt
03c0890b4a Merge pull request #476 from totto82/extrapolate_co2store
extrapolate co2, brine and h2O properties only when called via CO2STORE  module
2021-10-14 14:03:58 +02:00
Tor Harald Sandve
588604ae8f extrapolate co2, brine and h2O properties only when called from the CO2STORE module 2021-10-14 12:01:07 +02:00
Tor Harald Sandve
1171817349 Merge pull request #474 from totto82/brinethermal
allow for brine + thermal
2021-10-08 10:38:06 +02:00
Tor Harald Sandve
334482196d allow for brine and thermal 2021-10-07 14:53:20 +02:00
Cintia Goncalves Machado
7484caa42c Change name to enableSaltPrecipitation 2021-09-29 11:29:39 +02:00
Tor Harald Sandve
f8647c2ced Merge pull request #473 from blattms/hardcode-extrapolation-co2
Use extrapolation for unreasonable/untabulated values for CO2 sequestration cases.
2021-09-29 08:42:04 +02:00
Markus Blatt
dd1bb73472 Fixed old type extend -> extent 2021-09-28 17:07:25 +02:00
Markus Blatt
868531e414 Extrapolate for values not in domain (UniformTabulated2DFunction/liquidDensity).
Extrapolate liquidDensity for unreasonable
pressure/temperature (Brine) and in UniformTabulated2DFunction.
In the current code the interpolation actually already works if the
values are outside of the tabulated region.

With this change there is now an additional function parameter
If it is true we will interpolate for every value instead of throwing
and aborting (was the case always before).
2021-09-28 16:34:42 +02:00
Tor Harald Sandve
99a67af32c Merge pull request #471 from totto82/fixOilPvtMult
make oilReferenceDensity const
2021-09-20 08:21:45 +02:00
Tor Harald Sandve
4306c593c1 make oilReferenceDensity const 2021-09-17 14:45:45 +02:00
Markus Blatt
1978121580 Merge pull request #468 from akva2/drop_unused_macro
changed: get rid of OPM_UNUSED macro usage
2021-08-18 16:27:13 +02:00
Cintia Goncalves Machado
599c55b9a7 preparation for water evaporation and salt precipitatio 2021-08-04 22:31:51 +02:00
Tor Harald Sandve
f127b5b162 Merge pull request #466 from plgbrts/gaswater5
fixed use of wrong saturations for gas relperm for gas-water system
2021-08-03 11:59:00 +02:00
Arne Morten Kvarving
24dba01e99 changed: get rid of OPM_UNUSED macro usage
prefer anonymous parameters and c++17 [[maybe_unused]]
2021-08-03 09:32:02 +02:00
Paul Egberts
76c759ee17 fixed use of wrong saturations for gas relperm for gas-water system 2021-07-14 13:22:43 +02:00
Bård Skaflestad
0eb0d51186 Merge pull request #463 from akva2/janitoring
Some janitoring
2021-06-21 15:36:57 +02:00
Arne Morten Kvarving
d397cb0429 fix some issues in pvt classes
comparison operators were broken by 15ff65ffcd
2021-06-21 13:00:01 +02:00
Arne Morten Kvarving
25321c5558 fixed: remove unused variable 2021-06-21 12:59:54 +02:00
Arne Morten Kvarving
b2776b00e0 fixed: move header guard on top of file
tools expect it to be the first thing
2021-06-21 12:59:13 +02:00
Bård Skaflestad
9ae03c4095 Merge pull request #462 from akva2/janitoring
fixed: do not assert conditions guaranteed by unsigned
2021-06-18 16:56:01 +02:00
Arne Morten Kvarving
50c8cbea78 fixed: do not assert conditions guaranteed by unsigned 2021-06-18 13:24:02 +02:00
Bård Skaflestad
4ac1eab2cd Merge pull request #461 from akva2/janitoring
Some janitoring
2021-06-09 10:36:45 +02:00
Arne Morten Kvarving
1a75bd9ab4 avoid signed/unsigned comparison warnings 2021-06-09 08:30:39 +02:00
Arne Morten Kvarving
69970a0602 add missing includes 2021-06-09 08:30:01 +02:00
Bård Skaflestad
8960609e04 Merge pull request #460 from akva2/missing_includes
fixed: add missing includes
2021-05-25 20:49:35 +02:00
Arne Morten Kvarving
07af818a5e fixed: add missing includes 2021-05-25 11:44:53 +02:00
Bård Skaflestad
29e8f523de Merge pull request #459 from akva2/no_opm_in_opm_part_2
fixed: do not use Opm:: prefix within Opm namespace part 2
2021-05-07 21:39:24 +02:00
Arne Morten Kvarving
6689e6d08f fixed: do not use Opm:: prefix within Opm namespace part 2
have to use anchoring to root namespace in some places due
to overlapping namespace and class type names.
2021-05-05 21:58:33 +02:00
Arne Morten Kvarving
9e8d48f1d2 remove unused typedefs
they cause conflicts with templates in Opm namespace.
2021-05-05 21:53:12 +02:00
Arne Morten Kvarving
7241acabac changed: make enums enum class
and put them outside class defintion to avoid template
parameter dependence.
2021-05-05 21:44:13 +02:00
Bård Skaflestad
3e26468453 Merge pull request #458 from akva2/no_opm_in_opm
fixed: do not use Opm:: prefix when inside namespace Opm
2021-05-05 14:15:53 +02:00
Arne Morten Kvarving
13f0659d71 fixed: do not use Opm:: prefix when inside namespace Opm 2021-05-05 09:46:32 +02:00
Bård Skaflestad
e97f4d49f8 Merge pull request #455 from akva2/include_deck
fixed: need to include Deck.hpp in test
2021-04-26 14:19:36 +02:00
Arne Morten Kvarving
8cdc05caf0 fixed: need to include Deck.hpp in test 2021-04-26 12:04:35 +02:00
Bård Skaflestad
e706b69cad Merge pull request #451 from osae/fix2pIndex
Correcting phase index.
2021-04-08 15:11:52 +02:00
Ove Sævareid
f4b5fe48da Correcting phase index. 2021-04-08 12:14:25 +02:00
Bård Skaflestad
92f430cd1d Merge pull request #450 from joakim-hove/ep-value
Use value objects for endpoint scaling
2021-04-07 17:24:40 +02:00
Joakim Hove
6979b62754 Use value objects for endpoint scaling 2021-04-07 10:09:43 +02:00
Tor Harald Sandve
819d8379ed Merge pull request #446 from bska/eval-2p-krox
Expose Two-Phase Oil Relperm As Individual Operation
2021-04-06 08:49:52 +02:00
Bård Skaflestad
ab386e0074 Expose Two-Phase Oil Relperm As Individual Operation
This commit adds new operations

    relpermOilInOilGasSystem(params, fluidState)
    relpermOilInOilWaterSystem(params, fluidState)

to the Ecl*Material implementations.  The primary objective is to
support calculating the KROG and KROW quantities separately for
summary output purposes (keywords BKROG, BKROW).  Reimplement the
'krn' operation in terms of these new functions.

At present, these operations are supported only for three-phase
simulation runs.
2021-03-22 13:00:26 +01:00
Bård Skaflestad
af5f93c6f9 Merge pull request #447 from plgbrts/gaswater
Adaptations neededed for gas-water system
2021-03-22 12:59:36 +01:00
Atgeirr Flø Rasmussen
3218ae4286 Merge pull request #445 from bska/prevent-neg-kro-stone2
Explicitly Prevent Negative 3-p Kro Values in Stone 2 Model
2021-03-22 11:27:56 +01:00
Paul Egberts
d2d86e250b added throw when wrong saturation family is specified 2021-03-22 09:59:21 +01:00
Paul Egberts
fc2524a57a fix to allow running a one-phase system 2021-03-19 10:18:04 +01:00
Paul Egberts
eea578a0ef small clean up 2021-03-16 10:21:37 +01:00
Paul Egberts
249983c52a fix to avoid reading gaswater parameters if oil is present 2021-03-11 16:07:53 +01:00
Paul Egberts
809c1d3f1b fix of the wrong number of template arguments error in test_fluidmatrixintercations.cpp 2021-03-11 16:07:53 +01:00
Paul Egberts
ace2930603 use of normalizeKrValues() to account for TOLCRIT 2021-03-11 16:07:52 +01:00
Paul Egberts
b2ce73012e Adaptations neededed for gas-water system 2021-03-11 16:07:52 +01:00
Bård Skaflestad
1479adf6af Explicitly Prevent Negative 3-p Kro Values in Stone 2 Model
This makes the material balance equations converge more smoothly in
corner cases and makes a real field case run at all.
2021-02-23 09:17:13 +01:00
Tor Harald Sandve
372bb122a6 Merge pull request #448 from totto82/addExtrapolationThermalVisc
Extrapolate oil viscosity temperature factor for undersaturated case
2021-02-23 08:52:01 +01:00
Tor Harald Sandve
ea03ba8287 Extrapolate oil viscosity temperatuer factor for undersaturated case 2021-02-22 15:31:13 +01:00
Bård Skaflestad
c7317befa7 Merge pull request #443 from totto82/blackoilDiff
Add support for diffusion in the blackoil fluid system
2021-02-18 18:05:15 +01:00
Tor Harald Sandve
ac4a3871ef Add expression that return diffusion coefficient based on temperature, pressure and salinity
Diffusion coefficient of CO2 in pure water according to (McLachlan and Danckwerts, 1972)
Diffusion coefficient of CO2 in the brine phase modified following (Ratcliff and Holdcroft,1963 and Al-Rawajfeh, 2004)
2021-02-12 12:18:07 +01:00
Tor Harald Sandve
f9552a2081 fix assert statement 2021-02-04 09:44:56 +01:00
Tor Harald Sandve
e55568a646 dont allow for default molar weight in DIFFC table 2021-02-04 09:44:56 +01:00
Tor Harald Sandve
f406ecd914 fix molar weights 2021-02-04 09:44:56 +01:00
Tor Harald Sandve
570ec20598 init diffusion from deck 2021-02-04 09:44:56 +01:00
Tor Harald Sandve
ceb71c53a2 Add diffusion to blackoil fluidsystem. Diffusion coefficients are only implemented for the CO2-Brine system 2021-02-04 09:44:56 +01:00
Bård Skaflestad
d10786a18c Merge pull request #439 from bska/vscale-disp-sat-general
Implement Three-Point Vertical Scaling for Non-Wetting Phase Relative Permeability
2021-01-27 21:27:47 +01:00
Bård Skaflestad
a56df026be Implement Three-Point Vertical Scaling for Krn
This commit implements the vertical scaling mode activated by the
keywords KRORW, KRORG, and KRGR.  This is the same scaling mode as
the KRWR feature implemented, but requires reversing the logic since
we implement the non-wetting phase's relative permeability function
in terms of the wetting phase's saturation.
2021-01-27 18:34:24 +01:00
Bård Skaflestad
2f07358322 Honour TOLCRIT for Tabulated Relative Permeability
This commit ensures that we honour TOLCRIT settings when
constructing the internal representations of tabulated relative
permeability functions.  In particular, relative permeability values
less than or equal to TOLCRIT are treated as zero.
2021-01-27 18:34:24 +01:00
Bård Skaflestad
a5a45e4020 Merge pull request #438 from bska/fix-famI-sogcr
Fix Family I SOGCR Endpoint Hack
2021-01-27 18:29:57 +01:00
Bård Skaflestad
c390e356f3 Fix Family I SOGCR Endpoint Hack
The maximum attainable oil saturation in the G/O system is 1-SWL.
Update call sites accordingly.
2021-01-25 20:37:54 +01:00
Bård Skaflestad
247ce0e3fa Mark Objects 'const' Where Possible
Also, don't use lifetime extension for 'Evaluation' objects where
these are constructed inside functions.  Doing so inhibits NRVO.
2021-01-25 20:37:54 +01:00
Tor Harald Sandve
f8f1bfc341 Merge pull request #444 from totto82/addInternalEnergy3
add missing internal energy function in CO2-Brine module
2021-01-25 14:12:00 +01:00
Tor Harald Sandve
61d262684d add missing internal energy function in CO2-Brine module 2021-01-21 15:11:10 +01:00
Bård Skaflestad
d0bc4a2c05 Merge pull request #442 from totto82/co2outofidx
fix out of bound in CO2.hpp

Closes #441.
2021-01-19 12:39:04 +01:00
Tor Harald Sandve
f528b2c33f fix out of bound in CO2.hpp 2021-01-18 10:12:30 +01:00
Bård Skaflestad
292ee5174a Merge pull request #436 from bska/vscale-disp-sat
Implement KRWR Vertical Scaling
2021-01-14 14:15:46 +01:00
Bård Skaflestad
5a30a49e53 Implement KRWR Vertical Scaling
This commit adds support for scaling of the relative permeability
value for water at the residual saturation of the displacing
(non-wetting) phase.  We use pure vertical scaling in the left
interval [SWL, SR], and a linear/affine function in the right
interval [SR, SWU].
2021-01-13 15:38:34 +01:00
Bård Skaflestad
d1ccb8fcee Capture Three-Point Vertical Scaling Properties
These scale relative permeability function values at the residual
saturation of the displacing phase.
2021-01-13 15:38:34 +01:00
Bård Skaflestad
bb191a5381 Always Store Three Saturation End-Points
The two-point scalings will use [0] and [2] instead of [0] and [1].
This is in preparation of introducing 'KRWR' scaling which does not
necessarily require the alternative scaling method ('SCALECRS') for
the horizontal direction.
2021-01-13 15:38:34 +01:00
Atgeirr Flø Rasmussen
bc70036de5 Merge pull request #440 from totto82/fixIdxSalinity
fix the index into salinity in the BrineCo2Pvt model
2021-01-13 15:01:54 +01:00
Tor Harald Sandve
474d8c72c5 fix the index into salinity in the BrineCo2Pvt model 2021-01-13 12:35:04 +01:00
Joakim Hove
f4cb4dc292 Merge pull request #437 from joakim-hove/sched-oilvap
Get OilVaporization properties from ScheduleState
2021-01-08 09:21:36 +01:00
Joakim Hove
a431e8ba7f Get OilVaporization properties from ScheduleState 2021-01-07 09:20:19 +01:00
Bård Skaflestad
3db77dd5f9 Merge pull request #434 from bska/use-common-eps-api
Extract Endpoints Using Common Facilities
2021-01-05 11:52:52 +01:00
Bård Skaflestad
51e2efd431 Get Saturation Function Family From SatFuncControls
There's no need to duplicate this logic.
2020-12-21 00:51:36 +01:00
Bård Skaflestad
15c84cc3fc Extract Endpoints Using Common Facilities
This means we get the "SWCO" handling in SOGCR based on SGOF for
free, and also removes duplicated and complex logic.
2020-12-21 00:51:36 +01:00
Bård Skaflestad
fb5bdc1302 EPS Grid Properties: Prefer Single Assignments 2020-12-11 12:11:14 +01:00
Atgeirr Flø Rasmussen
ce4cbafe95 Merge pull request #435 from akva2/test_init
Change static intialization of CO2 tables to avoid function call, use construction.
2020-12-11 07:34:52 +01:00
Arne Morten Kvarving
75b2609336 test if apple clang likes this better 2020-12-08 15:27:50 +01:00
Atgeirr Flø Rasmussen
e58a660235 Merge pull request #432 from goncalvesmachadoc/aquifer
Do not check for kr curves for water single-phase
2020-12-01 08:38:02 +01:00
Cintia Goncalves Machado
5513bff1ba generalize single-phase fix 2020-11-25 17:48:45 +01:00
Cintia Goncalves Machado
1d4dd874ca do not check for kr curves for flow_onephase 2020-11-24 17:38:12 +01:00
Arne Morten Kvarving
2e7b1e4339 Merge pull request #430 from akva2/janitoring
fix header guard
2020-10-05 12:46:15 +02:00
Arne Morten Kvarving
d3a226166f fix header guard 2020-10-05 11:04:48 +02:00
Tor Harald Sandve
28dd5a2b36 Merge pull request #427 from totto82/co2pvt
Add a co2brine pvt model
2020-10-02 12:26:19 +02:00
Tor Harald Sandve
15ff65ffcd Add a co2brine pvt model
The CO2BRINE model is activated by setting CO2STOR in the RUNSPEC section

The CO2 and brine pvt properties are computed based on pvt models in opm-material
- CO2 density is from Span and Wager (1996) as given in co2table.inc
- CO2 viscosity is from Fenhour et al (1998)
- Brine density and viscosity is based on H20 + correction based on Batzle and Wang (1992)
- H20 density is from Hu et al (2007)
- H20 viscosity is computed from density based on correlation given in IAPWS 97

At the current stage the oil-phase is used to model the brine. If a proper gas-water
simulator is made, the Brine PVT should be moved to the water phase.

Known limitations:
- Currently the viscosity of the Brine does not depend on the composition
- Salinity is assumed to be constant and given by SALINITY [mol/kg].
2020-10-01 16:15:39 +02:00
Joakim Hove
e54ff1af09 Merge pull request #428 from joakim-hove/remove-common-exceptions
Remove unusued #include common excpetions
2020-09-21 14:27:34 +02:00
Joakim Hove
1315acfe51 Remove unusued #include common excpetions 2020-09-21 10:56:05 +02:00
Bård Skaflestad
a068071f88 Merge pull request #425 from goncalvesmachadoc/patch-3
Extrapolate GASVISCT
2020-08-22 00:12:38 +02:00
Bård Skaflestad
d846c7128a Merge pull request #424 from goncalvesmachadoc/patch-2
Extrapolate OILVISCT
2020-08-22 00:10:44 +02:00
Cintia Goncalves Machado
d4f6ed4366 Extrapolate GASVISCT
Allow for extrapolation of gas viscosity curves.
2020-08-06 17:26:14 +02:00
Cintia Goncalves Machado
2ac7f84b9f Extrapolate OILVISCT
Allow for extrapolation of oil viscosity curves
2020-08-06 17:20:58 +02:00
Bård Skaflestad
50bd881199 Merge pull request #423 from totto82/applyPVTWsalt
make the water PVT salt dependent
2020-07-08 09:28:53 +02:00
Tor Harald Sandve
74a6b98b4f fix return type getSaltConcentration 2020-07-08 08:09:26 +02:00
Tor Harald Sandve
b4c8dd5e86 make the water PVT salt dependent 2020-07-02 13:42:58 +02:00
Atgeirr Flø Rasmussen
a11b3a53b2 Merge pull request #422 from goncalvesmachadoc/patch-1
Allow for extrapolation of WATVISC curve
2020-06-26 09:55:30 +02:00
Cintia Goncalves Machado
50f0f36156 Allow for extrapolation of WATVISC curve 2020-06-25 14:25:26 +02:00
Atgeirr Flø Rasmussen
1a9c3c30ca Merge pull request #421 from atgeirr/sequential
Add total saturation and capillary pressure to blackoil fluid state.
2020-06-11 11:18:50 +02:00
hnil
efb7dce342 Add total saturation and capillary pressure to blackoil fluid state.
This is intended for use with sequential formulations.
2020-06-11 08:51:55 +02:00
Atgeirr Flø Rasmussen
1f9c136f20 Merge pull request #420 from atgeirr/add-phaseIsActive
Add phaseIsActive(unsigned int) to base fluid system (returning true).
2020-05-29 16:31:59 +02:00
Atgeirr Flø Rasmussen
b5bd0a519f Add phaseIsActive(unsigned int) to base fluid system (returning true).
This promotes the feature from being a special function for the black oil
fluid system to being in theory available for all. The need for this
arose in downstream code.
2020-05-29 14:49:59 +02:00
Joakim Hove
12161d9c79 Merge pull request #417 from bska/fix-missing-include
Grid Properties: Include FieldPropsManager
2020-04-07 11:49:41 +02:00
Bård Skaflestad
f343e605ea Grid Properties: Include FieldPropsManager
We use the manager internally (for instance in the try_get() helper
function) and therefore need a declaration in scope.
2020-04-06 17:30:19 +02:00
Joakim Hove
30cbe6ed25 Merge pull request #415 from joakim-hove/use-shared-ptr
Use std::shared_ptr for Python handle
2020-03-31 16:50:47 +02:00
Joakim Hove
68e779a827 Use std::shared_ptr for Python handle 2020-03-31 10:46:17 +02:00
Joakim Hove
0defd3de8e Merge pull request #414 from joakim-hove/add-python-arg
Add Python arg to Schedule constructor
2020-03-27 13:43:55 +01:00
Joakim Hove
b68bdea6e4 Add Python arg to Schedule constructor 2020-03-25 18:32:46 +01:00
Bård Skaflestad
778459ec84 Merge pull request #413 from akva2/followup_stonetype
use relocated KrModel
2020-03-10 07:58:17 -05:00
Arne Morten Kvarving
51e5574c07 use relocated KrModel 2020-03-10 10:40:09 +01:00
Atgeirr Flø Rasmussen
a003a21d5c Merge pull request #412 from akva2/no_serialization_matman
Get rid of deck usage setting up MaterialLawManager
2020-03-09 16:05:40 +01:00
Arne Morten Kvarving
91d4dcdf90 remove serialization templates from EclMaterialLawManager 2020-03-09 11:42:37 +01:00
Arne Morten Kvarving
a2d52da69f rename EclMaterialLawManager::initFromDeck to initFromState
no deck usage any more
2020-03-09 11:42:37 +01:00
Arne Morten Kvarving
c85243314b get rid of deck usage setting up EclEpsScalingPointsInfo 2020-03-09 10:28:02 +01:00
Arne Morten Kvarving
477f2cd425 get rid of deck usage setting up EclEpsConfig 2020-03-09 10:28:02 +01:00
Arne Morten Kvarving
8d07bef17c get rid of deck usage setting up three phase options 2020-03-09 10:10:32 +01:00
Arne Morten Kvarving
e0a43d7973 use hysteresis config from state 2020-03-09 09:33:08 +01:00
Arne Morten Kvarving
5f2d7c6308 use STONE1EX from table manager 2020-03-06 12:17:21 +01:00
Bård Skaflestad
861a6ad4b4 Merge pull request #411 from akva2/no_serialization_fluidsystem
Get rid of deck usage in BlackoilFluidSystem
2020-03-03 21:27:04 -06:00
Arne Morten Kvarving
36d9df1876 drop serialization templates for BlackoilFluidSystem 2020-03-03 15:57:58 +01:00
Arne Morten Kvarving
51d644b96c changed: get rid of last deck usage in BlackoilFluidSystem
rename initFromDeck to initFromState. Pass the Schedule instead
of the deck.
2020-03-03 15:57:58 +01:00
Arne Morten Kvarving
43232d878f Merge pull request #409 from akva2/less_deck_blackoil_fluid_system
changed: lessen deck usage setting up BlackoilFluidSystem
2020-03-03 15:57:05 +01:00
Arne Morten Kvarving
2c270cb4f3 changed: lessen deck usage setting up BlackoilFluidSystem 2020-03-03 15:56:33 +01:00
Arne Morten Kvarving
24e84ad2e5 Merge pull request #410 from akva2/use_state_surface_conditions
use surface conditions from InitConfig
2020-03-03 13:46:14 +01:00
Arne Morten Kvarving
3dc71ffb5b use standard conditions from EclipseState 2020-03-03 12:03:48 +01:00
Markus Blatt
fb803f1fec Merge pull request #408 from akva2/use_compressed_props
Use compressed field properties
2020-03-02 09:46:16 +01:00
Arne Morten Kvarving
ac9207cba1 use compressed field properties in EclThermalLawManager 2020-02-28 13:07:03 +01:00
Arne Morten Kvarving
efdb6a4dfc use compressed field properties in EclMaterialLawManager 2020-02-28 13:07:03 +01:00
Arne Morten Kvarving
7f749723e5 Merge pull request #406 from akva2/sdensity_from_manager
changed: use solvent density from table manager
2020-02-27 13:37:36 +01:00
Bård Skaflestad
cecce4ddd2 Merge pull request #407 from akva2/less_deck_usage
changed: lessen deck usage in pvt setup
2020-02-26 09:48:45 -06:00
Arne Morten Kvarving
b76a809e04 changed: lessen deck usage in pvt setup 2020-02-26 15:33:08 +01:00
Arne Morten Kvarving
988f1b9577 changed: use solvent density from table manager 2020-02-26 13:31:29 +01:00
Joakim Hove
86e12ae598 Merge pull request #404 from joakim-hove/use-DenT
Use dent
2020-02-26 09:56:09 +01:00
Bård Skaflestad
29b46efea8 Merge pull request #405 from akva2/fix_heatcr_indices
fixed: wrong indices setting up HeatCr
2020-02-25 08:57:16 -06:00
Arne Morten Kvarving
2ba7c31e5a fixed: wrong indices setting up HeatCr 2020-02-25 14:38:04 +01:00
Joakim Hove
1bbc8f2315 Use Tables::gas_comp_index() 2020-02-25 08:03:17 +01:00
Joakim Hove
de9dd579b6 Use DenT instances for temperature dependent density 2020-02-25 06:49:56 +01:00
Bård Skaflestad
d4ee80c358 Merge pull request #403 from akva2/avoid_deck_usage
changed: void more deck usage setting up pvt classes
2020-02-24 11:09:34 -06:00
Bård Skaflestad
14286eca07 Merge pull request #402 from akva2/use_array
changed: use std::array instead of C arrays
2020-02-24 08:16:24 -06:00
Arne Morten Kvarving
723c619b5e changed: void more deck usage setting up pvt classes 2020-02-24 13:41:48 +01:00
Arne Morten Kvarving
2f838a4268 Merge pull request #391 from akva2/noecl_avoid_global
changed: avoid allocating long vectors of zeros
2020-02-24 13:13:27 +01:00
Arne Morten Kvarving
aa0725e519 changed: use std::array instead of C arrays 2020-02-24 09:56:03 +01:00
Tor Harald Sandve
517ce64f58 Merge pull request #392 from akva2/cleanup_brine
some cleanups in ConstantCompressibilityBrinePvt
2020-02-17 14:13:55 +01:00
Atgeirr Flø Rasmussen
89dd68d1e7 Merge pull request #398 from atgeirr/fix-warning
Silence unused variable warning.
2020-02-13 12:59:10 +01:00
Atgeirr Flø Rasmussen
6dfe5c7ac9 Silence unused variable warning. 2020-02-13 09:18:01 +01:00
Atgeirr Flø Rasmussen
ee5011a61d Merge pull request #397 from akva2/use_numeric_limits
fixed: use std::numeric_limits<Scalar> in one more spot
2020-02-11 08:06:13 +01:00
Arne Morten Kvarving
0668699179 fixed: use std::numeric_limits<Scalar> in one more spot 2020-02-10 15:57:25 +01:00
Arne Morten Kvarving
5f36812707 get rid of deck usage setting up GasPvtMultiplexer 2020-02-07 10:11:44 +01:00
Arne Morten Kvarving
6524ed889a use PvtwTable from TableManager setting up ConstantCompressibilityWaterPvt 2020-02-07 10:11:44 +01:00
Arne Morten Kvarving
6d8f5f50bf changed: use PVCDO from TableManager setting up ConstantCompressibilityOilPvt 2020-02-07 10:11:44 +01:00
Arne Morten Kvarving
c681d0a402 Merge pull request #393 from akva2/no_density_kw
changed: avoid using DENSITY from deck in Pvt classes
2020-02-06 18:14:39 +01:00
Arne Morten Kvarving
ed99a1df1a changed: avoid using DENSITY from deck in Pvt classes 2020-02-06 12:12:09 +01:00
Arne Morten Kvarving
9a7eac1874 some cleanups in ConstantCompressibilityBrinePvt 2020-02-06 10:33:00 +01:00
Arne Morten Kvarving
1c71722179 changed: avoid allocating long vectors of zeros 2020-01-29 16:45:12 +01:00
Bård Skaflestad
ff5c8eea84 Merge pull request #390 from akva2/thermal_fixes
Thermal fixes
2020-01-29 13:26:36 +01:00
Arne Morten Kvarving
75c9726d96 remove unused parameters from private member functions
they can be re-added if they are needed. keep it simple
2020-01-29 08:48:39 +01:00
Arne Morten Kvarving
8909d471e8 disable assert
this triggers while running a thermal deck (SPE1CASE2_THERMAL),
but there is no apparent reason why it is an error.
2020-01-29 08:48:39 +01:00
Arne Morten Kvarving
370923a186 fix operators after brine addition 2020-01-29 08:48:39 +01:00
Arne Morten Kvarving
328bb9c427 add missing initializers
does not really do harm, but quells warnings from valgrind
when serializing the class
2020-01-29 08:48:39 +01:00
Arne Morten Kvarving
81ccf49424 changed: rename initFromDeck to initParamsForElements
there is no deck dependent code now
2020-01-29 08:48:39 +01:00
Arne Morten Kvarving
e96c7d9cbc changed: check for SPECROCK in tables instead of checking deck for keyword 2020-01-29 08:42:16 +01:00
Arne Morten Kvarving
31d5347d73 Merge pull request #389 from akva2/hide_fprops_ifaces
don't use templated get and has interface from fieldpropsmanager
2020-01-28 15:34:02 +01:00
Arne Morten Kvarving
1cd88d27d7 don't use templated get and has interface from fieldpropsmanager
it is now private
2020-01-27 15:32:32 +01:00
Markus Blatt
3be6b7de6e Merge pull request #388 from bska/fix-oob-indexing
Don't Index Out of Bounds
2020-01-25 17:21:42 +01:00
Bård Skaflestad
2f827bfae5 Don't Index Out of Bounds
The phaseIsActive_ array has size numPhases.  We must not form the
expression phaseIsActive_[numPhases].  Switch to using fill_n in
place of fill lest we have to write

    fill(&phaseIsActive_[0], &phaseIsActive_[0] + numPhases, v)
2020-01-24 20:44:26 +01:00
Joakim Hove
f36d181279 Merge pull request #387 from akva2/noecl_flush_matman
MPI serialization support for MaterialLawManager
2020-01-22 15:09:38 +01:00
Arne Morten Kvarving
73b9e32d88 add mpi serialization for EclMaterialLawManager 2020-01-22 11:26:45 +01:00
Arne Morten Kvarving
ee17c70ade add mpi serialization for EclHysteresisConfig 2020-01-22 11:26:45 +01:00
Arne Morten Kvarving
e58d8675ee add serialization support for EclEpsConfig 2020-01-22 11:26:45 +01:00
Arne Morten Kvarving
908b2d1aa6 add equality operator to EclEpsScalingPointsInfo 2020-01-22 11:26:45 +01:00
Joakim Hove
2f53cb9616 Merge pull request #386 from akva2/fix_enums
fixed: enum member in EclMultiplexerApproach clashes with EclTwoPhaseApproach enum
2020-01-21 14:49:55 +01:00
Arne Morten Kvarving
93df3fa6d5 fixed: enum member in EclMultiplexerApproach clashes with EclTwoPhaseApproach enum
fix by converting both to enum class
2020-01-21 13:22:00 +01:00
Bård Skaflestad
1b5206200c Merge pull request #384 from akva2/reorganize_matlaw
Reorganize EclMaterialLawManager
2020-01-21 12:57:26 +01:00
Arne Morten Kvarving
9af6f1fe4d changed: do not call initParamsForElements in initFromDeck 2020-01-21 11:32:57 +01:00
Arne Morten Kvarving
14eff62913 changed: make initParamsForElements public 2020-01-21 11:32:57 +01:00
Arne Morten Kvarving
fcf113509e remove unnecessary parameters
these are class members. no need to pass them as parameters
2020-01-21 11:32:57 +01:00
Arne Morten Kvarving
064930de95 EclMaterialLawManager: reorganize to better separate deck and deck-independent code
in the process some of the config vars are moved to members
2020-01-21 11:32:56 +01:00
Arne Morten Kvarving
5cfd584e89 changed: put the phase active status in member vars
and chase the deck usages it eliminates. to prepare for
parallel setup without deck access
2020-01-21 11:32:14 +01:00
Bård Skaflestad
fe5760beb4 Merge pull request #383 from akva2/add_blackoil_serialization
Add serialization support for BlackoilFluidSystem
2020-01-21 10:41:32 +01:00
Arne Morten Kvarving
20b5f5f4bf changed: store stone etas in a member
thus we avoid deck usage in initThreePhaseParams_
2020-01-20 14:59:59 +01:00
Joakim Hove
c68202eada Merge pull request #382 from joakim-hove/remove-eclipse3d
Remove #include GridProperty.hpp
2020-01-20 11:35:14 +01:00
Arne Morten Kvarving
44d81819f6 add serialization support for BlackoilFluidSystem 2020-01-20 11:16:19 +01:00
Arne Morten Kvarving
e2841d943c use std::array instead of C array
motivation: simpler serialization
2020-01-20 11:16:14 +01:00
Joakim Hove
429d008eb6 Remove #include GridProperty.hpp 2020-01-20 08:42:00 +01:00
Joakim Hove
028e53e7d7 Merge pull request #380 from joakim-hove/only-active-cells
Use FieldProps implementation for 3D properties
2020-01-13 15:47:22 +01:00
Joakim Hove
ce989e6a64 Use FieldPropsManager unconditionally 2020-01-11 07:01:07 +01:00
Joakim Hove
a2d728724d Merge pull request #381 from totto82/trinemykk-smartwater
Trinemykk smartwater
2020-01-11 06:50:36 +01:00
Tor Harald Sandve
fdfe8cbbb2 allow constructing ConstCompressibilityBrinePvt from data
also add accessors and equality operator
    and adapt multiplexer to brine
2020-01-09 11:04:18 +01:00
Trine S. Mykkeltvedt
36eda7f17e renamed saltwater-->brine and fixed other things commented in review 2020-01-07 09:30:08 +01:00
Trine S. Mykkeltvedt
1841b05b16 implemented simple salt/brine option 2020-01-07 09:30:08 +01:00
Bård Skaflestad
8d5d8ad26c Merge pull request #379 from akva2/noecl_flush
More serialization preparation
2019-12-19 17:42:13 +01:00
Arne Morten Kvarving
4606f7e752 allow constructing WaterPvtThermal from data
also add accessors, assignment operator and equality operator
2019-12-19 14:21:40 +01:00
Arne Morten Kvarving
c1b55c4364 allow constructing WaterPvtMultiplexer from data
also add accessors, assignment operator and equality operator
2019-12-19 14:19:40 +01:00
Arne Morten Kvarving
125ab46c71 allow constructing ConstCompressibilityWaterPvt from data
also add accessors and equality operator
2019-12-19 14:19:01 +01:00
Arne Morten Kvarving
9966756ef1 allow constructing OilPvtThermal from data
also add accessors and equality operator
2019-12-19 14:18:01 +01:00
Arne Morten Kvarving
0d53ec6e3f allow constructing OilPvtMultiplexer from data
also add accessors, assignment operator and equality operator
2019-12-19 14:14:58 +01:00
Arne Morten Kvarving
788ec7eb6a allow constructing LiveOilPvt from data
also add accessors and equality operator
2019-12-19 14:14:58 +01:00
Arne Morten Kvarving
b3b22c8021 allow constructing DeadOilPvt from data
also add accessors and equality operator
2019-12-19 14:14:13 +01:00
Arne Morten Kvarving
d21edaff6a allow constructing ConstCompressOilPvt from data
also add accessors and equality operator
2019-12-19 14:12:08 +01:00
Bård Skaflestad
d63c127d52 Merge pull request #378 from akva2/noecl_flush
Serialization preparation
2019-12-19 13:57:58 +01:00
Arne Morten Kvarving
e9e495295a allow constructing GasPvtThermal from data
also add accessors, assignment operator and equality operator
2019-12-19 12:02:40 +01:00
Arne Morten Kvarving
bd03a9a30e allow constructing GasPvtMultiplexer from data
also add accessors, assignment operator and equality operator
2019-12-19 12:02:40 +01:00
Arne Morten Kvarving
a23f6998ea allow constructing WetGasPvt from data
also add accessors and equality operator
2019-12-19 10:57:03 +01:00
Joakim Hove
477360ca75 Merge pull request #377 from joakim-hove/use-vector-value
Use std::vector<T> and check for .empty() instead of pointer
2019-12-19 10:53:54 +01:00
Arne Morten Kvarving
059c6b58aa add accessors and equality operator to Uniform(X)Tabulated2DFunction 2019-12-19 10:45:05 +01:00
Arne Morten Kvarving
0a73e4531e allow DryGasPvt to be constructed from variables
also add accesors and equality operator
2019-12-19 10:33:20 +01:00
Arne Morten Kvarving
52d310760b add accessors and equality operator to IntervalTabulated2DFunction 2019-12-19 10:32:47 +01:00
Arne Morten Kvarving
5757ccd237 allow SolventPvt to be constructed from variables
also add accesors and equality operator
2019-12-19 10:29:05 +01:00
Arne Morten Kvarving
5a23d7ffca add accessors and equality operator to Tabulated1DFunction 2019-12-19 10:27:50 +01:00
Joakim Hove
2740e89b13 Use std::vector<T> and check for .empty() instead of pointer 2019-12-18 15:26:08 +01:00
Joakim Hove
f85e9754a3 Merge pull request #376 from joakim-hove/thermal-cond
Thermal cond
2019-12-16 12:10:43 +01:00
Joakim Hove
a9d70c223c Default initialize thermal keywords with numerical 0 2019-12-16 09:13:12 +01:00
Joakim Hove
0448e902b4 Use get_global for thermal properties 2019-12-16 08:32:23 +01:00
Joakim Hove
a668794a3b Merge pull request #375 from joakim-hove/only-active-cells
Use temporary global properties when accesing FieldPropsManager
2019-12-14 15:13:36 +01:00
Joakim Hove
751f3b5091 Use temporary global properties when accessing FieldPropsManager 2019-12-14 12:53:03 +01:00
Joakim Hove
ce0f902777 Merge pull request #374 from akva2/janitoring
remove unused variable
2019-12-07 13:36:36 +01:00
Joakim Hove
4b3b64c88c Merge pull request #373 from joakim-hove/ecleps-config-fp
Ecleps config fp
2019-12-07 12:08:02 +01:00
Joakim Hove
7feb96014c FieldPropsManager in EclThermal 2019-12-07 09:57:48 +01:00
Joakim Hove
6b21e51fa2 Enable FieldPropsManager in EclEpsGridProperties 2019-12-07 09:57:48 +01:00
Arne Morten Kvarving
0445dc3ddb remove unused variable 2019-12-06 23:35:12 +01:00
Joakim Hove
9c3763d02f Remove unused function 2019-12-05 19:49:58 +01:00
Joakim Hove
7fc692ec62 Move variable into correct #ifdef block 2019-12-05 19:36:35 +01:00
Joakim Hove
4792cc63ec Enable FieldPropsManager in EclEpsConfig 2019-12-05 19:35:06 +01:00
Joakim Hove
6f047e4360 Moved code-lines around to prepare for FieldPropsManager 2019-12-05 19:33:02 +01:00
Joakim Hove
2282e439e2 Merge pull request #370 from joakim-hove/fp-double
Fp double
2019-11-29 16:53:33 +01:00
Joakim Hove
95b514f660 Merge pull request #371 from joakim-hove/add-PORO
Add PORO to testdata
2019-11-29 12:46:51 +01:00
Joakim Hove
ba798c5c22 Add PORO to testdata 2019-11-29 11:19:04 +01:00
Joakim Hove
8c2c7d2fdc Enable 3DProps testing for thermal properties 2019-11-28 16:58:13 +01:00
Joakim Hove
c6a2017e8d Grouping lines of code 2019-11-28 16:52:47 +01:00
Tor Harald Sandve
f6beba2caa Merge pull request #369 from joakim-hove/use-fp
Use FieldPropsManager to get SATNUM vector
2019-11-28 09:07:55 +01:00
Joakim Hove
2ac41b75ca Use FieldPropsManager to get SATNUM vector 2019-11-27 17:55:29 +01:00
Joakim Hove
589e55d30d Merge pull request #368 from joakim-hove/pull-out-of-loop
Extract creation of EclEpsGridProperties out of loop
2019-11-27 17:02:15 +01:00
Joakim Hove
da16a4ef42 Extract creation of EclEpsGridProperties out of loop 2019-11-27 15:07:40 +01:00
Joakim Hove
1427042583 Merge pull request #365 from joakim-hove/use-active-vectors
Use active vectors
2019-11-26 20:46:24 +01:00
Joakim Hove
c991993d7f Store and use only active cells in EclEpsGridProperties 2019-11-26 19:38:31 +01:00
Joakim Hove
0f04b8ef69 Wrap all EclEpsGridProperties members behind public get 2019-11-21 11:32:49 +01:00
Joakim Hove
c97d39cb35 Use constructor for EclEpsGridProperties 2019-11-21 11:32:49 +01:00
Joakim Hove
d8db34f3f7 Extract EclEpsGridProperties class to separate file 2019-11-21 11:32:49 +01:00
Joakim Hove
343f2faa52 Merge pull request #360 from joakim-hove/deckitem-size-rename
Rename DeckItem::size -> DeckItem::data_size
2019-11-19 20:39:54 +01:00
Joakim Hove
7d0d4c4712 Rename DeckItem::size -> DeckItem::data_size 2019-11-16 16:45:17 +01:00
Atgeirr Flø Rasmussen
d0af89eca1 Merge pull request #348 from atgeirr/silence-warning
Silence unused argument warning for DynamicEvaluation.
2019-07-05 11:15:47 +02:00
Atgeirr Flø Rasmussen
a9e1551e79 Silence unused argument warning for DynamicEvaluation. 2019-07-05 10:09:23 +02:00
Andreas Lauser
45207e1e7a Merge pull request #347 from akva2/add_unused_mpi
added: OPM_UNUSED_NOMPI
2019-06-28 14:38:13 +02:00
Arne Morten Kvarving
8c2cb50569 added: OPM_UNUSED_NOMPI
for suppressing unused variable warnings when a variable
is unused if compiled without MPI
2019-06-28 13:49:13 +02:00
Atgeirr Flø Rasmussen
56491a2e90 Merge pull request #346 from akva2/janitoring
mark unused parameter OPM_UNUSED
2019-06-26 15:11:56 +02:00
Arne Morten Kvarving
615538bac2 mark unused parameter OPM_UNUSED 2019-06-26 13:59:59 +02:00
Atgeirr Flø Rasmussen
f496d62cbf Merge pull request #345 from akva2/janitoring
anonymize unused parameters
2019-06-26 12:53:40 +02:00
Arne Morten Kvarving
51bf76a061 mark unused parameters as OPM_UNUSED 2019-06-26 10:55:33 +02:00
Atgeirr Flø Rasmussen
02f7359570 Merge pull request #343 from akva2/janitoring
quell unhandled value in switch warning
2019-06-19 10:06:48 +02:00
Arne Morten Kvarving
cd6eb3cc38 quell unhandled value in switch warning 2019-06-19 08:48:46 +02:00
Andreas Lauser
961ddcbd37 Merge pull request #342 from atgeirr/enable-onefase
Enable onephase
2019-06-18 17:34:03 +02:00
hnil
f2711be107 Small changes to try to make onephase work 2019-06-18 14:47:59 +02:00
Atgeirr Flø Rasmussen
6cfd9b5740 Merge pull request #340 from andlaus/unify_eval_creation
unify the creation of evalutions
2019-06-14 09:16:29 +02:00
Atgeirr Flø Rasmussen
609c88e4d4 Merge pull request #339 from GitPaean/creating_zero_one_constant
adding createConstantOne and createConstantZero to Evaluations
2019-06-13 14:41:15 +02:00
Andreas Lauser
819ee5bbf2 Evaluation code generator: add a missing OPM_UNUSED
thanks to [at]GitPaean for the catch!
2019-06-12 15:10:17 +02:00
Andreas Lauser
663a5bcc2b Merge pull request #2 from GitPaean/andlaus-unify_eval_creation
fixing the compilation problem related to DenseAD
2019-06-12 15:01:51 +02:00
Kai Bao
292e84ec08 fixing the compilation problem related to DenseAD 2019-06-12 14:53:54 +02:00
Andreas Lauser
3b933ae42a unify the creation of evalutions
to create a constant, there are now always the three functions

Opm::constant<Eval>(value);
Opm::constant<Eval>(numDeriv, value);
Opm::constant<Eval>(x, value); // with 'x' being the 'template' of the returned value

If a given call does not make sense, an exception is thrown:

- Plain floating point objects like `float`, `double` or `quad`
  complain if the specified number of derivatives is not zero.
- Statically sized evaluations throw if the specified number of
  derivatives of passed to the function is not equal to their static
  size.
- Dynamically sized evaluations complain if the number of derivatives
  cannot be determined.

The third variant of `Opm::constant()` works unconditionally. The
`Opm::variable()` helpers are modified analogously.
2019-06-12 11:50:37 +02:00
Kai Bao
0c005595c4 adding createConstantOne and createConstantZero to Evaluations 2019-06-11 09:48:44 +02:00
Andreas Lauser
d5df7ab935 Merge pull request #337 from totto82/log10
Add log10 AD function
2019-06-03 13:45:33 +02:00
Tor Harald Sandve
a62ea4b0f1 Add log10 AD function 2019-06-03 11:22:42 +02:00
Tor Harald Sandve
c1d66b3699 Merge pull request #332 from andlaus/fix_max_oil_sat
black oil PVT: make the maximum oil saturation a evaluation
2019-05-07 10:19:38 +02:00
Andreas Lauser
14351c5794 black oil PVT: make the maximum oil saturation a evaluation
the maximum oil saturation *can* depend on the most current solution,
so it needs to include derivatives. Note that this fix should not
change the converged solution, only the convergence behaviour, i.e.,
if changes in the results are encountered, these are likely only
numerical noise.
2019-05-03 14:30:30 +02:00
Andreas Lauser
438653d0b5 UniformXTabulated2DFunction: minor cleanups 2019-05-03 14:30:30 +02:00
Atgeirr Flø Rasmussen
77c963167f Merge pull request #328 from atgeirr/interpolation_2d_miscibility_fix
Interpolation 2d miscibility fix
2019-04-02 08:20:02 +02:00
Atgeirr Flø Rasmussen
f8d11efe82 Added explanatory comments about the use of 'shift'. 2019-04-01 14:08:18 +02:00
Atgeirr Flø Rasmussen
322c6fb0ff Address review issues. 2019-03-29 11:48:35 +01:00
Andreas Lauser
e51ea63933 Merge pull request #330 from andlaus/maintainance
add missing <vector> include
2019-03-26 15:51:07 +01:00
Andreas Lauser
523ee1007a add missing <vector> include 2019-03-26 13:10:18 +01:00
Atgeirr Flø Rasmussen
215af283e2 Stop interpolating between unsaturated/saturated regions.
This is possible since the new interpolation ensures continuity
up to the boundary between the regions.
2019-03-22 14:18:48 +01:00
hnil
5399d72477 Change 2D interpolation of live oil and wet gas.
Interpolation is now done parallel to the saturated/unsaturated boundary lines,
instead of axis-aligned.
2019-03-22 14:08:28 +01:00
Andreas Lauser
3b9c8e190f Merge pull request #327 from GitPaean/improving_dynamic_evaluation
Improving dynamic evaluation
2019-03-22 10:00:13 +01:00
Kai Bao
6fe8e1c74f adding a few more tests for DynamicEvaluation in test_densead 2019-03-22 08:51:16 +01:00
Kai Bao
a1396bb237 Doxygen documents for FastSmallVector 2019-03-21 21:56:28 +01:00
Kai Bao
0ce7a779da updating genEvalSpecializations.py 2019-03-21 13:16:49 +01:00
Kai Bao
bf4bf1aa1f adding staticSize to the template parameters for Evaluation and DynamicEvaluation 2019-03-21 11:51:45 +01:00
Kai Bao
36905ccefc Merge pull request #1 from andlaus/fix_FastSmallVector
clean up the new FastSmallVector class
2019-03-20 12:58:24 +01:00
Andreas Lauser
1e7d566a93 clean up the new FastSmallVector class
also, this fixes some potential memory leaks if vectors of different
sizes are assigned and it fixes the assignment-to-self (`x = x`) case.
2019-03-20 12:41:57 +01:00
Kai Bao
a8f5501e15 update genEvalSpecializations.py 2019-03-15 14:16:14 +01:00
Kai Bao
e4d23d201e making DynamicEvaluation using FastSmallVector 2019-03-15 13:38:07 +01:00
Kai Bao
c633e70f81 adding FastSmallVector to be used by DynamicEvaluation 2019-03-15 13:23:33 +01:00
Andreas Lauser
1ca8ab813c Merge pull request #325 from andlaus/BlackOilIndexTraits
BlackOilFluidSystem: make it easy to change the indices of phases and components
2019-03-11 14:47:33 +01:00
Andreas Lauser
e72b27fd8b BlackOilFluidSystem: make it easy to change the indices of phases and components
this is done by introducing an "IndexTraits" template parameter to the
BlackOilFluidSystem class which only specifies
`{oil,gas,water}{Phase,Comp}Idx`. By default, nothing which faces user
code changes.
2019-03-11 13:48:37 +01:00
Andreas Lauser
3fa1adc514 Merge pull request #323 from totto82/fix_visct
Fix issues with temperature dependent viscosity
2019-01-29 12:19:14 +01:00
Tor Harald Sandve
99e2d4c2ec Fix issues with temperature dependent viscosity 2019-01-29 11:12:38 +01:00
Arne Morten Kvarving
f4f6164831 Merge pull request #322 from andlaus/add_jenkins_pre-build_hook
add a pre build check to ensure that the Evaluation code is identical with the one produced by the code generator
2019-01-21 14:23:05 +01:00
Andreas Lauser
0d3e38e1a1 pre-build.sh: print a message for the non-error case as well.
thanks to [at]akva2 for the suggestion.
2019-01-17 14:06:09 +01:00
Andreas Lauser
d07d3cf5eb add a pre build check to ensure that the Evaluation code is identical with the one produced by the code generator 2019-01-09 14:29:58 +01:00
Tor Harald Sandve
26c607b086 Merge pull request #321 from andlaus/fix_masochistic_warnings
fix some masochistic compiler warnings for the GCC 9 pre-release
2019-01-09 12:16:16 +01:00
Andreas Lauser
7c104e82d6 fix some masochistic compiler warnings for the GCC 9 pre-release
the flags which I used are
```
-pedantic \
-Wall \
-Wextra \
-Wformat-nonliteral \
-Wcast-align
-Wpointer-arith \
-Wmissing-declarations \
-Wcast-qual \
-Wshadow
-Wwrite-strings \
-Wchar-subscripts \
-Wredundant-decls \
-fstrict-overflow \
-O3 \
-march=native \
-DNDEBUG=1
```

note that some heavy filtering is not the worst idea because DUNE is
far from not emiting any warnings with these flags.

also, if quadruple precision math is enabled, GCC complains that a
non-standard floating point signifier suffix is used in quad.hpp. As
far as I can see there's nothing that can be done about that.
2019-01-09 09:35:08 +01:00
Andreas Lauser
f4330e9771 Merge pull request #319 from andlaus/fix_style_issues
Fix coding style issues and rename XYTabulated2DFunction
2019-01-08 13:34:06 +01:00
Joakim Hove
556e2bbf92 Merge pull request #320 from joakim-hove/error-guard
Do not create ParseContext in tests
2019-01-08 07:48:04 +01:00
Joakim Hove
d4332da83e Do not create ParseContext in tests 2019-01-07 12:23:11 +01:00
Andreas Lauser
7c1bda6df1 rename XYTabulated2DFunction to IntervalTabulated2DFunction
... because every 2D function depends on two variables which are
usually called X and Y. The name of that class is still clunky,
suggestions are appreciated.

(also, UniformXTabulated2DFunction is a bad name. I also take
suggestions for that.)
2018-12-20 13:38:03 +01:00
Andreas Lauser
7a4c6546b4 fix some coding style isses in new class XYTabulated2DFunction and its test 2018-12-20 13:38:03 +01:00
Andreas Lauser
20b6068a87 Merge pull request #318 from GitPaean/fixing_gen_eval_python
fixing genEvalSpecializations.py instead of editing Evaluationn directly
2018-12-18 13:21:19 +01:00
Kai Bao
120410e468 fixing genEvalSpecializations.py instead of editing Evaluationn directly 2018-12-18 11:51:00 +01:00
Atgeirr Flø Rasmussen
c8aab83a62 Merge pull request #317 from GitPaean/adding_2D_cartisian_grid
Adding regular 2d cartesian interpolation for the injectivity simulation.
2018-12-11 12:56:28 +01:00
Kai Bao
17264e0873 addressing reviewing comments from PR#137 2018-12-11 10:58:49 +01:00
Kai Bao
25e01bd962 removing the duplicate code in XYTabulated2DFunction 2018-12-11 10:33:52 +01:00
Atgeirr Flø Rasmussen
b20c692b32 Merge pull request #316 from totto82/fix_swatinit
Avoid division by very small numbers when computing the swatinit scaling
2018-12-07 18:46:07 +01:00
Tor Harald Sandve
fa8ac7a891 Avoid division by very small numbers when computing the swatinit scaling
Fix unphysical capillary pressure scaling
2018-12-07 11:09:32 +01:00
Kai Bao
9bf6d01acc adding a test for XYTabulated2DFunction 2018-12-06 13:19:04 +01:00
Kai Bao
889ff8f0a5 some cleaning up of XYTabulated2DFunction 2018-12-03 10:30:27 +01:00
Kai Bao
bbfafad2da various fixes to make DynamicEvaluation work with simulations 2018-11-30 15:34:26 +01:00
Kai Bao
6c20ecad14 adding table XYTabulated2DFunction 2018-11-30 15:34:26 +01:00
Andreas Lauser
b3afa00d08 Merge pull request #312 from totto82/passCanonicalPhaseIdx
Pass canonical phaseIdx to setXXX() methods in fluidsystem
2018-10-29 18:45:46 +01:00
Tor Harald Sandve
e1105cbf0a Pass canonical phaseIdx to setXXX() methods in fluidsystem 2018-10-29 13:01:03 +01:00
Andreas Lauser
7c1d52346b Merge pull request #311 from andlaus/stylistic_BlackOilFluidState_cleanups
some minor coding style cleanups for BlackOilFluidState
2018-10-19 15:17:38 +02:00
Andreas Lauser
656d98721c some minor coding style cleanups for BlackOilFluidState
OPM/opm-material#310 introduced a few minor coding style
inconsistencies. this patch fixes them; none of its changes are
supposed to alter anything functionality-wise.
2018-10-19 14:15:01 +02:00
Tor Harald Sandve
ef5154951a BlackOilFluidState: Only store active phases in the two phase case 2018-10-18 12:41:29 +02:00
Andreas Lauser
20630fa856 Merge pull request #305 from andlaus/fix_gcc8_warnings
fix some GCC 8 warnings
2018-09-20 18:05:25 +02:00
Andreas Lauser
555bf7ad75 fix some GCC 8 warnings
the warnings about catching a polymorphic type by value. I agree that
this should not be done.
2018-09-18 14:03:53 +02:00
Bård Skaflestad
c765b21917 Merge pull request #304 from andlaus/remove_FluidSystems_namespace
remove the Opm::FluidSystems namespace
2018-07-27 21:05:11 +02:00
Andreas Lauser
6cb7df3541 remove the Opm::FluidSystems namespace
this has mildly annoyed me for quite some time, and finally managed to
bring myself to changing it: The Opm::FluidSystems namespace is pretty
useless because the number of classes contained within it is quite
small and mismatch between the naming convention of the file names the
actual classes is somewhat confusing IMO. Thus, this patch changes the
naming of fluid systems from `Opm::FluidSystems::Foo` to
`Opm::FooFluidSystem`.

(also, flat hierarchies currently seem to be popular with the cool
people!?)

this patch requires some simple mop-ups for `ewoms` and `opm-simulators`.
2018-07-27 12:57:09 +02:00
Atgeirr Flø Rasmussen
70e6fcb190 Merge pull request #303 from andlaus/fix_extra_warnings
Fix extra warnings
2018-07-05 14:29:52 +02:00
Andreas Lauser
e1f33492c8 EclMaterialLawManager: actually use the imbibition number array passed as argument
for some reason, the version of 311c1a6 that was merged did still use
the compressed cell index as the logically Cartesian one. I blame it
on the constant back-and-forth debugging when making that patch.
2018-07-05 12:50:54 +02:00
Andreas Lauser
8cde35ef7b MathToolbox: fix unused argument warning 2018-07-05 12:50:54 +02:00
Andreas Lauser
de6c6e8cfa Evaluation: update generated code 2018-07-05 12:50:54 +02:00
Andreas Lauser
b91f198747 update Evaluation-code generator to get rid of a few warnings in the generated code
these warnings require -Wextra or above but do not occur with -Wall.
2018-07-05 12:50:54 +02:00
Kai Bao
5c1ddaefab Merge pull request #302 from andlaus/dynamic_evaluation
Dynamically sized evaluations
2018-06-28 19:42:45 +02:00
Andreas Lauser
f316b0699e add an Opm::blank(Evaluation) function
this creates an uninitialized "compatible" evaluation that is
compatible with its argument. For primitive floating point types and
statically-sized Evaluations, this is identical to calling the default
constructor, for dynamically sized ones, it creates an uninitialized
Evaluation object of identical size as the argument.

thanks to [at]GitPaen for the heads up.
2018-06-28 17:27:48 +02:00
Andreas Lauser
328efa793c add dynamic evaluations to the unit test for dense-AD
this requires a medium-sized refactoring of the test.
2018-06-28 17:27:48 +02:00
Andreas Lauser
7b12d493d7 make the "shrubbery" of dense-AD aware of dynamic evaluations
i.e., adapt the math routines.
2018-06-28 17:27:48 +02:00
Andreas Lauser
362965c198 update the generated source files 2018-06-28 17:27:48 +02:00
Andreas Lauser
fec2428c3e evaluation code gen: add a dynamically-sized variant of evaluation
this works by passing -1 as the template argument for the number of
derivatives. most of the code is identical, but creation of such
objects requires the number of derivatives passed to the constructor
or the copy constructor must be used.

Finally `DynamicEvaluation<Scalar>` is provided as a more expressive
alias for `Evaluation<Scalar, -1>`.
2018-06-28 17:27:47 +02:00
Tor Harald Sandve
2a8b6e8974 Merge pull request #300 from andlaus/1_for_EHSYTR_item_2
implement support for "1" of the second item of EHYSTR
2018-06-28 07:42:52 +02:00
Andreas Lauser
bcec72a7db implement support for "1" of the second item of EHYSTR
this means Carlson's hysteresis model for the relperm of the
non-wetting phase and the imbibition instead of the drainage curve for
the relperm of the wetting phase.
2018-06-19 14:37:09 +02:00
Andreas Lauser
311c1a6ae1 ECL hysteresis: fix the imbibition number
so far, compressed element indices have been used to access data for
logical cartesian cells. this does not matter if there is only a
single saturation region for imbibition and thus IMBNUM is
uniform. (e.g., this is the case for Norne as far as I can see.)
2018-06-19 14:29:40 +02:00
Andreas Lauser
86a377dc1e make the quadruple precision math support code compatible with dune-fem
the stream operators are actually the ones for double precision.
2018-05-17 11:30:31 +02:00
Atgeirr Flø Rasmussen
6dd79068fd Merge pull request #292 from andlaus/rename_internal_vars
SPECROCK thermal law: rename internal variables
2018-03-28 12:21:37 +02:00
Andreas Lauser
898af59418 use the midpoint rule to integrate linear functions
this used to be the unmodified quadratic function that results from
integrating a linear function. using the midpoint rule is quite a bit
simpler and should yield the same results.

thanks to [at]atgeirr for pointing this out.
2018-03-28 09:45:29 +02:00
Andreas Lauser
038f9c7bf1 thermal PVT and rock laws: fix the integration of the heat capacities
this was quite embarrassing. thanks to [at]atgeirr for pointing it out.
2018-03-27 14:00:41 +02:00
Andreas Lauser
01403ccdb3 thermal laws: rename some internal variables
using `u` or `h` for heat capacities is very confusing because the
variables can easily be mistaken for the internal energy or enthalpy.
2018-03-27 13:52:51 +02:00
Andreas Lauser
e773914399 Merge pull request #291 from andlaus/fix_dune_master
make it work with the latest dune master
2018-03-12 15:16:00 +01:00
Andreas Lauser
9891b2a3c7 make it work with the latest dune master
Dune::set_singularity_limit() has been removed there and std::real()
gets used by the dense matrix-vector code (this causes trouble if
`quad` is selected as scalar type)
2018-03-12 13:58:45 +01:00
Arne Morten Kvarving
283550a702 Merge pull request #290 from akva2/adjust_ecl
adjustments for moved eclipse support (now in opm-common)
2018-03-06 15:34:34 +01:00
Arne Morten Kvarving
53b24d482a adjustments for moved eclipse support (now in opm-common) 2018-03-05 12:49:22 +01:00
Andreas Lauser
52321e5c04 Merge pull request #289 from andlaus/fix_warnings
Fix warnings
2018-03-03 13:30:38 +01:00
Andreas Lauser
ed0e839eb5 avoid single precision floating point underflows in MiscibleMultiPhaseComposition
for single-precision FP scalars, this was the same as setting a
tolerance of 0. maybe this should be done instead?!
2018-03-03 13:17:33 +01:00
Andreas Lauser
135f81073d add a few OPM_UNUSED decorations to variables which are only used within static_assert
for some reason icc produces a warning about this.
2018-03-03 13:17:33 +01:00
Atgeirr Flø Rasmussen
a7d929e638 Merge pull request #288 from atgeirr/missing-include
Include <stdexcept> for std::runtime_error.
2018-02-14 14:46:06 +01:00
Atgeirr Flø Rasmussen
da4b160438 Include <stdexcept> for std::runtime_error. 2018-02-14 13:02:40 +01:00
Andreas Lauser
e5e43fa7a8 Merge pull request #287 from andlaus/separate_opm-common_concerns
move some basic infrastructure from opm-common to here
2018-02-08 16:24:51 +01:00
Andreas Lauser
27386851a2 move some basic infrastructure from opm-common to here
all of these classes have only been used in opm-material and its
downstreams in the first place.
2018-02-07 16:44:44 +01:00
Joakim Hove
9aa47b2969 Merge pull request #282 from andlaus/cp_to_cv
Cp to cv
2018-01-31 17:51:13 +01:00
Atgeirr Flø Rasmussen
94f0f8b985 Merge pull request #283 from akva2/relocate_files_in_common
changed: opm/common/[->utility/]ConditionalStorage.hpp
2018-01-31 13:17:57 +01:00
Andreas Lauser
7fece91b76 Merge pull request #284 from atgeirr/master
Silence some warnings
2018-01-30 15:47:43 +01:00
Atgeirr Flø Rasmussen
a9018ece34 Add OPM_UNUSED to unused temperature arguments. 2018-01-30 15:06:26 +01:00
Atgeirr Flø Rasmussen
578426f4cd Remove unused arguments. 2018-01-30 15:06:13 +01:00
Atgeirr Flø Rasmussen
904a5c674b Put code in separate scope to avoid shadowing. 2018-01-30 15:05:48 +01:00
Arne Morten Kvarving
46892f54f0 changed: opm/common/[->utility/]ConditionalStorage.hpp 2018-01-30 12:24:04 +01:00
Andreas Lauser
096c22be92 ECL thermal: assume heat capacities for constant volume instead for constant pressure
this implies that the internal energy instead of the enthalpy is
specified by the fluid PVT classes.
2018-01-30 12:19:17 +01:00
Andreas Lauser
be4245a397 improve the documentation of the NCP flash solver 2018-01-30 12:18:34 +01:00
Andreas Lauser
b86664f3a9 Merge pull request #280 from andlaus/fix_fluidstate_getters2
fix Opm::getInvB_(fluidState) once more
2018-01-22 16:09:48 +01:00
Andreas Lauser
64eae1c92f fix Opm::getInvB_(fluidState) once more
after #278, the generic version of getInvB_() was always used because
no argument for fluidState.invB() was specified when invoking the
GENERATE_HAS_MEMBER() macro, so has_invB<FluidState>() returned false
for any fluid state. since the getInvB_() function is not used by the
master version of `flow` yet, it was unaffected by this issue and this
is also the reason why neither Jenkins complained nor any performance
regression could be seen after #278. That said, for implementing
non-trivial boundary conditions, it is very helpful to have a unified
code path for the case where boundary conditions are specified using
generic fluid states and black-oil model specific ones as well as with
the flux computations in the interior of the domain.

Note that I only found this issue due to the fact that on my current
WIP branch linearization got 10% slower for Norne. This means that the
generic version of this function must be correct and, considering the
fact that the massFraction() method is quite elaborate for
BlackOilFluidState, this is also a very strong indication that on
modern processors the performance of even the linearization part of
the simulation is more limited by memory latency than by the execution
speed of the ALUs.
2018-01-22 14:24:41 +01:00
Andreas Lauser
a03f9a73cc Merge pull request #278 from andlaus/fix_fluidstate_getters
Fix fluid state getters for blackoil quantities
2018-01-19 13:01:17 +01:00
Andreas Lauser
fdf506794f make the ordering of the template parameters of the get*_(fluidState) functions consistent
the order of template parameter now always is FluidSystem, FluidState,
Evaluation. This requires some downstream mop-up patches.
2018-01-19 11:40:25 +01:00
Andreas Lauser
f46b23fcbb add the PVT region index as a parameter for getInvB_()
this is only relevant for the generic-fluidstate version. In most
cases, 0 should be passed as the PVT region index.
2018-01-19 11:38:18 +01:00
Andreas Lauser
4416b4ae83 fix typo in version of getInvB_() for generic fluid states 2018-01-19 11:31:50 +01:00
Andreas Lauser
d3b20fa5c5 use has_invB() to decide if the generic or trivial versions of getInvB_() are used
this used to be has_pvtRegionIndex(). While there currently is no
difference in practice because the only fluid state that exhibits a
pvtRegionIndex() method also has invB(), a bug is a bug...
2018-01-19 11:30:55 +01:00
Andreas Lauser
847213f36e Merge pull request #275 from andlaus/implement_TOLCRIT
implement support for the TOLCRIT ECL keyword
2018-01-08 15:41:03 +01:00
Andreas Lauser
68ed9ea7b3 implement support for the TOLCRIT ECL keyword 2018-01-08 11:58:53 +01:00
Andreas Lauser
e4d4454671 Merge pull request #273 from andlaus/avoid_heat
thoroughly rename the thermal laws
2018-01-05 13:59:35 +01:00
Andreas Lauser
86a0e9befc ECL thermal gas PVT: add the heat of vaporization to the gas enthalpy
this does only matters for temperature changes due to dissolution and
evaporization of gas in oil or oil in gas. The comprehensive solution
would be to make the enthalpy of the phases composition dependent, but
ECL does not seem to support this when using the black-oil model.
2018-01-04 15:25:12 +01:00
Andreas Lauser
bf3cffa6b4 thoroughly rename the thermal laws
this was only partially done so far: the term "heat" should be avoided
if possible because it is a somewhat fuzzy concept. Thus, replace it
by "energy" and "thermal" where it is not a well established
term. ("well established" basically means "heat capacity".)
2018-01-04 15:25:11 +01:00
Andreas Lauser
d2588eac7d compute the inverse formation volume factor for generic fluid states
before, if the fluid state did not provide an invB() method,
Opm::getInvB_() just returned 0.0. with this, it uses the composition
and density of the phase in question to compute that quantity.

(also, this commit contains a few stylistic cleanups for
BlackOilFluidSystem)
2018-01-02 10:33:22 +01:00
Andreas Lauser
1f114a2bc9 Merge pull request #268 from andlaus/improve_BlackOilFluidState
improve the BlackOilFluidState class
2017-12-15 09:26:51 +01:00
Andreas Lauser
644240e6b9 improve the BlackOilFluidState class
now the assign() function should work and all functions should exhibit
a doxygen string. note that the inverse formation volume factors are
zero if the fluid state passed as the argument to assign() does not
feature an invB() member function.
2017-12-14 17:54:22 +01:00
Andreas Lauser
a4aa334c02 Merge pull request #267 from andlaus/implement_blackoil_energy
Implement blackoil energy
2017-12-14 10:44:33 +01:00
Andreas Lauser
f8ecd7ceaa implement the ECL thermal laws
Like for the material laws, an EclThermalLaw manager class is provided
to simplify initialization of the parameter objects from ECL decks.
2017-12-14 10:43:54 +01:00
Andreas Lauser
7b8951ed83 refactor the "heat conduction" laws into "thermal laws"
thermal laws are the heat conduction laws plus "solid energy laws"
which can be used to specify the relations which govern the volumetric
internal energy of the solid matrix of the porous medium.
2017-12-14 10:43:54 +01:00
Andreas Lauser
f195effcdd VanGenuchtenParams: remove superfluous include 2017-12-14 10:43:54 +01:00
Andreas Lauser
0bd4596e8d BlackOilFluidSystem: implement enthalpy() 2017-12-14 10:43:54 +01:00
Andreas Lauser
255fa88bd5 BlackOilFluidSystem: honor the STCOND keyword to specify the standard conditions 2017-12-14 10:43:54 +01:00
Andreas Lauser
7e651c2317 black-oil: improve the thermal fluid PVT classes
- Introduce an enthalpy() method to all low-level PVT classes
- change the approach to define temperature dependent density for oil
  and gas to the OPM-specific keywords GASDENT and OILDENT. Funnily
  enough, ECL already has a WATDENT keyword.
2017-12-14 10:43:54 +01:00
Andreas Lauser
835a74cc1e extend BlackOilFluidState by energy related quantities
i.e. enthalpy, internal energy and temperature. To make sure that this
does not affect simulatiors which do not use energy, two additional
template parameters, `enableTemperature` and `enableEnergy` are
introduced and the energy quantities are only stored
conditionally. The first parameter allows to store a temperature in
the fluid state without storing enthalpies while the second stores
everything (i.e., setting it to true also implies the first).
2017-12-14 10:43:54 +01:00
Andreas Lauser
aacdf72356 BlackOilFluidState: document it properly 2017-12-14 10:43:54 +01:00
Andreas Lauser
ab0183f6d8 quad.hpp: simplify the error prevention mechanism for Dune::className()
there is no need to include quad.hpp before dune's
classname.hh. Instead we just include classname.hh into quad.hpp and
it will work unconditionally.
2017-12-14 10:42:23 +01:00
Andreas Lauser
300bbe4fe8 Merge pull request #263 from andlaus/remove_blackoil_satinterpolation
BlackOilFluidSystem: remove interpolation between saturated and unsaturated quantities
2017-12-13 09:49:28 +01:00
Andreas Lauser
b9b81b38b6 BlackOilFluidSystem: re-add the linear interpolation between saturated and undersaturated conditions
since the undersaturated PVT relations may use bi-linear 2D
interpolation but the saturated ones always use linear 1D
interpolation, not having this leads to a discontinuity. that
discontinuity turns out to be very bad news if the partial derivatives
are calculated using finite differences. On the other hand, the
untersaturated PVT relations cannot be used unconditionally (this
would be the clean solution, IMO) because this causes the results to
deflect from those produced by ECL. The hack to make DR[SV]DT work is
to only use the saturated PVT quantities if the R value is
sufficiently large. (This may lead to issues in the future because
there now is a discontinuity w.r.t. R, but let's burn that bridge when
we come to it.)
2017-12-11 15:35:01 +01:00
Andreas Lauser
fc1a042669 black oil: only use the saturated quantities if the R factor is large enough
in the oil case the previous condition that the saturation of the gas
phase is non-zero is cheaper to evaluate, but it does not work when
the maximum Rs value at which the gas phase starts to appear is lower
than the Rs value of the saturated gas. In particular this happens for
the DRSDT keyword.

note that the best solution would be to eliminate these case
distinctions alltogether, but this does not work because ECL does not
seem to use bi-linear interpolation if the pressure gets larger than
the maximum pressure specified by the PVT table. (it only seems to use
the pressure to extrapolate linearly.)
2017-12-11 15:35:01 +01:00
Andreas Lauser
45870255f7 fluid states: remove phaseIsPresent()
this method is now unused and before, it only caused trouble. To
replicate it, use fluidState.saturation(phaseIdx) > 0.0.
2017-12-11 15:35:01 +01:00
Andreas Lauser
a15cb08d2e do not use fluidState.phaseIsPresent() anymore
this lead to problems if finite differences were used because to
calculate the derivative, it may deflect the saturations.
2017-12-11 15:35:01 +01:00
Andreas Lauser
5f650785a9 BlackOilFluidSystem: remove interpolation between saturated and unsaturated quantities
this causes problems with things like DRSDT where
"isSaturated(oilPhasIdx)" is not necessarily related to the presence
of the gas phase. (analogous for DRVDT.)

The impact of performance seems to be negligible:

```
Total time (seconds):         550.185
Solver time (seconds):        534.769
 Assembly time (seconds):     251.509 (Failed: 4.51604; 1.79558%)
 Linear solve time (seconds): 263.03 (Failed: 5.78332; 2.19873%)
 Update time (seconds):       11.0526 (Failed: 0.220144; 1.99177%)
 Output write time (seconds): 18.1411
Overall Well Iterations:      902 (Failed: 7; 0.776053%)
Overall Linearizations:       1890 (Failed: 33; 1.74603%)
Overall Newton Iterations:    1553 (Failed: 33; 2.12492%)
Overall Linear Iterations:    23525 (Failed: 511; 2.17216%)
```

before and

```
Total time (seconds):         556.463
Solver time (seconds):        541.06
 Assembly time (seconds):     253.165 (Failed: 4.42903; 1.74946%)
 Linear solve time (seconds): 267.343 (Failed: 4.52042; 1.69087%)
 Update time (seconds):       11.334 (Failed: 0.214721; 1.89449%)
 Output write time (seconds): 18.0694
Overall Well Iterations:      903 (Failed: 8; 0.885936%)
Overall Linearizations:       1909 (Failed: 33; 1.72865%)
Overall Newton Iterations:    1572 (Failed: 33; 2.09924%)
Overall Linear Iterations:    23866 (Failed: 391; 1.63831%)
```

after this patch, i.e., on my machine the runtime for Norne went from
550 to 556 seconds due to slightly larger number of non-linear and
linear iterations. Note that this also happens if the 1e-4 threshold
value is changed instead of the case distinction being removed. (This
hints on the into the direction that the performance difference is
just numerical noise.)
2017-12-11 15:35:01 +01:00
Andreas Lauser
1f0be92300 add a unit test for BlackOilFluidSystem 2017-12-11 15:35:01 +01:00
Andreas Lauser
53d9d92d65 make Tabulated1DFunction more consistent with UniformXTabulated2DFunction
these are basically cosmetic cleanups.
2017-12-11 15:35:01 +01:00
Andreas Lauser
94b6124fba improve implementation of UniformXTabulated2DFunction
in particular, do not mingle the segment index and the relative
position within the segment into a single number anymore.
2017-12-11 15:35:01 +01:00
Andreas Lauser
408ceb820b Merge pull request #265 from andlaus/remove_useComplexRelations
fluid systems: remove the complex relations flag from the fluid systems
2017-12-04 15:20:30 +01:00
Andreas Lauser
9c57728405 fluid systems: remove the complex relations flag from the fluid systems
this flag is way too non-descript (a complex relation for one person
may be a simple one for another), the implementation is pretty
inconsistent and it makes the code more complicated and harder to
maintain. Thus, IMO the approach turned out to be a bummer, so let's
pull the plug.
2017-12-04 11:08:50 +01:00
Andreas Lauser
0d6ef73d9e Merge pull request #264 from andlaus/add_BlackOilFluidState
add a tailor-made fluid state for black-oil models
2017-12-01 17:52:51 +01:00
Andreas Lauser
7cb5e91e2b add a tailor-made fluid state for black-oil models
this is basically a slightly cleaned up version of
Ewoms::BlackOilFluidState.
2017-12-01 17:25:08 +01:00
Andreas Lauser
5f7ac68b1a Merge pull request #260 from totto82/supportSOF2
Add support for SOF2 for 2p runs.
2017-11-24 10:29:28 +01:00
Tor Harald Sandve
f6146db122 Add support for SOF2 for 2p runs.
Make it possible to use SOF2 in combination with either
SGFN og SWFN for gas-oil and water-oil case respectivly.
2017-11-23 10:46:55 +01:00
Andreas Lauser
cb75a7ad6f Merge pull request #259 from andlaus/fix_n2_heatcap
N2: make the heat capacity consistent with the enthalpy again
2017-11-17 19:19:21 +01:00
Andreas Lauser
0d613a7c25 N2: make the heat capacity consistent with the enthalpy again
I missed the fact that in the enthalpy() function, the polynomial
coefficients are divided, i.e., this component defines a polynomial
for the heat capacity and integrates it for the enthalpy. (not
the other way around.)
2017-11-17 19:09:01 +01:00
Andreas Lauser
0e78de262d Merge pull request #258 from andlaus/fix_component_enthalpy
fix heatCapacity() and enthaply() of some components
2017-11-17 19:00:49 +01:00
Andreas Lauser
db87b77896 fix heatCapacity() and enthaply() of some components
I looked at all components: For the ones that use simple enthalpy
relations, heatCapacity() and enthalpy() should now be
consistent. (Here "simple" means "an approach that I understood without
reading literature for several hours".)
2017-11-16 16:30:24 +01:00
Tor Harald Sandve
ef91bbf7d2 SWATINIT Also scale capPres when water saturation is below residual
This assure that the initial state is in eqvilibrium also for cells with
where SWATINIT is set below residual value.
2017-09-21 14:50:08 +02:00
Andreas Lauser
93d448457c Merge pull request #246 from totto82/gasoil
Allow for 2p gasoil case
2017-09-05 21:28:14 +02:00
Tor Harald Sandve
a13a3a3f62 Allow for 2p gasoil case 2017-09-04 12:32:27 +02:00
Andreas Lauser
d68dd09aee Merge pull request #245 from andlaus/limit_VAPPARS
limit the reduction due to VAPPARS to a factor of 1000
2017-07-31 15:01:13 +02:00
Andreas Lauser
2457b4d5af VAPPARS: considerably increase the epsilon value for the numerator
again, the effect of this on the results should be negligible, but the
numerical performance should become much better.
2017-07-28 23:04:18 +02:00
Andreas Lauser
87122bb2f5 limit the reduction due to VAPPARS to a factor of 1000
a reduction of Rs and Rv of a factor 1000 should be enough physically
and the numerical stability is quite a bit better with this. In
particular, this is should not really matter because the whole concept
of VAPPARS is a staggeringly ugly hack from the outset.
2017-07-28 23:02:37 +02:00
Andreas Lauser
2f537717c8 Merge pull request #244 from andlaus/VAPPARS_limit_SoMax
VAPPARS: limit the maximum oil saturation to 1.0
2017-07-28 20:54:46 +02:00
Andreas Lauser
b631809de8 VAPPARS: limit the maximum oil saturation to 1.0
It should never become larger than 1, but during a Newton-Raphson
update it may happen anyway.
2017-07-28 19:13:10 +02:00
Andreas Lauser
3a65e712c9 Merge pull request #242 from andlaus/Evaluation_default_copy
Evaluation: use the trivial copy constructor and copy operator
2017-07-27 20:14:24 +02:00
Andreas Lauser
be96015760 Merge pull request #243 from andlaus/no_by_value_catch
TabulatedComponent: don't catch std::exception by value
2017-07-27 20:03:14 +02:00
Andreas Lauser
2b4114907e TabulatedComponent: don't catch std::exception by value
std::exception is a polymorphic type and catching these by values
generates warnings when using the latest GCC from SVN. Besides this,
catching objects by value is bad style and was unintended from the
start.
2017-07-27 18:04:43 +02:00
Andreas Lauser
6cdae5f4c2 Evaluation: update the generated code 2017-07-27 18:02:55 +02:00
Andreas Lauser
8a0de34ad0 Evaluation: use the trivial copy constructor and copy operator
this potentially allows the compiler to do better optimizations.
2017-07-27 18:02:55 +02:00
Andreas Lauser
a66273c6aa Merge pull request #241 from andlaus/keep_track_of_reservoir_temperature
BlackOilFluidSystem: Keep track of the reservoir temperature
2017-07-27 18:01:23 +02:00
Andreas Lauser
0bc9299010 BlackOilFluidSystem: Keep track of the reservoir temperature
In fact, the temperature at the reservoir is not constant, so this
should be more thought of as "representative temperature" of the
reservoir.

In ECL, this value is specified using the RTEMP or the RTEMPA
keywords, opm-parser provides this via the table manager. (NB: is this
really something that belongs there?)
2017-07-27 16:06:58 +02:00
Andreas Lauser
2f08e57ad8 Merge pull request #240 from andlaus/fix_headercheck
make all headers autonomous again
2017-07-20 13:10:44 +02:00
Andreas Lauser
b65defe489 make all headers autonomous again
i.e., they can be included without having other files included before them.
2017-07-20 12:08:47 +02:00
Andreas Lauser
9583b402c7 Merge pull request #237 from andlaus/remove_deprecated
RegularizedBrooksCoreyParams: remove long deprecated method
2017-06-30 14:33:17 +02:00
Andreas Lauser
99039f6d62 RegularizedBrooksCoreyParams: remove long deprecated method
this method is unused in the whole OPM project and has long been
renamed to setPcLowSw().
2017-06-29 18:42:39 +02:00
Andreas Lauser
3ddc7a5340 Merge pull request #234 from dr-robertk/PR/cleanup-scalar
[cleanup] make code compile when Scalar is non POD type.
2017-06-27 13:13:39 +02:00
Andreas Lauser
0a2591f3fd Merge pull request #236 from andlaus/fix_debug_mode_warning
fix an unused typedef warning that only occurs in debug mode
2017-06-27 13:13:01 +02:00
Andreas Lauser
e9dfe00335 Merge pull request #235 from andlaus/fix_critsat
EclEpsScalingPoints: make determining the critical saturations more robust
2017-06-26 13:29:30 +02:00
Andreas Lauser
3c7e12976f fix an unused typedef warning that only occurs in debug mode 2017-06-26 10:40:17 +02:00
Andreas Lauser
967af088bb EclEpsScalingPoints: make determining the critical saturations more robust
these loops are somewhat tricky. the new versions are infinitessimally
slower, but hopefully much more robust.
2017-06-24 13:13:02 +02:00
Robert Kloefkorn
aec9fe5834 [cleanup] make code compile when Scalar is non POD type. 2017-06-23 10:46:55 +02:00
Atgeirr Flø Rasmussen
d0ef28833a Merge pull request #220 from andlaus/eval_specializations_v2
Eval specializations v2
2017-06-15 10:39:57 +02:00
Andreas Lauser
72fd2c8a7e Merge pull request #233 from andlaus/densead_declutter
Densead declutter
2017-06-15 10:33:42 +02:00
Andreas Lauser
87222f3c6a disable a static assertation in the DenseAD convenience functions
the problem is that some of these function names clash with those for
code using AutoDiffBlock. This is normally not a problem because of
the SFINAE rule, but the static assertation makes the compiler bail
out before SFINAE kicks in.

IMO this is a little unfortunate because without this static_assert
compiler errors are bound to becomming quite a bit more obscure, but
as long there is code which uses both AD approaches at the same time,
I cannot see a way to keep the assert without moving one approach or
the other to a different namespace (or renaming the math function for
one).
2017-06-14 11:06:04 +02:00
Andreas Lauser
0f6540bdad DenseAD: make less fuzz about it
this patch converts to code to use the convenience functions instead
of the math toolboxes whereever possible. the main advantage is that
Opm::foo(x) will work regardless of the type of `x`, but it also
reduces visual clutter.

also, constant Evaluations are now directly created by assigning
Scalars, which removes further visual noise.

while I hope it improves the readability of the code,
functionality-wise this patch should not change anything.
2017-06-13 17:25:03 +02:00
Andreas Lauser
acfa7c43e5 convenience functions: use the raw type for results
i.e., we should not return references and we also should remove the
const qualifier in this context. (if these are wanted, the calling
scope should add them.)
2017-06-13 17:18:47 +02:00
Andreas Lauser
256fcd65d4 use log() instead of ln() to calculate the natural logarithm
it seems like ln() is non-standard and this piece of code only
compiled because that particular method is never instantiated.
2017-06-13 17:17:26 +02:00
Andreas Lauser
7050193167 update generated files 2017-06-07 15:20:01 +02:00
Andreas Lauser
ee5ee215bd explicitly include all Evaluations in the file for each specialization
indirectly this was already the case: Math.hpp includes
Evaluation.hpp, but this change should make it more explicit.
2017-06-07 15:20:01 +02:00
Andreas Lauser
1a1b17a5c8 revert optimizing the division code for evaluations 2017-06-07 15:20:01 +02:00
Andreas Lauser
19fb18dc20 clean up the code generator script for Evaluations a bit
this mainly removes superfluous newlines in the generated files, but
also makes them bit more consistent.
2017-06-07 15:20:01 +02:00
Andreas Lauser
2f86c78dd8 Revert "Revert "[WIP] Evaluation: specialize evaluations for used numbers in Blackoil setting""
This reverts commit cfc79fd6d5.
2017-06-07 15:20:01 +02:00
Andreas Lauser
2a69da14f0 Simplify usage of Evaluations in some places
The convenience functions allow to get rid of many direct calls to the
toolbox and constants can be directly returned as doubles.
2017-06-07 15:20:01 +02:00
Atgeirr Flø Rasmussen
14bf347ec3 Merge pull request #232 from nairr/term_output_mod
Minor changes to log type
2017-05-29 08:52:41 +02:00
Rohith Nair
0d70d3c32d Minor changes to log type 2017-05-24 11:31:16 +02:00
Andreas Lauser
ea7cc1f56e Merge pull request #229 from andlaus/implement_blackoil_solvent
black-oil: add a PVT class for solvents
2017-05-05 18:45:56 +02:00
Andreas Lauser
027c366dd1 black-oil: add a PVT class for solvents
this is anlogous to the dry gas PVT code but it uses the PVDS and
SDENSITY keywords.

Note that this object is only used by the eWoms black-oil solvent
code, i.e. it not used by the black oil fluid system or any other
opm-material code, but IMO opm-material is the right place for it
because of its similarity to dry gas.
2017-05-05 10:47:43 +02:00
Andreas Lauser
6b2fe9633b Merge pull request #228 from andlaus/fix_warning
FluidStateCompositionModules: fix some compiler warning
2017-05-04 14:21:29 +02:00
Andreas Lauser
db0086df29 FluidStateCompositionModules: fix some compiler warning
that warning was correct, but bogus: while this data was indeed used
without initialization, using the mass composition of a phase before
fully specifying the molar composition is incorrect and would have
trigger a valgrind complaint. (valgrind will still complain after that
patch.)
2017-05-04 13:14:43 +02:00
Andreas Lauser
34f3a35c97 Merge pull request #225 from atgeirr/silence-warnings
Silence warnings.
2017-04-12 10:19:12 +02:00
Atgeirr Flø Rasmussen
a229ba0945 Silence warnings.
One shadowing and one unused variable.
2017-04-12 07:49:31 +02:00
Andreas Lauser
aa7d20fe12 Merge pull request #224 from nairr/terminal_output_mod
terminal output modifications
2017-04-11 11:04:19 +02:00
Andreas Lauser
d24f82a86d Merge pull request #216 from dr-robertk/PR/fix-pointer-deleting-problem
EclMultiplexerMaterialParams: use shared_ptr instead of void*.
2017-04-11 10:46:25 +02:00
Rohith Nair
901f72599f minor change 2017-04-11 09:57:24 +02:00
Rohith Nair
8e61957b8d minor changes to output tag 2017-04-11 09:53:31 +02:00
Rohith Nair
7194815a87 Changed certain output classifications 2017-04-10 19:01:53 +02:00
Andreas Lauser
86300907cb test_components: check the API comprehensively
for some reason some methods were untested up now.
2017-04-10 12:26:11 +02:00
Andreas Lauser
a9d997785c make all components compile properly with evaluations 2017-04-10 12:26:11 +02:00
Andreas Lauser
989e04efe9 fix the headercheck
i.e., make all headers includable without preconditions.
2017-04-10 12:26:11 +02:00
Andreas Lauser
262de1b8fb simple CO2: fix a snafu related to evaluations
in some places, it used primitive floating point objects when it
should have used Evaluations. This is probably not the only place
where this happens, but IMO the individual components are pretty low
priority.
2017-04-10 12:26:11 +02:00
babrodtk
5950d6458e Fixed numerical problems with bubble/dew point pressures 2017-04-10 12:26:11 +02:00
Atgeirr Flø Rasmussen
0d6655ad86 Revert "[WIP] Evaluation: specialize evaluations for used numbers in Blackoil setting" 2017-04-10 12:26:11 +02:00
Tor Harald Sandve
0210dff3af Add method to get connectionMaterialLawParams
This method changes the saturation table idx in the original material
law parameter object. In the context of ECL reservoir simulators, this
is required to properly handle wells with its own saturation table idx.
In order to reset the saturation table idx in the materialLawparams_
call the method with the cells satRegionIdx after it has been used for
the well connection.

Hysteresis is not accounted for. Is is a open question how this should
be implemented. A warning is given if hysteresis is combined with a
modified saturation table idx for the connection.
2017-04-10 12:26:11 +02:00
Andreas Lauser
2e578ce6b3 Merge pull request #223 from andlaus/fix-test_components
Fix API test for components
2017-04-10 12:22:56 +02:00
Andreas Lauser
7892561f29 Merge pull request #221 from andlaus/release_maintainance
Release maintainance
2017-04-10 11:28:06 +02:00
Andreas Lauser
e88216d9d5 test_components: check the API comprehensively
for some reason some methods were untested up now.
2017-04-10 11:22:54 +02:00
Andreas Lauser
83d73f65e7 make all components compile properly with evaluations 2017-04-10 11:22:54 +02:00
Andreas Lauser
c5a62aa0d8 fix the headercheck
i.e., make all headers includable without preconditions.
2017-04-10 11:08:34 +02:00
Andreas Lauser
2b185c49e2 Merge pull request #222 from andlaus/fix_simpleCO2
simple CO2: fix a snafu related to evaluations
2017-04-09 19:54:47 +02:00
Andreas Lauser
899437ac27 simple CO2: fix a snafu related to evaluations
in some places, it used primitive floating point objects when it
should have used Evaluations. This is probably not the only place
where this happens, but IMO the individual components are pretty low
priority.
2017-04-09 19:51:05 +02:00
Atgeirr Flø Rasmussen
77ea8d5d41 Merge pull request #217 from totto82/connMat2
Add method to get connectionMaterialLawParams
2017-04-07 14:43:39 +02:00
Atgeirr Flø Rasmussen
d7c9962644 Merge pull request #218 from babrodtk/fix_pbpd_numericalproblems
Fixed numerical problems with bubble/dew point pressures
2017-04-05 10:32:55 +02:00
babrodtk
d0b2eb9606 Fixed numerical problems with bubble/dew point pressures 2017-03-31 14:05:05 +02:00
Atgeirr Flø Rasmussen
a9280edb82 Merge pull request #219 from OPM/revert-213-PR/improved-performance
Revert "[WIP] Evaluation: specialize evaluations for used numbers in Blackoil setting"
2017-03-28 15:24:35 +02:00
Atgeirr Flø Rasmussen
cfc79fd6d5 Revert "[WIP] Evaluation: specialize evaluations for used numbers in Blackoil setting" 2017-03-28 13:26:10 +02:00
Robert Kloefkorn
2f6ae41e2c EclMultiplexerMaterialParams: implement correct operator=. 2017-03-23 19:48:45 +01:00
Tor Harald Sandve
e26fd1227b Add method to get connectionMaterialLawParams
This method changes the saturation table idx in the original material
law parameter object. In the context of ECL reservoir simulators, this
is required to properly handle wells with its own saturation table idx.
In order to reset the saturation table idx in the materialLawparams_
call the method with the cells satRegionIdx after it has been used for
the well connection.

Hysteresis is not accounted for. Is is a open question how this should
be implemented. A warning is given if hysteresis is combined with a
modified saturation table idx for the connection.
2017-03-23 10:09:41 +01:00
Robert Kloefkorn
0a5a5f7eb1 [bugfix][EclMultiplexerMaterialParams] use shared_ptr instead of void* to store pointer to avoid
problems with copying of objects.
2017-03-22 17:23:14 +01:00
Andreas Lauser
943f022277 Merge pull request #213 from dr-robertk/PR/improved-performance
[WIP] Evaluation: specialize evaluations for used numbers in Blackoil setting
2017-03-21 10:31:59 +01:00
Robert Kloefkorn
1a4f382a52 [cleanup] newly created Evaluation files, now with {} in for loops to
make it through the review process.
2017-03-20 14:51:47 +01:00
Robert Kloefkorn
49ff83d140 [cleanup] Avoid creation of empty lines and make work with python3. 2017-03-20 14:51:15 +01:00
dr-robertk
d6bb4353c2 Merge pull request #4 from andlaus/generated_eval_specializations_v3
dense AD: fix a few stupid bugs due to code generation
2017-03-20 10:23:07 +01:00
Andreas Lauser
2f44918a2b dense AD: fix a few stupid bugs
e.g., looping over the wrong range or an infinite loop. also, the
dense-AD unit test is shortend to test one specialization and the
unspecialized class.
2017-03-17 20:48:39 +01:00
dr-robertk
efa158589f Merge pull request #3 from andlaus/generated_eval_specializations_v2
auto-generate and specialize the whole Evaluation class
2017-03-17 17:52:18 +01:00
Andreas Lauser
bf771b09b4 auto-generate and specialize the whole Evaluation class
older compilers (-> GCC < 5) seem to have trouble with inlining here
which leads to sub-optimal performance. since it is not a big problem
to also generate the unspecialized Evaluation class, let's do that
instead. (for hand-written code, this would be a huge
consistency/maintainance problem, though.)
2017-03-17 17:25:49 +01:00
dr-robertk
99ad3843df Merge pull request #2 from andlaus/generated_eval_specializations
Generated eval specializations
2017-03-16 13:51:54 +01:00
Andreas Lauser
dff851951e add description to the code generator for the Evaluation specializations
and make the maximum number of variables for which specializations
should be generated settable via a command line argument.
2017-03-16 11:51:24 +01:00
Andreas Lauser
72b9830b6c move the script that generates the specializations for Evaluation to bin/ 2017-03-16 11:17:33 +01:00
Andreas Lauser
cba7ad9530 specify the type for the data storage via EvaluationOps 2017-03-16 01:05:00 +01:00
Andreas Lauser
b91c9feca9 fix typo: 'devide' -> 'divide' 2017-03-16 00:08:01 +01:00
Andreas Lauser
c170647969 use code generation for producing the specializations if the dense AD Evaluation class 2017-03-16 00:05:52 +01:00
Robert Kloefkorn
db46b907a2 Evaluation: specialize evaluations for used number in Blackoil setting
to increase performance. Also, change from unsigned to int because it's
better supported by compilers.
2017-03-14 14:49:24 +01:00
Andreas Lauser
2a9128a515 Merge pull request #209 from babrodtk/hysteresis_output
Add option to store/restore hysteresis parameters
2017-03-14 10:44:58 +01:00
babrodtk
64bdc84a9f Add option to store/restore hysteresis parameters 2017-03-14 10:15:15 +01:00
Andreas Lauser
fc9885229c Merge pull request #212 from andlaus/satpressure_improvements
Saturation pressure & tabulation improvements
2017-03-09 21:30:42 +01:00
Kai Bao
770b0b863a handle a few NaN situations when evaluating saturationPressure() 2017-03-09 21:18:15 +01:00
Andreas Lauser
00659e5847 LiveOil, WetGas: improve the saturationPressure() methods
we now ask the tabulation class for the derivative directly and we do
not return negative saturation pressures anymore. (the latter is done
via putting the Newton method on "probation" if the saturation
pressure becomes negative. The first time it does this offense we try
to help it out of its mess, but if it happens again, we abort it and
return 0 as the saturation pressure.)
2017-03-09 17:45:10 +01:00
Andreas Lauser
777f8f0bc8 LiveOilPvt, WetGasPvt: do not copy table columns if this is not necessary 2017-03-09 17:45:10 +01:00
Andreas Lauser
0ab39c5f7a synchronize the evaluation code of Spline and Tabulated1DFunction
in particular out-of-range conditions are now no longer done using
assertations but always trigger an Opm::NumericalProblem to be thrown.
2017-03-09 17:45:10 +01:00
Andreas Lauser
d23801b098 Merge pull request #210 from andlaus/fix_isfinite_isnan
isfinite() and isnan() are supposed to return booleans
2017-03-06 19:14:39 +01:00
Andreas Lauser
005cf203d7 isfinite() and isnan() are supposed to return booleans
... not Evaluations. This was probably a copy-and-pasto.
2017-03-06 17:05:23 +01:00
Andreas Lauser
38cee86f6c Merge pull request #208 from andlaus/satregion_parameters
EclMaterialLawManager: add saturation region-specific material law parameters
2017-03-02 11:00:41 +01:00
Andreas Lauser
1f2d72aba1 EclMaterialLawManager: add saturation region-specific material law parameters
this is needed for the well model. Be aware that in the future this
will probably need to be changed to have one material parameter object
per connection instead of one per saturation region. This attitude
adjustment would be necessary to support endpoint scaling and
hysteresis in the well model, but so far it is unclear what the
reference simulator does.
2017-03-01 13:19:56 +01:00
Andreas Lauser
9d6a620680 Merge pull request #207 from andlaus/SCALECRS-from-EclipseState
Scalecrs from eclipse state
2017-02-24 17:33:22 +01:00
Andreas Lauser
dd587f10e3 Merge pull request #206 from andlaus/sort_by_default
make the "sortInputs" argument of the 1D function tabulation classes default to true
2017-02-24 16:54:33 +01:00
Andreas Lauser
b15f99de5e make this work with the latest master version of opm-parser 2017-02-24 16:51:28 +01:00
Jørgen Kvalsvik
956e7f5341 Read SCALECRS and ENDSCALE from EclipseState 2017-02-24 16:11:01 +01:00
Andreas Lauser
2bafb4f7ed make the "sortInputs" argument of the 1D function tabulation classes default to true
"1D function tabulation classes" means 'Opm::Spline' and
'Opm::Tabulated1DFunction'.

note that 'sortInputs' is a slight misnomer because these setter
methods still expect the arguments to be given in either ascending or
descending order of the 'x' values and if they are given in descending
order, the order internal copies of these arrays are reversed. a full
sort would be a bit more work because it requires to sort two
independent arrays synchronously.
2017-02-24 12:03:07 +01:00
Atgeirr Flø Rasmussen
2b566f5324 Merge pull request #205 from andlaus/no-splines-in-blackoil
do not use splines within the black-oil PVT objects
2017-02-24 08:58:59 +01:00
Andreas Lauser
b79baada99 do not use splines within the black-oil PVT objects
as far as I can see, the splines were only used to get a good initial
guess for the R(p) inversion code, so it should be safe to replace
them by piecewise linear functions.
2017-02-23 14:49:01 +01:00
Andreas Lauser
b168cae42b Merge pull request #204 from babrodtk/pdpb_output
Added bubble point and dew point functions
2017-02-17 09:13:43 +01:00
babrodtk
7aac046e04 Added bubble point and dew point functions 2017-02-17 08:49:40 +01:00
Andreas Lauser
a70059448f Merge pull request #201 from totto82/fixJFUNC
Adapt to unit changes in opm-parser for JFUNC
2017-02-09 09:54:44 +01:00
Andreas Lauser
47c6940de5 Merge pull request #202 from dr-robertk/PR/move-finalized_-to-base-class
[WIP] Move assertFinalized_ to base class to avoid code duplication.
2017-02-07 19:23:31 +01:00
Robert Kloefkorn
a6617c575e Restore default behavior of finalize_ 2017-02-07 16:28:14 +01:00
Robert Kloefkorn
e02a5d63e8 Converted all *Params classes to use EnsureFinalized. By default this feature is
enabled until an optional switch will be implemented.
2017-02-07 16:10:54 +01:00
Robert Kloefkorn
a4417d4a9f AssertFinalized --> EnsureFinalized. 2017-02-07 13:05:21 +01:00
Robert Kloefkorn
fd7059d6a0 Move assertFinalized_ to base class to avoid code duplication and allow for easy
toggle of functionality.
2017-02-07 11:29:38 +01:00
Tor Harald Sandve
2e51ae5079 Adpat to unit changes in opm-parser for JFUNC
The ECL Leverett function implementation "misuses" the pressure column
of the underlying tables (SWOF, SGOF, SWFN, etc.) for the
(dimensionless) J-Function. The correct converstion factor is now
applied in the parser and no converstions is needed no the opm-material
side.
2017-02-06 09:31:10 +01:00
Atgeirr Flø Rasmussen
b9d209a8b0 Merge pull request #196 from andlaus/consistency_improvements
Consistency improvements
2017-01-19 10:17:03 +01:00
Andreas Lauser
45da261142 move the '&' of references and the '*' of pointers to the type name
i.e., the new-style is `TypeName& var` instead of
`TypeName &var`. this patch is analogous to part of OPM/ewoms#83.
2017-01-18 17:57:54 +01:00
Andreas Lauser
19f1a27447 place the OPM_UNUSED macro after the variable name
this is analogous to OPM/ewoms#134.
2017-01-18 17:55:58 +01:00
Andreas Lauser
301be1ab8d Merge pull request #195 from andlaus/blackoilfluidsystem_isInitialized
BlackOilFluidSystem: add isInitialized()
2017-01-09 12:15:10 +01:00
Andreas Lauser
0d22035995 BlackOilFluidSystem: add isInitialized()
this allows to explicitly query if the fluid system has already been
initialized or not. the motiviation for this patch is that this method
can be used to avoid initializing the fluid system multiple times.
2017-01-09 12:11:06 +01:00
Andreas Lauser
affa356382 Merge pull request #194 from andlaus/valgrind_fix
properly initialize the VAPPAR parameters for wet gas and live oil
2017-01-06 09:20:42 +01:00
Andreas Lauser
a407546355 properly initialize the VAPPAR parameters for wet gas and live oil
valgrind complained about it. this is only relevant if initFromDeck()
is **not** used to initialize these objects. (e.g., this is the case
for the reservoir_blackoil_* tests of eWoms.)
2017-01-06 09:18:57 +01:00
Andreas Lauser
4e3b48688d Merge pull request #191 from atgeirr/remove-unused-deck-arg
Remove unused Deck arguments.
2017-01-02 11:01:25 +01:00
Atgeirr Flø Rasmussen
4abfb825eb Remove unused Deck arguments. 2017-01-02 09:46:30 +01:00
Pål Grønås Drange
42c739c679 Merge pull request #190 from andlaus/use_internalized_jfunc
use the new and shiny internalized JFUNC object from opm-parser
2016-12-30 09:33:52 +01:00
Andreas Lauser
7e0cb71002 use the new and shiny internalized JFUNC object from opm-parser
from my point of view, the main advantage is that the string
processing for the 'flag' and 'direction' items does no longer need to
be done by opm-material.
2016-12-29 13:48:25 +01:00
Andreas Lauser
8d27890544 Merge pull request #189 from andlaus/constexpr_quad
quad.hh: constexpressify std::numeric_limits<quad>
2016-12-27 22:17:00 +01:00
Andreas Lauser
f9aa063ba0 quad.hh: constexpressify std::numeric_limits<quad>
our oldest supported compiler (GCC 4.8) now has good enough constexpr
support and c++-2011 and above seem to use constexpr for the numeric
limits of the standard floating point types.
2016-12-27 17:01:06 +01:00
Atgeirr Flø Rasmussen
1f74a77730 Merge pull request #188 from andlaus/fix_twophase_ecl_hysteresis
EclTwoPhaseMaterial: do not update the oil-water hysteresis parameters for non-existing objects
2016-12-22 15:36:45 +01:00
Andreas Lauser
5bebabcd79 EclTwoPhaseMaterial: do not update the oil-water hysteresis parameters for non-existing objects
we must not update these parameters because the respective objects do
not exist in these cases. As far as I can see, both saturation function
objects need to exist for the gas-water twophase case despide the fact
that there is no oil because the capillary pressure between water and
gas is the sum of the capillary pressures between gas+oil and
oil+water. (also, I am not aware of any ECL keywords to provide the
gas-water saturation functions directly.)
2016-12-22 14:43:04 +01:00
Andreas Lauser
6075748dda Merge pull request #187 from andlaus/include_correct_header
quad.hh: include the correct header for std::runtime_error
2016-12-15 11:00:26 +01:00
Andreas Lauser
1d1f0e2095 quad.hh: include the correct header for std::runtime_error 2016-12-15 10:58:57 +01:00
Atgeirr Flø Rasmussen
16451b2bf9 Merge pull request #186 from andlaus/minor_reorg
Minor reorg
2016-12-14 21:46:05 +01:00
Andreas Lauser
4ab2b3dc70 move over the quadruple precision math code from eWoms 2016-12-14 12:36:09 +01:00
Andreas Lauser
39c5c94ac7 the new home of Valgrind.hpp is opm-common! 2016-12-14 09:46:21 +01:00
Andreas Lauser
a607daa6e1 delete ClassName.hpp
it is now replaced in favour of Dune::className() from dune/common/classname.hh
2016-12-14 09:46:16 +01:00
Andreas Lauser
36faf5d156 Merge pull request #185 from andlaus/inline_className
add missing "inline" to __float128 specialization of className()
2016-12-13 14:12:41 +01:00
Andreas Lauser
59c4d0f91b add missing "inline" to __float128 specialization of className()
if this specialization is not marked as "inline" it leads to linker
errors due to multiple definitions of the
`Opm::className<__float128>()` symbol. I consider this pretty
surprising behaviour of the C++ language because template functions do
not need to declared as `inline`.
2016-12-13 14:11:14 +01:00
Andreas Lauser
fde29dc7f3 Merge pull request #184 from andlaus/fix_2p_ecl_init
EclMaterialLawManager: fix and simpilfy the two-phase inititialization
2016-12-12 19:21:59 +01:00
Andreas Lauser
8fa3b6ee81 EclMaterialLawManager: fix and simpilfy the two-phase inititialization
this also fixes a bug where some parameter objects were not correctly
initialized in the two-phase (i.e., oil-water) case.
2016-12-12 14:39:43 +01:00
Atgeirr Flø Rasmussen
8dc4e0b2dc Merge pull request #179 from andlaus/move_Unused_hpp
delete Unused.hpp
2016-11-29 10:35:24 +01:00
Andreas Lauser
29de6a0174 Merge pull request #180 from andlaus/implement_two-phase_blackoil
make the BlackOilFluidSystem two-phase ready
2016-11-28 15:15:41 +01:00
Andreas Lauser
6592dc54f7 make the BlackOilFluidSystem two-phase ready 2016-11-22 15:10:28 +01:00
Andreas Lauser
69b2ebc5c6 delete Unused.hpp
it is moved to opm-common. use that file instead.
2016-11-22 14:43:00 +01:00
Joakim Hove
afa02f05d7 Merge pull request #178 from atgeirr/use-eclstate-tabdims
Use tabdims from EclipseState.
2016-11-18 11:30:19 +01:00
Atgeirr Flø Rasmussen
4514d5454c Use tabdims from EclipseState. 2016-11-17 22:39:32 +01:00
Andreas Lauser
051bff3e9b Merge pull request #177 from andlaus/fix_pedantic_warnings
fix some pedantic compiler warnings
2016-11-09 13:24:21 +01:00
Andreas Lauser
93fe614558 fix some pedantic compiler warnings
this allows the test suite of eWoms to be compiled on clang++ 3.8
using the following warning flags

```
    -Weverything
    -Wno-documentation
    -Wno-documentation-unknown-command
    -Wno-c++98-compat
    -Wno-c++98-compat-pedantic
    -Wno-undef
    -Wno-padded
    -Wno-global-constructors
    -Wno-exit-time-destructors
    -Wno-weak-vtables
    -Wno-float-equal
```

without triggering warnings in opm-material or eWoms.

Note that the test-suite for opm-material does *not* yet pass without
warnings with these flags because with these flags clang likes to
complain about reducing or increasing floating point precision which
results in a formidable nightmare. I will see what I can do about
these warnings in a separate PR.

v4: properly fix the unused parameter warnings for the valgrind client
requests. thanks to [at]atgeirr for finding the issue.
2016-11-09 12:06:36 +01:00
Andreas Lauser
4c0c570dbc Merge pull request #175 from dr-robertk/PR/reimp-evaluation
Re-implementation of Evaluation.
2016-11-04 12:42:52 +01:00
Robert Kloefkorn
fceaafdce1 [performance] re-implementation of Evaluation.hpp that avoid the use of high
level functions and clusters the data together in a CPU friendly way.
2016-11-01 21:57:59 +01:00
Andreas Lauser
acc29874aa Merge pull request #173 from andlaus/Evaluation_accessors
change Evaluation to accessor methods
2016-11-01 13:15:53 +01:00
Andreas Lauser
66ec787438 DenseAD: access the value and derivatives of Evaluations via accessor functions
this allows some flexibility of how an Evaluation object is
represented internally. the main motivation for this is to allow using
SIMD instruction which expect special data types as their operants.
2016-10-30 19:01:06 +01:00
Andreas Lauser
e047e85f54 DenseAD: simplify the min(), max() and abs() functions
note that while this simplifies the source code, the performance of
the binaries should be unaffected.
2016-10-30 19:01:06 +01:00
Andreas Lauser
48d570afc5 DenseAD: add copyDerivatives(x) and clearDerivatives() methods to Evaluation
this makes it possible to implement these functions more
efficiently...
2016-10-30 19:01:06 +01:00
Andreas Lauser
a289230202 Merge pull request #174 from andlaus/valgrind_cr_improvements
minor Valgrind client request improvements
2016-10-27 17:55:16 +02:00
Andreas Lauser
7bb2fdff20 fix some minor documentation bugs in Valgrind.hpp 2016-10-27 17:47:32 +02:00
Andreas Lauser
3f3d6355af Valgrind helpers: add client request to check if a memory range is accessible
the function is called `Valgrind::CheckAddressable(object)`.
2016-10-27 17:47:32 +02:00
Andreas Lauser
b7dd411c1c Merge pull request #169 from andlaus/implement_JFUNC
implement ECL-like Leverett capillary pressure scaling
2016-10-21 09:47:20 +02:00
Andreas Lauser
ab2650923d implement ECL-like Leverett capillary pressure scaling
i.e., this patch deals with the JFUNC ECL keyword.
2016-10-20 19:57:27 +02:00
jokva
0a09945fb6 Merge pull request #170 from jokva/remove-shared-ptr
The great shared_ptr purge
2016-10-20 19:19:13 +02:00
Andreas Lauser
c547e36877 Merge pull request #172 from andlaus/add_isfinite_and_isnan
MathToolbox: add isfinite() and isnan() methods
2016-10-19 21:49:24 +02:00
Andreas Lauser
98898cae1d MathToolbox: add isfinite() and isnan() methods
for primitive floating point objects, these correspond to
std::isfinite() and std::isnan() while for evaluations, they trigger
on the evaluation's value or any of its derivatives being non-finite
or NaN. (i.e., for evaluations they should be better called
containsnonfinite(), containsnan().)
2016-10-19 21:46:23 +02:00
Andreas Lauser
34c9e1efe9 Merge pull request #171 from andlaus/improve_comment
H2O-Air henry coefficient: improve citation in comment
2016-10-19 14:55:50 +02:00
Andreas Lauser
c84dca9f95 H2O-Air henry coefficient: improve citation in comment
this change has been motivated by a recent Dumux commit...
2016-10-19 14:52:22 +02:00
Jørgen Kvalsvik
2532f1e56e Update to shared_ptr-less parser interface. 2016-10-13 14:49:48 +02:00
Tor Harald Sandve
cc6dcccf85 Merge pull request #168 from andlaus/fix_zero_base_pow
DenseAD: special case the base == 0.0 case
2016-09-16 09:07:34 +02:00
Andreas Lauser
1236009d3e DenseAD: special case the base == 0.0 case
if this is not done the generic code produces NaNs. (either by using
the result of ln(0.0) or by means of a division by zero.)

This seems to fix the linearization of flow_ebos for "Model 2".
2016-09-16 00:09:45 +02:00
Andreas Lauser
1941f9717f Merge pull request #167 from qilicun/Remove-endscale-options-check
remove the ENDSCALE options check, they're handled by flow.
2016-09-15 13:56:49 +02:00
Liu Ming
04c05d658d remove the ENDSCALE options check, they're handled by flow. 2016-09-09 10:29:31 +08:00
Andreas Lauser
18c44e7285 Merge pull request #166 from babrodtk/warning_fixes
Fixed warning of (potentially) uninitialized variables
2016-09-06 09:43:19 +02:00
babrodtk
c67a7d3a25 Fixed warning of (potentially) uninitialized variable 2016-09-06 08:09:33 +02:00
Atgeirr Flø Rasmussen
32c1d6b66f Merge pull request #162 from andlaus/densead_convenience_functions
dense AD: introduce convenience functions
2016-08-15 12:20:19 +02:00
Andreas Lauser
e33fc441b3 Dense AD convenience functions: introduce scalarValue(x) and getValue(x)
`getValue(x)` should be better called `value(x)` but this leads to
really cryptic compiler errors which seem to be related to the fact
that the Evaluation class has a `value` attribute (this is for GCC
5.2.1).
2016-08-11 16:54:15 +02:00
Andreas Lauser
d21a6fbefe dense AD convenience functions: add decay<LhsEval>()
with this, evaluation objects can be decayed via
`Opm::decay<Scalar>(x)`. since function templates do not require a
'template' qualifier, it is a bigger advantage for this function that
for the mathematical ones. (the conventional way to do this is way
more verbose:

```c++
Opm::MathToolbox<Evaluation>::template decay<Scalar>(x)
```
)
2016-08-11 16:43:10 +02:00
Andreas Lauser
62de45a665 dense AD convenience functions: determine the return type in a smarter way
we now take the type which can by assigned by the other. this is still
not perfect because the result may be surprising for cases like
'double' and 'int', but it is much better than the situation before.
2016-08-11 16:43:10 +02:00
Andreas Lauser
9f465784a8 dense AD: introduce convenience functions
this PR was inspired by one of @atgeirr's recent comments. it allows
to get rid if the `MathToolbox<Eval>` detour for the dense AD code in
most cases: e.g. instead of writing

```c++
template <class Eval>
Eval f(const Eval& val)
{ return Opm::MathToolbox<Eval>::sqrt(val); }
```

one can simply write

```c++
template <class Eval>
Eval f(const Eval& val)
{ return Opm::sqrt(val); }
```

and it will work transparently with DenseAD `Evaluation` objects and
primitive floating point values.

one complication of this is that the type of the `Evaluation` object
does not need to be explicitly defined. for functions which take more
than one argument (like e.g. `pow()`, `min()` and `max()`), it is thus
assumed that the type of the result is the same as the type of the
first argument.

another drawback is that when both, the contents of the `Opm::` and
the `std::` namespaces are implicitly available, it is not clear to me
what's used for primitive floating point values. (it seems to compile
but IMO it could lead to surprising behaviour. thus, please only merge
if you consider the benefits of these convenience functions to be
greater than their drawbacks.)
2016-08-11 15:54:03 +02:00
Andreas Lauser
32e5630ae7 Merge pull request #160 from andlaus/fix_vappars
fix inconsistency in the VAPPARS treatment of wet gas
2016-08-09 13:05:25 +02:00
Andreas Lauser
219ec18c6e fix inconsistency in the VAPPARS treatment of wet gas
in contrast to live oil, there it was not conditional on whether the
oil saturation was smaller than the maximum observed one.
2016-08-09 13:03:06 +02:00
Andreas Lauser
7910a54947 Merge pull request #159 from pgdr/downstream-transmult-and-shared_ptrs
use ref constructor for EclipseState
2016-08-08 12:51:54 +02:00
Pål Grønås Drange
e7a89ea838 use ref constructor for EclipseState 2016-08-08 10:04:45 +02:00
Andreas Lauser
30a6d3ea87 Merge pull request #158 from andlaus/VAPPARS_changes
blackoil PVT: treat the maximum oil saturation for VAPPARS a constant
2016-08-02 15:15:51 +02:00
Andreas Lauser
9074f1ccca blackoil PVT: treat the maximum oil saturation for VAPPARS a constant
also, only calculate a factor if the currently observed oil saturation
is smaller than the maximum oil saturation. The new code is not
completely equivalent to the old one because derivatives are not
considered if the oil saturation increases, but the differences should
be small and they should be closer to how the current master version
of opm-simulators handles VAPPARS.
2016-08-02 15:10:49 +02:00
Andreas Lauser
c445e7414e Merge pull request #154 from andlaus/implement_vappars
implement the E100 VAPPARS keyword
2016-07-06 18:41:33 +02:00
Atgeirr Flø Rasmussen
739bb51cc2 Merge pull request #156 from andlaus/fix_MaterialLawManager
MaterialLawManager: don't use the materialLawParamsPointer() method in materialLawParams()
2016-07-06 14:52:04 +02:00
Andreas Lauser
0d4996f43f EclMaterialLawManager: rename the *Pointer() methods to something more appropriate
they are now called materialLawParamsPointerReferenceHack() and
oilWaterScaledEpsInfoDrainagePointerReferenceHack() which -- in my
opinion -- describes better what they do and which are also
sufficiently clunky and scary names to deter people from using them.
2016-07-06 12:57:51 +02:00
Andreas Lauser
7192a3495e MaterialLawManager: don't use the materialLawParamsPointer() method in materialLawParams()
this fixes the issue of https://github.com/OPM/opm-material/pull/155
in a better manner. (I hope.)
2016-07-06 11:12:09 +02:00
Andreas Lauser
30d3b68df4 implement the E100 VAPPARS keyword
this is yet another crazy Eclipse hack: it prevents the dissolved
component to be fully assimilated by solvent phases if the maximum oil
phase saturation seen during the simulation stays below a given
limit...
2016-07-05 17:16:58 +02:00
Andreas Lauser
56022bb9f6 use 1e30 instead of 1e100 to indicate a "way too large" value
10^100 cannot be represented by single-precision floating point values
and 10^30 is large enough considering the fact that the distance from
Earth to Alpha-Centauri is "only" about 4*10^16 m...
2016-07-05 17:00:40 +02:00
Atgeirr Flø Rasmussen
b50aa8a094 Silence unused argument warning. 2016-06-29 09:06:29 +02:00
Andreas Lauser
f20b87ae1f Merge pull request #151 from andlaus/introduce_phasePresence
FluidStates: introduce phaseIsPresence(phaseIdx)
2016-06-27 15:49:44 +02:00
Andreas Lauser
4b01433dcc FluidStates: introduce phaseIsPresence(phaseIdx)
by default, this just checks if the saturation of the incriminating
phase is larger than 0, but in some cases (i.e., black-oil) the
calling code might have a different opinion: E.g., the black-oil model
looks at the primary variables to determine the phase presence.
2016-06-27 15:39:07 +02:00
Andreas Lauser
a4200d81c8 Merge pull request #150 from andlaus/add_phase_component_mappings
BlackOilFluidSystem: add mappings from the phase index to its solute and solvent components
2016-06-25 12:28:51 +02:00
Andreas Lauser
afe4f666c8 BlackOilFluidSystem: add mappings from the phase index to its solute and solvent components
this is quite black-oil specific: it assumes that each phase has at
most one solute. (i.e., the number of components per phase is at most
two.)
2016-06-25 12:22:36 +02:00
Andreas Lauser
55c2bc9c45 Merge pull request #147 from andlaus/localad_to_densead
rename "LocalAd" to "DenseAd"
2016-06-06 14:02:36 +02:00
Andreas Lauser
ad253d699f rename MathToolbox::toLhs to MathToolbox::decay
this is because this method is completely analogous to std::decay()...
2016-06-03 21:28:45 +02:00
Andreas Lauser
9bbe67d19f rename "LocalAd" to "DenseAd"
Since "dense automatic differentiation" describes what this code is
all about much better in my opinion. ("Local AD" is just a possible
use case in the context of PDE discretization.)
2016-06-03 21:28:45 +02:00
Andreas Lauser
8778e29ae2 Merge pull request #146 from andlaus/fix_dune_2.3_warnings
fix warnings from Evaluation.hpp when using Dune 2.3
2016-05-14 12:10:56 +02:00
Andreas Lauser
a33a1eac86 fix warnings from Evaluation.hpp when using Dune 2.3
these warnings were caused by the fmatrix.hh header being included
before Evaluation.hpp. While they were harmeless, they were annoying.

(I did not discover this earlier because I normally use Dune 2.4 which
does not have this particular issue.)
2016-05-14 12:04:50 +02:00
Andreas Lauser
405031f6b5 Merge pull request #143 from andlaus/fix_build
fix the build
2016-04-20 16:16:02 +02:00
Andreas Lauser
e245988709 fix the build
this change is trivial: seems like a rename not accounted for for some
reason.
2016-04-20 16:14:22 +02:00
Joakim Hove
e48817fb35 Merge pull request #141 from pgdr/eclipsegrid-is-input
Using getInputGrid API from Parser
2016-04-20 15:57:21 +02:00
Atgeirr Flø Rasmussen
4d253a1a5a Merge pull request #142 from andlaus/various_fixes
Various fixes
2016-04-20 15:38:49 +02:00
Andreas Lauser
71da62bebe fix some signedness issues
mainly these issues stemmed from the fact that floating point values
can be negative and casting negative values to unsigned integers leads
to very large unsigned values instead of 0.
2016-04-20 15:37:09 +02:00
Andreas Lauser
05bf95d232 use Toolbox::scalarValue() instead of Toolbox::value() where appropriate
in opm-material "where appropriate" is equivalent to "everywhere" as
far as I can see.
2016-04-20 11:38:17 +02:00
Andreas Lauser
c132bcc018 H2O: fix a Scalar vs Evaluation issue
actually, this patch should not change the result at all, but the code
is probably less confusing that way...
2016-04-20 11:38:15 +02:00
Andreas Lauser
c764df8166 Brine: fix some Scalar vs Evaluation issues 2016-04-20 11:38:13 +02:00
Andreas Lauser
70c4000f8b Evaluation<>: fix the corner cases where the scalar object which is used is part of the evaluation itself
this only affects `operator/=()` and `operator*=()`, the addition and
subtraction operators will work fine even if `other` is contained in
`this`.
2016-04-20 11:38:11 +02:00
Pål Grønås Drange
a5b70b1119 Using getInputGrid API from Parser 2016-04-19 16:54:35 +02:00
Andreas Lauser
13c9df45f6 Merge pull request #140 from atgeirr/silence-warning
Silence warnings
2016-04-19 14:39:00 +02:00
Atgeirr Flø Rasmussen
0a4578ad15 Silence warning from Dune header. 2016-04-18 15:11:40 +02:00
Atgeirr Flø Rasmussen
6bc5ee0d0e Silence unused argument. 2016-04-18 15:11:16 +02:00
Andreas Lauser
ee4dd837ea Merge pull request #138 from andlaus/nested_ad
Nested AD and opm-material spring cleaning
2016-04-18 11:01:03 +02:00
Andreas Lauser
3e7e35a2a1 squelch masochisic compiler warnings
this is the clang-3.9 and GCC 6.0 edition for the OPM 2016.04 release.
2016-04-17 11:42:33 +02:00
Andreas Lauser
28333c3f54 make the unit tests for the flash solvers bite if they detect an error
so far, they only printed a warning. in this case the error message
was usually ignored and the test was counted as 'passed'. (before the
switch of the flash solvers to use automatic differentiation, this
happened in some cases where single precision floating point scalars
were used.)

not anymore: now an exception is thrown and the test is aborted if an
error is detected.
2016-04-17 11:42:33 +02:00
Andreas Lauser
dbb707ede5 convert the flash constraints solvers to use automatic differentiation
this fixes some precision issues with single-precision floating point
values as a nice side effect.
2016-04-17 11:42:33 +02:00
Andreas Lauser
7a27c5398e allow the Peng-Robinson EOS to be used with nested automatic differentiation 2016-04-17 11:42:33 +02:00
Andreas Lauser
d55f213653 make it possible to nest function evaluation objects
IMO this is pretty cool because it allows to transparantly calculate
higher order derivatives. for example this enables to implement the
linearization stage of higher-order non-linear solvers without much
additional effort compared to just evaluating the function in
question. (essentially, such higher order non-linear solvers are based
on truncating the Taylor series not after the first term -- like for the
Newton scheme -- but later. That said, they require to solve linear
systems of equations which involve tensors of orders greater than 2,
so they are not really practical as far as I can see.)

A more practical motivation for this is to allow the constraint
solvers to be used in "nested mode", i.e., linearizing the system of
equations they need to solve using automatic differentiation, but
allowing the value objects which are passed to the constraint solvers
be function evaluations themselves. (E.g. the result of a flash
calculation can also include the derivatives with regard to the
primary variables of the flow model. Note that the individual
constraint solvers need to some patches to make this work.)
2016-04-17 11:42:33 +02:00
Andreas Lauser
573e45d1a4 remove MathToolbox::passThroughOrCreateConstant()
this method is an artifact from the beginning of the automatic
differentiation code and is not needed anymore: its original pupose
was to be able to retain a full function evaluation object if it was
available or a function evaluation object representing a constant
function if only a primitive scalar is available. Nowadays, the method
can be replaced by a direct initialization:

template <class T, class V>
T fn(const V& v)
{ return T(v); }

is equivalent to

template <class T, class V>
T fn(const V& v)
{
    typedef Opm::MathToolbox<T> Toolbox;
    return passThroughOrCreateConstant(v);
}
2016-04-17 11:42:33 +02:00
Andreas Lauser
f94770092e move the approximate comparison code from the Evaluation to the Toolbox
i.e. the isSame() method. The reason is that this way it works
transparently with primitive floating point types.
2016-04-17 11:42:33 +02:00
Andreas Lauser
47c3d11403 Evaluation<>: remove the concept of "tags"
In my recent experience it did more harm than good: tags often made
the compiler errors mucht longer and more unreadable, and I have not
encountered a single instance where they were really helpful...
2016-04-17 11:40:59 +02:00
Andreas Lauser
8679d3a23c initialize MPI for all unit tests
This started to cause crashes for me. I don't really have an idea why,
but it is not too bad of a thing to do anyway...
2016-04-17 11:28:06 +02:00
Andreas Lauser
6f9451ba06 fluid systems: make the ParameterCache mechanism work with Evaluation<>
so far, using function evaluation objects instead of primitive
floating point scalars only worked for trivial parameter caches which
do not store any values (most of the time, this means that the
ParameterCache is `NullParameterCache`), or it explicitly did not work
(like for `Spe5ParameterCache`). this patch fixes the problem by
making the parameter caches of fluid systems template classes which
are templated on the type of scalar values. On the flipside, this
requires changes to all downstream modules that use fluid systems.
2016-04-17 11:28:04 +02:00
Andreas Lauser
d44dd50cb7 reduce the execution time of test_fluidsystems
this is done by reducing the default resolution of tabulated
components for the relevant fluid systems.
2016-04-17 11:28:02 +02:00
Andreas Lauser
801b1fef77 make test_pengrobinson faster
again, we just use less samples...
2016-04-17 11:28:00 +02:00
Andreas Lauser
35b5ad833b reduce the excution time needed by test_tabulation
instead of 200 samples in the pressure direction, let's be confident
with only 50...
2016-04-17 11:27:57 +02:00
Pål Grønås Drange
ac0652805d Using API get3DProperties() 2016-04-11 14:59:01 +02:00
Pål Grønås Drange
02beac295c Merge branch 'use-eclipse3dproperties' of github.com:pgdr/opm-material into use-eclipse3dproperties 2016-04-08 15:39:16 +02:00
Pål Grønås Drange
f1405bbafd Updated opm-material to use new opm-parser Eclipse3DProperties API 2016-04-08 15:31:32 +02:00
Pål Grønås Drange
65d9ee2924 opm-material uses new Eclipse3DProperties API 2016-04-05 11:47:40 +02:00
Pål Grønås Drange
6eddf22fc4 added lacking references in auto types (SimpleTable) 2016-04-01 16:44:23 +02:00
Pål Grønås Drange
88249811fc update opm-material repo to use Eclipse3DProperties API 2016-04-01 15:52:25 +02:00
Andreas Lauser
013eb6c17e Merge pull request #133 from andlaus/cleanup_preambles
clean up the licensing preable of source files
2016-03-17 13:12:51 +01:00
Joakim Hove
0f36222f7b Merge pull request #134 from qilicun/rename-ParseMode
rename ParserMode as ParseContext.
2016-03-17 09:51:38 +01:00
Liu Ming
bbf8d5d3a3 rename ParserMode as ParseContext. 2016-03-17 08:49:02 +08:00
Andreas Lauser
da401551be clean up the licensing preable of source files
this patch removes the in-file lists in favor of a global list of in
the COPYING file. this is done because (a) maintaining a list of
authors at the beginning of each source file is a major pain in the
a**, (b) for this reason, the list of authors was not accurate in
about 85% of all cases where more than one person was involved and (c)
this list is not legally binding in any way (the copyright is at the
person who authored a given change; if these lists had any legal
relevance, one could "aquire" the copyright of the module by forking
it and replacing the lists...)
2016-03-15 00:58:09 +01:00
Tor Harald Sandve
78fcbb1ed3 Merge pull request #132 from andlaus/ecl_water_viscosibility
handle the "viscosibility" of water with constant compressibility as documented by the ECL RM
2016-03-09 11:31:58 +01:00
Andreas Lauser
03c2ee8b4e handle the "viscosibility" of water with constant compressibility as documented by the ECL RM
this is basically a revert of 1d2ad56ba1.
2016-03-07 15:56:36 +01:00
Andreas Lauser
9e6c38b06b Merge pull request #131 from andlaus/always_copy_on_toLhs
make MathToolbox::toLhs() always return a copy again
2016-03-07 13:56:49 +01:00
Andreas Lauser
ea6899d032 Merge pull request #130 from atgeirr/silence-warnings
Silence unused argument warnings.
2016-03-05 19:06:49 +01:00
Andreas Lauser
362374daea make MathToolbox::toLhs() always return a copy again
in my testing, the GCC SVN version from 4th of March causes problems
if lvalue references are just passed through and neither GCC-5 nor
clang 3.6 show any obvious differences in performance. (I guess that's
because of the copy elision compiler optimizations in conjunction with
inlining.)

It is also worthwhile to know that clang 3.6 is about 20% faster with
ebos than both, GCC-6 and GCC-5. I can only speculate why this is the
case, but since the performance improvement seems to evenly apply to
the linearization and linear-solve parts, the auto-vectorizer of clang
possibly works better for ebos than the one of GCC...
2016-03-05 15:22:05 +01:00
Atgeirr Flø Rasmussen
46d1a512c2 Silence unused argument warnings. 2016-02-29 10:35:33 +01:00
Andreas Lauser
8eadacde62 Merge pull request #129 from jokva/fix-header-parser-695
Add missing opm-parser headers
2016-02-26 12:24:50 +01:00
Jørgen Kvalsvik
e467684137 Add missing opm-parser headers
opm-parser pull #695
https://github.com/OPM/opm-parser/pull/695
2016-02-26 11:38:53 +01:00
Andreas Lauser
88e85042e0 Merge pull request #127 from andlaus/fix_twophase_ecl_decks
black-oil PVT: bail out from trying to initialize PVT objects for inactive phases
2016-02-21 18:05:13 +01:00
Andreas Lauser
9b9816d8e9 Merge pull request #128 from andlaus/fix_deprecation_warnings
fix a bunch of deprecation warnings caused by OPM/opm-parser#687
2016-02-19 23:36:45 +01:00
Andreas Lauser
e30b43ad7e fix a bunch of deprecation warnings caused by OPM/opm-parser#687 2016-02-19 23:32:52 +01:00
Andreas Lauser
32980c57d9 black-oil PVT: bail out from trying to initialize PVT objects for inactive phases
this should fix twophase decks, see
https://github.com/OPM/opm-autodiff/pull/576#issuecomment-185770114.
2016-02-19 14:22:40 +01:00
Joakim Hove
54542d997b Merge pull request #122 from jokva/unique-auto-deck
Change Deck access methods/types to references
2016-02-18 22:59:51 +01:00
Andreas Lauser
d5bf1b637a Merge pull request #126 from andlaus/export_drainage_eps_points
EclMaterialLawManager: make the method which provides the scaled drainage end points public
2016-02-17 18:59:37 +01:00
Andreas Lauser
b8d08e7b52 EclMaterialLawManager: make the function which provides the scaled drainage end points public
That is because they might have to modified externally (e.g. if
SWATINIT is computed and applied externally).
2016-02-17 18:56:54 +01:00
Jørgen Kvalsvik
cedb629f6d Change Deck access methods/types to references
opm-parser#677 changes the return types for the Deck family of classes.
This patch fixes all broken code from that patch set.

https://github.com/OPM/opm-parser/pull/677
2016-02-16 16:09:56 +01:00
Andreas Lauser
09f02eb2f4 fluid states: clean up the remaining modules w.r.t. references vs values 2016-02-12 18:43:15 +01:00
Andreas Lauser
307cc6c0f0 clean up the overlay fluid state w.r.t. the type which they return
if the base fluid state returns a reference, the overlay fluid state
should just pass it through instead if copying it. The difference
became relevant with the introduction of Evaluations for localized
AD. (is not relevant if Scalars are floating point values, which was
the only choice when the overlay fluid states were written.)
2016-02-12 18:43:15 +01:00
Andreas Lauser
20c78f5757 test_fluidsystems: improve the naming of the template arguments of the test functions 2016-02-12 18:43:15 +01:00
Andreas Lauser
3ad0c087ca distinguish between rvalues and lvalues in MathToolbox::toLhs<LhsEval>()
the problem is that references to lvalues can be just passed through,
whilst the objects the rvalue references point are temporary and thus
need need to be copied. Fixing this issue forced me to go into the
rabbit hole of the c++ memory model, but at least I guess I now know
what rvalue references ('Foo&&' instead of 'Foo&') are good for...
2016-02-12 18:43:08 +01:00
Andreas Lauser
460dd578d0 Merge pull request #124 from andlaus/valgrind_fix
test_fluidsystems: fix valgrind complaints about unused memory
2016-02-12 11:52:51 +01:00
Andreas Lauser
78db8b01d5 test_fluidsystems: fix valgrind complaints about unused memory
I doubt that this is the reason for this test's segfault on Jenkins,
but it that was a real (if minor) issue...
2016-02-12 11:49:38 +01:00
Andreas Lauser
76af0dd218 Merge pull request #120 from andlaus/fix_toLhs
MathToolbox: return a constant reference for toLhs() (if possible)
2016-02-05 18:56:39 +01:00
Andreas Lauser
39933a747b MathToolbox: return a constant reference for toLhs() (if possible)
also improve the documentation somewhat. (it was a bit "raw on its
teeth".)
2016-02-05 18:53:05 +01:00
Andreas Lauser
47e89e2c9d Merge pull request #118 from andlaus/fix_blackoil_pvt_unit_test
fix the unit test for the blackoil PVT API
2016-02-03 16:13:01 +01:00
Andreas Lauser
7b35935099 fix the unit test for the blackoil PVT API
mea culpa, I forgot to remove the calls to the initEnd() method after
fc933ef94d.
2016-02-03 15:56:49 +01:00
Andreas Lauser
3d9397d274 Merge pull request #115 from andlaus/fix_headercheck
squelch extra-pedantic clang and GCC warnings and fix the headercheck
2016-02-01 13:41:28 +01:00
Andreas Lauser
4dc417fcca squelch extra-pedantic clang and GCC warnings and fix the headercheck
once more, OPM/opm-parser#661 was the culprit for the headercheck.
2016-02-01 13:39:29 +01:00
Atgeirr Flø Rasmussen
051a17cdf4 Merge pull request #114 from andlaus/blackoil_improvements
Blackoil improvements
2016-02-01 13:38:26 +01:00
Andreas Lauser
397f6c67a7 LocalAd: fix the return type of toLhs<LhsEval>()
instead of always copying to the return value we now simply pass
through a const reference if possible.
2016-01-30 14:33:37 +01:00
Andreas Lauser
bb82a6b5e3 black-oil fluid system: take advantage of fluid states which provide Rs() and Rv() directly
this avoids converting Rs and Rv to mass fractions (as provided by the
generic fluid system API) just to immediately convert them back to
dissolution factors (as required by the blackoil PVT objects).

Note that the implementation of this is a bit ugly because it requires
advanced C-preprocessor usage and higher
template-meta-programming-foo. Any ideas of how to do this in a
simpler fashion are welcome.
2016-01-29 19:58:07 +01:00
Andreas Lauser
c0d680adb6 black-oil PVT: implement thermal PVT properties
the primary goal of this patch is to implement what's currently
provided by the opm-core PVT classes, and it is thus not very
comprehensive: some non-standard keywords are required (e.g.,
GCOMPIDX), there has been some guess-working going on, some approaches
are only consequences of what the ECL documentation says (but is not
mentioned explicitly anywhere) and the relations for enthalpy are
still missing (i.e., the quanties provided are insufficient to
implement an energy conservation equation).

the patch works by adding a boolean 'enableTemperature' template
parameter to the multiplexer classes which is set to 'true' by
default. if it is detected that the PVT properties are thermally
dependent the respective *PvtThermal class is used (which in turn
creates an isothermal multiplexer internally).

the schema for the names of the thermal PVT classes
(${PHASE}PvtThermal) is a bit inconsistent with that used for
isothermal PVT classes (${APPROACH}${PHASE}Pvt) which was done to
avoid naming conflicts with the current opm-core PVT classes.
2016-01-29 19:57:58 +01:00
Andreas Lauser
2fce78289f black-oil fluid system: introduce methods to convert mole- into mass fractions
... only for the solutes of hydrocarbon phases.
2016-01-29 19:42:51 +01:00
Andreas Lauser
abc0caea7a black-oil PVT: provide inverse formation volume factors
this makes things go less in circles: before this patch, the
interpolation happened on the inverse formation volume factors, the
PVT classes inverted the result to get the FVF and then the calling
code divided by what fell out of this. Now, the calling code can
directly multiply with the result of the interpolation.
2016-01-29 19:42:09 +01:00
Andreas Lauser
c780233ad1 black-oil PVT: remove the density related methods
instead, the calling code needs to directly use the formation volume
factors to calculate it.
2016-01-29 19:27:52 +01:00
Andreas Lauser
d29c85dc9a blackoil-pvt: introduce a numRegions() method 2016-01-29 19:27:52 +01:00
Andreas Lauser
fc933ef94d blackoil-pvt: simplify the initialization from an ECL-deck
now if the object is initialized using the initFromDeck() method, a
call to initEnd() is not required anymore. IMO, this makes the API
easier to use and more bullet-proof.
2016-01-29 19:27:52 +01:00
Andreas Lauser
fa5a2f66a1 make the meat of the unit tests for fluid states and fluid systems available publicly 2016-01-29 19:27:52 +01:00
Andreas Lauser
58c9022a98 fix a compiler warning 2016-01-29 19:27:52 +01:00
Andreas Lauser
3e54344556 black-oil fluid system: remove some spurious spaces 2016-01-29 19:27:52 +01:00
Andreas Lauser
7c15621160 pvt multiplexers: don't spill the multiplexer macros
the #undef directives were wrong or missing...
2016-01-29 19:27:52 +01:00
Andreas Lauser
10fb871c64 Merge pull request #113 from jokva/clean-up-headers
Improve includes from opm-parser
2016-01-29 14:58:58 +01:00
Jørgen Kvalsvik
3bbfa75644 Improve includes from opm-parser
Adopting to opm-parser PR#661, add previously missing includes.

https://github.com/OPM/opm-parser/pull/661
2016-01-26 13:27:25 +01:00
Andreas Lauser
639f1be605 Merge pull request #112 from andlaus/autonomous_headers
make all headers stand-alone again
2016-01-21 13:18:22 +01:00
Andreas Lauser
5d270f4436 make all headers stand-alone again
i.e., after this all headers are supposed to be fully autonomous again
and can thus be included without preconditions. this property broke
when OPM/opm-parser#656 was merged.
2016-01-21 13:14:01 +01:00
Joakim Hove
2fdacd3f74 Merge pull request #111 from jokva/fix-header-include-parser656
Fixes missing includes (opm-parser PR-656)
2016-01-21 11:58:38 +01:00
Jørgen Kvalsvik
d1a2924e08 Fixes missing includes (opm-parser PR-656)
Adds missing includes which due to PR-656 in opm-parser are no longer
automatically pulled from other headers.
2016-01-19 14:11:44 +01:00
Andreas Lauser
515475a187 Merge pull request #109 from dr-robertk/PR/multiple-precision
Add tests using Scalar=float (try 2).
2016-01-15 22:30:52 +01:00
dr-robertk
925a014b83 Merge pull request #1 from andlaus/fix_float
Fix float
2016-01-15 14:23:08 -07:00
Andreas Lauser
54cb64bcb0 enable testing for Scalar == float for all unit tests
for some unit tests the precision of `float` is insufficient. To at
least enforce that the tested code compiles with `float` as Scalar,
they are wrapped by `while(false)` statements.
2016-01-15 16:07:40 +01:00
Andreas Lauser
29254f2fcc components: fix build failures caused by implicit casts to double
normally this is not a problem, but template functions which take two
arguments, will break, i.e., the following will not compile

```c++
float f = 1.23;
std::max(f, 2.0*f);
```

this is because the second argument for max gets silently cast to
`double` which causes the compiler to be confused because it cannot
determine a uniform type for the arguments passed to
std::max<T>(a, b)...
2016-01-15 16:03:29 +01:00
Andreas Lauser
fe44bcc8f9 Spline: consistently use the same (template) code for the scalar and Evaluation<> cases 2016-01-15 16:01:45 +01:00
Robert Kloefkorn
2a2b5b91de tests: added checks with Scalar=float. All tests compile with Scalar=float, but only
some work.
2016-01-14 17:28:07 -07:00
Robert Kloefkorn
92062f009c PengRobinson: make compile when Scalar is not double. 2016-01-14 17:27:44 -07:00
Robert Kloefkorn
c6c44acb4c LiveOilPvt/WetGasPvt: return value of vectorCopy is std::vector<double>. 2016-01-14 17:27:11 -07:00
Andreas Lauser
e468219af7 Merge pull request #107 from andlaus/fix_tables
fix the table handling code for live oil
2016-01-14 19:41:05 +01:00
Andreas Lauser
cf7d072399 remove some unneeded spaces 2016-01-14 19:35:21 +01:00
Andreas Lauser
890fdf54f7 fix the table handling code for live oil
the recent table refactoring replaced the compile-time-safe approach
to columns (i.e., table.getFooColumn()) by a generic method which
requires a magic cookie (i.e., table.getColumn("FOO")). Unfortunately,
this went belly-up with the viscosity column of the PVTO table (here
the magic constant is "MU" and not "MUO". Note that in this respect,
opm-parser is inconsistent w.r.t. the column of the formation volume
factor which is called "BO" and not "B".)

there were also some additional typos: the gas dissolution factor is
"RS" and the pressure of oil is "P".

It probably gets time to make the opm-core/opm-autodiff PVT code use
the stuff from opm-material so that this receives some run-time
testing with `flow` during development. (currently this is only used
by `ebos`...)
2016-01-14 19:33:39 +01:00
Joakim Hove
df618f43a6 Merge pull request #103 from joakim-hove/table-column
Using new table api
2016-01-08 15:29:04 +01:00
Joakim Hove
d8898a1c1a Update EclMateriallawmanager to use new Table api. 2016-01-08 14:35:23 +01:00
Joakim Hove
20310cdd81 Updated LiveOilPvt and WetGasPvt to new Table api. 2016-01-08 14:35:22 +01:00
Andreas Lauser
e2e05f53f6 Merge pull request #106 from andlaus/remove_asserts
EclEpsScalingPoints: Remove some spurious asserations
2016-01-05 12:10:46 +01:00
Andreas Lauser
24324e4e94 Merge pull request #105 from joakim-hove/remove-assert
Removed assert - allow nonzero min swat.
2016-01-05 12:08:17 +01:00
Joakim Hove
bc56a40992 Removed assert - allow nonzero min swat. 2016-01-05 12:02:22 +01:00
Andreas Lauser
10f2397c6a EclEpsScalingPoints: Remove some spurious asserations
these were added to make sure that the input data confirms to what is
required by the ECL documentation. It is better to do these
consistency checks externally, though. (and also not just in debug
mode.)
2016-01-05 12:00:39 +01:00
Atgeirr Flø Rasmussen
18f5863d4e Merge pull request #102 from andlaus/blackoil_API_refactor
Blackoil api refactor
2016-01-05 08:20:20 +01:00
Andreas Lauser
7068aa3669 fix clang-3.5 and GCC-4.9 extra-pedantic warnings
hopefully this fixes all of them. While doing this, I noticed that the
warnings produced by GCC 5 and GCC 4.9 differ. I did not try to
compile it with GCC 5, though.
2016-01-04 15:31:43 +01:00
Andreas Lauser
b515b9ddc0 remove some unneeded consts
they do not affect the result of the compilation and IMO just look
ugly. (I'm aware that there are other opinions.)
2016-01-04 15:31:38 +01:00
Andreas Lauser
b6bca92907 NcpFlash: change the default tolerances
for the most common case (i.e., Scalar == double) the previous method
lead to a tolerance of 10^-3 (relative) which is way too much if an
absolute tolerance of 10^-8 kg/(m^3*s) is required by the model.
2016-01-04 15:31:36 +01:00
Andreas Lauser
9c0fe9eb4c black-oil fluid system: some stylistic and comment cleanups 2016-01-04 15:31:34 +01:00
Andreas Lauser
8d1e470559 black-oil fluid system: some functional changes
- avoid the discontinuity between saturated and undersaturated
  hydrocarbon density and viscosity. This introduces a dependency of
  density and viscosity on the saturation of gas and oil which does
  not make much sense from a physical POV. (note that the dependency
  on the phase saturations was already there, but it was a
  discontinuous one, i.e., it dependeded on S_{o,g} > 0 instead of on
  S_{o,g})
- fixes for the fugacityCoefficient() method (it now also works for
  wet gas and dead oil, i.e., it avoids a division by zero for
  immiscible hydrocarbon phases.)
2016-01-04 15:31:32 +01:00
Andreas Lauser
91508eb6e1 black-oil fluid system: introduce black-oil specific variants of the methods
i.e., the PVT region index is passed directly to them and the
ParameterCache objects are not required. also:

- convert all methods to fluid states instead of passing the dependent
  parameters directly.
- do no longer encode the phase or component names in the method names
  of the fluid system.
2016-01-04 15:31:30 +01:00
Andreas Lauser
862f808e74 black-oil fluid system: introduce methods to convert Rs and Rv to their respective mass and mole fractions
going from Rs/Rv to the mole fractions is intentionally a bit clumsy
because it is relatively expensive computationally.
2016-01-04 15:31:28 +01:00
Andreas Lauser
5bf8cba955 Fluid systems: export the type which is used to represent scalar values 2016-01-04 15:31:25 +01:00
Andreas Lauser
8bb8864140 fix setting the live oil properties from the saturated quantities 2016-01-04 15:31:23 +01:00
Andreas Lauser
f1548f5c72 improve the API of the low-level blackoil PVT classes
- they are not concerned with fugacity anymore:
  - as a consequence, they are now more self contained:
    - they do not need to know the molar mass of each component anymore
    - they do not need to call methods of the other PVT classes
      anymore (that was only needed to be able to calculate the
      fugacity coefficients consistently.)
    - quite a few methods could be removed
- also, some methods where renamed for consistency.
2016-01-04 15:31:21 +01:00
Andreas Lauser
1a8d9a30c4 fix the LiveOilPvt w.r.t. setting the saturated viscosities from ECL input 2016-01-04 15:31:18 +01:00
Andreas Lauser
a9a648a667 make the API of the Spline class more similar to the Tabulated*Function classes 2016-01-04 15:31:16 +01:00
Atgeirr Flø Rasmussen
b5bc9b1324 Merge pull request #98 from andlaus/saturated_blackoil_PVT
Saturated blackoil pvt
2015-11-27 11:53:28 +01:00
Andreas Lauser
f89d3bab70 extend the PVT tables in the same way as the opm-core code 2015-11-26 15:29:06 +01:00
Andreas Lauser
e47db7cfca test the API of the black-oil fluid system more extensively
note that currently this only means that it compiles, correct runtime
behaviour is not (yet?) ensured.
2015-11-26 15:29:06 +01:00
Andreas Lauser
1d2ad56ba1 ConstantCompressibilityWaterPvt: calculate the viscosity the same way as the current opm-core code
this is *NOT* equivalent to the equation given by the ECL
documentation, but it makes it possible to compare it with the current
implementation. (also, the differences are pretty small: about < 10^-8
for SPE3.)
2015-11-24 18:13:32 +01:00
Andreas Lauser
f2d8a4e7a6 Tabulated1DFunction: Unify the code paths for local AD and scalars
this is analogous to 8a06000e which did the same for
UniformXTabulated2DFunction.
2015-11-24 18:13:32 +01:00
Andreas Lauser
126375db7d blackoil: introduce saturated{Oil,Gas}{Density,Viscosity}() methods and use them in the fluid system
this eliminates minor differences with the current opm-core PVT
classes which were due to extrapolation of the untersaturated
tables. (Also, the result should be slightly faster if both, oil and
gas are present.)

I'm not really sure if this is always a good thing, though: It implies
discontinuities at the saturated <-> undersaturated transition which
may sometimes deter convergence rates of the non-linear solver.
2015-11-24 18:13:32 +01:00
Andreas Lauser
b7b1d91c94 Merge pull request #100 from andlaus/some_fixes
Some fixes
2015-11-18 17:48:21 +01:00
Andreas Lauser
adb28d4a0e LiveOilPvt: get rid of a "local variable is unused" compiler warning
this only occured if the PVT object was not initialized via
initFromDeck().
2015-11-18 17:29:21 +01:00
Andreas Lauser
ce1a7b35c5 NcpFlash: catch Dune::FMatrixError by constant reference
the difference should not be detectable performance-wise but it is
better style to do it like this.
2015-11-18 17:28:15 +01:00
Andreas Lauser
49356ba0c4 NcpFlash: actually respect the tolerance and improve automatic tolerance determination
so far, the tolerance passed to the solve() method has been silently
ignored. Besides this, the approach to determine the tolerance if none
was given is changed and a negative value is used to indicate that the
tolerance should be determined automatically.
2015-11-18 17:25:17 +01:00
Andreas Lauser
ee67dfd176 geometricMean(): fix a most stupid bug
*meaculpa!*. so far, this did not matter because the geometricMean() function was
is not used within opm-material yet. (or rather the results are
ignored.)
2015-11-18 17:23:16 +01:00
Andreas Lauser
475ff74ad3 Merge pull request #96 from atgeirr/silence-warnings
Silence warnings from Dune includes.
2015-11-10 11:38:34 +01:00
Atgeirr Flø Rasmussen
b9b3a232c4 Silence warnings from Dune includes. 2015-11-10 11:11:24 +01:00
Andreas Lauser
2dfc2723a1 black-oil: prefix XoGToRs() and XgOToRv() with "convert"
this makes it consistent with the method naming scheme while keeping
the method names reasonably brief.

thanks to [at]atgeirr for the suggestion.
2015-11-09 14:51:29 +01:00
Andreas Lauser
ee91d9aad4 blackoil PVT: convert the gas PVT interface to use Rv instead of XgO 2015-11-04 14:21:54 +01:00
Andreas Lauser
925c176477 black oil PVT: use Rs to specify the composition of the oil phase
IMO, the gas mass fraction is more natural, but given the fact that
E100 is all about Rs, this simplifies using opm-material's PVT
relations in opm-autodiff.
2015-11-04 14:21:54 +01:00
Andreas Lauser
8f5093aa2f Merge pull request #93 from andlaus/fix-test_2dtables
fix a test failure for the 2D tables test
2015-10-29 14:36:34 +01:00
Andreas Lauser
2f68011270 fix a test failure for the 2D tables test
this was caused by trying to get a value outside of the tabulated
region. for some reason I do not fully understand, this did not
trigger until now...
2015-10-29 13:54:37 +01:00
Andreas Lauser
812f556e97 Merge pull request #77 from blattms/redistribute-EclMaterialLawManager
Give access to the shared_ptr of the parameters.
2015-10-28 11:51:01 +01:00
Andreas Lauser
8f63cb9d70 Merge pull request #91 from andlaus/compile_without_opm-parser
make it compile again if opm-parser is not available
2015-10-27 12:31:27 +01:00
Andreas Lauser
76e31b3323 make it compile again if opm-parser is not available
this is basically a simple #if HAVE_OPM_PARSER which was forgotten...
2015-10-27 12:28:03 +01:00
Andreas Lauser
e1088c8a3f Merge pull request #90 from akva2/add_fuzz
fix for tests
2015-10-26 11:47:23 +01:00
Arne Morten Kvarving
ce972c003a fix for tests
add some fuzz to make them pass on other archs
2015-10-26 11:16:45 +01:00
Andreas Lauser
351c8ac775 Merge pull request #81 from andlaus/fix_stone1
Fixes for the stone1 ECL material law
2015-10-26 11:10:08 +01:00
Andreas Lauser
cebee06a2d Merge pull request #88 from atgeirr/bump-version
Bump version and unify format of dune.module.
2015-10-23 14:27:05 +02:00
Atgeirr Flø Rasmussen
361e9e10fb Remove version.h. 2015-10-23 13:34:35 +02:00
Andreas Lauser
bc9e243873 Stone1: fix another division by zero
this time, the guilty guy is the base of the "beta" factor.
2015-10-22 18:30:03 +02:00
Andreas Lauser
8a46ffb5bd End-point scaling: prevent division by zero
this occured if threepoint scaling was enabled and the last two
saturations were identical. I'm actually not sure if the deck is valid
in this case (should not twopoint scaling used in this case?), but it
seems like it occures in Real Life (TM) and it is accepted by E100, so
let's do the same. (Note that the behavior of E100 may still be
different if the two last scaled saturation endpoints are identical
and the unscaled ones are not, or vice versa. In that case, the input
data is quite certainly rubbish, though.)
2015-10-22 18:30:03 +02:00
Andreas Lauser
8a06000efa UniformXTabulated2DFunction: simplify, fix fallout of warning removal patch
the simplification is that there is now only one code path regardless
of whether an Evaluation or plain scalars are used.

the warning removal patch broke the extrapolation case for values
smaller than the minimum value.
2015-10-22 18:30:03 +02:00
Andreas Lauser
bd3a148e79 Stone1: smallish cleanups
- move the oil relperm for connate water to the parameters. this
  improves performance slightly. (although I have some doubts that the
  effect is measurable in real world simulations.)
- clarify some comments
- remove unneeded parameters from the parameter object of the Stone1
  material law. (reduces memory consumption slightly.)
2015-10-22 18:30:03 +02:00
Andreas Lauser
a38f44a2c3 Stone1: make the results identical to the ones produces by E100
It looks like the equations that scale the saturations for the Stone 1
model given by the Eclipse documentation are wrong. ("wrong" in the
sense that they seem not to be the ones implemented by E100).

With this change, the oil relperm seems to be identical to the ones of
E100 for SPE-1 based test deck. I'd be grateful if somebody else could
have look at this before it is merged.
2015-10-22 18:30:03 +02:00
Andreas Lauser
6636901f12 EclStone1MaterialParams: initialize the exponent correctly
it seems like this was a thinko or a copy-and-pasto...
2015-10-22 18:30:03 +02:00
Andreas Lauser
589b2f96ba Merge pull request #86 from joakim-hove/master
Restore lost commits from mistaken force push
2015-10-22 11:28:04 +02:00
Andreas Lauser
e3e79e6562 Merge pull request #85 from andlaus/fix_headercheck
UniformXTabulated2DFunction: include missing header file
2015-10-21 18:18:20 +02:00
Andreas Lauser
ddc54a3e46 UniformXTabulated2DFunction: include missing header file
for some reason, this did not trigger before...
2015-10-21 18:16:11 +02:00
Andreas Lauser
2af0a8da26 Merge pull request #82 from andlaus/fix_gcc5_warnings
fix GCC5 sign comparison warning
2015-10-19 12:33:39 +02:00
Andreas Lauser
a36db0a5a9 fix GCC5 sign comparison warning 2015-10-19 12:32:41 +02:00
Andreas Lauser
4c0a471f30 Merge pull request #80 from andlaus/fix_gcc5_warnings
blackoil-PVT: fix a few "non-void method may not return anything" warnings on GCC5
2015-10-14 13:38:22 +02:00
Andreas Lauser
a347461486 blackoil-PVT: fix a few "non-void method may not return anything" warnings on GCC5
this warning is a false positive because the branch of the switch
statement which does not return a value throws an exception instead.
2015-10-13 14:14:38 +02:00
Andreas Lauser
8b4d3c644c Merge pull request #79 from andlaus/fix_gcc44
fix build on GCC 4.4
2015-10-13 13:35:47 +02:00
Andreas Lauser
5622351d5e fix build on GCC 4.4
the explicit include of <array> is beneficial anyway.
2015-10-13 11:46:19 +02:00
Andreas Lauser
191330f55a Merge pull request #78 from totto82/fix_family2deck
Fix the SOF3 input  to make the KROW input similar as in SWOF.
2015-10-12 17:20:58 +02:00
Tor Harald Sandve
4a42a2af8e Fix the SOF3 input to make the KROW input similar as in SWOF. 2015-10-12 14:26:19 +02:00
Atgeirr Flø Rasmussen
a20978000d Merge pull request #76 from andlaus/error_macros_to_opm_common
use the error macros from opm-common
2015-10-12 13:31:46 +02:00
Markus Blatt
60b4169283 Give access to the shared_ptr of the parameters.
This is needed to keep the pointer structure when creating
a new material law manager for just a subgrid.
2015-10-08 12:16:12 +02:00
Andreas Lauser
d52579277a use the error macros from opm-common 2015-10-08 11:49:10 +02:00
Andreas Lauser
7646a4e17a Merge pull request #75 from andlaus/remove_assertation_in_eps
EclEpsScalingPoints: remove incorrect assertation
2015-10-07 21:26:45 +02:00
Andreas Lauser
a99f43428d EclEpsScalingPoints: remove incorrect assertation
the documentation only requires the maximum gas satuation to
correspond to 1-Swco, not that the gas and water relperms are equal at
that point.
2015-10-07 21:23:41 +02:00
Joakim Hove
151a5b87f5 Merge pull request #62 from joakim-hove/table-container
Table container
2015-10-05 14:46:37 +02:00
Joakim Hove
3136ec04ed Changed Table code to use TableContainer 2015-10-04 17:00:55 +02:00
Andreas Lauser
216dde38b4 Merge pull request #73 from andlaus/fix_EclMaterialLawManager_unit_test
fix the (newly added) unit test for EclMaterialLawManager
2015-10-01 20:39:14 +02:00
Andreas Lauser
e79f363d04 fix the (newly added) unit test for EclMaterialLawManager
the first reason why it failed was that the parameters are now
per-element instead of per-satregions. (this was merged after this was
written.) The second issue was a problem in the deck data: according
to the ECL reference manual (or the technical description, I don't
remember), the maximum relperms for the water and for the gas phase
must be equal, but in the test's decks they were not.
2015-10-01 15:57:01 +02:00
Andreas Lauser
6073558373 Merge pull request #69 from andlaus/various_stuff
various improvements
2015-09-30 12:24:19 +02:00
Andreas Lauser
731d2fccf1 various improvements
- add unit tests for the EclMaterialLawManager and the black-oil PVT classes
- rework the API of the blackoil PVT classes so that it follows the
  initFromDeck() pattern and uses multiplexer classes instead of
  dynamic polymorphism to select the concrete PVT approach
- the former change allowed to use the BlackOil fluid system with
  arbitrary Evaluations, i.e., it is not limited to a single
  Evaluation class which is specified as a class template argument
  anymore.
- more fixes for GCC and clang warnings. now it should be reasonably
  hard to trigger warnings using these compilers.

this commit squashes the following patches:

- add a unit test for the EclMaterialLawManager
- black oil: simplify the WaterPvtInterface
- add a unit test for the PVT classes of the black oil fluid system
- black oil: improvements to the PVT classes
- blackoil PVT: remove dynamic polymorphism
2015-09-29 14:09:19 +02:00
Andreas Lauser
e932fe0ff0 Merge pull request #68 from andlaus/remove_non_element_specific
EclMaterialLawManager: remove the non-element specific initialization
2015-09-28 23:36:13 +02:00
Andreas Lauser
cacf06468f EclMaterialLawManager: remove the non-element specific initialization
This simplifies the satfunc initialization code paths considerably and
avoids troubles with SWATINIT if endpoint scaling and hysteresis is
disabled. on the flipside it now requires more memory in the simple case.

It seems to me that the usual proverb about optimization holds once
more: Say 99.5% of all time: premature optimization is the root of all
evil.
2015-09-28 12:29:20 +02:00
Andreas Lauser
535746e178 Merge pull request #64 from blattms/do-not-store-compressedToCartesian-in-ECLMaterialLawManager
Do not store compressed to cartesian in ecl material law manager
2015-09-23 18:55:33 +02:00
Markus Blatt
1292fbdb43 Prevent missing return statement warning. 2015-09-23 17:11:58 +02:00
Markus Blatt
418c4a5c57 Prevent yet another signed-unsigned warning. 2015-09-23 17:11:08 +02:00
Markus Blatt
d0751b7ff4 Do not store compressedToCartesianIndex mapping
It is only needed during initialization and not afterwards.
Therefore we can save some space here.
2015-09-23 17:09:39 +02:00
Tor Harald Sandve
0526614fef Merge pull request #44 from andlaus/implement_twophase_ecl_satfuncs
various improvements to the ECL satfuncs
2015-09-23 14:50:57 +02:00
Andreas Lauser
b1f9d86974 make it work with single precision scalars 2015-09-23 12:53:13 +02:00
Andreas Lauser
17b7b3b7f3 EclDefaultMaterial: improve the division-by-zero avoidance logic 2015-09-23 12:53:13 +02:00
Andreas Lauser
7dffa66f96 EclDefaultMaterial: calculate the oil relperm according to the ECL technical description
the differences are not huge, but they can be seen...

(note that the "almost" match of the summary files with Eclipse is
still accomplished, but the "spot-on" match with the current opm-core
saturation functions goes away.)
2015-09-23 12:53:13 +02:00
Andreas Lauser
7faa1a8844 Merge pull request #63 from andlaus/fix_masochistic_warnings
Fix masochistic warnings
2015-09-23 12:37:31 +02:00
Andreas Lauser
a6499a01aa fix most of the warnings enabled by masochists
most of these people like to inflict pain on themselfs (i.e., warnings
in their own code), but they usually don't like if pain is inflicted
on them by others (i.e., warnings produced by external code which they
use). This patch should make these kinds of people happy. I'm not
really sure if the code is easier to understand with this, but at
least clang does not complain for most of the warnings of
"-Weverything" anymore.
2015-09-23 12:36:52 +02:00
Andreas Lauser
be1fd178f1 do not squelch unused argument warnings using casts to void
casts to void are not very explicit (in particular if they do not come
with a comment about their purpose). Instead, the names of unused
argument are now simply commented out or the OPM_UNUSED macro is used
for the few cases where this is not possible.
2015-09-23 12:35:45 +02:00
Andreas Lauser
9778a853e3 Merge pull request #61 from osae/fix-index-mixup
Buxfix - compressed versus cartesian index.
2015-09-23 12:34:51 +02:00
osae
4c08b6e5f4 Buxfix - compressed versus cartesian index. 2015-09-21 13:03:29 +02:00
Atgeirr Flø Rasmussen
044edeac4f Merge pull request #60 from atgeirr/silence-warning
Comment out unused argument.
2015-09-17 15:05:39 +02:00
Atgeirr Flø Rasmussen
337cf41d96 Comment out unused argument. 2015-09-17 15:04:46 +02:00
Atgeirr Flø Rasmussen
fd4b4bf6d1 Merge pull request #57 from atgeirr/silence-warnings
Silence warnings
2015-09-15 17:43:56 +02:00
Atgeirr Flø Rasmussen
1ebec84bd1 Remove unused code. 2015-09-15 17:41:09 +02:00
Atgeirr Flø Rasmussen
4768861535 Merge pull request #58 from totto82/fix_fam2
Use tabulated oil saturations directly in KROG for familyII
2015-09-15 14:37:39 +02:00
Tor Harald Sandve
ace6a25210 Use tabulated oil saturations directly in KROG for familyII
Revert bug introduced when refactoring the code in the process of
supporting two-phase simulations.
2015-09-15 13:35:09 +02:00
Atgeirr Flø Rasmussen
bba5e33973 Suppressed more warnings. 2015-09-14 17:15:04 +02:00
Atgeirr Flø Rasmussen
a5ecbd765c Silence unused argument warnings. 2015-09-11 14:32:59 +02:00
Atgeirr Flø Rasmussen
a15fa4444e Delete unused argument. 2015-09-11 14:32:36 +02:00
Atgeirr Flø Rasmussen
b3f6740a68 Silence more unused argument warnings. 2015-09-11 13:46:45 +02:00
Atgeirr Flø Rasmussen
db3d60eeae Avoid shadowing variables. 2015-09-11 13:38:09 +02:00
Atgeirr Flø Rasmussen
1f42957755 Silence some unused argument warnings. 2015-09-11 13:37:31 +02:00
Andreas Lauser
1b794a44f6 Merge pull request #55 from andlaus/wet_gas_fixes
blackoil: fix some screw ups with wet gas
2015-09-04 18:14:35 +02:00
Andreas Lauser
fb79b732d8 blackoil: fix some screw ups with wet gas 2015-09-04 14:33:19 +02:00
Andreas Lauser
ac14e53129 Merge pull request #50 from andlaus/make_twophase_ecl_satfuncs_work
Make twophase ecl satfuncs work
2015-09-03 14:53:18 +02:00
Andreas Lauser
b314ee4ba7 Merge pull request #54 from andlaus/fix_Evaluation_on_dune-2.3
Evaluation: forward declare Opm::LocalAd::abs() instead of including Math.hpp
2015-09-03 11:34:55 +02:00
Andreas Lauser
8c3db57025 Evaluation: forward declare Opm::LocalAd::abs() instead of including Math.hpp
this solves an "order of #include" problem on Dune before 2.4
2015-09-03 11:20:26 +02:00
Andreas Lauser
03129c01f6 make the ECL twophase code work
this has been tested with a real deck now.
2015-09-03 10:55:46 +02:00
Andreas Lauser
d7b5a1b2e3 EpsScalingInfo: move the code which handles individual tables to their own functions
this avoids copy-and-pasting stuff in the twophase case.
2015-09-03 10:52:32 +02:00
Andreas Lauser
820046191e Merge pull request #53 from andlaus/fix_Evaluation_with_FieldMatrix
make the Evaluation template class work better as field type for Dune::FieldMatrix/Dune::FieldVector
2015-09-02 13:21:59 +02:00
Andreas Lauser
8ef6f7bfc2 make the Evaluation template class work better as field type for Dune::FieldMatrix/Dune::FieldVector
IMO this doges the edges of the c++ specifcation quite a bit too hard,
but at least with Dune >= 2.4 it should now work unconditionally (and
for older dune versions, the #error has been demoted to a #warning)
2015-09-02 13:15:08 +02:00
Andreas Lauser
9b72e928c6 Merge pull request #52 from andlaus/fix_TableManager_fallout
fix the fallout of the TableManager
2015-09-02 12:33:35 +02:00
Andreas Lauser
e08691f90a fix the fallout of the TableManager
the problem is that the EclMaterialLawManager is currently not used in
any opm-material unit test, so the module compiled just fine without
these fixes. Mental note to myself: add such a unit test!
2015-09-02 12:29:45 +02:00
Joakim Hove
a76cb4cfc6 Merge pull request #49 from joakim-hove/table-refactor
Using TableManager class to get input tables.
2015-09-02 11:57:42 +02:00
Andreas Lauser
327c8a306d Merge pull request #51 from andlaus/blackoil_fixes
Blackoil fixes
2015-09-01 16:07:00 +02:00
Andreas Lauser
543c3cb603 fix some bugs in WetGasPvt
so far, this has never been tested on a deck which features vaporized oil.
2015-09-01 16:05:05 +02:00
Andreas Lauser
5edc12bef2 BlackOilFluidSystem: make the order of the phases identical to opm-core
this simplifies comparisons and mixing code.
2015-09-01 16:05:05 +02:00
Andreas Lauser
1eee36c9ab Merge pull request #48 from andlaus/add_twophase_multiplexer
implement a material law for twophase ECL simulations
2015-09-01 12:35:03 +02:00
Andreas Lauser
9bfc26a2d8 implement a material law for twophase ECL simulations
the basic idea is that implements the threephase API, but only
calculates the quantities for the selected fluid phases.
2015-09-01 12:33:43 +02:00
Andreas Lauser
0db938f199 Merge pull request #47 from andlaus/change_EPS_conventions
EclEpsTwoPhaseLaw: clean up the terminology it uses for variable names
2015-09-01 12:32:35 +02:00
Andreas Lauser
ee61bc00e7 EclEpsTwoPhaseLaw: clean up the terminology it uses for variable names
now all variables should contain either "scaled" or "unscaled".
2015-09-01 12:30:04 +02:00
Joakim Hove
8cf963ba3f Using TableManager class to get input tables. 2015-09-01 12:21:11 +02:00
Andreas Lauser
8c612009ac Merge pull request #46 from andlaus/implement_slgof_support
ECL satfuncs: implement support for the SLGOF keyword
2015-08-25 21:55:29 +02:00
Andreas Lauser
a58531c3de fix the satfunc family detection code in ECL scaling points class
thanks to [at]totto82 for finding this.
2015-08-25 11:38:31 +02:00
Andreas Lauser
5e447cb83a ECL satfuncs: implement support for the SLGOF keyword
if my understanding of this keyword is correct, it is identical to
SGOF except that the saturation column is specified in terms of Swco +
So instead of as Sg
2015-08-24 21:51:46 +02:00
Tor Harald Sandve
6c403d457e Merge pull request #45 from andlaus/shift_gas_saturations_again
shift the gas saturations of the oil relperm tables again
2015-08-24 15:30:12 +02:00
Andreas Lauser
c6cafe3a7a shift the gas saturations of the oil relperm tables again
it seems like this was accidentally undone while resolving conflicts in #42.
2015-08-24 13:52:09 +02:00
Andreas Lauser
086b129773 Merge pull request #43 from andlaus/fix_compile
fix compilation in debug mode
2015-08-19 16:07:59 +02:00
Andreas Lauser
6e27d1ab1d fix compilation in debug mode 2015-08-19 16:07:07 +02:00
Andreas Lauser
5490017b3f Merge pull request #42 from totto82/family2
Support for Family II saturation functions input
2015-08-19 13:06:06 +02:00
Andreas Lauser
220fe9cffa Merge pull request #38 from andlaus/SplineLaw_implement_twophase_inversion_api
SplineTwoPhaseMaterial: implement the two-phase inversion functions
2015-08-19 11:02:56 +02:00
Tor Harald Sandve
3c7a087d3d Merge pull request #41 from andlaus/ecl_satfunc_improvements
Ecl satfunc improvements
2015-08-19 10:43:26 +02:00
Tor Harald Sandve
4431ff6d7d Add function to check saturation function family
Adapt to change in the EclipseState i.e. the method
to get the saturation function family is no longer available and a
similar method is implemented in EclMaterialLawManager
2015-08-19 09:29:20 +02:00
Andreas Lauser
ef28c31368 EclHysteresisTwoPhaseLaw: use '<=' instead of '<' to decide whether to use the imbibition or the drainage curve
this does not change the results in any way, but for the Norne deck,
it improves performance (i.e., It Must Be Right (TM))...
2015-08-18 17:35:35 +02:00
Andreas Lauser
57948012a5 PiecewiseLinearTwoPhaseMaterial: remove unnecessary calls to min() and max()
it is nicer to read like this and it may improve performance a tiny
bit.
2015-08-18 17:35:22 +02:00
Andreas Lauser
0edc7b5f70 EclMaterialLawManager: shift the saturations of the oil phase the in gas-oil twophase system by the connate water saturation
for the oil phase relperm, the gas saturation column of the SGOF
keyword actually is Sg - Swco. why? it's ECL! don't ask why!
2015-08-18 17:24:28 +02:00
Tor Harald Sandve
3cffd067e3 PiecewiseLinearTwoPhaseMaterial: make the saturation columns of the quantities independent 2015-08-18 17:24:28 +02:00
Andreas Lauser
3693edb044 Merge pull request #40 from andlaus/revert_family_2_support
Revert "Add support for saturation family 2 keywords"
2015-08-18 17:23:10 +02:00
Andreas Lauser
7e83191892 Revert "Add support for saturation family 2 keywords"
This reverts commit a041e3ccff.

it does not compile with the current opm-parser.
2015-08-18 17:20:29 +02:00
Andreas Lauser
4a7e099246 Merge pull request #37 from totto82/family2
Add support for saturation family II keywords
2015-08-18 17:02:54 +02:00
Tor Harald Sandve
a041e3ccff Add support for saturation family 2 keywords
Saturation functions can no be given using the family 2 keywords SWFN,
SGFN and SOF3.
2015-08-17 07:08:13 +02:00
Andreas Lauser
8e11a8254e Merge pull request #39 from andlaus/change_connate_water_treatment
EclDefaultMaterial: do not add the connate water saturation to Sw_ow
2015-08-14 17:42:50 +02:00
Andreas Lauser
14e4692386 EclDefaultMaterial: do not add the connate water saturation to Sw_ow 2015-08-14 17:40:05 +02:00
Andreas Lauser
8e51155f24 Merge pull request #36 from andlaus/inconsistent_hysteresis_updates
EclDefaultMaterial: use inconsistent saturations for the hysteresis update
2015-08-14 15:32:03 +02:00
Andreas Lauser
fb6eb1279a SplineTwoPhaseMaterial: implement the two-phase inversion functions
these are required for ECL hysteresis.
2015-08-14 14:04:20 +02:00
Andreas Lauser
a8aaa168e2 EclDefaultMaterial: allow the parameters to decide if consistent or inconsistent hysteresis are used 2015-08-14 09:33:28 +02:00
Andreas Lauser
893538c9f3 EclDefaultMaterial: use inconsistent saturations for the hysteresis update
with this, I got slightly better performance than the opm-core master
version if flow is tasked on simulating the full Norne deck. Be aware
that from the physical POV, this is wrong.
2015-08-14 09:26:28 +02:00
Andreas Lauser
83de8aceb1 Merge pull request #35 from andlaus/connate_water_fixes
Connate water fixes
2015-08-14 09:26:10 +02:00
Andreas Lauser
a52c279fc8 Merge pull request #34 from andlaus/fix_two-point_krw_scaling
fix saturation scaling points for two-point krw scaling
2015-08-13 17:39:24 +02:00
Andreas Lauser
0d1c711d8e EclDefaultMaterial: increase the epsilon for division-by-zero-avoidance to 1e-20
also, treat saturations smaller than 0 as 0. this also makes clamping the
kro values to range [0, 1] superfluous.
2015-08-13 17:37:19 +02:00
Andreas Lauser
797012a8ba EclDefaultMaterial: add the connate water saturation to the wetting-phase saturation in the gas-oil system 2015-08-13 17:34:21 +02:00
Andreas Lauser
be4593841f EclDefaultMaterial: Make sure that the water saturation is at least the connate water saturation
I thought this would not make a difference if the tables are
extrapolated by constants, but apparantly it makes a difference for
endpoint scaling.
2015-08-13 17:31:56 +02:00
Andreas Lauser
ca2a4bbb4e fix saturation scaling points for two-point krw scaling
kudos to [at]osae for finding this!
2015-08-12 18:07:05 +02:00
Andreas Lauser
10dc683c75 Merge pull request #33 from andlaus/only_non-wetting_phase_ecl_hysteresis
limit ecl relperm hystersis to the non-wetting phase
2015-08-12 13:21:35 +02:00
Andreas Lauser
edf345219f limit ecl relperm hystersis to the non-wetting phase
I have trouble seeing why this can possibly physically justified
(because oil is once the wetting and once the non-wetting phase), but
things seem to be like this as the documentation says that in case of
chosing the relperm hysteresis model 0 via the EHYSTR keyword,
hysteresis is only used for the non-wetting phase.
2015-08-11 17:23:02 +02:00
Andreas Lauser
f48891ffb0 Merge pull request #30 from andlaus/no_limits_in_krn
EclDefaultMaterial: do not limit the saturations in krn()
2015-08-10 12:31:38 +02:00
Andreas Lauser
89cbb8aab7 EclMaterialLawManager: slightly clean up the materialLawParams() methods 2015-08-07 18:23:32 +02:00
Andreas Lauser
a82648a002 embed the scaled endpoints directly into the relevant parameter objects
this hopefully improves performance slightly.
2015-08-07 18:23:32 +02:00
Andreas Lauser
8b9cfa0a65 EclDefaultMaterial: do not limit the saturations in krn()
this is required to get a match with the current opm-core satfuncs for
Norne.
2015-08-07 16:47:23 +02:00
Andreas Lauser
53309405c2 EclMaterialLawManager: make it use compressed instead of logically Cartesian elements
for grids with many inactive cells, this can change quite a bit of
memory and might even lead to slightly better performance because of
the memory prefetching potentially works better.
2015-08-06 16:44:00 +02:00
Andreas Lauser
5d2dadc6e1 replace custom conditional type selector by std::conditional
I did not know about std::conditional until today...
2015-07-29 13:56:53 +02:00
Andreas Lauser
fc2e6c9918 implement a EclMaterialLawManager class
this class internalizes and manages the material parameters from the
ECL deck because this turns out to be a non-trivial task.
2015-07-28 17:24:31 +02:00
Andreas Lauser
7cbffc22c6 introduce SimpleModularFluidState and make ModularFluidState not depend on the FluidSystem anymore
it is called "simple" because the usage is somewhat simpler: The
quantities are stored and those which are not can be specified using
simple boolean template arguments instead of having to pass the class
names of the storage modules. The definition of the class is quite a
bit more involved than the non-"simple" variant, though.
2015-07-28 17:24:27 +02:00
Andreas Lauser
a25cee980b implement a multiplexer three-phase fluid-matrixinteraction for ECL problems
this allows to switch between the Default three-phase implementation,
Stone1 and Stone2 at runtime.
2015-07-28 17:24:25 +02:00
Andreas Lauser
11ccc40e44 implement Stone2 three-phase fluid-matrixinteractions for ECL problems 2015-07-28 17:24:22 +02:00
Andreas Lauser
d46f4bafe3 implement Stone1 three-phase fluid-matrixinteractions for ECL problems 2015-07-28 17:24:20 +02:00
Andreas Lauser
c7c4784746 some updates for EclDefaultMaterial
it now uses shared pointers to the underlying twophase material law
parameter objects and it can be used with hysteresis.
2015-07-28 17:24:18 +02:00
Andreas Lauser
014a8faa04 implement ECL hysteresis
so far, this is only for relperm hysteresis. the Eclipse docu seems to
be incorrect (or at least vague) for capillary pressure hysteresis...
2015-07-28 17:24:16 +02:00
Andreas Lauser
4dea8c0642 add invertion methods to some of the two-phase fluid-matrix interactions
these are required for hysteresis
2015-07-28 17:24:14 +02:00
Andreas Lauser
01aaaea95c Brooks-Corey: fix some comments
they were misleading or wrong.
2015-07-28 17:24:12 +02:00
Andreas Lauser
bb100ced1c implement a two-phase fluid-matrix interaction for ECL end-point scaling 2015-07-28 17:24:09 +02:00
Andreas Lauser
9343d3d720 go back to using Dune's MPIHelper class in test_fluidmatrixinteractions
Dune's MPIHelper API might be sub-optimal (because it easily leads to
race conditions w.r.t. the destruction of singletons), but it does the
job and we don't have to maintain it.
2015-07-28 17:24:07 +02:00
Andreas Lauser
4ba1490310 remove the unused 'Evaluation' template parameter from the MaterialTraits
the evaluation is actually more dynamic because it is a template
argument for the individual methods of the fluid-matrixinteractions.
2015-07-28 17:24:05 +02:00
Andreas Lauser
18531103a6 fix error in comment 2015-07-28 17:24:03 +02:00
Andreas Lauser
6eb9c42e5c LiveOilPvt: fix convergence criterium for oilSaturationPressure()
in some cases this pressure can be quite low (e.g. 0), and für
slightly inconsistent decks it can be even negative, so it makes sense
to compare the absolute values and to add an absolute convergence
criterion.
2015-07-03 11:51:57 +02:00
Andreas Lauser
99a61df00a re-add the vim and emacs modelines
conceptually, this may not be the purest conceivable solution, but it
is the most practical one.
2015-06-18 13:47:26 +02:00
Andreas Lauser
813ab7ecc6 fix a GCC "typedef unused" warning for optimized builds 2015-05-28 13:50:14 +02:00
Andreas Lauser
2673badd5b fix the headercheck
i.e., make all header files includable without preconditions.
2015-05-21 16:23:18 +02:00
Andreas Lauser
520ce9ddf1 make the heat conduction laws usable with the local-AD framework 2015-05-21 16:23:18 +02:00
Andreas Lauser
662531fee8 make the constraint solvers usable with local-AD 2015-05-21 16:23:18 +02:00
Andreas Lauser
8aaf2bfdab make the fluid-matrix interactions usable with the local-AD framework
also, adapt the unit test to test this capability.
2015-05-21 16:23:18 +02:00
Andreas Lauser
26c8553902 make all fluid systems local-AD aware
also, adapt the unit test make sure they can be used synchronously
with function evaluations as well as scalars.
2015-05-21 15:33:16 +02:00
Andreas Lauser
e009e640c5 make the fluid states ready for the local-AD framework
in fact they wouldn't have needed any modification, but returning
constant references instead of copies of the stored values saves quite
a few calls to copy constructors.

besides this, fluid states are now required to export the 'Scalar'
type, which allows to use it outside of the FluidState without
resorting to the c++ 'decltype' construct.
2015-05-21 15:33:14 +02:00
Andreas Lauser
0149901e4f make the binary coefficients local-AD aware 2015-05-21 15:33:12 +02:00
Andreas Lauser
b5b7864ca5 add a unit test for the components
note that this test only checks for API compliance but not if the
compotations of the components make any sense.
2015-05-21 15:33:09 +02:00
Andreas Lauser
dadefcd3f3 make all components local-AD aware 2015-05-21 15:33:07 +02:00
Andreas Lauser
35bbae78ab make the linear 1D and 2D tabulation classes local-AD aware 2015-05-21 15:33:05 +02:00
Andreas Lauser
2739b031b7 make the spline class usable with local function evaluations instead of scalars 2015-05-21 15:33:03 +02:00
Andreas Lauser
b9d9f893d9 introduce the concept of "math toolboxes"
these are "traits" classes and provide a way to access the value of
function evaluations, conditional access to its value (i.e., to
forward them if the target object of an assignment includes the
derivatives or use the function value if not) and some algebraic
functions.

the main idea is to be able to abstract the differences between plain
scalars and function evaluation...
2015-05-21 15:33:01 +02:00
Andreas Lauser
d34bbc57a9 add a "local" AD framework
The basic idea is to replace "plain" scalar values by "function
evaluations": these store the function's value plus a set of
derivatives for it and the chain rule is used to "drag" the
derivatives along.

So far, the framework only implements the "forward" approach to
automatic differentiation and expression templates are not supported
yet. (The latter point may change in the furture, though.)

"local" means that the framework uses static arrays to represent the
derivatives, i.e. the number of derivatives which are required must be
specified at compile time. Compared to dynamic arrays this improves
efficiency considerably if function evaluation objects must be
allocated and deallocated frequently.
2015-05-21 15:32:59 +02:00
Andreas Lauser
7b49035575 unify the formatting of the copyright statements 2015-04-29 13:59:08 +02:00
Andreas Lauser
d601f672ac {geometric,harmonic}Mean(): handle the case where both factors are zero properly
without this commit, this case caused NaNs which in turn cause quite a
bit of hilarity...
2015-04-29 13:59:08 +02:00
Andreas Lauser
5b08de4244 incorperate all infrastructural classes required into opm-material itself
they used to be in opm-core, but this allows to be more flexible with
the dependency order: What's now called "opm-core" can easily depend
on opm-material which might come in handy for the refactoring.

Besides moving in classes from opm-core, the infrastructural code
which was still in opm-material is moved to the directory
opm/material/common. The intention is to collect these classes at a
central location to make it easy to move them to a real "core" module.
(if this is ever going to happen.)
2015-04-28 12:17:49 +02:00
Andreas Lauser
0c4fd68f2a update version number to 2015.10 2015-03-29 15:13:19 +02:00
Andreas Lauser
2c5d51f841 change the version number to the scheme used by eWoms
i.e., there is no distinction between the "API version" and the
"Release version" anymore. IMO, the split scheme is just confusing for
no benefit because we are handling API/ABI changes in a pretty relaxed
manner anyway: i.e., whenever the "release version" gets incremented,
the "API version" needs to follow suite!
2015-03-29 15:07:06 +02:00
Andreas Lauser
898930b3d5 black oil fluid system: implement vaporized oil 2015-02-11 15:31:15 +01:00
Andreas Lauser
dc5fdd7059 change the surface temperature to 15.56 degrees Celsius
this is what Eclipse seems to use, at least according to the STDCOND
keyword...
2015-02-05 16:22:31 +01:00
Andreas Lauser
e036cbea5c Black oil fluid system: use dynamic polymorphism to determine the phase quantities
this allows to freely mix and match ECL keywords like PVT[OG],
PVC[OG], PVDC[OG], and PVTW...
2015-02-05 16:22:31 +01:00
Andreas Lauser
f896d85f4f add a wrapper macro for the c++-2011 "final" keyword 2015-02-05 16:03:47 +01:00
Andreas Lauser
ee05d77f79 black oil fluid system: use extrapolation for all tabulated quantities
this seems to be required for my version of SPE9...
2015-01-26 16:08:25 +01:00
Andreas Lauser
ea3c68694b black oil fluid system: correct a few method descriptions and names 2015-01-26 12:56:53 +01:00
Andreas Lauser
d074070e11 Revert "rename {gil,gas}FormationVolumeFactor to \1FormationFactor"
This reverts commit 1cf745943a. After a
more thorough investigation, the cannonical name of these quantities
turned out to be "* formation volume factor"...
2015-01-26 12:03:42 +01:00
Andreas Lauser
1cf745943a rename {gil,gas}FormationVolumeFactor to \1FormationFactor
the new name is shorter, not less descriptive and it seems like it is
also more common...
2015-01-25 18:20:58 +01:00
Andreas Lauser
b1c35e0e0d Black oil fluid system: make immiscible components less dissolvable
This is only relevant for the approximation which uses large instead
of infinite fugacity coefficients for immiscible components. The
motivation is to bring the solution of the NCP flash solver closer to
what's expected using the blackoil assumptions directly. (Physically
speaking, the result is less realistic in most cases, though...)
2015-01-21 15:33:12 +01:00
Andreas Lauser
f1cb777fb0 Tabulated functions: fix the bisection code
seems like somebody can't properly implement an interval-halving
algorithm. Maybe I should consider to give back my degree...
2015-01-21 15:33:12 +01:00
Andreas Lauser
0b675bfa38 Black oil fluid system: fix Rs <-> XoG conversions
some stupid guy messed them up...
2015-01-21 15:33:09 +01:00
Andreas Lauser
2f343412b7 black oil fluid system: Do things the Eclipse way
i.e., interpolate between inverse volume factors and the inverse of
the product of the volume factors. I have my doubts if these
"optimizations" make the results physically better, but it seems like
they at least make things different...
2015-01-21 15:32:13 +01:00
Andreas Lauser
a44bb9b887 add methods to access the sample points to the tabulated function classes
also, the getSamplePoint() has been renamed to valueAt()
2015-01-21 15:32:13 +01:00
Andreas Lauser
3f82e67847 Black oil fluid system: Use piecewise linear interpolation for all parameters
seems like this is what causes the discrepancies to eclipse in SPE1.
2015-01-21 15:32:05 +01:00
Andreas Lauser
e01cf39448 add a class for piecewise linear 1D functions
this class exhibits almost the same interface as Opm::Spline in order
to faciliate replacing one by the other.
2015-01-16 17:50:39 +01:00
Andreas Lauser
df0dc97c53 fluid-matrixinteractions: remove the derivative functions
these were unused, quite likely broken and could only calculate the
derivatives with regard to some quantities.

if the general derivatives of the relperms and capillary pressures are
ever required, finite differences can be used to save the
day... (these *might* be sightly slower, but they are automatically
consistent with the function.)
2015-01-08 17:57:40 +01:00
Andreas Lauser
0c8a5503d7 fix the headercheck
i.e. make all headers includable without preconditions.
2015-01-06 14:38:00 +01:00
Andreas Lauser
e97c16eeb5 PiecewiseLinearTwoPhaseMaterial: use constant extrapolation.
this makes the result identical to the saturation functions used by
opm-core, although I have my doubts if this is the physically correct
thing to do.
2014-12-16 17:18:54 +01:00
Andreas Lauser
33671258eb EclDefaultMaterial: fix typo
it is Sw instead of Sg. with this, the results for SPE9 seem
reasonable again.
2014-12-16 17:17:37 +01:00
Andreas Lauser
578980e16a PiecewiseLinearTwoPhaseMaterialParams: use the same API as SplineTwoPhaseMaterialParams
this allows to use the two by changing the class name but without
requiring any further code changes...
2014-12-08 17:50:36 +01:00
Andreas Lauser
c267cacbd6 water viscosity: calculate it the same way as documented by the Eclipse RM 2014-12-08 14:58:02 +01:00
Andreas Lauser
8109900567 ECL default material: make the oil relperm match that of autodiff
at least it seems to be very similar for SPE1. the difference in the
BHP of the wells for SPE1 is significantly reduced (but still too
large) by this...
2014-11-27 19:26:47 +01:00
Andreas Lauser
e57b4410f1 ECL default material parameters: add connate water 2014-11-27 19:22:06 +01:00
Andreas Lauser
447268e79d remove unused variable to fix compiler warnings 2014-10-29 16:07:58 +01:00
Andreas Lauser
1f91c1fd93 rename PengRobinsonparamsMixture.hpp to PengRobinsonParamsMixture.hpp 2014-10-29 16:07:21 +01:00
Andreas Lauser
6b5973d6a1 black oil fluid system: use Rs instead of XoG and interpolate the inverse B factor
this is much closer to how things are done in Eclipse. For the
external API, nothing changes provided that only the "official" fluid
system API is used...
2014-10-01 13:46:12 +02:00
Andreas Lauser
f4eaf1769b UniformXTabulated2DFunction: fix interval halving code
now the values for X and Y can be added in ascending or descending
order. The descending code path is pretty slow though, and it is still
possible to screw up the object by specifying the inputs in a totally
unsorted manner. (At this place, I don't really care about these two
things, though.)
2014-10-01 13:41:44 +02:00
Joakim Hove
59bd096d40 Merge pull request #18 from andlaus/table_improvements
adapt the the table related API changes of opm-parser
2014-09-19 15:27:53 +02:00
Andreas Lauser
b865227cfc adapt the the table related API changes of opm-parser 2014-09-18 16:49:02 +02:00
Andreas Lauser
0f17c64f39 Black oil fluid system: copy the undersaturated oil info from a master table
... instead of just assuming some arbitrary behavior. this fixes SPE9
for eWoms as far as the fluid system is concerned. (the ecl_blackoil
still seems to have some problems with anisotropic permeability. this
will hopefulls be fixed soon.)
2014-08-19 15:53:28 +02:00
Andreas Lauser
feeedb7428 properly deal with water compressibility and water "viscosibility" 2014-08-15 16:26:50 +02:00
Andreas Lauser
39cfb4e38a Make it work if HAVE_OPM_PARSER is false
currently, this can't happen because opm-material depends mandatorily
on opm-core which in turn requires opm-parser. In the future, this
might change, though...
2014-08-15 14:01:44 +02:00
Andreas Lauser
197fe4b1e3 black oil fluid system: fix stupid bug when setting the gas viscosity
gas viscosity != gas formation volume factor (even if the values are
somewhat similar)
2014-08-12 16:45:19 +02:00
Andreas Lauser
1051a964e0 black oil fluid system: rename surfaceDensity() to referenceDensity()
because it seems like what eclipse uses in the DENSITY keyword is not
really for surface pressure but at the pressure where the phase's
formation volume factor is one. (this pressure does not seem to be
specified and can potentially be different for every fluid phase.)
Thus rename surfaceDensity() to referenceDensity() and remove the
logic to allow volume formation factors which are not equal to one at
the reference pressure. (i.e., formerly the surface pressure.)
2014-08-12 15:49:01 +02:00
Andreas Lauser
d4a58aefd3 fluid systems: return human readable strings for the phaseName() method
this avoids a bit of guess-work...
2014-08-07 19:19:03 +02:00
Andreas Lauser
883f032aa0 {Spline,PiecewiseLinear}TwoPhaseMaterial: limit the relperms to [0, 1]
it used to be the range of the sampling points. If for some reason the
sampling points describe a subset of the full range, the material laws
use extrapolation outside of the table and properly limit the values
of that operation.

In the real world, the effect of this change is rather limited because
all tested tables used the range...

TODO: adapt the evalDerivative() methods. This is not very urgent, though
because they are usually not used...
2014-08-06 14:53:42 +02:00
Andreas Lauser
34f50e6613 fluid-matrix interactions: add a tabulated two-phase pc/kr law which uses splines
compared to the variant which uses linear interpolation, this makes
the resulting curves smoother and thus hopefully improves the
convergence rates of the simulations.
2014-08-06 13:52:23 +02:00
Andreas Lauser
1108f24c33 black oil fluid system: fix build on GCC 4.4
this compiler is for some reason not able to determine the number of
phases for externally defined attributes the way it was done. this is
most likely a compiler bug (or it is a left-over ideosyncrasy from
c++-2003 which was not yet removed for GCC 4.4...)
2014-08-06 11:26:25 +02:00
Andreas Lauser
20b63fdb6e Black oil fluid system: implement support for multi-region PVT tables
it is slightly hacky that the ParameterCache is used to specify the
PVT region. Having said that, the multiple PVT regions stuff in no way
based on physical assumptions, but is just a way to fit the black-oil
model to the measured values of real reservoirs...
2014-08-05 16:27:08 +02:00
Andreas Lauser
fbf81ef8ec Black oil fluid system: add support for decks which only specify gas-saturated oil in PVTO
SPE-9, I'm looking at you!!! (this is probably still different from
what Eclipse does, but it should be more or less okay from the
thermodynamic POV.)
2014-07-29 16:01:11 +02:00
Andreas Lauser
9534d56f13 black oil fluid system: don't use the numerical value for the surface pressure directly
this is just a minor clean up which does not change anything...
2014-07-25 15:06:15 +02:00
Andreas Lauser
291928955a black oil fluid system: remove commented out density calculation code
I thought about this a bit and came to the conclusion that since the
composition of oil is already fixed in that context, only the pressure
dependance needs to be included in addition.
2014-07-25 15:06:15 +02:00
Andreas Lauser
c5f55c1cd2 black oil fluid system: keep the saturation pressure spline consistent
It was not updated if the set PvtoTable was used which then lead to
segfaults.
2014-07-25 15:06:14 +02:00
Andreas Lauser
a43fec22cc black-oil fluid system: remove debugging artifact
*grr* which idiot forgot this one?
2014-07-24 18:48:38 +02:00
Andreas Lauser
4d61a9dc3f Black-oil fluid system: do not explicitly include the composition in the tabulated density
It might have to be included, but it made the reservoir test in eWoms
fail...
2014-07-24 14:12:05 +02:00
Andreas Lauser
de558bdd3b black oil system: use the UniformXTabulated2DFunction class for the oil formation factor
this means that undersaturated oil is now properly supported.
2014-07-24 14:12:05 +02:00
Andreas Lauser
8f52b80448 refactor the 2D tabulation classes
- the StaticTabulated2DFunction class and the base class
  (Tabulated2DFunction) are gone
- the DynamicTabulated2DFunction class has been renamed to
  UniformTabulated2DFunction
- a new class called UniformXTabulated2DFunction has been
  introduced. Like UniformTabulated2DFunction, it assumes uniform
  intervalls of the sampling points in X direction, but in contrast to
  UniformTabulated2DFunction, the Y locations of the sampling points
  can be set freely (as long as they are specified in increasing order
  for each x value)
- add a unit test for the two tabulation classes
2014-07-24 14:12:04 +02:00
Andreas Lauser
a7126a7a13 peng-robinson test: fix it, so that it produces correct output 2014-07-23 17:45:12 +02:00
Andreas Lauser
b02cff76b1 black oil density: correct the gas mass fraction in saturated oil 2014-07-22 19:16:55 +02:00
Andreas Lauser
a1de23b4fc peng-robinson test: correct calculation of the Rs factor 2014-07-08 12:43:44 +02:00
Andreas Lauser
506700d579 BlackOilFluidSystem: some improvements
the biggest one was that the Rs factor was used incorrectly: instead
of "surface volume of gas per volume of saturated reservoir oil" it is
defined as "surface volume of gas which a volume unit of surface oil
dissolves at reservoir pressure".

Besides this, there are a few smallish improvements like the oil
density being a function which can be called without having the
boilerplate objects (i.e., the fluid state and parameter cache
objects) instantiated.
2014-07-07 12:09:45 +02:00
Andreas Lauser
d9e24bb5c0 improve a few comments and error messages 2014-07-07 12:07:48 +02:00
Andreas Lauser
ced870fbd2 fix another off-by-one error
quite certainly, this won't be the last...
2014-05-23 14:02:13 +02:00
Andreas Lauser
3d91ac3577 1p/2p fluid systems: rename them to more sensfull class names
they were totally inconsistent with the remaining fluid systems
because their file names stated with a number and "P" was used instead
of "Phase"...
2014-05-08 17:02:28 +02:00
Andreas Lauser
5eaedaddf6 make the EclDefaultMaterial actually work
in the sense that it is now used by an eWoms simulator
2014-04-28 19:11:53 +02:00
Andreas Lauser
90e1375e0b Black-oil fluid system: take advantage of opm-parser
this considerably simplifies reading blackoil PVT parameters from an
ECL deck file.
2014-04-25 17:10:44 +02:00
Andreas Lauser
805750a82d convert to opm-parser
and fix some (likely) bugs...
2014-04-16 12:30:13 +02:00
Andreas Lauser
c0a7947357 fluid systems: rename unexpressive phase and component indices
These index names have been fully fluid system dependent for a while
and are supposed to be just used for convenience. This means that
phase names are now actual camelCase words.
2014-04-03 17:27:22 +02:00
Andreas Lauser
96b3d753e2 EclDefaultMaterial: fix sign error 2014-03-27 19:06:50 +01:00
Andreas Lauser
1c374b8391 fluid-matrix interactions: remove "3p" folder
because fluid-matrix interactions have been independent of the number
of phases for a while. The only law left in this folder (implementing
the Parker-van Genuchten law) has been moved one folder up and been
cleaned up considerably.
2014-03-27 19:06:50 +01:00
Andreas Lauser
df9efcf342 some documentation and stylistic updates 2014-03-05 16:30:54 +01:00
Benjamin Faigle
9674745464 Add functions for the heat capacity to the components air and co2
Enabled access to these methods in the co2-brine-fluidsystem (only
pure-phase heat capacities are used). reviewed by Klaus

Dumux-Svn-Revison: 12462
Ported-By: Andreas Lauser <and@poware.org>
2014-02-23 15:10:04 +01:00
Andreas Lauser
b77ecb46c5 h2o-n2 fluid system: use the total pressure to calculate the component enthalpies
this is analogous to commit r12402 of dumux. The current approach was
doing the "compositional consideration" twice. (and the difference
between using the partial pressure for the enthalpy and using the
total one in conjunction with weighting by mass fraction should be
neglectible for "almost ideal" gases, i.e., for low pressure and
temperature scenarios.)
2014-02-04 22:02:00 +01:00
Andreas Lauser
b333007fc3 FluidSystems::BlackOil: increase the fugacity coefficient of gas in water by a factor of 1000
this makes the PVS model work with SPE-9 and the NCP model to converge
better...
2014-01-24 15:15:22 +01:00
Andreas Lauser
f386599669 remove all vim and emacs modelines
for emacs, add a toplevel .dir-locals.el file instead...
2014-01-16 18:41:00 +01:00
Andreas Lauser
78a30208d8 simplify the valgrind client request helpers
the macros where used to make the influence of the valgrind calls zero
even for debug builds if valgrind client requests were
unavailable. Since this resulted in some inconsistencies, and the
performance hit is not terribly large, we now always use the same
inlined functions. For optimized builds the impact of those is still
zero...
2013-12-14 12:03:44 +01:00
Andreas Lauser
249592a57d fix the screw-ups caused by a0101ee 2013-12-03 12:13:53 +01:00
Andreas Lauser
019d188efb update the in-file copyright holder statements
this patch is quite large as there were various bug fixes to the
script which generates these statements
2013-12-02 17:26:34 +01:00
Andreas Lauser
a0101ee033 replace in-source copyright comments by the standard OPM ones 2013-12-02 16:35:57 +01:00
Andreas Lauser
96f38877f5 remove all print statements in classes intended for use of other modules
because these classes should not have any side effects. case in point:
the warnings intended to be printed once get printed once per process
which can be quite a few times for parallel simulations with thousands
of cores. This could also be avoided by checking the MPI rank, but
IMHO this is way too much boilerplate code for a feature of questionable
value.
2013-11-23 00:47:49 +01:00
Andreas Lauser
79c38f94b7 Parker-Lenhard: work around a debug mode bug of GCC 4.4
The resize() method for std::vector seems to copy an uninitialized
object for the new objects in the array on GCC 4.4. This means that we
should not assume that the copied objects are finalized in the
Parker-Lenhard parameters. Strangely enough this only seems to affect
older GCCs (at least 4.4) and only in debug mode...
2013-11-16 10:10:42 +01:00
Andreas Lauser
72bc625357 EclDefaultMaterial: produce something meaningful for krn()
at least mathematically meaningful. whether it makes sense phyiscally
is still to be determined...
2013-11-15 17:10:48 +01:00
Andreas Lauser
34d1934e60 Capillary pressure laws: enforce that parameter objects are finalized before they are used
this only has an effect if compiled in debug mode, i.e., if the NDEBUG
symbol is not defined.
2013-11-15 16:15:10 +01:00
Andreas Lauser
e1ad7112b0 add a tabulated piecewise linear two-phase material law
this is intended to be used for ECLIPSE saturation curves, but the
code is more generic. (Be aware that using cubic splines for the
interpolation between sampling points is probably a better choice in
most cases.)
2013-11-14 18:46:27 +01:00
Andreas Lauser
555154661e fix headercheck 2013-11-14 11:55:11 +01:00
Andreas Lauser
a7f6049a96 make EclDefaultMaterial three-phase API conformant 2013-11-14 11:55:00 +01:00
Andreas Lauser
5c57117365 guard macros: _HH -> _HPP 2013-11-13 18:45:52 +01:00
Andreas Lauser
62e7aad7f5 test_fluidmatrixinteractions: mark some variables as OPM_UNUSED
this should prevent some warnings on GCC 4.6. Thanks to Arne Morten
Kvarving for investigating this.
2013-11-13 12:27:37 +01:00
Andreas Lauser
696503c51e Brooks-Corey: explicitly include <cmath>
it seems to be implicitly included by newer compilers, but not GCC
4.4. In this case I agree with GCC 4.4...

Thanks to Bård Skaflestad for the hat-tip.
2013-11-13 11:37:37 +01:00
Andreas Lauser
8811400173 rename "pcwn" to "pcnw" and "pcng" to "pcgn"
because it is p_n - p_w and p_g - p_n instead of the other way round.
2013-11-12 18:11:40 +01:00
Andreas Lauser
aabce7f005 fluid-matrix interactions: API extension
- add methods to calculate the derivatives of the capillary pressures
  and relative permeabilities with regard to the phase saturations,
  temperature, absolute pressure and phase composition
- extend the unit test to enforce the above
- make the NullMaterial conform to the API and add it to the unit test
- introduce Opm::NullMaterialTraits for material laws that don't use
  any phase indices
2013-11-12 18:11:40 +01:00
Andreas Lauser
abab1d9a87 add the three-phase capillary pressure law Eclipse uses by default 2013-11-11 13:23:55 +01:00
Andreas Lauser
19db7481fd Cosmetic change: remove the subdirectories for sources of the tests
that was a leftover of eWoms/Dumux...
2013-11-11 13:23:55 +01:00
Andreas Lauser
dd70732ae9 Refactor the twophase laws
They are now all generic capillary pressure laws, but with some
additional methods to make working with them easier. For this reason,
they have been moved up one directory to opm/material/fluidmatrixinteractions

Also, a unit test which ensures that all capillary pressure laws
conform to their respective APIs has been added.
2013-11-11 13:23:47 +01:00
Andreas Lauser
0f7c888100 rename doxygen groups "fluidmatrixinteractions(laws|params)" to "FluidMatrixInteractions"
and improve the van Genuchten law
2013-11-05 13:13:16 +01:00
Andreas Lauser
2b493c0e95 fix end of namespace comments
long live python ;)!
2013-11-04 14:15:53 +01:00
Andreas Lauser
febb8d9d8f blackoil fluid system: rename gasFormationFactor to gasDissolutionFactor
that was a thinko/reado of mine...
2013-11-04 14:07:53 +01:00
Andreas Lauser
ca94fdeb88 capillary pressure laws: move the M-phase laws one directory up
since they are also generic in the sense that they can depend on
arbitrary quanities expressed by the fluid state, not just
saturations...
2013-11-03 17:03:36 +01:00
Andreas Lauser
b51bf6d0b1 H2O: remove too expensive range checks
when they worked, they were only used in debug mode anyway...
2013-11-03 15:38:00 +01:00
Andreas Lauser
9b5e1f27e6 Valgrind: fix a small issue that only appears with multiple compile units
this were forgotten 'inline' statements for some client request functions.
2013-10-29 12:23:13 +01:00
Andreas Lauser
851063c659 change API version to 3.0 2013-10-12 16:17:50 +02:00
Andreas Lauser
37777ac9e9 tabulated component: don't catch NumericalProblem anymore
this lead to a compiler warning on gcc 4.8 that this case was already
covered by catching std::exception. Since we did the same in both
branches anyway, these statements were not required...
2013-09-25 16:14:24 +02:00
Andreas Lauser
439d0626da use monotonic splines for the black-oil curves 2013-09-24 19:21:33 +02:00
Andreas Lauser
5e26a52eee remove superfluous CMakeLists.txt files 2013-09-24 12:59:09 +02:00
Andreas Lauser
900db58464 Merge pull request #11 from andlaus/rename_filenames
the big rename
2013-09-24 02:37:31 -07:00
Andreas Lauser
ddd81d4e31 use the spline class correctly
(i.e., remove a template argument. This only fell through the cracks
because Somerton.hpp is not yet used by a unit test...)
2013-09-24 11:37:07 +02:00
Andreas Lauser
7ad9eb26ef remove some lonely usages of Dune::NotImplemented 2013-09-24 11:37:07 +02:00
Andreas Lauser
2e34aecf67 the big rename
make all file names confirm to the OPM conventions. (hopefully)
2013-09-24 11:37:07 +02:00
Andreas Lauser
a985ec3ef5 fix fluid system unit test
this was due to a missing initialization of the MPI. Because
MPI_Finalize should probably called even if the program is aborted due
to an exception, this is done using a helper class. (which does the
same job as Dune::MPIHelper, but is much simpler.)
2013-09-24 10:25:45 +02:00
Andreas Lauser
ee1c36c2a1 Merge pull request #13 from andlaus/reduce_reliance_on_dune
Discussed with Atgeirr
2013-09-23 04:51:18 -07:00
Andreas Lauser
a407f5c389 use OPM instead of dune infrastructure wherever possible
basically the only Dune thing which is still used are the FieldVector
and FieldMatrix classes used by some constraint solvers. Until
something similar goes into opm-core, opm-material must depend on
dune-common...
2013-09-20 15:04:27 +02:00
Andreas Lauser
f60682b472 add version.h header file and adapt version number in dune.module 2013-09-10 13:42:43 +02:00
Andreas Lauser
7f0e63fd89 include the unused.hh header in valgrind.hh
the dune/common/{unused,deprecated}.hh headers do not get implicitly
included by the OPM build system. Since the test for valgrind is has
been added recently, this file produced a compiler error if
HAVE_VALGRIND is 1.
2013-08-14 12:21:08 +02:00
Andreas Lauser
7278da759d fix compileo 2013-06-06 11:30:08 +02:00
Andreas Lauser
8a0830284d eliminate 'constexpr'
use 'const' instead to make old compilers happy. the disadvantage is
that you cannot use the normal methods for template specialization,
but this currently should not be a major drawback.
2013-06-06 11:21:02 +02:00
Andreas Lauser
1fa4ad0c5d make the tests compile using OPM's shiny new CMake based build system 2013-05-30 19:17:00 +02:00
Andreas Lauser
c61b0bd63d change namespace from 'Ewoms' to 'Opm' 2013-05-30 15:45:31 +02:00
1094 changed files with 178448 additions and 12776 deletions

View File

@@ -9,7 +9,7 @@ option(ENABLE_ECL_INPUT "Enable eclipse input support?" ON)
option(ENABLE_ECL_OUTPUT "Enable eclipse output support?" ON)
option(ENABLE_MOCKSIM "Build the mock simulator for io testing" ON)
option(OPM_ENABLE_PYTHON "Enable python bindings?" OFF)
option(OPM_INSTALL_PYTHON "Enable python bindings?" OFF)
option(OPM_INSTALL_PYTHON "Install python bindings?" ON)
option(OPM_ENABLE_EMBEDDED_PYTHON "Enable embedded python?" OFF)
# Output implies input
@@ -32,13 +32,13 @@ set(OPM_PROJECT_EXTRA_CODE_INSTALLED "#ENABLE_ECL_INPUT is needed by opm-common
set(ENABLE_ECL_INPUT ${ENABLE_ECL_INPUT})
set(OPM_MACROS_ROOT ${CMAKE_INSTALL_PREFIX}/share/opm)
list(APPEND CMAKE_MODULE_PATH \${OPM_MACROS_ROOT}/cmake/Modules)
include(OpmPackage) #Make macros availabe after find_package(opm-common)")
include(OpmPackage) #Make macros available after find_package(opm-common)")
set(OPM_PROJECT_EXTRA_CODE_INTREE "#ENABLE_ECL_INPUT is needed by opm-common-prereq.cmake
set(ENABLE_ECL_INPUT ${ENABLE_ECL_INPUT})
set(OPM_MACROS_ROOT ${OPM_MACROS_ROOT})
list(APPEND CMAKE_MODULE_PATH \${OPM_MACROS_ROOT}/cmake/Modules)
include(OpmPackage) #Make macros availabe after find_package(opm-common)")
include(OpmPackage) #Make macros available after find_package(opm-common)")
if(ENABLE_ECL_OUTPUT)
set(OPM_PROJECT_EXTRA_CODE_INSTALLED "${OPM_PROJECT_EXTRA_CODE_INSTALLED}
set(COMPARE_ECL_COMMAND ${CMAKE_INSTALL_PREFIX}/bin${${name}_VER_DIR}/compareECL)
@@ -66,18 +66,16 @@ include(Findopm-tests)
# with the find module
include (${project}-prereqs)
if(ENABLE_ECL_INPUT)
# source_hook runs before config_hook and the former needs fmt, hence this
# needs to be here.
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)
endif()
# source_hook runs before config_hook and the former needs fmt, hence this
# needs to be here.
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)
endif()
if(OPM_ENABLE_EMBEDDED_PYTHON AND NOT OPM_ENABLE_PYTHON)
@@ -108,6 +106,7 @@ macro (config_hook)
set(HAVE_ECL_INPUT 1)")
set(OPM_PROJECT_EXTRA_CODE_INSTALLED "${OPM_PROJECT_EXTRA_CODE_INSTALLED}
set(HAVE_ECL_INPUT 1)")
set(HAVE_ECL_INPUT 1)
endif()
if(ENABLE_ECL_OUTPUT)
set(OPM_PROJECT_EXTRA_CODE_INTREE "${OPM_PROJECT_EXTRA_CODE_INTREE}
@@ -115,13 +114,19 @@ macro (config_hook)
set(OPM_PROJECT_EXTRA_CODE_INSTALLED "${OPM_PROJECT_EXTRA_CODE_INSTALLED}
set(HAVE_ECL_OUTPUT 1)")
endif()
find_package(Boost COMPONENTS filesystem regex system unit_test_framework)
# We need to use the correct search mode. Otherwise not finding one
# boost component beloq will mark the previously found ones as not
# found again. (Code stolen from UseDynamicBoost.cmake
if(Boost_DIR)
set(_Boost_CONFIG_MODE CONFIG)
endif()
find_package(Boost COMPONENTS filesystem regex system unit_test_framework ${_Boost_CONFIG_MODE})
if (HAVE_DYNAMIC_BOOST_TEST)
set_target_properties(Boost::unit_test_framework PROPERTIES INTERFACE_COMPILE_DEFINITIONS BOOST_TEST_DYN_LINK=1)
endif()
endif()
endmacro (config_hook)
macro (prereqs_hook)
@@ -136,6 +141,9 @@ macro (sources_hook)
list(INSERT opm-common_SOURCES 0 ${PROJECT_BINARY_DIR}/ParserInit.cpp)
foreach (name A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)
list(INSERT opm-common_SOURCES 0 ${PROJECT_BINARY_DIR}/ParserKeywords/${name}.cpp)
list(INSERT opm-common_SOURCES 0 ${PROJECT_BINARY_DIR}/ParserKeywords/ParserInit${name}.cpp)
list(INSERT opm-common_SOURCES 0 ${PROJECT_BINARY_DIR}/ParserKeywords/Builtin${name}.cpp)
list(INSERT opm-common_HEADERS 0 ${PROJECT_BINARY_DIR}/include/opm/input/eclipse/Parser/ParserKeywords/${name}.hpp)
endforeach()
if (OPM_ENABLE_EMBEDDED_PYTHON)
list(INSERT opm-common_SOURCES 0 ${PROJECT_BINARY_DIR}/python/cxx/builtin_pybind11.cpp)
@@ -143,6 +151,15 @@ macro (sources_hook)
endif()
set_source_files_properties(src/opm/input/eclipse/Python/Python.cpp
PROPERTIES COMPILE_FLAGS -Wno-shadow)
if(QuadMath_FOUND)
get_target_property(qm_defs QuadMath::QuadMath INTERFACE_COMPILE_DEFINITIONS)
get_target_property(qm_options QuadMath::QuadMath INTERFACE_COMPILE_OPTIONS)
set_source_files_properties(src/opm/material/components/CO2.cpp
src/opm/material/densead/Evaluation.cpp
PROPERTIES COMPILE_DEFINITIONS "${qm_defs}"
COMPILE_OPTIONS "${qm_options}")
endif()
endmacro (sources_hook)
macro (fortran_hook)
@@ -163,11 +180,19 @@ macro (install_hook)
PATTERN *.hpp)
endmacro (install_hook)
# Used to append entries from one list to another.
# The output list is suitable for use in setup.py subtitution
macro(append_quoted OUT IN)
foreach(ENTRY ${${IN}})
list(APPEND ${OUT} "'${ARGN}${ENTRY}'")
endforeach()
endmacro()
# If opm-common is configured to embed the python interpreter we must make sure
# that all downstream modules link libpython transitively. Due to the required
# integration with Python+cmake machinery provided by pybind11 this is done by
# manually adding to the opm-common_LIBRARIES variable here, and not in the
# OpmnLibMain function. Here only the library dependency is implemented, the
# OpmLibMain function. Here only the library dependency is implemented, the
# bulk of the python configuration is further down in the file.
if (OPM_ENABLE_PYTHON)
# We need to be compatible with older CMake versions
@@ -184,36 +209,48 @@ if (OPM_ENABLE_PYTHON)
endif()
set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
set(Python3_LIBRARIES ${PYTHON_LIBRARIES})
set(Python3_VERSION "${PYTHON_VERSION_STRING}")
set(Python3_VERSION_MINOR ${PYTHON_VERSION_MINOR})
else()
# Be backwards compatible.
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\"")
if(Python3_VERSION_MINOR LESS 3)
# Python native namespace packages requires python >= 3.3
message(SEND_ERROR "OPM requires python >= 3.3 but only version ${Python3_VERSION} was found")
endif()
# Compatibility settings for PythonInterp and PythonLibs
# used e.g. in FindCwrap, pybind11
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
# Directory to install common (for opm modules) python scripts
include (GNUInstallDirs)
set(OPM_PYTHON_COMMON_DIR "${CMAKE_INSTALL_DATAROOTDIR}/opm/python")
set(OPM_PROJECT_EXTRA_CODE_INTREE "${OPM_PROJECT_EXTRA_CODE_INTREE}
set(opm-common_PYTHON_COMMON_DIR ${PROJECT_SOURCE_DIR}/python)")
set(OPM_PROJECT_EXTRA_CODE_INSTALLED "${OPM_PROJECT_EXTRA_CODE_INSTALLED}
set(opm-common_PYTHON_COMMON_DIR ${CMAKE_INSTALL_PREFIX}/${OPM_PYTHON_COMMON_DIR})")
endif()
# We always need the PYTHON_INCLUDE_DIR. Unfortunately
# When we build pypi packages CMake will fail to determine
@@ -232,8 +269,10 @@ if (OPM_ENABLE_PYTHON)
endif()
find_package(pybind11 2.2 CONFIG)
if (NOT pybind11_FOUND)
# Use full path for reuse with pypi
set(pybind11_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/python/pybind11/include ${PYTHON_INCLUDE_DIRS})
add_subdirectory(python/pybind11)
if (NOT pybind11_INCLUDE_DIRS)
set(pybind11_INCLUDE_DIRS ${PYBIND11_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS})
endif()
endif()
endif()
@@ -241,7 +280,7 @@ endif()
# all setup common to the OPM library modules is done here
include (OpmLibMain)
if (ENABLE_MOCKSIM)
if (ENABLE_MOCKSIM AND ENABLE_ECL_INPUT)
add_library(mocksim
msim/src/msim.cpp)
target_link_libraries(mocksim opmcommon)
@@ -322,6 +361,26 @@ if(ENABLE_ECL_INPUT)
endif()
# Explicitly link tests needing dune-common.
# To avoid pulling dune-common into the opm-common interface
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})
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})
target_compile_definitions(dunecommon INTERFACE DUNE_COMMON_VERSION_REVISION=${DUNE_COMMON_VERSION_REVISION})
if(Boost_UNIT_TEST_FRAMEWORK_FOUND)
foreach(src ${DUNE_TEST_SOURCE_FILES})
get_filename_component(tgt ${src} NAME_WE)
target_link_libraries(${tgt} dunecommon)
endforeach()
endif()
if(BUILD_EXAMPLES)
target_link_libraries(co2brinepvt dunecommon)
endif()
# Install build system files and documentation
install(DIRECTORY cmake
DESTINATION share/opm USE_SOURCE_PERMISSIONS
@@ -334,140 +393,53 @@ install(FILES cmake/OPM-CMake.md
install(FILES etc/opm_bash_completion.sh.in DESTINATION share/opm/etc)
if (OPM_ENABLE_PYTHON)
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "
import site, sys
try:
sys.stdout.write(site.getsitepackages()[-1])
except e:
sys.stdout.write('')" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES_PATH)
# -------------------------------------------------------------------------
# 1: Wrap C++ functionality in Python
if (PYTHON_SITE_PACKAGES_PATH MATCHES ".*/dist-packages/?" AND
CMAKE_INSTALL_PREFIX MATCHES "^/usr.*")
# dist-packages is only used if we install below /usr and python's site packages
# path matches dist-packages
set(PYTHON_PACKAGE_PATH "dist-packages")
else()
set(PYTHON_PACKAGE_PATH "site-packages")
endif()
if(PYTHON_VERSION_MAJOR)
set(PY_MAJOR ${PYTHON_VERSION_MAJOR})
else()
set(PY_MAJOR ${Python3_VERSION_MAJOR})
endif()
if(PYTHON_VERSION_MINOR)
set(PY_MINOR ${PYTHON_VERSION_MINOR})
else()
set(PY_MINOR ${Python3_VERSION_MINOR})
endif()
set(PYTHON_INSTALL_PREFIX "lib/python${PY_MAJOR}.${PY_MINOR}/${PYTHON_PACKAGE_PATH}" CACHE STRING "Subdirectory to install Python modules in")
make_directory(${PROJECT_BINARY_DIR}/python)
get_target_property(_opmcommon_include_dirs opmcommon INCLUDE_DIRECTORIES)
list(APPEND _opmcommon_include_dirs ${_ecl_include_dirs})
string(REPLACE ";" ":" _setup_include_dirs "${_opmcommon_include_dirs}")
get_target_property(_opmcommon_lib_dirs opmcommon LINK_DIRECTORIES)
if (CMAKE_PREFIX_PATH)
list(APPEND _opmcommon_lib_dirs ${PROJECT_BINARY_DIR}/lib ${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR})
else()
list(APPEND _opmcommon_lib_dirs ${PROJECT_BINARY_DIR}/lib)
endif()
string(REPLACE ";" ":" _setup_lib_dirs "${_opmcommon_lib_dirs}")
if (USE_RUNPATH)
set (_python_rpath_list)
if (CMAKE_PREFIX_PATH)
foreach(path ${CMAKE_PREFIX_PATH})
list(APPEND _python_rpath_list "${path}/${CMAKE_INSTALL_LIBDIR}")
endforeach()
endif()
if (BUILD_SHARED_LIBS)
if (OPM_INSTALL_PYTHON)
list(APPEND _python_rpath_list "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
list(APPEND _python_rpath_list "${PROJECT_BINARY_DIR}/lib")
else()
list(APPEND _python_rpath_list "${PROJECT_BINARY_DIR}/lib")
endif()
endif()
if (_python_rpath_list)
string(REPLACE ";" ":" _rpath "${_python_rpath_list}")
set( _rpath_arg "--rpath=${_rpath}")
else()
set(_rpath_arg "")
endif()
else()
set( _rpath_arg "")
endif()
set(opm-common_PYTHON_PACKAGE_VERSION ${OPM_PYTHON_PACKAGE_VERSION_TAG})
# Generate versioned setup.py
if (pybind11_INCLUDE_DIRS)
string(REGEX REPLACE ";" "', '" _tmp "${pybind11_INCLUDE_DIRS}")
set(SETUP_PY_PYBIND_INCLUDE_DIR "'${_tmp}'")
endif()
if (TARGET fmt::fmt)
get_target_property(SETUP_PY_FMT_LIBS fmt::fmt LOCATION)
get_target_property(FMT_FLAGS fmt::fmt INTERFACE_COMPILE_DEFINITIONS)
foreach(flag ${FMT_FLAGS})
set(SETUP_PY_FMT_FLAGS "${SETUP_PY_FMT_FLAGS} '-D${flag}',")
endforeach()
list(APPEND opm-common_PYTHON_LINKAGE "'${SETUP_PY_FMT_LIBS}'")
else()
set(SETUP_PY_FMT_FLAGS "'-DFMT_HEADER_ONLY'")
endif()
if(cjson_FOUND)
list(APPEND opm-common_PYTHON_LINKAGE "'${cjson_LIBRARIES}'")
endif()
# opm-common_PYTHON_LINKAGE is used verbatim in a listin python.
# Hence items need to be comma separated.
if (opm-common_PYTHON_LINKAGE)
string(REPLACE ";" "," SETUP_PY_LINKAGE "${opm-common_PYTHON_LINKAGE}")
endif()
configure_file (${PROJECT_SOURCE_DIR}/python/setup.py.in ${PROJECT_BINARY_DIR}/python/setup.py)
file(COPY ${PROJECT_SOURCE_DIR}/python/README.md DESTINATION ${PROJECT_BINARY_DIR}/python)
execute_process(COMMAND ${Python3_EXECUTABLE} target_name.py
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/python
OUTPUT_VARIABLE python_lib_target)
add_custom_target(copy_python ALL
COMMAND ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/python/install.py ${PROJECT_SOURCE_DIR}/python ${PROJECT_BINARY_DIR} 0)
add_custom_command(OUTPUT python/opm/${python_lib_target}
DEPENDS ${PYTHON_CXX_DEPENDS}
DEPENDS copy_python
COMMAND ${Python3_EXECUTABLE} ${PROJECT_BINARY_DIR}/python/setup.py
build
build_ext
--build-lib=${PROJECT_BINARY_DIR}/python
--library-dirs=${_setup_lib_dirs}
${_rpath_arg}
--include-dirs=${_setup_include_dirs}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/python
COMMENT "Building python bindings at python/opm/${python_lib_target}")
add_custom_target(opmcommon_python ALL DEPENDS python/opm/${python_lib_target})
add_dependencies(opmcommon_python opmcommon)
file(COPY ${PROJECT_SOURCE_DIR}/python/README.md DESTINATION ${PROJECT_BINARY_DIR}/python)
pybind11_add_module(opmcommon_python
${PYTHON_CXX_SOURCE_FILES}
${PROJECT_BINARY_DIR}/python/cxx/builtin_pybind11.cpp)
target_link_libraries(opmcommon_python PRIVATE
opmcommon)
if(TARGET pybind11::pybind11)
target_link_libraries(opmcommon_python PRIVATE
pybind11::pybind11)
else()
target_include_directories(opmcommon_python SYSTEM PRIVATE ${pybind11_INCLUDE_DIRS})
endif()
set_target_properties(opmcommon_python PROPERTIES
LIBRARY_OUTPUT_DIRECTORY python/opm)
add_dependencies(opmcommon_python copy_python)
# Generate versioned setup.py
configure_file(${PROJECT_SOURCE_DIR}/python/setup.py.in
${PROJECT_BINARY_DIR}/python/setup.py.tmp)
file(GENERATE OUTPUT ${PROJECT_BINARY_DIR}/python/setup.py
INPUT ${PROJECT_BINARY_DIR}/python/setup.py.tmp)
# The install target is based on manually copying the python file tree to the
# installation area with a small installation script 'install.py'. Would have
# preferred to use standard setup.py install, but the setup.py based solution
# refuses to install to a location which the current python executable can not
# load from, and the use of eggs in the setup.py based installation makes
# debugging quite difficult.
#
# Since the installation of Python code is nonstandard it is protected by an
# extra cmake switch, OPM_INSTALL_PYTHON. If you prefer you can still invoke
# setup.py install manually - optionally with the generated script
# setup-install.sh - and completely bypass cmake in the installation phase.
if (OPM_INSTALL_PYTHON)
install( CODE "execute_process(COMMAND ${Python3_EXECUTABLE} ${PROJECT_BINARY_DIR}/python/install.py ${PROJECT_BINARY_DIR}/python/opm ${DEST_PREFIX}${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX} 1)")
include(PyInstallPrefix)
install(TARGETS opmcommon_python DESTINATION ${DEST_PREFIX}${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX}/opm)
install(
CODE "execute_process(
COMMAND ${PYTHON_EXECUTABLE}
python/install.py
${PROJECT_BINARY_DIR}/python/opm
${DEST_PREFIX}${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX} 1)")
## Need to install this Python script such that it can be used by opm-simulators when building against an installed
## opm-common
install( PROGRAMS "python/install.py" DESTINATION "${OPM_PYTHON_COMMON_DIR}" )
endif()
# Observe that if the opmcommon library has been built as a shared library the
@@ -475,7 +447,7 @@ except e:
# testing.
add_test(NAME python_tests
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/python
COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/lib ${Python3_EXECUTABLE} setup.py build_ext --dry-run --build-lib ${PROJECT_BINARY_DIR}/python test
COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/lib ${Python3_EXECUTABLE} -m unittest discover
)
set_target_properties(opmcommon PROPERTIES POSITION_INDEPENDENT_CODE ON)
@@ -489,11 +461,6 @@ except e:
DESTINATION ${PROJECT_BINARY_DIR}
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE )
configure_file(python/setup-package.sh.in tmp/setup-package.sh)
file( COPY ${PROJECT_BINARY_DIR}/tmp/setup-package.sh
DESTINATION ${PROJECT_BINARY_DIR}
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE )
configure_file(python/setup-test.sh.in tmp/setup-test.sh)
file( COPY ${PROJECT_BINARY_DIR}/tmp/setup-test.sh
DESTINATION ${PROJECT_BINARY_DIR}

View File

@@ -32,18 +32,58 @@ list (APPEND MAIN_SOURCE_FILES
src/opm/common/OpmLog/StreamLog.cpp
src/opm/common/OpmLog/TimerLog.cpp
src/opm/common/utility/ActiveGridCells.cpp
src/opm/common/utility/Demangle.cpp
src/opm/common/utility/FileSystem.cpp
src/opm/common/utility/MemPacker.cpp
src/opm/common/utility/numeric/MonotCubicInterpolator.cpp
src/opm/common/utility/OpmInputError.cpp
src/opm/common/utility/parameters/Parameter.cpp
src/opm/common/utility/parameters/ParameterGroup.cpp
src/opm/common/utility/parameters/ParameterRequirement.cpp
src/opm/common/utility/parameters/ParameterTools.cpp
src/opm/common/utility/numeric/calculateCellVol.cpp
src/opm/common/utility/numeric/RootFinders.cpp
src/opm/common/utility/shmatch.cpp
src/opm/common/utility/String.cpp
src/opm/common/utility/TimeService.cpp
src/opm/material/common/Spline.cpp
src/opm/material/common/Tabulated1DFunction.cpp
src/opm/material/common/TridiagonalMatrix.cpp
src/opm/material/common/UniformXTabulated2DFunction.cpp
src/opm/material/components/CO2.cpp
src/opm/material/densead/Evaluation.cpp
src/opm/material/fluidmatrixinteractions/EclEpsScalingPoints.cpp
src/opm/material/fluidsystems/BlackOilFluidSystem.cpp
src/opm/material/fluidsystems/blackoilpvt/DeadOilPvt.cpp
src/opm/material/fluidsystems/blackoilpvt/DryGasPvt.cpp
src/opm/material/fluidsystems/blackoilpvt/DryHumidGasPvt.cpp
src/opm/material/fluidsystems/blackoilpvt/LiveOilPvt.cpp
src/opm/material/fluidsystems/blackoilpvt/SolventPvt.cpp
src/opm/material/fluidsystems/blackoilpvt/WetGasPvt.cpp
src/opm/material/fluidsystems/blackoilpvt/WetHumidGasPvt.cpp
)
if(ENABLE_ECL_INPUT)
list(APPEND MAIN_SOURCE_FILES
external/resinsight/LibCore/cvfAssert.cpp
external/resinsight/LibCore/cvfAtomicCounter.cpp
external/resinsight/LibCore/cvfCharArray.cpp
external/resinsight/LibCore/cvfMath.cpp
external/resinsight/LibCore/cvfObject.cpp
external/resinsight/LibCore/cvfPlane.cpp
external/resinsight/LibCore/cvfString.cpp
external/resinsight/LibCore/cvfSystem.cpp
external/resinsight/LibCore/cvfTrace.cpp
external/resinsight/LibCore/cvfVector3.cpp
external/resinsight/LibGeometry/cvfBoundingBox.cpp
external/resinsight/LibGeometry/cvfBoundingBoxTree.cpp
external/resinsight/LibGeometry/cvfRay.cpp
external/resinsight/ReservoirDataModel/cvfGeometryTools.cpp
external/resinsight/ReservoirDataModel/RigHexIntersectionTools.cpp
external/resinsight/ReservoirDataModel/RigWellLogExtractor.cpp
external/resinsight/ReservoirDataModel/RigWellPath.cpp
external/resinsight/CommonCode/cvfStructGrid.cpp
external/resinsight/cafPdmCore/cafSignal.cpp
external/resinsight/cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp
src/opm/io/eclipse/SummaryNode.cpp
src/opm/json/JsonObject.cpp
src/opm/input/eclipse/Deck/Deck.cpp
@@ -61,6 +101,7 @@ if(ENABLE_ECL_INPUT)
src/opm/input/eclipse/Python/Python.cpp
src/opm/input/eclipse/Schedule/Action/PyAction.cpp
src/opm/input/eclipse/EclipseState/Aquifer/AquiferConfig.cpp
src/opm/input/eclipse/EclipseState/Aquifer/AquiferFlux.cpp
src/opm/input/eclipse/EclipseState/Aquifer/AquiferCT.cpp
src/opm/input/eclipse/EclipseState/Aquifer/Aquifetp.cpp
src/opm/input/eclipse/EclipseState/Aquifer/Aquancon.cpp
@@ -73,21 +114,25 @@ if(ENABLE_ECL_INPUT)
src/opm/input/eclipse/EclipseState/EclipseConfig.cpp
src/opm/input/eclipse/EclipseState/EclipseState.cpp
src/opm/input/eclipse/EclipseState/EndpointScaling.cpp
src/opm/input/eclipse/EclipseState/Grid/FieldProps.cpp
src/opm/input/eclipse/EclipseState/Grid/FieldPropsManager.cpp
src/opm/input/eclipse/EclipseState/Grid/Box.cpp
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/EclipseGrid.cpp
src/opm/input/eclipse/EclipseState/Grid/FieldProps.cpp
src/opm/input/eclipse/EclipseState/Grid/FieldPropsManager.cpp
src/opm/input/eclipse/EclipseState/Grid/FaceDir.cpp
src/opm/input/eclipse/EclipseState/Grid/FaultCollection.cpp
src/opm/input/eclipse/EclipseState/Grid/Fault.cpp
src/opm/input/eclipse/EclipseState/Grid/FaultFace.cpp
src/opm/input/eclipse/EclipseState/Grid/GridDims.cpp
src/opm/input/eclipse/EclipseState/Grid/MapAxes.cpp
src/opm/input/eclipse/EclipseState/Grid/MinpvMode.cpp
src/opm/input/eclipse/EclipseState/Grid/MULTREGTScanner.cpp
src/opm/input/eclipse/EclipseState/Grid/NNC.cpp
src/opm/input/eclipse/EclipseState/Grid/Operate.cpp
src/opm/input/eclipse/EclipseState/Grid/PinchMode.cpp
src/opm/input/eclipse/EclipseState/Grid/readKeywordCarfin.cpp
src/opm/input/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.cpp
src/opm/input/eclipse/EclipseState/Grid/setKeywordBox.cpp
src/opm/input/eclipse/EclipseState/Grid/TranCalculator.cpp
@@ -97,6 +142,7 @@ if(ENABLE_ECL_INPUT)
src/opm/input/eclipse/EclipseState/InitConfig/InitConfig.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/Schedule/Action/ActionAST.cpp
@@ -130,6 +176,7 @@ if(ENABLE_ECL_INPUT)
src/opm/input/eclipse/Schedule/MSW/icd.cpp
src/opm/input/eclipse/Schedule/MSW/Compsegs.cpp
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/AICD.cpp
src/opm/input/eclipse/Schedule/MSW/SICD.cpp
@@ -152,26 +199,29 @@ if(ENABLE_ECL_INPUT)
src/opm/input/eclipse/Schedule/WriteRestartFileEvents.cpp
src/opm/input/eclipse/Schedule/Well/Connection.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/Well.cpp
src/opm/input/eclipse/Schedule/Well/WellConnections.cpp
src/opm/input/eclipse/Schedule/Well/NameOrder.cpp
src/opm/input/eclipse/Schedule/Well/WellMatcher.cpp
src/opm/input/eclipse/Schedule/Well/WList.cpp
src/opm/input/eclipse/Schedule/Well/WListManager.cpp
src/opm/input/eclipse/Schedule/Well/WellEnums.cpp
src/opm/input/eclipse/Schedule/Well/WellBrineProperties.cpp
src/opm/input/eclipse/Schedule/Well/WellEconProductionLimits.cpp
src/opm/input/eclipse/Schedule/Well/WellFoamProperties.cpp
src/opm/input/eclipse/Schedule/Well/WellInjectionProperties.cpp
src/opm/input/eclipse/Schedule/Well/WellMICPProperties.cpp
src/opm/input/eclipse/Schedule/Well/WellPolymerProperties.cpp
src/opm/input/eclipse/Schedule/Well/WellBrineProperties.cpp
src/opm/input/eclipse/Schedule/Well/WellTracerProperties.cpp
src/opm/input/eclipse/Schedule/Well/WVFPEXP.cpp
src/opm/input/eclipse/Schedule/Well/WellProductionProperties.cpp
src/opm/input/eclipse/Schedule/Well/WellTestConfig.cpp
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/WList.cpp
src/opm/input/eclipse/Schedule/Well/WListManager.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
src/opm/input/eclipse/EclipseState/SimulationConfig/RockConfig.cpp
src/opm/input/eclipse/EclipseState/SimulationConfig/SimulationConfig.cpp
@@ -180,6 +230,7 @@ if(ENABLE_ECL_INPUT)
src/opm/input/eclipse/EclipseState/Tables/Aqudims.cpp
src/opm/input/eclipse/EclipseState/Tables/ColumnSchema.cpp
src/opm/input/eclipse/EclipseState/Tables/DenT.cpp
src/opm/input/eclipse/EclipseState/Tables/JouleThomson.cpp
src/opm/input/eclipse/EclipseState/Tables/Eqldims.cpp
src/opm/input/eclipse/EclipseState/Tables/JFunc.cpp
src/opm/input/eclipse/EclipseState/Tables/PvtxTable.cpp
@@ -198,7 +249,6 @@ if(ENABLE_ECL_INPUT)
src/opm/input/eclipse/EclipseState/Tables/Rock2dtrTable.cpp
src/opm/input/eclipse/EclipseState/Tables/PvtwsaltTable.cpp
src/opm/input/eclipse/EclipseState/Tables/BrineDensityTable.cpp
src/opm/input/eclipse/EclipseState/Tables/RwgsaltTable.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
@@ -219,6 +269,7 @@ if(ENABLE_ECL_INPUT)
src/opm/input/eclipse/Schedule/VFPInjTable.cpp
src/opm/input/eclipse/Schedule/VFPProdTable.cpp
src/opm/input/eclipse/Parser/ErrorGuard.cpp
src/opm/input/eclipse/Parser/InputErrorAction.cpp
src/opm/input/eclipse/Parser/ParseContext.cpp
src/opm/input/eclipse/Parser/Parser.cpp
src/opm/input/eclipse/Parser/ParserEnums.cpp
@@ -231,13 +282,27 @@ if(ENABLE_ECL_INPUT)
src/opm/input/eclipse/Units/Dimension.cpp
src/opm/input/eclipse/Units/UnitSystem.cpp
src/opm/input/eclipse/Utility/Functional.cpp
src/opm/material/fluidmatrixinteractions/EclEpsConfig.cpp
src/opm/material/fluidmatrixinteractions/EclEpsGridProperties.cpp
src/opm/material/fluidmatrixinteractions/EclHysteresisConfig.cpp
src/opm/material/fluidmatrixinteractions/EclMaterialLawManager.cpp
src/opm/material/fluidmatrixinteractions/EclMaterialLawManagerReadEffectiveParams.cpp
src/opm/material/fluidmatrixinteractions/EclMaterialLawManagerInitParams.cpp
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/ConstantCompressibilityBrinePvt.cpp
src/opm/material/fluidsystems/blackoilpvt/ConstantCompressibilityOilPvt.cpp
src/opm/material/fluidsystems/blackoilpvt/ConstantCompressibilityWaterPvt.cpp
src/opm/material/fluidsystems/blackoilpvt/GasPvtMultiplexer.cpp
src/opm/material/fluidsystems/blackoilpvt/GasPvtThermal.cpp
src/opm/material/fluidsystems/blackoilpvt/OilPvtMultiplexer.cpp
src/opm/material/fluidsystems/blackoilpvt/OilPvtThermal.cpp
src/opm/material/fluidsystems/blackoilpvt/WaterPvtMultiplexer.cpp
src/opm/material/fluidsystems/blackoilpvt/WaterPvtThermal.cpp
src/opm/material/thermal/EclThermalLawManager.cpp
)
# This list is only used to register a CMake dependency between the the python
# extension and the corresponding C++ wrapper files. The cpp files actually
# listed here are repeated in the actual definition of the extension in the
# setup.py file.
list( APPEND PYTHON_CXX_SOURCE_FILES
python/cxx/connection.cpp
python/cxx/converters.cpp
@@ -301,6 +366,7 @@ if(ENABLE_ECL_OUTPUT)
src/opm/io/eclipse/rst/connection.cpp
src/opm/io/eclipse/rst/group.cpp
src/opm/io/eclipse/rst/header.cpp
src/opm/io/eclipse/rst/netbalan.cpp
src/opm/io/eclipse/rst/network.cpp
src/opm/io/eclipse/rst/udq.cpp
src/opm/io/eclipse/rst/segment.cpp
@@ -347,22 +413,44 @@ if(ENABLE_ECL_OUTPUT)
endif()
list (APPEND TEST_SOURCE_FILES
tests/test_ActiveGridCells.cpp
tests/test_calculateCellVol.cpp
tests/test_cmp.cpp
tests/test_ConditionalStorage.cpp
tests/test_cubic.cpp
tests/test_EvaluationFormat.cpp
tests/test_densead.cpp
tests/test_messagelimiter.cpp
tests/test_nonuniformtablelinear.cpp
tests/test_OpmInputError_format.cpp
tests/test_OpmLog.cpp
tests/test_param.cpp
tests/test_RootFinders.cpp
tests/test_SegmentMatcher.cpp
tests/test_sparsevector.cpp
tests/test_uniformtablelinear.cpp
tests/material/test_2dtables.cpp
tests/material/test_blackoilfluidstate.cpp
tests/material/test_components.cpp
tests/material/test_fluidmatrixinteractions.cpp
tests/material/test_fluidsystems.cpp
tests/material/test_spline.cpp
tests/material/test_tabulation.cpp
)
# tests that need to be linked to dune-common
list(APPEND DUNE_TEST_SOURCE_FILES
tests/material/test_co2brine_ptflash.cpp
tests/material/test_immiscibleflash.cpp
tests/material/test_ncpflash.cpp
tests/material/test_pengrobinson.cpp
tests/material/test_threecomponents_ptflash.cpp
)
if(ENABLE_ECL_INPUT)
list(APPEND TEST_SOURCE_FILES
tests/rst_test.cpp
tests/test_ActiveGridCells.cpp
tests/test_CopyablePtr.cpp
tests/test_ERsm.cpp
tests/test_GuideRate.cpp
tests/test_RestartFileView.cpp
@@ -373,10 +461,16 @@ if(ENABLE_ECL_INPUT)
tests/test_ESmry.cpp
tests/test_EInit.cpp
tests/test_ExtESmry.cpp
tests/test_Serialization.cpp
tests/material/test_co2brinepvt.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/BoxTests.cpp
tests/parser/CarfinTests.cpp
tests/parser/ColumnSchemaTests.cpp
tests/parser/ConnectionTests.cpp
tests/parser/COMPSEGUnits.cpp
@@ -445,6 +539,7 @@ if(ENABLE_ECL_INPUT)
tests/parser/WriteRestartFileEventsTests.cpp
tests/parser/WTEST.cpp)
endif()
if(ENABLE_ECL_OUTPUT)
list (APPEND TEST_SOURCE_FILES
tests/test_ActiveIndexByColumns.cpp
@@ -473,8 +568,8 @@ if(ENABLE_ECL_OUTPUT)
tests/test_Restart.cpp
tests/test_RFT.cpp
tests/test_rst.cpp
tests/test_rst_netbalan.cpp
tests/test_Solution.cpp
tests/test_Serializer.cpp
tests/test_Inplace.cpp
tests/test_Summary.cpp
tests/test_Summary_Group.cpp
@@ -485,6 +580,8 @@ if(ENABLE_ECL_OUTPUT)
)
endif()
list(APPEND TEST_SOURCE_FILES ${DUNE_TEST_SOURCE_FILES})
list (APPEND TEST_DATA_FILES
tests/testdata.param
)
@@ -508,6 +605,7 @@ if(ENABLE_ECL_OUTPUT)
tests/SPE1CASE1.SMSPEC
tests/SPE1CASE1A.SMSPEC
tests/SPE1CASE1B.DATA
tests/SPE1CASE1_WELTRAJ.DATA
tests/props_spe1case1b.inc
tests/SPE9_CP_PACKED.DATA
tests/SOFR_TEST.DATA
@@ -598,6 +696,7 @@ if(ENABLE_ECL_INPUT)
examples/rst_deck.cpp
examples/wellgraph.cpp
examples/make_ext_smry.cpp
examples/co2brinepvt.cpp
)
endif()
@@ -612,12 +711,14 @@ if(ENABLE_ECL_INPUT)
examples/opmhash.cpp
examples/rst_deck.cpp
examples/make_esmry.cpp
examples/co2brinepvt.cpp
)
endif()
list( APPEND PUBLIC_HEADER_FILES
opm/common/ErrorMacros.hpp
opm/common/Exceptions.hpp
opm/common/TimingMacros.hpp
opm/common/OpmLog/CounterLog.hpp
opm/common/OpmLog/EclipsePRTLog.hpp
opm/common/OpmLog/LogBackend.hpp
@@ -630,10 +731,12 @@ list( APPEND PUBLIC_HEADER_FILES
opm/common/OpmLog/OpmLog.hpp
opm/common/OpmLog/StreamLog.hpp
opm/common/OpmLog/TimerLog.hpp
opm/common/utility/Serializer.hpp
opm/common/utility/ActiveGridCells.hpp
opm/common/utility/Demangle.hpp
opm/common/utility/FileSystem.hpp
opm/common/utility/OpmInputError.hpp
opm/common/utility/Serializer.hpp
opm/common/utility/MemPacker.hpp
opm/common/utility/numeric/cmp.hpp
opm/common/utility/platform_dependent/disable_warnings.h
opm/common/utility/platform_dependent/reenable_warnings.h
@@ -656,9 +759,279 @@ list( APPEND PUBLIC_HEADER_FILES
opm/common/utility/shmatch.hpp
opm/common/utility/String.hpp
opm/common/utility/TimeService.hpp
opm/material/components/Lnapl.hpp
opm/material/components/N2.hpp
opm/material/components/H2.hpp
opm/material/components/Unit.hpp
opm/material/components/iapws/Common.hpp
opm/material/components/iapws/Region1.hpp
opm/material/components/iapws/Region4.hpp
opm/material/components/iapws/Region2.hpp
opm/material/components/Dnapl.hpp
opm/material/components/NullComponent.hpp
opm/material/components/H2O.hpp
opm/material/components/TabulatedComponent.hpp
opm/material/components/Xylene.hpp
opm/material/components/SimpleH2O.hpp
opm/material/components/CO2.hpp
opm/material/components/Mesitylene.hpp
opm/material/components/SimpleCO2.hpp
opm/material/components/C10.hpp
opm/material/components/SimpleHuDuanH2O.hpp
opm/material/components/Component.hpp
opm/material/components/Air.hpp
opm/material/components/C1.hpp
opm/material/components/Brine.hpp
opm/material/fluidstates/BlackOilFluidState.hpp
opm/material/fluidstates/NonEquilibriumFluidState.hpp
opm/material/fluidstates/FluidStateSaturationModules.hpp
opm/material/fluidstates/FluidStateCompositionModules.hpp
opm/material/fluidstates/PressureOverlayFluidState.hpp
opm/material/fluidstates/CompositionalFluidState.hpp
opm/material/fluidstates/FluidStateEnthalpyModules.hpp
opm/material/fluidstates/FluidStatePressureModules.hpp
opm/material/fluidstates/ModularFluidState.hpp
opm/material/fluidstates/FluidStateTemperatureModules.hpp
opm/material/fluidstates/SimpleModularFluidState.hpp
opm/material/fluidstates/FluidStateViscosityModules.hpp
opm/material/fluidstates/TemperatureOverlayFluidState.hpp
opm/material/fluidstates/ImmiscibleFluidState.hpp
opm/material/fluidstates/SaturationOverlayFluidState.hpp
opm/material/fluidstates/FluidStateFugacityModules.hpp
opm/material/fluidstates/FluidStateDensityModules.hpp
opm/material/constraintsolvers/ComputeFromReferencePhase.hpp
opm/material/constraintsolvers/PTFlash.hpp
opm/material/constraintsolvers/CompositionFromFugacities.hpp
opm/material/constraintsolvers/MiscibleMultiPhaseComposition.hpp
opm/material/constraintsolvers/NcpFlash.hpp
opm/material/constraintsolvers/ImmiscibleFlash.hpp
opm/material/IdealGas.hpp
opm/material/binarycoefficients/H2O_Mesitylene.hpp
opm/material/binarycoefficients/H2O_Air.hpp
opm/material/binarycoefficients/H2O_N2.hpp
opm/material/binarycoefficients/Air_Mesitylene.hpp
opm/material/binarycoefficients/FullerMethod.hpp
opm/material/binarycoefficients/H2O_Xylene.hpp
opm/material/binarycoefficients/H2O_CO2.hpp
opm/material/binarycoefficients/Air_Xylene.hpp
opm/material/binarycoefficients/Brine_CO2.hpp
opm/material/binarycoefficients/HenryIapws.hpp
opm/material/Constants.hpp
opm/material/fluidsystems/NullParameterCache.hpp
opm/material/fluidsystems/BaseFluidSystem.hpp
opm/material/fluidsystems/BlackOilDefaultIndexTraits.hpp
opm/material/fluidsystems/ParameterCacheBase.hpp
opm/material/fluidsystems/H2ON2LiquidPhaseFluidSystem.hpp
opm/material/fluidsystems/BrineCO2FluidSystem.hpp
opm/material/fluidsystems/GasPhase.hpp
opm/material/fluidsystems/TwoPhaseImmiscibleFluidSystem.hpp
opm/material/fluidsystems/BlackOilFluidSystem.hpp
opm/material/fluidsystems/LiquidPhase.hpp
opm/material/fluidsystems/PTFlashParameterCache.hpp
opm/material/fluidsystems/Spe5ParameterCache.hpp
opm/material/fluidsystems/H2OAirMesityleneFluidSystem.hpp
opm/material/fluidsystems/H2OAirXyleneFluidSystem.hpp
opm/material/fluidsystems/SinglePhaseFluidSystem.hpp
opm/material/fluidsystems/Spe5FluidSystem.hpp
opm/material/fluidsystems/blackoilpvt/SolventPvt.hpp
opm/material/fluidsystems/blackoilpvt/WetHumidGasPvt.hpp
opm/material/fluidsystems/blackoilpvt/WaterPvtThermal.hpp
opm/material/fluidsystems/blackoilpvt/WaterPvtMultiplexer.hpp
opm/material/fluidsystems/blackoilpvt/BrineCo2Pvt.hpp
opm/material/fluidsystems/blackoilpvt/OilPvtMultiplexer.hpp
opm/material/fluidsystems/blackoilpvt/GasPvtMultiplexer.hpp
opm/material/fluidsystems/blackoilpvt/DryHumidGasPvt.hpp
opm/material/fluidsystems/blackoilpvt/WetGasPvt.hpp
opm/material/fluidsystems/blackoilpvt/DeadOilPvt.hpp
opm/material/fluidsystems/blackoilpvt/DryGasPvt.hpp
opm/material/fluidsystems/blackoilpvt/ConstantCompressibilityWaterPvt.hpp
opm/material/fluidsystems/blackoilpvt/LiveOilPvt.hpp
opm/material/fluidsystems/blackoilpvt/OilPvtThermal.hpp
opm/material/fluidsystems/blackoilpvt/ConstantCompressibilityBrinePvt.hpp
opm/material/fluidsystems/blackoilpvt/GasPvtThermal.hpp
opm/material/fluidsystems/blackoilpvt/Co2GasPvt.hpp
opm/material/fluidsystems/blackoilpvt/ConstantCompressibilityOilPvt.hpp
opm/material/fluidsystems/H2OAirFluidSystem.hpp
opm/material/fluidsystems/H2ON2FluidSystem.hpp
opm/material/fluidmatrixinteractions/EclTwoPhaseMaterial.hpp
opm/material/fluidmatrixinteractions/SatCurveMultiplexerParams.hpp
opm/material/fluidmatrixinteractions/EclTwoPhaseMaterialParams.hpp
opm/material/fluidmatrixinteractions/EclEpsTwoPhaseLawParams.hpp
opm/material/fluidmatrixinteractions/ParkerLenhardParams.hpp
opm/material/fluidmatrixinteractions/ThreePhaseParkerVanGenuchtenParams.hpp
opm/material/fluidmatrixinteractions/RegularizedVanGenuchtenParams.hpp
opm/material/fluidmatrixinteractions/MaterialTraits.hpp
opm/material/fluidmatrixinteractions/VanGenuchtenParams.hpp
opm/material/fluidmatrixinteractions/VanGenuchten.hpp
opm/material/fluidmatrixinteractions/LinearMaterial.hpp
opm/material/fluidmatrixinteractions/ParkerLenhard.hpp
opm/material/fluidmatrixinteractions/SatCurveMultiplexer.hpp
opm/material/fluidmatrixinteractions/EclEpsGridProperties.hpp
opm/material/fluidmatrixinteractions/EclHysteresisTwoPhaseLaw.hpp
opm/material/fluidmatrixinteractions/EclHysteresisConfig.hpp
opm/material/fluidmatrixinteractions/RegularizedBrooksCoreyParams.hpp
opm/material/fluidmatrixinteractions/EclMultiplexerMaterialParams.hpp
opm/material/fluidmatrixinteractions/NullMaterial.hpp
opm/material/fluidmatrixinteractions/EclEpsScalingPoints.hpp
opm/material/fluidmatrixinteractions/EclHysteresisTwoPhaseLawParams.hpp
opm/material/fluidmatrixinteractions/TwoPhaseLETCurvesParams.hpp
opm/material/fluidmatrixinteractions/EclStone2Material.hpp
opm/material/fluidmatrixinteractions/NullMaterialParams.hpp
opm/material/fluidmatrixinteractions/LinearMaterialParams.hpp
opm/material/fluidmatrixinteractions/EclStone1Material.hpp
opm/material/fluidmatrixinteractions/EclMultiplexerMaterial.hpp
opm/material/fluidmatrixinteractions/EclStone1MaterialParams.hpp
opm/material/fluidmatrixinteractions/EclEpsConfig.hpp
opm/material/fluidmatrixinteractions/EclStone2MaterialParams.hpp
opm/material/fluidmatrixinteractions/EffToAbsLawParams.hpp
opm/material/fluidmatrixinteractions/RegularizedBrooksCorey.hpp
opm/material/fluidmatrixinteractions/SplineTwoPhaseMaterial.hpp
opm/material/fluidmatrixinteractions/EffToAbsLaw.hpp
opm/material/fluidmatrixinteractions/EclDefaultMaterial.hpp
opm/material/fluidmatrixinteractions/PiecewiseLinearTwoPhaseMaterialParams.hpp
opm/material/fluidmatrixinteractions/SplineTwoPhaseMaterialParams.hpp
opm/material/fluidmatrixinteractions/EclEpsTwoPhaseLaw.hpp
opm/material/fluidmatrixinteractions/TwoPhaseLETCurves.hpp
opm/material/fluidmatrixinteractions/EclMaterialLawManager.hpp
opm/material/fluidmatrixinteractions/DirectionalMaterialLawParams.hpp
opm/material/fluidmatrixinteractions/DirectionalMaterialLawParams.hpp
opm/material/fluidmatrixinteractions/RegularizedVanGenuchten.hpp
opm/material/fluidmatrixinteractions/EclDefaultMaterialParams.hpp
opm/material/fluidmatrixinteractions/ThreePhaseParkerVanGenuchten.hpp
opm/material/fluidmatrixinteractions/BrooksCoreyParams.hpp
opm/material/fluidmatrixinteractions/BrooksCorey.hpp
opm/material/fluidmatrixinteractions/PiecewiseLinearTwoPhaseMaterial.hpp
opm/material/checkFluidSystem.hpp
opm/material/viscositymodels/LBC.hpp
opm/material/viscositymodels/LBCco2rich.hpp
opm/material/common/Valgrind.hpp
opm/material/common/EnsureFinalized.hpp
opm/material/common/quad.hpp
opm/material/common/Spline.hpp
opm/material/common/PolynomialUtils.hpp
opm/material/common/UniformXTabulated2DFunction.hpp
opm/material/common/MathToolbox.hpp
opm/material/common/TridiagonalMatrix.hpp
opm/material/common/ResetLocale.hpp
opm/material/common/HasMemberGeneratorMacros.hpp
opm/material/common/UniformTabulated2DFunction.hpp
opm/material/common/FastSmallVector.hpp
opm/material/common/ConditionalStorage.hpp
opm/material/common/Means.hpp
opm/material/common/IntervalTabulated2DFunction.hpp
opm/material/common/Tabulated1DFunction.hpp
opm/material/densead/Evaluation9.hpp
opm/material/densead/Evaluation8.hpp
opm/material/densead/Evaluation7.hpp
opm/material/densead/Evaluation.hpp
opm/material/densead/Evaluation5.hpp
opm/material/densead/Evaluation3.hpp
opm/material/densead/Evaluation4.hpp
opm/material/densead/Evaluation11.hpp
opm/material/densead/DynamicEvaluation.hpp
opm/material/densead/Math.hpp
opm/material/densead/Evaluation1.hpp
opm/material/densead/Evaluation12.hpp
opm/material/densead/Evaluation2.hpp
opm/material/densead/EvaluationFormat.hpp
opm/material/densead/EvaluationSpecializations.hpp
opm/material/densead/Evaluation10.hpp
opm/material/densead/Evaluation6.hpp
opm/material/eos/PengRobinson.hpp
opm/material/eos/PengRobinsonParams.hpp
opm/material/eos/PengRobinsonParamsMixture.hpp
opm/material/eos/PengRobinsonMixture.hpp
opm/material/thermal/ConstantSolidHeatCapLawParams.hpp
opm/material/thermal/ConstantSolidHeatCapLaw.hpp
opm/material/thermal/EclHeatcrLaw.hpp
opm/material/thermal/SomertonThermalConductionLawParams.hpp
opm/material/thermal/EclThcLawParams.hpp
opm/material/thermal/EclSpecrockLawParams.hpp
opm/material/thermal/EclThconrLaw.hpp
opm/material/thermal/EclThconrLawParams.hpp
opm/material/thermal/FluidThermalConductionLaw.hpp
opm/material/thermal/EclThcLaw.hpp
opm/material/thermal/FluidThermalConductionLawParams.hpp
opm/material/thermal/EclHeatcrLawParams.hpp
opm/material/thermal/NullThermalConductionLaw.hpp
opm/material/thermal/EclSolidEnergyLawMultiplexer.hpp
opm/material/thermal/EclThermalConductionLawMultiplexerParams.hpp
opm/material/thermal/EclThermalConductionLawMultiplexer.hpp
opm/material/thermal/EclSolidEnergyLawMultiplexerParams.hpp
opm/material/thermal/EclThermalLawManager.hpp
opm/material/thermal/SomertonThermalConductionLaw.hpp
opm/material/thermal/EclSpecrockLaw.hpp
opm/material/thermal/NullSolidEnergyLaw.hpp
)
if(ENABLE_ECL_INPUT)
list(APPEND PUBLIC_HEADER_FILES
external/resinsight/CommonCode/cvfStructGrid.h
external/resinsight/LibCore/cvfArray.h
external/resinsight/LibCore/cvfArrayWrapperConst.h
external/resinsight/LibCore/cvfAssert.h
external/resinsight/LibCore/cvfAtomicCounter.h
external/resinsight/LibCore/cvfBase.h
external/resinsight/LibCore/cvfBase64.h
external/resinsight/LibCore/cvfCharArray.h
external/resinsight/LibCore/cvfCodeLocation.h
external/resinsight/LibCore/cvfCollection.h
external/resinsight/LibCore/cvfColor3.h
external/resinsight/LibCore/cvfColor4.h
external/resinsight/LibCore/cvfConfigCore.h
external/resinsight/LibCore/cvfDebugTimer.h
external/resinsight/LibCore/cvfFlags.h
external/resinsight/LibCore/cvfFunctorRange.h
external/resinsight/LibCore/cvfLibCore.h
external/resinsight/LibCore/cvfLogDestination.h
external/resinsight/LibCore/cvfLogger.h
external/resinsight/LibCore/cvfMath.h
external/resinsight/LibCore/cvfMatrix3.h
external/resinsight/LibCore/cvfMatrix4.h
external/resinsight/LibCore/cvfObject.h
external/resinsight/LibCore/cvfPlane.h
external/resinsight/LibCore/cvfPropertySet.h
external/resinsight/LibCore/cvfQuat.h
external/resinsight/LibCore/cvfRect.h
external/resinsight/LibCore/cvfString.h
external/resinsight/LibCore/cvfSystem.h
external/resinsight/LibCore/cvfTBBControl.h
external/resinsight/LibCore/cvfTimer.h
external/resinsight/LibCore/cvfTrace.h
external/resinsight/LibCore/cvfValueArray.h
external/resinsight/LibCore/cvfVector2.h
external/resinsight/LibCore/cvfVector3.h
external/resinsight/LibCore/cvfVector4.h
external/resinsight/LibCore/cvfVersion.h
external/resinsight/LibGeometry/cvfBoundingBox.h
external/resinsight/LibGeometry/cvfBoundingBoxTree.h
external/resinsight/LibGeometry/cvfRay.h
external/resinsight/ReservoirDataModel/RigCellGeometryTools.h
#external/resinsight/ReservoirDataModel/RigEclipseCaseData.h
external/resinsight/ReservoirDataModel/RigHexIntersectionTools.h
#external/resinsight/ReservoirDataModel/RigMainGrid.h
external/resinsight/ReservoirDataModel/RigWellLogExtractionTools.h
external/resinsight/ReservoirDataModel/RigWellLogExtractor.h
external/resinsight/ReservoirDataModel/RigWellPath.h
#external/resinsight/ReservoirDataModel/RigWellPathIntersectionTools.h
external/resinsight/ReservoirDataModel/cvfGeometryTools.h
external/resinsight/cafHexGridIntersectionTools/cafHexGridIntersectionTools.h
external/resinsight/cafPdmCore/cafAppEnum.h
external/resinsight/cafPdmCore/cafAssert.h
external/resinsight/cafPdmCore/cafSignal.h
external/resinsight/LibCore/cvfArray.inl
external/resinsight/LibCore/cvfCollection.inl
external/resinsight/LibCore/cvfFlags.inl
external/resinsight/LibCore/cvfMath.inl
external/resinsight/LibCore/cvfMatrix3.inl
external/resinsight/LibCore/cvfMatrix4.inl
external/resinsight/LibCore/cvfObject.inl
external/resinsight/LibCore/cvfQuat.inl
external/resinsight/LibCore/cvfRect.inl
external/resinsight/LibCore/cvfVector2.inl
external/resinsight/LibCore/cvfVector3.inl
external/resinsight/LibCore/cvfVector4.inl
external/resinsight/ReservoirDataModel/cvfGeometryTools.inl
opm/io/eclipse/SummaryNode.hpp
opm/json/JsonObject.hpp
opm/input/eclipse/Utility/Functional.hpp
@@ -694,11 +1067,14 @@ if(ENABLE_ECL_INPUT)
opm/input/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.hpp
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/FieldProps.hpp
opm/input/eclipse/EclipseState/Grid/FieldPropsManager.hpp
opm/input/eclipse/EclipseState/Grid/FaultFace.hpp
opm/input/eclipse/EclipseState/Grid/NNC.hpp
opm/input/eclipse/EclipseState/Grid/EclipseGrid.hpp
opm/input/eclipse/EclipseState/Grid/BoxManager.hpp
opm/input/eclipse/EclipseState/Grid/CarfinManager.hpp
opm/input/eclipse/EclipseState/Grid/FaceDir.hpp
opm/input/eclipse/EclipseState/Grid/MapAxes.hpp
opm/input/eclipse/EclipseState/Grid/MinpvMode.hpp
@@ -706,6 +1082,7 @@ if(ENABLE_ECL_INPUT)
opm/input/eclipse/EclipseState/TracerConfig.hpp
opm/input/eclipse/EclipseState/MICPpara.hpp
opm/input/eclipse/EclipseState/Tables/DenT.hpp
opm/input/eclipse/EclipseState/Tables/JouleThomson.hpp
opm/input/eclipse/EclipseState/Tables/SimpleTable.hpp
opm/input/eclipse/EclipseState/Tables/StandardCond.hpp
opm/input/eclipse/EclipseState/Tables/PolyInjTable.hpp
@@ -755,6 +1132,7 @@ if(ENABLE_ECL_INPUT)
opm/input/eclipse/EclipseState/Tables/WatvisctTable.hpp
opm/input/eclipse/EclipseState/Tables/TableEnums.hpp
opm/input/eclipse/EclipseState/Tables/RvvdTable.hpp
opm/input/eclipse/EclipseState/Tables/RvwvdTable.hpp
opm/input/eclipse/EclipseState/Tables/TableContainer.hpp
opm/input/eclipse/EclipseState/Tables/AqutabTable.hpp
opm/input/eclipse/EclipseState/Tables/PlyadsTable.hpp
@@ -769,6 +1147,8 @@ if(ENABLE_ECL_INPUT)
opm/input/eclipse/EclipseState/Tables/PvdoTable.hpp
opm/input/eclipse/EclipseState/Tables/OilvisctTable.hpp
opm/input/eclipse/EclipseState/Tables/SgfnTable.hpp
opm/input/eclipse/EclipseState/Tables/WsfTable.hpp
opm/input/eclipse/EclipseState/Tables/GsfTable.hpp
opm/input/eclipse/EclipseState/Tables/MiscTable.hpp
opm/input/eclipse/EclipseState/Tables/SgwfnTable.hpp
opm/input/eclipse/EclipseState/Tables/PvdsTable.hpp
@@ -791,6 +1171,7 @@ if(ENABLE_ECL_INPUT)
opm/input/eclipse/EclipseState/EclipseConfig.hpp
opm/input/eclipse/EclipseState/Aquifer/Aquancon.hpp
opm/input/eclipse/EclipseState/Aquifer/AquiferConfig.hpp
opm/input/eclipse/EclipseState/Aquifer/AquiferFlux.hpp
opm/input/eclipse/EclipseState/Aquifer/AquiferCT.hpp
opm/input/eclipse/EclipseState/Aquifer/Aquifetp.hpp
opm/input/eclipse/EclipseState/Aquifer/NumericalAquifer/NumericalAquiferCell.hpp
@@ -820,12 +1201,13 @@ 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/ProductionControls.hpp
opm/input/eclipse/Schedule/Well/InjectionControls.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/Well.hpp
opm/input/eclipse/Schedule/Well/WellEnums.hpp
opm/input/eclipse/Schedule/Well/WellInjectionControls.hpp
opm/input/eclipse/Schedule/Well/WellProductionControls.hpp
opm/input/eclipse/Schedule/Well/WList.hpp
opm/input/eclipse/Schedule/Well/NameOrder.hpp
opm/input/eclipse/Schedule/Well/WellMatcher.hpp
@@ -833,15 +1215,14 @@ if(ENABLE_ECL_INPUT)
opm/input/eclipse/Schedule/Well/WellEconProductionLimits.hpp
opm/input/eclipse/Schedule/Well/WellFoamProperties.hpp
opm/input/eclipse/Schedule/Well/WellBrineProperties.hpp
opm/input/eclipse/Schedule/Well/WellInjectionProperties.hpp
opm/input/eclipse/Schedule/Well/WellMICPProperties.hpp
opm/input/eclipse/Schedule/Well/WellPolymerProperties.hpp
opm/input/eclipse/Schedule/Well/WellProductionProperties.hpp
opm/input/eclipse/Schedule/Well/WellTracerProperties.hpp
opm/input/eclipse/Schedule/Well/WVFPEXP.hpp
opm/input/eclipse/Schedule/Well/WellTestConfig.hpp
opm/input/eclipse/Schedule/Well/WellTestState.hpp
opm/input/eclipse/Schedule/Well/WellConnections.hpp
opm/input/eclipse/Schedule/WellTraj/RigEclipseWellLogExtractor.hpp
opm/input/eclipse/Schedule/SummaryState.hpp
opm/input/eclipse/Schedule/RFTConfig.hpp
opm/input/eclipse/Schedule/RPTConfig.hpp
@@ -867,7 +1248,7 @@ if(ENABLE_ECL_INPUT)
opm/input/eclipse/Schedule/OilVaporizationProperties.hpp
opm/input/eclipse/Schedule/MSW/icd.hpp
opm/input/eclipse/Schedule/MSW/Segment.hpp
opm/input/eclipse/Schedule/MSW/Segment.hpp
opm/input/eclipse/Schedule/MSW/SegmentMatcher.hpp
opm/input/eclipse/Schedule/MSW/WellSegments.hpp
opm/input/eclipse/Schedule/MSW/AICD.hpp
opm/input/eclipse/Schedule/MSW/SICD.hpp
@@ -878,6 +1259,7 @@ if(ENABLE_ECL_INPUT)
opm/input/eclipse/Schedule/MSW/Valve.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/UDQAssign.hpp
opm/input/eclipse/Schedule/UDQ/UDQASTNode.hpp
@@ -931,6 +1313,7 @@ if(ENABLE_ECL_OUTPUT)
opm/io/eclipse/rst/connection.hpp
opm/io/eclipse/rst/group.hpp
opm/io/eclipse/rst/header.hpp
opm/io/eclipse/rst/netbalan.hpp
opm/io/eclipse/rst/network.hpp
opm/io/eclipse/rst/segment.hpp
opm/io/eclipse/rst/state.hpp
@@ -985,6 +1368,7 @@ if(ENABLE_ECL_OUTPUT)
opm/output/eclipse/WriteRPT.hpp
opm/output/eclipse/WriteRestartHelpers.hpp
opm/output/OutputWriter.hpp
opm/utility/CopyablePtr.hpp
opm/utility/EModel.hpp
)
endif()

View File

@@ -31,4 +31,10 @@ foreach (name A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
${BASE_DIR}/tmp_gen/ParserKeywords/${name}.cpp
${BASE_DIR}/ParserKeywords/${name}.cpp)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
${BASE_DIR}/tmp_gen/ParserKeywords/ParserInit${name}.cpp
${BASE_DIR}/ParserKeywords/ParserInit${name}.cpp)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
${BASE_DIR}/tmp_gen/ParserKeywords/Builtin${name}.cpp
${BASE_DIR}/ParserKeywords/Builtin${name}.cpp)
endforeach()

View File

@@ -42,6 +42,7 @@ opm_add_test(EclipseStateTests
list(APPEND EXTRA_TESTS EclipseStateTests)
foreach (test BoxTest
CarfinTest
CheckDeckValidity
EclipseGridCreateFromDeck
IncludeTest
@@ -59,16 +60,6 @@ foreach (test BoxTest
list(APPEND EXTRA_TESTS ${test})
endforeach ()
opm_add_test( rst_spe1
SOURCES tests/rst_test.cpp
LIBRARIES ${TEST_LIBS}
TEST_ARGS tests/SPE1CASE2.DATA tests/SPE1CASE2_RESTART.DATA )
opm_add_test( rst_msw
SOURCES tests/rst_test.cpp
LIBRARIES ${TEST_LIBS}
TEST_ARGS tests/MSW.DATA tests/MSW_RESTART.DATA )
add_test( NAME rst_deck_test
COMMAND ${PROJECT_SOURCE_DIR}/tests/rst_test_driver.sh ${PROJECT_BINARY_DIR}/bin/rst_deck ${PROJECT_BINARY_DIR}/bin/opmhash
${PROJECT_SOURCE_DIR}/tests/SPE1CASE2_INCLUDE.DATA)
@@ -104,8 +95,6 @@ if(HAVE_OPM_TESTS)
${OPM_TESTS_ROOT}/spe9/SPE9_CP_GROUP.DATA
${OPM_TESTS_ROOT}/spe9/SPE9_CP_SHORT.DATA
${OPM_TESTS_ROOT}/spe9/SPE9.DATA
${OPM_TESTS_ROOT}/spe10model1/SPE10_MODEL1.DATA
${OPM_TESTS_ROOT}/spe10model2/SPE10_MODEL2.DATA
${OPM_TESTS_ROOT}/msw_2d_h/2D_H__.DATA
${OPM_TESTS_ROOT}/model2/0_BASE_MODEL2.DATA
${OPM_TESTS_ROOT}/model2/1_MULTREGT_MODEL2.DATA

View File

@@ -11,6 +11,7 @@ set(genkw_SOURCES src/opm/json/JsonObject.cpp
src/opm/input/eclipse/Deck/DeckOutput.cpp
src/opm/input/eclipse/Generator/KeywordGenerator.cpp
src/opm/input/eclipse/Generator/KeywordLoader.cpp
src/opm/input/eclipse/Schedule/UDQ/UDQEnums.cpp
src/opm/input/eclipse/Parser/ErrorGuard.cpp
src/opm/input/eclipse/Parser/ParseContext.cpp
src/opm/input/eclipse/Parser/ParserEnums.cpp
@@ -24,6 +25,7 @@ set(genkw_SOURCES src/opm/json/JsonObject.cpp
src/opm/input/eclipse/Units/UnitSystem.cpp
src/opm/common/utility/OpmInputError.cpp
src/opm/common/utility/shmatch.cpp
src/opm/common/utility/String.cpp
src/opm/common/OpmLog/OpmLog.cpp
src/opm/common/OpmLog/Logger.cpp
src/opm/common/OpmLog/StreamLog.cpp
@@ -51,76 +53,35 @@ set( genkw_argv keyword_list.argv
opm/input/eclipse/Parser/ParserKeywords
${PROJECT_BINARY_DIR}/tmp_gen/TestKeywords.cpp)
set( _tmp_output
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/A.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/B.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/C.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/D.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/E.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/F.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/G.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/H.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/I.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/J.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/K.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/L.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/M.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/N.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/O.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/P.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/Q.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/R.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/S.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/T.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/U.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/V.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/W.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/X.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/Y.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/Z.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserInit.cpp
${PROJECT_BINARY_DIR}/tmp_gen/TestKeywords.cpp)
foreach (name A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)
list(APPEND _tmp_output ${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/${name}.cpp
${PROJECT_BINARY_DIR}/tmp_gen/include/opm/input/eclipse/Parser/ParserKeywords/${name}.hpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/ParserInit${name}.cpp
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/Builtin${name}.cpp
${PROJECT_BINARY_DIR}/tmp_gen/include/opm/input/eclipse/Parser/ParserKeywords/ParserInit${name}.hpp)
list(APPEND _target_output ${PROJECT_BINARY_DIR}/ParserKeywords/${name}.cpp
${PROJECT_BINARY_DIR}/include/opm/input/eclipse/Parser/ParserKeywords/${name}.hpp
${PROJECT_BINARY_DIR}/ParserKeywords/ParserInit${name}.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/Builtin${name}.cpp
${PROJECT_BINARY_DIR}/include/opm/input/eclipse/Parser/ParserKeywords/ParserInit${name}.hpp)
endforeach()
foreach(name TestKeywords.cpp ParserInit.cpp)
list(APPEND _target_output ${PROJECT_BINARY_DIR}/${name})
list(APPEND _tmp_output ${PROJECT_BINARY_DIR}/tmp_gen/${name})
endforeach()
set( _target_output
${PROJECT_BINARY_DIR}/ParserKeywords/A.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/B.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/C.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/D.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/E.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/F.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/G.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/H.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/I.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/J.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/K.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/L.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/M.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/N.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/O.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/P.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/Q.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/R.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/S.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/T.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/U.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/V.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/W.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/X.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/Y.cpp
${PROJECT_BINARY_DIR}/ParserKeywords/Z.cpp
${PROJECT_BINARY_DIR}/TestKeywords.cpp
${PROJECT_BINARY_DIR}/ParserInit.cpp)
list(APPEND _target_output ${PROJECT_BINARY_DIR}/include/opm/input/eclipse/Parser/ParserKeywords/Builtin.hpp)
list(APPEND _tmp_output ${PROJECT_BINARY_DIR}/tmp_gen/include/opm/input/eclipse/Parser/ParserKeywords/Builtin.hpp)
set(GEN_DEPS ${_tmp_output})
if (OPM_ENABLE_PYTHON)
list(APPEND genkw_argv ${PROJECT_BINARY_DIR}/tmp_gen/builtin_pybind11.cpp)
list(APPEND _tmp_output ${PROJECT_BINARY_DIR}/tmp_gen/builtin_pybind11.cpp)
list(APPEND _target_output ${PROJECT_BINARY_DIR}/python/cxx/builtin_pybind11.cpp)
list(APPEND GEN_DEPS copy_python)
endif()
add_custom_command( OUTPUT
${_tmp_output}
COMMAND genkw ${genkw_argv}
@@ -129,5 +90,5 @@ add_custom_command( OUTPUT
# To avoid some rebuilds
add_custom_command(OUTPUT
${_target_output}
DEPENDS ${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/A.cpp
DEPENDS ${GEN_DEPS}
COMMAND ${CMAKE_COMMAND} -DBASE_DIR=${PROJECT_BINARY_DIR} -P ${PROJECT_SOURCE_DIR}/CopyHeaders.cmake)

1011
bin/genEvalSpecializations.py Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -46,8 +46,8 @@ if (METIS_INCLUDE_DIRS OR METIS_LIBRARIES)
file(READ "${METIS_INCLUDE_DIRS}/metis.h" metisheader)
string(REGEX MATCH "#define METIS_VER_MAJOR[ ]+([0-9]+)" METIS_MAJOR_VERSION ${metisheader})
if(NOT METIS_API_VERSION AND METIS_MAJOR_VERSION)
# string(REGEX REPLACE ".*#define METIS_VER_MAJOR[ ]+([0-9]+).*" "\\1"
# METIS_MAJOR_VERSION "${metisheader}")
string(REGEX REPLACE ".*#define METIS_VER_MAJOR[ ]+([0-9]+).*" "\\1"
METIS_MAJOR_VERSION "${metisheader}")
if(METIS_MAJOR_VERSION GREATER_EQUAL 3 AND METIS_MAJOR_VERSION LESS 5)
set(METIS_API_VERSION "3")
else()
@@ -55,11 +55,13 @@ if (METIS_INCLUDE_DIRS OR METIS_LIBRARIES)
endif()
endif()
add_library(METIS::METIS UNKNOWN IMPORTED)
set_target_properties(METIS::METIS PROPERTIES
IMPORTED_LOCATION ${METIS_LIBRARIES}
INTERFACE_INCLUDE_DIRECTORIES ${METIS_INCLUDE_DIRS}
INTERFACE_COMPILE_DEFINITIONS METIS_API_VERSION=${METIS_API_VERSION})
if (NOT TARGET METIS::METIS)
add_library(METIS::METIS UNKNOWN IMPORTED)
set_target_properties(METIS::METIS PROPERTIES
IMPORTED_LOCATION ${METIS_LIBRARIES}
INTERFACE_INCLUDE_DIRECTORIES ${METIS_INCLUDE_DIRS}
INTERFACE_COMPILE_DEFINITIONS METIS_API_VERSION=${METIS_API_VERSION})
endif()
endif()
# print a message to indicate status of this package

View File

@@ -0,0 +1,49 @@
# Module that checks whether the compiler supports the
# quadruple precision floating point math
#
# Adds target QuadMath::QuadMath if found
#
# perform tests
include(CheckCXXSourceCompiles)
include(CMakePushCheckState)
cmake_push_check_state()
set(CMAKE_REQUIRED_LIBRARIES quadmath)
if(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
set(CMAKE_REQUIRED_FLAGS "-fext-numeric-literals")
endif()
check_cxx_source_compiles("
#include <quadmath.h>
int main ()
{
__float128 r = 1.0q;
r = strtoflt128(\"1.2345678\", NULL);
return 0;
}" QuadMath_COMPILES)
cmake_pop_check_state() # Reset CMAKE_REQUIRED_XXX variables
if(QuadMath_COMPILES)
# Use additional variable for better report message
set(QuadMath_VAR "(Supported by compiler)")
endif()
# Report that package was found
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(QuadMath
DEFAULT_MSG
QuadMath_VAR QuadMath_COMPILES
)
# add imported target for quadmath
if(QuadMath_FOUND AND NOT TARGET QuadMath::QuadMath)
# Compiler supports QuadMath: Add appropriate linker flag
add_library(QuadMath::QuadMath INTERFACE IMPORTED)
target_link_libraries(QuadMath::QuadMath INTERFACE quadmath)
target_compile_definitions(QuadMath::QuadMath INTERFACE
_GLIBCXX_USE_FLOAT128 HAVE_QUAD=1
)
target_compile_options(QuadMath::QuadMath INTERFACE
$<$<CXX_COMPILER_ID:GNU>:-fext-numeric-literals>
)
endif()

View File

@@ -1,54 +0,0 @@
# Module that checks whether the compiler supports the
# quadruple precision floating point math
#
# Sets the following variables:
# HAVE_QUAD
# QUADMATH_LIBRARIES
#
# perform tests
include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)
include(CMakePushCheckState)
include(CheckCXXCompilerFlag)
if(NOT DEFINED USE_QUADMATH OR USE_QUADMATH)
if(NOT DEFINED HAVE_EXTENDED_NUMERIC_LITERALS)
check_cxx_compiler_flag("-Werror -fext-numeric-literals" HAVE_EXTENDED_NUMERIC_LITERALS)
endif()
if (HAVE_EXTENDED_NUMERIC_LITERALS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fext-numeric-literals")
endif()
cmake_push_check_state(RESET)
list(APPEND CMAKE_REQUIRED_LIBRARIES "quadmath")
CHECK_CXX_SOURCE_COMPILES("
#include <quadmath.h>
int main(void){
__float128 foo = sqrtq(123.456);
foo = FLT128_MIN;
}" QUADMATH_FOUND)
cmake_pop_check_state()
if (QUADMATH_FOUND)
set(QUADMATH_LIBRARIES "quadmath")
set(HAVE_QUAD "${QUADMATH_FOUND}")
add_library(QuadMath::QuadMath INTERFACE IMPORTED)
set_target_properties(QuadMath::QuadMath PROPERTIES
INTERFACE_LINK_LIBRARIES quadmath
INTERFACE_COMPILE_DEFINITIONS _GLIBCXX_USE_FLOAT128
INTERFACE_COMPILE_OPTIONS $<$<CXX_COMPILER_ID:GNU>:-fext-numeric-literals>)
endif()
endif()
if (USE_QUADMATH AND NOT QUADMATH_FOUND)
message(FATAL_ERROR "Quadruple precision math support was explicitly requested but is unavailable!")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Quadmath
DEFAULT_MSG
QUADMATH_LIBRARIES
HAVE_QUAD
)

View File

@@ -3,13 +3,10 @@
# This module defines:
# VALGRIND_INCLUDE_DIR, where to find valgrind/memcheck.h, etc.
# VALGRIND_PROGRAM, the valgrind executable.
# VALGRIND_FOUND, If false, do not try to use valgrind.
# Valgrind_FOUND, If false, do not try to use valgrind.
#
# If you have valgrind installed in a non-standard place, you can define
# VALGRIND_ROOT to tell cmake where it is.
if (VALGRIND_FOUND)
return()
endif()
find_path(VALGRIND_INCLUDE_DIR valgrind/memcheck.h
/usr/include /usr/local/include ${VALGRIND_ROOT}/include)
@@ -18,7 +15,7 @@ find_path(VALGRIND_INCLUDE_DIR valgrind/memcheck.h
# path, but this does not hurt...
find_program(VALGRIND_PROGRAM NAMES valgrind PATH ${VALGRIND_ROOT}/bin)
find_package_handle_standard_args(VALGRIND DEFAULT_MSG
find_package_handle_standard_args(Valgrind DEFAULT_MSG
VALGRIND_INCLUDE_DIR
VALGRIND_PROGRAM)

View File

@@ -24,7 +24,7 @@ find_package(PTScotch)
#find_package(ParMETIS)
# search for files which implements this module
find_path (ZOLTAN_INCLUDE_DIRS
find_path (ZOLTAN_INCLUDE_DIR
NAMES "zoltan.h"
PATHS ${ZOLTAN_SEARCH_PATH}
PATH_SUFFIXES include trilinos
@@ -35,7 +35,7 @@ if (CMAKE_SIZEOF_VOID_P)
math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}")
endif (CMAKE_SIZEOF_VOID_P)
find_library(ZOLTAN_LIBRARIES
find_library(ZOLTAN_LIBRARY
NAMES zoltan trilinos_zoltan
PATHS ${ZOLTAN_SEARCH_PATH}
PATH_SUFFIXES "lib/.libs" "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
@@ -50,15 +50,20 @@ include (FindPackageHandleStandardArgs)
find_package_handle_standard_args(ZOLTAN
DEFAULT_MSG
ZOLTAN_LIBRARIES
ZOLTAN_INCLUDE_DIRS
ZOLTAN_LIBRARY
ZOLTAN_INCLUDE_DIR
MPI_FOUND
)
if (ZOLTAN_FOUND)
set(HAVE_ZOLTAN 1)
set(ZOLTAN_LIBRARIES ${ZOLTAN_LIBRARIES} ${PARMETIS_LIBRARIES} ${PTSCOTCH_LIBRARIES})
set(ZOLTAN_INCLUDE_DIRS ${ZOLTAN_INCLUDE_DIRS} ${PARMETIS_INCLUDE_DIRS}
set(ZOLTAN_LIBRARIES ${ZOLTAN_LIBRARY} ${PARMETIS_LIBRARIES} ${PTSCOTCH_LIBRARIES})
set(ZOLTAN_INCLUDE_DIRS ${ZOLTAN_INCLUDE_DIR} ${PARMETIS_INCLUDE_DIRS}
${PTSCOTCH_INCLUDE_DIRS})
# log result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determing location of ZOLTAN succeeded:\n"
" Include directory: ${ZOLTAN_INCLUDE_DIRS}\n"
" Library directory: ${ZOLTAN_LIBRARIES}\n\n")
endif()

View File

@@ -22,10 +22,11 @@ find_opm_package (
"dune-common REQUIRED;
dune-grid REQUIRED;
dune-alugrid;
dune-polygongrid;
ZLIB;
ZOLTAN;
METIS;
Quadmath
QuadMath
"
# header to search for
"dune/fem/space/shapefunctionset/legendre.hh"

View File

@@ -19,7 +19,7 @@ find_opm_package (
"dune-common REQUIRED;
ParMETIS;
SuperLU;
SuiteSparse COMPONENTS umfpack
SuiteSparse COMPONENTS umfpack REQUIRED
"
# header to search for
"dune/istl/bcrsmatrix.hh"

View File

@@ -0,0 +1,47 @@
# - Find DUNE Fem library
#
# Defines the following variables:
# dune-polygongrid_INCLUDE_DIRS Directory of header files
# dune-polygongrid_LIBRARIES Directory of shared object files
# dune-polygongrid_DEFINITIONS Defines that must be set to compile
# dune-alugrid_CONFIG_VARS List of defines that should be in config.h
# HAVE_DUNE_POLYGONGRID Binary value to use in config.h
# Copyright (C) 2015 IRIS AS
# This code is licensed under The GNU General Public License v3.0
include (OpmPackage)
find_opm_package (
# module name
"dune-polygongrid"
# dependencies
# 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;
"
# header to search for
"dune/polygongrid/mesh.hh"
# library to search for
"dunepolygongrid"
# defines to be added to compilations
""
# test program
"#include <dune/polygongrid/mesh.hh>
int main (void) {
return 0;
}
"
# config variables
"HAVE_DUNE_POLYGONGRID
")
#debug_find_vars ("dune-polygongrid")
# make version number available in config.h
include (UseDuneVer)
find_dune_version ("dune" "polygongrid")

View File

@@ -38,7 +38,7 @@ macro (opm_compile opm)
endif()
set (${opm}_VERSION "${${opm}_VERSION_MAJOR}.${${opm}_VERSION_MINOR}")
if (${opm}_SOURCES)
add_library (${${opm}_TARGET} ${${opm}_LIBRARY_TYPE} ${${opm}_SOURCES})
add_library (${${opm}_TARGET} ${${opm}_LIBRARY_TYPE} ${${opm}_SOURCES} ${${opm}_HEADERS})
set_target_properties (${${opm}_TARGET} PROPERTIES
SOVERSION ${${opm}_VERSION}
VERSION ${${opm}_VERSION}

View File

@@ -128,35 +128,41 @@ macro (find_and_append_package_to prefix name)
# We even need to repeat the search for opm-common once as this is done
# in the top most CMakeLists.txt without querying defines, setting dependencies
# and the likes which is only done via opm_find_package
if ( (NOT DEFINED ${name}_FOUND AND NOT DEFINED ${NAME}_FOUND )
OR _search_components GREATER -1)
string(REGEX MATCH "(opm)-.*" _is_opm ${name})
if(NOT _is_opm)
# When using Boost >= 1.70 and e.g. CMake 3.18 we need to make sure that
# subsequent searches are using config mode too. Otherwise the library
# list will be completely messed up. We use a set Boost_Dir to detect that
# previous searches were done using config mode.
if("${name}" STREQUAL "Boost" AND Boost_DIR)
set(_CONFIG_MODE CONFIG)
else()
set(_CONFIG_MODE "")
endif()
find_package (${name} ${ARGN} ${_CONFIG_MODE})
string(REGEX MATCH "(opm)-.*" _is_opm ${name})
if(NOT _is_opm)
# When using Boost >= 1.70 and e.g. CMake 3.18 we need to make sure that
# subsequent searches are using config mode too. Otherwise the library
# list will be completely messed up. We use a set Boost_Dir to detect that
# previous searches were done using config mode.
if("${name}" STREQUAL "Boost" AND Boost_DIR)
set(_CONFIG_MODE CONFIG)
else()
if(${name}_DIR)
find_package (${name} ${${prefix}_VERSION_MAJOR}.${${prefix}_VERSION_MINOR} ${ARGN} NO_MODULE PATHS ${${name}_DIR} NO_DEFAULT_PATH)
else()
find_package (${name} ${${prefix}_VERSION_MAJOR}.${${prefix}_VERSION_MINOR} ${ARGN} NO_MODULE)
endif()
include(FindPackageHandleStandardArgs)
if(${name}_FOUND AND ${name}_LIBRARY STREQUAL "")
find_package_handle_standard_args(${name}
REQUIRED_VARS ${name}_INCLUDE_DIRS)
else()
find_package_handle_standard_args(${name}
REQUIRED_VARS ${name}_LIBRARY)
endif()
endif ()
set(_CONFIG_MODE "")
endif()
find_package (${name} ${ARGN} ${_CONFIG_MODE})
else()
if(${name}_DIR)
find_package (${name} ${${prefix}_VERSION_MAJOR}.${${prefix}_VERSION_MINOR} ${ARGN} NO_MODULE PATHS ${${name}_DIR} NO_DEFAULT_PATH)
else()
find_package (${name} ${${prefix}_VERSION_MAJOR}.${${prefix}_VERSION_MINOR} ${ARGN} NO_MODULE)
endif()
include(FindPackageHandleStandardArgs)
if( CMAKE_VERSION VERSION_GREATER_EQUAL "3.17")
# For some reason we will e.g. call
# find_package_handle_standard_args(opm-common)
# in a find_package(opm-material) call and this will
# usuallly print an annoying warnig. Prevent this at least
# for cmake >=3.17
# \todo Check why/whether these calls are even needed.
set(_NAME_MISMATCHED "NAME_MISMATCHED")
endif()
if(${name}_FOUND AND ${name}_LIBRARY STREQUAL "")
find_package_handle_standard_args(${name}
REQUIRED_VARS ${name}_INCLUDE_DIRS ${_NAME_MISMATCHED})
else()
find_package_handle_standard_args(${name}
REQUIRED_VARS ${name}_LIBRARY ${_NAME_MISMATCHED})
endif()
endif ()
if (NOT DEFINED ${name}_FOUND)
set (${name}_FOUND "${${NAME}_FOUND}")

View File

@@ -130,7 +130,7 @@ endif ()
# parallel computing must be explicitly enabled
# This needs to be in OpmInit as prereqs is called before OpmLibMain is included.
option (USE_MPI "Use Message Passing Interface for parallel computing" OFF)
option (USE_MPI "Use Message Passing Interface for parallel computing" ON)
if (NOT USE_MPI)
set (CMAKE_DISABLE_FIND_PACKAGE_MPI TRUE)
endif ()
@@ -142,9 +142,7 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# quadmath must be explicitly enabled
# This needs to be in OpmInit as prereqs is called before OpmLibMain is included.
option (USE_QUADMATH "Use high precision floating point library (slow)" OFF)
if (NOT USE_QUADMATH)
set (CMAKE_DISABLE_FIND_PACKAGE_QuadMath TRUE)
option (USE_SUPERLU "Use SuperLU direct solvers for AMG (if umfpack is not found)" ON)
if (NOT USE_SUPERLU)
set (CMAKE_DISABLE_FIND_PACKAGE_SuperLU TRUE)
endif ()

View File

@@ -63,9 +63,6 @@ find_openmp (${project})
include (UseThreads)
find_threads (${project})
# SuperLU is optional
option (USE_SUPERLU "Use SuperLU direct solvers" OFF)
# PETSc is optional
option (USE_PETSC "Use PETSc iterative solvers" OFF)

View File

@@ -124,7 +124,7 @@ macro (find_opm_package module deps header lib defs prog conf)
# without config.h
config_cmd_line (${module}_CMD_CONFIG ${module}_CONFIG_VARS)
if(prog)
if(prog) # always evaluates to false, but makes tests with DUNE 2.6-2.7 work
# check that we can compile a small test-program
include (CMakePushCheckState)
cmake_push_check_state ()
@@ -138,13 +138,16 @@ macro (find_opm_package module deps header lib defs prog conf)
list (APPEND CMAKE_REQUIRED_DEFINITIONS ${${module}_CMD_CONFIG})
check_cxx_source_compiles ("${prog}" HAVE_${MODULE})
cmake_pop_check_state ()
else(prog)
else()
if(${module}_FOUND)
# No test code provided, mark compilation as successful
# if module was founf
set(HAVE_${MODULE} 1)
# if module was found
# Has to be cached because of scope. Otherwise it is not accessible
# where it is used.
set(HAVE_${MODULE} 1 CACHE BOOL "${module} found")
mark_as_advanced(HAVE_${MODULE})
endif(${module}_FOUND)
endif(prog)
endif()
# write status message in the same manner as everyone else
include (FindPackageHandleStandardArgs)

View File

@@ -54,6 +54,12 @@ function (configure_cmake_file name variant version)
foreach (suffix IN LISTS variable_suffices)
set (opm-project_${suffix} "${${name}_${suffix}}")
endforeach (suffix)
if (BUILD_SHARED_LIBS)
# No need to list shared libraries as the linker information is alread
# in the shared lib
string(REGEX REPLACE ";?[^;]*.so" "" opm-project_LIBRARIES "${opm-project_LIBRARIES}")
endif()
set (opm-project_NAME "${${name}_NAME}")
set (opm-project_NAME_UC "${${name}_NAME}")
string(TOUPPER "${opm-project_NAME}" opm-project_NAME_UC)

View File

@@ -0,0 +1,28 @@
# We make this a cmake module so it can be used from opm-simulators' CMakeLists.txt also
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "
import site, sys
try:
sys.stdout.write(site.getsitepackages()[-1])
except e:
sys.stdout.write('')" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES_PATH)
# -------------------------------------------------------------------------
# 1: Wrap C++ functionality in Python
if (PYTHON_SITE_PACKAGES_PATH MATCHES ".*/dist-packages/?" AND
CMAKE_INSTALL_PREFIX MATCHES "^/usr.*")
# dist-packages is only used if we install below /usr and python's site packages
# path matches dist-packages
set(PYTHON_PACKAGE_PATH "dist-packages")
else()
set(PYTHON_PACKAGE_PATH "site-packages")
endif()
if(PYTHON_VERSION_MAJOR)
set(PY_MAJOR ${PYTHON_VERSION_MAJOR})
else()
set(PY_MAJOR ${Python3_VERSION_MAJOR})
endif()
if(PYTHON_VERSION_MINOR)
set(PY_MINOR ${PYTHON_VERSION_MINOR})
else()
set(PY_MINOR ${Python3_VERSION_MINOR})
endif()
set(PYTHON_INSTALL_PREFIX "lib/python${PY_MAJOR}.${PY_MINOR}/${PYTHON_PACKAGE_PATH}" CACHE STRING "Subdirectory to install Python modules in")

View File

@@ -0,0 +1,27 @@
if(USE_DAMARIS_LIB AND MPI_FOUND)
if (Damaris_FOUND)
set(HAVE_DAMARIS 1)
message(STATUS "The Damaris library was found: ${Damaris_VERSION} ${Damaris_DIR}")
if (Damaris_HAS_HDF5)
message(STATUS "The Damaris library has HDF5 support: ${HDF5_VERSION}")
else()
message(STATUS "The Damaris library does NOT have HDF5 support")
endif()
if (Damaris_HAS_VISIT)
message(STATUS "The Damaris library has VisIt support: ${VisIt_VERSION}")
else()
message(STATUS "The Damaris library does NOT have VisIt support")
endif()
if (Damaris_HAS_CATALYST)
message(STATUS "The Damaris library has Catalyst support: ${Catalyst_VERSION} ${Paraview_VERSION}")
else()
message(STATUS "The Damaris library does NOT have Catalyst support")
endif()
else()
message(STATUS "The Damaris library was requested but NOT found")
endif()
else() # User did not request Damaris support
unset(HAVE_DAMARIS)
endif()
mark_as_advanced(HAVE_DAMARIS)

View File

@@ -64,7 +64,14 @@ if (CXX_COMPAT_GCC)
# use these options for release builds - full optimization
add_options (ALL_LANGUAGES "${_prof_RELEASE}" ${_opt_rel} ${_opt_flags})
option(WITH_NDEBUG "Disable asserts in release mode" OFF)
if(NOT WITH_NDEBUG)
if(WITH_NDEBUG)
foreach(type ${_prof_RELEASE})
string(TOUPPER ${type} type)
string(REPLACE -UNDEBUG "" CMAKE_CXX_FLAGS_${type} "${CMAKE_CXX_FLAGS_${type}}")
string(REPLACE -UNDEBUG "" CMAKE_C_FLAGS_${type} "${CMAKE_C_FLAGS_${type}}")
string(REPLACE -UNDEBUG "" CMAKE_Fortran_FLAGS_${type} "${CMAKE_Fortran_FLAGS_${type}}")
endforeach()
else()
add_options (ALL_LANGUAGES "${_prof_RELEASE}" -UNDEBUG)
endif()

View File

@@ -58,6 +58,7 @@ if(NOT @opm-project_NAME@_FOUND)
string(REPLACE ${@opm-project_NAME@_PREFIX} ${DEST_PREFIX} @opm-project_NAME@_INCLUDE_DIRS "${@opm-project_NAME@_INCLUDE_DIRS}")
string(REPLACE ${@opm-project_NAME@_PREFIX} ${DEST_PREFIX} @opm-project_NAME@_LIBRARY_DIRS "${@opm-project_NAME@_LIBRARY_DIRS}")
string(REPLACE ${@opm-project_NAME@_PREFIX} ${DEST_PREFIX} @opm-project_NAME@_LIBRARY "${@opm-project_NAME@_LIBRARY}")
string(REPLACE ${@opm-project_NAME@_PREFIX} ${DEST_PREFIX} @opm-project_NAME@_PYTHON_COMMON_DIR "${@opm-project_NAME@_PYTHON_COMMON_DIR}")
endif()
@@ -107,7 +108,18 @@ if(NOT @opm-project_NAME@_FOUND)
# The settings in this block do not mix well with the DEST_PREFIX
# setting.
if (NOT DEST_PREFIX)
# This is required to include OpmPackage
# if this file is not processed using the OPM CMake system but
# simply by a call to find_package(module) then the CMAKE_MODULE_PATH
# might not include the location of the OPM cmake module yet.
# Hence we search for opm-common using config mode to set it up.
# The check for opm-common_PREFIX is there to not do this in
# opm-common-config.cmake
if(NOT opm-common_PREFIX
AND NOT opm-common_FOUND)
# This needed to find the path to the CMake modules
find_package(opm-common CONFIG)
endif()
# This is required to include OpmPackage /opm-common-prereq.cmake
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" @PREREQ_LOCATION@)
# extra code from variable OPM_PROJECT_EXTRA_CODE

View File

@@ -1,4 +1,4 @@
/* Userspesific CSS for doxygen */
/* Userspecific CSS for doxygen */
body, table, div, p, dl {
font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif;
font-size: 16px;

11
docs/man1/arraylist.1 Normal file
View File

@@ -0,0 +1,11 @@
.TH SUMMARY "1" "October 2022" "arraylist 2022.10" "User Commands"
.SH NAME
summary \- Printer for list of arrays in Eclipse summary files
.SH DESCRIPTION
List all arrays found in an EclFile specified on the command line.
.PP
.SH OPTIONS
\fB\-h\fR Print help and exit.
.TP
\fB\-r\fR List array for a specific report time step number. Option only valid for a unified restart file.
.PP

29
docs/man1/co2brinepvt.1 Normal file
View File

@@ -0,0 +1,29 @@
.TH CO2BRINEPVT "1" "April 2022" "co2brinepvt" "User Commands"
.SH NAME
co2brinepvt \- compute and print pvt properties for co2 with brine
.SH DESCRIPTION
co2brinepvt computes PVT properties of a brine/co2 system
for a given phase (oil or brine), pressure, temperature, salinity and rs.
The properties support are: density, the inverse phase formation volume factor (invB), viscosity,
saturated dissolution factor (rsSat)
See CO2STORE in the OPM manual for more details.
.PP
.SH Synopsis
co2brinepvt <prop> <phase> <p> <T> <salinity> <rs>
.br
where
.br
prop = {density, invB, B, viscosity, rsSat, diffusionCoefficient}
.br
phase = {CO2, brine}
.br
p: pressure in pascal
.br
T: temperature in kelvin
.br
salinity(optional): salt molality in mol/kg
.nr
rs(optional): amount of dissolved CO2 in Brine in SM3/SM3
.PP
.SH OPTIONS
\fB\-\-h\fR/\-\-help Print help and exit.

View File

@@ -1,5 +1,4 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.8.
.TH COMPAREECL "1" "April 2021" "compareECL 2020.04" "User Commands"
.TH COMPAREECL "1" "October 2022" "compareECL 2022.10" "User Commands"
.SH NAME
compareECL \- Comparator for Eclipse files
.SH DESCRIPTION
@@ -11,55 +10,57 @@ The program takes four arguments:
3. Absolute tolerance
4. Relative tolerance (between 0 and 1)
.PP
.SH OPTIONS
.HP
In addition, the program takes these options (which must be given before the arguments):
.PP
\fB\-a\fR Run a full analysis of errors.
.TP
\fB\-h\fR Print help and exit.
.TP
\fB\-d\fR Use report steps only when comparing results from summary files.
.TP
\fB\-i\fR Execute integration test (regression test is default).
.IP
The integration test compares SGAS, SWAT and PRESSURE in unified restart files, and WOPR, WGPR, WWPR and WBHP (all wells) in summary file.
.PP
\fB\-k\fR Specify specific keyword to compare (capitalized), for examples \fB\-k\fR PRESSURE or \fB\-k\fR WOPR:A\-1H
\fB\-l\fR Only do comparison for the last Report Step. This option is only valid for restart files.
\fB\-n\fR Do not throw on errors.
\fB\-p\fR Print keywords in both cases and exit.
\fB\-r\fR compare a spesific report time step number in a restart file.
\fB\-t\fR Specify ECLIPSE filetype to compare, (default behaviour is that all files are compared if found). Different possible arguments are:
.TP
\fB\-l\fR Only do comparison for the last Report Step. This option is only valid for restart files.
.TP
\fB\-n\fR Do not throw on errors.
.TP
\fB\-p\fR Print keywords in both cases and exit.
.TP
\fB\-r\fR compare a specific report time step number in a restart file.
.TP
\fB\-t\fR Specify ECLIPSE filetype to compare, (default behaviour is that all files are compared if found). Different possible arguments are:
.IP
\fB\-t\fR UNRST
Compare two unified restart files (.UNRST). This the default value, so it is the same as not passing option \fB\-t\fR.
.TP
.IP
\fB\-t\fR EGRID
Compare two EGrid files (.EGRID).
.TP
.IP
\fB\-t\fR INIT
Compare two initial files (.INIT).
.TP
.IP
\fB\-t\fR RFT
Compare two RFT files (.RFT).
.TP
.IP
\fB\-t\fR SMRY
Compare two cases consistent of (unified) summary files.
.IP
\fB\-t\fR RSM
Compare RSM file against a summary file.
.PP
\fB\-x\fR Allow extra keywords in case number 2. These additional keywords (not found in case number1) will be ignored in the comparison.
.PP
Example usage of the program:
.SH Example usage of the program:
.PP
compareECL \fB\-k\fR PRESSURE <path to first casefile> <path to second casefile> 1e\-3 1e\-5
compareECL \fB\-t\fR INIT \fB\-k\fR PORO <path to first casefile> <path to second casefile> 1e\-3 1e\-5
compareECL \fB\-i\fR <path to first casefile> <path to second casefile> 0.01 1e\-6
.PP
Exceptions are thrown (and hence program exits) when deviations are larger than the specified tolerances, or when the number of cells does not match \fB\-\-\fR either in the grid file or for a specific keyword. Information about the keyword, keyword occurrence (zero based) and cell coordinate is printed when an exception is thrown. For more information about how the cases are compared, see the documentation of the EclFilesComparator class.
.SH "SEE ALSO"
The full documentation for
.B compareECL
is maintained as a Texinfo manual. If the
.B info
and
.B compareECL
programs are properly installed at your site, the command
.IP
.B info compareECL
.PP
should give you access to the complete manual.

View File

@@ -1,5 +1,4 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.8.
.TH CONVERTECL "1" "April 2021" "convertECL 2020.04" "User Commands"
.TH CONVERTECL "1" "October 2022" "convertECL 2022.10" "User Commands"
.SH NAME
convertECL \- Converter for Eclipse files (binary <-> formatted format)
.SH DESCRIPTION
@@ -7,18 +6,13 @@ convertECL needs one argument which is the input file to be converted. If this i
.PP
In addition, the program takes these options (which must be given before the arguments):
.PP
.SH OPTIONS
.HP
\fB\-h\fR Print help and exit.
.TP
\fB\-l\fR list report step numbers in the selected restart file.
\fB\-r\fR extract and convert a spesific report time step number from a unified restart file.
.SH "SEE ALSO"
The full documentation for
.B convertECL
is maintained as a Texinfo manual. If the
.B info
and
.B convertECL
programs are properly installed at your site, the command
.IP
.B info convertECL
.TP
\fB\-i\fR Enforce IX standard on output file.
.TP
\fB\-r\fR extract and convert a specific report time step number from a unified restart file.
.PP
should give you access to the complete manual.

View File

@@ -1,5 +1,4 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.8.
.TH OPMHASH "1" "April 2021" "opmhash 2020.04" "User Commands"
.TH OPMHASH "1" "October 2022" "opmhash 2022.10" "User Commands"
.SH NAME
opmhash \- Hasher for summary keywords in Eclipse files
.SH DESCRIPTION
@@ -40,15 +39,11 @@ depends on the keyword order.
\fB\-l\fR : Add filename and linenumber information to each keyword.
.HP
\fB\-s\fR : Short form \- only print the hash of the complete deck.
.SH "SEE ALSO"
The full documentation for
.B opmhash
is maintained as a Texinfo manual. If the
.B info
and
.B opmhash
programs are properly installed at your site, the command
.IP
.B info opmhash
.HP
\fB\-S\fR : Silent form \- will not print any deck output.
.PP
should give you access to the complete manual.
It is possible to add multiple deck arguments, they are then scanned repeatedly,
and the decks are compared. In the case of multiple deck arguments the exit
status of the program will be zero if all are equal and nonzero in case of
differences.

View File

@@ -1,10 +1,7 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.8.
.TH OPMPACK "1" "April 2021" "opmpack 2020.04" "User Commands"
.TH OPMPACK "1" "October 2022" "opmpack 2022.10" "User Commands"
.SH NAME
opmpack \- Validator and printer of deck in Eclipse files without comments
.SH DESCRIPTION
opmpack: invalid option \fB\-\-\fR 'h'
.PP
The opmpack program will load a deck, resolve all include
files and then print it out again on stdout. All comments
will be stripped and the value types will be validated.
@@ -28,15 +25,4 @@ opmpack \fB\-o\fR NEW_CASE.DATA path/to/MY_CASE.DATA
As an alternative to the \fB\-o\fR option you can use \fB\-c\fR; that is equivalent to \fB\-o\fR \-
but restart and import files referred to in the deck are also copied. The \fB\-o\fR and
\fB\-c\fR options are mutually exclusive.
.SH "SEE ALSO"
The full documentation for
.B opmpack
is maintained as a Texinfo manual. If the
.B info
and
.B opmpack
programs are properly installed at your site, the command
.IP
.B info opmpack
.PP
should give you access to the complete manual.

View File

@@ -1,7 +1,88 @@
.TH RST_DECK
.TH RST_DECK: "1" "October 2022" "rst_deck 2022.10" "User Commands"
.SH NAME
rst_deck \- Create a version of deck ready for restart
rst_deck \- Convert simulation deck to a deck ready for restart
.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
output the program will update the SOLUTION and SCHEDULE sections. All keywords
from the SOLUTION section will be cleared out(1) and a RESTART keyword will be
inserted. In the SCHEDULE section the program can either remove all keywords up
until the restart date, or alternatively insert SKIPREST immediately following
the SCHEDULE keyword.
.PP
When creating the updated restart deck the program can either link to unmodified
include files with INCLUDE statements, create a copy of deck structure in an
alternative location or create one large file with all keywords in the same
file. Apart from the alterations to support restart the output deck will be
equivalent to the input deck, but formatting is not retained and comments have
been stripped away.
.PP
Arguments:
.PP
1. The data file we are starting with.
.PP
2. The restart source; this can either be a basename with an optional path
.IP
prefix and a :N to restart from step N; alternatively you can point to an
existing restart file. If you point to an existing restart file the input
will be validated in several ways:
.IP
a) Unified/multiple files will be checked against the UNIFIN setting of
.IP
the deck.
.IP
b) Formatted/unformatted will be checked against the FMTIn setting of the
.IP
deck.
.IP
c) If a single file like \fI\,/path/to/case/HISTORY.X0067\/\fP is given as argument the
.IP
:N notation to denote report step should not be used.
.IP
If the restart argument is given as the path to an existing file the content
of the RESTART keyword will be updated to contain the correct path from the
location of the restart deck to the location of the restart file. This path
awareness will be fooled if the restart deck is redirected from stdout to a
path different from cwd. If the restart argument is given as an absolute
filename the RESTART keyword will have an absolute path, if the restart
argument is a relative path the RESTART keyword will get a relative path \-
although an absolute path will be used if the restart file and the output
deck have different roots. If the restart argument is given as a string not
pointing to an existing file it will be inserted verbatim in the restart
deck.
.IP
A restart step value of 0 is interpreted as a dry run \- a deck which has not
been set up for restart will be written out.
.PP
3. Basename of the restart deck we create, can optionally contain a path prefix;
.IP
the path will be created if it does not already exist. This argument is
optional, if it is not provided the program will dump a restart deck on
stdout. If the argument corresponds to an existing directory the restart case
will get the same name as the base case.
.SH OPTIONS
\fB\-s\fR: Manipulate the SCHEDULE section by inserting a SKIPREST keyword immediately
.IP
following the SCHEDULE keyword. If the \fB\-s\fR option is not used the SCHEDULE
section will be modified by removing all keywords until we reach the restart
date.
.PP
\fB\-m\fR: [share|inline|copy] The restart deck can reuse the unmodified include files
.IP
from the base case, this is mode 'share' and is the default. With mode
\&'inline' the restart deck will be one long file and with mode 'copy' the
file structure of the base case will be retained. The default if no \fB\-m\fR
option is given is the 'share' mode.
.IP
In the case of 'share' and 'copy' the correct path to include files will be
negotiated based on the path given to the output case in the third argument.
If the restart deck is passed to stdout the include files will be resolved
based on output in cwd.
.PP
Example:
.IP
rst_deck \fI\,/path/to/history/HISTORY.DATA\/\fP rst/HISTORY:30 \fI\,/path/to/rst/RESTART\/\fP \fB\-s\fR
.PP
1: The program has a compiled list of keywords which will be retained in the
.IP
SOLUTION section. The current value of that list is: RPTRST

View File

@@ -1,5 +1,4 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.8.
.TH SUMMARY "1" "April 2021" "summary 2020.04" "User Commands"
.TH SUMMARY "1" "October 2022" "summary 2022.10" "User Commands"
.SH NAME
summary \- Printer for summary keys in Eclipse summary files
.SH DESCRIPTION
@@ -7,18 +6,10 @@ summary needs a minimum of two arguments. First is smspec filename and then list
.PP
In addition, the program takes these options (which must be given before the arguments):
.PP
.SH OPTIONS
\fB\-h\fR Print help and exit.
.TP
\fB\-l\fR list all summary vectors.
.TP
\fB\-r\fR extract data only for report steps.
.SH "SEE ALSO"
The full documentation for
.B summary
is maintained as a Texinfo manual. If the
.B info
and
.B summary
programs are properly installed at your site, the command
.IP
.B info summary
.PP
should give you access to the complete manual.

View File

@@ -5,9 +5,9 @@
Module: opm-common
Description: Open Porous Media Initiative shared infrastructure
Version: 2022.04-pre
Label: 2022.04-pre
Version: 2023.04
Label: 2023.04
Maintainer: opm@opm-project.org
MaintainerName: OPM community
Url: http://opm-project.org
Depends: dune-common
Depends: dune-common (>= 2.7)

194
examples/co2brinepvt.cpp Normal file
View File

@@ -0,0 +1,194 @@
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
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 2 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/>.
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
/*!
* \file
*
* \brief This is the unit test for the co2 brine PVT model
*
*/
#include "config.h"
#include <opm/material/fluidsystems/blackoilpvt/Co2GasPvt.hpp>
#include <opm/material/fluidsystems/blackoilpvt/BrineCo2Pvt.hpp>
#include <iostream>
template <class Co2Pvt>
double densityGas(const Co2Pvt& co2Pvt, const double p, const double T, const double Rv)
{
return co2Pvt.inverseFormationVolumeFactor(/*regionIdx=*/0,
T,
p,
Rv,
/*Rvw=*/0.0) * co2Pvt.gasReferenceDensity(0);
}
template <class BrinePvt>
double densityBrine(const BrinePvt& brinePvt, const double p, const double T, const double Rs)
{
double bo = brinePvt.inverseFormationVolumeFactor(/*regionIdx=*/0,
T,
p,
Rs);
return bo * (brinePvt.oilReferenceDensity(0) + Rs * brinePvt.gasReferenceDensity(0));
}
int main(int argc, char **argv)
{
bool help = false;
for (int i = 1; i < argc; ++i) {
std::string tmp = argv[i];
help = help || (tmp == "--h") || (tmp == "--help");
}
if (argc < 5 || help) {
std::cout << "USAGE:" << std::endl;
std::cout << "co2brinepvt <prop> <phase> <p> <T> <salinity> <rs> "<< std::endl;
std::cout << "prop = {density, invB, B, viscosity, rsSat, internalEnergy, enthalpy, diffusionCoefficient}" << std::endl;
std::cout << "phase = {CO2, brine}" << std::endl;
std::cout << "p: pressure in pascal" << std::endl;
std::cout << "T: temperature in kelvin" << std::endl;
std::cout << "salinity(optional): salt molality in mol/kg" << std::endl;
std::cout << "rs(optional): amount of dissolved CO2 in Brine in SM3/SM3" << std::endl;
std::cout << "OPTIONS:" << std::endl;
std::cout << "--h/--help Print help and exit." << std::endl;
std::cout << "DESCRIPTION:" << std::endl;
std::cout << "co2brinepvt computes PVT properties of a brine/co2 system " << std::endl;
std::cout << "for a given phase (oil or brine), pressure, temperature, salinity and rs." << std::endl;
std::cout << "The properties support are: density, the inverse phase formation volume factor (invB), viscosity, " << std::endl;
std::cout << "saturated dissolution factor (rsSat) " << std::endl;
std::cout << "See CO2STORE in the OPM manual for more details." << std::endl;
return EXIT_FAILURE;
}
std::string prop = argv[1];
std::string phase = argv[2];
double p = atof(argv[3]);
double T = atof(argv[4]);
double molality = 0.0;
double rs = 0.0;
double rv = 0.0; // only support 0.0 for now
if (argc > 5)
molality = atof(argv[5]);
if (argc > 6)
rs = atof(argv[6]);
const double MmNaCl = 58e-3; // molar mass of NaCl [kg/mol]
// convert to mass fraction
std::vector<double> salinity = {0.0};
if (molality > 0.0)
salinity[0] = 1 / ( 1 + 1 / (molality*MmNaCl));
Opm::BrineCo2Pvt<double> brineCo2Pvt(salinity);
Opm::Co2GasPvt<double> co2Pvt(salinity);
double value;
if (prop == "density") {
if (phase == "CO2") {
value = densityGas(co2Pvt, p, T, rv);
} else if (phase == "brine") {
value = densityBrine(brineCo2Pvt, p, T, rs);
} else {
throw std::runtime_error("phase " + phase + " not recognized. Use either CO2 or brine");
}
} else if (prop == "invB" || prop == "B") {
if (phase == "CO2") {
value = co2Pvt.inverseFormationVolumeFactor(/*regionIdx=*/0,
T,
p,
rv,
/*Rvw=*/0.0);
} else if (phase == "brine") {
value = brineCo2Pvt.inverseFormationVolumeFactor(/*regionIdx=*/0,
T,
p,
rs);
} else {
throw std::runtime_error("phase " + phase + " not recognized. Use either CO2 or brine");
}
if (prop == "B")
value = 1 / value;
} else if (prop == "viscosity") {
if (phase == "CO2") {
value = co2Pvt.viscosity(/*regionIdx=*/0,
T,
p,
rv,
/*Rvw=*/0.0);
} else if (phase == "brine") {
value = brineCo2Pvt.viscosity(/*regionIdx=*/0,
T,
p,
rs);
} else {
throw std::runtime_error("phase " + phase + " not recognized. Use either CO2 or brine");
}
} else if (prop == "rsSat") {
if (phase == "CO2") {
value = co2Pvt.saturatedWaterVaporizationFactor(/*regionIdx=*/0,
T,
p);
} else if (phase == "brine") {
value = brineCo2Pvt.saturatedGasDissolutionFactor(/*regionIdx=*/0,
T,
p);
} else {
throw std::runtime_error("phase " + phase + " not recognized. Use either CO2 or brine");
}
} else if (prop == "diffusionCoefficient") {
size_t comp_idx = 0; // not used
if (phase == "CO2") {
value = co2Pvt.diffusionCoefficient(T,p, comp_idx);
} else if (phase == "brine") {
value = brineCo2Pvt.diffusionCoefficient(T,p, comp_idx);
} else {
throw std::runtime_error("phase " + phase + " not recognized. Use either CO2 or brine");
}
} else if (prop == "internalEnergy") {
if (phase == "CO2") {
value = co2Pvt.internalEnergy(/*regionIdx=*/0 ,T,p, rv, 0.0);
} else if (phase == "brine") {
value = brineCo2Pvt.internalEnergy(/*regionIdx=*/0 ,T,p, rs);
} else {
throw std::runtime_error("phase " + phase + " not recognized. Use either CO2 or brine");
}
} else if (prop == "enthalpy") {
if (phase == "CO2") {
value = p / densityGas(co2Pvt, p, T, rv) + co2Pvt.internalEnergy(/*regionIdx=*/0 ,T,p, rv, 0.0);
} else if (phase == "brine") {
value = p / densityBrine(brineCo2Pvt, p, T, rs) + brineCo2Pvt.internalEnergy(/*regionIdx=*/0 ,T,p, rs);
} else {
throw std::runtime_error("phase " + phase + " not recognized. Use either CO2 or brine");
}
} else {
throw std::runtime_error("prop " + prop + " not recognized. "
+ "Use either density, visosity, invB, B, internalEnergy, enthalpy or diffusionCoefficient");
}
std::cout << value << std::endl;
return 0;
}

View File

@@ -91,9 +91,12 @@ int main(int argc, char **argv) {
auto lap0 = std::chrono::system_clock::now();
int num_esmry = argc-argOffset;
std::vector<bool> status(num_esmry, false);
#pragma omp parallel for
for (int f = argOffset; f < argc; f ++){
std::filesystem::path inputFileName = argv[f];
for (int f = 0; f < num_esmry; f ++){
std::filesystem::path inputFileName = argv[f + argOffset];
std::filesystem::path esmryFileName = inputFileName.parent_path() / inputFileName.stem();
esmryFileName = esmryFileName += ".ESMRY";
@@ -101,15 +104,23 @@ int main(int argc, char **argv) {
if (Opm::EclIO::fileExists(esmryFileName) && (force))
remove (esmryFileName);
Opm::EclIO::ESmry smryFile(argv[f]);
if (!smryFile.make_esmry_file()){
std::cout << "\n! Warning, smspec already have one lod file, existing kept use option -f to replace this" << std::endl;
try {
Opm::EclIO::ESmry smry{ argv[f + argOffset] };
status[f] = smry.make_esmry_file();
if (! status[f]) {
std::cerr << "\n! Warning, smspec already have one esmry file, existing kept use option -f to replace this\n";
}
} catch (...) {
std::cerr << "\n! Warning, could not open summary file " << argv[f + argOffset] << '\n';
}
}
const auto n_converted = std::count(status.begin(), status.end(), true);
auto lap1 = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds1 = lap1-lap0;
std::cout << "\nruntime for creating " << (argc-argOffset) << " ESMRY files: " << elapsed_seconds1.count() << " seconds\n" << std::endl;
std::cout << "\nruntime for creating " << n_converted << " ESMRY files: " << elapsed_seconds1.count() << " seconds\n" << std::endl;
return 0;
}

View File

@@ -19,6 +19,8 @@
#include <opm/output/eclipse/EclipseIO.hpp>
#include <opm/input/eclipse/Deck/Deck.hpp>
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>

View File

@@ -27,11 +27,8 @@
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
#include <opm/input/eclipse/Deck/Deck.hpp>
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
#include <opm/input/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
#include <opm/input/eclipse/Schedule/Schedule.hpp>
struct keyword {
@@ -58,10 +55,10 @@ std::vector<keyword> load_deck(const std::string& deck_file) {
std::vector<keyword> keywords;
/* Use the same default ParseContext as flow. */
parseContext.update(Opm::ParseContext::PARSE_RANDOM_SLASH, Opm::InputError::IGNORE);
parseContext.update(Opm::ParseContext::PARSE_MISSING_DIMS_KEYWORD, Opm::InputError::WARN);
parseContext.update(Opm::ParseContext::SUMMARY_UNKNOWN_WELL, Opm::InputError::WARN);
parseContext.update(Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputError::WARN);
parseContext.update(Opm::ParseContext::PARSE_RANDOM_SLASH, Opm::InputErrorAction::IGNORE);
parseContext.update(Opm::ParseContext::PARSE_MISSING_DIMS_KEYWORD, Opm::InputErrorAction::WARN);
parseContext.update(Opm::ParseContext::SUMMARY_UNKNOWN_WELL, Opm::InputErrorAction::WARN);
parseContext.update(Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputErrorAction::WARN);
auto deck = parser.parseFile(deck_file, parseContext, errors);
for (const auto& kw : deck) {

View File

@@ -22,6 +22,9 @@
#include <iostream>
#include <getopt.h>
#include <opm/input/eclipse/Deck/Deck.hpp>
#include <opm/input/eclipse/EclipseState/InitConfig/InitConfig.hpp>
#include <opm/input/eclipse/EclipseState/IOConfig/IOConfig.hpp>
#include <opm/input/eclipse/Parser/ParserKeywords/I.hpp>
#include <opm/input/eclipse/Parser/ParserKeywords/P.hpp>
#include <opm/input/eclipse/Parser/ParserKeywords/G.hpp>
@@ -29,12 +32,11 @@
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
#include <opm/input/eclipse/Deck/Deck.hpp>
namespace fs = std::filesystem;
Opm::Deck pack_deck( const char * deck_file, std::ostream& os) {
Opm::ParseContext parseContext(Opm::InputError::WARN);
Opm::ParseContext parseContext(Opm::InputErrorAction::WARN);
Opm::ErrorGuard errors;
Opm::Parser parser;

View File

@@ -163,15 +163,15 @@ struct Options {
Opm::Deck load_deck(const Options& opt) {
Opm::ParseContext parseContext(Opm::InputError::WARN);
Opm::ParseContext parseContext(Opm::InputErrorAction::WARN);
Opm::ErrorGuard errors;
Opm::Parser parser;
/* Use the same default ParseContext as flow. */
parseContext.update(Opm::ParseContext::PARSE_RANDOM_SLASH, Opm::InputError::IGNORE);
parseContext.update(Opm::ParseContext::PARSE_MISSING_DIMS_KEYWORD, Opm::InputError::WARN);
parseContext.update(Opm::ParseContext::SUMMARY_UNKNOWN_WELL, Opm::InputError::WARN);
parseContext.update(Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputError::WARN);
parseContext.update(Opm::ParseContext::PARSE_RANDOM_SLASH, Opm::InputErrorAction::IGNORE);
parseContext.update(Opm::ParseContext::PARSE_MISSING_DIMS_KEYWORD, Opm::InputErrorAction::WARN);
parseContext.update(Opm::ParseContext::SUMMARY_UNKNOWN_WELL, Opm::InputErrorAction::WARN);
parseContext.update(Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputErrorAction::WARN);
return parser.parseFile(opt.input_deck, parseContext, errors);
}

View File

@@ -20,18 +20,24 @@
#include <filesystem>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <chrono>
#include <sstream>
#include <opm/input/eclipse/Deck/Deck.hpp>
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <opm/input/eclipse/Parser/ParseContext.hpp>
#include <opm/input/eclipse/Parser/ErrorGuard.hpp>
#include <opm/input/eclipse/Deck/Deck.hpp>
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
#include <opm/input/eclipse/Schedule/Schedule.hpp>
#include <opm/input/eclipse/Python/Python.hpp>
#include <opm/input/eclipse/Schedule/Schedule.hpp>
#include <opm/input/eclipse/Schedule/Well/Well.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/common/OpmLog/StreamLog.hpp>
#include <opm/common/OpmLog/LogUtil.hpp>
@@ -91,10 +97,10 @@ inline void createDot(const Opm::Schedule& schedule, const std::string& casename
inline Opm::Schedule loadSchedule(const std::string& deck_file)
{
Opm::ParseContext parseContext({{Opm::ParseContext::PARSE_RANDOM_SLASH, Opm::InputError::IGNORE},
{Opm::ParseContext::PARSE_MISSING_DIMS_KEYWORD, Opm::InputError::WARN},
{Opm::ParseContext::SUMMARY_UNKNOWN_WELL, Opm::InputError::WARN},
{Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputError::WARN}});
Opm::ParseContext parseContext({{Opm::ParseContext::PARSE_RANDOM_SLASH, Opm::InputErrorAction::IGNORE},
{Opm::ParseContext::PARSE_MISSING_DIMS_KEYWORD, Opm::InputErrorAction::WARN},
{Opm::ParseContext::SUMMARY_UNKNOWN_WELL, Opm::InputErrorAction::WARN},
{Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputErrorAction::WARN}});
Opm::ErrorGuard errors;
Opm::Parser parser;
auto python = std::make_shared<Opm::Python>();

View File

@@ -0,0 +1,401 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
//##################################################################################################
#include "../CommonCode/cvfStructGrid.h"
#include "../LibCore/cvfBase.h"
// namespace caf
// {
// template <>
// void cvf::StructGridInterface::FaceEnum::setUp()
// {
// addItem( cvf::StructGridInterface::POS_I, "POS I", "" );
// addItem( cvf::StructGridInterface::NEG_I, "NEG I", "" );
// addItem( cvf::StructGridInterface::POS_J, "POS J", "" );
// addItem( cvf::StructGridInterface::NEG_J, "NEG J", "" );
// addItem( cvf::StructGridInterface::POS_K, "POS K", "" );
// addItem( cvf::StructGridInterface::NEG_K, "NEG K", "" );
// addItem( cvf::StructGridInterface::NO_FACE, "UnDef", "" );
// }
// } // namespace caf
namespace external
{
namespace cvf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
StructGridInterface::StructGridInterface()
{
m_characteristicCellSizeI = cvf::UNDEFINED_DOUBLE;
m_characteristicCellSizeJ = cvf::UNDEFINED_DOUBLE;
m_characteristicCellSizeK = cvf::UNDEFINED_DOUBLE;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t StructGridInterface::cellCountI() const
{
if ( gridPointCountI() == 0 ) return 0;
return gridPointCountI() - 1;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t StructGridInterface::cellCountJ() const
{
if ( gridPointCountJ() == 0 ) return 0;
return gridPointCountJ() - 1;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t StructGridInterface::cellCountK() const
{
if ( gridPointCountK() == 0 ) return 0;
return gridPointCountK() - 1;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void StructGridInterface::cellFaceVertexIndices( FaceType face, cvf::ubyte vertexIndices[4] )
{
//
// 7---------6
// /| /| |k
// / | / | | /j
// 4---------5 | |/
// | 3------|--2 *---i
// | / | /
// |/ |/
// 0---------1
if ( face == NEG_K )
{
vertexIndices[0] = 0;
vertexIndices[1] = 3;
vertexIndices[2] = 2;
vertexIndices[3] = 1;
}
else if ( face == POS_K )
{
vertexIndices[0] = 4;
vertexIndices[1] = 5;
vertexIndices[2] = 6;
vertexIndices[3] = 7;
}
else if ( face == NEG_J )
{
vertexIndices[0] = 0;
vertexIndices[1] = 1;
vertexIndices[2] = 5;
vertexIndices[3] = 4;
}
else if ( face == POS_I )
{
vertexIndices[0] = 1;
vertexIndices[1] = 2;
vertexIndices[2] = 6;
vertexIndices[3] = 5;
}
else if ( face == POS_J )
{
vertexIndices[0] = 3;
vertexIndices[1] = 7;
vertexIndices[2] = 6;
vertexIndices[3] = 2;
}
else if ( face == NEG_I )
{
vertexIndices[0] = 0;
vertexIndices[1] = 4;
vertexIndices[2] = 7;
vertexIndices[3] = 3;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<ubyte, ubyte> StructGridInterface::edgeVertexIndices( FaceType face1, FaceType face2 )
{
// Return the two shared vertex indices between two faces
// The ordering is identical to the ordering in StructGridInterface::cellFaceVertexIndices
// Ensure face1 has the largest enum value
if ( face2 > face1 ) std::swap( face1, face2 );
if ( face1 == NEG_K )
{
if ( face2 == NEG_I ) return { 0, 3 };
if ( face2 == POS_I ) return { 2, 1 };
if ( face2 == NEG_J ) return { 1, 0 };
if ( face2 == POS_J ) return { 3, 2 };
}
if ( face1 == POS_K )
{
if ( face2 == NEG_I ) return { 7, 4 };
if ( face2 == POS_I ) return { 5, 6 };
if ( face2 == NEG_J ) return { 4, 5 };
if ( face2 == POS_J ) return { 6, 7 };
}
if ( face1 == NEG_J )
{
if ( face2 == NEG_I ) return { 4, 0 };
if ( face2 == POS_I ) return { 1, 5 };
}
if ( face1 == POS_J )
{
if ( face2 == NEG_I ) return { 3, 7 };
if ( face2 == POS_I ) return { 6, 2 };
}
return {};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
StructGridInterface::FaceType StructGridInterface::oppositeFace( FaceType face )
{
FaceType opposite;
switch ( face )
{
case NEG_I:
opposite = POS_I;
break;
case POS_I:
opposite = NEG_I;
break;
case NEG_J:
opposite = POS_J;
break;
case POS_J:
opposite = NEG_J;
break;
case NEG_K:
opposite = POS_K;
break;
case POS_K:
opposite = NEG_K;
break;
default:
opposite = POS_I;
CVF_ASSERT( false );
}
return opposite;
}
//--------------------------------------------------------------------------------------------------
/// Return values are set to cvf::UNDEFINED_SIZE_T if the neighbor is in the negative area
//--------------------------------------------------------------------------------------------------
void StructGridInterface::neighborIJKAtCellFace( size_t i, size_t j, size_t k, FaceType face, size_t* ni, size_t* nj, size_t* nk )
{
*ni = i;
*nj = j;
*nk = k;
switch ( face )
{
case POS_I:
( *ni )++;
break;
case NEG_I:
if ( i > 0 )
( *ni )--;
else
( *ni ) = cvf::UNDEFINED_SIZE_T;
break;
case POS_J:
( *nj )++;
break;
case NEG_J:
if ( j > 0 )
( *nj )--;
else
( *nj ) = cvf::UNDEFINED_SIZE_T;
break;
case POS_K:
( *nk )++;
break;
case NEG_K:
if ( k > 0 )
( *nk )--;
else
( *nk ) = cvf::UNDEFINED_SIZE_T;
break;
default:
break;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
StructGridInterface::GridAxisType StructGridInterface::gridAxisFromFace( FaceType face )
{
GridAxisType axis = GridAxisType::NO_AXIS;
if ( face == cvf::StructGridInterface::POS_I || face == cvf::StructGridInterface::NEG_I )
{
axis = GridAxisType::AXIS_I;
}
else if ( face == cvf::StructGridInterface::POS_J || face == cvf::StructGridInterface::NEG_J )
{
axis = GridAxisType::AXIS_J;
}
else if ( face == cvf::StructGridInterface::POS_K || face == cvf::StructGridInterface::NEG_K )
{
axis = GridAxisType::AXIS_K;
}
return axis;
}
//--------------------------------------------------------------------------------------------------
/// Models with large absolute values for coordinate scalars will often end up with z-fighting due
/// to numerical limits in float used by OpenGL. displayModelOffset() is intended
// to be subtracted from a domain model coordinate when building geometry
//
// Used in StructGridGeometryGenerator::computeArrays()
//
// Vec3d domainModelCoord = ...
// Vec3d vizCoord = domainModelCoord - displayModelOffset();
//--------------------------------------------------------------------------------------------------
cvf::Vec3d StructGridInterface::displayModelOffset() const
{
return cvf::Vec3d::ZERO;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void StructGridInterface::characteristicCellSizes( double* iSize, double* jSize, double* kSize ) const
{
CVF_ASSERT( iSize && jSize && kSize );
if ( m_characteristicCellSizeI == cvf::UNDEFINED_DOUBLE || m_characteristicCellSizeJ == cvf::UNDEFINED_DOUBLE ||
m_characteristicCellSizeK == cvf::UNDEFINED_DOUBLE )
{
ubyte faceConnPosI[4];
cellFaceVertexIndices( StructGridInterface::POS_I, faceConnPosI );
ubyte faceConnNegI[4];
cellFaceVertexIndices( StructGridInterface::NEG_I, faceConnNegI );
ubyte faceConnPosJ[4];
cellFaceVertexIndices( StructGridInterface::POS_J, faceConnPosJ );
ubyte faceConnNegJ[4];
cellFaceVertexIndices( StructGridInterface::NEG_J, faceConnNegJ );
ubyte faceConnPosK[4];
cellFaceVertexIndices( StructGridInterface::POS_K, faceConnPosK );
ubyte faceConnNegK[4];
cellFaceVertexIndices( StructGridInterface::NEG_K, faceConnNegK );
double iLengthAccumulated = 0.0;
double jLengthAccumulated = 0.0;
double kLengthAccumulated = 0.0;
cvf::Vec3d cornerVerts[8];
size_t cellCount = 0;
size_t k;
for ( k = 0; k < cellCountK(); k++ )
{
size_t j;
for ( j = 0; j < cellCountJ(); j++ )
{
size_t i;
for ( i = 0; i < cellCountI(); i += 10 ) // NB! Evaluate every n-th cell
{
if ( isCellValid( i, j, k ) )
{
size_t cellIndex = cellIndexFromIJK( i, j, k );
cellCornerVertices( cellIndex, cornerVerts );
iLengthAccumulated +=
( cornerVerts[faceConnPosI[0]] - cornerVerts[faceConnNegI[0]] ).lengthSquared();
iLengthAccumulated +=
( cornerVerts[faceConnPosI[1]] - cornerVerts[faceConnNegI[3]] ).lengthSquared();
iLengthAccumulated +=
( cornerVerts[faceConnPosI[2]] - cornerVerts[faceConnNegI[2]] ).lengthSquared();
iLengthAccumulated +=
( cornerVerts[faceConnPosI[3]] - cornerVerts[faceConnNegI[1]] ).lengthSquared();
jLengthAccumulated +=
( cornerVerts[faceConnPosJ[0]] - cornerVerts[faceConnNegJ[0]] ).lengthSquared();
jLengthAccumulated +=
( cornerVerts[faceConnPosJ[1]] - cornerVerts[faceConnNegJ[3]] ).lengthSquared();
jLengthAccumulated +=
( cornerVerts[faceConnPosJ[2]] - cornerVerts[faceConnNegJ[2]] ).lengthSquared();
jLengthAccumulated +=
( cornerVerts[faceConnPosJ[3]] - cornerVerts[faceConnNegJ[1]] ).lengthSquared();
kLengthAccumulated +=
( cornerVerts[faceConnPosK[0]] - cornerVerts[faceConnNegK[0]] ).lengthSquared();
kLengthAccumulated +=
( cornerVerts[faceConnPosK[1]] - cornerVerts[faceConnNegK[3]] ).lengthSquared();
kLengthAccumulated +=
( cornerVerts[faceConnPosK[2]] - cornerVerts[faceConnNegK[2]] ).lengthSquared();
kLengthAccumulated +=
( cornerVerts[faceConnPosK[3]] - cornerVerts[faceConnNegK[1]] ).lengthSquared();
cellCount++;
}
}
}
}
double divisor = cellCount * 4.0;
if ( divisor > 0.0 )
{
m_characteristicCellSizeI = cvf::Math::sqrt( iLengthAccumulated / divisor );
m_characteristicCellSizeJ = cvf::Math::sqrt( jLengthAccumulated / divisor );
m_characteristicCellSizeK = cvf::Math::sqrt( kLengthAccumulated / divisor );
}
}
*iSize = m_characteristicCellSizeI;
*jSize = m_characteristicCellSizeJ;
*kSize = m_characteristicCellSizeK;
}
} // namespace cvf
} //namespace external

View File

@@ -0,0 +1,135 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "../LibCore/cvfObject.h"
#include "../LibCore/cvfVector3.h"
#include <cstddef>
// #include "../cafPdmCore/cafAppEnum.h"
namespace external
{
namespace cvf
{
class CellFilterBase;
// Navneforslag
// StructGridGeometryGeneratorInterface
// Main purpose of this class is to define the interface to be used by geometry generators
class StructGridInterface : public Object
{
public:
enum FaceType
{
POS_I,
NEG_I,
POS_J,
NEG_J,
POS_K,
NEG_K,
NO_FACE
};
// typedef caf::AppEnum<StructGridInterface::FaceType> FaceEnum;
enum class GridAxisType
{
AXIS_I,
AXIS_J,
AXIS_K,
NO_AXIS
};
public:
StructGridInterface();
virtual size_t gridPointCountI() const = 0;
virtual size_t gridPointCountJ() const = 0;
virtual size_t gridPointCountK() const = 0;
size_t cellCountI() const;
size_t cellCountJ() const;
size_t cellCountK() const;
virtual bool isCellValid( size_t i, size_t j, size_t k ) const = 0;
virtual cvf::Vec3d minCoordinate() const = 0;
virtual cvf::Vec3d maxCoordinate() const = 0;
void characteristicCellSizes( double* iSize, double* jSize, double* kSize ) const;
virtual cvf::Vec3d displayModelOffset() const;
virtual bool cellIJKNeighbor( size_t i, size_t j, size_t k, FaceType face, size_t* neighborCellIndex ) const = 0;
virtual size_t cellIndexFromIJK( size_t i, size_t j, size_t k ) const = 0;
virtual bool ijkFromCellIndex( size_t cellIndex, size_t* i, size_t* j, size_t* k ) const = 0;
virtual bool cellIJKFromCoordinate( const cvf::Vec3d& coord, size_t* i, size_t* j, size_t* k ) const = 0;
virtual void cellCornerVertices( size_t cellIndex, cvf::Vec3d vertices[8] ) const = 0;
virtual cvf::Vec3d cellCentroid( size_t cellIndex ) const = 0;
virtual void cellMinMaxCordinates( size_t cellIndex, cvf::Vec3d* minCoordinate, cvf::Vec3d* maxCoordinate ) const = 0;
virtual size_t gridPointIndexFromIJK( size_t i, size_t j, size_t k ) const = 0;
virtual cvf::Vec3d gridPointCoordinate( size_t i, size_t j, size_t k ) const = 0;
public:
static void cellFaceVertexIndices( FaceType face, cvf::ubyte vertexIndices[4] );
static FaceType oppositeFace( FaceType face );
static void neighborIJKAtCellFace( size_t i,
size_t j,
size_t k,
StructGridInterface::FaceType face,
size_t* ni,
size_t* nj,
size_t* nk );
static GridAxisType gridAxisFromFace( FaceType face );
static std::pair<ubyte, ubyte> edgeVertexIndices( cvf::StructGridInterface::FaceType face1,
cvf::StructGridInterface::FaceType face2 );
private:
mutable double m_characteristicCellSizeI;
mutable double m_characteristicCellSizeJ;
mutable double m_characteristicCellSizeK;
};
} // namespace cvf
} //namespace external

153
external/resinsight/LibCore/cvfArray.h vendored Normal file
View File

@@ -0,0 +1,153 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfObject.h"
#include "cvfValueArray.h"
#include <vector>
namespace external
{
namespace cvf {
//==================================================================================================
//
// Templated array designed for high performance and no overhead over C arrays.
//
//==================================================================================================
template <typename T>
class Array : public Object, public ValueArray<T>
{
public:
Array();
Array(const Array& other);
Array(const T* data, size_t size);
explicit Array(size_t size);
explicit Array(const ValueArray<T>& other);
explicit Array(const std::vector<T>& other);
~Array();
inline const T& operator[](size_t index) const;
inline T& operator[](size_t index);
Array& operator=(Array rhs);
void assign(const T* data, size_t size);
void assign(const std::vector<T>& data);
void resize(size_t size);
void clear();
inline virtual size_t size() const;
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 const T* ptr() const;
inline T* ptr();
inline const T* ptr(size_t index) const;
inline T* ptr(size_t index);
void setSharedPtr(T* data, size_t size);
void setPtr(T* data, size_t size);
void copyData(const T* source, size_t numElementsToCopy, size_t destIndex);
void copyData(const Array<T>& source, size_t numElementsToCopy, size_t destIndex, size_t sourceIndex);
template<typename U>
void copyConvertedData(const Array<U>& source, size_t numElementsToCopy, size_t destIndex, size_t sourceIndex);
template<typename U>
ref<Array<T> > extractElements(const Array<U>& elementIndices) const;
void toStdVector(std::vector<T>* vec) const;
size_t capacity() const;
void reserve(size_t capacity);
void squeeze();
void setSizeZero();
inline void add(const T& val);
T min(size_t* index = 0) const;
T max(size_t* index = 0) const;
void swap(Array& other);
// Basic iterator support to be able to utilize STL algorithms
public:
typedef T* iterator;
typedef const T* const_iterator;
inline iterator begin() { return m_data; }
inline iterator end() { return m_data + m_size; }
inline const_iterator begin() const { return m_data; }
inline const_iterator end() const { return m_data + m_size; }
private:
void ground();
private:
size_t m_size; ///< Number of elements/items in array
size_t m_capacity; ///< Size of the allocated buffer
T* m_data; ///< Array holding the actual data
bool m_sharedData; ///< True if the data member is shared with another object and cannot be changed
};
// Only works for simple types that don't require copy operators.
typedef Array<int> IntArray;
typedef Array<uint> UIntArray;
typedef Array<ushort> UShortArray;
typedef Array<ubyte> UByteArray;
typedef Array<float> FloatArray;
typedef Array<double> DoubleArray;
typedef Array<Vec2f> Vec2fArray;
typedef Array<Vec2d> Vec2dArray;
typedef Array<Vec3f> Vec3fArray;
typedef Array<Vec3d> Vec3dArray;
typedef Array<Vec4f> Vec4fArray;
typedef Array<Vec4d> Vec4dArray;
typedef Array<Color3ub> Color3ubArray;
typedef Array<Color3f> Color3fArray;
typedef Array<Color4ub> Color4ubArray;
}
} //namespace external
#include "cvfArray.inl"

785
external/resinsight/LibCore/cvfArray.inl vendored Normal file
View File

@@ -0,0 +1,785 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
namespace external
{
namespace cvf {
//==================================================================================================
///
/// \class cvf::Array
/// \ingroup Core
///
/// Templated version of a simple array designed for high performance and no overhead over C arrays
/// in release (non-check builds).
///
/// Will only work on simple types and classes that do not rely on a constructor or
/// destructor (as they are not called).
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
/// Create an empty array
//--------------------------------------------------------------------------------------------------
template <typename T>
Array<T>::Array()
{
ground();
}
//--------------------------------------------------------------------------------------------------
/// Create an array with the given number of elements
//--------------------------------------------------------------------------------------------------
template <typename T>
Array<T>::Array(size_t size)
{
CVF_ASSERT(size > 0);
ground();
resize(size);
}
//--------------------------------------------------------------------------------------------------
/// Create the array and assign (copy) the given data
//--------------------------------------------------------------------------------------------------
template <typename T>
Array<T>::Array(const T* data, size_t size)
{
CVF_ASSERT(data);
CVF_ASSERT(size > 0);
ground();
assign(data, size);
}
//--------------------------------------------------------------------------------------------------
/// Create the array and assign (copy) the given data
//--------------------------------------------------------------------------------------------------
template <typename T>
Array<T>::Array(const Array& other)
: Object(), ValueArray<T>()
{
ground();
if (other.size() > 0)
{
assign(other.m_data, other.size());
}
}
//--------------------------------------------------------------------------------------------------
/// Explicit constructor to create the array and assign (copy) the passed value array
//--------------------------------------------------------------------------------------------------
template <typename T>
Array<T>::Array(const ValueArray<T>& other)
{
ground();
if (other.size() > 0)
{
resize(other.size());
size_t i;
for (i = 0; i < other.size(); i++)
{
set(i, other.val(i));
}
}
}
//--------------------------------------------------------------------------------------------------
/// Explicit constructor to create the array and assign (copy) the passed std::vector
//--------------------------------------------------------------------------------------------------
template <typename T>
Array<T>::Array(const std::vector<T>& other)
{
ground();
if (other.size() > 0)
{
assign(other);
}
}
//--------------------------------------------------------------------------------------------------
/// Init all members
//--------------------------------------------------------------------------------------------------
template <typename T>
void Array<T>::ground()
{
m_size = 0;
m_data = NULL;
m_capacity = 0;
m_sharedData = false;
}
//--------------------------------------------------------------------------------------------------
/// Destructor. Deletes the data.
//--------------------------------------------------------------------------------------------------
template <typename T>
Array<T>::~Array()
{
clear();
}
//--------------------------------------------------------------------------------------------------
/// Returns a const reference to the element at the given index.
//--------------------------------------------------------------------------------------------------
template <typename T>
inline const T& Array<T>::operator[] (size_t index) const
{
CVF_TIGHT_ASSERT(m_data);
CVF_TIGHT_ASSERT(index < m_size);
return m_data[index];
}
//--------------------------------------------------------------------------------------------------
/// Returns a modifiable reference to the element at the given index.
//--------------------------------------------------------------------------------------------------
template <typename T>
inline T& Array<T>::operator[] (size_t index)
{
CVF_TIGHT_ASSERT(m_data);
CVF_TIGHT_ASSERT(index < m_size);
return m_data[index];
}
//--------------------------------------------------------------------------------------------------
/// Assign (copy) the data in the given array
//--------------------------------------------------------------------------------------------------
template <typename T>
Array<T>& Array<T>::operator=(Array rhs)
{
CVF_TIGHT_ASSERT(!m_sharedData);
rhs.swap(*this);
return *this;
}
//--------------------------------------------------------------------------------------------------
/// Resize the array to the given size.
/// The current contents (data) will be kept (as much as possible). Any new elements will be unassigned.
/// Calling resize(0) is the same as clear().
//--------------------------------------------------------------------------------------------------
template <typename T>
void Array<T>::resize(size_t size)
{
CVF_ASSERT(!m_sharedData);
if (size > 0)
{
if (m_data)
{
// Copy old data
T* pTmp = m_data;
m_data = new T[size];
size_t numToCopy = CVF_MIN(size, m_size);
cvf::System::memcpy(m_data, size*sizeof(T), pTmp, numToCopy*sizeof(T));
delete[] pTmp;
}
else
{
m_data = new T[size];
}
m_size = size;
m_capacity = size;
}
else
{
clear();
}
}
//--------------------------------------------------------------------------------------------------
/// Clear the array, freeing all memory (if not shared) and setting capacity and size to zero.
/// If the array was in shared mode, it will not be in shared mode anymore.
//--------------------------------------------------------------------------------------------------
template <typename T>
void Array<T>::clear()
{
if (!m_sharedData)
{
delete[] m_data;
}
ground();
}
//--------------------------------------------------------------------------------------------------
/// Returns the number of elements in the array
//--------------------------------------------------------------------------------------------------
template <typename T>
inline size_t Array<T>::size() const
{
return m_size;
}
//--------------------------------------------------------------------------------------------------
/// Set the element at the given index. Index must be < size()
//--------------------------------------------------------------------------------------------------
template <typename T>
inline void Array<T>::set(size_t index, const T& val)
{
CVF_TIGHT_ASSERT(index < m_size);
m_data[index] = val;
}
//--------------------------------------------------------------------------------------------------
/// Set all elements in the array to the given value
//--------------------------------------------------------------------------------------------------
template <typename T>
inline void Array<T>::setAll(const T& val)
{
size_t i;
for (i = 0; i < m_size; i++)
{
set(i, val);
}
}
//--------------------------------------------------------------------------------------------------
/// Assign consecutive values to the elements in the array
///
/// Example: setConsecutive(2) on an array with size=3 gives: {2,3,4}
//--------------------------------------------------------------------------------------------------
template <typename T>
void Array<T>::setConsecutive(const T& startValue)
{
T val = startValue;
size_t i;
for (i = 0; i < m_size; i++)
{
set(i, val++);
}
}
//--------------------------------------------------------------------------------------------------
/// Returns a const reference to the element at the given index
//--------------------------------------------------------------------------------------------------
template <typename T>
const T& cvf::Array<T>::get(size_t index) const
{
CVF_TIGHT_ASSERT(index < m_size);
return m_data[index];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename T>
T cvf::Array<T>::val(size_t index) const
{
CVF_TIGHT_ASSERT(index < m_size);
return m_data[index];
}
//--------------------------------------------------------------------------------------------------
/// Returns a const native pointer to the array storing the data
//--------------------------------------------------------------------------------------------------
template <typename T>
inline const T* Array<T>::ptr() const
{
return m_data;
}
//--------------------------------------------------------------------------------------------------
/// Returns the native pointer to the array storing the data
//--------------------------------------------------------------------------------------------------
template <typename T>
inline T* Array<T>::ptr()
{
return m_data;
}
//--------------------------------------------------------------------------------------------------
/// Returns a const native pointer to the array storing the data
//--------------------------------------------------------------------------------------------------
template <typename T>
inline const T* Array<T>::ptr(size_t index) const
{
CVF_TIGHT_ASSERT(index < m_size);
return &m_data[index];
}
//--------------------------------------------------------------------------------------------------
/// Returns the native pointer to the array storing the data
//--------------------------------------------------------------------------------------------------
template <typename T>
inline T* Array<T>::ptr(size_t index)
{
CVF_TIGHT_ASSERT(index < m_size);
return &m_data[index];
}
//--------------------------------------------------------------------------------------------------
/// Data shared with another class. Will not delete on destruction.
///
/// Any method that reallocates data (resize, assign & setPtr) is not allowed and will assert
/// The only way to break the shared 'connection' is via clear()
//--------------------------------------------------------------------------------------------------
template <typename T>
void Array<T>::setSharedPtr(T* data, size_t size)
{
CVF_ASSERT((data && size > 0) || (!data && size == 0));
clear();
m_data = data;
m_size = size;
m_sharedData = true;
}
//--------------------------------------------------------------------------------------------------
/// Set the data in the array to use the passed array.
///
/// This class takes ownership of the passed data.
//--------------------------------------------------------------------------------------------------
template <typename T>
void Array<T>::setPtr(T* data, size_t size)
{
CVF_ASSERT((data && size > 0) || (!data && size == 0));
// Not allowed
// The only way to break the shared 'connection' is via clear()
CVF_ASSERT(!m_sharedData);
clear();
m_data = data;
m_size = size;
}
//--------------------------------------------------------------------------------------------------
/// Delete any current data and set from the given data pointer
//--------------------------------------------------------------------------------------------------
template <typename T>
void Array<T>::assign(const T* data, size_t size)
{
CVF_ASSERT(data);
CVF_ASSERT(size > 0);
CVF_ASSERT(!m_sharedData);
clear();
resize(size);
// copy
cvf::System::memcpy(m_data, m_size*sizeof(T), data, size*sizeof(T));
}
//--------------------------------------------------------------------------------------------------
/// Delete any current data and set from the given data
//--------------------------------------------------------------------------------------------------
template <typename T>
void Array<T>::assign(const std::vector<T>& data)
{
CVF_ASSERT(!m_sharedData);
clear();
size_t newSize = data.size();
if (newSize > 0)
{
resize(newSize);
cvf::System::memcpy(m_data, m_size*sizeof(T), &data[0], newSize*sizeof(T));
}
}
//--------------------------------------------------------------------------------------------------
/// Copy data into the array
///
/// \warning Must have enough room for the new data, meaning the array must be resize()'ed before use
//--------------------------------------------------------------------------------------------------
template <typename T>
void Array<T>::copyData(const T* pSource, size_t numElementsToCopy, size_t destIndex)
{
CVF_ASSERT(pSource);
CVF_ASSERT(numElementsToCopy > 0);
CVF_ASSERT(destIndex < m_size);
CVF_ASSERT(destIndex + numElementsToCopy <= m_size);
cvf::System::memcpy(m_data + destIndex, (m_size - destIndex)*sizeof(T), pSource, numElementsToCopy*sizeof(T));
}
//--------------------------------------------------------------------------------------------------
/// Copy data into the array
///
/// \warning Must have enough room for the new data, meaning the array must be resize()'ed before use
//--------------------------------------------------------------------------------------------------
template <typename T>
void Array<T>::copyData(const Array<T>& source, size_t numElementsToCopy, size_t destIndex, size_t sourceIndex)
{
CVF_ASSERT(numElementsToCopy > 0);
CVF_ASSERT(destIndex < m_size);
CVF_ASSERT(numElementsToCopy + destIndex <= m_size);
cvf::System::memcpy(m_data + destIndex, (m_size - destIndex)*sizeof(T), source.ptr() + sourceIndex, numElementsToCopy*sizeof(T));
}
//--------------------------------------------------------------------------------------------------
/// Copy data into this array with conversion.
/// Data in source array will be converted using static_cast
//--------------------------------------------------------------------------------------------------
template <typename T>
template <typename U>
void Array<T>::copyConvertedData(const Array<U>& source, size_t numElementsToCopy, size_t destIndex, size_t sourceIndex)
{
CVF_ASSERT(numElementsToCopy > 0);
CVF_ASSERT(destIndex < m_size);
CVF_ASSERT(numElementsToCopy + destIndex <= m_size);
size_t dst = destIndex;
size_t i;
for (i = sourceIndex; i < sourceIndex + numElementsToCopy; i++)
{
m_data[dst++] = static_cast<T>(source[i]);
}
}
//--------------------------------------------------------------------------------------------------
/// Returns an array containing the specified elements
///
/// Example:
/// <PRE>
/// this = {2.0, 5.5, 100.0}
/// elementIndices = { 0, 2, 1, 0, 2}
/// -> output = {2.0, 100.0, 5.5, 2.0, 100.0}
/// </PRE>
//--------------------------------------------------------------------------------------------------
template <typename T>
template <typename U>
ref<Array<T> > Array<T>::extractElements(const Array<U>& elementIndices) const
{
ref<Array<T> > arr = new Array<T>;
size_t numItems = elementIndices.size();
if (numItems > 0)
{
arr->resize(numItems);
size_t i;
for (i = 0; i < numItems; i++)
{
U idx = elementIndices[i];
arr->set(i, get(idx));
}
}
return arr;
}
//--------------------------------------------------------------------------------------------------
/// Copy the contents of the array to the given std::vector
//--------------------------------------------------------------------------------------------------
template <typename T>
void Array<T>::toStdVector(std::vector<T>* vec) const
{
CVF_ASSERT(vec);
size_t numItems = size();
vec->resize(numItems);
size_t i;
for (i = 0; i < numItems; i++)
{
(*vec)[i] = (*this)[i];
}
}
//--------------------------------------------------------------------------------------------------
/// Get the current capacity of the array (the size of the buffer). This will return a number >= size(),
/// depending on if reserve() has been used or not.
/// If capacity() > size(), then add() is allowed on the array.
///
/// \sa
/// - reserve()
/// - add()
/// - squeeze()
/// - setSizeZero()
//--------------------------------------------------------------------------------------------------
template <typename T>
size_t Array<T>::capacity() const
{
return m_capacity;
}
//--------------------------------------------------------------------------------------------------
/// Reserve (allocate) at least the given number of items.
/// If capacity is less than the current buffer, nothing is done.
/// size() of the array is not changed.
///
/// \sa
/// - capacity()
/// - add()
/// - squeeze()
/// - setSizeZero()
//--------------------------------------------------------------------------------------------------
template <typename T>
void Array<T>::reserve(size_t capacity)
{
CVF_ASSERT(!m_sharedData);
if ((capacity <= m_size) || (capacity <= m_capacity))
{
// Required capacity is less than current capacity, done!
return;
}
CVF_ASSERT(capacity > 0);
CVF_ASSERT(capacity > m_size);
if (m_data)
{
// Copy old data
T* pTmp = m_data;
m_data = new T[capacity];
m_capacity = capacity;
cvf::System::memcpy(m_data, capacity*sizeof(T), pTmp, m_size*sizeof(T));
delete[] pTmp;
}
else
{
// alloc
m_data = new T[capacity];
m_capacity = capacity;
}
CVF_ASSERT(m_size <= m_capacity);
}
//--------------------------------------------------------------------------------------------------
/// Realloc the array to the current size(). Removing any reserved memory created by reserve().
///
/// \sa
/// - reserve()
/// - capacity()
/// - add()
/// - setSizeZero()
//--------------------------------------------------------------------------------------------------
template <typename T>
void Array<T>::squeeze()
{
CVF_ASSERT(!m_sharedData);
if (m_data && (m_size < m_capacity))
{
if (m_size > 0)
{
// Copy old data
T* pTmp = m_data;
m_data = new T[m_size];
cvf::System::memcpy(m_data, m_capacity*sizeof(T), pTmp, m_size*sizeof(T));
delete[] pTmp;
m_capacity = m_size;
}
else
{
clear();
}
}
}
//--------------------------------------------------------------------------------------------------
/// Set the size (number of items) in the array to zero, but keep the buffer. Items in the buffer
/// are not modified.
///
/// \sa
/// - reserve()
/// - capacity()
/// - add()
/// - squeeze()
//--------------------------------------------------------------------------------------------------
template <typename T>
void Array<T>::setSizeZero()
{
CVF_TIGHT_ASSERT(!m_sharedData);
m_size = 0;
}
//--------------------------------------------------------------------------------------------------
/// Add an item to the array.
///
/// Note that this will not grow the array, so the array needs to be pre-allocated with reserve()
/// before calling this method. The method will assert if not enough space.
///
/// \sa
/// - reserve()
/// - capacity()
/// - squeeze()
/// - setSizeZero()
//--------------------------------------------------------------------------------------------------
template <typename T>
inline void Array<T>::add(const T& val)
{
CVF_TIGHT_ASSERT(!m_sharedData);
CVF_TIGHT_ASSERT(m_size < m_capacity);
m_data[m_size] = val;
m_size++;
}
//--------------------------------------------------------------------------------------------------
/// Get the min value and optionally the index of the (first) min value
/// Works only on arrays with types that implement comparison operators
/// Empty arrays will return std::numeric_limits<T>::max() and not modify index
//--------------------------------------------------------------------------------------------------
template <typename T>
T Array<T>::min(size_t* index) const
{
T minVal = std::numeric_limits<T>::max();
size_t i;
for (i = 0; i < m_size; i++)
{
if (m_data[i] < minVal)
{
minVal = m_data[i];
if (index)
{
*index = i;
}
}
}
return minVal;
}
//--------------------------------------------------------------------------------------------------
/// Get the min value and optionally the index of the (first) min value
/// Works only on arrays with types that implement comparison operators
/// Empty arrays will return std::numeric_limits<T>::max() and not modify index
//--------------------------------------------------------------------------------------------------
template <typename T>
T Array<T>::max(size_t* index) const
{
T maxVal = std::numeric_limits<T>::min();
size_t i;
for (i = 0; i < m_size; i++)
{
if (m_data[i] > maxVal)
{
maxVal = m_data[i];
if (index)
{
*index = i;
}
}
}
return maxVal;
}
//--------------------------------------------------------------------------------------------------
/// Exchanges the contents of the two arrays.
///
/// \param other Modifiable reference to the array that should have its contents swapped.
///
/// \warning Note that signature differs from normal practice. This is done to be
/// consistent with the signature of std::swap()
//--------------------------------------------------------------------------------------------------
template <typename T>
void Array<T>::swap(Array& other)
{
using std::swap;
swap(m_size, other.m_size);
swap(m_capacity, other.m_capacity);
swap(m_data, other.m_data);
swap(m_sharedData, other.m_sharedData);
}
} // namespace cvf
} //namespace external

View File

@@ -0,0 +1,156 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) Ceetron Solutions AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
namespace external {
namespace cvf {
//--------------------------------------------------------------------------------------------------
///
/// \class cvf::ArrayWrapperConst
/// \ingroup Core
///
/// A wrapper class for const access to make it possible to use different array types with
/// different element types in the same algorithms.
///
/// The implementation has a specialization for bare pointer arrays.
/// The reason for the bare pointer specialization is the [] access implementation
/// which is different. (*array)[] vs array[]
///
/// The convenience functions wrapArrayConst() are available to simplify wrapping of your data making it
/// possible to do:
/// myFunction (wrapArrayConst(myNodeArray), wrapArrayConst(myIndexArray), ...);
/// when calling a template function using ArrayWrapperConst's as input.
///
//--------------------------------------------------------------------------------------------------
template < typename ArrayType, typename ElmType >
class ArrayWrapperConst
{
public:
ArrayWrapperConst(const ArrayType* array, size_t size) : m_array(array), m_size(size) { }
inline size_t size() const { return m_size; }
inline const ElmType& operator[] (const size_t index) const { return (*m_array)[index]; }
private:
const ArrayType * m_array;
size_t m_size;
};
//--------------------------------------------------------------------------------------------------
/// Const bare-pointer array wrapper specialization
//--------------------------------------------------------------------------------------------------
template < typename ElmType >
class ArrayWrapperConst <const ElmType*, ElmType>
{
public:
ArrayWrapperConst(const ElmType* array, size_t size) : m_array(array), m_size(size) { }
inline size_t size() const { return m_size; }
inline const ElmType& operator[](const size_t index) const { return m_array[index]; }
private:
const ElmType * m_array;
size_t m_size;
};
#include "cvfArray.h"
#include <vector>
//--------------------------------------------------------------------------------------------------
/// const cvf::Array specialization
//--------------------------------------------------------------------------------------------------
template <typename ElmType>
inline const ArrayWrapperConst< const cvf::Array<ElmType>, ElmType > wrapArrayConst(const cvf::Array<ElmType>* array )
{
const ArrayWrapperConst<const cvf::Array<ElmType>, ElmType> warr(array, array->size());
return warr;
}
template <typename ElmType>
inline const ArrayWrapperConst< const cvf::Array<ElmType>, ElmType > wrapArrayConst( cvf::Array<ElmType>* array )
{
const ArrayWrapperConst<const cvf::Array<ElmType>, ElmType> warr(array, array->size());
return warr;
}
//--------------------------------------------------------------------------------------------------
/// const std::vector specialization
//--------------------------------------------------------------------------------------------------
template <typename ElmType>
inline const ArrayWrapperConst< const std::vector<ElmType>, ElmType > wrapArrayConst( const std::vector<ElmType>* array )
{
const ArrayWrapperConst< const std::vector<ElmType>, ElmType> warr(array, array->size());
return warr;
}
template <typename ElmType>
inline const ArrayWrapperConst< const std::vector<ElmType>, ElmType > wrapArrayConst( std::vector<ElmType>* array )
{
const ArrayWrapperConst< const std::vector<ElmType>, ElmType> warr(array, array->size());
return warr;
}
//--------------------------------------------------------------------------------------------------
/// const Bare-pointer specialization
//--------------------------------------------------------------------------------------------------
template <typename ElmType>
inline const ArrayWrapperConst< const ElmType*, ElmType > wrapArrayConst( const ElmType* array, size_t size )
{
const ArrayWrapperConst<const ElmType*, ElmType> warr(array, size);
return warr;
}
template <typename ElmType>
inline const ArrayWrapperConst< const ElmType*, ElmType > wrapArrayConst( ElmType* array, size_t size )
{
const ArrayWrapperConst<const ElmType*, ElmType> warr(array, size);
return warr;
}
}
} //namespace external

View File

@@ -0,0 +1,478 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfAssert.h"
#include "cvfSystem.h"
#include <cstdlib>
#include <iostream>
#include <string>
#ifdef WIN32
#pragma warning (push)
#pragma warning (disable: 4668)
#include <windows.h>
#pragma warning (pop)
#include <io.h>
#include <signal.h>
#include <fcntl.h>
#endif
namespace external {
namespace cvf {
// User actions (interactive responses)
static const int USERACTION_CONTINUE = 0;
static const int USERACTION_DEBUGBREAK = 1;
static const int USERACTION_ABORT = 2;
//==================================================================================================
///
/// \class cvf::AssertHandler
/// \ingroup Core
///
/// Base class for assert handlers
///
//==================================================================================================
class AssertHandler
{
public:
virtual ~AssertHandler() {}
virtual Assert::FailAction handleAssert(const char* fileName, int lineNumber, const char* expr, const char* msg) = 0;
};
//==================================================================================================
///
/// \class cvf::AssertHandlerConsole
/// \ingroup Core
///
/// Assert handler for basic assert output to console
///
//==================================================================================================
class AssertHandlerConsole : public AssertHandler
{
public:
virtual Assert::FailAction handleAssert(const char* fileName, int lineNumber, const char* expr, const char* msg);
private:
static void reportToConsole(const char* fileName, int lineNumber, const char* expr, const char* msg);
static int askForUserActionUsingConsole();
#ifdef WIN32
static void winCreateConsoleAndRedirectIO(bool redirectInput);
#endif
};
//--------------------------------------------------------------------------------------------------
/// Show report of a failed assert in console and abort execution
///
/// On Windows, a console will be created if one doesn't exist (GUI applications)
//--------------------------------------------------------------------------------------------------
Assert::FailAction AssertHandlerConsole::handleAssert(const char* fileName, int lineNumber, const char* expr, const char* msg)
{
// Just shows assert message in console.
// Does the job on both Windows and Linux (creates a console on Windows if one doesn't exist)
reportToConsole(fileName, lineNumber, expr, msg);
#ifdef _MSC_VER
#if (_MSC_VER >= 1600)
if (::IsDebuggerPresent())
#endif
{
__debugbreak();
}
#endif
abort();
// Shouldn't really matter since we always abort
return Assert::CONTINUE;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void AssertHandlerConsole::reportToConsole(const char* fileName, int lineNumber, const char* expr, const char* msg)
{
#ifdef WIN32
// Make sure we have a console (applicable to Windows GUI applications)
winCreateConsoleAndRedirectIO(false);
#endif
std::cerr << "Assertion failed:";
if (expr)
{
std::cerr << " (" << expr << ")";
}
if (msg)
{
std::cerr << " '" << msg << "'";
}
if (expr || msg)
{
std::cerr << ",";
}
std::cerr << " file " << fileName << ", line " << lineNumber << std::endl;
}
//--------------------------------------------------------------------------------------------------
/// Ask for user action using console input
///
/// \return One of the USERACTION_ constants
//--------------------------------------------------------------------------------------------------
int AssertHandlerConsole::askForUserActionUsingConsole()
{
#ifdef WIN32
// Make sure we have a console (applicable to Windows GUI applications)
// Also ensures that input is redirected
winCreateConsoleAndRedirectIO(true);
#endif
// Let abort be the default choice
#ifdef WIN32
std::cerr << "Choose action: [A]bort, [R]etry (debug) or [I]gnore: default [A]\n";
#else
std::cerr << "Choose action: [A]bort or [I]gnore: default [A]\n";
#endif
// Reset failstate, just in case.
std::cin.clear();
std::string line;
while (std::getline(std::cin, line))
{
int ch = 0;
if (!std::cin.fail() && line.length() == 1)
{
ch = tolower(line[0]);
}
if (ch == 'i')
{
return USERACTION_CONTINUE;
}
#ifdef WIN32
else if (ch == 'r')
{
return USERACTION_DEBUGBREAK;
}
#endif
else if (ch == 'a' || line.length() == 0)
{
return USERACTION_ABORT;
}
}
return USERACTION_ABORT;
}
//--------------------------------------------------------------------------------------------------
/// Creates a console and redirects I/O from/to it (Windows only)
///
/// \param redirectInput If true, input will also be redirected.
///
/// Function is useful for Windows GUI applications. Allocates a console if it doesn't exist and
/// then redirects output to the console. Also redirects input if \a redirectInput is true
//--------------------------------------------------------------------------------------------------
#ifdef WIN32
void AssertHandlerConsole::winCreateConsoleAndRedirectIO(bool redirectInput)
{
// Allocate a new console for this app
// Only one console can be associated with an app, so should fail if a console is already present.
AllocConsole();
bool redirStdOut = true;
bool redirStdErr = true;
bool redirStdIn = redirectInput;
if (redirStdOut)
{
HANDLE stdHandle = GetStdHandle(STD_OUTPUT_HANDLE);
int fileDescriptor = _open_osfhandle((intptr_t)stdHandle, _O_TEXT);
FILE* fp = _fdopen(fileDescriptor, "w");
*stdout = *fp;
setvbuf(stdout, NULL, _IONBF, 0);
}
if (redirStdErr)
{
HANDLE stdHandle = GetStdHandle(STD_ERROR_HANDLE);
int fileDescriptor = _open_osfhandle((intptr_t)stdHandle, _O_TEXT);
FILE* fp = _fdopen(fileDescriptor, "w");
*stderr = *fp;
setvbuf(stderr, NULL, _IONBF, 0);
}
if (redirStdIn)
{
HANDLE stdHandle = GetStdHandle(STD_INPUT_HANDLE);
int fileDescriptor = _open_osfhandle((intptr_t)stdHandle, _O_TEXT);
FILE* fp = _fdopen(fileDescriptor, "r");
*stdin = *fp;
setvbuf(stdin, NULL, _IONBF, 0);
}
// Make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog point to console as well
std::ios::sync_with_stdio();
}
#endif
//==================================================================================================
///
/// \class cvf::AssertHandlerWinDialog
/// \ingroup Core
///
/// Assert handler for Windows, using a dialog with interaction
///
//==================================================================================================
#ifdef WIN32
class AssertHandlerWinDialog : public AssertHandler
{
public:
virtual Assert::FailAction handleAssert(const char* fileName, int lineNumber, const char* expr, const char* msg);
private:
static int handleUsingDialog(const char* fileName, int lineNumber, const char* expr, const char* msg);
#ifdef _DEBUG
static int handleUsingCrtDbgReport(const char* fileName, int lineNumber, const char* expr, const char* msg);
#endif
};
#endif
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
#ifdef WIN32
Assert::FailAction AssertHandlerWinDialog::handleAssert(const char* fileName, int lineNumber, const char* expr, const char* msg)
{
//int retVal = handleUsingCrtDbgReport(fileName, lineNumber, expr, msg);
int retVal = handleUsingDialog(fileName, lineNumber, expr, msg);
if (retVal == USERACTION_CONTINUE)
{
return Assert::CONTINUE;
}
else if (retVal == USERACTION_DEBUGBREAK)
{
return Assert::DEBUGBREAK;
}
else if (retVal == USERACTION_ABORT)
{
// From __crtMessageWindow() in response to user clicking abort button
// Note that it is better NOT to call abort() here, because the default implementation of abort() will call Watson
// raise abort signal
raise(SIGABRT);
// We usually won't get here, but it's possible that SIGABRT was ignored.
// So exit the program anyway.
_exit(3);
}
// Shouldn't be getting here
abort();
return Assert::CONTINUE;
}
#endif
//--------------------------------------------------------------------------------------------------
/// Shows message in interactive dialog and lets user choose how to proceed
///
/// \return Returns one of the USERACTION_ constants depending on which button the user chooses.
///
/// Compared to the handleUsingCrtDbgReport() function, this function will also work in release builds
/// As opposed to the handleUsingCrtDbgReport(), this function will not call abort, but will return
/// USERACTION_ABORT instead.
///
/// \todo Must add code to handle case where new assert is triggered while handling an assert
//--------------------------------------------------------------------------------------------------
#ifdef WIN32
int AssertHandlerWinDialog::handleUsingDialog(const char* fileName, int lineNumber, const char* expr, const char* msg)
{
char szMsgBuf[2048];
System::strcpy(szMsgBuf, sizeof(szMsgBuf), "Assertion failed\n");
System::strcat(szMsgBuf, sizeof(szMsgBuf), "\nFile: ");
if (fileName)
{
System::strcat(szMsgBuf, sizeof(szMsgBuf), fileName);
}
System::strcat(szMsgBuf, sizeof(szMsgBuf), "\nLine: ");
if (lineNumber >= 0)
{
char szLinNumBuf[20];
System::sprintf(szLinNumBuf, sizeof(szLinNumBuf), "%d", lineNumber);
System::strcat(szMsgBuf, sizeof(szMsgBuf), szLinNumBuf);
}
if (expr)
{
System::strcat(szMsgBuf, sizeof(szMsgBuf), "\n\n");
System::strcat(szMsgBuf, sizeof(szMsgBuf), "Expression: ");
System::strcat(szMsgBuf, sizeof(szMsgBuf), expr);
}
if (msg)
{
System::strcat(szMsgBuf, sizeof(szMsgBuf), "\n\n");
System::strcat(szMsgBuf, sizeof(szMsgBuf), msg);
}
System::strcat(szMsgBuf, sizeof(szMsgBuf), "\n\n(Press Retry to debug application)");
int retVal = ::MessageBoxA(NULL, szMsgBuf, "Assertion Failed", MB_TASKMODAL|MB_ICONHAND|MB_ABORTRETRYIGNORE|MB_SETFOREGROUND);
if (retVal == IDIGNORE) return USERACTION_CONTINUE;
else if (retVal == IDRETRY) return USERACTION_DEBUGBREAK;
else return USERACTION_ABORT;
}
#endif
//--------------------------------------------------------------------------------------------------
/// Wrapper function for the CRT _CrtDbgReport() function
///
/// This function never returns if the user chooses 'Abort'
/// Note that the underlying function is only available in debug builds
//--------------------------------------------------------------------------------------------------
#if defined WIN32 && defined _DEBUG
int AssertHandlerWinDialog::handleUsingCrtDbgReport(const char* fileName, int lineNumber, const char* expr, const char* msg)
{
// Create message combining expression and message
char szMsgBuf[2048];
szMsgBuf[0] = '\0';
if (expr)
{
System::strcat(szMsgBuf, sizeof(szMsgBuf), expr);
}
if (msg)
{
System::strcat(szMsgBuf, sizeof(szMsgBuf), "\n");
System::strcat(szMsgBuf, sizeof(szMsgBuf), msg);
}
int retVal = _CrtDbgReport(_CRT_ASSERT, fileName, lineNumber, NULL, szMsgBuf);
if (retVal == 0) return USERACTION_CONTINUE;
else if (retVal == 1) return USERACTION_DEBUGBREAK;
else return USERACTION_ABORT;
}
#endif
//==================================================================================================
///
/// \class cvf::Assert
/// \ingroup Core
///
/// Helper class to customize assert
///
//==================================================================================================
#ifdef WIN32
AssertHandler* Assert::sm_handler = new AssertHandlerWinDialog;
#else
AssertHandler* Assert::sm_handler = new AssertHandlerConsole;
#endif
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Assert::setReportMode(ReportMode reportMode)
{
#ifndef WIN32
if (reportMode == INTERACTIVE_DIALOG) return;
#endif
delete sm_handler;
sm_handler = NULL;
if (reportMode == CONSOLE)
{
sm_handler = new AssertHandlerConsole;
}
#ifdef WIN32
else if (reportMode == INTERACTIVE_DIALOG)
{
sm_handler = new AssertHandlerWinDialog;
}
#endif
}
//--------------------------------------------------------------------------------------------------
/// Show report of a failed assert
///
/// If assertions are configured to be interactive, a message box will be shown on Windows and
/// the user may opt to ignore or trigger debugging.
/// On Linux, or if interactive asserts are disabled, the application will terminate.
///
/// \todo Add handling of cases where we get another assert while processing the first one AND
/// asserts from multiple threads.
//--------------------------------------------------------------------------------------------------
Assert::FailAction Assert::reportFailedAssert(const char* fileName, int lineNumber, const char* expr, const char* msg)
{
if (sm_handler)
{
return sm_handler->handleAssert(fileName, lineNumber, expr, msg);
}
else
{
abort();
return CONTINUE;
}
}
} // namespace cvf
} //namespace external

107
external/resinsight/LibCore/cvfAssert.h vendored Normal file
View File

@@ -0,0 +1,107 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
namespace external {
namespace cvf {
// Forward of base class for assert handlers
class AssertHandler;
//==================================================================================================
//
// Helper class to customize assert behavior
//
//==================================================================================================
class Assert
{
public:
enum ReportMode
{
CONSOLE, // Report asserts to console only and then abort. (default mode for Linux)
INTERACTIVE_DIALOG // Show message in dialog and ask for user action (Windows only, default mode on Windows)
};
enum FailAction
{
CONTINUE, // Continue execution
DEBUGBREAK // Execution should be stopped and debugger should be triggered (currently windows only)
};
public:
static void setReportMode(ReportMode reportMode);
static FailAction reportFailedAssert(const char* fileName, int lineNumber, const char* expr, const char* msg);
private:
static AssertHandler* sm_handler;
};
} // cvf
// Define to trigger debug trap for use with assert macros
// Currently only useful and in action on windows
#ifdef WIN32
#define CVF_DEBUGTRAP() __debugbreak()
#else
#define CVF_DEBUGTRAP() ((void)0)
#endif
// Define our assert macros
#if CVF_ENABLE_ASSERTS == 1
# define CVF_ASSERT(expr) (void)( (!!(expr)) || (cvf::Assert::CONTINUE == cvf::Assert::reportFailedAssert(__FILE__, __LINE__, #expr, NULL)) || (CVF_DEBUGTRAP(), 0) )
# define CVF_ASSERT_MSG(expr, msg) (void)( (!!(expr)) || (cvf::Assert::CONTINUE == cvf::Assert::reportFailedAssert(__FILE__, __LINE__, #expr, (msg))) || (CVF_DEBUGTRAP(), 0) )
# define CVF_FAIL_MSG(msg) (void)( (cvf::Assert::CONTINUE == cvf::Assert::reportFailedAssert(__FILE__, __LINE__, NULL, (msg))) || (CVF_DEBUGTRAP(), 0) )
#else
# define CVF_ASSERT(expr) ((void)0)
# define CVF_ASSERT_MSG(expr, msg) ((void)0)
# define CVF_FAIL_MSG(msg) ((void)0)
#endif
#if CVF_ENABLE_TIGHT_ASSERTS == 1 && CVF_ENABLE_ASSERTS == 1
# define CVF_TIGHT_ASSERT(expr) CVF_ASSERT(expr)
# define CVF_TIGHT_ASSERT_MSG(expr, msg) CVF_ASSERT_MSG(expr, msg)
#else
# define CVF_TIGHT_ASSERT(expr) ((void)0)
# define CVF_TIGHT_ASSERT_MSG(expr, msg) ((void)0)
#endif
} //namespace external

View File

@@ -0,0 +1,175 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2014 Ceetron Solutions AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
//##################################################################################################
#include "cvfAtomicCounter.h"
namespace external {
// Some older GCC version do not support atomics, we have seen this for RHEL5
#if defined(CVF_ATOMIC_COUNTER_CLASS_EXISTS)
namespace cvf {
#ifdef WIN32
#pragma warning (push)
#pragma warning (disable: 4668)
#include <windows.h>
#pragma warning (pop)
AtomicCounter::AtomicCounter(int initialValue)
: m_counter(initialValue)
{
}
AtomicCounter::~AtomicCounter()
{
}
AtomicCounter::operator int () const
{
return m_counter;
}
int AtomicCounter::operator ++ () // prefix
{
return InterlockedIncrement(&m_counter);
}
int AtomicCounter::operator ++ (int) // postfix
{
int result = InterlockedIncrement(&m_counter);
return --result;
}
int AtomicCounter::operator -- () // prefix
{
return InterlockedDecrement(&m_counter);
}
int AtomicCounter::operator -- (int) // postfix
{
int result = InterlockedDecrement(&m_counter);
return ++result;
}
#elif defined(CVF_IOS) || defined(CVF_OSX)
AtomicCounter::AtomicCounter(int initialValue)
: m_counter(initialValue)
{
}
AtomicCounter::~AtomicCounter()
{
}
AtomicCounter::operator int () const
{
return m_counter;
}
int AtomicCounter::operator ++ () // prefix
{
return OSAtomicIncrement32(&m_counter);
}
int AtomicCounter::operator ++ (int) // postfix
{
int result = OSAtomicIncrement32(&m_counter);
return --result;
}
int AtomicCounter::operator -- () // prefix
{
return OSAtomicDecrement32(&m_counter);
}
int AtomicCounter::operator -- (int) // postfix
{
int result = OSAtomicDecrement32(&m_counter);
return ++result;
}
#elif defined(CVF_GCC_DEFINED)
AtomicCounter::AtomicCounter(int initialValue)
: m_counter(initialValue)
{
}
AtomicCounter::~AtomicCounter()
{
}
AtomicCounter::operator int () const
{
return m_counter;
}
int AtomicCounter::operator ++ () // prefix
{
return __sync_add_and_fetch(&m_counter, 1);
}
int AtomicCounter::operator ++ (int) // postfix
{
return __sync_fetch_and_add(&m_counter, 1);
}
int AtomicCounter::operator -- () // prefix
{
return __sync_sub_and_fetch(&m_counter, 1);
}
int AtomicCounter::operator -- (int) // postfix
{
return __sync_fetch_and_sub(&m_counter, 1);
}
#endif
} // namespace cvf
#endif // CVF_ATOMICS_COMPILED
} //namespace external

View File

@@ -0,0 +1,94 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2014 Ceetron Solutions AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfBase.h"
namespace external {
#ifdef WIN32
#define CVF_ATOMIC_COUNTER_CLASS_EXISTS
#elif defined(CVF_IOS) || defined(CVF_OSX)
#include <libkern/OSAtomic.h>
#define CVF_ATOMIC_COUNTER_CLASS_EXISTS
#elif defined __GNUC__
#define CVF_GCC_DEFINED
#define CVF_ATOMIC_COUNTER_CLASS_EXISTS
#endif
#if defined(CVF_ATOMIC_COUNTER_CLASS_EXISTS)
namespace cvf {
// Inspired by Poco
class AtomicCounter
{
public:
explicit AtomicCounter(int initialValue);
~AtomicCounter();
operator int () const;
int operator ++ (); // prefix
int operator ++ (int); // postfix
int operator -- (); // prefix
int operator -- (int); // postfix
private:
CVF_DISABLE_COPY_AND_ASSIGN(AtomicCounter);
#ifdef WIN32
typedef volatile long ImplType;
#elif defined(CVF_IOS) || defined(CVF_OSX)
typedef int32_t ImplType;
#else
typedef int ImplType;
#endif
ImplType m_counter;
};
} // namespace cvf
#endif
} //namespace external

133
external/resinsight/LibCore/cvfBase.h vendored Normal file
View File

@@ -0,0 +1,133 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
// #if !defined(WIN32) && !defined(CVF_LINUX) && !defined(CVF_IOS) && !defined(CVF_OSX) && !defined(CVF_ANDROID)
// #error No platform defined
// #endif
// Global include file with definitions useful for all library files
// Disable some annoying warnings so we can compile with warning level Wall
#ifdef _MSC_VER
// 4512 'class' : assignment operator could not be generated : Due to problems with classes with reference member variables (e.g. VertexCompactor)
// 4514 unreferenced inline/local function has been removed
// 4625 copy constructor could not be generated because a base class copy constructor is inaccessible
// 4626 assignment operator could not be generated because a base class assignment operator is inaccessible
// 4640 'staticInstance' : construction of local static object is not thread-safe -> used by singletons. To be revisited.
// 4710 function 'func_name' not inlined
// 4711 function 'func_name' selected for automatic inline expansion
// 4738 storing 32-bit float result in memory, possible loss of performance
// 4820 'bytes' bytes padding added after construct 'member_name'
#pragma warning (disable: 4512 4514 4625 4626 4640 4710 4711 4738 4820)
#if (_MSC_VER >= 1600)
// VS2010 and newer
// 4986 'operator new[]': exception specification does not match previous declaration
#pragma warning (disable: 4986)
#endif
#endif
// Makes it easier to check on the current GCC version
#ifdef __GNUC__
// 40302 means version 4.3.2.
# define CVF_GCC_VER (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__)
#endif
// Helper macro to disable (ignore) compiler warnings on GCC
// The needed pragma is only available in GCC for versions 4.2.x and above
#if defined(__GNUC__) && (CVF_GCC_VER >= 40200)
#define CVF_DO_PRAGMA(x) _Pragma(#x)
#define CVF_GCC_DIAGNOSTIC_IGNORE(OPTION_STRING) CVF_DO_PRAGMA(GCC diagnostic ignored OPTION_STRING)
#else
#define CVF_GCC_DIAGNOSTIC_IGNORE(OPTION_STRING)
#endif
#if defined(CVF_LINUX) || defined(CVF_IOS) || defined(CVF_OSX) || defined(CVF_ANDROID)
// Used by int64_t on *nix below
#include <stdint.h>
#endif
// Brings in size_t and definition of NULL
#include <cstddef>
namespace external {
// Added due to conflict between std::min/max and define in Windows.h
#define CVF_MIN(X, Y) ((X) < (Y) ? (X) : (Y))
#define CVF_MAX(X, Y) ((X) > (Y) ? (X) : (Y))
// Macro for avoiding "unused parameter" warnings
// The bottom one is the best alternative, but unfortunately doesn't work on VS2010
#ifdef WIN32
#define CVF_UNUSED(EXPR) (void)(EXPR);
#else
#define CVF_UNUSED(EXPR) (void)sizeof(EXPR);
#endif
// Macro to disable the copy constructor and assignment operator
// Should be used in the private section of a class
#define CVF_DISABLE_COPY_AND_ASSIGN(CLASS_NAME) \
CLASS_NAME(const CLASS_NAME&); \
void operator=(const CLASS_NAME&)
/// Ceetron Visualization Framework namespace
namespace cvf {
typedef unsigned char ubyte;
typedef unsigned short ushort;
typedef unsigned int uint;
// 64bit integer support via the int64 type
#ifdef WIN32
typedef __int64 int64;
#elif defined(CVF_LINUX) || defined(CVF_IOS) || defined(CVF_OSX) || defined(CVF_ANDROID)
typedef int64_t int64;
#endif
}
} //namespace external
#include "cvfConfigCore.h"
#include "cvfVersion.h"
#include "cvfAssert.h"

59
external/resinsight/LibCore/cvfBase64.h vendored Normal file
View File

@@ -0,0 +1,59 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfString.h"
#include "cvfArray.h"
namespace external {
namespace cvf {
//==================================================================================================
//
// Base64 encoding and decoding for representing binary data in an ASCII string
//
//==================================================================================================
class Base64
{
public:
static std::string encode(const cvf::UByteArray& data);
static cvf::ref<cvf::UByteArray> decode(const std::string& encodedData);
};
}
} //namespace external

View File

@@ -0,0 +1,172 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfCharArray.h"
#include "cvfSystem.h"
#include <sstream>
#include <iomanip>
namespace external {
namespace cvf {
//==================================================================================================
///
/// \class cvf::CharArray
/// \ingroup Core
///
/// 8 bit zero terminated char array.
///
/// Behind the scenes, the array always has a 0 termination sentinel.
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
CharArray::CharArray()
{
m_data.push_back('\0');
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
CharArray::CharArray(size_t size, char c)
{
resize(size);
size_t i;
for (i = 0; i < size; i++)
{
m_data[i] = c;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
CharArray::CharArray(const char* str)
{
size_t numChars = System::strlen(str);
resize(numChars);
size_t i;
for (i = 0; i < numChars; i++)
{
m_data[i] = str[i];
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
char& CharArray::operator[](size_t i)
{
CVF_TIGHT_ASSERT(i < m_data.size() - 1);
return m_data[i];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const char& CharArray::operator[](size_t i) const
{
CVF_TIGHT_ASSERT(i < m_data.size() - 1);
return m_data[i];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void CharArray::resize(size_t size)
{
m_data.resize(size + 1, '\0');
m_data[size] = '\0';
}
//--------------------------------------------------------------------------------------------------
/// Add a character to the array. Array grows if necessary.
//--------------------------------------------------------------------------------------------------
void CharArray::push_back(char c)
{
CVF_TIGHT_ASSERT(m_data.size() > 0);
m_data[m_data.size() - 1] = c;
m_data.push_back('\0');
}
//--------------------------------------------------------------------------------------------------
/// Get the size of the character array.
///
/// Note that this is not necessarily the length of the contained string. In order to get the string
/// length, you must call System::strlen().
//--------------------------------------------------------------------------------------------------
size_t CharArray::size() const
{
CVF_TIGHT_ASSERT(m_data.size() > 0);
return m_data.size() - 1;
}
//--------------------------------------------------------------------------------------------------
/// Get a const char* pointer to the string
//--------------------------------------------------------------------------------------------------
const char* CharArray::ptr() const
{
CVF_ASSERT(m_data.size() > 0);
CVF_ASSERT(m_data[m_data.size() - 1] == '\0');
return &m_data[0];
}
//--------------------------------------------------------------------------------------------------
/// Get a const char* pointer to the string
//--------------------------------------------------------------------------------------------------
char* CharArray::ptr()
{
CVF_ASSERT(m_data.size() > 0);
CVF_ASSERT(m_data[m_data.size() - 1] == '\0');
return &m_data[0];
}
} // namespace cvf
} //namespace external

View File

@@ -0,0 +1,75 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfBase.h"
#include <vector>
namespace external {
namespace cvf {
//==================================================================================================
//
// 8 bit zero terminated char array
//
//==================================================================================================
class CharArray
{
public:
CharArray();
CharArray(size_t size, char c);
explicit CharArray(const char* str);
char& operator[](size_t i);
const char& operator[](size_t i) const;
void resize(size_t size);
void push_back(char c);
size_t size() const;
const char* ptr() const;
char* ptr();
private:
std::vector<char> m_data;
};
}
} //namespace external

View File

@@ -0,0 +1,85 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
namespace external {
namespace cvf {
//==================================================================================================
//
//
//
//==================================================================================================
class CodeLocation
{
public:
CodeLocation();
CodeLocation(const char* fileName, const char* functionName, int lineNumber);
CodeLocation(const CodeLocation& other);
const CodeLocation& operator=(CodeLocation rhs);
const char* fileName() const;
const char* shortFileName() const;
const char* functionName() const;
int lineNumber() const;
void swap(CodeLocation& other);
private:
const char* m_fileName;
const char* m_functionName;
int m_lineNumber;
};
#if defined(_MSC_VER)
#define CVF_CODELOC_FUNCNAME __FUNCSIG__
#elif defined(__GNUC__)
#define CVF_CODELOC_FUNCNAME __PRETTY_FUNCTION__
#else
#define CVF_CODELOC_FUNCNAME ""
#endif
#define CVF_CODE_LOCATION ::cvf::CodeLocation(__FILE__, CVF_CODELOC_FUNCNAME, __LINE__)
} // cvf
} //namespace external

View File

@@ -0,0 +1,102 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfObject.h"
#include "cvfMath.h"
#include <vector>
#include <algorithm>
namespace external {
namespace cvf {
//==================================================================================================
//
// A collection class for reference counted objects (that derive from Object)
//
//==================================================================================================
template<typename T>
class Collection
{
public:
Collection();
Collection(const Collection& other);
explicit Collection(const std::vector< ref<T> >& vector);
Collection& operator=(Collection rhs);
Collection& operator=(const std::vector< ref<T> >& vector);
const ref<T>& operator[](size_t index) const;
ref<T>& operator[](size_t index);
void push_back(T* data);
const T* at(size_t index) const;
T* at(size_t index);
void resize(size_t size);
size_t size() const;
void reserve(size_t capacity);
size_t capacity() const;
void clear();
bool empty() const;
bool contains(const T* data) const;
size_t indexOf(const T* data) const;
void erase(const T* data);
void eraseAt(size_t index);
void swap(Collection& other);
// Iterator support
public:
typedef typename std::vector<ref<T> >::iterator iterator;
typedef typename std::vector<ref<T> >::const_iterator const_iterator;
iterator begin();
iterator end();
const_iterator begin() const;
const_iterator end() const;
private:
std::vector<ref<T> > m_vector;
};
}
} //namespace external
#include "cvfCollection.inl"

View File

@@ -0,0 +1,334 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
namespace external {
namespace cvf {
//==================================================================================================
///
/// \class cvf::Collection
/// \ingroup Core
///
/// A collection class for reference counted objects (that derive from Object).
///
/// The class add a reference to all objects when added to the array, and releases them when removed
/// from the array.
///
/// The class exposes the same public interface as a std::vector, so see the STL documentation
/// for documentation on most of the methods.
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
/// Default constructor. Create an empty collection
//--------------------------------------------------------------------------------------------------
template<typename T>
Collection<T>::Collection()
{
}
//--------------------------------------------------------------------------------------------------
/// Copy constructor
//--------------------------------------------------------------------------------------------------
template<typename T>
Collection<T>::Collection(const Collection& other)
: m_vector(other.m_vector)
{
}
//--------------------------------------------------------------------------------------------------
/// Create a collection and copy the contents from the passed collection
//--------------------------------------------------------------------------------------------------
template<typename T>
Collection<T>::Collection(const std::vector< ref<T> >& vector)
: m_vector(vector)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
Collection<T>& Collection<T>::operator=(Collection rhs)
{
rhs.swap(*this);
return *this;
}
//--------------------------------------------------------------------------------------------------
/// Set the collection to contain the same elements as the passed collection
//--------------------------------------------------------------------------------------------------
template<typename T>
Collection<T>& Collection<T>::operator=(const std::vector< ref<T> >& vector)
{
m_vector = vector;
return *this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
const ref<T>& Collection<T>::operator[](size_t index) const
{
return m_vector[index];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
ref<T>& Collection<T>::operator[](size_t index)
{
return m_vector[index];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
void Collection<T>::push_back(T* data)
{
m_vector.push_back(data);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
const T* Collection<T>::at(size_t index) const
{
return m_vector[index].p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
T* Collection<T>::at(size_t index)
{
return m_vector[index].p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
void Collection<T>::resize(size_t size)
{
m_vector.resize(size);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
size_t Collection<T>::size() const
{
return m_vector.size();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
void Collection<T>::reserve(size_t capacity)
{
m_vector.reserve(capacity);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
size_t Collection<T>::capacity() const
{
return m_vector.capacity();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
void Collection<T>::clear()
{
m_vector.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
bool Collection<T>::empty() const
{
return m_vector.empty();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
bool Collection<T>::contains(const T* data) const
{
if (std::find(m_vector.begin(), m_vector.end(), data) != m_vector.end())
{
return true;
}
else
{
return false;
}
}
//--------------------------------------------------------------------------------------------------
/// Find index of the first occurence of the specified element
///
/// Returns UNDEFINED_SIZE_T if element could not be found
//--------------------------------------------------------------------------------------------------
template<typename T>
size_t Collection<T>::indexOf(const T* data) const
{
typename std::vector<ref<T> >::const_iterator it = std::find(m_vector.begin(), m_vector.end(), data);
if (it != m_vector.end())
{
return static_cast<size_t>(it - m_vector.begin());
}
else
{
return UNDEFINED_SIZE_T;
}
}
//--------------------------------------------------------------------------------------------------
/// Erase the specified element
//--------------------------------------------------------------------------------------------------
template<typename T>
void Collection<T>::erase(const T* data)
{
typename std::vector<ref<T> >::iterator it = std::find(m_vector.begin(), m_vector.end(), data);
if (it != m_vector.end())
{
m_vector.erase(it);
}
}
//--------------------------------------------------------------------------------------------------
/// Erase the element at the specified index
//--------------------------------------------------------------------------------------------------
template<typename T>
void Collection<T>::eraseAt(size_t index)
{
CVF_ASSERT(index < m_vector.size());
// Cast may have to be to std::vector<T>::difference_type
m_vector.erase(m_vector.begin() + static_cast<ptrdiff_t>(index));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
void Collection<T>::swap(Collection& other)
{
m_vector.swap(other.m_vector);
}
//--------------------------------------------------------------------------------------------------
/// Return iterator to beginning
//--------------------------------------------------------------------------------------------------
template<typename T>
typename Collection<T>::iterator Collection<T>::begin()
{
return m_vector.begin();
}
//--------------------------------------------------------------------------------------------------
/// Return iterator to end
//--------------------------------------------------------------------------------------------------
template<typename T>
typename Collection<T>::iterator Collection<T>::end()
{
return m_vector.end();
}
//--------------------------------------------------------------------------------------------------
/// Return const iterator to beginning
//--------------------------------------------------------------------------------------------------
template<typename T>
typename Collection<T>::const_iterator Collection<T>::begin() const
{
return m_vector.begin();
}
//--------------------------------------------------------------------------------------------------
/// Return const iterator to end
//--------------------------------------------------------------------------------------------------
template<typename T>
typename Collection<T>::const_iterator Collection<T>::end() const
{
return m_vector.end();
}
} // namespace cvf
} //namespace external

186
external/resinsight/LibCore/cvfColor3.h vendored Normal file
View File

@@ -0,0 +1,186 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfBase.h"
namespace external {
namespace cvf {
// Forward declarations
class Color3ub;
//==================================================================================================
//
// Abstract base class for RGB colors
//
//==================================================================================================
class Color3
{
public:
enum ColorIdent
{
RED, ///< Pure red (255, 0, 0)
GREEN, ///< Pure greed (0, 255, 0)
BLUE, ///< Pure blue (0, 0, 255)
YELLOW, ///< Yellow (255, 255, 0)
CYAN, ///< Cyan (0, 255, 255)
MAGENTA, ///< Magenta (255, 0, 255)
WHITE, ///< White
BLACK, ///< Black
LIGHT_GRAY, ///< Light gray (192, 192, 192)
GRAY, ///< Gray (128, 128, 128)
DARK_GRAY, ///< Dark gray (64, 64, 64)
BROWN, ///< Brown (165, 42, 42)
CRIMSON, ///< Crimson (220, 20, 60)
DARK_BLUE, ///< Dark blue (0, 0, 139)
DARK_YELLOW, ///< Dark yellow (139, 139, 0)
DARK_CYAN, ///< Dark cyan (0, 139, 139)
DARK_GREEN, ///< Dark green (0, 100, 0)
DARK_MAGENTA, ///< Dark magenta (139, 0, 139)
DARK_ORANGE, ///< Dark orange (255, 140, 0)
DARK_RED, ///< Dark red (139, 0, 0)
DARK_VIOLET, ///< Dark violet (148, 0, 211)
DEEP_PINK, ///< Deep pink (255, 20, 147)
FOREST_GREEN, ///< Forest green (34, 139, 34)
GOLD, ///< Gold (255, 215, 0)
GREEN_YELLOW, ///< Green yellow (173, 255, 47)
INDIGO, ///< Indigo (75, 0, 130)
OLIVE, ///< Olive (128, 128, 0)
ORANGE, ///< Orange (255, 165, 0)
ORANGE_RED, ///< Orange red (255, 69, 0)
ORCHID, ///< Orchid (218, 112, 214)
PINK, ///< Pink (255, 192, 203)
PURPLE, ///< Purple (128, 0, 128)
SEA_GREEN, ///< Sea green (46, 139, 87)
SKY_BLUE, ///< Sky blue (135, 206, 235)
VIOLET, ///< Violet (238, 130, 238)
YELLOW_GREEN, ///< Yellow green (154, 205, 50)
CEETRON ///< Ceetron Color (81, 134, 148)
};
};
//==================================================================================================
//
// Floating point RGB colors
//
//==================================================================================================
class Color3f : public Color3
{
public:
Color3f();
Color3f(float r, float g, float b);
Color3f(const Color3f& other);
Color3f(ColorIdent colorIdent);
explicit Color3f(const Color3ub& other);
Color3f& operator=(const Color3f& rhs);
Color3f& operator=(ColorIdent colorIdent);
bool operator==(const Color3f& rhs) const;
bool operator!=(const Color3f& rhs) const;
const float& r() const { return m_rgb[0]; } ///< Returns the red color component
const float& g() const { return m_rgb[1]; } ///< Returns the green color component
const float& b() const { return m_rgb[2]; } ///< Returns the blue color component
float& r() { return m_rgb[0]; } ///< Get modifiable reference to the red color component, used for setting the component.
float& g() { return m_rgb[1]; } ///< Get modifiable reference to the green color component, used for setting the component
float& b() { return m_rgb[2]; } ///< Get modifiable reference to the blue color component, used for setting the component
void set(float r, float g, float b);
bool isValid() const;
const float* ptr() const;
ubyte rByte() const;
ubyte gByte() const;
ubyte bByte() const;
static Color3f fromByteColor(ubyte r, ubyte g, ubyte b);
friend bool operator < (const Color3f& color1, const Color3f& color2);
private:
float m_rgb[3];
};
bool operator < (const Color3f& color1, const Color3f& color2);
//==================================================================================================
//
// Unsigned byte RGB colors
//
//==================================================================================================
class Color3ub : public Color3
{
public:
Color3ub();
Color3ub(ubyte r, ubyte g, ubyte b);
Color3ub(const Color3ub& other);
Color3ub(ColorIdent colorIdent);
explicit Color3ub(const Color3f& other);
Color3ub& operator=(const Color3ub& rhs);
Color3ub& operator=(ColorIdent colorIdent);
bool operator==(const Color3ub& rhs) const;
bool operator!=(const Color3ub& rhs) const;
ubyte r() const { return m_rgb[0]; } ///< Returns the red color component
ubyte g() const { return m_rgb[1]; } ///< Returns the green color component
ubyte b() const { return m_rgb[2]; } ///< Returns the blue color component
ubyte& r() { return m_rgb[0]; } ///< Get modifiable reference to the red color component.
ubyte& g() { return m_rgb[1]; } ///< Get modifiable reference to the green color component.
ubyte& b() { return m_rgb[2]; } ///< Get modifiable reference to the blue color component.
void set(ubyte r, ubyte g, ubyte b);
const ubyte* ptr() const;
private:
ubyte m_rgb[3];
};
}
} //namespace external

128
external/resinsight/LibCore/cvfColor4.h vendored Normal file
View File

@@ -0,0 +1,128 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfColor3.h"
namespace external {
namespace cvf {
class Color4ub;
//==================================================================================================
//
// Class for RGBA colors
//
//==================================================================================================
class Color4f
{
public:
Color4f();
Color4f(float r, float g, float b, float alpha);
Color4f(const Color4f& other);
Color4f(const Color3f& rgbColor, float alpha);
explicit Color4f(const Color3f& rgbColor);
explicit Color4f(Color3::ColorIdent colorIdent);
explicit Color4f(const Color4ub& other);
Color4f& operator=(const Color4f& rhs);
bool operator==(const Color4f& rhs) const;
bool operator!=(const Color4f& rhs) const;
const float& r() const { return m_rgba[0]; } ///< Returns the red color component
const float& g() const { return m_rgba[1]; } ///< Returns the green color component
const float& b() const { return m_rgba[2]; } ///< Returns the blue color component
const float& a() const { return m_rgba[3]; } ///< Returns the alpha component
float& r() { return m_rgba[0]; } ///< Get modifiable reference to the red color component, used for setting the component.
float& g() { return m_rgba[1]; } ///< Get modifiable reference to the green color component, used for setting the component
float& b() { return m_rgba[2]; } ///< Get modifiable reference to the blue color component, used for setting the component
float& a() { return m_rgba[3]; } ///< Get modifiable reference to the alpha component, used for setting the component
void set(float r, float g, float b, float alpha);
void set(const Color3f& rgbColor, float alpha);
void set(const Color3f& rgbColor);
bool isValid() const;
const float* ptr() const;
Color3f toColor3f() const;
private:
float m_rgba[4];
};
//==================================================================================================
//
// Unsigned byte RGBA colors
//
//==================================================================================================
class Color4ub
{
public:
Color4ub();
Color4ub(ubyte r, ubyte g, ubyte b, ubyte a);
Color4ub(const Color4ub& other);
Color4ub(const Color3ub& rgbColor, ubyte a);
explicit Color4ub(const Color3ub& rgbColor);
explicit Color4ub(Color3::ColorIdent colorIdent);
explicit Color4ub(const Color4f& other);
Color4ub& operator=(const Color4ub& rhs);
bool operator==(const Color4ub& rhs) const;
bool operator!=(const Color4ub& rhs) const;
ubyte r() const { return m_rgba[0]; } ///< Returns the red color component
ubyte g() const { return m_rgba[1]; } ///< Returns the green color component
ubyte b() const { return m_rgba[2]; } ///< Returns the blue color component
ubyte a() const { return m_rgba[3]; } ///< Returns the alpha component
ubyte& r() { return m_rgba[0]; } ///< Get modifiable reference to the red color component.
ubyte& g() { return m_rgba[1]; } ///< Get modifiable reference to the green color component.
ubyte& b() { return m_rgba[2]; } ///< Get modifiable reference to the blue color component.
ubyte& a() { return m_rgba[3]; } ///< Get modifiable reference to the alpha component.
void set(ubyte r, ubyte g, ubyte b, ubyte a);
const ubyte* ptr() const;
private:
ubyte m_rgba[4];
};
}
} //namespace external

View File

@@ -0,0 +1,78 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
namespace external {
// Define this one to tell windows.h to not define min() and max() as macros
#if defined WIN32 && !defined NOMINMAX
#define NOMINMAX
#endif
// Used to keep track of all instances of classes derived from Object.
// Can be used to detect memory leaks in combination with the static member
// functions: Object::activeObjectInstances() and Object::dumpActiveObjectInstances()
// 0 - disable tracking of active object instances
// 1 - track active instances in debug builds
// 2 - track active instances in BOTH debug and release builds
#ifndef CVF_TRACK_ACTIVE_OBJECT_INSTANCES
#define CVF_TRACK_ACTIVE_OBJECT_INSTANCES 0
#endif
// Behavior of assert macros
// In debug builds, all asserts are in action, including tight asserts
// In release builds, tight asserts are disabled by default. Normal asserts are still in action (including CVF_FAIL_...)
#ifndef CVF_ENABLE_ASSERTS
#define CVF_ENABLE_ASSERTS 1
#endif
#ifndef CVF_ENABLE_TIGHT_ASSERTS
#ifdef _DEBUG
#define CVF_ENABLE_TIGHT_ASSERTS 1
#else
#define CVF_ENABLE_TIGHT_ASSERTS 0
#endif
#endif
} //namespace external

View File

@@ -0,0 +1,87 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfString.h"
namespace external {
namespace cvf {
class Timer;
//=================================================================================================
//
// Timer class
//
//=================================================================================================
class DebugTimer
{
public:
enum OperationMode
{
NORMAL, ///< Normal operation
DISABLED ///< Disables all functionality in the class
};
public:
DebugTimer(const char* prefix, OperationMode operationMode = NORMAL);
~DebugTimer();
void restart(const char* msg = NULL);
void reportTime(const char* msg = NULL);
void reportTimeMS(const char* msg = NULL);
void reportLapTime(const char* msg = NULL);
void reportLapTimeMS(const char* msg = NULL);
void echoMessage(const char* format, ...);
private:
String makeMessageStartString(const char* msg);
private:
Timer* m_timer; ///< The actual timer object to use
String* m_prefix; ///< String to prefix all output
int m_messageCount; ///< Counts number of messages returned
CVF_DISABLE_COPY_AND_ASSIGN(DebugTimer);
};
}
} //namespace external

77
external/resinsight/LibCore/cvfFlags.h vendored Normal file
View File

@@ -0,0 +1,77 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
namespace external {
namespace cvf {
//=================================================================================================
//
// Flags class
//
//=================================================================================================
template<typename FlagEnum>
class Flags
{
public:
inline Flags();
inline Flags(const Flags& other);
inline Flags(FlagEnum flag);
inline Flags& operator=(const Flags& rhs);
inline Flags& operator=(FlagEnum flag);
inline Flags& operator|=(const Flags& rhs);
inline Flags operator|(const Flags& rhs) const;
inline Flags& operator&=(const Flags& rhs);
inline Flags operator&(const Flags& rhs) const;
inline bool operator==(const Flags& rhs) const;
inline bool operator==(int rhs) const;
inline bool operator!=(const Flags& rhs) const;
inline bool operator!=(int rhs) const;
inline bool testFlag(FlagEnum flag) const;
private:
int m_bitfield;
};
}
} //namespace external
#include "cvfFlags.inl"

198
external/resinsight/LibCore/cvfFlags.inl vendored Normal file
View File

@@ -0,0 +1,198 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
namespace external {
namespace cvf {
//==================================================================================================
///
/// \class cvf::Flags
/// \ingroup Core
///
/// The Flags class provides a type-safe way of storing OR-combinations of enum values
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
/// Default constructor
//--------------------------------------------------------------------------------------------------
template<typename FlagEnum>
inline Flags<FlagEnum>::Flags()
: m_bitfield(0)
{
}
//--------------------------------------------------------------------------------------------------
/// Copy constructor
//--------------------------------------------------------------------------------------------------
template<typename FlagEnum>
inline Flags<FlagEnum>::Flags(const Flags& other)
: m_bitfield(other.m_bitfield)
{
}
//--------------------------------------------------------------------------------------------------
/// Constructor with initialization
//--------------------------------------------------------------------------------------------------
template<typename FlagEnum>
inline Flags<FlagEnum>::Flags(FlagEnum flag)
: m_bitfield(flag)
{
}
//--------------------------------------------------------------------------------------------------
/// Assignment operator
//--------------------------------------------------------------------------------------------------
template<typename FlagEnum>
inline Flags<FlagEnum>& Flags<FlagEnum>::operator=(const Flags& rhs)
{
m_bitfield = rhs.m_bitfield;
return *this;
}
//--------------------------------------------------------------------------------------------------
/// Assignment operator
//--------------------------------------------------------------------------------------------------
template<typename FlagEnum>
inline Flags<FlagEnum>& Flags<FlagEnum>::operator=(FlagEnum flag)
{
m_bitfield = flag;
return *this;
}
//--------------------------------------------------------------------------------------------------
/// Performs a bitwise OR operation with rhs and stores the result in this Flags object.
//--------------------------------------------------------------------------------------------------
template<typename FlagEnum>
inline Flags<FlagEnum>& Flags<FlagEnum>::operator|=(const Flags& rhs)
{
m_bitfield |= rhs.m_bitfield;
return *this;
}
//--------------------------------------------------------------------------------------------------
/// Performs a bitwise OR operation with rhs and returns new object
//--------------------------------------------------------------------------------------------------
template<typename FlagEnum>
inline Flags<FlagEnum> Flags<FlagEnum>::operator|(const Flags& rhs) const
{
Flags ret(*this);
return (ret |= rhs);
}
//--------------------------------------------------------------------------------------------------
/// Performs a bitwise AND operation with rhs and stores the result in this Flags object.
//--------------------------------------------------------------------------------------------------
template<typename FlagEnum>
inline Flags<FlagEnum>& Flags<FlagEnum>::operator&=(const Flags& rhs)
{
m_bitfield &= rhs.m_bitfield;
return *this;
}
//--------------------------------------------------------------------------------------------------
/// Performs a bitwise AND operation with rhs and returns new object
//--------------------------------------------------------------------------------------------------
template<typename FlagEnum>
inline Flags<FlagEnum> Flags<FlagEnum>::operator&(const Flags& rhs) const
{
Flags ret(*this);
return (ret &= rhs);
}
//--------------------------------------------------------------------------------------------------
/// Comparison operator, equality
//--------------------------------------------------------------------------------------------------
template<typename FlagEnum>
inline bool Flags<FlagEnum>::operator==(const Flags& rhs) const
{
return m_bitfield == rhs.m_bitfield;
}
//--------------------------------------------------------------------------------------------------
/// Comparison operator, equality
//--------------------------------------------------------------------------------------------------
template<typename FlagEnum>
inline bool Flags<FlagEnum>::operator==(int rhs) const
{
return m_bitfield == rhs;
}
//--------------------------------------------------------------------------------------------------
/// Comparison operator, not equal
//--------------------------------------------------------------------------------------------------
template<typename FlagEnum>
inline bool Flags<FlagEnum>::operator!=(const Flags& rhs) const
{
return m_bitfield != rhs.m_bitfield;
}
//--------------------------------------------------------------------------------------------------
/// Comparison operator, not equal
//--------------------------------------------------------------------------------------------------
template<typename FlagEnum>
inline bool Flags<FlagEnum>::operator!=(int rhs) const
{
return m_bitfield != rhs;
}
//--------------------------------------------------------------------------------------------------
/// Return true only if ALL bits in flag are set
//--------------------------------------------------------------------------------------------------
template<typename FlagEnum>
inline bool Flags<FlagEnum>::testFlag(FlagEnum flag) const
{
return ((m_bitfield & flag) == flag);
}
} // namespace cvf
} //namespace external

View File

@@ -0,0 +1,73 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
namespace external {
namespace cvf {
//==================================================================================================
///
/// \class cvf::FunctorRange
/// \ingroup Core
///
/// Implements an iteration range for use with our functors.
/// The class is designed to be compatible with TBB's blocked_range class with regards to
/// the functor's requirements
///
//==================================================================================================
template <typename T>
class FunctorRange
{
public:
FunctorRange(T beginIndex, T endIndex)
: m_beginIndex(beginIndex), m_endIndex(endIndex) {}
inline T begin() const { return m_beginIndex; } ///< The first index included in the range
inline T end() const { return m_endIndex; } ///< Index one past last the last index to be included in the range
private:
T m_beginIndex; // The first index to be included in the iteration.
T m_endIndex; // The index one past the last index to be included in the iteration
};
} // cvf
} //namespace external

View File

@@ -0,0 +1,74 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
// Doxygen module definition
/// \ingroup VizFramework
/// @{
/// \defgroup Core Core module
/// @}
/// \defgroup VizFramework Framework Basis
// Intentionally on top to be included first
#include "cvfBase.h"
#include "cvfArray.h"
#include "cvfAssert.h"
#include "cvfBase64.h"
#include "cvfCharArray.h"
#include "cvfCollection.h"
#include "cvfColor3.h"
#include "cvfColor4.h"
#include "cvfDebugTimer.h"
#include "cvfFlags.h"
#include "cvfFunctorRange.h"
#include "cvfLogger.h"
#include "cvfMath.h"
#include "cvfMatrix4.h"
#include "cvfObject.h"
#include "cvfPlane.h"
#include "cvfRect.h"
#include "cvfQuat.h"
#include "cvfString.h"
#include "cvfSystem.h"
#include "cvfTBBControl.h"
#include "cvfTimer.h"
#include "cvfTrace.h"
#include "cvfVector2.h"
#include "cvfVector3.h"
#include "cvfVector4.h"
#include "cvfVersion.h"

View File

@@ -0,0 +1,64 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfObject.h"
namespace external {
namespace cvf {
class LogEvent;
//==================================================================================================
//
// Interface for log destinations
//
//==================================================================================================
class LogDestination : public Object
{
public:
virtual void log(const LogEvent& logEvent) = 0;
};
} // cvf
} //namespace external

114
external/resinsight/LibCore/cvfLogger.h vendored Normal file
View File

@@ -0,0 +1,114 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfObject.h"
#include "cvfString.h"
#include "cvfCodeLocation.h"
namespace external {
namespace cvf {
class LogEvent;
class LogDestination;
//==================================================================================================
//
// Logger class
//
//==================================================================================================
class Logger : public Object
{
public:
enum Level
{
LL_ERROR = 1,
LL_WARNING,
LL_INFO,
LL_DEBUG
};
public:
Logger(const String& loggerName, int logLevel, LogDestination* logDestination);
~Logger();
const String& name() const;
int level() const;
void setLevel(int logLevel);
LogDestination* destination();
void setDestination(LogDestination* logDestination);
void error(const String& message);
void error(const String& message, const CodeLocation& location);
void warning(const String& message);
void warning(const String& message, const CodeLocation& location);
void info(const String& message);
void info(const String& message, const CodeLocation& location);
void debug(const String& message, const CodeLocation& location);
bool isErrorEnabled() const { return m_logLevel >= LL_ERROR; }
bool isWarningEnabled() const { return m_logLevel >= LL_WARNING; }
bool isInfoEnabled() const { return m_logLevel >= LL_INFO; }
bool isDebugEnabled() const { return m_logLevel >= LL_DEBUG; }
private:
void log(const String& message, Logger::Level messageLevel, const CodeLocation& location);
private:
String m_name; // Logger name
int m_logLevel; // Logging level, all messages with a level less than or equal to this level will be logged
ref<LogDestination> m_destination;
CVF_DISABLE_COPY_AND_ASSIGN(Logger);
};
// Helper macros for writing log messages to a logger
#define CVF_LOG_ERROR(theLogger, theMessage) if ((theLogger)->isErrorEnabled()) { (theLogger)->error((theMessage), CVF_CODE_LOCATION); }
#define CVF_LOG_WARNING(theLogger, theMessage) if ((theLogger)->isWarningEnabled()) { (theLogger)->warning((theMessage), CVF_CODE_LOCATION); }
#define CVF_LOG_INFO(theLogger, theMessage) if ((theLogger)->isInfoEnabled()) { (theLogger)->info((theMessage), CVF_CODE_LOCATION); }
#define CVF_LOG_DEBUG(theLogger, theMessage) if ((theLogger)->isDebugEnabled()) { (theLogger)->debug((theMessage), CVF_CODE_LOCATION); }
} // cvf
} //namespace external

341
external/resinsight/LibCore/cvfMath.cpp vendored Normal file
View File

@@ -0,0 +1,341 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfMath.h"
#include <cmath>
namespace external {
namespace cvf {
//==================================================================================================
///
/// \class cvf::Math
/// \ingroup Core
///
/// Static class providing basic math operations
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
float Math::toRadians(float degrees)
{
return degrees*PI_F/180.0f;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double Math::toRadians(double degrees)
{
return degrees*PI_D/180.0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
float Math::toDegrees(float radians)
{
return radians*180.0f/PI_F;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double Math::toDegrees(double radians)
{
return radians*180.0/PI_D;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double Math::cos(double val)
{
return ::cos(val);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
float Math::cos(float val)
{
return ::cosf(val);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double Math::acos(double val)
{
return ::acos(val);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
float Math::acos(float val)
{
return ::acosf(val);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double Math::sin(double val)
{
return ::sin(val);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
float Math::sin(float val)
{
return ::sinf(val);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double Math::asin(double val)
{
return ::asin(val);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
float Math::asin(float val)
{
return ::asinf(val);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double Math::tan(double val)
{
return ::tan(val);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
float Math::tan(float val)
{
return ::tanf(val);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double Math::atan(double val)
{
return ::atan(val);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
float Math::atan(float val)
{
return ::atanf(val);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double Math::sqrt(double val)
{
return ::sqrt(val);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
float Math::sqrt(float val)
{
return ::sqrtf(val);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double Math::floor(double val)
{
return ::floor(val);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
float Math::floor(float val)
{
return ::floorf(val);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double Math::ceil(double val)
{
return ::ceil(val);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
float Math::ceil(float val)
{
return ::ceilf(val);
}
//--------------------------------------------------------------------------------------------------
/// Returns the floating-point remainder of x / y
//--------------------------------------------------------------------------------------------------
double Math::fmod(double x, double y)
{
return ::fmod(x, y);
}
//--------------------------------------------------------------------------------------------------
/// Returns the floating-point remainder of x / y
//--------------------------------------------------------------------------------------------------
float Math::fmod(float x, float y)
{
return ::fmodf(x, y);
}
//--------------------------------------------------------------------------------------------------
/// Returns true if the number is a power of 2
///
/// The number 0 is not considered a power of 2.
//--------------------------------------------------------------------------------------------------
bool Math::isPow2(uint number)
{
// From Bit Twiddling Hacks
// http://graphics.stanford.edu/~seander/bithacks.html
return (number && !(number & (number - 1)));
}
//--------------------------------------------------------------------------------------------------
/// Round up to the next highest power of 2
///
/// If the number is already a power of 2 this function will return the same value
/// If number if out of range (greater than 2147483648) we cannot represent the next power of 2 and 0 is returned
//--------------------------------------------------------------------------------------------------
uint Math::roundUpPow2(uint number)
{
// From Bit Twiddling Hacks
// http://graphics.stanford.edu/~seander/bithacks.html
if (number == 0)
{
// Handle edge case where number is 0, algo returns 0, which isn't a power of 2;
return 1;
}
if (number > 2147483648u)
{
// Input is too large, we cannot represent the next power of two
return 0;
}
number--;
number |= number >> 1;
number |= number >> 2;
number |= number >> 4;
number |= number >> 8;
number |= number >> 16;
number++;
return number;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool Math::isUndefined(double val)
{
if (val < UNDEFINED_DOUBLE_THRESHOLD)
{
return false;
}
else
{
return true;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool Math::isUndefined(float val)
{
if (val < UNDEFINED_FLOAT_THRESHOLD)
{
return false;
}
else
{
return true;
}
}
} // namespace cvf
} //namespace external

117
external/resinsight/LibCore/cvfMath.h vendored Normal file
View File

@@ -0,0 +1,117 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfBase.h"
namespace external {
namespace cvf {
//==================================================================================================
//
// Static class providing basic math operations
//
//==================================================================================================
class Math
{
public:
static float toRadians(float degrees);
static double toRadians(double degrees);
static float toDegrees(float radians);
static double toDegrees(double radians);
static double cos(double val);
static float cos(float val);
static double acos(double val);
static float acos(float val);
static double sin(double val);
static float sin(float val);
static double asin(double val);
static float asin(float val);
static double tan(double val);
static float tan(float val);
static double atan(double val);
static float atan(float val);
static double sqrt(double val);
static float sqrt(float val);
static double floor(double val);
static float floor(float val);
static double ceil(double val);
static float ceil(float val);
static double fmod(double x, double y);
static float fmod(float x, float y);
static bool isPow2(uint number);
static uint roundUpPow2(uint number);
static bool isUndefined(double val);
static bool isUndefined(float val);
template<typename T> static bool valueInRange(T val, T min, T max);
template<typename T> static T clamp(T val, T minVal, T maxVal);
template<typename T> static inline T abs(const T& val);
template<typename T> static int sign(const T& val);
};
const float PI_F = 3.14159265f;
const double PI_D = 3.14159265358979323846;
const float ONE_THIRD_F = 1.0f/3.0f;
const double ONE_THIRD_D = 1.0/3.0;
const double SQRT2_F = 1.41421356f; // sqrt(2)
const double SQRT2_D = 1.41421356237309504880; // sqrt(2)
const double SQRT1_2_F = 0.70710678f; // 1/sqrt(2)
const double SQRT1_2_D = 0.70710678118654752440; // 1/sqrt(2)
const int UNDEFINED_INT = 2147483647;
const uint UNDEFINED_UINT = static_cast<uint>(-1); // 4294967295u
const size_t UNDEFINED_SIZE_T = static_cast<size_t>(-1);// 18446744073709551615u
const double UNDEFINED_DOUBLE = 1.7976931348623158e+308;
const double UNDEFINED_DOUBLE_THRESHOLD = 1.00e+308;
const float UNDEFINED_FLOAT = 3.402823466e+38f;
const float UNDEFINED_FLOAT_THRESHOLD = 2.99e+38f;
} // namespace cvf
} //namespace external
#include "cvfMath.inl"

108
external/resinsight/LibCore/cvfMath.inl vendored Normal file
View File

@@ -0,0 +1,108 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
namespace external {
namespace cvf {
//--------------------------------------------------------------------------------------------------
/// Check if a value is within the specified range, inclusive.
///
/// \return Returns true if \a val >= \a min and \a val <= \a max.
//--------------------------------------------------------------------------------------------------
template<typename T>
bool Math::valueInRange(T val, T minVal, T maxVal)
{
CVF_ASSERT(minVal <= maxVal);
if (val >= minVal && val <= maxVal)
{
return true;
}
else
{
return false;
}
}
//--------------------------------------------------------------------------------------------------
/// Clamp a value within an inclusive range.
///
/// \return The clamped value
//--------------------------------------------------------------------------------------------------
template<typename T>
T Math::clamp(T val, T minVal, T maxVal)
{
CVF_ASSERT(minVal <= maxVal);
if (val >= minVal && val <= maxVal)
{
return val;
}
else if (val > maxVal)
{
return maxVal;
}
else
{
return minVal;
}
}
//--------------------------------------------------------------------------------------------------
/// Returns the absolute value of val
//--------------------------------------------------------------------------------------------------
template<typename T>
T Math::abs(const T& val)
{
return val >= 0 ? val : -val;
}
//--------------------------------------------------------------------------------------------------
/// Returns the sign of val
//--------------------------------------------------------------------------------------------------
template<typename T>
int Math::sign(const T& val)
{
return val < 0 ? -1 : 1;
}
} // namespace cvf
} //namespace external

110
external/resinsight/LibCore/cvfMatrix3.h vendored Normal file
View File

@@ -0,0 +1,110 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfSystem.h"
#include "cvfVector3.h"
namespace external {
namespace cvf {
//==================================================================================================
//
// Template matrix class for 3x3 matrices
//
//==================================================================================================
template<typename S>
class Matrix3
{
public:
Matrix3();
Matrix3(const Matrix3& other);
Matrix3(S m00, S m01, S m02, S m10, S m11, S m12, S m20, S m21, S m22);
template<typename T>
explicit Matrix3(const Matrix3<T>& other);
inline Matrix3& operator=(const Matrix3& rhs);
bool equals(const Matrix3& mat) const;
bool operator==(const Matrix3& rhs) const;
bool operator!=(const Matrix3& rhs) const;
void multiply(const Matrix3& mat);
const Matrix3 operator*(const Matrix3& rhs) const;
void setIdentity();
bool isIdentity() const;
void setZero();
bool isZero() const;
inline void setRowCol(int row, int col, S value);
inline S rowCol(int row, int col) const;
inline S& operator()(int row, int col);
inline S operator()(int row, int col) const;
bool invert();
const Matrix3 getInverted(bool* pInvertible = NULL) const;
S determinant() const;
void transpose();
inline const S* ptr() const;
static Matrix3 fromRotation(Vector3<S> axis, S angle);
public:
static const Matrix3 IDENTITY; ///< Identity matrix
static const Matrix3 ZERO; ///< Matrix with all zeros
private:
// Constants for accessing our internal array using standard matrix notation
static const int e00 = 0; static const int e01 = 3; static const int e02 = 6;
static const int e10 = 1; static const int e11 = 4; static const int e12 = 7;
static const int e20 = 2; static const int e21 = 5; static const int e22 = 8;
private:
S m_v[9];
};
typedef Matrix3<float> Mat3f;
typedef Matrix3<double> Mat3d;
}
} //namespace external
#include "cvfMatrix3.inl"

View File

@@ -0,0 +1,487 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
namespace external {
namespace cvf {
//==================================================================================================
///
/// \class cvf::Matrix3
/// \ingroup Core
///
/// Matrices are stored internally as a one dimensional array for performance reasons.
///
/// The internal indices into the 1D array are as follows:
///
/// <PRE>
/// | m00 m01 m02 | | 0 3 6 |
/// | m10 m11 m12 | | 1 4 7 |
/// | m20 m21 m22 | | 2 5 18 |
/// </PRE>
///
/// See description of Matrix4 for more details on storage
///
//==================================================================================================
template<typename S> Matrix3<S> const Matrix3<S>::IDENTITY;
template<typename S> Matrix3<S> const Matrix3<S>::ZERO(0, 0, 0, 0, 0, 0, 0, 0, 0);
//----------------------------------------------------------------------------------------------------
/// Default constructor. Initializes matrix to identity
//----------------------------------------------------------------------------------------------------
template <typename S>
Matrix3<S>::Matrix3()
{
setIdentity();
}
//----------------------------------------------------------------------------------------------------
/// Copy constructor
//----------------------------------------------------------------------------------------------------
template <typename S>
inline Matrix3<S>::Matrix3(const Matrix3& other)
{
System::memcpy(m_v, sizeof(m_v), other.m_v, sizeof(other.m_v));
}
//----------------------------------------------------------------------------------------------------
/// Constructor with explicit initialization of all matrix elements.
///
/// The value of the parameter \a mrc will be placed in row r and column c of the matrix, eg m12
/// goes into row 1, column 2.
//----------------------------------------------------------------------------------------------------
template <typename S>
Matrix3<S>::Matrix3(S m00, S m01, S m02, S m10, S m11, S m12, S m20, S m21, S m22)
{
m_v[e00] = m00;
m_v[e10] = m10;
m_v[e20] = m20;
m_v[e01] = m01;
m_v[e11] = m11;
m_v[e21] = m21;
m_v[e02] = m02;
m_v[e12] = m12;
m_v[e22] = m22;
}
//----------------------------------------------------------------------------------------------------
///
//----------------------------------------------------------------------------------------------------
template<typename S>
template<typename T>
Matrix3<S>::Matrix3(const Matrix3<T>& other)
{
m_v[e00] = static_cast<S>(other.rowCol(0, 0));
m_v[e01] = static_cast<S>(other.rowCol(0, 1));
m_v[e02] = static_cast<S>(other.rowCol(0, 2));
m_v[e10] = static_cast<S>(other.rowCol(1, 0));
m_v[e11] = static_cast<S>(other.rowCol(1, 1));
m_v[e12] = static_cast<S>(other.rowCol(1, 2));
m_v[e20] = static_cast<S>(other.rowCol(2, 0));
m_v[e21] = static_cast<S>(other.rowCol(2, 1));
m_v[e22] = static_cast<S>(other.rowCol(2, 2));
}
//----------------------------------------------------------------------------------------------------
/// Assignment operator
//----------------------------------------------------------------------------------------------------
template <typename S>
inline Matrix3<S>& Matrix3<S>::operator=(const Matrix3& obj)
{
System::memcpy(m_v, sizeof(m_v), obj.m_v, sizeof(obj.m_v));
return *this;
}
//----------------------------------------------------------------------------------------------------
/// Check if matrices are equal using exact comparisons.
//----------------------------------------------------------------------------------------------------
template<typename S>
bool Matrix3<S>::equals(const Matrix3& mat) const
{
for (int i = 0; i < 9; i++)
{
if (m_v[i] != mat.m_v[i]) return false;
}
return true;
}
//----------------------------------------------------------------------------------------------------
/// Comparison operator. Checks for equality using exact comparisons.
//----------------------------------------------------------------------------------------------------
template <typename S>
bool Matrix3<S>::operator==(const Matrix3& rhs) const
{
return this->equals(rhs);
}
//----------------------------------------------------------------------------------------------------
/// Comparison operator. Checks for not equal using exact comparisons.
//----------------------------------------------------------------------------------------------------
template <typename S>
bool Matrix3<S>::operator!=(const Matrix3& rhs) const
{
int i;
for (i = 0; i < 9; i++)
{
if (m_v[i] != rhs.m_v[i]) return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
/// Multiplies this matrix M with the matrix \a mat, M = M*mat
//--------------------------------------------------------------------------------------------------
template<typename S>
void Matrix3<S>::multiply(const Matrix3& mat)
{
*this = (*this)*mat;
}
//----------------------------------------------------------------------------------------------------
///
//----------------------------------------------------------------------------------------------------
template <typename S>
const Matrix3<S> Matrix3<S>::operator*(const Matrix3& rhs) const
{
Matrix3 m;
int r;
for (r = 0; r < 3; r++)
{
int c;
for (c = 0; c < 3; c++)
{
S val = 0;
int a;
for (a = 0; a < 3; a++)
{
val += rowCol(r, a)*rhs.rowCol(a, c);
}
m.setRowCol(r, c, val);
}
}
return m;
}
//----------------------------------------------------------------------------------------------------
/// Sets this matrix to identity
//----------------------------------------------------------------------------------------------------
template <typename S>
void Matrix3<S>::setIdentity()
{
m_v[0] = 1;
m_v[1] = 0;
m_v[2] = 0;
m_v[3] = 0;
m_v[4] = 1;
m_v[5] = 0;
m_v[6] = 0;
m_v[7] = 0;
m_v[8] = 1;
}
//----------------------------------------------------------------------------------------------------
/// Check if this matrix is identity using exact comparisons
//----------------------------------------------------------------------------------------------------
template <typename S>
bool Matrix3<S>::isIdentity() const
{
if (m_v[0] != 1) return false;
if (m_v[1] != 0) return false;
if (m_v[2] != 0) return false;
if (m_v[3] != 0) return false;
if (m_v[4] != 1) return false;
if (m_v[5] != 0) return false;
if (m_v[6] != 0) return false;
if (m_v[7] != 0) return false;
if (m_v[8] != 1) return false;
return true;
}
//----------------------------------------------------------------------------------------------------
/// Set all matrix elements to 0
//----------------------------------------------------------------------------------------------------
template <typename S>
void Matrix3<S>::setZero()
{
m_v[0] = 0;
m_v[1] = 0;
m_v[2] = 0;
m_v[3] = 0;
m_v[4] = 0;
m_v[5] = 0;
m_v[6] = 0;
m_v[7] = 0;
m_v[8] = 0;
}
//----------------------------------------------------------------------------------------------------
/// Returns true if all elements of the matrix are 0. Uses exact comparison.
//----------------------------------------------------------------------------------------------------
template <typename S>
bool Matrix3<S>::isZero() const
{
if (m_v[0] != 0) return false;
if (m_v[1] != 0) return false;
if (m_v[2] != 0) return false;
if (m_v[3] != 0) return false;
if (m_v[4] != 0) return false;
if (m_v[5] != 0) return false;
if (m_v[6] != 0) return false;
if (m_v[7] != 0) return false;
if (m_v[8] != 0) return false;
return true;
}
//----------------------------------------------------------------------------------------------------
/// Set the matrix element at the specified row and column
//----------------------------------------------------------------------------------------------------
template <typename S>
inline void Matrix3<S>::setRowCol(int row, int col, S value)
{
CVF_TIGHT_ASSERT(row >= 0 && row < 3);
CVF_TIGHT_ASSERT(col >= 0 && col < 3);
m_v[3*col + row] = value;
}
//----------------------------------------------------------------------------------------------------
/// Get the matrix element at the specified row and column
//----------------------------------------------------------------------------------------------------
template <typename S>
inline S Matrix3<S>::rowCol(int row, int col) const
{
CVF_TIGHT_ASSERT(row >= 0 && row < 3);
CVF_TIGHT_ASSERT(col >= 0 && col < 3);
return m_v[3*col + row];
}
//--------------------------------------------------------------------------------------------------
/// Get modifiable reference to the the matrix element at the specified row and column
//--------------------------------------------------------------------------------------------------
template <typename S>
inline S& Matrix3<S>::operator()(int row, int col)
{
CVF_TIGHT_ASSERT(row >= 0 && row < 3);
CVF_TIGHT_ASSERT(col >= 0 && col < 3);
return m_v[3*col + row];
}
//--------------------------------------------------------------------------------------------------
/// Get the matrix element at the specified row and column
//--------------------------------------------------------------------------------------------------
template <typename S>
inline S Matrix3<S>::operator()(int row, int col) const
{
CVF_TIGHT_ASSERT(row >= 0 && row < 3);
CVF_TIGHT_ASSERT(col >= 0 && col < 3);
return m_v[3*col + row];
}
//----------------------------------------------------------------------------------------------------
///
//----------------------------------------------------------------------------------------------------
template <typename S>
bool Matrix3<S>::invert()
{
// Use double internally here
double m00 = static_cast<double>(m_v[e00]);
double m10 = static_cast<double>(m_v[e10]);
double m20 = static_cast<double>(m_v[e20]);
double m01 = static_cast<double>(m_v[e01]);
double m11 = static_cast<double>(m_v[e11]);
double m21 = static_cast<double>(m_v[e21]);
double m02 = static_cast<double>(m_v[e02]);
double m12 = static_cast<double>(m_v[e12]);
double m22 = static_cast<double>(m_v[e22]);
double det = m00*m11*m22 + m01*m12*m20 + m02*m10*m21 - m00*m12*m21 - m01*m10*m22 - m02*m11*m20;
if (Math::abs(det) > std::numeric_limits<double>::epsilon())
{
double invDet = 1/det;
m_v[e00] = static_cast<S>( (m11*m22 - m12*m21) * invDet );
m_v[e01] = static_cast<S>( (m02*m21 - m01*m22) * invDet );
m_v[e02] = static_cast<S>( (m01*m12 - m02*m11) * invDet );
m_v[e10] = static_cast<S>( (m12*m20 - m10*m22) * invDet );
m_v[e11] = static_cast<S>( (m00*m22 - m02*m20) * invDet );
m_v[e12] = static_cast<S>( (m02*m10 - m00*m12) * invDet );
m_v[e20] = static_cast<S>( (m10*m21 - m11*m20) * invDet );
m_v[e21] = static_cast<S>( (m01*m20 - m00*m21) * invDet );
m_v[e22] = static_cast<S>( (m00*m11 - m01*m10) * invDet );
return true;
}
else
{
return false;
}
}
//----------------------------------------------------------------------------------------------------
///
//----------------------------------------------------------------------------------------------------
template <typename S>
const Matrix3<S> Matrix3<S>::getInverted(bool* pInvertible) const
{
Matrix3 m(*this);
if (m.invert())
{
if (pInvertible) *pInvertible = true;
}
else
{
if (pInvertible) *pInvertible = false;
m.setZero();
}
return m;
}
//----------------------------------------------------------------------------------------------------
///
//----------------------------------------------------------------------------------------------------
template <typename S>
S Matrix3<S>::determinant() const
{
S det = m_v[e00]*m_v[e11]*m_v[e22] +
m_v[e01]*m_v[e12]*m_v[e20] +
m_v[e02]*m_v[e10]*m_v[e21] -
m_v[e00]*m_v[e12]*m_v[e21] -
m_v[e01]*m_v[e10]*m_v[e22] -
m_v[e02]*m_v[e11]*m_v[e20];
return det;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename S>
void Matrix3<S>::transpose()
{
S tmp;
int i, j;
for (i = 0; i < 3; i++)
{
for (j = i + 1; j < 3; j++)
{
tmp = m_v[j + 3*i];
m_v[j + 3*i] = m_v[3*j + i];
m_v[3*j + i] = tmp;
}
}
}
//----------------------------------------------------------------------------------------------------
///
//----------------------------------------------------------------------------------------------------
template <typename S>
const S* Matrix3<S>::ptr() const
{
return m_v;
}
//----------------------------------------------------------------------------------------------------
///
//----------------------------------------------------------------------------------------------------
template <typename S>
Matrix3<S> Matrix3<S>::fromRotation(Vector3<S> axis, S angle)
{
axis.normalize();
S rcos = Math::cos(angle);
S rsin = Math::sin(angle);
Matrix3 m;
m.m_v[e00] = rcos + axis.x()*axis.x()*(1 - rcos);
m.m_v[e10] = axis.z() * rsin + axis.y()*axis.x()*(1 - rcos);
m.m_v[e20] = -axis.y() * rsin + axis.z()*axis.x()*(1 - rcos);
m.m_v[e01] = -axis.z() * rsin + axis.x()*axis.y()*(1 - rcos);
m.m_v[e11] = rcos + axis.y()*axis.y()*(1 - rcos);
m.m_v[e21] = axis.x() * rsin + axis.z()*axis.y()*(1 - rcos);
m.m_v[e02] = axis.y() * rsin + axis.x()*axis.z()*(1 - rcos);
m.m_v[e12] = -axis.x() * rsin + axis.y()*axis.z()*(1 - rcos);
m.m_v[e22] = rcos + axis.z()*axis.z()*(1 - rcos);
return m;
}
}
} //namespace external

143
external/resinsight/LibCore/cvfMatrix4.h vendored Normal file
View File

@@ -0,0 +1,143 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfBase.h"
#include "cvfSystem.h"
#include "cvfVector3.h"
#include "cvfVector4.h"
#include "cvfMatrix3.h"
namespace external {
namespace cvf {
//==================================================================================================
//
// Template matrix class for 4x4 matrices
//
//==================================================================================================
template<typename S>
class Matrix4
{
public:
Matrix4();
Matrix4(const Matrix4& other);
Matrix4(S m00, S m01, S m02, S m03, S m10, S m11, S m12, S m13, S m20, S m21, S m22, S m23, S m30, S m31, S m32, S m33);
explicit Matrix4(const Matrix3<S>& other);
template<typename T>
explicit Matrix4(const Matrix4<T>& other);
inline Matrix4& operator=(const Matrix4& rhs);
bool equals(const Matrix4& mat) const;
bool operator==(const Matrix4& rhs) const;
bool operator!=(const Matrix4& rhs) const;
void multiply(const Matrix4& mat);
const Matrix4 operator*(const Matrix4& rhs) const;
const Vector4<S> operator*(const Vector4<S>& rhs) const;
void setIdentity();
bool isIdentity() const;
void setZero();
bool isZero() const;
inline void setRowCol(int row, int col, S value);
inline S rowCol(int row, int col) const;
inline S& operator()(int row, int col);
inline S operator()(int row, int col) const;
void setRow(int row, const Vector4<S>& vector);
Vector4<S> row(int row) const;
void setCol(int column, const Vector4<S>& vector);
Vector4<S> col(int column) const;
template<typename T>
void set(const Matrix4<T>& mat);
Vector3<S> translation() const;
void setTranslation(const Vector3<S>& trans);
void translatePreMultiply(const Vector3<S>& trans);
void translatePostMultiply(const Vector3<S>& trans);
bool invert();
const Matrix4 getInverted(bool* pInvertible = NULL) const;
S determinant() const;
void transpose();
const Matrix4 getTransposed() const;
void setFromMatrix3(const Matrix3<S>& mat3);
Matrix3<S> toMatrix3() const;
void toMatrix3(Matrix3<S>* mat3) const;
inline const S* ptr() const;
static Matrix4 fromTranslation(const Vector3<S>& trans);
static Matrix4 fromScaling(const Vector3<S>& scale);
static Matrix4 fromRotation(Vector3<S> axis, S angle);
static Matrix4 fromCoordSystemAxes(const Vector3<S>* xAxis, const Vector3<S>* yAxis, const Vector3<S>* zAxis);
public:
static const Matrix4 IDENTITY; ///< Identity matrix
static const Matrix4 ZERO; ///< Matrix with all zeros
private:
// Constants for accessing our internal array using standard matrix notation
static const int e00 = 0; static const int e01 = 4; static const int e02 = 8; static const int e03 = 12;
static const int e10 = 1; static const int e11 = 5; static const int e12 = 9; static const int e13 = 13;
static const int e20 = 2; static const int e21 = 6; static const int e22 = 10; static const int e23 = 14;
static const int e30 = 3; static const int e31 = 7; static const int e32 = 11; static const int e33 = 15;
private:
S m_v[16];
};
template<typename S>
Vector4<S> operator*(const Matrix4<S>& m, const Vector4<S>& v);
typedef Matrix4<float> Mat4f;
typedef Matrix4<double> Mat4d;
}
} //namespace external
#include "cvfMatrix4.inl"

View File

@@ -0,0 +1,938 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
namespace external {
namespace cvf {
//==================================================================================================
///
/// \class cvf::Matrix4
/// \ingroup Core
///
/// Matrices are stored internally as a one dimensional array for performance reasons.
///
/// The internal indices into the 1D array are as follows:
///
/// <PRE>
/// | m00 m01 m02 m03 | | 0 4 8 12 |
/// | m10 m11 m12 m13 | | 1 5 9 13 |
/// | m20 m21 m22 m23 | | 2 6 10 14 |
/// | m30 m31 m32 m33 | | 3 7 11 15 |
/// </PRE>
///
/// This is consistent with the way matrices are represented in %OpenGL.
/// To exemplify, translation values are stored in elements 12,13,14; see figure below
///
/// <PRE>
/// | 1 0 0 Tx |
/// | 0 1 0 Ty |
/// | 0 0 1 Tz |
/// | 0 0 0 1 |
/// </PRE>
///
/// From the %OpenGL red book (page 68) v' = M*v
///
/// <PRE>
/// | X'| | 1 0 0 Tx | | X |
/// | Y'| | 0 1 0 Ty | | Y |
/// | Z'| = | 0 0 1 Tz | * | Z |
/// | 1 | | 0 0 0 1 | | 1 |
/// </PRE>
///
/// Beware when porting code that uses C style double array indexing. In this case, the first
/// index given will corrspond to the columnd, eg M[3][0] = Tx, M[3][1] = Ty, M[3][2] = Tz
///
/// To ease accessing the internal 1D array in implementations, the private eij constants can be used.
/// These are consistent with the normal row column ordering, so that e02 accesses the element
/// in the first row and the third column.
///
//==================================================================================================
template<typename S> Matrix4<S> const Matrix4<S>::IDENTITY;
template<typename S> Matrix4<S> const Matrix4<S>::ZERO(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
//----------------------------------------------------------------------------------------------------
/// Default constructor. Initializes matrix to identity
//----------------------------------------------------------------------------------------------------
template <typename S>
Matrix4<S>::Matrix4()
{
setIdentity();
}
//----------------------------------------------------------------------------------------------------
/// Copy constructor
//----------------------------------------------------------------------------------------------------
template <typename S>
inline Matrix4<S>::Matrix4(const Matrix4& other)
{
System::memcpy(m_v, sizeof(m_v), other.m_v, sizeof(other.m_v));
}
//----------------------------------------------------------------------------------------------------
/// Constructor with explicit initialization of all matrix elements.
///
/// The value of the parameter \a mrc will be placed in row r and column c of the matrix, eg m23
/// goes into row 2, column 3.
//----------------------------------------------------------------------------------------------------
template <typename S>
Matrix4<S>::Matrix4(S m00, S m01, S m02, S m03, S m10, S m11, S m12, S m13, S m20, S m21, S m22, S m23, S m30, S m31, S m32, S m33)
{
m_v[e00] = m00;
m_v[e10] = m10;
m_v[e20] = m20;
m_v[e30] = m30;
m_v[e01] = m01;
m_v[e11] = m11;
m_v[e21] = m21;
m_v[e31] = m31;
m_v[e02] = m02;
m_v[e12] = m12;
m_v[e22] = m22;
m_v[e32] = m32;
m_v[e03] = m03;
m_v[e13] = m13;
m_v[e23] = m23;
m_v[e33] = m33;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename S>
Matrix4<S>::Matrix4(const Matrix3<S>& other)
{
setFromMatrix3(other);
}
//----------------------------------------------------------------------------------------------------
///
//----------------------------------------------------------------------------------------------------
template<typename S>
template<typename T>
Matrix4<S>::Matrix4(const Matrix4<T>& other)
{
m_v[e00] = static_cast<S>(other.rowCol(0, 0));
m_v[e10] = static_cast<S>(other.rowCol(1, 0));
m_v[e20] = static_cast<S>(other.rowCol(2, 0));
m_v[e30] = static_cast<S>(other.rowCol(3, 0));
m_v[e01] = static_cast<S>(other.rowCol(0, 1));
m_v[e11] = static_cast<S>(other.rowCol(1, 1));
m_v[e21] = static_cast<S>(other.rowCol(2, 1));
m_v[e31] = static_cast<S>(other.rowCol(3, 1));
m_v[e02] = static_cast<S>(other.rowCol(0, 2));
m_v[e12] = static_cast<S>(other.rowCol(1, 2));
m_v[e22] = static_cast<S>(other.rowCol(2, 2));
m_v[e32] = static_cast<S>(other.rowCol(3, 2));
m_v[e03] = static_cast<S>(other.rowCol(0, 3));
m_v[e13] = static_cast<S>(other.rowCol(1, 3));
m_v[e23] = static_cast<S>(other.rowCol(2, 3));
m_v[e33] = static_cast<S>(other.rowCol(3, 3));
}
//----------------------------------------------------------------------------------------------------
/// Assignment operator
//----------------------------------------------------------------------------------------------------
template <typename S>
inline Matrix4<S>& Matrix4<S>::operator=(const Matrix4& obj)
{
System::memcpy(m_v, sizeof(m_v), obj.m_v, sizeof(obj.m_v));
return *this;
}
//----------------------------------------------------------------------------------------------------
/// Check if matrices are equal using exact comparisons.
//----------------------------------------------------------------------------------------------------
template<typename S>
bool Matrix4<S>::equals(const Matrix4& mat) const
{
for (int i = 0; i < 16; i++)
{
if (m_v[i] != mat.m_v[i]) return false;
}
return true;
}
//----------------------------------------------------------------------------------------------------
/// Comparison operator. Checks for equality using exact comparisons.
//----------------------------------------------------------------------------------------------------
template <typename S>
bool Matrix4<S>::operator==(const Matrix4& rhs) const
{
return this->equals(rhs);
}
//----------------------------------------------------------------------------------------------------
/// Comparison operator. Checks for not equal using exact comparisons.
//----------------------------------------------------------------------------------------------------
template <typename S>
bool Matrix4<S>::operator!=(const Matrix4& rhs) const
{
int i;
for (i = 0; i < 16; i++)
{
if (m_v[i] != rhs.m_v[i]) return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
/// Multiplies this matrix M with the matrix \a mat, M = M*mat
//--------------------------------------------------------------------------------------------------
template<typename S>
void Matrix4<S>::multiply(const Matrix4& mat)
{
*this = (*this)*mat;
}
//----------------------------------------------------------------------------------------------------
///
//----------------------------------------------------------------------------------------------------
template <typename S>
const Matrix4<S> Matrix4<S>::operator*(const Matrix4& rhs) const
{
Matrix4 m;
m.m_v[e00] = m_v[e00] * rhs.m_v[e00] + m_v[e01] * rhs.m_v[e10] + m_v[e02] * rhs.m_v[e20] + m_v[e03] * rhs.m_v[e30];
m.m_v[e01] = m_v[e00] * rhs.m_v[e01] + m_v[e01] * rhs.m_v[e11] + m_v[e02] * rhs.m_v[e21] + m_v[e03] * rhs.m_v[e31];
m.m_v[e02] = m_v[e00] * rhs.m_v[e02] + m_v[e01] * rhs.m_v[e12] + m_v[e02] * rhs.m_v[e22] + m_v[e03] * rhs.m_v[e32];
m.m_v[e03] = m_v[e00] * rhs.m_v[e03] + m_v[e01] * rhs.m_v[e13] + m_v[e02] * rhs.m_v[e23] + m_v[e03] * rhs.m_v[e33];
m.m_v[e10] = m_v[e10] * rhs.m_v[e00] + m_v[e11] * rhs.m_v[e10] + m_v[e12] * rhs.m_v[e20] + m_v[e13] * rhs.m_v[e30];
m.m_v[e11] = m_v[e10] * rhs.m_v[e01] + m_v[e11] * rhs.m_v[e11] + m_v[e12] * rhs.m_v[e21] + m_v[e13] * rhs.m_v[e31];
m.m_v[e12] = m_v[e10] * rhs.m_v[e02] + m_v[e11] * rhs.m_v[e12] + m_v[e12] * rhs.m_v[e22] + m_v[e13] * rhs.m_v[e32];
m.m_v[e13] = m_v[e10] * rhs.m_v[e03] + m_v[e11] * rhs.m_v[e13] + m_v[e12] * rhs.m_v[e23] + m_v[e13] * rhs.m_v[e33];
m.m_v[e20] = m_v[e20] * rhs.m_v[e00] + m_v[e21] * rhs.m_v[e10] + m_v[e22] * rhs.m_v[e20] + m_v[e23] * rhs.m_v[e30];
m.m_v[e21] = m_v[e20] * rhs.m_v[e01] + m_v[e21] * rhs.m_v[e11] + m_v[e22] * rhs.m_v[e21] + m_v[e23] * rhs.m_v[e31];
m.m_v[e22] = m_v[e20] * rhs.m_v[e02] + m_v[e21] * rhs.m_v[e12] + m_v[e22] * rhs.m_v[e22] + m_v[e23] * rhs.m_v[e32];
m.m_v[e23] = m_v[e20] * rhs.m_v[e03] + m_v[e21] * rhs.m_v[e13] + m_v[e22] * rhs.m_v[e23] + m_v[e23] * rhs.m_v[e33];
m.m_v[e30] = m_v[e30] * rhs.m_v[e00] + m_v[e31] * rhs.m_v[e10] + m_v[e32] * rhs.m_v[e20] + m_v[e33] * rhs.m_v[e30];
m.m_v[e31] = m_v[e30] * rhs.m_v[e01] + m_v[e31] * rhs.m_v[e11] + m_v[e32] * rhs.m_v[e21] + m_v[e33] * rhs.m_v[e31];
m.m_v[e32] = m_v[e30] * rhs.m_v[e02] + m_v[e31] * rhs.m_v[e12] + m_v[e32] * rhs.m_v[e22] + m_v[e33] * rhs.m_v[e32];
m.m_v[e33] = m_v[e30] * rhs.m_v[e03] + m_v[e31] * rhs.m_v[e13] + m_v[e32] * rhs.m_v[e23] + m_v[e33] * rhs.m_v[e33];
return m;
}
//----------------------------------------------------------------------------------------------------
///
//----------------------------------------------------------------------------------------------------
template <typename S>
const Vector4<S> Matrix4<S>::operator*(const Vector4<S>& rhs) const
{
return Vector4<S>(m_v[e00]*rhs.x() + m_v[e01]*rhs.y() + m_v[e02]*rhs.z() + m_v[e03]*rhs.w(),
m_v[e10]*rhs.x() + m_v[e11]*rhs.y() + m_v[e12]*rhs.z() + m_v[e13]*rhs.w(),
m_v[e20]*rhs.x() + m_v[e21]*rhs.y() + m_v[e22]*rhs.z() + m_v[e23]*rhs.w(),
m_v[e30]*rhs.x() + m_v[e31]*rhs.y() + m_v[e32]*rhs.z() + m_v[e33]*rhs.w());
}
//----------------------------------------------------------------------------------------------------
/// Sets this matrix to identity
//----------------------------------------------------------------------------------------------------
template <typename S>
void Matrix4<S>::setIdentity()
{
m_v[0] = 1;
m_v[1] = 0;
m_v[2] = 0;
m_v[3] = 0;
m_v[4] = 0;
m_v[5] = 1;
m_v[6] = 0;
m_v[7] = 0;
m_v[8] = 0;
m_v[9] = 0;
m_v[10] = 1;
m_v[11] = 0;
m_v[12] = 0;
m_v[13] = 0;
m_v[14] = 0;
m_v[15] = 1;
}
//----------------------------------------------------------------------------------------------------
/// Check if this matrix is identity using exact comparisons
//----------------------------------------------------------------------------------------------------
template <typename S>
bool Matrix4<S>::isIdentity() const
{
if (m_v[0] != 1) return false;
if (m_v[1] != 0) return false;
if (m_v[2] != 0) return false;
if (m_v[3] != 0) return false;
if (m_v[4] != 0) return false;
if (m_v[5] != 1) return false;
if (m_v[6] != 0) return false;
if (m_v[7] != 0) return false;
if (m_v[8] != 0) return false;
if (m_v[9] != 0) return false;
if (m_v[10] != 1) return false;
if (m_v[11] != 0) return false;
if (m_v[12] != 0) return false;
if (m_v[13] != 0) return false;
if (m_v[14] != 0) return false;
if (m_v[15] != 1) return false;
return true;
}
//----------------------------------------------------------------------------------------------------
/// Set all matrix elements to 0
//----------------------------------------------------------------------------------------------------
template <typename S>
void Matrix4<S>::setZero()
{
m_v[0] = 0;
m_v[1] = 0;
m_v[2] = 0;
m_v[3] = 0;
m_v[4] = 0;
m_v[5] = 0;
m_v[6] = 0;
m_v[7] = 0;
m_v[8] = 0;
m_v[9] = 0;
m_v[10] = 0;
m_v[11] = 0;
m_v[12] = 0;
m_v[13] = 0;
m_v[14] = 0;
m_v[15] = 0;
}
//----------------------------------------------------------------------------------------------------
/// Returns true if all elements of the matrix are 0. Uses exact comparison.
//----------------------------------------------------------------------------------------------------
template <typename S>
bool Matrix4<S>::isZero() const
{
if (m_v[0] != 0) return false;
if (m_v[1] != 0) return false;
if (m_v[2] != 0) return false;
if (m_v[3] != 0) return false;
if (m_v[4] != 0) return false;
if (m_v[5] != 0) return false;
if (m_v[6] != 0) return false;
if (m_v[7] != 0) return false;
if (m_v[8] != 0) return false;
if (m_v[9] != 0) return false;
if (m_v[10] != 0) return false;
if (m_v[11] != 0) return false;
if (m_v[12] != 0) return false;
if (m_v[13] != 0) return false;
if (m_v[14] != 0) return false;
if (m_v[15] != 0) return false;
return true;
}
//----------------------------------------------------------------------------------------------------
/// Set the matrix element at the specified row and column
//----------------------------------------------------------------------------------------------------
template <typename S>
inline void Matrix4<S>::setRowCol(int row, int col, S value)
{
CVF_TIGHT_ASSERT(row >= 0 && row < 4);
CVF_TIGHT_ASSERT(col >= 0 && col < 4);
m_v[4*col + row] = value;
}
//----------------------------------------------------------------------------------------------------
/// Get the matrix element at the specified row and column
//----------------------------------------------------------------------------------------------------
template <typename S>
inline S Matrix4<S>::rowCol(int row, int col) const
{
CVF_TIGHT_ASSERT(row >= 0 && row < 4);
CVF_TIGHT_ASSERT(col >= 0 && col < 4);
return m_v[4*col + row];
}
//--------------------------------------------------------------------------------------------------
/// Get modifiable reference to the the matrix element at the specified row and column
//--------------------------------------------------------------------------------------------------
template <typename S>
inline S& Matrix4<S>::operator()(int row, int col)
{
CVF_TIGHT_ASSERT(row >= 0 && row < 4);
CVF_TIGHT_ASSERT(col >= 0 && col < 4);
return m_v[4*col + row];
}
//--------------------------------------------------------------------------------------------------
/// Get the matrix element at the specified row and column
//--------------------------------------------------------------------------------------------------
template <typename S>
inline S Matrix4<S>::operator()(int row, int col) const
{
CVF_TIGHT_ASSERT(row >= 0 && row < 4);
CVF_TIGHT_ASSERT(col >= 0 && col < 4);
return m_v[4*col + row];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename S>
void Matrix4<S>::setRow(int row, const Vector4<S>& vector)
{
CVF_TIGHT_ASSERT(row >= 0 && row < 4);
m_v[row] = vector.x();
m_v[row + 4] = vector.y();
m_v[row + 8] = vector.z();
m_v[row + 12] = vector.w();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename S>
Vector4<S> Matrix4<S>::row(int row) const
{
CVF_TIGHT_ASSERT(row >= 0 && row < 4);
return Vector4<S>(m_v[row], m_v[row + 4], m_v[row + 8], m_v[row + 12]);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename S>
void Matrix4<S>::setCol(int column, const Vector4<S>& vector)
{
CVF_TIGHT_ASSERT(column >= 0 && column < 4);
m_v[4*column] = vector.x();
m_v[4*column + 1] = vector.y();
m_v[4*column + 2] = vector.z();
m_v[4*column + 3] = vector.w();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename S>
Vector4<S> Matrix4<S>::col(int column) const
{
CVF_TIGHT_ASSERT(column >= 0 && column < 4);
return Vector4<S>(m_v[4*column], m_v[4*column + 1], m_v[4*column + 2], m_v[4*column + 3]);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename S>
template<typename T>
void Matrix4<S>::set(const Matrix4<T>& mat)
{
const T* matPtr = mat.ptr();
for (int i = 0; i < 16; i++)
{
m_v[i] = static_cast<S>(matPtr[i]);
}
}
//----------------------------------------------------------------------------------------------------
/// Extracts the translation part of the transformation matrix
//----------------------------------------------------------------------------------------------------
template <typename S>
Vector3<S> Matrix4<S>::translation() const
{
return Vector3<S>(m_v[e03], m_v[e13], m_v[e23]);
}
//----------------------------------------------------------------------------------------------------
/// Sets the translation transformation part of the matrix
//----------------------------------------------------------------------------------------------------
template <typename S>
void Matrix4<S>::setTranslation(const Vector3<S>& trans)
{
m_v[e03] = trans.x();
m_v[e13] = trans.y();
m_v[e23] = trans.z();
}
//----------------------------------------------------------------------------------------------------
/// Adds translation by pre-multiplying the matrix with a matrix containing the specified translation
///
/// Adds translation to this (transformation) matrix by pre-multiplying the current matrix M with
/// a matrix T containing only the specified translation.
/// Calling this function has the effect of doing the multiplication M' = T x M
///
/// \param trans Specifies the X, Y and Z components of the translation.
//----------------------------------------------------------------------------------------------------
template <typename S>
void Matrix4<S>::translatePreMultiply(const Vector3<S>& trans)
{
m_v[e00] += trans.x()*m_v[e30];
m_v[e01] += trans.x()*m_v[e31];
m_v[e02] += trans.x()*m_v[e32];
m_v[e03] += trans.x()*m_v[e33];
m_v[e10] += trans.y()*m_v[e30];
m_v[e11] += trans.y()*m_v[e31];
m_v[e12] += trans.y()*m_v[e32];
m_v[e13] += trans.y()*m_v[e33];
m_v[e20] += trans.z()*m_v[e30];
m_v[e21] += trans.z()*m_v[e31];
m_v[e22] += trans.z()*m_v[e32];
m_v[e23] += trans.z()*m_v[e33];
}
//----------------------------------------------------------------------------------------------------
/// Adds translation by post-multiplying the matrix with a matrix containing the specified translation
///
/// Adds translation to this (transformation) matrix by post-multiplying the current matrix M with
/// a matrix T containing only the specified translation.
/// Calling this function has the effect of doing the multiplication M' = M x T
///
/// \param trans Specifies the X, Y and Z coordinates of the translation.
//----------------------------------------------------------------------------------------------------
template <typename S>
void Matrix4<S>::translatePostMultiply(const Vector3<S>& trans)
{
m_v[e03] += trans.x()*m_v[e00] + trans.y()*m_v[e01] + trans.z()*m_v[e02];
m_v[e13] += trans.x()*m_v[e10] + trans.y()*m_v[e11] + trans.z()*m_v[e12];
m_v[e23] += trans.x()*m_v[e20] + trans.y()*m_v[e21] + trans.z()*m_v[e22];
m_v[e33] += trans.x()*m_v[e30] + trans.y()*m_v[e31] + trans.z()*m_v[e32];
}
//----------------------------------------------------------------------------------------------------
///
//----------------------------------------------------------------------------------------------------
template <typename S>
bool Matrix4<S>::invert()
{
// Use double internally here
const double m00 = static_cast<double>(m_v[e00]);
const double m10 = static_cast<double>(m_v[e10]);
const double m20 = static_cast<double>(m_v[e20]);
const double m30 = static_cast<double>(m_v[e30]);
const double m01 = static_cast<double>(m_v[e01]);
const double m11 = static_cast<double>(m_v[e11]);
const double m21 = static_cast<double>(m_v[e21]);
const double m31 = static_cast<double>(m_v[e31]);
const double m02 = static_cast<double>(m_v[e02]);
const double m12 = static_cast<double>(m_v[e12]);
const double m22 = static_cast<double>(m_v[e22]);
const double m32 = static_cast<double>(m_v[e32]);
const double m03 = static_cast<double>(m_v[e03]);
const double m13 = static_cast<double>(m_v[e13]);
const double m23 = static_cast<double>(m_v[e23]);
const double m33 = static_cast<double>(m_v[e33]);
const double s0 = m00 * m11 - m01 * m10;
const double s1 = m00 * m12 - m02 * m10;
const double s2 = m00 * m13 - m03 * m10;
const double s3 = m01 * m12 - m02 * m11;
const double s4 = m01 * m13 - m03 * m11;
const double s5 = m02 * m13 - m03 * m12;
const double c5 = m22 * m33 - m23 * m32;
const double c4 = m21 * m33 - m23 * m31;
const double c3 = m21 * m32 - m22 * m31;
const double c2 = m20 * m33 - m23 * m30;
const double c1 = m20 * m32 - m22 * m30;
const double c0 = m20 * m31 - m21 * m30;
const double det = s0*c5 - s1*c4 + s2*c3 + s3*c2 - s4*c1 + s5*c0;
if (Math::abs(det) > std::numeric_limits<double>::epsilon())
{
const double invDet = 1/det;
m_v[e00] = static_cast<S>( ( m11 * c5 - m12 * c4 + m13 * c3 ) * invDet );
m_v[e10] = static_cast<S>( ( - m10 * c5 + m12 * c2 - m13 * c1 ) * invDet );
m_v[e20] = static_cast<S>( ( m10 * c4 - m11 * c2 + m13 * c0 ) * invDet );
m_v[e30] = static_cast<S>( ( - m10 * c3 + m11 * c1 - m12 * c0 ) * invDet );
m_v[e01] = static_cast<S>( ( - m01 * c5 + m02 * c4 - m03 * c3 ) * invDet );
m_v[e11] = static_cast<S>( ( m00 * c5 - m02 * c2 + m03 * c1 ) * invDet );
m_v[e21] = static_cast<S>( ( - m00 * c4 + m01 * c2 - m03 * c0 ) * invDet );
m_v[e31] = static_cast<S>( ( m00 * c3 - m01 * c1 + m02 * c0 ) * invDet );
m_v[e02] = static_cast<S>( ( m31 * s5 - m32 * s4 + m33 * s3 ) * invDet );
m_v[e12] = static_cast<S>( ( - m30 * s5 + m32 * s2 - m33 * s1 ) * invDet );
m_v[e22] = static_cast<S>( ( m30 * s4 - m31 * s2 + m33 * s0 ) * invDet );
m_v[e32] = static_cast<S>( ( - m30 * s3 + m31 * s1 - m32 * s0 ) * invDet );
m_v[e03] = static_cast<S>( ( - m21 * s5 + m22 * s4 - m23 * s3 ) * invDet );
m_v[e13] = static_cast<S>( ( m20 * s5 - m22 * s2 + m23 * s1 ) * invDet );
m_v[e23] = static_cast<S>( ( - m20 * s4 + m21 * s2 - m23 * s0 ) * invDet );
m_v[e33] = static_cast<S>( ( m20 * s3 - m21 * s1 + m22 * s0 ) * invDet );
return true;
}
else
{
return false;
}
}
//----------------------------------------------------------------------------------------------------
///
//----------------------------------------------------------------------------------------------------
template <typename S>
const Matrix4<S> Matrix4<S>::getInverted(bool* pInvertible) const
{
Matrix4 m(*this);
if (m.invert())
{
if (pInvertible) *pInvertible = true;
}
else
{
if (pInvertible) *pInvertible = false;
m.setZero();
}
return m;
}
//----------------------------------------------------------------------------------------------------
///
//----------------------------------------------------------------------------------------------------
template <typename S>
S Matrix4<S>::determinant() const
{
// Consider using double precision for the intermediate calculations here
// Haven't seen any direct need for it yet, but good old GLview API did that
const S a0 = m_v[e00]*m_v[e11] - m_v[e01]*m_v[e10];
const S a1 = m_v[e00]*m_v[e12] - m_v[e02]*m_v[e10];
const S a2 = m_v[e00]*m_v[e13] - m_v[e03]*m_v[e10];
const S a3 = m_v[e01]*m_v[e12] - m_v[e02]*m_v[e11];
const S a4 = m_v[e01]*m_v[e13] - m_v[e03]*m_v[e11];
const S a5 = m_v[e02]*m_v[e13] - m_v[e03]*m_v[e12];
const S b0 = m_v[e20]*m_v[e31] - m_v[e21]*m_v[e30];
const S b1 = m_v[e20]*m_v[e32] - m_v[e22]*m_v[e30];
const S b2 = m_v[e20]*m_v[e33] - m_v[e23]*m_v[e30];
const S b3 = m_v[e21]*m_v[e32] - m_v[e22]*m_v[e31];
const S b4 = m_v[e21]*m_v[e33] - m_v[e23]*m_v[e31];
const S b5 = m_v[e22]*m_v[e33] - m_v[e23]*m_v[e32];
return (a0*b5 - a1*b4 + a2*b3 + a3*b2 - a4*b1 + a5*b0);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename S>
void Matrix4<S>::transpose()
{
S tmp;
int i, j;
for (i = 0; i < 4; i++)
{
for (j = i + 1; j < 4; j++)
{
tmp = m_v[j + 4*i];
m_v[j + 4*i] = m_v[4*j + i];
m_v[4*j + i] = tmp;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename S>
const Matrix4<S> Matrix4<S>::getTransposed() const
{
Matrix4 m(*this);
m.transpose();
return m;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename S>
void Matrix4<S>::setFromMatrix3(const Matrix3<S>& mat3)
{
m_v[e00] = mat3.rowCol(0, 0);
m_v[e01] = mat3.rowCol(0, 1);
m_v[e02] = mat3.rowCol(0, 2);
m_v[e03] = 0;
m_v[e10] = mat3.rowCol(1, 0);
m_v[e11] = mat3.rowCol(1, 1);
m_v[e12] = mat3.rowCol(1, 2);
m_v[e13] = 0;
m_v[e20] = mat3.rowCol(2, 0);
m_v[e21] = mat3.rowCol(2, 1);
m_v[e22] = mat3.rowCol(2, 2);
m_v[e23] = 0;
m_v[e30] = 0;
m_v[e31] = 0;
m_v[e32] = 0;
m_v[e33] = 1;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename S>
Matrix3<S> Matrix4<S>::toMatrix3() const
{
return Matrix3<S>(m_v[e00], m_v[e01], m_v[e02],
m_v[e10], m_v[e11], m_v[e12],
m_v[e20], m_v[e21], m_v[e22]);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename S>
void Matrix4<S>::toMatrix3(Matrix3<S>* mat3) const
{
CVF_ASSERT(mat3);
mat3->setRowCol(0, 0, m_v[e00]);
mat3->setRowCol(0, 1, m_v[e01]);
mat3->setRowCol(0, 2, m_v[e02]);
mat3->setRowCol(1, 0, m_v[e10]);
mat3->setRowCol(1, 1, m_v[e11]);
mat3->setRowCol(1, 2, m_v[e12]);
mat3->setRowCol(2, 0, m_v[e20]);
mat3->setRowCol(2, 1, m_v[e21]);
mat3->setRowCol(2, 2, m_v[e22]);
}
//----------------------------------------------------------------------------------------------------
///
//----------------------------------------------------------------------------------------------------
template <typename S>
const S* Matrix4<S>::ptr() const
{
return m_v;
}
//----------------------------------------------------------------------------------------------------
/// Static member function that creates a transformation matrix containing only translation
//----------------------------------------------------------------------------------------------------
template <typename S>
Matrix4<S> Matrix4<S>::fromTranslation(const Vector3<S>& trans)
{
return Matrix4(1, 0, 0, trans.x(),
0, 1, 0, trans.y(),
0, 0, 1, trans.z(),
0, 0, 0, 1);
}
//----------------------------------------------------------------------------------------------------
/// Static member function that creates a transformation matrix containing only scaling
//----------------------------------------------------------------------------------------------------
template <typename S>
Matrix4<S> Matrix4<S>::fromScaling(const Vector3<S>& scale)
{
return Matrix4(scale.x(), 0, 0, 0,
0, scale.y(), 0, 0,
0, 0, scale.z(), 0,
0, 0, 0, 1);
}
//----------------------------------------------------------------------------------------------------
///
//----------------------------------------------------------------------------------------------------
template <typename S>
Matrix4<S> Matrix4<S>::fromRotation(Vector3<S> axis, S angle)
{
axis.normalize();
S rcos = Math::cos(angle);
S rsin = Math::sin(angle);
Matrix4 m;
m.m_v[e00] = rcos + axis.x()*axis.x()*(1 - rcos);
m.m_v[e10] = axis.z() * rsin + axis.y()*axis.x()*(1 - rcos);
m.m_v[e20] = -axis.y() * rsin + axis.z()*axis.x()*(1 - rcos);
m.m_v[e01] = -axis.z() * rsin + axis.x()*axis.y()*(1 - rcos);
m.m_v[e11] = rcos + axis.y()*axis.y()*(1 - rcos);
m.m_v[e21] = axis.x() * rsin + axis.z()*axis.y()*(1 - rcos);
m.m_v[e02] = axis.y() * rsin + axis.x()*axis.z()*(1 - rcos);
m.m_v[e12] = -axis.x() * rsin + axis.y()*axis.z()*(1 - rcos);
m.m_v[e22] = rcos + axis.z()*axis.z()*(1 - rcos);
return m;
}
//----------------------------------------------------------------------------------------------------
/// Create a rotation matrix that will align the global X, Y and Z axes with the specified axes.
///
/// Note that at least one axis must be specified and all specified axes must be normalized.
/// If two or three axes are specified, they must be orthogonal to each other.
///
/// \param xAxis Orientation of x axis
/// \param yAxis Orientation of y axis
/// \param zAxis Orientation of z axis
//----------------------------------------------------------------------------------------------------
template <typename S>
Matrix4<S> Matrix4<S>::fromCoordSystemAxes(const Vector3<S>* xAxis, const Vector3<S>* yAxis, const Vector3<S>* zAxis)
{
Vector3<S> x(0, 0, 0);
Vector3<S> y(0, 0, 0);
Vector3<S> z(0, 0, 0);
if (xAxis && yAxis && zAxis)
{
x = *xAxis;
y = *yAxis;
z = *zAxis;
}
else if (xAxis && yAxis)
{
x = *xAxis;
y = *yAxis;
z = x ^ y;
}
else if (xAxis && zAxis)
{
x = *xAxis;
z = *zAxis;
y = z ^ x;
}
else if (yAxis && zAxis)
{
y = *yAxis;
z = *zAxis;
x = y ^ z;
}
else if (xAxis)
{
xAxis->createOrthonormalBasis(0, &x, &y, &z);
}
else if (yAxis)
{
yAxis->createOrthonormalBasis(1, &x, &y, &z);
}
else if (zAxis)
{
zAxis->createOrthonormalBasis(2, &x, &y, &z);
}
else
{
CVF_FAIL_MSG("Must specify at least one axis");
}
Matrix4 m;
m.setIdentity();
m.setCol(0, Vector4<S>(x, 0));
m.setCol(1, Vector4<S>(y, 0));
m.setCol(2, Vector4<S>(z, 0));
return m;
}
//--------------------------------------------------------------------------------------------------
/// Post multiplication: matrix * column vector
///
/// v' = M*v
//--------------------------------------------------------------------------------------------------
template<typename S>
cvf::Vector4<S> operator*(const cvf::Matrix4<S>& m, const cvf::Vector4<S>& v)
{
cvf::Vector4<S> vec(
v.x()*m.rowCol(0,0) + v.y()*m.rowCol(0,1) + v.z()*m.rowCol(0,2) + v.w()*m.rowCol(0,3),
v.x()*m.rowCol(1,0) + v.y()*m.rowCol(1,1) + v.z()*m.rowCol(1,2) + v.w()*m.rowCol(1,3),
v.x()*m.rowCol(2,0) + v.y()*m.rowCol(2,1) + v.z()*m.rowCol(2,2) + v.w()*m.rowCol(2,3),
v.x()*m.rowCol(3,0) + v.y()*m.rowCol(3,1) + v.z()*m.rowCol(3,2) + v.w()*m.rowCol(3,3)
);
return vec;
}
}
} //namespace external

View File

@@ -0,0 +1,124 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfTrace.h"
#include <map>
namespace external {
namespace cvf {
//==================================================================================================
///
/// \class cvf::Object
/// \ingroup Core
///
/// Base class for all reference counted objects
///
/// Very often used in conjunction with the ref<> class (smart pointer) which wraps the
/// reference counting. Thus direct use of addRef() and release() is seldom needed.
///
/// The copy constructor and assignment operator is disabled by default so you will get compiler errors
/// instead of unexpected behavior if you pass objects (that derive from Object) by value or assign objects.
//==================================================================================================
//--------------------------------------------------------------------------------------------------
/// Get the set of currently active/allocated object instances
///
/// Note that unless the define CVF_TRACK_ACTIVE_OBJECT_INSTANCES is set to 1, this function
/// will always return an empty set.
//--------------------------------------------------------------------------------------------------
std::set<Object*>* Object::activeObjectInstances()
{
static std::set<Object*>* sl_activeObjects = NULL;
if (!sl_activeObjects)
{
sl_activeObjects = new std::set<Object*>;
}
return sl_activeObjects;
}
//--------------------------------------------------------------------------------------------------
/// Dump list of active object instances using Trace class
///
/// Currently this function utilizes RTTI and typeid to get the class names.
/// Data on active instances will only be present if CVF_TRACK_ACTIVE_OBJECT_INSTANCES is defined
//--------------------------------------------------------------------------------------------------
void Object::dumpActiveObjectInstances()
{
Trace::show("Dumping active object instances:");
std::set<Object*>* objInstances = Object::activeObjectInstances();
size_t numInstances = objInstances->size();
#if ((CVF_TRACK_ACTIVE_OBJECT_INSTANCES >= 1 && defined(_DEBUG)) || CVF_TRACK_ACTIVE_OBJECT_INSTANCES == 2)
// Use a map to count the number of occurences of each class
std::map<std::string, int> occurences;
std::set<Object*>::iterator it;
for (it = objInstances->begin(); it != objInstances->end(); ++it)
{
Object* obj = *it;
const type_info& typeInfo = typeid(*obj);
const char* className = typeInfo.name();
if (occurences.find(className) != occurences.end())
{
occurences[className] += 1;
}
else
{
occurences[className] = 1;
}
}
if (occurences.size() > 0)
{
std::map<std::string, int>::iterator it;
for (it = occurences.begin(); it != occurences.end(); ++it)
{
Trace::show("%6d instances of: %s", it->second, it->first.data());
}
}
#else
Trace::show(" Tracking of active instances not enabled!");
#endif
Trace::show("Total number of active object instances: %d", numInstances);
}
} // namespace cvf
} //namespace external

200
external/resinsight/LibCore/cvfObject.h vendored Normal file
View File

@@ -0,0 +1,200 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfBase.h"
#include "cvfSystem.h"
#include <set>
#include "cvfAtomicCounter.h"
namespace external {
#if !defined(CVF_ATOMIC_COUNTER_CLASS_EXISTS) && !defined(CVF_USE_NON_THREADSAFE_REFERENCE_COUNT)
#error No support for atomics. Define CVF_USE_NON_THREADSAFE_REFERENCE_COUNT to be able to compile
#endif
namespace cvf {
//==================================================================================================
//
// Base class for all reference counted objects
//
//==================================================================================================
class Object
{
public:
inline Object();
inline virtual ~Object();
inline int addRef() const;
inline int release() const;
inline int refCount() const;
// Helpers for debugging, see the CVF_TRACK_ACTIVE_OBJECT_INSTANCES define
static std::set<Object*>* activeObjectInstances();
static void dumpActiveObjectInstances();
private:
#if defined(CVF_USE_NON_THREADSAFE_REFERENCE_COUNT)
mutable int m_refCount;
#elif defined(CVF_ATOMIC_COUNTER_CLASS_EXISTS)
mutable AtomicCounter m_refCount;
#else
#error No support for atomics. Define CVF_USE_NON_THREADSAFE_REFERENCE_COUNT to be able to compile
#endif
CVF_DISABLE_COPY_AND_ASSIGN(Object);
};
//==================================================================================================
//
// Smart pointer class
//
//==================================================================================================
template <typename T>
class ref
{
public:
ref(T* object = NULL);
ref(const ref& other);
template<typename T2> ref(const ref<T2>& other);
~ref();
ref& operator=(T* rhs);
ref& operator=(ref rhs);
template<typename T2> ref& operator=(const ref<T2>& rhs);
inline T* operator->();
inline const T* operator->() const;
inline T& operator*();
inline const T& operator*() const;
inline T* p();
inline const T* p() const;
inline bool isNull() const;
inline bool notNull() const;
bool operator<(const ref& rhs) const;
void swap(ref& other);
private:
T* m_object;
};
/// \relates cvf::ref
/// @{
template<typename T1, typename T2> inline bool operator==(const ref<T1>& a, const ref<T2>& b) { return a.p() == b.p(); } ///< Returns true if the internal pointers of refs \a a and \a b are equal.
template<typename T1, typename T2> inline bool operator!=(const ref<T1>& a, const ref<T2>& b) { return a.p() != b.p(); } ///< Returns true if the internal pointers of refs \a a and \a b are different.
template<typename T1, typename T2> inline bool operator==(const ref<T1>& a, T2* b) { return a.p() == b; } ///< Returns true if the internal pointer of ref \a a is equal to the naked pointer \a b.
template<typename T1, typename T2> inline bool operator!=(const ref<T1>& a, T2* b) { return a.p() != b; } ///< Returns true if the internal pointer of ref \a a is different from the naked pointer \a b.
template<typename T1, typename T2> inline bool operator==(T1* a, const ref<T2>& b) { return a == b.p(); } ///< Returns true if the naked pointer \a a is equal to the internal pointer of ref \a b.
template<typename T1, typename T2> inline bool operator!=(T1* a, const ref<T2>& b) { return a != b.p(); } ///< Returns true if the naked pointer \a a is different from the internal pointer of ref \a b.
/// Swap contents of \a a and \a b. Matches signature of std::swap().
/// \todo Need to investigate which STL algorithms actually utilize the swap() function.
template<typename T> inline void swap(ref<T>& a, ref<T>& b) { a.swap(b); }
/// @}
//==================================================================================================
//
// Smart pointer class for const pointers
//
//==================================================================================================
template <typename T>
class cref
{
public:
cref(const T* object = NULL);
cref(const cref& other);
template<typename T2> cref(const cref<T2>& other);
~cref();
cref& operator=(const T* rhs);
cref& operator=(cref rhs);
template<typename T2> cref& operator=(const cref<T2>& rhs);
inline const T* operator->() const;
inline const T& operator*() const;
inline const T* p() const;
inline bool isNull() const;
inline bool notNull() const;
bool operator<(const cref& rhs) const;
void swap(cref& other);
private:
const T* m_object;
};
/// \relates cvf::cref
/// @{
template<typename T1, typename T2> inline bool operator==(const cref<T1>& a, const cref<T2>& b) { return a.p() == b.p(); } ///< Returns true if the internal pointers of refs \a a and \a b are equal.
template<typename T1, typename T2> inline bool operator!=(const cref<T1>& a, const cref<T2>& b) { return a.p() != b.p(); } ///< Returns true if the internal pointers of refs \a a and \a b are different.
template<typename T1, typename T2> inline bool operator==(const cref<T1>& a, T2* b) { return a.p() == b; } ///< Returns true if the internal pointer of ref \a a is equal to the naked pointer \a b.
template<typename T1, typename T2> inline bool operator!=(const cref<T1>& a, T2* b) { return a.p() != b; } ///< Returns true if the internal pointer of ref \a a is different from the naked pointer \a b.
template<typename T1, typename T2> inline bool operator==(T1* a, const cref<T2>& b) { return a == b.p(); } ///< Returns true if the naked pointer \a a is equal to the internal pointer of ref \a b.
template<typename T1, typename T2> inline bool operator!=(T1* a, const cref<T2>& b) { return a != b.p(); } ///< Returns true if the naked pointer \a a is different from the internal pointer of ref \a b.
//==================================================================================================
//
// Creation of smart pointers.
//
//==================================================================================================
template<typename T, class... Args>
ref<T> make_ref(Args&&... args);
template<typename T, class... Args>
cref<T> make_cref(Args&&... args);
/// @}
}
} //namespace external
#include "cvfObject.inl"

View File

@@ -0,0 +1,592 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
namespace external {
namespace cvf {
//--------------------------------------------------------------------------------------------------
/// Constructor. Set the ref count to zero
//--------------------------------------------------------------------------------------------------
inline Object::Object()
: m_refCount(0)
{
#if ((CVF_TRACK_ACTIVE_OBJECT_INSTANCES >= 1 && defined(_DEBUG)) || CVF_TRACK_ACTIVE_OBJECT_INSTANCES == 2)
activeObjectInstances()->insert(this);
#endif
}
//--------------------------------------------------------------------------------------------------
/// Destructor. Asserts that the ref count is zero.
//--------------------------------------------------------------------------------------------------
inline Object::~Object()
{
CVF_ASSERT(m_refCount == 0);
#if ((CVF_TRACK_ACTIVE_OBJECT_INSTANCES >= 1 && defined(_DEBUG)) || CVF_TRACK_ACTIVE_OBJECT_INSTANCES == 2)
activeObjectInstances()->erase(this);
#endif
}
//--------------------------------------------------------------------------------------------------
/// Increments reference count.
///
/// \return The new reference count.
//--------------------------------------------------------------------------------------------------
inline int Object::addRef() const
{
CVF_TIGHT_ASSERT(this);
return ++m_refCount;
}
//--------------------------------------------------------------------------------------------------
/// Decrements the reference count. Returns the new reference count.
///
/// \return The new reference count.
///
/// If the new reference count is zero, the object (this) is deleted.\n
//--------------------------------------------------------------------------------------------------
inline int Object::release() const
{
CVF_TIGHT_ASSERT(m_refCount > 0);
if (--m_refCount == 0)
{
delete this;
return 0;
}
else
{
return m_refCount;
}
}
//--------------------------------------------------------------------------------------------------
/// Returns the current reference count
//--------------------------------------------------------------------------------------------------
inline int Object::refCount() const
{
CVF_TIGHT_ASSERT(this);
return m_refCount;
}
//==================================================================================================
///
/// \class cvf::ref
/// \ingroup Core
///
/// Smart pointer class used for handling reference counted objects (that derive from Object).
///
/// The ref<T> class encapsulates reference counting by calling Object::addRef() and Object::release()
/// on the internally stored object pointer.
///
/// \internal Inspired by boost's intrusive_ptr class.
//==================================================================================================
//--------------------------------------------------------------------------------------------------
/// Constructor from naked pointer
///
/// Will call addRef() on the passed object.
//--------------------------------------------------------------------------------------------------
template<typename T>
ref<T>::ref(T* object)
{
if (object)
{
object->addRef();
m_object = object;
}
else
{
m_object = NULL;
}
}
//--------------------------------------------------------------------------------------------------
/// Copy constructor
///
/// Copies the internal pointer from the passed ref object and calls addRef() on the object.
//--------------------------------------------------------------------------------------------------
template<typename T>
ref<T>::ref(const ref& other)
{
if (other.m_object)
{
other.m_object->addRef();
m_object = other.m_object;
}
else
{
m_object = NULL;
}
}
//--------------------------------------------------------------------------------------------------
/// Construct from related.
///
/// Copies the internal pointer from the passed ref object and calls addRef() on the object.
//--------------------------------------------------------------------------------------------------
template<typename T>
template<typename T2>
ref<T>::ref(const ref<T2>& other)
{
if (other.notNull())
{
other->addRef();
// Escape const
m_object = const_cast<T2*>(other.p());
}
else
{
m_object = NULL;
}
}
//--------------------------------------------------------------------------------------------------
/// Destructor.
///
/// Will call release() on the internal pointer.
//--------------------------------------------------------------------------------------------------
template<typename T>
ref<T>::~ref()
{
if (m_object)
{
m_object->release();
m_object = NULL;
}
}
//--------------------------------------------------------------------------------------------------
/// Assignment from raw pointer.
//--------------------------------------------------------------------------------------------------
template<typename T>
ref<T>& ref<T>::operator=(T* rhs)
{
// Copy-and-swap (on temporary obj)
ref<T>(rhs).swap(*this);
return *this;
}
//--------------------------------------------------------------------------------------------------
/// Assignment operator
///
/// Copies the internal pointer from \a rhs and calls addRef().
/// If we're already storing an internal pointer, this pointer will be release()'ed.
//--------------------------------------------------------------------------------------------------
template<typename T>
ref<T>& ref<T>::operator=(ref rhs)
{
// Copy-and-swap (copy already done since parameter is passed by value)
rhs.swap(*this);
return *this;
}
//--------------------------------------------------------------------------------------------------
/// Assignment from related.
///
/// Copies the internal pointer from \a rhs and calls addRef().
/// If we're already storing an internal pointer, this pointer will be release()'ed.
//--------------------------------------------------------------------------------------------------
template<typename T>
template<typename T2>
ref<T>& ref<T>::operator=(const ref<T2>& rhs)
{
// Copy-and-swap (on temporary obj)
ref<T>(rhs).swap(*this);
return *this;
}
//--------------------------------------------------------------------------------------------------
/// Returns the naked pointer this object is associated with.
///
/// Added to be able to write the same code for smart pointers as for normal naked pointers.
///
/// \code
/// ref<MyObject> myObject = new MyObject;
/// myObject->doSomething(); // Easier than myObject.p()->doSomething()
/// \endcode
//--------------------------------------------------------------------------------------------------
template<typename T>
inline T* ref<T>::operator->()
{
CVF_TIGHT_ASSERT(m_object);
return m_object;
}
//--------------------------------------------------------------------------------------------------
/// Returns naked const pointer this object is associated with.
//--------------------------------------------------------------------------------------------------
template<typename T>
inline const T* ref<T>::operator->() const
{
CVF_TIGHT_ASSERT(m_object);
return m_object;
}
//--------------------------------------------------------------------------------------------------
/// Dereference operator returning a modifiable reference to the associated object.
///
/// Added to be able to write the same code for smart pointers as for normal naked pointers.
/// \code
/// ref<MyObject> myObject = new MyObject;
/// *myObject.doSomething();
/// \endcode
//--------------------------------------------------------------------------------------------------
template<typename T>
inline T& ref<T>::operator*()
{
CVF_TIGHT_ASSERT(m_object);
return *m_object;
}
//--------------------------------------------------------------------------------------------------
/// Dereference operator returning a const reference to the associated object.
//--------------------------------------------------------------------------------------------------
template<typename T>
inline const T& ref<T>::operator*() const
{
CVF_TIGHT_ASSERT(m_object);
return *m_object;
}
//--------------------------------------------------------------------------------------------------
/// Returns the naked pointer
//--------------------------------------------------------------------------------------------------
template<typename T>
inline T* ref<T>::p()
{
return m_object;
}
//--------------------------------------------------------------------------------------------------
/// Returns naked const pointer
//--------------------------------------------------------------------------------------------------
template<typename T>
inline const T* ref<T>::p() const
{
return m_object;
}
//--------------------------------------------------------------------------------------------------
/// Returns true if the internal pointer is NULL
//--------------------------------------------------------------------------------------------------
template<typename T>
inline bool ref<T>::isNull() const
{
return m_object == NULL;
}
//--------------------------------------------------------------------------------------------------
/// Returns true if the internal pointer is different from NULL
//--------------------------------------------------------------------------------------------------
template<typename T>
inline bool ref<T>::notNull() const
{
return m_object != NULL;
}
//--------------------------------------------------------------------------------------------------
/// Does less than comparison of two ref objects.
///
/// \return Returns true if this object's internal pointer is less than the internal pointer of \a rhs.
///
/// The comparison is done by comparing the internal pointer values ( this.p() < rhs.p() )
/// This operator is used in several STL collections (e.g. std::set) as well as in many STL algorithms
/// (e.g. std::sort() ).
//--------------------------------------------------------------------------------------------------
template<typename T>
bool ref<T>::operator<(const ref& rhs) const
{
CVF_TIGHT_ASSERT((m_object != NULL) && (rhs.p() != NULL));
return std::less<T*>()(m_object, rhs.m_object);
}
//--------------------------------------------------------------------------------------------------
/// Exchanges the contents of the two smart pointers.
///
/// \param other Modifiable reference to the ref object that should have its contents swapped.
///
/// Swap the associated pointer in this and the passed ref object. Will not modify the reference
/// count of any of the associated objects.
///
/// \warning Note that signature differs from normal practice. This is done to be
/// consistent with the signature of std::swap()
//--------------------------------------------------------------------------------------------------
template<typename T>
void ref<T>::swap(ref& other)
{
T* tmp = other.m_object;
other.m_object = m_object;
m_object = tmp;
}
//==================================================================================================
///
/// \class cvf::cref
/// \ingroup Core
///
/// Smart pointer class used for handling const reference counted objects
//==================================================================================================
//--------------------------------------------------------------------------------------------------
/// Construct from naked pointer
//--------------------------------------------------------------------------------------------------
template<typename T>
cref<T>::cref(const T* object)
{
if (object)
{
object->addRef();
m_object = object;
}
else
{
m_object = NULL;
}
}
//--------------------------------------------------------------------------------------------------
/// Copy constructor
//--------------------------------------------------------------------------------------------------
template<typename T>
cref<T>::cref(const cref& other)
{
if (other.m_object)
{
other.m_object->addRef();
m_object = other.m_object;
}
else
{
m_object = NULL;
}
}
//--------------------------------------------------------------------------------------------------
/// Construct from related
//--------------------------------------------------------------------------------------------------
template<typename T>
template<typename T2>
cref<T>::cref(const cref<T2>& other)
{
if (other.notNull())
{
other->addRef();
m_object = other.p();
}
else
{
m_object = NULL;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
cref<T>::~cref()
{
if (m_object)
{
m_object->release();
m_object = NULL;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
cref<T>& cref<T>::operator=(const T* rhs)
{
// Copy-and-swap (on temporary obj)
cref<T>(rhs).swap(*this);
return *this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
cref<T>& cref<T>::operator=(cref rhs)
{
// Copy-and-swap (copy already done since parameter is passed by value)
rhs.swap(*this);
return *this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
template<typename T2>
cref<T>& cref<T>::operator=(const cref<T2>& rhs)
{
// Copy-and-swap (on temporary obj)
cref<T>(rhs).swap(*this);
return *this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
inline const T* cref<T>::operator->() const
{
CVF_TIGHT_ASSERT(m_object);
return m_object;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
inline const T& cref<T>::operator*() const
{
CVF_TIGHT_ASSERT(m_object);
return *m_object;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
inline const T* cref<T>::p() const
{
return m_object;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
inline bool cref<T>::isNull() const
{
return m_object == NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
inline bool cref<T>::notNull() const
{
return m_object != NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
bool cref<T>::operator<(const cref& rhs) const
{
CVF_TIGHT_ASSERT((m_object != NULL) && (rhs.p() != NULL));
return std::less<const T*>()(m_object, rhs.m_object);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename T>
void cref<T>::swap(cref& other)
{
const T* tmp = other.m_object;
other.m_object = m_object;
m_object = tmp;
}
//--------------------------------------------------------------------------------------------------
/// Creation of smart pointers.
//--------------------------------------------------------------------------------------------------
template<typename T, class... Args>
ref<T> make_ref(Args&&... args)
{
return cvf::ref(new T(args...));
}
//--------------------------------------------------------------------------------------------------
/// Creation of const smart pointers.
//--------------------------------------------------------------------------------------------------
template<typename T, class... Args>
cref<T> make_cref(Args&&... args)
{
return cvf::cref(new T(args...));
}
} // namespace cvf
} //namespace external

664
external/resinsight/LibCore/cvfPlane.cpp vendored Normal file
View File

@@ -0,0 +1,664 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfPlane.h"
#include "cvfMath.h"
namespace external {
namespace cvf {
//==================================================================================================
///
/// \class cvf::Plane
/// \ingroup Core
///
/// Class defining a plane in space
///
/// The class describes a plane by the equation: \f$Ax + By + Cz + D = 0\f$
/// The plane's normal is defined by the coefficients \f$[A, B, C]\f$
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
/// Default constructor
///
/// The plane will be set to invalid
//--------------------------------------------------------------------------------------------------
Plane::Plane()
{
// Invalidate plane coefficients
// Note: Coefficients set to zero will still comply with the line equation but
// the normal is of zero length which is considered an invalid state in this class.
m_A = m_B = m_C = m_D = 0.0;
}
//--------------------------------------------------------------------------------------------------
/// Constructor with plane equation coefficients
///
/// Define a plane by the plane equation coefficients.
/// Setting at least the A, B and C coefficients to zero will effectually set the plane to invalid.
//--------------------------------------------------------------------------------------------------
Plane::Plane(double A, double B, double C, double D)
{
m_A = A;
m_B = B;
m_C = C;
m_D = D;
}
//--------------------------------------------------------------------------------------------------
/// Copy constructor
//--------------------------------------------------------------------------------------------------
Plane::Plane(const Plane& other)
: Object()
{
*this = other;
}
//--------------------------------------------------------------------------------------------------
/// Destructor
//--------------------------------------------------------------------------------------------------
Plane::~Plane()
{
}
//--------------------------------------------------------------------------------------------------
/// Assignment operator
//--------------------------------------------------------------------------------------------------
const Plane& Plane::operator=(const Plane& rhs)
{
m_A = rhs.m_A;
m_B = rhs.m_B;
m_C = rhs.m_C;
m_D = rhs.m_D;
return *this;
}
//--------------------------------------------------------------------------------------------------
/// Equality operator
///
/// Check if the two planes are identically defined. Note, equal planes may be defined differently
/// and are as such considered not to be identical to each other. (Different plane coefficients)
//--------------------------------------------------------------------------------------------------
bool Plane::operator==(const Plane& rhs) const
{
if (m_A != rhs.m_A) return false;
if (m_B != rhs.m_B) return false;
if (m_C != rhs.m_C) return false;
if (m_D != rhs.m_D) return false;
return true;
}
//--------------------------------------------------------------------------------------------------
/// Inequality operator
///
/// Check if the two planes are not identically defined. Note, equal planes may be defined differently
/// and are as such considered not to be identical to each other. (Different plane coefficients)
//--------------------------------------------------------------------------------------------------
bool Plane::operator!=(const Plane& rhs) const
{
return !operator==(rhs);
}
//--------------------------------------------------------------------------------------------------
/// Is the plane definition valid or not
///
/// The plane is considered invalid if the normal is of zero length
//--------------------------------------------------------------------------------------------------
bool Plane::isValid() const
{
return !((m_A == 0.0) && (m_B == 0.0) && (m_C == 0.0));
}
//--------------------------------------------------------------------------------------------------
/// Define a plane by the plane equation coefficients
///
/// \param A Plane coefficient A
/// \param B Plane coefficient B
/// \param C Plane coefficient C
/// \param D Plane coefficient D
///
/// The coefficients defines a plane by the equation: \f$Ax + By + Cz + D = 0\f$
/// The plane coefficients \f$[A, B, C]\f$ defines the normal to the plane
//--------------------------------------------------------------------------------------------------
void Plane::set(double A, double B, double C, double D)
{
CVF_ASSERT(!(A == 0.0 && B == 0.0 && C == 0.0));
m_A = A;
m_B = B;
m_C = C;
m_D = D;
}
//--------------------------------------------------------------------------------------------------
/// Compute the plane equation from the given point and normal
///
/// \param point Point on the plane
/// \param normal The plane's normal
//--------------------------------------------------------------------------------------------------
bool Plane::setFromPointAndNormal(const Vec3d& point, const Vec3d& normal)
{
if (normal.isZero()) return false;
m_A = normal.x();
m_B = normal.y();
m_C = normal.z();
m_D = -(normal*point);
return true;
}
//--------------------------------------------------------------------------------------------------
/// Compute the plane equation from the given three points
///
/// \param p1 First point on the plane
/// \param p2 Second point on the plane
/// \param p3 Third point on the plane
///
/// \return true if successfully set. false if points are on the same line.
///
/// The three points must be different from each other and cannot be on the same line in space
//--------------------------------------------------------------------------------------------------
bool Plane::setFromPoints(const Vec3d& p1, const Vec3d& p2, const Vec3d& p3)
{
Vec3d v1 = p2 - p1;
Vec3d v2 = p3 - p1;
Vec3d normal = v1 ^ v2;
if (normal.isZero()) return false;
setFromPointAndNormal(p1, normal);
return true;
}
//--------------------------------------------------------------------------------------------------
/// Get the normal of the plane
///
/// The normal may not be normalized
//--------------------------------------------------------------------------------------------------
Vec3d Plane::normal() const
{
Vec3d normal = Vec3d(m_A, m_B, m_C);
CVF_ASSERT(!normal.isZero());
return normal;
}
//--------------------------------------------------------------------------------------------------
/// Get a point located on the plane
//--------------------------------------------------------------------------------------------------
Vec3d Plane::pointInPlane() const
{
double distToOrigin = distanceToOrigin();
Vec3d point(m_A, m_B, m_C);
point *= distToOrigin;
return point;
}
//--------------------------------------------------------------------------------------------------
/// Flip the plane
//--------------------------------------------------------------------------------------------------
void Plane::flip()
{
m_A *= -1.0;
m_B *= -1.0;
m_C *= -1.0;
m_D *= -1.0;
}
//--------------------------------------------------------------------------------------------------
/// Transforms the plane with the given homogeneous transformation \a matrix
//--------------------------------------------------------------------------------------------------
void Plane::transform(const Mat4d& matrix)
{
Vec3d n = normal();
Vec3d point = pointInPlane();
n.transformVector(matrix);
point.transformPoint(matrix);
setFromPointAndNormal(point, n);
}
//--------------------------------------------------------------------------------------------------
/// Get the distance from the point to the plane
//--------------------------------------------------------------------------------------------------
double Plane::distance(const Vec3d& point) const
{
double factor = Math::sqrt(m_A*m_A + m_B*m_B + m_C*m_C);
CVF_ASSERT(factor > 0.0);
double dist = distanceSquared(point) / factor;
return dist;
}
//--------------------------------------------------------------------------------------------------
/// Get the square of the distance from the point to the plane
///
/// The square of the distance is relatively fast to compute (no \a sqrt) and is useful for determine
/// which side the point is on. To obtain the actual distance, divide by \f$\sqrt{(A^2 + B^2 + C^2)}\f$
/// or use the distance() function directly.
//--------------------------------------------------------------------------------------------------
double Plane::distanceSquared(const Vec3d& point) const
{
return m_A*point.x() + m_B*point.y() + m_C*point.z() + m_D;
}
//--------------------------------------------------------------------------------------------------
/// Get the distance from the plane to the origin
//--------------------------------------------------------------------------------------------------
double Plane::distanceToOrigin() const
{
double factor = m_A*m_A + m_B*m_B + m_C*m_C;
CVF_ASSERT(factor > 0.0);
return -m_D/factor;
}
//--------------------------------------------------------------------------------------------------
/// Project the given vector onto the plane
///
/// \param vector Vector to be projected
/// \param projectedVector Projected vector to be returned by pointer
///
/// \return true if successfully projected.
/// false if the given \a vector is parallel with the plane's normal
//--------------------------------------------------------------------------------------------------
bool Plane::projectVector(const Vec3d& vector, Vec3d* projectedVector) const
{
CVF_ASSERT(projectedVector);
Vec3d n = normal();
Vec3d tmp = n ^ vector;
Vec3d k = tmp ^ n;
double length = k.length();
if (length <= 0.0) return false;
k *= 1.0/length;
length = vector*k;
*projectedVector = k;
*projectedVector *= length;
return true;
}
//--------------------------------------------------------------------------------------------------
/// Project the given point onto the plane
//--------------------------------------------------------------------------------------------------
Vec3d Plane::projectPoint(const Vec3d& point) const
{
Vec3d pip = pointInPlane();
// Create vector from point in plane to node
Vec3d vector = point - pip;
// Project vector to find node in plane
Vec3d projectedPoint;
if (projectVector(vector, &projectedPoint))
{
projectedPoint += pip;
}
else
{
// The <point - pip> vector is parallel with the normal vector, use the point in plane as the projected
projectedPoint = pip;
}
return projectedPoint;
}
//--------------------------------------------------------------------------------------------------
/// Find intersection line between two planes
///
/// \param other The other plane to find intersection line with
/// \param point Point on line
/// \param direction Normalized direction of line
///
/// \return true if success. false if direction is zero -> no point of intersection exists
//--------------------------------------------------------------------------------------------------
bool Plane::intersect(const Plane& other, Vec3d* point, Vec3d* direction) const
{
// Note: Ripped from Graphics Gems III page 233.
CVF_ASSERT(point);
double invdet = UNDEFINED_DOUBLE;
Vec3d normal1 = this->normal();
Vec3d normal2 = other.normal();
Vec3d vector = normal1 ^ normal2;
Vec3d dir2(vector.x()*vector.x(), vector.y()*vector.y(), vector.z()*vector.z());
// Todo: VTFIsGreater(...) and VTFeqZero(..) replacement
if ((dir2.z() > dir2.y()) && (dir2.z() > dir2.x()) && (dir2.z() != 0.0))
{
// then get a point on the XY plane
invdet = 1.0 / vector.z();
// solve < pl1.x() * xpt.x() + pl1.y() * xpt.y() = - pl1.w > < pl2.x() * xpt.x() + pl2.y() * xpt.y() = - pl2.w >
point->x() = m_B*other.m_D - other.m_B*m_D;
point->y() = other.m_A*m_D - m_A*other.m_D;
point->z() = 0.0;
}
// Todo: VTFIsGreater(...) and VTFeqZero(..) replacement
else if ((dir2.y() > dir2.x()) && (dir2.y() != 0.0))
{
// then get a point on the XZ plane
invdet = 1.0f / vector.y();
// solve < pl1.x() * xpt.x() + pl1.z() * xpt.z() = -pl1.w > < pl2.x() * xpt.x() + pl2.z() * xpt.z() = -pl2.w >
point->x() = other.m_C*m_D - m_C*other.m_D;
point->y() = 0.0;
point->z() = m_A*other.m_D - other.m_A*m_D;
}
// Todo: VTFeqZero(..) replacement
else if (dir2.x() != 0.0)
{
// then get a point on the YZ plane
invdet = 1.0 / vector.x();
// solve < pl1.y() * xpt.y() + pl1.z() * xpt.z() = - pl1.w > < pl2.y() * xpt.y() + pl2.z() * xpt.z() = - pl2.w >
point->x() = 0.0;
point->y() = m_C*other.m_D - other.m_C*m_D;
point->z() = other.m_B*m_D - m_B*other.m_D;
}
else
{
// direction is zero, then no point of intersection exists
return false;
}
*point *= invdet;
if (direction)
{
*direction = vector;
direction->normalize();
}
return true;
}
//--------------------------------------------------------------------------------------------------
/// Find intersection between a line segment and a plane
///
/// \param a Start of line segment
/// \param b End of line segment
/// \param intersection Returns intersection point if not NULL
///
/// \return True if line segment intersects the plane
//--------------------------------------------------------------------------------------------------
bool Plane::intersect(const Vec3d& a, const Vec3d& b, Vec3d* intersection) const
{
// From Real-Time Collision Detection by Christer Eriscon, published by Morgen Kaufmann Publishers, (c) 2005 Elsevier Inc
// Compute the t value for the directed line ab intersecting the plane
Vec3d ab = b - a;
double t = (-m_D - (normal() * a)) / (normal() * ab);
// If t in [0..1] compute and return intersection point
if (t >= 0.0 && t <= 1.0)
{
if (intersection)
{
*intersection = a + t * ab;
}
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
/// Clip a triangle against this plane
///
/// Clip the triangle given by parameters a, b and c against this plane. The vertices of the
/// resulting clipped polygon (triangle or quad) will be returned in \a clippedPolygon. Since the
/// clipped polygon may be a quad, the \a clippedPolygon array must have room for at least 4 elements.
///
/// \return The number of resulting vertices that are populated in \a clippedPolygon. Will be 0, 3 or 4.
//--------------------------------------------------------------------------------------------------
size_t Plane::clipTriangle(const Vec3d& a, const Vec3d& b, const Vec3d& c, Vec3d clippedPolygon[4]) const
{
// Except for the trivial cases where all vertices are in front
// or behind plane, these are the permutations
//
// Single vertex on positive side of plane
// => return a triangle
//
// +\ /\c /\c /+ /\c .
// \ / \ / \ / + / \ + .
// \ \ / \/ ---/----\--- .
// / \ \ / /\ / \ .
// a/___\____\b a/_____/__\b a/________\b .
// +\ /+
//
// Two vertices vertex on positive side of plane
// => return a quad
//
// /\c \+ /\c /\c +/ .
// / \ \ / \ / \ / .
// ___/____\___ \ \ / \/ .
// + / \ + / \ \ / /\ .
// a/________\b a/___\____\b a/_____/__\b .
// \+ +/
bool onPosSide[3];
onPosSide[0] = distanceSquared(a) >= 0 ? true : false;
onPosSide[1] = distanceSquared(b) >= 0 ? true : false;
onPosSide[2] = distanceSquared(c) >= 0 ? true : false;
const int numPositiveVertices = (onPosSide[0] ? 1 : 0) + (onPosSide[1] ? 1 : 0) + (onPosSide[2] ? 1 : 0);
// The entire triangle is on the negative side
// Clip everything
if (numPositiveVertices == 0)
{
return 0;
}
// All triangle vertices are on the positive side
// Return the same triangle
if (numPositiveVertices == 3)
{
clippedPolygon[0] = a;
clippedPolygon[1] = b;
clippedPolygon[2] = c;
return 3;
}
// Handle case where a single vertex is on the positive side
// Will result in the return of a single clipped triangle
if (numPositiveVertices == 1)
{
if (onPosSide[0])
{
clippedPolygon[0] = a;
intersect(a, b, &clippedPolygon[1]);
intersect(a, c, &clippedPolygon[2]);
}
else if (onPosSide[1])
{
clippedPolygon[0] = b;
intersect(b, c, &clippedPolygon[1]);
intersect(b, a, &clippedPolygon[2]);
}
else
{
CVF_ASSERT(onPosSide[2]);
clippedPolygon[0] = c;
intersect(c, a, &clippedPolygon[1]);
intersect(c, b, &clippedPolygon[2]);
}
return 3;
}
else
{
CVF_ASSERT(numPositiveVertices == 2);
if (onPosSide[0] && onPosSide[1])
{
// a & b are on positive side
clippedPolygon[0] = a;
clippedPolygon[1] = b;
intersect(b, c, &clippedPolygon[2]);
intersect(a, c, &clippedPolygon[3]);
}
else if (onPosSide[1] && onPosSide[2])
{
// b & c are on positive side
clippedPolygon[0] = b;
clippedPolygon[1] = c;
intersect(c, a, &clippedPolygon[2]);
intersect(b, a, &clippedPolygon[3]);
}
else
{
// c && a are on positive side
CVF_ASSERT(onPosSide[2] && onPosSide[0]);
clippedPolygon[0] = c;
clippedPolygon[1] = a;
intersect(a, b, &clippedPolygon[2]);
intersect(c, b, &clippedPolygon[3]);
}
return 4;
}
}
//--------------------------------------------------------------------------------------------------
/// Classify where the point is located relative to the plane
///
/// \return Plane::FRONT if the point is located on the side the plane normal is pointing\n
/// Plane::BACK if the point is located on the opposite side the plane normal is pointing\n
/// Plane::ON if the point is located in the plane
///
//--------------------------------------------------------------------------------------------------
Plane::Side Plane::side(const Vec3d& point) const
{
double d = distanceSquared(point);
if (d > 0.0)
{
return FRONT;
}
else if (d < 0.0)
{
return BACK;
}
else
{
return ON;
}
}
//--------------------------------------------------------------------------------------------------
/// Classify where the points are located relative to the plane
///
/// \param points Points to test for location relative the plane
///
/// \return Plane::FRONT if points are either Plane::FRONT or Plane::ON\n
/// Plane::BACK if points are either Plane::BACK or Plane::ON\n
/// Plane::ON if all points are Plane::ON\n
/// Plane::BOTH if points are located on both sides
//--------------------------------------------------------------------------------------------------
Plane::Side Plane::side(const Vec3dArray& points) const
{
// Code taken from
// http://code.google.com/p/papervision3d/source/browse/trunk/as3/trunk/src/org/papervision3d/core/math/util/ClassificationUtil.as
cvf::uint frontCount = 0;
cvf::uint backCount = 0;
for (size_t i = 0; i < points.size(); i++)
{
Side s = side(points[i]);
if (s == FRONT)
{
frontCount++;
}
else if (s == BACK)
{
backCount++;
}
}
if (frontCount > 0 && backCount == 0)
{
return FRONT;
}
else if (frontCount == 0 && backCount > 0)
{
return BACK;
}
else if (frontCount > 0 && backCount > 0)
{
return BOTH;
}
else
{
return ON;
}
}
} // namespace cvf
} //namespace external

107
external/resinsight/LibCore/cvfPlane.h vendored Normal file
View File

@@ -0,0 +1,107 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfObject.h"
#include "cvfVector3.h"
#include "cvfMatrix4.h"
#include "cvfArray.h"
namespace external {
namespace cvf {
//=================================================================================================
//
// Plane class
//
//=================================================================================================
class Plane : public Object
{
public:
enum Side { FRONT, BACK, ON, BOTH };
public:
Plane();
Plane(double A, double B, double C, double D);
Plane(const Plane& other);
~Plane();
const Plane& operator=(const Plane& other);
bool operator==(const Plane& other) const;
bool operator!=(const Plane& other) const;
inline double A() const { return m_A; } ///< Get plane coefficient A
inline double B() const { return m_B; } ///< Get plane coefficient B
inline double C() const { return m_C; } ///< Get plane coefficient C
inline double D() const { return m_D; } ///< Get plane coefficient D
bool isValid() const;
void set(double A, double B, double C, double D);
bool setFromPointAndNormal(const Vec3d& point, const Vec3d& normal);
bool setFromPoints(const Vec3d& p1, const Vec3d& p2, const Vec3d& p3);
Vec3d normal() const;
Vec3d pointInPlane() const;
void flip();
void transform(const Mat4d& matrix);
double distance(const Vec3d& point) const;
double distanceSquared(const Vec3d& point) const;
double distanceToOrigin() const;
bool projectVector(const Vec3d& vector, Vec3d* projectedVector) const;
Vec3d projectPoint(const Vec3d& point) const;
bool intersect(const Plane& other, Vec3d* point, Vec3d* direction = NULL) const;
bool intersect(const Vec3d& a, const Vec3d& b, Vec3d* intersection) const;
size_t clipTriangle(const Vec3d& ta, const Vec3d& tb, const Vec3d& tc, Vec3d clippedPolygon[4]) const;
Side side(const Vec3d& point) const;
Side side(const Vec3dArray& points) const;
private:
double m_A; // Plane equation coefficients
double m_B; //
double m_C; //
double m_D; //
};
}
} //namespace external

View File

@@ -0,0 +1,168 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfPropertySet.h"
namespace external {
namespace cvf {
//==================================================================================================
///
/// \class cvf::PropertySet
/// \ingroup Core
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PropertySet::PropertySet(const String& classType)
: m_classType(classType)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PropertySet::~PropertySet()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool PropertySet::operator==(const PropertySet& rhs) const
{
if (m_classType == rhs.m_classType)
{
return (m_propMap == rhs.m_propMap);
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
String PropertySet::classType() const
{
return m_classType;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool PropertySet::isEmpty() const
{
return m_propMap.empty();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Variant PropertySet::value(const String& key) const
{
std::map<String, Variant>::const_iterator it = m_propMap.find(key);
if (it != m_propMap.end())
{
return it->second;
}
else
{
return Variant();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PropertySet::setValue(const String& key, const Variant& data)
{
m_propMap[key] = data;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool PropertySet::contains(const String& key) const
{
if (m_propMap.find(key) != m_propMap.end())
{
return true;
}
else
{
return false;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<String> PropertySet::allKeys() const
{
std::vector<String> all;
std::map<String, Variant>::const_iterator it;
for (it = m_propMap.begin(); it != m_propMap.end(); ++it)
{
all.push_back(it->first);
}
return all;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<Variant> PropertySet::allValues() const
{
std::vector<Variant> all;
std::map<String, Variant>::const_iterator it;
for (it = m_propMap.begin(); it != m_propMap.end(); ++it)
{
all.push_back(it->second);
}
return all;
}
} // namespace gc
} //namespace external

View File

@@ -0,0 +1,80 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfObject.h"
#include "cvfVariant.h"
#include "cvfString.h"
#include <map>
namespace external {
namespace cvf {
//==================================================================================================
//
//
//
//==================================================================================================
class PropertySet : public Object
{
public:
PropertySet(const String& classType);
~PropertySet();
bool operator==(const PropertySet& rhs) const;
String classType() const;
bool isEmpty() const;
Variant value(const String& key) const;
void setValue(const String& key, const Variant& data);
bool contains(const String& key) const;
std::vector<String> allKeys() const;
std::vector<Variant> allValues() const;
private:
String m_classType;
std::map<String, Variant> m_propMap;
};
} // namespace cvf
} //namespace external

101
external/resinsight/LibCore/cvfQuat.h vendored Normal file
View File

@@ -0,0 +1,101 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfVector3.h"
namespace external {
namespace cvf {
//==================================================================================================
//
// This class implements a quaternion
//
//==================================================================================================
template<typename S>
class Quat
{
public:
Quat();
Quat(S x, S y, S z, S w);
Quat(const Quat& other);
template<typename T>
explicit Quat(const T& other);
Quat& operator=(const Quat& rhs);
bool operator==(const Quat& rhs) const;
bool operator!=(const Quat& rhs) const;
const S& x() const { return m_x; } ///< Get the X element of the quaternion
const S& y() const { return m_y; } ///< Get the Y element of the quaternion
const S& z() const { return m_z; } ///< Get the Z element of the quaternion
const S& w() const { return m_w; } ///< Get the W element of the quaternion
S& x() { return m_x; } ///< Get a reference to the X element of the quaternion. E.g. x() = 2;
S& y() { return m_y; } ///< Get a reference to the Y element of the quaternion. E.g. y() = 2;
S& z() { return m_z; } ///< Get a reference to the Z element of the quaternion. E.g. z() = 2;
S& w() { return m_w; } ///< Get a reference to the W element of the quaternion. E.g. w() = 2;
void set(S x, S y, S z, S w);
bool normalize();
// The setFromAxisAngle() function is left as a placeholder to illustrate naming of functions
void setFromAxisAngle(Vector3<S> rotationAxis, S angle);
void toAxisAngle(Vector3<S>* rotationAxis, S* angle) const;
Matrix3<S> toMatrix3() const;
Matrix4<S> toMatrix4() const;
static Quat fromAxisAngle(Vector3<S> rotationAxis, S angle);
static Quat fromRotationMatrix(const Matrix4<S>& rotMat);
private:
S m_x;
S m_y;
S m_z;
S m_w;
};
typedef Quat<float> Quatf;
typedef Quat<double> Quatd;
}
} //namespace external
#include "cvfQuat.inl"

396
external/resinsight/LibCore/cvfQuat.inl vendored Normal file
View File

@@ -0,0 +1,396 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
namespace external {
namespace cvf {
//==================================================================================================
///
/// \class cvf::Quat
/// \ingroup Core
///
/// Templated quaternion
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
/// Default constructor, initializes all elements to 0
//--------------------------------------------------------------------------------------------------
template<typename S>
Quat<S>::Quat()
: m_x(0),
m_y(0),
m_z(0),
m_w(0)
{
}
//--------------------------------------------------------------------------------------------------
/// Constructor with initialization
//--------------------------------------------------------------------------------------------------
template<typename S>
Quat<S>::Quat(S x, S y, S z, S w)
: m_x(x),
m_y(y),
m_z(z),
m_w(w)
{
}
//--------------------------------------------------------------------------------------------------
/// Copy constructor
//--------------------------------------------------------------------------------------------------
template<typename S>
Quat<S>::Quat(const Quat& other)
: m_x(other.m_x),
m_y(other.m_y),
m_z(other.m_z),
m_w(other.m_w)
{
}
//--------------------------------------------------------------------------------------------------
/// Conversion constructor for explicit conversion
//--------------------------------------------------------------------------------------------------
template<typename S>
template<typename T>
Quat<S>::Quat(const T& other)
{
m_x = static_cast<S>(other.x());
m_y = static_cast<S>(other.y());
m_z = static_cast<S>(other.z());
m_w = static_cast<S>(other.w());
}
//--------------------------------------------------------------------------------------------------
/// Assignment operator
//--------------------------------------------------------------------------------------------------
template<typename S>
Quat<S>& Quat<S>::operator=(const Quat& rhs)
{
m_x = rhs.m_x;
m_y = rhs.m_y;
m_z = rhs.m_z;
m_w = rhs.m_w;
return *this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename S>
bool Quat<S>::operator==(const Quat& rhs) const
{
if (m_x != rhs.m_x) return false;
if (m_y != rhs.m_y) return false;
if (m_z != rhs.m_z) return false;
if (m_w != rhs.m_w) return false;
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename S>
bool Quat<S>::operator!=(const Quat& rhs) const
{
if (m_x != rhs.m_x) return true;
if (m_y != rhs.m_y) return true;
if (m_z != rhs.m_z) return true;
if (m_w != rhs.m_w) return true;
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename S>
void Quat<S>::set(S x, S y, S z, S w)
{
m_x = x;
m_y = y;
m_z = z;
m_w = w;
}
//--------------------------------------------------------------------------------------------------
/// Normalize the quaternion
//--------------------------------------------------------------------------------------------------
template<typename S>
bool Quat<S>::normalize()
{
// Quaternions always obey: a^2 + b^2 + c^2 + d^2 = 1.0.
// If they don't add up to 1.0, dividing by their magnitude will re-normalize them.
S len = Math::sqrt(m_x*m_x + m_y*m_y + m_z*m_z + m_w*m_w);
if (len > 0)
{
// Pre-compute 1/length and do multiplication instead of division
S oneOverLen = static_cast<S>(1.0/len);
m_x *= oneOverLen;
m_y *= oneOverLen;
m_z *= oneOverLen;
m_w *= oneOverLen;
return true;
}
else
{
// Might be NaN, so set it to zero
m_x = 0;
m_y = 0;
m_z = 0;
m_w = 0;
return false;
}
}
//--------------------------------------------------------------------------------------------------
/// Sets the quaternion from a rotation axis and an angle (in radians)
//--------------------------------------------------------------------------------------------------
template<typename S>
void Quat<S>::setFromAxisAngle(Vector3<S> rotationAxis, S angle)
{
*this = Quat::fromAxisAngle(rotationAxis, angle);
}
//--------------------------------------------------------------------------------------------------
/// Extracts the rotation in this quaternion as an axis and an angle (in radians)
//--------------------------------------------------------------------------------------------------
template<typename S>
void Quat<S>::toAxisAngle(Vector3<S>* rotationAxis, S* angle) const
{
// From matrix an quaternion FAQ
CVF_ASSERT(rotationAxis);
CVF_ASSERT(angle);
// Need a normalized quaternion
Quat nQ(*this);
nQ.normalize();
// Clamp to acos' input domain
S cos_a = Math::clamp(nQ.m_w, static_cast<S>(-1), static_cast<S>(1));
*angle = 2*Math::acos(cos_a);
S sin_a = Math::sqrt(1 - cos_a*cos_a);
if (Math::abs(sin_a) < 0.0005) sin_a = 1;
rotationAxis->x() = nQ.m_x/sin_a;
rotationAxis->y() = nQ.m_y/sin_a;
rotationAxis->z() = nQ.m_z/sin_a;
}
//--------------------------------------------------------------------------------------------------
/// Constructs a rotation matrix from this quaternion
//--------------------------------------------------------------------------------------------------
template<typename S>
Matrix3<S> Quat<S>::toMatrix3() const
{
// Based on Quaternions paper by Ken Shoemake
// The current version works even if quaternion isn't normalized
// If we assume that the quaternion is normalized, this function can be made simpler/quicker
S Nq = m_x*m_x + m_y*m_y + m_z*m_z + m_w*m_w;
S s = (Nq > 0) ? (2/Nq) : 0;
S xs = m_x*s;
S ys = m_y*s;
S zs = m_z*s;
S wx = m_w*xs;
S wy = m_w*ys;
S wz = m_w*zs;
S xx = m_x*xs;
S xy = m_x*ys;
S xz = m_x*zs;
S yy = m_y*ys;
S yz = m_y*zs;
S zz = m_z*zs;
// Default constructor initializes to identity
Matrix3<S> m;
m.setRowCol( 0, 0, 1 - (yy + zz));
m.setRowCol( 0, 1, xy - wz );
m.setRowCol( 0, 2, xz + wy );
m.setRowCol( 1, 0, xy + wz );
m.setRowCol( 1, 1, 1 - (xx + zz));
m.setRowCol( 1, 2, yz - wx );
m.setRowCol( 2, 0, xz - wy );
m.setRowCol( 2, 1, yz + wx );
m.setRowCol( 2, 2, 1 - (xx + yy));
return m;
}
//--------------------------------------------------------------------------------------------------
/// Constructs a rotation matrix from this quaternion
//--------------------------------------------------------------------------------------------------
template<typename S>
Matrix4<S> Quat<S>::toMatrix4() const
{
// Create via the Matrix3 version
return Matrix4<S>(toMatrix3());
}
//--------------------------------------------------------------------------------------------------
/// Creates a quaternion from specified rotation axis and angle (in radians)
//--------------------------------------------------------------------------------------------------
template<typename S>
Quat<S> Quat<S>::fromAxisAngle(Vector3<S> rotationAxis, S angle)
{
// From matrix an quaternion FAQ
rotationAxis.normalize();
S halfAngle = static_cast<S>(angle/2.0);
S sinHalfAngle = Math::sin(halfAngle);
Quat q;
q.m_x = rotationAxis.x()*sinHalfAngle;;
q.m_y = rotationAxis.y()*sinHalfAngle;
q.m_z = rotationAxis.z()*sinHalfAngle;
q.m_w = Math::cos(halfAngle);
return q;
}
//--------------------------------------------------------------------------------------------------
/// Creates a quaternion from the passed rotation matrix
//--------------------------------------------------------------------------------------------------
template<typename S>
Quat<S> Quat<S>::fromRotationMatrix(const Matrix4<S>& rotMat)
{
const S m00 = rotMat.rowCol(0, 0);
const S m01 = rotMat.rowCol(0, 1);
const S m02 = rotMat.rowCol(0, 2);
const S m10 = rotMat.rowCol(1, 0);
const S m11 = rotMat.rowCol(1, 1);
const S m12 = rotMat.rowCol(1, 2);
const S m20 = rotMat.rowCol(2, 0);
const S m21 = rotMat.rowCol(2, 1);
const S m22 = rotMat.rowCol(2, 2);
// If the trace of the matrix is greater than zero, then perform an "instant" calculation.
S trace = m00 + m11 + m22;
Quat q(0, 0, 0, 1);
// Try and test against a very small value instead of 0 here
// The FAQ suggests testing against ( T > 0.00000001 ) to avoid large distortions
if (trace > 0.00000001)
{
S s = Math::sqrt(trace + 1)*2;
q.m_x = (m21 - m12)/s;
q.m_y = (m02 - m20)/s;
q.m_z = (m10 - m01)/s;
q.m_w = static_cast<S>(0.25*s);
}
else
{
// If the trace of the matrix is equal to zero then identify
// which major diagonal element has the greatest value.
int iDominantColumn = 0;
if (m11 > m00) iDominantColumn = 1;
if (m22 > m11) iDominantColumn = 2;
if (iDominantColumn == 0)
{
S s = Math::sqrt(1 + m00 - m11 - m22)*2;
if (s > 0)
{
q.m_x = static_cast<S>(0.25*s);
q.m_y = (m10 + m01)/s;
q.m_z = (m20 + m02)/s;
q.m_w = (m21 - m12)/s;
}
}
else if (iDominantColumn == 1)
{
S s = Math::sqrt(1 + m11 - m00 - m22)*2;
if (s > 0)
{
q.m_x = (m10 + m01)/s;
q.m_y = static_cast<S>(0.25*s);
q.m_z = (m21 + m12)/s;
q.m_w = (m02 - m20)/s;
}
}
else
{
S s = Math::sqrt(1 + m22 - m00 - m11)*2;
if (s > 0)
{
q.m_x = (m20 + m02)/s;
q.m_y = (m21 + m12)/s;
q.m_z = static_cast<S>(0.25*s);
q.m_w = (m10 - m01)/s;
}
}
}
return q;
}
} // namespace cvf
} //namespace external

103
external/resinsight/LibCore/cvfRect.h vendored Normal file
View File

@@ -0,0 +1,103 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfVector2.h"
namespace external {
namespace cvf {
//==================================================================================================
//
//
//
//==================================================================================================
template <typename T>
class Rect
{
public:
Rect();
Rect(T minX, T minY, T width, T height);
Rect(const Vector2<T>& min, T width, T height);
Rect(const Rect& rect);
Rect& operator=(const Rect& rhs);
Vector2<T> min() const;
Vector2<T> max() const;
T width() const;
T height() const;
Vector2<T> center() const;
void setMin(const Vector2<T>& min);
void setWidth(T width);
void setHeight(T height);
bool isValid() const;
void normalize();
void include(const Vector2<T>& coord);
void include(const Rect& rect);
bool contains(const Vector2<T>& coord) const;
bool intersects(const Rect& rect) const;
void translate(const Vector2<T>& offset);
bool segmentIntersect(const Vec2d& p1, const Vec2d& p2, Vec2d* intersect1, Vec2d* intersect2);
static Rect fromMinMax(const Vector2<T>& min, const Vector2<T>& max);
private:
static bool clipTest(double p, double q, double *u1, double *u2);
private:
Vector2<T> m_minPos; ///< Position of left lower corner
T m_width; ///< Width
T m_height; ///< Height
};
typedef Rect<float> Rectf; ///< A rect with float components
typedef Rect<double> Rectd; ///< A rect with double components
typedef Rect<int> Recti; ///< A rect with integer components
typedef Rect<uint> Rectui; ///< A rect with unsigned integer components
}
} //namespace external
#include "cvfRect.inl"

605
external/resinsight/LibCore/cvfRect.inl vendored Normal file
View File

@@ -0,0 +1,605 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
namespace external {
namespace cvf {
//==================================================================================================
///
/// \class cvf::Rect
/// \ingroup Core
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename T>
Rect<T>::Rect()
{
m_minPos.setZero();
m_width = 0;
m_height = 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename T>
Rect<T>::Rect(T minX, T minY, T width, T height)
{
m_minPos.set(minX, minY);
m_width = width;
m_height = height;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename T>
Rect<T>::Rect(const Vector2<T>& min, T width, T height)
{
m_minPos = min;
m_width = width;
m_height = height;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename T>
Rect<T>::Rect(const Rect& rect)
{
m_minPos = rect.min();
m_width = rect.width();
m_height = rect.height();
}
//--------------------------------------------------------------------------------------------------
/// Assignment operator
//--------------------------------------------------------------------------------------------------
template<typename T>
Rect<T>& Rect<T>::operator=(const Rect& rhs)
{
m_minPos = rhs.min();
m_width = rhs.max().x() - rhs.min().x();
m_height = rhs.max().y() - rhs.min().y();
return *this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename T>
Vector2<T> Rect<T>::min() const
{
return m_minPos;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename T>
Vector2<T> Rect<T>::max() const
{
Vector2<T> max(m_minPos);
max.x() += m_width;
max.y() += m_height;
return max;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename T>
T Rect<T>::width() const
{
return m_width;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename T>
T Rect<T>::height() const
{
return m_height;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename T>
Vector2<T> Rect<T>::center() const
{
Vector2<T> center(m_minPos);
center.x() += m_width / 2.0;
center.y() += m_height / 2.0;
return center;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename T>
void Rect<T>::setMin(const Vector2<T>& min)
{
m_minPos = min;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename T>
void Rect<T>::setWidth(T width)
{
m_width = width;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename T>
void Rect<T>::setHeight(T height)
{
m_height = height;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename T>
bool Rect<T>::isValid() const
{
return (m_width > 0.0) && (m_height > 0.0);
}
//--------------------------------------------------------------------------------------------------
/// Normalizes the rectangle
///
/// Ensures that the rectangle has a non-negative width and height. If width or height is negative,
/// the corresponding min component will be moved.
//--------------------------------------------------------------------------------------------------
template <typename T>
void Rect<T>::normalize()
{
if (m_width < 0.0)
{
m_width = -m_width;
m_minPos.x() -= m_width;
}
if (m_height < 0.0)
{
m_height = -m_height;
m_minPos.y() -= m_height;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename T>
void Rect<T>::include(const Vector2<T>& coord)
{
if (!isValid())
{
Vector2<T> diff = coord - m_minPos;
m_width = diff.x();
m_height = diff.y();
return;
}
if (coord.x() < m_minPos.x())
{
T deltaX = m_minPos.x() - coord.x();
m_minPos.x() -= deltaX;
m_width += deltaX;
}
else if (coord.x() > m_minPos.x() + m_width)
{
T deltaX = coord.x() - (m_minPos.x() + m_width);
m_width += deltaX;
}
if (coord.y() < m_minPos.y())
{
T deltaY = m_minPos.y() - coord.y();
m_minPos.y() -= deltaY;
m_height += deltaY;
}
else if (coord.y() > m_minPos.y() + m_height)
{
T deltaY = coord.y() - (m_minPos.y() + m_height);
m_height += deltaY;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename T>
void Rect<T>::include(const Rect& rect)
{
if (!rect.isValid()) return;
T left = m_minPos.x();
T right = m_minPos.x();
if (m_width < 0.0)
{
left += m_width;
}
else
{
right += m_width;
}
if (rect.width() < 0.0)
{
left = CVF_MIN(left, rect.min().x() + rect.width());
right = CVF_MAX(right, rect.min().x());
}
else
{
left = CVF_MIN(left, rect.min().x());
right = CVF_MAX(right, rect.min().x() + rect.width());
}
T bottom = m_minPos.y();
T top = m_minPos.y();
if (m_height < 0.0)
{
bottom += m_height;
}
else
{
top += m_height;
}
if (rect.height() < 0.0)
{
bottom = CVF_MIN(bottom, rect.min().y() + rect.height());
top = CVF_MAX(top, rect.min().y());
}
else
{
bottom = CVF_MIN(bottom, rect.min().y());
top = CVF_MAX(top, rect.min().y() + rect.height());
}
m_minPos.set(left, bottom);
m_width = right - left;
m_height = top - bottom;
}
//--------------------------------------------------------------------------------------------------
/// Check if the rectangle contains the specified coordinate
///
/// Returns true if the point is inside or on the edge of the rectangle; otherwise returns false.
//--------------------------------------------------------------------------------------------------
template <typename T>
bool Rect<T>::contains(const Vector2<T>& coord) const
{
T left = m_minPos.x();
T right = m_minPos.x();
if (m_width < 0.0)
{
left += m_width;
}
else
{
right += m_width;
}
if (left == right)
{
// null rect
return false;
}
if (coord.x() < left || coord.x() > right)
{
return false;
}
T bot = m_minPos.y();
T top = m_minPos.y();
if (m_height < 0.0)
{
bot += m_height;
}
else
{
top += m_height;
}
if (bot == top)
{
// null rect
return false;
}
if (coord.y() < bot || coord.y() > top)
{
return false;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename T>
bool Rect<T>::intersects(const Rect& rect) const
{
T left1 = m_minPos.x();
T right1 = m_minPos.x();
if (m_width < 0.0)
{
left1 += m_width;
}
else
{
right1 += m_width;
}
if (left1 == right1)
{
// null rect
return false;
}
T left2 = rect.min().x();
T right2 = rect.min().x();
if (rect.width() < 0.0)
{
left2 += rect.width();
}
else
{
right2 += rect.width();
}
if (left2 == right2)
{
// null rect
return false;
}
if (left1 >= right2 || left2 >= right1)
{
return false;
}
T bot1 = m_minPos.y();
T top1 = m_minPos.y();
if (m_height < 0.0)
{
bot1 += m_height;
}
else
{
top1 += m_height;
}
if (bot1 == top1)
{
// null rect
return false;
}
T bot2 = rect.min().y();
T top2 = rect.min().y();
if (rect.height() < 0.0)
{
bot2 += rect.height();
}
else
{
top2 += rect.height();
}
if (bot2 == top2)
{
// null rect
return false;
}
if (bot1 >= top2 || bot2 >= top1)
{
return false;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename T>
void Rect<T>::translate(const Vector2<T>& offset)
{
m_minPos += offset;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename T>
Rect<T> Rect<T>::fromMinMax(const Vector2<T>& min, const Vector2<T>& max)
{
// Enforce min/max - otherwise we'll get bogus results for unsigned types
CVF_ASSERT(min.x() <= max.x());
CVF_ASSERT(min.y() <= max.y());
Rect<T> rect(min, max.x() - min.x(), max.y() - min.y());
return rect;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename T>
bool Rect<T>::segmentIntersect(const Vec2d& p1, const Vec2d& p2, Vec2d* intersect1, Vec2d* intersect2)
{
// Uses Liang-Barsky line clipping algorithm
// See http://stackoverflow.com/questions/99353/how-to-test-if-a-line-segment-intersects-an-axis-aligned-rectange-in-2d
CVF_ASSERT(intersect1);
CVF_ASSERT(intersect2);
if (!isValid()) return false;
double u1 = 0.0;
double u2 = 1.0;
double dx = p2.x() - p1.x();
double dy;
Vec2d maxPos = max();
if (clipTest(-dx, p1.x() - m_minPos.x(), &u1, &u2))
{
if (clipTest(dx, maxPos.x() - p1.x(), &u1, &u2))
{
dy = p2.y() - p1.y();
if (clipTest (-dy, p1.y() - m_minPos.y(), &u1, &u2))
{
if (clipTest (dy, maxPos.y() - p1.y(), &u1, &u2))
{
*intersect1 = p1;
*intersect2 = p2;
if (u2 < 1.0)
{
intersect2->x() = p1.x() + u2 * dx;
intersect2->y() = p1.y() + u2 * dy;
}
if (u1 > 0.0)
{
intersect1->x() += u1 * dx;
intersect1->y() += u1 * dy;
}
return true;
}
}
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename T>
bool Rect<T>::clipTest(double p, double q, double *u1, double *u2)
{
// Uses Liang-Barsky line clipping algorithm
// See also http://stackoverflow.com/questions/99353/how-to-test-if-a-line-segment-intersects-an-axis-aligned-rectange-in-2d
CVF_ASSERT(u1);
CVF_ASSERT(u2);
bool retval = true;
if (p < 0.0)
{
double r = q / p;
if (r > *u2)
{
retval = false;
}
else if (r > *u1)
{
*u1 = r;
}
}
else if (p > 0.0)
{
double r = q / p;
if (r < *u1)
{
retval = false;
}
else if (r < *u2)
{
*u2 = r;
}
}
else
{
// p = 0, so line is parallel to this clipping edge
if(q < 0.0)
{
// Line is outside clipping edge
retval = false;
}
}
return retval;
}
} // namespace cvf
} //namespace external

1553
external/resinsight/LibCore/cvfString.cpp vendored Normal file

File diff suppressed because it is too large Load Diff

142
external/resinsight/LibCore/cvfString.h vendored Normal file
View File

@@ -0,0 +1,142 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfCharArray.h"
#include <string>
namespace external {
namespace cvf {
//==================================================================================================
//
// A general unicode based string class
//
//==================================================================================================
class String
{
public:
String();
String(const std::string& str);
String(const std::wstring& str);
String(const String& str);
String(const char* str);
String(const wchar_t* str);
explicit String(char c);
explicit String(int number);
explicit String(int64_t number);
explicit String(uint number);
explicit String(float number);
explicit String(double number);
String& operator=(String rhs);
bool operator==(const String& rhs) const;
bool operator==(const wchar_t* rhs) const;
bool operator<(const String& rhs) const;
bool operator!=(const String& rhs) const;
const String operator+(const String& rhs) const;
String& operator+=(const String& rhs);
const wchar_t& operator[](size_t pos) const;
wchar_t& operator[](size_t pos);
String toLower() const;
String toUpper() const;
String trimmedRight() const;
String trimmedLeft() const;
String trimmed() const;
String simplified() const;
std::vector<String> split(const String& delimiters = " ") const;
size_t find(const String& str, size_t start = 0) const;
bool startsWith(const String& str) const;
String subString(size_t start, size_t length = npos) const;
void replace(const String& before, const String& after);
const wchar_t* c_str() const;
CharArray toAscii() const; // Useful when you need a const char* pointer.
std::string toStdString() const;
std::wstring toStdWString() const;
CharArray toUtf8() const;
static String fromAscii(const char* str, size_t strSize = npos);
static String fromUtf8(const char* str);
bool isEmpty() const;
size_t size() const;
void resize(size_t size);
static String number(float n, char format = 'g', int precision = -1);
static String number(double n, char format = 'g', int precision = -1);
double toDouble(bool* ok = NULL) const;
double toDouble(double defaultValue) const;
float toFloat(bool* ok = NULL) const;
float toFloat(float defaultValue) const;
int toInt(bool* ok = NULL) const;
int toInt(int defaultValue) const;
uint toUInt(bool* ok = NULL) const;
uint toUInt(uint defaultValue) const;
int64_t toInt64(bool* ok = NULL) const;
int64_t toInt64(int64_t defaultValue) const;
String arg(const String& a, int fieldWidth = 0, const wchar_t& fillChar = ' ') const;
String arg(char a, int fieldWidth = 0, const wchar_t& fillChar = ' ') const;
String arg(int a, int fieldWidth = 0, const wchar_t& fillChar = ' ') const;
String arg(int64_t a, int fieldWidth = 0, const wchar_t& fillChar = ' ') const;
String arg(uint a, int fieldWidth = 0, const wchar_t& fillChar = ' ') const;
String arg(float a, int fieldWidth = 0, char format = 'g', int precision = -1, const wchar_t& fillChar = ' ') const;
String arg(double a, int fieldWidth = 0, char format = 'g', int precision = -1, const wchar_t& fillChar = ' ') const;
void swap(String& other);
static const size_t npos; // Same as std::string::npos. This value, when used as the value for a count parameter n in string's member functions, roughly indicates "as many as possible".
// As a return value it is usually used to indicate failure.
private:
std::wstring m_string;
};
String operator+(const char* str1, const String& str2);
}
} //namespace external

View File

@@ -0,0 +1,320 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfSystem.h"
#include "cvfString.h"
#include <memory>
#include <cstring>
#include <cstdio>
#include <cstdarg>
namespace external {
namespace cvf {
//==================================================================================================
///
/// \class cvf::System
/// \ingroup Core
///
/// Static wrapper class for system functions
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
/// Check if we're running 64bit
//--------------------------------------------------------------------------------------------------
bool System::is64Bit()
{
return (sizeof(void*) == 8) ? true : false;
}
//--------------------------------------------------------------------------------------------------
/// Check if we are running on a big endian system.
///
/// \return Returns true if we're on big endian, false for little endian.
//--------------------------------------------------------------------------------------------------
bool System::isBigEndian()
{
int iInt = 1;
char* pcChar = reinterpret_cast<char*>(&iInt);
return !(*pcChar);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool System::memcpy(void* dst, size_t dstSizeInBytes, const void* src, size_t numBytesToCopy)
{
#if WIN32
// Debug version asserts
errno_t err = memcpy_s(dst, dstSizeInBytes, src, numBytesToCopy);
if (err == 0)
{
return true;
}
else
{
return false;
}
#else
if (!dst || dstSizeInBytes == 0 || !src)
{
// Be consistent with the behavior of memcpy_s.
return false;
}
if (numBytesToCopy > dstSizeInBytes)
{
// The source memory is too large to copy to the destination.
// To be consistent with memcpy_s, return false to indicate failure
return false;
}
::memcpy(dst, src, numBytesToCopy);
return true;
#endif
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool System::strcpy(char* strDestination, size_t maxNumElementsInDestination, const char* strSource)
{
#ifdef WIN32
// Debug version asserts
// Note that on windows the debug versions functions first fills the buffer with 0xFD
errno_t err = strcpy_s(strDestination, maxNumElementsInDestination, strSource);
if (err == 0)
{
return true;
}
else
{
return false;
}
#else
CVF_UNUSED(maxNumElementsInDestination);
::strcpy(strDestination, strSource);
return true;
#endif
}
//--------------------------------------------------------------------------------------------------
/// Append a string
///
/// \param strDestination Null-terminated destination string buffer
/// \param maxNumElementsInDestination Total size of the destination string buffer in characters
/// \param strSource Null-terminated source string buffer
//--------------------------------------------------------------------------------------------------
bool System::strcat(char* strDestination, size_t maxNumElementsInDestination, const char* strSource)
{
#ifdef WIN32
errno_t err = strcat_s(strDestination, maxNumElementsInDestination, strSource);
if (err == 0)
{
return true;
}
else
{
return false;
}
#else
if (!strDestination || maxNumElementsInDestination == 0 || !strSource)
{
// Be consistent with the behavior of strcat_s.
return false;
}
size_t dstLen = strlen(strDestination);
size_t srcLen = strlen(strSource);
size_t sumLen = srcLen + dstLen;
if (sumLen + 1 > maxNumElementsInDestination)
{
return false;
}
strncat(strDestination, strSource, srcLen);
strDestination[sumLen] = 0;
return true;
#endif
}
//--------------------------------------------------------------------------------------------------
/// Wrapper for sprintf
///
/// \param buffer The buffer to write into
/// \param maxNumElementsInBuffer Size of the buffer in number of characters
/// \param format Format string
///
/// \return Number of character written into buffer, excluding the terminating NULL character.
/// If the function fails the return is -1
///
/// Not that at most maxNumElementsInBuffer - 1 characters are ever written into the buffer since
/// a termination character is always written to the last position in the buffer.
//--------------------------------------------------------------------------------------------------
int System::sprintf(char* buffer, size_t maxNumElementsInBuffer, const char* format, ...)
{
if (!buffer || maxNumElementsInBuffer == 0 || !format)
{
return -1;
}
va_list argList;
va_start(argList, format);
#ifdef WIN32
int numWritten = vsnprintf_s(buffer, maxNumElementsInBuffer*sizeof(char), maxNumElementsInBuffer - 1, format, argList);
#else
int numWritten = vsnprintf(buffer, maxNumElementsInBuffer, format, argList);
// Linux will fill the buffer without adding a NULL
// Catch this and report as error
if (numWritten == static_cast<int>(maxNumElementsInBuffer))
{
numWritten = -1;
}
#endif
va_end(argList);
// Ensure buffer is NULL terminated
buffer[maxNumElementsInBuffer - 1] = '\0';
return numWritten;
}
//--------------------------------------------------------------------------------------------------
/// Wrapper for sprintf
///
/// \param buffer The buffer to write into
/// \param maxNumElementsInBuffer Size of the buffer in number of wide characters (not bytes)
/// \param format Format string
///
/// \return Number of wide character written into buffer, excluding the terminating NULL character.
/// If the function fails the return is -1
///
/// Not that at most maxNumElementsInBuffer - 1 characters are ever written into the buffer since
/// a termination character is always written to the last position in the buffer.
//--------------------------------------------------------------------------------------------------
int System::swprintf(wchar_t* buffer, size_t maxNumElementsInBuffer, const wchar_t* format, ...)
{
if (!buffer || maxNumElementsInBuffer == 0 || !format)
{
return -1;
}
va_list argList;
va_start(argList, format);
#ifdef WIN32
int numWritten = _vsnwprintf_s(buffer, maxNumElementsInBuffer, maxNumElementsInBuffer - 1, format, argList);
#else
int numWritten = vswprintf(buffer, maxNumElementsInBuffer, format, argList);
#endif
va_end(argList);
buffer[maxNumElementsInBuffer - 1] = L'\0';
return numWritten;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t System::strlen(const char* str)
{
if (str)
{
return ::strlen(str);
}
else
{
return 0;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int System::strcmp(const char* str1, const char* str2)
{
if (str1 == NULL || str2 == NULL)
{
if (str1 == NULL && str2 == NULL)
{
return 0;
}
if (str1 == NULL)
{
return -1;
}
else
{
return 1;
}
}
else
{
return ::strcmp(str1, str2);
}
}
} // namespace cvf
} //namespace external

65
external/resinsight/LibCore/cvfSystem.h vendored Normal file
View File

@@ -0,0 +1,65 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
namespace external {
namespace cvf {
//==================================================================================================
//
// Static wrapper class for system functions
//
//==================================================================================================
class System
{
public:
static bool is64Bit();
static bool isBigEndian();
static bool memcpy(void* dst, size_t dstSizeInBytes, const void* src, size_t numBytesToCopy);
static bool strcpy(char* strDestination, size_t maxNumElementsInDestination, const char* strSource);
static bool strcat(char* strDestination, size_t maxNumElementsInDestination, const char* strSource);
static int sprintf(char* buffer, size_t maxNumElementsInBuffer, const char* format, ...);
static int swprintf(wchar_t* buffer, size_t maxNumElementsInBuffer, const wchar_t* format, ...);
static size_t strlen(const char* str);
static int strcmp(const char* str1, const char* str2);
};
}
} //namespace external

View File

@@ -0,0 +1,63 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
namespace external {
namespace cvf {
//==================================================================================================
//
// Static wrapper class to control usage of TBB
//
//==================================================================================================
class TBBControl
{
public:
static void enable(bool enableTBB);
static bool isEnabled();
private:
static bool sm_useTBB;
};
} // cvf
} //namespace external

69
external/resinsight/LibCore/cvfTimer.h vendored Normal file
View File

@@ -0,0 +1,69 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfObject.h"
namespace external {
namespace cvf {
class PrivateTimerState;
//=================================================================================================
//
// Timer class
//
//=================================================================================================
class Timer : public Object
{
public:
Timer();
~Timer();
void restart();
double time() const;
double lapTime();
private:
PrivateTimerState* m_timerState;
};
}
} //namespace external

166
external/resinsight/LibCore/cvfTrace.cpp vendored Normal file
View File

@@ -0,0 +1,166 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfTrace.h"
#include "cvfSystem.h"
#ifdef WIN32
#pragma warning (push)
#pragma warning (disable: 4668)
#include <windows.h>
#pragma warning (pop)
#else
#include <cstdio>
#include <cstdarg>
#endif
#ifdef CVF_ANDROID
#include <android/log.h>
#endif
namespace external
{
namespace cvf {
//==================================================================================================
///
/// \class cvf::Trace
/// \ingroup Core
///
/// Class for writing debug text to console, DevStudio output window and file (future)
///
/// TODO: Create file output.
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
/// Write debug text to console, DevStudio output window and file (future)
//--------------------------------------------------------------------------------------------------
void Trace::show(String message)
{
showTraceOutput(message, true);
}
//--------------------------------------------------------------------------------------------------
/// Write printf formatted debug text to console, DevStudio output window and file (future)
//--------------------------------------------------------------------------------------------------
void Trace::show(const char* format, ...)
{
// Create the printf-style string and send it to the console and trace file
// TODO! Note: var-arg is solved locally here, but needs to be revisited e.g. in String class
va_list argList;
va_start(argList, format);
const int maxFormatLength = 4000;
char temp[maxFormatLength + 1];
#ifdef WIN32
_vsnprintf_s(temp, maxFormatLength, format, argList);
#elif defined(CVF_ANDROID)
__android_log_print(ANDROID_LOG_DEBUG, "CVF_TAG", format, argList);
#else
vsprintf(temp, format, argList);
#endif
va_end(argList);
showTraceOutput(temp, true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Trace::showFileLineNumber(const String& file, int line, const String& message)
{
String tmp = file + "(" + String(line) + ")";
if (!message.isEmpty())
{
tmp += ": msg: " + message;
}
Trace::show(tmp);
}
//--------------------------------------------------------------------------------------------------
/// Show the trace output in console and DevStudio output window
//--------------------------------------------------------------------------------------------------
void Trace::showTraceOutput(String text, bool addNewLine)
{
#ifdef WIN32
AllocConsole();
HANDLE hStdOutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
if (hStdOutputHandle)
{
unsigned long iDum = 0;
CharArray ascii = text.toAscii();
DWORD stringLength = static_cast<DWORD>(System::strlen(ascii.ptr()));
WriteConsoleA(hStdOutputHandle, ascii.ptr(), stringLength, &iDum, NULL);
if (addNewLine) WriteConsole(hStdOutputHandle, "\n", 1, &iDum, NULL);
}
#elif defined(CVF_ANDROID)
__android_log_print(ANDROID_LOG_DEBUG, "CVF_TAG", "%s", text.toAscii().ptr());
#else
fprintf(stderr, "%s", text.toAscii().ptr());
if (addNewLine)
{
fprintf(stderr, "\n");
}
#endif
// Show output in "Output window" in Visual Studio
#if defined(WIN32) && defined(_DEBUG)
// Alternativly use OutputDebugStringA(text.toAscii().ptr()); if this does not work on some platforms
_RPT0(_CRT_WARN, text.toAscii().ptr());
if (addNewLine)
{
_RPT0(_CRT_WARN, "\n");
}
#endif
}
} // namespace cvf
} // namespace external

69
external/resinsight/LibCore/cvfTrace.h vendored Normal file
View File

@@ -0,0 +1,69 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfString.h"
namespace external {
namespace cvf {
//=================================================================================================
//
// Trace class
//
//=================================================================================================
class Trace
{
public:
static void show(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);
};
}// namespace cvf
#define CVF_TRACE_FILELINE cvf::Trace::showFileLineNumber(__FILE__, __LINE__, "");
#define CVF_TRACE_FILELINE_MSG(message) cvf::Trace::showFileLineNumber(__FILE__, __LINE__, message);
} //namespace external

View File

@@ -0,0 +1,78 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfVector4.h"
#include "cvfColor4.h"
namespace external {
namespace cvf {
//==================================================================================================
//
// Abstract base class for templated read-only array that returns elements by value
//
//==================================================================================================
template <typename T>
class ValueArray
{
public:
virtual ~ValueArray() {}
virtual T val(size_t index) const = 0;
virtual size_t size() const = 0;
};
typedef ValueArray<int> IntValueArray;
typedef ValueArray<uint> UIntValueArray;
typedef ValueArray<ushort> UShortValueArray;
typedef ValueArray<ubyte> UByteValueArray;
typedef ValueArray<float> FloatValueArray;
typedef ValueArray<double> DoubleValueArray;
typedef ValueArray<Vec2f> Vec2fValueArray;
typedef ValueArray<Vec3f> Vec3fValueArray;
typedef ValueArray<Vec3d> Vec3dValueArray;
typedef ValueArray<Color3ub> Color3ubValueArray;
typedef ValueArray<Color3f> Color3fValueArray;
typedef ValueArray<Color4ub> Color4ubValueArray;
}
} //namespace external

137
external/resinsight/LibCore/cvfVector2.h vendored Normal file
View File

@@ -0,0 +1,137 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfMath.h"
#include <limits>
namespace external {
namespace cvf {
//==================================================================================================
//
// Vector class for 2D vectors
//
//==================================================================================================
template<typename S>
class Vector2
{
public:
Vector2();
Vector2(S x, S y);
Vector2(const Vector2& other);
template<typename T>
explicit Vector2(const T& other);
inline Vector2& operator=(const Vector2& rhs);
inline bool equals(const Vector2& other) const;
inline bool operator==(const Vector2& rhs) const;
inline bool operator!=(const Vector2& rhs) const;
inline void add(const Vector2& other);
inline void subtract(const Vector2& other);
inline const Vector2 operator+(const Vector2& rhs) const;
inline const Vector2 operator-(const Vector2& rhs) const;
inline Vector2& operator+=(const Vector2& rhs);
inline Vector2& operator-=(const Vector2& rhs);
inline const Vector2 operator-() const;
inline void scale(S scalar);
inline const Vector2 operator*(S scalar) const;
inline const Vector2 operator/(S scalar) const;
inline Vector2& operator*=(S scalar);
inline Vector2& operator/=(S scalar);
inline S dot(const Vector2& other) const;
inline S operator*(const Vector2& rhs) const; // Dot product
template<typename T>
void set(const T& other);
inline void set(S x, S y);
inline void setZero();
inline const S& x() const { return m_v[0]; } ///< Get the X element of the vector
inline const S& y() const { return m_v[1]; } ///< Get the Y element of the vector
inline S& x() { return m_v[0]; } ///< Get a reference to the X element of the vector. E.g. x() = 1;
inline S& y() { return m_v[1]; } ///< Get a reference to the Y element of the vector. E.g. y() = 2;
inline const S& operator[](int index) const; // Get component 0 or 1. E.g. x = v[0];
inline S& operator[](int index); // Set component 0 or 1. E.g. v[0] = x;
inline S* ptr() { return m_v; } ///< Get a raw pointer to the internal c array of type S.
inline const S* ptr() const { return m_v; } ///< Get a const raw pointer to the internal c array of type S.
inline bool isZero() const;
inline bool isUndefined() const;
bool normalize();
const Vector2 getNormalized(bool* normalizationOK = NULL) const;
inline S length() const;
inline S lengthSquared() const;
bool setLength(S newLength);
const Vector2 perpendicularVector() const;
public:
static const Vector2 X_AXIS; ///< X axis vector <1, 0>
static const Vector2 Y_AXIS; ///< Y axis vector <0, 1>
static const Vector2 ZERO; ///< Null vector <0, 0>
static const Vector2 UNDEFINED; ///< Undefined vector
private:
template<typename T>
friend const Vector2<T> operator*(T scalar, const Vector2<T>& rhs);
private:
S m_v[2];
};
typedef Vector2<float> Vec2f; ///< A vector with float components
typedef Vector2<double> Vec2d; ///< A vector with double components
typedef Vector2<int> Vec2i; ///< A vector with int components
typedef Vector2<uint> Vec2ui; ///< A vector with uint components
typedef Vector2<ushort> Vec2us; ///< A vector with ushort components
}
} //namespace external
#include "cvfVector2.inl"

View File

@@ -0,0 +1,534 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
namespace external {
namespace cvf {
//==================================================================================================
///
/// \class cvf::Vector2
/// \ingroup Core
///
/// Templated vector class for a 2 component vector.
///
/// Three ready-to-use typedefs are defined:\n
/// - cvf::Vec2f (Vector2<float>)
/// - cvf::Vec2d (Vector2<double>)
/// - cvf::Vec2i (Vector2<int>)
///
//==================================================================================================
template<typename S> Vector2<S> const Vector2<S>::X_AXIS(1, 0);
template<typename S> Vector2<S> const Vector2<S>::Y_AXIS(0, 1);
template<typename S> Vector2<S> const Vector2<S>::ZERO(0, 0);
//--------------------------------------------------------------------------------------------------
/// Default constructor.
//--------------------------------------------------------------------------------------------------
template<typename S>
Vector2<S>::Vector2()
{
m_v[0] = 0;
m_v[1] = 0;
}
//--------------------------------------------------------------------------------------------------
/// Set the vector to <x,y>
//--------------------------------------------------------------------------------------------------
template<typename S>
Vector2<S>::Vector2(S x, S y)
{
m_v[0] = x;
m_v[1] = y;
}
//--------------------------------------------------------------------------------------------------
/// Set the vector to the same as other
//--------------------------------------------------------------------------------------------------
template<typename S>
Vector2<S>::Vector2(const Vector2& other)
{
*this = other;
}
//--------------------------------------------------------------------------------------------------
/// An explicit cast constructor to convert from one vector type to another.
//--------------------------------------------------------------------------------------------------
template<typename S>
template<typename T>
Vector2<S>::Vector2(const T& other)
{
m_v[0] = static_cast<S>(other.x());
m_v[1] = static_cast<S>(other.y());
}
//--------------------------------------------------------------------------------------------------
/// Assign the vector to the contents of other
//--------------------------------------------------------------------------------------------------
template<typename S>
Vector2<S>& Vector2<S>::operator=(const Vector2& other)
{
m_v[0] = other.m_v[0];
m_v[1] = other.m_v[1];
return *this;
}
//--------------------------------------------------------------------------------------------------
/// Check if two vectors are equal. An exact match is required.
//--------------------------------------------------------------------------------------------------
template<typename S>
bool Vector2<S>::equals(const Vector2& other) const
{
return (*this == other);
}
//--------------------------------------------------------------------------------------------------
/// Check if two vectors are equal. An exact match is required.
//--------------------------------------------------------------------------------------------------
template<typename S>
inline bool Vector2<S>::operator==(const Vector2& rhs) const
{
return (m_v[0] == rhs.m_v[0]) && (m_v[1] == rhs.m_v[1]);
}
//--------------------------------------------------------------------------------------------------
/// Check if two vectors are different. Returns true if not an exact match
//--------------------------------------------------------------------------------------------------
template<typename S>
inline bool Vector2<S>::operator!=(const Vector2& rhs) const
{
return !operator==(rhs);
}
//--------------------------------------------------------------------------------------------------
/// Returns the sum of this vector and the rhs vector
//--------------------------------------------------------------------------------------------------
template<typename S>
inline const Vector2<S> Vector2<S>::operator+(const Vector2& rhs) const
{
return Vector2(m_v[0]+rhs.m_v[0], m_v[1]+rhs.m_v[1]);
}
//--------------------------------------------------------------------------------------------------
/// Adds the vector \a other to this vector
//--------------------------------------------------------------------------------------------------
template<typename S>
void Vector2<S>::add(const Vector2& other)
{
(*this) += other;
}
//--------------------------------------------------------------------------------------------------
/// Subtracts the vector \a other from this vector
//--------------------------------------------------------------------------------------------------
template<typename S>
void cvf::Vector2<S>::subtract(const Vector2& other)
{
(*this) -= other;
}
//--------------------------------------------------------------------------------------------------
/// Compute this-rhs and return the result.
//--------------------------------------------------------------------------------------------------
template<typename S>
inline const Vector2<S> Vector2<S>::operator-(const Vector2& rhs) const
{
return Vector2(m_v[0] - rhs.m_v[0], m_v[1] - rhs.m_v[1]);
}
//--------------------------------------------------------------------------------------------------
/// Scale this vector by the given scalar
//--------------------------------------------------------------------------------------------------
template<typename S>
void Vector2<S>::scale(S scalar)
{
(*this) *= scalar;
}
//--------------------------------------------------------------------------------------------------
/// Return this vector scaled by the given scalar
//--------------------------------------------------------------------------------------------------
template<typename S>
const Vector2<S> Vector2<S>::operator*(S scalar) const
{
return Vector2(m_v[0]*scalar, m_v[1]*scalar);
}
//--------------------------------------------------------------------------------------------------
/// Return vector scaled by the given scalar
//--------------------------------------------------------------------------------------------------
template<typename T>
const Vector2<T> operator*(T scalar, const Vector2<T>& rhs)
{
// Note that this is a friend function
return Vector2<T>(rhs.m_v[0]*scalar, rhs.m_v[1]*scalar);
}
//--------------------------------------------------------------------------------------------------
/// Return a vector where each component is the corresponding component in this divided by scalar
//--------------------------------------------------------------------------------------------------
template<typename S>
const Vector2<S> Vector2<S>::operator/(S scalar) const
{
return Vector2(m_v[0]/scalar, m_v[1]/scalar);
}
//--------------------------------------------------------------------------------------------------
/// Return a vector which is the negation of this
//--------------------------------------------------------------------------------------------------
template<typename S>
const Vector2<S> Vector2<S>::operator-() const
{
return Vector2(-m_v[0], -m_v[1]);
}
//--------------------------------------------------------------------------------------------------
/// Add the given vector to this
//--------------------------------------------------------------------------------------------------
template<typename S>
inline Vector2<S>& Vector2<S>::operator+=(const Vector2& v)
{
m_v[0] += v.x();
m_v[1] += v.y();
return *this;
}
//--------------------------------------------------------------------------------------------------
/// Subtract the given vector from this
//--------------------------------------------------------------------------------------------------
template<typename S>
inline Vector2<S>& Vector2<S>::operator-=(const Vector2& v)
{
m_v[0] -= v.x();
m_v[1] -= v.y();
return *this;
}
//--------------------------------------------------------------------------------------------------
/// Scale this with the given scalar. Each component is multiplied with the given value
//--------------------------------------------------------------------------------------------------
template<typename S>
inline Vector2<S>& Vector2<S>::operator*=(S scalar)
{
m_v[0] *= scalar;
m_v[1] *= scalar;
return *this;
}
//--------------------------------------------------------------------------------------------------
/// Divide this with the given scalar. Each component is divided by the given scalar
//--------------------------------------------------------------------------------------------------
template<typename S>
inline Vector2<S>& Vector2<S>::operator/=(S scalar)
{
m_v[0] /= scalar;
m_v[1] /= scalar;
return *this;
}
//--------------------------------------------------------------------------------------------------
/// Get component 0 or 1. E.g. x = v[0];
//--------------------------------------------------------------------------------------------------
template<typename S>
inline const S& Vector2<S>::operator[](int index) const
{
CVF_TIGHT_ASSERT(index >= 0);
CVF_TIGHT_ASSERT(index < 2);
return m_v[index];
}
//--------------------------------------------------------------------------------------------------
/// Set component 0 or 1. E.g. v[0] = x;
//--------------------------------------------------------------------------------------------------
template<typename S>
inline S& Vector2<S>::operator[](int index)
{
CVF_TIGHT_ASSERT(index >= 0);
CVF_TIGHT_ASSERT(index < 2);
return m_v[index];
}
//--------------------------------------------------------------------------------------------------
/// Compute the dot product of this and \a other
//--------------------------------------------------------------------------------------------------
template<typename S>
S Vector2<S>::dot(const Vector2& other) const
{
return (*this)*other;
}
//--------------------------------------------------------------------------------------------------
/// Compute the dot product of this and rhs and return the result (scalar)
///
/// Formula:
/// \code
/// S = tx*rx + ty*ry
/// \endcode
//--------------------------------------------------------------------------------------------------
template<typename S>
inline S Vector2<S>::operator*(const Vector2& rhs) const
{
return m_v[0]*rhs.m_v[0] + m_v[1]*rhs.m_v[1];
}
//--------------------------------------------------------------------------------------------------
/// Set the vector from the other vector (of different type). Cast each component to convert it.
//--------------------------------------------------------------------------------------------------
template<typename S>
template<typename T>
void Vector2<S>::set(const T& other)
{
m_v[0] = static_cast<S>(other.x());
m_v[1] = static_cast<S>(other.y());
}
//--------------------------------------------------------------------------------------------------
/// Get the length of the vector
///
/// Formula:
/// \code
/// len = sqrt(x*x + y*y)
/// \endcode
//--------------------------------------------------------------------------------------------------
template<typename S>
inline S Vector2<S>::length() const
{
return Math::sqrt(m_v[0]*m_v[0] + m_v[1]*m_v[1]);
}
//--------------------------------------------------------------------------------------------------
/// Get the squared length (L2) of the vector
///
/// Formula:
/// \code
/// len = x*x + y*y
/// \endcode
//--------------------------------------------------------------------------------------------------
template<typename S>
inline S Vector2<S>::lengthSquared() const
{
return m_v[0]*m_v[0] + m_v[1]*m_v[1];
}
//--------------------------------------------------------------------------------------------------
/// Set the length of the vector to \a newLength.
///
/// \sa Vector3::setLength()
//--------------------------------------------------------------------------------------------------
template<typename S>
bool Vector2<S>::setLength(S newLength)
{
CVF_ASSERT(newLength >= 0);
S currLen = length();
if (currLen > std::numeric_limits<S>::epsilon() && newLength > 0)
{
S scale = newLength/currLen;
m_v[0] *= scale;
m_v[1] *= scale;
return true;
}
else
{
setZero();
return (newLength == 0) ? true : false;
}
}
//--------------------------------------------------------------------------------------------------
/// Return a unit length perpendicular vector
///
/// Returns the vector (y,-x), normalized. This can be thought of as the 'right' vector.
//--------------------------------------------------------------------------------------------------
template<typename S>
const Vector2<S> Vector2<S>::perpendicularVector() const
{
S len = length();
if (len > 0.0)
{
S oneOverLen = (static_cast<S>(1.0)/len);
return Vector2<S>(m_v[1]*oneOverLen, -m_v[0]*oneOverLen);
}
else
{
return Vector2<S>::ZERO;
}
}
//--------------------------------------------------------------------------------------------------
/// Normalize the vector (make sure the length is 1.0).
///
/// \return Returns true if normalization was possible. Returns false if length is zero or a NaN vector.
//--------------------------------------------------------------------------------------------------
template<typename S>
bool Vector2<S>::normalize()
{
S len = length();
if (len > 0.0)
{
// Precompute 1/length and do multiplication instead of division
S oneOverLen = (static_cast<S>(1.0)/len);
m_v[0] *= oneOverLen;
m_v[1] *= oneOverLen;
return true;
}
else
{
// Might be NaN, so set it to zero
m_v[0] = 0;
m_v[1] = 0;
return false;
}
}
//--------------------------------------------------------------------------------------------------
/// Returns a normalized version of the current vector. The vector is unchanged.
//--------------------------------------------------------------------------------------------------
template<typename S>
const Vector2<S> Vector2<S>::getNormalized(bool* normalizationOK) const
{
S len = length();
if (len > 0.0)
{
if (normalizationOK) *normalizationOK = true;
S oneOverLen = (static_cast<S>(1.0)/len);
return Vector2<S>(m_v[0]*oneOverLen, m_v[1]*oneOverLen);
}
else
{
if (normalizationOK) *normalizationOK = false;
return Vector2<S>::ZERO;
}
}
//--------------------------------------------------------------------------------------------------
/// Set all components to 0
//--------------------------------------------------------------------------------------------------
template<typename S>
inline void Vector2<S>::setZero()
{
m_v[0] = 0;
m_v[1] = 0;
}
//--------------------------------------------------------------------------------------------------
/// Check if all components are zero (exact match)
//--------------------------------------------------------------------------------------------------
template<typename S>
inline bool Vector2<S>::isZero() const
{
return (m_v[0] == 0) && (m_v[1] == 0);
}
//--------------------------------------------------------------------------------------------------
/// Check if vector is undefined
///
/// \return Returns true if any one of the components is undefined
//--------------------------------------------------------------------------------------------------
template<typename S>
inline bool Vector2<S>::isUndefined() const
{
if (Math::isUndefined(m_v[0]) ||
Math::isUndefined(m_v[1]))
{
return true;
}
else
{
return false;
}
}
//--------------------------------------------------------------------------------------------------
/// Set the components of the vector
//--------------------------------------------------------------------------------------------------
template<typename S>
inline void Vector2<S>::set(S x, S y)
{
m_v[0] = x;
m_v[1] = y;
}
} // namespace cvf
} //namespace external

View File

@@ -0,0 +1,39 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfVector3.h"
namespace external {
namespace cvf {
template<> Vector3<double> const Vector3<double>::UNDEFINED(UNDEFINED_DOUBLE, UNDEFINED_DOUBLE, UNDEFINED_DOUBLE);
template<> Vector3<float> const Vector3<float>::UNDEFINED(UNDEFINED_FLOAT, UNDEFINED_FLOAT, UNDEFINED_FLOAT);
template<> Vector3<int> const Vector3<int>::UNDEFINED(UNDEFINED_INT, UNDEFINED_INT, UNDEFINED_INT);
template<> Vector3<size_t> const Vector3<size_t>::UNDEFINED(UNDEFINED_SIZE_T, UNDEFINED_SIZE_T, UNDEFINED_SIZE_T);
} // namespace cvf
} //namespace external

164
external/resinsight/LibCore/cvfVector3.h vendored Normal file
View File

@@ -0,0 +1,164 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfVector2.h"
namespace external {
namespace cvf {
// Forward declaration of templated matrix class
template<typename S>
class Matrix4;
template<typename S>
class Matrix3;
//==================================================================================================
//
// Vector class for 3D vectors
//
//==================================================================================================
template<typename S>
class Vector3
{
public:
Vector3();
Vector3(S x, S y, S z);
Vector3(const Vector3& other);
explicit Vector3(const Vector2<S>& other);
Vector3(const Vector2<S>& other, S z);
template<typename T>
explicit Vector3(const T& other);
inline Vector3& operator=(const Vector3& rhs);
inline bool equals(const Vector3& other) const;
inline bool operator==(const Vector3& rhs) const;
inline bool operator!=(const Vector3& rhs) const;
inline void add(const Vector3& other);
inline void subtract(const Vector3& other);
inline const Vector3 operator+(const Vector3& rhs) const;
inline const Vector3 operator-(const Vector3& rhs) const;
inline Vector3& operator+=(const Vector3& rhs);
inline Vector3& operator-=(const Vector3& rhs);
inline const Vector3 operator-() const;
inline void scale(S scalar);
inline const Vector3 operator*(S scalar) const;
inline const Vector3 operator/(S scalar) const;
inline Vector3& operator*=(S scalar);
inline Vector3& operator/=(S scalar);
inline S dot(const Vector3& other) const;
inline S operator*(const Vector3& rhs) const; // Dot product
inline void cross(const Vector3& v1, const Vector3& v2);
inline const Vector3 operator^(const Vector3& rhs) const; // Cross product
template<typename T>
void set(const T& other);
inline void set(S x, S y, S z);
inline void setZero();
inline const S& x() const { return m_v[0]; } ///< Get the X element of the vector
inline const S& y() const { return m_v[1]; } ///< Get the Y element of the vector
inline const S& z() const { return m_v[2]; } ///< Get the Z element of the vector
inline S& x() { return m_v[0]; } ///< Get a reference to the X element of the vector. E.g. x() = 1;
inline S& y() { return m_v[1]; } ///< Get a reference to the Y element of the vector. E.g. y() = 2;
inline S& z() { return m_v[2]; } ///< Get a reference to the Z element of the vector. E.g. z() = 3;
inline const S& operator[](int index) const; // Get component 0,1,2. E.g. x = v[0];
inline S& operator[](int index); // Set component 0,1,2. E.g. v[0] = x;
inline S* ptr() { return m_v; } ///< Get a raw pointer to the internal c array of type S.
inline const S* ptr() const { return m_v; } ///< Get a const raw pointer to the internal c array of type S.
inline bool isZero() const;
inline bool isUndefined() const;
bool normalize();
const Vector3 getNormalized(bool* normalizationOK = NULL) const;
inline S length() const;
inline S lengthSquared() const;
bool setLength(S newLength);
inline S pointDistance(const Vector3& otherPoint) const;
inline S pointDistanceSquared(const Vector3& otherPoint) const;
void transformPoint(const Matrix4<S>& m);
const Vector3 getTransformedPoint(const Matrix4<S>& m) const;
void transformVector(const Matrix4<S>& m);
const Vector3 getTransformedVector(const Matrix4<S>& m) const;
void transformVector(const Matrix3<S>& m);
const Vector3 getTransformedVector(const Matrix3<S>& m) const;
bool createOrthonormalBasis(int mapToAxis, Vector3<S>* uAxis, Vector3<S>* vAxis, Vector3<S>* wAxis) const;
const Vector3 perpendicularVector(bool* perpendicularOK = NULL) const;
public:
static const Vector3 X_AXIS; ///< X axis vector <1, 0, 0>
static const Vector3 Y_AXIS; ///< Y axis vector <0, 1, 0>
static const Vector3 Z_AXIS; ///< Z axis vector <0, 0, 1>
static const Vector3 ZERO; ///< Null vector <0, 0, 0>
static const Vector3 UNDEFINED; ///< Undefined vector
private:
template<typename T>
friend const Vector3<T> operator*(T scalar, const Vector3<T>& rhs);
private:
S m_v[3];
};
typedef Vector3<float> Vec3f; ///< A vector with float components
typedef Vector3<double> Vec3d; ///< A vector with double components
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
}
} //namespace external
#include "cvfVector3.inl"

View File

@@ -0,0 +1,800 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
namespace external {
namespace cvf {
//==================================================================================================
///
/// \class cvf::Vector3
/// \ingroup Core
///
/// Templated vector class for a 3 component vector.
///
/// Three ready-to-use typedefs are defined:\n
/// - cvf::Vec3f (Vector3<float>)
/// - cvf::Vec3d (Vector3<double>)
/// - cvf::Vec3i (Vector3<int>)
///
//==================================================================================================
template<typename S> Vector3<S> const Vector3<S>::X_AXIS(1,0,0);
template<typename S> Vector3<S> const Vector3<S>::Y_AXIS(0,1,0);
template<typename S> Vector3<S> const Vector3<S>::Z_AXIS(0,0,1);
template<typename S> Vector3<S> const Vector3<S>::ZERO(0,0,0);
//--------------------------------------------------------------------------------------------------
/// Default constructor.
//--------------------------------------------------------------------------------------------------
template<typename S>
Vector3<S>::Vector3()
{
m_v[0] = 0;
m_v[1] = 0;
m_v[2] = 0;
}
//--------------------------------------------------------------------------------------------------
/// Set the vector to <x,y,z>
//--------------------------------------------------------------------------------------------------
template<typename S>
Vector3<S>::Vector3(S x, S y, S z)
{
m_v[0] = x;
m_v[1] = y;
m_v[2] = z;
}
//--------------------------------------------------------------------------------------------------
/// Set the vector to the same as other
//--------------------------------------------------------------------------------------------------
template<typename S>
Vector3<S>::Vector3(const Vector3& other)
{
*this = other;
}
//--------------------------------------------------------------------------------------------------
/// An explicit cast constructor to convert from one vector type to another.
//--------------------------------------------------------------------------------------------------
template<typename S>
template<typename T>
Vector3<S>::Vector3(const T& other)
{
m_v[0] = static_cast<S>(other.x());
m_v[1] = static_cast<S>(other.y());
m_v[2] = static_cast<S>(other.z());
}
//--------------------------------------------------------------------------------------------------
/// Explicit constructor from 2D vector.
///
/// Will initialize x and y components from the 2D vector, z will be set to 0.
//--------------------------------------------------------------------------------------------------
template<typename S>
Vector3<S>::Vector3(const Vector2<S>& other)
{
m_v[0] = other.x();
m_v[1] = other.y();
m_v[2] = 0.0;
}
//--------------------------------------------------------------------------------------------------
/// Constructor
//--------------------------------------------------------------------------------------------------
template<typename S>
Vector3<S>::Vector3(const Vector2<S>& other, S z)
{
m_v[0] = other.x();
m_v[1] = other.y();
m_v[2] = z;
}
//--------------------------------------------------------------------------------------------------
/// Assign the vector to the contents of other
//--------------------------------------------------------------------------------------------------
template<typename S>
Vector3<S>& Vector3<S>::operator=(const Vector3& other)
{
m_v[0] = other.m_v[0];
m_v[1] = other.m_v[1];
m_v[2] = other.m_v[2];
return *this;
}
//--------------------------------------------------------------------------------------------------
/// Check if two vectors are equal. An exact match is required.
//--------------------------------------------------------------------------------------------------
template<typename S>
bool Vector3<S>::equals(const Vector3& other) const
{
return (*this == other);
}
//--------------------------------------------------------------------------------------------------
/// Check if two vectors are equal. An exact match is required.
//--------------------------------------------------------------------------------------------------
template<typename S>
inline bool Vector3<S>::operator==(const Vector3& rhs) const
{
return (m_v[0] == rhs.m_v[0]) && (m_v[1] == rhs.m_v[1]) && (m_v[2] == rhs.m_v[2]);
}
//--------------------------------------------------------------------------------------------------
/// Check if two vectors are different. Returns true if not an exact match
//--------------------------------------------------------------------------------------------------
template<typename S>
inline bool Vector3<S>::operator!=(const Vector3& rhs) const
{
return !operator==(rhs);
}
//--------------------------------------------------------------------------------------------------
/// Adds the vector \a other to this vector
//--------------------------------------------------------------------------------------------------
template<typename S>
void cvf::Vector3<S>::add(const Vector3& other)
{
(*this) += other;
}
//--------------------------------------------------------------------------------------------------
/// Subtracts the vector \a other from this vector
//--------------------------------------------------------------------------------------------------
template<typename S>
void cvf::Vector3<S>::subtract(const Vector3& other)
{
(*this) -= other;
}
//--------------------------------------------------------------------------------------------------
/// Returns the sum of this vector and the rhs vector
//--------------------------------------------------------------------------------------------------
template<typename S>
inline const Vector3<S> Vector3<S>::operator+(const Vector3& rhs) const
{
return Vector3(m_v[0]+rhs.m_v[0], m_v[1]+rhs.m_v[1], m_v[2]+rhs.m_v[2]);
}
//--------------------------------------------------------------------------------------------------
/// Compute this-rhs and return the result.
//--------------------------------------------------------------------------------------------------
template<typename S>
inline const Vector3<S> Vector3<S>::operator-(const Vector3& rhs) const
{
return Vector3(m_v[0] - rhs.m_v[0], m_v[1] - rhs.m_v[1], m_v[2] - rhs.m_v[2]);
}
//--------------------------------------------------------------------------------------------------
/// Scale this vector by the given scalar
//--------------------------------------------------------------------------------------------------
template<typename S>
void Vector3<S>::scale(S scalar)
{
(*this) *= scalar;
}
//--------------------------------------------------------------------------------------------------
/// Return this vector scaled by the given scalar
//--------------------------------------------------------------------------------------------------
template<typename S>
const Vector3<S> Vector3<S>::operator*(S scalar) const
{
return Vector3(m_v[0]*scalar, m_v[1]*scalar, m_v[2]*scalar);
}
//--------------------------------------------------------------------------------------------------
/// Return vector scaled by the given scalar
//--------------------------------------------------------------------------------------------------
template<typename T>
const Vector3<T> operator*(T scalar, const Vector3<T>& rhs)
{
// Note that this is a friend function
return Vector3<T>(rhs.m_v[0]*scalar, rhs.m_v[1]*scalar, rhs.m_v[2]*scalar);
}
//--------------------------------------------------------------------------------------------------
/// Return a vector where each component is the corresponding component in this divided by scalar
//--------------------------------------------------------------------------------------------------
template<typename S>
const Vector3<S> Vector3<S>::operator/(S scalar) const
{
return Vector3(m_v[0]/scalar, m_v[1]/scalar, m_v[2]/scalar);
}
//--------------------------------------------------------------------------------------------------
/// Return a vector which is the negation of this
//--------------------------------------------------------------------------------------------------
template<typename S>
const Vector3<S> Vector3<S>::operator-() const
{
return Vector3(-m_v[0], -m_v[1], -m_v[2]);
}
//--------------------------------------------------------------------------------------------------
/// Add the given vector to this
//--------------------------------------------------------------------------------------------------
template<typename S>
inline Vector3<S>& Vector3<S>::operator+=(const Vector3& v)
{
m_v[0] += v.x();
m_v[1] += v.y();
m_v[2] += v.z();
return *this;
}
//--------------------------------------------------------------------------------------------------
/// Subtract the given vector from this
//--------------------------------------------------------------------------------------------------
template<typename S>
inline Vector3<S>& Vector3<S>::operator-=(const Vector3& v)
{
m_v[0] -= v.x();
m_v[1] -= v.y();
m_v[2] -= v.z();
return *this;
}
//--------------------------------------------------------------------------------------------------
/// Scale this with the given scalar. Each component is multiplied with the given value
//--------------------------------------------------------------------------------------------------
template<typename S>
inline Vector3<S>& Vector3<S>::operator*=(S scalar)
{
m_v[0] *= scalar;
m_v[1] *= scalar;
m_v[2] *= scalar;
return *this;
}
//--------------------------------------------------------------------------------------------------
/// Divide this with the given scalar. Each component is divided by the given scalar
//--------------------------------------------------------------------------------------------------
template<typename S>
inline Vector3<S>& Vector3<S>::operator/=(S scalar)
{
m_v[0] /= scalar;
m_v[1] /= scalar;
m_v[2] /= scalar;
return *this;
}
//--------------------------------------------------------------------------------------------------
/// Get component 0,1,2. E.g. x = v[0];
//--------------------------------------------------------------------------------------------------
template<typename S>
inline const S& Vector3<S>::operator[](int index) const
{
CVF_TIGHT_ASSERT(index >= 0);
CVF_TIGHT_ASSERT(index < 3);
return m_v[index];
}
//--------------------------------------------------------------------------------------------------
/// Set component 0,1,2. E.g. v[0] = x;
//--------------------------------------------------------------------------------------------------
template<typename S>
inline S& Vector3<S>::operator[](int index)
{
CVF_TIGHT_ASSERT(index >= 0);
CVF_TIGHT_ASSERT(index < 3);
return m_v[index];
}
//--------------------------------------------------------------------------------------------------
/// Compute the dot product of this and \a other
//--------------------------------------------------------------------------------------------------
template<typename S>
S Vector3<S>::dot(const Vector3& other) const
{
return (*this)*other;
}
//--------------------------------------------------------------------------------------------------
/// Compute the dot product of this and rhs and return the result (scalar)
///
/// Formula:
/// \code
/// S = tx*rx + ty*ry + tz*rz
/// \endcode
//--------------------------------------------------------------------------------------------------
template<typename S>
inline S Vector3<S>::operator*(const Vector3& rhs) const
{
return m_v[0]*rhs.m_v[0] + m_v[1]*rhs.m_v[1] + m_v[2]*rhs.m_v[2];
}
//--------------------------------------------------------------------------------------------------
/// Sets this vector to the cross product of vectors \a v1 and \a v2
//--------------------------------------------------------------------------------------------------
template<typename S>
void cvf::Vector3<S>::cross(const Vector3& v1, const Vector3& v2)
{
*this = v1 ^ v2;
}
//--------------------------------------------------------------------------------------------------
/// Compute the cross product of this and rhs and return the result (vector)
///
/// Formula:
/// \code
/// vec = <ty*rz - tz*ry, tz*rx - tx*rz, tx*ry - ty*rx>
/// \endcode
//--------------------------------------------------------------------------------------------------
template<typename S>
inline const Vector3<S> Vector3<S>::operator^(const Vector3& rhs) const
{
return Vector3(m_v[1]*rhs.m_v[2] - m_v[2]*rhs.m_v[1], m_v[2]*rhs.m_v[0] - m_v[0]*rhs.m_v[2], m_v[0]*rhs.m_v[1] - m_v[1]*rhs.m_v[0]);
}
//--------------------------------------------------------------------------------------------------
/// Set the vector from the other vector (of different type). Cast each component to convert it.
//--------------------------------------------------------------------------------------------------
template<typename S>
template<typename T>
void Vector3<S>::set(const T& other)
{
m_v[0] = static_cast<S>(other.x());
m_v[1] = static_cast<S>(other.y());
m_v[2] = static_cast<S>(other.z());
}
//--------------------------------------------------------------------------------------------------
/// Get the length of the vector
///
/// Formula:
/// \code
/// len = sqrt(x*x + y*y + z*z)
/// \endcode
//--------------------------------------------------------------------------------------------------
template<typename S>
inline S Vector3<S>::length() const
{
return Math::sqrt(m_v[0]*m_v[0] + m_v[1]*m_v[1] + m_v[2]*m_v[2]);
}
//--------------------------------------------------------------------------------------------------
/// Get the squared length (L2) of the vector
///
/// Formula:
/// \code
/// len = x*x + y*y + z*z
/// \endcode
//--------------------------------------------------------------------------------------------------
template<typename S>
inline S Vector3<S>::lengthSquared() const
{
return m_v[0]*m_v[0] + m_v[1]*m_v[1] + m_v[2]*m_v[2];
}
//--------------------------------------------------------------------------------------------------
/// Set the length of the vector to \a newLength.
///
/// \return The method returns true if scaling was a success. Returns false if the vector was of
/// zero length and \a newLength was different from 0.
///
/// This is the same as calling normalize() and then scaling with \a newLength.
/// If the current vector length is 0 or \a newLength is 0, the vector is set to all zeros.
//--------------------------------------------------------------------------------------------------
template<typename S>
bool Vector3<S>::setLength(S newLength)
{
CVF_ASSERT(newLength >= 0);
S currLen = length();
if (currLen > std::numeric_limits<S>::epsilon() && newLength > 0)
{
S scale = newLength/currLen;
m_v[0] *= scale;
m_v[1] *= scale;
m_v[2] *= scale;
return true;
}
else
{
setZero();
return (newLength == 0) ? true : false;
}
}
//--------------------------------------------------------------------------------------------------
/// Get the distance between this point and the point specified in \a otherPoint
//--------------------------------------------------------------------------------------------------
template<typename S>
inline S Vector3<S>::pointDistance(const Vector3& otherPoint) const
{
return Math::sqrt(pointDistanceSquared(otherPoint));
}
//--------------------------------------------------------------------------------------------------
/// Get the squared distance between this point and the point specified in \a otherPoint
//--------------------------------------------------------------------------------------------------
template<typename S>
inline S Vector3<S>::pointDistanceSquared(const Vector3& otherPoint) const
{
S x = otherPoint.m_v[0] - m_v[0];
S y = otherPoint.m_v[1] - m_v[1];
S z = otherPoint.m_v[2] - m_v[2];
return (x*x + y*y + z*z);
}
//--------------------------------------------------------------------------------------------------
/// Normalize the vector (make sure the length is 1.0).
///
/// \return Returns true if normalization was possible. Returns false if length is zero or a NaN vector.
//--------------------------------------------------------------------------------------------------
template<typename S>
bool Vector3<S>::normalize()
{
S len = length();
if (len > 0.0)
{
// Precompute 1/length and do multiplication instead of division
S oneOverLen = (static_cast<S>(1.0)/len);
m_v[0] *= oneOverLen;
m_v[1] *= oneOverLen;
m_v[2] *= oneOverLen;
return true;
}
else
{
// Might be NaN, so set it to zero
m_v[0] = 0;
m_v[1] = 0;
m_v[2] = 0;
return false;
}
}
//--------------------------------------------------------------------------------------------------
/// Returns a normalized version of the current vector. The vector is unchanged.
//--------------------------------------------------------------------------------------------------
template<typename S>
const Vector3<S> Vector3<S>::getNormalized(bool* normalizationOK) const
{
S len = length();
if (len > 0.0)
{
if (normalizationOK) *normalizationOK = true;
S oneOverLen = (static_cast<S>(1.0)/len);
return Vector3<S>(m_v[0]*oneOverLen, m_v[1]*oneOverLen, m_v[2]*oneOverLen);
}
else
{
if (normalizationOK) *normalizationOK = false;
return Vector3<S>::ZERO;
}
}
//--------------------------------------------------------------------------------------------------
/// Set all components to 0
//--------------------------------------------------------------------------------------------------
template<typename S>
inline void Vector3<S>::setZero()
{
m_v[0] = 0;
m_v[1] = 0;
m_v[2] = 0;
}
//--------------------------------------------------------------------------------------------------
/// Check if all components are zero (exact match)
//--------------------------------------------------------------------------------------------------
template<typename S>
inline bool Vector3<S>::isZero() const
{
return (m_v[0] == 0) && (m_v[1] == 0) && (m_v[2] == 0);
}
//--------------------------------------------------------------------------------------------------
/// Check if vector is undefined
///
/// \return Returns true if any one of the components is undefined
//--------------------------------------------------------------------------------------------------
template<typename S>
inline bool Vector3<S>::isUndefined() const
{
if (Math::isUndefined(m_v[0]) ||
Math::isUndefined(m_v[1]) ||
Math::isUndefined(m_v[2]))
{
return true;
}
else
{
return false;
}
}
//--------------------------------------------------------------------------------------------------
/// Set the components of the vector
//--------------------------------------------------------------------------------------------------
template<typename S>
inline void Vector3<S>::set(S x, S y, S z)
{
m_v[0] = x;
m_v[1] = y;
m_v[2] = z;
}
//--------------------------------------------------------------------------------------------------
/// Transforms this vector as a point.
///
/// Transforms this vector as a point by multiplying it with the passed matrix.
/// This will both rotate and translate this.
/// Assumes the matrix m doesn't contain any perspective projection
//--------------------------------------------------------------------------------------------------
template<typename S>
void Vector3<S>::transformPoint(const Matrix4<S>& m)
{
const S* pV = m.ptr();
S valX = pV[0]*x() + pV[4]*y() + pV[8]*z() + pV[12];
S valY = pV[1]*x() + pV[5]*y() + pV[9]*z() + pV[13];
S valZ = pV[2]*x() + pV[6]*y() + pV[10]*z() + pV[14];
x() = valX;
y() = valY;
z() = valZ;
}
//--------------------------------------------------------------------------------------------------
/// Return this vector transformed as a point (rotation and translation) with the given matrix.
/// \sa
/// transformPoint
//--------------------------------------------------------------------------------------------------
template<typename S>
const Vector3<S> Vector3<S>::getTransformedPoint(const Matrix4<S>& m) const
{
Vector3<S> pt(*this);
pt.transformPoint(m);
return pt;
}
//--------------------------------------------------------------------------------------------------
/// Transforms this vector as a vector.
///
/// Transforms this vector as a vector by multiplying it with the passed matrix.
/// This will only rotate the vector, but not consider the translation part of the matrix.
/// Assumes the matrix m doesn't contain any perspective projection.
//--------------------------------------------------------------------------------------------------
template<typename S>
void Vector3<S>::transformVector(const Matrix4<S>& m)
{
const S* pV = m.ptr();
S valX = pV[0]*x() + pV[4]*y() + pV[8]*z();
S valY = pV[1]*x() + pV[5]*y() + pV[9]*z();
S valZ = pV[2]*x() + pV[6]*y() + pV[10]*z();
x() = valX;
y() = valY;
z() = valZ;
}
//--------------------------------------------------------------------------------------------------
/// Return this vector transformed as a vector (rotation only) with the given matrix.
/// \sa
/// transformVector
//--------------------------------------------------------------------------------------------------
template<typename S>
const Vector3<S> Vector3<S>::getTransformedVector(const Matrix4<S>& m) const
{
Vector3<S> vec(*this);
vec.transformVector(m);
return vec;
}
//--------------------------------------------------------------------------------------------------
/// Transforms this vector.
///
/// Transforms this vector by multiplying it with the passed matrix.
//--------------------------------------------------------------------------------------------------
template<typename S>
void Vector3<S>::transformVector(const Matrix3<S>& m)
{
const S* pV = m.ptr();
S valX = pV[0]*x() + pV[3]*y() + pV[6]*z();
S valY = pV[1]*x() + pV[4]*y() + pV[7]*z();
S valZ = pV[2]*x() + pV[5]*y() + pV[8]*z();
x() = valX;
y() = valY;
z() = valZ;
}
//--------------------------------------------------------------------------------------------------
/// Return this vector transformed with the given matrix.
/// \sa
/// transformVector
//--------------------------------------------------------------------------------------------------
template<typename S>
const Vector3<S> Vector3<S>::getTransformedVector(const Matrix3<S>& m) const
{
Vector3<S> vec(*this);
vec.transformVector(m);
return vec;
}
//----------------------------------------------------------------------------------------------------
/// Create an orthonormal basis from this vector
///
/// \param mapToAxis Specifies which axis this vector should be mapped onto (0=u, 1=v, 2=w)
/// \param uAxis Output u vector
/// \param vAxis Output v vector
/// \param wAxis Output w vector
///
/// Will create an orthonormal basis from this vector. The returned u, v and w axes will all be unit
/// length and will be perpendicular to each other.
/// The vector does not have to be normalized before calling this function.
//----------------------------------------------------------------------------------------------------
template<typename S>
bool Vector3<S>::createOrthonormalBasis(int mapToAxis, Vector3<S>* uAxis, Vector3<S>* vAxis, Vector3<S>* wAxis) const
{
bool normalizedOK = false;
Vector3<S> W = getNormalized(&normalizedOK);
if (!normalizedOK)
{
return false;
}
Vector3<S> U(0, 0, 0);
if (Math::abs(W.x()) >= Math::abs(W.y()))
{
// W.x or W.z component has largest magnitude
S length = Math::sqrt(W.x()*W.x() + W.z()*W.z());
U.x() = -W.z()/length;
U.y() = 0.0;
U.z() = +W.x()/length;
}
else
{
// W.y or W.z component has largest magnitude
S length = Math::sqrt(W.y()*W.y() + W.z()*W.z());
U.x() = 0.0;
U.y() = +W.z()/length;
U.z() = -W.y()/length;
}
// Get V as cross product of WxU
// Could be optimized by taking into account the fact that either the y or x component of U will be 0
Vector3<S> V = W^U;
// Algorithm above maps our vector onto W axis
// If another axis is requested, we need to shuffle the vectors
if (mapToAxis == 0)
{
if (uAxis) *uAxis = W;
if (vAxis) *vAxis = U;
if (wAxis) *wAxis = V;
}
else if (mapToAxis == 1)
{
if (uAxis) *uAxis = V;
if (vAxis) *vAxis = W;
if (wAxis) *wAxis = U;
}
else
{
if (uAxis) *uAxis = U;
if (vAxis) *vAxis = V;
if (wAxis) *wAxis = W;
}
return true;
}
//--------------------------------------------------------------------------------------------------
/// Return a unit length perpendicular vector
//--------------------------------------------------------------------------------------------------
template<typename S>
const Vector3<S> Vector3<S>::perpendicularVector(bool* perpendicularOK) const
{
Vector3<S> perpendic(0, 0, 0);
bool ok = createOrthonormalBasis(0, NULL, &perpendic, NULL);
if (perpendicularOK)
{
*perpendicularOK = ok;
}
return perpendic;
}
} // namespace cvf
} //namespace external

130
external/resinsight/LibCore/cvfVector4.h vendored Normal file
View File

@@ -0,0 +1,130 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfVector3.h"
namespace external {
namespace cvf {
//==================================================================================================
//
// Vector class for 3D vectors
//
//==================================================================================================
template<typename S>
class Vector4
{
public:
Vector4() {}
Vector4(S x, S y, S z, S w);
Vector4(const Vector4& other);
Vector4(const Vector3<S>& other, S w);
template<typename T>
explicit Vector4(const T& other);
inline Vector4& operator=(const Vector4& rhs);
inline bool equals(const Vector4& other) const;
inline bool operator==(const Vector4& rhs) const;
inline bool operator!=(const Vector4& rhs) const;
inline void add(const Vector4& other);
inline void subtract(const Vector4& other);
inline const Vector4 operator+(const Vector4& rhs) const;
inline const Vector4 operator-(const Vector4& rhs) const;
inline Vector4& operator+=(const Vector4& rhs);
inline Vector4& operator-=(const Vector4& rhs);
inline const Vector4 operator-() const;
inline void scale(S scalar);
inline const Vector4 operator*(S scalar) const;
inline const Vector4 operator/(S scalar) const;
inline Vector4& operator*=(S scalar);
inline Vector4& operator/=(S scalar);
inline S dot(const Vector4& other) const;
inline S operator*(const Vector4& rhs) const; // Dot product
template<typename T>
void set(const T& other);
inline void set(S x, S y, S z, S w);
inline void setZero();
inline const S& x() const { return m_v[0]; } ///< Get the X element of the vector
inline const S& y() const { return m_v[1]; } ///< Get the Y element of the vector
inline const S& z() const { return m_v[2]; } ///< Get the Z element of the vector
inline const S& w() const { return m_v[3]; } ///< Get the W element of the vector
inline S& x() { return m_v[0]; } ///< Get a reference to the X element of the vector. E.g. x() = 1;
inline S& y() { return m_v[1]; } ///< Get a reference to the Y element of the vector. E.g. y() = 2;
inline S& z() { return m_v[2]; } ///< Get a reference to the Z element of the vector. E.g. z() = 3;
inline S& w() { return m_v[3]; } ///< Get a reference to the W element of the vector. E.g. w() = 3;
inline const S& operator[](int index) const; // Get component 0,1,2,3. E.g. x = v[0];
inline S& operator[](int index); // Set component 0,1,2,3. E.g. v[0] = x;
inline S* ptr() { return m_v; } ///< Get a raw pointer to the internal c array of type S.
inline const S* ptr() const { return m_v; } ///< Get a const raw pointer to the internal c array of type S.
inline bool isZero() const;
bool normalize();
const Vector4 getNormalized(bool* normalizationOK = NULL) const;
inline S length() const;
inline S lengthSquared() const;
bool setLength(S newLength);
public:
static const Vector4 ZERO; ///< Null vector <0, 0, 0>
static const Vector4 UNDEFINED; ///< Undefined vector
private:
S m_v[4];
};
typedef Vector4<float> Vec4f; ///< A vector with float components
typedef Vector4<double> Vec4d; ///< A vector with double components
typedef Vector4<int> Vec4i; ///< A vector with int components
}
} //namespace external
#include "cvfVector4.inl"

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