Compare commits
26 Commits
release/20
...
release/20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1371b5706d | ||
|
|
b571dd9d66 | ||
|
|
ad746440e0 | ||
|
|
2bae3b2300 | ||
|
|
75a2a7e0ee | ||
|
|
917fc523ad | ||
|
|
28e492ecb9 | ||
|
|
ec1c315968 | ||
|
|
cf72ef0330 | ||
|
|
10a3bc4b56 | ||
|
|
8b4d8f1734 | ||
|
|
7cea357930 | ||
|
|
720fb8dcab | ||
|
|
8e56b44201 | ||
|
|
b14c5fc1a9 | ||
|
|
565d6b76dc | ||
|
|
ac840312e7 | ||
|
|
5e800ae2e7 | ||
|
|
2e0583cc74 | ||
|
|
8365eaed0b | ||
|
|
571582c881 | ||
|
|
6439ae1cea | ||
|
|
e796916057 | ||
|
|
63b663228a | ||
|
|
bf475b73b4 | ||
|
|
1e734020f1 |
@@ -73,12 +73,8 @@ macro (config_hook)
|
|||||||
if(NOT cjson_FOUND)
|
if(NOT cjson_FOUND)
|
||||||
list(APPEND EXTRA_INCLUDES ${PROJECT_SOURCE_DIR}/external/cjson)
|
list(APPEND EXTRA_INCLUDES ${PROJECT_SOURCE_DIR}/external/cjson)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# For this project
|
# For this project
|
||||||
add_definitions(-DFMT_HEADER_ONLY)
|
|
||||||
include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/external/fmtlib/include)
|
|
||||||
include_directories(${EXTRA_INCLUDES} ${PROJECT_BINARY_DIR}/include)
|
include_directories(${EXTRA_INCLUDES} ${PROJECT_BINARY_DIR}/include)
|
||||||
list(APPEND EXTRA_INCLUDES ${PROJECT_SOURCE_DIR}/external/fmtlib/include)
|
|
||||||
|
|
||||||
# For downstreams
|
# For downstreams
|
||||||
list(APPEND EXTRA_INCLUDES ${PROJECT_BINARY_DIR}/include)
|
list(APPEND EXTRA_INCLUDES ${PROJECT_BINARY_DIR}/include)
|
||||||
@@ -197,7 +193,11 @@ if(ENABLE_ECL_INPUT)
|
|||||||
test_util/summary.cpp
|
test_util/summary.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach(target compareECL convertECL summary)
|
add_executable(test_esmry_lod
|
||||||
|
test_util/test_esmry_lod.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach(target compareECL convertECL summary test_esmry_lod)
|
||||||
target_link_libraries(${target} opmcommon)
|
target_link_libraries(${target} opmcommon)
|
||||||
install(TARGETS ${target} DESTINATION bin)
|
install(TARGETS ${target} DESTINATION bin)
|
||||||
endforeach()
|
endforeach()
|
||||||
@@ -259,11 +259,10 @@ if (OPM_ENABLE_PYTHON)
|
|||||||
list(APPEND _opmcommon_include_dirs ${_ecl_include_dirs})
|
list(APPEND _opmcommon_include_dirs ${_ecl_include_dirs})
|
||||||
string(REPLACE ";" ":" _setup_include_dirs "${_opmcommon_include_dirs}")
|
string(REPLACE ";" ":" _setup_include_dirs "${_opmcommon_include_dirs}")
|
||||||
|
|
||||||
get_target_property(_opmcommon_lib_dirs opmcommon LINK_DIRECTORIES)
|
|
||||||
if (CMAKE_PREFIX_PATH)
|
if (CMAKE_PREFIX_PATH)
|
||||||
list(APPEND _opmcommon_lib_dirs ${PROJECT_BINARY_DIR}/lib ${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR})
|
set(_opmcommon_lib_dirs ${PROJECT_BINARY_DIR}/lib ${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR})
|
||||||
else()
|
else()
|
||||||
list(APPEND _opmcommon_lib_dirs ${PROJECT_BINARY_DIR}/lib)
|
set(_opmcommon_lib_dirs ${PROJECT_BINARY_DIR}/lib)
|
||||||
endif()
|
endif()
|
||||||
string(REPLACE ";" ":" _setup_lib_dirs "${_opmcommon_lib_dirs}")
|
string(REPLACE ";" ":" _setup_lib_dirs "${_opmcommon_lib_dirs}")
|
||||||
|
|
||||||
@@ -289,11 +288,6 @@ if (OPM_ENABLE_PYTHON)
|
|||||||
set( _rpath_arg "")
|
set( _rpath_arg "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(opm-common_PYTHON_PACKAGE_VERSION ${OPM_PYTHON_PACKAGE_VERSION_TAG})
|
|
||||||
|
|
||||||
# Generate versioned setup.py
|
|
||||||
configure_file (${PROJECT_SOURCE_DIR}/python/setup.py.in ${PROJECT_BINARY_DIR}/python/setup.py)
|
|
||||||
file(COPY ${PROJECT_SOURCE_DIR}/python/README.md DESTINATION ${PROJECT_BINARY_DIR}/python)
|
|
||||||
execute_process(COMMAND ${PYTHON_EXECUTABLE} target_name.py
|
execute_process(COMMAND ${PYTHON_EXECUTABLE} target_name.py
|
||||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/python
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/python
|
||||||
OUTPUT_VARIABLE python_lib_target)
|
OUTPUT_VARIABLE python_lib_target)
|
||||||
@@ -301,19 +295,19 @@ if (OPM_ENABLE_PYTHON)
|
|||||||
add_custom_target(copy_python ALL
|
add_custom_target(copy_python ALL
|
||||||
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/python/install.py ${PROJECT_SOURCE_DIR}/python ${PROJECT_BINARY_DIR} 0)
|
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/python/install.py ${PROJECT_SOURCE_DIR}/python ${PROJECT_BINARY_DIR} 0)
|
||||||
|
|
||||||
add_custom_command(OUTPUT python/opm/${python_lib_target}
|
add_custom_command(OUTPUT python/python/opm/${python_lib_target}
|
||||||
DEPENDS ${PYTHON_CXX_DEPENDS}
|
DEPENDS ${PYTHON_CXX_DEPENDS}
|
||||||
DEPENDS copy_python
|
DEPENDS copy_python
|
||||||
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_BINARY_DIR}/python/setup.py
|
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_BINARY_DIR}/python/setup.py
|
||||||
build
|
build
|
||||||
build_ext
|
build_ext
|
||||||
--build-lib=${PROJECT_BINARY_DIR}/python
|
--build-lib=${PROJECT_BINARY_DIR}/python/python/opm
|
||||||
--library-dirs=${_setup_lib_dirs}
|
--library-dirs=${_setup_lib_dirs}
|
||||||
${_rpath_arg}
|
${_rpath_arg}
|
||||||
--include-dirs=${_setup_include_dirs}
|
--include-dirs=${_setup_include_dirs}
|
||||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/python
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/python
|
||||||
COMMENT "Building python bindings at python/opm/${python_lib_target}")
|
COMMENT "Building python bindings")
|
||||||
add_custom_target(opmcommon_python ALL DEPENDS python/opm/${python_lib_target})
|
add_custom_target(opmcommon_python ALL DEPENDS python/python/opm/${python_lib_target})
|
||||||
add_dependencies(opmcommon_python opmcommon)
|
add_dependencies(opmcommon_python opmcommon)
|
||||||
|
|
||||||
# The install target is based on manually copying the python file tree to the
|
# The install target is based on manually copying the python file tree to the
|
||||||
@@ -328,7 +322,7 @@ if (OPM_ENABLE_PYTHON)
|
|||||||
# setup.py install manually - optionally with the generated script
|
# setup.py install manually - optionally with the generated script
|
||||||
# setup-install.sh - and completely bypass cmake in the installation phase.
|
# setup-install.sh - and completely bypass cmake in the installation phase.
|
||||||
if (OPM_INSTALL_PYTHON)
|
if (OPM_INSTALL_PYTHON)
|
||||||
install( CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_BINARY_DIR}/python/install.py ${PROJECT_BINARY_DIR}/python/opm ${DEST_PREFIX}${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX} 1)")
|
install( CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_BINARY_DIR}/python/install.py ${PROJECT_BINARY_DIR}/python/python/opm ${DEST_PREFIX}${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX} 1)")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Observe that if the opmcommon library has been built as a shared library the
|
# Observe that if the opmcommon library has been built as a shared library the
|
||||||
@@ -336,11 +330,11 @@ if (OPM_ENABLE_PYTHON)
|
|||||||
# testing.
|
# testing.
|
||||||
add_test(NAME python_tests
|
add_test(NAME python_tests
|
||||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/python
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/python
|
||||||
COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/lib ${PYTHON_EXECUTABLE} setup.py build_ext --dry-run --build-lib ${PROJECT_BINARY_DIR}/python test
|
COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/lib ${PYTHON_EXECUTABLE} setup.py build_ext --dry-run --build-lib ${PROJECT_BINARY_DIR}/python/python/opm test
|
||||||
)
|
)
|
||||||
|
|
||||||
set_target_properties(opmcommon PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
set_target_properties(opmcommon PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||||
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${PROJECT_BINARY_DIR}/python)
|
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${PROJECT_BINARY_DIR}/python/python)
|
||||||
|
|
||||||
# -------------------------------------------------------------------------
|
# -------------------------------------------------------------------------
|
||||||
# Let cmake configure some small shell scripts which can be used to simplify
|
# Let cmake configure some small shell scripts which can be used to simplify
|
||||||
@@ -350,11 +344,6 @@ if (OPM_ENABLE_PYTHON)
|
|||||||
DESTINATION ${PROJECT_BINARY_DIR}
|
DESTINATION ${PROJECT_BINARY_DIR}
|
||||||
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE )
|
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE )
|
||||||
|
|
||||||
configure_file(python/setup-package.sh.in tmp/setup-package.sh)
|
|
||||||
file( COPY ${PROJECT_BINARY_DIR}/tmp/setup-package.sh
|
|
||||||
DESTINATION ${PROJECT_BINARY_DIR}
|
|
||||||
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE )
|
|
||||||
|
|
||||||
configure_file(python/setup-test.sh.in tmp/setup-test.sh)
|
configure_file(python/setup-test.sh.in tmp/setup-test.sh)
|
||||||
file( COPY ${PROJECT_BINARY_DIR}/tmp/setup-test.sh
|
file( COPY ${PROJECT_BINARY_DIR}/tmp/setup-test.sh
|
||||||
DESTINATION ${PROJECT_BINARY_DIR}
|
DESTINATION ${PROJECT_BINARY_DIR}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
# the library needs it.
|
# the library needs it.
|
||||||
|
|
||||||
list (APPEND MAIN_SOURCE_FILES
|
list (APPEND MAIN_SOURCE_FILES
|
||||||
|
src/opm/common/data/SimulationDataContainer.cpp
|
||||||
src/opm/common/OpmLog/CounterLog.cpp
|
src/opm/common/OpmLog/CounterLog.cpp
|
||||||
src/opm/common/OpmLog/EclipsePRTLog.cpp
|
src/opm/common/OpmLog/EclipsePRTLog.cpp
|
||||||
src/opm/common/OpmLog/LogBackend.cpp
|
src/opm/common/OpmLog/LogBackend.cpp
|
||||||
@@ -32,7 +33,6 @@ list (APPEND MAIN_SOURCE_FILES
|
|||||||
src/opm/common/utility/ActiveGridCells.cpp
|
src/opm/common/utility/ActiveGridCells.cpp
|
||||||
src/opm/common/utility/FileSystem.cpp
|
src/opm/common/utility/FileSystem.cpp
|
||||||
src/opm/common/utility/numeric/MonotCubicInterpolator.cpp
|
src/opm/common/utility/numeric/MonotCubicInterpolator.cpp
|
||||||
src/opm/common/utility/OpmInputError.cpp
|
|
||||||
src/opm/common/utility/parameters/Parameter.cpp
|
src/opm/common/utility/parameters/Parameter.cpp
|
||||||
src/opm/common/utility/parameters/ParameterGroup.cpp
|
src/opm/common/utility/parameters/ParameterGroup.cpp
|
||||||
src/opm/common/utility/parameters/ParameterTools.cpp
|
src/opm/common/utility/parameters/ParameterTools.cpp
|
||||||
@@ -96,12 +96,8 @@ if(ENABLE_ECL_INPUT)
|
|||||||
src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionValue.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionValue.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/Action/ASTNode.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/Action/ASTNode.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/Action/Condition.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/Action/Condition.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/Action/State.cpp
|
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/ArrayDimChecker.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/ArrayDimChecker.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/eval_uda.cpp
|
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/Events.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/Events.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/GasLiftOpt.cpp
|
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/Group/GPMaint.cpp
|
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/Group/Group.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/Group/Group.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/Group/GuideRate.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/Group/GuideRate.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/Group/GuideRateConfig.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/Group/GuideRateConfig.cpp
|
||||||
@@ -109,18 +105,15 @@ if(ENABLE_ECL_INPUT)
|
|||||||
src/opm/parser/eclipse/EclipseState/Schedule/Group/GConSale.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/Group/GConSale.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/Group/GConSump.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/Group/GConSump.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/Group/GTNode.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/Group/GTNode.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/KeywordHandlers.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/Well/injection.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/MessageLimits.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/MessageLimits.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/MSW/icd.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/MSW/icd.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/MSW/AICD.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/MSW/SICD.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/MSW/SpiralICD.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/MSW/Valve.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/MSW/Valve.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/Network/Branch.cpp
|
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/Network/ExtNetwork.cpp
|
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/Network/Node.cpp
|
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/RFTConfig.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/RFTConfig.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/RPTConfig.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/RPTConfig.cpp
|
||||||
@@ -129,7 +122,7 @@ if(ENABLE_ECL_INPUT)
|
|||||||
src/opm/parser/eclipse/EclipseState/Schedule/SummaryState.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/SummaryState.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/TimeMap.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/TimeMap.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/Well/Connection.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/Well/Connection.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/Well/injection.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/eval_uda.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/Well/WList.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/Well/WList.cpp
|
||||||
@@ -158,7 +151,6 @@ if(ENABLE_ECL_INPUT)
|
|||||||
src/opm/parser/eclipse/EclipseState/Tables/TableColumn.cpp
|
src/opm/parser/eclipse/EclipseState/Tables/TableColumn.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Tables/TableContainer.cpp
|
src/opm/parser/eclipse/EclipseState/Tables/TableContainer.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Tables/TableIndex.cpp
|
src/opm/parser/eclipse/EclipseState/Tables/TableIndex.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Tables/TLMixpar.cpp
|
|
||||||
src/opm/parser/eclipse/EclipseState/Tables/TableManager.cpp
|
src/opm/parser/eclipse/EclipseState/Tables/TableManager.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Tables/TableSchema.cpp
|
src/opm/parser/eclipse/EclipseState/Tables/TableSchema.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Tables/Tables.cpp
|
src/opm/parser/eclipse/EclipseState/Tables/Tables.cpp
|
||||||
@@ -166,7 +158,6 @@ if(ENABLE_ECL_INPUT)
|
|||||||
src/opm/parser/eclipse/EclipseState/Tables/Rock2dtrTable.cpp
|
src/opm/parser/eclipse/EclipseState/Tables/Rock2dtrTable.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Tables/PvtwsaltTable.cpp
|
src/opm/parser/eclipse/EclipseState/Tables/PvtwsaltTable.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Tables/BrineDensityTable.cpp
|
src/opm/parser/eclipse/EclipseState/Tables/BrineDensityTable.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Tables/RwgsaltTable.cpp
|
|
||||||
src/opm/parser/eclipse/EclipseState/Tables/SolventDensityTable.cpp
|
src/opm/parser/eclipse/EclipseState/Tables/SolventDensityTable.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQASTNode.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQASTNode.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQParams.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQParams.cpp
|
||||||
@@ -176,13 +167,11 @@ if(ENABLE_ECL_INPUT)
|
|||||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQAssign.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQAssign.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQDefine.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQDefine.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQToken.cpp
|
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQContext.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQContext.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunction.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunction.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunctionTable.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunctionTable.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQInput.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQInput.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQState.cpp
|
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.cpp
|
||||||
src/opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.cpp
|
src/opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.cpp
|
||||||
src/opm/parser/eclipse/Parser/ErrorGuard.cpp
|
src/opm/parser/eclipse/Parser/ErrorGuard.cpp
|
||||||
@@ -198,6 +187,7 @@ if(ENABLE_ECL_INPUT)
|
|||||||
src/opm/parser/eclipse/Units/Dimension.cpp
|
src/opm/parser/eclipse/Units/Dimension.cpp
|
||||||
src/opm/parser/eclipse/Units/UnitSystem.cpp
|
src/opm/parser/eclipse/Units/UnitSystem.cpp
|
||||||
src/opm/parser/eclipse/Utility/Functional.cpp
|
src/opm/parser/eclipse/Utility/Functional.cpp
|
||||||
|
src/opm/parser/eclipse/Utility/Stringview.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -302,10 +292,10 @@ list (APPEND TEST_SOURCE_FILES
|
|||||||
tests/test_cubic.cpp
|
tests/test_cubic.cpp
|
||||||
tests/test_messagelimiter.cpp
|
tests/test_messagelimiter.cpp
|
||||||
tests/test_nonuniformtablelinear.cpp
|
tests/test_nonuniformtablelinear.cpp
|
||||||
tests/test_OpmInputError_format.cpp
|
|
||||||
tests/test_OpmLog.cpp
|
tests/test_OpmLog.cpp
|
||||||
tests/test_param.cpp
|
tests/test_param.cpp
|
||||||
tests/test_RootFinders.cpp
|
tests/test_RootFinders.cpp
|
||||||
|
tests/test_SimulationDataContainer.cpp
|
||||||
tests/test_sparsevector.cpp
|
tests/test_sparsevector.cpp
|
||||||
tests/test_uniformtablelinear.cpp
|
tests/test_uniformtablelinear.cpp
|
||||||
)
|
)
|
||||||
@@ -313,7 +303,6 @@ if(ENABLE_ECL_INPUT)
|
|||||||
list(APPEND TEST_SOURCE_FILES
|
list(APPEND TEST_SOURCE_FILES
|
||||||
tests/rst_test.cpp
|
tests/rst_test.cpp
|
||||||
tests/test_ERsm.cpp
|
tests/test_ERsm.cpp
|
||||||
tests/test_GuideRate.cpp
|
|
||||||
tests/parser/ACTIONX.cpp
|
tests/parser/ACTIONX.cpp
|
||||||
tests/parser/ADDREGTests.cpp
|
tests/parser/ADDREGTests.cpp
|
||||||
tests/parser/AquiferTests.cpp
|
tests/parser/AquiferTests.cpp
|
||||||
@@ -343,7 +332,6 @@ if(ENABLE_ECL_INPUT)
|
|||||||
tests/parser/MultiRegTests.cpp
|
tests/parser/MultiRegTests.cpp
|
||||||
tests/parser/MultisegmentWellTests.cpp
|
tests/parser/MultisegmentWellTests.cpp
|
||||||
tests/parser/MULTREGTScannerTests.cpp
|
tests/parser/MULTREGTScannerTests.cpp
|
||||||
tests/parser/NetworkTests.cpp
|
|
||||||
tests/parser/OrderedMapTests.cpp
|
tests/parser/OrderedMapTests.cpp
|
||||||
tests/parser/ParseContextTests.cpp
|
tests/parser/ParseContextTests.cpp
|
||||||
tests/parser/ParseContext_EXIT1.cpp
|
tests/parser/ParseContext_EXIT1.cpp
|
||||||
@@ -377,6 +365,7 @@ if(ENABLE_ECL_INPUT)
|
|||||||
tests/parser/TuningTests.cpp
|
tests/parser/TuningTests.cpp
|
||||||
tests/parser/UDQTests.cpp
|
tests/parser/UDQTests.cpp
|
||||||
tests/parser/UnitTests.cpp
|
tests/parser/UnitTests.cpp
|
||||||
|
tests/parser/ValueTests.cpp
|
||||||
tests/parser/WellSolventTests.cpp
|
tests/parser/WellSolventTests.cpp
|
||||||
tests/parser/WellTracerTests.cpp
|
tests/parser/WellTracerTests.cpp
|
||||||
tests/parser/WellTests.cpp
|
tests/parser/WellTests.cpp
|
||||||
@@ -392,7 +381,6 @@ if(ENABLE_ECL_OUTPUT)
|
|||||||
tests/test_AggregateConnectionData.cpp
|
tests/test_AggregateConnectionData.cpp
|
||||||
tests/test_AggregateUDQData.cpp
|
tests/test_AggregateUDQData.cpp
|
||||||
tests/test_ArrayDimChecker.cpp
|
tests/test_ArrayDimChecker.cpp
|
||||||
tests/test_data_GuideRateValue.cpp
|
|
||||||
tests/test_EclipseIO.cpp
|
tests/test_EclipseIO.cpp
|
||||||
tests/test_DoubHEAD.cpp
|
tests/test_DoubHEAD.cpp
|
||||||
tests/test_InteHEAD.cpp
|
tests/test_InteHEAD.cpp
|
||||||
@@ -405,7 +393,6 @@ if(ENABLE_ECL_OUTPUT)
|
|||||||
tests/test_RFT.cpp
|
tests/test_RFT.cpp
|
||||||
tests/test_rst.cpp
|
tests/test_rst.cpp
|
||||||
tests/test_Solution.cpp
|
tests/test_Solution.cpp
|
||||||
tests/test_Serializer.cpp
|
|
||||||
tests/test_Summary.cpp
|
tests/test_Summary.cpp
|
||||||
tests/test_Summary_Group.cpp
|
tests/test_Summary_Group.cpp
|
||||||
tests/test_Tables.cpp
|
tests/test_Tables.cpp
|
||||||
@@ -420,6 +407,8 @@ list (APPEND TEST_DATA_FILES
|
|||||||
)
|
)
|
||||||
if(ENABLE_ECL_OUTPUT)
|
if(ENABLE_ECL_OUTPUT)
|
||||||
list (APPEND TEST_DATA_FILES
|
list (APPEND TEST_DATA_FILES
|
||||||
|
tests/expect-wdims.chldg.err.out
|
||||||
|
tests/expect-wdims.err.out
|
||||||
tests/BASE_SIM.DATA
|
tests/BASE_SIM.DATA
|
||||||
tests/BASE_SIM_THPRES.DATA
|
tests/BASE_SIM_THPRES.DATA
|
||||||
tests/RESTART_SIM.DATA
|
tests/RESTART_SIM.DATA
|
||||||
@@ -435,8 +424,6 @@ if(ENABLE_ECL_OUTPUT)
|
|||||||
tests/SPE1CASE1A.SMSPEC
|
tests/SPE1CASE1A.SMSPEC
|
||||||
tests/SPE9_CP_PACKED.DATA
|
tests/SPE9_CP_PACKED.DATA
|
||||||
tests/SOFR_TEST.DATA
|
tests/SOFR_TEST.DATA
|
||||||
tests/UDQ_BASE.DATA
|
|
||||||
tests/UDQ_RESTART.DATA
|
|
||||||
tests/UDQ_TEST_WCONPROD_IUAD-2.DATA
|
tests/UDQ_TEST_WCONPROD_IUAD-2.DATA
|
||||||
tests/UDQ_ACTIONX_TEST1.DATA
|
tests/UDQ_ACTIONX_TEST1.DATA
|
||||||
tests/UDQ_ACTIONX_TEST1_U.DATA
|
tests/UDQ_ACTIONX_TEST1_U.DATA
|
||||||
@@ -449,7 +436,6 @@ if(ENABLE_ECL_OUTPUT)
|
|||||||
tests/SPE1CASE2_RESTART.DATA
|
tests/SPE1CASE2_RESTART.DATA
|
||||||
tests/SPE1CASE2.X0060
|
tests/SPE1CASE2.X0060
|
||||||
tests/PYACTION.DATA
|
tests/PYACTION.DATA
|
||||||
tests/0A4_GRCTRL_LRAT_LRAT_GGR_BASE_MODEL2_MSW_ALL.DATA
|
|
||||||
tests/act1.py
|
tests/act1.py
|
||||||
tests/MSW.DATA
|
tests/MSW.DATA
|
||||||
tests/EXIT_TEST.DATA
|
tests/EXIT_TEST.DATA
|
||||||
@@ -486,8 +472,6 @@ if(ENABLE_ECL_INPUT)
|
|||||||
examples/opmi.cpp
|
examples/opmi.cpp
|
||||||
examples/opmpack.cpp
|
examples/opmpack.cpp
|
||||||
examples/opmhash.cpp
|
examples/opmhash.cpp
|
||||||
examples/wellgraph.cpp
|
|
||||||
examples/make_lodsmry.cpp
|
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -500,13 +484,13 @@ if(ENABLE_ECL_INPUT)
|
|||||||
examples/opmi.cpp
|
examples/opmi.cpp
|
||||||
examples/opmpack.cpp
|
examples/opmpack.cpp
|
||||||
examples/opmhash.cpp
|
examples/opmhash.cpp
|
||||||
examples/make_lodsmry.cpp
|
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
list( APPEND PUBLIC_HEADER_FILES
|
list( APPEND PUBLIC_HEADER_FILES
|
||||||
opm/common/ErrorMacros.hpp
|
opm/common/ErrorMacros.hpp
|
||||||
opm/common/Exceptions.hpp
|
opm/common/Exceptions.hpp
|
||||||
|
opm/common/data/SimulationDataContainer.hpp
|
||||||
opm/common/OpmLog/CounterLog.hpp
|
opm/common/OpmLog/CounterLog.hpp
|
||||||
opm/common/OpmLog/EclipsePRTLog.hpp
|
opm/common/OpmLog/EclipsePRTLog.hpp
|
||||||
opm/common/OpmLog/LogBackend.hpp
|
opm/common/OpmLog/LogBackend.hpp
|
||||||
@@ -514,14 +498,12 @@ list( APPEND PUBLIC_HEADER_FILES
|
|||||||
opm/common/OpmLog/LogUtil.hpp
|
opm/common/OpmLog/LogUtil.hpp
|
||||||
opm/common/OpmLog/MessageFormatter.hpp
|
opm/common/OpmLog/MessageFormatter.hpp
|
||||||
opm/common/OpmLog/MessageLimiter.hpp
|
opm/common/OpmLog/MessageLimiter.hpp
|
||||||
opm/common/OpmLog/KeywordLocation.hpp
|
opm/common/OpmLog/Location.hpp
|
||||||
opm/common/OpmLog/OpmLog.hpp
|
opm/common/OpmLog/OpmLog.hpp
|
||||||
opm/common/OpmLog/StreamLog.hpp
|
opm/common/OpmLog/StreamLog.hpp
|
||||||
opm/common/OpmLog/TimerLog.hpp
|
opm/common/OpmLog/TimerLog.hpp
|
||||||
opm/common/utility/Serializer.hpp
|
|
||||||
opm/common/utility/ActiveGridCells.hpp
|
opm/common/utility/ActiveGridCells.hpp
|
||||||
opm/common/utility/FileSystem.hpp
|
opm/common/utility/FileSystem.hpp
|
||||||
opm/common/utility/OpmInputError.hpp
|
|
||||||
opm/common/utility/numeric/cmp.hpp
|
opm/common/utility/numeric/cmp.hpp
|
||||||
opm/common/utility/platform_dependent/disable_warnings.h
|
opm/common/utility/platform_dependent/disable_warnings.h
|
||||||
opm/common/utility/platform_dependent/reenable_warnings.h
|
opm/common/utility/platform_dependent/reenable_warnings.h
|
||||||
@@ -548,6 +530,7 @@ if(ENABLE_ECL_INPUT)
|
|||||||
list(APPEND PUBLIC_HEADER_FILES
|
list(APPEND PUBLIC_HEADER_FILES
|
||||||
opm/io/eclipse/SummaryNode.hpp
|
opm/io/eclipse/SummaryNode.hpp
|
||||||
opm/json/JsonObject.hpp
|
opm/json/JsonObject.hpp
|
||||||
|
opm/parser/eclipse/Utility/Stringview.hpp
|
||||||
opm/parser/eclipse/Utility/Functional.hpp
|
opm/parser/eclipse/Utility/Functional.hpp
|
||||||
opm/parser/eclipse/Utility/Typetools.hpp
|
opm/parser/eclipse/Utility/Typetools.hpp
|
||||||
opm/parser/eclipse/Generator/KeywordGenerator.hpp
|
opm/parser/eclipse/Generator/KeywordGenerator.hpp
|
||||||
@@ -567,14 +550,12 @@ if(ENABLE_ECL_INPUT)
|
|||||||
opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp
|
opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp
|
||||||
opm/parser/eclipse/EclipseState/InitConfig/Equil.hpp
|
opm/parser/eclipse/EclipseState/InitConfig/Equil.hpp
|
||||||
opm/parser/eclipse/EclipseState/InitConfig/FoamConfig.hpp
|
opm/parser/eclipse/EclipseState/InitConfig/FoamConfig.hpp
|
||||||
|
opm/parser/eclipse/EclipseState/Util/Value.hpp
|
||||||
opm/parser/eclipse/EclipseState/Util/IOrderSet.hpp
|
opm/parser/eclipse/EclipseState/Util/IOrderSet.hpp
|
||||||
opm/parser/eclipse/EclipseState/Util/OrderedMap.hpp
|
opm/parser/eclipse/EclipseState/Util/OrderedMap.hpp
|
||||||
opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp
|
opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp
|
||||||
opm/parser/eclipse/EclipseState/Edit/EDITNNC.hpp
|
opm/parser/eclipse/EclipseState/Edit/EDITNNC.hpp
|
||||||
opm/parser/eclipse/EclipseState/Grid/FieldData.hpp
|
|
||||||
opm/parser/eclipse/EclipseState/Grid/Keywords.hpp
|
|
||||||
opm/parser/eclipse/EclipseState/Grid/GridDims.hpp
|
opm/parser/eclipse/EclipseState/Grid/GridDims.hpp
|
||||||
opm/parser/eclipse/EclipseState/Grid/TranCalculator.hpp
|
|
||||||
opm/parser/eclipse/EclipseState/Grid/TransMult.hpp
|
opm/parser/eclipse/EclipseState/Grid/TransMult.hpp
|
||||||
opm/parser/eclipse/EclipseState/Grid/PinchMode.hpp
|
opm/parser/eclipse/EclipseState/Grid/PinchMode.hpp
|
||||||
opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.hpp
|
opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.hpp
|
||||||
@@ -605,11 +586,8 @@ if(ENABLE_ECL_INPUT)
|
|||||||
opm/parser/eclipse/EclipseState/Tables/SpecrockTable.hpp
|
opm/parser/eclipse/EclipseState/Tables/SpecrockTable.hpp
|
||||||
opm/parser/eclipse/EclipseState/Tables/PvtwsaltTable.hpp
|
opm/parser/eclipse/EclipseState/Tables/PvtwsaltTable.hpp
|
||||||
opm/parser/eclipse/EclipseState/Tables/BrineDensityTable.hpp
|
opm/parser/eclipse/EclipseState/Tables/BrineDensityTable.hpp
|
||||||
opm/parser/eclipse/EclipseState/Tables/PermfactTable.hpp
|
|
||||||
opm/parser/eclipse/EclipseState/Tables/RwgsaltTable.hpp
|
|
||||||
opm/parser/eclipse/EclipseState/Tables/SaltvdTable.hpp
|
|
||||||
opm/parser/eclipse/EclipseState/Tables/SaltpvdTable.hpp
|
|
||||||
opm/parser/eclipse/EclipseState/Tables/SolventDensityTable.hpp
|
opm/parser/eclipse/EclipseState/Tables/SolventDensityTable.hpp
|
||||||
|
opm/parser/eclipse/EclipseState/Tables/SaltvdTable.hpp
|
||||||
opm/parser/eclipse/EclipseState/Tables/PlydhflfTable.hpp
|
opm/parser/eclipse/EclipseState/Tables/PlydhflfTable.hpp
|
||||||
opm/parser/eclipse/EclipseState/Tables/PlymwinjTable.hpp
|
opm/parser/eclipse/EclipseState/Tables/PlymwinjTable.hpp
|
||||||
opm/parser/eclipse/EclipseState/Tables/PlyshlogTable.hpp
|
opm/parser/eclipse/EclipseState/Tables/PlyshlogTable.hpp
|
||||||
@@ -619,7 +597,6 @@ if(ENABLE_ECL_INPUT)
|
|||||||
opm/parser/eclipse/EclipseState/Tables/SpecheatTable.hpp
|
opm/parser/eclipse/EclipseState/Tables/SpecheatTable.hpp
|
||||||
opm/parser/eclipse/EclipseState/Tables/SgcwmisTable.hpp
|
opm/parser/eclipse/EclipseState/Tables/SgcwmisTable.hpp
|
||||||
opm/parser/eclipse/EclipseState/Tables/Sof2Table.hpp
|
opm/parser/eclipse/EclipseState/Tables/Sof2Table.hpp
|
||||||
opm/parser/eclipse/EclipseState/Tables/TLMixpar.hpp
|
|
||||||
opm/parser/eclipse/EclipseState/Tables/TableManager.hpp
|
opm/parser/eclipse/EclipseState/Tables/TableManager.hpp
|
||||||
opm/parser/eclipse/EclipseState/Tables/SwfnTable.hpp
|
opm/parser/eclipse/EclipseState/Tables/SwfnTable.hpp
|
||||||
opm/parser/eclipse/EclipseState/Tables/EnptvdTable.hpp
|
opm/parser/eclipse/EclipseState/Tables/EnptvdTable.hpp
|
||||||
@@ -629,8 +606,6 @@ if(ENABLE_ECL_INPUT)
|
|||||||
opm/parser/eclipse/EclipseState/Tables/JFunc.hpp
|
opm/parser/eclipse/EclipseState/Tables/JFunc.hpp
|
||||||
opm/parser/eclipse/EclipseState/Tables/TableIndex.hpp
|
opm/parser/eclipse/EclipseState/Tables/TableIndex.hpp
|
||||||
opm/parser/eclipse/EclipseState/Tables/PvtgTable.hpp
|
opm/parser/eclipse/EclipseState/Tables/PvtgTable.hpp
|
||||||
opm/parser/eclipse/EclipseState/Tables/PvtgwTable.hpp
|
|
||||||
opm/parser/eclipse/EclipseState/Tables/PvtgwoTable.hpp
|
|
||||||
opm/parser/eclipse/EclipseState/Tables/Tabdims.hpp
|
opm/parser/eclipse/EclipseState/Tables/Tabdims.hpp
|
||||||
opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp
|
opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp
|
||||||
opm/parser/eclipse/EclipseState/Tables/RocktabTable.hpp
|
opm/parser/eclipse/EclipseState/Tables/RocktabTable.hpp
|
||||||
@@ -687,12 +662,7 @@ if(ENABLE_ECL_INPUT)
|
|||||||
opm/parser/eclipse/EclipseState/Schedule/Action/Condition.hpp
|
opm/parser/eclipse/EclipseState/Schedule/Action/Condition.hpp
|
||||||
opm/parser/eclipse/EclipseState/Schedule/Action/ASTNode.hpp
|
opm/parser/eclipse/EclipseState/Schedule/Action/ASTNode.hpp
|
||||||
opm/parser/eclipse/EclipseState/Schedule/Action/PyAction.hpp
|
opm/parser/eclipse/EclipseState/Schedule/Action/PyAction.hpp
|
||||||
opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp
|
|
||||||
opm/parser/eclipse/EclipseState/Schedule/ArrayDimChecker.hpp
|
opm/parser/eclipse/EclipseState/Schedule/ArrayDimChecker.hpp
|
||||||
opm/parser/eclipse/EclipseState/Schedule/GasLiftOpt.hpp
|
|
||||||
opm/parser/eclipse/EclipseState/Schedule/Network/Branch.hpp
|
|
||||||
opm/parser/eclipse/EclipseState/Schedule/Network/ExtNetwork.hpp
|
|
||||||
opm/parser/eclipse/EclipseState/Schedule/Network/Node.hpp
|
|
||||||
opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp
|
opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp
|
||||||
opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp
|
opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp
|
||||||
opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.hpp
|
opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.hpp
|
||||||
@@ -719,7 +689,6 @@ if(ENABLE_ECL_INPUT)
|
|||||||
opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp
|
opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp
|
||||||
opm/parser/eclipse/EclipseState/Schedule/ScheduleTypes.hpp
|
opm/parser/eclipse/EclipseState/Schedule/ScheduleTypes.hpp
|
||||||
opm/parser/eclipse/EclipseState/Schedule/Tuning.hpp
|
opm/parser/eclipse/EclipseState/Schedule/Tuning.hpp
|
||||||
opm/parser/eclipse/EclipseState/Schedule/Group/GPMaint.hpp
|
|
||||||
opm/parser/eclipse/EclipseState/Schedule/Group/GTNode.hpp
|
opm/parser/eclipse/EclipseState/Schedule/Group/GTNode.hpp
|
||||||
opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp
|
opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp
|
||||||
opm/parser/eclipse/EclipseState/Schedule/Group/GuideRate.hpp
|
opm/parser/eclipse/EclipseState/Schedule/Group/GuideRate.hpp
|
||||||
@@ -735,8 +704,8 @@ if(ENABLE_ECL_INPUT)
|
|||||||
opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.hpp
|
opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.hpp
|
||||||
opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.hpp
|
opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.hpp
|
||||||
opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.hpp
|
opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.hpp
|
||||||
opm/parser/eclipse/EclipseState/Schedule/MSW/AICD.hpp
|
opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.hpp
|
||||||
opm/parser/eclipse/EclipseState/Schedule/MSW/SICD.hpp
|
opm/parser/eclipse/EclipseState/Schedule/MSW/SpiralICD.hpp
|
||||||
opm/parser/eclipse/EclipseState/SimulationConfig/ThresholdPressure.hpp
|
opm/parser/eclipse/EclipseState/SimulationConfig/ThresholdPressure.hpp
|
||||||
opm/parser/eclipse/EclipseState/SimulationConfig/BCConfig.hpp
|
opm/parser/eclipse/EclipseState/SimulationConfig/BCConfig.hpp
|
||||||
opm/parser/eclipse/EclipseState/SimulationConfig/RockConfig.hpp
|
opm/parser/eclipse/EclipseState/SimulationConfig/RockConfig.hpp
|
||||||
@@ -750,7 +719,6 @@ if(ENABLE_ECL_INPUT)
|
|||||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQASTNode.hpp
|
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQASTNode.hpp
|
||||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQDefine.hpp
|
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQDefine.hpp
|
||||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQContext.hpp
|
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQContext.hpp
|
||||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQState.hpp
|
|
||||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.hpp
|
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.hpp
|
||||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp
|
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp
|
||||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQParams.hpp
|
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQParams.hpp
|
||||||
@@ -792,10 +760,9 @@ if(ENABLE_ECL_OUTPUT)
|
|||||||
opm/io/eclipse/rst/well.hpp
|
opm/io/eclipse/rst/well.hpp
|
||||||
opm/output/data/Aquifer.hpp
|
opm/output/data/Aquifer.hpp
|
||||||
opm/output/data/Cells.hpp
|
opm/output/data/Cells.hpp
|
||||||
opm/output/data/GuideRateValue.hpp
|
|
||||||
opm/output/data/Groups.hpp
|
|
||||||
opm/output/data/Solution.hpp
|
opm/output/data/Solution.hpp
|
||||||
opm/output/data/Wells.hpp
|
opm/output/data/Wells.hpp
|
||||||
|
opm/output/data/Groups.hpp
|
||||||
opm/output/eclipse/VectorItems/aquifer.hpp
|
opm/output/eclipse/VectorItems/aquifer.hpp
|
||||||
opm/output/eclipse/VectorItems/connection.hpp
|
opm/output/eclipse/VectorItems/connection.hpp
|
||||||
opm/output/eclipse/VectorItems/group.hpp
|
opm/output/eclipse/VectorItems/group.hpp
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ set(genkw_SOURCES src/opm/json/JsonObject.cpp
|
|||||||
src/opm/parser/eclipse/Parser/raw/StarToken.cpp
|
src/opm/parser/eclipse/Parser/raw/StarToken.cpp
|
||||||
src/opm/parser/eclipse/Units/Dimension.cpp
|
src/opm/parser/eclipse/Units/Dimension.cpp
|
||||||
src/opm/parser/eclipse/Units/UnitSystem.cpp
|
src/opm/parser/eclipse/Units/UnitSystem.cpp
|
||||||
src/opm/common/utility/OpmInputError.cpp
|
src/opm/parser/eclipse/Utility/Stringview.cpp
|
||||||
src/opm/common/OpmLog/OpmLog.cpp
|
src/opm/common/OpmLog/OpmLog.cpp
|
||||||
src/opm/common/OpmLog/Logger.cpp
|
src/opm/common/OpmLog/Logger.cpp
|
||||||
src/opm/common/OpmLog/StreamLog.cpp
|
src/opm/common/OpmLog/StreamLog.cpp
|
||||||
|
|||||||
@@ -60,19 +60,6 @@ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${MPI_C_COMPILE_FLAGS}")
|
|||||||
|
|
||||||
include(CheckIncludeFile)
|
include(CheckIncludeFile)
|
||||||
check_include_file(parmetis.h PARMETIS_FOUND)
|
check_include_file(parmetis.h PARMETIS_FOUND)
|
||||||
|
|
||||||
if(NOT PARMETIS_FOUND)
|
|
||||||
# If we are using the ParMETIS bindings of PTScotch, we need
|
|
||||||
# to use the scotch include path as partmetis.h includes scotch.h
|
|
||||||
find_package(PTScotch)
|
|
||||||
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${PTSCOTCH_INCLUDE_DIR})
|
|
||||||
unset(PARMETIS_FOUND CACHE) # force recheck of include file
|
|
||||||
check_include_file(parmetis.h PARMETIS_FOUND)
|
|
||||||
if(PARMETIS_FOUND)
|
|
||||||
set(PARMETIS_SCOTCH_INCLUDE_DIRS ${PTSCOTCH_INCLUDE_DIRS})
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
_search_parmetis_lib(PARMETIS_LIBRARY parmetis "The main ParMETIS library.")
|
_search_parmetis_lib(PARMETIS_LIBRARY parmetis "The main ParMETIS library.")
|
||||||
|
|
||||||
# behave like a CMake module is supposed to behave
|
# behave like a CMake module is supposed to behave
|
||||||
@@ -90,7 +77,7 @@ find_package_handle_standard_args(
|
|||||||
cmake_pop_check_state()
|
cmake_pop_check_state()
|
||||||
|
|
||||||
if(PARMETIS_FOUND)
|
if(PARMETIS_FOUND)
|
||||||
set(PARMETIS_INCLUDE_DIRS ${PARMETIS_INCLUDE_DIR} ${PARMETIS_SCOTCH_INCLUDE_DIRS})
|
set(PARMETIS_INCLUDE_DIRS ${PARMETIS_INCLUDE_DIR})
|
||||||
set(PARMETIS_LIBRARIES ${PARMETIS_LIBRARY} ${METIS_LIBRARIES} ${MPI_C_LIBRARIES}
|
set(PARMETIS_LIBRARIES ${PARMETIS_LIBRARY} ${METIS_LIBRARIES} ${MPI_C_LIBRARIES}
|
||||||
CACHE FILEPATH "All libraries needed to link programs using ParMETIS")
|
CACHE FILEPATH "All libraries needed to link programs using ParMETIS")
|
||||||
set(PARMETIS_LINK_FLAGS "${DUNE_C_LINK_FLAGS}"
|
set(PARMETIS_LINK_FLAGS "${DUNE_C_LINK_FLAGS}"
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ find_opm_package (
|
|||||||
# test program
|
# test program
|
||||||
"#include <dune/geometry/quadraturerules.hh>
|
"#include <dune/geometry/quadraturerules.hh>
|
||||||
int main (void) {
|
int main (void) {
|
||||||
Dune::GeometryType gt = Dune::GeometryTypes::quadrilateral;
|
Dune::GeometryType gt;
|
||||||
|
gt.makeQuadrilateral();
|
||||||
Dune::QuadratureRules<double, 2>::rule(gt, 2).size();
|
Dune::QuadratureRules<double, 2>::rule(gt, 2).size();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,13 +106,8 @@ macro (find_and_append_package_to prefix name)
|
|||||||
|
|
||||||
# if we're told not to look for the package, pretend it was never found
|
# if we're told not to look for the package, pretend it was never found
|
||||||
if (CMAKE_DISABLE_FIND_PACKAGE_${name})
|
if (CMAKE_DISABLE_FIND_PACKAGE_${name})
|
||||||
# If required send an error
|
set (${name}_FOUND FALSE)
|
||||||
cmake_parse_arguments(FIND "REQUIRED" "" "" ${ARGN} )
|
set (${NAME}_FOUND FALSE)
|
||||||
set (${name}_FOUND FALSE)
|
|
||||||
set (${NAME}_FOUND FALSE)
|
|
||||||
if (FIND_REQUIRED)
|
|
||||||
message(SEND_ERROR "package ${name} but disable with CMAKE_DISABLE_FIND_PACKAGE_${name}")
|
|
||||||
endif ()
|
|
||||||
else ()
|
else ()
|
||||||
# List of components might differ for every module. Therefore we will
|
# List of components might differ for every module. Therefore we will
|
||||||
# need to research for a library multiple times. _search_components
|
# need to research for a library multiple times. _search_components
|
||||||
|
|||||||
@@ -62,10 +62,7 @@ include (UseOptimization)
|
|||||||
|
|
||||||
# turn on all warnings; this must be done before adding any
|
# turn on all warnings; this must be done before adding any
|
||||||
# dependencies, in case they alter the list of warnings
|
# dependencies, in case they alter the list of warnings
|
||||||
option(OPM_DISABLE_WARNINGS "Disable warning flags" OFF)
|
include (UseWarnings)
|
||||||
if(NOT OPM_DISABLE_WARNINGS)
|
|
||||||
include (UseWarnings)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# parallel programming
|
# parallel programming
|
||||||
include (UseOpenMP)
|
include (UseOpenMP)
|
||||||
|
|||||||
@@ -115,34 +115,26 @@ macro (find_opm_package module deps header lib defs prog conf)
|
|||||||
# without config.h
|
# without config.h
|
||||||
config_cmd_line (${module}_CMD_CONFIG ${module}_CONFIG_VARS)
|
config_cmd_line (${module}_CMD_CONFIG ${module}_CONFIG_VARS)
|
||||||
|
|
||||||
if(prog)
|
# check that we can compile a small test-program
|
||||||
# check that we can compile a small test-program
|
include (CMakePushCheckState)
|
||||||
include (CMakePushCheckState)
|
cmake_push_check_state ()
|
||||||
cmake_push_check_state ()
|
include (CheckCXXSourceCompiles)
|
||||||
include (CheckCXXSourceCompiles)
|
# only add these if they are actually found; otherwise it won't
|
||||||
# only add these if they are actually found; otherwise it won't
|
# compile and the variable won't be set
|
||||||
# compile and the variable won't be set
|
append_found (${module}_INCLUDE_DIRS CMAKE_REQUIRED_INCLUDES)
|
||||||
append_found (${module}_INCLUDE_DIRS CMAKE_REQUIRED_INCLUDES)
|
append_found (${module}_LIBRARIES CMAKE_REQUIRED_LIBRARIES)
|
||||||
append_found (${module}_LIBRARIES CMAKE_REQUIRED_LIBRARIES)
|
# since we don't have any config.h yet
|
||||||
# since we don't have any config.h yet
|
list (APPEND CMAKE_REQUIRED_DEFINITIONS ${${module}_DEFINITIONS})
|
||||||
list (APPEND CMAKE_REQUIRED_DEFINITIONS ${${module}_DEFINITIONS})
|
list (APPEND CMAKE_REQUIRED_DEFINITIONS ${${module}_CMD_CONFIG})
|
||||||
list (APPEND CMAKE_REQUIRED_DEFINITIONS ${${module}_CMD_CONFIG})
|
check_cxx_source_compiles ("${prog}" HAVE_${MODULE})
|
||||||
check_cxx_source_compiles ("${prog}" HAVE_${MODULE})
|
cmake_pop_check_state ()
|
||||||
cmake_pop_check_state ()
|
|
||||||
else(prog)
|
|
||||||
if(${module}_FOUND)
|
|
||||||
# No test code provided, mark compilation as successful
|
|
||||||
# if module was founf
|
|
||||||
set(HAVE_${MODULE} 1)
|
|
||||||
endif(${module}_FOUND)
|
|
||||||
endif(prog)
|
|
||||||
|
|
||||||
# write status message in the same manner as everyone else
|
# write status message in the same manner as everyone else
|
||||||
include (FindPackageHandleStandardArgs)
|
include (FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args (
|
find_package_handle_standard_args (
|
||||||
${module}
|
${module}
|
||||||
DEFAULT_MSG
|
DEFAULT_MSG
|
||||||
${module}_INCLUDE_DIRS ${module}_LIBRARIES ${module}_FOUND ${module}_ALL_PREREQS HAVE_${MODULE}
|
${module}_INCLUDE_DIRS ${module}_LIBRARIES ${module}_FOUND ${module}_ALL_PREREQS
|
||||||
)
|
)
|
||||||
|
|
||||||
# some genius that coded the FindPackageHandleStandardArgs figured out
|
# some genius that coded the FindPackageHandleStandardArgs figured out
|
||||||
|
|||||||
@@ -24,16 +24,9 @@ if (cmake_build_type_upper_ MATCHES DEBUG)
|
|||||||
"#define PROJECT_VERSION_NAME \"${${project}_LABEL}\"\n"
|
"#define PROJECT_VERSION_NAME \"${${project}_LABEL}\"\n"
|
||||||
"#define PROJECT_VERSION_HASH \"debug\"\n"
|
"#define PROJECT_VERSION_HASH \"debug\"\n"
|
||||||
"#define PROJECT_VERSION \"${${project}_LABEL} (debug)\"\n"
|
"#define PROJECT_VERSION \"${${project}_LABEL} (debug)\"\n"
|
||||||
|
"#define BUILD_TIMESTAMP \"${build_timestamp}\"\n"
|
||||||
"#endif // OPM_GENERATED_OPM_VERSION_HEADER_INCLUDED\n"
|
"#endif // OPM_GENERATED_OPM_VERSION_HEADER_INCLUDED\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Write header file with build timestamp
|
|
||||||
file (WRITE "${PROJECT_BINARY_DIR}/project-timestamp.h"
|
|
||||||
"#ifndef OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
|
|
||||||
"#define OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
|
|
||||||
"#define BUILD_TIMESTAMP \"${build_timestamp}\"\n"
|
|
||||||
"#endif // OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
|
|
||||||
)
|
|
||||||
else ()
|
else ()
|
||||||
if (NOT GIT_FOUND)
|
if (NOT GIT_FOUND)
|
||||||
find_package (Git)
|
find_package (Git)
|
||||||
@@ -50,15 +43,9 @@ else ()
|
|||||||
"#define PROJECT_VERSION_NAME \"${${project}_LABEL}\"\n"
|
"#define PROJECT_VERSION_NAME \"${${project}_LABEL}\"\n"
|
||||||
"#define PROJECT_VERSION_HASH \"unknown git version\"\n"
|
"#define PROJECT_VERSION_HASH \"unknown git version\"\n"
|
||||||
"#define PROJECT_VERSION \"${${project}_LABEL} (unknown git version)\"\n"
|
"#define PROJECT_VERSION \"${${project}_LABEL} (unknown git version)\"\n"
|
||||||
|
"#define BUILD_TIMESTAMP \"${build_timestamp}\"\n"
|
||||||
"#endif // OPM_GENERATED_OPM_VERSION_HEADER_INCLUDED\n"
|
"#endif // OPM_GENERATED_OPM_VERSION_HEADER_INCLUDED\n"
|
||||||
)
|
)
|
||||||
# Write header file with build timestamp
|
|
||||||
file (WRITE "${PROJECT_BINARY_DIR}/project-timestamp.h"
|
|
||||||
"#ifndef OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
|
|
||||||
"#define OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
|
|
||||||
"#define BUILD_TIMESTAMP \"${build_timestamp}\"\n"
|
|
||||||
"#endif // OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
|
|
||||||
)
|
|
||||||
else ()
|
else ()
|
||||||
add_custom_target (update-version ALL
|
add_custom_target (update-version ALL
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ file (WRITE "${PROJECT_BINARY_DIR}/project-version.tmp"
|
|||||||
"#define PROJECT_VERSION_NAME \"${PROJECT_LABEL}\"\n"
|
"#define PROJECT_VERSION_NAME \"${PROJECT_LABEL}\"\n"
|
||||||
"#define PROJECT_VERSION_HASH \"${sha1}\"\n"
|
"#define PROJECT_VERSION_HASH \"${sha1}\"\n"
|
||||||
"#define PROJECT_VERSION \"${PROJECT_LABEL} (${sha1})\"\n"
|
"#define PROJECT_VERSION \"${PROJECT_LABEL} (${sha1})\"\n"
|
||||||
|
"#define BUILD_TIMESTAMP \"${build_timestamp}\"\n"
|
||||||
"#endif // OPM_GENERATED_OPM_VERSION_HEADER_INCLUDED\n"
|
"#endif // OPM_GENERATED_OPM_VERSION_HEADER_INCLUDED\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -65,11 +66,3 @@ file (WRITE "${PROJECT_BINARY_DIR}/project-version.tmp"
|
|||||||
execute_process (COMMAND
|
execute_process (COMMAND
|
||||||
${CMAKE_COMMAND} -E copy_if_different "${PROJECT_BINARY_DIR}/project-version.tmp" "${PROJECT_BINARY_DIR}/project-version.h"
|
${CMAKE_COMMAND} -E copy_if_different "${PROJECT_BINARY_DIR}/project-version.tmp" "${PROJECT_BINARY_DIR}/project-version.h"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Write header file with build timestamp
|
|
||||||
file (WRITE "${PROJECT_BINARY_DIR}/project-timestamp.h"
|
|
||||||
"#ifndef OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
|
|
||||||
"#define OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
|
|
||||||
"#define BUILD_TIMESTAMP \"${build_timestamp}\"\n"
|
|
||||||
"#endif // OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
|
|
||||||
)
|
|
||||||
|
|||||||
2
debian/changelog
vendored
2
debian/changelog
vendored
@@ -1,4 +1,4 @@
|
|||||||
opm-common (2019.04-pre~xenial) xenial; urgency=medium
|
opm-common (2020.04-1~xenial) xenial; urgency=medium
|
||||||
|
|
||||||
* New release
|
* New release
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
Module: opm-common
|
Module: opm-common
|
||||||
Description: Open Porous Media Initiative shared infrastructure
|
Description: Open Porous Media Initiative shared infrastructure
|
||||||
Version: 2020.10
|
Version: 2020.04
|
||||||
Label: 2020.10
|
Label: 2020.04
|
||||||
Maintainer: opm@opm-project.org
|
Maintainer: opm@opm-project.org
|
||||||
MaintainerName: OPM community
|
MaintainerName: OPM community
|
||||||
Url: http://opm-project.org
|
Url: http://opm-project.org
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2019 Equinor ASA.
|
|
||||||
|
|
||||||
This file is part of the Open Porous Media project (OPM).
|
|
||||||
|
|
||||||
OPM is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OPM is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <getopt.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#if HAVE_OPENMP
|
|
||||||
#include <omp.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <opm/io/eclipse/ESmry.hpp>
|
|
||||||
#include <opm/io/eclipse/EclUtil.hpp>
|
|
||||||
#include <opm/common/utility/FileSystem.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
static void printHelp() {
|
|
||||||
|
|
||||||
std::cout << "\nThis program create one or more lodsmry files, designed for effective load on the demand. \n"
|
|
||||||
<< "These files are created with input from the smspec and unsmry file. \n"
|
|
||||||
<< "\nIn addition, the program takes these options (which must be given before the arguments):\n\n"
|
|
||||||
<< "-f if LODSMRY file exist, this will be replaced. Default behaviour is that existing file is kept.\n"
|
|
||||||
<< "-n Maximum number of threads to be used if mulitple files should be created.\n"
|
|
||||||
<< "-h Print help and exit.\n\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
|
||||||
|
|
||||||
int c = 0;
|
|
||||||
int max_threads [[maybe_unused]] = -1;
|
|
||||||
bool force = false;
|
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "fn:h")) != -1) {
|
|
||||||
switch (c) {
|
|
||||||
case 'f':
|
|
||||||
force = true;
|
|
||||||
break;
|
|
||||||
case 'h':
|
|
||||||
printHelp();
|
|
||||||
return 0;
|
|
||||||
case 'n':
|
|
||||||
max_threads = atoi(optarg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int argOffset = optind;
|
|
||||||
|
|
||||||
#if HAVE_OPENMP
|
|
||||||
int available_threads = omp_get_max_threads();
|
|
||||||
|
|
||||||
if (max_threads < 0)
|
|
||||||
max_threads = available_threads-2;
|
|
||||||
else if (max_threads > (available_threads - 1))
|
|
||||||
max_threads = available_threads-1;
|
|
||||||
|
|
||||||
if (max_threads > (argc-argOffset))
|
|
||||||
max_threads = argc-argOffset;
|
|
||||||
|
|
||||||
omp_set_num_threads(max_threads);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
auto lap0 = std::chrono::system_clock::now();
|
|
||||||
|
|
||||||
#pragma omp parallel for
|
|
||||||
for (int f = argOffset; f < argc; f ++){
|
|
||||||
Opm::filesystem::path inputFileName = argv[f];
|
|
||||||
|
|
||||||
Opm::filesystem::path lodFileName = inputFileName.parent_path() / inputFileName.stem();
|
|
||||||
lodFileName = lodFileName += ".LODSMRY";
|
|
||||||
|
|
||||||
if (Opm::EclIO::fileExists(lodFileName) && (force))
|
|
||||||
remove (lodFileName);
|
|
||||||
|
|
||||||
Opm::EclIO::ESmry smryFile(argv[f]);
|
|
||||||
if (!smryFile.make_lodsmry_file()){
|
|
||||||
std::cout << "\n! Warning, smspec already have one lod file, existing kept use option -f to replace this" << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto lap1 = std::chrono::system_clock::now();
|
|
||||||
std::chrono::duration<double> elapsed_seconds1 = lap1-lap0;
|
|
||||||
std::cout << "\nruntime for creating " << (argc-argOffset) << " LODSMRY files: " << elapsed_seconds1.count() << " seconds\n" << std::endl;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -27,7 +27,6 @@
|
|||||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
|
#include <opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
|
||||||
#include <opm/common/OpmLog/OpmLog.hpp>
|
|
||||||
|
|
||||||
#include <opm/msim/msim.hpp>
|
#include <opm/msim/msim.hpp>
|
||||||
|
|
||||||
@@ -39,12 +38,10 @@ int main(int /* argc */, char** argv) {
|
|||||||
Opm::ErrorGuard error_guard;
|
Opm::ErrorGuard error_guard;
|
||||||
auto python = std::make_shared<Opm::Python>();
|
auto python = std::make_shared<Opm::Python>();
|
||||||
|
|
||||||
Opm::OpmLog::setupSimpleDefaultLogging();
|
|
||||||
Opm::Deck deck = parser.parseFile(deck_file, parse_context, error_guard);
|
Opm::Deck deck = parser.parseFile(deck_file, parse_context, error_guard);
|
||||||
Opm::EclipseState state(deck);
|
Opm::EclipseState state(deck);
|
||||||
Opm::Schedule schedule(deck, state, parse_context, error_guard, python);
|
Opm::Schedule schedule(deck, state, parse_context, error_guard, python);
|
||||||
Opm::SummaryConfig summary_config(deck, schedule, state.getTableManager(), state.aquifer(),
|
Opm::SummaryConfig summary_config(deck, schedule, state.getTableManager(), parse_context, error_guard);
|
||||||
parse_context, error_guard);
|
|
||||||
|
|
||||||
if (error_guard) {
|
if (error_guard) {
|
||||||
error_guard.dump();
|
error_guard.dump();
|
||||||
|
|||||||
@@ -18,10 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <iomanip>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <fmt/format.h>
|
|
||||||
|
|
||||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||||
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
|
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
|
||||||
@@ -85,11 +85,12 @@ std::size_t deck_hash(const std::vector<keyword>& keywords) {
|
|||||||
void print_keywords(const std::vector<keyword>& keywords, bool location_info) {
|
void print_keywords(const std::vector<keyword>& keywords, bool location_info) {
|
||||||
for (const auto& kw : keywords) {
|
for (const auto& kw : keywords) {
|
||||||
if (location_info)
|
if (location_info)
|
||||||
fmt::print("{:8s} : {}:{} {} \n", kw.name, kw.filename, kw.line_number, kw.content_hash);
|
std::cout << std::setw(8) << std::left << kw.name << " : " << kw.filename << ":" << kw.line_number << " " << kw.content_hash << std::endl;
|
||||||
else
|
else
|
||||||
fmt::print("{:8s} : {} \n", kw.name, kw.content_hash);
|
std::cout << std::setw(8) << std::left << kw.name << " : " << kw.content_hash << std::endl;
|
||||||
}
|
}
|
||||||
fmt::print("\n{:8s} : {}\n", "Total", deck_hash(keywords));
|
std::cout << std::endl;
|
||||||
|
std::cout << std::setw(8) << std::left << "Total" << " : " << deck_hash(keywords) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -70,8 +70,7 @@ inline void loadDeck( const char * deck_file) {
|
|||||||
std::cout << "creating SummaryConfig .... "; std::cout.flush();
|
std::cout << "creating SummaryConfig .... "; std::cout.flush();
|
||||||
|
|
||||||
start = std::chrono::system_clock::now();
|
start = std::chrono::system_clock::now();
|
||||||
Opm::SummaryConfig summary( deck, schedule, state.getTableManager( ), state.aquifer(),
|
Opm::SummaryConfig summary( deck, schedule, state.getTableManager( ), parseContext, errors );
|
||||||
parseContext, errors );
|
|
||||||
auto summary_time = std::chrono::system_clock::now() - start;
|
auto summary_time = std::chrono::system_clock::now() - start;
|
||||||
|
|
||||||
std::cout << "complete." << std::endl << std::endl;
|
std::cout << "complete." << std::endl << std::endl;
|
||||||
|
|||||||
@@ -1,135 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2013, 2020 Equinor ASA.
|
|
||||||
|
|
||||||
This file is part of the Open Porous Media project (OPM).
|
|
||||||
|
|
||||||
OPM is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OPM is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <chrono>
|
|
||||||
|
|
||||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
|
||||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
|
||||||
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
|
|
||||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
|
||||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
|
||||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
|
||||||
#include <opm/parser/eclipse/Python/Python.hpp>
|
|
||||||
|
|
||||||
#include <opm/common/OpmLog/OpmLog.hpp>
|
|
||||||
#include <opm/common/OpmLog/StreamLog.hpp>
|
|
||||||
#include <opm/common/OpmLog/LogUtil.hpp>
|
|
||||||
#include <opm/common/utility/FileSystem.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
inline void createDot(const Opm::Schedule& schedule, const std::string& casename)
|
|
||||||
{
|
|
||||||
std::cout << "Writing " << casename << ".gv .... "; std::cout.flush();
|
|
||||||
std::ofstream os(casename + ".gv");
|
|
||||||
os << "// This file was written by the 'wellgraph' utility from OPM.\n";
|
|
||||||
os << "// Find the source code at github.com/OPM.\n";
|
|
||||||
os << "// Convert output to PDF with 'dot -Tpdf " << casename << ".gv > " << casename << ".pdf'\n";
|
|
||||||
os << "strict digraph \"" << casename << "\"\n{\n";
|
|
||||||
const auto groupnames = schedule.groupNames();
|
|
||||||
const std::size_t last = schedule.getTimeMap().last();
|
|
||||||
// Group -> Group relations.
|
|
||||||
for (const auto& gn : groupnames) {
|
|
||||||
const auto& g = schedule.getGroup(gn, last);
|
|
||||||
const auto& children = g.groups();
|
|
||||||
if (!children.empty()) {
|
|
||||||
os << " \"" << gn << "\" -> {";
|
|
||||||
for (const auto& child : children) {
|
|
||||||
os << " \"" << child << '"';
|
|
||||||
}
|
|
||||||
os << " }\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Group -> Well relations.
|
|
||||||
os << " node [shape=box]\n";
|
|
||||||
for (const auto& gn : groupnames) {
|
|
||||||
const auto& g = schedule.getGroup(gn, last);
|
|
||||||
const auto& children = g.wells();
|
|
||||||
if (!children.empty()) {
|
|
||||||
os << " \"" << gn << "\" -> {";
|
|
||||||
for (const auto& child : children) {
|
|
||||||
os << " \"" << child << '"';
|
|
||||||
}
|
|
||||||
os << " }\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Color wells by injector or producer.
|
|
||||||
for (const auto& w : schedule.getWellsatEnd()) {
|
|
||||||
os << " \"" << w.name() << '"';
|
|
||||||
if (w.isProducer() && w.isInjector()) {
|
|
||||||
os << " [color=purple]\n";
|
|
||||||
} else if (w.isProducer()) {
|
|
||||||
os << " [color=red]\n";
|
|
||||||
} else {
|
|
||||||
os << " [color=blue]\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
os << "}\n";
|
|
||||||
std::cout << "complete." << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline Opm::Schedule loadSchedule(const std::string& deck_file)
|
|
||||||
{
|
|
||||||
Opm::ParseContext parseContext({{Opm::ParseContext::PARSE_RANDOM_SLASH, Opm::InputError::IGNORE},
|
|
||||||
{Opm::ParseContext::PARSE_MISSING_DIMS_KEYWORD, Opm::InputError::WARN},
|
|
||||||
{Opm::ParseContext::SUMMARY_UNKNOWN_WELL, Opm::InputError::WARN},
|
|
||||||
{Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputError::WARN}});
|
|
||||||
Opm::ErrorGuard errors;
|
|
||||||
Opm::Parser parser;
|
|
||||||
auto python = std::make_shared<Opm::Python>();
|
|
||||||
|
|
||||||
std::cout << "Loading and parsing deck: " << deck_file << " ..... "; std::cout.flush();
|
|
||||||
auto deck = parser.parseFile(deck_file, parseContext, errors);
|
|
||||||
std::cout << "complete.\n";
|
|
||||||
|
|
||||||
std::cout << "Creating EclipseState .... "; std::cout.flush();
|
|
||||||
Opm::EclipseState state( deck );
|
|
||||||
std::cout << "complete.\n";
|
|
||||||
|
|
||||||
std::cout << "Creating Schedule .... "; std::cout.flush();
|
|
||||||
Opm::Schedule schedule( deck, state, python);
|
|
||||||
std::cout << "complete." << std::endl;
|
|
||||||
|
|
||||||
return schedule;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
std::ostringstream os;
|
|
||||||
std::shared_ptr<Opm::StreamLog> string_log = std::make_shared<Opm::StreamLog>(os, Opm::Log::DefaultMessageTypes);
|
|
||||||
Opm::OpmLog::addBackend( "STRING" , string_log);
|
|
||||||
try {
|
|
||||||
for (int iarg = 1; iarg < argc; iarg++) {
|
|
||||||
const std::string filename = argv[iarg];
|
|
||||||
const auto sched = loadSchedule(filename);
|
|
||||||
const auto casename = Opm::filesystem::path(filename).stem();
|
|
||||||
createDot(sched, casename);
|
|
||||||
}
|
|
||||||
} catch (const std::exception& e) {
|
|
||||||
std::cout << "\n\n***** Caught an exception: " << e.what() << std::endl;
|
|
||||||
std::cout << "\n\n***** Printing log: "<< std::endl;
|
|
||||||
std::cout << os.str();
|
|
||||||
std::cout << "\n\n***** Exiting due to errors." << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
27
external/fmtlib/LICENSE.rst
vendored
27
external/fmtlib/LICENSE.rst
vendored
@@ -1,27 +0,0 @@
|
|||||||
Copyright (c) 2012 - present, Victor Zverovich
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
a copy of this software and associated documentation files (the
|
|
||||||
"Software"), to deal in the Software without restriction, including
|
|
||||||
without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
|
||||||
included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
--- Optional exception to the license ---
|
|
||||||
|
|
||||||
As an exception, if, as a result of your compiling your source code, portions
|
|
||||||
of this Software are embedded into a machine-executable object form of such
|
|
||||||
source code, you may redistribute such embedded portions in such object form
|
|
||||||
without including the above copyright and permission notices.
|
|
||||||
12
external/fmtlib/README.opm
vendored
12
external/fmtlib/README.opm
vendored
@@ -1,12 +0,0 @@
|
|||||||
The include/ directory is a copy of the include directory from version 7.0.3 of
|
|
||||||
the fmtlib distribution. The fmtlib can be found at https://github.com/fmtlib/fmt
|
|
||||||
|
|
||||||
The fmtlib code embedded here should be compiled in header only mode, to ensure
|
|
||||||
that the symbol FMT_HEADER_ONLY must be defined before the the fmt/format.h
|
|
||||||
header is included:
|
|
||||||
|
|
||||||
#define FMT_HEADER_ONLY
|
|
||||||
#include <fmt/format.h>
|
|
||||||
|
|
||||||
....
|
|
||||||
auto msg = fmt::format("Hello {}", "world");
|
|
||||||
1123
external/fmtlib/include/fmt/chrono.h
vendored
1123
external/fmtlib/include/fmt/chrono.h
vendored
File diff suppressed because it is too large
Load Diff
566
external/fmtlib/include/fmt/color.h
vendored
566
external/fmtlib/include/fmt/color.h
vendored
@@ -1,566 +0,0 @@
|
|||||||
// Formatting library for C++ - color support
|
|
||||||
//
|
|
||||||
// Copyright (c) 2018 - present, Victor Zverovich and fmt contributors
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// For the license information refer to format.h.
|
|
||||||
|
|
||||||
#ifndef FMT_COLOR_H_
|
|
||||||
#define FMT_COLOR_H_
|
|
||||||
|
|
||||||
#include "format.h"
|
|
||||||
|
|
||||||
FMT_BEGIN_NAMESPACE
|
|
||||||
|
|
||||||
enum class color : uint32_t {
|
|
||||||
alice_blue = 0xF0F8FF, // rgb(240,248,255)
|
|
||||||
antique_white = 0xFAEBD7, // rgb(250,235,215)
|
|
||||||
aqua = 0x00FFFF, // rgb(0,255,255)
|
|
||||||
aquamarine = 0x7FFFD4, // rgb(127,255,212)
|
|
||||||
azure = 0xF0FFFF, // rgb(240,255,255)
|
|
||||||
beige = 0xF5F5DC, // rgb(245,245,220)
|
|
||||||
bisque = 0xFFE4C4, // rgb(255,228,196)
|
|
||||||
black = 0x000000, // rgb(0,0,0)
|
|
||||||
blanched_almond = 0xFFEBCD, // rgb(255,235,205)
|
|
||||||
blue = 0x0000FF, // rgb(0,0,255)
|
|
||||||
blue_violet = 0x8A2BE2, // rgb(138,43,226)
|
|
||||||
brown = 0xA52A2A, // rgb(165,42,42)
|
|
||||||
burly_wood = 0xDEB887, // rgb(222,184,135)
|
|
||||||
cadet_blue = 0x5F9EA0, // rgb(95,158,160)
|
|
||||||
chartreuse = 0x7FFF00, // rgb(127,255,0)
|
|
||||||
chocolate = 0xD2691E, // rgb(210,105,30)
|
|
||||||
coral = 0xFF7F50, // rgb(255,127,80)
|
|
||||||
cornflower_blue = 0x6495ED, // rgb(100,149,237)
|
|
||||||
cornsilk = 0xFFF8DC, // rgb(255,248,220)
|
|
||||||
crimson = 0xDC143C, // rgb(220,20,60)
|
|
||||||
cyan = 0x00FFFF, // rgb(0,255,255)
|
|
||||||
dark_blue = 0x00008B, // rgb(0,0,139)
|
|
||||||
dark_cyan = 0x008B8B, // rgb(0,139,139)
|
|
||||||
dark_golden_rod = 0xB8860B, // rgb(184,134,11)
|
|
||||||
dark_gray = 0xA9A9A9, // rgb(169,169,169)
|
|
||||||
dark_green = 0x006400, // rgb(0,100,0)
|
|
||||||
dark_khaki = 0xBDB76B, // rgb(189,183,107)
|
|
||||||
dark_magenta = 0x8B008B, // rgb(139,0,139)
|
|
||||||
dark_olive_green = 0x556B2F, // rgb(85,107,47)
|
|
||||||
dark_orange = 0xFF8C00, // rgb(255,140,0)
|
|
||||||
dark_orchid = 0x9932CC, // rgb(153,50,204)
|
|
||||||
dark_red = 0x8B0000, // rgb(139,0,0)
|
|
||||||
dark_salmon = 0xE9967A, // rgb(233,150,122)
|
|
||||||
dark_sea_green = 0x8FBC8F, // rgb(143,188,143)
|
|
||||||
dark_slate_blue = 0x483D8B, // rgb(72,61,139)
|
|
||||||
dark_slate_gray = 0x2F4F4F, // rgb(47,79,79)
|
|
||||||
dark_turquoise = 0x00CED1, // rgb(0,206,209)
|
|
||||||
dark_violet = 0x9400D3, // rgb(148,0,211)
|
|
||||||
deep_pink = 0xFF1493, // rgb(255,20,147)
|
|
||||||
deep_sky_blue = 0x00BFFF, // rgb(0,191,255)
|
|
||||||
dim_gray = 0x696969, // rgb(105,105,105)
|
|
||||||
dodger_blue = 0x1E90FF, // rgb(30,144,255)
|
|
||||||
fire_brick = 0xB22222, // rgb(178,34,34)
|
|
||||||
floral_white = 0xFFFAF0, // rgb(255,250,240)
|
|
||||||
forest_green = 0x228B22, // rgb(34,139,34)
|
|
||||||
fuchsia = 0xFF00FF, // rgb(255,0,255)
|
|
||||||
gainsboro = 0xDCDCDC, // rgb(220,220,220)
|
|
||||||
ghost_white = 0xF8F8FF, // rgb(248,248,255)
|
|
||||||
gold = 0xFFD700, // rgb(255,215,0)
|
|
||||||
golden_rod = 0xDAA520, // rgb(218,165,32)
|
|
||||||
gray = 0x808080, // rgb(128,128,128)
|
|
||||||
green = 0x008000, // rgb(0,128,0)
|
|
||||||
green_yellow = 0xADFF2F, // rgb(173,255,47)
|
|
||||||
honey_dew = 0xF0FFF0, // rgb(240,255,240)
|
|
||||||
hot_pink = 0xFF69B4, // rgb(255,105,180)
|
|
||||||
indian_red = 0xCD5C5C, // rgb(205,92,92)
|
|
||||||
indigo = 0x4B0082, // rgb(75,0,130)
|
|
||||||
ivory = 0xFFFFF0, // rgb(255,255,240)
|
|
||||||
khaki = 0xF0E68C, // rgb(240,230,140)
|
|
||||||
lavender = 0xE6E6FA, // rgb(230,230,250)
|
|
||||||
lavender_blush = 0xFFF0F5, // rgb(255,240,245)
|
|
||||||
lawn_green = 0x7CFC00, // rgb(124,252,0)
|
|
||||||
lemon_chiffon = 0xFFFACD, // rgb(255,250,205)
|
|
||||||
light_blue = 0xADD8E6, // rgb(173,216,230)
|
|
||||||
light_coral = 0xF08080, // rgb(240,128,128)
|
|
||||||
light_cyan = 0xE0FFFF, // rgb(224,255,255)
|
|
||||||
light_golden_rod_yellow = 0xFAFAD2, // rgb(250,250,210)
|
|
||||||
light_gray = 0xD3D3D3, // rgb(211,211,211)
|
|
||||||
light_green = 0x90EE90, // rgb(144,238,144)
|
|
||||||
light_pink = 0xFFB6C1, // rgb(255,182,193)
|
|
||||||
light_salmon = 0xFFA07A, // rgb(255,160,122)
|
|
||||||
light_sea_green = 0x20B2AA, // rgb(32,178,170)
|
|
||||||
light_sky_blue = 0x87CEFA, // rgb(135,206,250)
|
|
||||||
light_slate_gray = 0x778899, // rgb(119,136,153)
|
|
||||||
light_steel_blue = 0xB0C4DE, // rgb(176,196,222)
|
|
||||||
light_yellow = 0xFFFFE0, // rgb(255,255,224)
|
|
||||||
lime = 0x00FF00, // rgb(0,255,0)
|
|
||||||
lime_green = 0x32CD32, // rgb(50,205,50)
|
|
||||||
linen = 0xFAF0E6, // rgb(250,240,230)
|
|
||||||
magenta = 0xFF00FF, // rgb(255,0,255)
|
|
||||||
maroon = 0x800000, // rgb(128,0,0)
|
|
||||||
medium_aquamarine = 0x66CDAA, // rgb(102,205,170)
|
|
||||||
medium_blue = 0x0000CD, // rgb(0,0,205)
|
|
||||||
medium_orchid = 0xBA55D3, // rgb(186,85,211)
|
|
||||||
medium_purple = 0x9370DB, // rgb(147,112,219)
|
|
||||||
medium_sea_green = 0x3CB371, // rgb(60,179,113)
|
|
||||||
medium_slate_blue = 0x7B68EE, // rgb(123,104,238)
|
|
||||||
medium_spring_green = 0x00FA9A, // rgb(0,250,154)
|
|
||||||
medium_turquoise = 0x48D1CC, // rgb(72,209,204)
|
|
||||||
medium_violet_red = 0xC71585, // rgb(199,21,133)
|
|
||||||
midnight_blue = 0x191970, // rgb(25,25,112)
|
|
||||||
mint_cream = 0xF5FFFA, // rgb(245,255,250)
|
|
||||||
misty_rose = 0xFFE4E1, // rgb(255,228,225)
|
|
||||||
moccasin = 0xFFE4B5, // rgb(255,228,181)
|
|
||||||
navajo_white = 0xFFDEAD, // rgb(255,222,173)
|
|
||||||
navy = 0x000080, // rgb(0,0,128)
|
|
||||||
old_lace = 0xFDF5E6, // rgb(253,245,230)
|
|
||||||
olive = 0x808000, // rgb(128,128,0)
|
|
||||||
olive_drab = 0x6B8E23, // rgb(107,142,35)
|
|
||||||
orange = 0xFFA500, // rgb(255,165,0)
|
|
||||||
orange_red = 0xFF4500, // rgb(255,69,0)
|
|
||||||
orchid = 0xDA70D6, // rgb(218,112,214)
|
|
||||||
pale_golden_rod = 0xEEE8AA, // rgb(238,232,170)
|
|
||||||
pale_green = 0x98FB98, // rgb(152,251,152)
|
|
||||||
pale_turquoise = 0xAFEEEE, // rgb(175,238,238)
|
|
||||||
pale_violet_red = 0xDB7093, // rgb(219,112,147)
|
|
||||||
papaya_whip = 0xFFEFD5, // rgb(255,239,213)
|
|
||||||
peach_puff = 0xFFDAB9, // rgb(255,218,185)
|
|
||||||
peru = 0xCD853F, // rgb(205,133,63)
|
|
||||||
pink = 0xFFC0CB, // rgb(255,192,203)
|
|
||||||
plum = 0xDDA0DD, // rgb(221,160,221)
|
|
||||||
powder_blue = 0xB0E0E6, // rgb(176,224,230)
|
|
||||||
purple = 0x800080, // rgb(128,0,128)
|
|
||||||
rebecca_purple = 0x663399, // rgb(102,51,153)
|
|
||||||
red = 0xFF0000, // rgb(255,0,0)
|
|
||||||
rosy_brown = 0xBC8F8F, // rgb(188,143,143)
|
|
||||||
royal_blue = 0x4169E1, // rgb(65,105,225)
|
|
||||||
saddle_brown = 0x8B4513, // rgb(139,69,19)
|
|
||||||
salmon = 0xFA8072, // rgb(250,128,114)
|
|
||||||
sandy_brown = 0xF4A460, // rgb(244,164,96)
|
|
||||||
sea_green = 0x2E8B57, // rgb(46,139,87)
|
|
||||||
sea_shell = 0xFFF5EE, // rgb(255,245,238)
|
|
||||||
sienna = 0xA0522D, // rgb(160,82,45)
|
|
||||||
silver = 0xC0C0C0, // rgb(192,192,192)
|
|
||||||
sky_blue = 0x87CEEB, // rgb(135,206,235)
|
|
||||||
slate_blue = 0x6A5ACD, // rgb(106,90,205)
|
|
||||||
slate_gray = 0x708090, // rgb(112,128,144)
|
|
||||||
snow = 0xFFFAFA, // rgb(255,250,250)
|
|
||||||
spring_green = 0x00FF7F, // rgb(0,255,127)
|
|
||||||
steel_blue = 0x4682B4, // rgb(70,130,180)
|
|
||||||
tan = 0xD2B48C, // rgb(210,180,140)
|
|
||||||
teal = 0x008080, // rgb(0,128,128)
|
|
||||||
thistle = 0xD8BFD8, // rgb(216,191,216)
|
|
||||||
tomato = 0xFF6347, // rgb(255,99,71)
|
|
||||||
turquoise = 0x40E0D0, // rgb(64,224,208)
|
|
||||||
violet = 0xEE82EE, // rgb(238,130,238)
|
|
||||||
wheat = 0xF5DEB3, // rgb(245,222,179)
|
|
||||||
white = 0xFFFFFF, // rgb(255,255,255)
|
|
||||||
white_smoke = 0xF5F5F5, // rgb(245,245,245)
|
|
||||||
yellow = 0xFFFF00, // rgb(255,255,0)
|
|
||||||
yellow_green = 0x9ACD32 // rgb(154,205,50)
|
|
||||||
}; // enum class color
|
|
||||||
|
|
||||||
enum class terminal_color : uint8_t {
|
|
||||||
black = 30,
|
|
||||||
red,
|
|
||||||
green,
|
|
||||||
yellow,
|
|
||||||
blue,
|
|
||||||
magenta,
|
|
||||||
cyan,
|
|
||||||
white,
|
|
||||||
bright_black = 90,
|
|
||||||
bright_red,
|
|
||||||
bright_green,
|
|
||||||
bright_yellow,
|
|
||||||
bright_blue,
|
|
||||||
bright_magenta,
|
|
||||||
bright_cyan,
|
|
||||||
bright_white
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class emphasis : uint8_t {
|
|
||||||
bold = 1,
|
|
||||||
italic = 1 << 1,
|
|
||||||
underline = 1 << 2,
|
|
||||||
strikethrough = 1 << 3
|
|
||||||
};
|
|
||||||
|
|
||||||
// rgb is a struct for red, green and blue colors.
|
|
||||||
// Using the name "rgb" makes some editors show the color in a tooltip.
|
|
||||||
struct rgb {
|
|
||||||
FMT_CONSTEXPR rgb() : r(0), g(0), b(0) {}
|
|
||||||
FMT_CONSTEXPR rgb(uint8_t r_, uint8_t g_, uint8_t b_) : r(r_), g(g_), b(b_) {}
|
|
||||||
FMT_CONSTEXPR rgb(uint32_t hex)
|
|
||||||
: r((hex >> 16) & 0xFF), g((hex >> 8) & 0xFF), b(hex & 0xFF) {}
|
|
||||||
FMT_CONSTEXPR rgb(color hex)
|
|
||||||
: r((uint32_t(hex) >> 16) & 0xFF),
|
|
||||||
g((uint32_t(hex) >> 8) & 0xFF),
|
|
||||||
b(uint32_t(hex) & 0xFF) {}
|
|
||||||
uint8_t r;
|
|
||||||
uint8_t g;
|
|
||||||
uint8_t b;
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
// color is a struct of either a rgb color or a terminal color.
|
|
||||||
struct color_type {
|
|
||||||
FMT_CONSTEXPR color_type() FMT_NOEXCEPT : is_rgb(), value{} {}
|
|
||||||
FMT_CONSTEXPR color_type(color rgb_color) FMT_NOEXCEPT : is_rgb(true),
|
|
||||||
value{} {
|
|
||||||
value.rgb_color = static_cast<uint32_t>(rgb_color);
|
|
||||||
}
|
|
||||||
FMT_CONSTEXPR color_type(rgb rgb_color) FMT_NOEXCEPT : is_rgb(true), value{} {
|
|
||||||
value.rgb_color = (static_cast<uint32_t>(rgb_color.r) << 16) |
|
|
||||||
(static_cast<uint32_t>(rgb_color.g) << 8) | rgb_color.b;
|
|
||||||
}
|
|
||||||
FMT_CONSTEXPR color_type(terminal_color term_color) FMT_NOEXCEPT : is_rgb(),
|
|
||||||
value{} {
|
|
||||||
value.term_color = static_cast<uint8_t>(term_color);
|
|
||||||
}
|
|
||||||
bool is_rgb;
|
|
||||||
union color_union {
|
|
||||||
uint8_t term_color;
|
|
||||||
uint32_t rgb_color;
|
|
||||||
} value;
|
|
||||||
};
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
// Experimental text formatting support.
|
|
||||||
class text_style {
|
|
||||||
public:
|
|
||||||
FMT_CONSTEXPR text_style(emphasis em = emphasis()) FMT_NOEXCEPT
|
|
||||||
: set_foreground_color(),
|
|
||||||
set_background_color(),
|
|
||||||
ems(em) {}
|
|
||||||
|
|
||||||
FMT_CONSTEXPR text_style& operator|=(const text_style& rhs) {
|
|
||||||
if (!set_foreground_color) {
|
|
||||||
set_foreground_color = rhs.set_foreground_color;
|
|
||||||
foreground_color = rhs.foreground_color;
|
|
||||||
} else if (rhs.set_foreground_color) {
|
|
||||||
if (!foreground_color.is_rgb || !rhs.foreground_color.is_rgb)
|
|
||||||
FMT_THROW(format_error("can't OR a terminal color"));
|
|
||||||
foreground_color.value.rgb_color |= rhs.foreground_color.value.rgb_color;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!set_background_color) {
|
|
||||||
set_background_color = rhs.set_background_color;
|
|
||||||
background_color = rhs.background_color;
|
|
||||||
} else if (rhs.set_background_color) {
|
|
||||||
if (!background_color.is_rgb || !rhs.background_color.is_rgb)
|
|
||||||
FMT_THROW(format_error("can't OR a terminal color"));
|
|
||||||
background_color.value.rgb_color |= rhs.background_color.value.rgb_color;
|
|
||||||
}
|
|
||||||
|
|
||||||
ems = static_cast<emphasis>(static_cast<uint8_t>(ems) |
|
|
||||||
static_cast<uint8_t>(rhs.ems));
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
friend FMT_CONSTEXPR text_style operator|(text_style lhs,
|
|
||||||
const text_style& rhs) {
|
|
||||||
return lhs |= rhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
FMT_CONSTEXPR text_style& operator&=(const text_style& rhs) {
|
|
||||||
if (!set_foreground_color) {
|
|
||||||
set_foreground_color = rhs.set_foreground_color;
|
|
||||||
foreground_color = rhs.foreground_color;
|
|
||||||
} else if (rhs.set_foreground_color) {
|
|
||||||
if (!foreground_color.is_rgb || !rhs.foreground_color.is_rgb)
|
|
||||||
FMT_THROW(format_error("can't AND a terminal color"));
|
|
||||||
foreground_color.value.rgb_color &= rhs.foreground_color.value.rgb_color;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!set_background_color) {
|
|
||||||
set_background_color = rhs.set_background_color;
|
|
||||||
background_color = rhs.background_color;
|
|
||||||
} else if (rhs.set_background_color) {
|
|
||||||
if (!background_color.is_rgb || !rhs.background_color.is_rgb)
|
|
||||||
FMT_THROW(format_error("can't AND a terminal color"));
|
|
||||||
background_color.value.rgb_color &= rhs.background_color.value.rgb_color;
|
|
||||||
}
|
|
||||||
|
|
||||||
ems = static_cast<emphasis>(static_cast<uint8_t>(ems) &
|
|
||||||
static_cast<uint8_t>(rhs.ems));
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
friend FMT_CONSTEXPR text_style operator&(text_style lhs,
|
|
||||||
const text_style& rhs) {
|
|
||||||
return lhs &= rhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
FMT_CONSTEXPR bool has_foreground() const FMT_NOEXCEPT {
|
|
||||||
return set_foreground_color;
|
|
||||||
}
|
|
||||||
FMT_CONSTEXPR bool has_background() const FMT_NOEXCEPT {
|
|
||||||
return set_background_color;
|
|
||||||
}
|
|
||||||
FMT_CONSTEXPR bool has_emphasis() const FMT_NOEXCEPT {
|
|
||||||
return static_cast<uint8_t>(ems) != 0;
|
|
||||||
}
|
|
||||||
FMT_CONSTEXPR detail::color_type get_foreground() const FMT_NOEXCEPT {
|
|
||||||
FMT_ASSERT(has_foreground(), "no foreground specified for this style");
|
|
||||||
return foreground_color;
|
|
||||||
}
|
|
||||||
FMT_CONSTEXPR detail::color_type get_background() const FMT_NOEXCEPT {
|
|
||||||
FMT_ASSERT(has_background(), "no background specified for this style");
|
|
||||||
return background_color;
|
|
||||||
}
|
|
||||||
FMT_CONSTEXPR emphasis get_emphasis() const FMT_NOEXCEPT {
|
|
||||||
FMT_ASSERT(has_emphasis(), "no emphasis specified for this style");
|
|
||||||
return ems;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
FMT_CONSTEXPR text_style(bool is_foreground,
|
|
||||||
detail::color_type text_color) FMT_NOEXCEPT
|
|
||||||
: set_foreground_color(),
|
|
||||||
set_background_color(),
|
|
||||||
ems() {
|
|
||||||
if (is_foreground) {
|
|
||||||
foreground_color = text_color;
|
|
||||||
set_foreground_color = true;
|
|
||||||
} else {
|
|
||||||
background_color = text_color;
|
|
||||||
set_background_color = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
friend FMT_CONSTEXPR_DECL text_style fg(detail::color_type foreground)
|
|
||||||
FMT_NOEXCEPT;
|
|
||||||
friend FMT_CONSTEXPR_DECL text_style bg(detail::color_type background)
|
|
||||||
FMT_NOEXCEPT;
|
|
||||||
|
|
||||||
detail::color_type foreground_color;
|
|
||||||
detail::color_type background_color;
|
|
||||||
bool set_foreground_color;
|
|
||||||
bool set_background_color;
|
|
||||||
emphasis ems;
|
|
||||||
};
|
|
||||||
|
|
||||||
FMT_CONSTEXPR text_style fg(detail::color_type foreground) FMT_NOEXCEPT {
|
|
||||||
return text_style(/*is_foreground=*/true, foreground);
|
|
||||||
}
|
|
||||||
|
|
||||||
FMT_CONSTEXPR text_style bg(detail::color_type background) FMT_NOEXCEPT {
|
|
||||||
return text_style(/*is_foreground=*/false, background);
|
|
||||||
}
|
|
||||||
|
|
||||||
FMT_CONSTEXPR text_style operator|(emphasis lhs, emphasis rhs) FMT_NOEXCEPT {
|
|
||||||
return text_style(lhs) | rhs;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
template <typename Char> struct ansi_color_escape {
|
|
||||||
FMT_CONSTEXPR ansi_color_escape(detail::color_type text_color,
|
|
||||||
const char* esc) FMT_NOEXCEPT {
|
|
||||||
// If we have a terminal color, we need to output another escape code
|
|
||||||
// sequence.
|
|
||||||
if (!text_color.is_rgb) {
|
|
||||||
bool is_background = esc == detail::data::background_color;
|
|
||||||
uint32_t value = text_color.value.term_color;
|
|
||||||
// Background ASCII codes are the same as the foreground ones but with
|
|
||||||
// 10 more.
|
|
||||||
if (is_background) value += 10u;
|
|
||||||
|
|
||||||
size_t index = 0;
|
|
||||||
buffer[index++] = static_cast<Char>('\x1b');
|
|
||||||
buffer[index++] = static_cast<Char>('[');
|
|
||||||
|
|
||||||
if (value >= 100u) {
|
|
||||||
buffer[index++] = static_cast<Char>('1');
|
|
||||||
value %= 100u;
|
|
||||||
}
|
|
||||||
buffer[index++] = static_cast<Char>('0' + value / 10u);
|
|
||||||
buffer[index++] = static_cast<Char>('0' + value % 10u);
|
|
||||||
|
|
||||||
buffer[index++] = static_cast<Char>('m');
|
|
||||||
buffer[index++] = static_cast<Char>('\0');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < 7; i++) {
|
|
||||||
buffer[i] = static_cast<Char>(esc[i]);
|
|
||||||
}
|
|
||||||
rgb color(text_color.value.rgb_color);
|
|
||||||
to_esc(color.r, buffer + 7, ';');
|
|
||||||
to_esc(color.g, buffer + 11, ';');
|
|
||||||
to_esc(color.b, buffer + 15, 'm');
|
|
||||||
buffer[19] = static_cast<Char>(0);
|
|
||||||
}
|
|
||||||
FMT_CONSTEXPR ansi_color_escape(emphasis em) FMT_NOEXCEPT {
|
|
||||||
uint8_t em_codes[4] = {};
|
|
||||||
uint8_t em_bits = static_cast<uint8_t>(em);
|
|
||||||
if (em_bits & static_cast<uint8_t>(emphasis::bold)) em_codes[0] = 1;
|
|
||||||
if (em_bits & static_cast<uint8_t>(emphasis::italic)) em_codes[1] = 3;
|
|
||||||
if (em_bits & static_cast<uint8_t>(emphasis::underline)) em_codes[2] = 4;
|
|
||||||
if (em_bits & static_cast<uint8_t>(emphasis::strikethrough))
|
|
||||||
em_codes[3] = 9;
|
|
||||||
|
|
||||||
size_t index = 0;
|
|
||||||
for (int i = 0; i < 4; ++i) {
|
|
||||||
if (!em_codes[i]) continue;
|
|
||||||
buffer[index++] = static_cast<Char>('\x1b');
|
|
||||||
buffer[index++] = static_cast<Char>('[');
|
|
||||||
buffer[index++] = static_cast<Char>('0' + em_codes[i]);
|
|
||||||
buffer[index++] = static_cast<Char>('m');
|
|
||||||
}
|
|
||||||
buffer[index++] = static_cast<Char>(0);
|
|
||||||
}
|
|
||||||
FMT_CONSTEXPR operator const Char*() const FMT_NOEXCEPT { return buffer; }
|
|
||||||
|
|
||||||
FMT_CONSTEXPR const Char* begin() const FMT_NOEXCEPT { return buffer; }
|
|
||||||
FMT_CONSTEXPR const Char* end() const FMT_NOEXCEPT {
|
|
||||||
return buffer + std::char_traits<Char>::length(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Char buffer[7u + 3u * 4u + 1u];
|
|
||||||
|
|
||||||
static FMT_CONSTEXPR void to_esc(uint8_t c, Char* out,
|
|
||||||
char delimiter) FMT_NOEXCEPT {
|
|
||||||
out[0] = static_cast<Char>('0' + c / 100);
|
|
||||||
out[1] = static_cast<Char>('0' + c / 10 % 10);
|
|
||||||
out[2] = static_cast<Char>('0' + c % 10);
|
|
||||||
out[3] = static_cast<Char>(delimiter);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Char>
|
|
||||||
FMT_CONSTEXPR ansi_color_escape<Char> make_foreground_color(
|
|
||||||
detail::color_type foreground) FMT_NOEXCEPT {
|
|
||||||
return ansi_color_escape<Char>(foreground, detail::data::foreground_color);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Char>
|
|
||||||
FMT_CONSTEXPR ansi_color_escape<Char> make_background_color(
|
|
||||||
detail::color_type background) FMT_NOEXCEPT {
|
|
||||||
return ansi_color_escape<Char>(background, detail::data::background_color);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Char>
|
|
||||||
FMT_CONSTEXPR ansi_color_escape<Char> make_emphasis(emphasis em) FMT_NOEXCEPT {
|
|
||||||
return ansi_color_escape<Char>(em);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Char>
|
|
||||||
inline void fputs(const Char* chars, FILE* stream) FMT_NOEXCEPT {
|
|
||||||
std::fputs(chars, stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline void fputs<wchar_t>(const wchar_t* chars, FILE* stream) FMT_NOEXCEPT {
|
|
||||||
std::fputws(chars, stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Char> inline void reset_color(FILE* stream) FMT_NOEXCEPT {
|
|
||||||
fputs(detail::data::reset_color, stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <> inline void reset_color<wchar_t>(FILE* stream) FMT_NOEXCEPT {
|
|
||||||
fputs(detail::data::wreset_color, stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Char>
|
|
||||||
inline void reset_color(basic_memory_buffer<Char>& buffer) FMT_NOEXCEPT {
|
|
||||||
const char* begin = data::reset_color;
|
|
||||||
const char* end = begin + sizeof(data::reset_color) - 1;
|
|
||||||
buffer.append(begin, end);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Char>
|
|
||||||
void vformat_to(basic_memory_buffer<Char>& buf, const text_style& ts,
|
|
||||||
basic_string_view<Char> format_str,
|
|
||||||
basic_format_args<buffer_context<Char>> args) {
|
|
||||||
bool has_style = false;
|
|
||||||
if (ts.has_emphasis()) {
|
|
||||||
has_style = true;
|
|
||||||
auto emphasis = detail::make_emphasis<Char>(ts.get_emphasis());
|
|
||||||
buf.append(emphasis.begin(), emphasis.end());
|
|
||||||
}
|
|
||||||
if (ts.has_foreground()) {
|
|
||||||
has_style = true;
|
|
||||||
auto foreground = detail::make_foreground_color<Char>(ts.get_foreground());
|
|
||||||
buf.append(foreground.begin(), foreground.end());
|
|
||||||
}
|
|
||||||
if (ts.has_background()) {
|
|
||||||
has_style = true;
|
|
||||||
auto background = detail::make_background_color<Char>(ts.get_background());
|
|
||||||
buf.append(background.begin(), background.end());
|
|
||||||
}
|
|
||||||
detail::vformat_to(buf, format_str, args);
|
|
||||||
if (has_style) detail::reset_color<Char>(buf);
|
|
||||||
}
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
template <typename S, typename Char = char_t<S>>
|
|
||||||
void vprint(std::FILE* f, const text_style& ts, const S& format,
|
|
||||||
basic_format_args<buffer_context<Char>> args) {
|
|
||||||
basic_memory_buffer<Char> buf;
|
|
||||||
detail::vformat_to(buf, ts, to_string_view(format), args);
|
|
||||||
buf.push_back(Char(0));
|
|
||||||
detail::fputs(buf.data(), f);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Formats a string and prints it to the specified file stream using ANSI
|
|
||||||
escape sequences to specify text formatting.
|
|
||||||
Example:
|
|
||||||
fmt::print(fmt::emphasis::bold | fg(fmt::color::red),
|
|
||||||
"Elapsed time: {0:.2f} seconds", 1.23);
|
|
||||||
*/
|
|
||||||
template <typename S, typename... Args,
|
|
||||||
FMT_ENABLE_IF(detail::is_string<S>::value)>
|
|
||||||
void print(std::FILE* f, const text_style& ts, const S& format_str,
|
|
||||||
const Args&... args) {
|
|
||||||
detail::check_format_string<Args...>(format_str);
|
|
||||||
using context = buffer_context<char_t<S>>;
|
|
||||||
format_arg_store<context, Args...> as{args...};
|
|
||||||
vprint(f, ts, format_str, basic_format_args<context>(as));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Formats a string and prints it to stdout using ANSI escape sequences to
|
|
||||||
specify text formatting.
|
|
||||||
Example:
|
|
||||||
fmt::print(fmt::emphasis::bold | fg(fmt::color::red),
|
|
||||||
"Elapsed time: {0:.2f} seconds", 1.23);
|
|
||||||
*/
|
|
||||||
template <typename S, typename... Args,
|
|
||||||
FMT_ENABLE_IF(detail::is_string<S>::value)>
|
|
||||||
void print(const text_style& ts, const S& format_str, const Args&... args) {
|
|
||||||
return print(stdout, ts, format_str, args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename S, typename Char = char_t<S>>
|
|
||||||
inline std::basic_string<Char> vformat(
|
|
||||||
const text_style& ts, const S& format_str,
|
|
||||||
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
|
|
||||||
basic_memory_buffer<Char> buf;
|
|
||||||
detail::vformat_to(buf, ts, to_string_view(format_str), args);
|
|
||||||
return fmt::to_string(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
\rst
|
|
||||||
Formats arguments and returns the result as a string using ANSI
|
|
||||||
escape sequences to specify text formatting.
|
|
||||||
|
|
||||||
**Example**::
|
|
||||||
|
|
||||||
#include <fmt/color.h>
|
|
||||||
std::string message = fmt::format(fmt::emphasis::bold | fg(fmt::color::red),
|
|
||||||
"The answer is {}", 42);
|
|
||||||
\endrst
|
|
||||||
*/
|
|
||||||
template <typename S, typename... Args, typename Char = char_t<S>>
|
|
||||||
inline std::basic_string<Char> format(const text_style& ts, const S& format_str,
|
|
||||||
const Args&... args) {
|
|
||||||
return vformat(ts, to_string_view(format_str),
|
|
||||||
detail::make_args_checked<Args...>(format_str, args...));
|
|
||||||
}
|
|
||||||
|
|
||||||
FMT_END_NAMESPACE
|
|
||||||
|
|
||||||
#endif // FMT_COLOR_H_
|
|
||||||
665
external/fmtlib/include/fmt/compile.h
vendored
665
external/fmtlib/include/fmt/compile.h
vendored
@@ -1,665 +0,0 @@
|
|||||||
// Formatting library for C++ - experimental format string compilation
|
|
||||||
//
|
|
||||||
// Copyright (c) 2012 - present, Victor Zverovich and fmt contributors
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// For the license information refer to format.h.
|
|
||||||
|
|
||||||
#ifndef FMT_COMPILE_H_
|
|
||||||
#define FMT_COMPILE_H_
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "format.h"
|
|
||||||
|
|
||||||
FMT_BEGIN_NAMESPACE
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
// A compile-time string which is compiled into fast formatting code.
|
|
||||||
class compiled_string {};
|
|
||||||
|
|
||||||
template <typename S>
|
|
||||||
struct is_compiled_string : std::is_base_of<compiled_string, S> {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
\rst
|
|
||||||
Converts a string literal *s* into a format string that will be parsed at
|
|
||||||
compile time and converted into efficient formatting code. Requires C++17
|
|
||||||
``constexpr if`` compiler support.
|
|
||||||
|
|
||||||
**Example**::
|
|
||||||
|
|
||||||
// Converts 42 into std::string using the most efficient method and no
|
|
||||||
// runtime format string processing.
|
|
||||||
std::string s = fmt::format(FMT_COMPILE("{}"), 42);
|
|
||||||
\endrst
|
|
||||||
*/
|
|
||||||
#define FMT_COMPILE(s) FMT_STRING_IMPL(s, fmt::detail::compiled_string)
|
|
||||||
|
|
||||||
template <typename T, typename... Tail>
|
|
||||||
const T& first(const T& value, const Tail&...) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Part of a compiled format string. It can be either literal text or a
|
|
||||||
// replacement field.
|
|
||||||
template <typename Char> struct format_part {
|
|
||||||
enum class kind { arg_index, arg_name, text, replacement };
|
|
||||||
|
|
||||||
struct replacement {
|
|
||||||
arg_ref<Char> arg_id;
|
|
||||||
dynamic_format_specs<Char> specs;
|
|
||||||
};
|
|
||||||
|
|
||||||
kind part_kind;
|
|
||||||
union value {
|
|
||||||
int arg_index;
|
|
||||||
basic_string_view<Char> str;
|
|
||||||
replacement repl;
|
|
||||||
|
|
||||||
FMT_CONSTEXPR value(int index = 0) : arg_index(index) {}
|
|
||||||
FMT_CONSTEXPR value(basic_string_view<Char> s) : str(s) {}
|
|
||||||
FMT_CONSTEXPR value(replacement r) : repl(r) {}
|
|
||||||
} val;
|
|
||||||
// Position past the end of the argument id.
|
|
||||||
const Char* arg_id_end = nullptr;
|
|
||||||
|
|
||||||
FMT_CONSTEXPR format_part(kind k = kind::arg_index, value v = {})
|
|
||||||
: part_kind(k), val(v) {}
|
|
||||||
|
|
||||||
static FMT_CONSTEXPR format_part make_arg_index(int index) {
|
|
||||||
return format_part(kind::arg_index, index);
|
|
||||||
}
|
|
||||||
static FMT_CONSTEXPR format_part make_arg_name(basic_string_view<Char> name) {
|
|
||||||
return format_part(kind::arg_name, name);
|
|
||||||
}
|
|
||||||
static FMT_CONSTEXPR format_part make_text(basic_string_view<Char> text) {
|
|
||||||
return format_part(kind::text, text);
|
|
||||||
}
|
|
||||||
static FMT_CONSTEXPR format_part make_replacement(replacement repl) {
|
|
||||||
return format_part(kind::replacement, repl);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Char> struct part_counter {
|
|
||||||
unsigned num_parts = 0;
|
|
||||||
|
|
||||||
FMT_CONSTEXPR void on_text(const Char* begin, const Char* end) {
|
|
||||||
if (begin != end) ++num_parts;
|
|
||||||
}
|
|
||||||
|
|
||||||
FMT_CONSTEXPR int on_arg_id() { return ++num_parts, 0; }
|
|
||||||
FMT_CONSTEXPR int on_arg_id(int) { return ++num_parts, 0; }
|
|
||||||
FMT_CONSTEXPR int on_arg_id(basic_string_view<Char>) {
|
|
||||||
return ++num_parts, 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
FMT_CONSTEXPR void on_replacement_field(int, const Char*) {}
|
|
||||||
|
|
||||||
FMT_CONSTEXPR const Char* on_format_specs(int, const Char* begin,
|
|
||||||
const Char* end) {
|
|
||||||
// Find the matching brace.
|
|
||||||
unsigned brace_counter = 0;
|
|
||||||
for (; begin != end; ++begin) {
|
|
||||||
if (*begin == '{') {
|
|
||||||
++brace_counter;
|
|
||||||
} else if (*begin == '}') {
|
|
||||||
if (brace_counter == 0u) break;
|
|
||||||
--brace_counter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return begin;
|
|
||||||
}
|
|
||||||
|
|
||||||
FMT_CONSTEXPR void on_error(const char*) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Counts the number of parts in a format string.
|
|
||||||
template <typename Char>
|
|
||||||
FMT_CONSTEXPR unsigned count_parts(basic_string_view<Char> format_str) {
|
|
||||||
part_counter<Char> counter;
|
|
||||||
parse_format_string<true>(format_str, counter);
|
|
||||||
return counter.num_parts;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Char, typename PartHandler>
|
|
||||||
class format_string_compiler : public error_handler {
|
|
||||||
private:
|
|
||||||
using part = format_part<Char>;
|
|
||||||
|
|
||||||
PartHandler handler_;
|
|
||||||
part part_;
|
|
||||||
basic_string_view<Char> format_str_;
|
|
||||||
basic_format_parse_context<Char> parse_context_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
FMT_CONSTEXPR format_string_compiler(basic_string_view<Char> format_str,
|
|
||||||
PartHandler handler)
|
|
||||||
: handler_(handler),
|
|
||||||
format_str_(format_str),
|
|
||||||
parse_context_(format_str) {}
|
|
||||||
|
|
||||||
FMT_CONSTEXPR void on_text(const Char* begin, const Char* end) {
|
|
||||||
if (begin != end)
|
|
||||||
handler_(part::make_text({begin, to_unsigned(end - begin)}));
|
|
||||||
}
|
|
||||||
|
|
||||||
FMT_CONSTEXPR int on_arg_id() {
|
|
||||||
part_ = part::make_arg_index(parse_context_.next_arg_id());
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
FMT_CONSTEXPR int on_arg_id(int id) {
|
|
||||||
parse_context_.check_arg_id(id);
|
|
||||||
part_ = part::make_arg_index(id);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
FMT_CONSTEXPR int on_arg_id(basic_string_view<Char> id) {
|
|
||||||
part_ = part::make_arg_name(id);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
FMT_CONSTEXPR void on_replacement_field(int, const Char* ptr) {
|
|
||||||
part_.arg_id_end = ptr;
|
|
||||||
handler_(part_);
|
|
||||||
}
|
|
||||||
|
|
||||||
FMT_CONSTEXPR const Char* on_format_specs(int, const Char* begin,
|
|
||||||
const Char* end) {
|
|
||||||
auto repl = typename part::replacement();
|
|
||||||
dynamic_specs_handler<basic_format_parse_context<Char>> handler(
|
|
||||||
repl.specs, parse_context_);
|
|
||||||
auto it = parse_format_specs(begin, end, handler);
|
|
||||||
if (*it != '}') on_error("missing '}' in format string");
|
|
||||||
repl.arg_id = part_.part_kind == part::kind::arg_index
|
|
||||||
? arg_ref<Char>(part_.val.arg_index)
|
|
||||||
: arg_ref<Char>(part_.val.str);
|
|
||||||
auto part = part::make_replacement(repl);
|
|
||||||
part.arg_id_end = begin;
|
|
||||||
handler_(part);
|
|
||||||
return it;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Compiles a format string and invokes handler(part) for each parsed part.
|
|
||||||
template <bool IS_CONSTEXPR, typename Char, typename PartHandler>
|
|
||||||
FMT_CONSTEXPR void compile_format_string(basic_string_view<Char> format_str,
|
|
||||||
PartHandler handler) {
|
|
||||||
parse_format_string<IS_CONSTEXPR>(
|
|
||||||
format_str,
|
|
||||||
format_string_compiler<Char, PartHandler>(format_str, handler));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename OutputIt, typename Context, typename Id>
|
|
||||||
void format_arg(
|
|
||||||
basic_format_parse_context<typename Context::char_type>& parse_ctx,
|
|
||||||
Context& ctx, Id arg_id) {
|
|
||||||
ctx.advance_to(visit_format_arg(
|
|
||||||
arg_formatter<OutputIt, typename Context::char_type>(ctx, &parse_ctx),
|
|
||||||
ctx.arg(arg_id)));
|
|
||||||
}
|
|
||||||
|
|
||||||
// vformat_to is defined in a subnamespace to prevent ADL.
|
|
||||||
namespace cf {
|
|
||||||
template <typename Context, typename OutputIt, typename CompiledFormat>
|
|
||||||
auto vformat_to(OutputIt out, CompiledFormat& cf,
|
|
||||||
basic_format_args<Context> args) -> typename Context::iterator {
|
|
||||||
using char_type = typename Context::char_type;
|
|
||||||
basic_format_parse_context<char_type> parse_ctx(
|
|
||||||
to_string_view(cf.format_str_));
|
|
||||||
Context ctx(out, args);
|
|
||||||
|
|
||||||
const auto& parts = cf.parts();
|
|
||||||
for (auto part_it = std::begin(parts); part_it != std::end(parts);
|
|
||||||
++part_it) {
|
|
||||||
const auto& part = *part_it;
|
|
||||||
const auto& value = part.val;
|
|
||||||
|
|
||||||
using format_part_t = format_part<char_type>;
|
|
||||||
switch (part.part_kind) {
|
|
||||||
case format_part_t::kind::text: {
|
|
||||||
const auto text = value.str;
|
|
||||||
auto output = ctx.out();
|
|
||||||
auto&& it = reserve(output, text.size());
|
|
||||||
it = std::copy_n(text.begin(), text.size(), it);
|
|
||||||
ctx.advance_to(output);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case format_part_t::kind::arg_index:
|
|
||||||
advance_to(parse_ctx, part.arg_id_end);
|
|
||||||
detail::format_arg<OutputIt>(parse_ctx, ctx, value.arg_index);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case format_part_t::kind::arg_name:
|
|
||||||
advance_to(parse_ctx, part.arg_id_end);
|
|
||||||
detail::format_arg<OutputIt>(parse_ctx, ctx, value.str);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case format_part_t::kind::replacement: {
|
|
||||||
const auto& arg_id_value = value.repl.arg_id.val;
|
|
||||||
const auto arg = value.repl.arg_id.kind == arg_id_kind::index
|
|
||||||
? ctx.arg(arg_id_value.index)
|
|
||||||
: ctx.arg(arg_id_value.name);
|
|
||||||
|
|
||||||
auto specs = value.repl.specs;
|
|
||||||
|
|
||||||
handle_dynamic_spec<width_checker>(specs.width, specs.width_ref, ctx);
|
|
||||||
handle_dynamic_spec<precision_checker>(specs.precision,
|
|
||||||
specs.precision_ref, ctx);
|
|
||||||
|
|
||||||
error_handler h;
|
|
||||||
numeric_specs_checker<error_handler> checker(h, arg.type());
|
|
||||||
if (specs.align == align::numeric) checker.require_numeric_argument();
|
|
||||||
if (specs.sign != sign::none) checker.check_sign();
|
|
||||||
if (specs.alt) checker.require_numeric_argument();
|
|
||||||
if (specs.precision >= 0) checker.check_precision();
|
|
||||||
|
|
||||||
advance_to(parse_ctx, part.arg_id_end);
|
|
||||||
ctx.advance_to(
|
|
||||||
visit_format_arg(arg_formatter<OutputIt, typename Context::char_type>(
|
|
||||||
ctx, nullptr, &specs),
|
|
||||||
arg));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ctx.out();
|
|
||||||
}
|
|
||||||
} // namespace cf
|
|
||||||
|
|
||||||
struct basic_compiled_format {};
|
|
||||||
|
|
||||||
template <typename S, typename = void>
|
|
||||||
struct compiled_format_base : basic_compiled_format {
|
|
||||||
using char_type = char_t<S>;
|
|
||||||
using parts_container = std::vector<detail::format_part<char_type>>;
|
|
||||||
|
|
||||||
parts_container compiled_parts;
|
|
||||||
|
|
||||||
explicit compiled_format_base(basic_string_view<char_type> format_str) {
|
|
||||||
compile_format_string<false>(format_str,
|
|
||||||
[this](const format_part<char_type>& part) {
|
|
||||||
compiled_parts.push_back(part);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const parts_container& parts() const { return compiled_parts; }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Char, unsigned N> struct format_part_array {
|
|
||||||
format_part<Char> data[N] = {};
|
|
||||||
FMT_CONSTEXPR format_part_array() = default;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Char, unsigned N>
|
|
||||||
FMT_CONSTEXPR format_part_array<Char, N> compile_to_parts(
|
|
||||||
basic_string_view<Char> format_str) {
|
|
||||||
format_part_array<Char, N> parts;
|
|
||||||
unsigned counter = 0;
|
|
||||||
// This is not a lambda for compatibility with older compilers.
|
|
||||||
struct {
|
|
||||||
format_part<Char>* parts;
|
|
||||||
unsigned* counter;
|
|
||||||
FMT_CONSTEXPR void operator()(const format_part<Char>& part) {
|
|
||||||
parts[(*counter)++] = part;
|
|
||||||
}
|
|
||||||
} collector{parts.data, &counter};
|
|
||||||
compile_format_string<true>(format_str, collector);
|
|
||||||
if (counter < N) {
|
|
||||||
parts.data[counter] =
|
|
||||||
format_part<Char>::make_text(basic_string_view<Char>());
|
|
||||||
}
|
|
||||||
return parts;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T> constexpr const T& constexpr_max(const T& a, const T& b) {
|
|
||||||
return (a < b) ? b : a;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename S>
|
|
||||||
struct compiled_format_base<S, enable_if_t<is_compile_string<S>::value>>
|
|
||||||
: basic_compiled_format {
|
|
||||||
using char_type = char_t<S>;
|
|
||||||
|
|
||||||
FMT_CONSTEXPR explicit compiled_format_base(basic_string_view<char_type>) {}
|
|
||||||
|
|
||||||
// Workaround for old compilers. Format string compilation will not be
|
|
||||||
// performed there anyway.
|
|
||||||
#if FMT_USE_CONSTEXPR
|
|
||||||
static FMT_CONSTEXPR_DECL const unsigned num_format_parts =
|
|
||||||
constexpr_max(count_parts(to_string_view(S())), 1u);
|
|
||||||
#else
|
|
||||||
static const unsigned num_format_parts = 1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using parts_container = format_part<char_type>[num_format_parts];
|
|
||||||
|
|
||||||
const parts_container& parts() const {
|
|
||||||
static FMT_CONSTEXPR_DECL const auto compiled_parts =
|
|
||||||
compile_to_parts<char_type, num_format_parts>(
|
|
||||||
detail::to_string_view(S()));
|
|
||||||
return compiled_parts.data;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename S, typename... Args>
|
|
||||||
class compiled_format : private compiled_format_base<S> {
|
|
||||||
public:
|
|
||||||
using typename compiled_format_base<S>::char_type;
|
|
||||||
|
|
||||||
private:
|
|
||||||
basic_string_view<char_type> format_str_;
|
|
||||||
|
|
||||||
template <typename Context, typename OutputIt, typename CompiledFormat>
|
|
||||||
friend auto cf::vformat_to(OutputIt out, CompiledFormat& cf,
|
|
||||||
basic_format_args<Context> args) ->
|
|
||||||
typename Context::iterator;
|
|
||||||
|
|
||||||
public:
|
|
||||||
compiled_format() = delete;
|
|
||||||
explicit constexpr compiled_format(basic_string_view<char_type> format_str)
|
|
||||||
: compiled_format_base<S>(format_str), format_str_(format_str) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef __cpp_if_constexpr
|
|
||||||
template <typename... Args> struct type_list {};
|
|
||||||
|
|
||||||
// Returns a reference to the argument at index N from [first, rest...].
|
|
||||||
template <int N, typename T, typename... Args>
|
|
||||||
constexpr const auto& get(const T& first, const Args&... rest) {
|
|
||||||
static_assert(N < 1 + sizeof...(Args), "index is out of bounds");
|
|
||||||
if constexpr (N == 0)
|
|
||||||
return first;
|
|
||||||
else
|
|
||||||
return get<N - 1>(rest...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <int N, typename> struct get_type_impl;
|
|
||||||
|
|
||||||
template <int N, typename... Args> struct get_type_impl<N, type_list<Args...>> {
|
|
||||||
using type = remove_cvref_t<decltype(get<N>(std::declval<Args>()...))>;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <int N, typename T>
|
|
||||||
using get_type = typename get_type_impl<N, T>::type;
|
|
||||||
|
|
||||||
template <typename T> struct is_compiled_format : std::false_type {};
|
|
||||||
|
|
||||||
template <typename Char> struct text {
|
|
||||||
basic_string_view<Char> data;
|
|
||||||
using char_type = Char;
|
|
||||||
|
|
||||||
template <typename OutputIt, typename... Args>
|
|
||||||
OutputIt format(OutputIt out, const Args&...) const {
|
|
||||||
return write<Char>(out, data);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Char>
|
|
||||||
struct is_compiled_format<text<Char>> : std::true_type {};
|
|
||||||
|
|
||||||
template <typename Char>
|
|
||||||
constexpr text<Char> make_text(basic_string_view<Char> s, size_t pos,
|
|
||||||
size_t size) {
|
|
||||||
return {{&s[pos], size}};
|
|
||||||
}
|
|
||||||
|
|
||||||
// A replacement field that refers to argument N.
|
|
||||||
template <typename Char, typename T, int N> struct field {
|
|
||||||
using char_type = Char;
|
|
||||||
|
|
||||||
template <typename OutputIt, typename... Args>
|
|
||||||
OutputIt format(OutputIt out, const Args&... args) const {
|
|
||||||
// This ensures that the argument type is convertile to `const T&`.
|
|
||||||
const T& arg = get<N>(args...);
|
|
||||||
return write<Char>(out, arg);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Char, typename T, int N>
|
|
||||||
struct is_compiled_format<field<Char, T, N>> : std::true_type {};
|
|
||||||
|
|
||||||
// A replacement field that refers to argument N and has format specifiers.
|
|
||||||
template <typename Char, typename T, int N> struct spec_field {
|
|
||||||
using char_type = Char;
|
|
||||||
mutable formatter<T, Char> fmt;
|
|
||||||
|
|
||||||
template <typename OutputIt, typename... Args>
|
|
||||||
OutputIt format(OutputIt out, const Args&... args) const {
|
|
||||||
// This ensures that the argument type is convertile to `const T&`.
|
|
||||||
const T& arg = get<N>(args...);
|
|
||||||
basic_format_context<OutputIt, Char> ctx(out, {});
|
|
||||||
return fmt.format(arg, ctx);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Char, typename T, int N>
|
|
||||||
struct is_compiled_format<spec_field<Char, T, N>> : std::true_type {};
|
|
||||||
|
|
||||||
template <typename L, typename R> struct concat {
|
|
||||||
L lhs;
|
|
||||||
R rhs;
|
|
||||||
using char_type = typename L::char_type;
|
|
||||||
|
|
||||||
template <typename OutputIt, typename... Args>
|
|
||||||
OutputIt format(OutputIt out, const Args&... args) const {
|
|
||||||
out = lhs.format(out, args...);
|
|
||||||
return rhs.format(out, args...);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename L, typename R>
|
|
||||||
struct is_compiled_format<concat<L, R>> : std::true_type {};
|
|
||||||
|
|
||||||
template <typename L, typename R>
|
|
||||||
constexpr concat<L, R> make_concat(L lhs, R rhs) {
|
|
||||||
return {lhs, rhs};
|
|
||||||
}
|
|
||||||
|
|
||||||
struct unknown_format {};
|
|
||||||
|
|
||||||
template <typename Char>
|
|
||||||
constexpr size_t parse_text(basic_string_view<Char> str, size_t pos) {
|
|
||||||
for (size_t size = str.size(); pos != size; ++pos) {
|
|
||||||
if (str[pos] == '{' || str[pos] == '}') break;
|
|
||||||
}
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Args, size_t POS, int ID, typename S>
|
|
||||||
constexpr auto compile_format_string(S format_str);
|
|
||||||
|
|
||||||
template <typename Args, size_t POS, int ID, typename T, typename S>
|
|
||||||
constexpr auto parse_tail(T head, S format_str) {
|
|
||||||
if constexpr (POS !=
|
|
||||||
basic_string_view<typename S::char_type>(format_str).size()) {
|
|
||||||
constexpr auto tail = compile_format_string<Args, POS, ID>(format_str);
|
|
||||||
if constexpr (std::is_same<remove_cvref_t<decltype(tail)>,
|
|
||||||
unknown_format>())
|
|
||||||
return tail;
|
|
||||||
else
|
|
||||||
return make_concat(head, tail);
|
|
||||||
} else {
|
|
||||||
return head;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, typename Char> struct parse_specs_result {
|
|
||||||
formatter<T, Char> fmt;
|
|
||||||
size_t end;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T, typename Char>
|
|
||||||
constexpr parse_specs_result<T, Char> parse_specs(basic_string_view<Char> str,
|
|
||||||
size_t pos) {
|
|
||||||
str.remove_prefix(pos);
|
|
||||||
auto ctx = basic_format_parse_context<Char>(str);
|
|
||||||
auto f = formatter<T, Char>();
|
|
||||||
auto end = f.parse(ctx);
|
|
||||||
return {f, pos + (end - str.data()) + 1};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compiles a non-empty format string and returns the compiled representation
|
|
||||||
// or unknown_format() on unrecognized input.
|
|
||||||
template <typename Args, size_t POS, int ID, typename S>
|
|
||||||
constexpr auto compile_format_string(S format_str) {
|
|
||||||
using char_type = typename S::char_type;
|
|
||||||
constexpr basic_string_view<char_type> str = format_str;
|
|
||||||
if constexpr (str[POS] == '{') {
|
|
||||||
if (POS + 1 == str.size())
|
|
||||||
throw format_error("unmatched '{' in format string");
|
|
||||||
if constexpr (str[POS + 1] == '{') {
|
|
||||||
return parse_tail<Args, POS + 2, ID>(make_text(str, POS, 1), format_str);
|
|
||||||
} else if constexpr (str[POS + 1] == '}') {
|
|
||||||
using type = get_type<ID, Args>;
|
|
||||||
return parse_tail<Args, POS + 2, ID + 1>(field<char_type, type, ID>(),
|
|
||||||
format_str);
|
|
||||||
} else if constexpr (str[POS + 1] == ':') {
|
|
||||||
using type = get_type<ID, Args>;
|
|
||||||
constexpr auto result = parse_specs<type>(str, POS + 2);
|
|
||||||
return parse_tail<Args, result.end, ID + 1>(
|
|
||||||
spec_field<char_type, type, ID>{result.fmt}, format_str);
|
|
||||||
} else {
|
|
||||||
return unknown_format();
|
|
||||||
}
|
|
||||||
} else if constexpr (str[POS] == '}') {
|
|
||||||
if (POS + 1 == str.size())
|
|
||||||
throw format_error("unmatched '}' in format string");
|
|
||||||
return parse_tail<Args, POS + 2, ID>(make_text(str, POS, 1), format_str);
|
|
||||||
} else {
|
|
||||||
constexpr auto end = parse_text(str, POS + 1);
|
|
||||||
return parse_tail<Args, end, ID>(make_text(str, POS, end - POS),
|
|
||||||
format_str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename... Args, typename S,
|
|
||||||
FMT_ENABLE_IF(is_compile_string<S>::value ||
|
|
||||||
detail::is_compiled_string<S>::value)>
|
|
||||||
constexpr auto compile(S format_str) {
|
|
||||||
constexpr basic_string_view<typename S::char_type> str = format_str;
|
|
||||||
if constexpr (str.size() == 0) {
|
|
||||||
return detail::make_text(str, 0, 0);
|
|
||||||
} else {
|
|
||||||
constexpr auto result =
|
|
||||||
detail::compile_format_string<detail::type_list<Args...>, 0, 0>(
|
|
||||||
format_str);
|
|
||||||
if constexpr (std::is_same<remove_cvref_t<decltype(result)>,
|
|
||||||
detail::unknown_format>()) {
|
|
||||||
return detail::compiled_format<S, Args...>(to_string_view(format_str));
|
|
||||||
} else {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
template <typename... Args, typename S,
|
|
||||||
FMT_ENABLE_IF(is_compile_string<S>::value)>
|
|
||||||
constexpr auto compile(S format_str) -> detail::compiled_format<S, Args...> {
|
|
||||||
return detail::compiled_format<S, Args...>(to_string_view(format_str));
|
|
||||||
}
|
|
||||||
#endif // __cpp_if_constexpr
|
|
||||||
|
|
||||||
// Compiles the format string which must be a string literal.
|
|
||||||
template <typename... Args, typename Char, size_t N>
|
|
||||||
auto compile(const Char (&format_str)[N])
|
|
||||||
-> detail::compiled_format<const Char*, Args...> {
|
|
||||||
return detail::compiled_format<const Char*, Args...>(
|
|
||||||
basic_string_view<Char>(format_str, N - 1));
|
|
||||||
}
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
// DEPRECATED! use FMT_COMPILE instead.
|
|
||||||
template <typename... Args>
|
|
||||||
FMT_DEPRECATED auto compile(const Args&... args)
|
|
||||||
-> decltype(detail::compile(args...)) {
|
|
||||||
return detail::compile(args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if FMT_USE_CONSTEXPR
|
|
||||||
# ifdef __cpp_if_constexpr
|
|
||||||
|
|
||||||
template <typename CompiledFormat, typename... Args,
|
|
||||||
typename Char = typename CompiledFormat::char_type,
|
|
||||||
FMT_ENABLE_IF(detail::is_compiled_format<CompiledFormat>::value)>
|
|
||||||
FMT_INLINE std::basic_string<Char> format(const CompiledFormat& cf,
|
|
||||||
const Args&... args) {
|
|
||||||
basic_memory_buffer<Char> buffer;
|
|
||||||
detail::buffer<Char>& base = buffer;
|
|
||||||
cf.format(std::back_inserter(base), args...);
|
|
||||||
return to_string(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename OutputIt, typename CompiledFormat, typename... Args,
|
|
||||||
FMT_ENABLE_IF(detail::is_compiled_format<CompiledFormat>::value)>
|
|
||||||
OutputIt format_to(OutputIt out, const CompiledFormat& cf,
|
|
||||||
const Args&... args) {
|
|
||||||
return cf.format(out, args...);
|
|
||||||
}
|
|
||||||
# endif // __cpp_if_constexpr
|
|
||||||
#endif // FMT_USE_CONSTEXPR
|
|
||||||
|
|
||||||
template <typename CompiledFormat, typename... Args,
|
|
||||||
typename Char = typename CompiledFormat::char_type,
|
|
||||||
FMT_ENABLE_IF(std::is_base_of<detail::basic_compiled_format,
|
|
||||||
CompiledFormat>::value)>
|
|
||||||
std::basic_string<Char> format(const CompiledFormat& cf, const Args&... args) {
|
|
||||||
basic_memory_buffer<Char> buffer;
|
|
||||||
using context = buffer_context<Char>;
|
|
||||||
detail::buffer<Char>& base = buffer;
|
|
||||||
detail::cf::vformat_to<context>(std::back_inserter(base), cf,
|
|
||||||
make_format_args<context>(args...));
|
|
||||||
return to_string(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename S, typename... Args,
|
|
||||||
FMT_ENABLE_IF(detail::is_compiled_string<S>::value)>
|
|
||||||
FMT_INLINE std::basic_string<typename S::char_type> format(const S&,
|
|
||||||
Args&&... args) {
|
|
||||||
constexpr basic_string_view<typename S::char_type> str = S();
|
|
||||||
if (str.size() == 2 && str[0] == '{' && str[1] == '}')
|
|
||||||
return fmt::to_string(detail::first(args...));
|
|
||||||
constexpr auto compiled = detail::compile<Args...>(S());
|
|
||||||
return format(compiled, std::forward<Args>(args)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename OutputIt, typename CompiledFormat, typename... Args,
|
|
||||||
FMT_ENABLE_IF(std::is_base_of<detail::basic_compiled_format,
|
|
||||||
CompiledFormat>::value)>
|
|
||||||
OutputIt format_to(OutputIt out, const CompiledFormat& cf,
|
|
||||||
const Args&... args) {
|
|
||||||
using char_type = typename CompiledFormat::char_type;
|
|
||||||
using context = format_context_t<OutputIt, char_type>;
|
|
||||||
return detail::cf::vformat_to<context>(out, cf,
|
|
||||||
make_format_args<context>(args...));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename OutputIt, typename S, typename... Args,
|
|
||||||
FMT_ENABLE_IF(detail::is_compiled_string<S>::value)>
|
|
||||||
OutputIt format_to(OutputIt out, const S&, const Args&... args) {
|
|
||||||
constexpr auto compiled = detail::compile<Args...>(S());
|
|
||||||
return format_to(out, compiled, args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <
|
|
||||||
typename OutputIt, typename CompiledFormat, typename... Args,
|
|
||||||
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt>::value&& std::is_base_of<
|
|
||||||
detail::basic_compiled_format, CompiledFormat>::value)>
|
|
||||||
format_to_n_result<OutputIt> format_to_n(OutputIt out, size_t n,
|
|
||||||
const CompiledFormat& cf,
|
|
||||||
const Args&... args) {
|
|
||||||
auto it =
|
|
||||||
format_to(detail::truncating_iterator<OutputIt>(out, n), cf, args...);
|
|
||||||
return {it.base(), it.count()};
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename CompiledFormat, typename... Args>
|
|
||||||
size_t formatted_size(const CompiledFormat& cf, const Args&... args) {
|
|
||||||
return format_to(detail::counting_iterator(), cf, args...).count();
|
|
||||||
}
|
|
||||||
|
|
||||||
FMT_END_NAMESPACE
|
|
||||||
|
|
||||||
#endif // FMT_COMPILE_H_
|
|
||||||
1882
external/fmtlib/include/fmt/core.h
vendored
1882
external/fmtlib/include/fmt/core.h
vendored
File diff suppressed because it is too large
Load Diff
1453
external/fmtlib/include/fmt/format-inl.h
vendored
1453
external/fmtlib/include/fmt/format-inl.h
vendored
File diff suppressed because it is too large
Load Diff
3729
external/fmtlib/include/fmt/format.h
vendored
3729
external/fmtlib/include/fmt/format.h
vendored
File diff suppressed because it is too large
Load Diff
78
external/fmtlib/include/fmt/locale.h
vendored
78
external/fmtlib/include/fmt/locale.h
vendored
@@ -1,78 +0,0 @@
|
|||||||
// Formatting library for C++ - std::locale support
|
|
||||||
//
|
|
||||||
// Copyright (c) 2012 - present, Victor Zverovich
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// For the license information refer to format.h.
|
|
||||||
|
|
||||||
#ifndef FMT_LOCALE_H_
|
|
||||||
#define FMT_LOCALE_H_
|
|
||||||
|
|
||||||
#include <locale>
|
|
||||||
|
|
||||||
#include "format.h"
|
|
||||||
|
|
||||||
FMT_BEGIN_NAMESPACE
|
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
template <typename Char>
|
|
||||||
typename buffer_context<Char>::iterator vformat_to(
|
|
||||||
const std::locale& loc, buffer<Char>& buf,
|
|
||||||
basic_string_view<Char> format_str,
|
|
||||||
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
|
|
||||||
using af = arg_formatter<typename buffer_context<Char>::iterator, Char>;
|
|
||||||
return vformat_to<af>(std::back_inserter(buf), to_string_view(format_str),
|
|
||||||
args, detail::locale_ref(loc));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Char>
|
|
||||||
std::basic_string<Char> vformat(
|
|
||||||
const std::locale& loc, basic_string_view<Char> format_str,
|
|
||||||
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
|
|
||||||
basic_memory_buffer<Char> buffer;
|
|
||||||
detail::vformat_to(loc, buffer, format_str, args);
|
|
||||||
return fmt::to_string(buffer);
|
|
||||||
}
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
template <typename S, typename Char = char_t<S>>
|
|
||||||
inline std::basic_string<Char> vformat(
|
|
||||||
const std::locale& loc, const S& format_str,
|
|
||||||
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
|
|
||||||
return detail::vformat(loc, to_string_view(format_str), args);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename S, typename... Args, typename Char = char_t<S>>
|
|
||||||
inline std::basic_string<Char> format(const std::locale& loc,
|
|
||||||
const S& format_str, Args&&... args) {
|
|
||||||
return detail::vformat(
|
|
||||||
loc, to_string_view(format_str),
|
|
||||||
detail::make_args_checked<Args...>(format_str, args...));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename S, typename OutputIt, typename... Args,
|
|
||||||
typename Char = enable_if_t<
|
|
||||||
detail::is_output_iterator<OutputIt>::value, char_t<S>>>
|
|
||||||
inline OutputIt vformat_to(
|
|
||||||
OutputIt out, const std::locale& loc, const S& format_str,
|
|
||||||
format_args_t<type_identity_t<OutputIt>, Char> args) {
|
|
||||||
using af = detail::arg_formatter<OutputIt, Char>;
|
|
||||||
return vformat_to<af>(out, to_string_view(format_str), args,
|
|
||||||
detail::locale_ref(loc));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename OutputIt, typename S, typename... Args,
|
|
||||||
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt>::value&&
|
|
||||||
detail::is_string<S>::value)>
|
|
||||||
inline OutputIt format_to(OutputIt out, const std::locale& loc,
|
|
||||||
const S& format_str, Args&&... args) {
|
|
||||||
detail::check_format_string<Args...>(format_str);
|
|
||||||
using context = format_context_t<OutputIt, char_t<S>>;
|
|
||||||
format_arg_store<context, Args...> as{args...};
|
|
||||||
return vformat_to(out, loc, to_string_view(format_str),
|
|
||||||
basic_format_args<context>(as));
|
|
||||||
}
|
|
||||||
|
|
||||||
FMT_END_NAMESPACE
|
|
||||||
|
|
||||||
#endif // FMT_LOCALE_H_
|
|
||||||
450
external/fmtlib/include/fmt/os.h
vendored
450
external/fmtlib/include/fmt/os.h
vendored
@@ -1,450 +0,0 @@
|
|||||||
// Formatting library for C++ - optional OS-specific functionality
|
|
||||||
//
|
|
||||||
// Copyright (c) 2012 - present, Victor Zverovich
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// For the license information refer to format.h.
|
|
||||||
|
|
||||||
#ifndef FMT_OS_H_
|
|
||||||
#define FMT_OS_H_
|
|
||||||
|
|
||||||
#if defined(__MINGW32__) || defined(__CYGWIN__)
|
|
||||||
// Workaround MinGW bug https://sourceforge.net/p/mingw/bugs/2024/.
|
|
||||||
# undef __STRICT_ANSI__
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <cerrno>
|
|
||||||
#include <clocale> // for locale_t
|
|
||||||
#include <cstddef>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <cstdlib> // for strtod_l
|
|
||||||
|
|
||||||
#if defined __APPLE__ || defined(__FreeBSD__)
|
|
||||||
# include <xlocale.h> // for LC_NUMERIC_MASK on OS X
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "format.h"
|
|
||||||
|
|
||||||
// UWP doesn't provide _pipe.
|
|
||||||
#if FMT_HAS_INCLUDE("winapifamily.h")
|
|
||||||
# include <winapifamily.h>
|
|
||||||
#endif
|
|
||||||
#if FMT_HAS_INCLUDE("fcntl.h") && \
|
|
||||||
(!defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP))
|
|
||||||
# include <fcntl.h> // for O_RDONLY
|
|
||||||
# define FMT_USE_FCNTL 1
|
|
||||||
#else
|
|
||||||
# define FMT_USE_FCNTL 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef FMT_POSIX
|
|
||||||
# if defined(_WIN32) && !defined(__MINGW32__)
|
|
||||||
// Fix warnings about deprecated symbols.
|
|
||||||
# define FMT_POSIX(call) _##call
|
|
||||||
# else
|
|
||||||
# define FMT_POSIX(call) call
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Calls to system functions are wrapped in FMT_SYSTEM for testability.
|
|
||||||
#ifdef FMT_SYSTEM
|
|
||||||
# define FMT_POSIX_CALL(call) FMT_SYSTEM(call)
|
|
||||||
#else
|
|
||||||
# define FMT_SYSTEM(call) ::call
|
|
||||||
# ifdef _WIN32
|
|
||||||
// Fix warnings about deprecated symbols.
|
|
||||||
# define FMT_POSIX_CALL(call) ::_##call
|
|
||||||
# else
|
|
||||||
# define FMT_POSIX_CALL(call) ::call
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Retries the expression while it evaluates to error_result and errno
|
|
||||||
// equals to EINTR.
|
|
||||||
#ifndef _WIN32
|
|
||||||
# define FMT_RETRY_VAL(result, expression, error_result) \
|
|
||||||
do { \
|
|
||||||
(result) = (expression); \
|
|
||||||
} while ((result) == (error_result) && errno == EINTR)
|
|
||||||
#else
|
|
||||||
# define FMT_RETRY_VAL(result, expression, error_result) result = (expression)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define FMT_RETRY(result, expression) FMT_RETRY_VAL(result, expression, -1)
|
|
||||||
|
|
||||||
FMT_BEGIN_NAMESPACE
|
|
||||||
|
|
||||||
/**
|
|
||||||
\rst
|
|
||||||
A reference to a null-terminated string. It can be constructed from a C
|
|
||||||
string or ``std::string``.
|
|
||||||
|
|
||||||
You can use one of the following type aliases for common character types:
|
|
||||||
|
|
||||||
+---------------+-----------------------------+
|
|
||||||
| Type | Definition |
|
|
||||||
+===============+=============================+
|
|
||||||
| cstring_view | basic_cstring_view<char> |
|
|
||||||
+---------------+-----------------------------+
|
|
||||||
| wcstring_view | basic_cstring_view<wchar_t> |
|
|
||||||
+---------------+-----------------------------+
|
|
||||||
|
|
||||||
This class is most useful as a parameter type to allow passing
|
|
||||||
different types of strings to a function, for example::
|
|
||||||
|
|
||||||
template <typename... Args>
|
|
||||||
std::string format(cstring_view format_str, const Args & ... args);
|
|
||||||
|
|
||||||
format("{}", 42);
|
|
||||||
format(std::string("{}"), 42);
|
|
||||||
\endrst
|
|
||||||
*/
|
|
||||||
template <typename Char> class basic_cstring_view {
|
|
||||||
private:
|
|
||||||
const Char* data_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
/** Constructs a string reference object from a C string. */
|
|
||||||
basic_cstring_view(const Char* s) : data_(s) {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
\rst
|
|
||||||
Constructs a string reference from an ``std::string`` object.
|
|
||||||
\endrst
|
|
||||||
*/
|
|
||||||
basic_cstring_view(const std::basic_string<Char>& s) : data_(s.c_str()) {}
|
|
||||||
|
|
||||||
/** Returns the pointer to a C string. */
|
|
||||||
const Char* c_str() const { return data_; }
|
|
||||||
};
|
|
||||||
|
|
||||||
using cstring_view = basic_cstring_view<char>;
|
|
||||||
using wcstring_view = basic_cstring_view<wchar_t>;
|
|
||||||
|
|
||||||
// An error code.
|
|
||||||
class error_code {
|
|
||||||
private:
|
|
||||||
int value_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit error_code(int value = 0) FMT_NOEXCEPT : value_(value) {}
|
|
||||||
|
|
||||||
int get() const FMT_NOEXCEPT { return value_; }
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
namespace detail {
|
|
||||||
// A converter from UTF-16 to UTF-8.
|
|
||||||
// It is only provided for Windows since other systems support UTF-8 natively.
|
|
||||||
class utf16_to_utf8 {
|
|
||||||
private:
|
|
||||||
memory_buffer buffer_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
utf16_to_utf8() {}
|
|
||||||
FMT_API explicit utf16_to_utf8(wstring_view s);
|
|
||||||
operator string_view() const { return string_view(&buffer_[0], size()); }
|
|
||||||
size_t size() const { return buffer_.size() - 1; }
|
|
||||||
const char* c_str() const { return &buffer_[0]; }
|
|
||||||
std::string str() const { return std::string(&buffer_[0], size()); }
|
|
||||||
|
|
||||||
// Performs conversion returning a system error code instead of
|
|
||||||
// throwing exception on conversion error. This method may still throw
|
|
||||||
// in case of memory allocation error.
|
|
||||||
FMT_API int convert(wstring_view s);
|
|
||||||
};
|
|
||||||
|
|
||||||
FMT_API void format_windows_error(buffer<char>& out, int error_code,
|
|
||||||
string_view message) FMT_NOEXCEPT;
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
/** A Windows error. */
|
|
||||||
class windows_error : public system_error {
|
|
||||||
private:
|
|
||||||
FMT_API void init(int error_code, string_view format_str, format_args args);
|
|
||||||
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
\rst
|
|
||||||
Constructs a :class:`fmt::windows_error` object with the description
|
|
||||||
of the form
|
|
||||||
|
|
||||||
.. parsed-literal::
|
|
||||||
*<message>*: *<system-message>*
|
|
||||||
|
|
||||||
where *<message>* is the formatted message and *<system-message>* is the
|
|
||||||
system message corresponding to the error code.
|
|
||||||
*error_code* is a Windows error code as given by ``GetLastError``.
|
|
||||||
If *error_code* is not a valid error code such as -1, the system message
|
|
||||||
will look like "error -1".
|
|
||||||
|
|
||||||
**Example**::
|
|
||||||
|
|
||||||
// This throws a windows_error with the description
|
|
||||||
// cannot open file 'madeup': The system cannot find the file specified.
|
|
||||||
// or similar (system message may vary).
|
|
||||||
const char *filename = "madeup";
|
|
||||||
LPOFSTRUCT of = LPOFSTRUCT();
|
|
||||||
HFILE file = OpenFile(filename, &of, OF_READ);
|
|
||||||
if (file == HFILE_ERROR) {
|
|
||||||
throw fmt::windows_error(GetLastError(),
|
|
||||||
"cannot open file '{}'", filename);
|
|
||||||
}
|
|
||||||
\endrst
|
|
||||||
*/
|
|
||||||
template <typename... Args>
|
|
||||||
windows_error(int error_code, string_view message, const Args&... args) {
|
|
||||||
init(error_code, message, make_format_args(args...));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Reports a Windows error without throwing an exception.
|
|
||||||
// Can be used to report errors from destructors.
|
|
||||||
FMT_API void report_windows_error(int error_code,
|
|
||||||
string_view message) FMT_NOEXCEPT;
|
|
||||||
#endif // _WIN32
|
|
||||||
|
|
||||||
// A buffered file.
|
|
||||||
class buffered_file {
|
|
||||||
private:
|
|
||||||
FILE* file_;
|
|
||||||
|
|
||||||
friend class file;
|
|
||||||
|
|
||||||
explicit buffered_file(FILE* f) : file_(f) {}
|
|
||||||
|
|
||||||
public:
|
|
||||||
buffered_file(const buffered_file&) = delete;
|
|
||||||
void operator=(const buffered_file&) = delete;
|
|
||||||
|
|
||||||
// Constructs a buffered_file object which doesn't represent any file.
|
|
||||||
buffered_file() FMT_NOEXCEPT : file_(nullptr) {}
|
|
||||||
|
|
||||||
// Destroys the object closing the file it represents if any.
|
|
||||||
FMT_API ~buffered_file() FMT_NOEXCEPT;
|
|
||||||
|
|
||||||
public:
|
|
||||||
buffered_file(buffered_file&& other) FMT_NOEXCEPT : file_(other.file_) {
|
|
||||||
other.file_ = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffered_file& operator=(buffered_file&& other) {
|
|
||||||
close();
|
|
||||||
file_ = other.file_;
|
|
||||||
other.file_ = nullptr;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Opens a file.
|
|
||||||
FMT_API buffered_file(cstring_view filename, cstring_view mode);
|
|
||||||
|
|
||||||
// Closes the file.
|
|
||||||
FMT_API void close();
|
|
||||||
|
|
||||||
// Returns the pointer to a FILE object representing this file.
|
|
||||||
FILE* get() const FMT_NOEXCEPT { return file_; }
|
|
||||||
|
|
||||||
// We place parentheses around fileno to workaround a bug in some versions
|
|
||||||
// of MinGW that define fileno as a macro.
|
|
||||||
FMT_API int(fileno)() const;
|
|
||||||
|
|
||||||
void vprint(string_view format_str, format_args args) {
|
|
||||||
fmt::vprint(file_, format_str, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename... Args>
|
|
||||||
inline void print(string_view format_str, const Args&... args) {
|
|
||||||
vprint(format_str, make_format_args(args...));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#if FMT_USE_FCNTL
|
|
||||||
// A file. Closed file is represented by a file object with descriptor -1.
|
|
||||||
// Methods that are not declared with FMT_NOEXCEPT may throw
|
|
||||||
// fmt::system_error in case of failure. Note that some errors such as
|
|
||||||
// closing the file multiple times will cause a crash on Windows rather
|
|
||||||
// than an exception. You can get standard behavior by overriding the
|
|
||||||
// invalid parameter handler with _set_invalid_parameter_handler.
|
|
||||||
class file {
|
|
||||||
private:
|
|
||||||
int fd_; // File descriptor.
|
|
||||||
|
|
||||||
// Constructs a file object with a given descriptor.
|
|
||||||
explicit file(int fd) : fd_(fd) {}
|
|
||||||
|
|
||||||
public:
|
|
||||||
// Possible values for the oflag argument to the constructor.
|
|
||||||
enum {
|
|
||||||
RDONLY = FMT_POSIX(O_RDONLY), // Open for reading only.
|
|
||||||
WRONLY = FMT_POSIX(O_WRONLY), // Open for writing only.
|
|
||||||
RDWR = FMT_POSIX(O_RDWR), // Open for reading and writing.
|
|
||||||
CREATE = FMT_POSIX(O_CREAT) // Create if the file doesn't exist.
|
|
||||||
};
|
|
||||||
|
|
||||||
// Constructs a file object which doesn't represent any file.
|
|
||||||
file() FMT_NOEXCEPT : fd_(-1) {}
|
|
||||||
|
|
||||||
// Opens a file and constructs a file object representing this file.
|
|
||||||
FMT_API file(cstring_view path, int oflag);
|
|
||||||
|
|
||||||
public:
|
|
||||||
file(const file&) = delete;
|
|
||||||
void operator=(const file&) = delete;
|
|
||||||
|
|
||||||
file(file&& other) FMT_NOEXCEPT : fd_(other.fd_) { other.fd_ = -1; }
|
|
||||||
|
|
||||||
file& operator=(file&& other) FMT_NOEXCEPT {
|
|
||||||
close();
|
|
||||||
fd_ = other.fd_;
|
|
||||||
other.fd_ = -1;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destroys the object closing the file it represents if any.
|
|
||||||
FMT_API ~file() FMT_NOEXCEPT;
|
|
||||||
|
|
||||||
// Returns the file descriptor.
|
|
||||||
int descriptor() const FMT_NOEXCEPT { return fd_; }
|
|
||||||
|
|
||||||
// Closes the file.
|
|
||||||
FMT_API void close();
|
|
||||||
|
|
||||||
// Returns the file size. The size has signed type for consistency with
|
|
||||||
// stat::st_size.
|
|
||||||
FMT_API long long size() const;
|
|
||||||
|
|
||||||
// Attempts to read count bytes from the file into the specified buffer.
|
|
||||||
FMT_API size_t read(void* buffer, size_t count);
|
|
||||||
|
|
||||||
// Attempts to write count bytes from the specified buffer to the file.
|
|
||||||
FMT_API size_t write(const void* buffer, size_t count);
|
|
||||||
|
|
||||||
// Duplicates a file descriptor with the dup function and returns
|
|
||||||
// the duplicate as a file object.
|
|
||||||
FMT_API static file dup(int fd);
|
|
||||||
|
|
||||||
// Makes fd be the copy of this file descriptor, closing fd first if
|
|
||||||
// necessary.
|
|
||||||
FMT_API void dup2(int fd);
|
|
||||||
|
|
||||||
// Makes fd be the copy of this file descriptor, closing fd first if
|
|
||||||
// necessary.
|
|
||||||
FMT_API void dup2(int fd, error_code& ec) FMT_NOEXCEPT;
|
|
||||||
|
|
||||||
// Creates a pipe setting up read_end and write_end file objects for reading
|
|
||||||
// and writing respectively.
|
|
||||||
FMT_API static void pipe(file& read_end, file& write_end);
|
|
||||||
|
|
||||||
// Creates a buffered_file object associated with this file and detaches
|
|
||||||
// this file object from the file.
|
|
||||||
FMT_API buffered_file fdopen(const char* mode);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Returns the memory page size.
|
|
||||||
long getpagesize();
|
|
||||||
|
|
||||||
class direct_buffered_file;
|
|
||||||
|
|
||||||
template <typename S, typename... Args>
|
|
||||||
void print(direct_buffered_file& f, const S& format_str,
|
|
||||||
const Args&... args);
|
|
||||||
|
|
||||||
// A buffered file with a direct buffer access and no synchronization.
|
|
||||||
class direct_buffered_file {
|
|
||||||
private:
|
|
||||||
file file_;
|
|
||||||
|
|
||||||
enum { buffer_size = 4096 };
|
|
||||||
char buffer_[buffer_size];
|
|
||||||
int pos_;
|
|
||||||
|
|
||||||
void flush() {
|
|
||||||
if (pos_ == 0) return;
|
|
||||||
file_.write(buffer_, pos_);
|
|
||||||
pos_ = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int free_capacity() const { return buffer_size - pos_; }
|
|
||||||
|
|
||||||
public:
|
|
||||||
direct_buffered_file(cstring_view path, int oflag)
|
|
||||||
: file_(path, oflag), pos_(0) {}
|
|
||||||
|
|
||||||
~direct_buffered_file() {
|
|
||||||
flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
void close() {
|
|
||||||
flush();
|
|
||||||
file_.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename S, typename... Args>
|
|
||||||
friend void print(direct_buffered_file& f, const S& format_str,
|
|
||||||
const Args&... args) {
|
|
||||||
// We could avoid double buffering.
|
|
||||||
auto buf = fmt::memory_buffer();
|
|
||||||
fmt::format_to(std::back_inserter(buf), format_str, args...);
|
|
||||||
auto remaining_pos = 0;
|
|
||||||
auto remaining_size = buf.size();
|
|
||||||
while (remaining_size > detail::to_unsigned(f.free_capacity())) {
|
|
||||||
auto size = f.free_capacity();
|
|
||||||
memcpy(f.buffer_ + f.pos_, buf.data() + remaining_pos, size);
|
|
||||||
f.pos_ += size;
|
|
||||||
f.flush();
|
|
||||||
remaining_pos += size;
|
|
||||||
remaining_size -= size;
|
|
||||||
}
|
|
||||||
memcpy(f.buffer_ + f.pos_, buf.data() + remaining_pos, remaining_size);
|
|
||||||
f.pos_ += static_cast<int>(remaining_size);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
#endif // FMT_USE_FCNTL
|
|
||||||
|
|
||||||
#ifdef FMT_LOCALE
|
|
||||||
// A "C" numeric locale.
|
|
||||||
class locale {
|
|
||||||
private:
|
|
||||||
# ifdef _WIN32
|
|
||||||
using locale_t = _locale_t;
|
|
||||||
|
|
||||||
static void freelocale(locale_t loc) { _free_locale(loc); }
|
|
||||||
|
|
||||||
static double strtod_l(const char* nptr, char** endptr, _locale_t loc) {
|
|
||||||
return _strtod_l(nptr, endptr, loc);
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
locale_t locale_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
using type = locale_t;
|
|
||||||
locale(const locale&) = delete;
|
|
||||||
void operator=(const locale&) = delete;
|
|
||||||
|
|
||||||
locale() {
|
|
||||||
# ifndef _WIN32
|
|
||||||
locale_ = FMT_SYSTEM(newlocale(LC_NUMERIC_MASK, "C", nullptr));
|
|
||||||
# else
|
|
||||||
locale_ = _create_locale(LC_NUMERIC, "C");
|
|
||||||
# endif
|
|
||||||
if (!locale_) FMT_THROW(system_error(errno, "cannot create locale"));
|
|
||||||
}
|
|
||||||
~locale() { freelocale(locale_); }
|
|
||||||
|
|
||||||
type get() const { return locale_; }
|
|
||||||
|
|
||||||
// Converts string to floating-point number and advances str past the end
|
|
||||||
// of the parsed input.
|
|
||||||
double strtod(const char*& str) const {
|
|
||||||
char* end = nullptr;
|
|
||||||
double result = strtod_l(str, &end, locale_);
|
|
||||||
str = end;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
using Locale FMT_DEPRECATED_ALIAS = locale;
|
|
||||||
#endif // FMT_LOCALE
|
|
||||||
FMT_END_NAMESPACE
|
|
||||||
|
|
||||||
#endif // FMT_OS_H_
|
|
||||||
167
external/fmtlib/include/fmt/ostream.h
vendored
167
external/fmtlib/include/fmt/ostream.h
vendored
@@ -1,167 +0,0 @@
|
|||||||
// Formatting library for C++ - std::ostream support
|
|
||||||
//
|
|
||||||
// Copyright (c) 2012 - present, Victor Zverovich
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// For the license information refer to format.h.
|
|
||||||
|
|
||||||
#ifndef FMT_OSTREAM_H_
|
|
||||||
#define FMT_OSTREAM_H_
|
|
||||||
|
|
||||||
#include <ostream>
|
|
||||||
|
|
||||||
#include "format.h"
|
|
||||||
|
|
||||||
FMT_BEGIN_NAMESPACE
|
|
||||||
|
|
||||||
template <typename Char> class basic_printf_parse_context;
|
|
||||||
template <typename OutputIt, typename Char> class basic_printf_context;
|
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
template <class Char> class formatbuf : public std::basic_streambuf<Char> {
|
|
||||||
private:
|
|
||||||
using int_type = typename std::basic_streambuf<Char>::int_type;
|
|
||||||
using traits_type = typename std::basic_streambuf<Char>::traits_type;
|
|
||||||
|
|
||||||
buffer<Char>& buffer_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
formatbuf(buffer<Char>& buf) : buffer_(buf) {}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// The put-area is actually always empty. This makes the implementation
|
|
||||||
// simpler and has the advantage that the streambuf and the buffer are always
|
|
||||||
// in sync and sputc never writes into uninitialized memory. The obvious
|
|
||||||
// disadvantage is that each call to sputc always results in a (virtual) call
|
|
||||||
// to overflow. There is no disadvantage here for sputn since this always
|
|
||||||
// results in a call to xsputn.
|
|
||||||
|
|
||||||
int_type overflow(int_type ch = traits_type::eof()) FMT_OVERRIDE {
|
|
||||||
if (!traits_type::eq_int_type(ch, traits_type::eof()))
|
|
||||||
buffer_.push_back(static_cast<Char>(ch));
|
|
||||||
return ch;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::streamsize xsputn(const Char* s, std::streamsize count) FMT_OVERRIDE {
|
|
||||||
buffer_.append(s, s + count);
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Char> struct test_stream : std::basic_ostream<Char> {
|
|
||||||
private:
|
|
||||||
// Hide all operator<< from std::basic_ostream<Char>.
|
|
||||||
void_t<> operator<<(null<>);
|
|
||||||
void_t<> operator<<(const Char*);
|
|
||||||
|
|
||||||
template <typename T, FMT_ENABLE_IF(std::is_convertible<T, int>::value &&
|
|
||||||
!std::is_enum<T>::value)>
|
|
||||||
void_t<> operator<<(T);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Checks if T has a user-defined operator<< (e.g. not a member of
|
|
||||||
// std::ostream).
|
|
||||||
template <typename T, typename Char> class is_streamable {
|
|
||||||
private:
|
|
||||||
template <typename U>
|
|
||||||
static bool_constant<!std::is_same<decltype(std::declval<test_stream<Char>&>()
|
|
||||||
<< std::declval<U>()),
|
|
||||||
void_t<>>::value>
|
|
||||||
test(int);
|
|
||||||
|
|
||||||
template <typename> static std::false_type test(...);
|
|
||||||
|
|
||||||
using result = decltype(test<T>(0));
|
|
||||||
|
|
||||||
public:
|
|
||||||
static const bool value = result::value;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Write the content of buf to os.
|
|
||||||
template <typename Char>
|
|
||||||
void write_buffer(std::basic_ostream<Char>& os, buffer<Char>& buf) {
|
|
||||||
const Char* buf_data = buf.data();
|
|
||||||
using unsigned_streamsize = std::make_unsigned<std::streamsize>::type;
|
|
||||||
unsigned_streamsize size = buf.size();
|
|
||||||
unsigned_streamsize max_size = to_unsigned(max_value<std::streamsize>());
|
|
||||||
do {
|
|
||||||
unsigned_streamsize n = size <= max_size ? size : max_size;
|
|
||||||
os.write(buf_data, static_cast<std::streamsize>(n));
|
|
||||||
buf_data += n;
|
|
||||||
size -= n;
|
|
||||||
} while (size != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Char, typename T>
|
|
||||||
void format_value(buffer<Char>& buf, const T& value,
|
|
||||||
locale_ref loc = locale_ref()) {
|
|
||||||
formatbuf<Char> format_buf(buf);
|
|
||||||
std::basic_ostream<Char> output(&format_buf);
|
|
||||||
#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR)
|
|
||||||
if (loc) output.imbue(loc.get<std::locale>());
|
|
||||||
#endif
|
|
||||||
output << value;
|
|
||||||
output.exceptions(std::ios_base::failbit | std::ios_base::badbit);
|
|
||||||
buf.resize(buf.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Formats an object of type T that has an overloaded ostream operator<<.
|
|
||||||
template <typename T, typename Char>
|
|
||||||
struct fallback_formatter<T, Char, enable_if_t<is_streamable<T, Char>::value>>
|
|
||||||
: private formatter<basic_string_view<Char>, Char> {
|
|
||||||
FMT_CONSTEXPR auto parse(basic_format_parse_context<Char>& ctx)
|
|
||||||
-> decltype(ctx.begin()) {
|
|
||||||
return formatter<basic_string_view<Char>, Char>::parse(ctx);
|
|
||||||
}
|
|
||||||
template <typename ParseCtx,
|
|
||||||
FMT_ENABLE_IF(std::is_same<
|
|
||||||
ParseCtx, basic_printf_parse_context<Char>>::value)>
|
|
||||||
auto parse(ParseCtx& ctx) -> decltype(ctx.begin()) {
|
|
||||||
return ctx.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename OutputIt>
|
|
||||||
auto format(const T& value, basic_format_context<OutputIt, Char>& ctx)
|
|
||||||
-> OutputIt {
|
|
||||||
basic_memory_buffer<Char> buffer;
|
|
||||||
format_value(buffer, value, ctx.locale());
|
|
||||||
basic_string_view<Char> str(buffer.data(), buffer.size());
|
|
||||||
return formatter<basic_string_view<Char>, Char>::format(str, ctx);
|
|
||||||
}
|
|
||||||
template <typename OutputIt>
|
|
||||||
auto format(const T& value, basic_printf_context<OutputIt, Char>& ctx)
|
|
||||||
-> OutputIt {
|
|
||||||
basic_memory_buffer<Char> buffer;
|
|
||||||
format_value(buffer, value, ctx.locale());
|
|
||||||
return std::copy(buffer.begin(), buffer.end(), ctx.out());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
template <typename Char>
|
|
||||||
void vprint(std::basic_ostream<Char>& os, basic_string_view<Char> format_str,
|
|
||||||
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
|
|
||||||
basic_memory_buffer<Char> buffer;
|
|
||||||
detail::vformat_to(buffer, format_str, args);
|
|
||||||
detail::write_buffer(os, buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
\rst
|
|
||||||
Prints formatted data to the stream *os*.
|
|
||||||
|
|
||||||
**Example**::
|
|
||||||
|
|
||||||
fmt::print(cerr, "Don't {}!", "panic");
|
|
||||||
\endrst
|
|
||||||
*/
|
|
||||||
template <typename S, typename... Args,
|
|
||||||
typename Char = enable_if_t<detail::is_string<S>::value, char_t<S>>>
|
|
||||||
void print(std::basic_ostream<Char>& os, const S& format_str, Args&&... args) {
|
|
||||||
vprint(os, to_string_view(format_str),
|
|
||||||
detail::make_args_checked<Args...>(format_str, args...));
|
|
||||||
}
|
|
||||||
FMT_END_NAMESPACE
|
|
||||||
|
|
||||||
#endif // FMT_OSTREAM_H_
|
|
||||||
2
external/fmtlib/include/fmt/posix.h
vendored
2
external/fmtlib/include/fmt/posix.h
vendored
@@ -1,2 +0,0 @@
|
|||||||
#include "os.h"
|
|
||||||
#warning "fmt/posix.h is deprecated; use fmt/os.h instead"
|
|
||||||
751
external/fmtlib/include/fmt/printf.h
vendored
751
external/fmtlib/include/fmt/printf.h
vendored
@@ -1,751 +0,0 @@
|
|||||||
// Formatting library for C++ - legacy printf implementation
|
|
||||||
//
|
|
||||||
// Copyright (c) 2012 - 2016, Victor Zverovich
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// For the license information refer to format.h.
|
|
||||||
|
|
||||||
#ifndef FMT_PRINTF_H_
|
|
||||||
#define FMT_PRINTF_H_
|
|
||||||
|
|
||||||
#include <algorithm> // std::max
|
|
||||||
#include <limits> // std::numeric_limits
|
|
||||||
|
|
||||||
#include "ostream.h"
|
|
||||||
|
|
||||||
FMT_BEGIN_NAMESPACE
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
// Checks if a value fits in int - used to avoid warnings about comparing
|
|
||||||
// signed and unsigned integers.
|
|
||||||
template <bool IsSigned> struct int_checker {
|
|
||||||
template <typename T> static bool fits_in_int(T value) {
|
|
||||||
unsigned max = max_value<int>();
|
|
||||||
return value <= max;
|
|
||||||
}
|
|
||||||
static bool fits_in_int(bool) { return true; }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <> struct int_checker<true> {
|
|
||||||
template <typename T> static bool fits_in_int(T value) {
|
|
||||||
return value >= (std::numeric_limits<int>::min)() &&
|
|
||||||
value <= max_value<int>();
|
|
||||||
}
|
|
||||||
static bool fits_in_int(int) { return true; }
|
|
||||||
};
|
|
||||||
|
|
||||||
class printf_precision_handler {
|
|
||||||
public:
|
|
||||||
template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
|
|
||||||
int operator()(T value) {
|
|
||||||
if (!int_checker<std::numeric_limits<T>::is_signed>::fits_in_int(value))
|
|
||||||
FMT_THROW(format_error("number is too big"));
|
|
||||||
return (std::max)(static_cast<int>(value), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
|
|
||||||
int operator()(T) {
|
|
||||||
FMT_THROW(format_error("precision is not integer"));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// An argument visitor that returns true iff arg is a zero integer.
|
|
||||||
class is_zero_int {
|
|
||||||
public:
|
|
||||||
template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
|
|
||||||
bool operator()(T value) {
|
|
||||||
return value == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
|
|
||||||
bool operator()(T) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T> struct make_unsigned_or_bool : std::make_unsigned<T> {};
|
|
||||||
|
|
||||||
template <> struct make_unsigned_or_bool<bool> { using type = bool; };
|
|
||||||
|
|
||||||
template <typename T, typename Context> class arg_converter {
|
|
||||||
private:
|
|
||||||
using char_type = typename Context::char_type;
|
|
||||||
|
|
||||||
basic_format_arg<Context>& arg_;
|
|
||||||
char_type type_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
arg_converter(basic_format_arg<Context>& arg, char_type type)
|
|
||||||
: arg_(arg), type_(type) {}
|
|
||||||
|
|
||||||
void operator()(bool value) {
|
|
||||||
if (type_ != 's') operator()<bool>(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename U, FMT_ENABLE_IF(std::is_integral<U>::value)>
|
|
||||||
void operator()(U value) {
|
|
||||||
bool is_signed = type_ == 'd' || type_ == 'i';
|
|
||||||
using target_type = conditional_t<std::is_same<T, void>::value, U, T>;
|
|
||||||
if (const_check(sizeof(target_type) <= sizeof(int))) {
|
|
||||||
// Extra casts are used to silence warnings.
|
|
||||||
if (is_signed) {
|
|
||||||
arg_ = detail::make_arg<Context>(
|
|
||||||
static_cast<int>(static_cast<target_type>(value)));
|
|
||||||
} else {
|
|
||||||
using unsigned_type = typename make_unsigned_or_bool<target_type>::type;
|
|
||||||
arg_ = detail::make_arg<Context>(
|
|
||||||
static_cast<unsigned>(static_cast<unsigned_type>(value)));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (is_signed) {
|
|
||||||
// glibc's printf doesn't sign extend arguments of smaller types:
|
|
||||||
// std::printf("%lld", -42); // prints "4294967254"
|
|
||||||
// but we don't have to do the same because it's a UB.
|
|
||||||
arg_ = detail::make_arg<Context>(static_cast<long long>(value));
|
|
||||||
} else {
|
|
||||||
arg_ = detail::make_arg<Context>(
|
|
||||||
static_cast<typename make_unsigned_or_bool<U>::type>(value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename U, FMT_ENABLE_IF(!std::is_integral<U>::value)>
|
|
||||||
void operator()(U) {} // No conversion needed for non-integral types.
|
|
||||||
};
|
|
||||||
|
|
||||||
// Converts an integer argument to T for printf, if T is an integral type.
|
|
||||||
// If T is void, the argument is converted to corresponding signed or unsigned
|
|
||||||
// type depending on the type specifier: 'd' and 'i' - signed, other -
|
|
||||||
// unsigned).
|
|
||||||
template <typename T, typename Context, typename Char>
|
|
||||||
void convert_arg(basic_format_arg<Context>& arg, Char type) {
|
|
||||||
visit_format_arg(arg_converter<T, Context>(arg, type), arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Converts an integer argument to char for printf.
|
|
||||||
template <typename Context> class char_converter {
|
|
||||||
private:
|
|
||||||
basic_format_arg<Context>& arg_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit char_converter(basic_format_arg<Context>& arg) : arg_(arg) {}
|
|
||||||
|
|
||||||
template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
|
|
||||||
void operator()(T value) {
|
|
||||||
arg_ = detail::make_arg<Context>(
|
|
||||||
static_cast<typename Context::char_type>(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
|
|
||||||
void operator()(T) {} // No conversion needed for non-integral types.
|
|
||||||
};
|
|
||||||
|
|
||||||
// An argument visitor that return a pointer to a C string if argument is a
|
|
||||||
// string or null otherwise.
|
|
||||||
template <typename Char> struct get_cstring {
|
|
||||||
template <typename T> const Char* operator()(T) { return nullptr; }
|
|
||||||
const Char* operator()(const Char* s) { return s; }
|
|
||||||
};
|
|
||||||
|
|
||||||
// Checks if an argument is a valid printf width specifier and sets
|
|
||||||
// left alignment if it is negative.
|
|
||||||
template <typename Char> class printf_width_handler {
|
|
||||||
private:
|
|
||||||
using format_specs = basic_format_specs<Char>;
|
|
||||||
|
|
||||||
format_specs& specs_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit printf_width_handler(format_specs& specs) : specs_(specs) {}
|
|
||||||
|
|
||||||
template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
|
|
||||||
unsigned operator()(T value) {
|
|
||||||
auto width = static_cast<uint32_or_64_or_128_t<T>>(value);
|
|
||||||
if (detail::is_negative(value)) {
|
|
||||||
specs_.align = align::left;
|
|
||||||
width = 0 - width;
|
|
||||||
}
|
|
||||||
unsigned int_max = max_value<int>();
|
|
||||||
if (width > int_max) FMT_THROW(format_error("number is too big"));
|
|
||||||
return static_cast<unsigned>(width);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
|
|
||||||
unsigned operator()(T) {
|
|
||||||
FMT_THROW(format_error("width is not integer"));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Char, typename Context>
|
|
||||||
void vprintf(buffer<Char>& buf, basic_string_view<Char> format,
|
|
||||||
basic_format_args<Context> args) {
|
|
||||||
Context(std::back_inserter(buf), format, args).format();
|
|
||||||
}
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
// For printing into memory_buffer.
|
|
||||||
template <typename Char, typename Context>
|
|
||||||
FMT_DEPRECATED void printf(detail::buffer<Char>& buf,
|
|
||||||
basic_string_view<Char> format,
|
|
||||||
basic_format_args<Context> args) {
|
|
||||||
return detail::vprintf(buf, format, args);
|
|
||||||
}
|
|
||||||
using detail::vprintf;
|
|
||||||
|
|
||||||
template <typename Char>
|
|
||||||
class basic_printf_parse_context : public basic_format_parse_context<Char> {
|
|
||||||
using basic_format_parse_context<Char>::basic_format_parse_context;
|
|
||||||
};
|
|
||||||
template <typename OutputIt, typename Char> class basic_printf_context;
|
|
||||||
|
|
||||||
/**
|
|
||||||
\rst
|
|
||||||
The ``printf`` argument formatter.
|
|
||||||
\endrst
|
|
||||||
*/
|
|
||||||
template <typename OutputIt, typename Char>
|
|
||||||
class printf_arg_formatter : public detail::arg_formatter_base<OutputIt, Char> {
|
|
||||||
public:
|
|
||||||
using iterator = OutputIt;
|
|
||||||
|
|
||||||
private:
|
|
||||||
using char_type = Char;
|
|
||||||
using base = detail::arg_formatter_base<OutputIt, Char>;
|
|
||||||
using context_type = basic_printf_context<OutputIt, Char>;
|
|
||||||
|
|
||||||
context_type& context_;
|
|
||||||
|
|
||||||
void write_null_pointer(char) {
|
|
||||||
this->specs()->type = 0;
|
|
||||||
this->write("(nil)");
|
|
||||||
}
|
|
||||||
|
|
||||||
void write_null_pointer(wchar_t) {
|
|
||||||
this->specs()->type = 0;
|
|
||||||
this->write(L"(nil)");
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
using format_specs = typename base::format_specs;
|
|
||||||
|
|
||||||
/**
|
|
||||||
\rst
|
|
||||||
Constructs an argument formatter object.
|
|
||||||
*buffer* is a reference to the output buffer and *specs* contains format
|
|
||||||
specifier information for standard argument types.
|
|
||||||
\endrst
|
|
||||||
*/
|
|
||||||
printf_arg_formatter(iterator iter, format_specs& specs, context_type& ctx)
|
|
||||||
: base(iter, &specs, detail::locale_ref()), context_(ctx) {}
|
|
||||||
|
|
||||||
template <typename T, FMT_ENABLE_IF(fmt::detail::is_integral<T>::value)>
|
|
||||||
iterator operator()(T value) {
|
|
||||||
// MSVC2013 fails to compile separate overloads for bool and char_type so
|
|
||||||
// use std::is_same instead.
|
|
||||||
if (std::is_same<T, bool>::value) {
|
|
||||||
format_specs& fmt_specs = *this->specs();
|
|
||||||
if (fmt_specs.type != 's') return base::operator()(value ? 1 : 0);
|
|
||||||
fmt_specs.type = 0;
|
|
||||||
this->write(value != 0);
|
|
||||||
} else if (std::is_same<T, char_type>::value) {
|
|
||||||
format_specs& fmt_specs = *this->specs();
|
|
||||||
if (fmt_specs.type && fmt_specs.type != 'c')
|
|
||||||
return (*this)(static_cast<int>(value));
|
|
||||||
fmt_specs.sign = sign::none;
|
|
||||||
fmt_specs.alt = false;
|
|
||||||
fmt_specs.fill[0] = ' '; // Ignore '0' flag for char types.
|
|
||||||
// align::numeric needs to be overwritten here since the '0' flag is
|
|
||||||
// ignored for non-numeric types
|
|
||||||
if (fmt_specs.align == align::none || fmt_specs.align == align::numeric)
|
|
||||||
fmt_specs.align = align::right;
|
|
||||||
return base::operator()(value);
|
|
||||||
} else {
|
|
||||||
return base::operator()(value);
|
|
||||||
}
|
|
||||||
return this->out();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, FMT_ENABLE_IF(std::is_floating_point<T>::value)>
|
|
||||||
iterator operator()(T value) {
|
|
||||||
return base::operator()(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Formats a null-terminated C string. */
|
|
||||||
iterator operator()(const char* value) {
|
|
||||||
if (value)
|
|
||||||
base::operator()(value);
|
|
||||||
else if (this->specs()->type == 'p')
|
|
||||||
write_null_pointer(char_type());
|
|
||||||
else
|
|
||||||
this->write("(null)");
|
|
||||||
return this->out();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Formats a null-terminated wide C string. */
|
|
||||||
iterator operator()(const wchar_t* value) {
|
|
||||||
if (value)
|
|
||||||
base::operator()(value);
|
|
||||||
else if (this->specs()->type == 'p')
|
|
||||||
write_null_pointer(char_type());
|
|
||||||
else
|
|
||||||
this->write(L"(null)");
|
|
||||||
return this->out();
|
|
||||||
}
|
|
||||||
|
|
||||||
iterator operator()(basic_string_view<char_type> value) {
|
|
||||||
return base::operator()(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
iterator operator()(monostate value) { return base::operator()(value); }
|
|
||||||
|
|
||||||
/** Formats a pointer. */
|
|
||||||
iterator operator()(const void* value) {
|
|
||||||
if (value) return base::operator()(value);
|
|
||||||
this->specs()->type = 0;
|
|
||||||
write_null_pointer(char_type());
|
|
||||||
return this->out();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Formats an argument of a custom (user-defined) type. */
|
|
||||||
iterator operator()(typename basic_format_arg<context_type>::handle handle) {
|
|
||||||
handle.format(context_.parse_context(), context_);
|
|
||||||
return this->out();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T> struct printf_formatter {
|
|
||||||
printf_formatter() = delete;
|
|
||||||
|
|
||||||
template <typename ParseContext>
|
|
||||||
auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
|
|
||||||
return ctx.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename FormatContext>
|
|
||||||
auto format(const T& value, FormatContext& ctx) -> decltype(ctx.out()) {
|
|
||||||
detail::format_value(detail::get_container(ctx.out()), value);
|
|
||||||
return ctx.out();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
This template formats data and writes the output through an output iterator.
|
|
||||||
*/
|
|
||||||
template <typename OutputIt, typename Char> class basic_printf_context {
|
|
||||||
public:
|
|
||||||
/** The character type for the output. */
|
|
||||||
using char_type = Char;
|
|
||||||
using iterator = OutputIt;
|
|
||||||
using format_arg = basic_format_arg<basic_printf_context>;
|
|
||||||
using parse_context_type = basic_printf_parse_context<Char>;
|
|
||||||
template <typename T> using formatter_type = printf_formatter<T>;
|
|
||||||
|
|
||||||
private:
|
|
||||||
using format_specs = basic_format_specs<char_type>;
|
|
||||||
|
|
||||||
OutputIt out_;
|
|
||||||
basic_format_args<basic_printf_context> args_;
|
|
||||||
parse_context_type parse_ctx_;
|
|
||||||
|
|
||||||
static void parse_flags(format_specs& specs, const Char*& it,
|
|
||||||
const Char* end);
|
|
||||||
|
|
||||||
// Returns the argument with specified index or, if arg_index is -1, the next
|
|
||||||
// argument.
|
|
||||||
format_arg get_arg(int arg_index = -1);
|
|
||||||
|
|
||||||
// Parses argument index, flags and width and returns the argument index.
|
|
||||||
int parse_header(const Char*& it, const Char* end, format_specs& specs);
|
|
||||||
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
\rst
|
|
||||||
Constructs a ``printf_context`` object. References to the arguments are
|
|
||||||
stored in the context object so make sure they have appropriate lifetimes.
|
|
||||||
\endrst
|
|
||||||
*/
|
|
||||||
basic_printf_context(OutputIt out, basic_string_view<char_type> format_str,
|
|
||||||
basic_format_args<basic_printf_context> args)
|
|
||||||
: out_(out), args_(args), parse_ctx_(format_str) {}
|
|
||||||
|
|
||||||
OutputIt out() { return out_; }
|
|
||||||
void advance_to(OutputIt it) { out_ = it; }
|
|
||||||
|
|
||||||
detail::locale_ref locale() { return {}; }
|
|
||||||
|
|
||||||
format_arg arg(int id) const { return args_.get(id); }
|
|
||||||
|
|
||||||
parse_context_type& parse_context() { return parse_ctx_; }
|
|
||||||
|
|
||||||
FMT_CONSTEXPR void on_error(const char* message) {
|
|
||||||
parse_ctx_.on_error(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Formats stored arguments and writes the output to the range. */
|
|
||||||
template <typename ArgFormatter = printf_arg_formatter<OutputIt, Char>>
|
|
||||||
OutputIt format();
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename OutputIt, typename Char>
|
|
||||||
void basic_printf_context<OutputIt, Char>::parse_flags(format_specs& specs,
|
|
||||||
const Char*& it,
|
|
||||||
const Char* end) {
|
|
||||||
for (; it != end; ++it) {
|
|
||||||
switch (*it) {
|
|
||||||
case '-':
|
|
||||||
specs.align = align::left;
|
|
||||||
break;
|
|
||||||
case '+':
|
|
||||||
specs.sign = sign::plus;
|
|
||||||
break;
|
|
||||||
case '0':
|
|
||||||
specs.fill[0] = '0';
|
|
||||||
break;
|
|
||||||
case ' ':
|
|
||||||
if (specs.sign != sign::plus) {
|
|
||||||
specs.sign = sign::space;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '#':
|
|
||||||
specs.alt = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename OutputIt, typename Char>
|
|
||||||
typename basic_printf_context<OutputIt, Char>::format_arg
|
|
||||||
basic_printf_context<OutputIt, Char>::get_arg(int arg_index) {
|
|
||||||
if (arg_index < 0)
|
|
||||||
arg_index = parse_ctx_.next_arg_id();
|
|
||||||
else
|
|
||||||
parse_ctx_.check_arg_id(--arg_index);
|
|
||||||
return detail::get_arg(*this, arg_index);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename OutputIt, typename Char>
|
|
||||||
int basic_printf_context<OutputIt, Char>::parse_header(const Char*& it,
|
|
||||||
const Char* end,
|
|
||||||
format_specs& specs) {
|
|
||||||
int arg_index = -1;
|
|
||||||
char_type c = *it;
|
|
||||||
if (c >= '0' && c <= '9') {
|
|
||||||
// Parse an argument index (if followed by '$') or a width possibly
|
|
||||||
// preceded with '0' flag(s).
|
|
||||||
detail::error_handler eh;
|
|
||||||
int value = parse_nonnegative_int(it, end, eh);
|
|
||||||
if (it != end && *it == '$') { // value is an argument index
|
|
||||||
++it;
|
|
||||||
arg_index = value;
|
|
||||||
} else {
|
|
||||||
if (c == '0') specs.fill[0] = '0';
|
|
||||||
if (value != 0) {
|
|
||||||
// Nonzero value means that we parsed width and don't need to
|
|
||||||
// parse it or flags again, so return now.
|
|
||||||
specs.width = value;
|
|
||||||
return arg_index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
parse_flags(specs, it, end);
|
|
||||||
// Parse width.
|
|
||||||
if (it != end) {
|
|
||||||
if (*it >= '0' && *it <= '9') {
|
|
||||||
detail::error_handler eh;
|
|
||||||
specs.width = parse_nonnegative_int(it, end, eh);
|
|
||||||
} else if (*it == '*') {
|
|
||||||
++it;
|
|
||||||
specs.width = static_cast<int>(visit_format_arg(
|
|
||||||
detail::printf_width_handler<char_type>(specs), get_arg()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return arg_index;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename OutputIt, typename Char>
|
|
||||||
template <typename ArgFormatter>
|
|
||||||
OutputIt basic_printf_context<OutputIt, Char>::format() {
|
|
||||||
auto out = this->out();
|
|
||||||
const Char* start = parse_ctx_.begin();
|
|
||||||
const Char* end = parse_ctx_.end();
|
|
||||||
auto it = start;
|
|
||||||
while (it != end) {
|
|
||||||
char_type c = *it++;
|
|
||||||
if (c != '%') continue;
|
|
||||||
if (it != end && *it == c) {
|
|
||||||
out = std::copy(start, it, out);
|
|
||||||
start = ++it;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
out = std::copy(start, it - 1, out);
|
|
||||||
|
|
||||||
format_specs specs;
|
|
||||||
specs.align = align::right;
|
|
||||||
|
|
||||||
// Parse argument index, flags and width.
|
|
||||||
int arg_index = parse_header(it, end, specs);
|
|
||||||
if (arg_index == 0) on_error("argument not found");
|
|
||||||
|
|
||||||
// Parse precision.
|
|
||||||
if (it != end && *it == '.') {
|
|
||||||
++it;
|
|
||||||
c = it != end ? *it : 0;
|
|
||||||
if ('0' <= c && c <= '9') {
|
|
||||||
detail::error_handler eh;
|
|
||||||
specs.precision = parse_nonnegative_int(it, end, eh);
|
|
||||||
} else if (c == '*') {
|
|
||||||
++it;
|
|
||||||
specs.precision = static_cast<int>(
|
|
||||||
visit_format_arg(detail::printf_precision_handler(), get_arg()));
|
|
||||||
} else {
|
|
||||||
specs.precision = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
format_arg arg = get_arg(arg_index);
|
|
||||||
// For d, i, o, u, x, and X conversion specifiers, if a precision is
|
|
||||||
// specified, the '0' flag is ignored
|
|
||||||
if (specs.precision >= 0 && arg.is_integral())
|
|
||||||
specs.fill[0] =
|
|
||||||
' '; // Ignore '0' flag for non-numeric types or if '-' present.
|
|
||||||
if (specs.precision >= 0 && arg.type() == detail::type::cstring_type) {
|
|
||||||
auto str = visit_format_arg(detail::get_cstring<Char>(), arg);
|
|
||||||
auto str_end = str + specs.precision;
|
|
||||||
auto nul = std::find(str, str_end, Char());
|
|
||||||
arg = detail::make_arg<basic_printf_context>(basic_string_view<Char>(
|
|
||||||
str,
|
|
||||||
detail::to_unsigned(nul != str_end ? nul - str : specs.precision)));
|
|
||||||
}
|
|
||||||
if (specs.alt && visit_format_arg(detail::is_zero_int(), arg))
|
|
||||||
specs.alt = false;
|
|
||||||
if (specs.fill[0] == '0') {
|
|
||||||
if (arg.is_arithmetic() && specs.align != align::left)
|
|
||||||
specs.align = align::numeric;
|
|
||||||
else
|
|
||||||
specs.fill[0] = ' '; // Ignore '0' flag for non-numeric types or if '-'
|
|
||||||
// flag is also present.
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse length and convert the argument to the required type.
|
|
||||||
c = it != end ? *it++ : 0;
|
|
||||||
char_type t = it != end ? *it : 0;
|
|
||||||
using detail::convert_arg;
|
|
||||||
switch (c) {
|
|
||||||
case 'h':
|
|
||||||
if (t == 'h') {
|
|
||||||
++it;
|
|
||||||
t = it != end ? *it : 0;
|
|
||||||
convert_arg<signed char>(arg, t);
|
|
||||||
} else {
|
|
||||||
convert_arg<short>(arg, t);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'l':
|
|
||||||
if (t == 'l') {
|
|
||||||
++it;
|
|
||||||
t = it != end ? *it : 0;
|
|
||||||
convert_arg<long long>(arg, t);
|
|
||||||
} else {
|
|
||||||
convert_arg<long>(arg, t);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'j':
|
|
||||||
convert_arg<intmax_t>(arg, t);
|
|
||||||
break;
|
|
||||||
case 'z':
|
|
||||||
convert_arg<size_t>(arg, t);
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
convert_arg<std::ptrdiff_t>(arg, t);
|
|
||||||
break;
|
|
||||||
case 'L':
|
|
||||||
// printf produces garbage when 'L' is omitted for long double, no
|
|
||||||
// need to do the same.
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
--it;
|
|
||||||
convert_arg<void>(arg, c);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse type.
|
|
||||||
if (it == end) FMT_THROW(format_error("invalid format string"));
|
|
||||||
specs.type = static_cast<char>(*it++);
|
|
||||||
if (arg.is_integral()) {
|
|
||||||
// Normalize type.
|
|
||||||
switch (specs.type) {
|
|
||||||
case 'i':
|
|
||||||
case 'u':
|
|
||||||
specs.type = 'd';
|
|
||||||
break;
|
|
||||||
case 'c':
|
|
||||||
visit_format_arg(detail::char_converter<basic_printf_context>(arg),
|
|
||||||
arg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
start = it;
|
|
||||||
|
|
||||||
// Format argument.
|
|
||||||
out = visit_format_arg(ArgFormatter(out, specs, *this), arg);
|
|
||||||
}
|
|
||||||
return std::copy(start, it, out);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Char>
|
|
||||||
using basic_printf_context_t =
|
|
||||||
basic_printf_context<std::back_insert_iterator<detail::buffer<Char>>, Char>;
|
|
||||||
|
|
||||||
using printf_context = basic_printf_context_t<char>;
|
|
||||||
using wprintf_context = basic_printf_context_t<wchar_t>;
|
|
||||||
|
|
||||||
using printf_args = basic_format_args<printf_context>;
|
|
||||||
using wprintf_args = basic_format_args<wprintf_context>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
\rst
|
|
||||||
Constructs an `~fmt::format_arg_store` object that contains references to
|
|
||||||
arguments and can be implicitly converted to `~fmt::printf_args`.
|
|
||||||
\endrst
|
|
||||||
*/
|
|
||||||
template <typename... Args>
|
|
||||||
inline format_arg_store<printf_context, Args...> make_printf_args(
|
|
||||||
const Args&... args) {
|
|
||||||
return {args...};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
\rst
|
|
||||||
Constructs an `~fmt::format_arg_store` object that contains references to
|
|
||||||
arguments and can be implicitly converted to `~fmt::wprintf_args`.
|
|
||||||
\endrst
|
|
||||||
*/
|
|
||||||
template <typename... Args>
|
|
||||||
inline format_arg_store<wprintf_context, Args...> make_wprintf_args(
|
|
||||||
const Args&... args) {
|
|
||||||
return {args...};
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename S, typename Char = char_t<S>>
|
|
||||||
inline std::basic_string<Char> vsprintf(
|
|
||||||
const S& format,
|
|
||||||
basic_format_args<basic_printf_context_t<type_identity_t<Char>>> args) {
|
|
||||||
basic_memory_buffer<Char> buffer;
|
|
||||||
vprintf(buffer, to_string_view(format), args);
|
|
||||||
return to_string(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
\rst
|
|
||||||
Formats arguments and returns the result as a string.
|
|
||||||
|
|
||||||
**Example**::
|
|
||||||
|
|
||||||
std::string message = fmt::sprintf("The answer is %d", 42);
|
|
||||||
\endrst
|
|
||||||
*/
|
|
||||||
template <typename S, typename... Args,
|
|
||||||
typename Char = enable_if_t<detail::is_string<S>::value, char_t<S>>>
|
|
||||||
inline std::basic_string<Char> sprintf(const S& format, const Args&... args) {
|
|
||||||
using context = basic_printf_context_t<Char>;
|
|
||||||
return vsprintf(to_string_view(format), make_format_args<context>(args...));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename S, typename Char = char_t<S>>
|
|
||||||
inline int vfprintf(
|
|
||||||
std::FILE* f, const S& format,
|
|
||||||
basic_format_args<basic_printf_context_t<type_identity_t<Char>>> args) {
|
|
||||||
basic_memory_buffer<Char> buffer;
|
|
||||||
vprintf(buffer, to_string_view(format), args);
|
|
||||||
size_t size = buffer.size();
|
|
||||||
return std::fwrite(buffer.data(), sizeof(Char), size, f) < size
|
|
||||||
? -1
|
|
||||||
: static_cast<int>(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
\rst
|
|
||||||
Prints formatted data to the file *f*.
|
|
||||||
|
|
||||||
**Example**::
|
|
||||||
|
|
||||||
fmt::fprintf(stderr, "Don't %s!", "panic");
|
|
||||||
\endrst
|
|
||||||
*/
|
|
||||||
template <typename S, typename... Args,
|
|
||||||
typename Char = enable_if_t<detail::is_string<S>::value, char_t<S>>>
|
|
||||||
inline int fprintf(std::FILE* f, const S& format, const Args&... args) {
|
|
||||||
using context = basic_printf_context_t<Char>;
|
|
||||||
return vfprintf(f, to_string_view(format),
|
|
||||||
make_format_args<context>(args...));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename S, typename Char = char_t<S>>
|
|
||||||
inline int vprintf(
|
|
||||||
const S& format,
|
|
||||||
basic_format_args<basic_printf_context_t<type_identity_t<Char>>> args) {
|
|
||||||
return vfprintf(stdout, to_string_view(format), args);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
\rst
|
|
||||||
Prints formatted data to ``stdout``.
|
|
||||||
|
|
||||||
**Example**::
|
|
||||||
|
|
||||||
fmt::printf("Elapsed time: %.2f seconds", 1.23);
|
|
||||||
\endrst
|
|
||||||
*/
|
|
||||||
template <typename S, typename... Args,
|
|
||||||
FMT_ENABLE_IF(detail::is_string<S>::value)>
|
|
||||||
inline int printf(const S& format_str, const Args&... args) {
|
|
||||||
using context = basic_printf_context_t<char_t<S>>;
|
|
||||||
return vprintf(to_string_view(format_str),
|
|
||||||
make_format_args<context>(args...));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename S, typename Char = char_t<S>>
|
|
||||||
inline int vfprintf(
|
|
||||||
std::basic_ostream<Char>& os, const S& format,
|
|
||||||
basic_format_args<basic_printf_context_t<type_identity_t<Char>>> args) {
|
|
||||||
basic_memory_buffer<Char> buffer;
|
|
||||||
vprintf(buffer, to_string_view(format), args);
|
|
||||||
detail::write_buffer(os, buffer);
|
|
||||||
return static_cast<int>(buffer.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Formats arguments and writes the output to the range. */
|
|
||||||
template <typename ArgFormatter, typename Char,
|
|
||||||
typename Context =
|
|
||||||
basic_printf_context<typename ArgFormatter::iterator, Char>>
|
|
||||||
typename ArgFormatter::iterator vprintf(
|
|
||||||
detail::buffer<Char>& out, basic_string_view<Char> format_str,
|
|
||||||
basic_format_args<type_identity_t<Context>> args) {
|
|
||||||
typename ArgFormatter::iterator iter(out);
|
|
||||||
Context(iter, format_str, args).template format<ArgFormatter>();
|
|
||||||
return iter;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
\rst
|
|
||||||
Prints formatted data to the stream *os*.
|
|
||||||
|
|
||||||
**Example**::
|
|
||||||
|
|
||||||
fmt::fprintf(cerr, "Don't %s!", "panic");
|
|
||||||
\endrst
|
|
||||||
*/
|
|
||||||
template <typename S, typename... Args, typename Char = char_t<S>>
|
|
||||||
inline int fprintf(std::basic_ostream<Char>& os, const S& format_str,
|
|
||||||
const Args&... args) {
|
|
||||||
using context = basic_printf_context_t<Char>;
|
|
||||||
return vfprintf(os, to_string_view(format_str),
|
|
||||||
make_format_args<context>(args...));
|
|
||||||
}
|
|
||||||
FMT_END_NAMESPACE
|
|
||||||
|
|
||||||
#endif // FMT_PRINTF_H_
|
|
||||||
386
external/fmtlib/include/fmt/ranges.h
vendored
386
external/fmtlib/include/fmt/ranges.h
vendored
@@ -1,386 +0,0 @@
|
|||||||
// Formatting library for C++ - experimental range support
|
|
||||||
//
|
|
||||||
// Copyright (c) 2012 - present, Victor Zverovich
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// For the license information refer to format.h.
|
|
||||||
//
|
|
||||||
// Copyright (c) 2018 - present, Remotion (Igor Schulz)
|
|
||||||
// All Rights Reserved
|
|
||||||
// {fmt} support for ranges, containers and types tuple interface.
|
|
||||||
|
|
||||||
#ifndef FMT_RANGES_H_
|
|
||||||
#define FMT_RANGES_H_
|
|
||||||
|
|
||||||
#include <initializer_list>
|
|
||||||
#include <type_traits>
|
|
||||||
|
|
||||||
#include "format.h"
|
|
||||||
|
|
||||||
// output only up to N items from the range.
|
|
||||||
#ifndef FMT_RANGE_OUTPUT_LENGTH_LIMIT
|
|
||||||
# define FMT_RANGE_OUTPUT_LENGTH_LIMIT 256
|
|
||||||
#endif
|
|
||||||
|
|
||||||
FMT_BEGIN_NAMESPACE
|
|
||||||
|
|
||||||
template <typename Char> struct formatting_base {
|
|
||||||
template <typename ParseContext>
|
|
||||||
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
|
|
||||||
return ctx.begin();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Char, typename Enable = void>
|
|
||||||
struct formatting_range : formatting_base<Char> {
|
|
||||||
static FMT_CONSTEXPR_DECL const size_t range_length_limit =
|
|
||||||
FMT_RANGE_OUTPUT_LENGTH_LIMIT; // output only up to N items from the
|
|
||||||
// range.
|
|
||||||
Char prefix;
|
|
||||||
Char delimiter;
|
|
||||||
Char postfix;
|
|
||||||
formatting_range() : prefix('{'), delimiter(','), postfix('}') {}
|
|
||||||
static FMT_CONSTEXPR_DECL const bool add_delimiter_spaces = true;
|
|
||||||
static FMT_CONSTEXPR_DECL const bool add_prepostfix_space = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Char, typename Enable = void>
|
|
||||||
struct formatting_tuple : formatting_base<Char> {
|
|
||||||
Char prefix;
|
|
||||||
Char delimiter;
|
|
||||||
Char postfix;
|
|
||||||
formatting_tuple() : prefix('('), delimiter(','), postfix(')') {}
|
|
||||||
static FMT_CONSTEXPR_DECL const bool add_delimiter_spaces = true;
|
|
||||||
static FMT_CONSTEXPR_DECL const bool add_prepostfix_space = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
template <typename RangeT, typename OutputIterator>
|
|
||||||
OutputIterator copy(const RangeT& range, OutputIterator out) {
|
|
||||||
for (auto it = range.begin(), end = range.end(); it != end; ++it)
|
|
||||||
*out++ = *it;
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename OutputIterator>
|
|
||||||
OutputIterator copy(const char* str, OutputIterator out) {
|
|
||||||
while (*str) *out++ = *str++;
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename OutputIterator>
|
|
||||||
OutputIterator copy(char ch, OutputIterator out) {
|
|
||||||
*out++ = ch;
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return true value if T has std::string interface, like std::string_view.
|
|
||||||
template <typename T> class is_like_std_string {
|
|
||||||
template <typename U>
|
|
||||||
static auto check(U* p)
|
|
||||||
-> decltype((void)p->find('a'), p->length(), (void)p->data(), int());
|
|
||||||
template <typename> static void check(...);
|
|
||||||
|
|
||||||
public:
|
|
||||||
static FMT_CONSTEXPR_DECL const bool value =
|
|
||||||
is_string<T>::value || !std::is_void<decltype(check<T>(nullptr))>::value;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Char>
|
|
||||||
struct is_like_std_string<fmt::basic_string_view<Char>> : std::true_type {};
|
|
||||||
|
|
||||||
template <typename... Ts> struct conditional_helper {};
|
|
||||||
|
|
||||||
template <typename T, typename _ = void> struct is_range_ : std::false_type {};
|
|
||||||
|
|
||||||
#if !FMT_MSC_VER || FMT_MSC_VER > 1800
|
|
||||||
template <typename T>
|
|
||||||
struct is_range_<
|
|
||||||
T, conditional_t<false,
|
|
||||||
conditional_helper<decltype(std::declval<T>().begin()),
|
|
||||||
decltype(std::declval<T>().end())>,
|
|
||||||
void>> : std::true_type {};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// tuple_size and tuple_element check.
|
|
||||||
template <typename T> class is_tuple_like_ {
|
|
||||||
template <typename U>
|
|
||||||
static auto check(U* p) -> decltype(std::tuple_size<U>::value, int());
|
|
||||||
template <typename> static void check(...);
|
|
||||||
|
|
||||||
public:
|
|
||||||
static FMT_CONSTEXPR_DECL const bool value =
|
|
||||||
!std::is_void<decltype(check<T>(nullptr))>::value;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Check for integer_sequence
|
|
||||||
#if defined(__cpp_lib_integer_sequence) || FMT_MSC_VER >= 1900
|
|
||||||
template <typename T, T... N>
|
|
||||||
using integer_sequence = std::integer_sequence<T, N...>;
|
|
||||||
template <size_t... N> using index_sequence = std::index_sequence<N...>;
|
|
||||||
template <size_t N> using make_index_sequence = std::make_index_sequence<N>;
|
|
||||||
#else
|
|
||||||
template <typename T, T... N> struct integer_sequence {
|
|
||||||
using value_type = T;
|
|
||||||
|
|
||||||
static FMT_CONSTEXPR size_t size() { return sizeof...(N); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <size_t... N> using index_sequence = integer_sequence<size_t, N...>;
|
|
||||||
|
|
||||||
template <typename T, size_t N, T... Ns>
|
|
||||||
struct make_integer_sequence : make_integer_sequence<T, N - 1, N - 1, Ns...> {};
|
|
||||||
template <typename T, T... Ns>
|
|
||||||
struct make_integer_sequence<T, 0, Ns...> : integer_sequence<T, Ns...> {};
|
|
||||||
|
|
||||||
template <size_t N>
|
|
||||||
using make_index_sequence = make_integer_sequence<size_t, N>;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template <class Tuple, class F, size_t... Is>
|
|
||||||
void for_each(index_sequence<Is...>, Tuple&& tup, F&& f) FMT_NOEXCEPT {
|
|
||||||
using std::get;
|
|
||||||
// using free function get<I>(T) now.
|
|
||||||
const int _[] = {0, ((void)f(get<Is>(tup)), 0)...};
|
|
||||||
(void)_; // blocks warnings
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
FMT_CONSTEXPR make_index_sequence<std::tuple_size<T>::value> get_indexes(
|
|
||||||
T const&) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Tuple, class F> void for_each(Tuple&& tup, F&& f) {
|
|
||||||
const auto indexes = get_indexes(tup);
|
|
||||||
for_each(indexes, std::forward<Tuple>(tup), std::forward<F>(f));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Arg, FMT_ENABLE_IF(!is_like_std_string<
|
|
||||||
typename std::decay<Arg>::type>::value)>
|
|
||||||
FMT_CONSTEXPR const char* format_str_quoted(bool add_space, const Arg&) {
|
|
||||||
return add_space ? " {}" : "{}";
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Arg, FMT_ENABLE_IF(is_like_std_string<
|
|
||||||
typename std::decay<Arg>::type>::value)>
|
|
||||||
FMT_CONSTEXPR const char* format_str_quoted(bool add_space, const Arg&) {
|
|
||||||
return add_space ? " \"{}\"" : "\"{}\"";
|
|
||||||
}
|
|
||||||
|
|
||||||
FMT_CONSTEXPR const char* format_str_quoted(bool add_space, const char*) {
|
|
||||||
return add_space ? " \"{}\"" : "\"{}\"";
|
|
||||||
}
|
|
||||||
FMT_CONSTEXPR const wchar_t* format_str_quoted(bool add_space, const wchar_t*) {
|
|
||||||
return add_space ? L" \"{}\"" : L"\"{}\"";
|
|
||||||
}
|
|
||||||
|
|
||||||
FMT_CONSTEXPR const char* format_str_quoted(bool add_space, const char) {
|
|
||||||
return add_space ? " '{}'" : "'{}'";
|
|
||||||
}
|
|
||||||
FMT_CONSTEXPR const wchar_t* format_str_quoted(bool add_space, const wchar_t) {
|
|
||||||
return add_space ? L" '{}'" : L"'{}'";
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
template <typename T> struct is_tuple_like {
|
|
||||||
static FMT_CONSTEXPR_DECL const bool value =
|
|
||||||
detail::is_tuple_like_<T>::value && !detail::is_range_<T>::value;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename TupleT, typename Char>
|
|
||||||
struct formatter<TupleT, Char, enable_if_t<fmt::is_tuple_like<TupleT>::value>> {
|
|
||||||
private:
|
|
||||||
// C++11 generic lambda for format()
|
|
||||||
template <typename FormatContext> struct format_each {
|
|
||||||
template <typename T> void operator()(const T& v) {
|
|
||||||
if (i > 0) {
|
|
||||||
if (formatting.add_prepostfix_space) {
|
|
||||||
*out++ = ' ';
|
|
||||||
}
|
|
||||||
out = detail::copy(formatting.delimiter, out);
|
|
||||||
}
|
|
||||||
out = format_to(out,
|
|
||||||
detail::format_str_quoted(
|
|
||||||
(formatting.add_delimiter_spaces && i > 0), v),
|
|
||||||
v);
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
|
|
||||||
formatting_tuple<Char>& formatting;
|
|
||||||
size_t& i;
|
|
||||||
typename std::add_lvalue_reference<decltype(
|
|
||||||
std::declval<FormatContext>().out())>::type out;
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
formatting_tuple<Char> formatting;
|
|
||||||
|
|
||||||
template <typename ParseContext>
|
|
||||||
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
|
|
||||||
return formatting.parse(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename FormatContext = format_context>
|
|
||||||
auto format(const TupleT& values, FormatContext& ctx) -> decltype(ctx.out()) {
|
|
||||||
auto out = ctx.out();
|
|
||||||
size_t i = 0;
|
|
||||||
detail::copy(formatting.prefix, out);
|
|
||||||
|
|
||||||
detail::for_each(values, format_each<FormatContext>{formatting, i, out});
|
|
||||||
if (formatting.add_prepostfix_space) {
|
|
||||||
*out++ = ' ';
|
|
||||||
}
|
|
||||||
detail::copy(formatting.postfix, out);
|
|
||||||
|
|
||||||
return ctx.out();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T, typename Char> struct is_range {
|
|
||||||
static FMT_CONSTEXPR_DECL const bool value =
|
|
||||||
detail::is_range_<T>::value && !detail::is_like_std_string<T>::value &&
|
|
||||||
!std::is_convertible<T, std::basic_string<Char>>::value &&
|
|
||||||
!std::is_constructible<detail::std_string_view<Char>, T>::value;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename RangeT, typename Char>
|
|
||||||
struct formatter<RangeT, Char,
|
|
||||||
enable_if_t<fmt::is_range<RangeT, Char>::value>> {
|
|
||||||
formatting_range<Char> formatting;
|
|
||||||
|
|
||||||
template <typename ParseContext>
|
|
||||||
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
|
|
||||||
return formatting.parse(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename FormatContext>
|
|
||||||
typename FormatContext::iterator format(const RangeT& values,
|
|
||||||
FormatContext& ctx) {
|
|
||||||
auto out = detail::copy(formatting.prefix, ctx.out());
|
|
||||||
size_t i = 0;
|
|
||||||
auto it = values.begin();
|
|
||||||
auto end = values.end();
|
|
||||||
for (; it != end; ++it) {
|
|
||||||
if (i > 0) {
|
|
||||||
if (formatting.add_prepostfix_space) *out++ = ' ';
|
|
||||||
out = detail::copy(formatting.delimiter, out);
|
|
||||||
}
|
|
||||||
out = format_to(out,
|
|
||||||
detail::format_str_quoted(
|
|
||||||
(formatting.add_delimiter_spaces && i > 0), *it),
|
|
||||||
*it);
|
|
||||||
if (++i > formatting.range_length_limit) {
|
|
||||||
out = format_to(out, " ... <other elements>");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (formatting.add_prepostfix_space) *out++ = ' ';
|
|
||||||
return detail::copy(formatting.postfix, out);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Char, typename... T> struct tuple_arg_join : detail::view {
|
|
||||||
const std::tuple<T...>& tuple;
|
|
||||||
basic_string_view<Char> sep;
|
|
||||||
|
|
||||||
tuple_arg_join(const std::tuple<T...>& t, basic_string_view<Char> s)
|
|
||||||
: tuple{t}, sep{s} {}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Char, typename... T>
|
|
||||||
struct formatter<tuple_arg_join<Char, T...>, Char> {
|
|
||||||
template <typename ParseContext>
|
|
||||||
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
|
|
||||||
return ctx.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename FormatContext>
|
|
||||||
typename FormatContext::iterator format(
|
|
||||||
const tuple_arg_join<Char, T...>& value, FormatContext& ctx) {
|
|
||||||
return format(value, ctx, detail::make_index_sequence<sizeof...(T)>{});
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
template <typename FormatContext, size_t... N>
|
|
||||||
typename FormatContext::iterator format(
|
|
||||||
const tuple_arg_join<Char, T...>& value, FormatContext& ctx,
|
|
||||||
detail::index_sequence<N...>) {
|
|
||||||
return format_args(value, ctx, std::get<N>(value.tuple)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename FormatContext>
|
|
||||||
typename FormatContext::iterator format_args(
|
|
||||||
const tuple_arg_join<Char, T...>&, FormatContext& ctx) {
|
|
||||||
// NOTE: for compilers that support C++17, this empty function instantiation
|
|
||||||
// can be replaced with a constexpr branch in the variadic overload.
|
|
||||||
return ctx.out();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename FormatContext, typename Arg, typename... Args>
|
|
||||||
typename FormatContext::iterator format_args(
|
|
||||||
const tuple_arg_join<Char, T...>& value, FormatContext& ctx,
|
|
||||||
const Arg& arg, const Args&... args) {
|
|
||||||
using base = formatter<typename std::decay<Arg>::type, Char>;
|
|
||||||
auto out = ctx.out();
|
|
||||||
out = base{}.format(arg, ctx);
|
|
||||||
if (sizeof...(Args) > 0) {
|
|
||||||
out = std::copy(value.sep.begin(), value.sep.end(), out);
|
|
||||||
ctx.advance_to(out);
|
|
||||||
return format_args(value, ctx, args...);
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
\rst
|
|
||||||
Returns an object that formats `tuple` with elements separated by `sep`.
|
|
||||||
|
|
||||||
**Example**::
|
|
||||||
|
|
||||||
std::tuple<int, char> t = {1, 'a'};
|
|
||||||
fmt::print("{}", fmt::join(t, ", "));
|
|
||||||
// Output: "1, a"
|
|
||||||
\endrst
|
|
||||||
*/
|
|
||||||
template <typename... T>
|
|
||||||
FMT_CONSTEXPR tuple_arg_join<char, T...> join(const std::tuple<T...>& tuple,
|
|
||||||
string_view sep) {
|
|
||||||
return {tuple, sep};
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename... T>
|
|
||||||
FMT_CONSTEXPR tuple_arg_join<wchar_t, T...> join(const std::tuple<T...>& tuple,
|
|
||||||
wstring_view sep) {
|
|
||||||
return {tuple, sep};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
\rst
|
|
||||||
Returns an object that formats `initializer_list` with elements separated by
|
|
||||||
`sep`.
|
|
||||||
|
|
||||||
**Example**::
|
|
||||||
|
|
||||||
fmt::print("{}", fmt::join({1, 2, 3}, ", "));
|
|
||||||
// Output: "1, 2, 3"
|
|
||||||
\endrst
|
|
||||||
*/
|
|
||||||
template <typename T>
|
|
||||||
arg_join<const T*, const T*, char> join(std::initializer_list<T> list,
|
|
||||||
string_view sep) {
|
|
||||||
return join(std::begin(list), std::end(list), sep);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
arg_join<const T*, const T*, wchar_t> join(std::initializer_list<T> list,
|
|
||||||
wstring_view sep) {
|
|
||||||
return join(std::begin(list), std::end(list), sep);
|
|
||||||
}
|
|
||||||
|
|
||||||
FMT_END_NAMESPACE
|
|
||||||
|
|
||||||
#endif // FMT_RANGES_H_
|
|
||||||
@@ -14,8 +14,6 @@
|
|||||||
|
|
||||||
#include <opm/output/data/Solution.hpp>
|
#include <opm/output/data/Solution.hpp>
|
||||||
#include <opm/output/data/Wells.hpp>
|
#include <opm/output/data/Wells.hpp>
|
||||||
#include <opm/output/data/Groups.hpp>
|
|
||||||
#include <opm/parser/eclipse/Deck/UDAValue.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
@@ -25,12 +23,6 @@ class ParseContext;
|
|||||||
class Parser;
|
class Parser;
|
||||||
class Python;
|
class Python;
|
||||||
class SummaryState;
|
class SummaryState;
|
||||||
class UDQState;
|
|
||||||
|
|
||||||
namespace Action {
|
|
||||||
class State;
|
|
||||||
}
|
|
||||||
|
|
||||||
class msim {
|
class msim {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -39,18 +31,16 @@ public:
|
|||||||
|
|
||||||
msim(const EclipseState& state);
|
msim(const EclipseState& state);
|
||||||
|
|
||||||
Opm::UDAValue uda_val();
|
|
||||||
|
|
||||||
void well_rate(const std::string& well, data::Rates::opt rate, std::function<well_rate_function> func);
|
void well_rate(const std::string& well, data::Rates::opt rate, std::function<well_rate_function> func);
|
||||||
void solution(const std::string& field, std::function<solution_function> func);
|
void solution(const std::string& field, std::function<solution_function> func);
|
||||||
void run(Schedule& schedule, EclipseIO& io, bool report_only);
|
void run(Schedule& schedule, EclipseIO& io, bool report_only);
|
||||||
void post_step(Schedule& schedule, Action::State& action_state, SummaryState& st, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& group_nwrk_data, size_t report_step);
|
void post_step(Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void run_step(const Schedule& schedule, Action::State& action_state, SummaryState& st, UDQState& udq_state, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& group_nwrk_data, size_t report_step, EclipseIO& io) const;
|
void run_step(const Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, EclipseIO& io) const;
|
||||||
void run_step(const Schedule& schedule, Action::State& action_state, SummaryState& st, UDQState& udq_state, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& group_nwrk_data, size_t report_step, double dt, EclipseIO& io) const;
|
void run_step(const Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, double dt, EclipseIO& io) const;
|
||||||
void output(Action::State& action_state, SummaryState& st, const UDQState& udq_state, size_t report_step, bool substep, double seconds_elapsed, const data::Solution& sol, const data::Wells& well_data, const data::GroupAndNetworkValues& group_data, EclipseIO& io) const;
|
void output(SummaryState& st, size_t report_step, bool substep, double seconds_elapsed, const data::Solution& sol, const data::Wells& well_data, EclipseIO& io) const;
|
||||||
void simulate(const Schedule& schedule, const SummaryState& st, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& group_nwrk_data, size_t report_step, double seconds_elapsed, double time_step) const;
|
void simulate(const Schedule& schedule, const SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, double seconds_elapsed, double time_step) const;
|
||||||
|
|
||||||
EclipseState state;
|
EclipseState state;
|
||||||
std::map<std::string, std::map<data::Rates::opt, std::function<well_rate_function>>> well_rates;
|
std::map<std::string, std::map<data::Rates::opt, std::function<well_rate_function>>> well_rates;
|
||||||
|
|||||||
@@ -29,9 +29,6 @@
|
|||||||
|
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionContext.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionContext.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
|
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQState.hpp>
|
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.hpp>
|
|
||||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||||
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
|
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
|
||||||
@@ -47,42 +44,35 @@ void msim::run(Schedule& schedule, EclipseIO& io, bool report_only) {
|
|||||||
const double week = 7 * 86400;
|
const double week = 7 * 86400;
|
||||||
data::Solution sol;
|
data::Solution sol;
|
||||||
SummaryState st(std::chrono::system_clock::from_time_t(schedule.getStartTime()));
|
SummaryState st(std::chrono::system_clock::from_time_t(schedule.getStartTime()));
|
||||||
UDQState udq_state(schedule.getUDQConfig(0).params().undefinedValue());
|
|
||||||
Action::State action_state;
|
|
||||||
Python python;
|
Python python;
|
||||||
|
|
||||||
io.writeInitial();
|
io.writeInitial();
|
||||||
for (size_t report_step = 1; report_step < schedule.size(); report_step++) {
|
for (size_t report_step = 1; report_step < schedule.size(); report_step++) {
|
||||||
data::Wells well_data;
|
data::Wells well_data;
|
||||||
data::GroupAndNetworkValues group_nwrk_data;
|
|
||||||
if (report_only)
|
if (report_only)
|
||||||
run_step(schedule, action_state, st, udq_state, sol, well_data, group_nwrk_data, report_step, io);
|
run_step(schedule, st, sol, well_data, report_step, io);
|
||||||
else {
|
else {
|
||||||
double time_step = std::min(week, 0.5*schedule.stepLength(report_step - 1));
|
double time_step = std::min(week, 0.5*schedule.stepLength(report_step - 1));
|
||||||
run_step(schedule, action_state, st, udq_state, sol, well_data, group_nwrk_data, report_step, time_step, io);
|
run_step(schedule, st, sol, well_data, report_step, time_step, io);
|
||||||
}
|
}
|
||||||
post_step(schedule, action_state, st, sol, well_data, group_nwrk_data, report_step);
|
post_step(schedule, st, sol, well_data, report_step);
|
||||||
const auto& exit_status = schedule.exitStatus();
|
const auto& exit_status = schedule.exitStatus();
|
||||||
if (exit_status.has_value())
|
if (exit_status.has_value())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UDAValue msim::uda_val() {
|
|
||||||
return UDAValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void msim::post_step(Schedule& schedule, SummaryState& st, data::Solution& /* sol */, data::Wells& /* well_data */, size_t report_step) {
|
||||||
void msim::post_step(Schedule& schedule, Action::State& action_state, SummaryState& st, data::Solution& /* sol */, data::Wells& /* well_data */, data::GroupAndNetworkValues& /* grp_nwrk_data */, size_t report_step) {
|
|
||||||
const auto& actions = schedule.actions(report_step);
|
const auto& actions = schedule.actions(report_step);
|
||||||
if (actions.empty())
|
if (actions.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Action::Context context( st , schedule.getWListManager(report_step));
|
Action::Context context( st );
|
||||||
|
|
||||||
auto sim_time = schedule.simTime(report_step);
|
auto sim_time = schedule.simTime(report_step);
|
||||||
for (const auto& action : actions.pending(action_state, sim_time)) {
|
for (const auto& action : actions.pending(sim_time)) {
|
||||||
auto result = action->eval(context);
|
auto result = action->eval(sim_time, context);
|
||||||
if (result)
|
if (result)
|
||||||
schedule.applyAction(report_step, *action, result);
|
schedule.applyAction(report_step, *action, result);
|
||||||
}
|
}
|
||||||
@@ -93,12 +83,12 @@ void msim::post_step(Schedule& schedule, Action::State& action_state, SummarySta
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void msim::run_step(const Schedule& schedule, Action::State& action_state, SummaryState& st, UDQState& udq_state, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& grp_nwrk_data, size_t report_step, EclipseIO& io) const {
|
void msim::run_step(const Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, EclipseIO& io) const {
|
||||||
this->run_step(schedule, action_state, st, udq_state, sol, well_data, grp_nwrk_data, report_step, schedule.stepLength(report_step - 1), io);
|
this->run_step(schedule, st, sol, well_data, report_step, schedule.stepLength(report_step - 1), io);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void msim::run_step(const Schedule& schedule, Action::State& action_state, SummaryState& st, UDQState& udq_state, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& group_nwrk_data, size_t report_step, double dt, EclipseIO& io) const {
|
void msim::run_step(const Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, double dt, EclipseIO& io) const {
|
||||||
double start_time = schedule.seconds(report_step - 1);
|
double start_time = schedule.seconds(report_step - 1);
|
||||||
double end_time = schedule.seconds(report_step);
|
double end_time = schedule.seconds(report_step);
|
||||||
double seconds_elapsed = start_time;
|
double seconds_elapsed = start_time;
|
||||||
@@ -108,7 +98,9 @@ void msim::run_step(const Schedule& schedule, Action::State& action_state, Summa
|
|||||||
if ((seconds_elapsed + time_step) > end_time)
|
if ((seconds_elapsed + time_step) > end_time)
|
||||||
time_step = end_time - seconds_elapsed;
|
time_step = end_time - seconds_elapsed;
|
||||||
|
|
||||||
this->simulate(schedule, st, sol, well_data, group_nwrk_data, report_step, seconds_elapsed, time_step);
|
this->simulate(schedule, st, sol, well_data, report_step, seconds_elapsed, time_step);
|
||||||
|
|
||||||
|
Opm::data::Group group_data;
|
||||||
|
|
||||||
seconds_elapsed += time_step;
|
seconds_elapsed += time_step;
|
||||||
|
|
||||||
@@ -118,31 +110,24 @@ void msim::run_step(const Schedule& schedule, Action::State& action_state, Summa
|
|||||||
this->state,
|
this->state,
|
||||||
schedule,
|
schedule,
|
||||||
well_data,
|
well_data,
|
||||||
group_nwrk_data,
|
group_data,
|
||||||
{});
|
{});
|
||||||
|
|
||||||
schedule.getUDQConfig( report_step ).eval(report_step, st, udq_state);
|
this->output(st,
|
||||||
|
|
||||||
this->output(action_state,
|
|
||||||
st,
|
|
||||||
udq_state,
|
|
||||||
report_step,
|
report_step,
|
||||||
(seconds_elapsed < end_time),
|
(seconds_elapsed < end_time),
|
||||||
seconds_elapsed,
|
seconds_elapsed,
|
||||||
sol,
|
sol,
|
||||||
well_data,
|
well_data,
|
||||||
group_nwrk_data,
|
|
||||||
io);
|
io);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void msim::output(Action::State& action_state, SummaryState& st, const UDQState& udq_state, size_t report_step, bool substep, double seconds_elapsed, const data::Solution& sol, const data::Wells& well_data, const data::GroupAndNetworkValues& group_nwrk_data, EclipseIO& io) const {
|
void msim::output(SummaryState& st, size_t report_step, bool substep, double seconds_elapsed, const data::Solution& sol, const data::Wells& well_data, EclipseIO& io) const {
|
||||||
RestartValue value(sol, well_data, group_nwrk_data);
|
RestartValue value(sol, well_data);
|
||||||
io.writeTimeStep(action_state,
|
io.writeTimeStep(st,
|
||||||
st,
|
|
||||||
udq_state,
|
|
||||||
report_step,
|
report_step,
|
||||||
substep,
|
substep,
|
||||||
seconds_elapsed,
|
seconds_elapsed,
|
||||||
@@ -150,7 +135,7 @@ void msim::output(Action::State& action_state, SummaryState& st, const UDQState&
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void msim::simulate(const Schedule& schedule, const SummaryState& st, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& /* group_nwrk_data */, size_t report_step, double seconds_elapsed, double time_step) const {
|
void msim::simulate(const Schedule& schedule, const SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, double seconds_elapsed, double time_step) const {
|
||||||
for (const auto& sol_pair : this->solutions) {
|
for (const auto& sol_pair : this->solutions) {
|
||||||
auto func = sol_pair.second;
|
auto func = sol_pair.second;
|
||||||
func(this->state, schedule, sol, report_step, seconds_elapsed + time_step);
|
func(this->state, schedule, sol, report_step, seconds_elapsed + time_step);
|
||||||
@@ -159,17 +144,15 @@ void msim::simulate(const Schedule& schedule, const SummaryState& st, data::Solu
|
|||||||
for (const auto& well_pair : this->well_rates) {
|
for (const auto& well_pair : this->well_rates) {
|
||||||
const std::string& well_name = well_pair.first;
|
const std::string& well_name = well_pair.first;
|
||||||
const auto& sched_well = schedule.getWell(well_name, report_step);
|
const auto& sched_well = schedule.getWell(well_name, report_step);
|
||||||
bool well_open = (sched_well.getStatus() == Well::Status::OPEN);
|
if (sched_well.getStatus() != Well::Status::OPEN)
|
||||||
|
continue;
|
||||||
|
|
||||||
data::Well& well = well_data[well_name];
|
data::Well& well = well_data[well_name];
|
||||||
for (const auto& rate_pair : well_pair.second) {
|
for (const auto& rate_pair : well_pair.second) {
|
||||||
auto rate = rate_pair.first;
|
auto rate = rate_pair.first;
|
||||||
auto func = rate_pair.second;
|
auto func = rate_pair.second;
|
||||||
|
|
||||||
if (well_open)
|
well.rates.set(rate, func(this->state, schedule, st, sol, report_step, seconds_elapsed + time_step));
|
||||||
well.rates.set(rate, func(this->state, schedule, st, sol, report_step, seconds_elapsed + time_step));
|
|
||||||
else
|
|
||||||
well.rates.set(rate, 0.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is complete bogus; a temporary fix to pass an assert() in the
|
// This is complete bogus; a temporary fix to pass an assert() in the
|
||||||
|
|||||||
@@ -17,63 +17,39 @@
|
|||||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef KEYWORD_LOCATION_HPP
|
#ifndef LOCATION_HPP
|
||||||
#define KEYWORD_LOCATION_HPP
|
#define LOCATION_HPP
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
|
|
||||||
class KeywordLocation {
|
class Location {
|
||||||
public:
|
public:
|
||||||
/*
|
|
||||||
Observe that many error messages whcih should print out the name of the
|
|
||||||
problem keyword along with the location {} placeholders can be used. The
|
|
||||||
convention is:
|
|
||||||
|
|
||||||
{keyword} -> keyword
|
|
||||||
{file} -> filename
|
|
||||||
{line} -> lineno
|
|
||||||
|
|
||||||
This convention must be adhered to at the call site *creating the output
|
|
||||||
string*.
|
|
||||||
*/
|
|
||||||
|
|
||||||
std::string keyword;
|
|
||||||
std::string filename = "<memory string>";
|
std::string filename = "<memory string>";
|
||||||
std::size_t lineno = 0;
|
std::size_t lineno = 0;
|
||||||
|
|
||||||
KeywordLocation() = default;
|
Location() = default;
|
||||||
KeywordLocation(std::string kw, std::string fname, std::size_t lno) :
|
Location(std::string fname, std::size_t lno) :
|
||||||
keyword(std::move(kw)),
|
|
||||||
filename(std::move(fname)),
|
filename(std::move(fname)),
|
||||||
lineno(lno)
|
lineno(lno)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
std::string message() const {
|
static Location serializeObject()
|
||||||
return this->keyword + " in " + this->filename + " at line " + std::to_string(this->lineno);
|
|
||||||
}
|
|
||||||
|
|
||||||
static KeywordLocation serializeObject()
|
|
||||||
{
|
{
|
||||||
KeywordLocation result;
|
Location result;
|
||||||
result.keyword = "KW";
|
|
||||||
result.filename = "test";
|
result.filename = "test";
|
||||||
result.lineno = 1;
|
result.lineno = 1;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const KeywordLocation& data) const {
|
bool operator==(const Location& data) const {
|
||||||
return keyword == data.keyword &&
|
return filename == data.filename &&
|
||||||
filename == data.filename &&
|
|
||||||
lineno == data.lineno;
|
lineno == data.lineno;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Serializer>
|
template<class Serializer>
|
||||||
void serializeOp(Serializer& serializer)
|
void serializeOp(Serializer& serializer)
|
||||||
{
|
{
|
||||||
serializer(keyword);
|
|
||||||
serializer(filename);
|
serializer(filename);
|
||||||
serializer(lineno);
|
serializer(lineno);
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <opm/common/OpmLog/KeywordLocation.hpp>
|
#include <opm/common/OpmLog/Location.hpp>
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
|
|
||||||
@@ -59,8 +59,8 @@ namespace Log {
|
|||||||
|
|
||||||
|
|
||||||
bool isPower2(int64_t x);
|
bool isPower2(int64_t x);
|
||||||
std::string fileMessage(const KeywordLocation& location, const std::string& msg);
|
std::string fileMessage(const Location& location, const std::string& msg);
|
||||||
std::string fileMessage(int64_t messageType , const KeywordLocation& location , const std::string& msg);
|
std::string fileMessage(int64_t messageType , const Location& location , const std::string& msg);
|
||||||
std::string prefixMessage(int64_t messageType , const std::string& msg);
|
std::string prefixMessage(int64_t messageType , const std::string& msg);
|
||||||
std::string colorCodeMessage(int64_t messageType , const std::string& msg);
|
std::string colorCodeMessage(int64_t messageType , const std::string& msg);
|
||||||
|
|
||||||
|
|||||||
191
opm/common/data/SimulationDataContainer.hpp
Normal file
191
opm/common/data/SimulationDataContainer.hpp
Normal 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 <map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace Opm {
|
||||||
|
|
||||||
|
|
||||||
|
/// The SimulationDataContainer is a simple container to manage
|
||||||
|
/// simulation data. The container is instantiated with information
|
||||||
|
/// of how many cells, faces and phases are present in the
|
||||||
|
/// reservoirmodel. You can then add data to the container by using the
|
||||||
|
///
|
||||||
|
/// registerCellData()
|
||||||
|
/// registerFaceData()
|
||||||
|
///
|
||||||
|
/// functions. The container owns and manages the data, but
|
||||||
|
/// mutable references are returned with the getCellData() and
|
||||||
|
/// getFaceData() methods, and the content will typically be
|
||||||
|
/// modified by external scope.
|
||||||
|
class SimulationDataContainer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/// Main constructor setting the sizes for the contained data
|
||||||
|
/// types.
|
||||||
|
/// \param num_cells number of elements in cell data vectors
|
||||||
|
/// \param num_faces number of elements in face data vectors
|
||||||
|
/// \param num_phases number of phases, the number of components
|
||||||
|
/// in any data vector must equal 1 or this
|
||||||
|
/// number (this behaviour and argument is deprecated).
|
||||||
|
SimulationDataContainer(size_t num_cells, size_t num_faces, size_t num_phases);
|
||||||
|
|
||||||
|
/// Copy constructor.
|
||||||
|
/// Must be defined explicitly because class contains non-value objects
|
||||||
|
/// (the reference pointers pressure_ref_ etc.) that should not simply
|
||||||
|
/// be copied.
|
||||||
|
SimulationDataContainer(const SimulationDataContainer&);
|
||||||
|
|
||||||
|
/// Copy assignment operator.
|
||||||
|
/// Must be defined explicitly because class contains non-value objects
|
||||||
|
/// (the reference pointers pressure_ref_ etc.) that should not simply
|
||||||
|
/// be copied.
|
||||||
|
SimulationDataContainer& operator=(const SimulationDataContainer&);
|
||||||
|
|
||||||
|
/// Efficient O(1) swap.
|
||||||
|
void swap(SimulationDataContainer& other);
|
||||||
|
|
||||||
|
size_t numPhases() const;
|
||||||
|
size_t numFaces() const;
|
||||||
|
size_t numCells() const;
|
||||||
|
|
||||||
|
bool hasCellData( const std::string& name ) const;
|
||||||
|
|
||||||
|
/// Will register a data vector of size numCells() *
|
||||||
|
/// components.
|
||||||
|
void registerCellData( const std::string& name , size_t components , double initialValue = 0.0 );
|
||||||
|
std::vector<double>& getCellData( const std::string& name );
|
||||||
|
const std::vector<double>& getCellData( const std::string& name ) const;
|
||||||
|
|
||||||
|
bool hasFaceData( const std::string& name ) const;
|
||||||
|
void registerFaceData( const std::string& name , size_t components , double initialValue = 0.0 );
|
||||||
|
std::vector<double>& getFaceData( const std::string& name );
|
||||||
|
const std::vector<double>& getFaceData( const std::string& name ) const;
|
||||||
|
|
||||||
|
/// Will return the number of components of the celldata with
|
||||||
|
/// name @name:
|
||||||
|
///
|
||||||
|
/// numCellDataComponents( "PRESSURE" ) -> 1
|
||||||
|
/// numCellDataComponents( "SATURATION" ) -> 3
|
||||||
|
///
|
||||||
|
/// for a three phase model.
|
||||||
|
size_t numCellDataComponents( const std::string& name ) const;
|
||||||
|
bool equal(const SimulationDataContainer& other) const;
|
||||||
|
|
||||||
|
|
||||||
|
/// Will set the values of component nr @component in the
|
||||||
|
/// field @key. All the cells in @cells will be set to the
|
||||||
|
/// values in @values.
|
||||||
|
void setCellDataComponent( const std::string& key , size_t component , const std::vector<int>& cells , const std::vector<double>& values);
|
||||||
|
|
||||||
|
// Direct explicit field access for certain default fields.
|
||||||
|
// These methods are all deprecated, and will eventually be moved to
|
||||||
|
// concrete subclasses.
|
||||||
|
|
||||||
|
std::vector<double>& pressure ();
|
||||||
|
std::vector<double>& temperature ();
|
||||||
|
std::vector<double>& saturation ();
|
||||||
|
|
||||||
|
std::vector<double>& facepressure();
|
||||||
|
std::vector<double>& faceflux ();
|
||||||
|
|
||||||
|
const std::vector<double>& pressure () const;
|
||||||
|
const std::vector<double>& temperature () const;
|
||||||
|
const std::vector<double>& saturation () const;
|
||||||
|
|
||||||
|
const std::vector<double>& facepressure() const;
|
||||||
|
const std::vector<double>& faceflux () const;
|
||||||
|
|
||||||
|
const std::map<std::string, std::vector<double>>& cellData() const;
|
||||||
|
std::map<std::string, std::vector<double>>& cellData();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void addDefaultFields();
|
||||||
|
void setReferencePointers();
|
||||||
|
|
||||||
|
size_t m_num_cells;
|
||||||
|
size_t m_num_faces;
|
||||||
|
size_t m_num_phases;
|
||||||
|
|
||||||
|
std::map< std::string , std::vector<double> > m_cell_data;
|
||||||
|
std::map< std::string , std::vector<double> > m_face_data;
|
||||||
|
|
||||||
|
std::vector<double>* pressure_ref_;
|
||||||
|
std::vector<double>* temperature_ref_;
|
||||||
|
std::vector<double>* saturation_ref_;
|
||||||
|
std::vector<double>* facepressure_ref_;
|
||||||
|
std::vector<double>* faceflux_ref_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Inline implementations of the direct accessors required to guarantee
|
||||||
|
// performance.
|
||||||
|
|
||||||
|
|
||||||
|
inline std::vector<double>& SimulationDataContainer::pressure( ) {
|
||||||
|
return *pressure_ref_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::vector<double>& SimulationDataContainer::temperature() {
|
||||||
|
return *temperature_ref_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::vector<double>& SimulationDataContainer::saturation() {
|
||||||
|
return *saturation_ref_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::vector<double>& SimulationDataContainer::facepressure() {
|
||||||
|
return *facepressure_ref_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::vector<double>& SimulationDataContainer::faceflux() {
|
||||||
|
return *faceflux_ref_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const std::vector<double>& SimulationDataContainer::pressure( ) const {
|
||||||
|
return *pressure_ref_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const std::vector<double>& SimulationDataContainer::temperature() const {
|
||||||
|
return *temperature_ref_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const std::vector<double>& SimulationDataContainer::saturation() const {
|
||||||
|
return *saturation_ref_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const std::vector<double>& SimulationDataContainer::facepressure() const {
|
||||||
|
return *facepressure_ref_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const std::vector<double>& SimulationDataContainer::faceflux() const {
|
||||||
|
return *faceflux_ref_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
#define OPM_FILESYSTEM_HPP
|
#define OPM_FILESYSTEM_HPP
|
||||||
|
|
||||||
#if __cplusplus < 201703L || \
|
#if __cplusplus < 201703L || \
|
||||||
(defined(__GNUC__) && __GNUC__ < 8 && !defined(__clang__))
|
(defined(__GNUC__) && __GNUC__ < 8)
|
||||||
#include <experimental/filesystem>
|
#include <experimental/filesystem>
|
||||||
#else
|
#else
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
namespace Opm
|
namespace Opm
|
||||||
{
|
{
|
||||||
#if __cplusplus < 201703L || \
|
#if __cplusplus < 201703L || \
|
||||||
(defined(__GNUC__) && __GNUC__ < 8 && !defined(__clang__))
|
(defined(__GNUC__) && __GNUC__ < 8)
|
||||||
namespace filesystem = std::experimental::filesystem;
|
namespace filesystem = std::experimental::filesystem;
|
||||||
#else
|
#else
|
||||||
namespace filesystem = std::filesystem;
|
namespace filesystem = std::filesystem;
|
||||||
|
|||||||
@@ -1,121 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2020 Equinor ASA.
|
|
||||||
|
|
||||||
This file is part of the Open Porous Media project (OPM).
|
|
||||||
|
|
||||||
OPM is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OPM is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
#ifndef OPM_ERROR_HPP
|
|
||||||
#define OPM_ERROR_HPP
|
|
||||||
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include <opm/common/OpmLog/KeywordLocation.hpp>
|
|
||||||
|
|
||||||
namespace Opm {
|
|
||||||
|
|
||||||
/*
|
|
||||||
The OpmInputError is a custom exception class which can be used to signal
|
|
||||||
errors in input handling. The importance of the OpmInputError exception is
|
|
||||||
*not* the tecnical functionality it provides, but rather the convention
|
|
||||||
surrounding it, when and how it should be used.
|
|
||||||
|
|
||||||
The OpmInputError should be used in situations which are "close to user
|
|
||||||
input", the root cause can either be incorrect user input or a bug/limitation
|
|
||||||
in opm. OpmInputError should only be used in situations where we have a good
|
|
||||||
understanding of the underlying issue, and can provide a good error message.
|
|
||||||
|
|
||||||
The local error handling should be complete when the OpmInputError is
|
|
||||||
instantiated, it should not be caught and rethrown in order to e.g. add
|
|
||||||
additional context or log messages. In order to avoid inadvertendly catching
|
|
||||||
this exception in a catch all block.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class OpmInputError : public std::exception {
|
|
||||||
public:
|
|
||||||
/*
|
|
||||||
The message string will be used as format string in the fmt::format()
|
|
||||||
function as, and optional {} markers can be used to inject keyword,
|
|
||||||
filename and linenumber into the final what() message. The placeholders
|
|
||||||
must use named arguments
|
|
||||||
|
|
||||||
{keyword} -> loc.keyword
|
|
||||||
{file} -> loc.filename
|
|
||||||
{line} -> loc.lineno
|
|
||||||
|
|
||||||
additionally, the message can contain any number of positional
|
|
||||||
arguments to add further context to the message.
|
|
||||||
|
|
||||||
KeywordLocation loc("KW", "file.inc", 100);
|
|
||||||
OpmInputError("Error at line {line} in file {file} - keyword: {keyword} ignored", location);
|
|
||||||
OpmInputError("Error at line {line} in file {file} - keyword: {keyword} has invalid argument {}", invalid_argument);
|
|
||||||
*/
|
|
||||||
|
|
||||||
template<typename ... Args>
|
|
||||||
OpmInputError(const std::string& reason, const KeywordLocation& location, const Args& ...furtherLocations)
|
|
||||||
: locations { location, furtherLocations... }
|
|
||||||
, m_what {
|
|
||||||
locations.size() == 1
|
|
||||||
? formatSingle(reason, locations[0])
|
|
||||||
: formatMultiple(reason, locations)
|
|
||||||
}
|
|
||||||
{ }
|
|
||||||
|
|
||||||
/*
|
|
||||||
Allows for the initialisation of an OpmInputError from another exception.
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
|
|
||||||
try {
|
|
||||||
.
|
|
||||||
.
|
|
||||||
.
|
|
||||||
} catch (const Opm::OpmInputError&) {
|
|
||||||
throw;
|
|
||||||
} catch (const std::exception& e) {
|
|
||||||
std::throw_with_nested(Opm::OpmInputError(e, location));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
OpmInputError(const std::exception& error, const KeywordLocation& location)
|
|
||||||
: locations { location }
|
|
||||||
, m_what { formatException(error, locations[0]) }
|
|
||||||
{ }
|
|
||||||
|
|
||||||
const char * what() const throw()
|
|
||||||
{
|
|
||||||
return this->m_what.c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static std::string format(const std::string& msg_format, const KeywordLocation& loc);
|
|
||||||
|
|
||||||
private:
|
|
||||||
// The location member is here for debugging; depending on the msg_fmt
|
|
||||||
// passed in the constructor we might not have captured all the information
|
|
||||||
// in the location argument passed to the constructor.
|
|
||||||
std::vector<KeywordLocation> locations;
|
|
||||||
|
|
||||||
std::string m_what;
|
|
||||||
|
|
||||||
static std::string formatException(const std::exception& e, const KeywordLocation& loc);
|
|
||||||
static std::string formatSingle(const std::string& reason, const KeywordLocation&);
|
|
||||||
static std::string formatMultiple(const std::string& reason, const std::vector<KeywordLocation>&);
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -1,118 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2020 Equinor ASA.
|
|
||||||
|
|
||||||
This file is part of the Open Porous Media project (OPM).
|
|
||||||
|
|
||||||
OPM is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OPM is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
#include <string>
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#ifndef OPM_SERIALIZER_HPP
|
|
||||||
#define OPM_SERIALIZER_HPP
|
|
||||||
|
|
||||||
namespace Opm {
|
|
||||||
/*
|
|
||||||
This is a very basic serialization class used to support serialization of
|
|
||||||
small state objects from opm common. The main serialization code used in
|
|
||||||
opm/flow is initiated and controlled from the restart code, and therefor
|
|
||||||
slightly cumbersome to use for objects which should be serialized not as part
|
|
||||||
of the restart code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
class Serializer {
|
|
||||||
public:
|
|
||||||
Serializer() = default;
|
|
||||||
explicit Serializer(const std::vector<char>& buffer_arg) :
|
|
||||||
buffer(buffer_arg)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void put(const T& value) {
|
|
||||||
this->pack(std::addressof(value), sizeof(T));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void put(const T* ) {
|
|
||||||
throw std::logic_error("Serializer can not pack pointers");
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
T get() {
|
|
||||||
T value;
|
|
||||||
std::memcpy(&value, &this->buffer[this->read_pos], sizeof(T));
|
|
||||||
this->read_pos += sizeof(T);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename K, typename T>
|
|
||||||
void put(const std::unordered_map<K,T>& values) {
|
|
||||||
this->put(values.size());
|
|
||||||
for (const auto& value_pair : values) {
|
|
||||||
this->put(value_pair.first);
|
|
||||||
this->put(value_pair.second);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename K, typename T>
|
|
||||||
std::unordered_map<K,T> get() {
|
|
||||||
std::unordered_map<K,T> values;
|
|
||||||
auto size = this->get<std::size_t>();
|
|
||||||
for (std::size_t index = 0; index < size; index++) {
|
|
||||||
auto key = this->get<K>();
|
|
||||||
auto value = this->get<T>();
|
|
||||||
values.insert( std::make_pair(key,value) );
|
|
||||||
}
|
|
||||||
return values;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::vector<char> buffer;
|
|
||||||
private:
|
|
||||||
void pack(const void * ptr, std::size_t value_size) {
|
|
||||||
std::size_t write_pos = this->buffer.size();
|
|
||||||
std::size_t new_size = write_pos + value_size;
|
|
||||||
this->buffer.resize( new_size );
|
|
||||||
std::memcpy(&this->buffer[write_pos], ptr, value_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::size_t read_pos = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
void inline Serializer::put(const std::string& value) {
|
|
||||||
this->put(value.size());
|
|
||||||
if (value.empty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
this->pack(value.c_str(), value.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
template<>
|
|
||||||
std::string inline Serializer::get<std::string>() {
|
|
||||||
std::string::size_type length = this->get<std::string::size_type>();
|
|
||||||
if (length == 0)
|
|
||||||
return std::string{};
|
|
||||||
|
|
||||||
this->read_pos += length;
|
|
||||||
return {std::addressof(this->buffer[this->read_pos - length]), length};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -43,7 +43,7 @@ namespace Opm
|
|||||||
{
|
{
|
||||||
OPM_THROW(std::runtime_error, "Maximum number of iterations exceeded: " << maxiter << "\n"
|
OPM_THROW(std::runtime_error, "Maximum number of iterations exceeded: " << maxiter << "\n"
|
||||||
<< "Current interval is [" << std::min(x0, x1) << ", "
|
<< "Current interval is [" << std::min(x0, x1) << ", "
|
||||||
<< std::max(x0, x1) << "] abs(x0-x1) " << std::abs(x0-x1));
|
<< std::max(x0, x1) << "]");
|
||||||
return -1e100; // Never reached.
|
return -1e100; // Never reached.
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -64,7 +64,7 @@ namespace Opm
|
|||||||
OPM_REPORT;
|
OPM_REPORT;
|
||||||
std::cerr << "Maximum number of iterations exceeded: " << maxiter
|
std::cerr << "Maximum number of iterations exceeded: " << maxiter
|
||||||
<< ", current interval is [" << std::min(x0, x1) << ", "
|
<< ", current interval is [" << std::min(x0, x1) << ", "
|
||||||
<< std::max(x0, x1) << "] abs(x0-x1) " << std::abs(x0-x1);
|
<< std::max(x0, x1) << "]";
|
||||||
return 0.5*(x0 + x1);
|
return 0.5*(x0 + x1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -124,7 +124,7 @@ namespace Opm
|
|||||||
iterations_used = 0;
|
iterations_used = 0;
|
||||||
// In every iteraton, x1 is the last point computed,
|
// In every iteraton, x1 is the last point computed,
|
||||||
// and x0 is the last point computed that makes it a bracket.
|
// and x0 is the last point computed that makes it a bracket.
|
||||||
while (fabs(x1 - x0) >= eps) {
|
while (fabs(x1 - x0) >= 1e-9*eps) {
|
||||||
double xnew = regulaFalsiStep(x0, x1, f0, f1);
|
double xnew = regulaFalsiStep(x0, x1, f0, f1);
|
||||||
double fnew = f(xnew);
|
double fnew = f(xnew);
|
||||||
// cout << "xnew = " << xnew << " fnew = " << fnew << endl;
|
// cout << "xnew = " << xnew << " fnew = " << fnew << endl;
|
||||||
@@ -221,7 +221,7 @@ namespace Opm
|
|||||||
iterations_used = 0;
|
iterations_used = 0;
|
||||||
// In every iteraton, x1 is the last point computed,
|
// In every iteraton, x1 is the last point computed,
|
||||||
// and x0 is the last point computed that makes it a bracket.
|
// and x0 is the last point computed that makes it a bracket.
|
||||||
while (fabs(x1 - x0) >= eps) {
|
while (fabs(x1 - x0) >= 1e-9*eps) {
|
||||||
double xnew = regulaFalsiStep(x0, x1, f0, f1);
|
double xnew = regulaFalsiStep(x0, x1, f0, f1);
|
||||||
double fnew = f(xnew);
|
double fnew = f(xnew);
|
||||||
// cout << "xnew = " << xnew << " fnew = " << fnew << endl;
|
// cout << "xnew = " << xnew << " fnew = " << fnew << endl;
|
||||||
@@ -327,7 +327,7 @@ namespace Opm
|
|||||||
// and x0 is the last point computed that makes it a bracket.
|
// and x0 is the last point computed that makes it a bracket.
|
||||||
double width = fabs(x1 - x0);
|
double width = fabs(x1 - x0);
|
||||||
double contraction = 1.0;
|
double contraction = 1.0;
|
||||||
while (width >= eps) {
|
while (width >= 1e-9 * eps) {
|
||||||
// If we are contracting sufficiently to at least halve
|
// If we are contracting sufficiently to at least halve
|
||||||
// the interval width in two iterations we use regula
|
// the interval width in two iterations we use regula
|
||||||
// falsi. Otherwise, we take a bisection step to avoid
|
// falsi. Otherwise, we take a bisection step to avoid
|
||||||
|
|||||||
@@ -57,8 +57,6 @@ public:
|
|||||||
void LoadData(const std::vector<std::string>& vectList) const;
|
void LoadData(const std::vector<std::string>& vectList) const;
|
||||||
void LoadData() const;
|
void LoadData() const;
|
||||||
|
|
||||||
bool make_lodsmry_file();
|
|
||||||
|
|
||||||
std::chrono::system_clock::time_point startdate() const { return startdat; }
|
std::chrono::system_clock::time_point startdate() const { return startdat; }
|
||||||
|
|
||||||
const std::vector<std::string>& keywordList() const;
|
const std::vector<std::string>& keywordList() const;
|
||||||
@@ -67,7 +65,7 @@ public:
|
|||||||
|
|
||||||
int timestepIdxAtReportstepStart(const int reportStep) const;
|
int timestepIdxAtReportstepStart(const int reportStep) const;
|
||||||
|
|
||||||
size_t numberOfTimeSteps() const { return nTstep; }
|
size_t numberOfTimeSteps() const { return timeStepList.size(); }
|
||||||
|
|
||||||
const std::string& get_unit(const std::string& name) const;
|
const std::string& get_unit(const std::string& name) const;
|
||||||
const std::string& get_unit(const SummaryNode& node) const;
|
const std::string& get_unit(const SummaryNode& node) const;
|
||||||
@@ -76,11 +74,9 @@ public:
|
|||||||
void write_rsm_file(std::optional<Opm::filesystem::path> = std::nullopt) const;
|
void write_rsm_file(std::optional<Opm::filesystem::path> = std::nullopt) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Opm::filesystem::path inputFileName, lodFileName;
|
Opm::filesystem::path inputFileName;
|
||||||
int nI, nJ, nK, nSpecFiles;
|
int nI, nJ, nK, nSpecFiles;
|
||||||
bool fromSingleRun, lodEnabeled;
|
size_t nVect;
|
||||||
uint64_t lod_offset, lod_arr_size;
|
|
||||||
size_t nVect, nTstep;
|
|
||||||
|
|
||||||
std::vector<bool> formattedFiles;
|
std::vector<bool> formattedFiles;
|
||||||
std::vector<std::string> dataFileList;
|
std::vector<std::string> dataFileList;
|
||||||
@@ -133,9 +129,6 @@ private:
|
|||||||
|
|
||||||
std::vector<std::tuple <std::string, uint64_t>> getListOfArrays(std::string filename, bool formatted);
|
std::vector<std::tuple <std::string, uint64_t>> getListOfArrays(std::string filename, bool formatted);
|
||||||
std::vector<int> makeKeywPosVector(int speInd) const;
|
std::vector<int> makeKeywPosVector(int speInd) const;
|
||||||
std::string read_string_from_disk(std::fstream& fileH, uint64_t size) const;
|
|
||||||
void inspect_lodsmry();
|
|
||||||
void Load_from_lodsmry(const std::vector<int>& keywIndVect) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}} // namespace Opm::EclIO
|
}} // namespace Opm::EclIO
|
||||||
|
|||||||
@@ -23,8 +23,6 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
namespace Opm { namespace EclIO {
|
namespace Opm { namespace EclIO {
|
||||||
|
|
||||||
@@ -33,8 +31,6 @@ namespace Opm { namespace EclIO {
|
|||||||
float flipEndianFloat(float num);
|
float flipEndianFloat(float num);
|
||||||
double flipEndianDouble(double num);
|
double flipEndianDouble(double num);
|
||||||
bool isEOF(std::fstream* fileH);
|
bool isEOF(std::fstream* fileH);
|
||||||
bool fileExists(const std::string& filename);
|
|
||||||
bool isFormatted(const std::string& filename);
|
|
||||||
|
|
||||||
std::tuple<int, int> block_size_data_binary(eclArrType arrType);
|
std::tuple<int, int> block_size_data_binary(eclArrType arrType);
|
||||||
std::tuple<int, int, int> block_size_data_formatted(eclArrType arrType);
|
std::tuple<int, int, int> block_size_data_formatted(eclArrType arrType);
|
||||||
@@ -53,25 +49,6 @@ namespace Opm { namespace EclIO {
|
|||||||
void readFormattedHeader(std::fstream& fileH, std::string& arrName,
|
void readFormattedHeader(std::fstream& fileH, std::string& arrName,
|
||||||
int64_t &num, Opm::EclIO::eclArrType &arrType);
|
int64_t &num, Opm::EclIO::eclArrType &arrType);
|
||||||
|
|
||||||
template<typename T, typename T2>
|
|
||||||
std::vector<T> readBinaryArray(std::fstream& fileH, const int64_t size, Opm::EclIO::eclArrType type,
|
|
||||||
std::function<T(T2)>& flip);
|
|
||||||
|
|
||||||
std::vector<int> readBinaryInteArray(std::fstream &fileH, const int64_t size);
|
|
||||||
std::vector<float> readBinaryRealArray(std::fstream& fileH, const int64_t size);
|
|
||||||
std::vector<double> readBinaryDoubArray(std::fstream& fileH, const int64_t size);
|
|
||||||
std::vector<bool> readBinaryLogiArray(std::fstream &fileH, const int64_t size);
|
|
||||||
std::vector<std::string> readBinaryCharArray(std::fstream& fileH, const int64_t size);
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
std::vector<T> readFormattedArray(const std::string& file_str, const int size, int64_t fromPos,
|
|
||||||
std::function<T(const std::string&)>& process);
|
|
||||||
|
|
||||||
std::vector<int> readFormattedInteArray(const std::string& file_str, const int64_t size, int64_t fromPos);
|
|
||||||
std::vector<std::string> readFormattedCharArray(const std::string& file_str, const int64_t size, int64_t fromPos);
|
|
||||||
std::vector<float> readFormattedRealArray(const std::string& file_str, const int64_t size, int64_t fromPos);
|
|
||||||
std::vector<bool> readFormattedLogiArray(const std::string& file_str, const int64_t size, int64_t fromPos);
|
|
||||||
std::vector<double> readFormattedDoubArray(const std::string& file_str, const int64_t size, int64_t fromPos);
|
|
||||||
|
|
||||||
}} // namespace Opm::EclIO
|
}} // namespace Opm::EclIO
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef OPM_IO_SUMMARYNODE_HPP
|
#ifndef OPM_IO_SUMMARYNODE_HPP
|
||||||
#define OPM_IO_SUMMARYNODE_HPP
|
#define OPM_IO_SUMMARYNODE_HPP
|
||||||
@@ -25,10 +25,11 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
namespace Opm { namespace EclIO {
|
namespace Opm::EclIO {
|
||||||
|
|
||||||
struct SummaryNode {
|
struct SummaryNode {
|
||||||
enum class Category {
|
enum class Category {
|
||||||
|
Aquifer,
|
||||||
Well,
|
Well,
|
||||||
Group,
|
Group,
|
||||||
Field,
|
Field,
|
||||||
@@ -36,8 +37,6 @@ struct SummaryNode {
|
|||||||
Block,
|
Block,
|
||||||
Connection,
|
Connection,
|
||||||
Segment,
|
Segment,
|
||||||
Aquifer,
|
|
||||||
Node,
|
|
||||||
Miscellaneous,
|
Miscellaneous,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -56,7 +55,6 @@ struct SummaryNode {
|
|||||||
Type type;
|
Type type;
|
||||||
std::string wgname;
|
std::string wgname;
|
||||||
int number;
|
int number;
|
||||||
std::string fip_region;
|
|
||||||
|
|
||||||
constexpr static int default_number { std::numeric_limits<int>::min() };
|
constexpr static int default_number { std::numeric_limits<int>::min() };
|
||||||
|
|
||||||
@@ -74,6 +72,6 @@ struct SummaryNode {
|
|||||||
std::optional<std::string> display_number(number_renderer) const;
|
std::optional<std::string> display_number(number_renderer) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}} // namespace Opm::EclIO
|
} // namespace Opm::EclIO
|
||||||
|
|
||||||
#endif // OPM_IO_SUMMARYNODE_HPP
|
#endif // OPM_IO_SUMMARYNODE_HPP
|
||||||
|
|||||||
@@ -32,19 +32,12 @@ struct RstHeader;
|
|||||||
|
|
||||||
struct RstGroup {
|
struct RstGroup {
|
||||||
RstGroup(const UnitSystem& unit_system,
|
RstGroup(const UnitSystem& unit_system,
|
||||||
const RstHeader& header,
|
|
||||||
const std::string* zwel,
|
const std::string* zwel,
|
||||||
const int * igrp,
|
const int * igrp,
|
||||||
const float * sgrp,
|
const float * sgrp,
|
||||||
const double * xgrp);
|
const double * xgrp);
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
|
|
||||||
int parent_group;
|
|
||||||
int prod_cmode;
|
|
||||||
int winj_cmode;
|
|
||||||
int ginj_cmode;
|
|
||||||
|
|
||||||
float oil_rate_limit;
|
float oil_rate_limit;
|
||||||
float water_rate_limit;
|
float water_rate_limit;
|
||||||
float gas_rate_limit;
|
float gas_rate_limit;
|
||||||
|
|||||||
@@ -24,12 +24,10 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
class UnitSystem;
|
|
||||||
|
|
||||||
namespace RestartIO {
|
namespace RestartIO {
|
||||||
|
|
||||||
struct RstHeader {
|
struct RstHeader {
|
||||||
RstHeader(const UnitSystem& unit_system, const std::vector<int>& intehead, const std::vector<bool>& logihead, const std::vector<double>& doubhead);
|
RstHeader(const std::vector<int>& intehead, const std::vector<bool>& logihead, const std::vector<double>& doubhead);
|
||||||
|
|
||||||
int nx;
|
int nx;
|
||||||
int ny;
|
int ny;
|
||||||
@@ -88,7 +86,6 @@ struct RstHeader {
|
|||||||
int ntfreg;
|
int ntfreg;
|
||||||
int nplmix;
|
int nplmix;
|
||||||
int ngroup;
|
int ngroup;
|
||||||
int nwgmax;
|
|
||||||
|
|
||||||
bool e300_radial;
|
bool e300_radial;
|
||||||
bool e100_radial;
|
bool e100_radial;
|
||||||
@@ -103,7 +100,6 @@ struct RstHeader {
|
|||||||
bool dir_eps;
|
bool dir_eps;
|
||||||
bool reversible_eps;
|
bool reversible_eps;
|
||||||
bool alt_eps;
|
bool alt_eps;
|
||||||
bool group_control_active;
|
|
||||||
|
|
||||||
double next_timestep1;
|
double next_timestep1;
|
||||||
double next_timestep2;
|
double next_timestep2;
|
||||||
@@ -114,8 +110,6 @@ struct RstHeader {
|
|||||||
double guide_rate_d;
|
double guide_rate_d;
|
||||||
double guide_rate_e;
|
double guide_rate_e;
|
||||||
double guide_rate_f;
|
double guide_rate_f;
|
||||||
double guide_rate_delay;
|
|
||||||
double guide_rate_damping;
|
|
||||||
double udq_range;
|
double udq_range;
|
||||||
double udq_undefined;
|
double udq_undefined;
|
||||||
double udq_eps;
|
double udq_eps;
|
||||||
|
|||||||
@@ -35,11 +35,6 @@ namespace Opm {
|
|||||||
|
|
||||||
namespace RestartIO {
|
namespace RestartIO {
|
||||||
struct RstState {
|
struct RstState {
|
||||||
RstState(const ::Opm::UnitSystem& unit_system,
|
|
||||||
const std::vector<int>& intehead,
|
|
||||||
const std::vector<bool>& logihead,
|
|
||||||
const std::vector<double>& doubhead);
|
|
||||||
|
|
||||||
RstState(const ::Opm::UnitSystem& unit_system,
|
RstState(const ::Opm::UnitSystem& unit_system,
|
||||||
const std::vector<int>& intehead,
|
const std::vector<int>& intehead,
|
||||||
const std::vector<bool>& logihead,
|
const std::vector<bool>& logihead,
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ struct RstWell {
|
|||||||
std::array<int, 2> ij;
|
std::array<int, 2> ij;
|
||||||
std::pair<int,int> k1k2;
|
std::pair<int,int> k1k2;
|
||||||
WellType wtype;
|
WellType wtype;
|
||||||
int well_status;
|
|
||||||
int active_control;
|
int active_control;
|
||||||
int vfp_table;
|
int vfp_table;
|
||||||
int pred_requested_control;
|
int pred_requested_control;
|
||||||
@@ -89,14 +88,12 @@ struct RstWell {
|
|||||||
float datum_depth;
|
float datum_depth;
|
||||||
float drainage_radius;
|
float drainage_radius;
|
||||||
float efficiency_factor;
|
float efficiency_factor;
|
||||||
float alq_value;
|
|
||||||
|
|
||||||
double oil_rate;
|
double oil_rate;
|
||||||
double water_rate;
|
double water_rate;
|
||||||
double gas_rate;
|
double gas_rate;
|
||||||
double liquid_rate;
|
double liquid_rate;
|
||||||
double void_rate;
|
double void_rate;
|
||||||
double thp;
|
|
||||||
double flow_bhp;
|
double flow_bhp;
|
||||||
double wct;
|
double wct;
|
||||||
double gor;
|
double gor;
|
||||||
|
|||||||
@@ -30,26 +30,12 @@ namespace Json {
|
|||||||
|
|
||||||
class JsonObject {
|
class JsonObject {
|
||||||
public:
|
public:
|
||||||
JsonObject();
|
|
||||||
|
|
||||||
explicit JsonObject(const Opm::filesystem::path& jsonFile );
|
explicit JsonObject(const Opm::filesystem::path& jsonFile );
|
||||||
explicit JsonObject(const std::string& inline_json);
|
explicit JsonObject(const std::string& inline_json);
|
||||||
explicit JsonObject(const char * inline_json);
|
explicit JsonObject(const char * inline_json);
|
||||||
explicit JsonObject(cJSON * root);
|
explicit JsonObject(cJSON * root);
|
||||||
~JsonObject();
|
~JsonObject();
|
||||||
|
|
||||||
void add(double value);
|
|
||||||
void add(int value);
|
|
||||||
void add(const std::string& value);
|
|
||||||
JsonObject add_array();
|
|
||||||
JsonObject add_object();
|
|
||||||
void add_item(const std::string& key, double value);
|
|
||||||
void add_item(const std::string& key, int value);
|
|
||||||
void add_item(const std::string& key, const std::string& value);
|
|
||||||
JsonObject add_array(const std::string& key);
|
|
||||||
JsonObject add_object(const std::string& key);
|
|
||||||
std::string dump() const;
|
|
||||||
|
|
||||||
bool has_item(const std::string& key) const;
|
bool has_item(const std::string& key) const;
|
||||||
JsonObject get_array_item( size_t index ) const;
|
JsonObject get_array_item( size_t index ) const;
|
||||||
JsonObject get_item(const std::string& key) const;
|
JsonObject get_item(const std::string& key) const;
|
||||||
|
|||||||
@@ -46,31 +46,14 @@ namespace Opm { namespace data {
|
|||||||
struct AquiferData {
|
struct AquiferData {
|
||||||
int aquiferID; //< One-based ID, range 1..NANAQ
|
int aquiferID; //< One-based ID, range 1..NANAQ
|
||||||
double pressure; //< Aquifer pressure
|
double pressure; //< Aquifer pressure
|
||||||
double fluxRate; //< Aquifer influx rate (liquid aquifer)
|
|
||||||
// TODO: volume should have a better name, since meaning not clear
|
|
||||||
double volume; //< Produced liquid volume
|
double volume; //< Produced liquid volume
|
||||||
double initPressure; //< Aquifer's initial pressure
|
double initPressure; //< Aquifer's initial pressure
|
||||||
double datumDepth; //< Aquifer's pressure reference depth
|
double datumDepth; //< Aquifer's pressure reference depth
|
||||||
|
|
||||||
AquiferType type;
|
AquiferType type;
|
||||||
std::shared_ptr<FetkovichData> aquFet;
|
std::shared_ptr<FetkovichData> aquFet;
|
||||||
|
|
||||||
double get(const std::string& key) const
|
|
||||||
{
|
|
||||||
if ( key == "AAQR" ) {
|
|
||||||
return this->fluxRate;
|
|
||||||
} else if ( key == "AAQT" ) {
|
|
||||||
return this->volume;
|
|
||||||
} else if ( key == "AAQP" ) {
|
|
||||||
return this->pressure;
|
|
||||||
}
|
|
||||||
return 0.;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: not sure what extension we will need
|
|
||||||
using Aquifers = std::map<int, AquiferData>;
|
|
||||||
|
|
||||||
}} // Opm::data
|
}} // Opm::data
|
||||||
|
|
||||||
#endif // OPM_OUTPUT_AQUIFER_HPP
|
#endif // OPM_OUTPUT_AQUIFER_HPP
|
||||||
|
|||||||
@@ -36,10 +36,10 @@ namespace data {
|
|||||||
from the TargetType enum which indicates why they they have been
|
from the TargetType enum which indicates why they they have been
|
||||||
added to the container - and where they are headed.
|
added to the container - and where they are headed.
|
||||||
|
|
||||||
RESTART_SOLUTION : Cell-based quantities that are output to the
|
RESTART_SOLUTION : Fields which represent primary variables, and
|
||||||
SOLUTION section of the restart file. ECLIPSE-compatible names.
|
are reqired for restart. Typically pressure and
|
||||||
Many, but not necessarily all, of these quantities are required
|
suturation. WIll end up in the SOLUTION section of the restart
|
||||||
for restarting the simulator.
|
file.
|
||||||
|
|
||||||
RESTART_AUXILIARY : Fields with extra information, not required
|
RESTART_AUXILIARY : Fields with extra information, not required
|
||||||
for restart. Examples of this include fluid in place values or
|
for restart. Examples of this include fluid in place values or
|
||||||
@@ -52,10 +52,6 @@ namespace data {
|
|||||||
will not be output anywhere else.
|
will not be output anywhere else.
|
||||||
|
|
||||||
INIT : Fields which should go to the INIT file.
|
INIT : Fields which should go to the INIT file.
|
||||||
|
|
||||||
RESTART_OPM_EXTENDED: Cell-based quantities that are specific to
|
|
||||||
OPM-Flow. Output only to extended OPM restart files. Specifically
|
|
||||||
not output to ECLIPSE-compatible restart files.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -64,7 +60,6 @@ namespace data {
|
|||||||
RESTART_AUXILIARY,
|
RESTART_AUXILIARY,
|
||||||
SUMMARY,
|
SUMMARY,
|
||||||
INIT,
|
INIT,
|
||||||
RESTART_OPM_EXTENDED,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,173 +20,63 @@
|
|||||||
#ifndef OPM_OUTPUT_GROUPS_HPP
|
#ifndef OPM_OUTPUT_GROUPS_HPP
|
||||||
#define OPM_OUTPUT_GROUPS_HPP
|
#define OPM_OUTPUT_GROUPS_HPP
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <initializer_list>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <type_traits>
|
||||||
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <opm/output/data/GuideRateValue.hpp>
|
|
||||||
|
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp>
|
||||||
|
|
||||||
namespace Opm { namespace data {
|
namespace Opm {
|
||||||
|
|
||||||
struct GroupConstraints {
|
namespace data {
|
||||||
|
|
||||||
|
struct currentGroupConstraints {
|
||||||
Opm::Group::ProductionCMode currentProdConstraint;
|
Opm::Group::ProductionCMode currentProdConstraint;
|
||||||
Opm::Group::InjectionCMode currentGasInjectionConstraint;
|
Opm::Group::InjectionCMode currentGasInjectionConstraint;
|
||||||
Opm::Group::InjectionCMode currentWaterInjectionConstraint;
|
Opm::Group::InjectionCMode currentWaterInjectionConstraint;
|
||||||
|
|
||||||
template <class MessageBufferType>
|
template <class MessageBufferType>
|
||||||
void write(MessageBufferType& buffer) const;
|
void write(MessageBufferType& buffer) const;
|
||||||
|
|
||||||
template <class MessageBufferType>
|
template <class MessageBufferType>
|
||||||
void read(MessageBufferType& buffer);
|
void read(MessageBufferType& buffer);
|
||||||
|
|
||||||
bool operator==(const GroupConstraints& other) const
|
inline currentGroupConstraints& set( Opm::Group::ProductionCMode cpc,
|
||||||
{
|
Opm::Group::InjectionCMode cgic,
|
||||||
return this->currentProdConstraint == other.currentProdConstraint &&
|
Opm::Group::InjectionCMode cwic);
|
||||||
this->currentGasInjectionConstraint == other.currentGasInjectionConstraint &&
|
|
||||||
this->currentWaterInjectionConstraint == other.currentWaterInjectionConstraint;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline GroupConstraints& set(Opm::Group::ProductionCMode cpc,
|
|
||||||
Opm::Group::InjectionCMode cgic,
|
|
||||||
Opm::Group::InjectionCMode cwic);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GroupGuideRates {
|
|
||||||
GuideRateValue production{};
|
|
||||||
GuideRateValue injection{};
|
|
||||||
|
|
||||||
template <class MessageBufferType>
|
class Group : public std::map<std::string, Opm::data::currentGroupConstraints> {
|
||||||
void write(MessageBufferType& buffer) const
|
|
||||||
{
|
|
||||||
this->production.write(buffer);
|
|
||||||
this->injection .write(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class MessageBufferType>
|
|
||||||
void read(MessageBufferType& buffer)
|
|
||||||
{
|
|
||||||
this->production.read(buffer);
|
|
||||||
this->injection .read(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const GroupGuideRates& other) const
|
|
||||||
{
|
|
||||||
return this->production == other.production
|
|
||||||
&& this->injection == other.injection;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct GroupData {
|
|
||||||
GroupConstraints currentControl;
|
|
||||||
GroupGuideRates guideRates{};
|
|
||||||
|
|
||||||
template <class MessageBufferType>
|
|
||||||
void write(MessageBufferType& buffer) const
|
|
||||||
{
|
|
||||||
this->currentControl.write(buffer);
|
|
||||||
this->guideRates .write(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class MessageBufferType>
|
|
||||||
void read(MessageBufferType& buffer)
|
|
||||||
{
|
|
||||||
this->currentControl.read(buffer);
|
|
||||||
this->guideRates .read(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const GroupData& other) const
|
|
||||||
{
|
|
||||||
return this->currentControl == other.currentControl
|
|
||||||
&& this->guideRates == other.guideRates;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct NodeData {
|
|
||||||
double pressure { 0.0 };
|
|
||||||
|
|
||||||
template <class MessageBufferType>
|
|
||||||
void write(MessageBufferType& buffer) const
|
|
||||||
{
|
|
||||||
buffer.write(this->pressure);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class MessageBufferType>
|
|
||||||
void read(MessageBufferType& buffer)
|
|
||||||
{
|
|
||||||
buffer.read(this->pressure);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const NodeData& other) const
|
|
||||||
{
|
|
||||||
return this->pressure == other.pressure;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class GroupAndNetworkValues {
|
|
||||||
public:
|
public:
|
||||||
std::map<std::string, GroupData> groupData {};
|
|
||||||
std::map<std::string, NodeData> nodeData {};
|
|
||||||
|
|
||||||
template <class MessageBufferType>
|
template <class MessageBufferType>
|
||||||
void write(MessageBufferType& buffer) const
|
void write(MessageBufferType& buffer) const {
|
||||||
{
|
unsigned int size = this->size();
|
||||||
this->writeMap(this->groupData, buffer);
|
|
||||||
this->writeMap(this->nodeData, buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class MessageBufferType>
|
|
||||||
void read(MessageBufferType& buffer)
|
|
||||||
{
|
|
||||||
this->readMap(buffer, this->groupData);
|
|
||||||
this->readMap(buffer, this->nodeData);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const GroupAndNetworkValues& other) const
|
|
||||||
{
|
|
||||||
return (this->groupData == other.groupData)
|
|
||||||
&& (this->nodeData == other.nodeData);
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear()
|
|
||||||
{
|
|
||||||
this->groupData.clear();
|
|
||||||
this->nodeData.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
template <class MessageBufferType, class ValueType>
|
|
||||||
void writeMap(const std::map<std::string, ValueType>& map,
|
|
||||||
MessageBufferType& buffer) const
|
|
||||||
{
|
|
||||||
const unsigned int size = map.size();
|
|
||||||
buffer.write(size);
|
buffer.write(size);
|
||||||
|
for (const auto& witr : *this) {
|
||||||
for (const auto& [name, elm] : map) {
|
const std::string& name = witr.first;
|
||||||
buffer.write(name);
|
buffer.write(name);
|
||||||
elm .write(buffer);
|
const auto& pi_constr = witr.second;
|
||||||
|
pi_constr.write(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class MessageBufferType, class ValueType>
|
template <class MessageBufferType>
|
||||||
void readMap(MessageBufferType& buffer,
|
void read(MessageBufferType& buffer) {
|
||||||
std::map<std::string, ValueType>& map)
|
unsigned int size;
|
||||||
{
|
|
||||||
unsigned int size;
|
|
||||||
buffer.read(size);
|
buffer.read(size);
|
||||||
|
for (size_t i = 0; i < size; ++i) {
|
||||||
for (std::size_t i = 0; i < size; ++i) {
|
|
||||||
std::string name;
|
std::string name;
|
||||||
buffer.read(name);
|
buffer.read(name);
|
||||||
|
currentGroupConstraints cgc;
|
||||||
auto elm = ValueType{};
|
cgc.read(buffer);
|
||||||
elm.read(buffer);
|
this->emplace(name, cgc);
|
||||||
|
|
||||||
map.emplace(name, std::move(elm));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -194,28 +84,26 @@ namespace Opm { namespace data {
|
|||||||
/* IMPLEMENTATIONS */
|
/* IMPLEMENTATIONS */
|
||||||
|
|
||||||
template <class MessageBufferType>
|
template <class MessageBufferType>
|
||||||
void GroupConstraints::write(MessageBufferType& buffer) const {
|
void currentGroupConstraints::write(MessageBufferType& buffer) const {
|
||||||
buffer.write(this->currentProdConstraint);
|
buffer.write(this->currentProdConstraint);
|
||||||
buffer.write(this->currentGasInjectionConstraint);
|
buffer.write(this->currentGasInjectionConstraint);
|
||||||
buffer.write(this->currentWaterInjectionConstraint);
|
buffer.write(this->currentWaterInjectionConstraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class MessageBufferType>
|
template <class MessageBufferType>
|
||||||
void GroupConstraints::read(MessageBufferType& buffer) {
|
void currentGroupConstraints::read(MessageBufferType& buffer) {
|
||||||
buffer.read(this->currentProdConstraint);
|
buffer.read(this->currentProdConstraint);
|
||||||
buffer.read(this->currentGasInjectionConstraint);
|
buffer.read(this->currentGasInjectionConstraint);
|
||||||
buffer.read(this->currentWaterInjectionConstraint);
|
buffer.read(this->currentWaterInjectionConstraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline GroupConstraints&
|
|
||||||
GroupConstraints::set(Opm::Group::ProductionCMode cpc,
|
inline currentGroupConstraints& currentGroupConstraints::set( Opm::Group::ProductionCMode cpc,
|
||||||
Opm::Group::InjectionCMode cgic,
|
Opm::Group::InjectionCMode cgic,
|
||||||
Opm::Group::InjectionCMode cwic)
|
Opm::Group::InjectionCMode cwic) {
|
||||||
{
|
|
||||||
this->currentGasInjectionConstraint = cgic;
|
this->currentGasInjectionConstraint = cgic;
|
||||||
this->currentWaterInjectionConstraint = cwic;
|
this->currentWaterInjectionConstraint = cwic;
|
||||||
this->currentProdConstraint = cpc;
|
this->currentProdConstraint = cpc;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,156 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (c) 2020 Equinor ASA
|
|
||||||
|
|
||||||
This file is part of the Open Porous Media project (OPM).
|
|
||||||
|
|
||||||
OPM is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OPM is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef OPM_OUTPUT_DATA_GUIDERATEVALUE_HPP
|
|
||||||
#define OPM_OUTPUT_DATA_GUIDERATEVALUE_HPP
|
|
||||||
|
|
||||||
#include <array>
|
|
||||||
#include <bitset>
|
|
||||||
#include <cstddef>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace Opm { namespace data {
|
|
||||||
|
|
||||||
class GuideRateValue {
|
|
||||||
public:
|
|
||||||
enum class Item : std::size_t {
|
|
||||||
Oil, Gas, Water, ResV,
|
|
||||||
|
|
||||||
// -- Must be last enumerator --
|
|
||||||
NumItems,
|
|
||||||
};
|
|
||||||
|
|
||||||
void clear()
|
|
||||||
{
|
|
||||||
this->mask_.reset();
|
|
||||||
this->value_.fill(0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr bool has(const Item p) const
|
|
||||||
{
|
|
||||||
const auto i = this->index(p);
|
|
||||||
|
|
||||||
return (i < Size) && this->mask_[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const GuideRateValue& vec) const
|
|
||||||
{
|
|
||||||
return (this->mask_ == vec.mask_)
|
|
||||||
&& (this->value_ == vec.value_);
|
|
||||||
}
|
|
||||||
|
|
||||||
double get(const Item p) const
|
|
||||||
{
|
|
||||||
if (! this->has(p)) {
|
|
||||||
throw std::invalid_argument {
|
|
||||||
"Request for Unset Item Value for " + this->itemName(p)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return this->value_[ this->index(p) ];
|
|
||||||
}
|
|
||||||
|
|
||||||
GuideRateValue& set(const Item p, const double value)
|
|
||||||
{
|
|
||||||
const auto i = this->index(p);
|
|
||||||
|
|
||||||
if (i >= Size) {
|
|
||||||
throw std::invalid_argument {
|
|
||||||
"Cannot Assign Item Value for Unsupported Item '"
|
|
||||||
+ this->itemName(p) + '\''
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
this->mask_.set(i);
|
|
||||||
this->value_[i] = value;
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
GuideRateValue& operator+=(const GuideRateValue& rhs)
|
|
||||||
{
|
|
||||||
for (auto i = 0*Size; i < Size; ++i) {
|
|
||||||
if (rhs.mask_[i]) {
|
|
||||||
this->mask_.set(i);
|
|
||||||
this->value_[i] += rhs.value_[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class MessageBufferType>
|
|
||||||
void write(MessageBufferType& buffer) const
|
|
||||||
{
|
|
||||||
auto maskrep = this->mask_.to_ullong();
|
|
||||||
buffer.write(maskrep);
|
|
||||||
|
|
||||||
for (const auto& x : this->value_) {
|
|
||||||
buffer.write(x);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class MessageBufferType>
|
|
||||||
void read(MessageBufferType& buffer)
|
|
||||||
{
|
|
||||||
this->clear();
|
|
||||||
|
|
||||||
{
|
|
||||||
auto mask = 0ull;
|
|
||||||
buffer.read(mask);
|
|
||||||
|
|
||||||
this->mask_ = std::bitset<Size>(mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto& x : this->value_) {
|
|
||||||
buffer.read(x);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
enum { Size = static_cast<std::size_t>(Item::NumItems) };
|
|
||||||
|
|
||||||
std::bitset<Size> mask_{};
|
|
||||||
std::array<double, Size> value_{};
|
|
||||||
|
|
||||||
constexpr std::size_t index(const Item p) const noexcept
|
|
||||||
{
|
|
||||||
return static_cast<std::size_t>(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string itemName(const Item p) const
|
|
||||||
{
|
|
||||||
switch (p) {
|
|
||||||
case Item::Oil: return "Oil";
|
|
||||||
case Item::Gas: return "Gas";
|
|
||||||
case Item::Water: return "Water";
|
|
||||||
case Item::ResV: return "ResV";
|
|
||||||
|
|
||||||
case Item::NumItems:
|
|
||||||
return "Out of bounds (NumItems)";
|
|
||||||
}
|
|
||||||
|
|
||||||
return "Unknown (" + std::to_string(this->index(p)) + ')';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}} // namespace Opm::data
|
|
||||||
|
|
||||||
#endif // OPM_OUTPUT_DATA_GUIDERATEVALUE_HPP
|
|
||||||
@@ -30,8 +30,6 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <opm/output/data/GuideRateValue.hpp>
|
|
||||||
|
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp>
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
@@ -68,8 +66,6 @@ namespace Opm {
|
|||||||
well_potential_water = (1 << 14),
|
well_potential_water = (1 << 14),
|
||||||
well_potential_oil = (1 << 15),
|
well_potential_oil = (1 << 15),
|
||||||
well_potential_gas = (1 << 16),
|
well_potential_gas = (1 << 16),
|
||||||
brine = (1 << 17),
|
|
||||||
alq = (1 << 18)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
using enum_size = std::underlying_type< opt >::type;
|
using enum_size = std::underlying_type< opt >::type;
|
||||||
@@ -121,8 +117,6 @@ namespace Opm {
|
|||||||
double well_potential_water = 0.0;
|
double well_potential_water = 0.0;
|
||||||
double well_potential_oil = 0.0;
|
double well_potential_oil = 0.0;
|
||||||
double well_potential_gas = 0.0;
|
double well_potential_gas = 0.0;
|
||||||
double brine = 0.0;
|
|
||||||
double alq = 0.0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Connection {
|
struct Connection {
|
||||||
@@ -137,7 +131,6 @@ namespace Opm {
|
|||||||
double cell_saturation_water;
|
double cell_saturation_water;
|
||||||
double cell_saturation_gas;
|
double cell_saturation_gas;
|
||||||
double effective_Kh;
|
double effective_Kh;
|
||||||
double trans_factor;
|
|
||||||
|
|
||||||
bool operator==(const Connection& conn2) const
|
bool operator==(const Connection& conn2) const
|
||||||
{
|
{
|
||||||
@@ -258,7 +251,6 @@ namespace Opm {
|
|||||||
std::vector< Connection > connections;
|
std::vector< Connection > connections;
|
||||||
std::unordered_map<std::size_t, Segment> segments;
|
std::unordered_map<std::size_t, Segment> segments;
|
||||||
CurrentControl current_control;
|
CurrentControl current_control;
|
||||||
GuideRateValue guide_rates{};
|
|
||||||
|
|
||||||
inline bool flowing() const noexcept;
|
inline bool flowing() const noexcept;
|
||||||
template <class MessageBufferType>
|
template <class MessageBufferType>
|
||||||
@@ -299,8 +291,7 @@ namespace Opm {
|
|||||||
control == well2.control &&
|
control == well2.control &&
|
||||||
connections == well2.connections &&
|
connections == well2.connections &&
|
||||||
segments == well2.segments &&
|
segments == well2.segments &&
|
||||||
current_control == well2.current_control &&
|
current_control == well2.current_control;
|
||||||
guide_rates == well2.guide_rates;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -413,9 +404,7 @@ namespace Opm {
|
|||||||
productivity_index_oil == rate.productivity_index_oil &&
|
productivity_index_oil == rate.productivity_index_oil &&
|
||||||
well_potential_water == rate.well_potential_water &&
|
well_potential_water == rate.well_potential_water &&
|
||||||
well_potential_oil == rate.well_potential_oil &&
|
well_potential_oil == rate.well_potential_oil &&
|
||||||
well_potential_gas == rate.well_potential_gas &&
|
well_potential_gas == rate.well_potential_gas;
|
||||||
brine == rate.brine &&
|
|
||||||
alq == rate.alq;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -447,8 +436,6 @@ namespace Opm {
|
|||||||
case opt::well_potential_water: return this->well_potential_water;
|
case opt::well_potential_water: return this->well_potential_water;
|
||||||
case opt::well_potential_oil: return this->well_potential_oil;
|
case opt::well_potential_oil: return this->well_potential_oil;
|
||||||
case opt::well_potential_gas: return this->well_potential_gas;
|
case opt::well_potential_gas: return this->well_potential_gas;
|
||||||
case opt::brine: return this->brine;
|
|
||||||
case opt::alq: return this->alq;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw std::invalid_argument(
|
throw std::invalid_argument(
|
||||||
@@ -495,8 +482,6 @@ namespace Opm {
|
|||||||
buffer.write(this->well_potential_water);
|
buffer.write(this->well_potential_water);
|
||||||
buffer.write(this->well_potential_oil);
|
buffer.write(this->well_potential_oil);
|
||||||
buffer.write(this->well_potential_gas);
|
buffer.write(this->well_potential_gas);
|
||||||
buffer.write(this->brine);
|
|
||||||
buffer.write(this->alq);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class MessageBufferType>
|
template <class MessageBufferType>
|
||||||
@@ -509,7 +494,6 @@ namespace Opm {
|
|||||||
buffer.write(this->cell_saturation_water);
|
buffer.write(this->cell_saturation_water);
|
||||||
buffer.write(this->cell_saturation_gas);
|
buffer.write(this->cell_saturation_gas);
|
||||||
buffer.write(this->effective_Kh);
|
buffer.write(this->effective_Kh);
|
||||||
buffer.write(this->trans_factor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class MessageBufferType>
|
template <class MessageBufferType>
|
||||||
@@ -554,7 +538,6 @@ namespace Opm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->current_control.write(buffer);
|
this->current_control.write(buffer);
|
||||||
this->guide_rates.write(buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class MessageBufferType>
|
template <class MessageBufferType>
|
||||||
@@ -577,8 +560,6 @@ namespace Opm {
|
|||||||
buffer.read(this->well_potential_water);
|
buffer.read(this->well_potential_water);
|
||||||
buffer.read(this->well_potential_oil);
|
buffer.read(this->well_potential_oil);
|
||||||
buffer.read(this->well_potential_gas);
|
buffer.read(this->well_potential_gas);
|
||||||
buffer.read(this->brine);
|
|
||||||
buffer.read(this->alq);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class MessageBufferType>
|
template <class MessageBufferType>
|
||||||
@@ -591,7 +572,6 @@ namespace Opm {
|
|||||||
buffer.read(this->cell_saturation_water);
|
buffer.read(this->cell_saturation_water);
|
||||||
buffer.read(this->cell_saturation_gas);
|
buffer.read(this->cell_saturation_gas);
|
||||||
buffer.read(this->effective_Kh);
|
buffer.read(this->effective_Kh);
|
||||||
buffer.read(this->trans_factor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class MessageBufferType>
|
template <class MessageBufferType>
|
||||||
@@ -649,7 +629,6 @@ namespace Opm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->current_control.read(buffer);
|
this->current_control.read(buffer);
|
||||||
this->guide_rates.read(buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}} // Opm::data
|
}} // Opm::data
|
||||||
|
|||||||
@@ -41,10 +41,6 @@ namespace Opm {
|
|||||||
class Schedule;
|
class Schedule;
|
||||||
class UDQInput;
|
class UDQInput;
|
||||||
class UDQActive;
|
class UDQActive;
|
||||||
|
|
||||||
namespace Action {
|
|
||||||
class State;
|
|
||||||
}
|
|
||||||
} // Opm
|
} // Opm
|
||||||
|
|
||||||
|
|
||||||
@@ -56,11 +52,10 @@ class AggregateActionxData
|
|||||||
public:
|
public:
|
||||||
explicit AggregateActionxData(const std::vector<int>& actDims);
|
explicit AggregateActionxData(const std::vector<int>& actDims);
|
||||||
|
|
||||||
void captureDeclaredActionxData( const Opm::Schedule& sched,
|
void captureDeclaredActionxData( const Opm::Schedule& sched,
|
||||||
const Opm::Action::State& action_state,
|
const Opm::SummaryState& st,
|
||||||
const Opm::SummaryState& st,
|
const std::vector<int>& actDims,
|
||||||
const std::vector<int>& actDims,
|
const std::size_t simStep);
|
||||||
const std::size_t simStep);
|
|
||||||
|
|
||||||
const std::vector<int>& getIACT() const
|
const std::vector<int>& getIACT() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -74,12 +74,8 @@ public:
|
|||||||
"GOPT", "GWPT", "GGPT", "GVPT", "GWIT",
|
"GOPT", "GWPT", "GGPT", "GVPT", "GWIT",
|
||||||
"GGIT", "GVIT",
|
"GGIT", "GVIT",
|
||||||
"GOPTH", "GWPTH", "GGPTH",
|
"GOPTH", "GWPTH", "GGPTH",
|
||||||
"GWITH", "GGITH",
|
"GWITH", "GGITH"};
|
||||||
"GOPGR", "GWPGR", "GGPGR", "GVPGR",
|
|
||||||
"GOIGR", "GWIGR", "GGIGR",
|
|
||||||
};
|
|
||||||
|
|
||||||
// Note: guide rates don't exist at the FIELD level.
|
|
||||||
const std::vector<std::string> restart_field_keys = {"FOPP", "FWPP", "FOPR", "FWPR", "FGPR",
|
const std::vector<std::string> restart_field_keys = {"FOPP", "FWPP", "FOPR", "FWPR", "FGPR",
|
||||||
"FVPR", "FWIR", "FGIR", "FWCT", "FGOR",
|
"FVPR", "FWIR", "FGIR", "FWCT", "FGOR",
|
||||||
"FOPT", "FWPT", "FGPT", "FVPT", "FWIT",
|
"FOPT", "FWPT", "FGPT", "FVPT", "FWIT",
|
||||||
@@ -105,13 +101,6 @@ public:
|
|||||||
{"GVIT", 17},
|
{"GVIT", 17},
|
||||||
{"GOPP", 22},
|
{"GOPP", 22},
|
||||||
{"GWPP", 23},
|
{"GWPP", 23},
|
||||||
{"GOPGR", 85},
|
|
||||||
{"GWPGR", 86},
|
|
||||||
{"GGPGR", 87},
|
|
||||||
{"GVPGR", 88},
|
|
||||||
{"GOIGR", 89},
|
|
||||||
{"GWIGR", 91},
|
|
||||||
{"GGIGR", 93},
|
|
||||||
{"GOPTH", 135},
|
{"GOPTH", 135},
|
||||||
{"GWPTH", 139},
|
{"GWPTH", 139},
|
||||||
{"GWITH", 140},
|
{"GWITH", 140},
|
||||||
@@ -132,26 +121,6 @@ public:
|
|||||||
{inj_cmode_enum::SALE, 0},
|
{inj_cmode_enum::SALE, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Note: guide rates don't exist at the FIELD level.
|
|
||||||
const std::map<int, inj_cmode_enum> ICntlModeToiCMode = {
|
|
||||||
{0, inj_cmode_enum::NONE},
|
|
||||||
{1, inj_cmode_enum::RATE},
|
|
||||||
{2, inj_cmode_enum::RESV},
|
|
||||||
{3, inj_cmode_enum::REIN},
|
|
||||||
{4, inj_cmode_enum::VREP}, };
|
|
||||||
|
|
||||||
using p_cmode = Opm::Group::ProductionCMode;
|
|
||||||
const std::map<int, p_cmode> PCntlModeToPCMode = {
|
|
||||||
{0, p_cmode::NONE},
|
|
||||||
{1, p_cmode::ORAT},
|
|
||||||
{2, p_cmode::WRAT},
|
|
||||||
{3, p_cmode::GRAT},
|
|
||||||
{4, p_cmode::LRAT},
|
|
||||||
{9, p_cmode::CRAT},
|
|
||||||
{5, p_cmode::RESV},
|
|
||||||
{6, p_cmode::PRBL},
|
|
||||||
};
|
|
||||||
|
|
||||||
const std::map<std::string, size_t> fieldKeyToIndex = {
|
const std::map<std::string, size_t> fieldKeyToIndex = {
|
||||||
{"FOPR", 0},
|
{"FOPR", 0},
|
||||||
{"FWPR", 1},
|
{"FWPR", 1},
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ namespace Opm {
|
|||||||
class Schedule;
|
class Schedule;
|
||||||
class UDQInput;
|
class UDQInput;
|
||||||
class UDQActive;
|
class UDQActive;
|
||||||
class UDQState;
|
|
||||||
} // Opm
|
} // Opm
|
||||||
|
|
||||||
namespace Opm { namespace RestartIO { namespace Helpers {
|
namespace Opm { namespace RestartIO { namespace Helpers {
|
||||||
@@ -58,7 +57,7 @@ public:
|
|||||||
|
|
||||||
void captureDeclaredUDQData(const Opm::Schedule& sched,
|
void captureDeclaredUDQData(const Opm::Schedule& sched,
|
||||||
const std::size_t simStep,
|
const std::size_t simStep,
|
||||||
const Opm::UDQState& udqState,
|
const Opm::SummaryState& st,
|
||||||
const std::vector<int>& inteHead);
|
const std::vector<int>& inteHead);
|
||||||
|
|
||||||
const std::vector<int>& getIUDQ() const
|
const std::vector<int>& getIUDQ() const
|
||||||
@@ -95,12 +94,12 @@ void captureDeclaredUDQData(const Opm::Schedule& sched,
|
|||||||
{
|
{
|
||||||
return this->dUDW_.data();
|
return this->dUDW_.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<double>& getDUDG() const
|
const std::vector<double>& getDUDG() const
|
||||||
{
|
{
|
||||||
return this->dUDG_.data();
|
return this->dUDG_.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<double>& getDUDF() const
|
const std::vector<double>& getDUDF() const
|
||||||
{
|
{
|
||||||
return this->dUDF_.data();
|
return this->dUDF_.data();
|
||||||
@@ -128,10 +127,10 @@ private:
|
|||||||
|
|
||||||
/// Aggregate 'DUDW' array (Double Precision) for all UDQ data. (Dimension = max no wells * noOfUDQ's)
|
/// Aggregate 'DUDW' array (Double Precision) for all UDQ data. (Dimension = max no wells * noOfUDQ's)
|
||||||
WindowedArray<double> dUDW_;
|
WindowedArray<double> dUDW_;
|
||||||
|
|
||||||
/// Aggregate 'DUDG' array (Double Precision) for all UDQ data. (Dimension = (max no groups + 1) * noOfUDQ's)
|
/// Aggregate 'DUDG' array (Double Precision) for all UDQ data. (Dimension = (max no groups + 1) * noOfUDQ's)
|
||||||
WindowedArray<double> dUDG_;
|
WindowedArray<double> dUDG_;
|
||||||
|
|
||||||
/// Aggregate 'DUDF' array (Double Precision) for all UDQ data. (Dimension = Number of FU - UDQ's, with value equal to the actual constraint)
|
/// Aggregate 'DUDF' array (Double Precision) for all UDQ data. (Dimension = Number of FU - UDQ's, with value equal to the actual constraint)
|
||||||
WindowedArray<double> dUDF_;
|
WindowedArray<double> dUDF_;
|
||||||
|
|
||||||
|
|||||||
@@ -33,9 +33,6 @@ namespace Opm {
|
|||||||
class Schedule;
|
class Schedule;
|
||||||
class SummaryState;
|
class SummaryState;
|
||||||
class UnitSystem;
|
class UnitSystem;
|
||||||
namespace Action {
|
|
||||||
class State;
|
|
||||||
}
|
|
||||||
} // Opm
|
} // Opm
|
||||||
|
|
||||||
namespace Opm { namespace data {
|
namespace Opm { namespace data {
|
||||||
@@ -43,18 +40,22 @@ namespace Opm { namespace data {
|
|||||||
}} // Opm::data
|
}} // Opm::data
|
||||||
|
|
||||||
namespace Opm { namespace RestartIO { namespace Helpers {
|
namespace Opm { namespace RestartIO { namespace Helpers {
|
||||||
|
|
||||||
|
struct ActionResStatus {
|
||||||
|
std::vector<Opm::Action::Result> result;
|
||||||
|
std::vector<std::string> name;
|
||||||
|
};
|
||||||
|
|
||||||
class AggregateWellData
|
class AggregateWellData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit AggregateWellData(const std::vector<int>& inteHead);
|
explicit AggregateWellData(const std::vector<int>& inteHead);
|
||||||
|
|
||||||
void captureDeclaredWellData(const Schedule& sched,
|
void captureDeclaredWellData(const Schedule& sched,
|
||||||
const UnitSystem& units,
|
const UnitSystem& units,
|
||||||
const std::size_t sim_step,
|
const std::size_t sim_step,
|
||||||
const ::Opm::Action::State& action_state,
|
const ::Opm::SummaryState& smry,
|
||||||
const ::Opm::SummaryState& smry,
|
const std::vector<int>& inteHead);
|
||||||
const std::vector<int>& inteHead);
|
|
||||||
|
|
||||||
void captureDynamicWellData(const Opm::Schedule& sched,
|
void captureDynamicWellData(const Opm::Schedule& sched,
|
||||||
const std::size_t sim_step,
|
const std::size_t sim_step,
|
||||||
@@ -85,8 +86,8 @@ namespace Opm { namespace RestartIO { namespace Helpers {
|
|||||||
return this->zWell_.data();
|
return this->zWell_.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Aggregate 'IWEL' array (Integer) for all wells.
|
/// Aggregate 'IWEL' array (Integer) for all wells.
|
||||||
WindowedArray<int> iWell_;
|
WindowedArray<int> iWell_;
|
||||||
|
|||||||
@@ -45,8 +45,7 @@ class EclipseState;
|
|||||||
class Schedule;
|
class Schedule;
|
||||||
class SummaryConfig;
|
class SummaryConfig;
|
||||||
class SummaryState;
|
class SummaryState;
|
||||||
class UDQState;
|
|
||||||
namespace Action { class State; }
|
|
||||||
/*!
|
/*!
|
||||||
* \brief A class to write the reservoir state and the well state of a
|
* \brief A class to write the reservoir state and the well state of a
|
||||||
* blackoil simulation to disk using the Eclipse binary format.
|
* blackoil simulation to disk using the Eclipse binary format.
|
||||||
@@ -175,9 +174,7 @@ public:
|
|||||||
* hardcoded static map misc_units in Summary.cpp.
|
* hardcoded static map misc_units in Summary.cpp.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void writeTimeStep( const Action::State& action_state,
|
void writeTimeStep( const SummaryState& st,
|
||||||
const SummaryState& st,
|
|
||||||
const UDQState& udq_state,
|
|
||||||
int report_step,
|
int report_step,
|
||||||
bool isSubstep,
|
bool isSubstep,
|
||||||
double seconds_elapsed,
|
double seconds_elapsed,
|
||||||
@@ -223,7 +220,7 @@ public:
|
|||||||
missing, if the bool is false missing keywords will be ignored
|
missing, if the bool is false missing keywords will be ignored
|
||||||
(there will *not* be an empty vector in the return value).
|
(there will *not* be an empty vector in the return value).
|
||||||
*/
|
*/
|
||||||
RestartValue loadRestart(Action::State& action_state, SummaryState& summary_state, const std::vector<RestartKey>& solution_keys, const std::vector<RestartKey>& extra_keys = {}) const;
|
RestartValue loadRestart(SummaryState& summary_state, const std::vector<RestartKey>& solution_keys, const std::vector<RestartKey>& extra_keys = {}) const;
|
||||||
const out::Summary& summary();
|
const out::Summary& summary();
|
||||||
|
|
||||||
EclipseIO( const EclipseIO& ) = delete;
|
EclipseIO( const EclipseIO& ) = delete;
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ namespace RestartIO {
|
|||||||
int litmin;
|
int litmin;
|
||||||
int mxwsit;
|
int mxwsit;
|
||||||
int mxwpit;
|
int mxwpit;
|
||||||
int wseg_mx_rst;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Group {
|
struct Group {
|
||||||
|
|||||||
@@ -20,25 +20,23 @@
|
|||||||
#ifndef OPM_REGION_CACHE_HPP
|
#ifndef OPM_REGION_CACHE_HPP
|
||||||
#define OPM_REGION_CACHE_HPP
|
#define OPM_REGION_CACHE_HPP
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <set>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
class Schedule;
|
class Schedule;
|
||||||
class EclipseGrid;
|
class EclipseGrid;
|
||||||
class FieldPropsManager;
|
|
||||||
|
|
||||||
namespace out {
|
namespace out {
|
||||||
class RegionCache {
|
class RegionCache {
|
||||||
public:
|
public:
|
||||||
RegionCache() = default;
|
RegionCache() = default;
|
||||||
RegionCache(const std::set<std::string>& fip_regions, const FieldPropsManager& fp, const EclipseGrid& grid, const Schedule& schedule);
|
RegionCache(const std::vector<int>& fipnum, const EclipseGrid& grid, const Schedule& schedule);
|
||||||
const std::vector<std::pair<std::string,size_t>>& connections( const std::string& region_name, int region_id ) const;
|
const std::vector<std::pair<std::string,size_t>>& connections( int region_id ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::pair<std::string,size_t>> connections_empty;
|
std::vector<std::pair<std::string,size_t>> connections_empty;
|
||||||
std::map<std::pair<std::string, int> , std::vector<std::pair<std::string,size_t>>> connection_map;
|
|
||||||
|
std::map<int , std::vector<std::pair<std::string,size_t>>> connection_map;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include <opm/output/eclipse/RestartValue.hpp>
|
#include <opm/output/eclipse/RestartValue.hpp>
|
||||||
|
|
||||||
|
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@@ -36,8 +37,6 @@ namespace Opm {
|
|||||||
class EclipseGrid;
|
class EclipseGrid;
|
||||||
class EclipseState;
|
class EclipseState;
|
||||||
class Schedule;
|
class Schedule;
|
||||||
class UDQState;
|
|
||||||
class SummaryState;
|
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
|
||||||
@@ -47,12 +46,6 @@ namespace Opm { namespace EclIO { namespace OutputStream {
|
|||||||
|
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
namespace Opm { namespace Action {
|
|
||||||
|
|
||||||
class State;
|
|
||||||
|
|
||||||
}}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The two free functions RestartIO::save() and RestartIO::load() can
|
The two free functions RestartIO::save() and RestartIO::load() can
|
||||||
be used to save and load reservoir and well state from restart
|
be used to save and load reservoir and well state from restart
|
||||||
@@ -83,15 +76,12 @@ namespace Opm { namespace RestartIO {
|
|||||||
const EclipseState& es,
|
const EclipseState& es,
|
||||||
const EclipseGrid& grid,
|
const EclipseGrid& grid,
|
||||||
const Schedule& schedule,
|
const Schedule& schedule,
|
||||||
const Action::State& action_state,
|
|
||||||
const SummaryState& sumState,
|
const SummaryState& sumState,
|
||||||
const UDQState& udqState,
|
|
||||||
bool write_double = false);
|
bool write_double = false);
|
||||||
|
|
||||||
|
|
||||||
RestartValue load(const std::string& filename,
|
RestartValue load(const std::string& filename,
|
||||||
int report_step,
|
int report_step,
|
||||||
Action::State& action_state,
|
|
||||||
SummaryState& summary_state,
|
SummaryState& summary_state,
|
||||||
const std::vector<RestartKey>& solution_keys,
|
const std::vector<RestartKey>& solution_keys,
|
||||||
const EclipseState& es,
|
const EclipseState& es,
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
#include <opm/output/data/Aquifer.hpp>
|
#include <opm/output/data/Aquifer.hpp>
|
||||||
#include <opm/output/data/Solution.hpp>
|
#include <opm/output/data/Solution.hpp>
|
||||||
#include <opm/output/data/Wells.hpp>
|
#include <opm/output/data/Wells.hpp>
|
||||||
#include <opm/output/data/Groups.hpp>
|
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
|
|
||||||
@@ -71,11 +70,10 @@ namespace Opm {
|
|||||||
using ExtraVector = std::vector<std::pair<RestartKey, std::vector<double>>>;
|
using ExtraVector = std::vector<std::pair<RestartKey, std::vector<double>>>;
|
||||||
data::Solution solution;
|
data::Solution solution;
|
||||||
data::Wells wells;
|
data::Wells wells;
|
||||||
data::GroupAndNetworkValues grp_nwrk;
|
|
||||||
ExtraVector extra;
|
ExtraVector extra;
|
||||||
std::vector<data::AquiferData> aquifer;
|
std::vector<data::AquiferData> aquifer;
|
||||||
|
|
||||||
RestartValue(data::Solution sol, data::Wells wells_arg, data::GroupAndNetworkValues grpn_nwrk_arg);
|
RestartValue(data::Solution sol, data::Wells wells_arg);
|
||||||
|
|
||||||
RestartValue() {}
|
RestartValue() {}
|
||||||
|
|
||||||
@@ -91,7 +89,6 @@ namespace Opm {
|
|||||||
{
|
{
|
||||||
return solution == val2.solution &&
|
return solution == val2.solution &&
|
||||||
wells == val2.wells &&
|
wells == val2.wells &&
|
||||||
grp_nwrk == val2.grp_nwrk &&
|
|
||||||
extra == val2.extra;
|
extra == val2.extra;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
#define OPM_OUTPUT_SUMMARY_HPP
|
#define OPM_OUTPUT_SUMMARY_HPP
|
||||||
|
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp>
|
||||||
#include <opm/output/data/Aquifer.hpp>
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -39,7 +38,7 @@ namespace Opm {
|
|||||||
|
|
||||||
namespace Opm { namespace data {
|
namespace Opm { namespace data {
|
||||||
class WellRates;
|
class WellRates;
|
||||||
class GroupAndNetworkValues;
|
class Group;
|
||||||
}} // namespace Opm::data
|
}} // namespace Opm::data
|
||||||
|
|
||||||
namespace Opm { namespace out {
|
namespace Opm { namespace out {
|
||||||
@@ -60,21 +59,20 @@ public:
|
|||||||
|
|
||||||
void add_timestep(const SummaryState& st, const int report_step);
|
void add_timestep(const SummaryState& st, const int report_step);
|
||||||
|
|
||||||
void eval(SummaryState& summary_state,
|
void eval(SummaryState& summary_state,
|
||||||
const int report_step,
|
const int report_step,
|
||||||
const double secs_elapsed,
|
const double secs_elapsed,
|
||||||
const EclipseState& es,
|
const EclipseState& es,
|
||||||
const Schedule& schedule,
|
const Schedule& schedule,
|
||||||
const data::WellRates& well_solution,
|
const data::WellRates& well_solution,
|
||||||
const data::GroupAndNetworkValues& group_and_nwrk_solution,
|
const data::Group& group_solution,
|
||||||
GlobalProcessParameters single_values,
|
const GlobalProcessParameters& single_values,
|
||||||
const RegionParameters& region_values = {},
|
const RegionParameters& region_values = {},
|
||||||
const BlockValues& block_values = {},
|
const BlockValues& block_values = {}) const;
|
||||||
const data::Aquifers& aquifers_values = {}) const;
|
|
||||||
|
|
||||||
void write() const;
|
void write() const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class SummaryImplementation;
|
class SummaryImplementation;
|
||||||
std::unique_ptr<SummaryImplementation> pImpl_;
|
std::unique_ptr<SummaryImplementation> pImpl_;
|
||||||
|
|||||||
@@ -59,8 +59,6 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
|
|||||||
TrgFIP = 101,
|
TrgFIP = 101,
|
||||||
TrgSFT = 102,
|
TrgSFT = 102,
|
||||||
GRpar_damp = 144, // Guiderate parameter damping factor
|
GRpar_damp = 144, // Guiderate parameter damping factor
|
||||||
WsegRedFac = 145, // WSEGITER parameter (item 3) Reduction factor (F_R)
|
|
||||||
WsegIncFac = 146, // WSEGITER parameter (item 4) Increas factor (F_I)
|
|
||||||
UdqPar_2 = 212, // UDQPARAM item number 2 (Permitted range (+/-) of user-defined quantities)
|
UdqPar_2 = 212, // UDQPARAM item number 2 (Permitted range (+/-) of user-defined quantities)
|
||||||
UdqPar_3 = 213, // UDQPARAM item number 3 (Value given to undefined elements when outputting data)
|
UdqPar_3 = 213, // UDQPARAM item number 3 (Value given to undefined elements when outputting data)
|
||||||
UdqPar_4 = 214, // UDQPARAM item number 4 (fractional equality tolerance used in ==, <= etc. functions)
|
UdqPar_4 = 214, // UDQPARAM item number 4 (fractional equality tolerance used in ==, <= etc. functions)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems {
|
namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems {
|
||||||
|
|
||||||
|
|
||||||
namespace SGroup {
|
namespace SGroup {
|
||||||
enum prod_index : std::vector<float>::size_type {
|
enum prod_index : std::vector<float>::size_type {
|
||||||
OilRateLimit = 6, // Group's oil production target/limit
|
OilRateLimit = 6, // Group's oil production target/limit
|
||||||
@@ -32,12 +32,8 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
|
|||||||
GasRateLimit = 8, // Group's gas production target/limit
|
GasRateLimit = 8, // Group's gas production target/limit
|
||||||
LiqRateLimit = 9, // Group's liquid production target/limit
|
LiqRateLimit = 9, // Group's liquid production target/limit
|
||||||
};
|
};
|
||||||
|
|
||||||
enum inj_index : std::vector<float>::size_type {
|
enum inj_index : std::vector<float>::size_type {
|
||||||
oilSurfRateLimit = 10, // Group's oil surface volume injection rate target/limit
|
|
||||||
oilResRateLimit = 11, // Group's oil reservoir volume injection rate target/limit
|
|
||||||
oilReinjectionLimit = 12, // Group's oil reinjection fraction target/limit
|
|
||||||
oilVoidageLimit = 13, // Group's oil voidage injection fraction target/limit
|
|
||||||
waterSurfRateLimit = 15, //i Group's water surface volume injection rate target/limit
|
waterSurfRateLimit = 15, //i Group's water surface volume injection rate target/limit
|
||||||
waterResRateLimit = 16, // Group's water reservoir volume injection rate target/limit
|
waterResRateLimit = 16, // Group's water reservoir volume injection rate target/limit
|
||||||
waterReinjectionLimit = 17, // Group's water reinjection fraction target/limit
|
waterReinjectionLimit = 17, // Group's water reinjection fraction target/limit
|
||||||
@@ -50,17 +46,8 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
|
|||||||
};
|
};
|
||||||
} // SGroup
|
} // SGroup
|
||||||
|
|
||||||
|
|
||||||
namespace IGroup {
|
|
||||||
enum index : std::vector<int>::size_type {
|
|
||||||
ProdCMode = 1,
|
|
||||||
WInjCMode = 16,
|
|
||||||
GInjCMode = 21,
|
|
||||||
ParentGroup = 28,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
namespace XGroup {
|
namespace XGroup {
|
||||||
enum index : std::vector<double>::size_type {
|
enum index : std::vector<double>::size_type {
|
||||||
OilPrRate = 0, // Group's oil production rate
|
OilPrRate = 0, // Group's oil production rate
|
||||||
@@ -87,26 +74,6 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
|
|||||||
OilPrPot = 22, // Group's oil production potential
|
OilPrPot = 22, // Group's oil production potential
|
||||||
WatPrPot = 23, // Group's water production potential
|
WatPrPot = 23, // Group's water production potential
|
||||||
|
|
||||||
OilPrGuideRate = 85, // Group's producer guide rate for oil.
|
|
||||||
WatPrGuideRate = 86, // Group's producer guide rate for water.
|
|
||||||
GasPrGuideRate = 87, // Group's producer guide rate for gas.
|
|
||||||
VoidPrGuideRate = 88, // Group's producer guide rate for reservoir voidage volume.
|
|
||||||
|
|
||||||
OilInjGuideRate = 89, // Group's injection guide rate for oil.
|
|
||||||
WatInjGuideRate = 91, // Group's injection guide rate for water.
|
|
||||||
WatInjGuideRate_2 = 92, // Second copy of group's injection guide rate for water.
|
|
||||||
// Not fully characterised.
|
|
||||||
GasInjGuideRate = 93, // Groups injection guide rate for gas.
|
|
||||||
|
|
||||||
OilPrGuideRate_2 = 127, // Second copy of group's producer guide rate for oil.
|
|
||||||
// Not fully characterised.
|
|
||||||
WatPrGuideRate_2 = 128, // Second copy of group's producer guide rate for water.
|
|
||||||
// Not fully characterised.
|
|
||||||
GasPrGuideRate_2 = 129, // Second copy of group's producer guide rate for gas.
|
|
||||||
// Not fully characterised.
|
|
||||||
VoidPrGuideRate_2 = 130, // Second copy of group's producer guide rate for
|
|
||||||
// reservoir voidage volume. Not fully characterised.
|
|
||||||
|
|
||||||
HistOilPrTotal = 135, // Group's total cumulative oil
|
HistOilPrTotal = 135, // Group's total cumulative oil
|
||||||
// production (observed/historical rates)
|
// production (observed/historical rates)
|
||||||
HistWatPrTotal = 139, // Group's total cumulative water
|
HistWatPrTotal = 139, // Group's total cumulative water
|
||||||
|
|||||||
@@ -118,8 +118,6 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
|
|||||||
|
|
||||||
IHOURZ = 206, // IHOURZ = current simulation time HH:MM:SS – number of hours (HH) (0-23).
|
IHOURZ = 206, // IHOURZ = current simulation time HH:MM:SS – number of hours (HH) (0-23).
|
||||||
IMINTS = 207, // IMINTS = current simulation time HH:MM:SS – number of minutes (MM) (0-59).
|
IMINTS = 207, // IMINTS = current simulation time HH:MM:SS – number of minutes (MM) (0-59).
|
||||||
|
|
||||||
WSEGITR_IT2 = 208, // NR - maximum no of times that a new iteration cycle with a reduced Wp will be started
|
|
||||||
|
|
||||||
MAX_ACT_COND = 245, // Maximum number of conditions pr action
|
MAX_ACT_COND = 245, // Maximum number of conditions pr action
|
||||||
MAX_AN_AQUIFERS = 252, // Maximum number of analytic aquifers
|
MAX_AN_AQUIFERS = 252, // Maximum number of analytic aquifers
|
||||||
|
|||||||
@@ -55,8 +55,6 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
|
|||||||
GasFlowFract = 10, // Normalised Gas flow rate fraction
|
GasFlowFract = 10, // Normalised Gas flow rate fraction
|
||||||
Pressure = 11, // Segment pressure
|
Pressure = 11, // Segment pressure
|
||||||
|
|
||||||
item31 = 30, // Very close to Normalised Water flow rate fraction - value used pr today
|
|
||||||
|
|
||||||
item40 = 39, // Unknown
|
item40 = 39, // Unknown
|
||||||
|
|
||||||
ValveLength = 40, // Length of valve
|
ValveLength = 40, // Length of valve
|
||||||
|
|||||||
@@ -36,14 +36,14 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
|
|||||||
ActWCtrl = 7, // Well's active target control mode (constraint).
|
ActWCtrl = 7, // Well's active target control mode (constraint).
|
||||||
|
|
||||||
item9 = 8, // Unknown
|
item9 = 8, // Unknown
|
||||||
Status = 10, // Well status
|
item11 = 10, // Unknown
|
||||||
VFPTab = 11, // ID (one-based) of well's current VFP table.
|
VFPTab = 11, // ID (one-based) of well's current VFP table.
|
||||||
|
|
||||||
PredReqWCtrl = 15, // Well's requested control mode from
|
PredReqWCtrl = 15, // Well's requested control mode from
|
||||||
// simulation deck (WCONINJE, WCONPROD).
|
// simulation deck (WCONINJE, WCONPROD).
|
||||||
|
|
||||||
item18 = 17, // Unknown
|
item18 = 17, // Unknown
|
||||||
XFlow = 22,
|
XFlow = 22,
|
||||||
item25 = 24, // Unknown
|
item25 = 24, // Unknown
|
||||||
item32 = 31, // Unknown
|
item32 = 31, // Unknown
|
||||||
item48 = 47, // Unknown
|
item48 = 47, // Unknown
|
||||||
@@ -58,20 +58,6 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
|
|||||||
// Value 0 for regular wells
|
// Value 0 for regular wells
|
||||||
// Value #segments for MS wells
|
// Value #segments for MS wells
|
||||||
|
|
||||||
MSW_PlossMod = 81, // index for Pressure loss model for well segments
|
|
||||||
// ih value for this index is:
|
|
||||||
// = 0 for regular wells
|
|
||||||
// = 0 for MSW wells and HFA (WELSEGS item 6)
|
|
||||||
// = 1 for MSW wells and HF- (WELSEGS item 6)
|
|
||||||
// = 2 for MSW wells and H-- (WELSEGS item 6)
|
|
||||||
|
|
||||||
MSW_MulPhaseMod = 85, // index for Multiphase flow model for well segments - NOTE DF - model is not implemented yet!!
|
|
||||||
// ih value for this index is:
|
|
||||||
// = 0 for regular wells
|
|
||||||
// = 1 for MSW wells and HO (WELSEGS item 7)
|
|
||||||
// = 2 for MSW wells and DF (WELSEGS item 7)
|
|
||||||
|
|
||||||
|
|
||||||
CompOrd = 98, // Well's completion ordering scheme.
|
CompOrd = 98, // Well's completion ordering scheme.
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -80,6 +66,7 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
|
|||||||
enum WellCtrlMode : int {
|
enum WellCtrlMode : int {
|
||||||
WMCtlUnk = -10, // Unknown well control mode (OPM only)
|
WMCtlUnk = -10, // Unknown well control mode (OPM only)
|
||||||
Group = - 1, // Well under group control
|
Group = - 1, // Well under group control
|
||||||
|
Shut = 0, // Well is shut
|
||||||
OilRate = 1, // Well controlled by oil rate
|
OilRate = 1, // Well controlled by oil rate
|
||||||
WatRate = 2, // Well controlled by water rate
|
WatRate = 2, // Well controlled by water rate
|
||||||
GasRate = 3, // Well controlled by gas rate
|
GasRate = 3, // Well controlled by gas rate
|
||||||
@@ -110,29 +97,6 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
|
|||||||
// appearance in simulation model's
|
// appearance in simulation model's
|
||||||
// COMPDAT keyword.
|
// COMPDAT keyword.
|
||||||
};
|
};
|
||||||
|
|
||||||
enum PLossMod : int {
|
|
||||||
HFA = 0, // Components of pressure loss in MSW model for well (WELSEGS item 6)
|
|
||||||
// Hydrostatic, Friction, Acceleration
|
|
||||||
|
|
||||||
HF_ = 1, // Hydrostatic, Friction,
|
|
||||||
|
|
||||||
H__ = 2, // Hydrostatic
|
|
||||||
};
|
|
||||||
|
|
||||||
/*enum MPMod : int {
|
|
||||||
HO = 1, // Multiphase flow model for MSW well
|
|
||||||
// Homogeneous flow
|
|
||||||
|
|
||||||
DF = 2, // Drift flux model
|
|
||||||
};*/
|
|
||||||
|
|
||||||
enum Status : int {
|
|
||||||
Shut = -1000,
|
|
||||||
Stop = 0,
|
|
||||||
Open = 1,
|
|
||||||
Auto = 3,
|
|
||||||
};
|
|
||||||
} // Value
|
} // Value
|
||||||
} // IWell
|
} // IWell
|
||||||
|
|
||||||
@@ -149,11 +113,10 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
|
|||||||
BHPTarget = 6, // Well's bottom hole pressure target
|
BHPTarget = 6, // Well's bottom hole pressure target
|
||||||
|
|
||||||
DatumDepth = 9, // Well's reference depth for BHP
|
DatumDepth = 9, // Well's reference depth for BHP
|
||||||
Alq_value = 10, // Well's artificial lift quantity
|
|
||||||
|
|
||||||
DrainageRadius = 17, // Well's drainage radius - item 7 from WELSPECS
|
DrainageRadius = 17, // Well's drainage radius - item 7 from WELSPECS
|
||||||
EfficiencyFactor1 = 24, // Item2 from WEFAC; this value is repeated at two locations.
|
EfficiencyFactor1 = 24, // Item2 from WEFAC; this value is repeated at two locations.
|
||||||
EfficiencyFactor2 = 31, // Item2 from WEFAC
|
EfficiencyFactor2 = 31, //
|
||||||
HistLiqRateTarget = 33, // Well's historical/observed liquid
|
HistLiqRateTarget = 33, // Well's historical/observed liquid
|
||||||
// rate target/limit
|
// rate target/limit
|
||||||
|
|
||||||
@@ -172,7 +135,7 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
|
|||||||
GasPrRate = 2, // Well's gas production rate
|
GasPrRate = 2, // Well's gas production rate
|
||||||
LiqPrRate = 3, // Well's liquid production rate
|
LiqPrRate = 3, // Well's liquid production rate
|
||||||
VoidPrRate = 4, // Well's reservoir voidage production rate
|
VoidPrRate = 4, // Well's reservoir voidage production rate
|
||||||
TubHeadPr = 5, // Well's tubing head pressure
|
|
||||||
FlowBHP = 6, // Well's flowing/producing bottom hole pressure
|
FlowBHP = 6, // Well's flowing/producing bottom hole pressure
|
||||||
WatCut = 7, // Well's producing water cut
|
WatCut = 7, // Well's producing water cut
|
||||||
GORatio = 8, // Well's producing gas/oil ratio
|
GORatio = 8, // Well's producing gas/oil ratio
|
||||||
@@ -194,12 +157,6 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
|
|||||||
|
|
||||||
BHPTarget = 41, // Well's current BHP Target/Limit
|
BHPTarget = 41, // Well's current BHP Target/Limit
|
||||||
|
|
||||||
PrimGuideRate = 48, // Well's "primary" guide rate (oil for producers,
|
|
||||||
// preferred phase for injectors)
|
|
||||||
WatPrGuideRate = 49, // Well's producer guide rate for water
|
|
||||||
GasPrGuideRate = 50, // Well's producer guide rate for gas
|
|
||||||
VoidPrGuideRate = 68, // Well's producer guide rate for reservoir voidag volume
|
|
||||||
|
|
||||||
HistOilPrTotal = 75, // Well's total cumulative oil production
|
HistOilPrTotal = 75, // Well's total cumulative oil production
|
||||||
// (observed/historical rates)
|
// (observed/historical rates)
|
||||||
HistWatPrTotal = 76, // Well's total cumulative water
|
HistWatPrTotal = 76, // Well's total cumulative water
|
||||||
@@ -212,15 +169,6 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems
|
|||||||
HistGasInjTotal = 82, // Well's total cumulative gas injection
|
HistGasInjTotal = 82, // Well's total cumulative gas injection
|
||||||
// (observed/historical rates)
|
// (observed/historical rates)
|
||||||
|
|
||||||
PrimGuideRate_2 = 91, // Second copy of well's primary guide rate.
|
|
||||||
// Not fully characterised.
|
|
||||||
WatPrGuideRate_2 = 92, // Second copy of well's producer guide rate for water.
|
|
||||||
// Not fully characterised.
|
|
||||||
GasPrGuideRate_2 = 93, // Second copy of well's producer guide rate for gas
|
|
||||||
// Not fully characterised.
|
|
||||||
VoidPrGuideRate_2 = 94, // Second copy of well's producer guide rate for reservoir voidage
|
|
||||||
// Not fully characterised.
|
|
||||||
|
|
||||||
WatVoidPrRate = 122, // Well's voidage production rate
|
WatVoidPrRate = 122, // Well's voidage production rate
|
||||||
GasVoidPrRate = 123, // Well's voidage production rate
|
GasVoidPrRate = 123, // Well's voidage production rate
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ namespace Opm {
|
|||||||
|
|
||||||
class Schedule;
|
class Schedule;
|
||||||
class EclipseGrid;
|
class EclipseGrid;
|
||||||
class UnitSystem;
|
|
||||||
|
|
||||||
namespace RptIO {
|
namespace RptIO {
|
||||||
|
|
||||||
@@ -36,13 +35,12 @@ namespace Opm {
|
|||||||
unsigned value,
|
unsigned value,
|
||||||
const Schedule& schedule,
|
const Schedule& schedule,
|
||||||
const EclipseGrid& grid,
|
const EclipseGrid& grid,
|
||||||
const UnitSystem& unit_system,
|
|
||||||
std::size_t time_step
|
std::size_t time_step
|
||||||
);
|
);
|
||||||
|
|
||||||
namespace workers {
|
namespace workers {
|
||||||
|
|
||||||
void write_WELSPECS(std::ostream&, unsigned, const Schedule&, const EclipseGrid& grid, const UnitSystem&, std::size_t);
|
void write_WELSPECS(std::ostream&, unsigned, const Schedule&, const EclipseGrid& grid, std::size_t);
|
||||||
|
|
||||||
} } }
|
} } }
|
||||||
#endif // OPM_WRITE_RPT_HPP
|
#endif // OPM_WRITE_RPT_HPP
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
#include <opm/parser/eclipse/Deck/DeckValue.hpp>
|
#include <opm/parser/eclipse/Deck/DeckValue.hpp>
|
||||||
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
|
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
|
||||||
#include <opm/parser/eclipse/Deck/value_status.hpp>
|
#include <opm/parser/eclipse/Deck/value_status.hpp>
|
||||||
#include <opm/common/OpmLog/KeywordLocation.hpp>
|
#include <opm/common/OpmLog/Location.hpp>
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
class DeckOutput;
|
class DeckOutput;
|
||||||
@@ -43,7 +43,7 @@ namespace Opm {
|
|||||||
|
|
||||||
DeckKeyword();
|
DeckKeyword();
|
||||||
explicit DeckKeyword(const ParserKeyword& parserKeyword);
|
explicit DeckKeyword(const ParserKeyword& parserKeyword);
|
||||||
DeckKeyword(const KeywordLocation& location, const std::string& keywordName);
|
DeckKeyword(const Location& location, const std::string& keywordName);
|
||||||
DeckKeyword(const ParserKeyword& parserKeyword, const std::vector<std::vector<DeckValue>>& record_list, UnitSystem& system_active, UnitSystem& system_default);
|
DeckKeyword(const ParserKeyword& parserKeyword, const std::vector<std::vector<DeckValue>>& record_list, UnitSystem& system_active, UnitSystem& system_default);
|
||||||
DeckKeyword(const ParserKeyword& parserKeyword, const std::vector<int>& data);
|
DeckKeyword(const ParserKeyword& parserKeyword, const std::vector<int>& data);
|
||||||
DeckKeyword(const ParserKeyword& parserKeyword, const std::vector<double>& data, UnitSystem& system_active, UnitSystem& system_default);
|
DeckKeyword(const ParserKeyword& parserKeyword, const std::vector<double>& data, UnitSystem& system_active, UnitSystem& system_default);
|
||||||
@@ -52,7 +52,7 @@ namespace Opm {
|
|||||||
|
|
||||||
const std::string& name() const;
|
const std::string& name() const;
|
||||||
void setFixedSize();
|
void setFixedSize();
|
||||||
const KeywordLocation& location() const;
|
const Location& location() const;
|
||||||
|
|
||||||
|
|
||||||
size_t size() const;
|
size_t size() const;
|
||||||
@@ -105,7 +105,7 @@ namespace Opm {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::string m_keywordName;
|
std::string m_keywordName;
|
||||||
KeywordLocation m_location;
|
Location m_location;
|
||||||
|
|
||||||
std::vector< DeckRecord > m_recordList;
|
std::vector< DeckRecord > m_recordList;
|
||||||
bool m_isDataKeyword;
|
bool m_isDataKeyword;
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ namespace Opm {
|
|||||||
|
|
||||||
void start_record( );
|
void start_record( );
|
||||||
void end_record( );
|
void end_record( );
|
||||||
|
void split_record();
|
||||||
|
|
||||||
void start_keyword(const std::string& kw);
|
void start_keyword(const std::string& kw);
|
||||||
void end_keyword(bool add_slash);
|
void end_keyword(bool add_slash);
|
||||||
@@ -52,10 +53,8 @@ namespace Opm {
|
|||||||
size_t row_count;
|
size_t row_count;
|
||||||
bool record_on;
|
bool record_on;
|
||||||
int org_precision;
|
int org_precision;
|
||||||
bool split_line;
|
|
||||||
|
|
||||||
template <typename T> void write_value(const T& value);
|
template <typename T> void write_value(const T& value);
|
||||||
void split_record();
|
|
||||||
void write_sep( );
|
void write_sep( );
|
||||||
void set_precision(int precision);
|
void set_precision(int precision);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -54,9 +54,6 @@ public:
|
|||||||
double getSI() const;
|
double getSI() const;
|
||||||
bool zero() const;
|
bool zero() const;
|
||||||
|
|
||||||
//epsilon limit = 1.E-20 (~= 0.)
|
|
||||||
double epsilonLimit() const;
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool is() const;
|
bool is() const;
|
||||||
|
|
||||||
@@ -68,7 +65,6 @@ public:
|
|||||||
bool operator!=(const UDAValue& other) const;
|
bool operator!=(const UDAValue& other) const;
|
||||||
UDAValue& operator=(double value);
|
UDAValue& operator=(double value);
|
||||||
UDAValue& operator=(const std::string& value);
|
UDAValue& operator=(const std::string& value);
|
||||||
void update_value(const UDAValue& other);
|
|
||||||
|
|
||||||
bool is_numeric() { return numeric_value; }
|
bool is_numeric() { return numeric_value; }
|
||||||
|
|
||||||
|
|||||||
@@ -118,8 +118,6 @@ namespace Opm {
|
|||||||
const std::vector<AquiferCT::AQUCT_data>& data() const;
|
const std::vector<AquiferCT::AQUCT_data>& data() const;
|
||||||
bool operator==(const AquiferCT& other) const;
|
bool operator==(const AquiferCT& other) const;
|
||||||
|
|
||||||
bool hasAquifer(const int aquID) const;
|
|
||||||
|
|
||||||
template<class Serializer>
|
template<class Serializer>
|
||||||
void serializeOp(Serializer& serializer)
|
void serializeOp(Serializer& serializer)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ public:
|
|||||||
const Aquifetp& fetp() const;
|
const Aquifetp& fetp() const;
|
||||||
const Aquancon& connections() const;
|
const Aquancon& connections() const;
|
||||||
bool operator==(const AquiferConfig& other);
|
bool operator==(const AquiferConfig& other);
|
||||||
bool hasAquifer(const int aquID) const;
|
|
||||||
|
|
||||||
template<class Serializer>
|
template<class Serializer>
|
||||||
void serializeOp(Serializer& serializer)
|
void serializeOp(Serializer& serializer)
|
||||||
|
|||||||
@@ -76,8 +76,6 @@ class Aquifetp {
|
|||||||
std::vector<Aquifetp::AQUFETP_data>::const_iterator end() const;
|
std::vector<Aquifetp::AQUFETP_data>::const_iterator end() const;
|
||||||
bool operator==(const Aquifetp& other) const;
|
bool operator==(const Aquifetp& other) const;
|
||||||
|
|
||||||
bool hasAquifer(const int aquID) const;
|
|
||||||
|
|
||||||
template<class Serializer>
|
template<class Serializer>
|
||||||
void serializeOp(Serializer& serializer)
|
void serializeOp(Serializer& serializer)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,10 +38,9 @@ namespace Opm {
|
|||||||
|
|
||||||
static EclipseConfig serializeObject();
|
static EclipseConfig serializeObject();
|
||||||
|
|
||||||
InitConfig& init();
|
const InitConfig& init() const;
|
||||||
IOConfig& io();
|
IOConfig& io();
|
||||||
const IOConfig& io() const;
|
const IOConfig& io() const;
|
||||||
const InitConfig& init() const;
|
|
||||||
const InitConfig& getInitConfig() const;
|
const InitConfig& getInitConfig() const;
|
||||||
|
|
||||||
bool operator==(const EclipseConfig& data) const;
|
bool operator==(const EclipseConfig& data) const;
|
||||||
|
|||||||
@@ -77,8 +77,6 @@ namespace Opm {
|
|||||||
IOConfig& getIOConfig();
|
IOConfig& getIOConfig();
|
||||||
|
|
||||||
const InitConfig& getInitConfig() const;
|
const InitConfig& getInitConfig() const;
|
||||||
InitConfig& getInitConfig();
|
|
||||||
|
|
||||||
const SimulationConfig& getSimulationConfig() const;
|
const SimulationConfig& getSimulationConfig() const;
|
||||||
virtual const EclipseGrid& getInputGrid() const;
|
virtual const EclipseGrid& getInputGrid() const;
|
||||||
|
|
||||||
|
|||||||
@@ -21,9 +21,8 @@
|
|||||||
#ifndef BOX_HPP_
|
#ifndef BOX_HPP_
|
||||||
#define BOX_HPP_
|
#define BOX_HPP_
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
#include <limits>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
class DeckRecord;
|
class DeckRecord;
|
||||||
@@ -32,32 +31,17 @@ namespace Opm {
|
|||||||
class Box {
|
class Box {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
struct cell_index {
|
struct cell_index {
|
||||||
std::size_t global_index;
|
std::size_t global_index;
|
||||||
std::size_t active_index;
|
std::size_t active_index;
|
||||||
std::size_t data_index;
|
std::size_t data_index;
|
||||||
|
|
||||||
|
|
||||||
cell_index(std::size_t g,std::size_t a, std::size_t d) :
|
cell_index(std::size_t g,std::size_t a, std::size_t d) :
|
||||||
global_index(g),
|
global_index(g),
|
||||||
active_index(a),
|
active_index(a),
|
||||||
data_index(d)
|
data_index(d)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
This constructor should is used by the global_index_list() member
|
|
||||||
which will return a list of *all* the cells in the box. In this
|
|
||||||
case the active_index will be set to the global_index. This is a
|
|
||||||
hack to simplify the treatment of global fields in the FieldProps
|
|
||||||
implementation.
|
|
||||||
*/
|
|
||||||
cell_index(std::size_t g, std::size_t d) :
|
|
||||||
global_index(g),
|
|
||||||
active_index(g),
|
|
||||||
data_index(d)
|
|
||||||
{}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Box(const EclipseGrid& grid);
|
Box(const EclipseGrid& grid);
|
||||||
@@ -69,7 +53,7 @@ namespace Opm {
|
|||||||
bool isGlobal() const;
|
bool isGlobal() const;
|
||||||
size_t getDim(size_t idim) const;
|
size_t getDim(size_t idim) const;
|
||||||
const std::vector<cell_index>& index_list() const;
|
const std::vector<cell_index>& index_list() const;
|
||||||
const std::vector<Box::cell_index>& global_index_list() const;
|
const std::vector<size_t>& getIndexList() const;
|
||||||
bool equal(const Box& other) const;
|
bool equal(const Box& other) const;
|
||||||
|
|
||||||
|
|
||||||
@@ -89,8 +73,8 @@ namespace Opm {
|
|||||||
size_t m_offset[3];
|
size_t m_offset[3];
|
||||||
|
|
||||||
bool m_isGlobal;
|
bool m_isGlobal;
|
||||||
std::vector<cell_index> m_active_index_list;
|
std::vector<size_t> global_index_list;
|
||||||
std::vector<cell_index> m_global_index_list;
|
std::vector<cell_index> m_index_list;
|
||||||
|
|
||||||
int lower(int dim) const;
|
int lower(int dim) const;
|
||||||
int upper(int dim) const;
|
int upper(int dim) const;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#define OPM_PARSER_ECLIPSE_GRID_HPP
|
#define OPM_PARSER_ECLIPSE_GRID_HPP
|
||||||
|
|
||||||
|
|
||||||
|
#include <opm/parser/eclipse/EclipseState/Util/Value.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Grid/MinpvMode.hpp>
|
#include <opm/parser/eclipse/EclipseState/Grid/MinpvMode.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Grid/PinchMode.hpp>
|
#include <opm/parser/eclipse/EclipseState/Grid/PinchMode.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Grid/GridDims.hpp>
|
#include <opm/parser/eclipse/EclipseState/Grid/GridDims.hpp>
|
||||||
@@ -31,7 +32,6 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <optional>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
@@ -110,7 +110,6 @@ namespace Opm {
|
|||||||
double getPinchThresholdThickness( ) const;
|
double getPinchThresholdThickness( ) const;
|
||||||
PinchMode::ModeEnum getPinchOption( ) const;
|
PinchMode::ModeEnum getPinchOption( ) const;
|
||||||
PinchMode::ModeEnum getMultzOption( ) const;
|
PinchMode::ModeEnum getMultzOption( ) const;
|
||||||
PinchMode::ModeEnum getPinchGapMode( ) const;
|
|
||||||
|
|
||||||
MinpvMode::ModeEnum getMinpvMode() const;
|
MinpvMode::ModeEnum getMinpvMode() const;
|
||||||
const std::vector<double>& getMinpvVector( ) const;
|
const std::vector<double>& getMinpvVector( ) const;
|
||||||
@@ -194,10 +193,9 @@ namespace Opm {
|
|||||||
private:
|
private:
|
||||||
std::vector<double> m_minpvVector;
|
std::vector<double> m_minpvVector;
|
||||||
MinpvMode::ModeEnum m_minpvMode;
|
MinpvMode::ModeEnum m_minpvMode;
|
||||||
std::optional<double> m_pinch;
|
Value<double> m_pinch;
|
||||||
PinchMode::ModeEnum m_pinchoutMode;
|
PinchMode::ModeEnum m_pinchoutMode;
|
||||||
PinchMode::ModeEnum m_multzMode;
|
PinchMode::ModeEnum m_multzMode;
|
||||||
PinchMode::ModeEnum m_pinchGapMode;
|
|
||||||
|
|
||||||
bool m_circle = false;
|
bool m_circle = false;
|
||||||
|
|
||||||
|
|||||||
@@ -1,146 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2020 Equinor AS.
|
|
||||||
|
|
||||||
This file is part of the Open Porous Media project (OPM).
|
|
||||||
|
|
||||||
OPM is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OPM is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef FIELD_DATA_HPP
|
|
||||||
#define FIELD_DATA_HPP
|
|
||||||
|
|
||||||
#include <opm/parser/eclipse/EclipseState/Grid/Box.hpp>
|
|
||||||
#include <opm/parser/eclipse/EclipseState/Grid/Keywords.hpp>
|
|
||||||
#include <opm/parser/eclipse/EclipseState/Grid/FieldData.hpp>
|
|
||||||
#include <opm/parser/eclipse/Deck/value_status.hpp>
|
|
||||||
|
|
||||||
#include<string>
|
|
||||||
#include<vector>
|
|
||||||
#include<optional>
|
|
||||||
#include<array>
|
|
||||||
#include<algorithm>
|
|
||||||
|
|
||||||
namespace Opm
|
|
||||||
{
|
|
||||||
namespace Fieldprops
|
|
||||||
{
|
|
||||||
template<typename T>
|
|
||||||
static void compress(std::vector<T>& data, const std::vector<bool>& active_map) {
|
|
||||||
std::size_t shift = 0;
|
|
||||||
for (std::size_t g = 0; g < active_map.size(); g++) {
|
|
||||||
if (active_map[g] && shift > 0) {
|
|
||||||
data[g - shift] = data[g];
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!active_map[g])
|
|
||||||
shift += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
data.resize(data.size() - shift);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct FieldData {
|
|
||||||
std::vector<T> data;
|
|
||||||
std::vector<value::status> value_status;
|
|
||||||
keywords::keyword_info<T> kw_info;
|
|
||||||
std::optional<std::vector<T>> global_data;
|
|
||||||
std::optional<std::vector<value::status>> global_value_status;
|
|
||||||
mutable bool all_set;
|
|
||||||
|
|
||||||
FieldData() = default;
|
|
||||||
|
|
||||||
FieldData(const keywords::keyword_info<T>& info, std::size_t active_size, std::size_t global_size) :
|
|
||||||
data(std::vector<T>(active_size)),
|
|
||||||
value_status(active_size, value::status::uninitialized),
|
|
||||||
kw_info(info),
|
|
||||||
all_set(false)
|
|
||||||
{
|
|
||||||
if (global_size != 0) {
|
|
||||||
this->global_data = std::vector<T>(global_size);
|
|
||||||
this->global_value_status = std::vector<value::status>(global_size, value::status::uninitialized);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (info.scalar_init)
|
|
||||||
this->default_assign( *info.scalar_init );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::size_t size() const {
|
|
||||||
return this->data.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool valid() const {
|
|
||||||
if (this->all_set)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
static const std::array<value::status,2> invalid_value = {value::status::uninitialized, value::status::empty_default};
|
|
||||||
const auto& it = std::find_first_of(this->value_status.begin(), this->value_status.end(), invalid_value.begin(), invalid_value.end());
|
|
||||||
this->all_set = (it == this->value_status.end());
|
|
||||||
|
|
||||||
return this->all_set;
|
|
||||||
}
|
|
||||||
|
|
||||||
void compress(const std::vector<bool>& active_map) {
|
|
||||||
Fieldprops::compress(this->data, active_map);
|
|
||||||
Fieldprops::compress(this->value_status, active_map);
|
|
||||||
}
|
|
||||||
|
|
||||||
void copy(const FieldData<T>& src, const std::vector<Box::cell_index>& index_list) {
|
|
||||||
for (const auto& ci : index_list) {
|
|
||||||
this->data[ci.active_index] = src.data[ci.active_index];
|
|
||||||
this->value_status[ci.active_index] = src.value_status[ci.active_index];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void default_assign(T value) {
|
|
||||||
std::fill(this->data.begin(), this->data.end(), value);
|
|
||||||
std::fill(this->value_status.begin(), this->value_status.end(), value::status::valid_default);
|
|
||||||
|
|
||||||
if (this->global_data) {
|
|
||||||
std::fill(this->global_data->begin(), this->global_data->end(), value);
|
|
||||||
std::fill(this->global_value_status->begin(), this->global_value_status->end(), value::status::valid_default);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void default_assign(const std::vector<T>& src) {
|
|
||||||
if (src.size() != this->size())
|
|
||||||
throw std::invalid_argument("Size mismatch got: " + std::to_string(src.size()) + " expected: " + std::to_string(this->size()));
|
|
||||||
|
|
||||||
std::copy(src.begin(), src.end(), this->data.begin());
|
|
||||||
std::fill(this->value_status.begin(), this->value_status.end(), value::status::valid_default);
|
|
||||||
}
|
|
||||||
|
|
||||||
void default_update(const std::vector<T>& src) {
|
|
||||||
if (src.size() != this->size())
|
|
||||||
throw std::invalid_argument("Size mismatch got: " + std::to_string(src.size()) + " expected: " + std::to_string(this->size()));
|
|
||||||
|
|
||||||
for (std::size_t i = 0; i < src.size(); i++) {
|
|
||||||
if (!value::has_value(this->value_status[i])) {
|
|
||||||
this->value_status[i] = value::status::valid_default;
|
|
||||||
this->data[i] = src[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void update(std::size_t index, T value, value::status status) {
|
|
||||||
this->data[index] = value;
|
|
||||||
this->value_status[index] = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
} // end namespace Fieldprops
|
|
||||||
} // end namespace Opm
|
|
||||||
#endif // FIELD_DATA_HPP
|
|
||||||
@@ -21,9 +21,6 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <unordered_map>
|
|
||||||
#include <opm/parser/eclipse/EclipseState/Grid/TranCalculator.hpp>
|
|
||||||
#include <opm/parser/eclipse/EclipseState/Grid/FieldData.hpp>
|
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
|
|
||||||
@@ -35,6 +32,30 @@ class TableManager;
|
|||||||
|
|
||||||
class FieldPropsManager {
|
class FieldPropsManager {
|
||||||
|
|
||||||
|
struct MemInfo {
|
||||||
|
std::size_t global_size;
|
||||||
|
std::size_t active_size;
|
||||||
|
std::size_t int_fields;
|
||||||
|
std::size_t double_fields;
|
||||||
|
std::size_t total;
|
||||||
|
|
||||||
|
MemInfo(std::size_t gsize, std::size_t asize, std::size_t num_int, std::size_t num_double) :
|
||||||
|
global_size(gsize),
|
||||||
|
active_size(asize),
|
||||||
|
int_fields(num_int),
|
||||||
|
double_fields(num_double),
|
||||||
|
total(asize * sizeof(int) * num_int + // The integer fields like SATNUM and PVTNUM
|
||||||
|
asize * sizeof(double) * num_double + // The double fields like PORO and SWATINIT
|
||||||
|
asize * sizeof(double) * 2 + // Depth and volume of all active cells
|
||||||
|
asize * sizeof(unsigned char) * (num_int + num_double) + // The per cell value status flag
|
||||||
|
gsize * sizeof(int)) // The global ACTNUM mapping
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// The default constructor should be removed when the FieldPropsManager is mandatory
|
// The default constructor should be removed when the FieldPropsManager is mandatory
|
||||||
@@ -45,6 +66,7 @@ public:
|
|||||||
const std::string& default_region() const;
|
const std::string& default_region() const;
|
||||||
virtual std::vector<int> actnum() const;
|
virtual std::vector<int> actnum() const;
|
||||||
virtual std::vector<double> porv(bool global = false) const;
|
virtual std::vector<double> porv(bool global = false) const;
|
||||||
|
MemInfo meminfo( ) const;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The number of cells in the fields managed by this FieldPropsManager.
|
The number of cells in the fields managed by this FieldPropsManager.
|
||||||
@@ -156,14 +178,6 @@ public:
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
std::vector<std::string> keys() const;
|
std::vector<std::string> keys() const;
|
||||||
|
|
||||||
const Fieldprops::FieldData<int>&
|
|
||||||
get_int_field_data(const std::string& keyword) const;
|
|
||||||
|
|
||||||
/// \brief Get double field data associated with a keyword
|
|
||||||
/// \param allow_unsupported If true we deactivate some checks on the
|
|
||||||
/// keyword and thus allow getting FieldData used by the TranCalculator.
|
|
||||||
const Fieldprops::FieldData<double>&
|
|
||||||
get_double_field_data(const std::string& keyword, bool allow_unsupported=false) const;
|
|
||||||
virtual const std::vector<int>& get_int(const std::string& keyword) const { return this->get<int>(keyword); }
|
virtual const std::vector<int>& get_int(const std::string& keyword) const { return this->get<int>(keyword); }
|
||||||
virtual std::vector<int> get_global_int(const std::string& keyword) const { return this->get_global<int>(keyword); }
|
virtual std::vector<int> get_global_int(const std::string& keyword) const { return this->get_global<int>(keyword); }
|
||||||
|
|
||||||
@@ -173,59 +187,6 @@ public:
|
|||||||
virtual bool has_int(const std::string& keyword) const { return this->has<int>(keyword); }
|
virtual bool has_int(const std::string& keyword) const { return this->has<int>(keyword); }
|
||||||
virtual bool has_double(const std::string& keyword) const { return this->has<double>(keyword); }
|
virtual bool has_double(const std::string& keyword) const { return this->has<double>(keyword); }
|
||||||
|
|
||||||
/*
|
|
||||||
The transmissibility keywords TRANX, TRANY and TRANZ do not really fit
|
|
||||||
well in the FieldProps system. The opm codebase is based on a full
|
|
||||||
internalization in the parse phase, and then passing fully assembled
|
|
||||||
objects to the simulator. When it comes to the transmissibilities this
|
|
||||||
model breaks down because the input code in opm-common is not capable of
|
|
||||||
calculating the transmissibility, that is performed in the simulator.
|
|
||||||
|
|
||||||
The EDIT section can have modifiers on TRAN, these must be applied *after*
|
|
||||||
the initial transmissibilities are calculated. To support this all the
|
|
||||||
modifiers to the TRAN{XYZ} fields are assembled in "transmissibility
|
|
||||||
calculators", and then these modifiers can be applied to a TRAN vector
|
|
||||||
after it has been calculated in the simulator. Usage from the simulator
|
|
||||||
could look like:
|
|
||||||
|
|
||||||
|
|
||||||
const auto& fp = eclState.fieldProps();
|
|
||||||
|
|
||||||
// Calculate transmissibilities using grid and permeability
|
|
||||||
std::vector<double> tranx = ....
|
|
||||||
|
|
||||||
// Check if there are any active TRANX modifiers and apply them
|
|
||||||
if (fp.tran_active("TRANX"))
|
|
||||||
fp.apply_tran("TRANX", tranx);
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
Will check if there are any TRAN{XYZ} modifiers active in the deck.
|
|
||||||
*/
|
|
||||||
virtual bool tran_active(const std::string& keyword) const;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Will apply all the TRAN modifiers which are present in the deck on the
|
|
||||||
already initialized vector tran_data. The vector tran_data should be
|
|
||||||
organised as the data vectors in the fieldpropsmanager - i.e. one element
|
|
||||||
for each active cell - in lexicographical order. The operations which are
|
|
||||||
supported by the transmissibility calculator are those given by the enum
|
|
||||||
ScalarOperation in FieldProps.hpp.
|
|
||||||
*/
|
|
||||||
virtual void apply_tran(const std::string& keyword, std::vector<double>& tran_data) const;
|
|
||||||
|
|
||||||
/*
|
|
||||||
When using MPI the FieldPropsManager is typically only assembled on the
|
|
||||||
root node and then distributed to the other nodes afterwards. These
|
|
||||||
methods are support methods for that, the real data used by the
|
|
||||||
transmissibility calculators is in the form of custom 3D fields, they are
|
|
||||||
distributed the same way the rest of the 3D fields are distributed.
|
|
||||||
*/
|
|
||||||
virtual std::vector<char> serialize_tran() const;
|
|
||||||
virtual void deserialize_tran(const std::vector<char>& buffer);
|
|
||||||
private:
|
private:
|
||||||
/*
|
/*
|
||||||
Return the keyword values as a std::vector<>. All elements in the return
|
Return the keyword values as a std::vector<>. All elements in the return
|
||||||
@@ -256,8 +217,8 @@ private:
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
This is exactly like the get() method, but the returned vector will have
|
This is exactly like the get() method, but the returned vector will have
|
||||||
global cartesian size. If the field has a default value that value will be
|
global cartesian size, where all inactive cells have been filled with
|
||||||
used for filling in in the inactive cells, otherwise zero is used.
|
zeros.
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::vector<T> get_global(const std::string& keyword) const;
|
std::vector<T> get_global(const std::string& keyword) const;
|
||||||
@@ -266,16 +227,6 @@ private:
|
|||||||
std::shared_ptr<FieldProps> fp;
|
std::shared_ptr<FieldProps> fp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void deserialize_tran(std::unordered_map<std::string, Fieldprops::TranCalculator>& tran,
|
|
||||||
const std::vector<char>& buffer);
|
|
||||||
|
|
||||||
template<class MapType>
|
|
||||||
void apply_tran(const std::unordered_map<std::string, Fieldprops::TranCalculator>& tran,
|
|
||||||
const MapType& double_data,
|
|
||||||
std::size_t active_size,
|
|
||||||
const std::string& keyword, std::vector<double>& data);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2020 Equinor AS.
|
|
||||||
|
|
||||||
This file is part of the Open Porous Media project (OPM).
|
|
||||||
|
|
||||||
OPM is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OPM is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef OPM_KEYWORDS_HPP
|
|
||||||
#define OPM_KEYWORDS_HPP
|
|
||||||
|
|
||||||
namespace Opm
|
|
||||||
{
|
|
||||||
|
|
||||||
namespace Fieldprops
|
|
||||||
{
|
|
||||||
|
|
||||||
namespace keywords {
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct keyword_info {
|
|
||||||
std::optional<std::string> unit = std::nullopt;
|
|
||||||
std::optional<T> scalar_init = std::nullopt;
|
|
||||||
bool multiplier = false;
|
|
||||||
bool top = false;
|
|
||||||
bool global = false;
|
|
||||||
|
|
||||||
keyword_info<T>& init(T init_value) {
|
|
||||||
this->scalar_init = init_value;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
keyword_info<T>& unit_string(const std::string& unit_string) {
|
|
||||||
this->unit = unit_string;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
keyword_info<T>& distribute_top(bool dtop) {
|
|
||||||
this->top = dtop;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
keyword_info<T>& mult(bool m) {
|
|
||||||
this->multiplier = m;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
keyword_info<T>& global_kw(bool g) {
|
|
||||||
this->global = g;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // end namespace Keywords
|
|
||||||
} // end namespace Fieldprops
|
|
||||||
} //end namespace Opm
|
|
||||||
#endif //OPM_KEYWORDS_HPP
|
|
||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <opm/parser/eclipse/EclipseState/Grid/FieldPropsManager.hpp>
|
#include <opm/parser/eclipse/EclipseState/Grid/FieldPropsManager.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Grid/FaceDir.hpp>
|
#include <opm/parser/eclipse/EclipseState/Grid/FaceDir.hpp>
|
||||||
|
#include <opm/parser/eclipse/EclipseState/Util/Value.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
|
|||||||
@@ -28,9 +28,7 @@ namespace Opm {
|
|||||||
enum ModeEnum {
|
enum ModeEnum {
|
||||||
ALL = 1,
|
ALL = 1,
|
||||||
TOPBOT = 2,
|
TOPBOT = 2,
|
||||||
TOP = 3,
|
TOP = 3
|
||||||
GAP = 4,
|
|
||||||
NOGAP = 5,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::string PinchMode2String(const ModeEnum enumValue);
|
const std::string PinchMode2String(const ModeEnum enumValue);
|
||||||
|
|||||||
@@ -19,147 +19,227 @@
|
|||||||
#ifndef ECLIPSE_SATFUNCPROPERTY_INITIALIZERS_HPP
|
#ifndef ECLIPSE_SATFUNCPROPERTY_INITIALIZERS_HPP
|
||||||
#define ECLIPSE_SATFUNCPROPERTY_INITIALIZERS_HPP
|
#define ECLIPSE_SATFUNCPROPERTY_INITIALIZERS_HPP
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
|
|
||||||
class Phases;
|
class Phases;
|
||||||
class TableManager;
|
class TableManager;
|
||||||
}
|
|
||||||
|
|
||||||
namespace Opm { namespace satfunc {
|
namespace satfunc {
|
||||||
|
|
||||||
/// Collection of unscaled/raw saturation range endpoints extracted
|
std::vector<double> SGLEndpoint(const TableManager&,
|
||||||
/// directly from tables of tabulated saturation functions.
|
const Phases&,
|
||||||
struct RawTableEndPoints
|
const std::vector<double>&,
|
||||||
{
|
const std::vector<int>&,
|
||||||
/// Connate saturation endpoints
|
const std::vector<int>&);
|
||||||
struct {
|
|
||||||
/// Connate gas saturation. One value for each saturation region.
|
|
||||||
/// All zero values unless gas is an active phase.
|
|
||||||
std::vector<double> gas;
|
|
||||||
|
|
||||||
/// Connate water saturation. One value for each saturation region.
|
std::vector<double> ISGLEndpoint(const TableManager&,
|
||||||
/// All zero values unless water is an active phase.
|
const Phases&,
|
||||||
std::vector<double> water;
|
const std::vector<double>&,
|
||||||
} connate;
|
const std::vector<int>&,
|
||||||
|
const std::vector<int>&);
|
||||||
|
|
||||||
/// Critical saturation endpoints
|
std::vector<double> SGUEndpoint(const TableManager&,
|
||||||
struct {
|
const Phases&,
|
||||||
/// Critical saturation of oil in oil/gas two-phase system. One
|
const std::vector<double>&,
|
||||||
/// value for each saturation region. All zero values unless oil
|
const std::vector<int>&,
|
||||||
/// is an active phase.
|
const std::vector<int>&);
|
||||||
std::vector<double> oil_in_gas;
|
|
||||||
|
|
||||||
/// Critical saturation of oil in oil/water two-phase system. One
|
std::vector<double> ISGUEndpoint(const TableManager&,
|
||||||
/// value for each saturation region. All zero values unless oil
|
const Phases&,
|
||||||
/// is an active phase.
|
const std::vector<double>&,
|
||||||
std::vector<double> oil_in_water;
|
const std::vector<int>&,
|
||||||
|
const std::vector<int>&);
|
||||||
|
|
||||||
/// Critical saturation of gas. One value for each saturation
|
std::vector<double> SWLEndpoint(const TableManager&,
|
||||||
/// region. All zero values unless oil is an active phase.
|
const Phases&,
|
||||||
std::vector<double> gas;
|
const std::vector<double>&,
|
||||||
|
const std::vector<int>&,
|
||||||
|
const std::vector<int>&);
|
||||||
|
|
||||||
/// Critical saturation of water. One value for each saturation
|
std::vector<double> ISWLEndpoint(const TableManager&,
|
||||||
/// region. All zero values unless oil is an active phase.
|
const Phases&,
|
||||||
std::vector<double> water;
|
const std::vector<double>&,
|
||||||
} critical;
|
const std::vector<int>&,
|
||||||
|
const std::vector<int>&);
|
||||||
|
|
||||||
/// Maximum saturation endpoints
|
std::vector<double> SWUEndpoint(const TableManager&,
|
||||||
struct {
|
const Phases&,
|
||||||
/// Maximum gas saturation value. One value for each saturation
|
const std::vector<double>&,
|
||||||
/// region All zero values unless gas is an active phase.
|
const std::vector<int>&,
|
||||||
std::vector<double> gas;
|
const std::vector<int>&);
|
||||||
|
|
||||||
/// Maximum water saturation value. One value for each saturation
|
std::vector<double> ISWUEndpoint(const TableManager&,
|
||||||
/// region All zero values unless gas is an active phase.
|
const Phases&,
|
||||||
std::vector<double> water;
|
const std::vector<double>&,
|
||||||
} maximum;
|
const std::vector<int>&,
|
||||||
};
|
const std::vector<int>&);
|
||||||
|
|
||||||
/// Collection of unscaled/raw saturation function value range endpoints
|
std::vector<double> SGCREndpoint(const TableManager&,
|
||||||
/// extracted directly from tables of tabulated saturation functions.
|
const Phases&,
|
||||||
struct RawFunctionValues
|
const std::vector<double>&,
|
||||||
{
|
const std::vector<int>&,
|
||||||
/// Function values for relative permeability of oil.
|
const std::vector<int>&);
|
||||||
struct {
|
|
||||||
/// Maximum relative permeability value of oil in both oil/gas and
|
|
||||||
/// oil/water two-phase systems. One value for each saturation
|
|
||||||
/// region. All zero values unless oil is an active phase.
|
|
||||||
std::vector<double> max;
|
|
||||||
|
|
||||||
/// Relative permeability of oil at critical saturation of
|
std::vector<double> ISGCREndpoint(const TableManager&,
|
||||||
/// displacing phase in oil/gas two-phase system. One value for
|
const Phases&,
|
||||||
/// each saturation region. All zero values unless oil is
|
const std::vector<double>&,
|
||||||
/// an active phase.
|
const std::vector<int>&,
|
||||||
std::vector<double> rg;
|
const std::vector<int>&);
|
||||||
|
|
||||||
/// Relative permeability of oil at critical saturation of
|
std::vector<double> SOWCREndpoint(const TableManager&,
|
||||||
/// displacing phase in oil/water two-phase system. One value
|
const Phases&,
|
||||||
/// for each saturation region. All zero values unless oil is
|
const std::vector<double>&,
|
||||||
/// an active phase.
|
const std::vector<int>&,
|
||||||
std::vector<double> rw;
|
const std::vector<int>&);
|
||||||
} kro;
|
|
||||||
|
|
||||||
/// Function values for relative permeability of gas.
|
std::vector<double> ISOWCREndpoint(const TableManager&,
|
||||||
struct {
|
const Phases&,
|
||||||
/// Maximum relative permeability value of gas. One value for
|
const std::vector<double>&,
|
||||||
/// each saturation region. All zero values unless gas is
|
const std::vector<int>&,
|
||||||
/// an active phase.
|
const std::vector<int>&);
|
||||||
std::vector<double> max;
|
|
||||||
|
|
||||||
/// Relative permeability of gas at critical saturation of
|
std::vector<double> SOGCREndpoint(const TableManager&,
|
||||||
/// displacing phase. One value for each saturation region.
|
const Phases&,
|
||||||
/// All zero values unless gas is an active phase.
|
const std::vector<double>&,
|
||||||
std::vector<double> r;
|
const std::vector<int>&,
|
||||||
} krg;
|
const std::vector<int>&);
|
||||||
|
|
||||||
/// Function values for relative permeability of gas.
|
std::vector<double> ISOGCREndpoint(const TableManager&,
|
||||||
struct {
|
const Phases&,
|
||||||
/// Maximum relative permeability value of water. One value for
|
const std::vector<double>&,
|
||||||
/// each saturation region. All zero values unless water is
|
const std::vector<int>&,
|
||||||
/// an active phase.
|
const std::vector<int>&);
|
||||||
std::vector<double> max;
|
|
||||||
|
|
||||||
/// Relative permeability of water at critical saturation of
|
std::vector<double> SWCREndpoint(const TableManager&,
|
||||||
/// displacing phase. One value for each saturation region.
|
const Phases&,
|
||||||
/// All zero values unless water is an active phase.
|
const std::vector<double>&,
|
||||||
std::vector<double> r;
|
const std::vector<int>&,
|
||||||
} krw;
|
const std::vector<int>&);
|
||||||
|
|
||||||
/// Maximum capillary function values.
|
std::vector<double> ISWCREndpoint(const TableManager&,
|
||||||
struct {
|
const Phases&,
|
||||||
/// Maximum gas/oil capillary pressure value (Pg - Po). One
|
const std::vector<double>&,
|
||||||
/// value for each saturation region. All zero values unless
|
const std::vector<int>&,
|
||||||
/// both gas and oil are active phase.
|
const std::vector<int>&);
|
||||||
std::vector<double> g;
|
|
||||||
|
|
||||||
/// Maximum oil/eater capillary pressure value (Po - Pw). One
|
std::vector<double> PCWEndpoint(const TableManager&,
|
||||||
/// value for each saturation region. All zero values unless
|
const Phases&,
|
||||||
/// both oil and water are active phase.
|
const std::vector<double>&,
|
||||||
std::vector<double> w;
|
const std::vector<int>&,
|
||||||
} pc;
|
const std::vector<int>&);
|
||||||
};
|
|
||||||
|
|
||||||
std::shared_ptr<RawTableEndPoints>
|
std::vector<double> IPCWEndpoint(const TableManager&,
|
||||||
getRawTableEndpoints(const Opm::TableManager& tm,
|
const Phases&,
|
||||||
const Opm::Phases& phases,
|
const std::vector<double>&,
|
||||||
const double tolcrit);
|
const std::vector<int>&,
|
||||||
|
const std::vector<int>&);
|
||||||
|
|
||||||
std::shared_ptr<RawFunctionValues>
|
std::vector<double> PCGEndpoint(const TableManager&,
|
||||||
getRawFunctionValues(const Opm::TableManager& tm,
|
const Phases&,
|
||||||
const Opm::Phases& phases,
|
const std::vector<double>&,
|
||||||
const RawTableEndPoints& ep);
|
const std::vector<int>&,
|
||||||
|
const std::vector<int>&);
|
||||||
|
|
||||||
|
std::vector<double> IPCGEndpoint(const TableManager&,
|
||||||
|
const Phases&,
|
||||||
|
const std::vector<double>&,
|
||||||
|
const std::vector<int>&,
|
||||||
|
const std::vector<int>&);
|
||||||
|
|
||||||
|
std::vector<double> KRWEndpoint(const TableManager&,
|
||||||
|
const Phases&,
|
||||||
|
const std::vector<double>&,
|
||||||
|
const std::vector<int>&,
|
||||||
|
const std::vector<int>&);
|
||||||
|
|
||||||
|
std::vector<double> IKRWEndpoint(const TableManager&,
|
||||||
|
const Phases&,
|
||||||
|
const std::vector<double>&,
|
||||||
|
const std::vector<int>&,
|
||||||
|
const std::vector<int>&);
|
||||||
|
|
||||||
|
std::vector<double> KRWREndpoint(const TableManager&,
|
||||||
|
const Phases&,
|
||||||
|
const std::vector<double>&,
|
||||||
|
const std::vector<int>&,
|
||||||
|
const std::vector<int>&);
|
||||||
|
|
||||||
|
std::vector<double> IKRWREndpoint(const TableManager&,
|
||||||
|
const Phases&,
|
||||||
|
const std::vector<double>&,
|
||||||
|
const std::vector<int>&,
|
||||||
|
const std::vector<int>&);
|
||||||
|
|
||||||
|
std::vector<double> KROEndpoint(const TableManager&,
|
||||||
|
const Phases&,
|
||||||
|
const std::vector<double>&,
|
||||||
|
const std::vector<int>&,
|
||||||
|
const std::vector<int>&);
|
||||||
|
|
||||||
|
std::vector<double> IKROEndpoint(const TableManager&,
|
||||||
|
const Phases&,
|
||||||
|
const std::vector<double>&,
|
||||||
|
const std::vector<int>&,
|
||||||
|
const std::vector<int>&);
|
||||||
|
|
||||||
|
std::vector<double> KRORWEndpoint(const TableManager&,
|
||||||
|
const Phases&,
|
||||||
|
const std::vector<double>&,
|
||||||
|
const std::vector<int>&,
|
||||||
|
const std::vector<int>&);
|
||||||
|
|
||||||
|
std::vector<double> IKRORWEndpoint(const TableManager&,
|
||||||
|
const Phases&,
|
||||||
|
const std::vector<double>&,
|
||||||
|
const std::vector<int>&,
|
||||||
|
const std::vector<int>&);
|
||||||
|
|
||||||
|
std::vector<double> KRORGEndpoint(const TableManager&,
|
||||||
|
const Phases&,
|
||||||
|
const std::vector<double>&,
|
||||||
|
const std::vector<int>&,
|
||||||
|
const std::vector<int>&);
|
||||||
|
|
||||||
|
std::vector<double> IKRORGEndpoint(const TableManager&,
|
||||||
|
const Phases&,
|
||||||
|
const std::vector<double>&,
|
||||||
|
const std::vector<int>&,
|
||||||
|
const std::vector<int>&);
|
||||||
|
|
||||||
|
std::vector<double> KRGEndpoint(const TableManager&,
|
||||||
|
const Phases&,
|
||||||
|
const std::vector<double>&,
|
||||||
|
const std::vector<int>&,
|
||||||
|
const std::vector<int>&);
|
||||||
|
|
||||||
|
std::vector<double> IKRGEndpoint(const TableManager&,
|
||||||
|
const Phases&,
|
||||||
|
const std::vector<double>&,
|
||||||
|
const std::vector<int>&,
|
||||||
|
const std::vector<int>&);
|
||||||
|
|
||||||
|
std::vector<double> KRGREndpoint(const TableManager&,
|
||||||
|
const Phases&,
|
||||||
|
const std::vector<double>&,
|
||||||
|
const std::vector<int>&,
|
||||||
|
const std::vector<int>&);
|
||||||
|
|
||||||
|
std::vector<double> IKRGREndpoint(const TableManager&,
|
||||||
|
const Phases&,
|
||||||
|
const std::vector<double>&,
|
||||||
|
const std::vector<int>&,
|
||||||
|
const std::vector<int>&);
|
||||||
|
|
||||||
std::vector<double> init(const std::string& kewyord,
|
std::vector<double> init(const std::string& kewyord,
|
||||||
const TableManager& tables,
|
const TableManager& tables,
|
||||||
const Phases& phases,
|
const Phases& phases,
|
||||||
const RawTableEndPoints& ep,
|
|
||||||
const std::vector<double>& cell_depth,
|
const std::vector<double>& cell_depth,
|
||||||
const std::vector<int>& num,
|
const std::vector<int>& num,
|
||||||
const std::vector<int>& endnum);
|
const std::vector<int>& endnum);
|
||||||
|
}
|
||||||
}} // namespace Opm::satfunc
|
}
|
||||||
|
|
||||||
#endif // ECLIPSE_SATFUNCPROPERTY_INITIALIZERS_HPP
|
#endif // ECLIPSE_SATFUNCPROPERTY_INITIALIZERS_HPP
|
||||||
|
|||||||
@@ -1,107 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2020 Equinor AS.
|
|
||||||
|
|
||||||
This file is part of the Open Porous Media project (OPM).
|
|
||||||
|
|
||||||
OPM is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OPM is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
#ifndef TRAN_CALCULATOR_HPP
|
|
||||||
#define TRAN_CALCULATOR_HPP
|
|
||||||
|
|
||||||
#include<string>
|
|
||||||
|
|
||||||
#include <opm/parser/eclipse/EclipseState/Grid/Keywords.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
namespace Opm
|
|
||||||
{
|
|
||||||
|
|
||||||
namespace Fieldprops
|
|
||||||
{
|
|
||||||
|
|
||||||
enum class ScalarOperation {
|
|
||||||
ADD = 1,
|
|
||||||
EQUAL = 2,
|
|
||||||
MUL = 3,
|
|
||||||
MIN = 4,
|
|
||||||
MAX = 5
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class TranCalculator {
|
|
||||||
public:
|
|
||||||
|
|
||||||
struct TranAction {
|
|
||||||
ScalarOperation op;
|
|
||||||
std::string field;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
TranCalculator(const std::string& name_arg) :
|
|
||||||
m_name(name_arg)
|
|
||||||
{}
|
|
||||||
|
|
||||||
std::string next_name() const {
|
|
||||||
return this->m_name + std::to_string( this->actions.size() );
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<TranAction>::const_iterator begin() const {
|
|
||||||
return this->actions.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<TranAction>::const_iterator end() const {
|
|
||||||
return this->actions.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
void add_action(ScalarOperation op, const std::string& field) {
|
|
||||||
this->actions.push_back(TranAction{op, field});
|
|
||||||
}
|
|
||||||
|
|
||||||
std::size_t size() const {
|
|
||||||
return this->actions.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string& name() const {
|
|
||||||
return this->m_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
keywords::keyword_info<double> make_kw_info(ScalarOperation op) {
|
|
||||||
keywords::keyword_info<double> kw_info;
|
|
||||||
switch (op) {
|
|
||||||
case ScalarOperation::MUL:
|
|
||||||
kw_info.init(1);
|
|
||||||
break;
|
|
||||||
case ScalarOperation::ADD:
|
|
||||||
kw_info.init(0);
|
|
||||||
break;
|
|
||||||
case ScalarOperation::MAX:
|
|
||||||
kw_info.init(std::numeric_limits<double>::max());
|
|
||||||
break;
|
|
||||||
case ScalarOperation::MIN:
|
|
||||||
kw_info.init(std::numeric_limits<double>::lowest());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return kw_info;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
std::string m_name;
|
|
||||||
std::vector<TranAction> actions;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Fieldprops
|
|
||||||
} // end namespace Opm
|
|
||||||
#endif // TRAN_CALCULATOR_HPP
|
|
||||||
@@ -165,7 +165,7 @@ namespace Opm {
|
|||||||
const std::string& getEclipseInputPath() const;
|
const std::string& getEclipseInputPath() const;
|
||||||
|
|
||||||
void overrideNOSIM(bool nosim);
|
void overrideNOSIM(bool nosim);
|
||||||
void consistentFileFlags();
|
|
||||||
|
|
||||||
std::string getRestartFileName(const std::string& restart_base, int report_step, bool output) const;
|
std::string getRestartFileName(const std::string& restart_base, int report_step, bool output) const;
|
||||||
|
|
||||||
|
|||||||
@@ -21,9 +21,7 @@
|
|||||||
|
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <optional>
|
|
||||||
|
|
||||||
#include <opm/common/OpmLog/KeywordLocation.hpp>
|
|
||||||
#include <opm/parser/eclipse/EclipseState/Tables/Tabdims.hpp>
|
#include <opm/parser/eclipse/EclipseState/Tables/Tabdims.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/EndpointScaling.hpp>
|
#include <opm/parser/eclipse/EclipseState/EndpointScaling.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQParams.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQParams.hpp>
|
||||||
@@ -108,17 +106,11 @@ public:
|
|||||||
return this->nWMax;
|
return this->nWMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::optional<KeywordLocation>& location() const {
|
|
||||||
return this->m_location;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool operator==(const Welldims& data) const {
|
bool operator==(const Welldims& data) const {
|
||||||
return this->maxConnPerWell() == data.maxConnPerWell() &&
|
return this->maxConnPerWell() == data.maxConnPerWell() &&
|
||||||
this->maxWellsPerGroup() == data.maxWellsPerGroup() &&
|
this->maxWellsPerGroup() == data.maxWellsPerGroup() &&
|
||||||
this->maxGroupsInField() == data.maxGroupsInField() &&
|
this->maxGroupsInField() == data.maxGroupsInField() &&
|
||||||
this->maxWellsInField() == data.maxWellsInField() &&
|
this->maxWellsInField() == data.maxWellsInField();
|
||||||
this->location() == data.location();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Serializer>
|
template<class Serializer>
|
||||||
@@ -128,7 +120,6 @@ public:
|
|||||||
serializer(nCWMax);
|
serializer(nCWMax);
|
||||||
serializer(nWGMax);
|
serializer(nWGMax);
|
||||||
serializer(nGMax);
|
serializer(nGMax);
|
||||||
serializer(m_location);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -136,7 +127,6 @@ private:
|
|||||||
int nCWMax { 0 };
|
int nCWMax { 0 };
|
||||||
int nWGMax { 0 };
|
int nWGMax { 0 };
|
||||||
int nGMax { 0 };
|
int nGMax { 0 };
|
||||||
std::optional<KeywordLocation> m_location;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class WellSegmentDims {
|
class WellSegmentDims {
|
||||||
@@ -288,8 +278,6 @@ public:
|
|||||||
const EclHysterConfig& hysterPar() const noexcept;
|
const EclHysterConfig& hysterPar() const noexcept;
|
||||||
const Actdims& actdims() const noexcept;
|
const Actdims& actdims() const noexcept;
|
||||||
const SatFuncControls& saturationFunctionControls() const noexcept;
|
const SatFuncControls& saturationFunctionControls() const noexcept;
|
||||||
int nupcol() const noexcept;
|
|
||||||
bool co2Storage() const noexcept;
|
|
||||||
|
|
||||||
bool operator==(const Runspec& data) const;
|
bool operator==(const Runspec& data) const;
|
||||||
|
|
||||||
@@ -305,8 +293,6 @@ public:
|
|||||||
hystpar.serializeOp(serializer);
|
hystpar.serializeOp(serializer);
|
||||||
m_actdims.serializeOp(serializer);
|
m_actdims.serializeOp(serializer);
|
||||||
m_sfuncctrl.serializeOp(serializer);
|
m_sfuncctrl.serializeOp(serializer);
|
||||||
serializer(m_nupcol);
|
|
||||||
serializer(m_co2storage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -319,8 +305,6 @@ private:
|
|||||||
EclHysterConfig hystpar;
|
EclHysterConfig hystpar;
|
||||||
Actdims m_actdims;
|
Actdims m_actdims;
|
||||||
SatFuncControls m_sfuncctrl;
|
SatFuncControls m_sfuncctrl;
|
||||||
int m_nupcol;
|
|
||||||
bool m_co2storage;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WListManager.hpp>
|
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
namespace Action {
|
namespace Action {
|
||||||
@@ -38,7 +37,7 @@ namespace Action {
|
|||||||
|
|
||||||
class Context {
|
class Context {
|
||||||
public:
|
public:
|
||||||
explicit Context(const SummaryState& summary_state, const WListManager& wlm);
|
explicit Context(const SummaryState& summary_state);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The get methods will first check the internal storage in the 'values' map
|
The get methods will first check the internal storage in the 'values' map
|
||||||
@@ -51,11 +50,9 @@ public:
|
|||||||
void add(const std::string& func, double value);
|
void add(const std::string& func, double value);
|
||||||
|
|
||||||
std::vector<std::string> wells(const std::string& func) const;
|
std::vector<std::string> wells(const std::string& func) const;
|
||||||
const WListManager& wlist_manager() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const SummaryState& summary_state;
|
const SummaryState& summary_state;
|
||||||
const WListManager& wlm;
|
|
||||||
std::map<std::string, double> values;
|
std::map<std::string, double> values;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,9 +101,9 @@ public:
|
|||||||
void add_well(const std::string& well);
|
void add_well(const std::string& well);
|
||||||
|
|
||||||
Result& operator|=(const Result& other);
|
Result& operator|=(const Result& other);
|
||||||
Result& operator=(const Result& src);
|
Result& operator=(const Result& src);
|
||||||
Result& operator&=(const Result& other);
|
Result& operator&=(const Result& other);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void assign(bool value);
|
void assign(bool value);
|
||||||
bool result;
|
bool result;
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ namespace Opm {
|
|||||||
class DeckKeyword;
|
class DeckKeyword;
|
||||||
|
|
||||||
namespace Action {
|
namespace Action {
|
||||||
class State;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The ActionX class internalizes the ACTIONX keyword. This keyword represents a
|
The ActionX class internalizes the ACTIONX keyword. This keyword represents a
|
||||||
@@ -72,15 +71,13 @@ public:
|
|||||||
static ActionX serializeObject();
|
static ActionX serializeObject();
|
||||||
|
|
||||||
void addKeyword(const DeckKeyword& kw);
|
void addKeyword(const DeckKeyword& kw);
|
||||||
bool ready(const State& state, std::time_t sim_time) const;
|
bool ready(std::time_t sim_time) const;
|
||||||
Action::Result eval(const Action::Context& context) const;
|
Action::Result eval(std::time_t sim_time, const Action::Context& context) const;
|
||||||
|
|
||||||
|
|
||||||
std::string name() const { return this->m_name; }
|
std::string name() const { return this->m_name; }
|
||||||
size_t max_run() const { return this->m_max_run; }
|
size_t max_run() const { return this->m_max_run; }
|
||||||
double min_wait() const { return this->m_min_wait; }
|
double min_wait() const { return this->m_min_wait; }
|
||||||
std::size_t id() const;
|
|
||||||
void update_id(std::size_t id);
|
|
||||||
std::time_t start_time() const { return this->m_start_time; }
|
std::time_t start_time() const { return this->m_start_time; }
|
||||||
std::vector<DeckKeyword>::const_iterator begin() const;
|
std::vector<DeckKeyword>::const_iterator begin() const;
|
||||||
std::vector<DeckKeyword>::const_iterator end() const;
|
std::vector<DeckKeyword>::const_iterator end() const;
|
||||||
@@ -102,10 +99,11 @@ public:
|
|||||||
serializer(m_max_run);
|
serializer(m_max_run);
|
||||||
serializer(m_min_wait);
|
serializer(m_min_wait);
|
||||||
serializer(m_start_time);
|
serializer(m_start_time);
|
||||||
serializer(m_id);
|
|
||||||
serializer.vector(keywords);
|
serializer.vector(keywords);
|
||||||
condition.serializeOp(serializer);
|
condition.serializeOp(serializer);
|
||||||
serializer.vector(m_conditions);
|
serializer.vector(m_conditions);
|
||||||
|
serializer(run_count);
|
||||||
|
serializer(last_run);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -113,11 +111,12 @@ private:
|
|||||||
size_t m_max_run = 0;
|
size_t m_max_run = 0;
|
||||||
double m_min_wait = 0.0;
|
double m_min_wait = 0.0;
|
||||||
std::time_t m_start_time;
|
std::time_t m_start_time;
|
||||||
std::size_t m_id = 0;
|
|
||||||
|
|
||||||
std::vector<DeckKeyword> keywords;
|
std::vector<DeckKeyword> keywords;
|
||||||
Action::AST condition;
|
Action::AST condition;
|
||||||
std::vector<Condition> m_conditions;
|
std::vector<Condition> m_conditions;
|
||||||
|
mutable size_t run_count = 0;
|
||||||
|
mutable std::time_t last_run = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,6 @@
|
|||||||
namespace Opm {
|
namespace Opm {
|
||||||
namespace Action {
|
namespace Action {
|
||||||
|
|
||||||
class State;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The Actions class is a container of ACTIONX keywords. The main functionality
|
The Actions class is a container of ACTIONX keywords. The main functionality
|
||||||
is to provide a list of ACTIONX keywords which are ready to be evaluated.
|
is to provide a list of ACTIONX keywords which are ready to be evaluated.
|
||||||
@@ -50,10 +48,10 @@ public:
|
|||||||
bool empty() const;
|
bool empty() const;
|
||||||
void add(const ActionX& action);
|
void add(const ActionX& action);
|
||||||
void add(const PyAction& pyaction);
|
void add(const PyAction& pyaction);
|
||||||
bool ready(const State& state, std::time_t sim_time) const;
|
bool ready(std::time_t sim_time) const;
|
||||||
const ActionX& get(const std::string& name) const;
|
const ActionX& get(const std::string& name) const;
|
||||||
const ActionX& get(std::size_t index) const;
|
const ActionX& get(std::size_t index) const;
|
||||||
std::vector<const ActionX *> pending(const State& state, std::time_t sim_time) const;
|
std::vector<const ActionX *> pending(std::time_t sim_time) const;
|
||||||
std::vector<const PyAction *> pending_python() const;
|
std::vector<const PyAction *> pending_python() const;
|
||||||
|
|
||||||
std::vector<ActionX>::const_iterator begin() const;
|
std::vector<ActionX>::const_iterator begin() const;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <opm/common/OpmLog/KeywordLocation.hpp>
|
#include <opm/common/OpmLog/Location.hpp>
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ enum class Comparator {
|
|||||||
|
|
||||||
|
|
||||||
Condition() = default;
|
Condition() = default;
|
||||||
Condition(const std::vector<std::string>& tokens, const KeywordLocation& location);
|
Condition(const std::vector<std::string>& tokens, const Location& location);
|
||||||
|
|
||||||
|
|
||||||
Quantity lhs;
|
Quantity lhs;
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2020 Equinor ASA.
|
|
||||||
|
|
||||||
This file is part of the Open Porous Media project (OPM).
|
|
||||||
|
|
||||||
OPM is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OPM is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ACTION_STATE_HPP
|
|
||||||
#define ACTION_STATE_HPP
|
|
||||||
|
|
||||||
#include <ctime>
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
namespace Opm {
|
|
||||||
namespace Action {
|
|
||||||
|
|
||||||
class ActionX;
|
|
||||||
class State {
|
|
||||||
|
|
||||||
struct RunState {
|
|
||||||
RunState(std::time_t sim_time) :
|
|
||||||
run_count(1),
|
|
||||||
last_run(sim_time)
|
|
||||||
{}
|
|
||||||
|
|
||||||
void add_run(std::time_t sim_time) {
|
|
||||||
this->last_run = sim_time;
|
|
||||||
this->run_count += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::size_t run_count;
|
|
||||||
std::time_t last_run;
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
void add_run(const ActionX& action, std::time_t sim_time);
|
|
||||||
std::size_t run_count(const ActionX& action) const;
|
|
||||||
std::time_t run_time(const ActionX& action) const;
|
|
||||||
private:
|
|
||||||
std::map<std::pair<std::string, std::size_t>, RunState> run_state;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -21,11 +21,10 @@
|
|||||||
#ifndef DYNAMICSTATE_HPP_
|
#ifndef DYNAMICSTATE_HPP_
|
||||||
#define DYNAMICSTATE_HPP_
|
#define DYNAMICSTATE_HPP_
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <optional>
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <utility>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
|
#include <opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp>
|
||||||
|
|
||||||
@@ -156,49 +155,50 @@ class DynamicState {
|
|||||||
Schedule object, if e.g. a well is initially closed in the interval
|
Schedule object, if e.g. a well is initially closed in the interval
|
||||||
[T1,T2] and then opened at time T1 < Tx < T2 then the open should be
|
[T1,T2] and then opened at time T1 < Tx < T2 then the open should be
|
||||||
applied for all times in the range [Tx,T2].
|
applied for all times in the range [Tx,T2].
|
||||||
|
|
||||||
The return value is the index of the first element different from value,
|
|
||||||
or an empty optional if there is no such element.
|
|
||||||
*/
|
*/
|
||||||
std::optional<std::size_t> update_equal(size_t index, const T& value) {
|
void update_equal(size_t index, const T& value) {
|
||||||
if (this->m_data.size() <= index)
|
if (this->m_data.size() <= index)
|
||||||
throw std::out_of_range("Invalid index for update_equal()");
|
throw std::out_of_range("Invalid index for update_equal()");
|
||||||
|
|
||||||
const T prev_value = this->m_data[index];
|
const T prev_value = this->m_data[index];
|
||||||
//if (prev_value == value)
|
if (prev_value == value)
|
||||||
// return {};
|
return;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (this->m_data[index] != prev_value)
|
if (this->m_data[index] != prev_value)
|
||||||
return index;
|
break;
|
||||||
|
|
||||||
this->m_data[index] = value;
|
this->m_data[index] = value;
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
if (index == this->m_data.size())
|
if (index == this->m_data.size())
|
||||||
return {};
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Will return the index of the first occurence of @value
|
/// Will return the index of the first occurence of @value, or
|
||||||
std::optional<std::size_t> find(const T& value) const {
|
/// -1 if @value is not found.
|
||||||
|
int find(const T& value) const {
|
||||||
auto iter = std::find( m_data.begin() , m_data.end() , value);
|
auto iter = std::find( m_data.begin() , m_data.end() , value);
|
||||||
if( iter == this->m_data.end() ) return {};
|
if( iter == this->m_data.end() ) return -1;
|
||||||
|
|
||||||
return std::distance( m_data.begin() , iter );
|
return std::distance( m_data.begin() , iter );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename P>
|
template<typename P>
|
||||||
std::optional<std::size_t> find_if(P&& pred) const {
|
int find_if(P&& pred) const {
|
||||||
auto iter = std::find_if(m_data.begin(), m_data.end(), std::forward<P>(pred));
|
auto iter = std::find_if(m_data.begin(), m_data.end(), std::forward<P>(pred));
|
||||||
if( iter == this->m_data.end() ) return {};
|
if( iter == this->m_data.end() ) return -1;
|
||||||
|
|
||||||
return std::distance( m_data.begin() , iter );
|
return std::distance( m_data.begin() , iter );
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Will return the index of the first value which is != @value
|
/// Will return the index of the first value which is != @value, or -1
|
||||||
std::optional<std::size_t> find_not(const T& value) const {
|
/// if all values are == @value
|
||||||
|
int find_not(const T& value) const {
|
||||||
auto iter = std::find_if_not( m_data.begin() , m_data.end() , [&value] (const T& elm) { return value == elm; });
|
auto iter = std::find_if_not( m_data.begin() , m_data.end() , [&value] (const T& elm) { return value == elm; });
|
||||||
if( iter == this->m_data.end() ) return {};
|
if( iter == this->m_data.end() ) return -1;
|
||||||
|
|
||||||
return std::distance( m_data.begin() , iter );
|
return std::distance( m_data.begin() , iter );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,22 +35,22 @@ namespace Opm
|
|||||||
the Schedule object the NEW_WELL event is triggered
|
the Schedule object the NEW_WELL event is triggered
|
||||||
every time a WELSPECS keyword is encountered.
|
every time a WELSPECS keyword is encountered.
|
||||||
*/
|
*/
|
||||||
NEW_WELL = (1 << 0),
|
NEW_WELL = 1,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
WHen the well data is updated with the WELSPECS keyword
|
WHen the well data is updated with the WELSPECS keyword
|
||||||
this event is triggered. Only applies to individual
|
this event is triggered. Only applies to individual
|
||||||
wells, and not the global Schedule object.
|
wells, and not the global Schedule object.
|
||||||
*/
|
*/
|
||||||
WELL_WELSPECS_UPDATE = (1 << 1),
|
WELL_WELSPECS_UPDATE = 2,
|
||||||
|
|
||||||
|
|
||||||
//WELL_POLYMER_UPDATE = (1 << 2),
|
//WELL_POLYMER_UPDATE = 4,
|
||||||
/*
|
/*
|
||||||
The NEW_GROUP event is triggered by the WELSPECS and
|
The NEW_GROUP event is triggered by the WELSPECS and
|
||||||
GRUPTREE keywords.
|
GRUPTREE keywords.
|
||||||
*/
|
*/
|
||||||
NEW_GROUP = (1 << 3),
|
NEW_GROUP = 8,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The PRODUCTION_UPDATE event is triggered by the
|
The PRODUCTION_UPDATE event is triggered by the
|
||||||
@@ -59,59 +59,48 @@ namespace Opm
|
|||||||
is changed. Quite simlar for INJECTION_UPDATE and
|
is changed. Quite simlar for INJECTION_UPDATE and
|
||||||
POLYMER_UPDATE.
|
POLYMER_UPDATE.
|
||||||
*/
|
*/
|
||||||
PRODUCTION_UPDATE = (1 << 4),
|
PRODUCTION_UPDATE = 16,
|
||||||
INJECTION_UPDATE = (1 << 5),
|
INJECTION_UPDATE = 32,
|
||||||
//POLYMER_UPDATES = (1 << 6),
|
//POLYMER_UPDATES = 64,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This event is triggered if the well status is changed
|
This event is triggered if the well status is changed
|
||||||
between {OPEN,SHUT,STOP,AUTO}. There are many keywords
|
between {OPEN,SHUT,STOP,AUTO}. There are many keywords
|
||||||
which can trigger a well status change.
|
which can trigger a well status change.
|
||||||
*/
|
*/
|
||||||
WELL_STATUS_CHANGE = (1 << 7),
|
WELL_STATUS_CHANGE = 128,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
COMPDAT and WELOPEN
|
COMPDAT and WELOPEN
|
||||||
*/
|
*/
|
||||||
COMPLETION_CHANGE = (1 << 8),
|
COMPLETION_CHANGE = 256,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The well group topolyg has changed.
|
The well group topolyg has changed.
|
||||||
*/
|
*/
|
||||||
GROUP_CHANGE = (1 << 9),
|
GROUP_CHANGE = 512,
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Geology modifier.
|
Geology modifier.
|
||||||
*/
|
*/
|
||||||
GEO_MODIFIER = (1 << 10),
|
GEO_MODIFIER = 1024,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TUNING has changed
|
TUNING has changed
|
||||||
*/
|
*/
|
||||||
TUNING_CHANGE = (1 << 11),
|
TUNING_CHANGE = 2048,
|
||||||
|
|
||||||
/* The VFP tables have changed */
|
/* The VFP tables have changed */
|
||||||
VFPINJ_UPDATE = (1 << 12),
|
VFPINJ_UPDATE = 4096,
|
||||||
VFPPROD_UPDATE = (1 << 13),
|
VFPPROD_UPDATE = 8192,
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
GROUP production or injection targets has changed
|
GROUP production or injection targets has changed
|
||||||
*/
|
*/
|
||||||
GROUP_PRODUCTION_UPDATE = (1 << 14),
|
GROUP_PRODUCTION_UPDATE = 16384,
|
||||||
GROUP_INJECTION_UPDATE = (1 << 15),
|
GROUP_INJECTION_UPDATE = 32768
|
||||||
|
|
||||||
/*
|
|
||||||
* New explicit well productivity/injectivity assignment.
|
|
||||||
*/
|
|
||||||
WELL_PRODUCTIVITY_INDEX = (1 << 16),
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Well's internal WellConnections structure changed.
|
|
||||||
* Rerun WELPI scaling if applicable.
|
|
||||||
*/
|
|
||||||
WELL_CONNECTIONS_UPDATED = (1 << 17),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,254 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2020 Equinor ASA.
|
|
||||||
|
|
||||||
This file is part of the Open Porous Media project (OPM).
|
|
||||||
|
|
||||||
OPM is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OPM is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
#ifndef GAS_LIFT_OPT_HPP
|
|
||||||
#define GAS_LIFT_OPT_HPP
|
|
||||||
|
|
||||||
#include <optional>
|
|
||||||
#include <string>
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
namespace Opm {
|
|
||||||
|
|
||||||
class GasLiftOpt {
|
|
||||||
public:
|
|
||||||
|
|
||||||
class Group {
|
|
||||||
public:
|
|
||||||
Group() = default;
|
|
||||||
|
|
||||||
Group(const std::string& name) :
|
|
||||||
m_name(name)
|
|
||||||
{}
|
|
||||||
|
|
||||||
const std::optional<double>& max_lift_gas() const {
|
|
||||||
return this->m_max_lift_gas;
|
|
||||||
}
|
|
||||||
|
|
||||||
void max_lift_gas(double value) {
|
|
||||||
if (value >= 0)
|
|
||||||
this->m_max_lift_gas = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::optional<double>& max_total_gas() const {
|
|
||||||
return this->m_max_total_gas;
|
|
||||||
}
|
|
||||||
|
|
||||||
void max_total_gas(double value) {
|
|
||||||
if (value >= 0)
|
|
||||||
this->m_max_total_gas = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string& name() const {
|
|
||||||
return this->m_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Serializer>
|
|
||||||
void serializeOp(Serializer& serializer)
|
|
||||||
{
|
|
||||||
serializer(m_name);
|
|
||||||
serializer(m_max_lift_gas);
|
|
||||||
serializer(m_max_total_gas);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static Group serializeObject() {
|
|
||||||
Group group;
|
|
||||||
group.m_name = "GR";
|
|
||||||
group.m_max_lift_gas = 100;
|
|
||||||
group.m_max_total_gas = 200;
|
|
||||||
return group;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool operator==(const Group& other) const {
|
|
||||||
return this->m_name == other.m_name &&
|
|
||||||
this->m_max_lift_gas == other.m_max_lift_gas &&
|
|
||||||
this->m_max_total_gas == other.m_max_total_gas;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string m_name;
|
|
||||||
std::optional<double> m_max_lift_gas;
|
|
||||||
std::optional<double> m_max_total_gas;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Well {
|
|
||||||
public:
|
|
||||||
Well() = default;
|
|
||||||
Well(const std::string& name, bool use_glo) :
|
|
||||||
m_name(name),
|
|
||||||
m_use_glo(use_glo)
|
|
||||||
{}
|
|
||||||
|
|
||||||
const std::string& name() const {
|
|
||||||
return this->m_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool use_glo() const {
|
|
||||||
return this->m_use_glo;
|
|
||||||
}
|
|
||||||
|
|
||||||
void max_rate(double value) {
|
|
||||||
this->m_max_rate = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
The semantics of the max_rate is quite complicated:
|
|
||||||
|
|
||||||
1. If the std::optional<double> has a value that value should be
|
|
||||||
used as the maximum rate and all is fine.
|
|
||||||
|
|
||||||
2. If the std::optional<double> does not a have well we must check
|
|
||||||
the value of Well::use_glo():
|
|
||||||
|
|
||||||
False: The maximum gas lift should have been set with WCONPROD /
|
|
||||||
WELTARG - this code does not provide a value in that case.
|
|
||||||
|
|
||||||
True: If the well should be controlled with gas lift optimization
|
|
||||||
the value to use should be the largest ALQ value in the wells
|
|
||||||
VFP table.
|
|
||||||
*/
|
|
||||||
const std::optional<double>& max_rate() const {
|
|
||||||
return this->m_max_rate;
|
|
||||||
}
|
|
||||||
|
|
||||||
void weight_factor(double value) {
|
|
||||||
if (this->m_use_glo)
|
|
||||||
this->m_weight = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
double weight_factor() const {
|
|
||||||
return this->m_weight;
|
|
||||||
}
|
|
||||||
|
|
||||||
void inc_weight_factor(double value) {
|
|
||||||
if (this->m_use_glo)
|
|
||||||
this->m_inc_weight = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
double inc_weight_factor() const {
|
|
||||||
return this->m_inc_weight;
|
|
||||||
}
|
|
||||||
|
|
||||||
void min_rate(double value) {
|
|
||||||
if (this->m_use_glo)
|
|
||||||
this->m_min_rate = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
double min_rate() const {
|
|
||||||
return this->m_min_rate;
|
|
||||||
}
|
|
||||||
|
|
||||||
void alloc_extra_gas(bool value) {
|
|
||||||
if (this->m_use_glo)
|
|
||||||
this->m_alloc_extra_gas = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool alloc_extra_gas() const {
|
|
||||||
return this->m_alloc_extra_gas;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Serializer>
|
|
||||||
void serializeOp(Serializer& serializer)
|
|
||||||
{
|
|
||||||
serializer(m_name);
|
|
||||||
serializer(m_use_glo);
|
|
||||||
serializer(m_max_rate);
|
|
||||||
serializer(m_min_rate);
|
|
||||||
serializer(m_weight);
|
|
||||||
serializer(m_inc_weight);
|
|
||||||
serializer(m_alloc_extra_gas);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Well serializeObject() {
|
|
||||||
Well well;
|
|
||||||
well.m_name = "WELL";
|
|
||||||
well.m_max_rate = 2000;
|
|
||||||
well.m_min_rate = 56;
|
|
||||||
well.m_use_glo = true;
|
|
||||||
well.m_weight = 1.25;
|
|
||||||
well.m_inc_weight = 0.25;
|
|
||||||
well.m_alloc_extra_gas = false;
|
|
||||||
return well;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const Well& other) const {
|
|
||||||
return this->m_name == other.m_name &&
|
|
||||||
this->m_max_rate == other.m_max_rate &&
|
|
||||||
this->m_min_rate == other.m_min_rate &&
|
|
||||||
this->m_use_glo == other.m_use_glo &&
|
|
||||||
this->m_weight == other.m_weight &&
|
|
||||||
this->m_inc_weight == other.m_inc_weight &&
|
|
||||||
this->m_alloc_extra_gas == other.m_alloc_extra_gas;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string m_name;
|
|
||||||
std::optional<double> m_max_rate;
|
|
||||||
double m_min_rate = 0;
|
|
||||||
bool m_use_glo;
|
|
||||||
double m_weight = 1;
|
|
||||||
double m_inc_weight = 0;
|
|
||||||
bool m_alloc_extra_gas = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
GasLiftOpt() = default;
|
|
||||||
|
|
||||||
const Group& group(const std::string& gname) const;
|
|
||||||
const Well& well(const std::string& wname) const;
|
|
||||||
|
|
||||||
double gaslift_increment() const;
|
|
||||||
void gaslift_increment(double gaslift_increment);
|
|
||||||
double min_eco_gradient() const;
|
|
||||||
void min_eco_gradient(double min_eco_gradient);
|
|
||||||
void min_wait(double min_wait);
|
|
||||||
void all_newton(double all_newton);
|
|
||||||
bool all_newton() const;
|
|
||||||
void add_group(const Group& group);
|
|
||||||
void add_well(const Well& well);
|
|
||||||
bool active() const;
|
|
||||||
|
|
||||||
static GasLiftOpt serializeObject();
|
|
||||||
bool operator==(const GasLiftOpt& other) const;
|
|
||||||
|
|
||||||
template<class Serializer>
|
|
||||||
void serializeOp(Serializer& serializer)
|
|
||||||
{
|
|
||||||
serializer(m_increment);
|
|
||||||
serializer(m_min_eco_gradient);
|
|
||||||
serializer(m_min_wait);
|
|
||||||
serializer(m_all_newton);
|
|
||||||
serializer.map(m_groups);
|
|
||||||
serializer.map(m_wells);
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
double m_increment = 0;
|
|
||||||
double m_min_eco_gradient;
|
|
||||||
double m_min_wait;
|
|
||||||
bool m_all_newton = true;
|
|
||||||
|
|
||||||
std::map<std::string, GasLiftOpt::Group> m_groups;
|
|
||||||
std::map<std::string, GasLiftOpt::Well> m_wells;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2020 Equinor ASA.
|
|
||||||
|
|
||||||
This file is part of the Open Porous Media project (OPM).
|
|
||||||
|
|
||||||
OPM is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OPM is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GPMAINT_HPP
|
|
||||||
#define GPMAINT_HPP
|
|
||||||
|
|
||||||
#include <optional>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace Opm {
|
|
||||||
|
|
||||||
class DeckRecord;
|
|
||||||
|
|
||||||
class GPMaint {
|
|
||||||
public:
|
|
||||||
|
|
||||||
enum class FlowTarget {
|
|
||||||
RESV_PROD = 0,
|
|
||||||
RESV_OINJ = 1,
|
|
||||||
RESV_WINJ = 2,
|
|
||||||
RESV_GINJ = 3,
|
|
||||||
SURF_OINJ = 4,
|
|
||||||
SURF_WINJ = 5,
|
|
||||||
SURF_GINJ = 6,
|
|
||||||
};
|
|
||||||
|
|
||||||
GPMaint() = default;
|
|
||||||
explicit GPMaint(const DeckRecord& record);
|
|
||||||
static GPMaint serializeObject();
|
|
||||||
|
|
||||||
double pressure_target() const;
|
|
||||||
double prop_constant() const;
|
|
||||||
double time_constant() const;
|
|
||||||
std::optional<std::pair<std::string, int>> region() const;
|
|
||||||
FlowTarget flow_target() const;
|
|
||||||
bool operator==(const GPMaint& other) const;
|
|
||||||
template<class Serializer>
|
|
||||||
void serializeOp(Serializer& serializer)
|
|
||||||
{
|
|
||||||
serializer(m_flow_target);
|
|
||||||
serializer(m_region_number);
|
|
||||||
serializer(m_region_name);
|
|
||||||
serializer(m_pressure_target);
|
|
||||||
serializer(m_prop_constant);
|
|
||||||
serializer(m_time_constant);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
static FlowTarget FlowTargetFromString(const std::string& stringvalue);
|
|
||||||
FlowTarget m_flow_target;
|
|
||||||
int m_region_number;
|
|
||||||
std::string m_region_name;
|
|
||||||
double m_pressure_target;
|
|
||||||
double m_prop_constant;
|
|
||||||
double m_time_constant;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -41,8 +41,6 @@ public:
|
|||||||
const std::string& parent_name() const;
|
const std::string& parent_name() const;
|
||||||
|
|
||||||
const Group& group() const;
|
const Group& group() const;
|
||||||
std::size_t level() const;
|
|
||||||
std::vector<const GTNode*> all_nodes() const;
|
|
||||||
private:
|
private:
|
||||||
const Group m_group;
|
const Group m_group;
|
||||||
std::size_t m_level;
|
std::size_t m_level;
|
||||||
|
|||||||
@@ -24,24 +24,15 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#include <opm/parser/eclipse/Deck/UDAValue.hpp>
|
#include <opm/parser/eclipse/Deck/UDAValue.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Util/IOrderSet.hpp>
|
#include <opm/parser/eclipse/EclipseState/Util/IOrderSet.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Runspec.hpp>
|
#include <opm/parser/eclipse/EclipseState/Runspec.hpp>
|
||||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GPMaint.hpp>
|
|
||||||
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
|
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
|
|
||||||
namespace RestartIO {
|
|
||||||
struct RstGroup;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class SummaryState;
|
class SummaryState;
|
||||||
class UDQConfig;
|
|
||||||
class UDQActive;
|
|
||||||
class Group {
|
class Group {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -123,7 +114,7 @@ struct GroupInjectionProperties {
|
|||||||
UDAValue target_void_fraction;
|
UDAValue target_void_fraction;
|
||||||
std::string reinj_group;
|
std::string reinj_group;
|
||||||
std::string voidage_group;
|
std::string voidage_group;
|
||||||
bool available_group_control = true;
|
bool available_group_control;
|
||||||
|
|
||||||
static GroupInjectionProperties serializeObject();
|
static GroupInjectionProperties serializeObject();
|
||||||
|
|
||||||
@@ -161,20 +152,14 @@ struct InjectionControls {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct GroupProductionProperties {
|
struct GroupProductionProperties {
|
||||||
GroupProductionProperties() = default;
|
|
||||||
GroupProductionProperties(const std::string& gname) :
|
|
||||||
name(gname)
|
|
||||||
{}
|
|
||||||
|
|
||||||
std::string name;
|
|
||||||
ProductionCMode cmode = ProductionCMode::NONE;
|
ProductionCMode cmode = ProductionCMode::NONE;
|
||||||
ExceedAction exceed_action = ExceedAction::NONE;
|
ExceedAction exceed_action = ExceedAction::NONE;
|
||||||
UDAValue oil_target;
|
UDAValue oil_target;
|
||||||
UDAValue water_target;
|
UDAValue water_target;
|
||||||
UDAValue gas_target;
|
UDAValue gas_target;
|
||||||
UDAValue liquid_target;
|
UDAValue liquid_target;
|
||||||
double guide_rate = 0;
|
double guide_rate;
|
||||||
GuideRateTarget guide_rate_def = GuideRateTarget::NO_GUIDE_RATE;
|
GuideRateTarget guide_rate_def;
|
||||||
double resv_target = 0;
|
double resv_target = 0;
|
||||||
bool available_group_control = true;
|
bool available_group_control = true;
|
||||||
static GroupProductionProperties serializeObject();
|
static GroupProductionProperties serializeObject();
|
||||||
@@ -182,12 +167,10 @@ struct GroupProductionProperties {
|
|||||||
int production_controls = 0;
|
int production_controls = 0;
|
||||||
bool operator==(const GroupProductionProperties& other) const;
|
bool operator==(const GroupProductionProperties& other) const;
|
||||||
bool operator!=(const GroupProductionProperties& other) const;
|
bool operator!=(const GroupProductionProperties& other) const;
|
||||||
bool updateUDQActive(const UDQConfig& udq_config, UDQActive& active) const;
|
|
||||||
|
|
||||||
template<class Serializer>
|
template<class Serializer>
|
||||||
void serializeOp(Serializer& serializer)
|
void serializeOp(Serializer& serializer)
|
||||||
{
|
{
|
||||||
serializer(name);
|
|
||||||
serializer(cmode);
|
serializer(cmode);
|
||||||
serializer(exceed_action);
|
serializer(exceed_action);
|
||||||
oil_target.serializeOp(serializer);
|
oil_target.serializeOp(serializer);
|
||||||
@@ -211,7 +194,7 @@ struct ProductionControls {
|
|||||||
double gas_target;
|
double gas_target;
|
||||||
double liquid_target;
|
double liquid_target;
|
||||||
double guide_rate;
|
double guide_rate;
|
||||||
GuideRateTarget guide_rate_def = GuideRateTarget::NO_GUIDE_RATE;
|
GuideRateTarget guide_rate_def;
|
||||||
double resv_target = 0;
|
double resv_target = 0;
|
||||||
int production_controls = 0;
|
int production_controls = 0;
|
||||||
bool has_control(ProductionCMode control) const;
|
bool has_control(ProductionCMode control) const;
|
||||||
@@ -220,7 +203,6 @@ struct ProductionControls {
|
|||||||
|
|
||||||
Group();
|
Group();
|
||||||
Group(const std::string& group_name, std::size_t insert_index_arg, std::size_t init_step_arg, double udq_undefined_arg, const UnitSystem& unit_system);
|
Group(const std::string& group_name, std::size_t insert_index_arg, std::size_t init_step_arg, double udq_undefined_arg, const UnitSystem& unit_system);
|
||||||
Group(const RestartIO::RstGroup& rst_group, std::size_t insert_index_arg, std::size_t init_step_arg, double udq_undefined_arg, const UnitSystem& unit_system);
|
|
||||||
|
|
||||||
static Group serializeObject();
|
static Group serializeObject();
|
||||||
|
|
||||||
@@ -271,9 +253,6 @@ struct ProductionControls {
|
|||||||
bool has_control(InjectionCMode control) const;
|
bool has_control(InjectionCMode control) const;
|
||||||
bool productionGroupControlAvailable() const;
|
bool productionGroupControlAvailable() const;
|
||||||
bool injectionGroupControlAvailable(const Phase phase) const;
|
bool injectionGroupControlAvailable(const Phase phase) const;
|
||||||
const std::optional<GPMaint>& gpmaint() const;
|
|
||||||
void set_gpmaint(GPMaint gpmaint);
|
|
||||||
void set_gpmaint();
|
|
||||||
|
|
||||||
bool operator==(const Group& data) const;
|
bool operator==(const Group& data) const;
|
||||||
const Phase& topup_phase() const;
|
const Phase& topup_phase() const;
|
||||||
@@ -297,7 +276,6 @@ struct ProductionControls {
|
|||||||
serializer.map(injection_properties);
|
serializer.map(injection_properties);
|
||||||
production_properties.serializeOp(serializer);
|
production_properties.serializeOp(serializer);
|
||||||
serializer(m_topup_phase);
|
serializer(m_topup_phase);
|
||||||
serializer(m_gpmaint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -319,9 +297,8 @@ private:
|
|||||||
IOrderSet<std::string> m_groups;
|
IOrderSet<std::string> m_groups;
|
||||||
|
|
||||||
std::map<Phase, GroupInjectionProperties> injection_properties;
|
std::map<Phase, GroupInjectionProperties> injection_properties;
|
||||||
GroupProductionProperties production_properties;
|
GroupProductionProperties production_properties{};
|
||||||
std::pair<Phase, bool> m_topup_phase{Phase::WATER, false};
|
std::pair<Phase, bool> m_topup_phase{Phase::WATER, false};
|
||||||
std::optional<GPMaint> m_gpmaint;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Group::GroupType operator |(Group::GroupType lhs, Group::GroupType rhs);
|
Group::GroupType operator |(Group::GroupType lhs, Group::GroupType rhs);
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user