I iterate a collection of cells, and for each one I have to iterate the
active descendants.
Given a coarse cell, I use a FilteredIterator
<https://www.dealii.org/current/doxygen/deal.II/classFilteredIterator.html>
to iterate active descendants, but the method *set_to_next_positive*
significantly slows down the code. Something I'd expect runs in 0.1 s takes
10 s. The filter is:
*<start C++ code>*
class ActiveChild
{
public:
// Use CellId
<https://www.dealii.org/current/doxygen/deal.II/classCellId.html> to check
if is ancestor.
CellId parent;
ActiveChild(const CellId &parent)
: parent(parent) {}
template <typename Iterator>
bool operator()(const Iterator &cell) const
{
// cell is the potential descendant.
return parent.is_ancestor_of(cell->id());
}
};
*<end C++ code>*
I iterate active descendants like:
*<start C++ code>*
using ChildIt = FilteredIterator<typename DoFHandler<2,
3>::active_cell_iterator>;
Triangulation<2, 3> tria;
unsigned int level; // level of coarse cell.
unsigned int coarse_cell_index;
CellAccessor<2, 3> coarse_cell(&tria, level, coarse_cell_index);
ChildIt cell(ActiveChild(coarse_cell.id()));
ChildIt endc(ActiveChild(coarse_cell.id()), dof_handler.end());
*// This method, set_to_next_positive, is very slow.*
*cell.set_to_next_positive(dof_handler.begin_active());*
for (; cell != endc; ++cell)
{
// I use DoFHandler accessor to get global dof indices.
cell->get_dof_indices(global_dofs);
// Do stuff ...
}
*<end C++ code>*
Is there a better alternative to iterate active descendants? Why is
*set_to_next_positive* so slow here?
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/dealii/d2797193-e613-476d-9547-62846b318019n%40googlegroups.com.