add some parallel reductions in aquifer code

This commit is contained in:
Arne Morten Kvarving
2020-12-15 09:01:03 +01:00
parent 91336f30e7
commit fa90bc0709
3 changed files with 17 additions and 4 deletions

View File

@@ -63,6 +63,9 @@ public:
for (const auto& q : this->Qai_) {
this->W_flux_ += q * this->ebos_simulator_.timeStepSize();
}
this->fluxValue_ = this->W_flux_.value();
const auto& comm = this->ebos_simulator_.vanguard().grid().comm();
comm.sum(&this->fluxValue_, 1);
}
Opm::data::AquiferData aquiferData() const
@@ -87,6 +90,7 @@ protected:
Scalar beta_; // Influx constant
// TODO: it is possible it should be a AD variable
Scalar mu_w_; // water viscosity
Scalar fluxValue_; // value of flux
// This function is used to initialize and calculate the alpha_i for each grid connection to the aquifer
inline void initializeConnections() override
@@ -170,6 +174,8 @@ protected:
}
const double eps_sqrt = std::sqrt(std::numeric_limits<double>::epsilon());
const auto& comm = this->ebos_simulator_.vanguard().grid().comm();
comm.sum(&denom_face_areas, 1);
for (size_t idx = 0; idx < this->size(); ++idx) {
this->alphai_.at(idx) = (denom_face_areas < eps_sqrt)
? // Prevent no connection NaNs due to division by zero
@@ -207,7 +213,7 @@ protected:
Scalar PItdprime = 0.;
Scalar PItd = 0.;
getInfluenceTableValues(PItd, PItdprime, td_plus_dt);
a = 1.0 / this->Tc_ * ((beta_ * dpai(idx)) - (this->W_flux_.value() * PItdprime)) / (PItd - td * PItdprime);
a = 1.0 / this->Tc_ * ((beta_ * dpai(idx)) - (this->fluxValue_ * PItdprime)) / (PItd - td * PItdprime);
b = beta_ / (this->Tc_ * (PItd - td * PItdprime));
}

View File

@@ -176,6 +176,8 @@ protected:
denom_face_areas += (this->connections_[idx].influx_mult * this->faceArea_connected_.at(idx));
}
const auto& comm = this->ebos_simulator_.vanguard().grid().comm();
comm.sum(&denom_face_areas, 1);
const double eps_sqrt = std::sqrt(std::numeric_limits<double>::epsilon());
for (size_t idx = 0; idx < this->size(); ++idx) {
this->alphai_.at(idx) = (denom_face_areas < eps_sqrt)
@@ -206,6 +208,8 @@ protected:
inline Scalar aquiferPressure()
{
Scalar Flux = this->W_flux_.value();
const auto& comm = this->ebos_simulator_.vanguard().grid().comm();
comm.sum(&Flux, 1);
Scalar pa_ = this->pa0_ - Flux / (aqufetp_data_.C_t * aqufetp_data_.V0);
return pa_;
}

View File

@@ -278,9 +278,12 @@ protected:
}
// We take the average of the calculated equilibrium pressures.
const Scalar sum_alpha = std::accumulate(this->alphai_.begin(), this->alphai_.end(), 0.);
const Scalar aquifer_pres_avg = std::accumulate(pw_aquifer.begin(), pw_aquifer.end(), 0.) / sum_alpha;
return aquifer_pres_avg;
const auto& comm = ebos_simulator_.vanguard().grid().comm();
Scalar vals[2];
vals[0] = std::accumulate(this->alphai_.begin(), this->alphai_.end(), 0.);
vals[1] = std::accumulate(pw_aquifer.begin(), pw_aquifer.end(), 0.);
comm.sum(vals, 2);
return vals[1] / vals[0];
}
// This function is used to initialize and calculate the alpha_i for each grid connection to the aquifer