DUNE PDELab (2.8)

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#warning Support for AmiraMesh is deprecated and will be removed after Dune 2.8.
7
8#include <string>
9#include <array>
10
11#if HAVE_AMIRAMESH
12#include <amiramesh/AmiraMesh.h>
13#endif
14
15namespace Dune {
16
21 template<class GridView>
23
24 enum {dim = GridView::dimension};
25
26 public:
27
36 void addGrid(const GridView& gridView, bool splitAll=false);
37
47 template <class GridType2>
48 void addLevelGrid(const GridType2& grid, int level, bool splitAll=false);
49
58 template <class GridType2>
59 void addLeafGrid(const GridType2& grid, bool splitAll=false);
60
67 template <class DataContainer>
68 void addCellData(const DataContainer& data, const GridView& gridView, bool GridSplitUp=false);
69
76 template <class DataContainer>
77 void addVertexData(const DataContainer& data, const GridView& gridView, bool GridSplitUp=false);
78
83 void write(const std::string& filename, bool ascii=false) const;
84
87 template <class DataContainer>
88 void addUniformData(const GridView& gridView,
89 const std::array<unsigned int, dim>& n,
90 const DataContainer& data);
91
103 static void writeSurfaceGrid(const GridView& gridView,
104 const std::string& filename);
105
106 protected:
107
108#if HAVE_AMIRAMESH // better: use a pointer here and forward-declare AmiraMesh
109 AmiraMesh amiramesh_;
110#endif
111 };
112
117 template<class GridType>
119 : public AmiraMeshWriter<typename GridType::LevelGridView>
120 {
121
122 public:
123
126
128 LevelAmiraMeshWriter(const GridType& grid, int level) {
129 this->addGrid(grid.levelGridView(level));
130 }
131
138 static void writeGrid(const GridType& grid,
139 const std::string& filename,
140 int level) {
141 LevelAmiraMeshWriter amiramesh(grid, level);
142 amiramesh.write(filename);
143 }
144
153 template <class VectorType>
154 static void writeBlockVector(const GridType& grid,
155 const VectorType& f,
156 const std::string& filename,
157 int level,
158 bool GridSplitUp=false) {
159 LevelAmiraMeshWriter amiramesh;
160 if (f.size()==grid.size(level,GridType::dimension))
161 amiramesh.addVertexData(f, grid.levelGridView(level),GridSplitUp);
162 else
163 amiramesh.addCellData(f, grid.levelGridView(level),GridSplitUp);
164 amiramesh.write(filename);
165 }
166
167 };
168
173 template<class GridType>
175 : public AmiraMeshWriter<typename GridType::LeafGridView>
176 {
177
178 public:
179
182
184 LeafAmiraMeshWriter(const GridType& grid) {
185 this->addLeafGrid(grid);
186 }
187
193 static void writeGrid(const GridType& grid,
194 const std::string& filename) {
195 LeafAmiraMeshWriter amiramesh(grid);
196 amiramesh.write(filename);
197 }
198
205 template <class VectorType>
206 static void writeBlockVector(const GridType& grid,
207 const VectorType& f,
208 const std::string& filename,
209 bool GridSplitUp = false) {
210 LeafAmiraMeshWriter amiramesh;
211 if ((int) f.size() == grid.size(GridType::dimension))
212 amiramesh.addVertexData(f, grid.leafGridView(),GridSplitUp);
213 else
214 amiramesh.addCellData(f, grid.leafGridView(),GridSplitUp);
215
216 amiramesh.write(filename);
217 }
218
219 };
220
221}
222
223// implementation
224#if HAVE_AMIRAMESH
225#include "amiramesh/amirameshwriter.cc"
226#endif
227
228#endif
Provides file writing facilities in the AmiraMesh format.
Definition: amirameshwriter.hh:22
static void writeSurfaceGrid(const GridView &gridView, const std::string &filename)
Write a 2d grid in a 3d world.
Definition: amirameshwriter.cc:633
void addLeafGrid(const GridType2 &grid, bool splitAll=false)
Add leaf grid.
Definition: amirameshwriter.cc:319
void write(const std::string &filename, bool ascii=false) const
Write AmiraMesh object to disk.
Definition: amirameshwriter.cc:552
void addVertexData(const DataContainer &data, const GridView &gridView, bool GridSplitUp=false)
Add vertex data.
Definition: amirameshwriter.cc:450
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:309
void addUniformData(const GridView &gridView, const std::array< unsigned int, dim > &n, const DataContainer &data)
Write data on a uniform grid into an AmiraMesh file.
Definition: amirameshwriter.cc:565
void addCellData(const DataContainer &data, const GridView &gridView, bool GridSplitUp=false)
Add cell data.
Definition: amirameshwriter.cc:327
Grid view abstract base class.
Definition: gridview.hh:63
Provides file writing facilities in the AmiraMesh format for leaf grids.
Definition: amirameshwriter.hh:176
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:206
LeafAmiraMeshWriter()
Default constructor.
Definition: amirameshwriter.hh:181
static void writeGrid(const GridType &grid, const std::string &filename)
Write a grid in AmiraMesh format.
Definition: amirameshwriter.hh:193
LeafAmiraMeshWriter(const GridType &grid)
Constructor which initializes the AmiraMesh object with a given leaf grid.
Definition: amirameshwriter.hh:184
Provides file writing facilities in the AmiraMesh format for level grids.
Definition: amirameshwriter.hh:120
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:154
LevelAmiraMeshWriter(const GridType &grid, int level)
Constructor which initializes the AmiraMesh object with a given level grid.
Definition: amirameshwriter.hh:128
static void writeGrid(const GridType &grid, const std::string &filename, int level)
Write a grid in AmiraMesh format.
Definition: amirameshwriter.hh:138
LevelAmiraMeshWriter()
Default constructor.
Definition: amirameshwriter.hh:125
@ dimension
The dimension of the grid.
Definition: gridview.hh:130
Dune namespace.
Definition: alignedallocator.hh:11
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 24, 22:29, 2024)