2013-01-17 13:33:59 +01:00
|
|
|
/*
|
2019-05-07 07:15:25 +02:00
|
|
|
Copyright (C) 2011 Equinor ASA, Norway.
|
2017-02-07 13:44:59 +01:00
|
|
|
|
2013-01-17 13:33:59 +01:00
|
|
|
The file 'ecl_grid_cache.c' is part of ERT - Ensemble based
|
|
|
|
|
Reservoir Tool.
|
2017-02-07 13:44:59 +01:00
|
|
|
|
|
|
|
|
ERT 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.
|
|
|
|
|
|
|
|
|
|
ERT 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 at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
|
for more details.
|
2013-01-17 13:33:59 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
2018-08-13 10:20:34 +02:00
|
|
|
#include <ert/util/util.h>
|
2013-01-17 13:33:59 +01:00
|
|
|
|
2018-05-04 14:06:42 +02:00
|
|
|
#include <ert/ecl/ecl_kw.hpp>
|
|
|
|
|
#include <ert/ecl/ecl_util.hpp>
|
|
|
|
|
#include <ert/ecl/ecl_file.hpp>
|
|
|
|
|
#include <ert/ecl/ecl_grid.hpp>
|
2018-10-30 13:21:11 +01:00
|
|
|
|
|
|
|
|
#include "detail/ecl/ecl_grid_cache.hpp"
|
2013-01-17 13:33:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
The ecl_grid_cache_struct data structure internalizes the world
|
|
|
|
|
position of all the active cells. This is just a minor
|
|
|
|
|
simplification to speed up repeated calls to get the true world
|
2017-02-07 13:44:59 +01:00
|
|
|
coordinates of a cell.
|
2013-01-17 13:33:59 +01:00
|
|
|
*/
|
|
|
|
|
|
2018-10-30 13:21:11 +01:00
|
|
|
namespace ecl {
|
|
|
|
|
ecl_grid_cache::ecl_grid_cache(const ecl_grid_type * grid) :
|
|
|
|
|
grid(grid)
|
2013-01-17 13:33:59 +01:00
|
|
|
{
|
2018-10-30 13:21:11 +01:00
|
|
|
for (int active_index = 0; active_index < ecl_grid_get_active_size(this->grid); active_index++) {
|
|
|
|
|
double x,y,z;
|
|
|
|
|
int global_index = ecl_grid_get_global_index1A(this->grid, active_index);
|
|
|
|
|
ecl_grid_get_xyz1(this->grid, global_index, &x, &y, &z);
|
|
|
|
|
|
|
|
|
|
this->gi.push_back(global_index);
|
|
|
|
|
this->xp.push_back(x);
|
|
|
|
|
this->yp.push_back(y);
|
|
|
|
|
this->zp.push_back(z);
|
2013-01-17 13:33:59 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-10-30 13:21:11 +01:00
|
|
|
const std::vector<double>& ecl_grid_cache::volume() const {
|
|
|
|
|
if (this->v.empty()) {
|
|
|
|
|
for (int active_index = 0; active_index < this->size(); active_index++)
|
|
|
|
|
this->v.push_back( ecl_grid_get_cell_volume1A(this->grid, active_index));
|
|
|
|
|
}
|
|
|
|
|
return this->v;
|
2017-02-07 13:44:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|