numerics 0.1.0
Loading...
Searching...
No Matches
Field Examples

Field types provide grid storage for PDE and vector-calculus examples.

Scalar Field

num::Grid3D grid{64, 64, 64, 1.0 / 63.0};
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

num::FieldSolver::solve_poisson(phi, rho, 1e-8, 1000);
static SolverResult solve_poisson(ScalarField3D &phi, const ScalarField3D &source, double tol=1e-6, int max_iter=500)
Solve with zero Dirichlet boundaries.
Definition fields.cpp:82

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)
Definition fields.cpp:224

This computes vector potential components from Poisson solves and returns \(\mathbf{B}=\nabla\times\mathbf{A}\).