COSMOS
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
Ahf2d Class Reference

Implements a 2D Apparent Horizon Finder. More...

#include <ahf2d_d.h>

Collaboration diagram for Ahf2d:
Collaboration graph

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).
 
Fmv0fm
 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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Ahf2d()

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.

Parameters
ntheta_inNumber of theta grid points.
nphi_inNumber of phi grid points.
hini_inInitial guess for horizon radius.
var_inSolver acceleration parameter eta (etaah).
fac_inRadius update mixing factor (facn).
err_p_inPoisson solver tolerance.
err_e_inAH equation solver tolerance.
ahloop_inMaximum solver iterations.
fm_inPointer to the Fmv0/Fmv object with spacetime data.

◆ ~Ahf2d()

Ahf2d::~Ahf2d ( )

Destructor for the Ahf2d class. Frees allocated memory.

Member Function Documentation

◆ calc_expansion()

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).

◆ calculate_ah_mass()

double Ahf2d::calculate_ah_mass ( )

Calculates the irreducible mass of the found horizon.

Returns
Irreducible mass M_irr = sqrt(Area / (16 * PI)). Returns -1 if horizon not found.

◆ calculate_ah_spin()

double Ahf2d::calculate_ah_spin ( )

Calculates the dimensionless spin of the found horizon.

Returns
Dimensionless spin parameter J/M^2. Returns -1 if horizon not found or spin calculation fails.
Note
Spin calculation often requires integrating the extrinsic curvature over the horizon surface.

◆ D1ph()

double Ahf2d::D1ph ( double ** f,
int i,
int j )
protected

Calculates the phi derivative of a 2D AHF grid function.

◆ D1th()

double Ahf2d::D1th ( double ** f,
int i,
int j )
protected

Calculates the theta derivative of a 2D AHF grid function.

◆ find_ah()

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.

Parameters
[out]ah_massPointer to store the calculated irreducible mass (optional).
[out]ah_spinPointer to store the calculated dimensionless spin (optional).
Returns
0 on success, non-zero on failure (e.g., no convergence).
Here is the caller graph for this function:

◆ free_matrix2d()

void Ahf2d::free_matrix2d ( double ** m,
long nrl,
long nrh,
long ncl,
long nch )

Frees memory allocated by matrix2d().

◆ interpolate_to_ah()

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.

Parameters
fPointer to the 3D Cartesian grid function data (e.g., fm->alp).
rCoordinate radius of the point.
thTheta angle of the point.
phPhi angle of the point.
Returns
Interpolated value of f at (r, th, ph).
Note
Needs careful implementation of coordinate transformation and interpolation (e.g., trilinear).

◆ matrix2d()

double ** Ahf2d::matrix2d ( long nrl,
long nrh,
long ncl,
long nch )

Allocates memory for a 2D AHF grid array.

◆ print_horizon_shape()

void Ahf2d::print_horizon_shape ( const char * filename,
double t )

Prints the current horizon shape h(theta, phi) to a file.

Parameters
filenameName of the output file.
tCurrent simulation time to include in the output.

◆ solve_elliptic()

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).

Parameters
[in]sourceThe source term for the elliptic equation (related to Theta).
[out]solutionThe solution array (update to h or correction).
Returns
Number of iterations taken, or -1 on failure.

Member Data Documentation

◆ ahloop

int Ahf2d::ahloop

Maximum number of iterations allowed for the solver.

◆ dphi

double Ahf2d::dphi

Grid spacing in phi.

◆ dth

double Ahf2d::dth

Grid spacing in theta.

◆ err_e

double Ahf2d::err_e

Tolerance for the main AH equation solver part.

◆ err_p

double Ahf2d::err_p

Tolerance for the Poisson solver part.

◆ fac

double Ahf2d::fac

Mixing factor for updating horizon radius guess during iteration.

◆ fm

Fmv0* Ahf2d::fm

Pointer to the Fmv0/Fmv object containing the spacetime grid data.

◆ h

double** Ahf2d::h

Horizon shape function h(theta, phi).

◆ hini

double Ahf2d::hini

Initial guess for the horizon radius (coordinate radius).

◆ nphi

int Ahf2d::nphi

Number of grid points in phi direction (excluding buffers).

◆ ntheta

int Ahf2d::ntheta

Number of grid points in theta direction (excluding buffers).

◆ ths

double** Ahf2d::ths

Expansion Theta(theta, phi).

◆ var

double Ahf2d::var

Acceleration parameter eta for the elliptic solver. Also distinguishes AH/CH.


The documentation for this class was generated from the following file: