mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-07-07 04:53:03 -05:00
Merge pull request #5309 from akva2/aquifers_template_scalar
Aquifer: use Scalar type
This commit is contained in:
commit
1dfdae3892
|
@ -54,6 +54,7 @@ class AquiferAnalytical : public AquiferInterface<TypeTag>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Simulator = GetPropType<TypeTag, Properties::Simulator>;
|
using Simulator = GetPropType<TypeTag, Properties::Simulator>;
|
||||||
|
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
|
||||||
using ElementContext = GetPropType<TypeTag, Properties::ElementContext>;
|
using ElementContext = GetPropType<TypeTag, Properties::ElementContext>;
|
||||||
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
|
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
|
||||||
using BlackoilIndices = GetPropType<TypeTag, Properties::Indices>;
|
using BlackoilIndices = GetPropType<TypeTag, Properties::Indices>;
|
||||||
|
@ -70,9 +71,8 @@ public:
|
||||||
enum { enableSaltPrecipitation = getPropValue<TypeTag, Properties::EnableSaltPrecipitation>() };
|
enum { enableSaltPrecipitation = getPropValue<TypeTag, Properties::EnableSaltPrecipitation>() };
|
||||||
|
|
||||||
static constexpr int numEq = BlackoilIndices::numEq;
|
static constexpr int numEq = BlackoilIndices::numEq;
|
||||||
using Scalar = double;
|
|
||||||
|
|
||||||
using Eval = DenseAd::Evaluation<double, /*size=*/numEq>;
|
using Eval = DenseAd::Evaluation<Scalar, /*size=*/numEq>;
|
||||||
|
|
||||||
using FluidState = BlackOilFluidState<Eval,
|
using FluidState = BlackOilFluidState<Eval,
|
||||||
FluidSystem,
|
FluidSystem,
|
||||||
|
@ -99,12 +99,12 @@ public:
|
||||||
virtual ~AquiferAnalytical()
|
virtual ~AquiferAnalytical()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void computeFaceAreaFraction(const std::vector<double>& total_face_area) override
|
void computeFaceAreaFraction(const std::vector<Scalar>& total_face_area) override
|
||||||
{
|
{
|
||||||
assert (total_face_area.size() >= static_cast<std::vector<double>::size_type>(this->aquiferID()));
|
assert (total_face_area.size() >= static_cast<typename std::vector<Scalar>::size_type>(this->aquiferID()));
|
||||||
|
|
||||||
const auto tfa = total_face_area[this->aquiferID() - 1];
|
const auto tfa = total_face_area[this->aquiferID() - 1];
|
||||||
const auto eps_sqrt = std::sqrt(std::numeric_limits<double>::epsilon());
|
const auto eps_sqrt = std::sqrt(std::numeric_limits<Scalar>::epsilon());
|
||||||
|
|
||||||
if (tfa < eps_sqrt) {
|
if (tfa < eps_sqrt) {
|
||||||
this->alphai_.assign(this->size(), Scalar{0});
|
this->alphai_.assign(this->size(), Scalar{0});
|
||||||
|
@ -122,7 +122,7 @@ public:
|
||||||
this->area_fraction_ = this->totalFaceArea() / tfa;
|
this->area_fraction_ = this->totalFaceArea() / tfa;
|
||||||
}
|
}
|
||||||
|
|
||||||
double totalFaceArea() const override
|
Scalar totalFaceArea() const override
|
||||||
{
|
{
|
||||||
return this->total_face_area_;
|
return this->total_face_area_;
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,7 +260,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
Scalar timeConstantCO2Store() const
|
Scalar timeConstantCO2Store() const
|
||||||
{
|
{
|
||||||
const auto press = this->aquct_data_.initial_pressure.value();
|
const Scalar press = this->aquct_data_.initial_pressure.value();
|
||||||
const auto temp = this->reservoirTemperatureCO2Store();
|
const auto temp = this->reservoirTemperatureCO2Store();
|
||||||
|
|
||||||
auto waterViscosity = Scalar { 0 };
|
auto waterViscosity = Scalar { 0 };
|
||||||
|
@ -287,7 +287,7 @@ private:
|
||||||
|
|
||||||
Scalar waterDensityCO2Store() const
|
Scalar waterDensityCO2Store() const
|
||||||
{
|
{
|
||||||
const auto press = this->aquct_data_.initial_pressure.value();
|
const Scalar press = this->aquct_data_.initial_pressure.value();
|
||||||
const auto temp = this->reservoirTemperatureCO2Store();
|
const auto temp = this->reservoirTemperatureCO2Store();
|
||||||
|
|
||||||
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
|
if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
|
||||||
|
|
|
@ -43,9 +43,10 @@ public:
|
||||||
using ElementMapper = GetPropType<TypeTag, Properties::ElementMapper>;
|
using ElementMapper = GetPropType<TypeTag, Properties::ElementMapper>;
|
||||||
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
|
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
|
||||||
using BlackoilIndices = GetPropType<TypeTag, Properties::Indices>;
|
using BlackoilIndices = GetPropType<TypeTag, Properties::Indices>;
|
||||||
|
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
|
||||||
|
|
||||||
static constexpr int numEq = BlackoilIndices::numEq;
|
static constexpr int numEq = BlackoilIndices::numEq;
|
||||||
using Eval = DenseAd::Evaluation<double, /*size=*/numEq>;
|
using Eval = DenseAd::Evaluation<Scalar, /*size=*/numEq>;
|
||||||
|
|
||||||
AquiferConstantFlux(const std::vector<Aquancon::AquancCell>& connections,
|
AquiferConstantFlux(const std::vector<Aquancon::AquancCell>& connections,
|
||||||
const Simulator& simulator,
|
const Simulator& simulator,
|
||||||
|
@ -68,15 +69,15 @@ public:
|
||||||
|
|
||||||
virtual ~AquiferConstantFlux() = default;
|
virtual ~AquiferConstantFlux() = default;
|
||||||
|
|
||||||
void computeFaceAreaFraction(const std::vector<double>& total_face_area) override
|
void computeFaceAreaFraction(const std::vector<Scalar>& total_face_area) override
|
||||||
{
|
{
|
||||||
assert (total_face_area.size() >= static_cast<std::vector<double>::size_type>(this->aquiferID()));
|
assert (total_face_area.size() >= static_cast<typename std::vector<Scalar>::size_type>(this->aquiferID()));
|
||||||
|
|
||||||
this->area_fraction_ = this->totalFaceArea()
|
this->area_fraction_ = this->totalFaceArea()
|
||||||
/ total_face_area[this->aquiferID() - 1];
|
/ total_face_area[this->aquiferID() - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
double totalFaceArea() const override
|
Scalar totalFaceArea() const override
|
||||||
{
|
{
|
||||||
return this->total_face_area_;
|
return this->total_face_area_;
|
||||||
}
|
}
|
||||||
|
@ -163,12 +164,12 @@ private:
|
||||||
SingleAquiferFlux aquifer_data_;
|
SingleAquiferFlux aquifer_data_;
|
||||||
std::vector<Eval> connection_flux_{};
|
std::vector<Eval> connection_flux_{};
|
||||||
std::vector<int> cellToConnectionIdx_{};
|
std::vector<int> cellToConnectionIdx_{};
|
||||||
double flux_rate_{};
|
Scalar flux_rate_{};
|
||||||
double cumulative_flux_{};
|
Scalar cumulative_flux_{};
|
||||||
double total_face_area_{0.0};
|
Scalar total_face_area_{0.0};
|
||||||
double area_fraction_{1.0};
|
Scalar area_fraction_{1.0};
|
||||||
|
|
||||||
double initializeConnections()
|
Scalar initializeConnections()
|
||||||
{
|
{
|
||||||
auto connected_face_area = 0.0;
|
auto connected_face_area = 0.0;
|
||||||
|
|
||||||
|
@ -196,7 +197,7 @@ private:
|
||||||
return connected_face_area;
|
return connected_face_area;
|
||||||
}
|
}
|
||||||
|
|
||||||
double computeFaceAreaFraction(const double connected_face_area) const
|
Scalar computeFaceAreaFraction(const Scalar connected_face_area) const
|
||||||
{
|
{
|
||||||
const auto tot_face_area = this->simulator_.vanguard()
|
const auto tot_face_area = this->simulator_.vanguard()
|
||||||
.grid().comm().sum(connected_face_area);
|
.grid().comm().sum(connected_face_area);
|
||||||
|
@ -215,11 +216,11 @@ private:
|
||||||
return FluidSystem::waterCompIdx;
|
return FluidSystem::waterCompIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
double totalFluxRate() const
|
Scalar totalFluxRate() const
|
||||||
{
|
{
|
||||||
return std::accumulate(this->connection_flux_.begin(),
|
return std::accumulate(this->connection_flux_.begin(),
|
||||||
this->connection_flux_.end(), 0.0,
|
this->connection_flux_.end(), 0.0,
|
||||||
[](const double rate, const auto& q)
|
[](const Scalar rate, const auto& q)
|
||||||
{
|
{
|
||||||
return rate + getValue(q);
|
return rate + getValue(q);
|
||||||
});
|
});
|
||||||
|
|
|
@ -37,6 +37,7 @@ public:
|
||||||
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
|
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
|
||||||
using RateVector = GetPropType<TypeTag, Properties::RateVector>;
|
using RateVector = GetPropType<TypeTag, Properties::RateVector>;
|
||||||
using Simulator = GetPropType<TypeTag, Properties::Simulator>;
|
using Simulator = GetPropType<TypeTag, Properties::Simulator>;
|
||||||
|
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
AquiferInterface(int aqID,
|
AquiferInterface(int aqID,
|
||||||
|
@ -58,8 +59,8 @@ public:
|
||||||
|
|
||||||
virtual data::AquiferData aquiferData() const = 0;
|
virtual data::AquiferData aquiferData() const = 0;
|
||||||
|
|
||||||
virtual void computeFaceAreaFraction(const std::vector<double>& total_face_area) = 0;
|
virtual void computeFaceAreaFraction(const std::vector<Scalar>& total_face_area) = 0;
|
||||||
virtual double totalFaceArea() const = 0;
|
virtual Scalar totalFaceArea() const = 0;
|
||||||
|
|
||||||
template <class Context>
|
template <class Context>
|
||||||
void addToSource(RateVector& rates,
|
void addToSource(RateVector& rates,
|
||||||
|
|
|
@ -50,12 +50,13 @@ public:
|
||||||
using IntensiveQuantities = GetPropType<TypeTag, Properties::IntensiveQuantities>;
|
using IntensiveQuantities = GetPropType<TypeTag, Properties::IntensiveQuantities>;
|
||||||
using MaterialLaw = GetPropType<TypeTag, Properties::MaterialLaw>;
|
using MaterialLaw = GetPropType<TypeTag, Properties::MaterialLaw>;
|
||||||
using Simulator = GetPropType<TypeTag, Properties::Simulator>;
|
using Simulator = GetPropType<TypeTag, Properties::Simulator>;
|
||||||
|
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
|
||||||
|
|
||||||
enum { dimWorld = GridView::dimensionworld };
|
enum { dimWorld = GridView::dimensionworld };
|
||||||
enum { numPhases = FluidSystem::numPhases };
|
enum { numPhases = FluidSystem::numPhases };
|
||||||
static constexpr int numEq = BlackoilIndices::numEq;
|
static constexpr int numEq = BlackoilIndices::numEq;
|
||||||
|
|
||||||
using Eval = DenseAd::Evaluation<double, numEq>;
|
using Eval = DenseAd::Evaluation<Scalar, numEq>;
|
||||||
using Toolbox = MathToolbox<Eval>;
|
using Toolbox = MathToolbox<Eval>;
|
||||||
|
|
||||||
using typename AquiferInterface<TypeTag>::RateVector;
|
using typename AquiferInterface<TypeTag>::RateVector;
|
||||||
|
@ -111,7 +112,10 @@ public:
|
||||||
if (const auto* aqData = xaqPos->second.typeData.template get<data::AquiferType::Numerical>();
|
if (const auto* aqData = xaqPos->second.typeData.template get<data::AquiferType::Numerical>();
|
||||||
aqData != nullptr)
|
aqData != nullptr)
|
||||||
{
|
{
|
||||||
this->init_pressure_ = aqData->initPressure;
|
this->init_pressure_.resize(aqData->initPressure.size());
|
||||||
|
std::copy(aqData->initPressure.begin(),
|
||||||
|
aqData->initPressure.end(),
|
||||||
|
this->init_pressure_.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
this->solution_set_from_restart_ = true;
|
this->solution_set_from_restart_ = true;
|
||||||
|
@ -136,7 +140,10 @@ public:
|
||||||
data.volume = this->cumulative_flux_;
|
data.volume = this->cumulative_flux_;
|
||||||
|
|
||||||
auto* aquNum = data.typeData.template create<data::AquiferType::Numerical>();
|
auto* aquNum = data.typeData.template create<data::AquiferType::Numerical>();
|
||||||
aquNum->initPressure = this->init_pressure_;
|
aquNum->initPressure.resize(this->init_pressure_.size());
|
||||||
|
std::copy(this->init_pressure_.begin(),
|
||||||
|
this->init_pressure_.end(),
|
||||||
|
aquNum->initPressure.begin());
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -152,10 +159,10 @@ public:
|
||||||
this->cumulative_flux_ = 0.;
|
this->cumulative_flux_ = 0.;
|
||||||
}
|
}
|
||||||
|
|
||||||
void computeFaceAreaFraction(const std::vector<double>& /*total_face_area*/) override
|
void computeFaceAreaFraction(const std::vector<Scalar>& /*total_face_area*/) override
|
||||||
{}
|
{}
|
||||||
|
|
||||||
double totalFaceArea() const override
|
Scalar totalFaceArea() const override
|
||||||
{
|
{
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
@ -177,7 +184,7 @@ public:
|
||||||
this->pressure_ == rhs.pressure_;
|
this->pressure_ == rhs.pressure_;
|
||||||
}
|
}
|
||||||
|
|
||||||
double cumulativeFlux() const
|
Scalar cumulativeFlux() const
|
||||||
{
|
{
|
||||||
return this->cumulative_flux_;
|
return this->cumulative_flux_;
|
||||||
}
|
}
|
||||||
|
@ -205,16 +212,16 @@ private:
|
||||||
elemIt->partitionType() == Dune::InteriorEntity;
|
elemIt->partitionType() == Dune::InteriorEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
double calculateAquiferPressure() const
|
Scalar calculateAquiferPressure() const
|
||||||
{
|
{
|
||||||
auto capture = std::vector<double>(this->init_pressure_.size(), 0.0);
|
auto capture = std::vector<Scalar>(this->init_pressure_.size(), 0.0);
|
||||||
return this->calculateAquiferPressure(capture);
|
return this->calculateAquiferPressure(capture);
|
||||||
}
|
}
|
||||||
|
|
||||||
double calculateAquiferPressure(std::vector<double>& cell_pressure) const
|
Scalar calculateAquiferPressure(std::vector<Scalar>& cell_pressure) const
|
||||||
{
|
{
|
||||||
double sum_pressure_watervolume = 0.;
|
Scalar sum_pressure_watervolume = 0.;
|
||||||
double sum_watervolume = 0.;
|
Scalar sum_watervolume = 0.;
|
||||||
|
|
||||||
ElementContext elem_ctx(this->simulator_);
|
ElementContext elem_ctx(this->simulator_);
|
||||||
const auto& gridView = this->simulator_.gridView();
|
const auto& gridView = this->simulator_.gridView();
|
||||||
|
@ -236,12 +243,12 @@ private:
|
||||||
// TODO: the porosity of the cells are still wrong for numerical aquifer cells
|
// TODO: the porosity of the cells are still wrong for numerical aquifer cells
|
||||||
// Because the dofVolume still based on the grid information.
|
// Because the dofVolume still based on the grid information.
|
||||||
// The pore volume is correct. Extra efforts will be done to get sensible porosity value here later.
|
// The pore volume is correct. Extra efforts will be done to get sensible porosity value here later.
|
||||||
const double water_saturation = fs.saturation(this->phaseIdx_()).value();
|
const Scalar water_saturation = fs.saturation(this->phaseIdx_()).value();
|
||||||
const double porosity = iq0.porosity().value();
|
const Scalar porosity = iq0.porosity().value();
|
||||||
const double volume = elem_ctx.dofTotalVolume(0, 0);
|
const Scalar volume = elem_ctx.dofTotalVolume(0, 0);
|
||||||
// TODO: not sure we should use water pressure here
|
// TODO: not sure we should use water pressure here
|
||||||
const double water_pressure_reservoir = fs.pressure(this->phaseIdx_()).value();
|
const Scalar water_pressure_reservoir = fs.pressure(this->phaseIdx_()).value();
|
||||||
const double water_volume = volume * porosity * water_saturation;
|
const Scalar water_volume = volume * porosity * water_saturation;
|
||||||
sum_pressure_watervolume += water_volume * water_pressure_reservoir;
|
sum_pressure_watervolume += water_volume * water_pressure_reservoir;
|
||||||
sum_watervolume += water_volume;
|
sum_watervolume += water_volume;
|
||||||
|
|
||||||
|
@ -260,16 +267,16 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class ElemCtx>
|
template <class ElemCtx>
|
||||||
double getWaterFlux(const ElemCtx& elem_ctx, unsigned face_idx) const
|
Scalar getWaterFlux(const ElemCtx& elem_ctx, unsigned face_idx) const
|
||||||
{
|
{
|
||||||
const auto& exQuants = elem_ctx.extensiveQuantities(face_idx, /*timeIdx*/ 0);
|
const auto& exQuants = elem_ctx.extensiveQuantities(face_idx, /*timeIdx*/ 0);
|
||||||
const double water_flux = Toolbox::value(exQuants.volumeFlux(this->phaseIdx_()));
|
const Scalar water_flux = Toolbox::value(exQuants.volumeFlux(this->phaseIdx_()));
|
||||||
return water_flux;
|
return water_flux;
|
||||||
}
|
}
|
||||||
|
|
||||||
double calculateAquiferFluxRate() const
|
Scalar calculateAquiferFluxRate() const
|
||||||
{
|
{
|
||||||
double aquifer_flux = 0.0;
|
Scalar aquifer_flux = 0.0;
|
||||||
|
|
||||||
if (! this->connects_to_reservoir_) {
|
if (! this->connects_to_reservoir_) {
|
||||||
return aquifer_flux;
|
return aquifer_flux;
|
||||||
|
@ -312,11 +319,11 @@ private:
|
||||||
elem_ctx.updateAllIntensiveQuantities();
|
elem_ctx.updateAllIntensiveQuantities();
|
||||||
elem_ctx.updateAllExtensiveQuantities();
|
elem_ctx.updateAllExtensiveQuantities();
|
||||||
|
|
||||||
const double water_flux = getWaterFlux(elem_ctx,face_idx);
|
const Scalar water_flux = getWaterFlux(elem_ctx,face_idx);
|
||||||
const std::size_t up_id = water_flux >= 0.0 ? i : j;
|
const std::size_t up_id = water_flux >= 0.0 ? i : j;
|
||||||
const auto& intQuantsIn = elem_ctx.intensiveQuantities(up_id, 0);
|
const auto& intQuantsIn = elem_ctx.intensiveQuantities(up_id, 0);
|
||||||
const double invB = Toolbox::value(intQuantsIn.fluidState().invB(this->phaseIdx_()));
|
const Scalar invB = Toolbox::value(intQuantsIn.fluidState().invB(this->phaseIdx_()));
|
||||||
const double face_area = face.area();
|
const Scalar face_area = face.area();
|
||||||
aquifer_flux += water_flux * invB * face_area;
|
aquifer_flux += water_flux * invB * face_area;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,10 +334,10 @@ private:
|
||||||
return aquifer_flux;
|
return aquifer_flux;
|
||||||
}
|
}
|
||||||
|
|
||||||
double flux_rate_; // aquifer influx rate
|
Scalar flux_rate_; // aquifer influx rate
|
||||||
double cumulative_flux_; // cumulative aquifer influx
|
Scalar cumulative_flux_; // cumulative aquifer influx
|
||||||
std::vector<double> init_pressure_{};
|
std::vector<Scalar> init_pressure_{};
|
||||||
double pressure_; // aquifer pressure
|
Scalar pressure_; // aquifer pressure
|
||||||
bool solution_set_from_restart_ {false};
|
bool solution_set_from_restart_ {false};
|
||||||
bool connects_to_reservoir_ {false};
|
bool connects_to_reservoir_ {false};
|
||||||
|
|
||||||
|
|
|
@ -362,7 +362,7 @@ void BlackoilAquiferModel<TypeTag>::computeConnectionAreaFraction() const
|
||||||
|
|
||||||
maxAquID = this->simulator_.vanguard().grid().comm().max(maxAquID);
|
maxAquID = this->simulator_.vanguard().grid().comm().max(maxAquID);
|
||||||
|
|
||||||
auto totalConnArea = std::vector<double>(maxAquID, 0.0);
|
auto totalConnArea = std::vector<Scalar>(maxAquID, 0.0);
|
||||||
for (const auto& aquifer : this->aquifers) {
|
for (const auto& aquifer : this->aquifers) {
|
||||||
totalConnArea[aquifer->aquiferID() - 1] += aquifer->totalFaceArea();
|
totalConnArea[aquifer->aquiferID() - 1] += aquifer->totalFaceArea();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user