From f1bf0e8269360153ce9072e9b85f1fdf705199c7 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 19 Jun 2017 05:58:14 -0600 Subject: [PATCH] Add a couple of static asserts to SolutionTransfer. This class (in both of its incarnations) takes both a dimension and a DoFHandler as template argument. The dimension of the DoFHandler better match the explicitly given dimension. The added static_assert checks that and prevents instantiation of the class if that is not the case. --- include/deal.II/distributed/solution_transfer.h | 8 +++++++- include/deal.II/numerics/solution_transfer.h | 9 +++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/deal.II/distributed/solution_transfer.h b/include/deal.II/distributed/solution_transfer.h index 6717495d6e..2f14a8b4e0 100644 --- a/include/deal.II/distributed/solution_transfer.h +++ b/include/deal.II/distributed/solution_transfer.h @@ -112,9 +112,15 @@ namespace parallel * @ingroup distributed * @author Timo Heister, 2009-2011 */ - template > + template > class SolutionTransfer { + static_assert (dim == DoFHandlerType::dimension, + "The dimension explicitly provided as a template " + "argument, and the dimension of the DoFHandlerType " + "template argument must match."); public: /** * Constructor, takes the current DoFHandler as argument. diff --git a/include/deal.II/numerics/solution_transfer.h b/include/deal.II/numerics/solution_transfer.h index 3ed4f297ac..b033ca6203 100644 --- a/include/deal.II/numerics/solution_transfer.h +++ b/include/deal.II/numerics/solution_transfer.h @@ -288,10 +288,15 @@ DEAL_II_NAMESPACE_OPEN * @author Ralf Hartmann, 1999, Oliver Kayser-Herold and Wolfgang Bangerth, * 2006, Wolfgang Bangerth 2014 */ -template, - typename DoFHandlerType=DoFHandler > +template, + typename DoFHandlerType = DoFHandler > class SolutionTransfer { + static_assert (dim == DoFHandlerType::dimension, + "The dimension explicitly provided as a template " + "argument, and the dimension of the DoFHandlerType " + "template argument must match."); public: /** -- 2.39.5