# 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 = 2 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*
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
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;
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();
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;
}
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();
// output the grid
- string filename("grid.");
+ string filename("results/");
+ filename += ('0'+dim);
+ filename += "d.";
filename += ('0'+test_case);
ofstream out(filename.c_str());
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;
};
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"
# 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 = 2 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*
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
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;
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();
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;
}
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();
// output the grid
- string filename("grid.");
+ string filename("results/");
+ filename += ('0'+dim);
+ filename += "d.";
filename += ('0'+test_case);
ofstream out(filename.c_str());
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;
};
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"