Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save eclgrid after deactivating cells #59

Merged
merged 3 commits into from
Jul 30, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 64 additions & 63 deletions opm/porsol/common/setupGridAndProps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,34 +64,35 @@ namespace Opm
/// @param
template <template <int> class ResProp>
inline void setupGridAndProps(const Opm::parameter::ParameterGroup& param,
Dune::CpGrid& grid,
ResProp<3>& res_prop)
Dune::CpGrid& grid,
ResProp<3>& res_prop)
{
// Initialize grid and reservoir properties.
// Parts copied from Dune::CpGrid::init().
std::string fileformat = param.getDefault<std::string>("fileformat", "cartesian");
if (fileformat == "sintef_legacy") {
std::string grid_prefix = param.get<std::string>("grid_prefix");
grid.readSintefLegacyFormat(grid_prefix);
MESSAGE("Warning: We do not yet read legacy reservoir properties. Using defaults.");
res_prop.init(grid.size(0));
} else if (fileformat == "eclipse") {
// Initialize grid and reservoir properties.
// Parts copied from Dune::CpGrid::init().
std::string fileformat = param.getDefault<std::string>("fileformat", "cartesian");
if (fileformat == "sintef_legacy") {
std::string grid_prefix = param.get<std::string>("grid_prefix");
grid.readSintefLegacyFormat(grid_prefix);
MESSAGE("Warning: We do not yet read legacy reservoir properties. Using defaults.");
res_prop.init(grid.size(0));
} else if (fileformat == "eclipse") {
std::string ecl_file = param.get<std::string>("filename");
Opm::EclipseGridParser parser(ecl_file);
double z_tolerance = param.getDefault<double>("z_tolerance", 0.0);
bool periodic_extension = param.getDefault<bool>("periodic_extension", false);
bool turn_normals = param.getDefault<bool>("turn_normals", false);
grid.processEclipseFormat(parser, z_tolerance, periodic_extension, turn_normals);
Opm::EclipseGridParser parser(ecl_file);
double z_tolerance = param.getDefault<double>("z_tolerance", 0.0);
bool periodic_extension = param.getDefault<bool>("periodic_extension", false);
bool turn_normals = param.getDefault<bool>("turn_normals", false);
grid.processEclipseFormat(parser, z_tolerance, periodic_extension, turn_normals);
// Save EGRID file in case we are writing ECL output.
if (param.getDefault("output_ecl", false)) {
boost::filesystem::path ecl_path(ecl_file);
ecl_path.replace_extension(".FEGRID");
parser.saveEGRID(ecl_path.string());
const std::vector<int>& globalCell = grid.globalCell();
ecl_path.replace_extension(".EGRID");
parser.saveEGRID(ecl_path.string() , (int) globalCell.size() , &globalCell[0]);
}
double perm_threshold_md = param.getDefault("perm_threshold_md", 0.0);
double perm_threshold = Opm::unit::convert::from(perm_threshold_md, Opm::prefix::milli*Opm::unit::darcy);
std::string rock_list = param.getDefault<std::string>("rock_list", "no_list");
std::string* rl_ptr = (rock_list == "no_list") ? 0 : &rock_list;
double perm_threshold = Opm::unit::convert::from(perm_threshold_md, Opm::prefix::milli*Opm::unit::darcy);
std::string rock_list = param.getDefault<std::string>("rock_list", "no_list");
std::string* rl_ptr = (rock_list == "no_list") ? 0 : &rock_list;
bool use_j = param.getDefault("use_jfunction_scaling", useJ<ResProp<3> >());
double sigma = 1.0;
double theta = 0.0;
Expand All @@ -104,27 +105,27 @@ namespace Opm
double v2 = param.getDefault("viscosity2", 0.003);
res_prop.setViscosities(v1, v2);
}
res_prop.init(parser, grid.globalCell(), perm_threshold, rl_ptr,
res_prop.init(parser, grid.globalCell(), perm_threshold, rl_ptr,
use_j, sigma, theta);
} else if (fileformat == "cartesian") {
Dune::array<int, 3> dims = {{ param.getDefault<int>("nx", 1),
param.getDefault<int>("ny", 1),
param.getDefault<int>("nz", 1) }};
Dune::array<double, 3> cellsz = {{ param.getDefault<double>("dx", 1.0),
param.getDefault<double>("dy", 1.0),
param.getDefault<double>("dz", 1.0) }};
grid.createCartesian(dims, cellsz);
double default_poro = param.getDefault("default_poro", 0.2);
double default_perm_md = param.getDefault("default_perm_md", 100.0);
double default_perm = Opm::unit::convert::from(default_perm_md, Opm::prefix::milli*Opm::unit::darcy);
MESSAGE("Warning: For generated cartesian grids, we use uniform reservoir properties.");
res_prop.init(grid.size(0), default_poro, default_perm);
} else {
THROW("Unknown file format string: " << fileformat);
}
if (param.getDefault("use_unique_boundary_ids", false)) {
grid.setUniqueBoundaryIds(true);
}
} else if (fileformat == "cartesian") {
Dune::array<int, 3> dims = {{ param.getDefault<int>("nx", 1),
param.getDefault<int>("ny", 1),
param.getDefault<int>("nz", 1) }};
Dune::array<double, 3> cellsz = {{ param.getDefault<double>("dx", 1.0),
param.getDefault<double>("dy", 1.0),
param.getDefault<double>("dz", 1.0) }};
grid.createCartesian(dims, cellsz);
double default_poro = param.getDefault("default_poro", 0.2);
double default_perm_md = param.getDefault("default_perm_md", 100.0);
double default_perm = Opm::unit::convert::from(default_perm_md, Opm::prefix::milli*Opm::unit::darcy);
MESSAGE("Warning: For generated cartesian grids, we use uniform reservoir properties.");
res_prop.init(grid.size(0), default_poro, default_perm);
} else {
THROW("Unknown file format string: " << fileformat);
}
if (param.getDefault("use_unique_boundary_ids", false)) {
grid.setUniqueBoundaryIds(true);
}
}

