00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef __deal2__mesh_worker_output_h
00014 #define __deal2__mesh_worker_output_h
00015
00016 #include <deal.II/meshworker/dof_info.h>
00017 #include <deal.II/base/named_data.h>
00018 #include <deal.II/base/smartpointer.h>
00019 #include <deal.II/base/utilities.h>
00020 #include <deal.II/lac/block_vector.h>
00021 #include <deal.II/base/mg_level_object.h>
00022
00023
00024 DEAL_II_NAMESPACE_OPEN
00025
00026 namespace MeshWorker
00027 {
00028 namespace Assembler
00029 {
00030
00039 class GnuplotPatch
00040 {
00041 public:
00045 GnuplotPatch();
00046
00064 void initialize (const unsigned int n_points,
00065 const unsigned int n_vectors);
00066
00074 void initialize_stream (std::ostream& stream);
00075
00089 template <int dim>
00090 void initialize_info(DoFInfo<dim>& info, bool face);
00091
00096 template<int dim>
00097 void assemble(const DoFInfo<dim>& info);
00098
00103 template<int dim>
00104 void assemble(const DoFInfo<dim>& info1,
00105 const DoFInfo<dim>& info2);
00106
00107 private:
00115 template<typename T>
00116 void write(const T& t) const;
00117
00125 void write_endl () const;
00126
00131 unsigned int n_vectors;
00136 unsigned int n_points;
00137
00141 std::ostream* os;
00142 };
00143
00144
00145
00146 template <typename T>
00147 inline void
00148 GnuplotPatch::write(const T& d) const
00149 {
00150 if (os == 0)
00151 deallog << d;
00152 else
00153 (*os) << d;
00154 }
00155
00156
00157 inline void
00158 GnuplotPatch::write_endl() const
00159 {
00160 if (os == 0)
00161 deallog << std::endl;
00162 else
00163 (*os) << std::endl;
00164 }
00165
00166
00167 inline
00168 GnuplotPatch::GnuplotPatch()
00169 :
00170 os(0)
00171 {}
00172
00173
00174 inline void
00175 GnuplotPatch::initialize (const unsigned int np,
00176 const unsigned int nv)
00177 {
00178 n_vectors = nv;
00179 n_points = np;
00180 }
00181
00182
00183 inline void
00184 GnuplotPatch::initialize_stream (std::ostream& stream)
00185 {
00186 os = &stream;
00187 }
00188
00189
00190 template <int dim>
00191 inline void
00192 GnuplotPatch::initialize_info(DoFInfo<dim>& info, bool face)
00193 {
00194 if (face)
00195 info.initialize_quadrature(Utilities::fixed_power<dim-1>(n_points), n_vectors+dim);
00196 else
00197 info.initialize_quadrature(Utilities::fixed_power<dim>(n_points), n_vectors+dim);
00198 }
00199
00200
00201 template <int dim>
00202 inline void
00203 GnuplotPatch::assemble(const DoFInfo<dim>& info)
00204 {
00205 const unsigned int np = info.n_quadrature_points();
00206 const unsigned int nv = info.n_quadrature_values();
00207 const unsigned int patch_dim = (info.face_number == numbers::invalid_unsigned_int)
00208 ? dim : (dim-1);
00209 const unsigned int row_length = n_points;
00210
00211
00212
00213 const unsigned int row_length2 = (patch_dim==1) ? row_length : (row_length*row_length);
00214
00215
00216 AssertDimension(nv, n_vectors+dim);
00217
00218
00219 for (unsigned int k=0; k<np; ++k)
00220 {
00221 if (k % row_length == 0)
00222 write_endl();
00223 if (k % row_length2 == 0)
00224 write_endl();
00225
00226 for(unsigned int i=0; i<nv; ++i)
00227 {
00228 write(info.quadrature_value(k,i));
00229 write('\t');
00230 }
00231 write_endl();
00232 }
00233 }
00234
00235
00236 template <int dim>
00237 inline void
00238 GnuplotPatch::assemble(const DoFInfo<dim>& info1, const DoFInfo<dim>& info2)
00239 {
00240 assemble(info1);
00241 assemble(info2);
00242 }
00243 }
00244 }
00245
00246 DEAL_II_NAMESPACE_CLOSE
00247
00248 #endif
00249