Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F61079120
fftransform_fftw.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, May 4, 09:57
Size
3 KB
Mime Type
text/x-c++
Expires
Mon, May 6, 09:57 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17427666
Attached To
rTAMAAS tamaas
fftransform_fftw.cpp
View Options
/**
* @file
*
* @author Lucas Frérot <lucas.frerot@epfl.ch>
*
* @section LICENSE
*
* Copyright (©) 2016 EPFL (Ecole Polytechnique Fédérale de
* Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
* Solides)
*
* Tamaas is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Tamaas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Tamaas. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "fftransform_fftw.hh"
__BEGIN_TAMAAS__
template <typename T, UInt dim>
FFTransformFFTW<T, dim>::FFTransformFFTW(Grid<T, dim>& real,
GridHermitian<T, dim>& spectral)
: FFTransform<T, dim>(real, spectral), forward_plan(NULL),
backward_plan(NULL) {
TAMAAS_ASSERT(real.getNbComponents() == spectral.getNbComponents(),
"components for FFTW do not match");
// Data pointers
Real* in = this->real.getInternalData();
fftw_complex* out =
reinterpret_cast<fftw_complex*>(this->spectral.getInternalData());
int components = real.getNbComponents();
// fftw parameters
int rank = dim; // dimension of fft
int n[dim] = {0};
std::copy(real.sizes().begin(), real.sizes().end(),
n); // size of individual fft
int howmany = components; // how many fft to compute
int idist = 1, odist = 1; // components are next to each other in memory
int istride = components, ostride = components;
int *inembed = NULL, *onembed = NULL; // row major
forward_plan =
fftw_plan_many_dft_r2c(rank, n, howmany, in, inembed, istride, idist, out,
onembed, ostride, odist, FFTW_ESTIMATE);
backward_plan =
fftw_plan_many_dft_c2r(rank, n, howmany, out, onembed, ostride, odist, in,
inembed, istride, idist, FFTW_ESTIMATE);
}
/* -------------------------------------------------------------------------- */
template <typename T, UInt dim>
FFTransformFFTW<T, dim>::~FFTransformFFTW() {
fftw_destroy_plan(forward_plan);
fftw_destroy_plan(backward_plan);
}
/* -------------------------------------------------------------------------- */
template <typename T, UInt dim>
void FFTransformFFTW<T, dim>::forwardTransform() {
fftw_execute(forward_plan);
}
/* -------------------------------------------------------------------------- */
template <typename T, UInt dim>
void FFTransformFFTW<T, dim>::backwardTransform() {
fftw_execute(backward_plan);
this->normalize();
}
/* -------------------------------------------------------------------------- */
template class FFTransformFFTW<Real, 1>;
template class FFTransformFFTW<Real, 2>;
template class FFTransformFFTW<Real, 3>;
__END_TAMAAS__
Event Timeline
Log In to Comment