Or do they?  ;-)

In FE::reinit() there is a lot of work done to see if we can reuse the shape 
function values from the previous element.  This is a laudable goal... but 
there is something not quite right.

Around line 184 there is a check to see if the distances between nodes in the 
the current elem match the distances between nodes in the last element... 
trying to see if they are exactly the same shape.  Unfortunately it checks to 
see if they are the same by doing:

if((elem->point(n) - elem->point(0)) != cached_nodes[n] - cached_nodes[0]))

The trouble is that those Points are made up of floating point values... and 
any machine precision issues will cause this to fail.

Now, this isn't exactly a _bug_... because this is an extremely conservative 
check... but it does lead to some weird situations.  I ran into this because I 
noticed that for a particular 4th order problem I was solving today if I 
generated the mesh with 80x80 elements it ran about 10 times faster than if I 
generated it with 79 (or even 60)!  Indeed I could get this behavior by using 
any multiple of 80... including 40 and 160 (yes... 160x160 ran MUCH faster than 
79x79!).  After tracking it down for a while I figured out that it was making 
bazillions more calls to init_shape_functions() when the mesh wasn't a multiple 
of 80x80.... and that eventually led me to this check.

For whatever reason, on my architecture build_square() built meshes will fail 
this check unless the number of elements is a multiple of 80x80 (note that I 
haven't exhaustively investigated this claim yet... although I did try changing 
the size of the domain a bit and still saw this issue).

To "fix" this I propose using relative_fuzzy_equals() like so:

if (!(elem->point(n) - elem->point(0)).relative_fuzzy_equals((cached_nodes[n] - 
cached_nodes[0])))

But of course this could have the bad side effect of false positives... ie two 
elements that are _extremely_ similar but not exactly and still pass this check.

So what do you guys think?  Is this a valid thing to do... or is it just too 
unsafe?  Is there a better option?

Derek
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Libmesh-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-devel

Reply via email to