Using template for cmp::vector_equal()

This commit is contained in:
Joakim Hove 2016-02-17 22:01:52 +01:00
parent 1661ac8f58
commit 58f355935f
3 changed files with 23 additions and 23 deletions

View File

@ -52,22 +52,22 @@ grid_equal(const struct UnstructuredGrid * grid1 , const struct UnstructuredGrid
// Floating point comparisons.
{
if (!Opm::cmp::double_ptr_equal( grid1->node_coordinates , grid2->node_coordinates , grid1->dimensions * grid1->number_of_nodes))
if (!Opm::cmp::array_equal<double>( grid1->node_coordinates , grid2->node_coordinates , static_cast<size_t>(grid1->dimensions * grid1->number_of_nodes)))
return false;
if (!Opm::cmp::double_ptr_equal( grid1->face_centroids , grid2->face_centroids , grid1->dimensions * grid1->number_of_faces))
if (!Opm::cmp::array_equal<double>( grid1->face_centroids , grid2->face_centroids , static_cast<size_t>(grid1->dimensions * grid1->number_of_faces)))
return false;
if (!Opm::cmp::double_ptr_equal( grid1->face_areas , grid2->face_areas , grid1->number_of_faces))
if (!Opm::cmp::array_equal<double>( grid1->face_areas , grid2->face_areas , static_cast<size_t>(grid1->number_of_faces)))
return false;
if (!Opm::cmp::double_ptr_equal( grid1->face_normals , grid2->face_normals , grid1->dimensions * grid1->number_of_faces))
if (!Opm::cmp::array_equal<double>( grid1->face_normals , grid2->face_normals , static_cast<size_t>(grid1->dimensions * grid1->number_of_faces)))
return false;
if (!Opm::cmp::double_ptr_equal( grid1->cell_centroids , grid2->cell_centroids , grid1->dimensions * grid1->number_of_cells))
if (!Opm::cmp::array_equal<double>( grid1->cell_centroids , grid2->cell_centroids , static_cast<size_t>(grid1->dimensions * grid1->number_of_cells)))
return false;
if (!Opm::cmp::double_ptr_equal( grid1->cell_volumes , grid2->cell_volumes , grid1->number_of_cells))
if (!Opm::cmp::array_equal<double>( grid1->cell_volumes , grid2->cell_volumes , static_cast<size_t>(grid1->number_of_cells)))
return false;
}
return true;

View File

@ -40,19 +40,19 @@ BlackoilState::equals(const SimulatorState& other,
const BlackoilState* that = dynamic_cast <const BlackoilState*> (&other);
bool equal = that != 0;
equal = equal && SimulatorState::equals (other, epsilon);
equal = equal && cmp::double_vector_equal(this->surfacevol(),
that->surfacevol(),
cmp::default_abs_epsilon,
epsilon);
equal = equal && cmp::vector_equal(this->surfacevol(),
that->surfacevol(),
cmp::default_abs_epsilon,
epsilon);
equal = equal && cmp::double_vector_equal(this->gasoilratio(),
that->gasoilratio(),
cmp::default_abs_epsilon,
epsilon);
equal = equal && cmp::vector_equal(this->gasoilratio(),
that->gasoilratio(),
cmp::default_abs_epsilon,
epsilon);
equal = equal && cmp::double_vector_equal(this->rv(),
that->rv(),
cmp::default_abs_epsilon,
epsilon);
equal = equal && cmp::vector_equal(this->rv(),
that->rv(),
cmp::default_abs_epsilon,
epsilon);
return equal;
}

View File

@ -13,11 +13,11 @@ SimulatorState::equals (const SimulatorState& other,
bool equal = (num_phases_ == other.num_phases_);
// if we use &=, then all the tests will be run regardless
equal = equal && cmp::double_vector_equal( pressure() , other.pressure() , cmp::default_abs_epsilon , epsilon);
equal = equal && cmp::double_vector_equal( temperature() , other.temperature() , cmp::default_abs_epsilon , epsilon);
equal = equal && cmp::double_vector_equal( facepressure() , other.facepressure() , cmp::default_abs_epsilon , epsilon);
equal = equal && cmp::double_vector_equal( faceflux() , other.faceflux() , cmp::default_abs_epsilon , epsilon);
equal = equal && cmp::double_vector_equal( saturation() , other.saturation() , cmp::default_abs_epsilon , epsilon);
equal = equal && cmp::vector_equal( pressure() , other.pressure() , cmp::default_abs_epsilon , epsilon);
equal = equal && cmp::vector_equal( temperature() , other.temperature() , cmp::default_abs_epsilon , epsilon);
equal = equal && cmp::vector_equal( facepressure() , other.facepressure() , cmp::default_abs_epsilon , epsilon);
equal = equal && cmp::vector_equal( faceflux() , other.faceflux() , cmp::default_abs_epsilon , epsilon);
equal = equal && cmp::vector_equal( saturation() , other.saturation() , cmp::default_abs_epsilon , epsilon);
return equal;
}