Name | landlab-triangle JSON |
Version |
0.0.2
JSON |
| download |
home_page | None |
Summary | Create unstructured Landlab grids using Jonathan Shewchuk's Triangle mesh generation software |
upload_time | 2025-08-30 17:05:43 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.13 |
license | None |
keywords |
grid
landlab
mesh
triangle
unstructured
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# landlab-triangle
[**View Landlab Documentation**](https://landlab.readthedocs.io/)
[**View triangle Documentation**](https://www.cs.cmu.edu/~quake/triangle.html)
This repository adds `TriangleModelGrid`, a new Landlab grid type that enables unstructured triangular meshes. Unlike Landlab's standard structured grids, `TriangleModelGrid` allows for complex geometries with irregular boundaries, interior holes, and variable grid resolution.
Uses Jonathan Shewchuk's Triangle software.
## Installation
### Installing from PyPI
```bash
pip install triangle landlab-triangle
```
## Usage
### Option 1: direct initialization
```python
from landlab_triangle import TriangleModelGrid
import numpy as np
# Create a grid directly with exterior coordinates and optional holes
exterior_y = [-1.0, -1.0, 11.0, 11.0]
exterior_x = [0.0, 10.0, 10.0, 0.0]
holes = np.array([[5.0, 5.0]]) # Optional: define interior holes
grid = TriangleModelGrid(
exterior_y_and_x=(exterior_y, exterior_x),
holes=holes,
triangle_opts="pqa1Devjz"
)
print(f"Number of nodes: {grid.number_of_nodes}")
print(f"Number of cells: {grid.number_of_cells}")
print(f"Number of holes: {len(grid._holes)}")
```
### Option 2: from a dictionary
```python
from landlab_triangle import TriangleModelGrid
# Create a grid from a dictionary with "x" and "y" keys
grid_params = {
"x": [0.0, 10.0, 10.0, 0.0],
"y": [0.0, 0.0, 10.0, 10.0],
"triangle_opts": "pqDevjz"
}
grid = TriangleModelGrid.from_dict(grid_params)
```
### Option 3: from a shapefile
```python
from landlab_triangle import TriangleModelGrid
# Create a grid from a shapefile, GeoJSON, or other supported format
grid = TriangleModelGrid.from_shapefile(
"path/to/polygon.geojson",
triangle_opts="pqDevjz",
timeout=10
)
# The grid automatically handles holes defined in the input file
print(f"Number of holes: {len(grid._holes)}")
```
## Triangle options
The `triangle_opts` parameter controls the behavior of the Triangle meshing software. Common options include:
- **q**: Quality mesh generation - ensures no angles smaller than N degrees (defaults to 20)
- **a**: Area constraint - limits the maximum area of triangles
**Timeout**: The `timeout` parameter (in seconds) prevents the meshing process from running indefinitely if Triangle encounters complex geometries.
### Example with area constraint
```python
# Create a grid with maximum triangle area of 0.1
grid = TriangleModelGrid(
exterior_y_and_x=(exterior_y, exterior_x),
triangle_opts="pqa0.1Devjz" # 'a0.1' sets max area to 0.1
)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "landlab-triangle",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.13",
"maintainer_email": null,
"keywords": "grid, landlab, mesh, triangle, unstructured",
"author": null,
"author_email": "Ethan <ethan.g.pierce@dartmouth.edu>",
"download_url": "https://files.pythonhosted.org/packages/4f/9c/1ab70bbcd2a378aa96ad75f4113decae9c9134169e6f80aa31e182f48437/landlab_triangle-0.0.2.tar.gz",
"platform": null,
"description": "# landlab-triangle\n\n[**View Landlab Documentation**](https://landlab.readthedocs.io/)\n\n[**View triangle Documentation**](https://www.cs.cmu.edu/~quake/triangle.html)\n\nThis repository adds `TriangleModelGrid`, a new Landlab grid type that enables unstructured triangular meshes. Unlike Landlab's standard structured grids, `TriangleModelGrid` allows for complex geometries with irregular boundaries, interior holes, and variable grid resolution.\n\nUses Jonathan Shewchuk's Triangle software.\n\n## Installation\n\n### Installing from PyPI\n\n```bash\npip install triangle landlab-triangle\n```\n\n## Usage\n\n### Option 1: direct initialization\n\n```python\nfrom landlab_triangle import TriangleModelGrid\nimport numpy as np\n\n# Create a grid directly with exterior coordinates and optional holes\nexterior_y = [-1.0, -1.0, 11.0, 11.0]\nexterior_x = [0.0, 10.0, 10.0, 0.0]\n\nholes = np.array([[5.0, 5.0]]) # Optional: define interior holes\n\ngrid = TriangleModelGrid(\n exterior_y_and_x=(exterior_y, exterior_x),\n holes=holes,\n triangle_opts=\"pqa1Devjz\"\n)\n\nprint(f\"Number of nodes: {grid.number_of_nodes}\")\nprint(f\"Number of cells: {grid.number_of_cells}\")\nprint(f\"Number of holes: {len(grid._holes)}\")\n```\n\n### Option 2: from a dictionary\n\n```python\nfrom landlab_triangle import TriangleModelGrid\n\n# Create a grid from a dictionary with \"x\" and \"y\" keys\ngrid_params = {\n \"x\": [0.0, 10.0, 10.0, 0.0],\n \"y\": [0.0, 0.0, 10.0, 10.0],\n \"triangle_opts\": \"pqDevjz\"\n}\n\ngrid = TriangleModelGrid.from_dict(grid_params)\n```\n\n### Option 3: from a shapefile\n\n```python\nfrom landlab_triangle import TriangleModelGrid\n\n# Create a grid from a shapefile, GeoJSON, or other supported format\ngrid = TriangleModelGrid.from_shapefile(\n \"path/to/polygon.geojson\",\n triangle_opts=\"pqDevjz\",\n timeout=10\n)\n\n# The grid automatically handles holes defined in the input file\nprint(f\"Number of holes: {len(grid._holes)}\")\n```\n\n## Triangle options\n\nThe `triangle_opts` parameter controls the behavior of the Triangle meshing software. Common options include:\n\n- **q**: Quality mesh generation - ensures no angles smaller than N degrees (defaults to 20)\n- **a**: Area constraint - limits the maximum area of triangles\n\n**Timeout**: The `timeout` parameter (in seconds) prevents the meshing process from running indefinitely if Triangle encounters complex geometries.\n\n### Example with area constraint\n\n```python\n# Create a grid with maximum triangle area of 0.1\ngrid = TriangleModelGrid(\n exterior_y_and_x=(exterior_y, exterior_x),\n triangle_opts=\"pqa0.1Devjz\" # 'a0.1' sets max area to 0.1\n)\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Create unstructured Landlab grids using Jonathan Shewchuk's Triangle mesh generation software",
"version": "0.0.2",
"project_urls": null,
"split_keywords": [
"grid",
" landlab",
" mesh",
" triangle",
" unstructured"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "3a9eef907d342ad4d7d61fbe483c6b9edff3aae59c2d2e1c8d89532dd0883a5e",
"md5": "8e5662b421d7343b165d7e57e13d526d",
"sha256": "e96e7062815e8aac3dfa37ffe19f77bcc9a314750478b88f48dacb3155ae4265"
},
"downloads": -1,
"filename": "landlab_triangle-0.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8e5662b421d7343b165d7e57e13d526d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.13",
"size": 12117,
"upload_time": "2025-08-30T17:05:41",
"upload_time_iso_8601": "2025-08-30T17:05:41.784361Z",
"url": "https://files.pythonhosted.org/packages/3a/9e/ef907d342ad4d7d61fbe483c6b9edff3aae59c2d2e1c8d89532dd0883a5e/landlab_triangle-0.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "4f9c1ab70bbcd2a378aa96ad75f4113decae9c9134169e6f80aa31e182f48437",
"md5": "3eb18512ee3d7ade57053e32b1b915b8",
"sha256": "ea8b7e65c0de00dc26e2ece1bbfde686b2d58d434538cef2fbf94ade16467b18"
},
"downloads": -1,
"filename": "landlab_triangle-0.0.2.tar.gz",
"has_sig": false,
"md5_digest": "3eb18512ee3d7ade57053e32b1b915b8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.13",
"size": 44036,
"upload_time": "2025-08-30T17:05:43",
"upload_time_iso_8601": "2025-08-30T17:05:43.294249Z",
"url": "https://files.pythonhosted.org/packages/4f/9c/1ab70bbcd2a378aa96ad75f4113decae9c9134169e6f80aa31e182f48437/landlab_triangle-0.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-30 17:05:43",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "landlab-triangle"
}