mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
restruct so that we can release the global trans earlier
in the funciton finishInit().
This commit is contained in:
@@ -85,7 +85,7 @@ public:
|
||||
|
||||
const EclipseIO& eclIO() const;
|
||||
|
||||
void writeInit(const std::function<unsigned int(unsigned int)>& map);
|
||||
void writeInit();
|
||||
|
||||
void setTransmissibilities(const TransmissibilityType* globalTrans)
|
||||
{
|
||||
@@ -111,6 +111,8 @@ public:
|
||||
return collectOnIORank_;
|
||||
}
|
||||
|
||||
void extractOutputTransAndNNC(const std::function<unsigned int(unsigned int)>& map);
|
||||
|
||||
protected:
|
||||
const TransmissibilityType& globalTrans() const;
|
||||
unsigned int gridEquilIdxToGridIdx(unsigned int elemIndex) const;
|
||||
@@ -164,6 +166,7 @@ protected:
|
||||
SimulatorReportSingle sub_step_report_;
|
||||
SimulatorReport simulation_report_;
|
||||
mutable std::vector<NNCdata> outputNnc_;
|
||||
std::unique_ptr<data::Solution> outputTrans_;
|
||||
|
||||
private:
|
||||
data::Solution computeTrans_(const std::unordered_map<int,int>& cartesianToActive, const std::function<unsigned int(unsigned int)>& map) const;
|
||||
|
||||
@@ -241,7 +241,7 @@ eclIO() const
|
||||
|
||||
template<class Grid, class EquilGrid, class GridView, class ElementMapper, class Scalar>
|
||||
void EclGenericWriter<Grid,EquilGrid,GridView,ElementMapper,Scalar>::
|
||||
writeInit(const std::function<unsigned int(unsigned int)>& map)
|
||||
writeInit()
|
||||
{
|
||||
if (collectOnIORank_.isIORank()) {
|
||||
std::map<std::string, std::vector<int>> integerVectors;
|
||||
@@ -249,11 +249,21 @@ writeInit(const std::function<unsigned int(unsigned int)>& map)
|
||||
integerVectors.emplace("MPI_RANK", collectOnIORank_.globalRanks());
|
||||
}
|
||||
|
||||
auto cartMap = cartesianToCompressed(equilGrid_->size(0), UgGridHelpers::globalCell(*equilGrid_));
|
||||
|
||||
eclIO_->writeInitial(computeTrans_(cartMap, map),
|
||||
eclIO_->writeInitial(*this->outputTrans_,
|
||||
integerVectors,
|
||||
exportNncStructure_(cartMap, map));
|
||||
this->outputNnc_);
|
||||
this->outputTrans_.reset();
|
||||
}
|
||||
}
|
||||
template<class Grid, class EquilGrid, class GridView, class ElementMapper, class Scalar>
|
||||
void
|
||||
EclGenericWriter<Grid,EquilGrid,GridView,ElementMapper,Scalar>::
|
||||
extractOutputTransAndNNC(const std::function<unsigned int(unsigned int)>& map)
|
||||
{
|
||||
if (collectOnIORank_.isIORank()) {
|
||||
auto cartMap = cartesianToCompressed(equilGrid_->size(0), UgGridHelpers::globalCell(*equilGrid_));
|
||||
this->outputTrans_ = std::make_unique<data::Solution>(computeTrans_(cartMap, map));
|
||||
exportNncStructure_(cartMap, map);
|
||||
}
|
||||
|
||||
#if HAVE_MPI
|
||||
|
||||
@@ -343,8 +343,39 @@ public:
|
||||
void finishInit()
|
||||
{
|
||||
ParentType::finishInit();
|
||||
|
||||
auto& simulator = this->simulator();
|
||||
|
||||
bool transmissiblity_updated = false;
|
||||
auto processTransmissibilities = [&simulator, &transmissiblity_updated, this]() {
|
||||
// Re-ordering in case of ALUGrid
|
||||
auto gridToEquilGrid = [&simulator](unsigned int i) -> unsigned int {
|
||||
return simulator.vanguard().gridIdxToEquilGridIdx(i);
|
||||
};
|
||||
|
||||
transmissibilities_.finishInit(gridToEquilGrid);
|
||||
transmissiblity_updated = true;
|
||||
};
|
||||
|
||||
// calculating the TRANX, TRANY, TRANZ and NNC for output purpose
|
||||
// for parallel running, it is based on global trans_
|
||||
// for serial running, it is based on the transmissibilities_
|
||||
// we try to avoid for the parallel running, has both global trans_ and transmissibilities_ allocated at the same time
|
||||
if (enableEclOutput_) {
|
||||
if (simulator.vanguard().grid().comm().size() > 1) {
|
||||
if (simulator.vanguard().grid().comm().rank() == 0)
|
||||
eclWriter_->setTransmissibilities(&simulator.vanguard().globalTransmissibility());
|
||||
} else {
|
||||
processTransmissibilities();
|
||||
eclWriter_->setTransmissibilities(&simulator.problem().eclTransmissibilities());
|
||||
}
|
||||
|
||||
std::function<unsigned int(unsigned int)> equilGridToGrid = [&simulator](unsigned int i) {
|
||||
return simulator.vanguard().gridEquilIdxToGridIdx(i);
|
||||
};
|
||||
eclWriter_->extractOutputTransAndNNC(equilGridToGrid);
|
||||
}
|
||||
simulator.vanguard().releaseGlobalTransmissibilities();
|
||||
|
||||
const auto& eclState = simulator.vanguard().eclState();
|
||||
const auto& schedule = simulator.vanguard().schedule();
|
||||
|
||||
@@ -401,11 +432,15 @@ public:
|
||||
readMaterialParameters_();
|
||||
readThermalParameters_();
|
||||
|
||||
// Re-ordering in case of ALUGrid
|
||||
std::function<unsigned int(unsigned int)> gridToEquilGrid = [&simulator](unsigned int i) {
|
||||
return simulator.vanguard().gridIdxToEquilGridIdx(i);
|
||||
};
|
||||
transmissibilities_.finishInit(gridToEquilGrid);
|
||||
// write the static output files (EGRID, INIT)
|
||||
if (enableEclOutput_) {
|
||||
eclWriter_->writeInit();
|
||||
}
|
||||
|
||||
if (!transmissiblity_updated) {
|
||||
processTransmissibilities();
|
||||
}
|
||||
|
||||
|
||||
const auto& initconfig = eclState.getInitConfig();
|
||||
tracerModel_.init(initconfig.restartRequested());
|
||||
@@ -435,23 +470,6 @@ public:
|
||||
drift_ = 0.0;
|
||||
}
|
||||
|
||||
// write the static output files (EGRID, INIT, SMSPEC, etc.)
|
||||
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());
|
||||
|
||||
// Re-ordering in case of ALUGrid
|
||||
std::function<unsigned int(unsigned int)> equilGridToGrid = [&simulator](unsigned int i) {
|
||||
return simulator.vanguard().gridEquilIdxToGridIdx(i);
|
||||
};
|
||||
eclWriter_->writeInit(equilGridToGrid);
|
||||
}
|
||||
|
||||
simulator.vanguard().releaseGlobalTransmissibilities();
|
||||
|
||||
// after finishing the initialization and writing the initial solution, we move
|
||||
// to the first "real" episode/report step
|
||||
// for restart the episode index and start is already set
|
||||
|
||||
Reference in New Issue
Block a user