On Tue, 17 Jul 2012, Paul T. Bauman wrote:
Sorry if this is a stupid question, but why are dphidx, dphidy, etc. being
explicitly stored in FEGenericBase? We are duplicating what's stored in dphi
and d2phi.
Two generic reasons for storing separate scalar components:
Backwards compatibility. IIRC the dphidx etc. arrays existed first,
then the Gradient dphi array was added to allow simpler user code, but
the old arrays were kept so as not to break old code. In hindsight we
should have gotten rid of the old arrays years ago, but with a year or
more of libmesh_deprecated() warning to give people time to change
their apps. I'd love to deprecate those arrays immediately, but I'd
hate to spring that change on people in a apps-suddently-wont-compile
way.
Efficiency. IIRC the Phalanx people discovered that compilers are
much better at vectorizing operations (autogenerating SIMD code) when
the stride between those MD is 1 (as in scalar arrays) rather than 3
or 9 (as in 3-vector or 3x3-tensor arrays). However, this is just
theoretical for us - since we order our arrays phi[i][qp] instead of
phi[qp][i] but we typically want the quadrature point loop to be
outermost, we end up having a huge stride regardless. In our case it
would be more efficient to remove the scalar arrays just to avoid the
redundant copying.
What's wrong with just returning dphi[i][qp].slice(0) for dphidx,
etc.? AFAICT, dphidx etc. are only ever set, they're never explicitly used
in the library. We can remove them and still preserve the API.
How, exactly? It's possible for user code to get_dphidx() *outside*
an element loop, but expect the returned reference to continue to
point to a modified-at-each-reinit scalar array at each element inside
the loop. We could do something like the current calculate_dphi
tricks to update dphidx if-and-only-if it's been requested, but I'd
think this would make your code more complicated rather than less.
---
Roy
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Libmesh-devel mailing list
Libmesh-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-devel