[MOAB-dev] iMesh_stepIter

Steve Jackson stjackson at wisc.edu
Wed Feb 29 10:33:10 CST 2012


On Feb 27, 2012, at 13:07 , James Porter wrote:

> Any decision on whether we should add this or not?

Here's an update on my experiences faking this behavior using the stepIter function on array iterators of length 2:

After using pytaps to build a structured mesh of size 100x100x100, I walked over the whole mesh in a non-standard iteration order.  My iteration algorithm works as follows:

* Find the i,j,k coordinates of the next mesh element.
* Compute N, the offset from the zeroth hexahedron in the mesh, based on i, j, and k.
* Advance a pytaps array iterator N steps using a single call to stepIter.
* Return the first item from this pytaps iterator, and reset the iterator.

The bad news: while a standard pytaps iterator can walk over a 1 million element mesh in under a second, this customized approach takes more than ten minutes.  Unless the stepIter function for a non-array iterator is likely to be much faster than the array iterator, this algorithm is probably going to remain unusably slow in pytaps.

Options:

1) I can create a mapping in python of (i,j,k) coordinates -> entities handles.  This is potentially expensive in memory, though.
2) We can arrange a way to do math on entities handles, allowing me to add N to zeroth handle in the structured mesh and so advance to the Nth element in (smaller) constant time.

Tim / Jim, I'm available most of today if you want to talk about the details of this issue.  I should be in my office before 11am.
~S


> On Wed, 2012-02-22 at 15:56 -0600, Steve Jackson wrote:
>> On Feb 22, 2012, at 15:45 , James Porter wrote:
>> 
>>> On Wed, 2012-02-22 at 15:38 -0600, Tim Tautges wrote:
>>>> What's the difference between that and getNextEntIter?  If you're likely to want to step over multiple items, wouldn't 
>>>> you already be using an ArrIter?
>>> 
>>> I'll let Steve chime in on this, but this is part of working with
>>> structured meshes. I think Steve wants to get one element at a time, but
>>> sometimes he needs to skip ahead to get to the elements he cares about.
>>> Since doing that with getNextEntIter is an O(N) operation, it's not as
>>> good as using stepIter, which is O(1), at least for list-type sets.
>> 
>> Jim's correct: what I'm after is a fast way to jump to a given element (i,j,k) in a structured mesh, knowing only the structured mesh's dimensions, and the order in which vertices and elements are stored (i.e. fortran-order, with the x dimension changing fastest).  iMesh offers no way to walk over the elements of a set except iterators; in this case, I want the N'th item an iterator will give me, but I don't want to step it N times.  
>> 
>> In C-level iMesh I could cheat and do math on EntityHandles (by assuming that a structured mesh has contiguous and ordered handles), but PyTAPS doesn't allow mathematics on handles.  Even if it did, I'd rather be able to access structured mesh elements without having to go behind the library's back by manipulating its (theoretically opaque) handles mathematically.
>> ~S
> 



More information about the moab-dev mailing list