TURTLE
|
A class for handling Fourier representation tasks. More...
#include <kspace.hpp>
Data Fields | |
field_layout< ONE > * | layout |
double | dkx |
double | dky |
double | dkz |
double | dk |
double | dk2 |
double | kMx |
double | kMy |
double | kMz |
double | kM |
double | kM2 |
std::vector< double > | kx |
std::vector< double > | ky |
std::vector< double > | kz |
std::vector< double > | kshell |
std::vector< int64_t > | nshell |
int | nshells |
A class for handling Fourier representation tasks.
be | field backend, currently only FFTW is possible. |
dt | dealiasing mode, either ONE_HALF, TWO_THIRDS or SMOOTH. |
Contains wavenumber information (specific to each MPI process). This includes values of kx, ky, kz, including lowest modes dkx etc, as well as number of modes within sferical shells and mean wavenumber within shells.
kspace< be, dt >::kspace | ( | const field_layout< fc > * | source_layout, |
const double | DKX = 1.0, | ||
const double | DKY = 1.0, | ||
const double | DKZ = 1.0 ) |
kspace< be, dt >::~kspace | ( | ) |
void kspace< be, dt >::ball_filter | ( | typename fftw_interface< rnumber >::complex *__restrict__ | a, |
const double | ell ) |
Filter a field using a ball shaped top hat filter.
Filter's mathematical expression in real space is as follows:
\[ \phi^b_\ell(r) = \frac{1}{\ell^3}\frac{6}{\pi} H(\ell/2 - r) \]
with the corresponding Fourier space expression:
\[ \hat{\phi^b_\ell}(k) = \frac{3}{2(k\ell/2)^3} \left(2\sin (k \ell/2) - k \ell \cos (k \ell/2)\right) \]
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void kspace< be, dt >::cospectrum | ( | const rnumber(*) | a[2], |
const hid_t | group, | ||
const std::string | dset_name, | ||
const hsize_t | toffset, | ||
const double | wavenumber_exp = 0 ) |
void kspace< be, dt >::cospectrum | ( | const rnumber(*) | a[2], |
const rnumber(*) | b[2], | ||
const hid_t | group, | ||
const std::string | dset_name, | ||
const hsize_t | toffset, | ||
const double | wavenumber_exp = 0 ) |
void kspace< be, dt >::cospectrum | ( | const rnumber(*) | a[2], |
std::vector< double > & | spec, | ||
const double | wavenumber_exp = 0 ) |
void kspace< be, dt >::dealias | ( | typename fftw_interface< rnumber >::complex *__restrict__ | a | ) |
int kspace< be, dt >::filter | ( | typename fftw_interface< rnumber >::complex *__restrict__ | a, |
const double | wavenumber, | ||
std::string | filter_type = std::string("Gauss") ) |
Filter a field.
rnumber | type of real number, float or double. |
fc | field components, ONE, THREE or THREExTHREE. |
This is a wrapper that can choose between a sharp Fourier spherical filter, a Gaussian filter and a sharp real space spherical filter.
Filter expressions in real space are as follows:
\[ \phi^b_\ell(r) = \frac{1}{\ell^3}\frac{6}{\pi} H(\ell/2 - r) \]
\[ \phi^g_\ell(r) = \frac{1}{\sigma_\ell^3}\frac{1}{(2\pi)^{3/2}} \exp\left(-\frac{1}{2}\left(\frac{r}{\sigma_\ell}\right)^2\right) \]
\[ \phi^s_\ell(r) = \frac{1}{2 \pi^2 r^3} \left(\sin k_\ell r - k_\ell r \cos k_\ell r\right) \]
and the corresponding expressions in Fourier space are:
\[ \hat{\phi^b_\ell}(k) = \frac{3}{2(k\ell/2)^3} \left(2\sin (k \ell/2) - k \ell \cos (k \ell/2)\right) \]
\[ \hat{\phi^g_\ell}(k) = \exp\left(-\frac{1}{2}k^2 \sigma_\ell^2\right) \]
\[ \hat{\phi^s_\ell}(k) = H(k_\ell - k) \]
\( k_\ell \) is given as a parameter, and then we use
\[ \ell = \pi / k_\ell, \sigma_\ell = \pi / k_\ell \]
For the Gaussian filter this is the same convention used in [Buzzicotti2017] .
See also filter_calibrated_ell
.
int kspace< be, dt >::filter_calibrated_ell | ( | typename fftw_interface< rnumber >::complex *__restrict__ | a, |
const double | ell, | ||
std::string | filter_type = std::string("Gauss") ) |
Filter a field.
This is a wrapper that can choose between a sharp Fourier spherical filter, a Gaussian filter and a sharp real space spherical filter.
Filter expressions in real space are as follows:
embed:rst:leading-asterisk * .. math:: * :nowrap: * * \begin{eqnarray*} * \phi^b_\ell(r) &=& * \frac{1}{\ell^3}\frac{6}{\pi} H(\ell/2 - r) \\ * \phi^g_\ell(r) &=& * \frac{1}{\sigma_\ell^3}\frac{1}{(2\pi)^{3/2}} * \exp\left(-\frac{1}{2}\left(\frac{r}{\sigma_\ell}\right)^2\right) \\ * \phi^s_\ell(r) &=& * \frac{1}{2 \pi^2 r^3} * \left(\sin k_\ell r - k_\ell r \cos k_\ell r\right) * \end{eqnarray*} * *
and the corresponding expressions in Fourier space are:
embed:rst:leading-asterisk * .. math:: * :nowrap: * * \begin{eqnarray*} * \hat{\phi^b_\ell}(k) &=& * \frac{3}{2(k\ell/2)^3} * \left(2\sin (k \ell/2) - k \ell \cos (k \ell/2)\right) \\ * \hat{\phi^g_\ell}(k) &=& * \exp\left(-\frac{1}{2}k^2 \sigma_\ell^2\right) \\ * \hat{\phi^s_\ell}(k) &=& H(k_\ell - k) * \end{eqnarray*} * *
\(\sigma_\ell\) and \(k_\ell\) are calibrated such that the energy of the large scales is approximately the same (within the inertial range) independently of the shape of the filter.
This was done by hand, see [lalescu2018jfm]_ for details, with the results:
\[ \sigma_\ell = 0.23 \ell, k_\ell = 2.8 / \ell \]
|
inline |
void kspace< be, dt >::Gauss_filter | ( | typename fftw_interface< rnumber >::complex *__restrict__ | a, |
const double | sigma ) |
Filter a field using a Gaussian kernel.
rnumber | type of real number, float or double. |
fc | field components, ONE, THREE or THREExTHREE. |
Filter's mathematical expression in Fourier space is as follows:
\[ \hat{g}_\ell(\mathbf{k}) = \exp(-k^2 \sigma^2 / 2) \]
double kspace< be, dt >::L2norm | ( | const rnumber(*) | a[2] | ) |
void kspace< be, dt >::low_pass | ( | typename fftw_interface< rnumber >::complex *__restrict__ | a, |
const double | kmax ) |
void kspace< be, dt >::project_divfree | ( | typename fftw_interface< rnumber >::complex *__restrict__ | a, |
const bool | maintain_energy = false ) |
void kspace< be, dt >::rotate_divfree | ( | typename fftw_interface< rnumber >::complex *__restrict__ | a | ) |
Rotate vector modes perpendicular to wavenumber This is different from project because it maintains the energy of the field, I want it in order to be able to generate random fields with prescribed spectra.
int kspace< be, dt >::store | ( | hid_t | stat_file | ) |
double kspace< be, dt >::dk |
double kspace< be, dt >::dk2 |
double kspace< be, dt >::dkx |
double kspace< be, dt >::dky |
double kspace< be, dt >::dkz |
double kspace< be, dt >::kM |
double kspace< be, dt >::kM2 |
double kspace< be, dt >::kMx |
double kspace< be, dt >::kMy |
double kspace< be, dt >::kMz |
std::vector<double> kspace< be, dt >::kshell |
std::vector<double> kspace< be, dt >::kx |
std::vector<double> kspace< be, dt >::ky |
std::vector<double> kspace< be, dt >::kz |
field_layout<ONE>* kspace< be, dt >::layout |
std::vector<int64_t> kspace< be, dt >::nshell |
int kspace< be, dt >::nshells |