Add fdot_abs_integrated_moms diagnostic - #1098
Open
Maxwell-Rosen wants to merge 7 commits into
Open
Conversation
- Implement gkyl_array_reduce_range_sum_abs for CPU. - Implement gkyl_array_reduce_range_sum_abs_cu for CUDA. - Update tests to include absolute value reduction cases. - Modify gk_species to use absolute value reduction for diagnostics.
…g related structures
Antoinehoff
reviewed
Aug 27, 2026
| long start = gkyl_range_idx(range, iter.idx); | ||
| const double *d = gkyl_array_cfetch(arr, start); | ||
| for (long i=0; i<n; ++i) | ||
| res[i] += fabs(d[i]); |
Collaborator
There was a problem hiding this comment.
I am a bit confused about how
What's the meaning of this quantity? when
Collaborator
Author
There was a problem hiding this comment.
I believe this sums over all the components, which is also what the reduce operation for the regular sum does as well. In your notation, does i represent "cell" and k is the component? It sums over all cells and components here.
Collaborator
There was a problem hiding this comment.
Yeah sorry my question was not clear and I think I misunderstood something. We agree that the start is used to take only the 0th coefficient to sum over the absolute value of the cell average ?
- Updated the time rate diagnostics configuration in various files to support two diagnostic types: - GKYL_GK_TIME_RATE_DIAGNOSTIC_FDOT_INTEGRATED_MOMENTS - GKYL_GK_TIME_RATE_DIAGNOSTIC_FDOT_ABS_INTEGRATED_MOMENTS - Replaced the previous boolean flag for time rate diagnostics with a structured approach that includes the number of diagnostics and their specific types. - This change improves the diagnostic capabilities of the gyrokinetic simulations, allowing for more detailed analysis of the integrated moments over time.
… gyrokinetic species
… a seperate function rather than putting it inside gkyl_array_reduce_range as an option for GKYL_SUM_ABS. The existing implementation is correct, so refactor this to use the gkyl_array_reduce_range method
…add diagnostics that write the moments of fdot and fdot_abs that are computed from Implemented FdotMoments and FdotAbsMoments diagnostics. - Reuses the existing RK-computed moment arrays without recalculation. - Writes P0 configuration-space files named *_fdot_<moment>_<frame>.gkyl and *_fdot_abs_<moment>_<frame>.gkyl. - Added C enums and Lua bindings in gyrokinetic/apps/gkyl_gyrokinetic.h:103 and gyrokinetic/apps/gyrokinetic_lw.c:83. - CPU regression verified absolute values and agreement with both integrated diagnostics. - Library compiled and linked successfully. The final build step only failed when copying shared data outside the writable workspace. Avoid if statements in time loops - Time-loop fdot calculation now uses preselected enabled/no-op function pointers. - Signed, absolute, combined, and disabled writers are selected during initialization. - All new conditionals are limited to initialization/release. - Enabled/disabled regressions and Valgrind passed. - Library compiled and linked; only the sandboxed post-build data copy failed.
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.
Greg and I have been interested in the diagnostic of integral |fdot| dv dz in the mirror simulations. This is helpful for the L2 norm of the change in the distribution function. Here is an example of it being used.
The diagnostic is added to the
time_rate_diagnosticsflag, so it will show both fdot and fdot_abs integrated diagnostics.A new sum abs function was added, with a unit test, as this is necessary for |fdot| to be computed.
I also had GPT sol refactor the fdot diagnostics to take an enum table, specifying which of the fdot diagnostics the user wants. This also provides the fdot, RHS vector directly, which is a phase space array.