2013-05-07 12:58:10 -05:00
|
|
|
/*
|
|
|
|
Copyright 2013 SINTEF ICT, Applied Mathematics.
|
|
|
|
Copyright 2013 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_IMPESTPFAAD_HEADER_INCLUDED
|
|
|
|
#define OPM_IMPESTPFAAD_HEADER_INCLUDED
|
|
|
|
|
2013-05-15 09:10:20 -05:00
|
|
|
#include <opm/autodiff/AutoDiffBlock.hpp>
|
|
|
|
#include <opm/autodiff/AutoDiffHelpers.hpp>
|
2013-05-22 04:13:14 -05:00
|
|
|
#include <opm/autodiff/BlackoilPropsAdInterface.hpp>
|
2013-05-07 12:58:10 -05:00
|
|
|
|
|
|
|
struct UnstructuredGrid;
|
2013-05-22 08:49:55 -05:00
|
|
|
struct Wells;
|
2013-05-07 14:40:17 -05:00
|
|
|
|
|
|
|
namespace Opm {
|
2013-05-13 01:35:39 -05:00
|
|
|
|
2013-05-22 08:49:55 -05:00
|
|
|
class DerivedGeology;
|
|
|
|
class LinearSolverInterface;
|
|
|
|
class BlackoilState;
|
|
|
|
class WellState;
|
|
|
|
|
|
|
|
/// Class for solving black-oil impes problems.
|
|
|
|
/// Current known limitations:
|
|
|
|
/// - pressure solve only
|
|
|
|
/// - no miscibility
|
|
|
|
/// - no gravity in wells or crossflow
|
|
|
|
class ImpesTPFAAD
|
|
|
|
{
|
2013-05-07 12:58:10 -05:00
|
|
|
public:
|
2013-05-22 08:49:55 -05:00
|
|
|
/// Construct impes solver.
|
2013-05-22 08:27:16 -05:00
|
|
|
ImpesTPFAAD(const UnstructuredGrid& grid,
|
|
|
|
const BlackoilPropsAdInterface& fluid,
|
|
|
|
const DerivedGeology& geo,
|
|
|
|
const Wells& wells,
|
2013-05-22 08:49:55 -05:00
|
|
|
const LinearSolverInterface& linsolver);
|
|
|
|
|
|
|
|
/// Solve forward in time.
|
|
|
|
/// Currently this will only modify
|
|
|
|
/// state.pressure(), state.faceflux(), well_state.bhp()
|
|
|
|
/// and well_state.wellRates().
|
|
|
|
void solve(const double dt,
|
|
|
|
BlackoilState& state,
|
|
|
|
WellState& well_state);
|
2013-05-07 12:58:10 -05:00
|
|
|
private:
|
|
|
|
// Disallow copying and assignment
|
|
|
|
ImpesTPFAAD(const ImpesTPFAAD& rhs);
|
|
|
|
ImpesTPFAAD& operator=(const ImpesTPFAAD& rhs);
|
|
|
|
|
2013-05-22 08:49:55 -05:00
|
|
|
// Types
|
2013-09-19 05:53:28 -05:00
|
|
|
typedef AutoDiffBlock<double> ADB;
|
2013-05-16 09:05:47 -05:00
|
|
|
typedef ADB::V V;
|
|
|
|
typedef ADB::M M;
|
|
|
|
typedef Eigen::Array<double,
|
|
|
|
Eigen::Dynamic,
|
|
|
|
Eigen::Dynamic,
|
|
|
|
Eigen::RowMajor> DataBlock;
|
2013-05-22 08:49:55 -05:00
|
|
|
enum { Water = BlackoilPropsAdInterface::Water,
|
|
|
|
Oil = BlackoilPropsAdInterface::Oil,
|
|
|
|
Gas = BlackoilPropsAdInterface::Gas };
|
2013-05-07 12:58:10 -05:00
|
|
|
|
2013-05-22 08:49:55 -05:00
|
|
|
// Data
|
2013-05-21 02:33:52 -05:00
|
|
|
const UnstructuredGrid& grid_;
|
2013-05-22 04:13:14 -05:00
|
|
|
const BlackoilPropsAdInterface& fluid_;
|
2013-05-22 08:27:16 -05:00
|
|
|
const DerivedGeology& geo_ ;
|
2013-05-21 02:33:52 -05:00
|
|
|
const Wells& wells_;
|
2013-05-13 01:35:39 -05:00
|
|
|
const LinearSolverInterface& linsolver_;
|
2013-05-21 02:33:52 -05:00
|
|
|
HelperOps ops_;
|
|
|
|
const M grav_;
|
|
|
|
ADB cell_residual_;
|
2013-05-21 08:42:35 -05:00
|
|
|
std::vector<ADB> well_flow_residual_;
|
2013-05-21 02:33:52 -05:00
|
|
|
ADB well_residual_;
|
2013-05-21 16:26:55 -05:00
|
|
|
ADB total_residual_;
|
2013-05-21 02:33:52 -05:00
|
|
|
std::vector<V> kr_;
|
|
|
|
std::vector<V> well_kr_;
|
2013-05-23 08:08:21 -05:00
|
|
|
ADB qs_;
|
|
|
|
V well_perf_dp_;
|
2013-05-16 09:05:47 -05:00
|
|
|
|
2013-05-22 08:49:55 -05:00
|
|
|
// Methods for assembling and solving.
|
2013-05-23 08:08:21 -05:00
|
|
|
void computeExplicitData(const double dt,
|
|
|
|
const BlackoilState& state,
|
|
|
|
const WellState& well_state);
|
2013-05-22 08:49:55 -05:00
|
|
|
void assemble(const double dt,
|
|
|
|
const BlackoilState& state,
|
|
|
|
const WellState& well_state);
|
|
|
|
void solveJacobianSystem(BlackoilState& state,
|
|
|
|
WellState& well_state) const;
|
|
|
|
double residualNorm() const;
|
2013-05-22 15:51:14 -05:00
|
|
|
void computeFluxes(BlackoilState& state, WellState& well_state) const;
|
2013-05-22 08:49:55 -05:00
|
|
|
|
|
|
|
// Fluid interface forwarding calls to correct methods of fluid_.
|
2014-11-20 05:31:50 -06:00
|
|
|
V fluidMu(const int phase, const V& p, const V& T, const std::vector<int>& cells) const;
|
|
|
|
ADB fluidMu(const int phase, const ADB& p, const ADB& T, const std::vector<int>& cells) const;
|
|
|
|
V fluidFvf(const int phase, const V& p, const V& T, const std::vector<int>& cells) const;
|
|
|
|
ADB fluidFvf(const int phase, const ADB& p, const ADB& T, const std::vector<int>& cells) const;
|
|
|
|
V fluidRho(const int phase, const V& p, const V& T, const std::vector<int>& cells) const;
|
|
|
|
ADB fluidRho(const int phase, const ADB& p, const ADB& T, const std::vector<int>& cells) const;
|
2015-03-06 02:34:07 -06:00
|
|
|
std::vector<V> fluidRelperm(const V& sw, const V& so, const V& sg, const std::vector<int>& cells) const;
|
2013-05-22 08:49:55 -05:00
|
|
|
V fluidKr(const int phase) const;
|
|
|
|
V fluidKrWell(const int phase) const;
|
|
|
|
};
|
2013-05-21 02:33:52 -05:00
|
|
|
|
|
|
|
|
2013-05-07 12:58:10 -05:00
|
|
|
} // namespace Opm
|
|
|
|
|
|
|
|
#endif /* OPM_IMPESTPFAAD_HEADER_INCLUDED */
|