Reference documentation for deal.II version 8.1.0
output.h
1 // ---------------------------------------------------------------------
2 // @f$Id: output.h 30036 2013-07-18 16:55:32Z maier @f$
3 //
4 // Copyright (C) 2010 - 2013 by the deal.II authors
5 //
6 // This file is part of the deal.II library.
7 //
8 // The deal.II library is free software; you can use it, redistribute
9 // it, and/or modify it under the terms of the GNU Lesser General
10 // Public License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 // The full text of the license can be found in the file LICENSE at
13 // the top level of the deal.II distribution.
14 //
15 // ---------------------------------------------------------------------
16 
17 
18 #ifndef __deal2__mesh_worker_output_h
19 #define __deal2__mesh_worker_output_h
20 
21 #include <deal.II/meshworker/dof_info.h>
22 #include <deal.II/base/named_data.h>
23 #include <deal.II/base/smartpointer.h>
24 #include <deal.II/base/utilities.h>
25 #include <deal.II/lac/block_vector.h>
26 #include <deal.II/base/mg_level_object.h>
27 
28 
30 
31 namespace MeshWorker
32 {
33  namespace Assembler
34  {
35 
60  {
61  public:
65  GnuplotPatch();
66 
87  void initialize (const unsigned int n_points,
88  const unsigned int n_vectors);
89 
97  void initialize_stream (std::ostream &stream);
98 
112  template <int dim>
113  void initialize_info(DoFInfo<dim> &info, bool face);
114 
119  template<int dim>
120  void assemble(const DoFInfo<dim> &info);
121 
125  template<int dim>
126  void assemble(const DoFInfo<dim> &info1,
127  const DoFInfo<dim> &info2);
128 
129  private:
137  template<typename T>
138  void write(const T &t) const;
139 
147  void write_endl () const;
148 
153  unsigned int n_vectors;
158  unsigned int n_points;
159 
163  std::ostream *os;
164  };
165 
166 //----------------------------------------------------------------------//
167 
168  template <typename T>
169  inline void
170  GnuplotPatch::write(const T &d) const
171  {
172  if (os == 0)
173  deallog << d;
174  else
175  (*os) << d;
176  }
177 
178 
179  inline void
181  {
182  if (os == 0)
183  deallog << std::endl;
184  else
185  (*os) << std::endl;
186  }
187 
188 
189  inline
191  :
192  os(0)
193  {}
194 
195 
196  inline void
197  GnuplotPatch::initialize (const unsigned int np,
198  const unsigned int nv)
199  {
200  n_vectors = nv;
201  n_points = np;
202  }
203 
204 
205  inline void
206  GnuplotPatch::initialize_stream (std::ostream &stream)
207  {
208  os = &stream;
209  }
210 
211 
212  template <int dim>
213  inline void
215  {
216  if (face)
217  info.initialize_quadrature(Utilities::fixed_power<dim-1>(n_points), n_vectors+dim);
218  else
219  info.initialize_quadrature(Utilities::fixed_power<dim>(n_points), n_vectors+dim);
220  }
221 
222 
223  template <int dim>
224  inline void
226  {
227  const unsigned int np = info.n_quadrature_points();
228  const unsigned int nv = info.n_quadrature_values();
229  const unsigned int patch_dim = (info.face_number == numbers::invalid_unsigned_int)
230  ? dim : (dim-1);
231  const unsigned int row_length = n_points;
232  // If patches are 1D, end the
233  // patch after a row, else end
234  // it after a square
235  const unsigned int row_length2 = (patch_dim==1) ? row_length : (row_length*row_length);
236 
237 // AssertDimension(np, Utilities::fixed_power<dim>(n_points));
238  AssertDimension(nv, n_vectors+dim);
239 
240 
241  for (unsigned int k=0; k<np; ++k)
242  {
243  if (k % row_length == 0)
244  write_endl();
245  if (k % row_length2 == 0)
246  write_endl();
247 
248  for (unsigned int i=0; i<nv; ++i)
249  {
250  write(info.quadrature_value(k,i));
251  write('\t');
252  }
253  write_endl();
254  }
255  }
256 
257 
258  template <int dim>
259  inline void
261  {
262  assemble(info1);
263  assemble(info2);
264  }
265  }
266 }
267 
268 DEAL_II_NAMESPACE_CLOSE
269 
270 #endif
static const unsigned int invalid_unsigned_int
Definition: types.h:191
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:858
void assemble(const DoFInfo< dim > &info)
Definition: output.h:225
void initialize_quadrature(unsigned int np, unsigned int nv)
void write(const T &t) const
Definition: output.h:170
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:214
void initialize(const unsigned int n_points, const unsigned int n_vectors)
Definition: output.h:197
unsigned int n_quadrature_points() const
void initialize_stream(std::ostream &stream)
Definition: output.h:206
unsigned int face_number
Definition: dof_info.h:88