int refine_count = 0;int coarsen_count = 0;
for(auto cell = this->tria.begin_active(); cell != this->tria.end(); ++cell){ if(cell->refine_flag_set()) refine_count++; if(cell->coarsen_flag_set()) coarsen_count++;}
std::cout<<"Process No. "<<Utilities::MPI::this_mpi_process(this->mpi_communicator) <<". Refine Count = "<<refine_count<<std::endl;
std::cout<<"Process No. "<<Utilities::MPI::this_mpi_process(this->mpi_communicator) <<". Coarsen Count = "<<coarsen_count<<std::endl;
SolutionTransfer<dim> sol_trans(this->dof_handler);
this->tria.prepare_coarsening_and_refinement();sol_trans.prepare_for_coarsening_and_refinement(locally_relevant_sln);
std::cout<<"Process No. "<<Utilities::MPI::this_mpi_process(this->mpi_communicator) <<". Pre_refine, n_active_cells = "<<this->tria.n_active_cells()<<std::endl;this->run_mesh_refinement();std::cout<<"Process No. "<<Utilities::MPI::this_mpi_process(this->mpi_communicator) <<". Post_refine, n_active_cells = "<<this->tria.n_active_cells()<<std::endl;
Process No. 1. Refine Count = 6144
Process No. 1. Coarsen Count = 1442
Process No. 0. Refine Count = 6144
Process No. 0. Coarsen Count = 1442
Process No. 1. Pre_refine, n_active_cells = 43772
Process No. 0. Pre_refine, n_active_cells = 43772
Process No. 0. Post_refine, n_active_cells = 61367
Process No. 1. Post_refine, n_active_cells = 61364
Vector<float> estimated_error_per_cell(this->tria.n_active_cells());KellyErrorEstimator<dim>::estimate(this->dof_handler, QGauss<dim - 1>(Q_POINTS), typename FunctionMap<dim>::type(), locally_relevant_sln, estimated_error_per_cell, ComponentMask(), 0, MultithreadInfo::n_threads(), Utilities::MPI::this_mpi_process(this->mpi_communicator));
IndexSet local_active_cells(this->tria.n_active_cells());local_active_cells.clear();
for(auto cell = this->tria.begin_active(); cell != this->tria.end(); ++cell){
if(cell->is_locally_owned()){ local_active_cells.add_index(cell->active_cell_index()); }}TrilinosWrappers::MPI::Vector distributed_error_per_cell(local_active_cells, this->mpi_communicator);
for(auto cell = this->tria.begin_active(); cell != this->tria.end(); ++cell){
if(cell->is_locally_owned()){ distributed_error_per_cell(cell->active_cell_index()) = estimated_error_per_cell(cell->active_cell_index()); }}distributed_error_per_cell.compress(VectorOperation::insert);estimated_error_per_cell = distributed_error_per_cell;
GridRefinement::refine_and_coarsen_fixed_number(this->tria, estimated_error_per_cell, param[0], param[1], max_cells);
//restrict grid levels if these two parameters are given.if(max_grid_level > 0){ if (this->tria.n_levels() > max_grid_level) { for (typename Triangulation<dim>::active_cell_iterator cell = this->tria.begin_active(max_grid_level); cell != this->tria.end(max_grid_level); ++cell) { cell->clear_refine_flag(); } }}if(min_grid_level > 0){ for (typename Triangulation<dim>::active_cell_iterator cell = this->tria.begin_active(min_grid_level); cell != this->tria.end_active(min_grid_level); ++cell) { cell->clear_coarsen_flag();