Skip to content

River meshing #59

@SorooshMani-NOAA

Description

@SorooshMani-NOAA

In order to get a better representation of rivers and watersheds in the coastal ocean model, I'm trying to generate a mesh for extracted river polygons:
meshing domain
These polygons are extracted from DEM and are not necessarily connected. Apart from that I'd like to use all the vertices and edges that the extraction algorithm has outputed to guide the meshing. I can use pfix for nodes, but is there anything similar for edges?
initial edge and nodes

I know that probably I cannot rely on Shoreline and mesh sizing functions provided for "normal" coastal meshing, so I tried to hack it by defining mine (without worrying about performance for now). This is how I define the signed distance function

def get_dist(x):
    pts = gpd.points_from_xy(x[:, 0], x[:, 0])
    sign = pts.within(shp_geom) * -2 + 1
    dist = sign * pts.distance(shp_geom.boundary)
    return dist

sdf = om.Domain(extent.bbox, get_dist)

And this is how I define the edge length.

 edge_length = om.Grid(
    bbox=extent.bbox,
    dx=hmin,
    hmin=hmin,
    extrapolate=True,
    values=hmax,
    crs=gdf_river_polys.crs,
 )
edge_length.build_interpolant()

points, cells = om.generate_mesh(
    sdf,
    edge_length,
    pfix=df_river_coord[['lon', 'lat']].values,
    max_iter=20
)

I take the hmin to be the smallest of the initial edges and hmin to be the size of the largest edge. I'm still playing with what to specify at as edge_length function, but my ideal solution is to actually not have any size specified and the mesher to just triangulate the nodes specified as initial points pfix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions