CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

How to calculate the divergence of velocity at the grid vertex

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By bigphil

Reply
 
LinkBack Thread Tools Display Modes
Old   September 1, 2013, 01:10
Default How to calculate the divergence of velocity at the grid vertex
  #1
New Member
 
JM
Join Date: Jul 2013
Posts: 7
Rep Power: 4
xiaof is on a distinguished road
Hello everyone
I want to calculate the divergence of velocity at the grid vertex using the value of cell center just like the attached file showing.Because the mesh file is unstructured,I don't know how to express the U(i+1,j+1)V(i+1,j+1),U(i,j+1)V(i,j+1)
U(i+1,j)V(i+1,j),U(i,j)V(i,j).

If anyone knows how to realize this,please tell me!

Thank you very much!

best regards!

xiaof
Attached Images
File Type: png QQ??20130901130610.png (8.6 KB, 27 views)
xiaof is offline   Reply With Quote

Old   September 1, 2013, 05:51
Default
  #2
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,488
Blog Entries: 34
Rep Power: 86
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Greetings xiaof,

Have a look into:
Best regards,
Bruno
wyldckat is online now   Reply With Quote

Old   September 2, 2013, 09:05
Default
  #3
Senior Member
 
bigphil's Avatar
 
Philip Cardiff
Join Date: Mar 2009
Location: Dublin,Ireland
Posts: 570
Rep Power: 19
bigphil will become famous soon enoughbigphil will become famous soon enough
Hi xiaof,

