/// @brief Computes total absorbed polymer mass over all grid cells. /// @param[in] props fluid and rock properties. /// @param[in] polyprops polymer properties /// @param[in] pv the pore volume by cell. /// @param[in] cmax max polymer concentration for cell /// @return total absorbed polymer mass. double computePolymerAdsorbed(const IncompPropertiesInterface& props, const Opm::PolymerProperties& polyprops, const std::vector<double>& pv, const std::vector<double>& cmax) { const int num_cells = pv.size(); const double rhor = polyprops.rockDensity(); const double* poro = props.porosity(); double abs_mass = 0.0; for (int cell = 0; cell < num_cells; ++cell) { double c_ads; polyprops.simpleAdsorption(cmax[cell], c_ads); abs_mass += c_ads*pv[cell]*((1.0 - poro[cell])/poro[cell])*rhor; } return abs_mass; }
SimulatorIncompTwophase::Impl::Impl(const parameter::ParameterGroup& param, const UnstructuredGrid& grid, const IncompPropertiesInterface& props, const RockCompressibility* rock_comp_props, WellsManager& wells_manager, const std::vector<double>& src, const FlowBoundaryConditions* bcs, LinearSolverInterface& linsolver, const double* gravity) : use_reorder_(param.getDefault("use_reorder", true)), use_segregation_split_(param.getDefault("use_segregation_split", false)), grid_(grid), props_(props), rock_comp_props_(rock_comp_props), wells_manager_(wells_manager), wells_(wells_manager.c_wells()), src_(src), bcs_(bcs), psolver_(grid, props, rock_comp_props, linsolver, param.getDefault("nl_pressure_residual_tolerance", 0.0), param.getDefault("nl_pressure_change_tolerance", 1.0), param.getDefault("nl_pressure_maxiter", 10), gravity, wells_manager.c_wells(), src, bcs) { // Initialize transport solver. if (use_reorder_) { tsolver_.reset(new Opm::TransportSolverTwophaseReorder(grid, props, use_segregation_split_ ? gravity : NULL, param.getDefault("nl_tolerance", 1e-9), param.getDefault("nl_maxiter", 30))); } else { if (rock_comp_props && rock_comp_props->isActive()) { OPM_THROW(std::runtime_error, "The implicit pressure solver cannot handle rock compressibility."); } if (use_segregation_split_) { OPM_THROW(std::runtime_error, "The implicit pressure solver is not set up to use segregation splitting."); } std::vector<double> porevol; computePorevolume(grid, props.porosity(), porevol); tsolver_.reset(new Opm::TransportSolverTwophaseImplicit(grid, props, porevol, gravity, psolver_.getHalfTrans(), param)); } // For output. log_ = param.getDefault("quiet", false) ? &Opm::null_stream : &std::cout; output_ = param.getDefault("output", true); if (output_) { output_vtk_ = param.getDefault("output_vtk", true); output_dir_ = param.getDefault("output_dir", std::string("output")); // Ensure that output dir exists boost::filesystem::path fpath(output_dir_); try { create_directories(fpath); } catch (...) { OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath); } output_interval_ = param.getDefault("output_interval", 1); } // Well control related init. check_well_controls_ = param.getDefault("check_well_controls", false); max_well_control_iterations_ = param.getDefault("max_well_control_iterations", 10); // Transport related init. num_transport_substeps_ = param.getDefault("num_transport_substeps", 1); // Misc init. const int num_cells = grid.number_of_cells; allcells_.resize(num_cells); for (int cell = 0; cell < num_cells; ++cell) { allcells_[cell] = cell; } }