Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

## libmesh-users

 [Libmesh-users] Testing if element is on boundary From: - 2005-01-11 01:22:32 ```Hi Maybe a stupid question: Why is the following construct used in all the examples to determine that an element lives on the boundary? for (unsigned int s=0; sn_sides(); s++) if (elem->neighbor(s) == NULL) Would'nt this be faster / more obvious if one would use if (elem->on_boundary()) and then use the boundary side iterators (Elem::boundary_sides_begin)? Thanks for clarification Martin ```
 [Libmesh-users] Testing if element is on boundary From: John Peterson - 2005-01-11 14:40:14 ```Martin L=FCthi writes: > Hi >=20 > Maybe a stupid question: Why is the following construct used in all > the examples to determine that an element lives on the boundary? >=20 > for (unsigned int s=3D0; sn_sides(); s++) > if (elem->neighbor(s) =3D=3D NULL) >=20 > Would'nt this be faster / more obvious if one would use >=20 > if (elem->on_boundary()) >=20 > and then use the boundary side iterators (Elem::boundary_sides_begin= )? Heh, yes probably. The boundary side iterators were only recently added, the rest of the code hasn't been updated yet. -John ```
 Re: [Libmesh-users] Testing if element is on boundary From: Roy Stogner - 2009-06-03 15:06:35 ```On Mon, 10 Jan 2005, Martin Lüthi wrote: > Maybe a stupid question: Why is the following construct used in all > the examples to determine that an element lives on the boundary? > > for (unsigned int s=0; sn_sides(); s++) > if (elem->neighbor(s) == NULL) > > Would'nt this be faster / more obvious if one would use Faster, no (the side iterators basically do the same thing "behind the scenes"). More obvious, maybe. > if (elem->on_boundary()) > > and then use the boundary side iterators (Elem::boundary_sides_begin)? Probably because both Elem::on_boundary and the boundary side iterators postdate the examples? Although, if the boundary side iterators are written properly, the elem->on_boundary() call would be redundant; on non-boundary elements you'd have boundary_sides_begin == boundary_sides_end and no iteration would be done. --- Roy```