Mesh* Crayfish::loadFlo2D( const QString& datFileName, LoadStatus* status )
{
    if (status) status->clear();
    Mesh* mesh = 0;

    try
    {
        // Parse all nodes
        Mesh::Nodes nodes;
        parseCADPTSFile(datFileName, nodes);

        // Parse all elements
        Mesh::Elements elements;
        QVector<float> elevations = parseFPLAINFile(datFileName, elements);

        // Create mesh
        mesh = new Mesh(nodes, elements);

        // create output for bed elevation
        addStaticDataset(elevations, "Bed Elevation", DataSet::Bed, datFileName, mesh);

        // Create Depth and Velocity datasets Time varying datasets
        parseTIMDEPFile(datFileName, mesh, elevations);

        // Maximum Depth and Water Level
        parseDEPTHFile(datFileName, mesh, elevations);

        // Maximum Velocity
        parseVELFPVELOCFile(datFileName, mesh);

    }

    catch (LoadStatus::Error error)
    {
        if (status) status->mLastError = (error);
        if (mesh) delete mesh;
        mesh = 0;
    }

    return mesh;
}
Beispiel #2
0
std::unique_ptr< MDAL::Mesh > MDAL::DriverFlo2D::load( const std::string &resultsFile, MDAL_Status *status )
{
  mDatFileName = resultsFile;
  if ( status ) *status = MDAL_Status::None;
  mMesh.reset();
  std::vector<CellCenter> cells;

  try
  {
    // Parse mMesh info
    parseCADPTSFile( mDatFileName, cells );
    std::vector<double> elevations;
    parseFPLAINFile( elevations, mDatFileName, cells );
    double cell_size = calcCellSize( cells );

    // Create mMesh
    createMesh( cells, cell_size / 2.0 );

    // create output for bed elevation
    addStaticDataset( false, elevations, "Bed Elevation", mDatFileName );

    if ( parseHDF5Datasets( mDatFileName ) )
    {
      // some problem with HDF5 data, try text files
      parseOUTDatasets( mDatFileName, elevations );
    }
  }

  catch ( MDAL_Status error )
  {
    if ( status ) *status = ( error );
    mMesh.reset();
  }

  return std::unique_ptr<Mesh>( mMesh.release() );
}