seamsh.geometry module

class seamsh.geometry.CurveType(*values)

Bases: Enum

Determine how curves control points are interpolated.

BSPLINE = 4

cubic b-spline interpolation (smoother than spline)

FIXED = 5

the points are mesh nodes and the segments mesh elements, kept as they are (lines of an existing mesh, see Domain.add_boundary_curves_msh)

POLYLINE = 1

linear interpolation

SPLINE = 3

cubic spline interpolation

STRICTPOLYLINE = 2

linear interpolation with a mesh point forced on each curve point

class seamsh.geometry.Domain(projection)

Bases: object

List the domain boundaries, forced mesh points and forced mesh lines.

Parameters:

projection (SpatialReference) – coordinate system of the geometry and mesh

add_boundary_curve(points, physical_tag, projection, curve_type=CurveType.POLYLINE)

Add a tagged curve to the domain boundary.

Parameters:
  • points (ndarray) – the curve control points [n,2]

  • physical_tag (str) – the curve physical tag

  • projection (SpatialReference) – the points coordinate system

  • curve_type (CurveType) – curve interpolation

Return type:

None

add_boundary_curves_msh(filename, physical_tags=None, support=None)

Adds lines of an existing mesh as domain boundaries, with their mesh imposed: their nodes and segments are kept as they are (they are not coarsened) so that the new mesh joins the existing one conformally (see seamsh.gmsh.join_meshes). The lines must lie on the boundary of the existing mesh, and the mesh must be in the domain coordinate system.

Parameters:
  • filename (str) – the existing mesh (any format readable by gmsh, typically a .msh file)

  • physical_tags (List[str]) – names of the physical groups of lines to take; if None, the whole boundary of the existing mesh is taken

  • support (Domain) – the curves those lines were made from (e.g. the coastline the existing mesh was generated with), as a Domain whose boundary curves have the same physical tags. They are coarsened like the boundaries of a mesh, on the side of the existing mesh, and the nodes of the lines slide along them when the existing mesh may change (see seamsh.gmsh.mesh, modify_existing).

Return type:

None

add_boundary_curves_shp(filename, physical_name_field=None, curve_type=CurveType.POLYLINE)

Adds all lines, polylines and polygons of a shapefile as domain boundaries

Parameters:
  • filename (str) – path to a shapefile.

  • physical_name_field (str) – name of an attribute string field containing the curves physical tags

  • curve_type (CurveType) – curves interpolation

Return type:

None

add_interior_curve(points, physical_tag, projection, curve_type=CurveType.POLYLINE)

Adds a tagged curve inside the domain. The curve is not part of the domain boundary and will be meshed on both sides.

Parameters:
  • points (ndarray) – the curve control points [n,2]

  • physical_tag (str) – the curve physical tag

  • projection (SpatialReference) – the points coordinate system

  • curve_type (CurveType) – curve interpolation

Return type:

None

add_interior_curves_shp(filename, physical_name_field=None, curve_type=CurveType.POLYLINE)

Adds all lines, polylines and polygons of a shape file as forced interior mesh lines

Parameters:
  • filename (str) – path to a shapefile.

  • physical_name_field (str) – name of and attribute string field with the curves physical tags

  • curve_type (CurveType) – curves interpolation

Return type:

None

add_interior_points(points, physical_tag, projection)

Add forced interior mesh points

Parameters:
  • x – the points [n,2]

  • physical_tag (str) – the points physical tag

  • projection (SpatialReference) – the points coordinate system

Return type:

None

add_interior_points_shp(filename, physical_name_field=None)

Adds all points of a shape file as forced mesh points.

Parameters:
  • filename (str) – path to a shapefile.

  • physical_name_field (str) – name of an attribute string field with the curves physical tags

Return type:

None

seamsh.geometry.coarsen_boundaries(domain, x0=None, x0_projection=None, mesh_size=None, random_seed=0)

Creates a new Domain with the same projection and coarsened boundaries. The curves of type FIXED (lines of an existing mesh) are kept as they are.

Parameters:
  • domain (Domain) – the domain to coarsen

  • x0 (Tuple[float, float]) – the coordinates of one point inside the domain, or a list of points, one in each part of the domain to keep. If None, the part to keep is guessed: without FIXED curves, the largest region closed by the curves; with FIXED curves, every region closed by curves on the other side of the FIXED curves than the existing mesh, except the holes of the existing mesh.

  • x0_projection (SpatialReference) – the coordinates system of x0 (if None, the domain coordinate system).

  • mesh_size (Callable[[ndarray, SpatialReference], ndarray]) – a function returning the desired mesh element size for given coordinates

  • random_seed (int) – deprecated and unused; kept for backward compatibility. hxt2d’s Delaunay resolves cocircular/collinear points symbolically, so the sampled points no longer need a random perturbation.

Return type:

Domain