Merge pull request #3332 from akva2/fix_trans_writer_par

eclwriter: fix regression in parallel
This commit is contained in:
Bård Skaflestad 2021-06-01 10:32:20 +02:00 committed by GitHub
commit fc47eb8b4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 14 deletions

View File

@ -163,7 +163,6 @@ EclGenericWriter(const Schedule& schedule,
const GridView& gridView,
const Dune::CartesianIndexMapper<Grid>& cartMapper,
const Dune::CartesianIndexMapper<EquilGrid>* equilCartMapper,
const TransmissibilityType& globalTrans,
bool enableAsyncOutput)
: collectToIORank_(grid,
equilGrid,
@ -175,7 +174,6 @@ EclGenericWriter(const Schedule& schedule,
, schedule_(schedule)
, eclState_(eclState)
, summaryConfig_(summaryConfig)
, globalTrans_(globalTrans)
, cartMapper_(cartMapper)
, equilCartMapper_(equilCartMapper)
, equilGrid_(equilGrid)
@ -278,18 +276,18 @@ computeTrans_(const std::unordered_map<int,int>& cartesianToActive) const
int gc2 = std::max(cartIdx1, cartIdx2);
if (gc2 - gc1 == 1 && cartDims[0] > 1 ) {
tranx.data[gc1] = globalTrans_.transmissibility(c1, c2);
tranx.data[gc1] = globalTrans().transmissibility(c1, c2);
continue; // skip other if clauses as they are false, last one needs some computation
}
if (gc2 - gc1 == cartDims[0] && cartDims[1] > 1) {
trany.data[gc1] = globalTrans_.transmissibility(c1, c2);
trany.data[gc1] = globalTrans().transmissibility(c1, c2);
continue; // skipt next if clause as it needs some computation
}
if ( gc2 - gc1 == cartDims[0]*cartDims[1] ||
directVerticalNeighbors(cartDims, cartesianToActive, gc1, gc2))
tranz.data[gc1] = globalTrans_.transmissibility(c1, c2);
tranz.data[gc1] = globalTrans().transmissibility(c1, c2);
}
}
@ -365,7 +363,7 @@ exportNncStructure_(const std::unordered_map<int,int>& cartesianToActive) const
!directVerticalNeighbors(cartDims, cartesianToActive, cc1, cc2)) {
// We need to check whether an NNC for this face was also specified
// via the NNC keyword in the deck (i.e. in the first origNncSize entries.
auto t = globalTrans_.transmissibility(c1, c2);
auto t = globalTrans().transmissibility(c1, c2);
auto candidate = std::lower_bound(nncData.begin(), nncData.end(), NNCdata(cc1, cc2, 0.0));
while ( candidate != nncData.end() && candidate->cell1 == cc1
@ -519,6 +517,15 @@ evalSummary(int reportStepNum,
}
}
template<class Grid, class EquilGrid, class GridView, class ElementMapper, class Scalar>
const typename EclGenericWriter<Grid,EquilGrid,GridView,ElementMapper,Scalar>::TransmissibilityType&
EclGenericWriter<Grid,EquilGrid,GridView,ElementMapper,Scalar>::
globalTrans() const
{
assert (globalTrans_);
return *globalTrans_;
}
#if HAVE_DUNE_FEM
template class EclGenericWriter<Dune::CpGrid,
Dune::CpGrid,

View File

@ -69,14 +69,20 @@ public:
const GridView& gridView,
const Dune::CartesianIndexMapper<Grid>& cartMapper,
const Dune::CartesianIndexMapper<EquilGrid>* equilCartMapper,
const TransmissibilityType& globalTrans,
bool enableAsyncOutput);
const EclipseIO& eclIO() const;
void writeInit();
void setTransmissibilities(const TransmissibilityType* globalTrans)
{
globalTrans_ = globalTrans;
}
protected:
const TransmissibilityType& globalTrans() const;
void doWriteOutput(const int reportStepNum,
const bool isSubStep,
data::Solution&& localCellData,
@ -114,7 +120,7 @@ protected:
std::unique_ptr<EclipseIO> eclIO_;
std::unique_ptr<TaskletRunner> taskletRunner_;
Scalar restartTimeStepSize_;
const TransmissibilityType& globalTrans_;
const TransmissibilityType* globalTrans_ = nullptr;
const Dune::CartesianIndexMapper<Grid>& cartMapper_;
const Dune::CartesianIndexMapper<EquilGrid>* equilCartMapper_;
const EquilGrid* equilGrid_;

View File

@ -791,7 +791,7 @@ public:
ExtboModule::initFromState(vanguard.eclState());
// create the ECL writer
eclWriter_.reset(new EclWriterType(simulator, *this));
eclWriter_.reset(new EclWriterType(simulator));
enableDriftCompensation_ = EWOMS_GET_PARAM(TypeTag, bool, EclEnableDriftCompensation);
@ -926,8 +926,15 @@ public:
}
// write the static output files (EGRID, INIT, SMSPEC, etc.)
if (enableEclOutput_)
if (enableEclOutput_) {
if (simulator.vanguard().grid().comm().size() > 1) {
if (simulator.vanguard().grid().comm().rank() == 0)
eclWriter_->setTransmissibilities(&simulator.vanguard().globalTransmissibility());
} else
eclWriter_->setTransmissibilities(&simulator.problem().eclTransmissibilities());
eclWriter_->writeInit();
}
simulator.vanguard().releaseGlobalTransmissibilities();

View File

@ -112,8 +112,7 @@ public:
// The Simulator object should preferably have been const - the
// only reason that is not the case is due to the SummaryState
// object owned deep down by the vanguard.
template<class Problem>
EclWriter(Simulator& simulator, const Problem& problem)
EclWriter(Simulator& simulator)
: BaseType(simulator.vanguard().schedule(),
simulator.vanguard().eclState(),
simulator.vanguard().summaryConfig(),
@ -122,7 +121,6 @@ public:
simulator.vanguard().gridView(),
simulator.vanguard().cartesianIndexMapper(),
simulator.vanguard().grid().comm().rank() == 0 ? &simulator.vanguard().equilCartesianIndexMapper() : nullptr,
simulator.vanguard().grid().comm().size() > 1 ? simulator.vanguard().globalTransmissibility() : problem.eclTransmissibilities(),
EWOMS_GET_PARAM(TypeTag, bool, EnableAsyncEclOutput))
, simulator_(simulator)
{

View File

@ -159,7 +159,7 @@ BOOST_AUTO_TEST_CASE(Summary)
typedef Opm::EclWriter<TypeTag> EclWriterType;
// create the actual ECL writer
std::unique_ptr<EclWriterType> eclWriter = std::unique_ptr<EclWriterType>(new EclWriterType(*simulator, simulator->problem()));
std::unique_ptr<EclWriterType> eclWriter = std::unique_ptr<EclWriterType>(new EclWriterType(*simulator));
simulator->model().applyInitialSolution();
Opm::data::Wells dw;