Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F87742726
fftransform.hh
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
Mon, Oct 14, 17:00
Size
3 KB
Mime Type
text/x-c++
Expires
Wed, Oct 16, 17:00 (2 d)
Engine
blob
Format
Raw Data
Handle
21493243
Attached To
rTAMAAS tamaas
fftransform.hh
View Options
/**
*
* @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/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef FFTRANSFORM_HH
#define FFTRANSFORM_HH
/* -------------------------------------------------------------------------- */
#include "tamaas.hh"
#include "grid.hh"
#include "grid_hermitian.hh"
#include "types.hh"
#include <vector>
/* -------------------------------------------------------------------------- */
__BEGIN_TAMAAS__
/* -------------------------------------------------------------------------- */
template <typename T, UInt dim>
class FFTransform {
public:
/// Constructor
FFTransform(Grid<T, dim> & real,
GridHermitian<T, dim> & spectral);
/// Destructor
virtual ~FFTransform();
public:
/// Perform FFT
virtual void forwardTransform() = 0;
/// Perform IFFT
virtual void backwardTransform() = 0;
/// Normalize the real surface after backward transform
virtual void normalize();
public:
/// Fill a grid with modevectors: boolean if grid has hermitian dimensions
template <bool hermitian>
static void computeFrequencies(Grid<T, dim> & freq);
protected:
Grid<T, dim> & real;
GridHermitian<T, dim> & spectral;
};
/* -------------------------------------------------------------------------- */
template<typename T, UInt dim>
template<bool hermitian>
void FFTransform<T, dim>::computeFrequencies(Grid<T, dim> & freq) {
// If hermitian is true, we suppose the dimensions of freq are
// reduced based on hermitian symetry and that it has dim components
const UInt * n = freq.sizes();
#pragma omp parallel for
for (auto it = freq.begin(dim) ; it < freq.end(dim) ; ++it) {
VectorProxy<T> wavevector(*it, dim);
UInt index = freq.getNbPoints() - (freq.end(dim) - it);
UInt tuple[dim] = {0};
/// Computing tuple from index
for (UInt d = dim-1 ; d > 0 ; d--) {
tuple[d] = index % n[d];
index -= tuple[d];
index /= n[d];
}
tuple[0] = index;
UInt dmax = dim;
if (hermitian) {
dmax = dim - 1;
wavevector(dim-1) = tuple[dim-1];
}
for (UInt d = 0 ; d < dmax ; d++) {
T td = tuple[d];
T nd = n[d];
T q = (tuple[d] <= n[d]/2) ? td : td-nd;
wavevector(d) = q;
}
}
}
/* -------------------------------------------------------------------------- */
__END_TAMAAS__
/* -------------------------------------------------------------------------- */
#endif // FFTRANSFORM_HH
Event Timeline
Log In to Comment