MDAL
mdal_flo2d.hpp
1 /*
2  MDAL - Mesh Data Abstraction Library (MIT License)
3  Copyright (C) 2018 Peter Petrik (zilolv at gmail dot com)
4 */
5 
6 #ifndef MDAL_FLO2D_HPP
7 #define MDAL_FLO2D_HPP
8 
9 #include <string>
10 
11 #include "mdal_data_model.hpp"
12 #include "mdal_memory_data_model.hpp"
13 #include "mdal.h"
14 #include "mdal_driver.hpp"
15 
16 class HdfGroup;
17 class HdfFile;
18 
19 namespace MDAL
20 {
48  class DriverFlo2D: public Driver
49  {
50  public:
51  DriverFlo2D();
52  ~DriverFlo2D( ) override = default;
53  DriverFlo2D *create() override;
54 
55  bool canReadMesh( const std::string &uri ) override;
56  bool canReadDatasets( const std::string &uri ) override;
57  std::string buildUri( const std::string &meshFile ) override;
58 
59  std::unique_ptr< Mesh > load( const std::string &resultsFile, const std::string &meshName = "" ) override;
60  void load( const std::string &uri, Mesh *mesh ) override;
61  bool persist( DatasetGroup *group ) override;
62 
63  private:
64  struct CellCenter
65  {
66  size_t id;
67  double x;
68  double y;
69  };
70 
71  std::unique_ptr< MDAL::MemoryMesh > mMesh;
72  std::string mDatFileName;
73 
74  void createMesh2d( const std::vector<CellCenter> &cells, const MDAL::BBox &cellCenterExtent, double cell_size );
75  void createMesh1d( const std::string &datFileName, const std::vector<CellCenter> &cells, std::map<size_t, size_t> &cellsIdToVertex );
76 
77  void parseOUTDatasets( const std::string &datFileName, const std::vector<double> &elevations );
78  bool parseHDF5Datasets( MDAL::MemoryMesh *mesh, const std::string &timedepFileName );
79  void parseVELFPVELOCFile( const std::string &datFileName );
80  void parseDEPTHFile( const std::string &datFileName, const std::vector<double> &elevations );
81  void parseTIMDEPFile( const std::string &datFileName, const std::vector<double> &elevations );
82  void parseFPLAINFile( std::vector<double> &elevations, const std::string &datFileName, std::vector<CellCenter> &cells, double &cellZize );
83  void parseCADPTSFile( const std::string &datFileName, std::vector<CellCenter> &cells, BBox &cellCenterExtent );
84  void parseCHANBANKFile( const std::string &datFileName, std::map<size_t, size_t> &cellIdToVertices, std::map<size_t, std::vector<size_t> > &duplicatedRightBankToVertex, size_t &verticesCount );
85  void parseCHANFile( const std::string &datFileName, const std::map<size_t, size_t> &cellIdToVertices, std::vector<Edge> &edges );
86  void parseHYCHANFile( const std::string &datFileName, const std::map<size_t, size_t> &cellIdToVertices );
87  void addStaticDataset( std::vector<double> &vals, const std::string &groupName, const std::string &datFileName );
88  static MDAL::Vertex createVertex( size_t position, double half_cell_size, const CellCenter &cell );
89 
90  std::unique_ptr< Mesh > loadMesh2d();
91  std::unique_ptr<Mesh> loadMesh1d();
92 
93  // Write API
94  bool addToHDF5File( DatasetGroup *group );
95  bool saveNewHDF5File( DatasetGroup *group );
96  bool appendGroup( HdfFile &file, DatasetGroup *dsGroup, HdfGroup &groupTNOR );
97  };
98 
99 } // namespace MDAL
100 #endif //MDAL_FLO2D_HPP
Definition: mdal_hdf5.hpp:60
Definition: mdal_hdf5.hpp:108
Definition: mdal_data_model.hpp:137
This driver can be used to read FLO-2D mesh (1D, 2D) The required file for this format are :
Definition: mdal_flo2d.hpp:49
Definition: mdal_driver.hpp:28
Definition: mdal_memory_data_model.hpp:291
Definition: mdal_data_model.hpp:238
Definition: mdal_data_model.hpp:24
Definition: mdal_memory_data_model.hpp:23