CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   How to iterate over all cells in decomposed mesh (http://www.cfd-online.com/Forums/openfoam-solving/59366-how-iterate-over-all-cells-decomposed-mesh.html)

tehache October 23, 2007 06:08

Hi everybody, Could someone
 
Hi everybody,

Could someone give me a hint on how to iterate over all cells of a decomposed mesh?

After naively using it for quite some time, I just found out that mesh.cells() gives me only the cells of one partition http://www.cfd-online.com/OpenFOAM_D...lipart/sad.gif

Thank you!

Thomas

gschaider October 23, 2007 07:14

Hi Thomas! That's the whole
 
Hi Thomas!

That's the whole point of parallelizing: every processor is responsible for "his" cells. If one processor could loop over all cells it would no longer be parallel.

What do you want to do? If it is something like counting cells with a specific property (that's one of the reasons why you might want to do this), then you should do it as usual and use something like

reduce(cnt,sumOp<label>());

to calculate the sum over all processors and distribute it to all processors

Bernhard

tehache October 23, 2007 07:44

Hi Bernhard, Actually, I wa
 
Hi Bernhard,

Actually, I was looking for a cell at a specific location to set a reference value there (fvMatrix::setReference).
I think I ran into a trap with that idea ... now apperently every processor is setting reference at a different cell..
Isn't there some way, even doing communication, to globally find a cell?
Just tried findNearestCell(), but seems to work also ony within one processors cells...

gschaider October 23, 2007 09:26

Hi Thomas! Something like t
 
Hi Thomas!

Something like this?

label cellI=mesh.findCell(location);
if(cellI>=0) {
matrix.setReference(cellI,value);
}

That'd set the reference only on the processor that has the cell in question, I guess.

Bernhard

tehache October 23, 2007 10:06

Thx a lot! Thats it. And s
 
Thx a lot!

Thats it.
And so easy.... shame on me http://www.cfd-online.com/OpenFOAM_D...part/happy.gif


All times are GMT -4. The time now is 03:06.