36#ifndef OPENRS_SETUPBOUNDARYCONDITIONS_HEADER
37#define OPENRS_SETUPBOUNDARYCONDITIONS_HEADER
39#include <opm/common/utility/parameters/ParameterGroup.hpp>
40#include <opm/input/eclipse/Units/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,
111 "Illegal boundary condition type (0-2 are legal): " + std::to_string(bct));
113 BoundaryConditionType bctype =
static_cast<BoundaryConditionType
>(bct);
114 assert(pddir >=0 && pddir <= 2);
126 for (
int i = 0; i < 7; ++i) {
127 bcs.setCanonicalBoundaryId(i, i);
134 createLinear(bcs, g, pdrop, pddir, bdy_sat, twodim_hack);
141 std::array<FlowBC, 6> fcond = {{ fb, fb, fb, fb, fb, fb }};
145 std::array<SatBC, 6> scond = {{ sb, sb, sb, sb, sb, sb }};
160 OPM_THROW(std::runtime_error,
"Error in switch statement, should never be here.");
170 template <
class Vector>
173 return low[0] < pt[0]
183 template <
class Gr
idInterface,
class BCs>
185 const GridInterface& g,
191 low[0] = param.getDefault(
"dir_block_low_x", 0.0);
192 low[1] = param.getDefault(
"dir_block_low_y", 0.0);
193 low[2] = param.getDefault(
"dir_block_low_z", 0.0);
195 high[0] = param.getDefault(
"dir_block_high_x", 1.0);
196 high[1] = param.getDefault(
"dir_block_high_y", 1.0);
197 high[2] = param.getDefault(
"dir_block_high_z", 1.0);
198 double dir_block_pressure = param.get<
double>(
"dir_block_pressure");
204 typedef typename GridInterface::CellIterator CI;
205 typedef typename CI::FaceIterator FI;
207 std::vector<int> dir_bids;
208 for (CI c = g.cellbegin(); c != g.cellend(); ++c) {
209 for (FI f = c->facebegin(); f != c->faceend(); ++f) {
210 int bid = f->boundaryId();
211 max_bid = std::max(bid, max_bid);
212 if (bid != 0 && isInside(low, high, f->centroid())) {
213 dir_bids.push_back(bid);
217 bcs.resize(max_bid + 1);
218 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
Dune::BlockVector< Dune::FieldVector< double, 1 > > Vector
A vector holding our RHS.
Definition: matrixops.hpp:33
Definition: ImplicitAssembly.hpp:43
void setupRegionBasedConditions(const Opm::ParameterGroup ¶m, const GridInterface &g, BCs &bcs)
Definition: setupBoundaryConditions.hpp:184
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:220
void setupBoundaryConditions(const Opm::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 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