]> https://gitweb.dealii.org/ - dealii.git/commitdiff
GridGenerator checked all grids in 2D, including color
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Mon, 14 Mar 2005 22:50:32 +0000 (22:50 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Mon, 14 Mar 2005 22:50:32 +0000 (22:50 +0000)
git-svn-id: https://svn.dealii.org/trunk@10136 0785d39b-7218-0410-832d-ea1e28bc413d

tests/bits/Makefile
tests/bits/grid_generator_01.cc [new file with mode: 0644]

index ba02314110a55b15b2328baee1e8f320ab38bf3d..a83fc1d5715a07f47dac4159e67281eca4e77d2b 100644 (file)
@@ -1,4 +1,3 @@
-# Generated automatically from Makefile.in by configure.
 ############################################################
 # Makefile,v 1.15 2002/06/13 12:51:13 hartmann Exp
 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 by the deal.II authors
@@ -22,9 +21,9 @@ default: run-tests
 
 ############################################################
 
-tests_x = anna_? \
-         gerold_1 \
-         geometry_info_1 \
+tests_x = geometry_info_1 \
+         grid_generator_?? \
+         grid_in_* \
          point_inside_? \
          full_matrix_1 \
          block_matrix_array_* \
@@ -34,6 +33,8 @@ tests_x = anna_? \
          data_out_stack_0* \
          dof_tools_[0-9]* \
          fe_tools_[0-9]* \
+          anna_? \
+         gerold_1 \
          roy_1 \
           denis_1 \
          unit_support_points \
@@ -61,7 +62,6 @@ tests_x = anna_? \
          apply_boundary_values_* \
          error_estimator_* \
          cylinder_shell_* \
-         grid_in_* \
          compressed_sparsity_pattern_* \
          point_difference_* \
          umfpack_* \
diff --git a/tests/bits/grid_generator_01.cc b/tests/bits/grid_generator_01.cc
new file mode 100644 (file)
index 0000000..b7a812b
--- /dev/null
@@ -0,0 +1,163 @@
+//---------------------------------------------------------------------------
+//    $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.
+//
+//---------------------------------------------------------------------------
+
+
+// Test the various functions in grid generator.
+
+#include <base/logstream.h>
+#include <base/tensor.h>
+#include <grid/tria.h>
+#include <grid/grid_generator.h>
+#include <grid/grid_out.h>
+
+#include <fstream>
+#include <iostream>
+
+
+template<int dim>
+void test(std::ostream& out)
+{
+  Point<dim> p1;
+  p1[0] = 2.;
+  if (dim>1) p1[1] = -1.;
+  if (dim>2) p1[2] = 0.;
+  Point<dim> p2;
+  p2[0] = 3.;
+  if (dim>1) p2[1] = 2.;
+  if (dim>2) p2[2] = 4.;
+  Point<dim> p3;
+  p3[0] = 2.;
+  if (dim>1) p3[1] = 1.;
+  if (dim>2) p3[2] = 4.;
+  
+  GridOut go;
+  GridOutFlags::XFig xfig_flags;
+  xfig_flags.level_color = false;
+  xfig_flags.fill_style = 25;
+  
+  go.set_flags(xfig_flags);
+  
+  GridOut::OutputFormat format = (dim==2) ? GridOut::xfig : GridOut::dx;
+  
+  if (true)
+    {
+      deallog << "hyper_cube" << std::endl;
+      Triangulation<dim> tr;
+      GridGenerator::hyper_cube(tr, 3., 7.);
+      go.write(tr, out, format);
+    }
+  if (true)
+    {
+      deallog << "subdivided_hyper_cube" << std::endl;
+      Triangulation<dim> tr;
+      GridGenerator::subdivided_hyper_cube(tr, 3, 1., 7.);
+      go.write(tr, out, format);
+    }
+  if (true)
+    {
+      deallog << "hyper_rectangle" << std::endl;
+      Triangulation<dim> tr;
+      GridGenerator::hyper_rectangle(tr, p1, p2, true);
+      go.write(tr, out, format);
+    }
+  if (true)
+    {
+      deallog << "subdivided_hyper_rectangle" << std::endl;
+      Triangulation<dim> tr;
+      std::vector<unsigned int> sub(dim);
+      sub[0] = 2;
+      if (dim>1) sub[1] = 3;
+      if (dim>2) sub[2] = 4;
+      GridGenerator::subdivided_hyper_rectangle(tr, sub, p1, p2, true);
+      go.write(tr, out, format);
+    }
+  if (dim == 2)
+    {
+      deallog << "parallelogram" << std::endl;
+      Triangulation<dim> tr;
+      Tensor<dim,2> corners;
+      corners[0] = p1;
+      if (dim>1) corners[1] = p2;
+      if (dim>2) corners[2] = p3;
+      GridGenerator::parallelogram(tr, corners, true);
+      go.write(tr, out, format);
+    }
+  if (dim>1)
+    {
+      deallog << "enclosed_hyper_cube" << std::endl;
+      Triangulation<dim> tr;
+      GridGenerator::enclosed_hyper_cube(tr, 3., 7., 1., true);
+      go.write(tr, out, format);
+    }
+  if (true)
+    {
+      deallog << "hyper_ball" << std::endl;
+      Triangulation<dim> tr;
+      GridGenerator::hyper_ball(tr, p1, 3.);
+      go.write(tr, out, format);
+    }  
+  if (true)
+    {
+      deallog << "cylinder" << std::endl;
+      Triangulation<dim> tr;
+      GridGenerator::cylinder(tr, 1., 3.);
+      go.write(tr, out, format);
+    }  
+  if (true)
+    {
+      deallog << "hyper_L" << std::endl;
+      Triangulation<dim> tr;
+      GridGenerator::hyper_L(tr, -1., 1.);
+      go.write(tr, out, format);
+    }  
+  if (true)
+    {
+      deallog << "hyper_cube_slit" << std::endl;
+      Triangulation<dim> tr;
+      GridGenerator::hyper_cube_slit(tr, -2., 2., true);
+      go.write(tr, out, format);
+    }  
+  if (true)
+    {
+      deallog << "hyper_shell" << std::endl;
+      Triangulation<dim> tr;
+      GridGenerator::hyper_shell(tr, p1, 4., 6.);
+      go.write(tr, out, format);
+    }  
+  if (true)
+    {
+      deallog << "half_hyper_ball" << std::endl;
+      Triangulation<dim> tr;
+      GridGenerator::half_hyper_ball(tr, p1, 3.);
+      go.write(tr, out, format);
+    }  
+  if (true)
+    {
+      deallog << "half_hyper_shell" << std::endl;
+      Triangulation<dim> tr;
+      GridGenerator::half_hyper_shell(tr, p1, 4., 6.);
+      go.write(tr, out, format);
+    }  
+}
+
+
+int main()
+{
+  std::ofstream logfile("grid_generator_01.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  
+  deallog.push("2d-GridTest");
+  test<2>(logfile);
+  deallog.pop();
+}

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.