2018-12-14 14:59:53 +01:00
|
|
|
/*
|
|
|
|
MDAL - Mesh Data Abstraction Library (MIT License)
|
|
|
|
Copyright (C) 2018 Peter Petrik (zilolv at gmail dot com)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MDAL_FLO2D_HPP
|
|
|
|
#define MDAL_FLO2D_HPP
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "mdal_data_model.hpp"
|
|
|
|
#include "mdal_memory_data_model.hpp"
|
|
|
|
#include "mdal.h"
|
|
|
|
#include "mdal_driver.hpp"
|
|
|
|
|
2019-11-29 15:15:01 +01:00
|
|
|
class HdfGroup;
|
|
|
|
class HdfFile;
|
|
|
|
|
2018-12-14 14:59:53 +01:00
|
|
|
namespace MDAL
|
|
|
|
{
|
|
|
|
class DriverFlo2D: public Driver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DriverFlo2D();
|
|
|
|
~DriverFlo2D( ) override = default;
|
|
|
|
DriverFlo2D *create() override;
|
|
|
|
|
2019-11-29 15:15:01 +01:00
|
|
|
bool canReadMesh( const std::string &uri ) override;
|
|
|
|
bool canReadDatasets( const std::string &uri ) override;
|
|
|
|
|
2020-04-14 02:17:15 -04:00
|
|
|
std::unique_ptr< Mesh > load( const std::string &resultsFile, const std::string &meshName = "" ) override;
|
2020-03-09 05:59:51 +01:00
|
|
|
void load( const std::string &uri, Mesh *mesh ) override;
|
2019-11-29 15:15:01 +01:00
|
|
|
bool persist( DatasetGroup *group ) override;
|
2018-12-14 14:59:53 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
struct CellCenter
|
|
|
|
{
|
|
|
|
size_t id;
|
|
|
|
double x;
|
|
|
|
double y;
|
|
|
|
std::vector<int> conn; // north, east, south, west cell center index, -1 boundary Vertex
|
|
|
|
};
|
|
|
|
|
|
|
|
std::unique_ptr< MDAL::MemoryMesh > mMesh;
|
|
|
|
std::string mDatFileName;
|
|
|
|
|
|
|
|
void createMesh( const std::vector<CellCenter> &cells, double half_cell_size );
|
|
|
|
void parseOUTDatasets( const std::string &datFileName, const std::vector<double> &elevations );
|
2019-11-29 15:15:01 +01:00
|
|
|
bool parseHDF5Datasets( MDAL::MemoryMesh *mesh, const std::string &timedepFileName );
|
2018-12-14 14:59:53 +01:00
|
|
|
void parseVELFPVELOCFile( const std::string &datFileName );
|
|
|
|
void parseDEPTHFile( const std::string &datFileName, const std::vector<double> &elevations );
|
|
|
|
void parseTIMDEPFile( const std::string &datFileName, const std::vector<double> &elevations );
|
|
|
|
void parseFPLAINFile( std::vector<double> &elevations, const std::string &datFileName, std::vector<CellCenter> &cells );
|
|
|
|
void parseCADPTSFile( const std::string &datFileName, std::vector<CellCenter> &cells );
|
2019-05-27 13:15:59 +02:00
|
|
|
void addStaticDataset( std::vector<double> &vals, const std::string &groupName, const std::string &datFileName );
|
2018-12-14 14:59:53 +01:00
|
|
|
static MDAL::Vertex createVertex( size_t position, double half_cell_size, const CellCenter &cell );
|
|
|
|
static double calcCellSize( const std::vector<CellCenter> &cells );
|
2019-11-29 15:15:01 +01:00
|
|
|
|
|
|
|
// Write API
|
|
|
|
bool addToHDF5File( DatasetGroup *group );
|
|
|
|
bool saveNewHDF5File( DatasetGroup *group );
|
|
|
|
bool appendGroup( HdfFile &file, DatasetGroup *dsGroup, HdfGroup &groupTNOR );
|
|
|
|
|
2018-12-14 14:59:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace MDAL
|
|
|
|
#endif //MDAL_FLO2D_HPP
|