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 {
115  out.clear_data_vectors();
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
DoFPrintSolverStep
Definition: dof_print_solver_step.h:56
DoFPrintSolverStep::print_vectors
virtual void print_vectors(const unsigned int step, const VectorType &x, const VectorType &r, const VectorType &d) const
Definition: dof_print_solver_step.h:109
VectorType
SolverType
Physics::Elasticity::Kinematics::d
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
deallog
LogStream deallog
Definition: logstream.cc:37
DoFPrintSolverStep::basename
const std::string basename
Definition: dof_print_solver_step.h:89
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
DoFPrintSolverStep::out
DataOut< dim > & out
Definition: dof_print_solver_step.h:84
vector_memory.h
config.h
SolverControl
Definition: solver_control.h:67
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
DoFPrintSolverStep::DoFPrintSolverStep
DoFPrintSolverStep(SolverControl &control, VectorMemory< VectorType > &mem, DataOut< dim > &data_out, const std::string &basename)
Definition: dof_print_solver_step.h:96
logstream.h
data_out.h
DataOut< dim >
solver_control.h
VectorMemory
Definition: vector_memory.h:107