Skip to content

Commit

Permalink
TestRKAB: Changed random noise function to deterministic pseudo noise…
Browse files Browse the repository at this point in the history
… based on the sign of the cossine function
  • Loading branch information
Lucas Sanches committed Nov 5, 2024
1 parent 6836198 commit 13ac546
Show file tree
Hide file tree
Showing 21 changed files with 31 additions and 1,576 deletions.
10 changes: 4 additions & 6 deletions TestRKAB/par/noise.par
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ ActiveThorns = "
"

###### Settings ######
$final_time = 1.0
$out_every_time = 0.25
$final_time = 100.0
$out_every_time = 1.0

$start = -1.0
$end = 1.0

$ncells = 160
$cfl = 0.25
$ncells = 128
$cfl = 0.9
######################

# We are using a 5 point centered stencil
Expand All @@ -27,8 +27,6 @@ $out_every_it = ceil($out_every_time / $dt)

TestRKAB::compute_error = no
TestRKAB::initial_condition = "noise"
TestRKAB::noise_seed = 100.0
TestRKAB::noise_boundary = 1.0e-7

CarpetX::poison_undefined_values = no
CarpetX::verbose = no
Expand Down
9 changes: 2 additions & 7 deletions TestRKAB/param.ccl
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@ CCTK_REAL gaussian_width "width of Gaussian"
(0:* :: ""
} 1.0

CCTK_INT noise_seed "Seed of the RNG for noise initial data"
CCTK_REAL noise_boundary "Noise will be generated in the [-noise_boundary, noise_boundary] range"
{
*:* :: ""
} 100

CCTK_REAL noise_boundary "Nois will be generated in the [-noise_boundary, noise_boundary] range"
{
*:* :: ""
} 1.0e-7
} 1.0e-10
40 changes: 25 additions & 15 deletions TestRKAB/src/initial.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,38 @@ extern "C" void TestRKAB_Initial(CCTK_ARGUMENTS) {
});

} else if (CCTK_EQUALS(initial_condition, "noise")) {
// Make sure our RNG structures are initialized only once, regardless of the
// number of threads used.
static std::mt19937_64 noise_engine{noise_seed};
static std::uniform_real_distribution<CCTK_REAL> noise_distrib{
-noise_boundary, noise_boundary};

grid.loop_int<0, 0, 0>(
grid.nghostzones,
[&] CCTK_HOST(const Loop::PointDesc &p) CCTK_ATTRIBUTE_ALWAYS_INLINE {
#pragma omp critical
{
const auto value{noise_distrib(noise_engine)};
phi(p.I) = value;
Pi(p.I) = value;
Dx(p.I) = value;
Dy(p.I) = value;
Dz(p.I) = value;
}
using std::cos;

const auto noise_func{cos(10.0 * p.x / p.dx) *
cos(10.0 * p.y / p.dy) *
cos(10.0 * p.z / p.dz)};

const auto noise_value{noise_boundary *
(noise_func > 0 ? 1.0 : -1.0)};

phi(p.I) = noise_value;
Pi(p.I) = noise_value;
Dx(p.I) = noise_value;
Dy(p.I) = noise_value;
Dz(p.I) = noise_value;
});
} else {
CCTK_VERROR("Unknown initial condition \"%s\"", initial_condition);
}

// Regardless of ID choice, we initialize the previous RHS with zeros
grid.loop_int_device<0, 0, 0>(grid.nghostzones,
[=] CCTK_DEVICE(const Loop::PointDesc &p)
CCTK_ATTRIBUTE_ALWAYS_INLINE {
phi_pre(p.I) = 0.0;
Pi_pre(p.I) = 0.0;
Dx_pre(p.I) = 0.0;
Dy_pre(p.I) = 0.0;
Dz_pre(p.I) = 0.0;
});
}

} // namespace TestRKAB
86 changes: 0 additions & 86 deletions TestRKAB/test/gaussian/testrkab-error.it000000.x.tsv

This file was deleted.

Loading

0 comments on commit 13ac546

Please sign in to comment.