mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
changed: use BCData struct for freebc
This commit is contained in:
parent
95ab3427e2
commit
586b88d3ad
@ -1670,47 +1670,11 @@ public:
|
|||||||
unsigned interiorDofIdx = context.interiorScvIndex(spaceIdx, timeIdx);
|
unsigned interiorDofIdx = context.interiorScvIndex(spaceIdx, timeIdx);
|
||||||
unsigned globalDofIdx = context.globalSpaceIndex(interiorDofIdx, timeIdx);
|
unsigned globalDofIdx = context.globalSpaceIndex(interiorDofIdx, timeIdx);
|
||||||
unsigned pvtRegionIdx = pvtRegionIndex(context, spaceIdx, timeIdx);
|
unsigned pvtRegionIdx = pvtRegionIndex(context, spaceIdx, timeIdx);
|
||||||
switch (indexInInside) {
|
FaceDir::DirEnum dir = FaceDir::FromIntersectionIndex(indexInInside);
|
||||||
case 0:
|
if (freebc_(dir)[globalDofIdx])
|
||||||
if (freebcXMinus_[globalDofIdx])
|
values.setFreeFlow(context, spaceIdx, timeIdx, initialFluidStates_[globalDofIdx]);
|
||||||
values.setFreeFlow(context, spaceIdx, timeIdx, initialFluidStates_[globalDofIdx]);
|
else
|
||||||
else
|
values.setMassRate(massratebc_(dir)[globalDofIdx], pvtRegionIdx);
|
||||||
values.setMassRate(massratebc_.data[1][globalDofIdx], pvtRegionIdx);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
if (freebcX_[globalDofIdx])
|
|
||||||
values.setFreeFlow(context, spaceIdx, timeIdx, initialFluidStates_[globalDofIdx]);
|
|
||||||
else
|
|
||||||
values.setMassRate(massratebc_.data[0][globalDofIdx], pvtRegionIdx);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if (freebcYMinus_[globalDofIdx])
|
|
||||||
values.setFreeFlow(context, spaceIdx, timeIdx, initialFluidStates_[globalDofIdx]);
|
|
||||||
else
|
|
||||||
values.setMassRate(massratebc_.data[3][globalDofIdx], pvtRegionIdx);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
if (freebcY_[globalDofIdx])
|
|
||||||
values.setFreeFlow(context, spaceIdx, timeIdx, initialFluidStates_[globalDofIdx]);
|
|
||||||
else
|
|
||||||
values.setMassRate(massratebc_.data[2][globalDofIdx], pvtRegionIdx);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
if (freebcZMinus_[globalDofIdx])
|
|
||||||
values.setFreeFlow(context, spaceIdx, timeIdx, initialFluidStates_[globalDofIdx]);
|
|
||||||
else
|
|
||||||
values.setMassRate(massratebc_.data[5][globalDofIdx], pvtRegionIdx);
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
if (freebcZ_[globalDofIdx])
|
|
||||||
values.setFreeFlow(context, spaceIdx, timeIdx, initialFluidStates_[globalDofIdx]);
|
|
||||||
else
|
|
||||||
values.setMassRate(massratebc_.data[4][globalDofIdx], pvtRegionIdx);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw std::logic_error("invalid face index for boundary condition");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2079,22 +2043,8 @@ public:
|
|||||||
if (!nonTrivialBoundaryConditions_) {
|
if (!nonTrivialBoundaryConditions_) {
|
||||||
return { false, RateVector(0.0) };
|
return { false, RateVector(0.0) };
|
||||||
}
|
}
|
||||||
switch (directionId) {
|
FaceDir::DirEnum dir = FaceDir::FromIntersectionIndex(directionId);
|
||||||
case 0:
|
return { freebc_(dir)[globalSpaceIdx], massratebc_(dir)[globalSpaceIdx] };
|
||||||
return { freebcXMinus_[globalSpaceIdx], massratebc_.data[1][globalSpaceIdx] };
|
|
||||||
case 1:
|
|
||||||
return { freebcX_[globalSpaceIdx], massratebc_.data[0][globalSpaceIdx] };
|
|
||||||
case 2:
|
|
||||||
return { freebcYMinus_[globalSpaceIdx], massratebc_.data[3][globalSpaceIdx] };
|
|
||||||
case 3:
|
|
||||||
return { freebcY_[globalSpaceIdx], massratebc_.data[2][globalSpaceIdx] };
|
|
||||||
case 4:
|
|
||||||
return { freebcZMinus_[globalSpaceIdx], massratebc_.data[5][globalSpaceIdx] };
|
|
||||||
case 5:
|
|
||||||
return { freebcZ_[globalSpaceIdx], massratebc_.data[4][globalSpaceIdx] };
|
|
||||||
default:
|
|
||||||
return { false, RateVector(0.0) };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -2790,12 +2740,23 @@ private:
|
|||||||
cartesianToCompressedElemIdx[vanguard.cartesianIndex(elemIdx)] = elemIdx;
|
cartesianToCompressedElemIdx[vanguard.cartesianIndex(elemIdx)] = elemIdx;
|
||||||
|
|
||||||
massratebc_.resize(numElems, 0.0);
|
massratebc_.resize(numElems, 0.0);
|
||||||
freebcX_.resize(numElems, false);
|
freebc_.resize(numElems, false);
|
||||||
freebcXMinus_.resize(numElems, false);
|
|
||||||
freebcY_.resize(numElems, false);
|
auto loopAndApply = [&cartesianToCompressedElemIdx,
|
||||||
freebcYMinus_.resize(numElems, false);
|
&vanguard](const auto& bcface,
|
||||||
freebcZ_.resize(numElems, false);
|
auto apply)
|
||||||
freebcZMinus_.resize(numElems, false);
|
{
|
||||||
|
for (int i = bcface.i1; i <= bcface.i2; ++i) {
|
||||||
|
for (int j = bcface.j1; j <= bcface.j2; ++j) {
|
||||||
|
for (int k = bcface.k1; k <= bcface.k2; ++k) {
|
||||||
|
std::array<int, 3> tmp = {i,j,k};
|
||||||
|
auto elemIdx = cartesianToCompressedElemIdx[vanguard.cartesianIndex(tmp)];
|
||||||
|
if (elemIdx >= 0)
|
||||||
|
apply(elemIdx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
for (const auto& bcface : bcconfig) {
|
for (const auto& bcface : bcconfig) {
|
||||||
const auto& type = bcface.bctype;
|
const auto& type = bcface.bctype;
|
||||||
@ -2832,51 +2793,13 @@ private:
|
|||||||
std::vector<RateVector>& data = massratebc_(bcface.dir);
|
std::vector<RateVector>& data = massratebc_(bcface.dir);
|
||||||
|
|
||||||
const Evaluation rate = bcface.rate;
|
const Evaluation rate = bcface.rate;
|
||||||
for (int i = bcface.i1; i <= bcface.i2; ++i) {
|
loopAndApply(bcface,
|
||||||
for (int j = bcface.j1; j <= bcface.j2; ++j) {
|
[&data,compIdx,rate](int elemIdx)
|
||||||
for (int k = bcface.k1; k <= bcface.k2; ++k) {
|
{ data[elemIdx][compIdx] = rate; });
|
||||||
std::array<int, 3> tmp = {i,j,k};
|
|
||||||
auto elemIdx = cartesianToCompressedElemIdx[vanguard.cartesianIndex(tmp)];
|
|
||||||
if (elemIdx >= 0)
|
|
||||||
data[elemIdx][compIdx] = rate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (type == BCType::FREE) {
|
} else if (type == BCType::FREE) {
|
||||||
std::vector<bool>* data = nullptr;
|
std::vector<bool>& data = freebc_(bcface.dir);
|
||||||
switch (bcface.dir) {
|
loopAndApply(bcface,
|
||||||
case FaceDir::XMinus:
|
[&data](int elemIdx) { data[elemIdx] = true; });
|
||||||
data = &freebcXMinus_;
|
|
||||||
break;
|
|
||||||
case FaceDir::XPlus:
|
|
||||||
data = &freebcX_;
|
|
||||||
break;
|
|
||||||
case FaceDir::YMinus:
|
|
||||||
data = &freebcYMinus_;
|
|
||||||
break;
|
|
||||||
case FaceDir::YPlus:
|
|
||||||
data = &freebcY_;
|
|
||||||
break;
|
|
||||||
case FaceDir::ZMinus:
|
|
||||||
data = &freebcZMinus_;
|
|
||||||
break;
|
|
||||||
case FaceDir::ZPlus:
|
|
||||||
data = &freebcZ_;
|
|
||||||
break;
|
|
||||||
case FaceDir::Unknown:
|
|
||||||
throw std::runtime_error("Unexpected unknown face direction");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = bcface.i1; i <= bcface.i2; ++i) {
|
|
||||||
for (int j = bcface.j1; j <= bcface.j2; ++j) {
|
|
||||||
for (int k = bcface.k1; k <= bcface.k2; ++k) {
|
|
||||||
std::array<int, 3> tmp = {i,j,k};
|
|
||||||
auto elemIdx = cartesianToCompressedElemIdx[vanguard.cartesianIndex(tmp)];
|
|
||||||
if (elemIdx >= 0)
|
|
||||||
(*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();
|
||||||
@ -3020,15 +2943,9 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<bool> freebcX_;
|
BCData<bool> freebc_;
|
||||||
std::vector<bool> freebcXMinus_;
|
|
||||||
std::vector<bool> freebcY_;
|
|
||||||
std::vector<bool> freebcYMinus_;
|
|
||||||
std::vector<bool> freebcZ_;
|
|
||||||
std::vector<bool> freebcZMinus_;
|
|
||||||
|
|
||||||
bool nonTrivialBoundaryConditions_ = false;
|
|
||||||
BCData<RateVector> massratebc_;
|
BCData<RateVector> massratebc_;
|
||||||
|
bool nonTrivialBoundaryConditions_ = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
Loading…
Reference in New Issue
Block a user