From 50560bf6496511a41e3d3cdbf5e3a5f4e9d08968 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 5 Apr 2005 20:53:47 +0000 Subject: [PATCH] Add more tests. git-svn-id: https://svn.dealii.org/trunk@10362 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/bits/data_out_03.cc | 100 +++++++++++++++++++++++++ tests/bits/data_out_faces_03.cc | 112 ++++++++++++++++++++++++++++ tests/bits/data_out_rotation_03.cc | 113 +++++++++++++++++++++++++++++ 3 files changed, 325 insertions(+) create mode 100644 tests/bits/data_out_03.cc create mode 100644 tests/bits/data_out_faces_03.cc create mode 100644 tests/bits/data_out_rotation_03.cc diff --git a/tests/bits/data_out_03.cc b/tests/bits/data_out_03.cc new file mode 100644 index 0000000000..b6fa5b850b --- /dev/null +++ b/tests/bits/data_out_03.cc @@ -0,0 +1,100 @@ +//---------------------------- data_out_03.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2003, 2004 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//---------------------------- data_out_03.cc --------------------------- + + +// write the data in deal.II intermediate form, read it back in, and +// make sure that the result is the same + +#include "../tests.h" +#include "data_out_common.cc" +#include +#include + + +std::string output_file_name = "data_out_03.output"; + + +// have a class that makes sure we can get at the patches and data set +// names that the base class generates +template +class XDataOut : public DataOut +{ + public: + const std::vector > & + get_patches() const + { return DataOut::get_patches(); } + + std::vector + get_dataset_names () const + { return DataOut::get_dataset_names(); } +}; + +// have a class that makes sure we can get at the patches and data set +// names that the base class generates +template +class XDataOutReader : public DataOutReader +{ + public: + const std::vector > & + get_patches() const + { return DataOutReader::get_patches(); } + + std::vector + get_dataset_names () const + { return DataOutReader::get_dataset_names(); } +}; + + +template +void +check_this (const DoFHandler &dof_handler, + const Vector &v_node, + const Vector &v_cell) +{ + XDataOut data_out; + data_out.attach_dof_handler (dof_handler); + data_out.add_data_vector (v_node, "node_data"); + data_out.add_data_vector (v_cell, "cell_data"); + data_out.build_patches (); + + { + std::ofstream tmp ("data_out_03.tmp"); + data_out.write_deal_II_intermediate (tmp); + } + + XDataOutReader reader; + { + std::ifstream tmp ("data_out_03.tmp"); + reader.read (tmp); + } + + // finally make sure that we have + // read everything back in + // correctly + Assert (data_out.get_dataset_names() == reader.get_dataset_names(), + ExcInternalError()); + + Assert (data_out.get_patches().size() == reader.get_patches().size(), + ExcInternalError()); + + for (unsigned int i=0; i +#include + + +std::string output_file_name = "data_out_faces_03.output"; + + +// have a class that makes sure we can get at the patches and data set +// names that the base class generates +template +class XDataOut : public DataOutFaces +{ + public: + const std::vector > & + get_patches() const + { return DataOutFaces::get_patches(); } + + std::vector + get_dataset_names () const + { return DataOutFaces::get_dataset_names(); } +}; + +// have a class that makes sure we can get at the patches and data set +// names that the base class generates +template +class XDataOutReader : public DataOutReader +{ + public: + const std::vector > & + get_patches() const + { return DataOutReader::get_patches(); } + + std::vector + get_dataset_names () const + { return DataOutReader::get_dataset_names(); } +}; + + + +void +check_this (const DoFHandler<1> &, + const Vector &, + const Vector &) +{ + // don't check in 1d +} + + + + +template +void +check_this (const DoFHandler &dof_handler, + const Vector &v_node, + const Vector &v_cell) +{ + XDataOut data_out; + data_out.attach_dof_handler (dof_handler); + data_out.add_data_vector (v_node, "node_data"); + data_out.add_data_vector (v_cell, "cell_data"); + data_out.build_patches (); + + { + std::ofstream tmp ("data_out_faces_03.tmp"); + data_out.write_deal_II_intermediate (tmp); + } + + XDataOutReader reader; + { + std::ifstream tmp ("data_out_faces_03.tmp"); + reader.read (tmp); + } + + // finally make sure that we have + // read everything back in + // correctly + Assert (data_out.get_dataset_names() == reader.get_dataset_names(), + ExcInternalError()); + + Assert (data_out.get_patches().size() == reader.get_patches().size(), + ExcInternalError()); + + for (unsigned int i=0; i +#include + + +std::string output_file_name = "data_out_rotation_03.output"; + + +// have a class that makes sure we can get at the patches and data set +// names that the base class generates +template +class XDataOut : public DataOutRotation +{ + public: + const std::vector > & + get_patches() const + { return DataOutRotation::get_patches(); } + + std::vector + get_dataset_names () const + { return DataOutRotation::get_dataset_names(); } +}; + +// have a class that makes sure we can get at the patches and data set +// names that the base class generates +template +class XDataOutReader : public DataOutReader +{ + public: + const std::vector > & + get_patches() const + { return DataOutReader::get_patches(); } + + std::vector + get_dataset_names () const + { return DataOutReader::get_dataset_names(); } +}; + + +void +check_this (const DoFHandler<3> &, + const Vector &, + const Vector &) +{ + // no checks in 3d +} + + + +template +void +check_this (const DoFHandler &dof_handler, + const Vector &v_node, + const Vector &v_cell) +{ + XDataOut data_out; + data_out.attach_dof_handler (dof_handler); + data_out.add_data_vector (v_node, "node_data"); + data_out.add_data_vector (v_cell, "cell_data"); + data_out.build_patches (4); + + { + std::ofstream tmp ("data_out_rotation_03.tmp"); + // use full precision to avoid + // errors + tmp.precision (20); + data_out.write_deal_II_intermediate (tmp); + } + + XDataOutReader reader; + { + std::ifstream tmp ("data_out_rotation_03.tmp"); + reader.read (tmp); + } + + // finally make sure that we have + // read everything back in + // correctly + Assert (data_out.get_dataset_names() == reader.get_dataset_names(), + ExcInternalError()); + + Assert (data_out.get_patches().size() == reader.get_patches().size(), + ExcInternalError()); + + for (unsigned int i=0; i