|
[Sponsors] |
July 23, 2012, 12:24 |
Data access in define macros
|
#1 |
New Member
Erica
Join Date: Jul 2012
Location: Mountain View, CA
Posts: 14
Rep Power: 14 |
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! |
|
July 23, 2012, 14:49 |
|
#2 |
Super Moderator
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49 |
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. |
|
July 23, 2012, 14:54 |
|
#3 |
New Member
Erica
Join Date: Jul 2012
Location: Mountain View, CA
Posts: 14
Rep Power: 14 |
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!
|
|
July 23, 2012, 16:16 |
|
#4 |
New Member
Erica
Join Date: Jul 2012
Location: Mountain View, CA
Posts: 14
Rep Power: 14 |
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.
|
|
July 23, 2012, 18:00 |
|
#5 |
Super Moderator
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49 |
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. |
|
July 23, 2012, 18:17 |
|
#6 |
New Member
Erica
Join Date: Jul 2012
Location: Mountain View, CA
Posts: 14
Rep Power: 14 |
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.
|
|
July 25, 2012, 05:20 |
|
#7 |
Super Moderator
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49 |
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. |
|
July 25, 2012, 09:22 |
|
#8 |
New Member
Erica
Join Date: Jul 2012
Location: Mountain View, CA
Posts: 14
Rep Power: 14 |
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!
|
|
July 25, 2012, 09:27 |
|
#9 |
Super Moderator
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49 |
But you do know that a UDF has to be modified in order to work properly in a parallel computation?
|
|
July 25, 2012, 11:32 |
|
#10 |
New Member
Erica
Join Date: Jul 2012
Location: Mountain View, CA
Posts: 14
Rep Power: 14 |
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! |
|
July 25, 2012, 11:36 |
|
#11 |
Super Moderator
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49 |
I am very glad that you didn't ask, because I actually don't know
|
|
July 25, 2012, 13:22 |
|
#12 |
New Member
Erica
Join Date: Jul 2012
Location: Mountain View, CA
Posts: 14
Rep Power: 14 |
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.) |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Access to field data | sepp | OpenFOAM | 2 | February 10, 2011 12:45 |
enquiry-how to define OH radical properties into fluent's material data base | nita | FLUENT | 1 | December 9, 2010 22:09 |
How to define the velocity_inlet boundary condition with existed data for a face? | Byron | FLUENT | 4 | September 4, 2010 04:47 |
question on data access in parallel computation | wangrensong | FLUENT | 0 | January 7, 2009 04:24 |
Free surface boudary conditions with SOLA-VOF | Fan | Main CFD Forum | 10 | September 9, 2006 13:24 |