mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Use BCConfig when setting up boundary conditions
This commit is contained in:
parent
c9ef6ac843
commit
bc718bafc8
@ -2996,13 +2996,13 @@ private:
|
|||||||
nonTrivialBoundaryConditions_ = false;
|
nonTrivialBoundaryConditions_ = false;
|
||||||
const auto& simulator = this->simulator();
|
const auto& simulator = this->simulator();
|
||||||
const auto& vanguard = simulator.vanguard();
|
const auto& vanguard = simulator.vanguard();
|
||||||
|
const auto& bcconfig = vanguard.eclState().getSimulationConfig().bcconfig();
|
||||||
if (vanguard.deck().hasKeyword("BC")) {
|
if (bcconfig.size() > 0) {
|
||||||
nonTrivialBoundaryConditions_ = true;
|
nonTrivialBoundaryConditions_ = true;
|
||||||
|
|
||||||
size_t numCartDof = vanguard.cartesianSize();
|
size_t numCartDof = vanguard.cartesianSize();
|
||||||
unsigned numElems = vanguard.gridView().size(/*codim=*/0);
|
unsigned numElems = vanguard.gridView().size(/*codim=*/0);
|
||||||
std::vector<int> cartesianToCompressedElemIdx(numCartDof);
|
std::vector<int> cartesianToCompressedElemIdx(numCartDof, -1);
|
||||||
|
|
||||||
for (unsigned elemIdx = 0; elemIdx < numElems; ++elemIdx)
|
for (unsigned elemIdx = 0; elemIdx < numElems; ++elemIdx)
|
||||||
cartesianToCompressedElemIdx[vanguard.cartesianIndex(elemIdx)] = elemIdx;
|
cartesianToCompressedElemIdx[vanguard.cartesianIndex(elemIdx)] = elemIdx;
|
||||||
@ -3020,106 +3020,106 @@ private:
|
|||||||
freebcZ_.resize(numElems, false);
|
freebcZ_.resize(numElems, false);
|
||||||
freebcZMinus_.resize(numElems, false);
|
freebcZMinus_.resize(numElems, false);
|
||||||
|
|
||||||
const auto& bcs = vanguard.deck().getKeywordList("BC");
|
for (const auto& bcface : bcconfig) {
|
||||||
for (size_t listIdx = 0; listIdx < bcs.size(); ++listIdx) {
|
const auto& type = bcface.bctype;
|
||||||
const auto& bc = *bcs[listIdx];
|
if (type == BCType::RATE) {
|
||||||
|
int compIdx;
|
||||||
|
|
||||||
for (size_t record = 0; record < bc.size(); ++record) {
|
switch (bcface.component) {
|
||||||
|
case BCComponent::OIL:
|
||||||
std::string type = bc.getRecord(record).getItem("TYPE").getTrimmedString(0);
|
|
||||||
std::string compName = bc.getRecord(record).getItem("COMPONENT").getTrimmedString(0);
|
|
||||||
int compIdx = -999;
|
|
||||||
|
|
||||||
if (compName == "OIL")
|
|
||||||
compIdx = oilCompIdx;
|
compIdx = oilCompIdx;
|
||||||
else if (compName == "GAS")
|
break;
|
||||||
|
case BCComponent::GAS:
|
||||||
compIdx = gasCompIdx;
|
compIdx = gasCompIdx;
|
||||||
else if (compName == "WATER")
|
break;
|
||||||
|
case BCComponent::WATER:
|
||||||
compIdx = waterCompIdx;
|
compIdx = waterCompIdx;
|
||||||
else if (compName == "SOLVENT")
|
break;
|
||||||
{
|
case BCComponent::SOLVENT:
|
||||||
if (!enableSolvent)
|
if (!enableSolvent)
|
||||||
throw std::logic_error("solvent is disabled and you're trying to add solvent to BC");
|
throw std::logic_error("solvent is disabled and you're trying to add solvent to BC");
|
||||||
|
|
||||||
compIdx = Indices::solventSaturationIdx;
|
compIdx = Indices::solventSaturationIdx;
|
||||||
}
|
break;
|
||||||
else if (compName == "POLYMER")
|
case BCComponent::POLYMER:
|
||||||
{
|
|
||||||
if (!enablePolymer)
|
if (!enablePolymer)
|
||||||
throw std::logic_error("polymer is disabled and you're trying to add polymer to BC");
|
throw std::logic_error("polymer is disabled and you're trying to add polymer to BC");
|
||||||
|
|
||||||
compIdx = Indices::polymerConcentrationIdx;
|
compIdx = Indices::polymerConcentrationIdx;
|
||||||
}
|
break;
|
||||||
else if (compName == "NONE")
|
case BCComponent::NONE:
|
||||||
{
|
if (type == BCType::RATE)
|
||||||
if ( type == "RATE")
|
|
||||||
throw std::logic_error("you need to specify the component when RATE type is set in BC");
|
throw std::logic_error("you need to specify the component when RATE type is set in BC");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
throw std::logic_error("invalid component name for BC");
|
|
||||||
|
|
||||||
int i1 = bc.getRecord(record).getItem("I1").template get< int >(0) - 1;
|
std::vector<RateVector>* data = nullptr;
|
||||||
int i2 = bc.getRecord(record).getItem("I2").template get< int >(0) - 1;
|
switch (bcface.dir) {
|
||||||
int j1 = bc.getRecord(record).getItem("J1").template get< int >(0) - 1;
|
case FaceDir::XMinus:
|
||||||
int j2 = bc.getRecord(record).getItem("J2").template get< int >(0) - 1;
|
|
||||||
int k1 = bc.getRecord(record).getItem("K1").template get< int >(0) - 1;
|
|
||||||
int k2 = bc.getRecord(record).getItem("K2").template get< int >(0) - 1;
|
|
||||||
std::string direction = bc.getRecord(record).getItem("DIRECTION").getTrimmedString(0);
|
|
||||||
|
|
||||||
if (type == "RATE") {
|
|
||||||
assert(compIdx >= 0);
|
|
||||||
std::vector<RateVector>* data = 0;
|
|
||||||
if (direction == "X-")
|
|
||||||
data = &massratebcXMinus_;
|
data = &massratebcXMinus_;
|
||||||
else if (direction == "X")
|
break;
|
||||||
|
case FaceDir::XPlus:
|
||||||
data = &massratebcX_;
|
data = &massratebcX_;
|
||||||
else if (direction == "Y-")
|
break;
|
||||||
|
case FaceDir::YMinus:
|
||||||
data = &massratebcYMinus_;
|
data = &massratebcYMinus_;
|
||||||
else if (direction == "Y")
|
break;
|
||||||
|
case FaceDir::YPlus:
|
||||||
data = &massratebcY_;
|
data = &massratebcY_;
|
||||||
else if (direction == "Z-")
|
break;
|
||||||
|
case FaceDir::ZMinus:
|
||||||
data = &massratebcZMinus_;
|
data = &massratebcZMinus_;
|
||||||
else if (direction == "Z")
|
break;
|
||||||
|
case FaceDir::ZPlus:
|
||||||
data = &massratebcZ_;
|
data = &massratebcZ_;
|
||||||
else
|
break;
|
||||||
throw std::logic_error("invalid direction for BC");
|
}
|
||||||
|
|
||||||
const Evaluation rate = bc.getRecord(record).getItem("RATE").getSIDouble(0);
|
const Evaluation rate = bcface.rate;
|
||||||
for (int i = i1; i <= i2; ++i) {
|
for (int i = bcface.i1; i <= bcface.i2; ++i) {
|
||||||
for (int j = j1; j <= j2; ++j) {
|
for (int j = bcface.j1; j <= bcface.j2; ++j) {
|
||||||
for (int k = k1; k <= k2; ++k) {
|
for (int k = bcface.k1; k <= bcface.k2; ++k) {
|
||||||
std::array<int, 3> tmp = {i,j,k};
|
std::array<int, 3> tmp = {i,j,k};
|
||||||
size_t elemIdx = cartesianToCompressedElemIdx[vanguard.cartesianIndex(tmp)];
|
auto elemIdx = cartesianToCompressedElemIdx[vanguard.cartesianIndex(tmp)];
|
||||||
|
if (elemIdx >= 0)
|
||||||
(*data)[elemIdx][compIdx] = rate;
|
(*data)[elemIdx][compIdx] = rate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (type == "FREE") {
|
} else if (type == BCType::FREE) {
|
||||||
std::vector<bool>* data = 0;
|
std::vector<bool>* data = nullptr;
|
||||||
if (direction == "X-")
|
switch (bcface.dir) {
|
||||||
|
case FaceDir::XMinus:
|
||||||
data = &freebcXMinus_;
|
data = &freebcXMinus_;
|
||||||
else if (direction == "X")
|
break;
|
||||||
|
case FaceDir::XPlus:
|
||||||
data = &freebcX_;
|
data = &freebcX_;
|
||||||
else if (direction == "Y-")
|
break;
|
||||||
|
case FaceDir::YMinus:
|
||||||
data = &freebcYMinus_;
|
data = &freebcYMinus_;
|
||||||
else if (direction == "Y")
|
break;
|
||||||
|
case FaceDir::YPlus:
|
||||||
data = &freebcY_;
|
data = &freebcY_;
|
||||||
else if (direction == "Z-")
|
break;
|
||||||
|
case FaceDir::ZMinus:
|
||||||
data = &freebcZMinus_;
|
data = &freebcZMinus_;
|
||||||
else if (direction == "Z")
|
break;
|
||||||
|
case FaceDir::ZPlus:
|
||||||
data = &freebcZ_;
|
data = &freebcZ_;
|
||||||
else
|
break;
|
||||||
throw std::logic_error("invalid direction for BC");
|
}
|
||||||
|
|
||||||
for (int i = i1; i <= i2; ++i) {
|
for (int i = bcface.i1; i <= bcface.i2; ++i) {
|
||||||
for (int j = j1; j <= j2; ++j) {
|
for (int j = bcface.j1; j <= bcface.j2; ++j) {
|
||||||
for (int k = k1; k <= k2; ++k) {
|
for (int k = bcface.k1; k <= bcface.k2; ++k) {
|
||||||
std::array<int, 3> tmp = {i,j,k};
|
std::array<int, 3> tmp = {i,j,k};
|
||||||
size_t elemIdx = cartesianToCompressedElemIdx[vanguard.cartesianIndex(tmp)];
|
auto elemIdx = cartesianToCompressedElemIdx[vanguard.cartesianIndex(tmp)];
|
||||||
|
if (elemIdx >= 0)
|
||||||
(*data)[elemIdx] = true;
|
(*data)[elemIdx] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: either the real initial solution needs to be computed or read from the restart file
|
// TODO: either the real initial solution needs to be computed or read from the restart file
|
||||||
const auto& eclState = simulator.vanguard().eclState();
|
const auto& eclState = simulator.vanguard().eclState();
|
||||||
const auto& initconfig = eclState.getInitConfig();
|
const auto& initconfig = eclState.getInitConfig();
|
||||||
@ -3132,7 +3132,6 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// this method applies the runtime constraints specified via the deck and/or command
|
// this method applies the runtime constraints specified via the deck and/or command
|
||||||
// line parameters for the size of the next time step.
|
// line parameters for the size of the next time step.
|
||||||
|
Loading…
Reference in New Issue
Block a user