Discretization¶
PyFVTool discretizes PDE terms into sparse matrix contributions that are assembled
and solved by pyfvtool.solvePDE().
Available terms¶
Transient term¶
\[\alpha \frac{\partial \phi}{\partial t} \approx \alpha \frac{\phi^{n+1} - \phi^n}{\Delta t}\]
pf.transientTerm(c, dt, alpha)
Diffusion term¶
\[\nabla \cdot (\mathcal{D} \nabla \phi)\]
D_face = pf.geometricMean(D_cell)
pf.diffusionTerm(D_face)
Advection term¶
\[\nabla \cdot (\mathbf{u} \phi)\]
pf.convectionTerm(u_face) # central difference
pf.convectionUpwindTerm(u_face) # first-order upwind
pf.convectionTVDTerm(u_face, c, flux_limiter) # TVD scheme
Source terms¶
pf.linearSourceTerm(beta_cell) # β φ
pf.constantSourceTerm(gamma_cell) # γ
Averaging methods¶
Cell-centred values must be interpolated to faces before use in face-based terms:
Function |
Formula |
|---|---|
|
arithmetic average |
|
arithmetic average |
|
geometric average (recommended for diffusivity) |
|
harmonic average |
|
upwind-biased |
Assembling equations¶
Combine terms into a list and pass to solvePDE:
eqn = [pf.transientTerm(c, dt, 1.0),
-pf.diffusionTerm(D_face),
pf.constantSourceTerm(S_cell)]
pf.solvePDE(c, eqn)
The sign convention follows the PDE form: transient + advection + diffusion + source = 0, so diffusion typically appears with a negative sign.