CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   decay 2d turbulence - the initial field (https://www.cfd-online.com/Forums/main/113739-decay-2d-turbulence-initial-field.html)

anzillo October 18, 2013 10:53

Thank you !
I will try to run it :)

anzillo October 24, 2013 05:50

Hello Reza

I had another question regarding the 3D field generated with Rogallo's code and would be very thankful if you could help me.

The spectrum of the velocity field that the code generates is not matching the spectrum that the velocity field is expected to have, which is also an input to the code for generating the velocity field.

There is a dampening of the spectrum by a large factor, especially at low wavenumbers. I was wondering if you would know why is this happening. I checked my code and could not find anything wrong in the formulae that I use.

Thank you.

Regards

triple_r October 24, 2013 22:14

I don't remember such a difference. How are you calculating the spectrum? At higher frequencies because of aliasing you might get a bit higher energy, but can't think of a reason for a difference in lower frequencies. It was a long time ago when I was playing with DNS.

anzillo December 14, 2013 21:12

Hello Reza

I tried using the code that you gave me. It does indeed help make enforce the conjugate symmetry. However, I noticed that using ifftn (in MATLAB) with 'symmetric' defining the type of ifft, also delivers the same result.

With that done, I have a big problem. Although the velocity field is divergence free in wavenumber space, it loses its solenoidal character when the ifft is used to convert it into physical space.

Would you know why this happens or if there is a way of correcting this?

Thank you !

Kind regards
Dhruv

praveen December 15, 2013 00:15

How do you compute divergence in physical space ? using finite differences will not be accurate. You have to take divergence of the spectral interpolation of the velocity field, which should then give you zero divergence upto machine precision, since it is constructed to be solenoidal in fourier space.

FMDenaro December 15, 2013 03:54

yes, this problem is quite usual .... just think about a simulation performend in the physical space, for example an exact projection with second order discretization. You will have a diverge-free solution up to machine precision but only when the divergence of the velocity is computed on the compact stencil with central second order formula. If you try to compute the divergence using different discretizations (even higher order discretizations) you have no longer a divergence-free results.

This example explains why when the solution is divergence-free in wavenumber space you can not ensure the same result (in discrete sense) in physical space. You can try different formulas of various accuracy but you have to accept some tolerance.

anzillo December 15, 2013 08:22

Quote:

Originally Posted by praveen (Post 466425)
How do you compute divergence in physical space ? using finite differences will not be accurate. You have to take divergence of the spectral interpolation of the velocity field, which should then give you zero divergence upto machine precision, since it is constructed to be solenoidal in fourier space.


Hello Praveen

Thank you for your reply. However, I still did not understand whether it converting Rogallo's spectral field into a divergence free field in physical space is possible or not.

I did get zero divergence in spectral space using kx*u + ky*v + kz*w, you mean that is all I can get?

Thanks again !

Regards
Dhruv

triple_r December 15, 2013 10:16

They are mathematically equal. So divergence free-ness in physical space, means kx ux+ky uy+kz uz = 0 in the Fourier space. But this doesn't mean they are numerically the same. For example, if you calculate du/dx in physical space by central difference with a grid size of h, then the equivalent wave-form will have a k of sin(kh)/h. So, if you want your physical space to be divergence-free with central difference, then you should have:

sin(k_x h)/h u_x+sin(k_y h)/h u_y+sin(k_z h)/h u_z=0

in Fourier space.

anzillo December 15, 2013 10:39

Thank you very much :)
I will try to edit the code to satisfy the 'sine' condition you mentioned.

triple_r December 15, 2013 10:44

That is a work-around though. And it just converts your spectral code to a central finite difference code.

anzillo December 15, 2013 10:47

So, I can use the velocity field generated with Rogallo's code after converting it to physical space for a normal simulation?

I would then expect the field to readjust itself (to a possibly lower values of divergence) in physical space after a few turnover times after evolving in accordance with the navier stokes equation?

triple_r December 15, 2013 10:51

I see. So you are not using a spectral code to solve the problem, and just need an initial velocity for your non-sectral method? If that is the case, then you can use the sine relation I gave above to get the physical velocity field that better satisfies the continuity. But you need to change the velocity field given by Rogallo as it won't be divergence-free in the sense that you are after.

anzillo December 15, 2013 10:56

Yes, I have started changing the code to satisfy

sum( sin(h*kx)/h * ux ) = 0

and obtain u,v,w in spectral space. Then I will convert these into physical space for my simulations. I know it is weird to use a physical space code for LES, but I am working with energy-conserving schemes.

Thank you again for helping me with this :)


All times are GMT -4. The time now is 07:34.