mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
fix a few review comments
This commit is contained in:
parent
339c76bcac
commit
46b52448aa
@ -65,7 +65,7 @@ namespace Opm
|
||||
AquiferCarterTracy( const AquiferCT::AQUCT_data& aquct_data,
|
||||
const Aquancon::AquanconOutput& connection,
|
||||
const Simulator& ebosSimulator)
|
||||
: simulator_ (ebosSimulator)
|
||||
: ebos_simulator_ (ebosSimulator)
|
||||
, aquct_data_ (aquct_data)
|
||||
, connection_(connection)
|
||||
{}
|
||||
@ -77,22 +77,22 @@ namespace Opm
|
||||
|
||||
void beginTimeStep()
|
||||
{
|
||||
ElementContext elemCtx(simulator_);
|
||||
auto elemIt = simulator_.gridView().template begin<0>();
|
||||
const auto& elemEndIt = simulator_.gridView().template end<0>();
|
||||
ElementContext elemCtx(ebos_simulator_);
|
||||
auto elemIt = ebos_simulator_.gridView().template begin<0>();
|
||||
const auto& elemEndIt = ebos_simulator_.gridView().template end<0>();
|
||||
for (; elemIt != elemEndIt; ++elemIt) {
|
||||
const auto& elem = *elemIt;
|
||||
|
||||
elemCtx.updatePrimaryStencil(elem);
|
||||
|
||||
int cellIdx = elemCtx.globalSpaceIndex(0, 0);
|
||||
int connIdx = cellToConnectionIdx_[cellIdx];
|
||||
if (connIdx < 0)
|
||||
int idx = cellToConnectionIdx_[cellIdx];
|
||||
if (idx < 0)
|
||||
continue;
|
||||
|
||||
elemCtx.updateIntensiveQuantities(0);
|
||||
const auto& iq = elemCtx.intensiveQuantities(0, 0);
|
||||
pressure_previous_[connIdx] = Opm::getValue(iq.fluidState().pressure(waterPhaseIdx));
|
||||
pressure_previous_[idx] = Opm::getValue(iq.fluidState().pressure(waterPhaseIdx));
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,35 +101,34 @@ namespace Opm
|
||||
{
|
||||
unsigned cellIdx = context.globalSpaceIndex(spaceIdx, timeIdx);
|
||||
|
||||
int connIdx = cellToConnectionIdx_[cellIdx];
|
||||
if (connIdx < 0)
|
||||
int idx = cellToConnectionIdx_[cellIdx];
|
||||
if (idx < 0)
|
||||
return;
|
||||
|
||||
// We are dereferencing the value of IntensiveQuantities because cachedIntensiveQuantities return a const pointer to
|
||||
// IntensiveQuantities of that particular cell_id
|
||||
const IntensiveQuantities intQuants = context.intensiveQuantities(spaceIdx, timeIdx);
|
||||
// This is the pressure at td + dt
|
||||
updateCellPressure(pressure_current_,connIdx,intQuants);
|
||||
updateCellDensity(connIdx,intQuants);
|
||||
calculateInflowRate(connIdx, context.simulator());
|
||||
updateCellPressure(pressure_current_,idx,intQuants);
|
||||
updateCellDensity(idx,intQuants);
|
||||
calculateInflowRate(idx, context.simulator());
|
||||
|
||||
rates[BlackoilIndices::conti0EqIdx + FluidSystem::waterCompIdx] +=
|
||||
Qai_[connIdx]/context.dofVolume(spaceIdx, timeIdx);
|
||||
Qai_[idx]/context.dofVolume(spaceIdx, timeIdx);
|
||||
}
|
||||
|
||||
void endTimeStep()
|
||||
{
|
||||
for (const auto& Qai: Qai_) {
|
||||
totalWaterFlux_ += Qai*simulator_.timeStepSize();
|
||||
W_flux_ += Qai*ebos_simulator_.timeStepSize();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
const Simulator& simulator_;
|
||||
const Simulator& ebos_simulator_;
|
||||
|
||||
// Grid variables
|
||||
std::vector<size_t> connectionToCellIdx_;
|
||||
std::vector<size_t> cell_idx_;
|
||||
std::vector<Scalar> faceArea_connected_;
|
||||
|
||||
// Quantities at each grid id
|
||||
@ -140,8 +139,6 @@ namespace Opm
|
||||
std::vector<Eval> rhow_;
|
||||
std::vector<Scalar> alphai_;
|
||||
|
||||
std::vector<Eval> aquiferWaterInflux_;
|
||||
|
||||
// Variables constants
|
||||
const AquiferCT::AQUCT_data aquct_data_;
|
||||
|
||||
@ -150,11 +147,11 @@ namespace Opm
|
||||
Scalar Tc_; // Time constant
|
||||
Scalar pa0_; // initial aquifer pressure
|
||||
|
||||
Eval totalWaterFlux_;
|
||||
Eval W_flux_;
|
||||
|
||||
|
||||
Scalar gravity_() const
|
||||
{ return simulator_.problem().gravity()[2]; }
|
||||
{ return ebos_simulator_.problem().gravity()[2]; }
|
||||
|
||||
inline void getInfluenceTableValues(Scalar& pitd, Scalar& pitd_prime, const Scalar& td)
|
||||
{
|
||||
@ -166,7 +163,7 @@ namespace Opm
|
||||
inline void initQuantities(const Aquancon::AquanconOutput& connection)
|
||||
{
|
||||
// We reset the cumulative flux at the start of any simulation, so, W_flux = 0
|
||||
totalWaterFlux_ = 0.;
|
||||
W_flux_ = 0.;
|
||||
|
||||
// We next get our connections to the aquifer and initialize these quantities using the initialize_connections function
|
||||
initializeConnections(connection);
|
||||
@ -175,10 +172,9 @@ namespace Opm
|
||||
|
||||
calculateAquiferConstants();
|
||||
|
||||
aquiferWaterInflux_.resize(connectionToCellIdx_.size());
|
||||
pressure_previous_.resize(connectionToCellIdx_.size(), 0.);
|
||||
pressure_current_.resize(connectionToCellIdx_.size(), 0.);
|
||||
Qai_.resize(connectionToCellIdx_.size(), 0.0);
|
||||
pressure_previous_.resize(cell_idx_.size(), 0.);
|
||||
pressure_current_.resize(cell_idx_.size(), 0.);
|
||||
Qai_.resize(cell_idx_.size(), 0.0);
|
||||
}
|
||||
|
||||
inline void updateCellPressure(std::vector<Eval>& pressure_water, const int idx, const IntensiveQuantities& intQuants)
|
||||
@ -213,7 +209,7 @@ namespace Opm
|
||||
Scalar PItdprime = 0.;
|
||||
Scalar PItd = 0.;
|
||||
getInfluenceTableValues(PItd, PItdprime, td_plus_dt);
|
||||
a = 1.0/Tc_ * ( (beta_ * dpai(idx)) - (totalWaterFlux_.value() * PItdprime) ) / ( PItd - td*PItdprime );
|
||||
a = 1.0/Tc_ * ( (beta_ * dpai(idx)) - (W_flux_.value() * PItdprime) ) / ( PItd - td*PItdprime );
|
||||
b = beta_ / (Tc_ * ( PItd - td*PItdprime));
|
||||
}
|
||||
|
||||
@ -242,22 +238,22 @@ namespace Opm
|
||||
// This function is used to initialize and calculate the alpha_i for each grid connection to the aquifer
|
||||
inline void initializeConnections(const Aquancon::AquanconOutput& connection)
|
||||
{
|
||||
const auto& eclState = simulator_.vanguard().eclState();
|
||||
const auto& ugrid = simulator_.vanguard().grid();
|
||||
const auto& eclState = ebos_simulator_.vanguard().eclState();
|
||||
const auto& ugrid = ebos_simulator_.vanguard().grid();
|
||||
const auto& grid = eclState.getInputGrid();
|
||||
|
||||
connectionToCellIdx_ = connection.global_index;
|
||||
cell_idx_ = connection.global_index;
|
||||
auto globalCellIdx = ugrid.globalCell();
|
||||
|
||||
assert( connectionToCellIdx_ == connection.global_index);
|
||||
assert( (connectionToCellIdx_.size() == connection.influx_coeff.size()) );
|
||||
assert( cell_idx_ == connection.global_index);
|
||||
assert( (cell_idx_.size() == connection.influx_coeff.size()) );
|
||||
assert( (connection.influx_coeff.size() == connection.influx_multiplier.size()) );
|
||||
assert( (connection.influx_multiplier.size() == connection.reservoir_face_dir.size()) );
|
||||
|
||||
// We hack the cell depth values for now. We can actually get it from elementcontext pos
|
||||
cell_depth_.resize(connectionToCellIdx_.size(), aquct_data_.d0);
|
||||
alphai_.resize(connectionToCellIdx_.size(), 1.0);
|
||||
faceArea_connected_.resize(connectionToCellIdx_.size(),0.0);
|
||||
cell_depth_.resize(cell_idx_.size(), aquct_data_.d0);
|
||||
alphai_.resize(cell_idx_.size(), 1.0);
|
||||
faceArea_connected_.resize(cell_idx_.size(),0.0);
|
||||
Scalar faceArea;
|
||||
|
||||
auto cell2Faces = Opm::UgGridHelpers::cell2Faces(ugrid);
|
||||
@ -268,12 +264,12 @@ namespace Opm
|
||||
|
||||
// denom_face_areas is the sum of the areas connected to an aquifer
|
||||
Scalar denom_face_areas = 0.;
|
||||
cellToConnectionIdx_.resize(simulator_.gridView().size(/*codim=*/0), -1);
|
||||
for (size_t idx = 0; idx < connectionToCellIdx_.size(); ++idx)
|
||||
cellToConnectionIdx_.resize(ebos_simulator_.gridView().size(/*codim=*/0), -1);
|
||||
for (size_t idx = 0; idx < cell_idx_.size(); ++idx)
|
||||
{
|
||||
cellToConnectionIdx_[connectionToCellIdx_[idx]] = idx;
|
||||
cellToConnectionIdx_[cell_idx_[idx]] = idx;
|
||||
|
||||
auto cellFacesRange = cell2Faces[connectionToCellIdx_.at(idx)];
|
||||
auto cellFacesRange = cell2Faces[cell_idx_.at(idx)];
|
||||
for(auto cellFaceIter = cellFacesRange.begin(); cellFaceIter != cellFacesRange.end(); ++cellFaceIter)
|
||||
{
|
||||
// The index of the face in the compressed grid
|
||||
@ -309,11 +305,11 @@ namespace Opm
|
||||
denom_face_areas += ( connection.influx_multiplier.at(idx) * faceArea_connected_.at(idx) );
|
||||
}
|
||||
}
|
||||
auto cellCenter = grid.getCellCenter(connectionToCellIdx_.at(idx));
|
||||
auto cellCenter = grid.getCellCenter(cell_idx_.at(idx));
|
||||
cell_depth_.at(idx) = cellCenter[2];
|
||||
}
|
||||
|
||||
for (size_t idx = 0; idx < connectionToCellIdx_.size(); ++idx)
|
||||
for (size_t idx = 0; idx < cell_idx_.size(); ++idx)
|
||||
{
|
||||
alphai_.at(idx) = ( connection.influx_multiplier.at(idx) * faceArea_connected_.at(idx) )/denom_face_areas;
|
||||
}
|
||||
@ -324,7 +320,7 @@ namespace Opm
|
||||
|
||||
int pvttableIdx = aquct_data_.pvttableID - 1;
|
||||
|
||||
rhow_.resize(connectionToCellIdx_.size(),0.);
|
||||
rhow_.resize(cell_idx_.size(),0.);
|
||||
|
||||
if (aquct_data_.p0 < 1.0)
|
||||
{
|
||||
@ -337,8 +333,8 @@ namespace Opm
|
||||
|
||||
// use the thermodynamic state of the first active cell as a
|
||||
// reference. there might be better ways to do this...
|
||||
ElementContext elemCtx(simulator_);
|
||||
const auto& elem = *simulator_.gridView().template begin</*codim=*/0>();
|
||||
ElementContext elemCtx(ebos_simulator_);
|
||||
const auto& elem = *ebos_simulator_.gridView().template begin</*codim=*/0>();
|
||||
elemCtx.updateAll(elem);
|
||||
const auto& iq0 = elemCtx.intensiveQuantities(/*spaceIdx=*/0, /*timeIdx=*/0);
|
||||
|
||||
@ -364,8 +360,8 @@ namespace Opm
|
||||
std::vector<Scalar> pw_aquifer;
|
||||
Scalar water_pressure_reservoir;
|
||||
|
||||
ElementContext elemCtx(simulator_);
|
||||
const auto& gridView = simulator_.gridView();
|
||||
ElementContext elemCtx(ebos_simulator_);
|
||||
const auto& gridView = ebos_simulator_.gridView();
|
||||
auto elemIt = gridView.template begin</*codim=*/0>();
|
||||
const auto& elemEndIt = gridView.template end</*codim=*/0>();
|
||||
for (; elemIt != elemEndIt; ++elemIt) {
|
||||
@ -373,8 +369,8 @@ namespace Opm
|
||||
elemCtx.updatePrimaryStencil(elem);
|
||||
|
||||
size_t cellIdx = elemCtx.globalSpaceIndex(/*spaceIdx=*/0, /*timeIdx=*/0);
|
||||
int connIdx = cellToConnectionIdx_[cellIdx];
|
||||
if (connIdx < 0)
|
||||
int idx = cellToConnectionIdx_[cellIdx];
|
||||
if (idx < 0)
|
||||
continue;
|
||||
|
||||
elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0);
|
||||
@ -382,8 +378,8 @@ namespace Opm
|
||||
const auto& fs = iq0.fluidState();
|
||||
|
||||
water_pressure_reservoir = fs.pressure(waterPhaseIdx).value();
|
||||
rhow_[connIdx] = fs.density(waterPhaseIdx);
|
||||
pw_aquifer.push_back( (water_pressure_reservoir - rhow_[connIdx].value()*gravity_()*(cell_depth_[connIdx] - aquct_data_.d0))*alphai_[connIdx] );
|
||||
rhow_[idx] = fs.density(waterPhaseIdx);
|
||||
pw_aquifer.push_back( (water_pressure_reservoir - rhow_[idx].value()*gravity_()*(cell_depth_[idx] - aquct_data_.d0))*alphai_[idx] );
|
||||
}
|
||||
|
||||
// We take the average of the calculated equilibrium pressures.
|
||||
|
@ -36,29 +36,34 @@ namespace Opm {
|
||||
|
||||
/// Class for handling the blackoil well model.
|
||||
template<typename TypeTag>
|
||||
class BlackoilAquiferModel : public Ewoms::EclBaseAquiferModel<TypeTag>
|
||||
class BlackoilAquiferModel
|
||||
{
|
||||
typedef Ewoms::EclBaseAquiferModel<TypeTag> ParentType;
|
||||
|
||||
typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
|
||||
typedef typename GET_PROP_TYPE(TypeTag, RateVector) RateVector;
|
||||
|
||||
public:
|
||||
explicit BlackoilAquiferModel(Simulator& ebosSimulator);
|
||||
explicit BlackoilAquiferModel(Simulator& simulator);
|
||||
|
||||
void initialSolutionApplied()
|
||||
{
|
||||
for (auto aquifer = aquifers_.begin(); aquifer != aquifers_.end(); ++aquifer)
|
||||
for (auto aquifer = aquifers_.begin(); aquifer != aquifers_.end(); ++aquifer) {
|
||||
aquifer->initialSolutionApplied();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void beginEpisode()
|
||||
{ }
|
||||
|
||||
void beginTimeStep()
|
||||
{
|
||||
for (auto aquifer = aquifers_.begin(); aquifer != aquifers_.end(); ++aquifer)
|
||||
for (auto aquifer = aquifers_.begin(); aquifer != aquifers_.end(); ++aquifer) {
|
||||
aquifer->beginTimeStep();
|
||||
}
|
||||
}
|
||||
|
||||
void beginIteration()
|
||||
{ }
|
||||
|
||||
// add the water rate due to aquifers to the source term.
|
||||
template <class Context>
|
||||
void addToSource(RateVector& rates,
|
||||
@ -66,16 +71,24 @@ namespace Opm {
|
||||
unsigned spaceIdx,
|
||||
unsigned timeIdx) const
|
||||
{
|
||||
for (auto& aquifer: aquifers_)
|
||||
for (auto& aquifer: aquifers_) {
|
||||
aquifer.addToSource(rates, context, spaceIdx, timeIdx);
|
||||
}
|
||||
}
|
||||
|
||||
void endIteration()
|
||||
{ }
|
||||
|
||||
void endTimeStep()
|
||||
{
|
||||
for (auto aquifer = aquifers_.begin(); aquifer != aquifers_.end(); ++aquifer)
|
||||
for (auto aquifer = aquifers_.begin(); aquifer != aquifers_.end(); ++aquifer) {
|
||||
aquifer->endTimeStep();
|
||||
}
|
||||
}
|
||||
|
||||
void endEpisode()
|
||||
{ }
|
||||
|
||||
protected:
|
||||
// --------- Types ---------
|
||||
typedef typename GET_PROP_TYPE(TypeTag, ElementContext) ElementContext;
|
||||
@ -87,6 +100,8 @@ namespace Opm {
|
||||
// long term
|
||||
mutable std::vector<AquiferType> aquifers_;
|
||||
|
||||
Simulator& simulator_;
|
||||
|
||||
// This initialization function is used to connect the parser objects with the ones needed by AquiferCarterTracy
|
||||
void init();
|
||||
|
||||
|
@ -3,8 +3,8 @@ namespace Opm {
|
||||
|
||||
template<typename TypeTag>
|
||||
BlackoilAquiferModel<TypeTag>::
|
||||
BlackoilAquiferModel(Simulator& ebosSimulator)
|
||||
: ParentType(ebosSimulator)
|
||||
BlackoilAquiferModel(Simulator& simulator)
|
||||
: simulator_(simulator)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user