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

Data access in define macros

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 23, 2012, 11:24
Question Data access in define macros
  #1
New Member
 
Erica
Join Date: Jul 2012
Location: Mountain View, CA
Posts: 14
Rep Power: 13
Magneto is on a distinguished road
Hi Everyone,

I am writing a DEFINE_SOURCE macro where I need to access data in other cells (not just the current cell's neighbors) in order to calculate the source term for the current cell. Does anyone know how to do this?

Thanks!
Magneto is offline   Reply With Quote

Old   July 23, 2012, 13:49
Default
  #2
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,398
Rep Power: 46
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
If you have very few cells, you can add a loop over all the cells to the DEFINE_SOURCE macro and read the variables here.

Or you could define a user defined memory and store the desired variable here. In the DEFINE_SOURCE macro, you can then read the UDM for every cell.

I don't know if a cell value of a certain cell can be read directly.
flotus1 is offline   Reply With Quote

Old   July 23, 2012, 13:54
Default
  #3
New Member
 
Erica
Join Date: Jul 2012
Location: Mountain View, CA
Posts: 14
Rep Power: 13
Magneto is on a distinguished road
Right, looping over the other cells is exactly what I want to do, but I don't know the syntax for that. Do you? Thanks for your reply!
Magneto is offline   Reply With Quote

Old   July 23, 2012, 15:16
Default
  #4
New Member
 
Erica
Join Date: Jul 2012
Location: Mountain View, CA
Posts: 14
Rep Power: 13
Magneto is on a distinguished road
Just to clarify, I know begin_c_loop...end_c_loop loops over the cells, but I don't know how to initialize the cell and thread that should be inputs to this loop.
Magneto is offline   Reply With Quote

Old   July 23, 2012, 17:00
Default
  #5
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,398
Rep Power: 46
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
Until now, I haven't given any thought about that.

I just used begin_c_loop(c,t).
I guess the thread is the same on which the source is applied in this case.
flotus1 is offline   Reply With Quote

Old   July 23, 2012, 17:17
Default
  #6
New Member
 
Erica
Join Date: Jul 2012
Location: Mountain View, CA
Posts: 14
Rep Power: 13
Magneto is on a distinguished road
Using the same thread pointer causes an error (with no useful information in the error dialog.) After digging through a lot of fluent documentation, I think the solution might be to nest a begin_c_loop...end_c_loop inside a thread_loop_c. I will try this and post whether it works for other people following this message thread. I'd love to hear from anyone who has done this before and has advice on how to implement it.
Magneto is offline   Reply With Quote

Old   July 25, 2012, 04:20
Default
  #7
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,398
Rep Power: 46
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
I can only say that I dit it like this without geting an error message.
But if it really doesn't work, you can still use a UDM.
flotus1 is offline   Reply With Quote

Old   July 25, 2012, 08:22
Default
  #8
New Member
 
Erica
Join Date: Jul 2012
Location: Mountain View, CA
Posts: 14
Rep Power: 13
Magneto is on a distinguished road
The cell loop nested within the thread loop works without errors, but it's clear that it is only counting about half the cells. I also tried specifically looping over the interior zone (got the zone ID from fluent's cell zone conditions GUI) with the same problem. The number of cells that get counted seems to be affected by whether I am processing the solution in serial or parallel. Very strange!
Magneto is offline   Reply With Quote

Old   July 25, 2012, 08:27
Default
  #9
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,398
Rep Power: 46
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
But you do know that a UDF has to be modified in order to work properly in a parallel computation?
flotus1 is offline   Reply With Quote

Old   July 25, 2012, 10:32
Default
  #10
New Member
 
Erica
Join Date: Jul 2012
Location: Mountain View, CA
Posts: 14
Rep Power: 13
Magneto is on a distinguished road
I was actually not aware of this, so thanks for the tip. I won't ask you to explain how to modify the UDF here since I imagine it's nontrivial (and probably something I can look up), but I'll take a look at the Fluent documentation and stick to serial until I figure it out.

Cheers!
Magneto is offline   Reply With Quote

Old   July 25, 2012, 10:36
Default
  #11
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,398
Rep Power: 46
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
I am very glad that you didn't ask, because I actually don't know
flotus1 is offline   Reply With Quote

Old   July 25, 2012, 12:22
Default
  #12
New Member
 
Erica
Join Date: Jul 2012
Location: Mountain View, CA
Posts: 14
Rep Power: 13
Magneto is on a distinguished road
Just for future reference (and for anyone else reading this thread), here's what I've found out so far. In parallel mode, Fluent's central controller breaks the domain into discrete chunks of cells for each processor to solve, but the chunks have to share boundary cells because they need to pass information between the domains (mass flux, face pressure, etc.) In a UDF that has to loop over all the cells in the domain (like mine), you have to specifically tell the processors to loop over only the internal cells because otherwise the boundary cells get counted twice.

I may keep my UDF in serial because it looks like I would also have to implement a more complicated message passing system between the processors (which all work with different sets of threads) in order to simultaneously access the cell where I'm calculating the source term and the cell that's remotely causing the force (since the two cells may belong to different processors.)
Magneto is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Access to field data sepp OpenFOAM 2 February 10, 2011 11:45
enquiry-how to define OH radical properties into fluent's material data base nita FLUENT 1 December 9, 2010 21:09
How to define the velocity_inlet boundary condition with existed data for a face? Byron FLUENT 4 September 4, 2010 03:47
question on data access in parallel computation wangrensong FLUENT 0 January 7, 2009 03:24
Free surface boudary conditions with SOLA-VOF Fan Main CFD Forum 10 September 9, 2006 12:24


All times are GMT -4. The time now is 16:18.