mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Refactor BlackoilModelEbos::getConvergence().
The loop over elements to extract data has been moved to a separate function localConvergenceData().
This commit is contained in:
parent
576852b299
commit
48b0024855
@ -705,26 +705,12 @@ namespace Opm {
|
|||||||
return pvSum;
|
return pvSum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compute convergence based on total mass balance (tol_mb) and maximum
|
// Get reservoir quantities on this process needed for convergence calculations.
|
||||||
/// residual mass balance (tol_cnv).
|
double localConvergenceData(std::vector<Scalar>& R_sum,
|
||||||
/// \param[in] timer simulation timer
|
std::vector<Scalar>& maxCoeff,
|
||||||
/// \param[in] dt timestep length
|
std::vector<Scalar>& B_avg)
|
||||||
/// \param[in] iteration current iteration number
|
|
||||||
bool getConvergence(const SimulatorTimerInterface& timer, const int iteration, std::vector<double>& residual_norms)
|
|
||||||
{
|
{
|
||||||
typedef std::vector< Scalar > Vector;
|
double pvSumLocal = 0.0;
|
||||||
|
|
||||||
const double dt = timer.currentStepLength();
|
|
||||||
const double tol_mb = param_.tolerance_mb_;
|
|
||||||
const double tol_cnv = param_.tolerance_cnv_;
|
|
||||||
const double tol_cnv_relaxed = param_.tolerance_cnv_relaxed_;
|
|
||||||
|
|
||||||
const int numComp = numEq;
|
|
||||||
|
|
||||||
Vector R_sum(numComp, 0.0 );
|
|
||||||
Vector B_avg(numComp, 0.0 );
|
|
||||||
Vector maxCoeff(numComp, std::numeric_limits< Scalar >::lowest() );
|
|
||||||
|
|
||||||
const auto& ebosModel = ebosSimulator_.model();
|
const auto& ebosModel = ebosSimulator_.model();
|
||||||
const auto& ebosProblem = ebosSimulator_.problem();
|
const auto& ebosProblem = ebosSimulator_.problem();
|
||||||
|
|
||||||
@ -734,7 +720,6 @@ namespace Opm {
|
|||||||
const auto& gridView = ebosSimulator().gridView();
|
const auto& gridView = ebosSimulator().gridView();
|
||||||
const auto& elemEndIt = gridView.template end</*codim=*/0, Dune::Interior_Partition>();
|
const auto& elemEndIt = gridView.template end</*codim=*/0, Dune::Interior_Partition>();
|
||||||
|
|
||||||
double pvSumLocal = 0.0;
|
|
||||||
for (auto elemIt = gridView.template begin</*codim=*/0, Dune::Interior_Partition>();
|
for (auto elemIt = gridView.template begin</*codim=*/0, Dune::Interior_Partition>();
|
||||||
elemIt != elemEndIt;
|
elemIt != elemEndIt;
|
||||||
++elemIt)
|
++elemIt)
|
||||||
@ -792,9 +777,29 @@ namespace Opm {
|
|||||||
B_avg[ i ] /= Scalar( global_nc_ );
|
B_avg[ i ] /= Scalar( global_nc_ );
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: we remove the maxNormWell for now because the convergence of wells are on a individual well basis.
|
return pvSumLocal;
|
||||||
// Anyway, we need to provide some infromation to help debug the well iteration process.
|
}
|
||||||
|
|
||||||
|
/// Compute convergence based on total mass balance (tol_mb) and maximum
|
||||||
|
/// residual mass balance (tol_cnv).
|
||||||
|
/// \param[in] timer simulation timer
|
||||||
|
/// \param[in] dt timestep length
|
||||||
|
/// \param[in] iteration current iteration number
|
||||||
|
bool getConvergence(const SimulatorTimerInterface& timer, const int iteration, std::vector<double>& residual_norms)
|
||||||
|
{
|
||||||
|
typedef std::vector< Scalar > Vector;
|
||||||
|
|
||||||
|
const double dt = timer.currentStepLength();
|
||||||
|
const double tol_mb = param_.tolerance_mb_;
|
||||||
|
const double tol_cnv = param_.tolerance_cnv_;
|
||||||
|
const double tol_cnv_relaxed = param_.tolerance_cnv_relaxed_;
|
||||||
|
|
||||||
|
const int numComp = numEq;
|
||||||
|
|
||||||
|
Vector R_sum(numComp, 0.0 );
|
||||||
|
Vector maxCoeff(numComp, std::numeric_limits< Scalar >::lowest() );
|
||||||
|
Vector B_avg(numComp, 0.0 );
|
||||||
|
const double pvSumLocal = localConvergenceData(R_sum, maxCoeff, B_avg);
|
||||||
|
|
||||||
// compute global sum and max of quantities
|
// compute global sum and max of quantities
|
||||||
const double pvSum = convergenceReduction(grid_.comm(), pvSumLocal,
|
const double pvSum = convergenceReduction(grid_.comm(), pvSumLocal,
|
||||||
|
Loading…
Reference in New Issue
Block a user