From 32c16d1d88ae72ec79fd5c80e8a5f4fa40ab9078 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 19 Aug 2021 17:18:46 -0600 Subject: [PATCH] Allow for the default construction of 1d face iterators. --- include/deal.II/dofs/dof_accessor.h | 3 +- include/deal.II/dofs/dof_accessor.templates.h | 32 ++++++++++++++----- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/include/deal.II/dofs/dof_accessor.h b/include/deal.II/dofs/dof_accessor.h index 9d81ce0749..b3636f13b9 100644 --- a/include/deal.II/dofs/dof_accessor.h +++ b/include/deal.II/dofs/dof_accessor.h @@ -851,7 +851,8 @@ public: /** * Constructor. This constructor exists in order to maintain interface * compatibility with the other accessor classes. However, it doesn't do - * anything useful here and so may not actually be called. + * anything useful here and so may not actually be called except to + * default-construct iterator objects. */ DoFAccessor(const Triangulation<1, spacedim> *, const int = 0, diff --git a/include/deal.II/dofs/dof_accessor.templates.h b/include/deal.II/dofs/dof_accessor.templates.h index d360a2642a..582405f1c1 100644 --- a/include/deal.II/dofs/dof_accessor.templates.h +++ b/include/deal.II/dofs/dof_accessor.templates.h @@ -1836,15 +1836,31 @@ inline DoFAccessor<0, 1, spacedim, level_dof_access>::DoFAccessor( template inline DoFAccessor<0, 1, spacedim, level_dof_access>::DoFAccessor( - const Triangulation<1, spacedim> *, - const int, - const int, - const DoFHandler<1, spacedim> *) - : dof_handler(nullptr) -{ - Assert(false, + const Triangulation<1, spacedim> *tria, + const int level, + const int index, + const DoFHandler<1, spacedim> * dof_handler) + // This is the constructor signature for "ordinary" (non-vertex) + // accessors and we shouldn't be calling it altogether. But it is also + // the constructor that the default-constructor of TriaRawIterator + // calls when default-constructing an iterator object. If so, this + // happens with level==-2 and index==-2, and this is the only case we + // would like to support. We do this by just forwarding to the + // other constructor of this class, and then asserting the condition + // on level and index. + : DoFAccessor<0, 1, spacedim, level_dof_access>( + tria, + TriaAccessor<0, 1, spacedim>::interior_vertex, + 0U, + dof_handler) +{ + (void)level; + (void)index; + Assert((tria == nullptr) && (level == -2) && (index == -2) && + (dof_handler == nullptr), ExcMessage( - "This constructor can not be called for face iterators in 1d.")); + "This constructor can not be called for face iterators in 1d, " + "except to default-construct iterator objects.")); } -- 2.39.5