
[Sponsors] 
How to build divergence of volume fraction gradient in UDF? 

LinkBack  Thread Tools  Search this Thread  Display Modes 
April 1, 2017, 13:28 
How to build divergence of volume fraction gradient in UDF?

#1 
New Member
Bahador
Join Date: Jun 2016
Posts: 3
Rep Power: 10 
Hello,
I want to calculate 'curvature' in UDF. I have attached formulation of curvature. 'F' is volume fraction. C_VOF_G(c,t) can calculate gradient of volume fraction NV_MAG(C_VOF_G(c,t)) can calculate magnitude of volume fraction. I can calculate gradient of volume fraction but My problem is that I can't calculate divergence of volume fraction gradient in UDF. Thank you in advance. 

February 11, 2021, 13:53 

#2  
New Member
ANOOP K UNNI
Join Date: Jun 2017
Posts: 9
Rep Power: 9 
Quote:


February 12, 2021, 00:47 

#3 
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26 
Going from the gradient to the divergence (in standard Cartesian coordinates) is super simple... Just sum them.
Maybe I don't understand the problem? 

February 12, 2021, 01:14 

#4  
New Member
ANOOP K UNNI
Join Date: Jun 2017
Posts: 9
Rep Power: 9 
Quote:
#include "udf.h" #include "sg.h" #include "sg_mphase.h" #include "flow.h" #include "mem.h" #include "unsteady.h" DEFINE_ADJUST(vol_gradient, domain) { Thread *t; cell_t c; real DVOFNX,DVOFNY,DVOFDNZ; domain = Get_Domain(6); /* Fill UDS with the variable. */ thread_loop_c (t,domain) { begin_c_loop (c,t) { C_UDSI(c,t,0) = C_VOF(c,t); DVOFNX = C_UDSI_G(c,t,0)[0]; DVOFNY = C_UDSI_G(c,t,0)[1]; DVOFNZ = C_UDSI_G(c,t,0)[2]; C_UDMI(c,t,0) = DVOFNX; C_UDMI(c,t,1) = DVOFNY; C_UDMI(c,t,2) = DVOFNZ; } end_c_loop (c,t) } thread_loop_c (t,domain) { begin_c_loop (c,t) { C_UDMI(c,t,3) = NV_MAG(C_UDSI_G(c,t,0)); } end_c_loop (c,t) } DEFINE_ON_DEMAND(store_gradient) { Domain *domain; cell_t c; Thread *t; domain = Get_Domain(6); /* Fill the UDM with magnitude of gradient. */ *thread_loop_c (t,domain) { begin_c_loop (c,t) { C_UDMI(c,t,4) = C_UDMI(c,t,0)/NV_MAG(C_UDSI_G(c,t,0)); C_UDMI(c,t,5) = C_UDMI(c,t,1)/NV_MAG(C_UDSI_G(c,t,0)); C_UDMI(c,t,6) = C_UDMI(c,t,2)/NV_MAG(C_UDSI_G(c,t,0)); } end_c_loop (c,t) } } } DEFINE_SOURCE(x_recoil,c,t,dS,eqn) { real x[ND_ND]; real source; real time; real temp; time=RP_Get_Real("flowtime"); //Acquire time from FLUENT solver C_CENTROID(x,c,t); temp=C_T(c,t); //Acquire the face centroid location if (C_T(c,t) >= 3201.) { source=(54715.5*exp(13.14*(temp(3200)/temp)))*(C_UDMI(c,t,4)); C_UDMI(c,t,7) = source; dS[eqn] = 0; } else { source = dS[eqn] = 0.; } return source; } //same for y and z 

February 12, 2021, 06:31 

#5 
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26 

February 12, 2021, 07:39 

#6  
New Member
ANOOP K UNNI
Join Date: Jun 2017
Posts: 9
Rep Power: 9 
Quote:


February 12, 2021, 11:22 

#7  
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26 
Quote:
If you do get a problem: debug! Simplify your UDF, and find out which line causes the error. 

Tags 
curvature, gradients, udf and programming, vof method 
Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
[Other] mesh airfoil NACA0012  anand_30  OpenFOAM Meshing & Mesh Conversion  13  March 7, 2022 17:22 
how to set periodic boundary conditions  Ganesh  FLUENT  15  November 18, 2020 06:09 
Problem of simulating of small droplet with radius of 2mm  liguifan  OpenFOAM Running, Solving & CFD  5  June 3, 2014 02:53 
dynamic Mesh is faster than MRF????  sharonyue  OpenFOAM Running, Solving & CFD  14  August 26, 2013 07:47 
UDF for Species Mass Fraction Gradient *IN SPECIFIC ZONE *  e.g. along axis of sym.  ksiegs2  Fluent UDF and Scheme Programming  0  February 27, 2011 12:55 