|
[Sponsors] |
August 5, 2014, 09:42 |
Very simple question
|
#1 |
New Member
Join Date: Jul 2014
Posts: 6
Rep Power: 12 |
Hi everybody, I'm trying to validate my code and I discovered that there is a problem in some loops. In particular, I found out that if I make 2 identic loops over cells, I do not obtain the same results. So, in a very simple way, I obtain that the following code gives:
number of cells from loop 1 = 1041 number of cells from loop 2 = 847 The problem is that 2 loops are identical and that I have a mesh of 2024 cells. DEFINE_ADJUST(adjust_gradient, d) { Thread *t; cell_t c; int i; i=0; thread_loop_c (t,d) { begin_c_loop (c,t) { i+=1; printf("boucle cell %d \n", i); } end_c_loop (c,t) } } DEFINE_ADJUST(adjust_grad, d) { Thread *t; cell_t c; int k; k=0; thread_loop_c (t,d) { begin_c_loop (c,t) { k+=1; printf("boucle cell2 %d \n", k); } end_c_loop(c,t) } } Can anybody help me? Stefano |
|
August 5, 2014, 21:49 |
|
#2 |
Senior Member
|
You should have got thousands of lines of output. Try to print the result at the end of loop:
Code:
DEFINE_ADJUST(adjust_gradient, d) { Thread *t; cell_t c; int i; i=0; thread_loop_c (t,d) { begin_c_loop (c,t) { i+=1; } end_c_loop (c,t) } printf("boucle cell %d \n", i); } |
|
August 6, 2014, 03:55 |
|
#3 |
New Member
Join Date: Jul 2014
Posts: 6
Rep Power: 12 |
Thank you blackman!! Indeed I have thousands of lines but I did intentionally for looking all loops!
I run in parallel mode cause I compile it on Windows. I do not really understand how a so simple action could be wrong!!! |
|
August 20, 2014, 05:21 |
|
#4 |
Member
Join Date: Jul 2013
Posts: 80
Rep Power: 13 |
In not that simple actually, you have to take into account parallel considerations.
Note that you will find very different result according to the number of partitions of your case. DEFINE_ADJUST(adjust_gradient, d) { Thread *t; cell_t c; int i; i=0; thread_loop_c (t,d) { begin_c_loop (c,t) { i+=1; } end_c_loop (c,t) } i=PRF_GISUM1(i); printf("boucle cell %d \n", i); } I think it will work that way, I didn't test it. For further information, read that chapter of your manual. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[blockMesh] mergePatchPairs(); simple question | seav | OpenFOAM Meshing & Mesh Conversion | 0 | May 2, 2014 09:57 |
Simple Outlet Question | m.nichols19 | OpenFOAM | 3 | June 25, 2010 02:44 |
Simple Question Regarding Symmetry Planes | Atella | CFX | 3 | April 11, 2010 07:44 |
Simple Question Regarding Symmetry Planes | Atella | Main CFD Forum | 0 | April 9, 2010 11:58 |
Question of Anil Date's SIMPLE method | universez | Main CFD Forum | 0 | November 18, 2009 21:12 |