From 048bb4929de3dc3e263516973c57eaafaeb67478 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 11 May 1998 18:07:49 +0000 Subject: [PATCH] Example refinement. git-svn-id: https://svn.dealii.org/trunk@279 0785d39b-7218-0410-832d-ea1e28bc413d --- .../Attic/examples/error-estimation/Makefile | 6 ++-- .../examples/error-estimation/ee.gauss.prm | 1 + .../examples/error-estimation/ee.singular.prm | 5 ++-- .../error-estimation/error-estimation.cc | 30 +++++-------------- .../Attic/examples/error-estimation/make_ps | 8 +---- tests/big-tests/error-estimation/Makefile | 6 ++-- tests/big-tests/error-estimation/ee.gauss.prm | 1 + .../error-estimation/ee.singular.prm | 5 ++-- .../error-estimation/error-estimation.cc | 30 +++++-------------- tests/big-tests/error-estimation/make_ps | 8 +---- 10 files changed, 34 insertions(+), 66 deletions(-) diff --git a/deal.II/deal.II/Attic/examples/error-estimation/Makefile b/deal.II/deal.II/Attic/examples/error-estimation/Makefile index 3f035617cb..35cd1f7b8a 100644 --- a/deal.II/deal.II/Attic/examples/error-estimation/Makefile +++ b/deal.II/deal.II/Attic/examples/error-estimation/Makefile @@ -11,7 +11,7 @@ target = error-estimation # the archives ./Obj.a and ./Obj.g.a. By default, the debug version # is used to link. It you don't like that, change the following # variable to "off" -debug-mode = on +debug-mode = off # If you want your program to be linked with extra object or library # files, specify them here: @@ -23,7 +23,9 @@ run-parameters = ee.gauss.prm # To execute additional action apart from running the program, fill # in this list: -additional-run-action = $(target) ee.singular.prm ; gnuplot make_ps ; ./strip_comments +additional-run-action = $(target) ee.singular.prm ; \ + gnuplot make_ps ; \ + perl -pi -e 's/^\#.*$$\\${}n//g' data-*/*.inp # To specify which files are to be deleted by "make clean" (apart from # the usual ones: object files, executables, backups, etc), fill in the diff --git a/deal.II/deal.II/Attic/examples/error-estimation/ee.gauss.prm b/deal.II/deal.II/Attic/examples/error-estimation/ee.gauss.prm index 588bb9a327..cd8daeb2fd 100644 --- a/deal.II/deal.II/Attic/examples/error-estimation/ee.gauss.prm +++ b/deal.II/deal.II/Attic/examples/error-estimation/ee.gauss.prm @@ -2,5 +2,6 @@ set Test case = Gauss shape set Initial refinement = 2 set Refinement criterion = { global | true error | estimated error } set Refinement fraction = 0.3 +set Maximum cells = 3000 set Output base filename = data-gauss/ set Output format = ucd diff --git a/deal.II/deal.II/Attic/examples/error-estimation/ee.singular.prm b/deal.II/deal.II/Attic/examples/error-estimation/ee.singular.prm index d906f3f768..6b5861d006 100644 --- a/deal.II/deal.II/Attic/examples/error-estimation/ee.singular.prm +++ b/deal.II/deal.II/Attic/examples/error-estimation/ee.singular.prm @@ -1,6 +1,7 @@ set Test case = Singular set Initial refinement = 1 -set Refinement criterion = { global | true error | estimated error } -set Refinement fraction = 0.2 +set Refinement criterion = { global | estimated error } +set Refinement fraction = 0.1 +set Maximum cells = 10000 set Output base filename = data-singular/ set Output format = ucd diff --git a/deal.II/deal.II/Attic/examples/error-estimation/error-estimation.cc b/deal.II/deal.II/Attic/examples/error-estimation/error-estimation.cc index 2b42b1b95a..18c19ef5d5 100644 --- a/deal.II/deal.II/Attic/examples/error-estimation/error-estimation.cc +++ b/deal.II/deal.II/Attic/examples/error-estimation/error-estimation.cc @@ -80,8 +80,6 @@ class PoissonProblem : public ProblemBase, vector l2_error, linfty_error; vector h1_error, estimated_error; vector n_dofs; - - vector laplacian; }; @@ -292,6 +290,8 @@ void PoissonProblem::declare_parameters (ParameterHandler &prm) { "global\\|true error\\|estimated error"); prm.declare_entry ("Refinement fraction", "0.3", ParameterHandler::RegularExpressions::Double); + prm.declare_entry ("Maximum cells", "3000", + ParameterHandler::RegularExpressions::Integer); prm.declare_entry ("Output base filename", ""); prm.declare_entry ("Output format", "ucd" "ucd\\|gnuplot"); @@ -358,7 +358,8 @@ void PoissonProblem::run (ParameterHandler &prm) { QGauss3 quadrature; unsigned int refine_step = 0; - while (tria->n_active_cells() < 2000) + const unsigned int max_cells = prm.get_integer("Maximum cells"); + while (tria->n_active_cells() < max_cells) { cout << "Refinement step " << refine_step << ", using " << tria->n_active_cells() << " active cells on " @@ -382,7 +383,6 @@ void PoissonProblem::run (ParameterHandler &prm) { dVector l2_error_per_cell, linfty_error_per_cell, h1_error_per_cell; dVector estimated_error_per_cell; - dVector laplacian_per_cell; QGauss3 q; cout << " Calculating L2 error... "; @@ -412,28 +412,16 @@ void PoissonProblem::run (ParameterHandler &prm) { cout << estimated_error_per_cell.l2_norm() << endl; estimated_error.push_back (estimated_error_per_cell.l2_norm()); - laplacian_per_cell = estimated_error_per_cell; - DoFHandler::active_cell_iterator cell = dof->begin_active(), - endc = dof->end(); - for (unsigned int i=0; cell!=endc; ++cell, ++i) - laplacian_per_cell(i) /= (cell->diameter() * cell->diameter() / 24); - cout << " Computing second derivative maximum... " - << laplacian_per_cell.linfty_norm() - << endl; - laplacian.push_back (laplacian_per_cell.linfty_norm()); - dVector l2_error_per_dof, linfty_error_per_dof; dVector h1_error_per_dof, estimated_error_per_dof; - dVector laplacian_per_dof; + dVector error_ratio; dof->distribute_cell_to_dof_vector (l2_error_per_cell, l2_error_per_dof); dof->distribute_cell_to_dof_vector (linfty_error_per_cell, linfty_error_per_dof); dof->distribute_cell_to_dof_vector (h1_error_per_cell, h1_error_per_dof); dof->distribute_cell_to_dof_vector (estimated_error_per_cell, estimated_error_per_dof); - dof->distribute_cell_to_dof_vector (laplacian_per_cell, - laplacian_per_dof); - + error_ratio.ratio (h1_error_per_dof, estimated_error_per_dof); DataOut out; fill_data (out); @@ -441,7 +429,7 @@ void PoissonProblem::run (ParameterHandler &prm) { out.add_data_vector (linfty_error_per_dof, "Linfty-Error"); out.add_data_vector (h1_error_per_dof, "H1-Error"); out.add_data_vector (estimated_error_per_dof, "Estimated Error"); - out.add_data_vector (laplacian_per_dof, "Second derivative pointwise"); + out.add_data_vector (error_ratio, "Ratio True:Estimated Error"); String filename = prm.get ("Output base filename"); switch (refine_mode) { @@ -523,8 +511,7 @@ void PoissonProblem::print_history (const ParameterHandler &prm, << endl; ofstream out(filename); out << "# n_dofs l2_error linfty_error " - << "h1_error estimated_error " - << "laplacian" + << "h1_error estimated_error" << endl; for (unsigned int i=0; i::print_history (const ParameterHandler &prm, << linfty_error[i] << " " << h1_error[i] << " " << estimated_error[i] << " " - << laplacian[i] << endl; double average_l2=0, diff --git a/deal.II/deal.II/Attic/examples/error-estimation/make_ps b/deal.II/deal.II/Attic/examples/error-estimation/make_ps index ef9c54cf76..38d05f569a 100644 --- a/deal.II/deal.II/Attic/examples/error-estimation/make_ps +++ b/deal.II/deal.II/Attic/examples/error-estimation/make_ps @@ -34,16 +34,10 @@ set output "data-singular/history.global.eps" plot "data-singular/history.global.gnuplot" using 1:2 title "L2 error","data-singular/history.global.gnuplot" using 1:3 title "Linfty error","data-singular/history.global.gnuplot" using 1:4 title "H1 error","data-singular/history.global.gnuplot" using 1:5 title "Estimated H1 error" -set output "data-singular/history.true_error.eps" - -plot "data-singular/history.true_error.gnuplot" using 1:2 title "L2 error","data-singular/history.true_error.gnuplot" using 1:3 title "Linfty error","data-singular/history.true_error.gnuplot" using 1:4 title "H1 error","data-singular/history.true_error.gnuplot" using 1:5 title "Estimated H1 error" - - - set output "data-singular/history.estimated_error.eps" plot "data-singular/history.estimated_error.gnuplot" using 1:2 title "L2 error","data-singular/history.estimated_error.gnuplot" using 1:3 title "Linfty error","data-singular/history.estimated_error.gnuplot" using 1:4 title "H1 error","data-singular/history.estimated_error.gnuplot" using 1:5 title "Estimated H1 error" set output "data-singular/history.compare.eps" -plot "data-singular/history.global.gnuplot" using 1:2 title "global refinement -- L2 error", "data-singular/history.true_error.gnuplot" using 1:2 title "ref. by true error -- L2 error", "data-singular/history.estimated_error.gnuplot" using 1:2 title "ref. by estimated error -- L2 error", "data-singular/history.global.gnuplot" using 1:4 title "global refinement -- H1 error", "data-singular/history.true_error.gnuplot" using 1:4 title "ref. by true error -- H1 error", "data-singular/history.estimated_error.gnuplot" using 1:4 title "ref. by estimated error -- H1 error" +plot "data-singular/history.global.gnuplot" using 1:2 title "global refinement -- L2 error", "data-singular/history.estimated_error.gnuplot" using 1:2 title "ref. by estimated error -- L2 error", "data-singular/history.global.gnuplot" using 1:4 title "global refinement -- H1 error", "data-singular/history.estimated_error.gnuplot" using 1:4 title "ref. by estimated error -- H1 error" diff --git a/tests/big-tests/error-estimation/Makefile b/tests/big-tests/error-estimation/Makefile index 3f035617cb..35cd1f7b8a 100644 --- a/tests/big-tests/error-estimation/Makefile +++ b/tests/big-tests/error-estimation/Makefile @@ -11,7 +11,7 @@ target = error-estimation # the archives ./Obj.a and ./Obj.g.a. By default, the debug version # is used to link. It you don't like that, change the following # variable to "off" -debug-mode = on +debug-mode = off # If you want your program to be linked with extra object or library # files, specify them here: @@ -23,7 +23,9 @@ run-parameters = ee.gauss.prm # To execute additional action apart from running the program, fill # in this list: -additional-run-action = $(target) ee.singular.prm ; gnuplot make_ps ; ./strip_comments +additional-run-action = $(target) ee.singular.prm ; \ + gnuplot make_ps ; \ + perl -pi -e 's/^\#.*$$\\${}n//g' data-*/*.inp # To specify which files are to be deleted by "make clean" (apart from # the usual ones: object files, executables, backups, etc), fill in the diff --git a/tests/big-tests/error-estimation/ee.gauss.prm b/tests/big-tests/error-estimation/ee.gauss.prm index 588bb9a327..cd8daeb2fd 100644 --- a/tests/big-tests/error-estimation/ee.gauss.prm +++ b/tests/big-tests/error-estimation/ee.gauss.prm @@ -2,5 +2,6 @@ set Test case = Gauss shape set Initial refinement = 2 set Refinement criterion = { global | true error | estimated error } set Refinement fraction = 0.3 +set Maximum cells = 3000 set Output base filename = data-gauss/ set Output format = ucd diff --git a/tests/big-tests/error-estimation/ee.singular.prm b/tests/big-tests/error-estimation/ee.singular.prm index d906f3f768..6b5861d006 100644 --- a/tests/big-tests/error-estimation/ee.singular.prm +++ b/tests/big-tests/error-estimation/ee.singular.prm @@ -1,6 +1,7 @@ set Test case = Singular set Initial refinement = 1 -set Refinement criterion = { global | true error | estimated error } -set Refinement fraction = 0.2 +set Refinement criterion = { global | estimated error } +set Refinement fraction = 0.1 +set Maximum cells = 10000 set Output base filename = data-singular/ set Output format = ucd diff --git a/tests/big-tests/error-estimation/error-estimation.cc b/tests/big-tests/error-estimation/error-estimation.cc index 2b42b1b95a..18c19ef5d5 100644 --- a/tests/big-tests/error-estimation/error-estimation.cc +++ b/tests/big-tests/error-estimation/error-estimation.cc @@ -80,8 +80,6 @@ class PoissonProblem : public ProblemBase, vector l2_error, linfty_error; vector h1_error, estimated_error; vector n_dofs; - - vector laplacian; }; @@ -292,6 +290,8 @@ void PoissonProblem::declare_parameters (ParameterHandler &prm) { "global\\|true error\\|estimated error"); prm.declare_entry ("Refinement fraction", "0.3", ParameterHandler::RegularExpressions::Double); + prm.declare_entry ("Maximum cells", "3000", + ParameterHandler::RegularExpressions::Integer); prm.declare_entry ("Output base filename", ""); prm.declare_entry ("Output format", "ucd" "ucd\\|gnuplot"); @@ -358,7 +358,8 @@ void PoissonProblem::run (ParameterHandler &prm) { QGauss3 quadrature; unsigned int refine_step = 0; - while (tria->n_active_cells() < 2000) + const unsigned int max_cells = prm.get_integer("Maximum cells"); + while (tria->n_active_cells() < max_cells) { cout << "Refinement step " << refine_step << ", using " << tria->n_active_cells() << " active cells on " @@ -382,7 +383,6 @@ void PoissonProblem::run (ParameterHandler &prm) { dVector l2_error_per_cell, linfty_error_per_cell, h1_error_per_cell; dVector estimated_error_per_cell; - dVector laplacian_per_cell; QGauss3 q; cout << " Calculating L2 error... "; @@ -412,28 +412,16 @@ void PoissonProblem::run (ParameterHandler &prm) { cout << estimated_error_per_cell.l2_norm() << endl; estimated_error.push_back (estimated_error_per_cell.l2_norm()); - laplacian_per_cell = estimated_error_per_cell; - DoFHandler::active_cell_iterator cell = dof->begin_active(), - endc = dof->end(); - for (unsigned int i=0; cell!=endc; ++cell, ++i) - laplacian_per_cell(i) /= (cell->diameter() * cell->diameter() / 24); - cout << " Computing second derivative maximum... " - << laplacian_per_cell.linfty_norm() - << endl; - laplacian.push_back (laplacian_per_cell.linfty_norm()); - dVector l2_error_per_dof, linfty_error_per_dof; dVector h1_error_per_dof, estimated_error_per_dof; - dVector laplacian_per_dof; + dVector error_ratio; dof->distribute_cell_to_dof_vector (l2_error_per_cell, l2_error_per_dof); dof->distribute_cell_to_dof_vector (linfty_error_per_cell, linfty_error_per_dof); dof->distribute_cell_to_dof_vector (h1_error_per_cell, h1_error_per_dof); dof->distribute_cell_to_dof_vector (estimated_error_per_cell, estimated_error_per_dof); - dof->distribute_cell_to_dof_vector (laplacian_per_cell, - laplacian_per_dof); - + error_ratio.ratio (h1_error_per_dof, estimated_error_per_dof); DataOut out; fill_data (out); @@ -441,7 +429,7 @@ void PoissonProblem::run (ParameterHandler &prm) { out.add_data_vector (linfty_error_per_dof, "Linfty-Error"); out.add_data_vector (h1_error_per_dof, "H1-Error"); out.add_data_vector (estimated_error_per_dof, "Estimated Error"); - out.add_data_vector (laplacian_per_dof, "Second derivative pointwise"); + out.add_data_vector (error_ratio, "Ratio True:Estimated Error"); String filename = prm.get ("Output base filename"); switch (refine_mode) { @@ -523,8 +511,7 @@ void PoissonProblem::print_history (const ParameterHandler &prm, << endl; ofstream out(filename); out << "# n_dofs l2_error linfty_error " - << "h1_error estimated_error " - << "laplacian" + << "h1_error estimated_error" << endl; for (unsigned int i=0; i::print_history (const ParameterHandler &prm, << linfty_error[i] << " " << h1_error[i] << " " << estimated_error[i] << " " - << laplacian[i] << endl; double average_l2=0, diff --git a/tests/big-tests/error-estimation/make_ps b/tests/big-tests/error-estimation/make_ps index ef9c54cf76..38d05f569a 100644 --- a/tests/big-tests/error-estimation/make_ps +++ b/tests/big-tests/error-estimation/make_ps @@ -34,16 +34,10 @@ set output "data-singular/history.global.eps" plot "data-singular/history.global.gnuplot" using 1:2 title "L2 error","data-singular/history.global.gnuplot" using 1:3 title "Linfty error","data-singular/history.global.gnuplot" using 1:4 title "H1 error","data-singular/history.global.gnuplot" using 1:5 title "Estimated H1 error" -set output "data-singular/history.true_error.eps" - -plot "data-singular/history.true_error.gnuplot" using 1:2 title "L2 error","data-singular/history.true_error.gnuplot" using 1:3 title "Linfty error","data-singular/history.true_error.gnuplot" using 1:4 title "H1 error","data-singular/history.true_error.gnuplot" using 1:5 title "Estimated H1 error" - - - set output "data-singular/history.estimated_error.eps" plot "data-singular/history.estimated_error.gnuplot" using 1:2 title "L2 error","data-singular/history.estimated_error.gnuplot" using 1:3 title "Linfty error","data-singular/history.estimated_error.gnuplot" using 1:4 title "H1 error","data-singular/history.estimated_error.gnuplot" using 1:5 title "Estimated H1 error" set output "data-singular/history.compare.eps" -plot "data-singular/history.global.gnuplot" using 1:2 title "global refinement -- L2 error", "data-singular/history.true_error.gnuplot" using 1:2 title "ref. by true error -- L2 error", "data-singular/history.estimated_error.gnuplot" using 1:2 title "ref. by estimated error -- L2 error", "data-singular/history.global.gnuplot" using 1:4 title "global refinement -- H1 error", "data-singular/history.true_error.gnuplot" using 1:4 title "ref. by true error -- H1 error", "data-singular/history.estimated_error.gnuplot" using 1:4 title "ref. by estimated error -- H1 error" +plot "data-singular/history.global.gnuplot" using 1:2 title "global refinement -- L2 error", "data-singular/history.estimated_error.gnuplot" using 1:2 title "ref. by estimated error -- L2 error", "data-singular/history.global.gnuplot" using 1:4 title "global refinement -- H1 error", "data-singular/history.estimated_error.gnuplot" using 1:4 title "ref. by estimated error -- H1 error" -- 2.39.5