From: Wolfgang Bangerth Date: Tue, 28 Apr 1998 12:32:03 +0000 (+0000) Subject: Add error estimation. Works perfectly! :-)) X-Git-Tag: v8.0.0~23040 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d57eb34f70279bd79e6dcb9d85b5090d95b5b082;p=dealii.git Add error estimation. Works perfectly! :-)) git-svn-id: https://svn.dealii.org/trunk@214 0785d39b-7218-0410-832d-ea1e28bc413d --- 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 3767cdd2a5..e78a9e8866 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 @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -227,15 +228,15 @@ void PoissonProblem::create_new () { template -void PoissonProblem::run (const unsigned int level) { +void PoissonProblem::run (const unsigned int start_level) { create_new (); - cout << "Refinement level = " << level + cout << "Refinement level = " << start_level << endl; cout << " Making grid... "; tria->create_hypercube (-1,+1); - tria->refine_global (level); + tria->refine_global (start_level); cout << tria->n_active_cells() << " active cells." << endl; rhs = new RHSPoly(); @@ -292,33 +293,42 @@ void PoissonProblem::run (const unsigned int level) { cout << h1_error_per_cell.l2_norm() << endl; h1_error.push_back (h1_error_per_cell.l2_norm()); - if (level<=5) - { - dVector l1_error_per_dof, l2_error_per_dof, linfty_error_per_dof; - dVector h1_seminorm_error_per_dof, h1_error_per_dof; - dof->distribute_cell_to_dof_vector (l1_error_per_cell, l1_error_per_dof); - 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_seminorm_error_per_cell, h1_seminorm_error_per_dof); - dof->distribute_cell_to_dof_vector (h1_error_per_cell, h1_error_per_dof); - - string filename = "gnuplot."; - filename += ('0'+level); - cout << " Writing error plots to <" << filename << ">..." << endl; - - DataOut out; - ofstream gnuplot(filename.c_str()); - fill_data (out); - out.add_data_vector (l1_error_per_dof, "L1-Error"); - out.add_data_vector (l2_error_per_dof, "L2-Error"); - out.add_data_vector (linfty_error_per_dof, "Linfty-Error"); - out.add_data_vector (h1_seminorm_error_per_dof, "H1-seminorm-Error"); - out.add_data_vector (h1_error_per_dof, "H1-Error"); - out.write_gnuplot (gnuplot); - gnuplot.close (); - } - else - cout << " Not writing error as grid." << endl; + cout << " Writing to file..." << endl; + dVector l1_error_per_dof, l2_error_per_dof, linfty_error_per_dof; + dVector h1_seminorm_error_per_dof, h1_error_per_dof; + dof->distribute_cell_to_dof_vector (l1_error_per_cell, l1_error_per_dof); + 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_seminorm_error_per_cell, + h1_seminorm_error_per_dof); + dof->distribute_cell_to_dof_vector (h1_error_per_cell, h1_error_per_dof); + + KellyErrorEstimator ee; + QTrapez eq; + dVector estimated_error_per_cell, estimated_error_per_dof; + ee.estimate_error (*dof, eq, fe, StraightBoundary(), + KellyErrorEstimator::FunctionMap(), + solution, + estimated_error_per_cell); + dof->distribute_cell_to_dof_vector (estimated_error_per_cell, + estimated_error_per_dof); + + + string filename = "gnuplot."; + filename += ('0'+start_level); + cout << " Writing error plots to <" << filename << ">..." << endl; + + DataOut out; + ofstream gnuplot(filename.c_str()); + fill_data (out); + out.add_data_vector (l1_error_per_dof, "L1-Error"); + out.add_data_vector (l2_error_per_dof, "L2-Error"); + out.add_data_vector (linfty_error_per_dof, "Linfty-Error"); + out.add_data_vector (h1_seminorm_error_per_dof, "H1-seminorm-Error"); + out.add_data_vector (h1_error_per_dof, "H1-Error"); + out.add_data_vector (estimated_error_per_dof, "Estimated Error"); + out.write_gnuplot (gnuplot); + gnuplot.close (); cout << endl; }; diff --git a/tests/big-tests/error-estimation/error-estimation.cc b/tests/big-tests/error-estimation/error-estimation.cc index 3767cdd2a5..e78a9e8866 100644 --- a/tests/big-tests/error-estimation/error-estimation.cc +++ b/tests/big-tests/error-estimation/error-estimation.cc @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -227,15 +228,15 @@ void PoissonProblem::create_new () { template -void PoissonProblem::run (const unsigned int level) { +void PoissonProblem::run (const unsigned int start_level) { create_new (); - cout << "Refinement level = " << level + cout << "Refinement level = " << start_level << endl; cout << " Making grid... "; tria->create_hypercube (-1,+1); - tria->refine_global (level); + tria->refine_global (start_level); cout << tria->n_active_cells() << " active cells." << endl; rhs = new RHSPoly(); @@ -292,33 +293,42 @@ void PoissonProblem::run (const unsigned int level) { cout << h1_error_per_cell.l2_norm() << endl; h1_error.push_back (h1_error_per_cell.l2_norm()); - if (level<=5) - { - dVector l1_error_per_dof, l2_error_per_dof, linfty_error_per_dof; - dVector h1_seminorm_error_per_dof, h1_error_per_dof; - dof->distribute_cell_to_dof_vector (l1_error_per_cell, l1_error_per_dof); - 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_seminorm_error_per_cell, h1_seminorm_error_per_dof); - dof->distribute_cell_to_dof_vector (h1_error_per_cell, h1_error_per_dof); - - string filename = "gnuplot."; - filename += ('0'+level); - cout << " Writing error plots to <" << filename << ">..." << endl; - - DataOut out; - ofstream gnuplot(filename.c_str()); - fill_data (out); - out.add_data_vector (l1_error_per_dof, "L1-Error"); - out.add_data_vector (l2_error_per_dof, "L2-Error"); - out.add_data_vector (linfty_error_per_dof, "Linfty-Error"); - out.add_data_vector (h1_seminorm_error_per_dof, "H1-seminorm-Error"); - out.add_data_vector (h1_error_per_dof, "H1-Error"); - out.write_gnuplot (gnuplot); - gnuplot.close (); - } - else - cout << " Not writing error as grid." << endl; + cout << " Writing to file..." << endl; + dVector l1_error_per_dof, l2_error_per_dof, linfty_error_per_dof; + dVector h1_seminorm_error_per_dof, h1_error_per_dof; + dof->distribute_cell_to_dof_vector (l1_error_per_cell, l1_error_per_dof); + 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_seminorm_error_per_cell, + h1_seminorm_error_per_dof); + dof->distribute_cell_to_dof_vector (h1_error_per_cell, h1_error_per_dof); + + KellyErrorEstimator ee; + QTrapez eq; + dVector estimated_error_per_cell, estimated_error_per_dof; + ee.estimate_error (*dof, eq, fe, StraightBoundary(), + KellyErrorEstimator::FunctionMap(), + solution, + estimated_error_per_cell); + dof->distribute_cell_to_dof_vector (estimated_error_per_cell, + estimated_error_per_dof); + + + string filename = "gnuplot."; + filename += ('0'+start_level); + cout << " Writing error plots to <" << filename << ">..." << endl; + + DataOut out; + ofstream gnuplot(filename.c_str()); + fill_data (out); + out.add_data_vector (l1_error_per_dof, "L1-Error"); + out.add_data_vector (l2_error_per_dof, "L2-Error"); + out.add_data_vector (linfty_error_per_dof, "Linfty-Error"); + out.add_data_vector (h1_seminorm_error_per_dof, "H1-seminorm-Error"); + out.add_data_vector (h1_error_per_dof, "H1-Error"); + out.add_data_vector (estimated_error_per_dof, "Estimated Error"); + out.write_gnuplot (gnuplot); + gnuplot.close (); cout << endl; };