From: li p. <li...@ya...> - 2006-05-18 14:24:20
|
dear developers, can I just call this function without any additional work? I mean, just MeshBase::const_element_iterator el=mesh.elements_begin(); const MeshBase::const_element_iterator end_el = mesh.elements_end(); for ( ; el != end_el; ++el) { elem = *el; el->contains_point(p); } kind regards pan __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: David K. <dav...@ba...> - 2006-05-18 15:29:44
|
Pan, contains_point is defined as virtual in Elem, so you can't call it directly on an Elem*. I suppose you'd have to cast the Elem* to whatever element type it actually is so that you can use contains_point. Perhaps there is a nicer way? - David > MeshBase::const_element_iterator > el=mesh.elements_begin(); > const MeshBase::const_element_iterator end_el = > mesh.elements_end(); > for ( ; el != end_el; ++el) > { > elem = *el; > el->contains_point(p); > } > > kind regards > > pan > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > > > ------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Libmesh-users mailing list > Lib...@li... > https://lists.sourceforge.net/lists/listinfo/libmesh-user |
From: Roy S. <roy...@ic...> - 2006-05-18 15:40:43
|
On Thu, 18 May 2006, David Knezevic wrote: > Pan, contains_point is defined as virtual in Elem, so you can't call it > directly on an Elem*. This is the point of virtual functions - you call it on an Elem* and it uses the virtual function table to jump to whichever code corresponds to your specific subclass. >> MeshBase::const_element_iterator >> el=mesh.elements_begin(); >> const MeshBase::const_element_iterator end_el = >> mesh.elements_end(); >> for ( ; el != end_el; ++el) >> { >> elem = *el; >> el->contains_point(p); contains_point() returns a bool and shouldn't have any side effects; there's no reason to call it unless you use that return value (presumably to break out of the for loop early). Also, you probably only want to loop through active local elements, not all elements. Notice that this loop is O(N) in the number of elements, by the way. If there is no outer loop, that's probably fine, but if you're needing to find the elements containing lots of points you should probably look at the MeshFunction or PointLocatorTree classes. --- Roy Stogner |