Reference documentation for deal.II version 9.0.0
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 at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 
17 #ifndef dealii_mesh_worker_output_h
18 #define dealii_mesh_worker_output_h
19 
20 #include <deal.II/meshworker/dof_info.h>
21 #include <deal.II/base/smartpointer.h>
22 #include <deal.II/base/utilities.h>
23 #include <deal.II/lac/block_vector.h>
24 #include <deal.II/base/mg_level_object.h>
25 
26 
27 DEAL_II_NAMESPACE_OPEN
28 
29 namespace MeshWorker
30 {
31  namespace Assembler
32  {
33 
58  {
59  public:
63  GnuplotPatch();
64 
74  void initialize (const unsigned int n_points,
75  const unsigned int n_vectors);
76 
81  void initialize_stream (std::ostream &stream);
82 
90  template <int dim>
91  void initialize_info(DoFInfo<dim> &info, bool face);
92 
96  template <int dim>
97  void assemble(const DoFInfo<dim> &info);
98 
102  template <int dim>
103  void assemble(const DoFInfo<dim> &info1,
104  const DoFInfo<dim> &info2);
105 
106  private:
111  template <typename T>
112  void write(const T &t) const;
113 
119  void write_endl () const;
120 
124  unsigned int n_vectors;
128  unsigned int n_points;
129 
133  std::ostream *os;
134  };
135 
136 //----------------------------------------------------------------------//
137 
138  template <typename T>
139  inline void
140  GnuplotPatch::write(const T &d) const
141  {
142  if (os == nullptr)
143  deallog << d;
144  else
145  (*os) << d;
146  }
147 
148 
149  inline void
151  {
152  if (os == nullptr)
153  deallog << std::endl;
154  else
155  (*os) << std::endl;
156  }
157 
158 
159  inline
161  :
162  n_vectors(numbers::invalid_unsigned_int),
163  n_points(numbers::invalid_unsigned_int),
164  os(nullptr)
165  {}
166 
167 
168  inline void
169  GnuplotPatch::initialize (const unsigned int np,
170  const unsigned int nv)
171  {
172  n_vectors = nv;
173  n_points = np;
174  }
175 
176 
177  inline void
178  GnuplotPatch::initialize_stream (std::ostream &stream)
179  {
180  os = &stream;
181  }
182 
183 
184  template <int dim>
185  inline void
187  {
188  if (face)
189  info.initialize_quadrature(Utilities::fixed_power<dim-1>(n_points), n_vectors+dim);
190  else
191  info.initialize_quadrature(Utilities::fixed_power<dim>(n_points), n_vectors+dim);
192  }
193 
194 
195  template <int dim>
196  inline void
198  {
199  const unsigned int np = info.n_quadrature_points();
200  const unsigned int nv = info.n_quadrature_values();
201  const unsigned int patch_dim = (info.face_number == numbers::invalid_unsigned_int)
202  ? dim : (dim-1);
203  const unsigned int row_length = n_points;
204  // If patches are 1D, end the
205  // patch after a row, else end
206  // it after a square
207  const unsigned int row_length2 = (patch_dim==1) ? row_length : (row_length*row_length);
208 
209 // AssertDimension(np, Utilities::fixed_power<dim>(n_points));
210  AssertDimension(nv, n_vectors+dim);
211 
212 
213  for (unsigned int k=0; k<np; ++k)
214  {
215  if (k % row_length == 0)
216  write_endl();
217  if (k % row_length2 == 0)
218  write_endl();
219 
220  for (unsigned int i=0; i<nv; ++i)
221  {
222  write(info.quadrature_value(k,i));
223  write('\t');
224  }
225  write_endl();
226  }
227  }
228 
229 
230  template <int dim>
231  inline void
233  {
234  assemble(info1);
235  assemble(info2);
236  }
237  }
238 }
239 
240 DEAL_II_NAMESPACE_CLOSE
241 
242 #endif
static const unsigned int invalid_unsigned_int
Definition: types.h:173
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1248
unsigned int n_quadrature_values() const
void assemble(const DoFInfo< dim > &info)
Definition: output.h:197
void initialize_quadrature(unsigned int np, unsigned int nv)
number & quadrature_value(unsigned int k, unsigned int i)
void write(const T &t) const
Definition: output.h:140
void initialize_info(DoFInfo< dim > &info, bool face)
Definition: output.h:186
void initialize(const unsigned int n_points, const unsigned int n_vectors)
Definition: output.h:169
void initialize_stream(std::ostream &stream)
Definition: output.h:178
unsigned int face_number
Definition: dof_info.h:84
unsigned int n_quadrature_points() const