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

looping over a cell zone

Register Blogs Community New Posts Updated Threads Search

Like Tree6Likes
  • 1 Post By pakk
  • 2 Post By macfly
  • 1 Post By macfly
  • 2 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 13, 2017, 11:45
Default looping over a cell zone
  #1
Boh
Member
 
Join Date: Sep 2016
Posts: 33
Rep Power: 10
Boh is on a distinguished road
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!
Boh is offline   Reply With Quote

Old   January 15, 2017, 12:06
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
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...
pakk is offline   Reply With Quote

Old   January 19, 2017, 09:47
Default
  #3
Boh
Member
 
Join Date: Sep 2016
Posts: 33
Rep Power: 10
Boh is on a distinguished road
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
Boh is offline   Reply With Quote

Old   January 19, 2017, 09:58
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Yes, there is a smarter way: use THREAD_ID.
Code:
thread_loop_f(f_thread, domain) {
 if (THREAD_ID(f_thread) == ID) {
  ... your code ...
 }
}
Replace "ID" by the number of the cell zone that you can find in Fluent.
solanki004 likes this.
pakk is offline   Reply With Quote

Old   January 21, 2017, 09:29
Default
  #5
Boh
Member
 
Join Date: Sep 2016
Posts: 33
Rep Power: 10
Boh is on a distinguished road
Thanks for your help!
Boh is offline   Reply With Quote

Old   January 31, 2017, 01:29
Default
  #6
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
You can use Lookup_Thread instead and loop directly on the desired thread (no need for a conditional statement).

From the UDF manual:

Quote:
You can use Lookup_Thread when you want to retrieve the pointer t to the thread that is associated with a given integer zone ID number for a boundary zone. The zone_ID that is passed to the macro is the zone number that ANSYS Fluent assigns to the boundary and displays in the boundary condition dialog box (for example, Fluid).
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
}
pakk and solanki004 like this.
macfly is offline   Reply With Quote

Old   July 15, 2019, 02:48
Default how to apply Energy Source at liquid cells next to interface?
  #7
Senior Member
 
vidyadhar
Join Date: Jul 2016
Posts: 138
Rep Power: 10
vidyadhar is on a distinguished road
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
vidyadhar is offline   Reply With Quote

Old   July 15, 2019, 05:13
Default
  #8
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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
AlexanderZ is offline   Reply With Quote

Old   July 15, 2019, 06:45
Default
  #9
Senior Member
 
vidyadhar
Join Date: Jul 2016
Posts: 138
Rep Power: 10
vidyadhar is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
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

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
vidyadhar is offline   Reply With Quote

Old   July 15, 2019, 08:36
Default
  #10
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
Hi Vidyadhar,


I'm not working with Fluent anymore, don't have it on my computer, can't really help you, sorry.


François
vidyadhar likes this.
macfly is offline   Reply With Quote

Old   July 15, 2019, 23:21
Default
  #11
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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;
}
something like this

best regards
vidyadhar and daisen like this.
AlexanderZ is offline   Reply With Quote

Old   September 9, 2019, 03:47
Default
  #12
Member
 
Vignesh Lakshmanan
Join Date: Nov 2016
Posts: 79
Rep Power: 10
ViLaks is on a distinguished road
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!!!
ViLaks is offline   Reply With Quote

Old   August 7, 2022, 22:33
Default
  #13
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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
AlexanderZ is offline   Reply With Quote

Reply


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
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


All times are GMT -4. The time now is 14:03.