From fcf09c5338dd927641492e95e3f169c77ee910ad Mon Sep 17 00:00:00 2001 From: kanschat Date: Mon, 24 Jun 2013 14:14:08 +0000 Subject: [PATCH] step 39 test with local refinement on a single processor git-svn-id: https://svn.dealii.org/trunk@29879 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/mpi/step-39.cc | 109 +++++++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 50 deletions(-) diff --git a/tests/mpi/step-39.cc b/tests/mpi/step-39.cc index baf365bb0b..a147f43539 100644 --- a/tests/mpi/step-39.cc +++ b/tests/mpi/step-39.cc @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include @@ -576,50 +576,59 @@ namespace Step39 } - // template - // double - // InteriorPenaltyProblem::estimate() - // { - // std::vector old_user_indices; - // triangulation.save_user_indices(old_user_indices); - - // estimates.block(0).reinit(triangulation.n_active_cells()); - // unsigned int i=0; - // for (typename Triangulation::active_cell_iterator cell = triangulation.begin_active(); - // cell != triangulation.end(); ++cell,++i) - // cell->set_user_index(i); + template + double + InteriorPenaltyProblem::estimate() + { + TrilinosWrappers::MPI::Vector ghost; + ghost.reinit(locally_relevant_set, MPI_COMM_WORLD); + ghost = solution; + + std::vector old_user_indices; + triangulation.save_user_indices(old_user_indices); - // MeshWorker::IntegrationInfoBox info_box; - // const unsigned int n_gauss_points = dof_handler.get_fe().tensor_degree()+1; - // info_box.initialize_gauss_quadrature(n_gauss_points, n_gauss_points+1, n_gauss_points); + estimates.block(0).reinit(triangulation.n_active_cells()); + unsigned int i=0; + for (typename Triangulation::active_cell_iterator cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell,++i) + cell->set_user_index(i); - // NamedData solution_data; - // solution_data.add(&solution, "solution"); + MeshWorker::IntegrationInfoBox info_box; + const unsigned int n_gauss_points = dof_handler.get_fe().tensor_degree()+1; + info_box.initialize_gauss_quadrature(n_gauss_points, n_gauss_points+1, n_gauss_points); - // info_box.cell_selector.add("solution", false, false, true); - // info_box.boundary_selector.add("solution", true, true, false); - // info_box.face_selector.add("solution", true, true, false); + NamedData solution_data; + solution_data.add(&ghost, "solution"); - // info_box.add_update_flags_boundary(update_quadrature_points); - // info_box.initialize(fe, mapping, solution_data); + info_box.cell_selector.add("solution", false, false, true); + info_box.boundary_selector.add("solution", true, true, false); + info_box.face_selector.add("solution", true, true, false); - // MeshWorker::DoFInfo dof_info(dof_handler); + info_box.add_update_flags_boundary(update_quadrature_points); + info_box.initialize(fe, mapping, solution_data); - // MeshWorker::Assembler::CellsAndFaces assembler; - // NamedData out_data; - // BlockTrilinosWrappers::MPI::Vector *est = &estimates; - // out_data.add(est, "cells"); - // assembler.initialize(out_data, false); + MeshWorker::DoFInfo dof_info(dof_handler); - // Estimator integrator; - // MeshWorker::integration_loop ( - // dof_handler.begin_active(), dof_handler.end(), - // dof_info, info_box, - // integrator, assembler); + MeshWorker::Assembler::CellsAndFaces assembler; + NamedData* > out_data; + BlockVector *est = &estimates; + out_data.add(est, "cells"); + assembler.initialize(out_data, false); + + FilteredIterator::active_cell_iterator> + begin(IteratorFilters::LocallyOwnedCell(), dof_handler.begin_active()); + FilteredIterator::active_cell_iterator> + end(IteratorFilters::LocallyOwnedCell(), dof_handler.end()); + + Estimator integrator; + MeshWorker::integration_loop ( + begin, end, + dof_info, info_box, + integrator, assembler); - // triangulation.load_user_indices(old_user_indices); - // return estimates.block(0).l2_norm(); - // } + triangulation.load_user_indices(old_user_indices); + return estimates.block(0).l2_norm(); + } // template @@ -673,20 +682,20 @@ namespace Step39 // { // char *fn = new char[100]; // sprintf(fn, "step-39/sol-%02d", cycle); - + // std::string filename(fn); // filename += ".gnuplot"; // deallog << "Writing solution to <" << filename << ">..." // << std::endl << std::endl; // std::ofstream gnuplot_output (filename.c_str()); - + // DataOut data_out; // data_out.attach_dof_handler (dof_handler); // data_out.add_data_vector (solution, "u"); // data_out.add_data_vector (estimates.block(0), "est"); - + // data_out.build_patches (); - + // data_out.write_gnuplot(gnuplot_output); // } @@ -698,15 +707,15 @@ namespace Step39 for (unsigned int s=0; s