Skip to content
ForCADDocumentation
Browse guide contents ↓

Verify a three-dimensional Poisson solution

Solve Poisson’s equation on the unit cube with zero values on all six faces. The load changes sign across the middle of each coordinate direction, which makes this a useful test of a volume implementation. If you have worked through the surface example, the new ingredient is integration over physical volume.

Run the bundled solver

From the checkout root, run the solver in a compiler shell.

fpm run --example poisson_iga_solver_3d --profile release

The example starts with six controls per direction and inserts knots at and along each axis. The resulting degree-five patch has analysis elements and scalar degrees of freedom before the boundary conditions are imposed.

See inside the cube

Open example/output/vtk/poisson_iga_solver_3d_interp.vtk in a VTK viewer. Select the point scalar u and apply a Contour filter at values -0.006 and 0.006. An isosurface joins positions where the computed field has the same value. The outer faces have prescribed value zero, so the interior contours reveal the sign changes.

Eight interior lobes of the computed Poisson field on the unit cube. Four positive and four negative isosurfaces alternate across the three coordinate directions.

The positive contour (ochre) and negative contour (blue) each occupy four octants. Crossing any midplane reverses the sign. The outline marks the boundary of the unit cube.

For a point check, inspect the exported nodes nearest and . Their values are approximately +0.0084163 and −0.0084163. The export samples 50 positions per direction, so the nearest layers are at and . The companion file example/output/vtk/poisson_iga_solver_3d.vtk contains the spline coefficients on the control net.

Check the error

Write . The load on the cube is the product . The exact field is , since differentiating twice along each axis contributes to the eigenvalue of .

Compare the terminal’s L2 error norm line with this result from the unmodified example at default precision.

L2 error norm                        =  2.4921E-06

The solver computes an absolute norm over the cube. Inside its quadrature loop, T holds the active basis values, Xg is the physical position, and dV includes the integration weight and the volume Jacobian.

call vol%ansatz(ie, ig, T, dT, dV)
Xg = matmul(T, Xc(elem_e,:))
l2_error = l2_error + (dot_product(T, X(elem_e,1)) &
                      - exact_solution(Xg, L, m))**2 * dV

After summing these squared differences over all elements and quadrature points, it takes the square root.

Small differences in the final digits can occur across builds. When comparing runs, check the degree, element count, and working precision first. Changing only the 50 × 50 × 50 visualization grid changes the exported samples independently of this quadrature check. Read the Fortran assembly and error calculation.

For a volume solve with an internal interface, assemble two connected volumes and check the two outward fluxes.