Merge pull request #5426 from totto82/output_every_timestep

fix option for output every timestep
This commit is contained in:
Bård Skaflestad 2024-06-19 12:09:34 +02:00 committed by GitHub
commit acb124bbdc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 26 additions and 17 deletions

View File

@ -118,6 +118,7 @@ protected:
unsigned int gridEquilIdxToGridIdx(unsigned int elemIndex) const;
void doWriteOutput(const int reportStepNum,
const std::optional<int> timeStepNum,
const bool isSubStep,
data::Solution&& localCellData,
data::Wells&& localWellData,

View File

@ -142,6 +142,7 @@ struct EclWriteTasklet : public Opm::TaskletInterface
Opm::UDQState udqState_;
Opm::EclipseIO& eclIO_;
int reportStepNum_;
std::optional<int> timeStepNum_;
bool isSubStep_;
double secondsElapsed_;
Opm::RestartValue restartValue_;
@ -153,6 +154,7 @@ struct EclWriteTasklet : public Opm::TaskletInterface
const Opm::UDQState& udqState,
Opm::EclipseIO& eclIO,
int reportStepNum,
std::optional<int> timeStepNum,
bool isSubStep,
double secondsElapsed,
Opm::RestartValue restartValue,
@ -163,6 +165,7 @@ struct EclWriteTasklet : public Opm::TaskletInterface
, udqState_(udqState)
, eclIO_(eclIO)
, reportStepNum_(reportStepNum)
, timeStepNum_(timeStepNum)
, isSubStep_(isSubStep)
, secondsElapsed_(secondsElapsed)
, restartValue_(std::move(restartValue))
@ -180,7 +183,9 @@ struct EclWriteTasklet : public Opm::TaskletInterface
this->isSubStep_,
this->secondsElapsed_,
std::move(this->restartValue_),
this->writeDoublePrecision_);
this->writeDoublePrecision_,
this->timeStepNum_
);
}
};
@ -524,6 +529,7 @@ exportNncStructure_(const std::unordered_map<int,int>& cartesianToActive,
template<class Grid, class EquilGrid, class GridView, class ElementMapper, class Scalar>
void EclGenericWriter<Grid,EquilGrid,GridView,ElementMapper,Scalar>::
doWriteOutput(const int reportStepNum,
const std::optional<int> timeStepNum,
const bool isSubStep,
data::Solution&& localCellData,
data::Wells&& localWellData,
@ -599,7 +605,7 @@ doWriteOutput(const int reportStepNum,
actionState,
isParallel ? this->collectOnIORank_.globalWellTestState() : std::move(localWTestState),
summaryState, udqState, *this->eclIO_,
reportStepNum, isSubStep, curTime, std::move(restartValue), doublePrecision);
reportStepNum, timeStepNum, isSubStep, curTime, std::move(restartValue), doublePrecision);
// then, make sure that the previous I/O request has been completed
// and the number of incomplete tasklets does not increase between

View File

@ -64,6 +64,12 @@ template<class TypeTag, class MyTypeTag>
struct EclOutputDoublePrecision {
using type = UndefinedProperty;
};
// Write all solutions for visualization, not just the ones for the
// report steps...
template<class TypeTag, class MyTypeTag>
struct EnableWriteAllSolutions {
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag>
struct EnableEsmry {
using type = UndefinedProperty;
@ -398,7 +404,7 @@ public:
auto floresn = this->outputModule_->getFloresn();
// data::Solution localCellData = {};
if (! isSubStep) {
if (! isSubStep || Parameters::get<TypeTag, Properties::EnableWriteAllSolutions>()) {
auto rstep = timer.reportStepNum();
@ -453,8 +459,11 @@ public:
if (this->collectOnIORank_.isIORank()) {
const Scalar curTime = simulator_.time() + simulator_.timeStepSize();
const Scalar nextStepSize = simulator_.problem().nextTimeStepSize();
this->doWriteOutput(reportStepNum, isSubStep,
std::optional<int> timeStepIdx;
if (Parameters::get<TypeTag, Properties::EnableWriteAllSolutions>()) {
timeStepIdx = simulator_.timeStepIndex();
}
this->doWriteOutput(reportStepNum, timeStepIdx, isSubStep,
std::move(localCellData),
std::move(localWellData),
std::move(localGroupAndNetworkData),
@ -627,7 +636,7 @@ private:
countLocalInteriorCellsGridView(gridView);
this->outputModule_->
allocBuffers(num_interior, reportStepNum,
isSubStep, log, /*isRestart*/ false);
isSubStep && !Parameters::get<TypeTag, Properties::EnableWriteAllSolutions>(), log, /*isRestart*/ false);
ElementContext elemCtx(simulator_);

View File

@ -471,6 +471,7 @@ public:
if (!initconfig.restartRequested()) {
simulator.startNextEpisode(schedule.seconds(1));
simulator.setEpisodeIndex(0);
simulator.setTimeStepIndex(0);
}
}
@ -667,6 +668,7 @@ public:
#endif // NDEBUG
auto& simulator = this->simulator();
simulator.setTimeStepIndex(simulator.timeStepIndex()+1);
this->wellModel_.endTimeStep();
this->aquiferModel_.endTimeStep();
@ -692,8 +694,7 @@ public:
}
}
const bool isSubStep = !Parameters::get<TypeTag, Properties::EnableWriteAllSolutions>()
&& !this->simulator().episodeWillBeOver();
const bool isSubStep = !this->simulator().episodeWillBeOver();
// For CpGrid with LGRs, ecl/vtk output is not supported yet.
const auto& grid = this->simulator().vanguard().gridView().grid();
@ -787,8 +788,7 @@ public:
ParentType::writeOutput(verbose);
}
bool isSubStep = !Parameters::get<TypeTag, Properties::EnableWriteAllSolutions>() &&
!this->simulator().episodeWillBeOver();
bool isSubStep = !this->simulator().episodeWillBeOver();
data::Solution localCellData = {};
#if HAVE_DAMARIS

View File

@ -71,13 +71,6 @@ struct WellModel {
using type = UndefinedProperty;
};
// Write all solutions for visualization, not just the ones for the
// report steps...
template<class TypeTag, class MyTypeTag>
struct EnableWriteAllSolutions {
using type = UndefinedProperty;
};
// The number of time steps skipped between writing two consequtive restart files
template<class TypeTag, class MyTypeTag>
struct RestartWritingInterval {