1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Multi-dimensional renumbering used in the Numerical Recipes
27 fft routine. This version is recursive, so works in n-d :
28 determined by the length of array nn
30 \*---------------------------------------------------------------------------*/
32 #include "fftRenumber.H"
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 // recursively evaluate the indexing necessary to do the folding of
42 // the fft data. We recurse until we have the indexing ncessary for
43 // the folding in all directions.
45 void fftRenumberRecurse
48 List<complex>& renumData,
58 // we've worked out the renumbering scheme. Now copy
59 // the components across
61 data[l1] = complex(renumData[l2].Re(),renumData[l2].Im());
65 // do another level of folding. First work out the
66 // multiplicative value of the index
71 for (label i=0; i<nn[ii]; i++)
73 // now evaluate the indices (both from array 1 and to
74 // array 2). These get multiplied by nnprod to (cumulatively)
75 // find the real position in the list corresponding to
76 // this set of indices.
88 // go to the next level of recursion.
105 // fftRenumber : fold the n-d data array to get the fft components in
108 #include "fftRenumber.H"
116 List<complex> renumData(data);
119 for (label i=0; i<nn.size(); i++)
124 label ii(0), l1(0), l2(0);
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 } // End namespace Foam
143 // ************************************************************************* //