You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MeshKernel does not refine a mesh with with a GeometryList that contains an inner (a polygon with a hole)
To reproduce, run the code at the bottom. The plot below results from the code. The left one is the base mesh. The middle one refined correcly, based on a GeometryList object without inners. The right one does not refine, as a GeometryList object with inner is provided.
Version info:
OS: Windows
Version: meshkernel 1.0.0
Script to test
`# Import modules
import meshkernel as mk
import matplotlib.pyplot as plt
import numpy as np
MeshKernel does not refine a mesh with with a GeometryList that contains an inner (a polygon with a hole)
To reproduce, run the code at the bottom. The plot below results from the code. The left one is the base mesh. The middle one refined correcly, based on a GeometryList object without inners. The right one does not refine, as a GeometryList object with inner is provided.
Version info:
Script to test
`# Import modules
import meshkernel as mk
import matplotlib.pyplot as plt
import numpy as np
Polygons
outer = mk.GeometryList(
x_coordinates=np.array([2.5, 6.5, 7.5, 1.5, 2.5]), y_coordinates=np.array([2.5, 1.5, 6.5, 7.5, 2.5])
)
inner = mk.GeometryList(
x_coordinates=np.array([4.0, 6.0, 6.0, 4.0, 4.0])-0.2, y_coordinates=np.array([4.0, 4.0, 6.0, 6.0, 4.0])-0.2,
)
holed = mk.GeometryList(
x_coordinates=np.concatenate([outer.x_coordinates, [outer.inner_outer_separator], inner.x_coordinates]),
y_coordinates=np.concatenate([outer.y_coordinates, [outer.inner_outer_separator], inner.y_coordinates]),
)
Refinement parameters
parameters = mk.MeshRefinementParameters(
refine_intersected=True,
use_mass_center_when_refining=False,
min_face_size=10.0, # Does nothing?
refinement_type=1, # No effect?
connect_hanging_nodes=True,
account_for_samples_outside_face=False,
max_refinement_iterations=1,
)
Meshkernel
meshkernel = mk.MeshKernel()
Function to create base mesh
def generate_base_mesh():
mesh2d_input = mk.Mesh2dFactory.create_rectilinear_mesh(
rows=10,
columns=10,
origin_x=0,
origin_y=0,
spacing_x=1,
spacing_y=1,
)
return mesh2d_input
Create base mesh
mesh2d_input = generate_base_mesh()
meshkernel.mesh2d_set(mesh2d_input)
mesh2d_base = meshkernel.mesh2d_get()
Create refined mesh
mesh2d_input = generate_base_mesh()
meshkernel.mesh2d_set(mesh2d_input)
meshkernel.mesh2d_refine_based_on_polygon(outer, parameters)
mesh2d_refined = meshkernel.mesh2d_get()
Create mesh that should be refined based on holed polygon
mesh2d_input = generate_base_mesh()
meshkernel.mesh2d_set(mesh2d_input)
meshkernel.mesh2d_refine_based_on_polygon(holed, parameters)
mesh2d_should_be_refined = meshkernel.mesh2d_get()
Plot
fig, axs = plt.subplots(ncols=3, figsize=(13.5, 5), constrained_layout=True)
for ax in axs:
ax.set(aspect=1.0)
mesh2d = meshkernel.mesh2d_get()
ax = axs[0]
mesh2d_base.plot_edges(ax=ax)
ax = axs[1]
mesh2d = meshkernel.mesh2d_get()
mesh2d_refined.plot_edges(ax=ax)
ax.plot(outer.x_coordinates, outer.y_coordinates, color='k')
ax = axs[2]
mesh2d_should_be_refined.plot_edges(ax=ax)
ax.plot(outer.x_coordinates, outer.y_coordinates, color='k')
ax.plot(inner.x_coordinates, inner.y_coordinates, color='k')`
The text was updated successfully, but these errors were encountered: