Compare commits

..

114 Commits

Author SHA1 Message Date
Arne Morten Kvarving
fb5c72688c bump packaging versions for 2016.04-rc1 2016-04-22 10:08:44 +02:00
Atgeirr Flø Rasmussen
da601681ef Bumped version for release. 2016-04-21 14:12:49 +02:00
Atgeirr Flø Rasmussen
80b73cd862 Merge pull request #110 from akva2/update_for_16.04_packaging
Updates for 16.04 packaging
2016-04-18 10:57:11 +02:00
Arne Morten Kvarving
510687f073 update redhat packaging
- package library
- add new dependencies on boost
  uses boost 1.48 on rhel6. rhel7 supplies a newer boost by default.
- pkg-config file relocated since a library is now provided.
2016-04-18 10:49:55 +02:00
Arne Morten Kvarving
06816f344a update debian packaging
- package library
- pkg-config file relocated since a library is now provided.
- add new boost dependencies
2016-04-18 10:49:37 +02:00
Arne Morten Kvarving
e4da825eb3 changed: run all tests through mpirun
ubuntu 14.04 openmpi libs will crash in MPI_Finalize()
if not run through mpirun
2016-04-15 15:01:36 +02:00
Arne Morten Kvarving
323a8b4e86 added: support trilinos-branded zoltan 2016-04-15 15:01:36 +02:00
Atgeirr Flø Rasmussen
330bda4688 Merge pull request #106 from atgeirr/log-throws
Make OPM_THROW call OpmLog::error().
2016-04-12 10:15:33 +02:00
Atgeirr Flø Rasmussen
77779e5553 Merge pull request #109 from andlaus/refine_quadmath_detection
refine FindQuadmath.cmake
2016-04-12 10:02:06 +02:00
Andreas Lauser
8ccd328b87 refine FindQuadmath.cmake
with this, it is now possible to disable quadruple precision math
detection without hacks. (by setting USE_QUADMATH to ON or OFF)
2016-04-11 23:25:31 +02:00
Joakim Hove
4abdd148e3 Merge pull request #108 from akva2/add_opm_data_handler_script
add a jenkins script for setting up opm-data
2016-04-11 14:37:38 +02:00
Arne Morten Kvarving
ca95ed62da add a jenkins script for setting up opm-data
there are two modes:
- user supplies OPM_DATA_ROOT directly. in this case, the supplied
  directory is copied into the workspace and used.
- user supplies OPM_DATA_ROOT_PREDEFINED. in this case, the
  supplied path copied into the workspace unless a specific
  PR is defined in the trigger comment.
2016-04-11 14:16:15 +02:00
Joakim Hove
42a9be4ce0 Merge pull request #107 from atgeirr/rename-autodiff
Rename opm-autodiff -> opm-simulators.
2016-04-10 22:15:22 +02:00
Atgeirr Flø Rasmussen
9b5d81e358 Rename opm-autodiff -> opm-simulators. 2016-04-08 14:05:26 +02:00
Atgeirr Flø Rasmussen
3e125643f5 Make OPM_THROW call OpmLog::error(). 2016-04-08 12:52:50 +02:00
Atgeirr Flø Rasmussen
3c295815ad Merge pull request #104 from atgeirr/module-renaming
Module renaming
2016-04-06 15:37:39 +02:00
Atgeirr Flø Rasmussen
d789962a93 Rename in comment. 2016-04-06 11:58:36 +02:00
Arne Morten Kvarving
b08fbb0022 fixed: use shallow clones on jenkins 2016-04-06 10:06:27 +02:00
Arne Morten Kvarving
4ca84813ae changed: build all targets and not just the things that are actually tested 2016-04-05 15:31:28 +02:00
Atgeirr Flø Rasmussen
c2b36fa760 Fix Findopm-grid.cmake module. 2016-04-05 14:54:08 +02:00
Arne Morten Kvarving
62ed653905 fixed: don't build test suite for upstream modules on jenkins
i somehow forgot to set this option. accelerates build process significantly.
2016-04-05 11:27:28 +02:00
Atgeirr Flø Rasmussen
0eae093620 Rename dune-cornerpoint -> opm-grid. 2016-04-04 21:17:57 +02:00
Arne Morten Kvarving
4e537c376f fixed: have the test-suite target depend on the test data file targets 2016-04-04 15:28:57 +02:00
Arne Morten Kvarving
d34a09fb2c fixed: properly quote parameter 2016-04-04 13:45:09 +02:00
Arne Morten Kvarving
49b620c295 remove erronous space 2016-04-04 13:18:50 +02:00
Joakim Hove
98afe9a8a8 Merge pull request #99 from joakim-hove/add-opm-parser-requirement
Add opm-parser requirement.
2016-04-04 12:19:12 +02:00
Arne Morten Kvarving
9a03f6320b changed: replace explicit make invocations with cmake --build 2016-04-04 11:33:32 +02:00
Arne Morten Kvarving
b139530928 Merge pull request #102 from akva2/jenkins_reboot
Jenkins reboot
2016-04-04 10:29:34 +02:00
Arne Morten Kvarving
218771a16a added: jenkins build scripts 2016-04-04 09:21:44 +02:00
Bård Skaflestad
1d3db34972 Merge pull request #100 from atgeirr/add-output-to-upscaling
Make opm-output REQUIRED for opm-upscaling.
2016-04-01 10:47:18 +02:00
Atgeirr Flø Rasmussen
5d57af105e Remove warning-generating semicolon. 2016-04-01 08:06:45 +02:00
Atgeirr Flø Rasmussen
87ca6b4764 Switch dependency order. 2016-04-01 08:06:15 +02:00
Atgeirr Flø Rasmussen
09aa68b90f Merge pull request #101 from OPM/revert-98-fix_opm-material-prereqs.cmake
Revert "opm-material-prereqs.cmake: fix the ordering of the dependencies"
2016-03-31 17:28:45 +02:00
Atgeirr Flø Rasmussen
7dc2b70aac Revert "opm-material-prereqs.cmake: fix the ordering of the dependencies" 2016-03-31 17:27:30 +02:00
Atgeirr Flø Rasmussen
fe8870bb97 Make opm-output REQUIRED for opm-upscaling. 2016-03-31 17:24:42 +02:00
Joakim Hove
6afeebd717 Add opm-parser requirement. 2016-03-31 16:04:31 +02:00
Atgeirr Flø Rasmussen
15addc22b5 Merge pull request #98 from andlaus/fix_opm-material-prereqs.cmake
opm-material-prereqs.cmake: fix the ordering of the dependencies
2016-03-31 15:07:21 +02:00
Andreas Lauser
d48a318401 opm-material-prereqs.cmake: fix the ordering of the dependencies
packages marked REQUIRED must currently preceed optional ones. Also
C99 is not required by opm-material because that module only consists
of c++ code.
2016-03-31 14:50:33 +02:00
Atgeirr Flø Rasmussen
61d3e2011a Merge pull request #92 from joakim-hove/mark-opmcommon-REQUIERED
Mark opm-common as required.
2016-03-31 13:55:24 +02:00
Atgeirr Flø Rasmussen
a75c109c0d Merge pull request #91 from akva2/import_porsol
changed: drop opm-porsol
2016-03-31 13:52:28 +02:00
Atgeirr Flø Rasmussen
dd8af482f2 Merge pull request #89 from kjellkongsvik/opm_autodiff_requires_opm_output
opm-autodiff now dependant on opm-output
2016-03-31 09:42:27 +02:00
Joakim Hove
116d741c89 Merge pull request #97 from atgeirr/experimental-pointerfiddling
Use reference pointers for fast field access.
2016-03-29 13:16:02 +02:00
Atgeirr Flø Rasmussen
52ce54bc47 Use reference pointers for fast field access.
This is necessary in the short term to replace SimulatorState with this
class without performance loss.
2016-03-29 09:44:50 +02:00
Atgeirr Flø Rasmussen
942e90c809 Merge pull request #93 from joakim-hove/add-fPIC
Add global target property: POSITION_INDEPENDENT_CODE
2016-03-29 08:32:59 +02:00
Andreas Lauser
c2d047da0d Merge pull request #96 from andlaus/add_config_macros_for_ewoms
ewoms build files: add HAVE_* variables for all dune modules
2016-03-22 11:59:37 +01:00
Andreas Lauser
06f4603fd3 ewoms build files: add HAVE_* variables for all dune modules
The main reason for this is that it is good style to add HAVE_FOO
config.h variables for everything which was discovered, but it also
turns out that dune-fem is quite picky about the macros which
expects (and I recently fell on my nose because of this)...
2016-03-22 11:55:01 +01:00
Joakim Hove
07266344bc Set target property POSITION_INDEPENDENT_CODE=True 2016-03-22 11:37:03 +01:00
Joakim Hove
7b5d10be22 Merge pull request #95 from joakim-hove/travis-build-common-shared
Added +x for travis build script
2016-03-22 10:18:17 +01:00
Joakim Hove
ddeab7dc69 Added +x for travis build script 2016-03-22 10:17:10 +01:00
Joakim Hove
e3372780c4 Merge pull request #94 from joakim-hove/travis-build-common-shared
Added travis/build-opm-common-shared.sh
2016-03-22 10:11:24 +01:00
Joakim Hove
493fbf95c3 Added travis/build-opm-common-shared.sh 2016-03-22 10:06:22 +01:00
Joakim Hove
b8f1d2164c Mark opm-common as required. 2016-03-21 22:31:05 +01:00
Joakim Hove
985819fb2c Merge pull request #90 from chflo/move_log_functionality
Added log functionality from opm-parser
2016-03-21 22:14:12 +01:00
Arne Morten Kvarving
93a3343b69 changed: drop opm-porsol 2016-03-17 20:11:46 +01:00
chflo
73ad043006 Moved in logfunctionality from opm-parser 2016-03-17 15:23:18 +01:00
Kjell W. Kongsvik
9c825716da opm-autodiff now dependant on opm-output 2016-03-17 14:56:01 +01:00
Joakim Hove
0d3d46e199 Merge pull request #88 from kjellkongsvik/Move_OutputWriter_to_opm-output_safely
Move OutputWriter to opm-output
2016-03-16 13:38:50 +01:00
Kjell W. Kongsvik
855ed76b10 Move OutputWriter to opm-output
Findopm finds opmoutput
2016-03-16 12:42:10 +01:00
Arne Morten Kvarving
5e1a915f76 Merge pull request #85 from joakim-hove/opm-output
Added cmake files for opm-output.
2016-03-14 13:58:25 +01:00
Joakim Hove
b032fc0d05 Added cmake files for opm-output. 2016-03-14 13:43:32 +01:00
Atgeirr Flø Rasmussen
c47d20468f Merge pull request #84 from blattms/make-core-common-required
Make opm-core and opm-common a hard requirement.
2016-03-08 08:40:38 +01:00
Markus Blatt
7d3c1e17ba Make opm-core and opm-common a hard requirement.
Previously, cmake succeeded even if opm-core or opm-common was not found.
The cause for this was that dune-cornerpoint was searched for first. As
it was not required it seems like opm-common and opm-core were treated as
optional too.

This commit moves the opm modules to the opm section of the variable and
changes the order of the modules such that modules listed first do not
depend on modules listed afterwards. Now cmake fails if it cannot finy any
of the required modules.
2016-03-07 17:40:23 +01:00
Atgeirr Flø Rasmussen
03fc74d115 Merge pull request #83 from joakim-hove/non-const-celldata-access
Added non const cellData() access.
2016-03-03 12:43:44 +01:00
Joakim Hove
4958bc55f2 Added non const cellData() access. 2016-03-02 23:20:16 +01:00
Arne Morten Kvarving
812902ff9d Merge pull request #79 from andlaus/do_not_depend_on_boost_iostreams
remove the dependency on boost::iostreams if it is not used
2016-03-01 09:46:37 +01:00
Bård Skaflestad
b833f6c37d Merge pull request #82 from joakim-hove/reference
Added missing &reference symbol.
2016-02-29 09:19:51 -06:00
Joakim Hove
72c8a44dc9 Added missing &reference symbol. 2016-02-29 16:06:59 +01:00
Atgeirr Flø Rasmussen
83b88f143c Merge pull request #81 from joakim-hove/add-iterator
Add iterator
2016-02-29 11:23:01 +01:00
Joakim Hove
5d2469f18e Added global cell data access methods. 2016-02-29 11:17:16 +01:00
Joakim Hove
84a827e847 Added method to query for number of components. 2016-02-29 11:13:06 +01:00
Bård Skaflestad
32dbe00516 Merge pull request #80 from joakim-hove/add-const-overload
Added const overloads
2016-02-25 22:18:35 -06:00
Joakim Hove
5e63006285 Added const overloads 2016-02-25 21:52:08 +01:00
Andreas Lauser
77e7ed97c9 remove the dependency on boost::iostreams if it is not used
as far as I can see, it is not used in any module except opm-upscaling
and it caused the configure stage to fail if I tried to use with a
self-compiled boost 1.60 (which I have to do in order to use clang on
any modern linux distribution.)
2016-02-25 16:40:59 +01:00
Joakim Hove
fb0f00662c Merge pull request #78 from atgeirr/minor-fixes
Minor bugfix and silence a warning.
2016-02-19 14:46:00 +01:00
Atgeirr Flø Rasmussen
70d1831a76 Silence sign mismatch warning. 2016-02-19 14:21:11 +01:00
Atgeirr Flø Rasmussen
4547b5bf82 Bugfix: honor tolerance arguments. 2016-02-19 14:20:44 +01:00
Atgeirr Flø Rasmussen
af24ed82d3 Merge pull request #77 from joakim-hove/template-cmp
Implemented float comparison with templates
2016-02-19 11:41:00 +01:00
Atgeirr Flø Rasmussen
b8d18a6909 Merge pull request #76 from joakim-hove/set-state-component
Added SimulationDataContainer::setCellDataComponent()
2016-02-19 10:43:12 +01:00
Joakim Hove
25746bb500 Added SimulationDataContainer::setCellDataComponent() 2016-02-19 08:31:13 +01:00
Joakim Hove
3d2fa142e2 Changes ptr_equal -> array_equal 2016-02-19 07:54:21 +01:00
Joakim Hove
aeeaf9c342 Using #include <cmath> and std::fabs() 2016-02-19 07:50:18 +01:00
Joakim Hove
48f0513ca1 Implemented float comparison with templates 2016-02-17 21:59:08 +01:00
Atgeirr Flø Rasmussen
765cd77b68 Merge pull request #74 from joakim-hove/float-cmp
Added util/numeric/cmp.hpp
2016-02-12 10:15:49 +01:00
Joakim Hove
ee6836bd39 Added equal() method to SimulationDataContainer 2016-02-09 15:34:39 +01:00
Joakim Hove
d2ab19f318 Added util/numeric/cmp.cpp 2016-02-09 15:31:40 +01:00
Alf Birger Rustad
005b2d2df4 Merge pull request #71 from akva2/fix_sibling_build_thing
fixed: workaround if() bug in cmake
2016-02-08 12:00:35 +01:00
Joakim Hove
8b36c2a7d6 Merge pull request #73 from jepebe/travis
Added Travis status to README.md
2016-02-05 10:45:01 +01:00
Jean-Paul Balabanian
ae29bdef23 Added Travis status to README.md 2016-02-05 08:33:51 +01:00
Joakim Hove
2729a503de Merge pull request #72 from joakim-hove/install-fixup
Install fixup.
2016-02-04 16:33:10 +01:00
Joakim Hove
3469177532 Install fixup. 2016-02-04 16:31:44 +01:00
Andreas Lauser
5a98a919e4 Merge pull request #67 from joakim-hove/findert-update
Simplified FindERT module
2016-02-04 16:22:44 +01:00
Joakim Hove
69d3942e21 Merge pull request #68 from joakim-hove/datacontainer
SimulationDatacontainer
2016-02-04 15:57:45 +01:00
Joakim Hove
c5acc7561d Added methods to register cell and face data. 2016-02-04 14:30:26 +01:00
Joakim Hove
e486194996 Renamed DataContainer -> SimulationDataContainer. 2016-02-04 12:54:23 +01:00
Joakim Hove
05e319b62e Added probe for sibling find of utilxx/include. 2016-02-04 12:40:03 +01:00
Joakim Hove
8b6fb56e84 Simplified FindERT module 2016-02-04 12:40:03 +01:00
Atgeirr Flø Rasmussen
daa700ab9f Merge pull request #70 from jepebe/travis
Travis support
2016-02-04 10:27:25 +01:00
Jean-Paul Balabanian
000ad4ab48 Added Travis support 2016-02-04 06:34:38 +01:00
Arne Morten Kvarving
531449951d fixed: workaround if() bug in cmake
seems you cannot rely on the NOTFOUND postfix for compound if's
2016-02-03 14:44:53 +01:00
Joakim Hove
10213b025c Merge pull request #66 from joakim-hove/create-lib
Create library in opm-common
2016-02-02 10:06:16 +01:00
Joakim Hove
cb626c71b9 Ignore build/ directory at project root. 2016-02-01 10:33:35 +01:00
Joakim Hove
c8e8be6db9 Added library opm-common with DataContainer. 2016-02-01 10:33:34 +01:00
Andreas Lauser
ecc98ac321 Merge pull request #65 from dr-robertk/PR/fix-dune-alugrid-find
Finddune-alugrid: find the package when build with cmake or autotools
2016-01-29 20:24:15 +01:00
Robert Kloefkorn
40573e6c57 Finddune-alugrid: switch order of appearance. 2016-01-28 13:42:55 -07:00
Robert Kloefkorn
1269d918a2 Finddune-alugrid: find the package when build with cmake or autotools (libs differ) 2016-01-28 13:27:45 -07:00
Joakim Hove
4b16c76d2d Added opmcommon library in Findopm-common. 2016-01-26 13:29:27 +01:00
Arne Morten Kvarving
dc77753950 Merge pull request #64 from andlaus/squelch_cmp00054_warning
hack around CMake policy CMP00054
2015-11-18 10:29:42 +01:00
Andreas Lauser
9cd4a79b87 hack around CMake policy CMP00054
newer versions of cmake (mine is 3.2.2) complain about policy CMP00054:

