COSMOS
cosmos_d.h
Go to the documentation of this file.
1
12 #ifndef COSMOS_H // Ensure include guards are present
13 #define COSMOS_H
14
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <math.h>
18 #include <string.h>
19 // Include other necessary headers like complex.h if used
20
21 // --- Constants and Macros (Example) ---
23 #define G_CONST 1.0
25 #define C_LIGHT 1.0
26 // Add other constants/macros if present
27
28 // --- Enums (Example if you have them) ---
30 typedef enum {
34 // Add other boundary types
36
37
38 // --- Fmv0 Class ---
47 class Fmv0 {
48 public: // Or protected, depending on your design
49 // --- Member Variables (Document important public/protected ones) ---
51 int tab;
53 int jmin;
55 int jmax;
56 // ... (similarly for kmin, kmax, lmin, lmax)
58 double xmin;
60 double xmax;
61 // ... (similarly for ymin, ymax, zmin, zmax)
63 double dx;
64 // ... (similarly for dy, dz)
66 double cfl;
68 double etaa;
70 double etab;
72 double etabb;
74 double KOep;
76 double Hb;
78 double fluidw;
80 double kap_MUSCL;
82 double b_minmod;
84 int exg;
86 double tmax;
88 double amp;
89
90 // Pointers to grid function arrays (Example for lapse 'alp')
92 double ***alp;
94 double ***betax;
95 // ... (Document ALL BSSN variables: betay, betaz, Gamh1, Gamh2, Gamh3, trK, A11, A12, ...)
96 // ... (Document scalar field variables: sf, Pi)
97 // ... (Document fluid variables: rho, Sx, Sy, Sz, tau)
98 // ... (Document auxiliary variables: Bx, By, Bz)
99 // ... (Document boundary flags: bflag)
100
101 // --- Constructor & Destructor ---
129 Fmv0(int tabs, int jupper, int jlower, int kupper, int klower, int lupper, int llower,
130 double xupper, double xlower, double yupper, double ylower, double zupper, double zlower,
131 double cfl_in, double etaa_in, double etab_in, double etabb_in, double KOep_in, int exg_in,
132 double Hb_in, double fluidw_in, double kap_MUSCL_in, double b_minmod_in, double amp_in);
133
137 virtual ~Fmv0(); // Make destructor virtual if inheritance is used
138
139 // --- Core Methods ---
149 virtual void rhs(double dt, double t); // Make virtual if overridden
150
156 void KOdiss(double ***q, double ***f);
157
163 double funcf(double x);
165 double df(double x);
167 double ddf(double x);
169 double dddf(double x);
170
171 // --- Getters/Setters (Examples) ---
173 int get_tab() const;
175 double get_cfl() const;
177 bool get_fluidevo() const; // Implement logic based on your setup
185 int& set_bflag(int l, int k, int j);
193 int get_bflag(int l, int k, int j) const;
194
195 // --- Utility Functions (Examples) ---
197 double*** matrix(long nrl, long nrh, long ncl, long nch, long ndl, long ndh);
199 void free_matrix(double ***m, long nrl, long nrh, long ncl, long nch, long ndl, long ndh);
200 // Add similar functions for int*** if needed (like for bflag)
201
202 protected: // Or private
203 // --- Helper functions for RHS (Examples) ---
205 double D1x(double ***f, int l, int k, int j); // Add similar for y, z, higher orders
207 void calculate_christoffel(int l, int k, int j /*, output parameters */);
209 void calculate_ricci(int l, int k, int j /*, output parameters */);
211 void calculate_matter_sources(int l, int k, int j /*, output parameters */);
212
213 // Add other protected members/methods if necessary
214 };
215
216
217 // --- Fmv Class ---
225 class Fmv : public Fmv0 {
226 public:
233 Fmv(/* Parameters matching Fmv0 constructor */); // List all params again
234
238 virtual ~Fmv();
239
240 // --- Overridden/Specific Methods ---
246 virtual void set_boundary(); // Override if Fmv0::set_boundary is virtual
247
258 void initial_data(double t, double mu, double kk, double xi2, double xi3, double w3);
259
269 void initial_nonsph(double t, double mu, double kk, double xi2, double xi3, double w3);
270
278 void set_initial_scalar(double mus, double kks, double xi2s, double xi3s);
279
285 void set_initial_fluid(double t /*, ... */);
286
287 // Add other specific methods for this class
288 };
289
290
291 // --- Fmv1 Class ---
301 class Fmv1 : public Fmv0 {
302 public:
306 Fmv0 **fmv; // Or Fmv **fmv;
308 int *jbs;
310 int *kbs;
312 int *lbs;
314 double *alp_fmr;
315
326 Fmv1(int laymax_in, int *jbs_in, int *kbs_in, int *lbs_in, double *alp_fmr_in /*, base level params */);
327
331 virtual ~Fmv1();
332
341 void evolution(double dt, double t);
342
348
353 void create_refinement_level(int level);
354
360 void prolongate(int coarse_level, int fine_level);
361
367 void restrict(int fine_level, int coarse_level);
368
369 // Add other FMR-specific methods
370 };
371
372
373 #endif // COSMOS_H
374
Base class for Finite Mesh Variables version 0.
Definition cosmos_d.h:47
double cfl
CFL factor for time step calculation.
Definition cosmos_d.h:66
double kap_MUSCL
MUSCL reconstruction parameter kappa (if fluid enabled).
Definition cosmos_d.h:80
int get_bflag(int l, int k, int j) const
Get the boundary flag at a specific grid point.
bool get_fluidevo() const
Check if fluid evolution is enabled (based on fluidw perhaps).
double b_minmod
Minmod limiter parameter b (if fluid enabled).
Definition cosmos_d.h:82
double get_cfl() const
Get the CFL factor.
void calculate_matter_sources(int l, int k, int j)
Calculates matter source terms (Stress-Energy Tensor T_munu).
void KOdiss(double ***q, double ***f)
Applies Kreiss-Oliger numerical dissipation to evolved variables.
double *** matrix(long nrl, long nrh, long ncl, long nch, long ndl, long ndh)
Allocates memory for a 3D grid function array.
double etab
Gauge parameter eta for Gamma-driver shift.
Definition cosmos_d.h:70
int get_tab() const
Get the number of buffer zones.
double tmax
Maximum simulation time.
Definition cosmos_d.h:86
void calculate_christoffel(int l, int k, int j)
Calculates Christoffel symbols or connection functions.
int & set_bflag(int l, int k, int j)
Set the boundary flag at a specific grid point. Returns a reference.
double df(double x)
First derivative of the coordinate mapping function funcf.
double xmin
Minimum coordinate value in x.
Definition cosmos_d.h:58
double D1x(double ***f, int l, int k, int j)
Calculates spatial derivatives (e.g., first derivative in x).
int tab
Number of buffer/ghost zones.
Definition cosmos_d.h:51
double ddf(double x)
Second derivative of the coordinate mapping function funcf.
int jmax
Maximum physical grid index in x.
Definition cosmos_d.h:55
void calculate_ricci(int l, int k, int j)
Calculates Ricci tensor components.
double fluidw
Fluid equation of state parameter w (if fluid enabled).
Definition cosmos_d.h:78
double KOep
Kreiss-Oliger dissipation coefficient epsilon.
Definition cosmos_d.h:74
double amp
Grid stretching parameter for coordinate mapping.
Definition cosmos_d.h:88
double funcf(double x)
Coordinate mapping function from logical coordinate (e.g., j*dx) to physical coordinate.
double Hb
Initial Hubble parameter.
Definition cosmos_d.h:76
virtual ~Fmv0()
Destructor for the Fmv0 class. Frees allocated memory.
double dx
Grid spacing in x (uniform logical grid).
Definition cosmos_d.h:63
double etaa
Gauge parameter eta for 1+log lapse.
Definition cosmos_d.h:68
void free_matrix(double ***m, long nrl, long nrh, long ncl, long nch, long ndl, long ndh)
Frees memory allocated by matrix().
double dddf(double x)
Third derivative of the coordinate mapping function funcf.
double *** betax
Pointer to the shift vector component beta^x grid data.
Definition cosmos_d.h:94
int jmin
Minimum physical grid index in x.
Definition cosmos_d.h:53
double *** alp
Pointer to the lapse function grid data.
Definition cosmos_d.h:92
int exg
Grid size for excision region (if enabled).
Definition cosmos_d.h:84
double xmax
Maximum coordinate value in x.
Definition cosmos_d.h:60
double etabb
Gauge parameter eta_b (or similar) for Gamma-driver shift.
Definition cosmos_d.h:72
virtual void rhs(double dt, double t)
Calculates the right-hand sides (RHS) of the BSSN evolution equations.
Fmv0(int tabs, int jupper, int jlower, int kupper, int klower, int lupper, int llower, double xupper, double xlower, double yupper, double ylower, double zupper, double zlower, double cfl_in, double etaa_in, double etab_in, double etabb_in, double KOep_in, int exg_in, double Hb_in, double fluidw_in, double kap_MUSCL_in, double b_minmod_in, double amp_in)
Constructor for the Fmv0 class.
Derived class from Fmv0, implementing Fixed Mesh Refinement (FMR).
Definition cosmos_d.h:301
void create_refinement_level(int level)
Creates a new refinement level.
int * lbs
Array storing z-boundary indices for refinement regions on coarser levels.
Definition cosmos_d.h:312
Fmv0 ** fmv
Array of pointers to Fmv0/Fmv objects representing each refinement level.
Definition cosmos_d.h:306
int * jbs
Array storing x-boundary indices for refinement regions on coarser levels.
Definition cosmos_d.h:308
void evolution(double dt, double t)
Performs one full evolution step across all refinement levels.
int * kbs
Array storing y-boundary indices for refinement regions on coarser levels.
Definition cosmos_d.h:310
virtual ~Fmv1()
Destructor for the Fmv1 class. Deallocates levels.
void check_refinement_trigger(double t)
Checks if new refinement levels need to be created based on triggers.
void restrict(int fine_level, int coarse_level)
Averages data from a finer level to a coarser level (Restriction).
double * alp_fmr
Array storing lapse threshold values for triggering refinement.
Definition cosmos_d.h:314
int laymax
Maximum number of refinement levels.
Definition cosmos_d.h:304
Fmv1(int laymax_in, int *jbs_in, int *kbs_in, int *lbs_in, double *alp_fmr_in)
Constructor for the Fmv1 class (FMR manager).
void prolongate(int coarse_level, int fine_level)
Interpolates data from a coarser level to a finer level (Prolongation).
Derived class from Fmv0, implementing specific boundary conditions and initial data routines for the ...
Definition cosmos_d.h:225
void set_initial_fluid(double t)
Sets the initial data for the fluid variables (if enabled).
virtual ~Fmv()
Destructor for the Fmv class.
virtual void set_boundary()
Sets the boundary conditions for all evolved grid functions.
void set_initial_scalar(double mus, double kks, double xi2s, double xi3s)
Sets the initial data for the scalar field variables.
void initial_nonsph(double t, double mu, double kk, double xi2, double xi3, double w3)
Sets the initial data for the geometric (BSSN) variables with non-spherical perturbations.
Fmv()
Constructor for the Fmv class.
void initial_data(double t, double mu, double kk, double xi2, double xi3, double w3)
Sets up the initial data for the simulation.
BoundaryType
Enum defining possible boundary condition types.
Definition cosmos_d.h:30
@ BOUNDARY_PERIODIC
Definition cosmos_d.h:31
@ BOUNDARY_REFLECTING
Definition cosmos_d.h:32
@ BOUNDARY_OUTFLOW
Definition cosmos_d.h:33