From f2a23873dab9ec2ba7b25287a5cafdda118c1b3b Mon Sep 17 00:00:00 2001 From: heister Date: Thu, 19 Sep 2013 14:58:19 +0000 Subject: [PATCH] add hdf5 test git-svn-id: https://svn.dealii.org/trunk@30828 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/mpi/data_out_hdf5_01.cc | 107 ++++++++++++++++++ tests/mpi/data_out_hdf5_01/ncpu_3/cmp/generic | 35 ++++++ 2 files changed, 142 insertions(+) create mode 100644 tests/mpi/data_out_hdf5_01.cc create mode 100644 tests/mpi/data_out_hdf5_01/ncpu_3/cmp/generic diff --git a/tests/mpi/data_out_hdf5_01.cc b/tests/mpi/data_out_hdf5_01.cc new file mode 100644 index 0000000000..a3c0a1d13f --- /dev/null +++ b/tests/mpi/data_out_hdf5_01.cc @@ -0,0 +1,107 @@ +// --------------------------------------------------------------------- +// $Id: data_out_multi_dh_01.cc 30150 2013-07-24 14:28:03Z kronbichler $ +// +// Copyright (C) 2003 - 2013 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. +// +// --------------------------------------------------------------------- + +// tests DataOut with HDF5 + +#include "../tests.h" +#include +#include +#include +#include +#include +#include + + +std::string output_file_name = "data_out_hdf5_01/output"; + + +template +void +test () +{ + Triangulation tria; + GridGenerator::hyper_cube(tria, 0., 1.); + tria.refine_global (1); + // tria.begin_active()->set_refine_flag(); + //tria.execute_coarsening_and_refinement (); + + FE_Q fe1(1); + + DoFHandler dof1(tria); + dof1.distribute_dofs(fe1); + + Vector v1(dof1.n_dofs()); + for (unsigned int i=0; i data_out; + data_out.add_data_vector (dof1, v1, "linear"); + data_out.build_patches (2); + + data_out.write_hdf5_parallel ("data_out_hdf5_01/out.h5", MPI_COMM_WORLD); + std::vector xdmf_entries; + xdmf_entries.push_back( + data_out.create_xdmf_entry("out.h5", 0, MPI_COMM_WORLD)); + + data_out.write_xdmf_file(xdmf_entries, "data_out_hdf5_01/out.xdmf", + MPI_COMM_WORLD); + + deallog <<"ok" << std::endl; + + + // Sadly hdf5 is binary and we can not use hd5dump because it might + // not be in the path. At least we can look at the xdmf: + if (0==Utilities::MPI::this_mpi_process (MPI_COMM_WORLD)) + cat_file("data_out_hdf5_01/out.xdmf"); +} + + +int main(int argc, char *argv[]) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + MPILogInitAll log(__FILE__); + + try + { + test<2>(); +// test<3>(); + + return 0; + } + catch (std::exception &exc) + { + deallog << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + deallog << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + } + catch (...) + { + deallog << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + deallog << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} + diff --git a/tests/mpi/data_out_hdf5_01/ncpu_3/cmp/generic b/tests/mpi/data_out_hdf5_01/ncpu_3/cmp/generic new file mode 100644 index 0000000000..b54e9c2d35 --- /dev/null +++ b/tests/mpi/data_out_hdf5_01/ncpu_3/cmp/generic @@ -0,0 +1,35 @@ + +DEAL:0::ok + + + + + + + + + + + + +DEAL:1::ok + + +DEAL:2::ok + -- 2.39.5