aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgoodale <goodale@50555cc7-fb31-491a-85db-9a2874240742>1999-10-11 11:15:26 +0000
committergoodale <goodale@50555cc7-fb31-491a-85db-9a2874240742>1999-10-11 11:15:26 +0000
commit381802dcf45ca575c0a2465fa87dd316461132b8 (patch)
tree11dad1b6c2724c7882bd3a1cc649f0f7aeab456b /src
parent02617407d19e1d0a3f6fb3a9f63f0e0f28f0768e (diff)
Brought into sync with the other wavetoys and added a test suite.
Tom git-svn-id: http://svn.cactuscode.org/arrangements/CactusWave/WaveToyCXX/trunk@3 50555cc7-fb31-491a-85db-9a2874240742
Diffstat (limited to 'src')
-rw-r--r--src/WaveToy.cc183
1 files changed, 94 insertions, 89 deletions
diff --git a/src/WaveToy.cc b/src/WaveToy.cc
index b9621e7..45d4eac 100644
--- a/src/WaveToy.cc
+++ b/src/WaveToy.cc
@@ -20,54 +20,11 @@
#include "CactusBase/Boundary/src/Boundary.h"
#include "CactusBase/CartGrid3D/src/Symmetry.h"
-
- /*@@
- @routine WaveToyC_Boundaries
- @date
- @author Tom Goodale
- @desc
- Boundary conditions for the wave equation
- @enddesc
- @calls ApplySymmetry,ApplyFlatBC,ApplyRadiativeBC
- @calledby
- @history
-
- @endhistory
-
-@@*/
-
-static void WaveToyC_Boundaries(CCTK_CARGUMENTS)
-{
- DECLARE_CCTK_CARGUMENTS
- DECLARE_CCTK_PARAMETERS
-
-int ierr;
-int sw[3];
-
- /* Set the stencil width */
- sw[0]=1;
- sw[1]=1;
- sw[2]=1;
-
- ApplySymmetry(cctkGH,"wavetoycxx::scalartmps");
-
- if (CCTK_EQUALS(bound,"flat"))
- {
- ierr = ApplyFlatBC(cctkGH,sw,"wavetoycxx::phi_new");
- }
- else if (CCTK_Equals(bound,"radiation"))
- {
- ierr = ApplyRadiativeBC(cctkGH,0,1,sw,"wavetoycxx::phi_new","wavetoy::phi");
- }
-
- if (ierr < 0)
- {
- CCTK_WARN(0,"Boundary conditions not applied - giving up!");
- }
-}
+static char *rcsid = "$Header$";
#define val(gridfunc,i,j,k) gridfunc[CCTK_GFINDEX3D(cctkGH,i,j,k)]
+static void WaveToyC_Boundaries(CCTK_CARGUMENTS);
/*@@
@routine WaveToyC_Evolution
@@ -87,69 +44,117 @@ int sw[3];
extern "C" void WaveToyCXX_Evolution(CCTK_CARGUMENTS)
{
- DECLARE_CCTK_CARGUMENTS
+ DECLARE_CCTK_CARGUMENTS
- // Set up shorthands
+ // Set up shorthands
-CCTK_REAL
- dx = CCTK_DELTA_SPACE(0),
- dy = CCTK_DELTA_SPACE(1),
- dz = CCTK_DELTA_SPACE(2),
- dt = CCTK_DELTA_TIME,
+ CCTK_REAL dx = CCTK_DELTA_SPACE(0),
+ dy = CCTK_DELTA_SPACE(1),
+ dz = CCTK_DELTA_SPACE(2),
+ dt = CCTK_DELTA_TIME,
- dx2=dx*dx,
- dy2=dy*dy,
- dz2=dz*dz,
- dt2=dt*dt,
-
- factor = 2*(1 - (dt2)*(1/dx2 + 1/dy2 + 1/dz2));
-
-int iend = cctk_lsh[0]-1,
- jend = cctk_lsh[1]-1,
- kend = cctk_lsh[2]-1;
-
- //
- // Do the evolution
- //
-
- for (int k=1; k<kend; k++)
- for (int j=1; j<jend; j++)
- for (int i=1; i<iend; i++)
- {
- val(phi_new, i,j,k) =
+ dx2=dx*dx,
+ dy2=dy*dy,
+ dz2=dz*dz,
+ dt2=dt*dt,
+
+ factor = 2*(1 - (dt2)*(1/dx2 + 1/dy2 + 1/dz2));
+
+ int iend = cctk_lsh[0]-1,
+ jend = cctk_lsh[1]-1,
+ kend = cctk_lsh[2]-1;
+
+ //
+ // Do the evolution
+ //
+
+ for (int k=1; k<kend; k++)
+ for (int j=1; j<jend; j++)
+ for (int i=1; i<iend; i++)
+ {
+ val(phi_new, i,j,k) =
factor* val( phi,i,j,k ) - val( phi_old,i,j,k)
+ dt2 *
( ( val( phi, i+1,j ,k ) + val( phi, i-1,j ,k) )/dx2
+( val( phi, i ,j+1,k ) + val( phi, i ,j-1,k) )/dy2
+( val( phi, i ,j ,k+1) + val( phi, i ,j, k-1) )/dz2
);
- }
+ }
- //
- // Synchronize before applying boundary conditions
- //
- CCTK_SyncGroup(cctkGH,"wavetoycxx::scalartmps");
+ //
+ // Synchronize before applying boundary conditions
+ //
+ CCTK_SyncGroup(cctkGH,"wavetoycxx::scalartmps");
- //
- // Apply boundary conditions
- //
- WaveToyC_Boundaries(CCTK_PASS_CTOC);
+ //
+ // Apply boundary conditions
+ //
+ WaveToyC_Boundaries(CCTK_PASS_CTOC);
- //
- // Update timeslices
- //
- { for (int k=0; k<cctk_lsh[2]; k++)
- for (int j=0; j<cctk_lsh[1]; j++)
+ //
+ // Update timeslices
+ //
+ {
+ 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_old[index] = phi[index];
- phi[index] = phi_new[index];
+ int index = CCTK_GFINDEX3D(cctkGH,i,j,k);
+ phi_old[index] = phi[index];
+ phi[index] = phi_new[index];
}
}
}
+ /*@@
+ @routine WaveToyC_Boundaries
+ @date
+ @author Tom Goodale
+ @desc
+ Boundary conditions for the wave equation
+ @enddesc
+ @calls ApplySymmetry,ApplyFlatBC,ApplyRadiativeBC
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+
+static void WaveToyC_Boundaries(CCTK_CARGUMENTS)
+{
+ DECLARE_CCTK_CARGUMENTS
+ DECLARE_CCTK_PARAMETERS
+
+ int ierr;
+ int sw[3];
+
+ /* Set the stencil width */
+ sw[0]=1;
+ sw[1]=1;
+ sw[2]=1;
+
+ ierr = CartSymBCGroup(cctkGH,"wavetoycxx::scalartmps");
+
+ if (CCTK_Equals(bound,"flat"))
+ {
+ ierr = ApplyFlatBC(cctkGH,sw,"wavetoycxx::phi_new");
+ }
+ else if (CCTK_Equals(bound,"radiation"))
+ {
+ ierr = ApplyRadiativeBC(cctkGH,0,1,sw,"wavetoycxx::phi_new","wavetoy::phi");
+ }
+
+ if (ierr < 0)
+ {
+ CCTK_WARN(0,"Boundary conditions not applied - giving up!");
+ }
+}
+
+
+
+