16#ifndef dealii_tria_connectivity_h
17#define dealii_tria_connectivity_h
34 namespace TriangulationImplementation
102 const unsigned int face)
const
114 virtual const std::array<unsigned int, 2> &
116 const unsigned int face)
const
122 const static std::array<unsigned int, 2> table = {};
137 const unsigned int e)
const override
143 static const std::array<unsigned int, 2> table = {{0, 1}};
171 static std::array<unsigned int, 2> table = {{2, 1}};
185 const unsigned int e)
const override
189 static const std::array<unsigned int, 3> table = {{0, 1, 2}};
198 static const ::ndarray<unsigned int, 3, 2> table = {
199 {{{0, 1}}, {{1, 2}}, {{2, 0}}}};
228 static std::array<unsigned int, 3> table = {{3, 3, 1}};
242 const unsigned int e)
const override
246 static const std::array<unsigned int, 4> table = {{0, 1, 2, 3}};
256 {{{0, 2}}, {{1, 3}}, {{0, 1}}, {{2, 3}}}};
285 static std::array<unsigned int, 3> table = {{4, 4, 1}};
299 const unsigned int e)
const override
303 static const std::array<unsigned int, 4> table = {{0, 1, 2, 3}};
313 {{{0, 1, 2}}, {{1, 0, 3}}, {{0, 2, 3}}, {{2, 1, 3}}}};
321 {{{0, 1}}, {{1, 2}}, {{2, 0}}, {{0, 3}}, {{1, 3}}, {{2, 3}}}};
353 static std::array<unsigned int, 4> table = {{4, 6, 4, 1}};
366 const unsigned int face)
const override
369 {{{0, 1, 2}}, {{0, 3, 4}}, {{2, 5, 3}}, {{1, 4, 5}}}};
371 return table[face][line];
374 const std::array<unsigned int, 2> &
376 const unsigned int face)
const override
379 {{{{{0, 1}}, {{1, 2}}, {{2, 0}}}},
380 {{{{1, 0}}, {{0, 3}}, {{3, 1}}}},
381 {{{{0, 2}}, {{2, 3}}, {{3, 0}}}},
382 {{{{2, 1}}, {{1, 3}}, {{3, 2}}}}}};
384 return table[face][line];
397 const unsigned int e)
const override
401 static const std::array<unsigned int, 5> table = {{0, 1, 2, 3, 4}};
412 static const std::array<unsigned int, 4> table = {{0, 1, 2, 3}};
417 {{{0, 2, 4}}, {{3, 1, 4}}, {{1, 0, 4}}, {{2, 3, 4}}}};
419 return {table[e - 1]};
450 if (d == 2 && e == 0)
466 static std::array<unsigned int, 4> table = {{5, 8, 5, 1}};
481 const unsigned int face)
const override
490 return table[face][line];
493 const std::array<unsigned int, 2> &
495 const unsigned int face)
const override
497 static const unsigned int X =
static_cast<unsigned int>(-1);
500 {{{{{0, 2}}, {{1, 3}}, {{0, 1}}, {{2, 3}}}},
501 {{{{0, 2}}, {{2, 4}}, {{4, 0}}, {{X, X}}}},
502 {{{{3, 1}}, {{1, 4}}, {{4, 3}}, {{X, X}}}},
503 {{{{1, 0}}, {{0, 4}}, {{4, 1}}, {{X, X}}}},
504 {{{{2, 3}}, {{3, 4}}, {{4, 2}}, {{X, X}}}}}};
506 return table[face][line];
519 const unsigned int e)
const override
523 static const std::array<unsigned int, 6> table = {
533 if (e == 0 || e == 1)
536 {{{1, 0, 2}}, {{3, 4, 5}}}};
542 {{{0, 1, 3, 4}}, {{1, 2, 4, 5}}, {{2, 0, 5, 3}}}};
544 return {table[e - 2]};
592 static std::array<unsigned int, 4> table = {{6, 9, 5, 1}};
607 const unsigned int face)
const override
609 static const unsigned int X =
static_cast<unsigned int>(-1);
618 return table[face][line];
621 const std::array<unsigned int, 2> &
623 const unsigned int face)
const override
625 static const unsigned int X =
static_cast<unsigned int>(-1);
628 {{{{{1, 0}}, {{0, 2}}, {{2, 1}}, {{X, X}}}},
629 {{{{3, 4}}, {{4, 5}}, {{5, 3}}, {{X, X}}}},
630 {{{{0, 3}}, {{1, 4}}, {{0, 1}}, {{3, 4}}}},
631 {{{{1, 4}}, {{2, 5}}, {{1, 2}}, {{4, 5}}}},
632 {{{{2, 5}}, {{0, 3}}, {{2, 0}}, {{5, 3}}}}}};
634 return table[face][line];
647 const unsigned int e)
const override
651 static const std::array<unsigned int, 8> table = {
652 {0, 1, 2, 3, 4, 5, 6, 7}};
718 static std::array<unsigned int, 4> table = {{8, 12, 6, 1}};
731 const unsigned int face)
const override
741 return table[face][line];
744 const std::array<unsigned int, 2> &
746 const unsigned int face)
const override
749 {{{{{0, 4}}, {{2, 6}}, {{0, 2}}, {{4, 6}}}},
750 {{{{1, 5}}, {{3, 7}}, {{1, 3}}, {{5, 7}}}},
751 {{{{0, 1}}, {{4, 5}}, {{0, 4}}, {{1, 5}}}},
752 {{{{2, 3}}, {{6, 7}}, {{2, 6}}, {{3, 7}}}},
753 {{{{0, 2}}, {{1, 3}}, {{0, 1}}, {{2, 3}}}},
754 {{{{4, 6}}, {{5, 7}}, {{4, 5}}, {{6, 7}}}}}};
756 return table[face][line];
768 template <
typename T =
unsigned int>
780 CRS(
const std::vector<std::size_t> &
ptr,
const std::vector<T> &
col)
786 std::vector<std::size_t>
ptr;
822 template <
typename T =
unsigned int>
853 inline std::vector<ReferenceCell> &
856 if (structdim ==
dim)
866 inline const std::vector<ReferenceCell> &
869 if (structdim ==
dim)
886 else if (
dim == 3 &&
from == 2 &&
to == 0)
888 else if (
dim == 3 &&
from == 2 &&
to == 1)
890 else if (
from == 1 &&
to == 0)
905 else if (
dim == 3 &&
from == 2 &&
to == 0)
907 else if (
dim == 3 &&
from == 2 &&
to == 1)
909 else if (
from == 1 &&
to == 0)
945 template <
typename T>
955 const unsigned int n_faces =
963 std::vector<std::pair<T, unsigned int>> neighbors(n_faces, {-1, -1});
971 if (neighbors[
col_cf[
j_0]].
first ==
static_cast<unsigned int>(-1))
998 template <
int max_n_vertices,
typename FU>
1002 const std::vector<std::shared_ptr<CellTypeBase>> &cell_types,
1012 const std::vector<std::size_t> &
cell_ptr =
crs.ptr;
1014 std::vector<std::size_t> &
ptr_d =
crs_d.ptr;
1015 std::vector<unsigned int> &
col_d =
crs_d.col;
1019 std::vector<std::size_t> &
ptr_0 =
crs_0.ptr;
1020 std::vector<unsigned int> &
col_0 =
crs_0.col;
1026 unsigned int n_entities = 0;
1039 std::tuple<std::array<unsigned int, max_n_vertices>,
unsigned int>>
1046 keys.reserve(n_entities);
1054 static const unsigned int offset = 1;
1059 const auto &cell_type =
1069 for (
unsigned int e = 0;
1087 keys.emplace_back(
key, counter++);
1100 col_d.resize(keys.size());
1105 std::sort(keys.begin(), keys.end());
1115 for (
unsigned int i = 0; i < keys.size(); ++i)
1117 const auto offset_i = std::get<1>(keys[i]);
1119 if (
ref_key != std::get<0>(keys[i]))
1121 ref_key = std::get<0>(keys[i]);
1132 std::get<0>(keys[i]) =
new_key;
1135 std::sort(keys.begin(), keys.end());
1142 std::array<unsigned int, max_n_vertices>
ref_key;
1143 std::array<unsigned int, max_n_vertices>
ref_indices;
1147 for (
unsigned int i = 0; i < keys.size(); i++)
1149 const auto offset_i = std::get<1>(keys[i]);
1151 if (
ref_key != std::get<0>(keys[i]))
1155 ref_key = std::get<0>(keys[i]);
1161 col_0.push_back(
j - offset);
1189 template <
typename FU>
1193 const std::vector<std::shared_ptr<CellTypeBase>> &cell_types,
1205 const auto &cell_type =
1207 for (
unsigned int e = 0;
1257 const std::vector<std::shared_ptr<CellTypeBase>> &cell_types,
1280 for (
unsigned int c = 0; c <
con_cq.ptr.
size() - 1; ++c)
1282 const auto &cell_type =
1291 const unsigned int f =
con_cq.col[
f_];
1298 for (
unsigned int i = 0; i <
con_ql.ptr.
size() - 1; ++i)
1306 for (
unsigned int c = 0; c <
con_cq.ptr.
size() - 1; ++c)
1308 const auto &cell_type =
1317 const unsigned int f =
con_cq.col[
f_];
1320 if (
ori_cq.get_combined_orientation(
f_) !=
1328 for (
unsigned int l = 0;
1329 l < cell_type->n_lines_of_surface(
f_index);
1334 cell_type->nth_line_of_surface(l,
f_index);
1341 cell_type->vertices_of_nth_line_of_surface(l,
f_index);
1353 ori_ql.set_combined_orientation(
1372 template <
typename T>
1375 const std::vector<std::shared_ptr<CellTypeBase>> &
cell_t,
1376 const std::vector<ReferenceCell> &
cell_t_id,
1384 connectivity.entity_to_entities(1, 0) =
con_cv;
1386 if (dim == 2 || dim == 3)
1393 connectivity.entity_types(dim),
1395 dim == 2 ? connectivity.entity_to_entities(2, 1) :
temp1,
1396 connectivity.entity_to_entities(1, 0),
1397 dim == 2 ? connectivity.entity_orientations(1) :
dummy,
1398 [](
auto key,
const auto &,
const auto &,
const auto &) {
1409 connectivity.entity_types(3),
1411 connectivity.entity_to_entities(3, 2),
1412 connectivity.entity_to_entities(2, 0),
1413 connectivity.entity_orientations(2),
1414 [&](
auto key,
const auto &cell_type,
const auto &c,
const auto &f) {
1416 AssertIndexRange(cell_type->n_lines_of_surface(f),
1421 for (; l < cell_type->n_lines_of_surface(f); ++l)
1424 .col[temp1.ptr[c] + cell_type->nth_line_of_surface(l, f)] +
1427 for (; l < key.size(); ++l)
1435 connectivity.entity_types(3),
1438 connectivity.entity_to_entities(1, 0),
1439 connectivity.entity_to_entities(3, 2),
1440 connectivity.entity_to_entities(2, 0),
1441 connectivity.entity_orientations(2),
1442 connectivity.entity_to_entities(2, 1),
1443 connectivity.entity_orientations(1),
1444 connectivity.entity_types(2));
1449 connectivity.entity_to_entities(dim, dim));
1451 return connectivity;
1459 template <
typename T,
int dim>
1474 std::make_shared<CellTypeQuadrilateral>();
1487 std::accumulate(cells.begin(),
1490 [](
const auto &
result,
const auto &cell) {
1491 return result + cell.vertices.size();
1502 for (
const auto &cell : cells)
1513 "The definition of a cell refers to the same vertex several "
1514 "times. This is not possible. A common reason is that "
1515 "CellData::vertices has a size that does not match the "
1516 "size expected from the reference cell. Please resize "
1517 "CellData::vertices or use the appropriate constructor of "
1537 for (
const auto &vertex : cell.vertices)
ArrayView< typename std::remove_reference< typename std::iterator_traits< Iterator >::reference >::type, MemorySpaceType > make_array_view(const Iterator begin, const Iterator end)
value_type * data() const noexcept
void reinit(value_type *starting_element, const std::size_t n_elements)
static constexpr unsigned char default_combined_face_orientation()
static constexpr unsigned char reversed_combined_line_orientation()
static ReferenceCell n_vertices_to_type(const int dim, const unsigned int n_vertices)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
constexpr const ReferenceCell Tetrahedron
constexpr const ReferenceCell Quadrilateral
constexpr const ReferenceCell Wedge
constexpr const ReferenceCell Pyramid
constexpr const ReferenceCell Invalid
constexpr const ReferenceCell Triangle
constexpr const ReferenceCell Hexahedron
constexpr const ReferenceCell Vertex
constexpr const ReferenceCell Line
void determine_neighbors(const CRS< T > &con_cf, CRS< T > &con_cc)
void build_intersection(const std::vector< std::shared_ptr< CellTypeBase > > &cell_types, const std::vector< ReferenceCell > &cell_types_index, const CRS< unsigned int > &con_cv, const CRS< unsigned int > &con_cl, const CRS< unsigned int > &con_lv, const CRS< unsigned int > &con_cq, const CRS< unsigned int > &con_qv, const TriaObjectsOrientations &ori_cq, CRS< unsigned int > &con_ql, TriaObjectsOrientations &ori_ql, std::vector< ReferenceCell > &quad_t_id)
void build_face_entities_templated(const unsigned int face_dimensionality, const std::vector< std::shared_ptr< CellTypeBase > > &cell_types, const std::vector< 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)
Connectivity< T > build_connectivity(const unsigned int dim, const std::vector< std::shared_ptr< CellTypeBase > > &cell_t, const std::vector< ReferenceCell > &cell_t_id, const CRS< T > &con_cv)
void build_face_entities(const unsigned int face_dimensionality, const std::vector< std::shared_ptr< CellTypeBase > > &cell_types, const std::vector< 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)
static const unsigned int invalid_unsigned_int
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
std::uint8_t geometric_entity_type
std::vector< std::size_t > ptr
CRS(const std::vector< std::size_t > &ptr, const std::vector< T > &col)
virtual unsigned int n_entities(const unsigned int d) const
virtual ::ArrayView< const unsigned int > vertices_of_entity(const unsigned int d, const unsigned int e) const
virtual ReferenceCell type_of_entity(const unsigned int d, const unsigned int e) const
virtual const std::array< unsigned int, 2 > & vertices_of_nth_line_of_surface(const unsigned int line, const unsigned int face) const
virtual unsigned int n_lines_of_surface(const unsigned int face) const
virtual ~CellTypeBase()=default
virtual unsigned int nth_line_of_surface(const unsigned int line, const unsigned int face) const
virtual ReferenceCell type_of_entity(const unsigned int d, const unsigned int e) const override
::ArrayView< const unsigned int > vertices_of_entity(const unsigned int d, const unsigned int e) const override
unsigned int nth_line_of_surface(const unsigned int line, const unsigned int face) const override
unsigned int n_entities(const unsigned int d) const override
const std::array< unsigned int, 2 > & vertices_of_nth_line_of_surface(const unsigned int line, const unsigned int face) const override
unsigned int n_lines_of_surface(const unsigned int surface) const override
::ArrayView< const unsigned int > vertices_of_entity(const unsigned int d, const unsigned int e) const override
unsigned int n_entities(const unsigned int d) const override
ReferenceCell type_of_entity(const unsigned int d, const unsigned int e) const override
unsigned int n_lines_of_surface(const unsigned int surface) const override
const std::array< unsigned int, 2 > & vertices_of_nth_line_of_surface(const unsigned int line, const unsigned int face) const override
::ArrayView< const unsigned int > vertices_of_entity(const unsigned int d, const unsigned int e) const override
unsigned int n_entities(const unsigned int d) const override
unsigned int nth_line_of_surface(const unsigned int line, const unsigned int face) const override
virtual ReferenceCell type_of_entity(const unsigned int d, const unsigned int e) const override
virtual ReferenceCell type_of_entity(const unsigned int d, const unsigned int e) const override
unsigned int n_entities(const unsigned int d) const override
::ArrayView< const unsigned int > vertices_of_entity(const unsigned int d, const unsigned int e) const override
unsigned int nth_line_of_surface(const unsigned int line, const unsigned int face) const override
unsigned int n_lines_of_surface(const unsigned int line) const override
::ArrayView< const unsigned int > vertices_of_entity(const unsigned int d, const unsigned int e) const override
unsigned int n_entities(const unsigned int d) const override
const std::array< unsigned int, 2 > & vertices_of_nth_line_of_surface(const unsigned int line, const unsigned int face) const override
virtual ReferenceCell type_of_entity(const unsigned int d, const unsigned int e) const override
unsigned int n_entities(const unsigned int d) const override
::ArrayView< const unsigned int > vertices_of_entity(const unsigned int d, const unsigned int e) const override
virtual ReferenceCell type_of_entity(const unsigned int d, const unsigned int e) const override
unsigned int n_entities(const unsigned int d) const override
unsigned int n_lines_of_surface(const unsigned int surface) const override
::ArrayView< const unsigned int > vertices_of_entity(const unsigned int d, const unsigned int e) const override
virtual ReferenceCell type_of_entity(const unsigned int d, const unsigned int e) const override
unsigned int nth_line_of_surface(const unsigned int line, const unsigned int face) const override
const std::array< unsigned int, 2 > & vertices_of_nth_line_of_surface(const unsigned int line, const unsigned int face) const override
const CRS< T > & entity_to_entities(const unsigned int from, const unsigned int to) const
CRS< T > & entity_to_entities(const unsigned int from, const unsigned int to)
TriaObjectsOrientations line_orientation
std::vector< ReferenceCell > & entity_types(const unsigned int structdim)
const std::vector< ReferenceCell > & entity_types(const unsigned int structdim) const
TriaObjectsOrientations quad_orientation
std::vector< ReferenceCell > quad_types
Connectivity(const unsigned int dim, const std::vector< ReferenceCell > &cell_types)
std::vector< ReferenceCell > cell_types
TriaObjectsOrientations & entity_orientations(const unsigned int structdim)
const TriaObjectsOrientations & entity_orientations(const unsigned int structdim) const