diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AMSS_NCKU_Program.py b/AMSS_NCKU_Program.py
index 2d777cd..9c025dd 100755
--- a/AMSS_NCKU_Program.py
+++ b/AMSS_NCKU_Program.py
@@ -126,12 +126,7 @@ setup.generate_AMSSNCKU_input()
#inputvalue = input() ## Wait for user input (press Enter) to proceed
#print()
-setup.print_puncture_information()
-
-
-##################################################################
-
-## Generate AMSS-NCKU program input files based on the configured parameters
+## Generate AMSS-NCKU program input files based on the configured parameters
print( )
print( " Generating the AMSS-NCKU input parfile for the ABE executable. " )
@@ -312,7 +307,7 @@ if (input_data.Initial_Data_Method == "Ansorg-TwoPuncture" ):
import generate_TwoPuncture_input
- generate_TwoPuncture_input.generate_AMSSNCKU_TwoPuncture_input()
+ generate_TwoPuncture_input.generate_AMSSNCKU_TwoPuncture_input(numerical_grid.puncture_data)
print( )
print( " The input parfile for the TwoPunctureABE executable has been generated. " )
@@ -354,7 +349,7 @@ if (input_data.Initial_Data_Method == "Ansorg-TwoPuncture" ):
import renew_puncture_parameter
-renew_puncture_parameter.append_AMSSNCKU_BSSN_input(File_directory, output_directory)
+renew_puncture_parameter.append_AMSSNCKU_BSSN_input(File_directory, output_directory, numerical_grid.puncture_data)
## Generated AMSS-NCKU input filename
diff --git a/AMSS_NCKU_source/BH_diagnostics.C b/AMSS_NCKU_source/AHF_Direct/BH_diagnostics.C
similarity index 97%
rename from AMSS_NCKU_source/BH_diagnostics.C
rename to AMSS_NCKU_source/AHF_Direct/BH_diagnostics.C
index c24adf7..09fe8cb 100644
--- a/AMSS_NCKU_source/BH_diagnostics.C
+++ b/AMSS_NCKU_source/AHF_Direct/BH_diagnostics.C
@@ -1,724 +1,724 @@
-#include
-#include
-#include
-
-#include "util_Table.h"
-#include "cctk.h"
-
-#include "config.h"
-#include "stdc.h"
-#include "util.h"
-#include "array.h"
-#include "cpm_map.h"
-#include "linear_map.h"
-
-#include "coords.h"
-#include "tgrid.h"
-#include "fd_grid.h"
-#include "patch.h"
-#include "patch_edge.h"
-#include "patch_interp.h"
-#include "ghost_zone.h"
-#include "patch_system.h"
-
-#include "Jacobian.h"
-
-#include "gfns.h"
-#include "gr.h"
-#include "myglobal.h"
-
-#include "horizon_sequence.h"
-#include "BH_diagnostics.h"
-#include "driver.h"
-
-namespace AHFinderDirect
-{
- using jtutil::error_exit;
-
- BH_diagnostics::BH_diagnostics()
- : centroid_x(0.0), centroid_y(0.0), centroid_z(0.0),
- quadrupole_xx(0.0), quadrupole_xy(0.0), quadrupole_xz(0.0),
- quadrupole_yy(0.0), quadrupole_yz(0.0),
- quadrupole_zz(0.0),
- min_radius(0.0), max_radius(0.0),
- mean_radius(0.0),
- min_x(0.0), max_x(0.0),
- min_y(0.0), max_y(0.0),
- min_z(0.0), max_z(0.0),
- circumference_xy(0.0), circumference_xz(0.0), circumference_yz(0.0),
- area(0.0), irreducible_mass(0.0), areal_radius(0.0) // no comma
- {
- }
-
- void BH_diagnostics::copy_to_buffer(double buffer[N_buffer])
- const
- {
- buffer[posn__centroid_x] = centroid_x;
- buffer[posn__centroid_y] = centroid_y;
- buffer[posn__centroid_z] = centroid_z;
-
- buffer[posn__quadrupole_xx] = quadrupole_xx;
- buffer[posn__quadrupole_xy] = quadrupole_xy;
- buffer[posn__quadrupole_xz] = quadrupole_xz;
- buffer[posn__quadrupole_yy] = quadrupole_yy;
- buffer[posn__quadrupole_xz] = quadrupole_yz;
- buffer[posn__quadrupole_zz] = quadrupole_zz;
-
- buffer[posn__min_radius] = min_radius;
- buffer[posn__max_radius] = max_radius;
- buffer[posn__mean_radius] = mean_radius;
-
- buffer[posn__min_x] = min_x;
- buffer[posn__max_x] = max_x;
- buffer[posn__min_y] = min_y;
- buffer[posn__max_y] = max_y;
- buffer[posn__min_z] = min_z;
- buffer[posn__max_z] = max_z;
-
- buffer[posn__circumference_xy] = circumference_xy;
- buffer[posn__circumference_xz] = circumference_xz;
- buffer[posn__circumference_yz] = circumference_yz;
-
- buffer[posn__area] = area;
- buffer[posn__irreducible_mass] = irreducible_mass;
- buffer[posn__areal_radius] = areal_radius;
- }
-
- void BH_diagnostics::copy_from_buffer(const double buffer[N_buffer])
- {
- centroid_x = buffer[posn__centroid_x];
- centroid_y = buffer[posn__centroid_y];
- centroid_z = buffer[posn__centroid_z];
-
- quadrupole_xx = buffer[posn__quadrupole_xx];
- quadrupole_xy = buffer[posn__quadrupole_xy];
- quadrupole_xz = buffer[posn__quadrupole_xz];
- quadrupole_yy = buffer[posn__quadrupole_yy];
- quadrupole_yz = buffer[posn__quadrupole_yz];
- quadrupole_zz = buffer[posn__quadrupole_zz];
-
- min_radius = buffer[posn__min_radius];
- max_radius = buffer[posn__max_radius];
- mean_radius = buffer[posn__mean_radius];
-
- min_x = buffer[posn__min_x];
- max_x = buffer[posn__max_x];
- min_y = buffer[posn__min_y];
- max_y = buffer[posn__max_y];
- min_z = buffer[posn__min_z];
- max_z = buffer[posn__max_z];
-
- circumference_xy = buffer[posn__circumference_xy];
- circumference_xz = buffer[posn__circumference_xz];
- circumference_yz = buffer[posn__circumference_yz];
-
- area = buffer[posn__area];
- irreducible_mass = buffer[posn__irreducible_mass];
- areal_radius = buffer[posn__areal_radius];
- }
- void BH_diagnostics::compute(patch_system &ps)
- {
- jtutil::norm h_norms;
- ps.ghosted_gridfn_norms(gfns::gfn__h, h_norms);
- min_radius = h_norms.min_abs_value();
- max_radius = h_norms.max_abs_value();
-
- jtutil::norm x_norms;
- jtutil::norm y_norms;
- jtutil::norm z_norms;
-
- ps.gridfn_norms(gfns::gfn__global_x, x_norms);
- ps.gridfn_norms(gfns::gfn__global_y, y_norms);
- ps.gridfn_norms(gfns::gfn__global_z, z_norms);
-
- min_x = x_norms.min_value();
- max_x = x_norms.max_value();
- min_y = y_norms.min_value();
- max_y = y_norms.max_value();
- min_z = z_norms.min_value();
- max_z = z_norms.max_value();
-
-// adjust the bounding box for the symmetries
-#define REFLECT(origin_, max_) (origin_ - (max_ - origin_))
- switch (ps.type())
- {
- case patch_system::patch_system__full_sphere:
- break;
- case patch_system::patch_system__plus_z_hemisphere:
- min_z = REFLECT(ps.origin_z(), max_z);
- break;
- case patch_system::patch_system__plus_xy_quadrant_mirrored:
- case patch_system::patch_system__plus_xy_quadrant_rotating:
- min_x = REFLECT(ps.origin_x(), max_x);
- min_y = REFLECT(ps.origin_y(), max_y);
- break;
- case patch_system::patch_system__plus_xz_quadrant_mirrored:
- case patch_system::patch_system__plus_xz_quadrant_rotating:
- min_x = REFLECT(ps.origin_x(), max_x);
- min_z = REFLECT(ps.origin_z(), max_z);
- break;
- case patch_system::patch_system__plus_xyz_octant_mirrored:
- case patch_system::patch_system__plus_xyz_octant_rotating:
- min_x = REFLECT(ps.origin_x(), max_x);
- min_y = REFLECT(ps.origin_y(), max_y);
- min_z = REFLECT(ps.origin_z(), max_z);
- break;
- default:
- error_exit(PANIC_EXIT,
- "***** BH_diagnostics::compute(): unknown patch system type()=(int)%d!\n"
- " (this should never happen!)\n",
- int(ps.type())); /*NOTREACHED*/
- }
-
- //
- // surface integrals
- //
- const fp integral_one = surface_integral(ps,
- gfns::gfn__one, true, true, true,
- patch::integration_method__automatic_choice);
- const fp integral_h = surface_integral(ps,
- gfns::gfn__h, true, true, true,
- patch::integration_method__automatic_choice);
- const fp integral_x = surface_integral(ps,
- gfns::gfn__global_x, true, true, false,
- patch::integration_method__automatic_choice);
- const fp integral_y = surface_integral(ps,
- gfns::gfn__global_y, true, false, true,
- patch::integration_method__automatic_choice);
- const fp integral_z = surface_integral(ps,
- gfns::gfn__global_z, false, true, true,
- patch::integration_method__automatic_choice);
- const fp integral_xx = surface_integral(ps,
- gfns::gfn__global_xx, true, true, true,
- patch::integration_method__automatic_choice);
- const fp integral_xy = surface_integral(ps,
- gfns::gfn__global_xy, true, false, false,
- patch::integration_method__automatic_choice);
- const fp integral_xz = surface_integral(ps,
- gfns::gfn__global_xz, false, true, false,
- patch::integration_method__automatic_choice);
- const fp integral_yy = surface_integral(ps,
- gfns::gfn__global_yy, true, true, true,
- patch::integration_method__automatic_choice);
- const fp integral_yz = surface_integral(ps,
- gfns::gfn__global_yz, false, false, true,
- patch::integration_method__automatic_choice);
- const fp integral_zz = surface_integral(ps,
- gfns::gfn__global_zz, true, true, true,
- patch::integration_method__automatic_choice);
-
- //
- // centroids
- //
- centroid_x = integral_x / integral_one;
- centroid_y = integral_y / integral_one;
- centroid_z = integral_z / integral_one;
-
- //
- // quadrupoles (taken about centroid position)
- //
- quadrupole_xx = integral_xx / integral_one - centroid_x * centroid_x;
- quadrupole_xy = integral_xy / integral_one - centroid_x * centroid_y;
- quadrupole_xz = integral_xz / integral_one - centroid_x * centroid_z;
- quadrupole_yy = integral_yy / integral_one - centroid_y * centroid_y;
- quadrupole_yz = integral_yz / integral_one - centroid_y * centroid_z;
- quadrupole_zz = integral_zz / integral_one - centroid_z * centroid_z;
-
- //
- // mean radius of horizon
- //
- mean_radius = integral_h / integral_one;
-
- //
- // surface area and quantities derived from it
- //
- area = integral_one;
- irreducible_mass = sqrt(area / (16.0 * PI));
- areal_radius = sqrt(area / (4.0 * PI));
-
- //
- // proper circumferences
- //
- circumference_xy = ps.circumference("xy", gfns::gfn__h,
- gfns::gfn__g_dd_11, gfns::gfn__g_dd_12, gfns::gfn__g_dd_13,
- gfns::gfn__g_dd_22, gfns::gfn__g_dd_23,
- gfns::gfn__g_dd_33,
- patch::integration_method__automatic_choice);
- circumference_xz = ps.circumference("xz", gfns::gfn__h,
- gfns::gfn__g_dd_11, gfns::gfn__g_dd_12, gfns::gfn__g_dd_13,
- gfns::gfn__g_dd_22, gfns::gfn__g_dd_23,
- gfns::gfn__g_dd_33,
- patch::integration_method__automatic_choice);
- circumference_yz = ps.circumference("yz", gfns::gfn__h,
- gfns::gfn__g_dd_11, gfns::gfn__g_dd_12, gfns::gfn__g_dd_13,
- gfns::gfn__g_dd_22, gfns::gfn__g_dd_23,
- gfns::gfn__g_dd_33,
- patch::integration_method__automatic_choice);
-
- // prepare P^i,S^i in xx,xy,xz and yy,yz,zz
- {
- for (int pn = 0; pn < ps.N_patches(); ++pn)
- {
- patch &p = ps.ith_patch(pn);
-
- for (int irho = p.min_irho(); irho <= p.max_irho(); ++irho)
- {
- for (int isigma = p.min_isigma();
- isigma <= p.max_isigma();
- ++isigma)
- {
- const fp g_xx = p.gridfn(gfns::gfn__g_dd_11, irho, isigma);
- const fp g_xy = p.gridfn(gfns::gfn__g_dd_12, irho, isigma);
- const fp g_xz = p.gridfn(gfns::gfn__g_dd_13, irho, isigma);
- const fp g_yy = p.gridfn(gfns::gfn__g_dd_22, irho, isigma);
- const fp g_yz = p.gridfn(gfns::gfn__g_dd_23, irho, isigma);
- const fp g_zz = p.gridfn(gfns::gfn__g_dd_33, irho, isigma);
-
- const fp k_xx = p.gridfn(gfns::gfn__K_dd_11, irho, isigma);
- const fp k_xy = p.gridfn(gfns::gfn__K_dd_12, irho, isigma);
- const fp k_xz = p.gridfn(gfns::gfn__K_dd_13, irho, isigma);
- const fp k_yy = p.gridfn(gfns::gfn__K_dd_22, irho, isigma);
- const fp k_yz = p.gridfn(gfns::gfn__K_dd_23, irho, isigma);
- const fp k_zz = p.gridfn(gfns::gfn__K_dd_33, irho, isigma);
- const fp trk = p.gridfn(gfns::gfn__trK, irho, isigma);
-
- const fp r = p.ghosted_gridfn(gfns::gfn__h, irho, isigma);
- const fp rho = p.rho_of_irho(irho);
- const fp sigma = p.sigma_of_isigma(isigma);
- fp xx, yy, zz; // local Cardesian coordinate
- p.xyz_of_r_rho_sigma(r, rho, sigma, xx, yy, zz);
- const fp X_ud_11 = p.partial_rho_wrt_x(xx, yy, zz);
- const fp X_ud_12 = p.partial_rho_wrt_y(xx, yy, zz);
- const fp X_ud_13 = p.partial_rho_wrt_z(xx, yy, zz);
- const fp X_ud_21 = p.partial_sigma_wrt_x(xx, yy, zz);
- const fp X_ud_22 = p.partial_sigma_wrt_y(xx, yy, zz);
- const fp X_ud_23 = p.partial_sigma_wrt_z(xx, yy, zz);
-#if 0 // for P^i and S^i
- // F,i = x^i/r-X_ud_1i(dh/drho)-X_ud_2i(dh/dsigma)
- double nx,ny,nz;
- nx = xx/r-X_ud_11*p.partial_rho(gfns::gfn__h, irho,isigma)-X_ud_21*p.partial_sigma(gfns::gfn__h, irho,isigma);
- ny = yy/r-X_ud_12*p.partial_rho(gfns::gfn__h, irho,isigma)-X_ud_22*p.partial_sigma(gfns::gfn__h, irho,isigma);
- nz = zz/r-X_ud_13*p.partial_rho(gfns::gfn__h, irho,isigma)-X_ud_23*p.partial_sigma(gfns::gfn__h, irho,isigma);
- double eps; // volume element
- fp g_uu_11, g_uu_12, g_uu_13, g_uu_22, g_uu_23, g_uu_33;
- double pxx,pxy,pxz,pyy,pyz,pzz;
- {
- fp t1, t2, t4, t5, t7, t8, t11, t12, t14, t15;
- fp t18, t21;
- t1 = g_yy;
- t2 = g_zz;
- t4 = g_yz;
- t5 = t4*t4;
- t7 = g_xx;
- t8 = t7*t1;
- t11 = g_xy;
- t12 = t11*t11;
- t14 = g_xz;
- t15 = t11*t14;
- t18 = t14*t14;
- eps = t8*t2-t7*t5-t12*t2+2.0*t15*t4-t18*t1;
- t21 = 1/eps;
- eps = sqrt(eps);
- g_uu_11 = (t1*t2-t5)*t21;
- g_uu_12 = -(t11*t2-t14*t4)*t21;
- g_uu_13 = -(-t11*t4+t14*t1)*t21;
- g_uu_22 = (t7*t2-t18)*t21;
- g_uu_23 = -(t7*t4-t15)*t21;
- g_uu_33 = (t8-t12)*t21;
-
- t5 = g_uu_11*nx*nx+g_uu_22*ny*ny+g_uu_33*nz*nz+2*(g_uu_12*nx*ny+g_uu_13*nx*nz+g_uu_23*ny*nz);
- t5 = sqrt(t5);
- nx = nx/t5; // lower index
- ny = ny/t5;
- nz = nz/t5;
-
- pxx= g_uu_11*(g_uu_11*k_xx+g_uu_12*k_xy+g_uu_13*k_xz)
- +g_uu_12*(g_uu_11*k_xy+g_uu_12*k_yy+g_uu_13*k_yz)
- +g_uu_13*(g_uu_11*k_xz+g_uu_12*k_yz+g_uu_13*k_zz); //k^xx
- pxy= g_uu_11*(g_uu_12*k_xx+g_uu_22*k_xy+g_uu_23*k_xz)
- +g_uu_12*(g_uu_12*k_xy+g_uu_22*k_yy+g_uu_23*k_yz)
- +g_uu_13*(g_uu_12*k_xz+g_uu_22*k_yz+g_uu_23*k_zz); //k^xy
- pxz= g_uu_11*(g_uu_13*k_xx+g_uu_23*k_xy+g_uu_33*k_xz)
- +g_uu_12*(g_uu_13*k_xy+g_uu_23*k_yy+g_uu_33*k_yz)
- +g_uu_13*(g_uu_13*k_xz+g_uu_23*k_yz+g_uu_33*k_zz); //k^xz
- pyy= g_uu_12*(g_uu_12*k_xx+g_uu_22*k_xy+g_uu_23*k_xz)
- +g_uu_22*(g_uu_12*k_xy+g_uu_22*k_yy+g_uu_23*k_yz)
- +g_uu_23*(g_uu_12*k_xz+g_uu_22*k_yz+g_uu_23*k_zz); //k^yy
- pyz= g_uu_12*(g_uu_13*k_xx+g_uu_23*k_xy+g_uu_33*k_xz)
- +g_uu_22*(g_uu_13*k_xy+g_uu_23*k_yy+g_uu_33*k_yz)
- +g_uu_23*(g_uu_13*k_xz+g_uu_23*k_yz+g_uu_33*k_zz); //k^yz
- pzz= g_uu_13*(g_uu_13*k_xx+g_uu_23*k_xy+g_uu_33*k_xz)
- +g_uu_23*(g_uu_13*k_xy+g_uu_23*k_yy+g_uu_33*k_yz)
- +g_uu_33*(g_uu_13*k_xz+g_uu_23*k_yz+g_uu_33*k_zz); //k^zz
- }
-
- pxx = pxx-g_uu_11*trk; // tracefree
- pyy = pyy-g_uu_22*trk;
- pzz = pzz-g_uu_33*trk;
- double tx,ty,tz;
- double sxx,sxy,sxz,syx,syy,syz,szx,szy,szz;
- tx = nx*pxx + ny*pxy + nz*pxz;
- ty = nx*pxy + ny*pyy + nz*pyz;
- tz = nx*pxz + ny*pyz + nz*pzz;
- sxx = xx*tx;
- sxy = xx*ty;
- sxz = xx*tz;
- syx = yy*tx;
- syy = yy*ty;
- syz = yy*tz;
- szx = zz*tx;
- szy = zz*ty;
- szz = zz*tz;
- p.gridfn(gfns::gfn__global_xx, irho,isigma) = tx; //p^x
- p.gridfn(gfns::gfn__global_xy, irho,isigma) = ty; //p^y
- p.gridfn(gfns::gfn__global_xz, irho,isigma) = tz; //p^z
- tx = eps*(syz-szy); //s_x
- ty = eps*(szx-sxz);
- tz = eps*(sxy-syx);
- p.gridfn(gfns::gfn__global_yy, irho,isigma) = g_uu_11*tx+g_uu_12*ty+g_uu_13*tz; //s^x
- p.gridfn(gfns::gfn__global_yz, irho,isigma) = g_uu_12*tx+g_uu_22*ty+g_uu_23*tz; //s^y
- p.gridfn(gfns::gfn__global_zz, irho,isigma) = g_uu_13*tx+g_uu_23*ty+g_uu_33*tz; //s^z
-#endif
-#if 1 // for P_i and S_i
- // F,i = x^i/r-X_ud_1i(dh/drho)-X_ud_2i(dh/dsigma)
- double nx, ny, nz;
- nx = xx / r - X_ud_11 * p.partial_rho(gfns::gfn__h, irho, isigma) - X_ud_21 * p.partial_sigma(gfns::gfn__h, irho, isigma);
- ny = yy / r - X_ud_12 * p.partial_rho(gfns::gfn__h, irho, isigma) - X_ud_22 * p.partial_sigma(gfns::gfn__h, irho, isigma);
- nz = zz / r - X_ud_13 * p.partial_rho(gfns::gfn__h, irho, isigma) - X_ud_23 * p.partial_sigma(gfns::gfn__h, irho, isigma);
- {
- fp g_uu_11, g_uu_12, g_uu_13, g_uu_22, g_uu_23, g_uu_33;
- fp t1, t2, t4, t5, t7, t8, t11, t12, t14, t15;
- fp t18, t21;
- t1 = g_yy;
- t2 = g_zz;
- t4 = g_yz;
- t5 = t4 * t4;
- t7 = g_xx;
- t8 = t7 * t1;
- t11 = g_xy;
- t12 = t11 * t11;
- t14 = g_xz;
- t15 = t11 * t14;
- t18 = t14 * t14;
- t21 = 1 / (t8 * t2 - t7 * t5 - t12 * t2 + 2.0 * t15 * t4 - t18 * t1);
- g_uu_11 = (t1 * t2 - t5) * t21;
- g_uu_12 = -(t11 * t2 - t14 * t4) * t21;
- g_uu_13 = -(-t11 * t4 + t14 * t1) * t21;
- g_uu_22 = (t7 * t2 - t18) * t21;
- g_uu_23 = -(t7 * t4 - t15) * t21;
- g_uu_33 = (t8 - t12) * t21;
-
- t1 = g_uu_11 * nx + g_uu_12 * ny + g_uu_13 * nz;
- t2 = g_uu_12 * nx + g_uu_22 * ny + g_uu_23 * nz;
- t4 = g_uu_13 * nx + g_uu_23 * ny + g_uu_33 * nz;
- t5 = g_uu_11 * nx * nx + g_uu_22 * ny * ny + g_uu_33 * nz * nz + 2 * (g_uu_12 * nx * ny + g_uu_13 * nx * nz + g_uu_23 * ny * nz);
- t5 = sqrt(t5);
- nx = t1 / t5; // uper index
- ny = t2 / t5;
- nz = t4 / t5;
- }
-
- double pxx, pxy, pxz, pyy, pyz, pzz;
- double sxx, sxy, sxz, syx, syy, syz, szx, szy, szz;
- // these tensor components are same for local Cardisean and global Cardisean
- pxx = k_xx - g_xx * trk; // lower index
- pxy = k_xy;
- pxz = k_xz;
- pyy = k_yy - g_yy * trk;
- pyz = k_yz;
- pzz = k_zz - g_zz * trk;
- /*
- sxx = yy*pxy - zz*pxz;
- sxy = yy*pyy - zz*pyz;
- sxz = yy*pyz - zz*pzz;
- syx = zz*pxy - yy*pxz;
- syy = zz*pyy - yy*pyz;
- syz = zz*pyz - yy*pzz;
- szx = xx*pxy - yy*pxx;
- szy = xx*pyy - yy*pxy;
- szz = xx*pyz - yy*pxz;
- */
- // we need Cardisean coordinate whose original point coincide with centroid_x^i
- xx = p.gridfn(gfns::gfn__global_x, irho, isigma) - centroid_x;
- yy = p.gridfn(gfns::gfn__global_y, irho, isigma) - centroid_y;
- zz = p.gridfn(gfns::gfn__global_z, irho, isigma) - centroid_z;
- sxx = yy * pxz - zz * pxy;
- sxy = zz * pxx - xx * pxz;
- sxz = xx * pxy - yy * pxx;
- syx = yy * pyz - zz * pyy;
- syy = zz * pxy - xx * pyz;
- syz = xx * pyy - yy * pxy;
- szx = yy * pzz - zz * pyz;
- szy = zz * pxz - xx * pzz;
- szz = xx * pyz - yy * pxz;
-
- p.gridfn(gfns::gfn__global_xx, irho, isigma) = nx * pxx + ny * pxy + nz * pxz; // p_x
- p.gridfn(gfns::gfn__global_xy, irho, isigma) = nx * pxy + ny * pyy + nz * pyz; // p_y
- p.gridfn(gfns::gfn__global_xz, irho, isigma) = nx * pxz + ny * pyz + nz * pzz; // p_z
- p.gridfn(gfns::gfn__global_yy, irho, isigma) = nx * sxx + ny * syx + nz * szx; // s_x
- p.gridfn(gfns::gfn__global_yz, irho, isigma) = nx * sxy + ny * syy + nz * szy; // s_y
- p.gridfn(gfns::gfn__global_zz, irho, isigma) = nx * sxz + ny * syz + nz * szz; // s_z
-#endif
- }
- }
- }
- }
-
- Px = surface_integral(ps,
- gfns::gfn__global_xx, true, true, false, // z,y,x direction, even or odd function
- patch::integration_method__automatic_choice);
- Py = surface_integral(ps,
- gfns::gfn__global_xy, true, false, true,
- patch::integration_method__automatic_choice);
- Pz = surface_integral(ps,
- gfns::gfn__global_xz, false, true, true,
- patch::integration_method__automatic_choice);
- Sx = surface_integral(ps,
- gfns::gfn__global_yy, false, false, true,
- patch::integration_method__automatic_choice);
- Sy = surface_integral(ps,
- gfns::gfn__global_yz, false, true, false,
- patch::integration_method__automatic_choice);
- Sz = surface_integral(ps,
- gfns::gfn__global_zz, true, false, false,
- patch::integration_method__automatic_choice);
- const double F1o8pi = 1.0 / 8 / PI;
- Px = Px * F1o8pi;
- Py = Py * F1o8pi;
- Pz = Pz * F1o8pi;
- Sx = Sx * F1o8pi;
- Sy = Sy * F1o8pi;
- Sz = Sz * F1o8pi;
- }
-
- //******************************************************************************
-
- //
- // This function computes the surface integral of a gridfn over the
- // horizon.
- //
- fp BH_diagnostics::surface_integral(const patch_system &ps,
- int src_gfn, bool src_gfn_is_even_across_xy_plane,
- bool src_gfn_is_even_across_xz_plane,
- bool src_gfn_is_even_across_yz_plane,
- enum patch::integration_method method)
- {
- return ps.integrate_gridfn(src_gfn, src_gfn_is_even_across_xy_plane,
- src_gfn_is_even_across_xz_plane,
- src_gfn_is_even_across_yz_plane,
- gfns::gfn__h,
- gfns::gfn__g_dd_11, gfns::gfn__g_dd_12, gfns::gfn__g_dd_13,
- gfns::gfn__g_dd_22, gfns::gfn__g_dd_23,
- gfns::gfn__g_dd_33,
- method);
- }
- // with triad theta and phi
- // since Thornburg uses vertex center, we will meet nan at pole points
- void BH_diagnostics::compute_signature(patch_system &ps, const double dT)
- {
- for (int pn = 0; pn < ps.N_patches(); ++pn)
- {
- patch &p = ps.ith_patch(pn);
-
- for (int irho = p.min_irho(); irho <= p.max_irho(); ++irho)
- for (int isigma = p.min_isigma(); isigma <= p.max_isigma(); ++isigma)
- {
- const fp r = p.ghosted_gridfn(gfns::gfn__h, irho, isigma);
- const fp rho = p.rho_of_irho(irho);
- const fp sigma = p.sigma_of_isigma(isigma);
- fp xx, yy, zz;
- p.xyz_of_r_rho_sigma(r, rho, sigma, xx, yy, zz);
-
- const fp sintheta = sqrt(1 - zz * zz / r / r);
-
- const fp X_ud_11 = xx * zz / r / r / sqrt(xx * xx + yy * yy);
- const fp X_ud_12 = yy * zz / r / r / sqrt(xx * xx + yy * yy);
- const fp X_ud_13 = -sqrt(xx * xx + yy * yy) / r / r;
- const fp X_ud_21 = -yy / (xx * xx + yy * yy);
- const fp X_ud_22 = xx / (xx * xx + yy * yy);
- const fp X_ud_23 = 0;
-
- const fp g_dd_11 = p.gridfn(gfns::gfn__g_dd_11, irho, isigma);
- const fp g_dd_12 = p.gridfn(gfns::gfn__g_dd_12, irho, isigma);
- const fp g_dd_13 = p.gridfn(gfns::gfn__g_dd_13, irho, isigma);
- const fp g_dd_22 = p.gridfn(gfns::gfn__g_dd_22, irho, isigma);
- const fp g_dd_23 = p.gridfn(gfns::gfn__g_dd_23, irho, isigma);
- const fp g_dd_33 = p.gridfn(gfns::gfn__g_dd_33, irho, isigma);
-
- const fp Lap = 1.0 + p.gridfn(gfns::gfn__global_xx, irho, isigma);
- const fp Sfx = p.gridfn(gfns::gfn__global_xy, irho, isigma);
- const fp Sfy = p.gridfn(gfns::gfn__global_xz, irho, isigma);
- const fp Sfz = p.gridfn(gfns::gfn__global_yy, irho, isigma);
-
- const fp dfdt = (r - p.gridfn(gfns::gfn__oldh, irho, isigma)) / dT;
-
- double Br = Sfx * xx / r + Sfy * yy / r + Sfz * zz / r;
- double Brho = Sfx * X_ud_11 + Sfy * X_ud_12 + Sfz * X_ud_13;
- double Bsigma = Sfx * X_ud_21 + Sfy * X_ud_22 + Sfz * X_ud_23;
-
- double g_uu_11, g_uu_12, g_uu_13, g_uu_22, g_uu_23, g_uu_33;
- double g11, g12, g13, g22, g23, g33;
- {
- // g^uu
- fp t1, t2, t4, t5, t7, t8, t11, t12, t14, t15;
- fp t18, t21;
- t1 = g_dd_22;
- t2 = g_dd_33;
- t4 = g_dd_23;
- t5 = t4 * t4;
- t7 = g_dd_11;
- t8 = t7 * t1;
- t11 = g_dd_12;
- t12 = t11 * t11;
- t14 = g_dd_13;
- t15 = t11 * t14;
- t18 = t14 * t14;
- t21 = 1 / (t8 * t2 - t7 * t5 - t12 * t2 + 2.0 * t15 * t4 - t18 * t1);
- g11 = (t1 * t2 - t5) * t21;
- g12 = -(t11 * t2 - t14 * t4) * t21;
- g13 = -(-t11 * t4 + t14 * t1) * t21;
- g22 = (t7 * t2 - t18) * t21;
- g23 = -(t7 * t4 - t15) * t21;
- g33 = (t8 - t12) * t21;
- }
- // 1 r;2 rho; 3 sigma
- g_uu_22 = (g11 * X_ud_11 + g12 * X_ud_12 + g13 * X_ud_13) * X_ud_11 + (g12 * X_ud_11 + g22 * X_ud_12 + g23 * X_ud_13) * X_ud_12 + (g13 * X_ud_11 + g23 * X_ud_12 + g33 * X_ud_13) * X_ud_13;
- g_uu_23 = (g11 * X_ud_11 + g12 * X_ud_12 + g13 * X_ud_13) * X_ud_21 + (g12 * X_ud_11 + g22 * X_ud_12 + g23 * X_ud_13) * X_ud_22 + (g13 * X_ud_11 + g23 * X_ud_12 + g33 * X_ud_13) * X_ud_23;
- g_uu_12 = (g11 * X_ud_11 + g12 * X_ud_12 + g13 * X_ud_13) * xx / r + (g12 * X_ud_11 + g22 * X_ud_12 + g23 * X_ud_13) * yy / r + (g13 * X_ud_11 + g23 * X_ud_12 + g33 * X_ud_13) * zz / r;
- g_uu_33 = (g11 * X_ud_21 + g12 * X_ud_22 + g13 * X_ud_23) * X_ud_21 + (g12 * X_ud_21 + g22 * X_ud_22 + g23 * X_ud_23) * X_ud_22 + (g13 * X_ud_21 + g23 * X_ud_22 + g33 * X_ud_23) * X_ud_23;
- g_uu_13 = (g11 * X_ud_21 + g12 * X_ud_22 + g13 * X_ud_23) * xx / r + (g12 * X_ud_21 + g22 * X_ud_22 + g23 * X_ud_23) * yy / r + (g13 * X_ud_21 + g23 * X_ud_22 + g33 * X_ud_23) * zz / r;
- g_uu_11 = (g11 * xx / r + g12 * yy / r + g13 * zz / r) * xx / r + (g12 * xx / r + g22 * yy / r + g23 * zz / r) * yy / r + (g13 * xx / r + g23 * yy / r + g33 * zz / r) * zz / r;
- {
- // g_uu
- fp t1, t2, t4, t5, t7, t8, t11, t12, t14, t15;
- fp t18, t21;
- t1 = g_uu_22;
- t2 = g_uu_33;
- t4 = g_uu_23;
- t5 = t4 * t4;
- t7 = g_uu_11;
- t8 = t7 * t1;
- t11 = g_uu_12;
- t12 = t11 * t11;
- t14 = g_uu_13;
- t15 = t11 * t14;
- t18 = t14 * t14;
- t21 = 1 / (t8 * t2 - t7 * t5 - t12 * t2 + 2.0 * t15 * t4 - t18 * t1);
- g11 = (t1 * t2 - t5) * t21;
- g12 = -(t11 * t2 - t14 * t4) * t21;
- g13 = -(-t11 * t4 + t14 * t1) * t21;
- g22 = (t7 * t2 - t18) * t21;
- g23 = -(t7 * t4 - t15) * t21;
- g33 = (t8 - t12) * t21;
- }
-
- double q11 = g22, q12 = g23, q13 = Br + dfdt * g12;
- double q22 = g33, q23 = Bsigma + dfdt * g13;
- double q33 = (-Lap * Lap + g11 * Br * Br + g22 * Brho * Brho + g33 * Bsigma * Bsigma +
- 2 * (g12 * Br * Brho + g13 * Br * Bsigma + g23 * Brho * Bsigma)) +
- 2 * dfdt * Br + dfdt * dfdt * g11;
- q12 = q12 / sintheta;
- q22 = q22 / sintheta / sintheta;
- q23 = q23 / sintheta;
- // we use gfns::gfn__global_zz to store determinant
- p.gridfn(gfns::gfn__global_zz, irho, isigma) = q11 * q22 * q33 + q12 * q23 * q13 + q13 * q12 * q23 - q13 * q22 * q13 - q12 * q12 * q33 - q11 * q23 * q23;
- } // end for irho isigma
- }
- }
- FILE *BH_diagnostics::setup_output_file(int N_horizons, int hn)
- const
- {
- char file_name_buffer[50];
- sprintf(file_name_buffer, "infoah%02d.dat", hn);
- const char *const file_open_mode = "w";
-
- FILE *fileptr = fopen(file_name_buffer, file_open_mode);
- if (fileptr == NULL)
- printf("\n"
- " BH_diagnostics::setup_output_file():\n"
- " can't open BH-diagnostics output file\n"
- " \"%s\"!",
- file_name_buffer);
- /*
- fprintf(fileptr, "# apparent horizon %d/%d\n", hn, N_horizons);
- fprintf(fileptr, "#\n");
- fprintf(fileptr, "# column 1 = cctk_time\n");
- fprintf(fileptr, "# column 2 = centroid_x\n");
- fprintf(fileptr, "# column 3 = centroid_y\n");
- fprintf(fileptr, "# column 4 = centroid_z\n");
- fprintf(fileptr, "# column 5 = min radius\n");
- fprintf(fileptr, "# column 6 = max radius\n");
- fprintf(fileptr, "# column 7 = mean radius\n");
- fprintf(fileptr, "# column 8 = quadrupole_xx\n");
- fprintf(fileptr, "# column 9 = quadrupole_xy\n");
- fprintf(fileptr, "# column 10 = quadrupole_xz\n");
- fprintf(fileptr, "# column 11 = quadrupole_yy\n");
- fprintf(fileptr, "# column 12 = quadrupole_yz\n");
- fprintf(fileptr, "# column 13 = quadrupole_zz\n");
- fprintf(fileptr, "# column 14 = min x\n");
- fprintf(fileptr, "# column 15 = max x\n");
- fprintf(fileptr, "# column 16 = min y\n");
- fprintf(fileptr, "# column 17 = max y\n");
- fprintf(fileptr, "# column 18 = min z\n");
- fprintf(fileptr, "# column 19 = max z\n");
- fprintf(fileptr, "# column 20 = xy-plane circumference\n");
- fprintf(fileptr, "# column 21 = xz-plane circumference\n");
- fprintf(fileptr, "# column 22 = yz-plane circumference\n");
- fprintf(fileptr, "# column 23 = ratio of xz/xy-plane circumferences\n");
- fprintf(fileptr, "# column 24 = ratio of yz/xy-plane circumferences\n");
- fprintf(fileptr, "# column 25 = area\n");
- fprintf(fileptr, "# column 26 = irreducible mass\n");
- fprintf(fileptr, "# column 27 = areal radius\n");
- */
-
- fprintf(fileptr, "#time Mass x y z Px Py Pz Sx Sy Sz\n");
- fflush(fileptr);
-
- return fileptr;
- }
- void BH_diagnostics::output(FILE *fileptr, double time)
- const
- {
- assert(fileptr != NULL);
- /*
- fprintf(fileptr,
- "%f\t%f\t%f\t%f\t%#.10g\t%#.10g\t%#.10g\t",
- double(time),
- double(centroid_x), double(centroid_y), double(centroid_z),
- double(min_radius), double(max_radius), double(mean_radius));
-
- fprintf(fileptr,
- "%#.10g\t%#.10g\t%#.10g\t%#.10g\t%#.10g\t%#.10g\t",
- double(quadrupole_xx), double(quadrupole_xy), double(quadrupole_xz),
- double(quadrupole_yy), double(quadrupole_yz),
- double(quadrupole_zz));
-
- fprintf(fileptr,
- "%#.10g\t%#.10g\t%#.10g\t%#.10g\t%#.10g\t%#.10g\t",
- double(min_x), double(max_x),
- double(min_y), double(max_y),
- double(min_z), double(max_z));
-
- fprintf(fileptr,
- "%#.10g\t%#.10g\t%#.10g\t%#.10g\t%#.10g\t",
- double(circumference_xy),
- double(circumference_xz),
- double(circumference_yz),
- double(circumference_xz / circumference_xy),
- double(circumference_yz / circumference_xy));
-
- fprintf(fileptr,
- "%#.10g\t%#.10g\t%#.10g\n",
- double(area), double(irreducible_mass), double(areal_radius));
- */
-
- fprintf(fileptr,
- "%#.10g\t%#.10g\t%#.10g\t%#.10g\t%#.10g\t%#.10g\t%#.10g\t%#.10g\t%#.10g\t%#.10g\t%#.10g\n",
- double(time), double(irreducible_mass),
- double(centroid_x), double(centroid_y), double(centroid_z),
- double(Px), double(Py), double(Pz), double(Sx), double(Sy), double(Sz));
-
- fflush(fileptr);
- }
-
-} // namespace AHFinderDirect
+#include
+#include
+#include
+
+#include "util_Table.h"
+#include "cctk.h"
+
+#include "config.h"
+#include "stdc.h"
+#include "util.h"
+#include "array.h"
+#include "cpm_map.h"
+#include "linear_map.h"
+
+#include "coords.h"
+#include "tgrid.h"
+#include "fd_grid.h"
+#include "patch.h"
+#include "patch_edge.h"
+#include "patch_interp.h"
+#include "ghost_zone.h"
+#include "patch_system.h"
+
+#include "Jacobian.h"
+
+#include "gfns.h"
+#include "gr.h"
+#include "myglobal.h"
+
+#include "horizon_sequence.h"
+#include "BH_diagnostics.h"
+#include "driver.h"
+
+namespace AHFinderDirect
+{
+ using jtutil::error_exit;
+
+ BH_diagnostics::BH_diagnostics()
+ : centroid_x(0.0), centroid_y(0.0), centroid_z(0.0),
+ quadrupole_xx(0.0), quadrupole_xy(0.0), quadrupole_xz(0.0),
+ quadrupole_yy(0.0), quadrupole_yz(0.0),
+ quadrupole_zz(0.0),
+ min_radius(0.0), max_radius(0.0),
+ mean_radius(0.0),
+ min_x(0.0), max_x(0.0),
+ min_y(0.0), max_y(0.0),
+ min_z(0.0), max_z(0.0),
+ circumference_xy(0.0), circumference_xz(0.0), circumference_yz(0.0),
+ area(0.0), irreducible_mass(0.0), areal_radius(0.0) // no comma
+ {
+ }
+
+ void BH_diagnostics::copy_to_buffer(double buffer[N_buffer])
+ const
+ {
+ buffer[posn__centroid_x] = centroid_x;
+ buffer[posn__centroid_y] = centroid_y;
+ buffer[posn__centroid_z] = centroid_z;
+
+ buffer[posn__quadrupole_xx] = quadrupole_xx;
+ buffer[posn__quadrupole_xy] = quadrupole_xy;
+ buffer[posn__quadrupole_xz] = quadrupole_xz;
+ buffer[posn__quadrupole_yy] = quadrupole_yy;
+ buffer[posn__quadrupole_xz] = quadrupole_yz;
+ buffer[posn__quadrupole_zz] = quadrupole_zz;
+
+ buffer[posn__min_radius] = min_radius;
+ buffer[posn__max_radius] = max_radius;
+ buffer[posn__mean_radius] = mean_radius;
+
+ buffer[posn__min_x] = min_x;
+ buffer[posn__max_x] = max_x;
+ buffer[posn__min_y] = min_y;
+ buffer[posn__max_y] = max_y;
+ buffer[posn__min_z] = min_z;
+ buffer[posn__max_z] = max_z;
+
+ buffer[posn__circumference_xy] = circumference_xy;
+ buffer[posn__circumference_xz] = circumference_xz;
+ buffer[posn__circumference_yz] = circumference_yz;
+
+ buffer[posn__area] = area;
+ buffer[posn__irreducible_mass] = irreducible_mass;
+ buffer[posn__areal_radius] = areal_radius;
+ }
+
+ void BH_diagnostics::copy_from_buffer(const double buffer[N_buffer])
+ {
+ centroid_x = buffer[posn__centroid_x];
+ centroid_y = buffer[posn__centroid_y];
+ centroid_z = buffer[posn__centroid_z];
+
+ quadrupole_xx = buffer[posn__quadrupole_xx];
+ quadrupole_xy = buffer[posn__quadrupole_xy];
+ quadrupole_xz = buffer[posn__quadrupole_xz];
+ quadrupole_yy = buffer[posn__quadrupole_yy];
+ quadrupole_yz = buffer[posn__quadrupole_yz];
+ quadrupole_zz = buffer[posn__quadrupole_zz];
+
+ min_radius = buffer[posn__min_radius];
+ max_radius = buffer[posn__max_radius];
+ mean_radius = buffer[posn__mean_radius];
+
+ min_x = buffer[posn__min_x];
+ max_x = buffer[posn__max_x];
+ min_y = buffer[posn__min_y];
+ max_y = buffer[posn__max_y];
+ min_z = buffer[posn__min_z];
+ max_z = buffer[posn__max_z];
+
+ circumference_xy = buffer[posn__circumference_xy];
+ circumference_xz = buffer[posn__circumference_xz];
+ circumference_yz = buffer[posn__circumference_yz];
+
+ area = buffer[posn__area];
+ irreducible_mass = buffer[posn__irreducible_mass];
+ areal_radius = buffer[posn__areal_radius];
+ }
+ void BH_diagnostics::compute(patch_system &ps)
+ {
+ jtutil::norm h_norms;
+ ps.ghosted_gridfn_norms(gfns::gfn__h, h_norms);
+ min_radius = h_norms.min_abs_value();
+ max_radius = h_norms.max_abs_value();
+
+ jtutil::norm x_norms;
+ jtutil::norm y_norms;
+ jtutil::norm z_norms;
+
+ ps.gridfn_norms(gfns::gfn__global_x, x_norms);
+ ps.gridfn_norms(gfns::gfn__global_y, y_norms);
+ ps.gridfn_norms(gfns::gfn__global_z, z_norms);
+
+ min_x = x_norms.min_value();
+ max_x = x_norms.max_value();
+ min_y = y_norms.min_value();
+ max_y = y_norms.max_value();
+ min_z = z_norms.min_value();
+ max_z = z_norms.max_value();
+
+// adjust the bounding box for the symmetries
+#define REFLECT(origin_, max_) (origin_ - (max_ - origin_))
+ switch (ps.type())
+ {
+ case patch_system::patch_system__full_sphere:
+ break;
+ case patch_system::patch_system__plus_z_hemisphere:
+ min_z = REFLECT(ps.origin_z(), max_z);
+ break;
+ case patch_system::patch_system__plus_xy_quadrant_mirrored:
+ case patch_system::patch_system__plus_xy_quadrant_rotating:
+ min_x = REFLECT(ps.origin_x(), max_x);
+ min_y = REFLECT(ps.origin_y(), max_y);
+ break;
+ case patch_system::patch_system__plus_xz_quadrant_mirrored:
+ case patch_system::patch_system__plus_xz_quadrant_rotating:
+ min_x = REFLECT(ps.origin_x(), max_x);
+ min_z = REFLECT(ps.origin_z(), max_z);
+ break;
+ case patch_system::patch_system__plus_xyz_octant_mirrored:
+ case patch_system::patch_system__plus_xyz_octant_rotating:
+ min_x = REFLECT(ps.origin_x(), max_x);
+ min_y = REFLECT(ps.origin_y(), max_y);
+ min_z = REFLECT(ps.origin_z(), max_z);
+ break;
+ default:
+ error_exit(PANIC_EXIT,
+ "***** BH_diagnostics::compute(): unknown patch system type()=(int)%d!\n"
+ " (this should never happen!)\n",
+ int(ps.type())); /*NOTREACHED*/
+ }
+
+ //
+ // surface integrals
+ //
+ const fp integral_one = surface_integral(ps,
+ gfns::gfn__one, true, true, true,
+ patch::integration_method__automatic_choice);
+ const fp integral_h = surface_integral(ps,
+ gfns::gfn__h, true, true, true,
+ patch::integration_method__automatic_choice);
+ const fp integral_x = surface_integral(ps,
+ gfns::gfn__global_x, true, true, false,
+ patch::integration_method__automatic_choice);
+ const fp integral_y = surface_integral(ps,
+ gfns::gfn__global_y, true, false, true,
+ patch::integration_method__automatic_choice);
+ const fp integral_z = surface_integral(ps,
+ gfns::gfn__global_z, false, true, true,
+ patch::integration_method__automatic_choice);
+ const fp integral_xx = surface_integral(ps,
+ gfns::gfn__global_xx, true, true, true,
+ patch::integration_method__automatic_choice);
+ const fp integral_xy = surface_integral(ps,
+ gfns::gfn__global_xy, true, false, false,
+ patch::integration_method__automatic_choice);
+ const fp integral_xz = surface_integral(ps,
+ gfns::gfn__global_xz, false, true, false,
+ patch::integration_method__automatic_choice);
+ const fp integral_yy = surface_integral(ps,
+ gfns::gfn__global_yy, true, true, true,
+ patch::integration_method__automatic_choice);
+ const fp integral_yz = surface_integral(ps,
+ gfns::gfn__global_yz, false, false, true,
+ patch::integration_method__automatic_choice);
+ const fp integral_zz = surface_integral(ps,
+ gfns::gfn__global_zz, true, true, true,
+ patch::integration_method__automatic_choice);
+
+ //
+ // centroids
+ //
+ centroid_x = integral_x / integral_one;
+ centroid_y = integral_y / integral_one;
+ centroid_z = integral_z / integral_one;
+
+ //
+ // quadrupoles (taken about centroid position)
+ //
+ quadrupole_xx = integral_xx / integral_one - centroid_x * centroid_x;
+ quadrupole_xy = integral_xy / integral_one - centroid_x * centroid_y;
+ quadrupole_xz = integral_xz / integral_one - centroid_x * centroid_z;
+ quadrupole_yy = integral_yy / integral_one - centroid_y * centroid_y;
+ quadrupole_yz = integral_yz / integral_one - centroid_y * centroid_z;
+ quadrupole_zz = integral_zz / integral_one - centroid_z * centroid_z;
+
+ //
+ // mean radius of horizon
+ //
+ mean_radius = integral_h / integral_one;
+
+ //
+ // surface area and quantities derived from it
+ //
+ area = integral_one;
+ irreducible_mass = sqrt(area / (16.0 * PI));
+ areal_radius = sqrt(area / (4.0 * PI));
+
+ //
+ // proper circumferences
+ //
+ circumference_xy = ps.circumference("xy", gfns::gfn__h,
+ gfns::gfn__g_dd_11, gfns::gfn__g_dd_12, gfns::gfn__g_dd_13,
+ gfns::gfn__g_dd_22, gfns::gfn__g_dd_23,
+ gfns::gfn__g_dd_33,
+ patch::integration_method__automatic_choice);
+ circumference_xz = ps.circumference("xz", gfns::gfn__h,
+ gfns::gfn__g_dd_11, gfns::gfn__g_dd_12, gfns::gfn__g_dd_13,
+ gfns::gfn__g_dd_22, gfns::gfn__g_dd_23,
+ gfns::gfn__g_dd_33,
+ patch::integration_method__automatic_choice);
+ circumference_yz = ps.circumference("yz", gfns::gfn__h,
+ gfns::gfn__g_dd_11, gfns::gfn__g_dd_12, gfns::gfn__g_dd_13,
+ gfns::gfn__g_dd_22, gfns::gfn__g_dd_23,
+ gfns::gfn__g_dd_33,
+ patch::integration_method__automatic_choice);
+
+ // prepare P^i,S^i in xx,xy,xz and yy,yz,zz
+ {
+ for (int pn = 0; pn < ps.N_patches(); ++pn)
+ {
+ patch &p = ps.ith_patch(pn);
+
+ for (int irho = p.min_irho(); irho <= p.max_irho(); ++irho)
+ {
+ for (int isigma = p.min_isigma();
+ isigma <= p.max_isigma();
+ ++isigma)
+ {
+ const fp g_xx = p.gridfn(gfns::gfn__g_dd_11, irho, isigma);
+ const fp g_xy = p.gridfn(gfns::gfn__g_dd_12, irho, isigma);
+ const fp g_xz = p.gridfn(gfns::gfn__g_dd_13, irho, isigma);
+ const fp g_yy = p.gridfn(gfns::gfn__g_dd_22, irho, isigma);
+ const fp g_yz = p.gridfn(gfns::gfn__g_dd_23, irho, isigma);
+ const fp g_zz = p.gridfn(gfns::gfn__g_dd_33, irho, isigma);
+
+ const fp k_xx = p.gridfn(gfns::gfn__K_dd_11, irho, isigma);
+ const fp k_xy = p.gridfn(gfns::gfn__K_dd_12, irho, isigma);
+ const fp k_xz = p.gridfn(gfns::gfn__K_dd_13, irho, isigma);
+ const fp k_yy = p.gridfn(gfns::gfn__K_dd_22, irho, isigma);
+ const fp k_yz = p.gridfn(gfns::gfn__K_dd_23, irho, isigma);
+ const fp k_zz = p.gridfn(gfns::gfn__K_dd_33, irho, isigma);
+ const fp trk = p.gridfn(gfns::gfn__trK, irho, isigma);
+
+ const fp r = p.ghosted_gridfn(gfns::gfn__h, irho, isigma);
+ const fp rho = p.rho_of_irho(irho);
+ const fp sigma = p.sigma_of_isigma(isigma);
+ fp xx, yy, zz; // local Cardesian coordinate
+ p.xyz_of_r_rho_sigma(r, rho, sigma, xx, yy, zz);
+ const fp X_ud_11 = p.partial_rho_wrt_x(xx, yy, zz);
+ const fp X_ud_12 = p.partial_rho_wrt_y(xx, yy, zz);
+ const fp X_ud_13 = p.partial_rho_wrt_z(xx, yy, zz);
+ const fp X_ud_21 = p.partial_sigma_wrt_x(xx, yy, zz);
+ const fp X_ud_22 = p.partial_sigma_wrt_y(xx, yy, zz);
+ const fp X_ud_23 = p.partial_sigma_wrt_z(xx, yy, zz);
+#if 0 // for P^i and S^i
+ // F,i = x^i/r-X_ud_1i(dh/drho)-X_ud_2i(dh/dsigma)
+ double nx,ny,nz;
+ nx = xx/r-X_ud_11*p.partial_rho(gfns::gfn__h, irho,isigma)-X_ud_21*p.partial_sigma(gfns::gfn__h, irho,isigma);
+ ny = yy/r-X_ud_12*p.partial_rho(gfns::gfn__h, irho,isigma)-X_ud_22*p.partial_sigma(gfns::gfn__h, irho,isigma);
+ nz = zz/r-X_ud_13*p.partial_rho(gfns::gfn__h, irho,isigma)-X_ud_23*p.partial_sigma(gfns::gfn__h, irho,isigma);
+ double eps; // volume element
+ fp g_uu_11, g_uu_12, g_uu_13, g_uu_22, g_uu_23, g_uu_33;
+ double pxx,pxy,pxz,pyy,pyz,pzz;
+ {
+ fp t1, t2, t4, t5, t7, t8, t11, t12, t14, t15;
+ fp t18, t21;
+ t1 = g_yy;
+ t2 = g_zz;
+ t4 = g_yz;
+ t5 = t4*t4;
+ t7 = g_xx;
+ t8 = t7*t1;
+ t11 = g_xy;
+ t12 = t11*t11;
+ t14 = g_xz;
+ t15 = t11*t14;
+ t18 = t14*t14;
+ eps = t8*t2-t7*t5-t12*t2+2.0*t15*t4-t18*t1;
+ t21 = 1/eps;
+ eps = sqrt(eps);
+ g_uu_11 = (t1*t2-t5)*t21;
+ g_uu_12 = -(t11*t2-t14*t4)*t21;
+ g_uu_13 = -(-t11*t4+t14*t1)*t21;
+ g_uu_22 = (t7*t2-t18)*t21;
+ g_uu_23 = -(t7*t4-t15)*t21;
+ g_uu_33 = (t8-t12)*t21;
+
+ t5 = g_uu_11*nx*nx+g_uu_22*ny*ny+g_uu_33*nz*nz+2*(g_uu_12*nx*ny+g_uu_13*nx*nz+g_uu_23*ny*nz);
+ t5 = sqrt(t5);
+ nx = nx/t5; // lower index
+ ny = ny/t5;
+ nz = nz/t5;
+
+ pxx= g_uu_11*(g_uu_11*k_xx+g_uu_12*k_xy+g_uu_13*k_xz)
+ +g_uu_12*(g_uu_11*k_xy+g_uu_12*k_yy+g_uu_13*k_yz)
+ +g_uu_13*(g_uu_11*k_xz+g_uu_12*k_yz+g_uu_13*k_zz); //k^xx
+ pxy= g_uu_11*(g_uu_12*k_xx+g_uu_22*k_xy+g_uu_23*k_xz)
+ +g_uu_12*(g_uu_12*k_xy+g_uu_22*k_yy+g_uu_23*k_yz)
+ +g_uu_13*(g_uu_12*k_xz+g_uu_22*k_yz+g_uu_23*k_zz); //k^xy
+ pxz= g_uu_11*(g_uu_13*k_xx+g_uu_23*k_xy+g_uu_33*k_xz)
+ +g_uu_12*(g_uu_13*k_xy+g_uu_23*k_yy+g_uu_33*k_yz)
+ +g_uu_13*(g_uu_13*k_xz+g_uu_23*k_yz+g_uu_33*k_zz); //k^xz
+ pyy= g_uu_12*(g_uu_12*k_xx+g_uu_22*k_xy+g_uu_23*k_xz)
+ +g_uu_22*(g_uu_12*k_xy+g_uu_22*k_yy+g_uu_23*k_yz)
+ +g_uu_23*(g_uu_12*k_xz+g_uu_22*k_yz+g_uu_23*k_zz); //k^yy
+ pyz= g_uu_12*(g_uu_13*k_xx+g_uu_23*k_xy+g_uu_33*k_xz)
+ +g_uu_22*(g_uu_13*k_xy+g_uu_23*k_yy+g_uu_33*k_yz)
+ +g_uu_23*(g_uu_13*k_xz+g_uu_23*k_yz+g_uu_33*k_zz); //k^yz
+ pzz= g_uu_13*(g_uu_13*k_xx+g_uu_23*k_xy+g_uu_33*k_xz)
+ +g_uu_23*(g_uu_13*k_xy+g_uu_23*k_yy+g_uu_33*k_yz)
+ +g_uu_33*(g_uu_13*k_xz+g_uu_23*k_yz+g_uu_33*k_zz); //k^zz
+ }
+
+ pxx = pxx-g_uu_11*trk; // tracefree
+ pyy = pyy-g_uu_22*trk;
+ pzz = pzz-g_uu_33*trk;
+ double tx,ty,tz;
+ double sxx,sxy,sxz,syx,syy,syz,szx,szy,szz;
+ tx = nx*pxx + ny*pxy + nz*pxz;
+ ty = nx*pxy + ny*pyy + nz*pyz;
+ tz = nx*pxz + ny*pyz + nz*pzz;
+ sxx = xx*tx;
+ sxy = xx*ty;
+ sxz = xx*tz;
+ syx = yy*tx;
+ syy = yy*ty;
+ syz = yy*tz;
+ szx = zz*tx;
+ szy = zz*ty;
+ szz = zz*tz;
+ p.gridfn(gfns::gfn__global_xx, irho,isigma) = tx; //p^x
+ p.gridfn(gfns::gfn__global_xy, irho,isigma) = ty; //p^y
+ p.gridfn(gfns::gfn__global_xz, irho,isigma) = tz; //p^z
+ tx = eps*(syz-szy); //s_x
+ ty = eps*(szx-sxz);
+ tz = eps*(sxy-syx);
+ p.gridfn(gfns::gfn__global_yy, irho,isigma) = g_uu_11*tx+g_uu_12*ty+g_uu_13*tz; //s^x
+ p.gridfn(gfns::gfn__global_yz, irho,isigma) = g_uu_12*tx+g_uu_22*ty+g_uu_23*tz; //s^y
+ p.gridfn(gfns::gfn__global_zz, irho,isigma) = g_uu_13*tx+g_uu_23*ty+g_uu_33*tz; //s^z
+#endif
+#if 1 // for P_i and S_i
+ // F,i = x^i/r-X_ud_1i(dh/drho)-X_ud_2i(dh/dsigma)
+ double nx, ny, nz;
+ nx = xx / r - X_ud_11 * p.partial_rho(gfns::gfn__h, irho, isigma) - X_ud_21 * p.partial_sigma(gfns::gfn__h, irho, isigma);
+ ny = yy / r - X_ud_12 * p.partial_rho(gfns::gfn__h, irho, isigma) - X_ud_22 * p.partial_sigma(gfns::gfn__h, irho, isigma);
+ nz = zz / r - X_ud_13 * p.partial_rho(gfns::gfn__h, irho, isigma) - X_ud_23 * p.partial_sigma(gfns::gfn__h, irho, isigma);
+ {
+ fp g_uu_11, g_uu_12, g_uu_13, g_uu_22, g_uu_23, g_uu_33;
+ fp t1, t2, t4, t5, t7, t8, t11, t12, t14, t15;
+ fp t18, t21;
+ t1 = g_yy;
+ t2 = g_zz;
+ t4 = g_yz;
+ t5 = t4 * t4;
+ t7 = g_xx;
+ t8 = t7 * t1;
+ t11 = g_xy;
+ t12 = t11 * t11;
+ t14 = g_xz;
+ t15 = t11 * t14;
+ t18 = t14 * t14;
+ t21 = 1 / (t8 * t2 - t7 * t5 - t12 * t2 + 2.0 * t15 * t4 - t18 * t1);
+ g_uu_11 = (t1 * t2 - t5) * t21;
+ g_uu_12 = -(t11 * t2 - t14 * t4) * t21;
+ g_uu_13 = -(-t11 * t4 + t14 * t1) * t21;
+ g_uu_22 = (t7 * t2 - t18) * t21;
+ g_uu_23 = -(t7 * t4 - t15) * t21;
+ g_uu_33 = (t8 - t12) * t21;
+
+ t1 = g_uu_11 * nx + g_uu_12 * ny + g_uu_13 * nz;
+ t2 = g_uu_12 * nx + g_uu_22 * ny + g_uu_23 * nz;
+ t4 = g_uu_13 * nx + g_uu_23 * ny + g_uu_33 * nz;
+ t5 = g_uu_11 * nx * nx + g_uu_22 * ny * ny + g_uu_33 * nz * nz + 2 * (g_uu_12 * nx * ny + g_uu_13 * nx * nz + g_uu_23 * ny * nz);
+ t5 = sqrt(t5);
+ nx = t1 / t5; // uper index
+ ny = t2 / t5;
+ nz = t4 / t5;
+ }
+
+ double pxx, pxy, pxz, pyy, pyz, pzz;
+ double sxx, sxy, sxz, syx, syy, syz, szx, szy, szz;
+ // these tensor components are same for local Cardisean and global Cardisean
+ pxx = k_xx - g_xx * trk; // lower index
+ pxy = k_xy;
+ pxz = k_xz;
+ pyy = k_yy - g_yy * trk;
+ pyz = k_yz;
+ pzz = k_zz - g_zz * trk;
+ /*
+ sxx = yy*pxy - zz*pxz;
+ sxy = yy*pyy - zz*pyz;
+ sxz = yy*pyz - zz*pzz;
+ syx = zz*pxy - yy*pxz;
+ syy = zz*pyy - yy*pyz;
+ syz = zz*pyz - yy*pzz;
+ szx = xx*pxy - yy*pxx;
+ szy = xx*pyy - yy*pxy;
+ szz = xx*pyz - yy*pxz;
+ */
+ // we need Cardisean coordinate whose original point coincide with centroid_x^i
+ xx = p.gridfn(gfns::gfn__global_x, irho, isigma) - centroid_x;
+ yy = p.gridfn(gfns::gfn__global_y, irho, isigma) - centroid_y;
+ zz = p.gridfn(gfns::gfn__global_z, irho, isigma) - centroid_z;
+ sxx = yy * pxz - zz * pxy;
+ sxy = zz * pxx - xx * pxz;
+ sxz = xx * pxy - yy * pxx;
+ syx = yy * pyz - zz * pyy;
+ syy = zz * pxy - xx * pyz;
+ syz = xx * pyy - yy * pxy;
+ szx = yy * pzz - zz * pyz;
+ szy = zz * pxz - xx * pzz;
+ szz = xx * pyz - yy * pxz;
+
+ p.gridfn(gfns::gfn__global_xx, irho, isigma) = nx * pxx + ny * pxy + nz * pxz; // p_x
+ p.gridfn(gfns::gfn__global_xy, irho, isigma) = nx * pxy + ny * pyy + nz * pyz; // p_y
+ p.gridfn(gfns::gfn__global_xz, irho, isigma) = nx * pxz + ny * pyz + nz * pzz; // p_z
+ p.gridfn(gfns::gfn__global_yy, irho, isigma) = nx * sxx + ny * syx + nz * szx; // s_x
+ p.gridfn(gfns::gfn__global_yz, irho, isigma) = nx * sxy + ny * syy + nz * szy; // s_y
+ p.gridfn(gfns::gfn__global_zz, irho, isigma) = nx * sxz + ny * syz + nz * szz; // s_z
+#endif
+ }
+ }
+ }
+ }
+
+ Px = surface_integral(ps,
+ gfns::gfn__global_xx, true, true, false, // z,y,x direction, even or odd function
+ patch::integration_method__automatic_choice);
+ Py = surface_integral(ps,
+ gfns::gfn__global_xy, true, false, true,
+ patch::integration_method__automatic_choice);
+ Pz = surface_integral(ps,
+ gfns::gfn__global_xz, false, true, true,
+ patch::integration_method__automatic_choice);
+ Sx = surface_integral(ps,
+ gfns::gfn__global_yy, false, false, true,
+ patch::integration_method__automatic_choice);
+ Sy = surface_integral(ps,
+ gfns::gfn__global_yz, false, true, false,
+ patch::integration_method__automatic_choice);
+ Sz = surface_integral(ps,
+ gfns::gfn__global_zz, true, false, false,
+ patch::integration_method__automatic_choice);
+ const double F1o8pi = 1.0 / 8 / PI;
+ Px = Px * F1o8pi;
+ Py = Py * F1o8pi;
+ Pz = Pz * F1o8pi;
+ Sx = Sx * F1o8pi;
+ Sy = Sy * F1o8pi;
+ Sz = Sz * F1o8pi;
+ }
+
+ //******************************************************************************
+
+ //
+ // This function computes the surface integral of a gridfn over the
+ // horizon.
+ //
+ fp BH_diagnostics::surface_integral(const patch_system &ps,
+ int src_gfn, bool src_gfn_is_even_across_xy_plane,
+ bool src_gfn_is_even_across_xz_plane,
+ bool src_gfn_is_even_across_yz_plane,
+ enum patch::integration_method method)
+ {
+ return ps.integrate_gridfn(src_gfn, src_gfn_is_even_across_xy_plane,
+ src_gfn_is_even_across_xz_plane,
+ src_gfn_is_even_across_yz_plane,
+ gfns::gfn__h,
+ gfns::gfn__g_dd_11, gfns::gfn__g_dd_12, gfns::gfn__g_dd_13,
+ gfns::gfn__g_dd_22, gfns::gfn__g_dd_23,
+ gfns::gfn__g_dd_33,
+ method);
+ }
+ // with triad theta and phi
+ // since Thornburg uses vertex center, we will meet nan at pole points
+ void BH_diagnostics::compute_signature(patch_system &ps, const double dT)
+ {
+ for (int pn = 0; pn < ps.N_patches(); ++pn)
+ {
+ patch &p = ps.ith_patch(pn);
+
+ for (int irho = p.min_irho(); irho <= p.max_irho(); ++irho)
+ for (int isigma = p.min_isigma(); isigma <= p.max_isigma(); ++isigma)
+ {
+ const fp r = p.ghosted_gridfn(gfns::gfn__h, irho, isigma);
+ const fp rho = p.rho_of_irho(irho);
+ const fp sigma = p.sigma_of_isigma(isigma);
+ fp xx, yy, zz;
+ p.xyz_of_r_rho_sigma(r, rho, sigma, xx, yy, zz);
+
+ const fp sintheta = sqrt(1 - zz * zz / r / r);
+
+ const fp X_ud_11 = xx * zz / r / r / sqrt(xx * xx + yy * yy);
+ const fp X_ud_12 = yy * zz / r / r / sqrt(xx * xx + yy * yy);
+ const fp X_ud_13 = -sqrt(xx * xx + yy * yy) / r / r;
+ const fp X_ud_21 = -yy / (xx * xx + yy * yy);
+ const fp X_ud_22 = xx / (xx * xx + yy * yy);
+ const fp X_ud_23 = 0;
+
+ const fp g_dd_11 = p.gridfn(gfns::gfn__g_dd_11, irho, isigma);
+ const fp g_dd_12 = p.gridfn(gfns::gfn__g_dd_12, irho, isigma);
+ const fp g_dd_13 = p.gridfn(gfns::gfn__g_dd_13, irho, isigma);
+ const fp g_dd_22 = p.gridfn(gfns::gfn__g_dd_22, irho, isigma);
+ const fp g_dd_23 = p.gridfn(gfns::gfn__g_dd_23, irho, isigma);
+ const fp g_dd_33 = p.gridfn(gfns::gfn__g_dd_33, irho, isigma);
+
+ const fp Lap = 1.0 + p.gridfn(gfns::gfn__global_xx, irho, isigma);
+ const fp Sfx = p.gridfn(gfns::gfn__global_xy, irho, isigma);
+ const fp Sfy = p.gridfn(gfns::gfn__global_xz, irho, isigma);
+ const fp Sfz = p.gridfn(gfns::gfn__global_yy, irho, isigma);
+
+ const fp dfdt = (r - p.gridfn(gfns::gfn__oldh, irho, isigma)) / dT;
+
+ double Br = Sfx * xx / r + Sfy * yy / r + Sfz * zz / r;
+ double Brho = Sfx * X_ud_11 + Sfy * X_ud_12 + Sfz * X_ud_13;
+ double Bsigma = Sfx * X_ud_21 + Sfy * X_ud_22 + Sfz * X_ud_23;
+
+ double g_uu_11, g_uu_12, g_uu_13, g_uu_22, g_uu_23, g_uu_33;
+ double g11, g12, g13, g22, g23, g33;
+ {
+ // g^uu
+ fp t1, t2, t4, t5, t7, t8, t11, t12, t14, t15;
+ fp t18, t21;
+ t1 = g_dd_22;
+ t2 = g_dd_33;
+ t4 = g_dd_23;
+ t5 = t4 * t4;
+ t7 = g_dd_11;
+ t8 = t7 * t1;
+ t11 = g_dd_12;
+ t12 = t11 * t11;
+ t14 = g_dd_13;
+ t15 = t11 * t14;
+ t18 = t14 * t14;
+ t21 = 1 / (t8 * t2 - t7 * t5 - t12 * t2 + 2.0 * t15 * t4 - t18 * t1);
+ g11 = (t1 * t2 - t5) * t21;
+ g12 = -(t11 * t2 - t14 * t4) * t21;
+ g13 = -(-t11 * t4 + t14 * t1) * t21;
+ g22 = (t7 * t2 - t18) * t21;
+ g23 = -(t7 * t4 - t15) * t21;
+ g33 = (t8 - t12) * t21;
+ }
+ // 1 r;2 rho; 3 sigma
+ g_uu_22 = (g11 * X_ud_11 + g12 * X_ud_12 + g13 * X_ud_13) * X_ud_11 + (g12 * X_ud_11 + g22 * X_ud_12 + g23 * X_ud_13) * X_ud_12 + (g13 * X_ud_11 + g23 * X_ud_12 + g33 * X_ud_13) * X_ud_13;
+ g_uu_23 = (g11 * X_ud_11 + g12 * X_ud_12 + g13 * X_ud_13) * X_ud_21 + (g12 * X_ud_11 + g22 * X_ud_12 + g23 * X_ud_13) * X_ud_22 + (g13 * X_ud_11 + g23 * X_ud_12 + g33 * X_ud_13) * X_ud_23;
+ g_uu_12 = (g11 * X_ud_11 + g12 * X_ud_12 + g13 * X_ud_13) * xx / r + (g12 * X_ud_11 + g22 * X_ud_12 + g23 * X_ud_13) * yy / r + (g13 * X_ud_11 + g23 * X_ud_12 + g33 * X_ud_13) * zz / r;
+ g_uu_33 = (g11 * X_ud_21 + g12 * X_ud_22 + g13 * X_ud_23) * X_ud_21 + (g12 * X_ud_21 + g22 * X_ud_22 + g23 * X_ud_23) * X_ud_22 + (g13 * X_ud_21 + g23 * X_ud_22 + g33 * X_ud_23) * X_ud_23;
+ g_uu_13 = (g11 * X_ud_21 + g12 * X_ud_22 + g13 * X_ud_23) * xx / r + (g12 * X_ud_21 + g22 * X_ud_22 + g23 * X_ud_23) * yy / r + (g13 * X_ud_21 + g23 * X_ud_22 + g33 * X_ud_23) * zz / r;
+ g_uu_11 = (g11 * xx / r + g12 * yy / r + g13 * zz / r) * xx / r + (g12 * xx / r + g22 * yy / r + g23 * zz / r) * yy / r + (g13 * xx / r + g23 * yy / r + g33 * zz / r) * zz / r;
+ {
+ // g_uu
+ fp t1, t2, t4, t5, t7, t8, t11, t12, t14, t15;
+ fp t18, t21;
+ t1 = g_uu_22;
+ t2 = g_uu_33;
+ t4 = g_uu_23;
+ t5 = t4 * t4;
+ t7 = g_uu_11;
+ t8 = t7 * t1;
+ t11 = g_uu_12;
+ t12 = t11 * t11;
+ t14 = g_uu_13;
+ t15 = t11 * t14;
+ t18 = t14 * t14;
+ t21 = 1 / (t8 * t2 - t7 * t5 - t12 * t2 + 2.0 * t15 * t4 - t18 * t1);
+ g11 = (t1 * t2 - t5) * t21;
+ g12 = -(t11 * t2 - t14 * t4) * t21;
+ g13 = -(-t11 * t4 + t14 * t1) * t21;
+ g22 = (t7 * t2 - t18) * t21;
+ g23 = -(t7 * t4 - t15) * t21;
+ g33 = (t8 - t12) * t21;
+ }
+
+ double q11 = g22, q12 = g23, q13 = Br + dfdt * g12;
+ double q22 = g33, q23 = Bsigma + dfdt * g13;
+ double q33 = (-Lap * Lap + g11 * Br * Br + g22 * Brho * Brho + g33 * Bsigma * Bsigma +
+ 2 * (g12 * Br * Brho + g13 * Br * Bsigma + g23 * Brho * Bsigma)) +
+ 2 * dfdt * Br + dfdt * dfdt * g11;
+ q12 = q12 / sintheta;
+ q22 = q22 / sintheta / sintheta;
+ q23 = q23 / sintheta;
+ // we use gfns::gfn__global_zz to store determinant
+ p.gridfn(gfns::gfn__global_zz, irho, isigma) = q11 * q22 * q33 + q12 * q23 * q13 + q13 * q12 * q23 - q13 * q22 * q13 - q12 * q12 * q33 - q11 * q23 * q23;
+ } // end for irho isigma
+ }
+ }
+ FILE *BH_diagnostics::setup_output_file(int N_horizons, int hn)
+ const
+ {
+ char file_name_buffer[50];
+ sprintf(file_name_buffer, "infoah%02d.dat", hn);
+ const char *const file_open_mode = "w";
+
+ FILE *fileptr = fopen(file_name_buffer, file_open_mode);
+ if (fileptr == NULL)
+ printf("\n"
+ " BH_diagnostics::setup_output_file():\n"
+ " can't open BH-diagnostics output file\n"
+ " \"%s\"!",
+ file_name_buffer);
+ /*
+ fprintf(fileptr, "# apparent horizon %d/%d\n", hn, N_horizons);
+ fprintf(fileptr, "#\n");
+ fprintf(fileptr, "# column 1 = cctk_time\n");
+ fprintf(fileptr, "# column 2 = centroid_x\n");
+ fprintf(fileptr, "# column 3 = centroid_y\n");
+ fprintf(fileptr, "# column 4 = centroid_z\n");
+ fprintf(fileptr, "# column 5 = min radius\n");
+ fprintf(fileptr, "# column 6 = max radius\n");
+ fprintf(fileptr, "# column 7 = mean radius\n");
+ fprintf(fileptr, "# column 8 = quadrupole_xx\n");
+ fprintf(fileptr, "# column 9 = quadrupole_xy\n");
+ fprintf(fileptr, "# column 10 = quadrupole_xz\n");
+ fprintf(fileptr, "# column 11 = quadrupole_yy\n");
+ fprintf(fileptr, "# column 12 = quadrupole_yz\n");
+ fprintf(fileptr, "# column 13 = quadrupole_zz\n");
+ fprintf(fileptr, "# column 14 = min x\n");
+ fprintf(fileptr, "# column 15 = max x\n");
+ fprintf(fileptr, "# column 16 = min y\n");
+ fprintf(fileptr, "# column 17 = max y\n");
+ fprintf(fileptr, "# column 18 = min z\n");
+ fprintf(fileptr, "# column 19 = max z\n");
+ fprintf(fileptr, "# column 20 = xy-plane circumference\n");
+ fprintf(fileptr, "# column 21 = xz-plane circumference\n");
+ fprintf(fileptr, "# column 22 = yz-plane circumference\n");
+ fprintf(fileptr, "# column 23 = ratio of xz/xy-plane circumferences\n");
+ fprintf(fileptr, "# column 24 = ratio of yz/xy-plane circumferences\n");
+ fprintf(fileptr, "# column 25 = area\n");
+ fprintf(fileptr, "# column 26 = irreducible mass\n");
+ fprintf(fileptr, "# column 27 = areal radius\n");
+ */
+
+ fprintf(fileptr, "#time Mass x y z Px Py Pz Sx Sy Sz\n");
+ fflush(fileptr);
+
+ return fileptr;
+ }
+ void BH_diagnostics::output(FILE *fileptr, double time)
+ const
+ {
+ assert(fileptr != NULL);
+ /*
+ fprintf(fileptr,
+ "%f\t%f\t%f\t%f\t%#.10g\t%#.10g\t%#.10g\t",
+ double(time),
+ double(centroid_x), double(centroid_y), double(centroid_z),
+ double(min_radius), double(max_radius), double(mean_radius));
+
+ fprintf(fileptr,
+ "%#.10g\t%#.10g\t%#.10g\t%#.10g\t%#.10g\t%#.10g\t",
+ double(quadrupole_xx), double(quadrupole_xy), double(quadrupole_xz),
+ double(quadrupole_yy), double(quadrupole_yz),
+ double(quadrupole_zz));
+
+ fprintf(fileptr,
+ "%#.10g\t%#.10g\t%#.10g\t%#.10g\t%#.10g\t%#.10g\t",
+ double(min_x), double(max_x),
+ double(min_y), double(max_y),
+ double(min_z), double(max_z));
+
+ fprintf(fileptr,
+ "%#.10g\t%#.10g\t%#.10g\t%#.10g\t%#.10g\t",
+ double(circumference_xy),
+ double(circumference_xz),
+ double(circumference_yz),
+ double(circumference_xz / circumference_xy),
+ double(circumference_yz / circumference_xy));
+
+ fprintf(fileptr,
+ "%#.10g\t%#.10g\t%#.10g\n",
+ double(area), double(irreducible_mass), double(areal_radius));
+ */
+
+ fprintf(fileptr,
+ "%#.10g\t%#.10g\t%#.10g\t%#.10g\t%#.10g\t%#.10g\t%#.10g\t%#.10g\t%#.10g\t%#.10g\t%#.10g\n",
+ double(time), double(irreducible_mass),
+ double(centroid_x), double(centroid_y), double(centroid_z),
+ double(Px), double(Py), double(Pz), double(Sx), double(Sy), double(Sz));
+
+ fflush(fileptr);
+ }
+
+} // namespace AHFinderDirect
diff --git a/AMSS_NCKU_source/BH_diagnostics.h b/AMSS_NCKU_source/AHF_Direct/BH_diagnostics.h
similarity index 95%
rename from AMSS_NCKU_source/BH_diagnostics.h
rename to AMSS_NCKU_source/AHF_Direct/BH_diagnostics.h
index d2d3cd4..eefd3ec 100644
--- a/AMSS_NCKU_source/BH_diagnostics.h
+++ b/AMSS_NCKU_source/AHF_Direct/BH_diagnostics.h
@@ -1,101 +1,101 @@
-#ifndef BH_DIAGNOSTICS_H
-#define BH_DIAGNOSTICS_H
-namespace AHFinderDirect
-{
-
- struct BH_diagnostics
- {
- public:
- // mean x,y,z
- fp centroid_x, centroid_y, centroid_z;
-
- // these are quadrupole moments about the centroid, i.e.
- // mean(xi*xj) - centroid_i*centroid_j
- fp quadrupole_xx, quadrupole_xy, quadrupole_xz,
- quadrupole_yy, quadrupole_yz,
- quadrupole_zz;
-
- // min,max,mean surface radius about local coordinate origin
- fp min_radius, max_radius, mean_radius;
-
- // xyz bounding box
- fp min_x, max_x,
- min_y, max_y,
- min_z, max_z;
-
- // proper circumference
- // (computed using induced metric along these local-coordinate planes)
- fp circumference_xy,
- circumference_xz,
- circumference_yz;
-
- // surface area (computed using induced metric)
- // and quantities derived from it
- fp area, irreducible_mass, areal_radius;
-
- double Px, Py, Pz, Sx, Sy, Sz;
-
- public:
- // position of diagnostics in buffer and number of diagnostics
- enum
- {
- posn__centroid_x = 0,
- posn__centroid_y,
- posn__centroid_z,
- posn__quadrupole_xx,
- posn__quadrupole_xy,
- posn__quadrupole_xz,
- posn__quadrupole_yy,
- posn__quadrupole_yz,
- posn__quadrupole_zz,
- posn__min_radius,
- posn__max_radius,
- posn__mean_radius,
-
- posn__min_x,
- posn__max_x,
- posn__min_y,
- posn__max_y,
- posn__min_z,
- posn__max_z,
-
- posn__circumference_xy,
- posn__circumference_xz,
- posn__circumference_yz,
-
- posn__area,
- posn__irreducible_mass,
- posn__areal_radius,
-
- N_buffer // no comma // size of buffer
- };
-
- // copy diagnostics to/from buffer
- void copy_to_buffer(double buffer[N_buffer]) const;
- void copy_from_buffer(const double buffer[N_buffer]);
-
- public:
- void compute(patch_system &ps);
-
- void compute_signature(patch_system &ps, const double dT);
-
- FILE *setup_output_file(int N_horizons, int hn)
- const;
-
- void output(FILE *fileptr, double time)
- const;
-
- BH_diagnostics();
-
- private:
- static double surface_integral(const patch_system &ps,
- int src_gfn, bool src_gfn_is_even_across_xy_plane,
- bool src_gfn_is_even_across_xz_plane,
- bool src_gfn_is_even_across_yz_plane,
- enum patch::integration_method method);
- };
-
- //******************************************************************************
-
-} // namespace AHFinderDirect
-#endif /* BH_DIAGNOSTICS_H */
+#ifndef BH_DIAGNOSTICS_H
+#define BH_DIAGNOSTICS_H
+namespace AHFinderDirect
+{
+
+ struct BH_diagnostics
+ {
+ public:
+ // mean x,y,z
+ fp centroid_x, centroid_y, centroid_z;
+
+ // these are quadrupole moments about the centroid, i.e.
+ // mean(xi*xj) - centroid_i*centroid_j
+ fp quadrupole_xx, quadrupole_xy, quadrupole_xz,
+ quadrupole_yy, quadrupole_yz,
+ quadrupole_zz;
+
+ // min,max,mean surface radius about local coordinate origin
+ fp min_radius, max_radius, mean_radius;
+
+ // xyz bounding box
+ fp min_x, max_x,
+ min_y, max_y,
+ min_z, max_z;
+
+ // proper circumference
+ // (computed using induced metric along these local-coordinate planes)
+ fp circumference_xy,
+ circumference_xz,
+ circumference_yz;
+
+ // surface area (computed using induced metric)
+ // and quantities derived from it
+ fp area, irreducible_mass, areal_radius;
+
+ double Px, Py, Pz, Sx, Sy, Sz;
+
+ public:
+ // position of diagnostics in buffer and number of diagnostics
+ enum
+ {
+ posn__centroid_x = 0,
+ posn__centroid_y,
+ posn__centroid_z,
+ posn__quadrupole_xx,
+ posn__quadrupole_xy,
+ posn__quadrupole_xz,
+ posn__quadrupole_yy,
+ posn__quadrupole_yz,
+ posn__quadrupole_zz,
+ posn__min_radius,
+ posn__max_radius,
+ posn__mean_radius,
+
+ posn__min_x,
+ posn__max_x,
+ posn__min_y,
+ posn__max_y,
+ posn__min_z,
+ posn__max_z,
+
+ posn__circumference_xy,
+ posn__circumference_xz,
+ posn__circumference_yz,
+
+ posn__area,
+ posn__irreducible_mass,
+ posn__areal_radius,
+
+ N_buffer // no comma // size of buffer
+ };
+
+ // copy diagnostics to/from buffer
+ void copy_to_buffer(double buffer[N_buffer]) const;
+ void copy_from_buffer(const double buffer[N_buffer]);
+
+ public:
+ void compute(patch_system &ps);
+
+ void compute_signature(patch_system &ps, const double dT);
+
+ FILE *setup_output_file(int N_horizons, int hn)
+ const;
+
+ void output(FILE *fileptr, double time)
+ const;
+
+ BH_diagnostics();
+
+ private:
+ static double surface_integral(const patch_system &ps,
+ int src_gfn, bool src_gfn_is_even_across_xy_plane,
+ bool src_gfn_is_even_across_xz_plane,
+ bool src_gfn_is_even_across_yz_plane,
+ enum patch::integration_method method);
+ };
+
+ //******************************************************************************
+
+} // namespace AHFinderDirect
+#endif /* BH_DIAGNOSTICS_H */
diff --git a/AMSS_NCKU_source/FFT.f90 b/AMSS_NCKU_source/AHF_Direct/FFT.f90
similarity index 95%
rename from AMSS_NCKU_source/FFT.f90
rename to AMSS_NCKU_source/AHF_Direct/FFT.f90
index 7dfe727..eb37d8c 100644
--- a/AMSS_NCKU_source/FFT.f90
+++ b/AMSS_NCKU_source/AHF_Direct/FFT.f90
@@ -1,87 +1,87 @@
-
-
-#if 0
-program checkFFT
-use dfport
-implicit none
-double precision::x
-integer,parameter::N=256
-double precision,dimension(N*2)::p
-double precision,dimension(N/2)::s
-integer::ncount,j,idum
-character(len=8)::tt
-tt=clock()
-idum=iachar(tt(8:8))-48
-p=0.0
-open(77,file='prime.dat',status='unknown')
-loop1:do ncount=1,N
- x=ran(idum)
- p(2*ncount-1)=x
- write(77,'(f15.3)')x
-enddo loop1
-close(77)
-call four1(p,N,1)
-do j=1,N/2
- s(j)=p(2*j)*p(2*j)+p(2*j-1)*p(2*j-1)
-enddo
-x=0.0
-do j=1,N/2
- x=x+s(j)
-enddo
-s=s/x
-open(77,file='power.dat',status='unknown')
-do j=1,N/2
- write(77,'(2(1x,f15.3))')dble(j-1)/dble(N),s(j)
-enddo
-close(77)
-end program checkFFT
-#endif
-
-!-------------
-! Optimized FFT using Intel oneMKL DFTI
-! Mathematical equivalence: Standard DFT definition
-! Forward (isign=1): X[k] = sum_{n=0}^{N-1} x[n] * exp(-2*pi*i*k*n/N)
-! Backward (isign=-1): X[k] = sum_{n=0}^{N-1} x[n] * exp(+2*pi*i*k*n/N)
-! Input/Output: dataa is interleaved complex array [Re(0),Im(0),Re(1),Im(1),...]
-!-------------
-SUBROUTINE four1(dataa,nn,isign)
-use MKL_DFTI
-implicit none
-INTEGER, intent(in) :: isign, nn
-DOUBLE PRECISION, dimension(2*nn), intent(inout) :: dataa
-
-type(DFTI_DESCRIPTOR), pointer :: desc
-integer :: status
-
-! Create DFTI descriptor for 1D complex-to-complex transform
-status = DftiCreateDescriptor(desc, DFTI_DOUBLE, DFTI_COMPLEX, 1, nn)
-if (status /= 0) return
-
-! Set input/output storage as interleaved complex (default)
-status = DftiSetValue(desc, DFTI_PLACEMENT, DFTI_INPLACE)
-if (status /= 0) then
- status = DftiFreeDescriptor(desc)
- return
-endif
-
-! Commit the descriptor
-status = DftiCommitDescriptor(desc)
-if (status /= 0) then
- status = DftiFreeDescriptor(desc)
- return
-endif
-
-! Execute FFT based on direction
-if (isign == 1) then
- ! Forward FFT: exp(-2*pi*i*k*n/N)
- status = DftiComputeForward(desc, dataa)
-else
- ! Backward FFT: exp(+2*pi*i*k*n/N)
- status = DftiComputeBackward(desc, dataa)
-endif
-
-! Free descriptor
-status = DftiFreeDescriptor(desc)
-
-return
-END SUBROUTINE four1
+
+
+#if 0
+program checkFFT
+use dfport
+implicit none
+double precision::x
+integer,parameter::N=256
+double precision,dimension(N*2)::p
+double precision,dimension(N/2)::s
+integer::ncount,j,idum
+character(len=8)::tt
+tt=clock()
+idum=iachar(tt(8:8))-48
+p=0.0
+open(77,file='prime.dat',status='unknown')
+loop1:do ncount=1,N
+ x=ran(idum)
+ p(2*ncount-1)=x
+ write(77,'(f15.3)')x
+enddo loop1
+close(77)
+call four1(p,N,1)
+do j=1,N/2
+ s(j)=p(2*j)*p(2*j)+p(2*j-1)*p(2*j-1)
+enddo
+x=0.0
+do j=1,N/2
+ x=x+s(j)
+enddo
+s=s/x
+open(77,file='power.dat',status='unknown')
+do j=1,N/2
+ write(77,'(2(1x,f15.3))')dble(j-1)/dble(N),s(j)
+enddo
+close(77)
+end program checkFFT
+#endif
+
+!-------------
+! Optimized FFT using Intel oneMKL DFTI
+! Mathematical equivalence: Standard DFT definition
+! Forward (isign=1): X[k] = sum_{n=0}^{N-1} x[n] * exp(-2*pi*i*k*n/N)
+! Backward (isign=-1): X[k] = sum_{n=0}^{N-1} x[n] * exp(+2*pi*i*k*n/N)
+! Input/Output: dataa is interleaved complex array [Re(0),Im(0),Re(1),Im(1),...]
+!-------------
+SUBROUTINE four1(dataa,nn,isign)
+use MKL_DFTI
+implicit none
+INTEGER, intent(in) :: isign, nn
+DOUBLE PRECISION, dimension(2*nn), intent(inout) :: dataa
+
+type(DFTI_DESCRIPTOR), pointer :: desc
+integer :: status
+
+! Create DFTI descriptor for 1D complex-to-complex transform
+status = DftiCreateDescriptor(desc, DFTI_DOUBLE, DFTI_COMPLEX, 1, nn)
+if (status /= 0) return
+
+! Set input/output storage as interleaved complex (default)
+status = DftiSetValue(desc, DFTI_PLACEMENT, DFTI_INPLACE)
+if (status /= 0) then
+ status = DftiFreeDescriptor(desc)
+ return
+endif
+
+! Commit the descriptor
+status = DftiCommitDescriptor(desc)
+if (status /= 0) then
+ status = DftiFreeDescriptor(desc)
+ return
+endif
+
+! Execute FFT based on direction
+if (isign == 1) then
+ ! Forward FFT: exp(-2*pi*i*k*n/N)
+ status = DftiComputeForward(desc, dataa)
+else
+ ! Backward FFT: exp(+2*pi*i*k*n/N)
+ status = DftiComputeBackward(desc, dataa)
+endif
+
+! Free descriptor
+status = DftiFreeDescriptor(desc)
+
+return
+END SUBROUTINE four1
diff --git a/AMSS_NCKU_source/IntPnts.C b/AMSS_NCKU_source/AHF_Direct/IntPnts.C
similarity index 96%
rename from AMSS_NCKU_source/IntPnts.C
rename to AMSS_NCKU_source/AHF_Direct/IntPnts.C
index d8739c9..aac52a8 100644
--- a/AMSS_NCKU_source/IntPnts.C
+++ b/AMSS_NCKU_source/AHF_Direct/IntPnts.C
@@ -1,97 +1,97 @@
-//$Id: IntPnts.C,v 1.1 2012/04/03 10:49:42 zjcao Exp $
-
-#include "macrodef.h"
-#ifdef With_AHF
-
-#include
-#include
-
-#include
-using namespace std;
-
-#include "myglobal.h"
-
-namespace AHFinderDirect
-{
- extern struct state state;
- int globalInterpGFL(double *X, double *Y, double *Z, int Ns,
- double *Data)
- {
- if (Ns == 0)
- return 0;
- int n;
- double *pox[3];
- for (int i = 0; i < 3; i++)
- pox[i] = new double[Ns];
- for (n = 0; n < Ns; n++)
- {
- pox[0][n] = X[n];
- pox[1][n] = Y[n];
- pox[2][n] = Z[n];
- }
-
- const int InList = 35;
-
- double *datap;
- datap = new double[Ns * InList];
- if (!(state.ADM->AH_Interp_Points(state.AHList, Ns, pox, datap, state.Symmetry)))
- return 0;
- // reform data
- for (int pnt = 0; pnt < Ns; pnt++)
- for (int ii = 0; ii < InList; ii++)
- {
- if (ii == 0 || ii == 12 || ii == 20)
- Data[pnt + ii * Ns] = datap[ii + pnt * InList] + 1;
- else if (ii == 24) // from chi-1 to psi
- Data[pnt + ii * Ns] = pow(datap[ii + pnt * InList] + 1, -0.25);
- else if (ii == 25 || ii == 26 || ii == 27) // from chi,i to psi,i
- Data[pnt + ii * Ns] = -pow(datap[24 + pnt * InList] + 1, -1.25) / 4 * datap[ii + pnt * InList];
- else
- Data[pnt + ii * Ns] = datap[ii + pnt * InList];
- }
- delete[] datap;
-
- delete[] pox[0];
- delete[] pox[1];
- delete[] pox[2];
-
- return 1;
- }
- // inerpolate lapse and shift
- int globalInterpGFLlash(double *X, double *Y, double *Z, int Ns,
- double *Data)
- {
- if (Ns == 0)
- return 0;
- int n;
- double *pox[3];
- for (int i = 0; i < 3; i++)
- pox[i] = new double[Ns];
- for (n = 0; n < Ns; n++)
- {
- pox[0][n] = X[n];
- pox[1][n] = Y[n];
- pox[2][n] = Z[n];
- }
-
- double SYM = 1.0, ANT = -1.0;
- const int InList = 4;
-
- double *datap;
- datap = new double[Ns * InList];
- state.ADM->AH_Interp_Points(state.GaugeList, Ns, pox, datap, state.Symmetry);
- // reform data
- for (int pnt = 0; pnt < Ns; pnt++)
- for (int ii = 0; ii < InList; ii++)
- Data[pnt + ii * Ns] = datap[ii + pnt * InList];
-
- delete[] datap;
- delete[] pox[0];
- delete[] pox[1];
- delete[] pox[2];
-
- return 1;
- }
-
-} // namespace AHFinderDirect
-#endif
+//$Id: IntPnts.C,v 1.1 2012/04/03 10:49:42 zjcao Exp $
+
+#include "macrodef.h"
+#ifdef With_AHF
+
+#include
+#include
+
+#include
+using namespace std;
+
+#include "myglobal.h"
+
+namespace AHFinderDirect
+{
+ extern struct state state;
+ int globalInterpGFL(double *X, double *Y, double *Z, int Ns,
+ double *Data)
+ {
+ if (Ns == 0)
+ return 0;
+ int n;
+ double *pox[3];
+ for (int i = 0; i < 3; i++)
+ pox[i] = new double[Ns];
+ for (n = 0; n < Ns; n++)
+ {
+ pox[0][n] = X[n];
+ pox[1][n] = Y[n];
+ pox[2][n] = Z[n];
+ }
+
+ const int InList = 35;
+
+ double *datap;
+ datap = new double[Ns * InList];
+ if (!(state.ADM->AH_Interp_Points(state.AHList, Ns, pox, datap, state.Symmetry)))
+ return 0;
+ // reform data
+ for (int pnt = 0; pnt < Ns; pnt++)
+ for (int ii = 0; ii < InList; ii++)
+ {
+ if (ii == 0 || ii == 12 || ii == 20)
+ Data[pnt + ii * Ns] = datap[ii + pnt * InList] + 1;
+ else if (ii == 24) // from chi-1 to psi
+ Data[pnt + ii * Ns] = pow(datap[ii + pnt * InList] + 1, -0.25);
+ else if (ii == 25 || ii == 26 || ii == 27) // from chi,i to psi,i
+ Data[pnt + ii * Ns] = -pow(datap[24 + pnt * InList] + 1, -1.25) / 4 * datap[ii + pnt * InList];
+ else
+ Data[pnt + ii * Ns] = datap[ii + pnt * InList];
+ }
+ delete[] datap;
+
+ delete[] pox[0];
+ delete[] pox[1];
+ delete[] pox[2];
+
+ return 1;
+ }
+ // inerpolate lapse and shift
+ int globalInterpGFLlash(double *X, double *Y, double *Z, int Ns,
+ double *Data)
+ {
+ if (Ns == 0)
+ return 0;
+ int n;
+ double *pox[3];
+ for (int i = 0; i < 3; i++)
+ pox[i] = new double[Ns];
+ for (n = 0; n < Ns; n++)
+ {
+ pox[0][n] = X[n];
+ pox[1][n] = Y[n];
+ pox[2][n] = Z[n];
+ }
+
+ double SYM = 1.0, ANT = -1.0;
+ const int InList = 4;
+
+ double *datap;
+ datap = new double[Ns * InList];
+ state.ADM->AH_Interp_Points(state.GaugeList, Ns, pox, datap, state.Symmetry);
+ // reform data
+ for (int pnt = 0; pnt < Ns; pnt++)
+ for (int ii = 0; ii < InList; ii++)
+ Data[pnt + ii * Ns] = datap[ii + pnt * InList];
+
+ delete[] datap;
+ delete[] pox[0];
+ delete[] pox[1];
+ delete[] pox[2];
+
+ return 1;
+ }
+
+} // namespace AHFinderDirect
+#endif
diff --git a/AMSS_NCKU_source/IntPnts0.C b/AMSS_NCKU_source/AHF_Direct/IntPnts0.C
similarity index 95%
rename from AMSS_NCKU_source/IntPnts0.C
rename to AMSS_NCKU_source/AHF_Direct/IntPnts0.C
index fb176d8..1942ba7 100644
--- a/AMSS_NCKU_source/IntPnts0.C
+++ b/AMSS_NCKU_source/AHF_Direct/IntPnts0.C
@@ -1,43 +1,43 @@
-
-#include
-#include
-#include
-#include
-
-#include
-
-#include "myglobal.h"
-
-int CCTK_VInfo(const char *thorn, const char *format, ...)
-{
- int myrank;
- MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
- if (myrank !=0) return 0;
-
- va_list ap;
- va_start (ap, format);
- fprintf (stdout, "INFO (%s): ", thorn);
- vfprintf (stdout, format, ap);
- fprintf (stdout, "\n");
- va_end (ap);
- return 0;
-}
-int CCTK_VWarn (int level,
- int line,
- const char *file,
- const char *thorn,
- const char *format,
- ...)
-{
- int myrank;
- MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
- if (myrank !=0) return 0;
-
- va_list ap;
- va_start (ap, format);
- fprintf (stdout, "WARN (%s): ", thorn);
- vfprintf (stdout, format, ap);
- fprintf (stdout, "\n");
- va_end (ap);
- return 0;
-}
+
+#include
+#include
+#include
+#include
+
+#include
+
+#include "myglobal.h"
+
+int CCTK_VInfo(const char *thorn, const char *format, ...)
+{
+ int myrank;
+ MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
+ if (myrank !=0) return 0;
+
+ va_list ap;
+ va_start (ap, format);
+ fprintf (stdout, "INFO (%s): ", thorn);
+ vfprintf (stdout, format, ap);
+ fprintf (stdout, "\n");
+ va_end (ap);
+ return 0;
+}
+int CCTK_VWarn (int level,
+ int line,
+ const char *file,
+ const char *thorn,
+ const char *format,
+ ...)
+{
+ int myrank;
+ MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
+ if (myrank !=0) return 0;
+
+ va_list ap;
+ va_start (ap, format);
+ fprintf (stdout, "WARN (%s): ", thorn);
+ vfprintf (stdout, format, ap);
+ fprintf (stdout, "\n");
+ va_end (ap);
+ return 0;
+}
diff --git a/AMSS_NCKU_source/Jacobian.C b/AMSS_NCKU_source/AHF_Direct/Jacobian.C
similarity index 95%
rename from AMSS_NCKU_source/Jacobian.C
rename to AMSS_NCKU_source/AHF_Direct/Jacobian.C
index c8de8f2..d5a859b 100644
--- a/AMSS_NCKU_source/Jacobian.C
+++ b/AMSS_NCKU_source/AHF_Direct/Jacobian.C
@@ -1,270 +1,270 @@
-#include
-#include
-#include
-#include
-#include
-
-#include "util_Table.h"
-#include "cctk.h"
-
-#include "config.h"
-#include "stdc.h"
-
-#include "util.h"
-#include "array.h"
-#include "cpm_map.h"
-#include "linear_map.h"
-
-#include "coords.h"
-#include "tgrid.h"
-#include "fd_grid.h"
-#include "patch.h"
-#include "patch_edge.h"
-#include "patch_interp.h"
-#include "ghost_zone.h"
-#include "patch_system.h"
-
-#include "Jacobian.h"
-#include "ilucg.h"
-// all the code in this file is inside this namespace
-namespace AHFinderDirect
-{
- // this represents a single element stored in the matrix for
- // sort_row_into_column_order() and sort_row_into_column_order__cmp()
- struct matrix_element
- {
- int JA;
- fp A;
- };
-
- Jacobian::Jacobian(patch_system &ps)
- : ps_(ps),
- N_rows_(ps.N_grid_points()),
- N_nonzeros_(0), current_N_rows_(0), N_nonzeros_allocated_(0),
- IA_(new integer[N_rows_ + 1]), JA_(NULL), A_(NULL),
- itemp_(NULL), rtemp_(NULL)
- {
- IO_ = 1;
- zero_matrix();
- }
-
- Jacobian::~Jacobian()
- {
- if (A_)
- delete[] A_;
- if (JA_)
- delete[] JA_;
- if (IA_)
- delete[] IA_;
- if (rtemp_)
- delete[] rtemp_;
- if (itemp_)
- delete[] itemp_;
- }
-
- double Jacobian::element(int II, int JJ)
- const
- {
- const int posn = find_element(II, JJ);
- return (posn >= 0) ? A_[posn] : 0.0;
- }
-
- void Jacobian::zero_matrix()
- {
-
- N_nonzeros_ = 0;
- current_N_rows_ = 0;
- IA_[0] = IO_;
- }
-
- void Jacobian::set_element(int II, int JJ, fp value)
- {
- const int posn = find_element(II, JJ);
- if (posn >= 0)
- then A_[posn] = value;
- else
- insert_element(II, JJ, value);
- }
-
- void Jacobian::sum_into_element(int II, int JJ, fp value)
- {
- const int posn = find_element(II, JJ);
- if (posn >= 0)
- then A_[posn] += value;
- else
- insert_element(II, JJ, value);
- }
-
- int Jacobian::find_element(int II, int JJ)
- const
- {
- if (II >= current_N_rows_)
- then return -1; // this row not defined yet
-
- const int start = IA_[II] - IO_;
- const int stop = IA_[II + 1] - IO_;
- for (int posn = start; posn < stop; ++posn)
- {
- if (JA_[posn] - IO_ == JJ)
- then return posn; // found
- }
-
- return -1; // not found
- }
-
- int Jacobian::insert_element(int II, int JJ, double value)
- {
- if (!((II == current_N_rows_ - 1) || (II == current_N_rows_)))
- {
- printf(
- "***** row_sparse_Jacobian::insert_element(II=%d, JJ=%d, value=%g):\n"
- " attempt to insert element elsewhere than {last row, last row+1}!\n"
- " N_rows_=%d current_N_rows_=%d IO_=%d\n"
- " N_nonzeros_=%d N_nonzeros_allocated_=%d\n",
- II, JJ, double(value),
- N_rows_, current_N_rows_, IO_,
- N_nonzeros_, N_nonzeros_allocated_);
- abort();
- }
-
- // start a new row if necessary
- if (II == current_N_rows_)
- then
- {
- assert(current_N_rows_ < N_rows_);
- IA_[current_N_rows_ + 1] = IA_[current_N_rows_];
- ++current_N_rows_;
- }
-
- // insert into current row
- assert(II == current_N_rows_ - 1);
- if (IA_[II + 1] - IO_ >= N_nonzeros_allocated_)
- then grow_arrays();
- const int posn = IA_[II + 1] - IO_;
- assert(posn < N_nonzeros_allocated_);
- JA_[posn] = JJ + IO_;
- A_[posn] = value;
- ++IA_[II + 1];
- ++N_nonzeros_;
-
- return posn;
- }
-
- void Jacobian::grow_arrays()
- {
- N_nonzeros_allocated_ += base_growth_amount + (N_nonzeros_allocated_ >> 1);
-
- int *const new_JA = new int[N_nonzeros_allocated_];
- double *const new_A = new double[N_nonzeros_allocated_];
- for (int posn = 0; posn < N_nonzeros_; ++posn)
- {
- new_JA[posn] = JA_[posn];
- new_A[posn] = A_[posn];
- }
- delete[] A_;
- delete[] JA_;
- JA_ = new_JA;
- A_ = new_A;
- }
-
- int compare_matrix_elements(const void *x, const void *y)
- {
- const struct matrix_element *const px = static_cast(x);
- const struct matrix_element *const py = static_cast(y);
-
- return px->JA - py->JA;
- }
-
- void Jacobian::sort_each_row_into_column_order()
- {
- // buffer must be big enough to hold the largest row
- int max_N_in_row = 0;
- {
- for (int II = 0; II < N_rows_; ++II)
- {
- max_N_in_row = max(max_N_in_row, IA_[II + 1] - IA_[II]);
- }
- }
-
- // contiguous buffer for sorting
- struct matrix_element *const buffer = new struct matrix_element[max_N_in_row];
-
- {
- for (int II = 0; II < N_rows_; ++II)
- {
- const int N_in_row = IA_[II + 1] - IA_[II];
-
- // copy this row's JA_[] and A_[] values to the buffer
- const int start = IA_[II] - IO_;
- for (int p = 0; p < N_in_row; ++p)
- {
- const int posn = start + p;
- buffer[p].JA = JA_[posn];
- buffer[p].A = A_[posn];
- }
-
- // sort the buffer
- qsort(static_cast(buffer), N_in_row, sizeof(buffer[0]),
- &compare_matrix_elements);
-
- // copy the buffer values back to this row's JA_[] and A_[]
- for (int p = 0; p < N_in_row; ++p)
- {
- const int posn = start + p;
- JA_[posn] = buffer[p].JA;
- A_[posn] = buffer[p].A;
- }
- }
- }
-
- delete[] buffer;
- }
-
- double Jacobian::solve_linear_system(int rhs_gfn, int x_gfn, bool print_msg_flag)
- {
- assert(IO_ == Fortran_index_origin);
- assert(current_N_rows_ == N_rows_);
-
- if (itemp_ == NULL)
- then
- {
- itemp_ = new int[3 * N_rows_ + 3 * N_nonzeros_ + 2];
- rtemp_ = new double[4 * N_rows_ + N_nonzeros_];
- }
-
- // initial guess = all zeros
- double *x = ps_.gridfn_data(x_gfn);
- for (int II = 0; II < N_rows_; ++II)
- {
- x[II] = 0.0;
- }
-
- const int N = N_rows_;
- const double *rhs = ps_.gridfn_data(rhs_gfn);
- const double eps = 1e-10;
- const int max_iterations = N_rows_;
- int istatus;
-
- // the actual linear solution
- f_ilucg(N,
- IA_, JA_, A_,
- rhs, x,
- itemp_, rtemp_,
- eps, max_iterations,
- istatus);
-
- if (istatus < 0)
- {
- printf(
- "***** row_sparse_Jacobian__ILUCG::solve_linear_system(rhs_gfn=%d, x_gfn=%d):\n"
- " error return from [sd]ilucg() routine!\n"
- " istatus=%d < 0 ==> bad matrix structure, eg. zero diagonal element!\n",
- rhs_gfn, x_gfn,
- int(istatus));
- abort();
- }
-
- return -1.0;
- }
-
-} // namespace AHFinderDirect
+#include
+#include
+#include
+#include
+#include
+
+#include "util_Table.h"
+#include "cctk.h"
+
+#include "config.h"
+#include "stdc.h"
+
+#include "util.h"
+#include "array.h"
+#include "cpm_map.h"
+#include "linear_map.h"
+
+#include "coords.h"
+#include "tgrid.h"
+#include "fd_grid.h"
+#include "patch.h"
+#include "patch_edge.h"
+#include "patch_interp.h"
+#include "ghost_zone.h"
+#include "patch_system.h"
+
+#include "Jacobian.h"
+#include "ilucg.h"
+// all the code in this file is inside this namespace
+namespace AHFinderDirect
+{
+ // this represents a single element stored in the matrix for
+ // sort_row_into_column_order() and sort_row_into_column_order__cmp()
+ struct matrix_element
+ {
+ int JA;
+ fp A;
+ };
+
+ Jacobian::Jacobian(patch_system &ps)
+ : ps_(ps),
+ N_rows_(ps.N_grid_points()),
+ N_nonzeros_(0), current_N_rows_(0), N_nonzeros_allocated_(0),
+ IA_(new integer[N_rows_ + 1]), JA_(NULL), A_(NULL),
+ itemp_(NULL), rtemp_(NULL)
+ {
+ IO_ = 1;
+ zero_matrix();
+ }
+
+ Jacobian::~Jacobian()
+ {
+ if (A_)
+ delete[] A_;
+ if (JA_)
+ delete[] JA_;
+ if (IA_)
+ delete[] IA_;
+ if (rtemp_)
+ delete[] rtemp_;
+ if (itemp_)
+ delete[] itemp_;
+ }
+
+ double Jacobian::element(int II, int JJ)
+ const
+ {
+ const int posn = find_element(II, JJ);
+ return (posn >= 0) ? A_[posn] : 0.0;
+ }
+
+ void Jacobian::zero_matrix()
+ {
+
+ N_nonzeros_ = 0;
+ current_N_rows_ = 0;
+ IA_[0] = IO_;
+ }
+
+ void Jacobian::set_element(int II, int JJ, fp value)
+ {
+ const int posn = find_element(II, JJ);
+ if (posn >= 0)
+ then A_[posn] = value;
+ else
+ insert_element(II, JJ, value);
+ }
+
+ void Jacobian::sum_into_element(int II, int JJ, fp value)
+ {
+ const int posn = find_element(II, JJ);
+ if (posn >= 0)
+ then A_[posn] += value;
+ else
+ insert_element(II, JJ, value);
+ }
+
+ int Jacobian::find_element(int II, int JJ)
+ const
+ {
+ if (II >= current_N_rows_)
+ then return -1; // this row not defined yet
+
+ const int start = IA_[II] - IO_;
+ const int stop = IA_[II + 1] - IO_;
+ for (int posn = start; posn < stop; ++posn)
+ {
+ if (JA_[posn] - IO_ == JJ)
+ then return posn; // found
+ }
+
+ return -1; // not found
+ }
+
+ int Jacobian::insert_element(int II, int JJ, double value)
+ {
+ if (!((II == current_N_rows_ - 1) || (II == current_N_rows_)))
+ {
+ printf(
+ "***** row_sparse_Jacobian::insert_element(II=%d, JJ=%d, value=%g):\n"
+ " attempt to insert element elsewhere than {last row, last row+1}!\n"
+ " N_rows_=%d current_N_rows_=%d IO_=%d\n"
+ " N_nonzeros_=%d N_nonzeros_allocated_=%d\n",
+ II, JJ, double(value),
+ N_rows_, current_N_rows_, IO_,
+ N_nonzeros_, N_nonzeros_allocated_);
+ abort();
+ }
+
+ // start a new row if necessary
+ if (II == current_N_rows_)
+ then
+ {
+ assert(current_N_rows_ < N_rows_);
+ IA_[current_N_rows_ + 1] = IA_[current_N_rows_];
+ ++current_N_rows_;
+ }
+
+ // insert into current row
+ assert(II == current_N_rows_ - 1);
+ if (IA_[II + 1] - IO_ >= N_nonzeros_allocated_)
+ then grow_arrays();
+ const int posn = IA_[II + 1] - IO_;
+ assert(posn < N_nonzeros_allocated_);
+ JA_[posn] = JJ + IO_;
+ A_[posn] = value;
+ ++IA_[II + 1];
+ ++N_nonzeros_;
+
+ return posn;
+ }
+
+ void Jacobian::grow_arrays()
+ {
+ N_nonzeros_allocated_ += base_growth_amount + (N_nonzeros_allocated_ >> 1);
+
+ int *const new_JA = new int[N_nonzeros_allocated_];
+ double *const new_A = new double[N_nonzeros_allocated_];
+ for (int posn = 0; posn < N_nonzeros_; ++posn)
+ {
+ new_JA[posn] = JA_[posn];
+ new_A[posn] = A_[posn];
+ }
+ delete[] A_;
+ delete[] JA_;
+ JA_ = new_JA;
+ A_ = new_A;
+ }
+
+ int compare_matrix_elements(const void *x, const void *y)
+ {
+ const struct matrix_element *const px = static_cast(x);
+ const struct matrix_element *const py = static_cast(y);
+
+ return px->JA - py->JA;
+ }
+
+ void Jacobian::sort_each_row_into_column_order()
+ {
+ // buffer must be big enough to hold the largest row
+ int max_N_in_row = 0;
+ {
+ for (int II = 0; II < N_rows_; ++II)
+ {
+ max_N_in_row = max(max_N_in_row, IA_[II + 1] - IA_[II]);
+ }
+ }
+
+ // contiguous buffer for sorting
+ struct matrix_element *const buffer = new struct matrix_element[max_N_in_row];
+
+ {
+ for (int II = 0; II < N_rows_; ++II)
+ {
+ const int N_in_row = IA_[II + 1] - IA_[II];
+
+ // copy this row's JA_[] and A_[] values to the buffer
+ const int start = IA_[II] - IO_;
+ for (int p = 0; p < N_in_row; ++p)
+ {
+ const int posn = start + p;
+ buffer[p].JA = JA_[posn];
+ buffer[p].A = A_[posn];
+ }
+
+ // sort the buffer
+ qsort(static_cast(buffer), N_in_row, sizeof(buffer[0]),
+ &compare_matrix_elements);
+
+ // copy the buffer values back to this row's JA_[] and A_[]
+ for (int p = 0; p < N_in_row; ++p)
+ {
+ const int posn = start + p;
+ JA_[posn] = buffer[p].JA;
+ A_[posn] = buffer[p].A;
+ }
+ }
+ }
+
+ delete[] buffer;
+ }
+
+ double Jacobian::solve_linear_system(int rhs_gfn, int x_gfn, bool print_msg_flag)
+ {
+ assert(IO_ == Fortran_index_origin);
+ assert(current_N_rows_ == N_rows_);
+
+ if (itemp_ == NULL)
+ then
+ {
+ itemp_ = new int[3 * N_rows_ + 3 * N_nonzeros_ + 2];
+ rtemp_ = new double[4 * N_rows_ + N_nonzeros_];
+ }
+
+ // initial guess = all zeros
+ double *x = ps_.gridfn_data(x_gfn);
+ for (int II = 0; II < N_rows_; ++II)
+ {
+ x[II] = 0.0;
+ }
+
+ const int N = N_rows_;
+ const double *rhs = ps_.gridfn_data(rhs_gfn);
+ const double eps = 1e-10;
+ const int max_iterations = N_rows_;
+ int istatus;
+
+ // the actual linear solution
+ f_ilucg(N,
+ IA_, JA_, A_,
+ rhs, x,
+ itemp_, rtemp_,
+ eps, max_iterations,
+ istatus);
+
+ if (istatus < 0)
+ {
+ printf(
+ "***** row_sparse_Jacobian__ILUCG::solve_linear_system(rhs_gfn=%d, x_gfn=%d):\n"
+ " error return from [sd]ilucg() routine!\n"
+ " istatus=%d < 0 ==> bad matrix structure, eg. zero diagonal element!\n",
+ rhs_gfn, x_gfn,
+ int(istatus));
+ abort();
+ }
+
+ return -1.0;
+ }
+
+} // namespace AHFinderDirect
diff --git a/AMSS_NCKU_source/Jacobian.h b/AMSS_NCKU_source/AHF_Direct/Jacobian.h
similarity index 95%
rename from AMSS_NCKU_source/Jacobian.h
rename to AMSS_NCKU_source/AHF_Direct/Jacobian.h
index b9c4490..44e864a 100644
--- a/AMSS_NCKU_source/Jacobian.h
+++ b/AMSS_NCKU_source/AHF_Direct/Jacobian.h
@@ -1,90 +1,90 @@
-#ifndef AHFINDERDIRECT__JACOBIAN_HH
-#define AHFINDERDIRECT__JACOBIAN_HH
-
-namespace AHFinderDirect
-{
- class Jacobian
- {
- public:
- // basic meta-info
- patch_system &my_patch_system() const { return ps_; }
- int N_rows() const { return N_rows_; }
-
- // convert (patch,irho,isigma) <--> row/column index
- int II_of_patch_irho_isigma(const patch &p, int irho, int isigma)
- const
- {
- return ps_.gpn_of_patch_irho_isigma(p, irho, isigma);
- }
- const patch &patch_irho_isigma_of_II(int II, int &irho, int &isigma)
- const
- {
- return ps_.patch_irho_isigma_of_gpn(II, irho, isigma);
- }
-
- double element(int II, int JJ) const;
-
- // is the matrix element (II,JJ) stored explicitly?
- bool is_explicitly_stored(int II, int JJ) const
- {
- return find_element(II, JJ) > 0;
- }
-
- int IO() const { return IO_; }
- enum
- {
- C_index_origin = 0,
- Fortran_index_origin = 1
- };
-
- void zero_matrix();
-
- void set_element(int II, int JJ, fp value);
-
- void sum_into_element(int II, int JJ, fp value);
-
- int find_element(int II, int JJ) const;
-
- int insert_element(int II, int JJ, fp value);
-
- void grow_arrays();
-
- enum
- {
- base_growth_amount = 1000
- };
-
- void sort_each_row_into_column_order();
-
- double solve_linear_system(int rhs_gfn, int x_gfn,
- bool print_msg_flag);
-
- public:
- Jacobian(patch_system &ps);
- ~Jacobian();
-
- protected:
- patch_system &ps_;
- int N_rows_;
-
- int IO_;
-
- int N_nonzeros_;
- int current_N_rows_;
-
- int N_nonzeros_allocated_;
-
- int *IA_;
-
- int *JA_;
-
- double *A_;
-
- int *itemp_;
- double *rtemp_;
- };
-
- //******************************************************************************
-
-} // namespace AHFinderDirect
-#endif /* AHFINDERDIRECT__JACOBIAN_HH */
+#ifndef AHFINDERDIRECT__JACOBIAN_HH
+#define AHFINDERDIRECT__JACOBIAN_HH
+
+namespace AHFinderDirect
+{
+ class Jacobian
+ {
+ public:
+ // basic meta-info
+ patch_system &my_patch_system() const { return ps_; }
+ int N_rows() const { return N_rows_; }
+
+ // convert (patch,irho,isigma) <--> row/column index
+ int II_of_patch_irho_isigma(const patch &p, int irho, int isigma)
+ const
+ {
+ return ps_.gpn_of_patch_irho_isigma(p, irho, isigma);
+ }
+ const patch &patch_irho_isigma_of_II(int II, int &irho, int &isigma)
+ const
+ {
+ return ps_.patch_irho_isigma_of_gpn(II, irho, isigma);
+ }
+
+ double element(int II, int JJ) const;
+
+ // is the matrix element (II,JJ) stored explicitly?
+ bool is_explicitly_stored(int II, int JJ) const
+ {
+ return find_element(II, JJ) > 0;
+ }
+
+ int IO() const { return IO_; }
+ enum
+ {
+ C_index_origin = 0,
+ Fortran_index_origin = 1
+ };
+
+ void zero_matrix();
+
+ void set_element(int II, int JJ, fp value);
+
+ void sum_into_element(int II, int JJ, fp value);
+
+ int find_element(int II, int JJ) const;
+
+ int insert_element(int II, int JJ, fp value);
+
+ void grow_arrays();
+
+ enum
+ {
+ base_growth_amount = 1000
+ };
+
+ void sort_each_row_into_column_order();
+
+ double solve_linear_system(int rhs_gfn, int x_gfn,
+ bool print_msg_flag);
+
+ public:
+ Jacobian(patch_system &ps);
+ ~Jacobian();
+
+ protected:
+ patch_system &ps_;
+ int N_rows_;
+
+ int IO_;
+
+ int N_nonzeros_;
+ int current_N_rows_;
+
+ int N_nonzeros_allocated_;
+
+ int *IA_;
+
+ int *JA_;
+
+ double *A_;
+
+ int *itemp_;
+ double *rtemp_;
+ };
+
+ //******************************************************************************
+
+} // namespace AHFinderDirect
+#endif /* AHFINDERDIRECT__JACOBIAN_HH */
diff --git a/AMSS_NCKU_source/Newton.C b/AMSS_NCKU_source/AHF_Direct/Newton.C
similarity index 97%
rename from AMSS_NCKU_source/Newton.C
rename to AMSS_NCKU_source/AHF_Direct/Newton.C
index 5e93014..2418ef7 100644
--- a/AMSS_NCKU_source/Newton.C
+++ b/AMSS_NCKU_source/AHF_Direct/Newton.C
@@ -1,555 +1,555 @@
-//$Id: Newton.C,v 1.1 2012/04/03 10:49:44 zjcao Exp $
-
-#include "macrodef.h"
-#ifdef With_AHF
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "util_Table.h"
-#include "cctk.h"
-
-#include "config.h"
-#include "stdc.h"
-#include "util.h"
-#include "array.h"
-#include "cpm_map.h"
-#include "linear_map.h"
-
-#include "coords.h"
-#include "tgrid.h"
-#include "fd_grid.h"
-#include "patch.h"
-#include "patch_edge.h"
-#include "patch_interp.h"
-#include "ghost_zone.h"
-#include "patch_system.h"
-
-#include "Jacobian.h"
-
-#include "gfns.h"
-#include "gr.h"
-
-#include "horizon_sequence.h"
-#include "BH_diagnostics.h"
-#include "driver.h"
-#include "myglobal.h"
-
-namespace AHFinderDirect
-{
- extern struct state state;
- using jtutil::error_exit;
-
- void recentering(patch_system &ps, double max_x, double max_y, double max_z,
- double min_x, double min_y, double min_z,
- double centroid_x, double centroid_y, double centroid_z)
- {
- fp ox = ps.origin_x();
- fp oy = ps.origin_y();
- fp oz = ps.origin_z();
-
- const fp CTR_TOLERENCE = .45;
- bool center = (abs(max_x + min_x - 2.0 * ox) < CTR_TOLERENCE * (max_x - min_x)) &&
- (abs(max_y + min_y - 2.0 * oy) < CTR_TOLERENCE * (max_y - min_y)) &&
- (abs(max_z + min_z - 2.0 * oz) < CTR_TOLERENCE * (max_z - min_z));
-
- if (!center)
- {
-
- for (int pn = 0; pn < ps.N_patches(); ++pn)
- {
- patch &p = ps.ith_patch(pn);
-
- for (int irho = p.min_irho(); irho <= p.max_irho(); ++irho)
- for (int isigma = p.min_isigma(); isigma <= p.max_isigma(); ++isigma)
- {
-
- p.ghosted_gridfn(gfns::gfn__h, irho, isigma) =
- sqrt(jtutil::pow2(p.gridfn(gfns::gfn__global_x, irho, isigma) - centroid_x) +
- jtutil::pow2(p.gridfn(gfns::gfn__global_y, irho, isigma) - centroid_y) +
- jtutil::pow2(p.gridfn(gfns::gfn__global_z, irho, isigma) - centroid_z));
- }
- }
-
- ps.recentering(centroid_x, centroid_y, centroid_z);
- }
- }
-
- namespace
- {
- bool broadcast_status(int N_procs, int N_active_procs,
- int my_proc, bool my_active_flag,
- int hn, int iteration,
- enum expansion_status expansion_status,
- fp mean_horizon_radius, fp infinity_norm,
- bool found_this_horizon, bool I_need_more_iterations,
- struct iteration_status_buffers &isb);
-
- void Newton_step(patch_system &ps,
- fp mean_horizon_radius, fp max_allowable_Delta_h_over_h);
-
- void save_oldh(patch_system &ps);
-
- int interpolate_alsh(patch_system *ps_ptr)
- {
- int status = 1;
-
-#define CAST_PTR_OR_NULL(type_, ptr_) \
- (ps_ptr == NULL) ? NULL : static_cast(ptr_)
-
- //
- // ***** interpolation points *****
- //
- const int N_interp_points = (ps_ptr == NULL) ? 0 : ps_ptr->N_grid_points();
- double *interp_coords[3] = {
- CAST_PTR_OR_NULL(double *, ps_ptr->gridfn_data(gfns::gfn__global_x)),
- CAST_PTR_OR_NULL(double *, ps_ptr->gridfn_data(gfns::gfn__global_y)),
- CAST_PTR_OR_NULL(double *, ps_ptr->gridfn_data(gfns::gfn__global_z)),
- };
-
- double *const output_arrays[] = {
- CAST_PTR_OR_NULL(double *, ps_ptr->gridfn_data(gfns::gfn__global_xx)), // Lapse-1
- CAST_PTR_OR_NULL(double *, ps_ptr->gridfn_data(gfns::gfn__global_xy)), // Sfx
- CAST_PTR_OR_NULL(double *, ps_ptr->gridfn_data(gfns::gfn__global_xz)), // Sfy
- CAST_PTR_OR_NULL(double *, ps_ptr->gridfn_data(gfns::gfn__global_yy)), // Sfz
- };
-
- const int N_output_arrays_dim = sizeof(output_arrays) / sizeof(output_arrays[0]);
- const int N_output_arrays_use = N_output_arrays_dim;
-
- double *Data, *oX, *oY, *oZ;
-
- int s;
- int Npts = 0;
- for (int ncpu = 0; ncpu < state.N_procs; ncpu++)
- {
-
- if (state.my_proc == ncpu)
- Npts = N_interp_points;
-
- MPI_Bcast(&Npts, 1, MPI_INT, ncpu, MPI_COMM_WORLD);
-
- if (Npts != 0)
- {
- Data = new double[Npts * N_output_arrays_use];
-
- oX = new double[Npts];
- oY = new double[Npts];
- oZ = new double[Npts];
- if (state.my_proc == ncpu)
- {
- memcpy(oX, interp_coords[0], Npts * sizeof(double));
- memcpy(oY, interp_coords[1], Npts * sizeof(double));
- memcpy(oZ, interp_coords[2], Npts * sizeof(double));
- }
- MPI_Bcast(oX, Npts, MPI_DOUBLE, ncpu, MPI_COMM_WORLD);
- MPI_Bcast(oY, Npts, MPI_DOUBLE, ncpu, MPI_COMM_WORLD);
- MPI_Bcast(oZ, Npts, MPI_DOUBLE, ncpu, MPI_COMM_WORLD);
-
- // each cpu calls interpolator
- s = globalInterpGFLlash(
- oX, oY, oZ, Npts,
- Data); // 1 succuss; 0 fail
-
- if (state.my_proc == ncpu)
- {
- status = s;
-
- if (status == 1)
- {
- for (int ngf = 0; ngf < N_output_arrays_use; ngf++)
- {
- memcpy(output_arrays[ngf], Data + ngf * N_interp_points,
- sizeof(double) * N_interp_points);
- }
- }
- }
-
- delete[] oX;
- delete[] oY;
- delete[] oZ;
- delete[] Data;
- }
- }
-
- return status;
- }
-
- }
-
- //******************************************************************************
- void Newton(int N_procs, int N_active_procs, int my_proc,
- horizon_sequence &hs, struct AH_data *const AH_data_array[],
- struct iteration_status_buffers &isb, int *dumpid, double *dT)
- {
- const bool my_active_flag = hs.has_genuine_horizons();
- const int N_horizons = hs.N_horizons();
-
- for (int hn = hs.init_hn();; hn = hs.next_hn()) // hn always =0 for cpu who has no patch_system
- {
- bool horizon_is_genuine = hs.is_genuine();
- const bool there_is_another_genuine_horizon = hs.is_next_genuine();
-
- struct AH_data *AH_data_ptr = horizon_is_genuine ? AH_data_array[hn] : NULL;
-
- horizon_is_genuine = horizon_is_genuine && AH_data_ptr->find_trigger && !AH_data_ptr->stop_finding;
- if (horizon_is_genuine)
- cout << "being finding horizon #" << hn << endl;
- patch_system *const ps_ptr = horizon_is_genuine ? AH_data_ptr->ps_ptr : NULL;
- Jacobian *const Jac_ptr = horizon_is_genuine ? AH_data_ptr->Jac_ptr : NULL;
- const double add_to_expansion = horizon_is_genuine ? -AH_data_ptr->surface_expansion : 0.0;
- const int max_iterations = horizon_is_genuine
- ? (AH_data_ptr->initial_find_flag ? 80 : 20)
- : INT_MAX;
-
- if (horizon_is_genuine)
- save_oldh(*ps_ptr);
-
- for (int iteration = 1;; ++iteration)
- {
- if (horizon_is_genuine && iteration == max_iterations)
- cout << "AHfinder: fail to find horizon #" << hn
- << " with Newton iteration " << iteration << " steps!!!" << endl;
- jtutil::norm Theta_norms;
-
- const enum expansion_status raw_expansion_status = expansion(ps_ptr, add_to_expansion,
- (iteration == 1), true, &Theta_norms);
-
- const bool Theta_is_ok = (raw_expansion_status == expansion_success);
- const bool norms_are_ok = horizon_is_genuine && Theta_is_ok;
-
- //
- // have we found this horizon?
- // if so, compute and output BH diagnostics
- //
- const bool found_this_horizon = norms_are_ok && (Theta_norms.infinity_norm() <= 1e-11);
-
- if (horizon_is_genuine)
- AH_data_ptr->found_flag = found_this_horizon;
-
- if (horizon_is_genuine && found_this_horizon)
- cout << "found horizon #" << hn << " with " << iteration << " steps!!!" << endl;
- //
- // see if the expansion is too big
- // (if so, we'll give up on this horizon)
- //
- const bool expansion_is_too_large = norms_are_ok && (Theta_norms.infinity_norm() > 1e10);
-
- //
- // compute the mean horizon radius, and if it's too large,
- // then pretend expansion() returned a "surface too large" error status
- //
- jtutil::norm h_norms;
- if (horizon_is_genuine)
- then ps_ptr->ghosted_gridfn_norms(gfns::gfn__h, h_norms);
- const fp mean_horizon_radius = horizon_is_genuine ? h_norms.mean()
- : 0.0;
- const bool horizon_is_too_large = (mean_horizon_radius > 1e10);
-
- const enum expansion_status effective_expansion_status = horizon_is_too_large ? expansion_failure__surface_too_large
- : raw_expansion_status;
-
- //
- // see if we need more iterations (either on this or another horizon)
- //
-
- // does *this* horizon need more iterations?
- // i.e. has this horizon's Newton iteration not yet converged?
- const bool this_horizon_needs_more_iterations = horizon_is_genuine && Theta_is_ok && !found_this_horizon && !expansion_is_too_large && !horizon_is_too_large && (iteration < max_iterations);
-
- // do I (this processor) need to do more iterations
- // on this or a following horizon?
- const bool I_need_more_iterations = this_horizon_needs_more_iterations || there_is_another_genuine_horizon;
-
- //
- // broadcast iteration status from each active processor
- // to all processors, and inclusive-or the "we need more iterations"
- // flags to see if *any* (active) processor needs more iterations
- //
- const bool any_proc_needs_more_iterations = broadcast_status(N_procs, N_active_procs,
- my_proc, my_active_flag,
- hn, iteration, effective_expansion_status,
- mean_horizon_radius,
- (norms_are_ok ? Theta_norms.infinity_norm() : 0.0),
- found_this_horizon, I_need_more_iterations,
- isb);
- // set found-this-horizon flags
- // for all active processors' non-dummy horizons
- for (int found_proc = 0; found_proc < N_active_procs; ++found_proc)
- {
- const int found_hn = isb.hn_buffer[found_proc];
- if (found_hn > 0)
- AH_data_array[found_hn]->found_flag = isb.found_horizon_buffer[found_proc];
- }
-
- //
- // prepare lapse and shift
- {
- int ff = 0, fft = 0;
- if (found_this_horizon && dumpid[hn - 1] > 0 && dT[hn - 1] > 0)
- fft = 1;
- MPI_Allreduce(&fft, &ff, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
-
- if (ff)
- {
- if ((interpolate_alsh(ps_ptr) == 0) && (state.my_proc == 0))
- cout << "interpolation of lapse and shift for AH failed." << endl;
- }
- }
-
- if (found_this_horizon)
- {
- struct BH_diagnostics &BH_diagnostics = AH_data_ptr->BH_diagnostics;
- // output data
- if (dumpid[hn - 1] > 0)
- {
- char filename[100];
- sprintf(filename, "ah%02d_%05d.dat", hn, dumpid[hn - 1]);
- if (dT[hn - 1] > 0)
- {
- // gridfunction xx,xy,xz,yy,yz,zz will be used as temp storage
- BH_diagnostics.compute_signature(*ps_ptr, dT[hn - 1]);
- ps_ptr->print_gridfn_with_xyz(gfns::gfn__global_zz, true, gfns::gfn__h, filename);
- }
- else
- ps_ptr->print_ghosted_gridfn_with_xyz(gfns::gfn__h, true, gfns::gfn__h, filename, false);
- }
-
- BH_diagnostics.compute(*ps_ptr); // gridfunction xx,xy,xz,yy,yz,zz changed
-
- if (AH_data_ptr->BH_diagnostics_fileptr == NULL)
- AH_data_ptr->BH_diagnostics_fileptr = BH_diagnostics.setup_output_file(N_horizons, hn);
- BH_diagnostics.output(AH_data_ptr->BH_diagnostics_fileptr, (*state.PhysTime));
-
- // recentering
- recentering(*ps_ptr, (AH_data_ptr->BH_diagnostics).max_x, (AH_data_ptr->BH_diagnostics).max_y, (AH_data_ptr->BH_diagnostics).max_z,
- (AH_data_ptr->BH_diagnostics).min_x, (AH_data_ptr->BH_diagnostics).min_y, (AH_data_ptr->BH_diagnostics).min_z,
- (AH_data_ptr->BH_diagnostics).centroid_x, (AH_data_ptr->BH_diagnostics).centroid_y, (AH_data_ptr->BH_diagnostics).centroid_z);
- AH_data_ptr->recentering_flag = true;
- }
-
- //
- // are all processors done with all their genuine horizons?
- // or if this is a single-processor run, are we done with this horizon?
- //
- if (!any_proc_needs_more_iterations)
- return; // *** NORMAL RETURN ***
-
- //
- // compute the Jacobian matrix
- // *** this is a synchronous operation across all processors ***
- //
-
- const enum expansion_status
- Jacobian_status = expansion_Jacobian(this_horizon_needs_more_iterations ? ps_ptr : NULL,
- this_horizon_needs_more_iterations ? Jac_ptr : NULL,
- add_to_expansion,
- (iteration == 1),
- false);
- const bool Jacobian_is_ok = (Jacobian_status == expansion_success);
-
- //
- // skip to the next horizon unless
- // this is a genuine Jacobian computation, and it went ok
- //
- if (!(this_horizon_needs_more_iterations && Jacobian_is_ok))
- break; // *** LOOP EXIT ***
-
- //
- // compute the Newton step
- //
- Jac_ptr->solve_linear_system(gfns::gfn__Theta, gfns::gfn__Delta_h, false);
-
- Newton_step(*ps_ptr, mean_horizon_radius, 0.1);
-
- // end of this Newton iteration
- }
-
- // end of this horizon
- }
-
- // we should never get to here
- assert(false);
- }
-
- //******************************************************************************
- //******************************************************************************
- //******************************************************************************
- namespace
- {
- bool broadcast_status(int N_procs, int N_active_procs,
- int my_proc, bool my_active_flag,
- int hn, int iteration,
- enum expansion_status effective_expansion_status,
- fp mean_horizon_radius, fp infinity_norm,
- bool found_this_horizon, bool I_need_more_iterations,
- struct iteration_status_buffers &isb)
- {
- assert(my_proc >= 0);
- assert(my_proc < N_procs);
-
- enum
- {
- buffer_var__hn = 0, // also encodes found_this_horizon flag
- // in sign: +=true, -=false
- buffer_var__iteration, // also encodes I_need_more_iterations flag
- // in sign: +=true, -=false
- buffer_var__expansion_status,
- buffer_var__mean_horizon_radius,
- buffer_var__Theta_infinity_norm,
- N_buffer_vars // no comma
- };
-
- //
- // allocate buffers if this is the first use
- //
- if (isb.hn_buffer == NULL)
- then
- {
- isb.hn_buffer = new int[N_active_procs];
- isb.iteration_buffer = new int[N_active_procs];
- isb.expansion_status_buffer = new enum expansion_status[N_active_procs];
- isb.mean_horizon_radius_buffer = new fp[N_active_procs];
- isb.Theta_infinity_norm_buffer = new fp[N_active_procs];
- isb.found_horizon_buffer = new bool[N_active_procs];
-
- isb.send_buffer_ptr = new jtutil::array2d(0, N_active_procs - 1,
- 0, N_buffer_vars - 1);
- isb.receive_buffer_ptr = new jtutil::array2d(0, N_active_procs - 1,
- 0, N_buffer_vars - 1);
- }
- jtutil::array2d &send_buffer = *isb.send_buffer_ptr;
- jtutil::array2d &receive_buffer = *isb.receive_buffer_ptr;
-
- //
- // pack this processor's values into the reduction buffer
- //
- jtutil::zero_C_array(send_buffer.N_array(), send_buffer.data_array());
- if (my_active_flag)
- then
- {
- assert(send_buffer.is_valid_i(my_proc));
- assert(hn >= 0); // encoding scheme assumes this
- assert(iteration > 0); // encoding scheme assumes this
- send_buffer(my_proc, buffer_var__hn) = found_this_horizon ? +hn : -hn;
- send_buffer(my_proc, buffer_var__iteration) = I_need_more_iterations ? +iteration : -iteration;
- send_buffer(my_proc, buffer_var__expansion_status) = int(effective_expansion_status);
- send_buffer(my_proc, buffer_var__mean_horizon_radius) = mean_horizon_radius;
- send_buffer(my_proc, buffer_var__Theta_infinity_norm) = infinity_norm;
- }
-
- const int reduction_status = MPI_Allreduce(static_cast(send_buffer.data_array()),
- static_cast(receive_buffer.data_array()),
- send_buffer.N_array(),
- MPI_DOUBLE_PRECISION, MPI_SUM, MPI_COMM_WORLD);
-
- // if (reduction_status < 0)
- if (reduction_status != MPI_SUCCESS)
- then CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
- "broadcast_status(): error status %d from reduction!",
- reduction_status); /*NOTREACHED*/
-
- //
- // unpack the reduction buffer back to the high-level result buffers and
- // compute the inclusive-or of the broadcast I_need_more_iterations flags
- //
- bool any_proc_needs_more_iterations = false;
- for (int proc = 0; proc < N_active_procs; ++proc)
- {
- const int hn_temp = static_cast(
- receive_buffer(proc, buffer_var__hn));
- isb.hn_buffer[proc] = jtutil::abs(hn_temp);
- isb.found_horizon_buffer[proc] = (hn_temp > 0);
-
- const int iteration_temp = static_cast(
- receive_buffer(proc, buffer_var__iteration));
- isb.iteration_buffer[proc] = jtutil::abs(iteration_temp);
- const bool proc_needs_more_iterations = (iteration_temp > 0);
- any_proc_needs_more_iterations |= proc_needs_more_iterations;
-
- isb.expansion_status_buffer[proc] = static_cast(
- static_cast(
- receive_buffer(proc, buffer_var__expansion_status)));
-
- isb.mean_horizon_radius_buffer[proc] = receive_buffer(proc, buffer_var__mean_horizon_radius);
- isb.Theta_infinity_norm_buffer[proc] = receive_buffer(proc, buffer_var__Theta_infinity_norm);
- }
-
- return any_proc_needs_more_iterations;
- }
- }
- //
- // This function takes the Newton step, scaling it down if it's too large.
- //
- // Arguments:
- // ps = The patch system containing the gridfns h and Delta_h.
- // mean_horizon_radius = ||h||_mean
- // max_allowable_Delta_h_over_h = The maximum allowable
- // ||Delta_h||_infinity / ||h||_mean
- // Any step over this is internally clamped
- // (scaled down) to this size.
- //
- namespace
- {
- void Newton_step(patch_system &ps,
- fp mean_horizon_radius, fp max_allowable_Delta_h_over_h)
- {
- //
- // compute scale factor (1 for small steps, <1 for large steps)
- //
-
- const fp max_allowable_Delta_h = max_allowable_Delta_h_over_h * mean_horizon_radius;
-
- jtutil::norm Delta_h_norms;
- ps.gridfn_norms(gfns::gfn__Delta_h, Delta_h_norms);
- const fp max_Delta_h = Delta_h_norms.infinity_norm();
-
- const fp scale = (max_Delta_h <= max_allowable_Delta_h)
- ? 1.0
- : max_allowable_Delta_h / max_Delta_h;
-
- //
- // take the Newton step (scaled if necessary)
- //
- for (int pn = 0; pn < ps.N_patches(); ++pn)
- {
- patch &p = ps.ith_patch(pn);
-
- for (int irho = p.min_irho(); irho <= p.max_irho(); ++irho)
- {
- for (int isigma = p.min_isigma();
- isigma <= p.max_isigma();
- ++isigma)
- {
- p.ghosted_gridfn(gfns::gfn__h, irho, isigma) -= scale * p.gridfn(gfns::gfn__Delta_h, irho, isigma);
- }
- }
- }
- }
- void save_oldh(patch_system &ps)
- {
- for (int pn = 0; pn < ps.N_patches(); ++pn)
- {
- patch &p = ps.ith_patch(pn);
-
- for (int irho = p.min_irho(); irho <= p.max_irho(); ++irho)
- {
- for (int isigma = p.min_isigma();
- isigma <= p.max_isigma();
- ++isigma)
- {
- p.gridfn(gfns::gfn__oldh, irho, isigma) = p.ghosted_gridfn(gfns::gfn__h, irho, isigma);
- }
- }
- }
- }
- }
-
- //******************************************************************************
-
-} // namespace AHFinderDirect
-#endif
+//$Id: Newton.C,v 1.1 2012/04/03 10:49:44 zjcao Exp $
+
+#include "macrodef.h"
+#ifdef With_AHF
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "util_Table.h"
+#include "cctk.h"
+
+#include "config.h"
+#include "stdc.h"
+#include "util.h"
+#include "array.h"
+#include "cpm_map.h"
+#include "linear_map.h"
+
+#include "coords.h"
+#include "tgrid.h"
+#include "fd_grid.h"
+#include "patch.h"
+#include "patch_edge.h"
+#include "patch_interp.h"
+#include "ghost_zone.h"
+#include "patch_system.h"
+
+#include "Jacobian.h"
+
+#include "gfns.h"
+#include "gr.h"
+
+#include "horizon_sequence.h"
+#include "BH_diagnostics.h"
+#include "driver.h"
+#include "myglobal.h"
+
+namespace AHFinderDirect
+{
+ extern struct state state;
+ using jtutil::error_exit;
+
+ void recentering(patch_system &ps, double max_x, double max_y, double max_z,
+ double min_x, double min_y, double min_z,
+ double centroid_x, double centroid_y, double centroid_z)
+ {
+ fp ox = ps.origin_x();
+ fp oy = ps.origin_y();
+ fp oz = ps.origin_z();
+
+ const fp CTR_TOLERENCE = .45;
+ bool center = (abs(max_x + min_x - 2.0 * ox) < CTR_TOLERENCE * (max_x - min_x)) &&
+ (abs(max_y + min_y - 2.0 * oy) < CTR_TOLERENCE * (max_y - min_y)) &&
+ (abs(max_z + min_z - 2.0 * oz) < CTR_TOLERENCE * (max_z - min_z));
+
+ if (!center)
+ {
+
+ for (int pn = 0; pn < ps.N_patches(); ++pn)
+ {
+ patch &p = ps.ith_patch(pn);
+
+ for (int irho = p.min_irho(); irho <= p.max_irho(); ++irho)
+ for (int isigma = p.min_isigma(); isigma <= p.max_isigma(); ++isigma)
+ {
+
+ p.ghosted_gridfn(gfns::gfn__h, irho, isigma) =
+ sqrt(jtutil::pow2(p.gridfn(gfns::gfn__global_x, irho, isigma) - centroid_x) +
+ jtutil::pow2(p.gridfn(gfns::gfn__global_y, irho, isigma) - centroid_y) +
+ jtutil::pow2(p.gridfn(gfns::gfn__global_z, irho, isigma) - centroid_z));
+ }
+ }
+
+ ps.recentering(centroid_x, centroid_y, centroid_z);
+ }
+ }
+
+ namespace
+ {
+ bool broadcast_status(int N_procs, int N_active_procs,
+ int my_proc, bool my_active_flag,
+ int hn, int iteration,
+ enum expansion_status expansion_status,
+ fp mean_horizon_radius, fp infinity_norm,
+ bool found_this_horizon, bool I_need_more_iterations,
+ struct iteration_status_buffers &isb);
+
+ void Newton_step(patch_system &ps,
+ fp mean_horizon_radius, fp max_allowable_Delta_h_over_h);
+
+ void save_oldh(patch_system &ps);
+
+ int interpolate_alsh(patch_system *ps_ptr)
+ {
+ int status = 1;
+
+#define CAST_PTR_OR_NULL(type_, ptr_) \
+ (ps_ptr == NULL) ? NULL : static_cast(ptr_)
+
+ //
+ // ***** interpolation points *****
+ //
+ const int N_interp_points = (ps_ptr == NULL) ? 0 : ps_ptr->N_grid_points();
+ double *interp_coords[3] = {
+ CAST_PTR_OR_NULL(double *, ps_ptr->gridfn_data(gfns::gfn__global_x)),
+ CAST_PTR_OR_NULL(double *, ps_ptr->gridfn_data(gfns::gfn__global_y)),
+ CAST_PTR_OR_NULL(double *, ps_ptr->gridfn_data(gfns::gfn__global_z)),
+ };
+
+ double *const output_arrays[] = {
+ CAST_PTR_OR_NULL(double *, ps_ptr->gridfn_data(gfns::gfn__global_xx)), // Lapse-1
+ CAST_PTR_OR_NULL(double *, ps_ptr->gridfn_data(gfns::gfn__global_xy)), // Sfx
+ CAST_PTR_OR_NULL(double *, ps_ptr->gridfn_data(gfns::gfn__global_xz)), // Sfy
+ CAST_PTR_OR_NULL(double *, ps_ptr->gridfn_data(gfns::gfn__global_yy)), // Sfz
+ };
+
+ const int N_output_arrays_dim = sizeof(output_arrays) / sizeof(output_arrays[0]);
+ const int N_output_arrays_use = N_output_arrays_dim;
+
+ double *Data, *oX, *oY, *oZ;
+
+ int s;
+ int Npts = 0;
+ for (int ncpu = 0; ncpu < state.N_procs; ncpu++)
+ {
+
+ if (state.my_proc == ncpu)
+ Npts = N_interp_points;
+
+ MPI_Bcast(&Npts, 1, MPI_INT, ncpu, MPI_COMM_WORLD);
+
+ if (Npts != 0)
+ {
+ Data = new double[Npts * N_output_arrays_use];
+
+ oX = new double[Npts];
+ oY = new double[Npts];
+ oZ = new double[Npts];
+ if (state.my_proc == ncpu)
+ {
+ memcpy(oX, interp_coords[0], Npts * sizeof(double));
+ memcpy(oY, interp_coords[1], Npts * sizeof(double));
+ memcpy(oZ, interp_coords[2], Npts * sizeof(double));
+ }
+ MPI_Bcast(oX, Npts, MPI_DOUBLE, ncpu, MPI_COMM_WORLD);
+ MPI_Bcast(oY, Npts, MPI_DOUBLE, ncpu, MPI_COMM_WORLD);
+ MPI_Bcast(oZ, Npts, MPI_DOUBLE, ncpu, MPI_COMM_WORLD);
+
+ // each cpu calls interpolator
+ s = globalInterpGFLlash(
+ oX, oY, oZ, Npts,
+ Data); // 1 succuss; 0 fail
+
+ if (state.my_proc == ncpu)
+ {
+ status = s;
+
+ if (status == 1)
+ {
+ for (int ngf = 0; ngf < N_output_arrays_use; ngf++)
+ {
+ memcpy(output_arrays[ngf], Data + ngf * N_interp_points,
+ sizeof(double) * N_interp_points);
+ }
+ }
+ }
+
+ delete[] oX;
+ delete[] oY;
+ delete[] oZ;
+ delete[] Data;
+ }
+ }
+
+ return status;
+ }
+
+ }
+
+ //******************************************************************************
+ void Newton(int N_procs, int N_active_procs, int my_proc,
+ horizon_sequence &hs, struct AH_data *const AH_data_array[],
+ struct iteration_status_buffers &isb, int *dumpid, double *dT)
+ {
+ const bool my_active_flag = hs.has_genuine_horizons();
+ const int N_horizons = hs.N_horizons();
+
+ for (int hn = hs.init_hn();; hn = hs.next_hn()) // hn always =0 for cpu who has no patch_system
+ {
+ bool horizon_is_genuine = hs.is_genuine();
+ const bool there_is_another_genuine_horizon = hs.is_next_genuine();
+
+ struct AH_data *AH_data_ptr = horizon_is_genuine ? AH_data_array[hn] : NULL;
+
+ horizon_is_genuine = horizon_is_genuine && AH_data_ptr->find_trigger && !AH_data_ptr->stop_finding;
+ if (horizon_is_genuine)
+ cout << "being finding horizon #" << hn << endl;
+ patch_system *const ps_ptr = horizon_is_genuine ? AH_data_ptr->ps_ptr : NULL;
+ Jacobian *const Jac_ptr = horizon_is_genuine ? AH_data_ptr->Jac_ptr : NULL;
+ const double add_to_expansion = horizon_is_genuine ? -AH_data_ptr->surface_expansion : 0.0;
+ const int max_iterations = horizon_is_genuine
+ ? (AH_data_ptr->initial_find_flag ? 80 : 20)
+ : INT_MAX;
+
+ if (horizon_is_genuine)
+ save_oldh(*ps_ptr);
+
+ for (int iteration = 1;; ++iteration)
+ {
+ if (horizon_is_genuine && iteration == max_iterations)
+ cout << "AHfinder: fail to find horizon #" << hn
+ << " with Newton iteration " << iteration << " steps!!!" << endl;
+ jtutil::norm Theta_norms;
+
+ const enum expansion_status raw_expansion_status = expansion(ps_ptr, add_to_expansion,
+ (iteration == 1), true, &Theta_norms);
+
+ const bool Theta_is_ok = (raw_expansion_status == expansion_success);
+ const bool norms_are_ok = horizon_is_genuine && Theta_is_ok;
+
+ //
+ // have we found this horizon?
+ // if so, compute and output BH diagnostics
+ //
+ const bool found_this_horizon = norms_are_ok && (Theta_norms.infinity_norm() <= 1e-11);
+
+ if (horizon_is_genuine)
+ AH_data_ptr->found_flag = found_this_horizon;
+
+ if (horizon_is_genuine && found_this_horizon)
+ cout << "found horizon #" << hn << " with " << iteration << " steps!!!" << endl;
+ //
+ // see if the expansion is too big
+ // (if so, we'll give up on this horizon)
+ //
+ const bool expansion_is_too_large = norms_are_ok && (Theta_norms.infinity_norm() > 1e10);
+
+ //
+ // compute the mean horizon radius, and if it's too large,
+ // then pretend expansion() returned a "surface too large" error status
+ //
+ jtutil::norm h_norms;
+ if (horizon_is_genuine)
+ then ps_ptr->ghosted_gridfn_norms(gfns::gfn__h, h_norms);
+ const fp mean_horizon_radius = horizon_is_genuine ? h_norms.mean()
+ : 0.0;
+ const bool horizon_is_too_large = (mean_horizon_radius > 1e10);
+
+ const enum expansion_status effective_expansion_status = horizon_is_too_large ? expansion_failure__surface_too_large
+ : raw_expansion_status;
+
+ //
+ // see if we need more iterations (either on this or another horizon)
+ //
+
+ // does *this* horizon need more iterations?
+ // i.e. has this horizon's Newton iteration not yet converged?
+ const bool this_horizon_needs_more_iterations = horizon_is_genuine && Theta_is_ok && !found_this_horizon && !expansion_is_too_large && !horizon_is_too_large && (iteration < max_iterations);
+
+ // do I (this processor) need to do more iterations
+ // on this or a following horizon?
+ const bool I_need_more_iterations = this_horizon_needs_more_iterations || there_is_another_genuine_horizon;
+
+ //
+ // broadcast iteration status from each active processor
+ // to all processors, and inclusive-or the "we need more iterations"
+ // flags to see if *any* (active) processor needs more iterations
+ //
+ const bool any_proc_needs_more_iterations = broadcast_status(N_procs, N_active_procs,
+ my_proc, my_active_flag,
+ hn, iteration, effective_expansion_status,
+ mean_horizon_radius,
+ (norms_are_ok ? Theta_norms.infinity_norm() : 0.0),
+ found_this_horizon, I_need_more_iterations,
+ isb);
+ // set found-this-horizon flags
+ // for all active processors' non-dummy horizons
+ for (int found_proc = 0; found_proc < N_active_procs; ++found_proc)
+ {
+ const int found_hn = isb.hn_buffer[found_proc];
+ if (found_hn > 0)
+ AH_data_array[found_hn]->found_flag = isb.found_horizon_buffer[found_proc];
+ }
+
+ //
+ // prepare lapse and shift
+ {
+ int ff = 0, fft = 0;
+ if (found_this_horizon && dumpid[hn - 1] > 0 && dT[hn - 1] > 0)
+ fft = 1;
+ MPI_Allreduce(&fft, &ff, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
+
+ if (ff)
+ {
+ if ((interpolate_alsh(ps_ptr) == 0) && (state.my_proc == 0))
+ cout << "interpolation of lapse and shift for AH failed." << endl;
+ }
+ }
+
+ if (found_this_horizon)
+ {
+ struct BH_diagnostics &BH_diagnostics = AH_data_ptr->BH_diagnostics;
+ // output data
+ if (dumpid[hn - 1] > 0)
+ {
+ char filename[100];
+ sprintf(filename, "ah%02d_%05d.dat", hn, dumpid[hn - 1]);
+ if (dT[hn - 1] > 0)
+ {
+ // gridfunction xx,xy,xz,yy,yz,zz will be used as temp storage
+ BH_diagnostics.compute_signature(*ps_ptr, dT[hn - 1]);
+ ps_ptr->print_gridfn_with_xyz(gfns::gfn__global_zz, true, gfns::gfn__h, filename);
+ }
+ else
+ ps_ptr->print_ghosted_gridfn_with_xyz(gfns::gfn__h, true, gfns::gfn__h, filename, false);
+ }
+
+ BH_diagnostics.compute(*ps_ptr); // gridfunction xx,xy,xz,yy,yz,zz changed
+
+ if (AH_data_ptr->BH_diagnostics_fileptr == NULL)
+ AH_data_ptr->BH_diagnostics_fileptr = BH_diagnostics.setup_output_file(N_horizons, hn);
+ BH_diagnostics.output(AH_data_ptr->BH_diagnostics_fileptr, (*state.PhysTime));
+
+ // recentering
+ recentering(*ps_ptr, (AH_data_ptr->BH_diagnostics).max_x, (AH_data_ptr->BH_diagnostics).max_y, (AH_data_ptr->BH_diagnostics).max_z,
+ (AH_data_ptr->BH_diagnostics).min_x, (AH_data_ptr->BH_diagnostics).min_y, (AH_data_ptr->BH_diagnostics).min_z,
+ (AH_data_ptr->BH_diagnostics).centroid_x, (AH_data_ptr->BH_diagnostics).centroid_y, (AH_data_ptr->BH_diagnostics).centroid_z);
+ AH_data_ptr->recentering_flag = true;
+ }
+
+ //
+ // are all processors done with all their genuine horizons?
+ // or if this is a single-processor run, are we done with this horizon?
+ //
+ if (!any_proc_needs_more_iterations)
+ return; // *** NORMAL RETURN ***
+
+ //
+ // compute the Jacobian matrix
+ // *** this is a synchronous operation across all processors ***
+ //
+
+ const enum expansion_status
+ Jacobian_status = expansion_Jacobian(this_horizon_needs_more_iterations ? ps_ptr : NULL,
+ this_horizon_needs_more_iterations ? Jac_ptr : NULL,
+ add_to_expansion,
+ (iteration == 1),
+ false);
+ const bool Jacobian_is_ok = (Jacobian_status == expansion_success);
+
+ //
+ // skip to the next horizon unless
+ // this is a genuine Jacobian computation, and it went ok
+ //
+ if (!(this_horizon_needs_more_iterations && Jacobian_is_ok))
+ break; // *** LOOP EXIT ***
+
+ //
+ // compute the Newton step
+ //
+ Jac_ptr->solve_linear_system(gfns::gfn__Theta, gfns::gfn__Delta_h, false);
+
+ Newton_step(*ps_ptr, mean_horizon_radius, 0.1);
+
+ // end of this Newton iteration
+ }
+
+ // end of this horizon
+ }
+
+ // we should never get to here
+ assert(false);
+ }
+
+ //******************************************************************************
+ //******************************************************************************
+ //******************************************************************************
+ namespace
+ {
+ bool broadcast_status(int N_procs, int N_active_procs,
+ int my_proc, bool my_active_flag,
+ int hn, int iteration,
+ enum expansion_status effective_expansion_status,
+ fp mean_horizon_radius, fp infinity_norm,
+ bool found_this_horizon, bool I_need_more_iterations,
+ struct iteration_status_buffers &isb)
+ {
+ assert(my_proc >= 0);
+ assert(my_proc < N_procs);
+
+ enum
+ {
+ buffer_var__hn = 0, // also encodes found_this_horizon flag
+ // in sign: +=true, -=false
+ buffer_var__iteration, // also encodes I_need_more_iterations flag
+ // in sign: +=true, -=false
+ buffer_var__expansion_status,
+ buffer_var__mean_horizon_radius,
+ buffer_var__Theta_infinity_norm,
+ N_buffer_vars // no comma
+ };
+
+ //
+ // allocate buffers if this is the first use
+ //
+ if (isb.hn_buffer == NULL)
+ then
+ {
+ isb.hn_buffer = new int[N_active_procs];
+ isb.iteration_buffer = new int[N_active_procs];
+ isb.expansion_status_buffer = new enum expansion_status[N_active_procs];
+ isb.mean_horizon_radius_buffer = new fp[N_active_procs];
+ isb.Theta_infinity_norm_buffer = new fp[N_active_procs];
+ isb.found_horizon_buffer = new bool[N_active_procs];
+
+ isb.send_buffer_ptr = new jtutil::array2d(0, N_active_procs - 1,
+ 0, N_buffer_vars - 1);
+ isb.receive_buffer_ptr = new jtutil::array2d(0, N_active_procs - 1,
+ 0, N_buffer_vars - 1);
+ }
+ jtutil::array2d &send_buffer = *isb.send_buffer_ptr;
+ jtutil::array2d &receive_buffer = *isb.receive_buffer_ptr;
+
+ //
+ // pack this processor's values into the reduction buffer
+ //
+ jtutil::zero_C_array(send_buffer.N_array(), send_buffer.data_array());
+ if (my_active_flag)
+ then
+ {
+ assert(send_buffer.is_valid_i(my_proc));
+ assert(hn >= 0); // encoding scheme assumes this
+ assert(iteration > 0); // encoding scheme assumes this
+ send_buffer(my_proc, buffer_var__hn) = found_this_horizon ? +hn : -hn;
+ send_buffer(my_proc, buffer_var__iteration) = I_need_more_iterations ? +iteration : -iteration;
+ send_buffer(my_proc, buffer_var__expansion_status) = int(effective_expansion_status);
+ send_buffer(my_proc, buffer_var__mean_horizon_radius) = mean_horizon_radius;
+ send_buffer(my_proc, buffer_var__Theta_infinity_norm) = infinity_norm;
+ }
+
+ const int reduction_status = MPI_Allreduce(static_cast(send_buffer.data_array()),
+ static_cast(receive_buffer.data_array()),
+ send_buffer.N_array(),
+ MPI_DOUBLE_PRECISION, MPI_SUM, MPI_COMM_WORLD);
+
+ // if (reduction_status < 0)
+ if (reduction_status != MPI_SUCCESS)
+ then CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "broadcast_status(): error status %d from reduction!",
+ reduction_status); /*NOTREACHED*/
+
+ //
+ // unpack the reduction buffer back to the high-level result buffers and
+ // compute the inclusive-or of the broadcast I_need_more_iterations flags
+ //
+ bool any_proc_needs_more_iterations = false;
+ for (int proc = 0; proc < N_active_procs; ++proc)
+ {
+ const int hn_temp = static_cast(
+ receive_buffer(proc, buffer_var__hn));
+ isb.hn_buffer[proc] = jtutil::abs(hn_temp);
+ isb.found_horizon_buffer[proc] = (hn_temp > 0);
+
+ const int iteration_temp = static_cast(
+ receive_buffer(proc, buffer_var__iteration));
+ isb.iteration_buffer[proc] = jtutil::abs(iteration_temp);
+ const bool proc_needs_more_iterations = (iteration_temp > 0);
+ any_proc_needs_more_iterations |= proc_needs_more_iterations;
+
+ isb.expansion_status_buffer[proc] = static_cast(
+ static_cast(
+ receive_buffer(proc, buffer_var__expansion_status)));
+
+ isb.mean_horizon_radius_buffer[proc] = receive_buffer(proc, buffer_var__mean_horizon_radius);
+ isb.Theta_infinity_norm_buffer[proc] = receive_buffer(proc, buffer_var__Theta_infinity_norm);
+ }
+
+ return any_proc_needs_more_iterations;
+ }
+ }
+ //
+ // This function takes the Newton step, scaling it down if it's too large.
+ //
+ // Arguments:
+ // ps = The patch system containing the gridfns h and Delta_h.
+ // mean_horizon_radius = ||h||_mean
+ // max_allowable_Delta_h_over_h = The maximum allowable
+ // ||Delta_h||_infinity / ||h||_mean
+ // Any step over this is internally clamped
+ // (scaled down) to this size.
+ //
+ namespace
+ {
+ void Newton_step(patch_system &ps,
+ fp mean_horizon_radius, fp max_allowable_Delta_h_over_h)
+ {
+ //
+ // compute scale factor (1 for small steps, <1 for large steps)
+ //
+
+ const fp max_allowable_Delta_h = max_allowable_Delta_h_over_h * mean_horizon_radius;
+
+ jtutil::norm Delta_h_norms;
+ ps.gridfn_norms(gfns::gfn__Delta_h, Delta_h_norms);
+ const fp max_Delta_h = Delta_h_norms.infinity_norm();
+
+ const fp scale = (max_Delta_h <= max_allowable_Delta_h)
+ ? 1.0
+ : max_allowable_Delta_h / max_Delta_h;
+
+ //
+ // take the Newton step (scaled if necessary)
+ //
+ for (int pn = 0; pn < ps.N_patches(); ++pn)
+ {
+ patch &p = ps.ith_patch(pn);
+
+ for (int irho = p.min_irho(); irho <= p.max_irho(); ++irho)
+ {
+ for (int isigma = p.min_isigma();
+ isigma <= p.max_isigma();
+ ++isigma)
+ {
+ p.ghosted_gridfn(gfns::gfn__h, irho, isigma) -= scale * p.gridfn(gfns::gfn__Delta_h, irho, isigma);
+ }
+ }
+ }
+ }
+ void save_oldh(patch_system &ps)
+ {
+ for (int pn = 0; pn < ps.N_patches(); ++pn)
+ {
+ patch &p = ps.ith_patch(pn);
+
+ for (int irho = p.min_irho(); irho <= p.max_irho(); ++irho)
+ {
+ for (int isigma = p.min_isigma();
+ isigma <= p.max_isigma();
+ ++isigma)
+ {
+ p.gridfn(gfns::gfn__oldh, irho, isigma) = p.ghosted_gridfn(gfns::gfn__h, irho, isigma);
+ }
+ }
+ }
+ }
+ }
+
+ //******************************************************************************
+
+} // namespace AHFinderDirect
+#endif
diff --git a/AMSS_NCKU_source/array.C b/AMSS_NCKU_source/AHF_Direct/array.C
similarity index 96%
rename from AMSS_NCKU_source/array.C
rename to AMSS_NCKU_source/AHF_Direct/array.C
index 830c2ce..7a1ee4a 100644
--- a/AMSS_NCKU_source/array.C
+++ b/AMSS_NCKU_source/AHF_Direct/array.C
@@ -1,186 +1,186 @@
-#include
-#include // NULL
-#include // size_t
-
-#include "cctk.h"
-
-#include "stdc.h"
-#include "util.h"
-#include "array.h"
-
-namespace AHFinderDirect
-{
- namespace jtutil
- {
-
- template
- array1d::array1d(int min_i_in, int max_i_in,
- T *array_in /* = NULL */,
- int stride_i_in /* = 0 */)
- : array_(array_in),
- offset_(0), // temp value, changed below
- stride_i_(stride_i_in),
- min_i_(min_i_in), max_i_(max_i_in),
- we_own_array_(array_in == NULL)
- {
- if (stride_i_ == 0)
- then stride_i_ = 1;
-
- // must use unchecked subscripting here since setup isn't done yet
- offset_ = -subscript_unchecked(min_i_); // RHS uses offset_ = 0
- assert(subscript_unchecked(min_i_) == 0);
- max_subscript_ = subscript_unchecked(max_i_);
-
- if (we_own_array_)
- then
- {
- // allocate it
- const int N_allocate = N_i();
- array_ = new T[N_allocate];
- }
-
- // explicitly initialize array (new[] *doesn't* do this automagically)
- for (int i = min_i(); i <= max_i(); ++i)
- {
- operator()(i) = T(0);
- }
- }
-
- //
- // This function destroys an array1d object.
- //
- template
- array1d::~array1d()
- {
- if (we_own_array_)
- then delete[] array_;
- }
-
- //
- // This function constructs an array2d object.
- //
- template
- array2d::array2d(int min_i_in, int max_i_in,
- int min_j_in, int max_j_in,
- T *array_in /* = NULL */,
- int stride_i_in /* = 0 */, int stride_j_in /* = 0 */)
- : array_(array_in),
- offset_(0), // temp value, changed below
- stride_i_(stride_i_in), stride_j_(stride_j_in),
- min_i_(min_i_in), max_i_(max_i_in),
- min_j_(min_j_in), max_j_(max_j_in),
- we_own_array_(array_in == NULL)
- {
- if (stride_j_ == 0)
- then stride_j_ = 1;
- if (stride_i_ == 0)
- then stride_i_ = N_j();
-
- // must use unchecked subscripting here since setup isn't done yet
- offset_ = -subscript_unchecked(min_i_, min_j_); // RHS uses offset_ = 0
- assert(subscript_unchecked(min_i_, min_j_) == 0);
- max_subscript_ = subscript_unchecked(max_i_, max_j_);
-
- if (we_own_array_)
- then
- {
- // allocate it
- const int N_allocate = N_i() * N_j();
- array_ = new T[N_allocate];
- }
-
- // explicitly initialize array (new[] *doesn't* do this automagically)
- for (int i = min_i(); i <= max_i(); ++i)
- {
- for (int j = min_j(); j <= max_j(); ++j)
- {
- operator()(i, j) = T(0);
- }
- }
- }
-
- //
- // This function destroys an array2d object.
- //
- template
- array2d::~array2d()
- {
- if (we_own_array_)
- then delete[] array_;
- }
-
- //
- // This function constructs an array3d object.
- //
- template
- array3d::array3d(int min_i_in, int max_i_in,
- int min_j_in, int max_j_in,
- int min_k_in, int max_k_in,
- T *array_in /* = NULL */,
- int stride_i_in /* = 0 */, int stride_j_in /* = 0 */,
- int stride_k_in /* = 0 */)
- : array_(array_in),
- offset_(0), // temp value, changed below
- stride_i_(stride_i_in), stride_j_(stride_j_in),
- stride_k_(stride_k_in),
- min_i_(min_i_in), max_i_(max_i_in),
- min_j_(min_j_in), max_j_(max_j_in),
- min_k_(min_k_in), max_k_(max_k_in),
- we_own_array_(array_in == NULL)
- {
- if (stride_k_ == 0)
- then stride_k_ = 1;
- if (stride_j_ == 0)
- then stride_j_ = N_k();
- if (stride_i_ == 0)
- then stride_i_ = N_j() * N_k();
-
- // must use unchecked subscripting here since setup isn't done yet
- offset_ = -subscript_unchecked(min_i_, min_j_, min_k_); // RHS uses offset_ = 0
- assert(subscript_unchecked(min_i_, min_j_, min_k_) == 0);
- max_subscript_ = subscript_unchecked(max_i_, max_j_, max_k_);
-
- if (we_own_array_)
- then
- {
- // allocate it
- const int N_allocate = N_i() * N_j() * N_k();
- array_ = new T[N_allocate];
- }
-
- // explicitly initialize array (new[] *doesn't* do this automagically)
- for (int i = min_i(); i <= max_i(); ++i)
- {
- for (int j = min_j(); j <= max_j(); ++j)
- {
- for (int k = min_k(); k <= max_k(); ++k)
- {
- operator()(i, j, k) = T(0);
- }
- }
- }
- }
- //
- // This function destroys an array3d object.
- //
- template
- array3d::~array3d()
- {
- if (we_own_array_)
- then delete[] array_;
- }
-
- template class array1d;
-
- // FIXME: we shouldn't have to instantiate these both, the const one
- // is actually trivially derivable from the non-const one. :(
- template class array1d;
- template class array1d;
-
- template class array1d;
- template class array2d;
- template class array2d;
- template class array3d;
-
- } // namespace jtutil
-} // namespace AHFinderDirect
+#include
+#include // NULL
+#include // size_t
+
+#include "cctk.h"
+
+#include "stdc.h"
+#include "util.h"
+#include "array.h"
+
+namespace AHFinderDirect
+{
+ namespace jtutil
+ {
+
+ template
+ array1d::array1d(int min_i_in, int max_i_in,
+ T *array_in /* = NULL */,
+ int stride_i_in /* = 0 */)
+ : array_(array_in),
+ offset_(0), // temp value, changed below
+ stride_i_(stride_i_in),
+ min_i_(min_i_in), max_i_(max_i_in),
+ we_own_array_(array_in == NULL)
+ {
+ if (stride_i_ == 0)
+ then stride_i_ = 1;
+
+ // must use unchecked subscripting here since setup isn't done yet
+ offset_ = -subscript_unchecked(min_i_); // RHS uses offset_ = 0
+ assert(subscript_unchecked(min_i_) == 0);
+ max_subscript_ = subscript_unchecked(max_i_);
+
+ if (we_own_array_)
+ then
+ {
+ // allocate it
+ const int N_allocate = N_i();
+ array_ = new T[N_allocate];
+ }
+
+ // explicitly initialize array (new[] *doesn't* do this automagically)
+ for (int i = min_i(); i <= max_i(); ++i)
+ {
+ operator()(i) = T(0);
+ }
+ }
+
+ //
+ // This function destroys an array1d object.
+ //
+ template
+ array1d::~array1d()
+ {
+ if (we_own_array_)
+ then delete[] array_;
+ }
+
+ //
+ // This function constructs an array2d object.
+ //
+ template
+ array2d::array2d(int min_i_in, int max_i_in,
+ int min_j_in, int max_j_in,
+ T *array_in /* = NULL */,
+ int stride_i_in /* = 0 */, int stride_j_in /* = 0 */)
+ : array_(array_in),
+ offset_(0), // temp value, changed below
+ stride_i_(stride_i_in), stride_j_(stride_j_in),
+ min_i_(min_i_in), max_i_(max_i_in),
+ min_j_(min_j_in), max_j_(max_j_in),
+ we_own_array_(array_in == NULL)
+ {
+ if (stride_j_ == 0)
+ then stride_j_ = 1;
+ if (stride_i_ == 0)
+ then stride_i_ = N_j();
+
+ // must use unchecked subscripting here since setup isn't done yet
+ offset_ = -subscript_unchecked(min_i_, min_j_); // RHS uses offset_ = 0
+ assert(subscript_unchecked(min_i_, min_j_) == 0);
+ max_subscript_ = subscript_unchecked(max_i_, max_j_);
+
+ if (we_own_array_)
+ then
+ {
+ // allocate it
+ const int N_allocate = N_i() * N_j();
+ array_ = new T[N_allocate];
+ }
+
+ // explicitly initialize array (new[] *doesn't* do this automagically)
+ for (int i = min_i(); i <= max_i(); ++i)
+ {
+ for (int j = min_j(); j <= max_j(); ++j)
+ {
+ operator()(i, j) = T(0);
+ }
+ }
+ }
+
+ //
+ // This function destroys an array2d object.
+ //
+ template
+ array2d::~array2d()
+ {
+ if (we_own_array_)
+ then delete[] array_;
+ }
+
+ //
+ // This function constructs an array3d object.
+ //
+ template
+ array3d::array3d(int min_i_in, int max_i_in,
+ int min_j_in, int max_j_in,
+ int min_k_in, int max_k_in,
+ T *array_in /* = NULL */,
+ int stride_i_in /* = 0 */, int stride_j_in /* = 0 */,
+ int stride_k_in /* = 0 */)
+ : array_(array_in),
+ offset_(0), // temp value, changed below
+ stride_i_(stride_i_in), stride_j_(stride_j_in),
+ stride_k_(stride_k_in),
+ min_i_(min_i_in), max_i_(max_i_in),
+ min_j_(min_j_in), max_j_(max_j_in),
+ min_k_(min_k_in), max_k_(max_k_in),
+ we_own_array_(array_in == NULL)
+ {
+ if (stride_k_ == 0)
+ then stride_k_ = 1;
+ if (stride_j_ == 0)
+ then stride_j_ = N_k();
+ if (stride_i_ == 0)
+ then stride_i_ = N_j() * N_k();
+
+ // must use unchecked subscripting here since setup isn't done yet
+ offset_ = -subscript_unchecked(min_i_, min_j_, min_k_); // RHS uses offset_ = 0
+ assert(subscript_unchecked(min_i_, min_j_, min_k_) == 0);
+ max_subscript_ = subscript_unchecked(max_i_, max_j_, max_k_);
+
+ if (we_own_array_)
+ then
+ {
+ // allocate it
+ const int N_allocate = N_i() * N_j() * N_k();
+ array_ = new T[N_allocate];
+ }
+
+ // explicitly initialize array (new[] *doesn't* do this automagically)
+ for (int i = min_i(); i <= max_i(); ++i)
+ {
+ for (int j = min_j(); j <= max_j(); ++j)
+ {
+ for (int k = min_k(); k <= max_k(); ++k)
+ {
+ operator()(i, j, k) = T(0);
+ }
+ }
+ }
+ }
+ //
+ // This function destroys an array3d object.
+ //
+ template
+ array3d::~array3d()
+ {
+ if (we_own_array_)
+ then delete[] array_;
+ }
+
+ template class array1d;
+
+ // FIXME: we shouldn't have to instantiate these both, the const one
+ // is actually trivially derivable from the non-const one. :(
+ template class array1d;
+ template class array1d;
+
+ template class array1d;
+ template class array2d;
+ template class array2d;
+ template class array3d;
+
+ } // namespace jtutil
+} // namespace AHFinderDirect
diff --git a/AMSS_NCKU_source/array.h b/AMSS_NCKU_source/AHF_Direct/array.h
similarity index 97%
rename from AMSS_NCKU_source/array.h
rename to AMSS_NCKU_source/AHF_Direct/array.h
index 463fc5f..c8ea8c1 100644
--- a/AMSS_NCKU_source/array.h
+++ b/AMSS_NCKU_source/AHF_Direct/array.h
@@ -1,292 +1,292 @@
-#ifndef AHFINDERDIRECT__ARRAY_HH
-#define AHFINDERDIRECT__ARRAY_HH
-
-namespace AHFinderDirect
-{
- namespace jtutil
- {
-
- //******************************************************************************
-
- template
- class array1d
- {
- public:
- int min_i() const { return min_i_; }
- int max_i() const { return max_i_; }
- int N_i() const { return jtutil::how_many_in_range(min_i_, max_i_); }
- bool is_valid_i(int i) const { return (i >= min_i_) && (i <= max_i_); }
-
- int subscript_unchecked(int i) const
- {
- return offset_ + stride_i_ * i;
- }
- int subscript(int i) const
- {
- assert(is_valid_i(i));
- const int posn = subscript_unchecked(i);
- assert(posn >= 0);
- assert(posn <= max_subscript_);
- return posn;
- }
- int subscript_offset() const { return offset_; }
- int subscript_stride_i() const { return stride_i_; }
-
- // normal-use access functions
- // ... rvalue
- const T &operator()(int i) const { return array_[subscript(i)]; }
- // ... lvalue
- T &operator()(int i) { return array_[subscript(i)]; }
-
- // get access to internal 0-origin 1D storage array
- // (low-level, dangerous, use with caution!)
- // ... semantics of N_array() may not be what you want
- // if strides specify noncontiguous storage
- int N_array() const { return max_subscript_ + stride_i_; }
- const T *data_array() const { return const_cast(array_); }
- T *data_array() { return array_; }
-
- // constructor, destructor
- // ... constructor initializes all array elements to T(0.0)
- // ... omitted strides default to C storage order
- array1d(int min_i_in, int max_i_in,
- T *array_in = NULL, // caller-provided storage array
- // if non-NULL
- int stride_i_in = 0);
- ~array1d();
-
- private:
- // we forbid copying and passing by value
- // by declaring the copy constructor and assignment operator
- // private, but never defining them
- array1d(const array1d &rhs);
- array1d &operator=(const array1d &rhs);
-
- private:
- // n.b. we declare the array pointer first in the class
- // ==> it's probably at 0 offset
- // ==> we may get slightly faster array access
- T *array_; // --> new-allocated 1D storage array
-
- // subscripting info
- // n.b. put this next in class so it should be in the same
- // cpu cache line as array_ ==> faster array access
- int offset_, stride_i_;
-
- // min/max array bounds
- const int min_i_, max_i_;
- int max_subscript_;
-
- // n.b. put this at end of class since performance doesn't matter
- bool we_own_array_; // true ==> array_ --> new[] array which we own
- // false ==> array_ --> client-owned storage
- };
-
- //******************************************************************************
-
- template
- class array2d
- {
- public:
- // array info
- int min_i() const { return min_i_; }
- int max_i() const { return max_i_; }
- int min_j() const { return min_j_; }
- int max_j() const { return max_j_; }
- int N_i() const { return jtutil::how_many_in_range(min_i_, max_i_); }
- int N_j() const { return jtutil::how_many_in_range(min_j_, max_j_); }
- bool is_valid_i(int i) const { return (i >= min_i_) && (i <= max_i_); }
- bool is_valid_j(int j) const { return (j >= min_j_) && (j <= max_j_); }
- bool is_valid_ij(int i, int j) const
- {
- return is_valid_i(i) && is_valid_j(j);
- }
-
- int subscript_unchecked(int i, int j) const
- {
- return offset_ + stride_i_ * i + stride_j_ * j;
- }
- int subscript(int i, int j) const
- {
- // n.b. we want each assert() here to be on a separate
- // source line, so an assert() failure message can
- // pinpoint *which* index is bad
- assert(is_valid_i(i));
- assert(is_valid_j(j));
- const int posn = subscript_unchecked(i, j);
- assert(posn >= 0);
- assert(posn <= max_subscript_);
- return posn;
- }
- int subscript_offset() const { return offset_; }
- int subscript_stride_i() const { return stride_i_; }
- int subscript_stride_j() const { return stride_j_; }
-
- // normal-use access functions
- // ... rvalue
- const T &operator()(int i, int j) const
- {
- return array_[subscript(i, j)];
- }
- // ... lvalue
- T &operator()(int i, int j)
- {
- return array_[subscript(i, j)];
- }
-
- // get access to internal 0-origin 1D storage array
- // (low-level, dangerous, use with caution!)
- // ... semantics of N_array() may not be what you want
- // if strides specify noncontiguous storage
- int N_array() const { return max_subscript_ + stride_j_; }
- const T *data_array() const { return const_cast(array_); }
- T *data_array() { return array_; }
-
- // constructor, destructor
- // ... constructor initializes all array elements to T(0.0)
- // ... omitted strides default to C storage order
- array2d(int min_i_in, int max_i_in,
- int min_j_in, int max_j_in,
- T *array_in = NULL, // caller-provided storage array
- // if non-NULL
- int stride_i_in = 0, int stride_j_in = 0);
- ~array2d();
-
- private:
- // we forbid copying and passing by value
- // by declaring the copy constructor and assignment operator
- // private, but never defining them
- array2d(const array2d &rhs);
- array2d &operator=(const array2d &rhs);
-
- private:
- // n.b. we declare the array pointer first in the class
- // ==> it's probably at 0 offset
- // ==> we may get slightly faster array access
- T *array_; // --> new-allocated 1D storage array
-
- // subscripting info
- // n.b. put this next in class so it should be in the same
- // cpu cache line as array_ ==> faster array access
- int offset_, stride_i_, stride_j_;
-
- // min/max array bounds
- const int min_i_, max_i_;
- const int min_j_, max_j_;
- int max_subscript_;
-
- // n.b. put this at end of class since performance doesn't matter
- bool we_own_array_; // true ==> array_ --> new[] array which we own
- // false ==> array_ --> client-owned storage
- };
-
- //******************************************************************************
-
- template
- class array3d
- {
- public:
- // array info
- int min_i() const { return min_i_; }
- int max_i() const { return max_i_; }
- int min_j() const { return min_j_; }
- int max_j() const { return max_j_; }
- int min_k() const { return min_k_; }
- int max_k() const { return max_k_; }
- int N_i() const { return jtutil::how_many_in_range(min_i_, max_i_); }
- int N_j() const { return jtutil::how_many_in_range(min_j_, max_j_); }
- int N_k() const { return jtutil::how_many_in_range(min_k_, max_k_); }
- bool is_valid_i(int i) const { return (i >= min_i_) && (i <= max_i_); }
- bool is_valid_j(int j) const { return (j >= min_j_) && (j <= max_j_); }
- bool is_valid_k(int k) const { return (k >= min_k_) && (k <= max_k_); }
- bool is_valid_ijk(int i, int j, int k) const
- {
- return is_valid_i(i) && is_valid_j(j) && is_valid_k(k);
- }
-
- int subscript_unchecked(int i, int j, int k) const
- {
- return offset_ + stride_i_ * i + stride_j_ * j + stride_k_ * k;
- }
- int subscript(int i, int j, int k) const
- {
- // n.b. we want each assert() here to be on a separate
- // source line, so an assert() failure message can
- // pinpoint *which* index is bad
- assert(is_valid_i(i));
- assert(is_valid_j(j));
- assert(is_valid_k(k));
- const int posn = subscript_unchecked(i, j, k);
- assert(posn >= 0);
- assert(posn <= max_subscript_);
- return posn;
- }
- int subscript_offset() const { return offset_; }
- int subscript_stride_i() const { return stride_i_; }
- int subscript_stride_j() const { return stride_j_; }
- int subscript_stride_k() const { return stride_k_; }
-
- // normal-use access functions
- // ... rvalue
- const T &operator()(int i, int j, int k) const
- {
- return array_[subscript(i, j, k)];
- }
- // ... lvalue
- T &operator()(int i, int j, int k)
- {
- return array_[subscript(i, j, k)];
- }
-
- // get access to internal 0-origin 1D storage array
- // (low-level, dangerous, use with caution!)
- // ... semantics of N_array() may not be what you want
- // if strides specify noncontiguous storage
- int N_array() const { return max_subscript_ + stride_k_; }
- const T *data_array() const { return const_cast(array_); }
- T *data_array() { return array_; }
-
- // constructor, destructor
- // ... constructor initializes all array elements to T(0.0)
- // ... omitted strides default to C storage order
- array3d(int min_i_in, int max_i_in,
- int min_j_in, int max_j_in,
- int min_k_in, int max_k_in,
- T *array_in = NULL, // caller-provided storage array
- // if non-NULL
- int stride_i_in = 0, int stride_j_in = 0, int stride_k_in = 0);
- ~array3d();
-
- private:
- // we forbid copying and passing by value
- // by declaring the copy constructor and assignment operator
- // private, but never defining them
- array3d(const array3d &rhs);
- array3d &operator=(const array3d &rhs);
-
- private:
- // n.b. we declare the array pointer first in the class
- // ==> it's probably at 0 offset
- // ==> we may get slightly faster array access
- T *array_; // --> new-allocated 1D storage array
-
- // subscripting info
- // n.b. put this next in class so it should be in the same
- // cpu cache line as array_ ==> faster array access
- int offset_, stride_i_, stride_j_, stride_k_;
-
- // min/max array bounds
- const int min_i_, max_i_;
- const int min_j_, max_j_;
- const int min_k_, max_k_;
- int max_subscript_;
-
- // n.b. put this at end of class since performance doesn't matter
- bool we_own_array_; // true ==> array_ --> new[] array which we own
- // false ==> array_ --> client-owned storage
- };
-
- } // namespace jtutil
-} // namespace AHFinderDirect
-
-#endif /* AHFINDERDIRECT__ARRAY_HH */
+#ifndef AHFINDERDIRECT__ARRAY_HH
+#define AHFINDERDIRECT__ARRAY_HH
+
+namespace AHFinderDirect
+{
+ namespace jtutil
+ {
+
+ //******************************************************************************
+
+ template
+ class array1d
+ {
+ public:
+ int min_i() const { return min_i_; }
+ int max_i() const { return max_i_; }
+ int N_i() const { return jtutil::how_many_in_range(min_i_, max_i_); }
+ bool is_valid_i(int i) const { return (i >= min_i_) && (i <= max_i_); }
+
+ int subscript_unchecked(int i) const
+ {
+ return offset_ + stride_i_ * i;
+ }
+ int subscript(int i) const
+ {
+ assert(is_valid_i(i));
+ const int posn = subscript_unchecked(i);
+ assert(posn >= 0);
+ assert(posn <= max_subscript_);
+ return posn;
+ }
+ int subscript_offset() const { return offset_; }
+ int subscript_stride_i() const { return stride_i_; }
+
+ // normal-use access functions
+ // ... rvalue
+ const T &operator()(int i) const { return array_[subscript(i)]; }
+ // ... lvalue
+ T &operator()(int i) { return array_[subscript(i)]; }
+
+ // get access to internal 0-origin 1D storage array
+ // (low-level, dangerous, use with caution!)
+ // ... semantics of N_array() may not be what you want
+ // if strides specify noncontiguous storage
+ int N_array() const { return max_subscript_ + stride_i_; }
+ const T *data_array() const { return const_cast(array_); }
+ T *data_array() { return array_; }
+
+ // constructor, destructor
+ // ... constructor initializes all array elements to T(0.0)
+ // ... omitted strides default to C storage order
+ array1d(int min_i_in, int max_i_in,
+ T *array_in = NULL, // caller-provided storage array
+ // if non-NULL
+ int stride_i_in = 0);
+ ~array1d();
+
+ private:
+ // we forbid copying and passing by value
+ // by declaring the copy constructor and assignment operator
+ // private, but never defining them
+ array1d(const array1d &rhs);
+ array1d &operator=(const array1d &rhs);
+
+ private:
+ // n.b. we declare the array pointer first in the class
+ // ==> it's probably at 0 offset
+ // ==> we may get slightly faster array access
+ T *array_; // --> new-allocated 1D storage array
+
+ // subscripting info
+ // n.b. put this next in class so it should be in the same
+ // cpu cache line as array_ ==> faster array access
+ int offset_, stride_i_;
+
+ // min/max array bounds
+ const int min_i_, max_i_;
+ int max_subscript_;
+
+ // n.b. put this at end of class since performance doesn't matter
+ bool we_own_array_; // true ==> array_ --> new[] array which we own
+ // false ==> array_ --> client-owned storage
+ };
+
+ //******************************************************************************
+
+ template
+ class array2d
+ {
+ public:
+ // array info
+ int min_i() const { return min_i_; }
+ int max_i() const { return max_i_; }
+ int min_j() const { return min_j_; }
+ int max_j() const { return max_j_; }
+ int N_i() const { return jtutil::how_many_in_range(min_i_, max_i_); }
+ int N_j() const { return jtutil::how_many_in_range(min_j_, max_j_); }
+ bool is_valid_i(int i) const { return (i >= min_i_) && (i <= max_i_); }
+ bool is_valid_j(int j) const { return (j >= min_j_) && (j <= max_j_); }
+ bool is_valid_ij(int i, int j) const
+ {
+ return is_valid_i(i) && is_valid_j(j);
+ }
+
+ int subscript_unchecked(int i, int j) const
+ {
+ return offset_ + stride_i_ * i + stride_j_ * j;
+ }
+ int subscript(int i, int j) const
+ {
+ // n.b. we want each assert() here to be on a separate
+ // source line, so an assert() failure message can
+ // pinpoint *which* index is bad
+ assert(is_valid_i(i));
+ assert(is_valid_j(j));
+ const int posn = subscript_unchecked(i, j);
+ assert(posn >= 0);
+ assert(posn <= max_subscript_);
+ return posn;
+ }
+ int subscript_offset() const { return offset_; }
+ int subscript_stride_i() const { return stride_i_; }
+ int subscript_stride_j() const { return stride_j_; }
+
+ // normal-use access functions
+ // ... rvalue
+ const T &operator()(int i, int j) const
+ {
+ return array_[subscript(i, j)];
+ }
+ // ... lvalue
+ T &operator()(int i, int j)
+ {
+ return array_[subscript(i, j)];
+ }
+
+ // get access to internal 0-origin 1D storage array
+ // (low-level, dangerous, use with caution!)
+ // ... semantics of N_array() may not be what you want
+ // if strides specify noncontiguous storage
+ int N_array() const { return max_subscript_ + stride_j_; }
+ const T *data_array() const { return const_cast(array_); }
+ T *data_array() { return array_; }
+
+ // constructor, destructor
+ // ... constructor initializes all array elements to T(0.0)
+ // ... omitted strides default to C storage order
+ array2d(int min_i_in, int max_i_in,
+ int min_j_in, int max_j_in,
+ T *array_in = NULL, // caller-provided storage array
+ // if non-NULL
+ int stride_i_in = 0, int stride_j_in = 0);
+ ~array2d();
+
+ private:
+ // we forbid copying and passing by value
+ // by declaring the copy constructor and assignment operator
+ // private, but never defining them
+ array2d(const array2d &rhs);
+ array2d &operator=(const array2d &rhs);
+
+ private:
+ // n.b. we declare the array pointer first in the class
+ // ==> it's probably at 0 offset
+ // ==> we may get slightly faster array access
+ T *array_; // --> new-allocated 1D storage array
+
+ // subscripting info
+ // n.b. put this next in class so it should be in the same
+ // cpu cache line as array_ ==> faster array access
+ int offset_, stride_i_, stride_j_;
+
+ // min/max array bounds
+ const int min_i_, max_i_;
+ const int min_j_, max_j_;
+ int max_subscript_;
+
+ // n.b. put this at end of class since performance doesn't matter
+ bool we_own_array_; // true ==> array_ --> new[] array which we own
+ // false ==> array_ --> client-owned storage
+ };
+
+ //******************************************************************************
+
+ template
+ class array3d
+ {
+ public:
+ // array info
+ int min_i() const { return min_i_; }
+ int max_i() const { return max_i_; }
+ int min_j() const { return min_j_; }
+ int max_j() const { return max_j_; }
+ int min_k() const { return min_k_; }
+ int max_k() const { return max_k_; }
+ int N_i() const { return jtutil::how_many_in_range(min_i_, max_i_); }
+ int N_j() const { return jtutil::how_many_in_range(min_j_, max_j_); }
+ int N_k() const { return jtutil::how_many_in_range(min_k_, max_k_); }
+ bool is_valid_i(int i) const { return (i >= min_i_) && (i <= max_i_); }
+ bool is_valid_j(int j) const { return (j >= min_j_) && (j <= max_j_); }
+ bool is_valid_k(int k) const { return (k >= min_k_) && (k <= max_k_); }
+ bool is_valid_ijk(int i, int j, int k) const
+ {
+ return is_valid_i(i) && is_valid_j(j) && is_valid_k(k);
+ }
+
+ int subscript_unchecked(int i, int j, int k) const
+ {
+ return offset_ + stride_i_ * i + stride_j_ * j + stride_k_ * k;
+ }
+ int subscript(int i, int j, int k) const
+ {
+ // n.b. we want each assert() here to be on a separate
+ // source line, so an assert() failure message can
+ // pinpoint *which* index is bad
+ assert(is_valid_i(i));
+ assert(is_valid_j(j));
+ assert(is_valid_k(k));
+ const int posn = subscript_unchecked(i, j, k);
+ assert(posn >= 0);
+ assert(posn <= max_subscript_);
+ return posn;
+ }
+ int subscript_offset() const { return offset_; }
+ int subscript_stride_i() const { return stride_i_; }
+ int subscript_stride_j() const { return stride_j_; }
+ int subscript_stride_k() const { return stride_k_; }
+
+ // normal-use access functions
+ // ... rvalue
+ const T &operator()(int i, int j, int k) const
+ {
+ return array_[subscript(i, j, k)];
+ }
+ // ... lvalue
+ T &operator()(int i, int j, int k)
+ {
+ return array_[subscript(i, j, k)];
+ }
+
+ // get access to internal 0-origin 1D storage array
+ // (low-level, dangerous, use with caution!)
+ // ... semantics of N_array() may not be what you want
+ // if strides specify noncontiguous storage
+ int N_array() const { return max_subscript_ + stride_k_; }
+ const T *data_array() const { return const_cast(array_); }
+ T *data_array() { return array_; }
+
+ // constructor, destructor
+ // ... constructor initializes all array elements to T(0.0)
+ // ... omitted strides default to C storage order
+ array3d(int min_i_in, int max_i_in,
+ int min_j_in, int max_j_in,
+ int min_k_in, int max_k_in,
+ T *array_in = NULL, // caller-provided storage array
+ // if non-NULL
+ int stride_i_in = 0, int stride_j_in = 0, int stride_k_in = 0);
+ ~array3d();
+
+ private:
+ // we forbid copying and passing by value
+ // by declaring the copy constructor and assignment operator
+ // private, but never defining them
+ array3d(const array3d &rhs);
+ array3d &operator=(const array3d &rhs);
+
+ private:
+ // n.b. we declare the array pointer first in the class
+ // ==> it's probably at 0 offset
+ // ==> we may get slightly faster array access
+ T *array_; // --> new-allocated 1D storage array
+
+ // subscripting info
+ // n.b. put this next in class so it should be in the same
+ // cpu cache line as array_ ==> faster array access
+ int offset_, stride_i_, stride_j_, stride_k_;
+
+ // min/max array bounds
+ const int min_i_, max_i_;
+ const int min_j_, max_j_;
+ const int min_k_, max_k_;
+ int max_subscript_;
+
+ // n.b. put this at end of class since performance doesn't matter
+ bool we_own_array_; // true ==> array_ --> new[] array which we own
+ // false ==> array_ --> client-owned storage
+ };
+
+ } // namespace jtutil
+} // namespace AHFinderDirect
+
+#endif /* AHFINDERDIRECT__ARRAY_HH */
diff --git a/AMSS_NCKU_source/cctk.h b/AMSS_NCKU_source/AHF_Direct/cctk.h
similarity index 96%
rename from AMSS_NCKU_source/cctk.h
rename to AMSS_NCKU_source/AHF_Direct/cctk.h
index 094e388..193704d 100644
--- a/AMSS_NCKU_source/cctk.h
+++ b/AMSS_NCKU_source/AHF_Direct/cctk.h
@@ -1,58 +1,58 @@
-#ifndef _CCTK_H_
-#define _CCTK_H_ 1
-
-/* Grab the main configuration info. */
-#include "cctk_Config.h"
-
-#define CCTK_THORNSTRING "AHFinderDirect"
-
-/* Include the constants */
-#include "cctk_Constants.h"
-
-/* get the definition of ptrdiff_t */
-#include
-int CCTK_VInfo(const char *thorn, const char *format, ...);
-int CCTK_VWarn(int level,
- int line,
- const char *file,
- const char *thorn,
- const char *format,
- ...);
-#define CCTK_ERROR_INTERP_GHOST_SIZE_TOO_SMALL (-1001)
-#ifdef __cplusplus
-#define HAVE_INLINE
-#else
-#ifndef inline
-#define HAVE_INLINE
-#endif
-#endif
-
-#define CCTK_PRINTSEPARATOR \
- printf("--------------------------------------------------------------------------------\n");
-
-#define _DECLARE_CCTK_ARGUMENTS _DECLARE_CCTK_CARGUMENTS
-#define _DECLARE_CCTK_CARGUMENTS \
- ptrdiff_t cctki_dummy_int; \
- CCTK_REAL cctk_time = cctkGH->PhysTime; \
- int cctk_iteration = 1; \
- int cctk_dim = 3;
-
-#define CCTK_EQUALS(a, b) (CCTK_Equals((a), (b)))
-
-#define CCTK_PASS_CTOC cctkGH
-
-#define CCTK_ORIGIN_SPACE(x) (cctk_origin_space[x] + cctk_delta_space[x] / cctk_levfac[x] * cctk_levoff[x] / cctk_levoffdenom[x])
-#define CCTK_DELTA_SPACE(x) (cctk_delta_space[x] / cctk_levfac[x])
-#define CCTK_DELTA_TIME (cctk_delta_time / cctk_timefac)
-#define CCTK_LSSH(stag, dim) cctk_lssh[(stag) + CCTK_NSTAGGER * (dim)]
-#define CCTK_LSSH_IDX(stag, dim) ((stag) + CCTK_NSTAGGER * (dim))
-
-#define CCTK_WARN(a, b) CCTK_Warn(a, __LINE__, __FILE__, CCTK_THORNSTRING, b)
-
-#define CCTK_MALLOC(s) CCTKi_Malloc(s, __LINE__, __FILE__)
-#define CCTK_FREE(p) CCTKi_Free(p)
-
-#define CCTK_INFO(a) CCTK_Info(CCTK_THORNSTRING, (a))
-#define CCTK_PARAMWARN(a) CCTK_ParamWarn(CCTK_THORNSTRING, (a))
-
-#endif
+#ifndef _CCTK_H_
+#define _CCTK_H_ 1
+
+/* Grab the main configuration info. */
+#include "cctk_Config.h"
+
+#define CCTK_THORNSTRING "AHFinderDirect"
+
+/* Include the constants */
+#include "cctk_Constants.h"
+
+/* get the definition of ptrdiff_t */
+#include
+int CCTK_VInfo(const char *thorn, const char *format, ...);
+int CCTK_VWarn(int level,
+ int line,
+ const char *file,
+ const char *thorn,
+ const char *format,
+ ...);
+#define CCTK_ERROR_INTERP_GHOST_SIZE_TOO_SMALL (-1001)
+#ifdef __cplusplus
+#define HAVE_INLINE
+#else
+#ifndef inline
+#define HAVE_INLINE
+#endif
+#endif
+
+#define CCTK_PRINTSEPARATOR \
+ printf("--------------------------------------------------------------------------------\n");
+
+#define _DECLARE_CCTK_ARGUMENTS _DECLARE_CCTK_CARGUMENTS
+#define _DECLARE_CCTK_CARGUMENTS \
+ ptrdiff_t cctki_dummy_int; \
+ CCTK_REAL cctk_time = cctkGH->PhysTime; \
+ int cctk_iteration = 1; \
+ int cctk_dim = 3;
+
+#define CCTK_EQUALS(a, b) (CCTK_Equals((a), (b)))
+
+#define CCTK_PASS_CTOC cctkGH
+
+#define CCTK_ORIGIN_SPACE(x) (cctk_origin_space[x] + cctk_delta_space[x] / cctk_levfac[x] * cctk_levoff[x] / cctk_levoffdenom[x])
+#define CCTK_DELTA_SPACE(x) (cctk_delta_space[x] / cctk_levfac[x])
+#define CCTK_DELTA_TIME (cctk_delta_time / cctk_timefac)
+#define CCTK_LSSH(stag, dim) cctk_lssh[(stag) + CCTK_NSTAGGER * (dim)]
+#define CCTK_LSSH_IDX(stag, dim) ((stag) + CCTK_NSTAGGER * (dim))
+
+#define CCTK_WARN(a, b) CCTK_Warn(a, __LINE__, __FILE__, CCTK_THORNSTRING, b)
+
+#define CCTK_MALLOC(s) CCTKi_Malloc(s, __LINE__, __FILE__)
+#define CCTK_FREE(p) CCTKi_Free(p)
+
+#define CCTK_INFO(a) CCTK_Info(CCTK_THORNSTRING, (a))
+#define CCTK_PARAMWARN(a) CCTK_ParamWarn(CCTK_THORNSTRING, (a))
+
+#endif
diff --git a/AMSS_NCKU_source/cctk_Config.h b/AMSS_NCKU_source/AHF_Direct/cctk_Config.h
similarity index 95%
rename from AMSS_NCKU_source/cctk_Config.h
rename to AMSS_NCKU_source/AHF_Direct/cctk_Config.h
index ca00555..04b310e 100644
--- a/AMSS_NCKU_source/cctk_Config.h
+++ b/AMSS_NCKU_source/AHF_Direct/cctk_Config.h
@@ -1,168 +1,168 @@
-#ifndef _CCTK_CONFIG_H_
-#define _CCTK_CONFIG_H_
-
-#define STDC_HEADERS 1
-
-#define CCTK_FCALL
-
-#define HAVE_GETHOSTBYNAME 1
-#define HAVE_GETOPT_LONG_ONLY 1
-#define HAVE_CRYPT 1
-#define HAVE_FINITE 1
-#define HAVE_ISNAN 1
-#define HAVE_ISINF 1
-#define HAVE_MKSTEMP 1
-#define HAVE_VA_COPY 1
-
-/* Do we have mode_t ? */
-#define HAVE_MODE_T 1
-
-#define HAVE_SOCKLEN_T 1
-#ifdef HAVE_SOCKLEN_T
-# define CCTK_SOCKLEN_T socklen_t
-#else
-# define CCTK_SOCKLEN_T int
-#endif
-
-#define HAVE_TIME_H 1
-#define HAVE_SYS_IOCTL_H 1
-#define HAVE_SYS_SOCKET_H 1
-#define HAVE_SYS_TIME_H 1
-#define HAVE_SYS_TYPES_H 1
-#define HAVE_UNISTD_H 1
-#define HAVE_STRING_H 1
-#define HAVE_ASSERT_H 1
-#define HAVE_TGMATH_H 1
-#define HAVE_SYS_STAT_H 1
-#define HAVE_GETOPT_H 1
-#define HAVE_REGEX_H 1
-#define HAVE_NETINET_IN_H 1
-#define HAVE_NETDB_H 1
-#define HAVE_ARPA_INET_H 1
-#define HAVE_CRYPT_H 1
-#define HAVE_DIRENT_H 1
-#define HAVE_SIGNAL_H 1
-#define HAVE_MALLOC_H 1
-#define HAVE_MALLINFO 1
-#define HAVE_MALLOPT 1
-#define HAVE_M_MMAP_THRESHOLD_VALUE 1
-
-#define TIME_WITH_SYS_TIME 1
-
-#define HAVE_VECTOR 1
-#define HAVE_VECTOR_H 1
-
-#define GETTIMEOFDAY_NEEDS_TIMEZONE 1
-
-#define CCTK_CACHELINE_BYTES 64
-#define CCTK_CACHE_SIZE 1024*1024
-
-#define NULL_DEVICE "/dev/null"
-
-#define CCTK_BUILD_OS "linux-gnu"
-#define CCTK_BUILD_CPU "x86_64"
-#define CCTK_BUILD_VENDOR "unknown"
-
-#define SIZEOF_SHORT_INT 2
-#define SIZEOF_INT 4
-#define SIZEOF_LONG_INT 8
-#define SIZEOF_LONG_LONG 8
-#define SIZEOF_LONG_DOUBLE 16
-#define SIZEOF_DOUBLE 8
-#define SIZEOF_FLOAT 4
-#define SIZEOF_CHAR_P 8
-
-#define CCTK_REAL_PRECISION_8 1
-
-#define CCTK_INTEGER_PRECISION_4 1
-
-#define HAVE_CCTK_INT8 1
-#define HAVE_CCTK_INT4 1
-#define HAVE_CCTK_INT2 1
-#define HAVE_CCTK_INT1 1
-
-#define HAVE_CCTK_REAL16 1
-#define HAVE_CCTK_REAL8 1
-#define HAVE_CCTK_REAL4 1
-
-#define CCTK_INT8 long int
-#define CCTK_INT4 int
-#define CCTK_INT2 short int
-#define CCTK_INT1 signed char
-
-#define CCTK_REAL16 long double
-#define CCTK_REAL8 double
-#define CCTK_REAL4 float
-
-#ifndef __cplusplus
-
-#ifdef CCTK_C_RESTRICT
-#define restrict CCTK_C_RESTRICT
-#endif
-
-/* Allow the use of CCTK_RESTRICT as a qualifier always. */
-#ifdef CCTK_C_RESTRICT
-#define CCTK_RESTRICT CCTK_C_RESTRICT
-#else
-#define CCTK_RESTRICT restrict
-#endif
-
-#ifdef HAVE_CCTK_C_BOOL
-#define CCTK_HAVE_C_BOOL
-#endif
-
-#endif /* ! defined __cplusplus */
-/****************************************************************************/
-
-/****************************************************************************/
-/* C++ specific stuff */
-/****************************************************************************/
-#ifdef __cplusplus
-
-/* Some C++ compilers don't have bool ! */
-#define HAVE_CCTK_CXX_BOOL 1
-
-#ifndef HAVE_CCTK_CXX_BOOL
-typedef enum {false, true} bool;
-#else
-/* deprecated in beta15 */
-#define CCTK_HAVE_CXX_BOOL
-#endif
-
-/* Some C++ compilers recognise the restrict keyword */
-#define CCTK_CXX_RESTRICT __restrict__
-
-/* Since this is non-standard leave commented out for the moment */
-#if 0
-/* Define to empty if the keyword does not work. */
-#ifdef CCTK_CXX_RESTRICT
-#define restrict CCTK_CXX_RESTRICT
-#endif
-#endif
-
-/* Allow the use of CCTK_RESTRICT as a qualifier always. */
-#ifdef CCTK_CXX_RESTRICT
-#define CCTK_RESTRICT CCTK_CXX_RESTRICT
-#else
-#define CCTK_RESTRICT restrict
-#endif
-
-#endif /* __cplusplus */
-/****************************************************************************/
-
-#ifdef FCODE
-
-#define HAVE_CCTK_FORTRAN_REAL4 1
-#define HAVE_CCTK_FORTRAN_REAL8 1
-#define HAVE_CCTK_FORTRAN_REAL16 1
-
-#define HAVE_CCTK_FORTRAN_COMPLEX8 1
-#define HAVE_CCTK_FORTRAN_COMPLEX16 1
-#define HAVE_CCTK_FORTRAN_COMPLEX32 1
-
-#endif /* FCODE */
-
-/* Now include the code to pick an appropriate precison for reals and ints */
-#include "cctk_Types.h"
-
-#endif /* _CCTK_CONFIG_H_ */
+#ifndef _CCTK_CONFIG_H_
+#define _CCTK_CONFIG_H_
+
+#define STDC_HEADERS 1
+
+#define CCTK_FCALL
+
+#define HAVE_GETHOSTBYNAME 1
+#define HAVE_GETOPT_LONG_ONLY 1
+#define HAVE_CRYPT 1
+#define HAVE_FINITE 1
+#define HAVE_ISNAN 1
+#define HAVE_ISINF 1
+#define HAVE_MKSTEMP 1
+#define HAVE_VA_COPY 1
+
+/* Do we have mode_t ? */
+#define HAVE_MODE_T 1
+
+#define HAVE_SOCKLEN_T 1
+#ifdef HAVE_SOCKLEN_T
+# define CCTK_SOCKLEN_T socklen_t
+#else
+# define CCTK_SOCKLEN_T int
+#endif
+
+#define HAVE_TIME_H 1
+#define HAVE_SYS_IOCTL_H 1
+#define HAVE_SYS_SOCKET_H 1
+#define HAVE_SYS_TIME_H 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_UNISTD_H 1
+#define HAVE_STRING_H 1
+#define HAVE_ASSERT_H 1
+#define HAVE_TGMATH_H 1
+#define HAVE_SYS_STAT_H 1
+#define HAVE_GETOPT_H 1
+#define HAVE_REGEX_H 1
+#define HAVE_NETINET_IN_H 1
+#define HAVE_NETDB_H 1
+#define HAVE_ARPA_INET_H 1
+#define HAVE_CRYPT_H 1
+#define HAVE_DIRENT_H 1
+#define HAVE_SIGNAL_H 1
+#define HAVE_MALLOC_H 1
+#define HAVE_MALLINFO 1
+#define HAVE_MALLOPT 1
+#define HAVE_M_MMAP_THRESHOLD_VALUE 1
+
+#define TIME_WITH_SYS_TIME 1
+
+#define HAVE_VECTOR 1
+#define HAVE_VECTOR_H 1
+
+#define GETTIMEOFDAY_NEEDS_TIMEZONE 1
+
+#define CCTK_CACHELINE_BYTES 64
+#define CCTK_CACHE_SIZE 1024*1024
+
+#define NULL_DEVICE "/dev/null"
+
+#define CCTK_BUILD_OS "linux-gnu"
+#define CCTK_BUILD_CPU "x86_64"
+#define CCTK_BUILD_VENDOR "unknown"
+
+#define SIZEOF_SHORT_INT 2
+#define SIZEOF_INT 4
+#define SIZEOF_LONG_INT 8
+#define SIZEOF_LONG_LONG 8
+#define SIZEOF_LONG_DOUBLE 16
+#define SIZEOF_DOUBLE 8
+#define SIZEOF_FLOAT 4
+#define SIZEOF_CHAR_P 8
+
+#define CCTK_REAL_PRECISION_8 1
+
+#define CCTK_INTEGER_PRECISION_4 1
+
+#define HAVE_CCTK_INT8 1
+#define HAVE_CCTK_INT4 1
+#define HAVE_CCTK_INT2 1
+#define HAVE_CCTK_INT1 1
+
+#define HAVE_CCTK_REAL16 1
+#define HAVE_CCTK_REAL8 1
+#define HAVE_CCTK_REAL4 1
+
+#define CCTK_INT8 long int
+#define CCTK_INT4 int
+#define CCTK_INT2 short int
+#define CCTK_INT1 signed char
+
+#define CCTK_REAL16 long double
+#define CCTK_REAL8 double
+#define CCTK_REAL4 float
+
+#ifndef __cplusplus
+
+#ifdef CCTK_C_RESTRICT
+#define restrict CCTK_C_RESTRICT
+#endif
+
+/* Allow the use of CCTK_RESTRICT as a qualifier always. */
+#ifdef CCTK_C_RESTRICT
+#define CCTK_RESTRICT CCTK_C_RESTRICT
+#else
+#define CCTK_RESTRICT restrict
+#endif
+
+#ifdef HAVE_CCTK_C_BOOL
+#define CCTK_HAVE_C_BOOL
+#endif
+
+#endif /* ! defined __cplusplus */
+/****************************************************************************/
+
+/****************************************************************************/
+/* C++ specific stuff */
+/****************************************************************************/
+#ifdef __cplusplus
+
+/* Some C++ compilers don't have bool ! */
+#define HAVE_CCTK_CXX_BOOL 1
+
+#ifndef HAVE_CCTK_CXX_BOOL
+typedef enum {false, true} bool;
+#else
+/* deprecated in beta15 */
+#define CCTK_HAVE_CXX_BOOL
+#endif
+
+/* Some C++ compilers recognise the restrict keyword */
+#define CCTK_CXX_RESTRICT __restrict__
+
+/* Since this is non-standard leave commented out for the moment */
+#if 0
+/* Define to empty if the keyword does not work. */
+#ifdef CCTK_CXX_RESTRICT
+#define restrict CCTK_CXX_RESTRICT
+#endif
+#endif
+
+/* Allow the use of CCTK_RESTRICT as a qualifier always. */
+#ifdef CCTK_CXX_RESTRICT
+#define CCTK_RESTRICT CCTK_CXX_RESTRICT
+#else
+#define CCTK_RESTRICT restrict
+#endif
+
+#endif /* __cplusplus */
+/****************************************************************************/
+
+#ifdef FCODE
+
+#define HAVE_CCTK_FORTRAN_REAL4 1
+#define HAVE_CCTK_FORTRAN_REAL8 1
+#define HAVE_CCTK_FORTRAN_REAL16 1
+
+#define HAVE_CCTK_FORTRAN_COMPLEX8 1
+#define HAVE_CCTK_FORTRAN_COMPLEX16 1
+#define HAVE_CCTK_FORTRAN_COMPLEX32 1
+
+#endif /* FCODE */
+
+/* Now include the code to pick an appropriate precison for reals and ints */
+#include "cctk_Types.h"
+
+#endif /* _CCTK_CONFIG_H_ */
diff --git a/AMSS_NCKU_source/cctk_Constants.h b/AMSS_NCKU_source/AHF_Direct/cctk_Constants.h
similarity index 96%
rename from AMSS_NCKU_source/cctk_Constants.h
rename to AMSS_NCKU_source/AHF_Direct/cctk_Constants.h
index 238f25e..876fc3d 100644
--- a/AMSS_NCKU_source/cctk_Constants.h
+++ b/AMSS_NCKU_source/AHF_Direct/cctk_Constants.h
@@ -1,57 +1,57 @@
-#ifndef _CCTK_CONSTANTS_H_
-#define _CCTK_CONSTANTS_H_
-
-#define CCTK_VARIABLE_VOID 100
-#define CCTK_VARIABLE_BYTE 101
-#define CCTK_VARIABLE_INT 102
-#define CCTK_VARIABLE_INT1 103
-#define CCTK_VARIABLE_INT2 104
-#define CCTK_VARIABLE_INT4 105
-#define CCTK_VARIABLE_INT8 106
-#define CCTK_VARIABLE_REAL 107
-#define CCTK_VARIABLE_REAL4 108
-#define CCTK_VARIABLE_REAL8 109
-#define CCTK_VARIABLE_REAL16 110
-#define CCTK_VARIABLE_COMPLEX 111
-#define CCTK_VARIABLE_COMPLEX8 112
-#define CCTK_VARIABLE_COMPLEX16 113
-#define CCTK_VARIABLE_COMPLEX32 114
-#define CCTK_VARIABLE_CHAR 115
-#define CCTK_VARIABLE_STRING 116
-#define CCTK_VARIABLE_POINTER 117
-#define CCTK_VARIABLE_POINTER_TO_CONST 118
-#define CCTK_VARIABLE_FPOINTER 119
-
-/* DEPRECATED IN BETA 12 */
-#define CCTK_VARIABLE_FN_POINTER CCTK_VARIABLE_FPOINTER
-
-/* steerable status of parameters */
-#define CCTK_STEERABLE_NEVER 200
-#define CCTK_STEERABLE_ALWAYS 201
-#define CCTK_STEERABLE_RECOVER 202
-
-/* number of staggerings */
-#define CCTK_NSTAGGER 3
-
-/* group distributions */
-#define CCTK_DISTRIB_CONSTANT 301
-#define CCTK_DISTRIB_DEFAULT 302
-
-/* group types */
-#define CCTK_SCALAR 401
-#define CCTK_GF 402
-#define CCTK_ARRAY 403
-
-/* group scopes */
-#define CCTK_PRIVATE 501
-#define CCTK_PROTECTED 502
-#define CCTK_PUBLIC 503
-
-/* constants for CCTK_TraverseString() */
-#define CCTK_VAR 601
-#define CCTK_GROUP 602
-#define CCTK_GROUP_OR_VAR 603
-
-
-#endif /* _CCTK_CONSTANTS_ */
-
+#ifndef _CCTK_CONSTANTS_H_
+#define _CCTK_CONSTANTS_H_
+
+#define CCTK_VARIABLE_VOID 100
+#define CCTK_VARIABLE_BYTE 101
+#define CCTK_VARIABLE_INT 102
+#define CCTK_VARIABLE_INT1 103
+#define CCTK_VARIABLE_INT2 104
+#define CCTK_VARIABLE_INT4 105
+#define CCTK_VARIABLE_INT8 106
+#define CCTK_VARIABLE_REAL 107
+#define CCTK_VARIABLE_REAL4 108
+#define CCTK_VARIABLE_REAL8 109
+#define CCTK_VARIABLE_REAL16 110
+#define CCTK_VARIABLE_COMPLEX 111
+#define CCTK_VARIABLE_COMPLEX8 112
+#define CCTK_VARIABLE_COMPLEX16 113
+#define CCTK_VARIABLE_COMPLEX32 114
+#define CCTK_VARIABLE_CHAR 115
+#define CCTK_VARIABLE_STRING 116
+#define CCTK_VARIABLE_POINTER 117
+#define CCTK_VARIABLE_POINTER_TO_CONST 118
+#define CCTK_VARIABLE_FPOINTER 119
+
+/* DEPRECATED IN BETA 12 */
+#define CCTK_VARIABLE_FN_POINTER CCTK_VARIABLE_FPOINTER
+
+/* steerable status of parameters */
+#define CCTK_STEERABLE_NEVER 200
+#define CCTK_STEERABLE_ALWAYS 201
+#define CCTK_STEERABLE_RECOVER 202
+
+/* number of staggerings */
+#define CCTK_NSTAGGER 3
+
+/* group distributions */
+#define CCTK_DISTRIB_CONSTANT 301
+#define CCTK_DISTRIB_DEFAULT 302
+
+/* group types */
+#define CCTK_SCALAR 401
+#define CCTK_GF 402
+#define CCTK_ARRAY 403
+
+/* group scopes */
+#define CCTK_PRIVATE 501
+#define CCTK_PROTECTED 502
+#define CCTK_PUBLIC 503
+
+/* constants for CCTK_TraverseString() */
+#define CCTK_VAR 601
+#define CCTK_GROUP 602
+#define CCTK_GROUP_OR_VAR 603
+
+
+#endif /* _CCTK_CONSTANTS_ */
+
diff --git a/AMSS_NCKU_source/cctk_Types.h b/AMSS_NCKU_source/AHF_Direct/cctk_Types.h
similarity index 95%
rename from AMSS_NCKU_source/cctk_Types.h
rename to AMSS_NCKU_source/AHF_Direct/cctk_Types.h
index aa5f536..9648598 100644
--- a/AMSS_NCKU_source/cctk_Types.h
+++ b/AMSS_NCKU_source/AHF_Direct/cctk_Types.h
@@ -1,180 +1,180 @@
-#ifndef _CCTK_TYPES_H_
-#define _CCTK_TYPES_H_
-
-#ifndef _CCTK_CONFIG_H_
-#include "cctk_Config.h"
-#endif
-
-typedef void *CCTK_POINTER;
-typedef const void *CCTK_POINTER_TO_CONST;
-typedef void (*CCTK_FPOINTER)(void);
-#define HAVE_CCTK_POINTER 1
-#define HAVE_CCTK_POINTER_TO_CONST 1
-#define HAVE_CCTK_FPOINTER 1
-
-/* Character types */
-typedef char CCTK_CHAR;
-typedef const char * CCTK_STRING;
-#define HAVE_CCTK_CHAR 1
-#define HAVE_CCTK_STRING 1
-
-/* Structures for complex types */
-
-#ifdef HAVE_CCTK_REAL16
-#define HAVE_CCTK_COMPLEX32 1
-typedef struct CCTK_COMPLEX32
-{
- CCTK_REAL16 Re;
- CCTK_REAL16 Im;
-#ifdef __cplusplus
- CCTK_REAL16 real() const { return Re; }
- CCTK_REAL16 imag() const { return Im; }
-#endif
-} CCTK_COMPLEX32;
-#endif
-
-#ifdef HAVE_CCTK_REAL8
-#define HAVE_CCTK_COMPLEX16 1
-typedef struct CCTK_COMPLEX16
-{
- CCTK_REAL8 Re;
- CCTK_REAL8 Im;
-#ifdef __cplusplus
- CCTK_REAL8 real() const { return Re; }
- CCTK_REAL8 imag() const { return Im; }
-#endif
-} CCTK_COMPLEX16;
-#endif
-
-#ifdef HAVE_CCTK_REAL4
-#define HAVE_CCTK_COMPLEX8 1
-typedef struct CCTK_COMPLEX8
-{
- CCTK_REAL4 Re;
- CCTK_REAL4 Im;
-#ifdef __cplusplus
- CCTK_REAL4 real() const { return Re; }
- CCTK_REAL4 imag() const { return Im; }
-#endif
-} CCTK_COMPLEX8;
-#endif
-
-/* Small positive integer type */
-typedef unsigned char CCTK_BYTE;
-#define HAVE_CCTK_BYTE 1
-
-/* Define stuff for fortran. */
-#ifdef FCODE
-
-#define CCTK_POINTER integer*SIZEOF_CHAR_P
-#define CCTK_POINTER_TO_CONST integer*SIZEOF_CHAR_P
-/* TODO: add autoconf for determining the size of function pointers */
-#define CCTK_FPOINTER integer*SIZEOF_CHAR_P
-#define HAVE_CCTK_POINTER 1
-#define HAVE_CCTK_POINTER_TO_CONST 1
-#define HAVE_CCTK_FPOINTER 1
-
-/* Character types */
-/* A single character does not exist in Fortran; in Fortran, all
- character types are strings. Hence we do not define CCTK_CHAR. */
-/* #define CCTK_CHAR CHARACTER */
-/* #define HAVE_CCTK_CHAR 1 */
-/* This is a C-string, i.e., only a pointer */
-#define CCTK_STRING CCTK_POINTER_TO_CONST
-#define HAVE_CCTK_STRING 1
-
-#ifdef HAVE_CCTK_INT8
-#define CCTK_INT8 INTEGER*8
-#endif
-#ifdef HAVE_CCTK_INT4
-#define CCTK_INT4 INTEGER*4
-#endif
-#ifdef HAVE_CCTK_INT2
-#define CCTK_INT2 INTEGER*2
-#endif
-#ifdef HAVE_CCTK_INT1
-#define CCTK_INT1 INTEGER*1
-#endif
-
-#ifdef HAVE_CCTK_REAL16
-#define CCTK_REAL16 REAL*16
-#define HAVE_CCTK_COMPLEX32 1
-#define CCTK_COMPLEX32 COMPLEX*32
-#endif
-
-#ifdef HAVE_CCTK_REAL8
-#define CCTK_REAL8 REAL*8
-#define HAVE_CCTK_COMPLEX16 1
-#define CCTK_COMPLEX16 COMPLEX*16
-#endif
-
-#ifdef HAVE_CCTK_REAL4
-#define CCTK_REAL4 REAL*4
-#define HAVE_CCTK_COMPLEX8 1
-#define CCTK_COMPLEX8 COMPLEX*8
-#endif
-
-/* Should be unsigned, but Fortran doesn't have that */
-#define CCTK_BYTE INTEGER*1
-#define HAVE_CCTK_BYTE 1
-
-#endif /*FCODE */
-
-/* Now pick the types based upon the precision variable. */
-
-/* Floating point precision */
-#ifdef CCTK_REAL_PRECISION_16
-#define CCTK_REAL_PRECISION 16
-#define CCTK_REAL CCTK_REAL16
-#endif
-
-#ifdef CCTK_REAL_PRECISION_8
-#define CCTK_REAL_PRECISION 8
-#define CCTK_REAL CCTK_REAL8
-#endif
-
-#ifdef CCTK_REAL_PRECISION_4
-#define CCTK_REAL_PRECISION 4
-#define CCTK_REAL CCTK_REAL4
-#endif
-
-/* Integer precision */
-
-#ifdef CCTK_INTEGER_PRECISION_8
-#define CCTK_INTEGER_PRECISION 8
-#define CCTK_INT CCTK_INT8
-#endif
-
-#ifdef CCTK_INTEGER_PRECISION_4
-#define CCTK_INTEGER_PRECISION 4
-#define CCTK_INT CCTK_INT4
-#endif
-
-#ifdef CCTK_INTEGER_PRECISION_2
-#define CCTK_INTEGER_PRECISION 2
-#define CCTK_INT CCTK_INT2
-#endif
-
-#ifdef CCTK_INTEGER_PRECISION_1
-#define CCTK_INTEGER_PRECISION 1
-#define CCTK_INT CCTK_INT1
-#endif
-
-/* Complex precision */
-#ifdef CCTK_REAL_PRECISION_16
-#define CCTK_COMPLEX_PRECISION 32
-#define CCTK_COMPLEX CCTK_COMPLEX32
-#endif
-
-#ifdef CCTK_REAL_PRECISION_8
-#define CCTK_COMPLEX_PRECISION 16
-#define CCTK_COMPLEX CCTK_COMPLEX16
-#endif
-
-#ifdef CCTK_REAL_PRECISION_4
-#define CCTK_COMPLEX_PRECISION 8
-#define CCTK_COMPLEX CCTK_COMPLEX8
-#endif
-
-#endif /*_CCTK_TYPES_H_ */
-
+#ifndef _CCTK_TYPES_H_
+#define _CCTK_TYPES_H_
+
+#ifndef _CCTK_CONFIG_H_
+#include "cctk_Config.h"
+#endif
+
+typedef void *CCTK_POINTER;
+typedef const void *CCTK_POINTER_TO_CONST;
+typedef void (*CCTK_FPOINTER)(void);
+#define HAVE_CCTK_POINTER 1
+#define HAVE_CCTK_POINTER_TO_CONST 1
+#define HAVE_CCTK_FPOINTER 1
+
+/* Character types */
+typedef char CCTK_CHAR;
+typedef const char * CCTK_STRING;
+#define HAVE_CCTK_CHAR 1
+#define HAVE_CCTK_STRING 1
+
+/* Structures for complex types */
+
+#ifdef HAVE_CCTK_REAL16
+#define HAVE_CCTK_COMPLEX32 1
+typedef struct CCTK_COMPLEX32
+{
+ CCTK_REAL16 Re;
+ CCTK_REAL16 Im;
+#ifdef __cplusplus
+ CCTK_REAL16 real() const { return Re; }
+ CCTK_REAL16 imag() const { return Im; }
+#endif
+} CCTK_COMPLEX32;
+#endif
+
+#ifdef HAVE_CCTK_REAL8
+#define HAVE_CCTK_COMPLEX16 1
+typedef struct CCTK_COMPLEX16
+{
+ CCTK_REAL8 Re;
+ CCTK_REAL8 Im;
+#ifdef __cplusplus
+ CCTK_REAL8 real() const { return Re; }
+ CCTK_REAL8 imag() const { return Im; }
+#endif
+} CCTK_COMPLEX16;
+#endif
+
+#ifdef HAVE_CCTK_REAL4
+#define HAVE_CCTK_COMPLEX8 1
+typedef struct CCTK_COMPLEX8
+{
+ CCTK_REAL4 Re;
+ CCTK_REAL4 Im;
+#ifdef __cplusplus
+ CCTK_REAL4 real() const { return Re; }
+ CCTK_REAL4 imag() const { return Im; }
+#endif
+} CCTK_COMPLEX8;
+#endif
+
+/* Small positive integer type */
+typedef unsigned char CCTK_BYTE;
+#define HAVE_CCTK_BYTE 1
+
+/* Define stuff for fortran. */
+#ifdef FCODE
+
+#define CCTK_POINTER integer*SIZEOF_CHAR_P
+#define CCTK_POINTER_TO_CONST integer*SIZEOF_CHAR_P
+/* TODO: add autoconf for determining the size of function pointers */
+#define CCTK_FPOINTER integer*SIZEOF_CHAR_P
+#define HAVE_CCTK_POINTER 1
+#define HAVE_CCTK_POINTER_TO_CONST 1
+#define HAVE_CCTK_FPOINTER 1
+
+/* Character types */
+/* A single character does not exist in Fortran; in Fortran, all
+ character types are strings. Hence we do not define CCTK_CHAR. */
+/* #define CCTK_CHAR CHARACTER */
+/* #define HAVE_CCTK_CHAR 1 */
+/* This is a C-string, i.e., only a pointer */
+#define CCTK_STRING CCTK_POINTER_TO_CONST
+#define HAVE_CCTK_STRING 1
+
+#ifdef HAVE_CCTK_INT8
+#define CCTK_INT8 INTEGER*8
+#endif
+#ifdef HAVE_CCTK_INT4
+#define CCTK_INT4 INTEGER*4
+#endif
+#ifdef HAVE_CCTK_INT2
+#define CCTK_INT2 INTEGER*2
+#endif
+#ifdef HAVE_CCTK_INT1
+#define CCTK_INT1 INTEGER*1
+#endif
+
+#ifdef HAVE_CCTK_REAL16
+#define CCTK_REAL16 REAL*16
+#define HAVE_CCTK_COMPLEX32 1
+#define CCTK_COMPLEX32 COMPLEX*32
+#endif
+
+#ifdef HAVE_CCTK_REAL8
+#define CCTK_REAL8 REAL*8
+#define HAVE_CCTK_COMPLEX16 1
+#define CCTK_COMPLEX16 COMPLEX*16
+#endif
+
+#ifdef HAVE_CCTK_REAL4
+#define CCTK_REAL4 REAL*4
+#define HAVE_CCTK_COMPLEX8 1
+#define CCTK_COMPLEX8 COMPLEX*8
+#endif
+
+/* Should be unsigned, but Fortran doesn't have that */
+#define CCTK_BYTE INTEGER*1
+#define HAVE_CCTK_BYTE 1
+
+#endif /*FCODE */
+
+/* Now pick the types based upon the precision variable. */
+
+/* Floating point precision */
+#ifdef CCTK_REAL_PRECISION_16
+#define CCTK_REAL_PRECISION 16
+#define CCTK_REAL CCTK_REAL16
+#endif
+
+#ifdef CCTK_REAL_PRECISION_8
+#define CCTK_REAL_PRECISION 8
+#define CCTK_REAL CCTK_REAL8
+#endif
+
+#ifdef CCTK_REAL_PRECISION_4
+#define CCTK_REAL_PRECISION 4
+#define CCTK_REAL CCTK_REAL4
+#endif
+
+/* Integer precision */
+
+#ifdef CCTK_INTEGER_PRECISION_8
+#define CCTK_INTEGER_PRECISION 8
+#define CCTK_INT CCTK_INT8
+#endif
+
+#ifdef CCTK_INTEGER_PRECISION_4
+#define CCTK_INTEGER_PRECISION 4
+#define CCTK_INT CCTK_INT4
+#endif
+
+#ifdef CCTK_INTEGER_PRECISION_2
+#define CCTK_INTEGER_PRECISION 2
+#define CCTK_INT CCTK_INT2
+#endif
+
+#ifdef CCTK_INTEGER_PRECISION_1
+#define CCTK_INTEGER_PRECISION 1
+#define CCTK_INT CCTK_INT1
+#endif
+
+/* Complex precision */
+#ifdef CCTK_REAL_PRECISION_16
+#define CCTK_COMPLEX_PRECISION 32
+#define CCTK_COMPLEX CCTK_COMPLEX32
+#endif
+
+#ifdef CCTK_REAL_PRECISION_8
+#define CCTK_COMPLEX_PRECISION 16
+#define CCTK_COMPLEX CCTK_COMPLEX16
+#endif
+
+#ifdef CCTK_REAL_PRECISION_4
+#define CCTK_COMPLEX_PRECISION 8
+#define CCTK_COMPLEX CCTK_COMPLEX8
+#endif
+
+#endif /*_CCTK_TYPES_H_ */
+
diff --git a/AMSS_NCKU_source/config.h b/AMSS_NCKU_source/AHF_Direct/config.h
similarity index 95%
rename from AMSS_NCKU_source/config.h
rename to AMSS_NCKU_source/AHF_Direct/config.h
index 5cd90fe..0f1ba8d 100644
--- a/AMSS_NCKU_source/config.h
+++ b/AMSS_NCKU_source/AHF_Direct/config.h
@@ -1,16 +1,16 @@
-#ifndef AHFINDERDIRECT__CONFIG_H
-#define AHFINDERDIRECT__CONFIG_H
-
-#include
-#include
-#include
-#include
-
-size_t Util_Strlcat(char* dst, const char* src, size_t dst_size);
-size_t Util_Strlcpy(char* dst, const char* src, size_t dst_size);
-
-typedef CCTK_REAL fp;
-
-typedef CCTK_INT integer;
-
-#endif /* AHFINDERDIRECT__CONFIG_H */
+#ifndef AHFINDERDIRECT__CONFIG_H
+#define AHFINDERDIRECT__CONFIG_H
+
+#include
+#include
+#include
+#include
+
+size_t Util_Strlcat(char* dst, const char* src, size_t dst_size);
+size_t Util_Strlcpy(char* dst, const char* src, size_t dst_size);
+
+typedef CCTK_REAL fp;
+
+typedef CCTK_INT integer;
+
+#endif /* AHFINDERDIRECT__CONFIG_H */
diff --git a/AMSS_NCKU_source/coords.C b/AMSS_NCKU_source/AHF_Direct/coords.C
similarity index 96%
rename from AMSS_NCKU_source/coords.C
rename to AMSS_NCKU_source/AHF_Direct/coords.C
index 2058d94..98d30c2 100644
--- a/AMSS_NCKU_source/coords.C
+++ b/AMSS_NCKU_source/AHF_Direct/coords.C
@@ -1,533 +1,533 @@
-#include
-#include
-#include
-#include
-
-#include "cctk.h"
-
-#include "config.h"
-#include "stdc.h"
-#include "util.h"
-
-#include "coords.h"
-
-namespace AHFinderDirect
-{
- using jtutil::arctan_xy;
- using jtutil::error_exit;
- using jtutil::hypot3;
- using jtutil::pow2;
- using jtutil::signum;
-
- namespace local_coords
- {
-
- bool fuzzy_EQ_ang(fp ang1, fp ang2)
- {
- return jtutil::fuzzy::is_integer((ang2 - ang1) / (2.0 * PI));
- }
-
- bool fuzzy_EQ_dang(fp dang1, fp dang2)
- {
- return jtutil::fuzzy::is_integer((dang2 - dang1) / 360.0);
- }
-
- }
-
- namespace local_coords
- {
-
- fp modulo_reduce_ang(fp ang, fp min_ang, fp max_ang)
- {
- return jtutil::modulo_reduce(ang, 2.0 * PI, min_ang, max_ang);
- }
-
- fp modulo_reduce_dang(fp dang, fp min_dang, fp max_dang)
- {
- return jtutil::modulo_reduce(dang, 360.0, min_dang, max_dang);
- }
-
- }
-
- namespace local_coords
- {
- void xyz_of_r_mu_nu(fp r, fp mu, fp nu, fp &x, fp &y, fp &z)
- {
- const fp sign_y = signum(sin(mu));
- const fp sign_z_via_mu = signum(cos(mu));
- assert(jtutil::fuzzy::NE(cos(mu), 0.0));
- const fp y_over_z = tan(mu);
-
- const fp sign_x = signum(sin(nu));
- const fp sign_z_via_nu = signum(cos(nu));
- assert(jtutil::fuzzy::NE(cos(nu), 0.0));
- const fp x_over_z = tan(nu);
-
- // failure of next assert() ==> inconsistent input (mu,nu)
- assert(sign_z_via_mu == sign_z_via_nu);
- const fp sign_z = sign_z_via_mu;
-
- const fp temp = 1.0 / sqrt(1.0 + pow2(y_over_z) + pow2(x_over_z));
-
- z = sign_z * r * temp;
- x = x_over_z * z;
- y = y_over_z * z;
- }
- }
-
- namespace local_coords
- {
- void xyz_of_r_mu_phi(fp r, fp mu, fp phi, fp &x, fp &y, fp &z)
- {
- const fp mu_bar = 0.5 * PI - mu;
- const fp phi_bar = 0.5 * PI - phi;
-
- const fp sign_z = signum(sin(mu_bar));
- const fp sign_y_via_mu_bar = signum(cos(mu_bar));
- assert(jtutil::fuzzy::NE(cos(mu_bar), 0.0));
- const fp z_over_y = tan(mu_bar);
-
- const fp sign_x = signum(sin(phi_bar));
- const fp sign_y_via_phi_bar = signum(cos(phi_bar));
- assert(jtutil::fuzzy::NE(cos(phi_bar), 0.0));
- const fp x_over_y = tan(phi_bar);
-
- // failure of next assert() ==> inconsistent input (mu,phi)
- assert(sign_y_via_mu_bar == sign_y_via_phi_bar);
- const fp sign_y = sign_y_via_mu_bar;
-
- const fp temp = 1.0 / sqrt(1.0 + pow2(z_over_y) + pow2(x_over_y));
-
- y = sign_y * r * temp;
- z = z_over_y * y;
- x = x_over_y * y;
- }
- }
- namespace local_coords
- {
- void xyz_of_r_nu_phi(fp r, fp nu, fp phi, fp &x, fp &y, fp &z)
- {
- const fp nu_bar = 0.5 * PI - nu;
-
- const fp sign_z = signum(sin(nu_bar));
- const fp sign_x_via_nu_bar = signum(cos(nu_bar));
- assert(jtutil::fuzzy::NE(cos(nu_bar), 0.0));
- const fp z_over_x = tan(nu_bar);
-
- const fp sign_y = signum(sin(phi));
- const fp sign_x_via_phi = signum(cos(phi));
- assert(jtutil::fuzzy::NE(cos(phi), 0.0));
- const fp y_over_x = tan(phi);
-
- // failure of next assert() ==> inconsistent input (nu,phi)
- assert(sign_x_via_nu_bar == sign_x_via_phi);
- const fp sign_x = sign_x_via_nu_bar;
-
- const fp temp = 1.0 / sqrt(1.0 + pow2(z_over_x) + pow2(y_over_x));
-
- x = sign_x * r * temp;
- z = z_over_x * x;
- y = y_over_x * x;
- }
- }
- namespace local_coords
- {
- fp phi_of_mu_nu(fp mu, fp nu)
- {
- fp x, y, z;
- xyz_of_r_mu_nu(1.0, mu, nu, x, y, z);
- return phi_of_xy(x, y);
- }
- }
-
- namespace local_coords
- {
- fp nu_of_mu_phi(fp mu, fp phi)
- {
- fp x, y, z;
- xyz_of_r_mu_phi(1.0, mu, phi, x, y, z);
- return nu_of_xz(x, z);
- }
- }
-
- //**************************************
-
- // ill-conditioned near x axis
- // not valid in yz plane (sin(nu) == 0 || cos(phi) == 0)
- namespace local_coords
- {
- fp mu_of_nu_phi(fp nu, fp phi)
- {
- fp x, y, z;
- xyz_of_r_nu_phi(1.0, nu, phi, x, y, z);
- return mu_of_yz(y, z);
- }
- }
-
- //******************************************************************************
-
- namespace local_coords
- {
- fp r_of_xyz(fp x, fp y, fp z) { return hypot3(x, y, z); }
- fp mu_of_yz(fp y, fp z) { return arctan_xy(z, y); }
- fp nu_of_xz(fp x, fp z) { return arctan_xy(z, x); }
- fp phi_of_xy(fp x, fp y) { return arctan_xy(x, y); }
- }
-
- namespace local_coords
- {
- void partial_xyz_wrt_r_mu_nu(fp r, fp mu, fp nu,
- fp &partial_x_wrt_r, fp &partial_x_wrt_mu, fp &partial_x_wrt_nu,
- fp &partial_y_wrt_r, fp &partial_y_wrt_mu, fp &partial_y_wrt_nu,
- fp &partial_z_wrt_r, fp &partial_z_wrt_mu, fp &partial_z_wrt_nu)
- {
- const fp tan_mu = tan(mu);
- const fp tan_nu = tan(nu);
- const fp tan2_mu = pow2(tan_mu);
- const fp tan2_nu = pow2(tan_nu);
-
- fp x, y, z;
- xyz_of_r_mu_nu(r, mu, nu, x, y, z);
-
- assert(jtutil::fuzzy::NE(r, 0.0));
- const fp rinv = 1.0 / r;
- partial_x_wrt_r = x * rinv;
- partial_y_wrt_r = y * rinv;
- partial_z_wrt_r = z * rinv;
-
- const fp t = 1 + tan2_mu + tan2_nu; // = $r^2/z^2$
- const fp partial_t_wrt_mu = 2.0 * tan_mu * (1.0 + tan2_mu);
- const fp partial_t_wrt_nu = 2.0 * tan_nu * (1.0 + tan2_nu);
-
- const fp r2_over_zt2 = (r * r) / (z * t * t);
- partial_z_wrt_mu = -0.5 * r2_over_zt2 * partial_t_wrt_mu;
- partial_z_wrt_nu = -0.5 * r2_over_zt2 * partial_t_wrt_nu;
-
- partial_x_wrt_mu = tan_nu * partial_z_wrt_mu;
- partial_x_wrt_nu = tan_nu * partial_z_wrt_nu + z * (1.0 + tan2_nu);
- partial_y_wrt_mu = tan_mu * partial_z_wrt_mu + z * (1.0 + tan2_mu);
- partial_y_wrt_nu = tan_mu * partial_z_wrt_nu;
- }
- }
-
- //**************************************
-
- namespace local_coords
- {
- void partial_xyz_wrt_r_mu_phi(fp r, fp mu, fp phi,
- fp &partial_x_wrt_r, fp &partial_x_wrt_mu, fp &partial_x_wrt_phi,
- fp &partial_y_wrt_r, fp &partial_y_wrt_mu, fp &partial_y_wrt_phi,
- fp &partial_z_wrt_r, fp &partial_z_wrt_mu, fp &partial_z_wrt_phi)
- {
- const fp mu_bar = 0.5 * PI - mu;
- const fp phi_bar = 0.5 * PI - phi;
-
- const fp tan_mu_bar = tan(mu_bar);
- const fp tan_phi_bar = tan(phi_bar);
- const fp tan2_mu_bar = pow2(tan_mu_bar);
- const fp tan2_phi_bar = pow2(tan_phi_bar);
-
- fp x, y, z;
- xyz_of_r_mu_phi(r, mu, phi, x, y, z);
-
- assert(jtutil::fuzzy::NE(r, 0.0));
- const fp rinv = 1.0 / r;
- partial_x_wrt_r = x * rinv;
- partial_y_wrt_r = y * rinv;
- partial_z_wrt_r = z * rinv;
-
- const fp t = 1 + tan2_mu_bar + tan2_phi_bar; // = $r^2/y^2$
- const fp partial_t_wrt_mu_bar = 2.0 * tan_mu_bar * (1.0 + tan2_mu_bar);
- const fp partial_t_wrt_phi_bar = 2.0 * tan_phi_bar * (1.0 + tan2_phi_bar);
-
- const fp r2_over_yt2 = (r * r) / (y * t * t);
- partial_y_wrt_mu = 0.5 * r2_over_yt2 * partial_t_wrt_mu_bar;
- partial_y_wrt_phi = 0.5 * r2_over_yt2 * partial_t_wrt_phi_bar;
-
- partial_x_wrt_mu = tan_phi_bar * partial_y_wrt_mu;
- partial_x_wrt_phi = tan_phi_bar * partial_y_wrt_phi - y * (1.0 + tan2_phi_bar);
- partial_z_wrt_mu = tan_mu_bar * partial_y_wrt_mu - y * (1.0 + tan2_mu_bar);
- partial_z_wrt_phi = tan_mu_bar * partial_y_wrt_phi;
- }
- }
-
- //**************************************
-
- namespace local_coords
- {
- void partial_xyz_wrt_r_nu_phi(fp r, fp nu, fp phi,
- fp &partial_x_wrt_r, fp &partial_x_wrt_nu, fp &partial_x_wrt_phi,
- fp &partial_y_wrt_r, fp &partial_y_wrt_nu, fp &partial_y_wrt_phi,
- fp &partial_z_wrt_r, fp &partial_z_wrt_nu, fp &partial_z_wrt_phi)
- {
- const fp nu_bar = 0.5 * PI - nu;
-
- const fp tan_nu_bar = tan(nu_bar);
- const fp tan_phi = tan(phi);
- const fp tan2_nu_bar = pow2(tan_nu_bar);
- const fp tan2_phi = pow2(tan_phi);
-
- fp x, y, z;
- xyz_of_r_nu_phi(r, nu, phi, x, y, z);
-
- assert(jtutil::fuzzy::NE(r, 0.0));
- const fp rinv = 1.0 / r;
- partial_x_wrt_r = x * rinv;
- partial_y_wrt_r = y * rinv;
- partial_z_wrt_r = z * rinv;
-
- const fp t = 1 + tan2_nu_bar + tan2_phi; // = $r^2/x^2$
- const fp partial_t_wrt_nu_bar = 2.0 * tan_nu_bar * (1.0 + tan2_nu_bar);
- const fp partial_t_wrt_phi = 2.0 * tan_phi * (1.0 + tan2_phi);
-
- const fp r2_over_xt2 = (r * r) / (x * t * t);
- partial_x_wrt_nu = 0.5 * r2_over_xt2 * partial_t_wrt_nu_bar;
- partial_x_wrt_phi = -0.5 * r2_over_xt2 * partial_t_wrt_phi;
-
- partial_y_wrt_nu = tan_phi * partial_x_wrt_nu;
- partial_y_wrt_phi = tan_phi * partial_x_wrt_phi + x * (1.0 + tan2_phi);
- partial_z_wrt_nu = tan_nu_bar * partial_x_wrt_nu - x * (1.0 + tan2_nu_bar);
- partial_z_wrt_phi = tan_nu_bar * partial_x_wrt_phi;
- }
- }
-
- //******************************************************************************
-
- //
- // these functions compute the partial derivatives
- // partial {mu,nu,phi} / partial {x,y,z}
- // as computed by the maple file "coord_derivs.{maple,out}" in this directory
- //
- namespace local_coords
- {
- fp partial_mu_wrt_y(fp y, fp z) { return z / (y * y + z * z); }
- fp partial_mu_wrt_z(fp y, fp z) { return -y / (y * y + z * z); }
-
- fp partial_nu_wrt_x(fp x, fp z) { return z / (x * x + z * z); }
- fp partial_nu_wrt_z(fp x, fp z) { return -x / (x * x + z * z); }
-
- fp partial_phi_wrt_x(fp x, fp y) { return -y / (x * x + y * y); }
- fp partial_phi_wrt_y(fp x, fp y) { return x / (x * x + y * y); }
- }
-
- //******************************************************************************
-
- //
- // these functions compute the 2nd partial derivatives
- // partial {mu,nu,phi} / partial {xx,xy,xz,yy,yz,zz}
- // as computed by the maple file "coord_derivs.{maple,out}" in this directory
- //
- namespace local_coords
- {
- fp partial2_mu_wrt_yy(fp y, fp z) { return -2.0 * y * z / pow2(y * y + z * z); }
- fp partial2_mu_wrt_yz(fp y, fp z) { return (y * y - z * z) / pow2(y * y + z * z); }
- fp partial2_mu_wrt_zz(fp y, fp z) { return 2.0 * y * z / pow2(y * y + z * z); }
-
- fp partial2_nu_wrt_xx(fp x, fp z) { return -2.0 * x * z / pow2(x * x + z * z); }
- fp partial2_nu_wrt_xz(fp x, fp z) { return (x * x - z * z) / pow2(x * x + z * z); }
- fp partial2_nu_wrt_zz(fp x, fp z) { return 2.0 * x * z / pow2(x * x + z * z); }
-
- fp partial2_phi_wrt_xx(fp x, fp y) { return 2.0 * x * y / pow2(x * x + y * y); }
- fp partial2_phi_wrt_xy(fp x, fp y) { return (y * y - x * x) / pow2(x * x + y * y); }
- fp partial2_phi_wrt_yy(fp x, fp y) { return -2.0 * x * y / pow2(x * x + y * y); }
- }
-
- namespace local_coords
- {
- void xyz_of_r_theta_phi(fp r, fp theta, fp phi, fp &x, fp &y, fp &z)
- {
- z = r * cos(theta);
- x = r * sin(theta) * cos(phi);
- y = r * sin(theta) * sin(phi);
- }
- }
-
- //**************************************
-
- namespace local_coords
- {
- void r_theta_phi_of_xyz(fp x, fp y, fp z, fp &r, fp &theta, fp &phi)
- {
- r = r_of_xyz(x, y, z);
- theta = theta_of_xyz(x, y, z);
- phi = phi_of_xy(x, y);
- }
- }
-
- //**************************************
-
- namespace local_coords
- {
- fp theta_of_xyz(fp x, fp y, fp z)
- {
- return arctan_xy(z, hypot(x, y));
- }
- }
-
- //******************************************************************************
-
- //
- // these functions convert ((mu,nu,phi)) <--> usual polar spherical (theta,phi)
- // ... note phi is the same coordinate in both systems
- //
-
- namespace local_coords
- {
- void theta_phi_of_mu_nu(fp mu, fp nu, fp &ps_theta, fp &ps_phi)
- {
- fp x, y, z;
- xyz_of_r_mu_nu(1.0, mu, nu, x, y, z);
-
- ps_theta = theta_of_xyz(x, y, z);
- ps_phi = phi_of_xy(x, y);
- }
- }
-
- //**************************************
-
- // Bugs: computes ps_phi via trig, even though it's trivially == phi
- namespace local_coords
- {
- void theta_phi_of_mu_phi(fp mu, fp phi, fp &ps_theta, fp &ps_phi)
- {
- fp x, y, z;
- xyz_of_r_mu_phi(1.0, mu, phi, x, y, z);
-
- ps_theta = theta_of_xyz(x, y, z);
- ps_phi = phi_of_xy(x, y);
- assert(fuzzy_EQ_ang(ps_phi, phi));
- }
- }
-
- //**************************************
-
- // Bugs: computes ps_phi via trig, even though it's trivially == phi
- namespace local_coords
- {
- void theta_phi_of_nu_phi(fp nu, fp phi, fp &ps_theta, fp &ps_phi)
- {
- fp x, y, z;
- xyz_of_r_nu_phi(1.0, nu, phi, x, y, z);
-
- ps_theta = theta_of_xyz(x, y, z);
- ps_phi = phi_of_xy(x, y);
- assert(fuzzy_EQ_ang(ps_phi, phi));
- }
- }
-
- //******************************************************************************
-
- namespace local_coords
- {
- void mu_nu_of_theta_phi(fp ps_theta, fp ps_phi, fp &mu, fp &nu)
- {
- fp x, y, z;
- xyz_of_r_theta_phi(1.0, ps_theta, ps_phi, x, y, z);
-
- mu = mu_of_yz(y, z);
- nu = nu_of_xz(x, z);
- }
- }
-
- //**************************************
-
- // Bugs: computes phi via trig, even though it's trivially == ps_phi
- namespace local_coords
- {
- void mu_phi_of_theta_phi(fp ps_theta, fp ps_phi, fp &mu, fp &phi)
- {
- fp x, y, z;
- xyz_of_r_theta_phi(1.0, ps_theta, ps_phi, x, y, z);
-
- mu = mu_of_yz(y, z);
- phi = phi_of_xy(x, y);
- assert(fuzzy_EQ_ang(phi, ps_phi));
- }
- }
-
- //**************************************
-
- // Bugs: computes phi via trig, even though it's trivially == ps_phi
- namespace local_coords
- {
- void nu_phi_of_theta_phi(fp ps_theta, fp ps_phi, fp &nu, fp &phi)
- {
- fp x, y, z;
- xyz_of_r_theta_phi(1.0, ps_theta, ps_phi, x, y, z);
-
- nu = nu_of_xz(x, z);
- phi = phi_of_xy(x, y);
- assert(fuzzy_EQ_ang(phi, ps_phi));
- }
- }
-
- //******************************************************************************
-
- //
- // these functions convert ((mu,nu,phi)) to the direction cosines
- // (xcos,ycos,zcos)
- //
-
- namespace local_coords
- {
- void xyzcos_of_mu_nu(fp mu, fp nu, fp &xcos, fp &ycos, fp &zcos)
- {
- xyz_of_r_mu_nu(1.0, mu, nu, xcos, ycos, zcos);
- }
- }
-
- namespace local_coords
- {
- void xyzcos_of_mu_phi(fp mu, fp phi, fp &xcos, fp &ycos, fp &zcos)
- {
- xyz_of_r_mu_phi(1.0, mu, phi, xcos, ycos, zcos);
- }
- }
-
- namespace local_coords
- {
- void xyzcos_of_nu_phi(fp nu, fp phi, fp &xcos, fp &ycos, fp &zcos)
- {
- xyz_of_r_nu_phi(1.0, nu, phi, xcos, ycos, zcos);
- }
- }
-
- //******************************************************************************
- //******************************************************************************
- //******************************************************************************
-
- //
- // This function computes a human-readable name from a (mu,nu,phi)
- // coordinates set.
- //
- const char *local_coords::name_of_coords_set(coords_set S)
- {
- //
- // we have to use an if-else chain because the local_coords::set_*
- // constants aren't compile-time constants and hence aren't eligible
- // to be switch case labels
- //
- if (S == coords_set_empty)
- then return "{}";
- else if (S == coords_set_mu)
- then return "mu";
- else if (S == coords_set_nu)
- then return "nu";
- else if (S == coords_set_phi)
- then return "phi";
- else if (S == coords_set_mu | coords_set_nu)
- then return "{mu,nu}";
- else if (S == coords_set_mu | coords_set_phi)
- then return "{mu,phi}";
- else if (S == coords_set_nu | coords_set_phi)
- then return "{nu,phi}";
- else if (S == coords_set_mu | coords_set_nu | coords_set_phi)
- then return "{mu,nu,phi}";
- else
- error_exit(PANIC_EXIT,
- "***** local_coords::mu_nu_phi::name_of_coords_set:\n"
- " S=0x%x isn't a valid coords_set bit vector!\n",
- int(S)); /*NOTREACHED*/
- }
-
-} // namespace AHFinderDirect
+#include
+#include
+#include
+#include
+
+#include "cctk.h"
+
+#include "config.h"
+#include "stdc.h"
+#include "util.h"
+
+#include "coords.h"
+
+namespace AHFinderDirect
+{
+ using jtutil::arctan_xy;
+ using jtutil::error_exit;
+ using jtutil::hypot3;
+ using jtutil::pow2;
+ using jtutil::signum;
+
+ namespace local_coords
+ {
+
+ bool fuzzy_EQ_ang(fp ang1, fp ang2)
+ {
+ return jtutil::fuzzy::is_integer((ang2 - ang1) / (2.0 * PI));
+ }
+
+ bool fuzzy_EQ_dang(fp dang1, fp dang2)
+ {
+ return jtutil::fuzzy::is_integer((dang2 - dang1) / 360.0);
+ }
+
+ }
+
+ namespace local_coords
+ {
+
+ fp modulo_reduce_ang(fp ang, fp min_ang, fp max_ang)
+ {
+ return jtutil::modulo_reduce(ang, 2.0 * PI, min_ang, max_ang);
+ }
+
+ fp modulo_reduce_dang(fp dang, fp min_dang, fp max_dang)
+ {
+ return jtutil::modulo_reduce(dang, 360.0, min_dang, max_dang);
+ }
+
+ }
+
+ namespace local_coords
+ {
+ void xyz_of_r_mu_nu(fp r, fp mu, fp nu, fp &x, fp &y, fp &z)
+ {
+ const fp sign_y = signum(sin(mu));
+ const fp sign_z_via_mu = signum(cos(mu));
+ assert(jtutil::fuzzy::NE(cos(mu), 0.0));
+ const fp y_over_z = tan(mu);
+
+ const fp sign_x = signum(sin(nu));
+ const fp sign_z_via_nu = signum(cos(nu));
+ assert(jtutil::fuzzy::NE(cos(nu), 0.0));
+ const fp x_over_z = tan(nu);
+
+ // failure of next assert() ==> inconsistent input (mu,nu)
+ assert(sign_z_via_mu == sign_z_via_nu);
+ const fp sign_z = sign_z_via_mu;
+
+ const fp temp = 1.0 / sqrt(1.0 + pow2(y_over_z) + pow2(x_over_z));
+
+ z = sign_z * r * temp;
+ x = x_over_z * z;
+ y = y_over_z * z;
+ }
+ }
+
+ namespace local_coords
+ {
+ void xyz_of_r_mu_phi(fp r, fp mu, fp phi, fp &x, fp &y, fp &z)
+ {
+ const fp mu_bar = 0.5 * PI - mu;
+ const fp phi_bar = 0.5 * PI - phi;
+
+ const fp sign_z = signum(sin(mu_bar));
+ const fp sign_y_via_mu_bar = signum(cos(mu_bar));
+ assert(jtutil::fuzzy::NE(cos(mu_bar), 0.0));
+ const fp z_over_y = tan(mu_bar);
+
+ const fp sign_x = signum(sin(phi_bar));
+ const fp sign_y_via_phi_bar = signum(cos(phi_bar));
+ assert(jtutil::fuzzy::NE(cos(phi_bar), 0.0));
+ const fp x_over_y = tan(phi_bar);
+
+ // failure of next assert() ==> inconsistent input (mu,phi)
+ assert(sign_y_via_mu_bar == sign_y_via_phi_bar);
+ const fp sign_y = sign_y_via_mu_bar;
+
+ const fp temp = 1.0 / sqrt(1.0 + pow2(z_over_y) + pow2(x_over_y));
+
+ y = sign_y * r * temp;
+ z = z_over_y * y;
+ x = x_over_y * y;
+ }
+ }
+ namespace local_coords
+ {
+ void xyz_of_r_nu_phi(fp r, fp nu, fp phi, fp &x, fp &y, fp &z)
+ {
+ const fp nu_bar = 0.5 * PI - nu;
+
+ const fp sign_z = signum(sin(nu_bar));
+ const fp sign_x_via_nu_bar = signum(cos(nu_bar));
+ assert(jtutil::fuzzy::NE(cos(nu_bar), 0.0));
+ const fp z_over_x = tan(nu_bar);
+
+ const fp sign_y = signum(sin(phi));
+ const fp sign_x_via_phi = signum(cos(phi));
+ assert(jtutil::fuzzy::NE(cos(phi), 0.0));
+ const fp y_over_x = tan(phi);
+
+ // failure of next assert() ==> inconsistent input (nu,phi)
+ assert(sign_x_via_nu_bar == sign_x_via_phi);
+ const fp sign_x = sign_x_via_nu_bar;
+
+ const fp temp = 1.0 / sqrt(1.0 + pow2(z_over_x) + pow2(y_over_x));
+
+ x = sign_x * r * temp;
+ z = z_over_x * x;
+ y = y_over_x * x;
+ }
+ }
+ namespace local_coords
+ {
+ fp phi_of_mu_nu(fp mu, fp nu)
+ {
+ fp x, y, z;
+ xyz_of_r_mu_nu(1.0, mu, nu, x, y, z);
+ return phi_of_xy(x, y);
+ }
+ }
+
+ namespace local_coords
+ {
+ fp nu_of_mu_phi(fp mu, fp phi)
+ {
+ fp x, y, z;
+ xyz_of_r_mu_phi(1.0, mu, phi, x, y, z);
+ return nu_of_xz(x, z);
+ }
+ }
+
+ //**************************************
+
+ // ill-conditioned near x axis
+ // not valid in yz plane (sin(nu) == 0 || cos(phi) == 0)
+ namespace local_coords
+ {
+ fp mu_of_nu_phi(fp nu, fp phi)
+ {
+ fp x, y, z;
+ xyz_of_r_nu_phi(1.0, nu, phi, x, y, z);
+ return mu_of_yz(y, z);
+ }
+ }
+
+ //******************************************************************************
+
+ namespace local_coords
+ {
+ fp r_of_xyz(fp x, fp y, fp z) { return hypot3(x, y, z); }
+ fp mu_of_yz(fp y, fp z) { return arctan_xy(z, y); }
+ fp nu_of_xz(fp x, fp z) { return arctan_xy(z, x); }
+ fp phi_of_xy(fp x, fp y) { return arctan_xy(x, y); }
+ }
+
+ namespace local_coords
+ {
+ void partial_xyz_wrt_r_mu_nu(fp r, fp mu, fp nu,
+ fp &partial_x_wrt_r, fp &partial_x_wrt_mu, fp &partial_x_wrt_nu,
+ fp &partial_y_wrt_r, fp &partial_y_wrt_mu, fp &partial_y_wrt_nu,
+ fp &partial_z_wrt_r, fp &partial_z_wrt_mu, fp &partial_z_wrt_nu)
+ {
+ const fp tan_mu = tan(mu);
+ const fp tan_nu = tan(nu);
+ const fp tan2_mu = pow2(tan_mu);
+ const fp tan2_nu = pow2(tan_nu);
+
+ fp x, y, z;
+ xyz_of_r_mu_nu(r, mu, nu, x, y, z);
+
+ assert(jtutil::fuzzy::NE(r, 0.0));
+ const fp rinv = 1.0 / r;
+ partial_x_wrt_r = x * rinv;
+ partial_y_wrt_r = y * rinv;
+ partial_z_wrt_r = z * rinv;
+
+ const fp t = 1 + tan2_mu + tan2_nu; // = $r^2/z^2$
+ const fp partial_t_wrt_mu = 2.0 * tan_mu * (1.0 + tan2_mu);
+ const fp partial_t_wrt_nu = 2.0 * tan_nu * (1.0 + tan2_nu);
+
+ const fp r2_over_zt2 = (r * r) / (z * t * t);
+ partial_z_wrt_mu = -0.5 * r2_over_zt2 * partial_t_wrt_mu;
+ partial_z_wrt_nu = -0.5 * r2_over_zt2 * partial_t_wrt_nu;
+
+ partial_x_wrt_mu = tan_nu * partial_z_wrt_mu;
+ partial_x_wrt_nu = tan_nu * partial_z_wrt_nu + z * (1.0 + tan2_nu);
+ partial_y_wrt_mu = tan_mu * partial_z_wrt_mu + z * (1.0 + tan2_mu);
+ partial_y_wrt_nu = tan_mu * partial_z_wrt_nu;
+ }
+ }
+
+ //**************************************
+
+ namespace local_coords
+ {
+ void partial_xyz_wrt_r_mu_phi(fp r, fp mu, fp phi,
+ fp &partial_x_wrt_r, fp &partial_x_wrt_mu, fp &partial_x_wrt_phi,
+ fp &partial_y_wrt_r, fp &partial_y_wrt_mu, fp &partial_y_wrt_phi,
+ fp &partial_z_wrt_r, fp &partial_z_wrt_mu, fp &partial_z_wrt_phi)
+ {
+ const fp mu_bar = 0.5 * PI - mu;
+ const fp phi_bar = 0.5 * PI - phi;
+
+ const fp tan_mu_bar = tan(mu_bar);
+ const fp tan_phi_bar = tan(phi_bar);
+ const fp tan2_mu_bar = pow2(tan_mu_bar);
+ const fp tan2_phi_bar = pow2(tan_phi_bar);
+
+ fp x, y, z;
+ xyz_of_r_mu_phi(r, mu, phi, x, y, z);
+
+ assert(jtutil::fuzzy::NE(r, 0.0));
+ const fp rinv = 1.0 / r;
+ partial_x_wrt_r = x * rinv;
+ partial_y_wrt_r = y * rinv;
+ partial_z_wrt_r = z * rinv;
+
+ const fp t = 1 + tan2_mu_bar + tan2_phi_bar; // = $r^2/y^2$
+ const fp partial_t_wrt_mu_bar = 2.0 * tan_mu_bar * (1.0 + tan2_mu_bar);
+ const fp partial_t_wrt_phi_bar = 2.0 * tan_phi_bar * (1.0 + tan2_phi_bar);
+
+ const fp r2_over_yt2 = (r * r) / (y * t * t);
+ partial_y_wrt_mu = 0.5 * r2_over_yt2 * partial_t_wrt_mu_bar;
+ partial_y_wrt_phi = 0.5 * r2_over_yt2 * partial_t_wrt_phi_bar;
+
+ partial_x_wrt_mu = tan_phi_bar * partial_y_wrt_mu;
+ partial_x_wrt_phi = tan_phi_bar * partial_y_wrt_phi - y * (1.0 + tan2_phi_bar);
+ partial_z_wrt_mu = tan_mu_bar * partial_y_wrt_mu - y * (1.0 + tan2_mu_bar);
+ partial_z_wrt_phi = tan_mu_bar * partial_y_wrt_phi;
+ }
+ }
+
+ //**************************************
+
+ namespace local_coords
+ {
+ void partial_xyz_wrt_r_nu_phi(fp r, fp nu, fp phi,
+ fp &partial_x_wrt_r, fp &partial_x_wrt_nu, fp &partial_x_wrt_phi,
+ fp &partial_y_wrt_r, fp &partial_y_wrt_nu, fp &partial_y_wrt_phi,
+ fp &partial_z_wrt_r, fp &partial_z_wrt_nu, fp &partial_z_wrt_phi)
+ {
+ const fp nu_bar = 0.5 * PI - nu;
+
+ const fp tan_nu_bar = tan(nu_bar);
+ const fp tan_phi = tan(phi);
+ const fp tan2_nu_bar = pow2(tan_nu_bar);
+ const fp tan2_phi = pow2(tan_phi);
+
+ fp x, y, z;
+ xyz_of_r_nu_phi(r, nu, phi, x, y, z);
+
+ assert(jtutil::fuzzy::NE(r, 0.0));
+ const fp rinv = 1.0 / r;
+ partial_x_wrt_r = x * rinv;
+ partial_y_wrt_r = y * rinv;
+ partial_z_wrt_r = z * rinv;
+
+ const fp t = 1 + tan2_nu_bar + tan2_phi; // = $r^2/x^2$
+ const fp partial_t_wrt_nu_bar = 2.0 * tan_nu_bar * (1.0 + tan2_nu_bar);
+ const fp partial_t_wrt_phi = 2.0 * tan_phi * (1.0 + tan2_phi);
+
+ const fp r2_over_xt2 = (r * r) / (x * t * t);
+ partial_x_wrt_nu = 0.5 * r2_over_xt2 * partial_t_wrt_nu_bar;
+ partial_x_wrt_phi = -0.5 * r2_over_xt2 * partial_t_wrt_phi;
+
+ partial_y_wrt_nu = tan_phi * partial_x_wrt_nu;
+ partial_y_wrt_phi = tan_phi * partial_x_wrt_phi + x * (1.0 + tan2_phi);
+ partial_z_wrt_nu = tan_nu_bar * partial_x_wrt_nu - x * (1.0 + tan2_nu_bar);
+ partial_z_wrt_phi = tan_nu_bar * partial_x_wrt_phi;
+ }
+ }
+
+ //******************************************************************************
+
+ //
+ // these functions compute the partial derivatives
+ // partial {mu,nu,phi} / partial {x,y,z}
+ // as computed by the maple file "coord_derivs.{maple,out}" in this directory
+ //
+ namespace local_coords
+ {
+ fp partial_mu_wrt_y(fp y, fp z) { return z / (y * y + z * z); }
+ fp partial_mu_wrt_z(fp y, fp z) { return -y / (y * y + z * z); }
+
+ fp partial_nu_wrt_x(fp x, fp z) { return z / (x * x + z * z); }
+ fp partial_nu_wrt_z(fp x, fp z) { return -x / (x * x + z * z); }
+
+ fp partial_phi_wrt_x(fp x, fp y) { return -y / (x * x + y * y); }
+ fp partial_phi_wrt_y(fp x, fp y) { return x / (x * x + y * y); }
+ }
+
+ //******************************************************************************
+
+ //
+ // these functions compute the 2nd partial derivatives
+ // partial {mu,nu,phi} / partial {xx,xy,xz,yy,yz,zz}
+ // as computed by the maple file "coord_derivs.{maple,out}" in this directory
+ //
+ namespace local_coords
+ {
+ fp partial2_mu_wrt_yy(fp y, fp z) { return -2.0 * y * z / pow2(y * y + z * z); }
+ fp partial2_mu_wrt_yz(fp y, fp z) { return (y * y - z * z) / pow2(y * y + z * z); }
+ fp partial2_mu_wrt_zz(fp y, fp z) { return 2.0 * y * z / pow2(y * y + z * z); }
+
+ fp partial2_nu_wrt_xx(fp x, fp z) { return -2.0 * x * z / pow2(x * x + z * z); }
+ fp partial2_nu_wrt_xz(fp x, fp z) { return (x * x - z * z) / pow2(x * x + z * z); }
+ fp partial2_nu_wrt_zz(fp x, fp z) { return 2.0 * x * z / pow2(x * x + z * z); }
+
+ fp partial2_phi_wrt_xx(fp x, fp y) { return 2.0 * x * y / pow2(x * x + y * y); }
+ fp partial2_phi_wrt_xy(fp x, fp y) { return (y * y - x * x) / pow2(x * x + y * y); }
+ fp partial2_phi_wrt_yy(fp x, fp y) { return -2.0 * x * y / pow2(x * x + y * y); }
+ }
+
+ namespace local_coords
+ {
+ void xyz_of_r_theta_phi(fp r, fp theta, fp phi, fp &x, fp &y, fp &z)
+ {
+ z = r * cos(theta);
+ x = r * sin(theta) * cos(phi);
+ y = r * sin(theta) * sin(phi);
+ }
+ }
+
+ //**************************************
+
+ namespace local_coords
+ {
+ void r_theta_phi_of_xyz(fp x, fp y, fp z, fp &r, fp &theta, fp &phi)
+ {
+ r = r_of_xyz(x, y, z);
+ theta = theta_of_xyz(x, y, z);
+ phi = phi_of_xy(x, y);
+ }
+ }
+
+ //**************************************
+
+ namespace local_coords
+ {
+ fp theta_of_xyz(fp x, fp y, fp z)
+ {
+ return arctan_xy(z, hypot(x, y));
+ }
+ }
+
+ //******************************************************************************
+
+ //
+ // these functions convert ((mu,nu,phi)) <--> usual polar spherical (theta,phi)
+ // ... note phi is the same coordinate in both systems
+ //
+
+ namespace local_coords
+ {
+ void theta_phi_of_mu_nu(fp mu, fp nu, fp &ps_theta, fp &ps_phi)
+ {
+ fp x, y, z;
+ xyz_of_r_mu_nu(1.0, mu, nu, x, y, z);
+
+ ps_theta = theta_of_xyz(x, y, z);
+ ps_phi = phi_of_xy(x, y);
+ }
+ }
+
+ //**************************************
+
+ // Bugs: computes ps_phi via trig, even though it's trivially == phi
+ namespace local_coords
+ {
+ void theta_phi_of_mu_phi(fp mu, fp phi, fp &ps_theta, fp &ps_phi)
+ {
+ fp x, y, z;
+ xyz_of_r_mu_phi(1.0, mu, phi, x, y, z);
+
+ ps_theta = theta_of_xyz(x, y, z);
+ ps_phi = phi_of_xy(x, y);
+ assert(fuzzy_EQ_ang(ps_phi, phi));
+ }
+ }
+
+ //**************************************
+
+ // Bugs: computes ps_phi via trig, even though it's trivially == phi
+ namespace local_coords
+ {
+ void theta_phi_of_nu_phi(fp nu, fp phi, fp &ps_theta, fp &ps_phi)
+ {
+ fp x, y, z;
+ xyz_of_r_nu_phi(1.0, nu, phi, x, y, z);
+
+ ps_theta = theta_of_xyz(x, y, z);
+ ps_phi = phi_of_xy(x, y);
+ assert(fuzzy_EQ_ang(ps_phi, phi));
+ }
+ }
+
+ //******************************************************************************
+
+ namespace local_coords
+ {
+ void mu_nu_of_theta_phi(fp ps_theta, fp ps_phi, fp &mu, fp &nu)
+ {
+ fp x, y, z;
+ xyz_of_r_theta_phi(1.0, ps_theta, ps_phi, x, y, z);
+
+ mu = mu_of_yz(y, z);
+ nu = nu_of_xz(x, z);
+ }
+ }
+
+ //**************************************
+
+ // Bugs: computes phi via trig, even though it's trivially == ps_phi
+ namespace local_coords
+ {
+ void mu_phi_of_theta_phi(fp ps_theta, fp ps_phi, fp &mu, fp &phi)
+ {
+ fp x, y, z;
+ xyz_of_r_theta_phi(1.0, ps_theta, ps_phi, x, y, z);
+
+ mu = mu_of_yz(y, z);
+ phi = phi_of_xy(x, y);
+ assert(fuzzy_EQ_ang(phi, ps_phi));
+ }
+ }
+
+ //**************************************
+
+ // Bugs: computes phi via trig, even though it's trivially == ps_phi
+ namespace local_coords
+ {
+ void nu_phi_of_theta_phi(fp ps_theta, fp ps_phi, fp &nu, fp &phi)
+ {
+ fp x, y, z;
+ xyz_of_r_theta_phi(1.0, ps_theta, ps_phi, x, y, z);
+
+ nu = nu_of_xz(x, z);
+ phi = phi_of_xy(x, y);
+ assert(fuzzy_EQ_ang(phi, ps_phi));
+ }
+ }
+
+ //******************************************************************************
+
+ //
+ // these functions convert ((mu,nu,phi)) to the direction cosines
+ // (xcos,ycos,zcos)
+ //
+
+ namespace local_coords
+ {
+ void xyzcos_of_mu_nu(fp mu, fp nu, fp &xcos, fp &ycos, fp &zcos)
+ {
+ xyz_of_r_mu_nu(1.0, mu, nu, xcos, ycos, zcos);
+ }
+ }
+
+ namespace local_coords
+ {
+ void xyzcos_of_mu_phi(fp mu, fp phi, fp &xcos, fp &ycos, fp &zcos)
+ {
+ xyz_of_r_mu_phi(1.0, mu, phi, xcos, ycos, zcos);
+ }
+ }
+
+ namespace local_coords
+ {
+ void xyzcos_of_nu_phi(fp nu, fp phi, fp &xcos, fp &ycos, fp &zcos)
+ {
+ xyz_of_r_nu_phi(1.0, nu, phi, xcos, ycos, zcos);
+ }
+ }
+
+ //******************************************************************************
+ //******************************************************************************
+ //******************************************************************************
+
+ //
+ // This function computes a human-readable name from a (mu,nu,phi)
+ // coordinates set.
+ //
+ const char *local_coords::name_of_coords_set(coords_set S)
+ {
+ //
+ // we have to use an if-else chain because the local_coords::set_*
+ // constants aren't compile-time constants and hence aren't eligible
+ // to be switch case labels
+ //
+ if (S == coords_set_empty)
+ then return "{}";
+ else if (S == coords_set_mu)
+ then return "mu";
+ else if (S == coords_set_nu)
+ then return "nu";
+ else if (S == coords_set_phi)
+ then return "phi";
+ else if (S == coords_set_mu | coords_set_nu)
+ then return "{mu,nu}";
+ else if (S == coords_set_mu | coords_set_phi)
+ then return "{mu,phi}";
+ else if (S == coords_set_nu | coords_set_phi)
+ then return "{nu,phi}";
+ else if (S == coords_set_mu | coords_set_nu | coords_set_phi)
+ then return "{mu,nu,phi}";
+ else
+ error_exit(PANIC_EXIT,
+ "***** local_coords::mu_nu_phi::name_of_coords_set:\n"
+ " S=0x%x isn't a valid coords_set bit vector!\n",
+ int(S)); /*NOTREACHED*/
+ }
+
+} // namespace AHFinderDirect
diff --git a/AMSS_NCKU_source/coords.h b/AMSS_NCKU_source/AHF_Direct/coords.h
similarity index 97%
rename from AMSS_NCKU_source/coords.h
rename to AMSS_NCKU_source/AHF_Direct/coords.h
index c93ddab..8c3c630 100644
--- a/AMSS_NCKU_source/coords.h
+++ b/AMSS_NCKU_source/AHF_Direct/coords.h
@@ -1,173 +1,173 @@
-#ifndef COORDS_H
-#define COORDS_H
-namespace AHFinderDirect
-{
- namespace local_coords
- {
-
- // compare if two angles are fuzzily equal mod 2*pi radians (360 degrees)
- bool fuzzy_EQ_ang(fp ang1, fp ang2); // radians
- bool fuzzy_EQ_dang(fp dang1, fp dang2); // degrees
-
- // modulo-reduce {ang,dang} to be (fuzzily) within the range
- // [min,max]_{ang,dang}, or error_exit() if no such value exists
- fp modulo_reduce_ang(fp ang, fp min_ang, fp max_ang);
- fp modulo_reduce_dang(fp dang, fp min_dang, fp max_dang);
-
- } // close namespace local_coords::
-
- namespace local_coords
- {
- // (r,(mu,nu,phi)) <--> (x,y,z)
- void xyz_of_r_mu_nu(fp r, fp mu, fp nu, fp &x, fp &y, fp &z);
- void xyz_of_r_mu_phi(fp r, fp mu, fp phi, fp &x, fp &y, fp &z);
- void xyz_of_r_nu_phi(fp r, fp nu, fp phi, fp &x, fp &y, fp &z);
- fp r_of_xyz(fp x, fp y, fp z);
- fp mu_of_yz(fp y, fp z);
- fp nu_of_xz(fp x, fp z);
- fp phi_of_xy(fp x, fp y);
-
- // ((mu,nu,phi)) --> the 3rd
- fp phi_of_mu_nu(fp mu, fp nu);
- fp nu_of_mu_phi(fp mu, fp phi);
- fp mu_of_nu_phi(fp nu, fp phi);
-
- // partial {x,y,z} / partial {mu,nu,phi}
- void partial_xyz_wrt_r_mu_nu(fp r, fp mu, fp nu,
- fp &partial_x_wrt_r, fp &partial_x_wrt_mu, fp &partial_x_wrt_nu,
- fp &partial_y_wrt_r, fp &partial_y_wrt_mu, fp &partial_y_wrt_nu,
- fp &partial_z_wrt_r, fp &partial_z_wrt_mu, fp &partial_z_wrt_nu);
- void partial_xyz_wrt_r_mu_phi(fp r, fp mu, fp phi,
- fp &partial_x_wrt_r, fp &partial_x_wrt_mu, fp &partial_x_wrt_phi,
- fp &partial_y_wrt_r, fp &partial_y_wrt_mu, fp &partial_y_wrt_phi,
- fp &partial_z_wrt_r, fp &partial_z_wrt_mu, fp &partial_z_wrt_phi);
- void partial_xyz_wrt_r_nu_phi(fp r, fp nu, fp phi,
- fp &partial_x_wrt_r, fp &partial_x_wrt_nu, fp &partial_x_wrt_phi,
- fp &partial_y_wrt_r, fp &partial_y_wrt_nu, fp &partial_y_wrt_phi,
- fp &partial_z_wrt_r, fp &partial_z_wrt_nu, fp &partial_z_wrt_phi);
-
- // partial {mu,nu,phi} / partial {x,y,z}
- fp partial_mu_wrt_y(fp y, fp z);
- fp partial_mu_wrt_z(fp y, fp z);
- fp partial_nu_wrt_x(fp x, fp z);
- fp partial_nu_wrt_z(fp x, fp z);
- fp partial_phi_wrt_x(fp x, fp y);
- fp partial_phi_wrt_y(fp x, fp y);
-
- // partial^2 {mu,nu,phi} / partial {x,y,z}{x,y,z}
- fp partial2_mu_wrt_yy(fp y, fp z);
- fp partial2_mu_wrt_yz(fp y, fp z);
- fp partial2_mu_wrt_zz(fp y, fp z);
- fp partial2_nu_wrt_xx(fp x, fp z);
- fp partial2_nu_wrt_xz(fp x, fp z);
- fp partial2_nu_wrt_zz(fp x, fp z);
- fp partial2_phi_wrt_xx(fp x, fp y);
- fp partial2_phi_wrt_xy(fp x, fp y);
- fp partial2_phi_wrt_yy(fp x, fp y);
-
- // usual polar spherical (r,theta,phi) <--> (x,y,z)
- void xyz_of_r_theta_phi(fp r, fp theta, fp phi, fp &x, fp &y, fp &z);
- void r_theta_phi_of_xyz(fp x, fp y, fp z, fp &r, fp &theta, fp &phi);
- // ... already have r_of_xyz()
- // ... already have phi_of_xy()
- fp theta_of_xyz(fp x, fp y, fp z);
-
- // ((mu,nu,phi)) <--> usual polar spherical (theta,phi)
- // ... note phi is the same coordinate in both systems
- void theta_phi_of_mu_nu(fp mu, fp nu, fp &ps_theta, fp &ps_phi);
- void theta_phi_of_mu_phi(fp mu, fp phi, fp &ps_theta, fp &ps_phi);
- void theta_phi_of_nu_phi(fp nu, fp phi, fp &ps_theta, fp &ps_phi);
- void mu_nu_of_theta_phi(fp ps_theta, fp ps_phi, fp &mu, fp &nu);
- void mu_phi_of_theta_phi(fp ps_theta, fp ps_phi, fp &mu, fp &phi);
- void nu_phi_of_theta_phi(fp ps_theta, fp ps_phi, fp &nu, fp &phi);
-
- // ((mu,nu,phi)) --> direction cosines (xcos,ycos,zcos)
- void xyzcos_of_mu_nu(fp mu, fp nu, fp &xcos, fp &ycos, fp &zcos);
- void xyzcos_of_mu_phi(fp mu, fp phi, fp &xcos, fp &ycos, fp &zcos);
- void xyzcos_of_nu_phi(fp nu, fp phi, fp &xcos, fp &ycos, fp &zcos);
- } // close namespace local_coords::
-
- //*****************************************************************************
-
- //
- // ***** bit masks for coordinates ****
- //
-
- //
- // We need to manipulate coordinates to do calculations like "which
- // coordinate do these two patches have in common". We do these by
- // Boolean operations on integers using the following bit masks:
- //
-
- namespace local_coords
- {
-
- typedef int coords_set;
-
- enum
- {
- coords_set_mu = 0x1,
- coords_set_nu = 0x2,
- coords_set_phi = 0x4,
-
- coords_set_empty = 0x0,
- coords_set_all = coords_set_mu | coords_set_nu | coords_set_phi // no comma
- };
-
- // human-readable coordinate names for debugging etc
- const char *name_of_coords_set(coords_set S);
-
- // set complement of coordinates
- inline coords_set coords_set_not(coords_set S)
- {
- return coords_set_all & ~S;
- }
-
- } // close namespace local_coords::
-
- //******************************************************************************
-
- //
- // This class stores the origin point of our local coordinates, and
- // provides conversions between local and global coordinates.
- //
- class global_coords
- {
- public:
- // get global (x,y,z) coordinates of local origin point
- fp origin_x() const { return origin_x_; }
- fp origin_y() const { return origin_y_; }
- fp origin_z() const { return origin_z_; }
-
- // constructor: specify global (x,y,z) coordinates of local origin point
- global_coords(fp origin_x_in, fp origin_y_in, fp origin_z_in)
- : origin_x_(origin_x_in),
- origin_y_(origin_y_in),
- origin_z_(origin_z_in)
- {
- }
- // destructor: compiler-generated no-op is ok
-
- void recentering(fp x, fp y, fp z)
- {
- origin_x_ = x;
- origin_y_ = y;
- origin_z_ = z;
- }
-
- private:
- // we forbid copying and passing by value
- // by declaring the copy constructor and assignment operator
- // private, but never defining them
- global_coords(const global_coords &rhs);
- global_coords &operator=(const global_coords &rhs);
-
- private:
- // global (x,y,z) coordinates of local origin point
- fp origin_x_, origin_y_, origin_z_;
- };
-
- //******************************************************************************
-
-} // namespace AHFinderDirect
-#endif /* COORDS_H */
+#ifndef COORDS_H
+#define COORDS_H
+namespace AHFinderDirect
+{
+ namespace local_coords
+ {
+
+ // compare if two angles are fuzzily equal mod 2*pi radians (360 degrees)
+ bool fuzzy_EQ_ang(fp ang1, fp ang2); // radians
+ bool fuzzy_EQ_dang(fp dang1, fp dang2); // degrees
+
+ // modulo-reduce {ang,dang} to be (fuzzily) within the range
+ // [min,max]_{ang,dang}, or error_exit() if no such value exists
+ fp modulo_reduce_ang(fp ang, fp min_ang, fp max_ang);
+ fp modulo_reduce_dang(fp dang, fp min_dang, fp max_dang);
+
+ } // close namespace local_coords::
+
+ namespace local_coords
+ {
+ // (r,(mu,nu,phi)) <--> (x,y,z)
+ void xyz_of_r_mu_nu(fp r, fp mu, fp nu, fp &x, fp &y, fp &z);
+ void xyz_of_r_mu_phi(fp r, fp mu, fp phi, fp &x, fp &y, fp &z);
+ void xyz_of_r_nu_phi(fp r, fp nu, fp phi, fp &x, fp &y, fp &z);
+ fp r_of_xyz(fp x, fp y, fp z);
+ fp mu_of_yz(fp y, fp z);
+ fp nu_of_xz(fp x, fp z);
+ fp phi_of_xy(fp x, fp y);
+
+ // ((mu,nu,phi)) --> the 3rd
+ fp phi_of_mu_nu(fp mu, fp nu);
+ fp nu_of_mu_phi(fp mu, fp phi);
+ fp mu_of_nu_phi(fp nu, fp phi);
+
+ // partial {x,y,z} / partial {mu,nu,phi}
+ void partial_xyz_wrt_r_mu_nu(fp r, fp mu, fp nu,
+ fp &partial_x_wrt_r, fp &partial_x_wrt_mu, fp &partial_x_wrt_nu,
+ fp &partial_y_wrt_r, fp &partial_y_wrt_mu, fp &partial_y_wrt_nu,
+ fp &partial_z_wrt_r, fp &partial_z_wrt_mu, fp &partial_z_wrt_nu);
+ void partial_xyz_wrt_r_mu_phi(fp r, fp mu, fp phi,
+ fp &partial_x_wrt_r, fp &partial_x_wrt_mu, fp &partial_x_wrt_phi,
+ fp &partial_y_wrt_r, fp &partial_y_wrt_mu, fp &partial_y_wrt_phi,
+ fp &partial_z_wrt_r, fp &partial_z_wrt_mu, fp &partial_z_wrt_phi);
+ void partial_xyz_wrt_r_nu_phi(fp r, fp nu, fp phi,
+ fp &partial_x_wrt_r, fp &partial_x_wrt_nu, fp &partial_x_wrt_phi,
+ fp &partial_y_wrt_r, fp &partial_y_wrt_nu, fp &partial_y_wrt_phi,
+ fp &partial_z_wrt_r, fp &partial_z_wrt_nu, fp &partial_z_wrt_phi);
+
+ // partial {mu,nu,phi} / partial {x,y,z}
+ fp partial_mu_wrt_y(fp y, fp z);
+ fp partial_mu_wrt_z(fp y, fp z);
+ fp partial_nu_wrt_x(fp x, fp z);
+ fp partial_nu_wrt_z(fp x, fp z);
+ fp partial_phi_wrt_x(fp x, fp y);
+ fp partial_phi_wrt_y(fp x, fp y);
+
+ // partial^2 {mu,nu,phi} / partial {x,y,z}{x,y,z}
+ fp partial2_mu_wrt_yy(fp y, fp z);
+ fp partial2_mu_wrt_yz(fp y, fp z);
+ fp partial2_mu_wrt_zz(fp y, fp z);
+ fp partial2_nu_wrt_xx(fp x, fp z);
+ fp partial2_nu_wrt_xz(fp x, fp z);
+ fp partial2_nu_wrt_zz(fp x, fp z);
+ fp partial2_phi_wrt_xx(fp x, fp y);
+ fp partial2_phi_wrt_xy(fp x, fp y);
+ fp partial2_phi_wrt_yy(fp x, fp y);
+
+ // usual polar spherical (r,theta,phi) <--> (x,y,z)
+ void xyz_of_r_theta_phi(fp r, fp theta, fp phi, fp &x, fp &y, fp &z);
+ void r_theta_phi_of_xyz(fp x, fp y, fp z, fp &r, fp &theta, fp &phi);
+ // ... already have r_of_xyz()
+ // ... already have phi_of_xy()
+ fp theta_of_xyz(fp x, fp y, fp z);
+
+ // ((mu,nu,phi)) <--> usual polar spherical (theta,phi)
+ // ... note phi is the same coordinate in both systems
+ void theta_phi_of_mu_nu(fp mu, fp nu, fp &ps_theta, fp &ps_phi);
+ void theta_phi_of_mu_phi(fp mu, fp phi, fp &ps_theta, fp &ps_phi);
+ void theta_phi_of_nu_phi(fp nu, fp phi, fp &ps_theta, fp &ps_phi);
+ void mu_nu_of_theta_phi(fp ps_theta, fp ps_phi, fp &mu, fp &nu);
+ void mu_phi_of_theta_phi(fp ps_theta, fp ps_phi, fp &mu, fp &phi);
+ void nu_phi_of_theta_phi(fp ps_theta, fp ps_phi, fp &nu, fp &phi);
+
+ // ((mu,nu,phi)) --> direction cosines (xcos,ycos,zcos)
+ void xyzcos_of_mu_nu(fp mu, fp nu, fp &xcos, fp &ycos, fp &zcos);
+ void xyzcos_of_mu_phi(fp mu, fp phi, fp &xcos, fp &ycos, fp &zcos);
+ void xyzcos_of_nu_phi(fp nu, fp phi, fp &xcos, fp &ycos, fp &zcos);
+ } // close namespace local_coords::
+
+ //*****************************************************************************
+
+ //
+ // ***** bit masks for coordinates ****
+ //
+
+ //
+ // We need to manipulate coordinates to do calculations like "which
+ // coordinate do these two patches have in common". We do these by
+ // Boolean operations on integers using the following bit masks:
+ //
+
+ namespace local_coords
+ {
+
+ typedef int coords_set;
+
+ enum
+ {
+ coords_set_mu = 0x1,
+ coords_set_nu = 0x2,
+ coords_set_phi = 0x4,
+
+ coords_set_empty = 0x0,
+ coords_set_all = coords_set_mu | coords_set_nu | coords_set_phi // no comma
+ };
+
+ // human-readable coordinate names for debugging etc
+ const char *name_of_coords_set(coords_set S);
+
+ // set complement of coordinates
+ inline coords_set coords_set_not(coords_set S)
+ {
+ return coords_set_all & ~S;
+ }
+
+ } // close namespace local_coords::
+
+ //******************************************************************************
+
+ //
+ // This class stores the origin point of our local coordinates, and
+ // provides conversions between local and global coordinates.
+ //
+ class global_coords
+ {
+ public:
+ // get global (x,y,z) coordinates of local origin point
+ fp origin_x() const { return origin_x_; }
+ fp origin_y() const { return origin_y_; }
+ fp origin_z() const { return origin_z_; }
+
+ // constructor: specify global (x,y,z) coordinates of local origin point
+ global_coords(fp origin_x_in, fp origin_y_in, fp origin_z_in)
+ : origin_x_(origin_x_in),
+ origin_y_(origin_y_in),
+ origin_z_(origin_z_in)
+ {
+ }
+ // destructor: compiler-generated no-op is ok
+
+ void recentering(fp x, fp y, fp z)
+ {
+ origin_x_ = x;
+ origin_y_ = y;
+ origin_z_ = z;
+ }
+
+ private:
+ // we forbid copying and passing by value
+ // by declaring the copy constructor and assignment operator
+ // private, but never defining them
+ global_coords(const global_coords &rhs);
+ global_coords &operator=(const global_coords &rhs);
+
+ private:
+ // global (x,y,z) coordinates of local origin point
+ fp origin_x_, origin_y_, origin_z_;
+ };
+
+ //******************************************************************************
+
+} // namespace AHFinderDirect
+#endif /* COORDS_H */
diff --git a/AMSS_NCKU_source/cpm_map.C b/AMSS_NCKU_source/AHF_Direct/cpm_map.C
similarity index 97%
rename from AMSS_NCKU_source/cpm_map.C
rename to AMSS_NCKU_source/AHF_Direct/cpm_map.C
index be80f8a..847ae1d 100644
--- a/AMSS_NCKU_source/cpm_map.C
+++ b/AMSS_NCKU_source/AHF_Direct/cpm_map.C
@@ -1,93 +1,93 @@
-#include
-#include
-
-#include "stdc.h"
-#include "util.h"
-#include "cpm_map.h"
-
-namespace AHFinderDirect
-{
- namespace jtutil
- {
-
- template
- cpm_map::cpm_map(int min_i_in, int max_i_in,
- fp_t fixed_point)
- : min_i_(min_i_in), max_i_(max_i_in),
- map_is_plus_(false)
- {
- const fp_t d_offset = 2.0 * fixed_point;
- if (!fuzzy::is_integer(d_offset))
- then error_exit(ERROR_EXIT,
- "***** cpm_map::cpm_map (mirror):\n"
- " fixed_point=%g isn't (fuzzily) integral or half-integral!\n",
- double(fixed_point)); /*NOTREACHED*/
-
- offset_ = round::to_integer(d_offset);
-
- assert(
- map_unchecked(fuzzy::floor(fixed_point)) ==
- fuzzy::ceiling(fixed_point));
- }
-
- //******************************************************************************
-
- //
- // This function constructs a generic cpm_map object, with the mapping
- // specified by a sample point sample_i --> sample_j and by sign.
- // The sample point need not be in the map's domain/range.
- //
- template
- cpm_map::cpm_map(int min_i_in, int max_i_in,
- int sample_i, int sample_j,
- bool map_is_plus_in)
- : min_i_(min_i_in), max_i_(max_i_in),
- offset_(map_is_plus_in ? sample_j - sample_i
- : sample_j + sample_i),
- map_is_plus_(map_is_plus_in)
- {
- assert(map_unchecked(sample_i) == sample_j);
- }
-
- //******************************************************************************
-
- //
- // This function constructs a generic cpm_map object, with the mapping
- // specified by a *fp* sample point sample_i --> sample_j (which
- // must specify an integer --> integer mapping, i.e. 4.2 --> 4.2 is
- // ok for a + map, and 4.5 --> 4.5 is ok for a minus map, but 4.2 --> 4.7
- // is never ok) and by sign. The sample point need not be in the map's
- // domain/range.
- //
- template
- cpm_map::cpm_map(int min_i_in, int max_i_in,
- fp_t sample_i, fp_t sample_j,
- bool map_is_plus_in)
- : min_i_(min_i_in), max_i_(max_i_in),
- map_is_plus_(map_is_plus_in)
- {
- const fp_t fp_offset = map_is_plus_in ? sample_j - sample_i
- : sample_j + sample_i;
- if (!fuzzy::is_integer(fp_offset))
- then error_exit(ERROR_EXIT,
- "***** cpm_map::cpm_map (generic via fp sample point):\n"
- " fp_offset=%g isn't fuzzily integral!\n"
- " ==> sample_i=%g --> sample_j=%g\n"
- " doesn't fuzzily specify an integer --> integer mapping!\n",
- double(fp_offset),
- double(sample_i), double(sample_j)); /*NOTREACHED*/
-
- offset_ = round::to_integer(fp_offset);
-
- // verify that we have setup correct
- assert(
- map_unchecked(fuzzy::floor(sample_i)) ==
- (map_is_plus_in ? fuzzy::floor(sample_j)
- : fuzzy::ceiling(sample_j)));
- }
-
- template class cpm_map;
- template class cpm_map;
-
- } // namespace jtutil
-} // namespace AHFinderDirect
+#include
+#include
+
+#include "stdc.h"
+#include "util.h"
+#include "cpm_map.h"
+
+namespace AHFinderDirect
+{
+ namespace jtutil
+ {
+
+ template
+ cpm_map::cpm_map(int min_i_in, int max_i_in,
+ fp_t fixed_point)
+ : min_i_(min_i_in), max_i_(max_i_in),
+ map_is_plus_(false)
+ {
+ const fp_t d_offset = 2.0 * fixed_point;
+ if (!fuzzy::is_integer(d_offset))
+ then error_exit(ERROR_EXIT,
+ "***** cpm_map::cpm_map (mirror):\n"
+ " fixed_point=%g isn't (fuzzily) integral or half-integral!\n",
+ double(fixed_point)); /*NOTREACHED*/
+
+ offset_ = round::to_integer(d_offset);
+
+ assert(
+ map_unchecked(fuzzy::floor(fixed_point)) ==
+ fuzzy::ceiling(fixed_point));
+ }
+
+ //******************************************************************************
+
+ //
+ // This function constructs a generic cpm_map object, with the mapping
+ // specified by a sample point sample_i --> sample_j and by sign.
+ // The sample point need not be in the map's domain/range.
+ //
+ template
+ cpm_map::cpm_map(int min_i_in, int max_i_in,
+ int sample_i, int sample_j,
+ bool map_is_plus_in)
+ : min_i_(min_i_in), max_i_(max_i_in),
+ offset_(map_is_plus_in ? sample_j - sample_i
+ : sample_j + sample_i),
+ map_is_plus_(map_is_plus_in)
+ {
+ assert(map_unchecked(sample_i) == sample_j);
+ }
+
+ //******************************************************************************
+
+ //
+ // This function constructs a generic cpm_map object, with the mapping
+ // specified by a *fp* sample point sample_i --> sample_j (which
+ // must specify an integer --> integer mapping, i.e. 4.2 --> 4.2 is
+ // ok for a + map, and 4.5 --> 4.5 is ok for a minus map, but 4.2 --> 4.7
+ // is never ok) and by sign. The sample point need not be in the map's
+ // domain/range.
+ //
+ template
+ cpm_map::cpm_map(int min_i_in, int max_i_in,
+ fp_t sample_i, fp_t sample_j,
+ bool map_is_plus_in)
+ : min_i_(min_i_in), max_i_(max_i_in),
+ map_is_plus_(map_is_plus_in)
+ {
+ const fp_t fp_offset = map_is_plus_in ? sample_j - sample_i
+ : sample_j + sample_i;
+ if (!fuzzy::is_integer(fp_offset))
+ then error_exit(ERROR_EXIT,
+ "***** cpm_map::cpm_map (generic via fp sample point):\n"
+ " fp_offset=%g isn't fuzzily integral!\n"
+ " ==> sample_i=%g --> sample_j=%g\n"
+ " doesn't fuzzily specify an integer --> integer mapping!\n",
+ double(fp_offset),
+ double(sample_i), double(sample_j)); /*NOTREACHED*/
+
+ offset_ = round::to_integer(fp_offset);
+
+ // verify that we have setup correct
+ assert(
+ map_unchecked(fuzzy::floor(sample_i)) ==
+ (map_is_plus_in ? fuzzy::floor(sample_j)
+ : fuzzy::ceiling(sample_j)));
+ }
+
+ template class cpm_map;
+ template class cpm_map;
+
+ } // namespace jtutil
+} // namespace AHFinderDirect
diff --git a/AMSS_NCKU_source/cpm_map.h b/AMSS_NCKU_source/AHF_Direct/cpm_map.h
similarity index 96%
rename from AMSS_NCKU_source/cpm_map.h
rename to AMSS_NCKU_source/AHF_Direct/cpm_map.h
index 92e0596..2f8d759 100644
--- a/AMSS_NCKU_source/cpm_map.h
+++ b/AMSS_NCKU_source/AHF_Direct/cpm_map.h
@@ -1,120 +1,120 @@
-#ifndef AHFINDERDIRECT__CPM_MAP_HH
-#define AHFINDERDIRECT__CPM_MAP_HH
-namespace AHFinderDirect
-{
- namespace jtutil
- {
-
- template
- class cpm_map
- {
- public:
- // bounds info -- domain
- int min_i() const { return min_i_; }
- int max_i() const { return max_i_; }
- int N_points() const
- {
- return jtutil::how_many_in_range(min_i_, max_i_);
- }
- bool in_domain(int i) const { return (i >= min_i_) && (i <= max_i_); }
-
- // is the mapping + or - ?
- bool is_plus() const { return map_is_plus_; }
- bool is_minus() const { return !map_is_plus_; }
- int sign() const { return map_is_plus_ ? +1 : -1; }
- fp_t fp_sign() const { return map_is_plus_ ? +1.0 : -1.0; }
-
- // the mapping itself
- int map_unchecked(int i) const
- {
- return map_is_plus_ ? offset_ + i
- : offset_ - i;
- }
- int inv_map_unchecked(int j) const
- {
- return map_is_plus_ ? j - offset_
- : offset_ - j;
- }
- int map(int i) const
- {
- assert(in_domain(i));
- return map_unchecked(i);
- }
- int inv_map(int j) const
- {
- int i = inv_map_unchecked(j);
- assert(in_domain(i));
- return i;
- }
-
- // bounds info -- range
- // ... we use the unchecked map here in case the domain is empty
- int min_j() const
- {
- return map_is_plus_ ? map_unchecked(min_i_)
- : map_unchecked(max_i_);
- }
- int max_j() const
- {
- return map_is_plus_ ? map_unchecked(max_i_)
- : map_unchecked(min_i_);
- }
- bool in_range(int j) const { return in_domain(inv_map_unchecked(j)); }
-
- //
- // constructors
- //
-
- // "mirror" map: i --> const - i
- // ... map specified by fixed point (must be integer or half-integer)
- // ... fixed point need not be in domain/range
- cpm_map(int min_i_in, int max_i_in,
- fp_t fixed_point);
-
- // "shift" map: i --> const + i
- // ... map specified by shift amount
- // ... default is identity map
- cpm_map(int min_i_in, int max_i_in,
- int shift_amount = 0)
- : min_i_(min_i_in), max_i_(max_i_in),
- offset_(shift_amount), map_is_plus_(true)
- {
- }
-
- // generic map: i --> const +/- i
- // ... map specified by sample point sample_i --> sample_j
- // and by sign (one of {plus,minus}_map )
- // ... sample point need not be in domain/range
- cpm_map(int min_i_in, int max_i_in,
- int sample_i, int sample_j,
- bool map_is_plus_in);
-
- // generic map: i --> const +/- i
- // ... map specified by *fp* sample point sample_i --> sample_j
- // (must specify an integer --> integer mapping)
- // and by sign (one of {plus,minus}_map )
- // ... hence if sign is -1, then sample_i and sample_j
- // must both be half-integral
- // ... sample point need *not* be in domain/range
- cpm_map(int min_i_in, int max_i_in,
- fp_t sample_i, fp_t sample_j,
- bool map_is_plus_in);
-
- // no need for explicit destructor, compiler-generated no-op is ok
- // ditto for copy constructor and assignment operator
-
- private:
- // bounds (inclusive)
- int min_i_, max_i_;
-
- // these define the actual mapping
- int offset_;
- bool map_is_plus_;
- };
-
- //******************************************************************************
-
- } // namespace jtutil
-} // namespace AHFinderDirect
-
-#endif /* AHFINDERDIRECT__CPM_MAP_HH */
+#ifndef AHFINDERDIRECT__CPM_MAP_HH
+#define AHFINDERDIRECT__CPM_MAP_HH
+namespace AHFinderDirect
+{
+ namespace jtutil
+ {
+
+ template
+ class cpm_map
+ {
+ public:
+ // bounds info -- domain
+ int min_i() const { return min_i_; }
+ int max_i() const { return max_i_; }
+ int N_points() const
+ {
+ return jtutil::how_many_in_range(min_i_, max_i_);
+ }
+ bool in_domain(int i) const { return (i >= min_i_) && (i <= max_i_); }
+
+ // is the mapping + or - ?
+ bool is_plus() const { return map_is_plus_; }
+ bool is_minus() const { return !map_is_plus_; }
+ int sign() const { return map_is_plus_ ? +1 : -1; }
+ fp_t fp_sign() const { return map_is_plus_ ? +1.0 : -1.0; }
+
+ // the mapping itself
+ int map_unchecked(int i) const
+ {
+ return map_is_plus_ ? offset_ + i
+ : offset_ - i;
+ }
+ int inv_map_unchecked(int j) const
+ {
+ return map_is_plus_ ? j - offset_
+ : offset_ - j;
+ }
+ int map(int i) const
+ {
+ assert(in_domain(i));
+ return map_unchecked(i);
+ }
+ int inv_map(int j) const
+ {
+ int i = inv_map_unchecked(j);
+ assert(in_domain(i));
+ return i;
+ }
+
+ // bounds info -- range
+ // ... we use the unchecked map here in case the domain is empty
+ int min_j() const
+ {
+ return map_is_plus_ ? map_unchecked(min_i_)
+ : map_unchecked(max_i_);
+ }
+ int max_j() const
+ {
+ return map_is_plus_ ? map_unchecked(max_i_)
+ : map_unchecked(min_i_);
+ }
+ bool in_range(int j) const { return in_domain(inv_map_unchecked(j)); }
+
+ //
+ // constructors
+ //
+
+ // "mirror" map: i --> const - i
+ // ... map specified by fixed point (must be integer or half-integer)
+ // ... fixed point need not be in domain/range
+ cpm_map(int min_i_in, int max_i_in,
+ fp_t fixed_point);
+
+ // "shift" map: i --> const + i
+ // ... map specified by shift amount
+ // ... default is identity map
+ cpm_map(int min_i_in, int max_i_in,
+ int shift_amount = 0)
+ : min_i_(min_i_in), max_i_(max_i_in),
+ offset_(shift_amount), map_is_plus_(true)
+ {
+ }
+
+ // generic map: i --> const +/- i
+ // ... map specified by sample point sample_i --> sample_j
+ // and by sign (one of {plus,minus}_map )
+ // ... sample point need not be in domain/range
+ cpm_map(int min_i_in, int max_i_in,
+ int sample_i, int sample_j,
+ bool map_is_plus_in);
+
+ // generic map: i --> const +/- i
+ // ... map specified by *fp* sample point sample_i --> sample_j
+ // (must specify an integer --> integer mapping)
+ // and by sign (one of {plus,minus}_map )
+ // ... hence if sign is -1, then sample_i and sample_j
+ // must both be half-integral
+ // ... sample point need *not* be in domain/range
+ cpm_map(int min_i_in, int max_i_in,
+ fp_t sample_i, fp_t sample_j,
+ bool map_is_plus_in);
+
+ // no need for explicit destructor, compiler-generated no-op is ok
+ // ditto for copy constructor and assignment operator
+
+ private:
+ // bounds (inclusive)
+ int min_i_, max_i_;
+
+ // these define the actual mapping
+ int offset_;
+ bool map_is_plus_;
+ };
+
+ //******************************************************************************
+
+ } // namespace jtutil
+} // namespace AHFinderDirect
+
+#endif /* AHFINDERDIRECT__CPM_MAP_HH */
diff --git a/AMSS_NCKU_source/driver.h b/AMSS_NCKU_source/AHF_Direct/driver.h
similarity index 95%
rename from AMSS_NCKU_source/driver.h
rename to AMSS_NCKU_source/AHF_Direct/driver.h
index 39c6053..e90f8c0 100644
--- a/AMSS_NCKU_source/driver.h
+++ b/AMSS_NCKU_source/AHF_Direct/driver.h
@@ -1,108 +1,108 @@
-#ifndef DRIVER_H
-#define DRIVER_H
-#include
-#include
-#include
-#include
-
-#include "util_Table.h"
-#include "cctk.h"
-#include "config.h"
-#include "stdc.h"
-#include "util.h"
-#include "array.h"
-#include "cpm_map.h"
-#include "linear_map.h"
-
-#include "coords.h"
-#include "tgrid.h"
-#include "fd_grid.h"
-#include "patch.h"
-#include "patch_edge.h"
-#include "patch_interp.h"
-#include "ghost_zone.h"
-#include "patch_system.h"
-
-#include "Jacobian.h"
-
-#include "gfns.h"
-#include "gr.h"
-
-#include "horizon_sequence.h"
-#include "BH_diagnostics.h"
-
-namespace AHFinderDirect
-{
- struct iteration_status_buffers
- {
- int *hn_buffer;
- int *iteration_buffer;
- enum expansion_status *expansion_status_buffer;
- fp *mean_horizon_radius_buffer;
- fp *Theta_infinity_norm_buffer;
- bool *found_horizon_buffer;
-
- jtutil::array2d *send_buffer_ptr;
- jtutil::array2d *receive_buffer_ptr;
-
- iteration_status_buffers()
- : hn_buffer(NULL), iteration_buffer(NULL),
- expansion_status_buffer(NULL),
- mean_horizon_radius_buffer(NULL),
- Theta_infinity_norm_buffer(NULL),
- found_horizon_buffer(NULL),
- send_buffer_ptr(NULL), receive_buffer_ptr(NULL)
- {
- }
- };
-
- //
- // This struct holds interprocessor-communication buffers for broadcasting
- // the BH diagnostics and horizon shape from the processor which finds a
- // given horizon, to all processors.
- //
- struct horizon_buffers
- {
- int N_buffer;
- double *send_buffer;
- double *receive_buffer;
-
- horizon_buffers()
- : N_buffer(0),
- send_buffer(NULL),
- receive_buffer(NULL)
- {
- }
- };
- //
- struct AH_data
- {
- patch_system *ps_ptr;
- Jacobian *Jac_ptr;
- double surface_expansion;
-
- bool initial_find_flag;
- bool recentering_flag, stop_finding, find_trigger;
-
- bool found_flag; // did we find this horizon (successfully)
-
- struct BH_diagnostics BH_diagnostics;
- FILE *BH_diagnostics_fileptr;
-
- // interprocessor-communication buffers
- // for this horizon's BH diagnostics and (optionally) horizon shape
- struct horizon_buffers horizon_buffers;
- };
-
- // initial_guess.cc
- void setup_initial_guess(patch_system &ps,
- fp x_center, fp y_center, fp z_center,
- fp x_radius, fp y_radius, fp z_radius);
-
- // Newton.cc
- void Newton(int N_procs, int N_active_procs, int my_proc,
- horizon_sequence &hs, struct AH_data *const AH_data_array[],
- struct iteration_status_buffers &isb, int *dumpid, double *);
-
-} // namespace AHFinderDirect
-#endif /* DRIVER_H */
+#ifndef DRIVER_H
+#define DRIVER_H
+#include
+#include
+#include
+#include
+
+#include "util_Table.h"
+#include "cctk.h"
+#include "config.h"
+#include "stdc.h"
+#include "util.h"
+#include "array.h"
+#include "cpm_map.h"
+#include "linear_map.h"
+
+#include "coords.h"
+#include "tgrid.h"
+#include "fd_grid.h"
+#include "patch.h"
+#include "patch_edge.h"
+#include "patch_interp.h"
+#include "ghost_zone.h"
+#include "patch_system.h"
+
+#include "Jacobian.h"
+
+#include "gfns.h"
+#include "gr.h"
+
+#include "horizon_sequence.h"
+#include "BH_diagnostics.h"
+
+namespace AHFinderDirect
+{
+ struct iteration_status_buffers
+ {
+ int *hn_buffer;
+ int *iteration_buffer;
+ enum expansion_status *expansion_status_buffer;
+ fp *mean_horizon_radius_buffer;
+ fp *Theta_infinity_norm_buffer;
+ bool *found_horizon_buffer;
+
+ jtutil::array2d *send_buffer_ptr;
+ jtutil::array2d *receive_buffer_ptr;
+
+ iteration_status_buffers()
+ : hn_buffer(NULL), iteration_buffer(NULL),
+ expansion_status_buffer(NULL),
+ mean_horizon_radius_buffer(NULL),
+ Theta_infinity_norm_buffer(NULL),
+ found_horizon_buffer(NULL),
+ send_buffer_ptr(NULL), receive_buffer_ptr(NULL)
+ {
+ }
+ };
+
+ //
+ // This struct holds interprocessor-communication buffers for broadcasting
+ // the BH diagnostics and horizon shape from the processor which finds a
+ // given horizon, to all processors.
+ //
+ struct horizon_buffers
+ {
+ int N_buffer;
+ double *send_buffer;
+ double *receive_buffer;
+
+ horizon_buffers()
+ : N_buffer(0),
+ send_buffer(NULL),
+ receive_buffer(NULL)
+ {
+ }
+ };
+ //
+ struct AH_data
+ {
+ patch_system *ps_ptr;
+ Jacobian *Jac_ptr;
+ double surface_expansion;
+
+ bool initial_find_flag;
+ bool recentering_flag, stop_finding, find_trigger;
+
+ bool found_flag; // did we find this horizon (successfully)
+
+ struct BH_diagnostics BH_diagnostics;
+ FILE *BH_diagnostics_fileptr;
+
+ // interprocessor-communication buffers
+ // for this horizon's BH diagnostics and (optionally) horizon shape
+ struct horizon_buffers horizon_buffers;
+ };
+
+ // initial_guess.cc
+ void setup_initial_guess(patch_system &ps,
+ fp x_center, fp y_center, fp z_center,
+ fp x_radius, fp y_radius, fp z_radius);
+
+ // Newton.cc
+ void Newton(int N_procs, int N_active_procs, int my_proc,
+ horizon_sequence &hs, struct AH_data *const AH_data_array[],
+ struct iteration_status_buffers &isb, int *dumpid, double *);
+
+} // namespace AHFinderDirect
+#endif /* DRIVER_H */
diff --git a/AMSS_NCKU_source/error_exit.C b/AMSS_NCKU_source/AHF_Direct/error_exit.C
similarity index 95%
rename from AMSS_NCKU_source/error_exit.C
rename to AMSS_NCKU_source/AHF_Direct/error_exit.C
index b0eae77..b51295d 100644
--- a/AMSS_NCKU_source/error_exit.C
+++ b/AMSS_NCKU_source/AHF_Direct/error_exit.C
@@ -1,38 +1,38 @@
-#include
-#include
-#include