From e8984be8dd0f832d9d38ad494073b94a194dacc2 Mon Sep 17 00:00:00 2001 From: Lucas Timotheo Sanches Date: Fri, 14 Feb 2025 15:28:53 -0600 Subject: [PATCH 1/5] NoiseX: New thorn. ADMBaseX: Adapted to use NoiseX. --- ADMBaseX/configuration.ccl | 2 +- ADMBaseX/interface.ccl | 1 + ADMBaseX/param.ccl | 5 +- ADMBaseX/schedule.ccl | 3 +- ADMBaseX/src/noise.cxx | 103 +++++++++++-------------------------- NoiseX/README | 11 ++++ NoiseX/configuration.ccl | 7 +++ NoiseX/interface.ccl | 7 +++ NoiseX/param.ccl | 29 +++++++++++ NoiseX/schedule.ccl | 6 +++ NoiseX/src/make.code.defn | 7 +++ NoiseX/src/noisex.cxx | 80 ++++++++++++++++++++++++++++ NoiseX/src/noisex.hxx | 9 ++++ 13 files changed, 190 insertions(+), 80 deletions(-) create mode 100644 NoiseX/README create mode 100644 NoiseX/configuration.ccl create mode 100644 NoiseX/interface.ccl create mode 100644 NoiseX/param.ccl create mode 100644 NoiseX/schedule.ccl create mode 100644 NoiseX/src/make.code.defn create mode 100644 NoiseX/src/noisex.cxx create mode 100644 NoiseX/src/noisex.hxx diff --git a/ADMBaseX/configuration.ccl b/ADMBaseX/configuration.ccl index 198e70337..caaa54e65 100644 --- a/ADMBaseX/configuration.ccl +++ b/ADMBaseX/configuration.ccl @@ -1,3 +1,3 @@ # Configuration definition for thorn ADMBaseX -REQUIRES Loop +REQUIRES Loop NoiseX diff --git a/ADMBaseX/interface.ccl b/ADMBaseX/interface.ccl index adaf3b270..ae7a6438c 100644 --- a/ADMBaseX/interface.ccl +++ b/ADMBaseX/interface.ccl @@ -3,6 +3,7 @@ IMPLEMENTS: ADMBaseX USES INCLUDE HEADER: loop_device.hxx +USES INCLUDE HEADER: noisex.hxx diff --git a/ADMBaseX/param.ccl b/ADMBaseX/param.ccl index 725b64ba3..0d7a267f6 100644 --- a/ADMBaseX/param.ccl +++ b/ADMBaseX/param.ccl @@ -47,7 +47,6 @@ CCTK_REAL linear_wave_wavelength "Linear wave wavelength" 0.0:* :: "" } 1.0 -CCTK_REAL noise_amplitude "Noise amplitude" +BOOLEAN add_noise "Add noise to initial data" { - 0.0:* :: "" -} 0.0 +} no diff --git a/ADMBaseX/schedule.ccl b/ADMBaseX/schedule.ccl index 9d0db9191..a00927403 100644 --- a/ADMBaseX/schedule.ccl +++ b/ADMBaseX/schedule.ccl @@ -106,9 +106,8 @@ if (CCTK_EQUALS(initial_dtshift, "zero")) { -if (noise_amplitude != 0) { +if (add_noise) { # TODO: Also add noise during evolution? - # TODO: Noise should be added by a separate thorn. SCHEDULE ADMBaseX_add_noise IN ADMBaseX_PostInitial { diff --git a/ADMBaseX/src/noise.cxx b/ADMBaseX/src/noise.cxx index e805b13d7..6f60c4e5e 100644 --- a/ADMBaseX/src/noise.cxx +++ b/ADMBaseX/src/noise.cxx @@ -4,85 +4,40 @@ #include #include -#include +#include namespace ADMBaseX { using namespace Loop; -using namespace std; extern "C" void ADMBaseX_add_noise(CCTK_ARGUMENTS) { - DECLARE_CCTK_ARGUMENTS_ADMBaseX_add_noise; - DECLARE_CCTK_PARAMETERS; - - // Hardware random device - random_device device; - // Create and seed software random number engine from hardware random number - default_random_engine engine(device()); - // Random number distribution - uniform_real_distribution distribution(-noise_amplitude, - noise_amplitude); - const auto add_noise = [&](CCTK_REAL &restrict var) { - var += distribution(engine); - }; - - const GF3D gxx_(cctkGH, gxx); - const GF3D gxy_(cctkGH, gxy); - const GF3D gxz_(cctkGH, gxz); - const GF3D gyy_(cctkGH, gyy); - const GF3D gyz_(cctkGH, gyz); - const GF3D gzz_(cctkGH, gzz); - - const GF3D kxx_(cctkGH, kxx); - const GF3D kxy_(cctkGH, kxy); - const GF3D kxz_(cctkGH, kxz); - const GF3D kyy_(cctkGH, kyy); - const GF3D kyz_(cctkGH, kyz); - const GF3D kzz_(cctkGH, kzz); - - const GF3D alp_(cctkGH, alp); - - const GF3D dtalp_(cctkGH, dtalp); - - const GF3D betax_(cctkGH, betax); - const GF3D betay_(cctkGH, betay); - const GF3D betaz_(cctkGH, betaz); - - const GF3D dtbetax_(cctkGH, dtbetax); - const GF3D dtbetay_(cctkGH, dtbetay); - const GF3D dtbetaz_(cctkGH, dtbetaz); - - loop_int<0, 0, 0>(cctkGH, [&](const PointDesc &p) { add_noise(gxx_(p.I)); }); - loop_int<0, 0, 0>(cctkGH, [&](const PointDesc &p) { add_noise(gxy_(p.I)); }); - loop_int<0, 0, 0>(cctkGH, [&](const PointDesc &p) { add_noise(gxz_(p.I)); }); - loop_int<0, 0, 0>(cctkGH, [&](const PointDesc &p) { add_noise(gyy_(p.I)); }); - loop_int<0, 0, 0>(cctkGH, [&](const PointDesc &p) { add_noise(gyz_(p.I)); }); - loop_int<0, 0, 0>(cctkGH, [&](const PointDesc &p) { add_noise(gzz_(p.I)); }); - - loop_int<0, 0, 0>(cctkGH, [&](const PointDesc &p) { add_noise(kxx_(p.I)); }); - loop_int<0, 0, 0>(cctkGH, [&](const PointDesc &p) { add_noise(kxy_(p.I)); }); - loop_int<0, 0, 0>(cctkGH, [&](const PointDesc &p) { add_noise(kxz_(p.I)); }); - loop_int<0, 0, 0>(cctkGH, [&](const PointDesc &p) { add_noise(kyy_(p.I)); }); - loop_int<0, 0, 0>(cctkGH, [&](const PointDesc &p) { add_noise(kyz_(p.I)); }); - loop_int<0, 0, 0>(cctkGH, [&](const PointDesc &p) { add_noise(kzz_(p.I)); }); - - loop_int<0, 0, 0>(cctkGH, [&](const PointDesc &p) { add_noise(alp_(p.I)); }); - - loop_int<0, 0, 0>(cctkGH, - [&](const PointDesc &p) { add_noise(dtalp_(p.I)); }); - - loop_int<0, 0, 0>(cctkGH, - [&](const PointDesc &p) { add_noise(betax_(p.I)); }); - loop_int<0, 0, 0>(cctkGH, - [&](const PointDesc &p) { add_noise(betay_(p.I)); }); - loop_int<0, 0, 0>(cctkGH, - [&](const PointDesc &p) { add_noise(betaz_(p.I)); }); - - loop_int<0, 0, 0>(cctkGH, - [&](const PointDesc &p) { add_noise(dtbetax_(p.I)); }); - loop_int<0, 0, 0>(cctkGH, - [&](const PointDesc &p) { add_noise(dtbetay_(p.I)); }); - loop_int<0, 0, 0>(cctkGH, - [&](const PointDesc &p) { add_noise(dtbetaz_(p.I)); }); + DECLARE_CCTK_ARGUMENTSX_ADMBaseX_add_noise; + + NoiseX::add(cctkGH, gxx); + NoiseX::add(cctkGH, gxx); + NoiseX::add(cctkGH, gxy); + NoiseX::add(cctkGH, gxz); + NoiseX::add(cctkGH, gyy); + NoiseX::add(cctkGH, gyz); + NoiseX::add(cctkGH, gzz); + + NoiseX::add(cctkGH, kxx); + NoiseX::add(cctkGH, kxy); + NoiseX::add(cctkGH, kxz); + NoiseX::add(cctkGH, kyy); + NoiseX::add(cctkGH, kyz); + NoiseX::add(cctkGH, kzz); + + NoiseX::add(cctkGH, alp); + + NoiseX::add(cctkGH, dtalp); + + NoiseX::add(cctkGH, betax); + NoiseX::add(cctkGH, betay); + NoiseX::add(cctkGH, betaz); + + NoiseX::add(cctkGH, dtbetax); + NoiseX::add(cctkGH, dtbetay); + NoiseX::add(cctkGH, dtbetaz); } } // namespace ADMBaseX diff --git a/NoiseX/README b/NoiseX/README new file mode 100644 index 000000000..721e66bfc --- /dev/null +++ b/NoiseX/README @@ -0,0 +1,11 @@ +Cactus Code Thorn Noise +Author(s) : Lucas Timotheo Sanches +Maintainer(s): Lucas Timotheo Sanches +Licence : GPL +-------------------------------------------------------------------------- + +1. Purpose + +This thorn provides a unified way to add pseudo-random noise to CarpetX +variables. This is useful mainly for testing time evolution codes, i.e., +performing robust stability tests. diff --git a/NoiseX/configuration.ccl b/NoiseX/configuration.ccl new file mode 100644 index 000000000..69368e8bd --- /dev/null +++ b/NoiseX/configuration.ccl @@ -0,0 +1,7 @@ +# Configuration definition for thorn NoiseX + +REQUIRES Loop + +PROVIDES NoiseX +{ +} \ No newline at end of file diff --git a/NoiseX/interface.ccl b/NoiseX/interface.ccl new file mode 100644 index 000000000..69e022181 --- /dev/null +++ b/NoiseX/interface.ccl @@ -0,0 +1,7 @@ +# Interface definition for thorn NoiseX + +IMPLEMENTS: NoiseX + +USES INCLUDE HEADER: loop_device.hxx + +INCLUDE HEADER: noisex.hxx in noisex.hxx \ No newline at end of file diff --git a/NoiseX/param.ccl b/NoiseX/param.ccl new file mode 100644 index 000000000..a0904c674 --- /dev/null +++ b/NoiseX/param.ccl @@ -0,0 +1,29 @@ +# Parameter definitions for thorn NoiseX + +KEYWORD seed_type "The type of seed to use" +{ + "hardware random device" :: "Uses the hardware random device to generate a seed" + "fixed" :: "A fixed integer value is used as sseed" +} "hardware random device" + +KEYWORD random_engine "The random engine to use" +{ + "default" :: "Uses C++'s default random engine" + "mersenne twister" :: "32-bit Mersenne Twister by Matsumoto and Nishimura, 1998" + "sine wave" :: "Uses the values of a high frequency sine wave to create pseudo-randomness" +} "default" + +INT fixed_seed_value "The value of the fixed seed to use" +{ + 0:* :: "Positive integer" +} 100 + +REAL noise_amplitude "The value of the noise amplitude to use" +{ + 0.0:* :: "Positive real" +} 1.0e-10 + +REAL noise_frequency "The value of the noise frenquecy to use with the sine wave engie" +{ + 0.0:* :: "Positive real" +} 5.0 \ No newline at end of file diff --git a/NoiseX/schedule.ccl b/NoiseX/schedule.ccl new file mode 100644 index 000000000..4cd9abb97 --- /dev/null +++ b/NoiseX/schedule.ccl @@ -0,0 +1,6 @@ +# Schedule definitions for thorn NoiseX + +SCHEDULE NoiseX_setup_globals AT startup BEFORE Driver_Startup +{ + LANG: C +} "Create NoiseX global data" \ No newline at end of file diff --git a/NoiseX/src/make.code.defn b/NoiseX/src/make.code.defn new file mode 100644 index 000000000..fd845890d --- /dev/null +++ b/NoiseX/src/make.code.defn @@ -0,0 +1,7 @@ +# Main make.code.defn file for thorn NoiseX + +# Source files in this directory +SRCS = noisex.cxx + +# Subdirectories containing source files +SUBDIRS = \ No newline at end of file diff --git a/NoiseX/src/noisex.cxx b/NoiseX/src/noisex.cxx new file mode 100644 index 000000000..5f27a3ff7 --- /dev/null +++ b/NoiseX/src/noisex.cxx @@ -0,0 +1,80 @@ +#include + +#include +#include +#include + +#include "noisex.hxx" + +#include +#include + +namespace NoiseX { + +struct NoiseData { + std::default_random_engine default_engine{}; + std::mt19937 mt_engine{}; + std::uniform_real_distribution distrib{}; +}; + +static NoiseData noise_data{}; + +extern "C" int NoiseX_setup_globals() { + DECLARE_CCTK_PARAMETERS; + + if (CCTK_EQUALS(seed_type, "hardware random device")) { + std::random_device device{}; + noise_data.default_engine = std::default_random_engine(device()); + noise_data.mt_engine = std::mt19937(device()); + } else if (CCTK_EQUALS(seed_type, "fixed")) { + noise_data.default_engine = std::default_random_engine(fixed_seed_value); + noise_data.mt_engine = std::mt19937(fixed_seed_value); + } else { + CCTK_VERROR("Unrecognized seed type \"%s\"", seed_type); + } + + noise_data.distrib = std::uniform_real_distribution( + -noise_amplitude, noise_amplitude); + + return 0; +} + +void add(const cGH *restrict const cctkGH, Loop::GF3D2 var) { + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + const Loop::GridDescBaseDevice grid(cctkGH); + + if (CCTK_EQUALS(random_engine, "default")) { + grid.loop_int<0, 0, 0>(grid.nghostzones, + [&] CCTK_DEVICE CCTK_HOST(const Loop::PointDesc &p) + CCTK_ATTRIBUTE_ALWAYS_INLINE { + var(p.I) += noise_data.distrib( + noise_data.default_engine); + }); + + } else if (CCTK_EQUALS(random_engine, "mersenne twister")) { + grid.loop_int<0, 0, 0>(grid.nghostzones, + [&] CCTK_DEVICE CCTK_HOST(const Loop::PointDesc &p) + CCTK_ATTRIBUTE_ALWAYS_INLINE { + var(p.I) += + noise_data.distrib(noise_data.mt_engine); + }); + + } else if (CCTK_EQUALS(random_engine, "sine wave")) { + grid.loop_int<0, 0, 0>(grid.nghostzones, + [=] CCTK_DEVICE CCTK_HOST(const Loop::PointDesc &p) + CCTK_ATTRIBUTE_ALWAYS_INLINE { + using std::sin; + var(p.I) += noise_amplitude * + sin(noise_frequency * p.x / p.dx) * + sin(noise_frequency * p.y / p.dy) * + sin(noise_frequency * p.z / p.dz); + }); + + } else { + CCTK_VERROR("Unrecognized random engine \"%s\"", random_engine); + } +} + +} // namespace NoiseX \ No newline at end of file diff --git a/NoiseX/src/noisex.hxx b/NoiseX/src/noisex.hxx new file mode 100644 index 000000000..7ac43786c --- /dev/null +++ b/NoiseX/src/noisex.hxx @@ -0,0 +1,9 @@ +#include + +#include + +namespace NoiseX { + +void add(const cGH *restrict const cctkGH, Loop::GF3D2 var); + +} // namespace NoiseX \ No newline at end of file From 3d0d5e37a81698ce5ee6be7864e5639683709b8f Mon Sep 17 00:00:00 2001 From: Lucas Timotheo Sanches Date: Fri, 14 Feb 2025 16:20:36 -0600 Subject: [PATCH 2/5] NoiseX: Global data is now a unique pointer --- NoiseX/src/noisex.cxx | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/NoiseX/src/noisex.cxx b/NoiseX/src/noisex.cxx index 5f27a3ff7..6b8ef4583 100644 --- a/NoiseX/src/noisex.cxx +++ b/NoiseX/src/noisex.cxx @@ -8,6 +8,7 @@ #include #include +#include namespace NoiseX { @@ -17,25 +18,32 @@ struct NoiseData { std::uniform_real_distribution distrib{}; }; -static NoiseData noise_data{}; +std::unique_ptr g_noise_data{}; extern "C" int NoiseX_setup_globals() { DECLARE_CCTK_PARAMETERS; if (CCTK_EQUALS(seed_type, "hardware random device")) { std::random_device device{}; - noise_data.default_engine = std::default_random_engine(device()); - noise_data.mt_engine = std::mt19937(device()); + const auto random_seed{device()}; + + g_noise_data = std::make_unique( + NoiseData{.default_engine = std::default_random_engine(random_seed), + .mt_engine = std::mt19937(random_seed), + .distrib = std::uniform_real_distribution( + -noise_amplitude, noise_amplitude)}); + } else if (CCTK_EQUALS(seed_type, "fixed")) { - noise_data.default_engine = std::default_random_engine(fixed_seed_value); - noise_data.mt_engine = std::mt19937(fixed_seed_value); + g_noise_data = std::make_unique(NoiseData{ + .default_engine = std::default_random_engine(fixed_seed_value), + .mt_engine = std::mt19937(fixed_seed_value), + .distrib = std::uniform_real_distribution(-noise_amplitude, + noise_amplitude)}); + } else { CCTK_VERROR("Unrecognized seed type \"%s\"", seed_type); } - noise_data.distrib = std::uniform_real_distribution( - -noise_amplitude, noise_amplitude); - return 0; } @@ -47,18 +55,18 @@ void add(const cGH *restrict const cctkGH, Loop::GF3D2 var) { if (CCTK_EQUALS(random_engine, "default")) { grid.loop_int<0, 0, 0>(grid.nghostzones, - [&] CCTK_DEVICE CCTK_HOST(const Loop::PointDesc &p) + [=] CCTK_DEVICE CCTK_HOST(const Loop::PointDesc &p) CCTK_ATTRIBUTE_ALWAYS_INLINE { - var(p.I) += noise_data.distrib( - noise_data.default_engine); + var(p.I) += g_noise_data->distrib( + g_noise_data->default_engine); }); } else if (CCTK_EQUALS(random_engine, "mersenne twister")) { grid.loop_int<0, 0, 0>(grid.nghostzones, - [&] CCTK_DEVICE CCTK_HOST(const Loop::PointDesc &p) + [=] CCTK_DEVICE CCTK_HOST(const Loop::PointDesc &p) CCTK_ATTRIBUTE_ALWAYS_INLINE { - var(p.I) += - noise_data.distrib(noise_data.mt_engine); + var(p.I) += g_noise_data->distrib( + g_noise_data->mt_engine); }); } else if (CCTK_EQUALS(random_engine, "sine wave")) { From 916465f199c56b5445bbdee4ebf5518e55cf3fe2 Mon Sep 17 00:00:00 2001 From: Lucas Timotheo Sanches Date: Fri, 14 Feb 2025 17:46:37 -0600 Subject: [PATCH 3/5] NoiseX: Noise is added on the host --- NoiseX/interface.ccl | 2 +- NoiseX/src/noisex.cxx | 68 ++++++++++++++++++------------------------- NoiseX/src/noisex.hxx | 2 +- 3 files changed, 31 insertions(+), 41 deletions(-) diff --git a/NoiseX/interface.ccl b/NoiseX/interface.ccl index 69e022181..8107f55b4 100644 --- a/NoiseX/interface.ccl +++ b/NoiseX/interface.ccl @@ -2,6 +2,6 @@ IMPLEMENTS: NoiseX -USES INCLUDE HEADER: loop_device.hxx +USES INCLUDE HEADER: loop.hxx INCLUDE HEADER: noisex.hxx in noisex.hxx \ No newline at end of file diff --git a/NoiseX/src/noisex.cxx b/NoiseX/src/noisex.cxx index 6b8ef4583..48978d70e 100644 --- a/NoiseX/src/noisex.cxx +++ b/NoiseX/src/noisex.cxx @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -8,7 +8,6 @@ #include #include -#include namespace NoiseX { @@ -18,32 +17,26 @@ struct NoiseData { std::uniform_real_distribution distrib{}; }; -std::unique_ptr g_noise_data{}; +static NoiseData noise_data{}; extern "C" int NoiseX_setup_globals() { DECLARE_CCTK_PARAMETERS; if (CCTK_EQUALS(seed_type, "hardware random device")) { std::random_device device{}; - const auto random_seed{device()}; - - g_noise_data = std::make_unique( - NoiseData{.default_engine = std::default_random_engine(random_seed), - .mt_engine = std::mt19937(random_seed), - .distrib = std::uniform_real_distribution( - -noise_amplitude, noise_amplitude)}); - + const auto random_seed_value{device()}; + noise_data.default_engine = std::default_random_engine(random_seed_value); + noise_data.mt_engine = std::mt19937(random_seed_value); } else if (CCTK_EQUALS(seed_type, "fixed")) { - g_noise_data = std::make_unique(NoiseData{ - .default_engine = std::default_random_engine(fixed_seed_value), - .mt_engine = std::mt19937(fixed_seed_value), - .distrib = std::uniform_real_distribution(-noise_amplitude, - noise_amplitude)}); - + noise_data.default_engine = std::default_random_engine(fixed_seed_value); + noise_data.mt_engine = std::mt19937(fixed_seed_value); } else { CCTK_VERROR("Unrecognized seed type \"%s\"", seed_type); } + noise_data.distrib = std::uniform_real_distribution( + -noise_amplitude, noise_amplitude); + return 0; } @@ -51,34 +44,31 @@ void add(const cGH *restrict const cctkGH, Loop::GF3D2 var) { DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; - const Loop::GridDescBaseDevice grid(cctkGH); + const Loop::GridDescBase grid(cctkGH); if (CCTK_EQUALS(random_engine, "default")) { - grid.loop_int<0, 0, 0>(grid.nghostzones, - [=] CCTK_DEVICE CCTK_HOST(const Loop::PointDesc &p) - CCTK_ATTRIBUTE_ALWAYS_INLINE { - var(p.I) += g_noise_data->distrib( - g_noise_data->default_engine); - }); + grid.loop_int<0, 0, 0>( + grid.nghostzones, + [&] CCTK_HOST(const Loop::PointDesc &p) CCTK_ATTRIBUTE_ALWAYS_INLINE { + var(p.I) += noise_data.distrib(noise_data.default_engine); + }); } else if (CCTK_EQUALS(random_engine, "mersenne twister")) { - grid.loop_int<0, 0, 0>(grid.nghostzones, - [=] CCTK_DEVICE CCTK_HOST(const Loop::PointDesc &p) - CCTK_ATTRIBUTE_ALWAYS_INLINE { - var(p.I) += g_noise_data->distrib( - g_noise_data->mt_engine); - }); + grid.loop_int<0, 0, 0>( + grid.nghostzones, + [&] CCTK_HOST(const Loop::PointDesc &p) CCTK_ATTRIBUTE_ALWAYS_INLINE { + var(p.I) += noise_data.distrib(noise_data.mt_engine); + }); } else if (CCTK_EQUALS(random_engine, "sine wave")) { - grid.loop_int<0, 0, 0>(grid.nghostzones, - [=] CCTK_DEVICE CCTK_HOST(const Loop::PointDesc &p) - CCTK_ATTRIBUTE_ALWAYS_INLINE { - using std::sin; - var(p.I) += noise_amplitude * - sin(noise_frequency * p.x / p.dx) * - sin(noise_frequency * p.y / p.dy) * - sin(noise_frequency * p.z / p.dz); - }); + grid.loop_int<0, 0, 0>( + grid.nghostzones, + [=] CCTK_HOST(const Loop::PointDesc &p) CCTK_ATTRIBUTE_ALWAYS_INLINE { + using std::sin; + var(p.I) += noise_amplitude * sin(noise_frequency * p.x / p.dx) * + sin(noise_frequency * p.y / p.dy) * + sin(noise_frequency * p.z / p.dz); + }); } else { CCTK_VERROR("Unrecognized random engine \"%s\"", random_engine); diff --git a/NoiseX/src/noisex.hxx b/NoiseX/src/noisex.hxx index 7ac43786c..36235cb13 100644 --- a/NoiseX/src/noisex.hxx +++ b/NoiseX/src/noisex.hxx @@ -1,6 +1,6 @@ #include -#include +#include namespace NoiseX { From 2ccd6c3aea7fd6cf4e23ac2daa05257788350622 Mon Sep 17 00:00:00 2001 From: Lucas Timotheo Sanches Date: Fri, 14 Feb 2025 17:52:33 -0600 Subject: [PATCH 4/5] CI: Updated thornlist to include NoiseX --- scripts/carpetx.th | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/carpetx.th b/scripts/carpetx.th index 7b36eb5f4..9cedc4317 100644 --- a/scripts/carpetx.th +++ b/scripts/carpetx.th @@ -709,6 +709,7 @@ CarpetX/FluxWaveToyX CarpetX/HydroBaseX CarpetX/Loop CarpetX/MovingBoxToy +CarpetX/NoiseX CarpetX/ODESolvers CarpetX/PDESolvers CarpetX/PoissonX From 0609f66bea6c79be5d856209937513923e8f5d9c Mon Sep 17 00:00:00 2001 From: Lucas Timotheo Sanches Date: Fri, 14 Feb 2025 20:47:25 -0600 Subject: [PATCH 5/5] NoiseX: Changed the parameter name for the random seed --- NoiseX/param.ccl | 10 +++++----- NoiseX/src/noisex.cxx | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/NoiseX/param.ccl b/NoiseX/param.ccl index a0904c674..055f664f8 100644 --- a/NoiseX/param.ccl +++ b/NoiseX/param.ccl @@ -2,15 +2,15 @@ KEYWORD seed_type "The type of seed to use" { - "hardware random device" :: "Uses the hardware random device to generate a seed" + "random" :: "Uses the hardware random device to generate a seed" "fixed" :: "A fixed integer value is used as sseed" -} "hardware random device" +} "random" KEYWORD random_engine "The random engine to use" { - "default" :: "Uses C++'s default random engine" - "mersenne twister" :: "32-bit Mersenne Twister by Matsumoto and Nishimura, 1998" - "sine wave" :: "Uses the values of a high frequency sine wave to create pseudo-randomness" + "default" :: "Uses C++'s default random engine" + "mersenne twister" :: "32-bit Mersenne Twister by Matsumoto and Nishimura, 1998" + "sine wave" :: "Uses the values of a high frequency sine wave to create pseudo-randomness" } "default" INT fixed_seed_value "The value of the fixed seed to use" diff --git a/NoiseX/src/noisex.cxx b/NoiseX/src/noisex.cxx index 48978d70e..ae68aba97 100644 --- a/NoiseX/src/noisex.cxx +++ b/NoiseX/src/noisex.cxx @@ -22,7 +22,7 @@ static NoiseData noise_data{}; extern "C" int NoiseX_setup_globals() { DECLARE_CCTK_PARAMETERS; - if (CCTK_EQUALS(seed_type, "hardware random device")) { + if (CCTK_EQUALS(seed_type, "random")) { std::random_device device{}; const auto random_seed_value{device()}; noise_data.default_engine = std::default_random_engine(random_seed_value);