dune-grid
2.1.1
|
00001 // -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- 00002 // vi: set et ts=8 sw=2 sts=2: 00003 00004 #ifndef DUNE_GRID_IO_FILE_VTK_VOLUMEWRITER_HH 00005 #define DUNE_GRID_IO_FILE_VTK_VOLUMEWRITER_HH 00006 00007 #include <dune/common/shared_ptr.hh> 00008 00009 #include <dune/grid/io/file/vtk/basicwriter.hh> 00010 #include <dune/grid/io/file/vtk/function.hh> 00011 #include <dune/grid/io/file/vtk/functionwriter.hh> 00012 #include <dune/grid/io/file/vtk/volumeiterators.hh> 00013 00014 namespace Dune { 00017 00018 namespace VTK { 00019 00020 template<typename GV> 00021 class ConformingVolumeWriter 00022 : public ConformingVolumeIteratorFactory<GV>, 00023 public BasicWriter<ConformingVolumeIteratorFactory<GV> > 00024 { 00025 typedef ConformingVolumeIteratorFactory<GV> Factory; 00026 typedef BasicWriter<Factory> Base; 00027 00028 const GV& gv; 00029 00030 public: 00031 typedef Dune::VTKFunction<typename GV::Grid> VTKFunction; 00032 typedef shared_ptr<VTKFunction> VTKFunctionPtr; 00033 00034 ConformingVolumeWriter(const GV& gv_) 00035 : Factory(gv_), Base(static_cast<const Factory&>(*this)), gv(gv_) 00036 { } 00037 00038 using Base::addCellData; 00039 using Base::addPointData; 00040 00041 void addCellData(const VTKFunctionPtr& p) { 00042 addCellData(shared_ptr<typename Base::FunctionWriter> 00043 (new VTKFunctionWriter<VTKFunction>(p))); 00044 } 00045 00046 void addCellData(VTKFunction* p) { 00047 addCellData(VTKFunctionPtr(p)); 00048 } 00049 00050 template<typename V> 00051 void addCellData(const V &v, const std::string &name, int ncomps=1) { 00052 addCellData(new P0VTKFunction<GV, V>(gv, v, name, ncomps)); 00053 } 00054 00055 void addVertexData(const VTKFunctionPtr& p) { 00056 addPointData(shared_ptr<typename Base::FunctionWriter> 00057 (new VTKFunctionWriter<VTKFunction>(p))); 00058 } 00059 00060 void addVertexData(VTKFunction* p) { 00061 addVertexData(VTKFunctionPtr(p)); 00062 } 00063 00064 template<typename V> 00065 void addVertexData(const V &v, const std::string &name, int ncomps=1) { 00066 addVertexData(new P1VTKFunction<GV, V>(gv, v, name, ncomps)); 00067 } 00068 00069 }; 00070 00071 } // namespace VTK 00072 00074 00075 } // namespace Dune 00076 00077 #endif // DUNE_GRID_IO_FILE_VTK_VOLUMEWRITER_HH