<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<pre wrap="">Hi Vijay,
<blockquote type="cite"><pre wrap="">Yes, you can check for psize==1 and do something optimized since the
sequences are always contiguous. If psize>1, you can use the iterator
and not worry about traversing the Range object, immaterial of how
segmented the data may be.
</pre></blockquote>Agreed. GeomTopoTool currently does just that. I was thinking that you could optimize the contiguity check further by never determining the total number of pairs, but rather by determining that there is no more than one pair. The explicit method I added and tested in a branch on my fork was
inline bool contiguous()
{ return ( <ins style="display: inline-block; margin-top: -1px; text-decoration: none; background-color: rgb(151, 242, 149);">++const_pair_begin</ins>() == <ins style="display: inline-block; margin-top: -1px; text-decoration: none; background-color: rgb(151, 242, 149);">const_pair_end()</ins> && !empty() ); }
This way if the Range is constructed of very segmented data, you wouldn't need to visit each pair to determine that. Whether or not the Range should contain something to be considered contiguous is probably up for debate...
It's just a thought. For context, this is related to some performance issues that we've seen after our refactor of some DagMC capabilities into the GeomTopoTool and GeomQueryTool. Paul created an issue explaining in more detail (<a class="moz-txt-link-freetext" href="https://bitbucket.org/fathomteam/moab/issues/73/change-contiguity-of-gtts-obb-cross">https://bitbucket.org/fathomteam/moab/issues/73/change-contiguity-of-gtts-obb-cross</a>). I don't think that our final solution to these problems will require this, but perhaps some future developer will find this matter interesting though.
Cheers,
</pre>
<pre class="moz-signature" cols="72">Patrick C. Shriwise
Research Fellow
University of Wisconsin - Madison
Engineering Research Building - Rm. 428
1500 Engineering Drive
Madison, WI 53706
(608) 446-8173
</pre>
<div class="moz-cite-prefix">On 08/09/2017 08:35 PM, Vijay S.
Mahadevan wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAOcbyd1wJrZYFhcBbfez7wS3BRE=Pq0TkdsV6h+he_mcXqb64g@mail.gmail.com">
<blockquote type="cite">
<pre wrap="">Perhaps a quicker way would be to check that there is no more than one pair
in the Range rather than iterating over them all,
</pre>
</blockquote>
<pre wrap="">
Yes, you can check for psize==1 and do something optimized since the
sequences are always contiguous. If psize>1, you can use the iterator
and not worry about traversing the Range object, immaterial of how
segmented the data may be.
</pre>
<blockquote type="cite">
<pre wrap="">but there probably aren't
many pairs in Ranges in practice. Is that right?
</pre>
</blockquote>
<pre wrap="">
This entirely depends on how you queried your data and populated the
Range object. The mesh that you load in parallel matters too. In
general, if the entities are well ordered, in serial you would have
one sequence only. In parallel, you could have 2 or more, depending on
the number of ghost entities. However, since Range is a general
object, if you were to insert just random series of entities, it will
result in a pretty segmented data underneath. You might as well be
well off using a std::vector in such a case, since you are not saving
much on memory.
Vijay
On Wed, Aug 9, 2017 at 7:52 PM, Patrick Shriwise <a class="moz-txt-link-rfc2396E" href="mailto:shriwise@wisc.edu"><shriwise@wisc.edu></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi Vijay,
After some exploring, I saw the psize method. That would do the trick.
Perhaps a quicker way would be to check that there is no more than one pair
in the Range rather than iterating over them all, but there probably aren't
many pairs in Ranges in practice. Is that right?
Cheers,
Patrick C. Shriwise
Research Fellow
University of Wisconsin - Madison
Engineering Research Building - Rm. 428
1500 Engineering Drive
Madison, WI 53706
(608) 446-8173
On 8/9/17 5:38 PM, Vijay S. Mahadevan wrote:
</pre>
<blockquote type="cite">
<pre wrap="">
Patrick, you are looking for something like Range::psize() [1], which
returns the number of non-contiguous sequences in the object. Does
that help ? If this is not what you are asking, them I'm unclear what
you mean by "rapidly check that a Range object contains a set of
contiguous values".
Vijay
[1]
<a class="moz-txt-link-freetext" href="ftp://ftp.mcs.anl.gov/pub/fathom/moab-docs/classmoab_1_1Range.html#a04d1b55838117d5ef4ba3c4dfb4d2df0">ftp://ftp.mcs.anl.gov/pub/fathom/moab-docs/classmoab_1_1Range.html#a04d1b55838117d5ef4ba3c4dfb4d2df0</a>
On Tue, Aug 8, 2017 at 11:30 PM, Patrick Shriwise <a class="moz-txt-link-rfc2396E" href="mailto:shriwise@wisc.edu"><shriwise@wisc.edu></a>
wrote:
</pre>
<blockquote type="cite">
<pre wrap="">
Hi all,
I'm wondering if there is a way to rapidly check that a Range object
contains a set of contiguous values.
Naively, it seems that this can be done by checking that it is made up of
only one pair_node by looking at the mNext & mPrev pointers to verify
this
is the case.
This would allow some MOAB interfaces (such as the GeomTopoTool) to
rapidly
determine if they are working only with contiguous EntitySets and take
advantage of this fact.
Cheers,
Patrick
</pre>
</blockquote>
</blockquote>
<pre wrap="">
</pre>
</blockquote>
</blockquote>
<br>
</body>
</html>