-- removed double evaluation of processLocalData

-- separated fluid in place work from other cell based data
-- added some timing macros for better preformance overview
This commit is contained in:
hnil 2023-03-21 22:29:56 +01:00
parent e25657943e
commit e1c4a73c43
5 changed files with 49 additions and 6 deletions

View File

@ -169,6 +169,7 @@ EclGenericOutputBlackoilModule(const EclipseState& eclState,
, enableSaltPrecipitation_(enableSaltPrecipitation) , enableSaltPrecipitation_(enableSaltPrecipitation)
, enableExtbo_(enableExtbo) , enableExtbo_(enableExtbo)
, enableMICP_(enableMICP) , enableMICP_(enableMICP)
, local_data_valid_(false)
{ {
const auto& fp = eclState_.fieldProps(); const auto& fp = eclState_.fieldProps();

View File

@ -249,6 +249,18 @@ public:
return this->initialInplace_.value(); return this->initialInplace_.value();
} }
bool localDataValid() const{
return local_data_valid_;
}
void invalidateLocalData(){
local_data_valid_ = false;
}
void validateLocalData(){
local_data_valid_ = true;
}
// Virtual destructor for safer inheritance. // Virtual destructor for safer inheritance.
virtual ~EclGenericOutputBlackoilModule(); virtual ~EclGenericOutputBlackoilModule();
@ -543,6 +555,7 @@ protected:
std::map<std::size_t , double> wbpData_; std::map<std::size_t , double> wbpData_;
std::optional<Inplace> initialInplace_; std::optional<Inplace> initialInplace_;
bool local_data_valid_;
}; };
} // namespace Opm } // namespace Opm

View File

@ -546,7 +546,7 @@ public:
} }
// Add fluid in Place values // Add fluid in Place values
updateFluidInPlace_(elemCtx, dofIdx); //updateFluidInPlace_(elemCtx, dofIdx);
// Adding block data // Adding block data
const auto cartesianIdx = elemCtx.simulator().vanguard().cartesianIndex(globalDofIdx); const auto cartesianIdx = elemCtx.simulator().vanguard().cartesianIndex(globalDofIdx);
@ -978,6 +978,11 @@ public:
} }
} }
void updateFluidInPlace(const ElementContext& elemCtx){
for (unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(/*timeIdx=*/0); ++dofIdx) {
updateFluidInPlace_(elemCtx, dofIdx);
}
}
private: private:
bool isDefunctParallelWell(std::string wname) const override bool isDefunctParallelWell(std::string wname) const override
{ {

View File

@ -175,6 +175,7 @@ public:
*/ */
void evalSummaryState(bool isSubStep) void evalSummaryState(bool isSubStep)
{ {
OPM_TIMEBLOCK(evalSummaryState);
const int reportStepNum = simulator_.episodeIndex() + 1; const int reportStepNum = simulator_.episodeIndex() + 1;
/* /*
The summary data is not evaluated for timestep 0, that is The summary data is not evaluated for timestep 0, that is
@ -247,9 +248,12 @@ public:
std::map<std::string, double> miscSummaryData; std::map<std::string, double> miscSummaryData;
std::map<std::string, std::vector<double>> regionData; std::map<std::string, std::vector<double>> regionData;
auto inplace = eclOutputModule_->outputFipLog(miscSummaryData, regionData, isSubStep, simulator_.gridView().comm()); Inplace inplace;
{
OPM_TIMEBLOCK(outputFipLogAndFipresvLog);
inplace = eclOutputModule_->outputFipLog(miscSummaryData, regionData, isSubStep, simulator_.gridView().comm());
eclOutputModule_->outputFipresvLog(miscSummaryData, regionData, isSubStep, simulator_.gridView().comm()); eclOutputModule_->outputFipresvLog(miscSummaryData, regionData, isSubStep, simulator_.gridView().comm());
}
bool forceDisableProdOutput = false; bool forceDisableProdOutput = false;
bool forceDisableInjOutput = false; bool forceDisableInjOutput = false;
bool forceDisableCumOutput = false; bool forceDisableCumOutput = false;
@ -279,7 +283,8 @@ public:
if (this->simulation_report_.success.total_newton_iterations != 0) { if (this->simulation_report_.success.total_newton_iterations != 0) {
miscSummaryData["MSUMNEWT"] = this->simulation_report_.success.total_newton_iterations; miscSummaryData["MSUMNEWT"] = this->simulation_report_.success.total_newton_iterations;
} }
{
OPM_TIMEBLOCK(evalSummary);
this->evalSummary(reportStepNum, curTime, this->evalSummary(reportStepNum, curTime,
this->collectToIORank_.isParallel() ? this->collectToIORank_.isParallel() ?
this->collectToIORank_.globalWBPData() : this->collectToIORank_.globalWBPData() :
@ -297,10 +302,13 @@ public:
? this->collectToIORank_.globalInterRegFlows() ? this->collectToIORank_.globalInterRegFlows()
: this->eclOutputModule_->getInterRegFlows(), : this->eclOutputModule_->getInterRegFlows(),
summaryState(), udqState()); summaryState(), udqState());
}
{
OPM_TIMEBLOCK(outputXXX);
eclOutputModule_->outputProdLog(reportStepNum, isSubStep, forceDisableProdOutput); eclOutputModule_->outputProdLog(reportStepNum, isSubStep, forceDisableProdOutput);
eclOutputModule_->outputInjLog(reportStepNum, isSubStep, forceDisableInjOutput); eclOutputModule_->outputInjLog(reportStepNum, isSubStep, forceDisableInjOutput);
eclOutputModule_->outputCumLog(reportStepNum, isSubStep, forceDisableCumOutput); eclOutputModule_->outputCumLog(reportStepNum, isSubStep, forceDisableCumOutput);
}
} }
void writeOutput(bool isSubStep) void writeOutput(bool isSubStep)
@ -470,7 +478,7 @@ public:
void endRestart() void endRestart()
{} {}
const EclOutputBlackOilModule<TypeTag>& eclOutputModule() const EclOutputBlackOilModule<TypeTag>& eclOutputModule() const
{ return *eclOutputModule_; } { return *eclOutputModule_; }
Scalar restartTimeStepSize() const Scalar restartTimeStepSize() const
@ -507,6 +515,7 @@ private:
void prepareLocalCellData(const bool isSubStep, void prepareLocalCellData(const bool isSubStep,
const int reportStepNum) const int reportStepNum)
{ {
if( !(eclOutputModule_->localDataValid()) ){
OPM_TIMEBLOCK(prepareLocalCellData); OPM_TIMEBLOCK(prepareLocalCellData);
const auto& gridView = simulator_.vanguard().gridView(); const auto& gridView = simulator_.vanguard().gridView();
const int numElements = gridView.size(/*codim=*/0); const int numElements = gridView.size(/*codim=*/0);
@ -517,13 +526,27 @@ private:
ElementContext elemCtx(simulator_); ElementContext elemCtx(simulator_);
OPM_BEGIN_PARALLEL_TRY_CATCH(); OPM_BEGIN_PARALLEL_TRY_CATCH();
{
OPM_TIMEBLOCK(prepareCellBasedData);
for (const auto& elem : elements(gridView)) { for (const auto& elem : elements(gridView)) {
elemCtx.updatePrimaryStencil(elem); elemCtx.updatePrimaryStencil(elem);
elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0); elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0);
eclOutputModule_->processElement(elemCtx); eclOutputModule_->processElement(elemCtx);
} }
}
{
OPM_TIMEBLOCK(prepareFluidInPlace);
for (const auto& elem : elements(gridView)) {
elemCtx.updatePrimaryStencil(elem);
elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0);
eclOutputModule_->updateFluidInPlace(elemCtx);
}
}
eclOutputModule_->validateLocalData();
OPM_END_PARALLEL_TRY_CATCH("EclWriter::prepareLocalCellData() failed: ", simulator_.vanguard().grid().comm()); OPM_END_PARALLEL_TRY_CATCH("EclWriter::prepareLocalCellData() failed: ", simulator_.vanguard().grid().comm());
}
} }
void captureLocalFluxData() void captureLocalFluxData()

View File

@ -647,6 +647,7 @@ namespace Opm {
{ {
OPM_TIMEBLOCK(invalidateAndUpdateIntensiveQuantities); OPM_TIMEBLOCK(invalidateAndUpdateIntensiveQuantities);
ebosSimulator_.model().invalidateAndUpdateIntensiveQuantities(/*timeIdx=*/0); ebosSimulator_.model().invalidateAndUpdateIntensiveQuantities(/*timeIdx=*/0);
ebosSimulator_.problem().eclWriter()->eclOutputModule().invalidateLocalData();
} }
} }