2013-05-22 08:16:24 -05:00
|
|
|
/*
|
|
|
|
Copyright 2013 SINTEF ICT, Applied Mathematics.
|
|
|
|
|
|
|
|
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_GEOPROPS_HEADER_INCLUDED
|
|
|
|
#define OPM_GEOPROPS_HEADER_INCLUDED
|
|
|
|
|
|
|
|
#include <opm/core/grid.h>
|
2014-02-20 06:15:02 -06:00
|
|
|
#include <opm/autodiff/GridHelpers.hpp>
|
2014-02-20 06:17:18 -06:00
|
|
|
//#include <opm/core/pressure/tpfa/trans_tpfa.h>
|
|
|
|
#include <opm/core/pressure/tpfa/TransTpfa.hpp>
|
2013-05-22 08:16:24 -05:00
|
|
|
#include <Eigen/Eigen>
|
|
|
|
|
|
|
|
namespace Opm
|
|
|
|
{
|
|
|
|
|
2013-09-23 06:02:56 -05:00
|
|
|
/// Class containing static geological properties that are
|
2013-09-20 07:55:24 -05:00
|
|
|
/// derived from grid and petrophysical properties:
|
|
|
|
/// - pore volume
|
|
|
|
/// - transmissibilities
|
|
|
|
/// - gravity potentials
|
2013-05-22 08:16:24 -05:00
|
|
|
class DerivedGeology
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef Eigen::ArrayXd Vector;
|
|
|
|
|
|
|
|
/// Construct contained derived geological properties
|
|
|
|
/// from grid and property information.
|
2014-02-20 06:17:18 -06:00
|
|
|
template <class Props, class Grid>
|
|
|
|
DerivedGeology(const Grid& grid,
|
2013-05-22 08:16:24 -05:00
|
|
|
const Props& props ,
|
|
|
|
const double* grav = 0)
|
2014-02-20 06:15:02 -06:00
|
|
|
: pvol_ (Opm::AutoDiffGrid::numCells(grid))
|
|
|
|
, trans_(Opm::AutoDiffGrid::numFaces(grid))
|
|
|
|
, gpot_ (Vector::Zero(Opm::AutoDiffGrid::cell2Faces(grid).noEntries(), 1))
|
|
|
|
, z_(Opm::AutoDiffGrid::numCells(grid))
|
2013-05-22 08:16:24 -05:00
|
|
|
{
|
2014-02-20 06:15:02 -06:00
|
|
|
using namespace Opm::AutoDiffGrid;
|
2013-05-22 08:16:24 -05:00
|
|
|
// Pore volume
|
2014-02-20 06:15:02 -06:00
|
|
|
const typename Vector::Index nc = numCells(grid);
|
|
|
|
std::transform(beginCellVolumes(grid), endCellVolumes(grid),
|
2013-05-22 08:16:24 -05:00
|
|
|
props.porosity(), pvol_.data(),
|
|
|
|
std::multiplies<double>());
|
|
|
|
|
|
|
|
// Transmissibility
|
2014-02-20 06:17:18 -06:00
|
|
|
Vector htrans(numCellFaces(grid));
|
|
|
|
Grid* ug = const_cast<Grid*>(& grid);
|
2013-05-22 08:16:24 -05:00
|
|
|
tpfa_htrans_compute(ug, props.permeability(), htrans.data());
|
|
|
|
tpfa_trans_compute (ug, htrans.data() , trans_.data());
|
|
|
|
|
2013-09-19 07:47:12 -05:00
|
|
|
// Compute z coordinates
|
|
|
|
for (int c = 0; c<nc; ++c){
|
2014-02-20 06:15:02 -06:00
|
|
|
z_[c] = cellCentroid(grid, c)[2];
|
2013-09-19 07:47:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-23 07:48:34 -05:00
|
|
|
// Gravity potential
|
|
|
|
std::fill(gravity_, gravity_ + 3, 0.0);
|
2013-05-22 08:16:24 -05:00
|
|
|
if (grav != 0) {
|
2014-02-20 06:15:02 -06:00
|
|
|
const typename Vector::Index nd = dimensions(grid);
|
2014-02-20 06:17:18 -06:00
|
|
|
typedef typename ADCell2FacesTraits<Grid>::Type Cell2Faces;
|
|
|
|
Cell2Faces c2f=cell2Faces(grid);
|
2013-05-22 08:16:24 -05:00
|
|
|
|
|
|
|
for (typename Vector::Index c = 0; c < nc; ++c) {
|
2014-02-20 06:15:02 -06:00
|
|
|
const double* const cc = cellCentroid(grid, c);
|
2013-05-22 08:16:24 -05:00
|
|
|
|
2014-02-20 06:17:18 -06:00
|
|
|
typename Cell2Faces::row_type faces=c2f[c];
|
|
|
|
typedef typename Cell2Faces::row_type::iterator Iter;
|
2013-05-22 08:16:24 -05:00
|
|
|
|
2014-02-20 06:15:02 -06:00
|
|
|
for (Iter f=faces.begin(), end=faces.end(); f!=end; ++f) {
|
|
|
|
const double* const fc = faceCentroid(grid, *f);
|
2013-05-22 08:16:24 -05:00
|
|
|
|
|
|
|
for (typename Vector::Index d = 0; d < nd; ++d) {
|
2014-02-20 06:15:02 -06:00
|
|
|
gpot_[f-faces.begin()] += grav[d] * (fc[d] - cc[d]);
|
2013-05-22 08:16:24 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-05-23 07:48:34 -05:00
|
|
|
std::copy(grav, grav + nd, gravity_);
|
2013-05-22 08:16:24 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-24 02:33:33 -05:00
|
|
|
const Vector& poreVolume() const { return pvol_ ;}
|
|
|
|
const Vector& transmissibility() const { return trans_ ;}
|
|
|
|
const Vector& gravityPotential() const { return gpot_ ;}
|
|
|
|
const Vector& z() const { return z_ ;}
|
|
|
|
const double* gravity() const { return gravity_;}
|
2013-05-22 08:16:24 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
Vector pvol_ ;
|
|
|
|
Vector trans_;
|
|
|
|
Vector gpot_ ;
|
2013-09-19 07:47:12 -05:00
|
|
|
Vector z_;
|
2013-05-23 07:48:34 -05:00
|
|
|
double gravity_[3]; // Size 3 even if grid is 2-dim.
|
2013-05-22 08:16:24 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // OPM_GEOPROPS_HEADER_INCLUDED
|