void
reset_global_cell_indices();
+ /**
+ * Reset cache for the cells' vertex indices.
+ */
+ void
+ reset_cell_vertex_indices_cache();
+
/**
* Refine all cells on all levels which were previously flagged for
* refinement.
level->global_active_cell_indices.resize(level->refine_flags.size());
level->global_level_cell_indices.resize(level->refine_flags.size());
}
+ reset_cell_vertex_indices_cache();
reset_active_cell_indices();
reset_global_cell_indices();
}
{
AssertIndexRange(corner, this->n_vertices());
- return dealii::internal::TriaAccessorImplementation::Implementation::
- vertex_index(*this, corner);
+ if (structdim == dim)
+ {
+ constexpr unsigned int max_vertices_per_cell = 1 << dim;
+ const std::size_t my_index =
+ static_cast<std::size_t>(this->present_index) * max_vertices_per_cell;
+ AssertIndexRange(my_index + corner,
+ this->tria->levels[this->present_level]
+ ->cell_vertex_indices_cache.size());
+ const unsigned int vertex_index =
+ this->tria->levels[this->present_level]
+ ->cell_vertex_indices_cache[my_index + corner];
+ Assert(vertex_index != numbers::invalid_unsigned_int, ExcInternalError());
+ return vertex_index;
+ }
+ else
+ return dealii::internal::TriaAccessorImplementation::Implementation::
+ vertex_index(*this, corner);
}
((i == 1) && cell.at_boundary(1) ?
dealii::TriaAccessor<0, 1, spacedim>::right_vertex :
dealii::TriaAccessor<0, 1, spacedim>::interior_vertex)),
- cell.vertex_index(i));
+ dealii::internal::TriaAccessorImplementation::Implementation::
+ vertex_index(cell, i));
return dealii::TriaIterator<dealii::TriaAccessor<0, 1, spacedim>>(a);
}
*/
std::vector<dealii::ReferenceCell> reference_cell;
+ /**
+ * A cache for the vertex indices of the cells (`structdim == dim`), in
+ * order to more quickly retrieve these frequently accessed quantities.
+ * For simplified addressing, the information is indexed by the maximum
+ * number of vertices possible for a cell (quadrilateral/hexahedron).
+ */
+ std::vector<unsigned int> cell_vertex_indices_cache;
+
/**
* Determine an estimate for the memory consumption (in bytes) of this
* object.
ar &refine_flags &coarsen_flags;
- // do not serialize 'active_cell_indices' here. instead of storing them
- // to the stream and re-reading them again later, we just rebuild them
- // in Triangulation::load()
+ // do not serialize `active_cell_indices` and `vertex_indices_cache`
+ // here. instead of storing them to the stream and re-reading them again
+ // later, we just rebuild them in Triangulation::load()
ar &neighbors;
ar &subdomain_ids;
// update our counts of the various elements of a triangulation, and set
// active_cell_indices of all cells
+ reset_cell_vertex_indices_cache();
internal::TriangulationImplementation::Implementation::compute_number_cache(
*this, levels.size(), number_cache);
reset_active_cell_indices();
const DistortedCellList cells_with_distorted_children = execute_refinement();
+ reset_cell_vertex_indices_cache();
+
// verify a case with which we have had
// some difficulty in the past (see the
// deal.II/coarsening_* tests)
+template <int dim, int spacedim>
+void
+Triangulation<dim, spacedim>::reset_cell_vertex_indices_cache()
+{
+ for (unsigned int l = 0; l < levels.size(); ++l)
+ {
+ constexpr unsigned int max_vertices_per_cell = 1 << dim;
+ std::vector<unsigned int> &cache = levels[l]->cell_vertex_indices_cache;
+ cache.clear();
+ cache.resize(levels[l]->refine_flags.size() * max_vertices_per_cell,
+ numbers::invalid_unsigned_int);
+ for (const auto &cell : cell_iterators_on_level(l))
+ {
+ const unsigned int my_index = cell->index() * max_vertices_per_cell;
+ for (const unsigned int i : cell->vertex_indices())
+ cache[my_index + i] = internal::TriaAccessorImplementation::
+ Implementation::vertex_index(*cell, i);
+ }
+ }
+}
+
+
+
template <int dim, int spacedim>
void
Triangulation<dim, spacedim>::update_periodic_face_map()