From 81d0cbb1280bb9ba5e9c75c7cfaa8933f5f2606a Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 2 Apr 1998 17:19:34 +0000 Subject: [PATCH] Make example work finally. git-svn-id: https://svn.dealii.org/trunk@127 0785d39b-7218-0410-832d-ea1e28bc413d --- .../Attic/examples/poisson/poisson.prm | 5 +-- .../deal.II/Attic/examples/poisson/problem.cc | 31 ++++++++++++------- tests/big-tests/poisson/poisson.prm | 5 +-- tests/big-tests/poisson/problem.cc | 31 ++++++++++++------- 4 files changed, 46 insertions(+), 26 deletions(-) diff --git a/deal.II/deal.II/Attic/examples/poisson/poisson.prm b/deal.II/deal.II/Attic/examples/poisson/poisson.prm index c974e9afb6..fb9f151be9 100644 --- a/deal.II/deal.II/Attic/examples/poisson/poisson.prm +++ b/deal.II/deal.II/Attic/examples/poisson/poisson.prm @@ -1,2 +1,3 @@ -set Test run = random -set Global refinement = 1 +set Test run = { zoom in | ball | curved line | random } +set Global refinement = {{ 2 | 4 | 6 | 0 }} +set Output file = gnuplot.{{ zoom_in | ball | curved_line | random }} diff --git a/deal.II/deal.II/Attic/examples/poisson/problem.cc b/deal.II/deal.II/Attic/examples/poisson/problem.cc index acef23aa40..3d4a4ea1ec 100644 --- a/deal.II/deal.II/Attic/examples/poisson/problem.cc +++ b/deal.II/deal.II/Attic/examples/poisson/problem.cc @@ -71,7 +71,9 @@ void PoissonProblem::declare_parameters (ParameterHandler &prm) { else prm.declare_entry ("Test run", "zoom in", "zoom in\\|random"); - prm.declare_entry ("Global refinement", "0", ParameterHandler::RegularExpressions::Integer); + prm.declare_entry ("Global refinement", "0", + ParameterHandler::RegularExpressions::Integer); + prm.declare_entry ("Output file", "gnuplot.1"); }; @@ -89,22 +91,25 @@ bool PoissonProblem::make_grid (ParameterHandler &prm) { else if (test=="random") test_case = 4; else - cerr << "This test seems not to be implemented!" << endl; + { + cerr << "This test seems not to be implemented!" << endl; + return false; + }; switch (test_case) { case 1: make_zoom_in_grid (); - return true; + break; case 2: make_ball_grid (); - return true; + break; case 3: make_curved_line_grid (); - return true; + break; case 4: make_random_grid (); - return true; + break; default: return false; }; @@ -114,6 +119,8 @@ bool PoissonProblem::make_grid (ParameterHandler &prm) { return false; else tria->refine_global (refine_global); + + return true; }; @@ -172,6 +179,7 @@ void PoissonProblem::make_curved_line_grid () { template void PoissonProblem::make_random_grid () { + tria->create_hypercube (); tria->refine_global (1); Triangulation::active_cell_iterator cell, endc; @@ -215,11 +223,11 @@ void PoissonProblem::run (ParameterHandler &prm) { PoissonEquation equation (rhs); QGauss4 quadrature; - cout << "Distributing dofs... "; + cout << " Distributing dofs... "; dof->distribute_dofs (fe); cout << dof->n_dofs() << " degrees of freedom." << endl; - cout << "Assembling matrices..." << endl; + cout << " Assembling matrices..." << endl; FEValues::UpdateStruct update_flags; update_flags.q_points = update_flags.gradients = true; update_flags.jacobians = update_flags.JxW_values = true; @@ -229,12 +237,13 @@ void PoissonProblem::run (ParameterHandler &prm) { dirichlet_bc[0] = &zero; assemble (equation, quadrature, fe, update_flags, dirichlet_bc); - cout << "Solving..." << endl; + cout << " Solving..." << endl; solve (); - cout << "Printing..." << endl; + cout << " Writing to file <" << prm.get("Output file") << ">..." << endl; DataOut out; - ofstream gnuplot("gnuplot.out.5"); + + ofstream gnuplot(prm.get("Output file")); fill_data (out); out.write_gnuplot (gnuplot); gnuplot.close (); diff --git a/tests/big-tests/poisson/poisson.prm b/tests/big-tests/poisson/poisson.prm index c974e9afb6..fb9f151be9 100644 --- a/tests/big-tests/poisson/poisson.prm +++ b/tests/big-tests/poisson/poisson.prm @@ -1,2 +1,3 @@ -set Test run = random -set Global refinement = 1 +set Test run = { zoom in | ball | curved line | random } +set Global refinement = {{ 2 | 4 | 6 | 0 }} +set Output file = gnuplot.{{ zoom_in | ball | curved_line | random }} diff --git a/tests/big-tests/poisson/problem.cc b/tests/big-tests/poisson/problem.cc index acef23aa40..3d4a4ea1ec 100644 --- a/tests/big-tests/poisson/problem.cc +++ b/tests/big-tests/poisson/problem.cc @@ -71,7 +71,9 @@ void PoissonProblem::declare_parameters (ParameterHandler &prm) { else prm.declare_entry ("Test run", "zoom in", "zoom in\\|random"); - prm.declare_entry ("Global refinement", "0", ParameterHandler::RegularExpressions::Integer); + prm.declare_entry ("Global refinement", "0", + ParameterHandler::RegularExpressions::Integer); + prm.declare_entry ("Output file", "gnuplot.1"); }; @@ -89,22 +91,25 @@ bool PoissonProblem::make_grid (ParameterHandler &prm) { else if (test=="random") test_case = 4; else - cerr << "This test seems not to be implemented!" << endl; + { + cerr << "This test seems not to be implemented!" << endl; + return false; + }; switch (test_case) { case 1: make_zoom_in_grid (); - return true; + break; case 2: make_ball_grid (); - return true; + break; case 3: make_curved_line_grid (); - return true; + break; case 4: make_random_grid (); - return true; + break; default: return false; }; @@ -114,6 +119,8 @@ bool PoissonProblem::make_grid (ParameterHandler &prm) { return false; else tria->refine_global (refine_global); + + return true; }; @@ -172,6 +179,7 @@ void PoissonProblem::make_curved_line_grid () { template void PoissonProblem::make_random_grid () { + tria->create_hypercube (); tria->refine_global (1); Triangulation::active_cell_iterator cell, endc; @@ -215,11 +223,11 @@ void PoissonProblem::run (ParameterHandler &prm) { PoissonEquation equation (rhs); QGauss4 quadrature; - cout << "Distributing dofs... "; + cout << " Distributing dofs... "; dof->distribute_dofs (fe); cout << dof->n_dofs() << " degrees of freedom." << endl; - cout << "Assembling matrices..." << endl; + cout << " Assembling matrices..." << endl; FEValues::UpdateStruct update_flags; update_flags.q_points = update_flags.gradients = true; update_flags.jacobians = update_flags.JxW_values = true; @@ -229,12 +237,13 @@ void PoissonProblem::run (ParameterHandler &prm) { dirichlet_bc[0] = &zero; assemble (equation, quadrature, fe, update_flags, dirichlet_bc); - cout << "Solving..." << endl; + cout << " Solving..." << endl; solve (); - cout << "Printing..." << endl; + cout << " Writing to file <" << prm.get("Output file") << ">..." << endl; DataOut out; - ofstream gnuplot("gnuplot.out.5"); + + ofstream gnuplot(prm.get("Output file")); fill_data (out); out.write_gnuplot (gnuplot); gnuplot.close (); -- 2.39.5