Reference documentation for deal.II version Git 7026f387cc 2019-10-15 14:19:01 -0400
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
local_results.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2006 - 2018 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.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 
17 #ifndef dealii_mesh_worker_local_results_h
18 #define dealii_mesh_worker_local_results_h
19 
20 #include <deal.II/base/config.h>
21 
22 #include <deal.II/base/geometry_info.h>
23 
24 #include <deal.II/lac/block_vector.h>
25 #include <deal.II/lac/matrix_block.h>
26 
27 #include <deal.II/meshworker/vector_selector.h>
28 
29 #include <functional>
30 
31 DEAL_II_NAMESPACE_OPEN
32 
33 // Forward declaration
34 #ifndef DOXYGEN
35 class BlockIndices;
36 #endif
37 
181 namespace MeshWorker
182 {
225  template <typename number>
227  {
228  public:
234  unsigned int
235  n_values() const;
236 
243  unsigned int
244  n_vectors() const;
245 
249  unsigned int
250  n_matrices() const;
251 
255  unsigned int
256  n_quadrature_points() const;
257 
261  unsigned int
262  n_quadrature_values() const;
263 
267  number &
268  value(const unsigned int i);
269 
273  number
274  value(const unsigned int i) const;
275 
280  vector(const unsigned int i);
281 
285  const BlockVector<number> &
286  vector(const unsigned int i) const;
287 
295  matrix(const unsigned int i, const bool external = false);
296 
304  matrix(const unsigned int i, const bool external = false) const;
305 
313 
317  number &
318  quadrature_value(const unsigned int k, const unsigned int i);
319 
323  number
324  quadrature_value(const unsigned int k, const unsigned int i) const;
325 
331  void
332  initialize_numbers(const unsigned int n);
333 
339  void
340  initialize_vectors(const unsigned int n);
341 
349  void
350  initialize_matrices(const unsigned int n, bool both);
351 
359  template <typename MatrixType>
360  void
362  bool both);
363 
371  template <typename MatrixType>
372  void
374  bool both);
375 
380  void
381  initialize_quadrature(const unsigned int np, const unsigned int nv);
382 
388  void
389  reinit(const BlockIndices &local_sizes);
390 
391  template <class StreamType>
392  void
393  print_debug(StreamType &os) const;
394 
398  std::size_t
399  memory_consumption() const;
400 
401  private:
405  std::vector<number> J;
406 
411  std::vector<BlockVector<number>> R;
412 
417  std::vector<MatrixBlock<FullMatrix<number>>> M1;
418 
425  std::vector<MatrixBlock<FullMatrix<number>>> M2;
426 
431  };
432 
433  //----------------------------------------------------------------------//
434 
435  template <typename number>
436  inline void
438  {
439  J.resize(n);
440  }
441 
442 
443  template <typename number>
444  inline void
446  {
447  R.resize(n);
448  }
449 
450 
451  template <typename number>
452  template <typename MatrixType>
453  inline void
455  const MatrixBlockVector<MatrixType> &matrices,
456  bool both)
457  {
458  M1.resize(matrices.size());
459  if (both)
460  M2.resize(matrices.size());
461  for (unsigned int i = 0; i < matrices.size(); ++i)
462  {
463  const unsigned int row = matrices.block(i).row;
464  const unsigned int col = matrices.block(i).column;
465 
466  M1[i].row = row;
467  M1[i].column = col;
468  if (both)
469  {
470  M2[i].row = row;
471  M2[i].column = col;
472  }
473  }
474  }
475 
476 
477  template <typename number>
478  template <typename MatrixType>
479  inline void
481  const MGMatrixBlockVector<MatrixType> &matrices,
482  bool both)
483  {
484  M1.resize(matrices.size());
485  if (both)
486  M2.resize(matrices.size());
487  for (unsigned int i = 0; i < matrices.size(); ++i)
488  {
489  const MGLevelObject<MatrixBlock<MatrixType>> &o = matrices.block(i);
490  const unsigned int row = o[o.min_level()].row;
491  const unsigned int col = o[o.min_level()].column;
492 
493  M1[i].row = row;
494  M1[i].column = col;
495  if (both)
496  {
497  M2[i].row = row;
498  M2[i].column = col;
499  }
500  }
501  }
502 
503 
504  template <typename number>
505  inline void
507  const bool both)
508  {
509  M1.resize(n);
510  if (both)
511  M2.resize(n);
512  for (unsigned int i = 0; i < n; ++i)
513  {
514  M1[i].row = 0;
515  M1[i].column = 0;
516  if (both)
517  {
518  M2[i].row = 0;
519  M2[i].column = 0;
520  }
521  }
522  }
523 
524 
525  template <typename number>
526  inline void
528  const unsigned int nv)
529  {
530  quadrature_data.reinit(np, nv);
531  }
532 
533 
534  template <typename number>
535  inline unsigned int
537  {
538  return J.size();
539  }
540 
541 
542  template <typename number>
543  inline unsigned int
545  {
546  return R.size();
547  }
548 
549 
550  template <typename number>
551  inline unsigned int
553  {
554  return M1.size();
555  }
556 
557 
558  template <typename number>
559  inline unsigned int
561  {
562  return quadrature_data.n_rows();
563  }
564 
565 
566  template <typename number>
567  inline unsigned int
569  {
570  return quadrature_data.n_cols();
571  }
572 
573 
574  template <typename number>
575  inline number &
576  LocalResults<number>::value(const unsigned int i)
577  {
578  AssertIndexRange(i, J.size());
579  return J[i];
580  }
581 
582 
583  template <typename number>
584  inline BlockVector<number> &
585  LocalResults<number>::vector(const unsigned int i)
586  {
587  AssertIndexRange(i, R.size());
588  return R[i];
589  }
590 
591 
592  template <typename number>
594  LocalResults<number>::matrix(const unsigned int i, const bool external)
595  {
596  if (external)
597  {
598  AssertIndexRange(i, M2.size());
599  return M2[i];
600  }
601  AssertIndexRange(i, M1.size());
602  return M1[i];
603  }
604 
605 
606  template <typename number>
607  inline number &
609  const unsigned int i)
610  {
611  return quadrature_data(k, i);
612  }
613 
614 
615  template <typename number>
616  inline Table<2, number> &
618  {
619  return quadrature_data;
620  }
621 
622 
623  template <typename number>
624  inline number
625  LocalResults<number>::value(const unsigned int i) const
626  {
627  AssertIndexRange(i, J.size());
628  return J[i];
629  }
630 
631 
632  template <typename number>
633  inline const BlockVector<number> &
634  LocalResults<number>::vector(const unsigned int i) const
635  {
636  AssertIndexRange(i, R.size());
637  return R[i];
638  }
639 
640 
641  template <typename number>
642  inline const MatrixBlock<FullMatrix<number>> &
643  LocalResults<number>::matrix(const unsigned int i, const bool external) const
644  {
645  if (external)
646  {
647  AssertIndexRange(i, M2.size());
648  return M2[i];
649  }
650  AssertIndexRange(i, M1.size());
651  return M1[i];
652  }
653 
654 
655  template <typename number>
656  inline number
658  const unsigned int i) const
659  {
660  return quadrature_data(k, i);
661  }
662 
663 
664  template <typename number>
665  template <class StreamType>
666  void
667  LocalResults<number>::print_debug(StreamType &os) const
668  {
669  os << "J: " << J.size() << std::endl;
670  os << "R: " << R.size() << std::endl;
671  for (unsigned int i = 0; i < R.size(); ++i)
672  {
673  os << " " << R[i].n_blocks() << " -";
674  for (unsigned int j = 0; j < R[i].n_blocks(); ++j)
675  os << ' ' << R[i].block(j).size();
676  os << std::endl;
677  }
678  os << "M: " << M1.size() << " face " << M2.size() << std::endl;
679  for (unsigned int i = 0; i < M1.size(); ++i)
680  {
681  os << " " << M1[i].row << "," << M1[i].column << " "
682  << M1[i].matrix.m() << 'x' << M1[i].matrix.n();
683  if (i < M2.size())
684  os << " face " << M2[i].row << "," << M2[i].column << " "
685  << M2[i].matrix.m() << 'x' << M2[i].matrix.n();
686  os << std::endl;
687  }
688  }
689 
690 } // namespace MeshWorker
691 
692 
693 DEAL_II_NAMESPACE_CLOSE
694 
695 #endif
unsigned int n_matrices() const
const value_type & block(size_type i) const
Definition: matrix_block.h:893
unsigned int n_quadrature_values() const
std::vector< BlockVector< number > > R
#define AssertIndexRange(index, range)
Definition: exceptions.h:1637
const value_type & block(size_type i) const
Definition: matrix_block.h:960
void initialize_vectors(const unsigned int n)
void initialize_matrices(const unsigned int n, bool both)
size_type column
Definition: matrix_block.h:306
Table< 2, number > quadrature_data
unsigned int min_level() const
unsigned int n_vectors() const
void reinit(const TableIndices< N > &new_size, const bool omit_default_initialization=false)
number & value(const unsigned int i)
std::vector< number > J
MatrixBlock< FullMatrix< number > > & matrix(const unsigned int i, const bool external=false)
std::vector< MatrixBlock< FullMatrix< number > > > M2
Table< 2, number > & quadrature_values()
unsigned int n_values() const
void initialize_quadrature(const unsigned int np, const unsigned int nv)
number & quadrature_value(const unsigned int k, const unsigned int i)
unsigned int size() const
Definition: matrix_block.h:928
unsigned int size() const
Number of stored data objects.
Definition: any_data.h:223
BlockVector< number > & vector(const unsigned int i)
void reinit(const BlockIndices &local_sizes)
Definition: mesh_worker.cc:28
std::size_t memory_consumption() const
Definition: mesh_worker.cc:46
std::vector< MatrixBlock< FullMatrix< number > > > M1
void initialize_numbers(const unsigned int n)
size_type row
Definition: matrix_block.h:301
unsigned int n_quadrature_points() const