libMesh / libmesh

libMesh github repository
http://libmesh.github.io
GNU Lesser General Public License v2.1
652 stars 286 forks source link

Iterating over semi local elements fails on refined meshes #974

Open dschwen opened 8 years ago

dschwen commented 8 years ago

Incrementing the iterator obtained via .semilocal_elements_begin() can trigger an Assertionstart_elem->active()' failed.`

This will fix idaholab/moose#7097

dschwen commented 8 years ago

@jwpeterson has proposed a fix for this: adding

this->_predicates.push_back(new active<T>)

to the SemiLocal multi-predicate. This seems to fix the issue I observe.

jwpeterson commented 8 years ago

Will make PR momentarily...

roystgnr commented 8 years ago

Semilocal elements are not necessary active elements, and we may already have other code in which that assumption is important. The fix here should probably be two-fold: create a semilocal_active_elements_foo() pair of iterators if that's what you need, and fix the iteration in the semilocal_elements_foo() iterators too.

roystgnr commented 8 years ago

Huh. We do rely on find_point_neighbors(), which does assert active(). This seems like the underlying bug...

jwpeterson commented 8 years ago

OK, so you think that find_point_neighbors() shouldn't assert this?

roystgnr commented 8 years ago

No, find_point_neighbors() was definitely written to work for active elements only. Perhaps what we need to be doing is, for inactive elements, looping over the children and testing is_semilocal() on each of them?

roystgnr commented 8 years ago

Yeah, that sounds like the right fix - iff any descendant of mine is semilocal, then so am I. Could be slow as hell to iterate through the low level ancestors... but I suppose the number of remote ancestors decreases exponentially with level. And I don't think there's any other safe way to handle it.

jwpeterson commented 8 years ago

OK, is there any reason to have #975 as a temporary quick fix until someone implements this loop over children checking for semi-locality? Otherwise I will just close that...