Merge pull request #2254 from GitPaean/clang-format-aquifer

re-formatting aquifer files with clang-format
This commit is contained in:
Bård Skaflestad 2019-12-20 16:50:11 +01:00 committed by GitHub
commit b64116a70c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 679 additions and 685 deletions

View File

@ -37,15 +37,15 @@ namespace Opm
public: public:
typedef AquiferInterface<TypeTag> Base; typedef AquiferInterface<TypeTag> Base;
using typename Base::Simulator;
using typename Base::ElementContext;
using typename Base::FluidSystem;
using typename Base::BlackoilIndices; using typename Base::BlackoilIndices;
using typename Base::RateVector; using typename Base::ElementContext;
using typename Base::IntensiveQuantities;
using typename Base::Eval; using typename Base::Eval;
using typename Base::Scalar;
using typename Base::FluidState; using typename Base::FluidState;
using typename Base::FluidSystem;
using typename Base::IntensiveQuantities;
using typename Base::RateVector;
using typename Base::Scalar;
using typename Base::Simulator;
using Base::waterCompIdx; using Base::waterCompIdx;
using Base::waterPhaseIdx; using Base::waterPhaseIdx;
@ -55,7 +55,8 @@ namespace Opm
const AquiferCT::AQUCT_data& aquct_data) const AquiferCT::AQUCT_data& aquct_data)
: Base(connection, cartesian_to_compressed, ebosSimulator) : Base(connection, cartesian_to_compressed, ebosSimulator)
, aquct_data_(aquct_data) , aquct_data_(aquct_data)
{} {
}
void endTimeStep() override void endTimeStep() override
{ {
@ -100,39 +101,43 @@ namespace Opm
// denom_face_areas is the sum of the areas connected to an aquifer // denom_face_areas is the sum of the areas connected to an aquifer
Scalar denom_face_areas = 0.; Scalar denom_face_areas = 0.;
Base::cellToConnectionIdx_.resize(Base::ebos_simulator_.gridView().size(/*codim=*/0), -1); Base::cellToConnectionIdx_.resize(Base::ebos_simulator_.gridView().size(/*codim=*/0), -1);
for (size_t idx = 0; idx < Base::cell_idx_.size(); ++idx) for (size_t idx = 0; idx < Base::cell_idx_.size(); ++idx) {
{
const int cell_index = Base::cartesian_to_compressed_.at(Base::cell_idx_[idx]); const int cell_index = Base::cartesian_to_compressed_.at(Base::cell_idx_[idx]);
Base::cellToConnectionIdx_[cell_index] = idx; Base::cellToConnectionIdx_[cell_index] = idx;
const auto cellFacesRange = cell2Faces[cell_index]; const auto cellFacesRange = cell2Faces[cell_index];
for(auto cellFaceIter = cellFacesRange.begin(); cellFaceIter != cellFacesRange.end(); ++cellFaceIter) for (auto cellFaceIter = cellFacesRange.begin(); cellFaceIter != cellFacesRange.end(); ++cellFaceIter) {
{
// The index of the face in the compressed grid // The index of the face in the compressed grid
const int faceIdx = *cellFaceIter; const int faceIdx = *cellFaceIter;
// the logically-Cartesian direction of the face // the logically-Cartesian direction of the face
const int faceTag = Opm::UgGridHelpers::faceTag(ugrid, cellFaceIter); const int faceTag = Opm::UgGridHelpers::faceTag(ugrid, cellFaceIter);
switch(faceTag) switch (faceTag) {
{ case 0:
case 0: faceDirection = Opm::FaceDir::XMinus; faceDirection = Opm::FaceDir::XMinus;
break; break;
case 1: faceDirection = Opm::FaceDir::XPlus; case 1:
faceDirection = Opm::FaceDir::XPlus;
break; break;
case 2: faceDirection = Opm::FaceDir::YMinus; case 2:
faceDirection = Opm::FaceDir::YMinus;
break; break;
case 3: faceDirection = Opm::FaceDir::YPlus; case 3:
faceDirection = Opm::FaceDir::YPlus;
break; break;
case 4: faceDirection = Opm::FaceDir::ZMinus; case 4:
faceDirection = Opm::FaceDir::ZMinus;
break; break;
case 5: faceDirection = Opm::FaceDir::ZPlus; case 5:
faceDirection = Opm::FaceDir::ZPlus;
break; break;
default: OPM_THROW(Opm::NumericalIssue,"Initialization of Aquifer Carter Tracy problem. Make sure faceTag is correctly defined"); default:
OPM_THROW(Opm::NumericalIssue,
"Initialization of Aquifer Carter Tracy problem. Make sure faceTag is correctly defined");
} }
if (faceDirection == connection.reservoir_face_dir.at(idx)) if (faceDirection == connection.reservoir_face_dir.at(idx)) {
{
Base::faceArea_connected_.at(idx) = Base::getFaceArea(faceCells, ugrid, faceIdx, idx, connection); Base::faceArea_connected_.at(idx) = Base::getFaceArea(faceCells, ugrid, faceIdx, idx, connection);
denom_face_areas += (connection.influx_multiplier.at(idx) * Base::faceArea_connected_.at(idx)); denom_face_areas += (connection.influx_multiplier.at(idx) * Base::faceArea_connected_.at(idx));
} }
@ -142,9 +147,9 @@ namespace Opm
} }
const double eps_sqrt = std::sqrt(std::numeric_limits<double>::epsilon()); const double eps_sqrt = std::sqrt(std::numeric_limits<double>::epsilon());
for (size_t idx = 0; idx < Base::cell_idx_.size(); ++idx) for (size_t idx = 0; idx < Base::cell_idx_.size(); ++idx) {
{ Base::alphai_.at(idx) = (denom_face_areas < eps_sqrt)
Base::alphai_.at(idx) = (denom_face_areas < eps_sqrt)? // Prevent no connection NaNs due to division by zero ? // Prevent no connection NaNs due to division by zero
0. 0.
: (connection.influx_multiplier.at(idx) * Base::faceArea_connected_.at(idx)) / denom_face_areas; : (connection.influx_multiplier.at(idx) * Base::faceArea_connected_.at(idx)) / denom_face_areas;
} }
@ -152,10 +157,8 @@ namespace Opm
void assignRestartData(const data::AquiferData& /* xaq */) override void assignRestartData(const data::AquiferData& /* xaq */) override
{ {
throw std::runtime_error { throw std::runtime_error {"Restart-based initialization not currently supported "
"Restart-based initialization not currently supported " "for Carter-Tracey analytic aquifers"};
"for Carter-Tracey analytic aquifers"
};
} }
inline void getInfluenceTableValues(Scalar& pitd, Scalar& pitd_prime, const Scalar& td) inline void getInfluenceTableValues(Scalar& pitd, Scalar& pitd_prime, const Scalar& td)
@ -167,7 +170,9 @@ namespace Opm
inline Scalar dpai(int idx) inline Scalar dpai(int idx)
{ {
Scalar dp = Base::pa0_ + Base::rhow_.at(idx).value()*Base::gravity_()*(Base::cell_depth_.at(idx) - aquct_data_.d0) - Base::pressure_previous_.at(idx); Scalar dp = Base::pa0_
+ Base::rhow_.at(idx).value() * Base::gravity_() * (Base::cell_depth_.at(idx) - aquct_data_.d0)
- Base::pressure_previous_.at(idx);
return dp; return dp;
} }
@ -188,20 +193,17 @@ namespace Opm
{ {
Scalar a, b; Scalar a, b;
calculateEqnConstants(a, b, idx, simulator); calculateEqnConstants(a, b, idx, simulator);
Base::Qai_.at(idx) = Base::alphai_.at(idx)*( a - b * ( Base::pressure_current_.at(idx) - Base::pressure_previous_.at(idx) ) ); Base::Qai_.at(idx)
= Base::alphai_.at(idx) * (a - b * (Base::pressure_current_.at(idx) - Base::pressure_previous_.at(idx)));
} }
inline void calculateAquiferConstants() override inline void calculateAquiferConstants() override
{ {
// We calculate the influx constant // We calculate the influx constant
beta_ = aquct_data_.c2 * aquct_data_.h beta_ = aquct_data_.c2 * aquct_data_.h * aquct_data_.theta * aquct_data_.phi_aq * aquct_data_.C_t
* aquct_data_.theta * aquct_data_.phi_aq
* aquct_data_.C_t
* aquct_data_.r_o * aquct_data_.r_o; * aquct_data_.r_o * aquct_data_.r_o;
// We calculate the time constant // We calculate the time constant
Base::Tc_ = mu_w_ * aquct_data_.phi_aq Base::Tc_ = mu_w_ * aquct_data_.phi_aq * aquct_data_.C_t * aquct_data_.r_o * aquct_data_.r_o
* aquct_data_.C_t
* aquct_data_.r_o * aquct_data_.r_o
/ (aquct_data_.k_a * aquct_data_.c1); / (aquct_data_.k_a * aquct_data_.c1);
} }
@ -210,12 +212,9 @@ namespace Opm
int pvttableIdx = aquct_data_.pvttableID - 1; int pvttableIdx = aquct_data_.pvttableID - 1;
Base::rhow_.resize(Base::cell_idx_.size(), 0.); Base::rhow_.resize(Base::cell_idx_.size(), 0.);
if (!aquct_data_.p0) if (!aquct_data_.p0) {
{
Base::pa0_ = calculateReservoirEquilibrium(); Base::pa0_ = calculateReservoirEquilibrium();
} } else {
else
{
Base::pa0_ = *(aquct_data_.p0); Base::pa0_ = *(aquct_data_.p0);
} }
@ -236,7 +235,6 @@ namespace Opm
pa0_mean = Base::pa0_; pa0_mean = Base::pa0_;
Eval mu_w_aquifer = FluidSystem::waterPvt().viscosity(pvttableIdx, temperature_aq, pa0_mean); Eval mu_w_aquifer = FluidSystem::waterPvt().viscosity(pvttableIdx, temperature_aq, pa0_mean);
mu_w_ = mu_w_aquifer.value(); mu_w_ = mu_w_aquifer.value();
} }
// This function is for calculating the aquifer properties from equilibrium state with the reservoir // This function is for calculating the aquifer properties from equilibrium state with the reservoir
@ -266,7 +264,10 @@ namespace Opm
water_pressure_reservoir = fs.pressure(waterPhaseIdx).value(); water_pressure_reservoir = fs.pressure(waterPhaseIdx).value();
Base::rhow_[idx] = fs.density(waterPhaseIdx); Base::rhow_[idx] = fs.density(waterPhaseIdx);
pw_aquifer.push_back( (water_pressure_reservoir - Base::rhow_[idx].value()*Base::gravity_()*(Base::cell_depth_[idx] - aquct_data_.d0))*Base::alphai_[idx] ); pw_aquifer.push_back(
(water_pressure_reservoir
- Base::rhow_[idx].value() * Base::gravity_() * (Base::cell_depth_[idx] - aquct_data_.d0))
* Base::alphai_[idx]);
} }
// We take the average of the calculated equilibrium pressures. // We take the average of the calculated equilibrium pressures.

