36#ifndef OPENRS_SETUPBOUNDARYCONDITIONS_HEADER 
   37#define OPENRS_SETUPBOUNDARYCONDITIONS_HEADER 
   39#include <opm/core/utility/parameters/ParameterGroup.hpp> 
   40#include <opm/core/utility/Units.hpp> 
   50    template <
class Gr
idInterface, 
class BCs>
 
   52                    const GridInterface& g,
 
   55    if (param.getDefault(
"upscaling", 
false)) {
 
   56        int bct = param.get<
int>(
"boundary_condition_type");
 
   57        int pddir = param.getDefault(
"pressure_drop_direction", 0);
 
   58        double pdrop = param.getDefault(
"boundary_pressuredrop", 1.0e5);
 
   59        double bdy_sat = param.getDefault(
"boundary_saturation", 1.0);
 
   60        bool twodim_hack = param.getDefault(
"2d_hack", 
false);
 
   64        if (param.getDefault(
"region_based_bcs", 
false)) {
 
   72    std::string flow_bc_type = param.getDefault<std::string>(
"flow_bc_type", 
"dirichlet");
 
   74    double leftval = 1.0*Opm::unit::barsa;
 
   75    double rightval = 0.0;
 
   76    if (flow_bc_type == 
"neumann") {
 
   78        leftval = param.get<
double>(
"left_flux");
 
   79        rightval = param.getDefault<
double>(
"right_flux", -leftval);
 
   80    } 
else if (flow_bc_type == 
"dirichlet") {
 
   81        leftval = param.getDefault<
double>(
"left_pressure", leftval);
 
   82        rightval = param.getDefault<
double>(
"right_pressure", rightval);
 
   83    } 
else if (flow_bc_type == 
"periodic") {
 
   84        OPM_THROW(std::runtime_error, 
"Periodic conditions not here yet.");
 
   86        OPM_THROW(std::runtime_error, 
"Unknown flow boundary condition type " << flow_bc_type);
 
   89    bcs.flowCond(1) = 
FlowBC(bct, leftval);
 
   90    bcs.flowCond(2) = 
FlowBC(bct, rightval);
 
   98    template <
class Gr
idInterface, 
class BCs>
 
  108    enum BoundaryConditionType { Fixed = 0, Linear = 1, Periodic = 2, PeriodicSingleDirection = 3, Noflow = 4 };
 
  109        if (bct < 0 || bct > 2) {
 
  110            OPM_THROW(std::runtime_error, 
"Illegal boundary condition type (0-2 are legal): " << bct); 
 
  112    BoundaryConditionType bctype = 
static_cast<BoundaryConditionType
>(bct);
 
  113        assert(pddir >=0 && pddir <= 2);
 
  125        for (
int i = 0; i < 7; ++i) {
 
  126            bcs.setCanonicalBoundaryId(i, i);
 
  133        createLinear(bcs, g, pdrop, pddir, bdy_sat, twodim_hack);
 
  140        std::array<FlowBC, 6> fcond = {{ fb, fb, fb, fb, fb, fb }};
 
  144        std::array<SatBC, 6> scond = {{ sb, sb, sb, sb, sb, sb }};
 
  159        OPM_THROW(std::runtime_error, 
"Error in switch statement, should never be here.");
 
  169        template <
class Vector>
 
  170        bool isInside(
const Vector& low, 
const Vector& high, 
const Vector& pt)
 
  172            return low[0] < pt[0]
 
  182    template <
class Gr
idInterface, 
class BCs>
 
  184                                           const GridInterface& g,
 
  188        typedef typename GridInterface::Vector Vector;
 
  190        low[0] = param.getDefault(
"dir_block_low_x", 0.0);
 
  191        low[1] = param.getDefault(
"dir_block_low_y", 0.0);
 
  192        low[2] = param.getDefault(
"dir_block_low_z", 0.0);
 
  194        high[0] = param.getDefault(
"dir_block_high_x", 1.0);
 
  195        high[1] = param.getDefault(
"dir_block_high_y", 1.0);
 
  196        high[2] = param.getDefault(
"dir_block_high_z", 1.0);
 
  197        double dir_block_pressure = param.get<
double>(
"dir_block_pressure");
 
  203        typedef typename GridInterface::CellIterator CI;
 
  204        typedef typename CI::FaceIterator FI;
 
  206        std::vector<int> dir_bids;
 
  207        for (CI c = g.cellbegin(); c != g.cellend(); ++c) {
 
  208            for (FI f = c->facebegin(); f != c->faceend(); ++f) {
 
  209                int bid = f->boundaryId();
 
  210                max_bid = std::max(bid, max_bid);
 
  211                if (bid != 0 && isInside(low, high, f->centroid())) {
 
  212                    dir_bids.push_back(bid);
 
  216        bcs.resize(max_bid + 1);
 
  217        for (std::vector<int>::const_iterator it = dir_bids.begin(); it != dir_bids.end(); ++it) {
 
BCType
Enum for the allowed boundary condition types. So far, we support Dirichlet, Neumann and Periodic con...
Definition: BoundaryConditions.hpp:58
 
@ Periodic
Definition: BoundaryConditions.hpp:58
 
@ Neumann
Definition: BoundaryConditions.hpp:58
 
@ Dirichlet
Definition: BoundaryConditions.hpp:58
 
A class for representing a flow boundary condition.
Definition: BoundaryConditions.hpp:122
 
A class for representing a saturation boundary condition.
Definition: BoundaryConditions.hpp:176
 
Definition: BlackoilFluid.hpp:32
 
void setupBoundaryConditions(const Opm::parameter::ParameterGroup ¶m, const GridInterface &g, BCs &bcs)
Setup boundary conditions for a simulation. It is assumed that the boundary ids are 1-6,...
Definition: setupBoundaryConditions.hpp:51
 
void setupRegionBasedConditions(const Opm::parameter::ParameterGroup ¶m, const GridInterface &g, BCs &bcs)
Definition: setupBoundaryConditions.hpp:183
 
void createLinear(BCs &fbcs, const GridInterface &g, const double pdrop, const int pddir, const double bdy_sat, const bool twodim_hack=false, const double spatial_tolerance=1e-6)
Makes a boundary condition object representing linear boundary conditions in any cartesian direction....
Definition: PeriodicHelpers.hpp:224
 
void setupUpscalingConditions(const GridInterface &g, int bct, int pddir, double pdrop, double bdy_sat, bool twodim_hack, BCs &bcs)
Definition: setupBoundaryConditions.hpp:99
 
void createPeriodic(BCs &fbcs, const GridInterface &g, const std::array< FlowBC, 2 *GridInterface::Dimension > &fconditions, const std::array< SatBC, 2 *GridInterface::Dimension > &sconditions, double spatial_tolerance=1e-6)
Makes a boundary condition object representing periodic boundary conditions in any cartesian directio...
Definition: PeriodicHelpers.hpp:105