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: #pragma omp parallel for for (const auto& chunk : ElementChunks(gridview, num_threads)) { for (const auto& elem : chunk) { // Do something with elem } } The ElementChunks object stores a vector of iterators, so if you have several such loops it can be a good idea to create the object once instead of once per loop: ElementChunks chunks(gridview, num_threads) // First loop #pragma omp parallel for for (const auto& chunk : chunks) { for (const auto& elem : chunk) { // Do something with elem } } // ... // Second loop #pragma omp parallel for for (const auto& chunk : chunks) { for (const auto& elem : chunk) { // Do something else with elem } } 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 >
◆ size()
template<class GridView , class PartitionSet >
The documentation for this class was generated from the following file: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||