Hi,
I've looked in more detail through the code and there are a few places to look:
(1) SireMM::GridFF2 provides a complete forcefield that uses a grid to calculate the coulomb energy of a molecule. It is one of the early grid classes that are not as well integrated with the new forcefield system. An advantage of this is that it is almost completely self-contained, with the grid potential, code to working with grids, and tri-linear interpolation all included within the class. It is very specific for coulomb energies, so would require a lot of adapting for anything else.
(2) SireMM::CLJGrid is the newer replacement for GridFF2 that integrates grids with the "new" forcefields (those based on SireMM::InterFF and SireMM::IntraFF). CLJGrid is used by InterFF and InterGroupFF to calculate the coulomb energy for fixed atoms via a coulomb grid. It is a more generic class than GridFF2, as the values of the grid points can be populate by any of the SireMM::CLJFunction-derived functions that calculate coulomb and LJ interactions. The grid is described and navigated using the SireVol::GridInfo class.
(3) SireVol::GridInfo is the class that provides metadata and navigation of a regular axis-aligned grid. This provides functions like "pointToArrayndex" that returns the index into an array for the gridpoint that is nearest the passed 3D vector in space, or "pointToGridCorners" that returns the indices of all gridpoints of the box surrounding a 3D vector in space, with, optionally, grid weights that are derived from trilinear weighting. This SireVol::GridInfo class is designed to be used with an array of values to calculate grid energies. For example, in the function "CLJGrid::total", around line 709 in SireMM/cljgrid.cpp, you will see a loop over all of the atoms, for which all atoms will be located within the grid, and grid_info.pointToGridCorners is used to find the indices of surrounding grid points and weights from trilinear interpolation. These are used to work out the potential ("phi") at each atom, which is multiplied by the charge on each atom (q[i]) to be added onto the grid energy.
As a note, this is vectorised explicitly by using SireMaths::MultiFloat, which maps to the vector type for whatever vector scheme (SSE2, AVX, AVX-512) is available on the processor.
I hope this is useful. Please feel free to ask more questions.
Best wishes,
Christopher
p.s. SireVol::RegularGrid is an old class that was used to store grid data for writing out to Gaussian Cube data files (using SireIO::Cube). It hasn't seen much other use in Sire and is not integrated with the SireVol::GridInfo. Work is needed to link this with GridInfo and with CLJGrid etc. so that we can easily write out the grids produced by Sire.