Dune Core Modules (2.4.2)

amirameshwriter.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_AMIRAMESH_WRITER_HH
4#define DUNE_AMIRAMESH_WRITER_HH
5
6#include <string>
7
9
10#if HAVE_AMIRAMESH
11#include <amiramesh/AmiraMesh.h>
12#endif
13
14namespace Dune {
15
20 template<class GridView>
22
23 enum {dim = GridView::dimension};
24
25 public:
26
35 void addGrid(const GridView& gridView, bool splitAll=false);
36
46 template <class GridType2>
47 void addLevelGrid(const GridType2& grid, int level, bool splitAll=false);
48
57 template <class GridType2>
58 void addLeafGrid(const GridType2& grid, bool splitAll=false);
59
66 template <class DataContainer>
67 void addCellData(const DataContainer& data, const GridView& gridView, bool GridSplitUp=false);
68
75 template <class DataContainer>
76 void addVertexData(const DataContainer& data, const GridView& gridView, bool GridSplitUp=false);
77
82 void write(const std::string& filename, bool ascii=false) const;
83
86 template <class DataContainer>
87 void addUniformData(const GridView& gridView,
88 const array<unsigned int, dim>& n,
89 const DataContainer& data);
90
102 static void writeSurfaceGrid(const GridView& gridView,
103 const std::string& filename);
104
105 protected:
106
107#if HAVE_AMIRAMESH // better: use a pointer here and forward-declare AmiraMesh
108 AmiraMesh amiramesh_;
109#endif
110 };
111
116 template<class GridType>
118 : public AmiraMeshWriter<typename GridType::LevelGridView>
119 {
120
121 public:
122
125
127 LevelAmiraMeshWriter(const GridType& grid, int level) {
128 this->addGrid(grid.levelGridView(level));
129 }
130
137 static void writeGrid(const GridType& grid,
138 const std::string& filename,
139 int level) {
140 LevelAmiraMeshWriter amiramesh(grid, level);
141 amiramesh.write(filename);
142 }
143
152 template <class VectorType>
153 static void writeBlockVector(const GridType& grid,
154 const VectorType& f,
155 const std::string& filename,
156 int level,
157 bool GridSplitUp=false) {
158 LevelAmiraMeshWriter amiramesh;
159 if (f.size()==grid.size(level,GridType::dimension))
160 amiramesh.addVertexData(f, grid.levelGridView(level),GridSplitUp);
161 else
162 amiramesh.addCellData(f, grid.levelGridView(level),GridSplitUp);
163 amiramesh.write(filename);
164 }
165
166 };
167
172 template<class GridType>
174 : public AmiraMeshWriter<typename GridType::LeafGridView>
175 {
176
177 public:
178
181
183 LeafAmiraMeshWriter(const GridType& grid) {
184 this->addLeafGrid(grid);
185 }
186
192 static void writeGrid(const GridType& grid,
193 const std::string& filename) {
194 LeafAmiraMeshWriter amiramesh(grid);
195 amiramesh.write(filename);
196 }
197
204 template <class VectorType>
205 static void writeBlockVector(const GridType& grid,
206 const VectorType& f,
207 const std::string& filename,
208 bool GridSplitUp = false) {
209 LeafAmiraMeshWriter amiramesh;
210 if (f.size()==grid.size(GridType::dimension))
211 amiramesh.addVertexData(f, grid.leafGridView(),GridSplitUp);
212 else
213 amiramesh.addCellData(f, grid.leafGridView(),GridSplitUp);
214
215 amiramesh.write(filename);
216 }
217
218 };
219
220}
221
222// implementation
223#if HAVE_AMIRAMESH
224#include "amiramesh/amirameshwriter.cc"
225#endif
226
227#endif
Fallback implementation of the std::array class (a static array)
Provides file writing facilities in the AmiraMesh format.
Definition: amirameshwriter.hh:21
static void writeSurfaceGrid(const GridView &gridView, const std::string &filename)
Write a 2d grid in a 3d world.
Definition: amirameshwriter.cc:632
void addLeafGrid(const GridType2 &grid, bool splitAll=false)
Add leaf grid.
Definition: amirameshwriter.cc:318
void write(const std::string &filename, bool ascii=false) const
Write AmiraMesh object to disk.
Definition: amirameshwriter.cc:551
void addVertexData(const DataContainer &data, const GridView &gridView, bool GridSplitUp=false)
Add vertex data.
Definition: amirameshwriter.cc:449
void addGrid(const GridView &gridView, bool splitAll=false)
Add a grid view to the file.
Definition: amirameshwriter.cc:12
void addLevelGrid(const GridType2 &grid, int level, bool splitAll=false)
Add level grid.
Definition: amirameshwriter.cc:308
void addUniformData(const GridView &gridView, const array< unsigned int, dim > &n, const DataContainer &data)
Write data on a uniform grid into an AmiraMesh file.
Definition: amirameshwriter.cc:564
void addCellData(const DataContainer &data, const GridView &gridView, bool GridSplitUp=false)
Add cell data.
Definition: amirameshwriter.cc:326
Grid view abstract base class.
Definition: gridview.hh:59
Provides file writing facilities in the AmiraMesh format for leaf grids.
Definition: amirameshwriter.hh:175
static void writeBlockVector(const GridType &grid, const VectorType &f, const std::string &filename, bool GridSplitUp=false)
Writes an ISTL block vector in AmiraMesh format.
Definition: amirameshwriter.hh:205
LeafAmiraMeshWriter()
Default constructor.
Definition: amirameshwriter.hh:180
static void writeGrid(const GridType &grid, const std::string &filename)
Write a grid in AmiraMesh format.
Definition: amirameshwriter.hh:192
LeafAmiraMeshWriter(const GridType &grid)
Constructor which initializes the AmiraMesh object with a given leaf grid.
Definition: amirameshwriter.hh:183
Provides file writing facilities in the AmiraMesh format for level grids.
Definition: amirameshwriter.hh:119
static void writeBlockVector(const GridType &grid, const VectorType &f, const std::string &filename, int level, bool GridSplitUp=false)
Writes an ISTL block vector in AmiraMesh format.
Definition: amirameshwriter.hh:153
LevelAmiraMeshWriter(const GridType &grid, int level)
Constructor which initializes the AmiraMesh object with a given level grid.
Definition: amirameshwriter.hh:127
static void writeGrid(const GridType &grid, const std::string &filename, int level)
Write a grid in AmiraMesh format.
Definition: amirameshwriter.hh:137
LevelAmiraMeshWriter()
Default constructor.
Definition: amirameshwriter.hh:124
@ dimension
The dimension of the grid.
Definition: gridview.hh:130
Dune namespace.
Definition: alignment.hh:10
@ ascii
store data in a human readable form
Definition: grapedataioformattypes.hh:15
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)