From c48c7da42e4a200c47774cf0dd2ba07ff4c121e6 Mon Sep 17 00:00:00 2001 From: heister Date: Fri, 10 Aug 2012 08:39:21 +0000 Subject: [PATCH] types::global_dof_index git-svn-id: https://svn.dealii.org/branches/branch_bigger_global_dof_indices_3@25855 0785d39b-7218-0410-832d-ea1e28bc413d --- .../include/deal.II/dofs/dof_handler_policy.h | 12 +-- deal.II/source/dofs/dof_handler_policy.cc | 99 +++++++++---------- 2 files changed, 55 insertions(+), 56 deletions(-) diff --git a/deal.II/include/deal.II/dofs/dof_handler_policy.h b/deal.II/include/deal.II/dofs/dof_handler_policy.h index 65c9044016..fc589648e3 100644 --- a/deal.II/include/deal.II/dofs/dof_handler_policy.h +++ b/deal.II/include/deal.II/dofs/dof_handler_policy.h @@ -65,7 +65,7 @@ namespace internal */ virtual NumberCache - distribute_dofs (const unsigned int offset, + distribute_dofs (const types::global_dof_index offset, dealii::DoFHandler &dof_handler) const = 0; /** @@ -74,7 +74,7 @@ namespace internal */ virtual NumberCache - renumber_dofs (const std::vector &new_numbers, + renumber_dofs (const std::vector &new_numbers, dealii::DoFHandler &dof_handler) const = 0; }; @@ -95,7 +95,7 @@ namespace internal */ virtual NumberCache - distribute_dofs (const unsigned int offset, + distribute_dofs (const types::global_dof_index offset, dealii::DoFHandler &dof_handler) const; /** @@ -104,7 +104,7 @@ namespace internal */ virtual NumberCache - renumber_dofs (const std::vector &new_numbers, + renumber_dofs (const std::vector &new_numbers, dealii::DoFHandler &dof_handler) const; }; @@ -126,7 +126,7 @@ namespace internal */ virtual NumberCache - distribute_dofs (const unsigned int offset, + distribute_dofs (const types::global_dof_index offset, dealii::DoFHandler &dof_handler) const; /** @@ -135,7 +135,7 @@ namespace internal */ virtual NumberCache - renumber_dofs (const std::vector &new_numbers, + renumber_dofs (const std::vector &new_numbers, dealii::DoFHandler &dof_handler) const; }; } diff --git a/deal.II/source/dofs/dof_handler_policy.cc b/deal.II/source/dofs/dof_handler_policy.cc index 241199d891..f9577f2800 100644 --- a/deal.II/source/dofs/dof_handler_policy.cc +++ b/deal.II/source/dofs/dof_handler_policy.cc @@ -58,10 +58,10 @@ namespace internal */ template static - unsigned int + types::global_dof_index distribute_dofs_on_cell (const DoFHandler<1,spacedim> &dof_handler, const typename DoFHandler<1,spacedim>::active_cell_iterator &cell, - unsigned int next_free_dof) + types::global_dof_index next_free_dof) { // distribute dofs of vertices @@ -102,10 +102,10 @@ namespace internal template static - unsigned int + types::global_dof_index distribute_dofs_on_cell (const DoFHandler<2,spacedim> &dof_handler, const typename DoFHandler<2,spacedim>::active_cell_iterator &cell, - unsigned int next_free_dof) + types::global_dof_index next_free_dof) { if (dof_handler.get_fe().dofs_per_vertex > 0) // number dofs on vertices @@ -149,10 +149,10 @@ namespace internal template static - unsigned int + types::global_dof_index distribute_dofs_on_cell (const DoFHandler<3,spacedim> &dof_handler, const typename DoFHandler<3,spacedim>::active_cell_iterator &cell, - unsigned int next_free_dof) + types::global_dof_index next_free_dof) { if (dof_handler.get_fe().dofs_per_vertex > 0) // number dofs on vertices @@ -219,13 +219,12 @@ namespace internal * the corresponding * argument is not equal to * types::invalid_subdomain_id. Return - * the total number of dofs - * returned. + * the next free dof index. */ template static - unsigned int - distribute_dofs (const unsigned int offset, + types::global_dof_index + distribute_dofs (const types::global_dof_index offset, const types::subdomain_id_t subdomain_id, DoFHandler &dof_handler) { @@ -245,7 +244,7 @@ namespace internal tria.save_user_flags(user_flags); const_cast &>(tria).clear_user_flags (); - unsigned int next_free_dof = offset; + types::global_dof_index next_free_dof = offset; typename DoFHandler::active_cell_iterator cell = dof_handler.begin_active(), endc = dof_handler.end(); @@ -293,7 +292,7 @@ namespace internal template static void - renumber_dofs (const std::vector &new_numbers, + renumber_dofs (const std::vector &new_numbers, const IndexSet &, DoFHandler<1,spacedim> &dof_handler, const bool check_validity) @@ -308,7 +307,7 @@ namespace internal // numbers may be invalid_dof_index, // namely when the appropriate // vertex/line/etc is unused - for (std::vector::iterator + for (std::vector::iterator i=dof_handler.vertex_dofs.begin(); i!=dof_handler.vertex_dofs.end(); ++i) if (*i != DoFHandler<1,spacedim>::invalid_dof_index) @@ -325,7 +324,7 @@ namespace internal ExcInternalError ()); for (unsigned int level=0; level::iterator + for (std::vector::iterator i=dof_handler.levels[level]->lines.dofs.begin(); i!=dof_handler.levels[level]->lines.dofs.end(); ++i) if (*i != DoFHandler<1,spacedim>::invalid_dof_index) @@ -345,9 +344,9 @@ namespace internal template static void - renumber_dofs (const std::vector &new_numbers, + renumber_dofs (const std::vector &new_numbers, const IndexSet &indices, - DoFHandler<2,spacedim> &dof_handler, + DoFHandler<2,spacedim> &dof_handler, const bool check_validity) { // note that we can not use cell @@ -360,7 +359,7 @@ namespace internal // numbers may be invalid_dof_index, // namely when the appropriate // vertex/line/etc is unused - for (std::vector::iterator + for (std::vector::iterator i=dof_handler.vertex_dofs.begin(); i!=dof_handler.vertex_dofs.end(); ++i) if (*i != DoFHandler<2,spacedim>::invalid_dof_index) @@ -377,7 +376,7 @@ namespace internal == false, ExcInternalError ()); - for (std::vector::iterator + for (std::vector::iterator i=dof_handler.faces->lines.dofs.begin(); i!=dof_handler.faces->lines.dofs.end(); ++i) if (*i != DoFHandler<2,spacedim>::invalid_dof_index) @@ -387,7 +386,7 @@ namespace internal for (unsigned int level=0; level::iterator + for (std::vector::iterator i=dof_handler.levels[level]->quads.dofs.begin(); i!=dof_handler.levels[level]->quads.dofs.end(); ++i) if (*i != DoFHandler<2,spacedim>::invalid_dof_index) @@ -409,7 +408,7 @@ namespace internal template static void - renumber_dofs (const std::vector &new_numbers, + renumber_dofs (const std::vector &new_numbers, const IndexSet &indices, DoFHandler<3,spacedim> &dof_handler, const bool check_validity) @@ -424,7 +423,7 @@ namespace internal // numbers may be invalid_dof_index, // namely when the appropriate // vertex/line/etc is unused - for (std::vector::iterator + for (std::vector::iterator i=dof_handler.vertex_dofs.begin(); i!=dof_handler.vertex_dofs.end(); ++i) if (*i != DoFHandler<3,spacedim>::invalid_dof_index) @@ -441,14 +440,14 @@ namespace internal == false, ExcInternalError ()); - for (std::vector::iterator + for (std::vector::iterator i=dof_handler.faces->lines.dofs.begin(); i!=dof_handler.faces->lines.dofs.end(); ++i) if (*i != DoFHandler<3,spacedim>::invalid_dof_index) *i = ((indices.n_elements() == 0) ? new_numbers[*i] : new_numbers[indices.index_within_set(*i)]); - for (std::vector::iterator + for (std::vector::iterator i=dof_handler.faces->quads.dofs.begin(); i!=dof_handler.faces->quads.dofs.end(); ++i) if (*i != DoFHandler<3,spacedim>::invalid_dof_index) @@ -458,7 +457,7 @@ namespace internal for (unsigned int level=0; level::iterator + for (std::vector::iterator i=dof_handler.levels[level]->hexes.dofs.begin(); i!=dof_handler.levels[level]->hexes.dofs.end(); ++i) if (*i != DoFHandler<3,spacedim>::invalid_dof_index) @@ -492,10 +491,10 @@ namespace internal template NumberCache Sequential:: - distribute_dofs (const unsigned int offset, + distribute_dofs (const types::global_dof_index offset, DoFHandler &dof_handler) const { - const unsigned int n_dofs = + const types::global_dof_index n_dofs = Implementation::distribute_dofs (offset, types::invalid_subdomain_id, dof_handler); @@ -527,7 +526,7 @@ namespace internal template NumberCache Sequential:: - renumber_dofs (const std::vector &new_numbers, + renumber_dofs (const std::vector &new_numbers, dealii::DoFHandler &dof_handler) const { Implementation::renumber_dofs (new_numbers, IndexSet(0), @@ -584,7 +583,7 @@ namespace internal { std::vector tree_index; std::vector::quadrant> quadrants; - std::vector dofs; + std::vector dofs; unsigned int bytes_for_buffer () const { @@ -592,7 +591,7 @@ namespace internal tree_index.size() * sizeof(unsigned int) + quadrants.size() * sizeof(typename dealii::internal::p4est ::types::quadrant) + - dofs.size() * sizeof(unsigned int)); + dofs.size() * sizeof(types::global_dof_index)); } void pack_data (std::vector &buffer) const @@ -619,8 +618,8 @@ namespace internal std::memcpy(ptr, &dofs[0], - dofs.size() * sizeof(unsigned int)); - ptr += dofs.size() * sizeof(unsigned int); + dofs.size() * sizeof(types::global_dof_index)); + ptr += dofs.size() * sizeof(types::global_dof_index); Assert (ptr == &buffer[0]+buffer.size(), ExcInternalError()); @@ -694,7 +693,7 @@ namespace internal // this cell's dof_indices // need to be sent to // someone - std::vector + std::vector local_dof_indices (dealii_cell->get_fe().dofs_per_cell); dealii_cell->get_dof_indices (local_dof_indices); @@ -737,7 +736,7 @@ namespace internal const typename dealii::internal::p4est::types::quadrant &p4est_cell, const typename DoFHandler::cell_iterator &dealii_cell, const typename dealii::internal::p4est::types::quadrant &quadrant, - unsigned int * dofs) + types::global_dof_index * dofs) { if (internal::p4est::quadrant_is_equal(p4est_cell, quadrant)) { @@ -745,7 +744,7 @@ namespace internal Assert(dealii_cell->is_ghost(), ExcInternalError()); // update dof indices of cell - std::vector + std::vector dof_indices (dealii_cell->get_fe().dofs_per_cell); dealii_cell->update_cell_dof_indices_cache(); dealii_cell->get_dof_indices(dof_indices); @@ -914,7 +913,7 @@ namespace internal // that are going to send stuff to us std::set senders; { - std::vector local_dof_indices; + std::vector local_dof_indices; typename DoFHandler::active_cell_iterator cell, endc = dof_handler.end(); @@ -962,13 +961,13 @@ namespace internal memcpy(&cells, ptr, sizeof(unsigned int)); ptr+=sizeof(unsigned int); - //reinterpret too evil? + //TODO: reinterpret too evil? unsigned int * treeindex=reinterpret_cast(ptr); ptr+=cells*sizeof(unsigned int); typename dealii::internal::p4est::types::quadrant * quadrant =reinterpret_cast::quadrant *>(ptr); ptr+=cells*sizeof(typename dealii::internal::p4est::types::quadrant); - unsigned int * dofs=reinterpret_cast(ptr); + types::global_dof_index * dofs=reinterpret_cast(ptr); for (unsigned int c=0;c NumberCache ParallelDistributed:: - distribute_dofs (const unsigned int offset, + distribute_dofs (const types::global_dof_index offset, DoFHandler &dof_handler) const { Assert(offset==0, ExcNotImplemented()); @@ -1072,19 +1071,19 @@ namespace internal //* 1. distribute on own //* subdomain - const unsigned int n_initial_local_dofs = + const types::global_dof_index n_initial_local_dofs = Implementation::distribute_dofs (0, tr->locally_owned_subdomain(), dof_handler); //* 2. iterate over ghostcells and //kill dofs that are not owned //by us - std::vector renumbering(n_initial_local_dofs); + std::vector renumbering(n_initial_local_dofs); for (unsigned int i=0; i local_dof_indices; + std::vector local_dof_indices; typename DoFHandler::active_cell_iterator cell = dof_handler.begin_active(), @@ -1118,7 +1117,7 @@ namespace internal // make indices consecutive number_cache.n_locally_owned_dofs = 0; - for (std::vector::iterator it=renumbering.begin(); + for (std::vector::iterator it=renumbering.begin(); it!=renumbering.end(); ++it) if (*it != DoFHandler::invalid_dof_index) *it = number_cache.n_locally_owned_dofs++; @@ -1133,14 +1132,14 @@ namespace internal 1, MPI_UNSIGNED, tr->get_communicator()); - const unsigned int + const types::global_dof_index shift = std::accumulate (number_cache .n_locally_owned_dofs_per_processor.begin(), number_cache .n_locally_owned_dofs_per_processor.begin() + tr->locally_owned_subdomain(), 0); - for (std::vector::iterator it=renumbering.begin(); + for (std::vector::iterator it=renumbering.begin(); it!=renumbering.end(); ++it) if (*it != DoFHandler::invalid_dof_index) (*it) += shift; @@ -1171,7 +1170,7 @@ namespace internal // fill global_dof_indexsets number_cache.locally_owned_dofs_per_processor.resize(n_cpus); { - unsigned int lshift = 0; + types::global_dof_index lshift = 0; for (unsigned int i=0;i local_dof_indices; + std::vector local_dof_indices; typename DoFHandler::active_cell_iterator cell, endc = dof_handler.end(); @@ -1287,7 +1286,7 @@ namespace internal template NumberCache ParallelDistributed:: - renumber_dofs (const std::vector &new_numbers, + renumber_dofs (const std::vector &new_numbers, dealii::DoFHandler &dof_handler) const { Assert (new_numbers.size() == dof_handler.locally_owned_dofs().n_elements(), @@ -1312,9 +1311,9 @@ namespace internal number_cache.locally_owned_dofs = IndexSet (dof_handler.n_dofs()); if (dof_handler.locally_owned_dofs().n_elements()>0) { - std::vector::const_iterator it = new_numbers.begin(); + std::vector::const_iterator it = new_numbers.begin(); const unsigned int n_blocks = dof_handler.get_fe().n_blocks(); - std::vector > block_indices(n_blocks); + std::vector > block_indices(n_blocks); block_indices[0].first = *it++; block_indices[0].second = 1; unsigned int current_block = 0, n_filled_blocks = 1; @@ -1397,7 +1396,7 @@ namespace internal // mark not locally active DoFs as // invalid { - std::vector local_dof_indices; + std::vector local_dof_indices; typename DoFHandler::active_cell_iterator cell = dof_handler.begin_active(), -- 2.39.5