]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add more tests.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 5 Apr 2005 20:53:47 +0000 (20:53 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 5 Apr 2005 20:53:47 +0000 (20:53 +0000)
git-svn-id: https://svn.dealii.org/trunk@10362 0785d39b-7218-0410-832d-ea1e28bc413d

tests/bits/data_out_03.cc [new file with mode: 0644]
tests/bits/data_out_faces_03.cc [new file with mode: 0644]
tests/bits/data_out_rotation_03.cc [new file with mode: 0644]

diff --git a/tests/bits/data_out_03.cc b/tests/bits/data_out_03.cc
new file mode 100644 (file)
index 0000000..b6fa5b8
--- /dev/null
@@ -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 <lac/sparsity_pattern.h>
+#include <numerics/data_out.h>
+
+
+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 <int dim>
+class XDataOut : public DataOut<dim>
+{
+  public:
+    const std::vector<typename DataOutBase::Patch<dim,dim> > &
+    get_patches() const
+      { return DataOut<dim>::get_patches(); }
+
+    std::vector<std::string>
+    get_dataset_names () const    
+      { return DataOut<dim>::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 <int dim>
+class XDataOutReader : public DataOutReader<dim>
+{
+  public:
+    const std::vector<typename DataOutBase::Patch<dim,dim> > &
+    get_patches() const
+      { return DataOutReader<dim>::get_patches(); }
+
+    std::vector<std::string>
+    get_dataset_names () const    
+      { return DataOutReader<dim>::get_dataset_names();  }
+};
+
+
+template <int dim>
+void
+check_this (const DoFHandler<dim> &dof_handler,
+            const Vector<double>  &v_node,
+            const Vector<double>  &v_cell)
+{
+  XDataOut<dim> 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<dim> 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<reader.get_patches().size(); ++i)
+    Assert (data_out.get_patches()[i] == reader.get_patches()[i],
+           ExcInternalError());
+
+                                  // for good measure, delete tmp file
+  remove ("data_out_03.tmp");
+  
+  deallog << "OK" << std::endl;
+}
+
+
diff --git a/tests/bits/data_out_faces_03.cc b/tests/bits/data_out_faces_03.cc
new file mode 100644 (file)
index 0000000..87818d3
--- /dev/null
@@ -0,0 +1,112 @@
+//----------------------------  data_out_faces_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_faces_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 <lac/sparsity_pattern.h>
+#include <numerics/data_out_faces.h>
+
+
+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 <int dim>
+class XDataOut : public DataOutFaces<dim>
+{
+  public:
+    const std::vector<typename DataOutBase::Patch<dim-1,dim> > &
+    get_patches() const
+      { return DataOutFaces<dim>::get_patches(); }
+
+    std::vector<std::string>
+    get_dataset_names () const    
+      { return DataOutFaces<dim>::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 <int dim>
+class XDataOutReader : public DataOutReader<dim-1,dim>
+{
+  public:
+    const std::vector<typename DataOutBase::Patch<dim-1,dim> > &
+    get_patches() const
+      { return DataOutReader<dim-1,dim>::get_patches(); }
+
+    std::vector<std::string>
+    get_dataset_names () const    
+      { return DataOutReader<dim-1,dim>::get_dataset_names();  }
+};
+
+
+
+void
+check_this (const DoFHandler<1> &,
+            const Vector<double>  &,
+            const Vector<double>  &)
+{
+                                  // don't check in 1d
+}
+
+
+
+
+template <int dim>
+void
+check_this (const DoFHandler<dim> &dof_handler,
+            const Vector<double>  &v_node,
+            const Vector<double>  &v_cell)
+{
+  XDataOut<dim> 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<dim> 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<reader.get_patches().size(); ++i)
+    Assert (data_out.get_patches()[i] == reader.get_patches()[i],
+           ExcInternalError());
+
+                                  // for good measure, delete tmp file
+  remove ("data_out_faces_03.tmp");
+  
+  deallog << "OK" << std::endl;
+}
+
+
diff --git a/tests/bits/data_out_rotation_03.cc b/tests/bits/data_out_rotation_03.cc
new file mode 100644 (file)
index 0000000..6ec6e15
--- /dev/null
@@ -0,0 +1,113 @@
+//----------------------------  data_out_rotation_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_rotation_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 <lac/sparsity_pattern.h>
+#include <numerics/data_out_rotation.h>
+
+
+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 <int dim>
+class XDataOut : public DataOutRotation<dim>
+{
+  public:
+    const std::vector<typename DataOutBase::Patch<dim+1,dim+1> > &
+    get_patches() const
+      { return DataOutRotation<dim>::get_patches(); }
+
+    std::vector<std::string>
+    get_dataset_names () const    
+      { return DataOutRotation<dim>::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 <int dim>
+class XDataOutReader : public DataOutReader<dim+1>
+{
+  public:
+    const std::vector<typename DataOutBase::Patch<dim+1,dim+1> > &
+    get_patches() const
+      { return DataOutReader<dim+1>::get_patches(); }
+
+    std::vector<std::string>
+    get_dataset_names () const    
+      { return DataOutReader<dim+1>::get_dataset_names();  }
+};
+
+
+void
+check_this (const DoFHandler<3> &,
+            const Vector<double>  &,
+            const Vector<double>  &)
+{
+                                  // no checks in 3d
+}
+
+
+
+template <int dim>
+void
+check_this (const DoFHandler<dim> &dof_handler,
+            const Vector<double>  &v_node,
+            const Vector<double>  &v_cell)
+{
+  XDataOut<dim> 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<dim> 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<reader.get_patches().size(); ++i)
+    Assert (data_out.get_patches()[i] == reader.get_patches()[i],
+           ExcInternalError());
+
+                                  // for good measure, delete tmp file
+  remove ("data_out_rotation_03.tmp");
+  
+  deallog << "OK" << std::endl;
+}
+
+

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.