VTUGridReader.hpp
1 /*---------------------------------------------------------------------------*\
2  *
3  * mimmo
4  *
5  * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6  *
7  * -------------------------------------------------------------------------
8  * License
9  * This file is part of mimmo.
10  *
11  * mimmo is free software: you can redistribute it and/or modify it
12  * under the terms of the GNU Lesser General Public License v3 (LGPL)
13  * as published by the Free Software Foundation.
14  *
15  * mimmo is distributed in the hope that it will be useful, but WITHOUT
16  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18  * License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with mimmo. If not, see <http://www.gnu.org/licenses/>.
22  *
23 \*---------------------------------------------------------------------------*/
24 #ifndef __VTUGRIDREADER_HPP__
25 #define __VTUGRIDREADER_HPP__
26 
27 #include "mimmoTypeDef.hpp"
28 #include <bitpit_patchkernel.hpp>
29 
30 namespace mimmo{
31 
43 class VTUAbsorbStreamer : public bitpit::VTKBaseStreamer{
44 public:
46  virtual ~VTUAbsorbStreamer();
48  VTUAbsorbStreamer(const VTUAbsorbStreamer&) = default;
49 
50  virtual void absorbData(std::fstream &stream, const std::string & name, bitpit::VTKFormat format, uint64_t entries, uint8_t components, bitpit::VTKDataType datatype);
52  virtual void decodeRawData(bitpit::PatchKernel &) = 0;
53 };
54 
64 
65 protected:
72  std::vector<bitpit::ElementType> types;
75 #if MIMMO_ENABLE_MPI
76  livector1D cellsRank;
77  livector1D verticesRank;
78  livector1D cellsGlobalIndex;
79 #endif
80 
81 public:
83  virtual ~VTUGridStreamer();
85  VTUGridStreamer(const VTUGridStreamer&) = default;
86 
87  virtual void absorbData(std::fstream &stream, const std::string &name, bitpit::VTKFormat format, uint64_t entries, uint8_t components, bitpit::VTKDataType datatype);
88  void decodeRawData(bitpit::PatchKernel & patch);
89  void readIntegerPod(std::fstream & stream, bitpit::VTKFormat& format, bitpit::VTKDataType& datatype, long &target);
90  void readDoublePod(std::fstream & stream, bitpit::VTKFormat& format, bitpit::VTKDataType& datatype, double&target);
91 };
92 
102 class VTUGridReader: protected bitpit::VTKUnstructuredGrid
103 {
104 
105 public:
106  VTUGridReader( std::string dir, std::string name, VTUAbsorbStreamer & streamer,
107  bitpit::PatchKernel & patch, bool masterRankOnly = true, bitpit::VTKElementType eltype= bitpit::VTKElementType::UNDEFINED);
108  ~VTUGridReader();
109 
110  void read();
111 
112 private:
113  bitpit::PatchKernel& m_patch;
114  VTUAbsorbStreamer & m_streamer;
115 #if MIMMO_ENABLE_MPI
116  bool m_masterRankOnly;
117 #endif
118 };
119 
120 
121 };
122 
123 #endif /* __VTUGRIDREADER_HPP__ */
std::vector< darray3E > dvecarr3E
virtual void decodeRawData(bitpit::PatchKernel &)=0
Custom reader of unstructured grids from external files *.vtu.
std::vector< long > livector1D
Abstract class for custom reader/absorber of *.vtu mesh external files.
void readDoublePod(std::fstream &stream, bitpit::VTKFormat &format, bitpit::VTKDataType &datatype, double &target)
std::vector< bitpit::ElementType > types
virtual void absorbData(std::fstream &stream, const std::string &name, bitpit::VTKFormat format, uint64_t entries, uint8_t components, bitpit::VTKDataType datatype)
VTUGridReader(std::string dir, std::string name, VTUAbsorbStreamer &streamer, bitpit::PatchKernel &patch, bool masterRankOnly=true, bitpit::VTKElementType eltype=bitpit::VTKElementType::UNDEFINED)
virtual void absorbData(std::fstream &stream, const std::string &name, bitpit::VTKFormat format, uint64_t entries, uint8_t components, bitpit::VTKDataType datatype)
void readIntegerPod(std::fstream &stream, bitpit::VTKFormat &format, bitpit::VTKDataType &datatype, long &target)
void decodeRawData(bitpit::PatchKernel &patch)
Custom mesh/data absorber for unstructured grids given by external files *.vtu.