You could calculate the cell-centred divergence field and then interpolate this volume field to the vertices, using pointVolInterpolation (available in OpenFOAM-1.6-ext, I'm not sure which class does this in standard OpenFOAM).

Best regards,
Philip
bigphil is offline   Reply With Quote

Old   September 2, 2013, 11:12
Default
  #4
New Member
 
JM
Join Date: Jul 2013
Posts: 7
Rep Power: 4
xiaof is on a distinguished road
Hi Philip
Thank you for your method.With your method,I can get the divergence at the vertices.But I think it is different what I mean.I need to use the four cell-center velocity around the vertices to get the divergence.

So if I get the vertices velocity, can I use
Code:
fvc::div()
or
fvc::grad()
to get what I want? or are there any operators about the pointFields can I use?

thank you!

xiaof
xiaof is offline   Reply With Quote

Old   September 2, 2013, 11:32
Default
  #5
Senior Member
 
bigphil's Avatar
 
Philip Cardiff
Join Date: Mar 2009
Location: Dublin,Ireland
Posts: 570
Rep Power: 19
bigphil will become famous soon enoughbigphil will become famous soon enough
Hi xiaof,

I am not sure I understand what exactly you want to do, but I don't think the fvc/fvm operators will do exactly what you want.
The fvc/fvm operators typically deal with volume fields (cell centre) and surface fields (face centre).

You might be able to active what you want by manually calculating the value for each vertex, e.g.
Code:
const labelListList& pointCells = mesh.pointCells();
// go through all points
forAll(mesh.points(), pointi)
{
  // go through all cells around pointi
  forAll(pointCells[pointi], celli)
  {
    label cellID = pointCells[pointi][celli];

    // do some calculations here, maybe using centre co-ordinates
    // e.g.
    divU[pointi] += mesh.C()[cellID]*U[cellID];
  }
}
But you would need to be careful about including in boundary values.

Maybe you could explain a bit more about why you need to do this calculation, then we might be able to suggest the best way.

Best regards,
Philip
bigphil is offline   Reply With Quote

Old   September 2, 2013, 20:20
Default
  #6
New Member
 
JM
Join Date: Jul 2013
Posts: 7
Rep Power: 4
xiaof is on a distinguished road
Hi Philip
Because we want want to test a new interpolate scheme.Although the divergence at cell center approaches to zero,the divergence at cell vertices might not.So we want to calculate the divergence of velocity at the grid vertex using the value of cell center.

Code:
divU[pointi] += mesh.C()[cellID]*U[cellID];
This code is not for the divergence, right?
With the centre co-ordinates,maybe we should calculate some weight coefficient.


If the mesh is not hexahedron,how to calculate it with general method?

Thank you!

regards!

xiaof
xiaof is offline   Reply With Quote

Old   September 3, 2013, 10:03
Default
  #7
Senior Member
 
bigphil's Avatar
 
Philip Cardiff
Join Date: Mar 2009
Location: Dublin,Ireland
Posts: 570
Rep Power: 19
bigphil will become famous soon enoughbigphil will become famous soon enough
Quote:
Originally Posted by xiaof View Post
Hi Philip
Because we want want to test a new interpolate scheme.Although the divergence at cell center approaches to zero,the divergence at cell vertices might not.So we want to calculate the divergence of velocity at the grid vertex using the value of cell center.

Code:
divU[pointi] += mesh.C()[cellID]*U[cellID];
This code is not for the divergence, right?
With the centre co-ordinates,maybe we should calculate some weight coefficient.


If the mesh is not hexahedron,how to calculate it with general method?

Thank you!

regards!

xiaof
Your PM:
Quote:
I have some doubts there.And I have another question.Although I can know the cells around pointi,how can I know the exact cell ID of them(
left down, right down, left up, right up cells).Because to the different cell, I would take different operation,for example
Code:
0.5(Ux(right down)-Ux(left down))+0.5(Ux(right up)-Ux(right down))+0.5(Uy(left up) -Uy(left down))+0.5(Uy(right up)-Uy(right down))

Hi xiaof,

OK that sounds like an interesting interpolation scheme.

As regards this code:
Code:
divU[pointi] += mesh.C()[cellID]*U[cellID];
I was just showing you where to do your calculations, this code does not have a meaning and is just an example.

I cannot help you figure out how to do this for an unstructured grid; however, I would suggest you start by drawing some general polygons around a vertex and see if you can figure out a general method based on surrounding cell centre velocities and coordinates I suppose.
For example, OpenFOAM calculates gradients and divergences by summing up terms on each face of a cell so the method is independent of the cell shapes and number of faces.

To get the cell IDs of the cells surrounding a point is easy (OpenFOAM does the work), I will rewrite part of code from my previous post with more comments:
Code:
// pointCells gives you a list of the cell IDs of the cells around every mesh point
const labelListList& pointCells = mesh.pointCells();
// go through all points
forAll(mesh.points(), pointi)
{
  // now we go through all cells around pointi
// i.e. there are pointCells[pointi].size() cells around pointi
// and pointCells[pointi] gives you a list of the cell IDs
  forAll(pointCells[pointi], celli)
  {
// here is the ID of celli
    label cellID = pointCells[pointi][celli];
// so we can use cellID to get the velocity or coordinates below

    // do some calculations here, maybe using centre co-ordinates
    // just and example calculation - does not mean anything!
    divU[pointi] += mesh.C()[cellID]*U[cellID];
  }
}
Best regards,
Philip
bigphil is offline   Reply With Quote

Old   September 4, 2013, 04:37
Default
  #8
New Member
 
JM
Join Date: Jul 2013
Posts: 7
Rep Power: 4
xiaof is on a distinguished road
Hi Philip
Thank you for your explain.Now I can find the all cells around the pointi.What I want to make sue further is which one is the first one ,second one...
As to the attached file,is it the leftdown cell is the first one cell.And then I can take different operation.


Thank you very much!

regards!

xiaof
Attached Images
File Type: jpg 1.jpg (13.3 KB, 6 views)
xiaof is offline   Reply With Quote

Old   September 4, 2013, 10:07
Default
  #9
Senior Member
 
bigphil's Avatar
 
Philip Cardiff
Join Date: Mar 2009
Location: Dublin,Ireland
Posts: 570
Rep Power: 19
bigphil will become famous soon enoughbigphil will become famous soon enough
Quote:
Originally Posted by xiaof View Post
Hi Philip
Thank you for your explain.Now I can find the all cells around the pointi.What I want to make sue further is which one is the first one ,second one...
You need to stop thinking in a structured mesh way and start thinking in an unstructured mesh way;

In an unstructured mesh, there is no leftUp, rightUP, etc. because there might be 3 surrounding cells or 10 surrounding cells.
So for your case, the only pertinent information you know is:
  • the number of cells surrounding a point - pointCells[pointi].size()
  • the coordinates of these surrounding cell centres - mesh.C()[cellID]
  • all other mesh connectivity, face areas, etc.
so you need to come up with a version of your method that can only uses this information without knowing about leftUp, rightUp, etc.

Philip
Tushar@cfd likes this.
bigphil is offline   Reply With Quote

Old   December 18, 2014, 08:21
Default
  #10
Member
 
Niu
Join Date: Apr 2014
Posts: 42
Rep Power: 3
Z.Q. Niu is on a distinguished road
Dear Philip,
I'm doing the post-processing of a vector field, I want to take an average of velocity along one direction, but I don't know how to get the velocity at the point or center of cell. Would you mind giving me some advice? Thanks!
Z.Q. Niu is offline   Reply With Quote

Reply

Tags
divergence of velocity

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difficulty in calculating angular velocity of Savonius turbine simulation alfaruk CFX 8 December 3, 2013 17:51
Particle trace velocity structure in grid fire simulation hanklord Main CFD Forum 0 July 12, 2013 03:25
How to calculate velocity at a interior surface? wanghaojie Fluent UDF and Scheme Programming 0 March 23, 2012 11:21
Terrible Mistake In Fluid Dynamics History Abhi Main CFD Forum 12 July 8, 2002 09:11
Grid Independent Solution Chuck Leakeas Main CFD Forum 2 May 26, 2000 11:18


All times are GMT -4. The time now is 05:38.