```
CMake Warning (dev) at /home/and/src/opm-common/cmake/Modules/ConfigVars.cmake:30 (if):
  Policy CMP0054 is not set: Only interpret if() arguments as variables or
  keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
  details.  Use the cmake_policy command to set the policy and suppress this
  warning.

  Quoted variables like "FILE" will no longer be dereferenced when the policy
  is set to NEW.  Since the policy is not set the OLD behavior will be used.
Call Stack (most recent call first):
  /home/and/src/opm-common/cmake/Modules/OpmLibMain.cmake:173 (configure_vars)
  CMakeLists.txt:109 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.
```

since I'm pretty sure that the old behaviour was not intended here,
fix this for older versions of cmake as well (by adding a prefix so that
CMake does not interpret "FILE" as a variable.)
2015-11-17 17:36:11 +01:00
Atgeirr Flø Rasmussen
8fefe29e7c Merge pull request #58 from andlaus/fix_alugrid_libs
adapt Finddune-alugrid.cmake to the "paramerge" branch of dune-alugrid
2015-11-09 13:13:41 +01:00
dr-robertk
66d6d11bfd Merge pull request #61 from atgeirr/bump-version
Bump version and unify format of dune.module.
2015-10-23 15:06:44 +02:00
Atgeirr Flø Rasmussen
9a615468c5 Merge pull request #60 from atgeirr/improve-useversion
Improve the UseVersion module.
2015-10-23 13:37:38 +02:00
Atgeirr Flø Rasmussen
9265a695ea Bump version and unify format of dune.module. 2015-10-23 13:18:47 +02:00
Atgeirr Flø Rasmussen
6e1efc79af Improve the UseVersion module.
The changes are:
 - Add new macros PROJECT_VERSION_NAME and PROJECT_VERSION_HASH
   in addition to the existing PROJECT_VERSION.
 - Add header include guards.
2015-10-23 10:59:08 +02:00
Andreas Lauser
aebc12a227 adapt Finddune-alugrid.cmake to the "paramerge" branch of dune-alugrid 2015-10-21 17:58:58 +02:00
72 changed files with 2875 additions and 289 deletions

3
.gitignore vendored
View File

@@ -41,3 +41,6 @@ install_manifest.txt
CTestTestfile.cmake
DartConfiguration.tcl
Testing/
# Build directory in source.
build/

21
.travis.yml Normal file
View File

@@ -0,0 +1,21 @@
language: cpp
compiler:
- gcc
addons:
apt:
sources:
- boost-latest
- ubuntu-toolchain-r-test
packages:
- libboost1.55-all-dev
- gcc-4.8
- g++-4.8
- gfortran-4.8
before_script:
- export CXX="g++-4.8" CC="gcc-4.8" FC="gfortran-4.8"
- cd ..
script: opm-common/travis/build-and-test-opm-common.sh

View File

@@ -20,23 +20,27 @@
# you should only add to this list if the *user* of
# the library needs it.
# originally generated with the command:
# find opm -name '*.c*' -printf '\t%p\n' | sort
list (APPEND MAIN_SOURCE_FILES
opm/common/data/SimulationDataContainer.cpp
opm/common/OpmLog/CounterLog.cpp
opm/common/OpmLog/EclipsePRTLog.cpp
opm/common/OpmLog/LogBackend.cpp
opm/common/OpmLog/Logger.cpp
opm/common/OpmLog/LogUtil.cpp
opm/common/OpmLog/OpmLog.cpp
opm/common/OpmLog/StreamLog.cpp
opm/common/OpmLog/TimerLog.cpp
)
# originally generated with the command:
# find tests -name '*.cpp' -a ! -wholename '*/not-unit/*' -printf '\t%p\n' | sort
list (APPEND TEST_SOURCE_FILES
)
tests/test_SimulationDataContainer.cpp
tests/test_cmp.cpp
tests/test_OpmLog.cpp
)
# originally generated with the command:
# find tests -name '*.xml' -a ! -wholename '*/not-unit/*' -printf '\t%p\n' | sort
list (APPEND TEST_DATA_FILES
)
# originally generated with the command:
# find tutorials examples -name '*.c*' -printf '\t%p\n' | sort
list (APPEND EXAMPLE_SOURCE_FILES
)
@@ -49,5 +53,15 @@ list (APPEND PROGRAM_SOURCE_FILES
list( APPEND PUBLIC_HEADER_FILES
opm/common/ErrorMacros.hpp
opm/common/Exceptions.hpp
opm/common/data/SimulationDataContainer.hpp
opm/common/OpmLog/CounterLog.hpp
opm/common/OpmLog/EclipsePRTLog.hpp
opm/common/OpmLog/LogBackend.hpp
opm/common/OpmLog/Logger.hpp
opm/common/OpmLog/LogUtil.hpp
opm/common/OpmLog/OpmLog.hpp
opm/common/OpmLog/StreamLog.hpp
opm/common/OpmLog/TimerLog.hpp
opm/common/util/numeric/cmp.hpp
opm/common/utility/platform_dependent/disable_warnings.h
opm/common/utility/platform_dependent/reenable_warnings.h )
opm/common/utility/platform_dependent/reenable_warnings.h)

View File

@@ -1,3 +1,3 @@
# opm-common
Contains common components used througout all of OPM,
# opm-common ![alt text](https://travis-ci.org/OPM/opm-common.svg?branch=master "TravisCI Build Status")
Contains common components used throughout all of OPM,
in particular CMake modules for the build system.

View File

