mesh
The mesh
module provides tools for manipulating ADCIRC meshes.
Functions
Submodules
mesh_merger
Module for merging ADCIRC meshes with optional VEW boundary generation.
- class vewutils.mesh.mesh_merger.MergeStrategy[source]
Bases:
ABC
Abstract base class for mesh merging strategies.
- class vewutils.mesh.mesh_merger.VEWBoundaryStrategy[source]
Bases:
MergeStrategy
Strategy that keeps duplicate nodes and adds VEW boundaries.
- static _find_edges(elements_df)[source]
Find all edges in the mesh and count how many elements each edge belongs to.
- Parameters:
elements_df (
DataFrame
) – DataFrame containing element definitions- Return type:
Dict
- Returns:
Dictionary mapping edges (as frozenset of node IDs) to the number of elements they belong to
- static _split_node_string(nodes, node_neighbors, elements_df)[source]
Split a string of nodes into segments based on domain boundaries.
- Return type:
List
[List
[int
]]
- _find_paired_nodes(nodes_df, tolerance)[source]
Find pairs of nodes that are at identical locations.
- Return type:
List
[Tuple
[int
,int
]]
- _create_vew_boundaries(paired_nodes, land_mesh, node_mapping, combined_elements, config)[source]
Create VEW boundary definitions.
- Return type:
List
[Dict
]
- _filter_boundary_nodes(node_ids, original_length, matching_nodes)[source]
Filter out nodes that are members of matching nodes from a boundary.
- Parameters:
node_ids (
List
[str
]) – List of node IDs in the boundaryoriginal_length (
int
) – Original length of the boundarymatching_nodes (
Set
[str
]) – Set of node IDs that match between the two meshes
- Return type:
Tuple
[List
[int
],bool
]- Returns:
Tuple of (list of indices to keep, whether to keep the boundary)
- class vewutils.mesh.mesh_merger.MergedNodesStrategy[source]
Bases:
MergeStrategy
Strategy that merges duplicate nodes at boundaries.
- class vewutils.mesh.mesh_merger.MeshMerger(channel_mesh, land_mesh)[source]
Bases:
object
Class for merging ADCIRC meshes with configurable strategies.
- static _create_default_config()[source]
Create default configuration for mesh merging.
- Return type:
Dict
- with_flow_coefficients(subcritical, supercritical)[source]
Set the flow coefficients for VEW boundaries.
- Return type:
mesh_subtractor
- class vewutils.mesh.mesh_subtractor.MeshSubtractor[source]
Bases:
object
- _split_node_string(mesh, unshared_edges, unshared_elems)[source]
Split node string into segments based on domain boundaries.
- _generate_boundary_polygons(mesh, segments)[source]
Generate a polygon from the mesh boundary segments.
- Parameters:
mesh – AdcircMesh object containing node coordinates
segments – List of node segments defining boundary rings
- Returns:
A shapely geometry representing the union of all boundary polygons
- Return type:
MultiPolygon or Polygon
- Raises:
ValueError – If no valid polygons could be created from the segments
add_land_boundaries
Module for adding land boundaries (ibtype = 20) along unassigned boundary segments.
- class vewutils.mesh.add_land_boundaries.LandBoundaryAdder(mesh)[source]
Bases:
object
Class for adding land boundaries along unassigned boundary segments.
- static _find_edges(elements_df)[source]
Find all edges in the mesh and count how many elements each edge belongs to.
- Parameters:
elements_df – DataFrame containing element definitions
- Return type:
Dict
- Returns:
Dictionary mapping edges (as frozenset of node IDs) to the number of elements they belong to
- _get_assigned_boundary_nodes()[source]
Get all nodes that are already part of boundary conditions and their endpoints.
- Return type:
Tuple
[Set
[int
],Set
[int
]]- Returns:
Tuple of (set of all assigned nodes, set of endpoint nodes that are part of unassigned boundary edges)
adjust_vew_barrier_heights
Script to ensure VEW boundary barrier heights are above bank elevations.
adjust_vew_channel_elevations
Script to adjust VEW boundary elevations by lowering channel node elevations relative to bank nodes.
vew_boundary_manipulator
Module for manipulating VEW boundaries in ADCIRC meshes.
- class vewutils.mesh.vew_boundary_manipulator.VEWBoundaryManipulator[source]
Bases:
object
Class for manipulating VEW boundaries in ADCIRC meshes.
- static find_matching_nodes(nodes_df1, nodes_df2, tolerance)[source]
Find matching nodes between two meshes within tolerance.
- Parameters:
nodes_df1 (
DataFrame
) – First mesh nodes DataFramenodes_df2 (
DataFrame
) – Second mesh nodes DataFrametolerance (
float
) – Distance tolerance for matching nodes
- Return type:
Dict
[int
,int
]- Returns:
Dictionary mapping first mesh node IDs to second mesh node IDs
- static get_vew_node_pairs(mesh)[source]
Extract bank and channel node pairs from VEW boundaries.
- Parameters:
mesh (
AdcircMesh
) – AdcircMesh object- Returns:
(bank_to_channel, channel_to_bank) dictionaries mapping node IDs
- Return type:
tuple
- static lower_channel_elevations_above_banks(mesh, tolerance)[source]
Lower channel node elevations only when they are above their corresponding bank nodes.
- Parameters:
mesh (
AdcircMesh
) – AdcircMesh objecttolerance (
float
) – Amount to lower channel node elevations below bank node elevations (in meters)
- Return type:
AdcircMesh
- Returns:
Modified AdcircMesh object
- static get_vew_boundaries(mesh)[source]
Get all VEW boundaries from the mesh.
- Parameters:
mesh (
AdcircMesh
) – AdcircMesh object- Return type:
list
- Returns:
List of VEW boundary dictionaries
- static add_vew_boundary(mesh, node_pairs, barrier_heights, subcritical_coefficients=None, supercritical_coefficients=None)[source]
Add a new VEW boundary to the mesh.
- Parameters:
mesh (
AdcircMesh
) – AdcircMesh objectnode_pairs (
list
) – List of (bank_node, channel_node) tuplesbarrier_heights (
list
) – List of barrier heights for each node pairsubcritical_coefficients (
list
) – List of subcritical flow coefficients (default: 1.0)supercritical_coefficients (
list
) – List of supercritical flow coefficients (default: 1.0)
- Return type:
AdcircMesh
- Returns:
Modified AdcircMesh object
- static ensure_barrier_heights_above_banks(mesh, tolerance=0.001)[source]
Set barrier heights in VEW boundaries to bank elevations plus tolerance.
- Parameters:
mesh (
AdcircMesh
) – AdcircMesh objecttolerance (
float
) – Amount to add to bank elevations for barrier heights (in meters, default: 0.001)
- Return type:
AdcircMesh
- Returns:
Modified AdcircMesh object