COSMOS
ahf2d_d.h
Go to the documentation of this file.
1
12 #ifndef AHF2D_H
13 #define AHF2D_H
14
15 #include "cosmos.h" // Include if it needs access to Fmv0/Fmv grid data/methods
16 #include <stdio.h>
17 #include <math.h>
18 // Include other necessary headers
19
27 class Ahf2d {
28 public:
29 // --- Member Variables ---
31 int ntheta;
33 int nphi;
35 double dth;
37 double dphi;
39 double hini;
41 double var; // Corresponds to etaah in par_ahf.d
43 double fac; // Corresponds to facn in par_ahf.d
45 double err_p;
47 double err_e;
49 int ahloop;
50
51 // Pointers to AHF internal grid arrays (Example for horizon shape 'h')
53 double **h;
55 double **ths;
56 // Add other internal arrays if needed (e.g., for solver residuals, coefficients)
57
59 Fmv0 *fm; // Use Fmv0* or Fmv* depending on what data is needed
60
61 // --- Constructor & Destructor ---
74 Ahf2d(int ntheta_in, int nphi_in, double hini_in, double var_in, double fac_in,
75 double err_p_in, double err_e_in, int ahloop_in, Fmv0 *fm_in);
76
81
82 // --- Core Methods ---
92 int find_ah(double *ah_mass = nullptr, double *ah_spin = nullptr); // Example output params
93
101
109 int solve_elliptic(double **source, double **solution);
110
120 double interpolate_to_ah(double ***f, double r, double th, double ph);
121
127
134
140 void print_horizon_shape(const char* filename, double t);
141
142 // --- Utility Functions ---
144 double** matrix2d(long nrl, long nrh, long ncl, long nch);
146 void free_matrix2d(double **m, long nrl, long nrh, long ncl, long nch);
147
148 protected: // Or private
149 // Add helper functions if needed, e.g., for calculating derivatives on the spherical grid
151 double D1th(double **f, int i, int j);
153 double D1ph(double **f, int i, int j);
154 // Add second derivatives if needed (D2th, D2ph, Dthph)
155 };
156
157
158 #endif // AHF2D_H
159
Implements a 2D Apparent Horizon Finder.
Definition ahf2d_d.h:27
double fac
Mixing factor for updating horizon radius guess during iteration.
Definition ahf2d_d.h:43
double D1ph(double **f, int i, int j)
Calculates the phi derivative of a 2D AHF grid function.
~Ahf2d()
Destructor for the Ahf2d class. Frees allocated memory.
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.
int find_ah(double *ah_mass=nullptr, double *ah_spin=nullptr)
Main function to find the apparent horizon.
int solve_elliptic(double **source, double **solution)
Solves the elliptic (Poisson-like) equation arising in the iteration.
double ** ths
Expansion Theta(theta, phi).
Definition ahf2d_d.h:55
double hini
Initial guess for the horizon radius (coordinate radius).
Definition ahf2d_d.h:39
double err_p
Tolerance for the Poisson solver part.
Definition ahf2d_d.h:45
double ** matrix2d(long nrl, long nrh, long ncl, long nch)
Allocates memory for a 2D AHF grid array.
Fmv0 * fm
Pointer to the Fmv0/Fmv object containing the spacetime grid data.
Definition ahf2d_d.h:59
double err_e
Tolerance for the main AH equation solver part.
Definition ahf2d_d.h:47
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.
int ntheta
Number of grid points in theta direction (excluding buffers).
Definition ahf2d_d.h:31
double var
Acceleration parameter eta for the elliptic solver. Also distinguishes AH/CH.
Definition ahf2d_d.h:41
void free_matrix2d(double **m, long nrl, long nrh, long ncl, long nch)
Frees memory allocated by matrix2d().
int ahloop
Maximum number of iterations allowed for the solver.
Definition ahf2d_d.h:49
double dth
Grid spacing in theta.
Definition ahf2d_d.h:35
double calculate_ah_mass()
Calculates the irreducible mass of the found horizon.
void calc_expansion()
Calculates the expansion Theta at all points on the AHF grid.
void print_horizon_shape(const char *filename, double t)
Prints the current horizon shape h(theta, phi) to a file.
double ** h
Horizon shape function h(theta, phi).
Definition ahf2d_d.h:53
double calculate_ah_spin()
Calculates the dimensionless spin of the found horizon.
double D1th(double **f, int i, int j)
Calculates the theta derivative of a 2D AHF grid function.
int nphi
Number of grid points in phi direction (excluding buffers).
Definition ahf2d_d.h:33
double dphi
Grid spacing in phi.
Definition ahf2d_d.h:37
Base class for Finite Mesh Variables version 0.
Definition cosmos_d.h:47