diff --git a/src/core/fftransform.hh b/src/core/fftransform.hh index 0fb3772..034e9db 100644 --- a/src/core/fftransform.hh +++ b/src/core/fftransform.hh @@ -1,117 +1,117 @@ /** * @file * * @author Lucas Frérot * * @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 . * */ /* -------------------------------------------------------------------------- */ #ifndef FFTRANSFORM_HH #define FFTRANSFORM_HH /* -------------------------------------------------------------------------- */ #include "grid.hh" #include "grid_hermitian.hh" #include "tamaas.hh" #include "static_types.hh" #include #include /* -------------------------------------------------------------------------- */ __BEGIN_TAMAAS__ /* -------------------------------------------------------------------------- */ /** * @brief Generic class for FFT interface wrapping */ template class FFTransform { public: /// Constructor FFTransform(Grid& real, GridHermitian& 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 static Grid computeFrequencies(const std::array& sizes); protected: Grid& real; GridHermitian& spectral; }; /* -------------------------------------------------------------------------- */ template template Grid FFTransform::computeFrequencies(const std::array& sizes) { // If hermitian is true, we suppose the dimensions of freq are // reduced based on hermitian symetry and that it has dim components auto& n = sizes; Grid freq(n, dim); constexpr UInt dmax = dim - static_cast(hermitian); static_assert(is_policy::value, "is_policy problem"); #pragma omp parallel for // to get rid of a compilation warning from nvcc for (UInt index = 0; index < freq.getNbPoints(); ++index) { - StaticVector wavevector(freq(0)); + StaticVector wavevector(freq(index * freq.getNbComponents())); std::array tuple{{0}}; /// Computing tuple from index for (Int d = dim - 1; d >= 0; d--) { tuple[d] = index % n[d]; index -= tuple[d]; index /= n[d]; } if (hermitian) wavevector(dim - 1) = tuple[dim - 1]; for (UInt d = 0; d < dmax; d++) { // Type conversion T td = tuple[d]; T nd = n[d]; T q = (tuple[d] < n[d] / 2) ? td : td - nd; wavevector(d) = q; } } return freq; } /* -------------------------------------------------------------------------- */ __END_TAMAAS__ /* -------------------------------------------------------------------------- */ #endif // FFTRANSFORM_HH