From fc0758578cc6f07ab45fb79163b6e4d573374530 Mon Sep 17 00:00:00 2001 From: pollney Date: Wed, 21 May 2003 16:12:38 +0000 Subject: noisy boundary conditions for robust stability tests (due to Erik Schnetter). git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/Noise/trunk@13 936e0995-0e4f-0410-aade-aa24bf7baf3d --- src/bc_noise.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++--------- src/noise.h | 1 - 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/src/bc_noise.c b/src/bc_noise.c index 2779051..e6c25ed 100644 --- a/src/bc_noise.c +++ b/src/bc_noise.c @@ -1,4 +1,6 @@ + + #include "noise.h" #include "cctk_Parameters.h" @@ -16,6 +18,43 @@ static int ApplyBndNoise (const cGH *GH, int first_var, int num_vars); + + +int +BndNoiseVI (const cGH *GH, const int *stencil, int vi) +{ + int retval; + retval = ApplyBndNoise (GH, -1, stencil, 0, vi, 1); + return retval; +} + +void +CCTK_FCALL CCTK_FNAME (BndNoiseVI) (int *ierr, const cGH *GH, + const int *stencil, const int *vi) +{ + *ierr = BndNoiseVI (GH, stencil, *vi); +} + +int +BndNoiseVN (const cGH *GH, const int *stencil, const char *vn) +{ + int vi, retval; + vi = CCTK_VarIndex(vn); + retval = BndNoiseVI (GH, stencil, vi); + return retval; +} + +void +CCTK_FCALL CCTK_FNAME (BndNoiseVN) (int *ierr, const cGH *GH, + const int *stencil, ONE_FORTSTRING_ARG) +{ + ONE_FORTSTRING_CREATE (vn); + *ierr = BndNoiseVN (GH, stencil, vn); + free (vn); +} + + + int BndNoiseGI (const cGH *GH, const int *stencil, int gi) { @@ -37,6 +76,8 @@ BndNoiseGI (const cGH *GH, const int *stencil, int gi) return (retval); } + + void CCTK_FCALL CCTK_FNAME (BndNoiseGI) (int *ierr, const cGH *GH, const int *stencil, const int *gi) @@ -240,8 +281,8 @@ static int ApplyBndNoise (const cGH *GH, } -void -add_bc_noise_to_group (int idx, const char* optstring, void* cctkGH) +static void +add_bc_noise_to_var (int idx, const char* optstring, void* cctkGH) { int i, j, k, ijk; CCTK_REAL* data; @@ -252,7 +293,7 @@ add_bc_noise_to_group (int idx, const char* optstring, void* cctkGH) sw[1] = 1; sw[2] = 1; - BndNoiseGI(GH, sw, idx); + BndNoiseVI(GH, sw, idx); } @@ -260,11 +301,11 @@ void bc_noise(CCTK_ARGUMENTS) { DECLARE_CCTK_ARGUMENTS - DECLARE_CCTK_PARAMETERS + DECLARE_CCTK_PARAMETERS - if (CCTK_TraverseString(bc_vars, add_bc_noise_to_group, cctkGH, - CCTK_GROUP_OR_VAR) < 0) - { - CCTK_WARN (1, "Failed to parse 'Noise::bc_vars' parameter"); - } + if (CCTK_TraverseString(bc_vars, add_bc_noise_to_var, cctkGH, + CCTK_GROUP_OR_VAR) < 0) + { + CCTK_WARN (1, "Failed to parse 'Noise::bc_vars' parameter"); + } } diff --git a/src/noise.h b/src/noise.h index d2488b1..7cb839a 100644 --- a/src/noise.h +++ b/src/noise.h @@ -29,7 +29,6 @@ { \ if (doBC) \ { \ - srandom(time(0)); \ for (k = 0; k < kend; k++) \ { \ for (j = 0; j < jend; j++) \ -- cgit v1.2.3