ECLFilesComparator::ECLFilesComparator(int file_type, const std::string& basename1, const std::string& basename2, double absTolerance, double relTolerance): file_type(file_type), absTolerance(absTolerance), relTolerance(relTolerance) { std::string file1, file2; if (file_type == ECL_UNIFIED_RESTART_FILE) { file1 = basename1 + ".UNRST"; file2 = basename2 + ".UNRST"; } else if (file_type == ECL_INIT_FILE) { file1 = basename1 + ".INIT"; file2 = basename2 + ".INIT"; } else if (file_type == ECL_RFT_FILE) { file1 = basename1 + ".RFT"; file2 = basename2 + ".RFT"; } else { OPM_THROW(std::invalid_argument, "Unsupported filetype sent to ECLFilesComparator's constructor." << "Only unified restart (.UNRST), initial (.INIT) and .RFT files are supported."); } ecl_file1 = ecl_file_open(file1.c_str(), 0); ecl_file2 = ecl_file_open(file2.c_str(), 0); ecl_grid1 = ecl_grid_load_case(basename1.c_str()); ecl_grid2 = ecl_grid_load_case(basename2.c_str()); if (ecl_file1 == nullptr) { OPM_THROW(std::invalid_argument, "Error opening first file: " << file1); } if (ecl_file2 == nullptr) { OPM_THROW(std::invalid_argument, "Error opening second file: " << file2); } if (ecl_grid1 == nullptr) { OPM_THROW(std::invalid_argument, "Error opening first grid file: " << basename1); } if (ecl_grid2 == nullptr) { OPM_THROW(std::invalid_argument, "Error opening second grid file. " << basename2); } unsigned int numKeywords1 = ecl_file_get_num_distinct_kw(ecl_file1); unsigned int numKeywords2 = ecl_file_get_num_distinct_kw(ecl_file2); keywords1.reserve(numKeywords1); keywords2.reserve(numKeywords2); for (unsigned int i = 0; i < numKeywords1; ++i) { std::string keyword(ecl_file_iget_distinct_kw(ecl_file1, i)); keywords1.push_back(keyword); } for (unsigned int i = 0; i < numKeywords2; ++i) { std::string keyword(ecl_file_iget_distinct_kw(ecl_file2, i)); keywords2.push_back(keyword); } }
ECLFilesComparator::ECLFilesComparator(eclFileEnum fileType, const std::string& basename1, const std::string& basename2, double absTolerance, double relTolerance): fileType(fileType), absTolerance(absTolerance), relTolerance(relTolerance) { std::string file1, file2; if (fileType == RESTARTFILE) { file1 = basename1 + ".UNRST"; file2 = basename2 + ".UNRST"; } else if (fileType == INITFILE) { file1 = basename1 + ".INIT"; file2 = basename2 + ".INIT"; } ecl_file1 = ecl_file_open(file1.c_str(), 0); ecl_file2 = ecl_file_open(file2.c_str(), 0); ecl_grid1 = ecl_grid_load_case(basename1.c_str()); ecl_grid2 = ecl_grid_load_case(basename2.c_str()); if (ecl_file1 == nullptr) { std::cout << "Tried to open: " << file1 << std::endl; OPM_THROW(std::runtime_error, "Error opening first file."); } if (ecl_file2 == nullptr) { std::cout << "Tried to open: " << file2 << std::endl; OPM_THROW(std::runtime_error, "Error opening second file."); } if (ecl_grid1 == nullptr) { std::cout << "Tried to open: " << basename1 + ".EGRID" << std::endl; OPM_THROW(std::runtime_error, "Error opening first file."); } if (ecl_grid2 == nullptr) { std::cout << "Tried to open: " << basename2 + ".EGRID" << std::endl; OPM_THROW(std::runtime_error, "Error opening second file."); } unsigned int numKeywords1 = ecl_file_get_num_distinct_kw(ecl_file1); unsigned int numKeywords2 = ecl_file_get_num_distinct_kw(ecl_file2); for (unsigned int i = 0; i < numKeywords1; ++i) { std::string keyword(ecl_file_iget_distinct_kw(ecl_file1, i)); keywords1.push_back(keyword); } for (unsigned int i = 0; i < numKeywords2; ++i) { std::string keyword(ecl_file_iget_distinct_kw(ecl_file2, i)); keywords2.push_back(keyword); } }