[WIP] Implement 3D mass matrices for the implicit solver (direct deposition only) - #7181
Open
RemiLehe wants to merge 2 commits into
Open
[WIP] Implement 3D mass matrices for the implicit solver (direct deposition only)#7181RemiLehe wants to merge 2 commits into
RemiLehe wants to merge 2 commits into
Conversation
…ition) The full mass-matrix machinery used by the particle-suppressed JFNK implicit solver (implicit_evolve.use_mass_matrices_jacobian) was only implemented in 1D and 2D. This adds the 3D implementation for direct deposition, following the 1D/2D style: - MassMatricesDeposition.H: fill in the full_mass_matrices branch of the 3D direct deposition kernel, with the same component-index convention as ApplyMassMatrices (dir-0 fastest, per-pair staggering shifts) and the symmetry-reduced deposit of the diagonal blocks (dx+dy+dz <= 1). - ImplicitSolver.cpp: add the 3D symmetry fold in FinishMassMatrices (copy components with dx+dy+dz >= 2 from their point-symmetric mirrors); add the missing dir-2 loop in SyncMassMatricesPCAndApplyBCs; allow mass_matrices_pc_width in 3D; replace the blanket 3D assert by one requiring direct deposition (the Villasenor 3D mass-matrix kernel is left as follow-up work and now aborts with a clear message). - ThetaImplicitEM.cpp: fix an operator-precedence bug in the 3D curl2_BC_mask setup (field_dir + 1 % AMREX_SPACEDIM). - MatrixPC.H: fix a wrong comment on the component-index mapping. Add CI test test_3d_theta_implicit_jfnk_vandb: a 3D periodic uniform plasma (16^3 cells, 2x2x2 ppc, 10 steps, ~25 s on 2 CI ranks) using the theta-implicit solver with the mass-matrices Jacobian and the curl-curl MLMG preconditioner with mass-matrices response. The analysis checks energy conservation (~2e-15) and Newton/GMRES iteration counts, both sensitive to mass-matrix indexing errors. The mass-matrix-Jacobian solution was verified to agree with the matrix-free (particle-based) Jacobian solution to <= 6e-13 on all fields. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Factor the parameters shared by the 2D and 3D theta-implicit JFNK vandb tests into inputs_base_vandb, included from the test input files via the FILE mechanism, as done in other tests. The 2D test is unchanged (its warpx_used_inputs dump is identical); the 3D test only changes the location of its reduced diagnostics files to the default paths. Merge analysis_vandb_jfnk_2d.py and analysis_vandb_jfnk_3d.py into a single analysis_vandb_jfnk.py, which reads the dimensionality and the relevant algorithm options from warpx_used_inputs: the charge conservation check runs for the charge-conserving Villasenor deposition, and the Newton/GMRES iteration checks run when the mass matrices are used for the Jacobian. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The full mass-matrix machinery used by the particle-suppressed JFNK solver (
implicit_evolve.use_mass_matrices_jacobian) was implemented in 1D and 2D, but not in 3D.This PR adds the 3D implementation for direct deposition, following the 1D/2D style.
Changes
MassMatricesDeposition.H: implement thefull_mass_matricesbranch of the 3D direct deposition kernel, using the same component-index convention asApplyMassMatricesand the symmetry-reduced deposit of the diagonal blocks (only offsets withdx+dy+dz <= 1).ImplicitSolver.cpp:FinishMassMatrices, which copies the remaining diagonal-block components from their point-symmetric mirrors;SyncMassMatricesPCAndApplyBCsand allowimplicit_evolve.mass_matrices_pc_widthin 3D;ThetaImplicitEM.cpp: fix an operator-precedence bug in the 3Dcurl2_BC_masksetup (field_dir + 1 % AMREX_SPACEDIMevaluated tofield_dir + 1).MatrixPC.H: fix a wrong comment on the component-index mapping.New CI test
test_3d_theta_implicit_jfnk_vandb: a 3D periodic uniform plasma (16^3 cells, 2x2x2 particlesper cell, 2 species, 10 steps), extending the existing 2D Villasenor and Buneman test. It uses the
theta-implicit solver with the mass-matrices Jacobian and the curl-curl MLMG preconditioner with
mass-matrices response, so it needs no PETSc. It runs in about 25 s on 2 ranks. The analysis
checks energy conservation and the Newton and GMRES iteration counts, all of which are sensitive
to mass-matrix indexing errors.
The parameters shared by the 2D and 3D vandb tests are factored into
inputs_base_vandb(included via the
FILEmechanism), and the 2D and 3D analysis scripts are merged into a singleanalysis_vandb_jfnk.pythat reads the dimensionality and algorithm options fromwarpx_used_inputs. The 2D test is unchanged (identicalwarpx_used_inputsdump).Validation
🤖 Generated with Claude Code