[docs] Check-in Fluids_Tutorial.ipynb
"source": [
"# Staggered grids\n",
"\n",
+ "[![Google Collab Book](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/tum-pbs/PhiFlow/blob/develop/docs/Staggered_Grids.ipynb)\n",
+ "\n",
"Staggered grids are a key component of the marker-and-cell (MAC) method \\[Harlow and Welch 1965\\].\n",
"They sample the velocity components not at the cell centers but in staggered form at the corresponding face centers.\n",
"Their main advantage is that the divergence of a cell can be computed exactly.\n",
"execution_count": null,
"outputs": [],
"source": [
+ "# !pip install --quiet phiflow==2.0.0rc2\n",
"from phi.flow import *\n",
"\n",
"grid = StaggeredGrid(0, extrapolation.BOUNDARY, x=10, y=10)\n",
{
"cell_type": "markdown",
"source": [
- "Here, each component of the values tensor has one more sample point in the direction it is facing, because.\n",
+ "Here, each component of the values tensor has one more sample point in the direction it is facing.\n",
"If the extrapolation was `extrapolation.ZERO`, it would be one less (see above image)."
],
"metadata": {
"\n",
"The [`StaggeredGrid` constructor](phi/field/#phi.field.StaggeredGrid) supports two modes:\n",
"\n",
- "* **Direct construction** `StaggeredGrid(Tensor, extrapolation, bounds)`.\n",
+ "* **Direct construction** `StaggeredGrid(values: Tensor, extrapolation, bounds)`.\n",
" All required fields are passed as arguments and stored as-is.\n",
" The `values` tensor must have the correct shape considering the extrapolation.\n",
- "* Construction by resampling `StaggeredGrid(Any, extrapolation, bounds, resolution, **resolution)`.\n",
+ "* **Construction by resampling** `StaggeredGrid(values: Any, extrapolation, bounds, resolution, **resolution)`.\n",
" When specifying the resolution as a `Shape` or via keyword arguments, non-Tensor values can be passed for `values`,\n",
- " such as geometries, other fields, constants or functions (see the [documentation]((phi/field/#phi.field.StaggeredGrid))).\n",
+ " such as geometries, other fields, constants or functions (see the [documentation](phi/field/#phi.field.StaggeredGrid)).\n",
"\n",
"\n",
"Examples:"
{
"cell_type": "markdown",
"source": [
- "Fields can also be sliced using [`unstack`](phi/field/#phi.field.unstack).\n",
+ "Fields can also be sliced using [`unstack()`](phi/field/#phi.field.unstack).\n",
"This returns a `tuple` of all slices along a dimension."
],
"metadata": {
