On 6/10/11 12:05 PM, John Peterson wrote:
> On Fri, Jun 10, 2011 at 9:50 AM, Ataollah Mesgarnejad
> <[email protected]> wrote:
>> Dear all,
>>
>> Is there a way to implement a fourth order tensor A_ijkl using libmesh
>> native classes?
>
> Nope.
>
>> If not how do you recommend to do it ?
>
> If it has a fixed size I * J * K * L:
>
> Real tensor[I][J][K][L];
>
> If the size is variable, you could use a
>
> vector<vector<vector<vector<Real> > > >
>
> (This is one reason why Fortran programmers think C++ is dumb.)
>
> but a better idea would be to write a class which wraps the data
> structure above or a 1D vector and do array subscripting tricks.
>
> If you want to bring external libraries into the mix, there is
> probably a good one out there. Don't know of one off the top of my
> head.
One external library that might be worth considering for this kind of
stuff is Blitz++, which provides "tensor-like" notation that can make
dealing with higher order tensors less painful:
http://www.oonumerics.org/blitz/docs/blitz_3.html#SEC99
(It is also easy to get carried away and write very cryptic array
expressions.)
Blitz++ development has slowed over the last several years, and so to
get the most recent released version (0.9) to run on recent C++
compilers, it may be necessary to patch the source code, e.g.:
http://sharpen.che.caltech.edu/mediawiki/index.php/Patching_blitz_0.9
If you download the source from their repo, I think it should work
without patching.
-- Boyce
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Libmesh-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-users