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