Skip to content

[WIP] Fix FDTD: Bump GetMaxGuardCell to 2#6762

Open
ax3l wants to merge 2 commits intoBLAST-WarpX:developmentfrom
ax3l:fix-GetMaxGuardCell
Open

[WIP] Fix FDTD: Bump GetMaxGuardCell to 2#6762
ax3l wants to merge 2 commits intoBLAST-WarpX:developmentfrom
ax3l:fix-GetMaxGuardCell

Conversation

@ax3l
Copy link
Copy Markdown
Member

@ax3l ax3l commented Apr 10, 2026

Fix #6760

  • validate manually this is not excessive for all staggering options we support
    • probably at least F/G are now a bit excessively padded

@ax3l ax3l added bug Something isn't working bug: affects latest release Bug also exists in latest release version component: parallelization Guard cell exchanges and particle redistribution component: FDTD FDTD solvers labels Apr 10, 2026
This is the only call paht in `OneStep_nosub` not using
`WarpX::sync_nodal_points`.
// outdated.
if (m_safe_guard_cells) {
FillBoundaryB(guard_cells.ng_alloc_EB);
FillBoundaryB(guard_cells.ng_alloc_EB, WarpX::sync_nodal_points);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything else in this function calls with WarpX::sync_nodal_points.

This might address the issue @EZoni saw here that warpx.safe_guard_cells = 1 makes things actually worse rn.

@EZoni
Copy link
Copy Markdown
Member

EZoni commented Apr 10, 2026

I think this results in the "worst-case scenario" I observed in #6666 (comment), with or without warpx.safe_guard_cells, if I'm not mistaken, but I can double check again.

It would be consistent with the fact that we have some tests failing at the analysis stage (not only checksums):

The following tests FAILED:
	140 - test_2d_langmuir_multi_mr_momentum_conserving.analysis (Failed)
	141 - test_2d_langmuir_multi_mr_momentum_conserving.checksum (Failed)
	342 - test_2d_projection_div_cleaner_initial_analytical_field_picmi.checksum (Failed)
Errors while running CTest

The following tests FAILED:
	413 - test_3d_projection_div_cleaner_callback_picmi.run (Failed)
	414 - test_3d_projection_div_cleaner_callback_picmi.checksum (Failed)
	417 - test_3d_projection_div_cleaner_picmi.checksum (Failed)

The following tests FAILED:
	140 - test_rz_particle_boundary_interaction_picmi.analysis (Failed)
	141 - test_rz_particle_boundary_interaction_picmi.checksum (Failed)
	153 - test_rz_projection_div_cleaner.checksum (Failed)

If all of this is confirmed, I think the bug fix might require more tweaking.

@EZoni
Copy link
Copy Markdown
Member

EZoni commented Apr 10, 2026

Here's how I test test_2d_langmuir_multi_mr_momentum_conserving locally:

  • Configure:
cmake -S . -B build -DAMReX_ASSERTIONS=ON -DAMReX_TESTING=ON -DWarpX_TEST_CLEANUP=OFF -DWarpX_TEST_FPETRAP=ON -DWarpX_BACKTRACE_INFO=ON -DWarpX_DIMS="2" -DWarpX_FFT=ON -DWarpX_QED=ON -DWarpX_PYTHON=OFF -DWarpX_PYTHON_IPO=OFF
  • Build:
cmake --build build -j 8
  • Run:
ctest --test-dir build --output-on-failure -R test_2d_langmuir_multi_mr_momentum_conserving

If you have this patch applied locally,

diff --git a/Examples/Tests/langmuir/analysis_2d.py b/Examples/Tests/langmuir/analysis_2d.py
index 42f8dacdf..b5a35aa2b 100755
--- a/Examples/Tests/langmuir/analysis_2d.py
+++ b/Examples/Tests/langmuir/analysis_2d.py
@@ -103,27 +103,20 @@ for field in ["Ex", "Ez"]:
     print("%s: Max error: %.2e" % (field, max_error))
     error_rel = max(error_rel, max_error)
 
-# Plot the last field from the loop (Ez at iteration 40)
-fig, (ax1, ax2) = plt.subplots(1, 2, dpi=100)
-# First plot
-vmin = E_sim.min()
-vmax = E_sim.max()
-cax1 = make_axes_locatable(ax1).append_axes("right", size="5%", pad="5%")
-im1 = ax1.imshow(E_sim, origin="lower", extent=edge, vmin=vmin, vmax=vmax)
-cb1 = fig.colorbar(im1, cax=cax1)
-ax1.set_xlabel(r"$z$")
-ax1.set_ylabel(r"$x$")
-ax1.set_title(r"$E_z$ (sim)")
-# Second plot
-vmin = E_th.min()
-vmax = E_th.max()
-cax2 = make_axes_locatable(ax2).append_axes("right", size="5%", pad="5%")
-im2 = ax2.imshow(E_th, origin="lower", extent=edge, vmin=vmin, vmax=vmax)
-cb2 = fig.colorbar(im2, cax=cax2)
-ax2.set_xlabel(r"$z$")
-ax2.set_ylabel(r"$x$")
-ax2.set_title(r"$E_z$ (theory)")
-# Save figure
+# Plot By from the last iteration
+By_sim = data[("mesh", "By")].to_ndarray()[:, :, 0]
+fig, ax = plt.subplots(1, 1, dpi=100)
+vmax = np.abs(By_sim).max()
+if vmax == 0.0:
+    vmax = 1.0
+cax = make_axes_locatable(ax).append_axes("right", size="5%", pad="5%")
+im = ax.imshow(
+    By_sim, origin="lower", extent=edge, vmin=-vmax, vmax=vmax, cmap="RdBu_r"
+)
+cb = fig.colorbar(im, cax=cax)
+ax.set_xlabel(r"$z$")
+ax.set_ylabel(r"$x$")
+ax.set_title(r"$B_y$ (sim)")
 fig.tight_layout()
 fig.savefig("Langmuir_multi_2d_analysis.png", dpi=200)

you can visualize the y-component of the B field as in the following example:

Langmuir_multi_2d_analysis

The figure is saved automatically in build/bin/test_2d_langmuir_multi_mr_momentum_conserving/.

@RemiLehe RemiLehe changed the title Fix FDTD: Bump GetMaxGuardCell to 2 [WIP] Fix FDTD: Bump GetMaxGuardCell to 2 Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug: affects latest release Bug also exists in latest release version bug Something isn't working component: FDTD FDTD solvers component: parallelization Guard cell exchanges and particle redistribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GetMaxGuardCell() returns 1 instead of 2 for Yee-Like Solvers

2 participants