From de26ff29eea47b25464d1ad1c7e79c60d12abf94 Mon Sep 17 00:00:00 2001 From: bangerth Date: Sun, 11 Sep 2011 05:44:26 +0000 Subject: [PATCH] Use the cell->is_locally_owned() predicate introduced in the previous patch. git-svn-id: https://svn.dealii.org/trunk@24304 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/examples/step-32/step-32.cc | 6 +-- deal.II/examples/step-40/step-40.cc | 15 +++++--- .../deal.II/numerics/vectors.templates.h | 8 ++-- deal.II/source/dofs/dof_renumbering.cc | 6 +-- deal.II/source/dofs/dof_tools.cc | 22 ++++------- deal.II/source/grid/grid_tools.cc | 8 ++-- deal.II/source/grid/tria.cc | 3 +- deal.II/source/numerics/data_out.cc | 4 +- deal.II/source/numerics/data_out_faces.cc | 15 ++++---- deal.II/source/numerics/data_out_rotation.cc | 5 +-- deal.II/source/numerics/data_out_stack.cc | 37 +++++++++---------- 11 files changed, 62 insertions(+), 67 deletions(-) diff --git a/deal.II/examples/step-32/step-32.cc b/deal.II/examples/step-32/step-32.cc index c96c0db93b..b000b0c185 100644 --- a/deal.II/examples/step-32/step-32.cc +++ b/deal.II/examples/step-32/step-32.cc @@ -1673,7 +1673,7 @@ compute_viscosity (const std::vector &old_temperature, max_velocity = std::max (std::sqrt (u*u), max_velocity); } - const double max_viscosity = (parameters.stabilization_beta * + const double max_viscosity = (parameters.stabilization_beta * max_velocity * cell_diameter); if (timestep_number == 0) return max_viscosity; @@ -3614,7 +3614,7 @@ void BoussinesqFlowProblem::output_results () temperature_cell = temperature_dof_handler.begin_active(); for (; joint_cell!=joint_endc; ++joint_cell, ++stokes_cell, ++temperature_cell) - if (!joint_cell->is_artificial() && !joint_cell->is_ghost()) + if (joint_cell->is_locally_owned()) { joint_cell->get_dof_indices (local_joint_dof_indices); stokes_cell->get_dof_indices (local_stokes_dof_indices); @@ -3817,7 +3817,7 @@ void BoussinesqFlowProblem::refine_mesh (const unsigned int max_grid_level) // for (typename Triangulation::active_cell_iterator // cell = triangulation.begin_active(); // cell != triangulation.end(); ++cell) - // if (!cell->is_ghost() && !cell->is_artificial()) + // if (cell->is_locally_owned()) // if ((cell->center()[1] > 0) // && // (cell->center()[2] > 0)) diff --git a/deal.II/examples/step-40/step-40.cc b/deal.II/examples/step-40/step-40.cc index 732097b0d9..bb22eb8796 100644 --- a/deal.II/examples/step-40/step-40.cc +++ b/deal.II/examples/step-40/step-40.cc @@ -432,14 +432,19 @@ namespace Step40 // being almost exactly what we've seen // before. The points to watch out for are: // - Assembly must only loop over locally - // owned cells. We test this by comparing + // owned cells. There are multiple ways to + // test that; for example, we could + // compare // a cell's subdomain_id against // information from the triangulation - // but an equally valid condition would - // have been to skip all cells for which + // as in cell->subdomain_id() == + // triangulation.locally_owned_subdomain(), + // or skip all cells for which // the condition cell->is_ghost() // || cell->is_artificial() is - // true. + // true. The simplest way, however, is + // to simply ask the cell whether it is + // owned by the local processor. // - Copying local contributions into the // global matrix must include distributing // constraints and boundary values. In @@ -483,7 +488,7 @@ namespace Step40 cell = dof_handler.begin_active(), endc = dof_handler.end(); for (; cell!=endc; ++cell) - if (cell->subdomain_id() == triangulation.locally_owned_subdomain()) + if (cell->is_locally_owned()) { cell_matrix = 0; cell_rhs = 0; diff --git a/deal.II/include/deal.II/numerics/vectors.templates.h b/deal.II/include/deal.II/numerics/vectors.templates.h index 78a23c855a..854b3b9721 100644 --- a/deal.II/include/deal.II/numerics/vectors.templates.h +++ b/deal.II/include/deal.II/numerics/vectors.templates.h @@ -190,7 +190,7 @@ void VectorTools::interpolate (const Mapping fe, support_quadrature, update_quadrature_points); for (; cell!=endc; ++cell) - if (!cell->is_artificial() && !cell->is_ghost()) + if (cell->is_locally_owned()) { const unsigned int fe_index = cell->active_fe_index(); @@ -4346,7 +4346,7 @@ compute_no_normal_flux_constraints (const DH &dof_handler, // length of the vector // back to one, just to be // on the safe side - Point normal_vector + Point normal_vector = (cell->face(face_no)->get_boundary() .normal_vector (cell->face(face_no), fe_values.quadrature_point(i))); @@ -4928,7 +4928,7 @@ namespace internal typename DH::active_cell_iterator cell = dof.begin_active(), endc = dof.end(); for (unsigned int index=0; cell != endc; ++cell, ++index) - if (!cell->is_artificial() && !cell->is_ghost()) + if (cell->is_locally_owned()) { double diff=0; // initialize for this cell @@ -5480,7 +5480,7 @@ VectorTools::compute_mean_value (const Mapping &mapping, double area = 0.; // Compute mean value for (cell = dof.begin_active(); cell != dof.end(); ++cell) - if (!cell->is_artificial() && !cell->is_ghost()) + if (cell->is_locally_owned()) { fe.reinit (cell); fe.get_function_values(v, values); diff --git a/deal.II/source/dofs/dof_renumbering.cc b/deal.II/source/dofs/dof_renumbering.cc index 9f306b1a53..dfa196c5ca 100644 --- a/deal.II/source/dofs/dof_renumbering.cc +++ b/deal.II/source/dofs/dof_renumbering.cc @@ -765,7 +765,7 @@ namespace DoFRenumbering std::vector > component_to_dof_map (fe_collection.n_components()); for (ITERATOR cell=start; cell!=end; ++cell) - if (!cell->is_artificial() && !cell->is_ghost()) + if (cell->is_locally_owned()) { // on each cell: get dof indices // and insert them into the global @@ -922,7 +922,7 @@ namespace DoFRenumbering } else { - if (!cell->is_artificial() && !cell->is_ghost()) + if (cell->is_locally_owned()) { const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell; std::vector local_dof_indices (dofs_per_cell); @@ -1017,7 +1017,7 @@ namespace DoFRenumbering numbers::invalid_unsigned_int) == renumbering.end(), ExcInternalError()); - + dof_handler.renumber_dofs(renumbering); } diff --git a/deal.II/source/dofs/dof_tools.cc b/deal.II/source/dofs/dof_tools.cc index 591a4303d3..62792b0320 100644 --- a/deal.II/source/dofs/dof_tools.cc +++ b/deal.II/source/dofs/dof_tools.cc @@ -96,9 +96,7 @@ namespace DoFTools || (subdomain_id == cell->subdomain_id())) && - !cell->is_artificial() - && - !cell->is_ghost()) + cell->is_locally_owned()) { const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell; dofs_on_this_cell.resize (dofs_per_cell); @@ -225,9 +223,7 @@ namespace DoFTools || (subdomain_id == cell->subdomain_id())) && - !cell->is_artificial() - && - !cell->is_ghost()) + cell->is_locally_owned()) { const unsigned int fe_index = cell->active_fe_index(); const unsigned int dofs_per_cell =fe_collection[fe_index].dofs_per_cell; @@ -568,9 +564,7 @@ namespace DoFTools || (subdomain_id == cell->subdomain_id())) && - !cell->is_artificial() - && - !cell->is_ghost()) + cell->is_locally_owned()) { const unsigned int n_dofs_on_this_cell = cell->get_fe().dofs_per_cell; dofs_on_this_cell.resize (n_dofs_on_this_cell); @@ -768,7 +762,7 @@ namespace DoFTools typename DH::active_cell_iterator cell = dof.begin_active(), endc = dof.end(); for (; cell!=endc; ++cell) - if (!cell->is_ghost() && !cell->is_artificial()) + if (cell->is_locally_owned()) { cell->get_dof_indices (dofs_on_this_cell); // make sparsity pattern for this cell @@ -3383,7 +3377,7 @@ namespace DoFTools std::vector indices; for (typename DH::active_cell_iterator c=dof.begin_active(); c!=dof.end(); ++ c) - if (!c->is_artificial() && !c->is_ghost()) + if (c->is_locally_owned()) { const unsigned int fe_index = c->active_fe_index(); const unsigned int dofs_per_cell = c->get_fe().dofs_per_cell; @@ -4161,7 +4155,7 @@ namespace DoFTools typename DH::active_cell_iterator cell = dof_handler.begin_active(), endc = dof_handler.end(); for (; cell!=endc; ++cell) - if (!cell->is_ghost() && !cell->is_artificial()) + if (cell->is_locally_owned()) { dof_indices.resize(cell->get_fe().dofs_per_cell); cell->get_dof_indices(dof_indices); @@ -4670,7 +4664,7 @@ namespace DoFTools #ifdef DEAL_II_COMPILER_SUPPORTS_MPI const unsigned int dim = DH::dimension; const unsigned int spacedim = DH::space_dimension; - + if (const parallel::distributed::Triangulation * tria = (dynamic_cast*> (&dof_handler.get_tria()))) @@ -5021,7 +5015,7 @@ namespace DoFTools tasks.join_all (); } - + /** * This is a helper function that diff --git a/deal.II/source/grid/grid_tools.cc b/deal.II/source/grid/grid_tools.cc index 79ea68df19..b987daf18f 100644 --- a/deal.II/source/grid/grid_tools.cc +++ b/deal.II/source/grid/grid_tools.cc @@ -83,7 +83,7 @@ GridTools::diameter (const Triangulation &tria) Assert ((dynamic_cast*>(&tria) == 0), ExcNotImplemented()); - + // the algorithm used simply // traverses all cells and picks // out the boundary vertices. it @@ -142,7 +142,7 @@ GridTools::volume (const Triangulation &triangulation, = (dynamic_cast*>(&mapping) != 0 ? dynamic_cast*>(&mapping)->get_degree() : 1); - + // then initialize an appropriate quadrature formula const QGauss quadrature_formula (mapping_degree + 1); const unsigned int n_q_points = quadrature_formula.size(); @@ -159,7 +159,7 @@ GridTools::volume (const Triangulation &triangulation, // compute the integral quantities by quadrature for (; cell!=endc; ++cell) - if (!cell->is_ghost() && !cell->is_artificial()) + if (cell->is_locally_owned()) { fe_values.reinit (cell); for (unsigned int q=0; q &triangulation, global_volume = local_volume; #endif - return global_volume; + return global_volume; } diff --git a/deal.II/source/grid/tria.cc b/deal.II/source/grid/tria.cc index 705431cefe..e39dc92d71 100644 --- a/deal.II/source/grid/tria.cc +++ b/deal.II/source/grid/tria.cc @@ -13470,8 +13470,7 @@ bool Triangulation::prepare_coarsening_and_refinement () if (!cell->active() || (cell->active() && cell->refine_flag_set() && - !cell->is_ghost() && - !cell->is_artificial())) + cell->is_locally_owned())) { // check whether all // children are diff --git a/deal.II/source/numerics/data_out.cc b/deal.II/source/numerics/data_out.cc index f5bd839985..bf829e0863 100644 --- a/deal.II/source/numerics/data_out.cc +++ b/deal.II/source/numerics/data_out.cc @@ -1143,7 +1143,7 @@ DataOut::first_locally_owned_cell () // is a ghost or artificial cell while ((cell != this->dofs->end()) && (cell->has_children() == false) && - (cell->is_ghost() || cell->is_artificial())) + !cell->is_locally_owned()) cell = next_cell(cell); return cell; @@ -1159,7 +1159,7 @@ DataOut::next_locally_owned_cell (const typename DataOut::cell_i cell = next_cell(old_cell); while ((cell != this->dofs->end()) && (cell->has_children() == false) && - (cell->is_ghost() || cell->is_artificial())) + !cell->is_locally_owned()) cell = next_cell(cell); return cell; } diff --git a/deal.II/source/numerics/data_out_faces.cc b/deal.II/source/numerics/data_out_faces.cc index f051172aff..f9b6f37609 100644 --- a/deal.II/source/numerics/data_out_faces.cc +++ b/deal.II/source/numerics/data_out_faces.cc @@ -93,10 +93,9 @@ build_one_patch (const FaceDescriptor *cell_and_face, internal::DataOutFaces::ParallelData &data, DataOutBase::Patch &patch) { - Assert (!cell_and_face->first->is_ghost() && - !cell_and_face->first->is_artificial(), + Assert (cell_and_face->first->is_locally_owned(), ExcNotImplemented()); - + // we use the mapping to transform the // vertices. However, the mapping works on // cells, not faces, so transform the face @@ -180,10 +179,10 @@ build_one_patch (const FaceDescriptor *cell_and_face, if (update_flags & update_hessians) this->dof_data[dataset]->get_function_hessians (fe_patch_values, data.patch_hessians); - + if (update_flags & update_quadrature_points) - data.patch_evaluation_points = fe_patch_values.get_quadrature_points(); - + data.patch_evaluation_points = fe_patch_values.get_quadrature_points(); + postprocessor-> compute_derived_quantities_scalar(data.patch_values, data.patch_gradients, @@ -207,10 +206,10 @@ build_one_patch (const FaceDescriptor *cell_and_face, if (update_flags & update_hessians) this->dof_data[dataset]->get_function_hessians (fe_patch_values, data.patch_hessians_system); - + if (update_flags & update_quadrature_points) data.patch_evaluation_points = fe_patch_values.get_quadrature_points(); - + postprocessor-> compute_derived_quantities_vector(data.patch_values_system, data.patch_gradients_system, diff --git a/deal.II/source/numerics/data_out_rotation.cc b/deal.II/source/numerics/data_out_rotation.cc index a9523cc64e..f7dba804c1 100644 --- a/deal.II/source/numerics/data_out_rotation.cc +++ b/deal.II/source/numerics/data_out_rotation.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -112,8 +112,7 @@ build_one_patch (const cell_iterator *cell, return; } - Assert (!(*cell)->is_ghost() && - !(*cell)->is_artificial(), + Assert ((*cell)->is_locally_owned(), ExcNotImplemented()); const unsigned int n_patches_per_circle = data.n_patches_per_circle; diff --git a/deal.II/source/numerics/data_out_stack.cc b/deal.II/source/numerics/data_out_stack.cc index d671e72bb1..685c0db07e 100644 --- a/deal.II/source/numerics/data_out_stack.cc +++ b/deal.II/source/numerics/data_out_stack.cc @@ -65,17 +65,17 @@ void DataOutStack::new_parameter_value (const double p, i!=cell_data.end(); ++i) Assert (i->data.size() == 0, ExcDataNotCleared ()); - + } template -void DataOutStack::attach_dof_handler (const DH& dof) +void DataOutStack::attach_dof_handler (const DH& dof) { // Check consistency of redundant // template parameter Assert (dim==DH::dimension, ExcDimensionMismatch(dim, DH::dimension)); - + dof_handler = &dof; } @@ -114,7 +114,7 @@ void DataOutStack::declare_data_vector (const std::vectornames.size(); ++i) Assert (*name != data_set->names[i], ExcNameAlreadyUsed(*name)); }; - + switch (vector_type) { case dof_vector: @@ -185,7 +185,7 @@ void DataOutStack::add_data_vector (const Vector &vec, names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789_<>()"))); - + if (vec.size() == dof_handler->n_dofs()) { typename std::vector::iterator data_vector=dof_data.begin(); @@ -231,22 +231,22 @@ void DataOutStack::add_data_vector (const Vector &vec, template -void DataOutStack::build_patches (const unsigned int nnnn_subdivisions) +void DataOutStack::build_patches (const unsigned int nnnn_subdivisions) { // this is mostly copied from the // DataOut class unsigned int n_subdivisions = (nnnn_subdivisions != 0) ? nnnn_subdivisions : this->default_subdivisions; - + Assert (n_subdivisions >= 1, - ExcInvalidNumberOfSubdivisions(n_subdivisions)); + ExcInvalidNumberOfSubdivisions(n_subdivisions)); Assert (dof_handler != 0, ExcNoDoFHandlerSelected()); - + const unsigned int n_components = dof_handler->get_fe().n_components(); const unsigned int n_datasets = dof_data.size() * n_components + cell_data.size(); - + // first count the cells we want to // create patches of and make sure // there is enough memory for that @@ -265,7 +265,7 @@ void DataOutStack::build_patches (const unsigned int nnnn_subdi // cell to these points QTrapez<1> q_trapez; QIterated patch_points (q_trapez, n_subdivisions); - + // create collection objects from // single quadratures, // and finite elements. if we have @@ -275,7 +275,7 @@ void DataOutStack::build_patches (const unsigned int nnnn_subdi // shallow copy instead const hp::QCollection q_collection (patch_points); const hp::FECollection fe_collection(dof_handler->get_fe()); - + hp::FEValues x_fe_patch_values (fe_collection, q_collection, update_values); @@ -302,8 +302,7 @@ void DataOutStack::build_patches (const unsigned int nnnn_subdi for (typename DH::active_cell_iterator cell=dof_handler->begin_active(); cell != dof_handler->end(); ++cell, ++patch, ++cell_number) { - Assert (!cell->is_ghost() && - !cell->is_artificial(), + Assert (cell->is_locally_owned(), ExcNotImplemented()); Assert (patch != patches.end(), ExcInternalError()); @@ -329,7 +328,7 @@ void DataOutStack::build_patches (const unsigned int nnnn_subdi patch->vertices[3] = Point(cell->vertex(1)(0), parameter); break; - + case 2: patch->vertices[0] = Point(cell->vertex(0)(0), cell->vertex(0)(1), @@ -356,7 +355,7 @@ void DataOutStack::build_patches (const unsigned int nnnn_subdi cell->vertex(3)(1), parameter); break; - + default: Assert (false, ExcNotImplemented()); }; @@ -373,7 +372,7 @@ void DataOutStack::build_patches (const unsigned int nnnn_subdi x_fe_patch_values.reinit (cell); const FEValues &fe_patch_values = x_fe_patch_values.get_present_fe_values (); - + // first fill dof_data for (unsigned int dataset=0; dataset::finish_parameter_value () for (typename std::vector::iterator i=dof_data.begin(); i!=dof_data.end(); ++i) i->data.reinit (0); - + for (typename std::vector::iterator i=cell_data.begin(); i!=cell_data.end(); ++i) i->data.reinit (0); @@ -463,7 +462,7 @@ std::vector DataOutStack::get_dataset_names () con for (typename std::vector::const_iterator dataset=cell_data.begin(); dataset!=cell_data.end(); ++dataset) names.insert (names.end(), dataset->names.begin(), dataset->names.end()); - + return names; } -- 2.39.5