Gradients without writing to disk

Is there a way to access the gradients of a PyFR simulation from within Python, similar to integ.soln, without the need to write the solution file to disk and using pyfr export -g?

I intend to run a large number of simulations and compute some quantities based on the vorticity, which is slowed down substantially by the need to write to disk first when using the export approach.

UPDATE : I now found integ.grad_soln, but some other posts in the forum seem to imply that these gradients might actually not be the physical gradients, but rather the gradients w.r.t. the canonical coordinates in each element.

I looked at the time-averaging plugin, and the implementation of that plugin seems to rely on the following line: self.elementscls.grad_con_to_pri(soln, grad_soln, self.cfg)

If I try to call this function, in the following fashion: integ.system.elementscls.grad_con_to_pri(integ.soln[k], integ.grad_soln[k], integ.cfg), I get identical values to simply calling integ.grad_soln[k]. Iā€™m assuming that Iā€™m misusing this somehow?

The specifics here depend on what solver you are using.

For the incompressible solver the conservative variables are equal to the primitive variables and so no further processing is required. This is handled by grad_con_to_pri being a no-op. For the compressible solver it is necessary to employ the chain rule to convert the conserved gradients to primitive gradients.

Regards, Freddie.

1 Like