CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   Surrounding cells of a node (http://www.cfd-online.com/Forums/fluent-udf/65250-surrounding-cells-node.html)

 gemini June 9, 2009 18:08

Surrounding cells of a node

Hi everyone,

In my udf, I need to calculate the node value of a UDS. To do this I want to use following formula

UDS_node_value = (1/number_of_CVs)*(summation of cell center UDS value of surrounding CVs)

Does someone have an idea how to obtain cell ids of surrounding cells. Scanning adjacent cells of a node make things very complicated. :(

Thanks

 ak6g08 June 29, 2009 13:30

hi,

I would like to do something similar...unfortunately i dont know how, have you gotten anywhere with this yet?...I would appreciate any advice if you have. Thanks

AK

 gemini June 30, 2009 02:30

Hi,

I don't have a solution for this issue. I think Fluent will not let us to use more accurate gradient calculation. I applied the Gauss theorem myself using face values calculated by equating fluxes from the two cells adjacent to the face.

Good luck.

Gemini

 ak6g08 June 30, 2009 06:29

Quote:
 Originally Posted by gemini (Post 220916) Hi, I don't have a solution for this issue. I think Fluent will not let us to use more accurate gradient calculation. I applied the Gauss theorem myself using face values calculated by equating fluxes from the two cells adjacent to the face. Good luck. Gemini
Hi,

Thanks for your speedy reply, so when you access an adjacent cell in FLUENT using the F_CO and F_C1 macros, how do you know if its the cell to the right, left, top or bottom of it??? adjacent could be in any direction...this effectively means that we cannot do detailed Finite volume discretisation within the UDF environment im assuming..am I right? There is no way to know which direction the adjacent cell is in relative to the initial cell?

Thanks again
AK

 gemini June 30, 2009 12:31

Quote:
 Originally Posted by ak6g08 (Post 220944) Hi, Thanks for your speedy reply, so when you access an adjacent cell in FLUENT using the F_CO and F_C1 macros, how do you know if its the cell to the right, left, top or bottom of it??? adjacent could be in any direction...this effectively means that we cannot do detailed Finite volume discretisation within the UDF environment im assuming..am I right? There is no way to know which direction the adjacent cell is in relative to the initial cell? Thanks again AK
You can check this by looking at Area vector if A vector points +x direction for example your neighbor cell is at the EAST for example, or is Area vector point -y direction your neighbour cell is at the SOUTH. This is true if cell pointed by c0 and cell pointed by c are the same. if not you'll have area vector with opposite direction.

Please careful that c0 cell is your center cell identified by c. if not you should treat c1 cell as your center cell. You can check this by making 3x3 2d grid having 9 cells and by writing an execute on demand function which prints out current cell id (c) and its face ids (f) and c0 and c1 values of each face of the current cell (c) with area vector (A) components. So you can clearly understand the situation.

best luck
Gemini

 ak6g08 July 1, 2009 12:40

Gemini,

thank you very much for your help, i have one FINAL question, i promise, you seem experienced so I woul value your assistance, when I use the macro C_UDSI_G(...) for gradient calculation, if I want to calculate a source term which depends on the gradient of the scalar being solved, do I need to write the gradient down as C_UDSI_G(...)*C_VOLUME(c,t)...because of gauss's theorem? or does fluent treat the gradient function C_UDSI_G(...) as a fully discretised version which incorporates the integration of the gradient??

Thank you very much for all of your help
AK

 gemini July 2, 2009 14:28

Quote:
 Originally Posted by ak6g08 (Post 221116) Gemini, thank you very much for your help, i have one FINAL question, i promise, you seem experienced so I woul value your assistance, when I use the macro C_UDSI_G(...) for gradient calculation, if I want to calculate a source term which depends on the gradient of the scalar being solved, do I need to write the gradient down as C_UDSI_G(...)*C_VOLUME(c,t)...because of gauss's theorem? or does fluent treat the gradient function C_UDSI_G(...) as a fully discretised version which incorporates the integration of the gradient?? Thank you very much for all of your help AK
I'm sorry that I couldn't understand what are you trying to do, so can you explain your aim in detail by giving your source term?

regards,

Gemini

 ak6g08 July 2, 2009 18:05

hi gemini,

My actual problem is outlined in the post 'problematic source term UDS', here is the link:

http://www.cfd-online.com/Forums/flu...-term-uds.html

I posted this about a week ago, basically, the way I defined my source term (see the post) causes my solution to diverge so I think I may need to do it manually somehow via accessing individual cell faces, and calculating gradients manually by accessing north, south,east and west faces... I think the soltuion is diverging because of a problem similar to decoupling of pressure and velocity when solving the momentum equation, only in my case it is with space charge and electric field... If it is easier you can reply on that post, the source term is a little bit more complicated than usual...

Thank you so much
AK

 gemini July 4, 2009 14:54

Quote:
 Originally Posted by ak6g08 (Post 221290) hi gemini, My actual problem is outlined in the post 'problematic source term UDS', here is the link: http://www.cfd-online.com/Forums/flu...-term-uds.html I posted this about a week ago, basically, the way I defined my source term (see the post) causes my solution to diverge so I think I may need to do it manually somehow via accessing individual cell faces, and calculating gradients manually by accessing north, south,east and west faces... I think the soltuion is diverging because of a problem similar to decoupling of pressure and velocity when solving the momentum equation, only in my case it is with space charge and electric field... If it is easier you can reply on that post, the source term is a little bit more complicated than usual... Thank you so much AK
Hi,

In your first function you have

Code:

```/*problematic source of scalar 2 (Q)*/ DEFINE_SOURCE(spcharge_lin,c,t,dS,eqn) ... dS[eqn] = 0.0;```
However, in the second function you have

Code:

```/*OK source of scalar 2*/ DEFINE_SOURCE(spcharge_quad,c,t,dS,eqn) ... dS[eqn] = -(2*pow(C_R(c,t),2)*C_UDSI(c,t,1)*kappa)/epsilon;```
So it seems that you did not linearized the source term in your problematic source function while you did it in the second function. The only thing I can say is that you should try linearizing the source term (See Patankar's book) .

Good luck

 All times are GMT -4. The time now is 06:56.