]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add some tests.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 25 Feb 2003 00:22:03 +0000 (00:22 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 25 Feb 2003 00:22:03 +0000 (00:22 +0000)
git-svn-id: https://svn.dealii.org/trunk@7238 0785d39b-7218-0410-832d-ea1e28bc413d

tests/bits/Makefile
tests/bits/data_out_01.cc [new file with mode: 0644]
tests/bits/data_out_common.cc [new file with mode: 0644]
tests/bits/data_out_faces_01.cc [new file with mode: 0644]

index 512ff116664d1d8f203453995dc03b5c89d5cfb1..337e77d66017a026755d47cc2e87f1813efae1cb 100644 (file)
@@ -28,6 +28,8 @@ anna_3.exe              : anna_3.g.$(OBJEXT)              $(libraries)
 anna_4.exe              : anna_4.g.$(OBJEXT)              $(libraries)
 anna_5.exe              : anna_5.g.$(OBJEXT)              $(libraries)
 anna_6.exe              : anna_6.g.$(OBJEXT)              $(libraries)
+data_out_01.exe         : data_out_01.g.$(OBJEXT)         $(libraries)
+data_out_faces_01.exe   : data_out_faces_01.g.$(OBJEXT)   $(libraries)
 dof_tools_01a.exe       : dof_tools_01a.g.$(OBJEXT)       $(libraries)
 dof_tools_01b.exe       : dof_tools_01b.g.$(OBJEXT)       $(libraries)
 dof_tools_01c.exe       : dof_tools_01c.g.$(OBJEXT)       $(libraries)
@@ -81,6 +83,7 @@ unit_support_points.exe : unit_support_points.g.$(OBJEXT) $(libraries)
 parameter_handler_1.exe : parameter_handler_1.g.$(OBJEXT) $(libraries)
 
 tests = anna_1 anna_2 anna_3 anna_4 anna_5 anna_6 \
+       data_out_01 data_out_faces_01 \
         dof_tools_01a dof_tools_01b dof_tools_01c dof_tools_01d \
         dof_tools_02a dof_tools_02b dof_tools_02c dof_tools_02d \
        dof_tools_03 dof_tools_04 dof_tools_05 dof_tools_06 \
diff --git a/tests/bits/data_out_01.cc b/tests/bits/data_out_01.cc
new file mode 100644 (file)
index 0000000..f33ea6f
--- /dev/null
@@ -0,0 +1,49 @@
+//----------------------------  data_out_01.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2003 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_01.cc  ---------------------------
+
+#include "data_out_common.cc"
+#include <lac/sparsity_pattern.h>
+#include <numerics/data_out.h>
+
+
+std::string output_file_name = "data_out_01.output";
+
+
+template <int dim>
+void
+check_this (const DoFHandler<dim> &dof_handler,
+            const Vector<double>  &v_node,
+            const Vector<double>  &v_cell)
+{
+  DataOut<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 ();
+  
+  data_out.write_dx (deallog.get_file_stream());
+  data_out.write_ucd (deallog.get_file_stream());  
+  data_out.write_gmv (deallog.get_file_stream());
+  data_out.write_tecplot (deallog.get_file_stream());
+  data_out.write_vtk (deallog.get_file_stream());
+
+                                   // the following is only
+                                   // implemented for 2d
+  if (dim == 2)
+    {
+      data_out.write_povray (deallog.get_file_stream());
+      data_out.write_eps (deallog.get_file_stream());
+    }  
+}
+
+
diff --git a/tests/bits/data_out_common.cc b/tests/bits/data_out_common.cc
new file mode 100644 (file)
index 0000000..35b2cce
--- /dev/null
@@ -0,0 +1,144 @@
+//----------------------------  dof_tools_common.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2003 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.
+//
+//----------------------------  dof_tools_common.cc  ---------------------------
+
+
+// common framework for the various dof_tools_*.cc tests
+
+#include <base/logstream.h>
+#include <lac/vector.h>
+#include <grid/tria.h>
+#include <grid/tria_iterator.h>
+#include <grid/grid_generator.h>
+#include <dofs/dof_accessor.h>
+#include <dofs/dof_handler.h>
+#include <dofs/dof_tools.h>
+#include <fe/fe_q.h>
+#include <fe/fe_dgq.h>
+#include <fe/fe_dgp.h>
+#include <fe/fe_nedelec.h>
+#include <fe/fe_system.h>
+
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <string>
+
+
+// forward declaration of the function that must be provided in the
+// .cc files
+template <int dim>
+void
+check_this (const DoFHandler<dim> &dof_handler,
+            const Vector<double>  &v_node,
+            const Vector<double>  &v_cell);
+
+// forward declaration of a variable with the name of the output file
+extern std::string output_file_name;
+
+  
+
+
+template <int dim>
+void
+check (const FiniteElement<dim> &fe,
+       const std::string        &name)
+{
+  deallog << "Checking " << name
+          << " in " << dim << "d:"
+          << std::endl;
+  
+                                   // create tria and dofhandler
+                                   // objects. set different boundary
+                                   // and sub-domain ids
+  Triangulation<dim> tria;
+  GridGenerator::hyper_cube(tria, 0., 1.);
+  tria.refine_global (1);
+  tria.begin_active()->set_refine_flag();
+  tria.execute_coarsening_and_refinement ();
+
+  DoFHandler<dim> dof_handler (tria);
+  dof_handler.distribute_dofs (fe);
+
+  Vector<double> v_node (dof_handler.n_dofs());
+  for (unsigned int i=0; i<v_node.size(); ++i) v_node(i) = i;
+
+  Vector<double> v_cell (dof_handler.get_tria().n_active_cells());
+  for (unsigned int i=0; i<v_node.size(); ++i) v_node(i) = i;
+  
+                                   // call main function in .cc files
+  check_this (dof_handler, v_node, v_cell);
+}
+
+
+
+
+
+#define CHECK(EL,deg,dim)\
+ { FE_ ## EL<dim> EL(deg);   \
+   check(EL, #EL #deg); }
+
+#define CHECK_ALL(EL,deg)\
+ { CHECK(EL,deg,1); \
+   CHECK(EL,deg,2); \
+   CHECK(EL,deg,3); \
+ }
+
+
+int
+main()
+{
+  try
+    {
+      std::ofstream logfile(output_file_name.c_str());
+      logfile.precision (2);
+      deallog.attach(logfile);
+      deallog.depth_console(0);
+
+      CHECK_ALL(Q,1);
+      CHECK_ALL(Q,2);
+      CHECK_ALL(Q,3);
+
+      CHECK_ALL(DGQ,0);
+      CHECK_ALL(DGQ,1);
+      CHECK_ALL(DGQ,2);
+
+      CHECK(Nedelec, 1, 2);
+      CHECK(Nedelec, 1, 3);
+  
+      return 0;
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+               << exc.what() << std::endl
+               << "Aborting!" << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      return 1;
+    }
+  catch (...) 
+    {
+      std::cerr << std::endl << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+               << "Aborting!" << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      return 1;
+    };
+}
+
diff --git a/tests/bits/data_out_faces_01.cc b/tests/bits/data_out_faces_01.cc
new file mode 100644 (file)
index 0000000..8f4a224
--- /dev/null
@@ -0,0 +1,59 @@
+//----------------------------  data_out_faces_01.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2003 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_01.cc  ---------------------------
+
+#include "data_out_common.cc"
+#include <lac/sparsity_pattern.h>
+#include <numerics/data_out_faces.h>
+
+
+std::string output_file_name = "data_out_faces_01.output";
+
+
+
+void
+check_this (const DoFHandler<1>   &dof_handler,
+            const Vector<double>  &v_node,
+            const Vector<double>  &v_cell)
+{
+                                   // nothing to check in 1d
+}
+
+
+template <int dim>
+void
+check_this (const DoFHandler<dim> &dof_handler,
+            const Vector<double>  &v_node,
+            const Vector<double>  &v_cell)
+{
+  DataOutFaces<dim> data_out_faces;
+  data_out_faces.attach_dof_handler (dof_handler);
+  data_out_faces.add_data_vector (v_node, "node_data");
+  data_out_faces.add_data_vector (v_cell, "cell_data");
+  data_out_faces.build_patches ();
+  
+  data_out_faces.write_dx (deallog.get_file_stream());
+  data_out_faces.write_ucd (deallog.get_file_stream());  
+  data_out_faces.write_gmv (deallog.get_file_stream());
+  data_out_faces.write_tecplot (deallog.get_file_stream());
+  data_out_faces.write_vtk (deallog.get_file_stream());
+
+                                   // the following is only
+                                   // implemented for 2d
+  if (dim == 2)
+    {
+      data_out_faces.write_povray (deallog.get_file_stream());
+      data_out_faces.write_eps (deallog.get_file_stream());
+    }  
+}
+
+

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.