WorkStream iterator

28 views
Skip to first unread message

Daniel Shapero

unread,
Jun 19, 2016, 5:12:22 PM6/19/16
to deal.II User Group
I'm working on a problem which involves iterating over the DoFHandlers of both a scalar and a vector field at the same time, similar to step 31. I'm creating an iterator class which will wrap up the iterators for both the scalar and vector field into one object using a std::array of active_cell_iterators. The increment operator is implemented by incrementing each active_cell_iterator in the array; the dereference operator returns a reference to the array; etc. I've tested this out and it works fine.

I'd like to be able to parallelize the assembly using WorkStream, which uses an iterator range. What operations are required of the iterators passed to WorkStream? From the comments in the source code, it looks like the iterator must have operator- defined, so I take it that it must be a random-access iterator. The simple multi-iterator implementation I have now is only a forward iterator, since that was the bare minimum needed to get things working in single-threaded mode.

Wolfgang Bangerth

unread,
Jun 19, 2016, 6:18:33 PM6/19/16
to dea...@googlegroups.com
On 06/19/2016 04:12 PM, Daniel Shapero wrote:
> I'm working on a problem which involves iterating over the DoFHandlers of both
> a scalar and a vector field at the same time, similar to step 31
> <https://urldefense.proofpoint.com/v2/url?u=https-3A__dealii.org_developer_doxygen_deal.II_step-5F31.html-23BoussinesqFlowProblemassemble-5Fstokes-5Fsystem&d=AwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=bn1clvQAiDQrfAC4yKbN0PlSr7RWRs-U3WJ0zRBB2qM&m=LKWtqGDlr1IIKNzL19q-BeEv113uSM-htWgg0-mfxtg&s=ZhkrkZJVtq3qsxTuL_dfYkgGkRnWYG_k859WMeIjWYQ&e=>.
> I'm creating an iterator class which will wrap up the iterators for both the
> scalar and vector field into one object using a std::array of
> active_cell_iterators. The increment operator is implemented by incrementing
> each active_cell_iterator in the array; the dereference operator returns a
> reference to the array; etc. I've tested this out and it works fine.
>
> I'd like to be able to parallelize the assembly using WorkStream, which uses
> an iterator range. What operations are required of the iterators passed to
> WorkStream? From the comments in the source code, it looks like the iterator
> must have operator- defined, so I take it that it must be a random-access
> iterator
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__en.cppreference.com_w_cpp_concept_RandomAccessIterator&d=AwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=bn1clvQAiDQrfAC4yKbN0PlSr7RWRs-U3WJ0zRBB2qM&m=LKWtqGDlr1IIKNzL19q-BeEv113uSM-htWgg0-mfxtg&s=vlOxQjDUZgqn4d-Y5UwVkuANFbQJHZSsP3ooIzECGyc&e=>.
> The simple multi-iterator implementation I have now is only a forward
> iterator, since that was the bare minimum needed to get things working in
> single-threaded mode.

Daniel,
you are looking for the SynchronousIterator class :-)

Cheers
W.

--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@math.tamu.edu
www: http://www.math.tamu.edu/~bangerth/

Daniel Shapero

unread,
Jun 20, 2016, 1:00:43 PM6/20/16
to deal.II User Group
So glad I asked this question instead of reinventing the wheel :) I was mostly working off the Boussinesq and elasticity examples, so I missed step-35.
Reply all
Reply to author
Forward
0 new messages