Constructors of *FromDeck classes now take an UnstructuredGrid.
This is a change from taking a vector containing the mapping to deck-consistent logical cartesian indices. The mapping is contained in the UnstructuredGrid::global_cell member, and may be null. The change therefore saves the overhead of constructing a vector as a copy of the data in the grid or (if null) as an identity mapping.
This commit is contained in:
parent
abb4264b48
commit
9a23b8db74
@ -81,17 +81,7 @@ main(int argc, char** argv)
|
||||
// Grid init
|
||||
grid.reset(new GridManager(*deck));
|
||||
// Rock and fluid init
|
||||
int nc = grid->c_grid()->number_of_cells;
|
||||
std::vector<int> global_cell(nc);
|
||||
const int* gc = grid->c_grid()->global_cell;
|
||||
if (gc != 0) {
|
||||
std::copy(gc, gc + nc, global_cell.begin());
|
||||
} else {
|
||||
for (int cell = 0; cell < nc; ++cell) {
|
||||
global_cell[cell] = cell;
|
||||
}
|
||||
}
|
||||
props.reset(new IncompPropertiesFromDeck(*deck, global_cell));
|
||||
props.reset(new IncompPropertiesFromDeck(*deck, *grid->c_grid()));
|
||||
// check_well_controls = param.getDefault("check_well_controls", false);
|
||||
// max_well_control_iterations = param.getDefault("max_well_control_iterations", 10);
|
||||
// Rock compressibility.
|
||||
|
@ -178,17 +178,7 @@ main(int argc, char** argv)
|
||||
// Grid init
|
||||
grid.reset(new Opm::GridManager(deck));
|
||||
// Rock and fluid init
|
||||
int nc = grid->c_grid()->number_of_cells;
|
||||
std::vector<int> global_cell(nc);
|
||||
const int* gc = grid->c_grid()->global_cell;
|
||||
if (gc != 0) {
|
||||
std::copy(gc, gc + nc, global_cell.begin());
|
||||
} else {
|
||||
for (int cell = 0; cell < nc; ++cell) {
|
||||
global_cell[cell] = cell;
|
||||
}
|
||||
}
|
||||
props.reset(new Opm::BlackoilPropertiesFromDeck(deck, global_cell));
|
||||
props.reset(new Opm::BlackoilPropertiesFromDeck(deck, *grid->c_grid()));
|
||||
// Wells init.
|
||||
wells.reset(new Opm::WellsManager(deck, *grid->c_grid(), props->permeability()));
|
||||
check_well_controls = param.getDefault("check_well_controls", false);
|
||||
|
@ -309,17 +309,7 @@ main(int argc, char** argv)
|
||||
// Grid init
|
||||
grid.reset(new Opm::GridManager(deck));
|
||||
// Rock and fluid init
|
||||
int nc = grid->c_grid()->number_of_cells;
|
||||
std::vector<int> global_cell(nc);
|
||||
const int* gc = grid->c_grid()->global_cell;
|
||||
if (gc != 0) {
|
||||
std::copy(gc, gc + nc, global_cell.begin());
|
||||
} else {
|
||||
for (int cell = 0; cell < nc; ++cell) {
|
||||
global_cell[cell] = cell;
|
||||
}
|
||||
}
|
||||
props.reset(new Opm::IncompPropertiesFromDeck(deck, global_cell));
|
||||
props.reset(new Opm::IncompPropertiesFromDeck(deck, *grid->c_grid()));
|
||||
// Wells init.
|
||||
wells.reset(new Opm::WellsManager(deck, *grid->c_grid(), props->permeability()));
|
||||
check_well_controls = param.getDefault("check_well_controls", false);
|
||||
|
@ -38,19 +38,8 @@ int main(int argc, char** argv)
|
||||
// Finally handle the wells
|
||||
WellsManager wells(parser, *grid.c_grid(), NULL);
|
||||
|
||||
int nc = grid.c_grid()->number_of_cells;
|
||||
std::vector<int> global_cells(nc);
|
||||
const int* gc = grid.c_grid()->global_cell;
|
||||
if (gc != 0) {
|
||||
std::copy(gc, gc + nc, global_cells.begin());
|
||||
} else {
|
||||
for (int cell = 0; cell < nc; ++cell) {
|
||||
global_cells[cell] = cell;
|
||||
}
|
||||
}
|
||||
|
||||
double gravity[3] = {0.0, 0.0, parameters.getDefault<double>("gravity", 0.0)};
|
||||
IncompPropertiesFromDeck incomp_properties(parser, global_cells);
|
||||
IncompPropertiesFromDeck incomp_properties(parser, *grid.c_grid());
|
||||
|
||||
RockCompressibility rock_comp(parser);
|
||||
|
||||
|
@ -23,11 +23,11 @@ namespace Opm
|
||||
{
|
||||
|
||||
BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck(const EclipseGridParser& deck,
|
||||
const std::vector<int>& global_cell)
|
||||
const UnstructuredGrid& grid)
|
||||
{
|
||||
rock_.init(deck, global_cell);
|
||||
rock_.init(deck, grid);
|
||||
pvt_.init(deck);
|
||||
satprops_.init(deck, global_cell);
|
||||
satprops_.init(deck, grid);
|
||||
if (pvt_.numPhases() != satprops_.numPhases()) {
|
||||
THROW("BlackoilPropertiesBasic::BlackoilPropertiesBasic() - Inconsistent number of phases in pvt data ("
|
||||
<< pvt_.numPhases() << ") and saturation-dependent function data (" << satprops_.numPhases() << ").");
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <opm/core/fluid/SaturationPropsFromDeck.hpp>
|
||||
#include <opm/core/eclipse/EclipseGridParser.hpp>
|
||||
|
||||
struct UnstructuredGrid;
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
@ -35,12 +37,13 @@ namespace Opm
|
||||
class BlackoilPropertiesFromDeck : public BlackoilPropertiesInterface
|
||||
{
|
||||
public:
|
||||
/// Construct from deck and cell mapping.
|
||||
/// \param deck eclipse input parser
|
||||
/// \param global_cell mapping from cell indices (typically from a processed grid)
|
||||
/// Initialize from deck and grid.
|
||||
/// \param deck Deck input parser
|
||||
/// \param grid Grid to which property object applies, needed for the
|
||||
/// mapping from cell indices (typically from a processed grid)
|
||||
/// to logical cartesian indices consistent with the deck.
|
||||
BlackoilPropertiesFromDeck(const EclipseGridParser& deck,
|
||||
const std::vector<int>& global_cell);
|
||||
const UnstructuredGrid& grid);
|
||||
|
||||
/// Destructor.
|
||||
virtual ~BlackoilPropertiesFromDeck();
|
||||
|
@ -27,11 +27,11 @@ namespace Opm
|
||||
{
|
||||
|
||||
IncompPropertiesFromDeck::IncompPropertiesFromDeck(const EclipseGridParser& deck,
|
||||
const std::vector<int>& global_cell)
|
||||
const UnstructuredGrid& grid)
|
||||
{
|
||||
rock_.init(deck, global_cell);
|
||||
rock_.init(deck, grid);
|
||||
pvt_.init(deck);
|
||||
satprops_.init(deck, global_cell);
|
||||
satprops_.init(deck, grid);
|
||||
if (pvt_.numPhases() != satprops_.numPhases()) {
|
||||
THROW("IncompPropertiesFromDeck::IncompPropertiesFromDeck() - Inconsistent number of phases in pvt data ("
|
||||
<< pvt_.numPhases() << ") and saturation-dependent function data (" << satprops_.numPhases() << ").");
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include <opm/core/fluid/SaturationPropsFromDeck.hpp>
|
||||
#include <opm/core/eclipse/EclipseGridParser.hpp>
|
||||
|
||||
struct UnstructuredGrid;
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
@ -43,12 +45,13 @@ namespace Opm
|
||||
class IncompPropertiesFromDeck : public IncompPropertiesInterface
|
||||
{
|
||||
public:
|
||||
/// Construct from deck and cell mapping.
|
||||
/// \param deck eclipse input parser
|
||||
/// \param global_cell mapping from cell indices (typically from a processed grid)
|
||||
/// Initialize from deck and grid.
|
||||
/// \param deck Deck input parser
|
||||
/// \param grid Grid to which property object applies, needed for the
|
||||
/// mapping from cell indices (typically from a processed grid)
|
||||
/// to logical cartesian indices consistent with the deck.
|
||||
IncompPropertiesFromDeck(const EclipseGridParser& deck,
|
||||
const std::vector<int>& global_cell);
|
||||
const UnstructuredGrid& grid);
|
||||
|
||||
/// Destructor.
|
||||
virtual ~IncompPropertiesFromDeck();
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
|
||||
#include <opm/core/fluid/RockFromDeck.hpp>
|
||||
|
||||
#include <opm/core/grid.h>
|
||||
#include <tr1/array>
|
||||
|
||||
namespace Opm
|
||||
@ -53,28 +53,29 @@ namespace Opm
|
||||
|
||||
/// Initialize from deck and cell mapping.
|
||||
/// \param deck Deck input parser
|
||||
/// \param global_cell mapping from cell indices (typically from a processed grid)
|
||||
/// \param grid grid to which property object applies, needed for the
|
||||
/// mapping from cell indices (typically from a processed grid)
|
||||
/// to logical cartesian indices consistent with the deck.
|
||||
void RockFromDeck::init(const EclipseGridParser& deck,
|
||||
const std::vector<int>& global_cell)
|
||||
const UnstructuredGrid& grid)
|
||||
{
|
||||
assignPorosity(deck, global_cell);
|
||||
permfield_valid_.assign(global_cell.size(), false);
|
||||
assignPorosity(deck, grid);
|
||||
permfield_valid_.assign(grid.number_of_cells, false);
|
||||
const double perm_threshold = 0.0; // Maybe turn into parameter?
|
||||
assignPermeability(deck, global_cell, perm_threshold);
|
||||
assignPermeability(deck, grid, perm_threshold);
|
||||
}
|
||||
|
||||
|
||||
void RockFromDeck::assignPorosity(const EclipseGridParser& parser,
|
||||
const std::vector<int>& global_cell)
|
||||
const UnstructuredGrid& grid)
|
||||
{
|
||||
porosity_.assign(global_cell.size(), 1.0);
|
||||
|
||||
porosity_.assign(grid.number_of_cells, 1.0);
|
||||
const int* gc = grid.global_cell;
|
||||
if (parser.hasField("PORO")) {
|
||||
const std::vector<double>& poro = parser.getFloatingPointValue("PORO");
|
||||
|
||||
for (int c = 0; c < int(porosity_.size()); ++c) {
|
||||
porosity_[c] = poro[global_cell[c]];
|
||||
const int deck_pos = (gc == NULL) ? c : gc[c];
|
||||
porosity_[c] = poro[deck_pos];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -82,14 +83,16 @@ namespace Opm
|
||||
|
||||
|
||||
void RockFromDeck::assignPermeability(const EclipseGridParser& parser,
|
||||
const std::vector<int>& global_cell,
|
||||
const UnstructuredGrid& grid,
|
||||
double perm_threshold)
|
||||
{
|
||||
const int dim = 3;
|
||||
const int num_global_cells = numGlobalCells(parser);
|
||||
const int nc = grid.number_of_cells;
|
||||
|
||||
ASSERT (num_global_cells > 0);
|
||||
|
||||
permeability_.assign(dim * dim * global_cell.size(), 0.0);
|
||||
permeability_.assign(dim * dim * nc, 0.0);
|
||||
|
||||
std::vector<const std::vector<double>*> tensor;
|
||||
tensor.reserve(10);
|
||||
@ -111,13 +114,13 @@ namespace Opm
|
||||
// chosen) default value...
|
||||
//
|
||||
if (tensor.size() > 1) {
|
||||
const int nc = global_cell.size();
|
||||
int off = 0;
|
||||
const int* gc = grid.global_cell;
|
||||
int off = 0;
|
||||
|
||||
for (int c = 0; c < nc; ++c, off += dim*dim) {
|
||||
// SharedPermTensor K(dim, dim, &permeability_[off]);
|
||||
int kix = 0;
|
||||
const int glob = global_cell[c];
|
||||
const int glob = (gc == NULL) ? c : gc[c];
|
||||
|
||||
for (int i = 0; i < dim; ++i) {
|
||||
for (int j = 0; j < dim; ++j, ++kix) {
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <opm/core/eclipse/EclipseGridParser.hpp>
|
||||
#include <vector>
|
||||
|
||||
struct UnstructuredGrid;
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
@ -34,12 +35,13 @@ namespace Opm
|
||||
/// Default constructor.
|
||||
RockFromDeck();
|
||||
|
||||
/// Initialize from deck and cell mapping.
|
||||
/// Initialize from deck and grid.
|
||||
/// \param deck Deck input parser
|
||||
/// \param global_cell mapping from cell indices (typically from a processed grid)
|
||||
/// \param grid Grid to which property object applies, needed for the
|
||||
/// mapping from cell indices (typically from a processed grid)
|
||||
/// to logical cartesian indices consistent with the deck.
|
||||
void init(const EclipseGridParser& deck,
|
||||
const std::vector<int>& global_cell);
|
||||
const UnstructuredGrid& grid);
|
||||
|
||||
/// \return D, the number of spatial dimensions. Always 3 for deck input.
|
||||
int numDimensions() const
|
||||
@ -69,9 +71,9 @@ namespace Opm
|
||||
|
||||
private:
|
||||
void assignPorosity(const EclipseGridParser& parser,
|
||||
const std::vector<int>& global_cell);
|
||||
const UnstructuredGrid& grid);
|
||||
void assignPermeability(const EclipseGridParser& parser,
|
||||
const std::vector<int>& global_cell,
|
||||
const UnstructuredGrid& grid,
|
||||
const double perm_threshold);
|
||||
|
||||
std::vector<double> porosity_;
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <opm/core/fluid/SaturationPropsFromDeck.hpp>
|
||||
#include <opm/core/grid.h>
|
||||
#include <opm/core/fluid/blackoil/phaseUsageFromDeck.hpp>
|
||||
#include <opm/core/utility/buildUniformMonotoneTable.hpp>
|
||||
#include <opm/core/utility/ErrorMacros.hpp>
|
||||
@ -33,7 +34,7 @@ namespace Opm
|
||||
|
||||
/// Initialize from deck.
|
||||
void SaturationPropsFromDeck::init(const EclipseGridParser& deck,
|
||||
const std::vector<int>& global_cell)
|
||||
const UnstructuredGrid& grid)
|
||||
{
|
||||
phase_usage_ = phaseUsageFromDeck(deck);
|
||||
|
||||
@ -49,10 +50,12 @@ namespace Opm
|
||||
if (deck.hasField("SATNUM")) {
|
||||
const std::vector<int>& satnum = deck.getIntegerValue("SATNUM");
|
||||
satfuncs_expected = *std::max_element(satnum.begin(), satnum.end());
|
||||
int num_cells = global_cell.size();
|
||||
const int num_cells = grid.number_of_cells;
|
||||
cell_to_func_.resize(num_cells);
|
||||
const int* gc = grid.global_cell;
|
||||
for (int cell = 0; cell < num_cells; ++cell) {
|
||||
cell_to_func_[cell] = satnum[global_cell[cell]] - 1;
|
||||
const int deck_pos = (gc == NULL) ? cell : gc[cell];
|
||||
cell_to_func_[cell] = satnum[deck_pos] - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include <opm/core/fluid/blackoil/BlackoilPhases.hpp>
|
||||
#include <vector>
|
||||
|
||||
struct UnstructuredGrid;
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
@ -34,10 +36,13 @@ namespace Opm
|
||||
/// Default constructor.
|
||||
SaturationPropsFromDeck();
|
||||
|
||||
/// Initialize from deck.
|
||||
/// global_cell maps from grid cells to their original logical Cartesian indices.
|
||||
/// Initialize from deck and grid.
|
||||
/// \param deck Deck input parser
|
||||
/// \param grid Grid to which property object applies, needed for the
|
||||
/// mapping from cell indices (typically from a processed grid)
|
||||
/// to logical cartesian indices consistent with the deck.
|
||||
void init(const EclipseGridParser& deck,
|
||||
const std::vector<int>& global_cell);
|
||||
const UnstructuredGrid& grid);
|
||||
|
||||
/// \return P, the number of phases.
|
||||
int numPhases() const;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <opm/core/eclipse/EclipseGridParser.hpp>
|
||||
#include <opm/core/eclipse/EclipseGridInspector.hpp>
|
||||
#include <opm/core/fluid/BlackoilPropertiesFromDeck.hpp>
|
||||
#include <opm/core/grid.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
@ -39,14 +40,10 @@ int main(int argc, char** argv)
|
||||
// Parser.
|
||||
std::string ecl_file = param.get<std::string>("filename");
|
||||
Opm::EclipseGridParser deck(ecl_file);
|
||||
Opm::EclipseGridInspector insp(deck);
|
||||
std::tr1::array<int, 3> gs = insp.gridSize();
|
||||
int num_cells = gs[0]*gs[1]*gs[2];
|
||||
std::vector<int> global_cell(num_cells);
|
||||
for (int i = 0; i < num_cells; ++i) {
|
||||
global_cell[i] = i;
|
||||
}
|
||||
Opm::BlackoilPropertiesFromDeck props(deck, global_cell);
|
||||
UnstructuredGrid grid;
|
||||
grid.number_of_cells = 1;
|
||||
grid.global_cell = NULL;
|
||||
Opm::BlackoilPropertiesFromDeck props(deck, grid);
|
||||
|
||||
const int n = 1;
|
||||
double p[n] = { 150e5 };
|
||||
|
Loading…
Reference in New Issue
Block a user