#include <deal.II/base/config.h>
#include <deal.II/base/exceptions.h>
#include <deal.II/base/template_constraints.h>
+#include <deal.II/dofs/dof_tools.h>
#include <vector>
#include <map>
extract_locally_relevant_dofs (const DH &dof_handler,
IndexSet &dof_set);
+ template <class DH>
+ IndexSet
+ locally_owned_dofs_with_subdomain (const DH &dof_handler,
+ const types::subdomain_id subdomain );
+
/**
* For each DoF, return in the output array to which subdomain (as
* given by the <tt>cell->subdomain_id()</tt> function) it
#include <deal.II/dofs/function_map.h>
#include <deal.II/dofs/dof_iterator_selector.h>
#include <deal.II/dofs/number_cache.h>
+//#include <deal.II/dofs/dof_tools.h>
#include <deal.II/hp/fe_collection.h>
#include <vector>
policy_name = "Policy::Sequential<";
else if (dynamic_cast<const typename dealii::internal::DoFHandler::Policy::ParallelDistributed<dim,spacedim>*>(&policy))
policy_name = "Policy::ParallelDistributed<";
+ else if (dynamic_cast<const typename dealii::internal::DoFHandler::Policy::ParallelShared<dim,spacedim>*>(&policy))
+ policy_name = "Policy::ParallelShared<";
else
AssertThrow(false, ExcNotImplemented());
policy_name += Utilities::int_to_string(dim)+
// decide whether we need a
// sequential or a parallel
// distributed policy
+ if (dynamic_cast<const parallel::shared::Triangulation< dim, spacedim>*>
+ (&tria)
+ != 0)
+ policy.reset (new internal::DoFHandler::Policy::ParallelShared<dim,spacedim>());
+ else
if (dynamic_cast<const parallel::distributed::Triangulation< dim, spacedim >*>
(&tria)
== 0)
{
NumberCache number_cache = Sequential<dim,spacedim>::distribute_dofs (dof_handler);
//correct number_cache:
-
-
+ number_cache.locally_owned_dofs = dealii::DoFTools::locally_owned_dofs_with_subdomain(dof_handler,dof_handler.get_tria().locally_owned_subdomain() );
return number_cache;
}
distribute_mg_dofs (DoFHandler<dim,spacedim> &dof_handler,
std::vector<NumberCache> &number_caches) const
{
- NumberCache number_cache = Sequential<dim,spacedim>:: distribute_mg_dofs (dof_handler, number_caches);
+ Sequential<dim,spacedim>:: distribute_mg_dofs (dof_handler, number_caches);
Assert(false,ExcMessage("Not implemented"));
- return number_cache;
}
template <int dim, int spacedim>
{
NumberCache number_cache = Sequential<dim,spacedim>::renumber_dofs (new_numbers,dof_handler);
//correct number_cache:
-
+ number_cache.locally_owned_dofs = dealii::DoFTools::locally_owned_dofs_with_subdomain(dof_handler,dof_handler.get_tria().locally_owned_subdomain() );
return number_cache;
}
\{
template class PolicyBase<deal_II_dimension,deal_II_dimension>;
template class Sequential<deal_II_dimension,deal_II_dimension>;
+ template class ParallelShared<deal_II_dimension,deal_II_dimension>;
template class ParallelDistributed<deal_II_dimension,deal_II_dimension>;
#if deal_II_dimension==1 || deal_II_dimension==2
template class PolicyBase<deal_II_dimension,deal_II_dimension+1>;
template class Sequential<deal_II_dimension,deal_II_dimension+1>;
+ template class ParallelShared<deal_II_dimension,deal_II_dimension+1>;
template class ParallelDistributed<deal_II_dimension,deal_II_dimension+1>;
#endif
#if deal_II_dimension==3
template class PolicyBase<1,3>;
template class Sequential<1,3>;
+ template class ParallelShared<1,3>;
template class ParallelDistributed<1,3>;
#endif
\}
active_fe_indices[index] = cell->active_fe_index();
}
-
+ template <class DH>
+ IndexSet
+ locally_owned_dofs_with_subdomain (const DH &dof_handler,
+ const types::subdomain_id subdomain )
+ {
+ IndexSet index_set (dof_handler.n_dofs());
+ std::vector< types::subdomain_id > subdomain_association(dof_handler.n_dofs());
+ DoFTools::get_subdomain_association(dof_handler,subdomain_association);
+ types::global_dof_index i_min=0, i_max_plus_1=0;
+
+ //loop over subdomain_association
+ //and populate IndexSet when
+ //a given subdomain is found
+ bool found_start = false;
+ for (types::global_dof_index ind = 0; ind < subdomain_association.size(); ind++)
+ {
+ if (!found_start && (subdomain_association[ind]== subdomain) )
+ {
+ found_start = true;
+ i_min = ind;
+ }
+ if (found_start && (subdomain_association[ind] != subdomain) )
+ {
+ found_start = false;
+ i_max_plus_1 = ind;
+ index_set.add_range(i_min,i_max_plus_1);
+ }
+ }
+
+ // we have found the starting element, but not the end.
+ // the last element must have the same subdomain id,
+ // thus use it to add the range
+ if (found_start) {
+ index_set.add_range(i_min,subdomain_association.size());
+ }
+ index_set.compress();
+ return index_set;
+ }
template <class DH>
void
DoFTools::get_subdomain_association<hp::DoFHandler<deal_II_dimension> >
(const hp::DoFHandler<deal_II_dimension> &dof_handler,
std::vector<types::subdomain_id> &subdomain_association);
-
+
+template
+IndexSet
+DoFTools::locally_owned_dofs_with_subdomain<DoFHandler<deal_II_dimension> >
+(const DoFHandler<deal_II_dimension> &dof_handler,
+ const types::subdomain_id subdomain);
+template
+IndexSet
+DoFTools::locally_owned_dofs_with_subdomain<hp::DoFHandler<deal_II_dimension> >
+(const hp::DoFHandler<deal_II_dimension> &dof_handler,
+ const types::subdomain_id subdomain);
template
unsigned int
DoFTools::get_subdomain_association<hp::DoFHandler<deal_II_dimension,deal_II_dimension+1> >
(const hp::DoFHandler<deal_II_dimension,deal_II_dimension+1> &dof_handler,
std::vector<types::subdomain_id> &subdomain_association);
+
+template
+IndexSet
+DoFTools::locally_owned_dofs_with_subdomain<DoFHandler<deal_II_dimension,deal_II_dimension+1> >
+(const DoFHandler<deal_II_dimension,deal_II_dimension+1> &dof_handler,
+ const types::subdomain_id subdomain);
+template
+IndexSet
+DoFTools::locally_owned_dofs_with_subdomain<hp::DoFHandler<deal_II_dimension,deal_II_dimension+1> >
+(const hp::DoFHandler<deal_II_dimension,deal_II_dimension+1> &dof_handler,
+ const types::subdomain_id subdomain);
template
void
DoFTools::get_subdomain_association<hp::DoFHandler<1,3> >
(const hp::DoFHandler<1,3> &dof_handler,
std::vector<types::subdomain_id> &subdomain_association);
+
+template
+IndexSet
+DoFTools::locally_owned_dofs_with_subdomain<DoFHandler<1,3> >
+(const DoFHandler<1,3> &dof_handler,
+ const types::subdomain_id subdomain);
+template
+IndexSet
+DoFTools::locally_owned_dofs_with_subdomain<hp::DoFHandler<1,3> >
+(const hp::DoFHandler<1,3> &dof_handler,
+ const types::subdomain_id subdomain);
template
unsigned int
number_cache.n_global_dofs = next_free_dof;
number_cache.n_locally_owned_dofs = number_cache.n_global_dofs;
- number_cache.locally_owned_dofs
- = IndexSet (number_cache.n_global_dofs);
- number_cache.locally_owned_dofs.add_range (0,
- number_cache.n_global_dofs);
+ if (dynamic_cast<const parallel::shared::Triangulation< dim, spacedim >*>
+ (&this->get_tria())
+ == 0) {
+ number_cache.locally_owned_dofs
+ = IndexSet (number_cache.n_global_dofs);
+ number_cache.locally_owned_dofs.add_range (0,
+ number_cache.n_global_dofs);
+ } else {
+ Assert(false, ExcMessage("not implemented"));
+ //number_cache.locally_owned_dofs = dealii::DoFTools::locally_owned_dofs_with_subdomain(this,tria->locally_owned_subdomain() );
+ }
Assert (number_cache.n_global_dofs < std::numeric_limits<unsigned int>::max (),
ExcMessage ("Global number of degrees of freedom is too large."));
number_cache.n_locally_owned_dofs_per_processor