Skip to content

Commit

Permalink
Merge pull request #429 from ammarhakim/dg_10m
Browse files Browse the repository at this point in the history
Refactors and improvements to PKPM, SR Vlasov, and Canonical Poisson Bracket systems
  • Loading branch information
ammarhakim authored Jul 23, 2024
2 parents db60d35 + 71e083b commit 4c6796b
Show file tree
Hide file tree
Showing 649 changed files with 88,867 additions and 27,096 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ UNIT_CU_OBJS =
# There is some problem with the Vlasov and Maxwell kernels that is causing some unit builds to fail
ifdef USING_NVCC
# UNIT_CU_SRCS = $(shell find unit -name *.cu)
UNIT_CU_SRCS = unit/ctest_cusolver.cu unit/ctest_basis_cu.cu unit/ctest_array_cu.cu unit/ctest_mom_vlasov_cu.cu unit/ctest_range_cu.cu unit/ctest_rect_grid_cu.cu unit/ctest_wave_geom_cu.cu unit/ctest_wv_euler_cu.cu
UNIT_CU_SRCS = unit/ctest_cusolver.cu unit/ctest_basis_cu.cu unit/ctest_array_cu.cu unit/ctest_mom_vlasov_cu.cu unit/ctest_range_cu.cu unit/ctest_rect_grid_cu.cu unit/ctest_wave_geom_cu.cu unit/ctest_wv_euler_cu.cu unit/ctest_wv_maxwell_cu.cu unit/ctest_wv_ten_moment_cu.cu
UNIT_CU_OBJS = $(UNIT_CU_SRCS:%=$(BUILD_DIR)/%.o)
endif

Expand Down
8 changes: 4 additions & 4 deletions amr/amr_core_five_moment.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ five_moment_1d_run_single(int argc, char **argv, struct five_moment_1d_single_in
mesh_pdata[i].euler_elc = gkyl_wv_euler_new(gas_gamma, app_args.use_gpu);
mesh_pdata[i].euler_ion = gkyl_wv_euler_new(gas_gamma, app_args.use_gpu);
}
mesh_pdata[i].maxwell = gkyl_wv_maxwell_new(light_speed, e_fact, b_fact);
mesh_pdata[i].maxwell = gkyl_wv_maxwell_new(light_speed, e_fact, b_fact, app_args.use_gpu);

