# Divergence - approach to calculate it

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

 March 30, 2015, 07:36 Divergence - approach to calculate it #1 Member   Join Date: Dec 2014 Posts: 38 Rep Power: 3 Dear colleagues, I would like to make sure if my approach is correct: I need to calculate equation for a source: phi * (alpha*V) alpha - void fraction phi - UDS V - velocity In the DEFINE_SOURCE I iterate over all cell's faces and on each cell (I took central differencing scheme to get values on the faces in interior): c_face_loop(c, t, i) /* I added all variables but to understand approach it is not necessary to show them all */ { F_AREA(Area,f,t); vec[0] = (C_U(c0,t0)*C_U(c1,t1))/2*(C_VOF(c0,t0)*C_VOF(c1,t1))/2; vec[1] = (C_W(c0,t0)*C_W(c1,t1))/2*(C_VOF(c0,t0)*C_VOF(c1,t1))/2; vec[2] = (C_V(c0,t0)*C_V(c1,t1))/2*(C_VOF(c0,t0)*C_VOF(c1,t1))/2; velocity += NV_DOT(vec, Area); } return velocity * C_UDSI(c,t,0); Is a good approach? I put some conditions for boundaries, but they are not important to understand the approach. But the question is should I take dot product of a vectors?

 March 30, 2015, 08:24 #2 Senior Member   Join Date: Nov 2013 Posts: 891 Rep Power: 12 The "velocity" variable does not represent velocity, that is confusing. You should rename it. It would help greatly to check your code, if you could indicate why you wrote these equations. Why do you think "(C_U(c0,t0)*C_U(c1,t1))/2*(C_VOF(c0,t0)*C_VOF(c1,t1))/2" is the first component of ?

 March 30, 2015, 08:50 #3 Member   Join Date: Dec 2014 Posts: 38 Rep Power: 3 Thank you very much for your reply and sugestions. to calculate this I used face values multiplied by the area. To get face values of alpha and velocity I used: (C_U(c0,t0)*C_U(c1,t1))/2*(C_VOF(c0,t0)*C_VOF(c1,t1))/2 - for x direction and for other direction I used other lines of the code. NV_DOT(vec, Area); - I belive this will give values of alpha * velocity * Area of a face. velocity += NV_DOT(vec, Area); - velocity variable will "store" and add all values on faces which are multiplied by the face area which should be equal the divergence. and then in return velocity * C_UDSI(c,t,0); I mulitpied C_UDSI which is phi with divergence Does it clear? I will be more than glad to try to explain what I meant if it is still not clear. Should I add whole code for DEFINE_SOURCE?

 March 30, 2015, 08:55 #4 Senior Member   Join Date: Nov 2013 Posts: 891 Rep Power: 12 It is not clear to me where you think you calculate the gradient. I can not find anything that corresponds to calculating a gradient, but maybe I am overlooking it.

 March 30, 2015, 09:04 #5 Member   Join Date: Dec 2014 Posts: 38 Rep Power: 3 I can go from divergence in the volume to the sum over all values on faces and in case of vector I need to multiply velocity values by the area normal vector. As far as I understand numerical methods Fluent uses finite volume technique, so that's way I multiply velocity times area and sum over all faces should give me a value of the surface integral of a velocity. But I am not sure.

 March 30, 2015, 09:06 #6 Senior Member   Join Date: Nov 2013 Posts: 891 Rep Power: 12 But you don't have divergence, you have gradient. At least, that is what you wrote above.

 March 30, 2015, 09:14 #7 Member   Join Date: Dec 2014 Posts: 38 Rep Power: 3 ohhhhh, you're absolutely right! Sorry, I should write at first place

 March 30, 2015, 14:16 #9 Member   Join Date: Dec 2014 Posts: 38 Rep Power: 3 Sorry, I couldn't answer eariler. First of all, thank you very much and you are right, I should be more specific from the beginning. Well,: should be wrriten like that: f stands for face Fluent doesn't store values for faces because it uses differencing schemes to calculate it. In my case (C_U(c0,t0)*C_U(c1,t1))/2 ((c0, t0) and (c1,t1) are values in cells on both sides of one face - to have in mind that I iterate over all faces in one cell) will give value of a component of the in x direction (the same with the rest) and (C_VOF(c0,t0)*C_VOF(c1,t1))/2 will give value of at the face - accroding to the central differencing schemes. Using: vec[0] = (C_U(c0,t0)+C_U(c1,t1))/2*(C_VOF(c0,t0)+C_VOF(c1,t1))/2; vec[1] = (C_W(c0,t0)+C_W(c1,t1))/2*(C_VOF(c0,t0)+C_VOF(c1,t1))/2; vec[2] = (C_V(c0,t0)+C_V(c1,t1))/2*(C_VOF(c0,t0)+C_VOF(c1,t1))/2; I will get values of velocity vector component in every direction on faces and its value is multiply by the value of - both from central differencing scheme. NV_DOT(vec, Area) - in my opinion should give and now I need to iterate over all faces All of it is in the loop: c_face_loop(c, t, i) { } so I iterate over all faces; velocity += NV_DOT(vec, Area); - is also in the loop, so after last iteration I supposed to get: which in my opinion is equal to and in the last step in return there is a multiplication by C_UDSI Edit: There was a mistake in the first post...to be honest I don't know way (C_VOF(c0,t0)*C_VOF(c1,t1))/2; it should be (C_VOF(c0,t0)+C_VOF(c1,t1))/2, it was unprofessional, I am sorry

 Thread Tools Display Modes Linear Mode

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

 Similar Threads Thread Thread Starter Forum Replies Last Post cris FLUENT 3 September 4, 2014 18:06 rendagar OpenFOAM Running, Solving & CFD 0 February 4, 2014 11:20 manish CFX 4 March 15, 2007 03:57 maka OpenFOAM Post-Processing 0 April 28, 2006 12:46 D. Puigjaner Main CFD Forum 1 August 28, 2000 10:06

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