Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,4 @@ __marimo__/

#
.pyc
__pycache__
125 changes: 102 additions & 23 deletions examples/basic_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"outputs": [],
"source": [
"\n",
"domain = box(0, 0, 200, 150)\n",
"domain = box(0, 0, 200, 200)\n",
"poly1 = box(50, 50, 75, 75)\n",
"# generate sine wave curve for river\n",
"river_coords = [(x, 75 + 20 * np.sin(0.1 * x)) for x in range(-10, 220, 10)]\n",
Expand All @@ -36,60 +36,139 @@
"fault_line = LineString([(100, 0), (100, 150)])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c970674e",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "d52a10b8",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "71f205cc",
"metadata": {},
"outputs": [],
"source": [
"# 1. Setup Blueprint\n",
"background_lc=100\n",
"\n",
"blueprint = ConceptualMesh(crs=\"EPSG:3857\")\n",
"blueprint.add_polygon(domain, zone_id=1, resolution=200)\n",
"blueprint.add_polygon(poly1, zone_id=2, resolution=5, z_order=1) \n",
"blueprint.add_point(well_point, point_id=\"Well-A\", resolution=100)\n",
"blueprint.add_line(fault_line, line_id=\"Fault-1\", resolution=5, \n",
" is_barrier=True)\n",
"blueprint.add_line(river_coords, line_id=\"riv-1\", resolution=3, \n",
" is_barrier=False)\n",
"blueprint.add_polygon(domain, zone_id=1)#,border_density=100,dist_max_in=background_lc)\n",
"blueprint.add_polygon(poly1, zone_id=2, \n",
" resolution=1, z_order=2,\n",
" dist_max_out=3* background_lc,\n",
" #dist_max_in=10\n",
" ) \n",
"blueprint.add_point(well_point, point_id=\"Well-A\", \n",
" resolution=2,\n",
" dist_max=300)\n",
"blueprint.add_line(fault_line, line_id=\"Fault-1\", \n",
" resolution=1, \n",
" is_barrier=True,\n",
" #straddle_width=1,\n",
" dist_max=3* 5)\n",
"blueprint.add_line(river_coords, line_id=\"riv-1\", \n",
" resolution=1, \n",
" is_barrier=False,\n",
" dist_max=3* 5,)\n",
"\n",
"clean_polys, clean_lines, clean_pts = blueprint.generate()\n",
"\n",
"# 2. Mesh Generation\n",
"mesher = MeshGenerator()\n",
"mesher = MeshGenerator(background_lc=background_lc, verbosity=10)\n",
"mesher.generate(clean_polys, clean_lines, clean_pts)\n",
"\n",
"# 3. Voronoi Conversion\n",
"tessellator = VoronoiTessellator(mesher, blueprint)\n",
"tessellator = VoronoiTessellator(mesher, blueprint, clip_to_boundary=True)\n",
"grid_gdf = tessellator.generate()\n",
"\n",
"# 4. Output\n",
"#grid_gdf.to_file(\"mf6_grid.shp\")"
"#grid_gdf.to_file(\"mf6_grid.shp\")\n",
"\n",
"\n",
"\n",
"fig,ax = plt.subplots(1,1,figsize=(12,12))\n",
"ax.set_aspect('equal')\n",
"# plot domain\n",
"ax.plot(*domain.exterior.xy,marker='.', color='black')\n",
"# plot poly1\n",
"#ax.plot(*poly1.exterior.xy, color='blue',lw=1,ls='--',label='Polygon 1')\n",
"ax.plot(*river_coords.xy, color='cyan',lw=1,ls='--',label='River')\n",
"ax.plot(*fault_line.xy, color='r',lw=1,ls='--',label='Fault')\n",
"ax.scatter(*well_point.xy, color='r',s=20,marker='x',label='Well')\n",
"grid_gdf.plot(ax=ax, alpha=0.5, edgecolor='k', linewidth=0.2)\n",
"\n",
"ax.legend(loc='upper left', fontsize=8)\n",
"#ax.set_ylim(50,80)\n",
"#ax.set_xlim(90, 110)\n",
"#\n",
"#ax.set_ylim(40,80)\n",
"#ax.set_xlim(40, 80)\n",
"\n",
"fig.tight_layout()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "71f205cc",
"id": "efd5f0a2",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "eda65ca1",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "0ba0153a",
"metadata": {},
"outputs": [],
"source": [
"fig,ax = plt.subplots(1,1,figsize=(15,15))\n",
"ax.set_aspect('equal')\n",
"# plot domain\n",
"ax.plot(*domain.exterior.xy,marker='.', color='black')\n",
"# plot poly1\n",
"ax.plot(*poly1.exterior.xy, color='blue',lw=1,ls='--')\n",
"ax.plot(*river_coords.xy, color='cyan',lw=1,ls='--')\n",
"ax.plot(*fault_line.xy, color='r',lw=1,ls='--')\n",
"ax.scatter(*well_point.xy, color='green',s=100,marker='x')\n",
"grid_gdf.plot(ax=ax)"
"from vorflow.utils import *"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cfd21be8",
"metadata": {},
"outputs": [],
"source": [
"gdf = calculate_mesh_quality(grid_gdf,calc_ortho=True)\n",
"gdf.plot(column='drift_ratio', cmap='viridis', legend=True, figsize=(10,8),vmax=.25)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9f7361dd",
"metadata": {},
"outputs": [],
"source": [
"summarize_quality(gdf)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b6c2a945",
"id": "870ec1be",
"metadata": {},
"outputs": [],
"source": []
Expand Down
Loading
Loading