Skip to content

Extending the kinetic mesh beyond the BOUT++ plasma domain - #44

Open
mrhardman wants to merge 45 commits into
VANTAGE-Reactions-Coupling/devfrom
VANTAGE-Reactions-Coupling/dmplex-features
Open

mrhardman wants to merge 45 commits into
VANTAGE-Reactions-Coupling/devfrom
VANTAGE-Reactions-Coupling/dmplex-features

Conversation

@mrhardman

@mrhardman mrhardman commented Sep 17, 2026

Copy link
Copy Markdown

Purpose

This PR enables the Vantage component to use a mesh for kinetic particles which extends beyond the BOUT++ plasma simulation domain.

Changes

When writing this PR, we assume that the kinetic mesh is provided in a GMSH .msh format (see https://gmsh.info/). The mesh is assumed to be triangular with the region overlapping with the BOUT++ mesh constructed by bisection of the quadrilaterals implied by the Rxy, Zxy corners of the BOUT++ grid cells. The remainder of the mesh is arbitrary, and can extend to a wall boundary. It is assumed that the user is able to provide a list of integers map_RZ_to_itriangle_0, map_RZ_to_itriangle_1, which define for each (x,y) in the BOUT++ Mesh object the global triangular cell definitions for the triangles at that (x,y), consistent with the triangles defined in the GMSH .msh file.

This PR also refactors the Vantage component to introduce source files that contain the VantageSourceManager class, a class VantageDataTransfer for moving data from Field2D and NESO-particles particle groups and std::vector storage formats, and a class VantageDiagnosticsManager for handling BOUT++ and NESO-Particles kinetic diagnostics. The plasma data seen by the particles is only constant within the BOUT++ plasma simulation domain, and is zero outside of the plasma data. Plasma data is specified through Field2D variables, which should enable coupling to the Hermes-3 state. Plasma properties of particles are updated after particle pushing. Reactions are only applied to particles or markers with non-zero electron density (as a proxy for whether or not the particle is within the plasma domain).

The diagnostics now write the moments of the neutral particle distribution in VTKHDF file format, with a new file for each internal time iteration of the Vantage component. The sources Siz and Srec are also written in the VTKHDF diagnostics. The VTKHDF diagnostic covers the entire kinetic mesh. The pre-existing diagnostics are also supported, writing source data on the BOUT++ grid.

The particle-pusher integrated test is updated to use VTKHDF data for the neutral particles, and BOUT++ .nc data for the sources and the saved "ion_density" written by the Vantage component. The Vantage component makes an internal mass conservation test by default.

Validation

The pre-existing tests verify that the existing quadrilateral DMPlex mesh features remain supported. Local tests were performed with valid .msh and .nc grid files to test the features here. Automatic tests will follow.

AI Assistance

Non-agentic AI was consulted in writing and debugging this work.

Documentation

Documentation has not been updated.

###To do

  • Automatic test of the extended kinetic mesh
  • Correct mesh area factor when creating the mesh_coupler_dg0 object for meshes with non-rectangular quadrilateral cells, see

    hermes-3/src/vantage.cxx

    Lines 639 to 645 in 8921151

    // n.b. forward and backward weights may be incorrect for non-rectangular BOUT++ cells
    // lower triangle
    coupler_map.at(static_cast<size_t>(icell)).push_back(
    {kinetic_mesh_map.at(static_cast<size_t>(map_RZ_to_itriangle_0(ix,iy))), 1.0, 0.5});
    // upper triangle
    coupler_map.at(static_cast<size_t>(icell)).push_back(
    {kinetic_mesh_map.at(static_cast<size_t>(map_RZ_to_itriangle_1(ix,iy))), 1.0, 0.5});
    implemented by 6962119
  • Upgrade check of cell centres to support triangular mesh option.

…tored in the BOUT.dmp.*.nc files to plot the particle positions in SI units, following the change to normalised units in the vantage component. Optional argument to plot equal scale length axes in the animated figure. Set an explicit `dpi` in the `ani.save()` command.
…hen distribute this over MPI ranks. Tested only in serial. Prototype code for MPI map information for DG0 object is left in place.
… to determine how dg0 is created (in a later commit).
…ch of code to make the `mesh_coupler_dg0` variable.
…h()` and `create_dmplex_from_GMSH_msh()` are separate functions for initialising the DMPlex. For now, always use the `project_eval_dg0` object for projection and evaluation.
…egrees of freedom to BOUT++ Field2D data when the kinetic mesh has a different number of degrees of freedom to the BOUT++ grid. This commit does not update the VantageSourceManager.
…emperature are inputs. The initial condition is a uniform Maxwellian across the entire kinetic domain. Propagate the temperature to the standard deviation of the distrubtion of marker particles for the initial condition and for the recombination markers.
…e.0.nc` output file can be used as a valid grid file when produced by a hermes-3 simulation running in serial.
…tion in parallel. Rename `source_data` variable to `source_data_plasma_grid`.
…mesh covers a larger physical volume than the plasma grid. Plasma quantities (set from inputs) are temporarily extended to the kinetic mesh. Diagnostics are written at every timestep, and the mass conservation check in `tests/integrated/particle-pusher/runtest` now uses data from the `VTKHDF` file.
… Field2D, std::vector and particle groups. Correct bug in ASSERT1() in vantage_sources.cxx.
…grid, and to transfer this data first to the kinetic mesh and then to the particle group with functions from the VantageDataTransfer class. Test `vantage-iz-rec-balance` fails with NaN but `bout_particle_push` and `dmplex-vertex-coordinates` pass. Further work is required to add `ASSERT1()` or similar checks to ensure that the data operated on by VantageDataTransfer, VantageDiagnosticsManager, etc, are correct when variables are passed in two different ways. Alternatively, it may be appropriate to make a redesign of these classes to ensure there is a single source of truth for particle groups, `bout_mesh`, `neso_mesh` and other data.
… data transfer functions to act on multiple particle groups for the same mesh.
…re only applied when the electron density is greater then the `electron_density_reaction_threshold` input parameter. Set the marker group plasma properties with the `update_particle_properties_from_plasma()` function. Set the standard deviation of the velocity distribution for the markers from the plasma temperature.
…c mesh and plasma grid diagnostics, through a for loop indexing over the existing sources in the source manager object. Only scalar source variables are presently supported. Any new scalar sources are automatically diagnosed.
… Field2D for the ion_density. Fails mass conservation test for the cases where the kinetic mesh extends beyond the BOUT++ mesh boundary.
…h cell volumes, transferred from the kinetic mesh to plasma grid using unit weights so that the areas of triangles in the kinetic mesh are added to make the area of the quad in the BOUT++ mesh.
… this field in the `particle-pusher/runtest` to diagnose mass conservation.
@mrhardman mrhardman self-assigned this Sep 17, 2026
@mrhardman mrhardman added the enhancement New feature or request label Sep 17, 2026
…lative area of the two kinetic mesh triangles which subdivide the plasma quadrilateral cell.
…c input grid file for a test of the extended kinetic mesh implementation in a slab case. The test uses the the `tests/integrated/particle-pusher` test code to run the same advection, ionisation and recombination tests on the extended, triangular, kinetic mesh as on the existing quad mesh that aligns with the BOUT++ grid. This verifies mass conservation in the new kinetic mesh implementation.
…igned with a BOUT++ grid. Achieves a speedup in the test runtime.
@mrhardman
mrhardman marked this pull request as ready for review September 22, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant