CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

Fourth Order Central Differencing of Flow Field Data? (Post-Processing)

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By sbaffini

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 3, 2019, 15:21
Unhappy Fourth Order Central Differencing of Flow Field Data? (Post-Processing)
  #1
New Member
 
Join Date: Dec 2019
Posts: 13
Rep Power: 7
sbro is on a distinguished road
Hi all!

I have been tasked with using a Fourth Order Central Differencing scheme to compute the z-vorticity component (Wz = dv/dx - du/dy) within Matlab; given 3D flow field data for velocities (u,v,w) in a 64^3 point domain plus 4x halo / ghost nodes (2x at the start and 2x at the end) for each dimension.

This problem stems from a 3D Taylor Green Vortex simulation for a cube of size 0<x0,x1,x2<2pi with periodic boundary conditions applied in all directions (time-step of dt=0.005s).

I understand the general concept of central differencing but I do not understand the application to this particular task and the appropriate Matlab syntax so any help would be greatly appreciated.
sbro is offline   Reply With Quote

Old   December 3, 2019, 15:33
Default
  #2
Member
 
Join Date: Aug 2018
Posts: 77
Rep Power: 8
vesp is on a distinguished road
Start by looking up a 4th order accurate finite difference stencil. It will involve e.g. points at i,i-1,i+1,... just apply it atvery grid point to approcimate the gradients you need.
vesp is offline   Reply With Quote

Old   December 3, 2019, 15:39
Default
  #3
New Member
 
Join Date: Dec 2019
Posts: 13
Rep Power: 7
sbro is on a distinguished road
Quote:
Originally Posted by vesp View Post
Start by looking up a 4th order accurate finite difference stencil. It will involve e.g. points at i,i-1,i+1,... just apply it atvery grid point to approcimate the gradients you need.
Thanks for the reply.

I have the stencil: df/dx ~ {(fi-2)-(8fi-1)+(8fi+1)-(fi+2)}/(12dx).

It is the application of this (and the central differencing methodology) to this problem and within Matlab that I am struggling with...
sbro is offline   Reply With Quote

Old   December 3, 2019, 15:42
Default
  #4
Member
 
Join Date: Aug 2018
Posts: 77
Rep Power: 8
vesp is on a distinguished road
this is already a central difference, so no need to worry about that aspect anymore. What exactlyare you struggling with? Do you understand how to apply a FD to compute a derivate in 1D?
vesp is offline   Reply With Quote

Old   December 3, 2019, 15:54
Default
  #5
New Member
 
Join Date: Dec 2019
Posts: 13
Rep Power: 7
sbro is on a distinguished road
Quote:
Originally Posted by vesp View Post
this is already a central difference, so no need to worry about that aspect anymore. What exactlyare you struggling with? Do you understand how to apply a FD to compute a derivate in 1D?
I'm unsure how to apply this scheme to my data (velocity flow field in 3D) to achieve the Z vorticity field. I'm assuming the method is to derive velocity gradient at each node using the scheme (dv/dx and du/dy) but I'm uncertain how to initialise and compute this in Matlab given the information above.
sbro is offline   Reply With Quote

Old   December 3, 2019, 15:59
Default Fourth Order Central Differencing of Flow Field Data? (Post-Processing)
  #6
Member
 
Join Date: Aug 2018
Posts: 77
Rep Power: 8
vesp is on a distinguished road
yes, just compute dv/dx by applying it to the field in the x-direction and to u in the y-direction. just loop over all points, you have a structured grid so this is really easy... still not sure what you are struggling with...

example:
outer loop over all ijk,
inner loop 1: i-2 to i+2, compute dv/dx
inner loop 2: j-2 to j+2, compute du/dy
add at each ijk
done
vesp is offline   Reply With Quote

Old   December 3, 2019, 16:08
Default
  #7
New Member
 
Join Date: Dec 2019
Posts: 13
Rep Power: 7
sbro is on a distinguished road
Quote:
Originally Posted by vesp View Post
yes, just compute dv/dx by applying it to the field in the x-direction and to u in the y-direction. just loop over all points, you have a structured grid so this is really easy... still not sure what you are struggling with...

example:
outer loop over all ijk,
inner loop 1: i-2 to i+2, compute dv/dx
inner loop 2: j-2 to j+2, compute du/dy
add at each ijk
done
Thanks again for your help.

Do I not need to initialise the boundary conditions before looping the scheme through the points? Is the scheme calculating the velocity gradient from upwind / downstream velocity components (which I already have) or the neighbouring gradients calculated through the loop?
sbro is offline   Reply With Quote

Old   December 3, 2019, 16:11
Default
  #8
Member
 
Join Date: Aug 2018
Posts: 77
Rep Power: 8
vesp is on a distinguished road
sure. you should fill the ghostcells first, so you can apply the stencil at the boundary points. not sure what you mean by the second part...
vesp is offline   Reply With Quote

Old   December 4, 2019, 04:49
Default
  #9
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,195
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
You have all the pieces, what we could add is just actually doing it for you... but this looks a lot like a homework. And even if it isn't, you really need to figure this out by yourself.

Still... you need to first copy your periodic data in the right ghost cells. For example, the data in the plane at nx+1 needs to be copied in the plane at 0. Those in the plane at nx+2 has to be copied in the plane at -1. Same for the other directions. I obviously don't know the actual indexing of your ghost planes in the code, so you need to figure out this by yourself, mine was just an example. Once this is done, you can loop on all interior i,j,k (no ghosts) and straighforwardly use the derivative formula.

Actually, in MATLAB there are more correct ways to do that, involving vectorization, and are also trivial for this structured case. But would leave that for the future.
FMDenaro likes this.
sbaffini is offline   Reply With Quote

Old   December 5, 2019, 18:45
Default
  #10
Member
 
Join Date: Aug 2018
Posts: 77
Rep Power: 8
vesp is on a distinguished road
did you figure it out?
vesp is offline   Reply With Quote

Old   December 6, 2019, 01:57
Default
  #11
Senior Member
 
Arjun
Join Date: Mar 2009
Location: Nurenberg, Germany
Posts: 1,290
Rep Power: 34
arjun will become famous soon enougharjun will become famous soon enough
Quote:
Originally Posted by sbro View Post
Hi all!

I have been tasked with using a Fourth Order Central Differencing scheme to compute the z-vorticity component (Wz = dv/dx - du/dy) within Matlab; given 3D flow field data for velocities (u,v,w) in a 64^3 point domain plus 4x halo / ghost nodes (2x at the start and 2x at the end) for each dimension.

This problem stems from a 3D Taylor Green Vortex simulation for a cube of size 0<x0,x1,x2<2pi with periodic boundary conditions applied in all directions (time-step of dt=0.005s).

I understand the general concept of central differencing but I do not understand the application to this particular task and the appropriate Matlab syntax so any help would be greatly appreciated.

Construct proper number of points at the boundary. For fourth order you will need two points at the boundary. Since you are in periodic condition, fill these two points values by copy from the other side of domain.



Now using fourth order central differencing formula compute the gradients.



Using these gradients compute the term that you need to compute.


PS: if you are asked to use 4rth order compact then you would have to solve tri diagonal equations obtaining these gradients (look in literature).
arjun is offline   Reply With Quote

Old   December 6, 2019, 13:23
Default
  #12
New Member
 
Join Date: Dec 2019
Posts: 13
Rep Power: 7
sbro is on a distinguished road
Quote:
Originally Posted by vesp View Post
did you figure it out?
Yes, I got there in the end. As you said, I was confusing myself and it was a more simple problem than I was making it.

Thanks again!
sbro is offline   Reply With Quote

Old   December 6, 2019, 13:24
Default
  #13
Member
 
Join Date: Aug 2018
Posts: 77
Rep Power: 8
vesp is on a distinguished road
great, glad to help!
vesp is offline   Reply With Quote

Reply

Tags
central difference, central differencing, matlab code, matlab coding, post-processing


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CFD by anderson, chp 10.... supersonic flow over flat plate varunjain89 Main CFD Forum 18 May 11, 2018 08:31
[General] Advice on post processing compressor blade data in paraview Jack001 ParaView 0 February 4, 2016 18:16
[General] 2 datas on one plot Akuji ParaView 46 December 1, 2013 15:06
post processing field average in cht moritzhoefert OpenFOAM Pre-Processing 0 January 11, 2012 11:41
fluid flow fundas ram Main CFD Forum 5 June 17, 2000 22:31


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