Iterating over mesh cells in a custom order

48 views
Skip to first unread message

Corbin Foucart

unread,
Aug 17, 2022, 2:05:00 PM8/17/22
to deal.II User Group
Hello everyone,

I have a problem in which I'm propagating information downwards in depth by solving the same local finite element problem on each element in an adaptive grid. The only condition is that the cells above the current cell must have already been worked on.

I'm looking for a way to loop over cells using something akin to MeshWorker::mesh_loop or WorkStream::run, but with a custom order, namely, according to the z-coordinate of each cell center. Is there a simple way to do this?

If not, I can always loop over the cells manually by recording a depth-sorted list, but then I'd lose the multi-thread capabilities of mesh_loop() and the like. Any advice would be appreciated.

Thank you,
Corbin

Bruno Turcksin

unread,
Aug 17, 2022, 3:04:01 PM8/17/22
to deal.II User Group
Corbin,

It's possible to do it using WorkStream::run (see here) However, you need to create the ordering manually by "coloring" the cells. All the cells in the same color can be worked on in parallel but the colors are treated sequentially; we first go over all the cells in color 0, then in color 1, etc.

Best,

Bruno

Wolfgang Bangerth

unread,
Aug 17, 2022, 5:00:34 PM8/17/22
to dea...@googlegroups.com
On 8/17/22 13:04, Bruno Turcksin wrote:
>
> It's possible to do it using WorkStream::run (see here
> <https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdealii.org%2Fdeveloper%2Fdoxygen%2Fdeal.II%2FnamespaceWorkStream.html%23ab8ceb010811941c351803b671a19fb73&data=05%7C01%7CWolfgang.Bangerth%40colostate.edu%7Ca97d7a48b22746f58ad208da808340b0%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637963598455384647%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=jCYZjVQjmFZ2YEuOUsJtrj8ZSgabPVskjBEfZQGGZfM%3D&reserved=0>)
> However, you need to create the ordering manually by "coloring" the
> cells. All the cells in the same color can be worked on in parallel but
> the colors are treated sequentially; we first go over all the cells in
> color 0, then in color 1, etc.

Alternatively, WorkStream works on a set of iterators. These can be the
iterators into a
std::set<DoFHandler::active_cell_iterator, COMP>
if you choose the right comparator object that ensures that
active_cell_iterators that need to be worked on first compare as less
than those active_cell_iterators that need to be worked on later.

Best
W.

--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/
Reply all
Reply to author
Forward
0 new messages