OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
kspace.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 VTT Technical Research Centre of Finland Ltd
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
61#pragma once
62
63#include <array>
64#include <cmath>
65#include <openpfc/constants.hpp>
67
68namespace pfc {
69namespace fft {
70namespace kspace {
71
99template <typename T>
100inline std::array<double, 3>
101k_frequency_scaling(const world::World<T> &world) noexcept {
102 const auto spacing = world::get_spacing(world);
103 const auto size = world::get_size(world);
104 return {two_pi / (spacing[0] * size[0]), two_pi / (spacing[1] * size[1]),
105 two_pi / (spacing[2] * size[2])};
106}
107
140inline double k_component(int index, int size, double freq_scale) noexcept {
141 return (index <= size / 2) ? index * freq_scale : (index - size) * freq_scale;
142}
143
181inline double k_laplacian_value(double ki, double kj, double kk) noexcept {
182 return -(ki * ki + kj * kj + kk * kk);
183}
184
220inline double k_squared_value(double ki, double kj, double kk) noexcept {
221 return ki * ki + kj * kj + kk * kk;
222}
223
224} // namespace kspace
225} // namespace fft
226} // namespace pfc
Mathematical and physical constants.
double k_component(int index, int size, double freq_scale) noexcept
Compute k-space wave vector component with Nyquist folding.
Definition kspace.hpp:140
double k_squared_value(double ki, double kj, double kk) noexcept
Compute squared magnitude k² = k_x² + k_y² + k_z².
Definition kspace.hpp:220
double k_laplacian_value(double ki, double kj, double kk) noexcept
Compute Laplacian operator value -k² in Fourier space.
Definition kspace.hpp:181
std::array< double, 3 > k_frequency_scaling(const world::World< T > &world) noexcept
Compute frequency scaling factors for each dimension.
Definition kspace.hpp:101
Represents the global simulation domain (the "world").
Definition world.hpp:91
World class definition and unified interface.