]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a test using LA::d::Vector<double, MemorySpace::CUDA> 7446/head
authorBruno Turcksin <bruno.turcksin@gmail.com>
Wed, 14 Nov 2018 21:57:31 +0000 (21:57 +0000)
committerBruno Turcksin <bruno.turcksin@gmail.com>
Fri, 16 Nov 2018 13:43:22 +0000 (13:43 +0000)
tests/cuda/matrix_free_matrix_vector_06a.cu [new file with mode: 0644]
tests/cuda/matrix_free_matrix_vector_06a.output [new file with mode: 0644]

diff --git a/tests/cuda/matrix_free_matrix_vector_06a.cu b/tests/cuda/matrix_free_matrix_vector_06a.cu
new file mode 100644 (file)
index 0000000..c9c5d1c
--- /dev/null
@@ -0,0 +1,78 @@
+// ---------------------------------------------------------------------
+//
+// 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.
+//
+// ---------------------------------------------------------------------
+
+
+// Same as matrix_free_matrix_vector_06a but uses LA::distributed::Vector
+// instead of CUDAWrappers::Vector
+
+#include <deal.II/base/function.h>
+
+#include "../tests.h"
+#include "create_mesh.h"
+
+std::ofstream logfile("output");
+
+#include "matrix_vector_common.h"
+
+template <int dim, int fe_degree>
+void
+test()
+{
+  if (fe_degree > 1)
+    return;
+  Triangulation<dim> tria;
+  create_mesh(tria);
+  tria.begin_active()->set_refine_flag();
+  tria.execute_coarsening_and_refinement();
+  typename Triangulation<dim>::active_cell_iterator cell, endc;
+  cell = tria.begin_active();
+  endc = tria.end();
+  for (; cell != endc; ++cell)
+    if (cell->center().norm() < 0.5)
+      cell->set_refine_flag();
+  tria.execute_coarsening_and_refinement();
+  tria.begin(tria.n_levels() - 1)->set_refine_flag();
+  tria.last()->set_refine_flag();
+  tria.execute_coarsening_and_refinement();
+  tria.refine_global(1);
+  cell = tria.begin_active();
+  for (unsigned int i = 0; i < 10 - 3 * dim; ++i)
+    {
+      cell                 = tria.begin_active();
+      endc                 = tria.end();
+      unsigned int counter = 0;
+      for (; cell != endc; ++cell, ++counter)
+        if (counter % (7 - i) == 0)
+          cell->set_refine_flag();
+      tria.execute_coarsening_and_refinement();
+    }
+
+  FE_Q<dim>       fe(fe_degree);
+  DoFHandler<dim> dof(tria);
+  dof.distribute_dofs(fe);
+  AffineConstraints<double> constraints;
+  DoFTools::make_hanging_node_constraints(dof, constraints);
+  VectorTools::interpolate_boundary_values(dof,
+                                           0,
+                                           Functions::ZeroFunction<dim>(),
+                                           constraints);
+  constraints.close();
+
+  do_test<dim,
+          fe_degree,
+          double,
+          LinearAlgebra::distributed::Vector<double, MemorySpace::CUDA>,
+          fe_degree + 1>(dof, constraints);
+}
diff --git a/tests/cuda/matrix_free_matrix_vector_06a.output b/tests/cuda/matrix_free_matrix_vector_06a.output
new file mode 100644 (file)
index 0000000..e9e176a
--- /dev/null
@@ -0,0 +1,7 @@
+
+DEAL:2d::Testing FE_Q<2>(1)
+DEAL:2d::Norm of difference: 0
+DEAL:2d::
+DEAL:3d::Testing FE_Q<3>(1)
+DEAL:3d::Norm of difference: 0
+DEAL:3d::

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.