Reference documentation for deal.II version 9.2.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\}}\)
dof_print_solver_step.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2000 - 2018 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 
21 #include <deal.II/base/logstream.h>
22 
25 
27 
28 #include <fstream>
29 #include <iomanip>
30 #include <sstream>
31 
33 
34 
55 template <int dim, typename SolverType, class VectorType = Vector<double>>
57 {
58 public:
68  DataOut<dim> & data_out,
69  const std::string & basename);
70 
74  virtual void
75  print_vectors(const unsigned int step,
76  const VectorType & x,
77  const VectorType & r,
78  const VectorType & d) const;
79 
80 private:
85 
89  const std::string basename;
90 };
91 
92 
93 /* ----------------------- template functions --------------- */
94 
95 template <int dim, typename SolverType, class VectorType>
97  SolverControl & control,
99  DataOut<dim> & data_out,
100  const std::string & basename)
101  : SolverType(control, mem)
102  , out(data_out)
103  , basename(basename)
104 {}
105 
106 
107 template <int dim, typename SolverType, class VectorType>
108 void
110  const unsigned int step,
111  const VectorType & x,
112  const VectorType & r,
113  const VectorType & d) const
114 {
116  out.add_data_vector(x, "solution");
117  out.add_data_vector(r, "residual");
118  out.add_data_vector(d, "update");
119 
120  std::ostringstream filename;
121  filename << basename << std::setw(3) << std::setfill('0') << step
122  << out.default_suffix();
123 
124  const std::string fname = filename.str();
125 
126  deallog << "Writing file:" << fname << std::endl;
127 
128  out.build_patches();
129  std::ofstream of(fname.c_str());
130  out.write(of);
131 }
132 
134 
135 #endif
LogStream deallog
Definition: logstream.cc:37
void write(std::ostream &out, const DataOutBase::OutputFormat output_format=DataOutBase::default_format) const
std::string default_suffix(const DataOutBase::OutputFormat output_format=DataOutBase::default_format) const
virtual void build_patches(const unsigned int n_subdivisions=0)
Definition: data_out.cc:1071
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
void add_data_vector(const VectorType &data, const std::vector< std::string > &names, const DataVectorType type=type_automatic, const std::vector< DataComponentInterpretation::DataComponentInterpretation > &data_component_interpretation=std::vector< DataComponentInterpretation::DataComponentInterpretation >())
virtual void print_vectors(const unsigned int step, const VectorType &x, const VectorType &r, const VectorType &d) const
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
void clear_data_vectors()
const std::string basename
DoFPrintSolverStep(SolverControl &control, VectorMemory< VectorType > &mem, DataOut< dim > &data_out, const std::string &basename)