Add a simple test fluid conforming to SinglePoint* interface.
Accompanied by demonstration programme. Not integrated into build system.
This commit is contained in:
92
src/SimpleFluid2p.hpp
Normal file
92
src/SimpleFluid2p.hpp
Normal file
@@ -0,0 +1,92 @@
|
||||
/*===========================================================================
|
||||
//
|
||||
// File: SimpleFluid2p.hpp
|
||||
//
|
||||
// Created: 2011-09-30 11:38:28+0200
|
||||
//
|
||||
// Authors: Ingeborg S. Ligaarden <Ingeborg.Ligaarden@sintef.no>
|
||||
// Jostein R. Natvig <Jostein.R.Natvig@sintef.no>
|
||||
// Halvor M. Nilsen <HalvorMoll.Nilsen@sintef.no>
|
||||
// Atgeirr F. Rasmussen <atgeirr@sintef.no>
|
||||
// Bård Skaflestad <Bard.Skaflestad@sintef.no>
|
||||
//
|
||||
//==========================================================================*/
|
||||
|
||||
|
||||
/*
|
||||
Copyright 2011 SINTEF ICT, Applied Mathematics.
|
||||
Copyright 2011 Statoil ASA.
|
||||
|
||||
This file is part of the Open Porous Media Project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef OPM_SIMPLEFLUID2P_HPP_HEADER
|
||||
#define OPM_SIMPLEFLUID2P_HPP_HEADER
|
||||
|
||||
#include <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)
|
||||
: mu_(mu), rho_(rho)
|
||||
{
|
||||
}
|
||||
|
||||
double density(int p) const { return rho_[p]; }
|
||||
|
||||
template <class Sat ,
|
||||
class Mob ,
|
||||
class DMob>
|
||||
void
|
||||
mobility(int c, const Sat& s, Mob& mob, DMob& dmob) const {
|
||||
(void) c; // Unused
|
||||
|
||||
const double s1 = s[0];
|
||||
const double s2 = 1 - s1;
|
||||
|
||||
if (n == 1) {
|
||||
mob [ 0] = s1; mob [ 1] = s2;
|
||||
|
||||
dmob[0*2 + 0] = 1 ; dmob[1*2 + 1] = 1 ;
|
||||
} else if (n == 2) {
|
||||
mob [ 0] = s1 * s1; mob [ 1] = s2 * s2;
|
||||
|
||||
dmob[0*2 + 0] = 2 * s1 ; dmob[1*2 + 1] = 2 * s2 ;
|
||||
} else {
|
||||
mob [ 0] = pow(s1, double(n));
|
||||
mob [ 1] = pow(s2, double(n));
|
||||
|
||||
dmob[0*2 + 0] = double(n) * pow(s1, double(n) - 1);
|
||||
dmob[1*2 + 1] = double(n) * pow(s2, double(n) - 1);
|
||||
}
|
||||
|
||||
mob[0] /= mu_[0]; dmob[0*2 + 0] /= mu_[0];
|
||||
mob[1] /= mu_[1]; dmob[1*2 + 1] /= mu_[1];
|
||||
|
||||
dmob[0*2 + 1] = dmob[1*2 + 0] = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
std::array<double, 2> mu_ ;
|
||||
std::array<double, 2> rho_;
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* OPM_SIMPLEFLUID2P_HPP_HEADER */
|
||||
62
src/test_sf2p.cpp
Normal file
62
src/test_sf2p.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
|
||||
#include <SimpleFluid2p.hpp>
|
||||
|
||||
template <class Ostream, typename T, size_t n>
|
||||
Ostream&
|
||||
operator<<(Ostream& os, const std::array<T, n>& a)
|
||||
{
|
||||
os << "[ ";
|
||||
std::copy(a.begin(), a.end(), std::ostream_iterator<T>(os, " "));
|
||||
os << "]";
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
template <int n = 2>
|
||||
void
|
||||
test_simplefluid2p()
|
||||
{
|
||||
std::array<double, 2> mu = { {1.0, 1.0} };
|
||||
std::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 }};
|
||||
|
||||
std::array<double, 2> mob;
|
||||
std::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 }};
|
||||
fluid.mobility(0, sm, mob, dmob);
|
||||
|
||||
std::cerr << "s = " << sm << ", m = " << mob << ", dm = " << dmob << '\n';
|
||||
|
||||
std::array<double, 2> sr = {{ 0.0, 1.0 }};
|
||||
fluid.mobility(0, sr, mob, dmob);
|
||||
|
||||
std::cerr << "s = " << sr << ", m = " << mob << ", dm = " << dmob << '\n';
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cerr << "n = 1\n";
|
||||
test_simplefluid2p<1>();
|
||||
|
||||
std::cerr << "n = 2\n";
|
||||
test_simplefluid2p<> ();
|
||||
|
||||
std::cerr << "n = 3\n";
|
||||
test_simplefluid2p<3>();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user