diff options
author | goodale <goodale@7ec00dc9-1e7a-42ad-bf73-a299ee168e72> | 1999-10-11 10:30:21 +0000 |
---|---|---|
committer | goodale <goodale@7ec00dc9-1e7a-42ad-bf73-a299ee168e72> | 1999-10-11 10:30:21 +0000 |
commit | 71dc800db76cce021294def0e6c36997a0b76f85 (patch) | |
tree | 7f6e8e09cbab3bc397156aa828c30e19972bc139 | |
parent | b728565aaa12282846d658d7837b32511cd23cee (diff) |
Modified to have precisely the functionality of IDScalarWave
- now is another implementation of IDScalarWave.
Tom
git-svn-id: http://svn.cactuscode.org/arrangements/CactusWave/IDScalarWaveCXX/trunk@3 7ec00dc9-1e7a-42ad-bf73-a299ee168e72
-rw-r--r-- | interface.ccl | 2 | ||||
-rw-r--r-- | param.ccl | 22 | ||||
-rw-r--r-- | schedule.ccl | 7 | ||||
-rw-r--r-- | src/CheckParameters.cc | 51 | ||||
-rw-r--r-- | src/InitialData.cc | 104 | ||||
-rw-r--r-- | src/make.code.defn | 2 |
6 files changed, 157 insertions, 31 deletions
diff --git a/interface.ccl b/interface.ccl index 6f8e4d9..ee17e13 100644 --- a/interface.ccl +++ b/interface.ccl @@ -1,6 +1,6 @@ # Interface definition for thorn IDScalarWave # $Header$ -implements: idscalarwavecxx +implements: idscalarwave inherits: wavetoy grid @@ -7,6 +7,15 @@ USES KEYWORD type "" { } +restricted: + +KEYWORD initial_data "Type of initial data" +{ + "plane" :: "Plane wave" + "gaussian" :: "Gaussian wave" + "box" :: "Box wave" +} "gaussian" + private: REAL radius "The radius of the gaussian wave" @@ -19,6 +28,19 @@ REAL sigma "The sigma for the gaussian wave" 0:* :: } 0.1 +REAL kx "The wave number in the x-direction" +{ + *:* :: "No restriction" +} 4.0 +REAL ky "The wave number in the y-direction" +{ + *:* :: "No restriction" +} 0.0 +REAL kz "The wave number in the z-direction" +{ + *:* :: "No restriction" +} 0.0 + REAL amplitude "The amplitude of the waves" { *:* :: "No restriction" diff --git a/schedule.ccl b/schedule.ccl index 91ea515..052e424 100644 --- a/schedule.ccl +++ b/schedule.ccl @@ -1,9 +1,14 @@ # Schedule definitions for thorn IDScalarWave # $Header$ +schedule IDScalarWaveCXX_CheckParameters at CCTK_PARAMCHECK +{ + LANG: C +} "Check parameters" + schedule IDScalarWaveCXX_InitialData at CCTK_INITIAL { - STORAGE: wavetoy::scalarevolve,wavetoy::scalarold + STORAGE: wavetoy::scalarevolve COMMUNICATION: wavetoy::scalarevolve LANG: C } "Initial data for 3D wave equation" diff --git a/src/CheckParameters.cc b/src/CheckParameters.cc new file mode 100644 index 0000000..f0f6fdb --- /dev/null +++ b/src/CheckParameters.cc @@ -0,0 +1,51 @@ +/* + @file CheckParameters.F77 + @date + @author Gabrielle Allen + @desc + Check parameters for the wave equation initial data + @enddesc + @@*/ + +#include "cctk.h" +#include "cctk_parameters.h" +#include "cctk_arguments.h" + +static char *rcsid = "$Header$"; + + /*@@ + @routine IDScalarWave_CheckParameters + @date + @author Gabrielle Allen + @desc + Check parameters for the wave equation initial data + @enddesc + @calls + @calledby + @history + @hdate Mon Oct 11 11:49:21 1999 @hauthor Tom Goodale + @hdesc Converted to C++ + @endhistory + +@@*/ + +extern "C" void IDScalarWaveCXX_CheckParameters(CCTK_CARGUMENTS) +{ + DECLARE_CCTK_CARGUMENTS + DECLARE_CCTK_PARAMETERS + + if(CCTK_Equals(initial_data,"box")) + { + if (!CCTK_Equals(type, "box")) + { + CCTK_PARAMWARN("Must have a box grid with box initial data"); + } + + if (kx == 0 || ky == 0 || kz == 0) + { + CCTK_PARAMWARN("Cannot have zero kx,ky,kz for box initial data"); + } + } + return; +} + diff --git a/src/InitialData.cc b/src/InitialData.cc index c8d790d..8b770dc 100644 --- a/src/InitialData.cc +++ b/src/InitialData.cc @@ -8,23 +8,24 @@ @enddesc @@*/ +#include <math.h> + #include "cctk.h" #include "cctk_Flesh.h" #include "cctk_parameters.h" #include "cctk_Groups.h" #include "cctk_arguments.h" -#include "cctk_Comm.h" +#include "cctk_Misc.h" -#include "CactusBase/CartGrid3D/src/Symmetry.h" +static char *rcsid = "$Header$"; -#include <math.h> - -inline double sqr(double val) +inline CCTK_REAL sqr(CCTK_REAL val) { - return val*val; + return val*val; } + /*@@ @routine IDScalarWave_InitialData @date @@ -35,39 +36,86 @@ inline double sqr(double val) @calls @calledby @history - + @hdate Mon Oct 11 11:48:03 1999 @hauthor Werner Benger + @hdesc Converted to C++ + @hdate Mon Oct 11 11:48:20 1999 @hauthor Tom Goodale + @hdesc Added the rest of the initial data. @endhistory @@*/ extern "C" void IDScalarWaveCXX_InitialData(CCTK_CARGUMENTS) { - DECLARE_CCTK_CARGUMENTS - DECLARE_CCTK_PARAMETERS + DECLARE_CCTK_CARGUMENTS + DECLARE_CCTK_PARAMETERS + + CCTK_REAL dt = CCTK_DELTA_TIME; + + if(CCTK_Equals(initial_data, "plane")) + { + CCTK_REAL omega = sqrt(sqr(kx)+sqr(ky)+sqr(kz)); + + for(int k=0; k<cctk_lsh[2]; k++) + { + for(int j=0; j<cctk_lsh[1]; j++) + { + for(int i=0; i<cctk_lsh[0]; i++) + { + + int index = CCTK_GFINDEX3D(cctkGH,i,j,k); + + phi[index] = amplitude*cos(kx*x[index]+ky*y[index]+kz*z[index]+omega*cctk_time); + phi_old[index] = amplitude*cos(kx*x[index]+ky*y[index]+kz*z[index]+omega*(cctk_time-dt)); + } + } + } + } + else if(CCTK_Equals(initial_data, "gaussian")) + { + for(int k=0; k<cctk_lsh[2]; k++) + { + for(int j=0; j<cctk_lsh[1]; j++) + { + for(int i=0; i<cctk_lsh[0]; i++) + { + int index = CCTK_GFINDEX3D(cctkGH,i,j,k); - for(int k=0; k<cctk_lsh[2]; k++) - for(int j=0; j<cctk_lsh[1]; j++) - for(int i=0; i<cctk_lsh[0]; i++) - { - int index = CCTK_GFINDEX3D(cctkGH,i,j,k); + CCTK_REAL X = x[index], Y = y[index], Z = z[index]; + CCTK_REAL R = sqrt(X*X + Y*Y + Z*Z); - double X = x[index], Y = y[index], Z = z[index]; - double R = sqrt(X*X + Y*Y + Z*Z); + phi[index] = amplitude*exp( - sqr( (R - radius) / sigma ) ); + phi_old[index] = amplitude*exp( - sqr( (R - radius - dt) / sigma ) ); - phi_old[index] = phi[index] = - amplitude*exp( - sqr( (R - radius) / sigma ) ); - } + } + } + } + } + else if(CCTK_Equals(initial_data, "box")) + { + CCTK_REAL pi = 4.0*atan(1.0); + CCTK_REAL omega = sqrt(sqr(kx)+sqr(ky)+sqr(kz)); - // - // Apply symmetry boundary conditions - // - ApplySymmetry(cctkGH,"wavetoy::scalarevolve"); + for(int k=0; k<cctk_lsh[2]; k++) + { + for(int j=0; j<cctk_lsh[1]; j++) + { + for(int i=0; i<cctk_lsh[0]; i++) + { + int index = CCTK_GFINDEX3D(cctkGH,i,j,k); - // - // Synchronise - // - CCTK_SyncGroup(cctkGH,"wavetoy::scalarevolve"); + phi[index] = amplitude*sin(kx*(x[index]-0.5)*pi)* + sin(ky*(y[index]-0.5)*pi)* + sin(kz*(z[index]-0.5)*pi)* + cos(omega*cctk_time*pi); - return; + phi_old[index] = amplitude*sin(kx*(x[index]-0.5)*pi)* + sin(ky*(y[index]-0.5)*pi)* + sin(kz*(z[index]-0.5)*pi)* + cos(omega*(cctk_time-dt)*pi); + } + } + } + } + return; } diff --git a/src/make.code.defn b/src/make.code.defn index 4335306..b5e2b73 100644 --- a/src/make.code.defn +++ b/src/make.code.defn @@ -2,7 +2,7 @@ # $Header$ # Source files in this directory -SRCS = InitialData.cc +SRCS = InitialData.cc CheckParameters.cc # Subdirectories containing source files SUBDIRS = |