* <tt>keep_constrained_dofs</tt>
* needs to be set to
* <tt>false</tt>.
+ *
+ * If the @p subdomain_id parameter is
+ * given, the sparsity pattern is built
+ * only on cells that have a subdomain_id
+ * equal to the given argument. This is
+ * useful in parallel contexts where the
+ * matrix and sparsity pattern (for
+ * example a
+ * TrilinosWrappers::SparsityPattern) may
+ * be distributed and not every MPI
+ * process needs to build the entire
+ * sparsity pattern; in that case, it is
+ * sufficient if every process only
+ * builds that part of the sparsity
+ * pattern that corresponds to the
+ * subdomain_id for which it is
+ * responsible. This feature is
+ * @ref step_32 "step-32".
*/
template <class DH, class SparsityPattern>
static
make_sparsity_pattern (const DH &dof,
SparsityPattern &sparsity_pattern,
const ConstraintMatrix &constraints = ConstraintMatrix(),
- const bool keep_constrained_dofs = true);
+ const bool keep_constrained_dofs = true,
+ const unsigned int subdomain_id = numbers::invalid_unsigned_int);
/**
* Locate non-zero entries for
* <tt>keep_constrained_dofs</tt>
* needs to be set to
* <tt>false</tt>.
+ *
+ * If the @p subdomain_id parameter is
+ * given, the sparsity pattern is built
+ * only on cells that have a subdomain_id
+ * equal to the given argument. This is
+ * useful in parallel contexts where the
+ * matrix and sparsity pattern (for
+ * example a
+ * TrilinosWrappers::SparsityPattern) may
+ * be distributed and not every MPI
+ * process needs to build the entire
+ * sparsity pattern; in that case, it is
+ * sufficient if every process only
+ * builds that part of the sparsity
+ * pattern that corresponds to the
+ * subdomain_id for which it is
+ * responsible. This feature is
+ * @ref step_32 "step-32".
*/
template <class DH, class SparsityPattern>
static
const Table<2, Coupling> &coupling,
SparsityPattern &sparsity_pattern,
const ConstraintMatrix &constraints = ConstraintMatrix(),
- const bool keep_constrained_dofs = true);
+ const bool keep_constrained_dofs = true,
+ const unsigned int subdomain_id = numbers::invalid_unsigned_int);
/**
* @deprecated This is the old
DoFTools::make_sparsity_pattern (const DH &dof,
SparsityPattern &sparsity,
const ConstraintMatrix &constraints,
- const bool keep_constrained_dofs)
+ const bool keep_constrained_dofs,
+ const unsigned int subdomain_id)
{
const unsigned int n_dofs = dof.n_dofs();
// only have to do the work if the
// current cell is owned by the calling
// processor. Otherwise, just continue.
- //
- // TODO: here, we should actually check
- // the communicator of the sparsity
- // pattern, not MPI_COMM_WORLD as the
- // Utilities function does!
- for (; cell!=endc; ++cell)
-#ifdef DEAL_II_USE_TRILINOS
- if ((types_are_equal<SparsityPattern,TrilinosWrappers::SparsityPattern>::value
- ||
- types_are_equal<SparsityPattern,TrilinosWrappers::BlockSparsityPattern>::value)
- &&
- cell->subdomain_id() !=
- Utilities::Trilinos::get_this_mpi_process(Utilities::Trilinos::comm_world()))
- continue;
- else
-
-#endif
- {
- const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell;
- dofs_on_this_cell.resize (dofs_per_cell);
- cell->get_dof_indices (dofs_on_this_cell);
-
- // make sparsity pattern for this
- // cell. if no constraints pattern was
- // given, then the following call acts
- // as if simply no constraints existed
- constraints.add_entries_local_to_global (dofs_on_this_cell,
- sparsity,
- keep_constrained_dofs);
- }
+ for (; cell!=endc; ++cell)
+ if ((subdomain_id == numbers::invalid_unsigned_int)
+ ||
+ (subdomain_id == cell->subdomain_id()))
+ {
+ const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell;
+ dofs_on_this_cell.resize (dofs_per_cell);
+ cell->get_dof_indices (dofs_on_this_cell);
+
+ // make sparsity pattern for this
+ // cell. if no constraints pattern was
+ // given, then the following call acts
+ // as if simply no constraints existed
+ constraints.add_entries_local_to_global (dofs_on_this_cell,
+ sparsity,
+ keep_constrained_dofs);
+ }
}
template <class DH, class SparsityPattern>
void
-DoFTools::make_sparsity_pattern (
- const DH &dof,
- const Table<2,Coupling> &couplings,
- SparsityPattern &sparsity,
- const ConstraintMatrix &constraints,
- const bool keep_constrained_dofs)
+DoFTools::make_sparsity_pattern (const DH &dof,
+ const Table<2,Coupling> &couplings,
+ SparsityPattern &sparsity,
+ const ConstraintMatrix &constraints,
+ const bool keep_constrained_dofs,
+ const unsigned int subdomain_id)
{
const unsigned int n_dofs = dof.n_dofs();
// current cell is owned by the calling
// processor. Otherwise, just continue.
for (; cell!=endc; ++cell)
-#ifdef DEAL_II_USE_TRILINOS
- if ((types_are_equal<SparsityPattern,TrilinosWrappers::SparsityPattern>::value
- ||
- types_are_equal<SparsityPattern,TrilinosWrappers::BlockSparsityPattern>::value)
- &&
- cell->subdomain_id() !=
- Utilities::Trilinos::get_this_mpi_process(Utilities::Trilinos::comm_world()))
- continue;
- else
-
-#endif
- {
- const unsigned int fe_index
- = cell->active_fe_index();
+ if ((subdomain_id == numbers::invalid_unsigned_int)
+ ||
+ (subdomain_id == cell->subdomain_id()))
+ {
+ const unsigned int fe_index
+ = cell->active_fe_index();
- const unsigned int dofs_per_cell
- = fe_collection[fe_index].dofs_per_cell;
+ const unsigned int dofs_per_cell
+ = fe_collection[fe_index].dofs_per_cell;
- dofs_on_this_cell.resize (dofs_per_cell);
- cell->get_dof_indices (dofs_on_this_cell);
+ dofs_on_this_cell.resize (dofs_per_cell);
+ cell->get_dof_indices (dofs_on_this_cell);
- // make sparsity pattern for this
- // cell. if no constraints pattern was
- // given, then the following call acts
- // as if simply no constraints existed
- constraints.add_entries_local_to_global (dofs_on_this_cell,
- sparsity,
- keep_constrained_dofs,
- dof_mask[fe_index]);
- }
+ // make sparsity pattern for this
+ // cell. if no constraints pattern was
+ // given, then the following call acts
+ // as if simply no constraints existed
+ constraints.add_entries_local_to_global (dofs_on_this_cell,
+ sparsity,
+ keep_constrained_dofs,
+ dof_mask[fe_index]);
+ }
}
(const DoFHandler<deal_II_dimension,deal_II_dimension> &dof,
SP &sparsity,
const ConstraintMatrix &,
- const bool);
+ const bool,
+ const unsigned int);
template void
DoFTools::make_sparsity_pattern<hp::DoFHandler<deal_II_dimension,deal_II_dimension>, SP>
(const hp::DoFHandler<deal_II_dimension,deal_II_dimension> &dof,
SP &sparsity,
const ConstraintMatrix &,
- const bool);
+ const bool,
+ const unsigned int);
template void
DoFTools::make_sparsity_pattern<DoFHandler<deal_II_dimension,deal_II_dimension>, SP>
const Table<2,Coupling>&,
SP &,
const ConstraintMatrix &,
- const bool);
+ const bool,
+ const unsigned int);
template void
DoFTools::make_sparsity_pattern<hp::DoFHandler<deal_II_dimension,deal_II_dimension>, SP>
const Table<2,Coupling>&,
SP &,
const ConstraintMatrix &,
- const bool);
+ const bool,
+ const unsigned int);
template void
DoFTools::make_sparsity_pattern<DoFHandler<deal_II_dimension,deal_II_dimension>, SP>
(const DoFHandler<deal_II_dimension,deal_II_dimension+1> &dof,
SP &sparsity,
const ConstraintMatrix &,
- const bool);
+ const bool,
+ const unsigned int);
template void
DoFTools::make_sparsity_pattern<hp::DoFHandler<deal_II_dimension,deal_II_dimension+1>, SP>
(const hp::DoFHandler<deal_II_dimension,deal_II_dimension+1> &dof,
SP &sparsity,
const ConstraintMatrix &,
- const bool);
+ const bool,
+ const unsigned int);
template void
DoFTools::make_sparsity_pattern<DoFHandler<deal_II_dimension,deal_II_dimension+1>, SP>
const Table<2,Coupling>&,
SP &,
const ConstraintMatrix &,
- const bool);
+ const bool,
+ const unsigned int);
template void
DoFTools::make_sparsity_pattern<hp::DoFHandler<deal_II_dimension,deal_II_dimension+1>, SP>
const Table<2,Coupling>&,
SP &,
const ConstraintMatrix &,
- const bool);
+ const bool,
+ const unsigned int);
template void
DoFTools::make_sparsity_pattern<DoFHandler<deal_II_dimension,deal_II_dimension+1>, SP>