Reference documentation for deal.II version GIT relicensing-224-gc660c0d696 2024-03-28 18:40:02+00:00
\(\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\}}\)
Loading...
Searching...
No Matches
local_results.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2009 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15
16#ifndef dealii_mesh_worker_local_results_h
17#define dealii_mesh_worker_local_results_h
18
19#include <deal.II/base/config.h>
20
22
25
27
28#include <functional>
29
31
32// Forward declaration
33#ifndef DOXYGEN
34class BlockIndices;
35#endif
36
178namespace MeshWorker
179{
221 template <typename number>
223 {
224 public:
230 unsigned int
231 n_values() const;
232
239 unsigned int
240 n_vectors() const;
241
245 unsigned int
246 n_matrices() const;
247
251 unsigned int
253
257 unsigned int
259
263 number &
264 value(const unsigned int i);
265
269 number
270 value(const unsigned int i) const;
271
276 vector(const unsigned int i);
277
281 const BlockVector<number> &
282 vector(const unsigned int i) const;
283
291 matrix(const unsigned int i, const bool external = false);
292
300 matrix(const unsigned int i, const bool external = false) const;
301
309
313 number &
314 quadrature_value(const unsigned int k, const unsigned int i);
315
319 number
320 quadrature_value(const unsigned int k, const unsigned int i) const;
321
327 void
328 initialize_numbers(const unsigned int n);
329
335 void
336 initialize_vectors(const unsigned int n);
337
345 void
346 initialize_matrices(const unsigned int n, bool both);
347
355 template <typename MatrixType>
356 void
358 bool both);
359
367 template <typename MatrixType>
368 void
370 bool both);
371
376 void
377 initialize_quadrature(const unsigned int np, const unsigned int nv);
378
384 void
386
387 template <typename StreamType>
388 void
390
394 std::size_t
395 memory_consumption() const;
396
397 private:
401 std::vector<number> J;
402
407 std::vector<BlockVector<number>> R;
408
413 std::vector<MatrixBlock<FullMatrix<number>>> M1;
414
421 std::vector<MatrixBlock<FullMatrix<number>>> M2;
422
427 };
428
429 //----------------------------------------------------------------------//
430
431 template <typename number>
432 inline void
434 {
435 J.resize(n);
436 }
437
438
439 template <typename number>
440 inline void
442 {
443 R.resize(n);
444 }
445
446
447 template <typename number>
448 template <typename MatrixType>
449 inline void
451 const MatrixBlockVector<MatrixType> &matrices,
452 bool both)
453 {
454 M1.resize(matrices.size());
455 if (both)
456 M2.resize(matrices.size());
457 for (unsigned int i = 0; i < matrices.size(); ++i)
458 {
459 const unsigned int row = matrices.block(i).row;
460 const unsigned int col = matrices.block(i).column;
461
462 M1[i].row = row;
463 M1[i].column = col;
464 if (both)
465 {
466 M2[i].row = row;
467 M2[i].column = col;
468 }
469 }
470 }
471
472
473 template <typename number>
474 template <typename MatrixType>
475 inline void
477 const MGMatrixBlockVector<MatrixType> &matrices,
478 bool both)
479 {
480 M1.resize(matrices.size());
481 if (both)
482 M2.resize(matrices.size());
483 for (unsigned int i = 0; i < matrices.size(); ++i)
484 {
485 const MGLevelObject<MatrixBlock<MatrixType>> &o = matrices.block(i);
486 const unsigned int row = o[o.min_level()].row;
487 const unsigned int col = o[o.min_level()].column;
488
489 M1[i].row = row;
490 M1[i].column = col;
491 if (both)
492 {
493 M2[i].row = row;
494 M2[i].column = col;
495 }
496 }
497 }
498
499
500 template <typename number>
501 inline void
503 const bool both)
504 {
505 M1.resize(n);
506 if (both)
507 M2.resize(n);
508 for (unsigned int i = 0; i < n; ++i)
509 {
510 M1[i].row = 0;
511 M1[i].column = 0;
512 if (both)
513 {
514 M2[i].row = 0;
515 M2[i].column = 0;
516 }
517 }
518 }
519
520
521 template <typename number>
522 inline void
524 const unsigned int nv)
525 {
526 quadrature_data.reinit(np, nv);
527 }
528
529
530 template <typename number>
531 inline unsigned int
533 {
534 return J.size();
535 }
536
537
538 template <typename number>
539 inline unsigned int
541 {
542 return R.size();
543 }
544
545
546 template <typename number>
547 inline unsigned int
549 {
550 return M1.size();
551 }
552
553
554 template <typename number>
555 inline unsigned int
557 {
558 return quadrature_data.n_rows();
559 }
560
561
562 template <typename number>
563 inline unsigned int
565 {
566 return quadrature_data.n_cols();
567 }
568
569
570 template <typename number>
571 inline number &
572 LocalResults<number>::value(const unsigned int i)
573 {
574 AssertIndexRange(i, J.size());
575 return J[i];
576 }
577
578
579 template <typename number>
580 inline BlockVector<number> &
581 LocalResults<number>::vector(const unsigned int i)
582 {
583 AssertIndexRange(i, R.size());
584 return R[i];
585 }
586
587
588 template <typename number>
590 LocalResults<number>::matrix(const unsigned int i, const bool external)
591 {
592 if (external)
593 {
594 AssertIndexRange(i, M2.size());
595 return M2[i];
596 }
597 AssertIndexRange(i, M1.size());
598 return M1[i];
599 }
600
601
602 template <typename number>
603 inline number &
605 const unsigned int i)
606 {
607 return quadrature_data(k, i);
608 }
609
610
611 template <typename number>
612 inline Table<2, number> &
614 {
615 return quadrature_data;
616 }
617
618
619 template <typename number>
620 inline number
621 LocalResults<number>::value(const unsigned int i) const
622 {
623 AssertIndexRange(i, J.size());
624 return J[i];
625 }
626
627
628 template <typename number>
629 inline const BlockVector<number> &
630 LocalResults<number>::vector(const unsigned int i) const
631 {
632 AssertIndexRange(i, R.size());
633 return R[i];
634 }
635
636
637 template <typename number>
638 inline const MatrixBlock<FullMatrix<number>> &
639 LocalResults<number>::matrix(const unsigned int i, const bool external) const
640 {
641 if (external)
642 {
643 AssertIndexRange(i, M2.size());
644 return M2[i];
645 }
646 AssertIndexRange(i, M1.size());
647 return M1[i];
648 }
649
650
651 template <typename number>
652 inline number
654 const unsigned int i) const
655 {
656 return quadrature_data(k, i);
657 }
658
659
660 template <typename number>
661 template <typename StreamType>
662 void
664 {
665 os << "J: " << J.size() << std::endl;
666 os << "R: " << R.size() << std::endl;
667 for (unsigned int i = 0; i < R.size(); ++i)
668 {
669 os << " " << R[i].n_blocks() << " -";
670 for (unsigned int j = 0; j < R[i].n_blocks(); ++j)
671 os << ' ' << R[i].block(j).size();
672 os << std::endl;
673 }
674 os << "M: " << M1.size() << " face " << M2.size() << std::endl;
675 for (unsigned int i = 0; i < M1.size(); ++i)
676 {
677 os << " " << M1[i].row << ',' << M1[i].column << ' '
678 << M1[i].matrix.m() << 'x' << M1[i].matrix.n();
679 if (i < M2.size())
680 os << " face " << M2[i].row << ',' << M2[i].column << ' '
681 << M2[i].matrix.m() << 'x' << M2[i].matrix.n();
682 os << std::endl;
683 }
684 }
685
686} // namespace MeshWorker
687
688
690
691#endif
unsigned int min_level() const
const value_type & block(size_type i) const
unsigned int size() const
unsigned int size() const
Number of stored data objects.
Definition any_data.h:221
const value_type & block(size_type i) const
size_type row
size_type column
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
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)
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:502
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:503
#define AssertIndexRange(index, range)