Calculating cell averages in Mako macros

Since PyFR is an unstructured code, there’s not necessarily an ordered structure to elements and adjacency only comes into play through the interfaces which are treated separately from the element interiors. Getting adjacent element information is not simple to do in PyFR. If you want to pass a single solution value per element through interfaces (such as the mean), you can look at how the minimum entropy is passed through the interfaces in this PR:

If you want to do operations on the whole solution across elements, I don’t think you can do this through the kernels. You may have to try it through the plugins which can access/modify the whole solution but it can be very slow.

For the boundaries, like I said, everything PyFR does is through the interfaces, so there are no “ghost elements”, but just a ghost state given as outer value for the boundary interface solution pair used to compute the boundary flux via the Riemann solver (see bccflux.mako and the associated BC kernels).