diff --git a/examples/sim_poly2p_comp_reorder.cpp b/examples/sim_poly2p_comp_reorder.cpp index cdccc3820..28d34e2a9 100644 --- a/examples/sim_poly2p_comp_reorder.cpp +++ b/examples/sim_poly2p_comp_reorder.cpp @@ -73,6 +73,7 @@ namespace // ----------------- Main program ----------------- int main(int argc, char** argv) +try { using namespace Opm; @@ -225,7 +226,7 @@ main(int argc, char** argv) create_directories(fpath); } catch (...) { - THROW("Creating directories failed: " << fpath); + OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath); } param.writeParam(output_dir + "/simulation.param"); } @@ -273,7 +274,7 @@ main(int argc, char** argv) const bool use_wpolymer = deck->hasField("WPOLYMER"); if (use_wpolymer) { if (param.has("poly_start_days")) { - MESSAGE("Warning: Using WPOLYMER to control injection since it was found in deck. " + OPM_MESSAGE("Warning: Using WPOLYMER to control injection since it was found in deck. " "You seem to be trying to control it via parameter poly_start_days (etc.) as well."); } } @@ -286,7 +287,7 @@ main(int argc, char** argv) simtimer.init(*deck); } else { if (epoch != 0) { - THROW("No TSTEP in deck for epoch " << epoch); + OPM_THROW(std::runtime_error, "No TSTEP in deck for epoch " << epoch); } simtimer.init(param); } @@ -303,7 +304,7 @@ main(int argc, char** argv) boost::scoped_ptr polymer_inflow; if (use_wpolymer) { if (wells.c_wells() == 0) { - THROW("Cannot control polymer injection via WPOLYMER without wells."); + OPM_THROW(std::runtime_error, "Cannot control polymer injection via WPOLYMER without wells."); } polymer_inflow.reset(new PolymerInflowFromDeck(*deck, *wells.c_wells(), props->numCells())); } else { @@ -345,3 +346,8 @@ main(int argc, char** argv) std::cout << "\n\n================ End of simulation ===============\n\n"; rep.report(std::cout); } +catch (const std::exception &e) { + std::cerr << "Program threw an exception: " << e.what() << "\n"; + throw; +} + diff --git a/examples/sim_poly2p_incomp_reorder.cpp b/examples/sim_poly2p_incomp_reorder.cpp index 8b3644ae7..48aab1ebc 100644 --- a/examples/sim_poly2p_incomp_reorder.cpp +++ b/examples/sim_poly2p_incomp_reorder.cpp @@ -73,6 +73,7 @@ namespace // ----------------- Main program ----------------- int main(int argc, char** argv) +try { using namespace Opm; @@ -229,7 +230,7 @@ main(int argc, char** argv) create_directories(fpath); } catch (...) { - THROW("Creating directories failed: " << fpath); + OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath); } param.writeParam(output_dir + "/simulation.param"); } @@ -277,7 +278,7 @@ main(int argc, char** argv) const bool use_wpolymer = deck->hasField("WPOLYMER"); if (use_wpolymer) { if (param.has("poly_start_days")) { - MESSAGE("Warning: Using WPOLYMER to control injection since it was found in deck. " + OPM_MESSAGE("Warning: Using WPOLYMER to control injection since it was found in deck. " "You seem to be trying to control it via parameter poly_start_days (etc.) as well."); } } @@ -290,7 +291,7 @@ main(int argc, char** argv) simtimer.init(*deck); } else { if (epoch != 0) { - THROW("No TSTEP in deck for epoch " << epoch); + OPM_THROW(std::runtime_error, "No TSTEP in deck for epoch " << epoch); } simtimer.init(param); } @@ -307,7 +308,7 @@ main(int argc, char** argv) boost::scoped_ptr polymer_inflow; if (use_wpolymer) { if (wells.c_wells() == 0) { - THROW("Cannot control polymer injection via WPOLYMER without wells."); + OPM_THROW(std::runtime_error, "Cannot control polymer injection via WPOLYMER without wells."); } polymer_inflow.reset(new PolymerInflowFromDeck(*deck, *wells.c_wells(), props->numCells())); } else { @@ -349,3 +350,7 @@ main(int argc, char** argv) std::cout << "\n\n================ End of simulation ===============\n\n"; rep.report(std::cout); } +catch (const std::exception &e) { + std::cerr << "Program threw an exception: " << e.what() << "\n"; + throw; +} diff --git a/examples/test_singlecellsolves.cpp b/examples/test_singlecellsolves.cpp index fbee1a3fa..217be6b49 100644 --- a/examples/test_singlecellsolves.cpp +++ b/examples/test_singlecellsolves.cpp @@ -60,6 +60,7 @@ // ----------------- Main program ----------------- int main(int argc, char** argv) +try { using namespace Opm; @@ -167,7 +168,7 @@ main(int argc, char** argv) } else if (method_string == "NewtonSimpleC") { method = Opm::TransportSolverTwophasePolymer::NewtonSimpleC; } else { - THROW("Unknown method: " << method_string); + OPM_THROW(std::runtime_error, "Unknown method: " << method_string); } Opm::TransportSolverTwophasePolymer reorder_model(*grid->c_grid(), *props, poly_props, method, nl_tolerance, nl_maxiter); @@ -203,7 +204,7 @@ main(int argc, char** argv) } } if (face01 == -1) { - THROW("Could not find face adjacent to cells [0 1]"); + OPM_THROW(std::runtime_error, "Could not find face adjacent to cells [0 1]"); } state.faceflux()[face01] = src[0]; for (int sats = 0; sats < num_sats; ++sats) { @@ -247,3 +248,8 @@ main(int argc, char** argv) } } } +catch (const std::exception &e) { + std::cerr << "Program threw an exception: " << e.what() << "\n"; + throw; +} + diff --git a/opm/polymer/GravityColumnSolverPolymer_impl.hpp b/opm/polymer/GravityColumnSolverPolymer_impl.hpp index 7197aea0a..baca8abcb 100644 --- a/opm/polymer/GravityColumnSolverPolymer_impl.hpp +++ b/opm/polymer/GravityColumnSolverPolymer_impl.hpp @@ -40,6 +40,7 @@ #include #include #include +#include namespace Opm { @@ -217,7 +218,7 @@ namespace Opm ++iter; } if (max_delta >= tol_) { - THROW("Failed to converge!"); + OPM_THROW(std::runtime_error, "Failed to converge!"); } // Finalize. // fmodel_.finishIteration(); // @@ -286,7 +287,7 @@ namespace Opm hm[bmc(2*ci + 1, 2*(ci - 1) + 0)] += dFd2[2]; hm[bmc(2*ci + 1, 2*(ci - 1) + 1)] += dFd2[3]; } else { - ASSERT(c1 == next_cell || c2 == next_cell); + assert(c1 == next_cell || c2 == next_cell); hm[bmc(2*ci + 0, 2*(ci + 1) + 0)] += dFd2[0]; hm[bmc(2*ci + 0, 2*(ci + 1) + 1)] += dFd2[1]; hm[bmc(2*ci + 1, 2*(ci + 1) + 0)] += dFd2[2]; @@ -328,7 +329,7 @@ namespace Opm std::cerr << "Failed column cells: "; std::copy(column_cells.begin(), column_cells.end(), std::ostream_iterator(std::cerr, " ")); std::cerr << "\n"; - THROW("Lapack reported error in dgtsv: " << info); + OPM_THROW(std::runtime_error, "Lapack reported error in dgtsv: " << info); } for (int ci = 0; ci < col_size; ++ci) { sol_vec[2*column_cells[ci] + 0] = -rhs[2*ci + 0]; diff --git a/opm/polymer/IncompPropertiesDefaultPolymer.hpp b/opm/polymer/IncompPropertiesDefaultPolymer.hpp index b58d8bb0d..ca3faccf2 100644 --- a/opm/polymer/IncompPropertiesDefaultPolymer.hpp +++ b/opm/polymer/IncompPropertiesDefaultPolymer.hpp @@ -43,7 +43,7 @@ namespace Opm IncompPropertiesDefaultPolymer(const Opm::parameter::ParameterGroup& param, int dim, int num_cells) : Opm::IncompPropertiesBasic(param, dim, num_cells) { - ASSERT(numPhases() == 2); + assert(numPhases() == 2); sw_.resize(3); sw_[0] = 0.2; sw_[1] = 0.7; @@ -76,7 +76,7 @@ namespace Opm double* kr, double* dkrds) const { - // ASSERT(dkrds == 0); + // assert(dkrds == 0); // We assume two phases flow for (int i = 0; i < n; ++i) { kr[2*i] = krw(s[2*i]); diff --git a/opm/polymer/PolymerInflow.cpp b/opm/polymer/PolymerInflow.cpp index cb643efbc..7c4e4b507 100644 --- a/opm/polymer/PolymerInflow.cpp +++ b/opm/polymer/PolymerInflow.cpp @@ -46,7 +46,7 @@ namespace Opm if (step_start + eps >= stime_ && step_end - eps <= etime_) { std::fill(poly_inflow_c.begin(), poly_inflow_c.end(), amount_); } else if (step_start + eps <= etime_ && step_end - eps >= stime_) { - MESSAGE("Warning: polymer injection set to change inside timestep. Using value at start of step."); + OPM_MESSAGE("Warning: polymer injection set to change inside timestep. Using value at start of step."); std::fill(poly_inflow_c.begin(), poly_inflow_c.end(), amount_); } else { std::fill(poly_inflow_c.begin(), poly_inflow_c.end(), 0.0); @@ -66,7 +66,7 @@ namespace Opm : sparse_inflow_(num_cells) { if (!deck.hasField("WPOLYMER")) { - MESSAGE("PolymerInflowFromDeck initialized without WPOLYMER in current epoch."); + OPM_MESSAGE("PolymerInflowFromDeck initialized without WPOLYMER in current epoch."); return; } @@ -85,7 +85,7 @@ namespace Opm } } if (wix == wells.number_of_wells) { - THROW("Could not find a match for well " << wpl[i].well_ << " from WPOLYMER."); + OPM_THROW(std::runtime_error, "Could not find a match for well " << wpl[i].well_ << " from WPOLYMER."); } for (int j = wells.well_connpos[wix]; j < wells.well_connpos[wix+1]; ++j) { const int perf_cell = wells.well_cells[j]; diff --git a/opm/polymer/PolymerProperties.cpp b/opm/polymer/PolymerProperties.cpp index 2c609f34f..4234a55b7 100644 --- a/opm/polymer/PolymerProperties.cpp +++ b/opm/polymer/PolymerProperties.cpp @@ -119,7 +119,7 @@ namespace Opm simpleAdsorptionBoth(c, c_ads, dc_ads_dc, if_with_der); } } else { - THROW("Invalid Adsoption index"); + OPM_THROW(std::runtime_error, "Invalid Adsoption index"); } } diff --git a/opm/polymer/PolymerProperties.hpp b/opm/polymer/PolymerProperties.hpp index a447d08c5..197fd9489 100644 --- a/opm/polymer/PolymerProperties.hpp +++ b/opm/polymer/PolymerProperties.hpp @@ -117,7 +117,7 @@ namespace Opm // We assume NTSFUN=1 const std::vector& plyrock = gridparser.getPLYROCK().plyrock_; - ASSERT(plyrock.size() == 5); + assert(plyrock.size() == 5); dead_pore_vol_ = plyrock[0]; res_factor_ = plyrock[1]; rock_density_ = plyrock[2]; diff --git a/opm/polymer/SimulatorCompressiblePolymer.cpp b/opm/polymer/SimulatorCompressiblePolymer.cpp index 637198d13..829761fb4 100644 --- a/opm/polymer/SimulatorCompressiblePolymer.cpp +++ b/opm/polymer/SimulatorCompressiblePolymer.cpp @@ -58,6 +58,7 @@ #include #include +#include namespace Opm @@ -213,7 +214,7 @@ namespace Opm create_directories(fpath); } catch (...) { - THROW("Creating directories failed: " << fpath); + OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath); } output_interval_ = param.getDefault("output_interval", 1); } @@ -230,7 +231,7 @@ namespace Opm } else if (method_string == "Newton") { method = Opm::TransportSolverTwophaseCompressiblePolymer::Newton; } else { - THROW("Unknown method: " << method_string); + OPM_THROW(std::runtime_error, "Unknown method: " << method_string); } tsolver_.setPreferredMethod(method); num_transport_substeps_ = param.getDefault("num_transport_substeps", 1); @@ -367,7 +368,7 @@ namespace Opm well_control_passed = wells_manager_.conditionsMet(well_state.bhp(), well_resflows_phase, well_resflows_phase); ++well_control_iteration; if (!well_control_passed && well_control_iteration > max_well_control_iterations_) { - THROW("Could not satisfy well conditions in " << max_well_control_iterations_ << " tries."); + OPM_THROW(std::runtime_error, "Could not satisfy well conditions in " << max_well_control_iterations_ << " tries."); } if (!well_control_passed) { std::cout << "Well controls not passed, solving again." << std::endl; @@ -539,12 +540,12 @@ namespace Opm create_directories(fpath); } catch (...) { - THROW("Creating directories failed: " << fpath); + OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath); } vtkfilename << "/output-" << std::setw(5) << std::setfill('0') << step << ".vtu"; std::ofstream vtkfile(vtkfilename.str().c_str()); if (!vtkfile) { - THROW("Failed to open " << vtkfilename.str()); + OPM_THROW(std::runtime_error, "Failed to open " << vtkfilename.str()); } Opm::DataMap dm; dm["saturation"] = &state.saturation(); @@ -582,12 +583,12 @@ namespace Opm create_directories(fpath); } catch (...) { - THROW("Creating directories failed: " << fpath); + OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath); } fname << "/" << std::setw(5) << std::setfill('0') << step << ".txt"; std::ofstream file(fname.str().c_str()); if (!file) { - THROW("Failed to open " << fname.str()); + OPM_THROW(std::runtime_error, "Failed to open " << fname.str()); } const std::vector& d = *(it->second); std::copy(d.begin(), d.end(), std::ostream_iterator(file, "\n")); @@ -601,7 +602,7 @@ namespace Opm std::string fname = output_dir + "/watercut.txt"; std::ofstream os(fname.c_str()); if (!os) { - THROW("Failed to open " << fname); + OPM_THROW(std::runtime_error, "Failed to open " << fname); } watercut.write(os); } @@ -614,7 +615,7 @@ namespace Opm std::string fname = output_dir + "/wellreport.txt"; std::ofstream os(fname.c_str()); if (!os) { - THROW("Failed to open " << fname); + OPM_THROW(std::runtime_error, "Failed to open " << fname); } wellreport.write(os); } diff --git a/opm/polymer/SimulatorPolymer.cpp b/opm/polymer/SimulatorPolymer.cpp index ebe8c587a..4e21fb23d 100644 --- a/opm/polymer/SimulatorPolymer.cpp +++ b/opm/polymer/SimulatorPolymer.cpp @@ -58,6 +58,7 @@ #include #include +#include #ifdef HAVE_ERT #include @@ -219,7 +220,7 @@ namespace Opm output_binary_ = param.getDefault("output_binary", false); #ifndef HAVE_ERT if (output_binary_) { - THROW("Cannot make binary output without ert library support. Reconfigure opm-core and opm-polymer with --with-ert and recompile."); + OPM_THROW(std::runtime_error, "Cannot make binary output without ert library support. Reconfigure opm-core and opm-polymer with --with-ert and recompile."); } #endif output_dir_ = param.getDefault("output_dir", std::string("output")); @@ -229,7 +230,7 @@ namespace Opm create_directories(fpath); } catch (...) { - THROW("Creating directories failed: " << fpath); + OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath); } output_interval_ = param.getDefault("output_interval", 1); } @@ -246,7 +247,7 @@ namespace Opm } else if (method_string == "Newton") { method = Opm::TransportSolverTwophasePolymer::Newton; } else { - THROW("Unknown method: " << method_string); + OPM_THROW(std::runtime_error, "Unknown method: " << method_string); } tsolver_.setPreferredMethod(method); num_transport_substeps_ = param.getDefault("num_transport_substeps", 1); @@ -388,7 +389,7 @@ namespace Opm well_control_passed = wells_manager_.conditionsMet(well_state.bhp(), well_resflows_phase, well_resflows_phase); ++well_control_iteration; if (!well_control_passed && well_control_iteration > max_well_control_iterations_) { - THROW("Could not satisfy well conditions in " << max_well_control_iterations_ << " tries."); + OPM_THROW(std::runtime_error, "Could not satisfy well conditions in " << max_well_control_iterations_ << " tries."); } if (!well_control_passed) { std::cout << "Well controls not passed, solving again." << std::endl; @@ -551,12 +552,12 @@ namespace Opm create_directories(fpath); } catch (...) { - THROW("Creating directories failed: " << fpath); + OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath); } vtkfilename << "/output-" << std::setw(5) << std::setfill('0') << step << ".vtu"; std::ofstream vtkfile(vtkfilename.str().c_str()); if (!vtkfile) { - THROW("Failed to open " << vtkfilename.str()); + OPM_THROW(std::runtime_error, "Failed to open " << vtkfilename.str()); } Opm::DataMap dm; dm["saturation"] = &state.saturation(); @@ -592,12 +593,12 @@ namespace Opm create_directories(fpath); } catch (...) { - THROW("Creating directories failed: " << fpath); + OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath); } fname << "/" << std::setw(5) << std::setfill('0') << step << ".txt"; std::ofstream file(fname.str().c_str()); if (!file) { - THROW("Failed to open " << fname.str()); + OPM_THROW(std::runtime_error, "Failed to open " << fname.str()); } const std::vector& d = *(it->second); std::copy(d.begin(), d.end(), std::ostream_iterator(file, "\n")); @@ -622,7 +623,7 @@ namespace Opm writeECLData(grid, dm, simtimer.currentStepNum(), simtimer.currentTime(), simtimer.currentDateTime(), output_dir, "polymer_ecl"); #else - THROW("Cannot call outputStateBinary() without ert library support. Reconfigure with --with-ert and recompile."); + OPM_THROW(std::runtime_error, "Cannot call outputStateBinary() without ert library support. Reconfigure with --with-ert and recompile."); #endif } @@ -633,7 +634,7 @@ namespace Opm std::string fname = output_dir + "/watercut.txt"; std::ofstream os(fname.c_str()); if (!os) { - THROW("Failed to open " << fname); + OPM_THROW(std::runtime_error, "Failed to open " << fname); } watercut.write(os); } @@ -646,7 +647,7 @@ namespace Opm std::string fname = output_dir + "/wellreport.txt"; std::ofstream os(fname.c_str()); if (!os) { - THROW("Failed to open " << fname); + OPM_THROW(std::runtime_error, "Failed to open " << fname); } wellreport.write(os); } diff --git a/opm/polymer/TransportSolverTwophaseCompressiblePolymer.cpp b/opm/polymer/TransportSolverTwophaseCompressiblePolymer.cpp index f963f799d..fbe0e5863 100644 --- a/opm/polymer/TransportSolverTwophaseCompressiblePolymer.cpp +++ b/opm/polymer/TransportSolverTwophaseCompressiblePolymer.cpp @@ -26,9 +26,10 @@ #include #include #include +#include #include #include -#include +#include // Choose error policy for scalar solves here. typedef Opm::RegulaFalsi RootFinder; @@ -185,7 +186,7 @@ namespace Opm const int np = props.numPhases(); const int num_cells = grid.number_of_cells; if (props.numPhases() != 2) { - THROW("Property object must have 2 phases"); + OPM_THROW(std::runtime_error, "Property object must have 2 phases"); } visc_.resize(np*num_cells); A_.resize(np*np*num_cells); @@ -243,7 +244,7 @@ namespace Opm // Check immiscibility requirement (only done for first cell). if (A_[1] != 0.0 || A_[2] != 0.0) { - THROW("TransportCompressibleSolverTwophaseCompressibleTwophase requires a property object without miscibility."); + OPM_THROW(std::runtime_error, "TransportCompressibleSolverTwophaseCompressibleTwophase requires a property object without miscibility."); } std::vector seq(grid_.number_of_cells); std::vector comp(grid_.number_of_cells + 1); @@ -635,7 +636,7 @@ namespace Opm solveSingleCellGradient(cell); break; default: - THROW("Unknown method " << method_); + OPM_THROW(std::runtime_error, "Unknown method " << method_); } } @@ -817,7 +818,7 @@ namespace Opm if ((iters_used_split >= max_iters_split) && (norm(res) > tol_)) { - MESSAGE("Newton for single cell did not work in cell number " << cell); + OPM_MESSAGE("Newton for single cell did not work in cell number " << cell); solveSingleCellBracketing(cell); } else { scToc(x, x_c); @@ -963,7 +964,7 @@ namespace Opm } if ((iters_used_split >= max_iters_split) && (norm(res) > tol_)) { - MESSAGE("Newton for single cell did not work in cell number " << cell); + OPM_MESSAGE("Newton for single cell did not work in cell number " << cell); solveSingleCellBracketing(cell); } else { concentration_[cell] = x[1]; @@ -1021,11 +1022,11 @@ namespace Opm // << " in cell " << max_change_cell << std::endl; } while (((max_s_change > tol_) || (max_c_change > tol_)) && ++num_iters < maxit_); if (max_s_change > tol_) { - THROW("In solveMultiCell(), we did not converge after " + OPM_THROW(std::runtime_error, "In solveMultiCell(), we did not converge after " << num_iters << " iterations. Delta s = " << max_s_change); } if (max_c_change > tol_) { - THROW("In solveMultiCell(), we did not converge after " + OPM_THROW(std::runtime_error, "In solveMultiCell(), we did not converge after " << num_iters << " iterations. Delta c = " << max_c_change); } // std::cout << "Solved " << num_cells << " cell multicell problem in " @@ -1255,7 +1256,7 @@ namespace Opm const int nc = grid_.number_of_cells; const int nf = grid_.number_of_faces; const int np = props_.numPhases(); - ASSERT(np == 2); + assert(np == 2); const int dim = grid_.dimensions; density_.resize(nc*np); props_.density(grid_.number_of_cells, &A_[0], &density_[0]); @@ -1356,7 +1357,7 @@ namespace Opm } while (max_sc_change > tol_ && ++num_iters < maxit_); if (max_sc_change > tol_) { - THROW("In solveGravityColumn(), we did not converge after " + OPM_THROW(std::runtime_error, "In solveGravityColumn(), we did not converge after " << num_iters << " iterations. Delta s = " << max_sc_change); } return num_iters + 1; @@ -1501,7 +1502,7 @@ namespace } else if (t1_exists) { t_out_ = t1; } else { - THROW("Direction illegal: is a zero vector."); + OPM_THROW(std::runtime_error, "Direction illegal: is a zero vector."); } x_out_[0] = x_[0] + t_out_*direction_[0]; x_out_[1] = x_[1] + t_out_*direction_[1]; diff --git a/opm/polymer/TransportSolverTwophasePolymer.cpp b/opm/polymer/TransportSolverTwophasePolymer.cpp index 7fe811344..e6179bf07 100644 --- a/opm/polymer/TransportSolverTwophasePolymer.cpp +++ b/opm/polymer/TransportSolverTwophasePolymer.cpp @@ -24,9 +24,10 @@ #include #include #include +#include #include #include -#include +#include // Choose error policy for scalar solves here. typedef Opm::RegulaFalsi RootFinder; @@ -199,7 +200,7 @@ namespace Opm adhoc_safety_(1.1) { if (props.numPhases() != 2) { - THROW("Property object must have 2 phases"); + OPM_THROW(std::runtime_error, "Property object must have 2 phases"); } visc_ = props.viscosity(); @@ -569,7 +570,7 @@ namespace Opm solveSingleCellNewtonSimple(cell,false); break; default: - THROW("Unknown method " << method_); + OPM_THROW(std::runtime_error, "Unknown method " << method_); } } @@ -751,7 +752,7 @@ namespace Opm if ((iters_used_split >= max_iters_split) && (norm(res) > tol_)) { - MESSAGE("Newton for single cell did not work in cell number " << cell); + OPM_MESSAGE("Newton for single cell did not work in cell number " << cell); solveSingleCellBracketing(cell); } else { scToc(x, x_c); @@ -850,7 +851,7 @@ namespace Opm } if ((iters_used_split >= max_iters_split) && (norm(res) > tol_)) { - MESSAGE("Newton for single cell did not work in cell number " << cell); + OPM_MESSAGE("Newton for single cell did not work in cell number " << cell); solveSingleCellBracketing(cell); } else { concentration_[cell] = x[1]; @@ -943,7 +944,7 @@ namespace Opm } det = dFx_dx*dFy_dy - dFy_dx*dFx_dy; if(det==0){ - THROW("det is zero"); + OPM_THROW(std::runtime_error, "det is zero"); } double alpha=1; @@ -997,7 +998,7 @@ namespace Opm } if ((iters_used_split >= max_iters_split) || (norm(res) > tol_)) { - MESSAGE("NewtonSimple for single cell did not work in cell number " << cell); + OPM_MESSAGE("NewtonSimple for single cell did not work in cell number " << cell); solveSingleCellBracketing(cell); } else { concentration_[cell] = x[1]; @@ -1056,11 +1057,11 @@ namespace Opm // << " in cell " << max_change_cell << std::endl; } while (((max_s_change > tol_) || (max_c_change > tol_)) && ++num_iters < maxit_); if (max_s_change > tol_) { - THROW("In solveMultiCell(), we did not converge after " + OPM_THROW(std::runtime_error, "In solveMultiCell(), we did not converge after " << num_iters << " iterations. Delta s = " << max_s_change); } if (max_c_change > tol_) { - THROW("In solveMultiCell(), we did not converge after " + OPM_THROW(std::runtime_error, "In solveMultiCell(), we did not converge after " << num_iters << " iterations. Delta c = " << max_c_change); } std::cout << "Solved " << num_cells << " cell multicell problem in " @@ -1365,7 +1366,7 @@ namespace Opm } while (max_sc_change > tol_ && ++num_iters < maxit_); if (max_sc_change > tol_) { - THROW("In solveGravityColumn(), we did not converge after " + OPM_THROW(std::runtime_error, "In solveGravityColumn(), we did not converge after " << num_iters << " iterations. Delta s = " << max_sc_change); } return num_iters + 1; @@ -1501,7 +1502,7 @@ namespace } else if (t1_exists) { t_out_ = t1; } else { - THROW("Direction illegal: is a zero vector."); + OPM_THROW(std::runtime_error, "Direction illegal: is a zero vector."); } x_out_[0] = x_[0] + t_out_*direction_[0]; x_out_[1] = x_[1] + t_out_*direction_[1]; diff --git a/opm/polymer/polymerUtilities.cpp b/opm/polymer/polymerUtilities.cpp index 33e0ebf02..da34adfc3 100644 --- a/opm/polymer/polymerUtilities.cpp +++ b/opm/polymer/polymerUtilities.cpp @@ -75,7 +75,7 @@ namespace Opm int num_phases = props.numPhases(); totmob.resize(num_cells); omega.resize(num_cells); - ASSERT(int(s.size()) == num_cells*num_phases); + assert(int(s.size()) == num_cells*num_phases); std::vector kr(num_cells*num_phases); props.relperm(num_cells, &s[0], &cells[0], &kr[0], 0); const double* visc = props.viscosity(); @@ -110,10 +110,10 @@ namespace Opm int num_cells = cells.size(); int num_phases = props.numPhases(); if (num_phases != 2) { - THROW("computeFractionalFlow() assumes 2 phases."); + OPM_THROW(std::runtime_error, "computeFractionalFlow() assumes 2 phases."); } fractional_flows.resize(num_cells*num_phases); - ASSERT(int(s.size()) == num_cells*num_phases); + assert(int(s.size()) == num_cells*num_phases); std::vector kr(num_cells*num_phases); props.relperm(num_cells, &s[0], &cells[0], &kr[0], 0); const double* visc = props.viscosity(); @@ -150,10 +150,10 @@ namespace Opm int num_cells = cells.size(); int num_phases = props.numPhases(); if (num_phases != 2) { - THROW("computeFractionalFlow() assumes 2 phases."); + OPM_THROW(std::runtime_error, "computeFractionalFlow() assumes 2 phases."); } fractional_flows.resize(num_cells*num_phases); - ASSERT(int(s.size()) == num_cells*num_phases); + assert(int(s.size()) == num_cells*num_phases); std::vector kr(num_cells*num_phases); props.relperm(num_cells, &s[0], &cells[0], &kr[0], 0); std::vector mu(num_cells*num_phases); @@ -201,11 +201,11 @@ namespace Opm const int num_cells = transport_src.size(); if (props.numCells() != num_cells) { - THROW("Size of transport_src vector does not match number of cells in props."); + OPM_THROW(std::runtime_error, "Size of transport_src vector does not match number of cells in props."); } const int np = props.numPhases(); if (int(state.saturation().size()) != num_cells*np) { - THROW("Sizes of state vectors do not match number of cells."); + OPM_THROW(std::runtime_error, "Sizes of state vectors do not match number of cells."); } const std::vector& s = state.saturation(); const std::vector& c = state.concentration(); @@ -269,11 +269,11 @@ namespace Opm { const int num_cells = transport_src.size(); if (props.numCells() != num_cells) { - THROW("Size of transport_src vector does not match number of cells in props."); + OPM_THROW(std::runtime_error, "Size of transport_src vector does not match number of cells in props."); } const int np = props.numPhases(); if (int(state.saturation().size()) != num_cells*np) { - THROW("Sizes of state vectors do not match number of cells."); + OPM_THROW(std::runtime_error, "Sizes of state vectors do not match number of cells."); } const std::vector& press = state.pressure(); const std::vector& s = state.saturation(); @@ -344,7 +344,7 @@ namespace Opm const int num_cells = pv.size(); const int np = s.size()/pv.size(); if (int(s.size()) != num_cells*np) { - THROW("Sizes of s and pv vectors do not match."); + OPM_THROW(std::runtime_error, "Sizes of s and pv vectors do not match."); } double polymass = 0.0; for (int cell = 0; cell < num_cells; ++cell) {