Added try-catch to computation of bubble/dew point pressure

This commit is contained in:
babrodtk 2017-02-16 16:52:01 +01:00
parent 4a46451d95
commit c39964c712

View File

@ -1277,6 +1277,8 @@ namespace Opm {
VectorType& Pb = simData.getCellData( "PBUB" ); VectorType& Pb = simData.getCellData( "PBUB" );
VectorType& Pd = simData.getCellData( "PDEW" ); VectorType& Pd = simData.getCellData( "PDEW" );
std::vector<int> failed_cells_pb;
std::vector<int> failed_cells_pd;
for (int cellIdx = 0; cellIdx < numCells; ++cellIdx) { for (int cellIdx = 0; cellIdx < numCells; ++cellIdx) {
const auto& intQuants = *ebosModel.cachedIntensiveQuantities(cellIdx, /*timeIdx=*/0); const auto& intQuants = *ebosModel.cachedIntensiveQuantities(cellIdx, /*timeIdx=*/0);
@ -1311,9 +1313,19 @@ namespace Opm {
FluidSystem::gasPhaseIdx, FluidSystem::gasPhaseIdx,
intQuants.pvtRegionIndex(), intQuants.pvtRegionIndex(),
/*maxOilSaturation=*/1.0).value(); /*maxOilSaturation=*/1.0).value();
try {
Pb[cellIdx] = FluidSystem::bubblePointPressure(fs, intQuants.pvtRegionIndex()).value(); Pb[cellIdx] = FluidSystem::bubblePointPressure(fs, intQuants.pvtRegionIndex()).value();
}
catch (const NumericalProblem& e) {
failed_cells_pb.push_back(cellIdx);
}
try {
Pd[cellIdx] = FluidSystem::dewPointPressure(fs, intQuants.pvtRegionIndex()).value(); Pd[cellIdx] = FluidSystem::dewPointPressure(fs, intQuants.pvtRegionIndex()).value();
} }
catch (const NumericalProblem& e) {
failed_cells_pd.push_back(cellIdx);
}
}
if( liquid_active ) if( liquid_active )
{ {
saturation[ satIdx + liquid_pos ] = fs.saturation(FluidSystem::oilPhaseIdx).value(); saturation[ satIdx + liquid_pos ] = fs.saturation(FluidSystem::oilPhaseIdx).value();
@ -1324,6 +1336,36 @@ namespace Opm {
} }
} }
const size_t max_num_cells_faillog = 20;
if (failed_cells_pb.size() > 0) {
std::stringstream errlog;
errlog << "Finding the dew point pressure failed for " << failed_cells_pb.size() << " cells [";
errlog << failed_cells_pb[0];
const int max_elems = std::min(max_num_cells_faillog, failed_cells_pb.size());
for (size_t i = 1; i < max_elems; ++i) {
errlog << ", " << failed_cells_pb[i];
}
if (failed_cells_pb.size() > max_num_cells_faillog) {
errlog << ", ...";
}
errlog << "]";
OpmLog::problem("pb numerical problem", errlog.str());
}
if (failed_cells_pd.size() > 0) {
std::stringstream errlog;
errlog << "Finding the dew point pressure failed for " << failed_cells_pd.size() << " cells [";
errlog << failed_cells_pd[0];
const int max_elems = std::min(max_num_cells_faillog, failed_cells_pd.size());
for (size_t i = 1; i < max_elems; ++i) {
errlog << ", " << failed_cells_pd[i];
}
if (failed_cells_pd.size() > max_num_cells_faillog) {
errlog << ", ...";
}
errlog << "]";
OpmLog::problem("pd numerical problem", errlog.str());
}
return simData; return simData;
} }