]> https://gitweb.dealii.org/ - dealii.git/commitdiff
set components correctly in IncrementalFunction 7415/head
authorDenis Davydov <davydden@gmail.com>
Sun, 4 Nov 2018 21:44:26 +0000 (22:44 +0100)
committerDenis Davydov <davydden@gmail.com>
Sun, 4 Nov 2018 21:45:14 +0000 (22:45 +0100)
source/base/incremental_function.cc
tests/base/functions_incremental_03.cc [new file with mode: 0644]
tests/base/functions_incremental_03.output [new file with mode: 0644]

index 18091c358da37f6721c89aa22ff953d0735af4d7..38739f9bd3039e688c9bfff7519baddca65cc56f 100644 (file)
@@ -25,7 +25,8 @@ namespace Functions
   template <int dim, typename RangeNumberType>
   IncrementalFunction<dim, RangeNumberType>::IncrementalFunction(
     Function<dim, RangeNumberType> &base)
-    : base(base)
+    : Function<dim, RangeNumberType>(base.n_components)
+    , base(base)
     , delta_t(numbers::signaling_nan<time_type>())
     , values_old(base.n_components)
   {}
diff --git a/tests/base/functions_incremental_03.cc b/tests/base/functions_incremental_03.cc
new file mode 100644 (file)
index 0000000..3284f10
--- /dev/null
@@ -0,0 +1,41 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+// Check that IncrementalFunction use correct number of components
+
+#include <deal.II/base/incremental_function.h>
+
+#include "../tests.h"
+
+template <int dim>
+void
+check(const unsigned int n_comp = 3)
+{
+  Functions::ZeroFunction<dim>        func(n_comp);
+  Functions::IncrementalFunction<dim> inc(func);
+
+  AssertThrow(inc.n_components == n_comp, ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+int
+main()
+{
+  initlog();
+
+  check<2>();
+}
diff --git a/tests/base/functions_incremental_03.output b/tests/base/functions_incremental_03.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+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.