]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Test SubCellData and create_triangulation.
authorRalf Hartmann <Ralf.Hartmann@dlr.de>
Tue, 9 Aug 2005 14:30:09 +0000 (14:30 +0000)
committerRalf Hartmann <Ralf.Hartmann@dlr.de>
Tue, 9 Aug 2005 14:30:09 +0000 (14:30 +0000)
git-svn-id: https://svn.dealii.org/trunk@11258 0785d39b-7218-0410-832d-ea1e28bc413d

tests/deal.II/subcelldata.cc [new file with mode: 0644]

diff --git a/tests/deal.II/subcelldata.cc b/tests/deal.II/subcelldata.cc
new file mode 100644 (file)
index 0000000..e0c5e5d
--- /dev/null
@@ -0,0 +1,109 @@
+//----------------------------  subcelldata.cc  ---------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2005 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.
+//
+//----------------------------  subcelldata.cc  ---------------------------
+
+
+#include "../tests.h"
+#include <grid/tria.h>
+#include <grid/grid_out.h>
+#include <grid/tria_iterator.h>
+#include <grid/tria_accessor.h>
+
+#include <fstream>
+
+
+template <int dim>
+void test()
+{
+  Assert(dim==2 || dim==3, ExcNotImplemented());
+  
+  std::vector<Point<dim> > vertices (GeometryInfo<dim>::vertices_per_cell);
+  vertices[0](0)=0;
+  vertices[0](1)=0;
+  vertices[1](0)=2;
+  vertices[1](1)=1;
+  vertices[2](0)=3;
+  vertices[2](1)=3;
+  vertices[3](0)=0;
+  vertices[3](1)=1;
+  if (dim==3)
+    {
+                                  // for the new numbering
+//       for (unsigned int i=0; i<4; ++i)
+//     {
+//       vertices[i+4]=vertices[i];
+//       vertices[i+4](2)=1;
+//     }
+                                      // for the old numbering
+      for (unsigned int i=0; i<4; ++i)
+       {
+         std::swap(vertices[i](1),vertices[i](2));
+         vertices[i+4]=vertices[i];
+         vertices[i+4](1)=1;
+       }
+      
+    }
+
+  std::vector<CellData<dim> > cells (1);
+  for (unsigned int i=0;i<GeometryInfo<dim>::vertices_per_cell;++i)
+    cells[0].vertices[i] = i;
+  cells[0].material_id = 0;
+
+  SubCellData subcelldata;
+  if (dim==2)
+    {
+      subcelldata.boundary_lines.resize(GeometryInfo<dim>::faces_per_cell);
+      for(unsigned int i=0; i<GeometryInfo<dim>::faces_per_cell; ++i)
+       {
+         subcelldata.boundary_lines[i].vertices[0]=i;
+         subcelldata.boundary_lines[i].vertices[1]=(i+1)%4;
+         subcelldata.boundary_lines[i].material_id=10*i+1;
+       }
+    }
+  else if (dim==3)
+    {
+      subcelldata.boundary_quads.resize(GeometryInfo<dim>::faces_per_cell);
+      for(unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
+       {
+         for(unsigned int i=0; i<GeometryInfo<dim>::vertices_per_face; ++i)
+           subcelldata.boundary_quads[f].vertices[i]=
+             GeometryInfo<dim>::face_to_cell_vertices(f,i);
+         subcelldata.boundary_quads[f].material_id=10*f+1;
+       }
+    }
+
+  Triangulation<dim> tria;
+  tria.create_triangulation (vertices, cells, subcelldata);
+
+  GridOutFlags::Ucd ucd_flags(true,true);
+  GridOut grid_out;
+  grid_out.set_flags(ucd_flags);
+  grid_out.write_ucd(tria, deallog.get_file_stream());
+
+//   std::ofstream gnuplot_file("subcelldata.gnuplot");
+//   grid_out.write_gnuplot(tria, gnuplot_file);
+//   std::ofstream ucd_file("subcelldata.inp");
+//   grid_out.write_ucd(tria, ucd_file);
+}
+
+
+int main ()
+{
+  std::ofstream logfile("subcelldata.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  
+  test<2>();
+  test<3>();
+  
+  return 0;
+}

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.