From 095d9afcf17198827cd1bed17b008f818a5a97af Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Sat, 24 Jun 2017 02:22:25 -0600 Subject: [PATCH] Introduce new constructors for NumberCache. --- include/deal.II/dofs/number_cache.h | 24 +++++++++++++++++ source/dofs/number_cache.cc | 41 +++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/include/deal.II/dofs/number_cache.h b/include/deal.II/dofs/number_cache.h index 16c44d7e2c..bee2368e83 100644 --- a/include/deal.II/dofs/number_cache.h +++ b/include/deal.II/dofs/number_cache.h @@ -51,6 +51,30 @@ namespace internal */ NumberCache (NumberCache &&) = default; + /** + * Create a NumberCache object that corresponds to a sequential + * DoFHandler object in which a single processor stores all + * degrees of freedom. + */ + NumberCache (const types::global_dof_index n_global_dofs); + + + /** + * Create a NumberCache object that corresponds to a parallel + * DoFHandler object with as many processors as the size of the + * given argument, in which each processor stores the degrees + * of freedom indicated in the corresponding element of the + * vector passed as first argument. The second argument indicates + * the rank among all participating processors the current + * processor has, so that we can set the @p locally_owned_dofs + * and @p n_locally_owned_dofs fields. + * + * All other fields stored by the current object can be and are computed + * from the argument. + */ + NumberCache (const std::vector &locally_owned_dofs_per_processor, + const unsigned int my_rank); + /** * Copy operator. Simply copy all members of the referenced * object to the current object. diff --git a/source/dofs/number_cache.cc b/source/dofs/number_cache.cc index ea16f3d0e8..993a0c4811 100644 --- a/source/dofs/number_cache.cc +++ b/source/dofs/number_cache.cc @@ -16,6 +16,9 @@ #include #include +#include + + DEAL_II_NAMESPACE_OPEN namespace internal @@ -29,6 +32,44 @@ namespace internal {} + + NumberCache::NumberCache (const types::global_dof_index n_global_dofs) + : + n_global_dofs (n_global_dofs), + n_locally_owned_dofs (n_global_dofs), + locally_owned_dofs (complete_index_set(n_global_dofs)), + n_locally_owned_dofs_per_processor (1, n_global_dofs), + locally_owned_dofs_per_processor (1, complete_index_set(n_global_dofs)) + {} + + + + NumberCache::NumberCache (const std::vector &locally_owned_dofs_per_processor, + const unsigned int my_rank) + : + locally_owned_dofs_per_processor (locally_owned_dofs_per_processor) + { + const unsigned int n_procs = locally_owned_dofs_per_processor.size(); + + // compress IndexSet representation before using it for anything else + for (unsigned int p=0; p