Reference documentation for deal.II version 9.3.3
\(\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\}}\)
dof_print_solver_step.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2000 - 2020 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16#ifndef dealii_dof_print_solver_step_h
17#define dealii_dof_print_solver_step_h
18
19#include <deal.II/base/config.h>
20
22
25
27
28#include <fstream>
29#include <iomanip>
30#include <sstream>
31
33
34
54template <int dim, typename SolverType, class VectorType = Vector<double>>
56{
57public:
67 DataOut<dim> & data_out,
68 const std::string & basename);
69
73 virtual void
74 print_vectors(const unsigned int step,
75 const VectorType & x,
76 const VectorType & r,
77 const VectorType & d) const;
78
79private:
84
88 const std::string basename;
89};
90
91
92/* ----------------------- template functions --------------- */
93
94template <int dim, typename SolverType, class VectorType>
96 SolverControl & control,
98 DataOut<dim> & data_out,
99 const std::string & basename)
100 : SolverType(control, mem)
101 , out(data_out)
102 , basename(basename)
103{}
104
105
106template <int dim, typename SolverType, class VectorType>
107void
109 const unsigned int step,
110 const VectorType & x,
111 const VectorType & r,
112 const VectorType & d) const
113{
114 out.clear_data_vectors();
115 out.add_data_vector(x, "solution");
116 out.add_data_vector(r, "residual");
117 out.add_data_vector(d, "update");
118
119 std::ostringstream filename;
120 filename << basename << std::setw(3) << std::setfill('0') << step
121 << out.default_suffix();
122
123 const std::string fname = filename.str();
124
125 deallog << "Writing file:" << fname << std::endl;
126
127 out.build_patches();
128 std::ofstream of(fname.c_str());
129 out.write(of);
130}
131
133
134#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:402
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:403
LogStream deallog
Definition: logstream.cc:37
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)