|
numerics 0.1.0
|
include/pde/fields.hpp and src/pde/fields.cpp provide general-purpose 3D scalar and vector field types together with PDE field solvers for Poisson, gradient, divergence, and curl. The old path include/spatial/fields.hpp is a forwarding shim and continues to work.
These classes previously lived in apps/em_demo/field.hpp/cpp as physics:: types. Moving them into num:: makes them available to any 3D app without copy-pasting.
Wraps a num::Grid3D with a world-space origin (ox, oy, oz). sample() converts world coordinates to grid coordinates and performs trilinear interpolation across the 8 surrounding nodes.
Three co-located components. sample() returns {x.sample(p), y.sample(p), z.sample(p)} via trilinear interpolation.
Static PDE utilities. All methods operate on ScalarField3D / VectorField3D in-place or return new field objects.
solve_poisson internally calls num::neg_laplacian_3d (see Stencil Higher-Order Functions) and num::cg_matfree. The SPD operator (-Lap) with identity rows on the boundary means the Dirichlet system is SPD -> CG converges.
solve_magnetic_field runs three independent solve_poisson calls (one per component of A) then applies curl.
| Type / Method | App | Purpose |
|---|---|---|
ScalarField3D, VectorField3D | EM demo | Potential phi, conductivity sigma, E and B fields |
FieldSolver::solve_poisson | EM demo | Lapphi = rho for electrostatic potential |
FieldSolver::gradient | EM demo | E = -gradphi, J component from gradient |
FieldSolver::curl | EM demo | B = gradxA |
MagneticSolver::current_density | EM demo | J = -sigmagradphi |
MagneticSolver::solve_magnetic_field | EM demo | Vector Poisson + curl for B |
The EM-specific ElectricSolver (variable-conductivity div(sigmagradphi)=0 with electrode BCs and Joule heating) remains in apps/em_demo/field.hpp.