/// \brief Get a vector of pressure thresholds from either EclipseState /// or maxDp (for defaulted values) for all Non-neighbour connections (NNCs). /// \param[in] nnc The NNCs, /// \param[in] eclipseState Processed eclipse state, EQLNUM is accessed from it. /// \param[in] maxDp The maximum gravity corrected pressure differences between /// the equilibration regions. /// \return A vector of pressure thresholds, one /// for each NNC in the grid. A value /// of zero means no threshold for that /// particular connection. An empty vector is /// returned if there is no THPRES /// feature used in the deck. std::vector<double> thresholdPressuresNNC(EclipseStateConstPtr eclipseState, const NNC& nnc, const std::map<std::pair<int, int>, double>& maxDp) { const SimulationConfig& simulationConfig = eclipseState->getSimulationConfig(); std::vector<double> thpres_vals; if (simulationConfig.hasThresholdPressure()) { std::shared_ptr<const ThresholdPressure> thresholdPressure = simulationConfig.getThresholdPressure(); const auto& eqlnum = eclipseState->get3DProperties().getIntGridProperty("EQLNUM"); const auto& eqlnumData = eqlnum.getData(); // Set values for each NNC thpres_vals.resize(nnc.numNNC(), 0.0); for (size_t i = 0 ; i < nnc.numNNC(); ++i) { const int gc1 = nnc.nncdata()[i].cell1; const int gc2 = nnc.nncdata()[i].cell2; const int eq1 = eqlnumData[gc1]; const int eq2 = eqlnumData[gc2]; if (thresholdPressure->hasRegionBarrier(eq1,eq2)) { if (thresholdPressure->hasThresholdPressure(eq1,eq2)) { thpres_vals[i] = thresholdPressure->getThresholdPressure(eq1,eq2); } else { // set the threshold pressure for NNC of PVT regions where the third item // has been defaulted to the maximum pressure potential difference between // these regions const auto barrierId = std::make_pair(eq1, eq2); thpres_vals[i] = maxDp.at(barrierId); } } } } return thpres_vals; }
void restoreSOLUTION(const std::string& restart_filename, int reportstep, bool unified, EclipseStateConstPtr eclipseState, int numcells, const PhaseUsage& phaseUsage, SimulatorState& simulator_state) { const char* filename = restart_filename.c_str(); ecl_file_type* file_type = ecl_file_open(filename, 0); if (file_type) { bool block_selected = unified ? ecl_file_select_rstblock_report_step(file_type , reportstep) : true; if (block_selected) { restorePressureData(file_type, eclipseState, numcells, simulator_state); restoreTemperatureData(file_type, eclipseState, numcells, simulator_state); restoreSaturation(file_type, phaseUsage, numcells, simulator_state); BlackoilState* blackoilState = dynamic_cast<BlackoilState*>(&simulator_state); if (blackoilState) { SimulationConfigConstPtr sim_config = eclipseState->getSimulationConfig(); restoreRSandRV(file_type, sim_config, numcells, blackoilState); } } else { std::string error_str = "Restart file " + restart_filename + " does not contain data for report step " + std::to_string(reportstep) + "!\n"; throw std::runtime_error(error_str); } ecl_file_close(file_type); } else { std::string error_str = "Restart file " + restart_filename + " not found!\n"; throw std::runtime_error(error_str); } }
std::vector<double> thresholdPressures(const DeckConstPtr& /* deck */, EclipseStateConstPtr eclipseState, const Grid& grid, const std::map<std::pair<int, int>, double>& maxDp) { const SimulationConfig& simulationConfig = eclipseState->getSimulationConfig(); std::vector<double> thpres_vals; if (simulationConfig.hasThresholdPressure()) { std::shared_ptr<const ThresholdPressure> thresholdPressure = simulationConfig.getThresholdPressure(); const auto& eqlnum = eclipseState->get3DProperties().getIntGridProperty("EQLNUM"); const auto& eqlnumData = eqlnum.getData(); // Set threshold pressure values for each cell face. const int num_faces = UgGridHelpers::numFaces(grid); const auto& fc = UgGridHelpers::faceCells(grid); const int* gc = UgGridHelpers::globalCell(grid); thpres_vals.resize(num_faces, 0.0); for (int face = 0; face < num_faces; ++face) { const int c1 = fc(face, 0); const int c2 = fc(face, 1); if (c1 < 0 || c2 < 0) { // Boundary face, skip it. continue; } const int gc1 = (gc == 0) ? c1 : gc[c1]; const int gc2 = (gc == 0) ? c2 : gc[c2]; const int eq1 = eqlnumData[gc1]; const int eq2 = eqlnumData[gc2]; if (thresholdPressure->hasRegionBarrier(eq1,eq2)) { if (thresholdPressure->hasThresholdPressure(eq1,eq2)) { thpres_vals[face] = thresholdPressure->getThresholdPressure(eq1,eq2); } else { // set the threshold pressure for faces of PVT regions where the third item // has been defaulted to the maximum pressure potential difference between // these regions const auto barrierId = std::make_pair(std::min(eq1, eq2), std::max(eq1, eq2)); if (maxDp.count(barrierId) > 0) thpres_vals[face] = maxDp.at(barrierId); else thpres_vals[face] = 0.0; } } } } return thpres_vals; }