Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #pragma once 11 : 12 : namespace // Anonymous namespace for helpers 13 : { 14 : /** 15 : * Specific weak ordering for Elem *'s to be used in a set. 16 : * We use the id, but first sort by level. This guarantees 17 : * when traversing the set from beginning to end the lower 18 : * level (parent) elements are encountered first. 19 : * 20 : * This was swiped from libMesh mesh_communication.C, and ought to be 21 : * replaced with libMesh::CompareElemIdsByLevel just as soon as I refactor to 22 : * create that - @roystgnr 23 : */ 24 : struct CompareElemsByLevel 25 : { 26 0 : bool operator()(const Elem * a, const Elem * b) const 27 : { 28 : libmesh_assert(a); 29 : libmesh_assert(b); 30 0 : const unsigned int al = a->level(), bl = b->level(); 31 : const dof_id_type aid = a->id(), bid = b->id(); 32 : 33 0 : return (al == bl) ? aid < bid : al < bl; 34 : } 35 : }; 36 : 37 : } // anonymous namespace