From: Peter Munch Date: Sat, 21 Mar 2020 11:11:54 +0000 (+0100) Subject: Add test and MatrixFree::initialize_dof_vector X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a50988423c081192454f043dcbe0d1664105cece;p=dealii.git Add test and MatrixFree::initialize_dof_vector --- diff --git a/include/deal.II/lac/la_sm_vector.templates.h b/include/deal.II/lac/la_sm_vector.templates.h index be5cf3474a..6049b90438 100644 --- a/include/deal.II/lac/la_sm_vector.templates.h +++ b/include/deal.II/lac/la_sm_vector.templates.h @@ -126,9 +126,7 @@ namespace LinearAlgebra Vector::Vector() : partitioner(new Utilities::MPI::Partitioner()) , allocated_size(0) - { - Assert(false, ExcNotImplemented()); - } + {} diff --git a/include/deal.II/matrix_free/matrix_free.h b/include/deal.II/matrix_free/matrix_free.h index 45f562a141..082d549213 100644 --- a/include/deal.II/matrix_free/matrix_free.h +++ b/include/deal.II/matrix_free/matrix_free.h @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -1477,6 +1478,11 @@ public: initialize_dof_vector(LinearAlgebra::distributed::Vector &vec, const unsigned int dof_handler_index = 0) const; + template + void + initialize_dof_vector(LinearAlgebra::SharedMPI::Vector &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::initialize_dof_vector( +template +template +inline void +MatrixFree::initialize_dof_vector( + LinearAlgebra::SharedMPI::Vector &vec, + const unsigned int comp) const +{ + AssertIndexRange(comp, n_components()); + vec.reinit(dof_info[comp].vector_partitioner); +} + + + template inline const std::shared_ptr & MatrixFree::get_vector_partitioner( diff --git a/tests/sm/CMakeLists.txt b/tests/sm/CMakeLists.txt new file mode 100644 index 0000000000..d33eafa20b --- /dev/null +++ b/tests/sm/CMakeLists.txt @@ -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 index 0000000000..749c8d033d --- /dev/null +++ b/tests/sm/vector_sm_01.cc @@ -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 + +#include + +#include +#include + +#include +#include + +#include + +#include + +#include "../tests.h" + +using namespace dealii; + +template +void +test(const int n_refinements, const int degree) +{ + Triangulation tria; + GridGenerator::hyper_cube(tria); + tria.refine_global(n_refinements); + + DoFHandler dof_handler(tria); + FE_Q fe(degree); + dof_handler.distribute_dofs(fe); + + AffineConstraints constraint; + constraint.close(); + + QGauss<1> quad(degree + 1); + + MappingQGeneric mapping(1); + + typename dealii::MatrixFree::AdditionalData additional_data; + additional_data.mapping_update_flags = + update_gradients | update_JxW_values | update_quadrature_points; + + dealii::MatrixFree matrix_free; + matrix_free.reinit(mapping, dof_handler, constraint, quad, additional_data); + + LinearAlgebra::SharedMPI::Vector vec; + matrix_free.initialize_dof_vector(vec); +} + +int +main() +{ + initlog(); + + test(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 index 0000000000..8b13789179 --- /dev/null +++ b/tests/sm/vector_sm_01.output @@ -0,0 +1 @@ +