Field types provide grid storage for PDE and vector-calculus examples.
Scalar Field
rho.fill([&](double x, double y, double z) {
return std::exp(-40.0 * ((x - 0.5) * (x - 0.5)
+ (y - 0.5) * (y - 0.5)
+ (z - 0.5) * (z - 0.5)));
});
Vector Field
v.x.fill(0.0);
v.y.fill(0.0);
v.z.fill(1.0);
Poisson Utility
static SolverResult solve_poisson(ScalarField3D &phi, const ScalarField3D &source, double tol=1e-6, int max_iter=500)
Solve with zero Dirichlet boundaries.
Internally this wraps the finite-difference operator with num::operators::make_op and solves with conjugate gradients.
Magnetic Field Utility
load_current_density(J);
static VectorField3D solve_magnetic_field(const VectorField3D &J, double tol=1e-6, int max_iter=500)
This computes vector potential components from Poisson solves and returns \(\mathbf{B}=\nabla\times\mathbf{A}\).