aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgoodale <goodale@071ba4cb-2270-47cd-a45a-3e542e115664>2000-02-17 09:08:48 +0000
committergoodale <goodale@071ba4cb-2270-47cd-a45a-3e542e115664>2000-02-17 09:08:48 +0000
commit0e3c104605c3cbad724ee0d8e70b67ba4d7feee0 (patch)
tree0439d3e6513a45b049a1d0e28eb6fae22f5b7dcc /src
parentdd684770ca7f1cd7fb2204e292addb35f9ef3349 (diff)
C version of IDScalarWave
git-svn-id: http://svn.cactuscode.org/arrangements/CactusWave/IDScalarWaveC/trunk@2 071ba4cb-2270-47cd-a45a-3e542e115664
Diffstat (limited to 'src')
-rw-r--r--src/CheckParameters.c56
-rw-r--r--src/InitialData.c134
-rw-r--r--src/make.code.defn9
3 files changed, 199 insertions, 0 deletions
diff --git a/src/CheckParameters.c b/src/CheckParameters.c
new file mode 100644
index 0000000..de6a523
--- /dev/null
+++ b/src/CheckParameters.c
@@ -0,0 +1,56 @@
+/*
+ @file CheckParameters.c
+ @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"
+#include "cctk_Groups.h"
+#include "cctk_Misc.h"
+#include "cctk_WarnLevel.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++
+ @hdate Thu Feb 17 09:20:41 2000 @hauthor Tom Goodale
+ @hdesc Converted to C
+ @endhistory
+
+@@*/
+
+void IDScalarWaveC_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.c b/src/InitialData.c
new file mode 100644
index 0000000..d6b22c4
--- /dev/null
+++ b/src/InitialData.c
@@ -0,0 +1,134 @@
+ /*@@
+ @file InitialData.c
+ @date
+ @author Werner Benger
+ @desc
+ Initial data for the 3D Wave Equation
+ Derived from Tom Goodale
+ @enddesc
+ @version $Header$
+ @@*/
+
+#include <math.h>
+
+#include "cctk.h"
+#include "cctk_Flesh.h"
+#include "cctk_Parameters.h"
+#include "cctk_Groups.h"
+#include "cctk_Arguments.h"
+#include "cctk_Misc.h"
+
+static char *rcsid = "$Header$";
+
+static CCTK_REAL sqr(CCTK_REAL val)
+{
+ return val*val;
+}
+
+
+
+ /*@@
+ @routine IDScalarWave_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_CARGUMENTS)
+{
+ DECLARE_CCTK_CARGUMENTS
+ 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_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(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 ) );
+ phi_old[index] = amplitude*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_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
new file mode 100644
index 0000000..f96f4ed
--- /dev/null
+++ b/src/make.code.defn
@@ -0,0 +1,9 @@
+# Main make.code.defn file for thorn IDScalarWave
+# $Header$
+
+# Source files in this directory
+SRCS = InitialData.c CheckParameters.c
+
+# Subdirectories containing source files
+SUBDIRS =
+