]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add hdf5 test
authorTimo Heister <timo.heister@gmail.com>
Thu, 19 Sep 2013 14:58:19 +0000 (14:58 +0000)
committerTimo Heister <timo.heister@gmail.com>
Thu, 19 Sep 2013 14:58:19 +0000 (14:58 +0000)
git-svn-id: https://svn.dealii.org/trunk@30828 0785d39b-7218-0410-832d-ea1e28bc413d

tests/mpi/data_out_hdf5_01.cc [new file with mode: 0644]
tests/mpi/data_out_hdf5_01/ncpu_3/cmp/generic [new file with mode: 0644]

diff --git a/tests/mpi/data_out_hdf5_01.cc b/tests/mpi/data_out_hdf5_01.cc
new file mode 100644 (file)
index 0000000..a3c0a1d
--- /dev/null
@@ -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 <deal.II/dofs/dof_handler.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/lac/sparsity_pattern.h>
+#include <deal.II/numerics/data_out.h>
+
+
+std::string output_file_name = "data_out_hdf5_01/output";
+
+
+template <int dim>
+void
+test ()
+{
+  Triangulation<dim> tria;
+  GridGenerator::hyper_cube(tria, 0., 1.);
+  tria.refine_global (1);
+  //  tria.begin_active()->set_refine_flag();
+  //tria.execute_coarsening_and_refinement ();
+
+  FE_Q<dim> fe1(1);
+
+  DoFHandler<dim> dof1(tria);
+  dof1.distribute_dofs(fe1);
+
+  Vector<double> v1(dof1.n_dofs());
+  for (unsigned int i=0; i<v1.size(); ++i) v1(i) = i;
+
+  DataOut<dim> 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<XDMFEntry> 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 (file)
index 0000000..b54e9c2
--- /dev/null
@@ -0,0 +1,35 @@
+
+DEAL:0::ok
+<?xml version="1.0" ?>
+<!DOCTYPE Xdmf SYSTEM "Xdmf.dtd" []>
+<Xdmf Version="2.0">
+  <Domain>
+    <Grid Name="CellTime" GridType="Collection" CollectionType="Temporal">
+      <Grid Name="mesh" GridType="Uniform">
+        <Time Value="0"/>
+        <Geometry GeometryType="XY">
+          <DataItem Dimensions="108 2" NumberType="Float" Precision="8" Format="HDF">
+            out.h5:/nodes
+          </DataItem>
+        </Geometry>
+        <Topology TopologyType="Quadrilateral" NumberOfElements="48">
+          <DataItem Dimensions="48 4" NumberType="UInt" Format="HDF">
+            out.h5:/cells
+          </DataItem>
+        </Topology>
+        <Attribute Name="linear" AttributeType="Scalar" Center="Node">
+          <DataItem Dimensions="108 1" NumberType="Float" Precision="8" Format="HDF">
+            out.h5:/linear
+          </DataItem>
+        </Attribute>
+      </Grid>
+    </Grid>
+  </Domain>
+</Xdmf>
+
+
+DEAL:1::ok
+
+
+DEAL:2::ok
+

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.