From a0e22f0e2faf23ff2f815e4b5e73003ceb33f1c5 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 27 Dec 2018 11:27:46 -0700 Subject: [PATCH] Add test. --- .../interpolate_with_material_id_02.cc | 76 +++++++++++++++++++ ...polate_with_material_id_02.mpirun=2.output | 13 ++++ 2 files changed, 89 insertions(+) create mode 100644 tests/vector_tools/interpolate_with_material_id_02.cc create mode 100644 tests/vector_tools/interpolate_with_material_id_02.mpirun=2.output diff --git a/tests/vector_tools/interpolate_with_material_id_02.cc b/tests/vector_tools/interpolate_with_material_id_02.cc new file mode 100644 index 0000000000..64779bbacc --- /dev/null +++ b/tests/vector_tools/interpolate_with_material_id_02.cc @@ -0,0 +1,76 @@ +// --------------------------------------------------------------------- +// +// 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. +// +// --------------------------------------------------------------------- + + +// Tests if proper checks are run when interpolating on distributed vectors + +#include +#include +#include +#include + +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include "../tests.h" + +using namespace dealii; + +template +void +test_interpolating_distributed(unsigned int ref_cube) +{ + MPI_Comm mpi_communicator = MPI_COMM_WORLD; + unsigned int n_procs = Utilities::MPI::n_mpi_processes(mpi_communicator); + + FE_Q fe(1); + // Implementing the constant function + Functions::ConstantFunction f_constant(1.0); + + // Creating a distributed triangulation + + parallel::distributed::Triangulation cube_d(mpi_communicator); + GridGenerator::hyper_cube(cube_d); + cube_d.refine_global(ref_cube); + DoFHandler dof_handler_d(cube_d); + dof_handler_d.distribute_dofs(fe); + + LinearAlgebra::distributed::Vector data_d(dof_handler_d.n_dofs()); + VectorTools::interpolate(dof_handler_d, f_constant, data_d); + data_d.print(deallog.get_file_stream()); + deallog << "Test passed" << std::endl; +} + +int +main(int argc, char *argv[]) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + MPILogInitAll log; + test_interpolating_distributed<2>(3); +} diff --git a/tests/vector_tools/interpolate_with_material_id_02.mpirun=2.output b/tests/vector_tools/interpolate_with_material_id_02.mpirun=2.output new file mode 100644 index 0000000000..5aac3ed2c0 --- /dev/null +++ b/tests/vector_tools/interpolate_with_material_id_02.mpirun=2.output @@ -0,0 +1,13 @@ + +Process #0 +Local range: [0, 81), global size: 81 +Vector data: +1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 +DEAL:0::Test passed + +Process #0 +Local range: [0, 81), global size: 81 +Vector data: +0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 1.000e+00 1.000e+00 1.000e+00 0.000e+00 0.000e+00 1.000e+00 1.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 0.000e+00 1.000e+00 1.000e+00 0.000e+00 0.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 1.000e+00 +DEAL:1::Test passed + -- 2.39.5