mesh_pdata[i].slvr_elc[0] = gkyl_wave_prop_new(& (struct gkyl_wave_prop_inp) {
.grid = &mesh_pdata[i].grid,
Expand Down Expand Up @@ -399,7 +399,7 @@ five_moment_1d_run_double(int argc, char **argv, struct five_moment_1d_double_in
mesh_pdata[i].euler_elc = gkyl_wv_euler_new(gas_gamma, app_args.use_gpu);
mesh_pdata[i].euler_ion = gkyl_wv_euler_new(gas_gamma, app_args.use_gpu);
}
mesh_pdata[i].maxwell = gkyl_wv_maxwell_new(light_speed, e_fact, b_fact);
mesh_pdata[i].maxwell = gkyl_wv_maxwell_new(light_speed, e_fact, b_fact, app_args.use_gpu);

mesh_pdata[i].slvr_elc[0] = gkyl_wave_prop_new(& (struct gkyl_wave_prop_inp) {
.grid = &mesh_pdata[i].grid,
Expand Down Expand Up @@ -744,7 +744,7 @@ five_moment_2d_run_single(int argc, char **argv, struct five_moment_2d_single_in
mesh_bdata[i].euler_elc = gkyl_wv_euler_new(gas_gamma, app_args.use_gpu);
mesh_bdata[i].euler_ion = gkyl_wv_euler_new(gas_gamma, app_args.use_gpu);
}
mesh_bdata[i].maxwell = gkyl_wv_maxwell_new(light_speed, e_fact, b_fact);
mesh_bdata[i].maxwell = gkyl_wv_maxwell_new(light_speed, e_fact, b_fact, app_args.use_gpu);

for (int d = 0; d < ndim; d++) {
mesh_bdata[i].slvr_elc[d] = gkyl_wave_prop_new(& (struct gkyl_wave_prop_inp) {
Expand Down Expand Up @@ -1124,7 +1124,7 @@ five_moment_2d_run_double(int argc, char **argv, struct five_moment_2d_double_in
mesh_bdata[i].euler_elc = gkyl_wv_euler_new(gas_gamma, app_args.use_gpu);
mesh_bdata[i].euler_ion = gkyl_wv_euler_new(gas_gamma, app_args.use_gpu);
}
mesh_bdata[i].maxwell = gkyl_wv_maxwell_new(light_speed, e_fact, b_fact);
mesh_bdata[i].maxwell = gkyl_wv_maxwell_new(light_speed, e_fact, b_fact, app_args.use_gpu);

for (int d = 0; d < ndim; d++) {
mesh_bdata[i].slvr_elc[d] = gkyl_wave_prop_new(& (struct gkyl_wave_prop_inp) {
Expand Down
18 changes: 9 additions & 9 deletions amr/amr_core_ten_moment.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ ten_moment_1d_run_single(int argc, char **argv, struct ten_moment_1d_single_init
}

for (int i = 0; i < num_patches; i++) {
mesh_pdata[i].euler_elc = gkyl_wv_ten_moment_new(k0_elc);
mesh_pdata[i].euler_ion = gkyl_wv_ten_moment_new(k0_ion);
mesh_pdata[i].maxwell = gkyl_wv_maxwell_new(light_speed, e_fact, b_fact);
mesh_pdata[i].euler_elc = gkyl_wv_ten_moment_new(k0_elc, app_args.use_gpu);
mesh_pdata[i].euler_ion = gkyl_wv_ten_moment_new(k0_ion, app_args.use_gpu);
mesh_pdata[i].maxwell = gkyl_wv_maxwell_new(light_speed, e_fact, b_fact, app_args.use_gpu);

mesh_pdata[i].slvr_elc[0] = gkyl_wave_prop_new(& (struct gkyl_wave_prop_inp) {
.grid = &mesh_pdata[i].grid,
Expand Down Expand Up @@ -401,9 +401,9 @@ ten_moment_2d_run_single(int argc, char **argv, struct ten_moment_2d_single_init
}

for (int i = 0; i < num_blocks; i++) {
mesh_bdata[i].euler_elc = gkyl_wv_ten_moment_new(k0_elc);
mesh_bdata[i].euler_ion = gkyl_wv_ten_moment_new(k0_ion);
mesh_bdata[i].maxwell = gkyl_wv_maxwell_new(light_speed, e_fact, b_fact);
mesh_bdata[i].euler_elc = gkyl_wv_ten_moment_new(k0_elc, app_args.use_gpu);
mesh_bdata[i].euler_ion = gkyl_wv_ten_moment_new(k0_ion, app_args.use_gpu);
mesh_bdata[i].maxwell = gkyl_wv_maxwell_new(light_speed, e_fact, b_fact, app_args.use_gpu);

for (int d = 0; d < ndim; d++) {
mesh_bdata[i].slvr_elc[d] = gkyl_wave_prop_new(& (struct gkyl_wave_prop_inp) {
Expand Down Expand Up @@ -770,9 +770,9 @@ ten_moment_2d_run_double(int argc, char **argv, struct ten_moment_2d_double_init
}

for (int i = 0; i < num_blocks; i++) {
mesh_bdata[i].euler_elc = gkyl_wv_ten_moment_new(k0_elc);
mesh_bdata[i].euler_ion = gkyl_wv_ten_moment_new(k0_ion);
mesh_bdata[i].maxwell = gkyl_wv_maxwell_new(light_speed, e_fact, b_fact);
mesh_bdata[i].euler_elc = gkyl_wv_ten_moment_new(k0_elc, app_args.use_gpu);
mesh_bdata[i].euler_ion = gkyl_wv_ten_moment_new(k0_ion, app_args.use_gpu);
mesh_bdata[i].maxwell = gkyl_wv_maxwell_new(light_speed, e_fact, b_fact, app_args.use_gpu);

for (int d = 0; d < ndim; d++) {
mesh_bdata[i].slvr_elc[d] = gkyl_wave_prop_new(& (struct gkyl_wave_prop_inp) {
Expand Down
23 changes: 20 additions & 3 deletions apps/gkyl_pkpm.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,14 @@ struct gkyl_pkpm_species {
// diffusion coupling to include for momentum
struct gkyl_pkpm_fluid_diffusion diffusion;

void *accel_ctx; // context for applied acceleration function
void *app_accel_ctx; // context for applied acceleration function
// pointer to applied acceleration function
void (*accel)(double t, const double *xn, double *aout, void *ctx);
void (*app_accel)(double t, const double *xn, double *aout, void *ctx);
bool app_accel_evolve; // set to true if applied acceleration function is time dependent

double limiter_fac; // Optional input parameter for adjusting diffusion in slope limiter
bool limit_fluid; // Optional input parameter for applying limiters to fluid variables

// boundary conditions
enum gkyl_species_bc_type bcx[2], bcy[2], bcz[2];
};
Expand Down Expand Up @@ -101,6 +104,9 @@ struct gkyl_pkpm_field {
void (*app_current)(double t, const double *xn, double *app_current_out, void *ctx);
bool app_current_evolve; // set to true if applied current function is time dependent

double limiter_fac; // Optional input parameter for adjusting diffusion in slope limiter
bool limit_em; // Optional input parameter for applying limiters to EM fields

// boundary conditions
enum gkyl_field_bc_type bcx[2], bcy[2], bcz[2];
};
Expand All @@ -115,6 +121,12 @@ struct gkyl_pkpm {
int poly_order; // polynomial order
enum gkyl_basis_type basis_type; // type of basis functions to use

void *c2p_ctx; // context for mapc2p function
// pointer to mapc2p function: xc are the computational space
// coordinates and on output xp are the corresponding physical space
// coordinates.
void (*mapc2p)(double t, const double *xc, double *xp, void *ctx);

double cfl_frac; // CFL fraction to use (default 1.0)

bool use_gpu; // Flag to indicate if solver should use GPUs
Expand All @@ -125,9 +137,12 @@ struct gkyl_pkpm {
int num_species; // number of species
struct gkyl_pkpm_species species[GKYL_MAX_SPECIES]; // species objects

bool skip_field; // Skip field update or no field specified
struct gkyl_pkpm_field field; // field object

bool use_explicit_source; // Use fully explicit SSP RK3 scheme
// Default is a first-order operator split with
// implicit fluid-EM coupling.

// this should not be set by typical user-facing code but only by
// higher-level drivers
bool has_low_inp; // should one use low-level inputs?
Expand All @@ -148,6 +163,8 @@ struct gkyl_pkpm_stat {
double stage_3_dt_diff[2]; // [min,max] rel-diff for stage-3 failure

double total_tm; // time for simulation (not including ICs)
double rk3_tm; // time for SSP RK3 step
double pkpm_em_tm; // time for implicit fluid-EM coupling step
double init_species_tm; // time to initialize all species
double init_fluid_species_tm; // time to initialize all fluid species
double init_field_tm; // time to initialize fields
Expand Down
Loading

0 comments on commit 4c6796b

Please sign in to comment.