r3.gwflow(1grass)
β¨ NAME β¨
okay so bestie, welcome to r3.gwflow β this is the numerical calculation program for transient, confined groundwater flow in three dimensions. it lives in the GRASS User's Manual and yes it's giving very serious hydrology scientist energy π§π
π KEYWORDS π
raster3d, groundwater flow, voxel, hydrology
π SYNOPSIS π
r3.gwflow
r3.gwflow --help
r3.gwflow [-mf] phead=name status=name hc_x=name hc_y=name hc_z=name
[sink=name] yield=name [recharge=name] output=name [velocity_x=name]
[velocity_y=name] [velocity_z=name] [budget=name] dtime=float
[maxit=integer] [error=float] [solver=name] [--overwrite]
[--help] [--verbose] [--quiet] [--ui]
π«Ά Flags
-mβ use 3D raster mask (if it exists, that is) π-fβ use a full filled quadratic linear equation system. default is a sparse linear equation system, so this is you choosing the chunky option β¨--overwriteβ allow output files to overwrite existing files (aka permission to be a lil destructive, on purpose) π--helpβ print usage summary--verboseβ verbose module output (it will talk. a lot.)--quietβ quiet module output (the silent treatment)--uiβ force launching GUI dialog
π Parameters
phead=name[required] β input 3D raster map with initial piezometric heads in [m]status=name[required] β input 3D raster map providing the status for each cell, = 0 - inactive, 1 - active, 2 - dirichlethc_x=name[required] β input 3D raster map with the x-part of the hydraulic conductivity tensor in [m/s]hc_y=name[required] β input 3D raster map with the y-part of the hydraulic conductivity tensor in [m/s]hc_z=name[required] β input 3D raster map with the z-part of the hydraulic conductivity tensor in [m/s]sink=nameβ input 3D raster map with sources and sinks in [m^3/s]yield=name[required] β specific yield [1/m] input 3D raster maprecharge=nameβ recharge input 3D raster map in m^3/soutput=name[required] β output 3D raster map storing the piezometric head result of the numerical calculationvelocity_x=nameβ output 3D raster map storing the groundwater filter velocity vector part in x direction [m/s]velocity_y=nameβ output 3D raster map storing the groundwater filter velocity vector part in y direction [m/s]velocity_z=nameβ output 3D raster map storing the groundwater filter velocity vector part in z direction [m/s]budget=nameβ output 3D raster map storing the groundwater budget for each cell [m^3/s]dtime=float[required] β the calculation time in seconds. Default:86400maxit=integerβ maximum number of iteration used to solve the linear equation system. Default:10000error=floatβ error break criteria for iterative solver. Default:0.000001solver=nameβ the type of solver which should solve the symmetric linear equation system. Options:cg,pcg,cholesky. Default:cg
π« DESCRIPTION π«
so this numerical module calculates implicit transient and steady state, confined groundwater flow in three dimensions, based on volume maps and the current 3D region settings. all initial- and boundary-conditions have to be handed over as volume maps. and the unit of the current coordinate reference system? it must be meters. no vibes-based units, bestie, meters only π
this module is sensitive to mask settings β literally. every cell that's outside the mask gets ignored and treated as a no flow boundary ππ«
the module calculates the piezometric head and optionally the water balance for each cell, plus the groundwater velocity field in 3 dimensions. you can visualize those vector components with ParaView if you export them using r3.out.vtk. iconic combo fr fr β¨
and heads up: the groundwater flow will always be calculated transient. so if you want steady state computation, you either set the timestep to a large number (billions of seconds, yes really) or set the specific yield raster map to zero π°οΈ
π NOTES π
the groundwater flow calculation is based on Darcy's law and a numerical implicit finite volume discretization. that discretization results in a symmetric and positive definite linear equation system in the form of Ax = b, which must be solved. the groundwater flow partial differential equation goes like this:
(dh/dt)*S = div (K grad h) + q
in detail for 3 dimensions:
(dh/dt)*S = Kxx * (d^2h/dx^2) + Kyy * (d^2h/dy^2) + Kzz * (d^2h/dz^2) +
q
h-- the piezometric head im meters [m]dt-- the time step for transient calculation in seconds [s]S-- the specific yield [1/m]b-- the bottom surface of the aquifer meters [m]Kxx-- the hydraulic conductivity tensor part in x direction in meter per second [m/s]Kyy-- the hydraulic conductivity tensor part in y direction in meter per seconds [m/s]Kzz-- the hydraulic conductivity tensor part in z direction in meter per seconds [m/s]q- inner source/sinc in [1/s]
π§ Boundary conditions
two different boundary conditions are implemented, the Dirichlet and Neumann conditions. by default the calculation area is surrounded by homogeneous Neumann boundary conditions. you can set the calculation and boundary status of single cells with the status map, and these are the cell states it supports:
0 == inactive- the cell with status 0 will not be calculated, active cells will have a no flow boundary to an inactive cell1 == active- this cell is used for groundwater calculation, inner sources can be defined for those cells2 == Dirichlet- cells of this type will have a fixed piezometric head value which do not change over time
not me warning you about memory: note that all required raster maps are read into main memory. additionally the linear equation system will be allocated, so the memory consumption of this module rapidely grow with the size of the input maps. she EATS ram π
π₯ Solvers
the resulting linear equation system Ax = b can be solved with several solvers. an iterative solvers with sparse and quadratic matrices support is implemented. that means the conjugate gradients method with (pcg) and without (cg) precondition. additionally a direct Cholesky solver is available. this direct solver only work with normal quadratic matrices, so be careful using them with large maps (maps of size 10.000 cells will need more than one Gigabyte of RAM π). the user should always prefer to use a sparse matrix solver. periodt.
πΈ EXAMPLE 1 πΈ
this small script creates a working groundwater flow area and data. it cannot be run in a lat/lon project, so check your projection bestie πΊοΈ
# set the region accordingly
g.region res=25 res3=25 t=100 b=0 n=1000 s=0 w=0 e=1000 -p3
#now create the input raster maps for a confined aquifer
r3.mapcalc expression="phead = if(row() == 1 && depth() == 4, 50, 40)"
r3.mapcalc expression="status = if(row() == 1 && depth() == 4, 2, 1)"
r3.mapcalc expression="well = if(row() == 20 && col() == 20 && depth() == 2, -0.25, 0)"
r3.mapcalc expression="hydcond = 0.00025"
r3.mapcalc expression="syield = 0.0001"
r.mapcalc expression="recharge = 0.0"
r3.gwflow solver=cg phead=phead statuyield=status hc_x=hydcond hc_y=hydcond \
hc_z=hydcond sink=well yield=syield r=recharge output=gwresult dt=8640000 vx=vx vy=vy vz=vz budget=budget
# The data can be visualized with ParaView when exported with r3.out.vtk
r3.out.vtk -p in=gwresult,status,budget vector=vx,vy,vz out=/tmp/gwdata3d.vtk
#now load the data into ParaView
paraview --data=/tmp/gwdata3d.vtk
π¦ EXAMPLE 2 π¦
this one creates a nice 3D model with geological layer with different hydraulic conductivities. make sure you're not in a lat/lon projection, for real this time.
# set the region accordingly
g.region res=15 res3=15 t=500 b=0 n=1000 s=0 w=0 e=1000
#now create the input raster maps for a confined aquifer
r3.mapcalc expression="phead = if(col() == 1 && depth() == 33, 50, 40)"
r3.mapcalc expression="status = if(col() == 1 && depth() == 33, 2, 1)"
r3.mapcalc expression="well = if(row() == 20 && col() == 20 && depth() == 3, -0.25, 0)"
r3.mapcalc expression="well = if(row() == 50 && col() == 50 && depth() == 3, -0.25, well)"
r3.mapcalc expression="hydcond = 0.0025"
r3.mapcalc expression="hydcond = if(depth() < 30 && depth() > 23 && col() < 60, 0.000025, hydcond)"
r3.mapcalc expression="hydcond = if(depth() < 20 && depth() > 13 && col() > 7, 0.000025, hydcond)"
r3.mapcalc expression="hydcond = if(depth() < 10 && depth() > 7 && col() < 60, 0.000025, hydcond)"
r3.mapcalc expression="syield = 0.0001"
r3.gwflow solver=cg phead=phead statuyield=status hc_x=hydcond hc_y=hydcond \
hc_z=hydcond sink=well yield=syield output=gwresult dt=8640000 vx=vx vy=vy vz=vz budget=budget
# The data can be visualized with paraview when exported with r3.out.vtk
r3.out.vtk -p in=gwresult,status,budget,hydcond,well vector=vx,vy,vz out=/tmp/gwdata3d.vtk
#now load the data into paraview
paraview --data=/tmp/gwdata3d.vtk
π SEE ALSO π
r.gwflow, r.solute.transport, r3.out.vtk
π AUTHOR π
SΓΆren Gebbert
this work is based on the Diploma Thesis of SΓΆren Gebbert, available here at Technical University Berlin, Germany π
β SOURCE CODE β
Available at: r3.gwflow source code (history)
Latest change: Monday Aug 25 05:52:25 2025 in commit: 8cc8db20996eb7558d53dc0ca50e942aa4902af6
Main index | 3D raster index | Topics index | Keywords index | Graphical index | Full index
and that's the whole page bestie π«Ά it's the GRASS 8.5.0 Reference Manual, Β© 2003-2026 GRASS Development Team, with the latest change landing Monday Aug 25 05:52:25 2025 β r3.gwflow(1grass), GRASS 8.5.0, that's a wrap π
β¨
π¦ where this page comes from
- alpine 3.24: grass-gis-doc 8.5.0-r1 Β· GPL-2.0-or-later
- ubuntu stonking: grass-doc 8.5.0-1ubuntu1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms