Reference documentation for deal.II version 9.6.0
\(\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: 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// 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_dof_print_solver_step_h
16#define dealii_dof_print_solver_step_h
17
18#include <deal.II/base/config.h>
19
21
24
26
27#include <fstream>
28#include <iomanip>
29#include <sstream>
30
32
33
53template <int dim, typename SolverType, typename VectorType = Vector<double>>
54class DoFPrintSolverStep : public SolverType
55{
56public:
66 DataOut<dim> &data_out,
67 const std::string &basename);
68
72 virtual void
73 print_vectors(const unsigned int step,
74 const VectorType &x,
75 const VectorType &r,
76 const VectorType &d) const;
77
78private:
83
87 const std::string basename;
88};
89
90
91/* ----------------------- template functions --------------- */
92
93template <int dim, typename SolverType, typename VectorType>
95 SolverControl &control,
97 DataOut<dim> &data_out,
98 const std::string &basename)
99 : SolverType(control, mem)
100 , out(data_out)
101 , basename(basename)
102{}
103
104
105template <int dim, typename SolverType, typename VectorType>
106void
108 const unsigned int step,
109 const VectorType &x,
110 const VectorType &r,
111 const VectorType &d) const
112{
113 out.clear_data_vectors();
114 out.add_data_vector(x, "solution");
115 out.add_data_vector(r, "residual");
116 out.add_data_vector(d, "update");
117
118 std::ostringstream filename;
119 filename << basename << std::setw(3) << std::setfill('0') << step
120 << out.default_suffix();
121
122 const std::string fname = filename.str();
123
124 deallog << "Writing file:" << fname << std::endl;
125
126 out.build_patches();
127 std::ofstream of(fname);
128 out.write(of);
129}
130
132
133#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:503
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:504
LogStream deallog
Definition logstream.cc:36