1"""Unit-verify the cut-cell IBM stencil mathematics."""
15 print(
"Testing Point-Value IBM Polynomials for Quadratic Exactness...")
16 thetas = [0.1, 0.3, 0.5, 0.8]
25 u_ghost = (Nnb + Nc + Nbc) / D
26 if abs(u_ghost - 1.0) > 1e-12:
27 print(f
" FAIL Constant (xi={xi}): u_ghost={u_ghost}")
36 u_ghost_target = (-1.0 + xi)**2
38 u_ghost_calc = (Nnb * u_nb + Nc * u_c + Nbc * 0.0) / D
39 if abs(u_ghost_calc - u_ghost_target) > 1e-12:
40 print(f
" FAIL Quadratic (xi={xi}): calc={u_ghost_calc}, target={u_ghost_target}")
42 print(f
" PASS xi={xi}")
45 print(
"\nTesting Cell-Average IBM Polynomials for Quadratic Exactness...")
48 thetas = [0.1, 0.3, 0.5, 0.8]
61 u_c = 1.0/12.0 + xi**2
62 u_nb = 1.0/12.0 + (1.0 + xi)**2
63 u_ghost_target = 1.0/12.0 + (xi - 1.0)**2
65 u_ghost_calc = (Nnb * u_nb + Nc * u_c + Nbc * 0.0) / D
66 if abs(u_ghost_calc - u_ghost_target) > 1e-12:
67 print(f
" FAIL Quadratic (xi={xi}): calc={u_ghost_calc}, target={u_ghost_target}")
69 print(f
" PASS xi={xi}")
82 print(
"\nTesting Sandwiched Point-Value Polynomials...")
83 xis = [(0.5, 0.5), (0.2, 0.8), (0.1, 0.4)]
95 u_ghost_target = (1.0 + xm) * (xp - 1.0)
98 u_ghost_calc = (Nc * u_c) / D
99 if abs(u_ghost_calc - u_ghost_target) > 1e-12:
100 print(f
" FAIL (xm={xm}, xp={xp}): calc={u_ghost_calc}, target={u_ghost_target}")
102 print(f
" PASS xm={xm}, xp={xp}")
105 print(
"\nTesting Sandwiched Cell-Average Polynomials...")
106 xis = [(0.5, 0.5), (0.2, 0.8), (0.1, 0.4)]
114 u_c = xm * xp - 1.0/12.0
115 u_ghost_target = (1.0 + xm) * (xp - 1.0) - 1.0/12.0
117 u_ghost_calc = (Nc * u_c) / D
118 if abs(u_ghost_calc - u_ghost_target) > 1e-12:
119 print(f
" FAIL (xm={xm}, xp={xp}): calc={u_ghost_calc}, target={u_ghost_target}")
121 print(f
" PASS xm={xm}, xp={xp}")
123if __name__ ==
"__main__":
test_sandwich_point_value()
test_point_value_exactness()
test_sandwich_cell_average()
poly_Nbc_pp_sw_avg(xm, xp)
poly_Nbc_pp_sw_pt(xm, xp)
poly_Nbc_mp_sw_avg(xm, xp)
poly_Nbc_mp_sw_pt(xm, xp)
test_cell_average_exactness()