Reference documentation for deal.II version 9.2.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
local_results.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2006 - 2020 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 
23 
26 
28 
29 #include <functional>
30 
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 
694 
695 #endif
MGMatrixBlockVector
Definition: matrix_block.h:444
MeshWorker::LocalResults::R
std::vector< BlockVector< number > > R
Definition: local_results.h:411
MatrixBlock::column
size_type column
Definition: matrix_block.h:312
MeshWorker::LocalResults::value
number & value(const unsigned int i)
Definition: local_results.h:576
MeshWorker::LocalResults::initialize_vectors
void initialize_vectors(const unsigned int n)
Definition: local_results.h:445
MeshWorker::LocalResults::M2
std::vector< MatrixBlock< FullMatrix< number > > > M2
Definition: local_results.h:425
vector_selector.h
MeshWorker::LocalResults::n_matrices
unsigned int n_matrices() const
Definition: local_results.h:552
MGLevelObject::min_level
unsigned int min_level() const
Definition: mg_level_object.h:238
BlockVector< number >
MatrixBlock::row
size_type row
Definition: matrix_block.h:307
MatrixBlockVector::size
unsigned int size() const
Number of stored data objects.
Definition: any_data.h:223
MeshWorker::LocalResults::J
std::vector< number > J
Definition: local_results.h:405
MeshWorker
Definition: assemble_flags.h:30
MeshWorker::LocalResults::print_debug
void print_debug(StreamType &os) const
Definition: local_results.h:667
AssertIndexRange
#define AssertIndexRange(index, range)
Definition: exceptions.h:1649
Table< 2, number >
MeshWorker::LocalResults::initialize_quadrature
void initialize_quadrature(const unsigned int np, const unsigned int nv)
Definition: local_results.h:527
MeshWorker::LocalResults::initialize_matrices
void initialize_matrices(const unsigned int n, bool both)
Definition: local_results.h:506
MeshWorker::LocalResults::n_values
unsigned int n_values() const
Definition: local_results.h:536
MeshWorker::LocalResults::M1
std::vector< MatrixBlock< FullMatrix< number > > > M1
Definition: local_results.h:417
MeshWorker::LocalResults
Definition: local_results.h:226
MeshWorker::LocalResults::n_vectors
unsigned int n_vectors() const
Definition: local_results.h:544
block_vector.h
geometry_info.h
MGMatrixBlockVector::block
const value_type & block(size_type i) const
Definition: matrix_block.h:955
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
MeshWorker::LocalResults::vector
BlockVector< number > & vector(const unsigned int i)
Definition: local_results.h:585
MeshWorker::LocalResults::quadrature_value
number & quadrature_value(const unsigned int k, const unsigned int i)
Definition: local_results.h:608
MeshWorker::LocalResults::quadrature_data
Table< 2, number > quadrature_data
Definition: local_results.h:430
MeshWorker::LocalResults::matrix
MatrixBlock< FullMatrix< number > > & matrix(const unsigned int i, const bool external=false)
Definition: local_results.h:594
MeshWorker::LocalResults::n_quadrature_values
unsigned int n_quadrature_values() const
Definition: local_results.h:568
MeshWorker::LocalResults::quadrature_values
Table< 2, number > & quadrature_values()
Definition: local_results.h:617
MGLevelObject
Definition: mg_level_object.h:50
MatrixBlock
Definition: matrix_block.h:112
MeshWorker::LocalResults::reinit
void reinit(const BlockIndices &local_sizes)
Definition: mesh_worker.cc:28
MeshWorker::LocalResults::initialize_numbers
void initialize_numbers(const unsigned int n)
Definition: local_results.h:437
MatrixBlockVector
Definition: matrix_block.h:354
MeshWorker::LocalResults::memory_consumption
std::size_t memory_consumption() const
Definition: mesh_worker.cc:46
MGMatrixBlockVector::size
unsigned int size() const
Definition: matrix_block.h:923
config.h
matrix_block.h
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
MeshWorker::LocalResults::n_quadrature_points
unsigned int n_quadrature_points() const
Definition: local_results.h:560
BlockIndices
Definition: block_indices.h:60
MatrixBlockVector::block
const value_type & block(size_type i) const
Definition: matrix_block.h:888