2011-10-05 20:06:03 +02:00
|
|
|
/*===========================================================================
|
|
|
|
|
//
|
|
|
|
|
// File: spu_2p.cpp
|
|
|
|
|
//
|
|
|
|
|
// Created: 2011-10-05 10:29:01+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/>.
|
|
|
|
|
*/
|
2011-12-05 19:22:20 +01:00
|
|
|
#include "config.h"
|
2011-10-05 20:06:03 +02:00
|
|
|
|
|
|
|
|
#include <cassert>
|
2011-10-13 19:38:33 +02:00
|
|
|
#include <cstddef>
|
2011-10-05 20:06:03 +02:00
|
|
|
|
|
|
|
|
#include <algorithm>
|
2011-12-12 10:29:40 +01:00
|
|
|
#include <tr1/array>
|
2011-10-05 20:06:03 +02:00
|
|
|
#include <functional>
|
|
|
|
|
#include <iostream>
|
2012-01-19 14:12:53 +01:00
|
|
|
#include <iomanip>
|
2012-01-19 16:48:27 +01:00
|
|
|
#include <fstream>
|
2011-10-05 20:06:03 +02:00
|
|
|
#include <iterator>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2011-12-12 11:28:09 +01:00
|
|
|
#include <opm/core/linalg/sparse_sys.h>
|
2011-10-05 20:06:03 +02:00
|
|
|
|
2011-12-12 11:28:09 +01:00
|
|
|
#include <opm/core/pressure/tpfa/ifs_tpfa.h>
|
|
|
|
|
#include <opm/core/pressure/tpfa/trans_tpfa.h>
|
2011-10-05 20:06:03 +02:00
|
|
|
|
2011-12-12 11:28:09 +01:00
|
|
|
#include <opm/core/utility/cart_grid.h>
|
2012-01-19 16:48:27 +01:00
|
|
|
#include <opm/core/utility/ErrorMacros.hpp>
|
2012-01-19 14:12:53 +01:00
|
|
|
#include <opm/core/utility/Units.hpp>
|
2012-01-19 13:58:25 +01:00
|
|
|
#include <opm/core/utility/parameters/ParameterGroup.hpp>
|
2011-10-05 20:06:03 +02:00
|
|
|
|
2011-12-12 11:28:09 +01:00
|
|
|
#include <opm/core/fluid/SimpleFluid2p.hpp>
|
2011-10-05 20:06:03 +02:00
|
|
|
|
2011-12-12 11:28:09 +01:00
|
|
|
#include <opm/core/transport/transport_source.h>
|
|
|
|
|
#include <opm/core/transport/CSRMatrixUmfpackSolver.hpp>
|
|
|
|
|
#include <opm/core/transport/NormSupport.hpp>
|
|
|
|
|
#include <opm/core/transport/ImplicitAssembly.hpp>
|
|
|
|
|
#include <opm/core/transport/ImplicitTransport.hpp>
|
|
|
|
|
#include <opm/core/transport/JacobianSystem.hpp>
|
|
|
|
|
#include <opm/core/transport/CSRMatrixBlockAssembler.hpp>
|
|
|
|
|
#include <opm/core/transport/SinglePointUpwindTwoPhase.hpp>
|
2011-10-13 19:38:33 +02:00
|
|
|
|
2012-01-23 12:43:37 +01:00
|
|
|
#include <opm/core/transport/reorder/twophasetransport.h>
|
2011-10-05 20:06:03 +02:00
|
|
|
|
|
|
|
|
class Rock {
|
|
|
|
|
public:
|
|
|
|
|
Rock(::std::size_t nc, ::std::size_t dim)
|
|
|
|
|
: dim_ (dim ),
|
|
|
|
|
perm_(nc * dim * dim),
|
|
|
|
|
poro_(nc ) {}
|
|
|
|
|
|
|
|
|
|
const ::std::vector<double>& perm() const { return perm_; }
|
|
|
|
|
const ::std::vector<double>& poro() const { return poro_; }
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
perm_homogeneous(double k) {
|
|
|
|
|
setVector(0.0, perm_);
|
|
|
|
|
|
|
|
|
|
const ::std::size_t d2 = dim_ * dim_;
|
|
|
|
|
|
|
|
|
|
for (::std::size_t c = 0, nc = poro_.size(); c < nc; ++c) {
|
|
|
|
|
for (::std::size_t i = 0; i < dim_; ++i) {
|
|
|
|
|
perm_[c*d2 + i*(dim_ + 1)] = k;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
poro_homogeneous(double phi) {
|
|
|
|
|
setVector(phi, poro_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void
|
|
|
|
|
setVector(double x, ::std::vector<double>& v) {
|
|
|
|
|
::std::fill(v.begin(), v.end(), x);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
::std::size_t dim_ ;
|
|
|
|
|
::std::vector<double> perm_;
|
|
|
|
|
::std::vector<double> poro_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ReservoirState {
|
|
|
|
|
public:
|
2012-01-19 16:48:27 +01:00
|
|
|
ReservoirState(const UnstructuredGrid* g, const int num_phases = 2)
|
2011-10-05 20:06:03 +02:00
|
|
|
: press_ (g->number_of_cells),
|
|
|
|
|
fpress_(g->number_of_faces),
|
|
|
|
|
flux_ (g->number_of_faces),
|
2012-01-19 16:48:27 +01:00
|
|
|
sat_ (num_phases * g->number_of_cells)
|
2011-10-05 20:06:03 +02:00
|
|
|
{}
|
|
|
|
|
|
2012-01-19 16:48:27 +01:00
|
|
|
int numPhases() const { return sat_.size()/press_.size(); }
|
|
|
|
|
|
2011-10-05 20:06:03 +02:00
|
|
|
::std::vector<double>& pressure () { return press_ ; }
|
|
|
|
|
::std::vector<double>& facepressure() { return fpress_; }
|
|
|
|
|
::std::vector<double>& faceflux () { return flux_ ; }
|
|
|
|
|
::std::vector<double>& saturation () { return sat_ ; }
|
|
|
|
|
|
2012-01-19 16:48:27 +01:00
|
|
|
const ::std::vector<double>& pressure () const { return press_ ; }
|
|
|
|
|
const ::std::vector<double>& facepressure() const { return fpress_; }
|
|
|
|
|
const ::std::vector<double>& faceflux () const { return flux_ ; }
|
|
|
|
|
const ::std::vector<double>& saturation () const { return sat_ ; }
|
2011-10-05 20:06:03 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
::std::vector<double> press_ ;
|
|
|
|
|
::std::vector<double> fpress_;
|
|
|
|
|
::std::vector<double> flux_ ;
|
|
|
|
|
::std::vector<double> sat_ ;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class PressureSolver {
|
|
|
|
|
public:
|
2012-01-19 16:48:27 +01:00
|
|
|
PressureSolver(UnstructuredGrid* g, const Rock& rock)
|
2011-10-05 20:06:03 +02:00
|
|
|
: htrans_(g->cell_facepos[ g->number_of_cells ]),
|
|
|
|
|
trans_ (g->number_of_faces),
|
|
|
|
|
gpress_(g->cell_facepos[ g->number_of_cells ])
|
|
|
|
|
{
|
|
|
|
|
tpfa_htrans_compute(g, &rock.perm()[0], &htrans_[0]);
|
|
|
|
|
|
|
|
|
|
h_ = ifs_tpfa_construct(g);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~PressureSolver() {
|
|
|
|
|
ifs_tpfa_destroy(h_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class State>
|
|
|
|
|
void
|
2012-01-23 12:43:37 +01:00
|
|
|
solve(UnstructuredGrid* g ,
|
2011-10-05 20:06:03 +02:00
|
|
|
const ::std::vector<double>& totmob,
|
|
|
|
|
const ::std::vector<double>& src ,
|
|
|
|
|
State& state ) {
|
|
|
|
|
|
|
|
|
|
tpfa_eff_trans_compute(g, &totmob[0], &htrans_[0], &trans_[0]);
|
|
|
|
|
|
|
|
|
|
// No gravity
|
|
|
|
|
::std::fill(gpress_.begin(), gpress_.end(), double(0.0));
|
|
|
|
|
|
|
|
|
|
ifs_tpfa_assemble(g, &trans_[0], &src[0], &gpress_[0], h_);
|
|
|
|
|
|
|
|
|
|
using Opm::ImplicitTransportLinAlgSupport::CSRMatrixUmfpackSolver;
|
|
|
|
|
|
|
|
|
|
CSRMatrixUmfpackSolver linsolve;
|
|
|
|
|
linsolve.solve(h_->A, h_->b, h_->x);
|
|
|
|
|
|
|
|
|
|
ifs_tpfa_press_flux(g, &trans_[0], h_,
|
|
|
|
|
&state.pressure()[0],
|
|
|
|
|
&state.faceflux()[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
::std::vector<double> htrans_;
|
|
|
|
|
::std::vector<double> trans_ ;
|
|
|
|
|
::std::vector<double> gpress_;
|
|
|
|
|
|
|
|
|
|
struct ifs_tpfa_data* h_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2012-01-19 23:51:09 +01:00
|
|
|
typedef Opm::SimpleFluid2p<2> TwophaseFluid;
|
2011-10-05 20:06:03 +02:00
|
|
|
typedef Opm::SinglePointUpwindTwoPhase<TwophaseFluid> TransportModel;
|
|
|
|
|
|
|
|
|
|
using namespace Opm::ImplicitTransportDefault;
|
|
|
|
|
|
|
|
|
|
typedef NewtonVectorCollection< ::std::vector<double> > NVecColl;
|
|
|
|
|
typedef JacobianSystem < struct CSRMatrix, NVecColl > JacSys;
|
|
|
|
|
|
|
|
|
|
template <class Vector>
|
|
|
|
|
class MaxNorm {
|
|
|
|
|
public:
|
|
|
|
|
static double
|
|
|
|
|
norm(const Vector& v) {
|
|
|
|
|
return AccumulationNorm <Vector, MaxAbs>::norm(v);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef Opm::ImplicitTransport<TransportModel,
|
2011-10-06 17:25:13 +02:00
|
|
|
JacSys ,
|
|
|
|
|
MaxNorm ,
|
|
|
|
|
VectorNegater ,
|
|
|
|
|
VectorZero ,
|
2011-11-25 19:17:17 +01:00
|
|
|
MatrixZero ,
|
|
|
|
|
VectorAssign > TransportSolver;
|
2011-10-05 20:06:03 +02:00
|
|
|
|
2011-12-08 16:41:27 +01:00
|
|
|
static void
|
2012-01-19 16:48:27 +01:00
|
|
|
compute_porevolume(const UnstructuredGrid* g,
|
2011-10-05 20:06:03 +02:00
|
|
|
const Rock& rock,
|
|
|
|
|
std::vector<double>& porevol)
|
|
|
|
|
{
|
|
|
|
|
const ::std::vector<double>& poro = rock.poro();
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
assert (poro.size() == static_cast<::std::size_t>(g->number_of_cells));
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
porevol.resize(rock.poro().size());
|
|
|
|
|
|
|
|
|
|
::std::transform(poro.begin(), poro.end(),
|
|
|
|
|
g->cell_volumes,
|
|
|
|
|
porevol.begin(),
|
|
|
|
|
::std::multiplies<double>());
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-19 13:58:25 +01:00
|
|
|
|
|
|
|
|
template <class State>
|
2012-01-19 16:48:27 +01:00
|
|
|
void outputState(const std::tr1::array<int, 3>& grid_dims,
|
|
|
|
|
const std::tr1::array<double, 3>& cell_size,
|
|
|
|
|
const State& state,
|
|
|
|
|
const int step)
|
|
|
|
|
{
|
|
|
|
|
std::ostringstream vtkfilename;
|
|
|
|
|
vtkfilename << "output-" << std::setw(3) << std::setfill('0') << step << ".vtk";
|
|
|
|
|
std::ofstream vtkfile(vtkfilename.str().c_str());
|
|
|
|
|
if (!vtkfile) {
|
|
|
|
|
THROW("Failed to open " << vtkfilename.str());
|
|
|
|
|
}
|
|
|
|
|
writeVtkDataAllCartesian(grid_dims, cell_size, state, vtkfile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <class State>
|
|
|
|
|
void writeVtkDataAllCartesian(const std::tr1::array<int, 3>& dims,
|
|
|
|
|
const std::tr1::array<double, 3>& cell_size,
|
|
|
|
|
const State& state,
|
|
|
|
|
std::ostream& vtk_file)
|
2012-01-19 13:58:25 +01:00
|
|
|
{
|
2012-01-19 16:48:27 +01:00
|
|
|
// Dimension is hardcoded in the prototype and the next two lines,
|
|
|
|
|
// but the rest is flexible (allows dimension == 2 or 3).
|
|
|
|
|
int dimension = 3;
|
|
|
|
|
int num_cells = dims[0]*dims[1]*dims[2];
|
|
|
|
|
|
|
|
|
|
ASSERT(dimension == 2 || dimension == 3);
|
|
|
|
|
ASSERT(num_cells = dims[0]*dims[1]* (dimension == 2 ? 1 : dims[2]));
|
|
|
|
|
|
|
|
|
|
vtk_file << "# vtk DataFile Version 2.0\n";
|
|
|
|
|
vtk_file << "Structured Grid\n \n";
|
|
|
|
|
vtk_file << "ASCII \n";
|
|
|
|
|
vtk_file << "DATASET STRUCTURED_POINTS\n";
|
|
|
|
|
|
|
|
|
|
vtk_file << "DIMENSIONS "
|
|
|
|
|
<< dims[0] + 1 << " "
|
|
|
|
|
<< dims[1] + 1 << " ";
|
|
|
|
|
if (dimension == 3) {
|
|
|
|
|
vtk_file << dims[2] + 1;
|
|
|
|
|
} else {
|
|
|
|
|
vtk_file << 1;
|
|
|
|
|
}
|
|
|
|
|
vtk_file << "\n";
|
|
|
|
|
|
|
|
|
|
vtk_file << "ORIGIN " << 0.0 << " " << 0.0 << " " << 0.0 << "\n";
|
|
|
|
|
|
|
|
|
|
vtk_file << "SPACING " << cell_size[0] << " " << cell_size[1];
|
|
|
|
|
if (dimension == 3) {
|
|
|
|
|
vtk_file << " " << cell_size[2];
|
|
|
|
|
} else {
|
|
|
|
|
vtk_file << " " << 0.0;
|
|
|
|
|
}
|
|
|
|
|
vtk_file << "\n";
|
|
|
|
|
|
|
|
|
|
vtk_file << "CELL_DATA " << num_cells << '\n';
|
|
|
|
|
vtk_file << "SCALARS pressure float" << '\n';
|
|
|
|
|
vtk_file << "LOOKUP_TABLE pressure_table " << '\n';
|
|
|
|
|
for (int i = 0; i < num_cells; ++i) {
|
|
|
|
|
vtk_file << state.pressure()[i] << '\n';
|
|
|
|
|
}
|
2012-01-19 13:58:25 +01:00
|
|
|
|
2012-01-19 16:48:27 +01:00
|
|
|
ASSERT(state.numPhases() == 2);
|
|
|
|
|
vtk_file << "SCALARS saturation float" << '\n';
|
|
|
|
|
vtk_file << "LOOKUP_TABLE saturation_table " << '\n';
|
|
|
|
|
for (int i = 0; i < num_cells; ++i) {
|
|
|
|
|
double s = state.saturation()[2*i];
|
|
|
|
|
if (s > 1e-10) {
|
|
|
|
|
vtk_file << s << '\n';
|
|
|
|
|
} else {
|
|
|
|
|
vtk_file << 0.0 << '\n';
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-01-19 13:58:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-01-23 12:43:37 +01:00
|
|
|
static void toWaterSat(const std::vector<double>& sboth, std::vector<double>& sw)
|
|
|
|
|
{
|
|
|
|
|
int num = sboth.size()/2;
|
|
|
|
|
sw.resize(num);
|
|
|
|
|
for (int i = 0; i < num; ++i) {
|
|
|
|
|
sw[i] = sboth[2*i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void toBothSat(const std::vector<double>& sw, std::vector<double>& sboth)
|
|
|
|
|
{
|
|
|
|
|
int num = sw.size();
|
|
|
|
|
sboth.resize(2*num);
|
|
|
|
|
for (int i = 0; i < num; ++i) {
|
|
|
|
|
sboth[2*i] = sw[i];
|
|
|
|
|
sboth[2*i + 1] = 1.0 - sw[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-01-19 13:58:25 +01:00
|
|
|
// ----------------- Main program -----------------
|
2011-10-05 20:06:03 +02:00
|
|
|
int
|
2012-01-19 13:58:25 +01:00
|
|
|
main(int argc, char** argv)
|
2011-10-05 20:06:03 +02:00
|
|
|
{
|
2012-01-19 14:12:53 +01:00
|
|
|
Opm::parameter::ParameterGroup param(argc, argv, false);
|
2012-01-19 16:48:27 +01:00
|
|
|
const int nx = param.getDefault("nx", 100);
|
|
|
|
|
const int ny = param.getDefault("ny", 100);
|
|
|
|
|
const int nz = param.getDefault("nz", 1);
|
2012-01-19 13:58:25 +01:00
|
|
|
const int num_psteps = param.getDefault("num_psteps", 1);
|
2012-01-19 23:51:09 +01:00
|
|
|
const double stepsize_days = param.getDefault("stepsize_days", 1.0);
|
|
|
|
|
const double stepsize = Opm::unit::convert::from(stepsize_days, Opm::unit::day);
|
|
|
|
|
const bool guess_old_solution = param.getDefault("guess_old_solution", false);
|
2012-01-23 12:43:37 +01:00
|
|
|
const bool use_reorder = param.getDefault("use_reorder", false);
|
2012-01-20 15:51:29 +01:00
|
|
|
const bool output = param.getDefault("output", true);
|
2012-01-19 16:48:27 +01:00
|
|
|
|
2012-01-23 13:06:25 +01:00
|
|
|
// Grid init.
|
2012-01-19 16:48:27 +01:00
|
|
|
std::tr1::array<int, 3> grid_dims = {{ nx, ny, nz }};
|
|
|
|
|
std::tr1::array<double, 3> cell_size = {{ 1.0, 1.0, 1.0 }};
|
|
|
|
|
UnstructuredGrid* grid = create_cart_grid(nx, ny, nz);
|
2012-01-23 13:06:25 +01:00
|
|
|
|
|
|
|
|
// Rock init.
|
2011-10-05 20:06:03 +02:00
|
|
|
Rock rock(grid->number_of_cells, grid->dimensions);
|
|
|
|
|
rock.perm_homogeneous(1);
|
|
|
|
|
rock.poro_homogeneous(1);
|
2012-01-23 13:06:25 +01:00
|
|
|
std::vector<double> porevol;
|
|
|
|
|
compute_porevolume(grid, rock, porevol);
|
|
|
|
|
|
|
|
|
|
// Fluid init.
|
|
|
|
|
std::tr1::array<double, 2> mu = {{ 1.0, 1.0 }};
|
|
|
|
|
std::tr1::array<double, 2> rho = {{ 0.0, 0.0 }};
|
|
|
|
|
TwophaseFluid fluid(mu, rho);
|
2011-10-06 17:25:13 +02:00
|
|
|
|
2012-01-23 13:06:25 +01:00
|
|
|
// Solvers init.
|
2011-10-05 20:06:03 +02:00
|
|
|
PressureSolver psolver(grid, rock);
|
2012-01-23 13:06:25 +01:00
|
|
|
TransportModel model (fluid, *grid, porevol, 0, guess_old_solution);
|
|
|
|
|
TransportSolver tsolver(model);
|
2011-10-05 20:06:03 +02:00
|
|
|
|
2012-01-23 13:06:25 +01:00
|
|
|
// State-related and source-related variables init.
|
2011-10-05 20:06:03 +02:00
|
|
|
std::vector<double> totmob(grid->number_of_cells, 1.0);
|
|
|
|
|
std::vector<double> src (grid->number_of_cells, 0.0);
|
|
|
|
|
src[0] = 1.0;
|
|
|
|
|
src[grid->number_of_cells - 1] = -1.0;
|
2012-01-19 16:48:27 +01:00
|
|
|
ReservoirState state(grid);
|
2012-01-23 13:06:25 +01:00
|
|
|
// We need a separate reorder_sat, because the reorder
|
2012-01-23 12:43:37 +01:00
|
|
|
// code expects a scalar sw, not both sw and so.
|
|
|
|
|
std::vector<double> reorder_sat(grid->number_of_cells);
|
2011-10-05 20:06:03 +02:00
|
|
|
TransportSource* tsrc = create_transport_source(2, 2);
|
|
|
|
|
double ssrc[] = { 1.0, 0.0 };
|
|
|
|
|
double ssink[] = { 0.0, 1.0 };
|
|
|
|
|
double zdummy[] = { 0.0, 0.0 };
|
|
|
|
|
append_transport_source(0, 2, 0, src[0], ssrc, zdummy, tsrc);
|
|
|
|
|
append_transport_source(grid->number_of_cells - 1, 2, 0,
|
2012-01-19 13:58:25 +01:00
|
|
|
src.back(), ssink, zdummy, tsrc);
|
2012-01-23 12:43:37 +01:00
|
|
|
std::vector<double> reorder_src = src;
|
2011-10-05 20:06:03 +02:00
|
|
|
|
2012-01-23 13:06:25 +01:00
|
|
|
// Control init.
|
2012-01-19 13:58:25 +01:00
|
|
|
Opm::ImplicitTransportDetails::NRReport rpt;
|
|
|
|
|
Opm::ImplicitTransportDetails::NRControl ctrl;
|
2012-01-19 14:12:53 +01:00
|
|
|
double current_time = 0.0;
|
|
|
|
|
double total_time = stepsize*num_psteps;
|
2012-01-19 23:51:09 +01:00
|
|
|
ctrl.max_it = param.getDefault("max_it", 20);
|
|
|
|
|
ctrl.verbosity = param.getDefault("verbosity", 0);
|
|
|
|
|
ctrl.max_it_ls = param.getDefault("max_it_ls", 5);
|
2011-10-05 20:06:03 +02:00
|
|
|
|
2012-01-23 13:06:25 +01:00
|
|
|
// Linear solver init.
|
2012-01-19 13:58:25 +01:00
|
|
|
using Opm::ImplicitTransportLinAlgSupport::CSRMatrixUmfpackSolver;
|
|
|
|
|
CSRMatrixUmfpackSolver linsolve;
|
|
|
|
|
|
2012-01-23 13:06:25 +01:00
|
|
|
// Main simulation loop.
|
2012-01-19 13:58:25 +01:00
|
|
|
for (int pstep = 0; pstep < num_psteps; ++pstep) {
|
2012-01-19 14:12:53 +01:00
|
|
|
std::cout << "\n\n================ Simulation step number " << pstep
|
2012-01-19 13:58:25 +01:00
|
|
|
<< " ==============="
|
2012-01-19 14:12:53 +01:00
|
|
|
<< "\n Current time (days) " << Opm::unit::convert::to(current_time, Opm::unit::day)
|
|
|
|
|
<< "\n Current stepsize (days) " << Opm::unit::convert::to(stepsize, Opm::unit::day)
|
|
|
|
|
<< "\n Total time (days) " << Opm::unit::convert::to(total_time, Opm::unit::day)
|
2012-01-19 13:58:25 +01:00
|
|
|
<< "\n" << std::endl;
|
|
|
|
|
|
2012-01-20 15:51:29 +01:00
|
|
|
if (output) {
|
|
|
|
|
outputState(grid_dims, cell_size, state, pstep);
|
|
|
|
|
}
|
2012-01-19 14:24:39 +01:00
|
|
|
|
2012-01-19 13:58:25 +01:00
|
|
|
psolver.solve(grid, totmob, src, state);
|
2012-01-19 14:24:39 +01:00
|
|
|
|
2012-01-23 12:43:37 +01:00
|
|
|
if (use_reorder) {
|
|
|
|
|
toWaterSat(state.saturation(), reorder_sat);
|
|
|
|
|
// We must treat reorder_src here,
|
|
|
|
|
// if we are to handle anything but simple water
|
|
|
|
|
// injection, since it is expected to be
|
|
|
|
|
// equal to total outflow (if negative)
|
|
|
|
|
// and water inflow (if positive).
|
|
|
|
|
// Also, for anything but noflow boundaries,
|
|
|
|
|
// boundary flows must be accumulated into
|
|
|
|
|
// source term following the same convention.
|
|
|
|
|
twophasetransport(&porevol[0],
|
|
|
|
|
&reorder_src[0],
|
|
|
|
|
stepsize,
|
|
|
|
|
grid,
|
|
|
|
|
&state.faceflux()[0],
|
|
|
|
|
NULL,
|
|
|
|
|
&reorder_sat[0]);
|
|
|
|
|
toBothSat(reorder_sat, state.saturation());
|
|
|
|
|
} else {
|
|
|
|
|
tsolver.solve(*grid, tsrc, stepsize, ctrl, state, linsolve, rpt);
|
|
|
|
|
std::cout << rpt;
|
|
|
|
|
}
|
2012-01-19 14:12:53 +01:00
|
|
|
|
|
|
|
|
current_time += stepsize;
|
2012-01-19 13:58:25 +01:00
|
|
|
}
|
2012-01-19 14:12:53 +01:00
|
|
|
|
2012-01-20 15:51:29 +01:00
|
|
|
if (output) {
|
|
|
|
|
outputState(grid_dims, cell_size, state, num_psteps);
|
|
|
|
|
}
|
2011-10-06 17:25:13 +02:00
|
|
|
|
2011-10-05 20:06:03 +02:00
|
|
|
destroy_transport_source(tsrc);
|
|
|
|
|
destroy_cart_grid(grid);
|
|
|
|
|
}
|