Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First pass at core GR infrastructure #354

Merged
merged 40 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
1271f3d
Began robustifying conservative->primitive SRHD recovery algorithm, a…
JonathanGorard Apr 9, 2024
3c8b724
Implementing general Lax RP solver (SR-only for now, but should exten…
JonathanGorard Apr 9, 2024
4b0e784
The mildly relativistic shock problem and strongly relativistic blast…
JonathanGorard Apr 9, 2024
473203d
Added 2D SRHD quadrants test, and slightly refactored the two 1D rela…
JonathanGorard Apr 9, 2024
1dd73cf
Added initial core infrastructure (gkyl_gr_spacetime object) for hand…
JonathanGorard Apr 10, 2024
ca63a5d
Added default (gr_minkowski) gkyl_gr_spacetime object, along with all…
JonathanGorard Apr 10, 2024
6131363
Fluid solver has been generalized to curved spacetimes! Mild relativi…
JonathanGorard Apr 10, 2024
5441863
Added excision boundary conditions and refactored mild relativistic s…
JonathanGorard Apr 10, 2024
56aa2b0
Fixed handling of excision boundary conditions so that they now work …
JonathanGorard Apr 10, 2024
a6c6cbb
Added dependence of fluid variables on the inverse spatial metric com…
JonathanGorard Apr 10, 2024
286014c
Implemented full GRHD eigensystem, but (inevitably) it's slower and l…
JonathanGorard Apr 11, 2024
c6ef8c7
Very *very* preliminary implementation of black hole spacetimes. Most…
JonathanGorard Apr 11, 2024
bcc60c2
GR fluid solver is now (more-or-less) robust, following several cruci…
JonathanGorard Apr 11, 2024
44ca80e
Added BH spacetime metric in Kerr-Schild coordinates, plus added pert…
JonathanGorard Apr 15, 2024
2af21b0
Merge branch 'main' into gr-prototyping
JonathanGorard Apr 15, 2024
7302511
Added fallback to fast SR time-step estimator when flat spacetime is …
JonathanGorard Apr 16, 2024
ce93778
Refactored static and spinning black hole tests, and added Bondi-Hoyl…
JonathanGorard Apr 16, 2024
1aa5232
Added refactored relativistic Kelvin-Helmholtz instability test. It g…
JonathanGorard Apr 16, 2024
4601337
Starting implementation on general relativistic Roe solver, but this …
JonathanGorard Apr 17, 2024
d700211
I'm going to level with you here: this code does not work. Like, at a…
JonathanGorard Apr 17, 2024
97e9f86
Fixed various random typos and implementation issues. The GR Roe solv…
JonathanGorard Apr 18, 2024
610c658
Fixed various things. The GR Roe solver still doesn't work, but in, l…
JonathanGorard Apr 18, 2024
e1f7fd9
Added metric inverses, plus metric and gauge derivative functions, fo…
JonathanGorard Apr 23, 2024
97717e2
Progress towards fixing the GR Roe solver. Flux jumps are now correct…
JonathanGorard Apr 23, 2024
3bc9c74
Added spatial and spacetime Christoffel symbol computations, and adde…
JonathanGorard Apr 24, 2024
c97dce9
Added flat spacetime unit test (with full test coverage).
JonathanGorard Apr 24, 2024
12c34d6
Fixed malloc -> gkyl_malloc conventions consistently throughout GR co…
JonathanGorard Apr 24, 2024
1a3e92d
(Mostly) stabilized Roe solver for the SR limit, although there are s…
JonathanGorard Apr 25, 2024
65fcaad
Fixed fast computation of inverse spacetime metric for general black …
JonathanGorard Apr 25, 2024
66d3194
Added consistency check for spatial/spacetime Christoffel symbols to …
JonathanGorard Apr 25, 2024
f9e5bbb
Added automatic checking of extrinsic curvature tensor constraint to …
JonathanGorard Apr 25, 2024
2374a2e
Fixed an absolutely catastrophic, weapons-grade memory leak that I fo…
JonathanGorard Apr 25, 2024
a1f6320
Refactored black hole/curved spacetime regression tests, and fixed ge…
JonathanGorard Apr 26, 2024
bf927ac
Fixed memory leak in spacetime unit test.
JonathanGorard Apr 26, 2024
fe37e66
Added consistent releasing for gr_spacetime objects.
JonathanGorard Apr 26, 2024
2f13be5
Added unit test for general relativistic Euler equations (testing con…
JonathanGorard Apr 26, 2024
a91f7af
Added prototype Riemann and Ricci curvature tensor (and scalar) funct…
JonathanGorard Apr 28, 2024
bc5b793
Merge branch 'main' into gr-prototyping
JonathanGorard May 4, 2024
2763af7
Factored out finite-difference approximations of metric derivative qu…
JonathanGorard May 4, 2024
ee8771b
Added spatial and spacetime Weyl tensor computations (e.g. for potent…
JonathanGorard May 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
502 changes: 502 additions & 0 deletions regression/rt_gr_bhl_spinning.c

Large diffs are not rendered by default.

502 changes: 502 additions & 0 deletions regression/rt_gr_bhl_static.c

Large diffs are not rendered by default.

526 changes: 526 additions & 0 deletions regression/rt_gr_blackhole_spinning.c

Large diffs are not rendered by default.

526 changes: 526 additions & 0 deletions regression/rt_gr_blackhole_static.c

Large diffs are not rendered by default.

489 changes: 489 additions & 0 deletions regression/rt_gr_kh_2d.c

Large diffs are not rendered by default.

452 changes: 452 additions & 0 deletions regression/rt_gr_mild_shock.c

Large diffs are not rendered by default.

452 changes: 452 additions & 0 deletions regression/rt_gr_perturbed_density.c

Large diffs are not rendered by default.

529 changes: 529 additions & 0 deletions regression/rt_gr_quadrants_2d.c

Large diffs are not rendered by default.

452 changes: 452 additions & 0 deletions regression/rt_gr_strong_blast.c

Large diffs are not rendered by default.

429 changes: 429 additions & 0 deletions unit/ctest_gr_euler.c

Large diffs are not rendered by default.

1,029 changes: 1,029 additions & 0 deletions unit/ctest_gr_spacetime.c

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions zero/gkyl_eqn_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ enum gkyl_eqn_type {
GKYL_EQN_MHD, // Ideal MHD equations
GKYL_EQN_BURGERS, // Burgers equations
GKYL_EQN_ADVECTION, // Scalar advection equation
GKYL_EQN_GR_EULER, // General relativistic Euler equations.
};

// Identifiers for specific field object types
Expand Down
542 changes: 542 additions & 0 deletions zero/gkyl_gr_blackhole.h

Large diffs are not rendered by default.

453 changes: 453 additions & 0 deletions zero/gkyl_gr_minkowski.h

Large diffs are not rendered by default.

581 changes: 581 additions & 0 deletions zero/gkyl_gr_spacetime.h

Large diffs are not rendered by default.

265 changes: 265 additions & 0 deletions zero/gkyl_gr_spacetime_diff.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,265 @@
#pragma once

#include <math.h>
#include <gkyl_array.h>
#include <gkyl_gr_spacetime.h>
#include <gkyl_range.h>
#include <gkyl_util.h>

/**
* Compute the rank-3 (spatial) partial derivative of the spatial metric tensor at a given point in spacetime, using finite differences.
*
* @param spacetime Base spacetime object.
* @param t Time coordinate.
* @param x Spatial coordinate (x-direction).
* @param y Spatial coordinate (y-direction).
* @param z Spatial coordinate (z-direction).
* @param dx Spatial coordinate spacing (x-direction).
* @param dy Spatial coordinate spacing (y-direction).
* @param dz Spatial coordinate spacing (z-direction).
* @param spatial_metric_tensor_diff Rank-3 partial derivative of the spatial metric tensor (output).
*/
GKYL_CU_D
void
gkyl_gr_spatial_metric_tensor_diff(const struct gkyl_gr_spacetime* spacetime, const double t, const double x, const double y, const double z,
const double dx, const double dy, const double dz, double**** spatial_metric_tensor_diff);

/**
* Compute the rank-3 (spacetime) partial derivative of the spacetime metric tensor at a given point in spacetime, using finite differences.
*
* @param spacetime Base spacetime object.
* @param t Time coordinate.
* @param x Spatial coordinate (x-direction).
* @param y Spatial coordinate (y-direction).
* @param z Spatial coordinate (z-direction).
* @param dt Time coordinate spacing.
* @param dx Spatial coordinate spacing (x-direction).
* @param dy Spatial coordinate spacing (y-direction).
* @param dz Spatial coordinate spacing (z-direction).
* @param spacetime_metric_tensor_diff Rank-3 partial derivative of the spacetime metric tensor (output).
*/
GKYL_CU_D
void
gkyl_gr_spacetime_metric_tensor_diff(const struct gkyl_gr_spacetime* spacetime, const double t, const double x, const double y, const double z,
const double dt, const double dx, const double dy, const double dz, double**** spacetime_metric_tensor_diff);

/**
* Compute the rank-1 (spatial) partial derivative of the lapse function at a given point in spacetime, using finite differences.
*
* @param spacetime Base spacetime object.
* @param t Time coordinate.
* @param x Spatial coordinate (x-direction).
* @param y Spatial coordinate (y-direction).
* @param z Spatial coordinate (z-direction).
* @param dx Spatial coordinate spacing (x-direction).
* @param dy Spatial coordinate spacing (y-direction).
* @param dz Spatial coordinate spacing (z-direction).
* @param lapse_function_diff Rank-1 partial derivative of the lapse function (output).
*/
GKYL_CU_D
void
gkyl_gr_lapse_function_diff(const struct gkyl_gr_spacetime* spacetime, const double t, const double x, const double y, const double z,
const double dx, const double dy, const double dz, double** lapse_function_diff);

/**
* Compute the rank-2 (spatial) partial derivative of the shift vector at a given point in spacetime, using finite differences.
*
* @param spacetime Base spacetime object.
* @param t Time coordinate.
* @param x Spatial coordinate (x-direction).
* @param y Spatial coordinate (y-direction).
* @param z Spatial coordinate (z-direction).
* @param dx Spatial coordinate spacing (x-direction).
* @param dy Spatial coordinate spacing (y-direction).
* @param dz Spatial coordinate spacing (z-direction).
* @param shift_vector_diff Rank-2 partial derivative of the shift vector (output).
*/
GKYL_CU_D
void
gkyl_gr_shift_vector_diff(const struct gkyl_gr_spacetime* spacetime, const double t, const double x, const double y, const double z,
const double dx, const double dy, const double dz, double*** shift_vector_diff);

/**
* Compute the rank-3 (spatial) Christoffel symbols at a given point in spacetime, using finite differences.
*
* @param spacetime Base spacetime object.
* @param t Time coordinate.
* @param x Spatial coordinate (x-direction).
* @param y Spatial coordinate (y-direction).
* @param z Spatial coordinate (z-direction).
* @param dx Spatial coordinate spacing (x-direction).
* @param dy Spatial coordinate spacing (y-direction).
* @param dz Spatial coordinate spacing (z-direction).
* @param spatial_christoffel Rank-3 spatial Christoffel symbols (output).
*/
GKYL_CU_D
void
gkyl_gr_spatial_christoffel_fd(const struct gkyl_gr_spacetime* spacetime, const double t, const double x, const double y, const double z,
const double dx, const double dy, const double dz, double**** spatial_christoffel);

/**
* Compute the rank-3 (spacetime) Christoffel symbols at a given point in spacetime, using finite differences.
*
* @param spacetime Base spacetime object.
* @param t Time coordinate.
* @param x Spatial coordinate (x-direction).
* @param y Spatial coordinate (y-direction).
* @param z Spatial coordinate (z-direction).
* @param dt Time coordinate spacing.
* @param dx Spatial coordinate spacing (x-direction).
* @param dy Spatial coordinate spacing (y-direction).
* @param dz Spatial coordinate spacing (z-direction).
* @param spacetime_christoffel Rank-3 spacetime Christoffel symbols (output).
*/
GKYL_CU_D
void
gkyl_gr_spacetime_christoffel_fd(const struct gkyl_gr_spacetime* spacetime, const double t, const double x, const double y, const double z,
const double dt, const double dx, const double dy, const double dz, double**** spacetime_christoffel);

/**
* Compute the rank-4 (spatial) Riemann curvature tensor at a given point in spacetime, using finite differences.
*
* @param spacetime Base spacetime object.
* @param t Time coordinate.
* @param x Spatial coordinate (x-direction).
* @param y Spatial coordinate (y-direction).
* @param z Spatial coordinate (z-direction).
* @param dx Spatial coordinate spacing (x-direction).
* @param dy Spatial coordinate spacing (y-direction).
* @param dz Spatial coordinate spacing (z-direction).
* @param spatial_riemann_tensor Rank-4 spatial Riemann curvature tensor (output).
*/
GKYL_CU_D
void
gkyl_gr_spatial_riemann_tensor_fd(const struct gkyl_gr_spacetime* spacetime, const double t, const double x, const double y, const double z,
const double dx, const double dy, const double dz, double***** spatial_riemann_tensor);

/**
* Compute the rank-4 (spacetime) Riemann curvature tensor at a given point in spacetime, using finite differences.
*
* @param spacetime Base spacetime object.
* @param t Time coordinate.
* @param x Spatial coordinate (x-direction).
* @param y Spatial coordinate (y-direction).
* @param z Spatial coordinate (z-direction).
* @param dt Time coordinate spacing.
* @param dx Spatial coordinate spacing (x-direction).
* @param dy Spatial coordinate spacing (y-direction).
* @param dz Spatial coordinate spacing (z-direction).
* @param spacetime_riemann_tensor Rank-4 spacetime Riemann curvature tensor (output).
*/
GKYL_CU_D
void
gkyl_gr_spacetime_riemann_tensor_fd(const struct gkyl_gr_spacetime* spacetime, const double t, const double x, const double y, const double z,
const double dt, const double dx, const double dy, const double dz, double***** spacetime_riemann_tensor);

/**
* Compute the rank-2 (spatial) Ricci curvature tensor at a given point in spacetime, using finite differences.
*
* @param spacetime Base spacetime object.
* @param t Time coordinate.
* @param x Spatial coordinate (x-direction).
* @param y Spatial coordinate (y-direction).
* @param z Spatial coordinate (z-direction).
* @param dx Spatial coordinate spacing (x-direction).
* @param dy Spatial coordinate spacing (y-direction).
* @param dz Spatial coordinate spacing (z-direction).
* @param spatial_ricci_tensor Rank-2 spatial Ricci curvature tensor (output).
*/
GKYL_CU_D
void
gkyl_gr_spatial_ricci_tensor_fd(const struct gkyl_gr_spacetime* spacetime, const double t, const double x, const double y, const double z,
const double dx, const double dy, const double dz, double*** spatial_ricci_tensor);

/**
* Compute the rank-2 (spacetime) Ricci curvature tensor at a given point in spacetime, using finite differences.
*
* @param spacetime Base spacetime object.
* @param t Time coordinate.
* @param x Spatial coordinate (x-direction).
* @param y Spatial coordinate (y-direction).
* @param z Spatial coordinate (z-direction).
* @param dt Time coordinate spacing.
* @param dx Spatial coordinate spacing (x-direction).
* @param dy Spatial coordinate spacing (y-direction).
* @param dz Spatial coordinate spacing (z-direction).
* @param spacetime_ricci_tensor Rank-2 spacetime Ricci curvature tensor (output).
*/
GKYL_CU_D
void
gkyl_gr_spacetime_ricci_tensor_fd(const struct gkyl_gr_spacetime* spacetime, const double t, const double x, const double y, const double z,
const double dt, const double dx, const double dy, const double dz, double*** spacetime_ricci_tensor);

/**
* Compute the (spatial) Ricci scalar curvature at a given point in spacetime, using finite differences.
*
* @param spacetime Base spacetime object.
* @param t Time coordinate.
* @param x Spatial coordinate (x-direction).
* @param y Spatial coordinate (y-direction).
* @param z Spatial coordinate (z-direction).
* @param dx Spatial coordinate spacing (x-direction).
* @param dy Spatial coordinate spacing (y-direction).
* @param dz Spatial coordinate spacing (z-direction).
* @param spatial_ricci_scalar Spatial Ricci scalar curvature (output).
*/
GKYL_CU_D
void
gkyl_gr_spatial_ricci_scalar_fd(const struct gkyl_gr_spacetime* spacetime, const double t, const double x, const double y, const double z,
const double dx, const double dy, const double dz, double* spatial_ricci_scalar);

/**
* Compute the (spacetime) Ricci scalar curvature at a given point in spacetime, using finite differences.
*
* @param spacetime Base spacetime object.
* @param t Time coordinate.
* @param x Spatial coordinate (x-direction).
* @param y Spatial coordinate (y-direction).
* @param z Spatial coordinate (z-direction).
* @param dt Time coordinate spacing.
* @param dx Spatial coordinate spacing (x-direction).
* @param dy Spatial coordinate spacing (y-direction).
* @param dz Spatial coordinate spacing (z-direction).
* @param spacetime_ricci_tensor Spacetime Ricci scalar curvature (output).
*/
GKYL_CU_D
void
gkyl_gr_spacetime_ricci_scalar_fd(const struct gkyl_gr_spacetime* spacetime, const double t, const double x, const double y, const double z,
const double dt, const double dx, const double dy, const double dz, double* spacetime_ricci_scalar);

/**
* Compute the rank-4 (spatial) Weyl curvature tensor at a given point in spacetime, using finite differences.
*
* @param spacetime Base spacetime object.
* @param t Time coordinate.
* @param x Spatial coordinate (x-direction).
* @param y Spatial coordinate (y-direction).
* @param z Spatial coordinate (z-direction).
* @param dx Spatial coordinate spacing (x-direction).
* @param dy Spatial coordinate spacing (y-direction).
* @param dz Spatial coordinate spacing (z-direction).
* @param spatial_weyl_tensor Rank-4 spatial Weyl curvature tensor (output).
*/
GKYL_CU_D
void
gkyl_gr_spatial_weyl_tensor_fd(const struct gkyl_gr_spacetime* spacetime, const double t, const double x, const double y, const double z,
const double dx, const double dy, const double dz, double***** spatial_weyl_tensor);

/**
* Compute the rank-4 (spacetime) Weyl curvature tensor at a given point in spacetime, using finite differences.
*
* @param spacetime Base spacetime object.
* @param t Time coordinate.
* @param x Spatial coordinate (x-direction).
* @param y Spatial coordinate (y-direction).
* @param z Spatial coordinate (z-direction).
* @param dt Time coordinate spacing.
* @param dx Spatial coordinate spacing (x-direction).
* @param dy Spatial coordinate spacing (y-direction).
* @param dz Spatial coordinate spacing (z-direction).
* @param spacetime_weyl_tensor Rank-4 spacetime Weyl curvature tensor (output).
*/
GKYL_CU_D
void
gkyl_gr_spacetime_weyl_tensor_fd(const struct gkyl_gr_spacetime* spacetime, const double t, const double x, const double y, const double z,
const double dt, const double dx, const double dy, const double dz, double***** spacetime_weyl_tensor);
56 changes: 56 additions & 0 deletions zero/gkyl_wv_gr_euler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#pragma once

#include <gkyl_wv_eqn.h>
#include <gkyl_gr_spacetime.h>

// Type of Riemann-solver to use:
enum gkyl_wv_gr_euler_rp {
WV_GR_EULER_RP_LAX = 0, // Default (Lax fluxes).
WV_GR_EULER_RP_ROE,
};

// Input context, packaged as a struct.
struct gkyl_wv_gr_euler_inp {
double gas_gamma; // Adiabatic index.
struct gkyl_gr_spacetime *spacetime; // Pointer to base spacetime object.
enum gkyl_wv_gr_euler_rp rp_type; // Type of Riemann-solver to use.
bool use_gpu; // Whether the wave equation object is on the host (false) or the device (true).
};

/**
* Create a new general relativistic Euler equations object.
*
* @param gas_gamma Adiabatic index.
* @param spacetime Pointer to base spacetime object.
* @param use_gpu Whether the wave equation object is on the host (false) or the device (true).
* @return Pointer to the general relativistic Euler equations object.
*/
struct gkyl_wv_eqn*
gkyl_wv_gr_euler_new(double gas_gamma, struct gkyl_gr_spacetime* spacetime, bool use_gpu);

/**
* Create a new general relativistic Euler equations object, from an input context struct.
*
* @param inp Input context struct.
* @return Pointer to the general relativistic Euler equations object.
*/
struct gkyl_wv_eqn*
gkyl_wv_gr_euler_inew(const struct gkyl_wv_gr_euler_inp* inp);

/**
* Get adiabatic index.
*
* @param wv General relativistic Euler equations object.
* @return Adiabatic index.
*/
double
gkyl_wv_gr_euler_gas_gamma(const struct gkyl_wv_eqn* wv);

/**
* Get base spacetime object.
*
* @param wv General relativistic Euler equations object.
* @return Pointer to the base spacetime object.
*/
struct gkyl_gr_spacetime*
gkyl_wv_gr_euler_spacetime(const struct gkyl_wv_eqn* wv);
Loading
Loading