diff options
author | allen <allen@f80f6fb6-8356-4fd4-90bc-d84ad503c100> | 1999-07-29 20:29:17 +0000 |
---|---|---|
committer | allen <allen@f80f6fb6-8356-4fd4-90bc-d84ad503c100> | 1999-07-29 20:29:17 +0000 |
commit | 2e79efbd010b598ed77b27f4adb5a0d7162d6c78 (patch) | |
tree | 716984eef7f8c9a4bb1b76bd056299354d5986fb /src | |
parent | 41bb7119fae5797ed8422cee41c46f7d932145c4 (diff) |
This commit was generated by cvs2svn to compensate for changes in r2, which
included commits to RCS files with non-trunk default branches.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusWave/WaveToyF90/trunk@3 f80f6fb6-8356-4fd4-90bc-d84ad503c100
Diffstat (limited to 'src')
-rw-r--r-- | src/CheckParameters.F | 51 | ||||
-rw-r--r-- | src/InitSymBound.F | 41 | ||||
-rw-r--r-- | src/InitialData.F | 96 | ||||
-rw-r--r-- | src/Startup.c | 10 | ||||
-rw-r--r-- | src/WaveToy.F | 137 | ||||
-rw-r--r-- | src/make.code.defn | 9 |
6 files changed, 344 insertions, 0 deletions
diff --git a/src/CheckParameters.F b/src/CheckParameters.F new file mode 100644 index 0000000..e02897e --- /dev/null +++ b/src/CheckParameters.F @@ -0,0 +1,51 @@ + /*@@ + @file CheckParameters.F + @date + @author Gabrielle Allen + @desc + Check parameters for the wave equation evolver + @enddesc + @@*/ + +#include "cctk.h" +#include "cctk_parameters.h" +#include "cctk_arguments.h" + + + /*@@ + @routine WaveToy_CheckParameters + @date + @author Gabrielle Allen + @desc + Check parameters for the wave equation evolver + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ + + subroutine WaveToyF90_CheckParameters(CCTK_FARGUMENTS) + + implicit none + + DECLARE_CCTK_FARGUMENTS + DECLARE_CCTK_PARAMETERS + + INTEGER CCTK_Equals + + if (CCTK_Equals(initial_data,"box")==1) then + + if (CCTK_Equals(type, "box")==0) then + call CCTK_PARAMWARN("Must have a box grid with box initial data") + end if + + if (kx==0 .or. ky==0 .or. kz==0) then + call CCTK_PARAMWARN("Cannot have zero kx,ky,kz for box initial data") + end if + + end if + + end subroutine WaveToyF90_CheckParameters diff --git a/src/InitSymBound.F b/src/InitSymBound.F new file mode 100644 index 0000000..8f1dd64 --- /dev/null +++ b/src/InitSymBound.F @@ -0,0 +1,41 @@ + /*@@ + @file InitSymBound.F + @date + @author Gabrielle Allen + @desc + Sets the symmetries for Wave Toy + @enddesc + @@*/ + +#include "cctk.h" +#include "cctk_arguments.h" + + /*@@ + @routine WaveToyF90_InitSymBound + @date + @author Gabrielle Allen + @desc + Sets the symmetries for Wave Toy + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ + + subroutine WaveToyF90_InitSymBound(CCTK_FARGUMENTS) + + implicit none + + DECLARE_CCTK_FARGUMENTS + + INTEGER, DIMENSION(3) :: sym = 1 + + call SetCartSymmetry(cctkGH, sym, 'wavetoy::phi') + + return + + end subroutine WaveToyF90_InitSymbound + diff --git a/src/InitialData.F b/src/InitialData.F new file mode 100644 index 0000000..1f12a5f --- /dev/null +++ b/src/InitialData.F @@ -0,0 +1,96 @@ + /*@@ + @file InitialData.F + @date + @author Tom Goodale + @desc + Initial data for the 3D Wave Equation + @enddesc + @@*/ + +#include "cctk.h" +#include "cctk_parameters.h" +#include "cctk_arguments.h" + + + + /*@@ + @routine WaveToyF90_InitialData + @date + @author Tom Goodale + @desc + Set up initial data for the wave equation + @enddesc + @calls + @calledby + @history + + @endhistory + +@@*/ + + subroutine WaveToyF90_InitialData(CCTK_FARGUMENTS) + + implicit none + + DECLARE_CCTK_FARGUMENTS + DECLARE_CCTK_PARAMETERS + + INTEGER CCTK_Equals + + INTEGER :: i + CCTK_REAL :: dt,omega, pi + CCTK_REAL :: min_delta,dx,dy,dz + + pi = 4.0*atan(1.0) + +c Grid spacing shortcuts +c ---------------------- + dx = cctk_delta_space(1) + dy = cctk_delta_space(2) + dz = cctk_delta_space(3) + +c Calculate timestep +c ------------------ + min_delta = min(dx,dy,dz) + cctk_delta_time = dtfac*min_delta + dt = cctk_delta_time + omega = sqrt(kx**2+ky**2+kz**2) + + if (CCTK_Equals(initial_data,"plane")==1) then + + phi = amplitude*cos(kx*x+ky*y+kz*z+omega*cctk_time) + phi_old = amplitude*cos(kx*x+ky*y+kz*z+omega*(cctk_time-dt)) + + else if (CCTK_Equals(initial_data,"gaussian")==1) then + + call CCTK_INFO("Gaussian initial data for Wave Equation"); + phi = amplitude*exp( -(sqrt(x**2+y**2+z**2)-radius)**2/sigma**2) + phi_old = amplitude*exp( -(sqrt(x**2+y**2+z**2)-radius-dt)**2/sigma**2) + + else if (CCTK_Equals(initial_data, "box")==1) then + +c Use kx,ky,kz as number of modes in each direction. + + phi = amplitude*sin(kx*(x-0.5)*pi)* + $ sin(ky*(y-0.5)*pi)* + $ sin(kz*(z-0.5)*pi)* + $ cos(omega*cctk_time*pi) + + phi_old = amplitude*sin(kx*(x-0.5)*pi)* + $ sin(ky*(y-0.5)*pi)* + $ sin(kz*(z-0.5)*pi)* + $ cos(omega*(cctk_time-dt)*pi) + + end if + +c Apply symmetry boundary conditions +c ---------------------------------- + call ApplySymmetry(cctkGH,"wavetoy::scalarevolve") + +c Synchronise +c ----------- + call CCTK_SyncGroup(cctkGH,"wavetoy::scalarevolve") + + end subroutine WaveToyF90_InitialData + + diff --git a/src/Startup.c b/src/Startup.c new file mode 100644 index 0000000..3b868b1 --- /dev/null +++ b/src/Startup.c @@ -0,0 +1,10 @@ + +int WaveToyF90_Startup(void) +{ + + const char *banner = +"WaveToyF90: Evolutions of a Scalar Field\nWritten by: Tom Goodale"; + + CCTK_RegisterBanner(banner); + +} diff --git a/src/WaveToy.F b/src/WaveToy.F new file mode 100644 index 0000000..f800edf --- /dev/null +++ b/src/WaveToy.F @@ -0,0 +1,137 @@ + /*@@ + @file WaveToyF90.F + @date + @author Tom Goodale + @desc + Evolution routines for the wave equation solver + @enddesc + @@*/ + +#include "cctk.h" +#include "cctk_parameters.h" +#include "cctk_arguments.h" + + + /*@@ + @routine WaveToyF90_Boundaries + @date + @author Tom Goodale + @desc + Boundary conditions for the wave equation + @enddesc + @calls ApplyFlatBC,ApplyRadiativeBC + @calledby + @history + + @endhistory + +@@*/ + + subroutine WaveToyF90_Boundaries(CCTK_FARGUMENTS) + + implicit none + + DECLARE_CCTK_FARGUMENTS + DECLARE_CCTK_PARAMETERS + + INTEGER,DIMENSION(3):: sw=1 + CCTK_REAL,PARAMETER :: zero = 0.0 + INTEGER CCTK_Equals + + call ApplySymmetry(cctkGH,"wavetoy::scalarevolve") + + if (CCTK_Equals(bound,"flat")==1) then + call ApplyFlatBC(cctkGH,sw,"wavetoy::phi") + else if (CCTK_Equals(bound,"radiation")==1) then + call ApplyRadiativeBC(cctkGH,zero,sw,"wavetoy::phi","wavetoyf90::phi_old") + end if + + end subroutine wavetoyf90_boundaries + +c -------------------------------------------------------------- + + /*@@ + @routine WaveToyF90_Evolution + @date + @author Tom Goodale + @desc + Evolution for the wave equation + @enddesc + @calls CCTK_SyncGroup, wavetoy_boundaries + @calledby + @history + + @endhistory + +@@*/ + + subroutine wavetoyf90_evolution(CCTK_FARGUMENTS) + + implicit none + + DECLARE_CCTK_FARGUMENTS + DECLARE_CCTK_PARAMETERS + +c Declare local variables + INTEGER :: i,j,k + INTEGER :: istart, jstart, kstart, iend, jend, kend + CCTK_REAL :: dx,dy,dz,dt + +c Set up shorthands +c ----------------- + dx = cctk_delta_space(1) + dy = cctk_delta_space(2) + dz = cctk_delta_space(3) + dt = cctk_delta_time + + istart = 2 + jstart = 2 + kstart = 2 + + iend = cctk_lsh(1)-1 + jend = cctk_lsh(2)-1 + kend = cctk_lsh(3)-1 + +c Do the evolution +c ---------------- + do k = kstart, kend + do j = jstart, jend + do i = istart, iend + + phi_tmp(i,j,k) = + 1 2.0*(1.0 - (dt**2)*(1.0/dx**2 + + 2 1.0/dy**2 +1.0/dz**2))*phi(i,j,k) - + 3 phi_old(i,j,k) + (dt**2) * + 5 ((phi(i+1,j,k)+phi(i-1,j,k))/dx**2 + 6 +(phi(i,j+1,k)+phi(i,j-1,k))/dy**2 + 7 +(phi(i,j,k+1)+phi(i,j,k-1))/dz**2) + + end do + end do + end do + +c Update timeslices +c ----------------- + phi_old = phi + phi = phi_tmp + +c Apply boundary conditions +c ------------------------- + call wavetoyf90_boundaries(CCTK_FARGUMENTS) + +c Synchronize +c ----------- + call CCTK_SyncGroup(cctkGH,"wavetoy::scalarevolve") + + end subroutine wavetoyf90_evolution + + +c -------------------------------------------------------------- + + + + + + + + diff --git a/src/make.code.defn b/src/make.code.defn new file mode 100644 index 0000000..6797754 --- /dev/null +++ b/src/make.code.defn @@ -0,0 +1,9 @@ +# Main make.code.defn file for thorn WaveToy +# $Header$ + +# Source files in this directory +SRCS = InitialData.F InitSymBound.F CheckParameters.F WaveToy.F Startup.c + +# Subdirectories containing source files +SUBDIRS = + |