Skip to content

Commit

Permalink
addressing reviewing comments from PR#137
Browse files Browse the repository at this point in the history
  • Loading branch information
GitPaean committed Dec 11, 2018
1 parent c1e9ab1 commit 59a544c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
19 changes: 6 additions & 13 deletions opm/material/common/XYTabulated2DFunction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include <sstream>
#include <cassert>
#include <algorithm>
#include <iostream>

namespace Opm {

Expand Down Expand Up @@ -69,13 +68,13 @@ class XYTabulated2DFunction
{
// make sure the size is correct
if (numX() != samples_.size()) {
throw std::runtime_error("numX() is not equal with the number of rows of the sample points");
throw std::runtime_error("numX() is not equal to the number of rows of the sample points");
}

for (unsigned ix = 0; ix < numX(); ++ix) {
if (samples_[ix].size() != numY()) {
std::ostringstream oss;
oss << "the " << ix << "th row of the smaples_ has different number of data from numY() ";
oss << "the " << ix << "th row of the sample points has different number of data from numY() ";
throw std::runtime_error(oss.str());
}
}
Expand Down Expand Up @@ -227,11 +226,11 @@ class XYTabulated2DFunction
const unsigned num_pos = pos.size();
assert(num_pos >= 2);

if (y <= pos.front() || num_pos == 2)
if (y <= pos.front() || num_pos == 2) {
return 0;
else if (y >= pos.back())
return num_pos - 2;
else {
} else if (y >= pos.back()) {
return num_pos - 2;
} else {
assert(num_pos >= 3);

return --std::lower_bound(pos.begin(), pos.end(), y) - pos.begin();
Expand All @@ -247,9 +246,6 @@ class XYTabulated2DFunction
template <class Evaluation>
Evaluation xToAlpha(const Evaluation& x, unsigned xSegmentIdx) const
{
if ( xSegmentIdx == numX() -1 )
return blank(x);

Scalar x1 = xPos_[xSegmentIdx];
Scalar x2 = xPos_[xSegmentIdx + 1];
return (x - x1)/(x2 - x1);
Expand All @@ -264,9 +260,6 @@ class XYTabulated2DFunction
template <class Evaluation>
Evaluation yToBeta(const Evaluation& y, unsigned ySegmentIdx) const
{
if ( ySegmentIdx == numY() - 1)
return blank(y);

Scalar y1 = yPos_[ySegmentIdx];
Scalar y2 = yPos_[ySegmentIdx + 1];
return (y - y1)/(y2 - y1);
Expand Down
2 changes: 1 addition & 1 deletion tests/test_2dtables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ createXYTabulated2DFunction(Fn& f)
{
const Scalar xMin = -2.0;
const Scalar xMax = 3.0;
const Scalar m = 50;
const unsigned m = 50;

const Scalar yMin = -1/2.0;
const Scalar yMax = 1/3.0;
Expand Down

0 comments on commit 59a544c

Please sign in to comment.