From 449a9df36599fa10590f2288a0bbd81d19d0f7f0 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 4 May 1998 08:39:54 +0000 Subject: [PATCH] Example update. git-svn-id: https://svn.dealii.org/trunk@241 0785d39b-7218-0410-832d-ea1e28bc413d --- .../Attic/examples/error-estimation/Makefile | 2 +- .../error-estimation/error-estimation.cc | 88 ++++++++----------- tests/big-tests/error-estimation/Makefile | 2 +- .../error-estimation/error-estimation.cc | 88 ++++++++----------- 4 files changed, 74 insertions(+), 106 deletions(-) diff --git a/deal.II/deal.II/Attic/examples/error-estimation/Makefile b/deal.II/deal.II/Attic/examples/error-estimation/Makefile index 250a66411a..ee6a9b6713 100644 --- a/deal.II/deal.II/Attic/examples/error-estimation/Makefile +++ b/deal.II/deal.II/Attic/examples/error-estimation/Makefile @@ -28,7 +28,7 @@ additional-run-action = 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 = gnuplot* +delete-files = gnuplot* *inp 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 7225fc5097..346fc734cc 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 @@ -72,8 +72,8 @@ class PoissonProblem : public ProblemBase { HyperBallBoundary boundary; - vector l1_error, l2_error, linfty_error; - vector h1_seminorm_error, h1_error, estimated_error; + vector l2_error, linfty_error; + vector h1_error, estimated_error; vector n_dofs; }; @@ -269,16 +269,10 @@ void PoissonProblem::run (const unsigned int start_level) { solve (); Solution sol; - dVector l1_error_per_cell, l2_error_per_cell, linfty_error_per_cell; - dVector h1_seminorm_error_per_cell, h1_error_per_cell; + dVector l2_error_per_cell, linfty_error_per_cell, h1_error_per_cell; dVector estimated_error_per_cell; QGauss3 q; - cout << " Calculating L1 error... "; - integrate_difference (sol, l1_error_per_cell, q, fe, L1_norm); - cout << l1_error_per_cell.l1_norm() << endl; - l1_error.push_back (l1_error_per_cell.l1_norm()); - cout << " Calculating L2 error... "; integrate_difference (sol, l2_error_per_cell, q, fe, L2_norm); cout << l2_error_per_cell.l2_norm() << endl; @@ -288,11 +282,6 @@ void PoissonProblem::run (const unsigned int start_level) { integrate_difference (sol, linfty_error_per_cell, q, fe, Linfty_norm); cout << linfty_error_per_cell.linfty_norm() << endl; linfty_error.push_back (linfty_error_per_cell.linfty_norm()); - - cout << " Calculating H1-seminorm error... "; - integrate_difference (sol, h1_seminorm_error_per_cell, q, fe, H1_seminorm); - cout << h1_seminorm_error_per_cell.l2_norm() << endl; - h1_seminorm_error.push_back (h1_seminorm_error_per_cell.l2_norm()); cout << " Calculating H1 error... "; integrate_difference (sol, h1_error_per_cell, q, fe, H1_norm); @@ -306,17 +295,14 @@ void PoissonProblem::run (const unsigned int start_level) { KellyErrorEstimator::FunctionMap(), solution, estimated_error_per_cell); - cout << estimated_error_per_cell.l2_norm(); + cout << estimated_error_per_cell.l2_norm() << endl; estimated_error.push_back (estimated_error_per_cell.l2_norm()); - - 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, estimated_error_per_dof; - dof->distribute_cell_to_dof_vector (l1_error_per_cell, l1_error_per_dof); + + dVector l2_error_per_dof, linfty_error_per_dof; + dVector h1_error_per_dof, estimated_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 (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); @@ -324,24 +310,29 @@ void PoissonProblem::run (const unsigned int start_level) { DataOut out; 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"); -// string filename = "gnuplot."; - string filename = "ee."; + string filename = "gnuplot."; +// string filename = "ee."; filename += ('0'+start_level); - filename += ".inp"; +// filename += ".inp"; cout << " Writing error plots to <" << filename << ">..." << endl; -// ofstream gnuplot(filename.c_str()); -// out.write_gnuplot (gnuplot); -// gnuplot.close (); - ofstream ucd(filename.c_str()); - out.write_ucd (ucd); - ucd.close(); + ofstream gnuplot(filename.c_str()); + out.write_gnuplot (gnuplot); + gnuplot.close (); +// ofstream ucd(filename.c_str()); +// out.write_ucd (ucd); +// ucd.close(); + + tria->refine_fixed_number (estimated_error_per_cell, 0.3); + tria->execute_refinement (); + string ref_filename = "gnuplot.ref."; + ref_filename += ('0'+start_level); + ofstream oxx(ref_filename.c_str()); + tria->print_gnuplot (oxx); cout << endl; }; @@ -350,49 +341,39 @@ void PoissonProblem::run (const unsigned int start_level) { template void PoissonProblem::print_history () const { ofstream out("gnuplot.history"); - out << "# n_dofs l1_error l2_error linfty_error " - << "h1_seminorm_error h1_error estimated_error" + out << "# n_dofs l2_error linfty_error " + << "h1_error estimated_error" << endl; for (unsigned int i=0; ih/2:" << endl; - cout << " L1 error : " << 1./average_l1 << endl - << " L2 error : " << 1./average_l2 << endl + cout << " L2 error : " << 1./average_l2 << endl << " Linfty error : " << 1./average_linfty << endl - << " H1 seminorm error: " << 1./average_h1_semi << endl << " H1 error : " << 1./average_h1 << endl << " Estimated error : " << 1./average_est << endl; }; @@ -411,3 +392,6 @@ int main () { return 0; }; + + + diff --git a/tests/big-tests/error-estimation/Makefile b/tests/big-tests/error-estimation/Makefile index 250a66411a..ee6a9b6713 100644 --- a/tests/big-tests/error-estimation/Makefile +++ b/tests/big-tests/error-estimation/Makefile @@ -28,7 +28,7 @@ additional-run-action = 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 = gnuplot* +delete-files = gnuplot* *inp diff --git a/tests/big-tests/error-estimation/error-estimation.cc b/tests/big-tests/error-estimation/error-estimation.cc index 7225fc5097..346fc734cc 100644 --- a/tests/big-tests/error-estimation/error-estimation.cc +++ b/tests/big-tests/error-estimation/error-estimation.cc @@ -72,8 +72,8 @@ class PoissonProblem : public ProblemBase { HyperBallBoundary boundary; - vector l1_error, l2_error, linfty_error; - vector h1_seminorm_error, h1_error, estimated_error; + vector l2_error, linfty_error; + vector h1_error, estimated_error; vector n_dofs; }; @@ -269,16 +269,10 @@ void PoissonProblem::run (const unsigned int start_level) { solve (); Solution sol; - dVector l1_error_per_cell, l2_error_per_cell, linfty_error_per_cell; - dVector h1_seminorm_error_per_cell, h1_error_per_cell; + dVector l2_error_per_cell, linfty_error_per_cell, h1_error_per_cell; dVector estimated_error_per_cell; QGauss3 q; - cout << " Calculating L1 error... "; - integrate_difference (sol, l1_error_per_cell, q, fe, L1_norm); - cout << l1_error_per_cell.l1_norm() << endl; - l1_error.push_back (l1_error_per_cell.l1_norm()); - cout << " Calculating L2 error... "; integrate_difference (sol, l2_error_per_cell, q, fe, L2_norm); cout << l2_error_per_cell.l2_norm() << endl; @@ -288,11 +282,6 @@ void PoissonProblem::run (const unsigned int start_level) { integrate_difference (sol, linfty_error_per_cell, q, fe, Linfty_norm); cout << linfty_error_per_cell.linfty_norm() << endl; linfty_error.push_back (linfty_error_per_cell.linfty_norm()); - - cout << " Calculating H1-seminorm error... "; - integrate_difference (sol, h1_seminorm_error_per_cell, q, fe, H1_seminorm); - cout << h1_seminorm_error_per_cell.l2_norm() << endl; - h1_seminorm_error.push_back (h1_seminorm_error_per_cell.l2_norm()); cout << " Calculating H1 error... "; integrate_difference (sol, h1_error_per_cell, q, fe, H1_norm); @@ -306,17 +295,14 @@ void PoissonProblem::run (const unsigned int start_level) { KellyErrorEstimator::FunctionMap(), solution, estimated_error_per_cell); - cout << estimated_error_per_cell.l2_norm(); + cout << estimated_error_per_cell.l2_norm() << endl; estimated_error.push_back (estimated_error_per_cell.l2_norm()); - - 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, estimated_error_per_dof; - dof->distribute_cell_to_dof_vector (l1_error_per_cell, l1_error_per_dof); + + dVector l2_error_per_dof, linfty_error_per_dof; + dVector h1_error_per_dof, estimated_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 (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); @@ -324,24 +310,29 @@ void PoissonProblem::run (const unsigned int start_level) { DataOut out; 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"); -// string filename = "gnuplot."; - string filename = "ee."; + string filename = "gnuplot."; +// string filename = "ee."; filename += ('0'+start_level); - filename += ".inp"; +// filename += ".inp"; cout << " Writing error plots to <" << filename << ">..." << endl; -// ofstream gnuplot(filename.c_str()); -// out.write_gnuplot (gnuplot); -// gnuplot.close (); - ofstream ucd(filename.c_str()); - out.write_ucd (ucd); - ucd.close(); + ofstream gnuplot(filename.c_str()); + out.write_gnuplot (gnuplot); + gnuplot.close (); +// ofstream ucd(filename.c_str()); +// out.write_ucd (ucd); +// ucd.close(); + + tria->refine_fixed_number (estimated_error_per_cell, 0.3); + tria->execute_refinement (); + string ref_filename = "gnuplot.ref."; + ref_filename += ('0'+start_level); + ofstream oxx(ref_filename.c_str()); + tria->print_gnuplot (oxx); cout << endl; }; @@ -350,49 +341,39 @@ void PoissonProblem::run (const unsigned int start_level) { template void PoissonProblem::print_history () const { ofstream out("gnuplot.history"); - out << "# n_dofs l1_error l2_error linfty_error " - << "h1_seminorm_error h1_error estimated_error" + out << "# n_dofs l2_error linfty_error " + << "h1_error estimated_error" << endl; for (unsigned int i=0; ih/2:" << endl; - cout << " L1 error : " << 1./average_l1 << endl - << " L2 error : " << 1./average_l2 << endl + cout << " L2 error : " << 1./average_l2 << endl << " Linfty error : " << 1./average_linfty << endl - << " H1 seminorm error: " << 1./average_h1_semi << endl << " H1 error : " << 1./average_h1 << endl << " Estimated error : " << 1./average_est << endl; }; @@ -411,3 +392,6 @@ int main () { return 0; }; + + + -- 2.39.5