mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-09-05 04:40:19 -05:00
Merge pull request #4495 from atgeirr/add_timing_block
Add timing block
This commit is contained in:
@@ -631,6 +631,7 @@ namespace Opm {
|
||||
/// Apply an update to the primary variables.
|
||||
void updateSolution(const BVector& dx)
|
||||
{
|
||||
OPM_TIMEBLOCK(updateSolution);
|
||||
auto& ebosNewtonMethod = ebosSimulator_.model().newtonMethod();
|
||||
SolutionVector& solution = ebosSimulator_.model().solution(/*timeIdx=*/0);
|
||||
|
||||
@@ -642,7 +643,10 @@ namespace Opm {
|
||||
// residual
|
||||
|
||||
// if the solution is updated, the intensive quantities need to be recalculated
|
||||
ebosSimulator_.model().invalidateAndUpdateIntensiveQuantities(/*timeIdx=*/0);
|
||||
{
|
||||
OPM_TIMEBLOCK(invalidateAndUpdateIntensiveQuantities);
|
||||
ebosSimulator_.model().invalidateAndUpdateIntensiveQuantities(/*timeIdx=*/0);
|
||||
}
|
||||
}
|
||||
|
||||
/// Return true if output to cout is wanted.
|
||||
@@ -659,6 +663,7 @@ namespace Opm {
|
||||
std::vector< Scalar >& maxCoeff,
|
||||
std::vector< Scalar >& B_avg)
|
||||
{
|
||||
OPM_TIMEBLOCK(convergenceReduction);
|
||||
// Compute total pore volume (use only owned entries)
|
||||
double pvSum = pvSumLocal;
|
||||
double numAquiferPvSum = numAquiferPvSumLocal;
|
||||
@@ -718,6 +723,7 @@ namespace Opm {
|
||||
std::vector<Scalar>& maxCoeff,
|
||||
std::vector<Scalar>& B_avg)
|
||||
{
|
||||
OPM_TIMEBLOCK(localConvergenceData);
|
||||
double pvSumLocal = 0.0;
|
||||
double numAquiferPvSumLocal = 0.0;
|
||||
const auto& ebosModel = ebosSimulator_.model();
|
||||
@@ -848,6 +854,7 @@ namespace Opm {
|
||||
/// of a numerical aquifer.
|
||||
double computeCnvErrorPv(const std::vector<Scalar>& B_avg, double dt)
|
||||
{
|
||||
OPM_TIMEBLOCK(computeCnvErrorPv);
|
||||
double errorPV{};
|
||||
const auto& ebosModel = ebosSimulator_.model();
|
||||
const auto& ebosProblem = ebosSimulator_.problem();
|
||||
@@ -895,6 +902,7 @@ namespace Opm {
|
||||
std::vector<Scalar>& B_avg,
|
||||
std::vector<Scalar>& residual_norms)
|
||||
{
|
||||
OPM_TIMEBLOCK(getReservoirConvergence);
|
||||
typedef std::vector< Scalar > Vector;
|
||||
|
||||
const int numComp = numEq;
|
||||
@@ -1004,13 +1012,16 @@ namespace Opm {
|
||||
const int iteration,
|
||||
std::vector<double>& residual_norms)
|
||||
{
|
||||
OPM_TIMEBLOCK(getConvergence);
|
||||
// Get convergence reports for reservoir and wells.
|
||||
std::vector<Scalar> B_avg(numEq, 0.0);
|
||||
auto report = getReservoirConvergence(timer.simulationTimeElapsed(),
|
||||
timer.currentStepLength(),
|
||||
iteration, B_avg, residual_norms);
|
||||
report += wellModel().getWellConvergence(B_avg, /*checkWellGroupControls*/report.converged());
|
||||
|
||||
{
|
||||
OPM_TIMEBLOCK(getWellConvergence);
|
||||
report += wellModel().getWellConvergence(B_avg, /*checkWellGroupControls*/report.converged());
|
||||
}
|
||||
return report;
|
||||
}
|
||||
|
||||
@@ -1033,6 +1044,7 @@ namespace Opm {
|
||||
std::vector<std::vector<double> >
|
||||
computeFluidInPlace(const std::vector<int>& /*fipnum*/) const
|
||||
{
|
||||
OPM_TIMEBLOCK(computeFluidInPlace);
|
||||
//assert(true)
|
||||
//return an empty vector
|
||||
std::vector<std::vector<double> > regionValues(0, std::vector<double>(0,0.0));
|
||||
|
||||
@@ -237,6 +237,7 @@ std::unique_ptr<Matrix> blockJacobiAdjacency(const Grid& grid,
|
||||
converged_(false),
|
||||
matrix_()
|
||||
{
|
||||
OPM_TIMEBLOCK(IstlSolverEbos);
|
||||
const bool on_io_rank = (simulator.gridView().comm().rank() == 0);
|
||||
#if HAVE_MPI
|
||||
comm_.reset( new CommunicationType( simulator_.vanguard().grid().comm() ) );
|
||||
@@ -311,6 +312,7 @@ std::unique_ptr<Matrix> blockJacobiAdjacency(const Grid& grid,
|
||||
|
||||
void prepare(const SparseMatrixAdapter& M, Vector& b)
|
||||
{
|
||||
OPM_TIMEBLOCK(istlSolverEbosPrepare);
|
||||
static bool firstcall = true;
|
||||
#if HAVE_MPI
|
||||
if (firstcall) {
|
||||
@@ -370,6 +372,7 @@ std::unique_ptr<Matrix> blockJacobiAdjacency(const Grid& grid,
|
||||
|
||||
bool solve(Vector& x)
|
||||
{
|
||||
OPM_TIMEBLOCK(istlSolverEbosSolve);
|
||||
calls_ += 1;
|
||||
// Write linear system if asked for.
|
||||
const int verbosity = prm_.get<int>("verbosity", 0);
|
||||
@@ -396,6 +399,7 @@ std::unique_ptr<Matrix> blockJacobiAdjacency(const Grid& grid,
|
||||
x, result))
|
||||
#endif
|
||||
{
|
||||
OPM_TIMEBLOCK(flexibleSolverApply);
|
||||
assert(flexibleSolver_.solver_);
|
||||
flexibleSolver_.solver_->apply(x, *rhs_, result);
|
||||
}
|
||||
@@ -448,7 +452,7 @@ std::unique_ptr<Matrix> blockJacobiAdjacency(const Grid& grid,
|
||||
|
||||
void prepareFlexibleSolver()
|
||||
{
|
||||
|
||||
OPM_TIMEBLOCK(flexibleSolverPrepare);
|
||||
if (shouldCreateSolver()) {
|
||||
std::function<Vector()> trueFunc =
|
||||
[this]
|
||||
@@ -460,7 +464,7 @@ std::unique_ptr<Matrix> blockJacobiAdjacency(const Grid& grid,
|
||||
auto wellOp = std::make_unique<WellModelOperator>(simulator_.problem().wellModel());
|
||||
flexibleSolver_.wellOperator_ = std::move(wellOp);
|
||||
}
|
||||
|
||||
OPM_TIMEBLOCK(flexibleSolverCreate);
|
||||
flexibleSolver_.create(getMatrix(),
|
||||
isParallel(),
|
||||
prm_,
|
||||
@@ -470,6 +474,7 @@ std::unique_ptr<Matrix> blockJacobiAdjacency(const Grid& grid,
|
||||
}
|
||||
else
|
||||
{
|
||||
OPM_TIMEBLOCK(flexibleSolverUpdate);
|
||||
flexibleSolver_.pre_->update();
|
||||
}
|
||||
}
|
||||
@@ -527,6 +532,7 @@ std::unique_ptr<Matrix> blockJacobiAdjacency(const Grid& grid,
|
||||
// conservation equations, ignoring all other terms.
|
||||
Vector getTrueImpesWeights(int pressureVarIndex) const
|
||||
{
|
||||
OPM_TIMEBLOCK(getTrueImpesWeights);
|
||||
Vector weights(rhs_->size());
|
||||
ElementContext elemCtx(simulator_);
|
||||
Amg::getTrueImpesWeights(pressureVarIndex, weights,
|
||||
|
||||
@@ -44,16 +44,19 @@ public:
|
||||
|
||||
virtual void pre(X& x, Y& b) override
|
||||
{
|
||||
OPM_TIMEBLOCK(pre);
|
||||
block_precond_.pre(x, b);
|
||||
}
|
||||
|
||||
virtual void apply(X& v, const Y& d) override
|
||||
{
|
||||
OPM_TIMEBLOCK(apply);
|
||||
block_precond_.apply(v, d);
|
||||
}
|
||||
|
||||
virtual void post(X& x) override
|
||||
{
|
||||
OPM_TIMEBLOCK(post);
|
||||
block_precond_.post(x);
|
||||
}
|
||||
|
||||
@@ -65,6 +68,7 @@ public:
|
||||
// The update() function does nothing for a wrapped preconditioner.
|
||||
virtual void update() override
|
||||
{
|
||||
OPM_TIMEBLOCK(update);
|
||||
orig_precond_.update();
|
||||
}
|
||||
|
||||
|
||||
@@ -95,6 +95,7 @@ void ghost_last_bilu0_decomposition (M& A, size_t interiorSize)
|
||||
template<class M, class CRS, class InvVector>
|
||||
void convertToCRS(const M& A, CRS& lower, CRS& upper, InvVector& inv)
|
||||
{
|
||||
OPM_TIMEBLOCK(convertToCRS);
|
||||
// No need to do anything for 0 rows. Return to prevent indexing a
|
||||
// a zero sized array.
|
||||
if ( A.N() == 0 )
|
||||
@@ -285,6 +286,7 @@ template<class Matrix, class Domain, class Range, class ParallelInfoT>
|
||||
void ParallelOverlappingILU0<Matrix,Domain,Range,ParallelInfoT>::
|
||||
apply (Domain& v, const Range& d)
|
||||
{
|
||||
OPM_TIMEBLOCK(apply);
|
||||
Range& md = reorderD(d);
|
||||
Domain& mv = reorderV(v);
|
||||
|
||||
@@ -354,6 +356,7 @@ template<class Matrix, class Domain, class Range, class ParallelInfoT>
|
||||
void ParallelOverlappingILU0<Matrix,Domain,Range,ParallelInfoT>::
|
||||
update()
|
||||
{
|
||||
OPM_TIMEBLOCK(update);
|
||||
// (For older DUNE versions the communicator might be
|
||||
// invalid if redistribution in AMG happened on the coarset level.
|
||||
// Therefore we check for nonzero size
|
||||
@@ -403,11 +406,13 @@ update()
|
||||
|
||||
try
|
||||
{
|
||||
OPM_TIMEBLOCK(iluDecomposition);
|
||||
if (iluIteration_ == 0) {
|
||||
// create ILU-0 decomposition
|
||||
if (ordering_.empty())
|
||||
{
|
||||
if (ILU_) {
|
||||
OPM_TIMEBLOCK(iluDecompositionMakeMatrix);
|
||||
// The ILU_ matrix is already a copy with the same
|
||||
// sparse structure as A_, but the values of A_ may
|
||||
// have changed, so we must copy all elements.
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace Opm
|
||||
std::shared_ptr<Communication>& commRW,
|
||||
const int nw)
|
||||
{
|
||||
OPM_TIMEBLOCK(extendCommunicatorWithWells);
|
||||
// used for extending the coarse communicator pattern
|
||||
using IndexSet = typename Communication::ParallelIndexSet;
|
||||
using LocalIndex = typename IndexSet::LocalIndex;
|
||||
@@ -104,6 +105,7 @@ namespace Opm
|
||||
|
||||
virtual void createCoarseLevelSystem(const FineOperator& fineOperator) override
|
||||
{
|
||||
OPM_TIMEBLOCK(createCoarseLevelSystem);
|
||||
using CoarseMatrix = typename CoarseOperator::matrix_type;
|
||||
const auto& fineLevelMatrix = fineOperator.getmat();
|
||||
const auto& nw = fineOperator.getNumberOfExtraEquations();
|
||||
@@ -172,6 +174,7 @@ namespace Opm
|
||||
|
||||
virtual void calculateCoarseEntries(const FineOperator& fineOperator) override
|
||||
{
|
||||
OPM_TIMEBLOCK(calculateCoarseEntries);
|
||||
const auto& fineMatrix = fineOperator.getmat();
|
||||
*coarseLevelMatrix_ = 0;
|
||||
auto rowCoarse = coarseLevelMatrix_->begin();
|
||||
@@ -196,6 +199,7 @@ namespace Opm
|
||||
}
|
||||
}
|
||||
if (prm_.get<bool>("add_wells")) {
|
||||
OPM_TIMEBLOCK(cprwAddWellEquation);
|
||||
assert(transpose == false); // not implemented
|
||||
bool use_well_weights = prm_.get<bool>("use_well_weights");
|
||||
fineOperator.addWellPressureEquations(*coarseLevelMatrix_, weights_, use_well_weights);
|
||||
@@ -209,6 +213,7 @@ namespace Opm
|
||||
|
||||
virtual void moveToCoarseLevel(const typename ParentType::FineRangeType& fine) override
|
||||
{
|
||||
OPM_TIMEBLOCK(moveToCoarseLevel);
|
||||
//NB we iterate over fine assumming welldofs is at the end
|
||||
// Set coarse vector to zero
|
||||
this->rhs_ = 0;
|
||||
@@ -233,6 +238,7 @@ namespace Opm
|
||||
|
||||
virtual void moveToFineLevel(typename ParentType::FineDomainType& fine) override
|
||||
{
|
||||
OPM_TIMEBLOCK(moveToFineLevel);
|
||||
//NB we iterate over fine assumming welldofs is at the end
|
||||
auto end = fine.end(), begin = fine.begin();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user