Reference documentation for deal.II version 8.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
dof_info.h
1 // ---------------------------------------------------------------------
2 // @f$Id: dof_info.h 31076 2013-10-02 17:52:30Z heister @f$
3 //
4 // Copyright (C) 2011 - 2013 by the deal.II authors
5 //
6 // This file is part of the deal.II library.
7 //
8 // The deal.II library is free software; you can use it, redistribute
9 // it, and/or modify it under the terms of the GNU Lesser General
10 // Public License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 // The full text of the license can be found in the file LICENSE at
13 // the top level of the deal.II distribution.
14 //
15 // ---------------------------------------------------------------------
16 
17 
18 #ifndef __deal2__matrix_free_dof_info_h
19 #define __deal2__matrix_free_dof_info_h
20 
21 
23 #include <deal.II/base/vectorization.h>
24 #include <deal.II/base/partitioner.h>
25 #include <deal.II/lac/constraint_matrix.h>
26 #include <deal.II/dofs/dof_handler.h>
27 #include <deal.II/matrix_free/helper_functions.h>
28 
29 #include <deal.II/base/std_cxx1x/array.h>
30 
31 #include <memory>
32 
33 
34 DEAL_II_NAMESPACE_OPEN
35 
36 namespace internal
37 {
38  namespace MatrixFreeFunctions
39  {
58  struct DoFInfo
59  {
63  DoFInfo ();
64 
68  DoFInfo (const DoFInfo &dof_info);
69 
73  void clear ();
74 
75 
79  const unsigned int *begin_indices (const unsigned int row) const;
80 
85  const unsigned int *end_indices (const unsigned int row) const;
86 
90  unsigned int row_length_indices (const unsigned int row) const;
91 
96  const std::pair<unsigned short,unsigned short> *
97  begin_indicators (const unsigned int row) const;
98 
103  const std::pair<unsigned short,unsigned short> *
104  end_indicators (const unsigned int row) const;
105 
110  unsigned int row_length_indicators (const unsigned int row) const;
111 
116  const unsigned int *begin_indices_plain (const unsigned int row) const;
117 
122  const unsigned int *end_indices_plain (const unsigned int row) const;
123 
130  unsigned int fe_index_from_degree (const unsigned int fe_degree) const;
131 
132 
139  unsigned int
140  fe_index_from_dofs_per_cell (const unsigned int dofs_per_cell) const;
141 
150  void read_dof_indices (const std::vector<types::global_dof_index> &local_indices,
151  const std::vector<unsigned int> &lexicographic_inv,
152  const ConstraintMatrix &constraints,
153  const unsigned int cell_number,
154  ConstraintValues<double> &constraint_values,
155  bool &cell_at_boundary);
156 
164  void assign_ghosts(const std::vector<unsigned int> &boundary_cells);
165 
172  void compute_renumber_serial (const std::vector<unsigned int> &boundary_cells,
173  const SizeInfo &size_info,
174  std::vector<unsigned int> &renumbering);
175 
182  void compute_renumber_hp_serial (SizeInfo &size_info,
183  std::vector<unsigned int> &renumbering,
184  std::vector<unsigned int> &irregular_cells);
185 
191  void compute_renumber_parallel (const std::vector<unsigned int> &boundary_cells,
192  SizeInfo &size_info,
193  std::vector<unsigned int> &renumbering);
194 
201  void reorder_cells (const SizeInfo &size_info,
202  const std::vector<unsigned int> &renumbering,
203  const std::vector<unsigned int> &constraint_pool_row_index,
204  const std::vector<unsigned int> &irregular_cells,
205  const unsigned int vectorization_length);
206 
213  void guess_block_size (const SizeInfo &size_info,
214  TaskInfo &task_info);
215 
229  void
230  make_thread_graph_partition_color (SizeInfo &size_info,
231  TaskInfo &task_info,
232  std::vector<unsigned int> &renumbering,
233  std::vector<unsigned int> &irregular_cells,
234  const bool hp_bool);
235 
250  void
251  make_thread_graph_partition_partition (SizeInfo &size_info,
252  TaskInfo &task_info,
253  std::vector<unsigned int> &renumbering,
254  std::vector<unsigned int> &irregular_cells,
255  const bool hp_bool);
256 
263  void
264  make_connectivity_graph (const SizeInfo &size_info,
265  const TaskInfo &task_info,
266  const std::vector<unsigned int> &renumbering,
267  const std::vector<unsigned int> &irregular_cells,
268  const bool do_blocking,
269  CompressedSimpleSparsityPattern &connectivity) const;
270 
274  void renumber_dofs (std::vector<types::global_dof_index> &renumbering);
275 
279  std::size_t memory_consumption() const;
280 
285  template <typename STREAM>
286  void print_memory_consumption(STREAM &out,
287  const SizeInfo &size_info) const;
288 
293  template <typename Number>
294  void print (const std::vector<Number> &constraint_pool_data,
295  const std::vector<unsigned int> &constraint_pool_row_index,
296  std::ostream &out) const;
297 
308  std::vector<std_cxx1x::array<unsigned int, 3> > row_starts;
309 
326  std::vector<unsigned int> dof_indices;
327 
337  std::vector<std::pair<unsigned short,unsigned short> > constraint_indicator;
338 
345  std_cxx1x::shared_ptr<const Utilities::MPI::Partitioner> vector_partitioner;
346 
351  std::vector<unsigned int> constrained_dofs;
352 
357  std::vector<unsigned int> row_starts_plain_indices;
358 
367  std::vector<unsigned int> plain_dof_indices;
368 
374  unsigned int dimension;
375 
380  unsigned int n_components;
381 
385  std::vector<unsigned int> dofs_per_cell;
386 
390  std::vector<unsigned int> dofs_per_face;
391 
395  bool store_plain_indices;
396 
400  std::vector<unsigned int> cell_active_fe_index;
401 
406  unsigned int max_fe_index;
407 
413  std::vector<std::pair<unsigned int,unsigned int> > fe_index_conversion;
414 
420  std::vector<types::global_dof_index> ghost_dofs;
421  };
422 
423 
424  /*----------------------- Inline functions ----------------------------------*/
425 
426 #ifndef DOXYGEN
427 
428  inline
429  const unsigned int *
430  DoFInfo::begin_indices (const unsigned int row) const
431  {
432  AssertIndexRange (row, row_starts.size()-1);
433  const unsigned int index = row_starts[row][0];
434  AssertIndexRange(index, dof_indices.size()+1);
435  return dof_indices.empty() ? 0 : &dof_indices[0] + index;
436  }
437 
438 
439 
440  inline
441  const unsigned int *
442  DoFInfo::end_indices (const unsigned int row) const
443  {
444  AssertIndexRange (row, row_starts.size()-1);
445  const unsigned int index = row_starts[row+1][0];
446  AssertIndexRange(index, dof_indices.size()+1);
447  return dof_indices.empty() ? 0 : &dof_indices[0] + index;
448  }
449 
450 
451 
452  inline
453  unsigned int
454  DoFInfo::row_length_indices (const unsigned int row) const
455  {
456  AssertIndexRange (row, row_starts.size()-1);
457  return (row_starts[row+1][0] - row_starts[row][0]);
458  }
459 
460 
461 
462  inline
463  const std::pair<unsigned short,unsigned short> *
464  DoFInfo::begin_indicators (const unsigned int row) const
465  {
466  AssertIndexRange (row, row_starts.size()-1);
467  const unsigned int index = row_starts[row][1];
468  AssertIndexRange (index, constraint_indicator.size()+1);
469  return constraint_indicator.empty() ? 0 : &constraint_indicator[0] + index;
470  }
471 
472 
473 
474  inline
475  const std::pair<unsigned short,unsigned short> *
476  DoFInfo::end_indicators (const unsigned int row) const
477  {
478  AssertIndexRange (row, row_starts.size()-1);
479  const unsigned int index = row_starts[row+1][1];
480  AssertIndexRange (index, constraint_indicator.size()+1);
481  return constraint_indicator.empty() ? 0 : &constraint_indicator[0] + index;
482  }
483 
484 
485 
486  inline
487  unsigned int
488  DoFInfo::row_length_indicators (const unsigned int row) const
489  {
490  AssertIndexRange (row, row_starts.size()-1);
491  return (row_starts[row+1][1] - row_starts[row][1]);
492  }
493 
494 
495 
496  inline
497  const unsigned int *
498  DoFInfo::begin_indices_plain (const unsigned int row) const
499  {
500  // if we have no constraints, should take the data from dof_indices
501  if (row_length_indicators(row) == 0)
502  {
503  Assert (row_starts_plain_indices[row]==numbers::invalid_unsigned_int,
504  ExcInternalError());
505  return begin_indices(row);
506  }
507  else
508  {
509  AssertDimension (row_starts.size(), row_starts_plain_indices.size());
510  const unsigned int index = row_starts_plain_indices[row];
511  AssertIndexRange(index, plain_dof_indices.size()+1);
512  return plain_dof_indices.empty() ? 0 : &plain_dof_indices[0] + index;
513  }
514  }
515 
516 
517 
518  inline
519  const unsigned int *
520  DoFInfo::end_indices_plain (const unsigned int row) const
521  {
522  return begin_indices_plain(row) +
523  dofs_per_cell[(cell_active_fe_index.size()==0)?
524  0:cell_active_fe_index[row]];
525  }
526 
527 
528 
529  inline
530  unsigned int
531  DoFInfo::fe_index_from_degree (const unsigned int fe_degree) const
532  {
533  const unsigned int n_indices = fe_index_conversion.size();
534  for (unsigned int i=0; i<n_indices; ++i)
535  if (fe_index_conversion[i].first == fe_degree)
536  return i;
537  return n_indices;
538  }
539 
540 
541 
542  inline
543  unsigned int
544  DoFInfo::fe_index_from_dofs_per_cell (const unsigned int dofs_per_cell) const
545  {
546  for (unsigned int i=0; i<fe_index_conversion.size(); ++i)
547  if (fe_index_conversion[i].second == dofs_per_cell)
548  return i;
549  return 0;
550  }
551 
552  } // end of namespace MatrixFreeFunctions
553 } // end of namespace internal
554 
555 #endif // ifndef DOXYGEN
556 
557 DEAL_II_NAMESPACE_CLOSE
558 
559 #endif
static const unsigned int invalid_unsigned_int
Definition: types.h:191
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:858
#define AssertIndexRange(index, range)
Definition: exceptions.h:888
#define Assert(cond, exc)
Definition: exceptions.h:299
std::size_t memory_consumption(const T &t)
::ExceptionBase & ExcInternalError()