diff options
Diffstat (limited to 'src/WaveToy.cc')
-rw-r--r-- | src/WaveToy.cc | 90 |
1 files changed, 36 insertions, 54 deletions
diff --git a/src/WaveToy.cc b/src/WaveToy.cc index 4dd002e..bf8f756 100644 --- a/src/WaveToy.cc +++ b/src/WaveToy.cc @@ -1,14 +1,14 @@ /*@@ - @file WaveToy.cc - @date - @author Tom Goodale - @desc - Evolution routines for the wave equation solver - @enddesc - @version $Header$ + @file WaveToy.cc + @date + @author Tom Goodale + @desc + Evolution routines for the wave equation solver + @enddesc + @version $Id$ @@*/ - -#include "cctk.h" + +#include "cctk.h" #include "cctk_Parameters.h" #include "cctk_Arguments.h" @@ -20,31 +20,24 @@ CCTK_FILEVERSION (CactusWave_WaveToyCXX_WaveToy_cc); /*@@ @routine WaveToyC_Evolution - @date + @date @author Tom Goodale - @desc + @desc Evolution for the wave equation - @enddesc - @calls CCTK_SyncGroup, WaveToyC_Boundaries - @calledby - @history - - @endhistory - + @enddesc @@*/ extern "C" void WaveToyCXX_Evolution(CCTK_ARGUMENTS) { - DECLARE_CCTK_ARGUMENTS - // Set up shorthands + // Set up shorthands CCTK_REAL dx = CCTK_DELTA_SPACE(0); CCTK_REAL dy = CCTK_DELTA_SPACE(1); CCTK_REAL dz = CCTK_DELTA_SPACE(2); CCTK_REAL dt = CCTK_DELTA_TIME; - + CCTK_REAL dx2 = dx*dx; CCTK_REAL dy2 = dy*dy; CCTK_REAL dz2 = dz*dz; @@ -62,11 +55,11 @@ extern "C" void WaveToyCXX_Evolution(CCTK_ARGUMENTS) int iend = cctk_lsh[0]-1; int jend = cctk_lsh[1]-1; - int kend = cctk_lsh[2]-1; + int kend = cctk_lsh[2]-1; // - // Do the evolution - // + // Do the evolution + // for (int k=kstart; k<kend; k++) { @@ -74,35 +67,27 @@ extern "C" void WaveToyCXX_Evolution(CCTK_ARGUMENTS) { for (int i=istart; i<iend; i++) { - int index = CCTK_GFINDEX3D(cctkGH,i,j,k); + int vindex = CCTK_GFINDEX3D(cctkGH,i,j,k); - phi[index] = - factor*phi_p[index] - phi_p_p[index] - + dt2 * + phi[vindex] = + factor*phi_p[vindex] - phi_p_p[vindex] + + dt2 * ( ( val( phi_p, i+1,j ,k ) + val( phi_p, i-1,j ,k) )*dx2i +( val( phi_p, i ,j+1,k ) + val( phi_p, i ,j-1,k) )*dy2i +( val( phi_p, i ,j ,k+1) + val( phi_p, i ,j, k-1) )*dz2i ); - } + } } } - - return; } /*@@ @routine WaveToyC_Boundaries - @date + @date @author Tom Goodale - @desc + @desc Boundary conditions for the wave equation - @enddesc - @calls - @calledby - @history - - @endhistory - + @enddesc @@*/ extern "C" void WaveToyCXX_Boundaries(CCTK_ARGUMENTS) @@ -110,28 +95,25 @@ extern "C" void WaveToyCXX_Boundaries(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; - int ierr = 0; + const char *bctype; + - if (CCTK_EQUALS(bound,"flat") || CCTK_EQUALS(bound,"static") || - CCTK_EQUALS(bound,"radiation") || CCTK_EQUALS(bound,"robin") || + bctype = NULL; + if (CCTK_EQUALS(bound,"flat") || CCTK_EQUALS(bound,"static") || + CCTK_EQUALS(bound,"radiation") || CCTK_EQUALS(bound,"robin") || CCTK_EQUALS(bound,"none")) { - // Uses all default arguments, so invalid table handle -1 can be passed - ierr = Boundary_SelectVarForBC(cctkGH, CCTK_ALL_FACES, 1, -1, - "wavetoy::phi", bound); + bctype = bound; } else if (CCTK_EQUALS(bound,"zero")) { - // Uses all default arguments, so invalid table handle -1 can be passed - ierr = Boundary_SelectVarForBC - (cctkGH, CCTK_ALL_FACES, 1, -1, "wavetoy::phi", "scalar"); - + bctype = bound; } - if (ierr < 0) + // Uses all default arguments, so invalid table handle -1 can be passed + if (bctype && Boundary_SelectVarForBC (cctkGH, CCTK_ALL_FACES, 1, -1, + "wavetoy::phi", bctype) < 0) { - CCTK_WARN(0,"WaveToyCXX_Boundaries: Error selecting boundary condition"); + CCTK_WARN (0,"WaveToyCXX_Boundaries: Error selecting boundary condition"); } - - return; } |