/// @brief
Expand All @@ -148,38 +149,38 @@ namespace Opm
grid.processEclipseFormat(parser, z_tolerance, periodic_extension, turn_normals, clip_z);
const std::string* rl_ptr = (rock_list == "no_list") ? 0 : &rock_list;
res_prop.init(parser, grid.globalCell(), perm_threshold, rl_ptr, use_jfunction_scaling, sigma, theta);
if (unique_bids) {
grid.setUniqueBoundaryIds(true);
}
if (unique_bids) {
grid.setUniqueBoundaryIds(true);
}
}

/// @brief
/// @todo Doc me!
/// @param
template <template <int> class ResProp>
inline void setupGridAndProps(const Opm::parameter::ParameterGroup& param,
Dune::SGrid<3, 3>& grid,
ResProp<3>& res_prop)
Dune::SGrid<3, 3>& grid,
ResProp<3>& res_prop)
{
// Initialize grid and reservoir properties.
// Parts copied from Dune::CpGrid::init().
std::string fileformat = param.getDefault<std::string>("fileformat", "cartesian");
if (fileformat == "cartesian") {
Dune::array<int, 3> dims = {{ param.getDefault<int>("nx", 1),
param.getDefault<int>("ny", 1),
param.getDefault<int>("nz", 1) }};
Dune::array<double, 3> cellsz = {{ param.getDefault<double>("dx", 1.0),
param.getDefault<double>("dy", 1.0),
param.getDefault<double>("dz", 1.0) }};
// Initialize grid and reservoir properties.
// Parts copied from Dune::CpGrid::init().
std::string fileformat = param.getDefault<std::string>("fileformat", "cartesian");
if (fileformat == "cartesian") {
Dune::array<int, 3> dims = {{ param.getDefault<int>("nx", 1),
param.getDefault<int>("ny", 1),
param.getDefault<int>("nz", 1) }};
Dune::array<double, 3> cellsz = {{ param.getDefault<double>("dx", 1.0),
param.getDefault<double>("dy", 1.0),
param.getDefault<double>("dz", 1.0) }};
grid.~SGrid<3,3>();
new (&grid) Dune::SGrid<3, 3>(&dims[0], &cellsz[0]);
double default_poro = param.getDefault("default_poro", 0.2);
double default_perm = param.getDefault("default_perm", 100.0*Opm::prefix::milli*Opm::unit::darcy);
MESSAGE("Warning: For generated cartesian grids, we use uniform reservoir properties.");
res_prop.init(grid.size(0), default_poro, default_perm);
} else {
THROW("Dune::SGrid can only handle cartesian grids, unsupported file format string: " << fileformat);
}
double default_poro = param.getDefault("default_poro", 0.2);
double default_perm = param.getDefault("default_perm", 100.0*Opm::prefix::milli*Opm::unit::darcy);
MESSAGE("Warning: For generated cartesian grids, we use uniform reservoir properties.");
res_prop.init(grid.size(0), default_poro, default_perm);
} else {
THROW("Dune::SGrid can only handle cartesian grids, unsupported file format string: " << fileformat);
}
}

} // namespace Opm
Expand Down