* this variable is not used but exists only to allow access
* from general code in a generic fashion.
*/
- static unsigned int n_subdivisions;
+ static const unsigned int n_subdivisions;
/**
* Data vectors. The format is as follows: <tt>data(i,.)</tt> denotes the
Patch<0, spacedim>::no_neighbor};
template <int spacedim>
- unsigned int Patch<0, spacedim>::n_subdivisions = 1;
+ const unsigned int Patch<0, spacedim>::n_subdivisions = 1;
template <int spacedim>
const ReferenceCell Patch<0, spacedim>::reference_cell =
for (unsigned int i : patch.reference_cell.face_indices())
in >> patch.neighbors[i];
- in >> patch.patch_index >> patch.n_subdivisions;
+ in >> patch.patch_index;
+
+ // If dim>1, we also need to set the number of subdivisions, whereas
+ // in dim==1, this is a const variable equal to one that can't be changed.
+ unsigned int n_subdivisions;
+ in >> n_subdivisions;
+#ifdef DEAL_II_HAVE_CXX17
+ if constexpr (dim > 1)
+ patch.n_subdivisions = n_subdivisions;
+#else
+ // If we can't use 'if constexpr', work around the fact that we can't
+ // write to a 'const' variable by using a const_cast that is a no-op
+ // whenever the code is actually executed
+ if (dim > 1)
+ const_cast<unsigned int &>(patch.n_subdivisions) = n_subdivisions;
+#endif
in >> patch.points_are_available;
auto particle = particles.begin();
for (unsigned int i = 0; particle != particles.end(); ++particle, ++i)
{
- patches[i].vertices[0] = particle->get_location();
- patches[i].patch_index = i;
- patches[i].n_subdivisions = 1;
+ patches[i].vertices[0] = particle->get_location();
+ patches[i].patch_index = i;
// We have one more data components than dataset_names (the particle id)
patches[i].data.reinit(n_data_components, 1);