36 #define SWAP(a,b) tempr=(a); (a)=(b); (b)=tempr
37 #define TWOPI 6.28318530717959
51 unsigned int dimCount = nn[idim];
52 if (!dimCount || (dimCount & (dimCount - 1)))
55 <<
"number of elements in direction " << idim
56 <<
" is not a power of 2" <<
endl
57 <<
" Number of elements in each direction = " << nn
64 label i1, i2, i3, i2rev, i3rev, ip1, ip2, ip3, ifp1, ifp2;
65 label ibit, k1, k2,
n, nprev, nrem, idim;
67 scalar theta, wi, wpi, wpr, wr, wtemp;
68 scalar* data =
reinterpret_cast<scalar*
>(field.
begin()) - 1;
88 for (idim=ndim; idim>=1; idim--)
91 nrem = ntot/(
n*nprev);
97 for (i2=1; i2<=ip2; i2+=ip1)
101 for (i1=i2; i1<=i2 + ip1 - 2; i1+=2)
103 for (i3=i1; i3<=ip3; i3+=ip2)
105 i3rev = i2rev + i3 - i2;
106 SWAP(data[i3], data[i3rev]);
107 SWAP(data[i3 + 1], data[i3rev + 1]);
113 while (ibit >= ip1 && i2rev > ibit)
127 theta = isign*
TWOPI/(ifp2/ip1);
128 wtemp =
sin(0.5*theta);
129 wpr = -2.0*wtemp*wtemp;
134 for (i3 = 1; i3 <= ifp1; i3 += ip1)
136 for (i1 = i3; i1 <= i3 + ip1 - 2; i1 += 2)
138 for (i2 = i1; i2 <= ip3; i2 += ifp2)
142 tempr = scalar(wr*data[k2]) - scalar(wi*data[k2 + 1]);
143 tempi = scalar(wr*data[k2 + 1]) + scalar(wi*data[k2]);
144 data[k2] = data[k1] - tempr;
145 data[k2 + 1] = data[k1 + 1] - tempi;
147 data[k1 + 1] += tempi;
151 wr = (wtemp = wr)*wpr - wi*wpi + wr;
152 wi = wi*wpr + wtemp*wpi + wi;
170 scalar recRootN = 1.0/
sqrt(scalar(ntot));
174 field[i] *= recRootN;
234 tfftVectorField.
ref().replace
243 return tfftVectorField;
263 tifftVectorField.
ref().replace
272 return tifftVectorField;
#define forAll(list, i)
Loop across all elements in list.
Pre-declare SubField and related Field type.
void size(const label)
Override size to be inconsistent with allocated storage.
iterator begin()
Return an iterator to begin traversing the UList.
static const direction nComponents
Number of components in this vector space.
static tmp< complexField > reverseTransform(const tmp< complexField > &field, const labelList &nn)
static void transform(complexField &field, const labelList &nn, transformDirection fftDirection)
static tmp< complexField > forwardTransform(const tmp< complexField > &field, const labelList &nn)
A class for managing temporary objects.
void clear() const
If object pointer points to valid object:
T & ref() const
Return non-const reference or generate a fatal error.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Multi-dimensional renumbering used in the Numerical Recipes fft routine.
void fftRenumber(List< complex > &data, const labelList &nn)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
errorManip< error > abort(error &err)
dimensionedScalar sin(const dimensionedScalar &ds)
Field< complex > complexField
Specialisation of Field<T> for complex.
dimensionedScalar sqrt(const dimensionedScalar &ds)