Reference documentation for deal.II version 9.3.3
\(\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
35class BlockIndices;
36#endif
37
179namespace MeshWorker
180{
222 template <typename number>
224 {
225 public:
231 unsigned int
232 n_values() const;
233
240 unsigned int
241 n_vectors() const;
242
246 unsigned int
247 n_matrices() const;
248
252 unsigned int
254
258 unsigned int
260
264 number &
265 value(const unsigned int i);
266
270 number
271 value(const unsigned int i) const;
272
277 vector(const unsigned int i);
278
282 const BlockVector<number> &
283 vector(const unsigned int i) const;
284
292 matrix(const unsigned int i, const bool external = false);
293
301 matrix(const unsigned int i, const bool external = false) const;
302
310
314 number &
315 quadrature_value(const unsigned int k, const unsigned int i);
316
320 number
321 quadrature_value(const unsigned int k, const unsigned int i) const;
322
328 void
329 initialize_numbers(const unsigned int n);
330
336 void
337 initialize_vectors(const unsigned int n);
338
346 void
347 initialize_matrices(const unsigned int n, bool both);
348
356 template <typename MatrixType>
357 void
359 bool both);
360
368 template <typename MatrixType>
369 void
371 bool both);
372
377 void
378 initialize_quadrature(const unsigned int np, const unsigned int nv);
379
385 void
386 reinit(const BlockIndices &local_sizes);
387
388 template <class StreamType>
389 void
390 print_debug(StreamType &os) const;
391
395 std::size_t
396 memory_consumption() const;
397
398 private:
402 std::vector<number> J;
403
408 std::vector<BlockVector<number>> R;
409
414 std::vector<MatrixBlock<FullMatrix<number>>> M1;
415
422 std::vector<MatrixBlock<FullMatrix<number>>> M2;
423
428 };
429
430 //----------------------------------------------------------------------//
431
432 template <typename number>
433 inline void
435 {
436 J.resize(n);
437 }
438
439
440 template <typename number>
441 inline void
443 {
444 R.resize(n);
445 }
446
447
448 template <typename number>
449 template <typename MatrixType>
450 inline void
452 const MatrixBlockVector<MatrixType> &matrices,
453 bool both)
454 {
455 M1.resize(matrices.size());
456 if (both)
457 M2.resize(matrices.size());
458 for (unsigned int i = 0; i < matrices.size(); ++i)
459 {
460 const unsigned int row = matrices.block(i).row;
461 const unsigned int col = matrices.block(i).column;
462
463 M1[i].row = row;
464 M1[i].column = col;
465 if (both)
466 {
467 M2[i].row = row;
468 M2[i].column = col;
469 }
470 }
471 }
472
473
474 template <typename number>
475 template <typename MatrixType>
476 inline void
478 const MGMatrixBlockVector<MatrixType> &matrices,
479 bool both)
480 {
481 M1.resize(matrices.size());
482 if (both)
483 M2.resize(matrices.size());
484 for (unsigned int i = 0; i < matrices.size(); ++i)
485 {
486 const MGLevelObject<MatrixBlock<MatrixType>> &o = matrices.block(i);
487 const unsigned int row = o[o.min_level()].row;
488 const unsigned int col = o[o.min_level()].column;
489
490 M1[i].row = row;
491 M1[i].column = col;
492 if (both)
493 {
494 M2[i].row = row;
495 M2[i].column = col;
496 }
497 }
498 }
499
500
501 template <typename number>
502 inline void
504 const bool both)
505 {
506 M1.resize(n);
507 if (both)
508 M2.resize(n);
509 for (unsigned int i = 0; i < n; ++i)
510 {
511 M1[i].row = 0;
512 M1[i].column = 0;
513 if (both)
514 {
515 M2[i].row = 0;
516 M2[i].column = 0;
517 }
518 }
519 }
520
521
522 template <typename number>
523 inline void
525 const unsigned int nv)
526 {
527 quadrature_data.reinit(np, nv);
528 }
529
530
531 template <typename number>
532 inline unsigned int
534 {
535 return J.size();
536 }
537
538
539 template <typename number>
540 inline unsigned int
542 {
543 return R.size();
544 }
545
546
547 template <typename number>
548 inline unsigned int
550 {
551 return M1.size();
552 }
553
554
555 template <typename number>
556 inline unsigned int
558 {
559 return quadrature_data.n_rows();
560 }
561
562
563 template <typename number>
564 inline unsigned int
566 {
567 return quadrature_data.n_cols();
568 }
569
570
571 template <typename number>
572 inline number &
573 LocalResults<number>::value(const unsigned int i)
574 {
575 AssertIndexRange(i, J.size());
576 return J[i];
577 }
578
579
580 template <typename number>
581 inline BlockVector<number> &
582 LocalResults<number>::vector(const unsigned int i)
583 {
584 AssertIndexRange(i, R.size());
585 return R[i];
586 }
587
588
589 template <typename number>
591 LocalResults<number>::matrix(const unsigned int i, const bool external)
592 {
593 if (external)
594 {
595 AssertIndexRange(i, M2.size());
596 return M2[i];
597 }
598 AssertIndexRange(i, M1.size());
599 return M1[i];
600 }
601
602
603 template <typename number>
604 inline number &
606 const unsigned int i)
607 {
608 return quadrature_data(k, i);
609 }
610
611
612 template <typename number>
613 inline Table<2, number> &
615 {
616 return quadrature_data;
617 }
618
619
620 template <typename number>
621 inline number
622 LocalResults<number>::value(const unsigned int i) const
623 {
624 AssertIndexRange(i, J.size());
625 return J[i];
626 }
627
628
629 template <typename number>
630 inline const BlockVector<number> &
631 LocalResults<number>::vector(const unsigned int i) const
632 {
633 AssertIndexRange(i, R.size());
634 return R[i];
635 }
636
637
638 template <typename number>
639 inline const MatrixBlock<FullMatrix<number>> &
640 LocalResults<number>::matrix(const unsigned int i, const bool external) const
641 {
642 if (external)
643 {
644 AssertIndexRange(i, M2.size());
645 return M2[i];
646 }
647 AssertIndexRange(i, M1.size());
648 return M1[i];
649 }
650
651
652 template <typename number>
653 inline number
655 const unsigned int i) const
656 {
657 return quadrature_data(k, i);
658 }
659
660
661 template <typename number>
662 template <class StreamType>
663 void
665 {
666 os << "J: " << J.size() << std::endl;
667 os << "R: " << R.size() << std::endl;
668 for (unsigned int i = 0; i < R.size(); ++i)
669 {
670 os << " " << R[i].n_blocks() << " -";
671 for (unsigned int j = 0; j < R[i].n_blocks(); ++j)
672 os << ' ' << R[i].block(j).size();
673 os << std::endl;
674 }
675 os << "M: " << M1.size() << " face " << M2.size() << std::endl;
676 for (unsigned int i = 0; i < M1.size(); ++i)
677 {
678 os << " " << M1[i].row << "," << M1[i].column << " "
679 << M1[i].matrix.m() << 'x' << M1[i].matrix.n();
680 if (i < M2.size())
681 os << " face " << M2[i].row << "," << M2[i].column << " "
682 << M2[i].matrix.m() << 'x' << M2[i].matrix.n();
683 os << std::endl;
684 }
685 }
686
687} // namespace MeshWorker
688
689
691
692#endif
unsigned int min_level() const
const value_type & block(size_type i) const
Definition: matrix_block.h:952
unsigned int size() const
Definition: matrix_block.h:920
unsigned int size() const
Number of stored data objects.
Definition: any_data.h:223
const value_type & block(size_type i) const
Definition: matrix_block.h:885
size_type row
Definition: matrix_block.h:306
size_type column
Definition: matrix_block.h:311
MatrixBlock< FullMatrix< number > > & matrix(const unsigned int i, const bool external=false)
unsigned int n_quadrature_values() const
BlockVector< number > & vector(const unsigned int i)
unsigned int n_vectors() const
number & quadrature_value(const unsigned int k, const unsigned int i)
number value(const unsigned int i) const
std::vector< BlockVector< number > > R
std::size_t memory_consumption() const
Definition: mesh_worker.cc:46
const BlockVector< number > & vector(const unsigned int i) const
const MatrixBlock< FullMatrix< number > > & matrix(const unsigned int i, const bool external=false) const
number quadrature_value(const unsigned int k, const unsigned int i) const
Table< 2, number > quadrature_data
void initialize_matrices(const MatrixBlockVector< MatrixType > &matrices, bool both)
void initialize_matrices(const MGMatrixBlockVector< MatrixType > &matrices, bool both)
std::vector< MatrixBlock< FullMatrix< number > > > M2
void reinit(const BlockIndices &local_sizes)
Definition: mesh_worker.cc:28
void initialize_matrices(const unsigned int n, bool both)
std::vector< MatrixBlock< FullMatrix< number > > > M1
unsigned int n_values() const
void initialize_quadrature(const unsigned int np, const unsigned int nv)
Table< 2, number > & quadrature_values()
void initialize_numbers(const unsigned int n)
void initialize_vectors(const unsigned int n)
unsigned int n_matrices() const
void print_debug(StreamType &os) const
std::vector< number > J
unsigned int n_quadrature_points() const
number & value(const unsigned int i)
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:402
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:403
#define AssertIndexRange(index, range)
Definition: exceptions.h:1690