本文整理汇总了C++中opm::parameter::ParameterGroup类的典型用法代码示例。如果您正苦于以下问题:C++ ParameterGroup类的具体用法?C++ ParameterGroup怎么用?C++ ParameterGroup使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ParameterGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupGridAndProps
inline void setupGridAndProps(const Opm::parameter::ParameterGroup& param,
CpGrid& grid,
ResProp<3>& res_prop)
{
// Initialize grid and reservoir properties.
// Parts copied from 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") {
Opm::EclipseGridParser parser(param.get<std::string>("filename"));
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);
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;
bool use_j = param.getDefault("use_jfunction_scaling", useJ<ResProp<3> >());
double sigma = 1.0;
double theta = 0.0;
if (use_j) {
sigma = param.getDefault("sigma", sigma);
theta = param.getDefault("theta", theta);
}
if (param.has("viscosity1") || param.has("viscosity2")) {
double v1 = param.getDefault("viscosity1", 0.001);
double v2 = param.getDefault("viscosity2", 0.003);
res_prop.setViscosities(v1, v2);
}
res_prop.init(parser, grid.globalCell(), perm_threshold, rl_ptr,
use_j, sigma, theta);
} else if (fileformat == "cartesian") {
array<int, 3> dims = {{ param.getDefault<int>("nx", 1),
param.getDefault<int>("ny", 1),
param.getDefault<int>("nz", 1) }};
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);
}
}
示例2: LinearSolverISTLAMG
LinearSolverISTLAMG()
{
Opm::parameter::ParameterGroup params;
params.insertParameter("linsolver_tolerance",
boost::lexical_cast<std::string>(5.0e-9));
params.insertParameter("linsoler_verbosity",
boost::lexical_cast<std::string>(1));
params.insertParameter("linsolver_type",
boost::lexical_cast<std::string>(1));
ls_.init(params);
}
示例3:
inline void UpscalerBase<Traits>::initFinal(const Opm::parameter::ParameterGroup& param)
{
// Report any unused parameters.
std::cout << "==================== Unused parameters: ====================\n";
param.displayUsage();
std::cout << "================================================================\n";
}
示例4: createEclipseWriter
Opm::EclipseWriterPtr createEclipseWriter(Opm::DeckConstPtr deck,
Opm::EclipseStatePtr eclipseState,
std::string& eclipse_data_filename) {
Opm::parameter::ParameterGroup params;
params.insertParameter("deck_filename", eclipse_data_filename);
const Opm::PhaseUsage phaseUsage = Opm::phaseUsageFromDeck(deck);
Opm::EclipseWriterPtr eclWriter(new Opm::EclipseWriter(params,
eclipseState,
phaseUsage,
eclipseState->getEclipseGrid()->getCartesianSize(),
0));
return eclWriter;
}
示例5: init
/// Initialize the grid.
void CpGrid::init(const Opm::parameter::ParameterGroup& param)
{
std::string fileformat = param.get<std::string>("fileformat");
if (fileformat == "sintef_legacy") {
std::string grid_prefix = param.get<std::string>("grid_prefix");
readSintefLegacyFormat(grid_prefix);
} else if (fileformat == "eclipse") {
std::string filename = param.get<std::string>("filename");
if (param.has("z_tolerance")) {
std::cerr << "****** Warning: z_tolerance parameter is obsolete, use PINCH in deck input instead\n";
}
bool periodic_extension = param.getDefault<bool>("periodic_extension", false);
bool turn_normals = param.getDefault<bool>("turn_normals", false);
readEclipseFormat(filename, periodic_extension, turn_normals);
} else if (fileformat == "cartesian") {
array<int, 3> dims = {{ param.getDefault<int>("nx", 1),
param.getDefault<int>("ny", 1),
param.getDefault<int>("nz", 1) }};
array<double, 3> cellsz = {{ param.getDefault<double>("dx", 1.0),
param.getDefault<double>("dy", 1.0),
param.getDefault<double>("dz", 1.0) }};
createCartesian(dims, cellsz);
} else {
OPM_THROW(std::runtime_error, "Unknown file format string: " << fileformat);
}
}
示例6: createEclipseWriter
void createEclipseWriter(const char *deckString)
{
Opm::ParseContext parseContext;
Opm::ParserConstPtr parser(new Opm::Parser());
deck = parser->parseString(deckString, parseContext);
Opm::parameter::ParameterGroup params;
params.insertParameter("deck_filename", "foo.data");
eclipseState.reset(new Opm::EclipseState(deck , parseContext));
auto eclGrid = eclipseState->getEclipseGrid();
BOOST_CHECK(eclGrid->getNX() == 3);
BOOST_CHECK(eclGrid->getNY() == 3);
BOOST_CHECK(eclGrid->getNZ() == 3);
BOOST_CHECK(eclGrid->getCartesianSize() == 3*3*3);
simTimer.reset(new Opm::SimulatorTimer());
simTimer->init(eclipseState->getSchedule()->getTimeMap());
// also create an UnstructuredGrid (required to create a BlackoilState)
Opm::EclipseGridConstPtr constEclGrid(eclGrid);
ourFineGridManagerPtr.reset(new Opm::GridManager(constEclGrid));
const UnstructuredGrid &ourFinerUnstructuredGrid = *ourFineGridManagerPtr->c_grid();
BOOST_CHECK(ourFinerUnstructuredGrid.cartdims[0] == 3);
BOOST_CHECK(ourFinerUnstructuredGrid.cartdims[1] == 3);
BOOST_CHECK(ourFinerUnstructuredGrid.cartdims[2] == 3);
BOOST_CHECK(ourFinerUnstructuredGrid.number_of_cells == 3*3*3);
Opm::PhaseUsage phaseUsage = Opm::phaseUsageFromDeck(deck);
eclWriter.reset(new Opm::EclipseWriter(params,
eclipseState,
phaseUsage,
ourFinerUnstructuredGrid.number_of_cells,
0));
// this check is disabled so far, because UnstructuredGrid uses some weird definition
// of the term "face". For this grid, "number_of_faces" is 108 which is
// 2*6*numCells...
//BOOST_CHECK(ourFinerUnstructuredGrid.number_of_faces == 4*4*4);
int numCells = ourFinerUnstructuredGrid.number_of_cells;
for (int cellIdx = 0; cellIdx < numCells; ++cellIdx)
BOOST_CHECK(ourFinerUnstructuredGrid.global_cell[cellIdx] == cellIdx);
}
示例7: initSources
virtual void initSources(const Opm::parameter::ParameterGroup& param)
{
// Zero-initializing first.
int nc = this->ginterf_.numberOfCells();
this->injection_rates_ = Opm::SparseVector<double>(nc);
this->injection_rates_psolver_.resize(nc, 0.0);
// this->injection_rates_.addElement(1.0, 0);
// this->injection_rates_psolver_[0] = 1.0;
// this->injection_rates_.addElement(-1.0, nc-1);
// this->injection_rates_psolver_[nc-1] = -1.0;
// Initializing blocks.
double total_inj = 0.0;
bool has_inj_block = param.getDefault("has_inj_block", false);
if (has_inj_block) {
Vector low;
low[0] = param.getDefault("inj_block_low_x", 0.0);
low[1] = param.getDefault("inj_block_low_y", 0.0);
low[2] = param.getDefault("inj_block_low_z", 0.0);
Vector high;
high[0] = param.getDefault("inj_block_high_x", 1.0);
high[1] = param.getDefault("inj_block_high_y", 1.0);
high[2] = param.getDefault("inj_block_high_z", 1.0);
double inj_block_density = param.get<double>("inj_block_density");
total_inj = setSourceBlock(low, high, inj_block_density, true);
}
double total_prod = 0.0;
bool has_prod_block = param.getDefault("has_prod_block", false);
if (has_prod_block) {
Vector low;
low[0] = param.getDefault("prod_block_low_x", 0.0);
low[1] = param.getDefault("prod_block_low_y", 0.0);
low[2] = param.getDefault("prod_block_low_z", 0.0);
Vector high;
high[0] = param.getDefault("prod_block_high_x", 1.0);
high[1] = param.getDefault("prod_block_high_y", 1.0);
high[2] = param.getDefault("prod_block_high_z", 1.0);
double prod_block_density = param.get<double>("prod_block_density");
total_prod = setSourceBlock(low, high, prod_block_density, false);
}
if (has_inj_block || has_prod_block) {
std::cout << "Initialized injectors with total rate: " << total_inj
<< "\nInitialized producers with total rate: " << total_prod
<< std::endl;
}
}
示例8: setupRegionBasedConditions
inline void setupRegionBasedConditions(const Opm::parameter::ParameterGroup& param,
const GridInterface& g,
BCs& bcs)
{
// Extract region and pressure value for Dirichlet bcs.
typedef typename GridInterface::Vector Vector;
Vector low;
low[0] = param.getDefault("dir_block_low_x", 0.0);
low[1] = param.getDefault("dir_block_low_y", 0.0);
low[2] = param.getDefault("dir_block_low_z", 0.0);
Vector high;
high[0] = param.getDefault("dir_block_high_x", 1.0);
high[1] = param.getDefault("dir_block_high_y", 1.0);
high[2] = param.getDefault("dir_block_high_z", 1.0);
double dir_block_pressure = param.get<double>("dir_block_pressure");
// Set flow conditions for that region.
// For this to work correctly, unique boundary ids should be used,
// otherwise conditions may spread outside the given region, to all
// faces with the same bid as faces inside the region.
typedef typename GridInterface::CellIterator CI;
typedef typename CI::FaceIterator FI;
int max_bid = 0;
std::vector<int> dir_bids;
for (CI c = g.cellbegin(); c != g.cellend(); ++c) {
for (FI f = c->facebegin(); f != c->faceend(); ++f) {
int bid = f->boundaryId();
max_bid = std::max(bid, max_bid);
if (bid != 0 && isInside(low, high, f->centroid())) {
dir_bids.push_back(bid);
}
}
}
bcs.resize(max_bid + 1);
for (std::vector<int>::const_iterator it = dir_bids.begin(); it != dir_bids.end(); ++it) {
bcs.flowCond(*it) = FlowBC(FlowBC::Dirichlet, dir_block_pressure);
}
// Transport BCs are defaulted.
}
示例9: init
/// @brief Initialization from parameters.
/// @param param a parameter object
void init(const Opm::parameter::ParameterGroup& param)
{
initControl(param);
initGridAndProps(param);
initInitialConditions(param);
initBoundaryConditions(param);
initSources(param);
initSolvers(param);
// Write any unused parameters.
std::cout << "==================== Unused parameters: ====================\n";
param.displayUsage();
std::cout << "================================================================\n";
}
示例10:
inline void EulerUpstreamImplicit<GI, RP, BC>::init(const Opm::parameter::ParameterGroup& param)
{
check_sat_ = param.getDefault("check_sat", check_sat_);
clamp_sat_ = param.getDefault("clamp_sat", clamp_sat_);
//Opm::ImplicitTransportDetails::NRControl ctrl_;
ctrl_.max_it = param.getDefault("transport_nr_max_it", 10);
max_repeats_ = param.getDefault("transport_max_rep", 10);
ctrl_.atol = param.getDefault("transport_atol", 1.0e-6);
ctrl_.rtol = param.getDefault("transport_rtol", 5.0e-7);
ctrl_.max_it_ls = param.getDefault("transport_max_it_ls", 20);
ctrl_.dxtol = param.getDefault("transport_dxtol", 1e-6);
ctrl_.verbosity = param.getDefault("transport_verbosity", 0);
}
示例11: setupGridAndProps
inline void setupGridAndProps(const Opm::parameter::ParameterGroup& param,
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") {
std::array<int, 3> dims = {{ param.getDefault<int>("nx", 1),
param.getDefault<int>("ny", 1),
param.getDefault<int>("nz", 1) }};
std::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);
OPM_MESSAGE("Warning: For generated cartesian grids, we use uniform reservoir properties.");
res_prop.init(grid.size(0), default_poro, default_perm);
} else {
OPM_THROW(std::runtime_error, "Dune::SGrid can only handle cartesian grids, unsupported file format string: " << fileformat);
}
}
示例12:
inline void EulerUpstream<GI, RP, BC>::init(const Opm::parameter::ParameterGroup& param)
{
courant_number_ = param.getDefault("courant_number", courant_number_);
method_viscous_ = param.getDefault("method_viscous", method_viscous_);
method_gravity_ = param.getDefault("method_gravity", method_gravity_);
method_capillary_ = param.getDefault("method_capillary", method_capillary_);
use_cfl_viscous_ = param.getDefault("use_cfl_viscous", use_cfl_viscous_);
use_cfl_gravity_ = param.getDefault("use_cfl_gravity", use_cfl_gravity_);
use_cfl_capillary_ = param.getDefault("use_cfl_capillary", use_cfl_capillary_);
minimum_small_steps_ = param.getDefault("minimum_small_steps", minimum_small_steps_);
maximum_small_steps_ = param.getDefault("maximum_small_steps", maximum_small_steps_);
check_sat_ = param.getDefault("check_sat", check_sat_);
clamp_sat_ = param.getDefault("clamp_sat", clamp_sat_);
}
示例13: init
void LinearSolverISTL::init(const Opm::parameter::ParameterGroup& param)
{
linsolver_residual_tolerance_ = param.getDefault("linsolver_residual_tolerance", linsolver_residual_tolerance_);
linsolver_verbosity_ = param.getDefault("linsolver_verbosity", linsolver_verbosity_);
linsolver_type_ = LinsolverType(param.getDefault("linsolver_type", int(linsolver_type_)));
linsolver_save_system_ = param.getDefault("linsolver_save_system", linsolver_save_system_);
if (linsolver_save_system_) {
linsolver_save_filename_ = param.getDefault("linsolver_save_filename", std::string("linsys"));
}
linsolver_max_iterations_ = param.getDefault("linsolver_max_iterations", linsolver_max_iterations_);
}
示例14:
inline void ImplicitCapillarity<GI, RP, BC, IP>::init(const Opm::parameter::ParameterGroup& param)
{
method_viscous_ = param.getDefault("method_viscous", method_viscous_);
method_gravity_ = param.getDefault("method_gravity", method_gravity_);
check_sat_ = param.getDefault("check_sat", check_sat_);
clamp_sat_ = param.getDefault("clamp_sat", clamp_sat_);
residual_tolerance_ = param.getDefault("residual_tolerance", residual_tolerance_);
linsolver_verbosity_ = param.getDefault("linsolver_verbosity", linsolver_verbosity_);
linsolver_type_ = param.getDefault("linsolver_type", linsolver_type_);
update_relaxation_ = param.getDefault("update_relaxation", update_relaxation_);
}
示例15: setupBoundaryConditions
inline void setupBoundaryConditions(const Opm::parameter::ParameterGroup& param,
const GridInterface& g,
BCs& bcs)
{
if (param.getDefault("upscaling", false)) {
int bct = param.get<int>("boundary_condition_type");
int pddir = param.getDefault("pressure_drop_direction", 0);
double pdrop = param.getDefault("boundary_pressuredrop", 1.0e5);
double bdy_sat = param.getDefault("boundary_saturation", 1.0);
bool twodim_hack = param.getDefault("2d_hack", false);
setupUpscalingConditions(g, bct, pddir, pdrop, bdy_sat, twodim_hack, bcs);
return;
}
if (param.getDefault("region_based_bcs", false)) {
setupRegionBasedConditions(param, g, bcs);
return;
}
// Make flow equation boundary conditions.
// Default is pressure 1.0e5 on the left, 0.0 on the right.
// Recall that the boundary ids range from 1 to 6 for the cartesian edges,
// and that boundary id 0 means interiour face/intersection.
std::string flow_bc_type = param.getDefault<std::string>("flow_bc_type", "dirichlet");
FlowBC::BCType bct = FlowBC::Dirichlet;
double leftval = 1.0*Opm::unit::barsa;
double rightval = 0.0;
if (flow_bc_type == "neumann") {
bct = FlowBC::Neumann;
leftval = param.get<double>("left_flux");
rightval = param.getDefault<double>("right_flux", -leftval);
} else if (flow_bc_type == "dirichlet") {
leftval = param.getDefault<double>("left_pressure", leftval);
rightval = param.getDefault<double>("right_pressure", rightval);
} else if (flow_bc_type == "periodic") {
THROW("Periodic conditions not here yet.");
} else {
THROW("Unknown flow boundary condition type " << flow_bc_type);
}
bcs.resize(7);
bcs.flowCond(1) = FlowBC(bct, leftval);
bcs.flowCond(2) = FlowBC(bct, rightval);
// Default transport boundary conditions are used.
}