From 80337a8e142a692efa7fa8026a8cc4d32208da32 Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Wed, 6 Jul 2022 17:01:04 -0400 Subject: [PATCH] add test --- .../data_out_intermediate_parallel_01.cc | 93 +++++++++++++++++++ ...t_intermediate_parallel_01.mpirun=2.output | 6 ++ 2 files changed, 99 insertions(+) create mode 100644 tests/data_out/data_out_intermediate_parallel_01.cc create mode 100644 tests/data_out/data_out_intermediate_parallel_01.mpirun=2.output diff --git a/tests/data_out/data_out_intermediate_parallel_01.cc b/tests/data_out/data_out_intermediate_parallel_01.cc new file mode 100644 index 0000000000..6c3b24674f --- /dev/null +++ b/tests/data_out/data_out_intermediate_parallel_01.cc @@ -0,0 +1,93 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2022 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 DataOut::write_deal_II_intermediate_in_parallel() + +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include + +#include + +#include "../tests.h" + + +template +void +check() +{ + Triangulation tria; + GridGenerator::hyper_cube(tria, 0., 1.); + tria.refine_global(1); + + Vector cell_data(tria.n_active_cells()); + for (unsigned int i = 0; i < tria.n_active_cells(); ++i) + cell_data(i) = i * 1.0; + + FE_Q fe(1); + DoFHandler dof_handler(tria); + dof_handler.distribute_dofs(fe); + + Vector x(dof_handler.n_dofs()); + + DataOut data_out; + data_out.attach_dof_handler(dof_handler); + data_out.add_data_vector(cell_data, + "cell_data", + DataOut::type_cell_data); + data_out.add_data_vector(x, "solution"); + + data_out.build_patches(); + + data_out.write_deal_II_intermediate_in_parallel( + "test.d2p", MPI_COMM_WORLD, DataOutBase::VtkFlags::no_compression); + + const unsigned int my_rank = + dealii::Utilities::MPI::this_mpi_process(MPI_COMM_WORLD); + if (my_rank == 0) + { + // can't checksum as the file contains "[written by deal.II + // 9.5.0-pre]" which would change often, so we just look at the + // size for now. This will of course fail once we go to + // 10.0. :-) + std::ifstream in("test.d2p", std::ifstream::ate | std::ifstream::binary); + Assert(in, dealii::ExcIO()); + deallog << "size: " << in.tellg() << std::endl; + } + + deallog << "OK" << std::endl; +} + +int +main(int argc, char **argv) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + MPILogInitAll all; + + check<2>(); + + return 0; +} diff --git a/tests/data_out/data_out_intermediate_parallel_01.mpirun=2.output b/tests/data_out/data_out_intermediate_parallel_01.mpirun=2.output new file mode 100644 index 0000000000..6a193c2262 --- /dev/null +++ b/tests/data_out/data_out_intermediate_parallel_01.mpirun=2.output @@ -0,0 +1,6 @@ + +DEAL:0::size: 1244 +DEAL:0::OK + +DEAL:1::OK + -- 2.39.5