|
[Sponsors] |
October 10, 2017, 01:55 |
UDF for time integral field function
|
#1 |
New Member
Paolo
Join Date: Jan 2017
Posts: 19
Rep Power: 9 |
Hi all,
I would like to create an udf for calculating the time integral of a variable (i.e. CO concentration) and allocating it in a UDM. Nothing special, just multiply the new value for dt and adding the one calculated in the previous step. I know how to write udf but this time it seems that I need to declare a global variable and I don't now where I have to hook it in the model. Thank you in advance Paolo P.s. is there any precaution to use this udf in parallel computing? |
|
October 10, 2017, 11:26 |
|
#2 |
Senior Member
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,674
Rep Power: 66 |
Why can't you use the built-in data sampling for time statistics option? You should have the option of selecting species.
If you cannot select it, I think it is much easier to define a custom field function, set it equal to the [CO] and then sample this custom variable again using the data sampling option. I don't know how to decipher that to understand what your problem is. |
|
October 10, 2017, 12:59 |
|
#3 |
New Member
Paolo
Join Date: Jan 2017
Posts: 19
Rep Power: 9 |
Sorry for my English, I wish to have a field variable that is the cumulative of the co concentration in time for each cell. The aim is to show contour of FED (fractional effective dose) in all the domain.
I figured out that I have probably to set two udm, one for storing the [CO] in the previous time step (let's say udm0) and one for the last time step (udm1) and then sum udm0+udm1 each time step updating the first one (udm0=udm1). My problem is to write the udf that does this task and where to hook it (probably in the udf hook panel in one of the options). Thank you |
|
October 10, 2017, 13:01 |
|
#4 |
New Member
Paolo
Join Date: Jan 2017
Posts: 19
Rep Power: 9 |
Furthermore I wish to run the simulation in parallel, I know that loops over cells require some precaution
|
|
October 10, 2017, 20:40 |
|
#5 |
Senior Member
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,674
Rep Power: 66 |
This doesn't require a UDF afaik. Just turn on data sampling for time-statistics.
|
|
October 10, 2017, 21:58 |
|
#6 | |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Quote:
Hello For UDF use ANSYS Fluent Customization Manual For your case you may use this code for single cell as a basis, modify it Code:
#include "udf.h" DEFINE_EXECUTE_AT_END(execute_at_end) { Domain *d; Thread *t; /* Integrate dissipation. */ real integral=0.; real dtime; real temperature; cell_t c; d = Get_Domain(1); /* mixture domain if multiphase */ dtime = CURRENT_TIMESTEP; /* get time step value */ thread_loop_c (t,d) { /* Loop over all cells */ begin_c_loop(c,t) { /* Calculate volume of JR */ temperature = C_T(c,t); /* get temperature*/ integral += temperature*dtime; /* calculate integral */ C_UDMI(c,t,0) = integral; /* write to UDM */ } end_c_loop (c,t) } Message("Temperature time integral: %f\n", integral); } Then load in fluent. Hook DEFINE_EXECUTE_AT_END function (User-Defined -> function hooks) Add UMD ( User-Defined -> Memory -> Set memory locations 1) Best reagards |
||
October 15, 2017, 05:57 |
|
#7 | |
New Member
Paolo
Join Date: Jan 2017
Posts: 19
Rep Power: 9 |
Thank you very much!
I was able to do my task modifiyng the code like here below. Obviously is only an example, in my code I'll use the CO concentration instead of temperature. Now I just need to change the UDM name, for the parallel computing it seems that I don't need any change (looking at results). Thank you again, hope this post could help someone else. Cheers Paolo Quote:
|
||
|
|
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 |
Running UDF with Supercomputer | roi247 | FLUENT | 4 | October 15, 2015 13:41 |
UDF parallel error: chip-exec: function not found????? | shankara.2 | Fluent UDF and Scheme Programming | 1 | January 16, 2012 22:14 |
OpenFOAM static build on Cray XT5 | asaijo | OpenFOAM Installation | 9 | April 6, 2011 12:21 |
ParaView for OF-1.6-ext | Chrisi1984 | OpenFOAM Installation | 0 | December 31, 2010 06:42 |