From 94d3e79a8617f88dc0219cfdeedfa3147833719d Mon Sep 17 00:00:00 2001
From: Adrian Kummerlaender
Date: Mon, 24 Jun 2019 14:43:36 +0200
Subject: Initialize at openlb-1-3
---
src/io/vtiReader.h | 189 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 189 insertions(+)
create mode 100644 src/io/vtiReader.h
(limited to 'src/io/vtiReader.h')
diff --git a/src/io/vtiReader.h b/src/io/vtiReader.h
new file mode 100644
index 0000000..d5dfc28
--- /dev/null
+++ b/src/io/vtiReader.h
@@ -0,0 +1,189 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2015 Mathias J. Krause, Benjamin Förster
+ * E-mail contact: info@openlb.net
+ * The most recent release of OpenLB can be downloaded at
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+*/
+
+/** \file
+ * The VTI reader is able to read from VTI files and create and fill
+ * corresponding data structures. The reading process starts with
+ * the construction of the reader object. The name of the data type
+ * to be read (e.g. "physVelocity") is mandatory.
+ *
+ *
+ * Single cuboids (BlockVTIreader) and cuboid geometries
+ * (SuperVTIreader) are supported in 2D and 3D.
+ *
+ * The Base reader class is reading the generic information of the
+ * VTI file like origin, extend and number of nodes of the surrounding
+ * cuboid as well as the size (dimension) of the data vector to be read.
+ *
+ * In case of cuboid geometries, the reader follows these steps:
+ *
+ * 1. Create a CuboidGeometry and add all Cuboids.
+ *
+ * 2. Create a (Heuristic) LoadBalancer out of the CuboidGeometry.
+ *
+ * 3. Create a SuperData object out of the CuboidGeometry and
+ * LoadBalancer and by that also allocate all the neccessary memory
+ * for the actual data.
+ *
+ * 4. Iterate through the VTI data and fill the BlockData objects of SuperData.
+ *
+ *
+ */
+
+
+#ifndef VTI_READER_H
+#define VTI_READER_H
+
+#include
+#include
+
+#include "io/xmlReader.h"
+#include "geometry/cuboid3D.h"
+#include "geometry/cuboidGeometry3D.h"
+#include "core/superData3D.h"
+#include "core/blockData3D.h"
+#include "io/ostreamManager.h"
+#include "communication/loadBalancer.h"
+
+//typedef double T;
+namespace olb {
+
+template< typename T> class CuboidGeometry3D;
+//template< typename T> class Cuboid2D;
+template< typename T> class Cuboid3D;
+template< typename T> class LoadBalancer;
+template< typename T, typename BaseType> class SuperData3D;
+template< typename T, typename BaseType> class BlockData3D;
+
+template
+class BaseVTIreader {
+public:
+ BaseVTIreader(const std::string& fName, int dim, std::string dName,
+ const std::string class_name="BaseVTIreader");
+ virtual ~BaseVTIreader() {};
+ void printInfo();
+protected:
+ mutable OstreamManager clout;
+ /* Dimension (2D or 3D) */
+ int _dim;
+ /// Size of Data Field
+ int _size;
+ /* Origin */
+ std::vector _origin;
+ /* #Nodes */
+ std::vector _extent;
+ T _delta;
+ XMLreader _xmlReader;
+ // Number of Cuboids
+ int _nCuboids;
+ /// Reads Extent from extAttrName from XML Tag and returns as vector
+ std::vector readExtent(const XMLreader* reader, std::string extAttrName);
+ /// Converts 4D (or 6D) extents vector into 2D (3D) nb_nodes vector
+ std::vector getNbNodes(std::vector& extents);
+ /// Reads size from XML tag (attribute "NumberOfComponents")
+ int getSize(const XMLreader& tag);
+};
+
+
+template
+class BaseVTIreader3D : public BaseVTIreader {
+public:
+ BaseVTIreader3D(const std::string& fName, std::string dName,
+ const std::string class_name="BaseVTIreader3D");
+ ~BaseVTIreader3D() override {};
+protected:
+ /// Reads cuboid from piece node
+ void readCuboid(Cuboid3D& cuboid, XMLreader* piece);
+ /// Reads from pointDataTag and fills blockData
+ bool readBlockData(BlockData3D& blockData, const XMLreader& pointDataTag,
+ const std::string dName);
+};
+
+
+
+template
+class BlockVTIreader3D : public BaseVTIreader3D {
+public:
+ BlockVTIreader3D(const std::string& fName, const std::string dName);
+ ~BlockVTIreader3D() override {};
+ BlockData3D& getBlockData();
+ Cuboid3D& getCuboid();
+protected:
+ Cuboid3D _cuboid;
+ BlockData3D _blockData;
+};
+
+
+template
+class SuperVTIreader3D : public BaseVTIreader3D {
+private:
+ CuboidGeometry3D* _cGeometry;
+ LoadBalancer* _loadBalancer;
+ SuperData3D* _superData;
+public:
+ SuperVTIreader3D(const std::string& fName, const std::string dName);
+ ~SuperVTIreader3D() override;
+ SuperData3D& getSuperData();
+ CuboidGeometry3D& getCuboidGeometry();
+ LoadBalancer& getLoadBalancer();
+private:
+ /// Reads Cuboid Geometry and creates Cuboid objects
+ void readCuboidGeometry();
+ /// Fills all BlockData objects of SuperData
+ void readSuperData(const std::string dName);
+};
+
+
+
+
+
+
+
+
+
+
+/// \todo implement 2D version above
+/*
+template
+class VTIreader2D : public XMLreader {
+public:
+ VTIreader2D();
+ VTIreader2D(const std::string& fName);
+ ~VTIreader2D();
+
+ void getCuboid(Cuboid2D& cuboid);
+ void getCuboids(std::vector* >& cuboids);
+ //bool getScalarData(ScalarField2D* base, const std::string dName);
+ //bool getVectorData(TensorField2D* base, const std::string dName);
+ //void getScalarMultiPieceData(std::vector* >& bases, const std::string dName);
+ //void getVectorMultiPieceData(std::vector* >& bases, const std::string dName);
+ void printInfo();
+private:
+ int _x0, _y0, _z0;
+ int _x, _y, _z;
+ T _delta;
+};
+*/
+} // namespace olb
+
+#endif
--
cgit v1.2.3