View File

@ -38,15 +38,15 @@ namespace Opm
public: public:
typedef AquiferInterface<TypeTag> Base; typedef AquiferInterface<TypeTag> Base;
using typename Base::Simulator;
using typename Base::ElementContext;
using typename Base::FluidSystem;
using typename Base::BlackoilIndices; using typename Base::BlackoilIndices;
using typename Base::RateVector; using typename Base::ElementContext;
using typename Base::IntensiveQuantities;
using typename Base::Eval; using typename Base::Eval;
using typename Base::Scalar;
using typename Base::FluidState; using typename Base::FluidState;
using typename Base::FluidSystem;
using typename Base::IntensiveQuantities;
using typename Base::RateVector;
using typename Base::Scalar;
using typename Base::Simulator;
using Base::waterCompIdx; using Base::waterCompIdx;
using Base::waterPhaseIdx; using Base::waterPhaseIdx;
@ -57,7 +57,8 @@ namespace Opm
const Aquifetp::AQUFETP_data& aqufetp_data) const Aquifetp::AQUFETP_data& aqufetp_data)
: Base(connection, cartesian_to_compressed, ebosSimulator) : Base(connection, cartesian_to_compressed, ebosSimulator)
, aqufetp_data_(aqufetp_data) , aqufetp_data_(aqufetp_data)
{} {
}
void endTimeStep() override void endTimeStep() override
{ {
@ -101,39 +102,43 @@ namespace Opm
// denom_face_areas is the sum of the areas connected to an aquifer // denom_face_areas is the sum of the areas connected to an aquifer
Scalar denom_face_areas = 0.; Scalar denom_face_areas = 0.;
Base::cellToConnectionIdx_.resize(Base::ebos_simulator_.gridView().size(/*codim=*/0), -1); Base::cellToConnectionIdx_.resize(Base::ebos_simulator_.gridView().size(/*codim=*/0), -1);
for (size_t idx = 0; idx < Base::cell_idx_.size(); ++idx) for (size_t idx = 0; idx < Base::cell_idx_.size(); ++idx) {
{
const int cell_index = Base::cartesian_to_compressed_.at(Base::cell_idx_[idx]); const int cell_index = Base::cartesian_to_compressed_.at(Base::cell_idx_[idx]);
Base::cellToConnectionIdx_[cell_index] = idx; Base::cellToConnectionIdx_[cell_index] = idx;
const auto cellFacesRange = cell2Faces[cell_index]; const auto cellFacesRange = cell2Faces[cell_index];
for(auto cellFaceIter = cellFacesRange.begin(); cellFaceIter != cellFacesRange.end(); ++cellFaceIter) for (auto cellFaceIter = cellFacesRange.begin(); cellFaceIter != cellFacesRange.end(); ++cellFaceIter) {
{
// The index of the face in the compressed grid // The index of the face in the compressed grid
const int faceIdx = *cellFaceIter; const int faceIdx = *cellFaceIter;
// the logically-Cartesian direction of the face // the logically-Cartesian direction of the face
const int faceTag = Opm::UgGridHelpers::faceTag(ugrid, cellFaceIter); const int faceTag = Opm::UgGridHelpers::faceTag(ugrid, cellFaceIter);
switch(faceTag) switch (faceTag) {
{ case 0:
case 0: faceDirection = Opm::FaceDir::XMinus; faceDirection = Opm::FaceDir::XMinus;
break; break;
case 1: faceDirection = Opm::FaceDir::XPlus; case 1:
faceDirection = Opm::FaceDir::XPlus;
break; break;
case 2: faceDirection = Opm::FaceDir::YMinus; case 2:
faceDirection = Opm::FaceDir::YMinus;
break; break;
case 3: faceDirection = Opm::FaceDir::YPlus; case 3:
faceDirection = Opm::FaceDir::YPlus;
break; break;
case 4: faceDirection = Opm::FaceDir::ZMinus; case 4:
faceDirection = Opm::FaceDir::ZMinus;
break; break;
case 5: faceDirection = Opm::FaceDir::ZPlus; case 5:
faceDirection = Opm::FaceDir::ZPlus;
break; break;
default: OPM_THROW(Opm::NumericalIssue,"Initialization of Aquifer problem. Make sure faceTag is correctly defined"); default:
OPM_THROW(Opm::NumericalIssue,
"Initialization of Aquifer problem. Make sure faceTag is correctly defined");
} }
if (faceDirection == connection.reservoir_face_dir.at(idx)) if (faceDirection == connection.reservoir_face_dir.at(idx)) {
{
Base::faceArea_connected_.at(idx) = Base::getFaceArea(faceCells, ugrid, faceIdx, idx, connection); Base::faceArea_connected_.at(idx) = Base::getFaceArea(faceCells, ugrid, faceIdx, idx, connection);
denom_face_areas += (connection.influx_multiplier.at(idx) * Base::faceArea_connected_.at(idx)); denom_face_areas += (connection.influx_multiplier.at(idx) * Base::faceArea_connected_.at(idx));
} }
@ -143,9 +148,9 @@ namespace Opm
} }
const double eps_sqrt = std::sqrt(std::numeric_limits<double>::epsilon()); const double eps_sqrt = std::sqrt(std::numeric_limits<double>::epsilon());
for (size_t idx = 0; idx < Base::cell_idx_.size(); ++idx) for (size_t idx = 0; idx < Base::cell_idx_.size(); ++idx) {
{ Base::alphai_.at(idx) = (denom_face_areas < eps_sqrt)
Base::alphai_.at(idx) = (denom_face_areas < eps_sqrt)? // Prevent no connection NaNs due to division by zero ? // Prevent no connection NaNs due to division by zero
0. 0.
: (connection.influx_multiplier.at(idx) * Base::faceArea_connected_.at(idx)) / denom_face_areas; : (connection.influx_multiplier.at(idx) * Base::faceArea_connected_.at(idx)) / denom_face_areas;
} }
@ -153,12 +158,9 @@ namespace Opm
void assignRestartData(const data::AquiferData& xaq) override void assignRestartData(const data::AquiferData& xaq) override
{ {
if (xaq.type != data::AquiferType::Fetkovich) if (xaq.type != data::AquiferType::Fetkovich) {
{ throw std::invalid_argument {"Analytic aquifer data for unexpected aquifer type "
throw std::invalid_argument { "passed to Fetkovich aquifer"};
"Analytic aquifer data for unexpected aquifer type "
"passed to Fetkovich aquifer"
};
} }
this->aquifer_pressure_ = xaq.pressure; this->aquifer_pressure_ = xaq.pressure;
@ -199,12 +201,9 @@ namespace Opm
return; return;
} }
if (!aqufetp_data_.p0) if (!aqufetp_data_.p0) {
{
Base::pa0_ = calculateReservoirEquilibrium(); Base::pa0_ = calculateReservoirEquilibrium();
} } else {
else
{
Base::pa0_ = *(aqufetp_data_.p0); Base::pa0_ = *(aqufetp_data_.p0);
} }
aquifer_pressure_ = Base::pa0_; aquifer_pressure_ = Base::pa0_;
@ -234,7 +233,10 @@ namespace Opm
water_pressure_reservoir = fs.pressure(waterPhaseIdx).value(); water_pressure_reservoir = fs.pressure(waterPhaseIdx).value();
Base::rhow_[idx] = fs.density(waterPhaseIdx); Base::rhow_[idx] = fs.density(waterPhaseIdx);
pw_aquifer.push_back( (water_pressure_reservoir - Base::rhow_[idx].value()*Base::gravity_()*(Base::cell_depth_[idx] - aqufetp_data_.d0))*Base::alphai_[idx] ); pw_aquifer.push_back(
(water_pressure_reservoir
- Base::rhow_[idx].value() * Base::gravity_() * (Base::cell_depth_[idx] - aqufetp_data_.d0))
* Base::alphai_[idx]);
} }
// We take the average of the calculated equilibrium pressures. // We take the average of the calculated equilibrium pressures.

View File

@ -22,21 +22,21 @@
#ifndef OPM_AQUIFERINTERFACE_HEADER_INCLUDED #ifndef OPM_AQUIFERINTERFACE_HEADER_INCLUDED
#define OPM_AQUIFERINTERFACE_HEADER_INCLUDED #define OPM_AQUIFERINTERFACE_HEADER_INCLUDED
#include <opm/common/utility/numeric/linearInterpolation.hpp>
#include <opm/parser/eclipse/EclipseState/Aquancon.hpp>
#include <opm/parser/eclipse/EclipseState/AquiferCT.hpp> #include <opm/parser/eclipse/EclipseState/AquiferCT.hpp>
#include <opm/parser/eclipse/EclipseState/Aquifetp.hpp> #include <opm/parser/eclipse/EclipseState/Aquifetp.hpp>
#include <opm/parser/eclipse/EclipseState/Aquancon.hpp>
#include <opm/common/utility/numeric/linearInterpolation.hpp>
#include <opm/output/data/Aquifer.hpp> #include <opm/output/data/Aquifer.hpp>
#include <opm/material/common/MathToolbox.hpp> #include <opm/material/common/MathToolbox.hpp>
#include <opm/material/densead/Math.hpp>
#include <opm/material/densead/Evaluation.hpp> #include <opm/material/densead/Evaluation.hpp>
#include <opm/material/densead/Math.hpp>
#include <opm/material/fluidstates/BlackOilFluidState.hpp> #include <opm/material/fluidstates/BlackOilFluidState.hpp>
#include <vector>
#include <algorithm> #include <algorithm>
#include <unordered_map> #include <unordered_map>
#include <vector>
namespace Opm namespace Opm
{ {
@ -59,7 +59,13 @@ namespace Opm
typedef DenseAd::Evaluation<double, /*size=*/numEq> Eval; typedef DenseAd::Evaluation<double, /*size=*/numEq> Eval;
typedef Opm::BlackOilFluidState<Eval, FluidSystem, enableTemperature, enableEnergy, BlackoilIndices::gasEnabled, BlackoilIndices::numPhases> FluidState; typedef Opm::BlackOilFluidState<Eval,
FluidSystem,
enableTemperature,
enableEnergy,
BlackoilIndices::gasEnabled,
BlackoilIndices::numPhases>
FluidState;
static const auto waterCompIdx = FluidSystem::waterCompIdx; static const auto waterCompIdx = FluidSystem::waterCompIdx;
static const auto waterPhaseIdx = FluidSystem::waterPhaseIdx; static const auto waterPhaseIdx = FluidSystem::waterPhaseIdx;
@ -71,16 +77,18 @@ namespace Opm
: connection_(connection) : connection_(connection)
, ebos_simulator_(ebosSimulator) , ebos_simulator_(ebosSimulator)
, cartesian_to_compressed_(cartesian_to_compressed) , cartesian_to_compressed_(cartesian_to_compressed)
{} {
}
// Deconstructor // Deconstructor
virtual ~AquiferInterface() {} virtual ~AquiferInterface()
{
}
void initFromRestart(const std::vector<data::AquiferData>& aquiferSoln) void initFromRestart(const std::vector<data::AquiferData>& aquiferSoln)
{ {
auto xaqPos = std::find_if(aquiferSoln.begin(), aquiferSoln.end(), auto xaqPos
[this](const data::AquiferData& xaq) -> bool = std::find_if(aquiferSoln.begin(), aquiferSoln.end(), [this](const data::AquiferData& xaq) -> bool {
{
return xaq.aquiferID == this->connection_.aquiferID; return xaq.aquiferID == this->connection_.aquiferID;
}); });
@ -131,15 +139,15 @@ namespace Opm
if (idx < 0) if (idx < 0)
return; return;
// We are dereferencing the value of IntensiveQuantities because cachedIntensiveQuantities return a const pointer to // We are dereferencing the value of IntensiveQuantities because cachedIntensiveQuantities return a const
// IntensiveQuantities of that particular cell_id // pointer to IntensiveQuantities of that particular cell_id
const IntensiveQuantities intQuants = context.intensiveQuantities(spaceIdx, timeIdx); const IntensiveQuantities intQuants = context.intensiveQuantities(spaceIdx, timeIdx);
// This is the pressure at td + dt // This is the pressure at td + dt
updateCellPressure(pressure_current_, idx, intQuants); updateCellPressure(pressure_current_, idx, intQuants);
updateCellDensity(idx, intQuants); updateCellDensity(idx, intQuants);
calculateInflowRate(idx, context.simulator()); calculateInflowRate(idx, context.simulator());
rates[BlackoilIndices::conti0EqIdx + FluidSystem::waterCompIdx] += rates[BlackoilIndices::conti0EqIdx + FluidSystem::waterCompIdx]
Qai_[idx]/context.dofVolume(spaceIdx, timeIdx); += Qai_[idx] / context.dofVolume(spaceIdx, timeIdx);
} }
protected: protected:
@ -151,12 +159,12 @@ namespace Opm
inline void initQuantities(const Aquancon::AquanconOutput& connection) inline void initQuantities(const Aquancon::AquanconOutput& connection)
{ {
// We reset the cumulative flux at the start of any simulation, so, W_flux = 0 // We reset the cumulative flux at the start of any simulation, so, W_flux = 0
if (!this->solution_set_from_restart_) if (!this->solution_set_from_restart_) {
{
W_flux_ = 0.; W_flux_ = 0.;
} }
// We next get our connections to the aquifer and initialize these quantities using the initialize_connections function // We next get our connections to the aquifer and initialize these quantities using the initialize_connections
// function
initializeConnections(connection); initializeConnections(connection);
calculateAquiferCondition(); calculateAquiferCondition();
calculateAquiferConstants(); calculateAquiferConstants();
@ -166,13 +174,15 @@ namespace Opm
Qai_.resize(cell_idx_.size(), 0.0); Qai_.resize(cell_idx_.size(), 0.0);
} }
inline void updateCellPressure(std::vector<Eval>& pressure_water, const int idx, const IntensiveQuantities& intQuants) inline void
updateCellPressure(std::vector<Eval>& pressure_water, const int idx, const IntensiveQuantities& intQuants)
{ {
const auto& fs = intQuants.fluidState(); const auto& fs = intQuants.fluidState();
pressure_water.at(idx) = fs.pressure(waterPhaseIdx); pressure_water.at(idx) = fs.pressure(waterPhaseIdx);
} }
inline void updateCellPressure(std::vector<Scalar>& pressure_water, const int idx, const IntensiveQuantities& intQuants) inline void
updateCellPressure(std::vector<Scalar>& pressure_water, const int idx, const IntensiveQuantities& intQuants)
{ {
const auto& fs = intQuants.fluidState(); const auto& fs = intQuants.fluidState();
pressure_water.at(idx) = fs.pressure(waterPhaseIdx).value(); pressure_water.at(idx) = fs.pressure(waterPhaseIdx).value();
@ -185,25 +195,26 @@ namespace Opm
} }
template <class faceCellType, class ugridType> template <class faceCellType, class ugridType>
inline double getFaceArea(const faceCellType& faceCells, const ugridType& ugrid, inline double getFaceArea(const faceCellType& faceCells,
const int faceIdx, const int idx, const ugridType& ugrid,
const int faceIdx,
const int idx,
const Aquancon::AquanconOutput& connection) const const Aquancon::AquanconOutput& connection) const
{ {
// Check now if the face is outside of the reservoir, or if it adjoins an inactive cell // Check now if the face is outside of the reservoir, or if it adjoins an inactive cell
// Do not make the connection if the product of the two cellIdx > 0. This is because the // Do not make the connection if the product of the two cellIdx > 0. This is because the
// face is within the reservoir/not connected to boundary. (We still have yet to check for inactive cell adjoining) // face is within the reservoir/not connected to boundary. (We still have yet to check for inactive cell
// adjoining)
double faceArea = 0.; double faceArea = 0.;
const auto cellNeighbour0 = faceCells(faceIdx, 0); const auto cellNeighbour0 = faceCells(faceIdx, 0);
const auto cellNeighbour1 = faceCells(faceIdx, 1); const auto cellNeighbour1 = faceCells(faceIdx, 1);
const auto defaultFaceArea = Opm::UgGridHelpers::faceArea(ugrid, faceIdx); const auto defaultFaceArea = Opm::UgGridHelpers::faceArea(ugrid, faceIdx);
const auto calculatedFaceArea = (!connection.influx_coeff.at(idx))? const auto calculatedFaceArea
defaultFaceArea : = (!connection.influx_coeff.at(idx)) ? defaultFaceArea : *(connection.influx_coeff.at(idx));
*(connection.influx_coeff.at(idx));
faceArea = (cellNeighbour0 * cellNeighbour1 > 0) ? 0. : calculatedFaceArea; faceArea = (cellNeighbour0 * cellNeighbour1 > 0) ? 0. : calculatedFaceArea;
if (cellNeighbour1 == 0) { if (cellNeighbour1 == 0) {
faceArea = (cellNeighbour0 < 0) ? faceArea : 0.; faceArea = (cellNeighbour0 < 0) ? faceArea : 0.;
} } else if (cellNeighbour0 == 0) {
else if (cellNeighbour0 == 0){
faceArea = (cellNeighbour1 < 0) ? faceArea : 0.; faceArea = (cellNeighbour1 < 0) ? faceArea : 0.;
} }
return faceArea; return faceArea;

View File

@ -26,9 +26,9 @@
#include <ebos/eclbaseaquifermodel.hh> #include <ebos/eclbaseaquifermodel.hh>
#include <opm/parser/eclipse/EclipseState/Aquancon.hpp>
#include <opm/parser/eclipse/EclipseState/AquiferCT.hpp> #include <opm/parser/eclipse/EclipseState/AquiferCT.hpp>
#include <opm/parser/eclipse/EclipseState/Aquifetp.hpp> #include <opm/parser/eclipse/EclipseState/Aquifetp.hpp>
#include <opm/parser/eclipse/EclipseState/Aquancon.hpp>
#include <opm/output/data/Aquifer.hpp> #include <opm/output/data/Aquifer.hpp>
@ -39,7 +39,8 @@
#include <vector> #include <vector>
namespace Opm { namespace Opm
{
/// Class for handling the blackoil well model. /// Class for handling the blackoil well model.
template <typename TypeTag> template <typename TypeTag>
@ -59,10 +60,7 @@ namespace Opm {
void beginIteration(); void beginIteration();
// add the water rate due to aquifers to the source term. // add the water rate due to aquifers to the source term.
template <class Context> template <class Context>
void addToSource(RateVector& rates, void addToSource(RateVector& rates, const Context& context, unsigned spaceIdx, unsigned timeIdx) const;
const Context& context,
unsigned spaceIdx,
unsigned timeIdx) const;
void endIteration(); void endIteration();
void endTimeStep(); void endTimeStep();
void endEpisode(); void endEpisode();
@ -93,7 +91,6 @@ namespace Opm {
bool aquiferActive() const; bool aquiferActive() const;
bool aquiferCarterTracyActive() const; bool aquiferCarterTracyActive() const;
bool aquiferFetkovichActive() const; bool aquiferFetkovichActive() const;
}; };

View File

@ -1,9 +1,9 @@
#include <opm/grid/utility/cartesianToCompressed.hpp> #include <opm/grid/utility/cartesianToCompressed.hpp>
namespace Opm { namespace Opm
{
template <typename TypeTag> template <typename TypeTag>
BlackoilAquiferModel<TypeTag>:: BlackoilAquiferModel<TypeTag>::BlackoilAquiferModel(Simulator& simulator)
BlackoilAquiferModel(Simulator& simulator)
: simulator_(simulator) : simulator_(simulator)
{ {
init(); init();
@ -13,18 +13,14 @@ namespace Opm {
void void
BlackoilAquiferModel<TypeTag>::initialSolutionApplied() BlackoilAquiferModel<TypeTag>::initialSolutionApplied()
{ {
if(aquiferCarterTracyActive()) if (aquiferCarterTracyActive()) {
{ for (auto& aquifer : aquifers_CarterTracy) {
for (auto aquifer = aquifers_CarterTracy.begin(); aquifer != aquifers_CarterTracy.end(); ++aquifer) aquifer.initialSolutionApplied();
{
aquifer->initialSolutionApplied();
} }
} }
if(aquiferFetkovichActive()) if (aquiferFetkovichActive()) {
{ for (auto& aquifer : aquifers_Fetkovich) {
for (auto aquifer = aquifers_Fetkovich.begin(); aquifer != aquifers_Fetkovich.end(); ++aquifer) aquifer.initialSolutionApplied();
{
aquifer->initialSolutionApplied();
} }
} }
} }
@ -33,17 +29,13 @@ namespace Opm {
void void
BlackoilAquiferModel<TypeTag>::initFromRestart(const std::vector<data::AquiferData>& aquiferSoln) BlackoilAquiferModel<TypeTag>::initFromRestart(const std::vector<data::AquiferData>& aquiferSoln)
{ {
if(aquiferCarterTracyActive()) if (aquiferCarterTracyActive()) {
{ for (auto& aquifer : aquifers_CarterTracy) {
for (auto& aquifer : aquifers_CarterTracy)
{
aquifer.initFromRestart(aquiferSoln); aquifer.initFromRestart(aquiferSoln);
} }
} }
if(aquiferFetkovichActive()) if (aquiferFetkovichActive()) {
{ for (auto& aquifer : aquifers_Fetkovich) {
for (auto& aquifer : aquifers_Fetkovich)
{
aquifer.initFromRestart(aquiferSoln); aquifer.initFromRestart(aquiferSoln);
} }
} }
@ -52,47 +44,46 @@ namespace Opm {
template <typename TypeTag> template <typename TypeTag>
void void
BlackoilAquiferModel<TypeTag>::beginEpisode() BlackoilAquiferModel<TypeTag>::beginEpisode()
{ } {
}
template <typename TypeTag> template <typename TypeTag>
void void
BlackoilAquiferModel<TypeTag>::beginIteration() BlackoilAquiferModel<TypeTag>::beginIteration()
{ } {
}
template <typename TypeTag> template <typename TypeTag>
void BlackoilAquiferModel<TypeTag>:: beginTimeStep() void
BlackoilAquiferModel<TypeTag>::beginTimeStep()
{ {
if(aquiferCarterTracyActive()) if (aquiferCarterTracyActive()) {
{ for (auto& aquifer : aquifers_CarterTracy) {
for (auto aquifer = aquifers_CarterTracy.begin(); aquifer != aquifers_CarterTracy.end(); ++aquifer) aquifer.beginTimeStep();
{
aquifer->beginTimeStep();
} }
} }
if(aquiferFetkovichActive()) if (aquiferFetkovichActive()) {
{ for (auto& aquifer : aquifers_Fetkovich) {
for (auto aquifer = aquifers_Fetkovich.begin(); aquifer != aquifers_Fetkovich.end(); ++aquifer) aquifer.beginTimeStep();
{
aquifer->beginTimeStep();
} }
} }
} }
template <typename TypeTag> template <typename TypeTag>
template <class Context> template <class Context>
void BlackoilAquiferModel<TypeTag>:: addToSource(RateVector& rates, const Context& context, unsigned spaceIdx, unsigned timeIdx) const void
{ BlackoilAquiferModel<TypeTag>::addToSource(RateVector& rates,
if(aquiferCarterTracyActive()) const Context& context,
{ unsigned spaceIdx,
for (auto& aquifer : aquifers_CarterTracy) unsigned timeIdx) const
{ {
if (aquiferCarterTracyActive()) {
for (auto& aquifer : aquifers_CarterTracy) {
aquifer.addToSource(rates, context, spaceIdx, timeIdx); aquifer.addToSource(rates, context, spaceIdx, timeIdx);
} }
} }
if(aquiferFetkovichActive()) if (aquiferFetkovichActive()) {
{ for (auto& aquifer : aquifers_Fetkovich) {
for (auto& aquifer : aquifers_Fetkovich)
{
aquifer.addToSource(rates, context, spaceIdx, timeIdx); aquifer.addToSource(rates, context, spaceIdx, timeIdx);
} }
} }
@ -101,30 +92,29 @@ namespace Opm {
template <typename TypeTag> template <typename TypeTag>
void void
BlackoilAquiferModel<TypeTag>::endIteration() BlackoilAquiferModel<TypeTag>::endIteration()
{ } {
}
template <typename TypeTag> template <typename TypeTag>
void BlackoilAquiferModel<TypeTag>:: endTimeStep() void
BlackoilAquiferModel<TypeTag>::endTimeStep()
{ {
if(aquiferCarterTracyActive()) if (aquiferCarterTracyActive()) {
{ for (auto& aquifer : aquifers_CarterTracy) {
for (auto aquifer = aquifers_CarterTracy.begin(); aquifer != aquifers_CarterTracy.end(); ++aquifer) aquifer.endTimeStep();
{
aquifer->endTimeStep();
} }
} }
if(aquiferFetkovichActive()) if (aquiferFetkovichActive()) {
{ for (auto& aquifer : aquifers_Fetkovich) {
for (auto aquifer = aquifers_Fetkovich.begin(); aquifer != aquifers_Fetkovich.end(); ++aquifer) aquifer.endTimeStep();
{
aquifer->endTimeStep();
} }
} }
} }
template <typename TypeTag> template <typename TypeTag>
void void
BlackoilAquiferModel<TypeTag>::endEpisode() BlackoilAquiferModel<TypeTag>::endEpisode()
{ } {
}
template <typename TypeTag> template <typename TypeTag>
template <class Restarter> template <class Restarter>
@ -166,18 +156,14 @@ namespace Opm {
const auto& gridView = simulator_.gridView(); const auto& gridView = simulator_.gridView();
const int number_of_cells = gridView.size(0); const int number_of_cells = gridView.size(0);
cartesian_to_compressed_ = cartesianToCompressed(number_of_cells, cartesian_to_compressed_ = cartesianToCompressed(number_of_cells, Opm::UgGridHelpers::globalCell(ugrid));
Opm::UgGridHelpers::globalCell(ugrid));
for (size_t i = 0; i < aquifersData.size(); ++i) for (size_t i = 0; i < aquifersData.size(); ++i) {
{ aquifers_CarterTracy.push_back(AquiferCarterTracy<TypeTag>(
aquifers_CarterTracy.push_back( aquifer_connection.at(i), cartesian_to_compressed_, this->simulator_, aquifersData.at(i)));
AquiferCarterTracy<TypeTag> (aquifer_connection.at(i), cartesian_to_compressed_, this->simulator_ , aquifersData.at(i))
);
} }
} }
if(deck.hasKeyword("AQUFETP")) if (deck.hasKeyword("AQUFETP")) {
{
// updateConnectionIntensiveQuantities(); // updateConnectionIntensiveQuantities();
const auto& eclState = this->simulator_.vanguard().eclState(); const auto& eclState = this->simulator_.vanguard().eclState();
@ -193,14 +179,11 @@ namespace Opm {
const auto& gridView = simulator_.gridView(); const auto& gridView = simulator_.gridView();
const int number_of_cells = gridView.size(0); const int number_of_cells = gridView.size(0);
cartesian_to_compressed_ = cartesianToCompressed(number_of_cells, cartesian_to_compressed_ = cartesianToCompressed(number_of_cells, Opm::UgGridHelpers::globalCell(ugrid));
Opm::UgGridHelpers::globalCell(ugrid));
for (size_t i = 0; i < aquifersData.size(); ++i) for (size_t i = 0; i < aquifersData.size(); ++i) {
{ aquifers_Fetkovich.push_back(AquiferFetkovich<TypeTag>(
aquifers_Fetkovich.push_back( aquifer_connection.at(i), cartesian_to_compressed_, this->simulator_, aquifersData.at(i)));
AquiferFetkovich<TypeTag> (aquifer_connection.at(i), cartesian_to_compressed_, this->simulator_ , aquifersData.at(i))
);
} }
} }
} }