From c3b80ce0c7d94732292113758f7b5621abbcb4e4 Mon Sep 17 00:00:00 2001 From: Oliver Hahn Date: Sat, 24 Feb 2024 10:52:43 +0100 Subject: [PATCH 1/8] updated file header license statements --- src/Numerics.cc | 25 ++++++++++++++++--------- src/Numerics.hh | 25 ++++++++++++++++--------- src/cmake_config.hh.in | 17 +++++++++++++++++ src/constraints.cc | 25 ++++++++++++++++--------- src/constraints.hh | 25 ++++++++++++++++--------- src/convolution_kernel.cc | 24 ++++++++++++++++-------- src/convolution_kernel.hh | 25 ++++++++++++++++--------- src/cosmology_calculator.hh | 4 ++-- src/cosmology_parameters.cc | 4 ++-- src/cosmology_parameters.hh | 4 ++-- src/defaults.cc | 25 ++++++++++++++++--------- src/defaults.hh | 25 ++++++++++++++++--------- src/densities.cc | 25 ++++++++++++++++--------- src/densities.hh | 25 ++++++++++++++++--------- src/density_grid.hh | 17 +++++++++++++++++ src/fd_schemes.hh | 25 ++++++++++++++++--------- src/general.hh | 25 ++++++++++++++++--------- src/logger.cc | 2 +- src/logger.hh | 2 +- src/main.cc | 25 ++++++++++++++++--------- src/mesh.hh | 25 ++++++++++++++++--------- src/mg_interp.hh | 24 ++++++++++++++++-------- src/mg_operators.hh | 25 ++++++++++++++++--------- src/mg_solver.hh | 25 ++++++++++++++++--------- src/output.cc | 25 ++++++++++++++++--------- src/output.hh | 25 ++++++++++++++++--------- src/perturbation_theory.cc | 25 ++++++++++++++++--------- src/perturbation_theory.hh | 25 ++++++++++++++++--------- src/physical_constants.hh | 4 ++-- src/poisson.cc | 25 ++++++++++++++++--------- src/poisson.hh | 25 ++++++++++++++++--------- src/random.cc | 24 ++++++++++++++++-------- src/random.hh | 25 ++++++++++++++++--------- src/region_generator.cc | 18 ++++++++++++++++++ src/region_generator.hh | 17 +++++++++++++++++ src/schemes.hh | 24 ++++++++++++++++-------- src/solver.hh | 24 ++++++++++++++++-------- src/system_stat.hh | 9 +++++---- src/tests.hh | 26 ++++++++++++++++---------- src/transfer_function.cc | 25 ++++++++++++++++--------- src/transfer_function.hh | 24 ++++++++++++++++-------- 41 files changed, 564 insertions(+), 279 deletions(-) diff --git a/src/Numerics.cc b/src/Numerics.cc index 1639b9a..ee96348 100644 --- a/src/Numerics.cc +++ b/src/Numerics.cc @@ -1,12 +1,19 @@ -/* - - numerics.cc - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010 Oliver Hahn - -*/ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #ifdef WITH_MPI #ifdef MANNO diff --git a/src/Numerics.hh b/src/Numerics.hh index bfd93da..9bfb28c 100644 --- a/src/Numerics.hh +++ b/src/Numerics.hh @@ -1,12 +1,19 @@ -/* - - numerics.hh - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010 Oliver Hahn - - */ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #ifndef __NUMERICS_HH #define __NUMERICS_HH diff --git a/src/cmake_config.hh.in b/src/cmake_config.hh.in index 5162967..17b2d2a 100644 --- a/src/cmake_config.hh.in +++ b/src/cmake_config.hh.in @@ -1,3 +1,20 @@ +// This file is part of monofonIC (MUSIC2) +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + #pragma once diff --git a/src/constraints.cc b/src/constraints.cc index 82bfa1d..fb59b10 100644 --- a/src/constraints.cc +++ b/src/constraints.cc @@ -1,12 +1,19 @@ -/* - - constraints.cc - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010 Oliver Hahn - - */ +// This file is part of monofonIC (MUSIC2) +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #include "constraints.hh" diff --git a/src/constraints.hh b/src/constraints.hh index 450ae13..6c42a05 100644 --- a/src/constraints.hh +++ b/src/constraints.hh @@ -1,12 +1,19 @@ -/* - - constraints.hh - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010 Oliver Hahn - - */ +// This file is part of monofonIC (MUSIC2) +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #pragma once #include diff --git a/src/convolution_kernel.cc b/src/convolution_kernel.cc index 03a9c54..4a4efc9 100644 --- a/src/convolution_kernel.cc +++ b/src/convolution_kernel.cc @@ -1,11 +1,19 @@ -/* - - convolution_kernel.cc - This file is part of MUSIC - - a code to generate multi-scale initial conditions for cosmological simulations - - Copyright (C) 2010-23 Oliver Hahn - -*/ +// This file is part of monofonIC (MUSIC2) +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #include #include diff --git a/src/convolution_kernel.hh b/src/convolution_kernel.hh index 30bb851..b0265f9 100644 --- a/src/convolution_kernel.hh +++ b/src/convolution_kernel.hh @@ -1,12 +1,19 @@ -/* - - convolution_kernel.hh - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010-23 Oliver Hahn - -*/ +// This file is part of monofonIC (MUSIC2) +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #ifndef __CONVOLUTION_KERNELS_HH #define __CONVOLUTION_KERNELS_HH diff --git a/src/cosmology_calculator.hh b/src/cosmology_calculator.hh index 1748430..c059bd7 100644 --- a/src/cosmology_calculator.hh +++ b/src/cosmology_calculator.hh @@ -1,6 +1,6 @@ -// This file is part of monofonIC (MUSIC2) +// This file is part of MUSIC // A software package to generate ICs for cosmological simulations -// Copyright (C) 2020 by Oliver Hahn +// Copyright (C) 2010-2024 by Oliver Hahn // // monofonIC is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/cosmology_parameters.cc b/src/cosmology_parameters.cc index 61c456d..74d3fec 100644 --- a/src/cosmology_parameters.cc +++ b/src/cosmology_parameters.cc @@ -1,6 +1,6 @@ -// This file is part of monofonIC (MUSIC2) +// This file is part of MUSIC // A software package to generate ICs for cosmological simulations -// Copyright (C) 2020 by Oliver Hahn +// Copyright (C) 2010-2024 by Oliver Hahn // // monofonIC is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/cosmology_parameters.hh b/src/cosmology_parameters.hh index e43f33a..458e481 100644 --- a/src/cosmology_parameters.hh +++ b/src/cosmology_parameters.hh @@ -1,6 +1,6 @@ -// This file is part of monofonIC (MUSIC2) +// This file is part of MUSIC // A software package to generate ICs for cosmological simulations -// Copyright (C) 2020 by Oliver Hahn +// Copyright (C) 2010-2024 by Oliver Hahn // // monofonIC is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/defaults.cc b/src/defaults.cc index d0efe52..704179e 100644 --- a/src/defaults.cc +++ b/src/defaults.cc @@ -1,12 +1,19 @@ -/* - - defaults.cc - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010 Oliver Hahn - - */ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #include "defaults.hh" diff --git a/src/defaults.hh b/src/defaults.hh index 0c99178..c11c22f 100644 --- a/src/defaults.hh +++ b/src/defaults.hh @@ -1,12 +1,19 @@ -/* - - defaults.hh - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010 Oliver Hahn - - */ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #ifndef __DEFAULTS_HH diff --git a/src/densities.cc b/src/densities.cc index ec09459..56f7445 100644 --- a/src/densities.cc +++ b/src/densities.cc @@ -1,12 +1,19 @@ -/* - - densities.cc - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010 Oliver Hahn - - */ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #include diff --git a/src/densities.hh b/src/densities.hh index e6b52ae..bface34 100644 --- a/src/densities.hh +++ b/src/densities.hh @@ -1,12 +1,19 @@ -/* - - densities.hh - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010 Oliver Hahn - - */ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #ifndef __DENSITIES_HH #define __DENSITIES_HH diff --git a/src/density_grid.hh b/src/density_grid.hh index 7eba1e2..61d526f 100644 --- a/src/density_grid.hh +++ b/src/density_grid.hh @@ -1,3 +1,20 @@ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + #pragma once #include diff --git a/src/fd_schemes.hh b/src/fd_schemes.hh index 1ad2dd9..f32010d 100644 --- a/src/fd_schemes.hh +++ b/src/fd_schemes.hh @@ -1,12 +1,19 @@ -/* - - fd_schemes.hh - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010 Oliver Hahn - -*/ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #ifndef __FD_SCHEMES_HH #define __FD_SCHEMES_HH diff --git a/src/general.hh b/src/general.hh index f7eb32f..a71a3ad 100644 --- a/src/general.hh +++ b/src/general.hh @@ -1,12 +1,19 @@ -/* - - general.hh - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010 Oliver Hahn - -*/ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #pragma once diff --git a/src/logger.cc b/src/logger.cc index b60963a..4220af1 100644 --- a/src/logger.cc +++ b/src/logger.cc @@ -1,4 +1,4 @@ -// This file is part of monofonIC (MUSIC2) +// This file is part of MUSIC // A software package to generate ICs for cosmological simulations // Copyright (C) 2020 by Oliver Hahn & Michael Michaux (this file) // diff --git a/src/logger.hh b/src/logger.hh index 03f7960..38ee168 100644 --- a/src/logger.hh +++ b/src/logger.hh @@ -1,4 +1,4 @@ -// This file is part of monofonIC (MUSIC2) +// This file is part of MUSIC // A software package to generate ICs for cosmological simulations // Copyright (C) 2020 by Oliver Hahn & Michael Michaux (this file) // diff --git a/src/main.cc b/src/main.cc index fcb0dbe..a050284 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,12 +1,19 @@ -/* - - main.cc - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010 Oliver Hahn - -*/ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #include #include diff --git a/src/mesh.hh b/src/mesh.hh index 11f52f6..9aff209 100644 --- a/src/mesh.hh +++ b/src/mesh.hh @@ -1,12 +1,19 @@ -/* - - mesh.hh - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010 Oliver Hahn - -*/ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #pragma once diff --git a/src/mg_interp.hh b/src/mg_interp.hh index 7a601da..8bacff3 100644 --- a/src/mg_interp.hh +++ b/src/mg_interp.hh @@ -1,11 +1,19 @@ -/* - * mg_interp.hh - * FROLIC_mg - * - * Created by Oliver Hahn on 5/27/10. - * Copyright 2010 KIPAC/Stanford University. All rights reserved. - * - */ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #ifndef __MG_INTERP_HH #define __MG_INTERP_HH diff --git a/src/mg_operators.hh b/src/mg_operators.hh index c966b88..b2dee57 100644 --- a/src/mg_operators.hh +++ b/src/mg_operators.hh @@ -1,12 +1,19 @@ -/* - - mg_operators.hh - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010 Oliver Hahn - -*/ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #ifndef __MG_OPERATORS_HH #define __MG_OPERATORS_HH diff --git a/src/mg_solver.hh b/src/mg_solver.hh index 89e4083..ea72922 100644 --- a/src/mg_solver.hh +++ b/src/mg_solver.hh @@ -1,12 +1,19 @@ -/* - - mg_solver.hh - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010 Oliver Hahn - -*/ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #pragma once diff --git a/src/output.cc b/src/output.cc index e10dea1..9e70dad 100644 --- a/src/output.cc +++ b/src/output.cc @@ -1,12 +1,19 @@ -/* - - output.cc - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010 Oliver Hahn - -*/ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #include "output.hh" diff --git a/src/output.hh b/src/output.hh index 027a3ce..1a04b9f 100644 --- a/src/output.hh +++ b/src/output.hh @@ -1,12 +1,19 @@ -/* - - output.hh - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010 Oliver Hahn - -*/ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #ifndef __OUTPUT_HH #define __OUTPUT_HH diff --git a/src/perturbation_theory.cc b/src/perturbation_theory.cc index bbd4918..2f7b98b 100644 --- a/src/perturbation_theory.cc +++ b/src/perturbation_theory.cc @@ -1,12 +1,19 @@ -/* - - cosmology.cc - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010 Oliver Hahn - - */ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #include #include diff --git a/src/perturbation_theory.hh b/src/perturbation_theory.hh index 7a688ed..4fcf95b 100644 --- a/src/perturbation_theory.hh +++ b/src/perturbation_theory.hh @@ -1,12 +1,19 @@ -/* - - cosmology.hh - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010 Oliver Hahn - - */ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #pragma once diff --git a/src/physical_constants.hh b/src/physical_constants.hh index ceec634..c212d0a 100644 --- a/src/physical_constants.hh +++ b/src/physical_constants.hh @@ -1,6 +1,6 @@ -// This file is part of monofonIC (MUSIC2) +// This file is part of MUSIC // A software package to generate ICs for cosmological simulations -// Copyright (C) 2020 by Oliver Hahn +// Copyright (C) 2010-2024 by Oliver Hahn // // monofonIC is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/poisson.cc b/src/poisson.cc index 38bb59e..ecee6df 100644 --- a/src/poisson.cc +++ b/src/poisson.cc @@ -1,12 +1,19 @@ -/* - - poisson.cc - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010 Oliver Hahn - - */ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . /****** ABSTRACT FACTORY PATTERN IMPLEMENTATION *******/ diff --git a/src/poisson.hh b/src/poisson.hh index e1383bc..7e593fa 100644 --- a/src/poisson.hh +++ b/src/poisson.hh @@ -1,12 +1,19 @@ -/* - - poisson.cc - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010 Oliver Hahn - - */ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #ifndef __POISSON_HH #define __POISSON_HH diff --git a/src/random.cc b/src/random.cc index 2ecb486..725c840 100644 --- a/src/random.cc +++ b/src/random.cc @@ -1,11 +1,19 @@ -/* - - random.cc - This file is part of MUSIC - - a code to generate multi-scale initial conditions for cosmological simulations - - Copyright (C) 2010-23 Oliver Hahn - - */ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #include "random.hh" diff --git a/src/random.hh b/src/random.hh index 9f5df91..8bf7963 100644 --- a/src/random.hh +++ b/src/random.hh @@ -1,12 +1,19 @@ -/* - - random.hh - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010-23 by Oliver Hahn - -*/ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . //... for testing purposes............. // #define DEGRADE_RAND1 diff --git a/src/region_generator.cc b/src/region_generator.cc index 196a6a6..d0c054f 100644 --- a/src/region_generator.cc +++ b/src/region_generator.cc @@ -1,3 +1,21 @@ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + + #include #include "region_generator.hh" diff --git a/src/region_generator.hh b/src/region_generator.hh index 9b46634..f7363fd 100644 --- a/src/region_generator.hh +++ b/src/region_generator.hh @@ -1,3 +1,20 @@ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + #ifndef __REGION_GENERATOR_HH #define __REGION_GENERATOR_HH diff --git a/src/schemes.hh b/src/schemes.hh index 900118a..27d2700 100644 --- a/src/schemes.hh +++ b/src/schemes.hh @@ -1,11 +1,19 @@ -/* - * schemes.hh - * GravitySolver - * - * Created by Oliver Hahn on 2/1/10. - * Copyright 2010 KIPAC/Stanford University. All rights reserved. - * - */ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #ifndef __SCHEME_HH #define __SCHEME_HH diff --git a/src/solver.hh b/src/solver.hh index 51d506b..ec23f45 100644 --- a/src/solver.hh +++ b/src/solver.hh @@ -1,11 +1,19 @@ -/* - * solver.h - * GravitySolver - * - * Created by Oliver Hahn on 1/20/10. - * Copyright 2010 KIPAC/Stanford University. All rights reserved. - * - */ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #pragma once diff --git a/src/system_stat.hh b/src/system_stat.hh index 1a30566..9df25cb 100644 --- a/src/system_stat.hh +++ b/src/system_stat.hh @@ -1,19 +1,20 @@ -// This file is part of MUSIC2 +// This file is part of MUSIC // A software package to generate ICs for cosmological simulations -// Copyright (C) 2020-23 by Oliver Hahn +// Copyright (C) 2010-2024 by Oliver Hahn // -// MUSIC2 is free software: you can redistribute it and/or modify +// monofonIC is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // -// MUSIC2 is distributed in the hope that it will be useful, +// monofonIC 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . + #pragma once #ifdef __APPLE__ diff --git a/src/tests.hh b/src/tests.hh index 565b533..5eee6aa 100644 --- a/src/tests.hh +++ b/src/tests.hh @@ -1,13 +1,19 @@ -/* - - tests.hh - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010 Oliver Hahn - -*/ - +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #ifndef __TESTS_HH #define __TESTS_HH diff --git a/src/transfer_function.cc b/src/transfer_function.cc index 84fd0a1..4d45504 100644 --- a/src/transfer_function.cc +++ b/src/transfer_function.cc @@ -1,12 +1,19 @@ -/* - - transfer_function.cc - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010 Oliver Hahn - -*/ +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . #include "transfer_function.hh" diff --git a/src/transfer_function.hh b/src/transfer_function.hh index 0513557..2e4efaf 100644 --- a/src/transfer_function.hh +++ b/src/transfer_function.hh @@ -1,12 +1,20 @@ -/* +// This file is part of MUSIC +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2010-2024 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . - transfer_function.hh - This file is part of MUSIC - - a code to generate multi-scale initial conditions - for cosmological simulations - - Copyright (C) 2010 Oliver Hahn - -*/ #pragma once #include From a616b2ebf63fd71c86c5228513cae43afb69859b Mon Sep 17 00:00:00 2001 From: Oliver Hahn Date: Mon, 26 Feb 2024 05:18:53 +0800 Subject: [PATCH 2/8] wip commit --- src/densities.cc | 34 +++++----------- src/math/special.hh | 42 ++++++++++++++++++++ src/plugins/random_music_wnoise_generator.cc | 41 +++++++++++++------ 3 files changed, 82 insertions(+), 35 deletions(-) create mode 100644 src/math/special.hh diff --git a/src/densities.cc b/src/densities.cc index 56f7445..f4aee69 100644 --- a/src/densities.cc +++ b/src/densities.cc @@ -17,6 +17,8 @@ #include +#include "math/special.hh" + #include "densities.hh" #include "random.hh" #include "convolution_kernel.hh" @@ -24,20 +26,6 @@ //TODO: this should be a larger number by default, just to maintain consistency with old default #define DEF_RAN_CUBE_SIZE 32 -double Meyer_scaling_function( double k, double kmax ) -{ - constexpr double twopithirds{2.0*M_PI/3.0}; - constexpr double fourpithirds{4.0*M_PI/3.0}; - auto nu = []( double x ){ return x<0.0?0.0:(x<1.0?x:1.0); }; - - k = std::abs(k)/kmax * fourpithirds; - - if( k < twopithirds ) return 1.0; - else if( k< fourpithirds ){ - return std::cos( 0.5*M_PI * nu(3*k/(2*M_PI)-1.0) ); - } - return 0.0; -} template void fft_coarsen(m1 &v, m2 &V) @@ -131,6 +119,7 @@ void fft_interpolate(m1 &V, m2 &v, int margin, bool from_basegrid = false) size_t nxf = v.size(0), nyf = v.size(1), nzf = v.size(2), nzfp = nzf + 2; size_t mxf = v.margin(0), myf = v.margin(1), mzf = v.margin(2); + // adjust offsets to respect margins, all grids have 'margins' except basegrid (which is periodic) if (!from_basegrid) { oxf += mxf/2; @@ -217,22 +206,21 @@ void fft_interpolate(m1 &V, m2 &v, int margin, bool from_basegrid = false) double kz = (k <= (int)nzc / 2) ? (double)k : (double)(k - (int)nzc); double phase = -0.5 * M_PI * (kx / nxc + ky / nyc + kz / nzc); + // double phase = -0.5 * M_PI * (kx / nxc + ky / nyc + kz / nzc); std::complex val_phas(cos(phase), sin(phase)); std::complex val(RE(ccoarse[qc]), IM(ccoarse[qc])); val *= val_phas * 8.0; - if(i != (int)nxc / 2 && j != (int)nyc / 2 && k != (int)nzc / 2){ - double blend_coarse_x = Meyer_scaling_function(kx, nxc / 2); - double blend_coarse_y = Meyer_scaling_function(ky, nyc / 2); - double blend_coarse_z = Meyer_scaling_function(kz, nzc / 2); - double blend_coarse = blend_coarse_x*blend_coarse_y*blend_coarse_z; - double blend_fine = 1.0-blend_coarse; + double blend_coarse_x = Meyer_scaling_function(kx, nxc / 4); + double blend_coarse_y = Meyer_scaling_function(ky, nyc / 4); + double blend_coarse_z = Meyer_scaling_function(kz, nzc / 4); + double blend_coarse = blend_coarse_x*blend_coarse_y*blend_coarse_z; + double blend_fine = 1.0-blend_coarse; - RE(cfine[qf]) = blend_fine * RE(cfine[qf]) + blend_coarse * val.real(); - IM(cfine[qf]) = blend_fine * IM(cfine[qf]) + blend_coarse * val.imag(); - } + RE(cfine[qf]) = blend_fine * RE(cfine[qf]) + blend_coarse * val.real(); + IM(cfine[qf]) = blend_fine * IM(cfine[qf]) + blend_coarse * val.imag(); } delete[] rcoarse; diff --git a/src/math/special.hh b/src/math/special.hh new file mode 100644 index 0000000..59b0044 --- /dev/null +++ b/src/math/special.hh @@ -0,0 +1,42 @@ +// This file is part of monofonIC (MUSIC2) +// A software package to generate ICs for cosmological simulations +// Copyright (C) 2020 by Oliver Hahn +// +// monofonIC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// monofonIC 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 General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +#pragma once + +#include + +inline double Meyer_scaling_function( double k, double kmax ) +{ + constexpr double twopithirds{2.0*M_PI/3.0}; + constexpr double fourpithirds{4.0*M_PI/3.0}; + auto nu = []( double x ){ return x<0.0?0.0:(x<1.0?x:1.0); }; + + // k = std::abs(k)/kmax * fourpithirds; + k = std::abs(k)/kmax * 2 * M_PI; + + if( k < twopithirds ) return 1.0; + else if( k< fourpithirds ){ + return std::cos( 0.5*M_PI * nu(3*k/(2*M_PI)-1.0) ); + } + // if( k < fourpithirds ) return 1.0; + return 0.0; +} + +inline double Shannon_scaling_function( double k, double kmax ) +{ + if( std::abs(k) < kmax ) return 1.0; + return 0.0; +} \ No newline at end of file diff --git a/src/plugins/random_music_wnoise_generator.cc b/src/plugins/random_music_wnoise_generator.cc index 6d7f405..2eed5f7 100644 --- a/src/plugins/random_music_wnoise_generator.cc +++ b/src/plugins/random_music_wnoise_generator.cc @@ -4,6 +4,8 @@ #include #include +#include "math/special.hh" + #include "random.hh" #include "random_music_wnoise_generator.hh" @@ -627,18 +629,33 @@ music_wnoise_generator::music_wnoise_generator(music_wnoise_generator &rc, val *= val_phas * sqrt8; - // if (x0_ == NULL || lx_ == NULL){ - if (i != (int)nxc / 2 && j != (int)nyc / 2 && k != (int)nzc / 2) - { - RE(cfine[qf]) = val.real(); - IM(cfine[qf]) = val.imag(); - } - else - { - RE(cfine[qf]) = val.real(); - IM(cfine[qf]) = 0.0; - } - // } + // // if (x0_ == NULL || lx_ == NULL){ + // if (i != (int)nxc / 2 && j != (int)nyc / 2 && k != (int)nzc / 2) + // { + // RE(cfine[qf]) = val.real(); + // IM(cfine[qf]) = val.imag(); + // } + // else + // { + // RE(cfine[qf]) = val.real(); + // IM(cfine[qf]) = 0.0; + // } + // // } + if(i != (int)nxc / 2 && j != (int)nyc / 2 && k != (int)nzc / 2){ + double blend_coarse_x = Meyer_scaling_function(kx, nxc / 2); + double blend_coarse_y = Meyer_scaling_function(ky, nyc / 2); + double blend_coarse_z = Meyer_scaling_function(kz, nzc / 2); + + // double blend_coarse_x = Shannon_scaling_function(kx, nxc / 2); + // double blend_coarse_y = Shannon_scaling_function(ky, nyc / 2); + // double blend_coarse_z = Shannon_scaling_function(kz, nzc / 2); + + double blend_coarse = blend_coarse_x*blend_coarse_y*blend_coarse_z; + double blend_fine = std::sqrt(1.0-blend_coarse*blend_coarse); + + RE(cfine[qf]) = blend_fine * RE(cfine[qf]) + blend_coarse * val.real(); + IM(cfine[qf]) = blend_fine * IM(cfine[qf]) + blend_coarse * val.imag(); + } } delete[] rcoarse; From 41459bd425d0c0b4c14794909e488b7aa8a3f49f Mon Sep 17 00:00:00 2001 From: Oliver Hahn Date: Mon, 26 Feb 2024 05:48:57 +0800 Subject: [PATCH 3/8] removed some commented out code --- src/densities.cc | 1 - src/math/special.hh | 2 -- src/plugins/random_music_wnoise_generator.cc | 15 --------------- 3 files changed, 18 deletions(-) diff --git a/src/densities.cc b/src/densities.cc index f4aee69..48cbfc7 100644 --- a/src/densities.cc +++ b/src/densities.cc @@ -206,7 +206,6 @@ void fft_interpolate(m1 &V, m2 &v, int margin, bool from_basegrid = false) double kz = (k <= (int)nzc / 2) ? (double)k : (double)(k - (int)nzc); double phase = -0.5 * M_PI * (kx / nxc + ky / nyc + kz / nzc); - // double phase = -0.5 * M_PI * (kx / nxc + ky / nyc + kz / nzc); std::complex val_phas(cos(phase), sin(phase)); diff --git a/src/math/special.hh b/src/math/special.hh index 59b0044..2080d12 100644 --- a/src/math/special.hh +++ b/src/math/special.hh @@ -24,14 +24,12 @@ inline double Meyer_scaling_function( double k, double kmax ) constexpr double fourpithirds{4.0*M_PI/3.0}; auto nu = []( double x ){ return x<0.0?0.0:(x<1.0?x:1.0); }; - // k = std::abs(k)/kmax * fourpithirds; k = std::abs(k)/kmax * 2 * M_PI; if( k < twopithirds ) return 1.0; else if( k< fourpithirds ){ return std::cos( 0.5*M_PI * nu(3*k/(2*M_PI)-1.0) ); } - // if( k < fourpithirds ) return 1.0; return 0.0; } diff --git a/src/plugins/random_music_wnoise_generator.cc b/src/plugins/random_music_wnoise_generator.cc index 2eed5f7..90f243c 100644 --- a/src/plugins/random_music_wnoise_generator.cc +++ b/src/plugins/random_music_wnoise_generator.cc @@ -605,9 +605,6 @@ music_wnoise_generator::music_wnoise_generator(music_wnoise_generator &rc, { int ii(i), jj(j), kk(k); - // if( i==(int)nxc/2 ) continue; - // if( j==(int)nyc/2 ) continue; - if (i > (int)nxc / 2) ii += (int)nx / 2; if (j > (int)nyc / 2) @@ -629,18 +626,6 @@ music_wnoise_generator::music_wnoise_generator(music_wnoise_generator &rc, val *= val_phas * sqrt8; - // // if (x0_ == NULL || lx_ == NULL){ - // if (i != (int)nxc / 2 && j != (int)nyc / 2 && k != (int)nzc / 2) - // { - // RE(cfine[qf]) = val.real(); - // IM(cfine[qf]) = val.imag(); - // } - // else - // { - // RE(cfine[qf]) = val.real(); - // IM(cfine[qf]) = 0.0; - // } - // // } if(i != (int)nxc / 2 && j != (int)nyc / 2 && k != (int)nzc / 2){ double blend_coarse_x = Meyer_scaling_function(kx, nxc / 2); double blend_coarse_y = Meyer_scaling_function(ky, nyc / 2); From bfbb00ae7163e77fb18d7e16c27f93c96ec4ba3b Mon Sep 17 00:00:00 2001 From: Oliver Hahn Date: Mon, 26 Feb 2024 10:19:53 +0800 Subject: [PATCH 4/8] added low-pass filtering of coarse fields --- src/densities.cc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/densities.cc b/src/densities.cc index 48cbfc7..66a36b2 100644 --- a/src/densities.cc +++ b/src/densities.cc @@ -27,6 +27,7 @@ #define DEF_RAN_CUBE_SIZE 32 +/* interpolate upwards in the hierarchy */ template void fft_coarsen(m1 &v, m2 &V) { @@ -84,13 +85,14 @@ void fft_coarsen(m1 &v, m2 &V) val_fine *= val_phas * fftnorm / 8.0; - if( i!=(int)nxF/2 && j!=(int)nyF/2 && k!=(int)nzF/2 ){ - RE(ccoarse[qc]) = val_fine.real(); - IM(ccoarse[qc]) = val_fine.imag(); - }else{ - RE(ccoarse[qc]) = 0.0;//val_fine.real(); - IM(ccoarse[qc]) = 0.0;//val_fine.imag(); - } + double blend_coarse_x = Meyer_scaling_function(kx, nxF / 2); + double blend_coarse_y = Meyer_scaling_function(ky, nyF / 2); + double blend_coarse_z = Meyer_scaling_function(kz, nzF / 2); + + double blend_coarse = blend_coarse_x*blend_coarse_y*blend_coarse_z; + + RE(ccoarse[qc]) = val_fine.real() * blend_coarse; + IM(ccoarse[qc]) = val_fine.imag() * blend_coarse; } delete[] rfine; @@ -112,6 +114,7 @@ void fft_coarsen(m1 &v, m2 &V) FFTW_API(destroy_plan)(ipc); } +/* interpolate downwards in the hierarchy */ template void fft_interpolate(m1 &V, m2 &v, int margin, bool from_basegrid = false) { From c18cb64055793413c80094b4b6f06990bb8df9f4 Mon Sep 17 00:00:00 2001 From: Oliver Hahn Date: Mon, 26 Feb 2024 16:25:45 +0800 Subject: [PATCH 5/8] added back (and exposed) N-GenIC topgrid generator --- src/plugins/random_music.cc | 8 +++-- src/plugins/random_music_wnoise_generator.cc | 36 ++++++++++---------- src/plugins/random_music_wnoise_generator.hh | 5 ++- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/plugins/random_music.cc b/src/plugins/random_music.cc index af35b3e..6eeb798 100644 --- a/src/plugins/random_music.cc +++ b/src/plugins/random_music.cc @@ -145,6 +145,7 @@ void RNG_music::parse_random_parameters(void) void RNG_music::compute_random_numbers(void) { bool rndsign = pcf_->get_value_safe("random", "grafic_sign", false); + bool bUseNGenIC = pcf_->get_value_safe("random","coarse_ngenic",false); std::vector randc(std::max(levelmax_, levelmin_seed_) + 1, (rng *)NULL); @@ -156,7 +157,8 @@ void RNG_music::compute_random_numbers(void) if (rngfnames_[levelmin_seed_].size() > 0) randc[levelmin_seed_] = new rng(1 << levelmin_seed_, rngfnames_[levelmin_seed_], rndsign); else - randc[levelmin_seed_] = new rng(1 << levelmin_seed_, ran_cube_size_, rngseeds_[levelmin_seed_]); + randc[levelmin_seed_] = new rng(1 << levelmin_seed_, ran_cube_size_, rngseeds_[levelmin_seed_], + bUseNGenIC, true); for (int i = levelmin_seed_ + 1; i <= levelmin_; ++i) { @@ -178,7 +180,7 @@ void RNG_music::compute_random_numbers(void) randc[levelmin_seed_] = new rng(1 << levelmin_seed_, rngfnames_[levelmin_seed_], rndsign); else randc[levelmin_seed_] = - new rng(1 << levelmin_seed_, ran_cube_size_, rngseeds_[levelmin_seed_]); //, x0, lx ); + new rng(1 << levelmin_seed_, ran_cube_size_, rngseeds_[levelmin_seed_], bUseNGenIC, true); //, x0, lx ); for (int ilevel = levelmin_seed_ - 1; ilevel >= (int)levelmin_; --ilevel) { @@ -205,7 +207,7 @@ void RNG_music::compute_random_numbers(void) if (rngfnames_[levelmin_].size() > 0) randc[levelmin_] = new rng(1 << levelmin_, rngfnames_[levelmin_], rndsign); else - randc[levelmin_] = new rng(1 << levelmin_, ran_cube_size_, rngseeds_[levelmin_]); + randc[levelmin_] = new rng(1 << levelmin_, ran_cube_size_, rngseeds_[levelmin_], bUseNGenIC, true); } store_rnd(levelmin_, randc[levelmin_]); diff --git a/src/plugins/random_music_wnoise_generator.cc b/src/plugins/random_music_wnoise_generator.cc index 90f243c..f1d8113 100644 --- a/src/plugins/random_music_wnoise_generator.cc +++ b/src/plugins/random_music_wnoise_generator.cc @@ -11,10 +11,13 @@ template -void rapid_proto_ngenic_rng(size_t res, long baseseed, music_wnoise_generator &R) -{ - music::ulog.Print("Invoking the N-GenIC random number generator"); +void music_wnoise_generator:: gen_topgrid_NGenIC(size_t res, long baseseed) { + music::ulog.Print( + "Generating large-scale random numbers using N-GenIC RNG with seed %ld", + baseseed); + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // execute N-GenIC rando number generator unsigned *seedtable = new unsigned[res * res]; gsl_rng *random_generator = gsl_rng_alloc(gsl_rng_ranlxd1); @@ -138,7 +141,7 @@ void rapid_proto_ngenic_rng(size_t res, long baseseed, music_wnoise_generator for (int i = 0; i < (int)res; ++i) for (size_t j = 0; j < res; ++j) for (size_t k = 0; k < res; ++k) - R(i, j, k) = rnoise[((size_t)i * res + j) * res + k]; + (*this)(i, j, k) = rnoise[((size_t)i * res + j) * res + k]; delete[] rnoise; } @@ -154,7 +157,8 @@ music_wnoise_generator::music_wnoise_generator(unsigned res, unsigned cubesiz } template -music_wnoise_generator::music_wnoise_generator(unsigned res, unsigned cubesize, long baseseed, bool zeromean) +music_wnoise_generator::music_wnoise_generator( unsigned res, unsigned cubesize, long baseseed, + bool bUseNGenIC, bool zeromean ) : res_(res), cubesize_(cubesize), ncubes_(1), baseseed_(baseseed) { music::ilog.Print("Generating random numbers (2) with seed %ld", baseseed); @@ -162,23 +166,19 @@ music_wnoise_generator::music_wnoise_generator(unsigned res, unsigned cubesiz double mean = 0.0; size_t res_l = res; - bool musicnoise = true; - if (!musicnoise) - cubesize_ = res_; - - if (!musicnoise) - music::elog.Print("This currently breaks compatibility. Need to disable by hand! Make sure to not check into repo"); + if( bUseNGenIC ){ + cubesize_ = res; + ncubes_ = 1; + } initialize(); - if (musicnoise) + if( !bUseNGenIC ){ mean = fill_all(); - else - { - rnums_.push_back(new Meshvar(res, 0, 0, 0)); - cubemap_[0] = 0; // create dummy map index - register_cube(0, 0, 0); - rapid_proto_ngenic_rng( res_, baseseed_, *this ); + }else{ + mean = 0.0; + gen_topgrid_NGenIC( res_, baseseed_ ); + zeromean = false; } if (zeromean) diff --git a/src/plugins/random_music_wnoise_generator.hh b/src/plugins/random_music_wnoise_generator.hh index 97687b3..7fde3d0 100644 --- a/src/plugins/random_music_wnoise_generator.hh +++ b/src/plugins/random_music_wnoise_generator.hh @@ -39,6 +39,9 @@ protected: //! subtract a constant from an entire cube void subtract_from_cube(int i, int j, int k, double val); + //! usees the N-GenIC random number generator to set up the top grid + void gen_topgrid_NGenIC( size_t res, long baseseed ); + //! copy random numbers from a cube to a full grid array template void copy_cube(int i, int j, int k, C &dat) @@ -127,7 +130,7 @@ public: music_wnoise_generator(music_wnoise_generator &rc, unsigned cubesize, long baseseed, int *x0_ = NULL, int *lx_ = NULL, bool zeromean = true); //! constructor - music_wnoise_generator(unsigned res, unsigned cubesize, long baseseed, bool zeromean = true); + music_wnoise_generator(unsigned res, unsigned cubesize, long baseseed, bool bUseNGenIC, bool zeromean = true ); //! constructor to read white noise from file music_wnoise_generator(unsigned res, std::string randfname, bool rndsign); From fdb8f8dcffdd9017f51fa1131ac7a520caa1fab4 Mon Sep 17 00:00:00 2001 From: Oliver Hahn Date: Tue, 27 Feb 2024 01:29:15 +0800 Subject: [PATCH 6/8] wip --- src/plugins/random_music_wnoise_generator.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/random_music_wnoise_generator.cc b/src/plugins/random_music_wnoise_generator.cc index f1d8113..40b4149 100644 --- a/src/plugins/random_music_wnoise_generator.cc +++ b/src/plugins/random_music_wnoise_generator.cc @@ -136,7 +136,6 @@ void music_wnoise_generator:: gen_topgrid_NGenIC(size_t res, long baseseed) { FFTW_API(destroy_plan)(plan); // copy to array that holds the random numbers - #pragma omp parallel for for (int i = 0; i < (int)res; ++i) for (size_t j = 0; j < res; ++j) @@ -169,6 +168,8 @@ music_wnoise_generator::music_wnoise_generator( unsigned res, unsigned cubes if( bUseNGenIC ){ cubesize_ = res; ncubes_ = 1; + rnums_.push_back(new Meshvar(res, 0, 0, 0)); + cubemap_[0] = 0; // create dummy map index } initialize(); @@ -176,6 +177,7 @@ music_wnoise_generator::music_wnoise_generator( unsigned res, unsigned cubes if( !bUseNGenIC ){ mean = fill_all(); }else{ + music::ilog.Print("Using N-GenIC generator for top grid..."); mean = 0.0; gen_topgrid_NGenIC( res_, baseseed_ ); zeromean = false; From 75587bbf260df9ea485cfa61e247369139015237 Mon Sep 17 00:00:00 2001 From: Oliver Hahn Date: Tue, 27 Feb 2024 01:54:25 +0800 Subject: [PATCH 7/8] fixed bug in N-GenIC random number generator --- src/plugins/random_music_wnoise_generator.cc | 139 +++++++++---------- 1 file changed, 65 insertions(+), 74 deletions(-) diff --git a/src/plugins/random_music_wnoise_generator.cc b/src/plugins/random_music_wnoise_generator.cc index 40b4149..324450f 100644 --- a/src/plugins/random_music_wnoise_generator.cc +++ b/src/plugins/random_music_wnoise_generator.cc @@ -16,6 +16,10 @@ void music_wnoise_generator:: gen_topgrid_NGenIC(size_t res, long baseseed) { "Generating large-scale random numbers using N-GenIC RNG with seed %ld", baseseed); + rnums_.push_back(new Meshvar(res, 0, 0, 0)); + cubemap_[0] = 0; // create dummy map index + register_cube(0, 0, 0); + ///////////////////////////////////////////////////////////////////////////////////////////////////////// // execute N-GenIC rando number generator unsigned *seedtable = new unsigned[res * res]; @@ -48,87 +52,76 @@ void music_wnoise_generator:: gen_topgrid_NGenIC(size_t res, long baseseed) { real_t *rnoise = new real_t[res * res * (res + 2)]; complex_t *knoise = reinterpret_cast(rnoise); - double fnorm = 1. / sqrt(res * res * res); + double fnorm = pow((double)res, -1.5); -// #warning need to check for race conditions below - //#pragma omp parallel for - for (size_t i = 0; i < res; i++) - { - int ii = (int)res - (int)i; - if (ii == (int)res) - ii = 0; +// /#warning need to check for race conditions below +//#pragma omp parallel for + for (size_t i = 0; i < res; i++) { + int ii = (int)res - (int)i; + if (ii == (int)res) + ii = 0; - for (size_t j = 0; j < res; j++) - { - gsl_rng_set(random_generator, seedtable[i * res + j]); + for (size_t j = 0; j < res; j++) { + gsl_rng_set(random_generator, seedtable[i * res + j]); + for (size_t k = 0; k < res / 2; k++) { + double phase = gsl_rng_uniform(random_generator) * 2 * M_PI; + double ampl; + do { + ampl = gsl_rng_uniform(random_generator); + } while (ampl == 0); - for (size_t k = 0; k < res / 2; k++) - { - double phase = gsl_rng_uniform(random_generator) * 2 * M_PI; - double ampl; - do - ampl = gsl_rng_uniform(random_generator); - while (ampl == 0); + if (i == res / 2 || j == res / 2 || k == res / 2) + continue; + if (i == 0 && j == 0 && k == 0) + continue; - if (i == res / 2 || j == res / 2 || k == res / 2) - continue; - if (i == 0 && j == 0 && k == 0) - continue; + T rp = -sqrt(-log(ampl)) * cos(phase) * fnorm; + T ip = -sqrt(-log(ampl)) * sin(phase) * fnorm; - T rp = -sqrt(-log(ampl)) * cos(phase) * fnorm; - T ip = -sqrt(-log(ampl)) * sin(phase) * fnorm; + if (k > 0) { + RE(knoise[(i * res + j) * (res / 2 + 1) + k]) = rp; + IM(knoise[(i * res + j) * (res / 2 + 1) + k]) = ip; + } else /* k=0 plane needs special treatment */ + { + if (i == 0) { + if (j >= res / 2) { + continue; + } else { + int jj = + (int)res - (int)j; /* note: j!=0 surely holds at this point */ - if (k > 0) - { - RE(knoise[(i * res + j) * (res / 2 + 1) + k]) = rp; - IM(knoise[(i * res + j) * (res / 2 + 1) + k]) = ip; - } - else /* k=0 plane needs special treatment */ - { - if (i == 0) - { - if (j >= res / 2) - continue; - else - { - int jj = (int)res - (int)j; /* note: j!=0 surely holds at this point */ + RE(knoise[(i * res + j) * (res / 2 + 1) + k]) = rp; + IM(knoise[(i * res + j) * (res / 2 + 1) + k]) = ip; - RE(knoise[(i * res + j) * (res / 2 + 1) + k]) = rp; - IM(knoise[(i * res + j) * (res / 2 + 1) + k]) = ip; + RE(knoise[(i * res + jj) * (res / 2 + 1) + k]) = rp; + IM(knoise[(i * res + jj) * (res / 2 + 1) + k]) = -ip; + } + } else { + if (i >= res / 2) { + continue; + } else { + int ii = (int)res - (int)i; + if (ii == (int)res) + ii = 0; + int jj = (int)res - (int)j; + if (jj == (int)res) + jj = 0; - RE(knoise[(i * res + jj) * (res / 2 + 1) + k]) = rp; - IM(knoise[(i * res + jj) * (res / 2 + 1) + k]) = -ip; - } - } - else - { - if (i >= res / 2) - continue; - else - { - int ii = (int)res - (int)i; - if (ii == (int)res) - ii = 0; - int jj = (int)res - (int)j; - if (jj == (int)res) - jj = 0; + RE(knoise[(i * res + j) * (res / 2 + 1) + k]) = rp; + IM(knoise[(i * res + j) * (res / 2 + 1) + k]) = ip; - RE(knoise[(i * res + j) * (res / 2 + 1) + k]) = rp; - IM(knoise[(i * res + j) * (res / 2 + 1) + k]) = ip; + if (ii >= 0 && ii < (int)res) { + RE(knoise[(ii * res + jj) * (res / 2 + 1) + k]) = rp; + IM(knoise[(ii * res + jj) * (res / 2 + 1) + k]) = -ip; + } + } + } + } + } + } + } - if (ii >= 0 && ii < (int)res) - { - RE(knoise[(ii * res + jj) * (res / 2 + 1) + k]) = rp; - IM(knoise[(ii * res + jj) * (res / 2 + 1) + k]) = -ip; - } - } - } - } - } - } - } - - delete[] seedtable; + delete[] seedtable; //... perform FT to real space fftw_plan_t plan = FFTW_API(plan_dft_c2r_3d)(res, res, res, knoise, rnoise, FFTW_ESTIMATE); @@ -140,7 +133,7 @@ void music_wnoise_generator:: gen_topgrid_NGenIC(size_t res, long baseseed) { for (int i = 0; i < (int)res; ++i) for (size_t j = 0; j < res; ++j) for (size_t k = 0; k < res; ++k) - (*this)(i, j, k) = rnoise[((size_t)i * res + j) * res + k]; + (*this)(i, j, k) = -rnoise[((size_t)i * res + j) * (res + 2) + k]; delete[] rnoise; } @@ -168,8 +161,6 @@ music_wnoise_generator::music_wnoise_generator( unsigned res, unsigned cubes if( bUseNGenIC ){ cubesize_ = res; ncubes_ = 1; - rnums_.push_back(new Meshvar(res, 0, 0, 0)); - cubemap_[0] = 0; // create dummy map index } initialize(); From b6cef8dd016f8ead539ebd4fe5fc3161fc09e23c Mon Sep 17 00:00:00 2001 From: Oliver Hahn Date: Tue, 27 Feb 2024 01:59:49 +0800 Subject: [PATCH 8/8] updated N-GenIC RNG to multithreading --- src/plugins/random_music_wnoise_generator.cc | 111 ++++++++++--------- 1 file changed, 59 insertions(+), 52 deletions(-) diff --git a/src/plugins/random_music_wnoise_generator.cc b/src/plugins/random_music_wnoise_generator.cc index 324450f..ae75110 100644 --- a/src/plugins/random_music_wnoise_generator.cc +++ b/src/plugins/random_music_wnoise_generator.cc @@ -48,77 +48,84 @@ void music_wnoise_generator:: gen_topgrid_NGenIC(size_t res, long baseseed) { for (j = 0; j < i + 1; j++) seedtable[(res - 1 - j) * res + (res - 1 - i)] = 0x7fffffff * gsl_rng_uniform(random_generator); } + gsl_rng_free( random_generator ); real_t *rnoise = new real_t[res * res * (res + 2)]; complex_t *knoise = reinterpret_cast(rnoise); double fnorm = pow((double)res, -1.5); -// /#warning need to check for race conditions below -//#pragma omp parallel for - for (size_t i = 0; i < res; i++) { - int ii = (int)res - (int)i; - if (ii == (int)res) - ii = 0; + // launch threads with indendent RNGs + #pragma omp parallel + { + gsl_rng *thread_rng = gsl_rng_alloc(gsl_rng_ranlxd1); - for (size_t j = 0; j < res; j++) { - gsl_rng_set(random_generator, seedtable[i * res + j]); - for (size_t k = 0; k < res / 2; k++) { - double phase = gsl_rng_uniform(random_generator) * 2 * M_PI; - double ampl; - do { - ampl = gsl_rng_uniform(random_generator); - } while (ampl == 0); + #pragma omp for + for (size_t i = 0; i < res; i++) { + int ii = (int)res - (int)i; + if (ii == (int)res) + ii = 0; - if (i == res / 2 || j == res / 2 || k == res / 2) - continue; - if (i == 0 && j == 0 && k == 0) - continue; + for (size_t j = 0; j < res; j++) { + gsl_rng_set(thread_rng, seedtable[i * res + j]); + for (size_t k = 0; k < res / 2; k++) { + double phase = gsl_rng_uniform(thread_rng) * 2 * M_PI; + double ampl; + do { + ampl = gsl_rng_uniform(thread_rng); + } while (ampl == 0); - T rp = -sqrt(-log(ampl)) * cos(phase) * fnorm; - T ip = -sqrt(-log(ampl)) * sin(phase) * fnorm; + if (i == res / 2 || j == res / 2 || k == res / 2) + continue; + if (i == 0 && j == 0 && k == 0) + continue; - if (k > 0) { - RE(knoise[(i * res + j) * (res / 2 + 1) + k]) = rp; - IM(knoise[(i * res + j) * (res / 2 + 1) + k]) = ip; - } else /* k=0 plane needs special treatment */ - { - if (i == 0) { - if (j >= res / 2) { - continue; + T rp = -sqrt(-log(ampl)) * cos(phase) * fnorm; + T ip = -sqrt(-log(ampl)) * sin(phase) * fnorm; + + if (k > 0) { + RE(knoise[(i * res + j) * (res / 2 + 1) + k]) = rp; + IM(knoise[(i * res + j) * (res / 2 + 1) + k]) = ip; + } else /* k=0 plane needs special treatment */ + { + if (i == 0) { + if (j >= res / 2) { + continue; + } else { + int jj = + (int)res - (int)j; /* note: j!=0 surely holds at this point */ + + RE(knoise[(i * res + j) * (res / 2 + 1) + k]) = rp; + IM(knoise[(i * res + j) * (res / 2 + 1) + k]) = ip; + + RE(knoise[(i * res + jj) * (res / 2 + 1) + k]) = rp; + IM(knoise[(i * res + jj) * (res / 2 + 1) + k]) = -ip; + } } else { - int jj = - (int)res - (int)j; /* note: j!=0 surely holds at this point */ + if (i >= res / 2) { + continue; + } else { + int ii = (int)res - (int)i; + if (ii == (int)res) + ii = 0; + int jj = (int)res - (int)j; + if (jj == (int)res) + jj = 0; - RE(knoise[(i * res + j) * (res / 2 + 1) + k]) = rp; - IM(knoise[(i * res + j) * (res / 2 + 1) + k]) = ip; + RE(knoise[(i * res + j) * (res / 2 + 1) + k]) = rp; + IM(knoise[(i * res + j) * (res / 2 + 1) + k]) = ip; - RE(knoise[(i * res + jj) * (res / 2 + 1) + k]) = rp; - IM(knoise[(i * res + jj) * (res / 2 + 1) + k]) = -ip; - } - } else { - if (i >= res / 2) { - continue; - } else { - int ii = (int)res - (int)i; - if (ii == (int)res) - ii = 0; - int jj = (int)res - (int)j; - if (jj == (int)res) - jj = 0; - - RE(knoise[(i * res + j) * (res / 2 + 1) + k]) = rp; - IM(knoise[(i * res + j) * (res / 2 + 1) + k]) = ip; - - if (ii >= 0 && ii < (int)res) { - RE(knoise[(ii * res + jj) * (res / 2 + 1) + k]) = rp; - IM(knoise[(ii * res + jj) * (res / 2 + 1) + k]) = -ip; + if (ii >= 0 && ii < (int)res) { + RE(knoise[(ii * res + jj) * (res / 2 + 1) + k]) = rp; + IM(knoise[(ii * res + jj) * (res / 2 + 1) + k]) = -ip; + } } } } } } } + gsl_rng_free( thread_rng ); } delete[] seedtable;