Page 1 of 1

Selecting internal cells

Posted: Mon Sep 13, 2010 12:44 pm
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

Re: Selecting internal cells

Posted: Mon Sep 13, 2010 4:58 pm
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

Re: Selecting internal cells

Posted: Wed Sep 15, 2010 2:39 pm
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