Replaces std::array with std::tr1::array for improved compatibility (not requiring c++11).

This commit is contained in:
Atgeirr Flø Rasmussen
2011-12-12 10:29:40 +01:00
parent 108fcfc11b
commit 0e84c3de31
3 changed files with 20 additions and 19 deletions

View File

@@ -38,7 +38,7 @@
#include <cstddef>
#include <algorithm>
#include <array>
#include <tr1/array>
#include <functional>
#include <iostream>
#include <iterator>
@@ -273,8 +273,8 @@ main()
using Opm::ImplicitTransportLinAlgSupport::CSRMatrixUmfpackSolver;
CSRMatrixUmfpackSolver linsolve;
std::array<double, 2> mu = {{ 1.0, 1.0 }};
std::array<double, 2> rho = {{ 0.0, 0.0 }};
std::tr1::array<double, 2> mu = {{ 1.0, 1.0 }};
std::tr1::array<double, 2> rho = {{ 0.0, 0.0 }};
TwophaseFluid fluid(mu, rho);
std::vector<double> porevol;

View File

@@ -36,15 +36,15 @@
#ifndef OPM_SIMPLEFLUID2P_HPP_HEADER
#define OPM_SIMPLEFLUID2P_HPP_HEADER
#include <array>
#include <tr1/array>
#include <cmath>
namespace Opm {
template <int n = 2>
class SimpleFluid2p {
public:
SimpleFluid2p(const std::array<double, 2>& mu,
const std::array<double, 2>& rho)
SimpleFluid2p(const std::tr1::array<double, 2>& mu,
const std::tr1::array<double, 2>& rho)
: mu_(mu), rho_(rho)
{
}
@@ -99,8 +99,8 @@ namespace Opm {
double s_max(int c) const { (void) c; return 1.0; }
private:
std::array<double, 2> mu_ ;
std::array<double, 2> rho_;
std::tr1::array<double, 2> mu_ ;
std::tr1::array<double, 2> rho_;
};
}

View File

@@ -1,5 +1,5 @@
#include <algorithm>
#include <array>
#include <tr1/array>
#include <iostream>
#include <iterator>
@@ -7,7 +7,7 @@
template <class Ostream, typename T, size_t n>
Ostream&
operator<<(Ostream& os, const std::array<T, n>& a)
operator<<(Ostream& os, const std::tr1::array<T, n>& a)
{
os << "[ ";
std::copy(a.begin(), a.end(), std::ostream_iterator<T>(os, " "));
@@ -16,32 +16,33 @@ operator<<(Ostream& os, const std::array<T, n>& a)
return os;
}
template <int n = 2>
template <int n>
void
test_simplefluid2p()
{
std::array<double, 2> mu = { {1.0, 1.0} };
std::array<double, 2> rho = { {0.0, 0.0} };
using std::tr1::array;
array<double, 2> mu = { {1.0, 1.0} };
array<double, 2> rho = { {0.0, 0.0} };
Opm::SimpleFluid2p<n> fluid(mu, rho);
std::cerr << "\\rho = [ " << fluid.density(0)
<< ", " << fluid.density(1) << " ]\n";
std::array<double, 2> sl = {{ 1.0, 0.0 }};
array<double, 2> sl = {{ 1.0, 0.0 }};
std::array<double, 2> mob;
std::array<double, 2 * 2> dmob;
array<double, 2> mob;
array<double, 2 * 2> dmob;
fluid.mobility(0, sl, mob, dmob);
std::cerr << "s = " << sl << ", m = " << mob << ", dm = " << dmob << '\n';
std::array<double, 2> sm = {{ 0.5, 0.5 }};
array<double, 2> sm = {{ 0.5, 0.5 }};
fluid.mobility(0, sm, mob, dmob);
std::cerr << "s = " << sm << ", m = " << mob << ", dm = " << dmob << '\n';
std::array<double, 2> sr = {{ 0.0, 1.0 }};
array<double, 2> sr = {{ 0.0, 1.0 }};
fluid.mobility(0, sr, mob, dmob);
std::cerr << "s = " << sr << ", m = " << mob << ", dm = " << dmob << '\n';
@@ -53,7 +54,7 @@ int main()
test_simplefluid2p<1>();
std::cerr << "n = 2\n";
test_simplefluid2p<> ();
test_simplefluid2p<2> ();
std::cerr << "n = 3\n";
test_simplefluid2p<3>();