]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Make this testcase 3d aware. In fact, it is compiled with both libraries at the same...
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 17 Feb 1999 08:41:03 +0000 (08:41 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 17 Feb 1999 08:41:03 +0000 (08:41 +0000)
git-svn-id: https://svn.dealii.org/trunk@824 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/Attic/examples/grid/Makefile
deal.II/deal.II/Attic/examples/grid/grid_test.cc
deal.II/deal.II/Attic/examples/grid/make_ps
deal.II/deal.II/Attic/examples/grid/results/.cvsignore [new file with mode: 0644]
tests/big-tests/grid/Makefile
tests/big-tests/grid/grid_test.cc
tests/big-tests/grid/make_ps
tests/big-tests/grid/results/.cvsignore [new file with mode: 0644]

index d73b1f495be03f8e883de60313b1e5e8adbd5d7a..eb554b6ff2b872d3b5eddf3b1f842e97ceecdadc 100644 (file)
@@ -19,16 +19,16 @@ user-libs =
 
 # To run the program, use "make run"; to give parameters to the program,
 # give the parameters to the following variable:
-run-parameters  = 1
+run-parameters  = 1
 
 # To execute additional action apart from running the program, fill
 # in this list:
-additional-run-action = grid_test 2 ; grid_test 3 ; grid_test 4 ; gnuplot make_ps
+additional-run-action = grid_test 2 2 ; grid_test 2 3 ; grid_test 2 4 ; grid_test 3 1 ; grid_test 3 2 ; grid_test 3 3 ; grid_test 3 4 ; gnuplot make_ps
 
 # To specify which files are to be deleted by "make clean" (apart from
 # the usual ones: object files, executables, backups, etc), fill in the
 # following list
-delete-files = grid.? *.eps
+delete-files = results/[123]d*
 
 
 
@@ -49,8 +49,8 @@ h-files     = $(wildcard *.h)
 lib-h-files = $(wildcard ../../include/*/*.h)
 
 # list of libraries needed to link with
-libs     = ./Obj.a   ../../lib/libdeal_II_2d.a   ../../../lac/lib/liblac.a   ../../../base/lib/libbase.a
-libs.g   = ./Obj.g.a ../../lib/libdeal_II_2d.g.a ../../../lac/lib/liblac.g.a ../../../base/lib/libbase.g.a
+libs     = ./Obj.a   ../../lib/libdeal_II_2d.g.a ../../lib/libdeal_II_3d.a   ../../../lac/lib/liblac.a   ../../../base/lib/libbase.a
+libs.g   = ./Obj.g.a ../../lib/libdeal_II_2d.g.a ../../lib/libdeal_II_3d.g.a ../../../lac/lib/liblac.g.a ../../../base/lib/libbase.g.a
 
 
 # check whether we use debug mode or not
index 5246d88094ddb3c5eef2b7555ed7132bc4cd9883..f2afefd0c3f135d1b6477ba05df3de390c4789ec 100644 (file)
@@ -31,7 +31,7 @@ class Ball :
 
        for (int i=0; i<dim; ++i)
          middle(i) -= .5;
-       middle /= (sqrt(middle.square())*sqrt(2));
+       middle *= sqrt(dim) / (sqrt(middle.square())*2);
        for (int i=0; i<dim; ++i)
          middle(i) += .5;
        
@@ -44,33 +44,38 @@ template <int dim>
 class CurvedLine :
   public StraightBoundary<dim> {
   public:
-      virtual Point<dim> in_between (const PointArray &neighbors) const {
-       Point<dim> middle = StraightBoundary<dim>::in_between(neighbors);
-       double x=middle(0),
-              y=middle(1);
-       
-       if (y<x)
-         if (y<1-x)
-           middle(1) = 0.04*sin(6*3.141592*middle(0));
-         else
-           middle(0) = 1+0.04*sin(6*3.141592*middle(1));
-       
-       else
-         if (y<1-x)
-           middle(0) = 0.04*sin(6*3.141592*middle(1));
-         else
-           middle(1) = 1+0.04*sin(6*3.141592*middle(0));
+      virtual Point<dim> in_between (const PointArray &neighbors) const;
+};
 
-       return middle;
-      };
+
+
+template <int dim>
+Point<dim> CurvedLine<dim>::in_between (const PointArray &neighbors) const  {
+  Point<dim> middle = StraightBoundary<dim>::in_between(neighbors);
+  double x=middle(0),
+        y=middle(1);
+  
+  if (y<x)
+    if (y<1-x)
+      middle(1) = 0.04*sin(6*3.141592*middle(0));
+    else
+      middle(0) = 1+0.04*sin(6*3.141592*middle(1));
+  
+  else
+    if (y<1-x)
+      middle(0) = 0.04*sin(6*3.141592*middle(1));
+    else
+      middle(1) = 1+0.04*sin(6*3.141592*middle(0));
+  
+  return middle;
 };
 
 
 
-// since gcc can't resolve "test<2>()", do template parameter
-// passing this way...
 template <int dim>
-void test (const int test_case, const Point<dim> &) {
+void test (const int test_case) {
+  cout << "Running testcase " << test_case
+       << " in " << dim << " dimensions." << endl;
   Triangulation<dim> tria;
   tria.create_hypercube();
   
@@ -133,21 +138,23 @@ void test (const int test_case, const Point<dim> &) {
        tria.begin_active()->set_refine_flag();
        tria.execute_refinement ();
        
-       Triangulation<dim>::active_cell_iterator cell, endc;
-       for (int i=0; i<7; ++i) 
-         {
-           cell = tria.begin_active();
-           endc = tria.end();
+       Triangulation<dim>::active_cell_iterator cell, endc;
+       const unsigned int steps[4] = { 0, 10, 7, 2 };
+       for (unsigned int i=0; i<steps[dim]; ++i) 
+         {
+           cell = tria.begin_active();
+           endc = tria.end();
            
-                                            // refine all
-                                            // boundary cells
-           for (; cell!=endc; ++cell)
-             if (cell->at_boundary())
-               cell->set_refine_flag();
+                                            // refine all
+                                            // boundary cells
+           for (; cell!=endc; ++cell)
+             if (cell->at_boundary())
+               cell->set_refine_flag();
            
-           tria.execute_refinement();
-         };
-       
+           tria.execute_refinement();
+         };
+
+       tria.set_boundary (0);
        break;
       }
 
@@ -158,7 +165,7 @@ void test (const int test_case, const Point<dim> &) {
        tria.execute_refinement ();
        
        Triangulation<dim>::active_cell_iterator cell, endc;
-       for (int i=0; i<(dim==2 ? 13 : 30); ++i) 
+       for (int i=0; i<(dim==2 ? 13 : (dim==3 ? 7 : 30)); ++i) 
          {
            int n_levels = tria.n_levels();
            cell = tria.begin_active();
@@ -184,7 +191,9 @@ void test (const int test_case, const Point<dim> &) {
   
        
                                   // output the grid
-  string filename("grid.");
+  string filename("results/");
+  filename += ('0'+dim);
+  filename += "d.";
   filename += ('0'+test_case);
   
   ofstream out(filename.c_str());
@@ -197,18 +206,22 @@ void test (const int test_case, const Point<dim> &) {
 
 
 int main (int argc, char **argv) {
-  if (argc!=2
+  if (argc!=3
     {
-      cout << "Usage: grid_test testcase" << endl << endl
+      cout << "Usage: grid_test dimension testcase" << endl << endl
+          << "Dimension: 2 or 3" << endl << endl
           << "Testcases:" << endl
-          << "  1: continuous refinement of the unit square always in the middle" << endl
-          << "  2: refinement of the circle at the boundary" << endl
+          << "  1: continuous refinement of the unit square/cube always in the middle" << endl
+          << "  2: refinement of the circle/sphere at the boundary" << endl
           << "  3: refinement of a wiggled area at the boundary" << endl
           << "  4: random refinement" << endl << endl;
       return 1;
     };
 
-  test (argv[1][0]-'0', Point<2>());
+  if (argv[1][0] == '2')
+    test<2> (argv[2][0]-'0');
+  else
+    test<3> (argv[2][0]-'0');
 
   return 0;
 };
index eb6e01f1e9bdc0cbd99848965648fb3783fa02d8..21782a3337e03767c56c00cd62ae8f4fc4875714 100644 (file)
@@ -2,23 +2,42 @@ set size 0.721,1
 set data style lines
 set noxtics
 set noytics
+set noztics
 set noxzeroaxis
 set noyzeroaxis
+#set nozzeroaxis
 set nokey
 set term postscript eps
 
-!echo "  Making <grid.1.eps>"
-set output "grid.1.eps"
-plot "grid.1"
+!echo "  Making <results/2d.1.eps>"
+set output "results/2d.1.eps"
+plot "results/2d.1"
 
-!echo "  Making <grid.2.eps>"
-set output "grid.2.eps"
-plot "grid.2"
+!echo "  Making <results/2d.2.eps>"
+set output "results/2d.2.eps"
+plot "results/2d.2"
 
-!echo "  Making <grid.3.eps>"
-set output "grid.3.eps"
-plot "grid.3"
+!echo "  Making <results/2d.3.eps>"
+set output "results/2d.3.eps"
+plot "results/2d.3"
 
-!echo "  Making <grid.4.eps>"
-set output "grid.4.eps"
-plot "grid.4"
+!echo "  Making <results/2d.4.eps>"
+set output "results/2d.4.eps"
+plot "results/2d.4"
+
+
+!echo "  Making <results/3d.1.eps>"
+set output "results/3d.1.eps"
+splot "results/3d.1"
+
+!echo "  Making <results/3d.2.eps>"
+set output "results/3d.2.eps"
+splot "results/3d.2"
+
+!echo "  Making <results/3d.3.eps>"
+set output "results/3d.3.eps"
+splot "results/3d.3"
+
+!echo "  Making <results/3d.4.eps>"
+set output "results/3d.4.eps"
+splot "results/3d.4"
diff --git a/deal.II/deal.II/Attic/examples/grid/results/.cvsignore b/deal.II/deal.II/Attic/examples/grid/results/.cvsignore
new file mode 100644 (file)
index 0000000..480cb85
--- /dev/null
@@ -0,0 +1 @@
+?d.*
index d73b1f495be03f8e883de60313b1e5e8adbd5d7a..eb554b6ff2b872d3b5eddf3b1f842e97ceecdadc 100644 (file)
@@ -19,16 +19,16 @@ user-libs =
 
 # To run the program, use "make run"; to give parameters to the program,
 # give the parameters to the following variable:
-run-parameters  = 1
+run-parameters  = 1
 
 # To execute additional action apart from running the program, fill
 # in this list:
-additional-run-action = grid_test 2 ; grid_test 3 ; grid_test 4 ; gnuplot make_ps
+additional-run-action = grid_test 2 2 ; grid_test 2 3 ; grid_test 2 4 ; grid_test 3 1 ; grid_test 3 2 ; grid_test 3 3 ; grid_test 3 4 ; gnuplot make_ps
 
 # To specify which files are to be deleted by "make clean" (apart from
 # the usual ones: object files, executables, backups, etc), fill in the
 # following list
-delete-files = grid.? *.eps
+delete-files = results/[123]d*
 
 
 
@@ -49,8 +49,8 @@ h-files     = $(wildcard *.h)
 lib-h-files = $(wildcard ../../include/*/*.h)
 
 # list of libraries needed to link with
-libs     = ./Obj.a   ../../lib/libdeal_II_2d.a   ../../../lac/lib/liblac.a   ../../../base/lib/libbase.a
-libs.g   = ./Obj.g.a ../../lib/libdeal_II_2d.g.a ../../../lac/lib/liblac.g.a ../../../base/lib/libbase.g.a
+libs     = ./Obj.a   ../../lib/libdeal_II_2d.g.a ../../lib/libdeal_II_3d.a   ../../../lac/lib/liblac.a   ../../../base/lib/libbase.a
+libs.g   = ./Obj.g.a ../../lib/libdeal_II_2d.g.a ../../lib/libdeal_II_3d.g.a ../../../lac/lib/liblac.g.a ../../../base/lib/libbase.g.a
 
 
 # check whether we use debug mode or not
index 5246d88094ddb3c5eef2b7555ed7132bc4cd9883..f2afefd0c3f135d1b6477ba05df3de390c4789ec 100644 (file)
@@ -31,7 +31,7 @@ class Ball :
 
        for (int i=0; i<dim; ++i)
          middle(i) -= .5;
-       middle /= (sqrt(middle.square())*sqrt(2));
+       middle *= sqrt(dim) / (sqrt(middle.square())*2);
        for (int i=0; i<dim; ++i)
          middle(i) += .5;
        
@@ -44,33 +44,38 @@ template <int dim>
 class CurvedLine :
   public StraightBoundary<dim> {
   public:
-      virtual Point<dim> in_between (const PointArray &neighbors) const {
-       Point<dim> middle = StraightBoundary<dim>::in_between(neighbors);
-       double x=middle(0),
-              y=middle(1);
-       
-       if (y<x)
-         if (y<1-x)
-           middle(1) = 0.04*sin(6*3.141592*middle(0));
-         else
-           middle(0) = 1+0.04*sin(6*3.141592*middle(1));
-       
-       else
-         if (y<1-x)
-           middle(0) = 0.04*sin(6*3.141592*middle(1));
-         else
-           middle(1) = 1+0.04*sin(6*3.141592*middle(0));
+      virtual Point<dim> in_between (const PointArray &neighbors) const;
+};
 
-       return middle;
-      };
+
+
+template <int dim>
+Point<dim> CurvedLine<dim>::in_between (const PointArray &neighbors) const  {
+  Point<dim> middle = StraightBoundary<dim>::in_between(neighbors);
+  double x=middle(0),
+        y=middle(1);
+  
+  if (y<x)
+    if (y<1-x)
+      middle(1) = 0.04*sin(6*3.141592*middle(0));
+    else
+      middle(0) = 1+0.04*sin(6*3.141592*middle(1));
+  
+  else
+    if (y<1-x)
+      middle(0) = 0.04*sin(6*3.141592*middle(1));
+    else
+      middle(1) = 1+0.04*sin(6*3.141592*middle(0));
+  
+  return middle;
 };
 
 
 
-// since gcc can't resolve "test<2>()", do template parameter
-// passing this way...
 template <int dim>
-void test (const int test_case, const Point<dim> &) {
+void test (const int test_case) {
+  cout << "Running testcase " << test_case
+       << " in " << dim << " dimensions." << endl;
   Triangulation<dim> tria;
   tria.create_hypercube();
   
@@ -133,21 +138,23 @@ void test (const int test_case, const Point<dim> &) {
        tria.begin_active()->set_refine_flag();
        tria.execute_refinement ();
        
-       Triangulation<dim>::active_cell_iterator cell, endc;
-       for (int i=0; i<7; ++i) 
-         {
-           cell = tria.begin_active();
-           endc = tria.end();
+       Triangulation<dim>::active_cell_iterator cell, endc;
+       const unsigned int steps[4] = { 0, 10, 7, 2 };
+       for (unsigned int i=0; i<steps[dim]; ++i) 
+         {
+           cell = tria.begin_active();
+           endc = tria.end();
            
-                                            // refine all
-                                            // boundary cells
-           for (; cell!=endc; ++cell)
-             if (cell->at_boundary())
-               cell->set_refine_flag();
+                                            // refine all
+                                            // boundary cells
+           for (; cell!=endc; ++cell)
+             if (cell->at_boundary())
+               cell->set_refine_flag();
            
-           tria.execute_refinement();
-         };
-       
+           tria.execute_refinement();
+         };
+
+       tria.set_boundary (0);
        break;
       }
 
@@ -158,7 +165,7 @@ void test (const int test_case, const Point<dim> &) {
        tria.execute_refinement ();
        
        Triangulation<dim>::active_cell_iterator cell, endc;
-       for (int i=0; i<(dim==2 ? 13 : 30); ++i) 
+       for (int i=0; i<(dim==2 ? 13 : (dim==3 ? 7 : 30)); ++i) 
          {
            int n_levels = tria.n_levels();
            cell = tria.begin_active();
@@ -184,7 +191,9 @@ void test (const int test_case, const Point<dim> &) {
   
        
                                   // output the grid
-  string filename("grid.");
+  string filename("results/");
+  filename += ('0'+dim);
+  filename += "d.";
   filename += ('0'+test_case);
   
   ofstream out(filename.c_str());
@@ -197,18 +206,22 @@ void test (const int test_case, const Point<dim> &) {
 
 
 int main (int argc, char **argv) {
-  if (argc!=2
+  if (argc!=3
     {
-      cout << "Usage: grid_test testcase" << endl << endl
+      cout << "Usage: grid_test dimension testcase" << endl << endl
+          << "Dimension: 2 or 3" << endl << endl
           << "Testcases:" << endl
-          << "  1: continuous refinement of the unit square always in the middle" << endl
-          << "  2: refinement of the circle at the boundary" << endl
+          << "  1: continuous refinement of the unit square/cube always in the middle" << endl
+          << "  2: refinement of the circle/sphere at the boundary" << endl
           << "  3: refinement of a wiggled area at the boundary" << endl
           << "  4: random refinement" << endl << endl;
       return 1;
     };
 
-  test (argv[1][0]-'0', Point<2>());
+  if (argv[1][0] == '2')
+    test<2> (argv[2][0]-'0');
+  else
+    test<3> (argv[2][0]-'0');
 
   return 0;
 };
index eb6e01f1e9bdc0cbd99848965648fb3783fa02d8..21782a3337e03767c56c00cd62ae8f4fc4875714 100644 (file)
@@ -2,23 +2,42 @@ set size 0.721,1
 set data style lines
 set noxtics
 set noytics
+set noztics
 set noxzeroaxis
 set noyzeroaxis
+#set nozzeroaxis
 set nokey
 set term postscript eps
 
-!echo "  Making <grid.1.eps>"
-set output "grid.1.eps"
-plot "grid.1"
+!echo "  Making <results/2d.1.eps>"
+set output "results/2d.1.eps"
+plot "results/2d.1"
 
-!echo "  Making <grid.2.eps>"
-set output "grid.2.eps"
-plot "grid.2"
+!echo "  Making <results/2d.2.eps>"
+set output "results/2d.2.eps"
+plot "results/2d.2"
 
-!echo "  Making <grid.3.eps>"
-set output "grid.3.eps"
-plot "grid.3"
+!echo "  Making <results/2d.3.eps>"
+set output "results/2d.3.eps"
+plot "results/2d.3"
 
-!echo "  Making <grid.4.eps>"
-set output "grid.4.eps"
-plot "grid.4"
+!echo "  Making <results/2d.4.eps>"
+set output "results/2d.4.eps"
+plot "results/2d.4"
+
+
+!echo "  Making <results/3d.1.eps>"
+set output "results/3d.1.eps"
+splot "results/3d.1"
+
+!echo "  Making <results/3d.2.eps>"
+set output "results/3d.2.eps"
+splot "results/3d.2"
+
+!echo "  Making <results/3d.3.eps>"
+set output "results/3d.3.eps"
+splot "results/3d.3"
+
+!echo "  Making <results/3d.4.eps>"
+set output "results/3d.4.eps"
+splot "results/3d.4"
diff --git a/tests/big-tests/grid/results/.cvsignore b/tests/big-tests/grid/results/.cvsignore
new file mode 100644 (file)
index 0000000..480cb85
--- /dev/null
@@ -0,0 +1 @@
+?d.*

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.