OpenLB 1.8.1
Loading...
Searching...
No Matches
vtiReader.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2015 Mathias J. Krause, Benjamin Förster
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
54#ifndef VTI_READER_H
55#define VTI_READER_H
56
57#include <string>
58#include <vector>
59
60#include "io/xmlReader.h"
61#include "geometry/cuboid.h"
63#include "core/superData.h"
64#include "core/blockData.h"
65#include "io/ostreamManager.h"
67
68//typedef double T;
69namespace olb {
70
71template<typename T> class LoadBalancer;
72template<typename T, typename BaseType> class SuperData3D;
73template<typename T, typename BaseType> class BlockData3D;
74
75template<typename T> class CuboidGeometry2D;
76// template<typename T> class Cuboid2D;
77template<typename T, typename BaseType> class SuperData2D;
78template<typename T, typename BaseType> class BlockData2D;
79
84
85template<typename T>
87public:
88 BaseVTIreader(const std::string& fName, int dim, std::string dName,
89 const std::string class_name="BaseVTIreader", const DataType type = PointData);
90 virtual ~BaseVTIreader() {};
91 void printInfo();
92protected:
94 /* Dimension (2D or 3D) */
95 int _dim;
96 /* #Data array components */
97 int _comps;
98 /* Origin */
99 std::vector<T> _origin;
100 /* #Nodes */
101 std::vector<int> _extent;
104 // Number of Cuboids
107
109 std::vector<int> readExtent(const XMLreader* reader, std::string extAttrName);
111 std::vector<int> getNbNodes(std::vector<int>& extents);
114 int getNbComps(const XMLreader& tagReader);
117 size_t computeTotalDataValues();
118};
119
120
121template<typename T, typename BaseType>
123public:
124 BaseVTIreader3D(const std::string& fileName, std::string dataName,
125 const std::string class_name="BaseVTIreader3D", const DataType type = PointData);
126 ~BaseVTIreader3D() override {};
127protected:
129 void readCuboid(Cuboid3D<T>& cuboid, XMLreader* pieceReader);
131 bool readBlockData(BlockData<3,T,BaseType>& blockData, const XMLreader& pieceTagReader,
132 const std::string dataName);
133private:
135 void readAsciiData(std::stringstream& stream_val, BlockData<3,T,BaseType>& blockData);
137 void readBinaryData(std::stringstream& stream_val, BlockData<3,T,BaseType>& blockData, size_t str_length);
138};
139
140
141
142template<typename T, typename BaseType>
143class BlockVTIreader3D : public BaseVTIreader3D<T,BaseType> {
144public:
145 BlockVTIreader3D(const std::string& fileName, const std::string& dataName, const DataType type = PointData);
146 ~BlockVTIreader3D() override {};
149protected:
152};
153
154
155template<typename T, typename BaseType>
156class SuperVTIreader3D : public BaseVTIreader3D<T,BaseType> {
157private:
158 CuboidDecomposition3D<T>* _cGeometry;
159 LoadBalancer<T>* _loadBalancer;
160 SuperData<3,T,BaseType>* _superData;
161public:
162 SuperVTIreader3D(const std::string& fName, const std::string dName);
163 ~SuperVTIreader3D() override;
167private:
169 void readCuboidDecomposition();
171 void readSuperData(const std::string dName);
172};
173
174
175
176
177
178
179
180
181
182
184/*
185template<typename T>
186class VTIreader2D : public XMLreader {
187public:
188 VTIreader2D();
189 VTIreader2D(const std::string& fName);
190 ~VTIreader2D();
191
192 void getCuboid(Cuboid2D<T>& cuboid);
193 void getCuboids(std::vector<Cuboid2D<T>* >& cuboids);
194 //bool getScalarData(ScalarField2D<T>* base, const std::string dName);
195 //bool getVectorData(TensorField2D<T, 2>* base, const std::string dName);
196 //void getScalarMultiPieceData(std::vector<const ScalarFieldBase2D<T>* >& bases, const std::string dName);
197 //void getVectorMultiPieceData(std::vector<const TensorFieldBase2D<T, 2>* >& bases, const std::string dName);
198 void printInfo();
199private:
200 int _x0, _y0, _z0;
201 int _x, _y, _z;
202 T _delta;
203};
204*/
205
206/* ------------------ BaseVTIreader2D -----------------*/
207
208template<typename T, typename BaseType>
210public:
211 BaseVTIreader2D(const std::string& fileName, std::string dataName,
212 const std::string class_name="BaseVTIreader2D", const DataType type = PointData);
213 ~BaseVTIreader2D() override {};
214protected:
216 void readCuboid(Cuboid2D<T>& cuboid, XMLreader* pieceReader);
218 bool readBlockData(BlockData<2,T,BaseType>& blockData, const XMLreader& pieceTagReader,
219 const std::string dataName);
220private:
222 void readAsciiData(std::stringstream& stream_val, BlockData<2,T,BaseType>& blockData);
224 void readBinaryData(std::stringstream& stream_val, BlockData<2,T,BaseType>& blockData, size_t str_length);
225};
226
227/* ---------------- BlockVTIreader2D -------------------*/
228
229template<typename T, typename BaseType>
230class BlockVTIreader2D : public BaseVTIreader2D<T,BaseType> {
231public:
232 BlockVTIreader2D(const std::string& fileName, const std::string& dataName, const DataType type = PointData);
233 ~BlockVTIreader2D() override {};
236protected:
239};
240
241} // namespace olb
242
243#endif
BaseVTIreader2D(const std::string &fileName, std::string dataName, const std::string class_name="BaseVTIreader2D", const DataType type=PointData)
Definition vtiReader.hh:439
~BaseVTIreader2D() override
Definition vtiReader.h:213
bool readBlockData(BlockData< 2, T, BaseType > &blockData, const XMLreader &pieceTagReader, const std::string dataName)
Reads from DataArray and fills blockData.
Definition vtiReader.hh:535
void readCuboid(Cuboid2D< T > &cuboid, XMLreader *pieceReader)
Reads cuboid from piece node.
Definition vtiReader.hh:446
void readCuboid(Cuboid3D< T > &cuboid, XMLreader *pieceReader)
Reads cuboid from piece node.
Definition vtiReader.hh:178
~BaseVTIreader3D() override
Definition vtiReader.h:126
bool readBlockData(BlockData< 3, T, BaseType > &blockData, const XMLreader &pieceTagReader, const std::string dataName)
Reads from DataArray and fills blockData.
Definition vtiReader.hh:270
BaseVTIreader3D(const std::string &fileName, std::string dataName, const std::string class_name="BaseVTIreader3D", const DataType type=PointData)
Definition vtiReader.hh:171
std::vector< int > getNbNodes(std::vector< int > &extents)
Converts 4D (or 6D) extents vector into 2D (3D) nb_nodes vector.
Definition vtiReader.hh:133
std::vector< T > _origin
Definition vtiReader.h:99
BaseVTIreader(const std::string &fName, int dim, std::string dName, const std::string class_name="BaseVTIreader", const DataType type=PointData)
Definition vtiReader.hh:45
OstreamManager clout
Definition vtiReader.h:93
size_t computeTotalDataValues()
Computes the total amount of data values Number of components * number of cells/point.
Definition vtiReader.hh:159
virtual ~BaseVTIreader()
Definition vtiReader.h:90
std::vector< int > readExtent(const XMLreader *reader, std::string extAttrName)
Reads Extent from extAttrName from XML Tag and returns as vector.
Definition vtiReader.hh:118
int getNbComps(const XMLreader &tagReader)
Reads size from XML tag (attribute "NumberOfComponents") Reads the number of components from the XML ...
Definition vtiReader.hh:145
std::vector< int > _extent
Definition vtiReader.h:101
XMLreader _xmlReader
Definition vtiReader.h:103
BlockData< 2, T, BaseType > _blockData
Definition vtiReader.h:238
Cuboid2D< T > & getCuboid()
Definition vtiReader.hh:598
BlockData< 2, T, BaseType > & getBlockData()
Definition vtiReader.hh:592
Cuboid2D< T > _cuboid
Definition vtiReader.h:237
~BlockVTIreader2D() override
Definition vtiReader.h:233
BlockVTIreader2D(const std::string &fileName, const std::string &dataName, const DataType type=PointData)
Definition vtiReader.hh:569
Cuboid3D< T > & getCuboid()
Definition vtiReader.hh:336
BlockData< 3, T, BaseType > _blockData
Definition vtiReader.h:151
~BlockVTIreader3D() override
Definition vtiReader.h:146
BlockVTIreader3D(const std::string &fileName, const std::string &dataName, const DataType type=PointData)
Definition vtiReader.hh:306
BlockData< 3, T, BaseType > & getBlockData()
Definition vtiReader.hh:330
Cuboid3D< T > _cuboid
Definition vtiReader.h:150
Base class for all LoadBalancer.
Definition vtiWriter.h:42
class for marking output with some text
~SuperVTIreader3D() override
Definition vtiReader.hh:345
CuboidDecomposition3D< T > & getCuboidDecomposition()
Definition vtiReader.hh:424
LoadBalancer< T > & getLoadBalancer()
Definition vtiReader.hh:430
SuperData< 3, T, BaseType > & getSuperData()
Definition vtiReader.hh:418
SuperVTIreader3D(const std::string &fName, const std::string dName)
Definition vtiReader.hh:353
Top level namespace for all of OpenLB.
DataType
Definition vtiReader.h:80
@ PointData
Definition vtiReader.h:81
@ CellData
Definition vtiReader.h:82
Dynamics for a generic 2D super data – header file.
Input/Output in XML format – header file.