Reference documentation for deal.II version 8.5.1
dof_renumbering.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2003 - 2016 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii__dof_renumbering_h
17 #define dealii__dof_renumbering_h
18 
19 
20 #include <deal.II/base/config.h>
21 #include <deal.II/base/exceptions.h>
22 #include <deal.II/base/point.h>
23 #include <deal.II/dofs/dof_handler.h>
24 #include <deal.II/hp/dof_handler.h>
25 
26 #include <vector>
27 
28 DEAL_II_NAMESPACE_OPEN
29 
338 namespace DoFRenumbering
339 {
345  template <class Iterator, int dim>
347  {
352  :
353  dir(dir)
354  {}
358  bool operator () (const Iterator &c1, const Iterator &c2) const
359  {
360  const Tensor<1,dim> diff = c2->center() - c1->center();
361  return (diff*dir > 0);
362  }
363 
364  private:
369  };
370 
371 
379  template <int dim>
381  {
386  :
387  dir(dir)
388  {}
393  const std::pair<Point<dim>,types::global_dof_index> &c2) const
394  {
395  const Tensor<1,dim> diff = c2.first-c1.first;
396  return (diff*dir > 0 || (diff*dir==0 && c1.second<c2.second));
397  }
398 
399  private:
404  };
405 
406 
407 
421  namespace boost
422  {
434  template <typename DoFHandlerType>
435  void
436  Cuthill_McKee (DoFHandlerType &dof_handler,
437  const bool reversed_numbering = false,
438  const bool use_constraints = false);
439 
445  template <typename DoFHandlerType>
446  void
447  compute_Cuthill_McKee (std::vector<types::global_dof_index> &new_dof_indices,
448  const DoFHandlerType &,
449  const bool reversed_numbering = false,
450  const bool use_constraints = false);
451 
464  template <typename DoFHandlerType>
465  void
466  king_ordering (DoFHandlerType &dof_handler,
467  const bool reversed_numbering = false,
468  const bool use_constraints = false);
469 
474  template <typename DoFHandlerType>
475  void
476  compute_king_ordering (std::vector<types::global_dof_index> &new_dof_indices,
477  const DoFHandlerType &,
478  const bool reversed_numbering = false,
479  const bool use_constraints = false);
480 
492  template <typename DoFHandlerType>
493  void
494  minimum_degree (DoFHandlerType &dof_handler,
495  const bool reversed_numbering = false,
496  const bool use_constraints = false);
497 
502  template <typename DoFHandlerType>
503  void
504  compute_minimum_degree (std::vector<types::global_dof_index> &new_dof_indices,
505  const DoFHandlerType &,
506  const bool reversed_numbering = false,
507  const bool use_constraints = false);
508  }
509 
543  template <typename DoFHandlerType>
544  void
545  Cuthill_McKee (DoFHandlerType &dof_handler,
546  const bool reversed_numbering = false,
547  const bool use_constraints = false,
548  const std::vector<types::global_dof_index> &starting_indices
549  = std::vector<types::global_dof_index>());
550 
556  template <typename DoFHandlerType>
557  void
558  compute_Cuthill_McKee (std::vector<types::global_dof_index> &new_dof_indices,
559  const DoFHandlerType &,
560  const bool reversed_numbering = false,
561  const bool use_constraints = false,
562  const std::vector<types::global_dof_index> &starting_indices
563  = std::vector<types::global_dof_index>());
564 
578  template <typename DoFHandlerType>
579  void
580  Cuthill_McKee (DoFHandlerType &dof_handler,
581  const unsigned int level,
582  const bool reversed_numbering = false,
583  const std::vector<types::global_dof_index> &starting_indices
584  = std::vector<types::global_dof_index> ());
585 
617  template <int dim, int spacedim>
618  void
620  const std::vector<unsigned int> &target_component
621  = std::vector<unsigned int>());
622 
623 
628  template <int dim>
629  void
630  component_wise (hp::DoFHandler<dim> &dof_handler,
631  const std::vector<unsigned int> &target_component = std::vector<unsigned int> ());
632 
639  template <typename DoFHandlerType>
640  void
641  component_wise (DoFHandlerType &dof_handler,
642  const unsigned int level,
643  const std::vector<unsigned int> &target_component
644  = std::vector<unsigned int>());
645 
651  template <int dim, int spacedim, class ITERATOR, class ENDITERATOR>
653  compute_component_wise (std::vector<types::global_dof_index> &new_dof_indices,
654  const ITERATOR &start,
655  const ENDITERATOR &end,
656  const std::vector<unsigned int> &target_component,
657  bool is_level_operation);
658 
675  template <int dim, int spacedim>
676  void
677  block_wise (DoFHandler<dim,spacedim> &dof_handler);
678 
685  template <int dim, int spacedim>
686  void
687  block_wise (DoFHandler<dim,spacedim> &dof_handler, const unsigned int level);
688 
705  template <int dim, int spacedim>
706  void
708 
714  template <int dim, int spacedim, class ITERATOR, class ENDITERATOR>
716  compute_block_wise (std::vector<types::global_dof_index> &new_dof_indices,
717  const ITERATOR &start,
718  const ENDITERATOR &end,
719  bool is_level_operation);
720 
736  template <int dim>
737  void
738  hierarchical (DoFHandler<dim> &dof_handler);
739 
761  template <typename DoFHandlerType>
762  void
763  cell_wise (DoFHandlerType &dof_handler,
764  const std::vector<typename DoFHandlerType::active_cell_iterator> &cell_order);
765 
797  template <typename DoFHandlerType>
798  void
800  (std::vector<types::global_dof_index> &renumbering,
801  std::vector<types::global_dof_index> &inverse_renumbering,
802  const DoFHandlerType &dof_handler,
803  const std::vector<typename DoFHandlerType::active_cell_iterator> &cell_order);
804 
809  template <typename DoFHandlerType>
810  void
811  cell_wise (DoFHandlerType &dof_handler,
812  const unsigned int level,
813  const std::vector<typename DoFHandlerType::level_cell_iterator> &cell_order);
814 
819  template <typename DoFHandlerType>
820  void
822  (std::vector<types::global_dof_index> &renumbering,
823  std::vector<types::global_dof_index> &inverse_renumbering,
824  const DoFHandlerType &dof_handler,
825  const unsigned int level,
826  const std::vector<typename DoFHandlerType::level_cell_iterator> &cell_order);
827 
862  template <typename DoFHandlerType>
863  void
864  downstream (DoFHandlerType &dof_handler,
866  const bool dof_wise_renumbering = false);
867 
868 
873  template <typename DoFHandlerType>
874  void
875  downstream (DoFHandlerType &dof_handler,
876  const unsigned int level,
878  const bool dof_wise_renumbering = false);
879 
885  template <typename DoFHandlerType>
886  void
887  compute_downstream (std::vector<types::global_dof_index> &new_dof_indices,
888  std::vector<types::global_dof_index> &reverse,
889  const DoFHandlerType &dof_handler,
891  const bool dof_wise_renumbering);
892 
898  template <typename DoFHandlerType>
899  void
900  compute_downstream (std::vector<types::global_dof_index> &new_dof_indices,
901  std::vector<types::global_dof_index> &reverse,
902  const DoFHandlerType &dof_handler,
903  const unsigned int level,
905  const bool dof_wise_renumbering);
906 
915  template <typename DoFHandlerType>
916  void
917  clockwise_dg (DoFHandlerType &dof_handler,
919  const bool counter = false);
920 
925  template <typename DoFHandlerType>
926  void
927  clockwise_dg (DoFHandlerType &dof_handler,
928  const unsigned int level,
930  const bool counter = false);
931 
937  template <typename DoFHandlerType>
938  void
939  compute_clockwise_dg (std::vector<types::global_dof_index> &new_dof_indices,
940  const DoFHandlerType &dof_handler,
942  const bool counter);
943 
962  template <typename DoFHandlerType>
963  void
964  sort_selected_dofs_back (DoFHandlerType &dof_handler,
965  const std::vector<bool> &selected_dofs);
966 
977  template <typename DoFHandlerType>
978  void
979  sort_selected_dofs_back (DoFHandlerType &dof_handler,
980  const std::vector<bool> &selected_dofs,
981  const unsigned int level);
982 
991  template <typename DoFHandlerType>
992  void
993  compute_sort_selected_dofs_back (std::vector<types::global_dof_index> &new_dof_indices,
994  const DoFHandlerType &dof_handler,
995  const std::vector<bool> &selected_dofs);
996 
1006  template <typename DoFHandlerType>
1007  void
1008  compute_sort_selected_dofs_back (std::vector<types::global_dof_index> &new_dof_indices,
1009  const DoFHandlerType &dof_handler,
1010  const std::vector<bool> &selected_dofs,
1011  const unsigned int level);
1012 
1023  template <typename DoFHandlerType>
1024  void
1025  random (DoFHandlerType &dof_handler);
1026 
1034  template <typename DoFHandlerType>
1035  void
1036  compute_random (std::vector<types::global_dof_index> &new_dof_indices,
1037  const DoFHandlerType &dof_handler);
1038 
1066  template <typename DoFHandlerType>
1067  void
1068  subdomain_wise (DoFHandlerType &dof_handler);
1069 
1075  template <typename DoFHandlerType>
1076  void
1077  compute_subdomain_wise (std::vector<types::global_dof_index> &new_dof_indices,
1078  const DoFHandlerType &dof_handler);
1079 
1103 }
1104 
1105 /* ------------------------- inline functions -------------- */
1106 
1107 #ifndef DOXYGEN
1108 namespace DoFRenumbering
1109 {
1110  template <typename DoFHandlerType>
1111  void
1112  inline
1113  downstream (DoFHandlerType &dof,
1114  const Point<DoFHandlerType::space_dimension> &direction,
1115  const bool dof_wise_renumbering)
1116  {
1117  std::vector<types::global_dof_index> renumbering(dof.n_dofs());
1118  std::vector<types::global_dof_index> reverse(dof.n_dofs());
1119  compute_downstream(renumbering, reverse, dof, direction,
1120  dof_wise_renumbering);
1121 
1122  dof.renumber_dofs(renumbering);
1123  }
1124 }
1125 #endif
1126 
1127 
1128 DEAL_II_NAMESPACE_CLOSE
1129 
1130 #endif
static ::ExceptionBase & ExcInvalidComponentOrder()
void minimum_degree(DoFHandlerType &dof_handler, const bool reversed_numbering=false, const bool use_constraints=false)
void compute_cell_wise(std::vector< types::global_dof_index > &renumbering, std::vector< types::global_dof_index > &inverse_renumbering, const DoFHandlerType &dof_handler, const std::vector< typename DoFHandlerType::active_cell_iterator > &cell_order)
void compute_king_ordering(std::vector< types::global_dof_index > &new_dof_indices, const DoFHandlerType &, const bool reversed_numbering=false, const bool use_constraints=false)
void sort_selected_dofs_back(DoFHandlerType &dof_handler, const std::vector< bool > &selected_dofs)
void hierarchical(DoFHandler< dim > &dof_handler)
void component_wise(DoFHandler< dim, spacedim > &dof_handler, const std::vector< unsigned int > &target_component=std::vector< unsigned int >())
CompareDownstream(const Tensor< 1, dim > &dir)
void random(DoFHandlerType &dof_handler)
void compute_minimum_degree(std::vector< types::global_dof_index > &new_dof_indices, const DoFHandlerType &, const bool reversed_numbering=false, const bool use_constraints=false)
void Cuthill_McKee(DoFHandlerType &dof_handler, const bool reversed_numbering=false, const bool use_constraints=false)
unsigned int global_dof_index
Definition: types.h:88
void compute_subdomain_wise(std::vector< types::global_dof_index > &new_dof_indices, const DoFHandlerType &dof_handler)
static ::ExceptionBase & ExcNotDGFEM()
#define DeclException0(Exception0)
Definition: exceptions.h:541
bool operator()(const std::pair< Point< dim >, types::global_dof_index > &c1, const std::pair< Point< dim >, types::global_dof_index > &c2) const
static ::ExceptionBase & ExcRenumberingIncomplete()
void compute_random(std::vector< types::global_dof_index > &new_dof_indices, const DoFHandlerType &dof_handler)
void downstream(DoFHandlerType &dof_handler, const Point< DoFHandlerType::space_dimension > &direction, const bool dof_wise_renumbering=false)
void compute_sort_selected_dofs_back(std::vector< types::global_dof_index > &new_dof_indices, const DoFHandlerType &dof_handler, const std::vector< bool > &selected_dofs)
void compute_Cuthill_McKee(std::vector< types::global_dof_index > &new_dof_indices, const DoFHandlerType &, const bool reversed_numbering=false, const bool use_constraints=false, const std::vector< types::global_dof_index > &starting_indices=std::vector< types::global_dof_index >())
void compute_clockwise_dg(std::vector< types::global_dof_index > &new_dof_indices, const DoFHandlerType &dof_handler, const Point< DoFHandlerType::space_dimension > &center, const bool counter)
void king_ordering(DoFHandlerType &dof_handler, const bool reversed_numbering=false, const bool use_constraints=false)
void block_wise(DoFHandler< dim, spacedim > &dof_handler)
void Cuthill_McKee(DoFHandlerType &dof_handler, const bool reversed_numbering=false, const bool use_constraints=false, const std::vector< types::global_dof_index > &starting_indices=std::vector< types::global_dof_index >())
types::global_dof_index compute_component_wise(std::vector< types::global_dof_index > &new_dof_indices, const ITERATOR &start, const ENDITERATOR &end, const std::vector< unsigned int > &target_component, bool is_level_operation)
void compute_Cuthill_McKee(std::vector< types::global_dof_index > &new_dof_indices, const DoFHandlerType &, const bool reversed_numbering=false, const bool use_constraints=false)
ComparePointwiseDownstream(const Tensor< 1, dim > &dir)
void subdomain_wise(DoFHandlerType &dof_handler)
void clockwise_dg(DoFHandlerType &dof_handler, const Point< DoFHandlerType::space_dimension > &center, const bool counter=false)
void compute_downstream(std::vector< types::global_dof_index > &new_dof_indices, std::vector< types::global_dof_index > &reverse, const DoFHandlerType &dof_handler, const Point< DoFHandlerType::space_dimension > &direction, const bool dof_wise_renumbering)
types::global_dof_index compute_block_wise(std::vector< types::global_dof_index > &new_dof_indices, const ITERATOR &start, const ENDITERATOR &end, bool is_level_operation)
void cell_wise(DoFHandlerType &dof_handler, const std::vector< typename DoFHandlerType::active_cell_iterator > &cell_order)
bool operator()(const Iterator &c1, const Iterator &c2) const