Selecting internal cells

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
James McNaughton

Selecting internal cells

Post by James McNaughton »

Hi I am selecting an internal "circle" of cells for - the following seems to work how I'd like it to by looping on all cells in a yz-plane and then testing if the cells are in the circle's radius:
call getcel('x > -0.7 and x < 0.7',nlelt,lstelt)
! ======
do iel = 1, nlelt
if ( xyzcen(2,ii)**2 + xyzcen(3,ii)**2 .lt. 1.d2 ) then
...commands...
endif
enddo


But I am wondering on the looping of all cells in this plane when my mesh size increases. I have two questions: Will it be computationally expensive? Is there a better method for selecting the cells how I would like to?
Thanks,
James
Yvan Fournier

Re: Selecting internal cells

Post by Yvan Fournier »

Hello,
A better way would be to use the following:
call getcel(cylinder[x0, y0, z0, x1, y1, z1, radius], nlelt, lstelt)
! ======

Where the cylinder is described by the centers of its "bottom" and "top" disks, and by its radius (it is necessary to replace the arguments above with real values in you case).
In any case, there will be a loop over all elements, and though the solution above is more elegant, it may actually be more expensive than just looping on all cells and using a geometrical test, as the test is not inline but done through a selection test, called for every cell.
If you notice a slowdown of the code due to this (which would be surprising, as the pressure correction step should be much more costly than this), the best solution would be to save the list of selected cells (using save attributes and an allocatable array) on the first call, to avoid retesting everything at each time step.
Best regards,
  Yvan
James McNaughton

Re: Selecting internal cells

Post by James McNaughton »

Thanks Yvan,
If getcel loops over all elements I see your point that my initial method may be less expensive. Certainly storing the cells to use may be an option to investigate if my mesh gets very big. But you were right I did really just want a more elegant solution :)
Thanks again,
James
Post Reply