diff --git a/opm/parser/eclipse/CMakeLists.txt b/opm/parser/eclipse/CMakeLists.txt index f597701f5..ccfca755c 100644 --- a/opm/parser/eclipse/CMakeLists.txt +++ b/opm/parser/eclipse/CMakeLists.txt @@ -80,7 +80,8 @@ EclipseState/Grid/Box.cpp EclipseState/Grid/BoxManager.cpp EclipseState/Grid/FaceDir.cpp EclipseState/Grid/TransMult.cpp -EclipseState/Grid/EclipseGrid.cpp) +EclipseState/Grid/EclipseGrid.cpp +EclipseState/Grid/FaultFace.cpp) set (utility_source Utility/SingleRecordTable.cpp @@ -141,7 +142,8 @@ EclipseState/Grid/GridProperties.hpp EclipseState/Grid/Box.hpp EclipseState/Grid/BoxManager.hpp EclipseState/Grid/FaceDir.hpp -EclipseState/Grid/TransMult.hpp +EclipseState/Grid/TransMult.hpp +EclipseState/Grid/FaultFace.hpp # Utility/WconinjeWrapper.hpp Utility/CompdatWrapper.hpp diff --git a/opm/parser/eclipse/EclipseState/Grid/FaultFace.cpp b/opm/parser/eclipse/EclipseState/Grid/FaultFace.cpp new file mode 100644 index 000000000..4d886c5d1 --- /dev/null +++ b/opm/parser/eclipse/EclipseState/Grid/FaultFace.cpp @@ -0,0 +1,81 @@ +/* + Copyright 2014 Statoil ASA. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ +#include + +#include + +namespace Opm { + + FaultFace::FaultFace(size_t nx , size_t ny , size_t nz, + size_t I1 , size_t I2, + size_t J1 , size_t J2, + size_t K1 , size_t K2, + FaceDir::DirEnum faceDir) + : m_faceDir( faceDir ) + { + checkCoord(nx , I1,I2); + checkCoord(ny , J1,J2); + checkCoord(nz , K1,K2); + + + if ((faceDir == FaceDir::XPlus) || (faceDir == FaceDir::XMinus)) + if (I1 != I2) + throw std::invalid_argument("When the face is in X direction we must have I1 == I2"); + + if ((faceDir == FaceDir::YPlus) || (faceDir == FaceDir::YMinus)) + if (J1 != J2) + throw std::invalid_argument("When the face is in Y direction we must have J1 == J2"); + + if ((faceDir == FaceDir::ZPlus) || (faceDir == FaceDir::ZMinus)) + if (K1 != K2) + throw std::invalid_argument("When the face is in Z direction we must have K1 == K2"); + + + for (size_t k=K1; k <= K2; k++) + for (size_t j=J1; j <= J2; j++) + for (size_t i=I1; i <= I2; i++) { + size_t globalIndex = i + j*nx + k*nx*ny; + m_indexList.push_back( globalIndex ); + } + } + + + void FaultFace::checkCoord(size_t dim , size_t l1 , size_t l2) { + if (l1 > l2) + throw std::invalid_argument("Invalid coordinates"); + + if (l2 >= dim) + throw std::invalid_argument("Invalid coordinates"); + } + + + std::vector::const_iterator FaultFace::begin() const { + return m_indexList.begin(); + } + + std::vector::const_iterator FaultFace::end() const { + return m_indexList.end(); + } + + + FaceDir::DirEnum FaultFace::getDir() const { + return m_faceDir; + } + +} diff --git a/opm/parser/eclipse/EclipseState/Grid/FaultFace.hpp b/opm/parser/eclipse/EclipseState/Grid/FaultFace.hpp new file mode 100644 index 000000000..e32d65628 --- /dev/null +++ b/opm/parser/eclipse/EclipseState/Grid/FaultFace.hpp @@ -0,0 +1,51 @@ +/* + 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_FACE_HPP_ +#define FAULT_FACE_HPP_ + +#include +#include + +#include + +namespace Opm { + + +class FaultFace { +public: + FaultFace(size_t nx , size_t ny , size_t nz, + size_t I1 , size_t I2, + size_t J1 , size_t J2, + size_t K1 , size_t K2, + FaceDir::DirEnum faceDir); + + std::vector::const_iterator begin() const; + std::vector::const_iterator end() const; + FaceDir::DirEnum getDir() const; + +private: + static void checkCoord(size_t dim , size_t l1 , size_t l2); + FaceDir::DirEnum m_faceDir; + std::vector m_indexList; +}; + + +} + +#endif diff --git a/opm/parser/eclipse/EclipseState/Grid/tests/CMakeLists.txt b/opm/parser/eclipse/EclipseState/Grid/tests/CMakeLists.txt index ecd29a248..2107ebdc5 100644 --- a/opm/parser/eclipse/EclipseState/Grid/tests/CMakeLists.txt +++ b/opm/parser/eclipse/EclipseState/Grid/tests/CMakeLists.txt @@ -31,3 +31,8 @@ add_executable(runTransMultTests TransMultTests.cpp) target_link_libraries(runTransMultTests Parser ${Boost_LIBRARIES}) add_test(NAME runTransMultTests WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${TEST_MEMCHECK_TOOL} ${EXECUTABLE_OUTPUT_PATH}/runTransMultTests ) + +add_executable(runFaultTests FaultTests.cpp) +target_link_libraries(runFaultTests Parser ${Boost_LIBRARIES}) +add_test(NAME runFaultTests WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${TEST_MEMCHECK_TOOL} ${EXECUTABLE_OUTPUT_PATH}/runFaultTests ) + diff --git a/opm/parser/eclipse/EclipseState/Grid/tests/FaultTests.cpp b/opm/parser/eclipse/EclipseState/Grid/tests/FaultTests.cpp new file mode 100644 index 000000000..1c0fac648 --- /dev/null +++ b/opm/parser/eclipse/EclipseState/Grid/tests/FaultTests.cpp @@ -0,0 +1,74 @@ +/* + 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 +#include + +#define BOOST_TEST_MODULE FaultTests +#include +#include + +#include +#include + + + +BOOST_AUTO_TEST_CASE(CreateInvalidFace) { + // I out of range + BOOST_CHECK_THROW( Opm::FaultFace(10,10,10,10 , 10 , 1 , 1 , 5 , 5 , Opm::FaceDir::XPlus) , std::invalid_argument ); + + // I1 != I2 when face == X + BOOST_CHECK_THROW( Opm::FaultFace( 10,10,10, 1 , 3 , 1 , 1 , 5 , 5 , Opm::FaceDir::XPlus) , std::invalid_argument ); + + // J1 < J2 + BOOST_CHECK_THROW( Opm::FaultFace( 10,10,10,3 , 3 , 3 , 1 , 5 , 5 , Opm::FaceDir::XPlus) , std::invalid_argument ); + +} + + +BOOST_AUTO_TEST_CASE(CreateFace) { + std::shared_ptr face1 = std::make_shared(10,10,10,0, 2 , 0 , 0 , 0 , 0 , Opm::FaceDir::YPlus); + std::shared_ptr face2 = std::make_shared(10,10,10,0, 2 , 1 , 1 , 0 , 0 , Opm::FaceDir::YPlus); + std::shared_ptr face3 = std::make_shared(10,10,10,0, 2 , 0 , 0 , 1 , 1 , Opm::FaceDir::YPlus); + + std::vector trueValues1{0,1,2}; + std::vector trueValues2{10,11,12}; + std::vector trueValues3{100,101,102}; + size_t i = 0; + + { + auto iter3 = face3->begin(); + auto iter2 = face2->begin(); + for (auto iter1 = face1->begin(); iter1 != face1->end(); ++iter1) { + size_t index1 = *iter1; + size_t index2 = *iter2; + size_t index3 = *iter3; + + BOOST_CHECK_EQUAL( index1 , trueValues1[i] ); + BOOST_CHECK_EQUAL( index2 , trueValues2[i] ); + BOOST_CHECK_EQUAL( index3 , trueValues3[i] ); + + ++iter2; + ++iter3; + ++i; + } + } + BOOST_CHECK_EQUAL( face1->getDir() , Opm::FaceDir::YPlus); +} diff --git a/opm/parser/eclipse/EclipseState/Grid/tests/FaultsTests.cpp b/opm/parser/eclipse/EclipseState/Grid/tests/FaultsTests.cpp new file mode 100644 index 000000000..9b0e5dba2 --- /dev/null +++ b/opm/parser/eclipse/EclipseState/Grid/tests/FaultsTests.cpp @@ -0,0 +1,34 @@ +/* + 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 +#include + +#define BOOST_TEST_MODULE FaultsTests +#include +#include + +#include + + +BOOST_AUTO_TEST_CASE(CreateFaultCollection) { + Opm::FaultCollection faults; + BOOST_CHECK_EQUAL( faults.size() , 0 ); +}