From d3d941dd0aa15adc25f5fab074fd69011be52f79 Mon Sep 17 00:00:00 2001 From: knarf Date: Fri, 28 Apr 2006 09:22:16 +0000 Subject: 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 --- src/surface_integral.c | 268 ++++++++++++++++++++++++++----------------------- 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 #include -#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= 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