diff options
author | knarf <knarf@54511f98-0e4f-0410-826e-eb8b393f5a1e> | 2006-04-28 09:22:16 +0000 |
---|---|---|
committer | knarf <knarf@54511f98-0e4f-0410-826e-eb8b393f5a1e> | 2006-04-28 09:22:16 +0000 |
commit | d3d941dd0aa15adc25f5fab074fd69011be52f79 (patch) | |
tree | 8b8a042edcd668ccbbab4f106f8508d8d37b9364 | |
parent | cb80cd36253bae64ac0e41432e36ce14358b5892 (diff) |
only whitespace changes (tabs->spaces, lines should not have more than 80
characters)
git-svn-id: http://svn.aei.mpg.de/numrel/AEIThorns/ADMMass/trunk@13 54511f98-0e4f-0410-826e-eb8b393f5a1e
-rw-r--r-- | src/surface_integral.c | 268 | ||||
-rw-r--r-- | src/volume_integral.c | 223 |
2 files changed, 250 insertions, 241 deletions
diff --git a/src/surface_integral.c b/src/surface_integral.c index b8a3998..3f756fd 100644 --- a/src/surface_integral.c +++ b/src/surface_integral.c @@ -17,10 +17,11 @@ #include <cctk_Arguments.h> #include <cctk_Parameters.h> -#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068 +#define PI 3.1415926535897932384626433832795028841971693993751058209749445923 -CCTK_INT find_closest(const cGH *cctkGH, CCTK_INT *cctk_lsh, CCTK_REAL *cctk_delta_space, - CCTK_INT ghost, CCTK_REAL *coord, CCTK_REAL coord_min, CCTK_INT dir) +CCTK_INT find_closest(const cGH *cctkGH, CCTK_INT *cctk_lsh, + CCTK_REAL *cctk_delta_space, CCTK_INT ghost, + CCTK_REAL *coord, CCTK_REAL coord_min, CCTK_INT dir) { CCTK_INT i, ijk, min_i = -1; CCTK_REAL min = 1.e100; @@ -83,82 +84,95 @@ void ADMMass_Surface(CCTK_ARGUMENTS) z_max_k = INT_MAX; if (ADMMass_distance_from_grid_boundary[*ADMMass_LoopCounter] > 0.0) - { - if (strcmp(CCTK_ParameterValString("type", "cartgrid3d"), "coordbase")) - { - CCTK_WARN(0,"this thorns used with the ADMMass_distance_from_grid_boundar parameter requires to set coordinates through coordbase."); - } - - /* Find the physical coordinates of the boundaries */ - ierr = GetDomainSpecification - (3, physical_min, physical_max, interior_min, interior_max, - exterior_min, exterior_max, spacing); - if (ierr) - CCTK_VWarn ( 0, __LINE__, __FILE__, "CartGrid3D", "error returned from function GetDomainSpecification"); - *ADMMass_box_x_min = physical_min[0] + ADMMass_distance_from_grid_boundary[*ADMMass_LoopCounter]; - *ADMMass_box_x_max = physical_max[0] - ADMMass_distance_from_grid_boundary[*ADMMass_LoopCounter]; - *ADMMass_box_y_min = physical_min[1] + ADMMass_distance_from_grid_boundary[*ADMMass_LoopCounter]; - *ADMMass_box_y_max = physical_max[1] - ADMMass_distance_from_grid_boundary[*ADMMass_LoopCounter]; - *ADMMass_box_z_min = physical_min[2] + ADMMass_distance_from_grid_boundary[*ADMMass_LoopCounter]; - *ADMMass_box_z_max = physical_max[2] - ADMMass_distance_from_grid_boundary[*ADMMass_LoopCounter]; - } + { + if (strcmp(CCTK_ParameterValString("type", "cartgrid3d"), "coordbase")) + CCTK_WARN(0,"this thorns used with the ADMMass_distance_from_grid_boundar parameter requires to set coordinates through coordbase."); + + /* Find the physical coordinates of the boundaries */ + ierr = GetDomainSpecification( 3, physical_min, physical_max, + interior_min, interior_max, + exterior_min, exterior_max, spacing); + if (ierr) + CCTK_VWarn ( 0, __LINE__, __FILE__, "CartGrid3D", "error returned from function GetDomainSpecification"); + *ADMMass_box_x_min = + physical_min[0] + + ADMMass_distance_from_grid_boundary[*ADMMass_LoopCounter]; + *ADMMass_box_x_max = + physical_max[0] - + ADMMass_distance_from_grid_boundary[*ADMMass_LoopCounter]; + *ADMMass_box_y_min = + physical_min[1] + + ADMMass_distance_from_grid_boundary[*ADMMass_LoopCounter]; + *ADMMass_box_y_max = + physical_max[1] - + ADMMass_distance_from_grid_boundary[*ADMMass_LoopCounter]; + *ADMMass_box_z_min = + physical_min[2] + + ADMMass_distance_from_grid_boundary[*ADMMass_LoopCounter]; + *ADMMass_box_z_max = + physical_max[2] - + ADMMass_distance_from_grid_boundary[*ADMMass_LoopCounter]; + } else if (ADMMass_surface_distance[*ADMMass_LoopCounter] > 0.0) - { + { *ADMMass_box_x_min = ADMMass_x_pos[*ADMMass_LoopCounter] - - ADMMass_surface_distance[*ADMMass_LoopCounter]; + ADMMass_surface_distance[*ADMMass_LoopCounter]; *ADMMass_box_x_max = ADMMass_x_pos[*ADMMass_LoopCounter] + - ADMMass_surface_distance[*ADMMass_LoopCounter]; + ADMMass_surface_distance[*ADMMass_LoopCounter]; *ADMMass_box_y_min = ADMMass_y_pos[*ADMMass_LoopCounter] - - ADMMass_surface_distance[*ADMMass_LoopCounter]; + ADMMass_surface_distance[*ADMMass_LoopCounter]; *ADMMass_box_y_max = ADMMass_y_pos[*ADMMass_LoopCounter] + - ADMMass_surface_distance[*ADMMass_LoopCounter]; + ADMMass_surface_distance[*ADMMass_LoopCounter]; *ADMMass_box_z_min = ADMMass_z_pos[*ADMMass_LoopCounter] - - ADMMass_surface_distance[*ADMMass_LoopCounter]; + ADMMass_surface_distance[*ADMMass_LoopCounter]; *ADMMass_box_z_max = ADMMass_z_pos[*ADMMass_LoopCounter] + - ADMMass_surface_distance[*ADMMass_LoopCounter]; - } + ADMMass_surface_distance[*ADMMass_LoopCounter]; + } else - { + { *ADMMass_box_x_min = ADMMass_x_min[*ADMMass_LoopCounter]; *ADMMass_box_x_max = ADMMass_x_max[*ADMMass_LoopCounter]; *ADMMass_box_y_min = ADMMass_y_min[*ADMMass_LoopCounter]; *ADMMass_box_y_max = ADMMass_y_max[*ADMMass_LoopCounter]; *ADMMass_box_z_min = ADMMass_z_min[*ADMMass_LoopCounter]; *ADMMass_box_z_max = ADMMass_z_max[*ADMMass_LoopCounter]; - } + } if (CCTK_IsThornActive("PUGH")) - { - const void *ghost_ptr = CCTK_ParameterGet("ghost_size","PUGH",NULL); - assert( ghost_ptr != NULL ); - ghost = *(const int *)ghost_ptr; - } + { + const void *ghost_ptr = CCTK_ParameterGet("ghost_size","PUGH",NULL); + assert( ghost_ptr != NULL ); + ghost = *(const int *)ghost_ptr; + } else /* carpet */ - { - const void *ghost_ptr = CCTK_ParameterGet("ghost_size","Carpet",NULL); - assert( ghost_ptr != NULL ); - ghost = *(const int *)ghost_ptr; - } + { + const void *ghost_ptr = CCTK_ParameterGet("ghost_size","Carpet",NULL); + assert( ghost_ptr != NULL ); + ghost = *(const int *)ghost_ptr; + } - ijk = CCTK_GFINDEX3D(cctkGH, cctk_ubnd[0]-cctk_lbnd[0], cctk_ubnd[1]-cctk_lbnd[1],cctk_ubnd[2]-cctk_lbnd[2] ); + ijk = CCTK_GFINDEX3D(cctkGH, cctk_ubnd[0]-cctk_lbnd[0], + cctk_ubnd[1]-cctk_lbnd[1], + cctk_ubnd[2]-cctk_lbnd[2] ); if ( (x[0] < *ADMMass_box_x_min) && (*ADMMass_box_x_min < x[ijk]) ) - x_min_i = find_closest(cctkGH, cctk_lsh, cctk_delta_space, ghost, x, *ADMMass_box_x_min, 0); - + x_min_i = find_closest(cctkGH, cctk_lsh, cctk_delta_space, ghost, + x, *ADMMass_box_x_min, 0); if ( (x[0] < *ADMMass_box_x_max) && (*ADMMass_box_x_max < x[ijk]) ) - x_max_i = find_closest(cctkGH, cctk_lsh, cctk_delta_space, ghost, x, *ADMMass_box_x_max, 0); - + x_max_i = find_closest(cctkGH, cctk_lsh, cctk_delta_space, ghost, + x, *ADMMass_box_x_max, 0); if ( (y[0] < *ADMMass_box_y_min) && (*ADMMass_box_y_min < y[ijk]) ) - y_min_j = find_closest(cctkGH, cctk_lsh, cctk_delta_space, ghost, y, *ADMMass_box_y_min, 1); - + y_min_j = find_closest(cctkGH, cctk_lsh, cctk_delta_space, ghost, + y, *ADMMass_box_y_min, 1); if ( (y[0] < *ADMMass_box_y_max) && (*ADMMass_box_y_max < y[ijk]) ) - y_max_j = find_closest(cctkGH, cctk_lsh, cctk_delta_space, ghost, y, *ADMMass_box_y_max, 1); - + y_max_j = find_closest(cctkGH, cctk_lsh, cctk_delta_space, ghost, + y, *ADMMass_box_y_max, 1); if ( (z[0] < *ADMMass_box_z_min) && (*ADMMass_box_z_min < z[ijk]) ) - z_min_k = find_closest(cctkGH, cctk_lsh, cctk_delta_space, ghost, z, *ADMMass_box_z_min, 2); - + z_min_k = find_closest(cctkGH, cctk_lsh, cctk_delta_space, ghost, + z, *ADMMass_box_z_min, 2); if ( (z[0] < *ADMMass_box_z_max) && (*ADMMass_box_z_max < z[ijk]) ) - z_max_k = find_closest(cctkGH, cctk_lsh, cctk_delta_space, ghost, z, *ADMMass_box_z_max, 2); + z_max_k = find_closest(cctkGH, cctk_lsh, cctk_delta_space, ghost, + z, *ADMMass_box_z_max, 2); for(i=ghost; i<cctk_lsh[0]-ghost; i++) for(j=ghost; j<cctk_lsh[1]-ghost; j++) @@ -166,9 +180,9 @@ void ADMMass_Surface(CCTK_ARGUMENTS) { ijk = CCTK_GFINDEX3D(cctkGH, i, j, k); ADMMass_SurfaceMass_GF[ijk] = 0.0; - - /* delimit the cube on whose surface we want to integrate */ - if ((i >= x_min_i) && + + /* delimit the cube on whose surface we want to integrate */ + if ((i >= x_min_i) && (i <= x_max_i) && (j >= y_min_j) && (j <= y_max_j) && @@ -179,30 +193,35 @@ void ADMMass_Surface(CCTK_ARGUMENTS) ds[1] = 0.0; ds[2] = 0.0; - /* Select the points on the surfaces of the requested cube, - paying attention not to compute the corners (and the verteces) more than once. */ - - /* the whole face of the cube */ + /* Select the points on the surfaces of the requested cube, + paying attention not to compute the corners (and the verteces) + more than once. */ + + /* the whole face of the cube */ if (i == x_min_i) ds[0] = -oneDY*oneDZ; - /* the whole face of the cube */ - if (i == x_max_i) ds[0] = oneDY*oneDZ; + /* the whole face of the cube */ + if (i == x_max_i) ds[0] = oneDY*oneDZ; - /* face, excluding the two corners (and the four verteces) that were already computed above*/ + /* face, excluding the two corners (and the four verteces) that + were already computed above*/ if ((j == y_min_j) && (i != x_min_i) && (i != x_max_i)) ds[1] = -oneDX*oneDZ; - /* face, excluding the other two corners (and the four verteces) - that were already computed above*/ + /* face, excluding the other two corners (and the four verteces) + that were already computed above*/ if ((j == y_max_j) && (i != x_min_i) && (i != x_max_i)) ds[1] = oneDX*oneDZ; - /* face, excluding all corners (and verteces), since they were already computed above */ + /* face, excluding all corners (and verteces), since they were + already computed above */ if ((k == z_min_k) && (j != y_min_j) && (i != x_min_i) && (j != y_max_j) && (i != x_max_i)) ds[2] = -oneDX*oneDY; - /* face, excluding all corners (and verteces), since they were already computed above */ - if ((k == z_max_k) && (j != y_min_j) && (i != x_min_i) && (j != y_max_j) && (i != x_max_i)) + /* face, excluding all corners (and verteces), since they were + already computed above */ + if ((k == z_max_k) && (j != y_min_j) && (i != x_min_i) && + (j != y_max_j) && (i != x_max_i)) ds[2] = oneDX*oneDY; if ((ds[0] != 0.0) || (ds[1] != 0.0) || (ds[2] != 0.0)) @@ -218,50 +237,49 @@ void ADMMass_Surface(CCTK_ARGUMENTS) u[2][1] = UPPERMET_UYZ; u[2][2] = UPPERMET_UZZ; - dg[0][0][0] = ( gxx[di+ijk] - gxx[-di+ijk] ) * OneOverTwoDX; - dg[0][0][1] = ( gxx[dj+ijk] - gxx[-dj+ijk] ) * OneOverTwoDY; - dg[0][0][2] = ( gxx[dk+ijk] - gxx[-dk+ijk] ) * OneOverTwoDZ; - - dg[0][1][0] = ( gxy[di+ijk] - gxy[-di+ijk] ) * OneOverTwoDX; - dg[0][1][1] = ( gxy[dj+ijk] - gxy[-dj+ijk] ) * OneOverTwoDY; - dg[0][1][2] = ( gxy[dk+ijk] - gxy[-dk+ijk] ) * OneOverTwoDZ; - - dg[0][2][0] = ( gxz[di+ijk] - gxz[-di+ijk] ) * OneOverTwoDX; - dg[0][2][1] = ( gxz[dj+ijk] - gxz[-dj+ijk] ) * OneOverTwoDY; - dg[0][2][2] = ( gxz[dk+ijk] - gxz[-dk+ijk] ) * OneOverTwoDZ; - - dg[1][0][0] = dg[0][1][0]; - dg[1][0][1] = dg[0][1][1]; - dg[1][0][2] = dg[0][1][2]; - - dg[1][1][0] = ( gyy[di+ijk] - gyy[-di+ijk] ) * OneOverTwoDX; - dg[1][1][1] = ( gyy[dj+ijk] - gyy[-dj+ijk] ) * OneOverTwoDY; - dg[1][1][2] = ( gyy[dk+ijk] - gyy[-dk+ijk] ) * OneOverTwoDZ; - - dg[1][2][0] = ( gyz[di+ijk] - gyz[-di+ijk] ) * OneOverTwoDX; - dg[1][2][1] = ( gyz[dj+ijk] - gyz[-dj+ijk] ) * OneOverTwoDY; - dg[1][2][2] = ( gyz[dk+ijk] - gyz[-dk+ijk] ) * OneOverTwoDZ; - - dg[2][0][0] = dg[0][2][0]; - dg[2][0][1] = dg[0][2][1]; - dg[2][0][2] = dg[0][2][2]; - - dg[2][1][0] = dg[1][2][0]; - dg[2][1][1] = dg[1][2][1]; - dg[2][1][2] = dg[1][2][2]; - - dg[2][2][0] = ( gzz[di+ijk] - gzz[-di+ijk] ) * OneOverTwoDX; - dg[2][2][1] = ( gzz[dj+ijk] - gzz[-dj+ijk] ) * OneOverTwoDY; - dg[2][2][2] = ( gzz[dk+ijk] - gzz[-dk+ijk] ) * OneOverTwoDZ; + dg[0][0][0] = ( gxx[di+ijk] - gxx[-di+ijk] ) * OneOverTwoDX; + dg[0][0][1] = ( gxx[dj+ijk] - gxx[-dj+ijk] ) * OneOverTwoDY; + dg[0][0][2] = ( gxx[dk+ijk] - gxx[-dk+ijk] ) * OneOverTwoDZ; + + dg[0][1][0] = ( gxy[di+ijk] - gxy[-di+ijk] ) * OneOverTwoDX; + dg[0][1][1] = ( gxy[dj+ijk] - gxy[-dj+ijk] ) * OneOverTwoDY; + dg[0][1][2] = ( gxy[dk+ijk] - gxy[-dk+ijk] ) * OneOverTwoDZ; + + dg[0][2][0] = ( gxz[di+ijk] - gxz[-di+ijk] ) * OneOverTwoDX; + dg[0][2][1] = ( gxz[dj+ijk] - gxz[-dj+ijk] ) * OneOverTwoDY; + dg[0][2][2] = ( gxz[dk+ijk] - gxz[-dk+ijk] ) * OneOverTwoDZ; + + dg[1][0][0] = dg[0][1][0]; + dg[1][0][1] = dg[0][1][1]; + dg[1][0][2] = dg[0][1][2]; + + dg[1][1][0] = ( gyy[di+ijk] - gyy[-di+ijk] ) * OneOverTwoDX; + dg[1][1][1] = ( gyy[dj+ijk] - gyy[-dj+ijk] ) * OneOverTwoDY; + dg[1][1][2] = ( gyy[dk+ijk] - gyy[-dk+ijk] ) * OneOverTwoDZ; + + dg[1][2][0] = ( gyz[di+ijk] - gyz[-di+ijk] ) * OneOverTwoDX; + dg[1][2][1] = ( gyz[dj+ijk] - gyz[-dj+ijk] ) * OneOverTwoDY; + dg[1][2][2] = ( gyz[dk+ijk] - gyz[-dk+ijk] ) * OneOverTwoDZ; + + dg[2][0][0] = dg[0][2][0]; + dg[2][0][1] = dg[0][2][1]; + dg[2][0][2] = dg[0][2][2]; + + dg[2][1][0] = dg[1][2][0]; + dg[2][1][1] = dg[1][2][1]; + dg[2][1][2] = dg[1][2][2]; + + dg[2][2][0] = ( gzz[di+ijk] - gzz[-di+ijk] ) * OneOverTwoDX; + dg[2][2][1] = ( gzz[dj+ijk] - gzz[-dj+ijk] ) * OneOverTwoDY; + dg[2][2][2] = ( gzz[dk+ijk] - gzz[-dk+ijk] ) * OneOverTwoDZ; for (ti = 0; ti < 3; ti++) for (tj = 0; tj < 3; tj++) for (tk = 0; tk < 3; tk++) for (tl = 0; tl < 3; tl++) - { ADMMass_SurfaceMass_GF[ijk] += - u[ti][tj] * u[tk][tl] * ( dg[ti][tk][tj] - dg[ti][tj][tk] ) * ds[tk]; - } + u[ti][tj] * u[tk][tl] * + ( dg[ti][tk][tj] - dg[ti][tj][tk] ) * ds[tk]; ADMMass_SurfaceMass_GF[ijk] *= sqrt(DETG_DETG); } } @@ -290,12 +308,12 @@ void ADMMass_Surface_Global(CCTK_ARGUMENTS) ADMMass_SurfaceMass[*ADMMass_LoopCounter] /= 16.0*PI; CCTK_VInfo(CCTK_THORNSTRING, - "detector %d: ADM mass %g, surface (cube): xmin %g, xmax %g, ymin %g, ymax %g, zmin %g, zmax %g", - *ADMMass_LoopCounter, - ADMMass_SurfaceMass[*ADMMass_LoopCounter], - *ADMMass_box_x_min,*ADMMass_box_x_max, - *ADMMass_box_y_min,*ADMMass_box_y_max, - *ADMMass_box_z_min,*ADMMass_box_z_max); + "detector %d: ADM mass %g, surface (cube): xmin %g, xmax %g, ymin %g, ymax %g, zmin %g, zmax %g", + *ADMMass_LoopCounter, + ADMMass_SurfaceMass[*ADMMass_LoopCounter], + *ADMMass_box_x_min,*ADMMass_box_x_max, + *ADMMass_box_y_min,*ADMMass_box_y_max, + *ADMMass_box_z_min,*ADMMass_box_z_max); } void ADMMass_Surface_Lapse(CCTK_ARGUMENTS) @@ -307,15 +325,15 @@ void ADMMass_Surface_Lapse(CCTK_ARGUMENTS) if (CCTK_IsThornActive("PUGH")) { - const void *ghost_ptr = CCTK_ParameterGet("ghost_size","PUGH",NULL); - assert( ghost_ptr != NULL ); - ghost = *(const int *)ghost_ptr; + const void *ghost_ptr = CCTK_ParameterGet("ghost_size","PUGH",NULL); + assert( ghost_ptr != NULL ); + ghost = *(const int *)ghost_ptr; } else /* carpet */ { - const void *ghost_ptr = CCTK_ParameterGet("ghost_size","Carpet",NULL); - assert( ghost_ptr != NULL ); - ghost = *(const int *)ghost_ptr; + const void *ghost_ptr = CCTK_ParameterGet("ghost_size","Carpet",NULL); + assert( ghost_ptr != NULL ); + ghost = *(const int *)ghost_ptr; } for(i=ghost; i<cctk_lsh[0]-ghost; i++) @@ -347,11 +365,11 @@ void ADMMass_Surface_Lapse_Global(CCTK_ARGUMENTS) ADMMass_SurfaceMass_Lapse[*ADMMass_LoopCounter] /= 16.0*PI; CCTK_VInfo(CCTK_THORNSTRING, - "detector %d: ADM mass with lapse %g, surface (cube): xmin %g, xmax %g, ymin %g, ymax %g, zmin %g, zmax %g", - *ADMMass_LoopCounter, - ADMMass_SurfaceMass_Lapse[*ADMMass_LoopCounter], - *ADMMass_box_x_min,*ADMMass_box_x_max, - *ADMMass_box_y_min,*ADMMass_box_y_max, - *ADMMass_box_z_min,*ADMMass_box_z_max); + "detector %d: ADM mass with lapse %g, surface (cube): xmin %g, xmax %g, ymin %g, ymax %g, zmin %g, zmax %g", + *ADMMass_LoopCounter, + ADMMass_SurfaceMass_Lapse[*ADMMass_LoopCounter], + *ADMMass_box_x_min,*ADMMass_box_x_max, + *ADMMass_box_y_min,*ADMMass_box_y_max, + *ADMMass_box_z_min,*ADMMass_box_z_max); } diff --git a/src/volume_integral.c b/src/volume_integral.c index b64feaa..0b26959 100644 --- a/src/volume_integral.c +++ b/src/volume_integral.c @@ -18,7 +18,7 @@ #include "SpaceMask.h" -#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068 +#define PI 3.1415926535897932384626433832795028841971693993751058209749445923 void ADMMass_Volume(CCTK_ARGUMENTS) { @@ -64,15 +64,15 @@ void ADMMass_Volume(CCTK_ARGUMENTS) if (CCTK_IsThornActive("PUGH")) { - const void *ghost_ptr = CCTK_ParameterGet("ghost_size","PUGH",NULL); - assert( ghost_ptr != NULL ); - ghost = *(const int *)ghost_ptr; + const void *ghost_ptr = CCTK_ParameterGet("ghost_size","PUGH",NULL); + assert( ghost_ptr != NULL ); + ghost = *(const int *)ghost_ptr; } else /* carpet */ { - const void *ghost_ptr = CCTK_ParameterGet("ghost_size","Carpet",NULL); - assert( ghost_ptr != NULL ); - ghost = *(const int *)ghost_ptr; + const void *ghost_ptr = CCTK_ParameterGet("ghost_size","Carpet",NULL); + assert( ghost_ptr != NULL ); + ghost = *(const int *)ghost_ptr; } for(i=1; i<cctk_lsh[0]-1; i++) @@ -96,7 +96,7 @@ void ADMMass_Volume(CCTK_ARGUMENTS) u[2][1] = UPPERMET_UYZ; u[2][2] = UPPERMET_UZZ; - dg[0][0][0] = ( gxx[di+ijk] - gxx[-di+ijk] ) * OneOverTwoDX; + dg[0][0][0] = ( gxx[di+ijk] - gxx[-di+ijk] ) * OneOverTwoDX; dg[0][0][1] = ( gxx[dj+ijk] - gxx[-dj+ijk] ) * OneOverTwoDY; dg[0][0][2] = ( gxx[dk+ijk] - gxx[-dk+ijk] ) * OneOverTwoDZ; @@ -127,7 +127,7 @@ void ADMMass_Volume(CCTK_ARGUMENTS) dg[2][1][0] = dg[1][2][0]; dg[2][1][1] = dg[1][2][1]; dg[2][1][2] = dg[1][2][2]; - + dg[2][2][0] = ( gzz[di+ijk] - gzz[-di+ijk] ) * OneOverTwoDX; dg[2][2][1] = ( gzz[dj+ijk] - gzz[-dj+ijk] ) * OneOverTwoDY; dg[2][2][2] = ( gzz[dk+ijk] - gzz[-dk+ijk] ) * OneOverTwoDZ; @@ -138,13 +138,13 @@ void ADMMass_Volume(CCTK_ARGUMENTS) { ADMMass_VolumeMass_pot_x[ijk] += u[ti][tj] * u[tk][0] * - ( dg[ti][tk][tj] - dg[ti][tj][tk] ); + ( dg[ti][tk][tj] - dg[ti][tj][tk] ); ADMMass_VolumeMass_pot_y[ijk] += u[ti][tj] * u[tk][1] * - ( dg[ti][tk][tj] - dg[ti][tj][tk] ); + ( dg[ti][tk][tj] - dg[ti][tj][tk] ); ADMMass_VolumeMass_pot_z[ijk] += u[ti][tj] * u[tk][2] * - ( dg[ti][tk][tj] - dg[ti][tj][tk] ); + ( dg[ti][tk][tj] - dg[ti][tj][tk] ); } ADMMass_VolumeMass_pot_x[ijk] *= alp[ijk] * sqrt(DETG_DETG); ADMMass_VolumeMass_pot_y[ijk] *= alp[ijk] * sqrt(DETG_DETG); @@ -158,7 +158,8 @@ void ADMMass_Volume(CCTK_ARGUMENTS) { ijk = CCTK_GFINDEX3D(cctkGH, i, j, k); - if ((ADMMass_use_all_volume_as_volume_radius)||((!ADMMass_Excise_Horizons || + if ((ADMMass_use_all_volume_as_volume_radius)|| + ((!ADMMass_Excise_Horizons || SpaceMask_CheckStateBits(space_mask, ijk, mask_descriptor, state_descriptor_outside)) && @@ -172,108 +173,98 @@ void ADMMass_Volume(CCTK_ARGUMENTS) { ADMMass_VolumeMass_GF[ijk] = ((ADMMass_VolumeMass_pot_x[CCTK_GFINDEX3D(cctkGH,i+1,j,k)]- - ADMMass_VolumeMass_pot_x[CCTK_GFINDEX3D(cctkGH,i-1,j,k)])*OneOverTwoDX+ + ADMMass_VolumeMass_pot_x[CCTK_GFINDEX3D(cctkGH,i-1,j,k)])* + OneOverTwoDX+ (ADMMass_VolumeMass_pot_y[CCTK_GFINDEX3D(cctkGH,i,j+1,k)]- - ADMMass_VolumeMass_pot_y[CCTK_GFINDEX3D(cctkGH,i,j-1,k)])*OneOverTwoDY+ + ADMMass_VolumeMass_pot_y[CCTK_GFINDEX3D(cctkGH,i,j-1,k)])* + OneOverTwoDY+ (ADMMass_VolumeMass_pot_z[CCTK_GFINDEX3D(cctkGH,i,j,k+1)]- - ADMMass_VolumeMass_pot_z[CCTK_GFINDEX3D(cctkGH,i,j,k-1)])*OneOverTwoDZ); - } + ADMMass_VolumeMass_pot_z[CCTK_GFINDEX3D(cctkGH,i,j,k-1)])* + OneOverTwoDZ); + } } - /* Carpet does the following itself, but pugh does not. */ + /* Carpet does the following itself, but pugh does not. */ if (CCTK_IsThornActive("PUGH")) - { - /*Recompute the integrand on the symmetry and physical boundaries: devide by 2 on the boundary faces - cctk_lbnd values start from zero, so must add one to get the total number of points. - If cctk_ubnd[2]=n, it means that it is the (n+1)-st point (C notation) */ - - /* for short hand, right and left modified stencil values */ - const int lst = ghost; - const int rst1 = cctk_lsh[1] - ghost; - const int rst2 = cctk_lsh[2] - ghost; - const int rst3 = cctk_lsh[3] - ghost; - - /*find the value of the "avoid_origin" parameter */ - const void *avoid_origin_parameter_ptr = CCTK_ParameterValString("avoid_origin","CartGrid3D"); - assert( avoid_origin_parameter_ptr != NULL ); + { + /* Recompute the integrand on the symmetry and physical boundaries: + devide by 2 on the boundary faces cctk_lbnd values start from zero, + so must add one to get the total number of points. + If cctk_ubnd[2]=n, it means that it is the (n+1)-st point + (C notation) */ + + /* for short hand, right and left modified stencil values */ + const int lst = ghost; + const int rst1 = cctk_lsh[1] - ghost; + const int rst2 = cctk_lsh[2] - ghost; + const int rst3 = cctk_lsh[3] - ghost; + + /*find the value of the "avoid_origin" parameter */ + const void *avoid_origin_parameter_ptr = + CCTK_ParameterValString("avoid_origin","CartGrid3D"); + assert( avoid_origin_parameter_ptr != NULL ); avoid_origin_parameter = *(const CCTK_INT *)avoid_origin_parameter_ptr; - printf("avoid origin %d\n",avoid_origin_parameter); + printf("avoid origin %d\n",avoid_origin_parameter); - /* if avoid_origin = yes (default), then do not devide by two. - This gives the correct result for the trapezoidal integration rule on the symmetry boundaries, - while (even if it is wrong not to devide by two the points on the faces that are - physical outer boundaries) it should not spoil the result. */ - - if (! avoid_origin_parameter) - { - if (cctk_lbnd[2] == 0) - { - for(j = lst; j <= rst2; j++) - for(i = lst; i <= rst1; i++) - { - ijk = CCTK_GFINDEX3D(cctkGH, i, j, lst); - ADMMass_VolumeMass_GF[ijk] = ADMMass_VolumeMass_GF[ijk] * 0.5; - } - } - - if (cctk_ubnd[2]+1 == cctk_gsh[2]) - { - for(j = lst; j <= rst2; j++) - for(i = lst; i <= rst1; i++) - { - ijk = CCTK_GFINDEX3D(cctkGH, i, j, rst3); - ADMMass_VolumeMass_GF[ijk] = ADMMass_VolumeMass_GF[ijk] * 0.5; - } - } + /* if avoid_origin = yes (default), then do not devide by two. + This gives the correct result for the trapezoidal integration rule + on the symmetry boundaries, while (even if it is wrong not to devide + by two the points on the faces that are + physical outer boundaries) it should not spoil the result. */ - if (cctk_lbnd[1] == 0) - { - for(k = lst; k<= rst3; k++) - for(i = lst; i<= rst1; i++) - { - ijk = CCTK_GFINDEX3D(cctkGH, i, lst, k); - ADMMass_VolumeMass_GF[ijk] = ADMMass_VolumeMass_GF[ijk] * 0.5; - } - } - - if (cctk_ubnd[1]+1 == cctk_gsh[1]) - { - for(k = lst; k<= rst3; k++) - for(i = lst; i<= rst1; i++) - { - ijk = CCTK_GFINDEX3D(cctkGH, i, rst2, k); - ADMMass_VolumeMass_GF[ijk] = ADMMass_VolumeMass_GF[ijk] * 0.5; - } - } - - if (cctk_lbnd[0] == 0) - { - for(k = lst; k <= rst3; k++) - for(j = lst; j <= rst2; j++) - { - ijk = CCTK_GFINDEX3D(cctkGH, lst, j, k); - ADMMass_VolumeMass_GF[ijk] = ADMMass_VolumeMass_GF[ijk] * 0.5; - } - } - - if (cctk_ubnd[0]+1 == cctk_gsh[0]) - { - for(k = lst; k <= rst3; k++) - for(j = lst; j <= rst2; j++) - { - ijk = CCTK_GFINDEX3D(cctkGH, rst1, j, k); - ADMMass_VolumeMass_GF[ijk] = ADMMass_VolumeMass_GF[ijk] * 0.5; - } - } - - } /* end if avoid_origin */ - - } /* end if PUGH */ - - *grid_spacing_product = cctk_delta_space[0]*cctk_delta_space[1]*cctk_delta_space[2]; + if (! avoid_origin_parameter) + { + if (cctk_lbnd[2] == 0) + for(j = lst; j <= rst2; j++) + for(i = lst; i <= rst1; i++) + { + ijk = CCTK_GFINDEX3D(cctkGH, i, j, lst); + ADMMass_VolumeMass_GF[ijk] *= 0.5; + } + if (cctk_ubnd[2]+1 == cctk_gsh[2]) + for(j = lst; j <= rst2; j++) + for(i = lst; i <= rst1; i++) + { + ijk = CCTK_GFINDEX3D(cctkGH, i, j, rst3); + ADMMass_VolumeMass_GF[ijk] *= 0.5; + } + if (cctk_lbnd[1] == 0) + for(k = lst; k<= rst3; k++) + for(i = lst; i<= rst1; i++) + { + ijk = CCTK_GFINDEX3D(cctkGH, i, lst, k); + ADMMass_VolumeMass_GF[ijk] *= 0.5; + } + if (cctk_ubnd[1]+1 == cctk_gsh[1]) + for(k = lst; k<= rst3; k++) + for(i = lst; i<= rst1; i++) + { + ijk = CCTK_GFINDEX3D(cctkGH, i, rst2, k); + ADMMass_VolumeMass_GF[ijk] *= 0.5; + } + if (cctk_lbnd[0] == 0) + for(k = lst; k <= rst3; k++) + for(j = lst; j <= rst2; j++) + { + ijk = CCTK_GFINDEX3D(cctkGH, lst, j, k); + ADMMass_VolumeMass_GF[ijk] *= 0.5; + } + if (cctk_ubnd[0]+1 == cctk_gsh[0]) + for(k = lst; k <= rst3; k++) + for(j = lst; j <= rst2; j++) + { + ijk = CCTK_GFINDEX3D(cctkGH, rst1, j, k); + ADMMass_VolumeMass_GF[ijk] *= 0.5; + } + } /* end if avoid_origin */ + } /* end if PUGH */ + + *grid_spacing_product = cctk_delta_space[0]* + cctk_delta_space[1]* + cctk_delta_space[2]; #include "CactusEinstein/ADMMacros/src/macro/UPPERMET_undefine.h" } @@ -301,24 +292,24 @@ void ADMMass_Volume_Global(CCTK_ARGUMENTS) if (ADMMass_use_surface_distance_as_volume_radius) { - CCTK_VInfo(CCTK_THORNSTRING, - "detector %d: ADM mass %g, volume (cube): xmin %g, xmax %g, ymin %g, ymax %g, zmin %g, zmax %g", - *ADMMass_LoopCounter, - ADMMass_SurfaceMass[*ADMMass_LoopCounter], - *ADMMass_box_x_min,*ADMMass_box_x_max, - *ADMMass_box_y_min,*ADMMass_box_y_max, - *ADMMass_box_z_min,*ADMMass_box_z_max); + CCTK_VInfo(CCTK_THORNSTRING, + "detector %d: ADM mass %g, volume (cube): xmin %g, xmax %g, ymin %g, ymax %g, zmin %g, zmax %g", + *ADMMass_LoopCounter, + ADMMass_SurfaceMass[*ADMMass_LoopCounter], + *ADMMass_box_x_min,*ADMMass_box_x_max, + *ADMMass_box_y_min,*ADMMass_box_y_max, + *ADMMass_box_z_min,*ADMMass_box_z_max); } else if (ADMMass_use_all_volume_as_volume_radius) { - CCTK_VInfo(CCTK_THORNSTRING," detector %d: ADM mass %g, volume: the whole grid", - *ADMMass_LoopCounter, ADMMass_VolumeMass[*ADMMass_LoopCounter]); + CCTK_VInfo(CCTK_THORNSTRING," detector %d: ADM mass %g, volume: the whole grid", + *ADMMass_LoopCounter, ADMMass_VolumeMass[*ADMMass_LoopCounter]); } else { - CCTK_VInfo(CCTK_THORNSTRING," detector %d: ADM mass %g, volume (sphere of radius) %g", - *ADMMass_LoopCounter, ADMMass_VolumeMass[*ADMMass_LoopCounter], - ADMMass_volume_radius[*ADMMass_LoopCounter]); + CCTK_VInfo(CCTK_THORNSTRING," detector %d: ADM mass %g, volume (sphere of radius) %g", + *ADMMass_LoopCounter, ADMMass_VolumeMass[*ADMMass_LoopCounter], + ADMMass_volume_radius[*ADMMass_LoopCounter]); } } |