Minor clean-up based on review

This commit is contained in:
Tor Harald Sandve 2018-02-01 13:16:37 +01:00
parent 154e4fd97a
commit d3cb81a7ba
3 changed files with 25 additions and 23 deletions

View File

@ -361,7 +361,7 @@ namespace Ewoms
read( buffer, indexMap, data);
}
// write all block data
// read all block data
unsigned int size = 0;
buffer.read(size);
for (size_t i = 0; i < size; ++i) {

View File

@ -101,19 +101,31 @@ class EclOutputBlackOilModule
};
public:
EclOutputBlackOilModule(const Simulator& simulator)
template<class CollectDataToIORankType>
EclOutputBlackOilModule(const Simulator& simulator, const CollectDataToIORankType& collectToIORank)
: simulator_(simulator)
{
createLocalFipnum_();
firstStep_ = true;
// Summary output is for all steps
const Opm::SummaryConfig summaryConfig = simulator_.gridManager().summaryConfig();
// Initialize block output
for( const auto& node : summaryConfig ) {
if (node.type() == ECL_SMSPEC_BLOCK_VAR) {
if(collectToIORank.isGlobalIdxOnThisRank(node.num() - 1)) {
std::pair<std::string, int> key = std::make_pair(node.keyword(), node.num());
blockValues_[key] = 0.0;
}
}
}
}
/*!
* \brief Allocate memory for the scalar fields we would like to
* write to ECL output files
*/
template<class CollectDataToIORankType>
void allocBuffers(unsigned bufferSize, unsigned reportStepNum, const bool substep, const bool log, const CollectDataToIORankType& collectToIORank)
void allocBuffers(unsigned bufferSize, unsigned reportStepNum, const bool substep, const bool log)
{
if (!std::is_same<Discretization, Ewoms::EcfvDiscretization<TypeTag> >::value)
@ -122,19 +134,6 @@ public:
// Summary output is for all steps
const Opm::SummaryConfig summaryConfig = simulator_.gridManager().summaryConfig();
// block values
if (firstStep_) { // SummaryConfig doesn't change.
for( const auto& node : summaryConfig ) {
if (node.type() == ECL_SMSPEC_BLOCK_VAR) {
if(collectToIORank.isGlobalIdxOnThisRank(node.num() - 1)) {
std::pair<std::string, int> key = std::make_pair(node.keyword(), node.num());
blockValues_[key] = 0.0;
}
}
}
firstStep_ = false;
}
// Only output RESTART_AUXILIARY asked for by the user.
const Opm::RestartConfig& restartConfig = simulator_.gridManager().eclState().getRestartConfig();
std::map<std::string, int> rstKeywords = restartConfig.getRestartKeywords(reportStepNum);
@ -1095,6 +1094,10 @@ private:
ScalarBuffer computeFipForRegions_(const ScalarBuffer& fip, std::vector<int>& regionId, size_t maxNumberOfRegions, bool commSum = true)
{
ScalarBuffer totals(maxNumberOfRegions, 0.0);
if (fip.empty())
return totals;
assert(regionId.size() == fip.size());
for (size_t j = 0; j < regionId.size(); ++j) {
const int regionIdx = regionId[j] - 1;
@ -1231,7 +1234,6 @@ private:
bool outputRestart_;
bool outputFipRestart_;
bool firstStep_;
bool computeFip_;
ScalarBuffer saturation_[numPhases];

View File

@ -94,8 +94,8 @@ class EclWriter
public:
EclWriter(const Simulator& simulator)
: simulator_(simulator)
, eclOutputModule_(simulator)
, collectToIORank_(simulator_.gridManager())
, eclOutputModule_(simulator, collectToIORank_)
{
globalGrid_ = simulator_.gridManager().grid();
globalGrid_.switchToGlobalView();
@ -140,7 +140,7 @@ public:
const auto& gridView = simulator_.gridManager().gridView();
int numElements = gridView.size(/*codim=*/0);
bool log = collectToIORank_.isIORank();
eclOutputModule_.allocBuffers(numElements, episodeIdx, substep, log, collectToIORank_);
eclOutputModule_.allocBuffers(numElements, episodeIdx, substep, log);
ElementContext elemCtx(simulator_);
ElementIterator elemIt = gridView.template begin</*codim=*/0>();
@ -218,7 +218,7 @@ public:
unsigned episodeIdx = simulator_.episodeIndex();
const auto& gridView = simulator_.gridManager().gridView();
unsigned numElements = gridView.size(/*codim=*/0);
eclOutputModule_.allocBuffers(numElements, episodeIdx, /*substep=*/false, /*log=*/false, collectToIORank_);
eclOutputModule_.allocBuffers(numElements, episodeIdx, /*substep=*/false, /*log=*/false);
auto restart_values = eclIO_->loadRestart(solution_keys, extra_keys);
for (unsigned elemIdx = 0; elemIdx < numElements; ++elemIdx) {
@ -393,8 +393,8 @@ private:
{ return simulator_.gridManager().eclState(); }
const Simulator& simulator_;
EclOutputBlackOilModule<TypeTag> eclOutputModule_;
CollectDataToIORankType collectToIORank_;
EclOutputBlackOilModule<TypeTag> eclOutputModule_;
std::unique_ptr<Opm::EclipseIO> eclIO_;
Grid globalGrid_;