|
Opm::ElementChunks< GridView, PartitionSet > Class Template Reference
Detailed Descriptiontemplate<class GridView, class PartitionSet> class Opm::ElementChunks< GridView, PartitionSet > Class to simplify creating parallel yet performant threaded loops over a grid. The basic problem is that iteration over a Dune grid is not random-access, and therefore not amenable to typical OpenMP pragmas. The ThreadedEntityIterator class provided in opm-simulators is a possibility, but it uses locking, and is therefore not very efficient. The iteration over chunks facilitated by this class is significantly faster in many cases. Typical loop over grid without this facility: for (const auto& elem : elements(gridview)) { // Do something with elem } Typical OpenMP-threaded loop over grid using this class: ElementChunks chunks(gridview, Dune::Partitions::all, num_threads); #pragma omp parallel for for (std::size_t ci = 0; ci < chunks.size(); ++ci) { for (const auto& elem : chunks[ci]) { // Do something with elem } } The loop over the chunks is index-based: OpenMP accepts a range-based for loop after the pragma only from version 5.0 on, while the index-based form needs only version 3.0. The ElementChunks object stores a vector of iterators, so create it once and reuse it when several loops run over the same chunks. Constructor & Destructor Documentation◆ ElementChunks()
template<class GridView , class PartitionSet >
References Opm::createChunkIterators(). Member Function Documentation◆ begin()
template<class GridView , class PartitionSet >
◆ end()
template<class GridView , class PartitionSet >
◆ operator[]()
template<class GridView , class PartitionSet >
◆ size()
template<class GridView , class PartitionSet >
The documentation for this class was generated from the following file: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||