How how do I select only some of the cells?

Hi all,
I am working with the permeability example ( and I have to compute density of the fluid cells, without to take into account the porous medium cells. How do I select only the fluid cells? I guess that I could use the array “geometry”, and to create a Box3D with the only fluid cell, but I don’t know in what way.

Thanks in advance.

HI maxerrimus,

with the method “computeDensity” you can obtain the density of each cell of your lattice. Since the cells which are bounce-back and NoDynamic do not evolve in the simulation their density will be 0. In this case, as result, you will have a scalar field which you can also plot as VTK. What do you need more? I’m not sure I understood well what you are asking.

Anyway, as general rule, you can perform calculations on the single cells using data processors. In this particular case, for example, you can write a data processor called obtainrho which inherits the class “BoxProcessingFunctional3D_LS”. You can then override the method process and use the scalar field geometry to accede to all the fluid nodes.


Hi sdea,
thank you for the reply. The question is: Is there any way to understand if a cell is “bounce-back” and “NoDynamic”? Perhaps a flag or something else for each cell?


The scalar-field “geometry” is a mask which has value 0 for fluid cells, 1 for bounce-back and 2 for no-dynamics. You can use it to apply functions like “computeSum” or “computeAverage” to selected cells only. For example, to compute the averageDensity, you would do something like

computeAverage(*computeDensity(lattice), geometry, 0);

to compute the average density over fluid cells only.


Hi Jonsa,
thank you very much. I meant just something like your solution. And for selecting cells in a chosen location? How can I select only fluid cells located in a specific box?


Something like

computeAverage(*computeDensity(lattice), geometry, 0, Box3D(x0, x1, y0, y1, z0, z1));


Thank Jonas. Your post is very useful for my case.