Reference documentation for deal.II version 9.3.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 - 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 
21 #include <deal.II/base/logstream.h>
22 
25 
27 
28 #include <fstream>
29 #include <iomanip>
30 #include <sstream>
31 
33 
34 
54 template <int dim, typename SolverType, class VectorType = Vector<double>>
56 {
57 public:
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 
79 private:
84 
88  const std::string basename;
89 };
90 
91 
92 /* ----------------------- template functions --------------- */
93 
94 template <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 
106 template <int dim, typename SolverType, class VectorType>
107 void
109  const unsigned int step,
110  const VectorType & x,
111  const VectorType & r,
112  const VectorType & d) const
113 {
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
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:1085
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:395
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:394
void clear_data_vectors()
const std::string basename
DoFPrintSolverStep(SolverControl &control, VectorMemory< VectorType > &mem, DataOut< dim > &data_out, const std::string &basename)