COSMOS
|
Implements a 2D Apparent Horizon Finder. More...
#include <ahf2d_d.h>
Public Member Functions | |
Ahf2d (int ntheta_in, int nphi_in, double hini_in, double var_in, double fac_in, double err_p_in, double err_e_in, int ahloop_in, Fmv0 *fm_in) | |
Constructor for the Ahf2d class. | |
~Ahf2d () | |
Destructor for the Ahf2d class. Frees allocated memory. | |
int | find_ah (double *ah_mass=nullptr, double *ah_spin=nullptr) |
Main function to find the apparent horizon. | |
void | calc_expansion () |
Calculates the expansion Theta at all points on the AHF grid. | |
int | solve_elliptic (double **source, double **solution) |
Solves the elliptic (Poisson-like) equation arising in the iteration. | |
double | interpolate_to_ah (double ***f, double r, double th, double ph) |
Interpolates a spacetime grid function from the Cartesian grid to a point on the AH surface. | |
double | calculate_ah_mass () |
Calculates the irreducible mass of the found horizon. | |
double | calculate_ah_spin () |
Calculates the dimensionless spin of the found horizon. | |
void | print_horizon_shape (const char *filename, double t) |
Prints the current horizon shape h(theta, phi) to a file. | |
double ** | matrix2d (long nrl, long nrh, long ncl, long nch) |
Allocates memory for a 2D AHF grid array. | |
void | free_matrix2d (double **m, long nrl, long nrh, long ncl, long nch) |
Frees memory allocated by matrix2d(). | |
Public Attributes | |
int | ntheta |
Number of grid points in theta direction (excluding buffers). | |
int | nphi |
Number of grid points in phi direction (excluding buffers). | |
double | dth |
Grid spacing in theta. | |
double | dphi |
Grid spacing in phi. | |
double | hini |
Initial guess for the horizon radius (coordinate radius). | |
double | var |
Acceleration parameter eta for the elliptic solver. Also distinguishes AH/CH. | |
double | fac |
Mixing factor for updating horizon radius guess during iteration. | |
double | err_p |
Tolerance for the Poisson solver part. | |
double | err_e |
Tolerance for the main AH equation solver part. | |
int | ahloop |
Maximum number of iterations allowed for the solver. | |
double ** | h |
Horizon shape function h(theta, phi). | |
double ** | ths |
Expansion Theta(theta, phi). | |
Fmv0 * | fm |
Pointer to the Fmv0/Fmv object containing the spacetime grid data. | |
Protected Member Functions | |
double | D1th (double **f, int i, int j) |
Calculates the theta derivative of a 2D AHF grid function. | |
double | D1ph (double **f, int i, int j) |
Calculates the phi derivative of a 2D AHF grid function. | |
Implements a 2D Apparent Horizon Finder.
Solves the apparent horizon equation Theta = 0, where Theta is the expansion of outgoing null geodesics, on a spherical coordinate grid. Uses an iterative method involving a Poisson-like solver.
Ahf2d::Ahf2d | ( | int | ntheta_in, |
int | nphi_in, | ||
double | hini_in, | ||
double | var_in, | ||
double | fac_in, | ||
double | err_p_in, | ||
double | err_e_in, | ||
int | ahloop_in, | ||
Fmv0 * | fm_in ) |
Constructor for the Ahf2d class.
ntheta_in | Number of theta grid points. |
nphi_in | Number of phi grid points. |
hini_in | Initial guess for horizon radius. |
var_in | Solver acceleration parameter eta (etaah). |
fac_in | Radius update mixing factor (facn). |
err_p_in | Poisson solver tolerance. |
err_e_in | AH equation solver tolerance. |
ahloop_in | Maximum solver iterations. |
fm_in | Pointer to the Fmv0/Fmv object with spacetime data. |
Ahf2d::~Ahf2d | ( | ) |
Destructor for the Ahf2d class. Frees allocated memory.
void Ahf2d::calc_expansion | ( | ) |
Calculates the expansion Theta at all points on the AHF grid.
Requires interpolating spacetime variables (metric, extrinsic curvature) from the Cartesian grid (fm) to the current guess of the horizon surface defined by h(theta, phi).
double Ahf2d::calculate_ah_mass | ( | ) |
Calculates the irreducible mass of the found horizon.
double Ahf2d::calculate_ah_spin | ( | ) |
Calculates the dimensionless spin of the found horizon.
|
protected |
Calculates the phi derivative of a 2D AHF grid function.
|
protected |
Calculates the theta derivative of a 2D AHF grid function.
int Ahf2d::find_ah | ( | double * | ah_mass = nullptr, |
double * | ah_spin = nullptr ) |
Main function to find the apparent horizon.
Iteratively solves for the horizon shape function h(theta, phi) until the expansion Theta is sufficiently close to zero or the maximum number of iterations is reached.
[out] | ah_mass | Pointer to store the calculated irreducible mass (optional). |
[out] | ah_spin | Pointer to store the calculated dimensionless spin (optional). |
void Ahf2d::free_matrix2d | ( | double ** | m, |
long | nrl, | ||
long | nrh, | ||
long | ncl, | ||
long | nch ) |
Frees memory allocated by matrix2d().
double Ahf2d::interpolate_to_ah | ( | double *** | f, |
double | r, | ||
double | th, | ||
double | ph ) |
Interpolates a spacetime grid function from the Cartesian grid to a point on the AH surface.
f | Pointer to the 3D Cartesian grid function data (e.g., fm->alp). |
r | Coordinate radius of the point. |
th | Theta angle of the point. |
ph | Phi angle of the point. |
double ** Ahf2d::matrix2d | ( | long | nrl, |
long | nrh, | ||
long | ncl, | ||
long | nch ) |
Allocates memory for a 2D AHF grid array.
void Ahf2d::print_horizon_shape | ( | const char * | filename, |
double | t ) |
Prints the current horizon shape h(theta, phi) to a file.
filename | Name of the output file. |
t | Current simulation time to include in the output. |
int Ahf2d::solve_elliptic | ( | double ** | source, |
double ** | solution ) |
Solves the elliptic (Poisson-like) equation arising in the iteration.
This is likely the core iterative solver step (e.g., SOR, CG).
[in] | source | The source term for the elliptic equation (related to Theta). |
[out] | solution | The solution array (update to h or correction). |
int Ahf2d::ahloop |
Maximum number of iterations allowed for the solver.
double Ahf2d::dphi |
Grid spacing in phi.
double Ahf2d::dth |
Grid spacing in theta.
double Ahf2d::err_e |
Tolerance for the main AH equation solver part.
double Ahf2d::err_p |
Tolerance for the Poisson solver part.
double Ahf2d::fac |
Mixing factor for updating horizon radius guess during iteration.
Fmv0* Ahf2d::fm |
Pointer to the Fmv0/Fmv object containing the spacetime grid data.
double** Ahf2d::h |
Horizon shape function h(theta, phi).
double Ahf2d::hini |
Initial guess for the horizon radius (coordinate radius).
int Ahf2d::nphi |
Number of grid points in phi direction (excluding buffers).
int Ahf2d::ntheta |
Number of grid points in theta direction (excluding buffers).
double** Ahf2d::ths |
Expansion Theta(theta, phi).
double Ahf2d::var |
Acceleration parameter eta for the elliptic solver. Also distinguishes AH/CH.