CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Loop over cells per processor (parallel) (http://www.cfd-online.com/Forums/openfoam-programming-development/104341-loop-over-cells-per-processor-parallel.html)

bme79 July 7, 2012 12:56

Loop over cells per processor (parallel)
 
Hi I got a problem and I have read a lot of posts on a different forums but still could not find a solution. I am doing something wrong. Could some one help me out.

Basically when I run my program on single processor it works fine but when on parallel it does not.
I am using the loop

forAll(mesh.C(),celli){

x = mesh.C()[celli].component(0);
y = mesh.C()[celli].component(1);
z = mesh.C()[celli].component(2);
arr = getnewvelocity(rho, U[celli].x(), U[celli].y(), U[celli].z(), p[celli]);

// .......

}

I found a post on this forum suggesting to use "reduce" command but it means that I send all data from all proc to one. I dont want this. I wan to go through all cells per processor.

Could some one give me an advise or example.
Thank you

gschaider July 7, 2012 18:32

Quote:

Originally Posted by bme79 (Post 370238)
Hi I got a problem and I have read a lot of posts on a different forums but still could not find a solution. I am doing something wrong. Could some one help me out.

Basically when I run my program on single processor it works fine but when on parallel it does not.
I am using the loop

forAll(mesh.C(),celli){

x = mesh.C()[celli].component(0);
y = mesh.C()[celli].component(1);
z = mesh.C()[celli].component(2);
arr = getnewvelocity(rho, U[celli].x(), U[celli].y(), U[celli].z(), p[celli]);

// .......

}

I found a post on this forum suggesting to use "reduce" command but it means that I send all data from all proc to one. I dont want this. I wan to go through all cells per processor.

Well you can. But you must realize that in parallel this only goes through all the cells that are on this processors. But on all processors. Which makes it alright

Whether you want to do a reduce or not is irrelevant: it depends on what is happening in the location where you put the 7 points. May be that you don't need a reduce. May be that you need it after the loop.
Quote:

Originally Posted by bme79 (Post 370238)
Could some one give me an advise or example.
Thank you

That is hard without knowing what the 7 points do


All times are GMT -4. The time now is 13:43.