@@ -27,11 +27,10 @@
function (configure_vars obj syntax filename verb)
# this is just to make the syntax look like the build-in commands
if (NOT ("${obj}" STREQUAL "FILE" AND
if (NOT ("X Y Z ${obj}" STREQUAL "X Y Z FILE" AND
(("${verb}" STREQUAL "WRITE") OR ("${verb}" STREQUAL "APPEND"))))
message (FATAL_ERROR "Syntax error in argument list")
endif (NOT ("${obj}" STREQUAL "FILE" AND
(("${verb}" STREQUAL "WRITE") OR ("${verb}" STREQUAL "APPEND"))))
endif ()
if (NOT (("${syntax}" STREQUAL "CXX") OR ("${syntax}" STREQUAL "CMAKE")))
message (FATAL_ERROR "Invalid target syntax \"${syntax}\"")
endif (NOT (("${syntax}" STREQUAL "CXX") OR ("${syntax}" STREQUAL "CMAKE")))
@@ -67,14 +66,14 @@ function (configure_vars obj syntax filename verb)
# if the name of a variable has the syntax of a comments, write it
# verbatim to the file; this can be used to create headings
if ("${_var}" MATCHES "^/[/*]")
if ("X Y Z ${_var}" MATCHES "^X Y Z /[/*]")
if (NOT _prev_verbatim)
file (APPEND "${filename}" "\n")
endif (NOT _prev_verbatim)
file (APPEND "${filename}" "${_var}\n")
set (_prev_verbatim TRUE)
else ("${_var}" MATCHES "^/[/*]")
else ()
# write a CMake statements that warns if the value has changed
if ("${syntax}" STREQUAL "CMAKE")
@@ -106,6 +105,6 @@ function (configure_vars obj syntax filename verb)
endif ((NOT DEFINED ${_var}) OR ("${${_var}}" STREQUAL ""))
set (_prev_verbatim FALSE)
endif ("${_var}" MATCHES "^/[/*]")
endif ()
endforeach(_var)
endfunction (configure_vars obj syntax filename verb)

View File

@@ -62,6 +62,14 @@ find_path (ERT_UTIL_INCLUDE_DIR
DOC "Path to ERT Eclipse library header files"
${_no_default_path}
)
find_path (ERT_UTILXX_INCLUDE_DIR
NAMES "ert/util/ert_unique_ptr.hpp"
HINTS "${ERT_ROOT}"
PATHS "${PROJECT_SOURCE_DIR}/../ert"
PATH_SUFFIXES "devel/libert_utilxx/include/" "include"
DOC "Path to ERT Eclipse C++ library header files"
${_no_default_path}
)
find_path (ERT_GEN_INCLUDE_DIR
NAMES "ert/util/int_vector.h"
HINTS "${ERT_ROOT}"
@@ -143,6 +151,7 @@ list (APPEND ERT_INCLUDE_DIR
${ERT_ECL_WELL_INCLUDE_DIR}
${ERT_ECLXX_INCLUDE_DIR}
${ERT_UTIL_INCLUDE_DIR}
${ERT_UTILXX_INCLUDE_DIR}
${ERT_GEN_INCLUDE_DIR}
)
list (APPEND ERT_LIBRARY
@@ -170,36 +179,6 @@ if (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND")
return ()
endif (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND")
# these system variables are probed for, and used in HEADER files (sic)
list (APPEND ERT_CONFIG_VARS
HAVE_ISFINITE
HAVE_GLOB
HAVE_FORK
HAVE_GETUID
HAVE_LOCKF
HAVE_OPENDIR
HAVE_PROC
HAVE_READLINKAT
HAVE_SYMLINK
HAVE_VA_COPY
)
include (CheckSymbolExists)
include (CheckFunctionExists)
check_symbol_exists (isfinite math.h HAVE_ISFINITE)
check_function_exists (glob HAVE_GLOB)
check_function_exists (fork HAVE_FORK)
check_function_exists (getuid HAVE_GETUID)
check_function_exists (lockf HAVE_LOCKF)
check_function_exists (opendir HAVE_OPENDIR)
check_function_exists (readlinkat HAVE_READLINKAT)
check_function_exists (symlink HAVE_SYMLINK)
check_symbol_exists (va_copy stdarg.h HAVE_VA_COPY)
if (UNIX)
set (HAVE_PROC 1)
else (UNIX)
set (HAVE_PROC)
endif (UNIX)
# dependencies
@@ -221,6 +200,7 @@ if (BLAS_FOUND)
list (APPEND ERT_LIBRARIES ${BLAS_LIBRARIES})
list (APPEND ERT_LINKER_FLAGS ${BLAS_LINKER_FLAGS})
endif (BLAS_FOUND)
find_package (LAPACK ${ERT_QUIET})
if (LAPACK_FOUND)
list (APPEND ERT_INCLUDE_DIRS ${LAPACK_INCLUDE_DIRS})

View File

@@ -11,24 +11,34 @@ include(CheckCXXSourceCompiles)
include(CMakePushCheckState)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-Werror -fext-numeric-literals" HAVE_EXTENDED_NUMERIC_LITERALS)
if (HAVE_EXTENDED_NUMERIC_LITERALS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fext-numeric-literals")
endif()
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()
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_LIBRARIES "quadmath")
CHECK_CXX_SOURCE_COMPILES("
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;
}" HAVE_QUAD)
cmake_pop_check_state()
}" QUADMATH_FOUND)
cmake_pop_check_state()
if (HAVE_QUAD)
set(QUADMATH_LIBRARIES "quadmath")
if (QUADMATH_FOUND)
set(QUADMATH_LIBRARIES "quadmath")
set(HAVE_QUAD "${QUADMATH_FOUND}")
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)

View File

@@ -24,7 +24,7 @@ find_package(PTScotch)
find_path (ZOLTAN_INCLUDE_DIRS
NAMES "zoltan.h"
PATHS ${ZOLTAN_SEARCH_PATH}
PATH_SUFFIXES "include"
PATH_SUFFIXES include trilinos
${ZOLTAN_NO_DEFAULT_PATH})
# only search in architecture-relevant directory
@@ -33,7 +33,7 @@ if (CMAKE_SIZEOF_VOID_P)
endif (CMAKE_SIZEOF_VOID_P)
find_library(ZOLTAN_LIBRARIES
NAMES "zoltan"
NAMES zoltan trilinos_zoltan
PATHS ${ZOLTAN_SEARCH_PATH}
PATH_SUFFIXES "lib/.libs" "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
${ZOLTAN_NO_DEFAULT_PATH})

View File

@@ -11,6 +11,7 @@
# This code is licensed under The GNU General Public License v3.0
include (OpmPackage)
# find dune-alugrid when build with autotools (deprecated in dune 2.4 and removed after dune 3.0
find_opm_package (
# module name
"dune-alugrid"
@@ -21,7 +22,7 @@ find_opm_package (
# we just include them to forward here in case anyone else does
"CXX11Features REQUIRED;
dune-grid REQUIRED;
ZLIB REQUIRED;
ZLIB;
ZOLTAN;
METIS
"
@@ -29,13 +30,47 @@ find_opm_package (
"dune/alugrid/grid.hh"
# library to search for
"dunealugrid;alugrid_2d;alugrid_parallel;alugrid_serial"
"dunealugrid;alugrid_parallel;alugrid_serial"
# defines to be added to compilations
""
# test program
"#include <dune/alugrid/2d/indexsets.hh>
"#include <dune/alugrid/common/interfaces.hh>
int main (void) {
return 0;
}
"
# config variables
"HAVE_DUNE_ALUGRID
")
# find dune-alugrid when build with cmake
find_opm_package (
# module name
"dune-alugrid"
# 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
"CXX11Features REQUIRED;
dune-grid REQUIRED;
ZLIB;
ZOLTAN;
METIS
"
# header to search for
"dune/alugrid/grid.hh"
# library to search for
"dunealugrid"
# defines to be added to compilations
""
# test program
"#include <dune/alugrid/common/interfaces.hh>
int main (void) {
return 0;
}

View File

@@ -1,42 +0,0 @@
# - Find OPM corner-point grid library
#
# Defines the following variables:
# dune-cornerpoint_INCLUDE_DIRS Directory of header files
# dune-cornerpoint_LIBRARIES Directory of shared object files
# dune-cornerpoint_DEFINITIONS Defines that must be set to compile
# dune-cornerpoint_CONFIG_VARS List of defines that should be in config.h
# HAVE_DUNE_CORNERPOINT Binary value to use in config.h
# Copyright (C) 2013 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (dune-cornerpoint-prereqs)
include (OpmPackage)
find_opm_package (
# module name
"dune-cornerpoint"
# dependencies
"${dune-cornerpoint_DEPS}"
# header to search for
"dune/grid/CpGrid.hpp"
# library to search for
"dunecornerpoint"
# defines to be added to compilations
"HAVE_DUNE_CORNERPOINT"
# test program
"#include <dune/grid/CpGrid.hpp>
int main (void) {
Dune::CpGrid g;
return 0;
}
"
# config variables
"${dune-cornerpoint_CONFIG_VAR}"
)
#debug_find_vars ("dune-cornerpoint")

View File

@@ -24,7 +24,7 @@ find_opm_package (
"opm/common/utility/platform_dependent/disable_warnings.h"
# library to search for
""
"opmcommon"
# defines to be added to compilations
""

View File

@@ -0,0 +1,42 @@
# - Find OPM corner-point grid library
#
# Defines the following variables:
# opm-grid_INCLUDE_DIRS Directory of header files
# opm-grid_LIBRARIES Directory of shared object files
# opm-grid_DEFINITIONS Defines that must be set to compile
# opm-grid_CONFIG_VARS List of defines that should be in config.h
# HAVE_OPM_GRID Binary value to use in config.h
# Copyright (C) 2013 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (opm-grid-prereqs)
include (OpmPackage)
find_opm_package (
# module name
"opm-grid"
# dependencies
"${opm-grid_DEPS}"
# header to search for
"dune/grid/CpGrid.hpp"
# library to search for
"opmgrid"
# defines to be added to compilations
"HAVE_OPM_GRID"
# test program
"#include <dune/grid/CpGrid.hpp>
int main (void) {
Dune::CpGrid g;
return 0;
}
"
# config variables
"${opm-grid_CONFIG_VAR}"
)
#debug_find_vars ("opm-grid")

View File

@@ -0,0 +1,42 @@
# - Find OPM output library
#
# Defines the following variables:
# opm-output_INCLUDE_DIRS Directory of header files
# opm-output_LIBRARIES Directory of shared object files
# opm-output_DEFINITIONS Defines that must be set to compile
# opm-output_CONFIG_VARS List of defines that should be in config.h
# HAVE_OPM_OUTPUT Binary value to use in config.h
# Copyright (C) 2012 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
# use the generic find routine
include (opm-output-prereqs)
include (OpmPackage)
find_opm_package (
# module name
"opm-output"
# dependencies
"${opm-output_DEPS}"
# header to search for
"opm/output/OutputWriter.hpp"
# library to search for
"opmoutput"
# defines to be added to compilations
""
# test program
"#include <opm/output/OutputWriter.hpp>
int main (void) {
return 0;
}
"
# config variables
"${opm-output_CONFIG_VAR}"
)
include (UseDynamicBoost)
#debug_find_vars ("opm-output")

View File

@@ -1,42 +0,0 @@
# - Find OPM polymer library
#
# Defines the following variables:
# opm-polymer_INCLUDE_DIRS Directory of header files
# opm-polymer_LIBRARIES Directory of shared object files
# opm-polymer_DEFINITIONS Defines that must be set to compile
# opm-polymer_CONFIG_VARS List of defines that should be in config.h
# HAVE_OPM_POLYMER Binary value to use in config.h
# Copyright (C) 2013 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (opm-polymer-prereqs)
include (OpmPackage)
find_opm_package (
# module name
"opm-polymer"
# dependencies
"${opm-polymer_DEPS}"
# header to search for
"opm/polymer/PolymerState.hpp"
# library to search for
"opmpolymer"
# defines to be added to compilations
""
# test program
"#include <opm/polymer/PolymerState.hpp>
int main (void) {
Opm::PolymerState s;
return 0;
}
"
# config variables
"${opm-polymer_CONFIG_VAR}"
)
#debug_find_vars ("opm-polymer")

View File

@@ -1,41 +0,0 @@
# - Find OPM porous media solver library
#
# Defines the following variables:
# opm-porsol_INCLUDE_DIRS Directory of header files
# opm-porsol_LIBRARIES Directory of shared object files
# opm-porsol_DEFINITIONS Defines that must be set to compile
# opm-porsol_CONFIG_VARS List of defines that should be in config.h
# HAVE_OPM_PORSOL Binary value to use in config.h
# Copyright (C) 2013 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (opm-porsol-prereqs)
include (OpmPackage)
find_opm_package (
# module name
"opm-porsol"
# dependencies
"${opm-porsol_DEPS}"
# header to search for
"opm/porsol/mimetic/IncompFlowSolverHybrid.hpp"
# library to search for
"opmporsol"
# defines to be added to compilations
""
# test program
"#include <opm/porsol/mimetic/IncompFlowSolverHybrid.hpp>
int main (void) {
return 0;
}
"
# config variables
"${opm-porsol_CONFIG_VAR}"
)
#debug_find_vars ("opm-porsol")

View File

@@ -1,30 +1,30 @@
# - Find OPM automatic differentiation library
#
# Defines the following variables:
# opm-autodiff_INCLUDE_DIRS Directory of header files
# opm-autodiff_LIBRARIES Directory of shared object files
# opm-autodiff_DEFINITIONS Defines that must be set to compile
# opm-autodiff_CONFIG_VARS List of defines that should be in config.h
# HAVE_OPM_AUTODIFF Binary value to use in config.h
# opm-simulators_INCLUDE_DIRS Directory of header files
# opm-simulators_LIBRARIES Directory of shared object files
# opm-simulators_DEFINITIONS Defines that must be set to compile
# opm-simulators_CONFIG_VARS List of defines that should be in config.h
# HAVE_OPM_SIMULATORS Binary value to use in config.h
# Copyright (C) 2012 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
# use the generic find routine
include (opm-autodiff-prereqs)
include (opm-simulators-prereqs)
include (OpmPackage)
find_opm_package (
# module name
"opm-autodiff"
"opm-simulators"
# dependencies
"${opm-autodiff_DEPS}"
"${opm-simulators_DEPS}"
# header to search for
"opm/autodiff/AutoDiff.hpp"
# library to search for
"opmautodiff"
"opmsimulators"
# defines to be added to compilations
""
@@ -38,7 +38,7 @@ int main (void) {
}
"
# config variables
"${opm-autodiff_CONFIG_VAR}"
"${opm-simulators_CONFIG_VAR}"
)
include (UseDynamicBoost)
#debug_find_vars ("opm-autodiff")
#debug_find_vars ("opm-simulators")

View File

@@ -27,7 +27,8 @@ macro (opm_compile opm)
SOVERSION ${${opm}_VERSION_MAJOR}
VERSION ${${opm}_VERSION}
LINK_FLAGS "${${opm}_LINKER_FLAGS_STR}"
)
POSITION_INDEPENDENT_CODE TRUE
)
target_link_libraries (${${opm}_TARGET} ${${opm}_LIBRARIES})
if (STRIP_DEBUGGING_SYMBOLS)

View File

@@ -63,7 +63,7 @@ set (_opm_proj_exemptions
)
# although a DUNE module, it is delivered in the OPM suite
set (dune-cornerpoint_SUITE "opm")
set (opm-core_SUITE "opm")
set (ewoms_SUITE "opm")
# insert this boilerplate whenever we are going to find a new package
@@ -87,7 +87,7 @@ macro (find_and_append_package_to prefix name)
# module is part of a suite if it has name with the pattern xxx-yyy
if (("${name}" MATCHES "[^-]+-.+") OR ${name}_SUITE)
# allow to override if the module doesn't quite fit the convention
# e.g. dune-cornerpoint
# e.g. dune-cornerpoint (since renamed to opm-grid)
if (NOT DEFINED ${name}_SUITE)
# extract suite name from module
string (REGEX REPLACE "([^-]+)-.+" "\\1" ${name}_SUITE "${name}")

View File

@@ -69,7 +69,7 @@ function (opm_grid_type)
endfunction (opm_grid_type)
# write the grid type for dune-cornerpoint
# write the grid type for opm-grid
function (opm_cornerpoint_grid config_h)
opm_grid_type (
FILENAME ${CONFIG_H}

View File

@@ -25,19 +25,19 @@ set (KNOWN_VARS
)
set (KNOWN_opm_PKGS
autodiff
core
material
common
parser
polymer
porsol
material
core
grid
output
simulators
upscaling
verteq
)
set (KNOWN_dune_PKGS
common
cornerpoint
geometry
grid
istl

View File

@@ -98,7 +98,17 @@ macro (find_opm_package module deps header lib defs prog conf)
# to put the build-directories as siblings to the source trees,
# but with a -build suffix, DUNE likes to have the the build tree
# in a "build-cmake" sub-directory of each module
if (NOT (${module}_DIR OR ${module}_ROOT OR ${MODULE}_ROOT))
set(workaround_cmake_bug 0)
if(${module}_DIR})
set(workaround_cmake_bug 1)
endif()
if(${module}_ROOT})
set(workaround_cmake_bug 1)
endif()
if(${MODULE}_ROOT})
set(workaround_cmake_bug 1)
endif()
if (NOT workaround_cmake_bug)
string (TOLOWER "${module}" _module_lower)
set (_guess
"../${module}"
@@ -123,7 +133,7 @@ macro (find_opm_package module deps header lib defs prog conf)
list (APPEND _guess_bin "${PROJECT_BINARY_DIR}/${_item}")
endforeach (_item)
set (_no_system "")
else (NOT (${module}_DIR OR ${module}_ROOT OR ${MODULE}_ROOT))
else ()
# start looking at the paths in this order
set (_guess_bin
${${module}_DIR}
@@ -165,7 +175,7 @@ macro (find_opm_package module deps header lib defs prog conf)
# is a problem in our own specified directory, we don't necessarily
# want an old version that is left in one of the system paths!
set (_no_system "NO_DEFAULT_PATH")
endif (NOT (${module}_DIR OR ${module}_ROOT OR ${MODULE}_ROOT))
endif ()
# by specifying _guess in the HINTS section, it gets searched before
# the system locations as well. the CMake documentation has a cloudy

View File

@@ -84,6 +84,11 @@ macro (opm_compile_satellites opm satellite excl_all test_regexp)
endif ("${_sat_NAME}" MATCHES "${_regexp}")
endforeach (_regexp)
get_target_property (_sat_LOC ${_sat_NAME} LOCATION)
# Run tests through mpi-run. Ubuntu 14.04 provided mpi libs will crash
# in the MPI_Finalize() call otherwise.
if(MPI_FOUND)
set(_sat_LOC ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 1 ${_sat_LOC})
endif()
if (CMAKE_VERSION VERSION_LESS "2.8.4")
add_test (
NAME ${_sat_FANCY}
@@ -160,6 +165,10 @@ macro (opm_data satellite target dirname)
DEPENDS ${${satellite}_INPUT_FILES}
COMMENT "Making \"${satellite}\" data available in output tree"
)
if(NOT TARGET test-suite)
add_custom_target(test-suite)
endif()
add_dependencies(test-suite ${${satellite}_DATAFILES})
endmacro (opm_data satellite target dirname files)
# Add a single unit test (can be orchestrated by the 'ctest' command)

View File

@@ -92,13 +92,12 @@ opm_static_add_dependencies(dune-geometry dune-common)
opm_static_add_dependencies(dune-grid dune-geometry)
# OPM
foreach(opm_repo opm-common opm-parser opm-core dune-cornerpoint opm-material
opm-porsol opm-upscaling)
foreach(opm_repo opm-common opm-parser opm-core opm-output opm-grid opm-material
opm-upscaling)
opm_from_git(https://github.com/OPM/${opm_repo} ${opm_repo} ${OPM_BENCHMARK_VERSION})
endforeach()
opm_static_add_dependencies(opm-parser opm-common ert)
opm_static_add_dependencies(opm-core opm-parser dune-istl)
opm_static_add_dependencies(dune-cornerpoint opm-core dune-grid)
opm_static_add_dependencies(opm-grid opm-core dune-grid)
opm_static_add_dependencies(opm-material opm-core)
opm_static_add_dependencies(opm-porsol dune-cornerpoint opm-material)
opm_static_add_dependencies(opm-upscaling opm-porsol)
opm_static_add_dependencies(opm-upscaling opm-grid opm-material)

View File

@@ -9,6 +9,13 @@ set(DUNE_AVOID_CAPABILITIES_IS_PARALLEL_DEPRECATION_WARNING 1)
set (ewoms_CONFIG_VAR
HAVE_QUAD
HAVE_VALGRIND
HAVE_DUNE_COMMON
HAVE_DUNE_GEOMETRY
HAVE_DUNE_GRID
HAVE_DUNE_LOCALFUNCTIONS
HAVE_DUNE_ISTL
HAVE_DUNE_ALUGRID
HAVE_DUNE_FEM
DUNE_AVOID_CAPABILITIES_IS_PARALLEL_DEPRECATION_WARNING
)
@@ -22,10 +29,11 @@ set (ewoms_DEPS
"dune-geometry REQUIRED"
"dune-grid REQUIRED"
"dune-istl REQUIRED"
"opm-common REQUIRED"
"opm-material REQUIRED"
"dune-alugrid"
"dune-fem"
"dune-cornerpoint"
"opm-grid"
# librt (on some systems necessary for clock_gettime())
"librt REQUIRED"
# valgrind client requests

View File

@@ -11,7 +11,7 @@ set (opm-benchmarks_DEPS
"CXX11Features REQUIRED"
# various runtime library enhancements
"Boost 1.44.0
COMPONENTS date_time filesystem system iostreams unit_test_framework REQUIRED"
COMPONENTS date_time filesystem system unit_test_framework REQUIRED"
# OPM dependency
"opm-common"
"opm-core REQUIRED"

View File

@@ -12,5 +12,6 @@ set (opm-common_DEPS
# compile with C++0x/11 support if available
"CXX11Features REQUIRED"
# various runtime library enhancements
""
"Boost 1.44.0
COMPONENTS system unit_test_framework REQUIRED"
)

View File

@@ -18,7 +18,7 @@ set (opm-core_DEPS
"CXX11Features REQUIRED"
# various runtime library enhancements
"Boost 1.44.0
COMPONENTS date_time filesystem system iostreams unit_test_framework REQUIRED"
COMPONENTS date_time filesystem system unit_test_framework REQUIRED"
# matrix library
"BLAS REQUIRED"
"LAPACK REQUIRED"

View File

@@ -2,7 +2,7 @@
# vim: set filetype=cmake autoindent tabstop=2 shiftwidth=2 noexpandtab softtabstop=2 nowrap:
# defines that must be present in config.h for our headers
set (dune-cornerpoint_CONFIG_VAR
set (opm-grid_CONFIG_VAR
DUNE_GRID_VERSION_MAJOR
DUNE_GRID_VERSION_MINOR
DUNE_GRID_VERSION_REVISION
@@ -13,14 +13,14 @@ set (dune-cornerpoint_CONFIG_VAR
)
# dependencies
set (dune-cornerpoint_DEPS
set (opm-grid_DEPS
# compile with C99 support if available
"C99"
# compile with C++0x/11 support if available
"CXX11Features"
# various runtime library enhancements
"Boost 1.44.0
COMPONENTS date_time filesystem system iostreams unit_test_framework REQUIRED"
COMPONENTS date_time filesystem system unit_test_framework REQUIRED"
# DUNE dependency
"dune-common REQUIRED;
dune-grid REQUIRED;

View File

@@ -16,8 +16,8 @@ set (opm-material_DEPS
# compile with C++0x/11 support if available
"CXX11Features REQUIRED"
# prerequisite OPM modules
"opm-common"
"opm-parser"
"opm-common REQUIRED"
# DUNE dependency
"dune-common REQUIRED"
)

View File

@@ -2,24 +2,25 @@
# vim: set filetype=cmake autoindent tabstop=2 shiftwidth=2 noexpandtab softtabstop=2 nowrap:
# defines that must be present in config.h for our headers
set (opm-porsol_CONFIG_VAR
set (opm-core_CONFIG_VAR
HAVE_ERT
)
# dependencies
set (opm-porsol_DEPS
set (opm-output_DEPS
# compile with C99 support if available
"C99"
# compile with C++0x/11 support if available
"CXX11Features"
"CXX11Features REQUIRED"
# various runtime library enhancements
"Boost 1.44.0
COMPONENTS date_time filesystem system iostreams unit_test_framework REQUIRED"
# DUNE dependency
"dune-common REQUIRED;
dune-istl REQUIRED;
dune-grid REQUIRED;
opm-common;
opm-core REQUIRED;
opm-material REQUIRED;
dune-cornerpoint REQUIRED"
COMPONENTS date_time filesystem system unit_test_framework REQUIRED"
# Ensembles-based Reservoir Tools (ERT)
"ERT REQUIRED"
# Look for MPI support
"opm-common REQUIRED"
# Parser library for ECL-type simulation models
"opm-parser REQUIRED"
# TODO remove this dependancy
"opm-core REQUIRED"
)

View File

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

View File

@@ -2,25 +2,28 @@
# vim: set filetype=cmake autoindent tabstop=2 shiftwidth=2 noexpandtab softtabstop=2 nowrap:
# defines that must be present in config.h for our headers
set (opm-autodiff_CONFIG_VAR
HAVE_DUNE_CORNERPOINT
set (opm-simulators_CONFIG_VAR
HAVE_OPM_GRID
)
# dependencies
set (opm-autodiff_DEPS
set (opm-simulators_DEPS
# Compile with C99 support if available
"C99"
# Compile with C++0x/11 support if available
"CXX11Features"
# Various runtime library enhancements
"Boost 1.44.0
COMPONENTS date_time filesystem system iostreams unit_test_framework REQUIRED"
COMPONENTS date_time filesystem system unit_test_framework REQUIRED"
# DUNE prerequisites
"dune-common REQUIRED;
dune-istl REQUIRED;
dune-cornerpoint;
opm-common REQUIRED;
opm-core REQUIRED"
dune-istl REQUIRED"
# OPM dependency
"opm-common REQUIRED;
opm-parser REQUIRED;
opm-core REQUIRED;
opm-output REQUIRED;
opm-grid"
# Eigen
"Eigen3 3.2.0"
)

View File

@@ -25,8 +25,8 @@ set (opm-upscaling_DEPS
dune-istl REQUIRED;
dune-geometry REQUIRED;
dune-grid REQUIRED;
opm-common;
opm-common REQUIRED;
opm-core REQUIRED;
dune-cornerpoint REQUIRED;
opm-porsol REQUIRED"
opm-grid REQUIRED;
opm-output REQUIRED"
)

View File

@@ -13,7 +13,7 @@ set (opm-verteq_DEPS
"CXX11Features"
# various runtime library enhancements
"Boost 1.44.0
COMPONENTS date_time filesystem system iostreams unit_test_framework REQUIRED"
COMPONENTS date_time filesystem system unit_test_framework REQUIRED"
# OPM dependency
"opm-common;
opm-core REQUIRED"

4
debian/changelog vendored
View File

@@ -1,5 +1,5 @@
opm-common (2015.10-rfinal-1~trusty) trusty; urgency=medium
opm-common (2016.04-rc1-1~trusty) trusty; urgency=medium
* New release
-- Arne Morten Kvarving <arne.morten.kvarving@sintef.no> Mon, 19 Oct 2015 10:49:00 +0200
-- Arne Morten Kvarving <arne.morten.kvarving@sintef.no> Fri, 22 Apr 2016 10:06:00 +0200

13
debian/control vendored
View File

@@ -4,19 +4,30 @@ Maintainer: Arne Morten Kvarving <arne.morten.kvarving@sintef.no>
Build-Depends: build-essential, debhelper (>= 9),
pkg-config, cmake, git, libtool, doxygen,
texlive-latex-extra, texlive-latex-recommended,
ghostscript
ghostscript, libboost-system-dev, libboost-test-dev
Standards-Version: 3.9.2
Section: libs
Homepage: http://opm-project.org
Vcs-Git: git://github.com/OPM/opm-common.git
Vcs-Browser: https://github.com/OPM/opm-common
Package: libopm-common1
Section: libs
Pre-Depends: ${misc:Pre-Depends}, multiarch-support
Architecture: any
Multi-Arch: same
Depends: ${shlibs:Depends}, ${misc:Depends}
Provides: libopm-common
Description: OPM common library
The OPM common library contains generic code shared across all OPM modules.
Package: libopm-common1-dev
Section: libdevel
Architecture: any
Multi-Arch: foreign
Provides: libopm-common-dev
Suggests: libopm-common1-doc
Depends: libopm-common1 (= ${binary:Version})
Description: OPM common library -- development files
The OPM common library contains the shared buildsystem
and helpers shared across all OPM modules.

View File

@@ -1,5 +1,6 @@
usr/include/*
usr/lib/dunecontrol/*
usr/lib/pkgconfig/*
usr/lib/*/pkgconfig/*
usr/share/cmake/*
usr/share/opm/*
usr/lib/*/lib*.so

1
debian/libopm-common1.install vendored Normal file
View File

@@ -0,0 +1 @@
usr/lib/*/lib*.so.*

View File

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

11
jenkins/README.md Normal file
View File

@@ -0,0 +1,11 @@
# opm-common jenkins build scripts:
**build-opm-module.sh**:
This is a helper script which contains functions for building,
testing and cloning modules.
**build.sh**:
This expects to run on a jenkins instance with opm-common as the 'origin' remote.
It will build and test opm-common. It can be used both for post-merge builds
of the master branch and for a github pull request builder job.

46
jenkins/build-opm-module.sh Executable file
View File

@@ -0,0 +1,46 @@
#!/bin/bash
# $1 = Additional cmake parameters
# $2 = 0 to build and install module, 1 to build and test module
# $3 = Source root of module to build
function build_module {
cmake $3 -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=$2 $1
test $? -eq 0 || exit 1
if test $2 -eq 1
then
cmake --build .
test $? -eq 0 || exit 2
ctest -T Test --no-compress-output
$WORKSPACE/deps/opm-common/jenkins/convert.py -x $WORKSPACE/deps/opm-common/jenkins/conv.xsl -t . > testoutput.xml
else
cmake --build . --target install
fi
}
# $1 = Name of module
# $2 = git-rev to use for module
function clone_module {
pushd .
mkdir -p $WORKSPACE/deps/$1
cd $WORKSPACE/deps/$1
git init .
git remote add origin https://github.com/OPM/$1
git fetch --depth 1 origin $2:branch_to_build
git checkout branch_to_build
test $? -eq 0 || exit 1
popd
}
# $1 = Module to clone
# $2 = Additional cmake parameters
# $3 = git-rev to use for module
# $4 = Build root
function clone_and_build_module {
clone_module $1 $3
pushd .
mkdir $4/build-$1
cd $4/build-$1
build_module "$2" 0 $WORKSPACE/deps/$1
test $? -eq 0 || exit 1
popd
}

17
jenkins/build.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
source `dirname $0`/build-opm-module.sh
# Create symlink so build_module can find the test result converter
mkdir deps
ln -sf $WORKSPACE deps/opm-common
# Build without MPI
pushd .
mkdir -p serial/build-opm-common
cd serial/build-opm-common
build_module "-DUSE_MPI=0" 1 $WORKSPACE
test $? -eq 0 || exit 1
popd
cp serial/build-opm-common/testoutput.xml .

116
jenkins/conv.xsl Normal file
View File

@@ -0,0 +1,116 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/Site">
<testsuite>
<xsl:variable name="BuildName"><xsl:value-of select="@BuildName"/></xsl:variable>
<xsl:variable name="BuildStamp"><xsl:value-of select="@BuildStamp"/></xsl:variable>
<xsl:variable name="Name"><xsl:value-of select="@Name"/></xsl:variable>
<xsl:variable name="Generator"><xsl:value-of select="@Generator"/></xsl:variable>
<xsl:variable name="CompilerName"><xsl:value-of select="@CompilerName"/></xsl:variable>
<xsl:variable name="OSName"><xsl:value-of select="@OSName"/></xsl:variable>
<xsl:variable name="Hostname"><xsl:value-of select="@Hostname"/></xsl:variable>
<xsl:variable name="OSRelease"><xsl:value-of select="@OSRelease"/></xsl:variable>
<xsl:variable name="OSVersion"><xsl:value-of select="@OSVersion"/></xsl:variable>
<xsl:variable name="OSPlatform"><xsl:value-of select="@OSPlatform"/></xsl:variable>
<xsl:variable name="Is64Bits"><xsl:value-of select="@Is64Bits"/></xsl:variable>
<xsl:variable name="VendorString"><xsl:value-of select="@VendorString"/></xsl:variable>
<xsl:variable name="VendorID"><xsl:value-of select="@VendorID"/></xsl:variable>
<xsl:variable name="FamilyID"><xsl:value-of select="@FamilyID"/></xsl:variable>
<xsl:variable name="ModelID"><xsl:value-of select="@ModelID"/></xsl:variable>
<xsl:variable name="ProcessorCacheSize"><xsl:value-of select="@ProcessorCacheSize"/></xsl:variable>
<xsl:variable name="NumberOfLogicalCPU"><xsl:value-of select="@NumberOfLogicalCPU"/></xsl:variable>
<xsl:variable name="NumberOfPhysicalCPU"><xsl:value-of select="@NumberOfPhysicalCPU"/></xsl:variable>
<xsl:variable name="TotalVirtualMemory"><xsl:value-of select="@TotalVirtualMemory"/></xsl:variable>
<xsl:variable name="TotalPhysicalMemory"><xsl:value-of select="@TotalPhysicalMemory"/></xsl:variable>
<xsl:variable name="LogicalProcessorsPerPhysical"><xsl:value-of select="@LogicalProcessorsPerPhysical"/></xsl:variable>
<xsl:variable name="ProcessorClockFrequency"><xsl:value-of select="@ProcessorClockFrequency"/></xsl:variable>
<properties>
<property name="BuildName" value="{$BuildName}" />
<property name="BuildStamp" value="{$BuildStamp}" />
<property name="Name" value="{$Name}" />
<property name="Generator" value="{$Generator}" />
<property name="CompilerName" value="{$CompilerName}" />
<property name="OSName" value="{$OSName}" />
<property name="Hostname" value="{$Hostname}" />
<property name="OSRelease" value="{$OSRelease}" />
<property name="OSVersion" value="{$OSVersion}" />
<property name="OSPlatform" value="{$OSPlatform}" />
<property name="Is64Bits" value="{$Is64Bits}" />
<property name="VendorString" value="{$VendorString}" />
<property name="VendorID" value="{$VendorID}" />
<property name="FamilyID" value="{$FamilyID}" />
<property name="ModelID" value="{$ModelID}" />
<property name="ProcessorCacheSize" value="{$ProcessorCacheSize}" />
<property name="NumberOfLogicalCPU" value="{$NumberOfLogicalCPU}" />
<property name="NumberOfPhysicalCPU" value="{$NumberOfPhysicalCPU}" />
<property name="TotalVirtualMemory" value="{$TotalVirtualMemory}" />
<property name="TotalPhysicalMemory" value="{$TotalPhysicalMemory}" />
<property name="LogicalProcessorsPerPhysical" value="{$LogicalProcessorsPerPhysical}" />
<property name="ProcessorClockFrequency" value="{$ProcessorClockFrequency}" />
</properties>
<xsl:apply-templates select="Testing/Test"/>
<system-out>
BuildName: <xsl:value-of select="$BuildName" />
BuildStamp: <xsl:value-of select="$BuildStamp" />
Name: <xsl:value-of select="$Name" />
Generator: <xsl:value-of select="$Generator" />
CompilerName: <xsl:value-of select="$CompilerName" />
OSName: <xsl:value-of select="$OSName" />
Hostname: <xsl:value-of select="$Hostname" />
OSRelease: <xsl:value-of select="$OSRelease" />
OSVersion: <xsl:value-of select="$OSVersion" />
OSPlatform: <xsl:value-of select="$OSPlatform" />
Is64Bits: <xsl:value-of select="$Is64Bits" />
VendorString: <xsl:value-of select="$VendorString" />
VendorID: <xsl:value-of select="$VendorID" />
FamilyID: <xsl:value-of select="$FamilyID" />
ModelID: <xsl:value-of select="$ModelID" />
ProcessorCacheSize: <xsl:value-of select="$ProcessorCacheSize" />
NumberOfLogicalCPU: <xsl:value-of select="$NumberOfLogicalCPU" />
NumberOfPhysicalCPU: <xsl:value-of select="$NumberOfPhysicalCPU" />
TotalVirtualMemory: <xsl:value-of select="$TotalVirtualMemory" />
TotalPhysicalMemory: <xsl:value-of select="$TotalPhysicalMemory" />
LogicalProcessorsPerPhysical: <xsl:value-of select="$LogicalProcessorsPerPhysical" />
ProcessorClockFrequency: <xsl:value-of select="$ProcessorClockFrequency" />
</system-out>
</testsuite>
</xsl:template>
<xsl:template match="Testing/Test">
<xsl:variable name="testcasename"><xsl:value-of select= "Name"/></xsl:variable>
<xsl:variable name="exectime">
<xsl:for-each select="Results/NamedMeasurement">
<xsl:if test="@name = 'Execution Time'">
<xsl:value-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<testcase name="{$testcasename}" classname="TestSuite" time="{$exectime}">
<xsl:if test="@Status = 'passed'">
</xsl:if>
<xsl:if test="@Status = 'failed'">
<xsl:variable name="failtype">
<xsl:for-each select="Results/NamedMeasurement">
<xsl:if test="@name = 'Exit Code'">
<xsl:value-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="failcode">
<xsl:for-each select="Results/NamedMeasurement">
<xsl:if test="@name = 'Exit Value'">
<xsl:value-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<error message="{$failtype} ({$failcode})"><xsl:value-of select="Results/Measurement/Value/text()" /></error>
</xsl:if>
<xsl:if test="@Status = 'notrun'">
<skipped><xsl:value-of select="Results/Measurement/Value/text()" /></skipped>
</xsl:if>
</testcase>
</xsl:template>
</xsl:stylesheet>

74
jenkins/convert.py Executable file
View File

@@ -0,0 +1,74 @@
#!/usr/bin/env python
# coding: utf-8
# originally from:
# http://www.warp1337.com/content/how-use-ctest-jenkins-xunit-or-junit-plugin
# improved by:
# Jorge Araya Navarro <elcorreo@deshackra.com>
# Veni, Sancte Spiritus.
from lxml import etree
import argparse
from os.path import expanduser
from os.path import join
import logging
# configure logging
logging.basicConfig(format="%(levelname)s: %(message)s",
level=logging.ERROR)
desc = ("Converts ctest XML file to xUnit/JUnit XML "
"compatible file to use with Jenkins-CI. "
"Did you found any bug? please report it on: "
"https://bitbucket.org/shackra/ctest-jenkins/issues")
# configure argument parser.
parser = argparse.ArgumentParser(description=desc)
parser.add_argument("-x", "--xslt", help="the XSLT file to use", required=True)
parser.add_argument("-t", "--tag", help=("the directory where 'Testing/TAG'"
"file is. Remember to call ctest with"
" '-T test' option to generate it"),
required=True)
parsed = parser.parse_args()
# expanding user symbol "~"
parsed.xsl = expanduser(parsed.xslt)
parsed.tag = expanduser(parsed.tag)
# opening the TAG file
directory = None
try:
with open(join(parsed.tag, "Testing", "TAG")) as tagfile:
directory = tagfile.readline().strip()
except NotADirectoryError:
logging.error(
"'Testing/TAG' wasn't found on directory '{}'.".format(parsed.tag))
exit(1)
except FileNotFoundError:
logging.error(
"File '{}' not found.".format(join(parsed.tag, "Testing", "TAG")))
exit(1)
xmldoc = None
transform = None
try:
with open(join(parsed.tag, "Testing", directory, "Test.xml"))\
as testxmlfile:
xmldoc = etree.parse(testxmlfile)
except FileNotFoundError:
logging.error("File {} not found. Was it deleted or moved?".format(
join(parsed.tag, "Testing", directory, "Test.xml")))
exit(1)
try:
with open(parsed.xslt) as xsltfile:
xslt_root = etree.XML(xsltfile.read())
transform = etree.XSLT(xslt_root)
except FileNotFoundError:
logging.error("File {} not found.".format(parsed.xslt))
exit(1)
result_tree = transform(xmldoc)
print(result_tree)

29
jenkins/setup-opm-data.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
# Predefined by environment
if test -z "$OPM_DATA_ROOT"
then
OPM_DATA_REVISION="master"
if grep -q "opm-data=" <<< $ghprbCommentBody
then
OPM_DATA_REVISION=pull/`echo $ghprbCommentBody | sed -r 's/.*opm-data=([0-9]+).*/\1/g'`/merge
fi
# Not specified in trigger, use shared copy
if [[ "$OPM_DATA_REVISION" = "master" ]] && [[ ! "$OPM_DATA_ROOT_PREDEFINED" = "" ]]
then
if ! test -d $WORKSPACE/deps/opm-data
then
cp $OPM_DATA_ROOT_PREDEFINED $WORKSPACE/deps/opm-data -R
fi
else
# Specified in trigger, download it
source $WORKSPACE/deps/opm-common/jenkins/build-opm-module.sh
clone_module opm-data $OPM_DATA_REVISION
fi
else
if ! test -d $WORKSPACE/deps/opm-data
then
cp $OPM_DATA_ROOT $WORKSPACE/deps/opm-data -R
fi
fi
OPM_DATA_ROOT=$WORKSPACE/deps/opm-data

View File

@@ -21,11 +21,12 @@
#ifndef OPM_ERRORMACROS_HPP
#define OPM_ERRORMACROS_HPP
#include <opm/common/OpmLog/OpmLog.hpp>
#include <string>
#include <sstream>
#include <exception>
#include <stdexcept>
#include <cassert>
// macros for reporting to stderr
@@ -52,7 +53,7 @@
do { \
std::ostringstream oss__; \
oss__ << "[" << __FILE__ << ":" << __LINE__ << "] " << message; \
OPM_MESSAGE(message); \
Opm::OpmLog::error(oss__.str()); \
throw Exception(oss__.str()); \
} while (false)

View File

@@ -0,0 +1,64 @@
/*
Copyright 2014 Andreas Lauser
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdexcept>
#include <sstream>
#include <cassert>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/common/OpmLog/LogUtil.hpp>
#include <opm/common/OpmLog/CounterLog.hpp>
namespace Opm {
CounterLog::CounterLog(int64_t messageTypes) : LogBackend(messageTypes)
{ }
CounterLog::CounterLog() : LogBackend(Log::DefaultMessageTypes)
{ }
size_t CounterLog::numMessages(int64_t messageType) const {
if (Log::isPower2( messageType )) {
auto iter = m_count.find( messageType );
if (iter == m_count.end())
return 0;
else
return (*iter).second;
} else
throw std::invalid_argument("The messageType ID must be 2^n");
}
void CounterLog::addMessage(int64_t messageType , const std::string& ) {
if (includeMessage( messageType ))
m_count[messageType]++;
}
void CounterLog::clear()
{
m_count.clear();
}
} // namespace Opm

View File

@@ -0,0 +1,57 @@
/*
Copyright 2014 Andreas Lauser
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_COUNTERLOG_HPP
#define OPM_COUNTERLOG_HPP
#include <string>
#include <memory>
#include <map>
#include <opm/common/OpmLog/LogBackend.hpp>
namespace Opm {
/*!
* \brief Provides a simple sytem for log message which are found by the
* Parser/Deck/EclipseState classes during processing the deck.
*/
class CounterLog : public LogBackend {
public:
CounterLog(int64_t messageMask);
CounterLog();
size_t numMessages(int64_t messageType) const;
void addMessage(int64_t messageFlag ,
const std::string& message);
void clear();
~CounterLog() {};
private:
std::map<int64_t , size_t> m_count;
};
typedef std::shared_ptr<CounterLog> CounterLogPtr;
typedef std::shared_ptr<const CounterLog> CounterLogConstPtr;
} // namespace Opm
#endif

View File

@@ -0,0 +1,59 @@
/*
Copyright 2016 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <opm/common/OpmLog/EclipsePRTLog.hpp>
#include <opm/common/OpmLog/LogUtil.hpp>
namespace Opm {
void EclipsePRTLog::addMessage(int64_t messageType, const std::string& message)
{
StreamLog::addMessage(messageType, message);
m_count[messageType]++;
}
size_t EclipsePRTLog::numMessages(int64_t messageType) const
{
if (Log::isPower2( messageType )) {
auto iter = m_count.find( messageType );
if (iter == m_count.end())
return 0;
else
return (*iter).second;
} else
throw std::invalid_argument("The messageType ID must be 2^n");
}
EclipsePRTLog::~EclipsePRTLog()
{
//output summary.
const std::string summary_msg = "\n\nError summary:" +
std::string("\nWarnings " + std::to_string(numMessages(Log::MessageType::Warning))) +
std::string("\nProblems " + std::to_string(numMessages(Log::MessageType::Problem))) +
std::string("\nErrors " + std::to_string(numMessages(Log::MessageType::Error))) +
std::string("\nBugs " + std::to_string(numMessages(Log::MessageType::Bug))) +
std::string("\nDebug " + std::to_string(numMessages(Log::MessageType::Debug))) +
std::string("\nProblems " + std::to_string(numMessages(Log::MessageType::Problem))) +"\n";
addMessage(Log::MessageType::Info, summary_msg);
}
}

View File

@@ -0,0 +1,44 @@
/*
Copyright 2016 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ECLIPSEPRTLOG_H
#define ECLIPSEPRTLOG_H
#include <map>
#include <string>
#include <opm/common/OpmLog/StreamLog.hpp>
namespace Opm {
class EclipsePRTLog : public StreamLog {
public:
using StreamLog::StreamLog;
void addMessage(int64_t messageType, const std::string& message);
size_t numMessages(int64_t messageType) const;
~EclipsePRTLog();
private:
std::map<int64_t, size_t> m_count;
};
}
#endif // ECLIPSEPRTLOG_H

View File

@@ -0,0 +1,44 @@
/*
Copyright 2015 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <cstdint>
#include <opm/common/OpmLog/LogBackend.hpp>
namespace Opm {
LogBackend::LogBackend( int64_t mask ) :
m_mask(mask)
{
}
bool LogBackend::includeMessage(int64_t messageFlag) {
if (((messageFlag & m_mask) == messageFlag) &&
(messageFlag > 0))
return true;
else
return false;
}
int64_t LogBackend::getMask() const {
return m_mask;
}
}

View File

@@ -0,0 +1,45 @@
/*
Copyright 2015 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_LOGBACKEND_HPP
#define OPM_LOGBACKEND_HPP
#include <cstdint>
#include <string>
namespace Opm {
class LogBackend {
public:
LogBackend( int64_t mask );
virtual ~LogBackend() { };
virtual void addMessage(int64_t , const std::string& ) { };
int64_t getMask() const;
bool includeMessage(int64_t messageFlag);
private:
int64_t m_mask;
};
}
#endif

View File

@@ -0,0 +1,76 @@
/*
Copyright 2015 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <sstream>
#include <stdexcept>
#include <opm/common/OpmLog/LogUtil.hpp>
namespace Opm {
namespace Log {
bool isPower2(int64_t x) {
return ((x != 0) && !(x & (x - 1)));
}
std::string fileMessage(const std::string& filename , int line , const std::string& message) {
std::ostringstream oss;
oss << filename << ":" << line << ": " << message;
return oss.str();
}
std::string fileMessage(int64_t messageType , const std::string& filename , int line , const std::string& message) {
return fileMessage( filename , line , prefixMessage( messageType , message ));
}
std::string prefixMessage(int64_t messageType, const std::string& message) {
std::string prefix;
switch (messageType) {
case MessageType::Debug:
prefix = "debug";
break;
case MessageType::Info:
prefix = "info";
break;
case MessageType::Warning:
prefix = "warning";
break;
case MessageType::Error:
prefix = "error";
break;
case MessageType::Problem:
prefix = "problem";
break;
case MessageType::Bug:
prefix = "bug";
break;
default:
throw std::invalid_argument("Unhandled messagetype");
}
return prefix + ": " + message;
}
}
}

View File

@@ -0,0 +1,47 @@
/*
Copyright 2015 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_LOG_UTIL_HPP
#define OPM_LOG_UTIL_HPP
#include <cstdint>
#include <string>
namespace Opm {
namespace Log {
namespace MessageType {
const int64_t Debug = 1; /* Excessive information */
const int64_t Info = 2; /* Normal status information */
const int64_t Warning = 4; /* Input anomaly - possible error */
const int64_t Error = 8; /* Error in the input data - should probably exit. */
const int64_t Problem = 16; /* Calculation problems - e.g. convergence failure. */
const int64_t Bug = 32; /* An inconsistent state has been encountered in the simulator - should probably exit. */
}
const int64_t DefaultMessageTypes = MessageType::Debug + MessageType::Info + MessageType::Warning + MessageType::Error + MessageType::Problem + MessageType::Bug;
bool isPower2(int64_t x);
std::string fileMessage(const std::string& path, int line , const std::string& msg);
std::string fileMessage(int64_t messageType , const std::string& path, int line , const std::string& msg);
std::string prefixMessage(int64_t messageType , const std::string& msg);
}
}
#endif

View File

@@ -0,0 +1,114 @@
/*
Copyright 2015 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <sstream>
#include <stdexcept>
#include <iostream>
#include <opm/common/OpmLog/LogBackend.hpp>
#include <opm/common/OpmLog/Logger.hpp>
#include <opm/common/OpmLog/LogUtil.hpp>
namespace Opm {
Logger::Logger()
: m_globalMask(0),
m_enabledTypes(0)
{
addMessageType( Log::MessageType::Debug , "debug");
addMessageType( Log::MessageType::Info , "info");
addMessageType( Log::MessageType::Warning , "warning");
addMessageType( Log::MessageType::Error , "error");
addMessageType( Log::MessageType::Problem , "problem");
addMessageType( Log::MessageType::Bug , "bug");
}
void Logger::addMessage(int64_t messageType , const std::string& message) const {
if ((m_enabledTypes & messageType) == 0)
throw std::invalid_argument("Tried to issue message with unrecognized message ID");
if (m_globalMask & messageType) {
for (auto iter = m_backends.begin(); iter != m_backends.end(); ++iter) {
std::shared_ptr<LogBackend> backend = (*iter).second;
backend->addMessage( messageType , message );
}
}
}
void Logger::updateGlobalMask( int64_t mask ) {
m_globalMask |= mask;
}
bool Logger::hasBackend(const std::string& name) {
if (m_backends.find( name ) == m_backends.end())
return false;
else
return true;
}
bool Logger::removeBackend(const std::string& name) {
size_t eraseCount = m_backends.erase( name );
if (eraseCount == 1)
return true;
else
return false;
}
void Logger::addBackend(const std::string& name , std::shared_ptr<LogBackend> backend) {
updateGlobalMask( backend->getMask() );
m_backends[ name ] = backend;
}
int64_t Logger::enabledMessageTypes() const {
return m_enabledTypes;
}
//static:
bool Logger::enabledMessageType( int64_t enabledTypes , int64_t messageType) {
if (Log::isPower2( messageType)) {
if ((messageType & enabledTypes) == 0)
return false;
else
return true;
} else
throw std::invalid_argument("The message type id must be ~ 2^n");
}
//static:
bool Logger::enabledDefaultMessageType( int64_t messageType) {
return enabledMessageType( Log::DefaultMessageTypes , messageType );
}
bool Logger::enabledMessageType( int64_t messageType) const {
return enabledMessageType( m_enabledTypes , messageType );
}
void Logger::addMessageType( int64_t messageType , const std::string& /* prefix */) {
if (Log::isPower2( messageType)) {
m_enabledTypes |= messageType;
} else
throw std::invalid_argument("The message type id must be ~ 2^n");
}
}

View File

@@ -0,0 +1,80 @@
/*
Copyright 2015 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_LOGGER_HPP
#define OPM_LOGGER_HPP
#include <stdexcept>
#include <cstdint>
#include <map>
#include <memory>
#include <string>
namespace Opm {
class LogBackend;
class Logger {
public:
Logger();
void addMessage(int64_t messageType , const std::string& message) const;
static bool enabledDefaultMessageType( int64_t messageType);
bool enabledMessageType( int64_t messageType) const;
void addMessageType( int64_t messageType , const std::string& prefix);
int64_t enabledMessageTypes() const;
void addBackend(const std::string& name , std::shared_ptr<LogBackend> backend);
bool hasBackend(const std::string& name);
bool removeBackend(const std::string& name);
template <class BackendType>
std::shared_ptr<BackendType> getBackend(const std::string& name) const {
auto pair = m_backends.find( name );
if (pair == m_backends.end())
throw std::invalid_argument("Invalid backend name: " + name);
else
return std::static_pointer_cast<BackendType>(m_backends.find(name)->second);
}
template <class BackendType>
std::shared_ptr<BackendType> popBackend(const std::string& name) {
auto pair = m_backends.find( name );
if (pair == m_backends.end())
throw std::invalid_argument("Invalid backend name: " + name);
else {
std::shared_ptr<LogBackend> backend = (*pair).second;
removeBackend( name );
return std::static_pointer_cast<BackendType>(backend);
}
}
private:
void updateGlobalMask( int64_t mask );
static bool enabledMessageType( int64_t enabledTypes , int64_t messageType);
int64_t m_globalMask;
int64_t m_enabledTypes;
std::map<std::string , std::shared_ptr<LogBackend> > m_backends;
};
}
#endif

View File

@@ -0,0 +1,120 @@
/*
Copyright 2014 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/common/OpmLog/Logger.hpp>
namespace Opm {
std::shared_ptr<Logger> OpmLog::getLogger() {
if (!m_logger)
m_logger.reset( new Logger() );
return m_logger;
}
void OpmLog::addMessage(int64_t messageFlag , const std::string& message) {
if (m_logger)
m_logger->addMessage( messageFlag , message );
}
void OpmLog::info(const std::string& message)
{
const std::string msg = Log::prefixMessage(Log::MessageType::Info, message);
addMessage(Log::MessageType::Info, msg);
}
void OpmLog::warning(const std::string& message)
{
const std::string msg = Log::prefixMessage(Log::MessageType::Warning, message);
addMessage(Log::MessageType::Warning, msg);
}
void OpmLog::problem(const std::string& message)
{
const std::string msg = Log::prefixMessage(Log::MessageType::Problem, message);
addMessage(Log::MessageType::Problem, msg);
}
void OpmLog::error(const std::string& message)
{
const std::string msg = Log::prefixMessage(Log::MessageType::Error, message);
addMessage(Log::MessageType::Error, msg);
}
void OpmLog::bug(const std::string& message)
{
const std::string msg = Log::prefixMessage(Log::MessageType::Bug, message);
addMessage(Log::MessageType::Bug, msg);
}
void OpmLog::debug(const std::string& message)
{
const std::string msg = Log::prefixMessage(Log::MessageType::Debug, message);
addMessage(Log::MessageType::Debug, msg);
}
bool OpmLog::enabledMessageType( int64_t messageType ) {
if (m_logger)
return m_logger->enabledMessageType( messageType );
else
return Logger::enabledDefaultMessageType( messageType );
}
bool OpmLog::hasBackend(const std::string& name) {
if (m_logger)
return m_logger->hasBackend( name );
else
return false;
}
bool OpmLog::removeBackend(const std::string& name) {
if (m_logger)
return m_logger->removeBackend( name );
else
return false;
}
void OpmLog::addMessageType( int64_t messageType , const std::string& prefix) {
auto logger = OpmLog::getLogger();
logger->addMessageType( messageType , prefix );
}
void OpmLog::addBackend(const std::string& name , std::shared_ptr<LogBackend> backend) {
auto logger = OpmLog::getLogger();
return logger->addBackend( name , backend );
}
/******************************************************************/
std::shared_ptr<Logger> OpmLog::m_logger;
}

View File

@@ -0,0 +1,81 @@
/*
Copyright 2014 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPMLOG_HPP
#define OPMLOG_HPP
#include <memory>
#include <cstdint>
#include <opm/common/OpmLog/Logger.hpp>
#include <opm/common/OpmLog/LogUtil.hpp>
namespace Opm {
class LogBackend;
/*
The OpmLog class is a fully static class which manages a proper
Logger instance.
*/
class OpmLog {
public:
static void addMessage(int64_t messageFlag , const std::string& message);
static void info(const std::string& message);
static void warning(const std::string& message);
static void error(const std::string& message);
static void problem(const std::string& message);
static void bug(const std::string& message);
static void debug(const std::string& message);
static bool hasBackend( const std::string& backendName );
static void addBackend(const std::string& name , std::shared_ptr<LogBackend> backend);
static bool removeBackend(const std::string& name);
static bool enabledMessageType( int64_t messageType );
static void addMessageType( int64_t messageType , const std::string& prefix);
template <class BackendType>
static std::shared_ptr<BackendType> getBackend(const std::string& name) {
auto logger = OpmLog::getLogger();
return logger->getBackend<BackendType>(name);
}
template <class BackendType>
static std::shared_ptr<BackendType> popBackend(const std::string& name) {
auto logger = OpmLog::getLogger();
return logger->popBackend<BackendType>(name);
}
private:
static std::shared_ptr<Logger> getLogger();
static std::shared_ptr<Logger> m_logger;
};
}
#endif

View File

@@ -0,0 +1,61 @@
/*
Copyright 2015 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdexcept>
#include <opm/common/OpmLog/StreamLog.hpp>
namespace Opm {
StreamLog::StreamLog(const std::string& logFile , int64_t messageMask) : LogBackend(messageMask)
{
m_ofstream.open( logFile.c_str() , std::ofstream::out );
m_streamOwner = true;
m_ostream = &m_ofstream;
}
StreamLog::StreamLog(std::ostream& os , int64_t messageMask) : LogBackend(messageMask)
{
m_ostream = &os;
m_streamOwner = false;
}
void StreamLog::close() {
if (m_streamOwner && m_ofstream.is_open()) {
m_ofstream.close();
m_ostream = NULL;
}
}
void StreamLog::addMessage(int64_t messageType , const std::string& message) {
if (includeMessage( messageType )) {
(*m_ostream) << message << std::endl;
if (m_ofstream.is_open())
m_ofstream.flush();
}
}
StreamLog::~StreamLog() {
close();
}
}

View File

@@ -0,0 +1,48 @@
/*
Copyright 2015 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef STREAMLOG_H
#define STREAMLOG_H
#include <fstream>
#include <iostream>
#include <cstdint>
#include <opm/common/OpmLog/LogBackend.hpp>
namespace Opm {
class StreamLog : public LogBackend {
public:
StreamLog(const std::string& logFile , int64_t messageMask);
StreamLog(std::ostream& os , int64_t messageMask);
void addMessage(int64_t messageType , const std::string& message);
~StreamLog();
private:
void close();
std::ofstream m_ofstream;
std::ostream * m_ostream;
bool m_streamOwner;
};
}
#endif

View File

@@ -0,0 +1,60 @@
/*
Copyright 2014 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdexcept>
#include <cassert>
#include <iomanip>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/common/OpmLog/LogUtil.hpp>
#include <opm/common/OpmLog/TimerLog.hpp>
#include <opm/common/OpmLog/StreamLog.hpp>
namespace Opm {
TimerLog::TimerLog(const std::string& logFile) : StreamLog( logFile , StopTimer | StartTimer )
{
m_work.precision(8);
}
TimerLog::TimerLog(std::ostream& os) : StreamLog( os , StopTimer | StartTimer )
{
m_work.precision(8);
}
void TimerLog::addMessage(int64_t messageType , const std::string& msg ) {
if (messageType == StopTimer) {
clock_t stop = clock();
double secondsElapsed = 1.0 * (m_start - stop) / CLOCKS_PER_SEC ;
m_work.str("");
m_work << std::fixed << msg << ": " << secondsElapsed << " seconds ";
StreamLog::addMessage( messageType , m_work.str());
} else {
if (messageType == StartTimer)
m_start = clock();
}
}
} // namespace Opm

View File

@@ -0,0 +1,60 @@
/*
Copyright 2014 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_TIMERLOG_HPP
#define OPM_TIMERLOG_HPP
#include <time.h>
#include <memory>
#include <sstream>
#include <string>
#include <opm/common/OpmLog/StreamLog.hpp>
/*
This class is a simple demonstration of how the logging framework
can be used to create a simple very special case logging facility.
*/
namespace Opm {
class TimerLog : public StreamLog {
public:
static const int64_t StartTimer = 4096;
static const int64_t StopTimer = 8192;
TimerLog(const std::string& logFile);
TimerLog(std::ostream& os);
void addMessage(int64_t messageFlag ,
const std::string& message);
void clear();
~TimerLog() {};
private:
clock_t m_start;
std::ostringstream m_work;
};
typedef std::shared_ptr<TimerLog> TimerLogPtr;
typedef std::shared_ptr<const TimerLog> TimerLogConstPtr;
} // namespace Opm
#endif

View File

@@ -0,0 +1,247 @@
/*
Copyright 2016 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <opm/common/ErrorMacros.hpp>
#include <opm/common/util/numeric/cmp.hpp>
#include <opm/common/data/SimulationDataContainer.hpp>
namespace Opm {
SimulationDataContainer::SimulationDataContainer(size_t num_cells, size_t num_faces , size_t num_phases) :
m_num_cells( num_cells ),
m_num_faces( num_faces ),
m_num_phases( num_phases )
{
addDefaultFields( );
}
SimulationDataContainer::SimulationDataContainer(const SimulationDataContainer& other)
: m_num_cells(other.m_num_cells),
m_num_faces(other.m_num_faces),
m_num_phases(other.m_num_phases),
m_cell_data(other.m_cell_data),
m_face_data(other.m_face_data)
{
setReferencePointers();
}
SimulationDataContainer& SimulationDataContainer::operator=(const SimulationDataContainer& other)
{
SimulationDataContainer copy(other);
copy.swap(*this);
return *this;
}
void SimulationDataContainer::swap(SimulationDataContainer& other)
{
using std::swap;
swap(m_num_cells, other.m_num_cells);
swap(m_num_faces, other.m_num_faces);
swap(m_num_phases, other.m_num_phases);
swap(m_cell_data, other.m_cell_data);
swap(m_face_data, other.m_face_data);
setReferencePointers();
other.setReferencePointers();
}
size_t SimulationDataContainer::numPhases() const {
return m_num_phases;
}
size_t SimulationDataContainer::numFaces() const {
return m_num_faces;
}
size_t SimulationDataContainer::numCells() const {
return m_num_cells;
}
bool SimulationDataContainer::hasCellData( const std::string& name ) const {
return ( m_cell_data.find( name ) == m_cell_data.end() ? false : true );
}
std::vector<double>& SimulationDataContainer::getCellData( const std::string& name ) {
auto iter = m_cell_data.find( name );
if (iter == m_cell_data.end()) {
throw std::invalid_argument("The cell data with name: " + name + " does not exist");
} else
return iter->second;
}
const std::vector<double>& SimulationDataContainer::getCellData( const std::string& name ) const {
auto iter = m_cell_data.find( name );
if (iter == m_cell_data.end()) {
throw std::invalid_argument("The cell data with name: " + name + " does not exist");
} else
return iter->second;
}
void SimulationDataContainer::registerCellData( const std::string& name , size_t components , double initialValue) {
if (!hasCellData( name )) {
m_cell_data.insert( std::pair<std::string , std::vector<double>>( name , std::vector<double>(components * m_num_cells , initialValue )));
}
}
void SimulationDataContainer::setCellDataComponent( const std::string& key ,
size_t component ,
const std::vector<int>& cells ,
const std::vector<double>& values) {
auto& data = getCellData( key );
if (component >= m_num_phases)
OPM_THROW(std::invalid_argument, "The component number: " << component << " is invalid");
if (cells.size() != values.size())
OPM_THROW(std::invalid_argument, "size mismatch between cells and values");
// This is currently quite broken; the setCellDataComponent
// method assumes that the number of components in the field
// we are currently focusing on has num_phases components in
// total. This restriction should be lifted by allowing a per
// field number of components.
if (data.size() != m_num_phases * m_num_cells)
OPM_THROW(std::invalid_argument , "Can currently only be used on fields with num_components == num_phases (i.e. saturation...) ");
for (size_t i = 0; i < cells.size(); i++) {
if (size_t(cells[i]) < m_num_cells) {
auto field_index = cells[i] * m_num_phases + component;
data[field_index] = values[i];
} else {
OPM_THROW(std::invalid_argument , "The cell number: " << cells[i] << " is invalid.");
}
}
}
bool SimulationDataContainer::hasFaceData( const std::string& name ) const {
return ( m_face_data.find( name ) == m_face_data.end() ? false : true );
}
std::vector<double>& SimulationDataContainer::getFaceData( const std::string& name ) {
auto iter = m_face_data.find( name );
if (iter == m_face_data.end()) {
throw std::invalid_argument("The face data with name: " + name + " does not exist");
} else
return iter->second;
}
const std::vector<double>& SimulationDataContainer::getFaceData( const std::string& name ) const {
auto iter = m_face_data.find( name );
if (iter == m_face_data.end()) {
throw std::invalid_argument("The Face data with name: " + name + " does not exist");
} else
return iter->second;
}
void SimulationDataContainer::registerFaceData( const std::string& name , size_t components , double initialValue) {
if (!hasFaceData( name )) {
m_face_data.insert( std::pair<std::string , std::vector<double>>( name , std::vector<double>(components * m_num_faces , initialValue )));
}
}
bool SimulationDataContainer::equal( const SimulationDataContainer& other ) const {
if ((m_num_cells != other.m_num_cells) ||
(m_num_phases != other.m_num_phases) ||
(m_num_faces != other.m_num_faces))
return false;
if ((m_face_data.size() != other.m_face_data.size()) ||
(m_cell_data.size() != other.m_cell_data.size()))
return false;
for (const auto& cell_data : m_cell_data) {
const auto key = cell_data.first;
const auto data = cell_data.second;
if (other.hasCellData( key )) {
const auto& other_data = other.getCellData( key );
if (!cmp::vector_equal<double>( data , other_data ))
return false;
} else
return false;
}
for (const auto& face_data : m_face_data) {
const auto key = face_data.first;
const auto data = face_data.second;
if (other.hasFaceData( key )) {
const auto& other_data = other.getFaceData( key );
if (!cmp::vector_equal<double>( data , other_data ))
return false;
} else
return false;
}
return true;
}
size_t SimulationDataContainer::numCellDataComponents( const std::string& name ) const {
const auto& data = getCellData( name );
return data.size() / m_num_cells;
}
const std::unordered_map<std::string, std::vector<double>>& SimulationDataContainer::cellData() const {
return m_cell_data;
}
std::unordered_map<std::string, std::vector<double>>& SimulationDataContainer::cellData() {
return m_cell_data;
}
// This is very deprecated.
void SimulationDataContainer::addDefaultFields() {
registerCellData("PRESSURE" , 1 , 0.0);
registerCellData("SATURATION" , m_num_phases , 0.0);
registerCellData("TEMPERATURE" , 1 , 273.15 + 20);
registerFaceData("FACEPRESSURE" , 1 , 0.0 );
registerFaceData("FACEFLUX" , 1 , 0.0 );
setReferencePointers();
}
void SimulationDataContainer::setReferencePointers()
{
// This sets the reference pointers for the fast
// accessors, the fields must be created first
// by copying or a call to addDefaultFields().
pressure_ref_ = &getCellData("PRESSURE");
temperature_ref_ = &getCellData("TEMPERATURE");
saturation_ref_ = &getCellData("SATURATION");
facepressure_ref_ = &getFaceData("FACEPRESSURE");
faceflux_ref_ = &getFaceData("FACEFLUX");
}
} // namespace Opm

View File

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

View File

@@ -0,0 +1,132 @@
/*
Copyright 2016 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef COMMON_UTIL_NUMERIC_CMP
#define COMMON_UTIL_NUMERIC_CMP
#include <cstddef>
#include <vector>
#include <type_traits>
#include <cmath>
namespace Opm {
/// In the namespace cmp are implemented functions for
/// approximate comparison of double values based on absolute
/// and relative difference. There are three functions:
///
/// scalar_equal<T>() : Compare two <T> values.
///
/// ptr_equal<T>(): This compares all the element in the
/// two T * pointers.
///
/// vector_equal<T>(): This compares all the elements in
/// two std::vector<T> instances.
///
/// For both vector_equal<T>() and ptr_equal<T>() the
/// actual comparison is based on the scalar_equal<T>()
/// function. All functions exist as two overloads, one which
/// takes explicit input values for the absolute and relative
/// epsilon, and one which uses default values.
///
/// The comparison functions are implemented as templates, with
/// the following caveats:
///
/// 1. The static_assert() in scalar_equal<T> ensures that only
/// floating point types can be used.
///
/// 2. The default epsilon values are of type double -
/// irrespective of the type of data being compared.
///
/// For more details of floating point comparison please consult
/// this reference:
///
/// https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
namespace cmp {
const double default_abs_epsilon = 1e-8;
const double default_rel_epsilon = 1e-5;
template<typename T>
bool scalar_equal(T value1, T value2, T abs_eps , T rel_eps) {
static_assert(std::is_floating_point<T>::value, "Function scalar_equal() A can only be instantiated with floating point types");
bool equal = true;
T diff = std::fabs(value1 - value2);
if (diff > abs_eps) {
T scale = std::max(std::fabs(value1), std::fabs(value2));
if (diff > scale * rel_eps) {
equal = false;
}
}
return equal;
}
template<typename T>
bool scalar_equal(T value1, T value2) {
return scalar_equal<T>( value1 , value2 , default_abs_epsilon , default_rel_epsilon );
}
template<typename T>
bool vector_equal(const std::vector<T>& v1, const std::vector<T>& v2, T abs_eps, T rel_eps) {
if (v1.size() != v2.size()) {
return false;
}
for (size_t i = 0; i < v1.size(); i++) {
if (!scalar_equal<T>( v1[i], v2[i], abs_eps, rel_eps ))
return false;
}
return true;
}
template<typename T>
bool vector_equal(const std::vector<T>& v1, const std::vector<T>& v2) {
return vector_equal<T>(v1, v2, default_abs_epsilon, default_rel_epsilon);
}
template<typename T>
bool array_equal(const T* p1, const T* p2, size_t num_elements, T abs_eps, T rel_eps) {
if (memcmp(p1 , p2 , num_elements * sizeof * p1) == 0)
return true;
else {
size_t index;
for (index = 0; index < num_elements; index++) {
if (!scalar_equal<T>( p1[index] , p2[index] , abs_eps , rel_eps)) {
return false;
}
}
}
return true;
}
template<typename T>
bool array_equal(const T* p1, const T* p2, size_t num_elements) {
return array_equal<T>(p1, p2, num_elements , default_abs_epsilon, default_rel_epsilon);
}
}
}
#endif

View File

@@ -2,10 +2,10 @@
# spec file for package opm-common
#
%define tag final
%define tag rc1
Name: opm-common
Version: 2015.10
Version: 2016.04
Release: 0
Summary: Open Porous Media - common helpers and buildsystem
License: GPL-3.0
@@ -13,13 +13,20 @@ Group: Development/Libraries/C and C++
Url: http://www.opm-project.org/
Source0: https://github.com/OPM/%{name}/archive/release/%{version}/%{tag}.tar.gz#/%{name}-%{version}.tar.gz
BuildRequires: git doxygen bc
%{?el6:BuildRequires: devtoolset-2 cmake28}
%{!?el6:BuildRequires: gcc gcc-c++ cmake}
%{?el6:BuildRequires: devtoolset-2 cmake28 boost148-devel}
%{!?el6:BuildRequires: gcc gcc-c++ cmake boost-devel}
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
The Open Porous Media (OPM) initiative provides a set of open-source tools centered around the simulation of flow and transport of fluids in porous media. The goal of the initiative is to establish a sustainable environment for the development of an efficient and well-maintained software suite.
%package -n libopm-common1
Summary: OPM-common - library
Group: System/Libraries
%description -n libopm-common1
This package contains library for opm-common
%package devel
Summary: Development and header files for opm-common
Group: Development/Libraries/C and C++
@@ -42,7 +49,7 @@ This package contains the documentation files for opm-common
# consider using -DUSE_VERSIONED_DIR=ON if backporting
%build
%{?el6:scl enable devtoolset-2 bash}
%{?el6:cmake28} %{?!el6:cmake} -DBUILD_SHARED_LIBS=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DSTRIP_DEBUGGING_SYMBOLS=ON -DCMAKE_INSTALL_PREFIX=%{_prefix} -DCMAKE_INSTALL_DOCDIR=share/doc/%{name}-%{version} -DUSE_RUNPATH=OFF %{?el6:-DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-2/root/usr/bin/g++ -DCMAKE_C_COMPILER=/opt/rh/devtoolset-2/root/usr/bin/gcc -DCMAKE_Fortran_COMPILER=/opt/rh/devtoolset-2/root/usr/bin/gfortran} -DBOOST_LIBRARYDIR=%{_libdir}/boost148 -DBOOST_INCLUDEDIR=/usr/include/boost148
%{?el6:cmake28} %{?!el6:cmake} -DBUILD_SHARED_LIBS=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DSTRIP_DEBUGGING_SYMBOLS=ON -DCMAKE_INSTALL_PREFIX=%{_prefix} -DCMAKE_INSTALL_DOCDIR=share/doc/%{name}-%{version} -DUSE_RUNPATH=OFF %{?el6:-DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-2/root/usr/bin/g++ -DCMAKE_C_COMPILER=/opt/rh/devtoolset-2/root/usr/bin/gcc -DCMAKE_Fortran_COMPILER=/opt/rh/devtoolset-2/root/usr/bin/gfortran -DBOOST_LIBRARYDIR=%{_libdir}/boost148 -DBOOST_INCLUDEDIR=%{_includedir}/boost148}
make
%install
@@ -57,6 +64,10 @@ rm -rf %{buildroot}
%files doc
%{_docdir}/*
%files -n libopm-common1
%defattr(-,root,root,-)
%{_libdir}/*.so.*
%files devel
%defattr(-,root,root,-)
%{_libdir}/dunecontrol/*
@@ -64,3 +75,4 @@ rm -rf %{buildroot}
%{_includedir}/*
%{_datadir}/cmake/*
%{_datadir}/opm/*
%{_libdir}/*.so

251
tests/test_OpmLog.cpp Normal file
View File

@@ -0,0 +1,251 @@
/*
Copyright 2013 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE LogTests
#include <opm/common/utility/platform_dependent/disable_warnings.h>
#include <boost/test/unit_test.hpp>
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/common/OpmLog/LogBackend.hpp>
#include <opm/common/OpmLog/CounterLog.hpp>
#include <opm/common/OpmLog/TimerLog.hpp>
#include <opm/common/OpmLog/StreamLog.hpp>
#include <opm/common/OpmLog/LogUtil.hpp>
using namespace Opm;
BOOST_AUTO_TEST_CASE(DoLogging) {
OpmLog::addMessage(Log::MessageType::Warning , "Warning1");
OpmLog::addMessage(Log::MessageType::Warning , "Warning2");
}
BOOST_AUTO_TEST_CASE(Test_Format) {
BOOST_CHECK_EQUAL( "/path/to/file:100: There is a mild fuckup here?" , Log::fileMessage("/path/to/file" , 100 , "There is a mild fuckup here?"));
BOOST_CHECK_EQUAL( "error: This is the error" , Log::prefixMessage(Log::MessageType::Error , "This is the error"));
BOOST_CHECK_EQUAL( "warning: This is the warning" , Log::prefixMessage(Log::MessageType::Warning , "This is the warning"));
BOOST_CHECK_EQUAL( "info: This is the info" , Log::prefixMessage(Log::MessageType::Info , "This is the info"));
}
BOOST_AUTO_TEST_CASE(Test_AbstractBackend) {
int64_t mask = 1+4+16;
LogBackend backend(mask);
BOOST_CHECK_EQUAL(false , backend.includeMessage(0 ));
BOOST_CHECK_EQUAL(true , backend.includeMessage(1 ));
BOOST_CHECK_EQUAL(false , backend.includeMessage(2 ));
BOOST_CHECK_EQUAL(true , backend.includeMessage(4 ));
BOOST_CHECK_EQUAL(false , backend.includeMessage(8 ));
BOOST_CHECK_EQUAL(true , backend.includeMessage(16 ));
BOOST_CHECK_EQUAL(false, backend.includeMessage(6 ));
BOOST_CHECK_EQUAL(true , backend.includeMessage(5 ));
}
BOOST_AUTO_TEST_CASE(Test_Logger) {
Logger logger;
std::ostringstream log_stream;
std::shared_ptr<CounterLog> counter = std::make_shared<CounterLog>();
std::shared_ptr<StreamLog> streamLog = std::make_shared<StreamLog>( log_stream , Log::MessageType::Warning );
BOOST_CHECK_EQUAL( false , logger.hasBackend("NO"));
logger.addBackend("COUNTER" , counter);
logger.addBackend("STREAM" , streamLog);
BOOST_CHECK_EQUAL( true , logger.hasBackend("COUNTER"));
BOOST_CHECK_EQUAL( true , logger.hasBackend("STREAM"));
logger.addMessage( Log::MessageType::Error , "Error");
logger.addMessage( Log::MessageType::Warning , "Warning");
BOOST_CHECK_EQUAL( 1U , counter->numMessages(Log::MessageType::Error) );
BOOST_CHECK_EQUAL( 1U , counter->numMessages(Log::MessageType::Warning) );
BOOST_CHECK_EQUAL( 0U , counter->numMessages(Log::MessageType::Info) );
BOOST_CHECK_EQUAL( log_stream.str() , "Warning\n");
BOOST_CHECK_THROW( logger.getBackend<LogBackend>("No") , std::invalid_argument );
{
auto counter2 = logger.getBackend<CounterLog>("COUNTER");
BOOST_CHECK_EQUAL( 1U , counter2->numMessages( Log::MessageType::Warning));
BOOST_CHECK_EQUAL( 1U , counter2->numMessages( Log::MessageType::Error));
BOOST_CHECK_EQUAL( 0 , counter2->numMessages( Log::MessageType::Info));
}
BOOST_CHECK_EQUAL( false , logger.removeBackend("NO-not-found"));
BOOST_CHECK_EQUAL( true , logger.removeBackend("COUNTER"));
BOOST_CHECK_EQUAL( false , logger.hasBackend("COUNTER") );
{
auto stream2 = logger.popBackend<StreamLog>("STREAM");
BOOST_CHECK_EQUAL( false , logger.hasBackend("STREAM") );
BOOST_CHECK_THROW( logger.popBackend<StreamLog>("STREAM") , std::invalid_argument );
}
}
BOOST_AUTO_TEST_CASE(LoggerAddTypes_PowerOf2) {
Logger logger;
int64_t not_power_of2 = 13;
int64_t power_of2 = 4096;
BOOST_CHECK_THROW( logger.addMessageType( not_power_of2 , "Prefix") , std::invalid_argument);
BOOST_CHECK_THROW( logger.enabledMessageType( not_power_of2 ) , std::invalid_argument);
logger.addMessageType( power_of2 , "Prefix");
BOOST_CHECK( logger.enabledMessageType( power_of2 ));
BOOST_CHECK_EQUAL( false , logger.enabledMessageType( 2*power_of2 ));
}
class TestLog: public LogBackend {
public:
TestLog( int64_t messageMask ) : LogBackend( messageMask )
{
m_defaultMessages = 0;
m_specialMessages = 0;
}
void addMessage(int64_t messageType , const std::string& /* message */) {
if (messageType & Log::DefaultMessageTypes)
m_defaultMessages +=1;
else
m_specialMessages += 1;
}
int m_defaultMessages;
int m_specialMessages;
};
/*
Testing that the logger frontend does not let unknown message types
pass through; even though the backend has shown interest in the
phony 4096 messagetype.
*/
BOOST_AUTO_TEST_CASE(LoggerMasksTypes) {
Logger logger;
int64_t power_of2 = 4096;
std::shared_ptr<TestLog> testLog = std::make_shared<TestLog>(Log::DefaultMessageTypes + power_of2);
logger.addBackend("TEST" , testLog);
BOOST_CHECK_EQUAL( false , logger.enabledMessageType( power_of2 ));
logger.addMessage( Log::MessageType::Error , "Error");
logger.addMessage( Log::MessageType::Warning , "Warning");
logger.addMessage( Log::MessageType::Info , "Info");
BOOST_CHECK_THROW( logger.addMessage( power_of2 , "Blocked message") , std::invalid_argument );
BOOST_CHECK_EQUAL( testLog->m_defaultMessages , 3 );
BOOST_CHECK_EQUAL( testLog->m_specialMessages , 0 );
logger.addMessageType( power_of2 , "Phony");
logger.addMessage( power_of2 , "Passing through");
BOOST_CHECK_EQUAL( testLog->m_specialMessages , 1 );
}
BOOST_AUTO_TEST_CASE(LoggerDefaultTypesEnabled) {
Logger logger;
BOOST_CHECK_EQUAL( logger.enabledMessageTypes() , Log::DefaultMessageTypes);
}
BOOST_AUTO_TEST_CASE( CounterLogTesting) {
CounterLog counter(Log::DefaultMessageTypes);
counter.addMessage( Log::MessageType::Error , "This is an error ...");
counter.addMessage( Log::MessageType::Warning , "This is a warning");
BOOST_CHECK_EQUAL(1U , counter.numMessages( Log::MessageType::Error ));
BOOST_CHECK_EQUAL(1U , counter.numMessages( Log::MessageType::Warning ));
BOOST_CHECK_EQUAL(0 , counter.numMessages( Log::MessageType::Info ));
{
int64_t not_enabled = 4096;
int64_t not_power2 = 4095;
BOOST_CHECK_EQUAL( 0 , counter.numMessages( not_enabled ));
BOOST_CHECK_THROW( counter.numMessages( not_power2 ) , std::invalid_argument);
}
}
BOOST_AUTO_TEST_CASE(TestTimerLog) {
Logger logger;
std::ostringstream sstream;
std::shared_ptr<TimerLog> timer = std::make_shared<TimerLog>(sstream);
logger.addBackend( "TIMER" , timer );
logger.addMessageType( TimerLog::StartTimer , "Start");
logger.addMessageType( TimerLog::StopTimer , "Stop");
logger.addMessage( TimerLog::StartTimer , "");
logger.addMessage( TimerLog::StopTimer , "This was fast");
std::cout << sstream.str() << std::endl;
}
/*****************************************************************/
void initLogger(std::ostringstream& log_stream);
void initLogger(std::ostringstream& log_stream) {
std::shared_ptr<CounterLog> counter = std::make_shared<CounterLog>();
std::shared_ptr<StreamLog> streamLog = std::make_shared<StreamLog>( log_stream , Log::MessageType::Warning );
BOOST_CHECK_EQUAL( false , OpmLog::hasBackend("NO"));
OpmLog::addBackend("COUNTER" , counter);
OpmLog::addBackend("STREAM" , streamLog);
BOOST_CHECK_EQUAL( true , OpmLog::hasBackend("COUNTER"));
BOOST_CHECK_EQUAL( true , OpmLog::hasBackend("STREAM"));
}
BOOST_AUTO_TEST_CASE(TestOpmLog) {
std::ostringstream log_stream;
initLogger(log_stream);
OpmLog::addMessage( Log::MessageType::Warning , "Warning");
OpmLog::addMessage( Log::MessageType::Error , "Error");
{
auto counter = OpmLog::getBackend<CounterLog>("COUNTER");
BOOST_CHECK_EQUAL( 1 , counter->numMessages(Log::MessageType::Error) );
BOOST_CHECK_EQUAL( 1 , counter->numMessages(Log::MessageType::Warning) );
BOOST_CHECK_EQUAL( 0 , counter->numMessages(Log::MessageType::Info) );
}
BOOST_CHECK_EQUAL( log_stream.str() , "Warning\n");
}

View File

@@ -0,0 +1,207 @@
/*
Copyright 2016 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE SIMULATION_DATA_CONTAINER_TESTS
#include <boost/test/unit_test.hpp>
#include <stdexcept>
#include <iostream>
#include <opm/common/data/SimulationDataContainer.hpp>
using namespace Opm;
BOOST_AUTO_TEST_CASE(TestCreate) {
SimulationDataContainer container(1000 , 10 , 2);
BOOST_CHECK_EQUAL( 2U , container.numPhases() );
BOOST_CHECK_EQUAL( 1000U , container.numCells() );
BOOST_CHECK_EQUAL( 10U , container.numFaces() );
}
/*
This test verifies that the default fields are correctly registered;
this special behavior is deprecated - and the test should die; along
with the behavior.
*/
BOOST_AUTO_TEST_CASE(TestRegisterDefaults) {
SimulationDataContainer container(1000 , 10 , 2);
BOOST_CHECK( container.hasCellData("PRESSURE") );
BOOST_CHECK( container.hasCellData("SATURATION") );
{
auto pressure = container.getCellData("PRESSURE");
BOOST_CHECK_EQUAL( pressure.size() , 1000U );
BOOST_CHECK_EQUAL( container.numCellDataComponents( "PRESSURE") , 1U);
auto sat = container.getCellData("SATURATION");
BOOST_CHECK_EQUAL( sat.size() , 1000U*2 );
BOOST_CHECK_EQUAL( container.numCellDataComponents( "SATURATION") , 2U);
}
{
auto pressure = container.pressure();
BOOST_CHECK_EQUAL( pressure.size() , 1000U );
auto sat = container.saturation();
BOOST_CHECK_EQUAL( sat.size() , 1000U*2 );
}
BOOST_CHECK( container.hasFaceData("FACEPRESSURE") );
BOOST_CHECK( container.hasFaceData("FACEFLUX") );
}
BOOST_AUTO_TEST_CASE(TestRegisterFaceData) {
SimulationDataContainer container(100 , 10 , 2);
BOOST_CHECK( !container.hasFaceData("FLUX"));
BOOST_CHECK_THROW( container.getFaceData("FLUX") , std::invalid_argument );
container.registerFaceData("FLUX" , 1 , 99 );
auto& flux = container.getFaceData("FLUX");
BOOST_CHECK_EQUAL( flux.size() , 10U );
BOOST_CHECK_EQUAL( flux[0] , 99 );
}
BOOST_AUTO_TEST_CASE(TestRegisterCellData) {
SimulationDataContainer container(100 , 10 , 2);
BOOST_CHECK( !container.hasCellData("FIELDX"));
BOOST_CHECK_THROW( container.getCellData("FIELDX") , std::invalid_argument );
container.registerCellData("FIELDX" , 1 , 123 );
{
auto& fieldx = container.getCellData("FIELDX");
BOOST_CHECK_EQUAL( fieldx.size() , 100U );
for (auto v : fieldx)
BOOST_CHECK_EQUAL( v , 123 );
fieldx[0] *= 2;
}
{
auto fieldx = container.getCellData("FIELDX");
BOOST_CHECK_EQUAL( fieldx[0] , 246 );
BOOST_CHECK_EQUAL( fieldx[1] , 123 );
}
}
BOOST_AUTO_TEST_CASE(Test_Equal) {
{
SimulationDataContainer container1(100 , 10 , 2);
SimulationDataContainer container2(100 , 10 , 2);
BOOST_CHECK( container1.equal( container2 ));
}
{
SimulationDataContainer container1(100 , 10 , 2);
SimulationDataContainer container2(100 , 10 , 1);
BOOST_CHECK( !container1.equal( container2 ));
}
{
SimulationDataContainer container1(100 , 10 , 2);
SimulationDataContainer container2(100 , 10 , 2);
container1.registerCellData( "FIELDX" , 1 , 123 );
BOOST_CHECK( !container1.equal( container2 ));
container2.registerCellData( "FIELDX" , 1 , 123 );
BOOST_CHECK( container1.equal( container2 ));
container1.registerFaceData( "FACEX" , 1 , 123 );
BOOST_CHECK( !container1.equal( container2 ));
container2.registerFaceData( "FACEX" , 1 , 123 );
BOOST_CHECK( container1.equal( container2 ));
}
{
SimulationDataContainer container1(100 , 10 , 2);
SimulationDataContainer container2(100 , 10 , 2);
container1.registerCellData( "FIELD1" , 1 , 123 );
container2.registerCellData( "FIELD2" , 1 , 123 );
BOOST_CHECK( !container1.equal( container2 ));
}
{
SimulationDataContainer container1(100 , 10 , 2);
SimulationDataContainer container2(100 , 10 , 2);
container1.registerFaceData( "FIELD1" , 1 , 123 );
container2.registerFaceData( "FIELD2" , 1 , 123 );
BOOST_CHECK( !container1.equal( container2 ));
}
{
SimulationDataContainer container1(100 , 10 , 2);
SimulationDataContainer container2(100 , 10 , 2);
container1.registerFaceData( "FIELD1" , 1 , 123 );
container2.registerFaceData( "FIELD1" , 1 , 123 );
BOOST_CHECK( container1.equal( container2 ));
std::vector<double>& f = container1.getFaceData( "FIELD1" );
f[0] *= 1.1;
BOOST_CHECK( !container1.equal( container2 ));
}
}
BOOST_AUTO_TEST_CASE(TestSetComponent) {
SimulationDataContainer container(100 , 10 , 2);
container.registerCellData("FIELDX" , 2 , 123 );
std::vector<int> cells = { 1,2,3};
std::vector<int> cells2 = { 1,2,3,4};
std::vector<int> cells3 = { 1,2,100};
std::vector<double> values0 = {20,30,40};
std::vector<double> values1 = {2,3,4};
BOOST_CHECK_THROW( container.setCellDataComponent( "FIELDY" , 0 , cells , values0 ) , std::invalid_argument );
BOOST_CHECK_THROW( container.setCellDataComponent( "FIELDX" , 2 , cells , values0 ) , std::invalid_argument );
BOOST_CHECK_THROW( container.setCellDataComponent( "FIELDX" , 0 , cells2 , values0 ) , std::invalid_argument );
BOOST_CHECK_THROW( container.setCellDataComponent( "FIELDX" , 0 , cells3 , values0 ) , std::invalid_argument );
container.setCellDataComponent( "FIELDX" , 0 , cells , values0 );
container.setCellDataComponent( "FIELDX" , 1 , cells , values1 );
const auto& data = container.getCellData( "FIELDX" );
BOOST_CHECK_EQUAL( data[1*2 + 1] , 2 );
BOOST_CHECK_EQUAL( data[2*2 + 1] , 3 );
BOOST_CHECK_EQUAL( data[3*2 + 1] , 4 );
BOOST_CHECK_EQUAL( data[1*2] , 20 );
BOOST_CHECK_EQUAL( data[2*2] , 30 );
BOOST_CHECK_EQUAL( data[3*2] , 40 );
}

123
tests/test_cmp.cpp Normal file
View File

@@ -0,0 +1,123 @@
/*
Copyright 2016 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE FLOAT_CMP_TESTS
#include <boost/test/unit_test.hpp>
#include <stdexcept>
#include <opm/common/util/numeric/cmp.hpp>
using namespace Opm;
/**
Ahhh - the joys of comparing floating point numbers ....
http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
*/
BOOST_AUTO_TEST_CASE(TestSCalarcmp) {
const double abs_epsilon = cmp::default_abs_epsilon;
const double rel_epsilon = cmp::default_rel_epsilon;
BOOST_CHECK( cmp::scalar_equal<double>(1,1));
BOOST_CHECK_EQUAL( false , cmp::scalar_equal<double>(1,0));
BOOST_CHECK_EQUAL( false , cmp::scalar_equal<double>(0,1));
BOOST_CHECK_EQUAL( false , cmp::scalar_equal<double>(-1,1));
double v1,v2;
/* Should be equal: */
{
v1 = 0.0;
v2 = 0.0;
BOOST_CHECK( cmp::scalar_equal<double>( v1 , v2));
v1 = 1e-12;
v2 = v1 + 0.5*abs_epsilon;
BOOST_CHECK( cmp::scalar_equal<double>( v1 , v2));
v1 = 7.0;
v2 = 7.0;
BOOST_CHECK( cmp::scalar_equal<double>( v1 , v2));
v1 = -7.0;
v2 = -7.0;
BOOST_CHECK( cmp::scalar_equal<double>( v1 , v2));
v1 = 0;
v2 = 0.5 * abs_epsilon;
BOOST_CHECK( cmp::scalar_equal<double>( v1 , v2));
v1 = 1e7;
v2 = 1e7 + 2*abs_epsilon;
BOOST_CHECK( cmp::scalar_equal<double>( v1 , v2 ));
v1 = 1e7*(1 - abs_epsilon);
v2 = 1e7*(1 + rel_epsilon);
BOOST_CHECK( !cmp::scalar_equal<double>( v1 , v2 ));
v1 = 1e7*(1 + abs_epsilon);
v2 = 1e7*(1 + rel_epsilon);
BOOST_CHECK( cmp::scalar_equal<double>( v1 , v2 ));
}
/* Should be different: */
{
v1 = 0;
v2 = 1.5 * abs_epsilon;
BOOST_CHECK( !cmp::scalar_equal<double>( v1 , v2 ));
v1 = 1e-8;
v2 = v1 + 1.5*abs_epsilon;
BOOST_CHECK( !cmp::scalar_equal<double>( v1 , v2 ));
v1 = 1;
v2 = v1*(1 + 2*rel_epsilon + abs_epsilon);
BOOST_CHECK( !cmp::scalar_equal<double>( v1 , v2 ));
v1 = 10;
v2 = v1*(1 + 2*rel_epsilon + abs_epsilon);
BOOST_CHECK( !cmp::scalar_equal<double>( v1 , v2 ));
v1 = 1e7;
v2 = 1e7*(1 + 2*rel_epsilon + abs_epsilon);
BOOST_CHECK( !cmp::scalar_equal<double>( v1 , v2 ));
}
}
/* Ensure that float instantiation works. */
BOOST_AUTO_TEST_CASE(TestFloatcmp) {
std::vector<float> v1;
std::vector<float> v2;
for (size_t i =0; i < 10; i++) {
v1.push_back( i * 1.0 );
v2.push_back( i * 1.0 );
}
BOOST_CHECK( cmp::vector_equal<float>(v1 , v2 ));
v1.push_back( 27 );
BOOST_CHECK( !cmp::vector_equal<float>(v1 , v2 ));
v2.push_back( 27 );
BOOST_CHECK( cmp::vector_equal(v1 , v2 ));
}

View File

@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -e
pushd . > /dev/null
opm-common/travis/build-opm-common.sh
cd opm-common/build
ctest --output-on-failure
popd > /dev/null

View File

@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -e
pushd . > /dev/null
cd opm-common
mkdir build
cd build
cmake ../ -DBUILD_SHARED_LIBS=ON
make
popd > /dev/null

10
travis/build-opm-common.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -e
pushd . > /dev/null
cd opm-common
mkdir build
cd build
cmake ../
make
popd > /dev/null