COSMOS
|
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <cmath>
#include <cfloat>
#include <cstring>
#include "cosmos.h"
#include "ahf2d.h"
Functions | |
void | printpack (Fmv0 **fmv0, int ln, int pk, int pl, ofstream &filex, ofstream &filey, ofstream &filez, ofstream &filex0z, ofstream &filexy0) |
Helper function to call print routines for all active grid layers. | |
void | check_continue_file ( ifstream &fcontinue, bool &fld, bool &scl, int &tab, int &nxmin, int &nxmax, int &nymin, int &nymax, int &nzmin, int &nzmax, int &laymax, int &ln, int *jbs, int *kbs, int *lbs) |
Checks if parameters in the restart file match the current simulation setup. | |
void | output_params ( ofstream &fileall, bool &fld, bool &scl, int &tab, int &nxmin, int &nxmax, int &nymin, int &nymax, int &nzmin, int &nzmax, int &laymax, int &ln, int *jbs, int *kbs, int *lbs) |
Writes essential simulation parameters to the header of the restart file. | |
void | initial_read (ifstream &fin, long int &mstep, double &tmax, int &tab, double &, int &nxmin, int &nxmax, int &nymin, int &nymax, int &nzmin, int &nzmax, double &xmin, double &xmax, double &ymin, double &ymax, double &zmin, double &zmax, double &cfl, double &cdt, double &etaa, double &etab, double &etabb, double &KOep, int &exg, int &contn, char *file_continue, double &mu, double &kk, double &xi2, double &xi3, double &w3, double &mus, double &kks, double &xi2s, double &xi3s, double &Hb, double &fluidw, double &Mkap, double &bminmod, double &ptintval1, double &ptintval2, double &changept) |
Reads simulation parameters from the main initialization file (par_ini.d ). | |
void | initial_fmr ( ifstream &fin, int &laymax, int *jbs, int *kbs, int *lbs, double *alp_fmr) |
Reads Fixed Mesh Refinement (FMR) parameters from par_fmr.d . | |
void | ahf_read (ifstream &fin, double &AHFstart, int &ahcint, int &ahpint, int &ntheta, int &nphi, int &ahloop, double &etaah, double &facn, double &err_p, double &err_e, double &ahc) |
Reads Apparent Horizon Finder (AHF) parameters from par_ahf.d . | |
int | main (int argc, char *argv[]) |
Main function for the COSMOS simulation code. | |
void ahf_read | ( | ifstream & | fin, |
double & | AHFstart, | ||
int & | ahcint, | ||
int & | ahpint, | ||
int & | ntheta, | ||
int & | nphi, | ||
int & | ahloop, | ||
double & | etaah, | ||
double & | facn, | ||
double & | err_p, | ||
double & | err_e, | ||
double & | ahc ) |
Reads Apparent Horizon Finder (AHF) parameters from par_ahf.d
.
fin | Input file stream for par_ahf.d . |
AHFstart | Simulation time at which to start searching for apparent horizons. |
ahcint | Time step interval between AHF calls. |
ahpint | Time step interval for printing detailed AH information (e.g., shape). |
ntheta | Number of grid points in the theta direction for the AHF surface. |
nphi | Number of grid points in the phi direction for the AHF surface. |
ahloop | Maximum number of iterations allowed for the AHF solver. |
etaah | Relaxation parameter (eta) for the AHF elliptic solver. (Note: parameter name mismatch with variable var in main ) |
facn | Mixing factor for using the previous step's solution as an initial guess. |
err_p | Tolerance for the Poisson solver part of the AHF. |
err_e | Tolerance for the main apparent horizon equation solver. |
ahc | Initial guess for the coordinate radius of the apparent horizon. |
Reads parameters controlling the behavior and execution of the apparent horizon finder from the par_ahf.d
file. Aborts if the file cannot be opened.
void check_continue_file | ( | ifstream & | fcontinue, |
bool & | fld, | ||
bool & | scl, | ||
int & | tab, | ||
int & | nxmin, | ||
int & | nxmax, | ||
int & | nymin, | ||
int & | nymax, | ||
int & | nzmin, | ||
int & | nzmax, | ||
int & | laymax, | ||
int & | ln, | ||
int * | jbs, | ||
int * | kbs, | ||
int * | lbs ) |
Checks if parameters in the restart file match the current simulation setup.
fcontinue | Input file stream for the restart file (out_all.dat ). |
fld | Boolean indicating if fluid evolution is enabled (checked against file). |
scl | Boolean indicating if scalar field evolution is enabled (checked against file). |
tab | Number of ghost zones (checked against file). |
nxmin | Minimum x-index (checked against file). |
nxmax | Maximum x-index (checked against file). |
nymin | Minimum y-index (checked against file). |
nymax | Maximum y-index (checked against file). |
nzmin | Minimum z-index (checked against file). |
nzmax | Maximum z-index (checked against file). |
laymax | Maximum allowed FMR layer number (checked against file's ln ). |
ln | Current FMR layer number (read from file). |
jbs | Array of x-boundaries for FMR layers (checked against file). |
kbs | Array of y-boundaries for FMR layers (checked against file). |
lbs | Array of z-boundaries for FMR layers (checked against file). |
Reads header lines from the restart file (out_all.dat
) and compares the stored parameters (like grid dimensions, enabled physics modules, FMR setup) against the parameters provided from the current run's configuration. If any mismatch is found, it prints an error message and exits the program. It also reads the number of layers (ln
) present in the restart file.
void initial_fmr | ( | ifstream & | fin, |
int & | laymax, | ||
int * | jbs, | ||
int * | kbs, | ||
int * | lbs, | ||
double * | alp_fmr ) |
Reads Fixed Mesh Refinement (FMR) parameters from par_fmr.d
.
fin | Input file stream for par_fmr.d . |
laymax | Maximum number of FMR layers allowed. |
jbs | Array to store the x-index boundary for each FMR layer. |
kbs | Array to store the y-index boundary for each FMR layer. |
lbs | Array to store the z-index boundary for each FMR layer. |
alp_fmr | Array to store the central lapse function value threshold for adding each FMR layer. |
Reads the maximum number of layers and then iteratively reads the grid index boundaries (j, k, l) and the lapse threshold (alp_fmr
) for triggering the creation of each refinement layer. Aborts if the file cannot be opened.
void initial_read | ( | ifstream & | fin, |
long int & | mstep, | ||
double & | tmax, | ||
int & | tab, | ||
double & | amp, | ||
int & | nxmin, | ||
int & | nxmax, | ||
int & | nymin, | ||
int & | nymax, | ||
int & | nzmin, | ||
int & | nzmax, | ||
double & | xmin, | ||
double & | xmax, | ||
double & | ymin, | ||
double & | ymax, | ||
double & | zmin, | ||
double & | zmax, | ||
double & | cfl, | ||
double & | cdt, | ||
double & | etaa, | ||
double & | etab, | ||
double & | etabb, | ||
double & | KOep, | ||
int & | exg, | ||
int & | contn, | ||
char * | file_continue, | ||
double & | mu, | ||
double & | kk, | ||
double & | xi2, | ||
double & | xi3, | ||
double & | w3, | ||
double & | mus, | ||
double & | kks, | ||
double & | xi2s, | ||
double & | xi3s, | ||
double & | Hb, | ||
double & | fluidw, | ||
double & | Mkap, | ||
double & | bminmod, | ||
double & | ptintval1, | ||
double & | ptintval2, | ||
double & | changept ) |
Reads simulation parameters from the main initialization file (par_ini.d
).
fin | Input file stream for par_ini.d . |
mstep | Maximum number of time steps. |
tmax | Maximum simulation time. |
tab | Number of ghost zones. |
amp | Amplitude parameter for inhomogeneous grid stretching. |
nxmin | Minimum x-index. |
nxmax | Maximum x-index. |
nymin | Minimum y-index. |
nymax | Maximum y-index. |
nzmin | Minimum z-index. |
nzmax | Maximum z-index. |
xmin | Minimum x-coordinate. |
xmax | Maximum x-coordinate. |
ymin | Minimum y-coordinate. |
ymax | Maximum y-coordinate. |
zmin | Minimum z-coordinate. |
zmax | Maximum z-coordinate. |
cfl | CFL factor for time step calculation. |
cdt | Cosmological time scale factor for time step. |
etaa | Gauge parameter eta_alpha for 1+log slicing. |
etab | Gauge parameter eta_beta for Gamma-driver shift. |
etabb | Gauge parameter eta_B for Gamma-driver shift. |
KOep | Coefficient for Kreiss-Oliger dissipation. |
exg | Grid index for excision boundary (if used). |
contn | Flag indicating whether to continue from a restart file (1=yes, 0=no). |
file_continue | Name of the restart file (e.g., "out_all.dat"). |
mu | Amplitude of the initial metric perturbation. |
kk | Wavenumber/scale of the initial metric perturbation. |
xi2 | Non-sphericity parameter 1 for metric perturbation. |
xi3 | Non-sphericity parameter 2 for metric perturbation. |
w3 | Non-sphericity parameter 3 for metric perturbation. |
mus | Amplitude of the initial scalar field perturbation. |
kks | Wavenumber/scale of the initial scalar field perturbation. |
xi2s | Non-sphericity parameter 1 for scalar field perturbation Laplacian. |
xi3s | Non-sphericity parameter 2 for scalar field perturbation Laplacian. |
Hb | Initial Hubble parameter. |
fluidw | Equation of state parameter (w = P/rho) for the fluid. |
Mkap | Kappa parameter for MUSCL reconstruction in fluid dynamics. |
bminmod | Beta parameter for the minmod limiter in fluid dynamics. |
ptintval1 | Initial time interval for printing output. |
ptintval2 | Secondary time interval for printing output. |
changept | Time at which the printing interval switches from ptintval1 to ptintval2. |
Reads parameters line by line from par_ini.d
, skipping comment lines starting with '#'. Uses sscanf
to parse values. Aborts if the file cannot be opened.
int main | ( | int | argc, |
char * | argv[] ) |
Main function for the COSMOS simulation code.
argc | Number of command-line arguments. |
argv | Array of command-line arguments. |
This is the main driver routine for the simulation. It performs the following steps:
par_ini.d
, par_fmr.d
, and par_ahf.d
.Fmv
) and potentially higher FMR layers (Fmv1
).Ahf2d
).out_all.dat
).BSSN
calls).void output_params | ( | ofstream & | fileall, |
bool & | fld, | ||
bool & | scl, | ||
int & | tab, | ||
int & | nxmin, | ||
int & | nxmax, | ||
int & | nymin, | ||
int & | nymax, | ||
int & | nzmin, | ||
int & | nzmax, | ||
int & | laymax, | ||
int & | ln, | ||
int * | jbs, | ||
int * | kbs, | ||
int * | lbs ) |
Writes essential simulation parameters to the header of the restart file.
fileall | Output file stream for the restart file (out_all.dat ). |
fld | Boolean indicating if fluid evolution is enabled. |
scl | Boolean indicating if scalar field evolution is enabled. |
tab | Number of ghost zones. |
nxmin | Minimum x-index. |
nxmax | Maximum x-index. |
nymin | Minimum y-index. |
nymax | Maximum y-index. |
nzmin | Minimum z-index. |
nzmax | Maximum z-index. |
laymax | Maximum allowed FMR layer number (informational, not strictly needed for restart). |
ln | Current FMR layer number being saved. |
jbs | Array of x-boundaries for FMR layers. |
kbs | Array of y-boundaries for FMR layers. |
lbs | Array of z-boundaries for FMR layers. |
Writes specially formatted comment lines (##key=value
) at the beginning of the out_all.dat
file. These lines store crucial parameters needed to correctly interpret the data during a restart, ensuring consistency.
void printpack | ( | Fmv0 ** | fmv0, |
int | ln, | ||
int | pk, | ||
int | pl, | ||
ofstream & | filex, | ||
ofstream & | filey, | ||
ofstream & | filez, | ||
ofstream & | filex0z, | ||
ofstream & | filexy0 ) |
Helper function to call print routines for all active grid layers.
fmv0 | Array of pointers to Fmv0 objects (grid hierarchy). |
ln | Current highest layer index. |
pk | Y-index for slices. |
pl | Z-index for slices. |
filex | Output stream for x-slices. |
filey | Output stream for y-slices. |
filez | Output stream for z-slices. |
filex0z | Output stream for xz-plane slices. |
filexy0 | Output stream for xy-plane slices. |
Iterates through the grid hierarchy, calls dyntoprim
if needed, and then calls the respective print methods (print_x
, print_y
, print_z
, print_xz
, print_xy
) for each layer.