d2hydro / H2i_code_factory

Code factory for H2i data preperation
0 stars 2 forks source link

MDAL implementation #1

Open vcloarec opened 2 years ago

vcloarec commented 2 years ago

Hi,

Starting to explore the format,and thinking about the best way for MDAL to interpret the format.

It seems like H2i format is not a vertex/faces format but a nodes/links format.

Do nodes represent cells and links interfaces between cells?

In this case, have cells always the same size?

I am wondering about the "direction" of links, "horizontal" or "vertical"? What is the signification of this direction?

vcloarec commented 2 years ago

I think I have understand: Vertical: link in the Y direction, and horizontal, in the X direction.

Then, I suppose that the cell are always square with side in the X/Y direction, and mesh rotation is no supported by the format.

And cells can be quadtree.

vcloarec commented 2 years ago

here first results in QGIS:

Topography: The value considered by MDAL is the average value of Zmin and Zmax defined on H2i cells. image

Water level: h2i

Can you confirm the consistency of these results?

d2hydro commented 2 years ago

Hi @vcloarec; sorry I missed the last line in your last comment :-).

The mesh looks consistent with what I draw. I see a few things we have to discuss:

  1. Think we would like to show the hydrodem directly as the topography layer if possible. It is in gray-scale in the screendump below.
  2. Think we need to discuss where we show velocity. I convert the links to the red nodes in the picture below

image

vcloarec commented 2 years ago

hi @d2hydro

For point 1: it seems resolution of you topography layer is finer that the mesh resolution. So, the only way to render the topography as this original layer is to make a mesh with faces or vertices for each cells of the topographic layer, that will not be the same mesh. If we keep the quad tree for the mesh frame, we can't have the same rendering as your topographic layer.

In that case, if you don't want this coarse topographic dataset group (for example, if you prefer render the topography only with the raster layer), we can remove the topographic dataset from the mesh.

In the other hand, if you want the mesh to have the same resolution as the topographic layer, we have to change the approach with another mesh frame (not the quad tree). This is another story...

For point 2: Please, tell me if I have a good understanding of velocity/discharge dataset: The link contains velocity/discharge data for only one direction (X or Y) corresponding of the interface between cells (node). Retrieving the 2D velocity in the plane can be done by combining horizontal and vertical links.

For the current fresh implementation (see https://github.com/lutraconsulting/MDAL/pull/400), the velocity/discharge values are interpolated from the link values to the center of the cell. So for H2i format in MDAL, the velocity/discharge are vector value on face. In QGIS the rendering is either a vector starting fro the centroid of the face, either a scalar value (vector magnitude) considered constant on the whole face. With this interpretation of the links values, the discharge become the commonly used (in 2D modeling) "unit discharge" with unit m2/s. Here the rendering of your data under QGIS (unit discharge is rendered as scalar, and velocity rendered as arrows):

hdi_flux

with resampling unit discharge under QGIS: image

vcloarec commented 2 years ago

Looking at the "velocityupwind2d.dat" file that should contains vector velocity on nodes.

The structure of the file shows arrays that have a length of the nodes count. The array count is twice the count of time step. So we can suppose that the structure is for each time step, and with n nodes:

(M1, M2, ...,Mn) for time step 1 (D1, D2, ...,Dn) for time step 1 (M1, M2, ...,Mn) for time step 2 (D1, D2, ...,Dn) for time step 2 ... (M1, M2, ...,Mn) for time step t (D1, D2, ...,Dn) for time step t

With Mi and Di the magnitude and the direction of velocity at node i.

Can you confirm this file structure? Is the direction is from the positive X axis?

In that case, the result of reading this file in QGIS is: image Does this result look good? It looks odd to me, but maybe because this is a experimental result file?

d2hydro commented 2 years ago

Can you confirm the documentation is complete now: https://github.com/d2hydro/H2i_code_factory/blob/main/docs/data_format.md#flowsts.

I've checked with the core-development team; these should be the directions: 0 = East Pi = West 0.5Pi = South -0.5Pi = North