On Fri, Oct 15, 2010 at 8:08 AM, Derek Gaston <[email protected]> wrote: > Tim, we recently did something similar... and I think you can do this > much more efficiently another way. Instead of looking for what > element the point is in then finding the closest node.... just look > for the closest node directly then access the dof of the variable out > of the node and use that to index into the solution vector. > > Writing a loop over all nodes (or all nodes in a sideset) that checks > the distance to a point is a trivial exercise... and MUCH faster than > calling is_in_elem(). The only time I could see the search algorithm > in meshfunction winning is if you started off with a single element > mesh and uniformly refined it 10 or more times (because then the built > in search will be able to traverse the refinement tree and quickly > hone in on the position). But this is rarely the case.
I agree the code is simpler, and will definitely be faster if you only have to check a subset of nodes, but you still have to check *all* the nodes in that list, whereas you can stop once you find the element which contains the point. In a 2D mesh of triangles, for example, there are about half as many elements as there are nodes... Perhaps this doesn't change the theoretical complexity of the algorithm from O(N) but it seems like it has the potential to be faster. Maybe we should look at how our test for whether a point is inside an element is actually implemented... perhaps it could be made faster. In terms of a general library function, we should decide what happens when the search point is equi-distant, to within some tolerance, to two or more nodes of the containing element. Always pick the node of lower ID? -- John ------------------------------------------------------------------------------ Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev _______________________________________________ Libmesh-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libmesh-devel
