Managing Hydrodynamic Models With PHP


Published on

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Managing Hydrodynamic Models With PHP

    1. 1. Managing Hydrodynamic Models with PHP Sydney Open Source Developers’ Conference 3 rd December 2008
    2. 2. Talk Outline <ul><li>PHP class library for spatial data manipulation </li></ul><ul><li>Windows environment tweaked to facilitate usage of the library from the command line </li></ul><ul><li>PHP used to manipulate flood </li></ul><ul><li>models and present results </li></ul><ul><li>MySQL table structure developed to store and manage model input and output </li></ul><ul><li>Visualisations of flood model results can be used to summarise large and complex data sets </li></ul>
    3. 3. PHP Class Library <ul><li>Developed over the last 7 years as a problem solving tool </li></ul><ul><li>Used to manipulate, transform and analyse spatial data </li></ul><ul><li>Stores the data structures in a MySQL database </li></ul><ul><li>PHP provides the “glue” between numerous small command line utilities. </li></ul><ul><li>Used to produce visualisations of flood modelling results </li></ul>
    4. 4. PHP Environment <ul><li>Windows network with 75 users </li></ul><ul><li>PHP class library must be available to approximately 6 users </li></ul><ul><li>Scripts developed to perform common file manipulation tasks </li></ul><ul><li>Single PHP installation on a network drive to ensure a uniform operating environment </li></ul><ul><li>All users have access to the same class libraries </li></ul>
    5. 5. Benefits/Disadvantages of using PHP/MySQL <ul><li>Benefits </li></ul><ul><ul><li>Rapid development time </li></ul></ul><ul><ul><li>Readily interacts with text files and MySQL </li></ul></ul><ul><ul><li>Open Source </li></ul></ul><ul><ul><li>Can generate images using GD extension </li></ul></ul><ul><li>Disadvantages </li></ul><ul><ul><li>Slow run times </li></ul></ul><ul><ul><li>Memory hungry </li></ul></ul><ul><ul><li>Frequent minor changes to PHP architecture </li></ul></ul><ul><ul><li>Lack of pre-existing geometry and meshing libraries </li></ul></ul><ul><ul><li>MySQL Spatial support not mature </li></ul></ul>
    6. 6. Using PHP From the Command Line <ul><li>Meshing class library has no GUI </li></ul><ul><li>Scripts run from the command line </li></ul><ul><li>Scripts can be run interactively (php –a) </li></ul><ul><li>Interactive use of PHP allows greater flexibility when composing scripts </li></ul><ul><li>Requires the user to be familiar with the classes and methods </li></ul><ul><li>Several network “tweaks” are rolled out in the login script to make command line use of PHP easier </li></ul>
    7. 7. “ Command Prompt Here” <ul><li>1.Navigate in your Registry to </li></ul><ul><li>HKEY_LOCAL_MACHINE/Software/Classes/Folder/Shell </li></ul><ul><li>and create a key called &quot;Command Prompt&quot; without the quotes. </li></ul><ul><li>2. Set the default string to whatever text you want to appear in the right-click menu. </li></ul><ul><li>3.Create a new key within your newly created command prompt named &quot;command,&quot; and set the default string to </li></ul><ul><li>cmd.exe /k pushd %1 </li></ul><ul><li>4.The changes should take place immediately. Right click a folder and your new menu item should appear. </li></ul>
    8. 8. Example PHP Command Line Session
    9. 9. Example PHP Script
    10. 10. Flood Modelling Process
    11. 11. cli_progress_bar
    12. 12. Using class cli_progress_bar <ul><li><? </li></ul><ul><li>include &quot;meshlab.php&quot;; </li></ul><ul><li>$numsteps=100000; </li></ul><ul><li>$c=new cli_progressbar(100000,”Testing the progress bar”); </li></ul><ul><li>for($i=1;$i<=100000;$i++){ </li></ul><ul><li>$c->update($i); </li></ul><ul><li>} </li></ul><ul><li>$c->finish(); </li></ul><ul><li>?> </li></ul>
    13. 13. Commonly Used Tools in %PATH% <ul><li>PHP Library makes extensive use of the exec() command </li></ul><ul><li>Commonly used tools are kept in a network folder which is included in the users PATH variable </li></ul><ul><li>Allows small command line utilities to be accessible to the PHP script </li></ul><ul><li>Allows a modular approach to the software </li></ul><ul><li>Facilitates the use of custom written helper utilities </li></ul>
    14. 14. Flood Modelling Challenges <ul><li>Numerous applications used during the modelling process </li></ul><ul><li>Each application uses a different file format for storing meshes/points/other spatial information </li></ul><ul><li>Large volumes of data generated during the process </li></ul><ul><li>Numerous file formats used throughout the process </li></ul>
    15. 15. Available Data <ul><li>Airborne Laser Scanning (ALS) </li></ul><ul><li>ALS produces hundreds of millions of points that describe the terrain surface </li></ul><ul><li>Geo-rectified Air Photo </li></ul><ul><li>Subsidence predictions </li></ul><ul><li>Flood model output </li></ul>
    16. 16. Air Photo
    17. 17. Levels of Detail in Terrain Models
    18. 18. Initial 2D Finite Element Mesh
    19. 19. PHP Classes
    20. 20. PHP Library Input/Output Formats
    21. 21. Flood Modelling Process
    22. 22. 2 Dimensional Hydrodynamic Models <ul><li>We use a 2 dimensional finite element mesh to represent the floodplain </li></ul><ul><li>Balance between mesh accuracy and number of elements </li></ul><ul><li>Elements are only required where flooding occurs </li></ul><ul><li>Need to cull points that are above the flood level </li></ul><ul><li>Need to reduce the level of detail in the remaining points </li></ul>
    23. 23. Finite Element Mesh Generation <ul><li>Require less than 50000 elements with current computing technology </li></ul><ul><li>Resulting mesh must accurately represent the hydrodynamic features of the terrain </li></ul><ul><li>Quadric Error Metrics used to reduce mesh from ~1million to ~50000 elements (QSlim Application) </li></ul><ul><li>Results in “variable density” mesh </li></ul><ul><li>Good technique because it preserves volume </li></ul><ul><li>Important because this relates to the hydraulic conveyance of the topography </li></ul><ul><li>qslim_example.bat  </li></ul>
    24. 24. Data Flow and Storage
    25. 25. Example PHP Script
    26. 26. Vector vs Raster <ul><li>Vector </li></ul><ul><ul><li>Irregularly spaced data </li></ul></ul><ul><ul><li>Eg: triangulated meshes </li></ul></ul><ul><ul><li>Finite element models </li></ul></ul><ul><ul><li>Triangulated laser scan data </li></ul></ul><ul><li>Raster </li></ul><ul><ul><li>Images </li></ul></ul><ul><ul><li>Heightfields </li></ul></ul>
    27. 27. 2D Interpolation
    28. 28. 3D Interpolation
    29. 29. Vector to Raster Conversion Depth Animation
    30. 30. Rasterised Data <ul><li>Triangulation across each triangle or element allows us to calculate the following values at each pixel </li></ul><ul><ul><li>ground height </li></ul></ul><ul><ul><li>water surface elevation </li></ul></ul><ul><ul><li>water velocity </li></ul></ul><ul><ul><li>RGB colour </li></ul></ul><ul><ul><li>ground slope </li></ul></ul><ul><li>Some of these values vary with time allowinf the visualisation to be animated </li></ul>
    31. 31. Raster Database Structure
    32. 32. Terrain Model Properties - Pixel 1207,535
    33. 33. Design Storm Flood Depths Depth Animation
    34. 34. Design Storm Velocities
    35. 35. 2D Animation Example
    36. 36. Databases
    37. 37. Indexing Structures - Nodes
    38. 38. Indexing Structures - Elements
    39. 39. Indexing Structures
    40. 40. Indexing Structures - Edges
    41. 41. Indexing Structures - Fulledges
    42. 42. Cross Sections Through an Irregular Mesh
    43. 43. Selecting a cross section from the database <ul><li>Use of the “fulledges” indexing structure allows more complex queries to be performed </li></ul><ul><li>For example the following query will pull out a cross section across the mesh along a particular “Y” value </li></ul><ul><li>SELECT stored_fulledges.meshID, stored_fulledges.element1, stored_fulledges.element2, stored_nodes.x, stored_nodes.y, stored_nodes.z, stored_nodes_1.x, stored_nodes_1.y, stored_nodes_1.z </li></ul><ul><li>FROM </li></ul><ul><li>(stored_fulledges LEFT JOIN stored_nodes FORCE INDEX (PRIMARY) ON stored_fulledges.node1 = stored_nodes.nodeID ) </li></ul><ul><li>LEFT JOIN </li></ul><ul><li>stored_nodes AS stored_nodes_1 FORCE INDEX (PRIMARY) ON stored_fulledges.node2 = stored_nodes_1.nodeID </li></ul><ul><li>WHERE ( </li></ul><ul><li>(stored_fulledges.meshID = $meshID) AND ( stored_nodes.y > $y ) AND ( stored_nodes_1.y < $y) </li></ul><ul><li>) OR ( </li></ul><ul><li>(stored_fulledges.meshID = $meshID) AND (stored_nodes.y < $y) AND ( stored_nodes_1.y > $y) </li></ul><ul><li>) </li></ul><ul><li>ORDER BY stored_nodes.x, stored_nodes_1.x; </li></ul>
    44. 44. Levels of Detail
    45. 45. Area of Interest - 20000 Element Mesh
    46. 46. Comparison Through Cross Sections <ul><li>Initial mesh approximately represents the terrain </li></ul><ul><li>More detail required for smaller channels </li></ul>
    47. 47. Comparison Through Cross Sections <ul><li>Smaller mesh with 20000 elements much better represents the cross section </li></ul><ul><li>More detailed analysis of the flow is possible </li></ul>
    48. 48. Level of Detail in the Finite Element Mesh
    49. 49. Mesh Validation <ul><li>3D visualisations can assist in validation of the model </li></ul><ul><li>Allows checking to ensure mesh has enough detail </li></ul><ul><li>Integrity of channels can be visually checked </li></ul><ul><li>Show qvis model (ground_points_20k.bat) </li></ul>
    50. 50. Mesh Generation Tradeoffs <ul><li>Why would we need multiple models of the same region at different levels of detail? </li></ul><ul><li>Development time vs accuracy </li></ul><ul><li>Mesh detail vs accuracy </li></ul><ul><li>Model Run Time vs Number of Elements </li></ul><ul><li>Disk Storage </li></ul><ul><li>Consider the accuracy of input data </li></ul>
    51. 51. Other Applications <ul><li>Level of detail terrain modelling can be used for many applications </li></ul><ul><ul><li>Air modelling </li></ul></ul><ul><ul><li>Noise modelling </li></ul></ul><ul><ul><li>Identification of Vegetation communities </li></ul></ul><ul><ul><li>Visual impact studies </li></ul></ul><ul><ul><li>Landform analysis (e.g. slopes, x-sections) </li></ul></ul><ul><ul><li>Rainfall intensity (Animation ->) </li></ul></ul><ul><ul><li>… </li></ul></ul>
    52. 52. Visualising Flood Model Output in 3D <ul><li>Flood model output can be rendered in 3D using Povray open source rendering program </li></ul><ul><li>Time varying data can be animated </li></ul><ul><li>Visualising the data in 3 dimensions can summarise complex datasets </li></ul><ul><li>Model output can be more accessible in this format </li></ul>
    53. 53. Air Photo
    54. 54. RMA Mesh
    55. 55. Thematic Representation of Maximum Depth
    56. 56. Heightfield
    57. 57. Using Povray to Create a 3D Render
    58. 58. Air Photo
    59. 59. DTM – Ground Returns
    60. 60. DTM – Non-Ground Returns
    61. 61. 100 Year ARI Depth at Time 79500 seconds
    62. 62. Heightfield
    63. 63. Flood Model Results Draped on Heightfield
    64. 68. Rainfall Intensity Animation
    65. 69. Links <ul><li>View some of the animations from the presentation at the following URL: </li></ul><ul><ul><li> </li></ul></ul><ul><ul><li> </li></ul></ul>