CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Some cells have disappeared (https://www.cfd-online.com/Forums/openfoam-programming-development/82934-some-cells-have-disappeared.html)

cfdmarkus December 9, 2010 08:42

Some cells have disappeared
 
Hi all,

I have added two lines to pisoFoam to count the number of cells:

const cellList& cells = mesh.cells();
Info << " no cells: " << cells.size() << endl;

When I run it on a single processor it counts: 1278060 cells - which is correct.
But when I decompose the case and run it on 16 processsors, the number reduces to: 79043 cells. This is approx. 1/16 of the total number of cells.

Consequently, when I loop over all cells using "forAll(cells,cellI)" some cells are always missing :(

Does anyone know why mesh.cells() does not include all cells when run in parallel and how can the missing cells be accessed?

Thanks
Markus

MartinB December 9, 2010 09:14

Hi Markus,

you must gather the information to the master:
Code:

const cellList& cells = mesh.cells();
label nCells = 0;
nCells = cells.size();
reduce(nCells, sumOp<label>());
Info << " no cells: " << nCells << endl;

Martin

cfdmarkus December 10, 2010 11:37

Thank you Martin!

impecca August 19, 2011 08:48

field manipulation with parallel computations
 
Thanks for the thread on this subject first.

I've managed to get number of cells in parallel computing as Martin suggested but I still have a problem with modifying 'field' itself. here is the code I use



const cellList& cells = mesh.cells();
label nCells = 0;
nCells= cells.size();
reduce(nCells, sumOp<label>());
scalar i = 0;

forAll(cells, celli){
i++;
}
Info<<"i= "<<i <<nl;
Info<<"nCells= " <<nCells<<nl;


with a single processor, it shows:
i= 336000
nCells= 336000

with 4 processors, it shows:
i= 84332
nCells= 336000


as you can see, nCells isn't affected by multi processing but the field loop number (i) is depending on the number of processors. So question is that is there any way that I can manipulate field (say velocity) with the parallel compuations ?
What I want to do is imposing artificial fluctuations on one plane in the middle of domain.

I also wrote same question in this forum but no response so far,
http://www.cfd-online.com/Forums/ope...mputation.html

Thanks in advance

Yusik

MartinB August 19, 2011 08:58

Hi Yusik,

you can manipulate the field within the loop:
forAll(cells, celli)
{
i++;
// your manipulation here, each processor will manipulate
// its part of the field.
}

Hmmhhh, not sure if I understand your problem correctly, maybe you can provide some code snippets of your intended algorithm...

Martin

impecca August 21, 2011 09:23

Yes, it works. you are right Martin. I was a different problem. I replied to other thread (link below). Thanks for your help. :D


http://www.cfd-online.com/Forums/ope...tml#post320892


All times are GMT -4. The time now is 01:21.