dune-grid  2.3beta2
volumewriter.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 
4 #ifndef DUNE_GRID_IO_FILE_VTK_VOLUMEWRITER_HH
5 #define DUNE_GRID_IO_FILE_VTK_VOLUMEWRITER_HH
6 
7 #include <dune/common/shared_ptr.hh>
8 
13 
14 namespace Dune {
17 
18  namespace VTK {
19 
20  template<typename GV>
23  public BasicWriter<ConformingVolumeIteratorFactory<GV> >
24  {
26  typedef BasicWriter<Factory> Base;
27 
28  const GV& gv;
29 
30  public:
32  typedef shared_ptr<VTKFunction> VTKFunctionPtr;
33 
34  ConformingVolumeWriter(const GV& gv_)
35  : Factory(gv_), Base(static_cast<const Factory&>(*this)), gv(gv_)
36  { }
37 
38  using Base::addCellData;
39  using Base::addPointData;
40 
41  void addCellData(const VTKFunctionPtr& p) {
42  addCellData(shared_ptr<typename Base::FunctionWriter>
44  }
45 
48  }
49 
50  template<typename V>
51  void addCellData(const V &v, const std::string &name, int ncomps=1) {
52  addCellData(new P0VTKFunction<GV, V>(gv, v, name, ncomps));
53  }
54 
55  void addVertexData(const VTKFunctionPtr& p) {
56  addPointData(shared_ptr<typename Base::FunctionWriter>
58  }
59 
62  }
63 
64  template<typename V>
65  void addVertexData(const V &v, const std::string &name, int ncomps=1) {
66  addVertexData(new P1VTKFunction<GV, V>(gv, v, name, ncomps));
67  }
68 
69  };
70 
71  } // namespace VTK
72 
74 
75 } // namespace Dune
76 
77 #endif // DUNE_GRID_IO_FILE_VTK_VOLUMEWRITER_HH