Added FaultFace class
This commit is contained in:
@@ -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
|
||||
|
||||
81
opm/parser/eclipse/EclipseState/Grid/FaultFace.cpp
Normal file
81
opm/parser/eclipse/EclipseState/Grid/FaultFace.cpp
Normal file
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stdexcept>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/FaultFace.hpp>
|
||||
|
||||
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<size_t>::const_iterator FaultFace::begin() const {
|
||||
return m_indexList.begin();
|
||||
}
|
||||
|
||||
std::vector<size_t>::const_iterator FaultFace::end() const {
|
||||
return m_indexList.end();
|
||||
}
|
||||
|
||||
|
||||
FaceDir::DirEnum FaultFace::getDir() const {
|
||||
return m_faceDir;
|
||||
}
|
||||
|
||||
}
|
||||
51
opm/parser/eclipse/EclipseState/Grid/FaultFace.hpp
Normal file
51
opm/parser/eclipse/EclipseState/Grid/FaultFace.hpp
Normal file
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef FAULT_FACE_HPP_
|
||||
#define FAULT_FACE_HPP_
|
||||
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/FaceDir.hpp>
|
||||
|
||||
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<size_t>::const_iterator begin() const;
|
||||
std::vector<size_t>::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<size_t> m_indexList;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -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 )
|
||||
|
||||
|
||||
74
opm/parser/eclipse/EclipseState/Grid/tests/FaultTests.cpp
Normal file
74
opm/parser/eclipse/EclipseState/Grid/tests/FaultTests.cpp
Normal file
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#define BOOST_TEST_MODULE FaultTests
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/FaultFace.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/FaceDir.hpp>
|
||||
|
||||
|
||||
|
||||
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<Opm::FaultFace> face1 = std::make_shared<Opm::FaultFace>(10,10,10,0, 2 , 0 , 0 , 0 , 0 , Opm::FaceDir::YPlus);
|
||||
std::shared_ptr<Opm::FaultFace> face2 = std::make_shared<Opm::FaultFace>(10,10,10,0, 2 , 1 , 1 , 0 , 0 , Opm::FaceDir::YPlus);
|
||||
std::shared_ptr<Opm::FaultFace> face3 = std::make_shared<Opm::FaultFace>(10,10,10,0, 2 , 0 , 0 , 1 , 1 , Opm::FaceDir::YPlus);
|
||||
|
||||
std::vector<size_t> trueValues1{0,1,2};
|
||||
std::vector<size_t> trueValues2{10,11,12};
|
||||
std::vector<size_t> 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);
|
||||
}
|
||||
34
opm/parser/eclipse/EclipseState/Grid/tests/FaultsTests.cpp
Normal file
34
opm/parser/eclipse/EclipseState/Grid/tests/FaultsTests.cpp
Normal file
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#define BOOST_TEST_MODULE FaultsTests
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/FaultCollection.hpp>
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(CreateFaultCollection) {
|
||||
Opm::FaultCollection faults;
|
||||
BOOST_CHECK_EQUAL( faults.size() , 0 );
|
||||
}
|
||||
Reference in New Issue
Block a user