Debian Codegraph @

include/deal.II/algorithms/operator.templates.h

raw
1 // ------------------------------------------------------------------------
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 // Copyright (C) 2006 - 2019 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 #ifndef dealii_operator_templates_h
16 #define dealii_operator_templates_h
17
18
19 #include <deal.II/base/config.h>
20
21 #include <deal.II/algorithms/operator.h>
22
23 #include <deal.II/base/logstream.h>
24
25 #include <deal.II/lac/vector_element_access.h>
26
27 DEAL_II_NAMESPACE_OPEN
28
29 namespace Algorithms
30 {
31 template <typename VectorType>
32 OutputOperator<VectorType>::OutputOperator()
33 : step(numbers::invalid_unsigned_int)
34 , os(nullptr)
35 {}
36
37 template <typename VectorType>
38 void
39 OutputOperator<VectorType>::initialize_stream(std::ostream &stream)
40 {
41 os = &stream;
42 }
43
44 template <typename VectorType>
45 OutputOperator<VectorType> &
46 OutputOperator<VectorType>::operator<<(const AnyData &vectors)
47 {
48 if (os == nullptr)
49 {
50 deallog << "Step " << step << std::endl;
51 for (unsigned int i = 0; i < vectors.size(); ++i)
52 {
53 const VectorType *v = vectors.try_read_ptr<VectorType>(i);
54 if (v == nullptr)
55 continue;
56 deallog << vectors.name(i);
57 for (unsigned int j = 0; j < v->size(); ++j)
58 deallog << ' '
59 << ::dealii::internal::ElementAccess<VectorType>::get(*v,
60 j);
61 deallog << std::endl;
62 }
63 deallog << std::endl;
64 }
65 else
66 {
67 (*os) << ' ' << step;
68 for (unsigned int i = 0; i < vectors.size(); ++i)
69 {
70 const VectorType *v = vectors.try_read_ptr<VectorType>(i);
71 if (v == nullptr)
72 continue;
73 for (unsigned int j = 0; j < v->size(); ++j)
74 (*os) << ' '
75 << ::dealii::internal::ElementAccess<VectorType>::get(*v,
76 j);
77 }
78 (*os) << std::endl;
79 }
80 return *this;
81 }
82 } // namespace Algorithms
83
84 DEAL_II_NAMESPACE_CLOSE
85
86 #endif