|
[Sponsors] |
UDF for Defining different Diffusivity for different Cellzones |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 4, 2022, 06:44 |
UDF for Defining different Diffusivity for different Cellzones
|
#1 |
New Member
Joe
Join Date: Jan 2022
Posts: 13
Rep Power: 4 |
Hello all,
I have a problem in defining diffusivity. I want to define two different diffusion coefficients in two different cell zones. For this I use the following UDF: Code:
DEFINE_DIFFUSIVITY(diffusion, c, t, i) { Domain* d; Thread * tc1, * tc2; d = Get_Domain(1); tc1 = Lookup_Thread(d, 8); tc2 = Lookup_Thread(d, 9); if (t == tc1) { diffusivity = 1e-7; } else if (t == tc2) { diffusivity = 1e-5; } return diffusivity; } Many thanks in advance. Many greetings Joe |
|
March 7, 2022, 00:27 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
plot contour from 1e-7 to 1e-4
turn of node values in contours options
__________________
best regards ****************************** press LIKE if this message was helpful |
|
March 7, 2022, 05:29 |
|
#3 |
New Member
Joe
Join Date: Jan 2022
Posts: 13
Rep Power: 4 |
Dear Alexander,
Thank you very much for your answer. I followed your tips, but I didn't know what to do with your second tip. I now have the Contour displayed in range from 1e-7 to 1e-4 and have changed the Location variable from Vertex to Face. Unfortunately, this did not change much. Many thanks in advance. Joe |
|
March 7, 2022, 07:22 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
I thought it was the problem of plotting, which isn't
so you should compile the code. variable diffusivity was not defined Code:
#include "udf.h" DEFINE_DIFFUSIVITY(diffusion, c, t, i) { Domain* d; Thread * tc1, * tc2; real diffusivity; d = Get_Domain(1); tc1 = Lookup_Thread(d, 8); tc2 = Lookup_Thread(d, 9); if (t == tc1) { diffusivity = 1e-7; } else if (t == tc2) { diffusivity = 1e-5; } return diffusivity; } for me it's strange to see on your picture name diffusivity under user defined variable 7 at least its a property of scalar so first compile code and try again. I'm assuming that 8 and 9 zones ate rectangular and circle from your picture
__________________
best regards ****************************** press LIKE if this message was helpful |
|
March 7, 2022, 09:59 |
|
#5 |
New Member
Joe
Join Date: Jan 2022
Posts: 13
Rep Power: 4 |
Dear Alexander,
Thank you for your reply. I have already complicated the code. The diffusivity variable is defined as a global variable and therefore not seen in the code, please excuse me. I use the diffusivity in other UDF to define the laminar diffusion. There is a species source in the circle. These species must be transported across the circle wall using sinks and sources which are adjacent to the circle walls. The cell area in the circle has the cell thread 8 and the cells outside the circle has the cell area 9. I have saved the diffusivity in a UDM to be able to look at the values of this in postprocessing. Is there another way to view the values of diffusivity? Many thanks in advance. Many Greetings Joe |
|
March 8, 2022, 01:20 |
|
#6 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
diffusivity is applied in fluent as a material property
that's why you are using build in macro DEFINE_DIFFUSIVITY to define it if you are saying that diffusivity is saved in a UDM somewhere else, probably that's an issue as variable "diffusivity" contains only only 1 value (not an array of values over all cells) so to store diffusivity in UDM you may use this code ( i have no idea how you've made it, may be your way is correct either) Code:
#include "udf.h" DEFINE_DIFFUSIVITY(diffusion, c, t, i) { Domain* d; Thread * tc1, * tc2; real diffusivity; d = Get_Domain(1); tc1 = Lookup_Thread(d, 8); tc2 = Lookup_Thread(d, 9); if (t == tc1) { diffusivity = 1e-7; } else if (t == tc2) { diffusivity = 1e-5; } esle diffusivity = 0; C_UDMI(c,t,0) = diffusivity; return diffusivity; }
__________________
best regards ****************************** press LIKE if this message was helpful |
|
March 8, 2022, 03:22 |
|
#7 |
New Member
Joe
Join Date: Jan 2022
Posts: 13
Rep Power: 4 |
Dear Alexander,
Thank you very much for your reply. I have tried your code and it works. Previously I had saved the diffusivity in a Define on Demand macro in a UDM. Thank you very much for your help. However, I would have one more question. Is it necessary to use !RP_HOST in a Define Diffusivity macro? Thank you very much in advance. Many greetings Joe |
|
March 9, 2022, 21:13 |
|
#8 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
you don't need it while you are not doing following:
• Reading and Writing Files • Global Reductions • Global Sums • Global Minimums and Maximums • Global Logicals • Certain Loops over Cells and Faces • Displaying Messages on a Console • Printing to a Host or Node Process • Reading/writing VP_VARs
__________________
best regards ****************************** press LIKE if this message was helpful |
|
March 10, 2022, 08:33 |
|
#9 |
New Member
Joe
Join Date: Jan 2022
Posts: 13
Rep Power: 4 |
Thank you for your help.
Many Greetings Joe |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
udf for valve closing a pipe using dynamic mesh | chem engineer | Fluent UDF and Scheme Programming | 2 | May 13, 2017 10:39 |
UDF for anisotropic diffusivity | Zerzura | Fluent UDF and Scheme Programming | 2 | December 20, 2015 10:37 |
UDF Fluent binary diffusivity (stefan Maxwell) | natantyt | Fluent UDF and Scheme Programming | 0 | September 19, 2011 12:42 |
UDF, UDF, UDF, UDF | Luc SEMINEL | Main CFD Forum | 0 | November 25, 2002 05:01 |
UDF, defining diffusivity | Szasz Robert | FLUENT | 0 | March 10, 2000 07:46 |