+ // Separate these out to avoid an internal compiler error with intel 17
+ namespace internal
+ {
+ template <int dim>
+ std::array<unsigned int, GeometryInfo<dim>::vertices_per_cell>
+ order_cell( unsigned int /*start*/,
+ unsigned int /*d1*/,
+ unsigned int /*d2*/,
+ unsigned int /*d3*/)
+ {
+ Assert(false, ExcInternalError());
+ return {};
+ }
+
+ template <>
+ std::array<unsigned int, GeometryInfo<1>::vertices_per_cell>
+ order_cell<1>(
+ unsigned int start,
+ unsigned int d1,
+ unsigned int /*d2*/,
+ unsigned int /*d3*/)
+
+ {
+ std::array<unsigned int, GeometryInfo<1>::vertices_per_cell> nodes;
+ nodes[0] = start;
+ nodes[1] = start + d1;
+return nodes;
+ }
+
+ template <>
+ std::array<unsigned int, GeometryInfo<2>::vertices_per_cell>
+ order_cell<2>(
+ unsigned int start,
+ unsigned int d1,
+ unsigned int d2,
+ unsigned int /*d3*/)
+
+ {
+ std::array<unsigned int, GeometryInfo<2>::vertices_per_cell> nodes;
+ nodes[0] = start;
+ nodes[1] = start + d1;
+ nodes[2] = start + d2;
+ nodes[3] = start + d2 + d1;
+return nodes;
+ }
+
+ template <>
+ std::array<unsigned int, GeometryInfo<3>::vertices_per_cell>
+ order_cell<3>( unsigned int start,
+ unsigned int d1,
+ unsigned int d2,
+ unsigned int d3)
+ {
+ std::array<unsigned int, GeometryInfo<3>::vertices_per_cell> nodes;
+ nodes[0] = start;
+ nodes[1] = start + d1;
+ nodes[2] = start + d2;
+ nodes[3] = start + d2 + d1;
+ nodes[4] = start + d3;
+ nodes[5] = start + d3 + d1;
+ nodes[6] = start + d3 + d2;
+ nodes[7] = start + d3 + d2 + d1;
+return nodes;
+ }
+ }
+
+
+
template <int dim>
void
DXStream::write_cell(unsigned int,
unsigned int d2,
unsigned int d3)
{
- int nodes[1 << dim];
- nodes[GeometryInfo<dim>::dx_to_deal[0]] = start;
- if (dim >= 1)
- {
- nodes[GeometryInfo<dim>::dx_to_deal[1]] = start + d1;
- if (dim >= 2)
- {
- // Add shifted line in y direction
- nodes[GeometryInfo<dim>::dx_to_deal[2]] = start + d2;
- nodes[GeometryInfo<dim>::dx_to_deal[3]] = start + d2 + d1;
- if (dim >= 3)
- {
- // Add shifted quad in z direction
- nodes[GeometryInfo<dim>::dx_to_deal[4]] = start + d3;
- nodes[GeometryInfo<dim>::dx_to_deal[5]] = start + d3 + d1;
- nodes[GeometryInfo<dim>::dx_to_deal[6]] = start + d3 + d2;
- nodes[GeometryInfo<dim>::dx_to_deal[7]] = start + d3 + d2 + d1;
- }
- }
- }
+ auto nodes = internal::order_cell<dim>(start, d1, d2, d3);
if (flags.int_binary)
- stream.write(reinterpret_cast<const char *>(nodes),
- (1 << dim) * sizeof(*nodes));
+ stream.write(reinterpret_cast<const char *>(nodes.data()),
+ nodes.size() * sizeof(nodes[0]));
else
{
- const unsigned int final = (1 << dim) - 1;
- for (unsigned int i = 0; i < final; ++i)
- stream << nodes[i] << '\t';
- stream << nodes[final] << '\n';
+ for (unsigned int i = 0; i < nodes.size() - 1; ++i)
+ stream << nodes[GeometryInfo<dim>::dx_to_deal[i]] << '\t';
+ stream << nodes.back() << '\n';
}
}
unsigned int d2,
unsigned int d3)
{
- int nodes[1 << dim];
- nodes[GeometryInfo<dim>::ucd_to_deal[0]] = start;
- if (dim >= 1)
- {
- nodes[GeometryInfo<dim>::ucd_to_deal[1]] = start + d1;
- if (dim >= 2)
- {
- // Add shifted line in y direction
- nodes[GeometryInfo<dim>::ucd_to_deal[2]] = start + d2;
- nodes[GeometryInfo<dim>::ucd_to_deal[3]] = start + d2 + d1;
- if (dim >= 3)
- {
- // Add shifted quad in z direction
- nodes[GeometryInfo<dim>::ucd_to_deal[4]] = start + d3;
- nodes[GeometryInfo<dim>::ucd_to_deal[5]] = start + d3 + d1;
- nodes[GeometryInfo<dim>::ucd_to_deal[6]] = start + d3 + d2;
- nodes[GeometryInfo<dim>::ucd_to_deal[7]] = start + d3 + d2 + d1;
- }
- }
- }
+ auto nodes = internal::order_cell<dim>(start, d1, d2, d3);
// Write out all cells and remember that all indices must be shifted by one.
stream << index + 1 << "\t0 " << ucd_cell_type[dim];
- const unsigned int final = (1 << dim);
- for (unsigned int i = 0; i < final; ++i)
- stream << '\t' << nodes[i] + 1;
+ for (unsigned int i = 0; i < nodes.size(); ++i)
+ stream << '\t' << nodes[GeometryInfo<dim>::ucd_to_deal[i]] + 1;
stream << '\n';
}