Merge pull request #736 from akva2/use_range_generators

Use elements range generator
This commit is contained in:
Bård Skaflestad 2022-10-17 18:10:48 +02:00 committed by GitHub
commit 6f54bd9310
10 changed files with 20 additions and 54 deletions

View File

@ -380,11 +380,8 @@ public:
// update the history of the hysteresis law
ElementContext elemCtx(this->simulator());
auto elemIt = this->gridView().template begin<0>();
const auto& elemEndIt = this->gridView().template end<0>();
for (; elemIt != elemEndIt; ++elemIt) {
const auto& elem = *elemIt;
elemCtx.updateAll( elem );
for (const auto& elem : elements(this->gridView())) {
elemCtx.updateAll(elem);
size_t numDofs = elemCtx.numDof(/*timeIdx=*/0);
for (unsigned scvIdx = 0; scvIdx < numDofs; ++scvIdx)
{

View File

@ -247,10 +247,8 @@ public:
// determine which degrees of freedom are in the lens
Stencil stencil(this->gridView(), this->simulator().model().dofMapper() );
auto elemIt = this->gridView().template begin</*codim=*/0>();
auto elemEndIt = this->gridView().template end</*codim=*/0>();
for (; elemIt != elemEndIt; ++elemIt) {
stencil.update(*elemIt);
for (const auto& elem : elements(this->gridView())) {
stencil.update(elem);
for (unsigned dofIdx = 0; dofIdx < stencil.numPrimaryDof(); ++ dofIdx) {
unsigned globalDofIdx = stencil.globalSpaceIndex(dofIdx);
const auto& dofPos = stencil.subControlVolume(dofIdx).center();

View File

@ -542,10 +542,8 @@ public:
// them into the restart file and re-reading them, but it is better to calculate
// them from scratch because the input could have been changed in this regard...
ElementContext elemCtx(this->simulator_);
auto elemIt = this->gridView().template begin</*codim=*/0>();
auto elemEndIt = this->gridView().template end</*codim=*/0>();
for (; elemIt != elemEndIt; ++ elemIt) {
elemCtx.updateStencil(*elemIt);
for (const auto& elem : elements(this->gridView())) {
elemCtx.updateStencil(elem);
for (unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(/*timIdx=*/0); ++dofIdx) {
unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timIdx=*/0);
updatePvtRegionIndex_(this->solution(/*timeIdx=*/0)[globalDofIdx],

View File

@ -321,12 +321,8 @@ public:
ElementContext elemCtx( this->simulator() );
auto gridView = this->simulator().vanguard().gridView();
auto& grid = this->simulator().vanguard().grid();
auto elemIt = gridView.template begin</*codim=*/0, Dune::Interior_Partition>();
auto elemEndIt = gridView.template end</*codim=*/0, Dune::Interior_Partition>();
for (; elemIt != elemEndIt; ++elemIt)
{
const auto& element = *elemIt ;
elemCtx.updateAll( element );
for (const auto& element : elements(gridView, Dune::Partitions::interior)) {
elemCtx.updateAll(element);
// HACK: this should better be part of an AdaptionCriterion class
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {

View File

@ -522,10 +522,7 @@ public:
gridTotalVolume_ = 0.0;
// iterate through the grid and evaluate the initial condition
ElementIterator elemIt = gridView_.template begin</*codim=*/0>();
const ElementIterator& elemEndIt = gridView_.template end</*codim=*/0>();
for (; elemIt != elemEndIt; ++elemIt) {
const Element& elem = *elemIt;
for (const auto& elem : elements(gridView_)) {
const bool isInteriorElement = elem.partitionType() == Dune::InteriorEntity;
// ignore everything which is not in the interior if the
// current process' piece of the grid
@ -599,10 +596,7 @@ public:
ElementContext elemCtx(simulator_);
// iterate through the grid and evaluate the initial condition
ElementIterator elemIt = gridView_.template begin</*codim=*/0>();
const ElementIterator& elemEndIt = gridView_.template end</*codim=*/0>();
for (; elemIt != elemEndIt; ++elemIt) {
const Element& elem = *elemIt;
for (const auto& elem : elements(gridView_)) {
// ignore everything which is not in the interior if the
// current process' piece of the grid
if (elem.partitionType() != Dune::InteriorEntity)

View File

@ -341,10 +341,7 @@ private:
using NeighborSet = std::set< unsigned >;
std::vector<NeighborSet> sparsityPattern(model.numTotalDof());
ElementIterator elemIt = gridView_().template begin<0>();
const ElementIterator elemEndIt = gridView_().template end<0>();
for (; elemIt != elemEndIt; ++elemIt) {
const Element& elem = *elemIt;
for (const auto& elem : elements(gridView_())) {
stencil.update(elem);
for (unsigned primaryDofIdx = 0; primaryDofIdx < stencil.numPrimaryDof(); ++primaryDofIdx) {

View File

@ -318,10 +318,7 @@ private:
std::vector<NeighborInfo> loc_nbinfo;
const auto& materialLawManager = problem_().materialLawManager();
using FaceDirection = FaceDir::DirEnum;
ElementIterator elemIt = gridView_().template begin<0>();
const ElementIterator elemEndIt = gridView_().template end<0>();
for (; elemIt != elemEndIt; ++elemIt) {
const Element& elem = *elemIt;
for (const auto& elem : elements(gridView_())) {
stencil.update(elem);
for (unsigned primaryDofIdx = 0; primaryDofIdx < stencil.numPrimaryDof(); ++primaryDofIdx) {

View File

@ -498,12 +498,7 @@ public:
std::vector<bool> visited(this->numGridDof(), false);
ElementContext elemCtx(this->simulator_);
ElementIterator elemIt = this->gridView_.template begin<0>();
ElementIterator elemEndIt = this->gridView_.template end<0>();
for (; elemIt != elemEndIt; ++elemIt) {
const Element& elem = *elemIt;
if (elem.partitionType() != Dune::InteriorEntity)
continue;
for (const auto& elem : elements(this->gridView_, Dune::Partitions::interior)) {
elemCtx.updateStencil(elem);
size_t numLocalDof = elemCtx.stencil(/*timeIdx=*/0).numPrimaryDof();

View File

@ -71,11 +71,8 @@ public:
// whole grid and update a stencil for each element
Data *curElemDataPtr = &data_[0];
Stencil stencil(gridView_, dofMapper_);
auto elemIt = gridView_.template begin</*codim=*/0>();
const auto& elemEndIt = gridView_.template end</*codim=*/0>();
for (; elemIt != elemEndIt; ++elemIt) {
for (const auto& elem : elements(gridView_)) {
// set the DOF data pointer for the current element
const auto& elem = *elemIt;
unsigned elemIdx = elementMapper_.index(elem);
elemData_[elemIdx] = curElemDataPtr;
@ -112,10 +109,8 @@ private:
// loop over the whole grid and sum up the number of local DOFs of all Stencils
Stencil stencil(gridView_, dofMapper_);
auto elemIt = gridView_.template begin</*codim=*/0>();
const auto& elemEndIt = gridView_.template end</*codim=*/0>();
for (; elemIt != elemEndIt; ++elemIt) {
stencil.update(*elemIt);
for (const auto& elem : elements(gridView_)) {
stencil.update(elem);
result += stencil.numDof();
}

View File

@ -32,6 +32,7 @@
#include <dune/grid/common/datahandleif.hh>
#include <dune/grid/common/gridenums.hh>
#include <dune/grid/common/partitionset.hh>
#include <dune/istl/bcrsmatrix.hh>
#include <dune/istl/scalarproducts.hh>
#include <dune/istl/operators.hh>
@ -68,11 +69,9 @@ class ElementBorderListFromGrid
, blackList_(blackList)
, borderList_(borderList)
{
auto elemIt = gridView_.template begin<0>();
const auto& elemEndIt = gridView_.template end<0>();
for (; elemIt != elemEndIt; ++elemIt) {
if (elemIt->partitionType() != Dune::InteriorEntity) {
Index elemIdx = static_cast<Index>(map_.index(*elemIt));
for (const auto& elem : elements(gridView_)) {
if (elem.partitionType() != Dune::InteriorEntity) {
Index elemIdx = static_cast<Index>(map_.index(elem));
blackList_.addIndex(elemIdx);
}
}