Meshes and backend¶
- class geoswe.Mesh2D(nx, ny, dx, dy, x0=0.0, y0=0.0, ngh=4)[source]¶
Bases:
objectUniform 2D cell-centred Cartesian mesh:
nx × nycells of sizedx × dywithnghghost cells on every side.- interior(arr)[source]¶
Strip the ghost layers of a single padded SCALAR field.
Scalar-field-only:
arrmust be 2-D, shape (nx+2*ngh, ny+2*ngh). For a stacked stateqof shape (3, Nx, Ny), apply per component (mesh.interior(q[0])); passing the stack would silently slice the (variable, x) axes instead of (x, y).
- class geoswe.Mesh1D(nx, dx, x0=0.0, ngh=4)[source]¶
Bases:
objectUniform 1D cell-centred mesh:
nxcells of widthdxstarting atx0, withnghghost cells per side.
Backend control¶
These live in geoswe.backend and are re-exported at the top level, which is
how every page and example calls them: geoswe.get_backend().
geoswe.set_backend only takes effect before any solver module has been
imported; see Installation.
- geoswe.set_backend(name)[source]¶
Switch the global backend to ‘numpy’ or ‘cupy’.
Must be called before any solver module is imported:
geoswe.solver(and the CUDA kernels behind it) freeze the backend choice at import time, so a late switch would silently run the wrong code path. Prefer setting theGEOSWE_BACKENDenvironment variable beforeimport geoswe.- Parameters:
name (str)
- geoswe.get_backend()[source]¶
Return
"cupy"when the GPU backend is active, else"numpy".- Return type: