Skip to content

Commit

Permalink
Make CellData::vertices to std::vector
Browse files Browse the repository at this point in the history
  • Loading branch information
peterrum committed May 31, 2020
1 parent eab6000 commit 35335c4
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 50 deletions.
4 changes: 4 additions & 0 deletions doc/news/changes/minor/20200531Munch
@@ -0,0 +1,4 @@
Changed: The vertices in CellData are now stored in form of a std::vector
instead of C-style array.
<br>
(Peter Munch, 2020/05/31)
2 changes: 1 addition & 1 deletion include/deal.II/grid/tria_description.h
Expand Up @@ -71,7 +71,7 @@ struct CellData
* to entries in the vector of vertex locations passed to
* Triangulation::create_triangulation().
*/
unsigned int vertices[GeometryInfo<structdim>::vertices_per_cell];
std::vector<unsigned int> vertices;

/**
* Material or boundary indicator of this cell.
Expand Down
43 changes: 32 additions & 11 deletions source/grid/tria.cc
Expand Up @@ -1747,9 +1747,11 @@ namespace internal
// throw an exception if no such cells should exist.
if (!triangulation.check_for_distorted_cells)
{
const double cell_measure =
GridTools::cell_measure<1>(triangulation.vertices,
cells[cell_no].vertices);
const double cell_measure = GridTools::cell_measure<1>(
triangulation.vertices,
reinterpret_cast<const unsigned int(
&)[GeometryInfo<1>::vertices_per_cell]>(
cells[cell_no].vertices.front()));
AssertThrow(cell_measure > 0,
ExcGridHasInvalidCell(cell_no));
}
Expand Down Expand Up @@ -1930,9 +1932,11 @@ namespace internal
// See the note in the 1D function on this if statement.
if (!triangulation.check_for_distorted_cells)
{
const double cell_measure =
GridTools::cell_measure<2>(triangulation.vertices,
cells[cell_no].vertices);
const double cell_measure = GridTools::cell_measure<2>(
triangulation.vertices,
reinterpret_cast<const unsigned int(
&)[GeometryInfo<2>::vertices_per_cell]>(
cells[cell_no].vertices.front()));
AssertThrow(cell_measure > 0,
ExcGridHasInvalidCell(cell_no));
}
Expand Down Expand Up @@ -2305,9 +2309,11 @@ namespace internal
// See the note in the 1D function on this if statement.
if (!triangulation.check_for_distorted_cells)
{
const double cell_measure =
GridTools::cell_measure<3>(triangulation.vertices,
cells[cell_no].vertices);
const double cell_measure = GridTools::cell_measure<3>(
triangulation.vertices,
reinterpret_cast<
const unsigned int(&)[GeometryInfo<3>::vertices_per_cell]>(
cells[cell_no].vertices.front()));
AssertThrow(cell_measure > 0, ExcGridHasInvalidCell(cell_no));
}
}
Expand Down Expand Up @@ -10494,8 +10500,23 @@ Triangulation<dim, spacedim>::create_triangulation(
// because sometimes other objects are already attached to it:
try
{
internal::TriangulationImplementation::Implementation::
create_triangulation(v, cells, subcelldata, *this);
const bool arbitray_mesh_provided =
std::any_of(cells.begin(), cells.end(), [](const auto &cell) {
return cell.vertices.size() != GeometryInfo<dim>::vertices_per_cell;
});

if (arbitray_mesh_provided == false)
{
internal::TriangulationImplementation::Implementation::
create_triangulation(v, cells, subcelldata, *this);
}
else
{
Assert(
false,
ExcMessage(
"A cell with invalid number of vertices has been provided."));
}
}
catch (...)
{
Expand Down
10 changes: 4 additions & 6 deletions source/grid/tria_description.cc
Expand Up @@ -30,13 +30,11 @@ DEAL_II_NAMESPACE_OPEN

template <int structdim>
CellData<structdim>::CellData()
: material_id(0)
: vertices(GeometryInfo<structdim>::vertices_per_cell,
numbers::invalid_unsigned_int)
, material_id(0)
, manifold_id(numbers::flat_manifold_id)
{
std::fill(std::begin(vertices),
std::end(vertices),
numbers::invalid_unsigned_int);
}
{}



Expand Down
52 changes: 26 additions & 26 deletions tests/serialization/cell_data_1.output
@@ -1,54 +1,54 @@

DEAL::0 0 2 0 1 1 1 2
DEAL::0 0 2 0 0 1 1 1 2

DEAL::0 0 2 0 1 1 1 2
DEAL::0 0 2 0 0 1 1 1 2

DEAL::0 0 2 0 1 1 1 2
DEAL::0 0 2 0 0 1 1 1 2

DEAL::0 0 2 0 1 1 1 2
DEAL::0 0 2 0 0 1 1 1 2

DEAL::0 0 2 0 1 1 1 2
DEAL::0 0 2 0 0 1 1 1 2

DEAL::0 0 2 0 1 1 1 2
DEAL::0 0 2 0 0 1 1 1 2

DEAL::0 0 4 0 1 2 3 1 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