Reference documentation for deal.II version 9.1.0-pre
output.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2010 - 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 
17 #ifndef dealii_mesh_worker_output_h
18 #define dealii_mesh_worker_output_h
19 
20 #include <deal.II/base/mg_level_object.h>
21 #include <deal.II/base/smartpointer.h>
22 #include <deal.II/base/utilities.h>
23 
24 #include <deal.II/lac/block_vector.h>
25 
26 #include <deal.II/meshworker/dof_info.h>
27 
28 
29 DEAL_II_NAMESPACE_OPEN
30 
31 namespace MeshWorker
32 {
33  namespace Assembler
34  {
59  {
60  public:
64  GnuplotPatch();
65 
75  void
76  initialize(const unsigned int n_points, const unsigned int n_vectors);
77 
82  void
83  initialize_stream(std::ostream &stream);
84 
92  template <int dim>
93  void
94  initialize_info(DoFInfo<dim> &info, bool face);
95 
99  template <int dim>
100  void
101  assemble(const DoFInfo<dim> &info);
102 
106  template <int dim>
107  void
108  assemble(const DoFInfo<dim> &info1, const DoFInfo<dim> &info2);
109 
110  private:
115  template <typename T>
116  void
117  write(const T &t) const;
118 
124  void
125  write_endl() const;
126 
130  unsigned int n_vectors;
134  unsigned int n_points;
135 
139  std::ostream *os;
140  };
141 
142  //----------------------------------------------------------------------//
143 
144  template <typename T>
145  inline void
146  GnuplotPatch::write(const T &d) const
147  {
148  if (os == nullptr)
149  deallog << d;
150  else
151  (*os) << d;
152  }
153 
154 
155  inline void
157  {
158  if (os == nullptr)
159  deallog << std::endl;
160  else
161  (*os) << std::endl;
162  }
163 
164 
166  : n_vectors(numbers::invalid_unsigned_int)
167  , n_points(numbers::invalid_unsigned_int)
168  , os(nullptr)
169  {}
170 
171 
172  inline void
173  GnuplotPatch::initialize(const unsigned int np, const unsigned int nv)
174  {
175  n_vectors = nv;
176  n_points = np;
177  }
178 
179 
180  inline void
181  GnuplotPatch::initialize_stream(std::ostream &stream)
182  {
183  os = &stream;
184  }
185 
186 
187  template <int dim>
188  inline void
190  {
191  if (face)
192  info.initialize_quadrature(Utilities::fixed_power<dim - 1>(n_points),
193  n_vectors + dim);
194  else
195  info.initialize_quadrature(Utilities::fixed_power<dim>(n_points),
196  n_vectors + dim);
197  }
198 
199 
200  template <int dim>
201  inline void
203  {
204  const unsigned int np = info.n_quadrature_points();
205  const unsigned int nv = info.n_quadrature_values();
206  const unsigned int patch_dim =
207  (info.face_number == numbers::invalid_unsigned_int) ? dim : (dim - 1);
208  const unsigned int row_length = n_points;
209  // If patches are 1D, end the
210  // patch after a row, else end
211  // it after a square
212  const unsigned int row_length2 =
213  (patch_dim == 1) ? row_length : (row_length * row_length);
214 
215  // AssertDimension(np, Utilities::fixed_power<dim>(n_points));
216  AssertDimension(nv, n_vectors + dim);
217 
218 
219  for (unsigned int k = 0; k < np; ++k)
220  {
221  if (k % row_length == 0)
222  write_endl();
223  if (k % row_length2 == 0)
224  write_endl();
225 
226  for (unsigned int i = 0; i < nv; ++i)
227  {
228  write(info.quadrature_value(k, i));
229  write('\t');
230  }
231  write_endl();
232  }
233  }
234 
235 
236  template <int dim>
237  inline void
239  {
240  assemble(info1);
241  assemble(info2);
242  }
243  } // namespace Assembler
244 } // namespace MeshWorker
245 
246 DEAL_II_NAMESPACE_CLOSE
247 
248 #endif
static const unsigned int invalid_unsigned_int
Definition: types.h:173
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1366
void assemble(const DoFInfo< dim > &info)
Definition: output.h:202
void initialize_quadrature(unsigned int np, unsigned int nv)
void write(const T &t) const
Definition: output.h:146
number & quadrature_value(unsigned int k, unsigned int i)
unsigned int n_quadrature_values() const
void initialize_info(DoFInfo< dim > &info, bool face)
Definition: output.h:189
void initialize(const unsigned int n_points, const unsigned int n_vectors)
Definition: output.h:173
unsigned int n_quadrature_points() const
void initialize_stream(std::ostream &stream)
Definition: output.h:181
unsigned int face_number
Definition: dof_info.h:89