mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #4162 from akva2/use_range_generators
Use range generators for grid iterations
This commit is contained in:
commit
7096343121
@ -830,7 +830,7 @@ CollectDataToIORank(const Grid& grid, const EquilGrid* equilGrid,
|
||||
ElementMapper elemMapper(localGridView, Dune::mcmgElementLayout());
|
||||
sortedCartesianIdx_.reserve(localGridView.size(0));
|
||||
|
||||
for(const auto& elem: elements(localGridView))
|
||||
for (const auto& elem : elements(localGridView))
|
||||
{
|
||||
auto idx = elemMapper.index(elem);
|
||||
sortedCartesianIdx_.push_back(cartMapper.cartesianIndex(idx));
|
||||
@ -858,10 +858,8 @@ CollectDataToIORank(const Grid& grid, const EquilGrid* equilGrid,
|
||||
}
|
||||
|
||||
// loop over all elements (global grid) and store Cartesian index
|
||||
auto elemIt = equilGrid->leafGridView().template begin<0>();
|
||||
const auto& elemEndIt = equilGrid->leafGridView().template end<0>();
|
||||
for (; elemIt != elemEndIt; ++elemIt) {
|
||||
int elemIdx = equilElemMapper.index(*elemIt);
|
||||
for (const auto& elem : elements(equilGrid->leafGridView())) {
|
||||
int elemIdx = equilElemMapper.index(elem);
|
||||
int cartElemIdx = equilCartMapper->cartesianIndex(elemIdx);
|
||||
globalCartesianIndex_[elemIdx] = cartElemIdx;
|
||||
}
|
||||
@ -901,11 +899,8 @@ CollectDataToIORank(const Grid& grid, const EquilGrid* equilGrid,
|
||||
distributedCartesianIndex.resize(gridSize, -1);
|
||||
|
||||
// A mapping for the whole grid (including the ghosts) is needed for restarts
|
||||
auto eIt = localGridView.template begin<0>();
|
||||
const auto& eEndIt = localGridView.template end<0>();
|
||||
for (; eIt != eEndIt; ++eIt) {
|
||||
const auto element = *eIt;
|
||||
int elemIdx = elemMapper.index(element);
|
||||
for (const auto& elem : elements(localGridView)) {
|
||||
int elemIdx = elemMapper.index(elem);
|
||||
distributedCartesianIndex[elemIdx] = cartMapper.cartesianIndex(elemIdx);
|
||||
|
||||
// only store interior element for collection
|
||||
|
@ -551,12 +551,9 @@ protected:
|
||||
int numElements = this->gridView().size(/*codim=*/0);
|
||||
cellThickness_.resize(numElements);
|
||||
|
||||
auto elemIt = this->gridView().template begin</*codim=*/0>();
|
||||
const auto& elemEndIt = this->gridView().template end</*codim=*/0>();
|
||||
for (; elemIt != elemEndIt; ++elemIt) {
|
||||
const auto& element = *elemIt;
|
||||
const unsigned int elemIdx = elemMapper.index(element);
|
||||
cellThickness_[elemIdx] = computeCellThickness(element);
|
||||
for (const auto& elem : elements(this->gridView())) {
|
||||
const unsigned int elemIdx = elemMapper.index(elem);
|
||||
cellThickness_[elemIdx] = computeCellThickness(elem);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,19 +163,8 @@ applyExplicitThresholdPressures_()
|
||||
|
||||
// set the threshold pressures for all EQUIL region boundaries which have a
|
||||
// intersection in the grid
|
||||
auto elemIt = gridView_.template begin</*codim=*/ 0>();
|
||||
const auto& elemEndIt = gridView_.template end</*codim=*/ 0>();
|
||||
for (; elemIt != elemEndIt; ++elemIt) {
|
||||
const auto& elem = *elemIt;
|
||||
if (elem.partitionType() != Dune::InteriorEntity)
|
||||
continue;
|
||||
|
||||
auto isIt = gridView_.ibegin(elem);
|
||||
const auto& isEndIt = gridView_.iend(elem);
|
||||
for (; isIt != isEndIt; ++ isIt) {
|
||||
// store intersection, this might be costly
|
||||
const auto& intersection = *isIt;
|
||||
|
||||
for (const auto& elem : elements(gridView_, Dune::Partitions::interior)) {
|
||||
for (const auto& intersection : intersections(gridView_, elem)) {
|
||||
if (intersection.boundary())
|
||||
continue; // ignore boundary intersections for now (TODO?)
|
||||
else if (!intersection.neighbor()) //processor boundary but not domain boundary
|
||||
|
@ -221,10 +221,7 @@ doInit(bool rst, size_t numGridDof,
|
||||
std::vector<NeighborSet> neighbors(numGridDof);
|
||||
|
||||
Stencil stencil(gridView_, dofMapper_);
|
||||
auto elemIt = gridView_.template begin<0>();
|
||||
const auto elemEndIt = gridView_.template end<0>();
|
||||
for (; elemIt != elemEndIt; ++elemIt) {
|
||||
const auto& elem = *elemIt;
|
||||
for (const auto& elem : elements(gridView_)) {
|
||||
stencil.update(elem);
|
||||
|
||||
for (unsigned primaryDofIdx = 0; primaryDofIdx < stencil.numPrimaryDof(); ++primaryDofIdx) {
|
||||
|
@ -285,16 +285,8 @@ computeTrans_(const std::unordered_map<int,int>& cartesianToActive, const std::f
|
||||
using GlobElementMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GlobalGridView>;
|
||||
GlobElementMapper globalElemMapper(globalGridView, Dune::mcmgElementLayout());
|
||||
|
||||
auto elemIt = globalGridView.template begin</*codim=*/0>();
|
||||
const auto& elemEndIt = globalGridView.template end</*codim=*/0>();
|
||||
for (; elemIt != elemEndIt; ++ elemIt) {
|
||||
const auto& elem = *elemIt;
|
||||
|
||||
auto isIt = globalGridView.ibegin(elem);
|
||||
const auto& isEndIt = globalGridView.iend(elem);
|
||||
for (; isIt != isEndIt; ++ isIt) {
|
||||
const auto& is = *isIt;
|
||||
|
||||
for (const auto& elem : elements(globalGridView)) {
|
||||
for (const auto& is : intersections(globalGridView, elem)) {
|
||||
if (!is.neighbor())
|
||||
continue; // intersection is on the domain boundary
|
||||
|
||||
@ -373,16 +365,8 @@ exportNncStructure_(const std::unordered_map<int,int>& cartesianToActive, const
|
||||
// Cartesian index mapper for the serial I/O grid
|
||||
const auto& equilCartMapper = *equilCartMapper_;
|
||||
const auto& cartDims = cartMapper_.cartesianDimensions();
|
||||
auto elemIt = globalGridView.template begin</*codim=*/0>();
|
||||
const auto& elemEndIt = globalGridView.template end</*codim=*/0>();
|
||||
for (; elemIt != elemEndIt; ++ elemIt) {
|
||||
const auto& elem = *elemIt;
|
||||
|
||||
auto isIt = globalGridView.ibegin(elem);
|
||||
const auto& isEndIt = globalGridView.iend(elem);
|
||||
for (; isIt != isEndIt; ++ isIt) {
|
||||
const auto& is = *isIt;
|
||||
|
||||
for (const auto& elem : elements(globalGridView)) {
|
||||
for (const auto& is : intersections(globalGridView, elem)) {
|
||||
if (!is.neighbor())
|
||||
continue; // intersection is on the domain boundary
|
||||
|
||||
|
@ -978,14 +978,11 @@ private:
|
||||
|
||||
void createLocalRegion_(std::vector<int>& region)
|
||||
{
|
||||
ElementContext elemCtx(simulator_);
|
||||
ElementIterator elemIt = simulator_.gridView().template begin</*codim=*/0>();
|
||||
const ElementIterator& elemEndIt = simulator_.gridView().template end</*codim=*/0>();
|
||||
size_t elemIdx = 0;
|
||||
for (; elemIt != elemEndIt; ++elemIt, ++elemIdx) {
|
||||
const Element& elem = *elemIt;
|
||||
for (const auto& elem : elements(simulator_.gridView())) {
|
||||
if (elem.partitionType() != Dune::InteriorEntity)
|
||||
region[elemIdx] = 0;
|
||||
++elemIdx;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2467,13 +2467,7 @@ private:
|
||||
auto& sol = this->model().solution(/*timeIdx=*/0);
|
||||
const auto& gridView = this->gridView();
|
||||
ElementContext elemCtx(simulator);
|
||||
auto elemIt = gridView.template begin</*codim=*/0>();
|
||||
const auto& elemEndIt = gridView.template end</*codim=*/0>();
|
||||
for (; elemIt != elemEndIt; ++elemIt) {
|
||||
const auto& elem = *elemIt;
|
||||
if (elem.partitionType() != Dune::InteriorEntity)
|
||||
continue;
|
||||
|
||||
for (const auto& elem : elements(gridView, Dune::Partitions::interior)) {
|
||||
elemCtx.updatePrimaryStencil(elem);
|
||||
int elemIdx = elemCtx.globalSpaceIndex(/*spaceIdx=*/0, /*timeIdx=*/0);
|
||||
initial(sol[elemIdx], elemCtx, /*spaceIdx=*/0, /*timeIdx=*/0);
|
||||
|
@ -104,15 +104,8 @@ private:
|
||||
using Toolbox = MathToolbox<Evaluation>;
|
||||
// loop over the whole grid and compute the maximum gravity adjusted pressure
|
||||
// difference between two EQUIL regions.
|
||||
auto elemIt = gridView.template begin</*codim=*/ 0>();
|
||||
const auto& elemEndIt = gridView.template end</*codim=*/ 0>();
|
||||
ElementContext elemCtx(simulator_);
|
||||
for (; elemIt != elemEndIt; ++elemIt) {
|
||||
|
||||
const auto& elem = *elemIt;
|
||||
if (elem.partitionType() != Dune::InteriorEntity)
|
||||
continue;
|
||||
|
||||
for (const auto& elem : elements(gridView, Dune::Partitions::interior)) {
|
||||
elemCtx.updateAll(elem);
|
||||
const auto& stencil = elemCtx.stencil(/*timeIdx=*/0);
|
||||
|
||||
|
@ -273,14 +273,12 @@ protected:
|
||||
tr.residual_[tIdx] = 0.0;
|
||||
|
||||
ElementContext elemCtx(simulator_);
|
||||
auto elemIt = simulator_.gridView().template begin</*codim=*/0>();
|
||||
auto elemEndIt = simulator_.gridView().template end</*codim=*/0>();
|
||||
for (; elemIt != elemEndIt; ++ elemIt) {
|
||||
elemCtx.updateAll(*elemIt);
|
||||
for (const auto& elem : elements(simulator_.gridView())) {
|
||||
elemCtx.updateAll(elem);
|
||||
|
||||
size_t I = elemCtx.globalSpaceIndex(/*dofIdx=*/ 0, /*timIdx=*/0);
|
||||
|
||||
if (elemIt->partitionType() != Dune::InteriorEntity)
|
||||
if (elem.partitionType() != Dune::InteriorEntity)
|
||||
{
|
||||
// Dirichlet boundary conditions needed for the parallel matrix
|
||||
(*this->tracerMatrix_)[I][I][0][0] = 1.;
|
||||
|
@ -173,11 +173,7 @@ update(bool global, const std::function<unsigned int(unsigned int)>& map)
|
||||
for (unsigned dimIdx = 0; dimIdx < dimWorld; ++dimIdx)
|
||||
axisCentroids[dimIdx].resize(numElements);
|
||||
|
||||
auto elemIt = gridView_.template begin</*codim=*/ 0>();
|
||||
const auto& elemEndIt = gridView_.template end</*codim=*/ 0>();
|
||||
size_t centroidIdx = 0;
|
||||
for (; elemIt != elemEndIt; ++elemIt, ++centroidIdx) {
|
||||
const auto& elem = *elemIt;
|
||||
for (const auto& elem : elements(gridView_)) {
|
||||
unsigned elemIdx = elemMapper.index(elem);
|
||||
|
||||
// compute the axis specific "centroids" used for the transmissibilities. for
|
||||
@ -227,9 +223,7 @@ update(bool global, const std::function<unsigned int(unsigned int)>& map)
|
||||
}
|
||||
|
||||
// compute the transmissibilities for all intersections
|
||||
elemIt = gridView_.template begin</*codim=*/ 0>();
|
||||
for (; elemIt != elemEndIt; ++elemIt) {
|
||||
const auto& elem = *elemIt;
|
||||
for (const auto& elem : elements(gridView_)) {
|
||||
unsigned elemIdx = elemMapper.index(elem);
|
||||
|
||||
auto isIt = gridView_.ibegin(elem);
|
||||
@ -476,10 +470,8 @@ update(bool global, const std::function<unsigned int(unsigned int)>& map)
|
||||
std::unordered_map<std::size_t,int> globalToLocal;
|
||||
|
||||
// loop over all elements (global grid) and store Cartesian index
|
||||
elemIt = grid_.leafGridView().template begin<0>();
|
||||
|
||||
for (; elemIt != elemEndIt; ++elemIt) {
|
||||
int elemIdx = elemMapper.index(*elemIt);
|
||||
for (const auto& elem : elements(grid_.leafGridView())) {
|
||||
int elemIdx = elemMapper.index(elem);
|
||||
int cartElemIdx = cartMapper_.cartesianIndex(elemIdx);
|
||||
globalToLocal[cartElemIdx] = elemIdx;
|
||||
}
|
||||
@ -700,16 +692,9 @@ createTransmissibilityArrays_(const std::array<bool,3>& is_tran)
|
||||
std::vector<double>(is_tran[2] ? numElem : 0, 0)};
|
||||
|
||||
// compute the transmissibilities for all intersections
|
||||
auto elemIt = gridView_.template begin</*codim=*/ 0>();
|
||||
const auto& elemEndIt = gridView_.template end</*codim=*/ 0>();
|
||||
|
||||
for (; elemIt != elemEndIt; ++elemIt) {
|
||||
const auto& elem = *elemIt;
|
||||
auto isIt = gridView_.ibegin(elem);
|
||||
const auto& isEndIt = gridView_.iend(elem);
|
||||
for (; isIt != isEndIt; ++ isIt) {
|
||||
for (const auto& elem : elements(gridView_)) {
|
||||
for (const auto& intersection : intersections(gridView_, elem)) {
|
||||
// store intersection, this might be costly
|
||||
const auto& intersection = *isIt;
|
||||
if (!intersection.neighbor())
|
||||
continue; // intersection is on the domain boundary
|
||||
|
||||
@ -761,16 +746,8 @@ resetTransmissibilityFromArrays_(const std::array<bool,3>& is_tran,
|
||||
ElementMapper elemMapper(gridView_, Dune::mcmgElementLayout());
|
||||
|
||||
// compute the transmissibilities for all intersections
|
||||
auto elemIt = gridView_.template begin</*codim=*/ 0>();
|
||||
const auto& elemEndIt = gridView_.template end</*codim=*/ 0>();
|
||||
|
||||
for (; elemIt != elemEndIt; ++elemIt) {
|
||||
const auto& elem = *elemIt;
|
||||
auto isIt = gridView_.ibegin(elem);
|
||||
const auto& isEndIt = gridView_.iend(elem);
|
||||
for (; isIt != isEndIt; ++ isIt) {
|
||||
// store intersection, this might be costly
|
||||
const auto& intersection = *isIt;
|
||||
for (const auto& elem : elements(gridView_)) {
|
||||
for (const auto& intersection : intersections(gridView_, elem)) {
|
||||
if (!intersection.neighbor())
|
||||
continue; // intersection is on the domain boundary
|
||||
|
||||
|
@ -493,13 +493,8 @@ private:
|
||||
isSubStep, log, /*isRestart*/ false);
|
||||
|
||||
ElementContext elemCtx(simulator_);
|
||||
ElementIterator elemIt = gridView.template begin</*codim=*/0>();
|
||||
|
||||
const ElementIterator& elemEndIt = gridView.template end</*codim=*/0>();
|
||||
OPM_BEGIN_PARALLEL_TRY_CATCH();
|
||||
for (; elemIt != elemEndIt; ++elemIt) {
|
||||
const Element& elem = *elemIt;
|
||||
|
||||
for (const auto& elem : elements(gridView)) {
|
||||
elemCtx.updatePrimaryStencil(elem);
|
||||
elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0);
|
||||
|
||||
|
@ -114,13 +114,9 @@ public:
|
||||
void beginTimeStep() override
|
||||
{
|
||||
ElementContext elemCtx(this->ebos_simulator_);
|
||||
auto elemIt = this->ebos_simulator_.gridView().template begin<0>();
|
||||
const auto& elemEndIt = this->ebos_simulator_.gridView().template end<0>();
|
||||
OPM_BEGIN_PARALLEL_TRY_CATCH();
|
||||
|
||||
for (; elemIt != elemEndIt; ++elemIt) {
|
||||
const auto& elem = *elemIt;
|
||||
|
||||
for (const auto& elem : elements(this->ebos_simulator_.gridView())) {
|
||||
elemCtx.updatePrimaryStencil(elem);
|
||||
|
||||
const int cellIdx = elemCtx.globalSpaceIndex(0, 0);
|
||||
@ -272,10 +268,7 @@ protected:
|
||||
}
|
||||
// get areas for all connections
|
||||
ElementMapper elemMapper(gridView, Dune::mcmgElementLayout());
|
||||
auto elemIt = gridView.template begin</*codim=*/ 0>();
|
||||
const auto& elemEndIt = gridView.template end</*codim=*/ 0>();
|
||||
for (; elemIt != elemEndIt; ++elemIt) {
|
||||
const auto& elem = *elemIt;
|
||||
for (const auto& elem : elements(gridView)) {
|
||||
unsigned cell_index = elemMapper.index(elem);
|
||||
int idx = this->cellToConnectionIdx_[cell_index];
|
||||
|
||||
@ -283,12 +276,7 @@ protected:
|
||||
if( idx < 0)
|
||||
continue;
|
||||
|
||||
auto isIt = gridView.ibegin(elem);
|
||||
const auto& isEndIt = gridView.iend(elem);
|
||||
for (; isIt != isEndIt; ++ isIt) {
|
||||
// store intersection, this might be costly
|
||||
const auto& intersection = *isIt;
|
||||
|
||||
for (const auto& intersection : intersections(gridView, elem)) {
|
||||
// only deal with grid boundaries
|
||||
if (!intersection.boundary())
|
||||
continue;
|
||||
@ -371,10 +359,7 @@ protected:
|
||||
|
||||
ElementContext elemCtx(this->ebos_simulator_);
|
||||
const auto& gridView = this->ebos_simulator_.gridView();
|
||||
auto elemIt = gridView.template begin</*codim=*/0>();
|
||||
const auto& elemEndIt = gridView.template end</*codim=*/0>();
|
||||
for (; elemIt != elemEndIt; ++elemIt) {
|
||||
const auto& elem = *elemIt;
|
||||
for (const auto& elem : elements(gridView)) {
|
||||
elemCtx.updatePrimaryStencil(elem);
|
||||
|
||||
const auto cellIdx = elemCtx.globalSpaceIndex(/*spaceIdx=*/0, /*timeIdx=*/0);
|
||||
|
@ -176,15 +176,9 @@ private:
|
||||
|
||||
ElementContext elem_ctx(this->ebos_simulator_);
|
||||
const auto& gridView = this->ebos_simulator_.gridView();
|
||||
auto elemIt = gridView.template begin</*codim=*/0>();
|
||||
const auto& elemEndIt = gridView.template end</*codim=*/0>();
|
||||
OPM_BEGIN_PARALLEL_TRY_CATCH();
|
||||
|
||||
for (; elemIt != elemEndIt; ++elemIt) {
|
||||
const auto& elem = *elemIt;
|
||||
if (elem.partitionType() != Dune::InteriorEntity) {
|
||||
continue;
|
||||
}
|
||||
for (const auto& elem : elements(gridView, Dune::Partitions::interior)) {
|
||||
elem_ctx.updatePrimaryStencil(elem);
|
||||
|
||||
const size_t cell_index = elem_ctx.globalSpaceIndex(/*spaceIdx=*/0, /*timeIdx=*/0);
|
||||
@ -240,13 +234,7 @@ private:
|
||||
|
||||
ElementContext elem_ctx(this->ebos_simulator_);
|
||||
const auto& gridView = this->ebos_simulator_.gridView();
|
||||
auto elemIt = gridView.template begin</*codim=*/0>();
|
||||
const auto& elemEndIt = gridView.template end</*codim=*/0>();
|
||||
for (; elemIt != elemEndIt; ++elemIt) {
|
||||
const auto& elem = *elemIt;
|
||||
if (elem.partitionType() != Dune::InteriorEntity) {
|
||||
continue;
|
||||
}
|
||||
for (const auto& elem : elements(gridView, Dune::Partitions::interior)) {
|
||||
// elem_ctx.updatePrimaryStencil(elem);
|
||||
elem_ctx.updateStencil(elem);
|
||||
|
||||
|
@ -453,13 +453,7 @@ namespace Opm {
|
||||
|
||||
const auto& elemMapper = ebosSimulator_.model().elementMapper();
|
||||
const auto& gridView = ebosSimulator_.gridView();
|
||||
auto elemIt = gridView.template begin</*codim=*/0>();
|
||||
const auto& elemEndIt = gridView.template end</*codim=*/0>();
|
||||
for (; elemIt != elemEndIt; ++elemIt) {
|
||||
const auto& elem = *elemIt;
|
||||
if (elem.partitionType() != Dune::InteriorEntity)
|
||||
continue;
|
||||
|
||||
for (const auto& elem : elements(gridView, Dune::Partitions::interior)) {
|
||||
unsigned globalElemIdx = elemMapper.index(elem);
|
||||
const auto& priVarsNew = ebosSimulator_.model().solution(/*timeIdx=*/0)[globalElemIdx];
|
||||
|
||||
@ -667,14 +661,8 @@ namespace Opm {
|
||||
|
||||
ElementContext elemCtx(ebosSimulator_);
|
||||
const auto& gridView = ebosSimulator().gridView();
|
||||
const auto& elemEndIt = gridView.template end</*codim=*/0, Dune::Interior_Partition>();
|
||||
OPM_BEGIN_PARALLEL_TRY_CATCH();
|
||||
|
||||
for (auto elemIt = gridView.template begin</*codim=*/0, Dune::Interior_Partition>();
|
||||
elemIt != elemEndIt;
|
||||
++elemIt)
|
||||
{
|
||||
const auto& elem = *elemIt;
|
||||
for (const auto& elem : elements(gridView, Dune::Partitions::interior)) {
|
||||
elemCtx.updatePrimaryStencil(elem);
|
||||
elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0);
|
||||
const unsigned cell_idx = elemCtx.globalSpaceIndex(/*spaceIdx=*/0, /*timeIdx=*/0);
|
||||
@ -803,7 +791,7 @@ namespace Opm {
|
||||
|
||||
OPM_BEGIN_PARALLEL_TRY_CATCH();
|
||||
|
||||
for (const auto& elem: elements(gridView, Dune::Partitions::interiorBorder))
|
||||
for (const auto& elem : elements(gridView, Dune::Partitions::interiorBorder))
|
||||
{
|
||||
// Skip cells of numerical Aquifer
|
||||
if (isNumericalAquiferCell(gridView.grid(), elem))
|
||||
|
@ -95,13 +95,9 @@ namespace detail
|
||||
{
|
||||
//Numbering of cells
|
||||
const auto& gridView = grid.leafGridView();
|
||||
auto elemIt = gridView.template begin<0>();
|
||||
const auto& elemEndIt = gridView.template end<0>();
|
||||
|
||||
//loop over cells in mesh
|
||||
for (; elemIt != elemEndIt; ++elemIt)
|
||||
for (const auto& elem : elements(gridView))
|
||||
{
|
||||
const auto& elem = *elemIt;
|
||||
int lcell = mapper.index(elem);
|
||||
|
||||
if (elem.partitionType() != Dune::InteriorEntity)
|
||||
@ -127,17 +123,10 @@ namespace detail
|
||||
if (!ownerFirst || grid.comm().size()==1)
|
||||
return grid.leafGridView().size(0);
|
||||
const auto& gridView = grid.leafGridView();
|
||||
auto elemIt = gridView.template begin<0>();
|
||||
const auto& elemEndIt = gridView.template end<0>();
|
||||
|
||||
// loop over cells in mesh
|
||||
for (; elemIt != elemEndIt; ++elemIt) {
|
||||
|
||||
// Count only the interior cells.
|
||||
if (elemIt->partitionType() == Dune::InteriorEntity) {
|
||||
numInterior++;
|
||||
}
|
||||
}
|
||||
const auto& range = elements(gridView, Dune::Partitions::interior);
|
||||
numInterior = std::distance(range.begin(), range.end());
|
||||
|
||||
return numInterior;
|
||||
}
|
||||
|
@ -100,11 +100,9 @@ namespace Amg
|
||||
VectorBlockType rhs(0.0);
|
||||
rhs[pressureVarIndex] = 1.0;
|
||||
int index = 0;
|
||||
auto elemIt = gridView.template begin</*codim=*/0>();
|
||||
const auto& elemEndIt = gridView.template end</*codim=*/0>();
|
||||
OPM_BEGIN_PARALLEL_TRY_CATCH();
|
||||
for (; elemIt != elemEndIt; ++elemIt) {
|
||||
elemCtx.updatePrimaryStencil(*elemIt);
|
||||
for (const auto& elem : elements(gridView)) {
|
||||
elemCtx.updatePrimaryStencil(elem);
|
||||
elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0);
|
||||
Dune::FieldVector<Evaluation, numEq> storage;
|
||||
model.localLinearizer(threadId).localResidual().computeStorage(storage,elemCtx,/*spaceIdx=*/0, /*timeIdx=*/0);
|
||||
|
@ -581,18 +581,10 @@ namespace Opm {
|
||||
ElementContext elemCtx(ebosSimulator_);
|
||||
|
||||
const auto& gridView = ebosSimulator_.vanguard().gridView();
|
||||
const auto& elemEndIt = gridView.template end</*codim=*/0>();
|
||||
|
||||
OPM_BEGIN_PARALLEL_TRY_CATCH();
|
||||
|
||||
for (auto elemIt = gridView.template begin</*codim=*/0>();
|
||||
elemIt != elemEndIt;
|
||||
++elemIt)
|
||||
{
|
||||
if (elemIt->partitionType() != Dune::InteriorEntity) {
|
||||
continue;
|
||||
}
|
||||
|
||||
elemCtx.updatePrimaryStencil(*elemIt);
|
||||
for (const auto& elem : elements(gridView, Dune::Partitions::interior)) {
|
||||
elemCtx.updatePrimaryStencil(elem);
|
||||
elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0);
|
||||
|
||||
const auto& fs = elemCtx.intensiveQuantities(/*spaceIdx=*/0, /*timeIdx=*/0).fluidState();
|
||||
@ -1753,13 +1745,10 @@ namespace Opm {
|
||||
const auto& grid = ebosSimulator_.vanguard().grid();
|
||||
const auto& gridView = grid.leafGridView();
|
||||
ElementContext elemCtx(ebosSimulator_);
|
||||
const auto& elemEndIt = gridView.template end</*codim=*/0, Dune::Interior_Partition>();
|
||||
OPM_BEGIN_PARALLEL_TRY_CATCH();
|
||||
|
||||
for (auto elemIt = gridView.template begin</*codim=*/0, Dune::Interior_Partition>();
|
||||
elemIt != elemEndIt; ++elemIt)
|
||||
{
|
||||
elemCtx.updatePrimaryStencil(*elemIt);
|
||||
OPM_BEGIN_PARALLEL_TRY_CATCH();
|
||||
for (const auto& elem : elements(gridView, Dune::Partitions::interior)) {
|
||||
elemCtx.updatePrimaryStencil(elem);
|
||||
elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0);
|
||||
|
||||
const auto& intQuants = elemCtx.intensiveQuantities(/*spaceIdx=*/0, /*timeIdx=*/0);
|
||||
@ -1785,9 +1774,9 @@ namespace Opm {
|
||||
|
||||
// compute global average
|
||||
grid.comm().sum(B_avg.data(), B_avg.size());
|
||||
for(auto& bval: B_avg)
|
||||
for (auto& bval : B_avg)
|
||||
{
|
||||
bval/=global_num_cells_;
|
||||
bval /= global_num_cells_;
|
||||
}
|
||||
B_avg_ = B_avg;
|
||||
}
|
||||
@ -1857,17 +1846,14 @@ namespace Opm {
|
||||
template<typename TypeTag>
|
||||
void
|
||||
BlackoilWellModel<TypeTag>::
|
||||
updatePerforationIntensiveQuantities() {
|
||||
updatePerforationIntensiveQuantities()
|
||||
{
|
||||
ElementContext elemCtx(ebosSimulator_);
|
||||
const auto& gridView = ebosSimulator_.gridView();
|
||||
const auto& elemEndIt = gridView.template end</*codim=*/0, Dune::Interior_Partition>();
|
||||
OPM_BEGIN_PARALLEL_TRY_CATCH();
|
||||
for (auto elemIt = gridView.template begin</*codim=*/0, Dune::Interior_Partition>();
|
||||
elemIt != elemEndIt;
|
||||
++elemIt)
|
||||
{
|
||||
|
||||
elemCtx.updatePrimaryStencil(*elemIt);
|
||||
OPM_BEGIN_PARALLEL_TRY_CATCH();
|
||||
for (const auto& elem : elements(gridView, Dune::Partitions::interior)) {
|
||||
elemCtx.updatePrimaryStencil(elem);
|
||||
int elemIdx = elemCtx.globalSpaceIndex(0, 0);
|
||||
|
||||
if (!is_cell_perforated_[elemIdx]) {
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <opm/simulators/wells/RegionAttributeHelpers.hpp>
|
||||
#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
|
||||
#include <dune/grid/common/gridenums.hh>
|
||||
#include <dune/grid/common/rangegenerators.hh>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
@ -121,18 +122,9 @@ namespace Opm {
|
||||
ElementContext elemCtx( simulator );
|
||||
const auto& gridView = simulator.gridView();
|
||||
const auto& comm = gridView.comm();
|
||||
|
||||
OPM_BEGIN_PARALLEL_TRY_CATCH();
|
||||
|
||||
const auto& elemEndIt = gridView.template end</*codim=*/0>();
|
||||
for (auto elemIt = gridView.template begin</*codim=*/0>();
|
||||
elemIt != elemEndIt;
|
||||
++elemIt)
|
||||
{
|
||||
|
||||
const auto& elem = *elemIt;
|
||||
if (elem.partitionType() != Dune::InteriorEntity)
|
||||
continue;
|
||||
|
||||
for (const auto& elem : elements(gridView, Dune::Partitions::interior)) {
|
||||
elemCtx.updatePrimaryStencil(elem);
|
||||
elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0);
|
||||
const unsigned cellIdx = elemCtx.globalSpaceIndex(/*spaceIdx=*/0, /*timeIdx=*/0);
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
|
||||
|
||||
#include <dune/grid/common/gridenums.hh>
|
||||
#include <dune/grid/common/rangegenerators.hh>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
@ -116,18 +117,9 @@ namespace Opm {
|
||||
}
|
||||
|
||||
ElementContext elemCtx( simulator );
|
||||
const auto& elemEndIt = gridView.template end</*codim=*/0>();
|
||||
|
||||
OPM_BEGIN_PARALLEL_TRY_CATCH();
|
||||
|
||||
for (auto elemIt = gridView.template begin</*codim=*/0>();
|
||||
elemIt != elemEndIt;
|
||||
++elemIt)
|
||||
{
|
||||
|
||||
const auto& elem = *elemIt;
|
||||
if (elem.partitionType() != Dune::InteriorEntity)
|
||||
continue;
|
||||
|
||||
for (const auto& elem : elements(gridView, Dune::Partitions::interior)) {
|
||||
elemCtx.updatePrimaryStencil(elem);
|
||||
elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0);
|
||||
const unsigned cellIdx = elemCtx.globalSpaceIndex(/*spaceIdx=*/0, /*timeIdx=*/0);
|
||||
|
Loading…
Reference in New Issue
Block a user