DUNE PDELab (git)

volumewriter.hh
1// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4// vi: set et ts=4 sw=2 sts=2:
5
6#ifndef DUNE_GRID_IO_FILE_VTK_VOLUMEWRITER_HH
7#define DUNE_GRID_IO_FILE_VTK_VOLUMEWRITER_HH
8
9#include <memory>
10
11#include <dune/grid/io/file/vtk/basicwriter.hh>
13#include <dune/grid/io/file/vtk/functionwriter.hh>
14#include <dune/grid/io/file/vtk/volumeiterators.hh>
15
16namespace Dune {
19
20 namespace VTK {
21
22 template<typename GV>
23 class ConformingVolumeWriter
24 : public ConformingVolumeIteratorFactory<GV>,
25 public BasicWriter<ConformingVolumeIteratorFactory<GV> >
26 {
27 typedef ConformingVolumeIteratorFactory<GV> Factory;
28 typedef BasicWriter<Factory> Base;
29
30 const GV& gv;
31
32 public:
33 typedef Dune::VTKFunction< GV > VTKFunction;
34 typedef std::shared_ptr<VTKFunction> VTKFunctionPtr;
35
36 ConformingVolumeWriter(const GV& gv_)
37 : Factory(gv_), Base(static_cast<const Factory&>(*this)), gv(gv_)
38 { }
39
40 using Base::addPointData;
41
42 void addCellData(const VTKFunctionPtr& p) {
43 Base::addCellData(std::shared_ptr<typename Base::FunctionWriter>
44 (new VTKFunctionWriter<VTKFunction>(p)));
45 }
46
47 void addCellData(VTKFunction* p) {
48 addCellData(VTKFunctionPtr(p));
49 }
50
51 template<typename V>
52 void addCellData(const V &v, const std::string &name, int ncomps=1) {
53 addCellData(new P0VTKFunction<GV, V>(gv, v, name, ncomps));
54 }
55
56 void addVertexData(const VTKFunctionPtr& p) {
57 addPointData(std::shared_ptr<typename Base::FunctionWriter>
58 (new VTKFunctionWriter<VTKFunction>(p)));
59 }
60
61 void addVertexData(VTKFunction* p) {
62 addVertexData(VTKFunctionPtr(p));
63 }
64
65 template<typename V>
66 void addVertexData(const V &v, const std::string &name, int ncomps=1) {
67 addVertexData(new P1VTKFunction<GV, V>(gv, v, name, ncomps));
68 }
69
70 };
71
72 } // namespace VTK
73
75
76} // namespace Dune
77
78#endif // DUNE_GRID_IO_FILE_VTK_VOLUMEWRITER_HH
Functions for VTK output.
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 13, 23:29, 2024)