|
[Sponsors] |
March 26, 2002, 11:18 |
Looping over cells
|
#1 |
Guest
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. Thanks |
|
March 26, 2002, 21:56 |
Re: Looping over cells
|
#2 |
Guest
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 |
|
March 26, 2002, 22:16 |
Re: Code Snippets for You
|
#3 |
Guest
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]; sscanf(filename,"cell_file_node-%d",my_id); /* ---- 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! Greg |
|
March 26, 2002, 22:17 |
Re: Code Snippets for You - Opps
|
#4 |
Guest
Posts: n/a
|
the loop over compute ndoes line should be:
for(i=0; i<compute_node_count; i++) Greg |
|
March 26, 2002, 22:18 |
Re: Code Snippets for You - OppsAgain
|
#5 |
Guest
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. Greg |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Netgen] Import netgen mesh to OpenFOAM | hsieh | OpenFOAM Meshing & Mesh Conversion | 32 | September 13, 2011 06:50 |
[snappyHexMesh] snappyHexMesh won't work - zeros everywhere! | sc298 | OpenFOAM Meshing & Mesh Conversion | 2 | March 27, 2011 22:11 |
[snappyHexMesh] snappyHexMesh aborting | Tobi | OpenFOAM Meshing & Mesh Conversion | 0 | November 10, 2010 04:23 |
[snappyHexMesh] external flow with snappyHexMesh | chelvistero | OpenFOAM Meshing & Mesh Conversion | 11 | January 15, 2010 20:43 |
physical boundary error!! | kris | Siemens | 2 | August 3, 2005 01:32 |