Looping over all the active children of an arbitrary cell

29 views
Skip to first unread message

Stephen

unread,
Aug 21, 2020, 7:44:11 PM8/21/20
to deal.II User Group
I am writing a space-time adaptive algorithm (dG in time, cG in space) for a blowup problem and have an a posteriori error estimator computed on a union grid of up to three different grids. I then need to transfer this error estimator to my current triangulation. I can match the cells across the grids up to one level just fine using the following code

const std::list<std::pair<typename Triangulation<dim>::cell_iterator, typename Triangulation<dim>::cell_iterator>> cell_list = GridTools::get_finest_common_cells (triangulation_space, union_triangulation);
auto cell_iter = cell_list.begin();

    for (; cell_iter != cell_list.end(); ++cell_iter)
    {
    if (cell_iter->second->has_children () == false)
    {
    refinement_vector(cell_iter->first->active_cell_index()) = refinement_union_vector(cell_iter->second->active_cell_index());
    }
    else
    {
    const unsigned int no_of_subcells = cell_iter->second->n_children();

        for (unsigned int subcell = 0; subcell < no_of_subcells; ++subcell)
        {
        refinement_vector(cell_iter->first->active_cell_index()) = fmax(refinement_vector(cell_iter->first->active_cell_index()), refinement_union_vector(cell_iter->second->child(subcell)->active_cell_index()));
        }
    }
    }

but this only works under the assumption that the current grid differs from the union grid by one level which may not necessarily be the case. Obviously I could add "n" inner loops to this in order to take care of up to n different levels between the triangulations but this makes the code more unreadable and is not very "elegant". Does anybody have a better suggestion? Thanks!

Timo Heister

unread,
Aug 22, 2020, 3:26:19 PM8/22/20
to dea...@googlegroups.com
Stephan,

I am not 100% sure if that is what you need, but did you see
GridTools::get_active_child_cells()?
> --
> The deal.II project is located at http://www.dealii.org/
> For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
> ---
> You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/ea3fc64d-7348-4a73-b577-bf5c46d5952en%40googlegroups.com.



--
Timo Heister
http://www.math.clemson.edu/~heister/

Stephen

unread,
Aug 22, 2020, 5:32:45 PM8/22/20
to deal.II User Group
I believe that is exactly what I need!

Thanks

Reply all
Reply to author
Forward
0 new messages