diff options
author | eschnett <> | 2001-03-01 11:40:00 +0000 |
---|---|---|
committer | eschnett <> | 2001-03-01 11:40:00 +0000 |
commit | 310f0ea48d18866b773136aed11200b6eda6378b (patch) | |
tree | 445d3e34ce8b89812994b6614f7bc9f4acbc7fe2 /CarpetExtra/CarpetRegridTest/src |
Initial revision
darcs-hash:20010301114010-f6438-12fb8a9ffcc80e86c0a97e37b5b0dae0dbc59b79.gz
Diffstat (limited to 'CarpetExtra/CarpetRegridTest/src')
-rw-r--r-- | CarpetExtra/CarpetRegridTest/src/InitialData.c | 162 | ||||
-rw-r--r-- | CarpetExtra/CarpetRegridTest/src/SetupGaussian.c | 48 | ||||
-rw-r--r-- | CarpetExtra/CarpetRegridTest/src/Startup.c | 16 | ||||
-rw-r--r-- | CarpetExtra/CarpetRegridTest/src/TestGaussian.c | 45 | ||||
-rw-r--r-- | CarpetExtra/CarpetRegridTest/src/make.code.defn | 8 |
5 files changed, 279 insertions, 0 deletions
diff --git a/CarpetExtra/CarpetRegridTest/src/InitialData.c b/CarpetExtra/CarpetRegridTest/src/InitialData.c new file mode 100644 index 000000000..0dbf3ac11 --- /dev/null +++ b/CarpetExtra/CarpetRegridTest/src/InitialData.c @@ -0,0 +1,162 @@ + /*@@ + @file InitialData.c + @date + @author Werner Benger + @desc + Initial data for the 3D Wave Equation + Derived from Tom Goodale + @enddesc + @version $Header: /home/eschnett/C/carpet/Carpet/CarpetExtra/CarpetRegridTest/src/InitialData.c,v 1.1 2004/05/23 15:56:14 cott Exp $ + @@*/ + +#include <math.h> + +#include "cctk.h" +#include "cctk_Parameters.h" +#include "cctk_Arguments.h" + +static const char *rcsid = "$Header: /home/eschnett/C/carpet/Carpet/CarpetExtra/CarpetRegridTest/src/InitialData.c,v 1.1 2004/05/23 15:56:14 cott Exp $"; + +CCTK_FILEVERSION(CactusWave_IDScalarWaveC_InitialData_c) + +static CCTK_REAL sqr(CCTK_REAL val) +{ + return val*val; +} + +void IDScalarWaveC_InitialData(CCTK_ARGUMENTS); + + + /*@@ + @routine IDScalarWaveC_InitialData + @date + @author Tom Goodale + @desc + Set up initial data for the wave equation + @enddesc + @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. + @hdate Thu Feb 17 09:22:01 2000 @hauthor Tom Goodale + @hdesc Converted to C + @endhistory + +@@*/ + +void IDScalarWaveC_InitialData(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS + DECLARE_CCTK_PARAMETERS + + int i,j,k; + + CCTK_REAL dt; + CCTK_REAL omega; + int index; + CCTK_REAL X, Y, Z, R; + CCTK_REAL pi; + + dt = CCTK_DELTA_TIME; + + if(CCTK_Equals(initial_data, "plane")) + { + omega = sqrt(sqr(kx)+sqr(ky)+sqr(kz)); + + for(k=0; k<cctk_lsh[2]; k++) + { + for(j=0; j<cctk_lsh[1]; j++) + { + for(i=0; i<cctk_lsh[0]; i++) + { + index = CCTK_GFINDEX3D(cctkGH,i,j,k); + + phi[index] = amplitude*cos(kx*x[index]+ky*y[index]+kz*z[index]+omega*cctk_time); + phi_p[index] = amplitude*cos(kx*x[index]+ky*y[index]+kz*z[index]+omega*(cctk_time-dt)); + } + } + } + } + else if(CCTK_Equals(initial_data, "gaussian")) + { + for(k=0; k<cctk_lsh[2]; k++) + { + for(j=0; j<cctk_lsh[1]; j++) + { + for(i=0; i<cctk_lsh[0]; i++) + { + index = CCTK_GFINDEX3D(cctkGH,i,j,k); + + X = x[index]; + Y = y[index]; + Z = z[index]; + + R = sqrt(X*X + Y*Y + Z*Z); + + phi[index] = amplitude*exp( - sqr( (R - radius) / sigma ) ); + + if (R == 0.0) + { + phi_p[index] = amplitude*(1.0 - 2.0*dt*dt/sigma)*exp(-dt*dt/sigma); + } + else + { + phi_p[index] = amplitude/2.0*(R-dt)/R* + exp( - sqr( (R - radius - dt)/ sigma ) ) + + amplitude/2.0*(R+dt)/R* + exp( - sqr( (R - radius + dt)/ sigma ) ); + } + } + } + } + } + else if(CCTK_Equals(initial_data, "box")) + { + pi = 4.0*atan(1.0); + omega = sqrt(sqr(kx)+sqr(ky)+sqr(kz)); + + for(k=0; k<cctk_lsh[2]; k++) + { + for(j=0; j<cctk_lsh[1]; j++) + { + for(i=0; i<cctk_lsh[0]; i++) + { + index = CCTK_GFINDEX3D(cctkGH,i,j,k); + + 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); + + phi_p[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); + } + } + } + } + else if (CCTK_Equals(initial_data, "none")) + { + for(k=0; k<cctk_lsh[2]; k++) + { + for(j=0; j<cctk_lsh[1]; j++) + { + for(i=0; i<cctk_lsh[0]; i++) + { + index = CCTK_GFINDEX3D(cctkGH,i,j,k); + + phi[index] = 0.0; + + phi_p[index] = 0.0; + } + } + } + } + + return; +} + diff --git a/CarpetExtra/CarpetRegridTest/src/SetupGaussian.c b/CarpetExtra/CarpetRegridTest/src/SetupGaussian.c new file mode 100644 index 000000000..768656f10 --- /dev/null +++ b/CarpetExtra/CarpetRegridTest/src/SetupGaussian.c @@ -0,0 +1,48 @@ +#include <math.h> + +#include "cctk.h" +#include "cctk_Parameters.h" +#include "cctk_Arguments.h" + + +static const char *rcsid = "$Header: /home/eschnett/C/carpet/Carpet/CarpetExtra/CarpetRegridTest/src/SetupGaussian.c,v 1.2 2004/05/27 13:22:49 schnetter Exp $"; + +CCTK_FILEVERSION(CarpetExtra_CarpetRegridTest_SetupGaussian_c); + +void CarpetRegrid_SetupGaussian(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_PARAMETERS; + DECLARE_CCTK_ARGUMENTS; + + int i,j,k; + + CCTK_REAL omega; + int index; + CCTK_REAL X, Y, Z, R; + CCTK_REAL pi; + + for(k=0; k<cctk_lsh[2]; k++) + { + for(j=0; j<cctk_lsh[1]; j++) + { + for(i=0; i<cctk_lsh[0]; i++) + { + index = CCTK_GFINDEX3D(cctkGH,i,j,k); + + X = x[index]; + Y = y[index]; + Z = z[index]; + + R = sqrt(X*X + Y*Y + Z*Z); + + phi[index] = amplitude*exp( - pow( (R - radius) / sigma, 2.0 ) ); + + phi_p[index] = phi[index]; + phi_p_p[index] = phi[index]; + } + } + } + + CCTK_VInfo(CCTK_THORNSTRING,"Gaussian initial data have been set."); + +} diff --git a/CarpetExtra/CarpetRegridTest/src/Startup.c b/CarpetExtra/CarpetRegridTest/src/Startup.c new file mode 100644 index 000000000..6aa4bfb39 --- /dev/null +++ b/CarpetExtra/CarpetRegridTest/src/Startup.c @@ -0,0 +1,16 @@ +#include "cctk.h" +#include "cctk_Parameters.h" +#include "cctk_Arguments.h" + + +static const char *rcsid = "$Header: /home/eschnett/C/carpet/Carpet/CarpetExtra/CarpetRegridTest/src/Startup.c,v 1.1 2004/05/23 15:56:14 cott Exp $"; + +CCTK_FILEVERSION(CarpetExtra_CarpetRegridTest_Startup_c); + +void CarpetRegridTest_Startup(void) +{ + const char *banner = "CarpetRegridTest: Thoroughly testing PMR"; + + CCTK_RegisterBanner(banner); + +} diff --git a/CarpetExtra/CarpetRegridTest/src/TestGaussian.c b/CarpetExtra/CarpetRegridTest/src/TestGaussian.c new file mode 100644 index 000000000..be786c245 --- /dev/null +++ b/CarpetExtra/CarpetRegridTest/src/TestGaussian.c @@ -0,0 +1,45 @@ +#include <math.h> + +#include "cctk.h" +#include "cctk_Parameters.h" +#include "cctk_Arguments.h" + + +static const char *rcsid = "$Header: /home/eschnett/C/carpet/Carpet/CarpetExtra/CarpetRegridTest/src/TestGaussian.c,v 1.3 2004/05/27 13:22:49 schnetter Exp $"; + +CCTK_FILEVERSION(CarpetExtra_CarpetRegridTest_TestGaussian_c); + +void CarpetRegrid_TestGaussian(CCTK_ARGUMENTS) +{ + DECLARE_CCTK_PARAMETERS; + DECLARE_CCTK_ARGUMENTS; + + int i,j,k; + + int index; + CCTK_REAL X, Y, Z, R; + + + for(k=0; k<cctk_lsh[2]; k++) + { + for(j=0; j<cctk_lsh[1]; j++) + { + for(i=0; i<cctk_lsh[0]; i++) + { + index = CCTK_GFINDEX3D(cctkGH,i,j,k); + + X = x[index]; + Y = y[index]; + Z = z[index]; + + R = sqrt(X*X + Y*Y + Z*Z); + + phi_error[index] = phi[index] - amplitude*exp( - pow( (R - radius) / sigma, 2.0 ) ); + phi_relerror[index] = phi_error[index] / (amplitude*exp( - pow( (R - radius) / sigma, 2.0 ) ) ); + } + } + } + + // CCTK_VInfo(CCTK_THORNSTRING,"Performed CarpetRegridTest"); + +} diff --git a/CarpetExtra/CarpetRegridTest/src/make.code.defn b/CarpetExtra/CarpetRegridTest/src/make.code.defn new file mode 100644 index 000000000..5428339e9 --- /dev/null +++ b/CarpetExtra/CarpetRegridTest/src/make.code.defn @@ -0,0 +1,8 @@ +# Main make.code.defn file for thorn CarpetRegridTest +# $Header: /home/eschnett/C/carpet/Carpet/CarpetExtra/CarpetRegridTest/src/make.code.defn,v 1.1 2004/05/23 15:56:14 cott Exp $ + +# Source files in this directory +SRCS = Startup.c SetupGaussian.c TestGaussian.c + +# Subdirectories containing source files +SUBDIRS = |