Skip to content

Commit 0970eb2

Browse files
committed
Merge branch 'master' of https://github.com/rustychris/stompy
2 parents 3716e64 + cd78e8b commit 0970eb2

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

stompy/grid/multi_ugrid.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ def __init__(self,paths,cleanup_dfm='auto',xr_kwargs={},grid=None,
394394
if f in g.cells.dtype.names:
395395
log.warning("Dropping extra cell field %s to avoid max_sides issues"%f)
396396
g.delete_cell_field(f)
397+
g.edge_to_cells(recalc=True) # 20250813: failing to merge, seems to be edge ordering.
397398
if is_dfm:
398399
# kludge DFM output (ver. 2021.03) has nNetElem and nFlowElem, which appear to
399400
# both be for the cell dimension

stompy/grid/unstructured_grid.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,12 +865,14 @@ def process_as_index(varname):
865865
if 'face_edge_connectivity' in mesh.attrs:
866866
v=mesh.attrs['face_edge_connectivity']
867867
if v in nc:
868+
start_index=nc[v].attrs.get('start_index',0)
868869
# Some files advertise variable they don't have. Trust no one.
869-
ug.cells['edges'] = nc[v].values
870+
ug.cells['edges'] = nc[v].values - start_index
870871
if 'edge_face_connectivity' in mesh.attrs:
871872
v=mesh.attrs['edge_face_connectivity']
872873
if v in nc:
873-
cells = nc[v].values
874+
start_index=nc[v].attrs.get('start_index',0)
875+
cells = nc[v].values - start_index
874876
ug.edges['cells'] = np.where( np.isfinite(cells), cells, -1)
875877

876878
if dialect=='fishptm':

stompy/model/delft/dflow_model.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ class DFlowModel(hm.HydroModel,hm.MpiModel):
5353
dwaq=False
5454
# Specify location of proc_def.def file:
5555
waq_proc_def=None
56+
57+
# Explicitly write points in dry areas to make sure DFM doesn't turn islands into
58+
# cells. Hasn't generally been needed.
59+
automatic_dry_points=False
5660

5761
# flow and source/sink BCs will get the adjacent nodes dredged
5862
# down to this depth in order to ensure the impose flow doesn't
@@ -955,9 +959,23 @@ def write_config(self):
955959
# Assumes update_config() already called
956960
self.write_structures() # updates mdu
957961
self.write_monitors()
962+
if self.automatic_dry_points:
963+
self.write_dry_points()
958964
log.info("Writing MDU to %s"%self.mdu.filename)
959965
self.mdu.write()
960966

967+
def write_dry_points(self):
968+
self.mdu['geometry','DryPointsFile'] = 'dry_points.xyz'
969+
dest=os.path.join(self.run_dir, self.mdu['geometry','DryPointsFile'])
970+
971+
lines=self.grid.boundary_linestrings()
972+
with open(dest,'wt') as fp:
973+
for line in lines:
974+
# outer boundary has negative area, skip it.
975+
if utils.signed_area(line)<0: continue
976+
pnt=geometry.Polygon(line).representative_point().coords[0]
977+
fp.write(f"{pnt[0]:.6f},{pnt[1]:0.6f},0\n")
978+
961979
def write_monitors(self):
962980
# start with empty
963981
if not self.mdu['output','ObsFile']:

0 commit comments

Comments
 (0)