]> https://gitweb.dealii.org/ - dealii.git/commitdiff
FEEvaluationData: add virtual destructor 14190/head
authorPeter Munch <peterrmuench@gmail.com>
Tue, 16 Aug 2022 07:32:42 +0000 (09:32 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Wed, 17 Aug 2022 09:09:08 +0000 (11:09 +0200)
include/deal.II/matrix_free/fe_evaluation_data.h
tests/matrix_free/fe_evaluation_dynamic_cast.cc [new file with mode: 0644]
tests/matrix_free/fe_evaluation_dynamic_cast.output [new file with mode: 0644]

index f6854fb0c6786cd15d76c63b4937d78447397356..03be313a7ae6a1caebb869c65669e1f1fc34ff17 100644 (file)
@@ -149,6 +149,11 @@ public:
   FEEvaluationData &
   operator=(const FEEvaluationData &other);
 
+  /**
+   * Destructor.
+   */
+  virtual ~FEEvaluationData() = default;
+
   /**
    * Sets the pointers for values, gradients, hessians to the central
    * scratch_data_array inside the given scratch array, for a given number of
diff --git a/tests/matrix_free/fe_evaluation_dynamic_cast.cc b/tests/matrix_free/fe_evaluation_dynamic_cast.cc
new file mode 100644 (file)
index 0000000..ed60607
--- /dev/null
@@ -0,0 +1,69 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2019 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE.md at
+// the top level directory of deal.II.
+//
+// ---------------------------------------------------------------------
+
+
+
+// Test that FEEvaluationData is virtual.
+
+#include <deal.II/dofs/dof_handler.h>
+
+#include <deal.II/fe/fe_q.h>
+
+#include <deal.II/grid/grid_generator.h>
+
+#include <deal.II/lac/affine_constraints.h>
+
+#include <deal.II/matrix_free/fe_evaluation.h>
+#include <deal.II/matrix_free/matrix_free.h>
+
+#include "../tests.h"
+
+int
+main()
+{
+  initlog();
+
+  const unsigned int dim    = 2;
+  using Number              = double;
+  using VectorizedArrayType = VectorizedArray<Number>;
+
+  Triangulation<dim> tria;
+  GridGenerator::hyper_cube(tria);
+  DoFHandler<dim> dof(tria);
+  dof.distribute_dofs(FE_Q<dim>(1));
+
+  MatrixFree<dim, Number, VectorizedArrayType> dummy;
+
+  dummy.reinit(MappingQ1<dim>{},
+               dof,
+               AffineConstraints<double>(),
+               QGauss<1>(2));
+
+  std::unique_ptr<FEEvaluationData<dim, VectorizedArrayType, false>> phi_base =
+    std::make_unique<FEEvaluation<dim, -1, 0, 1, Number, VectorizedArrayType>>(
+      dummy);
+
+  if (dynamic_cast<FEEvaluation<dim, -1, 0, 1, Number, VectorizedArrayType> *>(
+        phi_base.get()))
+    deallog << "OK!" << std::endl;
+  else
+    deallog << "Fail!" << std::endl;
+
+  if (dynamic_cast<FEEvaluation<dim, -1, 0, 2, Number, VectorizedArrayType> *>(
+        phi_base.get()))
+    deallog << "Fail!" << std::endl;
+  else
+    deallog << "OK!" << std::endl;
+}
diff --git a/tests/matrix_free/fe_evaluation_dynamic_cast.output b/tests/matrix_free/fe_evaluation_dynamic_cast.output
new file mode 100644 (file)
index 0000000..043986a
--- /dev/null
@@ -0,0 +1,3 @@
+
+DEAL::OK!
+DEAL::OK!

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.