# Velocity gradients in /navstokes/kernels/flux.mako

**URL:** <https://pyfr.discourse.group/t/velocity-gradients-in-navstokes-kernels-flux-mako/203>\
**Category:** General\
**Created:** [27 March 2018 19:50 UTC](https://pyfr.discourse.group/t/velocity-gradients-in-navstokes-kernels-flux-mako/203 "2018-03-27T19:50:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![turbvs](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@turbvs](https://pyfr.discourse.group/u/turbvs)\
**Post date:** [27 March 2018 19:50 UTC](https://pyfr.discourse.group/t/velocity-gradients-in-navstokes-kernels-flux-mako/203/1 "2018-03-27T19:50:49Z")

</div>

Hi all,

I’m new to the high-order CFD world. I just have started playing around with PyFR and was hoping to implement Smagorinsky SGS model in the code.  
This model requires velocity gradients which I think are being calculated in flux calculation of navstokes solver (pyfr/solvers/navstokes/kernels/flux.mako) (??).  
May be I can directly calculate mu\_sgs using the vel. gradients here and add it to mu\_c.

My question is: Are these gradients being calculated in the physical space or the standard element space (transformed space)? If the answer is latter, then  
can someone please suggest how to transform these gradients into the physical space in order to be able to use them in the SGS model?

Regards,  
Vishal

---

<div class="post-metadata">

**Author:** ![Kiny\_Wan](https://avatars.discourse-cdn.com/v4/letter/k/c57346/32.png) [@Kiny\_Wan](https://pyfr.discourse.group/u/Kiny_Wan)\
**Post date:** [14 November 2019 12:11 UTC](https://pyfr.discourse.group/t/velocity-gradients-in-navstokes-kernels-flux-mako/203/2 "2019-11-14T12:11:11Z")

</div>

Hi Vishal,  
I found the gradient of velocity in fluidforce.py, expressed as

`

# Gradient of velocity

`  
gradu = (gradrhou - gradrho[:, None]\*u[None, 1:-1]/rho) / rho

Is this form right? I think that the “rho” should be deleted as

`gradu = (gradrhou - gradrho[:, None]*u[None, 1:-1]) / rho`

Yours  
Kiny

---

<div class="post-metadata">

**Author:** ![fdw](https://avatars.discourse-cdn.com/v4/letter/f/a587f6/32.png) [@fdw](https://pyfr.discourse.group/u/fdw)\
**Post date:** [14 November 2019 12:31 UTC](https://pyfr.discourse.group/t/velocity-gradients-in-navstokes-kernels-flux-mako/203/3 "2019-11-14T12:31:07Z")

</div>

Hi Kiny,  
In 3D:

u[None, 1:-1] = [rho_u, rho_v, rho\*w] (the momenta)

and thus we divide through by rho here to get the actual velocities  
which are required as per the chain rule.

Regards, Freddie.

---

<div class="post-metadata">

**Author:** ![Kiny\_Wan](https://avatars.discourse-cdn.com/v4/letter/k/c57346/32.png) [@Kiny\_Wan](https://pyfr.discourse.group/u/Kiny_Wan)\
**Post date:** [14 November 2019 13:39 UTC](https://pyfr.discourse.group/t/velocity-gradients-in-navstokes-kernels-flux-mako/203/4 "2019-11-14T13:39:13Z")

</div>

Hi Freddie,  
Thank you. I misunderstood u as [u, v, w].

Regards,

Kiny
