]> https://gitweb.dealii.org/ - dealii.git/commitdiff
test for DataOutBase; DX output must be checked later
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Thu, 8 May 2003 10:40:18 +0000 (10:40 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Thu, 8 May 2003 10:40:18 +0000 (10:40 +0000)
git-svn-id: https://svn.dealii.org/trunk@7605 0785d39b-7218-0410-832d-ea1e28bc413d

tests/base/Makefile
tests/base/data_out_base.cc [new file with mode: 0644]

index dc044d762737ad62017436d958e6bfb9bdc5ede4..23becf9f8c4083bc0190619ce789d9d73a3a040d 100644 (file)
@@ -24,25 +24,25 @@ threads.cc : threads.pl
        @echo =====regenerating== $@
        @$(PERL) $^ > $@
 
+data_out_base.exe  : data_out_base.g.$(OBJEXT)                      $(lib-base.g)
 logtest.exe        : logtest.g.$(OBJEXT)                            $(lib-base.g)
 polynomial_test.exe: polynomial_test.g.$(OBJEXT) abort.g.$(OBJEXT)  $(lib-base.g)
 polynomial1d.exe   : polynomial1d.g.$(OBJEXT)                       $(lib-base.g)
-quadrature_test.exe: quadrature_test.g.$(OBJEXT)                    $(libraries)
-reference.exe      : reference.g.$(OBJEXT) abort.g.$(OBJEXT)        $(libraries)
-table.exe          : table.g.$(OBJEXT)                              $(libraries)
-tensor.exe         : tensor.g.$(OBJEXT)                             $(libraries)
-timer.exe          : timer.g.$(OBJEXT)                              $(libraries)
-threads.exe        : threads.g.$(OBJEXT)                            $(libraries)
+quadrature_test.exe: quadrature_test.g.$(OBJEXT)                    $(lib-base.g)
+reference.exe      : reference.g.$(OBJEXT) abort.g.$(OBJEXT)        $(lib-base.g)
+table.exe          : table.g.$(OBJEXT)                              $(lib-base.g)
+tensor.exe         : tensor.g.$(OBJEXT)                             $(lib-base.g)
+timer.exe          : timer.g.$(OBJEXT)                              $(lib-base.g)
+threads.exe        : threads.g.$(OBJEXT)                            $(lib-base.g)
 auto_derivative_function.exe : auto_derivative_function.g.$(OBJEXT) $(libraries)
 anisotropic_1.exe  : anisotropic_1.g.$(OBJEXT)                      $(lib-base.g)
 anisotropic_2.exe  : anisotropic_2.g.$(OBJEXT)                      $(lib-base.g)
 hierarchical.exe   : hierarchical.g.$(OBJEXT)                       $(lib-base.g)
 
-tests = $(sort \
-          logtest reference quadrature_test table tensor \
+tests =  logtest reference quadrature_test table tensor \
           timer threads polynomial1d polynomial_test \
          auto_derivative_function anisotropic_1 anisotropic_2 \
-          hierarchical)
+          hierarchical data_out_base
 
 ############################################################
 
diff --git a/tests/base/data_out_base.cc b/tests/base/data_out_base.cc
new file mode 100644 (file)
index 0000000..3e92964
--- /dev/null
@@ -0,0 +1,186 @@
+//-----------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2000, 2001, 2002, 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.
+//
+//-----------------------------------------------------------------------------
+
+#include <base/data_out_base.h>
+#include <base/logstream.h>
+
+#include <vector>
+#include <iostream>
+#include <fstream>
+#include <string>
+
+#define WRITE(type) DataOutBase::write_ ## type (patches, names, type ## flags, out)
+
+template <int dim, int spacedim>
+void
+write_patches(const std::vector<DataOutBase::Patch<dim,spacedim> >& patches,
+             std::ostream& out)
+{
+  std::vector<std::string> names(2);
+  names[0] = std::string("first name");
+  names[1] = std::string("last name");
+
+  DataOutBase::DXFlags dxflags;
+//    DataOutBase::EpsFlags epsflags;
+//    DataOutBase::GnuplotFlags gnuplotflags;
+//    DataOutBase::GmvFlags gmvflags;
+//    DataOutBase::PovrayFlags povrayflags;
+//    DataOutBase::UcdFlags ucdflags;
+//    DataOutBase::VtkFlags vtkflags;
+  
+  WRITE(dx);
+  
+}
+
+template<int dim>
+struct PatchInfo
+{
+    static double vertices[GeometryInfo<dim>::vertices_per_cell][3];
+    static double offsets[GeometryInfo<dim>::vertices_per_cell][3];
+    static int neighbors[GeometryInfo<dim>::vertices_per_cell][GeometryInfo<dim>::faces_per_cell];
+};
+
+
+double PatchInfo<1>::vertices[2][3]
+= {{0, 0, 0}
+  ,{3, 6, 9}
+};
+
+double PatchInfo<2>::vertices[4][3]
+= {{0, 0, 0}
+  ,{3, 0, 3}
+  ,{3, 3, 6}
+  ,{3, 0, 3}
+};
+
+
+double PatchInfo<3>::vertices[8][3]
+= {{0, 0, 0}
+  ,{3, 0, 0}
+  ,{3, 3, 0}
+  ,{0, 3, 0}
+  ,{0, 0, 3}
+  ,{3, 0, 3}
+  ,{3, 3, 3}
+  ,{0, 3, 3}
+};
+
+
+int PatchInfo<1>::neighbors[2][2]
+= {{-1,  1}
+  ,{ 0, -1}
+};
+
+
+
+int PatchInfo<2>::neighbors[4][4]
+= {{-1,  1,  2, -1}
+  ,{-1, -1,  3,  0}
+  ,{ 0,  3, -1, -1}
+  ,{ 1, -1, -1,  2}  
+};
+
+
+
+int PatchInfo<3>::neighbors[8][6]
+= {{-1, -1, -1, -1, -1, -1}
+  ,{-1, -1, -1, -1, -1, -1}
+  ,{-1, -1, -1, -1, -1, -1}
+  ,{-1, -1, -1, -1, -1, -1}
+  ,{-1, -1, -1, -1, -1, -1}
+  ,{-1, -1, -1, -1, -1, -1}
+  ,{-1, -1, -1, -1, -1, -1}
+  ,{-1, -1, -1, -1, -1, -1}  
+};
+
+
+double PatchInfo<1>::offsets[2][3]
+= {{ 0, 0, 0}
+  ,{ 3, 0, 0}
+};
+
+
+double PatchInfo<2>::offsets[4][3]
+= {{ 0, 0, 0}
+  ,{ 3, 0, 0}
+  ,{ 0, 3, 0}
+  ,{ 3, 3, 0}
+};
+
+
+double PatchInfo<3>::offsets[8][3]
+= {{ 0, 0, 0}
+  ,{ 3, 0, 0}
+  ,{ 0, 3, 0}
+  ,{ 3, 3, 0}
+  ,{ 0, 0, 3}
+  ,{ 3, 0, 3}
+  ,{ 0, 3, 3}
+  ,{ 3, 3, 3}
+};
+
+
+
+template <int dim, int spacedim>
+void
+create_patches(std::vector<DataOutBase::Patch<dim,spacedim> >& patches)
+{
+  const unsigned int ncells = GeometryInfo<dim>::vertices_per_cell;
+  const unsigned int nsub = 3;
+  
+  patches.resize(ncells);
+
+  for (unsigned int c = 0; c < ncells;++c)
+    {
+      DataOutBase::Patch<dim, spacedim>& p = patches[c];
+      p.patch_index = c;
+      p.n_subdivisions = nsub;
+
+      for (unsigned int i=0;i<ncells;++i)
+       for (unsigned int j=0;j<spacedim;++j)
+         p.vertices[i](j) = PatchInfo<dim>::vertices[i][j]
+                            + PatchInfo<dim>::offsets[c][j];
+
+      for (unsigned int i=0;i<GeometryInfo<dim>::faces_per_cell;++i)
+       p.neighbors[i] = (unsigned int) PatchInfo<dim>::neighbors[c][i];
+
+      unsigned int ndata = 1;
+      for (unsigned int i=0;i<dim;++i)
+       ndata *= nsub+1;
+
+      p.data.reinit(2,ndata);
+      for (unsigned int i=0;i<ndata;++i)
+       {
+         p.data(0,i) = i;
+         p.data(1,i) = -(float) i;
+       }
+    }
+}
+
+
+int main()
+{
+  std::ofstream logfile("data_out_base.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  std::vector<DataOutBase::Patch<1,1> > patch11;
+  std::vector<DataOutBase::Patch<1,2> > patch12;
+  std::vector<DataOutBase::Patch<1,3> > patch13;
+  std::vector<DataOutBase::Patch<2,2> > patch22;
+  std::vector<DataOutBase::Patch<2,3> > patch23;
+  std::vector<DataOutBase::Patch<3,3> > patch33;
+
+  create_patches(patch33);
+  write_patches(patch33, logfile);
+}

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.