mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #736 from akva2/use_range_generators
Use elements range generator
This commit is contained in:
@@ -380,11 +380,8 @@ public:
|
|||||||
// update the history of the hysteresis law
|
// update the history of the hysteresis law
|
||||||
ElementContext elemCtx(this->simulator());
|
ElementContext elemCtx(this->simulator());
|
||||||
|
|
||||||
auto elemIt = this->gridView().template begin<0>();
|
for (const auto& elem : elements(this->gridView())) {
|
||||||
const auto& elemEndIt = this->gridView().template end<0>();
|
elemCtx.updateAll(elem);
|
||||||
for (; elemIt != elemEndIt; ++elemIt) {
|
|
||||||
const auto& elem = *elemIt;
|
|
||||||
elemCtx.updateAll( elem );
|
|
||||||
size_t numDofs = elemCtx.numDof(/*timeIdx=*/0);
|
size_t numDofs = elemCtx.numDof(/*timeIdx=*/0);
|
||||||
for (unsigned scvIdx = 0; scvIdx < numDofs; ++scvIdx)
|
for (unsigned scvIdx = 0; scvIdx < numDofs; ++scvIdx)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -247,10 +247,8 @@ public:
|
|||||||
|
|
||||||
// determine which degrees of freedom are in the lens
|
// determine which degrees of freedom are in the lens
|
||||||
Stencil stencil(this->gridView(), this->simulator().model().dofMapper() );
|
Stencil stencil(this->gridView(), this->simulator().model().dofMapper() );
|
||||||
auto elemIt = this->gridView().template begin</*codim=*/0>();
|
for (const auto& elem : elements(this->gridView())) {
|
||||||
auto elemEndIt = this->gridView().template end</*codim=*/0>();
|
stencil.update(elem);
|
||||||
for (; elemIt != elemEndIt; ++elemIt) {
|
|
||||||
stencil.update(*elemIt);
|
|
||||||
for (unsigned dofIdx = 0; dofIdx < stencil.numPrimaryDof(); ++ dofIdx) {
|
for (unsigned dofIdx = 0; dofIdx < stencil.numPrimaryDof(); ++ dofIdx) {
|
||||||
unsigned globalDofIdx = stencil.globalSpaceIndex(dofIdx);
|
unsigned globalDofIdx = stencil.globalSpaceIndex(dofIdx);
|
||||||
const auto& dofPos = stencil.subControlVolume(dofIdx).center();
|
const auto& dofPos = stencil.subControlVolume(dofIdx).center();
|
||||||
|
|||||||
@@ -542,10 +542,8 @@ public:
|
|||||||
// them into the restart file and re-reading them, but it is better to calculate
|
// 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...
|
// them from scratch because the input could have been changed in this regard...
|
||||||
ElementContext elemCtx(this->simulator_);
|
ElementContext elemCtx(this->simulator_);
|
||||||
auto elemIt = this->gridView().template begin</*codim=*/0>();
|
for (const auto& elem : elements(this->gridView())) {
|
||||||
auto elemEndIt = this->gridView().template end</*codim=*/0>();
|
elemCtx.updateStencil(elem);
|
||||||
for (; elemIt != elemEndIt; ++ elemIt) {
|
|
||||||
elemCtx.updateStencil(*elemIt);
|
|
||||||
for (unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(/*timIdx=*/0); ++dofIdx) {
|
for (unsigned dofIdx = 0; dofIdx < elemCtx.numPrimaryDof(/*timIdx=*/0); ++dofIdx) {
|
||||||
unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timIdx=*/0);
|
unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timIdx=*/0);
|
||||||
updatePvtRegionIndex_(this->solution(/*timeIdx=*/0)[globalDofIdx],
|
updatePvtRegionIndex_(this->solution(/*timeIdx=*/0)[globalDofIdx],
|
||||||
|
|||||||
@@ -321,12 +321,8 @@ public:
|
|||||||
ElementContext elemCtx( this->simulator() );
|
ElementContext elemCtx( this->simulator() );
|
||||||
auto gridView = this->simulator().vanguard().gridView();
|
auto gridView = this->simulator().vanguard().gridView();
|
||||||
auto& grid = this->simulator().vanguard().grid();
|
auto& grid = this->simulator().vanguard().grid();
|
||||||
auto elemIt = gridView.template begin</*codim=*/0, Dune::Interior_Partition>();
|
for (const auto& element : elements(gridView, Dune::Partitions::interior)) {
|
||||||
auto elemEndIt = gridView.template end</*codim=*/0, Dune::Interior_Partition>();
|
elemCtx.updateAll(element);
|
||||||
for (; elemIt != elemEndIt; ++elemIt)
|
|
||||||
{
|
|
||||||
const auto& element = *elemIt ;
|
|
||||||
elemCtx.updateAll( element );
|
|
||||||
|
|
||||||
// HACK: this should better be part of an AdaptionCriterion class
|
// HACK: this should better be part of an AdaptionCriterion class
|
||||||
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
|
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
|
||||||
|
|||||||
@@ -522,10 +522,7 @@ public:
|
|||||||
gridTotalVolume_ = 0.0;
|
gridTotalVolume_ = 0.0;
|
||||||
|
|
||||||
// iterate through the grid and evaluate the initial condition
|
// iterate through the grid and evaluate the initial condition
|
||||||
ElementIterator elemIt = gridView_.template begin</*codim=*/0>();
|
for (const auto& elem : elements(gridView_)) {
|
||||||
const ElementIterator& elemEndIt = gridView_.template end</*codim=*/0>();
|
|
||||||
for (; elemIt != elemEndIt; ++elemIt) {
|
|
||||||
const Element& elem = *elemIt;
|
|
||||||
const bool isInteriorElement = elem.partitionType() == Dune::InteriorEntity;
|
const bool isInteriorElement = elem.partitionType() == Dune::InteriorEntity;
|
||||||
// ignore everything which is not in the interior if the
|
// ignore everything which is not in the interior if the
|
||||||
// current process' piece of the grid
|
// current process' piece of the grid
|
||||||
@@ -599,10 +596,7 @@ public:
|
|||||||
ElementContext elemCtx(simulator_);
|
ElementContext elemCtx(simulator_);
|
||||||
|
|
||||||
// iterate through the grid and evaluate the initial condition
|
// iterate through the grid and evaluate the initial condition
|
||||||
ElementIterator elemIt = gridView_.template begin</*codim=*/0>();
|
for (const auto& elem : elements(gridView_)) {
|
||||||
const ElementIterator& elemEndIt = gridView_.template end</*codim=*/0>();
|
|
||||||
for (; elemIt != elemEndIt; ++elemIt) {
|
|
||||||
const Element& elem = *elemIt;
|
|
||||||
// ignore everything which is not in the interior if the
|
// ignore everything which is not in the interior if the
|
||||||
// current process' piece of the grid
|
// current process' piece of the grid
|
||||||
if (elem.partitionType() != Dune::InteriorEntity)
|
if (elem.partitionType() != Dune::InteriorEntity)
|
||||||
|
|||||||
@@ -341,10 +341,7 @@ private:
|
|||||||
using NeighborSet = std::set< unsigned >;
|
using NeighborSet = std::set< unsigned >;
|
||||||
std::vector<NeighborSet> sparsityPattern(model.numTotalDof());
|
std::vector<NeighborSet> sparsityPattern(model.numTotalDof());
|
||||||
|
|
||||||
ElementIterator elemIt = gridView_().template begin<0>();
|
for (const auto& elem : elements(gridView_())) {
|
||||||
const ElementIterator elemEndIt = gridView_().template end<0>();
|
|
||||||
for (; elemIt != elemEndIt; ++elemIt) {
|
|
||||||
const Element& elem = *elemIt;
|
|
||||||
stencil.update(elem);
|
stencil.update(elem);
|
||||||
|
|
||||||
for (unsigned primaryDofIdx = 0; primaryDofIdx < stencil.numPrimaryDof(); ++primaryDofIdx) {
|
for (unsigned primaryDofIdx = 0; primaryDofIdx < stencil.numPrimaryDof(); ++primaryDofIdx) {
|
||||||
|
|||||||
@@ -318,10 +318,7 @@ private:
|
|||||||
std::vector<NeighborInfo> loc_nbinfo;
|
std::vector<NeighborInfo> loc_nbinfo;
|
||||||
const auto& materialLawManager = problem_().materialLawManager();
|
const auto& materialLawManager = problem_().materialLawManager();
|
||||||
using FaceDirection = FaceDir::DirEnum;
|
using FaceDirection = FaceDir::DirEnum;
|
||||||
ElementIterator elemIt = gridView_().template begin<0>();
|
for (const auto& elem : elements(gridView_())) {
|
||||||
const ElementIterator elemEndIt = gridView_().template end<0>();
|
|
||||||
for (; elemIt != elemEndIt; ++elemIt) {
|
|
||||||
const Element& elem = *elemIt;
|
|
||||||
stencil.update(elem);
|
stencil.update(elem);
|
||||||
|
|
||||||
for (unsigned primaryDofIdx = 0; primaryDofIdx < stencil.numPrimaryDof(); ++primaryDofIdx) {
|
for (unsigned primaryDofIdx = 0; primaryDofIdx < stencil.numPrimaryDof(); ++primaryDofIdx) {
|
||||||
|
|||||||
@@ -498,12 +498,7 @@ public:
|
|||||||
std::vector<bool> visited(this->numGridDof(), false);
|
std::vector<bool> visited(this->numGridDof(), false);
|
||||||
ElementContext elemCtx(this->simulator_);
|
ElementContext elemCtx(this->simulator_);
|
||||||
|
|
||||||
ElementIterator elemIt = this->gridView_.template begin<0>();
|
for (const auto& elem : elements(this->gridView_, Dune::Partitions::interior)) {
|
||||||
ElementIterator elemEndIt = this->gridView_.template end<0>();
|
|
||||||
for (; elemIt != elemEndIt; ++elemIt) {
|
|
||||||
const Element& elem = *elemIt;
|
|
||||||
if (elem.partitionType() != Dune::InteriorEntity)
|
|
||||||
continue;
|
|
||||||
elemCtx.updateStencil(elem);
|
elemCtx.updateStencil(elem);
|
||||||
|
|
||||||
size_t numLocalDof = elemCtx.stencil(/*timeIdx=*/0).numPrimaryDof();
|
size_t numLocalDof = elemCtx.stencil(/*timeIdx=*/0).numPrimaryDof();
|
||||||
|
|||||||
@@ -71,11 +71,8 @@ public:
|
|||||||
// whole grid and update a stencil for each element
|
// whole grid and update a stencil for each element
|
||||||
Data *curElemDataPtr = &data_[0];
|
Data *curElemDataPtr = &data_[0];
|
||||||
Stencil stencil(gridView_, dofMapper_);
|
Stencil stencil(gridView_, dofMapper_);
|
||||||
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) {
|
|
||||||
// set the DOF data pointer for the current element
|
// set the DOF data pointer for the current element
|
||||||
const auto& elem = *elemIt;
|
|
||||||
unsigned elemIdx = elementMapper_.index(elem);
|
unsigned elemIdx = elementMapper_.index(elem);
|
||||||
elemData_[elemIdx] = curElemDataPtr;
|
elemData_[elemIdx] = curElemDataPtr;
|
||||||
|
|
||||||
@@ -112,10 +109,8 @@ private:
|
|||||||
|
|
||||||
// loop over the whole grid and sum up the number of local DOFs of all Stencils
|
// loop over the whole grid and sum up the number of local DOFs of all Stencils
|
||||||
Stencil stencil(gridView_, dofMapper_);
|
Stencil stencil(gridView_, dofMapper_);
|
||||||
auto elemIt = gridView_.template begin</*codim=*/0>();
|
for (const auto& elem : elements(gridView_)) {
|
||||||
const auto& elemEndIt = gridView_.template end</*codim=*/0>();
|
stencil.update(elem);
|
||||||
for (; elemIt != elemEndIt; ++elemIt) {
|
|
||||||
stencil.update(*elemIt);
|
|
||||||
result += stencil.numDof();
|
result += stencil.numDof();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include <dune/grid/common/datahandleif.hh>
|
#include <dune/grid/common/datahandleif.hh>
|
||||||
#include <dune/grid/common/gridenums.hh>
|
#include <dune/grid/common/gridenums.hh>
|
||||||
|
#include <dune/grid/common/partitionset.hh>
|
||||||
#include <dune/istl/bcrsmatrix.hh>
|
#include <dune/istl/bcrsmatrix.hh>
|
||||||
#include <dune/istl/scalarproducts.hh>
|
#include <dune/istl/scalarproducts.hh>
|
||||||
#include <dune/istl/operators.hh>
|
#include <dune/istl/operators.hh>
|
||||||
@@ -68,11 +69,9 @@ class ElementBorderListFromGrid
|
|||||||
, blackList_(blackList)
|
, blackList_(blackList)
|
||||||
, borderList_(borderList)
|
, borderList_(borderList)
|
||||||
{
|
{
|
||||||
auto elemIt = gridView_.template begin<0>();
|
for (const auto& elem : elements(gridView_)) {
|
||||||
const auto& elemEndIt = gridView_.template end<0>();
|
if (elem.partitionType() != Dune::InteriorEntity) {
|
||||||
for (; elemIt != elemEndIt; ++elemIt) {
|
Index elemIdx = static_cast<Index>(map_.index(elem));
|
||||||
if (elemIt->partitionType() != Dune::InteriorEntity) {
|
|
||||||
Index elemIdx = static_cast<Index>(map_.index(*elemIt));
|
|
||||||
blackList_.addIndex(elemIdx);
|
blackList_.addIndex(elemIdx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user