From: Wolfgang Bangerth Date: Mon, 7 Dec 2015 21:49:50 +0000 (-0600) Subject: Make instantiation of functions more uniform. X-Git-Tag: v8.4.0-rc2~168^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=000667af4cbc27515fd0b8cf747307c349fc480b;p=dealii.git Make instantiation of functions more uniform. Specifically, allow the script to also instantiate for parallel distributed and shared Triangulation classes. This also allows to significantly simplify the list of explicit instantiations for GridTools. --- diff --git a/cmake/config/template-arguments.in b/cmake/config/template-arguments.in index a28f358e92..15e46dc7b7 100644 --- a/cmake/config/template-arguments.in +++ b/cmake/config/template-arguments.in @@ -70,10 +70,18 @@ DOFHANDLER_TEMPLATES := { DoFHandler; hp::DoFHandler } TRIANGULATION_AND_DOFHANDLER_TEMPLATES := { Triangulation; + parallel::shared::Triangulation; + parallel::distributed::Triangulation; DoFHandler; hp::DoFHandler } +SEQUENTIAL_TRIANGULATION_AND_DOFHANDLERS := { Triangulation; + DoFHandler; + hp::DoFHandler } + TRIANGULATION_AND_DOFHANDLERS := { Triangulation; + parallel::shared::Triangulation; + parallel::distributed::Triangulation; DoFHandler; hp::DoFHandler } diff --git a/doc/news/changes.h b/doc/news/changes.h index adc6b2400b..fc61369fc3 100644 --- a/doc/news/changes.h +++ b/doc/news/changes.h @@ -482,7 +482,15 @@ inconvenience this causes.
    -
  1. Improved: both versions of distribute_sparsity_pattern are now plain, not +
  2. Improved: Many more functions in namespace GridTools and class + InterGridMap are now consistely instantiated also for types + parallel::distributed::Triangulation and parallel::shared::Triangulation. +
    + (Wolfgang Bangerth, 2015/12/07) +
  3. + +
  4. Improved: Both versions of SparsityTools::distribute_sparsity_pattern() + are now plain, not template, functions. This is not a breaking change because each function was instantiated for exactly one template argument.
    diff --git a/source/grid/grid_generator.cc b/source/grid/grid_generator.cc index d6d7768b91..5dacc7aed3 100644 --- a/source/grid/grid_generator.cc +++ b/source/grid/grid_generator.cc @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -4147,6 +4148,13 @@ namespace GridGenerator return tria; } + template + const Triangulation & + get_tria(const parallel::shared::Triangulation &tria) + { + return tria; + } + template class Container, int spacedim> const Triangulation & get_tria(const Container &container) @@ -4169,6 +4177,13 @@ namespace GridGenerator return tria; } + template + Triangulation & + get_tria(parallel::shared::Triangulation &tria) + { + return tria; + } + template class Container, int spacedim> const Triangulation & get_tria(Container &container) diff --git a/source/grid/grid_tools.inst.in b/source/grid/grid_tools.inst.in index 895ec9c46f..dbb8abb26e 100644 --- a/source/grid/grid_tools.inst.in +++ b/source/grid/grid_tools.inst.in @@ -52,7 +52,7 @@ for (X : TRIANGULATION_AND_DOFHANDLERS; deal_II_dimension : DIMENSIONS ; deal_II template std::list > get_finest_common_cells (const X &mesh_1, - const X &mesh_2); + const X &mesh_2); template @@ -65,76 +65,16 @@ for (X : TRIANGULATION_AND_DOFHANDLERS; deal_II_dimension : DIMENSIONS ; deal_II #endif } -// now also instantiate these functions for parallel::shared::Triangulation +// now also instantiate a few additional functions for parallel::distributed::Triangulation for (deal_II_dimension : DIMENSIONS ; deal_II_space_dimension : SPACE_DIMENSIONS) { #if deal_II_dimension <= deal_II_space_dimension namespace GridTools \{ - template - std::vector >::type> - compute_active_cell_halo_layer (const parallel::shared::Triangulation &, - const std_cxx11::function >::type&)> &); - \} - -#endif -} - - -// now also instantiate these functions for parallel::distributed::Triangulation -for (deal_II_dimension : DIMENSIONS ; deal_II_space_dimension : SPACE_DIMENSIONS) -{ - -#if deal_II_dimension <= deal_II_space_dimension - namespace GridTools \{ - - template - unsigned int - find_closest_vertex (const parallel::distributed::Triangulation &, - const Point &); - - template - std::vector >::type> - find_cells_adjacent_to_vertex(const parallel::distributed::Triangulation &, - const unsigned int); - template - dealii::internal::ActiveCellIterator >::type - find_active_cell_around_point (const parallel::distributed::Triangulation &, - const Point &p); - - template - std::pair >::type, Point > - find_active_cell_around_point (const Mapping &, - const parallel::distributed::Triangulation &, - const Point &); - - template - std::vector >::type> - compute_active_cell_halo_layer (const parallel::distributed::Triangulation &, - const std_cxx11::function >::type&)> &); - - template - std::vector >::type> - compute_ghost_cell_halo_layer (const parallel::distributed::Triangulation &); - template std::map compute_local_to_global_vertex_index_map(const parallel::distributed::Triangulation &triangulation); - - template - std::list::cell_iterator, parallel::distributed::Triangulation::cell_iterator> > - get_finest_common_cells (const parallel::distributed::Triangulation &mesh_1, - const parallel::distributed::Triangulation &mesh_2); - - - template - bool - have_same_coarse_mesh (const parallel::distributed::Triangulation &mesh_1, - const parallel::distributed::Triangulation &mesh_2); - \} #endif @@ -301,7 +241,13 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS } -for (X : TRIANGULATION_AND_DOFHANDLERS; deal_II_dimension : DIMENSIONS ; deal_II_space_dimension : SPACE_DIMENSIONS) +// instantiate the following functions only for the "sequential" containers. this +// is a misnomer here, however: the point is simply that we only instantiate +// these functions for certain *iterator* types, and the iterator types are +// the same for sequential and parallel containers; consequently, we get duplicate +// instantiation errors if we instantiate for *all* container types, rather than +// only the sequential ones +for (X : SEQUENTIAL_TRIANGULATION_AND_DOFHANDLERS; deal_II_dimension : DIMENSIONS ; deal_II_space_dimension : SPACE_DIMENSIONS) { #if deal_II_dimension <= deal_II_space_dimension namespace GridTools \{ diff --git a/source/grid/intergrid_map.cc b/source/grid/intergrid_map.cc index 8b10811c7a..d85bfab590 100644 --- a/source/grid/intergrid_map.cc +++ b/source/grid/intergrid_map.cc @@ -22,6 +22,8 @@ #include #include #include +#include +#include DEAL_II_NAMESPACE_OPEN @@ -45,7 +47,7 @@ namespace } -// specialization for grid==tria +// specialization for triangulation classes template unsigned int get_n_levels (const Triangulation &grid) @@ -54,6 +56,24 @@ namespace // we can ask directly. return grid.n_levels(); } + + template + unsigned int + get_n_levels (const parallel::distributed::Triangulation &grid) + { + // if GridClass==Triangulation, then + // we can ask directly. + return grid.n_levels(); + } + + template + unsigned int + get_n_levels (const parallel::shared::Triangulation &grid) + { + // if GridClass==Triangulation, then + // we can ask directly. + return grid.n_levels(); + } }