Merge pull request #789 from atgeirr/add_timing_block

Add timing block
This commit is contained in:
Atgeirr Flø Rasmussen
2023-02-28 15:24:07 +01:00
committed by GitHub
3 changed files with 24 additions and 2 deletions

View File

@@ -41,6 +41,7 @@
#include <opm/material/common/Valgrind.hpp>
#include <opm/input/eclipse/EclipseState/Grid/FaceDir.hpp>
#include <opm/common/ErrorMacros.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/utility/CopyablePtr.hpp>
@@ -168,7 +169,7 @@ public:
void update(const ElementContext& elemCtx, unsigned dofIdx, unsigned timeIdx)
{
ParentType::update(elemCtx, dofIdx, timeIdx);
OPM_TIMEBLOCK_LOCAL(blackoilIntensiveQuanititiesUpdate);
const auto& problem = elemCtx.problem();
const auto& priVars = elemCtx.primaryVars(dofIdx, timeIdx);
const auto& linearizationType = problem.model().linearizer().getLinearizationType();

View File

@@ -124,6 +124,7 @@ public:
static void computeStorage(Dune::FieldVector<LhsEval, numEq>& storage,
const IntensiveQuantities& intQuants)
{
OPM_TIMEBLOCK_LOCAL(computeStorage);
// retrieve the intensive quantities for the SCV at the specified point in time
const auto& fs = intQuants.fluidState();
storage = 0.0;
@@ -213,6 +214,7 @@ public:
const Scalar faceArea,
const FaceDir::DirEnum facedir)
{
OPM_TIMEBLOCK_LOCAL(computeFlux);
flux = 0.0;
darcy = 0.0;
Scalar Vin = problem.model().dofTotalVolume(globalIndexIn);
@@ -260,6 +262,7 @@ public:
unsigned scvfIdx,
unsigned timeIdx)
{
OPM_TIMEBLOCK_LOCAL(computeFlux);
assert(timeIdx == 0);
flux = 0.0;
@@ -336,6 +339,7 @@ public:
const Scalar& faceArea,
const FaceDir::DirEnum facedir)
{
OPM_TIMEBLOCK_LOCAL(calculateFluxes);
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
if (!FluidSystem::phaseIsActive(phaseIdx))
continue;
@@ -460,6 +464,7 @@ public:
const IntensiveQuantities& insideIntQuants,
unsigned globalSpaceIdx)
{
OPM_TIMEBLOCK_LOCAL(computeBoundaryFluxFree);
std::array<short, numPhases> upIdx;
std::array<short, numPhases> dnIdx;
RateVector volumeFlux;
@@ -543,6 +548,7 @@ public:
unsigned globalSpaceIdex,
unsigned timeIdx)
{
OPM_TIMEBLOCK_LOCAL(computeSource);
// retrieve the source term intrinsic to the problem
problem.source(source, globalSpaceIdex, timeIdx);
@@ -564,6 +570,7 @@ public:
unsigned dofIdx,
unsigned timeIdx) const
{
OPM_TIMEBLOCK_LOCAL(computeSource);
// retrieve the source term intrinsic to the problem
elemCtx.problem().source(source, elemCtx, dofIdx, timeIdx);

View File

@@ -175,6 +175,7 @@ public:
*/
void linearizeDomain()
{
OPM_TIMEBLOCK(linearizeDomain);
// we defer the initialization of the Jacobian matrix until here because the
// auxiliary modules usually assume the problem, model and grid to be fully
// initialized...
@@ -215,6 +216,7 @@ public:
*/
void linearizeAuxiliaryEquations()
{
OPM_TIMEBLOCK(linearizeAuxilaryEquations);
// flush possible local caches into matrix structure
jacobian_->commit();
@@ -334,6 +336,7 @@ private:
// Construct the BCRS matrix for the Jacobian of the residual function
void createMatrix_()
{
OPM_TIMEBLOCK(createMatrix);
if (!neighborInfo_.empty()) {
// It is ok to call this function multiple times, but it
// should not do anything if already called.
@@ -431,6 +434,7 @@ private:
// Initialize the flows and flores sparse tables
void createFlows_()
{
OPM_TIMEBLOCK(createFlows);
// If FLOWS/FLORES is set in any RPTRST in the schedule, then we initializate the sparse tables
const bool anyFlows = simulator_().problem().eclWriter()->eclOutputModule().anyFlows();
const bool anyFlores = simulator_().problem().eclWriter()->eclOutputModule().anyFlores();
@@ -515,6 +519,7 @@ public:
private:
void linearize_()
{
OPM_TIMEBLOCK(linearize);
const bool well_local = true;
resetSystem_();
unsigned numCells = model_().numTotalDof();
@@ -524,6 +529,7 @@ private:
#pragma omp parallel for
#endif
for (unsigned globI = 0; globI < numCells; globI++) {
OPM_TIMEBLOCK_LOCAL(linearizationForEachCell);
const auto& nbInfos = neighborInfo_[globI]; // this is a set but should maybe be changed
VectorBlock res(0.0);
MatrixBlock bMat(0.0);
@@ -536,8 +542,11 @@ private:
const IntensiveQuantities& intQuantsIn = *intQuantsInP;
// Flux term.
{
OPM_TIMEBLOCK_LOCAL(fluxCalculationForEachCell);
short loc = 0;
for (const auto& nbInfo : nbInfos) {
OPM_TIMEBLOCK_LOCAL(fluxCalculationForEachFace);
unsigned globJ = nbInfo.neighbor;
assert(globJ != globI);
res = 0.0;
@@ -572,13 +581,17 @@ private:
*nbInfo.matBlockAddress += bMat;
++loc;
}
}
// Accumulation term.
double dt = simulator_().timeStepSize();
double volume = model_().dofTotalVolume(globI);
Scalar storefac = volume / dt;
adres = 0.0;
LocalResidual::computeStorage(adres, intQuantsIn);
{
OPM_TIMEBLOCK_LOCAL(computeStorage);
LocalResidual::computeStorage(adres, intQuantsIn);
}
setResAndJacobi(res, bMat, adres);
// TODO: check recycleFirst etc.
// first we use it as storage cache
@@ -594,6 +607,7 @@ private:
*diagMatAddress_[globI] += bMat;
// wells sources for now (should be moved out)
if (well_local) {
OPM_TIMEBLOCK_LOCAL(localWellAssembly);
res = 0.0;
bMat = 0.0;
adres = 0.0;