diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index d0be64884..07a369eec 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -179,32 +179,27 @@ if(ENABLE_ECL_INPUT) src/opm/input/eclipse/Schedule/Well/WellTestConfig.cpp src/opm/input/eclipse/Schedule/Well/WellTestState.cpp - src/opm/input/eclipse/Schedule/Well/WellTrajectory.cpp - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibCore/cvfAssert.cpp - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibCore/cvfAtomicCounter.cpp - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibCore/cvfCharArray.cpp - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibCore/cvfMath.cpp - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibCore/cvfObject.cpp - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibCore/cvfPlane.cpp - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibCore/cvfString.cpp - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibCore/cvfSystem.cpp - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibCore/cvfVector3.cpp - - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibGeometry/cvfBoundingBox.cpp - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibGeometry/cvfBoundingBoxTree.cpp - - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibGeometry/cvfRay.cpp - - src/opm/input/eclipse/Schedule/WellTrajResInsight/ReservoirDataModel/cvfGeometryTools.cpp - src/opm/input/eclipse/Schedule/WellTrajResInsight/ReservoirDataModel/RigHexIntersectionTools.cpp - src/opm/input/eclipse/Schedule/WellTrajResInsight/ReservoirDataModel/RigWellLogExtractor.cpp - src/opm/input/eclipse/Schedule/WellTrajResInsight/ReservoirDataModel/RigWellPath.cpp - src/opm/input/eclipse/Schedule/WellTrajResInsight/ReservoirDataModel/MyRigEclipseWellLogExtractor.cpp - - src/opm/input/eclipse/Schedule/WellTrajResInsight/CommonCode/cvfStructGrid.cpp - src/opm/input/eclipse/Schedule/WellTrajResInsight/cafPdmCore/cafSignal.cpp - src/opm/input/eclipse/Schedule/WellTrajResInsight/cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp - + external/resinsight/LibCore/cvfAssert.cpp + external/resinsight/LibCore/cvfAtomicCounter.cpp + external/resinsight/LibCore/cvfCharArray.cpp + external/resinsight/LibCore/cvfMath.cpp + external/resinsight/LibCore/cvfObject.cpp + external/resinsight/LibCore/cvfPlane.cpp + external/resinsight/LibCore/cvfString.cpp + external/resinsight/LibCore/cvfSystem.cpp + external/resinsight/LibCore/cvfVector3.cpp + external/resinsight/LibGeometry/cvfBoundingBox.cpp + external/resinsight/LibGeometry/cvfBoundingBoxTree.cpp + external/resinsight/LibGeometry/cvfRay.cpp + external/resinsight/ReservoirDataModel/cvfGeometryTools.cpp + external/resinsight/ReservoirDataModel/RigHexIntersectionTools.cpp + external/resinsight/ReservoirDataModel/RigWellLogExtractor.cpp + external/resinsight/ReservoirDataModel/RigWellPath.cpp + external/resinsight/CommonCode/cvfStructGrid.cpp + external/resinsight/cafPdmCore/cafSignal.cpp + external/resinsight/cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp + src/opm/input/eclipse/Schedule/WellTraj/RigEclipseWellLogExtractor.cpp + src/opm/input/eclipse/EclipseState/SimulationConfig/BCConfig.cpp src/opm/input/eclipse/EclipseState/SimulationConfig/RockConfig.cpp src/opm/input/eclipse/EclipseState/SimulationConfig/SimulationConfig.cpp @@ -524,7 +519,6 @@ if(ENABLE_ECL_INPUT) tests/parser/integration/NNCTests.cpp tests/parser/WellSolventTests.cpp tests/parser/WellTracerTests.cpp - tests/parser/WellTrajectoryTests.cpp tests/parser/WellTests.cpp tests/parser/WLIST.cpp tests/parser/WriteRestartFileEventsTests.cpp @@ -1136,37 +1130,28 @@ if(ENABLE_ECL_INPUT) opm/input/eclipse/Schedule/Well/WellTestState.hpp opm/input/eclipse/Schedule/Well/WellConnections.hpp - src/opm/input/eclipse/Schedule/Well/WellTrajectory.hpp - - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibCore/cvfAssert.h - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibCore/cvfAtomicCounter.h - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibCore/cvfCharArray.h - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibCore/cvfMath.h - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibCore/cvfObject.h - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibCore/cvfObject.inl - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibCore/cvfPlane.h - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibCore/cvfString.h - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibCore/cvfSystem.h - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibCore/cvfVector3.h - - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibGeometry/cvfBoundingBox.h - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibGeometry/cvfBoundingBoxTree.h - - src/opm/input/eclipse/Schedule/WellTrajResInsight/LibGeometry/cvfRay.h - - src/opm/input/eclipse/Schedule/WellTrajResInsight/ReservoirDataModel/cvfGeometryTools.h - src/opm/input/eclipse/Schedule/WellTrajResInsight/ReservoirDataModel/RigHexIntersectionTools.h - src/opm/input/eclipse/Schedule/WellTrajResInsight/ReservoirDataModel/RigWellLogExtractionTools.h - src/opm/input/eclipse/Schedule/WellTrajResInsight/ReservoirDataModel/RigWellLogExtractor.h - src/opm/input/eclipse/Schedule/WellTrajResInsight/ReservoirDataModel/RigWellPath.h - src/opm/input/eclipse/Schedule/WellTrajResInsight/ReservoirDataModel/MyRigEclipseWellLogExtractor.h - - - src/opm/input/eclipse/Schedule/WellTrajResInsight/CommonCode/cvfStructGrid.h - - src/opm/input/eclipse/Schedule/WellTrajResInsight/cafPdmCore/cafSignal.h - - src/opm/input/eclipse/Schedule/WellTrajResInsight/cafHexGridIntersectionTools/cafHexGridIntersectionTools.h + external/resinsight/LibCore/cvfAssert.h + external/resinsight/LibCore/cvfAtomicCounter.h + external/resinsight/LibCore/cvfCharArray.h + external/resinsight/LibCore/cvfMath.h + external/resinsight/LibCore/cvfObject.h + external/resinsight/LibCore/cvfObject.inl + external/resinsight/LibCore/cvfPlane.h + external/resinsight/LibCore/cvfString.h + external/resinsight/LibCore/cvfSystem.h + external/resinsight/LibCore/cvfVector3.h + external/resinsight/LibGeometry/cvfBoundingBox.h + external/resinsight/LibGeometry/cvfBoundingBoxTree.h + external/resinsight/LibGeometry/cvfRay.h + external/resinsight/ReservoirDataModel/cvfGeometryTools.h + external/resinsight/ReservoirDataModel/RigHexIntersectionTools.h + external/resinsight/ReservoirDataModel/RigWellLogExtractionTools.h + external/resinsight/ReservoirDataModel/RigWellLogExtractor.h + external/resinsight/ReservoirDataModel/RigWellPath.h + external/resinsight/CommonCode/cvfStructGrid.h + external/resinsight/cafPdmCore/cafSignal.h + external/resinsight/cafHexGridIntersectionTools/cafHexGridIntersectionTools.h + opm/input/eclipse/Schedule/WellTraj/RigEclipseWellLogExtractor.hpp opm/input/eclipse/Schedule/SummaryState.hpp opm/input/eclipse/Schedule/RFTConfig.hpp diff --git a/external/resinsight/README.opm b/external/resinsight/README.opm new file mode 100644 index 000000000..2e128ed38 --- /dev/null +++ b/external/resinsight/README.opm @@ -0,0 +1,4 @@ +This directory contains a selection of files from ResInsight(https://github.com/OPM/ResInsight). +This part of the code of ResInsight is used within OPM-Flow to calculate, +given a geometric (thus grid-independent) well trajectory the I,J,K coordinates of intersected cells +and the well line segments within these cells. \ No newline at end of file diff --git a/opm/input/eclipse/Schedule/Schedule.hpp b/opm/input/eclipse/Schedule/Schedule.hpp index bd75fe3c2..2b38bb8ed 100644 --- a/opm/input/eclipse/Schedule/Schedule.hpp +++ b/opm/input/eclipse/Schedule/Schedule.hpp @@ -689,6 +689,7 @@ namespace Opm void handleCOMPLUMP (HandlerContext&); void handleCOMPORD (HandlerContext&); void handleCOMPSEGS (HandlerContext&); + void handleCOMPTRAJ (HandlerContext&); void handleDRSDT (HandlerContext&); void handleDRSDTCON (HandlerContext&); void handleDRSDTR (HandlerContext&); @@ -731,7 +732,6 @@ namespace Opm void handleWCONPROD (HandlerContext&); void handleWECON (HandlerContext&); void handleWEFAC (HandlerContext&); - void handleWELCOMPL (HandlerContext&); void handleWELOPEN (HandlerContext&); void handleWELPI (HandlerContext&); void handleWELSEGS (HandlerContext&); diff --git a/opm/input/eclipse/Schedule/ScheduleGrid.hpp b/opm/input/eclipse/Schedule/ScheduleGrid.hpp index cc0450792..f7fdff495 100644 --- a/opm/input/eclipse/Schedule/ScheduleGrid.hpp +++ b/opm/input/eclipse/Schedule/ScheduleGrid.hpp @@ -20,6 +20,7 @@ #define SCHEDULE_GRID #include +#include namespace Opm { @@ -32,6 +33,7 @@ public: explicit ScheduleGrid(CompletedCells& completed_cells); const CompletedCells::Cell& get_cell(std::size_t i, std::size_t j, std::size_t k) const; + const Opm::EclipseGrid* get_grid() const; private: const EclipseGrid* grid{nullptr}; diff --git a/opm/input/eclipse/Schedule/WellTraj/RigEclipseWellLogExtractor.hpp b/opm/input/eclipse/Schedule/WellTraj/RigEclipseWellLogExtractor.hpp index 93520bad2..2413b3094 100644 --- a/opm/input/eclipse/Schedule/WellTraj/RigEclipseWellLogExtractor.hpp +++ b/opm/input/eclipse/Schedule/WellTraj/RigEclipseWellLogExtractor.hpp @@ -19,8 +19,8 @@ #pragma once -#include "RigWellLogExtractor.h" -#include +#include +#include #include #include @@ -40,10 +40,10 @@ class BoundingBox; //================================================================================================== /// //================================================================================================== -class MyRigEclipseWellLogExtractor : public RigWellLogExtractor +class RigEclipseWellLogExtractor : public RigWellLogExtractor { public: - MyRigEclipseWellLogExtractor( const RigWellPath* wellpath, const Opm::EclipseGrid& grid, cvf::ref& cellSearchTree); + RigEclipseWellLogExtractor( const RigWellPath* wellpath, const Opm::EclipseGrid& grid, cvf::ref& cellSearchTree); cvf::ref getCellSearchTree(); private: diff --git a/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp b/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp index e30fb8ae1..ecf8ed3f9 100644 --- a/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp +++ b/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp @@ -85,6 +85,8 @@ #include "Well/injection.hpp" +#include + namespace Opm { namespace { @@ -189,8 +191,29 @@ namespace { auto well2 = this->snapshots.back().wells.get(name); auto connections = std::shared_ptr( new WellConnections( well2.getConnections())); connections->loadWELTRAJ(record, handlerContext.grid, name, handlerContext.keyword.location()); - //what to do here? need here something like updateTrajectory - //maybe new method WellConnection::addTrajectory? + if (well2.updateConnections(connections, handlerContext.grid)) { + this->snapshots.back().wells.update( well2 ); + wells.insert( name ); + } + this->snapshots.back().wellgroup_events().addEvent( name, ScheduleEvents::COMPLETION_CHANGE); + } + } + this->snapshots.back().events().addEvent(ScheduleEvents::COMPLETION_CHANGE); + } + + void Schedule::handleCOMPTRAJ(HandlerContext& handlerContext) { + // Keyword WELTRAJ must be read first + std::unordered_set wells; + cvf::ref cellSearchTree = nullptr; + for (const auto& record : handlerContext.keyword) { + const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0); + auto wellnames = this->wellNames(wellNamePattern, handlerContext ); + + for (const auto& name : wellnames) { + auto well2 = this->snapshots.back().wells.get(name); + auto connections = std::shared_ptr( new WellConnections( well2.getConnections())); + // cellsearchTree is calculated only once and is used to calculated cell intersections of the perforations specified in COMPTRAJ + connections->loadCOMPTRAJ(record, handlerContext.grid, name, handlerContext.keyword.location(), cellSearchTree); if (well2.updateConnections(connections, handlerContext.grid)) { this->snapshots.back().wells.update( well2 ); wells.insert( name ); @@ -198,7 +221,7 @@ namespace { if (connections->empty() && well2.getConnections().empty()) { const auto& location = handlerContext.keyword.location(); - auto msg = fmt::format("Problem with COMPDAT/{}\n" + auto msg = fmt::format("Problem with COMPTRAJ/{}\n" "In {} line {}\n" "Well {} is not connected to grid - will remain SHUT", name, location.filename, location.lineno, name); OpmLog::warning(msg); @@ -210,53 +233,13 @@ namespace { // In the case the wells reference depth has been defaulted in the // WELSPECS keyword we need to force a calculation of the wells - // reference depth exactly when the COMPDAT keyword has been completely + // reference depth exactly when the WELCOML keyword has been completely // processed. - // for (const auto& wname : wells) { - // auto& well = this->snapshots.back().wells.get( wname ); - // well.updateRefDepth(); - // this->snapshots.back().wells.update( std::move(well)); - // } - } - void Schedule::handleWELCOMPL(HandlerContext& handlerContext) { - //WELTRAJ should have been read first: ijk of trajectory is known - //update of connection - - std::unordered_set wells; - for (const auto& record : handlerContext.keyword) { - const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0); - auto wellnames = this->wellNames(wellNamePattern, handlerContext ); - - for (const auto& name : wellnames) { - auto well2 = this->snapshots.back().wells.get(name); - auto connections = std::shared_ptr( new WellConnections( well2.getConnections())); - connections->loadWELCOMPL(record, handlerContext.grid, name, handlerContext.keyword.location()); - // if (well2.updateConnections(connections, handlerContext.grid)) { - // this->snapshots.back().wells.update( well2 ); - // wells.insert( name ); - // } - - // if (connections->empty() && well2.getConnections().empty()) { - // const auto& location = handlerContext.keyword.location(); - // auto msg = fmt::format("Problem with COMPDAT/{}\n" - // "In {} line {}\n" - // "Well {} is not connected to grid - will remain SHUT", name, location.filename, location.lineno, name); - // OpmLog::warning(msg); - // } - // this->snapshots.back().wellgroup_events().addEvent( name, ScheduleEvents::COMPLETION_CHANGE); - } + for (const auto& wname : wells) { + auto& well = this->snapshots.back().wells.get( wname ); + well.updateRefDepth(); + this->snapshots.back().wells.update( std::move(well)); } - this->snapshots.back().events().addEvent(ScheduleEvents::COMPLETION_CHANGE); - - // In the case the wells reference depth has been defaulted in the - // WELSPECS keyword we need to force a calculation of the wells - // reference depth exactly when the COMPDAT keyword has been completely - // processed. - // for (const auto& wname : wells) { - // auto& well = this->snapshots.back().wells.get( wname ); - // well.updateRefDepth(); - // this->snapshots.back().wells.update( std::move(well)); - // } } void Schedule::handleCOMPLUMP(HandlerContext& handlerContext) { @@ -2321,6 +2304,7 @@ Well{0} entered with disallowed 'FIELD' parent group: { "COMPLUMP", &Schedule::handleCOMPLUMP }, { "COMPORD" , &Schedule::handleCOMPORD }, { "COMPSEGS", &Schedule::handleCOMPSEGS }, + { "COMPTRAJ", &Schedule::handleCOMPTRAJ }, { "DRSDT" , &Schedule::handleDRSDT }, { "DRSDTCON", &Schedule::handleDRSDTCON }, { "DRSDTR" , &Schedule::handleDRSDTR }, @@ -2378,7 +2362,6 @@ Well{0} entered with disallowed 'FIELD' parent group: { "WCONPROD", &Schedule::handleWCONPROD }, { "WECON" , &Schedule::handleWECON }, { "WEFAC" , &Schedule::handleWEFAC }, - { "WELCOMPL", &Schedule::handleWELCOMPL }, { "WELOPEN" , &Schedule::handleWELOPEN }, { "WELPI" , &Schedule::handleWELPI }, { "WELSEGS" , &Schedule::handleWELSEGS }, diff --git a/src/opm/input/eclipse/Schedule/ScheduleGrid.cpp b/src/opm/input/eclipse/Schedule/ScheduleGrid.cpp index 196613e7f..e40b7892f 100644 --- a/src/opm/input/eclipse/Schedule/ScheduleGrid.cpp +++ b/src/opm/input/eclipse/Schedule/ScheduleGrid.cpp @@ -33,7 +33,6 @@ Opm::ScheduleGrid::ScheduleGrid(Opm::CompletedCells& completed_cells) : cells(completed_cells) {} - namespace { double try_get_value(const Opm::FieldPropsManager& fp, const std::string& kw, std::size_t active_index) { if (fp.has_double(kw)) @@ -74,3 +73,6 @@ const Opm::CompletedCells::Cell& Opm::ScheduleGrid::get_cell(std::size_t i, std: return this->cells.get(i,j,k); } +const Opm::EclipseGrid* Opm::ScheduleGrid::get_grid() const { + return this->grid; +} diff --git a/src/opm/input/eclipse/Schedule/WellTraj/RigEclipseWellLogExtractor.cpp b/src/opm/input/eclipse/Schedule/WellTraj/RigEclipseWellLogExtractor.cpp index 4e5e02939..298c16866 100644 --- a/src/opm/input/eclipse/Schedule/WellTraj/RigEclipseWellLogExtractor.cpp +++ b/src/opm/input/eclipse/Schedule/WellTraj/RigEclipseWellLogExtractor.cpp @@ -19,15 +19,14 @@ #include #include -#include "MyRigEclipseWellLogExtractor.h" -#include "RigWellLogExtractionTools.h" -#include "RigWellPath.h" - -#include "../LibGeometry/cvfBoundingBox.h" -#include "cvfGeometryTools.h" -#include "RigWellLogExtractor.h" -#include "RigCellGeometryTools.h" -#include "../CommonCode/cvfStructGrid.h" +#include +#include +#include +#include +#include +#include +#include +#include #include @@ -35,7 +34,7 @@ /// //================================================================================================== - MyRigEclipseWellLogExtractor::MyRigEclipseWellLogExtractor(const RigWellPath* wellpath, const Opm::EclipseGrid& grid, cvf::ref& cellSearchTree) + RigEclipseWellLogExtractor::RigEclipseWellLogExtractor(const RigWellPath* wellpath, const Opm::EclipseGrid& grid, cvf::ref& cellSearchTree) : RigWellLogExtractor( wellpath, "" ) ,m_grid(grid) ,m_cellSearchTree(cellSearchTree) @@ -46,7 +45,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void MyRigEclipseWellLogExtractor::calculateIntersection() +void RigEclipseWellLogExtractor::calculateIntersection() { std::map uniqueIntersections; @@ -115,7 +114,7 @@ void MyRigEclipseWellLogExtractor::calculateIntersection() } -cvf::Vec3d MyRigEclipseWellLogExtractor::calculateLengthInCell( size_t cellIndex, +cvf::Vec3d RigEclipseWellLogExtractor::calculateLengthInCell( size_t cellIndex, const cvf::Vec3d& startPoint, const cvf::Vec3d& endPoint ) const { @@ -136,11 +135,11 @@ cvf::Vec3d MyRigEclipseWellLogExtractor::calculateLengthInCell( size_t hexCorners[6] = hexCorners_opm[7]; hexCorners[7] = hexCorners_opm[6]; - return MyRigEclipseWellLogExtractor::calculateLengthInCell( hexCorners, startPoint, endPoint ); + return RigEclipseWellLogExtractor::calculateLengthInCell( hexCorners, startPoint, endPoint ); } -cvf::Vec3d MyRigEclipseWellLogExtractor::calculateLengthInCell( const std::array& hexCorners, +cvf::Vec3d RigEclipseWellLogExtractor::calculateLengthInCell( const std::array& hexCorners, const cvf::Vec3d& startPoint, const cvf::Vec3d& endPoint ) const { @@ -150,7 +149,7 @@ cvf::Vec3d MyRigEclipseWellLogExtractor::calculateLengthInCell( const std::array cvf::Vec3d jAxisDirection; cvf::Vec3d kAxisDirection; - MyRigEclipseWellLogExtractor::findCellLocalXYZ( hexCorners, iAxisDirection, jAxisDirection, kAxisDirection ); + RigEclipseWellLogExtractor::findCellLocalXYZ( hexCorners, iAxisDirection, jAxisDirection, kAxisDirection ); cvf::Mat3d localCellCoordinateSystem( iAxisDirection.x(), jAxisDirection.x(), @@ -170,7 +169,7 @@ cvf::Vec3d MyRigEclipseWellLogExtractor::calculateLengthInCell( const std::array //================================================================================================== /// //================================================================================================== -void MyRigEclipseWellLogExtractor::findCellLocalXYZ( const std::array& hexCorners, +void RigEclipseWellLogExtractor::findCellLocalXYZ( const std::array& hexCorners, cvf::Vec3d& localXdirection, cvf::Vec3d& localYdirection, cvf::Vec3d& localZdirection ) const @@ -247,7 +246,7 @@ void MyRigEclipseWellLogExtractor::findCellLocalXYZ( const std::array* cellIndices ) const +void RigEclipseWellLogExtractor::findIntersectingCells( const cvf::BoundingBox& inputBB, std::vector* cellIndices ) const { CVF_ASSERT( m_cellSearchTree.notNull() ); m_cellSearchTree->findIntersections( inputBB, cellIndices ); } -std::vector MyRigEclipseWellLogExtractor::findCloseCellIndices( const cvf::BoundingBox& bb ) +std::vector RigEclipseWellLogExtractor::findCloseCellIndices( const cvf::BoundingBox& bb ) { std::vector closeCells; this->findIntersectingCells( bb, &closeCells ); return closeCells; } - cvf::ref MyRigEclipseWellLogExtractor::getCellSearchTree() + cvf::ref RigEclipseWellLogExtractor::getCellSearchTree() { return m_cellSearchTree; }