Adding new class EInit
- for parsing and loading data from INIT file - including functions to support parsing/logading LGR data
This commit is contained in:
parent
a242b3abfa
commit
e1334adbf6
@ -235,7 +235,7 @@ if(ENABLE_ECL_INPUT)
|
||||
${PROJECT_BINARY_DIR}/tests
|
||||
)
|
||||
|
||||
foreach(test test_EclIO test_EGrid test_ERft test_ERst test_ESmry)
|
||||
foreach(test test_EclIO test_EGrid test_ERft test_ERst test_ESmry test_EInit)
|
||||
opm_add_test(${test} CONDITION ENABLE_ECL_INPUT AND Boost_UNIT_TEST_FRAMEWORK_FOUND
|
||||
LIBRARIES ${_libs}
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/tests)
|
||||
|
@ -256,6 +256,7 @@ if(ENABLE_ECL_OUTPUT)
|
||||
src/opm/io/eclipse/EclOutput.cpp
|
||||
src/opm/io/eclipse/EclUtil.cpp
|
||||
src/opm/io/eclipse/EGrid.cpp
|
||||
src/opm/io/eclipse/EInit.cpp
|
||||
src/opm/io/eclipse/ERft.cpp
|
||||
src/opm/io/eclipse/ERst.cpp
|
||||
src/opm/io/eclipse/ERsm.cpp
|
||||
@ -478,7 +479,7 @@ if(ENABLE_ECL_INPUT)
|
||||
list (APPEND TEST_DATA_FILES
|
||||
tests/ECLFILE.INIT
|
||||
tests/ECLFILE.FINIT
|
||||
tests/ECLFILE.FINIT
|
||||
tests/LGR_TESTMOD.INIT
|
||||
tests/MODEL1_IX.INIT
|
||||
tests/MODEL1_IX.SMSPEC
|
||||
tests/MODEL1_IX.UNSMRY
|
||||
@ -795,6 +796,7 @@ if(ENABLE_ECL_OUTPUT)
|
||||
opm/io/eclipse/EclOutput.hpp
|
||||
opm/io/eclipse/EclUtil.hpp
|
||||
opm/io/eclipse/EGrid.hpp
|
||||
opm/io/eclipse/EInit.hpp
|
||||
opm/io/eclipse/ERft.hpp
|
||||
opm/io/eclipse/ERst.hpp
|
||||
opm/io/eclipse/ERsm.hpp
|
||||
|
102
opm/io/eclipse/EInit.hpp
Normal file
102
opm/io/eclipse/EInit.hpp
Normal file
@ -0,0 +1,102 @@
|
||||
/*
|
||||
Copyright 2020 Equinor 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 OPM_IO_EINIT_HPP
|
||||
#define OPM_IO_EINIT_HPP
|
||||
|
||||
#include <opm/io/eclipse/EclFile.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
namespace Opm { namespace EclIO {
|
||||
|
||||
class EInit : public EclFile
|
||||
{
|
||||
public:
|
||||
explicit EInit(const std::string& filename);
|
||||
|
||||
const std::vector<std::string>& list_of_lgrs() const { return lgr_names; }
|
||||
|
||||
std::vector<EclFile::EclEntry> list_arrays() const;
|
||||
std::vector<EclFile::EclEntry> list_arrays(const std::string& grid_name) const;
|
||||
|
||||
const std::array<int, 3>& grid_dimension(const std::string& grid_name = "global") const;
|
||||
int activeCells(const std::string& grid_name = "global") const;
|
||||
|
||||
bool hasLGR(const std::string& name) const;
|
||||
|
||||
template <typename T>
|
||||
const std::vector<T>& getInitData(const std::string& name, const std::string& grid_name = "global")
|
||||
{
|
||||
return this->ImplgetInitData<T>(name, grid_name);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
template <typename T>
|
||||
const std::vector<T>& ImplgetInitData(const std::string& name, const std::string& grid_name = "global")
|
||||
{
|
||||
int arr_ind = get_array_index(name, grid_name);
|
||||
|
||||
if constexpr (std::is_same_v<T, int>)
|
||||
return getImpl(arr_ind, INTE, inte_array, "integer");
|
||||
|
||||
if constexpr (std::is_same_v<T, float>)
|
||||
return getImpl(arr_ind, REAL, real_array, "float");
|
||||
|
||||
if constexpr (std::is_same_v<T, double>)
|
||||
return getImpl(arr_ind, DOUB, doub_array, "double");
|
||||
|
||||
if constexpr (std::is_same_v<T, bool>)
|
||||
return getImpl(arr_ind, LOGI, logi_array, "bool");
|
||||
|
||||
if constexpr (std::is_same_v<T, std::string>)
|
||||
{
|
||||
if (array_type[arr_ind] == Opm::EclIO::CHAR)
|
||||
return getImpl(arr_ind, array_type[arr_ind], char_array, "char");
|
||||
|
||||
if (array_type[arr_ind] == Opm::EclIO::C0NN)
|
||||
return getImpl(arr_ind, array_type[arr_ind], char_array, "c0nn");
|
||||
|
||||
OPM_THROW(std::runtime_error, "Array not of type CHAR or C0nn");
|
||||
}
|
||||
|
||||
OPM_THROW(std::runtime_error, "type not supported");
|
||||
}
|
||||
|
||||
private:
|
||||
std::array<int, 3> global_nijk;
|
||||
std::vector<std::array<int, 3>> lgr_nijk;
|
||||
|
||||
int global_nactive;
|
||||
std::vector<int> lgr_nactive;
|
||||
|
||||
std::vector<std::string> lgr_names;
|
||||
|
||||
std::map<std::string,int> global_array_index;
|
||||
std::vector<std::map<std::string,int>> lgr_array_index;
|
||||
|
||||
int get_array_index(const std::string& name, const std::string& grid_name) const;
|
||||
int get_lgr_index(const std::string& grid_name) const;
|
||||
};
|
||||
|
||||
}} // namespace Opm::EclIO
|
||||
|
||||
#endif // OPM_IO_EINIT_HPP
|
161
src/opm/io/eclipse/EInit.cpp
Normal file
161
src/opm/io/eclipse/EInit.cpp
Normal file
@ -0,0 +1,161 @@
|
||||
/*
|
||||
Copyright 2020 Equinor 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 <opm/io/eclipse/EInit.hpp>
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace Opm { namespace EclIO {
|
||||
|
||||
|
||||
EInit::EInit(const std::string &filename) : EclFile(filename)
|
||||
{
|
||||
std::string lgrname;
|
||||
std::string nncname;
|
||||
|
||||
lgrname = "global";
|
||||
|
||||
for (size_t n = 0; n < array_name.size(); n++) {
|
||||
if (array_name[n] == "LGR"){
|
||||
auto lgr = this->get<std::string>(n);
|
||||
lgrname = lgr[0];
|
||||
|
||||
if (std::find(lgr_names.begin(), lgr_names.end(), lgrname) == lgr_names.end()){
|
||||
lgr_names.push_back(lgrname);
|
||||
lgr_array_index.push_back({});
|
||||
lgr_nijk.push_back({});
|
||||
lgr_nactive.push_back(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (array_name[n] == "LGRSGONE")
|
||||
lgrname = "global";
|
||||
|
||||
if ((lgrname == "global") && (array_name[n] != "LGRSGONE"))
|
||||
global_array_index[array_name[n]] = n;
|
||||
|
||||
if ((lgrname != "global") && (array_name[n] != "LGRSGONE") && (array_name[n] != "LGR"))
|
||||
{
|
||||
auto it = std::find(lgr_names.begin(), lgr_names.end(), lgrname);
|
||||
size_t ind = std::distance(lgr_names.begin(), it);
|
||||
lgr_array_index[ind][array_name[n]] = n;
|
||||
}
|
||||
|
||||
if (array_name[n] == "INTEHEAD")
|
||||
{
|
||||
auto inteh = getImpl(n, INTE, inte_array, "integer");
|
||||
|
||||
if (lgrname == "global") {
|
||||
global_nijk = {inteh[8], inteh[9], inteh[10]};
|
||||
global_nactive = inteh[11];
|
||||
} else {
|
||||
auto it = std::find(lgr_names.begin(), lgr_names.end(), lgrname);
|
||||
size_t lgr_ind = std::distance(lgr_names.begin(), it);
|
||||
lgr_nijk[lgr_ind] = {inteh[8], inteh[9], inteh[10]};
|
||||
lgr_nactive[lgr_ind] = inteh[11];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int EInit::get_array_index(const std::string& name, const std::string& grid_name) const
|
||||
{
|
||||
if (grid_name == "global"){
|
||||
if (global_array_index.count(name) == 0)
|
||||
OPM_THROW(std::runtime_error, "Map key '" + name + "' not found in global_array_index");
|
||||
|
||||
return global_array_index.at(name);
|
||||
|
||||
} else {
|
||||
|
||||
int lgr_index = get_lgr_index(grid_name);
|
||||
|
||||
if (lgr_array_index[lgr_index].count(name) == 0)
|
||||
OPM_THROW(std::invalid_argument, "Map key '" + name + "' not found in lgr_array_index");
|
||||
|
||||
return lgr_array_index[lgr_index].at(name);
|
||||
}
|
||||
};
|
||||
|
||||
int EInit::activeCells(const std::string& grid_name) const
|
||||
{
|
||||
if (grid_name == "global")
|
||||
return global_nactive;
|
||||
else
|
||||
return lgr_nactive[get_lgr_index(grid_name)];
|
||||
}
|
||||
|
||||
const std::array<int, 3>& EInit::grid_dimension(const std::string& grid_name) const
|
||||
{
|
||||
if (grid_name == "global")
|
||||
return global_nijk;
|
||||
else
|
||||
return lgr_nijk[get_lgr_index(grid_name)];
|
||||
}
|
||||
|
||||
bool EInit::hasLGR(const std::string& name) const{
|
||||
if (std::find(lgr_names.begin(), lgr_names.end(), name) == lgr_names.end())
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
int EInit::get_lgr_index(const std::string& grid_name) const
|
||||
{
|
||||
auto it = std::find(lgr_names.begin(), lgr_names.end(), grid_name);
|
||||
|
||||
if (it == lgr_names.end()) {
|
||||
std::string message = "LGR '" + grid_name + "' not found in init file.";
|
||||
OPM_THROW(std::invalid_argument, message);
|
||||
}
|
||||
|
||||
return std::distance(lgr_names.begin(), it);
|
||||
}
|
||||
|
||||
std::vector<EclFile::EclEntry> EInit::list_arrays(const std::string& grid_name) const
|
||||
{
|
||||
std::vector<EclEntry> array_list;
|
||||
|
||||
int lgr_index = this->get_lgr_index(grid_name);
|
||||
|
||||
for (auto const& x : lgr_array_index[lgr_index])
|
||||
{
|
||||
int ind = x.second;
|
||||
array_list.push_back(std::make_tuple(array_name[ind], array_type[ind], array_size[ind]));
|
||||
}
|
||||
|
||||
return array_list;
|
||||
}
|
||||
|
||||
std::vector<EclFile::EclEntry> EInit::list_arrays() const
|
||||
{
|
||||
std::vector<EclEntry> array_list;
|
||||
|
||||
for (auto const& x : global_array_index)
|
||||
{
|
||||
int ind = x.second;
|
||||
array_list.push_back(std::make_tuple(array_name[ind], array_type[ind], array_size[ind]));
|
||||
}
|
||||
|
||||
return array_list;
|
||||
}
|
||||
|
||||
|
||||
}} // namespace Opm::EclIO
|
BIN
tests/LGR_TESTMOD.INIT
Normal file
BIN
tests/LGR_TESTMOD.INIT
Normal file
Binary file not shown.
271
tests/test_EInit.cpp
Normal file
271
tests/test_EInit.cpp
Normal file
@ -0,0 +1,271 @@
|
||||
/*
|
||||
+ Copyright 2019 Equinor 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 "config.h"
|
||||
|
||||
#include <opm/io/eclipse/EInit.hpp>
|
||||
|
||||
#define BOOST_TEST_MODULE Test EclIO
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
#include <opm/common/utility/FileSystem.hpp>
|
||||
|
||||
using namespace Opm::EclIO;
|
||||
|
||||
|
||||
template <typename T>
|
||||
bool operator==(const std::vector<T> & t1, const std::vector<T> & t2)
|
||||
{
|
||||
return std::equal(t1.begin(), t1.end(), t2.begin(), t2.end());
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestEInit_1) {
|
||||
|
||||
std::string testInitFile = "LGR_TESTMOD.INIT";
|
||||
|
||||
const std::vector<std::string> ref_lgr_list = {"LGR1", "LGR2"};
|
||||
|
||||
const std::vector<std::string> ref_global_names = {"CON", "DEPTH", "DOUBHEAD", "DX",
|
||||
"DY", "DZ", "ENDNUM", "EQLNUM", "FIPNUM", "INTEHEAD", "KRG", "KRGR", "KRO", "KRORG",
|
||||
"KRORW", "KRW", "KRWR", "LOGIHEAD", "MINPVV", "MULTPV", "MULTX", "MULTY", "MULTZ",
|
||||
"NTG", "PCG", "PCW", "PERMX", "PERMY", "PERMZ", "PORO", "PORV", "PVTNUM", "SATNUM",
|
||||
"SGCR", "SGL", "SGLPC", "SGU", "SOGCR", "SOWCR", "SWATINIT", "SWCR", "SWL", "SWLPC",
|
||||
"SWU", "TAB", "TABDIMS", "TOPS", "TRANNNC", "TRANX", "TRANY", "TRANZ" };
|
||||
|
||||
const std::vector<int> ref_global_size = {3, 30, 229, 30, 30, 30, 30, 30, 30, 411,
|
||||
30, 30, 30, 30, 30, 30, 30, 121, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
|
||||
30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 6821, 100, 30, 8, 30, 30, 30 };
|
||||
|
||||
const std::vector<std::string> ref_lgr1_names = {"DEPTH", "DOUBHEAD", "DX", "DY", "DZ",
|
||||
"ENDNUM", "EQLNUM", "FIPNUM", "INTEHEAD", "KRG", "KRGR", "KRO", "KRORG", "KRORW",
|
||||
"KRW", "KRWR", "LGRHEADD", "LGRHEADI", "LGRHEADQ", "LOGIHEAD", "MINPVV", "MULTPV",
|
||||
"MULTX", "MULTY", "MULTZ", "NTG", "PCG", "PCW", "PERMX", "PERMY", "PERMZ", "PORO",
|
||||
"PORV", "PVTNUM", "SATNUM", "SGCR", "SGL", "SGLPC", "SGU", "SOGCR", "SOWCR",
|
||||
"SWATINIT", "SWCR", "SWL", "SWLPC", "SWU", "TOPS", "TRANGL", "TRANNNC", "TRANX",
|
||||
"TRANY", "TRANZ" };
|
||||
|
||||
const std::vector<int> ref_lgr1_size = {128, 229, 128, 128, 128, 128, 128, 128, 411, 128,
|
||||
128, 128, 128, 128, 128, 128, 5, 45, 5, 121, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
|
||||
128, 128, 84, 12, 128, 128, 128 };
|
||||
|
||||
const std::vector<std::string> ref_lgr2_names = {"DEPTH", "DOUBHEAD", "DR", "DTHETA", "DZ",
|
||||
"EDTTRANX", "EDTTRANY", "EDTTRANZ", "ENDNUM", "EQLNUM", "FIPNUM", "INTEHEAD", "KRG",
|
||||
"KRGR", "KRO", "KRORG", "KRORW", "KRW", "KRWR", "LGRHEADD", "LGRHEADI", "LGRHEADQ",
|
||||
"LOGIHEAD", "MINPVV", "MULTPV", "MULTR", "MULTTHT", "MULTZ", "NTG", "PCG", "PCW", "PERMR",
|
||||
"PERMTHT", "PERMZ", "PORO", "PORV", "PVTNUM", "SATNUM", "SGCR", "SGL", "SGLPC", "SGU",
|
||||
"SOGCR", "SOWCR", "SWATINIT", "SWCR", "SWL", "SWLPC", "SWU", "TOPS", "TRANGL", "TRANNNC",
|
||||
"TRANR", "TRANTHT", "TRANZ" };
|
||||
|
||||
const std::vector<int> ref_lgr2_size = { 192, 229, 192, 192, 192, 192, 192, 192, 192, 192,
|
||||
192, 411, 192, 192, 192, 192, 192, 192, 192, 5, 45, 5, 121, 192, 192, 192, 192, 192,
|
||||
192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192,
|
||||
192, 192, 192, 192, 192, 58, 60, 192, 192, 192 };
|
||||
|
||||
EInit init1(testInitFile);
|
||||
|
||||
auto lgr_list = init1.list_of_lgrs();
|
||||
|
||||
BOOST_CHECK_EQUAL(ref_lgr_list == lgr_list, true);
|
||||
auto global_arrays = init1.list_arrays();
|
||||
|
||||
BOOST_CHECK_EQUAL(global_arrays.size() == ref_global_names.size(), true);
|
||||
BOOST_CHECK_EQUAL(global_arrays.size() == ref_global_size.size(), true);
|
||||
|
||||
|
||||
{
|
||||
std::vector<std::string> tmpg0;
|
||||
std::vector<int> tmpg2;
|
||||
|
||||
for (auto element : global_arrays){
|
||||
tmpg0.push_back(std::get<0>(element));
|
||||
tmpg2.push_back(std::get<2>(element));
|
||||
}
|
||||
|
||||
BOOST_CHECK_EQUAL(ref_global_names == tmpg0, true);
|
||||
BOOST_CHECK_EQUAL(ref_global_size == tmpg2, true);
|
||||
}
|
||||
|
||||
|
||||
BOOST_CHECK_THROW(init1.list_arrays("XXXX") , std::invalid_argument );
|
||||
|
||||
|
||||
auto lgr1_arrays = init1.list_arrays("LGR1");
|
||||
|
||||
BOOST_CHECK_EQUAL(lgr1_arrays.size() == ref_lgr1_names.size(), true);
|
||||
BOOST_CHECK_EQUAL(lgr1_arrays.size() == ref_lgr1_size.size(), true);
|
||||
|
||||
|
||||
{
|
||||
std::vector<std::string> tmplgr1_0;
|
||||
std::vector<int> tmplgr1_2;
|
||||
|
||||
for (auto element : lgr1_arrays){
|
||||
tmplgr1_0.push_back(std::get<0>(element));
|
||||
tmplgr1_2.push_back(std::get<2>(element));
|
||||
}
|
||||
|
||||
BOOST_CHECK_EQUAL(ref_lgr1_names == tmplgr1_0, true);
|
||||
BOOST_CHECK_EQUAL(ref_lgr1_size == tmplgr1_2, true);
|
||||
}
|
||||
|
||||
|
||||
auto lgr2_arrays = init1.list_arrays("LGR2");
|
||||
|
||||
BOOST_CHECK_EQUAL(lgr2_arrays.size() == ref_lgr2_names.size(), true);
|
||||
BOOST_CHECK_EQUAL(lgr2_arrays.size() == ref_lgr2_size.size(), true);
|
||||
|
||||
|
||||
{
|
||||
std::vector<std::string> tmplgr2_0;
|
||||
std::vector<int> tmplgr2_2;
|
||||
|
||||
for (auto element : lgr2_arrays){
|
||||
tmplgr2_0.push_back(std::get<0>(element));
|
||||
tmplgr2_2.push_back(std::get<2>(element));
|
||||
}
|
||||
|
||||
BOOST_CHECK_EQUAL(ref_lgr2_names == tmplgr2_0, true);
|
||||
BOOST_CHECK_EQUAL(ref_lgr2_size == tmplgr2_2, true);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestEInit_2) {
|
||||
|
||||
std::string testInitFile = "LGR_TESTMOD.INIT";
|
||||
|
||||
const std::array<int, 3> ref_dim_global = {2,3,5};
|
||||
const std::array<int, 3> ref_dim_lgr1 = {4,8,4};
|
||||
const std::array<int, 3> ref_dim_lgr2 = {6,8,4};
|
||||
|
||||
EInit init1(testInitFile);
|
||||
|
||||
BOOST_CHECK_THROW(init1.grid_dimension("XXXX") , std::invalid_argument );
|
||||
|
||||
const std::array<int, 3> nijk = init1.grid_dimension();
|
||||
BOOST_CHECK_EQUAL(nijk == ref_dim_global, true);
|
||||
|
||||
const std::array<int, 3> nijk_global = init1.grid_dimension("global");
|
||||
BOOST_CHECK_EQUAL(nijk_global == ref_dim_global, true);
|
||||
|
||||
const std::array<int, 3> nijk_lgr1 = init1.grid_dimension("LGR1");
|
||||
BOOST_CHECK_EQUAL(nijk_lgr1 == ref_dim_lgr1, true);
|
||||
|
||||
const std::array<int, 3> nijk_lgr2 = init1.grid_dimension("LGR2");
|
||||
BOOST_CHECK_EQUAL(nijk_lgr2 == ref_dim_lgr2, true);
|
||||
|
||||
BOOST_CHECK_EQUAL(init1.activeCells(), 30);
|
||||
BOOST_CHECK_THROW(init1.activeCells("XXXX") , std::invalid_argument );
|
||||
|
||||
BOOST_CHECK_EQUAL(init1.activeCells("global"), 30);
|
||||
BOOST_CHECK_EQUAL(init1.activeCells("LGR1"), 128);
|
||||
BOOST_CHECK_EQUAL(init1.activeCells("LGR2"), 192);
|
||||
|
||||
BOOST_CHECK_EQUAL(init1.hasLGR("XXX"), false);
|
||||
BOOST_CHECK_EQUAL(init1.hasLGR("global"), false);
|
||||
|
||||
BOOST_CHECK_EQUAL(init1.hasLGR("LGR1"), true);
|
||||
BOOST_CHECK_EQUAL(init1.hasLGR("LGR2"), true);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestEInit_3) {
|
||||
|
||||
// testing getInitData member function
|
||||
// main purpase of these tests, is to ensure that the correct array is picked
|
||||
|
||||
std::string testInitFile = "LGR_TESTMOD.INIT";
|
||||
|
||||
EInit init1(testInitFile);
|
||||
|
||||
// logihead item 5, logihead[4], is true if radial grid is used. This is the case for LGR2
|
||||
|
||||
// bool data type
|
||||
auto logi_data_global= init1.getInitData<bool>("LOGIHEAD");
|
||||
BOOST_CHECK_EQUAL(logi_data_global[4], false);
|
||||
|
||||
BOOST_CHECK_THROW(init1.getInitData<bool>("LOGIHEAD", "XXXX") , std::invalid_argument );
|
||||
|
||||
auto logi_data_lgr1= init1.getInitData<bool>("LOGIHEAD", "LGR1");
|
||||
BOOST_CHECK_EQUAL(logi_data_lgr1[4], false);
|
||||
|
||||
auto logi_data_lgr2= init1.getInitData<bool>("LOGIHEAD", "LGR2");
|
||||
BOOST_CHECK_EQUAL(logi_data_lgr2[4], true);
|
||||
|
||||
|
||||
// double data type
|
||||
|
||||
auto doub_data_global= init1.getInitData<double>("DOUBHEAD");
|
||||
|
||||
BOOST_CHECK_THROW(init1.getInitData<double>("DOUBHEAD", "XXXX") , std::invalid_argument );
|
||||
|
||||
auto doub_data_lgr1= init1.getInitData<double>("DOUBHEAD", "LGR1");
|
||||
auto doub_data_lgr2= init1.getInitData<double>("DOUBHEAD", "LGR2");
|
||||
|
||||
// item 4 in doubhead has been modified in this file test file
|
||||
// for LGR1 and LGR2 to ensure that at least one elemenet is different
|
||||
|
||||
BOOST_REQUIRE_CLOSE (doub_data_global[3], 0.10000000149012, 1e-5);
|
||||
BOOST_REQUIRE_CLOSE (doub_data_lgr1[3] , 0.10011100149012, 1e-5);
|
||||
BOOST_REQUIRE_CLOSE (doub_data_lgr2[3] , 0.10022200149012, 1e-5);
|
||||
|
||||
// int data type
|
||||
|
||||
auto fipnum_global= init1.getInitData<int>("FIPNUM");
|
||||
|
||||
BOOST_CHECK_THROW(init1.getInitData<int>("FIPNUM", "XXXX") , std::invalid_argument );
|
||||
|
||||
auto fipnum_lgr1= init1.getInitData<int>("FIPNUM", "LGR1");
|
||||
auto fipnum_lgr2= init1.getInitData<int>("FIPNUM", "LGR2");
|
||||
|
||||
BOOST_CHECK_EQUAL(fipnum_global.size(), 30);
|
||||
BOOST_CHECK_EQUAL(fipnum_lgr1.size(), 128);
|
||||
BOOST_CHECK_EQUAL(fipnum_lgr2.size(), 192);
|
||||
|
||||
// float data type
|
||||
|
||||
auto porv_global= init1.getInitData<float>("PORV");
|
||||
|
||||
BOOST_CHECK_THROW(init1.getInitData<float>("PORV", "XXXX") , std::invalid_argument );
|
||||
|
||||
auto porv_lgr1= init1.getInitData<float>("PORV", "LGR1");
|
||||
auto porv_lgr2= init1.getInitData<float>("PORV", "LGR2");
|
||||
|
||||
BOOST_CHECK_EQUAL(porv_global.size(), 30);
|
||||
BOOST_CHECK_EQUAL(porv_lgr1.size(), 128);
|
||||
BOOST_CHECK_EQUAL(porv_lgr2.size(), 192);
|
||||
|
||||
BOOST_CHECK_THROW(init1.getInitData<float>("DTHETA", "LGR1") , std::invalid_argument );
|
||||
BOOST_CHECK_THROW(init1.getInitData<float>("DY", "LGR2") , std::invalid_argument );
|
||||
|
||||
auto dx_lgr1= init1.getInitData<float>("DX", "LGR1");
|
||||
auto dx_global= init1.getInitData<float>("DX");
|
||||
auto dtheta_lgr2= init1.getInitData<float>("DTHETA", "LGR2");
|
||||
|
||||
for (auto dx : dx_lgr1)
|
||||
BOOST_REQUIRE_CLOSE (dx , 25.0, 0.1);
|
||||
|
||||
for (auto dx : dx_global)
|
||||
BOOST_REQUIRE_CLOSE (dx , 100.0, 0.1);
|
||||
|
||||
for (auto dtheta : dtheta_lgr2)
|
||||
BOOST_REQUIRE_CLOSE (dtheta , 45.0, 0.1);
|
||||
}
|
@ -87,6 +87,7 @@ void write_header(std::ofstream& ofileH, std::string& arrName, int size, std::st
|
||||
ofileH.write(reinterpret_cast<char*>(&bhead), sizeof(bhead));
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestEclFile_X231) {
|
||||
|
||||
std::string filename = "TEST.DAT";
|
||||
|
Loading…
Reference in New Issue
Block a user