diff --git a/opm/parser/eclipse/CMakeLists.txt b/opm/parser/eclipse/CMakeLists.txt index c9ba405ac..376cb462f 100644 --- a/opm/parser/eclipse/CMakeLists.txt +++ b/opm/parser/eclipse/CMakeLists.txt @@ -10,7 +10,6 @@ add_subdirectory(EclipseState/Tables/tests) add_subdirectory(EclipseState/Grid/tests) add_subdirectory(EclipseState/Util/tests) add_subdirectory(EclipseState/IOConfig/tests) -add_subdirectory(ert/tests) add_subdirectory( Applications ) @@ -107,10 +106,7 @@ EclipseState/Grid/FaultCollection.cpp EclipseState/SimulationConfig/SimulationConfig.cpp EclipseState/SimulationConfig/ThresholdPressure.cpp # -EclipseState/IOConfig/IOConfig.cpp -# -ert/EclKW.cpp -ert/FortIO.cpp) +EclipseState/IOConfig/IOConfig.cpp) set( HEADER_FILES @@ -245,11 +241,7 @@ Utility/GruptreeWrapper.hpp Utility/WelspecsWrapper.hpp Utility/EquilWrapper.hpp Utility/EndscaleWrapper.hpp -Utility/ScalecrsWrapper.hpp -# -ert/EclKW.hpp -ert/FortIO.hpp -) +Utility/ScalecrsWrapper.hpp) add_library(buildParser STATIC ${rawdeck_source} ${build_parser_source} ${deck_source} ${unit_source}) target_link_libraries(buildParser opmjson ${Boost_LIBRARIES}) diff --git a/opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp b/opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp index 27010c05f..b1935623f 100644 --- a/opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp +++ b/opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp @@ -26,7 +26,8 @@ #include #include -#include +#include + #include #include #include diff --git a/opm/parser/eclipse/ert/EclKW.cpp b/opm/parser/eclipse/ert/EclKW.cpp deleted file mode 100644 index 225bcbef4..000000000 --- a/opm/parser/eclipse/ert/EclKW.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include - - -namespace ERT { - template <> - EclKW::EclKW(const std::string& kw, int size_) { - ecl_kw_type * c_ptr = ecl_kw_alloc( kw.c_str() , size_ , ECL_INT_TYPE ); - reset( c_ptr ); - } - - template <> - EclKW::EclKW(const std::string& kw, int size_) { - ecl_kw_type * c_ptr = ecl_kw_alloc( kw.c_str() , size_ , ECL_FLOAT_TYPE ); - reset( c_ptr ); - } - - template <> - EclKW::EclKW(const std::string& kw, int size_) { - ecl_kw_type * c_ptr = ecl_kw_alloc( kw.c_str() , size_ , ECL_DOUBLE_TYPE ); - reset( c_ptr ); - } - - - - template <> - EclKW EclKW::load(FortIO& fortio) { - return checkedLoad(fortio , ECL_DOUBLE_TYPE); - } - - template <> - EclKW EclKW::load(FortIO& fortio) { - return checkedLoad(fortio , ECL_INT_TYPE); - } - - template <> - EclKW EclKW::load(FortIO& fortio) { - return checkedLoad(fortio , ECL_FLOAT_TYPE); - } -} diff --git a/opm/parser/eclipse/ert/EclKW.hpp b/opm/parser/eclipse/ert/EclKW.hpp deleted file mode 100644 index 178fab72b..000000000 --- a/opm/parser/eclipse/ert/EclKW.hpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - Copyright 2015 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 OPM_ERT_ECL_KW -#define OPM_ERT_ECL_KW - -#include -#include -#include -#include -#include - -#include - -#include -#include - - - -namespace ERT { - template - class EclKW - { - public: - EclKW(const std::string& kw, int size_); - EclKW() { ; } - - static EclKW load(FortIO& fortio); - - size_t size() const { - return static_cast( ecl_kw_get_size( m_kw.get() )); - } - - T& operator[](size_t index) { - return *( static_cast( ecl_kw_iget_ptr( m_kw.get() , index) )); - } - - - void fwrite(FortIO& fortio) const { - ecl_kw_fwrite( m_kw.get() , fortio.getPointer() ); - } - - - void assignVector(const std::vector& data) { - if (data.size() == size()) - ecl_kw_set_memcpy_data( m_kw.get() , data.data() ); - else - throw std::invalid_argument("Size error"); - } - - private: - EclKW(ecl_kw_type * c_ptr) { - reset(c_ptr); - } - - void reset(ecl_kw_type * c_ptr) { - m_kw.reset( c_ptr , ecl_kw_free); - } - - - static EclKW checkedLoad(FortIO& fortio, ecl_type_enum expectedType) { - ecl_kw_type * c_ptr = ecl_kw_fread_alloc( fortio.getPointer() ); - if (c_ptr) { - if (ecl_kw_get_type( c_ptr ) == expectedType) - return EclKW( c_ptr ); - else - throw std::invalid_argument("Type error"); - } else - throw std::invalid_argument("fread kw failed - EOF?"); - } - - - std::shared_ptr m_kw; - }; -} - -#endif diff --git a/opm/parser/eclipse/ert/FortIO.cpp b/opm/parser/eclipse/ert/FortIO.cpp deleted file mode 100644 index 6b0123c1d..000000000 --- a/opm/parser/eclipse/ert/FortIO.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - Copyright 2015 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 . -*/ - -#define BOOST_NO_CXX11_SCOPED_ENUMS -#include - -#include - -#include - -namespace ERT { - - FortIO::FortIO(const std::string& filename , std::ios_base::openmode mode , bool fmt_file , bool endian_flip_header) { - if (mode == std::ios_base::in) { - if (boost::filesystem::exists( filename )) { - fortio_type * c_ptr = fortio_open_reader( filename.c_str() , fmt_file , endian_flip_header); - m_fortio.reset( c_ptr , fortio_fclose ); - } else - throw std::invalid_argument("File " + filename + " does not exist"); - } else { - fortio_type * c_ptr = fortio_open_writer( filename.c_str() , fmt_file , endian_flip_header); - m_fortio.reset( c_ptr , fortio_fclose ); - } - } - - - void FortIO::close() { - if (m_fortio) - m_fortio.reset( ); - } - - - - - fortio_type * FortIO::getPointer() const { - return m_fortio.get(); - } - - - -} - - diff --git a/opm/parser/eclipse/ert/FortIO.hpp b/opm/parser/eclipse/ert/FortIO.hpp deleted file mode 100644 index 9bf4eef92..000000000 --- a/opm/parser/eclipse/ert/FortIO.hpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright 2015 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 OPM_ERT_FORTIO_KW -#define OPM_ERT_FORTIO_KW - -#include -#include - -#include -#include - - - - -namespace ERT { - class FortIO - { - public: - FortIO(const std::string& filename , std::ios_base::openmode mode , bool fmt_file = false , bool endian_flip_header = ECL_ENDIAN_FLIP); - fortio_type * getPointer() const; - void close(); - void reset() const; - - private: - std::shared_ptr m_fortio; - }; -} - - -#endif diff --git a/opm/parser/eclipse/ert/tests/CMakeLists.txt b/opm/parser/eclipse/ert/tests/CMakeLists.txt deleted file mode 100644 index 69040b0dd..000000000 --- a/opm/parser/eclipse/ert/tests/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -opm_add_test(runErtTests SOURCES test_ert_wrapper.cpp - LIBRARIES opmparser ${Boost_LIBRARIES}) diff --git a/opm/parser/eclipse/ert/tests/test_ert_wrapper.cpp b/opm/parser/eclipse/ert/tests/test_ert_wrapper.cpp deleted file mode 100644 index e565ea5a7..000000000 --- a/opm/parser/eclipse/ert/tests/test_ert_wrapper.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* - Copyright 2015 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 - - -#define BOOST_TEST_MODULE ERT_WRAPPER_TESTS -#include - -#include - -#include -#include - - -BOOST_AUTO_TEST_CASE(KWTEST) { - ERT::EclKW kw("XYZ" , 1000); - BOOST_CHECK_EQUAL( kw.size() , 1000U ); - - kw[0] = 1; - kw[10] = 77; - - BOOST_CHECK_EQUAL( kw[0] , 1 ); - BOOST_CHECK_EQUAL( kw[10] , 77 ); -} - - - -BOOST_AUTO_TEST_CASE(FortioTEST) { - test_work_area_type * work_area = test_work_area_alloc("fortio"); - - ERT::FortIO fortio("new_file" , std::fstream::out ); - { - std::vector data; - for (size_t i=0; i < 1000; i++) - data.push_back(i); - - fortio_fwrite_record( fortio.getPointer() , reinterpret_cast(data.data()) , 1000 * 4 ); - } - fortio.close(); - - fortio = ERT::FortIO("new_file" , std::fstream::in ); - { - std::vector data; - for (size_t i=0; i < 1000; i++) - data.push_back(99); - - BOOST_CHECK( fortio_fread_buffer( fortio.getPointer() , reinterpret_cast(data.data()) , 1000 * 4 )); - for (size_t i =0; i < 1000; i++) - BOOST_CHECK_EQUAL( data[i] , i ); - - } - fortio.close(); - test_work_area_free( work_area ); - - BOOST_CHECK_THROW( ERT::FortIO fortio("file/does/not/exists" , std::fstream::in) , std::invalid_argument ); -} - - - -BOOST_AUTO_TEST_CASE(Fortio_kw_TEST) { - test_work_area_type * work_area = test_work_area_alloc("fortio_kw"); - ERT::EclKW kw("XYZ" , 1000); - for (size_t i =0 ; i < kw.size(); i++) - kw[i] = i; - - { - ERT::FortIO fortio("new_file" , std::fstream::out ); - kw.fwrite( fortio ); - fortio.close(); - } - - { - ERT::FortIO fortio("new_file" , std::fstream::in ); - ERT::EclKW kw2 = ERT::EclKW::load( fortio ); - fortio.close( ); - for (size_t i =0 ; i < kw.size(); i++) - BOOST_CHECK_EQUAL(kw[i] , kw2[i]); - - - fortio = ERT::FortIO("new_file" , std::fstream::in ); - BOOST_CHECK_THROW( ERT::EclKW::load(fortio) , std::invalid_argument ); - fortio.close(); - } - - test_work_area_free( work_area ); -}