Skip to content

Commit

Permalink
Extract addLgrs, invoke it after loadBalance
Browse files Browse the repository at this point in the history
  • Loading branch information
aritorto committed Feb 13, 2025
1 parent ca550d3 commit 3e59fcb
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 13 deletions.
11 changes: 11 additions & 0 deletions opm/models/io/basevanguard.hh
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ public:
updateGridView_();
}

/*!
* \brief Add LGRs to the grid, if any. Only supported for CpGrid - for now.
*/
void addLgrs()
{
if(&asImp_() != this) {
asImp_().addLgrs();
updateGridView_();
}
}

protected:
// this method should be called after the grid has been allocated
void finalizeInit_()
Expand Down
13 changes: 13 additions & 0 deletions opm/models/utils/simulator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,19 @@ public:
checkParallelException("Could not distribute the vanguard data: ",
exceptionThrown, what);

// Only relevant for CpGrid
if (verbose_)
std::cout << "Adding LGRs, if any\n" << std::flush;

try
{ vanguard_->addLgrs(); }
catch (const std::exception& e) {
catchAction(e, verbose_);
}
checkParallelException("Adding LGRs to the simulation vanguard failed: ",
exceptionThrown, what);


if (verbose_)
std::cout << "Allocating the model\n" << std::flush;
try {
Expand Down
7 changes: 6 additions & 1 deletion opm/simulators/flow/AluGridVanguard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,12 @@ class AluGridVanguard : public FlowBaseVanguard<TypeTag>
globalTrans_->update(false, TransmissibilityType::TransUpdateQuantities::Trans,
[&](unsigned int i) { return gridEquilIdxToGridIdx(i);});
}


}

void addLgrs()
{
// do nothing: AluGrid with LGRs not supported yet!
}

template<class DataHandle>
Expand Down
18 changes: 16 additions & 2 deletions opm/simulators/flow/CpGridVanguard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,23 @@ class CpGridVanguard : public FlowBaseVanguard<TypeTag>
#endif
}

/*!
* \brief Add LGRs and update Leaf Grid View in the simulation grid.
*/
void addLgrs()
{
// Check if input file contains Lgrs.
//
// If there are lgrs, create the grid with them, and update the leaf grid view.
if (const auto& lgrs = this->eclState().getLgrs(); lgrs.size() > 0) {
OpmLog::info("\nAdding LGRs to the grid and updating its leaf grid view");
this->addLgrsUpdateLeafView(lgrs, lgrs.size(), *this->grid_);
}
}

unsigned int gridEquilIdxToGridIdx(unsigned int elemIndex) const {
return elemIndex;
}
return elemIndex;
}

unsigned int gridIdxToEquilGridIdx(unsigned int elemIndex) const {
return elemIndex;
Expand Down
11 changes: 1 addition & 10 deletions opm/simulators/flow/GenericCpGridVanguard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,15 +481,6 @@ void GenericCpGridVanguard<ElementMapper,GridView,Scalar>::doCreateGrids_(Eclips

cartesianIndexMapper_ = std::make_unique<CartesianIndexMapper>(*grid_);

// --- Add LGRs and update Leaf Grid View ---
// Check if input file contains Lgrs.
//
// If there are lgrs, create the grid with them, and update the leaf grid view.
if (const auto& lgrs = eclState.getLgrs(); lgrs.size() > 0) {
OpmLog::info("\nAdding LGRs to the grid and updating its leaf grid view");
this->addLgrsUpdateLeafView(lgrs, lgrs.size(), *this->grid_);
}

#if HAVE_MPI
if (this->grid_->comm().size() > 1) {
// Numerical aquifers generate new NNCs during grid processing. We
Expand Down Expand Up @@ -520,7 +511,7 @@ void GenericCpGridVanguard<ElementMapper,GridView,Scalar>::doCreateGrids_(Eclips
}
#endif

// --- Copy grid with LGRs to equilGrid_ ---
// --- Copy grid to equilGrid_ ---
// We use separate grid objects: one for the calculation of the initial
// condition via EQUIL and one for the actual simulation. The reason is
// that the EQUIL code is allergic to distributed grids and the
Expand Down
4 changes: 4 additions & 0 deletions opm/simulators/flow/PolyhedralGridVanguard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ class PolyhedralGridVanguard : public FlowBaseVanguard<TypeTag>
{ /* do nothing: PolyhedralGrid is not parallel! */
}

void addLgrs()
{ /* do nothing: PolyhedralGrid with LGRs not supported yet! */
}

/*!
* \brief Returns the object which maps a global element index of the simulation grid
* to the corresponding element index of the logically Cartesian index.
Expand Down

0 comments on commit 3e59fcb

Please sign in to comment.