Add optional argument preload=false to EclFile constructor

This commit is contained in:
Joakim Hove
2019-11-01 17:01:07 +01:00
parent d3aec121f1
commit 74aa7bbd48
3 changed files with 6 additions and 5 deletions

View File

@@ -35,7 +35,7 @@ namespace Opm { namespace EclIO {
class EclFile
{
public:
explicit EclFile(const std::string& filename);
explicit EclFile(const std::string& filename, bool preload = false);
bool formattedInput() { return formatted; }
void loadData(); // load all data

View File

@@ -454,7 +454,7 @@ std::vector<double> readFormattedDoubArray(const std::string& file_str, const in
namespace Opm { namespace EclIO {
EclFile::EclFile(const std::string& filename) : inputFilename(filename)
EclFile::EclFile(const std::string& filename, bool preload) : inputFilename(filename)
{
if (!fileExists(filename)){
std::string message="Could not open EclFile: " + filename;
@@ -512,8 +512,10 @@ EclFile::EclFile(const std::string& filename) : inputFilename(filename)
fileH.seekg(0, std::ios_base::end);
this->ifStreamPos.push_back(static_cast<unsigned long>(fileH.tellg()));
fileH.close();
if (preload)
this->loadData();
}

View File

@@ -226,8 +226,7 @@ BOOST_AUTO_TEST_CASE(TestEcl_Write_formatted) {
// loading vectors from formatted input file and write data back to a formatted file1
// compare input and output file, and delete file.
EclFile file1(inputFile);
file1.loadData();
EclFile file1(inputFile, true);
std::vector<int> icon = file1.get<int>("ICON");
std::vector<float> porv = file1.get<float>("PORV");