52 return static_cast<float>(grid_.
dx());
64 void set(
int i,
int j,
int k,
double v) {
65 grid_.
set(i, j, k, v);
72 void fill(F&& f) { grid_.
fill(std::forward<F>(f)); }
77 float ox = 0.0f,
float oy = 0.0f,
float oz = 0.0f)
82 float sample(
float x,
float y,
float z)
const;
103 std::array<float, 3>
sample(
float px,
float py,
float pz)
const;
136 const std::vector<DirichletBC>& bcs,
156 static constexpr double MU0 = 1.2566370614e-6;
static VectorField3D gradient(const ScalarField3D &phi)
static SolverResult solve_var_poisson(ScalarField3D &phi, const ScalarField3D &coeff, const std::vector< DirichletBC > &bcs, double tol=1e-6, int max_iter=500)
static SolverResult solve_poisson(ScalarField3D &phi, const ScalarField3D &source, double tol=1e-6, int max_iter=500)
static VectorField3D curl(const VectorField3D &A)
static ScalarField3D divergence(const VectorField3D &f)
Compute div(f) via central finite differences.
void set(int i, int j, int k, real v)
static VectorField3D solve_magnetic_field(const VectorField3D &J, double tol=1e-6, int max_iter=500)
static VectorField3D current_density(const ScalarField3D &sigma, const ScalarField3D &phi)
Compute current density J = -sigma*grad(phi) [A/m^2].
static constexpr double MU0
mu_0 [H/m]
void set(int i, int j, int k, double v)
void fill(F &&f)
Fill every cell with f(i, j, k).
ScalarField3D(int nx, int ny, int nz, float dx, F &&f, float ox=0.0f, float oy=0.0f, float oz=0.0f)
Construct and fill from callable f(i, j, k) -> double.
float sample(float x, float y, float z) const
const Grid3D & grid() const
3D Cartesian scalar grid backed by num::Vector storage.
constexpr real phi
Golden ratio.
Umbrella include for all linear solvers.
Dirichlet boundary condition: fix phi = value at grid node flat_idx.
int flat_idx
k*ny*nx + j*nx + i
std::array< float, 3 > sample(float px, float py, float pz) const
Trilinear-interpolated field vector at world position.
ScalarField3D z
x, y, z components on the same grid layout
void scale(float s)
Multiply all components by scalar s.