deal.II version GIT relicensing-6834-g5b78e6bcdf 2026-10-01 11:20:01+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: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2009 - 2024 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13
14#ifndef dealii_mesh_worker_local_results_h
15#define dealii_mesh_worker_local_results_h
16
17#include <deal.II/base/config.h>
18
20
23
25
26#include <functional>
27
29
30// Forward declaration
31#ifndef DOXYGEN
32class BlockIndices;
33#endif
34
35namespace MeshWorker
36{
78 template <typename number>
80 {
81 public:
87 unsigned int
88 n_values() const;
89
96 unsigned int
97 n_vectors() const;
98
102 unsigned int
103 n_matrices() const;
104
108 unsigned int
110
114 unsigned int
116
120 number &
121 value(const unsigned int i);
122
126 number
127 value(const unsigned int i) const;
128
133 vector(const unsigned int i);
134
138 const BlockVector<number> &
139 vector(const unsigned int i) const;
140
148 matrix(const unsigned int i, const bool external = false);
149
157 matrix(const unsigned int i, const bool external = false) const;
158
166
170 number &
171 quadrature_value(const unsigned int k, const unsigned int i);
172
176 number
177 quadrature_value(const unsigned int k, const unsigned int i) const;
178
184 void
185 initialize_numbers(const unsigned int n);
186
192 void
193 initialize_vectors(const unsigned int n);
194
202 void
203 initialize_matrices(const unsigned int n, bool both);
204
212 template <typename MatrixType>
213 void
215 bool both);
216
224 template <typename MatrixType>
225 void
227 bool both);
228
233 void
234 initialize_quadrature(const unsigned int np, const unsigned int nv);
235
241 void
242 reinit(const BlockIndices &local_sizes);
243
244 template <typename StreamType>
245 void
246 print_debug(StreamType &os) const;
247
251 std::size_t
252 memory_consumption() const;
253
254 private:
258 std::vector<number> J;
259
264 std::vector<BlockVector<number>> R;
265
270 std::vector<MatrixBlock<FullMatrix<number>>> M1;
271
278 std::vector<MatrixBlock<FullMatrix<number>>> M2;
279
284 };
285
286 //----------------------------------------------------------------------//
287
288 template <typename number>
289 inline void
291 {
292 J.resize(n);
293 }
294
295
296 template <typename number>
297 inline void
299 {
300 R.resize(n);
301 }
302
303
304 template <typename number>
305 template <typename MatrixType>
306 inline void
308 const MatrixBlockVector<MatrixType> &matrices,
309 bool both)
310 {
311 M1.resize(matrices.size());
312 if (both)
313 M2.resize(matrices.size());
314 for (unsigned int i = 0; i < matrices.size(); ++i)
315 {
316 const unsigned int row = matrices.block(i).row;
317 const unsigned int col = matrices.block(i).column;
318
319 M1[i].row = row;
320 M1[i].column = col;
321 if (both)
322 {
323 M2[i].row = row;
324 M2[i].column = col;
325 }
326 }
327 }
328
329
330 template <typename number>
331 template <typename MatrixType>
332 inline void
334 const MGMatrixBlockVector<MatrixType> &matrices,
335 bool both)
336 {
337 M1.resize(matrices.size());
338 if (both)
339 M2.resize(matrices.size());
340 for (unsigned int i = 0; i < matrices.size(); ++i)
341 {
342 const MGLevelObject<MatrixBlock<MatrixType>> &o = matrices.block(i);
343 const unsigned int row = o[o.min_level()].row;
344 const unsigned int col = o[o.min_level()].column;
345
346 M1[i].row = row;
347 M1[i].column = col;
348 if (both)
349 {
350 M2[i].row = row;
351 M2[i].column = col;
352 }
353 }
354 }
355
356
357 template <typename number>
358 inline void
360 const bool both)
361 {
362 M1.resize(n);
363 if (both)
364 M2.resize(n);
365 for (unsigned int i = 0; i < n; ++i)
366 {
367 M1[i].row = 0;
368 M1[i].column = 0;
369 if (both)
370 {
371 M2[i].row = 0;
372 M2[i].column = 0;
373 }
374 }
375 }
376
377
378 template <typename number>
379 inline void
381 const unsigned int nv)
382 {
383 quadrature_data.reinit(np, nv);
384 }
385
386
387 template <typename number>
388 inline unsigned int
390 {
391 return J.size();
392 }
393
394
395 template <typename number>
396 inline unsigned int
398 {
399 return R.size();
400 }
401
402
403 template <typename number>
404 inline unsigned int
406 {
407 return M1.size();
408 }
409
410
411 template <typename number>
412 inline unsigned int
414 {
415 return quadrature_data.n_rows();
416 }
417
418
419 template <typename number>
420 inline unsigned int
422 {
423 return quadrature_data.n_cols();
424 }
425
426
427 template <typename number>
428 inline number &
429 LocalResults<number>::value(const unsigned int i)
430 {
431 AssertIndexRange(i, J.size());
432 return J[i];
433 }
434
435
436 template <typename number>
437 inline BlockVector<number> &
438 LocalResults<number>::vector(const unsigned int i)
439 {
440 AssertIndexRange(i, R.size());
441 return R[i];
442 }
443
444
445 template <typename number>
447 LocalResults<number>::matrix(const unsigned int i, const bool external)
448 {
449 if (external)
450 {
451 AssertIndexRange(i, M2.size());
452 return M2[i];
453 }
454 AssertIndexRange(i, M1.size());
455 return M1[i];
456 }
457
458
459 template <typename number>
460 inline number &
462 const unsigned int i)
463 {
464 return quadrature_data(k, i);
465 }
466
467
468 template <typename number>
469 inline Table<2, number> &
471 {
472 return quadrature_data;
473 }
474
475
476 template <typename number>
477 inline number
478 LocalResults<number>::value(const unsigned int i) const
479 {
480 AssertIndexRange(i, J.size());
481 return J[i];
482 }
483
484
485 template <typename number>
486 inline const BlockVector<number> &
487 LocalResults<number>::vector(const unsigned int i) const
488 {
489 AssertIndexRange(i, R.size());
490 return R[i];
491 }
492
493
494 template <typename number>
495 inline const MatrixBlock<FullMatrix<number>> &
496 LocalResults<number>::matrix(const unsigned int i, const bool external) const
497 {
498 if (external)
499 {
500 AssertIndexRange(i, M2.size());
501 return M2[i];
502 }
503 AssertIndexRange(i, M1.size());
504 return M1[i];
505 }
506
507
508 template <typename number>
509 inline number
511 const unsigned int i) const
512 {
513 return quadrature_data(k, i);
514 }
515
516
517 template <typename number>
518 template <typename StreamType>
519 void
521 {
522 os << "J: " << J.size() << std::endl;
523 os << "R: " << R.size() << std::endl;
524 for (unsigned int i = 0; i < R.size(); ++i)
525 {
526 os << " " << R[i].n_blocks() << " -";
527 for (unsigned int j = 0; j < R[i].n_blocks(); ++j)
528 os << ' ' << R[i].block(j).size();
529 os << std::endl;
530 }
531 os << "M: " << M1.size() << " face " << M2.size() << std::endl;
532 for (unsigned int i = 0; i < M1.size(); ++i)
533 {
534 os << " " << M1[i].row << ',' << M1[i].column << ' '
535 << M1[i].matrix.m() << 'x' << M1[i].matrix.n();
536 if (i < M2.size())
537 os << " face " << M2[i].row << ',' << M2[i].column << ' '
538 << M2[i].matrix.m() << 'x' << M2[i].matrix.n();
539 os << std::endl;
540 }
541 }
542
543} // namespace MeshWorker
544
545
547
548#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
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 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_DEPRECATED
Definition config.h:294
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define AssertIndexRange(index, range)