|
[Sponsors] |
January 13, 2017, 11:45 |
looping over a cell zone
|
#1 |
Member
Join Date: Sep 2016
Posts: 33
Rep Power: 10 |
Hi!
In my simulation I have three different materials that constitute three different cell zones...if I want to loop over the cell zone of only one of the materials how should I do? Thanks! |
|
January 15, 2017, 12:06 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
In which context do you want to loop over the cell zones?
If for example you want to put a source term only in a certain cell zone, you are thinking too complex, because then you can just attach the udf only to that cell zone... |
|
January 19, 2017, 09:47 |
|
#3 |
Member
Join Date: Sep 2016
Posts: 33
Rep Power: 10 |
I need to calculate the mass of water that accumulates in a porous media...I did a thread loop over all domain's thread and inside a loop over all the cells of the thread and imposed the limitations on the domain using the x,y coordinates...but I thought that maybe there was a smarter way
|
|
January 19, 2017, 09:58 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Yes, there is a smarter way: use THREAD_ID.
Code:
thread_loop_f(f_thread, domain) { if (THREAD_ID(f_thread) == ID) { ... your code ... } } |
|
January 21, 2017, 09:29 |
|
#5 |
Member
Join Date: Sep 2016
Posts: 33
Rep Power: 10 |
Thanks for your help!
|
|
January 31, 2017, 01:29 |
|
#6 | |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
You can use Lookup_Thread instead and loop directly on the desired thread (no need for a conditional statement).
From the UDF manual: Quote:
Code:
/*******************************************************************/ Example of an adjust UDF that uses Lookup_Thread. Note that if this UDF is applied to a multiphase flow problem, the thread that is returned is the mixture-level thread ********************************************************************/ #include "udf.h" /* domain passed to Adjust function is mixture domain for multiphase*/ DEFINE_ADJUST(print_f_centroids, domain) { real FC[2]; face_t f; int ID = 1; /* Zone ID for wall-1 zone from Boundary Conditions task page */ Thread *thread = Lookup_Thread(domain, ID); begin_f_loop(f, thread) { F_CENTROID(FC,f,thread); printf("x-coord = %f y-coord = %f", FC[0], FC[1]); } end_f_loop(f,thread) } For DEFINE_EXECUTE_AT_END or DEFINE_ON_DEMAND you need to add the Domain... line: Code:
DEFINE_ON_DEMAND(on_demand_0) { #if !RP_HOST /* action not performed on host, only on compute nodes */ Domain *domain = Get_Domain(1); /* declare domain pointer since it is not passed as an argument to the DEFINE macro */ int Cell_Zone_ID = 13; cell_t c; Thread *t = Lookup_Thread(domain, Cell_Zone_ID); begin_c_loop(c,t) { Message("looping over cells...\n"); } end_c_loop(c,t) #endif } |
||
July 15, 2019, 02:48 |
how to apply Energy Source at liquid cells next to interface?
|
#7 |
Senior Member
vidyadhar
Join Date: Jul 2016
Posts: 138
Rep Power: 10 |
Hello François Grégoire,
I want to apply energy source on one layer of liquid cells which are lying next to the liquid vapor interface. Can you let me know how to do this. I guess I cannot use LookupThread and Adjacent Cell thread (THREAD_T0) for this. Thanks in advance! Vidyadhar |
|
July 15, 2019, 05:13 |
|
#8 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
as far as I know, you can get liquid-vapor interface if you are using Volume Of Fluid model (VOF). May be, you may get adjusted cells using macros for c1,t1
best regards |
|
July 15, 2019, 06:45 |
|
#9 | |
Senior Member
vidyadhar
Join Date: Jul 2016
Posts: 138
Rep Power: 10 |
Quote:
Hello Alexander, Thanks for the reply. I am using VOF model. I can visualize interface. The interface is of the type "interior" in the fluid zone. I request you to elaborate on "May be, you may get adjusted cells using macros for c1,t1" Thanks & Regards, Vidyadhar |
||
July 15, 2019, 08:36 |
|
#10 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
Hi Vidyadhar,
I'm not working with Fluent anymore, don't have it on my computer, can't really help you, sorry. François |
|
July 15, 2019, 23:21 |
|
#11 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
make a loop over all face/threads, check F_VOF(f, t); value
if it varies in range 0 .. 1 , than this cell is interface than you can check Code:
if (BOUNDARY_FACE_THREAD_P(t)) {} // do nothing, because there is no cell outside the face else { c1 = F_C1(f,t); t1 = THREAD_T1(t); F_UDMI(c1,t1,0) = your_source; } best regards |
|
September 9, 2019, 03:47 |
|
#12 |
Member
Vignesh Lakshmanan
Join Date: Nov 2016
Posts: 79
Rep Power: 10 |
Hi,
Sorry for restarting the thread. I am simulating flow through a capillary tube (3D) in Fluent and I would like to understand the variation in temperature and pressure across the length of the capillary. The simple and tedious option would be to create multiple faces across the capillary (varying in 2 directions, say x and y) and report values at each face. Is it possible to do this through UDFs? I would like inputs in looping through cells in a particular domain and write values at fixed intervals, say 0.1 m or so PS: My geometry is a coiled capillary Thanks in Advance!!! |
|
August 7, 2022, 22:33 |
|
#13 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
from your explanation it seems, that you don't need udf at all
you may create monitor points at locations you are interested in if there are too many points, you may use TUI commands and journal file to make points by script
__________________
best regards ****************************** press LIKE if this message was helpful |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Cell Zone Conditions initialization Problem | ansys_matt | FLUENT | 3 | October 13, 2014 05:45 |
[Commercial meshers] fluentMeshToFoam multidomain mesh conversion problem | Attesz | OpenFOAM Meshing & Mesh Conversion | 12 | May 2, 2013 11:52 |
Segmentation Fault in fluent3DMeshToFoam | cwang5 | OpenFOAM Bugs | 23 | April 13, 2011 16:37 |
[Other] cgnsToFoam problems with "QUAD_4" cells | lentschi | OpenFOAM Meshing & Mesh Conversion | 1 | March 9, 2011 05:49 |
Warning 097- | AB | Siemens | 6 | November 15, 2004 05:41 |