CFD Online Logo CFD Online URL
Home > Forums > FLUENT

Looping over cells

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

LinkBack Thread Tools Display Modes
Old   March 26, 2002, 11:18
Default Looping over cells
Posts: n/a
I have written a simple udf that loops over all the cells in a single cell zone of my domain, and writes values of certain flow variables in these cells to a file. (The entire domain consists of two zones, one zone is sliding, the other zone for which cell looping is being done is stationary).

My udf works fine on NT serial solver. When I run on SGI parallel solver, only about 1/4th of the cells are being written. The mesh is partitioned into four partitions. It seems like only cells in a single partition are being looped over (I have no way to check for sure though, since there is no simple way to know which cells are in which partition - and I would like to avoid this kind of lengthy analysis anyway).

I know that in some cases for NT you are supposed to do something special for parallel solver, but I do not see anything special to be done in writing the udf for parallel solver.

I am wondering if anyone has encountered this problem with Fluent 6, and also if anyone has specific suggestions to resolve.


  Reply With Quote

Old   March 26, 2002, 21:56
Default Re: Looping over cells
Greg Perkins
Posts: n/a
There's a couple of points to your problem.

First when writing files for a parallel program requires some additional thought. If all your parallel nodes write to the file at the same time, the results are not defined, unless you implement some sort of access control strategy to avoid clashes between the nodes when writing to the same file. This is a fairly well-known problem in parallel programming.

One way around this in Fluent is to restrict writing to the file to just one of the nodes. However, this creates a potential problem since this node can only access the cells on its partition and the common ones at the partition boundaries.

Another way is to get each node to write to a separate file and then once all nodes have completed this task, concatenate the node files into a single file.

This is relatively easy to do (I think). First define the filename based on the node number. Fluent uses nodes and 1 host. A node is defined and its partition number of process id is given by my_id.

#if RP_NODE /* --- I'm a ndoe process - id = my_id */ node_id = my_id; #endif

So you can create a filename using my_id in the name. Then run your udf with this mod.

Then write another udf or script to concatenate the files. If you use a udf for this, you'll have to get the total number of processes. I recommended running this udf only on the host process. The host is defined as:

#if !RP_NODE

/* --- I'm a host process ! */ #endif

I just had a look at para.h and there is a variable called compute_node_count which looks like it would contain the total number of compute nodes. You can also find looping macros which will enable you to loop over your files and then concatenate into a single one.

Hope it Helps Greg
  Reply With Quote

Old   March 26, 2002, 22:16
Default Re: Code Snippets for You
Greg Perkins
Posts: n/a
Here's some code snippets for how to do what I suggested:

/* --- node file writer */ DEFINE_ON_DEMAN(EXEC_Write_Node_File) { #if RP_NODE

char filename[100];


/* ---- write you cell data to this file as before */

#endif }

/* ---- concatenate files together */ DEFINE_ON_DEMAND(EXEC_Concate_Files) { #if !RP_NODE

int i;

/* --- open a main output file here */

/* --- loop over node files */

for(i=0; i<compute_node_count; i++)


/* --- read node file i and write to main output file */

/* --- close node file i */


/* --- close main file */

#endif }

Let me know if it works since I haven't tried this before and just made it up then!

  Reply With Quote

Old   March 26, 2002, 22:17
Default Re: Code Snippets for You - Opps
Greg Perkins
Posts: n/a
the loop over compute ndoes line should be:

for(i=0; i<compute_node_count; i++)

  Reply With Quote

Old   March 26, 2002, 22:18
Default Re: Code Snippets for You - OppsAgain
Greg Perkins
Posts: n/a
Something wrong with browser try:

for(i=0; i .LE. compute_node_number; i++)

and replace .LE. with less than equal to sign for C.

  Reply With Quote


Thread Tools
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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Import netgen mesh to OpenFOAM hsieh Open Source Meshers: Gmsh, Netgen, CGNS, ... 32 September 13, 2011 05:50
snappyHexMesh won't work - zeros everywhere! sc298 OpenFOAM Native Meshers: snappyHexMesh and Others 2 March 27, 2011 21:11
snappyHexMesh aborting Tobi OpenFOAM Native Meshers: snappyHexMesh and Others 0 November 10, 2010 04:23
external flow with snappyHexMesh chelvistero OpenFOAM 11 January 15, 2010 20:43
physical boundary error!! kris CD-adapco 2 August 3, 2005 00:32

All times are GMT -4. The time now is 20:10.