/usr/include/deal.II/numerics/dof_print_solver_step.h is in libdeal.ii-dev 6.3.1-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | //---------------------------------------------------------------------------
// $Id: dof_print_solver_step.h 14038 2006-10-23 02:46:34Z bangerth $
// Version: $Name$
//
// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
// to the file deal.II/doc/license.html for the text and
// further information on this license.
//
//---------------------------------------------------------------------------
#ifndef __deal2__dof_print_solver_step_h
#define __deal2__dof_print_solver_step_h
#include <base/config.h>
#include <base/logstream.h>
#include <lac/solver_control.h>
#include <lac/vector_memory.h>
#include <numerics/data_out.h>
#include <sstream>
#include <iomanip>
#include <fstream>
DEAL_II_NAMESPACE_OPEN
/**
* Print intermediate solutions in solvers. This is derived from a
* solver class provided as template argument. It implements the
* @p print_vector function of the solver using a
* DoFHandler. This way, the intermediate vectors can be viewed
* as finite element functions. This class might be used first to
* understand how solvers work (for example to visualize the smoothing
* properties of various solvers, e.g. in a multigrid context), and
* second to investigate why and how a solver fails to solve certain
* classes of problems.
*
* Objects of this class are provided with a solver class through a
* template argument, and with a file name (as a string), with which a
* new file is constructed in each iteration (named
* <tt>basename.[step].[suffix]</tt>) and into which the solution is
* written as a finite element field using the DataOut class.
* Please note that this class may produce enormous amounts of data!
*
* @ingroup output
* @author Guido Kanschat, 2000
*/
template<int dim, class SOLVER, class VECTOR = Vector<double> >
class DoFPrintSolverStep : public SOLVER
{
public:
/**
* Constructor. First, we take
* the arguments needed for the
* solver. @p data_out is the
* object doing the output as a
* finite element function.
*
* One output file with the name
* <tt>basename.[step].[suffix]</tt>
* will be produced for each
* iteration step.
*/
DoFPrintSolverStep (SolverControl& control,
VectorMemory<VECTOR>& mem,
DataOut<dim>& data_out,
const std::string& basename);
/**
* Call-back function for the
* iterative method.
*/
virtual void print_vectors (const unsigned int step,
const VECTOR& x,
const VECTOR& r,
const VECTOR& d) const;
private:
/**
* Output object.
*/
DataOut<dim>& out;
/**
* Base of filenames.
*/
const std::string basename;
};
/* ----------------------- template functions --------------- */
template<int dim, class SOLVER, class VECTOR>
DoFPrintSolverStep<dim, SOLVER, VECTOR>::DoFPrintSolverStep (SolverControl& control,
VectorMemory<VECTOR>& mem,
DataOut<dim>& data_out,
const std::string& basename)
: SOLVER (control, mem),
out (data_out),
basename (basename)
{}
template<int dim, class SOLVER, class VECTOR>
void
DoFPrintSolverStep<dim, SOLVER, VECTOR>::print_vectors (const unsigned int step,
const VECTOR& x,
const VECTOR& r,
const VECTOR& d) const
{
out.clear_data_vectors();
out.add_data_vector(x, "solution");
out.add_data_vector(r, "residual");
out.add_data_vector(d, "update");
std::ostringstream filename;
filename << basename
<< std::setw(3) << std::setfill('0') << step
<< out.default_suffix();
const std::string fname = filename.str();
deallog << "Writing file:" << fname << std::endl;
out.build_patches();
std::ofstream of (fname.c_str());
out.write (of);
}
DEAL_II_NAMESPACE_CLOSE
#endif
|