Revert: Removed unused SimulatorState comparison.
This reverts commit 5ce1d84ac1
.
This commit is contained in:
parent
b241fde63c
commit
9b1efd7810
@ -6,6 +6,40 @@
|
||||
|
||||
using namespace Opm;
|
||||
|
||||
bool
|
||||
SimulatorState::equals (const SimulatorState& other,
|
||||
double epsilon) const {
|
||||
bool equal = (num_phases_ == other.num_phases_);
|
||||
|
||||
// if we use &=, then all the tests will be run regardless
|
||||
equal = equal && vectorApproxEqual( pressure() , other.pressure() , epsilon);
|
||||
equal = equal && vectorApproxEqual( temperature() , other.temperature() , epsilon);
|
||||
equal = equal && vectorApproxEqual( facepressure() , other.facepressure() , epsilon);
|
||||
equal = equal && vectorApproxEqual( faceflux() , other.faceflux() , epsilon);
|
||||
equal = equal && vectorApproxEqual( saturation() , other.saturation() , epsilon);
|
||||
|
||||
return equal;
|
||||
}
|
||||
|
||||
bool
|
||||
SimulatorState::vectorApproxEqual(const std::vector<double>& v1,
|
||||
const std::vector<double>& v2,
|
||||
double epsilon) {
|
||||
if (v1.size() != v2.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < v1.size(); i++) {
|
||||
const double diff = std::abs(v1[i] - v2[i]);
|
||||
const double scale = std::abs(v1[i]) + std::abs(v2[i]);
|
||||
if (diff > epsilon * scale) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SimulatorState::init(int number_of_cells, int number_of_faces, int num_phases)
|
||||
|
@ -61,6 +61,13 @@ namespace Opm
|
||||
const std::vector<double>& faceflux () const { return faceData_[ faceFluxId_ ]; }
|
||||
const std::vector<double>& saturation () const { return cellData_[ saturationId_ ]; }
|
||||
|
||||
/**
|
||||
* Compare this state with another, to see if they are different
|
||||
* only within a small margin.
|
||||
*/
|
||||
virtual bool equals(const SimulatorState& other,
|
||||
double epsilon = 1e-8) const;
|
||||
|
||||
std::vector< std::vector<double> >& cellData() { return cellData_; }
|
||||
const std::vector< std::vector<double> >& cellData() const { return cellData_; }
|
||||
|
||||
@ -87,6 +94,19 @@ namespace Opm
|
||||
/// \brief names for the face data
|
||||
std::vector< std::string > faceDataNames_;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Check if two vectors are equal within a margin.
|
||||
*
|
||||
* @param epsilon Relative difference that is tolerated for the
|
||||
* vectors to still be considered equal.
|
||||
*
|
||||
* @return True if every element is within the margin, false if
|
||||
* there is at least one that is not.
|
||||
*/
|
||||
static bool vectorApproxEqual(const std::vector<double>& v1,
|
||||
const std::vector<double>& v2,
|
||||
double epsilon);
|
||||
};
|
||||
|
||||
} // namespace Opm
|
||||
|
Loading…
Reference in New Issue
Block a user