]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add test and MatrixFree::initialize_dof_vector
authorPeter Munch <peterrmuench@gmail.com>
Sat, 21 Mar 2020 11:11:54 +0000 (12:11 +0100)
committerPeter Munch <peterrmuench@gmail.com>
Sat, 21 Mar 2020 11:11:54 +0000 (12:11 +0100)
include/deal.II/lac/la_sm_vector.templates.h
include/deal.II/matrix_free/matrix_free.h
tests/sm/CMakeLists.txt [new file with mode: 0644]
tests/sm/vector_sm_01.cc [new file with mode: 0644]
tests/sm/vector_sm_01.output [new file with mode: 0644]

index be5cf3474a98592b2097d7b63108f8a0a11e949d..6049b90438d0b08cc72b3d3b3b2a37c2368f6457 100644 (file)
@@ -126,9 +126,7 @@ namespace LinearAlgebra
     Vector<Number, MemorySpaceType>::Vector()
       : partitioner(new Utilities::MPI::Partitioner())
       , allocated_size(0)
-    {
-      Assert(false, ExcNotImplemented());
-    }
+    {}
 
 
 
index 45f562a141b6f839b6610907eb949464696b359c..082d5492137469de4c85fdbdbd5abc522a92f5e2 100644 (file)
@@ -40,6 +40,7 @@
 #include <deal.II/lac/affine_constraints.h>
 #include <deal.II/lac/block_vector_base.h>
 #include <deal.II/lac/la_parallel_vector.h>
+#include <deal.II/lac/la_sm_vector.h>
 #include <deal.II/lac/vector_operation.h>
 
 #include <deal.II/matrix_free/dof_info.h>
@@ -1477,6 +1478,11 @@ public:
   initialize_dof_vector(LinearAlgebra::distributed::Vector<Number2> &vec,
                         const unsigned int dof_handler_index = 0) const;
 
+  template <typename Number2>
+  void
+  initialize_dof_vector(LinearAlgebra::SharedMPI::Vector<Number2> &vec,
+                        const unsigned int dof_handler_index = 0) const;
+
   /**
    * Return the partitioner that represents the locally owned data and the
    * ghost indices where access is needed to for the cell loop. The
@@ -2210,6 +2216,19 @@ MatrixFree<dim, Number, VectorizedArrayType>::initialize_dof_vector(
 
 
 
+template <int dim, typename Number, typename VectorizedArrayType>
+template <typename Number2>
+inline void
+MatrixFree<dim, Number, VectorizedArrayType>::initialize_dof_vector(
+  LinearAlgebra::SharedMPI::Vector<Number2> &vec,
+  const unsigned int                         comp) const
+{
+  AssertIndexRange(comp, n_components());
+  vec.reinit(dof_info[comp].vector_partitioner);
+}
+
+
+
 template <int dim, typename Number, typename VectorizedArrayType>
 inline const std::shared_ptr<const Utilities::MPI::Partitioner> &
 MatrixFree<dim, Number, VectorizedArrayType>::get_vector_partitioner(
diff --git a/tests/sm/CMakeLists.txt b/tests/sm/CMakeLists.txt
new file mode 100644 (file)
index 0000000..d33eafa
--- /dev/null
@@ -0,0 +1,4 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
+INCLUDE(../setup_testsubproject.cmake)
+PROJECT(testsuite CXX)
+DEAL_II_PICKUP_TESTS()
diff --git a/tests/sm/vector_sm_01.cc b/tests/sm/vector_sm_01.cc
new file mode 100644 (file)
index 0000000..749c8d0
--- /dev/null
@@ -0,0 +1,73 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2020 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 PolynomialsTet on quadrature points returned by QGaussTet.
+
+#include <deal.II/base/quadrature_lib.h>
+
+#include <deal.II/dofs/dof_handler.h>
+
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/fe/mapping_q_generic.h>
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria.h>
+
+#include <deal.II/lac/la_sm_vector.h>
+
+#include <deal.II/matrix_free/matrix_free.h>
+
+#include "../tests.h"
+
+using namespace dealii;
+
+template <typename Number, int dim>
+void
+test(const int n_refinements, const int degree)
+{
+  Triangulation<dim> tria;
+  GridGenerator::hyper_cube(tria);
+  tria.refine_global(n_refinements);
+
+  DoFHandler<dim> dof_handler(tria);
+  FE_Q<dim>       fe(degree);
+  dof_handler.distribute_dofs(fe);
+
+  AffineConstraints<Number> constraint;
+  constraint.close();
+
+  QGauss<1> quad(degree + 1);
+
+  MappingQGeneric<dim> mapping(1);
+
+  typename dealii::MatrixFree<dim, Number>::AdditionalData additional_data;
+  additional_data.mapping_update_flags =
+    update_gradients | update_JxW_values | update_quadrature_points;
+
+  dealii::MatrixFree<dim, Number> matrix_free;
+  matrix_free.reinit(mapping, dof_handler, constraint, quad, additional_data);
+
+  LinearAlgebra::SharedMPI::Vector<Number> vec;
+  matrix_free.initialize_dof_vector(vec);
+}
+
+int
+main()
+{
+  initlog();
+
+  test<double, 2>(1, 1);
+}
\ No newline at end of file
diff --git a/tests/sm/vector_sm_01.output b/tests/sm/vector_sm_01.output
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+

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.