From 61c4e677c59e3589e833b70ed414e3c756be078b Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Sat, 5 Jul 2014 13:45:35 +0200 Subject: [PATCH] ERT-700: Added FaultCollection class --- opm/parser/eclipse/CMakeLists.txt | 4 +- .../EclipseState/Grid/FaultCollection.cpp | 66 +++++++++++++++++++ .../EclipseState/Grid/FaultCollection.hpp | 55 ++++++++++++++++ .../EclipseState/Grid/tests/FaultTests.cpp | 31 +++++++++ 4 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 opm/parser/eclipse/EclipseState/Grid/FaultCollection.cpp create mode 100644 opm/parser/eclipse/EclipseState/Grid/FaultCollection.hpp diff --git a/opm/parser/eclipse/CMakeLists.txt b/opm/parser/eclipse/CMakeLists.txt index 08ccd22a7..c5efda316 100644 --- a/opm/parser/eclipse/CMakeLists.txt +++ b/opm/parser/eclipse/CMakeLists.txt @@ -82,7 +82,8 @@ EclipseState/Grid/FaceDir.cpp EclipseState/Grid/TransMult.cpp EclipseState/Grid/EclipseGrid.cpp EclipseState/Grid/FaultFace.cpp -EclipseState/Grid/Fault.cpp) +EclipseState/Grid/Fault.cpp +EclipseState/Grid/FaultCollection.cpp) set (utility_source Utility/SingleRecordTable.cpp @@ -146,6 +147,7 @@ EclipseState/Grid/FaceDir.hpp EclipseState/Grid/TransMult.hpp EclipseState/Grid/FaultFace.hpp EclipseState/Grid/Fault.hpp +EclipseState/Grid/FaultCollection.hpp # Utility/WconinjeWrapper.hpp Utility/CompdatWrapper.hpp diff --git a/opm/parser/eclipse/EclipseState/Grid/FaultCollection.cpp b/opm/parser/eclipse/EclipseState/Grid/FaultCollection.cpp new file mode 100644 index 000000000..05e0fbd54 --- /dev/null +++ b/opm/parser/eclipse/EclipseState/Grid/FaultCollection.cpp @@ -0,0 +1,66 @@ +/* + Copyright 2014 Statoil ASA. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ + +#include + +#include + +namespace Opm { + + FaultCollection::FaultCollection(size_t nx , size_t ny , size_t nz) : + m_nx(nx), + m_ny(ny), + m_nz(nz) + { + + } + + size_t FaultCollection::size() const { + return m_faults.size(); + } + + + bool FaultCollection::hasFault(const std::string& faultName) const { + return m_faults.hasKey( faultName ); + } + + + std::shared_ptr FaultCollection::getFault(const std::string& faultName) const { + return m_faults.get( faultName ); + } + + std::shared_ptr FaultCollection::getFault(size_t faultIndex) const { + return m_faults.get( faultIndex ); + } + + + void FaultCollection::addFault(std::shared_ptr fault) { + m_faults.insert(fault->getName() , fault); + } + + + + void FaultCollection::setTransMult(const std::string& faultName , double transMult) { + std::shared_ptr fault = getFault( faultName ); + fault->setTransMult( transMult ); + } + + + +} diff --git a/opm/parser/eclipse/EclipseState/Grid/FaultCollection.hpp b/opm/parser/eclipse/EclipseState/Grid/FaultCollection.hpp new file mode 100644 index 000000000..311f8cc9c --- /dev/null +++ b/opm/parser/eclipse/EclipseState/Grid/FaultCollection.hpp @@ -0,0 +1,55 @@ +/* + Copyright 2014 Statoil ASA. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ +#ifndef FAULT_COLLECTION_HPP_ +#define FAULT_COLLECTION_HPP_ + +#include +#include +#include +#include + + +#include + +#include +#include +#include + +namespace Opm { + + +class FaultCollection { +public: + FaultCollection(size_t nx , size_t ny , size_t nz); + size_t size() const; + bool hasFault(const std::string& faultName) const; + std::shared_ptr getFault(const std::string& faultName) const; + std::shared_ptr getFault(size_t faultIndex) const; + void addFault(std::shared_ptr fault); + void setTransMult(const std::string& faultName , double transMult); + +private: + + size_t m_nx, m_ny, m_nz; + OrderedMap > m_faults; +}; +} + + +#endif diff --git a/opm/parser/eclipse/EclipseState/Grid/tests/FaultTests.cpp b/opm/parser/eclipse/EclipseState/Grid/tests/FaultTests.cpp index 9f4b46491..b73d14ee4 100644 --- a/opm/parser/eclipse/EclipseState/Grid/tests/FaultTests.cpp +++ b/opm/parser/eclipse/EclipseState/Grid/tests/FaultTests.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -100,3 +101,33 @@ BOOST_AUTO_TEST_CASE(AddFaceToFaults) { } } + + + +BOOST_AUTO_TEST_CASE(CreateFaultCollection) { + Opm::FaultCollection faults(100,10,6); + BOOST_CHECK_EQUAL( faults.size() , 0 ); + BOOST_CHECK(! faults.hasFault("NO-NotThisOne")); + BOOST_CHECK_THROW( faults.getFault("NO") , std::invalid_argument ); +} + + +BOOST_AUTO_TEST_CASE(AddFaultsToCollection) { + Opm::FaultCollection faults(10,10,10); + std::shared_ptr fault = std::make_shared("FAULT"); + + faults.addFault(fault); + BOOST_CHECK_EQUAL( faults.size() , 1 ); + BOOST_CHECK(faults.hasFault("FAULT")); + + std::shared_ptr fault2 = faults.getFault("FAULT"); + std::shared_ptr fault0 = faults.getFault(0); + BOOST_CHECK_EQUAL( fault , fault2 ); + BOOST_CHECK_EQUAL( fault , fault0 ); + + std::shared_ptr faultx = std::make_shared("FAULTX"); + faults.addFault(faultx); + BOOST_CHECK_EQUAL( faults.size() , 2 ); + BOOST_CHECK(faults.hasFault("FAULTX")); + BOOST_CHECK_EQUAL( faultx , faults.getFault(1)); +}