deal.II version GIT relicensing-6917-gb466a1809f 2026-10-16 06:30: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
dof_print_solver_step.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) 2000 - 2023 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#ifndef dealii_dof_print_solver_step_h
14#define dealii_dof_print_solver_step_h
15
16#include <deal.II/base/config.h>
17
19
22
24
25#include <fstream>
26#include <iomanip>
27#include <sstream>
28
30
31
51template <int dim, typename SolverType, typename VectorType = Vector<double>>
52class DoFPrintSolverStep : public SolverType
53{
54public:
64 DataOut<dim> &data_out,
65 const std::string &basename);
66
70 virtual void
71 print_vectors(const unsigned int step,
72 const VectorType &x,
73 const VectorType &r,
74 const VectorType &d) const;
75
76private:
81
85 const std::string basename;
86};
87
88
89/* ----------------------- template functions --------------- */
90
91template <int dim, typename SolverType, typename VectorType>
93 SolverControl &control,
95 DataOut<dim> &data_out,
96 const std::string &basename)
97 : SolverType(control, mem)
98 , out(data_out)
99 , basename(basename)
100{}
101
102
103template <int dim, typename SolverType, typename VectorType>
104void
106 const unsigned int step,
107 const VectorType &x,
108 const VectorType &r,
109 const VectorType &d) const
110{
111 out.clear_data_vectors();
112 out.add_data_vector(x, "solution");
113 out.add_data_vector(r, "residual");
114 out.add_data_vector(d, "update");
115
116 std::ostringstream filename;
117 filename << basename << std::setw(3) << std::setfill('0') << step
118 << out.default_suffix();
119
120 const std::string fname = filename.str();
121
122 deallog << "Writing file:" << fname << std::endl;
123
124 out.build_patches();
125 std::ofstream of(fname);
126 out.write(of);
127}
128
130
131#endif
const std::string basename
DoFPrintSolverStep(SolverControl &control, VectorMemory< VectorType > &mem, DataOut< dim > &data_out, const std::string &basename)
virtual void print_vectors(const unsigned int step, const VectorType &x, const VectorType &r, const VectorType &d) const
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
LogStream deallog
Definition logstream.cc:36