CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Gradient of volume fraction(C_VOF_G)

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 21, 2021, 14:04
Post Gradient of volume fraction(C_VOF_G)
  #1
Member
 
Join Date: Jul 2020
Location: India
Posts: 63
Rep Power: 5
Cooper24 is on a distinguished road
I request all the experts and the senior members on the forum that once and for all if you could confirm whether the following piece of code can be used to access the gradient of volume fraction(C_VOF_G) in a UDF. I have seen this piece of code somewhere being used for accessing the C_VOF_G but could not confirm the validity of the source.

Thread *t;
Thread **pt;
cell_t c;
int phase_domain_index = 1;
Domain *d = Get_Domain(1);
Domain *pDomain = DOMAIN_SUB_DOMAIN(d,phase_domain_index);
{
Alloc_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_N ULL);
Scalar_Reconstruction(pDomain, SV_VOF,-1,SV_VOF_RG,NULL);
Scalar_Derivatives(pDomain,SV_VOF,-1,SV_VOF_G,SV_VOF_RG, Vof_Deriv_Accumulate);
}

mp_thread_loop_c(t,d,pt)
if (FLUID_THREAD_P(t))
{
Thread *ppt = pt[phase_domain_index];
begin_c_loop (c,t)
{
C_UDMI(c,t,0) = C_VOF_G(c,ppt)[0];
C_UDMI(c,t,1) = C_VOF_G(c,ppt)[1];
C_UDMI(c,t,2) = C_VOF_G(c,ppt)[2];
C_UDMI(c,t,3) = sqrt(C_UDMI(c,t,0)*C_UDMI(c,t,0) + C_UDMI(c,t,1)*C_UDMI(c,t,1) + C_UDMI(c,t,2)*C_UDMI(c,t,2)); // magnitude of gradient of volume fraction
C_UDMI(c,t,4) = C_UDMI(c,t,0)/C_UDMI(c,t,3); // x gradient of volume fraction divided by magnitude of gradient of volume fraction
C_UDMI(c,t,5) = C_UDMI(c,t,1)/C_UDMI(c,t,3); // y gradient of volume fraction divided by magnitude of gradient of volume fraction
C_UDMI(c,t,6) = C_UDMI(c,t,2)/C_UDMI(c,t,3); //z gradient of volume fraction divided by magnitude of gradient of volume fraction
}
end_c_loop (c,t)
}
Free_Storage_Vars(pDomain,SV_VOF_RG,SV_VOF_G,SV_NU LL);
}

If this is not correct then what is the correct way of accessing C_VOF_G?

Thanks in advance
Cooper24 is offline   Reply With Quote

Old   December 21, 2021, 14:52
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
If you want to know if this is correct, then... just try it, and see if it does what you want! You don't need "experts and senior members" for that! Open Fluent, compile the code, make a simple simulation with a VOF, and see if this code works.

If it does not work, explain here in what way it did not work (compile errors, crashing, wrong results, divergence, or something else), and we can help.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   December 21, 2021, 15:06
Default
  #3
Member
 
Join Date: Jul 2020
Location: India
Posts: 63
Rep Power: 5
Cooper24 is on a distinguished road
Thanks pakk for your reply. The code compiles without any error. Actually I am new to UDF writing and not an expert coder also. I learnt that C_VOG_G is not available as an inbuilt macro in fluent. When I run the simulation, the solution starts good but after a few steps it does not converge. So, I am unable to point out where the issue is. That's why I asked if the piece of code is right for storing C_VOF_G. Then atleast I would be sure that I can accessC_VOF_G using this code and the problem is somewhere else.
Cooper24 is offline   Reply With Quote

Old   December 21, 2021, 19:03
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Quote:
Originally Posted by Cooper24 View Post
When I run the simulation, the solution starts good but after a few steps it does not converge.
For next time: include this information with the question.

The code that you just showed only saves things in memory, it does not change the convergence in any way. So you must be doing something with these UDMs.

To find out where your problem comes from: don't do that something. Simulate a few iterations, and then plot the gradient of the VOF, and plot the VOF, and see if it looks more or less correct.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   December 22, 2021, 00:02
Default
  #5
Member
 
Join Date: Jul 2020
Location: India
Posts: 63
Rep Power: 5
Cooper24 is on a distinguished road
Thanks for your reply pakk. As I said I am new to UDF and to coding in general. I will do what you have suggested.
I just wanted to know whether the piece of code can be used to store C_VOF_G as the macro is not available as an inbuilt function in FLUENT. I hope it can be used to store C_VOF_G.
Cooper24 is offline   Reply With Quote

Old   December 22, 2021, 05:04
Default
  #6
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
I also hope that it is able to do that, but the way to find out is to test it. It does not matter if you are an expert or a beginner, I don't know why you feel the need to repeat that so many times.
If you want to know if something works: try it, and see if it does what you want. You do that for a car, you do that for a new recipe for a meal, and you also do that for software.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   December 22, 2021, 07:11
Default
  #7
Member
 
Join Date: Jul 2020
Location: India
Posts: 63
Rep Power: 5
Cooper24 is on a distinguished road
Thanks pakk for your encouragement. I will try what you have suggested. I can't say about others, but as I beginner I sometimes feel that if I try to do something out of book, I might destroy it beyond repair or might not be able to know the reason for destruction.
Anyways, thank you very much for all your help.
Cooper24 is offline   Reply With Quote

Old   December 22, 2021, 12:20
Default
  #8
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
There is a nice trick in Fluent: save your simulations before you experiment.
Then you can always go back to the point where it worked. The only thing you can lose is time, nothing can be damaged beyond repairs.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Reply

Tags
volume fraction gradient

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Other] mesh airfoil NACA0012 anand_30 OpenFOAM Meshing & Mesh Conversion 13 March 7, 2022 18:22
how to set periodic boundary conditions Ganesh FLUENT 15 November 18, 2020 07:09
pisoFOAM (LES) - internal pipe flow - convergence gu1 OpenFOAM Running, Solving & CFD 0 January 11, 2018 17:39
Periodic flow using Cyclic - comparison with Fluent nusivares OpenFOAM Running, Solving & CFD 30 December 12, 2017 06:35
alphaEqn.H in twoPhaseEulerFoam cheng1988sjtu OpenFOAM Bugs 15 May 1, 2016 17:12


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