Intersection::indexInOutside() crashes on locally refined grids
The implementation on the leaf grid view uses the following code:
// Move to the father of the facet until its level is the same as
// the level of the neighbor
FoamGridEntityImp<dimgrid-1, dimgrid, dimworld>* facet=(this->center_->facet_[this->facetIndex_]);
while(facet->level()<(*this->neighbor_)->level())
{
assert(facet->father_!=nullptr);
facet=facet->father_;
}
assert(facet->level()==(*this->neighbor_)->level());
This looks wrong: if the condition is true
, it uses the coarser father of facet
, reducing the level even further.
However just using >
instead doesn't handle the <
case (which seems to occur as well).
Attached is a small example program demonstrating the crash. It should exit with an assertion failure.