Skip to content

Commit

Permalink
Merge pull request #14675 from bangerth/deprecated
Browse files Browse the repository at this point in the history
Avoid a deprecated function in the last context where it is used.
  • Loading branch information
marcfehling committed Jan 13, 2023
2 parents b25449d + a9356b8 commit bd691de
Showing 1 changed file with 86 additions and 73 deletions.
159 changes: 86 additions & 73 deletions include/deal.II/grid/connectivity.h
Original file line number Diff line number Diff line change
Expand Up @@ -995,10 +995,10 @@ namespace internal
* Furthermore, the function determines for each cell of which d-dimensional
* entity it consists of and its orientation relative to the cell.
*/
template <int key_length, typename FU>
template <int max_n_vertices, typename FU>
void
build_entity_templated(
const unsigned int d,
build_face_entities_templated(
const unsigned int face_dimensionality,
const std::vector<std::shared_ptr<CellTypeBase>> &cell_types,
const std::vector<dealii::ReferenceCell> & cell_types_index,
const CRS<unsigned int> & crs,
Expand Down Expand Up @@ -1028,20 +1028,20 @@ namespace internal
for (const auto &c : cell_types_index)
n_entities +=
cell_types[static_cast<types::geometric_entity_type>(c)]->n_entities(
d);
face_dimensionality);

// step 1: store each d-dimensional entity of a cell (described by their
// vertices) into a vector and create a key for them
//
// note: it turned out to be more efficient to have a vector of tuples
// than to have two vectors (sorting becomes inefficient)
std::vector<
std::tuple<std::array<unsigned int, key_length>, unsigned int>>
std::tuple<std::array<unsigned int, max_n_vertices>, unsigned int>>
keys; // key (sorted vertices), cell-entity index

std::vector<std::array<unsigned int, key_length>> ad_entity_vertices;
std::vector<dealii::ReferenceCell> ad_entity_types;
std::vector<std::array<unsigned int, key_length>> ad_compatibility;
std::vector<std::array<unsigned int, max_n_vertices>> ad_entity_vertices;
std::vector<dealii::ReferenceCell> ad_entity_types;
std::vector<std::array<unsigned int, max_n_vertices>> ad_compatibility;

keys.reserve(n_entities);
ad_entity_vertices.reserve(n_entities);
Expand All @@ -1059,34 +1059,37 @@ namespace internal
const auto &cell_type =
cell_types[static_cast<types::geometric_entity_type>(
cell_types_index[c])];
ptr_d[c + 1] = ptr_d[c] + cell_type->n_entities(d);
ptr_d[c + 1] = ptr_d[c] + cell_type->n_entities(face_dimensionality);

// ... collect vertices of cell
const dealii::ArrayView<const unsigned int> cell_vertice(
cell_vertices.data() + cell_ptr[c], cell_ptr[c + 1] - cell_ptr[c]);

// ... loop over all its entities
for (unsigned int e = 0; e < cell_type->n_entities(d); ++e)
for (unsigned int e = 0;
e < cell_type->n_entities(face_dimensionality);
++e)
{
// ... determine global entity vertices
const auto &local_entity_vertices =
cell_type->vertices_of_entity(d, e);
cell_type->vertices_of_entity(face_dimensionality, e);

std::array<unsigned int, key_length> entity_vertices;
std::array<unsigned int, max_n_vertices> entity_vertices;
std::fill(entity_vertices.begin(), entity_vertices.end(), 0);

for (unsigned int i = 0; i < local_entity_vertices.size(); ++i)
entity_vertices[i] =
cell_vertice[local_entity_vertices[i]] + offset;

// ... create key
std::array<unsigned int, key_length> key = entity_vertices;
std::array<unsigned int, max_n_vertices> key = entity_vertices;
std::sort(key.begin(), key.end());
keys.emplace_back(key, counter++);

ad_entity_vertices.emplace_back(entity_vertices);

ad_entity_types.emplace_back(cell_type->type_of_entity(d, e));
ad_entity_types.emplace_back(
cell_type->type_of_entity(face_dimensionality, e));

if (compatibility_mode)
ad_compatibility.emplace_back(
Expand All @@ -1107,7 +1110,7 @@ namespace internal
unsigned int n_unique_entities = 0;
unsigned int n_unique_entity_vertices = 0;

std::array<unsigned int, key_length> ref_key, new_key;
std::array<unsigned int, max_n_vertices> ref_key, new_key;
std::fill(ref_key.begin(), ref_key.end(), 0);
for (unsigned int i = 0; i < keys.size(); ++i)
{
Expand Down Expand Up @@ -1136,13 +1139,12 @@ namespace internal
}


std::array<unsigned int, key_length> ref_key;
std::array<unsigned int, key_length> ref_indices;
std::array<unsigned int, max_n_vertices> ref_key;
std::array<unsigned int, max_n_vertices> ref_indices;
std::fill(ref_key.begin(), ref_key.end(), 0);

for (unsigned int i = 0, counter = dealii::numbers::invalid_unsigned_int;
i < keys.size();
i++)
unsigned int counter = dealii::numbers::invalid_unsigned_int;
for (unsigned int i = 0; i < keys.size(); i++)
{
const auto offset_i = std::get<1>(keys[i]);

Expand All @@ -1164,8 +1166,14 @@ namespace internal
// occurrence
orientations.set_raw_orientation(
offset_i,
ad_entity_types[offset_i].compute_orientation(
ad_entity_vertices[offset_i], ref_indices));
ad_entity_types[offset_i]
.template get_orientation_index<unsigned int>(
make_array_view(ad_entity_vertices[offset_i].begin(),
ad_entity_vertices[offset_i].begin() +
ad_entity_types[offset_i].n_vertices()),
make_array_view(ref_indices.begin(),
ref_indices.begin() +
ad_entity_types[offset_i].n_vertices())));
}
col_d[offset_i] = counter;
}
Expand All @@ -1180,53 +1188,57 @@ namespace internal
*/
template <typename FU>
void
build_entity(const unsigned int d,
const std::vector<std::shared_ptr<CellTypeBase>> &cell_types,
const std::vector<dealii::ReferenceCell> &cell_types_index,
const CRS<unsigned int> & crs,
CRS<unsigned int> & crs_d,
CRS<unsigned int> & crs_0,
TriaObjectsOrientations & orientations,
const FU & second_key_function)
build_face_entities(
const unsigned int face_dimensionality,
const std::vector<std::shared_ptr<CellTypeBase>> &cell_types,
const std::vector<dealii::ReferenceCell> & cell_types_index,
const CRS<unsigned int> & crs,
CRS<unsigned int> & crs_d,
CRS<unsigned int> & crs_0,
TriaObjectsOrientations & orientations,
const FU & second_key_function)
{
std::size_t key_length = 0;
std::size_t max_n_vertices = 0;

for (const auto &c : cell_types_index)
{
const auto &cell_type =
cell_types[static_cast<types::geometric_entity_type>(c)];
for (unsigned int e = 0; e < cell_type->n_entities(d); ++e)
key_length =
std::max(key_length, cell_type->vertices_of_entity(d, e).size());
for (unsigned int e = 0;
e < cell_type->n_entities(face_dimensionality);
++e)
max_n_vertices = std::max(
max_n_vertices,
cell_type->vertices_of_entity(face_dimensionality, e).size());
}

if (key_length == 2)
build_entity_templated<2>(d,
cell_types,
cell_types_index,
crs,
crs_d,
crs_0,
orientations,
second_key_function);
else if (key_length == 3)
build_entity_templated<3>(d,
cell_types,
cell_types_index,
crs,
crs_d,
crs_0,
orientations,
second_key_function);
else if (key_length == 4)
build_entity_templated<4>(d,
cell_types,
cell_types_index,
crs,
crs_d,
crs_0,
orientations,
second_key_function);
if (max_n_vertices == 2)
build_face_entities_templated<2>(face_dimensionality,
cell_types,
cell_types_index,
crs,
crs_d,
crs_0,
orientations,
second_key_function);
else if (max_n_vertices == 3)
build_face_entities_templated<3>(face_dimensionality,
cell_types,
cell_types_index,
crs,
crs_d,
crs_0,
orientations,
second_key_function);
else if (max_n_vertices == 4)
build_face_entities_templated<4>(face_dimensionality,
cell_types,
cell_types_index,
crs,
crs_d,
crs_0,
orientations,
second_key_function);
else
AssertThrow(false, dealii::StandardExceptions::ExcNotImplemented());
}
Expand Down Expand Up @@ -1371,22 +1383,23 @@ namespace internal
{
TriaObjectsOrientations dummy;

build_entity(1,
cell_t,
connectivity.entity_types(dim),
con_cv,
dim == 2 ? connectivity.entity_to_entities(2, 1) : temp1,
connectivity.entity_to_entities(1, 0),
dim == 2 ? connectivity.entity_orientations(1) : dummy,
[](auto key, const auto &, const auto &, const auto &) {
// to ensure same enumeration as in deal.II
return key;
});
build_face_entities(
1,
cell_t,
connectivity.entity_types(dim),
con_cv,
dim == 2 ? connectivity.entity_to_entities(2, 1) : temp1,
connectivity.entity_to_entities(1, 0),
dim == 2 ? connectivity.entity_orientations(1) : dummy,
[](auto key, const auto &, const auto &, const auto &) {
// to ensure same enumeration as in deal.II
return key;
});
}

if (dim == 3) // build quads
{
build_entity(
build_face_entities(
2,
cell_t,
connectivity.entity_types(3),
Expand Down

0 comments on commit bd691de

Please sign in to comment.