Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F85001095
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
Thu, Sep 26, 02:32
Size
3 KB
Mime Type
text/x-c++
Expires
Sat, Sep 28, 02:32 (2 d)
Engine
blob
Format
Raw Data
Handle
21116089
Attached To
rTAMAAS tamaas
fftransform.hh
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/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef FFTRANSFORM_HH
#define FFTRANSFORM_HH
/* -------------------------------------------------------------------------- */
#include "grid.hh"
#include "grid_hermitian.hh"
#include "tamaas.hh"
#include "types.hh"
#include <vector>
/* -------------------------------------------------------------------------- */
__BEGIN_TAMAAS__
/* -------------------------------------------------------------------------- */
/**
* @brief Generic class for FFT interface wrapping
*/
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
Grid
<
T
,
dim
>
computeFrequencies
(
const
std
::
array
<
UInt
,
dim
>&
sizes
);
protected
:
Grid
<
T
,
dim
>&
real
;
GridHermitian
<
T
,
dim
>&
spectral
;
};
/* -------------------------------------------------------------------------- */
template
<
typename
T
,
UInt
dim
>
template
<
bool
hermitian
>
Grid
<
T
,
dim
>
FFTransform
<
T
,
dim
>::
computeFrequencies
(
const
std
::
array
<
UInt
,
dim
>&
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
<
T
,
dim
>
freq
(
n
,
dim
);
std
::
array
<
UInt
,
dim
>
tuple
=
{
0
};
#pragma omp parallel for firstprivate(tuple)
for
(
auto
it
=
freq
.
begin
(
dim
);
it
<
freq
.
end
(
dim
);
++
it
)
{
VectorProxy
<
T
>
wavevector
(
&
(
*
it
),
dim
);
UInt
index
=
freq
.
getNbPoints
()
-
(
freq
.
end
(
dim
)
-
it
);
/// 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
;
}
}
return
freq
;
}
/* -------------------------------------------------------------------------- */
__END_TAMAAS__
/* -------------------------------------------------------------------------- */
#endif
// FFTRANSFORM_HH
Event Timeline
Log In to Comment