diff options
Diffstat (limited to 'src/volume_integral.c')
-rw-r--r-- | src/volume_integral.c | 223 |
1 files changed, 107 insertions, 116 deletions
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]); } } |