From c38b8928760595fdbcca486be12c634903f90c38 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Thu, 11 Jun 2015 23:11:29 +0200 Subject: [PATCH] Moved initialization of FaultCollection. --- .../eclipse/EclipseState/EclipseState.cpp | 35 ++---------------- .../EclipseState/Grid/FaultCollection.cpp | 37 +++++++++++++++++++ .../EclipseState/Grid/FaultCollection.hpp | 5 +++ 3 files changed, 45 insertions(+), 32 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/EclipseState.cpp b/opm/parser/eclipse/EclipseState/EclipseState.cpp index 629018017..7b8eb9b77 100644 --- a/opm/parser/eclipse/EclipseState/EclipseState.cpp +++ b/opm/parser/eclipse/EclipseState/EclipseState.cpp @@ -431,42 +431,13 @@ namespace Opm { void EclipseState::initFaults(DeckConstPtr deck) { EclipseGridConstPtr grid = getEclipseGrid(); - m_faults = std::make_shared(); - std::shared_ptr gridSection(new Opm::GRIDSection(deck) ); - - for (size_t index=0; index < gridSection->count("FAULTS"); index++) { - DeckKeywordConstPtr faultsKeyword = gridSection->getKeyword("FAULTS" , index); - for (auto iter = faultsKeyword->begin(); iter != faultsKeyword->end(); ++iter) { - DeckRecordConstPtr faultRecord = *iter; - const std::string& faultName = faultRecord->getItem(0)->getString(0); - int I1 = faultRecord->getItem(1)->getInt(0) - 1; - int I2 = faultRecord->getItem(2)->getInt(0) - 1; - int J1 = faultRecord->getItem(3)->getInt(0) - 1; - int J2 = faultRecord->getItem(4)->getInt(0) - 1; - int K1 = faultRecord->getItem(5)->getInt(0) - 1; - int K2 = faultRecord->getItem(6)->getInt(0) - 1; - FaceDir::DirEnum faceDir = FaceDir::FromString( faultRecord->getItem(7)->getString(0) ); - std::shared_ptr face = std::make_shared(grid->getNX() , grid->getNY() , grid->getNZ(), - static_cast(I1) , static_cast(I2) , - static_cast(J1) , static_cast(J2) , - static_cast(K1) , static_cast(K2) , - faceDir); - if (!m_faults->hasFault(faultName)) { - std::shared_ptr fault = std::make_shared( faultName ); - m_faults->addFault( fault ); - } - - { - std::shared_ptr fault = m_faults->getFault( faultName ); - fault->addFace( face ); - } - } - } + std::shared_ptr gridSection = std::make_shared( deck ); + m_faults = std::make_shared(gridSection , grid); setMULTFLT(gridSection); if (Section::hasEDIT(deck)) { - std::shared_ptr editSection(new Opm::EDITSection(deck) ); + std::shared_ptr editSection = std::make_shared( deck ); setMULTFLT(editSection); } diff --git a/opm/parser/eclipse/EclipseState/Grid/FaultCollection.cpp b/opm/parser/eclipse/EclipseState/Grid/FaultCollection.cpp index d94804775..9570573d4 100644 --- a/opm/parser/eclipse/EclipseState/Grid/FaultCollection.cpp +++ b/opm/parser/eclipse/EclipseState/Grid/FaultCollection.cpp @@ -19,6 +19,8 @@ #include +#include + #include namespace Opm { @@ -28,6 +30,41 @@ namespace Opm { } + + FaultCollection::FaultCollection( std::shared_ptr deck, std::shared_ptr grid) { + std::vector > faultKeywords = deck->getKeywordList(); + + for (auto keyword_iter = faultKeywords.begin(); keyword_iter != faultKeywords.end(); ++keyword_iter) { + std::shared_ptr faultsKeyword = *keyword_iter; + for (auto iter = faultsKeyword->begin(); iter != faultsKeyword->end(); ++iter) { + DeckRecordConstPtr faultRecord = *iter; + const std::string& faultName = faultRecord->getItem(0)->getString(0); + int I1 = faultRecord->getItem(1)->getInt(0) - 1; + int I2 = faultRecord->getItem(2)->getInt(0) - 1; + int J1 = faultRecord->getItem(3)->getInt(0) - 1; + int J2 = faultRecord->getItem(4)->getInt(0) - 1; + int K1 = faultRecord->getItem(5)->getInt(0) - 1; + int K2 = faultRecord->getItem(6)->getInt(0) - 1; + FaceDir::DirEnum faceDir = FaceDir::FromString( faultRecord->getItem(7)->getString(0) ); + std::shared_ptr face = std::make_shared(grid->getNX() , grid->getNY() , grid->getNZ(), + static_cast(I1) , static_cast(I2) , + static_cast(J1) , static_cast(J2) , + static_cast(K1) , static_cast(K2) , + faceDir); + if (!hasFault(faultName)) { + std::shared_ptr fault = std::make_shared( faultName ); + addFault( fault ); + } + + { + std::shared_ptr fault = getFault( faultName ); + fault->addFace( face ); + } + } + } + } + + size_t FaultCollection::size() const { return m_faults.size(); } diff --git a/opm/parser/eclipse/EclipseState/Grid/FaultCollection.hpp b/opm/parser/eclipse/EclipseState/Grid/FaultCollection.hpp index a141a50c9..f86ba5eaa 100644 --- a/opm/parser/eclipse/EclipseState/Grid/FaultCollection.hpp +++ b/opm/parser/eclipse/EclipseState/Grid/FaultCollection.hpp @@ -27,6 +27,9 @@ #include +#include + +#include #include #include #include @@ -37,6 +40,8 @@ namespace Opm { class FaultCollection { public: FaultCollection(); + FaultCollection( std::shared_ptr deck, std::shared_ptr grid); + size_t size() const; bool hasFault(const std::string& faultName) const; std::shared_ptr getFault(const std::string& faultName) const;