From d6fa31b4521e364a4168a91ecd691826d7c35dd7 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Wed, 28 Aug 2013 14:00:35 +0200 Subject: [PATCH] convert users of the ASSERT and the ASSERT2 macros to standard assert() --- opm/core/pressure/CompressibleTpfa.cpp | 2 +- opm/core/pressure/FlowBCManager.cpp | 16 ++++++++-------- opm/core/pressure/IncompTpfa.cpp | 16 ++++++++-------- opm/core/props/BlackoilPropertiesBasic.cpp | 2 +- opm/core/props/pvt/PvtPropertiesBasic.cpp | 2 +- opm/core/props/rock/RockFromDeck.cpp | 4 ++-- .../satfunc/SaturationPropsFromDeck_impl.hpp | 6 +++--- opm/core/simulator/BlackoilState.hpp | 2 +- opm/core/simulator/initState_impl.hpp | 4 ++-- opm/core/tof/TofDiscGalReorder.cpp | 4 ++-- opm/core/tof/TofReorder.cpp | 4 ++-- ...ransportSolverCompressibleTwophaseReorder.cpp | 2 +- opm/core/utility/miscUtilities.cpp | 10 +++++----- opm/core/utility/miscUtilitiesBlackoil.cpp | 4 ++-- opm/core/wells/WellCollection.cpp | 2 +- opm/core/wells/WellsGroup.cpp | 4 ++-- opm/core/wells/WellsManager.cpp | 12 ++++++------ 17 files changed, 48 insertions(+), 48 deletions(-) diff --git a/opm/core/pressure/CompressibleTpfa.cpp b/opm/core/pressure/CompressibleTpfa.cpp index ca2008764..606e04bab 100644 --- a/opm/core/pressure/CompressibleTpfa.cpp +++ b/opm/core/pressure/CompressibleTpfa.cpp @@ -488,7 +488,7 @@ namespace Opm // only inject pure fluids. props_.matrix(1, &perf_p, comp_frac, &c, wpA, NULL); props_.viscosity(1, &perf_p, comp_frac, &c, &mu[0], NULL); - ASSERT(std::fabs(std::accumulate(comp_frac, comp_frac + np, 0.0) - 1.0) < 1e-6); + assert(std::fabs(std::accumulate(comp_frac, comp_frac + np, 0.0) - 1.0) < 1e-6); props_.relperm (1, comp_frac, &c, wpM , NULL); for (int phase = 0; phase < np; ++phase) { wpM[phase] /= mu[phase]; diff --git a/opm/core/pressure/FlowBCManager.cpp b/opm/core/pressure/FlowBCManager.cpp index 8055af32a..b326cf8c0 100644 --- a/opm/core/pressure/FlowBCManager.cpp +++ b/opm/core/pressure/FlowBCManager.cpp @@ -182,9 +182,9 @@ namespace Opm ix /= dims[dim]; } - ASSERT2 (ix == 0, - "Lexicographic index is not consistent " - "with grid dimensions."); + // Make sure that lexicographic index is consistent with + // grid dimensions. + assert(ix == 0); } @@ -202,12 +202,12 @@ namespace Opm OPM_THROW(std::runtime_error, "Faces not tagged - cannot extract " << sideString(side) << " faces."); } - ASSERT2 (grid.dimensions <= 3, - "Grid must have three dimensions or less."); + // make sure that grid has three dimensions or less. + assert(grid.dimensions <= 3); - ASSERT2 (side < 2 * grid.dimensions, - "Boundary condition side not consistent with " - "number of physical grid dimensions."); + // Make sure boundary condition side is consistent with + // number of physical grid dimensions. + assert(side < 2 * grid.dimensions); // Get all boundary faces with the correct tag and with // min/max i/j/k (depending on side). diff --git a/opm/core/pressure/IncompTpfa.cpp b/opm/core/pressure/IncompTpfa.cpp index 54128d8e5..1682270c2 100644 --- a/opm/core/pressure/IncompTpfa.cpp +++ b/opm/core/pressure/IncompTpfa.cpp @@ -186,14 +186,14 @@ namespace Opm linsolver_.solve(h_->A, h_->b, h_->x); // Obtain solution. - ASSERT(int(state.pressure().size()) == grid_.number_of_cells); - ASSERT(int(state.faceflux().size()) == grid_.number_of_faces); + assert(int(state.pressure().size()) == grid_.number_of_cells); + assert(int(state.faceflux().size()) == grid_.number_of_faces); ifs_tpfa_solution soln = { NULL, NULL, NULL, NULL }; soln.cell_press = &state.pressure()[0]; soln.face_flux = &state.faceflux()[0]; if (wells_ != NULL) { - ASSERT(int(well_state.bhp().size()) == wells_->number_of_wells); - ASSERT(int(well_state.perfRates().size()) == wells_->well_connpos[ wells_->number_of_wells ]); + assert(int(well_state.bhp().size()) == wells_->number_of_wells); + assert(int(well_state.perfRates().size()) == wells_->well_connpos[ wells_->number_of_wells ]); soln.well_flux = &well_state.perfRates()[0]; soln.well_press = &well_state.bhp()[0]; } @@ -473,8 +473,8 @@ namespace Opm // Make sure h_->x contains the direct solution vector. - ASSERT(int(state.pressure().size()) == grid_.number_of_cells); - ASSERT(int(state.faceflux().size()) == grid_.number_of_faces); + assert(int(state.pressure().size()) == grid_.number_of_cells); + assert(int(state.faceflux().size()) == grid_.number_of_faces); std::copy(state.pressure().begin(), state.pressure().end(), h_->x); std::copy(well_state.bhp().begin(), well_state.bhp().end(), h_->x + grid_.number_of_cells); @@ -483,8 +483,8 @@ namespace Opm soln.cell_press = &state.pressure()[0]; soln.face_flux = &state.faceflux()[0]; if (wells_ != NULL) { - ASSERT(int(well_state.bhp().size()) == wells_->number_of_wells); - ASSERT(int(well_state.perfRates().size()) == wells_->well_connpos[ wells_->number_of_wells ]); + assert(int(well_state.bhp().size()) == wells_->number_of_wells); + assert(int(well_state.perfRates().size()) == wells_->well_connpos[ wells_->number_of_wells ]); soln.well_flux = &well_state.perfRates()[0]; soln.well_press = &well_state.bhp()[0]; } diff --git a/opm/core/props/BlackoilPropertiesBasic.cpp b/opm/core/props/BlackoilPropertiesBasic.cpp index f314bdb04..8700af117 100644 --- a/opm/core/props/BlackoilPropertiesBasic.cpp +++ b/opm/core/props/BlackoilPropertiesBasic.cpp @@ -128,7 +128,7 @@ namespace Opm double* dAdp) const { const int np = numPhases(); - ASSERT(np <= 2); + assert(np <= 2); double B[2]; // Must be enough since component classes do not handle more than 2. pvt_.B(1, 0, 0, B); // Compute A matrix diff --git a/opm/core/props/pvt/PvtPropertiesBasic.cpp b/opm/core/props/pvt/PvtPropertiesBasic.cpp index aea7c4c11..297905228 100644 --- a/opm/core/props/pvt/PvtPropertiesBasic.cpp +++ b/opm/core/props/pvt/PvtPropertiesBasic.cpp @@ -98,7 +98,7 @@ namespace Opm pu.phase_pos[BlackoilPhases::Liquid] = 1; pu.phase_pos[BlackoilPhases::Vapour] = 1; // Unused. } else { - ASSERT(pu.num_phases == 3); + assert(pu.num_phases == 3); pu.phase_used[BlackoilPhases::Aqua] = true; pu.phase_used[BlackoilPhases::Liquid] = true; pu.phase_used[BlackoilPhases::Vapour] = true; diff --git a/opm/core/props/rock/RockFromDeck.cpp b/opm/core/props/rock/RockFromDeck.cpp index 940993860..730363434 100644 --- a/opm/core/props/rock/RockFromDeck.cpp +++ b/opm/core/props/rock/RockFromDeck.cpp @@ -89,7 +89,7 @@ namespace Opm const int num_global_cells = grid.cartdims[0]*grid.cartdims[1]*grid.cartdims[2]; const int nc = grid.number_of_cells; - ASSERT (num_global_cells > 0); + assert(num_global_cells > 0); permeability_.assign(dim * dim * nc, 0.0); @@ -273,7 +273,7 @@ namespace Opm if (kind == Invalid) { OPM_THROW(std::runtime_error, "Invalid set of permeability fields given."); } - ASSERT (tensor.size() == 1); + assert(tensor.size() == 1); for (int i = 0; i < 9; ++i) { kmap[i] = 0; } enum { xx, xy, xz, // 0, 1, 2 diff --git a/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp b/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp index 86b17fc4e..0b5d61791 100644 --- a/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp +++ b/opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp @@ -159,7 +159,7 @@ namespace Opm double* kr, double* dkrds) const { - ASSERT (cells != 0); + assert(cells != 0); const int np = phase_usage_.num_phases; if (dkrds) { @@ -203,7 +203,7 @@ namespace Opm double* pc, double* dpcds) const { - ASSERT (cells != 0); + assert(cells != 0); const int np = phase_usage_.num_phases; if (dpcds) { @@ -233,7 +233,7 @@ namespace Opm double* smin, double* smax) const { - ASSERT (cells != 0); + assert(cells != 0); const int np = phase_usage_.num_phases; for (int i = 0; i < n; ++i) { diff --git a/opm/core/simulator/BlackoilState.hpp b/opm/core/simulator/BlackoilState.hpp index 974deffd8..d20fc6dde 100644 --- a/opm/core/simulator/BlackoilState.hpp +++ b/opm/core/simulator/BlackoilState.hpp @@ -65,7 +65,7 @@ namespace Opm return; } const int n = cells.size(); - ASSERT(n > 0); + assert(n > 0); std::vector smin(num_phases_*n); std::vector smax(num_phases_*n); props.satRange(n, &cells[0], &smin[0], &smax[0]); diff --git a/opm/core/simulator/initState_impl.hpp b/opm/core/simulator/initState_impl.hpp index 73852c1ee..34cf08bbb 100644 --- a/opm/core/simulator/initState_impl.hpp +++ b/opm/core/simulator/initState_impl.hpp @@ -154,7 +154,7 @@ namespace Opm Density(const BlackoilPropertiesInterface& props) : props_(props) {} double operator()(const double pressure, const int phase) { - ASSERT(props_.numPhases() == 2); + assert(props_.numPhases() == 2); const double surfvol[2][2] = { { 1.0, 0.0 }, { 0.0, 1.0 } }; // We do not handle multi-region PVT/EQUIL at this point. @@ -183,7 +183,7 @@ namespace Opm const double datum_p, State& state) { - ASSERT(props.numPhases() == 2); + assert(props.numPhases() == 2); // Obtain max and min z for which we will need to compute p. const int num_cells = grid.number_of_cells; diff --git a/opm/core/tof/TofDiscGalReorder.cpp b/opm/core/tof/TofDiscGalReorder.cpp index 329d9b700..609fc7acf 100644 --- a/opm/core/tof/TofDiscGalReorder.cpp +++ b/opm/core/tof/TofDiscGalReorder.cpp @@ -651,7 +651,7 @@ namespace Opm limiter = 0.0; basis_func_->addConstant(min_upstream_tof - tof_c, tof + num_basis*cell); } - ASSERT(limiter >= 0.0); + assert(limiter >= 0.0); // Actually do the limiting (if applicable). if (limiter < 1.0) { @@ -674,7 +674,7 @@ namespace Opm // any limiting applied to its upstream cells. const std::vector& seq = ReorderSolverInterface::sequence(); const int nc = seq.size(); - ASSERT(nc == grid_.number_of_cells); + assert(nc == grid_.number_of_cells); for (int i = 0; i < nc; ++i) { const int cell = seq[i]; applyLimiter(cell, tof_coeff_); diff --git a/opm/core/tof/TofReorder.cpp b/opm/core/tof/TofReorder.cpp index c4550856d..04a169e51 100644 --- a/opm/core/tof/TofReorder.cpp +++ b/opm/core/tof/TofReorder.cpp @@ -331,7 +331,7 @@ namespace Opm // Identify the adjacent faces of the upwind cell. const int* face_nodes_beg = grid_.face_nodes + grid_.face_nodepos[face]; const int* face_nodes_end = grid_.face_nodes + grid_.face_nodepos[face + 1]; - ASSERT(face_nodes_end - face_nodes_beg == 2 || grid_.dimensions != 2); + assert(face_nodes_end - face_nodes_beg == 2 || grid_.dimensions != 2); adj_faces_.clear(); for (int hf = grid_.cell_facepos[upwind_cell]; hf < grid_.cell_facepos[upwind_cell + 1]; ++hf) { const int f = grid_.cell_faces[hf]; @@ -358,7 +358,7 @@ namespace Opm const int num_adj = adj_faces_.size(); // The assertion below only holds if the grid is edge-conformal. // No longer testing, since method no longer requires it. - // ASSERT(num_adj == face_nodes_end - face_nodes_beg); + // assert(num_adj == face_nodes_end - face_nodes_beg); const double flux_face = std::fabs(darcyflux_[face]); face_term = 0.0; cell_term_factor = 0.0; diff --git a/opm/core/transport/reorder/TransportSolverCompressibleTwophaseReorder.cpp b/opm/core/transport/reorder/TransportSolverCompressibleTwophaseReorder.cpp index aed083aba..4370a8ef5 100644 --- a/opm/core/transport/reorder/TransportSolverCompressibleTwophaseReorder.cpp +++ b/opm/core/transport/reorder/TransportSolverCompressibleTwophaseReorder.cpp @@ -415,7 +415,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]); diff --git a/opm/core/utility/miscUtilities.cpp b/opm/core/utility/miscUtilities.cpp index 172ef1016..d5c359500 100644 --- a/opm/core/utility/miscUtilities.cpp +++ b/opm/core/utility/miscUtilities.cpp @@ -273,7 +273,7 @@ namespace Opm const std::vector::size_type nc = cells.size(); const std::size_t np = props.numPhases(); - ASSERT (s.size() == nc * np); + assert(s.size() == nc * np); std::vector(nc * np, 0.0).swap(pmobc ); double* dpmobc = 0; @@ -382,7 +382,7 @@ namespace Opm << perf_rate/Opm::unit::day << " m^3/day." << std::endl; perf_rate = 0.0; } else { - ASSERT(std::fabs(comp_frac[0] + comp_frac[1] - 1.0) < 1e-6); + assert(std::fabs(comp_frac[0] + comp_frac[1] - 1.0) < 1e-6); perf_rate *= comp_frac[0]; } } @@ -555,7 +555,7 @@ namespace Opm { const int np = wells.number_of_phases; const int nw = wells.number_of_wells; - ASSERT(int(flow_rates_per_well_cell.size()) == wells.well_connpos[nw]); + assert(int(flow_rates_per_well_cell.size()) == wells.well_connpos[nw]); phase_flow_per_well.resize(nw * np); for (int wix = 0; wix < nw; ++wix) { for (int phase = 0; phase < np; ++phase) { @@ -598,7 +598,7 @@ namespace Opm const std::vector& well_perfrates) { int nw = well_bhp.size(); - ASSERT(nw == wells.number_of_wells); + assert(nw == wells.number_of_wells); int np = props.numPhases(); const int max_np = 3; if (np > max_np) { @@ -657,7 +657,7 @@ namespace Opm { // TODO: refactor, since this is almost identical to the other push(). int nw = well_bhp.size(); - ASSERT(nw == wells.number_of_wells); + assert(nw == wells.number_of_wells); int np = props.numPhases(); const int max_np = 3; if (np > max_np) { diff --git a/opm/core/utility/miscUtilitiesBlackoil.cpp b/opm/core/utility/miscUtilitiesBlackoil.cpp index fc8cdbe5c..e22dbe44f 100644 --- a/opm/core/utility/miscUtilitiesBlackoil.cpp +++ b/opm/core/utility/miscUtilitiesBlackoil.cpp @@ -200,7 +200,7 @@ namespace Opm const int nc = props.numCells(); const int np = props.numPhases(); - ASSERT (int(s.size()) == nc * np); + assert(int(s.size()) == nc * np); std::vector mu(nc*np); props.viscosity(nc, &p[0], &z[0], &cells[0], &mu[0], 0); @@ -318,7 +318,7 @@ namespace Opm << perf_rate/Opm::unit::day << " m^3/day." << std::endl; perf_rate = 0.0; } else { - ASSERT(std::fabs(comp_frac[0] + comp_frac[1] - 1.0) < 1e-6); + assert(std::fabs(comp_frac[0] + comp_frac[1] - 1.0) < 1e-6); perf_rate *= comp_frac[0]; // Water reservoir volume rate. props.matrix(1, &well_state.perfPress()[perf], comp_frac, &perf_cell, &A[0], 0); perf_rate *= A[0]; // Water surface volume rate. diff --git a/opm/core/wells/WellCollection.cpp b/opm/core/wells/WellCollection.cpp index bd06414d2..350d2ffb3 100644 --- a/opm/core/wells/WellCollection.cpp +++ b/opm/core/wells/WellCollection.cpp @@ -106,7 +106,7 @@ namespace Opm if (parent == NULL) { OPM_THROW(std::runtime_error, "Parent with name = " << parent_name << " not found."); } - ASSERT(!parent->isLeafNode()); + assert(!parent->isLeafNode()); static_cast(parent)->addChild(child_node); if (child_node->isLeafNode()) { leaf_nodes_.push_back(static_cast(child_node.get())); diff --git a/opm/core/wells/WellsGroup.cpp b/opm/core/wells/WellsGroup.cpp index bb82e7228..d65555ed3 100644 --- a/opm/core/wells/WellsGroup.cpp +++ b/opm/core/wells/WellsGroup.cpp @@ -788,7 +788,7 @@ namespace Opm return; } if (wells_->type[self_index_] != INJECTOR) { - ASSERT(target == 0.0); + assert(target == 0.0); return; } @@ -865,7 +865,7 @@ namespace Opm return; } if (wells_->type[self_index_] != PRODUCER) { - ASSERT(target == 0.0); + assert(target == 0.0); return; } // We're a producer, so we need to negate the input diff --git a/opm/core/wells/WellsManager.cpp b/opm/core/wells/WellsManager.cpp index 2c55609ef..7cea11fa3 100644 --- a/opm/core/wells/WellsManager.cpp +++ b/opm/core/wells/WellsManager.cpp @@ -406,7 +406,7 @@ namespace Opm // Set up reference depths that were defaulted. Count perfs. int num_perfs = 0; - ASSERT(grid.dimensions == 3); + assert(grid.dimensions == 3); for (int w = 0; w < num_wells; ++w) { num_perfs += wellperf_data[w].size(); if (well_data[w].reference_bhp_depth < 0.0) { @@ -493,7 +493,7 @@ namespace Opm for (int wix = 0; wix < num_wells; ++wix) { if (well_names[wix].compare(0,len, name) == 0) { //equal well_found = true; - ASSERT(well_data[wix].type == w_->type[wix]); + assert(well_data[wix].type == w_->type[wix]); if (well_data[wix].type != INJECTOR) { OPM_THROW(std::runtime_error, "Found WCONINJE entry for a non-injector well: " << well_names[wix]); } @@ -604,7 +604,7 @@ namespace Opm for (int wix = 0; wix < num_wells; ++wix) { if (well_names[wix].compare(0,len, name) == 0) { //equal well_found = true; - ASSERT(well_data[wix].type == w_->type[wix]); + assert(well_data[wix].type == w_->type[wix]); if (well_data[wix].type != PRODUCER) { OPM_THROW(std::runtime_error, "Found WCONPROD entry for a non-producer well: " << well_names[wix]); } @@ -758,13 +758,13 @@ namespace Opm if (cur_ctrl >= 0) { cur_ctrl = ~cur_ctrl; } - ASSERT(w_->ctrls[index]->current < 0); + assert(w_->ctrls[index]->current < 0); } else if (line.openshutflag_ == "OPEN") { int& cur_ctrl = w_->ctrls[index]->current; if (cur_ctrl < 0) { cur_ctrl = ~cur_ctrl; } - ASSERT(w_->ctrls[index]->current >= 0); + assert(w_->ctrls[index]->current >= 0); } else { OPM_THROW(std::runtime_error, "Unknown Open/close keyword: \"" << line.openshutflag_<< "\". Allowed values: OPEN, SHUT."); } @@ -797,7 +797,7 @@ namespace Opm std::string name = lines[i].well_; const int wix = well_names_to_index[name]; WellNode& wellnode = *well_collection_.getLeafNodes()[wix]; - ASSERT(wellnode.name() == name); + assert(wellnode.name() == name); if (well_data[wix].type == PRODUCER) { wellnode.prodSpec().guide_rate_ = lines[i].guide_rate_; if (lines[i].phase_ == "OIL") {