Dune Core Modules (2.5.0)

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#include <array>
8
9#if HAVE_AMIRAMESH
10#include <amiramesh/AmiraMesh.h>
11#endif
12
13namespace Dune {
14
19 template<class GridView>
21
22 enum {dim = GridView::dimension};
23
24 public:
25
34 void addGrid(const GridView& gridView, bool splitAll=false);
35
45 template <class GridType2>
46 void addLevelGrid(const GridType2& grid, int level, bool splitAll=false);
47
56 template <class GridType2>
57 void addLeafGrid(const GridType2& grid, bool splitAll=false);
58
65 template <class DataContainer>
66 void addCellData(const DataContainer& data, const GridView& gridView, bool GridSplitUp=false);
67
74 template <class DataContainer>
75 void addVertexData(const DataContainer& data, const GridView& gridView, bool GridSplitUp=false);
76
81 void write(const std::string& filename, bool ascii=false) const;
82
85 template <class DataContainer>
86 void addUniformData(const GridView& gridView,
87 const std::array<unsigned int, dim>& n,
88 const DataContainer& data);
89
101 static void writeSurfaceGrid(const GridView& gridView,
102 const std::string& filename);
103
104 protected:
105
106#if HAVE_AMIRAMESH // better: use a pointer here and forward-declare AmiraMesh
107 AmiraMesh amiramesh_;
108#endif
109 };
110
115 template<class GridType>
117 : public AmiraMeshWriter<typename GridType::LevelGridView>
118 {
119
120 public:
121
124
126 LevelAmiraMeshWriter(const GridType& grid, int level) {
127 this->addGrid(grid.levelGridView(level));
128 }
129
136 static void writeGrid(const GridType& grid,
137 const std::string& filename,
138 int level) {
139 LevelAmiraMeshWriter amiramesh(grid, level);
140 amiramesh.write(filename);
141 }
142
151 template <class VectorType>
152 static void writeBlockVector(const GridType& grid,
153 const VectorType& f,
154 const std::string& filename,
155 int level,
156 bool GridSplitUp=false) {
157 LevelAmiraMeshWriter amiramesh;
158 if (f.size()==grid.size(level,GridType::dimension))
159 amiramesh.addVertexData(f, grid.levelGridView(level),GridSplitUp);
160 else
161 amiramesh.addCellData(f, grid.levelGridView(level),GridSplitUp);
162 amiramesh.write(filename);
163 }
164
165 };
166
171 template<class GridType>
173 : public AmiraMeshWriter<typename GridType::LeafGridView>
174 {
175
176 public:
177
180
182 LeafAmiraMeshWriter(const GridType& grid) {
183 this->addLeafGrid(grid);
184 }
185
191 static void writeGrid(const GridType& grid,
192 const std::string& filename) {
193 LeafAmiraMeshWriter amiramesh(grid);
194 amiramesh.write(filename);
195 }
196
203 template <class VectorType>
204 static void writeBlockVector(const GridType& grid,
205 const VectorType& f,
206 const std::string& filename,
207 bool GridSplitUp = false) {
208 LeafAmiraMeshWriter amiramesh;
209 if (f.size()==grid.size(GridType::dimension))
210 amiramesh.addVertexData(f, grid.leafGridView(),GridSplitUp);
211 else
212 amiramesh.addCellData(f, grid.leafGridView(),GridSplitUp);
213
214 amiramesh.write(filename);
215 }
216
217 };
218
219}
220
221// implementation
222#if HAVE_AMIRAMESH
223#include "amiramesh/amirameshwriter.cc"
224#endif
225
226#endif
Provides file writing facilities in the AmiraMesh format.
Definition: amirameshwriter.hh:20
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 std::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:60
Provides file writing facilities in the AmiraMesh format for leaf grids.
Definition: amirameshwriter.hh:174
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:204
LeafAmiraMeshWriter()
Default constructor.
Definition: amirameshwriter.hh:179
static void writeGrid(const GridType &grid, const std::string &filename)
Write a grid in AmiraMesh format.
Definition: amirameshwriter.hh:191
LeafAmiraMeshWriter(const GridType &grid)
Constructor which initializes the AmiraMesh object with a given leaf grid.
Definition: amirameshwriter.hh:182
Provides file writing facilities in the AmiraMesh format for level grids.
Definition: amirameshwriter.hh:118
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:152
LevelAmiraMeshWriter(const GridType &grid, int level)
Constructor which initializes the AmiraMesh object with a given level grid.
Definition: amirameshwriter.hh:126
static void writeGrid(const GridType &grid, const std::string &filename, int level)
Write a grid in AmiraMesh format.
Definition: amirameshwriter.hh:136
LevelAmiraMeshWriter()
Default constructor.
Definition: amirameshwriter.hh:123
@ dimension
The dimension of the grid.
Definition: gridview.hh:128
Dune namespace.
Definition: alignment.hh:11
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 23, 23:29, 2024)