Reference documentation for deal.II version GIT relicensing-822-gf1642d4ea5 2024-06-12 14:10: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
37namespace MeshWorker
38{
80 template <typename number>
82 {
83 public:
89 unsigned int
90 n_values() const;
91
98 unsigned int
99 n_vectors() const;
100
104 unsigned int
105 n_matrices() const;
106
110 unsigned int
112
116 unsigned int
118
122 number &
123 value(const unsigned int i);
124
128 number
129 value(const unsigned int i) const;
130
135 vector(const unsigned int i);
136
140 const BlockVector<number> &
141 vector(const unsigned int i) const;
142
150 matrix(const unsigned int i, const bool external = false);
151
159 matrix(const unsigned int i, const bool external = false) const;
160
168
172 number &
173 quadrature_value(const unsigned int k, const unsigned int i);
174
178 number
179 quadrature_value(const unsigned int k, const unsigned int i) const;
180
186 void
187 initialize_numbers(const unsigned int n);
188
194 void
195 initialize_vectors(const unsigned int n);
196
204 void
205 initialize_matrices(const unsigned int n, bool both);
206
214 template <typename MatrixType>
215 void
217 bool both);
218
226 template <typename MatrixType>
227 void
229 bool both);
230
235 void
236 initialize_quadrature(const unsigned int np, const unsigned int nv);
237
243 void
245
246 template <typename StreamType>
247 void
249
253 std::size_t
254 memory_consumption() const;
255
256 private:
260 std::vector<number> J;
261
266 std::vector<BlockVector<number>> R;
267
272 std::vector<MatrixBlock<FullMatrix<number>>> M1;
273
280 std::vector<MatrixBlock<FullMatrix<number>>> M2;
281
286 };
287
288 //----------------------------------------------------------------------//
289
290 template <typename number>
291 inline void
293 {
294 J.resize(n);
295 }
296
297
298 template <typename number>
299 inline void
301 {
302 R.resize(n);
303 }
304
305
306 template <typename number>
307 template <typename MatrixType>
308 inline void
310 const MatrixBlockVector<MatrixType> &matrices,
311 bool both)
312 {
313 M1.resize(matrices.size());
314 if (both)
315 M2.resize(matrices.size());
316 for (unsigned int i = 0; i < matrices.size(); ++i)
317 {
318 const unsigned int row = matrices.block(i).row;
319 const unsigned int col = matrices.block(i).column;
320
321 M1[i].row = row;
322 M1[i].column = col;
323 if (both)
324 {
325 M2[i].row = row;
326 M2[i].column = col;
327 }
328 }
329 }
330
331
332 template <typename number>
333 template <typename MatrixType>
334 inline void
336 const MGMatrixBlockVector<MatrixType> &matrices,
337 bool both)
338 {
339 M1.resize(matrices.size());
340 if (both)
341 M2.resize(matrices.size());
342 for (unsigned int i = 0; i < matrices.size(); ++i)
343 {
344 const MGLevelObject<MatrixBlock<MatrixType>> &o = matrices.block(i);
345 const unsigned int row = o[o.min_level()].row;
346 const unsigned int col = o[o.min_level()].column;
347
348 M1[i].row = row;
349 M1[i].column = col;
350 if (both)
351 {
352 M2[i].row = row;
353 M2[i].column = col;
354 }
355 }
356 }
357
358
359 template <typename number>
360 inline void
362 const bool both)
363 {
364 M1.resize(n);
365 if (both)
366 M2.resize(n);
367 for (unsigned int i = 0; i < n; ++i)
368 {
369 M1[i].row = 0;
370 M1[i].column = 0;
371 if (both)
372 {
373 M2[i].row = 0;
374 M2[i].column = 0;
375 }
376 }
377 }
378
379
380 template <typename number>
381 inline void
383 const unsigned int nv)
384 {
385 quadrature_data.reinit(np, nv);
386 }
387
388
389 template <typename number>
390 inline unsigned int
392 {
393 return J.size();
394 }
395
396
397 template <typename number>
398 inline unsigned int
400 {
401 return R.size();
402 }
403
404
405 template <typename number>
406 inline unsigned int
408 {
409 return M1.size();
410 }
411
412
413 template <typename number>
414 inline unsigned int
416 {
417 return quadrature_data.n_rows();
418 }
419
420
421 template <typename number>
422 inline unsigned int
424 {
425 return quadrature_data.n_cols();
426 }
427
428
429 template <typename number>
430 inline number &
431 LocalResults<number>::value(const unsigned int i)
432 {
433 AssertIndexRange(i, J.size());
434 return J[i];
435 }
436
437
438 template <typename number>
439 inline BlockVector<number> &
440 LocalResults<number>::vector(const unsigned int i)
441 {
442 AssertIndexRange(i, R.size());
443 return R[i];
444 }
445
446
447 template <typename number>
449 LocalResults<number>::matrix(const unsigned int i, const bool external)
450 {
451 if (external)
452 {
453 AssertIndexRange(i, M2.size());
454 return M2[i];
455 }
456 AssertIndexRange(i, M1.size());
457 return M1[i];
458 }
459
460
461 template <typename number>
462 inline number &
464 const unsigned int i)
465 {
466 return quadrature_data(k, i);
467 }
468
469
470 template <typename number>
471 inline Table<2, number> &
473 {
474 return quadrature_data;
475 }
476
477
478 template <typename number>
479 inline number
480 LocalResults<number>::value(const unsigned int i) const
481 {
482 AssertIndexRange(i, J.size());
483 return J[i];
484 }
485
486
487 template <typename number>
488 inline const BlockVector<number> &
489 LocalResults<number>::vector(const unsigned int i) const
490 {
491 AssertIndexRange(i, R.size());
492 return R[i];
493 }
494
495
496 template <typename number>
497 inline const MatrixBlock<FullMatrix<number>> &
498 LocalResults<number>::matrix(const unsigned int i, const bool external) const
499 {
500 if (external)
501 {
502 AssertIndexRange(i, M2.size());
503 return M2[i];
504 }
505 AssertIndexRange(i, M1.size());
506 return M1[i];
507 }
508
509
510 template <typename number>
511 inline number
513 const unsigned int i) const
514 {
515 return quadrature_data(k, i);
516 }
517
518
519 template <typename number>
520 template <typename StreamType>
521 void
523 {
524 os << "J: " << J.size() << std::endl;
525 os << "R: " << R.size() << std::endl;
526 for (unsigned int i = 0; i < R.size(); ++i)
527 {
528 os << " " << R[i].n_blocks() << " -";
529 for (unsigned int j = 0; j < R[i].n_blocks(); ++j)
530 os << ' ' << R[i].block(j).size();
531 os << std::endl;
532 }
533 os << "M: " << M1.size() << " face " << M2.size() << std::endl;
534 for (unsigned int i = 0; i < M1.size(); ++i)
535 {
536 os << " " << M1[i].row << ',' << M1[i].column << ' '
537 << M1[i].matrix.m() << 'x' << M1[i].matrix.n();
538 if (i < M2.size())
539 os << " face " << M2[i].row << ',' << M2[i].column << ' '
540 << M2[i].matrix.m() << 'x' << M2[i].matrix.n();
541 os << std::endl;
542 }
543 }
544
545} // namespace MeshWorker
546
547
549
550#endif
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)