Skip to content

Commit

Permalink
changed merge_overlapping_meshes + tests 02
Browse files Browse the repository at this point in the history
  • Loading branch information
felicio93 committed Sep 12, 2024
1 parent a56b4db commit 6e4eb9f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 67 deletions.
2 changes: 1 addition & 1 deletion ocsmesh/geom/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def __init__(
clip_shape = ops.transform(
transformer.transform, clip_shape)
try:
in_item.clip(clip_shape)
raster.clip(clip_shape)
except ValueError as err:
# This raster does not intersect shape
_logger.debug(err)
Expand Down
66 changes: 0 additions & 66 deletions ocsmesh/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3768,69 +3768,3 @@ def triangulate_rivermapper_poly(rm_poly):

return rm_mesh


def _calculate_mesh_size_function(
buffer_domain,
hires_mesh_clip,
lores_mesh_clip,
buffer_crs
):

assert buffer_crs == hires_mesh_clip.crs == lores_mesh_clip.crs

# HARDCODED FOR NOW
approx_elem_per_width = 3

msht_hi = deepcopy(hires_mesh_clip)
msht_lo = deepcopy(lores_mesh_clip)

crs = buffer_crs
assert(not buffer_crs.is_geographic)

# calculate mesh size for clipped bits
hfun_hi = Hfun(Mesh(msht_hi))
hfun_hi.size_from_mesh()

hfun_lo = Hfun(Mesh(msht_lo))
hfun_lo.size_from_mesh()

msht_cdt = ocsmesh.utils.triangulate_polygon(
buffer_domain, None, opts='p'
)
msht_cdt.crs = crs

hfun_cdt = Hfun(Mesh(msht_cdt))
hfun_cdt.size_from_mesh()

hfun_cdt_sz = deepcopy(hfun_cdt.msh_t().value) / approx_elem_per_width
msht_cdt.value[:] = hfun_cdt_sz
hfun_rep = Hfun(Mesh(msht_cdt))

mesh_domain_rep = JigsawDriver(
geom=Geom(buffer_domain, crs=crs),
hfun=hfun_rep,
initial_mesh=False
).run(sieve=0)

msht_domain_rep = deepcopy(mesh_domain_rep.msh_t)
# utils.reproject(msht_domain_rep, crs)

pts_2mesh = np.vstack(
(hfun_hi.msh_t().vert2['coord'], hfun_lo.msh_t().vert2['coord'])
)
val_2mesh = np.vstack(
(hfun_hi.msh_t().value, hfun_lo.msh_t().value)
)
domain_sz_1 = griddata(
pts_2mesh, val_2mesh, msht_domain_rep.vert2['coord'], method='linear'
)
domain_sz_2 = griddata(
pts_2mesh, val_2mesh, msht_domain_rep.vert2['coord'], method='nearest'
)
domain_sz = domain_sz_1.copy()
domain_sz[np.isnan(domain_sz_1)] = domain_sz_2[np.isnan(domain_sz_1)]

msht_domain_rep.value[:] = domain_sz
hfun_interp = Mesh(msht_domain_rep)

return hfun_interp

0 comments on commit 6e4eb9f

Please sign in to comment.