From a9572e20afc3eb6dc25769e1f0b95389477f8b11 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Wed, 8 Mar 2017 15:58:47 +0100 Subject: [PATCH] Test for matrix-free operator masking --- tests/matrix_free/mass_operator_04.cc | 116 ++++++++++++++++++ ...h_mpi=true.with_p4est=true.mpirun=4.output | 3 + 2 files changed, 119 insertions(+) create mode 100644 tests/matrix_free/mass_operator_04.cc create mode 100644 tests/matrix_free/mass_operator_04.with_mpi=true.with_p4est=true.mpirun=4.output diff --git a/tests/matrix_free/mass_operator_04.cc b/tests/matrix_free/mass_operator_04.cc new file mode 100644 index 0000000000..3b3c4f0764 --- /dev/null +++ b/tests/matrix_free/mass_operator_04.cc @@ -0,0 +1,116 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2016 - 2017 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 at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + + +// test MassOperator initialized on a MatrixFree object with several +// components by comparing to another one that only has a single component + +#include "../tests.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + + +template +void test () +{ + typedef double number; + + parallel::distributed::Triangulation tria (MPI_COMM_WORLD); + GridGenerator::hyper_cube (tria); + tria.refine_global(2); + FE_Q fe (1); + DoFHandler dof (tria); + dof.distribute_dofs(fe); + + IndexSet owned_set = dof.locally_owned_dofs(); + IndexSet relevant_set; + DoFTools::extract_locally_relevant_dofs (dof, relevant_set); + + ConstraintMatrix constraints_0 (relevant_set), constraints_1(relevant_set); + VectorTools::interpolate_boundary_values (dof, 0, ZeroFunction(), + constraints_0); + constraints_0.close(); + constraints_1.close(); + + std_cxx11::shared_ptr > mf_data_0(new MatrixFree ()); + std_cxx11::shared_ptr > mf_data_1(new MatrixFree ()); + std_cxx11::shared_ptr > mf_data_combined(new MatrixFree ()); + const QGauss<1> quad (2); + typename MatrixFree::AdditionalData data; + data.tasks_parallel_scheme = + MatrixFree::AdditionalData::none; + mf_data_0->reinit (dof, constraints_0, quad, data); + mf_data_1->reinit (dof, constraints_1, quad, data); + { + std::vector *> dof_handlers(2, &dof); + std::vector constraint(2); + constraint[0] = &constraints_0; + constraint[1] = &constraints_1; + mf_data_combined->reinit (dof_handlers, constraint, quad, data); + } + + MatrixFreeOperators::MassOperator > mf_0, mf_1, mf_c0, mf_c1; + mf_0.initialize(mf_data_0); + mf_1.initialize(mf_data_1); + + mf_c0.initialize(mf_data_combined, std::vector(1, 0)); + mf_c1.initialize(mf_data_combined, std::vector(1, 1)); + + LinearAlgebra::distributed::Vector in, out, ref; + mf_data_0->initialize_dof_vector (in); + + for (unsigned int i=0; i(); +} diff --git a/tests/matrix_free/mass_operator_04.with_mpi=true.with_p4est=true.mpirun=4.output b/tests/matrix_free/mass_operator_04.with_mpi=true.with_p4est=true.mpirun=4.output new file mode 100644 index 0000000000..685105d58a --- /dev/null +++ b/tests/matrix_free/mass_operator_04.with_mpi=true.with_p4est=true.mpirun=4.output @@ -0,0 +1,3 @@ + +DEAL::Error in component 0: 0.00000 +DEAL::Error in component 1: 0.00000 -- 2.39.5