diff --git a/core/zero/gkyl_eqn_type.h b/core/zero/gkyl_eqn_type.h index b3388eab11..10e7da7cf6 100644 --- a/core/zero/gkyl_eqn_type.h +++ b/core/zero/gkyl_eqn_type.h @@ -186,4 +186,5 @@ enum gkyl_gk_collisionless_type { GKYL_GK_COLLISIONLESS_EM_BPAR, // Electromagnetic with B_par fluctuations. GKYL_GK_COLLISIONLESS_EM, // Electromagnetic with B_perp and B_par fluctuations. GKYL_GK_COLLISIONLESS_NEUTRAL, // Neutral collisionless terms. + GKYL_GK_COLLISIONLESS_PASSIVE, // Passive advection (for dev/debug). }; diff --git a/core/zero/gkyl_rect_grid.h b/core/zero/gkyl_rect_grid.h index 0c1c772279..dbf7d6f150 100644 --- a/core/zero/gkyl_rect_grid.h +++ b/core/zero/gkyl_rect_grid.h @@ -50,7 +50,7 @@ struct gkyl_rect_grid* gkyl_rect_grid_new(int ndim, * @param pick_lower If point is on a cell boundary, pick the lower cell if true (per direction). * @param known_index Any known indices of where the point is (<0 if not known). * @param cell_index Pointer to cell indices. - * Asserts: point lies within cell(s) specified by knownIdx (if specified). + * Asserts: point lies within cell(s) specified by known_index (if specified). */ GKYL_CU_DH void gkyl_rect_grid_find_cell(const struct gkyl_rect_grid *grid, const double *point, @@ -158,4 +158,3 @@ bool gkyl_rect_grid_read(struct gkyl_rect_grid *grid, FILE *fp); * @param grid Grid object. */ void gkyl_rect_grid_release(struct gkyl_rect_grid *grid); - diff --git a/core/zero/rect_grid.c b/core/zero/rect_grid.c index 73ca69b2a4..4e645015a3 100644 --- a/core/zero/rect_grid.c +++ b/core/zero/rect_grid.c @@ -103,7 +103,7 @@ gkyl_rect_grid_find_cell(const struct gkyl_rect_grid *grid, const double *point, } for (int i=0; icdim, - .bcdir_ext_update_r = app->global_par_ext, + .bcdir_ext_update_r = &app->global_par_ext, .num_ghost = ghost, // one ghost per config direction - .basis = app->basis, - .grid = app->grid, + .basis = &app->basis, + .grid = &app->grid, .use_gpu = app->use_gpu, }; if (app->gk_geom->geometry_id == GKYL_GEOMETRY_TOKAMAK) @@ -271,7 +271,7 @@ gk_field_2x3x_add_TS_updaters(struct gkyl_gyrokinetic_app *app, struct gk_field T_LU_lo.shift_func = app->gk_geom->parallel_lower_bc_shift_func; T_LU_lo.shift_func_ctx = app->gk_geom->parallel_lower_bc_shift_ctx; } - f->bc_ts_lo = gkyl_bc_twistshift_new(&T_LU_lo); + f->bc_ts_lo = gkyl_bc_twistshift_inew(&T_LU_lo); // TS BC updater for upper edge. struct gkyl_bc_twistshift_inp T_UL_up = { @@ -280,10 +280,10 @@ gk_field_2x3x_add_TS_updaters(struct gkyl_gyrokinetic_app *app, struct gk_field .shear_dir = 0, // shift varies with x. .edge = GKYL_UPPER_EDGE, .cdim = app->cdim, - .bcdir_ext_update_r = app->global_par_ext, + .bcdir_ext_update_r = &app->global_par_ext, .num_ghost = ghost, // one ghost per config direction - .basis = app->basis, - .grid = app->grid, + .basis = &app->basis, + .grid = &app->grid, .use_gpu = app->use_gpu, }; if (app->gk_geom->geometry_id == GKYL_GEOMETRY_TOKAMAK) @@ -292,7 +292,7 @@ gk_field_2x3x_add_TS_updaters(struct gkyl_gyrokinetic_app *app, struct gk_field T_UL_up.shift_func = app->gk_geom->parallel_upper_bc_shift_func; T_UL_up.shift_func_ctx = app->gk_geom->parallel_upper_bc_shift_ctx; } - f->bc_ts_up = gkyl_bc_twistshift_new(&T_UL_up); + f->bc_ts_up = gkyl_bc_twistshift_inew(&T_UL_up); long buff_sz = app->global_lower_ghost[par_dir].volume; f->bc_buffer = mkarr(app->use_gpu, app->basis.num_basis, buff_sz); @@ -356,10 +356,10 @@ gk_field_2x3x_add_IWL_updaters(struct gkyl_gyrokinetic_app *app, struct gk_field .shear_dir = 0, // shift varies with x. .edge = GKYL_LOWER_EDGE, .cdim = app->cdim, - .bcdir_ext_update_r = app->global_par_ext_core, + .bcdir_ext_update_r = &app->global_par_ext_core, .num_ghost = ghost, // one ghost per config direction - .basis = app->basis, - .grid = app->grid, + .basis = &app->basis, + .grid = &app->grid, .use_gpu = app->use_gpu, }; if (app->gk_geom->geometry_id == GKYL_GEOMETRY_TOKAMAK) @@ -368,7 +368,7 @@ gk_field_2x3x_add_IWL_updaters(struct gkyl_gyrokinetic_app *app, struct gk_field T_LU_lo.shift_func = app->gk_geom->parallel_lower_bc_shift_func; T_LU_lo.shift_func_ctx = app->gk_geom->parallel_lower_bc_shift_ctx; } - f->bc_ts_lo = gkyl_bc_twistshift_new(&T_LU_lo); + f->bc_ts_lo = gkyl_bc_twistshift_inew(&T_LU_lo); long buff_sz = GKYL_MAX2(app->global_lower_ghost_par_sol.volume, app->global_lower_ghost_par_core.volume); f->bc_buffer = mkarr(app->use_gpu, app->basis.num_basis, buff_sz); diff --git a/gyrokinetic/apps/gk_species.c b/gyrokinetic/apps/gk_species.c index 2b93be63cf..873236eda2 100644 --- a/gyrokinetic/apps/gk_species.c +++ b/gyrokinetic/apps/gk_species.c @@ -886,10 +886,10 @@ gk_species_init_dynamic(struct gkyl_gk *gk_app_inp, struct gkyl_gyrokinetic_app .shear_dir = 0, // shift varies with x. .edge = GKYL_LOWER_EDGE, .cdim = cdim, - .bcdir_ext_update_r = gks->local_par_ext, + .bcdir_ext_update_r = &gks->local_par_ext, .num_ghost = ghost, - .basis = gks->basis, - .grid = gks->grid, + .basis = &gks->basis, + .grid = &gks->grid, .use_gpu = app->use_gpu, }; if (app->gk_geom->geometry_id == GKYL_GEOMETRY_TOKAMAK) @@ -899,7 +899,7 @@ gk_species_init_dynamic(struct gkyl_gk *gk_app_inp, struct gkyl_gyrokinetic_app tsinp.shift_func_ctx = app->gk_geom->parallel_lower_bc_shift_ctx; } - gks->bc_ts_lo = gkyl_bc_twistshift_new(&tsinp); + gks->bc_ts_lo = gkyl_bc_twistshift_inew(&tsinp); } else if ( (gks->lower_bc[d].type == GKYL_BC_GK_SPECIES_COPY) || @@ -946,10 +946,10 @@ gk_species_init_dynamic(struct gkyl_gk *gk_app_inp, struct gkyl_gyrokinetic_app .shear_dir = 0, // shift varies with x. .edge = GKYL_UPPER_EDGE, .cdim = cdim, - .bcdir_ext_update_r = gks->local_par_ext, + .bcdir_ext_update_r = &gks->local_par_ext, .num_ghost = ghost, - .basis = gks->basis, - .grid = gks->grid, + .basis = &gks->basis, + .grid = &gks->grid, .use_gpu = app->use_gpu, }; if (app->gk_geom->geometry_id == GKYL_GEOMETRY_TOKAMAK) @@ -959,7 +959,7 @@ gk_species_init_dynamic(struct gkyl_gk *gk_app_inp, struct gkyl_gyrokinetic_app tsinp.shift_func_ctx = app->gk_geom->parallel_upper_bc_shift_ctx; } - gks->bc_ts_up = gkyl_bc_twistshift_new(&tsinp); + gks->bc_ts_up = gkyl_bc_twistshift_inew(&tsinp); } else if ( (gks->upper_bc[d].type == GKYL_BC_GK_SPECIES_COPY) || (gks->upper_bc[d].type == GKYL_BC_GK_SPECIES_ABSORB) || @@ -999,10 +999,10 @@ gk_species_init_dynamic(struct gkyl_gk *gk_app_inp, struct gkyl_gyrokinetic_app .shear_dir = 0, // shift varies with x. .edge = GKYL_LOWER_EDGE, .cdim = cdim, - .bcdir_ext_update_r = gks->local_par_ext_core, + .bcdir_ext_update_r = &gks->local_par_ext_core, .num_ghost = ghost, - .basis = gks->basis, - .grid = gks->grid, + .basis = &gks->basis, + .grid = &gks->grid, .use_gpu = app->use_gpu, }; if (app->gk_geom->geometry_id == GKYL_GEOMETRY_TOKAMAK) @@ -1011,7 +1011,7 @@ gk_species_init_dynamic(struct gkyl_gk *gk_app_inp, struct gkyl_gyrokinetic_app tsinp_lo.shift_func = app->gk_geom->parallel_lower_bc_shift_func; tsinp_lo.shift_func_ctx = app->gk_geom->parallel_lower_bc_shift_ctx; } - gks->bc_ts_lo = gkyl_bc_twistshift_new(&tsinp_lo); + gks->bc_ts_lo = gkyl_bc_twistshift_inew(&tsinp_lo); struct gkyl_bc_twistshift_inp tsinp_up = { .bc_dir = par_dir, @@ -1019,10 +1019,10 @@ gk_species_init_dynamic(struct gkyl_gk *gk_app_inp, struct gkyl_gyrokinetic_app .shear_dir = 0, // shift varies with x. .edge = GKYL_UPPER_EDGE, .cdim = cdim, - .bcdir_ext_update_r = gks->local_par_ext_core, + .bcdir_ext_update_r = &gks->local_par_ext_core, .num_ghost = ghost, - .basis = gks->basis, - .grid = gks->grid, + .basis = &gks->basis, + .grid = &gks->grid, .use_gpu = app->use_gpu, }; if (app->gk_geom->geometry_id == GKYL_GEOMETRY_TOKAMAK) @@ -1031,7 +1031,7 @@ gk_species_init_dynamic(struct gkyl_gk *gk_app_inp, struct gkyl_gyrokinetic_app tsinp_up.shift_func = app->gk_geom->parallel_upper_bc_shift_func; tsinp_up.shift_func_ctx = app->gk_geom->parallel_upper_bc_shift_ctx; } - gks->bc_ts_up = gkyl_bc_twistshift_new(&tsinp_up); + gks->bc_ts_up = gkyl_bc_twistshift_inew(&tsinp_up); } // Set function pointers. diff --git a/gyrokinetic/apps/gk_species_bflux.c b/gyrokinetic/apps/gk_species_bflux.c index 7787e55620..689ecb4320 100644 --- a/gyrokinetic/apps/gk_species_bflux.c +++ b/gyrokinetic/apps/gk_species_bflux.c @@ -688,8 +688,11 @@ gk_species_bflux_init(struct gkyl_gyrokinetic_app *app, void *species, bflux->eqns = gkyl_malloc(bflux->num_eqns*sizeof(struct gkyl_dg_eqn *)); int eqc = 0; - if (gk_s->collisionless.collisionless_id) + if (gk_s->collisionless.collisionless_id == GKYL_GK_COLLISIONLESS_PASSIVE) + bflux->eqns[eqc++] = gkyl_dg_updater_gyrokinetic_passive_acquire_eqn(gk_s->collisionless.passive_slvr); + else if (gk_s->collisionless.collisionless_id) bflux->eqns[eqc++] = gkyl_dg_updater_gyrokinetic_acquire_eqn(gk_s->collisionless.slvr); + if (gk_s->anom_diff.anom_diff_id) bflux->eqns[eqc++] = gkyl_dg_updater_gk_anomalous_diffusion_acquire_eqn(gk_s->anom_diff.slvr); diff --git a/gyrokinetic/apps/gk_species_collisionless.c b/gyrokinetic/apps/gk_species_collisionless.c index b6520b51a4..10fffe3592 100644 --- a/gyrokinetic/apps/gk_species_collisionless.c +++ b/gyrokinetic/apps/gk_species_collisionless.c @@ -1,6 +1,13 @@ #include #include +static void +eval_on_nodes_c2p_position_func(const double *xcomp, double *xphys, void *ctx) +{ + struct gkyl_position_map *gpm = ctx; + gkyl_position_map_eval_mc2nu(gpm, xcomp, xphys); +} + static void gk_species_collisionless_flux_disabled(gkyl_gyrokinetic_app *app, struct gk_species *species, struct gk_collisionless *gkcls, const struct gkyl_array *fin) @@ -45,6 +52,31 @@ gk_species_collisionless_rhs_enabled(gkyl_gyrokinetic_app *app, struct gk_specie app->stat.species_collisionless_tm += gkyl_time_diff_now_sec(wst); } +static void +gk_species_collisionless_passive_flux(gkyl_gyrokinetic_app *app, struct gk_species *species, + struct gk_collisionless *gkcls, const struct gkyl_array *fin) +{ + gkyl_gk_collisionless_passive_flux_surf(gkcls->passive_surf_flux_op, + &app->local, &species->local, &app->local_ext, &species->local_ext, + fin, gkcls->flux_surf, species->cflrate); +} + +static void +gk_species_collisionless_passive_rhs(gkyl_gyrokinetic_app *app, struct gk_species *species, + struct gk_collisionless *gkcls, const struct gkyl_array *fin, struct gkyl_array *rhs) +{ + struct timespec wst = gkyl_wall_clock(); + + gkcls->flux_func(app, species, gkcls, fin); + + gkyl_dg_updater_gyrokinetic_passive_advance(gkcls->passive_slvr, &species->local, + fin, species->cflrate, rhs); + + gkcls->fdot_scaling(app, species, gkcls, rhs, species->cflrate, &species->local); + + app->stat.species_collisionless_tm += gkyl_time_diff_now_sec(wst); +} + static void gk_species_collisionless_fdot_scaling_disabled(gkyl_gyrokinetic_app *app, struct gk_species *gks, struct gk_collisionless *gkcls, struct gkyl_array *rhs, struct gkyl_array *cflrate, struct gkyl_range *rng) @@ -97,8 +129,75 @@ gk_species_collisionless_write_diags_enabled(gkyl_gyrokinetic_app* app, struct g app->stat.n_io += 1; } -void -gk_species_collisionless_init(struct gkyl_gyrokinetic_app *app, struct gk_species *gks, +static void +gk_species_collisionless_init_passive(struct gkyl_gyrokinetic_app *app, struct gk_species *gks, + struct gk_collisionless *gkcls, const bool *is_zero_flux, + const enum gkyl_gyrokinetic_bc_type *bctype_conf, const struct gkyl_basis *surf_basis) +{ + int cdim = app->cdim; + + gkcls->flux_surf = mkarr(app->use_gpu, cdim * surf_basis->num_basis, gks->local_ext.volume); + + gkcls->passive_speeds = mkarr(app->use_gpu, cdim * app->basis.num_basis, app->local_ext.volume); + gkcls->passive_speeds_ho = app->use_gpu? mkarr(false, gkcls->passive_speeds->ncomp, gkcls->passive_speeds->size) + : gkyl_array_acquire(gkcls->passive_speeds); + + struct gkyl_eval_on_nodes *speeds_proj = gkyl_eval_on_nodes_inew(&(struct gkyl_eval_on_nodes_inp){ + .grid = &app->grid, + .basis = &app->basis, + .num_ret_vals = cdim, + .eval = gks->info.collisionless.passive_speeds, + .ctx = gks->info.collisionless.passive_speeds_ctx, + .c2p_func = eval_on_nodes_c2p_position_func, + .c2p_func_ctx = app->position_map, + }); + gkyl_eval_on_nodes_advance(speeds_proj, 0.0, &app->local, gkcls->passive_speeds_ho); + gkyl_eval_on_nodes_release(speeds_proj); + gkyl_array_copy(gkcls->passive_speeds, gkcls->passive_speeds_ho); + + // Sync speeds. + int num_periodic_dir = app->num_periodic_dir; + gkyl_comm_array_per_sync(app->comm, &app->local, &app->local_ext, + num_periodic_dir, app->periodic_dirs, gkcls->passive_speeds); + gkyl_comm_array_sync(app->comm, &app->local, &app->local_ext, gkcls->passive_speeds); + + gkcls->passive_surf_flux_op = gkyl_gk_collisionless_passive_flux_new(&gks->grid, &app->basis, &gks->basis, + gkcls->passive_speeds, gks->info.charge, gks->info.mass, + app->gk_geom, app->dg_geom, app->gk_dg_geom, gks->vel_map, bctype_conf, app->use_gpu); + + struct gkyl_dg_gyrokinetic_passive_auxfields passive_aux = { + .flux_surf = gkcls->flux_surf, + .speeds = gkcls->passive_speeds, + }; + gkcls->passive_slvr = gkyl_dg_updater_gyrokinetic_passive_new(&gks->grid, &app->basis, &gks->basis, + &app->local, &gks->local, is_zero_flux, gks->info.charge, gks->info.mass, + app->gk_geom, gks->vel_map, &passive_aux, app->use_gpu); + + if (gkcls->write_diagnostics) { + gkyl_msgpack_map_elem_set_double(gks->io_meta_conf_len, gks->io_meta_conf, "time", 0.0); + gkyl_msgpack_map_elem_set_uint(gks->io_meta_conf_len, gks->io_meta_conf, "frame", 0); + struct gkyl_msgpack_map_elem desc[] = { + { .key = "Description", .elem_type = GKYL_MP_STRING, .cval = "Conf-space passive advection speeds." } + }; + int io_meta_len[] = {gks->io_meta_conf_len, app->gk_geom->io_meta_basic_len, 1}; + const struct gkyl_msgpack_map_elem* io_meta[] = {gks->io_meta_conf, app->gk_geom->io_meta_basic, desc}; + struct gkyl_msgpack_data *mt = gkyl_msgpack_create_union(sizeof(io_meta_len)/sizeof(int), io_meta_len, io_meta); + + const char *fmt = "%s-%s_passive_speeds_%d.gkyl"; + int sz = gkyl_calc_strlen(fmt, app->name, gks->info.name, 0); + char fileNm[sz+1]; + snprintf(fileNm, sizeof fileNm, fmt, app->name, gks->info.name, 0); + gkyl_comm_array_write(app->comm, &app->grid, &app->local, mt, gkcls->passive_speeds_ho, fileNm); + + gkyl_msgpack_data_release(mt); + } + + gkcls->flux_func = gk_species_collisionless_passive_flux; + gkcls->rhs_func = gk_species_collisionless_passive_rhs; +} + +void +gk_species_collisionless_init(struct gkyl_gyrokinetic_app *app, struct gk_species *gks, struct gk_collisionless *gkcls) { gkcls->collisionless_id = gks->info.collisionless.type; @@ -123,7 +222,7 @@ gk_species_collisionless_init(struct gkyl_gyrokinetic_app *app, struct gk_specie is_zero_flux[dir+pdim] = true; } - // Need to figure out size of flux_surf by finding size of surface basis set + // Need to figure out size of flux_surf by finding size of surface basis set struct gkyl_basis surf_basis; struct gkyl_basis surf_vpar_basis; // Define surface bases @@ -139,20 +238,6 @@ gk_species_collisionless_init(struct gkyl_gyrokinetic_app *app, struct gk_specie gkyl_cart_modal_serendip(&surf_basis, pdim-1, 2); // p=2 in vparallel } } - int flux_surf_sz = (cdim)*surf_basis.num_basis + surf_vpar_basis.num_basis; - - // Allocate arrays to store surface phase space flux. - gkcls->flux_surf = mkarr(app->use_gpu, flux_surf_sz, gks->local_ext.volume); - - if (gkcls->collisionless_id == GKYL_GK_COLLISIONLESS_EM_BPERP) { - // Parallel component of magnetic vector potential. - gkcls->apar = mkarr(app->use_gpu, app->basis.num_basis, app->local_ext.volume); - gkcls->apardot = mkarr(app->use_gpu, app->basis.num_basis, app->local_ext.volume); - } - else { - gkcls->apar = gkyl_array_acquire(app->field->phi_smooth); // Not used. - gkcls->apardot = gkyl_array_acquire(app->field->phi_smooth); // Not used. - } enum gkyl_gyrokinetic_bc_type bctype_conf[2*GKYL_MAX_CDIM]; for (int d=0; dcdim; d++) { @@ -160,18 +245,39 @@ gk_species_collisionless_init(struct gkyl_gyrokinetic_app *app, struct gk_specie bctype_conf[GKYL_MAX_CDIM+d] = gks->upper_bc[d].type; } - gkcls->surf_flux_op = gkyl_gk_collisionless_flux_new(&gks->grid, &app->basis, &gks->basis, - gks->info.charge, gks->info.mass, - gkcls->collisionless_id, app->gk_geom, - app->dg_geom, app->gk_dg_geom, gks->vel_map, bctype_conf, app->use_gpu); + if (gkcls->collisionless_id == GKYL_GK_COLLISIONLESS_PASSIVE) { + gk_species_collisionless_init_passive(app, gks, gkcls, is_zero_flux, bctype_conf, &surf_basis); + } else { + // Allocate arrays to store surface phase space flux. + gkcls->flux_surf = mkarr(app->use_gpu, + cdim*surf_basis.num_basis + surf_vpar_basis.num_basis, gks->local_ext.volume); + + if (gkcls->collisionless_id == GKYL_GK_COLLISIONLESS_EM_BPERP) { + // Parallel component of magnetic vector potential. + gkcls->apar = mkarr(app->use_gpu, app->basis.num_basis, app->local_ext.volume); + gkcls->apardot = mkarr(app->use_gpu, app->basis.num_basis, app->local_ext.volume); + } + else { + gkcls->apar = gkyl_array_acquire(app->field->phi_smooth); // Not used. + gkcls->apardot = gkyl_array_acquire(app->field->phi_smooth); // Not used. + } - struct gkyl_dg_gyrokinetic_auxfields aux_inp = { .flux_surf = gkcls->flux_surf, - .phi = gks->gyro_phi, .apar = gkcls->apar, .apardot = gkcls->apardot }; - // Create solver. - gkcls->slvr = gkyl_dg_updater_gyrokinetic_new(&gks->grid, &app->basis, &gks->basis, - &app->local, &gks->local, is_zero_flux, gks->info.charge, gks->info.mass, - gkcls->collisionless_id, app->gk_geom, gks->vel_map, - &aux_inp, app->use_gpu); + gkcls->surf_flux_op = gkyl_gk_collisionless_flux_new(&gks->grid, &app->basis, &gks->basis, + gks->info.charge, gks->info.mass, + gkcls->collisionless_id, app->gk_geom, + app->dg_geom, app->gk_dg_geom, gks->vel_map, bctype_conf, app->use_gpu); + + struct gkyl_dg_gyrokinetic_auxfields aux_inp = { .flux_surf = gkcls->flux_surf, + .phi = gks->gyro_phi, .apar = gkcls->apar, .apardot = gkcls->apardot }; + // Create solver. + gkcls->slvr = gkyl_dg_updater_gyrokinetic_new(&gks->grid, &app->basis, &gks->basis, + &app->local, &gks->local, is_zero_flux, gks->info.charge, gks->info.mass, + gkcls->collisionless_id, app->gk_geom, gks->vel_map, + &aux_inp, app->use_gpu); + + gkcls->flux_func = gk_species_collisionless_flux_enabled; + gkcls->rhs_func = gk_species_collisionless_rhs_enabled; + } gkcls->scale_fac = 1.0; // Not used if scale_factor in input file is not given. gkcls->fdot_scaling = gk_species_collisionless_fdot_scaling_disabled; @@ -180,9 +286,6 @@ gk_species_collisionless_init(struct gkyl_gyrokinetic_app *app, struct gk_specie gkcls->fdot_scaling = gk_species_collisionless_fdot_scaling_enabled; } - // Other methods chosen at runtime. - gkcls->flux_func = gk_species_collisionless_flux_enabled; - gkcls->rhs_func = gk_species_collisionless_rhs_enabled; if (gkcls->write_diagnostics) { gkcls->flux_surf_ho = mkarr(false, gkcls->flux_surf->ncomp, gkcls->flux_surf->size); gkcls->write_diags_func = gk_species_collisionless_write_diags_enabled; @@ -217,11 +320,18 @@ gk_species_collisionless_release(const struct gkyl_gyrokinetic_app *app, const s if (gkcls->collisionless_id) { gkyl_array_release(gkcls->flux_surf); - gkyl_array_release(gkcls->apar); - gkyl_array_release(gkcls->apardot); - - gkyl_gk_collisionless_flux_release(gkcls->surf_flux_op); - gkyl_dg_updater_gyrokinetic_release(gkcls->slvr); + + if (gkcls->collisionless_id == GKYL_GK_COLLISIONLESS_PASSIVE) { + gkyl_array_release(gkcls->passive_speeds); + gkyl_array_release(gkcls->passive_speeds_ho); + gkyl_gk_collisionless_passive_flux_release(gkcls->passive_surf_flux_op); + gkyl_dg_updater_gyrokinetic_passive_release(gkcls->passive_slvr); + } else { + gkyl_array_release(gkcls->apar); + gkyl_array_release(gkcls->apardot); + gkyl_gk_collisionless_flux_release(gkcls->surf_flux_op); + gkyl_dg_updater_gyrokinetic_release(gkcls->slvr); + } if (gkcls->write_diagnostics) { gkyl_array_release(gkcls->flux_surf_ho); diff --git a/gyrokinetic/apps/gkyl_gyrokinetic.h b/gyrokinetic/apps/gkyl_gyrokinetic.h index e04e1510ba..1d137b0963 100644 --- a/gyrokinetic/apps/gkyl_gyrokinetic.h +++ b/gyrokinetic/apps/gkyl_gyrokinetic.h @@ -100,6 +100,10 @@ struct gkyl_gyrokinetic_collisionless { enum gkyl_gk_collisionless_type type; // Type of collisionless terms. bool write_diagnostics; // Whether to output diagnostics. double scale_factor; // Factor multiplying collisionless terms (should be > 0). + // Passive advection speeds in x, y, z (for GKYL_GK_COLLISIONLESS_PASSIVE). + // Assumes no advection/dependence on vpar/mu. Should return cdim values. + evalf_t passive_speeds; + void *passive_speeds_ctx; // Context for passive_speeds. }; // Parameters for species collisions diff --git a/gyrokinetic/apps/gkyl_gyrokinetic_priv.h b/gyrokinetic/apps/gkyl_gyrokinetic_priv.h index 5615160973..e8d0955901 100644 --- a/gyrokinetic/apps/gkyl_gyrokinetic_priv.h +++ b/gyrokinetic/apps/gkyl_gyrokinetic_priv.h @@ -35,14 +35,17 @@ #include #include #include +#include #include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -287,9 +290,15 @@ struct gk_collisionless { struct gkyl_array *apar; // A_parallel. struct gkyl_array *apardot; // d/dt A_parallel. - struct gkyl_gk_collisionless_flux *surf_flux_op; // Collisionless fluxes. - gkyl_dg_updater_gyrokinetic *slvr; // Collisionless solver. - + struct gkyl_gk_collisionless_flux *surf_flux_op; // Collisionless fluxes (GK/EM cases). + gkyl_dg_updater_gyrokinetic *slvr; // Collisionless solver (GK/EM cases). + + // Passive advection (only for GKYL_GK_COLLISIONLESS_PASSIVE). + struct gkyl_array *passive_speeds; // Conf-space passive speeds. + struct gkyl_array *passive_speeds_ho; // Host copy of passive_speeds. + struct gkyl_gk_collisionless_passive_flux *passive_surf_flux_op; // Passive flux updater. + gkyl_dg_updater_gyrokinetic_passive *passive_slvr; // Passive collisionless solver. + // Methods chosen at runtime. void (*flux_func)(gkyl_gyrokinetic_app *app, struct gk_species *species, struct gk_collisionless *gkcls, const struct gkyl_array *fin); diff --git a/gyrokinetic/apps/gyrokinetic.c b/gyrokinetic/apps/gyrokinetic.c index 711b31cdbc..9d0298ed50 100644 --- a/gyrokinetic/apps/gyrokinetic.c +++ b/gyrokinetic/apps/gyrokinetic.c @@ -1251,15 +1251,15 @@ gyrokinetic_app_write_ts_shift_mapc2p(struct gkyl_gyrokinetic_app *app) .shear_dir = 0, // shift varies with x. .edge = eI == 0? GKYL_LOWER_EDGE : GKYL_UPPER_EDGE, .cdim = app->cdim, - .bcdir_ext_update_r = app->global_par_ext, + .bcdir_ext_update_r = &app->global_par_ext, .num_ghost = ghost, // one ghost per config direction - .basis = app->basis, - .grid = app->grid, + .basis = &app->basis, + .grid = &app->grid, .shift_func = eI == 0? app->gk_geom->parallel_lower_bc_shift_func : app->gk_geom->parallel_upper_bc_shift_func, .shift_func_ctx = eI == 0? app->gk_geom->parallel_lower_bc_shift_ctx : app->gk_geom->parallel_upper_bc_shift_ctx, .use_gpu = app->use_gpu, }; - struct gkyl_bc_twistshift *bc_ts_op = gkyl_bc_twistshift_new(&ts_inp); + struct gkyl_bc_twistshift *bc_ts_op = gkyl_bc_twistshift_inew(&ts_inp); struct gkyl_array *delta_ts_x = eI == 0? app->delta_ts_x_lo : app->delta_ts_x_up; delta_ts_x = gkyl_bc_twistshift_get_shift_objects(bc_ts_op, @@ -3566,11 +3566,11 @@ gkyl_gyrokinetic_app_release(gkyl_gyrokinetic_app* app) gkyl_dg_geom_release(app->dg_geom); gkyl_gk_dg_geom_release(app->gk_dg_geom); - if (app->gk_geom->geometry_id == GKYL_GEOMETRY_TOKAMAK) { - if (!gyrokinetic_str_ends_in_bnum(app->name)) { // Check if multiblock. - gkyl_array_release(app->delta_ts_x_lo); - gkyl_array_release(app->delta_ts_x_up); - } + if (app->cdim == 3 && (app->gk_geom->geometry_id == GKYL_GEOMETRY_TOKAMAK || + (app->gk_geom->geometry_id == GKYL_GEOMETRY_MAPC2P && + app->gk_geom->parallel_lower_bc_shift_func && app->gk_geom->parallel_upper_bc_shift_func))) { + gkyl_array_release(app->delta_ts_x_lo); + gkyl_array_release(app->delta_ts_x_up); } gk_field_release(app, app->field); gk_eirene_release(app, app->eirene); diff --git a/gyrokinetic/creg/rt_gk_cbc_2x2v_p1.c b/gyrokinetic/creg/rt_gk_cbc_2x2v_p1.c index b49d37b153..d3b08728c7 100644 --- a/gyrokinetic/creg/rt_gk_cbc_2x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_cbc_2x2v_p1.c @@ -9,16 +9,6 @@ #include #include #include -#include - -#ifdef GKYL_HAVE_MPI -#include -#include -#ifdef GKYL_HAVE_NCCL -#include -#endif -#endif - #include #include @@ -51,36 +41,36 @@ double interp_1x_lut(double x, double *lut_grid, double *lut_val, int N) // Define the context of the simulation. This stores global parameters. struct gk_app_ctx { - int cdim, vdim; - // Geometry and magnetic field parameters - double a_shift, Z_axis, R_axis, R0, a_mid, r0, B0, kappa, delta, q0, Cy, qaxis, qlcfs; - // Plasma parameters - double me, qe, mi, qi, n0, Te0, Ti0; - // Collision parameters - double nuFrac; - // Initial condition parameters - double Ln, LTe, LTi; - bool can_max; - // Krook and buffer parameters. - double nu_krook; - int num_cell_buff; - // Grid parameters - double Lx, Lz; - double x_min, z_min, x_max, z_max; - int num_cell_x, num_cell_z, num_cell_vpar, num_cell_mu; - int cells[GKYL_MAX_DIM], poly_order; - double vpar_max_elc, mu_max_elc, vpar_max_ion, mu_max_ion; - // Simulation control parameters - double final_time, write_phase_freq; - int num_frames, int_diag_calc_num, num_failures_max; - double dt_failure_tol; - double max_run_time; // Maximum run time in seconds, 0 means no limit. - // Table for intPsi interpolation and lookup table (LUT). - int psi_lut_size; - double *r_lut; - double *psi_lut; - // Table for dPsidr. - double *dPsidr_int_lut; + int cdim, vdim; + // Geometry and magnetic field parameters + double a_shift, Z_axis, R_axis, R0, a_mid, r0, B0, kappa, delta, q0, Cy, qaxis, qlcfs; + // Plasma parameters + double me, qe, mi, qi, n0, Te0, Ti0; + // Collision parameters + double nuFrac; + // Initial condition parameters + double Ln, LTe, LTi; + bool can_max; + // Krook and buffer parameters. + double nu_krook; + int num_cell_buff; + // Grid parameters + double Lx, Lz; + double x_min, z_min, x_max, z_max; + int Nx, Nz, Nvpar, Nmu; + int cells[GKYL_MAX_DIM], poly_order; + double vpar_max_elc, mu_max_elc, vpar_max_ion, mu_max_ion; + // Simulation control parameters + double t_end, write_phase_freq; + int num_frames, int_diag_calc_num, num_failures_max; + double dt_failure_tol; + double max_run_time; // Maximum run time in seconds, 0 means no limit. + // Table for intPsi interpolation and lookup table (LUT). + int psi_lut_size; + double *r_lut; + double *psi_lut; + // Table for dPsidr. + double *dPsidr_int_lut; }; // Geometry related functions @@ -326,7 +316,7 @@ void double_buffer_profile(double t, const double *xn, double *fout, void *ctx) { double x = xn[0]; struct gk_app_ctx *app = ctx; - int nx = app->num_cell_x; + int nx = app->Nx; double x_max = app->x_max; double x_min = app->x_min; double Lx = app->Lx; @@ -350,7 +340,7 @@ double tanh_profile(double x, double v0, double Lgrad, void *ctx) { struct gk_app_ctx *app = ctx; // Profile use in Gysela (see V. Grandgirard et al. / Computer Physics Communications 207 (2016) 35–68). - double buff_frac = (double)app->num_cell_buff / app->num_cell_x; + double buff_frac = (double)app->num_cell_buff / app->Nx; double delta = 0.5*(1-buff_frac) * app->Lx; double arg = x / (app->a_mid * delta); double prof_factor = (app->a_mid * delta) / Lgrad; @@ -536,12 +526,13 @@ struct gk_app_ctx create_ctx(void) double Cy = r0/q0; // Cylindrical coordinate shift for field-alignment. // Configuration domain parameters - double Lx = 150*rho_s; // Domain size along x. - double x_min = -Lx/2; - double x_max = Lx/2; - double Lz = 2.*M_PI-1e-10; // Domain size along magnetic field. - double z_min = -Lz/2.; - double z_max = Lz/2.; + double Lx = 150*rho_s; // Domain size along x. + double Lz = 2.*M_PI-1e-10; // Domain size along magnetic field. + + double x_min = -Lx/2; + double x_max = Lx/2; + double z_min = -Lz/2; + double z_max = Lz/2; // Initial conditions and gradients double kTi = 6.92; // R/LTi from Dimits et al. 2000. @@ -575,10 +566,10 @@ struct gk_app_ctx create_ctx(void) double inv_asp_ratio = a_mid/R0; // Grid parameters - int num_cell_x = 4; - int num_cell_z = 4; - int num_cell_vpar = 4; - int num_cell_mu = 2; + int Nx = 4; + int Nz = 4; + int Nvpar = 4; + int Nmu = 2; int poly_order = 1; // IC, Krook, buffer, and integration lookup tables (LUTs) parameters. @@ -592,7 +583,7 @@ struct gk_app_ctx create_ctx(void) double mu_max_elc = 7*Te0/B0; double vpar_max_ion = 4.*vti; double mu_max_ion = 7*Ti0/B0; - double final_time = 0.01*t_itg; + double t_end = 0.01*t_itg; int num_frames = 1; double write_phase_freq = 1.0; int int_diag_calc_num = num_frames*100; @@ -609,7 +600,7 @@ struct gk_app_ctx create_ctx(void) // printf("R0/c_s = %1.2e [s]\n", t_unit); // printf("t_itg = %1.2e [s], t_gam = %1.2e [s]\n", t_itg, t_gam); // printf("t_itg c_s/R0 = %1.2e, t_gam c_s/R0 = %1.2e\n", t_itg/t_unit, t_gam/t_unit); - // printf("Num cell for ky rhos = 0.5: %1.2g\n", (2.*M_PI/ky_itg)/(Ly/num_cell_y)); + // printf("Num cell for ky rhos = 0.5: %1.2g\n", (2.*M_PI/ky_itg)/(Ly/Ny)); struct gk_app_ctx ctx = { .cdim = cdim, @@ -640,20 +631,20 @@ struct gk_app_ctx create_ctx(void) .mi = mi, .qi = qi, .n0 = n0, .Te0 = Te0, .Ti0 = Ti0, .nuFrac = nuFrac, - .num_cell_x = num_cell_x, - .num_cell_z = num_cell_z, - .num_cell_vpar = num_cell_vpar, - .num_cell_mu = num_cell_mu, - .cells = {num_cell_x, num_cell_z, num_cell_vpar, num_cell_mu}, + .Nx = Nx, + .Nz = Nz, + .Nvpar = Nvpar, + .Nmu = Nmu, + .cells = {Nx, Nz, Nvpar, Nmu}, .poly_order = poly_order, .vpar_max_elc = vpar_max_elc, .mu_max_elc = mu_max_elc, .vpar_max_ion = vpar_max_ion, .mu_max_ion = mu_max_ion, .write_phase_freq = write_phase_freq, - .final_time = final_time, .num_frames = num_frames, + .t_end = t_end, .num_frames = num_frames, .int_diag_calc_num = int_diag_calc_num, .dt_failure_tol = dt_failure_tol, .num_failures_max = num_failures_max, - .psi_lut_size = psi_lut_nfact*num_cell_x, + .psi_lut_size = psi_lut_nfact*Nx, }; return ctx; } @@ -889,7 +880,7 @@ main(int argc, char **argv) struct gkyl_gyrokinetic_run_inp run_inp = { .app_inp = app_inp, .time_stepping = { - .t_end = ctx.final_time, + .t_end = ctx.t_end, .num_frames = ctx.num_frames, .write_phase_freq = ctx.write_phase_freq, .int_diag_calc_num = ctx.int_diag_calc_num, @@ -921,4 +912,4 @@ main(int argc, char **argv) free(ctx.dPsidr_int_lut); return 0; -} \ No newline at end of file +} diff --git a/gyrokinetic/creg/rt_gk_cbc_3x2v_p1.c b/gyrokinetic/creg/rt_gk_cbc_3x2v_p1.c index 2dcfcb6175..74c0854138 100644 --- a/gyrokinetic/creg/rt_gk_cbc_3x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_cbc_3x2v_p1.c @@ -9,16 +9,6 @@ #include #include #include -#include - -#ifdef GKYL_HAVE_MPI -#include -#include -#ifdef GKYL_HAVE_NCCL -#include -#endif -#endif - #include #include @@ -51,36 +41,36 @@ double interp_1x_lut(double x, double *lut_grid, double *lut_val, int N) // Define the context of the simulation. This stores global parameters. struct gk_app_ctx { - int cdim, vdim; - // Geometry and magnetic field parameters - double a_shift, Z_axis, R_axis, R0, a_mid, r0, B0, kappa, delta, q0, Cy, qaxis, qlcfs; - // Plasma parameters - double me, qe, mi, qi, n0, Te0, Ti0; - // Collision parameters - double nuFrac; - // Initial condition parameters - double Ln, LTe, LTi; - bool can_max; - // Krook and buffer parameters. - double nu_krook; - int num_cell_buff; - // Grid parameters - double Lx, Ly, Lz; - double x_min, y_min, z_min, x_max, y_max, z_max; - int num_cell_x, num_cell_y, num_cell_z, num_cell_vpar, num_cell_mu; - int cells[GKYL_MAX_DIM], poly_order; - double vpar_max_elc, mu_max_elc, vpar_max_ion, mu_max_ion; - // Simulation control parameters - double final_time, write_phase_freq; - int num_frames, int_diag_calc_num, num_failures_max; - double dt_failure_tol; - double max_run_time; // Maximum run time in seconds, 0 means no limit. - // Table for intPsi interpolation and lookup table (LUT). - int psi_lut_size; - double *r_lut; - double *psi_lut; - // Table for dPsidr. - double *dPsidr_int_lut; + int cdim, vdim; + // Geometry and magnetic field parameters + double a_shift, Z_axis, R_axis, R0, a_mid, r0, B0, kappa, delta, q0, Cy, qaxis, qlcfs; + // Plasma parameters + double me, qe, mi, qi, n0, Te0, Ti0; + // Collision parameters + double nuFrac; + // Initial condition parameters + double Ln, LTe, LTi; + bool can_max; + // Krook and buffer parameters. + double nu_krook; + int num_cell_buff; + // Grid parameters + double Lx, Ly, Lz; + double x_min, y_min, z_min, x_max, y_max, z_max; + int Nx, Ny, Nz, Nvpar, Nmu; + int cells[GKYL_MAX_DIM], poly_order; + double vpar_max_elc, mu_max_elc, vpar_max_ion, mu_max_ion; + // Simulation control parameters + double t_end, write_phase_freq; + int num_frames, int_diag_calc_num, num_failures_max; + double dt_failure_tol; + double max_run_time; // Maximum run time in seconds, 0 means no limit. + // Table for intPsi interpolation and lookup table (LUT). + int psi_lut_size; + double *r_lut; + double *psi_lut; + // Table for dPsidr. + double *dPsidr_int_lut; }; // Geometry related functions @@ -354,7 +344,7 @@ void double_buffer_profile(double t, const double *xn, double *fout, void *ctx) { double x = xn[0]; struct gk_app_ctx *app = ctx; - int nx = app->num_cell_x; + int nx = app->Nx; double x_max = app->x_max; double x_min = app->x_min; double Lx = app->Lx; @@ -370,7 +360,7 @@ double tanh_profile(double x, double v0, double Lgrad, void *ctx) { struct gk_app_ctx *app = ctx; // Profile use in Gysela (see V. Grandgirard et al. / Computer Physics Communications 207 (2016) 35–68). - double buff_frac = (double)app->num_cell_buff / app->num_cell_x; + double buff_frac = (double)app->num_cell_buff / app->Nx; double delta = 0.5*(1-buff_frac) * app->Lx; double arg = x / (app->a_mid * delta); double prof_factor = (app->a_mid * delta) / Lgrad; @@ -559,19 +549,20 @@ struct gk_app_ctx create_ctx(void) double Cy = r0/q0; // Cylindrical coordinate shift for field-alignment. // Configuration domain parameters - double Lx = 150*rho_s; // Domain size along x. - double x_min = -Lx/2; - double x_max = Lx/2; - double Ly = 150*rho_s; // Domain size along y. - double y_min = -Ly/2; - double y_max = Ly/2; - double Lz = 2.*M_PI-1e-10; // Domain size along magnetic field. - double z_min = -Lz/2.; - double z_max = Lz/2.; + double Lx = 150*rho_s; // Domain size along x. + double Ly = 150*rho_s; // Domain size along y. + double Lz = 2.*M_PI-1e-10; // Domain size along magnetic field. // Adjust the domain size along y to have integer toroidal mode number. // We need: 2*pi*Cy/Ly = integer. Ly = 2.*M_PI*Cy/round(2.*M_PI*Cy/Ly); + double x_min = -Lx/2; + double x_max = Lx/2; + double y_min = -Ly/2; + double y_max = Ly/2; + double z_min = -Lz/2; + double z_max = Lz/2; + // Initial conditions and gradients double kTi = 6.92; // R/LTi from Dimits et al. 2000. double etai = 3.114; // Lni/LTi from Dimits et al. 2000. @@ -604,11 +595,11 @@ struct gk_app_ctx create_ctx(void) double inv_asp_ratio = a_mid/R0; // Grid parameters - int num_cell_x = 4; - int num_cell_y = 4; - int num_cell_z = 4; - int num_cell_vpar = 4; - int num_cell_mu = 2; + int Nx = 4; + int Ny = 4; + int Nz = 4; + int Nvpar = 4; + int Nmu = 2; int poly_order = 1; // IC, Krook, buffer, and integration lookup tables (LUTs) parameters. @@ -622,7 +613,7 @@ struct gk_app_ctx create_ctx(void) double mu_max_elc = 7*Te0/B0; double vpar_max_ion = 4.*vti; double mu_max_ion = 7*Ti0/B0; - double final_time = 0.01*t_itg; + double t_end = 0.01*t_itg; int num_frames = 1; double write_phase_freq = 1.0; int int_diag_calc_num = num_frames*100; @@ -639,7 +630,7 @@ struct gk_app_ctx create_ctx(void) // printf("R0/c_s = %1.2e [s]\n", t_unit); // printf("t_itg = %1.2e [s], t_gam = %1.2e [s]\n", t_itg, t_gam); // printf("t_itg c_s/R0 = %1.2e, t_gam c_s/R0 = %1.2e\n", t_itg/t_unit, t_gam/t_unit); - // printf("Num cell for ky rhos = 0.5: %1.2g\n", (2.*M_PI/ky_itg)/(Ly/num_cell_y)); + // printf("Num cell for ky rhos = 0.5: %1.2g\n", (2.*M_PI/ky_itg)/(Ly/Ny)); struct gk_app_ctx ctx = { .cdim = cdim, @@ -672,21 +663,21 @@ struct gk_app_ctx create_ctx(void) .mi = mi, .qi = qi, .n0 = n0, .Te0 = Te0, .Ti0 = Ti0, .nuFrac = nuFrac, - .num_cell_x = num_cell_x, - .num_cell_y = num_cell_y, - .num_cell_z = num_cell_z, - .num_cell_vpar = num_cell_vpar, - .num_cell_mu = num_cell_mu, - .cells = {num_cell_x, num_cell_y, num_cell_z, num_cell_vpar, num_cell_mu}, + .Nx = Nx, + .Ny = Ny, + .Nz = Nz, + .Nvpar = Nvpar, + .Nmu = Nmu, + .cells = {Nx, Ny, Nz, Nvpar, Nmu}, .poly_order = poly_order, .vpar_max_elc = vpar_max_elc, .mu_max_elc = mu_max_elc, .vpar_max_ion = vpar_max_ion, .mu_max_ion = mu_max_ion, .write_phase_freq = write_phase_freq, - .final_time = final_time, .num_frames = num_frames, + .t_end = t_end, .num_frames = num_frames, .int_diag_calc_num = int_diag_calc_num, .dt_failure_tol = dt_failure_tol, .num_failures_max = num_failures_max, - .psi_lut_size = psi_lut_nfact*num_cell_x, + .psi_lut_size = psi_lut_nfact*Nx, }; return ctx; } @@ -915,7 +906,7 @@ main(int argc, char **argv) struct gkyl_gyrokinetic_run_inp run_inp = { .app_inp = app_inp, .time_stepping = { - .t_end = ctx.final_time, + .t_end = ctx.t_end, .num_frames = ctx.num_frames, .write_phase_freq = ctx.write_phase_freq, .int_diag_calc_num = ctx.int_diag_calc_num, @@ -942,4 +933,4 @@ main(int argc, char **argv) free(ctx.dPsidr_int_lut); return 0; -} \ No newline at end of file +} diff --git a/gyrokinetic/creg/rt_gk_cbc_passive_3x2v_p1.c b/gyrokinetic/creg/rt_gk_cbc_passive_3x2v_p1.c new file mode 100644 index 0000000000..c4a5f0e69d --- /dev/null +++ b/gyrokinetic/creg/rt_gk_cbc_passive_3x2v_p1.c @@ -0,0 +1,656 @@ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Function to perform 1D linear interpolation based on a lookup table (LUT). +double interp_1x_lut(double x, double *lut_grid, double *lut_val, int N) +{ + double x_min = lut_grid[0]; + double x_max = lut_grid[N-1]; + // Clamp values if x goes outside of the LUT range. + if (x <= x_min || x >= x_max) { + fprintf(stderr, "Warning: x = %g out of LUT range [%g, %g]. Clamping to boundaries.\n", x, x_min, x_max); + if (x <= x_min) return lut_val[0]; + if (x >= x_max) return lut_val[N-1]; + } + // Assume uniform spacing of the lookup table. + double dx = (x_max - x_min)/(N-1); + int idx = (int)((x - x_min)/dx); + // Safety check. + if (idx < 0 || idx >= N-1) { + fprintf(stderr, "Error: idx out of bounds in interp_Psi_lut: idx = %d, x = %g\n", idx, x); + return 0.0; + } + // Linear interpolation. + double x0 = lut_grid[idx]; + double x1 = lut_grid[idx+1]; + double f0 = lut_val[idx]; + double f1 = lut_val[idx+1]; + return f0 + (f1 - f0)*(x - x0)/(x1 - x0); +} + +// Define the context of the simulation. This stores global parameters. +struct gk_app_ctx { + int cdim, vdim; + // Geometry and magnetic field parameters + double a_shift, Z_axis, R_axis, R0, a_mid, r0, B0, kappa, delta, q0, Cy, qaxis, qlcfs; + // Plasma parameters + double me, qe, mi, qi, n0, Te0, Ti0; + double ux, uy, uz; // Passive advection velocity. + // Grid parameters + double Lx, Ly, Lz; + double x_min, y_min, z_min, x_max, y_max, z_max; + int Nx, Ny, Nz, Nvpar, Nmu; + int cells[GKYL_MAX_DIM], poly_order; + double vpar_max_elc, mu_max_elc; + // Simulation control parameters + double t_end, write_phase_freq; + int num_frames, int_diag_calc_num, num_failures_max; + double dt_failure_tol; + double max_run_time; // Maximum run time in seconds, 0 means no limit. + // Table for intPsi interpolation and lookup table (LUT). + int psi_lut_size; + double *r_lut; + double *psi_lut; + // Table for dPsidr. + double *dPsidr_int_lut; +}; + +// Geometry related functions +double r_x(double x, double r0) +{ + return x + r0; +} + +// quadratic q profile +double qprofile(double r, double a_mid, double qaxis, double qlcfs) +{ + // Profile from Grandgirard et al. 2008 + return 1.0 + 2.78 * pow(r/a_mid,2.8); + // Profile from Qu et al. 2026 https://hal.science/hal-05342386v2 + // return 0.86 - 0.16 * (r/a_mid) + 2.52 * pow(r/a_mid,2); + // return 1.4; +} + +double R_rtheta(double r, double theta, void *ctx) +{ + // Major radius as a function of minor radius r and poloidal angle theta. + struct gk_app_ctx *app = ctx; + double a_shift = app->a_shift; + double R_axis = app->R_axis; + double delta = app->delta; + return R_axis - a_shift*r*r/(2.*R_axis) + r*cos(theta + asin(delta)*sin(theta)); +} + +double Z_rtheta(double r, double theta, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double Z_axis = app->Z_axis; + double kappa = app->kappa; + return Z_axis + kappa*r*sin(theta); +} + +double dRdr(double r, double theta, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double a_shift = app->a_shift; + double R_axis = app->R_axis; + double delta = app->delta; + return -a_shift*r/(R_axis) + cos(theta + asin(delta)*sin(theta)); +} + +double dRdtheta(double r, double theta, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double delta = app->delta; + return -r*sin(theta + asin(delta)*sin(theta))*(1.+asin(delta)*cos(theta)); +} + +double dZdr(double r, double theta, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double kappa = app->kappa; + return kappa*sin(theta); +} + +double dZdtheta(double r, double theta, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double kappa = app->kappa; + return kappa*r*cos(theta); +} + +double Jr(double r, double theta, void *ctx) +{ + return R_rtheta(r,theta,ctx)*( dRdr(r,theta,ctx) * dZdtheta(r,theta,ctx) + -dRdtheta(r,theta,ctx) * dZdr(r,theta,ctx) ); +} + +struct integrand_ctx { + struct gk_app_ctx *app_ctx; + double r; + double theta; +}; + +double Bphi(double R, void *ctx) +{ + // Toroidal magnetic field. + struct gk_app_ctx *app = ctx; + double B0 = app->B0; + double R0 = app->R0; + return B0*R0/R; +} + +double integrand_JoRsq(double t, void *int_ctx) +{ + struct integrand_ctx *inctx = int_ctx; + double r = inctx->r; + struct gk_app_ctx *app = inctx->app_ctx; + return Jr(r,t,app) / pow(R_rtheta(r,t,app),2); +} + +double intdPsidr(double r, void *ctx) +{ + struct gk_app_ctx *app = ctx; + struct integrand_ctx tmp_ctx = {.app_ctx = app, .r = r}; + struct gkyl_qr_res integral; + integral = gkyl_dbl_exp(integrand_JoRsq, &tmp_ctx, 0., 2.*M_PI, 7, 1e-10); + return integral.res; +} + +double dPsidr(double r, double theta, void *ctx) +{ + struct gk_app_ctx *app = ctx; + struct integrand_ctx tmp_ctx = {.app_ctx = app, .r = r}; + struct gkyl_qr_res integral; + double integral_val = interp_1x_lut(r, app->r_lut, app->dPsidr_int_lut, app->psi_lut_size); + double R = R_rtheta(r,theta,ctx); + double Bt = Bphi(R,ctx); + return ( R*Bt/(2.*M_PI*qprofile(r, app->a_mid, app->qaxis, app->qlcfs)))*integral_val; +} + +double integrant_dpsi(double r, void *int_ctx) +{ + struct integrand_ctx *inctx = int_ctx; + struct gk_app_ctx *app = inctx->app_ctx; + double q = qprofile(r, app->a_mid, app->qaxis, app->qlcfs); + double dpsi = -r/q; // This is valid in the circular limit. The minus sign comes dBtheta/r < 0 + return dpsi; // I am not sure about this sign, I think it must be from dx/dr = -1. + // return -dPsidr(r, inctx->theta, app); // Seems to be the exact way but it makes the profile super flat (and -1 factor looks important here). +} + +double intPsi(double r0, double r, double theta, void *ctx) +{ + struct gk_app_ctx *app = ctx; + struct integrand_ctx tmp_ctx = {.app_ctx = app, .theta = theta}; + struct gkyl_qr_res integral; + integral = gkyl_dbl_exp(integrant_dpsi, &tmp_ctx, r0, r, 7, 1e-10); + return integral.res; +} + +double compute_alpha_integral(double r, double twrap, void *ctx) { + struct gk_app_ctx *app = ctx; + struct integrand_ctx tmp_ctx = {.app_ctx = app, .r = r}; + struct gkyl_qr_res integral; + + if (twrap == 0.0) return 0.0; + + if (0. < twrap) { + integral = gkyl_dbl_exp(integrand_JoRsq, &tmp_ctx, 0., twrap, 7, 1e-10); + return integral.res; + } else { + integral = gkyl_dbl_exp(integrand_JoRsq, &tmp_ctx, twrap, 0., 7, 1e-10); + return -integral.res; + } +} + +double alpha(double r, double theta, double phi, void *ctx) +{ + struct gk_app_ctx *app = ctx; + double twrap = theta; + while (twrap < -M_PI) twrap = twrap+2.*M_PI; + while (M_PI < twrap) twrap = twrap-2.*M_PI; + + double integral_val = compute_alpha_integral(r, twrap, ctx); + + double R = R_rtheta(r,theta,ctx); + double Bt = Bphi(R,ctx); + + return phi - R*Bt*integral_val/dPsidr(r,theta,ctx); +} + +double gradr(double r, double theta, void *ctx) +{ + return (R_rtheta(r,theta,ctx)/Jr(r,theta,ctx))*sqrt(pow(dRdtheta(r,theta,ctx),2) + pow(dZdtheta(r,theta,ctx),2)); +} + +void bfield_func(double t, const double *xc, double* GKYL_RESTRICT fout, void *ctx) +{ + double x = xc[0], y = xc[1], z = xc[2]; + struct gk_app_ctx *app = ctx; + double a_mid = app->a_mid; + double Cy = app->Cy; + double r0 = app->r0; + double r = r_x(x,r0); + double Bt = Bphi(R_rtheta(r,z,ctx),ctx); + double Bp = dPsidr(r,z,ctx)/R_rtheta(r,z,ctx)*gradr(r,z,ctx); + + double drdtheta = dRdtheta(r,z,ctx); + double dzdtheta = dZdtheta(r,z,ctx); + double den = sqrt(pow(drdtheta,2) + pow(dzdtheta,2)); + double B_r = Bp*drdtheta/den; + double B_z = Bp*dzdtheta/den; + double phi = y/Cy + alpha(r, z, 0, ctx); + double R = R_rtheta(r, z, ctx); + + // xc are computational coords. + // Set Cartesian components of magnetic field. + fout[0] = B_r * cos(phi) + Bt * sin(phi); + fout[1] = B_r * sin(phi) - Bt * cos(phi); + fout[2] = B_z; +} + +void bc_shift_func_lo(double t, const double *xc, double* GKYL_RESTRICT fout, void *ctx) +{ + double x = xc[0]; + struct gk_app_ctx *app = ctx; + + double Cy = app->Cy; + double z_min = app->z_min; + double z_max = app->z_max; + + double r = r_x(x, app->r0); + + fout[0] = Cy*( alpha(r, z_min, 0.0, ctx) - alpha(r, z_max, 0.0, ctx) ); +} + +void bc_shift_func_up(double t, const double *xc, double* GKYL_RESTRICT fout, void *ctx) +{ + double x = xc[0]; + struct gk_app_ctx *app = ctx; + + double Cy = app->Cy; + double z_min = app->z_min; + double z_max = app->z_max; + + double r = r_x(x, app->r0); + + fout[0] = -Cy*( alpha(r, z_min, 0.0, ctx) - alpha(r, z_max, 0.0, ctx) ); +} + +void eval_distf_elc(double t, const double* GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void* ctx) +{ + double x = xn[0], y = xn[1], z = xn[2], vpar = xn[3], mu = xn[4]; + + struct gk_app_ctx *app = ctx; + double Lx = app->Lx; + double Ly = app->Ly; + double Lz = app->Lz; + + // Gaussian in conf-space, constant in v-space. + + double loc[] = {0.0, 0.0, 0.0}; + double sig[] = {Lx/7.0, Ly/7.0, Lz/10.0}; + + fout[0] = exp(- pow(x-loc[0],2)/(2.0*pow(sig[0],2)) + - pow(y-loc[1],2)/(2.0*pow(sig[1],2)) + - pow(z-loc[2],2)/(2.0*pow(sig[2],2))); +} + +void +passive_velocity_elc(double t, const double* GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void* ctx) +{ + double x = xn[0], y = xn[1], z = xn[2]; + + struct gk_app_ctx *app = ctx; + double ux = app->ux; + double uy = app->uy; + double uz = app->uz; + + fout[0] = ux; + fout[1] = uy; + fout[2] = uz; +} + +// Geometry evaluation functions for the gk app +void mapc2p(double t, const double *xc, double* GKYL_RESTRICT xp, void *ctx) +{ + double x = xc[0], y = xc[1], z = xc[2]; + + struct gk_app_ctx *app = ctx; + double a_mid = app->a_mid; + double Cy = app->Cy; + + double r = r_x(x,app->r0); + + // Map to cylindrical (R, Z, phi) coordinates. + double R = R_rtheta(r, z, ctx); + double Z = Z_rtheta(r, z, ctx); + double phi = y/Cy + alpha(r, z, 0, ctx); + + // Map to Cartesian (X, Y, Z) coordinates. + double X = R*cos(phi); + double Y = R*sin(phi); + xp[0] = X; xp[1] = Y; xp[2] = Z; +} + +struct gk_app_ctx create_ctx(void) +{ + int cdim = 3, vdim = 2; // Dimensionality. + // Universal constant parameters. + double eps0 = GKYL_EPSILON0, eV = GKYL_ELEMENTARY_CHARGE; + double mp = GKYL_PROTON_MASS, me = GKYL_ELECTRON_MASS; + double qi = eV; // ion charge + double qe = -eV; // electron charge + + // Geometry and magnetic field. (Taken from Greenfield et al. 1997 table II) + double a_shift = 0.0; // Parameter in Shafranov shift. + double Z_axis = 0.0; // Magnetic axis height [m]. + double R_axis = 1.6714; // Magnetic axis major radius [m]. + double B_axis = 1.54; // Magnetic field at the magnetic axis [T]. + double a_mid = 0.604; // Minor radius at OBMP [m]. + double R0 = R_axis + 0.5 * a_mid; // Major radius of the simulation box [m]. + double r0 = 0.5*a_mid; // Minor radius of the simulation box [m]. + double B0 = B_axis*(R_axis/R0); // Magnetic field magnitude in the simulation box [T]. + double kappa = 1.0; // cirular geometry for comparison with Dimits et al. 2000. + double delta = 0.0; // + double qaxis = 1.2; // Safety factor at r=0. + double qlcfs = 2.0; // Safety factor at the LCFS. + + // Plasma parameters. + double AMU = 1.0; // Hydrogen. + double mi = mp*AMU; + double Te0 = 2000*eV; + double Ti0 = 2000*eV; + double n0 = 4.5e19; // [1/m^3] according to Fig 5 of Greenfield et al. 1997. + double nuFrac = 1.0; // Collision factor. + + double vte = sqrt(Te0/me), vti = sqrt(Ti0/mi); // Thermal speeds. + double c_s = sqrt(Te0/mi); + double omega_ci = fabs(qi*B0/mi); + double rho_s = c_s/omega_ci; + double rho_i = vti/omega_ci; + double q0 = qprofile(r0, a_mid, qaxis, qlcfs); + double Cy = r0/q0; // Cylindrical coordinate shift for field-alignment. + + // Configuration domain parameters + double Lx = 150*rho_s; // Domain size along x. + double Ly = 150*rho_s; // Domain size along y. + double Lz = 2.*M_PI-1e-10; // Domain size along magnetic field. + // Adjust the domain size along y to have integer toroidal mode number. + // We need: 2*pi*Cy/Ly = integer. + Ly = 2.*M_PI*Cy/round(2.*M_PI*Cy/Ly); + + double x_min = -Lx/2; + double x_max = Lx/2; + double y_min = -Ly/2; + double y_max = Ly/2; + double z_min = -Lz/2; + double z_max = Lz/2; + + double ux = 0.0, uy = 0.0, uz = Lz; // Passive advection velocity. + + // Check the global shear r/q*dq/dr in the middle of the domain + double rL = r0 - Lx/2; + double rR = r0 + Lx/2; + double qL = qprofile(rL, a_mid, qaxis, qlcfs); + double qR = qprofile(rR, a_mid, qaxis, qlcfs); + double dq_dr = (qR-qL)/(rR-rL); + double s0 = r0/q0*dq_dr; + double rhostar = rho_s/a_mid; + double inv_asp_ratio = a_mid/R0; + + // Grid parameters + int Nx = 32; + int Ny = 16; + int Nz = 16; + int Nvpar = 2; + int Nmu = 2; + int poly_order = 1; + + int psi_lut_nfact = 100*(poly_order+1); // Resolution factor for the psi lookup table. + + // Velocity box dimensions + double vpar_max_elc = 4.*vte; + double mu_max_elc = 7*Te0/B0; + + double t_end = 4.0; + int num_frames = 40; + double write_phase_freq = 1.0; + int int_diag_calc_num = num_frames*100; + double dt_failure_tol = 1.0e-3; // Minimum allowable fraction of initial time-step. + int num_failures_max = 20; // Maximum allowable number of consecutive small time-steps. + + // printf("-- Simulation parameters and info ---\n"); + // printf("vte = %1.2e, vti = %1.2e, c_s = %1.1e [m/s]\n", vte, vti, c_s); + // printf("Lx = %1.2g, rho_s = %1.2g [m]\n", Lx, rho_s); + // printf("x_min = %1.2g, x_max = %1.2g [m]\n", x_min, x_max); + // printf("Cy = %1.2g, q0 = %1.2g, qL = %1.2g, qR = %1.2g, s0 = %1.2g\n", Cy, q0, qL, qR, s0); + // printf("epsilon = %1.2g, rho_star = 1/%2.2g\n", inv_asp_ratio, 1/rhostar); + + struct gk_app_ctx ctx = { + .cdim = cdim, + .vdim = vdim, + .a_shift = a_shift, + .R_axis = R_axis, + .R0 = R0 , + .a_mid = a_mid , + .r0 = r0 , + .B0 = B0 , + .kappa = kappa , + .delta = delta , + .q0 = q0 , + .Cy = Cy , + .qaxis = qaxis , + .qlcfs = qlcfs , + .Lx = Lx , + .Ly = Ly , + .Lz = Lz , + .x_min = x_min, .x_max = x_max, + .y_min = y_min, .y_max = y_max, + .z_min = z_min, .z_max = z_max, + .me = me, .qe = qe, + .mi = mi, .qi = qi, + .n0 = n0, .Te0 = Te0, .Ti0 = Ti0, + .ux = ux, .uy = uy, uz = uz, + .Nx = Nx, + .Ny = Ny, + .Nz = Nz, + .Nvpar = Nvpar, + .Nmu = Nmu, + .cells = {Nx, Ny, Nz, Nvpar, Nmu}, + .poly_order = poly_order, + .vpar_max_elc = vpar_max_elc, .mu_max_elc = mu_max_elc, + .write_phase_freq = write_phase_freq, + .t_end = t_end, .num_frames = num_frames, + .int_diag_calc_num = int_diag_calc_num, + .dt_failure_tol = dt_failure_tol, + .num_failures_max = num_failures_max, + .psi_lut_size = psi_lut_nfact*Nx, + }; + return ctx; +} + +int +main(int argc, char **argv) +{ + struct timespec timer_global = gkyl_wall_clock(); + struct gkyl_app_args app_args = parse_app_args(argc, argv); + +#ifdef GKYL_HAVE_MPI + if (app_args.use_mpi) + MPI_Init(&argc, &argv); +#endif + + if (app_args.trace_mem) { + gkyl_cu_dev_mem_debug_set(true); + gkyl_mem_debug_set(true); + } + + struct gk_app_ctx ctx = create_ctx(); // context for init functions + + int cells_x[ctx.cdim], cells_v[ctx.vdim]; + for (int d=0; d +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +struct passive_ctx +{ + int cdim, vdim; // Dimensionality. + + // Physical constants (using non-normalized physical units). + double mass_elc; // Electron mass. + double charge_elc; // Electron charge. + + double Te; // Electron temperature. + double n0; // Reference number density (1 / m^3). + double B0; // Reference magnetic field strength (Tesla). + + double ux, uz; // Passive advection velocity. + double f_amplitude; // Amplitude of the distribution. + double f_floor; // Floor of the distribution. + + // Simulation parameters. + int Nx; // Cell count (configuration space: x-direction). + int Nz; // Cell count (configuration space: z-direction). + int Nvpar; // Cell count (velocity space: parallel velocity direction). + int Nmu; // Cell count (velocity space: magnetic moment direction). + int cells[GKYL_MAX_DIM]; // Number of cells in all directions. + double Lx; // Domain size (configuration space: x-direction). + double Lz; // Domain size (configuration space: z-direction). + double vpar_max_elc; // Domain boundary (electron velocity space: parallel velocity direction). + double mu_max_elc; // Domain boundary (electron velocity space: magnetic moment direction). + int poly_order; // Polynomial order. + double cfl_frac; // CFL coefficient. + + double t_end; // Final simulation time. + int num_frames; // Number of output frames. + double write_phase_freq; // Frequency of writing phase-space diagnostics (as a fraction of num_frames). + int int_diag_calc_num; // Number of integrated diagnostics computations (=INT_MAX for every step). + double dt_failure_tol; // Minimum allowable fraction of initial time-step. + int num_failures_max; // Maximum allowable number of consecutive small time-steps. +}; + +struct passive_ctx +create_ctx(void) +{ + int cdim = 2, vdim = 2; // Dimensionality. + + // Physical constants (using non-normalized physical units). + double mass_elc = GKYL_ELECTRON_MASS; // Electron mass. + double charge_elc = -GKYL_ELEMENTARY_CHARGE; // Electron charge. + + double Te = 1.0 * GKYL_ELEMENTARY_CHARGE; // Electron temperature. + double n0 = 1.0e18; // Reference number density (1 / m^3). + double B0 = 1.0; // Reference magnetic field. + + double ux = 0.0, uz = 1.0; // Passive advection velocity. + double f_amplitude = 1.0; // Amplitude of the distribution. + double f_floor = 1.0e-10; // Floor of the distribution. + + double vte = sqrt(Te/mass_elc); // Electron thermal velocity. + + // Simulation parameters. + int Nx = 16; // Cell count (configuration space: x-direction). + int Nz = 16; // Cell count (configuration space: z-direction). + int Nvpar = 2; // Cell count (velocity space: parallel velocity direction). + int Nmu = 2; // Cell count (velocity space: magnetic moment direction). + double Lx = 1.0; // Domain size (configuration space: x-direction). + double Lz = 1.0; // Domain size (configuration space: z-direction). + double vpar_max_elc = 4.0*vte; // Domain boundary (electron velocity space: parallel velocity direction). + double mu_max_elc = mass_elc*pow(vpar_max_elc,2.0)/(2.0*B0); // Domain boundary (electron velocity space: magnetic moment direction). + int poly_order = 1; // Polynomial order. + double cfl_frac = 1.0; // CFL coefficient. + + double t_end = 1.0; // Final simulation time. + int num_frames = 10; // Number of output frames. + double write_phase_freq = 1.0; // Frequency of writing phase-space diagnostics (as a fraction of num_frames). + int int_diag_calc_num = num_frames*100; + double dt_failure_tol = 1.0e-4; // Minimum allowable fraction of initial time-step. + int num_failures_max = 20; // Maximum allowable number of consecutive small time-steps. + + struct passive_ctx ctx = { + .cdim = cdim, + .vdim = vdim, + .mass_elc = mass_elc, + .charge_elc = charge_elc, + .Te = Te, + .n0 = n0, + .B0 = B0, + .ux = ux, uz = uz, + .f_amplitude = f_amplitude, + .f_floor = f_floor, + .Nx = Nx, + .Nz = Nz, + .Nvpar = Nvpar, + .Nmu = Nmu, + .cells = {Nx, Nz, Nvpar, Nmu}, + .Lx = Lx, + .Lz = Lz, + .vpar_max_elc = vpar_max_elc, + .mu_max_elc = mu_max_elc, + .poly_order = poly_order, + .cfl_frac = cfl_frac, + .t_end = t_end, + .num_frames = num_frames, + .write_phase_freq = write_phase_freq, + .int_diag_calc_num = int_diag_calc_num, + .dt_failure_tol = dt_failure_tol, + .num_failures_max = num_failures_max, + }; + + return ctx; +} + +void +distf_elc(double t, const double* GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void* ctx) +{ + double x = xn[0], z = xn[1], vpar = xn[2], mu = xn[3]; + + struct passive_ctx *app = ctx; + double Lx = app->Lx; + double Lz = app->Lz; + double f_amplitude = app->f_amplitude; + double f_floor = app->f_floor; + + // Cube + double rx2 = pow(x-Lx/2,2); + double rz2 = pow(z-Lz/2,2); + + if (rx2 < pow(Lx/4,2) && rz2 < pow(Lz/4,2)) + fout[0] = f_amplitude; + else + fout[0] = f_floor; +} + +void +passive_velocity_elc(double t, const double* GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void* ctx) +{ + double x = xn[0], z = xn[1]; + + struct passive_ctx *app = ctx; + double ux = app->ux; + double uz = app->uz; + + fout[0] = ux; + fout[1] = uz; +} + +static inline void +mapc2p(double t, const double* GKYL_RESTRICT zc, double* GKYL_RESTRICT xp, void* ctx) +{ + struct passive_ctx *app = ctx; + double x = zc[0], y = zc[1], z = zc[2]; + + xp[0] = x; xp[1] = y; xp[2] = z; +} + +void +bfield_func(double t, const double* GKYL_RESTRICT zc, double* GKYL_RESTRICT fout, void* ctx) +{ + struct passive_ctx *app = ctx; + double x = zc[0], y = zc[1], z = zc[2]; + + double B0 = app->B0; + + // zc are computational coords. + // Set Cartesian components of magnetic field. + fout[0] = 0.0; + fout[1] = 0.0; + fout[2] = B0; +} + +int +main(int argc, char **argv) +{ + struct gkyl_app_args app_args = parse_app_args(argc, argv); + +#ifdef GKYL_HAVE_MPI + if (app_args.use_mpi) MPI_Init(&argc, &argv); +#endif + + if (app_args.trace_mem) { + gkyl_cu_dev_mem_debug_set(true); + gkyl_mem_debug_set(true); + } + + struct passive_ctx ctx = create_ctx(); // Context for init functions. + + int cells_x[ctx.cdim], cells_v[ctx.vdim]; + for (int d=0; d +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +struct passive_ctx +{ + int cdim, vdim; // Dimensionality. + + // Physical constants (using non-normalized physical units). + double mass_elc; // Electron mass. + double charge_elc; // Electron charge. + + double Te; // Electron temperature. + double n0; // Reference number density (1 / m^3). + double B0; // Reference magnetic field strength (Tesla). + + double ux, uy, uz; // Passive advection velocity. + double f_amplitude; // Amplitude of the distribution. + double f_floor; // Floor of the distribution. + + // Simulation parameters. + int Nx; // Cell count (configuration space: x-direction). + int Ny; // Cell count (configuration space: y-direction). + int Nz; // Cell count (configuration space: z-direction). + int Nvpar; // Cell count (velocity space: parallel velocity direction). + int Nmu; // Cell count (velocity space: magnetic moment direction). + int cells[GKYL_MAX_DIM]; // Number of cells in all directions. + double Lx; // Domain size (configuration space: x-direction). + double Ly; // Domain size (configuration space: y-direction). + double Lz; // Domain size (configuration space: z-direction). + double vpar_max_elc; // Domain boundary (electron velocity space: parallel velocity direction). + double mu_max_elc; // Domain boundary (electron velocity space: magnetic moment direction). + int poly_order; // Polynomial order. + double cfl_frac; // CFL coefficient. + + double t_end; // Final simulation time. + int num_frames; // Number of output frames. + double write_phase_freq; // Frequency of writing phase-space diagnostics (as a fraction of num_frames). + int int_diag_calc_num; // Number of integrated diagnostics computations (=INT_MAX for every step). + double dt_failure_tol; // Minimum allowable fraction of initial time-step. + int num_failures_max; // Maximum allowable number of consecutive small time-steps. +}; + +struct passive_ctx +create_ctx(void) +{ + int cdim = 3, vdim = 2; // Dimensionality. + + // Physical constants (using non-normalized physical units). + double mass_elc = GKYL_ELECTRON_MASS; // Electron mass. + double charge_elc = -GKYL_ELEMENTARY_CHARGE; // Electron charge. + + double Te = 1.0 * GKYL_ELEMENTARY_CHARGE; // Electron temperature. + double n0 = 1.0e18; // Reference number density (1 / m^3). + double B0 = 1.0; // Reference magnetic field. + + double ux = 0.0, uy = 0.0, uz = 1.0; // Passive advection velocity. + double f_amplitude = 1.0; // Amplitude of the distribution. + double f_floor = 1.0e-10; // Floor of the distribution. + + double vte = sqrt(Te/mass_elc); // Electron thermal velocity. + + // Simulation parameters. + int Nx = 16; // Cell count (configuration space: x-direction). + int Ny = 16; // Cell count (configuration space: y-direction). + int Nz = 16; // Cell count (configuration space: z-direction). + int Nvpar = 2; // Cell count (velocity space: parallel velocity direction). + int Nmu = 2; // Cell count (velocity space: magnetic moment direction). + double Lx = 1.0; // Domain size (configuration space: x-direction). + double Ly = 1.0; // Domain size (configuration space: y-direction). + double Lz = 1.0; // Domain size (configuration space: z-direction). + double vpar_max_elc = 4.0*vte; // Domain boundary (electron velocity space: parallel velocity direction). + double mu_max_elc = mass_elc*pow(vpar_max_elc,2.0)/(2.0*B0); // Domain boundary (electron velocity space: magnetic moment direction). + int poly_order = 1; // Polynomial order. + double cfl_frac = 1.0; // CFL coefficient. + + double t_end = 1.; // Final simulation time. + int num_frames = 1; // Number of output frames. + double write_phase_freq = 1.0; // Frequency of writing phase-space diagnostics (as a fraction of num_frames). + int int_diag_calc_num = num_frames*100; + double dt_failure_tol = 1.0e-4; // Minimum allowable fraction of initial time-step. + int num_failures_max = 20; // Maximum allowable number of consecutive small time-steps. + + struct passive_ctx ctx = { + .cdim = cdim, + .vdim = vdim, + .mass_elc = mass_elc, + .charge_elc = charge_elc, + .Te = Te, + .n0 = n0, + .B0 = B0, + .ux = ux, .uy = uy, uz = uz, + .f_amplitude = f_amplitude, + .f_floor = f_floor, + .Nx = Nx, + .Ny = Ny, + .Nz = Nz, + .Nvpar = Nvpar, + .Nmu = Nmu, + .cells = {Nx, Ny, Nz, Nvpar, Nmu}, + .Lx = Lx, + .Ly = Ly, + .Lz = Lz, + .vpar_max_elc = vpar_max_elc, + .mu_max_elc = mu_max_elc, + .poly_order = poly_order, + .cfl_frac = cfl_frac, + .t_end = t_end, + .num_frames = num_frames, + .write_phase_freq = write_phase_freq, + .int_diag_calc_num = int_diag_calc_num, + .dt_failure_tol = dt_failure_tol, + .num_failures_max = num_failures_max, + }; + + return ctx; +} + +void +distf_elc(double t, const double* GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void* ctx) +{ + double x = xn[0], y = xn[1], z = xn[2], vpar = xn[3], mu = xn[4]; + + struct passive_ctx *app = ctx; + double Lx = app->Lx; + double Ly = app->Ly; + double Lz = app->Lz; + double f_amplitude = app->f_amplitude; + double f_floor = app->f_floor; + + // Cube + double rx2 = pow(x-Lx/2,2); + double ry2 = pow(y-Ly/2,2); + double rz2 = pow(z-Lz/2,2); + + if (rx2 < pow(Lx/4,2) && ry2 < pow(Ly/4,2) && rz2 < pow(Lz/4,2)) + fout[0] = f_amplitude; + else + fout[0] = f_floor; +} + +void +passive_velocity_elc(double t, const double* GKYL_RESTRICT xn, double* GKYL_RESTRICT fout, void* ctx) +{ + double x = xn[0], y = xn[1], z = xn[2]; + + struct passive_ctx *app = ctx; + double ux = app->ux; + double uy = app->uy; + double uz = app->uz; + + fout[0] = ux; + fout[1] = uy; + fout[2] = uz; +} + +static inline void +mapc2p(double t, const double* GKYL_RESTRICT zc, double* GKYL_RESTRICT xp, void* ctx) +{ + double x = zc[0], y = zc[1], z = zc[2]; + + struct passive_ctx *app = ctx; + + xp[0] = x; xp[1] = y; xp[2] = z; +} + +void +bfield_func(double t, const double* GKYL_RESTRICT zc, double* GKYL_RESTRICT fout, void* ctx) +{ + double x = zc[0], y = zc[1], z = zc[2]; + + struct passive_ctx *app = ctx; + double B0 = app->B0; + + // zc are computational coords. + // Set Cartesian components of magnetic field. + fout[0] = 0.0; + fout[1] = 0.0; + fout[2] = B0; +} + +void bc_shift_func_lo(double t, const double *xc, double* GKYL_RESTRICT fout, void *ctx) +{ + double x = xc[0], y = xc[1], z = xc[2]; + + struct gk_app_ctx *app = ctx; + + fout[0] = -(x-0.5); +} + +void bc_shift_func_up(double t, const double *xc, double* GKYL_RESTRICT fout, void *ctx) +{ + bc_shift_func_lo(t,xc,fout,ctx); + fout[0] *= -1.0; +} + +int +main(int argc, char **argv) +{ + struct gkyl_app_args app_args = parse_app_args(argc, argv); + +#ifdef GKYL_HAVE_MPI + if (app_args.use_mpi) MPI_Init(&argc, &argv); +#endif + + if (app_args.trace_mem) { + gkyl_cu_dev_mem_debug_set(true); + gkyl_mem_debug_set(true); + } + + struct passive_ctx ctx = create_ctx(); // Context for init functions. + + int cells_x[ctx.cdim], cells_v[ctx.vdim]; + for (int d=0; d the resolution must be divisible by 3. - int num_cell_z = 8; - int num_cell_vpar = 8; - int num_cell_mu = 8; + int Nx = 9; // The LCFS is positionned at 1/3 of the domain -> the resolution must be divisible by 3. + int Nz = 8; + int Nvpar = 8; + int Nmu = 8; int poly_order = 1; // Velocity box dimensions double vpar_max_elc = 5.*vte; double mu_max_elc = me*pow(4*vte,2)/(2*B0); double vpar_max_ion = 5.*vti; double mu_max_ion = mi*pow(4*vti,2)/(2*B0); - double final_time = 1.e-7; // Should take 8 time steps + double t_end = 1.e-7; // Should take 8 time steps int num_frames = 1; double write_phase_freq = 1.0; int int_diag_calc_num = num_frames*100; @@ -464,16 +464,16 @@ struct gk_app_ctx create_ctx(void) .energy_srcRECY = energy_srcRECY, .particle_srcRECY = particle_srcRECY, .floor_srcRECY = floor_srcRECY, - .num_cell_x = num_cell_x, - .num_cell_z = num_cell_z, - .num_cell_vpar = num_cell_vpar, - .num_cell_mu = num_cell_mu, - .cells = {num_cell_x, num_cell_z, num_cell_vpar, num_cell_mu}, + .Nx = Nx, + .Nz = Nz, + .Nvpar = Nvpar, + .Nmu = Nmu, + .cells = {Nx, Nz, Nvpar, Nmu}, .poly_order = poly_order, .vpar_max_elc = vpar_max_elc, .mu_max_elc = mu_max_elc, .vpar_max_ion = vpar_max_ion, .mu_max_ion = mu_max_ion, .write_phase_freq = write_phase_freq, - .final_time = final_time, .num_frames = num_frames, + .t_end = t_end, .num_frames = num_frames, .int_diag_calc_num = int_diag_calc_num, .dt_failure_tol = dt_failure_tol, .num_failures_max = num_failures_max, @@ -827,7 +827,7 @@ main(int argc, char **argv) struct gkyl_gyrokinetic_run_inp run_inp = { .app_inp = app_inp, .time_stepping = { - .t_end = ctx.final_time, + .t_end = ctx.t_end, .num_frames = ctx.num_frames, .write_phase_freq = ctx.write_phase_freq, .int_diag_calc_num = ctx.int_diag_calc_num, diff --git a/gyrokinetic/creg/rt_gk_tcv_iwl_adapt_source_3x2v_p1.c b/gyrokinetic/creg/rt_gk_tcv_iwl_adapt_source_3x2v_p1.c index 1520d5cdde..9798bee053 100644 --- a/gyrokinetic/creg/rt_gk_tcv_iwl_adapt_source_3x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_tcv_iwl_adapt_source_3x2v_p1.c @@ -35,11 +35,11 @@ struct gk_app_ctx { // Grid parameters double Lx, Ly, Lz; double x_min, x_max, y_min, y_max, z_min, z_max; - int num_cell_x, num_cell_y, num_cell_z, num_cell_vpar, num_cell_mu; + int Nx, Ny, Nz, Nvpar, Nmu; int cells[GKYL_MAX_DIM], poly_order; double vpar_max_elc, mu_max_elc, vpar_max_ion, mu_max_ion; // Simulation control parameters - double final_time, write_phase_freq; + double t_end, write_phase_freq; int num_frames, int_diag_calc_num, num_failures_max; double dt_failure_tol; }; @@ -439,18 +439,18 @@ struct gk_app_ctx create_ctx(void) double floor_srcRECY = 1e-10; // Grid parameters (reduced resolution for the regression test, minimal recommended values in comments) - int num_cell_x = 9; // (24) The LCFS is positionned at 1/3 of the domain -> the resolution must be divisible by 3. - int num_cell_y = 4; // (16) - int num_cell_z = 8; // (12) - int num_cell_vpar = 8; // (12) - int num_cell_mu = 8; // (8) + int Nx = 24; // (24) The LCFS is positionned at 1/3 of the domain -> the resolution must be divisible by 3. + int Ny = 4; // (16) + int Nz = 8; // (12) + int Nvpar = 8; // (12) + int Nmu = 4; // (8) int poly_order = 1; // Velocity box dimensions double vpar_max_elc = 5.*vte; double mu_max_elc = 1.*me*pow(4*vte,2)/(2*B0); double vpar_max_ion = 5.*vti; double mu_max_ion = 1.*mi*pow(4*vti,2)/(2*B0); - double final_time = 1.e-7; + double t_end = 1.e-7; int num_frames = 1; double write_phase_freq = 1.0; int int_diag_calc_num = num_frames*100; @@ -497,17 +497,17 @@ struct gk_app_ctx create_ctx(void) .sigma_srcRECY = {sigma_srcRECY[0], sigma_srcRECY[1], sigma_srcRECY[2]}, .energy_srcRECY = energy_srcRECY, .particle_srcRECY = particle_srcRECY, .floor_srcRECY = floor_srcRECY, - .num_cell_x = num_cell_x, - .num_cell_y = num_cell_y, - .num_cell_z = num_cell_z, - .num_cell_vpar = num_cell_vpar, - .num_cell_mu = num_cell_mu, - .cells = {num_cell_x, num_cell_y, num_cell_z, num_cell_vpar, num_cell_mu}, + .Nx = Nx, + .Ny = Ny, + .Nz = Nz, + .Nvpar = Nvpar, + .Nmu = Nmu, + .cells = {Nx, Ny, Nz, Nvpar, Nmu}, .poly_order = poly_order, .vpar_max_elc = vpar_max_elc, .mu_max_elc = mu_max_elc, .vpar_max_ion = vpar_max_ion, .mu_max_ion = mu_max_ion, .write_phase_freq = write_phase_freq, - .final_time = final_time, .num_frames = num_frames, + .t_end = t_end, .num_frames = num_frames, .int_diag_calc_num = int_diag_calc_num, .dt_failure_tol = dt_failure_tol, .num_failures_max = num_failures_max, @@ -872,7 +872,7 @@ main(int argc, char **argv) struct gkyl_gyrokinetic_run_inp run_inp = { .app_inp = app_inp, .time_stepping = { - .t_end = ctx.final_time, + .t_end = ctx.t_end, .num_frames = ctx.num_frames, .write_phase_freq = ctx.write_phase_freq, .int_diag_calc_num = ctx.int_diag_calc_num, diff --git a/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfx_1x1v_ser_p1.c b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfx_1x1v_ser_p1.c new file mode 100644 index 0000000000..5ff47f2290 --- /dev/null +++ b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfx_1x1v_ser_p1.c @@ -0,0 +1,52 @@ +#include +#include +GKYL_CU_DH double dg_gyrokinetic_passive_boundary_surfx_1x1v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_edge, const double *vmap_prime_skin, + const double *flux_surf_edge, const double *flux_surf_skin, + const int edge, double* GKYL_RESTRICT out) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap_prime_edge,vmap_prime_skin: velocity space mapping derivative in edge and skin cells. + // flux_surf_edge: Surface expansion of phase space flux on the lower edges of the edge cell. + // flux_surf_skin: Surface expansion of phase space flux on the lower edges of the skin cell. + // edge: determines if the update is for the left edge (-1) or right edge (+1). + // out: output increment in center cell. + + double rdx2 = 2.0/dxv[0]; + + double GhatL[3]= {0.0}; + double GhatR[3]= {0.0}; + + const double *fnodal_l = &flux_surf_skin[0]; + const double *fnodal_r = &flux_surf_edge[0]; + GhatL[0] = 0.39283710065919303*fnodal_l[2]+0.6285393610547091*fnodal_l[1]+0.39283710065919303*fnodal_l[0]; + GhatL[1] = 0.5270462766947298*fnodal_l[2]-0.5270462766947298*fnodal_l[0]; + GhatL[2] = 0.35136418446315326*fnodal_l[2]-0.7027283689263066*fnodal_l[1]+0.35136418446315326*fnodal_l[0]; + GhatR[0] = 0.39283710065919303*fnodal_r[2]+0.6285393610547091*fnodal_r[1]+0.39283710065919303*fnodal_r[0]; + GhatR[1] = 0.5270462766947298*fnodal_r[2]-0.5270462766947298*fnodal_r[0]; + GhatR[2] = 0.35136418446315326*fnodal_r[2]-0.7027283689263066*fnodal_r[1]+0.35136418446315326*fnodal_r[0]; + + if (edge == -1) { + + out[0] += -(0.7071067811865475*GhatR[0]*rdx2); + out[1] += -(1.224744871391589*GhatR[0]*rdx2); + out[2] += -(0.7071067811865475*GhatR[1]*rdx2); + out[3] += -(1.224744871391589*GhatR[1]*rdx2); + out[4] += -(0.7071067811865475*GhatR[2]*rdx2); + out[5] += -(1.224744871391589*GhatR[2]*rdx2); + + } else { + + out[0] += 0.7071067811865475*GhatL[0]*rdx2; + out[1] += -(1.224744871391589*GhatL[0]*rdx2); + out[2] += 0.7071067811865475*GhatL[1]*rdx2; + out[3] += -(1.224744871391589*GhatL[1]*rdx2); + out[4] += 0.7071067811865475*GhatL[2]*rdx2; + out[5] += -(1.224744871391589*GhatL[2]*rdx2); + + } + + return 0.0; + +} diff --git a/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfx_1x2v_ser_p1.c b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfx_1x2v_ser_p1.c new file mode 100644 index 0000000000..706db19b73 --- /dev/null +++ b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfx_1x2v_ser_p1.c @@ -0,0 +1,70 @@ +#include +#include +GKYL_CU_DH double dg_gyrokinetic_passive_boundary_surfx_1x2v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_edge, const double *vmap_prime_skin, + const double *flux_surf_edge, const double *flux_surf_skin, + const int edge, double* GKYL_RESTRICT out) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap_prime_edge,vmap_prime_skin: velocity space mapping derivative in edge and skin cells. + // flux_surf_edge: Surface expansion of phase space flux on the lower edges of the edge cell. + // flux_surf_skin: Surface expansion of phase space flux on the lower edges of the skin cell. + // edge: determines if the update is for the left edge (-1) or right edge (+1). + // out: output increment in center cell. + + double rdx2 = 2.0/dxv[0]; + + double GhatL[6]= {0.0}; + double GhatR[6]= {0.0}; + + const double *fnodal_l = &flux_surf_skin[0]; + const double *fnodal_r = &flux_surf_edge[0]; + GhatL[0] = 0.2777777777777778*fnodal_l[5]+0.4444444444444444*fnodal_l[4]+0.2777777777777778*fnodal_l[3]+0.2777777777777778*fnodal_l[2]+0.4444444444444444*fnodal_l[1]+0.2777777777777778*fnodal_l[0]; + GhatL[1] = 0.37267799624996495*fnodal_l[5]-0.37267799624996495*fnodal_l[3]+0.37267799624996495*fnodal_l[2]-0.37267799624996495*fnodal_l[0]; + GhatL[2] = 0.2777777777777778*fnodal_l[5]+0.4444444444444444*fnodal_l[4]+0.2777777777777778*fnodal_l[3]-0.2777777777777778*fnodal_l[2]-0.4444444444444444*fnodal_l[1]-0.2777777777777778*fnodal_l[0]; + GhatL[3] = 0.37267799624996495*fnodal_l[5]-0.37267799624996495*fnodal_l[3]-0.37267799624996495*fnodal_l[2]+0.37267799624996495*fnodal_l[0]; + GhatL[4] = 0.24845199749997662*fnodal_l[5]-0.49690399499995325*fnodal_l[4]+0.24845199749997662*fnodal_l[3]+0.24845199749997662*fnodal_l[2]-0.49690399499995325*fnodal_l[1]+0.24845199749997662*fnodal_l[0]; + GhatL[5] = 0.24845199749997673*fnodal_l[5]-0.49690399499995347*fnodal_l[4]+0.24845199749997673*fnodal_l[3]-0.24845199749997673*fnodal_l[2]+0.49690399499995347*fnodal_l[1]-0.24845199749997673*fnodal_l[0]; + GhatR[0] = 0.2777777777777778*fnodal_r[5]+0.4444444444444444*fnodal_r[4]+0.2777777777777778*fnodal_r[3]+0.2777777777777778*fnodal_r[2]+0.4444444444444444*fnodal_r[1]+0.2777777777777778*fnodal_r[0]; + GhatR[1] = 0.37267799624996495*fnodal_r[5]-0.37267799624996495*fnodal_r[3]+0.37267799624996495*fnodal_r[2]-0.37267799624996495*fnodal_r[0]; + GhatR[2] = 0.2777777777777778*fnodal_r[5]+0.4444444444444444*fnodal_r[4]+0.2777777777777778*fnodal_r[3]-0.2777777777777778*fnodal_r[2]-0.4444444444444444*fnodal_r[1]-0.2777777777777778*fnodal_r[0]; + GhatR[3] = 0.37267799624996495*fnodal_r[5]-0.37267799624996495*fnodal_r[3]-0.37267799624996495*fnodal_r[2]+0.37267799624996495*fnodal_r[0]; + GhatR[4] = 0.24845199749997662*fnodal_r[5]-0.49690399499995325*fnodal_r[4]+0.24845199749997662*fnodal_r[3]+0.24845199749997662*fnodal_r[2]-0.49690399499995325*fnodal_r[1]+0.24845199749997662*fnodal_r[0]; + GhatR[5] = 0.24845199749997673*fnodal_r[5]-0.49690399499995347*fnodal_r[4]+0.24845199749997673*fnodal_r[3]-0.24845199749997673*fnodal_r[2]+0.49690399499995347*fnodal_r[1]-0.24845199749997673*fnodal_r[0]; + + if (edge == -1) { + + out[0] += -(0.7071067811865475*GhatR[0]*rdx2); + out[1] += -(1.224744871391589*GhatR[0]*rdx2); + out[2] += -(0.7071067811865475*GhatR[1]*rdx2); + out[3] += -(0.7071067811865475*GhatR[2]*rdx2); + out[4] += -(1.224744871391589*GhatR[1]*rdx2); + out[5] += -(1.224744871391589*GhatR[2]*rdx2); + out[6] += -(0.7071067811865475*GhatR[3]*rdx2); + out[7] += -(1.224744871391589*GhatR[3]*rdx2); + out[8] += -(0.7071067811865475*GhatR[4]*rdx2); + out[9] += -(1.224744871391589*GhatR[4]*rdx2); + out[10] += -(0.7071067811865475*GhatR[5]*rdx2); + out[11] += -(1.224744871391589*GhatR[5]*rdx2); + + } else { + + out[0] += 0.7071067811865475*GhatL[0]*rdx2; + out[1] += -(1.224744871391589*GhatL[0]*rdx2); + out[2] += 0.7071067811865475*GhatL[1]*rdx2; + out[3] += 0.7071067811865475*GhatL[2]*rdx2; + out[4] += -(1.224744871391589*GhatL[1]*rdx2); + out[5] += -(1.224744871391589*GhatL[2]*rdx2); + out[6] += 0.7071067811865475*GhatL[3]*rdx2; + out[7] += -(1.224744871391589*GhatL[3]*rdx2); + out[8] += 0.7071067811865475*GhatL[4]*rdx2; + out[9] += -(1.224744871391589*GhatL[4]*rdx2); + out[10] += 0.7071067811865475*GhatL[5]*rdx2; + out[11] += -(1.224744871391589*GhatL[5]*rdx2); + + } + + return 0.0; + +} diff --git a/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfx_2x2v_ser_p1.c b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfx_2x2v_ser_p1.c new file mode 100644 index 0000000000..4da9f3b46a --- /dev/null +++ b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfx_2x2v_ser_p1.c @@ -0,0 +1,106 @@ +#include +#include +GKYL_CU_DH double dg_gyrokinetic_passive_boundary_surfx_2x2v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_edge, const double *vmap_prime_skin, + const double *flux_surf_edge, const double *flux_surf_skin, + const int edge, double* GKYL_RESTRICT out) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap_prime_edge,vmap_prime_skin: velocity space mapping derivative in edge and skin cells. + // flux_surf_edge: Surface expansion of phase space flux on the lower edges of the edge cell. + // flux_surf_skin: Surface expansion of phase space flux on the lower edges of the skin cell. + // edge: determines if the update is for the left edge (-1) or right edge (+1). + // out: output increment in center cell. + + double rdx2 = 2.0/dxv[0]; + + double GhatL[12]= {0.0}; + double GhatR[12]= {0.0}; + + const double *fnodal_l = &flux_surf_skin[0]; + const double *fnodal_r = &flux_surf_edge[0]; + GhatL[0] = 0.1964185503295965*fnodal_l[11]+0.3142696805273545*fnodal_l[10]+0.1964185503295965*fnodal_l[9]+0.1964185503295965*fnodal_l[8]+0.3142696805273545*fnodal_l[7]+0.1964185503295965*fnodal_l[6]+0.1964185503295965*fnodal_l[5]+0.3142696805273545*fnodal_l[4]+0.1964185503295965*fnodal_l[3]+0.1964185503295965*fnodal_l[2]+0.3142696805273545*fnodal_l[1]+0.1964185503295965*fnodal_l[0]; + GhatL[1] = 0.1964185503295965*fnodal_l[11]+0.3142696805273545*fnodal_l[10]+0.1964185503295965*fnodal_l[9]+0.1964185503295965*fnodal_l[8]+0.3142696805273545*fnodal_l[7]+0.1964185503295965*fnodal_l[6]-0.1964185503295965*fnodal_l[5]-0.3142696805273545*fnodal_l[4]-0.1964185503295965*fnodal_l[3]-0.1964185503295965*fnodal_l[2]-0.3142696805273545*fnodal_l[1]-0.1964185503295965*fnodal_l[0]; + GhatL[2] = 0.2635231383473649*fnodal_l[11]-0.2635231383473649*fnodal_l[9]+0.2635231383473649*fnodal_l[8]-0.2635231383473649*fnodal_l[6]+0.2635231383473649*fnodal_l[5]-0.2635231383473649*fnodal_l[3]+0.2635231383473649*fnodal_l[2]-0.2635231383473649*fnodal_l[0]; + GhatL[3] = 0.1964185503295965*fnodal_l[11]+0.3142696805273545*fnodal_l[10]+0.1964185503295965*fnodal_l[9]-0.1964185503295965*fnodal_l[8]-0.3142696805273545*fnodal_l[7]-0.1964185503295965*fnodal_l[6]+0.1964185503295965*fnodal_l[5]+0.3142696805273545*fnodal_l[4]+0.1964185503295965*fnodal_l[3]-0.1964185503295965*fnodal_l[2]-0.3142696805273545*fnodal_l[1]-0.1964185503295965*fnodal_l[0]; + GhatL[4] = 0.2635231383473649*fnodal_l[11]-0.2635231383473649*fnodal_l[9]+0.2635231383473649*fnodal_l[8]-0.2635231383473649*fnodal_l[6]-0.2635231383473649*fnodal_l[5]+0.2635231383473649*fnodal_l[3]-0.2635231383473649*fnodal_l[2]+0.2635231383473649*fnodal_l[0]; + GhatL[5] = 0.1964185503295965*fnodal_l[11]+0.3142696805273545*fnodal_l[10]+0.1964185503295965*fnodal_l[9]-0.1964185503295965*fnodal_l[8]-0.3142696805273545*fnodal_l[7]-0.1964185503295965*fnodal_l[6]-0.1964185503295965*fnodal_l[5]-0.3142696805273545*fnodal_l[4]-0.1964185503295965*fnodal_l[3]+0.1964185503295965*fnodal_l[2]+0.3142696805273545*fnodal_l[1]+0.1964185503295965*fnodal_l[0]; + GhatL[6] = 0.2635231383473649*fnodal_l[11]-0.2635231383473649*fnodal_l[9]-0.2635231383473649*fnodal_l[8]+0.2635231383473649*fnodal_l[6]+0.2635231383473649*fnodal_l[5]-0.2635231383473649*fnodal_l[3]-0.2635231383473649*fnodal_l[2]+0.2635231383473649*fnodal_l[0]; + GhatL[7] = 0.2635231383473649*fnodal_l[11]-0.2635231383473649*fnodal_l[9]-0.2635231383473649*fnodal_l[8]+0.2635231383473649*fnodal_l[6]-0.2635231383473649*fnodal_l[5]+0.2635231383473649*fnodal_l[3]+0.2635231383473649*fnodal_l[2]-0.2635231383473649*fnodal_l[0]; + GhatL[8] = 0.17568209223157663*fnodal_l[11]-0.35136418446315326*fnodal_l[10]+0.17568209223157663*fnodal_l[9]+0.17568209223157663*fnodal_l[8]-0.35136418446315326*fnodal_l[7]+0.17568209223157663*fnodal_l[6]+0.17568209223157663*fnodal_l[5]-0.35136418446315326*fnodal_l[4]+0.17568209223157663*fnodal_l[3]+0.17568209223157663*fnodal_l[2]-0.35136418446315326*fnodal_l[1]+0.17568209223157663*fnodal_l[0]; + GhatL[9] = 0.1756820922315767*fnodal_l[11]-0.35136418446315343*fnodal_l[10]+0.1756820922315767*fnodal_l[9]+0.1756820922315767*fnodal_l[8]-0.35136418446315343*fnodal_l[7]+0.1756820922315767*fnodal_l[6]-0.1756820922315767*fnodal_l[5]+0.35136418446315343*fnodal_l[4]-0.1756820922315767*fnodal_l[3]-0.1756820922315767*fnodal_l[2]+0.35136418446315343*fnodal_l[1]-0.1756820922315767*fnodal_l[0]; + GhatL[10] = 0.1756820922315767*fnodal_l[11]-0.35136418446315343*fnodal_l[10]+0.1756820922315767*fnodal_l[9]-0.1756820922315767*fnodal_l[8]+0.35136418446315343*fnodal_l[7]-0.1756820922315767*fnodal_l[6]+0.1756820922315767*fnodal_l[5]-0.35136418446315343*fnodal_l[4]+0.1756820922315767*fnodal_l[3]-0.1756820922315767*fnodal_l[2]+0.35136418446315343*fnodal_l[1]-0.1756820922315767*fnodal_l[0]; + GhatL[11] = 0.17568209223157663*fnodal_l[11]-0.35136418446315326*fnodal_l[10]+0.17568209223157663*fnodal_l[9]-0.17568209223157663*fnodal_l[8]+0.35136418446315326*fnodal_l[7]-0.17568209223157663*fnodal_l[6]-0.17568209223157663*fnodal_l[5]+0.35136418446315326*fnodal_l[4]-0.17568209223157663*fnodal_l[3]+0.17568209223157663*fnodal_l[2]-0.35136418446315326*fnodal_l[1]+0.17568209223157663*fnodal_l[0]; + GhatR[0] = 0.1964185503295965*fnodal_r[11]+0.3142696805273545*fnodal_r[10]+0.1964185503295965*fnodal_r[9]+0.1964185503295965*fnodal_r[8]+0.3142696805273545*fnodal_r[7]+0.1964185503295965*fnodal_r[6]+0.1964185503295965*fnodal_r[5]+0.3142696805273545*fnodal_r[4]+0.1964185503295965*fnodal_r[3]+0.1964185503295965*fnodal_r[2]+0.3142696805273545*fnodal_r[1]+0.1964185503295965*fnodal_r[0]; + GhatR[1] = 0.1964185503295965*fnodal_r[11]+0.3142696805273545*fnodal_r[10]+0.1964185503295965*fnodal_r[9]+0.1964185503295965*fnodal_r[8]+0.3142696805273545*fnodal_r[7]+0.1964185503295965*fnodal_r[6]-0.1964185503295965*fnodal_r[5]-0.3142696805273545*fnodal_r[4]-0.1964185503295965*fnodal_r[3]-0.1964185503295965*fnodal_r[2]-0.3142696805273545*fnodal_r[1]-0.1964185503295965*fnodal_r[0]; + GhatR[2] = 0.2635231383473649*fnodal_r[11]-0.2635231383473649*fnodal_r[9]+0.2635231383473649*fnodal_r[8]-0.2635231383473649*fnodal_r[6]+0.2635231383473649*fnodal_r[5]-0.2635231383473649*fnodal_r[3]+0.2635231383473649*fnodal_r[2]-0.2635231383473649*fnodal_r[0]; + GhatR[3] = 0.1964185503295965*fnodal_r[11]+0.3142696805273545*fnodal_r[10]+0.1964185503295965*fnodal_r[9]-0.1964185503295965*fnodal_r[8]-0.3142696805273545*fnodal_r[7]-0.1964185503295965*fnodal_r[6]+0.1964185503295965*fnodal_r[5]+0.3142696805273545*fnodal_r[4]+0.1964185503295965*fnodal_r[3]-0.1964185503295965*fnodal_r[2]-0.3142696805273545*fnodal_r[1]-0.1964185503295965*fnodal_r[0]; + GhatR[4] = 0.2635231383473649*fnodal_r[11]-0.2635231383473649*fnodal_r[9]+0.2635231383473649*fnodal_r[8]-0.2635231383473649*fnodal_r[6]-0.2635231383473649*fnodal_r[5]+0.2635231383473649*fnodal_r[3]-0.2635231383473649*fnodal_r[2]+0.2635231383473649*fnodal_r[0]; + GhatR[5] = 0.1964185503295965*fnodal_r[11]+0.3142696805273545*fnodal_r[10]+0.1964185503295965*fnodal_r[9]-0.1964185503295965*fnodal_r[8]-0.3142696805273545*fnodal_r[7]-0.1964185503295965*fnodal_r[6]-0.1964185503295965*fnodal_r[5]-0.3142696805273545*fnodal_r[4]-0.1964185503295965*fnodal_r[3]+0.1964185503295965*fnodal_r[2]+0.3142696805273545*fnodal_r[1]+0.1964185503295965*fnodal_r[0]; + GhatR[6] = 0.2635231383473649*fnodal_r[11]-0.2635231383473649*fnodal_r[9]-0.2635231383473649*fnodal_r[8]+0.2635231383473649*fnodal_r[6]+0.2635231383473649*fnodal_r[5]-0.2635231383473649*fnodal_r[3]-0.2635231383473649*fnodal_r[2]+0.2635231383473649*fnodal_r[0]; + GhatR[7] = 0.2635231383473649*fnodal_r[11]-0.2635231383473649*fnodal_r[9]-0.2635231383473649*fnodal_r[8]+0.2635231383473649*fnodal_r[6]-0.2635231383473649*fnodal_r[5]+0.2635231383473649*fnodal_r[3]+0.2635231383473649*fnodal_r[2]-0.2635231383473649*fnodal_r[0]; + GhatR[8] = 0.17568209223157663*fnodal_r[11]-0.35136418446315326*fnodal_r[10]+0.17568209223157663*fnodal_r[9]+0.17568209223157663*fnodal_r[8]-0.35136418446315326*fnodal_r[7]+0.17568209223157663*fnodal_r[6]+0.17568209223157663*fnodal_r[5]-0.35136418446315326*fnodal_r[4]+0.17568209223157663*fnodal_r[3]+0.17568209223157663*fnodal_r[2]-0.35136418446315326*fnodal_r[1]+0.17568209223157663*fnodal_r[0]; + GhatR[9] = 0.1756820922315767*fnodal_r[11]-0.35136418446315343*fnodal_r[10]+0.1756820922315767*fnodal_r[9]+0.1756820922315767*fnodal_r[8]-0.35136418446315343*fnodal_r[7]+0.1756820922315767*fnodal_r[6]-0.1756820922315767*fnodal_r[5]+0.35136418446315343*fnodal_r[4]-0.1756820922315767*fnodal_r[3]-0.1756820922315767*fnodal_r[2]+0.35136418446315343*fnodal_r[1]-0.1756820922315767*fnodal_r[0]; + GhatR[10] = 0.1756820922315767*fnodal_r[11]-0.35136418446315343*fnodal_r[10]+0.1756820922315767*fnodal_r[9]-0.1756820922315767*fnodal_r[8]+0.35136418446315343*fnodal_r[7]-0.1756820922315767*fnodal_r[6]+0.1756820922315767*fnodal_r[5]-0.35136418446315343*fnodal_r[4]+0.1756820922315767*fnodal_r[3]-0.1756820922315767*fnodal_r[2]+0.35136418446315343*fnodal_r[1]-0.1756820922315767*fnodal_r[0]; + GhatR[11] = 0.17568209223157663*fnodal_r[11]-0.35136418446315326*fnodal_r[10]+0.17568209223157663*fnodal_r[9]-0.17568209223157663*fnodal_r[8]+0.35136418446315326*fnodal_r[7]-0.17568209223157663*fnodal_r[6]-0.17568209223157663*fnodal_r[5]+0.35136418446315326*fnodal_r[4]-0.17568209223157663*fnodal_r[3]+0.17568209223157663*fnodal_r[2]-0.35136418446315326*fnodal_r[1]+0.17568209223157663*fnodal_r[0]; + + if (edge == -1) { + + out[0] += -(0.7071067811865475*GhatR[0]*rdx2); + out[1] += -(1.224744871391589*GhatR[0]*rdx2); + out[2] += -(0.7071067811865475*GhatR[1]*rdx2); + out[3] += -(0.7071067811865475*GhatR[2]*rdx2); + out[4] += -(0.7071067811865475*GhatR[3]*rdx2); + out[5] += -(1.224744871391589*GhatR[1]*rdx2); + out[6] += -(1.224744871391589*GhatR[2]*rdx2); + out[7] += -(0.7071067811865475*GhatR[4]*rdx2); + out[8] += -(1.224744871391589*GhatR[3]*rdx2); + out[9] += -(0.7071067811865475*GhatR[5]*rdx2); + out[10] += -(0.7071067811865475*GhatR[6]*rdx2); + out[11] += -(1.224744871391589*GhatR[4]*rdx2); + out[12] += -(1.224744871391589*GhatR[5]*rdx2); + out[13] += -(1.224744871391589*GhatR[6]*rdx2); + out[14] += -(0.7071067811865475*GhatR[7]*rdx2); + out[15] += -(1.224744871391589*GhatR[7]*rdx2); + out[16] += -(0.7071067811865475*GhatR[8]*rdx2); + out[17] += -(1.224744871391589*GhatR[8]*rdx2); + out[18] += -(0.7071067811865475*GhatR[9]*rdx2); + out[19] += -(0.7071067811865475*GhatR[10]*rdx2); + out[20] += -(1.224744871391589*GhatR[9]*rdx2); + out[21] += -(1.224744871391589*GhatR[10]*rdx2); + out[22] += -(0.7071067811865475*GhatR[11]*rdx2); + out[23] += -(1.224744871391589*GhatR[11]*rdx2); + + } else { + + out[0] += 0.7071067811865475*GhatL[0]*rdx2; + out[1] += -(1.224744871391589*GhatL[0]*rdx2); + out[2] += 0.7071067811865475*GhatL[1]*rdx2; + out[3] += 0.7071067811865475*GhatL[2]*rdx2; + out[4] += 0.7071067811865475*GhatL[3]*rdx2; + out[5] += -(1.224744871391589*GhatL[1]*rdx2); + out[6] += -(1.224744871391589*GhatL[2]*rdx2); + out[7] += 0.7071067811865475*GhatL[4]*rdx2; + out[8] += -(1.224744871391589*GhatL[3]*rdx2); + out[9] += 0.7071067811865475*GhatL[5]*rdx2; + out[10] += 0.7071067811865475*GhatL[6]*rdx2; + out[11] += -(1.224744871391589*GhatL[4]*rdx2); + out[12] += -(1.224744871391589*GhatL[5]*rdx2); + out[13] += -(1.224744871391589*GhatL[6]*rdx2); + out[14] += 0.7071067811865475*GhatL[7]*rdx2; + out[15] += -(1.224744871391589*GhatL[7]*rdx2); + out[16] += 0.7071067811865475*GhatL[8]*rdx2; + out[17] += -(1.224744871391589*GhatL[8]*rdx2); + out[18] += 0.7071067811865475*GhatL[9]*rdx2; + out[19] += 0.7071067811865475*GhatL[10]*rdx2; + out[20] += -(1.224744871391589*GhatL[9]*rdx2); + out[21] += -(1.224744871391589*GhatL[10]*rdx2); + out[22] += 0.7071067811865475*GhatL[11]*rdx2; + out[23] += -(1.224744871391589*GhatL[11]*rdx2); + + } + + return 0.0; + +} diff --git a/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfx_3x2v_ser_p1.c b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfx_3x2v_ser_p1.c new file mode 100644 index 0000000000..aa09d106ae --- /dev/null +++ b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfx_3x2v_ser_p1.c @@ -0,0 +1,178 @@ +#include +#include +GKYL_CU_DH double dg_gyrokinetic_passive_boundary_surfx_3x2v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_edge, const double *vmap_prime_skin, + const double *flux_surf_edge, const double *flux_surf_skin, + const int edge, double* GKYL_RESTRICT out) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap_prime_edge,vmap_prime_skin: velocity space mapping derivative in edge and skin cells. + // flux_surf_edge: Surface expansion of phase space flux on the lower edges of the edge cell. + // flux_surf_skin: Surface expansion of phase space flux on the lower edges of the skin cell. + // edge: determines if the update is for the left edge (-1) or right edge (+1). + // out: output increment in center cell. + + double rdx2 = 2.0/dxv[0]; + + double GhatL[24]= {0.0}; + double GhatR[24]= {0.0}; + + const double *fnodal_l = &flux_surf_skin[0]; + const double *fnodal_r = &flux_surf_edge[0]; + GhatL[0] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]+0.1388888888888889*fnodal_l[20]+0.2222222222222222*fnodal_l[19]+0.1388888888888889*fnodal_l[18]+0.1388888888888889*fnodal_l[17]+0.2222222222222222*fnodal_l[16]+0.1388888888888889*fnodal_l[15]+0.1388888888888889*fnodal_l[14]+0.2222222222222222*fnodal_l[13]+0.1388888888888889*fnodal_l[12]+0.1388888888888889*fnodal_l[11]+0.2222222222222222*fnodal_l[10]+0.1388888888888889*fnodal_l[9]+0.1388888888888889*fnodal_l[8]+0.2222222222222222*fnodal_l[7]+0.1388888888888889*fnodal_l[6]+0.1388888888888889*fnodal_l[5]+0.2222222222222222*fnodal_l[4]+0.1388888888888889*fnodal_l[3]+0.1388888888888889*fnodal_l[2]+0.2222222222222222*fnodal_l[1]+0.1388888888888889*fnodal_l[0]; + GhatL[1] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]+0.1388888888888889*fnodal_l[20]+0.2222222222222222*fnodal_l[19]+0.1388888888888889*fnodal_l[18]+0.1388888888888889*fnodal_l[17]+0.2222222222222222*fnodal_l[16]+0.1388888888888889*fnodal_l[15]+0.1388888888888889*fnodal_l[14]+0.2222222222222222*fnodal_l[13]+0.1388888888888889*fnodal_l[12]-0.1388888888888889*fnodal_l[11]-0.2222222222222222*fnodal_l[10]-0.1388888888888889*fnodal_l[9]-0.1388888888888889*fnodal_l[8]-0.2222222222222222*fnodal_l[7]-0.1388888888888889*fnodal_l[6]-0.1388888888888889*fnodal_l[5]-0.2222222222222222*fnodal_l[4]-0.1388888888888889*fnodal_l[3]-0.1388888888888889*fnodal_l[2]-0.2222222222222222*fnodal_l[1]-0.1388888888888889*fnodal_l[0]; + GhatL[2] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]+0.1388888888888889*fnodal_l[20]+0.2222222222222222*fnodal_l[19]+0.1388888888888889*fnodal_l[18]-0.1388888888888889*fnodal_l[17]-0.2222222222222222*fnodal_l[16]-0.1388888888888889*fnodal_l[15]-0.1388888888888889*fnodal_l[14]-0.2222222222222222*fnodal_l[13]-0.1388888888888889*fnodal_l[12]+0.1388888888888889*fnodal_l[11]+0.2222222222222222*fnodal_l[10]+0.1388888888888889*fnodal_l[9]+0.1388888888888889*fnodal_l[8]+0.2222222222222222*fnodal_l[7]+0.1388888888888889*fnodal_l[6]-0.1388888888888889*fnodal_l[5]-0.2222222222222222*fnodal_l[4]-0.1388888888888889*fnodal_l[3]-0.1388888888888889*fnodal_l[2]-0.2222222222222222*fnodal_l[1]-0.1388888888888889*fnodal_l[0]; + GhatL[3] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]+0.18633899812498247*fnodal_l[20]-0.18633899812498247*fnodal_l[18]+0.18633899812498247*fnodal_l[17]-0.18633899812498247*fnodal_l[15]+0.18633899812498247*fnodal_l[14]-0.18633899812498247*fnodal_l[12]+0.18633899812498247*fnodal_l[11]-0.18633899812498247*fnodal_l[9]+0.18633899812498247*fnodal_l[8]-0.18633899812498247*fnodal_l[6]+0.18633899812498247*fnodal_l[5]-0.18633899812498247*fnodal_l[3]+0.18633899812498247*fnodal_l[2]-0.18633899812498247*fnodal_l[0]; + GhatL[4] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]-0.1388888888888889*fnodal_l[20]-0.2222222222222222*fnodal_l[19]-0.1388888888888889*fnodal_l[18]+0.1388888888888889*fnodal_l[17]+0.2222222222222222*fnodal_l[16]+0.1388888888888889*fnodal_l[15]-0.1388888888888889*fnodal_l[14]-0.2222222222222222*fnodal_l[13]-0.1388888888888889*fnodal_l[12]+0.1388888888888889*fnodal_l[11]+0.2222222222222222*fnodal_l[10]+0.1388888888888889*fnodal_l[9]-0.1388888888888889*fnodal_l[8]-0.2222222222222222*fnodal_l[7]-0.1388888888888889*fnodal_l[6]+0.1388888888888889*fnodal_l[5]+0.2222222222222222*fnodal_l[4]+0.1388888888888889*fnodal_l[3]-0.1388888888888889*fnodal_l[2]-0.2222222222222222*fnodal_l[1]-0.1388888888888889*fnodal_l[0]; + GhatL[5] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]+0.1388888888888889*fnodal_l[20]+0.2222222222222222*fnodal_l[19]+0.1388888888888889*fnodal_l[18]-0.1388888888888889*fnodal_l[17]-0.2222222222222222*fnodal_l[16]-0.1388888888888889*fnodal_l[15]-0.1388888888888889*fnodal_l[14]-0.2222222222222222*fnodal_l[13]-0.1388888888888889*fnodal_l[12]-0.1388888888888889*fnodal_l[11]-0.2222222222222222*fnodal_l[10]-0.1388888888888889*fnodal_l[9]-0.1388888888888889*fnodal_l[8]-0.2222222222222222*fnodal_l[7]-0.1388888888888889*fnodal_l[6]+0.1388888888888889*fnodal_l[5]+0.2222222222222222*fnodal_l[4]+0.1388888888888889*fnodal_l[3]+0.1388888888888889*fnodal_l[2]+0.2222222222222222*fnodal_l[1]+0.1388888888888889*fnodal_l[0]; + GhatL[6] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]+0.18633899812498247*fnodal_l[20]-0.18633899812498247*fnodal_l[18]+0.18633899812498247*fnodal_l[17]-0.18633899812498247*fnodal_l[15]+0.18633899812498247*fnodal_l[14]-0.18633899812498247*fnodal_l[12]-0.18633899812498247*fnodal_l[11]+0.18633899812498247*fnodal_l[9]-0.18633899812498247*fnodal_l[8]+0.18633899812498247*fnodal_l[6]-0.18633899812498247*fnodal_l[5]+0.18633899812498247*fnodal_l[3]-0.18633899812498247*fnodal_l[2]+0.18633899812498247*fnodal_l[0]; + GhatL[7] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]+0.18633899812498247*fnodal_l[20]-0.18633899812498247*fnodal_l[18]-0.18633899812498247*fnodal_l[17]+0.18633899812498247*fnodal_l[15]-0.18633899812498247*fnodal_l[14]+0.18633899812498247*fnodal_l[12]+0.18633899812498247*fnodal_l[11]-0.18633899812498247*fnodal_l[9]+0.18633899812498247*fnodal_l[8]-0.18633899812498247*fnodal_l[6]-0.18633899812498247*fnodal_l[5]+0.18633899812498247*fnodal_l[3]-0.18633899812498247*fnodal_l[2]+0.18633899812498247*fnodal_l[0]; + GhatL[8] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]-0.1388888888888889*fnodal_l[20]-0.2222222222222222*fnodal_l[19]-0.1388888888888889*fnodal_l[18]+0.1388888888888889*fnodal_l[17]+0.2222222222222222*fnodal_l[16]+0.1388888888888889*fnodal_l[15]-0.1388888888888889*fnodal_l[14]-0.2222222222222222*fnodal_l[13]-0.1388888888888889*fnodal_l[12]-0.1388888888888889*fnodal_l[11]-0.2222222222222222*fnodal_l[10]-0.1388888888888889*fnodal_l[9]+0.1388888888888889*fnodal_l[8]+0.2222222222222222*fnodal_l[7]+0.1388888888888889*fnodal_l[6]-0.1388888888888889*fnodal_l[5]-0.2222222222222222*fnodal_l[4]-0.1388888888888889*fnodal_l[3]+0.1388888888888889*fnodal_l[2]+0.2222222222222222*fnodal_l[1]+0.1388888888888889*fnodal_l[0]; + GhatL[9] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]-0.1388888888888889*fnodal_l[20]-0.2222222222222222*fnodal_l[19]-0.1388888888888889*fnodal_l[18]-0.1388888888888889*fnodal_l[17]-0.2222222222222222*fnodal_l[16]-0.1388888888888889*fnodal_l[15]+0.1388888888888889*fnodal_l[14]+0.2222222222222222*fnodal_l[13]+0.1388888888888889*fnodal_l[12]+0.1388888888888889*fnodal_l[11]+0.2222222222222222*fnodal_l[10]+0.1388888888888889*fnodal_l[9]-0.1388888888888889*fnodal_l[8]-0.2222222222222222*fnodal_l[7]-0.1388888888888889*fnodal_l[6]-0.1388888888888889*fnodal_l[5]-0.2222222222222222*fnodal_l[4]-0.1388888888888889*fnodal_l[3]+0.1388888888888889*fnodal_l[2]+0.2222222222222222*fnodal_l[1]+0.1388888888888889*fnodal_l[0]; + GhatL[10] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]-0.18633899812498247*fnodal_l[20]+0.18633899812498247*fnodal_l[18]+0.18633899812498247*fnodal_l[17]-0.18633899812498247*fnodal_l[15]-0.18633899812498247*fnodal_l[14]+0.18633899812498247*fnodal_l[12]+0.18633899812498247*fnodal_l[11]-0.18633899812498247*fnodal_l[9]-0.18633899812498247*fnodal_l[8]+0.18633899812498247*fnodal_l[6]+0.18633899812498247*fnodal_l[5]-0.18633899812498247*fnodal_l[3]-0.18633899812498247*fnodal_l[2]+0.18633899812498247*fnodal_l[0]; + GhatL[11] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]+0.18633899812498247*fnodal_l[20]-0.18633899812498247*fnodal_l[18]-0.18633899812498247*fnodal_l[17]+0.18633899812498247*fnodal_l[15]-0.18633899812498247*fnodal_l[14]+0.18633899812498247*fnodal_l[12]-0.18633899812498247*fnodal_l[11]+0.18633899812498247*fnodal_l[9]-0.18633899812498247*fnodal_l[8]+0.18633899812498247*fnodal_l[6]+0.18633899812498247*fnodal_l[5]-0.18633899812498247*fnodal_l[3]+0.18633899812498247*fnodal_l[2]-0.18633899812498247*fnodal_l[0]; + GhatL[12] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]-0.1388888888888889*fnodal_l[20]-0.2222222222222222*fnodal_l[19]-0.1388888888888889*fnodal_l[18]-0.1388888888888889*fnodal_l[17]-0.2222222222222222*fnodal_l[16]-0.1388888888888889*fnodal_l[15]+0.1388888888888889*fnodal_l[14]+0.2222222222222222*fnodal_l[13]+0.1388888888888889*fnodal_l[12]-0.1388888888888889*fnodal_l[11]-0.2222222222222222*fnodal_l[10]-0.1388888888888889*fnodal_l[9]+0.1388888888888889*fnodal_l[8]+0.2222222222222222*fnodal_l[7]+0.1388888888888889*fnodal_l[6]+0.1388888888888889*fnodal_l[5]+0.2222222222222222*fnodal_l[4]+0.1388888888888889*fnodal_l[3]-0.1388888888888889*fnodal_l[2]-0.2222222222222222*fnodal_l[1]-0.1388888888888889*fnodal_l[0]; + GhatL[13] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]-0.18633899812498247*fnodal_l[20]+0.18633899812498247*fnodal_l[18]+0.18633899812498247*fnodal_l[17]-0.18633899812498247*fnodal_l[15]-0.18633899812498247*fnodal_l[14]+0.18633899812498247*fnodal_l[12]-0.18633899812498247*fnodal_l[11]+0.18633899812498247*fnodal_l[9]+0.18633899812498247*fnodal_l[8]-0.18633899812498247*fnodal_l[6]-0.18633899812498247*fnodal_l[5]+0.18633899812498247*fnodal_l[3]+0.18633899812498247*fnodal_l[2]-0.18633899812498247*fnodal_l[0]; + GhatL[14] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]-0.18633899812498247*fnodal_l[20]+0.18633899812498247*fnodal_l[18]-0.18633899812498247*fnodal_l[17]+0.18633899812498247*fnodal_l[15]+0.18633899812498247*fnodal_l[14]-0.18633899812498247*fnodal_l[12]+0.18633899812498247*fnodal_l[11]-0.18633899812498247*fnodal_l[9]-0.18633899812498247*fnodal_l[8]+0.18633899812498247*fnodal_l[6]-0.18633899812498247*fnodal_l[5]+0.18633899812498247*fnodal_l[3]+0.18633899812498247*fnodal_l[2]-0.18633899812498247*fnodal_l[0]; + GhatL[15] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]-0.18633899812498247*fnodal_l[20]+0.18633899812498247*fnodal_l[18]-0.18633899812498247*fnodal_l[17]+0.18633899812498247*fnodal_l[15]+0.18633899812498247*fnodal_l[14]-0.18633899812498247*fnodal_l[12]-0.18633899812498247*fnodal_l[11]+0.18633899812498247*fnodal_l[9]+0.18633899812498247*fnodal_l[8]-0.18633899812498247*fnodal_l[6]+0.18633899812498247*fnodal_l[5]-0.18633899812498247*fnodal_l[3]-0.18633899812498247*fnodal_l[2]+0.18633899812498247*fnodal_l[0]; + GhatL[16] = 0.12422599874998831*fnodal_l[23]-0.24845199749997662*fnodal_l[22]+0.12422599874998831*fnodal_l[21]+0.12422599874998831*fnodal_l[20]-0.24845199749997662*fnodal_l[19]+0.12422599874998831*fnodal_l[18]+0.12422599874998831*fnodal_l[17]-0.24845199749997662*fnodal_l[16]+0.12422599874998831*fnodal_l[15]+0.12422599874998831*fnodal_l[14]-0.24845199749997662*fnodal_l[13]+0.12422599874998831*fnodal_l[12]+0.12422599874998831*fnodal_l[11]-0.24845199749997662*fnodal_l[10]+0.12422599874998831*fnodal_l[9]+0.12422599874998831*fnodal_l[8]-0.24845199749997662*fnodal_l[7]+0.12422599874998831*fnodal_l[6]+0.12422599874998831*fnodal_l[5]-0.24845199749997662*fnodal_l[4]+0.12422599874998831*fnodal_l[3]+0.12422599874998831*fnodal_l[2]-0.24845199749997662*fnodal_l[1]+0.12422599874998831*fnodal_l[0]; + GhatL[17] = 0.12422599874998837*fnodal_l[23]-0.24845199749997673*fnodal_l[22]+0.12422599874998837*fnodal_l[21]+0.12422599874998837*fnodal_l[20]-0.24845199749997673*fnodal_l[19]+0.12422599874998837*fnodal_l[18]+0.12422599874998837*fnodal_l[17]-0.24845199749997673*fnodal_l[16]+0.12422599874998837*fnodal_l[15]+0.12422599874998837*fnodal_l[14]-0.24845199749997673*fnodal_l[13]+0.12422599874998837*fnodal_l[12]-0.12422599874998837*fnodal_l[11]+0.24845199749997673*fnodal_l[10]-0.12422599874998837*fnodal_l[9]-0.12422599874998837*fnodal_l[8]+0.24845199749997673*fnodal_l[7]-0.12422599874998837*fnodal_l[6]-0.12422599874998837*fnodal_l[5]+0.24845199749997673*fnodal_l[4]-0.12422599874998837*fnodal_l[3]-0.12422599874998837*fnodal_l[2]+0.24845199749997673*fnodal_l[1]-0.12422599874998837*fnodal_l[0]; + GhatL[18] = 0.12422599874998837*fnodal_l[23]-0.24845199749997673*fnodal_l[22]+0.12422599874998837*fnodal_l[21]+0.12422599874998837*fnodal_l[20]-0.24845199749997673*fnodal_l[19]+0.12422599874998837*fnodal_l[18]-0.12422599874998837*fnodal_l[17]+0.24845199749997673*fnodal_l[16]-0.12422599874998837*fnodal_l[15]-0.12422599874998837*fnodal_l[14]+0.24845199749997673*fnodal_l[13]-0.12422599874998837*fnodal_l[12]+0.12422599874998837*fnodal_l[11]-0.24845199749997673*fnodal_l[10]+0.12422599874998837*fnodal_l[9]+0.12422599874998837*fnodal_l[8]-0.24845199749997673*fnodal_l[7]+0.12422599874998837*fnodal_l[6]-0.12422599874998837*fnodal_l[5]+0.24845199749997673*fnodal_l[4]-0.12422599874998837*fnodal_l[3]-0.12422599874998837*fnodal_l[2]+0.24845199749997673*fnodal_l[1]-0.12422599874998837*fnodal_l[0]; + GhatL[19] = 0.12422599874998837*fnodal_l[23]-0.24845199749997673*fnodal_l[22]+0.12422599874998837*fnodal_l[21]-0.12422599874998837*fnodal_l[20]+0.24845199749997673*fnodal_l[19]-0.12422599874998837*fnodal_l[18]+0.12422599874998837*fnodal_l[17]-0.24845199749997673*fnodal_l[16]+0.12422599874998837*fnodal_l[15]-0.12422599874998837*fnodal_l[14]+0.24845199749997673*fnodal_l[13]-0.12422599874998837*fnodal_l[12]+0.12422599874998837*fnodal_l[11]-0.24845199749997673*fnodal_l[10]+0.12422599874998837*fnodal_l[9]-0.12422599874998837*fnodal_l[8]+0.24845199749997673*fnodal_l[7]-0.12422599874998837*fnodal_l[6]+0.12422599874998837*fnodal_l[5]-0.24845199749997673*fnodal_l[4]+0.12422599874998837*fnodal_l[3]-0.12422599874998837*fnodal_l[2]+0.24845199749997673*fnodal_l[1]-0.12422599874998837*fnodal_l[0]; + GhatL[20] = 0.12422599874998831*fnodal_l[23]-0.24845199749997662*fnodal_l[22]+0.12422599874998831*fnodal_l[21]+0.12422599874998831*fnodal_l[20]-0.24845199749997662*fnodal_l[19]+0.12422599874998831*fnodal_l[18]-0.12422599874998831*fnodal_l[17]+0.24845199749997662*fnodal_l[16]-0.12422599874998831*fnodal_l[15]-0.12422599874998831*fnodal_l[14]+0.24845199749997662*fnodal_l[13]-0.12422599874998831*fnodal_l[12]-0.12422599874998831*fnodal_l[11]+0.24845199749997662*fnodal_l[10]-0.12422599874998831*fnodal_l[9]-0.12422599874998831*fnodal_l[8]+0.24845199749997662*fnodal_l[7]-0.12422599874998831*fnodal_l[6]+0.12422599874998831*fnodal_l[5]-0.24845199749997662*fnodal_l[4]+0.12422599874998831*fnodal_l[3]+0.12422599874998831*fnodal_l[2]-0.24845199749997662*fnodal_l[1]+0.12422599874998831*fnodal_l[0]; + GhatL[21] = 0.12422599874998831*fnodal_l[23]-0.24845199749997662*fnodal_l[22]+0.12422599874998831*fnodal_l[21]-0.12422599874998831*fnodal_l[20]+0.24845199749997662*fnodal_l[19]-0.12422599874998831*fnodal_l[18]+0.12422599874998831*fnodal_l[17]-0.24845199749997662*fnodal_l[16]+0.12422599874998831*fnodal_l[15]-0.12422599874998831*fnodal_l[14]+0.24845199749997662*fnodal_l[13]-0.12422599874998831*fnodal_l[12]-0.12422599874998831*fnodal_l[11]+0.24845199749997662*fnodal_l[10]-0.12422599874998831*fnodal_l[9]+0.12422599874998831*fnodal_l[8]-0.24845199749997662*fnodal_l[7]+0.12422599874998831*fnodal_l[6]-0.12422599874998831*fnodal_l[5]+0.24845199749997662*fnodal_l[4]-0.12422599874998831*fnodal_l[3]+0.12422599874998831*fnodal_l[2]-0.24845199749997662*fnodal_l[1]+0.12422599874998831*fnodal_l[0]; + GhatL[22] = 0.12422599874998831*fnodal_l[23]-0.24845199749997662*fnodal_l[22]+0.12422599874998831*fnodal_l[21]-0.12422599874998831*fnodal_l[20]+0.24845199749997662*fnodal_l[19]-0.12422599874998831*fnodal_l[18]-0.12422599874998831*fnodal_l[17]+0.24845199749997662*fnodal_l[16]-0.12422599874998831*fnodal_l[15]+0.12422599874998831*fnodal_l[14]-0.24845199749997662*fnodal_l[13]+0.12422599874998831*fnodal_l[12]+0.12422599874998831*fnodal_l[11]-0.24845199749997662*fnodal_l[10]+0.12422599874998831*fnodal_l[9]-0.12422599874998831*fnodal_l[8]+0.24845199749997662*fnodal_l[7]-0.12422599874998831*fnodal_l[6]-0.12422599874998831*fnodal_l[5]+0.24845199749997662*fnodal_l[4]-0.12422599874998831*fnodal_l[3]+0.12422599874998831*fnodal_l[2]-0.24845199749997662*fnodal_l[1]+0.12422599874998831*fnodal_l[0]; + GhatL[23] = 0.12422599874998837*fnodal_l[23]-0.24845199749997673*fnodal_l[22]+0.12422599874998837*fnodal_l[21]-0.12422599874998837*fnodal_l[20]+0.24845199749997673*fnodal_l[19]-0.12422599874998837*fnodal_l[18]-0.12422599874998837*fnodal_l[17]+0.24845199749997673*fnodal_l[16]-0.12422599874998837*fnodal_l[15]+0.12422599874998837*fnodal_l[14]-0.24845199749997673*fnodal_l[13]+0.12422599874998837*fnodal_l[12]-0.12422599874998837*fnodal_l[11]+0.24845199749997673*fnodal_l[10]-0.12422599874998837*fnodal_l[9]+0.12422599874998837*fnodal_l[8]-0.24845199749997673*fnodal_l[7]+0.12422599874998837*fnodal_l[6]+0.12422599874998837*fnodal_l[5]-0.24845199749997673*fnodal_l[4]+0.12422599874998837*fnodal_l[3]-0.12422599874998837*fnodal_l[2]+0.24845199749997673*fnodal_l[1]-0.12422599874998837*fnodal_l[0]; + GhatR[0] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]+0.1388888888888889*fnodal_r[20]+0.2222222222222222*fnodal_r[19]+0.1388888888888889*fnodal_r[18]+0.1388888888888889*fnodal_r[17]+0.2222222222222222*fnodal_r[16]+0.1388888888888889*fnodal_r[15]+0.1388888888888889*fnodal_r[14]+0.2222222222222222*fnodal_r[13]+0.1388888888888889*fnodal_r[12]+0.1388888888888889*fnodal_r[11]+0.2222222222222222*fnodal_r[10]+0.1388888888888889*fnodal_r[9]+0.1388888888888889*fnodal_r[8]+0.2222222222222222*fnodal_r[7]+0.1388888888888889*fnodal_r[6]+0.1388888888888889*fnodal_r[5]+0.2222222222222222*fnodal_r[4]+0.1388888888888889*fnodal_r[3]+0.1388888888888889*fnodal_r[2]+0.2222222222222222*fnodal_r[1]+0.1388888888888889*fnodal_r[0]; + GhatR[1] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]+0.1388888888888889*fnodal_r[20]+0.2222222222222222*fnodal_r[19]+0.1388888888888889*fnodal_r[18]+0.1388888888888889*fnodal_r[17]+0.2222222222222222*fnodal_r[16]+0.1388888888888889*fnodal_r[15]+0.1388888888888889*fnodal_r[14]+0.2222222222222222*fnodal_r[13]+0.1388888888888889*fnodal_r[12]-0.1388888888888889*fnodal_r[11]-0.2222222222222222*fnodal_r[10]-0.1388888888888889*fnodal_r[9]-0.1388888888888889*fnodal_r[8]-0.2222222222222222*fnodal_r[7]-0.1388888888888889*fnodal_r[6]-0.1388888888888889*fnodal_r[5]-0.2222222222222222*fnodal_r[4]-0.1388888888888889*fnodal_r[3]-0.1388888888888889*fnodal_r[2]-0.2222222222222222*fnodal_r[1]-0.1388888888888889*fnodal_r[0]; + GhatR[2] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]+0.1388888888888889*fnodal_r[20]+0.2222222222222222*fnodal_r[19]+0.1388888888888889*fnodal_r[18]-0.1388888888888889*fnodal_r[17]-0.2222222222222222*fnodal_r[16]-0.1388888888888889*fnodal_r[15]-0.1388888888888889*fnodal_r[14]-0.2222222222222222*fnodal_r[13]-0.1388888888888889*fnodal_r[12]+0.1388888888888889*fnodal_r[11]+0.2222222222222222*fnodal_r[10]+0.1388888888888889*fnodal_r[9]+0.1388888888888889*fnodal_r[8]+0.2222222222222222*fnodal_r[7]+0.1388888888888889*fnodal_r[6]-0.1388888888888889*fnodal_r[5]-0.2222222222222222*fnodal_r[4]-0.1388888888888889*fnodal_r[3]-0.1388888888888889*fnodal_r[2]-0.2222222222222222*fnodal_r[1]-0.1388888888888889*fnodal_r[0]; + GhatR[3] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]+0.18633899812498247*fnodal_r[20]-0.18633899812498247*fnodal_r[18]+0.18633899812498247*fnodal_r[17]-0.18633899812498247*fnodal_r[15]+0.18633899812498247*fnodal_r[14]-0.18633899812498247*fnodal_r[12]+0.18633899812498247*fnodal_r[11]-0.18633899812498247*fnodal_r[9]+0.18633899812498247*fnodal_r[8]-0.18633899812498247*fnodal_r[6]+0.18633899812498247*fnodal_r[5]-0.18633899812498247*fnodal_r[3]+0.18633899812498247*fnodal_r[2]-0.18633899812498247*fnodal_r[0]; + GhatR[4] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]-0.1388888888888889*fnodal_r[20]-0.2222222222222222*fnodal_r[19]-0.1388888888888889*fnodal_r[18]+0.1388888888888889*fnodal_r[17]+0.2222222222222222*fnodal_r[16]+0.1388888888888889*fnodal_r[15]-0.1388888888888889*fnodal_r[14]-0.2222222222222222*fnodal_r[13]-0.1388888888888889*fnodal_r[12]+0.1388888888888889*fnodal_r[11]+0.2222222222222222*fnodal_r[10]+0.1388888888888889*fnodal_r[9]-0.1388888888888889*fnodal_r[8]-0.2222222222222222*fnodal_r[7]-0.1388888888888889*fnodal_r[6]+0.1388888888888889*fnodal_r[5]+0.2222222222222222*fnodal_r[4]+0.1388888888888889*fnodal_r[3]-0.1388888888888889*fnodal_r[2]-0.2222222222222222*fnodal_r[1]-0.1388888888888889*fnodal_r[0]; + GhatR[5] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]+0.1388888888888889*fnodal_r[20]+0.2222222222222222*fnodal_r[19]+0.1388888888888889*fnodal_r[18]-0.1388888888888889*fnodal_r[17]-0.2222222222222222*fnodal_r[16]-0.1388888888888889*fnodal_r[15]-0.1388888888888889*fnodal_r[14]-0.2222222222222222*fnodal_r[13]-0.1388888888888889*fnodal_r[12]-0.1388888888888889*fnodal_r[11]-0.2222222222222222*fnodal_r[10]-0.1388888888888889*fnodal_r[9]-0.1388888888888889*fnodal_r[8]-0.2222222222222222*fnodal_r[7]-0.1388888888888889*fnodal_r[6]+0.1388888888888889*fnodal_r[5]+0.2222222222222222*fnodal_r[4]+0.1388888888888889*fnodal_r[3]+0.1388888888888889*fnodal_r[2]+0.2222222222222222*fnodal_r[1]+0.1388888888888889*fnodal_r[0]; + GhatR[6] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]+0.18633899812498247*fnodal_r[20]-0.18633899812498247*fnodal_r[18]+0.18633899812498247*fnodal_r[17]-0.18633899812498247*fnodal_r[15]+0.18633899812498247*fnodal_r[14]-0.18633899812498247*fnodal_r[12]-0.18633899812498247*fnodal_r[11]+0.18633899812498247*fnodal_r[9]-0.18633899812498247*fnodal_r[8]+0.18633899812498247*fnodal_r[6]-0.18633899812498247*fnodal_r[5]+0.18633899812498247*fnodal_r[3]-0.18633899812498247*fnodal_r[2]+0.18633899812498247*fnodal_r[0]; + GhatR[7] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]+0.18633899812498247*fnodal_r[20]-0.18633899812498247*fnodal_r[18]-0.18633899812498247*fnodal_r[17]+0.18633899812498247*fnodal_r[15]-0.18633899812498247*fnodal_r[14]+0.18633899812498247*fnodal_r[12]+0.18633899812498247*fnodal_r[11]-0.18633899812498247*fnodal_r[9]+0.18633899812498247*fnodal_r[8]-0.18633899812498247*fnodal_r[6]-0.18633899812498247*fnodal_r[5]+0.18633899812498247*fnodal_r[3]-0.18633899812498247*fnodal_r[2]+0.18633899812498247*fnodal_r[0]; + GhatR[8] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]-0.1388888888888889*fnodal_r[20]-0.2222222222222222*fnodal_r[19]-0.1388888888888889*fnodal_r[18]+0.1388888888888889*fnodal_r[17]+0.2222222222222222*fnodal_r[16]+0.1388888888888889*fnodal_r[15]-0.1388888888888889*fnodal_r[14]-0.2222222222222222*fnodal_r[13]-0.1388888888888889*fnodal_r[12]-0.1388888888888889*fnodal_r[11]-0.2222222222222222*fnodal_r[10]-0.1388888888888889*fnodal_r[9]+0.1388888888888889*fnodal_r[8]+0.2222222222222222*fnodal_r[7]+0.1388888888888889*fnodal_r[6]-0.1388888888888889*fnodal_r[5]-0.2222222222222222*fnodal_r[4]-0.1388888888888889*fnodal_r[3]+0.1388888888888889*fnodal_r[2]+0.2222222222222222*fnodal_r[1]+0.1388888888888889*fnodal_r[0]; + GhatR[9] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]-0.1388888888888889*fnodal_r[20]-0.2222222222222222*fnodal_r[19]-0.1388888888888889*fnodal_r[18]-0.1388888888888889*fnodal_r[17]-0.2222222222222222*fnodal_r[16]-0.1388888888888889*fnodal_r[15]+0.1388888888888889*fnodal_r[14]+0.2222222222222222*fnodal_r[13]+0.1388888888888889*fnodal_r[12]+0.1388888888888889*fnodal_r[11]+0.2222222222222222*fnodal_r[10]+0.1388888888888889*fnodal_r[9]-0.1388888888888889*fnodal_r[8]-0.2222222222222222*fnodal_r[7]-0.1388888888888889*fnodal_r[6]-0.1388888888888889*fnodal_r[5]-0.2222222222222222*fnodal_r[4]-0.1388888888888889*fnodal_r[3]+0.1388888888888889*fnodal_r[2]+0.2222222222222222*fnodal_r[1]+0.1388888888888889*fnodal_r[0]; + GhatR[10] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]-0.18633899812498247*fnodal_r[20]+0.18633899812498247*fnodal_r[18]+0.18633899812498247*fnodal_r[17]-0.18633899812498247*fnodal_r[15]-0.18633899812498247*fnodal_r[14]+0.18633899812498247*fnodal_r[12]+0.18633899812498247*fnodal_r[11]-0.18633899812498247*fnodal_r[9]-0.18633899812498247*fnodal_r[8]+0.18633899812498247*fnodal_r[6]+0.18633899812498247*fnodal_r[5]-0.18633899812498247*fnodal_r[3]-0.18633899812498247*fnodal_r[2]+0.18633899812498247*fnodal_r[0]; + GhatR[11] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]+0.18633899812498247*fnodal_r[20]-0.18633899812498247*fnodal_r[18]-0.18633899812498247*fnodal_r[17]+0.18633899812498247*fnodal_r[15]-0.18633899812498247*fnodal_r[14]+0.18633899812498247*fnodal_r[12]-0.18633899812498247*fnodal_r[11]+0.18633899812498247*fnodal_r[9]-0.18633899812498247*fnodal_r[8]+0.18633899812498247*fnodal_r[6]+0.18633899812498247*fnodal_r[5]-0.18633899812498247*fnodal_r[3]+0.18633899812498247*fnodal_r[2]-0.18633899812498247*fnodal_r[0]; + GhatR[12] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]-0.1388888888888889*fnodal_r[20]-0.2222222222222222*fnodal_r[19]-0.1388888888888889*fnodal_r[18]-0.1388888888888889*fnodal_r[17]-0.2222222222222222*fnodal_r[16]-0.1388888888888889*fnodal_r[15]+0.1388888888888889*fnodal_r[14]+0.2222222222222222*fnodal_r[13]+0.1388888888888889*fnodal_r[12]-0.1388888888888889*fnodal_r[11]-0.2222222222222222*fnodal_r[10]-0.1388888888888889*fnodal_r[9]+0.1388888888888889*fnodal_r[8]+0.2222222222222222*fnodal_r[7]+0.1388888888888889*fnodal_r[6]+0.1388888888888889*fnodal_r[5]+0.2222222222222222*fnodal_r[4]+0.1388888888888889*fnodal_r[3]-0.1388888888888889*fnodal_r[2]-0.2222222222222222*fnodal_r[1]-0.1388888888888889*fnodal_r[0]; + GhatR[13] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]-0.18633899812498247*fnodal_r[20]+0.18633899812498247*fnodal_r[18]+0.18633899812498247*fnodal_r[17]-0.18633899812498247*fnodal_r[15]-0.18633899812498247*fnodal_r[14]+0.18633899812498247*fnodal_r[12]-0.18633899812498247*fnodal_r[11]+0.18633899812498247*fnodal_r[9]+0.18633899812498247*fnodal_r[8]-0.18633899812498247*fnodal_r[6]-0.18633899812498247*fnodal_r[5]+0.18633899812498247*fnodal_r[3]+0.18633899812498247*fnodal_r[2]-0.18633899812498247*fnodal_r[0]; + GhatR[14] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]-0.18633899812498247*fnodal_r[20]+0.18633899812498247*fnodal_r[18]-0.18633899812498247*fnodal_r[17]+0.18633899812498247*fnodal_r[15]+0.18633899812498247*fnodal_r[14]-0.18633899812498247*fnodal_r[12]+0.18633899812498247*fnodal_r[11]-0.18633899812498247*fnodal_r[9]-0.18633899812498247*fnodal_r[8]+0.18633899812498247*fnodal_r[6]-0.18633899812498247*fnodal_r[5]+0.18633899812498247*fnodal_r[3]+0.18633899812498247*fnodal_r[2]-0.18633899812498247*fnodal_r[0]; + GhatR[15] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]-0.18633899812498247*fnodal_r[20]+0.18633899812498247*fnodal_r[18]-0.18633899812498247*fnodal_r[17]+0.18633899812498247*fnodal_r[15]+0.18633899812498247*fnodal_r[14]-0.18633899812498247*fnodal_r[12]-0.18633899812498247*fnodal_r[11]+0.18633899812498247*fnodal_r[9]+0.18633899812498247*fnodal_r[8]-0.18633899812498247*fnodal_r[6]+0.18633899812498247*fnodal_r[5]-0.18633899812498247*fnodal_r[3]-0.18633899812498247*fnodal_r[2]+0.18633899812498247*fnodal_r[0]; + GhatR[16] = 0.12422599874998831*fnodal_r[23]-0.24845199749997662*fnodal_r[22]+0.12422599874998831*fnodal_r[21]+0.12422599874998831*fnodal_r[20]-0.24845199749997662*fnodal_r[19]+0.12422599874998831*fnodal_r[18]+0.12422599874998831*fnodal_r[17]-0.24845199749997662*fnodal_r[16]+0.12422599874998831*fnodal_r[15]+0.12422599874998831*fnodal_r[14]-0.24845199749997662*fnodal_r[13]+0.12422599874998831*fnodal_r[12]+0.12422599874998831*fnodal_r[11]-0.24845199749997662*fnodal_r[10]+0.12422599874998831*fnodal_r[9]+0.12422599874998831*fnodal_r[8]-0.24845199749997662*fnodal_r[7]+0.12422599874998831*fnodal_r[6]+0.12422599874998831*fnodal_r[5]-0.24845199749997662*fnodal_r[4]+0.12422599874998831*fnodal_r[3]+0.12422599874998831*fnodal_r[2]-0.24845199749997662*fnodal_r[1]+0.12422599874998831*fnodal_r[0]; + GhatR[17] = 0.12422599874998837*fnodal_r[23]-0.24845199749997673*fnodal_r[22]+0.12422599874998837*fnodal_r[21]+0.12422599874998837*fnodal_r[20]-0.24845199749997673*fnodal_r[19]+0.12422599874998837*fnodal_r[18]+0.12422599874998837*fnodal_r[17]-0.24845199749997673*fnodal_r[16]+0.12422599874998837*fnodal_r[15]+0.12422599874998837*fnodal_r[14]-0.24845199749997673*fnodal_r[13]+0.12422599874998837*fnodal_r[12]-0.12422599874998837*fnodal_r[11]+0.24845199749997673*fnodal_r[10]-0.12422599874998837*fnodal_r[9]-0.12422599874998837*fnodal_r[8]+0.24845199749997673*fnodal_r[7]-0.12422599874998837*fnodal_r[6]-0.12422599874998837*fnodal_r[5]+0.24845199749997673*fnodal_r[4]-0.12422599874998837*fnodal_r[3]-0.12422599874998837*fnodal_r[2]+0.24845199749997673*fnodal_r[1]-0.12422599874998837*fnodal_r[0]; + GhatR[18] = 0.12422599874998837*fnodal_r[23]-0.24845199749997673*fnodal_r[22]+0.12422599874998837*fnodal_r[21]+0.12422599874998837*fnodal_r[20]-0.24845199749997673*fnodal_r[19]+0.12422599874998837*fnodal_r[18]-0.12422599874998837*fnodal_r[17]+0.24845199749997673*fnodal_r[16]-0.12422599874998837*fnodal_r[15]-0.12422599874998837*fnodal_r[14]+0.24845199749997673*fnodal_r[13]-0.12422599874998837*fnodal_r[12]+0.12422599874998837*fnodal_r[11]-0.24845199749997673*fnodal_r[10]+0.12422599874998837*fnodal_r[9]+0.12422599874998837*fnodal_r[8]-0.24845199749997673*fnodal_r[7]+0.12422599874998837*fnodal_r[6]-0.12422599874998837*fnodal_r[5]+0.24845199749997673*fnodal_r[4]-0.12422599874998837*fnodal_r[3]-0.12422599874998837*fnodal_r[2]+0.24845199749997673*fnodal_r[1]-0.12422599874998837*fnodal_r[0]; + GhatR[19] = 0.12422599874998837*fnodal_r[23]-0.24845199749997673*fnodal_r[22]+0.12422599874998837*fnodal_r[21]-0.12422599874998837*fnodal_r[20]+0.24845199749997673*fnodal_r[19]-0.12422599874998837*fnodal_r[18]+0.12422599874998837*fnodal_r[17]-0.24845199749997673*fnodal_r[16]+0.12422599874998837*fnodal_r[15]-0.12422599874998837*fnodal_r[14]+0.24845199749997673*fnodal_r[13]-0.12422599874998837*fnodal_r[12]+0.12422599874998837*fnodal_r[11]-0.24845199749997673*fnodal_r[10]+0.12422599874998837*fnodal_r[9]-0.12422599874998837*fnodal_r[8]+0.24845199749997673*fnodal_r[7]-0.12422599874998837*fnodal_r[6]+0.12422599874998837*fnodal_r[5]-0.24845199749997673*fnodal_r[4]+0.12422599874998837*fnodal_r[3]-0.12422599874998837*fnodal_r[2]+0.24845199749997673*fnodal_r[1]-0.12422599874998837*fnodal_r[0]; + GhatR[20] = 0.12422599874998831*fnodal_r[23]-0.24845199749997662*fnodal_r[22]+0.12422599874998831*fnodal_r[21]+0.12422599874998831*fnodal_r[20]-0.24845199749997662*fnodal_r[19]+0.12422599874998831*fnodal_r[18]-0.12422599874998831*fnodal_r[17]+0.24845199749997662*fnodal_r[16]-0.12422599874998831*fnodal_r[15]-0.12422599874998831*fnodal_r[14]+0.24845199749997662*fnodal_r[13]-0.12422599874998831*fnodal_r[12]-0.12422599874998831*fnodal_r[11]+0.24845199749997662*fnodal_r[10]-0.12422599874998831*fnodal_r[9]-0.12422599874998831*fnodal_r[8]+0.24845199749997662*fnodal_r[7]-0.12422599874998831*fnodal_r[6]+0.12422599874998831*fnodal_r[5]-0.24845199749997662*fnodal_r[4]+0.12422599874998831*fnodal_r[3]+0.12422599874998831*fnodal_r[2]-0.24845199749997662*fnodal_r[1]+0.12422599874998831*fnodal_r[0]; + GhatR[21] = 0.12422599874998831*fnodal_r[23]-0.24845199749997662*fnodal_r[22]+0.12422599874998831*fnodal_r[21]-0.12422599874998831*fnodal_r[20]+0.24845199749997662*fnodal_r[19]-0.12422599874998831*fnodal_r[18]+0.12422599874998831*fnodal_r[17]-0.24845199749997662*fnodal_r[16]+0.12422599874998831*fnodal_r[15]-0.12422599874998831*fnodal_r[14]+0.24845199749997662*fnodal_r[13]-0.12422599874998831*fnodal_r[12]-0.12422599874998831*fnodal_r[11]+0.24845199749997662*fnodal_r[10]-0.12422599874998831*fnodal_r[9]+0.12422599874998831*fnodal_r[8]-0.24845199749997662*fnodal_r[7]+0.12422599874998831*fnodal_r[6]-0.12422599874998831*fnodal_r[5]+0.24845199749997662*fnodal_r[4]-0.12422599874998831*fnodal_r[3]+0.12422599874998831*fnodal_r[2]-0.24845199749997662*fnodal_r[1]+0.12422599874998831*fnodal_r[0]; + GhatR[22] = 0.12422599874998831*fnodal_r[23]-0.24845199749997662*fnodal_r[22]+0.12422599874998831*fnodal_r[21]-0.12422599874998831*fnodal_r[20]+0.24845199749997662*fnodal_r[19]-0.12422599874998831*fnodal_r[18]-0.12422599874998831*fnodal_r[17]+0.24845199749997662*fnodal_r[16]-0.12422599874998831*fnodal_r[15]+0.12422599874998831*fnodal_r[14]-0.24845199749997662*fnodal_r[13]+0.12422599874998831*fnodal_r[12]+0.12422599874998831*fnodal_r[11]-0.24845199749997662*fnodal_r[10]+0.12422599874998831*fnodal_r[9]-0.12422599874998831*fnodal_r[8]+0.24845199749997662*fnodal_r[7]-0.12422599874998831*fnodal_r[6]-0.12422599874998831*fnodal_r[5]+0.24845199749997662*fnodal_r[4]-0.12422599874998831*fnodal_r[3]+0.12422599874998831*fnodal_r[2]-0.24845199749997662*fnodal_r[1]+0.12422599874998831*fnodal_r[0]; + GhatR[23] = 0.12422599874998837*fnodal_r[23]-0.24845199749997673*fnodal_r[22]+0.12422599874998837*fnodal_r[21]-0.12422599874998837*fnodal_r[20]+0.24845199749997673*fnodal_r[19]-0.12422599874998837*fnodal_r[18]-0.12422599874998837*fnodal_r[17]+0.24845199749997673*fnodal_r[16]-0.12422599874998837*fnodal_r[15]+0.12422599874998837*fnodal_r[14]-0.24845199749997673*fnodal_r[13]+0.12422599874998837*fnodal_r[12]-0.12422599874998837*fnodal_r[11]+0.24845199749997673*fnodal_r[10]-0.12422599874998837*fnodal_r[9]+0.12422599874998837*fnodal_r[8]-0.24845199749997673*fnodal_r[7]+0.12422599874998837*fnodal_r[6]+0.12422599874998837*fnodal_r[5]-0.24845199749997673*fnodal_r[4]+0.12422599874998837*fnodal_r[3]-0.12422599874998837*fnodal_r[2]+0.24845199749997673*fnodal_r[1]-0.12422599874998837*fnodal_r[0]; + + if (edge == -1) { + + out[0] += -(0.7071067811865475*GhatR[0]*rdx2); + out[1] += -(1.224744871391589*GhatR[0]*rdx2); + out[2] += -(0.7071067811865475*GhatR[1]*rdx2); + out[3] += -(0.7071067811865475*GhatR[2]*rdx2); + out[4] += -(0.7071067811865475*GhatR[3]*rdx2); + out[5] += -(0.7071067811865475*GhatR[4]*rdx2); + out[6] += -(1.224744871391589*GhatR[1]*rdx2); + out[7] += -(1.224744871391589*GhatR[2]*rdx2); + out[8] += -(0.7071067811865475*GhatR[5]*rdx2); + out[9] += -(1.224744871391589*GhatR[3]*rdx2); + out[10] += -(0.7071067811865475*GhatR[6]*rdx2); + out[11] += -(0.7071067811865475*GhatR[7]*rdx2); + out[12] += -(1.224744871391589*GhatR[4]*rdx2); + out[13] += -(0.7071067811865475*GhatR[8]*rdx2); + out[14] += -(0.7071067811865475*GhatR[9]*rdx2); + out[15] += -(0.7071067811865475*GhatR[10]*rdx2); + out[16] += -(1.224744871391589*GhatR[5]*rdx2); + out[17] += -(1.224744871391589*GhatR[6]*rdx2); + out[18] += -(1.224744871391589*GhatR[7]*rdx2); + out[19] += -(0.7071067811865475*GhatR[11]*rdx2); + out[20] += -(1.224744871391589*GhatR[8]*rdx2); + out[21] += -(1.224744871391589*GhatR[9]*rdx2); + out[22] += -(0.7071067811865475*GhatR[12]*rdx2); + out[23] += -(1.224744871391589*GhatR[10]*rdx2); + out[24] += -(0.7071067811865475*GhatR[13]*rdx2); + out[25] += -(0.7071067811865475*GhatR[14]*rdx2); + out[26] += -(1.224744871391589*GhatR[11]*rdx2); + out[27] += -(1.224744871391589*GhatR[12]*rdx2); + out[28] += -(1.224744871391589*GhatR[13]*rdx2); + out[29] += -(1.224744871391589*GhatR[14]*rdx2); + out[30] += -(0.7071067811865475*GhatR[15]*rdx2); + out[31] += -(1.224744871391589*GhatR[15]*rdx2); + out[32] += -(0.7071067811865475*GhatR[16]*rdx2); + out[33] += -(1.224744871391589*GhatR[16]*rdx2); + out[34] += -(0.7071067811865475*GhatR[17]*rdx2); + out[35] += -(0.7071067811865475*GhatR[18]*rdx2); + out[36] += -(0.7071067811865475*GhatR[19]*rdx2); + out[37] += -(1.224744871391589*GhatR[17]*rdx2); + out[38] += -(1.224744871391589*GhatR[18]*rdx2); + out[39] += -(0.7071067811865475*GhatR[20]*rdx2); + out[40] += -(1.224744871391589*GhatR[19]*rdx2); + out[41] += -(0.7071067811865475*GhatR[21]*rdx2); + out[42] += -(0.7071067811865475*GhatR[22]*rdx2); + out[43] += -(1.224744871391589*GhatR[20]*rdx2); + out[44] += -(1.224744871391589*GhatR[21]*rdx2); + out[45] += -(1.224744871391589*GhatR[22]*rdx2); + out[46] += -(0.7071067811865475*GhatR[23]*rdx2); + out[47] += -(1.224744871391589*GhatR[23]*rdx2); + + } else { + + out[0] += 0.7071067811865475*GhatL[0]*rdx2; + out[1] += -(1.224744871391589*GhatL[0]*rdx2); + out[2] += 0.7071067811865475*GhatL[1]*rdx2; + out[3] += 0.7071067811865475*GhatL[2]*rdx2; + out[4] += 0.7071067811865475*GhatL[3]*rdx2; + out[5] += 0.7071067811865475*GhatL[4]*rdx2; + out[6] += -(1.224744871391589*GhatL[1]*rdx2); + out[7] += -(1.224744871391589*GhatL[2]*rdx2); + out[8] += 0.7071067811865475*GhatL[5]*rdx2; + out[9] += -(1.224744871391589*GhatL[3]*rdx2); + out[10] += 0.7071067811865475*GhatL[6]*rdx2; + out[11] += 0.7071067811865475*GhatL[7]*rdx2; + out[12] += -(1.224744871391589*GhatL[4]*rdx2); + out[13] += 0.7071067811865475*GhatL[8]*rdx2; + out[14] += 0.7071067811865475*GhatL[9]*rdx2; + out[15] += 0.7071067811865475*GhatL[10]*rdx2; + out[16] += -(1.224744871391589*GhatL[5]*rdx2); + out[17] += -(1.224744871391589*GhatL[6]*rdx2); + out[18] += -(1.224744871391589*GhatL[7]*rdx2); + out[19] += 0.7071067811865475*GhatL[11]*rdx2; + out[20] += -(1.224744871391589*GhatL[8]*rdx2); + out[21] += -(1.224744871391589*GhatL[9]*rdx2); + out[22] += 0.7071067811865475*GhatL[12]*rdx2; + out[23] += -(1.224744871391589*GhatL[10]*rdx2); + out[24] += 0.7071067811865475*GhatL[13]*rdx2; + out[25] += 0.7071067811865475*GhatL[14]*rdx2; + out[26] += -(1.224744871391589*GhatL[11]*rdx2); + out[27] += -(1.224744871391589*GhatL[12]*rdx2); + out[28] += -(1.224744871391589*GhatL[13]*rdx2); + out[29] += -(1.224744871391589*GhatL[14]*rdx2); + out[30] += 0.7071067811865475*GhatL[15]*rdx2; + out[31] += -(1.224744871391589*GhatL[15]*rdx2); + out[32] += 0.7071067811865475*GhatL[16]*rdx2; + out[33] += -(1.224744871391589*GhatL[16]*rdx2); + out[34] += 0.7071067811865475*GhatL[17]*rdx2; + out[35] += 0.7071067811865475*GhatL[18]*rdx2; + out[36] += 0.7071067811865475*GhatL[19]*rdx2; + out[37] += -(1.224744871391589*GhatL[17]*rdx2); + out[38] += -(1.224744871391589*GhatL[18]*rdx2); + out[39] += 0.7071067811865475*GhatL[20]*rdx2; + out[40] += -(1.224744871391589*GhatL[19]*rdx2); + out[41] += 0.7071067811865475*GhatL[21]*rdx2; + out[42] += 0.7071067811865475*GhatL[22]*rdx2; + out[43] += -(1.224744871391589*GhatL[20]*rdx2); + out[44] += -(1.224744871391589*GhatL[21]*rdx2); + out[45] += -(1.224744871391589*GhatL[22]*rdx2); + out[46] += 0.7071067811865475*GhatL[23]*rdx2; + out[47] += -(1.224744871391589*GhatL[23]*rdx2); + + } + + return 0.0; + +} diff --git a/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfy_2x2v_ser_p1.c b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfy_2x2v_ser_p1.c new file mode 100644 index 0000000000..075a85f198 --- /dev/null +++ b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfy_2x2v_ser_p1.c @@ -0,0 +1,106 @@ +#include +#include +GKYL_CU_DH double dg_gyrokinetic_passive_boundary_surfy_2x2v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_edge, const double *vmap_prime_skin, + const double *flux_surf_edge, const double *flux_surf_skin, + const int edge, double* GKYL_RESTRICT out) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap_prime_edge,vmap_prime_skin: velocity space mapping derivative in edge and skin cells. + // flux_surf_edge: Surface expansion of phase space flux on the lower edges of the edge cell. + // flux_surf_skin: Surface expansion of phase space flux on the lower edges of the skin cell. + // edge: determines if the update is for the left edge (-1) or right edge (+1). + // out: output increment in center cell. + + double rdz2 = 2.0/dxv[1]; + + double GhatL[12]= {0.0}; + double GhatR[12]= {0.0}; + + const double *fnodal_l = &flux_surf_skin[12]; + const double *fnodal_r = &flux_surf_edge[12]; + GhatL[0] = 0.1964185503295965*fnodal_l[11]+0.3142696805273545*fnodal_l[10]+0.1964185503295965*fnodal_l[9]+0.1964185503295965*fnodal_l[8]+0.3142696805273545*fnodal_l[7]+0.1964185503295965*fnodal_l[6]+0.1964185503295965*fnodal_l[5]+0.3142696805273545*fnodal_l[4]+0.1964185503295965*fnodal_l[3]+0.1964185503295965*fnodal_l[2]+0.3142696805273545*fnodal_l[1]+0.1964185503295965*fnodal_l[0]; + GhatL[1] = 0.1964185503295965*fnodal_l[11]+0.3142696805273545*fnodal_l[10]+0.1964185503295965*fnodal_l[9]+0.1964185503295965*fnodal_l[8]+0.3142696805273545*fnodal_l[7]+0.1964185503295965*fnodal_l[6]-0.1964185503295965*fnodal_l[5]-0.3142696805273545*fnodal_l[4]-0.1964185503295965*fnodal_l[3]-0.1964185503295965*fnodal_l[2]-0.3142696805273545*fnodal_l[1]-0.1964185503295965*fnodal_l[0]; + GhatL[2] = 0.2635231383473649*fnodal_l[11]-0.2635231383473649*fnodal_l[9]+0.2635231383473649*fnodal_l[8]-0.2635231383473649*fnodal_l[6]+0.2635231383473649*fnodal_l[5]-0.2635231383473649*fnodal_l[3]+0.2635231383473649*fnodal_l[2]-0.2635231383473649*fnodal_l[0]; + GhatL[3] = 0.1964185503295965*fnodal_l[11]+0.3142696805273545*fnodal_l[10]+0.1964185503295965*fnodal_l[9]-0.1964185503295965*fnodal_l[8]-0.3142696805273545*fnodal_l[7]-0.1964185503295965*fnodal_l[6]+0.1964185503295965*fnodal_l[5]+0.3142696805273545*fnodal_l[4]+0.1964185503295965*fnodal_l[3]-0.1964185503295965*fnodal_l[2]-0.3142696805273545*fnodal_l[1]-0.1964185503295965*fnodal_l[0]; + GhatL[4] = 0.2635231383473649*fnodal_l[11]-0.2635231383473649*fnodal_l[9]+0.2635231383473649*fnodal_l[8]-0.2635231383473649*fnodal_l[6]-0.2635231383473649*fnodal_l[5]+0.2635231383473649*fnodal_l[3]-0.2635231383473649*fnodal_l[2]+0.2635231383473649*fnodal_l[0]; + GhatL[5] = 0.1964185503295965*fnodal_l[11]+0.3142696805273545*fnodal_l[10]+0.1964185503295965*fnodal_l[9]-0.1964185503295965*fnodal_l[8]-0.3142696805273545*fnodal_l[7]-0.1964185503295965*fnodal_l[6]-0.1964185503295965*fnodal_l[5]-0.3142696805273545*fnodal_l[4]-0.1964185503295965*fnodal_l[3]+0.1964185503295965*fnodal_l[2]+0.3142696805273545*fnodal_l[1]+0.1964185503295965*fnodal_l[0]; + GhatL[6] = 0.2635231383473649*fnodal_l[11]-0.2635231383473649*fnodal_l[9]-0.2635231383473649*fnodal_l[8]+0.2635231383473649*fnodal_l[6]+0.2635231383473649*fnodal_l[5]-0.2635231383473649*fnodal_l[3]-0.2635231383473649*fnodal_l[2]+0.2635231383473649*fnodal_l[0]; + GhatL[7] = 0.2635231383473649*fnodal_l[11]-0.2635231383473649*fnodal_l[9]-0.2635231383473649*fnodal_l[8]+0.2635231383473649*fnodal_l[6]-0.2635231383473649*fnodal_l[5]+0.2635231383473649*fnodal_l[3]+0.2635231383473649*fnodal_l[2]-0.2635231383473649*fnodal_l[0]; + GhatL[8] = 0.17568209223157663*fnodal_l[11]-0.35136418446315326*fnodal_l[10]+0.17568209223157663*fnodal_l[9]+0.17568209223157663*fnodal_l[8]-0.35136418446315326*fnodal_l[7]+0.17568209223157663*fnodal_l[6]+0.17568209223157663*fnodal_l[5]-0.35136418446315326*fnodal_l[4]+0.17568209223157663*fnodal_l[3]+0.17568209223157663*fnodal_l[2]-0.35136418446315326*fnodal_l[1]+0.17568209223157663*fnodal_l[0]; + GhatL[9] = 0.1756820922315767*fnodal_l[11]-0.35136418446315343*fnodal_l[10]+0.1756820922315767*fnodal_l[9]+0.1756820922315767*fnodal_l[8]-0.35136418446315343*fnodal_l[7]+0.1756820922315767*fnodal_l[6]-0.1756820922315767*fnodal_l[5]+0.35136418446315343*fnodal_l[4]-0.1756820922315767*fnodal_l[3]-0.1756820922315767*fnodal_l[2]+0.35136418446315343*fnodal_l[1]-0.1756820922315767*fnodal_l[0]; + GhatL[10] = 0.1756820922315767*fnodal_l[11]-0.35136418446315343*fnodal_l[10]+0.1756820922315767*fnodal_l[9]-0.1756820922315767*fnodal_l[8]+0.35136418446315343*fnodal_l[7]-0.1756820922315767*fnodal_l[6]+0.1756820922315767*fnodal_l[5]-0.35136418446315343*fnodal_l[4]+0.1756820922315767*fnodal_l[3]-0.1756820922315767*fnodal_l[2]+0.35136418446315343*fnodal_l[1]-0.1756820922315767*fnodal_l[0]; + GhatL[11] = 0.17568209223157663*fnodal_l[11]-0.35136418446315326*fnodal_l[10]+0.17568209223157663*fnodal_l[9]-0.17568209223157663*fnodal_l[8]+0.35136418446315326*fnodal_l[7]-0.17568209223157663*fnodal_l[6]-0.17568209223157663*fnodal_l[5]+0.35136418446315326*fnodal_l[4]-0.17568209223157663*fnodal_l[3]+0.17568209223157663*fnodal_l[2]-0.35136418446315326*fnodal_l[1]+0.17568209223157663*fnodal_l[0]; + GhatR[0] = 0.1964185503295965*fnodal_r[11]+0.3142696805273545*fnodal_r[10]+0.1964185503295965*fnodal_r[9]+0.1964185503295965*fnodal_r[8]+0.3142696805273545*fnodal_r[7]+0.1964185503295965*fnodal_r[6]+0.1964185503295965*fnodal_r[5]+0.3142696805273545*fnodal_r[4]+0.1964185503295965*fnodal_r[3]+0.1964185503295965*fnodal_r[2]+0.3142696805273545*fnodal_r[1]+0.1964185503295965*fnodal_r[0]; + GhatR[1] = 0.1964185503295965*fnodal_r[11]+0.3142696805273545*fnodal_r[10]+0.1964185503295965*fnodal_r[9]+0.1964185503295965*fnodal_r[8]+0.3142696805273545*fnodal_r[7]+0.1964185503295965*fnodal_r[6]-0.1964185503295965*fnodal_r[5]-0.3142696805273545*fnodal_r[4]-0.1964185503295965*fnodal_r[3]-0.1964185503295965*fnodal_r[2]-0.3142696805273545*fnodal_r[1]-0.1964185503295965*fnodal_r[0]; + GhatR[2] = 0.2635231383473649*fnodal_r[11]-0.2635231383473649*fnodal_r[9]+0.2635231383473649*fnodal_r[8]-0.2635231383473649*fnodal_r[6]+0.2635231383473649*fnodal_r[5]-0.2635231383473649*fnodal_r[3]+0.2635231383473649*fnodal_r[2]-0.2635231383473649*fnodal_r[0]; + GhatR[3] = 0.1964185503295965*fnodal_r[11]+0.3142696805273545*fnodal_r[10]+0.1964185503295965*fnodal_r[9]-0.1964185503295965*fnodal_r[8]-0.3142696805273545*fnodal_r[7]-0.1964185503295965*fnodal_r[6]+0.1964185503295965*fnodal_r[5]+0.3142696805273545*fnodal_r[4]+0.1964185503295965*fnodal_r[3]-0.1964185503295965*fnodal_r[2]-0.3142696805273545*fnodal_r[1]-0.1964185503295965*fnodal_r[0]; + GhatR[4] = 0.2635231383473649*fnodal_r[11]-0.2635231383473649*fnodal_r[9]+0.2635231383473649*fnodal_r[8]-0.2635231383473649*fnodal_r[6]-0.2635231383473649*fnodal_r[5]+0.2635231383473649*fnodal_r[3]-0.2635231383473649*fnodal_r[2]+0.2635231383473649*fnodal_r[0]; + GhatR[5] = 0.1964185503295965*fnodal_r[11]+0.3142696805273545*fnodal_r[10]+0.1964185503295965*fnodal_r[9]-0.1964185503295965*fnodal_r[8]-0.3142696805273545*fnodal_r[7]-0.1964185503295965*fnodal_r[6]-0.1964185503295965*fnodal_r[5]-0.3142696805273545*fnodal_r[4]-0.1964185503295965*fnodal_r[3]+0.1964185503295965*fnodal_r[2]+0.3142696805273545*fnodal_r[1]+0.1964185503295965*fnodal_r[0]; + GhatR[6] = 0.2635231383473649*fnodal_r[11]-0.2635231383473649*fnodal_r[9]-0.2635231383473649*fnodal_r[8]+0.2635231383473649*fnodal_r[6]+0.2635231383473649*fnodal_r[5]-0.2635231383473649*fnodal_r[3]-0.2635231383473649*fnodal_r[2]+0.2635231383473649*fnodal_r[0]; + GhatR[7] = 0.2635231383473649*fnodal_r[11]-0.2635231383473649*fnodal_r[9]-0.2635231383473649*fnodal_r[8]+0.2635231383473649*fnodal_r[6]-0.2635231383473649*fnodal_r[5]+0.2635231383473649*fnodal_r[3]+0.2635231383473649*fnodal_r[2]-0.2635231383473649*fnodal_r[0]; + GhatR[8] = 0.17568209223157663*fnodal_r[11]-0.35136418446315326*fnodal_r[10]+0.17568209223157663*fnodal_r[9]+0.17568209223157663*fnodal_r[8]-0.35136418446315326*fnodal_r[7]+0.17568209223157663*fnodal_r[6]+0.17568209223157663*fnodal_r[5]-0.35136418446315326*fnodal_r[4]+0.17568209223157663*fnodal_r[3]+0.17568209223157663*fnodal_r[2]-0.35136418446315326*fnodal_r[1]+0.17568209223157663*fnodal_r[0]; + GhatR[9] = 0.1756820922315767*fnodal_r[11]-0.35136418446315343*fnodal_r[10]+0.1756820922315767*fnodal_r[9]+0.1756820922315767*fnodal_r[8]-0.35136418446315343*fnodal_r[7]+0.1756820922315767*fnodal_r[6]-0.1756820922315767*fnodal_r[5]+0.35136418446315343*fnodal_r[4]-0.1756820922315767*fnodal_r[3]-0.1756820922315767*fnodal_r[2]+0.35136418446315343*fnodal_r[1]-0.1756820922315767*fnodal_r[0]; + GhatR[10] = 0.1756820922315767*fnodal_r[11]-0.35136418446315343*fnodal_r[10]+0.1756820922315767*fnodal_r[9]-0.1756820922315767*fnodal_r[8]+0.35136418446315343*fnodal_r[7]-0.1756820922315767*fnodal_r[6]+0.1756820922315767*fnodal_r[5]-0.35136418446315343*fnodal_r[4]+0.1756820922315767*fnodal_r[3]-0.1756820922315767*fnodal_r[2]+0.35136418446315343*fnodal_r[1]-0.1756820922315767*fnodal_r[0]; + GhatR[11] = 0.17568209223157663*fnodal_r[11]-0.35136418446315326*fnodal_r[10]+0.17568209223157663*fnodal_r[9]-0.17568209223157663*fnodal_r[8]+0.35136418446315326*fnodal_r[7]-0.17568209223157663*fnodal_r[6]-0.17568209223157663*fnodal_r[5]+0.35136418446315326*fnodal_r[4]-0.17568209223157663*fnodal_r[3]+0.17568209223157663*fnodal_r[2]-0.35136418446315326*fnodal_r[1]+0.17568209223157663*fnodal_r[0]; + + if (edge == -1) { + + out[0] += -(0.7071067811865475*GhatR[0]*rdz2); + out[1] += -(0.7071067811865475*GhatR[1]*rdz2); + out[2] += -(1.224744871391589*GhatR[0]*rdz2); + out[3] += -(0.7071067811865475*GhatR[2]*rdz2); + out[4] += -(0.7071067811865475*GhatR[3]*rdz2); + out[5] += -(1.224744871391589*GhatR[1]*rdz2); + out[6] += -(0.7071067811865475*GhatR[4]*rdz2); + out[7] += -(1.224744871391589*GhatR[2]*rdz2); + out[8] += -(0.7071067811865475*GhatR[5]*rdz2); + out[9] += -(1.224744871391589*GhatR[3]*rdz2); + out[10] += -(0.7071067811865475*GhatR[6]*rdz2); + out[11] += -(1.224744871391589*GhatR[4]*rdz2); + out[12] += -(1.224744871391589*GhatR[5]*rdz2); + out[13] += -(0.7071067811865475*GhatR[7]*rdz2); + out[14] += -(1.224744871391589*GhatR[6]*rdz2); + out[15] += -(1.224744871391589*GhatR[7]*rdz2); + out[16] += -(0.7071067811865475*GhatR[8]*rdz2); + out[17] += -(0.7071067811865475*GhatR[9]*rdz2); + out[18] += -(1.224744871391589*GhatR[8]*rdz2); + out[19] += -(0.7071067811865475*GhatR[10]*rdz2); + out[20] += -(1.224744871391589*GhatR[9]*rdz2); + out[21] += -(0.7071067811865475*GhatR[11]*rdz2); + out[22] += -(1.224744871391589*GhatR[10]*rdz2); + out[23] += -(1.224744871391589*GhatR[11]*rdz2); + + } else { + + out[0] += 0.7071067811865475*GhatL[0]*rdz2; + out[1] += 0.7071067811865475*GhatL[1]*rdz2; + out[2] += -(1.224744871391589*GhatL[0]*rdz2); + out[3] += 0.7071067811865475*GhatL[2]*rdz2; + out[4] += 0.7071067811865475*GhatL[3]*rdz2; + out[5] += -(1.224744871391589*GhatL[1]*rdz2); + out[6] += 0.7071067811865475*GhatL[4]*rdz2; + out[7] += -(1.224744871391589*GhatL[2]*rdz2); + out[8] += 0.7071067811865475*GhatL[5]*rdz2; + out[9] += -(1.224744871391589*GhatL[3]*rdz2); + out[10] += 0.7071067811865475*GhatL[6]*rdz2; + out[11] += -(1.224744871391589*GhatL[4]*rdz2); + out[12] += -(1.224744871391589*GhatL[5]*rdz2); + out[13] += 0.7071067811865475*GhatL[7]*rdz2; + out[14] += -(1.224744871391589*GhatL[6]*rdz2); + out[15] += -(1.224744871391589*GhatL[7]*rdz2); + out[16] += 0.7071067811865475*GhatL[8]*rdz2; + out[17] += 0.7071067811865475*GhatL[9]*rdz2; + out[18] += -(1.224744871391589*GhatL[8]*rdz2); + out[19] += 0.7071067811865475*GhatL[10]*rdz2; + out[20] += -(1.224744871391589*GhatL[9]*rdz2); + out[21] += 0.7071067811865475*GhatL[11]*rdz2; + out[22] += -(1.224744871391589*GhatL[10]*rdz2); + out[23] += -(1.224744871391589*GhatL[11]*rdz2); + + } + + return 0.0; + +} diff --git a/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfy_3x2v_ser_p1.c b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfy_3x2v_ser_p1.c new file mode 100644 index 0000000000..a621e8b432 --- /dev/null +++ b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfy_3x2v_ser_p1.c @@ -0,0 +1,178 @@ +#include +#include +GKYL_CU_DH double dg_gyrokinetic_passive_boundary_surfy_3x2v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_edge, const double *vmap_prime_skin, + const double *flux_surf_edge, const double *flux_surf_skin, + const int edge, double* GKYL_RESTRICT out) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap_prime_edge,vmap_prime_skin: velocity space mapping derivative in edge and skin cells. + // flux_surf_edge: Surface expansion of phase space flux on the lower edges of the edge cell. + // flux_surf_skin: Surface expansion of phase space flux on the lower edges of the skin cell. + // edge: determines if the update is for the left edge (-1) or right edge (+1). + // out: output increment in center cell. + + double rdy2 = 2.0/dxv[1]; + + double GhatL[24]= {0.0}; + double GhatR[24]= {0.0}; + + const double *fnodal_l = &flux_surf_skin[24]; + const double *fnodal_r = &flux_surf_edge[24]; + GhatL[0] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]+0.1388888888888889*fnodal_l[20]+0.2222222222222222*fnodal_l[19]+0.1388888888888889*fnodal_l[18]+0.1388888888888889*fnodal_l[17]+0.2222222222222222*fnodal_l[16]+0.1388888888888889*fnodal_l[15]+0.1388888888888889*fnodal_l[14]+0.2222222222222222*fnodal_l[13]+0.1388888888888889*fnodal_l[12]+0.1388888888888889*fnodal_l[11]+0.2222222222222222*fnodal_l[10]+0.1388888888888889*fnodal_l[9]+0.1388888888888889*fnodal_l[8]+0.2222222222222222*fnodal_l[7]+0.1388888888888889*fnodal_l[6]+0.1388888888888889*fnodal_l[5]+0.2222222222222222*fnodal_l[4]+0.1388888888888889*fnodal_l[3]+0.1388888888888889*fnodal_l[2]+0.2222222222222222*fnodal_l[1]+0.1388888888888889*fnodal_l[0]; + GhatL[1] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]+0.1388888888888889*fnodal_l[20]+0.2222222222222222*fnodal_l[19]+0.1388888888888889*fnodal_l[18]+0.1388888888888889*fnodal_l[17]+0.2222222222222222*fnodal_l[16]+0.1388888888888889*fnodal_l[15]+0.1388888888888889*fnodal_l[14]+0.2222222222222222*fnodal_l[13]+0.1388888888888889*fnodal_l[12]-0.1388888888888889*fnodal_l[11]-0.2222222222222222*fnodal_l[10]-0.1388888888888889*fnodal_l[9]-0.1388888888888889*fnodal_l[8]-0.2222222222222222*fnodal_l[7]-0.1388888888888889*fnodal_l[6]-0.1388888888888889*fnodal_l[5]-0.2222222222222222*fnodal_l[4]-0.1388888888888889*fnodal_l[3]-0.1388888888888889*fnodal_l[2]-0.2222222222222222*fnodal_l[1]-0.1388888888888889*fnodal_l[0]; + GhatL[2] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]+0.1388888888888889*fnodal_l[20]+0.2222222222222222*fnodal_l[19]+0.1388888888888889*fnodal_l[18]-0.1388888888888889*fnodal_l[17]-0.2222222222222222*fnodal_l[16]-0.1388888888888889*fnodal_l[15]-0.1388888888888889*fnodal_l[14]-0.2222222222222222*fnodal_l[13]-0.1388888888888889*fnodal_l[12]+0.1388888888888889*fnodal_l[11]+0.2222222222222222*fnodal_l[10]+0.1388888888888889*fnodal_l[9]+0.1388888888888889*fnodal_l[8]+0.2222222222222222*fnodal_l[7]+0.1388888888888889*fnodal_l[6]-0.1388888888888889*fnodal_l[5]-0.2222222222222222*fnodal_l[4]-0.1388888888888889*fnodal_l[3]-0.1388888888888889*fnodal_l[2]-0.2222222222222222*fnodal_l[1]-0.1388888888888889*fnodal_l[0]; + GhatL[3] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]+0.18633899812498247*fnodal_l[20]-0.18633899812498247*fnodal_l[18]+0.18633899812498247*fnodal_l[17]-0.18633899812498247*fnodal_l[15]+0.18633899812498247*fnodal_l[14]-0.18633899812498247*fnodal_l[12]+0.18633899812498247*fnodal_l[11]-0.18633899812498247*fnodal_l[9]+0.18633899812498247*fnodal_l[8]-0.18633899812498247*fnodal_l[6]+0.18633899812498247*fnodal_l[5]-0.18633899812498247*fnodal_l[3]+0.18633899812498247*fnodal_l[2]-0.18633899812498247*fnodal_l[0]; + GhatL[4] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]-0.1388888888888889*fnodal_l[20]-0.2222222222222222*fnodal_l[19]-0.1388888888888889*fnodal_l[18]+0.1388888888888889*fnodal_l[17]+0.2222222222222222*fnodal_l[16]+0.1388888888888889*fnodal_l[15]-0.1388888888888889*fnodal_l[14]-0.2222222222222222*fnodal_l[13]-0.1388888888888889*fnodal_l[12]+0.1388888888888889*fnodal_l[11]+0.2222222222222222*fnodal_l[10]+0.1388888888888889*fnodal_l[9]-0.1388888888888889*fnodal_l[8]-0.2222222222222222*fnodal_l[7]-0.1388888888888889*fnodal_l[6]+0.1388888888888889*fnodal_l[5]+0.2222222222222222*fnodal_l[4]+0.1388888888888889*fnodal_l[3]-0.1388888888888889*fnodal_l[2]-0.2222222222222222*fnodal_l[1]-0.1388888888888889*fnodal_l[0]; + GhatL[5] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]+0.1388888888888889*fnodal_l[20]+0.2222222222222222*fnodal_l[19]+0.1388888888888889*fnodal_l[18]-0.1388888888888889*fnodal_l[17]-0.2222222222222222*fnodal_l[16]-0.1388888888888889*fnodal_l[15]-0.1388888888888889*fnodal_l[14]-0.2222222222222222*fnodal_l[13]-0.1388888888888889*fnodal_l[12]-0.1388888888888889*fnodal_l[11]-0.2222222222222222*fnodal_l[10]-0.1388888888888889*fnodal_l[9]-0.1388888888888889*fnodal_l[8]-0.2222222222222222*fnodal_l[7]-0.1388888888888889*fnodal_l[6]+0.1388888888888889*fnodal_l[5]+0.2222222222222222*fnodal_l[4]+0.1388888888888889*fnodal_l[3]+0.1388888888888889*fnodal_l[2]+0.2222222222222222*fnodal_l[1]+0.1388888888888889*fnodal_l[0]; + GhatL[6] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]+0.18633899812498247*fnodal_l[20]-0.18633899812498247*fnodal_l[18]+0.18633899812498247*fnodal_l[17]-0.18633899812498247*fnodal_l[15]+0.18633899812498247*fnodal_l[14]-0.18633899812498247*fnodal_l[12]-0.18633899812498247*fnodal_l[11]+0.18633899812498247*fnodal_l[9]-0.18633899812498247*fnodal_l[8]+0.18633899812498247*fnodal_l[6]-0.18633899812498247*fnodal_l[5]+0.18633899812498247*fnodal_l[3]-0.18633899812498247*fnodal_l[2]+0.18633899812498247*fnodal_l[0]; + GhatL[7] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]+0.18633899812498247*fnodal_l[20]-0.18633899812498247*fnodal_l[18]-0.18633899812498247*fnodal_l[17]+0.18633899812498247*fnodal_l[15]-0.18633899812498247*fnodal_l[14]+0.18633899812498247*fnodal_l[12]+0.18633899812498247*fnodal_l[11]-0.18633899812498247*fnodal_l[9]+0.18633899812498247*fnodal_l[8]-0.18633899812498247*fnodal_l[6]-0.18633899812498247*fnodal_l[5]+0.18633899812498247*fnodal_l[3]-0.18633899812498247*fnodal_l[2]+0.18633899812498247*fnodal_l[0]; + GhatL[8] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]-0.1388888888888889*fnodal_l[20]-0.2222222222222222*fnodal_l[19]-0.1388888888888889*fnodal_l[18]+0.1388888888888889*fnodal_l[17]+0.2222222222222222*fnodal_l[16]+0.1388888888888889*fnodal_l[15]-0.1388888888888889*fnodal_l[14]-0.2222222222222222*fnodal_l[13]-0.1388888888888889*fnodal_l[12]-0.1388888888888889*fnodal_l[11]-0.2222222222222222*fnodal_l[10]-0.1388888888888889*fnodal_l[9]+0.1388888888888889*fnodal_l[8]+0.2222222222222222*fnodal_l[7]+0.1388888888888889*fnodal_l[6]-0.1388888888888889*fnodal_l[5]-0.2222222222222222*fnodal_l[4]-0.1388888888888889*fnodal_l[3]+0.1388888888888889*fnodal_l[2]+0.2222222222222222*fnodal_l[1]+0.1388888888888889*fnodal_l[0]; + GhatL[9] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]-0.1388888888888889*fnodal_l[20]-0.2222222222222222*fnodal_l[19]-0.1388888888888889*fnodal_l[18]-0.1388888888888889*fnodal_l[17]-0.2222222222222222*fnodal_l[16]-0.1388888888888889*fnodal_l[15]+0.1388888888888889*fnodal_l[14]+0.2222222222222222*fnodal_l[13]+0.1388888888888889*fnodal_l[12]+0.1388888888888889*fnodal_l[11]+0.2222222222222222*fnodal_l[10]+0.1388888888888889*fnodal_l[9]-0.1388888888888889*fnodal_l[8]-0.2222222222222222*fnodal_l[7]-0.1388888888888889*fnodal_l[6]-0.1388888888888889*fnodal_l[5]-0.2222222222222222*fnodal_l[4]-0.1388888888888889*fnodal_l[3]+0.1388888888888889*fnodal_l[2]+0.2222222222222222*fnodal_l[1]+0.1388888888888889*fnodal_l[0]; + GhatL[10] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]-0.18633899812498247*fnodal_l[20]+0.18633899812498247*fnodal_l[18]+0.18633899812498247*fnodal_l[17]-0.18633899812498247*fnodal_l[15]-0.18633899812498247*fnodal_l[14]+0.18633899812498247*fnodal_l[12]+0.18633899812498247*fnodal_l[11]-0.18633899812498247*fnodal_l[9]-0.18633899812498247*fnodal_l[8]+0.18633899812498247*fnodal_l[6]+0.18633899812498247*fnodal_l[5]-0.18633899812498247*fnodal_l[3]-0.18633899812498247*fnodal_l[2]+0.18633899812498247*fnodal_l[0]; + GhatL[11] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]+0.18633899812498247*fnodal_l[20]-0.18633899812498247*fnodal_l[18]-0.18633899812498247*fnodal_l[17]+0.18633899812498247*fnodal_l[15]-0.18633899812498247*fnodal_l[14]+0.18633899812498247*fnodal_l[12]-0.18633899812498247*fnodal_l[11]+0.18633899812498247*fnodal_l[9]-0.18633899812498247*fnodal_l[8]+0.18633899812498247*fnodal_l[6]+0.18633899812498247*fnodal_l[5]-0.18633899812498247*fnodal_l[3]+0.18633899812498247*fnodal_l[2]-0.18633899812498247*fnodal_l[0]; + GhatL[12] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]-0.1388888888888889*fnodal_l[20]-0.2222222222222222*fnodal_l[19]-0.1388888888888889*fnodal_l[18]-0.1388888888888889*fnodal_l[17]-0.2222222222222222*fnodal_l[16]-0.1388888888888889*fnodal_l[15]+0.1388888888888889*fnodal_l[14]+0.2222222222222222*fnodal_l[13]+0.1388888888888889*fnodal_l[12]-0.1388888888888889*fnodal_l[11]-0.2222222222222222*fnodal_l[10]-0.1388888888888889*fnodal_l[9]+0.1388888888888889*fnodal_l[8]+0.2222222222222222*fnodal_l[7]+0.1388888888888889*fnodal_l[6]+0.1388888888888889*fnodal_l[5]+0.2222222222222222*fnodal_l[4]+0.1388888888888889*fnodal_l[3]-0.1388888888888889*fnodal_l[2]-0.2222222222222222*fnodal_l[1]-0.1388888888888889*fnodal_l[0]; + GhatL[13] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]-0.18633899812498247*fnodal_l[20]+0.18633899812498247*fnodal_l[18]+0.18633899812498247*fnodal_l[17]-0.18633899812498247*fnodal_l[15]-0.18633899812498247*fnodal_l[14]+0.18633899812498247*fnodal_l[12]-0.18633899812498247*fnodal_l[11]+0.18633899812498247*fnodal_l[9]+0.18633899812498247*fnodal_l[8]-0.18633899812498247*fnodal_l[6]-0.18633899812498247*fnodal_l[5]+0.18633899812498247*fnodal_l[3]+0.18633899812498247*fnodal_l[2]-0.18633899812498247*fnodal_l[0]; + GhatL[14] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]-0.18633899812498247*fnodal_l[20]+0.18633899812498247*fnodal_l[18]-0.18633899812498247*fnodal_l[17]+0.18633899812498247*fnodal_l[15]+0.18633899812498247*fnodal_l[14]-0.18633899812498247*fnodal_l[12]+0.18633899812498247*fnodal_l[11]-0.18633899812498247*fnodal_l[9]-0.18633899812498247*fnodal_l[8]+0.18633899812498247*fnodal_l[6]-0.18633899812498247*fnodal_l[5]+0.18633899812498247*fnodal_l[3]+0.18633899812498247*fnodal_l[2]-0.18633899812498247*fnodal_l[0]; + GhatL[15] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]-0.18633899812498247*fnodal_l[20]+0.18633899812498247*fnodal_l[18]-0.18633899812498247*fnodal_l[17]+0.18633899812498247*fnodal_l[15]+0.18633899812498247*fnodal_l[14]-0.18633899812498247*fnodal_l[12]-0.18633899812498247*fnodal_l[11]+0.18633899812498247*fnodal_l[9]+0.18633899812498247*fnodal_l[8]-0.18633899812498247*fnodal_l[6]+0.18633899812498247*fnodal_l[5]-0.18633899812498247*fnodal_l[3]-0.18633899812498247*fnodal_l[2]+0.18633899812498247*fnodal_l[0]; + GhatL[16] = 0.12422599874998831*fnodal_l[23]-0.24845199749997662*fnodal_l[22]+0.12422599874998831*fnodal_l[21]+0.12422599874998831*fnodal_l[20]-0.24845199749997662*fnodal_l[19]+0.12422599874998831*fnodal_l[18]+0.12422599874998831*fnodal_l[17]-0.24845199749997662*fnodal_l[16]+0.12422599874998831*fnodal_l[15]+0.12422599874998831*fnodal_l[14]-0.24845199749997662*fnodal_l[13]+0.12422599874998831*fnodal_l[12]+0.12422599874998831*fnodal_l[11]-0.24845199749997662*fnodal_l[10]+0.12422599874998831*fnodal_l[9]+0.12422599874998831*fnodal_l[8]-0.24845199749997662*fnodal_l[7]+0.12422599874998831*fnodal_l[6]+0.12422599874998831*fnodal_l[5]-0.24845199749997662*fnodal_l[4]+0.12422599874998831*fnodal_l[3]+0.12422599874998831*fnodal_l[2]-0.24845199749997662*fnodal_l[1]+0.12422599874998831*fnodal_l[0]; + GhatL[17] = 0.12422599874998837*fnodal_l[23]-0.24845199749997673*fnodal_l[22]+0.12422599874998837*fnodal_l[21]+0.12422599874998837*fnodal_l[20]-0.24845199749997673*fnodal_l[19]+0.12422599874998837*fnodal_l[18]+0.12422599874998837*fnodal_l[17]-0.24845199749997673*fnodal_l[16]+0.12422599874998837*fnodal_l[15]+0.12422599874998837*fnodal_l[14]-0.24845199749997673*fnodal_l[13]+0.12422599874998837*fnodal_l[12]-0.12422599874998837*fnodal_l[11]+0.24845199749997673*fnodal_l[10]-0.12422599874998837*fnodal_l[9]-0.12422599874998837*fnodal_l[8]+0.24845199749997673*fnodal_l[7]-0.12422599874998837*fnodal_l[6]-0.12422599874998837*fnodal_l[5]+0.24845199749997673*fnodal_l[4]-0.12422599874998837*fnodal_l[3]-0.12422599874998837*fnodal_l[2]+0.24845199749997673*fnodal_l[1]-0.12422599874998837*fnodal_l[0]; + GhatL[18] = 0.12422599874998837*fnodal_l[23]-0.24845199749997673*fnodal_l[22]+0.12422599874998837*fnodal_l[21]+0.12422599874998837*fnodal_l[20]-0.24845199749997673*fnodal_l[19]+0.12422599874998837*fnodal_l[18]-0.12422599874998837*fnodal_l[17]+0.24845199749997673*fnodal_l[16]-0.12422599874998837*fnodal_l[15]-0.12422599874998837*fnodal_l[14]+0.24845199749997673*fnodal_l[13]-0.12422599874998837*fnodal_l[12]+0.12422599874998837*fnodal_l[11]-0.24845199749997673*fnodal_l[10]+0.12422599874998837*fnodal_l[9]+0.12422599874998837*fnodal_l[8]-0.24845199749997673*fnodal_l[7]+0.12422599874998837*fnodal_l[6]-0.12422599874998837*fnodal_l[5]+0.24845199749997673*fnodal_l[4]-0.12422599874998837*fnodal_l[3]-0.12422599874998837*fnodal_l[2]+0.24845199749997673*fnodal_l[1]-0.12422599874998837*fnodal_l[0]; + GhatL[19] = 0.12422599874998837*fnodal_l[23]-0.24845199749997673*fnodal_l[22]+0.12422599874998837*fnodal_l[21]-0.12422599874998837*fnodal_l[20]+0.24845199749997673*fnodal_l[19]-0.12422599874998837*fnodal_l[18]+0.12422599874998837*fnodal_l[17]-0.24845199749997673*fnodal_l[16]+0.12422599874998837*fnodal_l[15]-0.12422599874998837*fnodal_l[14]+0.24845199749997673*fnodal_l[13]-0.12422599874998837*fnodal_l[12]+0.12422599874998837*fnodal_l[11]-0.24845199749997673*fnodal_l[10]+0.12422599874998837*fnodal_l[9]-0.12422599874998837*fnodal_l[8]+0.24845199749997673*fnodal_l[7]-0.12422599874998837*fnodal_l[6]+0.12422599874998837*fnodal_l[5]-0.24845199749997673*fnodal_l[4]+0.12422599874998837*fnodal_l[3]-0.12422599874998837*fnodal_l[2]+0.24845199749997673*fnodal_l[1]-0.12422599874998837*fnodal_l[0]; + GhatL[20] = 0.12422599874998831*fnodal_l[23]-0.24845199749997662*fnodal_l[22]+0.12422599874998831*fnodal_l[21]+0.12422599874998831*fnodal_l[20]-0.24845199749997662*fnodal_l[19]+0.12422599874998831*fnodal_l[18]-0.12422599874998831*fnodal_l[17]+0.24845199749997662*fnodal_l[16]-0.12422599874998831*fnodal_l[15]-0.12422599874998831*fnodal_l[14]+0.24845199749997662*fnodal_l[13]-0.12422599874998831*fnodal_l[12]-0.12422599874998831*fnodal_l[11]+0.24845199749997662*fnodal_l[10]-0.12422599874998831*fnodal_l[9]-0.12422599874998831*fnodal_l[8]+0.24845199749997662*fnodal_l[7]-0.12422599874998831*fnodal_l[6]+0.12422599874998831*fnodal_l[5]-0.24845199749997662*fnodal_l[4]+0.12422599874998831*fnodal_l[3]+0.12422599874998831*fnodal_l[2]-0.24845199749997662*fnodal_l[1]+0.12422599874998831*fnodal_l[0]; + GhatL[21] = 0.12422599874998831*fnodal_l[23]-0.24845199749997662*fnodal_l[22]+0.12422599874998831*fnodal_l[21]-0.12422599874998831*fnodal_l[20]+0.24845199749997662*fnodal_l[19]-0.12422599874998831*fnodal_l[18]+0.12422599874998831*fnodal_l[17]-0.24845199749997662*fnodal_l[16]+0.12422599874998831*fnodal_l[15]-0.12422599874998831*fnodal_l[14]+0.24845199749997662*fnodal_l[13]-0.12422599874998831*fnodal_l[12]-0.12422599874998831*fnodal_l[11]+0.24845199749997662*fnodal_l[10]-0.12422599874998831*fnodal_l[9]+0.12422599874998831*fnodal_l[8]-0.24845199749997662*fnodal_l[7]+0.12422599874998831*fnodal_l[6]-0.12422599874998831*fnodal_l[5]+0.24845199749997662*fnodal_l[4]-0.12422599874998831*fnodal_l[3]+0.12422599874998831*fnodal_l[2]-0.24845199749997662*fnodal_l[1]+0.12422599874998831*fnodal_l[0]; + GhatL[22] = 0.12422599874998831*fnodal_l[23]-0.24845199749997662*fnodal_l[22]+0.12422599874998831*fnodal_l[21]-0.12422599874998831*fnodal_l[20]+0.24845199749997662*fnodal_l[19]-0.12422599874998831*fnodal_l[18]-0.12422599874998831*fnodal_l[17]+0.24845199749997662*fnodal_l[16]-0.12422599874998831*fnodal_l[15]+0.12422599874998831*fnodal_l[14]-0.24845199749997662*fnodal_l[13]+0.12422599874998831*fnodal_l[12]+0.12422599874998831*fnodal_l[11]-0.24845199749997662*fnodal_l[10]+0.12422599874998831*fnodal_l[9]-0.12422599874998831*fnodal_l[8]+0.24845199749997662*fnodal_l[7]-0.12422599874998831*fnodal_l[6]-0.12422599874998831*fnodal_l[5]+0.24845199749997662*fnodal_l[4]-0.12422599874998831*fnodal_l[3]+0.12422599874998831*fnodal_l[2]-0.24845199749997662*fnodal_l[1]+0.12422599874998831*fnodal_l[0]; + GhatL[23] = 0.12422599874998837*fnodal_l[23]-0.24845199749997673*fnodal_l[22]+0.12422599874998837*fnodal_l[21]-0.12422599874998837*fnodal_l[20]+0.24845199749997673*fnodal_l[19]-0.12422599874998837*fnodal_l[18]-0.12422599874998837*fnodal_l[17]+0.24845199749997673*fnodal_l[16]-0.12422599874998837*fnodal_l[15]+0.12422599874998837*fnodal_l[14]-0.24845199749997673*fnodal_l[13]+0.12422599874998837*fnodal_l[12]-0.12422599874998837*fnodal_l[11]+0.24845199749997673*fnodal_l[10]-0.12422599874998837*fnodal_l[9]+0.12422599874998837*fnodal_l[8]-0.24845199749997673*fnodal_l[7]+0.12422599874998837*fnodal_l[6]+0.12422599874998837*fnodal_l[5]-0.24845199749997673*fnodal_l[4]+0.12422599874998837*fnodal_l[3]-0.12422599874998837*fnodal_l[2]+0.24845199749997673*fnodal_l[1]-0.12422599874998837*fnodal_l[0]; + GhatR[0] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]+0.1388888888888889*fnodal_r[20]+0.2222222222222222*fnodal_r[19]+0.1388888888888889*fnodal_r[18]+0.1388888888888889*fnodal_r[17]+0.2222222222222222*fnodal_r[16]+0.1388888888888889*fnodal_r[15]+0.1388888888888889*fnodal_r[14]+0.2222222222222222*fnodal_r[13]+0.1388888888888889*fnodal_r[12]+0.1388888888888889*fnodal_r[11]+0.2222222222222222*fnodal_r[10]+0.1388888888888889*fnodal_r[9]+0.1388888888888889*fnodal_r[8]+0.2222222222222222*fnodal_r[7]+0.1388888888888889*fnodal_r[6]+0.1388888888888889*fnodal_r[5]+0.2222222222222222*fnodal_r[4]+0.1388888888888889*fnodal_r[3]+0.1388888888888889*fnodal_r[2]+0.2222222222222222*fnodal_r[1]+0.1388888888888889*fnodal_r[0]; + GhatR[1] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]+0.1388888888888889*fnodal_r[20]+0.2222222222222222*fnodal_r[19]+0.1388888888888889*fnodal_r[18]+0.1388888888888889*fnodal_r[17]+0.2222222222222222*fnodal_r[16]+0.1388888888888889*fnodal_r[15]+0.1388888888888889*fnodal_r[14]+0.2222222222222222*fnodal_r[13]+0.1388888888888889*fnodal_r[12]-0.1388888888888889*fnodal_r[11]-0.2222222222222222*fnodal_r[10]-0.1388888888888889*fnodal_r[9]-0.1388888888888889*fnodal_r[8]-0.2222222222222222*fnodal_r[7]-0.1388888888888889*fnodal_r[6]-0.1388888888888889*fnodal_r[5]-0.2222222222222222*fnodal_r[4]-0.1388888888888889*fnodal_r[3]-0.1388888888888889*fnodal_r[2]-0.2222222222222222*fnodal_r[1]-0.1388888888888889*fnodal_r[0]; + GhatR[2] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]+0.1388888888888889*fnodal_r[20]+0.2222222222222222*fnodal_r[19]+0.1388888888888889*fnodal_r[18]-0.1388888888888889*fnodal_r[17]-0.2222222222222222*fnodal_r[16]-0.1388888888888889*fnodal_r[15]-0.1388888888888889*fnodal_r[14]-0.2222222222222222*fnodal_r[13]-0.1388888888888889*fnodal_r[12]+0.1388888888888889*fnodal_r[11]+0.2222222222222222*fnodal_r[10]+0.1388888888888889*fnodal_r[9]+0.1388888888888889*fnodal_r[8]+0.2222222222222222*fnodal_r[7]+0.1388888888888889*fnodal_r[6]-0.1388888888888889*fnodal_r[5]-0.2222222222222222*fnodal_r[4]-0.1388888888888889*fnodal_r[3]-0.1388888888888889*fnodal_r[2]-0.2222222222222222*fnodal_r[1]-0.1388888888888889*fnodal_r[0]; + GhatR[3] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]+0.18633899812498247*fnodal_r[20]-0.18633899812498247*fnodal_r[18]+0.18633899812498247*fnodal_r[17]-0.18633899812498247*fnodal_r[15]+0.18633899812498247*fnodal_r[14]-0.18633899812498247*fnodal_r[12]+0.18633899812498247*fnodal_r[11]-0.18633899812498247*fnodal_r[9]+0.18633899812498247*fnodal_r[8]-0.18633899812498247*fnodal_r[6]+0.18633899812498247*fnodal_r[5]-0.18633899812498247*fnodal_r[3]+0.18633899812498247*fnodal_r[2]-0.18633899812498247*fnodal_r[0]; + GhatR[4] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]-0.1388888888888889*fnodal_r[20]-0.2222222222222222*fnodal_r[19]-0.1388888888888889*fnodal_r[18]+0.1388888888888889*fnodal_r[17]+0.2222222222222222*fnodal_r[16]+0.1388888888888889*fnodal_r[15]-0.1388888888888889*fnodal_r[14]-0.2222222222222222*fnodal_r[13]-0.1388888888888889*fnodal_r[12]+0.1388888888888889*fnodal_r[11]+0.2222222222222222*fnodal_r[10]+0.1388888888888889*fnodal_r[9]-0.1388888888888889*fnodal_r[8]-0.2222222222222222*fnodal_r[7]-0.1388888888888889*fnodal_r[6]+0.1388888888888889*fnodal_r[5]+0.2222222222222222*fnodal_r[4]+0.1388888888888889*fnodal_r[3]-0.1388888888888889*fnodal_r[2]-0.2222222222222222*fnodal_r[1]-0.1388888888888889*fnodal_r[0]; + GhatR[5] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]+0.1388888888888889*fnodal_r[20]+0.2222222222222222*fnodal_r[19]+0.1388888888888889*fnodal_r[18]-0.1388888888888889*fnodal_r[17]-0.2222222222222222*fnodal_r[16]-0.1388888888888889*fnodal_r[15]-0.1388888888888889*fnodal_r[14]-0.2222222222222222*fnodal_r[13]-0.1388888888888889*fnodal_r[12]-0.1388888888888889*fnodal_r[11]-0.2222222222222222*fnodal_r[10]-0.1388888888888889*fnodal_r[9]-0.1388888888888889*fnodal_r[8]-0.2222222222222222*fnodal_r[7]-0.1388888888888889*fnodal_r[6]+0.1388888888888889*fnodal_r[5]+0.2222222222222222*fnodal_r[4]+0.1388888888888889*fnodal_r[3]+0.1388888888888889*fnodal_r[2]+0.2222222222222222*fnodal_r[1]+0.1388888888888889*fnodal_r[0]; + GhatR[6] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]+0.18633899812498247*fnodal_r[20]-0.18633899812498247*fnodal_r[18]+0.18633899812498247*fnodal_r[17]-0.18633899812498247*fnodal_r[15]+0.18633899812498247*fnodal_r[14]-0.18633899812498247*fnodal_r[12]-0.18633899812498247*fnodal_r[11]+0.18633899812498247*fnodal_r[9]-0.18633899812498247*fnodal_r[8]+0.18633899812498247*fnodal_r[6]-0.18633899812498247*fnodal_r[5]+0.18633899812498247*fnodal_r[3]-0.18633899812498247*fnodal_r[2]+0.18633899812498247*fnodal_r[0]; + GhatR[7] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]+0.18633899812498247*fnodal_r[20]-0.18633899812498247*fnodal_r[18]-0.18633899812498247*fnodal_r[17]+0.18633899812498247*fnodal_r[15]-0.18633899812498247*fnodal_r[14]+0.18633899812498247*fnodal_r[12]+0.18633899812498247*fnodal_r[11]-0.18633899812498247*fnodal_r[9]+0.18633899812498247*fnodal_r[8]-0.18633899812498247*fnodal_r[6]-0.18633899812498247*fnodal_r[5]+0.18633899812498247*fnodal_r[3]-0.18633899812498247*fnodal_r[2]+0.18633899812498247*fnodal_r[0]; + GhatR[8] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]-0.1388888888888889*fnodal_r[20]-0.2222222222222222*fnodal_r[19]-0.1388888888888889*fnodal_r[18]+0.1388888888888889*fnodal_r[17]+0.2222222222222222*fnodal_r[16]+0.1388888888888889*fnodal_r[15]-0.1388888888888889*fnodal_r[14]-0.2222222222222222*fnodal_r[13]-0.1388888888888889*fnodal_r[12]-0.1388888888888889*fnodal_r[11]-0.2222222222222222*fnodal_r[10]-0.1388888888888889*fnodal_r[9]+0.1388888888888889*fnodal_r[8]+0.2222222222222222*fnodal_r[7]+0.1388888888888889*fnodal_r[6]-0.1388888888888889*fnodal_r[5]-0.2222222222222222*fnodal_r[4]-0.1388888888888889*fnodal_r[3]+0.1388888888888889*fnodal_r[2]+0.2222222222222222*fnodal_r[1]+0.1388888888888889*fnodal_r[0]; + GhatR[9] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]-0.1388888888888889*fnodal_r[20]-0.2222222222222222*fnodal_r[19]-0.1388888888888889*fnodal_r[18]-0.1388888888888889*fnodal_r[17]-0.2222222222222222*fnodal_r[16]-0.1388888888888889*fnodal_r[15]+0.1388888888888889*fnodal_r[14]+0.2222222222222222*fnodal_r[13]+0.1388888888888889*fnodal_r[12]+0.1388888888888889*fnodal_r[11]+0.2222222222222222*fnodal_r[10]+0.1388888888888889*fnodal_r[9]-0.1388888888888889*fnodal_r[8]-0.2222222222222222*fnodal_r[7]-0.1388888888888889*fnodal_r[6]-0.1388888888888889*fnodal_r[5]-0.2222222222222222*fnodal_r[4]-0.1388888888888889*fnodal_r[3]+0.1388888888888889*fnodal_r[2]+0.2222222222222222*fnodal_r[1]+0.1388888888888889*fnodal_r[0]; + GhatR[10] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]-0.18633899812498247*fnodal_r[20]+0.18633899812498247*fnodal_r[18]+0.18633899812498247*fnodal_r[17]-0.18633899812498247*fnodal_r[15]-0.18633899812498247*fnodal_r[14]+0.18633899812498247*fnodal_r[12]+0.18633899812498247*fnodal_r[11]-0.18633899812498247*fnodal_r[9]-0.18633899812498247*fnodal_r[8]+0.18633899812498247*fnodal_r[6]+0.18633899812498247*fnodal_r[5]-0.18633899812498247*fnodal_r[3]-0.18633899812498247*fnodal_r[2]+0.18633899812498247*fnodal_r[0]; + GhatR[11] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]+0.18633899812498247*fnodal_r[20]-0.18633899812498247*fnodal_r[18]-0.18633899812498247*fnodal_r[17]+0.18633899812498247*fnodal_r[15]-0.18633899812498247*fnodal_r[14]+0.18633899812498247*fnodal_r[12]-0.18633899812498247*fnodal_r[11]+0.18633899812498247*fnodal_r[9]-0.18633899812498247*fnodal_r[8]+0.18633899812498247*fnodal_r[6]+0.18633899812498247*fnodal_r[5]-0.18633899812498247*fnodal_r[3]+0.18633899812498247*fnodal_r[2]-0.18633899812498247*fnodal_r[0]; + GhatR[12] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]-0.1388888888888889*fnodal_r[20]-0.2222222222222222*fnodal_r[19]-0.1388888888888889*fnodal_r[18]-0.1388888888888889*fnodal_r[17]-0.2222222222222222*fnodal_r[16]-0.1388888888888889*fnodal_r[15]+0.1388888888888889*fnodal_r[14]+0.2222222222222222*fnodal_r[13]+0.1388888888888889*fnodal_r[12]-0.1388888888888889*fnodal_r[11]-0.2222222222222222*fnodal_r[10]-0.1388888888888889*fnodal_r[9]+0.1388888888888889*fnodal_r[8]+0.2222222222222222*fnodal_r[7]+0.1388888888888889*fnodal_r[6]+0.1388888888888889*fnodal_r[5]+0.2222222222222222*fnodal_r[4]+0.1388888888888889*fnodal_r[3]-0.1388888888888889*fnodal_r[2]-0.2222222222222222*fnodal_r[1]-0.1388888888888889*fnodal_r[0]; + GhatR[13] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]-0.18633899812498247*fnodal_r[20]+0.18633899812498247*fnodal_r[18]+0.18633899812498247*fnodal_r[17]-0.18633899812498247*fnodal_r[15]-0.18633899812498247*fnodal_r[14]+0.18633899812498247*fnodal_r[12]-0.18633899812498247*fnodal_r[11]+0.18633899812498247*fnodal_r[9]+0.18633899812498247*fnodal_r[8]-0.18633899812498247*fnodal_r[6]-0.18633899812498247*fnodal_r[5]+0.18633899812498247*fnodal_r[3]+0.18633899812498247*fnodal_r[2]-0.18633899812498247*fnodal_r[0]; + GhatR[14] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]-0.18633899812498247*fnodal_r[20]+0.18633899812498247*fnodal_r[18]-0.18633899812498247*fnodal_r[17]+0.18633899812498247*fnodal_r[15]+0.18633899812498247*fnodal_r[14]-0.18633899812498247*fnodal_r[12]+0.18633899812498247*fnodal_r[11]-0.18633899812498247*fnodal_r[9]-0.18633899812498247*fnodal_r[8]+0.18633899812498247*fnodal_r[6]-0.18633899812498247*fnodal_r[5]+0.18633899812498247*fnodal_r[3]+0.18633899812498247*fnodal_r[2]-0.18633899812498247*fnodal_r[0]; + GhatR[15] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]-0.18633899812498247*fnodal_r[20]+0.18633899812498247*fnodal_r[18]-0.18633899812498247*fnodal_r[17]+0.18633899812498247*fnodal_r[15]+0.18633899812498247*fnodal_r[14]-0.18633899812498247*fnodal_r[12]-0.18633899812498247*fnodal_r[11]+0.18633899812498247*fnodal_r[9]+0.18633899812498247*fnodal_r[8]-0.18633899812498247*fnodal_r[6]+0.18633899812498247*fnodal_r[5]-0.18633899812498247*fnodal_r[3]-0.18633899812498247*fnodal_r[2]+0.18633899812498247*fnodal_r[0]; + GhatR[16] = 0.12422599874998831*fnodal_r[23]-0.24845199749997662*fnodal_r[22]+0.12422599874998831*fnodal_r[21]+0.12422599874998831*fnodal_r[20]-0.24845199749997662*fnodal_r[19]+0.12422599874998831*fnodal_r[18]+0.12422599874998831*fnodal_r[17]-0.24845199749997662*fnodal_r[16]+0.12422599874998831*fnodal_r[15]+0.12422599874998831*fnodal_r[14]-0.24845199749997662*fnodal_r[13]+0.12422599874998831*fnodal_r[12]+0.12422599874998831*fnodal_r[11]-0.24845199749997662*fnodal_r[10]+0.12422599874998831*fnodal_r[9]+0.12422599874998831*fnodal_r[8]-0.24845199749997662*fnodal_r[7]+0.12422599874998831*fnodal_r[6]+0.12422599874998831*fnodal_r[5]-0.24845199749997662*fnodal_r[4]+0.12422599874998831*fnodal_r[3]+0.12422599874998831*fnodal_r[2]-0.24845199749997662*fnodal_r[1]+0.12422599874998831*fnodal_r[0]; + GhatR[17] = 0.12422599874998837*fnodal_r[23]-0.24845199749997673*fnodal_r[22]+0.12422599874998837*fnodal_r[21]+0.12422599874998837*fnodal_r[20]-0.24845199749997673*fnodal_r[19]+0.12422599874998837*fnodal_r[18]+0.12422599874998837*fnodal_r[17]-0.24845199749997673*fnodal_r[16]+0.12422599874998837*fnodal_r[15]+0.12422599874998837*fnodal_r[14]-0.24845199749997673*fnodal_r[13]+0.12422599874998837*fnodal_r[12]-0.12422599874998837*fnodal_r[11]+0.24845199749997673*fnodal_r[10]-0.12422599874998837*fnodal_r[9]-0.12422599874998837*fnodal_r[8]+0.24845199749997673*fnodal_r[7]-0.12422599874998837*fnodal_r[6]-0.12422599874998837*fnodal_r[5]+0.24845199749997673*fnodal_r[4]-0.12422599874998837*fnodal_r[3]-0.12422599874998837*fnodal_r[2]+0.24845199749997673*fnodal_r[1]-0.12422599874998837*fnodal_r[0]; + GhatR[18] = 0.12422599874998837*fnodal_r[23]-0.24845199749997673*fnodal_r[22]+0.12422599874998837*fnodal_r[21]+0.12422599874998837*fnodal_r[20]-0.24845199749997673*fnodal_r[19]+0.12422599874998837*fnodal_r[18]-0.12422599874998837*fnodal_r[17]+0.24845199749997673*fnodal_r[16]-0.12422599874998837*fnodal_r[15]-0.12422599874998837*fnodal_r[14]+0.24845199749997673*fnodal_r[13]-0.12422599874998837*fnodal_r[12]+0.12422599874998837*fnodal_r[11]-0.24845199749997673*fnodal_r[10]+0.12422599874998837*fnodal_r[9]+0.12422599874998837*fnodal_r[8]-0.24845199749997673*fnodal_r[7]+0.12422599874998837*fnodal_r[6]-0.12422599874998837*fnodal_r[5]+0.24845199749997673*fnodal_r[4]-0.12422599874998837*fnodal_r[3]-0.12422599874998837*fnodal_r[2]+0.24845199749997673*fnodal_r[1]-0.12422599874998837*fnodal_r[0]; + GhatR[19] = 0.12422599874998837*fnodal_r[23]-0.24845199749997673*fnodal_r[22]+0.12422599874998837*fnodal_r[21]-0.12422599874998837*fnodal_r[20]+0.24845199749997673*fnodal_r[19]-0.12422599874998837*fnodal_r[18]+0.12422599874998837*fnodal_r[17]-0.24845199749997673*fnodal_r[16]+0.12422599874998837*fnodal_r[15]-0.12422599874998837*fnodal_r[14]+0.24845199749997673*fnodal_r[13]-0.12422599874998837*fnodal_r[12]+0.12422599874998837*fnodal_r[11]-0.24845199749997673*fnodal_r[10]+0.12422599874998837*fnodal_r[9]-0.12422599874998837*fnodal_r[8]+0.24845199749997673*fnodal_r[7]-0.12422599874998837*fnodal_r[6]+0.12422599874998837*fnodal_r[5]-0.24845199749997673*fnodal_r[4]+0.12422599874998837*fnodal_r[3]-0.12422599874998837*fnodal_r[2]+0.24845199749997673*fnodal_r[1]-0.12422599874998837*fnodal_r[0]; + GhatR[20] = 0.12422599874998831*fnodal_r[23]-0.24845199749997662*fnodal_r[22]+0.12422599874998831*fnodal_r[21]+0.12422599874998831*fnodal_r[20]-0.24845199749997662*fnodal_r[19]+0.12422599874998831*fnodal_r[18]-0.12422599874998831*fnodal_r[17]+0.24845199749997662*fnodal_r[16]-0.12422599874998831*fnodal_r[15]-0.12422599874998831*fnodal_r[14]+0.24845199749997662*fnodal_r[13]-0.12422599874998831*fnodal_r[12]-0.12422599874998831*fnodal_r[11]+0.24845199749997662*fnodal_r[10]-0.12422599874998831*fnodal_r[9]-0.12422599874998831*fnodal_r[8]+0.24845199749997662*fnodal_r[7]-0.12422599874998831*fnodal_r[6]+0.12422599874998831*fnodal_r[5]-0.24845199749997662*fnodal_r[4]+0.12422599874998831*fnodal_r[3]+0.12422599874998831*fnodal_r[2]-0.24845199749997662*fnodal_r[1]+0.12422599874998831*fnodal_r[0]; + GhatR[21] = 0.12422599874998831*fnodal_r[23]-0.24845199749997662*fnodal_r[22]+0.12422599874998831*fnodal_r[21]-0.12422599874998831*fnodal_r[20]+0.24845199749997662*fnodal_r[19]-0.12422599874998831*fnodal_r[18]+0.12422599874998831*fnodal_r[17]-0.24845199749997662*fnodal_r[16]+0.12422599874998831*fnodal_r[15]-0.12422599874998831*fnodal_r[14]+0.24845199749997662*fnodal_r[13]-0.12422599874998831*fnodal_r[12]-0.12422599874998831*fnodal_r[11]+0.24845199749997662*fnodal_r[10]-0.12422599874998831*fnodal_r[9]+0.12422599874998831*fnodal_r[8]-0.24845199749997662*fnodal_r[7]+0.12422599874998831*fnodal_r[6]-0.12422599874998831*fnodal_r[5]+0.24845199749997662*fnodal_r[4]-0.12422599874998831*fnodal_r[3]+0.12422599874998831*fnodal_r[2]-0.24845199749997662*fnodal_r[1]+0.12422599874998831*fnodal_r[0]; + GhatR[22] = 0.12422599874998831*fnodal_r[23]-0.24845199749997662*fnodal_r[22]+0.12422599874998831*fnodal_r[21]-0.12422599874998831*fnodal_r[20]+0.24845199749997662*fnodal_r[19]-0.12422599874998831*fnodal_r[18]-0.12422599874998831*fnodal_r[17]+0.24845199749997662*fnodal_r[16]-0.12422599874998831*fnodal_r[15]+0.12422599874998831*fnodal_r[14]-0.24845199749997662*fnodal_r[13]+0.12422599874998831*fnodal_r[12]+0.12422599874998831*fnodal_r[11]-0.24845199749997662*fnodal_r[10]+0.12422599874998831*fnodal_r[9]-0.12422599874998831*fnodal_r[8]+0.24845199749997662*fnodal_r[7]-0.12422599874998831*fnodal_r[6]-0.12422599874998831*fnodal_r[5]+0.24845199749997662*fnodal_r[4]-0.12422599874998831*fnodal_r[3]+0.12422599874998831*fnodal_r[2]-0.24845199749997662*fnodal_r[1]+0.12422599874998831*fnodal_r[0]; + GhatR[23] = 0.12422599874998837*fnodal_r[23]-0.24845199749997673*fnodal_r[22]+0.12422599874998837*fnodal_r[21]-0.12422599874998837*fnodal_r[20]+0.24845199749997673*fnodal_r[19]-0.12422599874998837*fnodal_r[18]-0.12422599874998837*fnodal_r[17]+0.24845199749997673*fnodal_r[16]-0.12422599874998837*fnodal_r[15]+0.12422599874998837*fnodal_r[14]-0.24845199749997673*fnodal_r[13]+0.12422599874998837*fnodal_r[12]-0.12422599874998837*fnodal_r[11]+0.24845199749997673*fnodal_r[10]-0.12422599874998837*fnodal_r[9]+0.12422599874998837*fnodal_r[8]-0.24845199749997673*fnodal_r[7]+0.12422599874998837*fnodal_r[6]+0.12422599874998837*fnodal_r[5]-0.24845199749997673*fnodal_r[4]+0.12422599874998837*fnodal_r[3]-0.12422599874998837*fnodal_r[2]+0.24845199749997673*fnodal_r[1]-0.12422599874998837*fnodal_r[0]; + + if (edge == -1) { + + out[0] += -(0.7071067811865475*GhatR[0]*rdy2); + out[1] += -(0.7071067811865475*GhatR[1]*rdy2); + out[2] += -(1.224744871391589*GhatR[0]*rdy2); + out[3] += -(0.7071067811865475*GhatR[2]*rdy2); + out[4] += -(0.7071067811865475*GhatR[3]*rdy2); + out[5] += -(0.7071067811865475*GhatR[4]*rdy2); + out[6] += -(1.224744871391589*GhatR[1]*rdy2); + out[7] += -(0.7071067811865475*GhatR[5]*rdy2); + out[8] += -(1.224744871391589*GhatR[2]*rdy2); + out[9] += -(0.7071067811865475*GhatR[6]*rdy2); + out[10] += -(1.224744871391589*GhatR[3]*rdy2); + out[11] += -(0.7071067811865475*GhatR[7]*rdy2); + out[12] += -(0.7071067811865475*GhatR[8]*rdy2); + out[13] += -(1.224744871391589*GhatR[4]*rdy2); + out[14] += -(0.7071067811865475*GhatR[9]*rdy2); + out[15] += -(0.7071067811865475*GhatR[10]*rdy2); + out[16] += -(1.224744871391589*GhatR[5]*rdy2); + out[17] += -(1.224744871391589*GhatR[6]*rdy2); + out[18] += -(0.7071067811865475*GhatR[11]*rdy2); + out[19] += -(1.224744871391589*GhatR[7]*rdy2); + out[20] += -(1.224744871391589*GhatR[8]*rdy2); + out[21] += -(0.7071067811865475*GhatR[12]*rdy2); + out[22] += -(1.224744871391589*GhatR[9]*rdy2); + out[23] += -(0.7071067811865475*GhatR[13]*rdy2); + out[24] += -(1.224744871391589*GhatR[10]*rdy2); + out[25] += -(0.7071067811865475*GhatR[14]*rdy2); + out[26] += -(1.224744871391589*GhatR[11]*rdy2); + out[27] += -(1.224744871391589*GhatR[12]*rdy2); + out[28] += -(1.224744871391589*GhatR[13]*rdy2); + out[29] += -(0.7071067811865475*GhatR[15]*rdy2); + out[30] += -(1.224744871391589*GhatR[14]*rdy2); + out[31] += -(1.224744871391589*GhatR[15]*rdy2); + out[32] += -(0.7071067811865475*GhatR[16]*rdy2); + out[33] += -(0.7071067811865475*GhatR[17]*rdy2); + out[34] += -(1.224744871391589*GhatR[16]*rdy2); + out[35] += -(0.7071067811865475*GhatR[18]*rdy2); + out[36] += -(0.7071067811865475*GhatR[19]*rdy2); + out[37] += -(1.224744871391589*GhatR[17]*rdy2); + out[38] += -(0.7071067811865475*GhatR[20]*rdy2); + out[39] += -(1.224744871391589*GhatR[18]*rdy2); + out[40] += -(0.7071067811865475*GhatR[21]*rdy2); + out[41] += -(1.224744871391589*GhatR[19]*rdy2); + out[42] += -(0.7071067811865475*GhatR[22]*rdy2); + out[43] += -(1.224744871391589*GhatR[20]*rdy2); + out[44] += -(1.224744871391589*GhatR[21]*rdy2); + out[45] += -(0.7071067811865475*GhatR[23]*rdy2); + out[46] += -(1.224744871391589*GhatR[22]*rdy2); + out[47] += -(1.224744871391589*GhatR[23]*rdy2); + + } else { + + out[0] += 0.7071067811865475*GhatL[0]*rdy2; + out[1] += 0.7071067811865475*GhatL[1]*rdy2; + out[2] += -(1.224744871391589*GhatL[0]*rdy2); + out[3] += 0.7071067811865475*GhatL[2]*rdy2; + out[4] += 0.7071067811865475*GhatL[3]*rdy2; + out[5] += 0.7071067811865475*GhatL[4]*rdy2; + out[6] += -(1.224744871391589*GhatL[1]*rdy2); + out[7] += 0.7071067811865475*GhatL[5]*rdy2; + out[8] += -(1.224744871391589*GhatL[2]*rdy2); + out[9] += 0.7071067811865475*GhatL[6]*rdy2; + out[10] += -(1.224744871391589*GhatL[3]*rdy2); + out[11] += 0.7071067811865475*GhatL[7]*rdy2; + out[12] += 0.7071067811865475*GhatL[8]*rdy2; + out[13] += -(1.224744871391589*GhatL[4]*rdy2); + out[14] += 0.7071067811865475*GhatL[9]*rdy2; + out[15] += 0.7071067811865475*GhatL[10]*rdy2; + out[16] += -(1.224744871391589*GhatL[5]*rdy2); + out[17] += -(1.224744871391589*GhatL[6]*rdy2); + out[18] += 0.7071067811865475*GhatL[11]*rdy2; + out[19] += -(1.224744871391589*GhatL[7]*rdy2); + out[20] += -(1.224744871391589*GhatL[8]*rdy2); + out[21] += 0.7071067811865475*GhatL[12]*rdy2; + out[22] += -(1.224744871391589*GhatL[9]*rdy2); + out[23] += 0.7071067811865475*GhatL[13]*rdy2; + out[24] += -(1.224744871391589*GhatL[10]*rdy2); + out[25] += 0.7071067811865475*GhatL[14]*rdy2; + out[26] += -(1.224744871391589*GhatL[11]*rdy2); + out[27] += -(1.224744871391589*GhatL[12]*rdy2); + out[28] += -(1.224744871391589*GhatL[13]*rdy2); + out[29] += 0.7071067811865475*GhatL[15]*rdy2; + out[30] += -(1.224744871391589*GhatL[14]*rdy2); + out[31] += -(1.224744871391589*GhatL[15]*rdy2); + out[32] += 0.7071067811865475*GhatL[16]*rdy2; + out[33] += 0.7071067811865475*GhatL[17]*rdy2; + out[34] += -(1.224744871391589*GhatL[16]*rdy2); + out[35] += 0.7071067811865475*GhatL[18]*rdy2; + out[36] += 0.7071067811865475*GhatL[19]*rdy2; + out[37] += -(1.224744871391589*GhatL[17]*rdy2); + out[38] += 0.7071067811865475*GhatL[20]*rdy2; + out[39] += -(1.224744871391589*GhatL[18]*rdy2); + out[40] += 0.7071067811865475*GhatL[21]*rdy2; + out[41] += -(1.224744871391589*GhatL[19]*rdy2); + out[42] += 0.7071067811865475*GhatL[22]*rdy2; + out[43] += -(1.224744871391589*GhatL[20]*rdy2); + out[44] += -(1.224744871391589*GhatL[21]*rdy2); + out[45] += 0.7071067811865475*GhatL[23]*rdy2; + out[46] += -(1.224744871391589*GhatL[22]*rdy2); + out[47] += -(1.224744871391589*GhatL[23]*rdy2); + + } + + return 0.0; + +} diff --git a/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfz_3x2v_ser_p1.c b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfz_3x2v_ser_p1.c new file mode 100644 index 0000000000..35dfc07ec6 --- /dev/null +++ b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfz_3x2v_ser_p1.c @@ -0,0 +1,178 @@ +#include +#include +GKYL_CU_DH double dg_gyrokinetic_passive_boundary_surfz_3x2v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_edge, const double *vmap_prime_skin, + const double *flux_surf_edge, const double *flux_surf_skin, + const int edge, double* GKYL_RESTRICT out) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap_prime_edge,vmap_prime_skin: velocity space mapping derivative in edge and skin cells. + // flux_surf_edge: Surface expansion of phase space flux on the lower edges of the edge cell. + // flux_surf_skin: Surface expansion of phase space flux on the lower edges of the skin cell. + // edge: determines if the update is for the left edge (-1) or right edge (+1). + // out: output increment in center cell. + + double rdz2 = 2.0/dxv[2]; + + double GhatL[24]= {0.0}; + double GhatR[24]= {0.0}; + + const double *fnodal_l = &flux_surf_skin[48]; + const double *fnodal_r = &flux_surf_edge[48]; + GhatL[0] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]+0.1388888888888889*fnodal_l[20]+0.2222222222222222*fnodal_l[19]+0.1388888888888889*fnodal_l[18]+0.1388888888888889*fnodal_l[17]+0.2222222222222222*fnodal_l[16]+0.1388888888888889*fnodal_l[15]+0.1388888888888889*fnodal_l[14]+0.2222222222222222*fnodal_l[13]+0.1388888888888889*fnodal_l[12]+0.1388888888888889*fnodal_l[11]+0.2222222222222222*fnodal_l[10]+0.1388888888888889*fnodal_l[9]+0.1388888888888889*fnodal_l[8]+0.2222222222222222*fnodal_l[7]+0.1388888888888889*fnodal_l[6]+0.1388888888888889*fnodal_l[5]+0.2222222222222222*fnodal_l[4]+0.1388888888888889*fnodal_l[3]+0.1388888888888889*fnodal_l[2]+0.2222222222222222*fnodal_l[1]+0.1388888888888889*fnodal_l[0]; + GhatL[1] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]+0.1388888888888889*fnodal_l[20]+0.2222222222222222*fnodal_l[19]+0.1388888888888889*fnodal_l[18]+0.1388888888888889*fnodal_l[17]+0.2222222222222222*fnodal_l[16]+0.1388888888888889*fnodal_l[15]+0.1388888888888889*fnodal_l[14]+0.2222222222222222*fnodal_l[13]+0.1388888888888889*fnodal_l[12]-0.1388888888888889*fnodal_l[11]-0.2222222222222222*fnodal_l[10]-0.1388888888888889*fnodal_l[9]-0.1388888888888889*fnodal_l[8]-0.2222222222222222*fnodal_l[7]-0.1388888888888889*fnodal_l[6]-0.1388888888888889*fnodal_l[5]-0.2222222222222222*fnodal_l[4]-0.1388888888888889*fnodal_l[3]-0.1388888888888889*fnodal_l[2]-0.2222222222222222*fnodal_l[1]-0.1388888888888889*fnodal_l[0]; + GhatL[2] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]+0.1388888888888889*fnodal_l[20]+0.2222222222222222*fnodal_l[19]+0.1388888888888889*fnodal_l[18]-0.1388888888888889*fnodal_l[17]-0.2222222222222222*fnodal_l[16]-0.1388888888888889*fnodal_l[15]-0.1388888888888889*fnodal_l[14]-0.2222222222222222*fnodal_l[13]-0.1388888888888889*fnodal_l[12]+0.1388888888888889*fnodal_l[11]+0.2222222222222222*fnodal_l[10]+0.1388888888888889*fnodal_l[9]+0.1388888888888889*fnodal_l[8]+0.2222222222222222*fnodal_l[7]+0.1388888888888889*fnodal_l[6]-0.1388888888888889*fnodal_l[5]-0.2222222222222222*fnodal_l[4]-0.1388888888888889*fnodal_l[3]-0.1388888888888889*fnodal_l[2]-0.2222222222222222*fnodal_l[1]-0.1388888888888889*fnodal_l[0]; + GhatL[3] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]+0.18633899812498247*fnodal_l[20]-0.18633899812498247*fnodal_l[18]+0.18633899812498247*fnodal_l[17]-0.18633899812498247*fnodal_l[15]+0.18633899812498247*fnodal_l[14]-0.18633899812498247*fnodal_l[12]+0.18633899812498247*fnodal_l[11]-0.18633899812498247*fnodal_l[9]+0.18633899812498247*fnodal_l[8]-0.18633899812498247*fnodal_l[6]+0.18633899812498247*fnodal_l[5]-0.18633899812498247*fnodal_l[3]+0.18633899812498247*fnodal_l[2]-0.18633899812498247*fnodal_l[0]; + GhatL[4] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]-0.1388888888888889*fnodal_l[20]-0.2222222222222222*fnodal_l[19]-0.1388888888888889*fnodal_l[18]+0.1388888888888889*fnodal_l[17]+0.2222222222222222*fnodal_l[16]+0.1388888888888889*fnodal_l[15]-0.1388888888888889*fnodal_l[14]-0.2222222222222222*fnodal_l[13]-0.1388888888888889*fnodal_l[12]+0.1388888888888889*fnodal_l[11]+0.2222222222222222*fnodal_l[10]+0.1388888888888889*fnodal_l[9]-0.1388888888888889*fnodal_l[8]-0.2222222222222222*fnodal_l[7]-0.1388888888888889*fnodal_l[6]+0.1388888888888889*fnodal_l[5]+0.2222222222222222*fnodal_l[4]+0.1388888888888889*fnodal_l[3]-0.1388888888888889*fnodal_l[2]-0.2222222222222222*fnodal_l[1]-0.1388888888888889*fnodal_l[0]; + GhatL[5] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]+0.1388888888888889*fnodal_l[20]+0.2222222222222222*fnodal_l[19]+0.1388888888888889*fnodal_l[18]-0.1388888888888889*fnodal_l[17]-0.2222222222222222*fnodal_l[16]-0.1388888888888889*fnodal_l[15]-0.1388888888888889*fnodal_l[14]-0.2222222222222222*fnodal_l[13]-0.1388888888888889*fnodal_l[12]-0.1388888888888889*fnodal_l[11]-0.2222222222222222*fnodal_l[10]-0.1388888888888889*fnodal_l[9]-0.1388888888888889*fnodal_l[8]-0.2222222222222222*fnodal_l[7]-0.1388888888888889*fnodal_l[6]+0.1388888888888889*fnodal_l[5]+0.2222222222222222*fnodal_l[4]+0.1388888888888889*fnodal_l[3]+0.1388888888888889*fnodal_l[2]+0.2222222222222222*fnodal_l[1]+0.1388888888888889*fnodal_l[0]; + GhatL[6] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]+0.18633899812498247*fnodal_l[20]-0.18633899812498247*fnodal_l[18]+0.18633899812498247*fnodal_l[17]-0.18633899812498247*fnodal_l[15]+0.18633899812498247*fnodal_l[14]-0.18633899812498247*fnodal_l[12]-0.18633899812498247*fnodal_l[11]+0.18633899812498247*fnodal_l[9]-0.18633899812498247*fnodal_l[8]+0.18633899812498247*fnodal_l[6]-0.18633899812498247*fnodal_l[5]+0.18633899812498247*fnodal_l[3]-0.18633899812498247*fnodal_l[2]+0.18633899812498247*fnodal_l[0]; + GhatL[7] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]+0.18633899812498247*fnodal_l[20]-0.18633899812498247*fnodal_l[18]-0.18633899812498247*fnodal_l[17]+0.18633899812498247*fnodal_l[15]-0.18633899812498247*fnodal_l[14]+0.18633899812498247*fnodal_l[12]+0.18633899812498247*fnodal_l[11]-0.18633899812498247*fnodal_l[9]+0.18633899812498247*fnodal_l[8]-0.18633899812498247*fnodal_l[6]-0.18633899812498247*fnodal_l[5]+0.18633899812498247*fnodal_l[3]-0.18633899812498247*fnodal_l[2]+0.18633899812498247*fnodal_l[0]; + GhatL[8] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]-0.1388888888888889*fnodal_l[20]-0.2222222222222222*fnodal_l[19]-0.1388888888888889*fnodal_l[18]+0.1388888888888889*fnodal_l[17]+0.2222222222222222*fnodal_l[16]+0.1388888888888889*fnodal_l[15]-0.1388888888888889*fnodal_l[14]-0.2222222222222222*fnodal_l[13]-0.1388888888888889*fnodal_l[12]-0.1388888888888889*fnodal_l[11]-0.2222222222222222*fnodal_l[10]-0.1388888888888889*fnodal_l[9]+0.1388888888888889*fnodal_l[8]+0.2222222222222222*fnodal_l[7]+0.1388888888888889*fnodal_l[6]-0.1388888888888889*fnodal_l[5]-0.2222222222222222*fnodal_l[4]-0.1388888888888889*fnodal_l[3]+0.1388888888888889*fnodal_l[2]+0.2222222222222222*fnodal_l[1]+0.1388888888888889*fnodal_l[0]; + GhatL[9] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]-0.1388888888888889*fnodal_l[20]-0.2222222222222222*fnodal_l[19]-0.1388888888888889*fnodal_l[18]-0.1388888888888889*fnodal_l[17]-0.2222222222222222*fnodal_l[16]-0.1388888888888889*fnodal_l[15]+0.1388888888888889*fnodal_l[14]+0.2222222222222222*fnodal_l[13]+0.1388888888888889*fnodal_l[12]+0.1388888888888889*fnodal_l[11]+0.2222222222222222*fnodal_l[10]+0.1388888888888889*fnodal_l[9]-0.1388888888888889*fnodal_l[8]-0.2222222222222222*fnodal_l[7]-0.1388888888888889*fnodal_l[6]-0.1388888888888889*fnodal_l[5]-0.2222222222222222*fnodal_l[4]-0.1388888888888889*fnodal_l[3]+0.1388888888888889*fnodal_l[2]+0.2222222222222222*fnodal_l[1]+0.1388888888888889*fnodal_l[0]; + GhatL[10] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]-0.18633899812498247*fnodal_l[20]+0.18633899812498247*fnodal_l[18]+0.18633899812498247*fnodal_l[17]-0.18633899812498247*fnodal_l[15]-0.18633899812498247*fnodal_l[14]+0.18633899812498247*fnodal_l[12]+0.18633899812498247*fnodal_l[11]-0.18633899812498247*fnodal_l[9]-0.18633899812498247*fnodal_l[8]+0.18633899812498247*fnodal_l[6]+0.18633899812498247*fnodal_l[5]-0.18633899812498247*fnodal_l[3]-0.18633899812498247*fnodal_l[2]+0.18633899812498247*fnodal_l[0]; + GhatL[11] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]+0.18633899812498247*fnodal_l[20]-0.18633899812498247*fnodal_l[18]-0.18633899812498247*fnodal_l[17]+0.18633899812498247*fnodal_l[15]-0.18633899812498247*fnodal_l[14]+0.18633899812498247*fnodal_l[12]-0.18633899812498247*fnodal_l[11]+0.18633899812498247*fnodal_l[9]-0.18633899812498247*fnodal_l[8]+0.18633899812498247*fnodal_l[6]+0.18633899812498247*fnodal_l[5]-0.18633899812498247*fnodal_l[3]+0.18633899812498247*fnodal_l[2]-0.18633899812498247*fnodal_l[0]; + GhatL[12] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]-0.1388888888888889*fnodal_l[20]-0.2222222222222222*fnodal_l[19]-0.1388888888888889*fnodal_l[18]-0.1388888888888889*fnodal_l[17]-0.2222222222222222*fnodal_l[16]-0.1388888888888889*fnodal_l[15]+0.1388888888888889*fnodal_l[14]+0.2222222222222222*fnodal_l[13]+0.1388888888888889*fnodal_l[12]-0.1388888888888889*fnodal_l[11]-0.2222222222222222*fnodal_l[10]-0.1388888888888889*fnodal_l[9]+0.1388888888888889*fnodal_l[8]+0.2222222222222222*fnodal_l[7]+0.1388888888888889*fnodal_l[6]+0.1388888888888889*fnodal_l[5]+0.2222222222222222*fnodal_l[4]+0.1388888888888889*fnodal_l[3]-0.1388888888888889*fnodal_l[2]-0.2222222222222222*fnodal_l[1]-0.1388888888888889*fnodal_l[0]; + GhatL[13] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]-0.18633899812498247*fnodal_l[20]+0.18633899812498247*fnodal_l[18]+0.18633899812498247*fnodal_l[17]-0.18633899812498247*fnodal_l[15]-0.18633899812498247*fnodal_l[14]+0.18633899812498247*fnodal_l[12]-0.18633899812498247*fnodal_l[11]+0.18633899812498247*fnodal_l[9]+0.18633899812498247*fnodal_l[8]-0.18633899812498247*fnodal_l[6]-0.18633899812498247*fnodal_l[5]+0.18633899812498247*fnodal_l[3]+0.18633899812498247*fnodal_l[2]-0.18633899812498247*fnodal_l[0]; + GhatL[14] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]-0.18633899812498247*fnodal_l[20]+0.18633899812498247*fnodal_l[18]-0.18633899812498247*fnodal_l[17]+0.18633899812498247*fnodal_l[15]+0.18633899812498247*fnodal_l[14]-0.18633899812498247*fnodal_l[12]+0.18633899812498247*fnodal_l[11]-0.18633899812498247*fnodal_l[9]-0.18633899812498247*fnodal_l[8]+0.18633899812498247*fnodal_l[6]-0.18633899812498247*fnodal_l[5]+0.18633899812498247*fnodal_l[3]+0.18633899812498247*fnodal_l[2]-0.18633899812498247*fnodal_l[0]; + GhatL[15] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]-0.18633899812498247*fnodal_l[20]+0.18633899812498247*fnodal_l[18]-0.18633899812498247*fnodal_l[17]+0.18633899812498247*fnodal_l[15]+0.18633899812498247*fnodal_l[14]-0.18633899812498247*fnodal_l[12]-0.18633899812498247*fnodal_l[11]+0.18633899812498247*fnodal_l[9]+0.18633899812498247*fnodal_l[8]-0.18633899812498247*fnodal_l[6]+0.18633899812498247*fnodal_l[5]-0.18633899812498247*fnodal_l[3]-0.18633899812498247*fnodal_l[2]+0.18633899812498247*fnodal_l[0]; + GhatL[16] = 0.12422599874998831*fnodal_l[23]-0.24845199749997662*fnodal_l[22]+0.12422599874998831*fnodal_l[21]+0.12422599874998831*fnodal_l[20]-0.24845199749997662*fnodal_l[19]+0.12422599874998831*fnodal_l[18]+0.12422599874998831*fnodal_l[17]-0.24845199749997662*fnodal_l[16]+0.12422599874998831*fnodal_l[15]+0.12422599874998831*fnodal_l[14]-0.24845199749997662*fnodal_l[13]+0.12422599874998831*fnodal_l[12]+0.12422599874998831*fnodal_l[11]-0.24845199749997662*fnodal_l[10]+0.12422599874998831*fnodal_l[9]+0.12422599874998831*fnodal_l[8]-0.24845199749997662*fnodal_l[7]+0.12422599874998831*fnodal_l[6]+0.12422599874998831*fnodal_l[5]-0.24845199749997662*fnodal_l[4]+0.12422599874998831*fnodal_l[3]+0.12422599874998831*fnodal_l[2]-0.24845199749997662*fnodal_l[1]+0.12422599874998831*fnodal_l[0]; + GhatL[17] = 0.12422599874998837*fnodal_l[23]-0.24845199749997673*fnodal_l[22]+0.12422599874998837*fnodal_l[21]+0.12422599874998837*fnodal_l[20]-0.24845199749997673*fnodal_l[19]+0.12422599874998837*fnodal_l[18]+0.12422599874998837*fnodal_l[17]-0.24845199749997673*fnodal_l[16]+0.12422599874998837*fnodal_l[15]+0.12422599874998837*fnodal_l[14]-0.24845199749997673*fnodal_l[13]+0.12422599874998837*fnodal_l[12]-0.12422599874998837*fnodal_l[11]+0.24845199749997673*fnodal_l[10]-0.12422599874998837*fnodal_l[9]-0.12422599874998837*fnodal_l[8]+0.24845199749997673*fnodal_l[7]-0.12422599874998837*fnodal_l[6]-0.12422599874998837*fnodal_l[5]+0.24845199749997673*fnodal_l[4]-0.12422599874998837*fnodal_l[3]-0.12422599874998837*fnodal_l[2]+0.24845199749997673*fnodal_l[1]-0.12422599874998837*fnodal_l[0]; + GhatL[18] = 0.12422599874998837*fnodal_l[23]-0.24845199749997673*fnodal_l[22]+0.12422599874998837*fnodal_l[21]+0.12422599874998837*fnodal_l[20]-0.24845199749997673*fnodal_l[19]+0.12422599874998837*fnodal_l[18]-0.12422599874998837*fnodal_l[17]+0.24845199749997673*fnodal_l[16]-0.12422599874998837*fnodal_l[15]-0.12422599874998837*fnodal_l[14]+0.24845199749997673*fnodal_l[13]-0.12422599874998837*fnodal_l[12]+0.12422599874998837*fnodal_l[11]-0.24845199749997673*fnodal_l[10]+0.12422599874998837*fnodal_l[9]+0.12422599874998837*fnodal_l[8]-0.24845199749997673*fnodal_l[7]+0.12422599874998837*fnodal_l[6]-0.12422599874998837*fnodal_l[5]+0.24845199749997673*fnodal_l[4]-0.12422599874998837*fnodal_l[3]-0.12422599874998837*fnodal_l[2]+0.24845199749997673*fnodal_l[1]-0.12422599874998837*fnodal_l[0]; + GhatL[19] = 0.12422599874998837*fnodal_l[23]-0.24845199749997673*fnodal_l[22]+0.12422599874998837*fnodal_l[21]-0.12422599874998837*fnodal_l[20]+0.24845199749997673*fnodal_l[19]-0.12422599874998837*fnodal_l[18]+0.12422599874998837*fnodal_l[17]-0.24845199749997673*fnodal_l[16]+0.12422599874998837*fnodal_l[15]-0.12422599874998837*fnodal_l[14]+0.24845199749997673*fnodal_l[13]-0.12422599874998837*fnodal_l[12]+0.12422599874998837*fnodal_l[11]-0.24845199749997673*fnodal_l[10]+0.12422599874998837*fnodal_l[9]-0.12422599874998837*fnodal_l[8]+0.24845199749997673*fnodal_l[7]-0.12422599874998837*fnodal_l[6]+0.12422599874998837*fnodal_l[5]-0.24845199749997673*fnodal_l[4]+0.12422599874998837*fnodal_l[3]-0.12422599874998837*fnodal_l[2]+0.24845199749997673*fnodal_l[1]-0.12422599874998837*fnodal_l[0]; + GhatL[20] = 0.12422599874998831*fnodal_l[23]-0.24845199749997662*fnodal_l[22]+0.12422599874998831*fnodal_l[21]+0.12422599874998831*fnodal_l[20]-0.24845199749997662*fnodal_l[19]+0.12422599874998831*fnodal_l[18]-0.12422599874998831*fnodal_l[17]+0.24845199749997662*fnodal_l[16]-0.12422599874998831*fnodal_l[15]-0.12422599874998831*fnodal_l[14]+0.24845199749997662*fnodal_l[13]-0.12422599874998831*fnodal_l[12]-0.12422599874998831*fnodal_l[11]+0.24845199749997662*fnodal_l[10]-0.12422599874998831*fnodal_l[9]-0.12422599874998831*fnodal_l[8]+0.24845199749997662*fnodal_l[7]-0.12422599874998831*fnodal_l[6]+0.12422599874998831*fnodal_l[5]-0.24845199749997662*fnodal_l[4]+0.12422599874998831*fnodal_l[3]+0.12422599874998831*fnodal_l[2]-0.24845199749997662*fnodal_l[1]+0.12422599874998831*fnodal_l[0]; + GhatL[21] = 0.12422599874998831*fnodal_l[23]-0.24845199749997662*fnodal_l[22]+0.12422599874998831*fnodal_l[21]-0.12422599874998831*fnodal_l[20]+0.24845199749997662*fnodal_l[19]-0.12422599874998831*fnodal_l[18]+0.12422599874998831*fnodal_l[17]-0.24845199749997662*fnodal_l[16]+0.12422599874998831*fnodal_l[15]-0.12422599874998831*fnodal_l[14]+0.24845199749997662*fnodal_l[13]-0.12422599874998831*fnodal_l[12]-0.12422599874998831*fnodal_l[11]+0.24845199749997662*fnodal_l[10]-0.12422599874998831*fnodal_l[9]+0.12422599874998831*fnodal_l[8]-0.24845199749997662*fnodal_l[7]+0.12422599874998831*fnodal_l[6]-0.12422599874998831*fnodal_l[5]+0.24845199749997662*fnodal_l[4]-0.12422599874998831*fnodal_l[3]+0.12422599874998831*fnodal_l[2]-0.24845199749997662*fnodal_l[1]+0.12422599874998831*fnodal_l[0]; + GhatL[22] = 0.12422599874998831*fnodal_l[23]-0.24845199749997662*fnodal_l[22]+0.12422599874998831*fnodal_l[21]-0.12422599874998831*fnodal_l[20]+0.24845199749997662*fnodal_l[19]-0.12422599874998831*fnodal_l[18]-0.12422599874998831*fnodal_l[17]+0.24845199749997662*fnodal_l[16]-0.12422599874998831*fnodal_l[15]+0.12422599874998831*fnodal_l[14]-0.24845199749997662*fnodal_l[13]+0.12422599874998831*fnodal_l[12]+0.12422599874998831*fnodal_l[11]-0.24845199749997662*fnodal_l[10]+0.12422599874998831*fnodal_l[9]-0.12422599874998831*fnodal_l[8]+0.24845199749997662*fnodal_l[7]-0.12422599874998831*fnodal_l[6]-0.12422599874998831*fnodal_l[5]+0.24845199749997662*fnodal_l[4]-0.12422599874998831*fnodal_l[3]+0.12422599874998831*fnodal_l[2]-0.24845199749997662*fnodal_l[1]+0.12422599874998831*fnodal_l[0]; + GhatL[23] = 0.12422599874998837*fnodal_l[23]-0.24845199749997673*fnodal_l[22]+0.12422599874998837*fnodal_l[21]-0.12422599874998837*fnodal_l[20]+0.24845199749997673*fnodal_l[19]-0.12422599874998837*fnodal_l[18]-0.12422599874998837*fnodal_l[17]+0.24845199749997673*fnodal_l[16]-0.12422599874998837*fnodal_l[15]+0.12422599874998837*fnodal_l[14]-0.24845199749997673*fnodal_l[13]+0.12422599874998837*fnodal_l[12]-0.12422599874998837*fnodal_l[11]+0.24845199749997673*fnodal_l[10]-0.12422599874998837*fnodal_l[9]+0.12422599874998837*fnodal_l[8]-0.24845199749997673*fnodal_l[7]+0.12422599874998837*fnodal_l[6]+0.12422599874998837*fnodal_l[5]-0.24845199749997673*fnodal_l[4]+0.12422599874998837*fnodal_l[3]-0.12422599874998837*fnodal_l[2]+0.24845199749997673*fnodal_l[1]-0.12422599874998837*fnodal_l[0]; + GhatR[0] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]+0.1388888888888889*fnodal_r[20]+0.2222222222222222*fnodal_r[19]+0.1388888888888889*fnodal_r[18]+0.1388888888888889*fnodal_r[17]+0.2222222222222222*fnodal_r[16]+0.1388888888888889*fnodal_r[15]+0.1388888888888889*fnodal_r[14]+0.2222222222222222*fnodal_r[13]+0.1388888888888889*fnodal_r[12]+0.1388888888888889*fnodal_r[11]+0.2222222222222222*fnodal_r[10]+0.1388888888888889*fnodal_r[9]+0.1388888888888889*fnodal_r[8]+0.2222222222222222*fnodal_r[7]+0.1388888888888889*fnodal_r[6]+0.1388888888888889*fnodal_r[5]+0.2222222222222222*fnodal_r[4]+0.1388888888888889*fnodal_r[3]+0.1388888888888889*fnodal_r[2]+0.2222222222222222*fnodal_r[1]+0.1388888888888889*fnodal_r[0]; + GhatR[1] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]+0.1388888888888889*fnodal_r[20]+0.2222222222222222*fnodal_r[19]+0.1388888888888889*fnodal_r[18]+0.1388888888888889*fnodal_r[17]+0.2222222222222222*fnodal_r[16]+0.1388888888888889*fnodal_r[15]+0.1388888888888889*fnodal_r[14]+0.2222222222222222*fnodal_r[13]+0.1388888888888889*fnodal_r[12]-0.1388888888888889*fnodal_r[11]-0.2222222222222222*fnodal_r[10]-0.1388888888888889*fnodal_r[9]-0.1388888888888889*fnodal_r[8]-0.2222222222222222*fnodal_r[7]-0.1388888888888889*fnodal_r[6]-0.1388888888888889*fnodal_r[5]-0.2222222222222222*fnodal_r[4]-0.1388888888888889*fnodal_r[3]-0.1388888888888889*fnodal_r[2]-0.2222222222222222*fnodal_r[1]-0.1388888888888889*fnodal_r[0]; + GhatR[2] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]+0.1388888888888889*fnodal_r[20]+0.2222222222222222*fnodal_r[19]+0.1388888888888889*fnodal_r[18]-0.1388888888888889*fnodal_r[17]-0.2222222222222222*fnodal_r[16]-0.1388888888888889*fnodal_r[15]-0.1388888888888889*fnodal_r[14]-0.2222222222222222*fnodal_r[13]-0.1388888888888889*fnodal_r[12]+0.1388888888888889*fnodal_r[11]+0.2222222222222222*fnodal_r[10]+0.1388888888888889*fnodal_r[9]+0.1388888888888889*fnodal_r[8]+0.2222222222222222*fnodal_r[7]+0.1388888888888889*fnodal_r[6]-0.1388888888888889*fnodal_r[5]-0.2222222222222222*fnodal_r[4]-0.1388888888888889*fnodal_r[3]-0.1388888888888889*fnodal_r[2]-0.2222222222222222*fnodal_r[1]-0.1388888888888889*fnodal_r[0]; + GhatR[3] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]+0.18633899812498247*fnodal_r[20]-0.18633899812498247*fnodal_r[18]+0.18633899812498247*fnodal_r[17]-0.18633899812498247*fnodal_r[15]+0.18633899812498247*fnodal_r[14]-0.18633899812498247*fnodal_r[12]+0.18633899812498247*fnodal_r[11]-0.18633899812498247*fnodal_r[9]+0.18633899812498247*fnodal_r[8]-0.18633899812498247*fnodal_r[6]+0.18633899812498247*fnodal_r[5]-0.18633899812498247*fnodal_r[3]+0.18633899812498247*fnodal_r[2]-0.18633899812498247*fnodal_r[0]; + GhatR[4] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]-0.1388888888888889*fnodal_r[20]-0.2222222222222222*fnodal_r[19]-0.1388888888888889*fnodal_r[18]+0.1388888888888889*fnodal_r[17]+0.2222222222222222*fnodal_r[16]+0.1388888888888889*fnodal_r[15]-0.1388888888888889*fnodal_r[14]-0.2222222222222222*fnodal_r[13]-0.1388888888888889*fnodal_r[12]+0.1388888888888889*fnodal_r[11]+0.2222222222222222*fnodal_r[10]+0.1388888888888889*fnodal_r[9]-0.1388888888888889*fnodal_r[8]-0.2222222222222222*fnodal_r[7]-0.1388888888888889*fnodal_r[6]+0.1388888888888889*fnodal_r[5]+0.2222222222222222*fnodal_r[4]+0.1388888888888889*fnodal_r[3]-0.1388888888888889*fnodal_r[2]-0.2222222222222222*fnodal_r[1]-0.1388888888888889*fnodal_r[0]; + GhatR[5] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]+0.1388888888888889*fnodal_r[20]+0.2222222222222222*fnodal_r[19]+0.1388888888888889*fnodal_r[18]-0.1388888888888889*fnodal_r[17]-0.2222222222222222*fnodal_r[16]-0.1388888888888889*fnodal_r[15]-0.1388888888888889*fnodal_r[14]-0.2222222222222222*fnodal_r[13]-0.1388888888888889*fnodal_r[12]-0.1388888888888889*fnodal_r[11]-0.2222222222222222*fnodal_r[10]-0.1388888888888889*fnodal_r[9]-0.1388888888888889*fnodal_r[8]-0.2222222222222222*fnodal_r[7]-0.1388888888888889*fnodal_r[6]+0.1388888888888889*fnodal_r[5]+0.2222222222222222*fnodal_r[4]+0.1388888888888889*fnodal_r[3]+0.1388888888888889*fnodal_r[2]+0.2222222222222222*fnodal_r[1]+0.1388888888888889*fnodal_r[0]; + GhatR[6] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]+0.18633899812498247*fnodal_r[20]-0.18633899812498247*fnodal_r[18]+0.18633899812498247*fnodal_r[17]-0.18633899812498247*fnodal_r[15]+0.18633899812498247*fnodal_r[14]-0.18633899812498247*fnodal_r[12]-0.18633899812498247*fnodal_r[11]+0.18633899812498247*fnodal_r[9]-0.18633899812498247*fnodal_r[8]+0.18633899812498247*fnodal_r[6]-0.18633899812498247*fnodal_r[5]+0.18633899812498247*fnodal_r[3]-0.18633899812498247*fnodal_r[2]+0.18633899812498247*fnodal_r[0]; + GhatR[7] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]+0.18633899812498247*fnodal_r[20]-0.18633899812498247*fnodal_r[18]-0.18633899812498247*fnodal_r[17]+0.18633899812498247*fnodal_r[15]-0.18633899812498247*fnodal_r[14]+0.18633899812498247*fnodal_r[12]+0.18633899812498247*fnodal_r[11]-0.18633899812498247*fnodal_r[9]+0.18633899812498247*fnodal_r[8]-0.18633899812498247*fnodal_r[6]-0.18633899812498247*fnodal_r[5]+0.18633899812498247*fnodal_r[3]-0.18633899812498247*fnodal_r[2]+0.18633899812498247*fnodal_r[0]; + GhatR[8] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]-0.1388888888888889*fnodal_r[20]-0.2222222222222222*fnodal_r[19]-0.1388888888888889*fnodal_r[18]+0.1388888888888889*fnodal_r[17]+0.2222222222222222*fnodal_r[16]+0.1388888888888889*fnodal_r[15]-0.1388888888888889*fnodal_r[14]-0.2222222222222222*fnodal_r[13]-0.1388888888888889*fnodal_r[12]-0.1388888888888889*fnodal_r[11]-0.2222222222222222*fnodal_r[10]-0.1388888888888889*fnodal_r[9]+0.1388888888888889*fnodal_r[8]+0.2222222222222222*fnodal_r[7]+0.1388888888888889*fnodal_r[6]-0.1388888888888889*fnodal_r[5]-0.2222222222222222*fnodal_r[4]-0.1388888888888889*fnodal_r[3]+0.1388888888888889*fnodal_r[2]+0.2222222222222222*fnodal_r[1]+0.1388888888888889*fnodal_r[0]; + GhatR[9] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]-0.1388888888888889*fnodal_r[20]-0.2222222222222222*fnodal_r[19]-0.1388888888888889*fnodal_r[18]-0.1388888888888889*fnodal_r[17]-0.2222222222222222*fnodal_r[16]-0.1388888888888889*fnodal_r[15]+0.1388888888888889*fnodal_r[14]+0.2222222222222222*fnodal_r[13]+0.1388888888888889*fnodal_r[12]+0.1388888888888889*fnodal_r[11]+0.2222222222222222*fnodal_r[10]+0.1388888888888889*fnodal_r[9]-0.1388888888888889*fnodal_r[8]-0.2222222222222222*fnodal_r[7]-0.1388888888888889*fnodal_r[6]-0.1388888888888889*fnodal_r[5]-0.2222222222222222*fnodal_r[4]-0.1388888888888889*fnodal_r[3]+0.1388888888888889*fnodal_r[2]+0.2222222222222222*fnodal_r[1]+0.1388888888888889*fnodal_r[0]; + GhatR[10] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]-0.18633899812498247*fnodal_r[20]+0.18633899812498247*fnodal_r[18]+0.18633899812498247*fnodal_r[17]-0.18633899812498247*fnodal_r[15]-0.18633899812498247*fnodal_r[14]+0.18633899812498247*fnodal_r[12]+0.18633899812498247*fnodal_r[11]-0.18633899812498247*fnodal_r[9]-0.18633899812498247*fnodal_r[8]+0.18633899812498247*fnodal_r[6]+0.18633899812498247*fnodal_r[5]-0.18633899812498247*fnodal_r[3]-0.18633899812498247*fnodal_r[2]+0.18633899812498247*fnodal_r[0]; + GhatR[11] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]+0.18633899812498247*fnodal_r[20]-0.18633899812498247*fnodal_r[18]-0.18633899812498247*fnodal_r[17]+0.18633899812498247*fnodal_r[15]-0.18633899812498247*fnodal_r[14]+0.18633899812498247*fnodal_r[12]-0.18633899812498247*fnodal_r[11]+0.18633899812498247*fnodal_r[9]-0.18633899812498247*fnodal_r[8]+0.18633899812498247*fnodal_r[6]+0.18633899812498247*fnodal_r[5]-0.18633899812498247*fnodal_r[3]+0.18633899812498247*fnodal_r[2]-0.18633899812498247*fnodal_r[0]; + GhatR[12] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]-0.1388888888888889*fnodal_r[20]-0.2222222222222222*fnodal_r[19]-0.1388888888888889*fnodal_r[18]-0.1388888888888889*fnodal_r[17]-0.2222222222222222*fnodal_r[16]-0.1388888888888889*fnodal_r[15]+0.1388888888888889*fnodal_r[14]+0.2222222222222222*fnodal_r[13]+0.1388888888888889*fnodal_r[12]-0.1388888888888889*fnodal_r[11]-0.2222222222222222*fnodal_r[10]-0.1388888888888889*fnodal_r[9]+0.1388888888888889*fnodal_r[8]+0.2222222222222222*fnodal_r[7]+0.1388888888888889*fnodal_r[6]+0.1388888888888889*fnodal_r[5]+0.2222222222222222*fnodal_r[4]+0.1388888888888889*fnodal_r[3]-0.1388888888888889*fnodal_r[2]-0.2222222222222222*fnodal_r[1]-0.1388888888888889*fnodal_r[0]; + GhatR[13] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]-0.18633899812498247*fnodal_r[20]+0.18633899812498247*fnodal_r[18]+0.18633899812498247*fnodal_r[17]-0.18633899812498247*fnodal_r[15]-0.18633899812498247*fnodal_r[14]+0.18633899812498247*fnodal_r[12]-0.18633899812498247*fnodal_r[11]+0.18633899812498247*fnodal_r[9]+0.18633899812498247*fnodal_r[8]-0.18633899812498247*fnodal_r[6]-0.18633899812498247*fnodal_r[5]+0.18633899812498247*fnodal_r[3]+0.18633899812498247*fnodal_r[2]-0.18633899812498247*fnodal_r[0]; + GhatR[14] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]-0.18633899812498247*fnodal_r[20]+0.18633899812498247*fnodal_r[18]-0.18633899812498247*fnodal_r[17]+0.18633899812498247*fnodal_r[15]+0.18633899812498247*fnodal_r[14]-0.18633899812498247*fnodal_r[12]+0.18633899812498247*fnodal_r[11]-0.18633899812498247*fnodal_r[9]-0.18633899812498247*fnodal_r[8]+0.18633899812498247*fnodal_r[6]-0.18633899812498247*fnodal_r[5]+0.18633899812498247*fnodal_r[3]+0.18633899812498247*fnodal_r[2]-0.18633899812498247*fnodal_r[0]; + GhatR[15] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]-0.18633899812498247*fnodal_r[20]+0.18633899812498247*fnodal_r[18]-0.18633899812498247*fnodal_r[17]+0.18633899812498247*fnodal_r[15]+0.18633899812498247*fnodal_r[14]-0.18633899812498247*fnodal_r[12]-0.18633899812498247*fnodal_r[11]+0.18633899812498247*fnodal_r[9]+0.18633899812498247*fnodal_r[8]-0.18633899812498247*fnodal_r[6]+0.18633899812498247*fnodal_r[5]-0.18633899812498247*fnodal_r[3]-0.18633899812498247*fnodal_r[2]+0.18633899812498247*fnodal_r[0]; + GhatR[16] = 0.12422599874998831*fnodal_r[23]-0.24845199749997662*fnodal_r[22]+0.12422599874998831*fnodal_r[21]+0.12422599874998831*fnodal_r[20]-0.24845199749997662*fnodal_r[19]+0.12422599874998831*fnodal_r[18]+0.12422599874998831*fnodal_r[17]-0.24845199749997662*fnodal_r[16]+0.12422599874998831*fnodal_r[15]+0.12422599874998831*fnodal_r[14]-0.24845199749997662*fnodal_r[13]+0.12422599874998831*fnodal_r[12]+0.12422599874998831*fnodal_r[11]-0.24845199749997662*fnodal_r[10]+0.12422599874998831*fnodal_r[9]+0.12422599874998831*fnodal_r[8]-0.24845199749997662*fnodal_r[7]+0.12422599874998831*fnodal_r[6]+0.12422599874998831*fnodal_r[5]-0.24845199749997662*fnodal_r[4]+0.12422599874998831*fnodal_r[3]+0.12422599874998831*fnodal_r[2]-0.24845199749997662*fnodal_r[1]+0.12422599874998831*fnodal_r[0]; + GhatR[17] = 0.12422599874998837*fnodal_r[23]-0.24845199749997673*fnodal_r[22]+0.12422599874998837*fnodal_r[21]+0.12422599874998837*fnodal_r[20]-0.24845199749997673*fnodal_r[19]+0.12422599874998837*fnodal_r[18]+0.12422599874998837*fnodal_r[17]-0.24845199749997673*fnodal_r[16]+0.12422599874998837*fnodal_r[15]+0.12422599874998837*fnodal_r[14]-0.24845199749997673*fnodal_r[13]+0.12422599874998837*fnodal_r[12]-0.12422599874998837*fnodal_r[11]+0.24845199749997673*fnodal_r[10]-0.12422599874998837*fnodal_r[9]-0.12422599874998837*fnodal_r[8]+0.24845199749997673*fnodal_r[7]-0.12422599874998837*fnodal_r[6]-0.12422599874998837*fnodal_r[5]+0.24845199749997673*fnodal_r[4]-0.12422599874998837*fnodal_r[3]-0.12422599874998837*fnodal_r[2]+0.24845199749997673*fnodal_r[1]-0.12422599874998837*fnodal_r[0]; + GhatR[18] = 0.12422599874998837*fnodal_r[23]-0.24845199749997673*fnodal_r[22]+0.12422599874998837*fnodal_r[21]+0.12422599874998837*fnodal_r[20]-0.24845199749997673*fnodal_r[19]+0.12422599874998837*fnodal_r[18]-0.12422599874998837*fnodal_r[17]+0.24845199749997673*fnodal_r[16]-0.12422599874998837*fnodal_r[15]-0.12422599874998837*fnodal_r[14]+0.24845199749997673*fnodal_r[13]-0.12422599874998837*fnodal_r[12]+0.12422599874998837*fnodal_r[11]-0.24845199749997673*fnodal_r[10]+0.12422599874998837*fnodal_r[9]+0.12422599874998837*fnodal_r[8]-0.24845199749997673*fnodal_r[7]+0.12422599874998837*fnodal_r[6]-0.12422599874998837*fnodal_r[5]+0.24845199749997673*fnodal_r[4]-0.12422599874998837*fnodal_r[3]-0.12422599874998837*fnodal_r[2]+0.24845199749997673*fnodal_r[1]-0.12422599874998837*fnodal_r[0]; + GhatR[19] = 0.12422599874998837*fnodal_r[23]-0.24845199749997673*fnodal_r[22]+0.12422599874998837*fnodal_r[21]-0.12422599874998837*fnodal_r[20]+0.24845199749997673*fnodal_r[19]-0.12422599874998837*fnodal_r[18]+0.12422599874998837*fnodal_r[17]-0.24845199749997673*fnodal_r[16]+0.12422599874998837*fnodal_r[15]-0.12422599874998837*fnodal_r[14]+0.24845199749997673*fnodal_r[13]-0.12422599874998837*fnodal_r[12]+0.12422599874998837*fnodal_r[11]-0.24845199749997673*fnodal_r[10]+0.12422599874998837*fnodal_r[9]-0.12422599874998837*fnodal_r[8]+0.24845199749997673*fnodal_r[7]-0.12422599874998837*fnodal_r[6]+0.12422599874998837*fnodal_r[5]-0.24845199749997673*fnodal_r[4]+0.12422599874998837*fnodal_r[3]-0.12422599874998837*fnodal_r[2]+0.24845199749997673*fnodal_r[1]-0.12422599874998837*fnodal_r[0]; + GhatR[20] = 0.12422599874998831*fnodal_r[23]-0.24845199749997662*fnodal_r[22]+0.12422599874998831*fnodal_r[21]+0.12422599874998831*fnodal_r[20]-0.24845199749997662*fnodal_r[19]+0.12422599874998831*fnodal_r[18]-0.12422599874998831*fnodal_r[17]+0.24845199749997662*fnodal_r[16]-0.12422599874998831*fnodal_r[15]-0.12422599874998831*fnodal_r[14]+0.24845199749997662*fnodal_r[13]-0.12422599874998831*fnodal_r[12]-0.12422599874998831*fnodal_r[11]+0.24845199749997662*fnodal_r[10]-0.12422599874998831*fnodal_r[9]-0.12422599874998831*fnodal_r[8]+0.24845199749997662*fnodal_r[7]-0.12422599874998831*fnodal_r[6]+0.12422599874998831*fnodal_r[5]-0.24845199749997662*fnodal_r[4]+0.12422599874998831*fnodal_r[3]+0.12422599874998831*fnodal_r[2]-0.24845199749997662*fnodal_r[1]+0.12422599874998831*fnodal_r[0]; + GhatR[21] = 0.12422599874998831*fnodal_r[23]-0.24845199749997662*fnodal_r[22]+0.12422599874998831*fnodal_r[21]-0.12422599874998831*fnodal_r[20]+0.24845199749997662*fnodal_r[19]-0.12422599874998831*fnodal_r[18]+0.12422599874998831*fnodal_r[17]-0.24845199749997662*fnodal_r[16]+0.12422599874998831*fnodal_r[15]-0.12422599874998831*fnodal_r[14]+0.24845199749997662*fnodal_r[13]-0.12422599874998831*fnodal_r[12]-0.12422599874998831*fnodal_r[11]+0.24845199749997662*fnodal_r[10]-0.12422599874998831*fnodal_r[9]+0.12422599874998831*fnodal_r[8]-0.24845199749997662*fnodal_r[7]+0.12422599874998831*fnodal_r[6]-0.12422599874998831*fnodal_r[5]+0.24845199749997662*fnodal_r[4]-0.12422599874998831*fnodal_r[3]+0.12422599874998831*fnodal_r[2]-0.24845199749997662*fnodal_r[1]+0.12422599874998831*fnodal_r[0]; + GhatR[22] = 0.12422599874998831*fnodal_r[23]-0.24845199749997662*fnodal_r[22]+0.12422599874998831*fnodal_r[21]-0.12422599874998831*fnodal_r[20]+0.24845199749997662*fnodal_r[19]-0.12422599874998831*fnodal_r[18]-0.12422599874998831*fnodal_r[17]+0.24845199749997662*fnodal_r[16]-0.12422599874998831*fnodal_r[15]+0.12422599874998831*fnodal_r[14]-0.24845199749997662*fnodal_r[13]+0.12422599874998831*fnodal_r[12]+0.12422599874998831*fnodal_r[11]-0.24845199749997662*fnodal_r[10]+0.12422599874998831*fnodal_r[9]-0.12422599874998831*fnodal_r[8]+0.24845199749997662*fnodal_r[7]-0.12422599874998831*fnodal_r[6]-0.12422599874998831*fnodal_r[5]+0.24845199749997662*fnodal_r[4]-0.12422599874998831*fnodal_r[3]+0.12422599874998831*fnodal_r[2]-0.24845199749997662*fnodal_r[1]+0.12422599874998831*fnodal_r[0]; + GhatR[23] = 0.12422599874998837*fnodal_r[23]-0.24845199749997673*fnodal_r[22]+0.12422599874998837*fnodal_r[21]-0.12422599874998837*fnodal_r[20]+0.24845199749997673*fnodal_r[19]-0.12422599874998837*fnodal_r[18]-0.12422599874998837*fnodal_r[17]+0.24845199749997673*fnodal_r[16]-0.12422599874998837*fnodal_r[15]+0.12422599874998837*fnodal_r[14]-0.24845199749997673*fnodal_r[13]+0.12422599874998837*fnodal_r[12]-0.12422599874998837*fnodal_r[11]+0.24845199749997673*fnodal_r[10]-0.12422599874998837*fnodal_r[9]+0.12422599874998837*fnodal_r[8]-0.24845199749997673*fnodal_r[7]+0.12422599874998837*fnodal_r[6]+0.12422599874998837*fnodal_r[5]-0.24845199749997673*fnodal_r[4]+0.12422599874998837*fnodal_r[3]-0.12422599874998837*fnodal_r[2]+0.24845199749997673*fnodal_r[1]-0.12422599874998837*fnodal_r[0]; + + if (edge == -1) { + + out[0] += -(0.7071067811865475*GhatR[0]*rdz2); + out[1] += -(0.7071067811865475*GhatR[1]*rdz2); + out[2] += -(0.7071067811865475*GhatR[2]*rdz2); + out[3] += -(1.224744871391589*GhatR[0]*rdz2); + out[4] += -(0.7071067811865475*GhatR[3]*rdz2); + out[5] += -(0.7071067811865475*GhatR[4]*rdz2); + out[6] += -(0.7071067811865475*GhatR[5]*rdz2); + out[7] += -(1.224744871391589*GhatR[1]*rdz2); + out[8] += -(1.224744871391589*GhatR[2]*rdz2); + out[9] += -(0.7071067811865475*GhatR[6]*rdz2); + out[10] += -(0.7071067811865475*GhatR[7]*rdz2); + out[11] += -(1.224744871391589*GhatR[3]*rdz2); + out[12] += -(0.7071067811865475*GhatR[8]*rdz2); + out[13] += -(0.7071067811865475*GhatR[9]*rdz2); + out[14] += -(1.224744871391589*GhatR[4]*rdz2); + out[15] += -(0.7071067811865475*GhatR[10]*rdz2); + out[16] += -(1.224744871391589*GhatR[5]*rdz2); + out[17] += -(0.7071067811865475*GhatR[11]*rdz2); + out[18] += -(1.224744871391589*GhatR[6]*rdz2); + out[19] += -(1.224744871391589*GhatR[7]*rdz2); + out[20] += -(0.7071067811865475*GhatR[12]*rdz2); + out[21] += -(1.224744871391589*GhatR[8]*rdz2); + out[22] += -(1.224744871391589*GhatR[9]*rdz2); + out[23] += -(0.7071067811865475*GhatR[13]*rdz2); + out[24] += -(0.7071067811865475*GhatR[14]*rdz2); + out[25] += -(1.224744871391589*GhatR[10]*rdz2); + out[26] += -(1.224744871391589*GhatR[11]*rdz2); + out[27] += -(1.224744871391589*GhatR[12]*rdz2); + out[28] += -(0.7071067811865475*GhatR[15]*rdz2); + out[29] += -(1.224744871391589*GhatR[13]*rdz2); + out[30] += -(1.224744871391589*GhatR[14]*rdz2); + out[31] += -(1.224744871391589*GhatR[15]*rdz2); + out[32] += -(0.7071067811865475*GhatR[16]*rdz2); + out[33] += -(0.7071067811865475*GhatR[17]*rdz2); + out[34] += -(0.7071067811865475*GhatR[18]*rdz2); + out[35] += -(1.224744871391589*GhatR[16]*rdz2); + out[36] += -(0.7071067811865475*GhatR[19]*rdz2); + out[37] += -(0.7071067811865475*GhatR[20]*rdz2); + out[38] += -(1.224744871391589*GhatR[17]*rdz2); + out[39] += -(1.224744871391589*GhatR[18]*rdz2); + out[40] += -(0.7071067811865475*GhatR[21]*rdz2); + out[41] += -(0.7071067811865475*GhatR[22]*rdz2); + out[42] += -(1.224744871391589*GhatR[19]*rdz2); + out[43] += -(1.224744871391589*GhatR[20]*rdz2); + out[44] += -(0.7071067811865475*GhatR[23]*rdz2); + out[45] += -(1.224744871391589*GhatR[21]*rdz2); + out[46] += -(1.224744871391589*GhatR[22]*rdz2); + out[47] += -(1.224744871391589*GhatR[23]*rdz2); + + } else { + + out[0] += 0.7071067811865475*GhatL[0]*rdz2; + out[1] += 0.7071067811865475*GhatL[1]*rdz2; + out[2] += 0.7071067811865475*GhatL[2]*rdz2; + out[3] += -(1.224744871391589*GhatL[0]*rdz2); + out[4] += 0.7071067811865475*GhatL[3]*rdz2; + out[5] += 0.7071067811865475*GhatL[4]*rdz2; + out[6] += 0.7071067811865475*GhatL[5]*rdz2; + out[7] += -(1.224744871391589*GhatL[1]*rdz2); + out[8] += -(1.224744871391589*GhatL[2]*rdz2); + out[9] += 0.7071067811865475*GhatL[6]*rdz2; + out[10] += 0.7071067811865475*GhatL[7]*rdz2; + out[11] += -(1.224744871391589*GhatL[3]*rdz2); + out[12] += 0.7071067811865475*GhatL[8]*rdz2; + out[13] += 0.7071067811865475*GhatL[9]*rdz2; + out[14] += -(1.224744871391589*GhatL[4]*rdz2); + out[15] += 0.7071067811865475*GhatL[10]*rdz2; + out[16] += -(1.224744871391589*GhatL[5]*rdz2); + out[17] += 0.7071067811865475*GhatL[11]*rdz2; + out[18] += -(1.224744871391589*GhatL[6]*rdz2); + out[19] += -(1.224744871391589*GhatL[7]*rdz2); + out[20] += 0.7071067811865475*GhatL[12]*rdz2; + out[21] += -(1.224744871391589*GhatL[8]*rdz2); + out[22] += -(1.224744871391589*GhatL[9]*rdz2); + out[23] += 0.7071067811865475*GhatL[13]*rdz2; + out[24] += 0.7071067811865475*GhatL[14]*rdz2; + out[25] += -(1.224744871391589*GhatL[10]*rdz2); + out[26] += -(1.224744871391589*GhatL[11]*rdz2); + out[27] += -(1.224744871391589*GhatL[12]*rdz2); + out[28] += 0.7071067811865475*GhatL[15]*rdz2; + out[29] += -(1.224744871391589*GhatL[13]*rdz2); + out[30] += -(1.224744871391589*GhatL[14]*rdz2); + out[31] += -(1.224744871391589*GhatL[15]*rdz2); + out[32] += 0.7071067811865475*GhatL[16]*rdz2; + out[33] += 0.7071067811865475*GhatL[17]*rdz2; + out[34] += 0.7071067811865475*GhatL[18]*rdz2; + out[35] += -(1.224744871391589*GhatL[16]*rdz2); + out[36] += 0.7071067811865475*GhatL[19]*rdz2; + out[37] += 0.7071067811865475*GhatL[20]*rdz2; + out[38] += -(1.224744871391589*GhatL[17]*rdz2); + out[39] += -(1.224744871391589*GhatL[18]*rdz2); + out[40] += 0.7071067811865475*GhatL[21]*rdz2; + out[41] += 0.7071067811865475*GhatL[22]*rdz2; + out[42] += -(1.224744871391589*GhatL[19]*rdz2); + out[43] += -(1.224744871391589*GhatL[20]*rdz2); + out[44] += 0.7071067811865475*GhatL[23]*rdz2; + out[45] += -(1.224744871391589*GhatL[21]*rdz2); + out[46] += -(1.224744871391589*GhatL[22]*rdz2); + out[47] += -(1.224744871391589*GhatL[23]*rdz2); + + } + + return 0.0; + +} diff --git a/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfx_1x1v_ser_p1.c b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfx_1x1v_ser_p1.c new file mode 100644 index 0000000000..4e500dae7c --- /dev/null +++ b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfx_1x1v_ser_p1.c @@ -0,0 +1,38 @@ +#include +#include +GKYL_CU_DH double dg_gyrokinetic_passive_surfx_1x1v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_l, const double *vmap_prime_c, const double *vmap_prime_r, + const double *flux_surf_l, const double *flux_surf_r, + double* GKYL_RESTRICT out) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap_prime_l,vmap_prime_c,vmap_prime_r: velocity space mapping derivative in left, center and right cells. + // flux_surf_l: Surface expansion of phase space flux on the left. + // flux_surf_r: Surface expansion of phase space flux on the right. + // out: output increment in center cell. + + double rdx2 = 2.0/dxv[0]; + + double GhatL[3]= {0.0}; + double GhatR[3]= {0.0}; + + const double *fnodal_l = &flux_surf_l[0]; + const double *fnodal_r = &flux_surf_r[0]; + GhatL[0] = 0.39283710065919303*fnodal_l[2]+0.6285393610547091*fnodal_l[1]+0.39283710065919303*fnodal_l[0]; + GhatL[1] = 0.5270462766947298*fnodal_l[2]-0.5270462766947298*fnodal_l[0]; + GhatL[2] = 0.35136418446315326*fnodal_l[2]-0.7027283689263066*fnodal_l[1]+0.35136418446315326*fnodal_l[0]; + GhatR[0] = 0.39283710065919303*fnodal_r[2]+0.6285393610547091*fnodal_r[1]+0.39283710065919303*fnodal_r[0]; + GhatR[1] = 0.5270462766947298*fnodal_r[2]-0.5270462766947298*fnodal_r[0]; + GhatR[2] = 0.35136418446315326*fnodal_r[2]-0.7027283689263066*fnodal_r[1]+0.35136418446315326*fnodal_r[0]; + + out[0] += (0.7071067811865475*GhatL[0]-0.7071067811865475*GhatR[0])*rdx2; + out[1] += (-(1.224744871391589*GhatR[0])-1.224744871391589*GhatL[0])*rdx2; + out[2] += (0.7071067811865475*GhatL[1]-0.7071067811865475*GhatR[1])*rdx2; + out[3] += (-(1.224744871391589*GhatR[1])-1.224744871391589*GhatL[1])*rdx2; + out[4] += (0.7071067811865475*GhatL[2]-0.7071067811865475*GhatR[2])*rdx2; + out[5] += (-(1.224744871391589*GhatR[2])-1.224744871391589*GhatL[2])*rdx2; + + return 0.0; + +} diff --git a/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfx_1x2v_ser_p1.c b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfx_1x2v_ser_p1.c new file mode 100644 index 0000000000..dbdde20e0c --- /dev/null +++ b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfx_1x2v_ser_p1.c @@ -0,0 +1,50 @@ +#include +#include +GKYL_CU_DH double dg_gyrokinetic_passive_surfx_1x2v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_l, const double *vmap_prime_c, const double *vmap_prime_r, + const double *flux_surf_l, const double *flux_surf_r, + double* GKYL_RESTRICT out) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap_prime_l,vmap_prime_c,vmap_prime_r: velocity space mapping derivative in left, center and right cells. + // flux_surf_l: Surface expansion of phase space flux on the left. + // flux_surf_r: Surface expansion of phase space flux on the right. + // out: output increment in center cell. + + double rdx2 = 2.0/dxv[0]; + + double GhatL[6]= {0.0}; + double GhatR[6]= {0.0}; + + const double *fnodal_l = &flux_surf_l[0]; + const double *fnodal_r = &flux_surf_r[0]; + GhatL[0] = 0.2777777777777778*fnodal_l[5]+0.4444444444444444*fnodal_l[4]+0.2777777777777778*fnodal_l[3]+0.2777777777777778*fnodal_l[2]+0.4444444444444444*fnodal_l[1]+0.2777777777777778*fnodal_l[0]; + GhatL[1] = 0.37267799624996495*fnodal_l[5]-0.37267799624996495*fnodal_l[3]+0.37267799624996495*fnodal_l[2]-0.37267799624996495*fnodal_l[0]; + GhatL[2] = 0.2777777777777778*fnodal_l[5]+0.4444444444444444*fnodal_l[4]+0.2777777777777778*fnodal_l[3]-0.2777777777777778*fnodal_l[2]-0.4444444444444444*fnodal_l[1]-0.2777777777777778*fnodal_l[0]; + GhatL[3] = 0.37267799624996495*fnodal_l[5]-0.37267799624996495*fnodal_l[3]-0.37267799624996495*fnodal_l[2]+0.37267799624996495*fnodal_l[0]; + GhatL[4] = 0.24845199749997662*fnodal_l[5]-0.49690399499995325*fnodal_l[4]+0.24845199749997662*fnodal_l[3]+0.24845199749997662*fnodal_l[2]-0.49690399499995325*fnodal_l[1]+0.24845199749997662*fnodal_l[0]; + GhatL[5] = 0.24845199749997673*fnodal_l[5]-0.49690399499995347*fnodal_l[4]+0.24845199749997673*fnodal_l[3]-0.24845199749997673*fnodal_l[2]+0.49690399499995347*fnodal_l[1]-0.24845199749997673*fnodal_l[0]; + GhatR[0] = 0.2777777777777778*fnodal_r[5]+0.4444444444444444*fnodal_r[4]+0.2777777777777778*fnodal_r[3]+0.2777777777777778*fnodal_r[2]+0.4444444444444444*fnodal_r[1]+0.2777777777777778*fnodal_r[0]; + GhatR[1] = 0.37267799624996495*fnodal_r[5]-0.37267799624996495*fnodal_r[3]+0.37267799624996495*fnodal_r[2]-0.37267799624996495*fnodal_r[0]; + GhatR[2] = 0.2777777777777778*fnodal_r[5]+0.4444444444444444*fnodal_r[4]+0.2777777777777778*fnodal_r[3]-0.2777777777777778*fnodal_r[2]-0.4444444444444444*fnodal_r[1]-0.2777777777777778*fnodal_r[0]; + GhatR[3] = 0.37267799624996495*fnodal_r[5]-0.37267799624996495*fnodal_r[3]-0.37267799624996495*fnodal_r[2]+0.37267799624996495*fnodal_r[0]; + GhatR[4] = 0.24845199749997662*fnodal_r[5]-0.49690399499995325*fnodal_r[4]+0.24845199749997662*fnodal_r[3]+0.24845199749997662*fnodal_r[2]-0.49690399499995325*fnodal_r[1]+0.24845199749997662*fnodal_r[0]; + GhatR[5] = 0.24845199749997673*fnodal_r[5]-0.49690399499995347*fnodal_r[4]+0.24845199749997673*fnodal_r[3]-0.24845199749997673*fnodal_r[2]+0.49690399499995347*fnodal_r[1]-0.24845199749997673*fnodal_r[0]; + + out[0] += (0.7071067811865475*GhatL[0]-0.7071067811865475*GhatR[0])*rdx2; + out[1] += (-(1.224744871391589*GhatR[0])-1.224744871391589*GhatL[0])*rdx2; + out[2] += (0.7071067811865475*GhatL[1]-0.7071067811865475*GhatR[1])*rdx2; + out[3] += (0.7071067811865475*GhatL[2]-0.7071067811865475*GhatR[2])*rdx2; + out[4] += (-(1.224744871391589*GhatR[1])-1.224744871391589*GhatL[1])*rdx2; + out[5] += (-(1.224744871391589*GhatR[2])-1.224744871391589*GhatL[2])*rdx2; + out[6] += (0.7071067811865475*GhatL[3]-0.7071067811865475*GhatR[3])*rdx2; + out[7] += (-(1.224744871391589*GhatR[3])-1.224744871391589*GhatL[3])*rdx2; + out[8] += (0.7071067811865475*GhatL[4]-0.7071067811865475*GhatR[4])*rdx2; + out[9] += (-(1.224744871391589*GhatR[4])-1.224744871391589*GhatL[4])*rdx2; + out[10] += (0.7071067811865475*GhatL[5]-0.7071067811865475*GhatR[5])*rdx2; + out[11] += (-(1.224744871391589*GhatR[5])-1.224744871391589*GhatL[5])*rdx2; + + return 0.0; + +} diff --git a/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfx_2x2v_ser_p1.c b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfx_2x2v_ser_p1.c new file mode 100644 index 0000000000..f6db300c2a --- /dev/null +++ b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfx_2x2v_ser_p1.c @@ -0,0 +1,74 @@ +#include +#include +GKYL_CU_DH double dg_gyrokinetic_passive_surfx_2x2v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_l, const double *vmap_prime_c, const double *vmap_prime_r, + const double *flux_surf_l, const double *flux_surf_r, + double* GKYL_RESTRICT out) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap_prime_l,vmap_prime_c,vmap_prime_r: velocity space mapping derivative in left, center and right cells. + // flux_surf_l: Surface expansion of phase space flux on the left. + // flux_surf_r: Surface expansion of phase space flux on the right. + // out: output increment in center cell. + + double rdx2 = 2.0/dxv[0]; + + double GhatL[12]= {0.0}; + double GhatR[12]= {0.0}; + + const double *fnodal_l = &flux_surf_l[0]; + const double *fnodal_r = &flux_surf_r[0]; + GhatL[0] = 0.1964185503295965*fnodal_l[11]+0.3142696805273545*fnodal_l[10]+0.1964185503295965*fnodal_l[9]+0.1964185503295965*fnodal_l[8]+0.3142696805273545*fnodal_l[7]+0.1964185503295965*fnodal_l[6]+0.1964185503295965*fnodal_l[5]+0.3142696805273545*fnodal_l[4]+0.1964185503295965*fnodal_l[3]+0.1964185503295965*fnodal_l[2]+0.3142696805273545*fnodal_l[1]+0.1964185503295965*fnodal_l[0]; + GhatL[1] = 0.1964185503295965*fnodal_l[11]+0.3142696805273545*fnodal_l[10]+0.1964185503295965*fnodal_l[9]+0.1964185503295965*fnodal_l[8]+0.3142696805273545*fnodal_l[7]+0.1964185503295965*fnodal_l[6]-0.1964185503295965*fnodal_l[5]-0.3142696805273545*fnodal_l[4]-0.1964185503295965*fnodal_l[3]-0.1964185503295965*fnodal_l[2]-0.3142696805273545*fnodal_l[1]-0.1964185503295965*fnodal_l[0]; + GhatL[2] = 0.2635231383473649*fnodal_l[11]-0.2635231383473649*fnodal_l[9]+0.2635231383473649*fnodal_l[8]-0.2635231383473649*fnodal_l[6]+0.2635231383473649*fnodal_l[5]-0.2635231383473649*fnodal_l[3]+0.2635231383473649*fnodal_l[2]-0.2635231383473649*fnodal_l[0]; + GhatL[3] = 0.1964185503295965*fnodal_l[11]+0.3142696805273545*fnodal_l[10]+0.1964185503295965*fnodal_l[9]-0.1964185503295965*fnodal_l[8]-0.3142696805273545*fnodal_l[7]-0.1964185503295965*fnodal_l[6]+0.1964185503295965*fnodal_l[5]+0.3142696805273545*fnodal_l[4]+0.1964185503295965*fnodal_l[3]-0.1964185503295965*fnodal_l[2]-0.3142696805273545*fnodal_l[1]-0.1964185503295965*fnodal_l[0]; + GhatL[4] = 0.2635231383473649*fnodal_l[11]-0.2635231383473649*fnodal_l[9]+0.2635231383473649*fnodal_l[8]-0.2635231383473649*fnodal_l[6]-0.2635231383473649*fnodal_l[5]+0.2635231383473649*fnodal_l[3]-0.2635231383473649*fnodal_l[2]+0.2635231383473649*fnodal_l[0]; + GhatL[5] = 0.1964185503295965*fnodal_l[11]+0.3142696805273545*fnodal_l[10]+0.1964185503295965*fnodal_l[9]-0.1964185503295965*fnodal_l[8]-0.3142696805273545*fnodal_l[7]-0.1964185503295965*fnodal_l[6]-0.1964185503295965*fnodal_l[5]-0.3142696805273545*fnodal_l[4]-0.1964185503295965*fnodal_l[3]+0.1964185503295965*fnodal_l[2]+0.3142696805273545*fnodal_l[1]+0.1964185503295965*fnodal_l[0]; + GhatL[6] = 0.2635231383473649*fnodal_l[11]-0.2635231383473649*fnodal_l[9]-0.2635231383473649*fnodal_l[8]+0.2635231383473649*fnodal_l[6]+0.2635231383473649*fnodal_l[5]-0.2635231383473649*fnodal_l[3]-0.2635231383473649*fnodal_l[2]+0.2635231383473649*fnodal_l[0]; + GhatL[7] = 0.2635231383473649*fnodal_l[11]-0.2635231383473649*fnodal_l[9]-0.2635231383473649*fnodal_l[8]+0.2635231383473649*fnodal_l[6]-0.2635231383473649*fnodal_l[5]+0.2635231383473649*fnodal_l[3]+0.2635231383473649*fnodal_l[2]-0.2635231383473649*fnodal_l[0]; + GhatL[8] = 0.17568209223157663*fnodal_l[11]-0.35136418446315326*fnodal_l[10]+0.17568209223157663*fnodal_l[9]+0.17568209223157663*fnodal_l[8]-0.35136418446315326*fnodal_l[7]+0.17568209223157663*fnodal_l[6]+0.17568209223157663*fnodal_l[5]-0.35136418446315326*fnodal_l[4]+0.17568209223157663*fnodal_l[3]+0.17568209223157663*fnodal_l[2]-0.35136418446315326*fnodal_l[1]+0.17568209223157663*fnodal_l[0]; + GhatL[9] = 0.1756820922315767*fnodal_l[11]-0.35136418446315343*fnodal_l[10]+0.1756820922315767*fnodal_l[9]+0.1756820922315767*fnodal_l[8]-0.35136418446315343*fnodal_l[7]+0.1756820922315767*fnodal_l[6]-0.1756820922315767*fnodal_l[5]+0.35136418446315343*fnodal_l[4]-0.1756820922315767*fnodal_l[3]-0.1756820922315767*fnodal_l[2]+0.35136418446315343*fnodal_l[1]-0.1756820922315767*fnodal_l[0]; + GhatL[10] = 0.1756820922315767*fnodal_l[11]-0.35136418446315343*fnodal_l[10]+0.1756820922315767*fnodal_l[9]-0.1756820922315767*fnodal_l[8]+0.35136418446315343*fnodal_l[7]-0.1756820922315767*fnodal_l[6]+0.1756820922315767*fnodal_l[5]-0.35136418446315343*fnodal_l[4]+0.1756820922315767*fnodal_l[3]-0.1756820922315767*fnodal_l[2]+0.35136418446315343*fnodal_l[1]-0.1756820922315767*fnodal_l[0]; + GhatL[11] = 0.17568209223157663*fnodal_l[11]-0.35136418446315326*fnodal_l[10]+0.17568209223157663*fnodal_l[9]-0.17568209223157663*fnodal_l[8]+0.35136418446315326*fnodal_l[7]-0.17568209223157663*fnodal_l[6]-0.17568209223157663*fnodal_l[5]+0.35136418446315326*fnodal_l[4]-0.17568209223157663*fnodal_l[3]+0.17568209223157663*fnodal_l[2]-0.35136418446315326*fnodal_l[1]+0.17568209223157663*fnodal_l[0]; + GhatR[0] = 0.1964185503295965*fnodal_r[11]+0.3142696805273545*fnodal_r[10]+0.1964185503295965*fnodal_r[9]+0.1964185503295965*fnodal_r[8]+0.3142696805273545*fnodal_r[7]+0.1964185503295965*fnodal_r[6]+0.1964185503295965*fnodal_r[5]+0.3142696805273545*fnodal_r[4]+0.1964185503295965*fnodal_r[3]+0.1964185503295965*fnodal_r[2]+0.3142696805273545*fnodal_r[1]+0.1964185503295965*fnodal_r[0]; + GhatR[1] = 0.1964185503295965*fnodal_r[11]+0.3142696805273545*fnodal_r[10]+0.1964185503295965*fnodal_r[9]+0.1964185503295965*fnodal_r[8]+0.3142696805273545*fnodal_r[7]+0.1964185503295965*fnodal_r[6]-0.1964185503295965*fnodal_r[5]-0.3142696805273545*fnodal_r[4]-0.1964185503295965*fnodal_r[3]-0.1964185503295965*fnodal_r[2]-0.3142696805273545*fnodal_r[1]-0.1964185503295965*fnodal_r[0]; + GhatR[2] = 0.2635231383473649*fnodal_r[11]-0.2635231383473649*fnodal_r[9]+0.2635231383473649*fnodal_r[8]-0.2635231383473649*fnodal_r[6]+0.2635231383473649*fnodal_r[5]-0.2635231383473649*fnodal_r[3]+0.2635231383473649*fnodal_r[2]-0.2635231383473649*fnodal_r[0]; + GhatR[3] = 0.1964185503295965*fnodal_r[11]+0.3142696805273545*fnodal_r[10]+0.1964185503295965*fnodal_r[9]-0.1964185503295965*fnodal_r[8]-0.3142696805273545*fnodal_r[7]-0.1964185503295965*fnodal_r[6]+0.1964185503295965*fnodal_r[5]+0.3142696805273545*fnodal_r[4]+0.1964185503295965*fnodal_r[3]-0.1964185503295965*fnodal_r[2]-0.3142696805273545*fnodal_r[1]-0.1964185503295965*fnodal_r[0]; + GhatR[4] = 0.2635231383473649*fnodal_r[11]-0.2635231383473649*fnodal_r[9]+0.2635231383473649*fnodal_r[8]-0.2635231383473649*fnodal_r[6]-0.2635231383473649*fnodal_r[5]+0.2635231383473649*fnodal_r[3]-0.2635231383473649*fnodal_r[2]+0.2635231383473649*fnodal_r[0]; + GhatR[5] = 0.1964185503295965*fnodal_r[11]+0.3142696805273545*fnodal_r[10]+0.1964185503295965*fnodal_r[9]-0.1964185503295965*fnodal_r[8]-0.3142696805273545*fnodal_r[7]-0.1964185503295965*fnodal_r[6]-0.1964185503295965*fnodal_r[5]-0.3142696805273545*fnodal_r[4]-0.1964185503295965*fnodal_r[3]+0.1964185503295965*fnodal_r[2]+0.3142696805273545*fnodal_r[1]+0.1964185503295965*fnodal_r[0]; + GhatR[6] = 0.2635231383473649*fnodal_r[11]-0.2635231383473649*fnodal_r[9]-0.2635231383473649*fnodal_r[8]+0.2635231383473649*fnodal_r[6]+0.2635231383473649*fnodal_r[5]-0.2635231383473649*fnodal_r[3]-0.2635231383473649*fnodal_r[2]+0.2635231383473649*fnodal_r[0]; + GhatR[7] = 0.2635231383473649*fnodal_r[11]-0.2635231383473649*fnodal_r[9]-0.2635231383473649*fnodal_r[8]+0.2635231383473649*fnodal_r[6]-0.2635231383473649*fnodal_r[5]+0.2635231383473649*fnodal_r[3]+0.2635231383473649*fnodal_r[2]-0.2635231383473649*fnodal_r[0]; + GhatR[8] = 0.17568209223157663*fnodal_r[11]-0.35136418446315326*fnodal_r[10]+0.17568209223157663*fnodal_r[9]+0.17568209223157663*fnodal_r[8]-0.35136418446315326*fnodal_r[7]+0.17568209223157663*fnodal_r[6]+0.17568209223157663*fnodal_r[5]-0.35136418446315326*fnodal_r[4]+0.17568209223157663*fnodal_r[3]+0.17568209223157663*fnodal_r[2]-0.35136418446315326*fnodal_r[1]+0.17568209223157663*fnodal_r[0]; + GhatR[9] = 0.1756820922315767*fnodal_r[11]-0.35136418446315343*fnodal_r[10]+0.1756820922315767*fnodal_r[9]+0.1756820922315767*fnodal_r[8]-0.35136418446315343*fnodal_r[7]+0.1756820922315767*fnodal_r[6]-0.1756820922315767*fnodal_r[5]+0.35136418446315343*fnodal_r[4]-0.1756820922315767*fnodal_r[3]-0.1756820922315767*fnodal_r[2]+0.35136418446315343*fnodal_r[1]-0.1756820922315767*fnodal_r[0]; + GhatR[10] = 0.1756820922315767*fnodal_r[11]-0.35136418446315343*fnodal_r[10]+0.1756820922315767*fnodal_r[9]-0.1756820922315767*fnodal_r[8]+0.35136418446315343*fnodal_r[7]-0.1756820922315767*fnodal_r[6]+0.1756820922315767*fnodal_r[5]-0.35136418446315343*fnodal_r[4]+0.1756820922315767*fnodal_r[3]-0.1756820922315767*fnodal_r[2]+0.35136418446315343*fnodal_r[1]-0.1756820922315767*fnodal_r[0]; + GhatR[11] = 0.17568209223157663*fnodal_r[11]-0.35136418446315326*fnodal_r[10]+0.17568209223157663*fnodal_r[9]-0.17568209223157663*fnodal_r[8]+0.35136418446315326*fnodal_r[7]-0.17568209223157663*fnodal_r[6]-0.17568209223157663*fnodal_r[5]+0.35136418446315326*fnodal_r[4]-0.17568209223157663*fnodal_r[3]+0.17568209223157663*fnodal_r[2]-0.35136418446315326*fnodal_r[1]+0.17568209223157663*fnodal_r[0]; + + out[0] += (0.7071067811865475*GhatL[0]-0.7071067811865475*GhatR[0])*rdx2; + out[1] += (-(1.224744871391589*GhatR[0])-1.224744871391589*GhatL[0])*rdx2; + out[2] += (0.7071067811865475*GhatL[1]-0.7071067811865475*GhatR[1])*rdx2; + out[3] += (0.7071067811865475*GhatL[2]-0.7071067811865475*GhatR[2])*rdx2; + out[4] += (0.7071067811865475*GhatL[3]-0.7071067811865475*GhatR[3])*rdx2; + out[5] += (-(1.224744871391589*GhatR[1])-1.224744871391589*GhatL[1])*rdx2; + out[6] += (-(1.224744871391589*GhatR[2])-1.224744871391589*GhatL[2])*rdx2; + out[7] += (0.7071067811865475*GhatL[4]-0.7071067811865475*GhatR[4])*rdx2; + out[8] += (-(1.224744871391589*GhatR[3])-1.224744871391589*GhatL[3])*rdx2; + out[9] += (0.7071067811865475*GhatL[5]-0.7071067811865475*GhatR[5])*rdx2; + out[10] += (0.7071067811865475*GhatL[6]-0.7071067811865475*GhatR[6])*rdx2; + out[11] += (-(1.224744871391589*GhatR[4])-1.224744871391589*GhatL[4])*rdx2; + out[12] += (-(1.224744871391589*GhatR[5])-1.224744871391589*GhatL[5])*rdx2; + out[13] += (-(1.224744871391589*GhatR[6])-1.224744871391589*GhatL[6])*rdx2; + out[14] += (0.7071067811865475*GhatL[7]-0.7071067811865475*GhatR[7])*rdx2; + out[15] += (-(1.224744871391589*GhatR[7])-1.224744871391589*GhatL[7])*rdx2; + out[16] += (0.7071067811865475*GhatL[8]-0.7071067811865475*GhatR[8])*rdx2; + out[17] += (-(1.224744871391589*GhatR[8])-1.224744871391589*GhatL[8])*rdx2; + out[18] += (0.7071067811865475*GhatL[9]-0.7071067811865475*GhatR[9])*rdx2; + out[19] += (0.7071067811865475*GhatL[10]-0.7071067811865475*GhatR[10])*rdx2; + out[20] += (-(1.224744871391589*GhatR[9])-1.224744871391589*GhatL[9])*rdx2; + out[21] += (-(1.224744871391589*GhatR[10])-1.224744871391589*GhatL[10])*rdx2; + out[22] += (0.7071067811865475*GhatL[11]-0.7071067811865475*GhatR[11])*rdx2; + out[23] += (-(1.224744871391589*GhatR[11])-1.224744871391589*GhatL[11])*rdx2; + + return 0.0; + +} diff --git a/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfx_3x2v_ser_p1.c b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfx_3x2v_ser_p1.c new file mode 100644 index 0000000000..5a8256a45c --- /dev/null +++ b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfx_3x2v_ser_p1.c @@ -0,0 +1,122 @@ +#include +#include +GKYL_CU_DH double dg_gyrokinetic_passive_surfx_3x2v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_l, const double *vmap_prime_c, const double *vmap_prime_r, + const double *flux_surf_l, const double *flux_surf_r, + double* GKYL_RESTRICT out) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap_prime_l,vmap_prime_c,vmap_prime_r: velocity space mapping derivative in left, center and right cells. + // flux_surf_l: Surface expansion of phase space flux on the left. + // flux_surf_r: Surface expansion of phase space flux on the right. + // out: output increment in center cell. + + double rdx2 = 2.0/dxv[0]; + + double GhatL[24]= {0.0}; + double GhatR[24]= {0.0}; + + const double *fnodal_l = &flux_surf_l[0]; + const double *fnodal_r = &flux_surf_r[0]; + GhatL[0] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]+0.1388888888888889*fnodal_l[20]+0.2222222222222222*fnodal_l[19]+0.1388888888888889*fnodal_l[18]+0.1388888888888889*fnodal_l[17]+0.2222222222222222*fnodal_l[16]+0.1388888888888889*fnodal_l[15]+0.1388888888888889*fnodal_l[14]+0.2222222222222222*fnodal_l[13]+0.1388888888888889*fnodal_l[12]+0.1388888888888889*fnodal_l[11]+0.2222222222222222*fnodal_l[10]+0.1388888888888889*fnodal_l[9]+0.1388888888888889*fnodal_l[8]+0.2222222222222222*fnodal_l[7]+0.1388888888888889*fnodal_l[6]+0.1388888888888889*fnodal_l[5]+0.2222222222222222*fnodal_l[4]+0.1388888888888889*fnodal_l[3]+0.1388888888888889*fnodal_l[2]+0.2222222222222222*fnodal_l[1]+0.1388888888888889*fnodal_l[0]; + GhatL[1] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]+0.1388888888888889*fnodal_l[20]+0.2222222222222222*fnodal_l[19]+0.1388888888888889*fnodal_l[18]+0.1388888888888889*fnodal_l[17]+0.2222222222222222*fnodal_l[16]+0.1388888888888889*fnodal_l[15]+0.1388888888888889*fnodal_l[14]+0.2222222222222222*fnodal_l[13]+0.1388888888888889*fnodal_l[12]-0.1388888888888889*fnodal_l[11]-0.2222222222222222*fnodal_l[10]-0.1388888888888889*fnodal_l[9]-0.1388888888888889*fnodal_l[8]-0.2222222222222222*fnodal_l[7]-0.1388888888888889*fnodal_l[6]-0.1388888888888889*fnodal_l[5]-0.2222222222222222*fnodal_l[4]-0.1388888888888889*fnodal_l[3]-0.1388888888888889*fnodal_l[2]-0.2222222222222222*fnodal_l[1]-0.1388888888888889*fnodal_l[0]; + GhatL[2] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]+0.1388888888888889*fnodal_l[20]+0.2222222222222222*fnodal_l[19]+0.1388888888888889*fnodal_l[18]-0.1388888888888889*fnodal_l[17]-0.2222222222222222*fnodal_l[16]-0.1388888888888889*fnodal_l[15]-0.1388888888888889*fnodal_l[14]-0.2222222222222222*fnodal_l[13]-0.1388888888888889*fnodal_l[12]+0.1388888888888889*fnodal_l[11]+0.2222222222222222*fnodal_l[10]+0.1388888888888889*fnodal_l[9]+0.1388888888888889*fnodal_l[8]+0.2222222222222222*fnodal_l[7]+0.1388888888888889*fnodal_l[6]-0.1388888888888889*fnodal_l[5]-0.2222222222222222*fnodal_l[4]-0.1388888888888889*fnodal_l[3]-0.1388888888888889*fnodal_l[2]-0.2222222222222222*fnodal_l[1]-0.1388888888888889*fnodal_l[0]; + GhatL[3] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]+0.18633899812498247*fnodal_l[20]-0.18633899812498247*fnodal_l[18]+0.18633899812498247*fnodal_l[17]-0.18633899812498247*fnodal_l[15]+0.18633899812498247*fnodal_l[14]-0.18633899812498247*fnodal_l[12]+0.18633899812498247*fnodal_l[11]-0.18633899812498247*fnodal_l[9]+0.18633899812498247*fnodal_l[8]-0.18633899812498247*fnodal_l[6]+0.18633899812498247*fnodal_l[5]-0.18633899812498247*fnodal_l[3]+0.18633899812498247*fnodal_l[2]-0.18633899812498247*fnodal_l[0]; + GhatL[4] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]-0.1388888888888889*fnodal_l[20]-0.2222222222222222*fnodal_l[19]-0.1388888888888889*fnodal_l[18]+0.1388888888888889*fnodal_l[17]+0.2222222222222222*fnodal_l[16]+0.1388888888888889*fnodal_l[15]-0.1388888888888889*fnodal_l[14]-0.2222222222222222*fnodal_l[13]-0.1388888888888889*fnodal_l[12]+0.1388888888888889*fnodal_l[11]+0.2222222222222222*fnodal_l[10]+0.1388888888888889*fnodal_l[9]-0.1388888888888889*fnodal_l[8]-0.2222222222222222*fnodal_l[7]-0.1388888888888889*fnodal_l[6]+0.1388888888888889*fnodal_l[5]+0.2222222222222222*fnodal_l[4]+0.1388888888888889*fnodal_l[3]-0.1388888888888889*fnodal_l[2]-0.2222222222222222*fnodal_l[1]-0.1388888888888889*fnodal_l[0]; + GhatL[5] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]+0.1388888888888889*fnodal_l[20]+0.2222222222222222*fnodal_l[19]+0.1388888888888889*fnodal_l[18]-0.1388888888888889*fnodal_l[17]-0.2222222222222222*fnodal_l[16]-0.1388888888888889*fnodal_l[15]-0.1388888888888889*fnodal_l[14]-0.2222222222222222*fnodal_l[13]-0.1388888888888889*fnodal_l[12]-0.1388888888888889*fnodal_l[11]-0.2222222222222222*fnodal_l[10]-0.1388888888888889*fnodal_l[9]-0.1388888888888889*fnodal_l[8]-0.2222222222222222*fnodal_l[7]-0.1388888888888889*fnodal_l[6]+0.1388888888888889*fnodal_l[5]+0.2222222222222222*fnodal_l[4]+0.1388888888888889*fnodal_l[3]+0.1388888888888889*fnodal_l[2]+0.2222222222222222*fnodal_l[1]+0.1388888888888889*fnodal_l[0]; + GhatL[6] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]+0.18633899812498247*fnodal_l[20]-0.18633899812498247*fnodal_l[18]+0.18633899812498247*fnodal_l[17]-0.18633899812498247*fnodal_l[15]+0.18633899812498247*fnodal_l[14]-0.18633899812498247*fnodal_l[12]-0.18633899812498247*fnodal_l[11]+0.18633899812498247*fnodal_l[9]-0.18633899812498247*fnodal_l[8]+0.18633899812498247*fnodal_l[6]-0.18633899812498247*fnodal_l[5]+0.18633899812498247*fnodal_l[3]-0.18633899812498247*fnodal_l[2]+0.18633899812498247*fnodal_l[0]; + GhatL[7] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]+0.18633899812498247*fnodal_l[20]-0.18633899812498247*fnodal_l[18]-0.18633899812498247*fnodal_l[17]+0.18633899812498247*fnodal_l[15]-0.18633899812498247*fnodal_l[14]+0.18633899812498247*fnodal_l[12]+0.18633899812498247*fnodal_l[11]-0.18633899812498247*fnodal_l[9]+0.18633899812498247*fnodal_l[8]-0.18633899812498247*fnodal_l[6]-0.18633899812498247*fnodal_l[5]+0.18633899812498247*fnodal_l[3]-0.18633899812498247*fnodal_l[2]+0.18633899812498247*fnodal_l[0]; + GhatL[8] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]-0.1388888888888889*fnodal_l[20]-0.2222222222222222*fnodal_l[19]-0.1388888888888889*fnodal_l[18]+0.1388888888888889*fnodal_l[17]+0.2222222222222222*fnodal_l[16]+0.1388888888888889*fnodal_l[15]-0.1388888888888889*fnodal_l[14]-0.2222222222222222*fnodal_l[13]-0.1388888888888889*fnodal_l[12]-0.1388888888888889*fnodal_l[11]-0.2222222222222222*fnodal_l[10]-0.1388888888888889*fnodal_l[9]+0.1388888888888889*fnodal_l[8]+0.2222222222222222*fnodal_l[7]+0.1388888888888889*fnodal_l[6]-0.1388888888888889*fnodal_l[5]-0.2222222222222222*fnodal_l[4]-0.1388888888888889*fnodal_l[3]+0.1388888888888889*fnodal_l[2]+0.2222222222222222*fnodal_l[1]+0.1388888888888889*fnodal_l[0]; + GhatL[9] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]-0.1388888888888889*fnodal_l[20]-0.2222222222222222*fnodal_l[19]-0.1388888888888889*fnodal_l[18]-0.1388888888888889*fnodal_l[17]-0.2222222222222222*fnodal_l[16]-0.1388888888888889*fnodal_l[15]+0.1388888888888889*fnodal_l[14]+0.2222222222222222*fnodal_l[13]+0.1388888888888889*fnodal_l[12]+0.1388888888888889*fnodal_l[11]+0.2222222222222222*fnodal_l[10]+0.1388888888888889*fnodal_l[9]-0.1388888888888889*fnodal_l[8]-0.2222222222222222*fnodal_l[7]-0.1388888888888889*fnodal_l[6]-0.1388888888888889*fnodal_l[5]-0.2222222222222222*fnodal_l[4]-0.1388888888888889*fnodal_l[3]+0.1388888888888889*fnodal_l[2]+0.2222222222222222*fnodal_l[1]+0.1388888888888889*fnodal_l[0]; + GhatL[10] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]-0.18633899812498247*fnodal_l[20]+0.18633899812498247*fnodal_l[18]+0.18633899812498247*fnodal_l[17]-0.18633899812498247*fnodal_l[15]-0.18633899812498247*fnodal_l[14]+0.18633899812498247*fnodal_l[12]+0.18633899812498247*fnodal_l[11]-0.18633899812498247*fnodal_l[9]-0.18633899812498247*fnodal_l[8]+0.18633899812498247*fnodal_l[6]+0.18633899812498247*fnodal_l[5]-0.18633899812498247*fnodal_l[3]-0.18633899812498247*fnodal_l[2]+0.18633899812498247*fnodal_l[0]; + GhatL[11] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]+0.18633899812498247*fnodal_l[20]-0.18633899812498247*fnodal_l[18]-0.18633899812498247*fnodal_l[17]+0.18633899812498247*fnodal_l[15]-0.18633899812498247*fnodal_l[14]+0.18633899812498247*fnodal_l[12]-0.18633899812498247*fnodal_l[11]+0.18633899812498247*fnodal_l[9]-0.18633899812498247*fnodal_l[8]+0.18633899812498247*fnodal_l[6]+0.18633899812498247*fnodal_l[5]-0.18633899812498247*fnodal_l[3]+0.18633899812498247*fnodal_l[2]-0.18633899812498247*fnodal_l[0]; + GhatL[12] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]-0.1388888888888889*fnodal_l[20]-0.2222222222222222*fnodal_l[19]-0.1388888888888889*fnodal_l[18]-0.1388888888888889*fnodal_l[17]-0.2222222222222222*fnodal_l[16]-0.1388888888888889*fnodal_l[15]+0.1388888888888889*fnodal_l[14]+0.2222222222222222*fnodal_l[13]+0.1388888888888889*fnodal_l[12]-0.1388888888888889*fnodal_l[11]-0.2222222222222222*fnodal_l[10]-0.1388888888888889*fnodal_l[9]+0.1388888888888889*fnodal_l[8]+0.2222222222222222*fnodal_l[7]+0.1388888888888889*fnodal_l[6]+0.1388888888888889*fnodal_l[5]+0.2222222222222222*fnodal_l[4]+0.1388888888888889*fnodal_l[3]-0.1388888888888889*fnodal_l[2]-0.2222222222222222*fnodal_l[1]-0.1388888888888889*fnodal_l[0]; + GhatL[13] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]-0.18633899812498247*fnodal_l[20]+0.18633899812498247*fnodal_l[18]+0.18633899812498247*fnodal_l[17]-0.18633899812498247*fnodal_l[15]-0.18633899812498247*fnodal_l[14]+0.18633899812498247*fnodal_l[12]-0.18633899812498247*fnodal_l[11]+0.18633899812498247*fnodal_l[9]+0.18633899812498247*fnodal_l[8]-0.18633899812498247*fnodal_l[6]-0.18633899812498247*fnodal_l[5]+0.18633899812498247*fnodal_l[3]+0.18633899812498247*fnodal_l[2]-0.18633899812498247*fnodal_l[0]; + GhatL[14] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]-0.18633899812498247*fnodal_l[20]+0.18633899812498247*fnodal_l[18]-0.18633899812498247*fnodal_l[17]+0.18633899812498247*fnodal_l[15]+0.18633899812498247*fnodal_l[14]-0.18633899812498247*fnodal_l[12]+0.18633899812498247*fnodal_l[11]-0.18633899812498247*fnodal_l[9]-0.18633899812498247*fnodal_l[8]+0.18633899812498247*fnodal_l[6]-0.18633899812498247*fnodal_l[5]+0.18633899812498247*fnodal_l[3]+0.18633899812498247*fnodal_l[2]-0.18633899812498247*fnodal_l[0]; + GhatL[15] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]-0.18633899812498247*fnodal_l[20]+0.18633899812498247*fnodal_l[18]-0.18633899812498247*fnodal_l[17]+0.18633899812498247*fnodal_l[15]+0.18633899812498247*fnodal_l[14]-0.18633899812498247*fnodal_l[12]-0.18633899812498247*fnodal_l[11]+0.18633899812498247*fnodal_l[9]+0.18633899812498247*fnodal_l[8]-0.18633899812498247*fnodal_l[6]+0.18633899812498247*fnodal_l[5]-0.18633899812498247*fnodal_l[3]-0.18633899812498247*fnodal_l[2]+0.18633899812498247*fnodal_l[0]; + GhatL[16] = 0.12422599874998831*fnodal_l[23]-0.24845199749997662*fnodal_l[22]+0.12422599874998831*fnodal_l[21]+0.12422599874998831*fnodal_l[20]-0.24845199749997662*fnodal_l[19]+0.12422599874998831*fnodal_l[18]+0.12422599874998831*fnodal_l[17]-0.24845199749997662*fnodal_l[16]+0.12422599874998831*fnodal_l[15]+0.12422599874998831*fnodal_l[14]-0.24845199749997662*fnodal_l[13]+0.12422599874998831*fnodal_l[12]+0.12422599874998831*fnodal_l[11]-0.24845199749997662*fnodal_l[10]+0.12422599874998831*fnodal_l[9]+0.12422599874998831*fnodal_l[8]-0.24845199749997662*fnodal_l[7]+0.12422599874998831*fnodal_l[6]+0.12422599874998831*fnodal_l[5]-0.24845199749997662*fnodal_l[4]+0.12422599874998831*fnodal_l[3]+0.12422599874998831*fnodal_l[2]-0.24845199749997662*fnodal_l[1]+0.12422599874998831*fnodal_l[0]; + GhatL[17] = 0.12422599874998837*fnodal_l[23]-0.24845199749997673*fnodal_l[22]+0.12422599874998837*fnodal_l[21]+0.12422599874998837*fnodal_l[20]-0.24845199749997673*fnodal_l[19]+0.12422599874998837*fnodal_l[18]+0.12422599874998837*fnodal_l[17]-0.24845199749997673*fnodal_l[16]+0.12422599874998837*fnodal_l[15]+0.12422599874998837*fnodal_l[14]-0.24845199749997673*fnodal_l[13]+0.12422599874998837*fnodal_l[12]-0.12422599874998837*fnodal_l[11]+0.24845199749997673*fnodal_l[10]-0.12422599874998837*fnodal_l[9]-0.12422599874998837*fnodal_l[8]+0.24845199749997673*fnodal_l[7]-0.12422599874998837*fnodal_l[6]-0.12422599874998837*fnodal_l[5]+0.24845199749997673*fnodal_l[4]-0.12422599874998837*fnodal_l[3]-0.12422599874998837*fnodal_l[2]+0.24845199749997673*fnodal_l[1]-0.12422599874998837*fnodal_l[0]; + GhatL[18] = 0.12422599874998837*fnodal_l[23]-0.24845199749997673*fnodal_l[22]+0.12422599874998837*fnodal_l[21]+0.12422599874998837*fnodal_l[20]-0.24845199749997673*fnodal_l[19]+0.12422599874998837*fnodal_l[18]-0.12422599874998837*fnodal_l[17]+0.24845199749997673*fnodal_l[16]-0.12422599874998837*fnodal_l[15]-0.12422599874998837*fnodal_l[14]+0.24845199749997673*fnodal_l[13]-0.12422599874998837*fnodal_l[12]+0.12422599874998837*fnodal_l[11]-0.24845199749997673*fnodal_l[10]+0.12422599874998837*fnodal_l[9]+0.12422599874998837*fnodal_l[8]-0.24845199749997673*fnodal_l[7]+0.12422599874998837*fnodal_l[6]-0.12422599874998837*fnodal_l[5]+0.24845199749997673*fnodal_l[4]-0.12422599874998837*fnodal_l[3]-0.12422599874998837*fnodal_l[2]+0.24845199749997673*fnodal_l[1]-0.12422599874998837*fnodal_l[0]; + GhatL[19] = 0.12422599874998837*fnodal_l[23]-0.24845199749997673*fnodal_l[22]+0.12422599874998837*fnodal_l[21]-0.12422599874998837*fnodal_l[20]+0.24845199749997673*fnodal_l[19]-0.12422599874998837*fnodal_l[18]+0.12422599874998837*fnodal_l[17]-0.24845199749997673*fnodal_l[16]+0.12422599874998837*fnodal_l[15]-0.12422599874998837*fnodal_l[14]+0.24845199749997673*fnodal_l[13]-0.12422599874998837*fnodal_l[12]+0.12422599874998837*fnodal_l[11]-0.24845199749997673*fnodal_l[10]+0.12422599874998837*fnodal_l[9]-0.12422599874998837*fnodal_l[8]+0.24845199749997673*fnodal_l[7]-0.12422599874998837*fnodal_l[6]+0.12422599874998837*fnodal_l[5]-0.24845199749997673*fnodal_l[4]+0.12422599874998837*fnodal_l[3]-0.12422599874998837*fnodal_l[2]+0.24845199749997673*fnodal_l[1]-0.12422599874998837*fnodal_l[0]; + GhatL[20] = 0.12422599874998831*fnodal_l[23]-0.24845199749997662*fnodal_l[22]+0.12422599874998831*fnodal_l[21]+0.12422599874998831*fnodal_l[20]-0.24845199749997662*fnodal_l[19]+0.12422599874998831*fnodal_l[18]-0.12422599874998831*fnodal_l[17]+0.24845199749997662*fnodal_l[16]-0.12422599874998831*fnodal_l[15]-0.12422599874998831*fnodal_l[14]+0.24845199749997662*fnodal_l[13]-0.12422599874998831*fnodal_l[12]-0.12422599874998831*fnodal_l[11]+0.24845199749997662*fnodal_l[10]-0.12422599874998831*fnodal_l[9]-0.12422599874998831*fnodal_l[8]+0.24845199749997662*fnodal_l[7]-0.12422599874998831*fnodal_l[6]+0.12422599874998831*fnodal_l[5]-0.24845199749997662*fnodal_l[4]+0.12422599874998831*fnodal_l[3]+0.12422599874998831*fnodal_l[2]-0.24845199749997662*fnodal_l[1]+0.12422599874998831*fnodal_l[0]; + GhatL[21] = 0.12422599874998831*fnodal_l[23]-0.24845199749997662*fnodal_l[22]+0.12422599874998831*fnodal_l[21]-0.12422599874998831*fnodal_l[20]+0.24845199749997662*fnodal_l[19]-0.12422599874998831*fnodal_l[18]+0.12422599874998831*fnodal_l[17]-0.24845199749997662*fnodal_l[16]+0.12422599874998831*fnodal_l[15]-0.12422599874998831*fnodal_l[14]+0.24845199749997662*fnodal_l[13]-0.12422599874998831*fnodal_l[12]-0.12422599874998831*fnodal_l[11]+0.24845199749997662*fnodal_l[10]-0.12422599874998831*fnodal_l[9]+0.12422599874998831*fnodal_l[8]-0.24845199749997662*fnodal_l[7]+0.12422599874998831*fnodal_l[6]-0.12422599874998831*fnodal_l[5]+0.24845199749997662*fnodal_l[4]-0.12422599874998831*fnodal_l[3]+0.12422599874998831*fnodal_l[2]-0.24845199749997662*fnodal_l[1]+0.12422599874998831*fnodal_l[0]; + GhatL[22] = 0.12422599874998831*fnodal_l[23]-0.24845199749997662*fnodal_l[22]+0.12422599874998831*fnodal_l[21]-0.12422599874998831*fnodal_l[20]+0.24845199749997662*fnodal_l[19]-0.12422599874998831*fnodal_l[18]-0.12422599874998831*fnodal_l[17]+0.24845199749997662*fnodal_l[16]-0.12422599874998831*fnodal_l[15]+0.12422599874998831*fnodal_l[14]-0.24845199749997662*fnodal_l[13]+0.12422599874998831*fnodal_l[12]+0.12422599874998831*fnodal_l[11]-0.24845199749997662*fnodal_l[10]+0.12422599874998831*fnodal_l[9]-0.12422599874998831*fnodal_l[8]+0.24845199749997662*fnodal_l[7]-0.12422599874998831*fnodal_l[6]-0.12422599874998831*fnodal_l[5]+0.24845199749997662*fnodal_l[4]-0.12422599874998831*fnodal_l[3]+0.12422599874998831*fnodal_l[2]-0.24845199749997662*fnodal_l[1]+0.12422599874998831*fnodal_l[0]; + GhatL[23] = 0.12422599874998837*fnodal_l[23]-0.24845199749997673*fnodal_l[22]+0.12422599874998837*fnodal_l[21]-0.12422599874998837*fnodal_l[20]+0.24845199749997673*fnodal_l[19]-0.12422599874998837*fnodal_l[18]-0.12422599874998837*fnodal_l[17]+0.24845199749997673*fnodal_l[16]-0.12422599874998837*fnodal_l[15]+0.12422599874998837*fnodal_l[14]-0.24845199749997673*fnodal_l[13]+0.12422599874998837*fnodal_l[12]-0.12422599874998837*fnodal_l[11]+0.24845199749997673*fnodal_l[10]-0.12422599874998837*fnodal_l[9]+0.12422599874998837*fnodal_l[8]-0.24845199749997673*fnodal_l[7]+0.12422599874998837*fnodal_l[6]+0.12422599874998837*fnodal_l[5]-0.24845199749997673*fnodal_l[4]+0.12422599874998837*fnodal_l[3]-0.12422599874998837*fnodal_l[2]+0.24845199749997673*fnodal_l[1]-0.12422599874998837*fnodal_l[0]; + GhatR[0] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]+0.1388888888888889*fnodal_r[20]+0.2222222222222222*fnodal_r[19]+0.1388888888888889*fnodal_r[18]+0.1388888888888889*fnodal_r[17]+0.2222222222222222*fnodal_r[16]+0.1388888888888889*fnodal_r[15]+0.1388888888888889*fnodal_r[14]+0.2222222222222222*fnodal_r[13]+0.1388888888888889*fnodal_r[12]+0.1388888888888889*fnodal_r[11]+0.2222222222222222*fnodal_r[10]+0.1388888888888889*fnodal_r[9]+0.1388888888888889*fnodal_r[8]+0.2222222222222222*fnodal_r[7]+0.1388888888888889*fnodal_r[6]+0.1388888888888889*fnodal_r[5]+0.2222222222222222*fnodal_r[4]+0.1388888888888889*fnodal_r[3]+0.1388888888888889*fnodal_r[2]+0.2222222222222222*fnodal_r[1]+0.1388888888888889*fnodal_r[0]; + GhatR[1] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]+0.1388888888888889*fnodal_r[20]+0.2222222222222222*fnodal_r[19]+0.1388888888888889*fnodal_r[18]+0.1388888888888889*fnodal_r[17]+0.2222222222222222*fnodal_r[16]+0.1388888888888889*fnodal_r[15]+0.1388888888888889*fnodal_r[14]+0.2222222222222222*fnodal_r[13]+0.1388888888888889*fnodal_r[12]-0.1388888888888889*fnodal_r[11]-0.2222222222222222*fnodal_r[10]-0.1388888888888889*fnodal_r[9]-0.1388888888888889*fnodal_r[8]-0.2222222222222222*fnodal_r[7]-0.1388888888888889*fnodal_r[6]-0.1388888888888889*fnodal_r[5]-0.2222222222222222*fnodal_r[4]-0.1388888888888889*fnodal_r[3]-0.1388888888888889*fnodal_r[2]-0.2222222222222222*fnodal_r[1]-0.1388888888888889*fnodal_r[0]; + GhatR[2] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]+0.1388888888888889*fnodal_r[20]+0.2222222222222222*fnodal_r[19]+0.1388888888888889*fnodal_r[18]-0.1388888888888889*fnodal_r[17]-0.2222222222222222*fnodal_r[16]-0.1388888888888889*fnodal_r[15]-0.1388888888888889*fnodal_r[14]-0.2222222222222222*fnodal_r[13]-0.1388888888888889*fnodal_r[12]+0.1388888888888889*fnodal_r[11]+0.2222222222222222*fnodal_r[10]+0.1388888888888889*fnodal_r[9]+0.1388888888888889*fnodal_r[8]+0.2222222222222222*fnodal_r[7]+0.1388888888888889*fnodal_r[6]-0.1388888888888889*fnodal_r[5]-0.2222222222222222*fnodal_r[4]-0.1388888888888889*fnodal_r[3]-0.1388888888888889*fnodal_r[2]-0.2222222222222222*fnodal_r[1]-0.1388888888888889*fnodal_r[0]; + GhatR[3] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]+0.18633899812498247*fnodal_r[20]-0.18633899812498247*fnodal_r[18]+0.18633899812498247*fnodal_r[17]-0.18633899812498247*fnodal_r[15]+0.18633899812498247*fnodal_r[14]-0.18633899812498247*fnodal_r[12]+0.18633899812498247*fnodal_r[11]-0.18633899812498247*fnodal_r[9]+0.18633899812498247*fnodal_r[8]-0.18633899812498247*fnodal_r[6]+0.18633899812498247*fnodal_r[5]-0.18633899812498247*fnodal_r[3]+0.18633899812498247*fnodal_r[2]-0.18633899812498247*fnodal_r[0]; + GhatR[4] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]-0.1388888888888889*fnodal_r[20]-0.2222222222222222*fnodal_r[19]-0.1388888888888889*fnodal_r[18]+0.1388888888888889*fnodal_r[17]+0.2222222222222222*fnodal_r[16]+0.1388888888888889*fnodal_r[15]-0.1388888888888889*fnodal_r[14]-0.2222222222222222*fnodal_r[13]-0.1388888888888889*fnodal_r[12]+0.1388888888888889*fnodal_r[11]+0.2222222222222222*fnodal_r[10]+0.1388888888888889*fnodal_r[9]-0.1388888888888889*fnodal_r[8]-0.2222222222222222*fnodal_r[7]-0.1388888888888889*fnodal_r[6]+0.1388888888888889*fnodal_r[5]+0.2222222222222222*fnodal_r[4]+0.1388888888888889*fnodal_r[3]-0.1388888888888889*fnodal_r[2]-0.2222222222222222*fnodal_r[1]-0.1388888888888889*fnodal_r[0]; + GhatR[5] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]+0.1388888888888889*fnodal_r[20]+0.2222222222222222*fnodal_r[19]+0.1388888888888889*fnodal_r[18]-0.1388888888888889*fnodal_r[17]-0.2222222222222222*fnodal_r[16]-0.1388888888888889*fnodal_r[15]-0.1388888888888889*fnodal_r[14]-0.2222222222222222*fnodal_r[13]-0.1388888888888889*fnodal_r[12]-0.1388888888888889*fnodal_r[11]-0.2222222222222222*fnodal_r[10]-0.1388888888888889*fnodal_r[9]-0.1388888888888889*fnodal_r[8]-0.2222222222222222*fnodal_r[7]-0.1388888888888889*fnodal_r[6]+0.1388888888888889*fnodal_r[5]+0.2222222222222222*fnodal_r[4]+0.1388888888888889*fnodal_r[3]+0.1388888888888889*fnodal_r[2]+0.2222222222222222*fnodal_r[1]+0.1388888888888889*fnodal_r[0]; + GhatR[6] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]+0.18633899812498247*fnodal_r[20]-0.18633899812498247*fnodal_r[18]+0.18633899812498247*fnodal_r[17]-0.18633899812498247*fnodal_r[15]+0.18633899812498247*fnodal_r[14]-0.18633899812498247*fnodal_r[12]-0.18633899812498247*fnodal_r[11]+0.18633899812498247*fnodal_r[9]-0.18633899812498247*fnodal_r[8]+0.18633899812498247*fnodal_r[6]-0.18633899812498247*fnodal_r[5]+0.18633899812498247*fnodal_r[3]-0.18633899812498247*fnodal_r[2]+0.18633899812498247*fnodal_r[0]; + GhatR[7] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]+0.18633899812498247*fnodal_r[20]-0.18633899812498247*fnodal_r[18]-0.18633899812498247*fnodal_r[17]+0.18633899812498247*fnodal_r[15]-0.18633899812498247*fnodal_r[14]+0.18633899812498247*fnodal_r[12]+0.18633899812498247*fnodal_r[11]-0.18633899812498247*fnodal_r[9]+0.18633899812498247*fnodal_r[8]-0.18633899812498247*fnodal_r[6]-0.18633899812498247*fnodal_r[5]+0.18633899812498247*fnodal_r[3]-0.18633899812498247*fnodal_r[2]+0.18633899812498247*fnodal_r[0]; + GhatR[8] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]-0.1388888888888889*fnodal_r[20]-0.2222222222222222*fnodal_r[19]-0.1388888888888889*fnodal_r[18]+0.1388888888888889*fnodal_r[17]+0.2222222222222222*fnodal_r[16]+0.1388888888888889*fnodal_r[15]-0.1388888888888889*fnodal_r[14]-0.2222222222222222*fnodal_r[13]-0.1388888888888889*fnodal_r[12]-0.1388888888888889*fnodal_r[11]-0.2222222222222222*fnodal_r[10]-0.1388888888888889*fnodal_r[9]+0.1388888888888889*fnodal_r[8]+0.2222222222222222*fnodal_r[7]+0.1388888888888889*fnodal_r[6]-0.1388888888888889*fnodal_r[5]-0.2222222222222222*fnodal_r[4]-0.1388888888888889*fnodal_r[3]+0.1388888888888889*fnodal_r[2]+0.2222222222222222*fnodal_r[1]+0.1388888888888889*fnodal_r[0]; + GhatR[9] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]-0.1388888888888889*fnodal_r[20]-0.2222222222222222*fnodal_r[19]-0.1388888888888889*fnodal_r[18]-0.1388888888888889*fnodal_r[17]-0.2222222222222222*fnodal_r[16]-0.1388888888888889*fnodal_r[15]+0.1388888888888889*fnodal_r[14]+0.2222222222222222*fnodal_r[13]+0.1388888888888889*fnodal_r[12]+0.1388888888888889*fnodal_r[11]+0.2222222222222222*fnodal_r[10]+0.1388888888888889*fnodal_r[9]-0.1388888888888889*fnodal_r[8]-0.2222222222222222*fnodal_r[7]-0.1388888888888889*fnodal_r[6]-0.1388888888888889*fnodal_r[5]-0.2222222222222222*fnodal_r[4]-0.1388888888888889*fnodal_r[3]+0.1388888888888889*fnodal_r[2]+0.2222222222222222*fnodal_r[1]+0.1388888888888889*fnodal_r[0]; + GhatR[10] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]-0.18633899812498247*fnodal_r[20]+0.18633899812498247*fnodal_r[18]+0.18633899812498247*fnodal_r[17]-0.18633899812498247*fnodal_r[15]-0.18633899812498247*fnodal_r[14]+0.18633899812498247*fnodal_r[12]+0.18633899812498247*fnodal_r[11]-0.18633899812498247*fnodal_r[9]-0.18633899812498247*fnodal_r[8]+0.18633899812498247*fnodal_r[6]+0.18633899812498247*fnodal_r[5]-0.18633899812498247*fnodal_r[3]-0.18633899812498247*fnodal_r[2]+0.18633899812498247*fnodal_r[0]; + GhatR[11] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]+0.18633899812498247*fnodal_r[20]-0.18633899812498247*fnodal_r[18]-0.18633899812498247*fnodal_r[17]+0.18633899812498247*fnodal_r[15]-0.18633899812498247*fnodal_r[14]+0.18633899812498247*fnodal_r[12]-0.18633899812498247*fnodal_r[11]+0.18633899812498247*fnodal_r[9]-0.18633899812498247*fnodal_r[8]+0.18633899812498247*fnodal_r[6]+0.18633899812498247*fnodal_r[5]-0.18633899812498247*fnodal_r[3]+0.18633899812498247*fnodal_r[2]-0.18633899812498247*fnodal_r[0]; + GhatR[12] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]-0.1388888888888889*fnodal_r[20]-0.2222222222222222*fnodal_r[19]-0.1388888888888889*fnodal_r[18]-0.1388888888888889*fnodal_r[17]-0.2222222222222222*fnodal_r[16]-0.1388888888888889*fnodal_r[15]+0.1388888888888889*fnodal_r[14]+0.2222222222222222*fnodal_r[13]+0.1388888888888889*fnodal_r[12]-0.1388888888888889*fnodal_r[11]-0.2222222222222222*fnodal_r[10]-0.1388888888888889*fnodal_r[9]+0.1388888888888889*fnodal_r[8]+0.2222222222222222*fnodal_r[7]+0.1388888888888889*fnodal_r[6]+0.1388888888888889*fnodal_r[5]+0.2222222222222222*fnodal_r[4]+0.1388888888888889*fnodal_r[3]-0.1388888888888889*fnodal_r[2]-0.2222222222222222*fnodal_r[1]-0.1388888888888889*fnodal_r[0]; + GhatR[13] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]-0.18633899812498247*fnodal_r[20]+0.18633899812498247*fnodal_r[18]+0.18633899812498247*fnodal_r[17]-0.18633899812498247*fnodal_r[15]-0.18633899812498247*fnodal_r[14]+0.18633899812498247*fnodal_r[12]-0.18633899812498247*fnodal_r[11]+0.18633899812498247*fnodal_r[9]+0.18633899812498247*fnodal_r[8]-0.18633899812498247*fnodal_r[6]-0.18633899812498247*fnodal_r[5]+0.18633899812498247*fnodal_r[3]+0.18633899812498247*fnodal_r[2]-0.18633899812498247*fnodal_r[0]; + GhatR[14] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]-0.18633899812498247*fnodal_r[20]+0.18633899812498247*fnodal_r[18]-0.18633899812498247*fnodal_r[17]+0.18633899812498247*fnodal_r[15]+0.18633899812498247*fnodal_r[14]-0.18633899812498247*fnodal_r[12]+0.18633899812498247*fnodal_r[11]-0.18633899812498247*fnodal_r[9]-0.18633899812498247*fnodal_r[8]+0.18633899812498247*fnodal_r[6]-0.18633899812498247*fnodal_r[5]+0.18633899812498247*fnodal_r[3]+0.18633899812498247*fnodal_r[2]-0.18633899812498247*fnodal_r[0]; + GhatR[15] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]-0.18633899812498247*fnodal_r[20]+0.18633899812498247*fnodal_r[18]-0.18633899812498247*fnodal_r[17]+0.18633899812498247*fnodal_r[15]+0.18633899812498247*fnodal_r[14]-0.18633899812498247*fnodal_r[12]-0.18633899812498247*fnodal_r[11]+0.18633899812498247*fnodal_r[9]+0.18633899812498247*fnodal_r[8]-0.18633899812498247*fnodal_r[6]+0.18633899812498247*fnodal_r[5]-0.18633899812498247*fnodal_r[3]-0.18633899812498247*fnodal_r[2]+0.18633899812498247*fnodal_r[0]; + GhatR[16] = 0.12422599874998831*fnodal_r[23]-0.24845199749997662*fnodal_r[22]+0.12422599874998831*fnodal_r[21]+0.12422599874998831*fnodal_r[20]-0.24845199749997662*fnodal_r[19]+0.12422599874998831*fnodal_r[18]+0.12422599874998831*fnodal_r[17]-0.24845199749997662*fnodal_r[16]+0.12422599874998831*fnodal_r[15]+0.12422599874998831*fnodal_r[14]-0.24845199749997662*fnodal_r[13]+0.12422599874998831*fnodal_r[12]+0.12422599874998831*fnodal_r[11]-0.24845199749997662*fnodal_r[10]+0.12422599874998831*fnodal_r[9]+0.12422599874998831*fnodal_r[8]-0.24845199749997662*fnodal_r[7]+0.12422599874998831*fnodal_r[6]+0.12422599874998831*fnodal_r[5]-0.24845199749997662*fnodal_r[4]+0.12422599874998831*fnodal_r[3]+0.12422599874998831*fnodal_r[2]-0.24845199749997662*fnodal_r[1]+0.12422599874998831*fnodal_r[0]; + GhatR[17] = 0.12422599874998837*fnodal_r[23]-0.24845199749997673*fnodal_r[22]+0.12422599874998837*fnodal_r[21]+0.12422599874998837*fnodal_r[20]-0.24845199749997673*fnodal_r[19]+0.12422599874998837*fnodal_r[18]+0.12422599874998837*fnodal_r[17]-0.24845199749997673*fnodal_r[16]+0.12422599874998837*fnodal_r[15]+0.12422599874998837*fnodal_r[14]-0.24845199749997673*fnodal_r[13]+0.12422599874998837*fnodal_r[12]-0.12422599874998837*fnodal_r[11]+0.24845199749997673*fnodal_r[10]-0.12422599874998837*fnodal_r[9]-0.12422599874998837*fnodal_r[8]+0.24845199749997673*fnodal_r[7]-0.12422599874998837*fnodal_r[6]-0.12422599874998837*fnodal_r[5]+0.24845199749997673*fnodal_r[4]-0.12422599874998837*fnodal_r[3]-0.12422599874998837*fnodal_r[2]+0.24845199749997673*fnodal_r[1]-0.12422599874998837*fnodal_r[0]; + GhatR[18] = 0.12422599874998837*fnodal_r[23]-0.24845199749997673*fnodal_r[22]+0.12422599874998837*fnodal_r[21]+0.12422599874998837*fnodal_r[20]-0.24845199749997673*fnodal_r[19]+0.12422599874998837*fnodal_r[18]-0.12422599874998837*fnodal_r[17]+0.24845199749997673*fnodal_r[16]-0.12422599874998837*fnodal_r[15]-0.12422599874998837*fnodal_r[14]+0.24845199749997673*fnodal_r[13]-0.12422599874998837*fnodal_r[12]+0.12422599874998837*fnodal_r[11]-0.24845199749997673*fnodal_r[10]+0.12422599874998837*fnodal_r[9]+0.12422599874998837*fnodal_r[8]-0.24845199749997673*fnodal_r[7]+0.12422599874998837*fnodal_r[6]-0.12422599874998837*fnodal_r[5]+0.24845199749997673*fnodal_r[4]-0.12422599874998837*fnodal_r[3]-0.12422599874998837*fnodal_r[2]+0.24845199749997673*fnodal_r[1]-0.12422599874998837*fnodal_r[0]; + GhatR[19] = 0.12422599874998837*fnodal_r[23]-0.24845199749997673*fnodal_r[22]+0.12422599874998837*fnodal_r[21]-0.12422599874998837*fnodal_r[20]+0.24845199749997673*fnodal_r[19]-0.12422599874998837*fnodal_r[18]+0.12422599874998837*fnodal_r[17]-0.24845199749997673*fnodal_r[16]+0.12422599874998837*fnodal_r[15]-0.12422599874998837*fnodal_r[14]+0.24845199749997673*fnodal_r[13]-0.12422599874998837*fnodal_r[12]+0.12422599874998837*fnodal_r[11]-0.24845199749997673*fnodal_r[10]+0.12422599874998837*fnodal_r[9]-0.12422599874998837*fnodal_r[8]+0.24845199749997673*fnodal_r[7]-0.12422599874998837*fnodal_r[6]+0.12422599874998837*fnodal_r[5]-0.24845199749997673*fnodal_r[4]+0.12422599874998837*fnodal_r[3]-0.12422599874998837*fnodal_r[2]+0.24845199749997673*fnodal_r[1]-0.12422599874998837*fnodal_r[0]; + GhatR[20] = 0.12422599874998831*fnodal_r[23]-0.24845199749997662*fnodal_r[22]+0.12422599874998831*fnodal_r[21]+0.12422599874998831*fnodal_r[20]-0.24845199749997662*fnodal_r[19]+0.12422599874998831*fnodal_r[18]-0.12422599874998831*fnodal_r[17]+0.24845199749997662*fnodal_r[16]-0.12422599874998831*fnodal_r[15]-0.12422599874998831*fnodal_r[14]+0.24845199749997662*fnodal_r[13]-0.12422599874998831*fnodal_r[12]-0.12422599874998831*fnodal_r[11]+0.24845199749997662*fnodal_r[10]-0.12422599874998831*fnodal_r[9]-0.12422599874998831*fnodal_r[8]+0.24845199749997662*fnodal_r[7]-0.12422599874998831*fnodal_r[6]+0.12422599874998831*fnodal_r[5]-0.24845199749997662*fnodal_r[4]+0.12422599874998831*fnodal_r[3]+0.12422599874998831*fnodal_r[2]-0.24845199749997662*fnodal_r[1]+0.12422599874998831*fnodal_r[0]; + GhatR[21] = 0.12422599874998831*fnodal_r[23]-0.24845199749997662*fnodal_r[22]+0.12422599874998831*fnodal_r[21]-0.12422599874998831*fnodal_r[20]+0.24845199749997662*fnodal_r[19]-0.12422599874998831*fnodal_r[18]+0.12422599874998831*fnodal_r[17]-0.24845199749997662*fnodal_r[16]+0.12422599874998831*fnodal_r[15]-0.12422599874998831*fnodal_r[14]+0.24845199749997662*fnodal_r[13]-0.12422599874998831*fnodal_r[12]-0.12422599874998831*fnodal_r[11]+0.24845199749997662*fnodal_r[10]-0.12422599874998831*fnodal_r[9]+0.12422599874998831*fnodal_r[8]-0.24845199749997662*fnodal_r[7]+0.12422599874998831*fnodal_r[6]-0.12422599874998831*fnodal_r[5]+0.24845199749997662*fnodal_r[4]-0.12422599874998831*fnodal_r[3]+0.12422599874998831*fnodal_r[2]-0.24845199749997662*fnodal_r[1]+0.12422599874998831*fnodal_r[0]; + GhatR[22] = 0.12422599874998831*fnodal_r[23]-0.24845199749997662*fnodal_r[22]+0.12422599874998831*fnodal_r[21]-0.12422599874998831*fnodal_r[20]+0.24845199749997662*fnodal_r[19]-0.12422599874998831*fnodal_r[18]-0.12422599874998831*fnodal_r[17]+0.24845199749997662*fnodal_r[16]-0.12422599874998831*fnodal_r[15]+0.12422599874998831*fnodal_r[14]-0.24845199749997662*fnodal_r[13]+0.12422599874998831*fnodal_r[12]+0.12422599874998831*fnodal_r[11]-0.24845199749997662*fnodal_r[10]+0.12422599874998831*fnodal_r[9]-0.12422599874998831*fnodal_r[8]+0.24845199749997662*fnodal_r[7]-0.12422599874998831*fnodal_r[6]-0.12422599874998831*fnodal_r[5]+0.24845199749997662*fnodal_r[4]-0.12422599874998831*fnodal_r[3]+0.12422599874998831*fnodal_r[2]-0.24845199749997662*fnodal_r[1]+0.12422599874998831*fnodal_r[0]; + GhatR[23] = 0.12422599874998837*fnodal_r[23]-0.24845199749997673*fnodal_r[22]+0.12422599874998837*fnodal_r[21]-0.12422599874998837*fnodal_r[20]+0.24845199749997673*fnodal_r[19]-0.12422599874998837*fnodal_r[18]-0.12422599874998837*fnodal_r[17]+0.24845199749997673*fnodal_r[16]-0.12422599874998837*fnodal_r[15]+0.12422599874998837*fnodal_r[14]-0.24845199749997673*fnodal_r[13]+0.12422599874998837*fnodal_r[12]-0.12422599874998837*fnodal_r[11]+0.24845199749997673*fnodal_r[10]-0.12422599874998837*fnodal_r[9]+0.12422599874998837*fnodal_r[8]-0.24845199749997673*fnodal_r[7]+0.12422599874998837*fnodal_r[6]+0.12422599874998837*fnodal_r[5]-0.24845199749997673*fnodal_r[4]+0.12422599874998837*fnodal_r[3]-0.12422599874998837*fnodal_r[2]+0.24845199749997673*fnodal_r[1]-0.12422599874998837*fnodal_r[0]; + + out[0] += (0.7071067811865475*GhatL[0]-0.7071067811865475*GhatR[0])*rdx2; + out[1] += (-(1.224744871391589*GhatR[0])-1.224744871391589*GhatL[0])*rdx2; + out[2] += (0.7071067811865475*GhatL[1]-0.7071067811865475*GhatR[1])*rdx2; + out[3] += (0.7071067811865475*GhatL[2]-0.7071067811865475*GhatR[2])*rdx2; + out[4] += (0.7071067811865475*GhatL[3]-0.7071067811865475*GhatR[3])*rdx2; + out[5] += (0.7071067811865475*GhatL[4]-0.7071067811865475*GhatR[4])*rdx2; + out[6] += (-(1.224744871391589*GhatR[1])-1.224744871391589*GhatL[1])*rdx2; + out[7] += (-(1.224744871391589*GhatR[2])-1.224744871391589*GhatL[2])*rdx2; + out[8] += (0.7071067811865475*GhatL[5]-0.7071067811865475*GhatR[5])*rdx2; + out[9] += (-(1.224744871391589*GhatR[3])-1.224744871391589*GhatL[3])*rdx2; + out[10] += (0.7071067811865475*GhatL[6]-0.7071067811865475*GhatR[6])*rdx2; + out[11] += (0.7071067811865475*GhatL[7]-0.7071067811865475*GhatR[7])*rdx2; + out[12] += (-(1.224744871391589*GhatR[4])-1.224744871391589*GhatL[4])*rdx2; + out[13] += (0.7071067811865475*GhatL[8]-0.7071067811865475*GhatR[8])*rdx2; + out[14] += (0.7071067811865475*GhatL[9]-0.7071067811865475*GhatR[9])*rdx2; + out[15] += (0.7071067811865475*GhatL[10]-0.7071067811865475*GhatR[10])*rdx2; + out[16] += (-(1.224744871391589*GhatR[5])-1.224744871391589*GhatL[5])*rdx2; + out[17] += (-(1.224744871391589*GhatR[6])-1.224744871391589*GhatL[6])*rdx2; + out[18] += (-(1.224744871391589*GhatR[7])-1.224744871391589*GhatL[7])*rdx2; + out[19] += (0.7071067811865475*GhatL[11]-0.7071067811865475*GhatR[11])*rdx2; + out[20] += (-(1.224744871391589*GhatR[8])-1.224744871391589*GhatL[8])*rdx2; + out[21] += (-(1.224744871391589*GhatR[9])-1.224744871391589*GhatL[9])*rdx2; + out[22] += (0.7071067811865475*GhatL[12]-0.7071067811865475*GhatR[12])*rdx2; + out[23] += (-(1.224744871391589*GhatR[10])-1.224744871391589*GhatL[10])*rdx2; + out[24] += (0.7071067811865475*GhatL[13]-0.7071067811865475*GhatR[13])*rdx2; + out[25] += (0.7071067811865475*GhatL[14]-0.7071067811865475*GhatR[14])*rdx2; + out[26] += (-(1.224744871391589*GhatR[11])-1.224744871391589*GhatL[11])*rdx2; + out[27] += (-(1.224744871391589*GhatR[12])-1.224744871391589*GhatL[12])*rdx2; + out[28] += (-(1.224744871391589*GhatR[13])-1.224744871391589*GhatL[13])*rdx2; + out[29] += (-(1.224744871391589*GhatR[14])-1.224744871391589*GhatL[14])*rdx2; + out[30] += (0.7071067811865475*GhatL[15]-0.7071067811865475*GhatR[15])*rdx2; + out[31] += (-(1.224744871391589*GhatR[15])-1.224744871391589*GhatL[15])*rdx2; + out[32] += (0.7071067811865475*GhatL[16]-0.7071067811865475*GhatR[16])*rdx2; + out[33] += (-(1.224744871391589*GhatR[16])-1.224744871391589*GhatL[16])*rdx2; + out[34] += (0.7071067811865475*GhatL[17]-0.7071067811865475*GhatR[17])*rdx2; + out[35] += (0.7071067811865475*GhatL[18]-0.7071067811865475*GhatR[18])*rdx2; + out[36] += (0.7071067811865475*GhatL[19]-0.7071067811865475*GhatR[19])*rdx2; + out[37] += (-(1.224744871391589*GhatR[17])-1.224744871391589*GhatL[17])*rdx2; + out[38] += (-(1.224744871391589*GhatR[18])-1.224744871391589*GhatL[18])*rdx2; + out[39] += (0.7071067811865475*GhatL[20]-0.7071067811865475*GhatR[20])*rdx2; + out[40] += (-(1.224744871391589*GhatR[19])-1.224744871391589*GhatL[19])*rdx2; + out[41] += (0.7071067811865475*GhatL[21]-0.7071067811865475*GhatR[21])*rdx2; + out[42] += (0.7071067811865475*GhatL[22]-0.7071067811865475*GhatR[22])*rdx2; + out[43] += (-(1.224744871391589*GhatR[20])-1.224744871391589*GhatL[20])*rdx2; + out[44] += (-(1.224744871391589*GhatR[21])-1.224744871391589*GhatL[21])*rdx2; + out[45] += (-(1.224744871391589*GhatR[22])-1.224744871391589*GhatL[22])*rdx2; + out[46] += (0.7071067811865475*GhatL[23]-0.7071067811865475*GhatR[23])*rdx2; + out[47] += (-(1.224744871391589*GhatR[23])-1.224744871391589*GhatL[23])*rdx2; + + return 0.0; + +} diff --git a/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfy_2x2v_ser_p1.c b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfy_2x2v_ser_p1.c new file mode 100644 index 0000000000..99918b2a94 --- /dev/null +++ b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfy_2x2v_ser_p1.c @@ -0,0 +1,74 @@ +#include +#include +GKYL_CU_DH double dg_gyrokinetic_passive_surfy_2x2v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_l, const double *vmap_prime_c, const double *vmap_prime_r, + const double *flux_surf_l, const double *flux_surf_r, + double* GKYL_RESTRICT out) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap_prime_l,vmap_prime_c,vmap_prime_r: velocity space mapping derivative in left, center and right cells. + // flux_surf_l: Surface expansion of phase space flux on the left. + // flux_surf_r: Surface expansion of phase space flux on the right. + // out: output increment in center cell. + + double rdz2 = 2.0/dxv[1]; + + double GhatL[12]= {0.0}; + double GhatR[12]= {0.0}; + + const double *fnodal_l = &flux_surf_l[12]; + const double *fnodal_r = &flux_surf_r[12]; + GhatL[0] = 0.1964185503295965*fnodal_l[11]+0.3142696805273545*fnodal_l[10]+0.1964185503295965*fnodal_l[9]+0.1964185503295965*fnodal_l[8]+0.3142696805273545*fnodal_l[7]+0.1964185503295965*fnodal_l[6]+0.1964185503295965*fnodal_l[5]+0.3142696805273545*fnodal_l[4]+0.1964185503295965*fnodal_l[3]+0.1964185503295965*fnodal_l[2]+0.3142696805273545*fnodal_l[1]+0.1964185503295965*fnodal_l[0]; + GhatL[1] = 0.1964185503295965*fnodal_l[11]+0.3142696805273545*fnodal_l[10]+0.1964185503295965*fnodal_l[9]+0.1964185503295965*fnodal_l[8]+0.3142696805273545*fnodal_l[7]+0.1964185503295965*fnodal_l[6]-0.1964185503295965*fnodal_l[5]-0.3142696805273545*fnodal_l[4]-0.1964185503295965*fnodal_l[3]-0.1964185503295965*fnodal_l[2]-0.3142696805273545*fnodal_l[1]-0.1964185503295965*fnodal_l[0]; + GhatL[2] = 0.2635231383473649*fnodal_l[11]-0.2635231383473649*fnodal_l[9]+0.2635231383473649*fnodal_l[8]-0.2635231383473649*fnodal_l[6]+0.2635231383473649*fnodal_l[5]-0.2635231383473649*fnodal_l[3]+0.2635231383473649*fnodal_l[2]-0.2635231383473649*fnodal_l[0]; + GhatL[3] = 0.1964185503295965*fnodal_l[11]+0.3142696805273545*fnodal_l[10]+0.1964185503295965*fnodal_l[9]-0.1964185503295965*fnodal_l[8]-0.3142696805273545*fnodal_l[7]-0.1964185503295965*fnodal_l[6]+0.1964185503295965*fnodal_l[5]+0.3142696805273545*fnodal_l[4]+0.1964185503295965*fnodal_l[3]-0.1964185503295965*fnodal_l[2]-0.3142696805273545*fnodal_l[1]-0.1964185503295965*fnodal_l[0]; + GhatL[4] = 0.2635231383473649*fnodal_l[11]-0.2635231383473649*fnodal_l[9]+0.2635231383473649*fnodal_l[8]-0.2635231383473649*fnodal_l[6]-0.2635231383473649*fnodal_l[5]+0.2635231383473649*fnodal_l[3]-0.2635231383473649*fnodal_l[2]+0.2635231383473649*fnodal_l[0]; + GhatL[5] = 0.1964185503295965*fnodal_l[11]+0.3142696805273545*fnodal_l[10]+0.1964185503295965*fnodal_l[9]-0.1964185503295965*fnodal_l[8]-0.3142696805273545*fnodal_l[7]-0.1964185503295965*fnodal_l[6]-0.1964185503295965*fnodal_l[5]-0.3142696805273545*fnodal_l[4]-0.1964185503295965*fnodal_l[3]+0.1964185503295965*fnodal_l[2]+0.3142696805273545*fnodal_l[1]+0.1964185503295965*fnodal_l[0]; + GhatL[6] = 0.2635231383473649*fnodal_l[11]-0.2635231383473649*fnodal_l[9]-0.2635231383473649*fnodal_l[8]+0.2635231383473649*fnodal_l[6]+0.2635231383473649*fnodal_l[5]-0.2635231383473649*fnodal_l[3]-0.2635231383473649*fnodal_l[2]+0.2635231383473649*fnodal_l[0]; + GhatL[7] = 0.2635231383473649*fnodal_l[11]-0.2635231383473649*fnodal_l[9]-0.2635231383473649*fnodal_l[8]+0.2635231383473649*fnodal_l[6]-0.2635231383473649*fnodal_l[5]+0.2635231383473649*fnodal_l[3]+0.2635231383473649*fnodal_l[2]-0.2635231383473649*fnodal_l[0]; + GhatL[8] = 0.17568209223157663*fnodal_l[11]-0.35136418446315326*fnodal_l[10]+0.17568209223157663*fnodal_l[9]+0.17568209223157663*fnodal_l[8]-0.35136418446315326*fnodal_l[7]+0.17568209223157663*fnodal_l[6]+0.17568209223157663*fnodal_l[5]-0.35136418446315326*fnodal_l[4]+0.17568209223157663*fnodal_l[3]+0.17568209223157663*fnodal_l[2]-0.35136418446315326*fnodal_l[1]+0.17568209223157663*fnodal_l[0]; + GhatL[9] = 0.1756820922315767*fnodal_l[11]-0.35136418446315343*fnodal_l[10]+0.1756820922315767*fnodal_l[9]+0.1756820922315767*fnodal_l[8]-0.35136418446315343*fnodal_l[7]+0.1756820922315767*fnodal_l[6]-0.1756820922315767*fnodal_l[5]+0.35136418446315343*fnodal_l[4]-0.1756820922315767*fnodal_l[3]-0.1756820922315767*fnodal_l[2]+0.35136418446315343*fnodal_l[1]-0.1756820922315767*fnodal_l[0]; + GhatL[10] = 0.1756820922315767*fnodal_l[11]-0.35136418446315343*fnodal_l[10]+0.1756820922315767*fnodal_l[9]-0.1756820922315767*fnodal_l[8]+0.35136418446315343*fnodal_l[7]-0.1756820922315767*fnodal_l[6]+0.1756820922315767*fnodal_l[5]-0.35136418446315343*fnodal_l[4]+0.1756820922315767*fnodal_l[3]-0.1756820922315767*fnodal_l[2]+0.35136418446315343*fnodal_l[1]-0.1756820922315767*fnodal_l[0]; + GhatL[11] = 0.17568209223157663*fnodal_l[11]-0.35136418446315326*fnodal_l[10]+0.17568209223157663*fnodal_l[9]-0.17568209223157663*fnodal_l[8]+0.35136418446315326*fnodal_l[7]-0.17568209223157663*fnodal_l[6]-0.17568209223157663*fnodal_l[5]+0.35136418446315326*fnodal_l[4]-0.17568209223157663*fnodal_l[3]+0.17568209223157663*fnodal_l[2]-0.35136418446315326*fnodal_l[1]+0.17568209223157663*fnodal_l[0]; + GhatR[0] = 0.1964185503295965*fnodal_r[11]+0.3142696805273545*fnodal_r[10]+0.1964185503295965*fnodal_r[9]+0.1964185503295965*fnodal_r[8]+0.3142696805273545*fnodal_r[7]+0.1964185503295965*fnodal_r[6]+0.1964185503295965*fnodal_r[5]+0.3142696805273545*fnodal_r[4]+0.1964185503295965*fnodal_r[3]+0.1964185503295965*fnodal_r[2]+0.3142696805273545*fnodal_r[1]+0.1964185503295965*fnodal_r[0]; + GhatR[1] = 0.1964185503295965*fnodal_r[11]+0.3142696805273545*fnodal_r[10]+0.1964185503295965*fnodal_r[9]+0.1964185503295965*fnodal_r[8]+0.3142696805273545*fnodal_r[7]+0.1964185503295965*fnodal_r[6]-0.1964185503295965*fnodal_r[5]-0.3142696805273545*fnodal_r[4]-0.1964185503295965*fnodal_r[3]-0.1964185503295965*fnodal_r[2]-0.3142696805273545*fnodal_r[1]-0.1964185503295965*fnodal_r[0]; + GhatR[2] = 0.2635231383473649*fnodal_r[11]-0.2635231383473649*fnodal_r[9]+0.2635231383473649*fnodal_r[8]-0.2635231383473649*fnodal_r[6]+0.2635231383473649*fnodal_r[5]-0.2635231383473649*fnodal_r[3]+0.2635231383473649*fnodal_r[2]-0.2635231383473649*fnodal_r[0]; + GhatR[3] = 0.1964185503295965*fnodal_r[11]+0.3142696805273545*fnodal_r[10]+0.1964185503295965*fnodal_r[9]-0.1964185503295965*fnodal_r[8]-0.3142696805273545*fnodal_r[7]-0.1964185503295965*fnodal_r[6]+0.1964185503295965*fnodal_r[5]+0.3142696805273545*fnodal_r[4]+0.1964185503295965*fnodal_r[3]-0.1964185503295965*fnodal_r[2]-0.3142696805273545*fnodal_r[1]-0.1964185503295965*fnodal_r[0]; + GhatR[4] = 0.2635231383473649*fnodal_r[11]-0.2635231383473649*fnodal_r[9]+0.2635231383473649*fnodal_r[8]-0.2635231383473649*fnodal_r[6]-0.2635231383473649*fnodal_r[5]+0.2635231383473649*fnodal_r[3]-0.2635231383473649*fnodal_r[2]+0.2635231383473649*fnodal_r[0]; + GhatR[5] = 0.1964185503295965*fnodal_r[11]+0.3142696805273545*fnodal_r[10]+0.1964185503295965*fnodal_r[9]-0.1964185503295965*fnodal_r[8]-0.3142696805273545*fnodal_r[7]-0.1964185503295965*fnodal_r[6]-0.1964185503295965*fnodal_r[5]-0.3142696805273545*fnodal_r[4]-0.1964185503295965*fnodal_r[3]+0.1964185503295965*fnodal_r[2]+0.3142696805273545*fnodal_r[1]+0.1964185503295965*fnodal_r[0]; + GhatR[6] = 0.2635231383473649*fnodal_r[11]-0.2635231383473649*fnodal_r[9]-0.2635231383473649*fnodal_r[8]+0.2635231383473649*fnodal_r[6]+0.2635231383473649*fnodal_r[5]-0.2635231383473649*fnodal_r[3]-0.2635231383473649*fnodal_r[2]+0.2635231383473649*fnodal_r[0]; + GhatR[7] = 0.2635231383473649*fnodal_r[11]-0.2635231383473649*fnodal_r[9]-0.2635231383473649*fnodal_r[8]+0.2635231383473649*fnodal_r[6]-0.2635231383473649*fnodal_r[5]+0.2635231383473649*fnodal_r[3]+0.2635231383473649*fnodal_r[2]-0.2635231383473649*fnodal_r[0]; + GhatR[8] = 0.17568209223157663*fnodal_r[11]-0.35136418446315326*fnodal_r[10]+0.17568209223157663*fnodal_r[9]+0.17568209223157663*fnodal_r[8]-0.35136418446315326*fnodal_r[7]+0.17568209223157663*fnodal_r[6]+0.17568209223157663*fnodal_r[5]-0.35136418446315326*fnodal_r[4]+0.17568209223157663*fnodal_r[3]+0.17568209223157663*fnodal_r[2]-0.35136418446315326*fnodal_r[1]+0.17568209223157663*fnodal_r[0]; + GhatR[9] = 0.1756820922315767*fnodal_r[11]-0.35136418446315343*fnodal_r[10]+0.1756820922315767*fnodal_r[9]+0.1756820922315767*fnodal_r[8]-0.35136418446315343*fnodal_r[7]+0.1756820922315767*fnodal_r[6]-0.1756820922315767*fnodal_r[5]+0.35136418446315343*fnodal_r[4]-0.1756820922315767*fnodal_r[3]-0.1756820922315767*fnodal_r[2]+0.35136418446315343*fnodal_r[1]-0.1756820922315767*fnodal_r[0]; + GhatR[10] = 0.1756820922315767*fnodal_r[11]-0.35136418446315343*fnodal_r[10]+0.1756820922315767*fnodal_r[9]-0.1756820922315767*fnodal_r[8]+0.35136418446315343*fnodal_r[7]-0.1756820922315767*fnodal_r[6]+0.1756820922315767*fnodal_r[5]-0.35136418446315343*fnodal_r[4]+0.1756820922315767*fnodal_r[3]-0.1756820922315767*fnodal_r[2]+0.35136418446315343*fnodal_r[1]-0.1756820922315767*fnodal_r[0]; + GhatR[11] = 0.17568209223157663*fnodal_r[11]-0.35136418446315326*fnodal_r[10]+0.17568209223157663*fnodal_r[9]-0.17568209223157663*fnodal_r[8]+0.35136418446315326*fnodal_r[7]-0.17568209223157663*fnodal_r[6]-0.17568209223157663*fnodal_r[5]+0.35136418446315326*fnodal_r[4]-0.17568209223157663*fnodal_r[3]+0.17568209223157663*fnodal_r[2]-0.35136418446315326*fnodal_r[1]+0.17568209223157663*fnodal_r[0]; + + out[0] += (0.7071067811865475*GhatL[0]-0.7071067811865475*GhatR[0])*rdz2; + out[1] += (0.7071067811865475*GhatL[1]-0.7071067811865475*GhatR[1])*rdz2; + out[2] += (-(1.224744871391589*GhatR[0])-1.224744871391589*GhatL[0])*rdz2; + out[3] += (0.7071067811865475*GhatL[2]-0.7071067811865475*GhatR[2])*rdz2; + out[4] += (0.7071067811865475*GhatL[3]-0.7071067811865475*GhatR[3])*rdz2; + out[5] += (-(1.224744871391589*GhatR[1])-1.224744871391589*GhatL[1])*rdz2; + out[6] += (0.7071067811865475*GhatL[4]-0.7071067811865475*GhatR[4])*rdz2; + out[7] += (-(1.224744871391589*GhatR[2])-1.224744871391589*GhatL[2])*rdz2; + out[8] += (0.7071067811865475*GhatL[5]-0.7071067811865475*GhatR[5])*rdz2; + out[9] += (-(1.224744871391589*GhatR[3])-1.224744871391589*GhatL[3])*rdz2; + out[10] += (0.7071067811865475*GhatL[6]-0.7071067811865475*GhatR[6])*rdz2; + out[11] += (-(1.224744871391589*GhatR[4])-1.224744871391589*GhatL[4])*rdz2; + out[12] += (-(1.224744871391589*GhatR[5])-1.224744871391589*GhatL[5])*rdz2; + out[13] += (0.7071067811865475*GhatL[7]-0.7071067811865475*GhatR[7])*rdz2; + out[14] += (-(1.224744871391589*GhatR[6])-1.224744871391589*GhatL[6])*rdz2; + out[15] += (-(1.224744871391589*GhatR[7])-1.224744871391589*GhatL[7])*rdz2; + out[16] += (0.7071067811865475*GhatL[8]-0.7071067811865475*GhatR[8])*rdz2; + out[17] += (0.7071067811865475*GhatL[9]-0.7071067811865475*GhatR[9])*rdz2; + out[18] += (-(1.224744871391589*GhatR[8])-1.224744871391589*GhatL[8])*rdz2; + out[19] += (0.7071067811865475*GhatL[10]-0.7071067811865475*GhatR[10])*rdz2; + out[20] += (-(1.224744871391589*GhatR[9])-1.224744871391589*GhatL[9])*rdz2; + out[21] += (0.7071067811865475*GhatL[11]-0.7071067811865475*GhatR[11])*rdz2; + out[22] += (-(1.224744871391589*GhatR[10])-1.224744871391589*GhatL[10])*rdz2; + out[23] += (-(1.224744871391589*GhatR[11])-1.224744871391589*GhatL[11])*rdz2; + + return 0.0; + +} diff --git a/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfy_3x2v_ser_p1.c b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfy_3x2v_ser_p1.c new file mode 100644 index 0000000000..1dd324d4ad --- /dev/null +++ b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfy_3x2v_ser_p1.c @@ -0,0 +1,122 @@ +#include +#include +GKYL_CU_DH double dg_gyrokinetic_passive_surfy_3x2v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_l, const double *vmap_prime_c, const double *vmap_prime_r, + const double *flux_surf_l, const double *flux_surf_r, + double* GKYL_RESTRICT out) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap_prime_l,vmap_prime_c,vmap_prime_r: velocity space mapping derivative in left, center and right cells. + // flux_surf_l: Surface expansion of phase space flux on the left. + // flux_surf_r: Surface expansion of phase space flux on the right. + // out: output increment in center cell. + + double rdy2 = 2.0/dxv[1]; + + double GhatL[24]= {0.0}; + double GhatR[24]= {0.0}; + + const double *fnodal_l = &flux_surf_l[24]; + const double *fnodal_r = &flux_surf_r[24]; + GhatL[0] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]+0.1388888888888889*fnodal_l[20]+0.2222222222222222*fnodal_l[19]+0.1388888888888889*fnodal_l[18]+0.1388888888888889*fnodal_l[17]+0.2222222222222222*fnodal_l[16]+0.1388888888888889*fnodal_l[15]+0.1388888888888889*fnodal_l[14]+0.2222222222222222*fnodal_l[13]+0.1388888888888889*fnodal_l[12]+0.1388888888888889*fnodal_l[11]+0.2222222222222222*fnodal_l[10]+0.1388888888888889*fnodal_l[9]+0.1388888888888889*fnodal_l[8]+0.2222222222222222*fnodal_l[7]+0.1388888888888889*fnodal_l[6]+0.1388888888888889*fnodal_l[5]+0.2222222222222222*fnodal_l[4]+0.1388888888888889*fnodal_l[3]+0.1388888888888889*fnodal_l[2]+0.2222222222222222*fnodal_l[1]+0.1388888888888889*fnodal_l[0]; + GhatL[1] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]+0.1388888888888889*fnodal_l[20]+0.2222222222222222*fnodal_l[19]+0.1388888888888889*fnodal_l[18]+0.1388888888888889*fnodal_l[17]+0.2222222222222222*fnodal_l[16]+0.1388888888888889*fnodal_l[15]+0.1388888888888889*fnodal_l[14]+0.2222222222222222*fnodal_l[13]+0.1388888888888889*fnodal_l[12]-0.1388888888888889*fnodal_l[11]-0.2222222222222222*fnodal_l[10]-0.1388888888888889*fnodal_l[9]-0.1388888888888889*fnodal_l[8]-0.2222222222222222*fnodal_l[7]-0.1388888888888889*fnodal_l[6]-0.1388888888888889*fnodal_l[5]-0.2222222222222222*fnodal_l[4]-0.1388888888888889*fnodal_l[3]-0.1388888888888889*fnodal_l[2]-0.2222222222222222*fnodal_l[1]-0.1388888888888889*fnodal_l[0]; + GhatL[2] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]+0.1388888888888889*fnodal_l[20]+0.2222222222222222*fnodal_l[19]+0.1388888888888889*fnodal_l[18]-0.1388888888888889*fnodal_l[17]-0.2222222222222222*fnodal_l[16]-0.1388888888888889*fnodal_l[15]-0.1388888888888889*fnodal_l[14]-0.2222222222222222*fnodal_l[13]-0.1388888888888889*fnodal_l[12]+0.1388888888888889*fnodal_l[11]+0.2222222222222222*fnodal_l[10]+0.1388888888888889*fnodal_l[9]+0.1388888888888889*fnodal_l[8]+0.2222222222222222*fnodal_l[7]+0.1388888888888889*fnodal_l[6]-0.1388888888888889*fnodal_l[5]-0.2222222222222222*fnodal_l[4]-0.1388888888888889*fnodal_l[3]-0.1388888888888889*fnodal_l[2]-0.2222222222222222*fnodal_l[1]-0.1388888888888889*fnodal_l[0]; + GhatL[3] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]+0.18633899812498247*fnodal_l[20]-0.18633899812498247*fnodal_l[18]+0.18633899812498247*fnodal_l[17]-0.18633899812498247*fnodal_l[15]+0.18633899812498247*fnodal_l[14]-0.18633899812498247*fnodal_l[12]+0.18633899812498247*fnodal_l[11]-0.18633899812498247*fnodal_l[9]+0.18633899812498247*fnodal_l[8]-0.18633899812498247*fnodal_l[6]+0.18633899812498247*fnodal_l[5]-0.18633899812498247*fnodal_l[3]+0.18633899812498247*fnodal_l[2]-0.18633899812498247*fnodal_l[0]; + GhatL[4] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]-0.1388888888888889*fnodal_l[20]-0.2222222222222222*fnodal_l[19]-0.1388888888888889*fnodal_l[18]+0.1388888888888889*fnodal_l[17]+0.2222222222222222*fnodal_l[16]+0.1388888888888889*fnodal_l[15]-0.1388888888888889*fnodal_l[14]-0.2222222222222222*fnodal_l[13]-0.1388888888888889*fnodal_l[12]+0.1388888888888889*fnodal_l[11]+0.2222222222222222*fnodal_l[10]+0.1388888888888889*fnodal_l[9]-0.1388888888888889*fnodal_l[8]-0.2222222222222222*fnodal_l[7]-0.1388888888888889*fnodal_l[6]+0.1388888888888889*fnodal_l[5]+0.2222222222222222*fnodal_l[4]+0.1388888888888889*fnodal_l[3]-0.1388888888888889*fnodal_l[2]-0.2222222222222222*fnodal_l[1]-0.1388888888888889*fnodal_l[0]; + GhatL[5] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]+0.1388888888888889*fnodal_l[20]+0.2222222222222222*fnodal_l[19]+0.1388888888888889*fnodal_l[18]-0.1388888888888889*fnodal_l[17]-0.2222222222222222*fnodal_l[16]-0.1388888888888889*fnodal_l[15]-0.1388888888888889*fnodal_l[14]-0.2222222222222222*fnodal_l[13]-0.1388888888888889*fnodal_l[12]-0.1388888888888889*fnodal_l[11]-0.2222222222222222*fnodal_l[10]-0.1388888888888889*fnodal_l[9]-0.1388888888888889*fnodal_l[8]-0.2222222222222222*fnodal_l[7]-0.1388888888888889*fnodal_l[6]+0.1388888888888889*fnodal_l[5]+0.2222222222222222*fnodal_l[4]+0.1388888888888889*fnodal_l[3]+0.1388888888888889*fnodal_l[2]+0.2222222222222222*fnodal_l[1]+0.1388888888888889*fnodal_l[0]; + GhatL[6] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]+0.18633899812498247*fnodal_l[20]-0.18633899812498247*fnodal_l[18]+0.18633899812498247*fnodal_l[17]-0.18633899812498247*fnodal_l[15]+0.18633899812498247*fnodal_l[14]-0.18633899812498247*fnodal_l[12]-0.18633899812498247*fnodal_l[11]+0.18633899812498247*fnodal_l[9]-0.18633899812498247*fnodal_l[8]+0.18633899812498247*fnodal_l[6]-0.18633899812498247*fnodal_l[5]+0.18633899812498247*fnodal_l[3]-0.18633899812498247*fnodal_l[2]+0.18633899812498247*fnodal_l[0]; + GhatL[7] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]+0.18633899812498247*fnodal_l[20]-0.18633899812498247*fnodal_l[18]-0.18633899812498247*fnodal_l[17]+0.18633899812498247*fnodal_l[15]-0.18633899812498247*fnodal_l[14]+0.18633899812498247*fnodal_l[12]+0.18633899812498247*fnodal_l[11]-0.18633899812498247*fnodal_l[9]+0.18633899812498247*fnodal_l[8]-0.18633899812498247*fnodal_l[6]-0.18633899812498247*fnodal_l[5]+0.18633899812498247*fnodal_l[3]-0.18633899812498247*fnodal_l[2]+0.18633899812498247*fnodal_l[0]; + GhatL[8] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]-0.1388888888888889*fnodal_l[20]-0.2222222222222222*fnodal_l[19]-0.1388888888888889*fnodal_l[18]+0.1388888888888889*fnodal_l[17]+0.2222222222222222*fnodal_l[16]+0.1388888888888889*fnodal_l[15]-0.1388888888888889*fnodal_l[14]-0.2222222222222222*fnodal_l[13]-0.1388888888888889*fnodal_l[12]-0.1388888888888889*fnodal_l[11]-0.2222222222222222*fnodal_l[10]-0.1388888888888889*fnodal_l[9]+0.1388888888888889*fnodal_l[8]+0.2222222222222222*fnodal_l[7]+0.1388888888888889*fnodal_l[6]-0.1388888888888889*fnodal_l[5]-0.2222222222222222*fnodal_l[4]-0.1388888888888889*fnodal_l[3]+0.1388888888888889*fnodal_l[2]+0.2222222222222222*fnodal_l[1]+0.1388888888888889*fnodal_l[0]; + GhatL[9] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]-0.1388888888888889*fnodal_l[20]-0.2222222222222222*fnodal_l[19]-0.1388888888888889*fnodal_l[18]-0.1388888888888889*fnodal_l[17]-0.2222222222222222*fnodal_l[16]-0.1388888888888889*fnodal_l[15]+0.1388888888888889*fnodal_l[14]+0.2222222222222222*fnodal_l[13]+0.1388888888888889*fnodal_l[12]+0.1388888888888889*fnodal_l[11]+0.2222222222222222*fnodal_l[10]+0.1388888888888889*fnodal_l[9]-0.1388888888888889*fnodal_l[8]-0.2222222222222222*fnodal_l[7]-0.1388888888888889*fnodal_l[6]-0.1388888888888889*fnodal_l[5]-0.2222222222222222*fnodal_l[4]-0.1388888888888889*fnodal_l[3]+0.1388888888888889*fnodal_l[2]+0.2222222222222222*fnodal_l[1]+0.1388888888888889*fnodal_l[0]; + GhatL[10] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]-0.18633899812498247*fnodal_l[20]+0.18633899812498247*fnodal_l[18]+0.18633899812498247*fnodal_l[17]-0.18633899812498247*fnodal_l[15]-0.18633899812498247*fnodal_l[14]+0.18633899812498247*fnodal_l[12]+0.18633899812498247*fnodal_l[11]-0.18633899812498247*fnodal_l[9]-0.18633899812498247*fnodal_l[8]+0.18633899812498247*fnodal_l[6]+0.18633899812498247*fnodal_l[5]-0.18633899812498247*fnodal_l[3]-0.18633899812498247*fnodal_l[2]+0.18633899812498247*fnodal_l[0]; + GhatL[11] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]+0.18633899812498247*fnodal_l[20]-0.18633899812498247*fnodal_l[18]-0.18633899812498247*fnodal_l[17]+0.18633899812498247*fnodal_l[15]-0.18633899812498247*fnodal_l[14]+0.18633899812498247*fnodal_l[12]-0.18633899812498247*fnodal_l[11]+0.18633899812498247*fnodal_l[9]-0.18633899812498247*fnodal_l[8]+0.18633899812498247*fnodal_l[6]+0.18633899812498247*fnodal_l[5]-0.18633899812498247*fnodal_l[3]+0.18633899812498247*fnodal_l[2]-0.18633899812498247*fnodal_l[0]; + GhatL[12] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]-0.1388888888888889*fnodal_l[20]-0.2222222222222222*fnodal_l[19]-0.1388888888888889*fnodal_l[18]-0.1388888888888889*fnodal_l[17]-0.2222222222222222*fnodal_l[16]-0.1388888888888889*fnodal_l[15]+0.1388888888888889*fnodal_l[14]+0.2222222222222222*fnodal_l[13]+0.1388888888888889*fnodal_l[12]-0.1388888888888889*fnodal_l[11]-0.2222222222222222*fnodal_l[10]-0.1388888888888889*fnodal_l[9]+0.1388888888888889*fnodal_l[8]+0.2222222222222222*fnodal_l[7]+0.1388888888888889*fnodal_l[6]+0.1388888888888889*fnodal_l[5]+0.2222222222222222*fnodal_l[4]+0.1388888888888889*fnodal_l[3]-0.1388888888888889*fnodal_l[2]-0.2222222222222222*fnodal_l[1]-0.1388888888888889*fnodal_l[0]; + GhatL[13] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]-0.18633899812498247*fnodal_l[20]+0.18633899812498247*fnodal_l[18]+0.18633899812498247*fnodal_l[17]-0.18633899812498247*fnodal_l[15]-0.18633899812498247*fnodal_l[14]+0.18633899812498247*fnodal_l[12]-0.18633899812498247*fnodal_l[11]+0.18633899812498247*fnodal_l[9]+0.18633899812498247*fnodal_l[8]-0.18633899812498247*fnodal_l[6]-0.18633899812498247*fnodal_l[5]+0.18633899812498247*fnodal_l[3]+0.18633899812498247*fnodal_l[2]-0.18633899812498247*fnodal_l[0]; + GhatL[14] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]-0.18633899812498247*fnodal_l[20]+0.18633899812498247*fnodal_l[18]-0.18633899812498247*fnodal_l[17]+0.18633899812498247*fnodal_l[15]+0.18633899812498247*fnodal_l[14]-0.18633899812498247*fnodal_l[12]+0.18633899812498247*fnodal_l[11]-0.18633899812498247*fnodal_l[9]-0.18633899812498247*fnodal_l[8]+0.18633899812498247*fnodal_l[6]-0.18633899812498247*fnodal_l[5]+0.18633899812498247*fnodal_l[3]+0.18633899812498247*fnodal_l[2]-0.18633899812498247*fnodal_l[0]; + GhatL[15] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]-0.18633899812498247*fnodal_l[20]+0.18633899812498247*fnodal_l[18]-0.18633899812498247*fnodal_l[17]+0.18633899812498247*fnodal_l[15]+0.18633899812498247*fnodal_l[14]-0.18633899812498247*fnodal_l[12]-0.18633899812498247*fnodal_l[11]+0.18633899812498247*fnodal_l[9]+0.18633899812498247*fnodal_l[8]-0.18633899812498247*fnodal_l[6]+0.18633899812498247*fnodal_l[5]-0.18633899812498247*fnodal_l[3]-0.18633899812498247*fnodal_l[2]+0.18633899812498247*fnodal_l[0]; + GhatL[16] = 0.12422599874998831*fnodal_l[23]-0.24845199749997662*fnodal_l[22]+0.12422599874998831*fnodal_l[21]+0.12422599874998831*fnodal_l[20]-0.24845199749997662*fnodal_l[19]+0.12422599874998831*fnodal_l[18]+0.12422599874998831*fnodal_l[17]-0.24845199749997662*fnodal_l[16]+0.12422599874998831*fnodal_l[15]+0.12422599874998831*fnodal_l[14]-0.24845199749997662*fnodal_l[13]+0.12422599874998831*fnodal_l[12]+0.12422599874998831*fnodal_l[11]-0.24845199749997662*fnodal_l[10]+0.12422599874998831*fnodal_l[9]+0.12422599874998831*fnodal_l[8]-0.24845199749997662*fnodal_l[7]+0.12422599874998831*fnodal_l[6]+0.12422599874998831*fnodal_l[5]-0.24845199749997662*fnodal_l[4]+0.12422599874998831*fnodal_l[3]+0.12422599874998831*fnodal_l[2]-0.24845199749997662*fnodal_l[1]+0.12422599874998831*fnodal_l[0]; + GhatL[17] = 0.12422599874998837*fnodal_l[23]-0.24845199749997673*fnodal_l[22]+0.12422599874998837*fnodal_l[21]+0.12422599874998837*fnodal_l[20]-0.24845199749997673*fnodal_l[19]+0.12422599874998837*fnodal_l[18]+0.12422599874998837*fnodal_l[17]-0.24845199749997673*fnodal_l[16]+0.12422599874998837*fnodal_l[15]+0.12422599874998837*fnodal_l[14]-0.24845199749997673*fnodal_l[13]+0.12422599874998837*fnodal_l[12]-0.12422599874998837*fnodal_l[11]+0.24845199749997673*fnodal_l[10]-0.12422599874998837*fnodal_l[9]-0.12422599874998837*fnodal_l[8]+0.24845199749997673*fnodal_l[7]-0.12422599874998837*fnodal_l[6]-0.12422599874998837*fnodal_l[5]+0.24845199749997673*fnodal_l[4]-0.12422599874998837*fnodal_l[3]-0.12422599874998837*fnodal_l[2]+0.24845199749997673*fnodal_l[1]-0.12422599874998837*fnodal_l[0]; + GhatL[18] = 0.12422599874998837*fnodal_l[23]-0.24845199749997673*fnodal_l[22]+0.12422599874998837*fnodal_l[21]+0.12422599874998837*fnodal_l[20]-0.24845199749997673*fnodal_l[19]+0.12422599874998837*fnodal_l[18]-0.12422599874998837*fnodal_l[17]+0.24845199749997673*fnodal_l[16]-0.12422599874998837*fnodal_l[15]-0.12422599874998837*fnodal_l[14]+0.24845199749997673*fnodal_l[13]-0.12422599874998837*fnodal_l[12]+0.12422599874998837*fnodal_l[11]-0.24845199749997673*fnodal_l[10]+0.12422599874998837*fnodal_l[9]+0.12422599874998837*fnodal_l[8]-0.24845199749997673*fnodal_l[7]+0.12422599874998837*fnodal_l[6]-0.12422599874998837*fnodal_l[5]+0.24845199749997673*fnodal_l[4]-0.12422599874998837*fnodal_l[3]-0.12422599874998837*fnodal_l[2]+0.24845199749997673*fnodal_l[1]-0.12422599874998837*fnodal_l[0]; + GhatL[19] = 0.12422599874998837*fnodal_l[23]-0.24845199749997673*fnodal_l[22]+0.12422599874998837*fnodal_l[21]-0.12422599874998837*fnodal_l[20]+0.24845199749997673*fnodal_l[19]-0.12422599874998837*fnodal_l[18]+0.12422599874998837*fnodal_l[17]-0.24845199749997673*fnodal_l[16]+0.12422599874998837*fnodal_l[15]-0.12422599874998837*fnodal_l[14]+0.24845199749997673*fnodal_l[13]-0.12422599874998837*fnodal_l[12]+0.12422599874998837*fnodal_l[11]-0.24845199749997673*fnodal_l[10]+0.12422599874998837*fnodal_l[9]-0.12422599874998837*fnodal_l[8]+0.24845199749997673*fnodal_l[7]-0.12422599874998837*fnodal_l[6]+0.12422599874998837*fnodal_l[5]-0.24845199749997673*fnodal_l[4]+0.12422599874998837*fnodal_l[3]-0.12422599874998837*fnodal_l[2]+0.24845199749997673*fnodal_l[1]-0.12422599874998837*fnodal_l[0]; + GhatL[20] = 0.12422599874998831*fnodal_l[23]-0.24845199749997662*fnodal_l[22]+0.12422599874998831*fnodal_l[21]+0.12422599874998831*fnodal_l[20]-0.24845199749997662*fnodal_l[19]+0.12422599874998831*fnodal_l[18]-0.12422599874998831*fnodal_l[17]+0.24845199749997662*fnodal_l[16]-0.12422599874998831*fnodal_l[15]-0.12422599874998831*fnodal_l[14]+0.24845199749997662*fnodal_l[13]-0.12422599874998831*fnodal_l[12]-0.12422599874998831*fnodal_l[11]+0.24845199749997662*fnodal_l[10]-0.12422599874998831*fnodal_l[9]-0.12422599874998831*fnodal_l[8]+0.24845199749997662*fnodal_l[7]-0.12422599874998831*fnodal_l[6]+0.12422599874998831*fnodal_l[5]-0.24845199749997662*fnodal_l[4]+0.12422599874998831*fnodal_l[3]+0.12422599874998831*fnodal_l[2]-0.24845199749997662*fnodal_l[1]+0.12422599874998831*fnodal_l[0]; + GhatL[21] = 0.12422599874998831*fnodal_l[23]-0.24845199749997662*fnodal_l[22]+0.12422599874998831*fnodal_l[21]-0.12422599874998831*fnodal_l[20]+0.24845199749997662*fnodal_l[19]-0.12422599874998831*fnodal_l[18]+0.12422599874998831*fnodal_l[17]-0.24845199749997662*fnodal_l[16]+0.12422599874998831*fnodal_l[15]-0.12422599874998831*fnodal_l[14]+0.24845199749997662*fnodal_l[13]-0.12422599874998831*fnodal_l[12]-0.12422599874998831*fnodal_l[11]+0.24845199749997662*fnodal_l[10]-0.12422599874998831*fnodal_l[9]+0.12422599874998831*fnodal_l[8]-0.24845199749997662*fnodal_l[7]+0.12422599874998831*fnodal_l[6]-0.12422599874998831*fnodal_l[5]+0.24845199749997662*fnodal_l[4]-0.12422599874998831*fnodal_l[3]+0.12422599874998831*fnodal_l[2]-0.24845199749997662*fnodal_l[1]+0.12422599874998831*fnodal_l[0]; + GhatL[22] = 0.12422599874998831*fnodal_l[23]-0.24845199749997662*fnodal_l[22]+0.12422599874998831*fnodal_l[21]-0.12422599874998831*fnodal_l[20]+0.24845199749997662*fnodal_l[19]-0.12422599874998831*fnodal_l[18]-0.12422599874998831*fnodal_l[17]+0.24845199749997662*fnodal_l[16]-0.12422599874998831*fnodal_l[15]+0.12422599874998831*fnodal_l[14]-0.24845199749997662*fnodal_l[13]+0.12422599874998831*fnodal_l[12]+0.12422599874998831*fnodal_l[11]-0.24845199749997662*fnodal_l[10]+0.12422599874998831*fnodal_l[9]-0.12422599874998831*fnodal_l[8]+0.24845199749997662*fnodal_l[7]-0.12422599874998831*fnodal_l[6]-0.12422599874998831*fnodal_l[5]+0.24845199749997662*fnodal_l[4]-0.12422599874998831*fnodal_l[3]+0.12422599874998831*fnodal_l[2]-0.24845199749997662*fnodal_l[1]+0.12422599874998831*fnodal_l[0]; + GhatL[23] = 0.12422599874998837*fnodal_l[23]-0.24845199749997673*fnodal_l[22]+0.12422599874998837*fnodal_l[21]-0.12422599874998837*fnodal_l[20]+0.24845199749997673*fnodal_l[19]-0.12422599874998837*fnodal_l[18]-0.12422599874998837*fnodal_l[17]+0.24845199749997673*fnodal_l[16]-0.12422599874998837*fnodal_l[15]+0.12422599874998837*fnodal_l[14]-0.24845199749997673*fnodal_l[13]+0.12422599874998837*fnodal_l[12]-0.12422599874998837*fnodal_l[11]+0.24845199749997673*fnodal_l[10]-0.12422599874998837*fnodal_l[9]+0.12422599874998837*fnodal_l[8]-0.24845199749997673*fnodal_l[7]+0.12422599874998837*fnodal_l[6]+0.12422599874998837*fnodal_l[5]-0.24845199749997673*fnodal_l[4]+0.12422599874998837*fnodal_l[3]-0.12422599874998837*fnodal_l[2]+0.24845199749997673*fnodal_l[1]-0.12422599874998837*fnodal_l[0]; + GhatR[0] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]+0.1388888888888889*fnodal_r[20]+0.2222222222222222*fnodal_r[19]+0.1388888888888889*fnodal_r[18]+0.1388888888888889*fnodal_r[17]+0.2222222222222222*fnodal_r[16]+0.1388888888888889*fnodal_r[15]+0.1388888888888889*fnodal_r[14]+0.2222222222222222*fnodal_r[13]+0.1388888888888889*fnodal_r[12]+0.1388888888888889*fnodal_r[11]+0.2222222222222222*fnodal_r[10]+0.1388888888888889*fnodal_r[9]+0.1388888888888889*fnodal_r[8]+0.2222222222222222*fnodal_r[7]+0.1388888888888889*fnodal_r[6]+0.1388888888888889*fnodal_r[5]+0.2222222222222222*fnodal_r[4]+0.1388888888888889*fnodal_r[3]+0.1388888888888889*fnodal_r[2]+0.2222222222222222*fnodal_r[1]+0.1388888888888889*fnodal_r[0]; + GhatR[1] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]+0.1388888888888889*fnodal_r[20]+0.2222222222222222*fnodal_r[19]+0.1388888888888889*fnodal_r[18]+0.1388888888888889*fnodal_r[17]+0.2222222222222222*fnodal_r[16]+0.1388888888888889*fnodal_r[15]+0.1388888888888889*fnodal_r[14]+0.2222222222222222*fnodal_r[13]+0.1388888888888889*fnodal_r[12]-0.1388888888888889*fnodal_r[11]-0.2222222222222222*fnodal_r[10]-0.1388888888888889*fnodal_r[9]-0.1388888888888889*fnodal_r[8]-0.2222222222222222*fnodal_r[7]-0.1388888888888889*fnodal_r[6]-0.1388888888888889*fnodal_r[5]-0.2222222222222222*fnodal_r[4]-0.1388888888888889*fnodal_r[3]-0.1388888888888889*fnodal_r[2]-0.2222222222222222*fnodal_r[1]-0.1388888888888889*fnodal_r[0]; + GhatR[2] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]+0.1388888888888889*fnodal_r[20]+0.2222222222222222*fnodal_r[19]+0.1388888888888889*fnodal_r[18]-0.1388888888888889*fnodal_r[17]-0.2222222222222222*fnodal_r[16]-0.1388888888888889*fnodal_r[15]-0.1388888888888889*fnodal_r[14]-0.2222222222222222*fnodal_r[13]-0.1388888888888889*fnodal_r[12]+0.1388888888888889*fnodal_r[11]+0.2222222222222222*fnodal_r[10]+0.1388888888888889*fnodal_r[9]+0.1388888888888889*fnodal_r[8]+0.2222222222222222*fnodal_r[7]+0.1388888888888889*fnodal_r[6]-0.1388888888888889*fnodal_r[5]-0.2222222222222222*fnodal_r[4]-0.1388888888888889*fnodal_r[3]-0.1388888888888889*fnodal_r[2]-0.2222222222222222*fnodal_r[1]-0.1388888888888889*fnodal_r[0]; + GhatR[3] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]+0.18633899812498247*fnodal_r[20]-0.18633899812498247*fnodal_r[18]+0.18633899812498247*fnodal_r[17]-0.18633899812498247*fnodal_r[15]+0.18633899812498247*fnodal_r[14]-0.18633899812498247*fnodal_r[12]+0.18633899812498247*fnodal_r[11]-0.18633899812498247*fnodal_r[9]+0.18633899812498247*fnodal_r[8]-0.18633899812498247*fnodal_r[6]+0.18633899812498247*fnodal_r[5]-0.18633899812498247*fnodal_r[3]+0.18633899812498247*fnodal_r[2]-0.18633899812498247*fnodal_r[0]; + GhatR[4] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]-0.1388888888888889*fnodal_r[20]-0.2222222222222222*fnodal_r[19]-0.1388888888888889*fnodal_r[18]+0.1388888888888889*fnodal_r[17]+0.2222222222222222*fnodal_r[16]+0.1388888888888889*fnodal_r[15]-0.1388888888888889*fnodal_r[14]-0.2222222222222222*fnodal_r[13]-0.1388888888888889*fnodal_r[12]+0.1388888888888889*fnodal_r[11]+0.2222222222222222*fnodal_r[10]+0.1388888888888889*fnodal_r[9]-0.1388888888888889*fnodal_r[8]-0.2222222222222222*fnodal_r[7]-0.1388888888888889*fnodal_r[6]+0.1388888888888889*fnodal_r[5]+0.2222222222222222*fnodal_r[4]+0.1388888888888889*fnodal_r[3]-0.1388888888888889*fnodal_r[2]-0.2222222222222222*fnodal_r[1]-0.1388888888888889*fnodal_r[0]; + GhatR[5] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]+0.1388888888888889*fnodal_r[20]+0.2222222222222222*fnodal_r[19]+0.1388888888888889*fnodal_r[18]-0.1388888888888889*fnodal_r[17]-0.2222222222222222*fnodal_r[16]-0.1388888888888889*fnodal_r[15]-0.1388888888888889*fnodal_r[14]-0.2222222222222222*fnodal_r[13]-0.1388888888888889*fnodal_r[12]-0.1388888888888889*fnodal_r[11]-0.2222222222222222*fnodal_r[10]-0.1388888888888889*fnodal_r[9]-0.1388888888888889*fnodal_r[8]-0.2222222222222222*fnodal_r[7]-0.1388888888888889*fnodal_r[6]+0.1388888888888889*fnodal_r[5]+0.2222222222222222*fnodal_r[4]+0.1388888888888889*fnodal_r[3]+0.1388888888888889*fnodal_r[2]+0.2222222222222222*fnodal_r[1]+0.1388888888888889*fnodal_r[0]; + GhatR[6] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]+0.18633899812498247*fnodal_r[20]-0.18633899812498247*fnodal_r[18]+0.18633899812498247*fnodal_r[17]-0.18633899812498247*fnodal_r[15]+0.18633899812498247*fnodal_r[14]-0.18633899812498247*fnodal_r[12]-0.18633899812498247*fnodal_r[11]+0.18633899812498247*fnodal_r[9]-0.18633899812498247*fnodal_r[8]+0.18633899812498247*fnodal_r[6]-0.18633899812498247*fnodal_r[5]+0.18633899812498247*fnodal_r[3]-0.18633899812498247*fnodal_r[2]+0.18633899812498247*fnodal_r[0]; + GhatR[7] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]+0.18633899812498247*fnodal_r[20]-0.18633899812498247*fnodal_r[18]-0.18633899812498247*fnodal_r[17]+0.18633899812498247*fnodal_r[15]-0.18633899812498247*fnodal_r[14]+0.18633899812498247*fnodal_r[12]+0.18633899812498247*fnodal_r[11]-0.18633899812498247*fnodal_r[9]+0.18633899812498247*fnodal_r[8]-0.18633899812498247*fnodal_r[6]-0.18633899812498247*fnodal_r[5]+0.18633899812498247*fnodal_r[3]-0.18633899812498247*fnodal_r[2]+0.18633899812498247*fnodal_r[0]; + GhatR[8] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]-0.1388888888888889*fnodal_r[20]-0.2222222222222222*fnodal_r[19]-0.1388888888888889*fnodal_r[18]+0.1388888888888889*fnodal_r[17]+0.2222222222222222*fnodal_r[16]+0.1388888888888889*fnodal_r[15]-0.1388888888888889*fnodal_r[14]-0.2222222222222222*fnodal_r[13]-0.1388888888888889*fnodal_r[12]-0.1388888888888889*fnodal_r[11]-0.2222222222222222*fnodal_r[10]-0.1388888888888889*fnodal_r[9]+0.1388888888888889*fnodal_r[8]+0.2222222222222222*fnodal_r[7]+0.1388888888888889*fnodal_r[6]-0.1388888888888889*fnodal_r[5]-0.2222222222222222*fnodal_r[4]-0.1388888888888889*fnodal_r[3]+0.1388888888888889*fnodal_r[2]+0.2222222222222222*fnodal_r[1]+0.1388888888888889*fnodal_r[0]; + GhatR[9] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]-0.1388888888888889*fnodal_r[20]-0.2222222222222222*fnodal_r[19]-0.1388888888888889*fnodal_r[18]-0.1388888888888889*fnodal_r[17]-0.2222222222222222*fnodal_r[16]-0.1388888888888889*fnodal_r[15]+0.1388888888888889*fnodal_r[14]+0.2222222222222222*fnodal_r[13]+0.1388888888888889*fnodal_r[12]+0.1388888888888889*fnodal_r[11]+0.2222222222222222*fnodal_r[10]+0.1388888888888889*fnodal_r[9]-0.1388888888888889*fnodal_r[8]-0.2222222222222222*fnodal_r[7]-0.1388888888888889*fnodal_r[6]-0.1388888888888889*fnodal_r[5]-0.2222222222222222*fnodal_r[4]-0.1388888888888889*fnodal_r[3]+0.1388888888888889*fnodal_r[2]+0.2222222222222222*fnodal_r[1]+0.1388888888888889*fnodal_r[0]; + GhatR[10] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]-0.18633899812498247*fnodal_r[20]+0.18633899812498247*fnodal_r[18]+0.18633899812498247*fnodal_r[17]-0.18633899812498247*fnodal_r[15]-0.18633899812498247*fnodal_r[14]+0.18633899812498247*fnodal_r[12]+0.18633899812498247*fnodal_r[11]-0.18633899812498247*fnodal_r[9]-0.18633899812498247*fnodal_r[8]+0.18633899812498247*fnodal_r[6]+0.18633899812498247*fnodal_r[5]-0.18633899812498247*fnodal_r[3]-0.18633899812498247*fnodal_r[2]+0.18633899812498247*fnodal_r[0]; + GhatR[11] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]+0.18633899812498247*fnodal_r[20]-0.18633899812498247*fnodal_r[18]-0.18633899812498247*fnodal_r[17]+0.18633899812498247*fnodal_r[15]-0.18633899812498247*fnodal_r[14]+0.18633899812498247*fnodal_r[12]-0.18633899812498247*fnodal_r[11]+0.18633899812498247*fnodal_r[9]-0.18633899812498247*fnodal_r[8]+0.18633899812498247*fnodal_r[6]+0.18633899812498247*fnodal_r[5]-0.18633899812498247*fnodal_r[3]+0.18633899812498247*fnodal_r[2]-0.18633899812498247*fnodal_r[0]; + GhatR[12] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]-0.1388888888888889*fnodal_r[20]-0.2222222222222222*fnodal_r[19]-0.1388888888888889*fnodal_r[18]-0.1388888888888889*fnodal_r[17]-0.2222222222222222*fnodal_r[16]-0.1388888888888889*fnodal_r[15]+0.1388888888888889*fnodal_r[14]+0.2222222222222222*fnodal_r[13]+0.1388888888888889*fnodal_r[12]-0.1388888888888889*fnodal_r[11]-0.2222222222222222*fnodal_r[10]-0.1388888888888889*fnodal_r[9]+0.1388888888888889*fnodal_r[8]+0.2222222222222222*fnodal_r[7]+0.1388888888888889*fnodal_r[6]+0.1388888888888889*fnodal_r[5]+0.2222222222222222*fnodal_r[4]+0.1388888888888889*fnodal_r[3]-0.1388888888888889*fnodal_r[2]-0.2222222222222222*fnodal_r[1]-0.1388888888888889*fnodal_r[0]; + GhatR[13] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]-0.18633899812498247*fnodal_r[20]+0.18633899812498247*fnodal_r[18]+0.18633899812498247*fnodal_r[17]-0.18633899812498247*fnodal_r[15]-0.18633899812498247*fnodal_r[14]+0.18633899812498247*fnodal_r[12]-0.18633899812498247*fnodal_r[11]+0.18633899812498247*fnodal_r[9]+0.18633899812498247*fnodal_r[8]-0.18633899812498247*fnodal_r[6]-0.18633899812498247*fnodal_r[5]+0.18633899812498247*fnodal_r[3]+0.18633899812498247*fnodal_r[2]-0.18633899812498247*fnodal_r[0]; + GhatR[14] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]-0.18633899812498247*fnodal_r[20]+0.18633899812498247*fnodal_r[18]-0.18633899812498247*fnodal_r[17]+0.18633899812498247*fnodal_r[15]+0.18633899812498247*fnodal_r[14]-0.18633899812498247*fnodal_r[12]+0.18633899812498247*fnodal_r[11]-0.18633899812498247*fnodal_r[9]-0.18633899812498247*fnodal_r[8]+0.18633899812498247*fnodal_r[6]-0.18633899812498247*fnodal_r[5]+0.18633899812498247*fnodal_r[3]+0.18633899812498247*fnodal_r[2]-0.18633899812498247*fnodal_r[0]; + GhatR[15] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]-0.18633899812498247*fnodal_r[20]+0.18633899812498247*fnodal_r[18]-0.18633899812498247*fnodal_r[17]+0.18633899812498247*fnodal_r[15]+0.18633899812498247*fnodal_r[14]-0.18633899812498247*fnodal_r[12]-0.18633899812498247*fnodal_r[11]+0.18633899812498247*fnodal_r[9]+0.18633899812498247*fnodal_r[8]-0.18633899812498247*fnodal_r[6]+0.18633899812498247*fnodal_r[5]-0.18633899812498247*fnodal_r[3]-0.18633899812498247*fnodal_r[2]+0.18633899812498247*fnodal_r[0]; + GhatR[16] = 0.12422599874998831*fnodal_r[23]-0.24845199749997662*fnodal_r[22]+0.12422599874998831*fnodal_r[21]+0.12422599874998831*fnodal_r[20]-0.24845199749997662*fnodal_r[19]+0.12422599874998831*fnodal_r[18]+0.12422599874998831*fnodal_r[17]-0.24845199749997662*fnodal_r[16]+0.12422599874998831*fnodal_r[15]+0.12422599874998831*fnodal_r[14]-0.24845199749997662*fnodal_r[13]+0.12422599874998831*fnodal_r[12]+0.12422599874998831*fnodal_r[11]-0.24845199749997662*fnodal_r[10]+0.12422599874998831*fnodal_r[9]+0.12422599874998831*fnodal_r[8]-0.24845199749997662*fnodal_r[7]+0.12422599874998831*fnodal_r[6]+0.12422599874998831*fnodal_r[5]-0.24845199749997662*fnodal_r[4]+0.12422599874998831*fnodal_r[3]+0.12422599874998831*fnodal_r[2]-0.24845199749997662*fnodal_r[1]+0.12422599874998831*fnodal_r[0]; + GhatR[17] = 0.12422599874998837*fnodal_r[23]-0.24845199749997673*fnodal_r[22]+0.12422599874998837*fnodal_r[21]+0.12422599874998837*fnodal_r[20]-0.24845199749997673*fnodal_r[19]+0.12422599874998837*fnodal_r[18]+0.12422599874998837*fnodal_r[17]-0.24845199749997673*fnodal_r[16]+0.12422599874998837*fnodal_r[15]+0.12422599874998837*fnodal_r[14]-0.24845199749997673*fnodal_r[13]+0.12422599874998837*fnodal_r[12]-0.12422599874998837*fnodal_r[11]+0.24845199749997673*fnodal_r[10]-0.12422599874998837*fnodal_r[9]-0.12422599874998837*fnodal_r[8]+0.24845199749997673*fnodal_r[7]-0.12422599874998837*fnodal_r[6]-0.12422599874998837*fnodal_r[5]+0.24845199749997673*fnodal_r[4]-0.12422599874998837*fnodal_r[3]-0.12422599874998837*fnodal_r[2]+0.24845199749997673*fnodal_r[1]-0.12422599874998837*fnodal_r[0]; + GhatR[18] = 0.12422599874998837*fnodal_r[23]-0.24845199749997673*fnodal_r[22]+0.12422599874998837*fnodal_r[21]+0.12422599874998837*fnodal_r[20]-0.24845199749997673*fnodal_r[19]+0.12422599874998837*fnodal_r[18]-0.12422599874998837*fnodal_r[17]+0.24845199749997673*fnodal_r[16]-0.12422599874998837*fnodal_r[15]-0.12422599874998837*fnodal_r[14]+0.24845199749997673*fnodal_r[13]-0.12422599874998837*fnodal_r[12]+0.12422599874998837*fnodal_r[11]-0.24845199749997673*fnodal_r[10]+0.12422599874998837*fnodal_r[9]+0.12422599874998837*fnodal_r[8]-0.24845199749997673*fnodal_r[7]+0.12422599874998837*fnodal_r[6]-0.12422599874998837*fnodal_r[5]+0.24845199749997673*fnodal_r[4]-0.12422599874998837*fnodal_r[3]-0.12422599874998837*fnodal_r[2]+0.24845199749997673*fnodal_r[1]-0.12422599874998837*fnodal_r[0]; + GhatR[19] = 0.12422599874998837*fnodal_r[23]-0.24845199749997673*fnodal_r[22]+0.12422599874998837*fnodal_r[21]-0.12422599874998837*fnodal_r[20]+0.24845199749997673*fnodal_r[19]-0.12422599874998837*fnodal_r[18]+0.12422599874998837*fnodal_r[17]-0.24845199749997673*fnodal_r[16]+0.12422599874998837*fnodal_r[15]-0.12422599874998837*fnodal_r[14]+0.24845199749997673*fnodal_r[13]-0.12422599874998837*fnodal_r[12]+0.12422599874998837*fnodal_r[11]-0.24845199749997673*fnodal_r[10]+0.12422599874998837*fnodal_r[9]-0.12422599874998837*fnodal_r[8]+0.24845199749997673*fnodal_r[7]-0.12422599874998837*fnodal_r[6]+0.12422599874998837*fnodal_r[5]-0.24845199749997673*fnodal_r[4]+0.12422599874998837*fnodal_r[3]-0.12422599874998837*fnodal_r[2]+0.24845199749997673*fnodal_r[1]-0.12422599874998837*fnodal_r[0]; + GhatR[20] = 0.12422599874998831*fnodal_r[23]-0.24845199749997662*fnodal_r[22]+0.12422599874998831*fnodal_r[21]+0.12422599874998831*fnodal_r[20]-0.24845199749997662*fnodal_r[19]+0.12422599874998831*fnodal_r[18]-0.12422599874998831*fnodal_r[17]+0.24845199749997662*fnodal_r[16]-0.12422599874998831*fnodal_r[15]-0.12422599874998831*fnodal_r[14]+0.24845199749997662*fnodal_r[13]-0.12422599874998831*fnodal_r[12]-0.12422599874998831*fnodal_r[11]+0.24845199749997662*fnodal_r[10]-0.12422599874998831*fnodal_r[9]-0.12422599874998831*fnodal_r[8]+0.24845199749997662*fnodal_r[7]-0.12422599874998831*fnodal_r[6]+0.12422599874998831*fnodal_r[5]-0.24845199749997662*fnodal_r[4]+0.12422599874998831*fnodal_r[3]+0.12422599874998831*fnodal_r[2]-0.24845199749997662*fnodal_r[1]+0.12422599874998831*fnodal_r[0]; + GhatR[21] = 0.12422599874998831*fnodal_r[23]-0.24845199749997662*fnodal_r[22]+0.12422599874998831*fnodal_r[21]-0.12422599874998831*fnodal_r[20]+0.24845199749997662*fnodal_r[19]-0.12422599874998831*fnodal_r[18]+0.12422599874998831*fnodal_r[17]-0.24845199749997662*fnodal_r[16]+0.12422599874998831*fnodal_r[15]-0.12422599874998831*fnodal_r[14]+0.24845199749997662*fnodal_r[13]-0.12422599874998831*fnodal_r[12]-0.12422599874998831*fnodal_r[11]+0.24845199749997662*fnodal_r[10]-0.12422599874998831*fnodal_r[9]+0.12422599874998831*fnodal_r[8]-0.24845199749997662*fnodal_r[7]+0.12422599874998831*fnodal_r[6]-0.12422599874998831*fnodal_r[5]+0.24845199749997662*fnodal_r[4]-0.12422599874998831*fnodal_r[3]+0.12422599874998831*fnodal_r[2]-0.24845199749997662*fnodal_r[1]+0.12422599874998831*fnodal_r[0]; + GhatR[22] = 0.12422599874998831*fnodal_r[23]-0.24845199749997662*fnodal_r[22]+0.12422599874998831*fnodal_r[21]-0.12422599874998831*fnodal_r[20]+0.24845199749997662*fnodal_r[19]-0.12422599874998831*fnodal_r[18]-0.12422599874998831*fnodal_r[17]+0.24845199749997662*fnodal_r[16]-0.12422599874998831*fnodal_r[15]+0.12422599874998831*fnodal_r[14]-0.24845199749997662*fnodal_r[13]+0.12422599874998831*fnodal_r[12]+0.12422599874998831*fnodal_r[11]-0.24845199749997662*fnodal_r[10]+0.12422599874998831*fnodal_r[9]-0.12422599874998831*fnodal_r[8]+0.24845199749997662*fnodal_r[7]-0.12422599874998831*fnodal_r[6]-0.12422599874998831*fnodal_r[5]+0.24845199749997662*fnodal_r[4]-0.12422599874998831*fnodal_r[3]+0.12422599874998831*fnodal_r[2]-0.24845199749997662*fnodal_r[1]+0.12422599874998831*fnodal_r[0]; + GhatR[23] = 0.12422599874998837*fnodal_r[23]-0.24845199749997673*fnodal_r[22]+0.12422599874998837*fnodal_r[21]-0.12422599874998837*fnodal_r[20]+0.24845199749997673*fnodal_r[19]-0.12422599874998837*fnodal_r[18]-0.12422599874998837*fnodal_r[17]+0.24845199749997673*fnodal_r[16]-0.12422599874998837*fnodal_r[15]+0.12422599874998837*fnodal_r[14]-0.24845199749997673*fnodal_r[13]+0.12422599874998837*fnodal_r[12]-0.12422599874998837*fnodal_r[11]+0.24845199749997673*fnodal_r[10]-0.12422599874998837*fnodal_r[9]+0.12422599874998837*fnodal_r[8]-0.24845199749997673*fnodal_r[7]+0.12422599874998837*fnodal_r[6]+0.12422599874998837*fnodal_r[5]-0.24845199749997673*fnodal_r[4]+0.12422599874998837*fnodal_r[3]-0.12422599874998837*fnodal_r[2]+0.24845199749997673*fnodal_r[1]-0.12422599874998837*fnodal_r[0]; + + out[0] += (0.7071067811865475*GhatL[0]-0.7071067811865475*GhatR[0])*rdy2; + out[1] += (0.7071067811865475*GhatL[1]-0.7071067811865475*GhatR[1])*rdy2; + out[2] += (-(1.224744871391589*GhatR[0])-1.224744871391589*GhatL[0])*rdy2; + out[3] += (0.7071067811865475*GhatL[2]-0.7071067811865475*GhatR[2])*rdy2; + out[4] += (0.7071067811865475*GhatL[3]-0.7071067811865475*GhatR[3])*rdy2; + out[5] += (0.7071067811865475*GhatL[4]-0.7071067811865475*GhatR[4])*rdy2; + out[6] += (-(1.224744871391589*GhatR[1])-1.224744871391589*GhatL[1])*rdy2; + out[7] += (0.7071067811865475*GhatL[5]-0.7071067811865475*GhatR[5])*rdy2; + out[8] += (-(1.224744871391589*GhatR[2])-1.224744871391589*GhatL[2])*rdy2; + out[9] += (0.7071067811865475*GhatL[6]-0.7071067811865475*GhatR[6])*rdy2; + out[10] += (-(1.224744871391589*GhatR[3])-1.224744871391589*GhatL[3])*rdy2; + out[11] += (0.7071067811865475*GhatL[7]-0.7071067811865475*GhatR[7])*rdy2; + out[12] += (0.7071067811865475*GhatL[8]-0.7071067811865475*GhatR[8])*rdy2; + out[13] += (-(1.224744871391589*GhatR[4])-1.224744871391589*GhatL[4])*rdy2; + out[14] += (0.7071067811865475*GhatL[9]-0.7071067811865475*GhatR[9])*rdy2; + out[15] += (0.7071067811865475*GhatL[10]-0.7071067811865475*GhatR[10])*rdy2; + out[16] += (-(1.224744871391589*GhatR[5])-1.224744871391589*GhatL[5])*rdy2; + out[17] += (-(1.224744871391589*GhatR[6])-1.224744871391589*GhatL[6])*rdy2; + out[18] += (0.7071067811865475*GhatL[11]-0.7071067811865475*GhatR[11])*rdy2; + out[19] += (-(1.224744871391589*GhatR[7])-1.224744871391589*GhatL[7])*rdy2; + out[20] += (-(1.224744871391589*GhatR[8])-1.224744871391589*GhatL[8])*rdy2; + out[21] += (0.7071067811865475*GhatL[12]-0.7071067811865475*GhatR[12])*rdy2; + out[22] += (-(1.224744871391589*GhatR[9])-1.224744871391589*GhatL[9])*rdy2; + out[23] += (0.7071067811865475*GhatL[13]-0.7071067811865475*GhatR[13])*rdy2; + out[24] += (-(1.224744871391589*GhatR[10])-1.224744871391589*GhatL[10])*rdy2; + out[25] += (0.7071067811865475*GhatL[14]-0.7071067811865475*GhatR[14])*rdy2; + out[26] += (-(1.224744871391589*GhatR[11])-1.224744871391589*GhatL[11])*rdy2; + out[27] += (-(1.224744871391589*GhatR[12])-1.224744871391589*GhatL[12])*rdy2; + out[28] += (-(1.224744871391589*GhatR[13])-1.224744871391589*GhatL[13])*rdy2; + out[29] += (0.7071067811865475*GhatL[15]-0.7071067811865475*GhatR[15])*rdy2; + out[30] += (-(1.224744871391589*GhatR[14])-1.224744871391589*GhatL[14])*rdy2; + out[31] += (-(1.224744871391589*GhatR[15])-1.224744871391589*GhatL[15])*rdy2; + out[32] += (0.7071067811865475*GhatL[16]-0.7071067811865475*GhatR[16])*rdy2; + out[33] += (0.7071067811865475*GhatL[17]-0.7071067811865475*GhatR[17])*rdy2; + out[34] += (-(1.224744871391589*GhatR[16])-1.224744871391589*GhatL[16])*rdy2; + out[35] += (0.7071067811865475*GhatL[18]-0.7071067811865475*GhatR[18])*rdy2; + out[36] += (0.7071067811865475*GhatL[19]-0.7071067811865475*GhatR[19])*rdy2; + out[37] += (-(1.224744871391589*GhatR[17])-1.224744871391589*GhatL[17])*rdy2; + out[38] += (0.7071067811865475*GhatL[20]-0.7071067811865475*GhatR[20])*rdy2; + out[39] += (-(1.224744871391589*GhatR[18])-1.224744871391589*GhatL[18])*rdy2; + out[40] += (0.7071067811865475*GhatL[21]-0.7071067811865475*GhatR[21])*rdy2; + out[41] += (-(1.224744871391589*GhatR[19])-1.224744871391589*GhatL[19])*rdy2; + out[42] += (0.7071067811865475*GhatL[22]-0.7071067811865475*GhatR[22])*rdy2; + out[43] += (-(1.224744871391589*GhatR[20])-1.224744871391589*GhatL[20])*rdy2; + out[44] += (-(1.224744871391589*GhatR[21])-1.224744871391589*GhatL[21])*rdy2; + out[45] += (0.7071067811865475*GhatL[23]-0.7071067811865475*GhatR[23])*rdy2; + out[46] += (-(1.224744871391589*GhatR[22])-1.224744871391589*GhatL[22])*rdy2; + out[47] += (-(1.224744871391589*GhatR[23])-1.224744871391589*GhatL[23])*rdy2; + + return 0.0; + +} diff --git a/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfz_3x2v_ser_p1.c b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfz_3x2v_ser_p1.c new file mode 100644 index 0000000000..a2931aa6dd --- /dev/null +++ b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfz_3x2v_ser_p1.c @@ -0,0 +1,122 @@ +#include +#include +GKYL_CU_DH double dg_gyrokinetic_passive_surfz_3x2v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_l, const double *vmap_prime_c, const double *vmap_prime_r, + const double *flux_surf_l, const double *flux_surf_r, + double* GKYL_RESTRICT out) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap_prime_l,vmap_prime_c,vmap_prime_r: velocity space mapping derivative in left, center and right cells. + // flux_surf_l: Surface expansion of phase space flux on the left. + // flux_surf_r: Surface expansion of phase space flux on the right. + // out: output increment in center cell. + + double rdz2 = 2.0/dxv[2]; + + double GhatL[24]= {0.0}; + double GhatR[24]= {0.0}; + + const double *fnodal_l = &flux_surf_l[48]; + const double *fnodal_r = &flux_surf_r[48]; + GhatL[0] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]+0.1388888888888889*fnodal_l[20]+0.2222222222222222*fnodal_l[19]+0.1388888888888889*fnodal_l[18]+0.1388888888888889*fnodal_l[17]+0.2222222222222222*fnodal_l[16]+0.1388888888888889*fnodal_l[15]+0.1388888888888889*fnodal_l[14]+0.2222222222222222*fnodal_l[13]+0.1388888888888889*fnodal_l[12]+0.1388888888888889*fnodal_l[11]+0.2222222222222222*fnodal_l[10]+0.1388888888888889*fnodal_l[9]+0.1388888888888889*fnodal_l[8]+0.2222222222222222*fnodal_l[7]+0.1388888888888889*fnodal_l[6]+0.1388888888888889*fnodal_l[5]+0.2222222222222222*fnodal_l[4]+0.1388888888888889*fnodal_l[3]+0.1388888888888889*fnodal_l[2]+0.2222222222222222*fnodal_l[1]+0.1388888888888889*fnodal_l[0]; + GhatL[1] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]+0.1388888888888889*fnodal_l[20]+0.2222222222222222*fnodal_l[19]+0.1388888888888889*fnodal_l[18]+0.1388888888888889*fnodal_l[17]+0.2222222222222222*fnodal_l[16]+0.1388888888888889*fnodal_l[15]+0.1388888888888889*fnodal_l[14]+0.2222222222222222*fnodal_l[13]+0.1388888888888889*fnodal_l[12]-0.1388888888888889*fnodal_l[11]-0.2222222222222222*fnodal_l[10]-0.1388888888888889*fnodal_l[9]-0.1388888888888889*fnodal_l[8]-0.2222222222222222*fnodal_l[7]-0.1388888888888889*fnodal_l[6]-0.1388888888888889*fnodal_l[5]-0.2222222222222222*fnodal_l[4]-0.1388888888888889*fnodal_l[3]-0.1388888888888889*fnodal_l[2]-0.2222222222222222*fnodal_l[1]-0.1388888888888889*fnodal_l[0]; + GhatL[2] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]+0.1388888888888889*fnodal_l[20]+0.2222222222222222*fnodal_l[19]+0.1388888888888889*fnodal_l[18]-0.1388888888888889*fnodal_l[17]-0.2222222222222222*fnodal_l[16]-0.1388888888888889*fnodal_l[15]-0.1388888888888889*fnodal_l[14]-0.2222222222222222*fnodal_l[13]-0.1388888888888889*fnodal_l[12]+0.1388888888888889*fnodal_l[11]+0.2222222222222222*fnodal_l[10]+0.1388888888888889*fnodal_l[9]+0.1388888888888889*fnodal_l[8]+0.2222222222222222*fnodal_l[7]+0.1388888888888889*fnodal_l[6]-0.1388888888888889*fnodal_l[5]-0.2222222222222222*fnodal_l[4]-0.1388888888888889*fnodal_l[3]-0.1388888888888889*fnodal_l[2]-0.2222222222222222*fnodal_l[1]-0.1388888888888889*fnodal_l[0]; + GhatL[3] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]+0.18633899812498247*fnodal_l[20]-0.18633899812498247*fnodal_l[18]+0.18633899812498247*fnodal_l[17]-0.18633899812498247*fnodal_l[15]+0.18633899812498247*fnodal_l[14]-0.18633899812498247*fnodal_l[12]+0.18633899812498247*fnodal_l[11]-0.18633899812498247*fnodal_l[9]+0.18633899812498247*fnodal_l[8]-0.18633899812498247*fnodal_l[6]+0.18633899812498247*fnodal_l[5]-0.18633899812498247*fnodal_l[3]+0.18633899812498247*fnodal_l[2]-0.18633899812498247*fnodal_l[0]; + GhatL[4] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]-0.1388888888888889*fnodal_l[20]-0.2222222222222222*fnodal_l[19]-0.1388888888888889*fnodal_l[18]+0.1388888888888889*fnodal_l[17]+0.2222222222222222*fnodal_l[16]+0.1388888888888889*fnodal_l[15]-0.1388888888888889*fnodal_l[14]-0.2222222222222222*fnodal_l[13]-0.1388888888888889*fnodal_l[12]+0.1388888888888889*fnodal_l[11]+0.2222222222222222*fnodal_l[10]+0.1388888888888889*fnodal_l[9]-0.1388888888888889*fnodal_l[8]-0.2222222222222222*fnodal_l[7]-0.1388888888888889*fnodal_l[6]+0.1388888888888889*fnodal_l[5]+0.2222222222222222*fnodal_l[4]+0.1388888888888889*fnodal_l[3]-0.1388888888888889*fnodal_l[2]-0.2222222222222222*fnodal_l[1]-0.1388888888888889*fnodal_l[0]; + GhatL[5] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]+0.1388888888888889*fnodal_l[20]+0.2222222222222222*fnodal_l[19]+0.1388888888888889*fnodal_l[18]-0.1388888888888889*fnodal_l[17]-0.2222222222222222*fnodal_l[16]-0.1388888888888889*fnodal_l[15]-0.1388888888888889*fnodal_l[14]-0.2222222222222222*fnodal_l[13]-0.1388888888888889*fnodal_l[12]-0.1388888888888889*fnodal_l[11]-0.2222222222222222*fnodal_l[10]-0.1388888888888889*fnodal_l[9]-0.1388888888888889*fnodal_l[8]-0.2222222222222222*fnodal_l[7]-0.1388888888888889*fnodal_l[6]+0.1388888888888889*fnodal_l[5]+0.2222222222222222*fnodal_l[4]+0.1388888888888889*fnodal_l[3]+0.1388888888888889*fnodal_l[2]+0.2222222222222222*fnodal_l[1]+0.1388888888888889*fnodal_l[0]; + GhatL[6] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]+0.18633899812498247*fnodal_l[20]-0.18633899812498247*fnodal_l[18]+0.18633899812498247*fnodal_l[17]-0.18633899812498247*fnodal_l[15]+0.18633899812498247*fnodal_l[14]-0.18633899812498247*fnodal_l[12]-0.18633899812498247*fnodal_l[11]+0.18633899812498247*fnodal_l[9]-0.18633899812498247*fnodal_l[8]+0.18633899812498247*fnodal_l[6]-0.18633899812498247*fnodal_l[5]+0.18633899812498247*fnodal_l[3]-0.18633899812498247*fnodal_l[2]+0.18633899812498247*fnodal_l[0]; + GhatL[7] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]+0.18633899812498247*fnodal_l[20]-0.18633899812498247*fnodal_l[18]-0.18633899812498247*fnodal_l[17]+0.18633899812498247*fnodal_l[15]-0.18633899812498247*fnodal_l[14]+0.18633899812498247*fnodal_l[12]+0.18633899812498247*fnodal_l[11]-0.18633899812498247*fnodal_l[9]+0.18633899812498247*fnodal_l[8]-0.18633899812498247*fnodal_l[6]-0.18633899812498247*fnodal_l[5]+0.18633899812498247*fnodal_l[3]-0.18633899812498247*fnodal_l[2]+0.18633899812498247*fnodal_l[0]; + GhatL[8] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]-0.1388888888888889*fnodal_l[20]-0.2222222222222222*fnodal_l[19]-0.1388888888888889*fnodal_l[18]+0.1388888888888889*fnodal_l[17]+0.2222222222222222*fnodal_l[16]+0.1388888888888889*fnodal_l[15]-0.1388888888888889*fnodal_l[14]-0.2222222222222222*fnodal_l[13]-0.1388888888888889*fnodal_l[12]-0.1388888888888889*fnodal_l[11]-0.2222222222222222*fnodal_l[10]-0.1388888888888889*fnodal_l[9]+0.1388888888888889*fnodal_l[8]+0.2222222222222222*fnodal_l[7]+0.1388888888888889*fnodal_l[6]-0.1388888888888889*fnodal_l[5]-0.2222222222222222*fnodal_l[4]-0.1388888888888889*fnodal_l[3]+0.1388888888888889*fnodal_l[2]+0.2222222222222222*fnodal_l[1]+0.1388888888888889*fnodal_l[0]; + GhatL[9] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]-0.1388888888888889*fnodal_l[20]-0.2222222222222222*fnodal_l[19]-0.1388888888888889*fnodal_l[18]-0.1388888888888889*fnodal_l[17]-0.2222222222222222*fnodal_l[16]-0.1388888888888889*fnodal_l[15]+0.1388888888888889*fnodal_l[14]+0.2222222222222222*fnodal_l[13]+0.1388888888888889*fnodal_l[12]+0.1388888888888889*fnodal_l[11]+0.2222222222222222*fnodal_l[10]+0.1388888888888889*fnodal_l[9]-0.1388888888888889*fnodal_l[8]-0.2222222222222222*fnodal_l[7]-0.1388888888888889*fnodal_l[6]-0.1388888888888889*fnodal_l[5]-0.2222222222222222*fnodal_l[4]-0.1388888888888889*fnodal_l[3]+0.1388888888888889*fnodal_l[2]+0.2222222222222222*fnodal_l[1]+0.1388888888888889*fnodal_l[0]; + GhatL[10] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]-0.18633899812498247*fnodal_l[20]+0.18633899812498247*fnodal_l[18]+0.18633899812498247*fnodal_l[17]-0.18633899812498247*fnodal_l[15]-0.18633899812498247*fnodal_l[14]+0.18633899812498247*fnodal_l[12]+0.18633899812498247*fnodal_l[11]-0.18633899812498247*fnodal_l[9]-0.18633899812498247*fnodal_l[8]+0.18633899812498247*fnodal_l[6]+0.18633899812498247*fnodal_l[5]-0.18633899812498247*fnodal_l[3]-0.18633899812498247*fnodal_l[2]+0.18633899812498247*fnodal_l[0]; + GhatL[11] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]+0.18633899812498247*fnodal_l[20]-0.18633899812498247*fnodal_l[18]-0.18633899812498247*fnodal_l[17]+0.18633899812498247*fnodal_l[15]-0.18633899812498247*fnodal_l[14]+0.18633899812498247*fnodal_l[12]-0.18633899812498247*fnodal_l[11]+0.18633899812498247*fnodal_l[9]-0.18633899812498247*fnodal_l[8]+0.18633899812498247*fnodal_l[6]+0.18633899812498247*fnodal_l[5]-0.18633899812498247*fnodal_l[3]+0.18633899812498247*fnodal_l[2]-0.18633899812498247*fnodal_l[0]; + GhatL[12] = 0.1388888888888889*fnodal_l[23]+0.2222222222222222*fnodal_l[22]+0.1388888888888889*fnodal_l[21]-0.1388888888888889*fnodal_l[20]-0.2222222222222222*fnodal_l[19]-0.1388888888888889*fnodal_l[18]-0.1388888888888889*fnodal_l[17]-0.2222222222222222*fnodal_l[16]-0.1388888888888889*fnodal_l[15]+0.1388888888888889*fnodal_l[14]+0.2222222222222222*fnodal_l[13]+0.1388888888888889*fnodal_l[12]-0.1388888888888889*fnodal_l[11]-0.2222222222222222*fnodal_l[10]-0.1388888888888889*fnodal_l[9]+0.1388888888888889*fnodal_l[8]+0.2222222222222222*fnodal_l[7]+0.1388888888888889*fnodal_l[6]+0.1388888888888889*fnodal_l[5]+0.2222222222222222*fnodal_l[4]+0.1388888888888889*fnodal_l[3]-0.1388888888888889*fnodal_l[2]-0.2222222222222222*fnodal_l[1]-0.1388888888888889*fnodal_l[0]; + GhatL[13] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]-0.18633899812498247*fnodal_l[20]+0.18633899812498247*fnodal_l[18]+0.18633899812498247*fnodal_l[17]-0.18633899812498247*fnodal_l[15]-0.18633899812498247*fnodal_l[14]+0.18633899812498247*fnodal_l[12]-0.18633899812498247*fnodal_l[11]+0.18633899812498247*fnodal_l[9]+0.18633899812498247*fnodal_l[8]-0.18633899812498247*fnodal_l[6]-0.18633899812498247*fnodal_l[5]+0.18633899812498247*fnodal_l[3]+0.18633899812498247*fnodal_l[2]-0.18633899812498247*fnodal_l[0]; + GhatL[14] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]-0.18633899812498247*fnodal_l[20]+0.18633899812498247*fnodal_l[18]-0.18633899812498247*fnodal_l[17]+0.18633899812498247*fnodal_l[15]+0.18633899812498247*fnodal_l[14]-0.18633899812498247*fnodal_l[12]+0.18633899812498247*fnodal_l[11]-0.18633899812498247*fnodal_l[9]-0.18633899812498247*fnodal_l[8]+0.18633899812498247*fnodal_l[6]-0.18633899812498247*fnodal_l[5]+0.18633899812498247*fnodal_l[3]+0.18633899812498247*fnodal_l[2]-0.18633899812498247*fnodal_l[0]; + GhatL[15] = 0.18633899812498247*fnodal_l[23]-0.18633899812498247*fnodal_l[21]-0.18633899812498247*fnodal_l[20]+0.18633899812498247*fnodal_l[18]-0.18633899812498247*fnodal_l[17]+0.18633899812498247*fnodal_l[15]+0.18633899812498247*fnodal_l[14]-0.18633899812498247*fnodal_l[12]-0.18633899812498247*fnodal_l[11]+0.18633899812498247*fnodal_l[9]+0.18633899812498247*fnodal_l[8]-0.18633899812498247*fnodal_l[6]+0.18633899812498247*fnodal_l[5]-0.18633899812498247*fnodal_l[3]-0.18633899812498247*fnodal_l[2]+0.18633899812498247*fnodal_l[0]; + GhatL[16] = 0.12422599874998831*fnodal_l[23]-0.24845199749997662*fnodal_l[22]+0.12422599874998831*fnodal_l[21]+0.12422599874998831*fnodal_l[20]-0.24845199749997662*fnodal_l[19]+0.12422599874998831*fnodal_l[18]+0.12422599874998831*fnodal_l[17]-0.24845199749997662*fnodal_l[16]+0.12422599874998831*fnodal_l[15]+0.12422599874998831*fnodal_l[14]-0.24845199749997662*fnodal_l[13]+0.12422599874998831*fnodal_l[12]+0.12422599874998831*fnodal_l[11]-0.24845199749997662*fnodal_l[10]+0.12422599874998831*fnodal_l[9]+0.12422599874998831*fnodal_l[8]-0.24845199749997662*fnodal_l[7]+0.12422599874998831*fnodal_l[6]+0.12422599874998831*fnodal_l[5]-0.24845199749997662*fnodal_l[4]+0.12422599874998831*fnodal_l[3]+0.12422599874998831*fnodal_l[2]-0.24845199749997662*fnodal_l[1]+0.12422599874998831*fnodal_l[0]; + GhatL[17] = 0.12422599874998837*fnodal_l[23]-0.24845199749997673*fnodal_l[22]+0.12422599874998837*fnodal_l[21]+0.12422599874998837*fnodal_l[20]-0.24845199749997673*fnodal_l[19]+0.12422599874998837*fnodal_l[18]+0.12422599874998837*fnodal_l[17]-0.24845199749997673*fnodal_l[16]+0.12422599874998837*fnodal_l[15]+0.12422599874998837*fnodal_l[14]-0.24845199749997673*fnodal_l[13]+0.12422599874998837*fnodal_l[12]-0.12422599874998837*fnodal_l[11]+0.24845199749997673*fnodal_l[10]-0.12422599874998837*fnodal_l[9]-0.12422599874998837*fnodal_l[8]+0.24845199749997673*fnodal_l[7]-0.12422599874998837*fnodal_l[6]-0.12422599874998837*fnodal_l[5]+0.24845199749997673*fnodal_l[4]-0.12422599874998837*fnodal_l[3]-0.12422599874998837*fnodal_l[2]+0.24845199749997673*fnodal_l[1]-0.12422599874998837*fnodal_l[0]; + GhatL[18] = 0.12422599874998837*fnodal_l[23]-0.24845199749997673*fnodal_l[22]+0.12422599874998837*fnodal_l[21]+0.12422599874998837*fnodal_l[20]-0.24845199749997673*fnodal_l[19]+0.12422599874998837*fnodal_l[18]-0.12422599874998837*fnodal_l[17]+0.24845199749997673*fnodal_l[16]-0.12422599874998837*fnodal_l[15]-0.12422599874998837*fnodal_l[14]+0.24845199749997673*fnodal_l[13]-0.12422599874998837*fnodal_l[12]+0.12422599874998837*fnodal_l[11]-0.24845199749997673*fnodal_l[10]+0.12422599874998837*fnodal_l[9]+0.12422599874998837*fnodal_l[8]-0.24845199749997673*fnodal_l[7]+0.12422599874998837*fnodal_l[6]-0.12422599874998837*fnodal_l[5]+0.24845199749997673*fnodal_l[4]-0.12422599874998837*fnodal_l[3]-0.12422599874998837*fnodal_l[2]+0.24845199749997673*fnodal_l[1]-0.12422599874998837*fnodal_l[0]; + GhatL[19] = 0.12422599874998837*fnodal_l[23]-0.24845199749997673*fnodal_l[22]+0.12422599874998837*fnodal_l[21]-0.12422599874998837*fnodal_l[20]+0.24845199749997673*fnodal_l[19]-0.12422599874998837*fnodal_l[18]+0.12422599874998837*fnodal_l[17]-0.24845199749997673*fnodal_l[16]+0.12422599874998837*fnodal_l[15]-0.12422599874998837*fnodal_l[14]+0.24845199749997673*fnodal_l[13]-0.12422599874998837*fnodal_l[12]+0.12422599874998837*fnodal_l[11]-0.24845199749997673*fnodal_l[10]+0.12422599874998837*fnodal_l[9]-0.12422599874998837*fnodal_l[8]+0.24845199749997673*fnodal_l[7]-0.12422599874998837*fnodal_l[6]+0.12422599874998837*fnodal_l[5]-0.24845199749997673*fnodal_l[4]+0.12422599874998837*fnodal_l[3]-0.12422599874998837*fnodal_l[2]+0.24845199749997673*fnodal_l[1]-0.12422599874998837*fnodal_l[0]; + GhatL[20] = 0.12422599874998831*fnodal_l[23]-0.24845199749997662*fnodal_l[22]+0.12422599874998831*fnodal_l[21]+0.12422599874998831*fnodal_l[20]-0.24845199749997662*fnodal_l[19]+0.12422599874998831*fnodal_l[18]-0.12422599874998831*fnodal_l[17]+0.24845199749997662*fnodal_l[16]-0.12422599874998831*fnodal_l[15]-0.12422599874998831*fnodal_l[14]+0.24845199749997662*fnodal_l[13]-0.12422599874998831*fnodal_l[12]-0.12422599874998831*fnodal_l[11]+0.24845199749997662*fnodal_l[10]-0.12422599874998831*fnodal_l[9]-0.12422599874998831*fnodal_l[8]+0.24845199749997662*fnodal_l[7]-0.12422599874998831*fnodal_l[6]+0.12422599874998831*fnodal_l[5]-0.24845199749997662*fnodal_l[4]+0.12422599874998831*fnodal_l[3]+0.12422599874998831*fnodal_l[2]-0.24845199749997662*fnodal_l[1]+0.12422599874998831*fnodal_l[0]; + GhatL[21] = 0.12422599874998831*fnodal_l[23]-0.24845199749997662*fnodal_l[22]+0.12422599874998831*fnodal_l[21]-0.12422599874998831*fnodal_l[20]+0.24845199749997662*fnodal_l[19]-0.12422599874998831*fnodal_l[18]+0.12422599874998831*fnodal_l[17]-0.24845199749997662*fnodal_l[16]+0.12422599874998831*fnodal_l[15]-0.12422599874998831*fnodal_l[14]+0.24845199749997662*fnodal_l[13]-0.12422599874998831*fnodal_l[12]-0.12422599874998831*fnodal_l[11]+0.24845199749997662*fnodal_l[10]-0.12422599874998831*fnodal_l[9]+0.12422599874998831*fnodal_l[8]-0.24845199749997662*fnodal_l[7]+0.12422599874998831*fnodal_l[6]-0.12422599874998831*fnodal_l[5]+0.24845199749997662*fnodal_l[4]-0.12422599874998831*fnodal_l[3]+0.12422599874998831*fnodal_l[2]-0.24845199749997662*fnodal_l[1]+0.12422599874998831*fnodal_l[0]; + GhatL[22] = 0.12422599874998831*fnodal_l[23]-0.24845199749997662*fnodal_l[22]+0.12422599874998831*fnodal_l[21]-0.12422599874998831*fnodal_l[20]+0.24845199749997662*fnodal_l[19]-0.12422599874998831*fnodal_l[18]-0.12422599874998831*fnodal_l[17]+0.24845199749997662*fnodal_l[16]-0.12422599874998831*fnodal_l[15]+0.12422599874998831*fnodal_l[14]-0.24845199749997662*fnodal_l[13]+0.12422599874998831*fnodal_l[12]+0.12422599874998831*fnodal_l[11]-0.24845199749997662*fnodal_l[10]+0.12422599874998831*fnodal_l[9]-0.12422599874998831*fnodal_l[8]+0.24845199749997662*fnodal_l[7]-0.12422599874998831*fnodal_l[6]-0.12422599874998831*fnodal_l[5]+0.24845199749997662*fnodal_l[4]-0.12422599874998831*fnodal_l[3]+0.12422599874998831*fnodal_l[2]-0.24845199749997662*fnodal_l[1]+0.12422599874998831*fnodal_l[0]; + GhatL[23] = 0.12422599874998837*fnodal_l[23]-0.24845199749997673*fnodal_l[22]+0.12422599874998837*fnodal_l[21]-0.12422599874998837*fnodal_l[20]+0.24845199749997673*fnodal_l[19]-0.12422599874998837*fnodal_l[18]-0.12422599874998837*fnodal_l[17]+0.24845199749997673*fnodal_l[16]-0.12422599874998837*fnodal_l[15]+0.12422599874998837*fnodal_l[14]-0.24845199749997673*fnodal_l[13]+0.12422599874998837*fnodal_l[12]-0.12422599874998837*fnodal_l[11]+0.24845199749997673*fnodal_l[10]-0.12422599874998837*fnodal_l[9]+0.12422599874998837*fnodal_l[8]-0.24845199749997673*fnodal_l[7]+0.12422599874998837*fnodal_l[6]+0.12422599874998837*fnodal_l[5]-0.24845199749997673*fnodal_l[4]+0.12422599874998837*fnodal_l[3]-0.12422599874998837*fnodal_l[2]+0.24845199749997673*fnodal_l[1]-0.12422599874998837*fnodal_l[0]; + GhatR[0] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]+0.1388888888888889*fnodal_r[20]+0.2222222222222222*fnodal_r[19]+0.1388888888888889*fnodal_r[18]+0.1388888888888889*fnodal_r[17]+0.2222222222222222*fnodal_r[16]+0.1388888888888889*fnodal_r[15]+0.1388888888888889*fnodal_r[14]+0.2222222222222222*fnodal_r[13]+0.1388888888888889*fnodal_r[12]+0.1388888888888889*fnodal_r[11]+0.2222222222222222*fnodal_r[10]+0.1388888888888889*fnodal_r[9]+0.1388888888888889*fnodal_r[8]+0.2222222222222222*fnodal_r[7]+0.1388888888888889*fnodal_r[6]+0.1388888888888889*fnodal_r[5]+0.2222222222222222*fnodal_r[4]+0.1388888888888889*fnodal_r[3]+0.1388888888888889*fnodal_r[2]+0.2222222222222222*fnodal_r[1]+0.1388888888888889*fnodal_r[0]; + GhatR[1] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]+0.1388888888888889*fnodal_r[20]+0.2222222222222222*fnodal_r[19]+0.1388888888888889*fnodal_r[18]+0.1388888888888889*fnodal_r[17]+0.2222222222222222*fnodal_r[16]+0.1388888888888889*fnodal_r[15]+0.1388888888888889*fnodal_r[14]+0.2222222222222222*fnodal_r[13]+0.1388888888888889*fnodal_r[12]-0.1388888888888889*fnodal_r[11]-0.2222222222222222*fnodal_r[10]-0.1388888888888889*fnodal_r[9]-0.1388888888888889*fnodal_r[8]-0.2222222222222222*fnodal_r[7]-0.1388888888888889*fnodal_r[6]-0.1388888888888889*fnodal_r[5]-0.2222222222222222*fnodal_r[4]-0.1388888888888889*fnodal_r[3]-0.1388888888888889*fnodal_r[2]-0.2222222222222222*fnodal_r[1]-0.1388888888888889*fnodal_r[0]; + GhatR[2] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]+0.1388888888888889*fnodal_r[20]+0.2222222222222222*fnodal_r[19]+0.1388888888888889*fnodal_r[18]-0.1388888888888889*fnodal_r[17]-0.2222222222222222*fnodal_r[16]-0.1388888888888889*fnodal_r[15]-0.1388888888888889*fnodal_r[14]-0.2222222222222222*fnodal_r[13]-0.1388888888888889*fnodal_r[12]+0.1388888888888889*fnodal_r[11]+0.2222222222222222*fnodal_r[10]+0.1388888888888889*fnodal_r[9]+0.1388888888888889*fnodal_r[8]+0.2222222222222222*fnodal_r[7]+0.1388888888888889*fnodal_r[6]-0.1388888888888889*fnodal_r[5]-0.2222222222222222*fnodal_r[4]-0.1388888888888889*fnodal_r[3]-0.1388888888888889*fnodal_r[2]-0.2222222222222222*fnodal_r[1]-0.1388888888888889*fnodal_r[0]; + GhatR[3] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]+0.18633899812498247*fnodal_r[20]-0.18633899812498247*fnodal_r[18]+0.18633899812498247*fnodal_r[17]-0.18633899812498247*fnodal_r[15]+0.18633899812498247*fnodal_r[14]-0.18633899812498247*fnodal_r[12]+0.18633899812498247*fnodal_r[11]-0.18633899812498247*fnodal_r[9]+0.18633899812498247*fnodal_r[8]-0.18633899812498247*fnodal_r[6]+0.18633899812498247*fnodal_r[5]-0.18633899812498247*fnodal_r[3]+0.18633899812498247*fnodal_r[2]-0.18633899812498247*fnodal_r[0]; + GhatR[4] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]-0.1388888888888889*fnodal_r[20]-0.2222222222222222*fnodal_r[19]-0.1388888888888889*fnodal_r[18]+0.1388888888888889*fnodal_r[17]+0.2222222222222222*fnodal_r[16]+0.1388888888888889*fnodal_r[15]-0.1388888888888889*fnodal_r[14]-0.2222222222222222*fnodal_r[13]-0.1388888888888889*fnodal_r[12]+0.1388888888888889*fnodal_r[11]+0.2222222222222222*fnodal_r[10]+0.1388888888888889*fnodal_r[9]-0.1388888888888889*fnodal_r[8]-0.2222222222222222*fnodal_r[7]-0.1388888888888889*fnodal_r[6]+0.1388888888888889*fnodal_r[5]+0.2222222222222222*fnodal_r[4]+0.1388888888888889*fnodal_r[3]-0.1388888888888889*fnodal_r[2]-0.2222222222222222*fnodal_r[1]-0.1388888888888889*fnodal_r[0]; + GhatR[5] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]+0.1388888888888889*fnodal_r[20]+0.2222222222222222*fnodal_r[19]+0.1388888888888889*fnodal_r[18]-0.1388888888888889*fnodal_r[17]-0.2222222222222222*fnodal_r[16]-0.1388888888888889*fnodal_r[15]-0.1388888888888889*fnodal_r[14]-0.2222222222222222*fnodal_r[13]-0.1388888888888889*fnodal_r[12]-0.1388888888888889*fnodal_r[11]-0.2222222222222222*fnodal_r[10]-0.1388888888888889*fnodal_r[9]-0.1388888888888889*fnodal_r[8]-0.2222222222222222*fnodal_r[7]-0.1388888888888889*fnodal_r[6]+0.1388888888888889*fnodal_r[5]+0.2222222222222222*fnodal_r[4]+0.1388888888888889*fnodal_r[3]+0.1388888888888889*fnodal_r[2]+0.2222222222222222*fnodal_r[1]+0.1388888888888889*fnodal_r[0]; + GhatR[6] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]+0.18633899812498247*fnodal_r[20]-0.18633899812498247*fnodal_r[18]+0.18633899812498247*fnodal_r[17]-0.18633899812498247*fnodal_r[15]+0.18633899812498247*fnodal_r[14]-0.18633899812498247*fnodal_r[12]-0.18633899812498247*fnodal_r[11]+0.18633899812498247*fnodal_r[9]-0.18633899812498247*fnodal_r[8]+0.18633899812498247*fnodal_r[6]-0.18633899812498247*fnodal_r[5]+0.18633899812498247*fnodal_r[3]-0.18633899812498247*fnodal_r[2]+0.18633899812498247*fnodal_r[0]; + GhatR[7] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]+0.18633899812498247*fnodal_r[20]-0.18633899812498247*fnodal_r[18]-0.18633899812498247*fnodal_r[17]+0.18633899812498247*fnodal_r[15]-0.18633899812498247*fnodal_r[14]+0.18633899812498247*fnodal_r[12]+0.18633899812498247*fnodal_r[11]-0.18633899812498247*fnodal_r[9]+0.18633899812498247*fnodal_r[8]-0.18633899812498247*fnodal_r[6]-0.18633899812498247*fnodal_r[5]+0.18633899812498247*fnodal_r[3]-0.18633899812498247*fnodal_r[2]+0.18633899812498247*fnodal_r[0]; + GhatR[8] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]-0.1388888888888889*fnodal_r[20]-0.2222222222222222*fnodal_r[19]-0.1388888888888889*fnodal_r[18]+0.1388888888888889*fnodal_r[17]+0.2222222222222222*fnodal_r[16]+0.1388888888888889*fnodal_r[15]-0.1388888888888889*fnodal_r[14]-0.2222222222222222*fnodal_r[13]-0.1388888888888889*fnodal_r[12]-0.1388888888888889*fnodal_r[11]-0.2222222222222222*fnodal_r[10]-0.1388888888888889*fnodal_r[9]+0.1388888888888889*fnodal_r[8]+0.2222222222222222*fnodal_r[7]+0.1388888888888889*fnodal_r[6]-0.1388888888888889*fnodal_r[5]-0.2222222222222222*fnodal_r[4]-0.1388888888888889*fnodal_r[3]+0.1388888888888889*fnodal_r[2]+0.2222222222222222*fnodal_r[1]+0.1388888888888889*fnodal_r[0]; + GhatR[9] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]-0.1388888888888889*fnodal_r[20]-0.2222222222222222*fnodal_r[19]-0.1388888888888889*fnodal_r[18]-0.1388888888888889*fnodal_r[17]-0.2222222222222222*fnodal_r[16]-0.1388888888888889*fnodal_r[15]+0.1388888888888889*fnodal_r[14]+0.2222222222222222*fnodal_r[13]+0.1388888888888889*fnodal_r[12]+0.1388888888888889*fnodal_r[11]+0.2222222222222222*fnodal_r[10]+0.1388888888888889*fnodal_r[9]-0.1388888888888889*fnodal_r[8]-0.2222222222222222*fnodal_r[7]-0.1388888888888889*fnodal_r[6]-0.1388888888888889*fnodal_r[5]-0.2222222222222222*fnodal_r[4]-0.1388888888888889*fnodal_r[3]+0.1388888888888889*fnodal_r[2]+0.2222222222222222*fnodal_r[1]+0.1388888888888889*fnodal_r[0]; + GhatR[10] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]-0.18633899812498247*fnodal_r[20]+0.18633899812498247*fnodal_r[18]+0.18633899812498247*fnodal_r[17]-0.18633899812498247*fnodal_r[15]-0.18633899812498247*fnodal_r[14]+0.18633899812498247*fnodal_r[12]+0.18633899812498247*fnodal_r[11]-0.18633899812498247*fnodal_r[9]-0.18633899812498247*fnodal_r[8]+0.18633899812498247*fnodal_r[6]+0.18633899812498247*fnodal_r[5]-0.18633899812498247*fnodal_r[3]-0.18633899812498247*fnodal_r[2]+0.18633899812498247*fnodal_r[0]; + GhatR[11] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]+0.18633899812498247*fnodal_r[20]-0.18633899812498247*fnodal_r[18]-0.18633899812498247*fnodal_r[17]+0.18633899812498247*fnodal_r[15]-0.18633899812498247*fnodal_r[14]+0.18633899812498247*fnodal_r[12]-0.18633899812498247*fnodal_r[11]+0.18633899812498247*fnodal_r[9]-0.18633899812498247*fnodal_r[8]+0.18633899812498247*fnodal_r[6]+0.18633899812498247*fnodal_r[5]-0.18633899812498247*fnodal_r[3]+0.18633899812498247*fnodal_r[2]-0.18633899812498247*fnodal_r[0]; + GhatR[12] = 0.1388888888888889*fnodal_r[23]+0.2222222222222222*fnodal_r[22]+0.1388888888888889*fnodal_r[21]-0.1388888888888889*fnodal_r[20]-0.2222222222222222*fnodal_r[19]-0.1388888888888889*fnodal_r[18]-0.1388888888888889*fnodal_r[17]-0.2222222222222222*fnodal_r[16]-0.1388888888888889*fnodal_r[15]+0.1388888888888889*fnodal_r[14]+0.2222222222222222*fnodal_r[13]+0.1388888888888889*fnodal_r[12]-0.1388888888888889*fnodal_r[11]-0.2222222222222222*fnodal_r[10]-0.1388888888888889*fnodal_r[9]+0.1388888888888889*fnodal_r[8]+0.2222222222222222*fnodal_r[7]+0.1388888888888889*fnodal_r[6]+0.1388888888888889*fnodal_r[5]+0.2222222222222222*fnodal_r[4]+0.1388888888888889*fnodal_r[3]-0.1388888888888889*fnodal_r[2]-0.2222222222222222*fnodal_r[1]-0.1388888888888889*fnodal_r[0]; + GhatR[13] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]-0.18633899812498247*fnodal_r[20]+0.18633899812498247*fnodal_r[18]+0.18633899812498247*fnodal_r[17]-0.18633899812498247*fnodal_r[15]-0.18633899812498247*fnodal_r[14]+0.18633899812498247*fnodal_r[12]-0.18633899812498247*fnodal_r[11]+0.18633899812498247*fnodal_r[9]+0.18633899812498247*fnodal_r[8]-0.18633899812498247*fnodal_r[6]-0.18633899812498247*fnodal_r[5]+0.18633899812498247*fnodal_r[3]+0.18633899812498247*fnodal_r[2]-0.18633899812498247*fnodal_r[0]; + GhatR[14] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]-0.18633899812498247*fnodal_r[20]+0.18633899812498247*fnodal_r[18]-0.18633899812498247*fnodal_r[17]+0.18633899812498247*fnodal_r[15]+0.18633899812498247*fnodal_r[14]-0.18633899812498247*fnodal_r[12]+0.18633899812498247*fnodal_r[11]-0.18633899812498247*fnodal_r[9]-0.18633899812498247*fnodal_r[8]+0.18633899812498247*fnodal_r[6]-0.18633899812498247*fnodal_r[5]+0.18633899812498247*fnodal_r[3]+0.18633899812498247*fnodal_r[2]-0.18633899812498247*fnodal_r[0]; + GhatR[15] = 0.18633899812498247*fnodal_r[23]-0.18633899812498247*fnodal_r[21]-0.18633899812498247*fnodal_r[20]+0.18633899812498247*fnodal_r[18]-0.18633899812498247*fnodal_r[17]+0.18633899812498247*fnodal_r[15]+0.18633899812498247*fnodal_r[14]-0.18633899812498247*fnodal_r[12]-0.18633899812498247*fnodal_r[11]+0.18633899812498247*fnodal_r[9]+0.18633899812498247*fnodal_r[8]-0.18633899812498247*fnodal_r[6]+0.18633899812498247*fnodal_r[5]-0.18633899812498247*fnodal_r[3]-0.18633899812498247*fnodal_r[2]+0.18633899812498247*fnodal_r[0]; + GhatR[16] = 0.12422599874998831*fnodal_r[23]-0.24845199749997662*fnodal_r[22]+0.12422599874998831*fnodal_r[21]+0.12422599874998831*fnodal_r[20]-0.24845199749997662*fnodal_r[19]+0.12422599874998831*fnodal_r[18]+0.12422599874998831*fnodal_r[17]-0.24845199749997662*fnodal_r[16]+0.12422599874998831*fnodal_r[15]+0.12422599874998831*fnodal_r[14]-0.24845199749997662*fnodal_r[13]+0.12422599874998831*fnodal_r[12]+0.12422599874998831*fnodal_r[11]-0.24845199749997662*fnodal_r[10]+0.12422599874998831*fnodal_r[9]+0.12422599874998831*fnodal_r[8]-0.24845199749997662*fnodal_r[7]+0.12422599874998831*fnodal_r[6]+0.12422599874998831*fnodal_r[5]-0.24845199749997662*fnodal_r[4]+0.12422599874998831*fnodal_r[3]+0.12422599874998831*fnodal_r[2]-0.24845199749997662*fnodal_r[1]+0.12422599874998831*fnodal_r[0]; + GhatR[17] = 0.12422599874998837*fnodal_r[23]-0.24845199749997673*fnodal_r[22]+0.12422599874998837*fnodal_r[21]+0.12422599874998837*fnodal_r[20]-0.24845199749997673*fnodal_r[19]+0.12422599874998837*fnodal_r[18]+0.12422599874998837*fnodal_r[17]-0.24845199749997673*fnodal_r[16]+0.12422599874998837*fnodal_r[15]+0.12422599874998837*fnodal_r[14]-0.24845199749997673*fnodal_r[13]+0.12422599874998837*fnodal_r[12]-0.12422599874998837*fnodal_r[11]+0.24845199749997673*fnodal_r[10]-0.12422599874998837*fnodal_r[9]-0.12422599874998837*fnodal_r[8]+0.24845199749997673*fnodal_r[7]-0.12422599874998837*fnodal_r[6]-0.12422599874998837*fnodal_r[5]+0.24845199749997673*fnodal_r[4]-0.12422599874998837*fnodal_r[3]-0.12422599874998837*fnodal_r[2]+0.24845199749997673*fnodal_r[1]-0.12422599874998837*fnodal_r[0]; + GhatR[18] = 0.12422599874998837*fnodal_r[23]-0.24845199749997673*fnodal_r[22]+0.12422599874998837*fnodal_r[21]+0.12422599874998837*fnodal_r[20]-0.24845199749997673*fnodal_r[19]+0.12422599874998837*fnodal_r[18]-0.12422599874998837*fnodal_r[17]+0.24845199749997673*fnodal_r[16]-0.12422599874998837*fnodal_r[15]-0.12422599874998837*fnodal_r[14]+0.24845199749997673*fnodal_r[13]-0.12422599874998837*fnodal_r[12]+0.12422599874998837*fnodal_r[11]-0.24845199749997673*fnodal_r[10]+0.12422599874998837*fnodal_r[9]+0.12422599874998837*fnodal_r[8]-0.24845199749997673*fnodal_r[7]+0.12422599874998837*fnodal_r[6]-0.12422599874998837*fnodal_r[5]+0.24845199749997673*fnodal_r[4]-0.12422599874998837*fnodal_r[3]-0.12422599874998837*fnodal_r[2]+0.24845199749997673*fnodal_r[1]-0.12422599874998837*fnodal_r[0]; + GhatR[19] = 0.12422599874998837*fnodal_r[23]-0.24845199749997673*fnodal_r[22]+0.12422599874998837*fnodal_r[21]-0.12422599874998837*fnodal_r[20]+0.24845199749997673*fnodal_r[19]-0.12422599874998837*fnodal_r[18]+0.12422599874998837*fnodal_r[17]-0.24845199749997673*fnodal_r[16]+0.12422599874998837*fnodal_r[15]-0.12422599874998837*fnodal_r[14]+0.24845199749997673*fnodal_r[13]-0.12422599874998837*fnodal_r[12]+0.12422599874998837*fnodal_r[11]-0.24845199749997673*fnodal_r[10]+0.12422599874998837*fnodal_r[9]-0.12422599874998837*fnodal_r[8]+0.24845199749997673*fnodal_r[7]-0.12422599874998837*fnodal_r[6]+0.12422599874998837*fnodal_r[5]-0.24845199749997673*fnodal_r[4]+0.12422599874998837*fnodal_r[3]-0.12422599874998837*fnodal_r[2]+0.24845199749997673*fnodal_r[1]-0.12422599874998837*fnodal_r[0]; + GhatR[20] = 0.12422599874998831*fnodal_r[23]-0.24845199749997662*fnodal_r[22]+0.12422599874998831*fnodal_r[21]+0.12422599874998831*fnodal_r[20]-0.24845199749997662*fnodal_r[19]+0.12422599874998831*fnodal_r[18]-0.12422599874998831*fnodal_r[17]+0.24845199749997662*fnodal_r[16]-0.12422599874998831*fnodal_r[15]-0.12422599874998831*fnodal_r[14]+0.24845199749997662*fnodal_r[13]-0.12422599874998831*fnodal_r[12]-0.12422599874998831*fnodal_r[11]+0.24845199749997662*fnodal_r[10]-0.12422599874998831*fnodal_r[9]-0.12422599874998831*fnodal_r[8]+0.24845199749997662*fnodal_r[7]-0.12422599874998831*fnodal_r[6]+0.12422599874998831*fnodal_r[5]-0.24845199749997662*fnodal_r[4]+0.12422599874998831*fnodal_r[3]+0.12422599874998831*fnodal_r[2]-0.24845199749997662*fnodal_r[1]+0.12422599874998831*fnodal_r[0]; + GhatR[21] = 0.12422599874998831*fnodal_r[23]-0.24845199749997662*fnodal_r[22]+0.12422599874998831*fnodal_r[21]-0.12422599874998831*fnodal_r[20]+0.24845199749997662*fnodal_r[19]-0.12422599874998831*fnodal_r[18]+0.12422599874998831*fnodal_r[17]-0.24845199749997662*fnodal_r[16]+0.12422599874998831*fnodal_r[15]-0.12422599874998831*fnodal_r[14]+0.24845199749997662*fnodal_r[13]-0.12422599874998831*fnodal_r[12]-0.12422599874998831*fnodal_r[11]+0.24845199749997662*fnodal_r[10]-0.12422599874998831*fnodal_r[9]+0.12422599874998831*fnodal_r[8]-0.24845199749997662*fnodal_r[7]+0.12422599874998831*fnodal_r[6]-0.12422599874998831*fnodal_r[5]+0.24845199749997662*fnodal_r[4]-0.12422599874998831*fnodal_r[3]+0.12422599874998831*fnodal_r[2]-0.24845199749997662*fnodal_r[1]+0.12422599874998831*fnodal_r[0]; + GhatR[22] = 0.12422599874998831*fnodal_r[23]-0.24845199749997662*fnodal_r[22]+0.12422599874998831*fnodal_r[21]-0.12422599874998831*fnodal_r[20]+0.24845199749997662*fnodal_r[19]-0.12422599874998831*fnodal_r[18]-0.12422599874998831*fnodal_r[17]+0.24845199749997662*fnodal_r[16]-0.12422599874998831*fnodal_r[15]+0.12422599874998831*fnodal_r[14]-0.24845199749997662*fnodal_r[13]+0.12422599874998831*fnodal_r[12]+0.12422599874998831*fnodal_r[11]-0.24845199749997662*fnodal_r[10]+0.12422599874998831*fnodal_r[9]-0.12422599874998831*fnodal_r[8]+0.24845199749997662*fnodal_r[7]-0.12422599874998831*fnodal_r[6]-0.12422599874998831*fnodal_r[5]+0.24845199749997662*fnodal_r[4]-0.12422599874998831*fnodal_r[3]+0.12422599874998831*fnodal_r[2]-0.24845199749997662*fnodal_r[1]+0.12422599874998831*fnodal_r[0]; + GhatR[23] = 0.12422599874998837*fnodal_r[23]-0.24845199749997673*fnodal_r[22]+0.12422599874998837*fnodal_r[21]-0.12422599874998837*fnodal_r[20]+0.24845199749997673*fnodal_r[19]-0.12422599874998837*fnodal_r[18]-0.12422599874998837*fnodal_r[17]+0.24845199749997673*fnodal_r[16]-0.12422599874998837*fnodal_r[15]+0.12422599874998837*fnodal_r[14]-0.24845199749997673*fnodal_r[13]+0.12422599874998837*fnodal_r[12]-0.12422599874998837*fnodal_r[11]+0.24845199749997673*fnodal_r[10]-0.12422599874998837*fnodal_r[9]+0.12422599874998837*fnodal_r[8]-0.24845199749997673*fnodal_r[7]+0.12422599874998837*fnodal_r[6]+0.12422599874998837*fnodal_r[5]-0.24845199749997673*fnodal_r[4]+0.12422599874998837*fnodal_r[3]-0.12422599874998837*fnodal_r[2]+0.24845199749997673*fnodal_r[1]-0.12422599874998837*fnodal_r[0]; + + out[0] += (0.7071067811865475*GhatL[0]-0.7071067811865475*GhatR[0])*rdz2; + out[1] += (0.7071067811865475*GhatL[1]-0.7071067811865475*GhatR[1])*rdz2; + out[2] += (0.7071067811865475*GhatL[2]-0.7071067811865475*GhatR[2])*rdz2; + out[3] += (-(1.224744871391589*GhatR[0])-1.224744871391589*GhatL[0])*rdz2; + out[4] += (0.7071067811865475*GhatL[3]-0.7071067811865475*GhatR[3])*rdz2; + out[5] += (0.7071067811865475*GhatL[4]-0.7071067811865475*GhatR[4])*rdz2; + out[6] += (0.7071067811865475*GhatL[5]-0.7071067811865475*GhatR[5])*rdz2; + out[7] += (-(1.224744871391589*GhatR[1])-1.224744871391589*GhatL[1])*rdz2; + out[8] += (-(1.224744871391589*GhatR[2])-1.224744871391589*GhatL[2])*rdz2; + out[9] += (0.7071067811865475*GhatL[6]-0.7071067811865475*GhatR[6])*rdz2; + out[10] += (0.7071067811865475*GhatL[7]-0.7071067811865475*GhatR[7])*rdz2; + out[11] += (-(1.224744871391589*GhatR[3])-1.224744871391589*GhatL[3])*rdz2; + out[12] += (0.7071067811865475*GhatL[8]-0.7071067811865475*GhatR[8])*rdz2; + out[13] += (0.7071067811865475*GhatL[9]-0.7071067811865475*GhatR[9])*rdz2; + out[14] += (-(1.224744871391589*GhatR[4])-1.224744871391589*GhatL[4])*rdz2; + out[15] += (0.7071067811865475*GhatL[10]-0.7071067811865475*GhatR[10])*rdz2; + out[16] += (-(1.224744871391589*GhatR[5])-1.224744871391589*GhatL[5])*rdz2; + out[17] += (0.7071067811865475*GhatL[11]-0.7071067811865475*GhatR[11])*rdz2; + out[18] += (-(1.224744871391589*GhatR[6])-1.224744871391589*GhatL[6])*rdz2; + out[19] += (-(1.224744871391589*GhatR[7])-1.224744871391589*GhatL[7])*rdz2; + out[20] += (0.7071067811865475*GhatL[12]-0.7071067811865475*GhatR[12])*rdz2; + out[21] += (-(1.224744871391589*GhatR[8])-1.224744871391589*GhatL[8])*rdz2; + out[22] += (-(1.224744871391589*GhatR[9])-1.224744871391589*GhatL[9])*rdz2; + out[23] += (0.7071067811865475*GhatL[13]-0.7071067811865475*GhatR[13])*rdz2; + out[24] += (0.7071067811865475*GhatL[14]-0.7071067811865475*GhatR[14])*rdz2; + out[25] += (-(1.224744871391589*GhatR[10])-1.224744871391589*GhatL[10])*rdz2; + out[26] += (-(1.224744871391589*GhatR[11])-1.224744871391589*GhatL[11])*rdz2; + out[27] += (-(1.224744871391589*GhatR[12])-1.224744871391589*GhatL[12])*rdz2; + out[28] += (0.7071067811865475*GhatL[15]-0.7071067811865475*GhatR[15])*rdz2; + out[29] += (-(1.224744871391589*GhatR[13])-1.224744871391589*GhatL[13])*rdz2; + out[30] += (-(1.224744871391589*GhatR[14])-1.224744871391589*GhatL[14])*rdz2; + out[31] += (-(1.224744871391589*GhatR[15])-1.224744871391589*GhatL[15])*rdz2; + out[32] += (0.7071067811865475*GhatL[16]-0.7071067811865475*GhatR[16])*rdz2; + out[33] += (0.7071067811865475*GhatL[17]-0.7071067811865475*GhatR[17])*rdz2; + out[34] += (0.7071067811865475*GhatL[18]-0.7071067811865475*GhatR[18])*rdz2; + out[35] += (-(1.224744871391589*GhatR[16])-1.224744871391589*GhatL[16])*rdz2; + out[36] += (0.7071067811865475*GhatL[19]-0.7071067811865475*GhatR[19])*rdz2; + out[37] += (0.7071067811865475*GhatL[20]-0.7071067811865475*GhatR[20])*rdz2; + out[38] += (-(1.224744871391589*GhatR[17])-1.224744871391589*GhatL[17])*rdz2; + out[39] += (-(1.224744871391589*GhatR[18])-1.224744871391589*GhatL[18])*rdz2; + out[40] += (0.7071067811865475*GhatL[21]-0.7071067811865475*GhatR[21])*rdz2; + out[41] += (0.7071067811865475*GhatL[22]-0.7071067811865475*GhatR[22])*rdz2; + out[42] += (-(1.224744871391589*GhatR[19])-1.224744871391589*GhatL[19])*rdz2; + out[43] += (-(1.224744871391589*GhatR[20])-1.224744871391589*GhatL[20])*rdz2; + out[44] += (0.7071067811865475*GhatL[23]-0.7071067811865475*GhatR[23])*rdz2; + out[45] += (-(1.224744871391589*GhatR[21])-1.224744871391589*GhatL[21])*rdz2; + out[46] += (-(1.224744871391589*GhatR[22])-1.224744871391589*GhatL[22])*rdz2; + out[47] += (-(1.224744871391589*GhatR[23])-1.224744871391589*GhatL[23])*rdz2; + + return 0.0; + +} diff --git a/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_vol_1x1v_ser_p1.c b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_vol_1x1v_ser_p1.c new file mode 100644 index 0000000000..ce8f0e53eb --- /dev/null +++ b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_vol_1x1v_ser_p1.c @@ -0,0 +1,41 @@ +#include +GKYL_CU_DH double dg_gyrokinetic_passive_vol_1x1v_ser_p1(const double *w, const double *dxv, const double *vmap, const double *vmapSq, + const double q_, const double m_, const double *bmag, const double *speeds, + const double *dualcurlbhatoverB, const double *rtg33inv, const double *bioverJB, + const double *fin, double* GKYL_RESTRICT out) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // q_,m_: species charge and mass. + // bmag: magnetic field amplitude. + // speeds: passive advection speeds. + // fin: Distribution function. + // out: output increment. + + double rdx2 = 2.0/dxv[0]; + double rdvpar2 = 2.0/dxv[1]; + + double rdvpar2Sq = rdvpar2*rdvpar2; + double dvparSq = dxv[1]*dxv[1]; + + const double *bioverJB_x = &bioverJB[0]; + const double *bioverJB_y = &bioverJB[2]; + const double *bioverJB_z = &bioverJB[4]; + + const double *dualcurlbhatoverB_x = &dualcurlbhatoverB[0]; + const double *dualcurlbhatoverB_y = &dualcurlbhatoverB[2]; + const double *dualcurlbhatoverB_z = &dualcurlbhatoverB[4]; + + double alphax[6] = {0.}; + alphax[0] = 1.4142135623730951*speeds[0]*rdx2; + alphax[1] = 1.4142135623730951*speeds[1]*rdx2; + + + out[1] += 0.8660254037844386*(alphax[1]*fin[1]+alphax[0]*fin[0]); + out[3] += 0.8660254037844386*(alphax[1]*fin[3]+alphax[0]*fin[2]); + out[5] += 0.8660254037844386*alphax[1]*fin[5]+0.8660254037844387*alphax[0]*fin[4]; + + return 0.; +} diff --git a/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_vol_1x2v_ser_p1.c b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_vol_1x2v_ser_p1.c new file mode 100644 index 0000000000..a42c930556 --- /dev/null +++ b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_vol_1x2v_ser_p1.c @@ -0,0 +1,45 @@ +#include +GKYL_CU_DH double dg_gyrokinetic_passive_vol_1x2v_ser_p1(const double *w, const double *dxv, const double *vmap, const double *vmapSq, + const double q_, const double m_, const double *bmag, const double *speeds, + const double *dualcurlbhatoverB, const double *rtg33inv, const double *bioverJB, + const double *fin, double* GKYL_RESTRICT out) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // q_,m_: species charge and mass. + // bmag: magnetic field amplitude. + // speeds: passive advection speeds. + // fin: Distribution function. + // out: output increment. + + double rdx2 = 2.0/dxv[0]; + double rdvpar2 = 2.0/dxv[1]; + double rdmu2 = 2.0/dxv[2]; + + double rdvpar2Sq = rdvpar2*rdvpar2; + double dvparSq = dxv[1]*dxv[1]; + + const double *bioverJB_x = &bioverJB[0]; + const double *bioverJB_y = &bioverJB[2]; + const double *bioverJB_z = &bioverJB[4]; + + const double *dualcurlbhatoverB_x = &dualcurlbhatoverB[0]; + const double *dualcurlbhatoverB_y = &dualcurlbhatoverB[2]; + const double *dualcurlbhatoverB_z = &dualcurlbhatoverB[4]; + + double alphax[12] = {0.}; + alphax[0] = 2.0*speeds[0]*rdx2; + alphax[1] = 2.0*speeds[1]*rdx2; + + + out[1] += 0.6123724356957944*(alphax[1]*fin[1]+alphax[0]*fin[0]); + out[4] += 0.6123724356957944*(alphax[1]*fin[4]+alphax[0]*fin[2]); + out[5] += 0.6123724356957944*(alphax[1]*fin[5]+alphax[0]*fin[3]); + out[7] += 0.6123724356957944*(alphax[1]*fin[7]+alphax[0]*fin[6]); + out[9] += 0.6123724356957944*(alphax[1]*fin[9]+alphax[0]*fin[8]); + out[11] += 0.6123724356957944*(alphax[1]*fin[11]+alphax[0]*fin[10]); + + return 0.; +} diff --git a/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_vol_2x2v_ser_p1.c b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_vol_2x2v_ser_p1.c new file mode 100644 index 0000000000..60520115ed --- /dev/null +++ b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_vol_2x2v_ser_p1.c @@ -0,0 +1,74 @@ +#include +GKYL_CU_DH double dg_gyrokinetic_passive_vol_2x2v_ser_p1(const double *w, const double *dxv, const double *vmap, const double *vmapSq, + const double q_, const double m_, const double *bmag, const double *speeds, + const double *dualcurlbhatoverB, const double *rtg33inv, const double *bioverJB, + const double *fin, double* GKYL_RESTRICT out) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // q_,m_: species charge and mass. + // bmag: magnetic field amplitude. + // speeds: passive advection speeds. + // fin: Distribution function. + // out: output increment. + + double rdx2 = 2.0/dxv[0]; + double rdz2 = 2.0/dxv[1]; + double rdvpar2 = 2.0/dxv[2]; + double rdmu2 = 2.0/dxv[3]; + + double rdvpar2Sq = rdvpar2*rdvpar2; + double dvparSq = dxv[2]*dxv[2]; + + const double *bioverJB_x = &bioverJB[0]; + const double *bioverJB_y = &bioverJB[4]; + const double *bioverJB_z = &bioverJB[8]; + + const double *dualcurlbhatoverB_x = &dualcurlbhatoverB[0]; + const double *dualcurlbhatoverB_y = &dualcurlbhatoverB[4]; + const double *dualcurlbhatoverB_z = &dualcurlbhatoverB[8]; + + double alphax[24] = {0.}; + alphax[0] = 2.0*speeds[0]*rdx2; + alphax[1] = 2.0*speeds[1]*rdx2; + alphax[2] = 2.0*speeds[2]*rdx2; + alphax[5] = 2.0*speeds[3]*rdx2; + + + out[1] += 0.4330127018922193*(alphax[5]*fin[5]+alphax[2]*fin[2]+alphax[1]*fin[1]+alphax[0]*fin[0]); + out[5] += 0.4330127018922193*(alphax[1]*fin[5]+fin[1]*alphax[5]+alphax[0]*fin[2]+fin[0]*alphax[2]); + out[6] += 0.4330127018922193*(alphax[5]*fin[11]+alphax[2]*fin[7]+alphax[1]*fin[6]+alphax[0]*fin[3]); + out[8] += 0.4330127018922193*(alphax[5]*fin[12]+alphax[2]*fin[9]+alphax[1]*fin[8]+alphax[0]*fin[4]); + out[11] += 0.4330127018922193*(alphax[1]*fin[11]+alphax[0]*fin[7]+alphax[5]*fin[6]+alphax[2]*fin[3]); + out[12] += 0.4330127018922193*(alphax[1]*fin[12]+alphax[0]*fin[9]+alphax[5]*fin[8]+alphax[2]*fin[4]); + out[13] += 0.4330127018922193*(alphax[5]*fin[15]+alphax[2]*fin[14]+alphax[1]*fin[13]+alphax[0]*fin[10]); + out[15] += 0.4330127018922193*(alphax[1]*fin[15]+alphax[0]*fin[14]+alphax[5]*fin[13]+alphax[2]*fin[10]); + out[17] += 0.43301270189221935*alphax[5]*fin[20]+0.4330127018922193*(alphax[2]*fin[18]+alphax[1]*fin[17])+0.43301270189221935*alphax[0]*fin[16]; + out[20] += 0.4330127018922193*alphax[1]*fin[20]+0.43301270189221935*(alphax[0]*fin[18]+alphax[5]*fin[17])+0.4330127018922193*alphax[2]*fin[16]; + out[21] += 0.43301270189221935*alphax[5]*fin[23]+0.4330127018922193*(alphax[2]*fin[22]+alphax[1]*fin[21])+0.43301270189221935*alphax[0]*fin[19]; + out[23] += 0.4330127018922193*alphax[1]*fin[23]+0.43301270189221935*(alphax[0]*fin[22]+alphax[5]*fin[21])+0.4330127018922193*alphax[2]*fin[19]; + + double alphaz[24] = {0.}; + alphaz[0] = 2.0*speeds[4]*rdz2; + alphaz[1] = 2.0*speeds[5]*rdz2; + alphaz[2] = 2.0*speeds[6]*rdz2; + alphaz[5] = 2.0*speeds[7]*rdz2; + + + out[2] += 0.4330127018922193*(alphaz[5]*fin[5]+alphaz[2]*fin[2]+alphaz[1]*fin[1]+alphaz[0]*fin[0]); + out[5] += 0.4330127018922193*(alphaz[2]*fin[5]+fin[2]*alphaz[5]+alphaz[0]*fin[1]+fin[0]*alphaz[1]); + out[7] += 0.4330127018922193*(alphaz[5]*fin[11]+alphaz[2]*fin[7]+alphaz[1]*fin[6]+alphaz[0]*fin[3]); + out[9] += 0.4330127018922193*(alphaz[5]*fin[12]+alphaz[2]*fin[9]+alphaz[1]*fin[8]+alphaz[0]*fin[4]); + out[11] += 0.4330127018922193*(alphaz[2]*fin[11]+alphaz[5]*fin[7]+alphaz[0]*fin[6]+alphaz[1]*fin[3]); + out[12] += 0.4330127018922193*(alphaz[2]*fin[12]+alphaz[5]*fin[9]+alphaz[0]*fin[8]+alphaz[1]*fin[4]); + out[14] += 0.4330127018922193*(alphaz[5]*fin[15]+alphaz[2]*fin[14]+alphaz[1]*fin[13]+alphaz[0]*fin[10]); + out[15] += 0.4330127018922193*(alphaz[2]*fin[15]+alphaz[5]*fin[14]+alphaz[0]*fin[13]+alphaz[1]*fin[10]); + out[18] += 0.43301270189221935*alphaz[5]*fin[20]+0.4330127018922193*(alphaz[2]*fin[18]+alphaz[1]*fin[17])+0.43301270189221935*alphaz[0]*fin[16]; + out[20] += 0.4330127018922193*alphaz[2]*fin[20]+0.43301270189221935*(alphaz[5]*fin[18]+alphaz[0]*fin[17])+0.4330127018922193*alphaz[1]*fin[16]; + out[22] += 0.43301270189221935*alphaz[5]*fin[23]+0.4330127018922193*(alphaz[2]*fin[22]+alphaz[1]*fin[21])+0.43301270189221935*alphaz[0]*fin[19]; + out[23] += 0.4330127018922193*alphaz[2]*fin[23]+0.43301270189221935*(alphaz[5]*fin[22]+alphaz[0]*fin[21])+0.4330127018922193*alphaz[1]*fin[19]; + + return 0.; +} diff --git a/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_vol_3x2v_ser_p1.c b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_vol_3x2v_ser_p1.c new file mode 100644 index 0000000000..735428d553 --- /dev/null +++ b/gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_vol_3x2v_ser_p1.c @@ -0,0 +1,143 @@ +#include +GKYL_CU_DH double dg_gyrokinetic_passive_vol_3x2v_ser_p1(const double *w, const double *dxv, const double *vmap, const double *vmapSq, + const double q_, const double m_, const double *bmag, const double *speeds, + const double *dualcurlbhatoverB, const double *rtg33inv, const double *bioverJB, + const double *fin, double* GKYL_RESTRICT out) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // q_,m_: species charge and mass. + // bmag: magnetic field amplitude. + // speeds: passive advection speeds. + // fin: Distribution function. + // out: output increment. + + double rdx2 = 2.0/dxv[0]; + double rdy2 = 2.0/dxv[1]; + double rdz2 = 2.0/dxv[2]; + double rdvpar2 = 2.0/dxv[3]; + double rdmu2 = 2.0/dxv[4]; + + double rdvpar2Sq = rdvpar2*rdvpar2; + double dvparSq = dxv[3]*dxv[3]; + + const double *bioverJB_x = &bioverJB[0]; + const double *bioverJB_y = &bioverJB[8]; + const double *bioverJB_z = &bioverJB[16]; + + const double *dualcurlbhatoverB_x = &dualcurlbhatoverB[0]; + const double *dualcurlbhatoverB_y = &dualcurlbhatoverB[8]; + const double *dualcurlbhatoverB_z = &dualcurlbhatoverB[16]; + + double alphax[48] = {0.}; + alphax[0] = 2.0*speeds[0]*rdx2; + alphax[1] = 2.0*speeds[1]*rdx2; + alphax[2] = 2.0*speeds[2]*rdx2; + alphax[3] = 2.0*speeds[3]*rdx2; + alphax[6] = 2.0*speeds[4]*rdx2; + alphax[7] = 2.0*speeds[5]*rdx2; + alphax[8] = 2.0*speeds[6]*rdx2; + alphax[16] = 2.0*speeds[7]*rdx2; + + + out[1] += 0.3061862178478971*(alphax[16]*fin[16]+alphax[8]*fin[8]+alphax[7]*fin[7]+alphax[6]*fin[6]+alphax[3]*fin[3]+alphax[2]*fin[2]+alphax[1]*fin[1]+alphax[0]*fin[0]); + out[6] += 0.3061862178478971*(alphax[7]*fin[16]+fin[7]*alphax[16]+alphax[3]*fin[8]+fin[3]*alphax[8]+alphax[1]*fin[6]+fin[1]*alphax[6]+alphax[0]*fin[2]+fin[0]*alphax[2]); + out[7] += 0.3061862178478971*(alphax[6]*fin[16]+fin[6]*alphax[16]+alphax[2]*fin[8]+fin[2]*alphax[8]+alphax[1]*fin[7]+fin[1]*alphax[7]+alphax[0]*fin[3]+fin[0]*alphax[3]); + out[9] += 0.3061862178478971*(alphax[16]*fin[26]+alphax[8]*fin[19]+alphax[7]*fin[18]+alphax[6]*fin[17]+alphax[3]*fin[11]+alphax[2]*fin[10]+alphax[1]*fin[9]+alphax[0]*fin[4]); + out[12] += 0.3061862178478971*(alphax[16]*fin[27]+alphax[8]*fin[22]+alphax[7]*fin[21]+alphax[6]*fin[20]+alphax[3]*fin[14]+alphax[2]*fin[13]+alphax[1]*fin[12]+alphax[0]*fin[5]); + out[16] += 0.3061862178478971*(alphax[1]*fin[16]+fin[1]*alphax[16]+alphax[0]*fin[8]+fin[0]*alphax[8]+alphax[6]*fin[7]+fin[6]*alphax[7]+alphax[2]*fin[3]+fin[2]*alphax[3]); + out[17] += 0.3061862178478971*(alphax[7]*fin[26]+alphax[3]*fin[19]+alphax[16]*fin[18]+alphax[1]*fin[17]+alphax[8]*fin[11]+alphax[0]*fin[10]+alphax[6]*fin[9]+alphax[2]*fin[4]); + out[18] += 0.3061862178478971*(alphax[6]*fin[26]+alphax[2]*fin[19]+alphax[1]*fin[18]+alphax[16]*fin[17]+alphax[0]*fin[11]+alphax[8]*fin[10]+alphax[7]*fin[9]+alphax[3]*fin[4]); + out[20] += 0.3061862178478971*(alphax[7]*fin[27]+alphax[3]*fin[22]+alphax[16]*fin[21]+alphax[1]*fin[20]+alphax[8]*fin[14]+alphax[0]*fin[13]+alphax[6]*fin[12]+alphax[2]*fin[5]); + out[21] += 0.3061862178478971*(alphax[6]*fin[27]+alphax[2]*fin[22]+alphax[1]*fin[21]+alphax[16]*fin[20]+alphax[0]*fin[14]+alphax[8]*fin[13]+alphax[7]*fin[12]+alphax[3]*fin[5]); + out[23] += 0.3061862178478971*(alphax[16]*fin[31]+alphax[8]*fin[30]+alphax[7]*fin[29]+alphax[6]*fin[28]+alphax[3]*fin[25]+alphax[2]*fin[24]+alphax[1]*fin[23]+alphax[0]*fin[15]); + out[26] += 0.3061862178478971*(alphax[1]*fin[26]+alphax[0]*fin[19]+alphax[6]*fin[18]+alphax[7]*fin[17]+fin[9]*alphax[16]+alphax[2]*fin[11]+alphax[3]*fin[10]+fin[4]*alphax[8]); + out[27] += 0.3061862178478971*(alphax[1]*fin[27]+alphax[0]*fin[22]+alphax[6]*fin[21]+alphax[7]*fin[20]+fin[12]*alphax[16]+alphax[2]*fin[14]+alphax[3]*fin[13]+fin[5]*alphax[8]); + out[28] += 0.3061862178478971*(alphax[7]*fin[31]+alphax[3]*fin[30]+alphax[16]*fin[29]+alphax[1]*fin[28]+alphax[8]*fin[25]+alphax[0]*fin[24]+alphax[6]*fin[23]+alphax[2]*fin[15]); + out[29] += 0.3061862178478971*(alphax[6]*fin[31]+alphax[2]*fin[30]+alphax[1]*fin[29]+alphax[16]*fin[28]+alphax[0]*fin[25]+alphax[8]*fin[24]+alphax[7]*fin[23]+alphax[3]*fin[15]); + out[31] += 0.3061862178478971*(alphax[1]*fin[31]+alphax[0]*fin[30]+alphax[6]*fin[29]+alphax[7]*fin[28]+alphax[2]*fin[25]+alphax[3]*fin[24]+alphax[16]*fin[23]+alphax[8]*fin[15]); + out[33] += 0.3061862178478971*(alphax[16]*fin[43]+alphax[8]*fin[39]+alphax[7]*fin[38]+alphax[6]*fin[37]+alphax[3]*fin[35]+alphax[2]*fin[34]+alphax[1]*fin[33]+alphax[0]*fin[32]); + out[37] += 0.3061862178478971*(alphax[7]*fin[43]+alphax[3]*fin[39]+alphax[16]*fin[38]+alphax[1]*fin[37]+alphax[8]*fin[35]+alphax[0]*fin[34]+alphax[6]*fin[33]+alphax[2]*fin[32]); + out[38] += 0.3061862178478971*(alphax[6]*fin[43]+alphax[2]*fin[39]+alphax[1]*fin[38]+alphax[16]*fin[37]+alphax[0]*fin[35]+alphax[8]*fin[34]+alphax[7]*fin[33]+alphax[3]*fin[32]); + out[40] += 0.3061862178478971*(alphax[16]*fin[47]+alphax[8]*fin[46]+alphax[7]*fin[45]+alphax[6]*fin[44]+alphax[3]*fin[42]+alphax[2]*fin[41]+alphax[1]*fin[40]+alphax[0]*fin[36]); + out[43] += 0.3061862178478971*(alphax[1]*fin[43]+alphax[0]*fin[39]+alphax[6]*fin[38]+alphax[7]*fin[37]+alphax[2]*fin[35]+alphax[3]*fin[34]+alphax[16]*fin[33]+alphax[8]*fin[32]); + out[44] += 0.3061862178478971*(alphax[7]*fin[47]+alphax[3]*fin[46]+alphax[16]*fin[45]+alphax[1]*fin[44]+alphax[8]*fin[42]+alphax[0]*fin[41]+alphax[6]*fin[40]+alphax[2]*fin[36]); + out[45] += 0.3061862178478971*(alphax[6]*fin[47]+alphax[2]*fin[46]+alphax[1]*fin[45]+alphax[16]*fin[44]+alphax[0]*fin[42]+alphax[8]*fin[41]+alphax[7]*fin[40]+alphax[3]*fin[36]); + out[47] += 0.3061862178478971*(alphax[1]*fin[47]+alphax[0]*fin[46]+alphax[6]*fin[45]+alphax[7]*fin[44]+alphax[2]*fin[42]+alphax[3]*fin[41]+alphax[16]*fin[40]+alphax[8]*fin[36]); + + double alphay[48] = {0.}; + alphay[0] = 2.0*speeds[8]*rdy2; + alphay[1] = 2.0*speeds[9]*rdy2; + alphay[2] = 2.0*speeds[10]*rdy2; + alphay[3] = 2.0*speeds[11]*rdy2; + alphay[6] = 2.0*speeds[12]*rdy2; + alphay[7] = 2.0*speeds[13]*rdy2; + alphay[8] = 2.0*speeds[14]*rdy2; + alphay[16] = 2.0*speeds[15]*rdy2; + + + out[2] += 0.3061862178478971*(alphay[16]*fin[16]+alphay[8]*fin[8]+alphay[7]*fin[7]+alphay[6]*fin[6]+alphay[3]*fin[3]+alphay[2]*fin[2]+alphay[1]*fin[1]+alphay[0]*fin[0]); + out[6] += 0.3061862178478971*(alphay[8]*fin[16]+fin[8]*alphay[16]+alphay[3]*fin[7]+fin[3]*alphay[7]+alphay[2]*fin[6]+fin[2]*alphay[6]+alphay[0]*fin[1]+fin[0]*alphay[1]); + out[8] += 0.3061862178478971*(alphay[6]*fin[16]+fin[6]*alphay[16]+alphay[2]*fin[8]+fin[2]*alphay[8]+alphay[1]*fin[7]+fin[1]*alphay[7]+alphay[0]*fin[3]+fin[0]*alphay[3]); + out[10] += 0.3061862178478971*(alphay[16]*fin[26]+alphay[8]*fin[19]+alphay[7]*fin[18]+alphay[6]*fin[17]+alphay[3]*fin[11]+alphay[2]*fin[10]+alphay[1]*fin[9]+alphay[0]*fin[4]); + out[13] += 0.3061862178478971*(alphay[16]*fin[27]+alphay[8]*fin[22]+alphay[7]*fin[21]+alphay[6]*fin[20]+alphay[3]*fin[14]+alphay[2]*fin[13]+alphay[1]*fin[12]+alphay[0]*fin[5]); + out[16] += 0.3061862178478971*(alphay[2]*fin[16]+fin[2]*alphay[16]+alphay[6]*fin[8]+fin[6]*alphay[8]+alphay[0]*fin[7]+fin[0]*alphay[7]+alphay[1]*fin[3]+fin[1]*alphay[3]); + out[17] += 0.3061862178478971*(alphay[8]*fin[26]+alphay[16]*fin[19]+alphay[3]*fin[18]+alphay[2]*fin[17]+alphay[7]*fin[11]+alphay[6]*fin[10]+alphay[0]*fin[9]+alphay[1]*fin[4]); + out[19] += 0.3061862178478971*(alphay[6]*fin[26]+alphay[2]*fin[19]+alphay[1]*fin[18]+alphay[16]*fin[17]+alphay[0]*fin[11]+alphay[8]*fin[10]+alphay[7]*fin[9]+alphay[3]*fin[4]); + out[20] += 0.3061862178478971*(alphay[8]*fin[27]+alphay[16]*fin[22]+alphay[3]*fin[21]+alphay[2]*fin[20]+alphay[7]*fin[14]+alphay[6]*fin[13]+alphay[0]*fin[12]+alphay[1]*fin[5]); + out[22] += 0.3061862178478971*(alphay[6]*fin[27]+alphay[2]*fin[22]+alphay[1]*fin[21]+alphay[16]*fin[20]+alphay[0]*fin[14]+alphay[8]*fin[13]+alphay[7]*fin[12]+alphay[3]*fin[5]); + out[24] += 0.3061862178478971*(alphay[16]*fin[31]+alphay[8]*fin[30]+alphay[7]*fin[29]+alphay[6]*fin[28]+alphay[3]*fin[25]+alphay[2]*fin[24]+alphay[1]*fin[23]+alphay[0]*fin[15]); + out[26] += 0.3061862178478971*(alphay[2]*fin[26]+alphay[6]*fin[19]+alphay[0]*fin[18]+alphay[8]*fin[17]+fin[10]*alphay[16]+alphay[1]*fin[11]+alphay[3]*fin[9]+fin[4]*alphay[7]); + out[27] += 0.3061862178478971*(alphay[2]*fin[27]+alphay[6]*fin[22]+alphay[0]*fin[21]+alphay[8]*fin[20]+fin[13]*alphay[16]+alphay[1]*fin[14]+alphay[3]*fin[12]+fin[5]*alphay[7]); + out[28] += 0.3061862178478971*(alphay[8]*fin[31]+alphay[16]*fin[30]+alphay[3]*fin[29]+alphay[2]*fin[28]+alphay[7]*fin[25]+alphay[6]*fin[24]+alphay[0]*fin[23]+alphay[1]*fin[15]); + out[30] += 0.3061862178478971*(alphay[6]*fin[31]+alphay[2]*fin[30]+alphay[1]*fin[29]+alphay[16]*fin[28]+alphay[0]*fin[25]+alphay[8]*fin[24]+alphay[7]*fin[23]+alphay[3]*fin[15]); + out[31] += 0.3061862178478971*(alphay[2]*fin[31]+alphay[6]*fin[30]+alphay[0]*fin[29]+alphay[8]*fin[28]+alphay[1]*fin[25]+alphay[16]*fin[24]+alphay[3]*fin[23]+alphay[7]*fin[15]); + out[34] += 0.3061862178478971*(alphay[16]*fin[43]+alphay[8]*fin[39]+alphay[7]*fin[38]+alphay[6]*fin[37]+alphay[3]*fin[35]+alphay[2]*fin[34]+alphay[1]*fin[33]+alphay[0]*fin[32]); + out[37] += 0.3061862178478971*(alphay[8]*fin[43]+alphay[16]*fin[39]+alphay[3]*fin[38]+alphay[2]*fin[37]+alphay[7]*fin[35]+alphay[6]*fin[34]+alphay[0]*fin[33]+alphay[1]*fin[32]); + out[39] += 0.3061862178478971*(alphay[6]*fin[43]+alphay[2]*fin[39]+alphay[1]*fin[38]+alphay[16]*fin[37]+alphay[0]*fin[35]+alphay[8]*fin[34]+alphay[7]*fin[33]+alphay[3]*fin[32]); + out[41] += 0.3061862178478971*(alphay[16]*fin[47]+alphay[8]*fin[46]+alphay[7]*fin[45]+alphay[6]*fin[44]+alphay[3]*fin[42]+alphay[2]*fin[41]+alphay[1]*fin[40]+alphay[0]*fin[36]); + out[43] += 0.3061862178478971*(alphay[2]*fin[43]+alphay[6]*fin[39]+alphay[0]*fin[38]+alphay[8]*fin[37]+alphay[1]*fin[35]+alphay[16]*fin[34]+alphay[3]*fin[33]+alphay[7]*fin[32]); + out[44] += 0.3061862178478971*(alphay[8]*fin[47]+alphay[16]*fin[46]+alphay[3]*fin[45]+alphay[2]*fin[44]+alphay[7]*fin[42]+alphay[6]*fin[41]+alphay[0]*fin[40]+alphay[1]*fin[36]); + out[46] += 0.3061862178478971*(alphay[6]*fin[47]+alphay[2]*fin[46]+alphay[1]*fin[45]+alphay[16]*fin[44]+alphay[0]*fin[42]+alphay[8]*fin[41]+alphay[7]*fin[40]+alphay[3]*fin[36]); + out[47] += 0.3061862178478971*(alphay[2]*fin[47]+alphay[6]*fin[46]+alphay[0]*fin[45]+alphay[8]*fin[44]+alphay[1]*fin[42]+alphay[16]*fin[41]+alphay[3]*fin[40]+alphay[7]*fin[36]); + + double alphaz[48] = {0.}; + alphaz[0] = 2.0*speeds[16]*rdz2; + alphaz[1] = 2.0*speeds[17]*rdz2; + alphaz[2] = 2.0*speeds[18]*rdz2; + alphaz[3] = 2.0*speeds[19]*rdz2; + alphaz[6] = 2.0*speeds[20]*rdz2; + alphaz[7] = 2.0*speeds[21]*rdz2; + alphaz[8] = 2.0*speeds[22]*rdz2; + alphaz[16] = 2.0*speeds[23]*rdz2; + + + out[3] += 0.3061862178478971*(alphaz[16]*fin[16]+alphaz[8]*fin[8]+alphaz[7]*fin[7]+alphaz[6]*fin[6]+alphaz[3]*fin[3]+alphaz[2]*fin[2]+alphaz[1]*fin[1]+alphaz[0]*fin[0]); + out[7] += 0.3061862178478971*(alphaz[8]*fin[16]+fin[8]*alphaz[16]+alphaz[3]*fin[7]+fin[3]*alphaz[7]+alphaz[2]*fin[6]+fin[2]*alphaz[6]+alphaz[0]*fin[1]+fin[0]*alphaz[1]); + out[8] += 0.3061862178478971*(alphaz[7]*fin[16]+fin[7]*alphaz[16]+alphaz[3]*fin[8]+fin[3]*alphaz[8]+alphaz[1]*fin[6]+fin[1]*alphaz[6]+alphaz[0]*fin[2]+fin[0]*alphaz[2]); + out[11] += 0.3061862178478971*(alphaz[16]*fin[26]+alphaz[8]*fin[19]+alphaz[7]*fin[18]+alphaz[6]*fin[17]+alphaz[3]*fin[11]+alphaz[2]*fin[10]+alphaz[1]*fin[9]+alphaz[0]*fin[4]); + out[14] += 0.3061862178478971*(alphaz[16]*fin[27]+alphaz[8]*fin[22]+alphaz[7]*fin[21]+alphaz[6]*fin[20]+alphaz[3]*fin[14]+alphaz[2]*fin[13]+alphaz[1]*fin[12]+alphaz[0]*fin[5]); + out[16] += 0.3061862178478971*(alphaz[3]*fin[16]+fin[3]*alphaz[16]+alphaz[7]*fin[8]+fin[7]*alphaz[8]+alphaz[0]*fin[6]+fin[0]*alphaz[6]+alphaz[1]*fin[2]+fin[1]*alphaz[2]); + out[18] += 0.3061862178478971*(alphaz[8]*fin[26]+alphaz[16]*fin[19]+alphaz[3]*fin[18]+alphaz[2]*fin[17]+alphaz[7]*fin[11]+alphaz[6]*fin[10]+alphaz[0]*fin[9]+alphaz[1]*fin[4]); + out[19] += 0.3061862178478971*(alphaz[7]*fin[26]+alphaz[3]*fin[19]+alphaz[16]*fin[18]+alphaz[1]*fin[17]+alphaz[8]*fin[11]+alphaz[0]*fin[10]+alphaz[6]*fin[9]+alphaz[2]*fin[4]); + out[21] += 0.3061862178478971*(alphaz[8]*fin[27]+alphaz[16]*fin[22]+alphaz[3]*fin[21]+alphaz[2]*fin[20]+alphaz[7]*fin[14]+alphaz[6]*fin[13]+alphaz[0]*fin[12]+alphaz[1]*fin[5]); + out[22] += 0.3061862178478971*(alphaz[7]*fin[27]+alphaz[3]*fin[22]+alphaz[16]*fin[21]+alphaz[1]*fin[20]+alphaz[8]*fin[14]+alphaz[0]*fin[13]+alphaz[6]*fin[12]+alphaz[2]*fin[5]); + out[25] += 0.3061862178478971*(alphaz[16]*fin[31]+alphaz[8]*fin[30]+alphaz[7]*fin[29]+alphaz[6]*fin[28]+alphaz[3]*fin[25]+alphaz[2]*fin[24]+alphaz[1]*fin[23]+alphaz[0]*fin[15]); + out[26] += 0.3061862178478971*(alphaz[3]*fin[26]+alphaz[7]*fin[19]+alphaz[8]*fin[18]+alphaz[0]*fin[17]+fin[11]*alphaz[16]+alphaz[1]*fin[10]+alphaz[2]*fin[9]+fin[4]*alphaz[6]); + out[27] += 0.3061862178478971*(alphaz[3]*fin[27]+alphaz[7]*fin[22]+alphaz[8]*fin[21]+alphaz[0]*fin[20]+fin[14]*alphaz[16]+alphaz[1]*fin[13]+alphaz[2]*fin[12]+fin[5]*alphaz[6]); + out[29] += 0.3061862178478971*(alphaz[8]*fin[31]+alphaz[16]*fin[30]+alphaz[3]*fin[29]+alphaz[2]*fin[28]+alphaz[7]*fin[25]+alphaz[6]*fin[24]+alphaz[0]*fin[23]+alphaz[1]*fin[15]); + out[30] += 0.3061862178478971*(alphaz[7]*fin[31]+alphaz[3]*fin[30]+alphaz[16]*fin[29]+alphaz[1]*fin[28]+alphaz[8]*fin[25]+alphaz[0]*fin[24]+alphaz[6]*fin[23]+alphaz[2]*fin[15]); + out[31] += 0.3061862178478971*(alphaz[3]*fin[31]+alphaz[7]*fin[30]+alphaz[8]*fin[29]+alphaz[0]*fin[28]+alphaz[16]*fin[25]+alphaz[1]*fin[24]+alphaz[2]*fin[23]+alphaz[6]*fin[15]); + out[35] += 0.3061862178478971*(alphaz[16]*fin[43]+alphaz[8]*fin[39]+alphaz[7]*fin[38]+alphaz[6]*fin[37]+alphaz[3]*fin[35]+alphaz[2]*fin[34]+alphaz[1]*fin[33]+alphaz[0]*fin[32]); + out[38] += 0.3061862178478971*(alphaz[8]*fin[43]+alphaz[16]*fin[39]+alphaz[3]*fin[38]+alphaz[2]*fin[37]+alphaz[7]*fin[35]+alphaz[6]*fin[34]+alphaz[0]*fin[33]+alphaz[1]*fin[32]); + out[39] += 0.3061862178478971*(alphaz[7]*fin[43]+alphaz[3]*fin[39]+alphaz[16]*fin[38]+alphaz[1]*fin[37]+alphaz[8]*fin[35]+alphaz[0]*fin[34]+alphaz[6]*fin[33]+alphaz[2]*fin[32]); + out[42] += 0.3061862178478971*(alphaz[16]*fin[47]+alphaz[8]*fin[46]+alphaz[7]*fin[45]+alphaz[6]*fin[44]+alphaz[3]*fin[42]+alphaz[2]*fin[41]+alphaz[1]*fin[40]+alphaz[0]*fin[36]); + out[43] += 0.3061862178478971*(alphaz[3]*fin[43]+alphaz[7]*fin[39]+alphaz[8]*fin[38]+alphaz[0]*fin[37]+alphaz[16]*fin[35]+alphaz[1]*fin[34]+alphaz[2]*fin[33]+alphaz[6]*fin[32]); + out[45] += 0.3061862178478971*(alphaz[8]*fin[47]+alphaz[16]*fin[46]+alphaz[3]*fin[45]+alphaz[2]*fin[44]+alphaz[7]*fin[42]+alphaz[6]*fin[41]+alphaz[0]*fin[40]+alphaz[1]*fin[36]); + out[46] += 0.3061862178478971*(alphaz[7]*fin[47]+alphaz[3]*fin[46]+alphaz[16]*fin[45]+alphaz[1]*fin[44]+alphaz[8]*fin[42]+alphaz[0]*fin[41]+alphaz[6]*fin[40]+alphaz[2]*fin[36]); + out[47] += 0.3061862178478971*(alphaz[3]*fin[47]+alphaz[7]*fin[46]+alphaz[8]*fin[45]+alphaz[0]*fin[44]+alphaz[16]*fin[42]+alphaz[1]*fin[41]+alphaz[2]*fin[40]+alphaz[6]*fin[36]); + + return 0.; +} diff --git a/gyrokinetic/ker/dg_gyrokinetic_passive/gkyl_dg_gyrokinetic_passive_kernels.h b/gyrokinetic/ker/dg_gyrokinetic_passive/gkyl_dg_gyrokinetic_passive_kernels.h new file mode 100644 index 0000000000..4e616a300e --- /dev/null +++ b/gyrokinetic/ker/dg_gyrokinetic_passive/gkyl_dg_gyrokinetic_passive_kernels.h @@ -0,0 +1,91 @@ +#pragma once + +#include +#include +#include +#include + +EXTERN_C_BEG + +GKYL_CU_DH double dg_gyrokinetic_passive_vol_1x1v_ser_p1(const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const double *bmag, const double *speeds, + const double *dualcurlbhatoverB, const double *rtg33inv, const double* bioverJB, + const double *fin, double* GKYL_RESTRICT out); +GKYL_CU_DH double dg_gyrokinetic_passive_surfx_1x1v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_l, const double *vmap_prime_c, const double *vmap_prime_r, + const double *flux_surf_l, const double *flux_surf_r, + double* GKYL_RESTRICT out); +GKYL_CU_DH double dg_gyrokinetic_passive_boundary_surfx_1x1v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_edge, const double *vmap_prime_skin, + const double *flux_surf_edge, const double *flux_surf_skin, + const int edge, double* GKYL_RESTRICT out); + +GKYL_CU_DH double dg_gyrokinetic_passive_vol_1x2v_ser_p1(const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const double *bmag, const double *speeds, + const double *dualcurlbhatoverB, const double *rtg33inv, const double* bioverJB, + const double *fin, double* GKYL_RESTRICT out); +GKYL_CU_DH double dg_gyrokinetic_passive_surfx_1x2v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_l, const double *vmap_prime_c, const double *vmap_prime_r, + const double *flux_surf_l, const double *flux_surf_r, + double* GKYL_RESTRICT out); +GKYL_CU_DH double dg_gyrokinetic_passive_boundary_surfx_1x2v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_edge, const double *vmap_prime_skin, + const double *flux_surf_edge, const double *flux_surf_skin, + const int edge, double* GKYL_RESTRICT out); + +GKYL_CU_DH double dg_gyrokinetic_passive_vol_2x2v_ser_p1(const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const double *bmag, const double *speeds, + const double *dualcurlbhatoverB, const double *rtg33inv, const double* bioverJB, + const double *fin, double* GKYL_RESTRICT out); +GKYL_CU_DH double dg_gyrokinetic_passive_surfx_2x2v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_l, const double *vmap_prime_c, const double *vmap_prime_r, + const double *flux_surf_l, const double *flux_surf_r, + double* GKYL_RESTRICT out); +GKYL_CU_DH double dg_gyrokinetic_passive_boundary_surfx_2x2v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_edge, const double *vmap_prime_skin, + const double *flux_surf_edge, const double *flux_surf_skin, + const int edge, double* GKYL_RESTRICT out); +GKYL_CU_DH double dg_gyrokinetic_passive_surfy_2x2v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_l, const double *vmap_prime_c, const double *vmap_prime_r, + const double *flux_surf_l, const double *flux_surf_r, + double* GKYL_RESTRICT out); +GKYL_CU_DH double dg_gyrokinetic_passive_boundary_surfy_2x2v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_edge, const double *vmap_prime_skin, + const double *flux_surf_edge, const double *flux_surf_skin, + const int edge, double* GKYL_RESTRICT out); + +GKYL_CU_DH double dg_gyrokinetic_passive_vol_3x2v_ser_p1(const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const double *bmag, const double *speeds, + const double *dualcurlbhatoverB, const double *rtg33inv, const double* bioverJB, + const double *fin, double* GKYL_RESTRICT out); +GKYL_CU_DH double dg_gyrokinetic_passive_surfx_3x2v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_l, const double *vmap_prime_c, const double *vmap_prime_r, + const double *flux_surf_l, const double *flux_surf_r, + double* GKYL_RESTRICT out); +GKYL_CU_DH double dg_gyrokinetic_passive_boundary_surfx_3x2v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_edge, const double *vmap_prime_skin, + const double *flux_surf_edge, const double *flux_surf_skin, + const int edge, double* GKYL_RESTRICT out); +GKYL_CU_DH double dg_gyrokinetic_passive_surfy_3x2v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_l, const double *vmap_prime_c, const double *vmap_prime_r, + const double *flux_surf_l, const double *flux_surf_r, + double* GKYL_RESTRICT out); +GKYL_CU_DH double dg_gyrokinetic_passive_boundary_surfy_3x2v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_edge, const double *vmap_prime_skin, + const double *flux_surf_edge, const double *flux_surf_skin, + const int edge, double* GKYL_RESTRICT out); +GKYL_CU_DH double dg_gyrokinetic_passive_surfz_3x2v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_l, const double *vmap_prime_c, const double *vmap_prime_r, + const double *flux_surf_l, const double *flux_surf_r, + double* GKYL_RESTRICT out); +GKYL_CU_DH double dg_gyrokinetic_passive_boundary_surfz_3x2v_ser_p1(const double *w, const double *dxv, + const double *vmap_prime_edge, const double *vmap_prime_skin, + const double *flux_surf_edge, const double *flux_surf_skin, + const int edge, double* GKYL_RESTRICT out); + + +EXTERN_C_END diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfx_1x1v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfx_1x1v_ser_p1.c new file mode 100644 index 0000000000..955833663c --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfx_1x1v_ser_p1.c @@ -0,0 +1,82 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_edge_surfx_1x1v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdvpar2 = 2.0/dxv[1]; + + double *flux_surf_nodal = &flux_surf[0]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.7745966692414834*JfL[5]+0.4472135954999579*JfL[4]-1.1618950038622249*JfL[3]-0.6708203932499369*JfL[2]+0.8660254037844386*JfL[1]+0.5*JfL[0]; + JfR_quad = -(0.7745966692414834*JfR[5])+0.4472135954999579*JfR[4]+1.1618950038622249*JfR[3]-0.6708203932499369*JfR[2]-0.8660254037844386*JfR[1]+0.5*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.9682458365518543*JfL[5])-0.5590169943749475*JfL[4]+0.8660254037844386*JfL[1]+0.5*JfL[0]; + JfR_quad = 0.9682458365518543*JfR[5]-0.5590169943749475*JfR[4]-0.8660254037844386*JfR[1]+0.5*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.7745966692414834*JfL[5]+0.4472135954999579*JfL[4]+1.1618950038622249*JfL[3]+0.6708203932499369*JfL[2]+0.8660254037844386*JfL[1]+0.5*JfL[0]; + JfR_quad = -(0.7745966692414834*JfR[5])+0.4472135954999579*JfR[4]-1.1618950038622249*JfR[3]+0.6708203932499369*JfR[2]-0.8660254037844386*JfR[1]+0.5*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdx2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfx_1x2v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfx_1x2v_ser_p1.c new file mode 100644 index 0000000000..80ec8064d9 --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfx_1x2v_ser_p1.c @@ -0,0 +1,109 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_edge_surfx_1x2v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdvpar2 = 2.0/dxv[1]; + + double *flux_surf_nodal = &flux_surf[0]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.5477225575051661*JfL[11])-0.3162277660168379*JfL[10]+0.5477225575051661*JfL[9]+0.3162277660168379*JfL[8]+0.8215838362577489*JfL[7]+0.4743416490252568*JfL[6]-0.6123724356957944*JfL[5]-0.8215838362577489*JfL[4]-0.3535533905932737*JfL[3]-0.4743416490252568*JfL[2]+0.6123724356957944*JfL[1]+0.3535533905932737*JfL[0]; + JfR_quad = 0.5477225575051661*JfR[11]-0.3162277660168379*JfR[10]-0.5477225575051661*JfR[9]+0.3162277660168379*JfR[8]-0.8215838362577489*JfR[7]+0.4743416490252568*JfR[6]+0.6123724356957944*JfR[5]+0.8215838362577489*JfR[4]-0.3535533905932737*JfR[3]-0.4743416490252568*JfR[2]-0.6123724356957944*JfR[1]+0.3535533905932737*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.6846531968814573*JfL[11]+0.39528470752104733*JfL[10]-0.6846531968814574*JfL[9]-0.3952847075210473*JfL[8]-0.6123724356957944*JfL[5]-0.3535533905932737*JfL[3]+0.6123724356957944*JfL[1]+0.3535533905932737*JfL[0]; + JfR_quad = -(0.6846531968814573*JfR[11])+0.39528470752104733*JfR[10]+0.6846531968814574*JfR[9]-0.3952847075210473*JfR[8]+0.6123724356957944*JfR[5]-0.3535533905932737*JfR[3]-0.6123724356957944*JfR[1]+0.3535533905932737*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.5477225575051661*JfL[11])-0.3162277660168379*JfL[10]+0.5477225575051661*JfL[9]+0.3162277660168379*JfL[8]-0.8215838362577489*JfL[7]-0.4743416490252568*JfL[6]-0.6123724356957944*JfL[5]+0.8215838362577489*JfL[4]-0.3535533905932737*JfL[3]+0.4743416490252568*JfL[2]+0.6123724356957944*JfL[1]+0.3535533905932737*JfL[0]; + JfR_quad = 0.5477225575051661*JfR[11]-0.3162277660168379*JfR[10]-0.5477225575051661*JfR[9]+0.3162277660168379*JfR[8]+0.8215838362577489*JfR[7]-0.4743416490252568*JfR[6]+0.6123724356957944*JfR[5]-0.8215838362577489*JfR[4]-0.3535533905932737*JfR[3]+0.4743416490252568*JfR[2]-0.6123724356957944*JfR[1]+0.3535533905932737*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.5477225575051661*JfL[11]+0.3162277660168379*JfL[10]+0.5477225575051661*JfL[9]+0.3162277660168379*JfL[8]-0.8215838362577489*JfL[7]-0.4743416490252568*JfL[6]+0.6123724356957944*JfL[5]-0.8215838362577489*JfL[4]+0.3535533905932737*JfL[3]-0.4743416490252568*JfL[2]+0.6123724356957944*JfL[1]+0.3535533905932737*JfL[0]; + JfR_quad = -(0.5477225575051661*JfR[11])+0.3162277660168379*JfR[10]-0.5477225575051661*JfR[9]+0.3162277660168379*JfR[8]+0.8215838362577489*JfR[7]-0.4743416490252568*JfR[6]-0.6123724356957944*JfR[5]+0.8215838362577489*JfR[4]+0.3535533905932737*JfR[3]-0.4743416490252568*JfR[2]-0.6123724356957944*JfR[1]+0.3535533905932737*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[3] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.6846531968814573*JfL[11])-0.39528470752104733*JfL[10]-0.6846531968814574*JfL[9]-0.3952847075210473*JfL[8]+0.6123724356957944*JfL[5]+0.3535533905932737*JfL[3]+0.6123724356957944*JfL[1]+0.3535533905932737*JfL[0]; + JfR_quad = 0.6846531968814573*JfR[11]-0.39528470752104733*JfR[10]+0.6846531968814574*JfR[9]-0.3952847075210473*JfR[8]-0.6123724356957944*JfR[5]+0.3535533905932737*JfR[3]-0.6123724356957944*JfR[1]+0.3535533905932737*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[4] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.5477225575051661*JfL[11]+0.3162277660168379*JfL[10]+0.5477225575051661*JfL[9]+0.3162277660168379*JfL[8]+0.8215838362577489*JfL[7]+0.4743416490252568*JfL[6]+0.6123724356957944*JfL[5]+0.8215838362577489*JfL[4]+0.3535533905932737*JfL[3]+0.4743416490252568*JfL[2]+0.6123724356957944*JfL[1]+0.3535533905932737*JfL[0]; + JfR_quad = -(0.5477225575051661*JfR[11])+0.3162277660168379*JfR[10]-0.5477225575051661*JfR[9]+0.3162277660168379*JfR[8]-0.8215838362577489*JfR[7]+0.4743416490252568*JfR[6]-0.6123724356957944*JfR[5]-0.8215838362577489*JfR[4]+0.3535533905932737*JfR[3]+0.4743416490252568*JfR[2]-0.6123724356957944*JfR[1]+0.3535533905932737*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[5] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdx2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfx_2x2v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfx_2x2v_ser_p1.c new file mode 100644 index 0000000000..f8ca73961f --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfx_2x2v_ser_p1.c @@ -0,0 +1,174 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_edge_surfx_2x2v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdz2 = 2.0/dxv[1]; + double rdvpar2 = 2.0/dxv[2]; + + double *flux_surf_nodal = &flux_surf[0]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = -(0.8660254037844386*speedsL[3])-0.5*speedsL[2]+0.8660254037844386*speedsL[1]+0.5*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3872983346207417*JfL[23]+0.22360679774997896*JfL[22]-0.38729833462074165*(JfL[21]+JfL[20])-0.22360679774997894*JfL[19]-0.22360679774997902*JfL[18]+0.3872983346207417*JfL[17]+0.22360679774997896*JfL[16]-0.5809475019311124*JfL[15]-0.33541019662496846*JfL[14]+0.5809475019311124*JfL[13]+0.4330127018922193*JfL[12]+0.5809475019311124*JfL[11]+0.33541019662496846*JfL[10]+0.25*JfL[9]-0.4330127018922193*JfL[8]+0.33541019662496846*JfL[7]-0.5809475019311124*JfL[6]-0.4330127018922193*JfL[5]-0.25*JfL[4]-0.33541019662496846*JfL[3]-0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.3872983346207417*JfR[23])+0.22360679774997896*JfR[22]+0.38729833462074165*(JfR[21]+JfR[20])-0.22360679774997894*JfR[19]-0.22360679774997902*JfR[18]-0.3872983346207417*JfR[17]+0.22360679774997896*JfR[16]+0.5809475019311124*JfR[15]-0.33541019662496846*JfR[14]-0.5809475019311124*JfR[13]-0.4330127018922193*JfR[12]-0.5809475019311124*JfR[11]+0.33541019662496846*JfR[10]+0.25*JfR[9]+0.4330127018922193*JfR[8]+0.33541019662496846*JfR[7]+0.5809475019311124*JfR[6]+0.4330127018922193*JfR[5]-0.25*JfR[4]-0.33541019662496846*JfR[3]-0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsL[3])-0.5*speedsL[2]+0.8660254037844386*speedsL[1]+0.5*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.4841229182759271*JfL[23])-0.2795084971874737*JfL[22]+0.4841229182759271*(JfL[21]+JfL[20])+0.2795084971874738*(JfL[19]+JfL[18])-0.4841229182759271*JfL[17]-0.2795084971874737*JfL[16]+0.4330127018922193*JfL[12]+0.25*JfL[9]-0.4330127018922193*(JfL[8]+JfL[5])-0.25*(JfL[4]+JfL[2])+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.4841229182759271*JfR[23]-0.2795084971874737*JfR[22]-0.4841229182759271*(JfR[21]+JfR[20])+0.2795084971874738*(JfR[19]+JfR[18])+0.4841229182759271*JfR[17]-0.2795084971874737*JfR[16]-0.4330127018922193*JfR[12]+0.25*JfR[9]+0.4330127018922193*(JfR[8]+JfR[5])-0.25*(JfR[4]+JfR[2])-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsL[3])-0.5*speedsL[2]+0.8660254037844386*speedsL[1]+0.5*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3872983346207417*JfL[23]+0.22360679774997896*JfL[22]-0.38729833462074165*(JfL[21]+JfL[20])-0.22360679774997894*JfL[19]-0.22360679774997902*JfL[18]+0.3872983346207417*JfL[17]+0.22360679774997896*JfL[16]+0.5809475019311124*JfL[15]+0.33541019662496846*JfL[14]-0.5809475019311124*JfL[13]+0.4330127018922193*JfL[12]-0.5809475019311124*JfL[11]-0.33541019662496846*JfL[10]+0.25*JfL[9]-0.4330127018922193*JfL[8]-0.33541019662496846*JfL[7]+0.5809475019311124*JfL[6]-0.4330127018922193*JfL[5]-0.25*JfL[4]+0.33541019662496846*JfL[3]-0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.3872983346207417*JfR[23])+0.22360679774997896*JfR[22]+0.38729833462074165*(JfR[21]+JfR[20])-0.22360679774997894*JfR[19]-0.22360679774997902*JfR[18]-0.3872983346207417*JfR[17]+0.22360679774997896*JfR[16]-0.5809475019311124*JfR[15]+0.33541019662496846*JfR[14]+0.5809475019311124*JfR[13]-0.4330127018922193*JfR[12]+0.5809475019311124*JfR[11]-0.33541019662496846*JfR[10]+0.25*JfR[9]+0.4330127018922193*JfR[8]-0.33541019662496846*JfR[7]-0.5809475019311124*JfR[6]+0.4330127018922193*JfR[5]-0.25*JfR[4]+0.33541019662496846*JfR[3]-0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsL[3])-0.5*speedsL[2]+0.8660254037844386*speedsL[1]+0.5*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3872983346207417*JfL[23])-0.22360679774997896*JfL[22]+0.38729833462074165*JfL[21]-0.38729833462074165*JfL[20]+0.22360679774997894*JfL[19]-0.22360679774997902*JfL[18]+0.3872983346207417*JfL[17]+0.22360679774997896*JfL[16]+0.5809475019311124*JfL[15]+0.33541019662496846*JfL[14]-0.5809475019311124*JfL[13]-0.4330127018922193*JfL[12]+0.5809475019311124*JfL[11]-0.33541019662496846*JfL[10]-0.25*JfL[9]+0.4330127018922193*JfL[8]+0.33541019662496846*JfL[7]-0.5809475019311124*JfL[6]-0.4330127018922193*JfL[5]+0.25*JfL[4]-0.33541019662496846*JfL[3]-0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.3872983346207417*JfR[23]-0.22360679774997896*JfR[22]-0.38729833462074165*JfR[21]+0.38729833462074165*JfR[20]+0.22360679774997894*JfR[19]-0.22360679774997902*JfR[18]-0.3872983346207417*JfR[17]+0.22360679774997896*JfR[16]-0.5809475019311124*JfR[15]+0.33541019662496846*JfR[14]+0.5809475019311124*JfR[13]+0.4330127018922193*JfR[12]-0.5809475019311124*JfR[11]-0.33541019662496846*JfR[10]-0.25*JfR[9]-0.4330127018922193*JfR[8]+0.33541019662496846*JfR[7]+0.5809475019311124*JfR[6]+0.4330127018922193*JfR[5]+0.25*JfR[4]-0.33541019662496846*JfR[3]-0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[3] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsL[3])-0.5*speedsL[2]+0.8660254037844386*speedsL[1]+0.5*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.4841229182759271*JfL[23]+0.2795084971874737*JfL[22]-0.4841229182759271*JfL[21]+0.4841229182759271*JfL[20]-0.2795084971874738*JfL[19]+0.2795084971874738*JfL[18]-0.4841229182759271*JfL[17]-0.2795084971874737*JfL[16]-0.4330127018922193*JfL[12]-0.25*JfL[9]+0.4330127018922193*JfL[8]-0.4330127018922193*JfL[5]+0.25*JfL[4]-0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.4841229182759271*JfR[23])+0.2795084971874737*JfR[22]+0.4841229182759271*JfR[21]-0.4841229182759271*JfR[20]-0.2795084971874738*JfR[19]+0.2795084971874738*JfR[18]+0.4841229182759271*JfR[17]-0.2795084971874737*JfR[16]+0.4330127018922193*JfR[12]-0.25*JfR[9]-0.4330127018922193*JfR[8]+0.4330127018922193*JfR[5]+0.25*JfR[4]-0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[4] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsL[3])-0.5*speedsL[2]+0.8660254037844386*speedsL[1]+0.5*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3872983346207417*JfL[23])-0.22360679774997896*JfL[22]+0.38729833462074165*JfL[21]-0.38729833462074165*JfL[20]+0.22360679774997894*JfL[19]-0.22360679774997902*JfL[18]+0.3872983346207417*JfL[17]+0.22360679774997896*JfL[16]-0.5809475019311124*JfL[15]-0.33541019662496846*JfL[14]+0.5809475019311124*JfL[13]-0.4330127018922193*JfL[12]-0.5809475019311124*JfL[11]+0.33541019662496846*JfL[10]-0.25*JfL[9]+0.4330127018922193*JfL[8]-0.33541019662496846*JfL[7]+0.5809475019311124*JfL[6]-0.4330127018922193*JfL[5]+0.25*JfL[4]+0.33541019662496846*JfL[3]-0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.3872983346207417*JfR[23]-0.22360679774997896*JfR[22]-0.38729833462074165*JfR[21]+0.38729833462074165*JfR[20]+0.22360679774997894*JfR[19]-0.22360679774997902*JfR[18]-0.3872983346207417*JfR[17]+0.22360679774997896*JfR[16]+0.5809475019311124*JfR[15]-0.33541019662496846*JfR[14]-0.5809475019311124*JfR[13]+0.4330127018922193*JfR[12]+0.5809475019311124*JfR[11]+0.33541019662496846*JfR[10]-0.25*JfR[9]-0.4330127018922193*JfR[8]-0.33541019662496846*JfR[7]-0.5809475019311124*JfR[6]+0.4330127018922193*JfR[5]+0.25*JfR[4]+0.33541019662496846*JfR[3]-0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[5] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[1].bmag; + Jc_quad = gkdgs[1].Jc; + B3_quad = gkdgs[1].B3; + normcurlbhat_quad = gkdgs[1].normcurlbhat; + bhat_quad[0] = gkdgs[1].bhat.x[0]; + bhat_quad[1] = gkdgs[1].bhat.x[1]; + bhat_quad[2] = gkdgs[1].bhat.x[2]; + area_elem_quad = dgs[1].area_elem; + + + alpha_quad = 0.8660254037844386*speedsL[3]+0.5*speedsL[2]+0.8660254037844386*speedsL[1]+0.5*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3872983346207417*JfL[23])-0.22360679774997896*JfL[22]-0.38729833462074165*JfL[21]+0.38729833462074165*JfL[20]-0.22360679774997894*JfL[19]+0.22360679774997902*JfL[18]+0.3872983346207417*JfL[17]+0.22360679774997896*JfL[16]+0.5809475019311124*JfL[15]+0.33541019662496846*JfL[14]+0.5809475019311124*JfL[13]-0.4330127018922193*JfL[12]-0.5809475019311124*JfL[11]+0.33541019662496846*JfL[10]-0.25*JfL[9]-0.4330127018922193*JfL[8]-0.33541019662496846*JfL[7]-0.5809475019311124*JfL[6]+0.4330127018922193*JfL[5]-0.25*JfL[4]-0.33541019662496846*JfL[3]+0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.3872983346207417*JfR[23]-0.22360679774997896*JfR[22]+0.38729833462074165*JfR[21]-0.38729833462074165*JfR[20]-0.22360679774997894*JfR[19]+0.22360679774997902*JfR[18]-0.3872983346207417*JfR[17]+0.22360679774997896*JfR[16]-0.5809475019311124*JfR[15]+0.33541019662496846*JfR[14]-0.5809475019311124*JfR[13]+0.4330127018922193*JfR[12]+0.5809475019311124*JfR[11]+0.33541019662496846*JfR[10]-0.25*JfR[9]+0.4330127018922193*JfR[8]-0.33541019662496846*JfR[7]+0.5809475019311124*JfR[6]-0.4330127018922193*JfR[5]-0.25*JfR[4]-0.33541019662496846*JfR[3]+0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[6] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsL[3]+0.5*speedsL[2]+0.8660254037844386*speedsL[1]+0.5*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.4841229182759271*JfL[23]+0.2795084971874737*JfL[22]+0.4841229182759271*JfL[21]-0.4841229182759271*JfL[20]+0.2795084971874738*JfL[19]-0.2795084971874738*JfL[18]-0.4841229182759271*JfL[17]-0.2795084971874737*JfL[16]-0.4330127018922193*JfL[12]-0.25*JfL[9]-0.4330127018922193*JfL[8]+0.4330127018922193*JfL[5]-0.25*JfL[4]+0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.4841229182759271*JfR[23])+0.2795084971874737*JfR[22]-0.4841229182759271*JfR[21]+0.4841229182759271*JfR[20]+0.2795084971874738*JfR[19]-0.2795084971874738*JfR[18]+0.4841229182759271*JfR[17]-0.2795084971874737*JfR[16]+0.4330127018922193*JfR[12]-0.25*JfR[9]+0.4330127018922193*JfR[8]-0.4330127018922193*JfR[5]-0.25*JfR[4]+0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[7] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsL[3]+0.5*speedsL[2]+0.8660254037844386*speedsL[1]+0.5*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3872983346207417*JfL[23])-0.22360679774997896*JfL[22]-0.38729833462074165*JfL[21]+0.38729833462074165*JfL[20]-0.22360679774997894*JfL[19]+0.22360679774997902*JfL[18]+0.3872983346207417*JfL[17]+0.22360679774997896*JfL[16]-0.5809475019311124*JfL[15]-0.33541019662496846*JfL[14]-0.5809475019311124*JfL[13]-0.4330127018922193*JfL[12]+0.5809475019311124*JfL[11]-0.33541019662496846*JfL[10]-0.25*JfL[9]-0.4330127018922193*JfL[8]+0.33541019662496846*JfL[7]+0.5809475019311124*JfL[6]+0.4330127018922193*JfL[5]-0.25*JfL[4]+0.33541019662496846*JfL[3]+0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.3872983346207417*JfR[23]-0.22360679774997896*JfR[22]+0.38729833462074165*JfR[21]-0.38729833462074165*JfR[20]-0.22360679774997894*JfR[19]+0.22360679774997902*JfR[18]-0.3872983346207417*JfR[17]+0.22360679774997896*JfR[16]+0.5809475019311124*JfR[15]-0.33541019662496846*JfR[14]+0.5809475019311124*JfR[13]+0.4330127018922193*JfR[12]-0.5809475019311124*JfR[11]-0.33541019662496846*JfR[10]-0.25*JfR[9]+0.4330127018922193*JfR[8]+0.33541019662496846*JfR[7]-0.5809475019311124*JfR[6]-0.4330127018922193*JfR[5]-0.25*JfR[4]+0.33541019662496846*JfR[3]+0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[8] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsL[3]+0.5*speedsL[2]+0.8660254037844386*speedsL[1]+0.5*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3872983346207417*JfL[23]+0.22360679774997896*JfL[22]+0.38729833462074165*(JfL[21]+JfL[20])+0.22360679774997894*JfL[19]+0.22360679774997902*JfL[18]+0.3872983346207417*JfL[17]+0.22360679774997896*JfL[16]-0.5809475019311124*JfL[15]-0.33541019662496846*JfL[14]-0.5809475019311124*JfL[13]+0.4330127018922193*JfL[12]-0.5809475019311124*JfL[11]-0.33541019662496846*JfL[10]+0.25*JfL[9]+0.4330127018922193*JfL[8]-0.33541019662496846*JfL[7]-0.5809475019311124*JfL[6]+0.4330127018922193*JfL[5]+0.25*JfL[4]-0.33541019662496846*JfL[3]+0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.3872983346207417*JfR[23])+0.22360679774997896*JfR[22]-0.38729833462074165*(JfR[21]+JfR[20])+0.22360679774997894*JfR[19]+0.22360679774997902*JfR[18]-0.3872983346207417*JfR[17]+0.22360679774997896*JfR[16]+0.5809475019311124*JfR[15]-0.33541019662496846*JfR[14]+0.5809475019311124*JfR[13]-0.4330127018922193*JfR[12]+0.5809475019311124*JfR[11]-0.33541019662496846*JfR[10]+0.25*JfR[9]-0.4330127018922193*JfR[8]-0.33541019662496846*JfR[7]+0.5809475019311124*JfR[6]-0.4330127018922193*JfR[5]+0.25*JfR[4]-0.33541019662496846*JfR[3]+0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[9] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsL[3]+0.5*speedsL[2]+0.8660254037844386*speedsL[1]+0.5*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.4841229182759271*JfL[23])-0.2795084971874737*JfL[22]-0.4841229182759271*(JfL[21]+JfL[20])-0.2795084971874738*(JfL[19]+JfL[18])-0.4841229182759271*JfL[17]-0.2795084971874737*JfL[16]+0.4330127018922193*JfL[12]+0.25*JfL[9]+0.4330127018922193*(JfL[8]+JfL[5])+0.25*(JfL[4]+JfL[2])+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.4841229182759271*JfR[23]-0.2795084971874737*JfR[22]+0.4841229182759271*(JfR[21]+JfR[20])-0.2795084971874738*(JfR[19]+JfR[18])+0.4841229182759271*JfR[17]-0.2795084971874737*JfR[16]-0.4330127018922193*JfR[12]+0.25*JfR[9]-0.4330127018922193*(JfR[8]+JfR[5])+0.25*(JfR[4]+JfR[2])-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[10] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsL[3]+0.5*speedsL[2]+0.8660254037844386*speedsL[1]+0.5*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3872983346207417*JfL[23]+0.22360679774997896*JfL[22]+0.38729833462074165*(JfL[21]+JfL[20])+0.22360679774997894*JfL[19]+0.22360679774997902*JfL[18]+0.3872983346207417*JfL[17]+0.22360679774997896*JfL[16]+0.5809475019311124*JfL[15]+0.33541019662496846*JfL[14]+0.5809475019311124*JfL[13]+0.4330127018922193*JfL[12]+0.5809475019311124*JfL[11]+0.33541019662496846*JfL[10]+0.25*JfL[9]+0.4330127018922193*JfL[8]+0.33541019662496846*JfL[7]+0.5809475019311124*JfL[6]+0.4330127018922193*JfL[5]+0.25*JfL[4]+0.33541019662496846*JfL[3]+0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.3872983346207417*JfR[23])+0.22360679774997896*JfR[22]-0.38729833462074165*(JfR[21]+JfR[20])+0.22360679774997894*JfR[19]+0.22360679774997902*JfR[18]-0.3872983346207417*JfR[17]+0.22360679774997896*JfR[16]-0.5809475019311124*JfR[15]+0.33541019662496846*JfR[14]-0.5809475019311124*JfR[13]-0.4330127018922193*JfR[12]-0.5809475019311124*JfR[11]+0.33541019662496846*JfR[10]+0.25*JfR[9]-0.4330127018922193*JfR[8]+0.33541019662496846*JfR[7]-0.5809475019311124*JfR[6]-0.4330127018922193*JfR[5]+0.25*JfR[4]+0.33541019662496846*JfR[3]+0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[11] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdx2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfx_3x2v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfx_3x2v_ser_p1.c new file mode 100644 index 0000000000..a6ebfeca23 --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfx_3x2v_ser_p1.c @@ -0,0 +1,303 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_edge_surfx_3x2v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdy2 = 2.0/dxv[1]; + double rdz2 = 2.0/dxv[2]; + double rdvpar2 = 2.0/dxv[3]; + + double *flux_surf_nodal = &flux_surf[0]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = 0.6123724356957944*speedsL[7]+0.3535533905932737*speedsL[6]-0.6123724356957944*(speedsL[5]+speedsL[4])-0.3535533905932737*(speedsL[3]+speedsL[2])+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.15811388300841892*JfL[46]+0.27386127875258304*(JfL[45]+JfL[44]+JfL[43])+0.15811388300841892*(JfL[42]+JfL[41])-0.273861278752583*JfL[40]+0.15811388300841892*JfL[39]-0.273861278752583*(JfL[38]+JfL[37])-0.15811388300841892*JfL[36]-0.15811388300841894*(JfL[35]+JfL[34])+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]+0.2371708245126284*JfL[30]-0.41079191812887433*(JfL[29]+JfL[28])-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]-0.2371708245126284*(JfL[25]+JfL[24])+0.41079191812887433*JfL[23]-0.1767766952966368*JfL[22]+0.3061862178478971*(JfL[21]+JfL[20])-0.2371708245126284*JfL[19]+0.41079191812887433*(JfL[18]+JfL[17])+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.1767766952966368*(JfL[14]+JfL[13])-0.3061862178478971*JfL[12]+0.2371708245126284*(JfL[11]+JfL[10])-0.41079191812887433*JfL[9]+0.1767766952966368*JfL[8]-0.3061862178478971*(JfL[7]+JfL[6])-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]-0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.15811388300841892*JfR[46]-0.27386127875258304*(JfR[45]+JfR[44]+JfR[43])+0.15811388300841892*(JfR[42]+JfR[41])+0.273861278752583*JfR[40]+0.15811388300841892*JfR[39]+0.273861278752583*(JfR[38]+JfR[37])-0.15811388300841892*JfR[36]-0.15811388300841894*(JfR[35]+JfR[34])-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.2371708245126284*JfR[30]+0.41079191812887433*(JfR[29]+JfR[28])+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.2371708245126284*(JfR[25]+JfR[24])-0.41079191812887433*JfR[23]-0.1767766952966368*JfR[22]-0.3061862178478971*(JfR[21]+JfR[20])-0.2371708245126284*JfR[19]-0.41079191812887433*(JfR[18]+JfR[17])-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.1767766952966368*(JfR[14]+JfR[13])+0.3061862178478971*JfR[12]+0.2371708245126284*(JfR[11]+JfR[10])+0.41079191812887433*JfR[9]+0.1767766952966368*JfR[8]+0.3061862178478971*(JfR[7]+JfR[6])-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[7]+0.3535533905932737*speedsL[6]-0.6123724356957944*(speedsL[5]+speedsL[4])-0.3535533905932737*(speedsL[3]+speedsL[2])+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]+0.19764235376052366*JfL[46]-0.3423265984407287*(JfL[45]+JfL[44]+JfL[43])-0.19764235376052364*(JfL[42]+JfL[41])+0.34232659844072866*JfL[40]-0.19764235376052364*JfL[39]+0.34232659844072866*(JfL[38]+JfL[37])+0.19764235376052366*(JfL[36]+JfL[35]+JfL[34])-0.3423265984407287*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*JfL[27]-0.1767766952966368*JfL[22]+0.3061862178478971*(JfL[21]+JfL[20]+JfL[16])+0.1767766952966368*(JfL[14]+JfL[13])-0.3061862178478971*JfL[12]+0.1767766952966368*JfL[8]-0.3061862178478971*(JfL[7]+JfL[6])-0.1767766952966368*(JfL[5]+JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.34232659844072866*JfR[47])+0.19764235376052366*JfR[46]+0.3423265984407287*(JfR[45]+JfR[44]+JfR[43])-0.19764235376052364*(JfR[42]+JfR[41])-0.34232659844072866*JfR[40]-0.19764235376052364*JfR[39]-0.34232659844072866*(JfR[38]+JfR[37])+0.19764235376052366*(JfR[36]+JfR[35]+JfR[34])+0.3423265984407287*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*JfR[27]-0.1767766952966368*JfR[22]-0.3061862178478971*(JfR[21]+JfR[20]+JfR[16])+0.1767766952966368*(JfR[14]+JfR[13])+0.3061862178478971*JfR[12]+0.1767766952966368*JfR[8]+0.3061862178478971*(JfR[7]+JfR[6])-0.1767766952966368*(JfR[5]+JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[7]+0.3535533905932737*speedsL[6]-0.6123724356957944*(speedsL[5]+speedsL[4])-0.3535533905932737*(speedsL[3]+speedsL[2])+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.15811388300841892*JfL[46]+0.27386127875258304*(JfL[45]+JfL[44]+JfL[43])+0.15811388300841892*(JfL[42]+JfL[41])-0.273861278752583*JfL[40]+0.15811388300841892*JfL[39]-0.273861278752583*(JfL[38]+JfL[37])-0.15811388300841892*JfL[36]-0.15811388300841894*(JfL[35]+JfL[34])+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]-0.2371708245126284*JfL[30]+0.41079191812887433*(JfL[29]+JfL[28])-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]+0.2371708245126284*(JfL[25]+JfL[24])-0.41079191812887433*JfL[23]-0.1767766952966368*JfL[22]+0.3061862178478971*(JfL[21]+JfL[20])+0.2371708245126284*JfL[19]-0.41079191812887433*(JfL[18]+JfL[17])+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.1767766952966368*(JfL[14]+JfL[13])-0.3061862178478971*JfL[12]-0.2371708245126284*(JfL[11]+JfL[10])+0.41079191812887433*JfL[9]+0.1767766952966368*JfL[8]-0.3061862178478971*(JfL[7]+JfL[6])-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]-0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.15811388300841892*JfR[46]-0.27386127875258304*(JfR[45]+JfR[44]+JfR[43])+0.15811388300841892*(JfR[42]+JfR[41])+0.273861278752583*JfR[40]+0.15811388300841892*JfR[39]+0.273861278752583*(JfR[38]+JfR[37])-0.15811388300841892*JfR[36]-0.15811388300841894*(JfR[35]+JfR[34])-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.2371708245126284*JfR[30]-0.41079191812887433*(JfR[29]+JfR[28])+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.2371708245126284*(JfR[25]+JfR[24])+0.41079191812887433*JfR[23]-0.1767766952966368*JfR[22]-0.3061862178478971*(JfR[21]+JfR[20])+0.2371708245126284*JfR[19]+0.41079191812887433*(JfR[18]+JfR[17])-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.1767766952966368*(JfR[14]+JfR[13])+0.3061862178478971*JfR[12]-0.2371708245126284*(JfR[11]+JfR[10])-0.41079191812887433*JfR[9]+0.1767766952966368*JfR[8]+0.3061862178478971*(JfR[7]+JfR[6])-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[7]+0.3535533905932737*speedsL[6]-0.6123724356957944*(speedsL[5]+speedsL[4])-0.3535533905932737*(speedsL[3]+speedsL[2])+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.15811388300841892*JfL[46]-0.27386127875258304*(JfL[45]+JfL[44])+0.27386127875258304*JfL[43]-0.15811388300841892*(JfL[42]+JfL[41])+0.273861278752583*JfL[40]+0.15811388300841892*JfL[39]-0.273861278752583*(JfL[38]+JfL[37])+0.15811388300841892*JfL[36]-0.15811388300841894*(JfL[35]+JfL[34])+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]-0.2371708245126284*JfL[30]+0.41079191812887433*(JfL[29]+JfL[28])+0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.2371708245126284*(JfL[25]+JfL[24])-0.41079191812887433*JfL[23]+0.1767766952966368*JfL[22]-0.3061862178478971*(JfL[21]+JfL[20])-0.2371708245126284*JfL[19]+0.41079191812887433*(JfL[18]+JfL[17])+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.1767766952966368*(JfL[14]+JfL[13])+0.3061862178478971*JfL[12]+0.2371708245126284*(JfL[11]+JfL[10])-0.41079191812887433*JfL[9]+0.1767766952966368*JfL[8]-0.3061862178478971*(JfL[7]+JfL[6])+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]-0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.15811388300841892*JfR[46]+0.27386127875258304*(JfR[45]+JfR[44])-0.27386127875258304*JfR[43]-0.15811388300841892*(JfR[42]+JfR[41])-0.273861278752583*JfR[40]+0.15811388300841892*JfR[39]+0.273861278752583*(JfR[38]+JfR[37])+0.15811388300841892*JfR[36]-0.15811388300841894*(JfR[35]+JfR[34])-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.2371708245126284*JfR[30]-0.41079191812887433*(JfR[29]+JfR[28])-0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]+0.2371708245126284*(JfR[25]+JfR[24])+0.41079191812887433*JfR[23]+0.1767766952966368*JfR[22]+0.3061862178478971*(JfR[21]+JfR[20])-0.2371708245126284*JfR[19]-0.41079191812887433*(JfR[18]+JfR[17])-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.1767766952966368*(JfR[14]+JfR[13])-0.3061862178478971*JfR[12]+0.2371708245126284*(JfR[11]+JfR[10])+0.41079191812887433*JfR[9]+0.1767766952966368*JfR[8]+0.3061862178478971*(JfR[7]+JfR[6])+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[3] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[7]+0.3535533905932737*speedsL[6]-0.6123724356957944*(speedsL[5]+speedsL[4])-0.3535533905932737*(speedsL[3]+speedsL[2])+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])-0.19764235376052366*JfL[46]+0.3423265984407287*(JfL[45]+JfL[44])-0.3423265984407287*JfL[43]+0.19764235376052364*(JfL[42]+JfL[41])-0.34232659844072866*JfL[40]-0.19764235376052364*JfL[39]+0.34232659844072866*(JfL[38]+JfL[37])-0.19764235376052366*JfL[36]+0.19764235376052366*(JfL[35]+JfL[34])-0.3423265984407287*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*JfL[27]+0.1767766952966368*JfL[22]-0.3061862178478971*(JfL[21]+JfL[20])+0.3061862178478971*JfL[16]-0.1767766952966368*(JfL[14]+JfL[13])+0.3061862178478971*JfL[12]+0.1767766952966368*JfL[8]-0.3061862178478971*(JfL[7]+JfL[6])+0.1767766952966368*JfL[5]-0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.34232659844072866*JfR[47]-0.19764235376052366*JfR[46]-0.3423265984407287*(JfR[45]+JfR[44])+0.3423265984407287*JfR[43]+0.19764235376052364*(JfR[42]+JfR[41])+0.34232659844072866*JfR[40]-0.19764235376052364*JfR[39]-0.34232659844072866*(JfR[38]+JfR[37])-0.19764235376052366*JfR[36]+0.19764235376052366*(JfR[35]+JfR[34])+0.3423265984407287*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*JfR[27]+0.1767766952966368*JfR[22]+0.3061862178478971*(JfR[21]+JfR[20])-0.3061862178478971*JfR[16]-0.1767766952966368*(JfR[14]+JfR[13])-0.3061862178478971*JfR[12]+0.1767766952966368*JfR[8]+0.3061862178478971*(JfR[7]+JfR[6])+0.1767766952966368*JfR[5]-0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[4] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[7]+0.3535533905932737*speedsL[6]-0.6123724356957944*(speedsL[5]+speedsL[4])-0.3535533905932737*(speedsL[3]+speedsL[2])+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.15811388300841892*JfL[46]-0.27386127875258304*(JfL[45]+JfL[44])+0.27386127875258304*JfL[43]-0.15811388300841892*(JfL[42]+JfL[41])+0.273861278752583*JfL[40]+0.15811388300841892*JfL[39]-0.273861278752583*(JfL[38]+JfL[37])+0.15811388300841892*JfL[36]-0.15811388300841894*(JfL[35]+JfL[34])+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]+0.2371708245126284*JfL[30]-0.41079191812887433*(JfL[29]+JfL[28])+0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.2371708245126284*(JfL[25]+JfL[24])+0.41079191812887433*JfL[23]+0.1767766952966368*JfL[22]-0.3061862178478971*(JfL[21]+JfL[20])+0.2371708245126284*JfL[19]-0.41079191812887433*(JfL[18]+JfL[17])+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.1767766952966368*(JfL[14]+JfL[13])+0.3061862178478971*JfL[12]-0.2371708245126284*(JfL[11]+JfL[10])+0.41079191812887433*JfL[9]+0.1767766952966368*JfL[8]-0.3061862178478971*(JfL[7]+JfL[6])+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]-0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.15811388300841892*JfR[46]+0.27386127875258304*(JfR[45]+JfR[44])-0.27386127875258304*JfR[43]-0.15811388300841892*(JfR[42]+JfR[41])-0.273861278752583*JfR[40]+0.15811388300841892*JfR[39]+0.273861278752583*(JfR[38]+JfR[37])+0.15811388300841892*JfR[36]-0.15811388300841894*(JfR[35]+JfR[34])-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.2371708245126284*JfR[30]+0.41079191812887433*(JfR[29]+JfR[28])-0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]-0.2371708245126284*(JfR[25]+JfR[24])-0.41079191812887433*JfR[23]+0.1767766952966368*JfR[22]+0.3061862178478971*(JfR[21]+JfR[20])+0.2371708245126284*JfR[19]+0.41079191812887433*(JfR[18]+JfR[17])-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.1767766952966368*(JfR[14]+JfR[13])-0.3061862178478971*JfR[12]-0.2371708245126284*(JfR[11]+JfR[10])-0.41079191812887433*JfR[9]+0.1767766952966368*JfR[8]+0.3061862178478971*(JfR[7]+JfR[6])+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[5] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[1].bmag; + Jc_quad = gkdgs[1].Jc; + B3_quad = gkdgs[1].B3; + normcurlbhat_quad = gkdgs[1].normcurlbhat; + bhat_quad[0] = gkdgs[1].bhat.x[0]; + bhat_quad[1] = gkdgs[1].bhat.x[1]; + bhat_quad[2] = gkdgs[1].bhat.x[2]; + area_elem_quad = dgs[1].area_elem; + + + alpha_quad = -(0.6123724356957944*speedsL[7])-0.3535533905932737*speedsL[6]+0.6123724356957944*speedsL[5]-0.6123724356957944*speedsL[4]+0.3535533905932737*speedsL[3]-0.3535533905932737*speedsL[2]+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.15811388300841892*JfL[46]-0.27386127875258304*JfL[45]+0.27386127875258304*JfL[44]-0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]+0.15811388300841892*JfL[41]-0.273861278752583*JfL[40]-0.15811388300841892*JfL[39]+0.273861278752583*JfL[38]-0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]-0.15811388300841894*JfL[34]+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]-0.2371708245126284*JfL[30]+0.41079191812887433*JfL[29]-0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]-0.2371708245126284*JfL[24]+0.41079191812887433*JfL[23]+0.1767766952966368*JfL[22]-0.3061862178478971*JfL[21]+0.3061862178478971*JfL[20]+0.2371708245126284*JfL[19]-0.41079191812887433*JfL[18]+0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]+0.1767766952966368*JfL[13]-0.3061862178478971*JfL[12]-0.2371708245126284*JfL[11]+0.2371708245126284*JfL[10]-0.41079191812887433*JfL[9]-0.1767766952966368*JfL[8]+0.3061862178478971*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]-0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.15811388300841892*JfR[46]+0.27386127875258304*JfR[45]-0.27386127875258304*JfR[44]+0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]+0.15811388300841892*JfR[41]+0.273861278752583*JfR[40]-0.15811388300841892*JfR[39]-0.273861278752583*JfR[38]+0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.15811388300841894*JfR[34]-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.2371708245126284*JfR[30]-0.41079191812887433*JfR[29]+0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]-0.2371708245126284*JfR[24]-0.41079191812887433*JfR[23]+0.1767766952966368*JfR[22]+0.3061862178478971*JfR[21]-0.3061862178478971*JfR[20]+0.2371708245126284*JfR[19]+0.41079191812887433*JfR[18]-0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]+0.1767766952966368*JfR[13]+0.3061862178478971*JfR[12]-0.2371708245126284*JfR[11]+0.2371708245126284*JfR[10]+0.41079191812887433*JfR[9]-0.1767766952966368*JfR[8]-0.3061862178478971*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[6] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[7])-0.3535533905932737*speedsL[6]+0.6123724356957944*speedsL[5]-0.6123724356957944*speedsL[4]+0.3535533905932737*speedsL[3]-0.3535533905932737*speedsL[2]+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])-0.19764235376052366*JfL[46]+0.3423265984407287*JfL[45]-0.3423265984407287*JfL[44]+0.3423265984407287*JfL[43]+0.19764235376052364*JfL[42]-0.19764235376052364*JfL[41]+0.34232659844072866*JfL[40]+0.19764235376052364*JfL[39]-0.34232659844072866*JfL[38]+0.34232659844072866*JfL[37]+0.19764235376052366*JfL[36]-0.19764235376052366*JfL[35]+0.19764235376052366*JfL[34]-0.3423265984407287*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*JfL[27]+0.1767766952966368*JfL[22]-0.3061862178478971*JfL[21]+0.3061862178478971*JfL[20]-0.3061862178478971*JfL[16]-0.1767766952966368*JfL[14]+0.1767766952966368*JfL[13]-0.3061862178478971*JfL[12]-0.1767766952966368*JfL[8]+0.3061862178478971*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.1767766952966368*JfL[3]-0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.34232659844072866*JfR[47]-0.19764235376052366*JfR[46]-0.3423265984407287*JfR[45]+0.3423265984407287*JfR[44]-0.3423265984407287*JfR[43]+0.19764235376052364*JfR[42]-0.19764235376052364*JfR[41]-0.34232659844072866*JfR[40]+0.19764235376052364*JfR[39]+0.34232659844072866*JfR[38]-0.34232659844072866*JfR[37]+0.19764235376052366*JfR[36]-0.19764235376052366*JfR[35]+0.19764235376052366*JfR[34]+0.3423265984407287*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*JfR[27]+0.1767766952966368*JfR[22]+0.3061862178478971*JfR[21]-0.3061862178478971*JfR[20]+0.3061862178478971*JfR[16]-0.1767766952966368*JfR[14]+0.1767766952966368*JfR[13]+0.3061862178478971*JfR[12]-0.1767766952966368*JfR[8]-0.3061862178478971*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.1767766952966368*JfR[3]-0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[7] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[7])-0.3535533905932737*speedsL[6]+0.6123724356957944*speedsL[5]-0.6123724356957944*speedsL[4]+0.3535533905932737*speedsL[3]-0.3535533905932737*speedsL[2]+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.15811388300841892*JfL[46]-0.27386127875258304*JfL[45]+0.27386127875258304*JfL[44]-0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]+0.15811388300841892*JfL[41]-0.273861278752583*JfL[40]-0.15811388300841892*JfL[39]+0.273861278752583*JfL[38]-0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]-0.15811388300841894*JfL[34]+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]+0.2371708245126284*JfL[30]-0.41079191812887433*JfL[29]+0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]+0.2371708245126284*JfL[24]-0.41079191812887433*JfL[23]+0.1767766952966368*JfL[22]-0.3061862178478971*JfL[21]+0.3061862178478971*JfL[20]-0.2371708245126284*JfL[19]+0.41079191812887433*JfL[18]-0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]+0.1767766952966368*JfL[13]-0.3061862178478971*JfL[12]+0.2371708245126284*JfL[11]-0.2371708245126284*JfL[10]+0.41079191812887433*JfL[9]-0.1767766952966368*JfL[8]+0.3061862178478971*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]-0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.15811388300841892*JfR[46]+0.27386127875258304*JfR[45]-0.27386127875258304*JfR[44]+0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]+0.15811388300841892*JfR[41]+0.273861278752583*JfR[40]-0.15811388300841892*JfR[39]-0.273861278752583*JfR[38]+0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.15811388300841894*JfR[34]-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.2371708245126284*JfR[30]+0.41079191812887433*JfR[29]-0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]+0.2371708245126284*JfR[24]+0.41079191812887433*JfR[23]+0.1767766952966368*JfR[22]+0.3061862178478971*JfR[21]-0.3061862178478971*JfR[20]-0.2371708245126284*JfR[19]-0.41079191812887433*JfR[18]+0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]+0.1767766952966368*JfR[13]+0.3061862178478971*JfR[12]+0.2371708245126284*JfR[11]-0.2371708245126284*JfR[10]-0.41079191812887433*JfR[9]-0.1767766952966368*JfR[8]-0.3061862178478971*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[8] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[7])-0.3535533905932737*speedsL[6]+0.6123724356957944*speedsL[5]-0.6123724356957944*speedsL[4]+0.3535533905932737*speedsL[3]-0.3535533905932737*speedsL[2]+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.15811388300841892*JfL[46]+0.27386127875258304*JfL[45]-0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]-0.15811388300841892*JfL[41]+0.273861278752583*JfL[40]-0.15811388300841892*JfL[39]+0.273861278752583*JfL[38]-0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]-0.15811388300841894*JfL[34]+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]+0.2371708245126284*JfL[30]-0.41079191812887433*JfL[29]+0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]+0.2371708245126284*JfL[24]-0.41079191812887433*JfL[23]-0.1767766952966368*JfL[22]+0.3061862178478971*JfL[21]-0.3061862178478971*JfL[20]+0.2371708245126284*JfL[19]-0.41079191812887433*JfL[18]+0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]-0.1767766952966368*JfL[13]+0.3061862178478971*JfL[12]-0.2371708245126284*JfL[11]+0.2371708245126284*JfL[10]-0.41079191812887433*JfL[9]-0.1767766952966368*JfL[8]+0.3061862178478971*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]-0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.15811388300841892*JfR[46]-0.27386127875258304*JfR[45]+0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]-0.15811388300841892*JfR[41]-0.273861278752583*JfR[40]-0.15811388300841892*JfR[39]-0.273861278752583*JfR[38]+0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.15811388300841894*JfR[34]-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.2371708245126284*JfR[30]+0.41079191812887433*JfR[29]-0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]+0.2371708245126284*JfR[24]+0.41079191812887433*JfR[23]-0.1767766952966368*JfR[22]-0.3061862178478971*JfR[21]+0.3061862178478971*JfR[20]+0.2371708245126284*JfR[19]+0.41079191812887433*JfR[18]-0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]-0.1767766952966368*JfR[13]-0.3061862178478971*JfR[12]-0.2371708245126284*JfR[11]+0.2371708245126284*JfR[10]+0.41079191812887433*JfR[9]-0.1767766952966368*JfR[8]-0.3061862178478971*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[9] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[7])-0.3535533905932737*speedsL[6]+0.6123724356957944*speedsL[5]-0.6123724356957944*speedsL[4]+0.3535533905932737*speedsL[3]-0.3535533905932737*speedsL[2]+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]+0.19764235376052366*JfL[46]-0.3423265984407287*JfL[45]+0.3423265984407287*(JfL[44]+JfL[43])-0.19764235376052364*JfL[42]+0.19764235376052364*JfL[41]-0.34232659844072866*JfL[40]+0.19764235376052364*JfL[39]-0.34232659844072866*JfL[38]+0.34232659844072866*JfL[37]-0.19764235376052366*(JfL[36]+JfL[35])+0.19764235376052366*JfL[34]-0.3423265984407287*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*JfL[27]-0.1767766952966368*JfL[22]+0.3061862178478971*JfL[21]-0.3061862178478971*(JfL[20]+JfL[16])+0.1767766952966368*JfL[14]-0.1767766952966368*JfL[13]+0.3061862178478971*JfL[12]-0.1767766952966368*JfL[8]+0.3061862178478971*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*(JfL[5]+JfL[3])-0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.34232659844072866*JfR[47])+0.19764235376052366*JfR[46]+0.3423265984407287*JfR[45]-0.3423265984407287*(JfR[44]+JfR[43])-0.19764235376052364*JfR[42]+0.19764235376052364*JfR[41]+0.34232659844072866*JfR[40]+0.19764235376052364*JfR[39]+0.34232659844072866*JfR[38]-0.34232659844072866*JfR[37]-0.19764235376052366*(JfR[36]+JfR[35])+0.19764235376052366*JfR[34]+0.3423265984407287*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*JfR[27]-0.1767766952966368*JfR[22]-0.3061862178478971*JfR[21]+0.3061862178478971*(JfR[20]+JfR[16])+0.1767766952966368*JfR[14]-0.1767766952966368*JfR[13]-0.3061862178478971*JfR[12]-0.1767766952966368*JfR[8]-0.3061862178478971*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*(JfR[5]+JfR[3])-0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[10] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[7])-0.3535533905932737*speedsL[6]+0.6123724356957944*speedsL[5]-0.6123724356957944*speedsL[4]+0.3535533905932737*speedsL[3]-0.3535533905932737*speedsL[2]+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.15811388300841892*JfL[46]+0.27386127875258304*JfL[45]-0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]-0.15811388300841892*JfL[41]+0.273861278752583*JfL[40]-0.15811388300841892*JfL[39]+0.273861278752583*JfL[38]-0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]-0.15811388300841894*JfL[34]+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]-0.2371708245126284*JfL[30]+0.41079191812887433*JfL[29]-0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]-0.2371708245126284*JfL[24]+0.41079191812887433*JfL[23]-0.1767766952966368*JfL[22]+0.3061862178478971*JfL[21]-0.3061862178478971*JfL[20]-0.2371708245126284*JfL[19]+0.41079191812887433*JfL[18]-0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]-0.1767766952966368*JfL[13]+0.3061862178478971*JfL[12]+0.2371708245126284*JfL[11]-0.2371708245126284*JfL[10]+0.41079191812887433*JfL[9]-0.1767766952966368*JfL[8]+0.3061862178478971*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]-0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.15811388300841892*JfR[46]-0.27386127875258304*JfR[45]+0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]-0.15811388300841892*JfR[41]-0.273861278752583*JfR[40]-0.15811388300841892*JfR[39]-0.273861278752583*JfR[38]+0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.15811388300841894*JfR[34]-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.2371708245126284*JfR[30]-0.41079191812887433*JfR[29]+0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]-0.2371708245126284*JfR[24]-0.41079191812887433*JfR[23]-0.1767766952966368*JfR[22]-0.3061862178478971*JfR[21]+0.3061862178478971*JfR[20]-0.2371708245126284*JfR[19]-0.41079191812887433*JfR[18]+0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]-0.1767766952966368*JfR[13]-0.3061862178478971*JfR[12]+0.2371708245126284*JfR[11]-0.2371708245126284*JfR[10]-0.41079191812887433*JfR[9]-0.1767766952966368*JfR[8]-0.3061862178478971*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[11] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[2].bmag; + Jc_quad = gkdgs[2].Jc; + B3_quad = gkdgs[2].B3; + normcurlbhat_quad = gkdgs[2].normcurlbhat; + bhat_quad[0] = gkdgs[2].bhat.x[0]; + bhat_quad[1] = gkdgs[2].bhat.x[1]; + bhat_quad[2] = gkdgs[2].bhat.x[2]; + area_elem_quad = dgs[2].area_elem; + + + alpha_quad = -(0.6123724356957944*speedsL[7])-0.3535533905932737*speedsL[6]-0.6123724356957944*speedsL[5]+0.6123724356957944*speedsL[4]-0.3535533905932737*speedsL[3]+0.3535533905932737*speedsL[2]+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.15811388300841892*JfL[46]+0.27386127875258304*JfL[45]-0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]-0.15811388300841892*JfL[41]-0.273861278752583*JfL[40]-0.15811388300841892*JfL[39]-0.273861278752583*JfL[38]+0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.15811388300841894*JfL[34]+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]-0.2371708245126284*JfL[30]-0.41079191812887433*JfL[29]+0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]+0.2371708245126284*JfL[24]+0.41079191812887433*JfL[23]+0.1767766952966368*JfL[22]+0.3061862178478971*JfL[21]-0.3061862178478971*JfL[20]+0.2371708245126284*JfL[19]+0.41079191812887433*JfL[18]-0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]-0.1767766952966368*JfL[13]-0.3061862178478971*JfL[12]+0.2371708245126284*JfL[11]-0.2371708245126284*JfL[10]-0.41079191812887433*JfL[9]-0.1767766952966368*JfL[8]-0.3061862178478971*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.15811388300841892*JfR[46]-0.27386127875258304*JfR[45]+0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]-0.15811388300841892*JfR[41]+0.273861278752583*JfR[40]-0.15811388300841892*JfR[39]+0.273861278752583*JfR[38]-0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]+0.15811388300841894*JfR[34]-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.2371708245126284*JfR[30]+0.41079191812887433*JfR[29]-0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]+0.2371708245126284*JfR[24]-0.41079191812887433*JfR[23]+0.1767766952966368*JfR[22]-0.3061862178478971*JfR[21]+0.3061862178478971*JfR[20]+0.2371708245126284*JfR[19]-0.41079191812887433*JfR[18]+0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]-0.1767766952966368*JfR[13]+0.3061862178478971*JfR[12]+0.2371708245126284*JfR[11]-0.2371708245126284*JfR[10]+0.41079191812887433*JfR[9]-0.1767766952966368*JfR[8]+0.3061862178478971*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]+0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[12] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[7])-0.3535533905932737*speedsL[6]-0.6123724356957944*speedsL[5]+0.6123724356957944*speedsL[4]-0.3535533905932737*speedsL[3]+0.3535533905932737*speedsL[2]+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])-0.19764235376052366*JfL[46]-0.3423265984407287*JfL[45]+0.3423265984407287*(JfL[44]+JfL[43])-0.19764235376052364*JfL[42]+0.19764235376052364*JfL[41]+0.34232659844072866*JfL[40]+0.19764235376052364*JfL[39]+0.34232659844072866*JfL[38]-0.34232659844072866*JfL[37]+0.19764235376052366*(JfL[36]+JfL[35])-0.19764235376052366*JfL[34]-0.3423265984407287*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*JfL[27]+0.1767766952966368*JfL[22]+0.3061862178478971*JfL[21]-0.3061862178478971*(JfL[20]+JfL[16])+0.1767766952966368*JfL[14]-0.1767766952966368*JfL[13]-0.3061862178478971*JfL[12]-0.1767766952966368*JfL[8]-0.3061862178478971*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*(JfL[5]+JfL[3])+0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.34232659844072866*JfR[47]-0.19764235376052366*JfR[46]+0.3423265984407287*JfR[45]-0.3423265984407287*(JfR[44]+JfR[43])-0.19764235376052364*JfR[42]+0.19764235376052364*JfR[41]-0.34232659844072866*JfR[40]+0.19764235376052364*JfR[39]-0.34232659844072866*JfR[38]+0.34232659844072866*JfR[37]+0.19764235376052366*(JfR[36]+JfR[35])-0.19764235376052366*JfR[34]+0.3423265984407287*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*JfR[27]+0.1767766952966368*JfR[22]-0.3061862178478971*JfR[21]+0.3061862178478971*(JfR[20]+JfR[16])+0.1767766952966368*JfR[14]-0.1767766952966368*JfR[13]+0.3061862178478971*JfR[12]-0.1767766952966368*JfR[8]+0.3061862178478971*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*(JfR[5]+JfR[3])+0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[13] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[7])-0.3535533905932737*speedsL[6]-0.6123724356957944*speedsL[5]+0.6123724356957944*speedsL[4]-0.3535533905932737*speedsL[3]+0.3535533905932737*speedsL[2]+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.15811388300841892*JfL[46]+0.27386127875258304*JfL[45]-0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]-0.15811388300841892*JfL[41]-0.273861278752583*JfL[40]-0.15811388300841892*JfL[39]-0.273861278752583*JfL[38]+0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.15811388300841894*JfL[34]+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]+0.2371708245126284*JfL[30]+0.41079191812887433*JfL[29]-0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]-0.2371708245126284*JfL[24]-0.41079191812887433*JfL[23]+0.1767766952966368*JfL[22]+0.3061862178478971*JfL[21]-0.3061862178478971*JfL[20]-0.2371708245126284*JfL[19]-0.41079191812887433*JfL[18]+0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]-0.1767766952966368*JfL[13]-0.3061862178478971*JfL[12]-0.2371708245126284*JfL[11]+0.2371708245126284*JfL[10]+0.41079191812887433*JfL[9]-0.1767766952966368*JfL[8]-0.3061862178478971*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.15811388300841892*JfR[46]-0.27386127875258304*JfR[45]+0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]-0.15811388300841892*JfR[41]+0.273861278752583*JfR[40]-0.15811388300841892*JfR[39]+0.273861278752583*JfR[38]-0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]+0.15811388300841894*JfR[34]-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.2371708245126284*JfR[30]-0.41079191812887433*JfR[29]+0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]-0.2371708245126284*JfR[24]+0.41079191812887433*JfR[23]+0.1767766952966368*JfR[22]-0.3061862178478971*JfR[21]+0.3061862178478971*JfR[20]-0.2371708245126284*JfR[19]+0.41079191812887433*JfR[18]-0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]-0.1767766952966368*JfR[13]+0.3061862178478971*JfR[12]-0.2371708245126284*JfR[11]+0.2371708245126284*JfR[10]-0.41079191812887433*JfR[9]-0.1767766952966368*JfR[8]+0.3061862178478971*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]+0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[14] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[7])-0.3535533905932737*speedsL[6]-0.6123724356957944*speedsL[5]+0.6123724356957944*speedsL[4]-0.3535533905932737*speedsL[3]+0.3535533905932737*speedsL[2]+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.15811388300841892*JfL[46]-0.27386127875258304*JfL[45]+0.27386127875258304*JfL[44]-0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]+0.15811388300841892*JfL[41]+0.273861278752583*JfL[40]-0.15811388300841892*JfL[39]-0.273861278752583*JfL[38]+0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.15811388300841894*JfL[34]+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]+0.2371708245126284*JfL[30]+0.41079191812887433*JfL[29]-0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]-0.2371708245126284*JfL[24]-0.41079191812887433*JfL[23]-0.1767766952966368*JfL[22]-0.3061862178478971*JfL[21]+0.3061862178478971*JfL[20]+0.2371708245126284*JfL[19]+0.41079191812887433*JfL[18]-0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]+0.1767766952966368*JfL[13]+0.3061862178478971*JfL[12]+0.2371708245126284*JfL[11]-0.2371708245126284*JfL[10]-0.41079191812887433*JfL[9]-0.1767766952966368*JfL[8]-0.3061862178478971*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.15811388300841892*JfR[46]+0.27386127875258304*JfR[45]-0.27386127875258304*JfR[44]+0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]+0.15811388300841892*JfR[41]-0.273861278752583*JfR[40]-0.15811388300841892*JfR[39]+0.273861278752583*JfR[38]-0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]+0.15811388300841894*JfR[34]-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.2371708245126284*JfR[30]-0.41079191812887433*JfR[29]+0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]-0.2371708245126284*JfR[24]+0.41079191812887433*JfR[23]-0.1767766952966368*JfR[22]+0.3061862178478971*JfR[21]-0.3061862178478971*JfR[20]+0.2371708245126284*JfR[19]-0.41079191812887433*JfR[18]+0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]+0.1767766952966368*JfR[13]-0.3061862178478971*JfR[12]+0.2371708245126284*JfR[11]-0.2371708245126284*JfR[10]+0.41079191812887433*JfR[9]-0.1767766952966368*JfR[8]+0.3061862178478971*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]+0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[15] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[7])-0.3535533905932737*speedsL[6]-0.6123724356957944*speedsL[5]+0.6123724356957944*speedsL[4]-0.3535533905932737*speedsL[3]+0.3535533905932737*speedsL[2]+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]+0.19764235376052366*JfL[46]+0.3423265984407287*JfL[45]-0.3423265984407287*JfL[44]+0.3423265984407287*JfL[43]+0.19764235376052364*JfL[42]-0.19764235376052364*JfL[41]-0.34232659844072866*JfL[40]+0.19764235376052364*JfL[39]+0.34232659844072866*JfL[38]-0.34232659844072866*JfL[37]-0.19764235376052366*JfL[36]+0.19764235376052366*JfL[35]-0.19764235376052366*JfL[34]-0.3423265984407287*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*JfL[27]-0.1767766952966368*JfL[22]-0.3061862178478971*JfL[21]+0.3061862178478971*JfL[20]-0.3061862178478971*JfL[16]-0.1767766952966368*JfL[14]+0.1767766952966368*JfL[13]+0.3061862178478971*JfL[12]-0.1767766952966368*JfL[8]-0.3061862178478971*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.1767766952966368*JfL[3]+0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.34232659844072866*JfR[47])+0.19764235376052366*JfR[46]-0.3423265984407287*JfR[45]+0.3423265984407287*JfR[44]-0.3423265984407287*JfR[43]+0.19764235376052364*JfR[42]-0.19764235376052364*JfR[41]+0.34232659844072866*JfR[40]+0.19764235376052364*JfR[39]-0.34232659844072866*JfR[38]+0.34232659844072866*JfR[37]-0.19764235376052366*JfR[36]+0.19764235376052366*JfR[35]-0.19764235376052366*JfR[34]+0.3423265984407287*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*JfR[27]-0.1767766952966368*JfR[22]+0.3061862178478971*JfR[21]-0.3061862178478971*JfR[20]+0.3061862178478971*JfR[16]-0.1767766952966368*JfR[14]+0.1767766952966368*JfR[13]-0.3061862178478971*JfR[12]-0.1767766952966368*JfR[8]+0.3061862178478971*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.1767766952966368*JfR[3]+0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[16] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[7])-0.3535533905932737*speedsL[6]-0.6123724356957944*speedsL[5]+0.6123724356957944*speedsL[4]-0.3535533905932737*speedsL[3]+0.3535533905932737*speedsL[2]+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.15811388300841892*JfL[46]-0.27386127875258304*JfL[45]+0.27386127875258304*JfL[44]-0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]+0.15811388300841892*JfL[41]+0.273861278752583*JfL[40]-0.15811388300841892*JfL[39]-0.273861278752583*JfL[38]+0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.15811388300841894*JfL[34]+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]-0.2371708245126284*JfL[30]-0.41079191812887433*JfL[29]+0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]+0.2371708245126284*JfL[24]+0.41079191812887433*JfL[23]-0.1767766952966368*JfL[22]-0.3061862178478971*JfL[21]+0.3061862178478971*JfL[20]-0.2371708245126284*JfL[19]-0.41079191812887433*JfL[18]+0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]+0.1767766952966368*JfL[13]+0.3061862178478971*JfL[12]-0.2371708245126284*JfL[11]+0.2371708245126284*JfL[10]+0.41079191812887433*JfL[9]-0.1767766952966368*JfL[8]-0.3061862178478971*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.15811388300841892*JfR[46]+0.27386127875258304*JfR[45]-0.27386127875258304*JfR[44]+0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]+0.15811388300841892*JfR[41]-0.273861278752583*JfR[40]-0.15811388300841892*JfR[39]+0.273861278752583*JfR[38]-0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]+0.15811388300841894*JfR[34]-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.2371708245126284*JfR[30]+0.41079191812887433*JfR[29]-0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]+0.2371708245126284*JfR[24]-0.41079191812887433*JfR[23]-0.1767766952966368*JfR[22]+0.3061862178478971*JfR[21]-0.3061862178478971*JfR[20]-0.2371708245126284*JfR[19]+0.41079191812887433*JfR[18]-0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]+0.1767766952966368*JfR[13]-0.3061862178478971*JfR[12]-0.2371708245126284*JfR[11]+0.2371708245126284*JfR[10]-0.41079191812887433*JfR[9]-0.1767766952966368*JfR[8]+0.3061862178478971*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]+0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[17] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[3].bmag; + Jc_quad = gkdgs[3].Jc; + B3_quad = gkdgs[3].B3; + normcurlbhat_quad = gkdgs[3].normcurlbhat; + bhat_quad[0] = gkdgs[3].bhat.x[0]; + bhat_quad[1] = gkdgs[3].bhat.x[1]; + bhat_quad[2] = gkdgs[3].bhat.x[2]; + area_elem_quad = dgs[3].area_elem; + + + alpha_quad = 0.6123724356957944*speedsL[7]+0.3535533905932737*speedsL[6]+0.6123724356957944*(speedsL[5]+speedsL[4])+0.3535533905932737*(speedsL[3]+speedsL[2])+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.15811388300841892*JfL[46]-0.27386127875258304*(JfL[45]+JfL[44])+0.27386127875258304*JfL[43]-0.15811388300841892*(JfL[42]+JfL[41])-0.273861278752583*JfL[40]+0.15811388300841892*JfL[39]+0.273861278752583*(JfL[38]+JfL[37])-0.15811388300841892*JfL[36]+0.15811388300841894*(JfL[35]+JfL[34])+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]+0.2371708245126284*JfL[30]+0.41079191812887433*(JfL[29]+JfL[28])-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.2371708245126284*(JfL[25]+JfL[24])+0.41079191812887433*JfL[23]-0.1767766952966368*JfL[22]-0.3061862178478971*(JfL[21]+JfL[20])-0.2371708245126284*JfL[19]-0.41079191812887433*(JfL[18]+JfL[17])+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.1767766952966368*(JfL[14]+JfL[13])-0.3061862178478971*JfL[12]-0.2371708245126284*(JfL[11]+JfL[10])-0.41079191812887433*JfL[9]+0.1767766952966368*JfL[8]+0.3061862178478971*(JfL[7]+JfL[6])-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.15811388300841892*JfR[46]+0.27386127875258304*(JfR[45]+JfR[44])-0.27386127875258304*JfR[43]-0.15811388300841892*(JfR[42]+JfR[41])+0.273861278752583*JfR[40]+0.15811388300841892*JfR[39]-0.273861278752583*(JfR[38]+JfR[37])-0.15811388300841892*JfR[36]+0.15811388300841894*(JfR[35]+JfR[34])-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.2371708245126284*JfR[30]-0.41079191812887433*(JfR[29]+JfR[28])+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]+0.2371708245126284*(JfR[25]+JfR[24])-0.41079191812887433*JfR[23]-0.1767766952966368*JfR[22]+0.3061862178478971*(JfR[21]+JfR[20])-0.2371708245126284*JfR[19]+0.41079191812887433*(JfR[18]+JfR[17])-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.1767766952966368*(JfR[14]+JfR[13])+0.3061862178478971*JfR[12]-0.2371708245126284*(JfR[11]+JfR[10])+0.41079191812887433*JfR[9]+0.1767766952966368*JfR[8]-0.3061862178478971*(JfR[7]+JfR[6])-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]+0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[18] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[7]+0.3535533905932737*speedsL[6]+0.6123724356957944*(speedsL[5]+speedsL[4])+0.3535533905932737*(speedsL[3]+speedsL[2])+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]+0.19764235376052366*JfL[46]+0.3423265984407287*(JfL[45]+JfL[44])-0.3423265984407287*JfL[43]+0.19764235376052364*(JfL[42]+JfL[41])+0.34232659844072866*JfL[40]-0.19764235376052364*JfL[39]-0.34232659844072866*(JfL[38]+JfL[37])+0.19764235376052366*JfL[36]-0.19764235376052366*(JfL[35]+JfL[34])-0.3423265984407287*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*JfL[27]-0.1767766952966368*JfL[22]-0.3061862178478971*(JfL[21]+JfL[20])+0.3061862178478971*JfL[16]-0.1767766952966368*(JfL[14]+JfL[13])-0.3061862178478971*JfL[12]+0.1767766952966368*JfL[8]+0.3061862178478971*(JfL[7]+JfL[6])-0.1767766952966368*JfL[5]+0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.34232659844072866*JfR[47])+0.19764235376052366*JfR[46]-0.3423265984407287*(JfR[45]+JfR[44])+0.3423265984407287*JfR[43]+0.19764235376052364*(JfR[42]+JfR[41])-0.34232659844072866*JfR[40]-0.19764235376052364*JfR[39]+0.34232659844072866*(JfR[38]+JfR[37])+0.19764235376052366*JfR[36]-0.19764235376052366*(JfR[35]+JfR[34])+0.3423265984407287*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*JfR[27]-0.1767766952966368*JfR[22]+0.3061862178478971*(JfR[21]+JfR[20])-0.3061862178478971*JfR[16]-0.1767766952966368*(JfR[14]+JfR[13])+0.3061862178478971*JfR[12]+0.1767766952966368*JfR[8]-0.3061862178478971*(JfR[7]+JfR[6])-0.1767766952966368*JfR[5]+0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[19] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[7]+0.3535533905932737*speedsL[6]+0.6123724356957944*(speedsL[5]+speedsL[4])+0.3535533905932737*(speedsL[3]+speedsL[2])+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.15811388300841892*JfL[46]-0.27386127875258304*(JfL[45]+JfL[44])+0.27386127875258304*JfL[43]-0.15811388300841892*(JfL[42]+JfL[41])-0.273861278752583*JfL[40]+0.15811388300841892*JfL[39]+0.273861278752583*(JfL[38]+JfL[37])-0.15811388300841892*JfL[36]+0.15811388300841894*(JfL[35]+JfL[34])+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]-0.2371708245126284*JfL[30]-0.41079191812887433*(JfL[29]+JfL[28])-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.2371708245126284*(JfL[25]+JfL[24])-0.41079191812887433*JfL[23]-0.1767766952966368*JfL[22]-0.3061862178478971*(JfL[21]+JfL[20])+0.2371708245126284*JfL[19]+0.41079191812887433*(JfL[18]+JfL[17])+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.1767766952966368*(JfL[14]+JfL[13])-0.3061862178478971*JfL[12]+0.2371708245126284*(JfL[11]+JfL[10])+0.41079191812887433*JfL[9]+0.1767766952966368*JfL[8]+0.3061862178478971*(JfL[7]+JfL[6])-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.15811388300841892*JfR[46]+0.27386127875258304*(JfR[45]+JfR[44])-0.27386127875258304*JfR[43]-0.15811388300841892*(JfR[42]+JfR[41])+0.273861278752583*JfR[40]+0.15811388300841892*JfR[39]-0.273861278752583*(JfR[38]+JfR[37])-0.15811388300841892*JfR[36]+0.15811388300841894*(JfR[35]+JfR[34])-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.2371708245126284*JfR[30]+0.41079191812887433*(JfR[29]+JfR[28])+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]-0.2371708245126284*(JfR[25]+JfR[24])+0.41079191812887433*JfR[23]-0.1767766952966368*JfR[22]+0.3061862178478971*(JfR[21]+JfR[20])+0.2371708245126284*JfR[19]-0.41079191812887433*(JfR[18]+JfR[17])-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.1767766952966368*(JfR[14]+JfR[13])+0.3061862178478971*JfR[12]+0.2371708245126284*(JfR[11]+JfR[10])-0.41079191812887433*JfR[9]+0.1767766952966368*JfR[8]-0.3061862178478971*(JfR[7]+JfR[6])-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]+0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[20] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[7]+0.3535533905932737*speedsL[6]+0.6123724356957944*(speedsL[5]+speedsL[4])+0.3535533905932737*(speedsL[3]+speedsL[2])+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.15811388300841892*JfL[46]+0.27386127875258304*(JfL[45]+JfL[44]+JfL[43])+0.15811388300841892*(JfL[42]+JfL[41])+0.273861278752583*JfL[40]+0.15811388300841892*JfL[39]+0.273861278752583*(JfL[38]+JfL[37])+0.15811388300841892*JfL[36]+0.15811388300841894*(JfL[35]+JfL[34])+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]-0.2371708245126284*JfL[30]-0.41079191812887433*(JfL[29]+JfL[28])+0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]-0.2371708245126284*(JfL[25]+JfL[24])-0.41079191812887433*JfL[23]+0.1767766952966368*JfL[22]+0.3061862178478971*(JfL[21]+JfL[20])-0.2371708245126284*JfL[19]-0.41079191812887433*(JfL[18]+JfL[17])+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.1767766952966368*(JfL[14]+JfL[13])+0.3061862178478971*JfL[12]-0.2371708245126284*(JfL[11]+JfL[10])-0.41079191812887433*JfL[9]+0.1767766952966368*JfL[8]+0.3061862178478971*(JfL[7]+JfL[6])+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.15811388300841892*JfR[46]-0.27386127875258304*(JfR[45]+JfR[44]+JfR[43])+0.15811388300841892*(JfR[42]+JfR[41])-0.273861278752583*JfR[40]+0.15811388300841892*JfR[39]-0.273861278752583*(JfR[38]+JfR[37])+0.15811388300841892*JfR[36]+0.15811388300841894*(JfR[35]+JfR[34])-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.2371708245126284*JfR[30]+0.41079191812887433*(JfR[29]+JfR[28])-0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.2371708245126284*(JfR[25]+JfR[24])+0.41079191812887433*JfR[23]+0.1767766952966368*JfR[22]-0.3061862178478971*(JfR[21]+JfR[20])-0.2371708245126284*JfR[19]+0.41079191812887433*(JfR[18]+JfR[17])-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.1767766952966368*(JfR[14]+JfR[13])-0.3061862178478971*JfR[12]-0.2371708245126284*(JfR[11]+JfR[10])+0.41079191812887433*JfR[9]+0.1767766952966368*JfR[8]-0.3061862178478971*(JfR[7]+JfR[6])+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]+0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[21] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[7]+0.3535533905932737*speedsL[6]+0.6123724356957944*(speedsL[5]+speedsL[4])+0.3535533905932737*(speedsL[3]+speedsL[2])+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])-0.19764235376052366*JfL[46]-0.3423265984407287*(JfL[45]+JfL[44]+JfL[43])-0.19764235376052364*(JfL[42]+JfL[41])-0.34232659844072866*JfL[40]-0.19764235376052364*JfL[39]-0.34232659844072866*(JfL[38]+JfL[37])-0.19764235376052366*(JfL[36]+JfL[35]+JfL[34])-0.3423265984407287*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*JfL[27]+0.1767766952966368*JfL[22]+0.3061862178478971*(JfL[21]+JfL[20]+JfL[16])+0.1767766952966368*(JfL[14]+JfL[13])+0.3061862178478971*JfL[12]+0.1767766952966368*JfL[8]+0.3061862178478971*(JfL[7]+JfL[6])+0.1767766952966368*(JfL[5]+JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.34232659844072866*JfR[47]-0.19764235376052366*JfR[46]+0.3423265984407287*(JfR[45]+JfR[44]+JfR[43])-0.19764235376052364*(JfR[42]+JfR[41])+0.34232659844072866*JfR[40]-0.19764235376052364*JfR[39]+0.34232659844072866*(JfR[38]+JfR[37])-0.19764235376052366*(JfR[36]+JfR[35]+JfR[34])+0.3423265984407287*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*JfR[27]+0.1767766952966368*JfR[22]-0.3061862178478971*(JfR[21]+JfR[20]+JfR[16])+0.1767766952966368*(JfR[14]+JfR[13])-0.3061862178478971*JfR[12]+0.1767766952966368*JfR[8]-0.3061862178478971*(JfR[7]+JfR[6])+0.1767766952966368*(JfR[5]+JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[22] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[7]+0.3535533905932737*speedsL[6]+0.6123724356957944*(speedsL[5]+speedsL[4])+0.3535533905932737*(speedsL[3]+speedsL[2])+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.15811388300841892*JfL[46]+0.27386127875258304*(JfL[45]+JfL[44]+JfL[43])+0.15811388300841892*(JfL[42]+JfL[41])+0.273861278752583*JfL[40]+0.15811388300841892*JfL[39]+0.273861278752583*(JfL[38]+JfL[37])+0.15811388300841892*JfL[36]+0.15811388300841894*(JfL[35]+JfL[34])+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]+0.2371708245126284*JfL[30]+0.41079191812887433*(JfL[29]+JfL[28])+0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]+0.2371708245126284*(JfL[25]+JfL[24])+0.41079191812887433*JfL[23]+0.1767766952966368*JfL[22]+0.3061862178478971*(JfL[21]+JfL[20])+0.2371708245126284*JfL[19]+0.41079191812887433*(JfL[18]+JfL[17])+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.1767766952966368*(JfL[14]+JfL[13])+0.3061862178478971*JfL[12]+0.2371708245126284*(JfL[11]+JfL[10])+0.41079191812887433*JfL[9]+0.1767766952966368*JfL[8]+0.3061862178478971*(JfL[7]+JfL[6])+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.15811388300841892*JfR[46]-0.27386127875258304*(JfR[45]+JfR[44]+JfR[43])+0.15811388300841892*(JfR[42]+JfR[41])-0.273861278752583*JfR[40]+0.15811388300841892*JfR[39]-0.273861278752583*(JfR[38]+JfR[37])+0.15811388300841892*JfR[36]+0.15811388300841894*(JfR[35]+JfR[34])-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.2371708245126284*JfR[30]-0.41079191812887433*(JfR[29]+JfR[28])-0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.2371708245126284*(JfR[25]+JfR[24])-0.41079191812887433*JfR[23]+0.1767766952966368*JfR[22]-0.3061862178478971*(JfR[21]+JfR[20])+0.2371708245126284*JfR[19]-0.41079191812887433*(JfR[18]+JfR[17])-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.1767766952966368*(JfR[14]+JfR[13])-0.3061862178478971*JfR[12]+0.2371708245126284*(JfR[11]+JfR[10])-0.41079191812887433*JfR[9]+0.1767766952966368*JfR[8]-0.3061862178478971*(JfR[7]+JfR[6])+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]+0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[23] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdx2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfy_2x2v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfy_2x2v_ser_p1.c new file mode 100644 index 0000000000..15e7e2718c --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfy_2x2v_ser_p1.c @@ -0,0 +1,174 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_edge_surfy_2x2v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdz2 = 2.0/dxv[1]; + double rdvpar2 = 2.0/dxv[2]; + + double *flux_surf_nodal = &flux_surf[12]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = -(0.8660254037844386*speedsL[7])+0.8660254037844386*speedsL[6]-0.5*speedsL[5]+0.5*speedsL[4]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3872983346207417*JfL[23]-0.38729833462074165*JfL[22]+0.22360679774997896*JfL[21]-0.38729833462074165*JfL[20]-0.22360679774997894*JfL[19]+0.3872983346207417*JfL[18]-0.22360679774997902*JfL[17]+0.22360679774997896*JfL[16]-0.5809475019311124*JfL[15]+0.5809475019311124*JfL[14]-0.33541019662496846*JfL[13]+0.4330127018922193*JfL[12]+0.5809475019311124*JfL[11]+0.33541019662496846*JfL[10]-0.4330127018922193*JfL[9]+0.25*JfL[8]-0.5809475019311124*JfL[7]+0.33541019662496846*JfL[6]-0.4330127018922193*JfL[5]-0.25*JfL[4]-0.33541019662496846*JfL[3]+0.4330127018922193*JfL[2]-0.25*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.3872983346207417*JfR[23])+0.38729833462074165*JfR[22]+0.22360679774997896*JfR[21]+0.38729833462074165*JfR[20]-0.22360679774997894*JfR[19]-0.3872983346207417*JfR[18]-0.22360679774997902*JfR[17]+0.22360679774997896*JfR[16]+0.5809475019311124*JfR[15]-0.5809475019311124*JfR[14]-0.33541019662496846*JfR[13]-0.4330127018922193*JfR[12]-0.5809475019311124*JfR[11]+0.33541019662496846*JfR[10]+0.4330127018922193*JfR[9]+0.25*JfR[8]+0.5809475019311124*JfR[7]+0.33541019662496846*JfR[6]+0.4330127018922193*JfR[5]-0.25*JfR[4]-0.33541019662496846*JfR[3]-0.4330127018922193*JfR[2]-0.25*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsL[7])+0.8660254037844386*speedsL[6]-0.5*speedsL[5]+0.5*speedsL[4]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.4841229182759271*JfL[23])+0.4841229182759271*JfL[22]-0.2795084971874737*JfL[21]+0.4841229182759271*JfL[20]+0.2795084971874738*JfL[19]-0.4841229182759271*JfL[18]+0.2795084971874738*JfL[17]-0.2795084971874737*JfL[16]+0.4330127018922193*JfL[12]-0.4330127018922193*JfL[9]+0.25*JfL[8]-0.4330127018922193*JfL[5]-0.25*JfL[4]+0.4330127018922193*JfL[2]-0.25*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.4841229182759271*JfR[23]-0.4841229182759271*JfR[22]-0.2795084971874737*JfR[21]-0.4841229182759271*JfR[20]+0.2795084971874738*JfR[19]+0.4841229182759271*JfR[18]+0.2795084971874738*JfR[17]-0.2795084971874737*JfR[16]-0.4330127018922193*JfR[12]+0.4330127018922193*JfR[9]+0.25*JfR[8]+0.4330127018922193*JfR[5]-0.25*JfR[4]-0.4330127018922193*JfR[2]-0.25*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsL[7])+0.8660254037844386*speedsL[6]-0.5*speedsL[5]+0.5*speedsL[4]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3872983346207417*JfL[23]-0.38729833462074165*JfL[22]+0.22360679774997896*JfL[21]-0.38729833462074165*JfL[20]-0.22360679774997894*JfL[19]+0.3872983346207417*JfL[18]-0.22360679774997902*JfL[17]+0.22360679774997896*JfL[16]+0.5809475019311124*JfL[15]-0.5809475019311124*JfL[14]+0.33541019662496846*JfL[13]+0.4330127018922193*JfL[12]-0.5809475019311124*JfL[11]-0.33541019662496846*JfL[10]-0.4330127018922193*JfL[9]+0.25*JfL[8]+0.5809475019311124*JfL[7]-0.33541019662496846*JfL[6]-0.4330127018922193*JfL[5]-0.25*JfL[4]+0.33541019662496846*JfL[3]+0.4330127018922193*JfL[2]-0.25*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.3872983346207417*JfR[23])+0.38729833462074165*JfR[22]+0.22360679774997896*JfR[21]+0.38729833462074165*JfR[20]-0.22360679774997894*JfR[19]-0.3872983346207417*JfR[18]-0.22360679774997902*JfR[17]+0.22360679774997896*JfR[16]-0.5809475019311124*JfR[15]+0.5809475019311124*JfR[14]+0.33541019662496846*JfR[13]-0.4330127018922193*JfR[12]+0.5809475019311124*JfR[11]-0.33541019662496846*JfR[10]+0.4330127018922193*JfR[9]+0.25*JfR[8]-0.5809475019311124*JfR[7]-0.33541019662496846*JfR[6]+0.4330127018922193*JfR[5]-0.25*JfR[4]+0.33541019662496846*JfR[3]-0.4330127018922193*JfR[2]-0.25*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsL[7])+0.8660254037844386*speedsL[6]-0.5*speedsL[5]+0.5*speedsL[4]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3872983346207417*JfL[23])+0.38729833462074165*JfL[22]-0.22360679774997896*JfL[21]-0.38729833462074165*JfL[20]+0.22360679774997894*JfL[19]+0.3872983346207417*JfL[18]-0.22360679774997902*JfL[17]+0.22360679774997896*JfL[16]+0.5809475019311124*JfL[15]-0.5809475019311124*JfL[14]+0.33541019662496846*JfL[13]-0.4330127018922193*JfL[12]+0.5809475019311124*JfL[11]-0.33541019662496846*JfL[10]+0.4330127018922193*JfL[9]-0.25*JfL[8]-0.5809475019311124*JfL[7]+0.33541019662496846*JfL[6]-0.4330127018922193*JfL[5]+0.25*JfL[4]-0.33541019662496846*JfL[3]+0.4330127018922193*JfL[2]-0.25*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.3872983346207417*JfR[23]-0.38729833462074165*JfR[22]-0.22360679774997896*JfR[21]+0.38729833462074165*JfR[20]+0.22360679774997894*JfR[19]-0.3872983346207417*JfR[18]-0.22360679774997902*JfR[17]+0.22360679774997896*JfR[16]-0.5809475019311124*JfR[15]+0.5809475019311124*JfR[14]+0.33541019662496846*JfR[13]+0.4330127018922193*JfR[12]-0.5809475019311124*JfR[11]-0.33541019662496846*JfR[10]-0.4330127018922193*JfR[9]-0.25*JfR[8]+0.5809475019311124*JfR[7]+0.33541019662496846*JfR[6]+0.4330127018922193*JfR[5]+0.25*JfR[4]-0.33541019662496846*JfR[3]-0.4330127018922193*JfR[2]-0.25*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[3] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsL[7])+0.8660254037844386*speedsL[6]-0.5*speedsL[5]+0.5*speedsL[4]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.4841229182759271*JfL[23]-0.4841229182759271*JfL[22]+0.2795084971874737*JfL[21]+0.4841229182759271*JfL[20]-0.2795084971874738*JfL[19]-0.4841229182759271*JfL[18]+0.2795084971874738*JfL[17]-0.2795084971874737*JfL[16]-0.4330127018922193*JfL[12]+0.4330127018922193*JfL[9]-0.25*JfL[8]-0.4330127018922193*JfL[5]+0.25*JfL[4]+0.4330127018922193*JfL[2]-0.25*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.4841229182759271*JfR[23])+0.4841229182759271*JfR[22]+0.2795084971874737*JfR[21]-0.4841229182759271*JfR[20]-0.2795084971874738*JfR[19]+0.4841229182759271*JfR[18]+0.2795084971874738*JfR[17]-0.2795084971874737*JfR[16]+0.4330127018922193*JfR[12]-0.4330127018922193*JfR[9]-0.25*JfR[8]+0.4330127018922193*JfR[5]+0.25*JfR[4]-0.4330127018922193*JfR[2]-0.25*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[4] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsL[7])+0.8660254037844386*speedsL[6]-0.5*speedsL[5]+0.5*speedsL[4]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3872983346207417*JfL[23])+0.38729833462074165*JfL[22]-0.22360679774997896*JfL[21]-0.38729833462074165*JfL[20]+0.22360679774997894*JfL[19]+0.3872983346207417*JfL[18]-0.22360679774997902*JfL[17]+0.22360679774997896*JfL[16]-0.5809475019311124*JfL[15]+0.5809475019311124*JfL[14]-0.33541019662496846*JfL[13]-0.4330127018922193*JfL[12]-0.5809475019311124*JfL[11]+0.33541019662496846*JfL[10]+0.4330127018922193*JfL[9]-0.25*JfL[8]+0.5809475019311124*JfL[7]-0.33541019662496846*JfL[6]-0.4330127018922193*JfL[5]+0.25*JfL[4]+0.33541019662496846*JfL[3]+0.4330127018922193*JfL[2]-0.25*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.3872983346207417*JfR[23]-0.38729833462074165*JfR[22]-0.22360679774997896*JfR[21]+0.38729833462074165*JfR[20]+0.22360679774997894*JfR[19]-0.3872983346207417*JfR[18]-0.22360679774997902*JfR[17]+0.22360679774997896*JfR[16]+0.5809475019311124*JfR[15]-0.5809475019311124*JfR[14]-0.33541019662496846*JfR[13]+0.4330127018922193*JfR[12]+0.5809475019311124*JfR[11]+0.33541019662496846*JfR[10]-0.4330127018922193*JfR[9]-0.25*JfR[8]-0.5809475019311124*JfR[7]-0.33541019662496846*JfR[6]+0.4330127018922193*JfR[5]+0.25*JfR[4]+0.33541019662496846*JfR[3]-0.4330127018922193*JfR[2]-0.25*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[5] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[1].bmag; + Jc_quad = gkdgs[1].Jc; + B3_quad = gkdgs[1].B3; + normcurlbhat_quad = gkdgs[1].normcurlbhat; + bhat_quad[0] = gkdgs[1].bhat.x[0]; + bhat_quad[1] = gkdgs[1].bhat.x[1]; + bhat_quad[2] = gkdgs[1].bhat.x[2]; + area_elem_quad = dgs[1].area_elem; + + + alpha_quad = 0.8660254037844386*(speedsL[7]+speedsL[6])+0.5*(speedsL[5]+speedsL[4]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3872983346207417*JfL[23])-0.38729833462074165*JfL[22]-0.22360679774997896*JfL[21]+0.38729833462074165*JfL[20]-0.22360679774997894*JfL[19]+0.3872983346207417*JfL[18]+0.22360679774997902*JfL[17]+0.22360679774997896*JfL[16]+0.5809475019311124*(JfL[15]+JfL[14])+0.33541019662496846*JfL[13]-0.4330127018922193*JfL[12]-0.5809475019311124*JfL[11]+0.33541019662496846*JfL[10]-0.4330127018922193*JfL[9]-0.25*JfL[8]-0.5809475019311124*JfL[7]-0.33541019662496846*JfL[6]+0.4330127018922193*JfL[5]-0.25*JfL[4]-0.33541019662496846*JfL[3]+0.4330127018922193*JfL[2]+0.25*(JfL[1]+JfL[0]); + JfR_quad = 0.3872983346207417*JfR[23]+0.38729833462074165*JfR[22]-0.22360679774997896*JfR[21]-0.38729833462074165*JfR[20]-0.22360679774997894*JfR[19]-0.3872983346207417*JfR[18]+0.22360679774997902*JfR[17]+0.22360679774997896*JfR[16]-0.5809475019311124*(JfR[15]+JfR[14])+0.33541019662496846*JfR[13]+0.4330127018922193*JfR[12]+0.5809475019311124*JfR[11]+0.33541019662496846*JfR[10]+0.4330127018922193*JfR[9]-0.25*JfR[8]+0.5809475019311124*JfR[7]-0.33541019662496846*JfR[6]-0.4330127018922193*JfR[5]-0.25*JfR[4]-0.33541019662496846*JfR[3]-0.4330127018922193*JfR[2]+0.25*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[6] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*(speedsL[7]+speedsL[6])+0.5*(speedsL[5]+speedsL[4]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.4841229182759271*(JfL[23]+JfL[22])+0.2795084971874737*JfL[21]-0.4841229182759271*JfL[20]+0.2795084971874738*JfL[19]-0.4841229182759271*JfL[18]-0.2795084971874738*JfL[17]-0.2795084971874737*JfL[16]-0.4330127018922193*(JfL[12]+JfL[9])-0.25*JfL[8]+0.4330127018922193*JfL[5]-0.25*JfL[4]+0.4330127018922193*JfL[2]+0.25*(JfL[1]+JfL[0]); + JfR_quad = -(0.4841229182759271*(JfR[23]+JfR[22]))+0.2795084971874737*JfR[21]+0.4841229182759271*JfR[20]+0.2795084971874738*JfR[19]+0.4841229182759271*JfR[18]-0.2795084971874738*JfR[17]-0.2795084971874737*JfR[16]+0.4330127018922193*(JfR[12]+JfR[9])-0.25*JfR[8]-0.4330127018922193*JfR[5]-0.25*JfR[4]-0.4330127018922193*JfR[2]+0.25*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[7] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*(speedsL[7]+speedsL[6])+0.5*(speedsL[5]+speedsL[4]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3872983346207417*JfL[23])-0.38729833462074165*JfL[22]-0.22360679774997896*JfL[21]+0.38729833462074165*JfL[20]-0.22360679774997894*JfL[19]+0.3872983346207417*JfL[18]+0.22360679774997902*JfL[17]+0.22360679774997896*JfL[16]-0.5809475019311124*(JfL[15]+JfL[14])-0.33541019662496846*JfL[13]-0.4330127018922193*JfL[12]+0.5809475019311124*JfL[11]-0.33541019662496846*JfL[10]-0.4330127018922193*JfL[9]-0.25*JfL[8]+0.5809475019311124*JfL[7]+0.33541019662496846*JfL[6]+0.4330127018922193*JfL[5]-0.25*JfL[4]+0.33541019662496846*JfL[3]+0.4330127018922193*JfL[2]+0.25*(JfL[1]+JfL[0]); + JfR_quad = 0.3872983346207417*JfR[23]+0.38729833462074165*JfR[22]-0.22360679774997896*JfR[21]-0.38729833462074165*JfR[20]-0.22360679774997894*JfR[19]-0.3872983346207417*JfR[18]+0.22360679774997902*JfR[17]+0.22360679774997896*JfR[16]+0.5809475019311124*(JfR[15]+JfR[14])-0.33541019662496846*JfR[13]+0.4330127018922193*JfR[12]-0.5809475019311124*JfR[11]-0.33541019662496846*JfR[10]+0.4330127018922193*JfR[9]-0.25*JfR[8]-0.5809475019311124*JfR[7]+0.33541019662496846*JfR[6]-0.4330127018922193*JfR[5]-0.25*JfR[4]+0.33541019662496846*JfR[3]-0.4330127018922193*JfR[2]+0.25*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[8] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*(speedsL[7]+speedsL[6])+0.5*(speedsL[5]+speedsL[4]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3872983346207417*JfL[23]+0.38729833462074165*JfL[22]+0.22360679774997896*JfL[21]+0.38729833462074165*JfL[20]+0.22360679774997894*JfL[19]+0.3872983346207417*JfL[18]+0.22360679774997902*JfL[17]+0.22360679774997896*JfL[16]-0.5809475019311124*(JfL[15]+JfL[14])-0.33541019662496846*JfL[13]+0.4330127018922193*JfL[12]-0.5809475019311124*JfL[11]-0.33541019662496846*JfL[10]+0.4330127018922193*JfL[9]+0.25*JfL[8]-0.5809475019311124*JfL[7]-0.33541019662496846*JfL[6]+0.4330127018922193*JfL[5]+0.25*JfL[4]-0.33541019662496846*JfL[3]+0.4330127018922193*JfL[2]+0.25*(JfL[1]+JfL[0]); + JfR_quad = -(0.3872983346207417*JfR[23])-0.38729833462074165*JfR[22]+0.22360679774997896*JfR[21]-0.38729833462074165*JfR[20]+0.22360679774997894*JfR[19]-0.3872983346207417*JfR[18]+0.22360679774997902*JfR[17]+0.22360679774997896*JfR[16]+0.5809475019311124*(JfR[15]+JfR[14])-0.33541019662496846*JfR[13]-0.4330127018922193*JfR[12]+0.5809475019311124*JfR[11]-0.33541019662496846*JfR[10]-0.4330127018922193*JfR[9]+0.25*JfR[8]+0.5809475019311124*JfR[7]-0.33541019662496846*JfR[6]-0.4330127018922193*JfR[5]+0.25*JfR[4]-0.33541019662496846*JfR[3]-0.4330127018922193*JfR[2]+0.25*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[9] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*(speedsL[7]+speedsL[6])+0.5*(speedsL[5]+speedsL[4]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.4841229182759271*(JfL[23]+JfL[22]))-0.2795084971874737*JfL[21]-0.4841229182759271*JfL[20]-0.2795084971874738*JfL[19]-0.4841229182759271*JfL[18]-0.2795084971874738*JfL[17]-0.2795084971874737*JfL[16]+0.4330127018922193*(JfL[12]+JfL[9])+0.25*JfL[8]+0.4330127018922193*JfL[5]+0.25*JfL[4]+0.4330127018922193*JfL[2]+0.25*(JfL[1]+JfL[0]); + JfR_quad = 0.4841229182759271*(JfR[23]+JfR[22])-0.2795084971874737*JfR[21]+0.4841229182759271*JfR[20]-0.2795084971874738*JfR[19]+0.4841229182759271*JfR[18]-0.2795084971874738*JfR[17]-0.2795084971874737*JfR[16]-0.4330127018922193*(JfR[12]+JfR[9])+0.25*JfR[8]-0.4330127018922193*JfR[5]+0.25*JfR[4]-0.4330127018922193*JfR[2]+0.25*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[10] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*(speedsL[7]+speedsL[6])+0.5*(speedsL[5]+speedsL[4]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3872983346207417*JfL[23]+0.38729833462074165*JfL[22]+0.22360679774997896*JfL[21]+0.38729833462074165*JfL[20]+0.22360679774997894*JfL[19]+0.3872983346207417*JfL[18]+0.22360679774997902*JfL[17]+0.22360679774997896*JfL[16]+0.5809475019311124*(JfL[15]+JfL[14])+0.33541019662496846*JfL[13]+0.4330127018922193*JfL[12]+0.5809475019311124*JfL[11]+0.33541019662496846*JfL[10]+0.4330127018922193*JfL[9]+0.25*JfL[8]+0.5809475019311124*JfL[7]+0.33541019662496846*JfL[6]+0.4330127018922193*JfL[5]+0.25*JfL[4]+0.33541019662496846*JfL[3]+0.4330127018922193*JfL[2]+0.25*(JfL[1]+JfL[0]); + JfR_quad = -(0.3872983346207417*JfR[23])-0.38729833462074165*JfR[22]+0.22360679774997896*JfR[21]-0.38729833462074165*JfR[20]+0.22360679774997894*JfR[19]-0.3872983346207417*JfR[18]+0.22360679774997902*JfR[17]+0.22360679774997896*JfR[16]-0.5809475019311124*(JfR[15]+JfR[14])+0.33541019662496846*JfR[13]-0.4330127018922193*JfR[12]-0.5809475019311124*JfR[11]+0.33541019662496846*JfR[10]-0.4330127018922193*JfR[9]+0.25*JfR[8]-0.5809475019311124*JfR[7]+0.33541019662496846*JfR[6]-0.4330127018922193*JfR[5]+0.25*JfR[4]+0.33541019662496846*JfR[3]-0.4330127018922193*JfR[2]+0.25*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[11] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdz2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfy_3x2v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfy_3x2v_ser_p1.c new file mode 100644 index 0000000000..b3c86a3139 --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfy_3x2v_ser_p1.c @@ -0,0 +1,303 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_edge_surfy_3x2v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdy2 = 2.0/dxv[1]; + double rdz2 = 2.0/dxv[2]; + double rdvpar2 = 2.0/dxv[3]; + + double *flux_surf_nodal = &flux_surf[24]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = 0.6123724356957944*speedsL[15]-0.6123724356957944*speedsL[14]+0.3535533905932737*speedsL[13]-0.6123724356957944*speedsL[12]-0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]-0.3535533905932737*speedsL[9]+0.3535533905932737*speedsL[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])+0.27386127875258304*JfL[46]-0.15811388300841892*JfL[45]+0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]-0.273861278752583*JfL[41]+0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]+0.15811388300841892*JfL[38]-0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]-0.41079191812887433*JfL[30]+0.2371708245126284*JfL[29]-0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]+0.41079191812887433*JfL[24]-0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]+0.41079191812887433*JfL[19]-0.2371708245126284*JfL[18]+0.41079191812887433*JfL[17]+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]+0.2371708245126284*JfL[11]-0.41079191812887433*JfL[10]+0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.27386127875258304*JfR[46]-0.15811388300841892*JfR[45]-0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]+0.273861278752583*JfR[41]+0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]+0.15811388300841892*JfR[38]+0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.41079191812887433*JfR[30]+0.2371708245126284*JfR[29]+0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]-0.41079191812887433*JfR[24]-0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]-0.41079191812887433*JfR[19]-0.2371708245126284*JfR[18]-0.41079191812887433*JfR[17]-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]+0.2371708245126284*JfR[11]+0.41079191812887433*JfR[10]+0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[15]-0.6123724356957944*speedsL[14]+0.3535533905932737*speedsL[13]-0.6123724356957944*speedsL[12]-0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]-0.3535533905932737*speedsL[9]+0.3535533905932737*speedsL[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]-0.3423265984407287*JfL[46]+0.19764235376052366*JfL[45]-0.3423265984407287*(JfL[44]+JfL[43])-0.19764235376052364*JfL[42]+0.34232659844072866*JfL[41]-0.19764235376052364*JfL[40]+0.34232659844072866*JfL[39]-0.19764235376052364*JfL[38]+0.34232659844072866*JfL[37]+0.19764235376052366*(JfL[36]+JfL[35])-0.3423265984407287*JfL[34]+0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*JfL[27]+0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]+0.3061862178478971*(JfL[20]+JfL[16])+0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]-0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*(JfL[5]+JfL[3])+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.34232659844072866*JfR[47])+0.3423265984407287*JfR[46]+0.19764235376052366*JfR[45]+0.3423265984407287*(JfR[44]+JfR[43])-0.19764235376052364*JfR[42]-0.34232659844072866*JfR[41]-0.19764235376052364*JfR[40]-0.34232659844072866*JfR[39]-0.19764235376052364*JfR[38]-0.34232659844072866*JfR[37]+0.19764235376052366*(JfR[36]+JfR[35])+0.3423265984407287*JfR[34]+0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*JfR[27]-0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]-0.3061862178478971*(JfR[20]+JfR[16])+0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]+0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*(JfR[5]+JfR[3])-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[15]-0.6123724356957944*speedsL[14]+0.3535533905932737*speedsL[13]-0.6123724356957944*speedsL[12]-0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]-0.3535533905932737*speedsL[9]+0.3535533905932737*speedsL[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])+0.27386127875258304*JfL[46]-0.15811388300841892*JfL[45]+0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]-0.273861278752583*JfL[41]+0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]+0.15811388300841892*JfL[38]-0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]+0.41079191812887433*JfL[30]-0.2371708245126284*JfL[29]+0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]-0.41079191812887433*JfL[24]+0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]-0.41079191812887433*JfL[19]+0.2371708245126284*JfL[18]-0.41079191812887433*JfL[17]+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]-0.2371708245126284*JfL[11]+0.41079191812887433*JfL[10]-0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.27386127875258304*JfR[46]-0.15811388300841892*JfR[45]-0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]+0.273861278752583*JfR[41]+0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]+0.15811388300841892*JfR[38]+0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.41079191812887433*JfR[30]-0.2371708245126284*JfR[29]-0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]+0.41079191812887433*JfR[24]+0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]+0.41079191812887433*JfR[19]+0.2371708245126284*JfR[18]+0.41079191812887433*JfR[17]-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]-0.2371708245126284*JfR[11]-0.41079191812887433*JfR[10]-0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[15]-0.6123724356957944*speedsL[14]+0.3535533905932737*speedsL[13]-0.6123724356957944*speedsL[12]-0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]-0.3535533905932737*speedsL[9]+0.3535533905932737*speedsL[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]-0.27386127875258304*JfL[46]+0.15811388300841892*JfL[45]-0.27386127875258304*JfL[44]+0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]+0.273861278752583*JfL[41]-0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]+0.15811388300841892*JfL[38]-0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]+0.41079191812887433*JfL[30]-0.2371708245126284*JfL[29]+0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]-0.41079191812887433*JfL[24]+0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]+0.41079191812887433*JfL[19]-0.2371708245126284*JfL[18]+0.41079191812887433*JfL[17]+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]+0.2371708245126284*JfL[11]-0.41079191812887433*JfL[10]+0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.27386127875258304*JfR[46]+0.15811388300841892*JfR[45]+0.27386127875258304*JfR[44]-0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]-0.273861278752583*JfR[41]-0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]+0.15811388300841892*JfR[38]+0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.41079191812887433*JfR[30]-0.2371708245126284*JfR[29]-0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]+0.41079191812887433*JfR[24]+0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]-0.41079191812887433*JfR[19]-0.2371708245126284*JfR[18]-0.41079191812887433*JfR[17]-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]+0.2371708245126284*JfR[11]+0.41079191812887433*JfR[10]+0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[3] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[15]-0.6123724356957944*speedsL[14]+0.3535533905932737*speedsL[13]-0.6123724356957944*speedsL[12]-0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]-0.3535533905932737*speedsL[9]+0.3535533905932737*speedsL[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])+0.3423265984407287*JfL[46]-0.19764235376052366*JfL[45]+0.3423265984407287*JfL[44]-0.3423265984407287*JfL[43]+0.19764235376052364*JfL[42]-0.34232659844072866*JfL[41]+0.19764235376052364*JfL[40]+0.34232659844072866*JfL[39]-0.19764235376052364*JfL[38]+0.34232659844072866*JfL[37]-0.19764235376052366*JfL[36]+0.19764235376052366*JfL[35]-0.3423265984407287*JfL[34]+0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*JfL[27]-0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]+0.3061862178478971*JfL[16]-0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]-0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.34232659844072866*JfR[47]-0.3423265984407287*JfR[46]-0.19764235376052366*JfR[45]-0.3423265984407287*JfR[44]+0.3423265984407287*JfR[43]+0.19764235376052364*JfR[42]+0.34232659844072866*JfR[41]+0.19764235376052364*JfR[40]-0.34232659844072866*JfR[39]-0.19764235376052364*JfR[38]-0.34232659844072866*JfR[37]-0.19764235376052366*JfR[36]+0.19764235376052366*JfR[35]+0.3423265984407287*JfR[34]+0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*JfR[27]+0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]-0.3061862178478971*JfR[16]-0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]+0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[4] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[15]-0.6123724356957944*speedsL[14]+0.3535533905932737*speedsL[13]-0.6123724356957944*speedsL[12]-0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]-0.3535533905932737*speedsL[9]+0.3535533905932737*speedsL[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]-0.27386127875258304*JfL[46]+0.15811388300841892*JfL[45]-0.27386127875258304*JfL[44]+0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]+0.273861278752583*JfL[41]-0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]+0.15811388300841892*JfL[38]-0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]-0.41079191812887433*JfL[30]+0.2371708245126284*JfL[29]-0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]+0.41079191812887433*JfL[24]-0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]-0.41079191812887433*JfL[19]+0.2371708245126284*JfL[18]-0.41079191812887433*JfL[17]+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]-0.2371708245126284*JfL[11]+0.41079191812887433*JfL[10]-0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.27386127875258304*JfR[46]+0.15811388300841892*JfR[45]+0.27386127875258304*JfR[44]-0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]-0.273861278752583*JfR[41]-0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]+0.15811388300841892*JfR[38]+0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.41079191812887433*JfR[30]+0.2371708245126284*JfR[29]+0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]-0.41079191812887433*JfR[24]-0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]+0.41079191812887433*JfR[19]+0.2371708245126284*JfR[18]+0.41079191812887433*JfR[17]-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]-0.2371708245126284*JfR[11]-0.41079191812887433*JfR[10]-0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[5] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[1].bmag; + Jc_quad = gkdgs[1].Jc; + B3_quad = gkdgs[1].B3; + normcurlbhat_quad = gkdgs[1].normcurlbhat; + bhat_quad[0] = gkdgs[1].bhat.x[0]; + bhat_quad[1] = gkdgs[1].bhat.x[1]; + bhat_quad[2] = gkdgs[1].bhat.x[2]; + area_elem_quad = dgs[1].area_elem; + + + alpha_quad = -(0.6123724356957944*speedsL[15])+0.6123724356957944*speedsL[14]-0.3535533905932737*speedsL[13]-0.6123724356957944*speedsL[12]+0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]-0.3535533905932737*speedsL[9]+0.3535533905932737*speedsL[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]-0.27386127875258304*JfL[46]+0.15811388300841892*JfL[45]+0.27386127875258304*JfL[44]-0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]-0.273861278752583*JfL[41]+0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]-0.15811388300841892*JfL[38]-0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]+0.41079191812887433*JfL[30]-0.2371708245126284*JfL[29]-0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]+0.41079191812887433*JfL[24]-0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]-0.41079191812887433*JfL[19]+0.2371708245126284*JfL[18]+0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]-0.2371708245126284*JfL[11]-0.41079191812887433*JfL[10]+0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.27386127875258304*JfR[46]+0.15811388300841892*JfR[45]-0.27386127875258304*JfR[44]+0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]+0.273861278752583*JfR[41]+0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]-0.15811388300841892*JfR[38]+0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.41079191812887433*JfR[30]-0.2371708245126284*JfR[29]+0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]-0.41079191812887433*JfR[24]-0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]+0.41079191812887433*JfR[19]+0.2371708245126284*JfR[18]-0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]-0.2371708245126284*JfR[11]+0.41079191812887433*JfR[10]+0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[6] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[15])+0.6123724356957944*speedsL[14]-0.3535533905932737*speedsL[13]-0.6123724356957944*speedsL[12]+0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]-0.3535533905932737*speedsL[9]+0.3535533905932737*speedsL[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])+0.3423265984407287*JfL[46]-0.19764235376052366*JfL[45]-0.3423265984407287*JfL[44]+0.3423265984407287*JfL[43]+0.19764235376052364*JfL[42]+0.34232659844072866*JfL[41]-0.19764235376052364*JfL[40]-0.34232659844072866*JfL[39]+0.19764235376052364*JfL[38]+0.34232659844072866*JfL[37]+0.19764235376052366*JfL[36]-0.19764235376052366*JfL[35]-0.3423265984407287*JfL[34]+0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*JfL[27]-0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]-0.3061862178478971*JfL[16]-0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]+0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.34232659844072866*JfR[47]-0.3423265984407287*JfR[46]-0.19764235376052366*JfR[45]+0.3423265984407287*JfR[44]-0.3423265984407287*JfR[43]+0.19764235376052364*JfR[42]-0.34232659844072866*JfR[41]-0.19764235376052364*JfR[40]+0.34232659844072866*JfR[39]+0.19764235376052364*JfR[38]-0.34232659844072866*JfR[37]+0.19764235376052366*JfR[36]-0.19764235376052366*JfR[35]+0.3423265984407287*JfR[34]+0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*JfR[27]+0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]+0.3061862178478971*JfR[16]-0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]-0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[7] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[15])+0.6123724356957944*speedsL[14]-0.3535533905932737*speedsL[13]-0.6123724356957944*speedsL[12]+0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]-0.3535533905932737*speedsL[9]+0.3535533905932737*speedsL[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]-0.27386127875258304*JfL[46]+0.15811388300841892*JfL[45]+0.27386127875258304*JfL[44]-0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]-0.273861278752583*JfL[41]+0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]-0.15811388300841892*JfL[38]-0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]-0.41079191812887433*JfL[30]+0.2371708245126284*JfL[29]+0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]-0.41079191812887433*JfL[24]+0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]+0.41079191812887433*JfL[19]-0.2371708245126284*JfL[18]-0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]+0.2371708245126284*JfL[11]+0.41079191812887433*JfL[10]-0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.27386127875258304*JfR[46]+0.15811388300841892*JfR[45]-0.27386127875258304*JfR[44]+0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]+0.273861278752583*JfR[41]+0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]-0.15811388300841892*JfR[38]+0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.41079191812887433*JfR[30]+0.2371708245126284*JfR[29]-0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]+0.41079191812887433*JfR[24]+0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]-0.41079191812887433*JfR[19]-0.2371708245126284*JfR[18]+0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]+0.2371708245126284*JfR[11]-0.41079191812887433*JfR[10]-0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[8] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[15])+0.6123724356957944*speedsL[14]-0.3535533905932737*speedsL[13]-0.6123724356957944*speedsL[12]+0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]-0.3535533905932737*speedsL[9]+0.3535533905932737*speedsL[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])+0.27386127875258304*JfL[46]-0.15811388300841892*JfL[45]-0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]+0.273861278752583*JfL[41]-0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]-0.15811388300841892*JfL[38]-0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]-0.41079191812887433*JfL[30]+0.2371708245126284*JfL[29]+0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]-0.41079191812887433*JfL[24]+0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]-0.41079191812887433*JfL[19]+0.2371708245126284*JfL[18]+0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]-0.2371708245126284*JfL[11]-0.41079191812887433*JfL[10]+0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.27386127875258304*JfR[46]-0.15811388300841892*JfR[45]+0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]-0.273861278752583*JfR[41]-0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]-0.15811388300841892*JfR[38]+0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.41079191812887433*JfR[30]+0.2371708245126284*JfR[29]-0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]+0.41079191812887433*JfR[24]+0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]+0.41079191812887433*JfR[19]+0.2371708245126284*JfR[18]-0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]-0.2371708245126284*JfR[11]+0.41079191812887433*JfR[10]+0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[9] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[15])+0.6123724356957944*speedsL[14]-0.3535533905932737*speedsL[13]-0.6123724356957944*speedsL[12]+0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]-0.3535533905932737*speedsL[9]+0.3535533905932737*speedsL[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]-0.3423265984407287*JfL[46]+0.19764235376052366*JfL[45]+0.3423265984407287*(JfL[44]+JfL[43])-0.19764235376052364*JfL[42]-0.34232659844072866*JfL[41]+0.19764235376052364*JfL[40]-0.34232659844072866*JfL[39]+0.19764235376052364*JfL[38]+0.34232659844072866*JfL[37]-0.19764235376052366*(JfL[36]+JfL[35])-0.3423265984407287*JfL[34]+0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*JfL[27]+0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]-0.3061862178478971*(JfL[20]+JfL[16])+0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]+0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*(JfL[5]+JfL[3])+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.34232659844072866*JfR[47])+0.3423265984407287*JfR[46]+0.19764235376052366*JfR[45]-0.3423265984407287*(JfR[44]+JfR[43])-0.19764235376052364*JfR[42]+0.34232659844072866*JfR[41]+0.19764235376052364*JfR[40]+0.34232659844072866*JfR[39]+0.19764235376052364*JfR[38]-0.34232659844072866*JfR[37]-0.19764235376052366*(JfR[36]+JfR[35])+0.3423265984407287*JfR[34]+0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*JfR[27]-0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]+0.3061862178478971*(JfR[20]+JfR[16])+0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]-0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*(JfR[5]+JfR[3])-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[10] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[15])+0.6123724356957944*speedsL[14]-0.3535533905932737*speedsL[13]-0.6123724356957944*speedsL[12]+0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]-0.3535533905932737*speedsL[9]+0.3535533905932737*speedsL[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])+0.27386127875258304*JfL[46]-0.15811388300841892*JfL[45]-0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]+0.273861278752583*JfL[41]-0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]-0.15811388300841892*JfL[38]-0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]+0.41079191812887433*JfL[30]-0.2371708245126284*JfL[29]-0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]+0.41079191812887433*JfL[24]-0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]+0.41079191812887433*JfL[19]-0.2371708245126284*JfL[18]-0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]+0.2371708245126284*JfL[11]+0.41079191812887433*JfL[10]-0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.27386127875258304*JfR[46]-0.15811388300841892*JfR[45]+0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]-0.273861278752583*JfR[41]-0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]-0.15811388300841892*JfR[38]+0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.41079191812887433*JfR[30]-0.2371708245126284*JfR[29]+0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]-0.41079191812887433*JfR[24]-0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]-0.41079191812887433*JfR[19]-0.2371708245126284*JfR[18]+0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]+0.2371708245126284*JfR[11]-0.41079191812887433*JfR[10]-0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[11] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[2].bmag; + Jc_quad = gkdgs[2].Jc; + B3_quad = gkdgs[2].B3; + normcurlbhat_quad = gkdgs[2].normcurlbhat; + bhat_quad[0] = gkdgs[2].bhat.x[0]; + bhat_quad[1] = gkdgs[2].bhat.x[1]; + bhat_quad[2] = gkdgs[2].bhat.x[2]; + area_elem_quad = dgs[2].area_elem; + + + alpha_quad = -(0.6123724356957944*(speedsL[15]+speedsL[14]))-0.3535533905932737*speedsL[13]+0.6123724356957944*speedsL[12]-0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]+0.3535533905932737*(speedsL[9]+speedsL[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.27386127875258304*JfL[46]+0.15811388300841892*JfL[45]-0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]-0.273861278752583*JfL[41]-0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]-0.15811388300841892*JfL[38]+0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*(JfL[31]+JfL[30])-0.2371708245126284*JfL[29]+0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]+0.41079191812887433*JfL[24]+0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]+0.41079191812887433*JfL[19]+0.2371708245126284*JfL[18]-0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]+0.2371708245126284*JfL[11]-0.41079191812887433*JfL[10]-0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])-0.27386127875258304*JfR[46]+0.15811388300841892*JfR[45]+0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]+0.273861278752583*JfR[41]-0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]-0.15811388300841892*JfR[38]-0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*(JfR[31]+JfR[30])-0.2371708245126284*JfR[29]-0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]-0.41079191812887433*JfR[24]+0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]-0.41079191812887433*JfR[19]+0.2371708245126284*JfR[18]+0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]+0.2371708245126284*JfR[11]+0.41079191812887433*JfR[10]-0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[12] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsL[15]+speedsL[14]))-0.3535533905932737*speedsL[13]+0.6123724356957944*speedsL[12]-0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]+0.3535533905932737*(speedsL[9]+speedsL[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])-0.3423265984407287*JfL[46]-0.19764235376052366*JfL[45]+0.3423265984407287*(JfL[44]+JfL[43])-0.19764235376052364*JfL[42]+0.34232659844072866*JfL[41]+0.19764235376052364*JfL[40]+0.34232659844072866*JfL[39]+0.19764235376052364*JfL[38]-0.34232659844072866*JfL[37]+0.19764235376052366*(JfL[36]+JfL[35])-0.3423265984407287*JfL[34]-0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*(JfL[27]+JfL[22])+0.1767766952966368*JfL[21]-0.3061862178478971*(JfL[20]+JfL[16])+0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]-0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*(JfL[5]+JfL[3])+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.34232659844072866*JfR[47]+0.3423265984407287*JfR[46]-0.19764235376052366*JfR[45]-0.3423265984407287*(JfR[44]+JfR[43])-0.19764235376052364*JfR[42]-0.34232659844072866*JfR[41]+0.19764235376052364*JfR[40]-0.34232659844072866*JfR[39]+0.19764235376052364*JfR[38]+0.34232659844072866*JfR[37]+0.19764235376052366*(JfR[36]+JfR[35])+0.3423265984407287*JfR[34]-0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*(JfR[27]+JfR[22])+0.1767766952966368*JfR[21]+0.3061862178478971*(JfR[20]+JfR[16])+0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]+0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*(JfR[5]+JfR[3])-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[13] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsL[15]+speedsL[14]))-0.3535533905932737*speedsL[13]+0.6123724356957944*speedsL[12]-0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]+0.3535533905932737*(speedsL[9]+speedsL[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.27386127875258304*JfL[46]+0.15811388300841892*JfL[45]-0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]-0.273861278752583*JfL[41]-0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]-0.15811388300841892*JfL[38]+0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*(JfL[31]+JfL[30])+0.2371708245126284*JfL[29]-0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]-0.41079191812887433*JfL[24]-0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]-0.41079191812887433*JfL[19]-0.2371708245126284*JfL[18]+0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]-0.2371708245126284*JfL[11]+0.41079191812887433*JfL[10]+0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])-0.27386127875258304*JfR[46]+0.15811388300841892*JfR[45]+0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]+0.273861278752583*JfR[41]-0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]-0.15811388300841892*JfR[38]-0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*(JfR[31]+JfR[30])+0.2371708245126284*JfR[29]+0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]+0.41079191812887433*JfR[24]-0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]+0.41079191812887433*JfR[19]-0.2371708245126284*JfR[18]-0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]-0.2371708245126284*JfR[11]-0.41079191812887433*JfR[10]+0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[14] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsL[15]+speedsL[14]))-0.3535533905932737*speedsL[13]+0.6123724356957944*speedsL[12]-0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]+0.3535533905932737*(speedsL[9]+speedsL[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.27386127875258304*JfL[46]-0.15811388300841892*JfL[45]+0.27386127875258304*JfL[44]-0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]+0.273861278752583*JfL[41]+0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]-0.15811388300841892*JfL[38]+0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*(JfL[31]+JfL[30])+0.2371708245126284*JfL[29]-0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]-0.41079191812887433*JfL[24]-0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]+0.41079191812887433*JfL[19]+0.2371708245126284*JfL[18]-0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]+0.2371708245126284*JfL[11]-0.41079191812887433*JfL[10]-0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.273861278752583*JfR[47]+0.27386127875258304*JfR[46]-0.15811388300841892*JfR[45]-0.27386127875258304*JfR[44]+0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]-0.273861278752583*JfR[41]+0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]-0.15811388300841892*JfR[38]-0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*(JfR[31]+JfR[30])+0.2371708245126284*JfR[29]+0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]+0.41079191812887433*JfR[24]-0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]-0.41079191812887433*JfR[19]+0.2371708245126284*JfR[18]+0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]+0.2371708245126284*JfR[11]+0.41079191812887433*JfR[10]-0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[15] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsL[15]+speedsL[14]))-0.3535533905932737*speedsL[13]+0.6123724356957944*speedsL[12]-0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]+0.3535533905932737*(speedsL[9]+speedsL[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]+0.3423265984407287*JfL[46]+0.19764235376052366*JfL[45]-0.3423265984407287*JfL[44]+0.3423265984407287*JfL[43]+0.19764235376052364*JfL[42]-0.34232659844072866*JfL[41]-0.19764235376052364*JfL[40]+0.34232659844072866*JfL[39]+0.19764235376052364*JfL[38]-0.34232659844072866*JfL[37]-0.19764235376052366*JfL[36]+0.19764235376052366*JfL[35]-0.3423265984407287*JfL[34]-0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*(JfL[27]+JfL[22])-0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]-0.3061862178478971*JfL[16]-0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]-0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.34232659844072866*JfR[47])-0.3423265984407287*JfR[46]+0.19764235376052366*JfR[45]+0.3423265984407287*JfR[44]-0.3423265984407287*JfR[43]+0.19764235376052364*JfR[42]+0.34232659844072866*JfR[41]-0.19764235376052364*JfR[40]-0.34232659844072866*JfR[39]+0.19764235376052364*JfR[38]+0.34232659844072866*JfR[37]-0.19764235376052366*JfR[36]+0.19764235376052366*JfR[35]+0.3423265984407287*JfR[34]-0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*(JfR[27]+JfR[22])-0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]+0.3061862178478971*JfR[16]-0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]+0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[16] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsL[15]+speedsL[14]))-0.3535533905932737*speedsL[13]+0.6123724356957944*speedsL[12]-0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]+0.3535533905932737*(speedsL[9]+speedsL[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.27386127875258304*JfL[46]-0.15811388300841892*JfL[45]+0.27386127875258304*JfL[44]-0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]+0.273861278752583*JfL[41]+0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]-0.15811388300841892*JfL[38]+0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*(JfL[31]+JfL[30])-0.2371708245126284*JfL[29]+0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]+0.41079191812887433*JfL[24]+0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]-0.41079191812887433*JfL[19]-0.2371708245126284*JfL[18]+0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]-0.2371708245126284*JfL[11]+0.41079191812887433*JfL[10]+0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.273861278752583*JfR[47]+0.27386127875258304*JfR[46]-0.15811388300841892*JfR[45]-0.27386127875258304*JfR[44]+0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]-0.273861278752583*JfR[41]+0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]-0.15811388300841892*JfR[38]-0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*(JfR[31]+JfR[30])-0.2371708245126284*JfR[29]-0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]-0.41079191812887433*JfR[24]+0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]+0.41079191812887433*JfR[19]-0.2371708245126284*JfR[18]-0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]-0.2371708245126284*JfR[11]-0.41079191812887433*JfR[10]+0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[17] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[3].bmag; + Jc_quad = gkdgs[3].Jc; + B3_quad = gkdgs[3].B3; + normcurlbhat_quad = gkdgs[3].normcurlbhat; + bhat_quad[0] = gkdgs[3].bhat.x[0]; + bhat_quad[1] = gkdgs[3].bhat.x[1]; + bhat_quad[2] = gkdgs[3].bhat.x[2]; + area_elem_quad = dgs[3].area_elem; + + + alpha_quad = 0.6123724356957944*(speedsL[15]+speedsL[14])+0.3535533905932737*speedsL[13]+0.6123724356957944*speedsL[12]+0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]+0.3535533905932737*(speedsL[9]+speedsL[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.27386127875258304*JfL[46]-0.15811388300841892*JfL[45]-0.27386127875258304*JfL[44]+0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]-0.273861278752583*JfL[41]-0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]+0.15811388300841892*JfL[38]+0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*(JfL[31]+JfL[30])+0.2371708245126284*JfL[29]+0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]+0.41079191812887433*JfL[24]+0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]-0.41079191812887433*JfL[19]-0.2371708245126284*JfL[18]-0.41079191812887433*JfL[17]+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]-0.2371708245126284*JfL[11]-0.41079191812887433*JfL[10]-0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.273861278752583*JfR[47]+0.27386127875258304*JfR[46]-0.15811388300841892*JfR[45]+0.27386127875258304*JfR[44]-0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]+0.273861278752583*JfR[41]-0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]+0.15811388300841892*JfR[38]-0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*(JfR[31]+JfR[30])+0.2371708245126284*JfR[29]-0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]-0.41079191812887433*JfR[24]+0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]+0.41079191812887433*JfR[19]-0.2371708245126284*JfR[18]+0.41079191812887433*JfR[17]-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]-0.2371708245126284*JfR[11]+0.41079191812887433*JfR[10]-0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[18] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsL[15]+speedsL[14])+0.3535533905932737*speedsL[13]+0.6123724356957944*speedsL[12]+0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]+0.3535533905932737*(speedsL[9]+speedsL[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]+0.3423265984407287*JfL[46]+0.19764235376052366*JfL[45]+0.3423265984407287*JfL[44]-0.3423265984407287*JfL[43]+0.19764235376052364*JfL[42]+0.34232659844072866*JfL[41]+0.19764235376052364*JfL[40]-0.34232659844072866*JfL[39]-0.19764235376052364*JfL[38]-0.34232659844072866*JfL[37]+0.19764235376052366*JfL[36]-0.19764235376052366*JfL[35]-0.3423265984407287*JfL[34]-0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*(JfL[27]+JfL[22])-0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]+0.3061862178478971*JfL[16]-0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]+0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.34232659844072866*JfR[47])-0.3423265984407287*JfR[46]+0.19764235376052366*JfR[45]-0.3423265984407287*JfR[44]+0.3423265984407287*JfR[43]+0.19764235376052364*JfR[42]-0.34232659844072866*JfR[41]+0.19764235376052364*JfR[40]+0.34232659844072866*JfR[39]-0.19764235376052364*JfR[38]+0.34232659844072866*JfR[37]+0.19764235376052366*JfR[36]-0.19764235376052366*JfR[35]+0.3423265984407287*JfR[34]-0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*(JfR[27]+JfR[22])-0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]-0.3061862178478971*JfR[16]-0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]-0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[19] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsL[15]+speedsL[14])+0.3535533905932737*speedsL[13]+0.6123724356957944*speedsL[12]+0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]+0.3535533905932737*(speedsL[9]+speedsL[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.27386127875258304*JfL[46]-0.15811388300841892*JfL[45]-0.27386127875258304*JfL[44]+0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]-0.273861278752583*JfL[41]-0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]+0.15811388300841892*JfL[38]+0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*(JfL[31]+JfL[30])-0.2371708245126284*JfL[29]-0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]-0.41079191812887433*JfL[24]-0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]+0.41079191812887433*JfL[19]+0.2371708245126284*JfL[18]+0.41079191812887433*JfL[17]+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]+0.2371708245126284*JfL[11]+0.41079191812887433*JfL[10]+0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.273861278752583*JfR[47]+0.27386127875258304*JfR[46]-0.15811388300841892*JfR[45]+0.27386127875258304*JfR[44]-0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]+0.273861278752583*JfR[41]-0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]+0.15811388300841892*JfR[38]-0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*(JfR[31]+JfR[30])-0.2371708245126284*JfR[29]+0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]+0.41079191812887433*JfR[24]-0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]-0.41079191812887433*JfR[19]+0.2371708245126284*JfR[18]-0.41079191812887433*JfR[17]-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]+0.2371708245126284*JfR[11]-0.41079191812887433*JfR[10]+0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[20] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsL[15]+speedsL[14])+0.3535533905932737*speedsL[13]+0.6123724356957944*speedsL[12]+0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]+0.3535533905932737*(speedsL[9]+speedsL[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.27386127875258304*JfL[46]+0.15811388300841892*JfL[45]+0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]+0.273861278752583*JfL[41]+0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]+0.15811388300841892*JfL[38]+0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*(JfL[31]+JfL[30])-0.2371708245126284*JfL[29]-0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]-0.41079191812887433*JfL[24]-0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]-0.41079191812887433*JfL[19]-0.2371708245126284*JfL[18]-0.41079191812887433*JfL[17]+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]-0.2371708245126284*JfL[11]-0.41079191812887433*JfL[10]-0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])-0.27386127875258304*JfR[46]+0.15811388300841892*JfR[45]-0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]-0.273861278752583*JfR[41]+0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]+0.15811388300841892*JfR[38]-0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*(JfR[31]+JfR[30])-0.2371708245126284*JfR[29]+0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]+0.41079191812887433*JfR[24]-0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]+0.41079191812887433*JfR[19]-0.2371708245126284*JfR[18]+0.41079191812887433*JfR[17]-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]-0.2371708245126284*JfR[11]+0.41079191812887433*JfR[10]-0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[21] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsL[15]+speedsL[14])+0.3535533905932737*speedsL[13]+0.6123724356957944*speedsL[12]+0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]+0.3535533905932737*(speedsL[9]+speedsL[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])-0.3423265984407287*JfL[46]-0.19764235376052366*JfL[45]-0.3423265984407287*(JfL[44]+JfL[43])-0.19764235376052364*JfL[42]-0.34232659844072866*JfL[41]-0.19764235376052364*JfL[40]-0.34232659844072866*JfL[39]-0.19764235376052364*JfL[38]-0.34232659844072866*JfL[37]-0.19764235376052366*(JfL[36]+JfL[35])-0.3423265984407287*JfL[34]-0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*(JfL[27]+JfL[22])+0.1767766952966368*JfL[21]+0.3061862178478971*(JfL[20]+JfL[16])+0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]+0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*(JfL[5]+JfL[3])+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.34232659844072866*JfR[47]+0.3423265984407287*JfR[46]-0.19764235376052366*JfR[45]+0.3423265984407287*(JfR[44]+JfR[43])-0.19764235376052364*JfR[42]+0.34232659844072866*JfR[41]-0.19764235376052364*JfR[40]+0.34232659844072866*JfR[39]-0.19764235376052364*JfR[38]+0.34232659844072866*JfR[37]-0.19764235376052366*(JfR[36]+JfR[35])+0.3423265984407287*JfR[34]-0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*(JfR[27]+JfR[22])+0.1767766952966368*JfR[21]-0.3061862178478971*(JfR[20]+JfR[16])+0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]-0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*(JfR[5]+JfR[3])-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[22] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsL[15]+speedsL[14])+0.3535533905932737*speedsL[13]+0.6123724356957944*speedsL[12]+0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]+0.3535533905932737*(speedsL[9]+speedsL[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.27386127875258304*JfL[46]+0.15811388300841892*JfL[45]+0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]+0.273861278752583*JfL[41]+0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]+0.15811388300841892*JfL[38]+0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*(JfL[31]+JfL[30])+0.2371708245126284*JfL[29]+0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]+0.41079191812887433*JfL[24]+0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]+0.41079191812887433*JfL[19]+0.2371708245126284*JfL[18]+0.41079191812887433*JfL[17]+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]+0.2371708245126284*JfL[11]+0.41079191812887433*JfL[10]+0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])-0.27386127875258304*JfR[46]+0.15811388300841892*JfR[45]-0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]-0.273861278752583*JfR[41]+0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]+0.15811388300841892*JfR[38]-0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*(JfR[31]+JfR[30])+0.2371708245126284*JfR[29]-0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]-0.41079191812887433*JfR[24]+0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]-0.41079191812887433*JfR[19]+0.2371708245126284*JfR[18]-0.41079191812887433*JfR[17]-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]+0.2371708245126284*JfR[11]-0.41079191812887433*JfR[10]+0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[23] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdy2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfz_3x2v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfz_3x2v_ser_p1.c new file mode 100644 index 0000000000..c2941016d3 --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfz_3x2v_ser_p1.c @@ -0,0 +1,303 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_edge_surfz_3x2v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdy2 = 2.0/dxv[1]; + double rdz2 = 2.0/dxv[2]; + double rdvpar2 = 2.0/dxv[3]; + + double *flux_surf_nodal = &flux_surf[48]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = 0.6123724356957944*speedsL[23]-0.6123724356957944*(speedsL[22]+speedsL[21])+0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]-0.3535533905932737*(speedsL[18]+speedsL[17])+0.3535533905932737*speedsL[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])+0.27386127875258304*(JfL[46]+JfL[45])-0.15811388300841892*JfL[44]+0.27386127875258304*JfL[43]-0.273861278752583*JfL[42]+0.15811388300841892*(JfL[41]+JfL[40])-0.273861278752583*(JfL[39]+JfL[38])+0.15811388300841892*JfL[37]-0.15811388300841892*JfL[36]+0.27386127875258304*JfL[35]-0.15811388300841894*(JfL[34]+JfL[33])+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]-0.41079191812887433*(JfL[30]+JfL[29])+0.2371708245126284*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.41079191812887433*JfL[25]-0.2371708245126284*(JfL[24]+JfL[23])+0.3061862178478971*(JfL[22]+JfL[21])-0.1767766952966368*JfL[20]+0.41079191812887433*(JfL[19]+JfL[18])-0.2371708245126284*JfL[17]+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.3061862178478971*JfL[14]+0.1767766952966368*(JfL[13]+JfL[12])-0.41079191812887433*JfL[11]+0.2371708245126284*(JfL[10]+JfL[9])-0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*JfL[6]-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]-0.1767766952966368*(JfL[2]+JfL[1])+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.27386127875258304*(JfR[46]+JfR[45])-0.15811388300841892*JfR[44]-0.27386127875258304*JfR[43]+0.273861278752583*JfR[42]+0.15811388300841892*(JfR[41]+JfR[40])+0.273861278752583*(JfR[39]+JfR[38])+0.15811388300841892*JfR[37]-0.15811388300841892*JfR[36]-0.27386127875258304*JfR[35]-0.15811388300841894*(JfR[34]+JfR[33])+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.41079191812887433*(JfR[30]+JfR[29])+0.2371708245126284*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.41079191812887433*JfR[25]-0.2371708245126284*(JfR[24]+JfR[23])-0.3061862178478971*(JfR[22]+JfR[21])-0.1767766952966368*JfR[20]-0.41079191812887433*(JfR[19]+JfR[18])-0.2371708245126284*JfR[17]-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.3061862178478971*JfR[14]+0.1767766952966368*(JfR[13]+JfR[12])+0.41079191812887433*JfR[11]+0.2371708245126284*(JfR[10]+JfR[9])+0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*JfR[6]-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]-0.1767766952966368*(JfR[2]+JfR[1])+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[23]-0.6123724356957944*(speedsL[22]+speedsL[21])+0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]-0.3535533905932737*(speedsL[18]+speedsL[17])+0.3535533905932737*speedsL[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]-0.3423265984407287*(JfL[46]+JfL[45])+0.19764235376052366*JfL[44]-0.3423265984407287*JfL[43]+0.34232659844072866*JfL[42]-0.19764235376052364*(JfL[41]+JfL[40])+0.34232659844072866*(JfL[39]+JfL[38])-0.19764235376052364*JfL[37]+0.19764235376052366*JfL[36]-0.3423265984407287*JfL[35]+0.19764235376052366*(JfL[34]+JfL[33])-0.19764235376052364*JfL[32]-0.3061862178478971*JfL[27]+0.3061862178478971*(JfL[22]+JfL[21])-0.1767766952966368*JfL[20]+0.3061862178478971*JfL[16]-0.3061862178478971*JfL[14]+0.1767766952966368*(JfL[13]+JfL[12])-0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*JfL[6]-0.1767766952966368*JfL[5]+0.3061862178478971*JfL[3]-0.1767766952966368*(JfL[2]+JfL[1])+0.1767766952966368*JfL[0]; + JfR_quad = -(0.34232659844072866*JfR[47])+0.3423265984407287*(JfR[46]+JfR[45])+0.19764235376052366*JfR[44]+0.3423265984407287*JfR[43]-0.34232659844072866*JfR[42]-0.19764235376052364*(JfR[41]+JfR[40])-0.34232659844072866*(JfR[39]+JfR[38])-0.19764235376052364*JfR[37]+0.19764235376052366*JfR[36]+0.3423265984407287*JfR[35]+0.19764235376052366*(JfR[34]+JfR[33])-0.19764235376052364*JfR[32]+0.3061862178478971*JfR[27]-0.3061862178478971*(JfR[22]+JfR[21])-0.1767766952966368*JfR[20]-0.3061862178478971*JfR[16]+0.3061862178478971*JfR[14]+0.1767766952966368*(JfR[13]+JfR[12])+0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*JfR[6]-0.1767766952966368*JfR[5]-0.3061862178478971*JfR[3]-0.1767766952966368*(JfR[2]+JfR[1])+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[23]-0.6123724356957944*(speedsL[22]+speedsL[21])+0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]-0.3535533905932737*(speedsL[18]+speedsL[17])+0.3535533905932737*speedsL[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])+0.27386127875258304*(JfL[46]+JfL[45])-0.15811388300841892*JfL[44]+0.27386127875258304*JfL[43]-0.273861278752583*JfL[42]+0.15811388300841892*(JfL[41]+JfL[40])-0.273861278752583*(JfL[39]+JfL[38])+0.15811388300841892*JfL[37]-0.15811388300841892*JfL[36]+0.27386127875258304*JfL[35]-0.15811388300841894*(JfL[34]+JfL[33])+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]+0.41079191812887433*(JfL[30]+JfL[29])-0.2371708245126284*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.41079191812887433*JfL[25]+0.2371708245126284*(JfL[24]+JfL[23])+0.3061862178478971*(JfL[22]+JfL[21])-0.1767766952966368*JfL[20]-0.41079191812887433*(JfL[19]+JfL[18])+0.2371708245126284*JfL[17]+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.3061862178478971*JfL[14]+0.1767766952966368*(JfL[13]+JfL[12])+0.41079191812887433*JfL[11]-0.2371708245126284*(JfL[10]+JfL[9])-0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*JfL[6]-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]-0.1767766952966368*(JfL[2]+JfL[1])+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.27386127875258304*(JfR[46]+JfR[45])-0.15811388300841892*JfR[44]-0.27386127875258304*JfR[43]+0.273861278752583*JfR[42]+0.15811388300841892*(JfR[41]+JfR[40])+0.273861278752583*(JfR[39]+JfR[38])+0.15811388300841892*JfR[37]-0.15811388300841892*JfR[36]-0.27386127875258304*JfR[35]-0.15811388300841894*(JfR[34]+JfR[33])+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.41079191812887433*(JfR[30]+JfR[29])-0.2371708245126284*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.41079191812887433*JfR[25]+0.2371708245126284*(JfR[24]+JfR[23])-0.3061862178478971*(JfR[22]+JfR[21])-0.1767766952966368*JfR[20]+0.41079191812887433*(JfR[19]+JfR[18])+0.2371708245126284*JfR[17]-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.3061862178478971*JfR[14]+0.1767766952966368*(JfR[13]+JfR[12])-0.41079191812887433*JfR[11]-0.2371708245126284*(JfR[10]+JfR[9])+0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*JfR[6]-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]-0.1767766952966368*(JfR[2]+JfR[1])+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[23]-0.6123724356957944*(speedsL[22]+speedsL[21])+0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]-0.3535533905932737*(speedsL[18]+speedsL[17])+0.3535533905932737*speedsL[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]-0.27386127875258304*(JfL[46]+JfL[45])+0.15811388300841892*JfL[44]+0.27386127875258304*JfL[43]+0.273861278752583*JfL[42]-0.15811388300841892*(JfL[41]+JfL[40])-0.273861278752583*(JfL[39]+JfL[38])+0.15811388300841892*(JfL[37]+JfL[36])+0.27386127875258304*JfL[35]-0.15811388300841894*(JfL[34]+JfL[33])+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]+0.41079191812887433*(JfL[30]+JfL[29])-0.2371708245126284*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*(JfL[26]+JfL[25])+0.2371708245126284*(JfL[24]+JfL[23])-0.3061862178478971*(JfL[22]+JfL[21])+0.1767766952966368*JfL[20]+0.41079191812887433*(JfL[19]+JfL[18])-0.2371708245126284*JfL[17]+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.3061862178478971*JfL[14]-0.1767766952966368*(JfL[13]+JfL[12])-0.41079191812887433*JfL[11]+0.2371708245126284*(JfL[10]+JfL[9])-0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*(JfL[6]+JfL[5])-0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]-0.1767766952966368*(JfL[2]+JfL[1])+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.27386127875258304*(JfR[46]+JfR[45])+0.15811388300841892*JfR[44]-0.27386127875258304*JfR[43]-0.273861278752583*JfR[42]-0.15811388300841892*(JfR[41]+JfR[40])+0.273861278752583*(JfR[39]+JfR[38])+0.15811388300841892*(JfR[37]+JfR[36])-0.27386127875258304*JfR[35]-0.15811388300841894*(JfR[34]+JfR[33])+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.41079191812887433*(JfR[30]+JfR[29])-0.2371708245126284*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*(JfR[26]+JfR[25])+0.2371708245126284*(JfR[24]+JfR[23])+0.3061862178478971*(JfR[22]+JfR[21])+0.1767766952966368*JfR[20]-0.41079191812887433*(JfR[19]+JfR[18])-0.2371708245126284*JfR[17]-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.3061862178478971*JfR[14]-0.1767766952966368*(JfR[13]+JfR[12])+0.41079191812887433*JfR[11]+0.2371708245126284*(JfR[10]+JfR[9])+0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*(JfR[6]+JfR[5])-0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]-0.1767766952966368*(JfR[2]+JfR[1])+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[3] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[23]-0.6123724356957944*(speedsL[22]+speedsL[21])+0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]-0.3535533905932737*(speedsL[18]+speedsL[17])+0.3535533905932737*speedsL[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])+0.3423265984407287*(JfL[46]+JfL[45])-0.19764235376052366*JfL[44]-0.3423265984407287*JfL[43]-0.34232659844072866*JfL[42]+0.19764235376052364*(JfL[41]+JfL[40])+0.34232659844072866*(JfL[39]+JfL[38])-0.19764235376052364*JfL[37]-0.19764235376052366*JfL[36]-0.3423265984407287*JfL[35]+0.19764235376052366*(JfL[34]+JfL[33])-0.19764235376052364*JfL[32]+0.3061862178478971*JfL[27]-0.3061862178478971*(JfL[22]+JfL[21])+0.1767766952966368*JfL[20]+0.3061862178478971*(JfL[16]+JfL[14])-0.1767766952966368*(JfL[13]+JfL[12])-0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*(JfL[6]+JfL[5])+0.3061862178478971*JfL[3]-0.1767766952966368*(JfL[2]+JfL[1])+0.1767766952966368*JfL[0]; + JfR_quad = 0.34232659844072866*JfR[47]-0.3423265984407287*(JfR[46]+JfR[45])-0.19764235376052366*JfR[44]+0.3423265984407287*JfR[43]+0.34232659844072866*JfR[42]+0.19764235376052364*(JfR[41]+JfR[40])-0.34232659844072866*(JfR[39]+JfR[38])-0.19764235376052364*JfR[37]-0.19764235376052366*JfR[36]+0.3423265984407287*JfR[35]+0.19764235376052366*(JfR[34]+JfR[33])-0.19764235376052364*JfR[32]-0.3061862178478971*JfR[27]+0.3061862178478971*(JfR[22]+JfR[21])+0.1767766952966368*JfR[20]-0.3061862178478971*(JfR[16]+JfR[14])-0.1767766952966368*(JfR[13]+JfR[12])+0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*(JfR[6]+JfR[5])-0.3061862178478971*JfR[3]-0.1767766952966368*(JfR[2]+JfR[1])+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[4] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[23]-0.6123724356957944*(speedsL[22]+speedsL[21])+0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]-0.3535533905932737*(speedsL[18]+speedsL[17])+0.3535533905932737*speedsL[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]-0.27386127875258304*(JfL[46]+JfL[45])+0.15811388300841892*JfL[44]+0.27386127875258304*JfL[43]+0.273861278752583*JfL[42]-0.15811388300841892*(JfL[41]+JfL[40])-0.273861278752583*(JfL[39]+JfL[38])+0.15811388300841892*(JfL[37]+JfL[36])+0.27386127875258304*JfL[35]-0.15811388300841894*(JfL[34]+JfL[33])+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]-0.41079191812887433*(JfL[30]+JfL[29])+0.2371708245126284*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*(JfL[26]+JfL[25])-0.2371708245126284*(JfL[24]+JfL[23])-0.3061862178478971*(JfL[22]+JfL[21])+0.1767766952966368*JfL[20]-0.41079191812887433*(JfL[19]+JfL[18])+0.2371708245126284*JfL[17]+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.3061862178478971*JfL[14]-0.1767766952966368*(JfL[13]+JfL[12])+0.41079191812887433*JfL[11]-0.2371708245126284*(JfL[10]+JfL[9])-0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*(JfL[6]+JfL[5])+0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]-0.1767766952966368*(JfL[2]+JfL[1])+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.27386127875258304*(JfR[46]+JfR[45])+0.15811388300841892*JfR[44]-0.27386127875258304*JfR[43]-0.273861278752583*JfR[42]-0.15811388300841892*(JfR[41]+JfR[40])+0.273861278752583*(JfR[39]+JfR[38])+0.15811388300841892*(JfR[37]+JfR[36])-0.27386127875258304*JfR[35]-0.15811388300841894*(JfR[34]+JfR[33])+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.41079191812887433*(JfR[30]+JfR[29])+0.2371708245126284*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*(JfR[26]+JfR[25])-0.2371708245126284*(JfR[24]+JfR[23])+0.3061862178478971*(JfR[22]+JfR[21])+0.1767766952966368*JfR[20]+0.41079191812887433*(JfR[19]+JfR[18])+0.2371708245126284*JfR[17]-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.3061862178478971*JfR[14]-0.1767766952966368*(JfR[13]+JfR[12])-0.41079191812887433*JfR[11]-0.2371708245126284*(JfR[10]+JfR[9])+0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*(JfR[6]+JfR[5])+0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]-0.1767766952966368*(JfR[2]+JfR[1])+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[5] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[1].bmag; + Jc_quad = gkdgs[1].Jc; + B3_quad = gkdgs[1].B3; + normcurlbhat_quad = gkdgs[1].normcurlbhat; + bhat_quad[0] = gkdgs[1].bhat.x[0]; + bhat_quad[1] = gkdgs[1].bhat.x[1]; + bhat_quad[2] = gkdgs[1].bhat.x[2]; + area_elem_quad = dgs[1].area_elem; + + + alpha_quad = -(0.6123724356957944*speedsL[23])+0.6123724356957944*speedsL[22]-0.6123724356957944*speedsL[21]-0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]+0.3535533905932737*speedsL[18]-0.3535533905932737*speedsL[17]+0.3535533905932737*speedsL[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]-0.27386127875258304*JfL[46]+0.27386127875258304*JfL[45]+0.15811388300841892*JfL[44]-0.27386127875258304*JfL[43]-0.273861278752583*JfL[42]-0.15811388300841892*JfL[41]+0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]-0.273861278752583*JfL[38]-0.15811388300841892*(JfL[37]+JfL[36])+0.27386127875258304*JfL[35]+0.15811388300841894*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]+0.41079191812887433*JfL[30]-0.41079191812887433*JfL[29]-0.2371708245126284*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*(JfL[26]+JfL[25])+0.2371708245126284*JfL[24]-0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]+0.3061862178478971*JfL[21]+0.1767766952966368*JfL[20]-0.41079191812887433*JfL[19]+0.41079191812887433*JfL[18]+0.2371708245126284*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.3061862178478971*JfL[14]-0.1767766952966368*JfL[13]+0.1767766952966368*JfL[12]-0.41079191812887433*JfL[11]-0.2371708245126284*JfL[10]+0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]-0.3061862178478971*JfL[7]-0.1767766952966368*(JfL[6]+JfL[5])-0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]+0.1767766952966368*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.27386127875258304*JfR[46]-0.27386127875258304*JfR[45]+0.15811388300841892*JfR[44]+0.27386127875258304*JfR[43]+0.273861278752583*JfR[42]-0.15811388300841892*JfR[41]+0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]+0.273861278752583*JfR[38]-0.15811388300841892*(JfR[37]+JfR[36])-0.27386127875258304*JfR[35]+0.15811388300841894*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.41079191812887433*JfR[30]+0.41079191812887433*JfR[29]-0.2371708245126284*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*(JfR[26]+JfR[25])+0.2371708245126284*JfR[24]-0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]-0.3061862178478971*JfR[21]+0.1767766952966368*JfR[20]+0.41079191812887433*JfR[19]-0.41079191812887433*JfR[18]+0.2371708245126284*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.3061862178478971*JfR[14]-0.1767766952966368*JfR[13]+0.1767766952966368*JfR[12]+0.41079191812887433*JfR[11]-0.2371708245126284*JfR[10]+0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]+0.3061862178478971*JfR[7]-0.1767766952966368*(JfR[6]+JfR[5])-0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]+0.1767766952966368*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[6] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[23])+0.6123724356957944*speedsL[22]-0.6123724356957944*speedsL[21]-0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]+0.3535533905932737*speedsL[18]-0.3535533905932737*speedsL[17]+0.3535533905932737*speedsL[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])+0.3423265984407287*JfL[46]-0.3423265984407287*JfL[45]-0.19764235376052366*JfL[44]+0.3423265984407287*JfL[43]+0.34232659844072866*JfL[42]+0.19764235376052364*JfL[41]-0.19764235376052364*JfL[40]-0.34232659844072866*JfL[39]+0.34232659844072866*JfL[38]+0.19764235376052364*JfL[37]+0.19764235376052366*JfL[36]-0.3423265984407287*JfL[35]-0.19764235376052366*JfL[34]+0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*JfL[27]-0.3061862178478971*JfL[22]+0.3061862178478971*JfL[21]+0.1767766952966368*JfL[20]-0.3061862178478971*(JfL[16]+JfL[14])-0.1767766952966368*JfL[13]+0.1767766952966368*JfL[12]+0.3061862178478971*JfL[8]-0.3061862178478971*JfL[7]-0.1767766952966368*(JfL[6]+JfL[5])+0.3061862178478971*JfL[3]+0.1767766952966368*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.34232659844072866*JfR[47]-0.3423265984407287*JfR[46]+0.3423265984407287*JfR[45]-0.19764235376052366*JfR[44]-0.3423265984407287*JfR[43]-0.34232659844072866*JfR[42]+0.19764235376052364*JfR[41]-0.19764235376052364*JfR[40]+0.34232659844072866*JfR[39]-0.34232659844072866*JfR[38]+0.19764235376052364*JfR[37]+0.19764235376052366*JfR[36]+0.3423265984407287*JfR[35]-0.19764235376052366*JfR[34]+0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*JfR[27]+0.3061862178478971*JfR[22]-0.3061862178478971*JfR[21]+0.1767766952966368*JfR[20]+0.3061862178478971*(JfR[16]+JfR[14])-0.1767766952966368*JfR[13]+0.1767766952966368*JfR[12]-0.3061862178478971*JfR[8]+0.3061862178478971*JfR[7]-0.1767766952966368*(JfR[6]+JfR[5])-0.3061862178478971*JfR[3]+0.1767766952966368*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[7] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[23])+0.6123724356957944*speedsL[22]-0.6123724356957944*speedsL[21]-0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]+0.3535533905932737*speedsL[18]-0.3535533905932737*speedsL[17]+0.3535533905932737*speedsL[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]-0.27386127875258304*JfL[46]+0.27386127875258304*JfL[45]+0.15811388300841892*JfL[44]-0.27386127875258304*JfL[43]-0.273861278752583*JfL[42]-0.15811388300841892*JfL[41]+0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]-0.273861278752583*JfL[38]-0.15811388300841892*(JfL[37]+JfL[36])+0.27386127875258304*JfL[35]+0.15811388300841894*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]-0.41079191812887433*JfL[30]+0.41079191812887433*JfL[29]+0.2371708245126284*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*(JfL[26]+JfL[25])-0.2371708245126284*JfL[24]+0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]+0.3061862178478971*JfL[21]+0.1767766952966368*JfL[20]+0.41079191812887433*JfL[19]-0.41079191812887433*JfL[18]-0.2371708245126284*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.3061862178478971*JfL[14]-0.1767766952966368*JfL[13]+0.1767766952966368*JfL[12]+0.41079191812887433*JfL[11]+0.2371708245126284*JfL[10]-0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]-0.3061862178478971*JfL[7]-0.1767766952966368*(JfL[6]+JfL[5])+0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]+0.1767766952966368*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.27386127875258304*JfR[46]-0.27386127875258304*JfR[45]+0.15811388300841892*JfR[44]+0.27386127875258304*JfR[43]+0.273861278752583*JfR[42]-0.15811388300841892*JfR[41]+0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]+0.273861278752583*JfR[38]-0.15811388300841892*(JfR[37]+JfR[36])-0.27386127875258304*JfR[35]+0.15811388300841894*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.41079191812887433*JfR[30]-0.41079191812887433*JfR[29]+0.2371708245126284*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*(JfR[26]+JfR[25])-0.2371708245126284*JfR[24]+0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]-0.3061862178478971*JfR[21]+0.1767766952966368*JfR[20]-0.41079191812887433*JfR[19]+0.41079191812887433*JfR[18]-0.2371708245126284*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.3061862178478971*JfR[14]-0.1767766952966368*JfR[13]+0.1767766952966368*JfR[12]-0.41079191812887433*JfR[11]+0.2371708245126284*JfR[10]-0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]+0.3061862178478971*JfR[7]-0.1767766952966368*(JfR[6]+JfR[5])+0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]+0.1767766952966368*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[8] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[23])+0.6123724356957944*speedsL[22]-0.6123724356957944*speedsL[21]-0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]+0.3535533905932737*speedsL[18]-0.3535533905932737*speedsL[17]+0.3535533905932737*speedsL[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])+0.27386127875258304*JfL[46]-0.27386127875258304*JfL[45]-0.15811388300841892*JfL[44]-0.27386127875258304*JfL[43]+0.273861278752583*JfL[42]+0.15811388300841892*JfL[41]-0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]-0.273861278752583*JfL[38]-0.15811388300841892*JfL[37]+0.15811388300841892*JfL[36]+0.27386127875258304*JfL[35]+0.15811388300841894*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]-0.41079191812887433*JfL[30]+0.41079191812887433*JfL[29]+0.2371708245126284*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.41079191812887433*JfL[25]-0.2371708245126284*JfL[24]+0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]-0.3061862178478971*JfL[21]-0.1767766952966368*JfL[20]-0.41079191812887433*JfL[19]+0.41079191812887433*JfL[18]+0.2371708245126284*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.3061862178478971*JfL[14]+0.1767766952966368*JfL[13]-0.1767766952966368*JfL[12]-0.41079191812887433*JfL[11]-0.2371708245126284*JfL[10]+0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]-0.3061862178478971*JfL[7]-0.1767766952966368*JfL[6]+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]+0.1767766952966368*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.27386127875258304*JfR[46]+0.27386127875258304*JfR[45]-0.15811388300841892*JfR[44]+0.27386127875258304*JfR[43]-0.273861278752583*JfR[42]+0.15811388300841892*JfR[41]-0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]+0.273861278752583*JfR[38]-0.15811388300841892*JfR[37]+0.15811388300841892*JfR[36]-0.27386127875258304*JfR[35]+0.15811388300841894*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.41079191812887433*JfR[30]-0.41079191812887433*JfR[29]+0.2371708245126284*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.41079191812887433*JfR[25]-0.2371708245126284*JfR[24]+0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]+0.3061862178478971*JfR[21]-0.1767766952966368*JfR[20]+0.41079191812887433*JfR[19]-0.41079191812887433*JfR[18]+0.2371708245126284*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.3061862178478971*JfR[14]+0.1767766952966368*JfR[13]-0.1767766952966368*JfR[12]+0.41079191812887433*JfR[11]-0.2371708245126284*JfR[10]+0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]+0.3061862178478971*JfR[7]-0.1767766952966368*JfR[6]+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]+0.1767766952966368*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[9] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[23])+0.6123724356957944*speedsL[22]-0.6123724356957944*speedsL[21]-0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]+0.3535533905932737*speedsL[18]-0.3535533905932737*speedsL[17]+0.3535533905932737*speedsL[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]-0.3423265984407287*JfL[46]+0.3423265984407287*JfL[45]+0.19764235376052366*JfL[44]+0.3423265984407287*JfL[43]-0.34232659844072866*JfL[42]-0.19764235376052364*JfL[41]+0.19764235376052364*JfL[40]-0.34232659844072866*JfL[39]+0.34232659844072866*JfL[38]+0.19764235376052364*JfL[37]-0.19764235376052366*JfL[36]-0.3423265984407287*JfL[35]-0.19764235376052366*JfL[34]+0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*JfL[27]+0.3061862178478971*JfL[22]-0.3061862178478971*JfL[21]-0.1767766952966368*JfL[20]-0.3061862178478971*JfL[16]+0.3061862178478971*JfL[14]+0.1767766952966368*JfL[13]-0.1767766952966368*JfL[12]+0.3061862178478971*JfL[8]-0.3061862178478971*JfL[7]-0.1767766952966368*JfL[6]+0.1767766952966368*JfL[5]+0.3061862178478971*JfL[3]+0.1767766952966368*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.34232659844072866*JfR[47])+0.3423265984407287*JfR[46]-0.3423265984407287*JfR[45]+0.19764235376052366*JfR[44]-0.3423265984407287*JfR[43]+0.34232659844072866*JfR[42]-0.19764235376052364*JfR[41]+0.19764235376052364*JfR[40]+0.34232659844072866*JfR[39]-0.34232659844072866*JfR[38]+0.19764235376052364*JfR[37]-0.19764235376052366*JfR[36]+0.3423265984407287*JfR[35]-0.19764235376052366*JfR[34]+0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*JfR[27]-0.3061862178478971*JfR[22]+0.3061862178478971*JfR[21]-0.1767766952966368*JfR[20]+0.3061862178478971*JfR[16]-0.3061862178478971*JfR[14]+0.1767766952966368*JfR[13]-0.1767766952966368*JfR[12]-0.3061862178478971*JfR[8]+0.3061862178478971*JfR[7]-0.1767766952966368*JfR[6]+0.1767766952966368*JfR[5]-0.3061862178478971*JfR[3]+0.1767766952966368*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[10] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[23])+0.6123724356957944*speedsL[22]-0.6123724356957944*speedsL[21]-0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]+0.3535533905932737*speedsL[18]-0.3535533905932737*speedsL[17]+0.3535533905932737*speedsL[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])+0.27386127875258304*JfL[46]-0.27386127875258304*JfL[45]-0.15811388300841892*JfL[44]-0.27386127875258304*JfL[43]+0.273861278752583*JfL[42]+0.15811388300841892*JfL[41]-0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]-0.273861278752583*JfL[38]-0.15811388300841892*JfL[37]+0.15811388300841892*JfL[36]+0.27386127875258304*JfL[35]+0.15811388300841894*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]+0.41079191812887433*JfL[30]-0.41079191812887433*JfL[29]-0.2371708245126284*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.41079191812887433*JfL[25]+0.2371708245126284*JfL[24]-0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]-0.3061862178478971*JfL[21]-0.1767766952966368*JfL[20]+0.41079191812887433*JfL[19]-0.41079191812887433*JfL[18]-0.2371708245126284*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.3061862178478971*JfL[14]+0.1767766952966368*JfL[13]-0.1767766952966368*JfL[12]+0.41079191812887433*JfL[11]+0.2371708245126284*JfL[10]-0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]-0.3061862178478971*JfL[7]-0.1767766952966368*JfL[6]+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]+0.1767766952966368*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.27386127875258304*JfR[46]+0.27386127875258304*JfR[45]-0.15811388300841892*JfR[44]+0.27386127875258304*JfR[43]-0.273861278752583*JfR[42]+0.15811388300841892*JfR[41]-0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]+0.273861278752583*JfR[38]-0.15811388300841892*JfR[37]+0.15811388300841892*JfR[36]-0.27386127875258304*JfR[35]+0.15811388300841894*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.41079191812887433*JfR[30]+0.41079191812887433*JfR[29]-0.2371708245126284*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.41079191812887433*JfR[25]+0.2371708245126284*JfR[24]-0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]+0.3061862178478971*JfR[21]-0.1767766952966368*JfR[20]-0.41079191812887433*JfR[19]+0.41079191812887433*JfR[18]-0.2371708245126284*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.3061862178478971*JfR[14]+0.1767766952966368*JfR[13]-0.1767766952966368*JfR[12]-0.41079191812887433*JfR[11]+0.2371708245126284*JfR[10]-0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]+0.3061862178478971*JfR[7]-0.1767766952966368*JfR[6]+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]+0.1767766952966368*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[11] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[2].bmag; + Jc_quad = gkdgs[2].Jc; + B3_quad = gkdgs[2].B3; + normcurlbhat_quad = gkdgs[2].normcurlbhat; + bhat_quad[0] = gkdgs[2].bhat.x[0]; + bhat_quad[1] = gkdgs[2].bhat.x[1]; + bhat_quad[2] = gkdgs[2].bhat.x[2]; + area_elem_quad = dgs[2].area_elem; + + + alpha_quad = -(0.6123724356957944*(speedsL[23]+speedsL[22]))+0.6123724356957944*speedsL[21]-0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]-0.3535533905932737*speedsL[18]+0.3535533905932737*(speedsL[17]+speedsL[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.27386127875258304*JfL[46]-0.27386127875258304*JfL[45]+0.15811388300841892*JfL[44]-0.27386127875258304*JfL[43]-0.273861278752583*JfL[42]+0.15811388300841892*JfL[41]-0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]+0.273861278752583*JfL[38]-0.15811388300841892*(JfL[37]+JfL[36])+0.27386127875258304*JfL[35]-0.15811388300841894*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*(JfL[31]+JfL[30])+0.41079191812887433*JfL[29]-0.2371708245126284*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*(JfL[26]+JfL[25])-0.2371708245126284*JfL[24]+0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]-0.3061862178478971*JfL[21]+0.1767766952966368*JfL[20]+0.41079191812887433*JfL[19]-0.41079191812887433*JfL[18]+0.2371708245126284*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.3061862178478971*JfL[14]+0.1767766952966368*JfL[13]-0.1767766952966368*JfL[12]-0.41079191812887433*JfL[11]+0.2371708245126284*JfL[10]-0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]+0.3061862178478971*JfL[7]-0.1767766952966368*(JfL[6]+JfL[5])-0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]-0.1767766952966368*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])-0.27386127875258304*JfR[46]+0.27386127875258304*JfR[45]+0.15811388300841892*JfR[44]+0.27386127875258304*JfR[43]+0.273861278752583*JfR[42]+0.15811388300841892*JfR[41]-0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]-0.273861278752583*JfR[38]-0.15811388300841892*(JfR[37]+JfR[36])-0.27386127875258304*JfR[35]-0.15811388300841894*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*(JfR[31]+JfR[30])-0.41079191812887433*JfR[29]-0.2371708245126284*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*(JfR[26]+JfR[25])-0.2371708245126284*JfR[24]+0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]+0.3061862178478971*JfR[21]+0.1767766952966368*JfR[20]-0.41079191812887433*JfR[19]+0.41079191812887433*JfR[18]+0.2371708245126284*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.3061862178478971*JfR[14]+0.1767766952966368*JfR[13]-0.1767766952966368*JfR[12]+0.41079191812887433*JfR[11]+0.2371708245126284*JfR[10]-0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]-0.3061862178478971*JfR[7]-0.1767766952966368*(JfR[6]+JfR[5])-0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]-0.1767766952966368*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[12] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsL[23]+speedsL[22]))+0.6123724356957944*speedsL[21]-0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]-0.3535533905932737*speedsL[18]+0.3535533905932737*(speedsL[17]+speedsL[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])-0.3423265984407287*JfL[46]+0.3423265984407287*JfL[45]-0.19764235376052366*JfL[44]+0.3423265984407287*JfL[43]+0.34232659844072866*JfL[42]-0.19764235376052364*JfL[41]+0.19764235376052364*JfL[40]+0.34232659844072866*JfL[39]-0.34232659844072866*JfL[38]+0.19764235376052364*JfL[37]+0.19764235376052366*JfL[36]-0.3423265984407287*JfL[35]+0.19764235376052366*JfL[34]-0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*(JfL[27]+JfL[22])-0.3061862178478971*JfL[21]+0.1767766952966368*JfL[20]-0.3061862178478971*(JfL[16]+JfL[14])+0.1767766952966368*JfL[13]-0.1767766952966368*JfL[12]-0.3061862178478971*JfL[8]+0.3061862178478971*JfL[7]-0.1767766952966368*(JfL[6]+JfL[5])+0.3061862178478971*JfL[3]-0.1767766952966368*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.34232659844072866*JfR[47]+0.3423265984407287*JfR[46]-0.3423265984407287*JfR[45]-0.19764235376052366*JfR[44]-0.3423265984407287*JfR[43]-0.34232659844072866*JfR[42]-0.19764235376052364*JfR[41]+0.19764235376052364*JfR[40]-0.34232659844072866*JfR[39]+0.34232659844072866*JfR[38]+0.19764235376052364*JfR[37]+0.19764235376052366*JfR[36]+0.3423265984407287*JfR[35]+0.19764235376052366*JfR[34]-0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*(JfR[27]+JfR[22])+0.3061862178478971*JfR[21]+0.1767766952966368*JfR[20]+0.3061862178478971*(JfR[16]+JfR[14])+0.1767766952966368*JfR[13]-0.1767766952966368*JfR[12]+0.3061862178478971*JfR[8]-0.3061862178478971*JfR[7]-0.1767766952966368*(JfR[6]+JfR[5])-0.3061862178478971*JfR[3]-0.1767766952966368*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[13] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsL[23]+speedsL[22]))+0.6123724356957944*speedsL[21]-0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]-0.3535533905932737*speedsL[18]+0.3535533905932737*(speedsL[17]+speedsL[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.27386127875258304*JfL[46]-0.27386127875258304*JfL[45]+0.15811388300841892*JfL[44]-0.27386127875258304*JfL[43]-0.273861278752583*JfL[42]+0.15811388300841892*JfL[41]-0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]+0.273861278752583*JfL[38]-0.15811388300841892*(JfL[37]+JfL[36])+0.27386127875258304*JfL[35]-0.15811388300841894*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*(JfL[31]+JfL[30])-0.41079191812887433*JfL[29]+0.2371708245126284*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*(JfL[26]+JfL[25])+0.2371708245126284*JfL[24]-0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]-0.3061862178478971*JfL[21]+0.1767766952966368*JfL[20]-0.41079191812887433*JfL[19]+0.41079191812887433*JfL[18]-0.2371708245126284*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.3061862178478971*JfL[14]+0.1767766952966368*JfL[13]-0.1767766952966368*JfL[12]+0.41079191812887433*JfL[11]-0.2371708245126284*JfL[10]+0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]+0.3061862178478971*JfL[7]-0.1767766952966368*(JfL[6]+JfL[5])+0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]-0.1767766952966368*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])-0.27386127875258304*JfR[46]+0.27386127875258304*JfR[45]+0.15811388300841892*JfR[44]+0.27386127875258304*JfR[43]+0.273861278752583*JfR[42]+0.15811388300841892*JfR[41]-0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]-0.273861278752583*JfR[38]-0.15811388300841892*(JfR[37]+JfR[36])-0.27386127875258304*JfR[35]-0.15811388300841894*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*(JfR[31]+JfR[30])+0.41079191812887433*JfR[29]+0.2371708245126284*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*(JfR[26]+JfR[25])+0.2371708245126284*JfR[24]-0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]+0.3061862178478971*JfR[21]+0.1767766952966368*JfR[20]+0.41079191812887433*JfR[19]-0.41079191812887433*JfR[18]-0.2371708245126284*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.3061862178478971*JfR[14]+0.1767766952966368*JfR[13]-0.1767766952966368*JfR[12]-0.41079191812887433*JfR[11]-0.2371708245126284*JfR[10]+0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]-0.3061862178478971*JfR[7]-0.1767766952966368*(JfR[6]+JfR[5])+0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]-0.1767766952966368*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[14] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsL[23]+speedsL[22]))+0.6123724356957944*speedsL[21]-0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]-0.3535533905932737*speedsL[18]+0.3535533905932737*(speedsL[17]+speedsL[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.27386127875258304*JfL[46]+0.27386127875258304*JfL[45]-0.15811388300841892*JfL[44]-0.27386127875258304*JfL[43]+0.273861278752583*JfL[42]-0.15811388300841892*JfL[41]+0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]+0.273861278752583*JfL[38]-0.15811388300841892*JfL[37]+0.15811388300841892*JfL[36]+0.27386127875258304*JfL[35]-0.15811388300841894*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*(JfL[31]+JfL[30])-0.41079191812887433*JfL[29]+0.2371708245126284*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.41079191812887433*JfL[25]+0.2371708245126284*JfL[24]-0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]+0.3061862178478971*JfL[21]-0.1767766952966368*JfL[20]+0.41079191812887433*JfL[19]-0.41079191812887433*JfL[18]+0.2371708245126284*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.3061862178478971*JfL[14]-0.1767766952966368*JfL[13]+0.1767766952966368*JfL[12]-0.41079191812887433*JfL[11]+0.2371708245126284*JfL[10]-0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]+0.3061862178478971*JfL[7]-0.1767766952966368*JfL[6]+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]-0.1767766952966368*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.273861278752583*JfR[47]+0.27386127875258304*JfR[46]-0.27386127875258304*JfR[45]-0.15811388300841892*JfR[44]+0.27386127875258304*JfR[43]-0.273861278752583*JfR[42]-0.15811388300841892*JfR[41]+0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]-0.273861278752583*JfR[38]-0.15811388300841892*JfR[37]+0.15811388300841892*JfR[36]-0.27386127875258304*JfR[35]-0.15811388300841894*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*(JfR[31]+JfR[30])+0.41079191812887433*JfR[29]+0.2371708245126284*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.41079191812887433*JfR[25]+0.2371708245126284*JfR[24]-0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]-0.3061862178478971*JfR[21]-0.1767766952966368*JfR[20]-0.41079191812887433*JfR[19]+0.41079191812887433*JfR[18]+0.2371708245126284*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.3061862178478971*JfR[14]-0.1767766952966368*JfR[13]+0.1767766952966368*JfR[12]+0.41079191812887433*JfR[11]+0.2371708245126284*JfR[10]-0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]-0.3061862178478971*JfR[7]-0.1767766952966368*JfR[6]+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]-0.1767766952966368*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[15] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsL[23]+speedsL[22]))+0.6123724356957944*speedsL[21]-0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]-0.3535533905932737*speedsL[18]+0.3535533905932737*(speedsL[17]+speedsL[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]+0.3423265984407287*JfL[46]-0.3423265984407287*JfL[45]+0.19764235376052366*JfL[44]+0.3423265984407287*JfL[43]-0.34232659844072866*JfL[42]+0.19764235376052364*JfL[41]-0.19764235376052364*JfL[40]+0.34232659844072866*JfL[39]-0.34232659844072866*JfL[38]+0.19764235376052364*JfL[37]-0.19764235376052366*JfL[36]-0.3423265984407287*JfL[35]+0.19764235376052366*JfL[34]-0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*(JfL[27]+JfL[22])+0.3061862178478971*JfL[21]-0.1767766952966368*JfL[20]-0.3061862178478971*JfL[16]+0.3061862178478971*JfL[14]-0.1767766952966368*JfL[13]+0.1767766952966368*JfL[12]-0.3061862178478971*JfL[8]+0.3061862178478971*JfL[7]-0.1767766952966368*JfL[6]+0.1767766952966368*JfL[5]+0.3061862178478971*JfL[3]-0.1767766952966368*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.34232659844072866*JfR[47])-0.3423265984407287*JfR[46]+0.3423265984407287*JfR[45]+0.19764235376052366*JfR[44]-0.3423265984407287*JfR[43]+0.34232659844072866*JfR[42]+0.19764235376052364*JfR[41]-0.19764235376052364*JfR[40]-0.34232659844072866*JfR[39]+0.34232659844072866*JfR[38]+0.19764235376052364*JfR[37]-0.19764235376052366*JfR[36]+0.3423265984407287*JfR[35]+0.19764235376052366*JfR[34]-0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*(JfR[27]+JfR[22])-0.3061862178478971*JfR[21]-0.1767766952966368*JfR[20]+0.3061862178478971*JfR[16]-0.3061862178478971*JfR[14]-0.1767766952966368*JfR[13]+0.1767766952966368*JfR[12]+0.3061862178478971*JfR[8]-0.3061862178478971*JfR[7]-0.1767766952966368*JfR[6]+0.1767766952966368*JfR[5]-0.3061862178478971*JfR[3]-0.1767766952966368*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[16] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsL[23]+speedsL[22]))+0.6123724356957944*speedsL[21]-0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]-0.3535533905932737*speedsL[18]+0.3535533905932737*(speedsL[17]+speedsL[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.27386127875258304*JfL[46]+0.27386127875258304*JfL[45]-0.15811388300841892*JfL[44]-0.27386127875258304*JfL[43]+0.273861278752583*JfL[42]-0.15811388300841892*JfL[41]+0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]+0.273861278752583*JfL[38]-0.15811388300841892*JfL[37]+0.15811388300841892*JfL[36]+0.27386127875258304*JfL[35]-0.15811388300841894*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*(JfL[31]+JfL[30])+0.41079191812887433*JfL[29]-0.2371708245126284*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.41079191812887433*JfL[25]-0.2371708245126284*JfL[24]+0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]+0.3061862178478971*JfL[21]-0.1767766952966368*JfL[20]-0.41079191812887433*JfL[19]+0.41079191812887433*JfL[18]-0.2371708245126284*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.3061862178478971*JfL[14]-0.1767766952966368*JfL[13]+0.1767766952966368*JfL[12]+0.41079191812887433*JfL[11]-0.2371708245126284*JfL[10]+0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]+0.3061862178478971*JfL[7]-0.1767766952966368*JfL[6]+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]-0.1767766952966368*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.273861278752583*JfR[47]+0.27386127875258304*JfR[46]-0.27386127875258304*JfR[45]-0.15811388300841892*JfR[44]+0.27386127875258304*JfR[43]-0.273861278752583*JfR[42]-0.15811388300841892*JfR[41]+0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]-0.273861278752583*JfR[38]-0.15811388300841892*JfR[37]+0.15811388300841892*JfR[36]-0.27386127875258304*JfR[35]-0.15811388300841894*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*(JfR[31]+JfR[30])-0.41079191812887433*JfR[29]-0.2371708245126284*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.41079191812887433*JfR[25]-0.2371708245126284*JfR[24]+0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]-0.3061862178478971*JfR[21]-0.1767766952966368*JfR[20]+0.41079191812887433*JfR[19]-0.41079191812887433*JfR[18]-0.2371708245126284*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.3061862178478971*JfR[14]-0.1767766952966368*JfR[13]+0.1767766952966368*JfR[12]-0.41079191812887433*JfR[11]-0.2371708245126284*JfR[10]+0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]-0.3061862178478971*JfR[7]-0.1767766952966368*JfR[6]+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]-0.1767766952966368*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[17] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[3].bmag; + Jc_quad = gkdgs[3].Jc; + B3_quad = gkdgs[3].B3; + normcurlbhat_quad = gkdgs[3].normcurlbhat; + bhat_quad[0] = gkdgs[3].bhat.x[0]; + bhat_quad[1] = gkdgs[3].bhat.x[1]; + bhat_quad[2] = gkdgs[3].bhat.x[2]; + area_elem_quad = dgs[3].area_elem; + + + alpha_quad = 0.6123724356957944*(speedsL[23]+speedsL[22]+speedsL[21])+0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]+0.3535533905932737*(speedsL[18]+speedsL[17]+speedsL[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.27386127875258304*(JfL[46]+JfL[45])-0.15811388300841892*JfL[44]+0.27386127875258304*JfL[43]-0.273861278752583*JfL[42]-0.15811388300841892*(JfL[41]+JfL[40])+0.273861278752583*(JfL[39]+JfL[38])+0.15811388300841892*JfL[37]-0.15811388300841892*JfL[36]+0.27386127875258304*JfL[35]+0.15811388300841894*(JfL[34]+JfL[33])+0.15811388300841892*JfL[32]+0.41079191812887433*(JfL[31]+JfL[30]+JfL[29])+0.2371708245126284*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.41079191812887433*JfL[25]+0.2371708245126284*(JfL[24]+JfL[23])-0.3061862178478971*(JfL[22]+JfL[21])-0.1767766952966368*JfL[20]-0.41079191812887433*(JfL[19]+JfL[18])-0.2371708245126284*JfL[17]+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.3061862178478971*JfL[14]-0.1767766952966368*(JfL[13]+JfL[12])-0.41079191812887433*JfL[11]-0.2371708245126284*(JfL[10]+JfL[9])+0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*JfL[6]-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]+0.1767766952966368*(JfL[2]+JfL[1]+JfL[0]); + JfR_quad = 0.273861278752583*JfR[47]+0.27386127875258304*(JfR[46]+JfR[45])-0.15811388300841892*JfR[44]-0.27386127875258304*JfR[43]+0.273861278752583*JfR[42]-0.15811388300841892*(JfR[41]+JfR[40])-0.273861278752583*(JfR[39]+JfR[38])+0.15811388300841892*JfR[37]-0.15811388300841892*JfR[36]-0.27386127875258304*JfR[35]+0.15811388300841894*(JfR[34]+JfR[33])+0.15811388300841892*JfR[32]-0.41079191812887433*(JfR[31]+JfR[30]+JfR[29])+0.2371708245126284*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.41079191812887433*JfR[25]+0.2371708245126284*(JfR[24]+JfR[23])+0.3061862178478971*(JfR[22]+JfR[21])-0.1767766952966368*JfR[20]+0.41079191812887433*(JfR[19]+JfR[18])-0.2371708245126284*JfR[17]-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.3061862178478971*JfR[14]-0.1767766952966368*(JfR[13]+JfR[12])+0.41079191812887433*JfR[11]-0.2371708245126284*(JfR[10]+JfR[9])-0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*JfR[6]-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]+0.1767766952966368*(JfR[2]+JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[18] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsL[23]+speedsL[22]+speedsL[21])+0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]+0.3535533905932737*(speedsL[18]+speedsL[17]+speedsL[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]+0.3423265984407287*(JfL[46]+JfL[45])+0.19764235376052366*JfL[44]-0.3423265984407287*JfL[43]+0.34232659844072866*JfL[42]+0.19764235376052364*(JfL[41]+JfL[40])-0.34232659844072866*(JfL[39]+JfL[38])-0.19764235376052364*JfL[37]+0.19764235376052366*JfL[36]-0.3423265984407287*JfL[35]-0.19764235376052366*(JfL[34]+JfL[33])-0.19764235376052364*JfL[32]-0.3061862178478971*(JfL[27]+JfL[22]+JfL[21])-0.1767766952966368*JfL[20]+0.3061862178478971*JfL[16]-0.3061862178478971*JfL[14]-0.1767766952966368*(JfL[13]+JfL[12])+0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*JfL[6]-0.1767766952966368*JfL[5]+0.3061862178478971*JfL[3]+0.1767766952966368*(JfL[2]+JfL[1]+JfL[0]); + JfR_quad = -(0.34232659844072866*JfR[47])-0.3423265984407287*(JfR[46]+JfR[45])+0.19764235376052366*JfR[44]+0.3423265984407287*JfR[43]-0.34232659844072866*JfR[42]+0.19764235376052364*(JfR[41]+JfR[40])+0.34232659844072866*(JfR[39]+JfR[38])-0.19764235376052364*JfR[37]+0.19764235376052366*JfR[36]+0.3423265984407287*JfR[35]-0.19764235376052366*(JfR[34]+JfR[33])-0.19764235376052364*JfR[32]+0.3061862178478971*(JfR[27]+JfR[22]+JfR[21])-0.1767766952966368*JfR[20]-0.3061862178478971*JfR[16]+0.3061862178478971*JfR[14]-0.1767766952966368*(JfR[13]+JfR[12])-0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*JfR[6]-0.1767766952966368*JfR[5]-0.3061862178478971*JfR[3]+0.1767766952966368*(JfR[2]+JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[19] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsL[23]+speedsL[22]+speedsL[21])+0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]+0.3535533905932737*(speedsL[18]+speedsL[17]+speedsL[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.27386127875258304*(JfL[46]+JfL[45])-0.15811388300841892*JfL[44]+0.27386127875258304*JfL[43]-0.273861278752583*JfL[42]-0.15811388300841892*(JfL[41]+JfL[40])+0.273861278752583*(JfL[39]+JfL[38])+0.15811388300841892*JfL[37]-0.15811388300841892*JfL[36]+0.27386127875258304*JfL[35]+0.15811388300841894*(JfL[34]+JfL[33])+0.15811388300841892*JfL[32]-0.41079191812887433*(JfL[31]+JfL[30]+JfL[29])-0.2371708245126284*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.41079191812887433*JfL[25]-0.2371708245126284*(JfL[24]+JfL[23])-0.3061862178478971*(JfL[22]+JfL[21])-0.1767766952966368*JfL[20]+0.41079191812887433*(JfL[19]+JfL[18])+0.2371708245126284*JfL[17]+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.3061862178478971*JfL[14]-0.1767766952966368*(JfL[13]+JfL[12])+0.41079191812887433*JfL[11]+0.2371708245126284*(JfL[10]+JfL[9])+0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*JfL[6]-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]+0.1767766952966368*(JfL[2]+JfL[1]+JfL[0]); + JfR_quad = 0.273861278752583*JfR[47]+0.27386127875258304*(JfR[46]+JfR[45])-0.15811388300841892*JfR[44]-0.27386127875258304*JfR[43]+0.273861278752583*JfR[42]-0.15811388300841892*(JfR[41]+JfR[40])-0.273861278752583*(JfR[39]+JfR[38])+0.15811388300841892*JfR[37]-0.15811388300841892*JfR[36]-0.27386127875258304*JfR[35]+0.15811388300841894*(JfR[34]+JfR[33])+0.15811388300841892*JfR[32]+0.41079191812887433*(JfR[31]+JfR[30]+JfR[29])-0.2371708245126284*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.41079191812887433*JfR[25]-0.2371708245126284*(JfR[24]+JfR[23])+0.3061862178478971*(JfR[22]+JfR[21])-0.1767766952966368*JfR[20]-0.41079191812887433*(JfR[19]+JfR[18])+0.2371708245126284*JfR[17]-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.3061862178478971*JfR[14]-0.1767766952966368*(JfR[13]+JfR[12])-0.41079191812887433*JfR[11]+0.2371708245126284*(JfR[10]+JfR[9])-0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*JfR[6]-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]+0.1767766952966368*(JfR[2]+JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[20] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsL[23]+speedsL[22]+speedsL[21])+0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]+0.3535533905932737*(speedsL[18]+speedsL[17]+speedsL[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.27386127875258304*(JfL[46]+JfL[45])+0.15811388300841892*JfL[44]+0.27386127875258304*JfL[43]+0.273861278752583*JfL[42]+0.15811388300841892*(JfL[41]+JfL[40])+0.273861278752583*(JfL[39]+JfL[38])+0.15811388300841892*(JfL[37]+JfL[36])+0.27386127875258304*JfL[35]+0.15811388300841894*(JfL[34]+JfL[33])+0.15811388300841892*JfL[32]-0.41079191812887433*(JfL[31]+JfL[30]+JfL[29])-0.2371708245126284*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*(JfL[26]+JfL[25])-0.2371708245126284*(JfL[24]+JfL[23])+0.3061862178478971*(JfL[22]+JfL[21])+0.1767766952966368*JfL[20]-0.41079191812887433*(JfL[19]+JfL[18])-0.2371708245126284*JfL[17]+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.3061862178478971*JfL[14]+0.1767766952966368*(JfL[13]+JfL[12])-0.41079191812887433*JfL[11]-0.2371708245126284*(JfL[10]+JfL[9])+0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*(JfL[6]+JfL[5])-0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]+0.1767766952966368*(JfL[2]+JfL[1]+JfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])-0.27386127875258304*(JfR[46]+JfR[45])+0.15811388300841892*JfR[44]-0.27386127875258304*JfR[43]-0.273861278752583*JfR[42]+0.15811388300841892*(JfR[41]+JfR[40])-0.273861278752583*(JfR[39]+JfR[38])+0.15811388300841892*(JfR[37]+JfR[36])-0.27386127875258304*JfR[35]+0.15811388300841894*(JfR[34]+JfR[33])+0.15811388300841892*JfR[32]+0.41079191812887433*(JfR[31]+JfR[30]+JfR[29])-0.2371708245126284*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*(JfR[26]+JfR[25])-0.2371708245126284*(JfR[24]+JfR[23])-0.3061862178478971*(JfR[22]+JfR[21])+0.1767766952966368*JfR[20]+0.41079191812887433*(JfR[19]+JfR[18])-0.2371708245126284*JfR[17]-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.3061862178478971*JfR[14]+0.1767766952966368*(JfR[13]+JfR[12])+0.41079191812887433*JfR[11]-0.2371708245126284*(JfR[10]+JfR[9])-0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*(JfR[6]+JfR[5])-0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]+0.1767766952966368*(JfR[2]+JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[21] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsL[23]+speedsL[22]+speedsL[21])+0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]+0.3535533905932737*(speedsL[18]+speedsL[17]+speedsL[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])-0.3423265984407287*(JfL[46]+JfL[45])-0.19764235376052366*JfL[44]-0.3423265984407287*JfL[43]-0.34232659844072866*JfL[42]-0.19764235376052364*(JfL[41]+JfL[40])-0.34232659844072866*(JfL[39]+JfL[38])-0.19764235376052364*JfL[37]-0.19764235376052366*JfL[36]-0.3423265984407287*JfL[35]-0.19764235376052366*(JfL[34]+JfL[33])-0.19764235376052364*JfL[32]+0.3061862178478971*(JfL[27]+JfL[22]+JfL[21])+0.1767766952966368*JfL[20]+0.3061862178478971*(JfL[16]+JfL[14])+0.1767766952966368*(JfL[13]+JfL[12])+0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*(JfL[6]+JfL[5])+0.3061862178478971*JfL[3]+0.1767766952966368*(JfL[2]+JfL[1]+JfL[0]); + JfR_quad = 0.34232659844072866*JfR[47]+0.3423265984407287*(JfR[46]+JfR[45])-0.19764235376052366*JfR[44]+0.3423265984407287*JfR[43]+0.34232659844072866*JfR[42]-0.19764235376052364*(JfR[41]+JfR[40])+0.34232659844072866*(JfR[39]+JfR[38])-0.19764235376052364*JfR[37]-0.19764235376052366*JfR[36]+0.3423265984407287*JfR[35]-0.19764235376052366*(JfR[34]+JfR[33])-0.19764235376052364*JfR[32]-0.3061862178478971*(JfR[27]+JfR[22]+JfR[21])+0.1767766952966368*JfR[20]-0.3061862178478971*(JfR[16]+JfR[14])+0.1767766952966368*(JfR[13]+JfR[12])-0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*(JfR[6]+JfR[5])-0.3061862178478971*JfR[3]+0.1767766952966368*(JfR[2]+JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[22] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsL[23]+speedsL[22]+speedsL[21])+0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]+0.3535533905932737*(speedsL[18]+speedsL[17]+speedsL[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.27386127875258304*(JfL[46]+JfL[45])+0.15811388300841892*JfL[44]+0.27386127875258304*JfL[43]+0.273861278752583*JfL[42]+0.15811388300841892*(JfL[41]+JfL[40])+0.273861278752583*(JfL[39]+JfL[38])+0.15811388300841892*(JfL[37]+JfL[36])+0.27386127875258304*JfL[35]+0.15811388300841894*(JfL[34]+JfL[33])+0.15811388300841892*JfL[32]+0.41079191812887433*(JfL[31]+JfL[30]+JfL[29])+0.2371708245126284*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*(JfL[26]+JfL[25])+0.2371708245126284*(JfL[24]+JfL[23])+0.3061862178478971*(JfL[22]+JfL[21])+0.1767766952966368*JfL[20]+0.41079191812887433*(JfL[19]+JfL[18])+0.2371708245126284*JfL[17]+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.3061862178478971*JfL[14]+0.1767766952966368*(JfL[13]+JfL[12])+0.41079191812887433*JfL[11]+0.2371708245126284*(JfL[10]+JfL[9])+0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*(JfL[6]+JfL[5])+0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]+0.1767766952966368*(JfL[2]+JfL[1]+JfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])-0.27386127875258304*(JfR[46]+JfR[45])+0.15811388300841892*JfR[44]-0.27386127875258304*JfR[43]-0.273861278752583*JfR[42]+0.15811388300841892*(JfR[41]+JfR[40])-0.273861278752583*(JfR[39]+JfR[38])+0.15811388300841892*(JfR[37]+JfR[36])-0.27386127875258304*JfR[35]+0.15811388300841894*(JfR[34]+JfR[33])+0.15811388300841892*JfR[32]-0.41079191812887433*(JfR[31]+JfR[30]+JfR[29])+0.2371708245126284*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*(JfR[26]+JfR[25])+0.2371708245126284*(JfR[24]+JfR[23])-0.3061862178478971*(JfR[22]+JfR[21])+0.1767766952966368*JfR[20]-0.41079191812887433*(JfR[19]+JfR[18])+0.2371708245126284*JfR[17]-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.3061862178478971*JfR[14]+0.1767766952966368*(JfR[13]+JfR[12])-0.41079191812887433*JfR[11]+0.2371708245126284*(JfR[10]+JfR[9])-0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*(JfR[6]+JfR[5])+0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]+0.1767766952966368*(JfR[2]+JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[23] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdz2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfx_1x1v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfx_1x1v_ser_p1.c new file mode 100644 index 0000000000..858ec538f9 --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfx_1x1v_ser_p1.c @@ -0,0 +1,84 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_edge_surfx_1x1v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdvpar2 = 2.0/dxv[1]; + + double JRatfR[3] = {0.}; + + double *flux_surf_nodal = &flux_surf[0]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.7745966692414834*JfL[5]+0.4472135954999579*JfL[4]-1.1618950038622249*JfL[3]-0.6708203932499369*JfL[2]+0.8660254037844386*JfL[1]+0.5*JfL[0]; + JfR_quad = 0.0; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.9682458365518543*JfL[5])-0.5590169943749475*JfL[4]+0.8660254037844386*JfL[1]+0.5*JfL[0]; + JfR_quad = 0.0; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.7745966692414834*JfL[5]+0.4472135954999579*JfL[4]+1.1618950038622249*JfL[3]+0.6708203932499369*JfL[2]+0.8660254037844386*JfL[1]+0.5*JfL[0]; + JfR_quad = 0.0; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdx2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfx_1x2v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfx_1x2v_ser_p1.c new file mode 100644 index 0000000000..47cc236214 --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfx_1x2v_ser_p1.c @@ -0,0 +1,111 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_edge_surfx_1x2v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdvpar2 = 2.0/dxv[1]; + + double JRatfR[6] = {0.}; + + double *flux_surf_nodal = &flux_surf[0]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.5477225575051661*JfL[11])-0.3162277660168379*JfL[10]+0.5477225575051661*JfL[9]+0.3162277660168379*JfL[8]+0.8215838362577489*JfL[7]+0.4743416490252568*JfL[6]-0.6123724356957944*JfL[5]-0.8215838362577489*JfL[4]-0.3535533905932737*JfL[3]-0.4743416490252568*JfL[2]+0.6123724356957944*JfL[1]+0.3535533905932737*JfL[0]; + JfR_quad = 0.0; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.6846531968814573*JfL[11]+0.39528470752104733*JfL[10]-0.6846531968814574*JfL[9]-0.3952847075210473*JfL[8]-0.6123724356957944*JfL[5]-0.3535533905932737*JfL[3]+0.6123724356957944*JfL[1]+0.3535533905932737*JfL[0]; + JfR_quad = 0.0; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.5477225575051661*JfL[11])-0.3162277660168379*JfL[10]+0.5477225575051661*JfL[9]+0.3162277660168379*JfL[8]-0.8215838362577489*JfL[7]-0.4743416490252568*JfL[6]-0.6123724356957944*JfL[5]+0.8215838362577489*JfL[4]-0.3535533905932737*JfL[3]+0.4743416490252568*JfL[2]+0.6123724356957944*JfL[1]+0.3535533905932737*JfL[0]; + JfR_quad = 0.0; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.5477225575051661*JfL[11]+0.3162277660168379*JfL[10]+0.5477225575051661*JfL[9]+0.3162277660168379*JfL[8]-0.8215838362577489*JfL[7]-0.4743416490252568*JfL[6]+0.6123724356957944*JfL[5]-0.8215838362577489*JfL[4]+0.3535533905932737*JfL[3]-0.4743416490252568*JfL[2]+0.6123724356957944*JfL[1]+0.3535533905932737*JfL[0]; + JfR_quad = 0.0; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[3] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.6846531968814573*JfL[11])-0.39528470752104733*JfL[10]-0.6846531968814574*JfL[9]-0.3952847075210473*JfL[8]+0.6123724356957944*JfL[5]+0.3535533905932737*JfL[3]+0.6123724356957944*JfL[1]+0.3535533905932737*JfL[0]; + JfR_quad = 0.0; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[4] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.5477225575051661*JfL[11]+0.3162277660168379*JfL[10]+0.5477225575051661*JfL[9]+0.3162277660168379*JfL[8]+0.8215838362577489*JfL[7]+0.4743416490252568*JfL[6]+0.6123724356957944*JfL[5]+0.8215838362577489*JfL[4]+0.3535533905932737*JfL[3]+0.4743416490252568*JfL[2]+0.6123724356957944*JfL[1]+0.3535533905932737*JfL[0]; + JfR_quad = 0.0; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[5] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdx2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfx_2x2v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfx_2x2v_ser_p1.c new file mode 100644 index 0000000000..05bac69424 --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfx_2x2v_ser_p1.c @@ -0,0 +1,188 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_edge_surfx_2x2v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdz2 = 2.0/dxv[1]; + double rdvpar2 = 2.0/dxv[2]; + + double JRatfR[12] = {0.}; + JRatfR[0] = -(0.5*(1.7320508075688772*(jacobgeo_rat_surfR[1]*JfR[5]+jacobgeo_rat_surfR[0]*JfR[1])-1.0*(jacobgeo_rat_surfR[1]*JfR[2]+JfR[0]*jacobgeo_rat_surfR[0]))); + JRatfR[1] = -(0.5*(1.7320508075688772*(jacobgeo_rat_surfR[0]*JfR[5]+JfR[1]*jacobgeo_rat_surfR[1])-1.0*(jacobgeo_rat_surfR[0]*JfR[2]+JfR[0]*jacobgeo_rat_surfR[1]))); + JRatfR[2] = -(0.5*(1.7320508075688772*(jacobgeo_rat_surfR[1]*JfR[11]+jacobgeo_rat_surfR[0]*JfR[6])-1.0*(jacobgeo_rat_surfR[1]*JfR[7]+jacobgeo_rat_surfR[0]*JfR[3]))); + JRatfR[3] = -(0.5*(1.7320508075688772*(jacobgeo_rat_surfR[1]*JfR[12]+jacobgeo_rat_surfR[0]*JfR[8])-1.0*(jacobgeo_rat_surfR[1]*JfR[9]+jacobgeo_rat_surfR[0]*JfR[4]))); + JRatfR[4] = -(0.5*(1.7320508075688772*(jacobgeo_rat_surfR[0]*JfR[11]+jacobgeo_rat_surfR[1]*JfR[6])-1.0*(jacobgeo_rat_surfR[0]*JfR[7]+jacobgeo_rat_surfR[1]*JfR[3]))); + JRatfR[5] = -(0.5*(1.7320508075688772*(jacobgeo_rat_surfR[0]*JfR[12]+jacobgeo_rat_surfR[1]*JfR[8])-1.0*(jacobgeo_rat_surfR[0]*JfR[9]+jacobgeo_rat_surfR[1]*JfR[4]))); + JRatfR[6] = -(0.5*(1.7320508075688772*(jacobgeo_rat_surfR[1]*JfR[15]+jacobgeo_rat_surfR[0]*JfR[13])-1.0*(jacobgeo_rat_surfR[1]*JfR[14]+jacobgeo_rat_surfR[0]*JfR[10]))); + JRatfR[7] = -(0.5*(1.7320508075688772*(jacobgeo_rat_surfR[0]*JfR[15]+jacobgeo_rat_surfR[1]*JfR[13])-1.0*(jacobgeo_rat_surfR[0]*JfR[14]+jacobgeo_rat_surfR[1]*JfR[10]))); + JRatfR[8] = 0.03333333333333333*(-(25.980762113533157*jacobgeo_rat_surfR[1]*JfR[20])+8.660254037844387*(1.7320508075688772*jacobgeo_rat_surfR[1]*JfR[18]-3.0*jacobgeo_rat_surfR[0]*JfR[17])+15.0*jacobgeo_rat_surfR[0]*JfR[16]); + JRatfR[9] = 0.03333333333333333*(8.660254037844387*(1.7320508075688772*jacobgeo_rat_surfR[1]*JfR[16]-3.0*jacobgeo_rat_surfR[0]*JfR[20])+15.0*jacobgeo_rat_surfR[0]*JfR[18]-25.980762113533157*jacobgeo_rat_surfR[1]*JfR[17]); + JRatfR[10] = 0.03333333333333333*(-(25.980762113533157*jacobgeo_rat_surfR[1]*JfR[23])+8.660254037844387*(1.7320508075688772*jacobgeo_rat_surfR[1]*JfR[22]-3.0*jacobgeo_rat_surfR[0]*JfR[21])+15.0*jacobgeo_rat_surfR[0]*JfR[19]); + JRatfR[11] = 0.03333333333333333*(8.660254037844387*(1.7320508075688772*jacobgeo_rat_surfR[1]*JfR[19]-3.0*jacobgeo_rat_surfR[0]*JfR[23])+15.0*jacobgeo_rat_surfR[0]*JfR[22]-25.980762113533157*jacobgeo_rat_surfR[1]*JfR[21]); + + double *flux_surf_nodal = &flux_surf[0]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = -(0.8660254037844386*speedsL[3])-0.5*speedsL[2]+0.8660254037844386*speedsL[1]+0.5*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3872983346207417*JfL[23]+0.22360679774997896*JfL[22]-0.38729833462074165*(JfL[21]+JfL[20])-0.22360679774997894*JfL[19]-0.22360679774997902*JfL[18]+0.3872983346207417*JfL[17]+0.22360679774997896*JfL[16]-0.5809475019311124*JfL[15]-0.33541019662496846*JfL[14]+0.5809475019311124*JfL[13]+0.4330127018922193*JfL[12]+0.5809475019311124*JfL[11]+0.33541019662496846*JfL[10]+0.25*JfL[9]-0.4330127018922193*JfL[8]+0.33541019662496846*JfL[7]-0.5809475019311124*JfL[6]-0.4330127018922193*JfL[5]-0.25*JfL[4]-0.33541019662496846*JfL[3]-0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.3162277660168379*JRatfR[11]-0.31622776601683794*(JRatfR[10]+JRatfR[9])+0.3162277660168379*JRatfR[8]-0.4743416490252568*JRatfR[7]+0.4743416490252568*JRatfR[6]+0.3535533905932737*JRatfR[5]+0.4743416490252568*JRatfR[4]-0.3535533905932737*JRatfR[3]-0.4743416490252568*JRatfR[2]-0.3535533905932737*JRatfR[1]+0.3535533905932737*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsL[3])-0.5*speedsL[2]+0.8660254037844386*speedsL[1]+0.5*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.4841229182759271*JfL[23])-0.2795084971874737*JfL[22]+0.4841229182759271*(JfL[21]+JfL[20])+0.2795084971874738*(JfL[19]+JfL[18])-0.4841229182759271*JfL[17]-0.2795084971874737*JfL[16]+0.4330127018922193*JfL[12]+0.25*JfL[9]-0.4330127018922193*(JfL[8]+JfL[5])-0.25*(JfL[4]+JfL[2])+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.3952847075210473*JRatfR[11])+0.39528470752104733*(JRatfR[10]+JRatfR[9])-0.3952847075210473*JRatfR[8]+0.3535533905932737*JRatfR[5]-0.3535533905932737*(JRatfR[3]+JRatfR[1])+0.3535533905932737*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsL[3])-0.5*speedsL[2]+0.8660254037844386*speedsL[1]+0.5*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3872983346207417*JfL[23]+0.22360679774997896*JfL[22]-0.38729833462074165*(JfL[21]+JfL[20])-0.22360679774997894*JfL[19]-0.22360679774997902*JfL[18]+0.3872983346207417*JfL[17]+0.22360679774997896*JfL[16]+0.5809475019311124*JfL[15]+0.33541019662496846*JfL[14]-0.5809475019311124*JfL[13]+0.4330127018922193*JfL[12]-0.5809475019311124*JfL[11]-0.33541019662496846*JfL[10]+0.25*JfL[9]-0.4330127018922193*JfL[8]-0.33541019662496846*JfL[7]+0.5809475019311124*JfL[6]-0.4330127018922193*JfL[5]-0.25*JfL[4]+0.33541019662496846*JfL[3]-0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.3162277660168379*JRatfR[11]-0.31622776601683794*(JRatfR[10]+JRatfR[9])+0.3162277660168379*JRatfR[8]+0.4743416490252568*JRatfR[7]-0.4743416490252568*JRatfR[6]+0.3535533905932737*JRatfR[5]-0.4743416490252568*JRatfR[4]-0.3535533905932737*JRatfR[3]+0.4743416490252568*JRatfR[2]-0.3535533905932737*JRatfR[1]+0.3535533905932737*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsL[3])-0.5*speedsL[2]+0.8660254037844386*speedsL[1]+0.5*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3872983346207417*JfL[23])-0.22360679774997896*JfL[22]+0.38729833462074165*JfL[21]-0.38729833462074165*JfL[20]+0.22360679774997894*JfL[19]-0.22360679774997902*JfL[18]+0.3872983346207417*JfL[17]+0.22360679774997896*JfL[16]+0.5809475019311124*JfL[15]+0.33541019662496846*JfL[14]-0.5809475019311124*JfL[13]-0.4330127018922193*JfL[12]+0.5809475019311124*JfL[11]-0.33541019662496846*JfL[10]-0.25*JfL[9]+0.4330127018922193*JfL[8]+0.33541019662496846*JfL[7]-0.5809475019311124*JfL[6]-0.4330127018922193*JfL[5]+0.25*JfL[4]-0.33541019662496846*JfL[3]-0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.3162277660168379*JRatfR[11])+0.31622776601683794*JRatfR[10]-0.31622776601683794*JRatfR[9]+0.3162277660168379*JRatfR[8]+0.4743416490252568*JRatfR[7]-0.4743416490252568*JRatfR[6]-0.3535533905932737*JRatfR[5]+0.4743416490252568*JRatfR[4]+0.3535533905932737*JRatfR[3]-0.4743416490252568*JRatfR[2]-0.3535533905932737*JRatfR[1]+0.3535533905932737*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[3] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsL[3])-0.5*speedsL[2]+0.8660254037844386*speedsL[1]+0.5*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.4841229182759271*JfL[23]+0.2795084971874737*JfL[22]-0.4841229182759271*JfL[21]+0.4841229182759271*JfL[20]-0.2795084971874738*JfL[19]+0.2795084971874738*JfL[18]-0.4841229182759271*JfL[17]-0.2795084971874737*JfL[16]-0.4330127018922193*JfL[12]-0.25*JfL[9]+0.4330127018922193*JfL[8]-0.4330127018922193*JfL[5]+0.25*JfL[4]-0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.3952847075210473*JRatfR[11]-0.39528470752104733*JRatfR[10]+0.39528470752104733*JRatfR[9]-0.3952847075210473*JRatfR[8]-0.3535533905932737*JRatfR[5]+0.3535533905932737*JRatfR[3]-0.3535533905932737*JRatfR[1]+0.3535533905932737*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[4] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsL[3])-0.5*speedsL[2]+0.8660254037844386*speedsL[1]+0.5*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3872983346207417*JfL[23])-0.22360679774997896*JfL[22]+0.38729833462074165*JfL[21]-0.38729833462074165*JfL[20]+0.22360679774997894*JfL[19]-0.22360679774997902*JfL[18]+0.3872983346207417*JfL[17]+0.22360679774997896*JfL[16]-0.5809475019311124*JfL[15]-0.33541019662496846*JfL[14]+0.5809475019311124*JfL[13]-0.4330127018922193*JfL[12]-0.5809475019311124*JfL[11]+0.33541019662496846*JfL[10]-0.25*JfL[9]+0.4330127018922193*JfL[8]-0.33541019662496846*JfL[7]+0.5809475019311124*JfL[6]-0.4330127018922193*JfL[5]+0.25*JfL[4]+0.33541019662496846*JfL[3]-0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.3162277660168379*JRatfR[11])+0.31622776601683794*JRatfR[10]-0.31622776601683794*JRatfR[9]+0.3162277660168379*JRatfR[8]-0.4743416490252568*JRatfR[7]+0.4743416490252568*JRatfR[6]-0.3535533905932737*JRatfR[5]-0.4743416490252568*JRatfR[4]+0.3535533905932737*JRatfR[3]+0.4743416490252568*JRatfR[2]-0.3535533905932737*JRatfR[1]+0.3535533905932737*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[5] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[1].bmag; + Jc_quad = gkdgs[1].Jc; + B3_quad = gkdgs[1].B3; + normcurlbhat_quad = gkdgs[1].normcurlbhat; + bhat_quad[0] = gkdgs[1].bhat.x[0]; + bhat_quad[1] = gkdgs[1].bhat.x[1]; + bhat_quad[2] = gkdgs[1].bhat.x[2]; + area_elem_quad = dgs[1].area_elem; + + + alpha_quad = 0.8660254037844386*speedsL[3]+0.5*speedsL[2]+0.8660254037844386*speedsL[1]+0.5*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3872983346207417*JfL[23])-0.22360679774997896*JfL[22]-0.38729833462074165*JfL[21]+0.38729833462074165*JfL[20]-0.22360679774997894*JfL[19]+0.22360679774997902*JfL[18]+0.3872983346207417*JfL[17]+0.22360679774997896*JfL[16]+0.5809475019311124*JfL[15]+0.33541019662496846*JfL[14]+0.5809475019311124*JfL[13]-0.4330127018922193*JfL[12]-0.5809475019311124*JfL[11]+0.33541019662496846*JfL[10]-0.25*JfL[9]-0.4330127018922193*JfL[8]-0.33541019662496846*JfL[7]-0.5809475019311124*JfL[6]+0.4330127018922193*JfL[5]-0.25*JfL[4]-0.33541019662496846*JfL[3]+0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.3162277660168379*JRatfR[11])-0.31622776601683794*JRatfR[10]+0.31622776601683794*JRatfR[9]+0.3162277660168379*JRatfR[8]+0.4743416490252568*(JRatfR[7]+JRatfR[6])-0.3535533905932737*JRatfR[5]-0.4743416490252568*JRatfR[4]-0.3535533905932737*JRatfR[3]-0.4743416490252568*JRatfR[2]+0.3535533905932737*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[6] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsL[3]+0.5*speedsL[2]+0.8660254037844386*speedsL[1]+0.5*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.4841229182759271*JfL[23]+0.2795084971874737*JfL[22]+0.4841229182759271*JfL[21]-0.4841229182759271*JfL[20]+0.2795084971874738*JfL[19]-0.2795084971874738*JfL[18]-0.4841229182759271*JfL[17]-0.2795084971874737*JfL[16]-0.4330127018922193*JfL[12]-0.25*JfL[9]-0.4330127018922193*JfL[8]+0.4330127018922193*JfL[5]-0.25*JfL[4]+0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.3952847075210473*JRatfR[11]+0.39528470752104733*JRatfR[10]-0.39528470752104733*JRatfR[9]-0.3952847075210473*JRatfR[8]-0.3535533905932737*(JRatfR[5]+JRatfR[3])+0.3535533905932737*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[7] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsL[3]+0.5*speedsL[2]+0.8660254037844386*speedsL[1]+0.5*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3872983346207417*JfL[23])-0.22360679774997896*JfL[22]-0.38729833462074165*JfL[21]+0.38729833462074165*JfL[20]-0.22360679774997894*JfL[19]+0.22360679774997902*JfL[18]+0.3872983346207417*JfL[17]+0.22360679774997896*JfL[16]-0.5809475019311124*JfL[15]-0.33541019662496846*JfL[14]-0.5809475019311124*JfL[13]-0.4330127018922193*JfL[12]+0.5809475019311124*JfL[11]-0.33541019662496846*JfL[10]-0.25*JfL[9]-0.4330127018922193*JfL[8]+0.33541019662496846*JfL[7]+0.5809475019311124*JfL[6]+0.4330127018922193*JfL[5]-0.25*JfL[4]+0.33541019662496846*JfL[3]+0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.3162277660168379*JRatfR[11])-0.31622776601683794*JRatfR[10]+0.31622776601683794*JRatfR[9]+0.3162277660168379*JRatfR[8]-0.4743416490252568*(JRatfR[7]+JRatfR[6])-0.3535533905932737*JRatfR[5]+0.4743416490252568*JRatfR[4]-0.3535533905932737*JRatfR[3]+0.4743416490252568*JRatfR[2]+0.3535533905932737*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[8] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsL[3]+0.5*speedsL[2]+0.8660254037844386*speedsL[1]+0.5*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3872983346207417*JfL[23]+0.22360679774997896*JfL[22]+0.38729833462074165*(JfL[21]+JfL[20])+0.22360679774997894*JfL[19]+0.22360679774997902*JfL[18]+0.3872983346207417*JfL[17]+0.22360679774997896*JfL[16]-0.5809475019311124*JfL[15]-0.33541019662496846*JfL[14]-0.5809475019311124*JfL[13]+0.4330127018922193*JfL[12]-0.5809475019311124*JfL[11]-0.33541019662496846*JfL[10]+0.25*JfL[9]+0.4330127018922193*JfL[8]-0.33541019662496846*JfL[7]-0.5809475019311124*JfL[6]+0.4330127018922193*JfL[5]+0.25*JfL[4]-0.33541019662496846*JfL[3]+0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.3162277660168379*JRatfR[11]+0.31622776601683794*(JRatfR[10]+JRatfR[9])+0.3162277660168379*JRatfR[8]-0.4743416490252568*(JRatfR[7]+JRatfR[6])+0.3535533905932737*JRatfR[5]-0.4743416490252568*JRatfR[4]+0.3535533905932737*JRatfR[3]-0.4743416490252568*JRatfR[2]+0.3535533905932737*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[9] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsL[3]+0.5*speedsL[2]+0.8660254037844386*speedsL[1]+0.5*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.4841229182759271*JfL[23])-0.2795084971874737*JfL[22]-0.4841229182759271*(JfL[21]+JfL[20])-0.2795084971874738*(JfL[19]+JfL[18])-0.4841229182759271*JfL[17]-0.2795084971874737*JfL[16]+0.4330127018922193*JfL[12]+0.25*JfL[9]+0.4330127018922193*(JfL[8]+JfL[5])+0.25*(JfL[4]+JfL[2])+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.3952847075210473*JRatfR[11])-0.39528470752104733*(JRatfR[10]+JRatfR[9])-0.3952847075210473*JRatfR[8]+0.3535533905932737*(JRatfR[5]+JRatfR[3]+JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[10] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsL[3]+0.5*speedsL[2]+0.8660254037844386*speedsL[1]+0.5*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3872983346207417*JfL[23]+0.22360679774997896*JfL[22]+0.38729833462074165*(JfL[21]+JfL[20])+0.22360679774997894*JfL[19]+0.22360679774997902*JfL[18]+0.3872983346207417*JfL[17]+0.22360679774997896*JfL[16]+0.5809475019311124*JfL[15]+0.33541019662496846*JfL[14]+0.5809475019311124*JfL[13]+0.4330127018922193*JfL[12]+0.5809475019311124*JfL[11]+0.33541019662496846*JfL[10]+0.25*JfL[9]+0.4330127018922193*JfL[8]+0.33541019662496846*JfL[7]+0.5809475019311124*JfL[6]+0.4330127018922193*JfL[5]+0.25*JfL[4]+0.33541019662496846*JfL[3]+0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.3162277660168379*JRatfR[11]+0.31622776601683794*(JRatfR[10]+JRatfR[9])+0.3162277660168379*JRatfR[8]+0.4743416490252568*(JRatfR[7]+JRatfR[6])+0.3535533905932737*JRatfR[5]+0.4743416490252568*JRatfR[4]+0.3535533905932737*JRatfR[3]+0.4743416490252568*JRatfR[2]+0.3535533905932737*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[11] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdx2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfx_3x2v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfx_3x2v_ser_p1.c new file mode 100644 index 0000000000..25efb362e3 --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfx_3x2v_ser_p1.c @@ -0,0 +1,329 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_edge_surfx_3x2v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdy2 = 2.0/dxv[1]; + double rdz2 = 2.0/dxv[2]; + double rdvpar2 = 2.0/dxv[3]; + + double JRatfR[24] = {0.}; + JRatfR[0] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[3]*JfR[16]+jacobgeo_rat_surfR[2]*JfR[7]+jacobgeo_rat_surfR[1]*JfR[6]+jacobgeo_rat_surfR[0]*JfR[1])-1.4142135623730951*(jacobgeo_rat_surfR[3]*JfR[8]+jacobgeo_rat_surfR[2]*JfR[3]+jacobgeo_rat_surfR[1]*JfR[2]+JfR[0]*jacobgeo_rat_surfR[0]))); + JRatfR[1] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[2]*JfR[16]+jacobgeo_rat_surfR[3]*JfR[7]+jacobgeo_rat_surfR[0]*JfR[6]+JfR[1]*jacobgeo_rat_surfR[1])-1.4142135623730951*(jacobgeo_rat_surfR[2]*JfR[8]+JfR[3]*jacobgeo_rat_surfR[3]+jacobgeo_rat_surfR[0]*JfR[2]+JfR[0]*jacobgeo_rat_surfR[1]))); + JRatfR[2] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[1]*JfR[16]+jacobgeo_rat_surfR[0]*JfR[7]+jacobgeo_rat_surfR[3]*JfR[6]+JfR[1]*jacobgeo_rat_surfR[2])-1.4142135623730951*(jacobgeo_rat_surfR[1]*JfR[8]+JfR[2]*jacobgeo_rat_surfR[3]+jacobgeo_rat_surfR[0]*JfR[3]+JfR[0]*jacobgeo_rat_surfR[2]))); + JRatfR[3] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[3]*JfR[26]+jacobgeo_rat_surfR[2]*JfR[18]+jacobgeo_rat_surfR[1]*JfR[17]+jacobgeo_rat_surfR[0]*JfR[9])-1.4142135623730951*(jacobgeo_rat_surfR[3]*JfR[19]+jacobgeo_rat_surfR[2]*JfR[11]+jacobgeo_rat_surfR[1]*JfR[10]+jacobgeo_rat_surfR[0]*JfR[4]))); + JRatfR[4] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[3]*JfR[27]+jacobgeo_rat_surfR[2]*JfR[21]+jacobgeo_rat_surfR[1]*JfR[20]+jacobgeo_rat_surfR[0]*JfR[12])-1.4142135623730951*(jacobgeo_rat_surfR[3]*JfR[22]+jacobgeo_rat_surfR[2]*JfR[14]+jacobgeo_rat_surfR[1]*JfR[13]+jacobgeo_rat_surfR[0]*JfR[5]))); + JRatfR[5] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[0]*JfR[16]+jacobgeo_rat_surfR[1]*JfR[7]+jacobgeo_rat_surfR[2]*JfR[6]+JfR[1]*jacobgeo_rat_surfR[3])-1.4142135623730951*(jacobgeo_rat_surfR[0]*JfR[8]+JfR[0]*jacobgeo_rat_surfR[3]+jacobgeo_rat_surfR[1]*JfR[3]+JfR[2]*jacobgeo_rat_surfR[2]))); + JRatfR[6] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[2]*JfR[26]+jacobgeo_rat_surfR[3]*JfR[18]+jacobgeo_rat_surfR[0]*JfR[17]+jacobgeo_rat_surfR[1]*JfR[9])-1.4142135623730951*(jacobgeo_rat_surfR[2]*JfR[19]+jacobgeo_rat_surfR[3]*JfR[11]+jacobgeo_rat_surfR[0]*JfR[10]+jacobgeo_rat_surfR[1]*JfR[4]))); + JRatfR[7] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[1]*JfR[26]+jacobgeo_rat_surfR[0]*JfR[18]+jacobgeo_rat_surfR[3]*JfR[17]+jacobgeo_rat_surfR[2]*JfR[9])-1.4142135623730951*(jacobgeo_rat_surfR[1]*JfR[19]+jacobgeo_rat_surfR[0]*JfR[11]+jacobgeo_rat_surfR[3]*JfR[10]+jacobgeo_rat_surfR[2]*JfR[4]))); + JRatfR[8] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[2]*JfR[27]+jacobgeo_rat_surfR[3]*JfR[21]+jacobgeo_rat_surfR[0]*JfR[20]+jacobgeo_rat_surfR[1]*JfR[12])-1.4142135623730951*(jacobgeo_rat_surfR[2]*JfR[22]+jacobgeo_rat_surfR[3]*JfR[14]+jacobgeo_rat_surfR[0]*JfR[13]+jacobgeo_rat_surfR[1]*JfR[5]))); + JRatfR[9] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[1]*JfR[27]+jacobgeo_rat_surfR[0]*JfR[21]+jacobgeo_rat_surfR[3]*JfR[20]+jacobgeo_rat_surfR[2]*JfR[12])-1.4142135623730951*(jacobgeo_rat_surfR[1]*JfR[22]+jacobgeo_rat_surfR[0]*JfR[14]+jacobgeo_rat_surfR[3]*JfR[13]+jacobgeo_rat_surfR[2]*JfR[5]))); + JRatfR[10] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[3]*JfR[31]+jacobgeo_rat_surfR[2]*JfR[29]+jacobgeo_rat_surfR[1]*JfR[28]+jacobgeo_rat_surfR[0]*JfR[23])-1.4142135623730951*(jacobgeo_rat_surfR[3]*JfR[30]+jacobgeo_rat_surfR[2]*JfR[25]+jacobgeo_rat_surfR[1]*JfR[24]+jacobgeo_rat_surfR[0]*JfR[15]))); + JRatfR[11] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[0]*JfR[26]+jacobgeo_rat_surfR[1]*JfR[18]+jacobgeo_rat_surfR[2]*JfR[17]+jacobgeo_rat_surfR[3]*JfR[9])-1.4142135623730951*(jacobgeo_rat_surfR[0]*JfR[19]+jacobgeo_rat_surfR[1]*JfR[11]+jacobgeo_rat_surfR[2]*JfR[10]+jacobgeo_rat_surfR[3]*JfR[4]))); + JRatfR[12] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[0]*JfR[27]+jacobgeo_rat_surfR[1]*JfR[21]+jacobgeo_rat_surfR[2]*JfR[20]+jacobgeo_rat_surfR[3]*JfR[12])-1.4142135623730951*(jacobgeo_rat_surfR[0]*JfR[22]+jacobgeo_rat_surfR[1]*JfR[14]+jacobgeo_rat_surfR[2]*JfR[13]+jacobgeo_rat_surfR[3]*JfR[5]))); + JRatfR[13] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[2]*JfR[31]+jacobgeo_rat_surfR[3]*JfR[29]+jacobgeo_rat_surfR[0]*JfR[28]+jacobgeo_rat_surfR[1]*JfR[23])-1.4142135623730951*(jacobgeo_rat_surfR[2]*JfR[30]+jacobgeo_rat_surfR[3]*JfR[25]+jacobgeo_rat_surfR[0]*JfR[24]+jacobgeo_rat_surfR[1]*JfR[15]))); + JRatfR[14] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[1]*JfR[31]+jacobgeo_rat_surfR[0]*JfR[29]+jacobgeo_rat_surfR[3]*JfR[28]+jacobgeo_rat_surfR[2]*JfR[23])-1.4142135623730951*(jacobgeo_rat_surfR[1]*JfR[30]+jacobgeo_rat_surfR[0]*JfR[25]+jacobgeo_rat_surfR[3]*JfR[24]+jacobgeo_rat_surfR[2]*JfR[15]))); + JRatfR[15] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[0]*JfR[31]+jacobgeo_rat_surfR[1]*JfR[29]+jacobgeo_rat_surfR[2]*JfR[28]+jacobgeo_rat_surfR[3]*JfR[23])-1.4142135623730951*(jacobgeo_rat_surfR[0]*JfR[30]+jacobgeo_rat_surfR[1]*JfR[25]+jacobgeo_rat_surfR[2]*JfR[24]+jacobgeo_rat_surfR[3]*JfR[15]))); + JRatfR[16] = 0.016666666666666666*(8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfR[2]*JfR[35]+jacobgeo_rat_surfR[1]*JfR[34])-4.242640687119286*(jacobgeo_rat_surfR[3]*JfR[43]+jacobgeo_rat_surfR[0]*JfR[33]))+21.213203435596427*(jacobgeo_rat_surfR[3]*JfR[39]+jacobgeo_rat_surfR[0]*JfR[32])-36.742346141747674*(jacobgeo_rat_surfR[2]*JfR[38]+jacobgeo_rat_surfR[1]*JfR[37])); + JRatfR[17] = 0.016666666666666666*(-(36.742346141747674*(jacobgeo_rat_surfR[2]*JfR[43]+jacobgeo_rat_surfR[1]*JfR[33]))+8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfR[2]*JfR[39]+jacobgeo_rat_surfR[1]*JfR[32])-4.242640687119286*(jacobgeo_rat_surfR[3]*JfR[38]+jacobgeo_rat_surfR[0]*JfR[37]))+21.213203435596427*(jacobgeo_rat_surfR[3]*JfR[35]+jacobgeo_rat_surfR[0]*JfR[34])); + JRatfR[18] = 0.016666666666666666*(-(36.742346141747674*(jacobgeo_rat_surfR[1]*JfR[43]+jacobgeo_rat_surfR[2]*JfR[33]))+8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfR[1]*JfR[39]+jacobgeo_rat_surfR[2]*JfR[32])-4.242640687119286*(jacobgeo_rat_surfR[0]*JfR[38]+jacobgeo_rat_surfR[3]*JfR[37]))+21.213203435596427*(jacobgeo_rat_surfR[0]*JfR[35]+jacobgeo_rat_surfR[3]*JfR[34])); + JRatfR[19] = 0.016666666666666666*(8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfR[2]*JfR[42]+jacobgeo_rat_surfR[1]*JfR[41])-4.242640687119286*(jacobgeo_rat_surfR[3]*JfR[47]+jacobgeo_rat_surfR[0]*JfR[40]))+21.213203435596427*(jacobgeo_rat_surfR[3]*JfR[46]+jacobgeo_rat_surfR[0]*JfR[36])-36.742346141747674*(jacobgeo_rat_surfR[2]*JfR[45]+jacobgeo_rat_surfR[1]*JfR[44])); + JRatfR[20] = 0.016666666666666666*(8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfR[1]*JfR[35]+jacobgeo_rat_surfR[2]*JfR[34])-4.242640687119286*(jacobgeo_rat_surfR[0]*JfR[43]+jacobgeo_rat_surfR[3]*JfR[33]))+21.213203435596427*(jacobgeo_rat_surfR[0]*JfR[39]+jacobgeo_rat_surfR[3]*JfR[32])-36.742346141747674*(jacobgeo_rat_surfR[1]*JfR[38]+jacobgeo_rat_surfR[2]*JfR[37])); + JRatfR[21] = 0.016666666666666666*(-(36.742346141747674*(jacobgeo_rat_surfR[2]*JfR[47]+jacobgeo_rat_surfR[1]*JfR[40]))+8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfR[2]*JfR[46]+jacobgeo_rat_surfR[1]*JfR[36])-4.242640687119286*(jacobgeo_rat_surfR[3]*JfR[45]+jacobgeo_rat_surfR[0]*JfR[44]))+21.213203435596427*(jacobgeo_rat_surfR[3]*JfR[42]+jacobgeo_rat_surfR[0]*JfR[41])); + JRatfR[22] = 0.016666666666666666*(-(36.742346141747674*(jacobgeo_rat_surfR[1]*JfR[47]+jacobgeo_rat_surfR[2]*JfR[40]))+8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfR[1]*JfR[46]+jacobgeo_rat_surfR[2]*JfR[36])-4.242640687119286*(jacobgeo_rat_surfR[0]*JfR[45]+jacobgeo_rat_surfR[3]*JfR[44]))+21.213203435596427*(jacobgeo_rat_surfR[0]*JfR[42]+jacobgeo_rat_surfR[3]*JfR[41])); + JRatfR[23] = 0.016666666666666666*(8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfR[1]*JfR[42]+jacobgeo_rat_surfR[2]*JfR[41])-4.242640687119286*(jacobgeo_rat_surfR[0]*JfR[47]+jacobgeo_rat_surfR[3]*JfR[40]))+21.213203435596427*(jacobgeo_rat_surfR[0]*JfR[46]+jacobgeo_rat_surfR[3]*JfR[36])-36.742346141747674*(jacobgeo_rat_surfR[1]*JfR[45]+jacobgeo_rat_surfR[2]*JfR[44])); + + double *flux_surf_nodal = &flux_surf[0]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = 0.6123724356957944*speedsL[7]+0.3535533905932737*speedsL[6]-0.6123724356957944*(speedsL[5]+speedsL[4])-0.3535533905932737*(speedsL[3]+speedsL[2])+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.15811388300841892*JfL[46]+0.27386127875258304*(JfL[45]+JfL[44]+JfL[43])+0.15811388300841892*(JfL[42]+JfL[41])-0.273861278752583*JfL[40]+0.15811388300841892*JfL[39]-0.273861278752583*(JfL[38]+JfL[37])-0.15811388300841892*JfL[36]-0.15811388300841894*(JfL[35]+JfL[34])+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]+0.2371708245126284*JfL[30]-0.41079191812887433*(JfL[29]+JfL[28])-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]-0.2371708245126284*(JfL[25]+JfL[24])+0.41079191812887433*JfL[23]-0.1767766952966368*JfL[22]+0.3061862178478971*(JfL[21]+JfL[20])-0.2371708245126284*JfL[19]+0.41079191812887433*(JfL[18]+JfL[17])+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.1767766952966368*(JfL[14]+JfL[13])-0.3061862178478971*JfL[12]+0.2371708245126284*(JfL[11]+JfL[10])-0.41079191812887433*JfL[9]+0.1767766952966368*JfL[8]-0.3061862178478971*(JfL[7]+JfL[6])-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]-0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.22360679774997894*JRatfR[23])+0.22360679774997896*(JRatfR[22]+JRatfR[21]+JRatfR[20])-0.22360679774997894*JRatfR[19]-0.22360679774997902*(JRatfR[18]+JRatfR[17])+0.22360679774997896*JRatfR[16]+0.33541019662496846*JRatfR[15]-0.33541019662496846*(JRatfR[14]+JRatfR[13])-0.25*JRatfR[12]-0.33541019662496846*JRatfR[11]+0.33541019662496846*JRatfR[10]+0.25*(JRatfR[9]+JRatfR[8])+0.33541019662496846*(JRatfR[7]+JRatfR[6])+0.25*JRatfR[5]-0.25*JRatfR[4]-0.33541019662496846*JRatfR[3]-0.25*(JRatfR[2]+JRatfR[1])+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[7]+0.3535533905932737*speedsL[6]-0.6123724356957944*(speedsL[5]+speedsL[4])-0.3535533905932737*(speedsL[3]+speedsL[2])+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]+0.19764235376052366*JfL[46]-0.3423265984407287*(JfL[45]+JfL[44]+JfL[43])-0.19764235376052364*(JfL[42]+JfL[41])+0.34232659844072866*JfL[40]-0.19764235376052364*JfL[39]+0.34232659844072866*(JfL[38]+JfL[37])+0.19764235376052366*(JfL[36]+JfL[35]+JfL[34])-0.3423265984407287*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*JfL[27]-0.1767766952966368*JfL[22]+0.3061862178478971*(JfL[21]+JfL[20]+JfL[16])+0.1767766952966368*(JfL[14]+JfL[13])-0.3061862178478971*JfL[12]+0.1767766952966368*JfL[8]-0.3061862178478971*(JfL[7]+JfL[6])-0.1767766952966368*(JfL[5]+JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.2795084971874738*JRatfR[23]-0.2795084971874737*(JRatfR[22]+JRatfR[21]+JRatfR[20])+0.2795084971874738*(JRatfR[19]+JRatfR[18]+JRatfR[17])-0.2795084971874737*JRatfR[16]-0.25*JRatfR[12]+0.25*(JRatfR[9]+JRatfR[8]+JRatfR[5])-0.25*(JRatfR[4]+JRatfR[2]+JRatfR[1])+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[7]+0.3535533905932737*speedsL[6]-0.6123724356957944*(speedsL[5]+speedsL[4])-0.3535533905932737*(speedsL[3]+speedsL[2])+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.15811388300841892*JfL[46]+0.27386127875258304*(JfL[45]+JfL[44]+JfL[43])+0.15811388300841892*(JfL[42]+JfL[41])-0.273861278752583*JfL[40]+0.15811388300841892*JfL[39]-0.273861278752583*(JfL[38]+JfL[37])-0.15811388300841892*JfL[36]-0.15811388300841894*(JfL[35]+JfL[34])+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]-0.2371708245126284*JfL[30]+0.41079191812887433*(JfL[29]+JfL[28])-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]+0.2371708245126284*(JfL[25]+JfL[24])-0.41079191812887433*JfL[23]-0.1767766952966368*JfL[22]+0.3061862178478971*(JfL[21]+JfL[20])+0.2371708245126284*JfL[19]-0.41079191812887433*(JfL[18]+JfL[17])+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.1767766952966368*(JfL[14]+JfL[13])-0.3061862178478971*JfL[12]-0.2371708245126284*(JfL[11]+JfL[10])+0.41079191812887433*JfL[9]+0.1767766952966368*JfL[8]-0.3061862178478971*(JfL[7]+JfL[6])-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]-0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.22360679774997894*JRatfR[23])+0.22360679774997896*(JRatfR[22]+JRatfR[21]+JRatfR[20])-0.22360679774997894*JRatfR[19]-0.22360679774997902*(JRatfR[18]+JRatfR[17])+0.22360679774997896*JRatfR[16]-0.33541019662496846*JRatfR[15]+0.33541019662496846*(JRatfR[14]+JRatfR[13])-0.25*JRatfR[12]+0.33541019662496846*JRatfR[11]-0.33541019662496846*JRatfR[10]+0.25*(JRatfR[9]+JRatfR[8])-0.33541019662496846*(JRatfR[7]+JRatfR[6])+0.25*JRatfR[5]-0.25*JRatfR[4]+0.33541019662496846*JRatfR[3]-0.25*(JRatfR[2]+JRatfR[1])+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[7]+0.3535533905932737*speedsL[6]-0.6123724356957944*(speedsL[5]+speedsL[4])-0.3535533905932737*(speedsL[3]+speedsL[2])+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.15811388300841892*JfL[46]-0.27386127875258304*(JfL[45]+JfL[44])+0.27386127875258304*JfL[43]-0.15811388300841892*(JfL[42]+JfL[41])+0.273861278752583*JfL[40]+0.15811388300841892*JfL[39]-0.273861278752583*(JfL[38]+JfL[37])+0.15811388300841892*JfL[36]-0.15811388300841894*(JfL[35]+JfL[34])+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]-0.2371708245126284*JfL[30]+0.41079191812887433*(JfL[29]+JfL[28])+0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.2371708245126284*(JfL[25]+JfL[24])-0.41079191812887433*JfL[23]+0.1767766952966368*JfL[22]-0.3061862178478971*(JfL[21]+JfL[20])-0.2371708245126284*JfL[19]+0.41079191812887433*(JfL[18]+JfL[17])+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.1767766952966368*(JfL[14]+JfL[13])+0.3061862178478971*JfL[12]+0.2371708245126284*(JfL[11]+JfL[10])-0.41079191812887433*JfL[9]+0.1767766952966368*JfL[8]-0.3061862178478971*(JfL[7]+JfL[6])+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]-0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.22360679774997894*JRatfR[23]-0.22360679774997896*(JRatfR[22]+JRatfR[21])+0.22360679774997896*JRatfR[20]+0.22360679774997894*JRatfR[19]-0.22360679774997902*(JRatfR[18]+JRatfR[17])+0.22360679774997896*JRatfR[16]-0.33541019662496846*JRatfR[15]+0.33541019662496846*(JRatfR[14]+JRatfR[13])+0.25*JRatfR[12]-0.33541019662496846*(JRatfR[11]+JRatfR[10])-0.25*(JRatfR[9]+JRatfR[8])+0.33541019662496846*(JRatfR[7]+JRatfR[6])+0.25*(JRatfR[5]+JRatfR[4])-0.33541019662496846*JRatfR[3]-0.25*(JRatfR[2]+JRatfR[1])+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[3] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[7]+0.3535533905932737*speedsL[6]-0.6123724356957944*(speedsL[5]+speedsL[4])-0.3535533905932737*(speedsL[3]+speedsL[2])+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])-0.19764235376052366*JfL[46]+0.3423265984407287*(JfL[45]+JfL[44])-0.3423265984407287*JfL[43]+0.19764235376052364*(JfL[42]+JfL[41])-0.34232659844072866*JfL[40]-0.19764235376052364*JfL[39]+0.34232659844072866*(JfL[38]+JfL[37])-0.19764235376052366*JfL[36]+0.19764235376052366*(JfL[35]+JfL[34])-0.3423265984407287*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*JfL[27]+0.1767766952966368*JfL[22]-0.3061862178478971*(JfL[21]+JfL[20])+0.3061862178478971*JfL[16]-0.1767766952966368*(JfL[14]+JfL[13])+0.3061862178478971*JfL[12]+0.1767766952966368*JfL[8]-0.3061862178478971*(JfL[7]+JfL[6])+0.1767766952966368*JfL[5]-0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.2795084971874738*JRatfR[23])+0.2795084971874737*(JRatfR[22]+JRatfR[21])-0.2795084971874737*JRatfR[20]-0.2795084971874738*JRatfR[19]+0.2795084971874738*(JRatfR[18]+JRatfR[17])-0.2795084971874737*JRatfR[16]+0.25*JRatfR[12]-0.25*(JRatfR[9]+JRatfR[8])+0.25*(JRatfR[5]+JRatfR[4])-0.25*(JRatfR[2]+JRatfR[1])+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[4] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[7]+0.3535533905932737*speedsL[6]-0.6123724356957944*(speedsL[5]+speedsL[4])-0.3535533905932737*(speedsL[3]+speedsL[2])+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.15811388300841892*JfL[46]-0.27386127875258304*(JfL[45]+JfL[44])+0.27386127875258304*JfL[43]-0.15811388300841892*(JfL[42]+JfL[41])+0.273861278752583*JfL[40]+0.15811388300841892*JfL[39]-0.273861278752583*(JfL[38]+JfL[37])+0.15811388300841892*JfL[36]-0.15811388300841894*(JfL[35]+JfL[34])+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]+0.2371708245126284*JfL[30]-0.41079191812887433*(JfL[29]+JfL[28])+0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.2371708245126284*(JfL[25]+JfL[24])+0.41079191812887433*JfL[23]+0.1767766952966368*JfL[22]-0.3061862178478971*(JfL[21]+JfL[20])+0.2371708245126284*JfL[19]-0.41079191812887433*(JfL[18]+JfL[17])+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.1767766952966368*(JfL[14]+JfL[13])+0.3061862178478971*JfL[12]-0.2371708245126284*(JfL[11]+JfL[10])+0.41079191812887433*JfL[9]+0.1767766952966368*JfL[8]-0.3061862178478971*(JfL[7]+JfL[6])+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]-0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.22360679774997894*JRatfR[23]-0.22360679774997896*(JRatfR[22]+JRatfR[21])+0.22360679774997896*JRatfR[20]+0.22360679774997894*JRatfR[19]-0.22360679774997902*(JRatfR[18]+JRatfR[17])+0.22360679774997896*JRatfR[16]+0.33541019662496846*JRatfR[15]-0.33541019662496846*(JRatfR[14]+JRatfR[13])+0.25*JRatfR[12]+0.33541019662496846*(JRatfR[11]+JRatfR[10])-0.25*(JRatfR[9]+JRatfR[8])-0.33541019662496846*(JRatfR[7]+JRatfR[6])+0.25*(JRatfR[5]+JRatfR[4])+0.33541019662496846*JRatfR[3]-0.25*(JRatfR[2]+JRatfR[1])+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[5] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[1].bmag; + Jc_quad = gkdgs[1].Jc; + B3_quad = gkdgs[1].B3; + normcurlbhat_quad = gkdgs[1].normcurlbhat; + bhat_quad[0] = gkdgs[1].bhat.x[0]; + bhat_quad[1] = gkdgs[1].bhat.x[1]; + bhat_quad[2] = gkdgs[1].bhat.x[2]; + area_elem_quad = dgs[1].area_elem; + + + alpha_quad = -(0.6123724356957944*speedsL[7])-0.3535533905932737*speedsL[6]+0.6123724356957944*speedsL[5]-0.6123724356957944*speedsL[4]+0.3535533905932737*speedsL[3]-0.3535533905932737*speedsL[2]+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.15811388300841892*JfL[46]-0.27386127875258304*JfL[45]+0.27386127875258304*JfL[44]-0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]+0.15811388300841892*JfL[41]-0.273861278752583*JfL[40]-0.15811388300841892*JfL[39]+0.273861278752583*JfL[38]-0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]-0.15811388300841894*JfL[34]+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]-0.2371708245126284*JfL[30]+0.41079191812887433*JfL[29]-0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]-0.2371708245126284*JfL[24]+0.41079191812887433*JfL[23]+0.1767766952966368*JfL[22]-0.3061862178478971*JfL[21]+0.3061862178478971*JfL[20]+0.2371708245126284*JfL[19]-0.41079191812887433*JfL[18]+0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]+0.1767766952966368*JfL[13]-0.3061862178478971*JfL[12]-0.2371708245126284*JfL[11]+0.2371708245126284*JfL[10]-0.41079191812887433*JfL[9]-0.1767766952966368*JfL[8]+0.3061862178478971*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]-0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.22360679774997894*JRatfR[23]-0.22360679774997896*JRatfR[22]+0.22360679774997896*JRatfR[21]-0.22360679774997896*JRatfR[20]-0.22360679774997894*JRatfR[19]+0.22360679774997902*JRatfR[18]-0.22360679774997902*JRatfR[17]+0.22360679774997896*JRatfR[16]-0.33541019662496846*JRatfR[15]+0.33541019662496846*JRatfR[14]-0.33541019662496846*JRatfR[13]+0.25*JRatfR[12]+0.33541019662496846*(JRatfR[11]+JRatfR[10])-0.25*JRatfR[9]+0.25*JRatfR[8]-0.33541019662496846*JRatfR[7]+0.33541019662496846*JRatfR[6]-0.25*(JRatfR[5]+JRatfR[4])-0.33541019662496846*JRatfR[3]+0.25*JRatfR[2]-0.25*JRatfR[1]+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[6] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[7])-0.3535533905932737*speedsL[6]+0.6123724356957944*speedsL[5]-0.6123724356957944*speedsL[4]+0.3535533905932737*speedsL[3]-0.3535533905932737*speedsL[2]+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])-0.19764235376052366*JfL[46]+0.3423265984407287*JfL[45]-0.3423265984407287*JfL[44]+0.3423265984407287*JfL[43]+0.19764235376052364*JfL[42]-0.19764235376052364*JfL[41]+0.34232659844072866*JfL[40]+0.19764235376052364*JfL[39]-0.34232659844072866*JfL[38]+0.34232659844072866*JfL[37]+0.19764235376052366*JfL[36]-0.19764235376052366*JfL[35]+0.19764235376052366*JfL[34]-0.3423265984407287*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*JfL[27]+0.1767766952966368*JfL[22]-0.3061862178478971*JfL[21]+0.3061862178478971*JfL[20]-0.3061862178478971*JfL[16]-0.1767766952966368*JfL[14]+0.1767766952966368*JfL[13]-0.3061862178478971*JfL[12]-0.1767766952966368*JfL[8]+0.3061862178478971*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.1767766952966368*JfL[3]-0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.2795084971874738*JRatfR[23])+0.2795084971874737*JRatfR[22]-0.2795084971874737*JRatfR[21]+0.2795084971874737*JRatfR[20]+0.2795084971874738*JRatfR[19]-0.2795084971874738*JRatfR[18]+0.2795084971874738*JRatfR[17]-0.2795084971874737*JRatfR[16]+0.25*JRatfR[12]-0.25*JRatfR[9]+0.25*JRatfR[8]-0.25*(JRatfR[5]+JRatfR[4])+0.25*JRatfR[2]-0.25*JRatfR[1]+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[7] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[7])-0.3535533905932737*speedsL[6]+0.6123724356957944*speedsL[5]-0.6123724356957944*speedsL[4]+0.3535533905932737*speedsL[3]-0.3535533905932737*speedsL[2]+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.15811388300841892*JfL[46]-0.27386127875258304*JfL[45]+0.27386127875258304*JfL[44]-0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]+0.15811388300841892*JfL[41]-0.273861278752583*JfL[40]-0.15811388300841892*JfL[39]+0.273861278752583*JfL[38]-0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]-0.15811388300841894*JfL[34]+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]+0.2371708245126284*JfL[30]-0.41079191812887433*JfL[29]+0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]+0.2371708245126284*JfL[24]-0.41079191812887433*JfL[23]+0.1767766952966368*JfL[22]-0.3061862178478971*JfL[21]+0.3061862178478971*JfL[20]-0.2371708245126284*JfL[19]+0.41079191812887433*JfL[18]-0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]+0.1767766952966368*JfL[13]-0.3061862178478971*JfL[12]+0.2371708245126284*JfL[11]-0.2371708245126284*JfL[10]+0.41079191812887433*JfL[9]-0.1767766952966368*JfL[8]+0.3061862178478971*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]-0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.22360679774997894*JRatfR[23]-0.22360679774997896*JRatfR[22]+0.22360679774997896*JRatfR[21]-0.22360679774997896*JRatfR[20]-0.22360679774997894*JRatfR[19]+0.22360679774997902*JRatfR[18]-0.22360679774997902*JRatfR[17]+0.22360679774997896*JRatfR[16]+0.33541019662496846*JRatfR[15]-0.33541019662496846*JRatfR[14]+0.33541019662496846*JRatfR[13]+0.25*JRatfR[12]-0.33541019662496846*(JRatfR[11]+JRatfR[10])-0.25*JRatfR[9]+0.25*JRatfR[8]+0.33541019662496846*JRatfR[7]-0.33541019662496846*JRatfR[6]-0.25*(JRatfR[5]+JRatfR[4])+0.33541019662496846*JRatfR[3]+0.25*JRatfR[2]-0.25*JRatfR[1]+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[8] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[7])-0.3535533905932737*speedsL[6]+0.6123724356957944*speedsL[5]-0.6123724356957944*speedsL[4]+0.3535533905932737*speedsL[3]-0.3535533905932737*speedsL[2]+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.15811388300841892*JfL[46]+0.27386127875258304*JfL[45]-0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]-0.15811388300841892*JfL[41]+0.273861278752583*JfL[40]-0.15811388300841892*JfL[39]+0.273861278752583*JfL[38]-0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]-0.15811388300841894*JfL[34]+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]+0.2371708245126284*JfL[30]-0.41079191812887433*JfL[29]+0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]+0.2371708245126284*JfL[24]-0.41079191812887433*JfL[23]-0.1767766952966368*JfL[22]+0.3061862178478971*JfL[21]-0.3061862178478971*JfL[20]+0.2371708245126284*JfL[19]-0.41079191812887433*JfL[18]+0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]-0.1767766952966368*JfL[13]+0.3061862178478971*JfL[12]-0.2371708245126284*JfL[11]+0.2371708245126284*JfL[10]-0.41079191812887433*JfL[9]-0.1767766952966368*JfL[8]+0.3061862178478971*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]-0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.22360679774997894*JRatfR[23])+0.22360679774997896*JRatfR[22]-0.22360679774997896*(JRatfR[21]+JRatfR[20])+0.22360679774997894*JRatfR[19]+0.22360679774997902*JRatfR[18]-0.22360679774997902*JRatfR[17]+0.22360679774997896*JRatfR[16]+0.33541019662496846*JRatfR[15]-0.33541019662496846*JRatfR[14]+0.33541019662496846*JRatfR[13]-0.25*JRatfR[12]+0.33541019662496846*JRatfR[11]-0.33541019662496846*JRatfR[10]+0.25*JRatfR[9]-0.25*JRatfR[8]-0.33541019662496846*JRatfR[7]+0.33541019662496846*JRatfR[6]-0.25*JRatfR[5]+0.25*JRatfR[4]-0.33541019662496846*JRatfR[3]+0.25*JRatfR[2]-0.25*JRatfR[1]+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[9] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[7])-0.3535533905932737*speedsL[6]+0.6123724356957944*speedsL[5]-0.6123724356957944*speedsL[4]+0.3535533905932737*speedsL[3]-0.3535533905932737*speedsL[2]+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]+0.19764235376052366*JfL[46]-0.3423265984407287*JfL[45]+0.3423265984407287*(JfL[44]+JfL[43])-0.19764235376052364*JfL[42]+0.19764235376052364*JfL[41]-0.34232659844072866*JfL[40]+0.19764235376052364*JfL[39]-0.34232659844072866*JfL[38]+0.34232659844072866*JfL[37]-0.19764235376052366*(JfL[36]+JfL[35])+0.19764235376052366*JfL[34]-0.3423265984407287*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*JfL[27]-0.1767766952966368*JfL[22]+0.3061862178478971*JfL[21]-0.3061862178478971*(JfL[20]+JfL[16])+0.1767766952966368*JfL[14]-0.1767766952966368*JfL[13]+0.3061862178478971*JfL[12]-0.1767766952966368*JfL[8]+0.3061862178478971*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*(JfL[5]+JfL[3])-0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.2795084971874738*JRatfR[23]-0.2795084971874737*JRatfR[22]+0.2795084971874737*(JRatfR[21]+JRatfR[20])-0.2795084971874738*(JRatfR[19]+JRatfR[18])+0.2795084971874738*JRatfR[17]-0.2795084971874737*JRatfR[16]-0.25*JRatfR[12]+0.25*JRatfR[9]-0.25*(JRatfR[8]+JRatfR[5])+0.25*(JRatfR[4]+JRatfR[2])-0.25*JRatfR[1]+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[10] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[7])-0.3535533905932737*speedsL[6]+0.6123724356957944*speedsL[5]-0.6123724356957944*speedsL[4]+0.3535533905932737*speedsL[3]-0.3535533905932737*speedsL[2]+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.15811388300841892*JfL[46]+0.27386127875258304*JfL[45]-0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]-0.15811388300841892*JfL[41]+0.273861278752583*JfL[40]-0.15811388300841892*JfL[39]+0.273861278752583*JfL[38]-0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]-0.15811388300841894*JfL[34]+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]-0.2371708245126284*JfL[30]+0.41079191812887433*JfL[29]-0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]-0.2371708245126284*JfL[24]+0.41079191812887433*JfL[23]-0.1767766952966368*JfL[22]+0.3061862178478971*JfL[21]-0.3061862178478971*JfL[20]-0.2371708245126284*JfL[19]+0.41079191812887433*JfL[18]-0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]-0.1767766952966368*JfL[13]+0.3061862178478971*JfL[12]+0.2371708245126284*JfL[11]-0.2371708245126284*JfL[10]+0.41079191812887433*JfL[9]-0.1767766952966368*JfL[8]+0.3061862178478971*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]-0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.22360679774997894*JRatfR[23])+0.22360679774997896*JRatfR[22]-0.22360679774997896*(JRatfR[21]+JRatfR[20])+0.22360679774997894*JRatfR[19]+0.22360679774997902*JRatfR[18]-0.22360679774997902*JRatfR[17]+0.22360679774997896*JRatfR[16]-0.33541019662496846*JRatfR[15]+0.33541019662496846*JRatfR[14]-0.33541019662496846*JRatfR[13]-0.25*JRatfR[12]-0.33541019662496846*JRatfR[11]+0.33541019662496846*JRatfR[10]+0.25*JRatfR[9]-0.25*JRatfR[8]+0.33541019662496846*JRatfR[7]-0.33541019662496846*JRatfR[6]-0.25*JRatfR[5]+0.25*JRatfR[4]+0.33541019662496846*JRatfR[3]+0.25*JRatfR[2]-0.25*JRatfR[1]+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[11] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[2].bmag; + Jc_quad = gkdgs[2].Jc; + B3_quad = gkdgs[2].B3; + normcurlbhat_quad = gkdgs[2].normcurlbhat; + bhat_quad[0] = gkdgs[2].bhat.x[0]; + bhat_quad[1] = gkdgs[2].bhat.x[1]; + bhat_quad[2] = gkdgs[2].bhat.x[2]; + area_elem_quad = dgs[2].area_elem; + + + alpha_quad = -(0.6123724356957944*speedsL[7])-0.3535533905932737*speedsL[6]-0.6123724356957944*speedsL[5]+0.6123724356957944*speedsL[4]-0.3535533905932737*speedsL[3]+0.3535533905932737*speedsL[2]+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.15811388300841892*JfL[46]+0.27386127875258304*JfL[45]-0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]-0.15811388300841892*JfL[41]-0.273861278752583*JfL[40]-0.15811388300841892*JfL[39]-0.273861278752583*JfL[38]+0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.15811388300841894*JfL[34]+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]-0.2371708245126284*JfL[30]-0.41079191812887433*JfL[29]+0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]+0.2371708245126284*JfL[24]+0.41079191812887433*JfL[23]+0.1767766952966368*JfL[22]+0.3061862178478971*JfL[21]-0.3061862178478971*JfL[20]+0.2371708245126284*JfL[19]+0.41079191812887433*JfL[18]-0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]-0.1767766952966368*JfL[13]-0.3061862178478971*JfL[12]+0.2371708245126284*JfL[11]-0.2371708245126284*JfL[10]-0.41079191812887433*JfL[9]-0.1767766952966368*JfL[8]-0.3061862178478971*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.22360679774997894*JRatfR[23]+0.22360679774997896*JRatfR[22]-0.22360679774997896*(JRatfR[21]+JRatfR[20])-0.22360679774997894*JRatfR[19]-0.22360679774997902*JRatfR[18]+0.22360679774997902*JRatfR[17]+0.22360679774997896*JRatfR[16]-0.33541019662496846*(JRatfR[15]+JRatfR[14])+0.33541019662496846*JRatfR[13]+0.25*JRatfR[12]+0.33541019662496846*(JRatfR[11]+JRatfR[10])+0.25*JRatfR[9]-0.25*JRatfR[8]+0.33541019662496846*JRatfR[7]-0.33541019662496846*JRatfR[6]-0.25*(JRatfR[5]+JRatfR[4])-0.33541019662496846*JRatfR[3]-0.25*JRatfR[2]+0.25*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[12] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[7])-0.3535533905932737*speedsL[6]-0.6123724356957944*speedsL[5]+0.6123724356957944*speedsL[4]-0.3535533905932737*speedsL[3]+0.3535533905932737*speedsL[2]+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])-0.19764235376052366*JfL[46]-0.3423265984407287*JfL[45]+0.3423265984407287*(JfL[44]+JfL[43])-0.19764235376052364*JfL[42]+0.19764235376052364*JfL[41]+0.34232659844072866*JfL[40]+0.19764235376052364*JfL[39]+0.34232659844072866*JfL[38]-0.34232659844072866*JfL[37]+0.19764235376052366*(JfL[36]+JfL[35])-0.19764235376052366*JfL[34]-0.3423265984407287*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*JfL[27]+0.1767766952966368*JfL[22]+0.3061862178478971*JfL[21]-0.3061862178478971*(JfL[20]+JfL[16])+0.1767766952966368*JfL[14]-0.1767766952966368*JfL[13]-0.3061862178478971*JfL[12]-0.1767766952966368*JfL[8]-0.3061862178478971*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*(JfL[5]+JfL[3])+0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.2795084971874738*JRatfR[23])-0.2795084971874737*JRatfR[22]+0.2795084971874737*(JRatfR[21]+JRatfR[20])+0.2795084971874738*(JRatfR[19]+JRatfR[18])-0.2795084971874738*JRatfR[17]-0.2795084971874737*JRatfR[16]+0.25*(JRatfR[12]+JRatfR[9])-0.25*(JRatfR[8]+JRatfR[5]+JRatfR[4]+JRatfR[2])+0.25*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[13] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[7])-0.3535533905932737*speedsL[6]-0.6123724356957944*speedsL[5]+0.6123724356957944*speedsL[4]-0.3535533905932737*speedsL[3]+0.3535533905932737*speedsL[2]+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.15811388300841892*JfL[46]+0.27386127875258304*JfL[45]-0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]-0.15811388300841892*JfL[41]-0.273861278752583*JfL[40]-0.15811388300841892*JfL[39]-0.273861278752583*JfL[38]+0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.15811388300841894*JfL[34]+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]+0.2371708245126284*JfL[30]+0.41079191812887433*JfL[29]-0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]-0.2371708245126284*JfL[24]-0.41079191812887433*JfL[23]+0.1767766952966368*JfL[22]+0.3061862178478971*JfL[21]-0.3061862178478971*JfL[20]-0.2371708245126284*JfL[19]-0.41079191812887433*JfL[18]+0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]-0.1767766952966368*JfL[13]-0.3061862178478971*JfL[12]-0.2371708245126284*JfL[11]+0.2371708245126284*JfL[10]+0.41079191812887433*JfL[9]-0.1767766952966368*JfL[8]-0.3061862178478971*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.22360679774997894*JRatfR[23]+0.22360679774997896*JRatfR[22]-0.22360679774997896*(JRatfR[21]+JRatfR[20])-0.22360679774997894*JRatfR[19]-0.22360679774997902*JRatfR[18]+0.22360679774997902*JRatfR[17]+0.22360679774997896*JRatfR[16]+0.33541019662496846*(JRatfR[15]+JRatfR[14])-0.33541019662496846*JRatfR[13]+0.25*JRatfR[12]-0.33541019662496846*(JRatfR[11]+JRatfR[10])+0.25*JRatfR[9]-0.25*JRatfR[8]-0.33541019662496846*JRatfR[7]+0.33541019662496846*JRatfR[6]-0.25*(JRatfR[5]+JRatfR[4])+0.33541019662496846*JRatfR[3]-0.25*JRatfR[2]+0.25*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[14] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[7])-0.3535533905932737*speedsL[6]-0.6123724356957944*speedsL[5]+0.6123724356957944*speedsL[4]-0.3535533905932737*speedsL[3]+0.3535533905932737*speedsL[2]+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.15811388300841892*JfL[46]-0.27386127875258304*JfL[45]+0.27386127875258304*JfL[44]-0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]+0.15811388300841892*JfL[41]+0.273861278752583*JfL[40]-0.15811388300841892*JfL[39]-0.273861278752583*JfL[38]+0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.15811388300841894*JfL[34]+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]+0.2371708245126284*JfL[30]+0.41079191812887433*JfL[29]-0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]-0.2371708245126284*JfL[24]-0.41079191812887433*JfL[23]-0.1767766952966368*JfL[22]-0.3061862178478971*JfL[21]+0.3061862178478971*JfL[20]+0.2371708245126284*JfL[19]+0.41079191812887433*JfL[18]-0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]+0.1767766952966368*JfL[13]+0.3061862178478971*JfL[12]+0.2371708245126284*JfL[11]-0.2371708245126284*JfL[10]-0.41079191812887433*JfL[9]-0.1767766952966368*JfL[8]-0.3061862178478971*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.22360679774997894*JRatfR[23])-0.22360679774997896*JRatfR[22]+0.22360679774997896*JRatfR[21]-0.22360679774997896*JRatfR[20]+0.22360679774997894*JRatfR[19]-0.22360679774997902*JRatfR[18]+0.22360679774997902*JRatfR[17]+0.22360679774997896*JRatfR[16]+0.33541019662496846*(JRatfR[15]+JRatfR[14])-0.33541019662496846*JRatfR[13]-0.25*JRatfR[12]+0.33541019662496846*JRatfR[11]-0.33541019662496846*JRatfR[10]-0.25*JRatfR[9]+0.25*JRatfR[8]+0.33541019662496846*JRatfR[7]-0.33541019662496846*JRatfR[6]-0.25*JRatfR[5]+0.25*JRatfR[4]-0.33541019662496846*JRatfR[3]-0.25*JRatfR[2]+0.25*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[15] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[7])-0.3535533905932737*speedsL[6]-0.6123724356957944*speedsL[5]+0.6123724356957944*speedsL[4]-0.3535533905932737*speedsL[3]+0.3535533905932737*speedsL[2]+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]+0.19764235376052366*JfL[46]+0.3423265984407287*JfL[45]-0.3423265984407287*JfL[44]+0.3423265984407287*JfL[43]+0.19764235376052364*JfL[42]-0.19764235376052364*JfL[41]-0.34232659844072866*JfL[40]+0.19764235376052364*JfL[39]+0.34232659844072866*JfL[38]-0.34232659844072866*JfL[37]-0.19764235376052366*JfL[36]+0.19764235376052366*JfL[35]-0.19764235376052366*JfL[34]-0.3423265984407287*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*JfL[27]-0.1767766952966368*JfL[22]-0.3061862178478971*JfL[21]+0.3061862178478971*JfL[20]-0.3061862178478971*JfL[16]-0.1767766952966368*JfL[14]+0.1767766952966368*JfL[13]+0.3061862178478971*JfL[12]-0.1767766952966368*JfL[8]-0.3061862178478971*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.1767766952966368*JfL[3]+0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.2795084971874738*JRatfR[23]+0.2795084971874737*JRatfR[22]-0.2795084971874737*JRatfR[21]+0.2795084971874737*JRatfR[20]-0.2795084971874738*JRatfR[19]+0.2795084971874738*JRatfR[18]-0.2795084971874738*JRatfR[17]-0.2795084971874737*JRatfR[16]-0.25*(JRatfR[12]+JRatfR[9])+0.25*JRatfR[8]-0.25*JRatfR[5]+0.25*JRatfR[4]-0.25*JRatfR[2]+0.25*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[16] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[7])-0.3535533905932737*speedsL[6]-0.6123724356957944*speedsL[5]+0.6123724356957944*speedsL[4]-0.3535533905932737*speedsL[3]+0.3535533905932737*speedsL[2]+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.15811388300841892*JfL[46]-0.27386127875258304*JfL[45]+0.27386127875258304*JfL[44]-0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]+0.15811388300841892*JfL[41]+0.273861278752583*JfL[40]-0.15811388300841892*JfL[39]-0.273861278752583*JfL[38]+0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.15811388300841894*JfL[34]+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]-0.2371708245126284*JfL[30]-0.41079191812887433*JfL[29]+0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]+0.2371708245126284*JfL[24]+0.41079191812887433*JfL[23]-0.1767766952966368*JfL[22]-0.3061862178478971*JfL[21]+0.3061862178478971*JfL[20]-0.2371708245126284*JfL[19]-0.41079191812887433*JfL[18]+0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]+0.1767766952966368*JfL[13]+0.3061862178478971*JfL[12]-0.2371708245126284*JfL[11]+0.2371708245126284*JfL[10]+0.41079191812887433*JfL[9]-0.1767766952966368*JfL[8]-0.3061862178478971*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.22360679774997894*JRatfR[23])-0.22360679774997896*JRatfR[22]+0.22360679774997896*JRatfR[21]-0.22360679774997896*JRatfR[20]+0.22360679774997894*JRatfR[19]-0.22360679774997902*JRatfR[18]+0.22360679774997902*JRatfR[17]+0.22360679774997896*JRatfR[16]-0.33541019662496846*(JRatfR[15]+JRatfR[14])+0.33541019662496846*JRatfR[13]-0.25*JRatfR[12]-0.33541019662496846*JRatfR[11]+0.33541019662496846*JRatfR[10]-0.25*JRatfR[9]+0.25*JRatfR[8]-0.33541019662496846*JRatfR[7]+0.33541019662496846*JRatfR[6]-0.25*JRatfR[5]+0.25*JRatfR[4]+0.33541019662496846*JRatfR[3]-0.25*JRatfR[2]+0.25*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[17] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[3].bmag; + Jc_quad = gkdgs[3].Jc; + B3_quad = gkdgs[3].B3; + normcurlbhat_quad = gkdgs[3].normcurlbhat; + bhat_quad[0] = gkdgs[3].bhat.x[0]; + bhat_quad[1] = gkdgs[3].bhat.x[1]; + bhat_quad[2] = gkdgs[3].bhat.x[2]; + area_elem_quad = dgs[3].area_elem; + + + alpha_quad = 0.6123724356957944*speedsL[7]+0.3535533905932737*speedsL[6]+0.6123724356957944*(speedsL[5]+speedsL[4])+0.3535533905932737*(speedsL[3]+speedsL[2])+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.15811388300841892*JfL[46]-0.27386127875258304*(JfL[45]+JfL[44])+0.27386127875258304*JfL[43]-0.15811388300841892*(JfL[42]+JfL[41])-0.273861278752583*JfL[40]+0.15811388300841892*JfL[39]+0.273861278752583*(JfL[38]+JfL[37])-0.15811388300841892*JfL[36]+0.15811388300841894*(JfL[35]+JfL[34])+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]+0.2371708245126284*JfL[30]+0.41079191812887433*(JfL[29]+JfL[28])-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.2371708245126284*(JfL[25]+JfL[24])+0.41079191812887433*JfL[23]-0.1767766952966368*JfL[22]-0.3061862178478971*(JfL[21]+JfL[20])-0.2371708245126284*JfL[19]-0.41079191812887433*(JfL[18]+JfL[17])+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.1767766952966368*(JfL[14]+JfL[13])-0.3061862178478971*JfL[12]-0.2371708245126284*(JfL[11]+JfL[10])-0.41079191812887433*JfL[9]+0.1767766952966368*JfL[8]+0.3061862178478971*(JfL[7]+JfL[6])-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.22360679774997894*JRatfR[23])-0.22360679774997896*(JRatfR[22]+JRatfR[21])+0.22360679774997896*JRatfR[20]-0.22360679774997894*JRatfR[19]+0.22360679774997902*(JRatfR[18]+JRatfR[17])+0.22360679774997896*JRatfR[16]+0.33541019662496846*(JRatfR[15]+JRatfR[14]+JRatfR[13])-0.25*JRatfR[12]-0.33541019662496846*JRatfR[11]+0.33541019662496846*JRatfR[10]-0.25*(JRatfR[9]+JRatfR[8])-0.33541019662496846*(JRatfR[7]+JRatfR[6])+0.25*JRatfR[5]-0.25*JRatfR[4]-0.33541019662496846*JRatfR[3]+0.25*(JRatfR[2]+JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[18] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[7]+0.3535533905932737*speedsL[6]+0.6123724356957944*(speedsL[5]+speedsL[4])+0.3535533905932737*(speedsL[3]+speedsL[2])+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]+0.19764235376052366*JfL[46]+0.3423265984407287*(JfL[45]+JfL[44])-0.3423265984407287*JfL[43]+0.19764235376052364*(JfL[42]+JfL[41])+0.34232659844072866*JfL[40]-0.19764235376052364*JfL[39]-0.34232659844072866*(JfL[38]+JfL[37])+0.19764235376052366*JfL[36]-0.19764235376052366*(JfL[35]+JfL[34])-0.3423265984407287*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*JfL[27]-0.1767766952966368*JfL[22]-0.3061862178478971*(JfL[21]+JfL[20])+0.3061862178478971*JfL[16]-0.1767766952966368*(JfL[14]+JfL[13])-0.3061862178478971*JfL[12]+0.1767766952966368*JfL[8]+0.3061862178478971*(JfL[7]+JfL[6])-0.1767766952966368*JfL[5]+0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.2795084971874738*JRatfR[23]+0.2795084971874737*(JRatfR[22]+JRatfR[21])-0.2795084971874737*JRatfR[20]+0.2795084971874738*JRatfR[19]-0.2795084971874738*(JRatfR[18]+JRatfR[17])-0.2795084971874737*JRatfR[16]-0.25*(JRatfR[12]+JRatfR[9]+JRatfR[8])+0.25*JRatfR[5]-0.25*JRatfR[4]+0.25*(JRatfR[2]+JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[19] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[7]+0.3535533905932737*speedsL[6]+0.6123724356957944*(speedsL[5]+speedsL[4])+0.3535533905932737*(speedsL[3]+speedsL[2])+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.15811388300841892*JfL[46]-0.27386127875258304*(JfL[45]+JfL[44])+0.27386127875258304*JfL[43]-0.15811388300841892*(JfL[42]+JfL[41])-0.273861278752583*JfL[40]+0.15811388300841892*JfL[39]+0.273861278752583*(JfL[38]+JfL[37])-0.15811388300841892*JfL[36]+0.15811388300841894*(JfL[35]+JfL[34])+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]-0.2371708245126284*JfL[30]-0.41079191812887433*(JfL[29]+JfL[28])-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.2371708245126284*(JfL[25]+JfL[24])-0.41079191812887433*JfL[23]-0.1767766952966368*JfL[22]-0.3061862178478971*(JfL[21]+JfL[20])+0.2371708245126284*JfL[19]+0.41079191812887433*(JfL[18]+JfL[17])+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.1767766952966368*(JfL[14]+JfL[13])-0.3061862178478971*JfL[12]+0.2371708245126284*(JfL[11]+JfL[10])+0.41079191812887433*JfL[9]+0.1767766952966368*JfL[8]+0.3061862178478971*(JfL[7]+JfL[6])-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.22360679774997894*JRatfR[23])-0.22360679774997896*(JRatfR[22]+JRatfR[21])+0.22360679774997896*JRatfR[20]-0.22360679774997894*JRatfR[19]+0.22360679774997902*(JRatfR[18]+JRatfR[17])+0.22360679774997896*JRatfR[16]-0.33541019662496846*(JRatfR[15]+JRatfR[14]+JRatfR[13])-0.25*JRatfR[12]+0.33541019662496846*JRatfR[11]-0.33541019662496846*JRatfR[10]-0.25*(JRatfR[9]+JRatfR[8])+0.33541019662496846*(JRatfR[7]+JRatfR[6])+0.25*JRatfR[5]-0.25*JRatfR[4]+0.33541019662496846*JRatfR[3]+0.25*(JRatfR[2]+JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[20] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[7]+0.3535533905932737*speedsL[6]+0.6123724356957944*(speedsL[5]+speedsL[4])+0.3535533905932737*(speedsL[3]+speedsL[2])+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.15811388300841892*JfL[46]+0.27386127875258304*(JfL[45]+JfL[44]+JfL[43])+0.15811388300841892*(JfL[42]+JfL[41])+0.273861278752583*JfL[40]+0.15811388300841892*JfL[39]+0.273861278752583*(JfL[38]+JfL[37])+0.15811388300841892*JfL[36]+0.15811388300841894*(JfL[35]+JfL[34])+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]-0.2371708245126284*JfL[30]-0.41079191812887433*(JfL[29]+JfL[28])+0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]-0.2371708245126284*(JfL[25]+JfL[24])-0.41079191812887433*JfL[23]+0.1767766952966368*JfL[22]+0.3061862178478971*(JfL[21]+JfL[20])-0.2371708245126284*JfL[19]-0.41079191812887433*(JfL[18]+JfL[17])+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.1767766952966368*(JfL[14]+JfL[13])+0.3061862178478971*JfL[12]-0.2371708245126284*(JfL[11]+JfL[10])-0.41079191812887433*JfL[9]+0.1767766952966368*JfL[8]+0.3061862178478971*(JfL[7]+JfL[6])+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.22360679774997894*JRatfR[23]+0.22360679774997896*(JRatfR[22]+JRatfR[21]+JRatfR[20])+0.22360679774997894*JRatfR[19]+0.22360679774997902*(JRatfR[18]+JRatfR[17])+0.22360679774997896*JRatfR[16]-0.33541019662496846*(JRatfR[15]+JRatfR[14]+JRatfR[13])+0.25*JRatfR[12]-0.33541019662496846*(JRatfR[11]+JRatfR[10])+0.25*(JRatfR[9]+JRatfR[8])-0.33541019662496846*(JRatfR[7]+JRatfR[6])+0.25*(JRatfR[5]+JRatfR[4])-0.33541019662496846*JRatfR[3]+0.25*(JRatfR[2]+JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[21] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[7]+0.3535533905932737*speedsL[6]+0.6123724356957944*(speedsL[5]+speedsL[4])+0.3535533905932737*(speedsL[3]+speedsL[2])+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])-0.19764235376052366*JfL[46]-0.3423265984407287*(JfL[45]+JfL[44]+JfL[43])-0.19764235376052364*(JfL[42]+JfL[41])-0.34232659844072866*JfL[40]-0.19764235376052364*JfL[39]-0.34232659844072866*(JfL[38]+JfL[37])-0.19764235376052366*(JfL[36]+JfL[35]+JfL[34])-0.3423265984407287*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*JfL[27]+0.1767766952966368*JfL[22]+0.3061862178478971*(JfL[21]+JfL[20]+JfL[16])+0.1767766952966368*(JfL[14]+JfL[13])+0.3061862178478971*JfL[12]+0.1767766952966368*JfL[8]+0.3061862178478971*(JfL[7]+JfL[6])+0.1767766952966368*(JfL[5]+JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.2795084971874738*JRatfR[23])-0.2795084971874737*(JRatfR[22]+JRatfR[21]+JRatfR[20])-0.2795084971874738*(JRatfR[19]+JRatfR[18]+JRatfR[17])-0.2795084971874737*JRatfR[16]+0.25*(JRatfR[12]+JRatfR[9]+JRatfR[8]+JRatfR[5]+JRatfR[4]+JRatfR[2]+JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[22] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[7]+0.3535533905932737*speedsL[6]+0.6123724356957944*(speedsL[5]+speedsL[4])+0.3535533905932737*(speedsL[3]+speedsL[2])+0.6123724356957944*speedsL[1]+0.3535533905932737*speedsL[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.15811388300841892*JfL[46]+0.27386127875258304*(JfL[45]+JfL[44]+JfL[43])+0.15811388300841892*(JfL[42]+JfL[41])+0.273861278752583*JfL[40]+0.15811388300841892*JfL[39]+0.273861278752583*(JfL[38]+JfL[37])+0.15811388300841892*JfL[36]+0.15811388300841894*(JfL[35]+JfL[34])+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]+0.2371708245126284*JfL[30]+0.41079191812887433*(JfL[29]+JfL[28])+0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]+0.2371708245126284*(JfL[25]+JfL[24])+0.41079191812887433*JfL[23]+0.1767766952966368*JfL[22]+0.3061862178478971*(JfL[21]+JfL[20])+0.2371708245126284*JfL[19]+0.41079191812887433*(JfL[18]+JfL[17])+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.1767766952966368*(JfL[14]+JfL[13])+0.3061862178478971*JfL[12]+0.2371708245126284*(JfL[11]+JfL[10])+0.41079191812887433*JfL[9]+0.1767766952966368*JfL[8]+0.3061862178478971*(JfL[7]+JfL[6])+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.22360679774997894*JRatfR[23]+0.22360679774997896*(JRatfR[22]+JRatfR[21]+JRatfR[20])+0.22360679774997894*JRatfR[19]+0.22360679774997902*(JRatfR[18]+JRatfR[17])+0.22360679774997896*JRatfR[16]+0.33541019662496846*(JRatfR[15]+JRatfR[14]+JRatfR[13])+0.25*JRatfR[12]+0.33541019662496846*(JRatfR[11]+JRatfR[10])+0.25*(JRatfR[9]+JRatfR[8])+0.33541019662496846*(JRatfR[7]+JRatfR[6])+0.25*(JRatfR[5]+JRatfR[4])+0.33541019662496846*JRatfR[3]+0.25*(JRatfR[2]+JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[23] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdx2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfy_2x2v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfy_2x2v_ser_p1.c new file mode 100644 index 0000000000..652ab2f000 --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfy_2x2v_ser_p1.c @@ -0,0 +1,188 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_edge_surfy_2x2v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdz2 = 2.0/dxv[1]; + double rdvpar2 = 2.0/dxv[2]; + + double JRatfR[12] = {0.}; + JRatfR[0] = -(0.5*(1.7320508075688772*(jacobgeo_rat_surfR[1]*JfR[5]+jacobgeo_rat_surfR[0]*JfR[2])-1.0*(JfR[1]*jacobgeo_rat_surfR[1]+JfR[0]*jacobgeo_rat_surfR[0]))); + JRatfR[1] = -(0.5*(1.7320508075688772*(jacobgeo_rat_surfR[0]*JfR[5]+jacobgeo_rat_surfR[1]*JfR[2])-1.0*(JfR[0]*jacobgeo_rat_surfR[1]+jacobgeo_rat_surfR[0]*JfR[1]))); + JRatfR[2] = -(0.5*(1.7320508075688772*(jacobgeo_rat_surfR[1]*JfR[11]+jacobgeo_rat_surfR[0]*JfR[7])-1.0*(jacobgeo_rat_surfR[1]*JfR[6]+jacobgeo_rat_surfR[0]*JfR[3]))); + JRatfR[3] = -(0.5*(1.7320508075688772*(jacobgeo_rat_surfR[1]*JfR[12]+jacobgeo_rat_surfR[0]*JfR[9])-1.0*(jacobgeo_rat_surfR[1]*JfR[8]+jacobgeo_rat_surfR[0]*JfR[4]))); + JRatfR[4] = -(0.5*(1.7320508075688772*(jacobgeo_rat_surfR[0]*JfR[11]+jacobgeo_rat_surfR[1]*JfR[7])-1.0*(jacobgeo_rat_surfR[0]*JfR[6]+jacobgeo_rat_surfR[1]*JfR[3]))); + JRatfR[5] = -(0.5*(1.7320508075688772*(jacobgeo_rat_surfR[0]*JfR[12]+jacobgeo_rat_surfR[1]*JfR[9])-1.0*(jacobgeo_rat_surfR[0]*JfR[8]+jacobgeo_rat_surfR[1]*JfR[4]))); + JRatfR[6] = -(0.5*(1.7320508075688772*(jacobgeo_rat_surfR[1]*JfR[15]+jacobgeo_rat_surfR[0]*JfR[14])-1.0*(jacobgeo_rat_surfR[1]*JfR[13]+jacobgeo_rat_surfR[0]*JfR[10]))); + JRatfR[7] = -(0.5*(1.7320508075688772*(jacobgeo_rat_surfR[0]*JfR[15]+jacobgeo_rat_surfR[1]*JfR[14])-1.0*(jacobgeo_rat_surfR[0]*JfR[13]+jacobgeo_rat_surfR[1]*JfR[10]))); + JRatfR[8] = 0.03333333333333333*(-(25.980762113533157*jacobgeo_rat_surfR[1]*JfR[20])+8.660254037844387*(1.7320508075688772*jacobgeo_rat_surfR[1]*JfR[17]-3.0*jacobgeo_rat_surfR[0]*JfR[18])+15.0*jacobgeo_rat_surfR[0]*JfR[16]); + JRatfR[9] = 0.03333333333333333*(8.660254037844387*(1.7320508075688772*jacobgeo_rat_surfR[1]*JfR[16]-3.0*jacobgeo_rat_surfR[0]*JfR[20])-25.980762113533157*jacobgeo_rat_surfR[1]*JfR[18]+15.0*jacobgeo_rat_surfR[0]*JfR[17]); + JRatfR[10] = 0.03333333333333333*(-(25.980762113533157*jacobgeo_rat_surfR[1]*JfR[23])+8.660254037844387*(1.7320508075688772*jacobgeo_rat_surfR[1]*JfR[21]-3.0*jacobgeo_rat_surfR[0]*JfR[22])+15.0*jacobgeo_rat_surfR[0]*JfR[19]); + JRatfR[11] = 0.03333333333333333*(8.660254037844387*(1.7320508075688772*jacobgeo_rat_surfR[1]*JfR[19]-3.0*jacobgeo_rat_surfR[0]*JfR[23])-25.980762113533157*jacobgeo_rat_surfR[1]*JfR[22]+15.0*jacobgeo_rat_surfR[0]*JfR[21]); + + double *flux_surf_nodal = &flux_surf[12]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = -(0.8660254037844386*speedsL[7])+0.8660254037844386*speedsL[6]-0.5*speedsL[5]+0.5*speedsL[4]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3872983346207417*JfL[23]-0.38729833462074165*JfL[22]+0.22360679774997896*JfL[21]-0.38729833462074165*JfL[20]-0.22360679774997894*JfL[19]+0.3872983346207417*JfL[18]-0.22360679774997902*JfL[17]+0.22360679774997896*JfL[16]-0.5809475019311124*JfL[15]+0.5809475019311124*JfL[14]-0.33541019662496846*JfL[13]+0.4330127018922193*JfL[12]+0.5809475019311124*JfL[11]+0.33541019662496846*JfL[10]-0.4330127018922193*JfL[9]+0.25*JfL[8]-0.5809475019311124*JfL[7]+0.33541019662496846*JfL[6]-0.4330127018922193*JfL[5]-0.25*JfL[4]-0.33541019662496846*JfL[3]+0.4330127018922193*JfL[2]-0.25*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.3162277660168379*JRatfR[11]-0.31622776601683794*(JRatfR[10]+JRatfR[9])+0.3162277660168379*JRatfR[8]-0.4743416490252568*JRatfR[7]+0.4743416490252568*JRatfR[6]+0.3535533905932737*JRatfR[5]+0.4743416490252568*JRatfR[4]-0.3535533905932737*JRatfR[3]-0.4743416490252568*JRatfR[2]-0.3535533905932737*JRatfR[1]+0.3535533905932737*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsL[7])+0.8660254037844386*speedsL[6]-0.5*speedsL[5]+0.5*speedsL[4]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.4841229182759271*JfL[23])+0.4841229182759271*JfL[22]-0.2795084971874737*JfL[21]+0.4841229182759271*JfL[20]+0.2795084971874738*JfL[19]-0.4841229182759271*JfL[18]+0.2795084971874738*JfL[17]-0.2795084971874737*JfL[16]+0.4330127018922193*JfL[12]-0.4330127018922193*JfL[9]+0.25*JfL[8]-0.4330127018922193*JfL[5]-0.25*JfL[4]+0.4330127018922193*JfL[2]-0.25*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.3952847075210473*JRatfR[11])+0.39528470752104733*(JRatfR[10]+JRatfR[9])-0.3952847075210473*JRatfR[8]+0.3535533905932737*JRatfR[5]-0.3535533905932737*(JRatfR[3]+JRatfR[1])+0.3535533905932737*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsL[7])+0.8660254037844386*speedsL[6]-0.5*speedsL[5]+0.5*speedsL[4]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3872983346207417*JfL[23]-0.38729833462074165*JfL[22]+0.22360679774997896*JfL[21]-0.38729833462074165*JfL[20]-0.22360679774997894*JfL[19]+0.3872983346207417*JfL[18]-0.22360679774997902*JfL[17]+0.22360679774997896*JfL[16]+0.5809475019311124*JfL[15]-0.5809475019311124*JfL[14]+0.33541019662496846*JfL[13]+0.4330127018922193*JfL[12]-0.5809475019311124*JfL[11]-0.33541019662496846*JfL[10]-0.4330127018922193*JfL[9]+0.25*JfL[8]+0.5809475019311124*JfL[7]-0.33541019662496846*JfL[6]-0.4330127018922193*JfL[5]-0.25*JfL[4]+0.33541019662496846*JfL[3]+0.4330127018922193*JfL[2]-0.25*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.3162277660168379*JRatfR[11]-0.31622776601683794*(JRatfR[10]+JRatfR[9])+0.3162277660168379*JRatfR[8]+0.4743416490252568*JRatfR[7]-0.4743416490252568*JRatfR[6]+0.3535533905932737*JRatfR[5]-0.4743416490252568*JRatfR[4]-0.3535533905932737*JRatfR[3]+0.4743416490252568*JRatfR[2]-0.3535533905932737*JRatfR[1]+0.3535533905932737*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsL[7])+0.8660254037844386*speedsL[6]-0.5*speedsL[5]+0.5*speedsL[4]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3872983346207417*JfL[23])+0.38729833462074165*JfL[22]-0.22360679774997896*JfL[21]-0.38729833462074165*JfL[20]+0.22360679774997894*JfL[19]+0.3872983346207417*JfL[18]-0.22360679774997902*JfL[17]+0.22360679774997896*JfL[16]+0.5809475019311124*JfL[15]-0.5809475019311124*JfL[14]+0.33541019662496846*JfL[13]-0.4330127018922193*JfL[12]+0.5809475019311124*JfL[11]-0.33541019662496846*JfL[10]+0.4330127018922193*JfL[9]-0.25*JfL[8]-0.5809475019311124*JfL[7]+0.33541019662496846*JfL[6]-0.4330127018922193*JfL[5]+0.25*JfL[4]-0.33541019662496846*JfL[3]+0.4330127018922193*JfL[2]-0.25*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.3162277660168379*JRatfR[11])+0.31622776601683794*JRatfR[10]-0.31622776601683794*JRatfR[9]+0.3162277660168379*JRatfR[8]+0.4743416490252568*JRatfR[7]-0.4743416490252568*JRatfR[6]-0.3535533905932737*JRatfR[5]+0.4743416490252568*JRatfR[4]+0.3535533905932737*JRatfR[3]-0.4743416490252568*JRatfR[2]-0.3535533905932737*JRatfR[1]+0.3535533905932737*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[3] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsL[7])+0.8660254037844386*speedsL[6]-0.5*speedsL[5]+0.5*speedsL[4]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.4841229182759271*JfL[23]-0.4841229182759271*JfL[22]+0.2795084971874737*JfL[21]+0.4841229182759271*JfL[20]-0.2795084971874738*JfL[19]-0.4841229182759271*JfL[18]+0.2795084971874738*JfL[17]-0.2795084971874737*JfL[16]-0.4330127018922193*JfL[12]+0.4330127018922193*JfL[9]-0.25*JfL[8]-0.4330127018922193*JfL[5]+0.25*JfL[4]+0.4330127018922193*JfL[2]-0.25*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.3952847075210473*JRatfR[11]-0.39528470752104733*JRatfR[10]+0.39528470752104733*JRatfR[9]-0.3952847075210473*JRatfR[8]-0.3535533905932737*JRatfR[5]+0.3535533905932737*JRatfR[3]-0.3535533905932737*JRatfR[1]+0.3535533905932737*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[4] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsL[7])+0.8660254037844386*speedsL[6]-0.5*speedsL[5]+0.5*speedsL[4]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3872983346207417*JfL[23])+0.38729833462074165*JfL[22]-0.22360679774997896*JfL[21]-0.38729833462074165*JfL[20]+0.22360679774997894*JfL[19]+0.3872983346207417*JfL[18]-0.22360679774997902*JfL[17]+0.22360679774997896*JfL[16]-0.5809475019311124*JfL[15]+0.5809475019311124*JfL[14]-0.33541019662496846*JfL[13]-0.4330127018922193*JfL[12]-0.5809475019311124*JfL[11]+0.33541019662496846*JfL[10]+0.4330127018922193*JfL[9]-0.25*JfL[8]+0.5809475019311124*JfL[7]-0.33541019662496846*JfL[6]-0.4330127018922193*JfL[5]+0.25*JfL[4]+0.33541019662496846*JfL[3]+0.4330127018922193*JfL[2]-0.25*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.3162277660168379*JRatfR[11])+0.31622776601683794*JRatfR[10]-0.31622776601683794*JRatfR[9]+0.3162277660168379*JRatfR[8]-0.4743416490252568*JRatfR[7]+0.4743416490252568*JRatfR[6]-0.3535533905932737*JRatfR[5]-0.4743416490252568*JRatfR[4]+0.3535533905932737*JRatfR[3]+0.4743416490252568*JRatfR[2]-0.3535533905932737*JRatfR[1]+0.3535533905932737*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[5] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[1].bmag; + Jc_quad = gkdgs[1].Jc; + B3_quad = gkdgs[1].B3; + normcurlbhat_quad = gkdgs[1].normcurlbhat; + bhat_quad[0] = gkdgs[1].bhat.x[0]; + bhat_quad[1] = gkdgs[1].bhat.x[1]; + bhat_quad[2] = gkdgs[1].bhat.x[2]; + area_elem_quad = dgs[1].area_elem; + + + alpha_quad = 0.8660254037844386*(speedsL[7]+speedsL[6])+0.5*(speedsL[5]+speedsL[4]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3872983346207417*JfL[23])-0.38729833462074165*JfL[22]-0.22360679774997896*JfL[21]+0.38729833462074165*JfL[20]-0.22360679774997894*JfL[19]+0.3872983346207417*JfL[18]+0.22360679774997902*JfL[17]+0.22360679774997896*JfL[16]+0.5809475019311124*(JfL[15]+JfL[14])+0.33541019662496846*JfL[13]-0.4330127018922193*JfL[12]-0.5809475019311124*JfL[11]+0.33541019662496846*JfL[10]-0.4330127018922193*JfL[9]-0.25*JfL[8]-0.5809475019311124*JfL[7]-0.33541019662496846*JfL[6]+0.4330127018922193*JfL[5]-0.25*JfL[4]-0.33541019662496846*JfL[3]+0.4330127018922193*JfL[2]+0.25*(JfL[1]+JfL[0]); + JfR_quad = -(0.3162277660168379*JRatfR[11])-0.31622776601683794*JRatfR[10]+0.31622776601683794*JRatfR[9]+0.3162277660168379*JRatfR[8]+0.4743416490252568*(JRatfR[7]+JRatfR[6])-0.3535533905932737*JRatfR[5]-0.4743416490252568*JRatfR[4]-0.3535533905932737*JRatfR[3]-0.4743416490252568*JRatfR[2]+0.3535533905932737*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[6] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*(speedsL[7]+speedsL[6])+0.5*(speedsL[5]+speedsL[4]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.4841229182759271*(JfL[23]+JfL[22])+0.2795084971874737*JfL[21]-0.4841229182759271*JfL[20]+0.2795084971874738*JfL[19]-0.4841229182759271*JfL[18]-0.2795084971874738*JfL[17]-0.2795084971874737*JfL[16]-0.4330127018922193*(JfL[12]+JfL[9])-0.25*JfL[8]+0.4330127018922193*JfL[5]-0.25*JfL[4]+0.4330127018922193*JfL[2]+0.25*(JfL[1]+JfL[0]); + JfR_quad = 0.3952847075210473*JRatfR[11]+0.39528470752104733*JRatfR[10]-0.39528470752104733*JRatfR[9]-0.3952847075210473*JRatfR[8]-0.3535533905932737*(JRatfR[5]+JRatfR[3])+0.3535533905932737*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[7] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*(speedsL[7]+speedsL[6])+0.5*(speedsL[5]+speedsL[4]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3872983346207417*JfL[23])-0.38729833462074165*JfL[22]-0.22360679774997896*JfL[21]+0.38729833462074165*JfL[20]-0.22360679774997894*JfL[19]+0.3872983346207417*JfL[18]+0.22360679774997902*JfL[17]+0.22360679774997896*JfL[16]-0.5809475019311124*(JfL[15]+JfL[14])-0.33541019662496846*JfL[13]-0.4330127018922193*JfL[12]+0.5809475019311124*JfL[11]-0.33541019662496846*JfL[10]-0.4330127018922193*JfL[9]-0.25*JfL[8]+0.5809475019311124*JfL[7]+0.33541019662496846*JfL[6]+0.4330127018922193*JfL[5]-0.25*JfL[4]+0.33541019662496846*JfL[3]+0.4330127018922193*JfL[2]+0.25*(JfL[1]+JfL[0]); + JfR_quad = -(0.3162277660168379*JRatfR[11])-0.31622776601683794*JRatfR[10]+0.31622776601683794*JRatfR[9]+0.3162277660168379*JRatfR[8]-0.4743416490252568*(JRatfR[7]+JRatfR[6])-0.3535533905932737*JRatfR[5]+0.4743416490252568*JRatfR[4]-0.3535533905932737*JRatfR[3]+0.4743416490252568*JRatfR[2]+0.3535533905932737*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[8] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*(speedsL[7]+speedsL[6])+0.5*(speedsL[5]+speedsL[4]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3872983346207417*JfL[23]+0.38729833462074165*JfL[22]+0.22360679774997896*JfL[21]+0.38729833462074165*JfL[20]+0.22360679774997894*JfL[19]+0.3872983346207417*JfL[18]+0.22360679774997902*JfL[17]+0.22360679774997896*JfL[16]-0.5809475019311124*(JfL[15]+JfL[14])-0.33541019662496846*JfL[13]+0.4330127018922193*JfL[12]-0.5809475019311124*JfL[11]-0.33541019662496846*JfL[10]+0.4330127018922193*JfL[9]+0.25*JfL[8]-0.5809475019311124*JfL[7]-0.33541019662496846*JfL[6]+0.4330127018922193*JfL[5]+0.25*JfL[4]-0.33541019662496846*JfL[3]+0.4330127018922193*JfL[2]+0.25*(JfL[1]+JfL[0]); + JfR_quad = 0.3162277660168379*JRatfR[11]+0.31622776601683794*(JRatfR[10]+JRatfR[9])+0.3162277660168379*JRatfR[8]-0.4743416490252568*(JRatfR[7]+JRatfR[6])+0.3535533905932737*JRatfR[5]-0.4743416490252568*JRatfR[4]+0.3535533905932737*JRatfR[3]-0.4743416490252568*JRatfR[2]+0.3535533905932737*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[9] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*(speedsL[7]+speedsL[6])+0.5*(speedsL[5]+speedsL[4]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.4841229182759271*(JfL[23]+JfL[22]))-0.2795084971874737*JfL[21]-0.4841229182759271*JfL[20]-0.2795084971874738*JfL[19]-0.4841229182759271*JfL[18]-0.2795084971874738*JfL[17]-0.2795084971874737*JfL[16]+0.4330127018922193*(JfL[12]+JfL[9])+0.25*JfL[8]+0.4330127018922193*JfL[5]+0.25*JfL[4]+0.4330127018922193*JfL[2]+0.25*(JfL[1]+JfL[0]); + JfR_quad = -(0.3952847075210473*JRatfR[11])-0.39528470752104733*(JRatfR[10]+JRatfR[9])-0.3952847075210473*JRatfR[8]+0.3535533905932737*(JRatfR[5]+JRatfR[3]+JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[10] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*(speedsL[7]+speedsL[6])+0.5*(speedsL[5]+speedsL[4]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3872983346207417*JfL[23]+0.38729833462074165*JfL[22]+0.22360679774997896*JfL[21]+0.38729833462074165*JfL[20]+0.22360679774997894*JfL[19]+0.3872983346207417*JfL[18]+0.22360679774997902*JfL[17]+0.22360679774997896*JfL[16]+0.5809475019311124*(JfL[15]+JfL[14])+0.33541019662496846*JfL[13]+0.4330127018922193*JfL[12]+0.5809475019311124*JfL[11]+0.33541019662496846*JfL[10]+0.4330127018922193*JfL[9]+0.25*JfL[8]+0.5809475019311124*JfL[7]+0.33541019662496846*JfL[6]+0.4330127018922193*JfL[5]+0.25*JfL[4]+0.33541019662496846*JfL[3]+0.4330127018922193*JfL[2]+0.25*(JfL[1]+JfL[0]); + JfR_quad = 0.3162277660168379*JRatfR[11]+0.31622776601683794*(JRatfR[10]+JRatfR[9])+0.3162277660168379*JRatfR[8]+0.4743416490252568*(JRatfR[7]+JRatfR[6])+0.3535533905932737*JRatfR[5]+0.4743416490252568*JRatfR[4]+0.3535533905932737*JRatfR[3]+0.4743416490252568*JRatfR[2]+0.3535533905932737*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[11] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdz2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfy_3x2v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfy_3x2v_ser_p1.c new file mode 100644 index 0000000000..9d9ed3c9ef --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfy_3x2v_ser_p1.c @@ -0,0 +1,329 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_edge_surfy_3x2v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdy2 = 2.0/dxv[1]; + double rdz2 = 2.0/dxv[2]; + double rdvpar2 = 2.0/dxv[3]; + + double JRatfR[24] = {0.}; + JRatfR[0] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[3]*JfR[16]+jacobgeo_rat_surfR[2]*JfR[8]+jacobgeo_rat_surfR[1]*JfR[6]+jacobgeo_rat_surfR[0]*JfR[2])-1.4142135623730951*(jacobgeo_rat_surfR[3]*JfR[7]+jacobgeo_rat_surfR[2]*JfR[3]+JfR[1]*jacobgeo_rat_surfR[1]+JfR[0]*jacobgeo_rat_surfR[0]))); + JRatfR[1] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[2]*JfR[16]+jacobgeo_rat_surfR[3]*JfR[8]+jacobgeo_rat_surfR[0]*JfR[6]+jacobgeo_rat_surfR[1]*JfR[2])-1.4142135623730951*(jacobgeo_rat_surfR[2]*JfR[7]+JfR[3]*jacobgeo_rat_surfR[3]+JfR[0]*jacobgeo_rat_surfR[1]+jacobgeo_rat_surfR[0]*JfR[1]))); + JRatfR[2] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[1]*JfR[16]+jacobgeo_rat_surfR[0]*JfR[8]+jacobgeo_rat_surfR[3]*JfR[6]+JfR[2]*jacobgeo_rat_surfR[2])-1.4142135623730951*(jacobgeo_rat_surfR[1]*JfR[7]+JfR[1]*jacobgeo_rat_surfR[3]+jacobgeo_rat_surfR[0]*JfR[3]+JfR[0]*jacobgeo_rat_surfR[2]))); + JRatfR[3] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[3]*JfR[26]+jacobgeo_rat_surfR[2]*JfR[19]+jacobgeo_rat_surfR[1]*JfR[17]+jacobgeo_rat_surfR[0]*JfR[10])-1.4142135623730951*(jacobgeo_rat_surfR[3]*JfR[18]+jacobgeo_rat_surfR[2]*JfR[11]+jacobgeo_rat_surfR[1]*JfR[9]+jacobgeo_rat_surfR[0]*JfR[4]))); + JRatfR[4] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[3]*JfR[27]+jacobgeo_rat_surfR[2]*JfR[22]+jacobgeo_rat_surfR[1]*JfR[20]+jacobgeo_rat_surfR[0]*JfR[13])-1.4142135623730951*(jacobgeo_rat_surfR[3]*JfR[21]+jacobgeo_rat_surfR[2]*JfR[14]+jacobgeo_rat_surfR[1]*JfR[12]+jacobgeo_rat_surfR[0]*JfR[5]))); + JRatfR[5] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[0]*JfR[16]+jacobgeo_rat_surfR[1]*JfR[8]+jacobgeo_rat_surfR[2]*JfR[6]+JfR[2]*jacobgeo_rat_surfR[3])-1.4142135623730951*(jacobgeo_rat_surfR[0]*JfR[7]+JfR[0]*jacobgeo_rat_surfR[3]+jacobgeo_rat_surfR[1]*JfR[3]+JfR[1]*jacobgeo_rat_surfR[2]))); + JRatfR[6] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[2]*JfR[26]+jacobgeo_rat_surfR[3]*JfR[19]+jacobgeo_rat_surfR[0]*JfR[17]+jacobgeo_rat_surfR[1]*JfR[10])-1.4142135623730951*(jacobgeo_rat_surfR[2]*JfR[18]+jacobgeo_rat_surfR[3]*JfR[11]+jacobgeo_rat_surfR[0]*JfR[9]+jacobgeo_rat_surfR[1]*JfR[4]))); + JRatfR[7] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[1]*JfR[26]+jacobgeo_rat_surfR[0]*JfR[19]+jacobgeo_rat_surfR[3]*JfR[17]+jacobgeo_rat_surfR[2]*JfR[10])-1.4142135623730951*(jacobgeo_rat_surfR[1]*JfR[18]+jacobgeo_rat_surfR[0]*JfR[11]+jacobgeo_rat_surfR[3]*JfR[9]+jacobgeo_rat_surfR[2]*JfR[4]))); + JRatfR[8] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[2]*JfR[27]+jacobgeo_rat_surfR[3]*JfR[22]+jacobgeo_rat_surfR[0]*JfR[20]+jacobgeo_rat_surfR[1]*JfR[13])-1.4142135623730951*(jacobgeo_rat_surfR[2]*JfR[21]+jacobgeo_rat_surfR[3]*JfR[14]+jacobgeo_rat_surfR[0]*JfR[12]+jacobgeo_rat_surfR[1]*JfR[5]))); + JRatfR[9] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[1]*JfR[27]+jacobgeo_rat_surfR[0]*JfR[22]+jacobgeo_rat_surfR[3]*JfR[20]+jacobgeo_rat_surfR[2]*JfR[13])-1.4142135623730951*(jacobgeo_rat_surfR[1]*JfR[21]+jacobgeo_rat_surfR[0]*JfR[14]+jacobgeo_rat_surfR[3]*JfR[12]+jacobgeo_rat_surfR[2]*JfR[5]))); + JRatfR[10] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[3]*JfR[31]+jacobgeo_rat_surfR[2]*JfR[30]+jacobgeo_rat_surfR[1]*JfR[28]+jacobgeo_rat_surfR[0]*JfR[24])-1.4142135623730951*(jacobgeo_rat_surfR[3]*JfR[29]+jacobgeo_rat_surfR[2]*JfR[25]+jacobgeo_rat_surfR[1]*JfR[23]+jacobgeo_rat_surfR[0]*JfR[15]))); + JRatfR[11] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[0]*JfR[26]+jacobgeo_rat_surfR[1]*JfR[19]+jacobgeo_rat_surfR[2]*JfR[17]+jacobgeo_rat_surfR[3]*JfR[10])-1.4142135623730951*(jacobgeo_rat_surfR[0]*JfR[18]+jacobgeo_rat_surfR[1]*JfR[11]+jacobgeo_rat_surfR[2]*JfR[9]+jacobgeo_rat_surfR[3]*JfR[4]))); + JRatfR[12] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[0]*JfR[27]+jacobgeo_rat_surfR[1]*JfR[22]+jacobgeo_rat_surfR[2]*JfR[20]+jacobgeo_rat_surfR[3]*JfR[13])-1.4142135623730951*(jacobgeo_rat_surfR[0]*JfR[21]+jacobgeo_rat_surfR[1]*JfR[14]+jacobgeo_rat_surfR[2]*JfR[12]+jacobgeo_rat_surfR[3]*JfR[5]))); + JRatfR[13] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[2]*JfR[31]+jacobgeo_rat_surfR[3]*JfR[30]+jacobgeo_rat_surfR[0]*JfR[28]+jacobgeo_rat_surfR[1]*JfR[24])-1.4142135623730951*(jacobgeo_rat_surfR[2]*JfR[29]+jacobgeo_rat_surfR[3]*JfR[25]+jacobgeo_rat_surfR[0]*JfR[23]+jacobgeo_rat_surfR[1]*JfR[15]))); + JRatfR[14] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[1]*JfR[31]+jacobgeo_rat_surfR[0]*JfR[30]+jacobgeo_rat_surfR[3]*JfR[28]+jacobgeo_rat_surfR[2]*JfR[24])-1.4142135623730951*(jacobgeo_rat_surfR[1]*JfR[29]+jacobgeo_rat_surfR[0]*JfR[25]+jacobgeo_rat_surfR[3]*JfR[23]+jacobgeo_rat_surfR[2]*JfR[15]))); + JRatfR[15] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[0]*JfR[31]+jacobgeo_rat_surfR[1]*JfR[30]+jacobgeo_rat_surfR[2]*JfR[28]+jacobgeo_rat_surfR[3]*JfR[24])-1.4142135623730951*(jacobgeo_rat_surfR[0]*JfR[29]+jacobgeo_rat_surfR[1]*JfR[25]+jacobgeo_rat_surfR[2]*JfR[23]+jacobgeo_rat_surfR[3]*JfR[15]))); + JRatfR[16] = 0.016666666666666666*(8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfR[2]*JfR[35]+jacobgeo_rat_surfR[1]*JfR[33])-4.242640687119286*(jacobgeo_rat_surfR[3]*JfR[43]+jacobgeo_rat_surfR[0]*JfR[34]))-36.742346141747674*(jacobgeo_rat_surfR[2]*JfR[39]+jacobgeo_rat_surfR[1]*JfR[37])+21.213203435596427*(jacobgeo_rat_surfR[3]*JfR[38]+jacobgeo_rat_surfR[0]*JfR[32])); + JRatfR[17] = 0.016666666666666666*(-(36.742346141747674*(jacobgeo_rat_surfR[2]*JfR[43]+jacobgeo_rat_surfR[1]*JfR[34]))+8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfR[2]*JfR[38]+jacobgeo_rat_surfR[1]*JfR[32])-4.242640687119286*(jacobgeo_rat_surfR[3]*JfR[39]+jacobgeo_rat_surfR[0]*JfR[37]))+21.213203435596427*(jacobgeo_rat_surfR[3]*JfR[35]+jacobgeo_rat_surfR[0]*JfR[33])); + JRatfR[18] = 0.016666666666666666*(-(36.742346141747674*(jacobgeo_rat_surfR[1]*JfR[43]+jacobgeo_rat_surfR[2]*JfR[34]))+8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfR[1]*JfR[38]+jacobgeo_rat_surfR[2]*JfR[32])-4.242640687119286*(jacobgeo_rat_surfR[0]*JfR[39]+jacobgeo_rat_surfR[3]*JfR[37]))+21.213203435596427*(jacobgeo_rat_surfR[0]*JfR[35]+jacobgeo_rat_surfR[3]*JfR[33])); + JRatfR[19] = 0.016666666666666666*(8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfR[2]*JfR[42]+jacobgeo_rat_surfR[1]*JfR[40])-4.242640687119286*(jacobgeo_rat_surfR[3]*JfR[47]+jacobgeo_rat_surfR[0]*JfR[41]))-36.742346141747674*(jacobgeo_rat_surfR[2]*JfR[46]+jacobgeo_rat_surfR[1]*JfR[44])+21.213203435596427*(jacobgeo_rat_surfR[3]*JfR[45]+jacobgeo_rat_surfR[0]*JfR[36])); + JRatfR[20] = 0.016666666666666666*(8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfR[1]*JfR[35]+jacobgeo_rat_surfR[2]*JfR[33])-4.242640687119286*(jacobgeo_rat_surfR[0]*JfR[43]+jacobgeo_rat_surfR[3]*JfR[34]))-36.742346141747674*(jacobgeo_rat_surfR[1]*JfR[39]+jacobgeo_rat_surfR[2]*JfR[37])+21.213203435596427*(jacobgeo_rat_surfR[0]*JfR[38]+jacobgeo_rat_surfR[3]*JfR[32])); + JRatfR[21] = 0.016666666666666666*(-(36.742346141747674*(jacobgeo_rat_surfR[2]*JfR[47]+jacobgeo_rat_surfR[1]*JfR[41]))+8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfR[2]*JfR[45]+jacobgeo_rat_surfR[1]*JfR[36])-4.242640687119286*(jacobgeo_rat_surfR[3]*JfR[46]+jacobgeo_rat_surfR[0]*JfR[44]))+21.213203435596427*(jacobgeo_rat_surfR[3]*JfR[42]+jacobgeo_rat_surfR[0]*JfR[40])); + JRatfR[22] = 0.016666666666666666*(-(36.742346141747674*(jacobgeo_rat_surfR[1]*JfR[47]+jacobgeo_rat_surfR[2]*JfR[41]))+8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfR[1]*JfR[45]+jacobgeo_rat_surfR[2]*JfR[36])-4.242640687119286*(jacobgeo_rat_surfR[0]*JfR[46]+jacobgeo_rat_surfR[3]*JfR[44]))+21.213203435596427*(jacobgeo_rat_surfR[0]*JfR[42]+jacobgeo_rat_surfR[3]*JfR[40])); + JRatfR[23] = 0.016666666666666666*(8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfR[1]*JfR[42]+jacobgeo_rat_surfR[2]*JfR[40])-4.242640687119286*(jacobgeo_rat_surfR[0]*JfR[47]+jacobgeo_rat_surfR[3]*JfR[41]))-36.742346141747674*(jacobgeo_rat_surfR[1]*JfR[46]+jacobgeo_rat_surfR[2]*JfR[44])+21.213203435596427*(jacobgeo_rat_surfR[0]*JfR[45]+jacobgeo_rat_surfR[3]*JfR[36])); + + double *flux_surf_nodal = &flux_surf[24]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = 0.6123724356957944*speedsL[15]-0.6123724356957944*speedsL[14]+0.3535533905932737*speedsL[13]-0.6123724356957944*speedsL[12]-0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]-0.3535533905932737*speedsL[9]+0.3535533905932737*speedsL[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])+0.27386127875258304*JfL[46]-0.15811388300841892*JfL[45]+0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]-0.273861278752583*JfL[41]+0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]+0.15811388300841892*JfL[38]-0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]-0.41079191812887433*JfL[30]+0.2371708245126284*JfL[29]-0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]+0.41079191812887433*JfL[24]-0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]+0.41079191812887433*JfL[19]-0.2371708245126284*JfL[18]+0.41079191812887433*JfL[17]+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]+0.2371708245126284*JfL[11]-0.41079191812887433*JfL[10]+0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.22360679774997894*JRatfR[23])+0.22360679774997896*(JRatfR[22]+JRatfR[21]+JRatfR[20])-0.22360679774997894*JRatfR[19]-0.22360679774997902*(JRatfR[18]+JRatfR[17])+0.22360679774997896*JRatfR[16]+0.33541019662496846*JRatfR[15]-0.33541019662496846*(JRatfR[14]+JRatfR[13])-0.25*JRatfR[12]-0.33541019662496846*JRatfR[11]+0.33541019662496846*JRatfR[10]+0.25*(JRatfR[9]+JRatfR[8])+0.33541019662496846*(JRatfR[7]+JRatfR[6])+0.25*JRatfR[5]-0.25*JRatfR[4]-0.33541019662496846*JRatfR[3]-0.25*(JRatfR[2]+JRatfR[1])+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[15]-0.6123724356957944*speedsL[14]+0.3535533905932737*speedsL[13]-0.6123724356957944*speedsL[12]-0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]-0.3535533905932737*speedsL[9]+0.3535533905932737*speedsL[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]-0.3423265984407287*JfL[46]+0.19764235376052366*JfL[45]-0.3423265984407287*(JfL[44]+JfL[43])-0.19764235376052364*JfL[42]+0.34232659844072866*JfL[41]-0.19764235376052364*JfL[40]+0.34232659844072866*JfL[39]-0.19764235376052364*JfL[38]+0.34232659844072866*JfL[37]+0.19764235376052366*(JfL[36]+JfL[35])-0.3423265984407287*JfL[34]+0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*JfL[27]+0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]+0.3061862178478971*(JfL[20]+JfL[16])+0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]-0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*(JfL[5]+JfL[3])+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.2795084971874738*JRatfR[23]-0.2795084971874737*(JRatfR[22]+JRatfR[21]+JRatfR[20])+0.2795084971874738*(JRatfR[19]+JRatfR[18]+JRatfR[17])-0.2795084971874737*JRatfR[16]-0.25*JRatfR[12]+0.25*(JRatfR[9]+JRatfR[8]+JRatfR[5])-0.25*(JRatfR[4]+JRatfR[2]+JRatfR[1])+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[15]-0.6123724356957944*speedsL[14]+0.3535533905932737*speedsL[13]-0.6123724356957944*speedsL[12]-0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]-0.3535533905932737*speedsL[9]+0.3535533905932737*speedsL[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])+0.27386127875258304*JfL[46]-0.15811388300841892*JfL[45]+0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]-0.273861278752583*JfL[41]+0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]+0.15811388300841892*JfL[38]-0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]+0.41079191812887433*JfL[30]-0.2371708245126284*JfL[29]+0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]-0.41079191812887433*JfL[24]+0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]-0.41079191812887433*JfL[19]+0.2371708245126284*JfL[18]-0.41079191812887433*JfL[17]+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]-0.2371708245126284*JfL[11]+0.41079191812887433*JfL[10]-0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.22360679774997894*JRatfR[23])+0.22360679774997896*(JRatfR[22]+JRatfR[21]+JRatfR[20])-0.22360679774997894*JRatfR[19]-0.22360679774997902*(JRatfR[18]+JRatfR[17])+0.22360679774997896*JRatfR[16]-0.33541019662496846*JRatfR[15]+0.33541019662496846*(JRatfR[14]+JRatfR[13])-0.25*JRatfR[12]+0.33541019662496846*JRatfR[11]-0.33541019662496846*JRatfR[10]+0.25*(JRatfR[9]+JRatfR[8])-0.33541019662496846*(JRatfR[7]+JRatfR[6])+0.25*JRatfR[5]-0.25*JRatfR[4]+0.33541019662496846*JRatfR[3]-0.25*(JRatfR[2]+JRatfR[1])+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[15]-0.6123724356957944*speedsL[14]+0.3535533905932737*speedsL[13]-0.6123724356957944*speedsL[12]-0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]-0.3535533905932737*speedsL[9]+0.3535533905932737*speedsL[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]-0.27386127875258304*JfL[46]+0.15811388300841892*JfL[45]-0.27386127875258304*JfL[44]+0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]+0.273861278752583*JfL[41]-0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]+0.15811388300841892*JfL[38]-0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]+0.41079191812887433*JfL[30]-0.2371708245126284*JfL[29]+0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]-0.41079191812887433*JfL[24]+0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]+0.41079191812887433*JfL[19]-0.2371708245126284*JfL[18]+0.41079191812887433*JfL[17]+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]+0.2371708245126284*JfL[11]-0.41079191812887433*JfL[10]+0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.22360679774997894*JRatfR[23]-0.22360679774997896*(JRatfR[22]+JRatfR[21])+0.22360679774997896*JRatfR[20]+0.22360679774997894*JRatfR[19]-0.22360679774997902*(JRatfR[18]+JRatfR[17])+0.22360679774997896*JRatfR[16]-0.33541019662496846*JRatfR[15]+0.33541019662496846*(JRatfR[14]+JRatfR[13])+0.25*JRatfR[12]-0.33541019662496846*(JRatfR[11]+JRatfR[10])-0.25*(JRatfR[9]+JRatfR[8])+0.33541019662496846*(JRatfR[7]+JRatfR[6])+0.25*(JRatfR[5]+JRatfR[4])-0.33541019662496846*JRatfR[3]-0.25*(JRatfR[2]+JRatfR[1])+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[3] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[15]-0.6123724356957944*speedsL[14]+0.3535533905932737*speedsL[13]-0.6123724356957944*speedsL[12]-0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]-0.3535533905932737*speedsL[9]+0.3535533905932737*speedsL[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])+0.3423265984407287*JfL[46]-0.19764235376052366*JfL[45]+0.3423265984407287*JfL[44]-0.3423265984407287*JfL[43]+0.19764235376052364*JfL[42]-0.34232659844072866*JfL[41]+0.19764235376052364*JfL[40]+0.34232659844072866*JfL[39]-0.19764235376052364*JfL[38]+0.34232659844072866*JfL[37]-0.19764235376052366*JfL[36]+0.19764235376052366*JfL[35]-0.3423265984407287*JfL[34]+0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*JfL[27]-0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]+0.3061862178478971*JfL[16]-0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]-0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.2795084971874738*JRatfR[23])+0.2795084971874737*(JRatfR[22]+JRatfR[21])-0.2795084971874737*JRatfR[20]-0.2795084971874738*JRatfR[19]+0.2795084971874738*(JRatfR[18]+JRatfR[17])-0.2795084971874737*JRatfR[16]+0.25*JRatfR[12]-0.25*(JRatfR[9]+JRatfR[8])+0.25*(JRatfR[5]+JRatfR[4])-0.25*(JRatfR[2]+JRatfR[1])+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[4] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[15]-0.6123724356957944*speedsL[14]+0.3535533905932737*speedsL[13]-0.6123724356957944*speedsL[12]-0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]-0.3535533905932737*speedsL[9]+0.3535533905932737*speedsL[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]-0.27386127875258304*JfL[46]+0.15811388300841892*JfL[45]-0.27386127875258304*JfL[44]+0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]+0.273861278752583*JfL[41]-0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]+0.15811388300841892*JfL[38]-0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]-0.41079191812887433*JfL[30]+0.2371708245126284*JfL[29]-0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]+0.41079191812887433*JfL[24]-0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]-0.41079191812887433*JfL[19]+0.2371708245126284*JfL[18]-0.41079191812887433*JfL[17]+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]-0.2371708245126284*JfL[11]+0.41079191812887433*JfL[10]-0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.22360679774997894*JRatfR[23]-0.22360679774997896*(JRatfR[22]+JRatfR[21])+0.22360679774997896*JRatfR[20]+0.22360679774997894*JRatfR[19]-0.22360679774997902*(JRatfR[18]+JRatfR[17])+0.22360679774997896*JRatfR[16]+0.33541019662496846*JRatfR[15]-0.33541019662496846*(JRatfR[14]+JRatfR[13])+0.25*JRatfR[12]+0.33541019662496846*(JRatfR[11]+JRatfR[10])-0.25*(JRatfR[9]+JRatfR[8])-0.33541019662496846*(JRatfR[7]+JRatfR[6])+0.25*(JRatfR[5]+JRatfR[4])+0.33541019662496846*JRatfR[3]-0.25*(JRatfR[2]+JRatfR[1])+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[5] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[1].bmag; + Jc_quad = gkdgs[1].Jc; + B3_quad = gkdgs[1].B3; + normcurlbhat_quad = gkdgs[1].normcurlbhat; + bhat_quad[0] = gkdgs[1].bhat.x[0]; + bhat_quad[1] = gkdgs[1].bhat.x[1]; + bhat_quad[2] = gkdgs[1].bhat.x[2]; + area_elem_quad = dgs[1].area_elem; + + + alpha_quad = -(0.6123724356957944*speedsL[15])+0.6123724356957944*speedsL[14]-0.3535533905932737*speedsL[13]-0.6123724356957944*speedsL[12]+0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]-0.3535533905932737*speedsL[9]+0.3535533905932737*speedsL[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]-0.27386127875258304*JfL[46]+0.15811388300841892*JfL[45]+0.27386127875258304*JfL[44]-0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]-0.273861278752583*JfL[41]+0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]-0.15811388300841892*JfL[38]-0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]+0.41079191812887433*JfL[30]-0.2371708245126284*JfL[29]-0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]+0.41079191812887433*JfL[24]-0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]-0.41079191812887433*JfL[19]+0.2371708245126284*JfL[18]+0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]-0.2371708245126284*JfL[11]-0.41079191812887433*JfL[10]+0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.22360679774997894*JRatfR[23]-0.22360679774997896*JRatfR[22]+0.22360679774997896*JRatfR[21]-0.22360679774997896*JRatfR[20]-0.22360679774997894*JRatfR[19]+0.22360679774997902*JRatfR[18]-0.22360679774997902*JRatfR[17]+0.22360679774997896*JRatfR[16]-0.33541019662496846*JRatfR[15]+0.33541019662496846*JRatfR[14]-0.33541019662496846*JRatfR[13]+0.25*JRatfR[12]+0.33541019662496846*(JRatfR[11]+JRatfR[10])-0.25*JRatfR[9]+0.25*JRatfR[8]-0.33541019662496846*JRatfR[7]+0.33541019662496846*JRatfR[6]-0.25*(JRatfR[5]+JRatfR[4])-0.33541019662496846*JRatfR[3]+0.25*JRatfR[2]-0.25*JRatfR[1]+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[6] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[15])+0.6123724356957944*speedsL[14]-0.3535533905932737*speedsL[13]-0.6123724356957944*speedsL[12]+0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]-0.3535533905932737*speedsL[9]+0.3535533905932737*speedsL[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])+0.3423265984407287*JfL[46]-0.19764235376052366*JfL[45]-0.3423265984407287*JfL[44]+0.3423265984407287*JfL[43]+0.19764235376052364*JfL[42]+0.34232659844072866*JfL[41]-0.19764235376052364*JfL[40]-0.34232659844072866*JfL[39]+0.19764235376052364*JfL[38]+0.34232659844072866*JfL[37]+0.19764235376052366*JfL[36]-0.19764235376052366*JfL[35]-0.3423265984407287*JfL[34]+0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*JfL[27]-0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]-0.3061862178478971*JfL[16]-0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]+0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.2795084971874738*JRatfR[23])+0.2795084971874737*JRatfR[22]-0.2795084971874737*JRatfR[21]+0.2795084971874737*JRatfR[20]+0.2795084971874738*JRatfR[19]-0.2795084971874738*JRatfR[18]+0.2795084971874738*JRatfR[17]-0.2795084971874737*JRatfR[16]+0.25*JRatfR[12]-0.25*JRatfR[9]+0.25*JRatfR[8]-0.25*(JRatfR[5]+JRatfR[4])+0.25*JRatfR[2]-0.25*JRatfR[1]+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[7] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[15])+0.6123724356957944*speedsL[14]-0.3535533905932737*speedsL[13]-0.6123724356957944*speedsL[12]+0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]-0.3535533905932737*speedsL[9]+0.3535533905932737*speedsL[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]-0.27386127875258304*JfL[46]+0.15811388300841892*JfL[45]+0.27386127875258304*JfL[44]-0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]-0.273861278752583*JfL[41]+0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]-0.15811388300841892*JfL[38]-0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]-0.41079191812887433*JfL[30]+0.2371708245126284*JfL[29]+0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]-0.41079191812887433*JfL[24]+0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]+0.41079191812887433*JfL[19]-0.2371708245126284*JfL[18]-0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]+0.2371708245126284*JfL[11]+0.41079191812887433*JfL[10]-0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.22360679774997894*JRatfR[23]-0.22360679774997896*JRatfR[22]+0.22360679774997896*JRatfR[21]-0.22360679774997896*JRatfR[20]-0.22360679774997894*JRatfR[19]+0.22360679774997902*JRatfR[18]-0.22360679774997902*JRatfR[17]+0.22360679774997896*JRatfR[16]+0.33541019662496846*JRatfR[15]-0.33541019662496846*JRatfR[14]+0.33541019662496846*JRatfR[13]+0.25*JRatfR[12]-0.33541019662496846*(JRatfR[11]+JRatfR[10])-0.25*JRatfR[9]+0.25*JRatfR[8]+0.33541019662496846*JRatfR[7]-0.33541019662496846*JRatfR[6]-0.25*(JRatfR[5]+JRatfR[4])+0.33541019662496846*JRatfR[3]+0.25*JRatfR[2]-0.25*JRatfR[1]+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[8] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[15])+0.6123724356957944*speedsL[14]-0.3535533905932737*speedsL[13]-0.6123724356957944*speedsL[12]+0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]-0.3535533905932737*speedsL[9]+0.3535533905932737*speedsL[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])+0.27386127875258304*JfL[46]-0.15811388300841892*JfL[45]-0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]+0.273861278752583*JfL[41]-0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]-0.15811388300841892*JfL[38]-0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]-0.41079191812887433*JfL[30]+0.2371708245126284*JfL[29]+0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]-0.41079191812887433*JfL[24]+0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]-0.41079191812887433*JfL[19]+0.2371708245126284*JfL[18]+0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]-0.2371708245126284*JfL[11]-0.41079191812887433*JfL[10]+0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.22360679774997894*JRatfR[23])+0.22360679774997896*JRatfR[22]-0.22360679774997896*(JRatfR[21]+JRatfR[20])+0.22360679774997894*JRatfR[19]+0.22360679774997902*JRatfR[18]-0.22360679774997902*JRatfR[17]+0.22360679774997896*JRatfR[16]+0.33541019662496846*JRatfR[15]-0.33541019662496846*JRatfR[14]+0.33541019662496846*JRatfR[13]-0.25*JRatfR[12]+0.33541019662496846*JRatfR[11]-0.33541019662496846*JRatfR[10]+0.25*JRatfR[9]-0.25*JRatfR[8]-0.33541019662496846*JRatfR[7]+0.33541019662496846*JRatfR[6]-0.25*JRatfR[5]+0.25*JRatfR[4]-0.33541019662496846*JRatfR[3]+0.25*JRatfR[2]-0.25*JRatfR[1]+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[9] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[15])+0.6123724356957944*speedsL[14]-0.3535533905932737*speedsL[13]-0.6123724356957944*speedsL[12]+0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]-0.3535533905932737*speedsL[9]+0.3535533905932737*speedsL[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]-0.3423265984407287*JfL[46]+0.19764235376052366*JfL[45]+0.3423265984407287*(JfL[44]+JfL[43])-0.19764235376052364*JfL[42]-0.34232659844072866*JfL[41]+0.19764235376052364*JfL[40]-0.34232659844072866*JfL[39]+0.19764235376052364*JfL[38]+0.34232659844072866*JfL[37]-0.19764235376052366*(JfL[36]+JfL[35])-0.3423265984407287*JfL[34]+0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*JfL[27]+0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]-0.3061862178478971*(JfL[20]+JfL[16])+0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]+0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*(JfL[5]+JfL[3])+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.2795084971874738*JRatfR[23]-0.2795084971874737*JRatfR[22]+0.2795084971874737*(JRatfR[21]+JRatfR[20])-0.2795084971874738*(JRatfR[19]+JRatfR[18])+0.2795084971874738*JRatfR[17]-0.2795084971874737*JRatfR[16]-0.25*JRatfR[12]+0.25*JRatfR[9]-0.25*(JRatfR[8]+JRatfR[5])+0.25*(JRatfR[4]+JRatfR[2])-0.25*JRatfR[1]+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[10] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[15])+0.6123724356957944*speedsL[14]-0.3535533905932737*speedsL[13]-0.6123724356957944*speedsL[12]+0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]-0.3535533905932737*speedsL[9]+0.3535533905932737*speedsL[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])+0.27386127875258304*JfL[46]-0.15811388300841892*JfL[45]-0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]+0.273861278752583*JfL[41]-0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]-0.15811388300841892*JfL[38]-0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]+0.41079191812887433*JfL[30]-0.2371708245126284*JfL[29]-0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]+0.41079191812887433*JfL[24]-0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]+0.41079191812887433*JfL[19]-0.2371708245126284*JfL[18]-0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]+0.2371708245126284*JfL[11]+0.41079191812887433*JfL[10]-0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.22360679774997894*JRatfR[23])+0.22360679774997896*JRatfR[22]-0.22360679774997896*(JRatfR[21]+JRatfR[20])+0.22360679774997894*JRatfR[19]+0.22360679774997902*JRatfR[18]-0.22360679774997902*JRatfR[17]+0.22360679774997896*JRatfR[16]-0.33541019662496846*JRatfR[15]+0.33541019662496846*JRatfR[14]-0.33541019662496846*JRatfR[13]-0.25*JRatfR[12]-0.33541019662496846*JRatfR[11]+0.33541019662496846*JRatfR[10]+0.25*JRatfR[9]-0.25*JRatfR[8]+0.33541019662496846*JRatfR[7]-0.33541019662496846*JRatfR[6]-0.25*JRatfR[5]+0.25*JRatfR[4]+0.33541019662496846*JRatfR[3]+0.25*JRatfR[2]-0.25*JRatfR[1]+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[11] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[2].bmag; + Jc_quad = gkdgs[2].Jc; + B3_quad = gkdgs[2].B3; + normcurlbhat_quad = gkdgs[2].normcurlbhat; + bhat_quad[0] = gkdgs[2].bhat.x[0]; + bhat_quad[1] = gkdgs[2].bhat.x[1]; + bhat_quad[2] = gkdgs[2].bhat.x[2]; + area_elem_quad = dgs[2].area_elem; + + + alpha_quad = -(0.6123724356957944*(speedsL[15]+speedsL[14]))-0.3535533905932737*speedsL[13]+0.6123724356957944*speedsL[12]-0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]+0.3535533905932737*(speedsL[9]+speedsL[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.27386127875258304*JfL[46]+0.15811388300841892*JfL[45]-0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]-0.273861278752583*JfL[41]-0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]-0.15811388300841892*JfL[38]+0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*(JfL[31]+JfL[30])-0.2371708245126284*JfL[29]+0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]+0.41079191812887433*JfL[24]+0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]+0.41079191812887433*JfL[19]+0.2371708245126284*JfL[18]-0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]+0.2371708245126284*JfL[11]-0.41079191812887433*JfL[10]-0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.22360679774997894*JRatfR[23]+0.22360679774997896*JRatfR[22]-0.22360679774997896*(JRatfR[21]+JRatfR[20])-0.22360679774997894*JRatfR[19]-0.22360679774997902*JRatfR[18]+0.22360679774997902*JRatfR[17]+0.22360679774997896*JRatfR[16]-0.33541019662496846*(JRatfR[15]+JRatfR[14])+0.33541019662496846*JRatfR[13]+0.25*JRatfR[12]+0.33541019662496846*(JRatfR[11]+JRatfR[10])+0.25*JRatfR[9]-0.25*JRatfR[8]+0.33541019662496846*JRatfR[7]-0.33541019662496846*JRatfR[6]-0.25*(JRatfR[5]+JRatfR[4])-0.33541019662496846*JRatfR[3]-0.25*JRatfR[2]+0.25*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[12] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsL[15]+speedsL[14]))-0.3535533905932737*speedsL[13]+0.6123724356957944*speedsL[12]-0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]+0.3535533905932737*(speedsL[9]+speedsL[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])-0.3423265984407287*JfL[46]-0.19764235376052366*JfL[45]+0.3423265984407287*(JfL[44]+JfL[43])-0.19764235376052364*JfL[42]+0.34232659844072866*JfL[41]+0.19764235376052364*JfL[40]+0.34232659844072866*JfL[39]+0.19764235376052364*JfL[38]-0.34232659844072866*JfL[37]+0.19764235376052366*(JfL[36]+JfL[35])-0.3423265984407287*JfL[34]-0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*(JfL[27]+JfL[22])+0.1767766952966368*JfL[21]-0.3061862178478971*(JfL[20]+JfL[16])+0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]-0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*(JfL[5]+JfL[3])+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.2795084971874738*JRatfR[23])-0.2795084971874737*JRatfR[22]+0.2795084971874737*(JRatfR[21]+JRatfR[20])+0.2795084971874738*(JRatfR[19]+JRatfR[18])-0.2795084971874738*JRatfR[17]-0.2795084971874737*JRatfR[16]+0.25*(JRatfR[12]+JRatfR[9])-0.25*(JRatfR[8]+JRatfR[5]+JRatfR[4]+JRatfR[2])+0.25*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[13] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsL[15]+speedsL[14]))-0.3535533905932737*speedsL[13]+0.6123724356957944*speedsL[12]-0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]+0.3535533905932737*(speedsL[9]+speedsL[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.27386127875258304*JfL[46]+0.15811388300841892*JfL[45]-0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]-0.273861278752583*JfL[41]-0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]-0.15811388300841892*JfL[38]+0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*(JfL[31]+JfL[30])+0.2371708245126284*JfL[29]-0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]-0.41079191812887433*JfL[24]-0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]-0.41079191812887433*JfL[19]-0.2371708245126284*JfL[18]+0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]-0.2371708245126284*JfL[11]+0.41079191812887433*JfL[10]+0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.22360679774997894*JRatfR[23]+0.22360679774997896*JRatfR[22]-0.22360679774997896*(JRatfR[21]+JRatfR[20])-0.22360679774997894*JRatfR[19]-0.22360679774997902*JRatfR[18]+0.22360679774997902*JRatfR[17]+0.22360679774997896*JRatfR[16]+0.33541019662496846*(JRatfR[15]+JRatfR[14])-0.33541019662496846*JRatfR[13]+0.25*JRatfR[12]-0.33541019662496846*(JRatfR[11]+JRatfR[10])+0.25*JRatfR[9]-0.25*JRatfR[8]-0.33541019662496846*JRatfR[7]+0.33541019662496846*JRatfR[6]-0.25*(JRatfR[5]+JRatfR[4])+0.33541019662496846*JRatfR[3]-0.25*JRatfR[2]+0.25*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[14] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsL[15]+speedsL[14]))-0.3535533905932737*speedsL[13]+0.6123724356957944*speedsL[12]-0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]+0.3535533905932737*(speedsL[9]+speedsL[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.27386127875258304*JfL[46]-0.15811388300841892*JfL[45]+0.27386127875258304*JfL[44]-0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]+0.273861278752583*JfL[41]+0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]-0.15811388300841892*JfL[38]+0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*(JfL[31]+JfL[30])+0.2371708245126284*JfL[29]-0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]-0.41079191812887433*JfL[24]-0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]+0.41079191812887433*JfL[19]+0.2371708245126284*JfL[18]-0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]+0.2371708245126284*JfL[11]-0.41079191812887433*JfL[10]-0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.22360679774997894*JRatfR[23])-0.22360679774997896*JRatfR[22]+0.22360679774997896*JRatfR[21]-0.22360679774997896*JRatfR[20]+0.22360679774997894*JRatfR[19]-0.22360679774997902*JRatfR[18]+0.22360679774997902*JRatfR[17]+0.22360679774997896*JRatfR[16]+0.33541019662496846*(JRatfR[15]+JRatfR[14])-0.33541019662496846*JRatfR[13]-0.25*JRatfR[12]+0.33541019662496846*JRatfR[11]-0.33541019662496846*JRatfR[10]-0.25*JRatfR[9]+0.25*JRatfR[8]+0.33541019662496846*JRatfR[7]-0.33541019662496846*JRatfR[6]-0.25*JRatfR[5]+0.25*JRatfR[4]-0.33541019662496846*JRatfR[3]-0.25*JRatfR[2]+0.25*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[15] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsL[15]+speedsL[14]))-0.3535533905932737*speedsL[13]+0.6123724356957944*speedsL[12]-0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]+0.3535533905932737*(speedsL[9]+speedsL[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]+0.3423265984407287*JfL[46]+0.19764235376052366*JfL[45]-0.3423265984407287*JfL[44]+0.3423265984407287*JfL[43]+0.19764235376052364*JfL[42]-0.34232659844072866*JfL[41]-0.19764235376052364*JfL[40]+0.34232659844072866*JfL[39]+0.19764235376052364*JfL[38]-0.34232659844072866*JfL[37]-0.19764235376052366*JfL[36]+0.19764235376052366*JfL[35]-0.3423265984407287*JfL[34]-0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*(JfL[27]+JfL[22])-0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]-0.3061862178478971*JfL[16]-0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]-0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.2795084971874738*JRatfR[23]+0.2795084971874737*JRatfR[22]-0.2795084971874737*JRatfR[21]+0.2795084971874737*JRatfR[20]-0.2795084971874738*JRatfR[19]+0.2795084971874738*JRatfR[18]-0.2795084971874738*JRatfR[17]-0.2795084971874737*JRatfR[16]-0.25*(JRatfR[12]+JRatfR[9])+0.25*JRatfR[8]-0.25*JRatfR[5]+0.25*JRatfR[4]-0.25*JRatfR[2]+0.25*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[16] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsL[15]+speedsL[14]))-0.3535533905932737*speedsL[13]+0.6123724356957944*speedsL[12]-0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]+0.3535533905932737*(speedsL[9]+speedsL[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.27386127875258304*JfL[46]-0.15811388300841892*JfL[45]+0.27386127875258304*JfL[44]-0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]+0.273861278752583*JfL[41]+0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]-0.15811388300841892*JfL[38]+0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*(JfL[31]+JfL[30])-0.2371708245126284*JfL[29]+0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]+0.41079191812887433*JfL[24]+0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]-0.41079191812887433*JfL[19]-0.2371708245126284*JfL[18]+0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]-0.2371708245126284*JfL[11]+0.41079191812887433*JfL[10]+0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.22360679774997894*JRatfR[23])-0.22360679774997896*JRatfR[22]+0.22360679774997896*JRatfR[21]-0.22360679774997896*JRatfR[20]+0.22360679774997894*JRatfR[19]-0.22360679774997902*JRatfR[18]+0.22360679774997902*JRatfR[17]+0.22360679774997896*JRatfR[16]-0.33541019662496846*(JRatfR[15]+JRatfR[14])+0.33541019662496846*JRatfR[13]-0.25*JRatfR[12]-0.33541019662496846*JRatfR[11]+0.33541019662496846*JRatfR[10]-0.25*JRatfR[9]+0.25*JRatfR[8]-0.33541019662496846*JRatfR[7]+0.33541019662496846*JRatfR[6]-0.25*JRatfR[5]+0.25*JRatfR[4]+0.33541019662496846*JRatfR[3]-0.25*JRatfR[2]+0.25*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[17] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[3].bmag; + Jc_quad = gkdgs[3].Jc; + B3_quad = gkdgs[3].B3; + normcurlbhat_quad = gkdgs[3].normcurlbhat; + bhat_quad[0] = gkdgs[3].bhat.x[0]; + bhat_quad[1] = gkdgs[3].bhat.x[1]; + bhat_quad[2] = gkdgs[3].bhat.x[2]; + area_elem_quad = dgs[3].area_elem; + + + alpha_quad = 0.6123724356957944*(speedsL[15]+speedsL[14])+0.3535533905932737*speedsL[13]+0.6123724356957944*speedsL[12]+0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]+0.3535533905932737*(speedsL[9]+speedsL[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.27386127875258304*JfL[46]-0.15811388300841892*JfL[45]-0.27386127875258304*JfL[44]+0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]-0.273861278752583*JfL[41]-0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]+0.15811388300841892*JfL[38]+0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*(JfL[31]+JfL[30])+0.2371708245126284*JfL[29]+0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]+0.41079191812887433*JfL[24]+0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]-0.41079191812887433*JfL[19]-0.2371708245126284*JfL[18]-0.41079191812887433*JfL[17]+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]-0.2371708245126284*JfL[11]-0.41079191812887433*JfL[10]-0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.22360679774997894*JRatfR[23])-0.22360679774997896*(JRatfR[22]+JRatfR[21])+0.22360679774997896*JRatfR[20]-0.22360679774997894*JRatfR[19]+0.22360679774997902*(JRatfR[18]+JRatfR[17])+0.22360679774997896*JRatfR[16]+0.33541019662496846*(JRatfR[15]+JRatfR[14]+JRatfR[13])-0.25*JRatfR[12]-0.33541019662496846*JRatfR[11]+0.33541019662496846*JRatfR[10]-0.25*(JRatfR[9]+JRatfR[8])-0.33541019662496846*(JRatfR[7]+JRatfR[6])+0.25*JRatfR[5]-0.25*JRatfR[4]-0.33541019662496846*JRatfR[3]+0.25*(JRatfR[2]+JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[18] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsL[15]+speedsL[14])+0.3535533905932737*speedsL[13]+0.6123724356957944*speedsL[12]+0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]+0.3535533905932737*(speedsL[9]+speedsL[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]+0.3423265984407287*JfL[46]+0.19764235376052366*JfL[45]+0.3423265984407287*JfL[44]-0.3423265984407287*JfL[43]+0.19764235376052364*JfL[42]+0.34232659844072866*JfL[41]+0.19764235376052364*JfL[40]-0.34232659844072866*JfL[39]-0.19764235376052364*JfL[38]-0.34232659844072866*JfL[37]+0.19764235376052366*JfL[36]-0.19764235376052366*JfL[35]-0.3423265984407287*JfL[34]-0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*(JfL[27]+JfL[22])-0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]+0.3061862178478971*JfL[16]-0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]+0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.2795084971874738*JRatfR[23]+0.2795084971874737*(JRatfR[22]+JRatfR[21])-0.2795084971874737*JRatfR[20]+0.2795084971874738*JRatfR[19]-0.2795084971874738*(JRatfR[18]+JRatfR[17])-0.2795084971874737*JRatfR[16]-0.25*(JRatfR[12]+JRatfR[9]+JRatfR[8])+0.25*JRatfR[5]-0.25*JRatfR[4]+0.25*(JRatfR[2]+JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[19] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsL[15]+speedsL[14])+0.3535533905932737*speedsL[13]+0.6123724356957944*speedsL[12]+0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]+0.3535533905932737*(speedsL[9]+speedsL[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.27386127875258304*JfL[46]-0.15811388300841892*JfL[45]-0.27386127875258304*JfL[44]+0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]-0.273861278752583*JfL[41]-0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]+0.15811388300841892*JfL[38]+0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*(JfL[31]+JfL[30])-0.2371708245126284*JfL[29]-0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]-0.41079191812887433*JfL[24]-0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]+0.41079191812887433*JfL[19]+0.2371708245126284*JfL[18]+0.41079191812887433*JfL[17]+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]+0.2371708245126284*JfL[11]+0.41079191812887433*JfL[10]+0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.22360679774997894*JRatfR[23])-0.22360679774997896*(JRatfR[22]+JRatfR[21])+0.22360679774997896*JRatfR[20]-0.22360679774997894*JRatfR[19]+0.22360679774997902*(JRatfR[18]+JRatfR[17])+0.22360679774997896*JRatfR[16]-0.33541019662496846*(JRatfR[15]+JRatfR[14]+JRatfR[13])-0.25*JRatfR[12]+0.33541019662496846*JRatfR[11]-0.33541019662496846*JRatfR[10]-0.25*(JRatfR[9]+JRatfR[8])+0.33541019662496846*(JRatfR[7]+JRatfR[6])+0.25*JRatfR[5]-0.25*JRatfR[4]+0.33541019662496846*JRatfR[3]+0.25*(JRatfR[2]+JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[20] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsL[15]+speedsL[14])+0.3535533905932737*speedsL[13]+0.6123724356957944*speedsL[12]+0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]+0.3535533905932737*(speedsL[9]+speedsL[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.27386127875258304*JfL[46]+0.15811388300841892*JfL[45]+0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]+0.273861278752583*JfL[41]+0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]+0.15811388300841892*JfL[38]+0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*(JfL[31]+JfL[30])-0.2371708245126284*JfL[29]-0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]-0.41079191812887433*JfL[24]-0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]-0.41079191812887433*JfL[19]-0.2371708245126284*JfL[18]-0.41079191812887433*JfL[17]+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]-0.2371708245126284*JfL[11]-0.41079191812887433*JfL[10]-0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.22360679774997894*JRatfR[23]+0.22360679774997896*(JRatfR[22]+JRatfR[21]+JRatfR[20])+0.22360679774997894*JRatfR[19]+0.22360679774997902*(JRatfR[18]+JRatfR[17])+0.22360679774997896*JRatfR[16]-0.33541019662496846*(JRatfR[15]+JRatfR[14]+JRatfR[13])+0.25*JRatfR[12]-0.33541019662496846*(JRatfR[11]+JRatfR[10])+0.25*(JRatfR[9]+JRatfR[8])-0.33541019662496846*(JRatfR[7]+JRatfR[6])+0.25*(JRatfR[5]+JRatfR[4])-0.33541019662496846*JRatfR[3]+0.25*(JRatfR[2]+JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[21] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsL[15]+speedsL[14])+0.3535533905932737*speedsL[13]+0.6123724356957944*speedsL[12]+0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]+0.3535533905932737*(speedsL[9]+speedsL[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])-0.3423265984407287*JfL[46]-0.19764235376052366*JfL[45]-0.3423265984407287*(JfL[44]+JfL[43])-0.19764235376052364*JfL[42]-0.34232659844072866*JfL[41]-0.19764235376052364*JfL[40]-0.34232659844072866*JfL[39]-0.19764235376052364*JfL[38]-0.34232659844072866*JfL[37]-0.19764235376052366*(JfL[36]+JfL[35])-0.3423265984407287*JfL[34]-0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*(JfL[27]+JfL[22])+0.1767766952966368*JfL[21]+0.3061862178478971*(JfL[20]+JfL[16])+0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]+0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*(JfL[5]+JfL[3])+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.2795084971874738*JRatfR[23])-0.2795084971874737*(JRatfR[22]+JRatfR[21]+JRatfR[20])-0.2795084971874738*(JRatfR[19]+JRatfR[18]+JRatfR[17])-0.2795084971874737*JRatfR[16]+0.25*(JRatfR[12]+JRatfR[9]+JRatfR[8]+JRatfR[5]+JRatfR[4]+JRatfR[2]+JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[22] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsL[15]+speedsL[14])+0.3535533905932737*speedsL[13]+0.6123724356957944*speedsL[12]+0.3535533905932737*speedsL[11]+0.6123724356957944*speedsL[10]+0.3535533905932737*(speedsL[9]+speedsL[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.27386127875258304*JfL[46]+0.15811388300841892*JfL[45]+0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]+0.273861278752583*JfL[41]+0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]+0.15811388300841892*JfL[38]+0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*(JfL[31]+JfL[30])+0.2371708245126284*JfL[29]+0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]+0.41079191812887433*JfL[24]+0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]+0.41079191812887433*JfL[19]+0.2371708245126284*JfL[18]+0.41079191812887433*JfL[17]+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]+0.2371708245126284*JfL[11]+0.41079191812887433*JfL[10]+0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.22360679774997894*JRatfR[23]+0.22360679774997896*(JRatfR[22]+JRatfR[21]+JRatfR[20])+0.22360679774997894*JRatfR[19]+0.22360679774997902*(JRatfR[18]+JRatfR[17])+0.22360679774997896*JRatfR[16]+0.33541019662496846*(JRatfR[15]+JRatfR[14]+JRatfR[13])+0.25*JRatfR[12]+0.33541019662496846*(JRatfR[11]+JRatfR[10])+0.25*(JRatfR[9]+JRatfR[8])+0.33541019662496846*(JRatfR[7]+JRatfR[6])+0.25*(JRatfR[5]+JRatfR[4])+0.33541019662496846*JRatfR[3]+0.25*(JRatfR[2]+JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[23] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdy2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfz_3x2v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfz_3x2v_ser_p1.c new file mode 100644 index 0000000000..a5745ca36a --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfz_3x2v_ser_p1.c @@ -0,0 +1,329 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_edge_surfz_3x2v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdy2 = 2.0/dxv[1]; + double rdz2 = 2.0/dxv[2]; + double rdvpar2 = 2.0/dxv[3]; + + double JRatfR[24] = {0.}; + JRatfR[0] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[3]*JfR[16]+jacobgeo_rat_surfR[2]*JfR[8]+jacobgeo_rat_surfR[1]*JfR[7]+jacobgeo_rat_surfR[0]*JfR[3])-1.4142135623730951*(jacobgeo_rat_surfR[3]*JfR[6]+JfR[2]*jacobgeo_rat_surfR[2]+JfR[1]*jacobgeo_rat_surfR[1]+JfR[0]*jacobgeo_rat_surfR[0]))); + JRatfR[1] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[2]*JfR[16]+jacobgeo_rat_surfR[3]*JfR[8]+jacobgeo_rat_surfR[0]*JfR[7]+jacobgeo_rat_surfR[1]*JfR[3])-1.4142135623730951*(jacobgeo_rat_surfR[2]*JfR[6]+JfR[2]*jacobgeo_rat_surfR[3]+JfR[0]*jacobgeo_rat_surfR[1]+jacobgeo_rat_surfR[0]*JfR[1]))); + JRatfR[2] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[1]*JfR[16]+jacobgeo_rat_surfR[0]*JfR[8]+jacobgeo_rat_surfR[3]*JfR[7]+jacobgeo_rat_surfR[2]*JfR[3])-1.4142135623730951*(jacobgeo_rat_surfR[1]*JfR[6]+JfR[1]*jacobgeo_rat_surfR[3]+JfR[0]*jacobgeo_rat_surfR[2]+jacobgeo_rat_surfR[0]*JfR[2]))); + JRatfR[3] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[3]*JfR[26]+jacobgeo_rat_surfR[2]*JfR[19]+jacobgeo_rat_surfR[1]*JfR[18]+jacobgeo_rat_surfR[0]*JfR[11])-1.4142135623730951*(jacobgeo_rat_surfR[3]*JfR[17]+jacobgeo_rat_surfR[2]*JfR[10]+jacobgeo_rat_surfR[1]*JfR[9]+jacobgeo_rat_surfR[0]*JfR[4]))); + JRatfR[4] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[3]*JfR[27]+jacobgeo_rat_surfR[2]*JfR[22]+jacobgeo_rat_surfR[1]*JfR[21]+jacobgeo_rat_surfR[0]*JfR[14])-1.4142135623730951*(jacobgeo_rat_surfR[3]*JfR[20]+jacobgeo_rat_surfR[2]*JfR[13]+jacobgeo_rat_surfR[1]*JfR[12]+jacobgeo_rat_surfR[0]*JfR[5]))); + JRatfR[5] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[0]*JfR[16]+jacobgeo_rat_surfR[1]*JfR[8]+jacobgeo_rat_surfR[2]*JfR[7]+JfR[3]*jacobgeo_rat_surfR[3])-1.4142135623730951*(jacobgeo_rat_surfR[0]*JfR[6]+JfR[0]*jacobgeo_rat_surfR[3]+JfR[1]*jacobgeo_rat_surfR[2]+jacobgeo_rat_surfR[1]*JfR[2]))); + JRatfR[6] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[2]*JfR[26]+jacobgeo_rat_surfR[3]*JfR[19]+jacobgeo_rat_surfR[0]*JfR[18]+jacobgeo_rat_surfR[1]*JfR[11])-1.4142135623730951*(jacobgeo_rat_surfR[2]*JfR[17]+jacobgeo_rat_surfR[3]*JfR[10]+jacobgeo_rat_surfR[0]*JfR[9]+jacobgeo_rat_surfR[1]*JfR[4]))); + JRatfR[7] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[1]*JfR[26]+jacobgeo_rat_surfR[0]*JfR[19]+jacobgeo_rat_surfR[3]*JfR[18]+jacobgeo_rat_surfR[2]*JfR[11])-1.4142135623730951*(jacobgeo_rat_surfR[1]*JfR[17]+jacobgeo_rat_surfR[0]*JfR[10]+jacobgeo_rat_surfR[3]*JfR[9]+jacobgeo_rat_surfR[2]*JfR[4]))); + JRatfR[8] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[2]*JfR[27]+jacobgeo_rat_surfR[3]*JfR[22]+jacobgeo_rat_surfR[0]*JfR[21]+jacobgeo_rat_surfR[1]*JfR[14])-1.4142135623730951*(jacobgeo_rat_surfR[2]*JfR[20]+jacobgeo_rat_surfR[3]*JfR[13]+jacobgeo_rat_surfR[0]*JfR[12]+jacobgeo_rat_surfR[1]*JfR[5]))); + JRatfR[9] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[1]*JfR[27]+jacobgeo_rat_surfR[0]*JfR[22]+jacobgeo_rat_surfR[3]*JfR[21]+jacobgeo_rat_surfR[2]*JfR[14])-1.4142135623730951*(jacobgeo_rat_surfR[1]*JfR[20]+jacobgeo_rat_surfR[0]*JfR[13]+jacobgeo_rat_surfR[3]*JfR[12]+jacobgeo_rat_surfR[2]*JfR[5]))); + JRatfR[10] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[3]*JfR[31]+jacobgeo_rat_surfR[2]*JfR[30]+jacobgeo_rat_surfR[1]*JfR[29]+jacobgeo_rat_surfR[0]*JfR[25])-1.4142135623730951*(jacobgeo_rat_surfR[3]*JfR[28]+jacobgeo_rat_surfR[2]*JfR[24]+jacobgeo_rat_surfR[1]*JfR[23]+jacobgeo_rat_surfR[0]*JfR[15]))); + JRatfR[11] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[0]*JfR[26]+jacobgeo_rat_surfR[1]*JfR[19]+jacobgeo_rat_surfR[2]*JfR[18]+jacobgeo_rat_surfR[3]*JfR[11])-1.4142135623730951*(jacobgeo_rat_surfR[0]*JfR[17]+jacobgeo_rat_surfR[1]*JfR[10]+jacobgeo_rat_surfR[2]*JfR[9]+jacobgeo_rat_surfR[3]*JfR[4]))); + JRatfR[12] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[0]*JfR[27]+jacobgeo_rat_surfR[1]*JfR[22]+jacobgeo_rat_surfR[2]*JfR[21]+jacobgeo_rat_surfR[3]*JfR[14])-1.4142135623730951*(jacobgeo_rat_surfR[0]*JfR[20]+jacobgeo_rat_surfR[1]*JfR[13]+jacobgeo_rat_surfR[2]*JfR[12]+jacobgeo_rat_surfR[3]*JfR[5]))); + JRatfR[13] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[2]*JfR[31]+jacobgeo_rat_surfR[3]*JfR[30]+jacobgeo_rat_surfR[0]*JfR[29]+jacobgeo_rat_surfR[1]*JfR[25])-1.4142135623730951*(jacobgeo_rat_surfR[2]*JfR[28]+jacobgeo_rat_surfR[3]*JfR[24]+jacobgeo_rat_surfR[0]*JfR[23]+jacobgeo_rat_surfR[1]*JfR[15]))); + JRatfR[14] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[1]*JfR[31]+jacobgeo_rat_surfR[0]*JfR[30]+jacobgeo_rat_surfR[3]*JfR[29]+jacobgeo_rat_surfR[2]*JfR[25])-1.4142135623730951*(jacobgeo_rat_surfR[1]*JfR[28]+jacobgeo_rat_surfR[0]*JfR[24]+jacobgeo_rat_surfR[3]*JfR[23]+jacobgeo_rat_surfR[2]*JfR[15]))); + JRatfR[15] = -(0.25*(2.4494897427831783*(jacobgeo_rat_surfR[0]*JfR[31]+jacobgeo_rat_surfR[1]*JfR[30]+jacobgeo_rat_surfR[2]*JfR[29]+jacobgeo_rat_surfR[3]*JfR[25])-1.4142135623730951*(jacobgeo_rat_surfR[0]*JfR[28]+jacobgeo_rat_surfR[1]*JfR[24]+jacobgeo_rat_surfR[2]*JfR[23]+jacobgeo_rat_surfR[3]*JfR[15]))); + JRatfR[16] = 0.016666666666666666*(8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfR[2]*JfR[34]+jacobgeo_rat_surfR[1]*JfR[33])-4.242640687119286*(jacobgeo_rat_surfR[3]*JfR[43]+jacobgeo_rat_surfR[0]*JfR[35]))-36.742346141747674*(jacobgeo_rat_surfR[2]*JfR[39]+jacobgeo_rat_surfR[1]*JfR[38])+21.213203435596427*(jacobgeo_rat_surfR[3]*JfR[37]+jacobgeo_rat_surfR[0]*JfR[32])); + JRatfR[17] = 0.016666666666666666*(-(36.742346141747674*(jacobgeo_rat_surfR[2]*JfR[43]+jacobgeo_rat_surfR[1]*JfR[35]))+8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfR[2]*JfR[37]+jacobgeo_rat_surfR[1]*JfR[32])-4.242640687119286*(jacobgeo_rat_surfR[3]*JfR[39]+jacobgeo_rat_surfR[0]*JfR[38]))+21.213203435596427*(jacobgeo_rat_surfR[3]*JfR[34]+jacobgeo_rat_surfR[0]*JfR[33])); + JRatfR[18] = 0.016666666666666666*(-(36.742346141747674*(jacobgeo_rat_surfR[1]*JfR[43]+jacobgeo_rat_surfR[2]*JfR[35]))+8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfR[1]*JfR[37]+jacobgeo_rat_surfR[2]*JfR[32])-4.242640687119286*(jacobgeo_rat_surfR[0]*JfR[39]+jacobgeo_rat_surfR[3]*JfR[38]))+21.213203435596427*(jacobgeo_rat_surfR[0]*JfR[34]+jacobgeo_rat_surfR[3]*JfR[33])); + JRatfR[19] = 0.016666666666666666*(8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfR[2]*JfR[41]+jacobgeo_rat_surfR[1]*JfR[40])-4.242640687119286*(jacobgeo_rat_surfR[3]*JfR[47]+jacobgeo_rat_surfR[0]*JfR[42]))-36.742346141747674*(jacobgeo_rat_surfR[2]*JfR[46]+jacobgeo_rat_surfR[1]*JfR[45])+21.213203435596427*(jacobgeo_rat_surfR[3]*JfR[44]+jacobgeo_rat_surfR[0]*JfR[36])); + JRatfR[20] = 0.016666666666666666*(8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfR[1]*JfR[34]+jacobgeo_rat_surfR[2]*JfR[33])-4.242640687119286*(jacobgeo_rat_surfR[0]*JfR[43]+jacobgeo_rat_surfR[3]*JfR[35]))-36.742346141747674*(jacobgeo_rat_surfR[1]*JfR[39]+jacobgeo_rat_surfR[2]*JfR[38])+21.213203435596427*(jacobgeo_rat_surfR[0]*JfR[37]+jacobgeo_rat_surfR[3]*JfR[32])); + JRatfR[21] = 0.016666666666666666*(-(36.742346141747674*(jacobgeo_rat_surfR[2]*JfR[47]+jacobgeo_rat_surfR[1]*JfR[42]))+8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfR[2]*JfR[44]+jacobgeo_rat_surfR[1]*JfR[36])-4.242640687119286*(jacobgeo_rat_surfR[3]*JfR[46]+jacobgeo_rat_surfR[0]*JfR[45]))+21.213203435596427*(jacobgeo_rat_surfR[3]*JfR[41]+jacobgeo_rat_surfR[0]*JfR[40])); + JRatfR[22] = 0.016666666666666666*(-(36.742346141747674*(jacobgeo_rat_surfR[1]*JfR[47]+jacobgeo_rat_surfR[2]*JfR[42]))+8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfR[1]*JfR[44]+jacobgeo_rat_surfR[2]*JfR[36])-4.242640687119286*(jacobgeo_rat_surfR[0]*JfR[46]+jacobgeo_rat_surfR[3]*JfR[45]))+21.213203435596427*(jacobgeo_rat_surfR[0]*JfR[41]+jacobgeo_rat_surfR[3]*JfR[40])); + JRatfR[23] = 0.016666666666666666*(8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfR[1]*JfR[41]+jacobgeo_rat_surfR[2]*JfR[40])-4.242640687119286*(jacobgeo_rat_surfR[0]*JfR[47]+jacobgeo_rat_surfR[3]*JfR[42]))-36.742346141747674*(jacobgeo_rat_surfR[1]*JfR[46]+jacobgeo_rat_surfR[2]*JfR[45])+21.213203435596427*(jacobgeo_rat_surfR[0]*JfR[44]+jacobgeo_rat_surfR[3]*JfR[36])); + + double *flux_surf_nodal = &flux_surf[48]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = 0.6123724356957944*speedsL[23]-0.6123724356957944*(speedsL[22]+speedsL[21])+0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]-0.3535533905932737*(speedsL[18]+speedsL[17])+0.3535533905932737*speedsL[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])+0.27386127875258304*(JfL[46]+JfL[45])-0.15811388300841892*JfL[44]+0.27386127875258304*JfL[43]-0.273861278752583*JfL[42]+0.15811388300841892*(JfL[41]+JfL[40])-0.273861278752583*(JfL[39]+JfL[38])+0.15811388300841892*JfL[37]-0.15811388300841892*JfL[36]+0.27386127875258304*JfL[35]-0.15811388300841894*(JfL[34]+JfL[33])+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]-0.41079191812887433*(JfL[30]+JfL[29])+0.2371708245126284*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.41079191812887433*JfL[25]-0.2371708245126284*(JfL[24]+JfL[23])+0.3061862178478971*(JfL[22]+JfL[21])-0.1767766952966368*JfL[20]+0.41079191812887433*(JfL[19]+JfL[18])-0.2371708245126284*JfL[17]+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.3061862178478971*JfL[14]+0.1767766952966368*(JfL[13]+JfL[12])-0.41079191812887433*JfL[11]+0.2371708245126284*(JfL[10]+JfL[9])-0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*JfL[6]-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]-0.1767766952966368*(JfL[2]+JfL[1])+0.1767766952966368*JfL[0]; + JfR_quad = -(0.22360679774997894*JRatfR[23])+0.22360679774997896*(JRatfR[22]+JRatfR[21]+JRatfR[20])-0.22360679774997894*JRatfR[19]-0.22360679774997902*(JRatfR[18]+JRatfR[17])+0.22360679774997896*JRatfR[16]+0.33541019662496846*JRatfR[15]-0.33541019662496846*(JRatfR[14]+JRatfR[13])-0.25*JRatfR[12]-0.33541019662496846*JRatfR[11]+0.33541019662496846*JRatfR[10]+0.25*(JRatfR[9]+JRatfR[8])+0.33541019662496846*(JRatfR[7]+JRatfR[6])+0.25*JRatfR[5]-0.25*JRatfR[4]-0.33541019662496846*JRatfR[3]-0.25*(JRatfR[2]+JRatfR[1])+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[23]-0.6123724356957944*(speedsL[22]+speedsL[21])+0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]-0.3535533905932737*(speedsL[18]+speedsL[17])+0.3535533905932737*speedsL[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]-0.3423265984407287*(JfL[46]+JfL[45])+0.19764235376052366*JfL[44]-0.3423265984407287*JfL[43]+0.34232659844072866*JfL[42]-0.19764235376052364*(JfL[41]+JfL[40])+0.34232659844072866*(JfL[39]+JfL[38])-0.19764235376052364*JfL[37]+0.19764235376052366*JfL[36]-0.3423265984407287*JfL[35]+0.19764235376052366*(JfL[34]+JfL[33])-0.19764235376052364*JfL[32]-0.3061862178478971*JfL[27]+0.3061862178478971*(JfL[22]+JfL[21])-0.1767766952966368*JfL[20]+0.3061862178478971*JfL[16]-0.3061862178478971*JfL[14]+0.1767766952966368*(JfL[13]+JfL[12])-0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*JfL[6]-0.1767766952966368*JfL[5]+0.3061862178478971*JfL[3]-0.1767766952966368*(JfL[2]+JfL[1])+0.1767766952966368*JfL[0]; + JfR_quad = 0.2795084971874738*JRatfR[23]-0.2795084971874737*(JRatfR[22]+JRatfR[21]+JRatfR[20])+0.2795084971874738*(JRatfR[19]+JRatfR[18]+JRatfR[17])-0.2795084971874737*JRatfR[16]-0.25*JRatfR[12]+0.25*(JRatfR[9]+JRatfR[8]+JRatfR[5])-0.25*(JRatfR[4]+JRatfR[2]+JRatfR[1])+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[23]-0.6123724356957944*(speedsL[22]+speedsL[21])+0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]-0.3535533905932737*(speedsL[18]+speedsL[17])+0.3535533905932737*speedsL[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])+0.27386127875258304*(JfL[46]+JfL[45])-0.15811388300841892*JfL[44]+0.27386127875258304*JfL[43]-0.273861278752583*JfL[42]+0.15811388300841892*(JfL[41]+JfL[40])-0.273861278752583*(JfL[39]+JfL[38])+0.15811388300841892*JfL[37]-0.15811388300841892*JfL[36]+0.27386127875258304*JfL[35]-0.15811388300841894*(JfL[34]+JfL[33])+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]+0.41079191812887433*(JfL[30]+JfL[29])-0.2371708245126284*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.41079191812887433*JfL[25]+0.2371708245126284*(JfL[24]+JfL[23])+0.3061862178478971*(JfL[22]+JfL[21])-0.1767766952966368*JfL[20]-0.41079191812887433*(JfL[19]+JfL[18])+0.2371708245126284*JfL[17]+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.3061862178478971*JfL[14]+0.1767766952966368*(JfL[13]+JfL[12])+0.41079191812887433*JfL[11]-0.2371708245126284*(JfL[10]+JfL[9])-0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*JfL[6]-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]-0.1767766952966368*(JfL[2]+JfL[1])+0.1767766952966368*JfL[0]; + JfR_quad = -(0.22360679774997894*JRatfR[23])+0.22360679774997896*(JRatfR[22]+JRatfR[21]+JRatfR[20])-0.22360679774997894*JRatfR[19]-0.22360679774997902*(JRatfR[18]+JRatfR[17])+0.22360679774997896*JRatfR[16]-0.33541019662496846*JRatfR[15]+0.33541019662496846*(JRatfR[14]+JRatfR[13])-0.25*JRatfR[12]+0.33541019662496846*JRatfR[11]-0.33541019662496846*JRatfR[10]+0.25*(JRatfR[9]+JRatfR[8])-0.33541019662496846*(JRatfR[7]+JRatfR[6])+0.25*JRatfR[5]-0.25*JRatfR[4]+0.33541019662496846*JRatfR[3]-0.25*(JRatfR[2]+JRatfR[1])+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[23]-0.6123724356957944*(speedsL[22]+speedsL[21])+0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]-0.3535533905932737*(speedsL[18]+speedsL[17])+0.3535533905932737*speedsL[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]-0.27386127875258304*(JfL[46]+JfL[45])+0.15811388300841892*JfL[44]+0.27386127875258304*JfL[43]+0.273861278752583*JfL[42]-0.15811388300841892*(JfL[41]+JfL[40])-0.273861278752583*(JfL[39]+JfL[38])+0.15811388300841892*(JfL[37]+JfL[36])+0.27386127875258304*JfL[35]-0.15811388300841894*(JfL[34]+JfL[33])+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]+0.41079191812887433*(JfL[30]+JfL[29])-0.2371708245126284*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*(JfL[26]+JfL[25])+0.2371708245126284*(JfL[24]+JfL[23])-0.3061862178478971*(JfL[22]+JfL[21])+0.1767766952966368*JfL[20]+0.41079191812887433*(JfL[19]+JfL[18])-0.2371708245126284*JfL[17]+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.3061862178478971*JfL[14]-0.1767766952966368*(JfL[13]+JfL[12])-0.41079191812887433*JfL[11]+0.2371708245126284*(JfL[10]+JfL[9])-0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*(JfL[6]+JfL[5])-0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]-0.1767766952966368*(JfL[2]+JfL[1])+0.1767766952966368*JfL[0]; + JfR_quad = 0.22360679774997894*JRatfR[23]-0.22360679774997896*(JRatfR[22]+JRatfR[21])+0.22360679774997896*JRatfR[20]+0.22360679774997894*JRatfR[19]-0.22360679774997902*(JRatfR[18]+JRatfR[17])+0.22360679774997896*JRatfR[16]-0.33541019662496846*JRatfR[15]+0.33541019662496846*(JRatfR[14]+JRatfR[13])+0.25*JRatfR[12]-0.33541019662496846*(JRatfR[11]+JRatfR[10])-0.25*(JRatfR[9]+JRatfR[8])+0.33541019662496846*(JRatfR[7]+JRatfR[6])+0.25*(JRatfR[5]+JRatfR[4])-0.33541019662496846*JRatfR[3]-0.25*(JRatfR[2]+JRatfR[1])+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[3] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[23]-0.6123724356957944*(speedsL[22]+speedsL[21])+0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]-0.3535533905932737*(speedsL[18]+speedsL[17])+0.3535533905932737*speedsL[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])+0.3423265984407287*(JfL[46]+JfL[45])-0.19764235376052366*JfL[44]-0.3423265984407287*JfL[43]-0.34232659844072866*JfL[42]+0.19764235376052364*(JfL[41]+JfL[40])+0.34232659844072866*(JfL[39]+JfL[38])-0.19764235376052364*JfL[37]-0.19764235376052366*JfL[36]-0.3423265984407287*JfL[35]+0.19764235376052366*(JfL[34]+JfL[33])-0.19764235376052364*JfL[32]+0.3061862178478971*JfL[27]-0.3061862178478971*(JfL[22]+JfL[21])+0.1767766952966368*JfL[20]+0.3061862178478971*(JfL[16]+JfL[14])-0.1767766952966368*(JfL[13]+JfL[12])-0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*(JfL[6]+JfL[5])+0.3061862178478971*JfL[3]-0.1767766952966368*(JfL[2]+JfL[1])+0.1767766952966368*JfL[0]; + JfR_quad = -(0.2795084971874738*JRatfR[23])+0.2795084971874737*(JRatfR[22]+JRatfR[21])-0.2795084971874737*JRatfR[20]-0.2795084971874738*JRatfR[19]+0.2795084971874738*(JRatfR[18]+JRatfR[17])-0.2795084971874737*JRatfR[16]+0.25*JRatfR[12]-0.25*(JRatfR[9]+JRatfR[8])+0.25*(JRatfR[5]+JRatfR[4])-0.25*(JRatfR[2]+JRatfR[1])+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[4] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsL[23]-0.6123724356957944*(speedsL[22]+speedsL[21])+0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]-0.3535533905932737*(speedsL[18]+speedsL[17])+0.3535533905932737*speedsL[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]-0.27386127875258304*(JfL[46]+JfL[45])+0.15811388300841892*JfL[44]+0.27386127875258304*JfL[43]+0.273861278752583*JfL[42]-0.15811388300841892*(JfL[41]+JfL[40])-0.273861278752583*(JfL[39]+JfL[38])+0.15811388300841892*(JfL[37]+JfL[36])+0.27386127875258304*JfL[35]-0.15811388300841894*(JfL[34]+JfL[33])+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]-0.41079191812887433*(JfL[30]+JfL[29])+0.2371708245126284*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*(JfL[26]+JfL[25])-0.2371708245126284*(JfL[24]+JfL[23])-0.3061862178478971*(JfL[22]+JfL[21])+0.1767766952966368*JfL[20]-0.41079191812887433*(JfL[19]+JfL[18])+0.2371708245126284*JfL[17]+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.3061862178478971*JfL[14]-0.1767766952966368*(JfL[13]+JfL[12])+0.41079191812887433*JfL[11]-0.2371708245126284*(JfL[10]+JfL[9])-0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*(JfL[6]+JfL[5])+0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]-0.1767766952966368*(JfL[2]+JfL[1])+0.1767766952966368*JfL[0]; + JfR_quad = 0.22360679774997894*JRatfR[23]-0.22360679774997896*(JRatfR[22]+JRatfR[21])+0.22360679774997896*JRatfR[20]+0.22360679774997894*JRatfR[19]-0.22360679774997902*(JRatfR[18]+JRatfR[17])+0.22360679774997896*JRatfR[16]+0.33541019662496846*JRatfR[15]-0.33541019662496846*(JRatfR[14]+JRatfR[13])+0.25*JRatfR[12]+0.33541019662496846*(JRatfR[11]+JRatfR[10])-0.25*(JRatfR[9]+JRatfR[8])-0.33541019662496846*(JRatfR[7]+JRatfR[6])+0.25*(JRatfR[5]+JRatfR[4])+0.33541019662496846*JRatfR[3]-0.25*(JRatfR[2]+JRatfR[1])+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[5] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[1].bmag; + Jc_quad = gkdgs[1].Jc; + B3_quad = gkdgs[1].B3; + normcurlbhat_quad = gkdgs[1].normcurlbhat; + bhat_quad[0] = gkdgs[1].bhat.x[0]; + bhat_quad[1] = gkdgs[1].bhat.x[1]; + bhat_quad[2] = gkdgs[1].bhat.x[2]; + area_elem_quad = dgs[1].area_elem; + + + alpha_quad = -(0.6123724356957944*speedsL[23])+0.6123724356957944*speedsL[22]-0.6123724356957944*speedsL[21]-0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]+0.3535533905932737*speedsL[18]-0.3535533905932737*speedsL[17]+0.3535533905932737*speedsL[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]-0.27386127875258304*JfL[46]+0.27386127875258304*JfL[45]+0.15811388300841892*JfL[44]-0.27386127875258304*JfL[43]-0.273861278752583*JfL[42]-0.15811388300841892*JfL[41]+0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]-0.273861278752583*JfL[38]-0.15811388300841892*(JfL[37]+JfL[36])+0.27386127875258304*JfL[35]+0.15811388300841894*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]+0.41079191812887433*JfL[30]-0.41079191812887433*JfL[29]-0.2371708245126284*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*(JfL[26]+JfL[25])+0.2371708245126284*JfL[24]-0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]+0.3061862178478971*JfL[21]+0.1767766952966368*JfL[20]-0.41079191812887433*JfL[19]+0.41079191812887433*JfL[18]+0.2371708245126284*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.3061862178478971*JfL[14]-0.1767766952966368*JfL[13]+0.1767766952966368*JfL[12]-0.41079191812887433*JfL[11]-0.2371708245126284*JfL[10]+0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]-0.3061862178478971*JfL[7]-0.1767766952966368*(JfL[6]+JfL[5])-0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]+0.1767766952966368*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.22360679774997894*JRatfR[23]-0.22360679774997896*JRatfR[22]+0.22360679774997896*JRatfR[21]-0.22360679774997896*JRatfR[20]-0.22360679774997894*JRatfR[19]+0.22360679774997902*JRatfR[18]-0.22360679774997902*JRatfR[17]+0.22360679774997896*JRatfR[16]-0.33541019662496846*JRatfR[15]+0.33541019662496846*JRatfR[14]-0.33541019662496846*JRatfR[13]+0.25*JRatfR[12]+0.33541019662496846*(JRatfR[11]+JRatfR[10])-0.25*JRatfR[9]+0.25*JRatfR[8]-0.33541019662496846*JRatfR[7]+0.33541019662496846*JRatfR[6]-0.25*(JRatfR[5]+JRatfR[4])-0.33541019662496846*JRatfR[3]+0.25*JRatfR[2]-0.25*JRatfR[1]+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[6] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[23])+0.6123724356957944*speedsL[22]-0.6123724356957944*speedsL[21]-0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]+0.3535533905932737*speedsL[18]-0.3535533905932737*speedsL[17]+0.3535533905932737*speedsL[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])+0.3423265984407287*JfL[46]-0.3423265984407287*JfL[45]-0.19764235376052366*JfL[44]+0.3423265984407287*JfL[43]+0.34232659844072866*JfL[42]+0.19764235376052364*JfL[41]-0.19764235376052364*JfL[40]-0.34232659844072866*JfL[39]+0.34232659844072866*JfL[38]+0.19764235376052364*JfL[37]+0.19764235376052366*JfL[36]-0.3423265984407287*JfL[35]-0.19764235376052366*JfL[34]+0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*JfL[27]-0.3061862178478971*JfL[22]+0.3061862178478971*JfL[21]+0.1767766952966368*JfL[20]-0.3061862178478971*(JfL[16]+JfL[14])-0.1767766952966368*JfL[13]+0.1767766952966368*JfL[12]+0.3061862178478971*JfL[8]-0.3061862178478971*JfL[7]-0.1767766952966368*(JfL[6]+JfL[5])+0.3061862178478971*JfL[3]+0.1767766952966368*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.2795084971874738*JRatfR[23])+0.2795084971874737*JRatfR[22]-0.2795084971874737*JRatfR[21]+0.2795084971874737*JRatfR[20]+0.2795084971874738*JRatfR[19]-0.2795084971874738*JRatfR[18]+0.2795084971874738*JRatfR[17]-0.2795084971874737*JRatfR[16]+0.25*JRatfR[12]-0.25*JRatfR[9]+0.25*JRatfR[8]-0.25*(JRatfR[5]+JRatfR[4])+0.25*JRatfR[2]-0.25*JRatfR[1]+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[7] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[23])+0.6123724356957944*speedsL[22]-0.6123724356957944*speedsL[21]-0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]+0.3535533905932737*speedsL[18]-0.3535533905932737*speedsL[17]+0.3535533905932737*speedsL[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]-0.27386127875258304*JfL[46]+0.27386127875258304*JfL[45]+0.15811388300841892*JfL[44]-0.27386127875258304*JfL[43]-0.273861278752583*JfL[42]-0.15811388300841892*JfL[41]+0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]-0.273861278752583*JfL[38]-0.15811388300841892*(JfL[37]+JfL[36])+0.27386127875258304*JfL[35]+0.15811388300841894*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]-0.41079191812887433*JfL[30]+0.41079191812887433*JfL[29]+0.2371708245126284*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*(JfL[26]+JfL[25])-0.2371708245126284*JfL[24]+0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]+0.3061862178478971*JfL[21]+0.1767766952966368*JfL[20]+0.41079191812887433*JfL[19]-0.41079191812887433*JfL[18]-0.2371708245126284*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.3061862178478971*JfL[14]-0.1767766952966368*JfL[13]+0.1767766952966368*JfL[12]+0.41079191812887433*JfL[11]+0.2371708245126284*JfL[10]-0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]-0.3061862178478971*JfL[7]-0.1767766952966368*(JfL[6]+JfL[5])+0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]+0.1767766952966368*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.22360679774997894*JRatfR[23]-0.22360679774997896*JRatfR[22]+0.22360679774997896*JRatfR[21]-0.22360679774997896*JRatfR[20]-0.22360679774997894*JRatfR[19]+0.22360679774997902*JRatfR[18]-0.22360679774997902*JRatfR[17]+0.22360679774997896*JRatfR[16]+0.33541019662496846*JRatfR[15]-0.33541019662496846*JRatfR[14]+0.33541019662496846*JRatfR[13]+0.25*JRatfR[12]-0.33541019662496846*(JRatfR[11]+JRatfR[10])-0.25*JRatfR[9]+0.25*JRatfR[8]+0.33541019662496846*JRatfR[7]-0.33541019662496846*JRatfR[6]-0.25*(JRatfR[5]+JRatfR[4])+0.33541019662496846*JRatfR[3]+0.25*JRatfR[2]-0.25*JRatfR[1]+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[8] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[23])+0.6123724356957944*speedsL[22]-0.6123724356957944*speedsL[21]-0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]+0.3535533905932737*speedsL[18]-0.3535533905932737*speedsL[17]+0.3535533905932737*speedsL[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])+0.27386127875258304*JfL[46]-0.27386127875258304*JfL[45]-0.15811388300841892*JfL[44]-0.27386127875258304*JfL[43]+0.273861278752583*JfL[42]+0.15811388300841892*JfL[41]-0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]-0.273861278752583*JfL[38]-0.15811388300841892*JfL[37]+0.15811388300841892*JfL[36]+0.27386127875258304*JfL[35]+0.15811388300841894*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]-0.41079191812887433*JfL[30]+0.41079191812887433*JfL[29]+0.2371708245126284*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.41079191812887433*JfL[25]-0.2371708245126284*JfL[24]+0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]-0.3061862178478971*JfL[21]-0.1767766952966368*JfL[20]-0.41079191812887433*JfL[19]+0.41079191812887433*JfL[18]+0.2371708245126284*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.3061862178478971*JfL[14]+0.1767766952966368*JfL[13]-0.1767766952966368*JfL[12]-0.41079191812887433*JfL[11]-0.2371708245126284*JfL[10]+0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]-0.3061862178478971*JfL[7]-0.1767766952966368*JfL[6]+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]+0.1767766952966368*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.22360679774997894*JRatfR[23])+0.22360679774997896*JRatfR[22]-0.22360679774997896*(JRatfR[21]+JRatfR[20])+0.22360679774997894*JRatfR[19]+0.22360679774997902*JRatfR[18]-0.22360679774997902*JRatfR[17]+0.22360679774997896*JRatfR[16]+0.33541019662496846*JRatfR[15]-0.33541019662496846*JRatfR[14]+0.33541019662496846*JRatfR[13]-0.25*JRatfR[12]+0.33541019662496846*JRatfR[11]-0.33541019662496846*JRatfR[10]+0.25*JRatfR[9]-0.25*JRatfR[8]-0.33541019662496846*JRatfR[7]+0.33541019662496846*JRatfR[6]-0.25*JRatfR[5]+0.25*JRatfR[4]-0.33541019662496846*JRatfR[3]+0.25*JRatfR[2]-0.25*JRatfR[1]+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[9] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[23])+0.6123724356957944*speedsL[22]-0.6123724356957944*speedsL[21]-0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]+0.3535533905932737*speedsL[18]-0.3535533905932737*speedsL[17]+0.3535533905932737*speedsL[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]-0.3423265984407287*JfL[46]+0.3423265984407287*JfL[45]+0.19764235376052366*JfL[44]+0.3423265984407287*JfL[43]-0.34232659844072866*JfL[42]-0.19764235376052364*JfL[41]+0.19764235376052364*JfL[40]-0.34232659844072866*JfL[39]+0.34232659844072866*JfL[38]+0.19764235376052364*JfL[37]-0.19764235376052366*JfL[36]-0.3423265984407287*JfL[35]-0.19764235376052366*JfL[34]+0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*JfL[27]+0.3061862178478971*JfL[22]-0.3061862178478971*JfL[21]-0.1767766952966368*JfL[20]-0.3061862178478971*JfL[16]+0.3061862178478971*JfL[14]+0.1767766952966368*JfL[13]-0.1767766952966368*JfL[12]+0.3061862178478971*JfL[8]-0.3061862178478971*JfL[7]-0.1767766952966368*JfL[6]+0.1767766952966368*JfL[5]+0.3061862178478971*JfL[3]+0.1767766952966368*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.2795084971874738*JRatfR[23]-0.2795084971874737*JRatfR[22]+0.2795084971874737*(JRatfR[21]+JRatfR[20])-0.2795084971874738*(JRatfR[19]+JRatfR[18])+0.2795084971874738*JRatfR[17]-0.2795084971874737*JRatfR[16]-0.25*JRatfR[12]+0.25*JRatfR[9]-0.25*(JRatfR[8]+JRatfR[5])+0.25*(JRatfR[4]+JRatfR[2])-0.25*JRatfR[1]+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[10] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsL[23])+0.6123724356957944*speedsL[22]-0.6123724356957944*speedsL[21]-0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]+0.3535533905932737*speedsL[18]-0.3535533905932737*speedsL[17]+0.3535533905932737*speedsL[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])+0.27386127875258304*JfL[46]-0.27386127875258304*JfL[45]-0.15811388300841892*JfL[44]-0.27386127875258304*JfL[43]+0.273861278752583*JfL[42]+0.15811388300841892*JfL[41]-0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]-0.273861278752583*JfL[38]-0.15811388300841892*JfL[37]+0.15811388300841892*JfL[36]+0.27386127875258304*JfL[35]+0.15811388300841894*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]+0.41079191812887433*JfL[30]-0.41079191812887433*JfL[29]-0.2371708245126284*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.41079191812887433*JfL[25]+0.2371708245126284*JfL[24]-0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]-0.3061862178478971*JfL[21]-0.1767766952966368*JfL[20]+0.41079191812887433*JfL[19]-0.41079191812887433*JfL[18]-0.2371708245126284*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.3061862178478971*JfL[14]+0.1767766952966368*JfL[13]-0.1767766952966368*JfL[12]+0.41079191812887433*JfL[11]+0.2371708245126284*JfL[10]-0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]-0.3061862178478971*JfL[7]-0.1767766952966368*JfL[6]+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]+0.1767766952966368*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.22360679774997894*JRatfR[23])+0.22360679774997896*JRatfR[22]-0.22360679774997896*(JRatfR[21]+JRatfR[20])+0.22360679774997894*JRatfR[19]+0.22360679774997902*JRatfR[18]-0.22360679774997902*JRatfR[17]+0.22360679774997896*JRatfR[16]-0.33541019662496846*JRatfR[15]+0.33541019662496846*JRatfR[14]-0.33541019662496846*JRatfR[13]-0.25*JRatfR[12]-0.33541019662496846*JRatfR[11]+0.33541019662496846*JRatfR[10]+0.25*JRatfR[9]-0.25*JRatfR[8]+0.33541019662496846*JRatfR[7]-0.33541019662496846*JRatfR[6]-0.25*JRatfR[5]+0.25*JRatfR[4]+0.33541019662496846*JRatfR[3]+0.25*JRatfR[2]-0.25*JRatfR[1]+0.25*JRatfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[11] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[2].bmag; + Jc_quad = gkdgs[2].Jc; + B3_quad = gkdgs[2].B3; + normcurlbhat_quad = gkdgs[2].normcurlbhat; + bhat_quad[0] = gkdgs[2].bhat.x[0]; + bhat_quad[1] = gkdgs[2].bhat.x[1]; + bhat_quad[2] = gkdgs[2].bhat.x[2]; + area_elem_quad = dgs[2].area_elem; + + + alpha_quad = -(0.6123724356957944*(speedsL[23]+speedsL[22]))+0.6123724356957944*speedsL[21]-0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]-0.3535533905932737*speedsL[18]+0.3535533905932737*(speedsL[17]+speedsL[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.27386127875258304*JfL[46]-0.27386127875258304*JfL[45]+0.15811388300841892*JfL[44]-0.27386127875258304*JfL[43]-0.273861278752583*JfL[42]+0.15811388300841892*JfL[41]-0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]+0.273861278752583*JfL[38]-0.15811388300841892*(JfL[37]+JfL[36])+0.27386127875258304*JfL[35]-0.15811388300841894*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*(JfL[31]+JfL[30])+0.41079191812887433*JfL[29]-0.2371708245126284*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*(JfL[26]+JfL[25])-0.2371708245126284*JfL[24]+0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]-0.3061862178478971*JfL[21]+0.1767766952966368*JfL[20]+0.41079191812887433*JfL[19]-0.41079191812887433*JfL[18]+0.2371708245126284*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.3061862178478971*JfL[14]+0.1767766952966368*JfL[13]-0.1767766952966368*JfL[12]-0.41079191812887433*JfL[11]+0.2371708245126284*JfL[10]-0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]+0.3061862178478971*JfL[7]-0.1767766952966368*(JfL[6]+JfL[5])-0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]-0.1767766952966368*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.22360679774997894*JRatfR[23]+0.22360679774997896*JRatfR[22]-0.22360679774997896*(JRatfR[21]+JRatfR[20])-0.22360679774997894*JRatfR[19]-0.22360679774997902*JRatfR[18]+0.22360679774997902*JRatfR[17]+0.22360679774997896*JRatfR[16]-0.33541019662496846*(JRatfR[15]+JRatfR[14])+0.33541019662496846*JRatfR[13]+0.25*JRatfR[12]+0.33541019662496846*(JRatfR[11]+JRatfR[10])+0.25*JRatfR[9]-0.25*JRatfR[8]+0.33541019662496846*JRatfR[7]-0.33541019662496846*JRatfR[6]-0.25*(JRatfR[5]+JRatfR[4])-0.33541019662496846*JRatfR[3]-0.25*JRatfR[2]+0.25*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[12] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsL[23]+speedsL[22]))+0.6123724356957944*speedsL[21]-0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]-0.3535533905932737*speedsL[18]+0.3535533905932737*(speedsL[17]+speedsL[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])-0.3423265984407287*JfL[46]+0.3423265984407287*JfL[45]-0.19764235376052366*JfL[44]+0.3423265984407287*JfL[43]+0.34232659844072866*JfL[42]-0.19764235376052364*JfL[41]+0.19764235376052364*JfL[40]+0.34232659844072866*JfL[39]-0.34232659844072866*JfL[38]+0.19764235376052364*JfL[37]+0.19764235376052366*JfL[36]-0.3423265984407287*JfL[35]+0.19764235376052366*JfL[34]-0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*(JfL[27]+JfL[22])-0.3061862178478971*JfL[21]+0.1767766952966368*JfL[20]-0.3061862178478971*(JfL[16]+JfL[14])+0.1767766952966368*JfL[13]-0.1767766952966368*JfL[12]-0.3061862178478971*JfL[8]+0.3061862178478971*JfL[7]-0.1767766952966368*(JfL[6]+JfL[5])+0.3061862178478971*JfL[3]-0.1767766952966368*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.2795084971874738*JRatfR[23])-0.2795084971874737*JRatfR[22]+0.2795084971874737*(JRatfR[21]+JRatfR[20])+0.2795084971874738*(JRatfR[19]+JRatfR[18])-0.2795084971874738*JRatfR[17]-0.2795084971874737*JRatfR[16]+0.25*(JRatfR[12]+JRatfR[9])-0.25*(JRatfR[8]+JRatfR[5]+JRatfR[4]+JRatfR[2])+0.25*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[13] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsL[23]+speedsL[22]))+0.6123724356957944*speedsL[21]-0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]-0.3535533905932737*speedsL[18]+0.3535533905932737*(speedsL[17]+speedsL[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.27386127875258304*JfL[46]-0.27386127875258304*JfL[45]+0.15811388300841892*JfL[44]-0.27386127875258304*JfL[43]-0.273861278752583*JfL[42]+0.15811388300841892*JfL[41]-0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]+0.273861278752583*JfL[38]-0.15811388300841892*(JfL[37]+JfL[36])+0.27386127875258304*JfL[35]-0.15811388300841894*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*(JfL[31]+JfL[30])-0.41079191812887433*JfL[29]+0.2371708245126284*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*(JfL[26]+JfL[25])+0.2371708245126284*JfL[24]-0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]-0.3061862178478971*JfL[21]+0.1767766952966368*JfL[20]-0.41079191812887433*JfL[19]+0.41079191812887433*JfL[18]-0.2371708245126284*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.3061862178478971*JfL[14]+0.1767766952966368*JfL[13]-0.1767766952966368*JfL[12]+0.41079191812887433*JfL[11]-0.2371708245126284*JfL[10]+0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]+0.3061862178478971*JfL[7]-0.1767766952966368*(JfL[6]+JfL[5])+0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]-0.1767766952966368*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.22360679774997894*JRatfR[23]+0.22360679774997896*JRatfR[22]-0.22360679774997896*(JRatfR[21]+JRatfR[20])-0.22360679774997894*JRatfR[19]-0.22360679774997902*JRatfR[18]+0.22360679774997902*JRatfR[17]+0.22360679774997896*JRatfR[16]+0.33541019662496846*(JRatfR[15]+JRatfR[14])-0.33541019662496846*JRatfR[13]+0.25*JRatfR[12]-0.33541019662496846*(JRatfR[11]+JRatfR[10])+0.25*JRatfR[9]-0.25*JRatfR[8]-0.33541019662496846*JRatfR[7]+0.33541019662496846*JRatfR[6]-0.25*(JRatfR[5]+JRatfR[4])+0.33541019662496846*JRatfR[3]-0.25*JRatfR[2]+0.25*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[14] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsL[23]+speedsL[22]))+0.6123724356957944*speedsL[21]-0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]-0.3535533905932737*speedsL[18]+0.3535533905932737*(speedsL[17]+speedsL[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.27386127875258304*JfL[46]+0.27386127875258304*JfL[45]-0.15811388300841892*JfL[44]-0.27386127875258304*JfL[43]+0.273861278752583*JfL[42]-0.15811388300841892*JfL[41]+0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]+0.273861278752583*JfL[38]-0.15811388300841892*JfL[37]+0.15811388300841892*JfL[36]+0.27386127875258304*JfL[35]-0.15811388300841894*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*(JfL[31]+JfL[30])-0.41079191812887433*JfL[29]+0.2371708245126284*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.41079191812887433*JfL[25]+0.2371708245126284*JfL[24]-0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]+0.3061862178478971*JfL[21]-0.1767766952966368*JfL[20]+0.41079191812887433*JfL[19]-0.41079191812887433*JfL[18]+0.2371708245126284*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.3061862178478971*JfL[14]-0.1767766952966368*JfL[13]+0.1767766952966368*JfL[12]-0.41079191812887433*JfL[11]+0.2371708245126284*JfL[10]-0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]+0.3061862178478971*JfL[7]-0.1767766952966368*JfL[6]+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]-0.1767766952966368*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.22360679774997894*JRatfR[23])-0.22360679774997896*JRatfR[22]+0.22360679774997896*JRatfR[21]-0.22360679774997896*JRatfR[20]+0.22360679774997894*JRatfR[19]-0.22360679774997902*JRatfR[18]+0.22360679774997902*JRatfR[17]+0.22360679774997896*JRatfR[16]+0.33541019662496846*(JRatfR[15]+JRatfR[14])-0.33541019662496846*JRatfR[13]-0.25*JRatfR[12]+0.33541019662496846*JRatfR[11]-0.33541019662496846*JRatfR[10]-0.25*JRatfR[9]+0.25*JRatfR[8]+0.33541019662496846*JRatfR[7]-0.33541019662496846*JRatfR[6]-0.25*JRatfR[5]+0.25*JRatfR[4]-0.33541019662496846*JRatfR[3]-0.25*JRatfR[2]+0.25*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[15] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsL[23]+speedsL[22]))+0.6123724356957944*speedsL[21]-0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]-0.3535533905932737*speedsL[18]+0.3535533905932737*(speedsL[17]+speedsL[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]+0.3423265984407287*JfL[46]-0.3423265984407287*JfL[45]+0.19764235376052366*JfL[44]+0.3423265984407287*JfL[43]-0.34232659844072866*JfL[42]+0.19764235376052364*JfL[41]-0.19764235376052364*JfL[40]+0.34232659844072866*JfL[39]-0.34232659844072866*JfL[38]+0.19764235376052364*JfL[37]-0.19764235376052366*JfL[36]-0.3423265984407287*JfL[35]+0.19764235376052366*JfL[34]-0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*(JfL[27]+JfL[22])+0.3061862178478971*JfL[21]-0.1767766952966368*JfL[20]-0.3061862178478971*JfL[16]+0.3061862178478971*JfL[14]-0.1767766952966368*JfL[13]+0.1767766952966368*JfL[12]-0.3061862178478971*JfL[8]+0.3061862178478971*JfL[7]-0.1767766952966368*JfL[6]+0.1767766952966368*JfL[5]+0.3061862178478971*JfL[3]-0.1767766952966368*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.2795084971874738*JRatfR[23]+0.2795084971874737*JRatfR[22]-0.2795084971874737*JRatfR[21]+0.2795084971874737*JRatfR[20]-0.2795084971874738*JRatfR[19]+0.2795084971874738*JRatfR[18]-0.2795084971874738*JRatfR[17]-0.2795084971874737*JRatfR[16]-0.25*(JRatfR[12]+JRatfR[9])+0.25*JRatfR[8]-0.25*JRatfR[5]+0.25*JRatfR[4]-0.25*JRatfR[2]+0.25*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[16] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsL[23]+speedsL[22]))+0.6123724356957944*speedsL[21]-0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]-0.3535533905932737*speedsL[18]+0.3535533905932737*(speedsL[17]+speedsL[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.27386127875258304*JfL[46]+0.27386127875258304*JfL[45]-0.15811388300841892*JfL[44]-0.27386127875258304*JfL[43]+0.273861278752583*JfL[42]-0.15811388300841892*JfL[41]+0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]+0.273861278752583*JfL[38]-0.15811388300841892*JfL[37]+0.15811388300841892*JfL[36]+0.27386127875258304*JfL[35]-0.15811388300841894*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*(JfL[31]+JfL[30])+0.41079191812887433*JfL[29]-0.2371708245126284*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.41079191812887433*JfL[25]-0.2371708245126284*JfL[24]+0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]+0.3061862178478971*JfL[21]-0.1767766952966368*JfL[20]-0.41079191812887433*JfL[19]+0.41079191812887433*JfL[18]-0.2371708245126284*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.3061862178478971*JfL[14]-0.1767766952966368*JfL[13]+0.1767766952966368*JfL[12]+0.41079191812887433*JfL[11]-0.2371708245126284*JfL[10]+0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]+0.3061862178478971*JfL[7]-0.1767766952966368*JfL[6]+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]-0.1767766952966368*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.22360679774997894*JRatfR[23])-0.22360679774997896*JRatfR[22]+0.22360679774997896*JRatfR[21]-0.22360679774997896*JRatfR[20]+0.22360679774997894*JRatfR[19]-0.22360679774997902*JRatfR[18]+0.22360679774997902*JRatfR[17]+0.22360679774997896*JRatfR[16]-0.33541019662496846*(JRatfR[15]+JRatfR[14])+0.33541019662496846*JRatfR[13]-0.25*JRatfR[12]-0.33541019662496846*JRatfR[11]+0.33541019662496846*JRatfR[10]-0.25*JRatfR[9]+0.25*JRatfR[8]-0.33541019662496846*JRatfR[7]+0.33541019662496846*JRatfR[6]-0.25*JRatfR[5]+0.25*JRatfR[4]+0.33541019662496846*JRatfR[3]-0.25*JRatfR[2]+0.25*(JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[17] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[3].bmag; + Jc_quad = gkdgs[3].Jc; + B3_quad = gkdgs[3].B3; + normcurlbhat_quad = gkdgs[3].normcurlbhat; + bhat_quad[0] = gkdgs[3].bhat.x[0]; + bhat_quad[1] = gkdgs[3].bhat.x[1]; + bhat_quad[2] = gkdgs[3].bhat.x[2]; + area_elem_quad = dgs[3].area_elem; + + + alpha_quad = 0.6123724356957944*(speedsL[23]+speedsL[22]+speedsL[21])+0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]+0.3535533905932737*(speedsL[18]+speedsL[17]+speedsL[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.27386127875258304*(JfL[46]+JfL[45])-0.15811388300841892*JfL[44]+0.27386127875258304*JfL[43]-0.273861278752583*JfL[42]-0.15811388300841892*(JfL[41]+JfL[40])+0.273861278752583*(JfL[39]+JfL[38])+0.15811388300841892*JfL[37]-0.15811388300841892*JfL[36]+0.27386127875258304*JfL[35]+0.15811388300841894*(JfL[34]+JfL[33])+0.15811388300841892*JfL[32]+0.41079191812887433*(JfL[31]+JfL[30]+JfL[29])+0.2371708245126284*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.41079191812887433*JfL[25]+0.2371708245126284*(JfL[24]+JfL[23])-0.3061862178478971*(JfL[22]+JfL[21])-0.1767766952966368*JfL[20]-0.41079191812887433*(JfL[19]+JfL[18])-0.2371708245126284*JfL[17]+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.3061862178478971*JfL[14]-0.1767766952966368*(JfL[13]+JfL[12])-0.41079191812887433*JfL[11]-0.2371708245126284*(JfL[10]+JfL[9])+0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*JfL[6]-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]+0.1767766952966368*(JfL[2]+JfL[1]+JfL[0]); + JfR_quad = -(0.22360679774997894*JRatfR[23])-0.22360679774997896*(JRatfR[22]+JRatfR[21])+0.22360679774997896*JRatfR[20]-0.22360679774997894*JRatfR[19]+0.22360679774997902*(JRatfR[18]+JRatfR[17])+0.22360679774997896*JRatfR[16]+0.33541019662496846*(JRatfR[15]+JRatfR[14]+JRatfR[13])-0.25*JRatfR[12]-0.33541019662496846*JRatfR[11]+0.33541019662496846*JRatfR[10]-0.25*(JRatfR[9]+JRatfR[8])-0.33541019662496846*(JRatfR[7]+JRatfR[6])+0.25*JRatfR[5]-0.25*JRatfR[4]-0.33541019662496846*JRatfR[3]+0.25*(JRatfR[2]+JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[18] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsL[23]+speedsL[22]+speedsL[21])+0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]+0.3535533905932737*(speedsL[18]+speedsL[17]+speedsL[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]+0.3423265984407287*(JfL[46]+JfL[45])+0.19764235376052366*JfL[44]-0.3423265984407287*JfL[43]+0.34232659844072866*JfL[42]+0.19764235376052364*(JfL[41]+JfL[40])-0.34232659844072866*(JfL[39]+JfL[38])-0.19764235376052364*JfL[37]+0.19764235376052366*JfL[36]-0.3423265984407287*JfL[35]-0.19764235376052366*(JfL[34]+JfL[33])-0.19764235376052364*JfL[32]-0.3061862178478971*(JfL[27]+JfL[22]+JfL[21])-0.1767766952966368*JfL[20]+0.3061862178478971*JfL[16]-0.3061862178478971*JfL[14]-0.1767766952966368*(JfL[13]+JfL[12])+0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*JfL[6]-0.1767766952966368*JfL[5]+0.3061862178478971*JfL[3]+0.1767766952966368*(JfL[2]+JfL[1]+JfL[0]); + JfR_quad = 0.2795084971874738*JRatfR[23]+0.2795084971874737*(JRatfR[22]+JRatfR[21])-0.2795084971874737*JRatfR[20]+0.2795084971874738*JRatfR[19]-0.2795084971874738*(JRatfR[18]+JRatfR[17])-0.2795084971874737*JRatfR[16]-0.25*(JRatfR[12]+JRatfR[9]+JRatfR[8])+0.25*JRatfR[5]-0.25*JRatfR[4]+0.25*(JRatfR[2]+JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[19] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsL[23]+speedsL[22]+speedsL[21])+0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]+0.3535533905932737*(speedsL[18]+speedsL[17]+speedsL[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.27386127875258304*(JfL[46]+JfL[45])-0.15811388300841892*JfL[44]+0.27386127875258304*JfL[43]-0.273861278752583*JfL[42]-0.15811388300841892*(JfL[41]+JfL[40])+0.273861278752583*(JfL[39]+JfL[38])+0.15811388300841892*JfL[37]-0.15811388300841892*JfL[36]+0.27386127875258304*JfL[35]+0.15811388300841894*(JfL[34]+JfL[33])+0.15811388300841892*JfL[32]-0.41079191812887433*(JfL[31]+JfL[30]+JfL[29])-0.2371708245126284*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.41079191812887433*JfL[25]-0.2371708245126284*(JfL[24]+JfL[23])-0.3061862178478971*(JfL[22]+JfL[21])-0.1767766952966368*JfL[20]+0.41079191812887433*(JfL[19]+JfL[18])+0.2371708245126284*JfL[17]+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.3061862178478971*JfL[14]-0.1767766952966368*(JfL[13]+JfL[12])+0.41079191812887433*JfL[11]+0.2371708245126284*(JfL[10]+JfL[9])+0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*JfL[6]-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]+0.1767766952966368*(JfL[2]+JfL[1]+JfL[0]); + JfR_quad = -(0.22360679774997894*JRatfR[23])-0.22360679774997896*(JRatfR[22]+JRatfR[21])+0.22360679774997896*JRatfR[20]-0.22360679774997894*JRatfR[19]+0.22360679774997902*(JRatfR[18]+JRatfR[17])+0.22360679774997896*JRatfR[16]-0.33541019662496846*(JRatfR[15]+JRatfR[14]+JRatfR[13])-0.25*JRatfR[12]+0.33541019662496846*JRatfR[11]-0.33541019662496846*JRatfR[10]-0.25*(JRatfR[9]+JRatfR[8])+0.33541019662496846*(JRatfR[7]+JRatfR[6])+0.25*JRatfR[5]-0.25*JRatfR[4]+0.33541019662496846*JRatfR[3]+0.25*(JRatfR[2]+JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[20] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsL[23]+speedsL[22]+speedsL[21])+0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]+0.3535533905932737*(speedsL[18]+speedsL[17]+speedsL[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.27386127875258304*(JfL[46]+JfL[45])+0.15811388300841892*JfL[44]+0.27386127875258304*JfL[43]+0.273861278752583*JfL[42]+0.15811388300841892*(JfL[41]+JfL[40])+0.273861278752583*(JfL[39]+JfL[38])+0.15811388300841892*(JfL[37]+JfL[36])+0.27386127875258304*JfL[35]+0.15811388300841894*(JfL[34]+JfL[33])+0.15811388300841892*JfL[32]-0.41079191812887433*(JfL[31]+JfL[30]+JfL[29])-0.2371708245126284*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*(JfL[26]+JfL[25])-0.2371708245126284*(JfL[24]+JfL[23])+0.3061862178478971*(JfL[22]+JfL[21])+0.1767766952966368*JfL[20]-0.41079191812887433*(JfL[19]+JfL[18])-0.2371708245126284*JfL[17]+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.3061862178478971*JfL[14]+0.1767766952966368*(JfL[13]+JfL[12])-0.41079191812887433*JfL[11]-0.2371708245126284*(JfL[10]+JfL[9])+0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*(JfL[6]+JfL[5])-0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]+0.1767766952966368*(JfL[2]+JfL[1]+JfL[0]); + JfR_quad = 0.22360679774997894*JRatfR[23]+0.22360679774997896*(JRatfR[22]+JRatfR[21]+JRatfR[20])+0.22360679774997894*JRatfR[19]+0.22360679774997902*(JRatfR[18]+JRatfR[17])+0.22360679774997896*JRatfR[16]-0.33541019662496846*(JRatfR[15]+JRatfR[14]+JRatfR[13])+0.25*JRatfR[12]-0.33541019662496846*(JRatfR[11]+JRatfR[10])+0.25*(JRatfR[9]+JRatfR[8])-0.33541019662496846*(JRatfR[7]+JRatfR[6])+0.25*(JRatfR[5]+JRatfR[4])-0.33541019662496846*JRatfR[3]+0.25*(JRatfR[2]+JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[21] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsL[23]+speedsL[22]+speedsL[21])+0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]+0.3535533905932737*(speedsL[18]+speedsL[17]+speedsL[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])-0.3423265984407287*(JfL[46]+JfL[45])-0.19764235376052366*JfL[44]-0.3423265984407287*JfL[43]-0.34232659844072866*JfL[42]-0.19764235376052364*(JfL[41]+JfL[40])-0.34232659844072866*(JfL[39]+JfL[38])-0.19764235376052364*JfL[37]-0.19764235376052366*JfL[36]-0.3423265984407287*JfL[35]-0.19764235376052366*(JfL[34]+JfL[33])-0.19764235376052364*JfL[32]+0.3061862178478971*(JfL[27]+JfL[22]+JfL[21])+0.1767766952966368*JfL[20]+0.3061862178478971*(JfL[16]+JfL[14])+0.1767766952966368*(JfL[13]+JfL[12])+0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*(JfL[6]+JfL[5])+0.3061862178478971*JfL[3]+0.1767766952966368*(JfL[2]+JfL[1]+JfL[0]); + JfR_quad = -(0.2795084971874738*JRatfR[23])-0.2795084971874737*(JRatfR[22]+JRatfR[21]+JRatfR[20])-0.2795084971874738*(JRatfR[19]+JRatfR[18]+JRatfR[17])-0.2795084971874737*JRatfR[16]+0.25*(JRatfR[12]+JRatfR[9]+JRatfR[8]+JRatfR[5]+JRatfR[4]+JRatfR[2]+JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[22] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsL[23]+speedsL[22]+speedsL[21])+0.3535533905932737*speedsL[20]+0.6123724356957944*speedsL[19]+0.3535533905932737*(speedsL[18]+speedsL[17]+speedsL[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.27386127875258304*(JfL[46]+JfL[45])+0.15811388300841892*JfL[44]+0.27386127875258304*JfL[43]+0.273861278752583*JfL[42]+0.15811388300841892*(JfL[41]+JfL[40])+0.273861278752583*(JfL[39]+JfL[38])+0.15811388300841892*(JfL[37]+JfL[36])+0.27386127875258304*JfL[35]+0.15811388300841894*(JfL[34]+JfL[33])+0.15811388300841892*JfL[32]+0.41079191812887433*(JfL[31]+JfL[30]+JfL[29])+0.2371708245126284*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*(JfL[26]+JfL[25])+0.2371708245126284*(JfL[24]+JfL[23])+0.3061862178478971*(JfL[22]+JfL[21])+0.1767766952966368*JfL[20]+0.41079191812887433*(JfL[19]+JfL[18])+0.2371708245126284*JfL[17]+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.3061862178478971*JfL[14]+0.1767766952966368*(JfL[13]+JfL[12])+0.41079191812887433*JfL[11]+0.2371708245126284*(JfL[10]+JfL[9])+0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*(JfL[6]+JfL[5])+0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]+0.1767766952966368*(JfL[2]+JfL[1]+JfL[0]); + JfR_quad = 0.22360679774997894*JRatfR[23]+0.22360679774997896*(JRatfR[22]+JRatfR[21]+JRatfR[20])+0.22360679774997894*JRatfR[19]+0.22360679774997902*(JRatfR[18]+JRatfR[17])+0.22360679774997896*JRatfR[16]+0.33541019662496846*(JRatfR[15]+JRatfR[14]+JRatfR[13])+0.25*JRatfR[12]+0.33541019662496846*(JRatfR[11]+JRatfR[10])+0.25*(JRatfR[9]+JRatfR[8])+0.33541019662496846*(JRatfR[7]+JRatfR[6])+0.25*(JRatfR[5]+JRatfR[4])+0.33541019662496846*JRatfR[3]+0.25*(JRatfR[2]+JRatfR[1]+JRatfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[23] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdz2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfx_1x1v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfx_1x1v_ser_p1.c new file mode 100644 index 0000000000..e445896549 --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfx_1x1v_ser_p1.c @@ -0,0 +1,84 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_surfx_1x1v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdvpar2 = 2.0/dxv[1]; + + double JRatfL[3] = {0.}; + + double *flux_surf_nodal = &flux_surf[0]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.0; + JfR_quad = -(0.7745966692414834*JfR[5])+0.4472135954999579*JfR[4]+1.1618950038622249*JfR[3]-0.6708203932499369*JfR[2]-0.8660254037844386*JfR[1]+0.5*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.0; + JfR_quad = 0.9682458365518543*JfR[5]-0.5590169943749475*JfR[4]-0.8660254037844386*JfR[1]+0.5*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.0; + JfR_quad = -(0.7745966692414834*JfR[5])+0.4472135954999579*JfR[4]-1.1618950038622249*JfR[3]+0.6708203932499369*JfR[2]-0.8660254037844386*JfR[1]+0.5*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdx2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfx_1x2v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfx_1x2v_ser_p1.c new file mode 100644 index 0000000000..df10145bb7 --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfx_1x2v_ser_p1.c @@ -0,0 +1,111 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_surfx_1x2v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdvpar2 = 2.0/dxv[1]; + + double JRatfL[6] = {0.}; + + double *flux_surf_nodal = &flux_surf[0]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.0; + JfR_quad = 0.5477225575051661*JfR[11]-0.3162277660168379*JfR[10]-0.5477225575051661*JfR[9]+0.3162277660168379*JfR[8]-0.8215838362577489*JfR[7]+0.4743416490252568*JfR[6]+0.6123724356957944*JfR[5]+0.8215838362577489*JfR[4]-0.3535533905932737*JfR[3]-0.4743416490252568*JfR[2]-0.6123724356957944*JfR[1]+0.3535533905932737*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.0; + JfR_quad = -(0.6846531968814573*JfR[11])+0.39528470752104733*JfR[10]+0.6846531968814574*JfR[9]-0.3952847075210473*JfR[8]+0.6123724356957944*JfR[5]-0.3535533905932737*JfR[3]-0.6123724356957944*JfR[1]+0.3535533905932737*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.0; + JfR_quad = 0.5477225575051661*JfR[11]-0.3162277660168379*JfR[10]-0.5477225575051661*JfR[9]+0.3162277660168379*JfR[8]+0.8215838362577489*JfR[7]-0.4743416490252568*JfR[6]+0.6123724356957944*JfR[5]-0.8215838362577489*JfR[4]-0.3535533905932737*JfR[3]+0.4743416490252568*JfR[2]-0.6123724356957944*JfR[1]+0.3535533905932737*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.0; + JfR_quad = -(0.5477225575051661*JfR[11])+0.3162277660168379*JfR[10]-0.5477225575051661*JfR[9]+0.3162277660168379*JfR[8]+0.8215838362577489*JfR[7]-0.4743416490252568*JfR[6]-0.6123724356957944*JfR[5]+0.8215838362577489*JfR[4]+0.3535533905932737*JfR[3]-0.4743416490252568*JfR[2]-0.6123724356957944*JfR[1]+0.3535533905932737*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[3] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.0; + JfR_quad = 0.6846531968814573*JfR[11]-0.39528470752104733*JfR[10]+0.6846531968814574*JfR[9]-0.3952847075210473*JfR[8]-0.6123724356957944*JfR[5]+0.3535533905932737*JfR[3]-0.6123724356957944*JfR[1]+0.3535533905932737*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[4] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.0; + JfR_quad = -(0.5477225575051661*JfR[11])+0.3162277660168379*JfR[10]-0.5477225575051661*JfR[9]+0.3162277660168379*JfR[8]-0.8215838362577489*JfR[7]+0.4743416490252568*JfR[6]-0.6123724356957944*JfR[5]-0.8215838362577489*JfR[4]+0.3535533905932737*JfR[3]+0.4743416490252568*JfR[2]-0.6123724356957944*JfR[1]+0.3535533905932737*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[5] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdx2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfx_2x2v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfx_2x2v_ser_p1.c new file mode 100644 index 0000000000..420299a545 --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfx_2x2v_ser_p1.c @@ -0,0 +1,188 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_surfx_2x2v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdz2 = 2.0/dxv[1]; + double rdvpar2 = 2.0/dxv[2]; + + double JRatfL[12] = {0.}; + JRatfL[0] = 0.5*(1.7320508075688772*(jacobgeo_rat_surfL[1]*JfL[5]+jacobgeo_rat_surfL[0]*JfL[1])+jacobgeo_rat_surfL[1]*JfL[2]+JfL[0]*jacobgeo_rat_surfL[0]); + JRatfL[1] = 0.5*(1.7320508075688772*(jacobgeo_rat_surfL[0]*JfL[5]+JfL[1]*jacobgeo_rat_surfL[1])+jacobgeo_rat_surfL[0]*JfL[2]+JfL[0]*jacobgeo_rat_surfL[1]); + JRatfL[2] = 0.5*(1.7320508075688772*(jacobgeo_rat_surfL[1]*JfL[11]+jacobgeo_rat_surfL[0]*JfL[6])+jacobgeo_rat_surfL[1]*JfL[7]+jacobgeo_rat_surfL[0]*JfL[3]); + JRatfL[3] = 0.5*(1.7320508075688772*(jacobgeo_rat_surfL[1]*JfL[12]+jacobgeo_rat_surfL[0]*JfL[8])+jacobgeo_rat_surfL[1]*JfL[9]+jacobgeo_rat_surfL[0]*JfL[4]); + JRatfL[4] = 0.5*(1.7320508075688772*(jacobgeo_rat_surfL[0]*JfL[11]+jacobgeo_rat_surfL[1]*JfL[6])+jacobgeo_rat_surfL[0]*JfL[7]+jacobgeo_rat_surfL[1]*JfL[3]); + JRatfL[5] = 0.5*(1.7320508075688772*(jacobgeo_rat_surfL[0]*JfL[12]+jacobgeo_rat_surfL[1]*JfL[8])+jacobgeo_rat_surfL[0]*JfL[9]+jacobgeo_rat_surfL[1]*JfL[4]); + JRatfL[6] = 0.5*(1.7320508075688772*(jacobgeo_rat_surfL[1]*JfL[15]+jacobgeo_rat_surfL[0]*JfL[13])+jacobgeo_rat_surfL[1]*JfL[14]+jacobgeo_rat_surfL[0]*JfL[10]); + JRatfL[7] = 0.5*(1.7320508075688772*(jacobgeo_rat_surfL[0]*JfL[15]+jacobgeo_rat_surfL[1]*JfL[13])+jacobgeo_rat_surfL[0]*JfL[14]+jacobgeo_rat_surfL[1]*JfL[10]); + JRatfL[8] = 0.03333333333333333*(25.980762113533157*jacobgeo_rat_surfL[1]*JfL[20]+8.660254037844387*(1.7320508075688772*jacobgeo_rat_surfL[1]*JfL[18]+3.0*jacobgeo_rat_surfL[0]*JfL[17])+15.0*jacobgeo_rat_surfL[0]*JfL[16]); + JRatfL[9] = 0.03333333333333333*(8.660254037844387*(3.0*jacobgeo_rat_surfL[0]*JfL[20]+1.7320508075688772*jacobgeo_rat_surfL[1]*JfL[16])+15.0*jacobgeo_rat_surfL[0]*JfL[18]+25.980762113533157*jacobgeo_rat_surfL[1]*JfL[17]); + JRatfL[10] = 0.03333333333333333*(25.980762113533157*jacobgeo_rat_surfL[1]*JfL[23]+8.660254037844387*(1.7320508075688772*jacobgeo_rat_surfL[1]*JfL[22]+3.0*jacobgeo_rat_surfL[0]*JfL[21])+15.0*jacobgeo_rat_surfL[0]*JfL[19]); + JRatfL[11] = 0.03333333333333333*(8.660254037844387*(3.0*jacobgeo_rat_surfL[0]*JfL[23]+1.7320508075688772*jacobgeo_rat_surfL[1]*JfL[19])+15.0*jacobgeo_rat_surfL[0]*JfL[22]+25.980762113533157*jacobgeo_rat_surfL[1]*JfL[21]); + + double *flux_surf_nodal = &flux_surf[0]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = 0.8660254037844386*speedsR[3]-0.5*speedsR[2]-0.8660254037844386*speedsR[1]+0.5*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3162277660168379*JRatfL[11]-0.31622776601683794*(JRatfL[10]+JRatfL[9])+0.3162277660168379*JRatfL[8]-0.4743416490252568*JRatfL[7]+0.4743416490252568*JRatfL[6]+0.3535533905932737*JRatfL[5]+0.4743416490252568*JRatfL[4]-0.3535533905932737*JRatfL[3]-0.4743416490252568*JRatfL[2]-0.3535533905932737*JRatfL[1]+0.3535533905932737*JRatfL[0]; + JfR_quad = -(0.3872983346207417*JfR[23])+0.22360679774997896*JfR[22]+0.38729833462074165*(JfR[21]+JfR[20])-0.22360679774997894*JfR[19]-0.22360679774997902*JfR[18]-0.3872983346207417*JfR[17]+0.22360679774997896*JfR[16]+0.5809475019311124*JfR[15]-0.33541019662496846*JfR[14]-0.5809475019311124*JfR[13]-0.4330127018922193*JfR[12]-0.5809475019311124*JfR[11]+0.33541019662496846*JfR[10]+0.25*JfR[9]+0.4330127018922193*JfR[8]+0.33541019662496846*JfR[7]+0.5809475019311124*JfR[6]+0.4330127018922193*JfR[5]-0.25*JfR[4]-0.33541019662496846*JfR[3]-0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsR[3]-0.5*speedsR[2]-0.8660254037844386*speedsR[1]+0.5*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3952847075210473*JRatfL[11])+0.39528470752104733*(JRatfL[10]+JRatfL[9])-0.3952847075210473*JRatfL[8]+0.3535533905932737*JRatfL[5]-0.3535533905932737*(JRatfL[3]+JRatfL[1])+0.3535533905932737*JRatfL[0]; + JfR_quad = 0.4841229182759271*JfR[23]-0.2795084971874737*JfR[22]-0.4841229182759271*(JfR[21]+JfR[20])+0.2795084971874738*(JfR[19]+JfR[18])+0.4841229182759271*JfR[17]-0.2795084971874737*JfR[16]-0.4330127018922193*JfR[12]+0.25*JfR[9]+0.4330127018922193*(JfR[8]+JfR[5])-0.25*(JfR[4]+JfR[2])-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsR[3]-0.5*speedsR[2]-0.8660254037844386*speedsR[1]+0.5*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3162277660168379*JRatfL[11]-0.31622776601683794*(JRatfL[10]+JRatfL[9])+0.3162277660168379*JRatfL[8]+0.4743416490252568*JRatfL[7]-0.4743416490252568*JRatfL[6]+0.3535533905932737*JRatfL[5]-0.4743416490252568*JRatfL[4]-0.3535533905932737*JRatfL[3]+0.4743416490252568*JRatfL[2]-0.3535533905932737*JRatfL[1]+0.3535533905932737*JRatfL[0]; + JfR_quad = -(0.3872983346207417*JfR[23])+0.22360679774997896*JfR[22]+0.38729833462074165*(JfR[21]+JfR[20])-0.22360679774997894*JfR[19]-0.22360679774997902*JfR[18]-0.3872983346207417*JfR[17]+0.22360679774997896*JfR[16]-0.5809475019311124*JfR[15]+0.33541019662496846*JfR[14]+0.5809475019311124*JfR[13]-0.4330127018922193*JfR[12]+0.5809475019311124*JfR[11]-0.33541019662496846*JfR[10]+0.25*JfR[9]+0.4330127018922193*JfR[8]-0.33541019662496846*JfR[7]-0.5809475019311124*JfR[6]+0.4330127018922193*JfR[5]-0.25*JfR[4]+0.33541019662496846*JfR[3]-0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsR[3]-0.5*speedsR[2]-0.8660254037844386*speedsR[1]+0.5*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3162277660168379*JRatfL[11])+0.31622776601683794*JRatfL[10]-0.31622776601683794*JRatfL[9]+0.3162277660168379*JRatfL[8]+0.4743416490252568*JRatfL[7]-0.4743416490252568*JRatfL[6]-0.3535533905932737*JRatfL[5]+0.4743416490252568*JRatfL[4]+0.3535533905932737*JRatfL[3]-0.4743416490252568*JRatfL[2]-0.3535533905932737*JRatfL[1]+0.3535533905932737*JRatfL[0]; + JfR_quad = 0.3872983346207417*JfR[23]-0.22360679774997896*JfR[22]-0.38729833462074165*JfR[21]+0.38729833462074165*JfR[20]+0.22360679774997894*JfR[19]-0.22360679774997902*JfR[18]-0.3872983346207417*JfR[17]+0.22360679774997896*JfR[16]-0.5809475019311124*JfR[15]+0.33541019662496846*JfR[14]+0.5809475019311124*JfR[13]+0.4330127018922193*JfR[12]-0.5809475019311124*JfR[11]-0.33541019662496846*JfR[10]-0.25*JfR[9]-0.4330127018922193*JfR[8]+0.33541019662496846*JfR[7]+0.5809475019311124*JfR[6]+0.4330127018922193*JfR[5]+0.25*JfR[4]-0.33541019662496846*JfR[3]-0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[3] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsR[3]-0.5*speedsR[2]-0.8660254037844386*speedsR[1]+0.5*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3952847075210473*JRatfL[11]-0.39528470752104733*JRatfL[10]+0.39528470752104733*JRatfL[9]-0.3952847075210473*JRatfL[8]-0.3535533905932737*JRatfL[5]+0.3535533905932737*JRatfL[3]-0.3535533905932737*JRatfL[1]+0.3535533905932737*JRatfL[0]; + JfR_quad = -(0.4841229182759271*JfR[23])+0.2795084971874737*JfR[22]+0.4841229182759271*JfR[21]-0.4841229182759271*JfR[20]-0.2795084971874738*JfR[19]+0.2795084971874738*JfR[18]+0.4841229182759271*JfR[17]-0.2795084971874737*JfR[16]+0.4330127018922193*JfR[12]-0.25*JfR[9]-0.4330127018922193*JfR[8]+0.4330127018922193*JfR[5]+0.25*JfR[4]-0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[4] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsR[3]-0.5*speedsR[2]-0.8660254037844386*speedsR[1]+0.5*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3162277660168379*JRatfL[11])+0.31622776601683794*JRatfL[10]-0.31622776601683794*JRatfL[9]+0.3162277660168379*JRatfL[8]-0.4743416490252568*JRatfL[7]+0.4743416490252568*JRatfL[6]-0.3535533905932737*JRatfL[5]-0.4743416490252568*JRatfL[4]+0.3535533905932737*JRatfL[3]+0.4743416490252568*JRatfL[2]-0.3535533905932737*JRatfL[1]+0.3535533905932737*JRatfL[0]; + JfR_quad = 0.3872983346207417*JfR[23]-0.22360679774997896*JfR[22]-0.38729833462074165*JfR[21]+0.38729833462074165*JfR[20]+0.22360679774997894*JfR[19]-0.22360679774997902*JfR[18]-0.3872983346207417*JfR[17]+0.22360679774997896*JfR[16]+0.5809475019311124*JfR[15]-0.33541019662496846*JfR[14]-0.5809475019311124*JfR[13]+0.4330127018922193*JfR[12]+0.5809475019311124*JfR[11]+0.33541019662496846*JfR[10]-0.25*JfR[9]-0.4330127018922193*JfR[8]-0.33541019662496846*JfR[7]-0.5809475019311124*JfR[6]+0.4330127018922193*JfR[5]+0.25*JfR[4]+0.33541019662496846*JfR[3]-0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[5] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[1].bmag; + Jc_quad = gkdgs[1].Jc; + B3_quad = gkdgs[1].B3; + normcurlbhat_quad = gkdgs[1].normcurlbhat; + bhat_quad[0] = gkdgs[1].bhat.x[0]; + bhat_quad[1] = gkdgs[1].bhat.x[1]; + bhat_quad[2] = gkdgs[1].bhat.x[2]; + area_elem_quad = dgs[1].area_elem; + + + alpha_quad = -(0.8660254037844386*speedsR[3])+0.5*speedsR[2]-0.8660254037844386*speedsR[1]+0.5*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3162277660168379*JRatfL[11])-0.31622776601683794*JRatfL[10]+0.31622776601683794*JRatfL[9]+0.3162277660168379*JRatfL[8]+0.4743416490252568*(JRatfL[7]+JRatfL[6])-0.3535533905932737*JRatfL[5]-0.4743416490252568*JRatfL[4]-0.3535533905932737*JRatfL[3]-0.4743416490252568*JRatfL[2]+0.3535533905932737*(JRatfL[1]+JRatfL[0]); + JfR_quad = 0.3872983346207417*JfR[23]-0.22360679774997896*JfR[22]+0.38729833462074165*JfR[21]-0.38729833462074165*JfR[20]-0.22360679774997894*JfR[19]+0.22360679774997902*JfR[18]-0.3872983346207417*JfR[17]+0.22360679774997896*JfR[16]-0.5809475019311124*JfR[15]+0.33541019662496846*JfR[14]-0.5809475019311124*JfR[13]+0.4330127018922193*JfR[12]+0.5809475019311124*JfR[11]+0.33541019662496846*JfR[10]-0.25*JfR[9]+0.4330127018922193*JfR[8]-0.33541019662496846*JfR[7]+0.5809475019311124*JfR[6]-0.4330127018922193*JfR[5]-0.25*JfR[4]-0.33541019662496846*JfR[3]+0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[6] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsR[3])+0.5*speedsR[2]-0.8660254037844386*speedsR[1]+0.5*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3952847075210473*JRatfL[11]+0.39528470752104733*JRatfL[10]-0.39528470752104733*JRatfL[9]-0.3952847075210473*JRatfL[8]-0.3535533905932737*(JRatfL[5]+JRatfL[3])+0.3535533905932737*(JRatfL[1]+JRatfL[0]); + JfR_quad = -(0.4841229182759271*JfR[23])+0.2795084971874737*JfR[22]-0.4841229182759271*JfR[21]+0.4841229182759271*JfR[20]+0.2795084971874738*JfR[19]-0.2795084971874738*JfR[18]+0.4841229182759271*JfR[17]-0.2795084971874737*JfR[16]+0.4330127018922193*JfR[12]-0.25*JfR[9]+0.4330127018922193*JfR[8]-0.4330127018922193*JfR[5]-0.25*JfR[4]+0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[7] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsR[3])+0.5*speedsR[2]-0.8660254037844386*speedsR[1]+0.5*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3162277660168379*JRatfL[11])-0.31622776601683794*JRatfL[10]+0.31622776601683794*JRatfL[9]+0.3162277660168379*JRatfL[8]-0.4743416490252568*(JRatfL[7]+JRatfL[6])-0.3535533905932737*JRatfL[5]+0.4743416490252568*JRatfL[4]-0.3535533905932737*JRatfL[3]+0.4743416490252568*JRatfL[2]+0.3535533905932737*(JRatfL[1]+JRatfL[0]); + JfR_quad = 0.3872983346207417*JfR[23]-0.22360679774997896*JfR[22]+0.38729833462074165*JfR[21]-0.38729833462074165*JfR[20]-0.22360679774997894*JfR[19]+0.22360679774997902*JfR[18]-0.3872983346207417*JfR[17]+0.22360679774997896*JfR[16]+0.5809475019311124*JfR[15]-0.33541019662496846*JfR[14]+0.5809475019311124*JfR[13]+0.4330127018922193*JfR[12]-0.5809475019311124*JfR[11]-0.33541019662496846*JfR[10]-0.25*JfR[9]+0.4330127018922193*JfR[8]+0.33541019662496846*JfR[7]-0.5809475019311124*JfR[6]-0.4330127018922193*JfR[5]-0.25*JfR[4]+0.33541019662496846*JfR[3]+0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[8] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsR[3])+0.5*speedsR[2]-0.8660254037844386*speedsR[1]+0.5*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3162277660168379*JRatfL[11]+0.31622776601683794*(JRatfL[10]+JRatfL[9])+0.3162277660168379*JRatfL[8]-0.4743416490252568*(JRatfL[7]+JRatfL[6])+0.3535533905932737*JRatfL[5]-0.4743416490252568*JRatfL[4]+0.3535533905932737*JRatfL[3]-0.4743416490252568*JRatfL[2]+0.3535533905932737*(JRatfL[1]+JRatfL[0]); + JfR_quad = -(0.3872983346207417*JfR[23])+0.22360679774997896*JfR[22]-0.38729833462074165*(JfR[21]+JfR[20])+0.22360679774997894*JfR[19]+0.22360679774997902*JfR[18]-0.3872983346207417*JfR[17]+0.22360679774997896*JfR[16]+0.5809475019311124*JfR[15]-0.33541019662496846*JfR[14]+0.5809475019311124*JfR[13]-0.4330127018922193*JfR[12]+0.5809475019311124*JfR[11]-0.33541019662496846*JfR[10]+0.25*JfR[9]-0.4330127018922193*JfR[8]-0.33541019662496846*JfR[7]+0.5809475019311124*JfR[6]-0.4330127018922193*JfR[5]+0.25*JfR[4]-0.33541019662496846*JfR[3]+0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[9] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsR[3])+0.5*speedsR[2]-0.8660254037844386*speedsR[1]+0.5*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3952847075210473*JRatfL[11])-0.39528470752104733*(JRatfL[10]+JRatfL[9])-0.3952847075210473*JRatfL[8]+0.3535533905932737*(JRatfL[5]+JRatfL[3]+JRatfL[1]+JRatfL[0]); + JfR_quad = 0.4841229182759271*JfR[23]-0.2795084971874737*JfR[22]+0.4841229182759271*(JfR[21]+JfR[20])-0.2795084971874738*(JfR[19]+JfR[18])+0.4841229182759271*JfR[17]-0.2795084971874737*JfR[16]-0.4330127018922193*JfR[12]+0.25*JfR[9]-0.4330127018922193*(JfR[8]+JfR[5])+0.25*(JfR[4]+JfR[2])-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[10] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsR[3])+0.5*speedsR[2]-0.8660254037844386*speedsR[1]+0.5*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3162277660168379*JRatfL[11]+0.31622776601683794*(JRatfL[10]+JRatfL[9])+0.3162277660168379*JRatfL[8]+0.4743416490252568*(JRatfL[7]+JRatfL[6])+0.3535533905932737*JRatfL[5]+0.4743416490252568*JRatfL[4]+0.3535533905932737*JRatfL[3]+0.4743416490252568*JRatfL[2]+0.3535533905932737*(JRatfL[1]+JRatfL[0]); + JfR_quad = -(0.3872983346207417*JfR[23])+0.22360679774997896*JfR[22]-0.38729833462074165*(JfR[21]+JfR[20])+0.22360679774997894*JfR[19]+0.22360679774997902*JfR[18]-0.3872983346207417*JfR[17]+0.22360679774997896*JfR[16]-0.5809475019311124*JfR[15]+0.33541019662496846*JfR[14]-0.5809475019311124*JfR[13]-0.4330127018922193*JfR[12]-0.5809475019311124*JfR[11]+0.33541019662496846*JfR[10]+0.25*JfR[9]-0.4330127018922193*JfR[8]+0.33541019662496846*JfR[7]-0.5809475019311124*JfR[6]-0.4330127018922193*JfR[5]+0.25*JfR[4]+0.33541019662496846*JfR[3]+0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[11] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdx2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfx_3x2v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfx_3x2v_ser_p1.c new file mode 100644 index 0000000000..2a0e66b24e --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfx_3x2v_ser_p1.c @@ -0,0 +1,329 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_surfx_3x2v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdy2 = 2.0/dxv[1]; + double rdz2 = 2.0/dxv[2]; + double rdvpar2 = 2.0/dxv[3]; + + double JRatfL[24] = {0.}; + JRatfL[0] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[3]*JfL[16]+jacobgeo_rat_surfL[2]*JfL[7]+jacobgeo_rat_surfL[1]*JfL[6]+jacobgeo_rat_surfL[0]*JfL[1])+1.4142135623730951*(jacobgeo_rat_surfL[3]*JfL[8]+jacobgeo_rat_surfL[2]*JfL[3]+jacobgeo_rat_surfL[1]*JfL[2]+JfL[0]*jacobgeo_rat_surfL[0])); + JRatfL[1] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[2]*JfL[16]+jacobgeo_rat_surfL[3]*JfL[7]+jacobgeo_rat_surfL[0]*JfL[6]+JfL[1]*jacobgeo_rat_surfL[1])+1.4142135623730951*(jacobgeo_rat_surfL[2]*JfL[8]+JfL[3]*jacobgeo_rat_surfL[3]+jacobgeo_rat_surfL[0]*JfL[2]+JfL[0]*jacobgeo_rat_surfL[1])); + JRatfL[2] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[1]*JfL[16]+jacobgeo_rat_surfL[0]*JfL[7]+jacobgeo_rat_surfL[3]*JfL[6]+JfL[1]*jacobgeo_rat_surfL[2])+1.4142135623730951*(jacobgeo_rat_surfL[1]*JfL[8]+JfL[2]*jacobgeo_rat_surfL[3]+jacobgeo_rat_surfL[0]*JfL[3]+JfL[0]*jacobgeo_rat_surfL[2])); + JRatfL[3] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[3]*JfL[26]+jacobgeo_rat_surfL[2]*JfL[18]+jacobgeo_rat_surfL[1]*JfL[17]+jacobgeo_rat_surfL[0]*JfL[9])+1.4142135623730951*(jacobgeo_rat_surfL[3]*JfL[19]+jacobgeo_rat_surfL[2]*JfL[11]+jacobgeo_rat_surfL[1]*JfL[10]+jacobgeo_rat_surfL[0]*JfL[4])); + JRatfL[4] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[3]*JfL[27]+jacobgeo_rat_surfL[2]*JfL[21]+jacobgeo_rat_surfL[1]*JfL[20]+jacobgeo_rat_surfL[0]*JfL[12])+1.4142135623730951*(jacobgeo_rat_surfL[3]*JfL[22]+jacobgeo_rat_surfL[2]*JfL[14]+jacobgeo_rat_surfL[1]*JfL[13]+jacobgeo_rat_surfL[0]*JfL[5])); + JRatfL[5] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[0]*JfL[16]+jacobgeo_rat_surfL[1]*JfL[7]+jacobgeo_rat_surfL[2]*JfL[6]+JfL[1]*jacobgeo_rat_surfL[3])+1.4142135623730951*(jacobgeo_rat_surfL[0]*JfL[8]+JfL[0]*jacobgeo_rat_surfL[3]+jacobgeo_rat_surfL[1]*JfL[3]+JfL[2]*jacobgeo_rat_surfL[2])); + JRatfL[6] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[2]*JfL[26]+jacobgeo_rat_surfL[3]*JfL[18]+jacobgeo_rat_surfL[0]*JfL[17]+jacobgeo_rat_surfL[1]*JfL[9])+1.4142135623730951*(jacobgeo_rat_surfL[2]*JfL[19]+jacobgeo_rat_surfL[3]*JfL[11]+jacobgeo_rat_surfL[0]*JfL[10]+jacobgeo_rat_surfL[1]*JfL[4])); + JRatfL[7] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[1]*JfL[26]+jacobgeo_rat_surfL[0]*JfL[18]+jacobgeo_rat_surfL[3]*JfL[17]+jacobgeo_rat_surfL[2]*JfL[9])+1.4142135623730951*(jacobgeo_rat_surfL[1]*JfL[19]+jacobgeo_rat_surfL[0]*JfL[11]+jacobgeo_rat_surfL[3]*JfL[10]+jacobgeo_rat_surfL[2]*JfL[4])); + JRatfL[8] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[2]*JfL[27]+jacobgeo_rat_surfL[3]*JfL[21]+jacobgeo_rat_surfL[0]*JfL[20]+jacobgeo_rat_surfL[1]*JfL[12])+1.4142135623730951*(jacobgeo_rat_surfL[2]*JfL[22]+jacobgeo_rat_surfL[3]*JfL[14]+jacobgeo_rat_surfL[0]*JfL[13]+jacobgeo_rat_surfL[1]*JfL[5])); + JRatfL[9] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[1]*JfL[27]+jacobgeo_rat_surfL[0]*JfL[21]+jacobgeo_rat_surfL[3]*JfL[20]+jacobgeo_rat_surfL[2]*JfL[12])+1.4142135623730951*(jacobgeo_rat_surfL[1]*JfL[22]+jacobgeo_rat_surfL[0]*JfL[14]+jacobgeo_rat_surfL[3]*JfL[13]+jacobgeo_rat_surfL[2]*JfL[5])); + JRatfL[10] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[3]*JfL[31]+jacobgeo_rat_surfL[2]*JfL[29]+jacobgeo_rat_surfL[1]*JfL[28]+jacobgeo_rat_surfL[0]*JfL[23])+1.4142135623730951*(jacobgeo_rat_surfL[3]*JfL[30]+jacobgeo_rat_surfL[2]*JfL[25]+jacobgeo_rat_surfL[1]*JfL[24]+jacobgeo_rat_surfL[0]*JfL[15])); + JRatfL[11] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[0]*JfL[26]+jacobgeo_rat_surfL[1]*JfL[18]+jacobgeo_rat_surfL[2]*JfL[17]+jacobgeo_rat_surfL[3]*JfL[9])+1.4142135623730951*(jacobgeo_rat_surfL[0]*JfL[19]+jacobgeo_rat_surfL[1]*JfL[11]+jacobgeo_rat_surfL[2]*JfL[10]+jacobgeo_rat_surfL[3]*JfL[4])); + JRatfL[12] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[0]*JfL[27]+jacobgeo_rat_surfL[1]*JfL[21]+jacobgeo_rat_surfL[2]*JfL[20]+jacobgeo_rat_surfL[3]*JfL[12])+1.4142135623730951*(jacobgeo_rat_surfL[0]*JfL[22]+jacobgeo_rat_surfL[1]*JfL[14]+jacobgeo_rat_surfL[2]*JfL[13]+jacobgeo_rat_surfL[3]*JfL[5])); + JRatfL[13] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[2]*JfL[31]+jacobgeo_rat_surfL[3]*JfL[29]+jacobgeo_rat_surfL[0]*JfL[28]+jacobgeo_rat_surfL[1]*JfL[23])+1.4142135623730951*(jacobgeo_rat_surfL[2]*JfL[30]+jacobgeo_rat_surfL[3]*JfL[25]+jacobgeo_rat_surfL[0]*JfL[24]+jacobgeo_rat_surfL[1]*JfL[15])); + JRatfL[14] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[1]*JfL[31]+jacobgeo_rat_surfL[0]*JfL[29]+jacobgeo_rat_surfL[3]*JfL[28]+jacobgeo_rat_surfL[2]*JfL[23])+1.4142135623730951*(jacobgeo_rat_surfL[1]*JfL[30]+jacobgeo_rat_surfL[0]*JfL[25]+jacobgeo_rat_surfL[3]*JfL[24]+jacobgeo_rat_surfL[2]*JfL[15])); + JRatfL[15] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[0]*JfL[31]+jacobgeo_rat_surfL[1]*JfL[29]+jacobgeo_rat_surfL[2]*JfL[28]+jacobgeo_rat_surfL[3]*JfL[23])+1.4142135623730951*(jacobgeo_rat_surfL[0]*JfL[30]+jacobgeo_rat_surfL[1]*JfL[25]+jacobgeo_rat_surfL[2]*JfL[24]+jacobgeo_rat_surfL[3]*JfL[15])); + JRatfL[16] = 0.016666666666666666*(8.660254037844387*(4.242640687119286*(jacobgeo_rat_surfL[3]*JfL[43]+jacobgeo_rat_surfL[0]*JfL[33])+2.4494897427831783*(jacobgeo_rat_surfL[2]*JfL[35]+jacobgeo_rat_surfL[1]*JfL[34]))+21.213203435596427*(jacobgeo_rat_surfL[3]*JfL[39]+jacobgeo_rat_surfL[0]*JfL[32])+36.742346141747674*(jacobgeo_rat_surfL[2]*JfL[38]+jacobgeo_rat_surfL[1]*JfL[37])); + JRatfL[17] = 0.016666666666666666*(36.742346141747674*(jacobgeo_rat_surfL[2]*JfL[43]+jacobgeo_rat_surfL[1]*JfL[33])+8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfL[2]*JfL[39]+jacobgeo_rat_surfL[1]*JfL[32])+4.242640687119286*(jacobgeo_rat_surfL[3]*JfL[38]+jacobgeo_rat_surfL[0]*JfL[37]))+21.213203435596427*(jacobgeo_rat_surfL[3]*JfL[35]+jacobgeo_rat_surfL[0]*JfL[34])); + JRatfL[18] = 0.016666666666666666*(36.742346141747674*(jacobgeo_rat_surfL[1]*JfL[43]+jacobgeo_rat_surfL[2]*JfL[33])+8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfL[1]*JfL[39]+jacobgeo_rat_surfL[2]*JfL[32])+4.242640687119286*(jacobgeo_rat_surfL[0]*JfL[38]+jacobgeo_rat_surfL[3]*JfL[37]))+21.213203435596427*(jacobgeo_rat_surfL[0]*JfL[35]+jacobgeo_rat_surfL[3]*JfL[34])); + JRatfL[19] = 0.016666666666666666*(8.660254037844387*(4.242640687119286*(jacobgeo_rat_surfL[3]*JfL[47]+jacobgeo_rat_surfL[0]*JfL[40])+2.4494897427831783*(jacobgeo_rat_surfL[2]*JfL[42]+jacobgeo_rat_surfL[1]*JfL[41]))+21.213203435596427*(jacobgeo_rat_surfL[3]*JfL[46]+jacobgeo_rat_surfL[0]*JfL[36])+36.742346141747674*(jacobgeo_rat_surfL[2]*JfL[45]+jacobgeo_rat_surfL[1]*JfL[44])); + JRatfL[20] = 0.016666666666666666*(8.660254037844387*(4.242640687119286*(jacobgeo_rat_surfL[0]*JfL[43]+jacobgeo_rat_surfL[3]*JfL[33])+2.4494897427831783*(jacobgeo_rat_surfL[1]*JfL[35]+jacobgeo_rat_surfL[2]*JfL[34]))+21.213203435596427*(jacobgeo_rat_surfL[0]*JfL[39]+jacobgeo_rat_surfL[3]*JfL[32])+36.742346141747674*(jacobgeo_rat_surfL[1]*JfL[38]+jacobgeo_rat_surfL[2]*JfL[37])); + JRatfL[21] = 0.016666666666666666*(36.742346141747674*(jacobgeo_rat_surfL[2]*JfL[47]+jacobgeo_rat_surfL[1]*JfL[40])+8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfL[2]*JfL[46]+jacobgeo_rat_surfL[1]*JfL[36])+4.242640687119286*(jacobgeo_rat_surfL[3]*JfL[45]+jacobgeo_rat_surfL[0]*JfL[44]))+21.213203435596427*(jacobgeo_rat_surfL[3]*JfL[42]+jacobgeo_rat_surfL[0]*JfL[41])); + JRatfL[22] = 0.016666666666666666*(36.742346141747674*(jacobgeo_rat_surfL[1]*JfL[47]+jacobgeo_rat_surfL[2]*JfL[40])+8.660254037844387*(2.4494897427831783*(jacobgeo_rat_surfL[1]*JfL[46]+jacobgeo_rat_surfL[2]*JfL[36])+4.242640687119286*(jacobgeo_rat_surfL[0]*JfL[45]+jacobgeo_rat_surfL[3]*JfL[44]))+21.213203435596427*(jacobgeo_rat_surfL[0]*JfL[42]+jacobgeo_rat_surfL[3]*JfL[41])); + JRatfL[23] = 0.016666666666666666*(8.660254037844387*(4.242640687119286*(jacobgeo_rat_surfL[0]*JfL[47]+jacobgeo_rat_surfL[3]*JfL[40])+2.4494897427831783*(jacobgeo_rat_surfL[1]*JfL[42]+jacobgeo_rat_surfL[2]*JfL[41]))+21.213203435596427*(jacobgeo_rat_surfL[0]*JfL[46]+jacobgeo_rat_surfL[3]*JfL[36])+36.742346141747674*(jacobgeo_rat_surfL[1]*JfL[45]+jacobgeo_rat_surfL[2]*JfL[44])); + + double *flux_surf_nodal = &flux_surf[0]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = -(0.6123724356957944*speedsR[7])+0.3535533905932737*speedsR[6]+0.6123724356957944*(speedsR[5]+speedsR[4])-0.3535533905932737*(speedsR[3]+speedsR[2])-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.22360679774997894*JRatfL[23])+0.22360679774997896*(JRatfL[22]+JRatfL[21]+JRatfL[20])-0.22360679774997894*JRatfL[19]-0.22360679774997902*(JRatfL[18]+JRatfL[17])+0.22360679774997896*JRatfL[16]+0.33541019662496846*JRatfL[15]-0.33541019662496846*(JRatfL[14]+JRatfL[13])-0.25*JRatfL[12]-0.33541019662496846*JRatfL[11]+0.33541019662496846*JRatfL[10]+0.25*(JRatfL[9]+JRatfL[8])+0.33541019662496846*(JRatfL[7]+JRatfL[6])+0.25*JRatfL[5]-0.25*JRatfL[4]-0.33541019662496846*JRatfL[3]-0.25*(JRatfL[2]+JRatfL[1])+0.25*JRatfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.15811388300841892*JfR[46]-0.27386127875258304*(JfR[45]+JfR[44]+JfR[43])+0.15811388300841892*(JfR[42]+JfR[41])+0.273861278752583*JfR[40]+0.15811388300841892*JfR[39]+0.273861278752583*(JfR[38]+JfR[37])-0.15811388300841892*JfR[36]-0.15811388300841894*(JfR[35]+JfR[34])-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.2371708245126284*JfR[30]+0.41079191812887433*(JfR[29]+JfR[28])+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.2371708245126284*(JfR[25]+JfR[24])-0.41079191812887433*JfR[23]-0.1767766952966368*JfR[22]-0.3061862178478971*(JfR[21]+JfR[20])-0.2371708245126284*JfR[19]-0.41079191812887433*(JfR[18]+JfR[17])-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.1767766952966368*(JfR[14]+JfR[13])+0.3061862178478971*JfR[12]+0.2371708245126284*(JfR[11]+JfR[10])+0.41079191812887433*JfR[9]+0.1767766952966368*JfR[8]+0.3061862178478971*(JfR[7]+JfR[6])-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[7])+0.3535533905932737*speedsR[6]+0.6123724356957944*(speedsR[5]+speedsR[4])-0.3535533905932737*(speedsR[3]+speedsR[2])-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.2795084971874738*JRatfL[23]-0.2795084971874737*(JRatfL[22]+JRatfL[21]+JRatfL[20])+0.2795084971874738*(JRatfL[19]+JRatfL[18]+JRatfL[17])-0.2795084971874737*JRatfL[16]-0.25*JRatfL[12]+0.25*(JRatfL[9]+JRatfL[8]+JRatfL[5])-0.25*(JRatfL[4]+JRatfL[2]+JRatfL[1])+0.25*JRatfL[0]; + JfR_quad = -(0.34232659844072866*JfR[47])+0.19764235376052366*JfR[46]+0.3423265984407287*(JfR[45]+JfR[44]+JfR[43])-0.19764235376052364*(JfR[42]+JfR[41])-0.34232659844072866*JfR[40]-0.19764235376052364*JfR[39]-0.34232659844072866*(JfR[38]+JfR[37])+0.19764235376052366*(JfR[36]+JfR[35]+JfR[34])+0.3423265984407287*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*JfR[27]-0.1767766952966368*JfR[22]-0.3061862178478971*(JfR[21]+JfR[20]+JfR[16])+0.1767766952966368*(JfR[14]+JfR[13])+0.3061862178478971*JfR[12]+0.1767766952966368*JfR[8]+0.3061862178478971*(JfR[7]+JfR[6])-0.1767766952966368*(JfR[5]+JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[7])+0.3535533905932737*speedsR[6]+0.6123724356957944*(speedsR[5]+speedsR[4])-0.3535533905932737*(speedsR[3]+speedsR[2])-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.22360679774997894*JRatfL[23])+0.22360679774997896*(JRatfL[22]+JRatfL[21]+JRatfL[20])-0.22360679774997894*JRatfL[19]-0.22360679774997902*(JRatfL[18]+JRatfL[17])+0.22360679774997896*JRatfL[16]-0.33541019662496846*JRatfL[15]+0.33541019662496846*(JRatfL[14]+JRatfL[13])-0.25*JRatfL[12]+0.33541019662496846*JRatfL[11]-0.33541019662496846*JRatfL[10]+0.25*(JRatfL[9]+JRatfL[8])-0.33541019662496846*(JRatfL[7]+JRatfL[6])+0.25*JRatfL[5]-0.25*JRatfL[4]+0.33541019662496846*JRatfL[3]-0.25*(JRatfL[2]+JRatfL[1])+0.25*JRatfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.15811388300841892*JfR[46]-0.27386127875258304*(JfR[45]+JfR[44]+JfR[43])+0.15811388300841892*(JfR[42]+JfR[41])+0.273861278752583*JfR[40]+0.15811388300841892*JfR[39]+0.273861278752583*(JfR[38]+JfR[37])-0.15811388300841892*JfR[36]-0.15811388300841894*(JfR[35]+JfR[34])-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.2371708245126284*JfR[30]-0.41079191812887433*(JfR[29]+JfR[28])+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.2371708245126284*(JfR[25]+JfR[24])+0.41079191812887433*JfR[23]-0.1767766952966368*JfR[22]-0.3061862178478971*(JfR[21]+JfR[20])+0.2371708245126284*JfR[19]+0.41079191812887433*(JfR[18]+JfR[17])-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.1767766952966368*(JfR[14]+JfR[13])+0.3061862178478971*JfR[12]-0.2371708245126284*(JfR[11]+JfR[10])-0.41079191812887433*JfR[9]+0.1767766952966368*JfR[8]+0.3061862178478971*(JfR[7]+JfR[6])-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[7])+0.3535533905932737*speedsR[6]+0.6123724356957944*(speedsR[5]+speedsR[4])-0.3535533905932737*(speedsR[3]+speedsR[2])-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.22360679774997894*JRatfL[23]-0.22360679774997896*(JRatfL[22]+JRatfL[21])+0.22360679774997896*JRatfL[20]+0.22360679774997894*JRatfL[19]-0.22360679774997902*(JRatfL[18]+JRatfL[17])+0.22360679774997896*JRatfL[16]-0.33541019662496846*JRatfL[15]+0.33541019662496846*(JRatfL[14]+JRatfL[13])+0.25*JRatfL[12]-0.33541019662496846*(JRatfL[11]+JRatfL[10])-0.25*(JRatfL[9]+JRatfL[8])+0.33541019662496846*(JRatfL[7]+JRatfL[6])+0.25*(JRatfL[5]+JRatfL[4])-0.33541019662496846*JRatfL[3]-0.25*(JRatfL[2]+JRatfL[1])+0.25*JRatfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.15811388300841892*JfR[46]+0.27386127875258304*(JfR[45]+JfR[44])-0.27386127875258304*JfR[43]-0.15811388300841892*(JfR[42]+JfR[41])-0.273861278752583*JfR[40]+0.15811388300841892*JfR[39]+0.273861278752583*(JfR[38]+JfR[37])+0.15811388300841892*JfR[36]-0.15811388300841894*(JfR[35]+JfR[34])-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.2371708245126284*JfR[30]-0.41079191812887433*(JfR[29]+JfR[28])-0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]+0.2371708245126284*(JfR[25]+JfR[24])+0.41079191812887433*JfR[23]+0.1767766952966368*JfR[22]+0.3061862178478971*(JfR[21]+JfR[20])-0.2371708245126284*JfR[19]-0.41079191812887433*(JfR[18]+JfR[17])-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.1767766952966368*(JfR[14]+JfR[13])-0.3061862178478971*JfR[12]+0.2371708245126284*(JfR[11]+JfR[10])+0.41079191812887433*JfR[9]+0.1767766952966368*JfR[8]+0.3061862178478971*(JfR[7]+JfR[6])+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[3] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[7])+0.3535533905932737*speedsR[6]+0.6123724356957944*(speedsR[5]+speedsR[4])-0.3535533905932737*(speedsR[3]+speedsR[2])-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.2795084971874738*JRatfL[23])+0.2795084971874737*(JRatfL[22]+JRatfL[21])-0.2795084971874737*JRatfL[20]-0.2795084971874738*JRatfL[19]+0.2795084971874738*(JRatfL[18]+JRatfL[17])-0.2795084971874737*JRatfL[16]+0.25*JRatfL[12]-0.25*(JRatfL[9]+JRatfL[8])+0.25*(JRatfL[5]+JRatfL[4])-0.25*(JRatfL[2]+JRatfL[1])+0.25*JRatfL[0]; + JfR_quad = 0.34232659844072866*JfR[47]-0.19764235376052366*JfR[46]-0.3423265984407287*(JfR[45]+JfR[44])+0.3423265984407287*JfR[43]+0.19764235376052364*(JfR[42]+JfR[41])+0.34232659844072866*JfR[40]-0.19764235376052364*JfR[39]-0.34232659844072866*(JfR[38]+JfR[37])-0.19764235376052366*JfR[36]+0.19764235376052366*(JfR[35]+JfR[34])+0.3423265984407287*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*JfR[27]+0.1767766952966368*JfR[22]+0.3061862178478971*(JfR[21]+JfR[20])-0.3061862178478971*JfR[16]-0.1767766952966368*(JfR[14]+JfR[13])-0.3061862178478971*JfR[12]+0.1767766952966368*JfR[8]+0.3061862178478971*(JfR[7]+JfR[6])+0.1767766952966368*JfR[5]-0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[4] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[7])+0.3535533905932737*speedsR[6]+0.6123724356957944*(speedsR[5]+speedsR[4])-0.3535533905932737*(speedsR[3]+speedsR[2])-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.22360679774997894*JRatfL[23]-0.22360679774997896*(JRatfL[22]+JRatfL[21])+0.22360679774997896*JRatfL[20]+0.22360679774997894*JRatfL[19]-0.22360679774997902*(JRatfL[18]+JRatfL[17])+0.22360679774997896*JRatfL[16]+0.33541019662496846*JRatfL[15]-0.33541019662496846*(JRatfL[14]+JRatfL[13])+0.25*JRatfL[12]+0.33541019662496846*(JRatfL[11]+JRatfL[10])-0.25*(JRatfL[9]+JRatfL[8])-0.33541019662496846*(JRatfL[7]+JRatfL[6])+0.25*(JRatfL[5]+JRatfL[4])+0.33541019662496846*JRatfL[3]-0.25*(JRatfL[2]+JRatfL[1])+0.25*JRatfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.15811388300841892*JfR[46]+0.27386127875258304*(JfR[45]+JfR[44])-0.27386127875258304*JfR[43]-0.15811388300841892*(JfR[42]+JfR[41])-0.273861278752583*JfR[40]+0.15811388300841892*JfR[39]+0.273861278752583*(JfR[38]+JfR[37])+0.15811388300841892*JfR[36]-0.15811388300841894*(JfR[35]+JfR[34])-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.2371708245126284*JfR[30]+0.41079191812887433*(JfR[29]+JfR[28])-0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]-0.2371708245126284*(JfR[25]+JfR[24])-0.41079191812887433*JfR[23]+0.1767766952966368*JfR[22]+0.3061862178478971*(JfR[21]+JfR[20])+0.2371708245126284*JfR[19]+0.41079191812887433*(JfR[18]+JfR[17])-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.1767766952966368*(JfR[14]+JfR[13])-0.3061862178478971*JfR[12]-0.2371708245126284*(JfR[11]+JfR[10])-0.41079191812887433*JfR[9]+0.1767766952966368*JfR[8]+0.3061862178478971*(JfR[7]+JfR[6])+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[5] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[1].bmag; + Jc_quad = gkdgs[1].Jc; + B3_quad = gkdgs[1].B3; + normcurlbhat_quad = gkdgs[1].normcurlbhat; + bhat_quad[0] = gkdgs[1].bhat.x[0]; + bhat_quad[1] = gkdgs[1].bhat.x[1]; + bhat_quad[2] = gkdgs[1].bhat.x[2]; + area_elem_quad = dgs[1].area_elem; + + + alpha_quad = 0.6123724356957944*speedsR[7]-0.3535533905932737*speedsR[6]-0.6123724356957944*speedsR[5]+0.6123724356957944*speedsR[4]+0.3535533905932737*speedsR[3]-0.3535533905932737*speedsR[2]-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.22360679774997894*JRatfL[23]-0.22360679774997896*JRatfL[22]+0.22360679774997896*JRatfL[21]-0.22360679774997896*JRatfL[20]-0.22360679774997894*JRatfL[19]+0.22360679774997902*JRatfL[18]-0.22360679774997902*JRatfL[17]+0.22360679774997896*JRatfL[16]-0.33541019662496846*JRatfL[15]+0.33541019662496846*JRatfL[14]-0.33541019662496846*JRatfL[13]+0.25*JRatfL[12]+0.33541019662496846*(JRatfL[11]+JRatfL[10])-0.25*JRatfL[9]+0.25*JRatfL[8]-0.33541019662496846*JRatfL[7]+0.33541019662496846*JRatfL[6]-0.25*(JRatfL[5]+JRatfL[4])-0.33541019662496846*JRatfL[3]+0.25*JRatfL[2]-0.25*JRatfL[1]+0.25*JRatfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.15811388300841892*JfR[46]+0.27386127875258304*JfR[45]-0.27386127875258304*JfR[44]+0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]+0.15811388300841892*JfR[41]+0.273861278752583*JfR[40]-0.15811388300841892*JfR[39]-0.273861278752583*JfR[38]+0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.15811388300841894*JfR[34]-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.2371708245126284*JfR[30]-0.41079191812887433*JfR[29]+0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]-0.2371708245126284*JfR[24]-0.41079191812887433*JfR[23]+0.1767766952966368*JfR[22]+0.3061862178478971*JfR[21]-0.3061862178478971*JfR[20]+0.2371708245126284*JfR[19]+0.41079191812887433*JfR[18]-0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]+0.1767766952966368*JfR[13]+0.3061862178478971*JfR[12]-0.2371708245126284*JfR[11]+0.2371708245126284*JfR[10]+0.41079191812887433*JfR[9]-0.1767766952966368*JfR[8]-0.3061862178478971*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[6] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[7]-0.3535533905932737*speedsR[6]-0.6123724356957944*speedsR[5]+0.6123724356957944*speedsR[4]+0.3535533905932737*speedsR[3]-0.3535533905932737*speedsR[2]-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.2795084971874738*JRatfL[23])+0.2795084971874737*JRatfL[22]-0.2795084971874737*JRatfL[21]+0.2795084971874737*JRatfL[20]+0.2795084971874738*JRatfL[19]-0.2795084971874738*JRatfL[18]+0.2795084971874738*JRatfL[17]-0.2795084971874737*JRatfL[16]+0.25*JRatfL[12]-0.25*JRatfL[9]+0.25*JRatfL[8]-0.25*(JRatfL[5]+JRatfL[4])+0.25*JRatfL[2]-0.25*JRatfL[1]+0.25*JRatfL[0]; + JfR_quad = 0.34232659844072866*JfR[47]-0.19764235376052366*JfR[46]-0.3423265984407287*JfR[45]+0.3423265984407287*JfR[44]-0.3423265984407287*JfR[43]+0.19764235376052364*JfR[42]-0.19764235376052364*JfR[41]-0.34232659844072866*JfR[40]+0.19764235376052364*JfR[39]+0.34232659844072866*JfR[38]-0.34232659844072866*JfR[37]+0.19764235376052366*JfR[36]-0.19764235376052366*JfR[35]+0.19764235376052366*JfR[34]+0.3423265984407287*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*JfR[27]+0.1767766952966368*JfR[22]+0.3061862178478971*JfR[21]-0.3061862178478971*JfR[20]+0.3061862178478971*JfR[16]-0.1767766952966368*JfR[14]+0.1767766952966368*JfR[13]+0.3061862178478971*JfR[12]-0.1767766952966368*JfR[8]-0.3061862178478971*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.1767766952966368*JfR[3]-0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[7] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[7]-0.3535533905932737*speedsR[6]-0.6123724356957944*speedsR[5]+0.6123724356957944*speedsR[4]+0.3535533905932737*speedsR[3]-0.3535533905932737*speedsR[2]-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.22360679774997894*JRatfL[23]-0.22360679774997896*JRatfL[22]+0.22360679774997896*JRatfL[21]-0.22360679774997896*JRatfL[20]-0.22360679774997894*JRatfL[19]+0.22360679774997902*JRatfL[18]-0.22360679774997902*JRatfL[17]+0.22360679774997896*JRatfL[16]+0.33541019662496846*JRatfL[15]-0.33541019662496846*JRatfL[14]+0.33541019662496846*JRatfL[13]+0.25*JRatfL[12]-0.33541019662496846*(JRatfL[11]+JRatfL[10])-0.25*JRatfL[9]+0.25*JRatfL[8]+0.33541019662496846*JRatfL[7]-0.33541019662496846*JRatfL[6]-0.25*(JRatfL[5]+JRatfL[4])+0.33541019662496846*JRatfL[3]+0.25*JRatfL[2]-0.25*JRatfL[1]+0.25*JRatfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.15811388300841892*JfR[46]+0.27386127875258304*JfR[45]-0.27386127875258304*JfR[44]+0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]+0.15811388300841892*JfR[41]+0.273861278752583*JfR[40]-0.15811388300841892*JfR[39]-0.273861278752583*JfR[38]+0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.15811388300841894*JfR[34]-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.2371708245126284*JfR[30]+0.41079191812887433*JfR[29]-0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]+0.2371708245126284*JfR[24]+0.41079191812887433*JfR[23]+0.1767766952966368*JfR[22]+0.3061862178478971*JfR[21]-0.3061862178478971*JfR[20]-0.2371708245126284*JfR[19]-0.41079191812887433*JfR[18]+0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]+0.1767766952966368*JfR[13]+0.3061862178478971*JfR[12]+0.2371708245126284*JfR[11]-0.2371708245126284*JfR[10]-0.41079191812887433*JfR[9]-0.1767766952966368*JfR[8]-0.3061862178478971*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[8] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[7]-0.3535533905932737*speedsR[6]-0.6123724356957944*speedsR[5]+0.6123724356957944*speedsR[4]+0.3535533905932737*speedsR[3]-0.3535533905932737*speedsR[2]-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.22360679774997894*JRatfL[23])+0.22360679774997896*JRatfL[22]-0.22360679774997896*(JRatfL[21]+JRatfL[20])+0.22360679774997894*JRatfL[19]+0.22360679774997902*JRatfL[18]-0.22360679774997902*JRatfL[17]+0.22360679774997896*JRatfL[16]+0.33541019662496846*JRatfL[15]-0.33541019662496846*JRatfL[14]+0.33541019662496846*JRatfL[13]-0.25*JRatfL[12]+0.33541019662496846*JRatfL[11]-0.33541019662496846*JRatfL[10]+0.25*JRatfL[9]-0.25*JRatfL[8]-0.33541019662496846*JRatfL[7]+0.33541019662496846*JRatfL[6]-0.25*JRatfL[5]+0.25*JRatfL[4]-0.33541019662496846*JRatfL[3]+0.25*JRatfL[2]-0.25*JRatfL[1]+0.25*JRatfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.15811388300841892*JfR[46]-0.27386127875258304*JfR[45]+0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]-0.15811388300841892*JfR[41]-0.273861278752583*JfR[40]-0.15811388300841892*JfR[39]-0.273861278752583*JfR[38]+0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.15811388300841894*JfR[34]-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.2371708245126284*JfR[30]+0.41079191812887433*JfR[29]-0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]+0.2371708245126284*JfR[24]+0.41079191812887433*JfR[23]-0.1767766952966368*JfR[22]-0.3061862178478971*JfR[21]+0.3061862178478971*JfR[20]+0.2371708245126284*JfR[19]+0.41079191812887433*JfR[18]-0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]-0.1767766952966368*JfR[13]-0.3061862178478971*JfR[12]-0.2371708245126284*JfR[11]+0.2371708245126284*JfR[10]+0.41079191812887433*JfR[9]-0.1767766952966368*JfR[8]-0.3061862178478971*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[9] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[7]-0.3535533905932737*speedsR[6]-0.6123724356957944*speedsR[5]+0.6123724356957944*speedsR[4]+0.3535533905932737*speedsR[3]-0.3535533905932737*speedsR[2]-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.2795084971874738*JRatfL[23]-0.2795084971874737*JRatfL[22]+0.2795084971874737*(JRatfL[21]+JRatfL[20])-0.2795084971874738*(JRatfL[19]+JRatfL[18])+0.2795084971874738*JRatfL[17]-0.2795084971874737*JRatfL[16]-0.25*JRatfL[12]+0.25*JRatfL[9]-0.25*(JRatfL[8]+JRatfL[5])+0.25*(JRatfL[4]+JRatfL[2])-0.25*JRatfL[1]+0.25*JRatfL[0]; + JfR_quad = -(0.34232659844072866*JfR[47])+0.19764235376052366*JfR[46]+0.3423265984407287*JfR[45]-0.3423265984407287*(JfR[44]+JfR[43])-0.19764235376052364*JfR[42]+0.19764235376052364*JfR[41]+0.34232659844072866*JfR[40]+0.19764235376052364*JfR[39]+0.34232659844072866*JfR[38]-0.34232659844072866*JfR[37]-0.19764235376052366*(JfR[36]+JfR[35])+0.19764235376052366*JfR[34]+0.3423265984407287*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*JfR[27]-0.1767766952966368*JfR[22]-0.3061862178478971*JfR[21]+0.3061862178478971*(JfR[20]+JfR[16])+0.1767766952966368*JfR[14]-0.1767766952966368*JfR[13]-0.3061862178478971*JfR[12]-0.1767766952966368*JfR[8]-0.3061862178478971*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*(JfR[5]+JfR[3])-0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[10] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[7]-0.3535533905932737*speedsR[6]-0.6123724356957944*speedsR[5]+0.6123724356957944*speedsR[4]+0.3535533905932737*speedsR[3]-0.3535533905932737*speedsR[2]-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.22360679774997894*JRatfL[23])+0.22360679774997896*JRatfL[22]-0.22360679774997896*(JRatfL[21]+JRatfL[20])+0.22360679774997894*JRatfL[19]+0.22360679774997902*JRatfL[18]-0.22360679774997902*JRatfL[17]+0.22360679774997896*JRatfL[16]-0.33541019662496846*JRatfL[15]+0.33541019662496846*JRatfL[14]-0.33541019662496846*JRatfL[13]-0.25*JRatfL[12]-0.33541019662496846*JRatfL[11]+0.33541019662496846*JRatfL[10]+0.25*JRatfL[9]-0.25*JRatfL[8]+0.33541019662496846*JRatfL[7]-0.33541019662496846*JRatfL[6]-0.25*JRatfL[5]+0.25*JRatfL[4]+0.33541019662496846*JRatfL[3]+0.25*JRatfL[2]-0.25*JRatfL[1]+0.25*JRatfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.15811388300841892*JfR[46]-0.27386127875258304*JfR[45]+0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]-0.15811388300841892*JfR[41]-0.273861278752583*JfR[40]-0.15811388300841892*JfR[39]-0.273861278752583*JfR[38]+0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.15811388300841894*JfR[34]-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.2371708245126284*JfR[30]-0.41079191812887433*JfR[29]+0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]-0.2371708245126284*JfR[24]-0.41079191812887433*JfR[23]-0.1767766952966368*JfR[22]-0.3061862178478971*JfR[21]+0.3061862178478971*JfR[20]-0.2371708245126284*JfR[19]-0.41079191812887433*JfR[18]+0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]-0.1767766952966368*JfR[13]-0.3061862178478971*JfR[12]+0.2371708245126284*JfR[11]-0.2371708245126284*JfR[10]-0.41079191812887433*JfR[9]-0.1767766952966368*JfR[8]-0.3061862178478971*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[11] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[2].bmag; + Jc_quad = gkdgs[2].Jc; + B3_quad = gkdgs[2].B3; + normcurlbhat_quad = gkdgs[2].normcurlbhat; + bhat_quad[0] = gkdgs[2].bhat.x[0]; + bhat_quad[1] = gkdgs[2].bhat.x[1]; + bhat_quad[2] = gkdgs[2].bhat.x[2]; + area_elem_quad = dgs[2].area_elem; + + + alpha_quad = 0.6123724356957944*speedsR[7]-0.3535533905932737*speedsR[6]+0.6123724356957944*speedsR[5]-0.6123724356957944*speedsR[4]-0.3535533905932737*speedsR[3]+0.3535533905932737*speedsR[2]-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.22360679774997894*JRatfL[23]+0.22360679774997896*JRatfL[22]-0.22360679774997896*(JRatfL[21]+JRatfL[20])-0.22360679774997894*JRatfL[19]-0.22360679774997902*JRatfL[18]+0.22360679774997902*JRatfL[17]+0.22360679774997896*JRatfL[16]-0.33541019662496846*(JRatfL[15]+JRatfL[14])+0.33541019662496846*JRatfL[13]+0.25*JRatfL[12]+0.33541019662496846*(JRatfL[11]+JRatfL[10])+0.25*JRatfL[9]-0.25*JRatfL[8]+0.33541019662496846*JRatfL[7]-0.33541019662496846*JRatfL[6]-0.25*(JRatfL[5]+JRatfL[4])-0.33541019662496846*JRatfL[3]-0.25*JRatfL[2]+0.25*(JRatfL[1]+JRatfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])+0.15811388300841892*JfR[46]-0.27386127875258304*JfR[45]+0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]-0.15811388300841892*JfR[41]+0.273861278752583*JfR[40]-0.15811388300841892*JfR[39]+0.273861278752583*JfR[38]-0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]+0.15811388300841894*JfR[34]-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.2371708245126284*JfR[30]+0.41079191812887433*JfR[29]-0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]+0.2371708245126284*JfR[24]-0.41079191812887433*JfR[23]+0.1767766952966368*JfR[22]-0.3061862178478971*JfR[21]+0.3061862178478971*JfR[20]+0.2371708245126284*JfR[19]-0.41079191812887433*JfR[18]+0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]-0.1767766952966368*JfR[13]+0.3061862178478971*JfR[12]+0.2371708245126284*JfR[11]-0.2371708245126284*JfR[10]+0.41079191812887433*JfR[9]-0.1767766952966368*JfR[8]+0.3061862178478971*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]+0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[12] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[7]-0.3535533905932737*speedsR[6]+0.6123724356957944*speedsR[5]-0.6123724356957944*speedsR[4]-0.3535533905932737*speedsR[3]+0.3535533905932737*speedsR[2]-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.2795084971874738*JRatfL[23])-0.2795084971874737*JRatfL[22]+0.2795084971874737*(JRatfL[21]+JRatfL[20])+0.2795084971874738*(JRatfL[19]+JRatfL[18])-0.2795084971874738*JRatfL[17]-0.2795084971874737*JRatfL[16]+0.25*(JRatfL[12]+JRatfL[9])-0.25*(JRatfL[8]+JRatfL[5]+JRatfL[4]+JRatfL[2])+0.25*(JRatfL[1]+JRatfL[0]); + JfR_quad = 0.34232659844072866*JfR[47]-0.19764235376052366*JfR[46]+0.3423265984407287*JfR[45]-0.3423265984407287*(JfR[44]+JfR[43])-0.19764235376052364*JfR[42]+0.19764235376052364*JfR[41]-0.34232659844072866*JfR[40]+0.19764235376052364*JfR[39]-0.34232659844072866*JfR[38]+0.34232659844072866*JfR[37]+0.19764235376052366*(JfR[36]+JfR[35])-0.19764235376052366*JfR[34]+0.3423265984407287*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*JfR[27]+0.1767766952966368*JfR[22]-0.3061862178478971*JfR[21]+0.3061862178478971*(JfR[20]+JfR[16])+0.1767766952966368*JfR[14]-0.1767766952966368*JfR[13]+0.3061862178478971*JfR[12]-0.1767766952966368*JfR[8]+0.3061862178478971*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*(JfR[5]+JfR[3])+0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[13] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[7]-0.3535533905932737*speedsR[6]+0.6123724356957944*speedsR[5]-0.6123724356957944*speedsR[4]-0.3535533905932737*speedsR[3]+0.3535533905932737*speedsR[2]-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.22360679774997894*JRatfL[23]+0.22360679774997896*JRatfL[22]-0.22360679774997896*(JRatfL[21]+JRatfL[20])-0.22360679774997894*JRatfL[19]-0.22360679774997902*JRatfL[18]+0.22360679774997902*JRatfL[17]+0.22360679774997896*JRatfL[16]+0.33541019662496846*(JRatfL[15]+JRatfL[14])-0.33541019662496846*JRatfL[13]+0.25*JRatfL[12]-0.33541019662496846*(JRatfL[11]+JRatfL[10])+0.25*JRatfL[9]-0.25*JRatfL[8]-0.33541019662496846*JRatfL[7]+0.33541019662496846*JRatfL[6]-0.25*(JRatfL[5]+JRatfL[4])+0.33541019662496846*JRatfL[3]-0.25*JRatfL[2]+0.25*(JRatfL[1]+JRatfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])+0.15811388300841892*JfR[46]-0.27386127875258304*JfR[45]+0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]-0.15811388300841892*JfR[41]+0.273861278752583*JfR[40]-0.15811388300841892*JfR[39]+0.273861278752583*JfR[38]-0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]+0.15811388300841894*JfR[34]-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.2371708245126284*JfR[30]-0.41079191812887433*JfR[29]+0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]-0.2371708245126284*JfR[24]+0.41079191812887433*JfR[23]+0.1767766952966368*JfR[22]-0.3061862178478971*JfR[21]+0.3061862178478971*JfR[20]-0.2371708245126284*JfR[19]+0.41079191812887433*JfR[18]-0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]-0.1767766952966368*JfR[13]+0.3061862178478971*JfR[12]-0.2371708245126284*JfR[11]+0.2371708245126284*JfR[10]-0.41079191812887433*JfR[9]-0.1767766952966368*JfR[8]+0.3061862178478971*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]+0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[14] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[7]-0.3535533905932737*speedsR[6]+0.6123724356957944*speedsR[5]-0.6123724356957944*speedsR[4]-0.3535533905932737*speedsR[3]+0.3535533905932737*speedsR[2]-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.22360679774997894*JRatfL[23])-0.22360679774997896*JRatfL[22]+0.22360679774997896*JRatfL[21]-0.22360679774997896*JRatfL[20]+0.22360679774997894*JRatfL[19]-0.22360679774997902*JRatfL[18]+0.22360679774997902*JRatfL[17]+0.22360679774997896*JRatfL[16]+0.33541019662496846*(JRatfL[15]+JRatfL[14])-0.33541019662496846*JRatfL[13]-0.25*JRatfL[12]+0.33541019662496846*JRatfL[11]-0.33541019662496846*JRatfL[10]-0.25*JRatfL[9]+0.25*JRatfL[8]+0.33541019662496846*JRatfL[7]-0.33541019662496846*JRatfL[6]-0.25*JRatfL[5]+0.25*JRatfL[4]-0.33541019662496846*JRatfL[3]-0.25*JRatfL[2]+0.25*(JRatfL[1]+JRatfL[0]); + JfR_quad = 0.273861278752583*JfR[47]-0.15811388300841892*JfR[46]+0.27386127875258304*JfR[45]-0.27386127875258304*JfR[44]+0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]+0.15811388300841892*JfR[41]-0.273861278752583*JfR[40]-0.15811388300841892*JfR[39]+0.273861278752583*JfR[38]-0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]+0.15811388300841894*JfR[34]-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.2371708245126284*JfR[30]-0.41079191812887433*JfR[29]+0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]-0.2371708245126284*JfR[24]+0.41079191812887433*JfR[23]-0.1767766952966368*JfR[22]+0.3061862178478971*JfR[21]-0.3061862178478971*JfR[20]+0.2371708245126284*JfR[19]-0.41079191812887433*JfR[18]+0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]+0.1767766952966368*JfR[13]-0.3061862178478971*JfR[12]+0.2371708245126284*JfR[11]-0.2371708245126284*JfR[10]+0.41079191812887433*JfR[9]-0.1767766952966368*JfR[8]+0.3061862178478971*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]+0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[15] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[7]-0.3535533905932737*speedsR[6]+0.6123724356957944*speedsR[5]-0.6123724356957944*speedsR[4]-0.3535533905932737*speedsR[3]+0.3535533905932737*speedsR[2]-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.2795084971874738*JRatfL[23]+0.2795084971874737*JRatfL[22]-0.2795084971874737*JRatfL[21]+0.2795084971874737*JRatfL[20]-0.2795084971874738*JRatfL[19]+0.2795084971874738*JRatfL[18]-0.2795084971874738*JRatfL[17]-0.2795084971874737*JRatfL[16]-0.25*(JRatfL[12]+JRatfL[9])+0.25*JRatfL[8]-0.25*JRatfL[5]+0.25*JRatfL[4]-0.25*JRatfL[2]+0.25*(JRatfL[1]+JRatfL[0]); + JfR_quad = -(0.34232659844072866*JfR[47])+0.19764235376052366*JfR[46]-0.3423265984407287*JfR[45]+0.3423265984407287*JfR[44]-0.3423265984407287*JfR[43]+0.19764235376052364*JfR[42]-0.19764235376052364*JfR[41]+0.34232659844072866*JfR[40]+0.19764235376052364*JfR[39]-0.34232659844072866*JfR[38]+0.34232659844072866*JfR[37]-0.19764235376052366*JfR[36]+0.19764235376052366*JfR[35]-0.19764235376052366*JfR[34]+0.3423265984407287*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*JfR[27]-0.1767766952966368*JfR[22]+0.3061862178478971*JfR[21]-0.3061862178478971*JfR[20]+0.3061862178478971*JfR[16]-0.1767766952966368*JfR[14]+0.1767766952966368*JfR[13]-0.3061862178478971*JfR[12]-0.1767766952966368*JfR[8]+0.3061862178478971*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.1767766952966368*JfR[3]+0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[16] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[7]-0.3535533905932737*speedsR[6]+0.6123724356957944*speedsR[5]-0.6123724356957944*speedsR[4]-0.3535533905932737*speedsR[3]+0.3535533905932737*speedsR[2]-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.22360679774997894*JRatfL[23])-0.22360679774997896*JRatfL[22]+0.22360679774997896*JRatfL[21]-0.22360679774997896*JRatfL[20]+0.22360679774997894*JRatfL[19]-0.22360679774997902*JRatfL[18]+0.22360679774997902*JRatfL[17]+0.22360679774997896*JRatfL[16]-0.33541019662496846*(JRatfL[15]+JRatfL[14])+0.33541019662496846*JRatfL[13]-0.25*JRatfL[12]-0.33541019662496846*JRatfL[11]+0.33541019662496846*JRatfL[10]-0.25*JRatfL[9]+0.25*JRatfL[8]-0.33541019662496846*JRatfL[7]+0.33541019662496846*JRatfL[6]-0.25*JRatfL[5]+0.25*JRatfL[4]+0.33541019662496846*JRatfL[3]-0.25*JRatfL[2]+0.25*(JRatfL[1]+JRatfL[0]); + JfR_quad = 0.273861278752583*JfR[47]-0.15811388300841892*JfR[46]+0.27386127875258304*JfR[45]-0.27386127875258304*JfR[44]+0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]+0.15811388300841892*JfR[41]-0.273861278752583*JfR[40]-0.15811388300841892*JfR[39]+0.273861278752583*JfR[38]-0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]+0.15811388300841894*JfR[34]-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.2371708245126284*JfR[30]+0.41079191812887433*JfR[29]-0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]+0.2371708245126284*JfR[24]-0.41079191812887433*JfR[23]-0.1767766952966368*JfR[22]+0.3061862178478971*JfR[21]-0.3061862178478971*JfR[20]-0.2371708245126284*JfR[19]+0.41079191812887433*JfR[18]-0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]+0.1767766952966368*JfR[13]-0.3061862178478971*JfR[12]-0.2371708245126284*JfR[11]+0.2371708245126284*JfR[10]-0.41079191812887433*JfR[9]-0.1767766952966368*JfR[8]+0.3061862178478971*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]+0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[17] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[3].bmag; + Jc_quad = gkdgs[3].Jc; + B3_quad = gkdgs[3].B3; + normcurlbhat_quad = gkdgs[3].normcurlbhat; + bhat_quad[0] = gkdgs[3].bhat.x[0]; + bhat_quad[1] = gkdgs[3].bhat.x[1]; + bhat_quad[2] = gkdgs[3].bhat.x[2]; + area_elem_quad = dgs[3].area_elem; + + + alpha_quad = -(0.6123724356957944*speedsR[7])+0.3535533905932737*speedsR[6]-0.6123724356957944*(speedsR[5]+speedsR[4])+0.3535533905932737*(speedsR[3]+speedsR[2])-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.22360679774997894*JRatfL[23])-0.22360679774997896*(JRatfL[22]+JRatfL[21])+0.22360679774997896*JRatfL[20]-0.22360679774997894*JRatfL[19]+0.22360679774997902*(JRatfL[18]+JRatfL[17])+0.22360679774997896*JRatfL[16]+0.33541019662496846*(JRatfL[15]+JRatfL[14]+JRatfL[13])-0.25*JRatfL[12]-0.33541019662496846*JRatfL[11]+0.33541019662496846*JRatfL[10]-0.25*(JRatfL[9]+JRatfL[8])-0.33541019662496846*(JRatfL[7]+JRatfL[6])+0.25*JRatfL[5]-0.25*JRatfL[4]-0.33541019662496846*JRatfL[3]+0.25*(JRatfL[2]+JRatfL[1]+JRatfL[0]); + JfR_quad = 0.273861278752583*JfR[47]-0.15811388300841892*JfR[46]+0.27386127875258304*(JfR[45]+JfR[44])-0.27386127875258304*JfR[43]-0.15811388300841892*(JfR[42]+JfR[41])+0.273861278752583*JfR[40]+0.15811388300841892*JfR[39]-0.273861278752583*(JfR[38]+JfR[37])-0.15811388300841892*JfR[36]+0.15811388300841894*(JfR[35]+JfR[34])-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.2371708245126284*JfR[30]-0.41079191812887433*(JfR[29]+JfR[28])+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]+0.2371708245126284*(JfR[25]+JfR[24])-0.41079191812887433*JfR[23]-0.1767766952966368*JfR[22]+0.3061862178478971*(JfR[21]+JfR[20])-0.2371708245126284*JfR[19]+0.41079191812887433*(JfR[18]+JfR[17])-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.1767766952966368*(JfR[14]+JfR[13])+0.3061862178478971*JfR[12]-0.2371708245126284*(JfR[11]+JfR[10])+0.41079191812887433*JfR[9]+0.1767766952966368*JfR[8]-0.3061862178478971*(JfR[7]+JfR[6])-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]+0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[18] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[7])+0.3535533905932737*speedsR[6]-0.6123724356957944*(speedsR[5]+speedsR[4])+0.3535533905932737*(speedsR[3]+speedsR[2])-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.2795084971874738*JRatfL[23]+0.2795084971874737*(JRatfL[22]+JRatfL[21])-0.2795084971874737*JRatfL[20]+0.2795084971874738*JRatfL[19]-0.2795084971874738*(JRatfL[18]+JRatfL[17])-0.2795084971874737*JRatfL[16]-0.25*(JRatfL[12]+JRatfL[9]+JRatfL[8])+0.25*JRatfL[5]-0.25*JRatfL[4]+0.25*(JRatfL[2]+JRatfL[1]+JRatfL[0]); + JfR_quad = -(0.34232659844072866*JfR[47])+0.19764235376052366*JfR[46]-0.3423265984407287*(JfR[45]+JfR[44])+0.3423265984407287*JfR[43]+0.19764235376052364*(JfR[42]+JfR[41])-0.34232659844072866*JfR[40]-0.19764235376052364*JfR[39]+0.34232659844072866*(JfR[38]+JfR[37])+0.19764235376052366*JfR[36]-0.19764235376052366*(JfR[35]+JfR[34])+0.3423265984407287*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*JfR[27]-0.1767766952966368*JfR[22]+0.3061862178478971*(JfR[21]+JfR[20])-0.3061862178478971*JfR[16]-0.1767766952966368*(JfR[14]+JfR[13])+0.3061862178478971*JfR[12]+0.1767766952966368*JfR[8]-0.3061862178478971*(JfR[7]+JfR[6])-0.1767766952966368*JfR[5]+0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[19] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[7])+0.3535533905932737*speedsR[6]-0.6123724356957944*(speedsR[5]+speedsR[4])+0.3535533905932737*(speedsR[3]+speedsR[2])-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.22360679774997894*JRatfL[23])-0.22360679774997896*(JRatfL[22]+JRatfL[21])+0.22360679774997896*JRatfL[20]-0.22360679774997894*JRatfL[19]+0.22360679774997902*(JRatfL[18]+JRatfL[17])+0.22360679774997896*JRatfL[16]-0.33541019662496846*(JRatfL[15]+JRatfL[14]+JRatfL[13])-0.25*JRatfL[12]+0.33541019662496846*JRatfL[11]-0.33541019662496846*JRatfL[10]-0.25*(JRatfL[9]+JRatfL[8])+0.33541019662496846*(JRatfL[7]+JRatfL[6])+0.25*JRatfL[5]-0.25*JRatfL[4]+0.33541019662496846*JRatfL[3]+0.25*(JRatfL[2]+JRatfL[1]+JRatfL[0]); + JfR_quad = 0.273861278752583*JfR[47]-0.15811388300841892*JfR[46]+0.27386127875258304*(JfR[45]+JfR[44])-0.27386127875258304*JfR[43]-0.15811388300841892*(JfR[42]+JfR[41])+0.273861278752583*JfR[40]+0.15811388300841892*JfR[39]-0.273861278752583*(JfR[38]+JfR[37])-0.15811388300841892*JfR[36]+0.15811388300841894*(JfR[35]+JfR[34])-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.2371708245126284*JfR[30]+0.41079191812887433*(JfR[29]+JfR[28])+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]-0.2371708245126284*(JfR[25]+JfR[24])+0.41079191812887433*JfR[23]-0.1767766952966368*JfR[22]+0.3061862178478971*(JfR[21]+JfR[20])+0.2371708245126284*JfR[19]-0.41079191812887433*(JfR[18]+JfR[17])-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.1767766952966368*(JfR[14]+JfR[13])+0.3061862178478971*JfR[12]+0.2371708245126284*(JfR[11]+JfR[10])-0.41079191812887433*JfR[9]+0.1767766952966368*JfR[8]-0.3061862178478971*(JfR[7]+JfR[6])-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]+0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[20] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[7])+0.3535533905932737*speedsR[6]-0.6123724356957944*(speedsR[5]+speedsR[4])+0.3535533905932737*(speedsR[3]+speedsR[2])-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.22360679774997894*JRatfL[23]+0.22360679774997896*(JRatfL[22]+JRatfL[21]+JRatfL[20])+0.22360679774997894*JRatfL[19]+0.22360679774997902*(JRatfL[18]+JRatfL[17])+0.22360679774997896*JRatfL[16]-0.33541019662496846*(JRatfL[15]+JRatfL[14]+JRatfL[13])+0.25*JRatfL[12]-0.33541019662496846*(JRatfL[11]+JRatfL[10])+0.25*(JRatfL[9]+JRatfL[8])-0.33541019662496846*(JRatfL[7]+JRatfL[6])+0.25*(JRatfL[5]+JRatfL[4])-0.33541019662496846*JRatfL[3]+0.25*(JRatfL[2]+JRatfL[1]+JRatfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])+0.15811388300841892*JfR[46]-0.27386127875258304*(JfR[45]+JfR[44]+JfR[43])+0.15811388300841892*(JfR[42]+JfR[41])-0.273861278752583*JfR[40]+0.15811388300841892*JfR[39]-0.273861278752583*(JfR[38]+JfR[37])+0.15811388300841892*JfR[36]+0.15811388300841894*(JfR[35]+JfR[34])-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.2371708245126284*JfR[30]+0.41079191812887433*(JfR[29]+JfR[28])-0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.2371708245126284*(JfR[25]+JfR[24])+0.41079191812887433*JfR[23]+0.1767766952966368*JfR[22]-0.3061862178478971*(JfR[21]+JfR[20])-0.2371708245126284*JfR[19]+0.41079191812887433*(JfR[18]+JfR[17])-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.1767766952966368*(JfR[14]+JfR[13])-0.3061862178478971*JfR[12]-0.2371708245126284*(JfR[11]+JfR[10])+0.41079191812887433*JfR[9]+0.1767766952966368*JfR[8]-0.3061862178478971*(JfR[7]+JfR[6])+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]+0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[21] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[7])+0.3535533905932737*speedsR[6]-0.6123724356957944*(speedsR[5]+speedsR[4])+0.3535533905932737*(speedsR[3]+speedsR[2])-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.2795084971874738*JRatfL[23])-0.2795084971874737*(JRatfL[22]+JRatfL[21]+JRatfL[20])-0.2795084971874738*(JRatfL[19]+JRatfL[18]+JRatfL[17])-0.2795084971874737*JRatfL[16]+0.25*(JRatfL[12]+JRatfL[9]+JRatfL[8]+JRatfL[5]+JRatfL[4]+JRatfL[2]+JRatfL[1]+JRatfL[0]); + JfR_quad = 0.34232659844072866*JfR[47]-0.19764235376052366*JfR[46]+0.3423265984407287*(JfR[45]+JfR[44]+JfR[43])-0.19764235376052364*(JfR[42]+JfR[41])+0.34232659844072866*JfR[40]-0.19764235376052364*JfR[39]+0.34232659844072866*(JfR[38]+JfR[37])-0.19764235376052366*(JfR[36]+JfR[35]+JfR[34])+0.3423265984407287*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*JfR[27]+0.1767766952966368*JfR[22]-0.3061862178478971*(JfR[21]+JfR[20]+JfR[16])+0.1767766952966368*(JfR[14]+JfR[13])-0.3061862178478971*JfR[12]+0.1767766952966368*JfR[8]-0.3061862178478971*(JfR[7]+JfR[6])+0.1767766952966368*(JfR[5]+JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[22] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[7])+0.3535533905932737*speedsR[6]-0.6123724356957944*(speedsR[5]+speedsR[4])+0.3535533905932737*(speedsR[3]+speedsR[2])-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.22360679774997894*JRatfL[23]+0.22360679774997896*(JRatfL[22]+JRatfL[21]+JRatfL[20])+0.22360679774997894*JRatfL[19]+0.22360679774997902*(JRatfL[18]+JRatfL[17])+0.22360679774997896*JRatfL[16]+0.33541019662496846*(JRatfL[15]+JRatfL[14]+JRatfL[13])+0.25*JRatfL[12]+0.33541019662496846*(JRatfL[11]+JRatfL[10])+0.25*(JRatfL[9]+JRatfL[8])+0.33541019662496846*(JRatfL[7]+JRatfL[6])+0.25*(JRatfL[5]+JRatfL[4])+0.33541019662496846*JRatfL[3]+0.25*(JRatfL[2]+JRatfL[1]+JRatfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])+0.15811388300841892*JfR[46]-0.27386127875258304*(JfR[45]+JfR[44]+JfR[43])+0.15811388300841892*(JfR[42]+JfR[41])-0.273861278752583*JfR[40]+0.15811388300841892*JfR[39]-0.273861278752583*(JfR[38]+JfR[37])+0.15811388300841892*JfR[36]+0.15811388300841894*(JfR[35]+JfR[34])-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.2371708245126284*JfR[30]-0.41079191812887433*(JfR[29]+JfR[28])-0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.2371708245126284*(JfR[25]+JfR[24])-0.41079191812887433*JfR[23]+0.1767766952966368*JfR[22]-0.3061862178478971*(JfR[21]+JfR[20])+0.2371708245126284*JfR[19]-0.41079191812887433*(JfR[18]+JfR[17])-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.1767766952966368*(JfR[14]+JfR[13])-0.3061862178478971*JfR[12]+0.2371708245126284*(JfR[11]+JfR[10])-0.41079191812887433*JfR[9]+0.1767766952966368*JfR[8]-0.3061862178478971*(JfR[7]+JfR[6])+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]+0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[23] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdx2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfy_2x2v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfy_2x2v_ser_p1.c new file mode 100644 index 0000000000..bc1bfb6b4e --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfy_2x2v_ser_p1.c @@ -0,0 +1,188 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_surfy_2x2v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdz2 = 2.0/dxv[1]; + double rdvpar2 = 2.0/dxv[2]; + + double JRatfL[12] = {0.}; + JRatfL[0] = 0.5*(1.7320508075688772*(jacobgeo_rat_surfL[1]*JfL[5]+jacobgeo_rat_surfL[0]*JfL[2])+JfL[1]*jacobgeo_rat_surfL[1]+JfL[0]*jacobgeo_rat_surfL[0]); + JRatfL[1] = 0.5*(1.7320508075688772*(jacobgeo_rat_surfL[0]*JfL[5]+jacobgeo_rat_surfL[1]*JfL[2])+JfL[0]*jacobgeo_rat_surfL[1]+jacobgeo_rat_surfL[0]*JfL[1]); + JRatfL[2] = 0.5*(1.7320508075688772*(jacobgeo_rat_surfL[1]*JfL[11]+jacobgeo_rat_surfL[0]*JfL[7])+jacobgeo_rat_surfL[1]*JfL[6]+jacobgeo_rat_surfL[0]*JfL[3]); + JRatfL[3] = 0.5*(1.7320508075688772*(jacobgeo_rat_surfL[1]*JfL[12]+jacobgeo_rat_surfL[0]*JfL[9])+jacobgeo_rat_surfL[1]*JfL[8]+jacobgeo_rat_surfL[0]*JfL[4]); + JRatfL[4] = 0.5*(1.7320508075688772*(jacobgeo_rat_surfL[0]*JfL[11]+jacobgeo_rat_surfL[1]*JfL[7])+jacobgeo_rat_surfL[0]*JfL[6]+jacobgeo_rat_surfL[1]*JfL[3]); + JRatfL[5] = 0.5*(1.7320508075688772*(jacobgeo_rat_surfL[0]*JfL[12]+jacobgeo_rat_surfL[1]*JfL[9])+jacobgeo_rat_surfL[0]*JfL[8]+jacobgeo_rat_surfL[1]*JfL[4]); + JRatfL[6] = 0.5*(1.7320508075688772*(jacobgeo_rat_surfL[1]*JfL[15]+jacobgeo_rat_surfL[0]*JfL[14])+jacobgeo_rat_surfL[1]*JfL[13]+jacobgeo_rat_surfL[0]*JfL[10]); + JRatfL[7] = 0.5*(1.7320508075688772*(jacobgeo_rat_surfL[0]*JfL[15]+jacobgeo_rat_surfL[1]*JfL[14])+jacobgeo_rat_surfL[0]*JfL[13]+jacobgeo_rat_surfL[1]*JfL[10]); + JRatfL[8] = 0.03333333333333333*(25.980762113533157*jacobgeo_rat_surfL[1]*JfL[20]+8.660254037844387*(3.0*jacobgeo_rat_surfL[0]*JfL[18]+1.7320508075688772*jacobgeo_rat_surfL[1]*JfL[17])+15.0*jacobgeo_rat_surfL[0]*JfL[16]); + JRatfL[9] = 0.03333333333333333*(8.660254037844387*(3.0*jacobgeo_rat_surfL[0]*JfL[20]+1.7320508075688772*jacobgeo_rat_surfL[1]*JfL[16])+25.980762113533157*jacobgeo_rat_surfL[1]*JfL[18]+15.0*jacobgeo_rat_surfL[0]*JfL[17]); + JRatfL[10] = 0.03333333333333333*(25.980762113533157*jacobgeo_rat_surfL[1]*JfL[23]+8.660254037844387*(3.0*jacobgeo_rat_surfL[0]*JfL[22]+1.7320508075688772*jacobgeo_rat_surfL[1]*JfL[21])+15.0*jacobgeo_rat_surfL[0]*JfL[19]); + JRatfL[11] = 0.03333333333333333*(8.660254037844387*(3.0*jacobgeo_rat_surfL[0]*JfL[23]+1.7320508075688772*jacobgeo_rat_surfL[1]*JfL[19])+25.980762113533157*jacobgeo_rat_surfL[1]*JfL[22]+15.0*jacobgeo_rat_surfL[0]*JfL[21]); + + double *flux_surf_nodal = &flux_surf[12]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = 0.8660254037844386*speedsR[7]-0.8660254037844386*speedsR[6]-0.5*speedsR[5]+0.5*speedsR[4]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3162277660168379*JRatfL[11]-0.31622776601683794*(JRatfL[10]+JRatfL[9])+0.3162277660168379*JRatfL[8]-0.4743416490252568*JRatfL[7]+0.4743416490252568*JRatfL[6]+0.3535533905932737*JRatfL[5]+0.4743416490252568*JRatfL[4]-0.3535533905932737*JRatfL[3]-0.4743416490252568*JRatfL[2]-0.3535533905932737*JRatfL[1]+0.3535533905932737*JRatfL[0]; + JfR_quad = -(0.3872983346207417*JfR[23])+0.38729833462074165*JfR[22]+0.22360679774997896*JfR[21]+0.38729833462074165*JfR[20]-0.22360679774997894*JfR[19]-0.3872983346207417*JfR[18]-0.22360679774997902*JfR[17]+0.22360679774997896*JfR[16]+0.5809475019311124*JfR[15]-0.5809475019311124*JfR[14]-0.33541019662496846*JfR[13]-0.4330127018922193*JfR[12]-0.5809475019311124*JfR[11]+0.33541019662496846*JfR[10]+0.4330127018922193*JfR[9]+0.25*JfR[8]+0.5809475019311124*JfR[7]+0.33541019662496846*JfR[6]+0.4330127018922193*JfR[5]-0.25*JfR[4]-0.33541019662496846*JfR[3]-0.4330127018922193*JfR[2]-0.25*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsR[7]-0.8660254037844386*speedsR[6]-0.5*speedsR[5]+0.5*speedsR[4]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3952847075210473*JRatfL[11])+0.39528470752104733*(JRatfL[10]+JRatfL[9])-0.3952847075210473*JRatfL[8]+0.3535533905932737*JRatfL[5]-0.3535533905932737*(JRatfL[3]+JRatfL[1])+0.3535533905932737*JRatfL[0]; + JfR_quad = 0.4841229182759271*JfR[23]-0.4841229182759271*JfR[22]-0.2795084971874737*JfR[21]-0.4841229182759271*JfR[20]+0.2795084971874738*JfR[19]+0.4841229182759271*JfR[18]+0.2795084971874738*JfR[17]-0.2795084971874737*JfR[16]-0.4330127018922193*JfR[12]+0.4330127018922193*JfR[9]+0.25*JfR[8]+0.4330127018922193*JfR[5]-0.25*JfR[4]-0.4330127018922193*JfR[2]-0.25*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsR[7]-0.8660254037844386*speedsR[6]-0.5*speedsR[5]+0.5*speedsR[4]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3162277660168379*JRatfL[11]-0.31622776601683794*(JRatfL[10]+JRatfL[9])+0.3162277660168379*JRatfL[8]+0.4743416490252568*JRatfL[7]-0.4743416490252568*JRatfL[6]+0.3535533905932737*JRatfL[5]-0.4743416490252568*JRatfL[4]-0.3535533905932737*JRatfL[3]+0.4743416490252568*JRatfL[2]-0.3535533905932737*JRatfL[1]+0.3535533905932737*JRatfL[0]; + JfR_quad = -(0.3872983346207417*JfR[23])+0.38729833462074165*JfR[22]+0.22360679774997896*JfR[21]+0.38729833462074165*JfR[20]-0.22360679774997894*JfR[19]-0.3872983346207417*JfR[18]-0.22360679774997902*JfR[17]+0.22360679774997896*JfR[16]-0.5809475019311124*JfR[15]+0.5809475019311124*JfR[14]+0.33541019662496846*JfR[13]-0.4330127018922193*JfR[12]+0.5809475019311124*JfR[11]-0.33541019662496846*JfR[10]+0.4330127018922193*JfR[9]+0.25*JfR[8]-0.5809475019311124*JfR[7]-0.33541019662496846*JfR[6]+0.4330127018922193*JfR[5]-0.25*JfR[4]+0.33541019662496846*JfR[3]-0.4330127018922193*JfR[2]-0.25*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsR[7]-0.8660254037844386*speedsR[6]-0.5*speedsR[5]+0.5*speedsR[4]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3162277660168379*JRatfL[11])+0.31622776601683794*JRatfL[10]-0.31622776601683794*JRatfL[9]+0.3162277660168379*JRatfL[8]+0.4743416490252568*JRatfL[7]-0.4743416490252568*JRatfL[6]-0.3535533905932737*JRatfL[5]+0.4743416490252568*JRatfL[4]+0.3535533905932737*JRatfL[3]-0.4743416490252568*JRatfL[2]-0.3535533905932737*JRatfL[1]+0.3535533905932737*JRatfL[0]; + JfR_quad = 0.3872983346207417*JfR[23]-0.38729833462074165*JfR[22]-0.22360679774997896*JfR[21]+0.38729833462074165*JfR[20]+0.22360679774997894*JfR[19]-0.3872983346207417*JfR[18]-0.22360679774997902*JfR[17]+0.22360679774997896*JfR[16]-0.5809475019311124*JfR[15]+0.5809475019311124*JfR[14]+0.33541019662496846*JfR[13]+0.4330127018922193*JfR[12]-0.5809475019311124*JfR[11]-0.33541019662496846*JfR[10]-0.4330127018922193*JfR[9]-0.25*JfR[8]+0.5809475019311124*JfR[7]+0.33541019662496846*JfR[6]+0.4330127018922193*JfR[5]+0.25*JfR[4]-0.33541019662496846*JfR[3]-0.4330127018922193*JfR[2]-0.25*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[3] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsR[7]-0.8660254037844386*speedsR[6]-0.5*speedsR[5]+0.5*speedsR[4]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3952847075210473*JRatfL[11]-0.39528470752104733*JRatfL[10]+0.39528470752104733*JRatfL[9]-0.3952847075210473*JRatfL[8]-0.3535533905932737*JRatfL[5]+0.3535533905932737*JRatfL[3]-0.3535533905932737*JRatfL[1]+0.3535533905932737*JRatfL[0]; + JfR_quad = -(0.4841229182759271*JfR[23])+0.4841229182759271*JfR[22]+0.2795084971874737*JfR[21]-0.4841229182759271*JfR[20]-0.2795084971874738*JfR[19]+0.4841229182759271*JfR[18]+0.2795084971874738*JfR[17]-0.2795084971874737*JfR[16]+0.4330127018922193*JfR[12]-0.4330127018922193*JfR[9]-0.25*JfR[8]+0.4330127018922193*JfR[5]+0.25*JfR[4]-0.4330127018922193*JfR[2]-0.25*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[4] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsR[7]-0.8660254037844386*speedsR[6]-0.5*speedsR[5]+0.5*speedsR[4]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3162277660168379*JRatfL[11])+0.31622776601683794*JRatfL[10]-0.31622776601683794*JRatfL[9]+0.3162277660168379*JRatfL[8]-0.4743416490252568*JRatfL[7]+0.4743416490252568*JRatfL[6]-0.3535533905932737*JRatfL[5]-0.4743416490252568*JRatfL[4]+0.3535533905932737*JRatfL[3]+0.4743416490252568*JRatfL[2]-0.3535533905932737*JRatfL[1]+0.3535533905932737*JRatfL[0]; + JfR_quad = 0.3872983346207417*JfR[23]-0.38729833462074165*JfR[22]-0.22360679774997896*JfR[21]+0.38729833462074165*JfR[20]+0.22360679774997894*JfR[19]-0.3872983346207417*JfR[18]-0.22360679774997902*JfR[17]+0.22360679774997896*JfR[16]+0.5809475019311124*JfR[15]-0.5809475019311124*JfR[14]-0.33541019662496846*JfR[13]+0.4330127018922193*JfR[12]+0.5809475019311124*JfR[11]+0.33541019662496846*JfR[10]-0.4330127018922193*JfR[9]-0.25*JfR[8]-0.5809475019311124*JfR[7]-0.33541019662496846*JfR[6]+0.4330127018922193*JfR[5]+0.25*JfR[4]+0.33541019662496846*JfR[3]-0.4330127018922193*JfR[2]-0.25*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[5] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[1].bmag; + Jc_quad = gkdgs[1].Jc; + B3_quad = gkdgs[1].B3; + normcurlbhat_quad = gkdgs[1].normcurlbhat; + bhat_quad[0] = gkdgs[1].bhat.x[0]; + bhat_quad[1] = gkdgs[1].bhat.x[1]; + bhat_quad[2] = gkdgs[1].bhat.x[2]; + area_elem_quad = dgs[1].area_elem; + + + alpha_quad = 0.5*(speedsR[5]+speedsR[4])-0.8660254037844386*(speedsR[7]+speedsR[6]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3162277660168379*JRatfL[11])-0.31622776601683794*JRatfL[10]+0.31622776601683794*JRatfL[9]+0.3162277660168379*JRatfL[8]+0.4743416490252568*(JRatfL[7]+JRatfL[6])-0.3535533905932737*JRatfL[5]-0.4743416490252568*JRatfL[4]-0.3535533905932737*JRatfL[3]-0.4743416490252568*JRatfL[2]+0.3535533905932737*(JRatfL[1]+JRatfL[0]); + JfR_quad = 0.3872983346207417*JfR[23]+0.38729833462074165*JfR[22]-0.22360679774997896*JfR[21]-0.38729833462074165*JfR[20]-0.22360679774997894*JfR[19]-0.3872983346207417*JfR[18]+0.22360679774997902*JfR[17]+0.22360679774997896*JfR[16]-0.5809475019311124*(JfR[15]+JfR[14])+0.33541019662496846*JfR[13]+0.4330127018922193*JfR[12]+0.5809475019311124*JfR[11]+0.33541019662496846*JfR[10]+0.4330127018922193*JfR[9]-0.25*JfR[8]+0.5809475019311124*JfR[7]-0.33541019662496846*JfR[6]-0.4330127018922193*JfR[5]-0.25*JfR[4]-0.33541019662496846*JfR[3]-0.4330127018922193*JfR[2]+0.25*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[6] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.5*(speedsR[5]+speedsR[4])-0.8660254037844386*(speedsR[7]+speedsR[6]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3952847075210473*JRatfL[11]+0.39528470752104733*JRatfL[10]-0.39528470752104733*JRatfL[9]-0.3952847075210473*JRatfL[8]-0.3535533905932737*(JRatfL[5]+JRatfL[3])+0.3535533905932737*(JRatfL[1]+JRatfL[0]); + JfR_quad = -(0.4841229182759271*(JfR[23]+JfR[22]))+0.2795084971874737*JfR[21]+0.4841229182759271*JfR[20]+0.2795084971874738*JfR[19]+0.4841229182759271*JfR[18]-0.2795084971874738*JfR[17]-0.2795084971874737*JfR[16]+0.4330127018922193*(JfR[12]+JfR[9])-0.25*JfR[8]-0.4330127018922193*JfR[5]-0.25*JfR[4]-0.4330127018922193*JfR[2]+0.25*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[7] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.5*(speedsR[5]+speedsR[4])-0.8660254037844386*(speedsR[7]+speedsR[6]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3162277660168379*JRatfL[11])-0.31622776601683794*JRatfL[10]+0.31622776601683794*JRatfL[9]+0.3162277660168379*JRatfL[8]-0.4743416490252568*(JRatfL[7]+JRatfL[6])-0.3535533905932737*JRatfL[5]+0.4743416490252568*JRatfL[4]-0.3535533905932737*JRatfL[3]+0.4743416490252568*JRatfL[2]+0.3535533905932737*(JRatfL[1]+JRatfL[0]); + JfR_quad = 0.3872983346207417*JfR[23]+0.38729833462074165*JfR[22]-0.22360679774997896*JfR[21]-0.38729833462074165*JfR[20]-0.22360679774997894*JfR[19]-0.3872983346207417*JfR[18]+0.22360679774997902*JfR[17]+0.22360679774997896*JfR[16]+0.5809475019311124*(JfR[15]+JfR[14])-0.33541019662496846*JfR[13]+0.4330127018922193*JfR[12]-0.5809475019311124*JfR[11]-0.33541019662496846*JfR[10]+0.4330127018922193*JfR[9]-0.25*JfR[8]-0.5809475019311124*JfR[7]+0.33541019662496846*JfR[6]-0.4330127018922193*JfR[5]-0.25*JfR[4]+0.33541019662496846*JfR[3]-0.4330127018922193*JfR[2]+0.25*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[8] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.5*(speedsR[5]+speedsR[4])-0.8660254037844386*(speedsR[7]+speedsR[6]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3162277660168379*JRatfL[11]+0.31622776601683794*(JRatfL[10]+JRatfL[9])+0.3162277660168379*JRatfL[8]-0.4743416490252568*(JRatfL[7]+JRatfL[6])+0.3535533905932737*JRatfL[5]-0.4743416490252568*JRatfL[4]+0.3535533905932737*JRatfL[3]-0.4743416490252568*JRatfL[2]+0.3535533905932737*(JRatfL[1]+JRatfL[0]); + JfR_quad = -(0.3872983346207417*JfR[23])-0.38729833462074165*JfR[22]+0.22360679774997896*JfR[21]-0.38729833462074165*JfR[20]+0.22360679774997894*JfR[19]-0.3872983346207417*JfR[18]+0.22360679774997902*JfR[17]+0.22360679774997896*JfR[16]+0.5809475019311124*(JfR[15]+JfR[14])-0.33541019662496846*JfR[13]-0.4330127018922193*JfR[12]+0.5809475019311124*JfR[11]-0.33541019662496846*JfR[10]-0.4330127018922193*JfR[9]+0.25*JfR[8]+0.5809475019311124*JfR[7]-0.33541019662496846*JfR[6]-0.4330127018922193*JfR[5]+0.25*JfR[4]-0.33541019662496846*JfR[3]-0.4330127018922193*JfR[2]+0.25*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[9] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.5*(speedsR[5]+speedsR[4])-0.8660254037844386*(speedsR[7]+speedsR[6]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3952847075210473*JRatfL[11])-0.39528470752104733*(JRatfL[10]+JRatfL[9])-0.3952847075210473*JRatfL[8]+0.3535533905932737*(JRatfL[5]+JRatfL[3]+JRatfL[1]+JRatfL[0]); + JfR_quad = 0.4841229182759271*(JfR[23]+JfR[22])-0.2795084971874737*JfR[21]+0.4841229182759271*JfR[20]-0.2795084971874738*JfR[19]+0.4841229182759271*JfR[18]-0.2795084971874738*JfR[17]-0.2795084971874737*JfR[16]-0.4330127018922193*(JfR[12]+JfR[9])+0.25*JfR[8]-0.4330127018922193*JfR[5]+0.25*JfR[4]-0.4330127018922193*JfR[2]+0.25*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[10] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.5*(speedsR[5]+speedsR[4])-0.8660254037844386*(speedsR[7]+speedsR[6]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3162277660168379*JRatfL[11]+0.31622776601683794*(JRatfL[10]+JRatfL[9])+0.3162277660168379*JRatfL[8]+0.4743416490252568*(JRatfL[7]+JRatfL[6])+0.3535533905932737*JRatfL[5]+0.4743416490252568*JRatfL[4]+0.3535533905932737*JRatfL[3]+0.4743416490252568*JRatfL[2]+0.3535533905932737*(JRatfL[1]+JRatfL[0]); + JfR_quad = -(0.3872983346207417*JfR[23])-0.38729833462074165*JfR[22]+0.22360679774997896*JfR[21]-0.38729833462074165*JfR[20]+0.22360679774997894*JfR[19]-0.3872983346207417*JfR[18]+0.22360679774997902*JfR[17]+0.22360679774997896*JfR[16]-0.5809475019311124*(JfR[15]+JfR[14])+0.33541019662496846*JfR[13]-0.4330127018922193*JfR[12]-0.5809475019311124*JfR[11]+0.33541019662496846*JfR[10]-0.4330127018922193*JfR[9]+0.25*JfR[8]-0.5809475019311124*JfR[7]+0.33541019662496846*JfR[6]-0.4330127018922193*JfR[5]+0.25*JfR[4]+0.33541019662496846*JfR[3]-0.4330127018922193*JfR[2]+0.25*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[11] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdz2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfy_3x2v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfy_3x2v_ser_p1.c new file mode 100644 index 0000000000..37779fea19 --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfy_3x2v_ser_p1.c @@ -0,0 +1,329 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_surfy_3x2v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdy2 = 2.0/dxv[1]; + double rdz2 = 2.0/dxv[2]; + double rdvpar2 = 2.0/dxv[3]; + + double JRatfL[24] = {0.}; + JRatfL[0] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[3]*JfL[16]+jacobgeo_rat_surfL[2]*JfL[8]+jacobgeo_rat_surfL[1]*JfL[6]+jacobgeo_rat_surfL[0]*JfL[2])+1.4142135623730951*(jacobgeo_rat_surfL[3]*JfL[7]+jacobgeo_rat_surfL[2]*JfL[3]+JfL[1]*jacobgeo_rat_surfL[1]+JfL[0]*jacobgeo_rat_surfL[0])); + JRatfL[1] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[2]*JfL[16]+jacobgeo_rat_surfL[3]*JfL[8]+jacobgeo_rat_surfL[0]*JfL[6]+jacobgeo_rat_surfL[1]*JfL[2])+1.4142135623730951*(jacobgeo_rat_surfL[2]*JfL[7]+JfL[3]*jacobgeo_rat_surfL[3]+JfL[0]*jacobgeo_rat_surfL[1]+jacobgeo_rat_surfL[0]*JfL[1])); + JRatfL[2] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[1]*JfL[16]+jacobgeo_rat_surfL[0]*JfL[8]+jacobgeo_rat_surfL[3]*JfL[6]+JfL[2]*jacobgeo_rat_surfL[2])+1.4142135623730951*(jacobgeo_rat_surfL[1]*JfL[7]+JfL[1]*jacobgeo_rat_surfL[3]+jacobgeo_rat_surfL[0]*JfL[3]+JfL[0]*jacobgeo_rat_surfL[2])); + JRatfL[3] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[3]*JfL[26]+jacobgeo_rat_surfL[2]*JfL[19]+jacobgeo_rat_surfL[1]*JfL[17]+jacobgeo_rat_surfL[0]*JfL[10])+1.4142135623730951*(jacobgeo_rat_surfL[3]*JfL[18]+jacobgeo_rat_surfL[2]*JfL[11]+jacobgeo_rat_surfL[1]*JfL[9]+jacobgeo_rat_surfL[0]*JfL[4])); + JRatfL[4] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[3]*JfL[27]+jacobgeo_rat_surfL[2]*JfL[22]+jacobgeo_rat_surfL[1]*JfL[20]+jacobgeo_rat_surfL[0]*JfL[13])+1.4142135623730951*(jacobgeo_rat_surfL[3]*JfL[21]+jacobgeo_rat_surfL[2]*JfL[14]+jacobgeo_rat_surfL[1]*JfL[12]+jacobgeo_rat_surfL[0]*JfL[5])); + JRatfL[5] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[0]*JfL[16]+jacobgeo_rat_surfL[1]*JfL[8]+jacobgeo_rat_surfL[2]*JfL[6]+JfL[2]*jacobgeo_rat_surfL[3])+1.4142135623730951*(jacobgeo_rat_surfL[0]*JfL[7]+JfL[0]*jacobgeo_rat_surfL[3]+jacobgeo_rat_surfL[1]*JfL[3]+JfL[1]*jacobgeo_rat_surfL[2])); + JRatfL[6] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[2]*JfL[26]+jacobgeo_rat_surfL[3]*JfL[19]+jacobgeo_rat_surfL[0]*JfL[17]+jacobgeo_rat_surfL[1]*JfL[10])+1.4142135623730951*(jacobgeo_rat_surfL[2]*JfL[18]+jacobgeo_rat_surfL[3]*JfL[11]+jacobgeo_rat_surfL[0]*JfL[9]+jacobgeo_rat_surfL[1]*JfL[4])); + JRatfL[7] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[1]*JfL[26]+jacobgeo_rat_surfL[0]*JfL[19]+jacobgeo_rat_surfL[3]*JfL[17]+jacobgeo_rat_surfL[2]*JfL[10])+1.4142135623730951*(jacobgeo_rat_surfL[1]*JfL[18]+jacobgeo_rat_surfL[0]*JfL[11]+jacobgeo_rat_surfL[3]*JfL[9]+jacobgeo_rat_surfL[2]*JfL[4])); + JRatfL[8] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[2]*JfL[27]+jacobgeo_rat_surfL[3]*JfL[22]+jacobgeo_rat_surfL[0]*JfL[20]+jacobgeo_rat_surfL[1]*JfL[13])+1.4142135623730951*(jacobgeo_rat_surfL[2]*JfL[21]+jacobgeo_rat_surfL[3]*JfL[14]+jacobgeo_rat_surfL[0]*JfL[12]+jacobgeo_rat_surfL[1]*JfL[5])); + JRatfL[9] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[1]*JfL[27]+jacobgeo_rat_surfL[0]*JfL[22]+jacobgeo_rat_surfL[3]*JfL[20]+jacobgeo_rat_surfL[2]*JfL[13])+1.4142135623730951*(jacobgeo_rat_surfL[1]*JfL[21]+jacobgeo_rat_surfL[0]*JfL[14]+jacobgeo_rat_surfL[3]*JfL[12]+jacobgeo_rat_surfL[2]*JfL[5])); + JRatfL[10] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[3]*JfL[31]+jacobgeo_rat_surfL[2]*JfL[30]+jacobgeo_rat_surfL[1]*JfL[28]+jacobgeo_rat_surfL[0]*JfL[24])+1.4142135623730951*(jacobgeo_rat_surfL[3]*JfL[29]+jacobgeo_rat_surfL[2]*JfL[25]+jacobgeo_rat_surfL[1]*JfL[23]+jacobgeo_rat_surfL[0]*JfL[15])); + JRatfL[11] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[0]*JfL[26]+jacobgeo_rat_surfL[1]*JfL[19]+jacobgeo_rat_surfL[2]*JfL[17]+jacobgeo_rat_surfL[3]*JfL[10])+1.4142135623730951*(jacobgeo_rat_surfL[0]*JfL[18]+jacobgeo_rat_surfL[1]*JfL[11]+jacobgeo_rat_surfL[2]*JfL[9]+jacobgeo_rat_surfL[3]*JfL[4])); + JRatfL[12] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[0]*JfL[27]+jacobgeo_rat_surfL[1]*JfL[22]+jacobgeo_rat_surfL[2]*JfL[20]+jacobgeo_rat_surfL[3]*JfL[13])+1.4142135623730951*(jacobgeo_rat_surfL[0]*JfL[21]+jacobgeo_rat_surfL[1]*JfL[14]+jacobgeo_rat_surfL[2]*JfL[12]+jacobgeo_rat_surfL[3]*JfL[5])); + JRatfL[13] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[2]*JfL[31]+jacobgeo_rat_surfL[3]*JfL[30]+jacobgeo_rat_surfL[0]*JfL[28]+jacobgeo_rat_surfL[1]*JfL[24])+1.4142135623730951*(jacobgeo_rat_surfL[2]*JfL[29]+jacobgeo_rat_surfL[3]*JfL[25]+jacobgeo_rat_surfL[0]*JfL[23]+jacobgeo_rat_surfL[1]*JfL[15])); + JRatfL[14] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[1]*JfL[31]+jacobgeo_rat_surfL[0]*JfL[30]+jacobgeo_rat_surfL[3]*JfL[28]+jacobgeo_rat_surfL[2]*JfL[24])+1.4142135623730951*(jacobgeo_rat_surfL[1]*JfL[29]+jacobgeo_rat_surfL[0]*JfL[25]+jacobgeo_rat_surfL[3]*JfL[23]+jacobgeo_rat_surfL[2]*JfL[15])); + JRatfL[15] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[0]*JfL[31]+jacobgeo_rat_surfL[1]*JfL[30]+jacobgeo_rat_surfL[2]*JfL[28]+jacobgeo_rat_surfL[3]*JfL[24])+1.4142135623730951*(jacobgeo_rat_surfL[0]*JfL[29]+jacobgeo_rat_surfL[1]*JfL[25]+jacobgeo_rat_surfL[2]*JfL[23]+jacobgeo_rat_surfL[3]*JfL[15])); + JRatfL[16] = 0.016666666666666666*(8.660254037844387*(4.242640687119286*(jacobgeo_rat_surfL[3]*JfL[43]+jacobgeo_rat_surfL[0]*JfL[34])+2.4494897427831783*(jacobgeo_rat_surfL[2]*JfL[35]+jacobgeo_rat_surfL[1]*JfL[33]))+36.742346141747674*(jacobgeo_rat_surfL[2]*JfL[39]+jacobgeo_rat_surfL[1]*JfL[37])+21.213203435596427*(jacobgeo_rat_surfL[3]*JfL[38]+jacobgeo_rat_surfL[0]*JfL[32])); + JRatfL[17] = 0.016666666666666666*(36.742346141747674*(jacobgeo_rat_surfL[2]*JfL[43]+jacobgeo_rat_surfL[1]*JfL[34])+8.660254037844387*(4.242640687119286*(jacobgeo_rat_surfL[3]*JfL[39]+jacobgeo_rat_surfL[0]*JfL[37])+2.4494897427831783*(jacobgeo_rat_surfL[2]*JfL[38]+jacobgeo_rat_surfL[1]*JfL[32]))+21.213203435596427*(jacobgeo_rat_surfL[3]*JfL[35]+jacobgeo_rat_surfL[0]*JfL[33])); + JRatfL[18] = 0.016666666666666666*(36.742346141747674*(jacobgeo_rat_surfL[1]*JfL[43]+jacobgeo_rat_surfL[2]*JfL[34])+8.660254037844387*(4.242640687119286*(jacobgeo_rat_surfL[0]*JfL[39]+jacobgeo_rat_surfL[3]*JfL[37])+2.4494897427831783*(jacobgeo_rat_surfL[1]*JfL[38]+jacobgeo_rat_surfL[2]*JfL[32]))+21.213203435596427*(jacobgeo_rat_surfL[0]*JfL[35]+jacobgeo_rat_surfL[3]*JfL[33])); + JRatfL[19] = 0.016666666666666666*(8.660254037844387*(4.242640687119286*(jacobgeo_rat_surfL[3]*JfL[47]+jacobgeo_rat_surfL[0]*JfL[41])+2.4494897427831783*(jacobgeo_rat_surfL[2]*JfL[42]+jacobgeo_rat_surfL[1]*JfL[40]))+36.742346141747674*(jacobgeo_rat_surfL[2]*JfL[46]+jacobgeo_rat_surfL[1]*JfL[44])+21.213203435596427*(jacobgeo_rat_surfL[3]*JfL[45]+jacobgeo_rat_surfL[0]*JfL[36])); + JRatfL[20] = 0.016666666666666666*(8.660254037844387*(4.242640687119286*(jacobgeo_rat_surfL[0]*JfL[43]+jacobgeo_rat_surfL[3]*JfL[34])+2.4494897427831783*(jacobgeo_rat_surfL[1]*JfL[35]+jacobgeo_rat_surfL[2]*JfL[33]))+36.742346141747674*(jacobgeo_rat_surfL[1]*JfL[39]+jacobgeo_rat_surfL[2]*JfL[37])+21.213203435596427*(jacobgeo_rat_surfL[0]*JfL[38]+jacobgeo_rat_surfL[3]*JfL[32])); + JRatfL[21] = 0.016666666666666666*(36.742346141747674*(jacobgeo_rat_surfL[2]*JfL[47]+jacobgeo_rat_surfL[1]*JfL[41])+8.660254037844387*(4.242640687119286*(jacobgeo_rat_surfL[3]*JfL[46]+jacobgeo_rat_surfL[0]*JfL[44])+2.4494897427831783*(jacobgeo_rat_surfL[2]*JfL[45]+jacobgeo_rat_surfL[1]*JfL[36]))+21.213203435596427*(jacobgeo_rat_surfL[3]*JfL[42]+jacobgeo_rat_surfL[0]*JfL[40])); + JRatfL[22] = 0.016666666666666666*(36.742346141747674*(jacobgeo_rat_surfL[1]*JfL[47]+jacobgeo_rat_surfL[2]*JfL[41])+8.660254037844387*(4.242640687119286*(jacobgeo_rat_surfL[0]*JfL[46]+jacobgeo_rat_surfL[3]*JfL[44])+2.4494897427831783*(jacobgeo_rat_surfL[1]*JfL[45]+jacobgeo_rat_surfL[2]*JfL[36]))+21.213203435596427*(jacobgeo_rat_surfL[0]*JfL[42]+jacobgeo_rat_surfL[3]*JfL[40])); + JRatfL[23] = 0.016666666666666666*(8.660254037844387*(4.242640687119286*(jacobgeo_rat_surfL[0]*JfL[47]+jacobgeo_rat_surfL[3]*JfL[41])+2.4494897427831783*(jacobgeo_rat_surfL[1]*JfL[42]+jacobgeo_rat_surfL[2]*JfL[40]))+36.742346141747674*(jacobgeo_rat_surfL[1]*JfL[46]+jacobgeo_rat_surfL[2]*JfL[44])+21.213203435596427*(jacobgeo_rat_surfL[0]*JfL[45]+jacobgeo_rat_surfL[3]*JfL[36])); + + double *flux_surf_nodal = &flux_surf[24]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = -(0.6123724356957944*speedsR[15])+0.6123724356957944*speedsR[14]+0.3535533905932737*speedsR[13]+0.6123724356957944*speedsR[12]-0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]-0.3535533905932737*speedsR[9]+0.3535533905932737*speedsR[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.22360679774997894*JRatfL[23])+0.22360679774997896*(JRatfL[22]+JRatfL[21]+JRatfL[20])-0.22360679774997894*JRatfL[19]-0.22360679774997902*(JRatfL[18]+JRatfL[17])+0.22360679774997896*JRatfL[16]+0.33541019662496846*JRatfL[15]-0.33541019662496846*(JRatfL[14]+JRatfL[13])-0.25*JRatfL[12]-0.33541019662496846*JRatfL[11]+0.33541019662496846*JRatfL[10]+0.25*(JRatfL[9]+JRatfL[8])+0.33541019662496846*(JRatfL[7]+JRatfL[6])+0.25*JRatfL[5]-0.25*JRatfL[4]-0.33541019662496846*JRatfL[3]-0.25*(JRatfL[2]+JRatfL[1])+0.25*JRatfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.27386127875258304*JfR[46]-0.15811388300841892*JfR[45]-0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]+0.273861278752583*JfR[41]+0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]+0.15811388300841892*JfR[38]+0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.41079191812887433*JfR[30]+0.2371708245126284*JfR[29]+0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]-0.41079191812887433*JfR[24]-0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]-0.41079191812887433*JfR[19]-0.2371708245126284*JfR[18]-0.41079191812887433*JfR[17]-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]+0.2371708245126284*JfR[11]+0.41079191812887433*JfR[10]+0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[15])+0.6123724356957944*speedsR[14]+0.3535533905932737*speedsR[13]+0.6123724356957944*speedsR[12]-0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]-0.3535533905932737*speedsR[9]+0.3535533905932737*speedsR[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.2795084971874738*JRatfL[23]-0.2795084971874737*(JRatfL[22]+JRatfL[21]+JRatfL[20])+0.2795084971874738*(JRatfL[19]+JRatfL[18]+JRatfL[17])-0.2795084971874737*JRatfL[16]-0.25*JRatfL[12]+0.25*(JRatfL[9]+JRatfL[8]+JRatfL[5])-0.25*(JRatfL[4]+JRatfL[2]+JRatfL[1])+0.25*JRatfL[0]; + JfR_quad = -(0.34232659844072866*JfR[47])+0.3423265984407287*JfR[46]+0.19764235376052366*JfR[45]+0.3423265984407287*(JfR[44]+JfR[43])-0.19764235376052364*JfR[42]-0.34232659844072866*JfR[41]-0.19764235376052364*JfR[40]-0.34232659844072866*JfR[39]-0.19764235376052364*JfR[38]-0.34232659844072866*JfR[37]+0.19764235376052366*(JfR[36]+JfR[35])+0.3423265984407287*JfR[34]+0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*JfR[27]-0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]-0.3061862178478971*(JfR[20]+JfR[16])+0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]+0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*(JfR[5]+JfR[3])-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[15])+0.6123724356957944*speedsR[14]+0.3535533905932737*speedsR[13]+0.6123724356957944*speedsR[12]-0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]-0.3535533905932737*speedsR[9]+0.3535533905932737*speedsR[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.22360679774997894*JRatfL[23])+0.22360679774997896*(JRatfL[22]+JRatfL[21]+JRatfL[20])-0.22360679774997894*JRatfL[19]-0.22360679774997902*(JRatfL[18]+JRatfL[17])+0.22360679774997896*JRatfL[16]-0.33541019662496846*JRatfL[15]+0.33541019662496846*(JRatfL[14]+JRatfL[13])-0.25*JRatfL[12]+0.33541019662496846*JRatfL[11]-0.33541019662496846*JRatfL[10]+0.25*(JRatfL[9]+JRatfL[8])-0.33541019662496846*(JRatfL[7]+JRatfL[6])+0.25*JRatfL[5]-0.25*JRatfL[4]+0.33541019662496846*JRatfL[3]-0.25*(JRatfL[2]+JRatfL[1])+0.25*JRatfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.27386127875258304*JfR[46]-0.15811388300841892*JfR[45]-0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]+0.273861278752583*JfR[41]+0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]+0.15811388300841892*JfR[38]+0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.41079191812887433*JfR[30]-0.2371708245126284*JfR[29]-0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]+0.41079191812887433*JfR[24]+0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]+0.41079191812887433*JfR[19]+0.2371708245126284*JfR[18]+0.41079191812887433*JfR[17]-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]-0.2371708245126284*JfR[11]-0.41079191812887433*JfR[10]-0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[15])+0.6123724356957944*speedsR[14]+0.3535533905932737*speedsR[13]+0.6123724356957944*speedsR[12]-0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]-0.3535533905932737*speedsR[9]+0.3535533905932737*speedsR[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.22360679774997894*JRatfL[23]-0.22360679774997896*(JRatfL[22]+JRatfL[21])+0.22360679774997896*JRatfL[20]+0.22360679774997894*JRatfL[19]-0.22360679774997902*(JRatfL[18]+JRatfL[17])+0.22360679774997896*JRatfL[16]-0.33541019662496846*JRatfL[15]+0.33541019662496846*(JRatfL[14]+JRatfL[13])+0.25*JRatfL[12]-0.33541019662496846*(JRatfL[11]+JRatfL[10])-0.25*(JRatfL[9]+JRatfL[8])+0.33541019662496846*(JRatfL[7]+JRatfL[6])+0.25*(JRatfL[5]+JRatfL[4])-0.33541019662496846*JRatfL[3]-0.25*(JRatfL[2]+JRatfL[1])+0.25*JRatfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.27386127875258304*JfR[46]+0.15811388300841892*JfR[45]+0.27386127875258304*JfR[44]-0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]-0.273861278752583*JfR[41]-0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]+0.15811388300841892*JfR[38]+0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.41079191812887433*JfR[30]-0.2371708245126284*JfR[29]-0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]+0.41079191812887433*JfR[24]+0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]-0.41079191812887433*JfR[19]-0.2371708245126284*JfR[18]-0.41079191812887433*JfR[17]-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]+0.2371708245126284*JfR[11]+0.41079191812887433*JfR[10]+0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[3] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[15])+0.6123724356957944*speedsR[14]+0.3535533905932737*speedsR[13]+0.6123724356957944*speedsR[12]-0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]-0.3535533905932737*speedsR[9]+0.3535533905932737*speedsR[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.2795084971874738*JRatfL[23])+0.2795084971874737*(JRatfL[22]+JRatfL[21])-0.2795084971874737*JRatfL[20]-0.2795084971874738*JRatfL[19]+0.2795084971874738*(JRatfL[18]+JRatfL[17])-0.2795084971874737*JRatfL[16]+0.25*JRatfL[12]-0.25*(JRatfL[9]+JRatfL[8])+0.25*(JRatfL[5]+JRatfL[4])-0.25*(JRatfL[2]+JRatfL[1])+0.25*JRatfL[0]; + JfR_quad = 0.34232659844072866*JfR[47]-0.3423265984407287*JfR[46]-0.19764235376052366*JfR[45]-0.3423265984407287*JfR[44]+0.3423265984407287*JfR[43]+0.19764235376052364*JfR[42]+0.34232659844072866*JfR[41]+0.19764235376052364*JfR[40]-0.34232659844072866*JfR[39]-0.19764235376052364*JfR[38]-0.34232659844072866*JfR[37]-0.19764235376052366*JfR[36]+0.19764235376052366*JfR[35]+0.3423265984407287*JfR[34]+0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*JfR[27]+0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]-0.3061862178478971*JfR[16]-0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]+0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[4] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[15])+0.6123724356957944*speedsR[14]+0.3535533905932737*speedsR[13]+0.6123724356957944*speedsR[12]-0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]-0.3535533905932737*speedsR[9]+0.3535533905932737*speedsR[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.22360679774997894*JRatfL[23]-0.22360679774997896*(JRatfL[22]+JRatfL[21])+0.22360679774997896*JRatfL[20]+0.22360679774997894*JRatfL[19]-0.22360679774997902*(JRatfL[18]+JRatfL[17])+0.22360679774997896*JRatfL[16]+0.33541019662496846*JRatfL[15]-0.33541019662496846*(JRatfL[14]+JRatfL[13])+0.25*JRatfL[12]+0.33541019662496846*(JRatfL[11]+JRatfL[10])-0.25*(JRatfL[9]+JRatfL[8])-0.33541019662496846*(JRatfL[7]+JRatfL[6])+0.25*(JRatfL[5]+JRatfL[4])+0.33541019662496846*JRatfL[3]-0.25*(JRatfL[2]+JRatfL[1])+0.25*JRatfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.27386127875258304*JfR[46]+0.15811388300841892*JfR[45]+0.27386127875258304*JfR[44]-0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]-0.273861278752583*JfR[41]-0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]+0.15811388300841892*JfR[38]+0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.41079191812887433*JfR[30]+0.2371708245126284*JfR[29]+0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]-0.41079191812887433*JfR[24]-0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]+0.41079191812887433*JfR[19]+0.2371708245126284*JfR[18]+0.41079191812887433*JfR[17]-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]-0.2371708245126284*JfR[11]-0.41079191812887433*JfR[10]-0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[5] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[1].bmag; + Jc_quad = gkdgs[1].Jc; + B3_quad = gkdgs[1].B3; + normcurlbhat_quad = gkdgs[1].normcurlbhat; + bhat_quad[0] = gkdgs[1].bhat.x[0]; + bhat_quad[1] = gkdgs[1].bhat.x[1]; + bhat_quad[2] = gkdgs[1].bhat.x[2]; + area_elem_quad = dgs[1].area_elem; + + + alpha_quad = 0.6123724356957944*speedsR[15]-0.6123724356957944*speedsR[14]-0.3535533905932737*speedsR[13]+0.6123724356957944*speedsR[12]+0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]-0.3535533905932737*speedsR[9]+0.3535533905932737*speedsR[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.22360679774997894*JRatfL[23]-0.22360679774997896*JRatfL[22]+0.22360679774997896*JRatfL[21]-0.22360679774997896*JRatfL[20]-0.22360679774997894*JRatfL[19]+0.22360679774997902*JRatfL[18]-0.22360679774997902*JRatfL[17]+0.22360679774997896*JRatfL[16]-0.33541019662496846*JRatfL[15]+0.33541019662496846*JRatfL[14]-0.33541019662496846*JRatfL[13]+0.25*JRatfL[12]+0.33541019662496846*(JRatfL[11]+JRatfL[10])-0.25*JRatfL[9]+0.25*JRatfL[8]-0.33541019662496846*JRatfL[7]+0.33541019662496846*JRatfL[6]-0.25*(JRatfL[5]+JRatfL[4])-0.33541019662496846*JRatfL[3]+0.25*JRatfL[2]-0.25*JRatfL[1]+0.25*JRatfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.27386127875258304*JfR[46]+0.15811388300841892*JfR[45]-0.27386127875258304*JfR[44]+0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]+0.273861278752583*JfR[41]+0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]-0.15811388300841892*JfR[38]+0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.41079191812887433*JfR[30]-0.2371708245126284*JfR[29]+0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]-0.41079191812887433*JfR[24]-0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]+0.41079191812887433*JfR[19]+0.2371708245126284*JfR[18]-0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]-0.2371708245126284*JfR[11]+0.41079191812887433*JfR[10]+0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[6] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[15]-0.6123724356957944*speedsR[14]-0.3535533905932737*speedsR[13]+0.6123724356957944*speedsR[12]+0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]-0.3535533905932737*speedsR[9]+0.3535533905932737*speedsR[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.2795084971874738*JRatfL[23])+0.2795084971874737*JRatfL[22]-0.2795084971874737*JRatfL[21]+0.2795084971874737*JRatfL[20]+0.2795084971874738*JRatfL[19]-0.2795084971874738*JRatfL[18]+0.2795084971874738*JRatfL[17]-0.2795084971874737*JRatfL[16]+0.25*JRatfL[12]-0.25*JRatfL[9]+0.25*JRatfL[8]-0.25*(JRatfL[5]+JRatfL[4])+0.25*JRatfL[2]-0.25*JRatfL[1]+0.25*JRatfL[0]; + JfR_quad = 0.34232659844072866*JfR[47]-0.3423265984407287*JfR[46]-0.19764235376052366*JfR[45]+0.3423265984407287*JfR[44]-0.3423265984407287*JfR[43]+0.19764235376052364*JfR[42]-0.34232659844072866*JfR[41]-0.19764235376052364*JfR[40]+0.34232659844072866*JfR[39]+0.19764235376052364*JfR[38]-0.34232659844072866*JfR[37]+0.19764235376052366*JfR[36]-0.19764235376052366*JfR[35]+0.3423265984407287*JfR[34]+0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*JfR[27]+0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]+0.3061862178478971*JfR[16]-0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]-0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[7] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[15]-0.6123724356957944*speedsR[14]-0.3535533905932737*speedsR[13]+0.6123724356957944*speedsR[12]+0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]-0.3535533905932737*speedsR[9]+0.3535533905932737*speedsR[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.22360679774997894*JRatfL[23]-0.22360679774997896*JRatfL[22]+0.22360679774997896*JRatfL[21]-0.22360679774997896*JRatfL[20]-0.22360679774997894*JRatfL[19]+0.22360679774997902*JRatfL[18]-0.22360679774997902*JRatfL[17]+0.22360679774997896*JRatfL[16]+0.33541019662496846*JRatfL[15]-0.33541019662496846*JRatfL[14]+0.33541019662496846*JRatfL[13]+0.25*JRatfL[12]-0.33541019662496846*(JRatfL[11]+JRatfL[10])-0.25*JRatfL[9]+0.25*JRatfL[8]+0.33541019662496846*JRatfL[7]-0.33541019662496846*JRatfL[6]-0.25*(JRatfL[5]+JRatfL[4])+0.33541019662496846*JRatfL[3]+0.25*JRatfL[2]-0.25*JRatfL[1]+0.25*JRatfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.27386127875258304*JfR[46]+0.15811388300841892*JfR[45]-0.27386127875258304*JfR[44]+0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]+0.273861278752583*JfR[41]+0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]-0.15811388300841892*JfR[38]+0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.41079191812887433*JfR[30]+0.2371708245126284*JfR[29]-0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]+0.41079191812887433*JfR[24]+0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]-0.41079191812887433*JfR[19]-0.2371708245126284*JfR[18]+0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]+0.2371708245126284*JfR[11]-0.41079191812887433*JfR[10]-0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[8] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[15]-0.6123724356957944*speedsR[14]-0.3535533905932737*speedsR[13]+0.6123724356957944*speedsR[12]+0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]-0.3535533905932737*speedsR[9]+0.3535533905932737*speedsR[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.22360679774997894*JRatfL[23])+0.22360679774997896*JRatfL[22]-0.22360679774997896*(JRatfL[21]+JRatfL[20])+0.22360679774997894*JRatfL[19]+0.22360679774997902*JRatfL[18]-0.22360679774997902*JRatfL[17]+0.22360679774997896*JRatfL[16]+0.33541019662496846*JRatfL[15]-0.33541019662496846*JRatfL[14]+0.33541019662496846*JRatfL[13]-0.25*JRatfL[12]+0.33541019662496846*JRatfL[11]-0.33541019662496846*JRatfL[10]+0.25*JRatfL[9]-0.25*JRatfL[8]-0.33541019662496846*JRatfL[7]+0.33541019662496846*JRatfL[6]-0.25*JRatfL[5]+0.25*JRatfL[4]-0.33541019662496846*JRatfL[3]+0.25*JRatfL[2]-0.25*JRatfL[1]+0.25*JRatfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.27386127875258304*JfR[46]-0.15811388300841892*JfR[45]+0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]-0.273861278752583*JfR[41]-0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]-0.15811388300841892*JfR[38]+0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.41079191812887433*JfR[30]+0.2371708245126284*JfR[29]-0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]+0.41079191812887433*JfR[24]+0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]+0.41079191812887433*JfR[19]+0.2371708245126284*JfR[18]-0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]-0.2371708245126284*JfR[11]+0.41079191812887433*JfR[10]+0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[9] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[15]-0.6123724356957944*speedsR[14]-0.3535533905932737*speedsR[13]+0.6123724356957944*speedsR[12]+0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]-0.3535533905932737*speedsR[9]+0.3535533905932737*speedsR[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.2795084971874738*JRatfL[23]-0.2795084971874737*JRatfL[22]+0.2795084971874737*(JRatfL[21]+JRatfL[20])-0.2795084971874738*(JRatfL[19]+JRatfL[18])+0.2795084971874738*JRatfL[17]-0.2795084971874737*JRatfL[16]-0.25*JRatfL[12]+0.25*JRatfL[9]-0.25*(JRatfL[8]+JRatfL[5])+0.25*(JRatfL[4]+JRatfL[2])-0.25*JRatfL[1]+0.25*JRatfL[0]; + JfR_quad = -(0.34232659844072866*JfR[47])+0.3423265984407287*JfR[46]+0.19764235376052366*JfR[45]-0.3423265984407287*(JfR[44]+JfR[43])-0.19764235376052364*JfR[42]+0.34232659844072866*JfR[41]+0.19764235376052364*JfR[40]+0.34232659844072866*JfR[39]+0.19764235376052364*JfR[38]-0.34232659844072866*JfR[37]-0.19764235376052366*(JfR[36]+JfR[35])+0.3423265984407287*JfR[34]+0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*JfR[27]-0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]+0.3061862178478971*(JfR[20]+JfR[16])+0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]-0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*(JfR[5]+JfR[3])-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[10] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[15]-0.6123724356957944*speedsR[14]-0.3535533905932737*speedsR[13]+0.6123724356957944*speedsR[12]+0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]-0.3535533905932737*speedsR[9]+0.3535533905932737*speedsR[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.22360679774997894*JRatfL[23])+0.22360679774997896*JRatfL[22]-0.22360679774997896*(JRatfL[21]+JRatfL[20])+0.22360679774997894*JRatfL[19]+0.22360679774997902*JRatfL[18]-0.22360679774997902*JRatfL[17]+0.22360679774997896*JRatfL[16]-0.33541019662496846*JRatfL[15]+0.33541019662496846*JRatfL[14]-0.33541019662496846*JRatfL[13]-0.25*JRatfL[12]-0.33541019662496846*JRatfL[11]+0.33541019662496846*JRatfL[10]+0.25*JRatfL[9]-0.25*JRatfL[8]+0.33541019662496846*JRatfL[7]-0.33541019662496846*JRatfL[6]-0.25*JRatfL[5]+0.25*JRatfL[4]+0.33541019662496846*JRatfL[3]+0.25*JRatfL[2]-0.25*JRatfL[1]+0.25*JRatfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.27386127875258304*JfR[46]-0.15811388300841892*JfR[45]+0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]-0.273861278752583*JfR[41]-0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]-0.15811388300841892*JfR[38]+0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.41079191812887433*JfR[30]-0.2371708245126284*JfR[29]+0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]-0.41079191812887433*JfR[24]-0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]-0.41079191812887433*JfR[19]-0.2371708245126284*JfR[18]+0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]+0.2371708245126284*JfR[11]-0.41079191812887433*JfR[10]-0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[11] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[2].bmag; + Jc_quad = gkdgs[2].Jc; + B3_quad = gkdgs[2].B3; + normcurlbhat_quad = gkdgs[2].normcurlbhat; + bhat_quad[0] = gkdgs[2].bhat.x[0]; + bhat_quad[1] = gkdgs[2].bhat.x[1]; + bhat_quad[2] = gkdgs[2].bhat.x[2]; + area_elem_quad = dgs[2].area_elem; + + + alpha_quad = 0.6123724356957944*(speedsR[15]+speedsR[14])-0.3535533905932737*speedsR[13]-0.6123724356957944*speedsR[12]-0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]+0.3535533905932737*(speedsR[9]+speedsR[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.22360679774997894*JRatfL[23]+0.22360679774997896*JRatfL[22]-0.22360679774997896*(JRatfL[21]+JRatfL[20])-0.22360679774997894*JRatfL[19]-0.22360679774997902*JRatfL[18]+0.22360679774997902*JRatfL[17]+0.22360679774997896*JRatfL[16]-0.33541019662496846*(JRatfL[15]+JRatfL[14])+0.33541019662496846*JRatfL[13]+0.25*JRatfL[12]+0.33541019662496846*(JRatfL[11]+JRatfL[10])+0.25*JRatfL[9]-0.25*JRatfL[8]+0.33541019662496846*JRatfL[7]-0.33541019662496846*JRatfL[6]-0.25*(JRatfL[5]+JRatfL[4])-0.33541019662496846*JRatfL[3]-0.25*JRatfL[2]+0.25*(JRatfL[1]+JRatfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])-0.27386127875258304*JfR[46]+0.15811388300841892*JfR[45]+0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]+0.273861278752583*JfR[41]-0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]-0.15811388300841892*JfR[38]-0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*(JfR[31]+JfR[30])-0.2371708245126284*JfR[29]-0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]-0.41079191812887433*JfR[24]+0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]-0.41079191812887433*JfR[19]+0.2371708245126284*JfR[18]+0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]+0.2371708245126284*JfR[11]+0.41079191812887433*JfR[10]-0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[12] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsR[15]+speedsR[14])-0.3535533905932737*speedsR[13]-0.6123724356957944*speedsR[12]-0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]+0.3535533905932737*(speedsR[9]+speedsR[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.2795084971874738*JRatfL[23])-0.2795084971874737*JRatfL[22]+0.2795084971874737*(JRatfL[21]+JRatfL[20])+0.2795084971874738*(JRatfL[19]+JRatfL[18])-0.2795084971874738*JRatfL[17]-0.2795084971874737*JRatfL[16]+0.25*(JRatfL[12]+JRatfL[9])-0.25*(JRatfL[8]+JRatfL[5]+JRatfL[4]+JRatfL[2])+0.25*(JRatfL[1]+JRatfL[0]); + JfR_quad = 0.34232659844072866*JfR[47]+0.3423265984407287*JfR[46]-0.19764235376052366*JfR[45]-0.3423265984407287*(JfR[44]+JfR[43])-0.19764235376052364*JfR[42]-0.34232659844072866*JfR[41]+0.19764235376052364*JfR[40]-0.34232659844072866*JfR[39]+0.19764235376052364*JfR[38]+0.34232659844072866*JfR[37]+0.19764235376052366*(JfR[36]+JfR[35])+0.3423265984407287*JfR[34]-0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*(JfR[27]+JfR[22])+0.1767766952966368*JfR[21]+0.3061862178478971*(JfR[20]+JfR[16])+0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]+0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*(JfR[5]+JfR[3])-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[13] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsR[15]+speedsR[14])-0.3535533905932737*speedsR[13]-0.6123724356957944*speedsR[12]-0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]+0.3535533905932737*(speedsR[9]+speedsR[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.22360679774997894*JRatfL[23]+0.22360679774997896*JRatfL[22]-0.22360679774997896*(JRatfL[21]+JRatfL[20])-0.22360679774997894*JRatfL[19]-0.22360679774997902*JRatfL[18]+0.22360679774997902*JRatfL[17]+0.22360679774997896*JRatfL[16]+0.33541019662496846*(JRatfL[15]+JRatfL[14])-0.33541019662496846*JRatfL[13]+0.25*JRatfL[12]-0.33541019662496846*(JRatfL[11]+JRatfL[10])+0.25*JRatfL[9]-0.25*JRatfL[8]-0.33541019662496846*JRatfL[7]+0.33541019662496846*JRatfL[6]-0.25*(JRatfL[5]+JRatfL[4])+0.33541019662496846*JRatfL[3]-0.25*JRatfL[2]+0.25*(JRatfL[1]+JRatfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])-0.27386127875258304*JfR[46]+0.15811388300841892*JfR[45]+0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]+0.273861278752583*JfR[41]-0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]-0.15811388300841892*JfR[38]-0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*(JfR[31]+JfR[30])+0.2371708245126284*JfR[29]+0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]+0.41079191812887433*JfR[24]-0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]+0.41079191812887433*JfR[19]-0.2371708245126284*JfR[18]-0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]-0.2371708245126284*JfR[11]-0.41079191812887433*JfR[10]+0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[14] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsR[15]+speedsR[14])-0.3535533905932737*speedsR[13]-0.6123724356957944*speedsR[12]-0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]+0.3535533905932737*(speedsR[9]+speedsR[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.22360679774997894*JRatfL[23])-0.22360679774997896*JRatfL[22]+0.22360679774997896*JRatfL[21]-0.22360679774997896*JRatfL[20]+0.22360679774997894*JRatfL[19]-0.22360679774997902*JRatfL[18]+0.22360679774997902*JRatfL[17]+0.22360679774997896*JRatfL[16]+0.33541019662496846*(JRatfL[15]+JRatfL[14])-0.33541019662496846*JRatfL[13]-0.25*JRatfL[12]+0.33541019662496846*JRatfL[11]-0.33541019662496846*JRatfL[10]-0.25*JRatfL[9]+0.25*JRatfL[8]+0.33541019662496846*JRatfL[7]-0.33541019662496846*JRatfL[6]-0.25*JRatfL[5]+0.25*JRatfL[4]-0.33541019662496846*JRatfL[3]-0.25*JRatfL[2]+0.25*(JRatfL[1]+JRatfL[0]); + JfR_quad = 0.273861278752583*JfR[47]+0.27386127875258304*JfR[46]-0.15811388300841892*JfR[45]-0.27386127875258304*JfR[44]+0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]-0.273861278752583*JfR[41]+0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]-0.15811388300841892*JfR[38]-0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*(JfR[31]+JfR[30])+0.2371708245126284*JfR[29]+0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]+0.41079191812887433*JfR[24]-0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]-0.41079191812887433*JfR[19]+0.2371708245126284*JfR[18]+0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]+0.2371708245126284*JfR[11]+0.41079191812887433*JfR[10]-0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[15] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsR[15]+speedsR[14])-0.3535533905932737*speedsR[13]-0.6123724356957944*speedsR[12]-0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]+0.3535533905932737*(speedsR[9]+speedsR[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.2795084971874738*JRatfL[23]+0.2795084971874737*JRatfL[22]-0.2795084971874737*JRatfL[21]+0.2795084971874737*JRatfL[20]-0.2795084971874738*JRatfL[19]+0.2795084971874738*JRatfL[18]-0.2795084971874738*JRatfL[17]-0.2795084971874737*JRatfL[16]-0.25*(JRatfL[12]+JRatfL[9])+0.25*JRatfL[8]-0.25*JRatfL[5]+0.25*JRatfL[4]-0.25*JRatfL[2]+0.25*(JRatfL[1]+JRatfL[0]); + JfR_quad = -(0.34232659844072866*JfR[47])-0.3423265984407287*JfR[46]+0.19764235376052366*JfR[45]+0.3423265984407287*JfR[44]-0.3423265984407287*JfR[43]+0.19764235376052364*JfR[42]+0.34232659844072866*JfR[41]-0.19764235376052364*JfR[40]-0.34232659844072866*JfR[39]+0.19764235376052364*JfR[38]+0.34232659844072866*JfR[37]-0.19764235376052366*JfR[36]+0.19764235376052366*JfR[35]+0.3423265984407287*JfR[34]-0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*(JfR[27]+JfR[22])-0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]+0.3061862178478971*JfR[16]-0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]+0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[16] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsR[15]+speedsR[14])-0.3535533905932737*speedsR[13]-0.6123724356957944*speedsR[12]-0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]+0.3535533905932737*(speedsR[9]+speedsR[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.22360679774997894*JRatfL[23])-0.22360679774997896*JRatfL[22]+0.22360679774997896*JRatfL[21]-0.22360679774997896*JRatfL[20]+0.22360679774997894*JRatfL[19]-0.22360679774997902*JRatfL[18]+0.22360679774997902*JRatfL[17]+0.22360679774997896*JRatfL[16]-0.33541019662496846*(JRatfL[15]+JRatfL[14])+0.33541019662496846*JRatfL[13]-0.25*JRatfL[12]-0.33541019662496846*JRatfL[11]+0.33541019662496846*JRatfL[10]-0.25*JRatfL[9]+0.25*JRatfL[8]-0.33541019662496846*JRatfL[7]+0.33541019662496846*JRatfL[6]-0.25*JRatfL[5]+0.25*JRatfL[4]+0.33541019662496846*JRatfL[3]-0.25*JRatfL[2]+0.25*(JRatfL[1]+JRatfL[0]); + JfR_quad = 0.273861278752583*JfR[47]+0.27386127875258304*JfR[46]-0.15811388300841892*JfR[45]-0.27386127875258304*JfR[44]+0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]-0.273861278752583*JfR[41]+0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]-0.15811388300841892*JfR[38]-0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*(JfR[31]+JfR[30])-0.2371708245126284*JfR[29]-0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]-0.41079191812887433*JfR[24]+0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]+0.41079191812887433*JfR[19]-0.2371708245126284*JfR[18]-0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]-0.2371708245126284*JfR[11]-0.41079191812887433*JfR[10]+0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[17] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[3].bmag; + Jc_quad = gkdgs[3].Jc; + B3_quad = gkdgs[3].B3; + normcurlbhat_quad = gkdgs[3].normcurlbhat; + bhat_quad[0] = gkdgs[3].bhat.x[0]; + bhat_quad[1] = gkdgs[3].bhat.x[1]; + bhat_quad[2] = gkdgs[3].bhat.x[2]; + area_elem_quad = dgs[3].area_elem; + + + alpha_quad = -(0.6123724356957944*(speedsR[15]+speedsR[14]))+0.3535533905932737*speedsR[13]-0.6123724356957944*speedsR[12]+0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]+0.3535533905932737*(speedsR[9]+speedsR[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.22360679774997894*JRatfL[23])-0.22360679774997896*(JRatfL[22]+JRatfL[21])+0.22360679774997896*JRatfL[20]-0.22360679774997894*JRatfL[19]+0.22360679774997902*(JRatfL[18]+JRatfL[17])+0.22360679774997896*JRatfL[16]+0.33541019662496846*(JRatfL[15]+JRatfL[14]+JRatfL[13])-0.25*JRatfL[12]-0.33541019662496846*JRatfL[11]+0.33541019662496846*JRatfL[10]-0.25*(JRatfL[9]+JRatfL[8])-0.33541019662496846*(JRatfL[7]+JRatfL[6])+0.25*JRatfL[5]-0.25*JRatfL[4]-0.33541019662496846*JRatfL[3]+0.25*(JRatfL[2]+JRatfL[1]+JRatfL[0]); + JfR_quad = 0.273861278752583*JfR[47]+0.27386127875258304*JfR[46]-0.15811388300841892*JfR[45]+0.27386127875258304*JfR[44]-0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]+0.273861278752583*JfR[41]-0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]+0.15811388300841892*JfR[38]-0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*(JfR[31]+JfR[30])+0.2371708245126284*JfR[29]-0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]-0.41079191812887433*JfR[24]+0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]+0.41079191812887433*JfR[19]-0.2371708245126284*JfR[18]+0.41079191812887433*JfR[17]-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]-0.2371708245126284*JfR[11]+0.41079191812887433*JfR[10]-0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[18] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsR[15]+speedsR[14]))+0.3535533905932737*speedsR[13]-0.6123724356957944*speedsR[12]+0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]+0.3535533905932737*(speedsR[9]+speedsR[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.2795084971874738*JRatfL[23]+0.2795084971874737*(JRatfL[22]+JRatfL[21])-0.2795084971874737*JRatfL[20]+0.2795084971874738*JRatfL[19]-0.2795084971874738*(JRatfL[18]+JRatfL[17])-0.2795084971874737*JRatfL[16]-0.25*(JRatfL[12]+JRatfL[9]+JRatfL[8])+0.25*JRatfL[5]-0.25*JRatfL[4]+0.25*(JRatfL[2]+JRatfL[1]+JRatfL[0]); + JfR_quad = -(0.34232659844072866*JfR[47])-0.3423265984407287*JfR[46]+0.19764235376052366*JfR[45]-0.3423265984407287*JfR[44]+0.3423265984407287*JfR[43]+0.19764235376052364*JfR[42]-0.34232659844072866*JfR[41]+0.19764235376052364*JfR[40]+0.34232659844072866*JfR[39]-0.19764235376052364*JfR[38]+0.34232659844072866*JfR[37]+0.19764235376052366*JfR[36]-0.19764235376052366*JfR[35]+0.3423265984407287*JfR[34]-0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*(JfR[27]+JfR[22])-0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]-0.3061862178478971*JfR[16]-0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]-0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[19] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsR[15]+speedsR[14]))+0.3535533905932737*speedsR[13]-0.6123724356957944*speedsR[12]+0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]+0.3535533905932737*(speedsR[9]+speedsR[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.22360679774997894*JRatfL[23])-0.22360679774997896*(JRatfL[22]+JRatfL[21])+0.22360679774997896*JRatfL[20]-0.22360679774997894*JRatfL[19]+0.22360679774997902*(JRatfL[18]+JRatfL[17])+0.22360679774997896*JRatfL[16]-0.33541019662496846*(JRatfL[15]+JRatfL[14]+JRatfL[13])-0.25*JRatfL[12]+0.33541019662496846*JRatfL[11]-0.33541019662496846*JRatfL[10]-0.25*(JRatfL[9]+JRatfL[8])+0.33541019662496846*(JRatfL[7]+JRatfL[6])+0.25*JRatfL[5]-0.25*JRatfL[4]+0.33541019662496846*JRatfL[3]+0.25*(JRatfL[2]+JRatfL[1]+JRatfL[0]); + JfR_quad = 0.273861278752583*JfR[47]+0.27386127875258304*JfR[46]-0.15811388300841892*JfR[45]+0.27386127875258304*JfR[44]-0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]+0.273861278752583*JfR[41]-0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]+0.15811388300841892*JfR[38]-0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*(JfR[31]+JfR[30])-0.2371708245126284*JfR[29]+0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]+0.41079191812887433*JfR[24]-0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]-0.41079191812887433*JfR[19]+0.2371708245126284*JfR[18]-0.41079191812887433*JfR[17]-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]+0.2371708245126284*JfR[11]-0.41079191812887433*JfR[10]+0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[20] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsR[15]+speedsR[14]))+0.3535533905932737*speedsR[13]-0.6123724356957944*speedsR[12]+0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]+0.3535533905932737*(speedsR[9]+speedsR[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.22360679774997894*JRatfL[23]+0.22360679774997896*(JRatfL[22]+JRatfL[21]+JRatfL[20])+0.22360679774997894*JRatfL[19]+0.22360679774997902*(JRatfL[18]+JRatfL[17])+0.22360679774997896*JRatfL[16]-0.33541019662496846*(JRatfL[15]+JRatfL[14]+JRatfL[13])+0.25*JRatfL[12]-0.33541019662496846*(JRatfL[11]+JRatfL[10])+0.25*(JRatfL[9]+JRatfL[8])-0.33541019662496846*(JRatfL[7]+JRatfL[6])+0.25*(JRatfL[5]+JRatfL[4])-0.33541019662496846*JRatfL[3]+0.25*(JRatfL[2]+JRatfL[1]+JRatfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])-0.27386127875258304*JfR[46]+0.15811388300841892*JfR[45]-0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]-0.273861278752583*JfR[41]+0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]+0.15811388300841892*JfR[38]-0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*(JfR[31]+JfR[30])-0.2371708245126284*JfR[29]+0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]+0.41079191812887433*JfR[24]-0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]+0.41079191812887433*JfR[19]-0.2371708245126284*JfR[18]+0.41079191812887433*JfR[17]-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]-0.2371708245126284*JfR[11]+0.41079191812887433*JfR[10]-0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[21] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsR[15]+speedsR[14]))+0.3535533905932737*speedsR[13]-0.6123724356957944*speedsR[12]+0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]+0.3535533905932737*(speedsR[9]+speedsR[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.2795084971874738*JRatfL[23])-0.2795084971874737*(JRatfL[22]+JRatfL[21]+JRatfL[20])-0.2795084971874738*(JRatfL[19]+JRatfL[18]+JRatfL[17])-0.2795084971874737*JRatfL[16]+0.25*(JRatfL[12]+JRatfL[9]+JRatfL[8]+JRatfL[5]+JRatfL[4]+JRatfL[2]+JRatfL[1]+JRatfL[0]); + JfR_quad = 0.34232659844072866*JfR[47]+0.3423265984407287*JfR[46]-0.19764235376052366*JfR[45]+0.3423265984407287*(JfR[44]+JfR[43])-0.19764235376052364*JfR[42]+0.34232659844072866*JfR[41]-0.19764235376052364*JfR[40]+0.34232659844072866*JfR[39]-0.19764235376052364*JfR[38]+0.34232659844072866*JfR[37]-0.19764235376052366*(JfR[36]+JfR[35])+0.3423265984407287*JfR[34]-0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*(JfR[27]+JfR[22])+0.1767766952966368*JfR[21]-0.3061862178478971*(JfR[20]+JfR[16])+0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]-0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*(JfR[5]+JfR[3])-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[22] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsR[15]+speedsR[14]))+0.3535533905932737*speedsR[13]-0.6123724356957944*speedsR[12]+0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]+0.3535533905932737*(speedsR[9]+speedsR[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.22360679774997894*JRatfL[23]+0.22360679774997896*(JRatfL[22]+JRatfL[21]+JRatfL[20])+0.22360679774997894*JRatfL[19]+0.22360679774997902*(JRatfL[18]+JRatfL[17])+0.22360679774997896*JRatfL[16]+0.33541019662496846*(JRatfL[15]+JRatfL[14]+JRatfL[13])+0.25*JRatfL[12]+0.33541019662496846*(JRatfL[11]+JRatfL[10])+0.25*(JRatfL[9]+JRatfL[8])+0.33541019662496846*(JRatfL[7]+JRatfL[6])+0.25*(JRatfL[5]+JRatfL[4])+0.33541019662496846*JRatfL[3]+0.25*(JRatfL[2]+JRatfL[1]+JRatfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])-0.27386127875258304*JfR[46]+0.15811388300841892*JfR[45]-0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]-0.273861278752583*JfR[41]+0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]+0.15811388300841892*JfR[38]-0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*(JfR[31]+JfR[30])+0.2371708245126284*JfR[29]-0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]-0.41079191812887433*JfR[24]+0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]-0.41079191812887433*JfR[19]+0.2371708245126284*JfR[18]-0.41079191812887433*JfR[17]-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]+0.2371708245126284*JfR[11]-0.41079191812887433*JfR[10]+0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[23] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdy2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfz_3x2v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfz_3x2v_ser_p1.c new file mode 100644 index 0000000000..b2a8696ed4 --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfz_3x2v_ser_p1.c @@ -0,0 +1,329 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_surfz_3x2v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdy2 = 2.0/dxv[1]; + double rdz2 = 2.0/dxv[2]; + double rdvpar2 = 2.0/dxv[3]; + + double JRatfL[24] = {0.}; + JRatfL[0] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[3]*JfL[16]+jacobgeo_rat_surfL[2]*JfL[8]+jacobgeo_rat_surfL[1]*JfL[7]+jacobgeo_rat_surfL[0]*JfL[3])+1.4142135623730951*(jacobgeo_rat_surfL[3]*JfL[6]+JfL[2]*jacobgeo_rat_surfL[2]+JfL[1]*jacobgeo_rat_surfL[1]+JfL[0]*jacobgeo_rat_surfL[0])); + JRatfL[1] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[2]*JfL[16]+jacobgeo_rat_surfL[3]*JfL[8]+jacobgeo_rat_surfL[0]*JfL[7]+jacobgeo_rat_surfL[1]*JfL[3])+1.4142135623730951*(jacobgeo_rat_surfL[2]*JfL[6]+JfL[2]*jacobgeo_rat_surfL[3]+JfL[0]*jacobgeo_rat_surfL[1]+jacobgeo_rat_surfL[0]*JfL[1])); + JRatfL[2] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[1]*JfL[16]+jacobgeo_rat_surfL[0]*JfL[8]+jacobgeo_rat_surfL[3]*JfL[7]+jacobgeo_rat_surfL[2]*JfL[3])+1.4142135623730951*(jacobgeo_rat_surfL[1]*JfL[6]+JfL[1]*jacobgeo_rat_surfL[3]+JfL[0]*jacobgeo_rat_surfL[2]+jacobgeo_rat_surfL[0]*JfL[2])); + JRatfL[3] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[3]*JfL[26]+jacobgeo_rat_surfL[2]*JfL[19]+jacobgeo_rat_surfL[1]*JfL[18]+jacobgeo_rat_surfL[0]*JfL[11])+1.4142135623730951*(jacobgeo_rat_surfL[3]*JfL[17]+jacobgeo_rat_surfL[2]*JfL[10]+jacobgeo_rat_surfL[1]*JfL[9]+jacobgeo_rat_surfL[0]*JfL[4])); + JRatfL[4] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[3]*JfL[27]+jacobgeo_rat_surfL[2]*JfL[22]+jacobgeo_rat_surfL[1]*JfL[21]+jacobgeo_rat_surfL[0]*JfL[14])+1.4142135623730951*(jacobgeo_rat_surfL[3]*JfL[20]+jacobgeo_rat_surfL[2]*JfL[13]+jacobgeo_rat_surfL[1]*JfL[12]+jacobgeo_rat_surfL[0]*JfL[5])); + JRatfL[5] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[0]*JfL[16]+jacobgeo_rat_surfL[1]*JfL[8]+jacobgeo_rat_surfL[2]*JfL[7]+JfL[3]*jacobgeo_rat_surfL[3])+1.4142135623730951*(jacobgeo_rat_surfL[0]*JfL[6]+JfL[0]*jacobgeo_rat_surfL[3]+JfL[1]*jacobgeo_rat_surfL[2]+jacobgeo_rat_surfL[1]*JfL[2])); + JRatfL[6] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[2]*JfL[26]+jacobgeo_rat_surfL[3]*JfL[19]+jacobgeo_rat_surfL[0]*JfL[18]+jacobgeo_rat_surfL[1]*JfL[11])+1.4142135623730951*(jacobgeo_rat_surfL[2]*JfL[17]+jacobgeo_rat_surfL[3]*JfL[10]+jacobgeo_rat_surfL[0]*JfL[9]+jacobgeo_rat_surfL[1]*JfL[4])); + JRatfL[7] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[1]*JfL[26]+jacobgeo_rat_surfL[0]*JfL[19]+jacobgeo_rat_surfL[3]*JfL[18]+jacobgeo_rat_surfL[2]*JfL[11])+1.4142135623730951*(jacobgeo_rat_surfL[1]*JfL[17]+jacobgeo_rat_surfL[0]*JfL[10]+jacobgeo_rat_surfL[3]*JfL[9]+jacobgeo_rat_surfL[2]*JfL[4])); + JRatfL[8] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[2]*JfL[27]+jacobgeo_rat_surfL[3]*JfL[22]+jacobgeo_rat_surfL[0]*JfL[21]+jacobgeo_rat_surfL[1]*JfL[14])+1.4142135623730951*(jacobgeo_rat_surfL[2]*JfL[20]+jacobgeo_rat_surfL[3]*JfL[13]+jacobgeo_rat_surfL[0]*JfL[12]+jacobgeo_rat_surfL[1]*JfL[5])); + JRatfL[9] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[1]*JfL[27]+jacobgeo_rat_surfL[0]*JfL[22]+jacobgeo_rat_surfL[3]*JfL[21]+jacobgeo_rat_surfL[2]*JfL[14])+1.4142135623730951*(jacobgeo_rat_surfL[1]*JfL[20]+jacobgeo_rat_surfL[0]*JfL[13]+jacobgeo_rat_surfL[3]*JfL[12]+jacobgeo_rat_surfL[2]*JfL[5])); + JRatfL[10] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[3]*JfL[31]+jacobgeo_rat_surfL[2]*JfL[30]+jacobgeo_rat_surfL[1]*JfL[29]+jacobgeo_rat_surfL[0]*JfL[25])+1.4142135623730951*(jacobgeo_rat_surfL[3]*JfL[28]+jacobgeo_rat_surfL[2]*JfL[24]+jacobgeo_rat_surfL[1]*JfL[23]+jacobgeo_rat_surfL[0]*JfL[15])); + JRatfL[11] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[0]*JfL[26]+jacobgeo_rat_surfL[1]*JfL[19]+jacobgeo_rat_surfL[2]*JfL[18]+jacobgeo_rat_surfL[3]*JfL[11])+1.4142135623730951*(jacobgeo_rat_surfL[0]*JfL[17]+jacobgeo_rat_surfL[1]*JfL[10]+jacobgeo_rat_surfL[2]*JfL[9]+jacobgeo_rat_surfL[3]*JfL[4])); + JRatfL[12] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[0]*JfL[27]+jacobgeo_rat_surfL[1]*JfL[22]+jacobgeo_rat_surfL[2]*JfL[21]+jacobgeo_rat_surfL[3]*JfL[14])+1.4142135623730951*(jacobgeo_rat_surfL[0]*JfL[20]+jacobgeo_rat_surfL[1]*JfL[13]+jacobgeo_rat_surfL[2]*JfL[12]+jacobgeo_rat_surfL[3]*JfL[5])); + JRatfL[13] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[2]*JfL[31]+jacobgeo_rat_surfL[3]*JfL[30]+jacobgeo_rat_surfL[0]*JfL[29]+jacobgeo_rat_surfL[1]*JfL[25])+1.4142135623730951*(jacobgeo_rat_surfL[2]*JfL[28]+jacobgeo_rat_surfL[3]*JfL[24]+jacobgeo_rat_surfL[0]*JfL[23]+jacobgeo_rat_surfL[1]*JfL[15])); + JRatfL[14] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[1]*JfL[31]+jacobgeo_rat_surfL[0]*JfL[30]+jacobgeo_rat_surfL[3]*JfL[29]+jacobgeo_rat_surfL[2]*JfL[25])+1.4142135623730951*(jacobgeo_rat_surfL[1]*JfL[28]+jacobgeo_rat_surfL[0]*JfL[24]+jacobgeo_rat_surfL[3]*JfL[23]+jacobgeo_rat_surfL[2]*JfL[15])); + JRatfL[15] = 0.25*(2.4494897427831783*(jacobgeo_rat_surfL[0]*JfL[31]+jacobgeo_rat_surfL[1]*JfL[30]+jacobgeo_rat_surfL[2]*JfL[29]+jacobgeo_rat_surfL[3]*JfL[25])+1.4142135623730951*(jacobgeo_rat_surfL[0]*JfL[28]+jacobgeo_rat_surfL[1]*JfL[24]+jacobgeo_rat_surfL[2]*JfL[23]+jacobgeo_rat_surfL[3]*JfL[15])); + JRatfL[16] = 0.016666666666666666*(8.660254037844387*(4.242640687119286*(jacobgeo_rat_surfL[3]*JfL[43]+jacobgeo_rat_surfL[0]*JfL[35])+2.4494897427831783*(jacobgeo_rat_surfL[2]*JfL[34]+jacobgeo_rat_surfL[1]*JfL[33]))+36.742346141747674*(jacobgeo_rat_surfL[2]*JfL[39]+jacobgeo_rat_surfL[1]*JfL[38])+21.213203435596427*(jacobgeo_rat_surfL[3]*JfL[37]+jacobgeo_rat_surfL[0]*JfL[32])); + JRatfL[17] = 0.016666666666666666*(36.742346141747674*(jacobgeo_rat_surfL[2]*JfL[43]+jacobgeo_rat_surfL[1]*JfL[35])+8.660254037844387*(4.242640687119286*(jacobgeo_rat_surfL[3]*JfL[39]+jacobgeo_rat_surfL[0]*JfL[38])+2.4494897427831783*(jacobgeo_rat_surfL[2]*JfL[37]+jacobgeo_rat_surfL[1]*JfL[32]))+21.213203435596427*(jacobgeo_rat_surfL[3]*JfL[34]+jacobgeo_rat_surfL[0]*JfL[33])); + JRatfL[18] = 0.016666666666666666*(36.742346141747674*(jacobgeo_rat_surfL[1]*JfL[43]+jacobgeo_rat_surfL[2]*JfL[35])+8.660254037844387*(4.242640687119286*(jacobgeo_rat_surfL[0]*JfL[39]+jacobgeo_rat_surfL[3]*JfL[38])+2.4494897427831783*(jacobgeo_rat_surfL[1]*JfL[37]+jacobgeo_rat_surfL[2]*JfL[32]))+21.213203435596427*(jacobgeo_rat_surfL[0]*JfL[34]+jacobgeo_rat_surfL[3]*JfL[33])); + JRatfL[19] = 0.016666666666666666*(8.660254037844387*(4.242640687119286*(jacobgeo_rat_surfL[3]*JfL[47]+jacobgeo_rat_surfL[0]*JfL[42])+2.4494897427831783*(jacobgeo_rat_surfL[2]*JfL[41]+jacobgeo_rat_surfL[1]*JfL[40]))+36.742346141747674*(jacobgeo_rat_surfL[2]*JfL[46]+jacobgeo_rat_surfL[1]*JfL[45])+21.213203435596427*(jacobgeo_rat_surfL[3]*JfL[44]+jacobgeo_rat_surfL[0]*JfL[36])); + JRatfL[20] = 0.016666666666666666*(8.660254037844387*(4.242640687119286*(jacobgeo_rat_surfL[0]*JfL[43]+jacobgeo_rat_surfL[3]*JfL[35])+2.4494897427831783*(jacobgeo_rat_surfL[1]*JfL[34]+jacobgeo_rat_surfL[2]*JfL[33]))+36.742346141747674*(jacobgeo_rat_surfL[1]*JfL[39]+jacobgeo_rat_surfL[2]*JfL[38])+21.213203435596427*(jacobgeo_rat_surfL[0]*JfL[37]+jacobgeo_rat_surfL[3]*JfL[32])); + JRatfL[21] = 0.016666666666666666*(36.742346141747674*(jacobgeo_rat_surfL[2]*JfL[47]+jacobgeo_rat_surfL[1]*JfL[42])+8.660254037844387*(4.242640687119286*(jacobgeo_rat_surfL[3]*JfL[46]+jacobgeo_rat_surfL[0]*JfL[45])+2.4494897427831783*(jacobgeo_rat_surfL[2]*JfL[44]+jacobgeo_rat_surfL[1]*JfL[36]))+21.213203435596427*(jacobgeo_rat_surfL[3]*JfL[41]+jacobgeo_rat_surfL[0]*JfL[40])); + JRatfL[22] = 0.016666666666666666*(36.742346141747674*(jacobgeo_rat_surfL[1]*JfL[47]+jacobgeo_rat_surfL[2]*JfL[42])+8.660254037844387*(4.242640687119286*(jacobgeo_rat_surfL[0]*JfL[46]+jacobgeo_rat_surfL[3]*JfL[45])+2.4494897427831783*(jacobgeo_rat_surfL[1]*JfL[44]+jacobgeo_rat_surfL[2]*JfL[36]))+21.213203435596427*(jacobgeo_rat_surfL[0]*JfL[41]+jacobgeo_rat_surfL[3]*JfL[40])); + JRatfL[23] = 0.016666666666666666*(8.660254037844387*(4.242640687119286*(jacobgeo_rat_surfL[0]*JfL[47]+jacobgeo_rat_surfL[3]*JfL[42])+2.4494897427831783*(jacobgeo_rat_surfL[1]*JfL[41]+jacobgeo_rat_surfL[2]*JfL[40]))+36.742346141747674*(jacobgeo_rat_surfL[1]*JfL[46]+jacobgeo_rat_surfL[2]*JfL[45])+21.213203435596427*(jacobgeo_rat_surfL[0]*JfL[44]+jacobgeo_rat_surfL[3]*JfL[36])); + + double *flux_surf_nodal = &flux_surf[48]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = -(0.6123724356957944*speedsR[23])+0.6123724356957944*(speedsR[22]+speedsR[21])+0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]-0.3535533905932737*(speedsR[18]+speedsR[17])+0.3535533905932737*speedsR[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.22360679774997894*JRatfL[23])+0.22360679774997896*(JRatfL[22]+JRatfL[21]+JRatfL[20])-0.22360679774997894*JRatfL[19]-0.22360679774997902*(JRatfL[18]+JRatfL[17])+0.22360679774997896*JRatfL[16]+0.33541019662496846*JRatfL[15]-0.33541019662496846*(JRatfL[14]+JRatfL[13])-0.25*JRatfL[12]-0.33541019662496846*JRatfL[11]+0.33541019662496846*JRatfL[10]+0.25*(JRatfL[9]+JRatfL[8])+0.33541019662496846*(JRatfL[7]+JRatfL[6])+0.25*JRatfL[5]-0.25*JRatfL[4]-0.33541019662496846*JRatfL[3]-0.25*(JRatfL[2]+JRatfL[1])+0.25*JRatfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.27386127875258304*(JfR[46]+JfR[45])-0.15811388300841892*JfR[44]-0.27386127875258304*JfR[43]+0.273861278752583*JfR[42]+0.15811388300841892*(JfR[41]+JfR[40])+0.273861278752583*(JfR[39]+JfR[38])+0.15811388300841892*JfR[37]-0.15811388300841892*JfR[36]-0.27386127875258304*JfR[35]-0.15811388300841894*(JfR[34]+JfR[33])+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.41079191812887433*(JfR[30]+JfR[29])+0.2371708245126284*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.41079191812887433*JfR[25]-0.2371708245126284*(JfR[24]+JfR[23])-0.3061862178478971*(JfR[22]+JfR[21])-0.1767766952966368*JfR[20]-0.41079191812887433*(JfR[19]+JfR[18])-0.2371708245126284*JfR[17]-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.3061862178478971*JfR[14]+0.1767766952966368*(JfR[13]+JfR[12])+0.41079191812887433*JfR[11]+0.2371708245126284*(JfR[10]+JfR[9])+0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*JfR[6]-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]-0.1767766952966368*(JfR[2]+JfR[1])+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[23])+0.6123724356957944*(speedsR[22]+speedsR[21])+0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]-0.3535533905932737*(speedsR[18]+speedsR[17])+0.3535533905932737*speedsR[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.2795084971874738*JRatfL[23]-0.2795084971874737*(JRatfL[22]+JRatfL[21]+JRatfL[20])+0.2795084971874738*(JRatfL[19]+JRatfL[18]+JRatfL[17])-0.2795084971874737*JRatfL[16]-0.25*JRatfL[12]+0.25*(JRatfL[9]+JRatfL[8]+JRatfL[5])-0.25*(JRatfL[4]+JRatfL[2]+JRatfL[1])+0.25*JRatfL[0]; + JfR_quad = -(0.34232659844072866*JfR[47])+0.3423265984407287*(JfR[46]+JfR[45])+0.19764235376052366*JfR[44]+0.3423265984407287*JfR[43]-0.34232659844072866*JfR[42]-0.19764235376052364*(JfR[41]+JfR[40])-0.34232659844072866*(JfR[39]+JfR[38])-0.19764235376052364*JfR[37]+0.19764235376052366*JfR[36]+0.3423265984407287*JfR[35]+0.19764235376052366*(JfR[34]+JfR[33])-0.19764235376052364*JfR[32]+0.3061862178478971*JfR[27]-0.3061862178478971*(JfR[22]+JfR[21])-0.1767766952966368*JfR[20]-0.3061862178478971*JfR[16]+0.3061862178478971*JfR[14]+0.1767766952966368*(JfR[13]+JfR[12])+0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*JfR[6]-0.1767766952966368*JfR[5]-0.3061862178478971*JfR[3]-0.1767766952966368*(JfR[2]+JfR[1])+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[23])+0.6123724356957944*(speedsR[22]+speedsR[21])+0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]-0.3535533905932737*(speedsR[18]+speedsR[17])+0.3535533905932737*speedsR[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.22360679774997894*JRatfL[23])+0.22360679774997896*(JRatfL[22]+JRatfL[21]+JRatfL[20])-0.22360679774997894*JRatfL[19]-0.22360679774997902*(JRatfL[18]+JRatfL[17])+0.22360679774997896*JRatfL[16]-0.33541019662496846*JRatfL[15]+0.33541019662496846*(JRatfL[14]+JRatfL[13])-0.25*JRatfL[12]+0.33541019662496846*JRatfL[11]-0.33541019662496846*JRatfL[10]+0.25*(JRatfL[9]+JRatfL[8])-0.33541019662496846*(JRatfL[7]+JRatfL[6])+0.25*JRatfL[5]-0.25*JRatfL[4]+0.33541019662496846*JRatfL[3]-0.25*(JRatfL[2]+JRatfL[1])+0.25*JRatfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.27386127875258304*(JfR[46]+JfR[45])-0.15811388300841892*JfR[44]-0.27386127875258304*JfR[43]+0.273861278752583*JfR[42]+0.15811388300841892*(JfR[41]+JfR[40])+0.273861278752583*(JfR[39]+JfR[38])+0.15811388300841892*JfR[37]-0.15811388300841892*JfR[36]-0.27386127875258304*JfR[35]-0.15811388300841894*(JfR[34]+JfR[33])+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.41079191812887433*(JfR[30]+JfR[29])-0.2371708245126284*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.41079191812887433*JfR[25]+0.2371708245126284*(JfR[24]+JfR[23])-0.3061862178478971*(JfR[22]+JfR[21])-0.1767766952966368*JfR[20]+0.41079191812887433*(JfR[19]+JfR[18])+0.2371708245126284*JfR[17]-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.3061862178478971*JfR[14]+0.1767766952966368*(JfR[13]+JfR[12])-0.41079191812887433*JfR[11]-0.2371708245126284*(JfR[10]+JfR[9])+0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*JfR[6]-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]-0.1767766952966368*(JfR[2]+JfR[1])+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[23])+0.6123724356957944*(speedsR[22]+speedsR[21])+0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]-0.3535533905932737*(speedsR[18]+speedsR[17])+0.3535533905932737*speedsR[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.22360679774997894*JRatfL[23]-0.22360679774997896*(JRatfL[22]+JRatfL[21])+0.22360679774997896*JRatfL[20]+0.22360679774997894*JRatfL[19]-0.22360679774997902*(JRatfL[18]+JRatfL[17])+0.22360679774997896*JRatfL[16]-0.33541019662496846*JRatfL[15]+0.33541019662496846*(JRatfL[14]+JRatfL[13])+0.25*JRatfL[12]-0.33541019662496846*(JRatfL[11]+JRatfL[10])-0.25*(JRatfL[9]+JRatfL[8])+0.33541019662496846*(JRatfL[7]+JRatfL[6])+0.25*(JRatfL[5]+JRatfL[4])-0.33541019662496846*JRatfL[3]-0.25*(JRatfL[2]+JRatfL[1])+0.25*JRatfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.27386127875258304*(JfR[46]+JfR[45])+0.15811388300841892*JfR[44]-0.27386127875258304*JfR[43]-0.273861278752583*JfR[42]-0.15811388300841892*(JfR[41]+JfR[40])+0.273861278752583*(JfR[39]+JfR[38])+0.15811388300841892*(JfR[37]+JfR[36])-0.27386127875258304*JfR[35]-0.15811388300841894*(JfR[34]+JfR[33])+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.41079191812887433*(JfR[30]+JfR[29])-0.2371708245126284*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*(JfR[26]+JfR[25])+0.2371708245126284*(JfR[24]+JfR[23])+0.3061862178478971*(JfR[22]+JfR[21])+0.1767766952966368*JfR[20]-0.41079191812887433*(JfR[19]+JfR[18])-0.2371708245126284*JfR[17]-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.3061862178478971*JfR[14]-0.1767766952966368*(JfR[13]+JfR[12])+0.41079191812887433*JfR[11]+0.2371708245126284*(JfR[10]+JfR[9])+0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*(JfR[6]+JfR[5])-0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]-0.1767766952966368*(JfR[2]+JfR[1])+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[3] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[23])+0.6123724356957944*(speedsR[22]+speedsR[21])+0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]-0.3535533905932737*(speedsR[18]+speedsR[17])+0.3535533905932737*speedsR[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.2795084971874738*JRatfL[23])+0.2795084971874737*(JRatfL[22]+JRatfL[21])-0.2795084971874737*JRatfL[20]-0.2795084971874738*JRatfL[19]+0.2795084971874738*(JRatfL[18]+JRatfL[17])-0.2795084971874737*JRatfL[16]+0.25*JRatfL[12]-0.25*(JRatfL[9]+JRatfL[8])+0.25*(JRatfL[5]+JRatfL[4])-0.25*(JRatfL[2]+JRatfL[1])+0.25*JRatfL[0]; + JfR_quad = 0.34232659844072866*JfR[47]-0.3423265984407287*(JfR[46]+JfR[45])-0.19764235376052366*JfR[44]+0.3423265984407287*JfR[43]+0.34232659844072866*JfR[42]+0.19764235376052364*(JfR[41]+JfR[40])-0.34232659844072866*(JfR[39]+JfR[38])-0.19764235376052364*JfR[37]-0.19764235376052366*JfR[36]+0.3423265984407287*JfR[35]+0.19764235376052366*(JfR[34]+JfR[33])-0.19764235376052364*JfR[32]-0.3061862178478971*JfR[27]+0.3061862178478971*(JfR[22]+JfR[21])+0.1767766952966368*JfR[20]-0.3061862178478971*(JfR[16]+JfR[14])-0.1767766952966368*(JfR[13]+JfR[12])+0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*(JfR[6]+JfR[5])-0.3061862178478971*JfR[3]-0.1767766952966368*(JfR[2]+JfR[1])+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[4] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[23])+0.6123724356957944*(speedsR[22]+speedsR[21])+0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]-0.3535533905932737*(speedsR[18]+speedsR[17])+0.3535533905932737*speedsR[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.22360679774997894*JRatfL[23]-0.22360679774997896*(JRatfL[22]+JRatfL[21])+0.22360679774997896*JRatfL[20]+0.22360679774997894*JRatfL[19]-0.22360679774997902*(JRatfL[18]+JRatfL[17])+0.22360679774997896*JRatfL[16]+0.33541019662496846*JRatfL[15]-0.33541019662496846*(JRatfL[14]+JRatfL[13])+0.25*JRatfL[12]+0.33541019662496846*(JRatfL[11]+JRatfL[10])-0.25*(JRatfL[9]+JRatfL[8])-0.33541019662496846*(JRatfL[7]+JRatfL[6])+0.25*(JRatfL[5]+JRatfL[4])+0.33541019662496846*JRatfL[3]-0.25*(JRatfL[2]+JRatfL[1])+0.25*JRatfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.27386127875258304*(JfR[46]+JfR[45])+0.15811388300841892*JfR[44]-0.27386127875258304*JfR[43]-0.273861278752583*JfR[42]-0.15811388300841892*(JfR[41]+JfR[40])+0.273861278752583*(JfR[39]+JfR[38])+0.15811388300841892*(JfR[37]+JfR[36])-0.27386127875258304*JfR[35]-0.15811388300841894*(JfR[34]+JfR[33])+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.41079191812887433*(JfR[30]+JfR[29])+0.2371708245126284*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*(JfR[26]+JfR[25])-0.2371708245126284*(JfR[24]+JfR[23])+0.3061862178478971*(JfR[22]+JfR[21])+0.1767766952966368*JfR[20]+0.41079191812887433*(JfR[19]+JfR[18])+0.2371708245126284*JfR[17]-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.3061862178478971*JfR[14]-0.1767766952966368*(JfR[13]+JfR[12])-0.41079191812887433*JfR[11]-0.2371708245126284*(JfR[10]+JfR[9])+0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*(JfR[6]+JfR[5])+0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]-0.1767766952966368*(JfR[2]+JfR[1])+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[5] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[1].bmag; + Jc_quad = gkdgs[1].Jc; + B3_quad = gkdgs[1].B3; + normcurlbhat_quad = gkdgs[1].normcurlbhat; + bhat_quad[0] = gkdgs[1].bhat.x[0]; + bhat_quad[1] = gkdgs[1].bhat.x[1]; + bhat_quad[2] = gkdgs[1].bhat.x[2]; + area_elem_quad = dgs[1].area_elem; + + + alpha_quad = 0.6123724356957944*speedsR[23]-0.6123724356957944*speedsR[22]+0.6123724356957944*speedsR[21]-0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]+0.3535533905932737*speedsR[18]-0.3535533905932737*speedsR[17]+0.3535533905932737*speedsR[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.22360679774997894*JRatfL[23]-0.22360679774997896*JRatfL[22]+0.22360679774997896*JRatfL[21]-0.22360679774997896*JRatfL[20]-0.22360679774997894*JRatfL[19]+0.22360679774997902*JRatfL[18]-0.22360679774997902*JRatfL[17]+0.22360679774997896*JRatfL[16]-0.33541019662496846*JRatfL[15]+0.33541019662496846*JRatfL[14]-0.33541019662496846*JRatfL[13]+0.25*JRatfL[12]+0.33541019662496846*(JRatfL[11]+JRatfL[10])-0.25*JRatfL[9]+0.25*JRatfL[8]-0.33541019662496846*JRatfL[7]+0.33541019662496846*JRatfL[6]-0.25*(JRatfL[5]+JRatfL[4])-0.33541019662496846*JRatfL[3]+0.25*JRatfL[2]-0.25*JRatfL[1]+0.25*JRatfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.27386127875258304*JfR[46]-0.27386127875258304*JfR[45]+0.15811388300841892*JfR[44]+0.27386127875258304*JfR[43]+0.273861278752583*JfR[42]-0.15811388300841892*JfR[41]+0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]+0.273861278752583*JfR[38]-0.15811388300841892*(JfR[37]+JfR[36])-0.27386127875258304*JfR[35]+0.15811388300841894*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.41079191812887433*JfR[30]+0.41079191812887433*JfR[29]-0.2371708245126284*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*(JfR[26]+JfR[25])+0.2371708245126284*JfR[24]-0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]-0.3061862178478971*JfR[21]+0.1767766952966368*JfR[20]+0.41079191812887433*JfR[19]-0.41079191812887433*JfR[18]+0.2371708245126284*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.3061862178478971*JfR[14]-0.1767766952966368*JfR[13]+0.1767766952966368*JfR[12]+0.41079191812887433*JfR[11]-0.2371708245126284*JfR[10]+0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]+0.3061862178478971*JfR[7]-0.1767766952966368*(JfR[6]+JfR[5])-0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]+0.1767766952966368*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[6] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[23]-0.6123724356957944*speedsR[22]+0.6123724356957944*speedsR[21]-0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]+0.3535533905932737*speedsR[18]-0.3535533905932737*speedsR[17]+0.3535533905932737*speedsR[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.2795084971874738*JRatfL[23])+0.2795084971874737*JRatfL[22]-0.2795084971874737*JRatfL[21]+0.2795084971874737*JRatfL[20]+0.2795084971874738*JRatfL[19]-0.2795084971874738*JRatfL[18]+0.2795084971874738*JRatfL[17]-0.2795084971874737*JRatfL[16]+0.25*JRatfL[12]-0.25*JRatfL[9]+0.25*JRatfL[8]-0.25*(JRatfL[5]+JRatfL[4])+0.25*JRatfL[2]-0.25*JRatfL[1]+0.25*JRatfL[0]; + JfR_quad = 0.34232659844072866*JfR[47]-0.3423265984407287*JfR[46]+0.3423265984407287*JfR[45]-0.19764235376052366*JfR[44]-0.3423265984407287*JfR[43]-0.34232659844072866*JfR[42]+0.19764235376052364*JfR[41]-0.19764235376052364*JfR[40]+0.34232659844072866*JfR[39]-0.34232659844072866*JfR[38]+0.19764235376052364*JfR[37]+0.19764235376052366*JfR[36]+0.3423265984407287*JfR[35]-0.19764235376052366*JfR[34]+0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*JfR[27]+0.3061862178478971*JfR[22]-0.3061862178478971*JfR[21]+0.1767766952966368*JfR[20]+0.3061862178478971*(JfR[16]+JfR[14])-0.1767766952966368*JfR[13]+0.1767766952966368*JfR[12]-0.3061862178478971*JfR[8]+0.3061862178478971*JfR[7]-0.1767766952966368*(JfR[6]+JfR[5])-0.3061862178478971*JfR[3]+0.1767766952966368*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[7] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[23]-0.6123724356957944*speedsR[22]+0.6123724356957944*speedsR[21]-0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]+0.3535533905932737*speedsR[18]-0.3535533905932737*speedsR[17]+0.3535533905932737*speedsR[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.22360679774997894*JRatfL[23]-0.22360679774997896*JRatfL[22]+0.22360679774997896*JRatfL[21]-0.22360679774997896*JRatfL[20]-0.22360679774997894*JRatfL[19]+0.22360679774997902*JRatfL[18]-0.22360679774997902*JRatfL[17]+0.22360679774997896*JRatfL[16]+0.33541019662496846*JRatfL[15]-0.33541019662496846*JRatfL[14]+0.33541019662496846*JRatfL[13]+0.25*JRatfL[12]-0.33541019662496846*(JRatfL[11]+JRatfL[10])-0.25*JRatfL[9]+0.25*JRatfL[8]+0.33541019662496846*JRatfL[7]-0.33541019662496846*JRatfL[6]-0.25*(JRatfL[5]+JRatfL[4])+0.33541019662496846*JRatfL[3]+0.25*JRatfL[2]-0.25*JRatfL[1]+0.25*JRatfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.27386127875258304*JfR[46]-0.27386127875258304*JfR[45]+0.15811388300841892*JfR[44]+0.27386127875258304*JfR[43]+0.273861278752583*JfR[42]-0.15811388300841892*JfR[41]+0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]+0.273861278752583*JfR[38]-0.15811388300841892*(JfR[37]+JfR[36])-0.27386127875258304*JfR[35]+0.15811388300841894*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.41079191812887433*JfR[30]-0.41079191812887433*JfR[29]+0.2371708245126284*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*(JfR[26]+JfR[25])-0.2371708245126284*JfR[24]+0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]-0.3061862178478971*JfR[21]+0.1767766952966368*JfR[20]-0.41079191812887433*JfR[19]+0.41079191812887433*JfR[18]-0.2371708245126284*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.3061862178478971*JfR[14]-0.1767766952966368*JfR[13]+0.1767766952966368*JfR[12]-0.41079191812887433*JfR[11]+0.2371708245126284*JfR[10]-0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]+0.3061862178478971*JfR[7]-0.1767766952966368*(JfR[6]+JfR[5])+0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]+0.1767766952966368*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[8] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[23]-0.6123724356957944*speedsR[22]+0.6123724356957944*speedsR[21]-0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]+0.3535533905932737*speedsR[18]-0.3535533905932737*speedsR[17]+0.3535533905932737*speedsR[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.22360679774997894*JRatfL[23])+0.22360679774997896*JRatfL[22]-0.22360679774997896*(JRatfL[21]+JRatfL[20])+0.22360679774997894*JRatfL[19]+0.22360679774997902*JRatfL[18]-0.22360679774997902*JRatfL[17]+0.22360679774997896*JRatfL[16]+0.33541019662496846*JRatfL[15]-0.33541019662496846*JRatfL[14]+0.33541019662496846*JRatfL[13]-0.25*JRatfL[12]+0.33541019662496846*JRatfL[11]-0.33541019662496846*JRatfL[10]+0.25*JRatfL[9]-0.25*JRatfL[8]-0.33541019662496846*JRatfL[7]+0.33541019662496846*JRatfL[6]-0.25*JRatfL[5]+0.25*JRatfL[4]-0.33541019662496846*JRatfL[3]+0.25*JRatfL[2]-0.25*JRatfL[1]+0.25*JRatfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.27386127875258304*JfR[46]+0.27386127875258304*JfR[45]-0.15811388300841892*JfR[44]+0.27386127875258304*JfR[43]-0.273861278752583*JfR[42]+0.15811388300841892*JfR[41]-0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]+0.273861278752583*JfR[38]-0.15811388300841892*JfR[37]+0.15811388300841892*JfR[36]-0.27386127875258304*JfR[35]+0.15811388300841894*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.41079191812887433*JfR[30]-0.41079191812887433*JfR[29]+0.2371708245126284*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.41079191812887433*JfR[25]-0.2371708245126284*JfR[24]+0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]+0.3061862178478971*JfR[21]-0.1767766952966368*JfR[20]+0.41079191812887433*JfR[19]-0.41079191812887433*JfR[18]+0.2371708245126284*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.3061862178478971*JfR[14]+0.1767766952966368*JfR[13]-0.1767766952966368*JfR[12]+0.41079191812887433*JfR[11]-0.2371708245126284*JfR[10]+0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]+0.3061862178478971*JfR[7]-0.1767766952966368*JfR[6]+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]+0.1767766952966368*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[9] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[23]-0.6123724356957944*speedsR[22]+0.6123724356957944*speedsR[21]-0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]+0.3535533905932737*speedsR[18]-0.3535533905932737*speedsR[17]+0.3535533905932737*speedsR[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.2795084971874738*JRatfL[23]-0.2795084971874737*JRatfL[22]+0.2795084971874737*(JRatfL[21]+JRatfL[20])-0.2795084971874738*(JRatfL[19]+JRatfL[18])+0.2795084971874738*JRatfL[17]-0.2795084971874737*JRatfL[16]-0.25*JRatfL[12]+0.25*JRatfL[9]-0.25*(JRatfL[8]+JRatfL[5])+0.25*(JRatfL[4]+JRatfL[2])-0.25*JRatfL[1]+0.25*JRatfL[0]; + JfR_quad = -(0.34232659844072866*JfR[47])+0.3423265984407287*JfR[46]-0.3423265984407287*JfR[45]+0.19764235376052366*JfR[44]-0.3423265984407287*JfR[43]+0.34232659844072866*JfR[42]-0.19764235376052364*JfR[41]+0.19764235376052364*JfR[40]+0.34232659844072866*JfR[39]-0.34232659844072866*JfR[38]+0.19764235376052364*JfR[37]-0.19764235376052366*JfR[36]+0.3423265984407287*JfR[35]-0.19764235376052366*JfR[34]+0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*JfR[27]-0.3061862178478971*JfR[22]+0.3061862178478971*JfR[21]-0.1767766952966368*JfR[20]+0.3061862178478971*JfR[16]-0.3061862178478971*JfR[14]+0.1767766952966368*JfR[13]-0.1767766952966368*JfR[12]-0.3061862178478971*JfR[8]+0.3061862178478971*JfR[7]-0.1767766952966368*JfR[6]+0.1767766952966368*JfR[5]-0.3061862178478971*JfR[3]+0.1767766952966368*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[10] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[23]-0.6123724356957944*speedsR[22]+0.6123724356957944*speedsR[21]-0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]+0.3535533905932737*speedsR[18]-0.3535533905932737*speedsR[17]+0.3535533905932737*speedsR[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.22360679774997894*JRatfL[23])+0.22360679774997896*JRatfL[22]-0.22360679774997896*(JRatfL[21]+JRatfL[20])+0.22360679774997894*JRatfL[19]+0.22360679774997902*JRatfL[18]-0.22360679774997902*JRatfL[17]+0.22360679774997896*JRatfL[16]-0.33541019662496846*JRatfL[15]+0.33541019662496846*JRatfL[14]-0.33541019662496846*JRatfL[13]-0.25*JRatfL[12]-0.33541019662496846*JRatfL[11]+0.33541019662496846*JRatfL[10]+0.25*JRatfL[9]-0.25*JRatfL[8]+0.33541019662496846*JRatfL[7]-0.33541019662496846*JRatfL[6]-0.25*JRatfL[5]+0.25*JRatfL[4]+0.33541019662496846*JRatfL[3]+0.25*JRatfL[2]-0.25*JRatfL[1]+0.25*JRatfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.27386127875258304*JfR[46]+0.27386127875258304*JfR[45]-0.15811388300841892*JfR[44]+0.27386127875258304*JfR[43]-0.273861278752583*JfR[42]+0.15811388300841892*JfR[41]-0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]+0.273861278752583*JfR[38]-0.15811388300841892*JfR[37]+0.15811388300841892*JfR[36]-0.27386127875258304*JfR[35]+0.15811388300841894*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.41079191812887433*JfR[30]+0.41079191812887433*JfR[29]-0.2371708245126284*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.41079191812887433*JfR[25]+0.2371708245126284*JfR[24]-0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]+0.3061862178478971*JfR[21]-0.1767766952966368*JfR[20]-0.41079191812887433*JfR[19]+0.41079191812887433*JfR[18]-0.2371708245126284*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.3061862178478971*JfR[14]+0.1767766952966368*JfR[13]-0.1767766952966368*JfR[12]-0.41079191812887433*JfR[11]+0.2371708245126284*JfR[10]-0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]+0.3061862178478971*JfR[7]-0.1767766952966368*JfR[6]+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]+0.1767766952966368*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[11] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[2].bmag; + Jc_quad = gkdgs[2].Jc; + B3_quad = gkdgs[2].B3; + normcurlbhat_quad = gkdgs[2].normcurlbhat; + bhat_quad[0] = gkdgs[2].bhat.x[0]; + bhat_quad[1] = gkdgs[2].bhat.x[1]; + bhat_quad[2] = gkdgs[2].bhat.x[2]; + area_elem_quad = dgs[2].area_elem; + + + alpha_quad = 0.6123724356957944*(speedsR[23]+speedsR[22])-0.6123724356957944*speedsR[21]-0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]-0.3535533905932737*speedsR[18]+0.3535533905932737*(speedsR[17]+speedsR[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.22360679774997894*JRatfL[23]+0.22360679774997896*JRatfL[22]-0.22360679774997896*(JRatfL[21]+JRatfL[20])-0.22360679774997894*JRatfL[19]-0.22360679774997902*JRatfL[18]+0.22360679774997902*JRatfL[17]+0.22360679774997896*JRatfL[16]-0.33541019662496846*(JRatfL[15]+JRatfL[14])+0.33541019662496846*JRatfL[13]+0.25*JRatfL[12]+0.33541019662496846*(JRatfL[11]+JRatfL[10])+0.25*JRatfL[9]-0.25*JRatfL[8]+0.33541019662496846*JRatfL[7]-0.33541019662496846*JRatfL[6]-0.25*(JRatfL[5]+JRatfL[4])-0.33541019662496846*JRatfL[3]-0.25*JRatfL[2]+0.25*(JRatfL[1]+JRatfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])-0.27386127875258304*JfR[46]+0.27386127875258304*JfR[45]+0.15811388300841892*JfR[44]+0.27386127875258304*JfR[43]+0.273861278752583*JfR[42]+0.15811388300841892*JfR[41]-0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]-0.273861278752583*JfR[38]-0.15811388300841892*(JfR[37]+JfR[36])-0.27386127875258304*JfR[35]-0.15811388300841894*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*(JfR[31]+JfR[30])-0.41079191812887433*JfR[29]-0.2371708245126284*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*(JfR[26]+JfR[25])-0.2371708245126284*JfR[24]+0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]+0.3061862178478971*JfR[21]+0.1767766952966368*JfR[20]-0.41079191812887433*JfR[19]+0.41079191812887433*JfR[18]+0.2371708245126284*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.3061862178478971*JfR[14]+0.1767766952966368*JfR[13]-0.1767766952966368*JfR[12]+0.41079191812887433*JfR[11]+0.2371708245126284*JfR[10]-0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]-0.3061862178478971*JfR[7]-0.1767766952966368*(JfR[6]+JfR[5])-0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]-0.1767766952966368*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[12] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsR[23]+speedsR[22])-0.6123724356957944*speedsR[21]-0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]-0.3535533905932737*speedsR[18]+0.3535533905932737*(speedsR[17]+speedsR[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.2795084971874738*JRatfL[23])-0.2795084971874737*JRatfL[22]+0.2795084971874737*(JRatfL[21]+JRatfL[20])+0.2795084971874738*(JRatfL[19]+JRatfL[18])-0.2795084971874738*JRatfL[17]-0.2795084971874737*JRatfL[16]+0.25*(JRatfL[12]+JRatfL[9])-0.25*(JRatfL[8]+JRatfL[5]+JRatfL[4]+JRatfL[2])+0.25*(JRatfL[1]+JRatfL[0]); + JfR_quad = 0.34232659844072866*JfR[47]+0.3423265984407287*JfR[46]-0.3423265984407287*JfR[45]-0.19764235376052366*JfR[44]-0.3423265984407287*JfR[43]-0.34232659844072866*JfR[42]-0.19764235376052364*JfR[41]+0.19764235376052364*JfR[40]-0.34232659844072866*JfR[39]+0.34232659844072866*JfR[38]+0.19764235376052364*JfR[37]+0.19764235376052366*JfR[36]+0.3423265984407287*JfR[35]+0.19764235376052366*JfR[34]-0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*(JfR[27]+JfR[22])+0.3061862178478971*JfR[21]+0.1767766952966368*JfR[20]+0.3061862178478971*(JfR[16]+JfR[14])+0.1767766952966368*JfR[13]-0.1767766952966368*JfR[12]+0.3061862178478971*JfR[8]-0.3061862178478971*JfR[7]-0.1767766952966368*(JfR[6]+JfR[5])-0.3061862178478971*JfR[3]-0.1767766952966368*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[13] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsR[23]+speedsR[22])-0.6123724356957944*speedsR[21]-0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]-0.3535533905932737*speedsR[18]+0.3535533905932737*(speedsR[17]+speedsR[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.22360679774997894*JRatfL[23]+0.22360679774997896*JRatfL[22]-0.22360679774997896*(JRatfL[21]+JRatfL[20])-0.22360679774997894*JRatfL[19]-0.22360679774997902*JRatfL[18]+0.22360679774997902*JRatfL[17]+0.22360679774997896*JRatfL[16]+0.33541019662496846*(JRatfL[15]+JRatfL[14])-0.33541019662496846*JRatfL[13]+0.25*JRatfL[12]-0.33541019662496846*(JRatfL[11]+JRatfL[10])+0.25*JRatfL[9]-0.25*JRatfL[8]-0.33541019662496846*JRatfL[7]+0.33541019662496846*JRatfL[6]-0.25*(JRatfL[5]+JRatfL[4])+0.33541019662496846*JRatfL[3]-0.25*JRatfL[2]+0.25*(JRatfL[1]+JRatfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])-0.27386127875258304*JfR[46]+0.27386127875258304*JfR[45]+0.15811388300841892*JfR[44]+0.27386127875258304*JfR[43]+0.273861278752583*JfR[42]+0.15811388300841892*JfR[41]-0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]-0.273861278752583*JfR[38]-0.15811388300841892*(JfR[37]+JfR[36])-0.27386127875258304*JfR[35]-0.15811388300841894*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*(JfR[31]+JfR[30])+0.41079191812887433*JfR[29]+0.2371708245126284*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*(JfR[26]+JfR[25])+0.2371708245126284*JfR[24]-0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]+0.3061862178478971*JfR[21]+0.1767766952966368*JfR[20]+0.41079191812887433*JfR[19]-0.41079191812887433*JfR[18]-0.2371708245126284*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.3061862178478971*JfR[14]+0.1767766952966368*JfR[13]-0.1767766952966368*JfR[12]-0.41079191812887433*JfR[11]-0.2371708245126284*JfR[10]+0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]-0.3061862178478971*JfR[7]-0.1767766952966368*(JfR[6]+JfR[5])+0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]-0.1767766952966368*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[14] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsR[23]+speedsR[22])-0.6123724356957944*speedsR[21]-0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]-0.3535533905932737*speedsR[18]+0.3535533905932737*(speedsR[17]+speedsR[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.22360679774997894*JRatfL[23])-0.22360679774997896*JRatfL[22]+0.22360679774997896*JRatfL[21]-0.22360679774997896*JRatfL[20]+0.22360679774997894*JRatfL[19]-0.22360679774997902*JRatfL[18]+0.22360679774997902*JRatfL[17]+0.22360679774997896*JRatfL[16]+0.33541019662496846*(JRatfL[15]+JRatfL[14])-0.33541019662496846*JRatfL[13]-0.25*JRatfL[12]+0.33541019662496846*JRatfL[11]-0.33541019662496846*JRatfL[10]-0.25*JRatfL[9]+0.25*JRatfL[8]+0.33541019662496846*JRatfL[7]-0.33541019662496846*JRatfL[6]-0.25*JRatfL[5]+0.25*JRatfL[4]-0.33541019662496846*JRatfL[3]-0.25*JRatfL[2]+0.25*(JRatfL[1]+JRatfL[0]); + JfR_quad = 0.273861278752583*JfR[47]+0.27386127875258304*JfR[46]-0.27386127875258304*JfR[45]-0.15811388300841892*JfR[44]+0.27386127875258304*JfR[43]-0.273861278752583*JfR[42]-0.15811388300841892*JfR[41]+0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]-0.273861278752583*JfR[38]-0.15811388300841892*JfR[37]+0.15811388300841892*JfR[36]-0.27386127875258304*JfR[35]-0.15811388300841894*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*(JfR[31]+JfR[30])+0.41079191812887433*JfR[29]+0.2371708245126284*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.41079191812887433*JfR[25]+0.2371708245126284*JfR[24]-0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]-0.3061862178478971*JfR[21]-0.1767766952966368*JfR[20]-0.41079191812887433*JfR[19]+0.41079191812887433*JfR[18]+0.2371708245126284*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.3061862178478971*JfR[14]-0.1767766952966368*JfR[13]+0.1767766952966368*JfR[12]+0.41079191812887433*JfR[11]+0.2371708245126284*JfR[10]-0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]-0.3061862178478971*JfR[7]-0.1767766952966368*JfR[6]+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]-0.1767766952966368*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[15] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsR[23]+speedsR[22])-0.6123724356957944*speedsR[21]-0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]-0.3535533905932737*speedsR[18]+0.3535533905932737*(speedsR[17]+speedsR[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.2795084971874738*JRatfL[23]+0.2795084971874737*JRatfL[22]-0.2795084971874737*JRatfL[21]+0.2795084971874737*JRatfL[20]-0.2795084971874738*JRatfL[19]+0.2795084971874738*JRatfL[18]-0.2795084971874738*JRatfL[17]-0.2795084971874737*JRatfL[16]-0.25*(JRatfL[12]+JRatfL[9])+0.25*JRatfL[8]-0.25*JRatfL[5]+0.25*JRatfL[4]-0.25*JRatfL[2]+0.25*(JRatfL[1]+JRatfL[0]); + JfR_quad = -(0.34232659844072866*JfR[47])-0.3423265984407287*JfR[46]+0.3423265984407287*JfR[45]+0.19764235376052366*JfR[44]-0.3423265984407287*JfR[43]+0.34232659844072866*JfR[42]+0.19764235376052364*JfR[41]-0.19764235376052364*JfR[40]-0.34232659844072866*JfR[39]+0.34232659844072866*JfR[38]+0.19764235376052364*JfR[37]-0.19764235376052366*JfR[36]+0.3423265984407287*JfR[35]+0.19764235376052366*JfR[34]-0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*(JfR[27]+JfR[22])-0.3061862178478971*JfR[21]-0.1767766952966368*JfR[20]+0.3061862178478971*JfR[16]-0.3061862178478971*JfR[14]-0.1767766952966368*JfR[13]+0.1767766952966368*JfR[12]+0.3061862178478971*JfR[8]-0.3061862178478971*JfR[7]-0.1767766952966368*JfR[6]+0.1767766952966368*JfR[5]-0.3061862178478971*JfR[3]-0.1767766952966368*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[16] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsR[23]+speedsR[22])-0.6123724356957944*speedsR[21]-0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]-0.3535533905932737*speedsR[18]+0.3535533905932737*(speedsR[17]+speedsR[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.22360679774997894*JRatfL[23])-0.22360679774997896*JRatfL[22]+0.22360679774997896*JRatfL[21]-0.22360679774997896*JRatfL[20]+0.22360679774997894*JRatfL[19]-0.22360679774997902*JRatfL[18]+0.22360679774997902*JRatfL[17]+0.22360679774997896*JRatfL[16]-0.33541019662496846*(JRatfL[15]+JRatfL[14])+0.33541019662496846*JRatfL[13]-0.25*JRatfL[12]-0.33541019662496846*JRatfL[11]+0.33541019662496846*JRatfL[10]-0.25*JRatfL[9]+0.25*JRatfL[8]-0.33541019662496846*JRatfL[7]+0.33541019662496846*JRatfL[6]-0.25*JRatfL[5]+0.25*JRatfL[4]+0.33541019662496846*JRatfL[3]-0.25*JRatfL[2]+0.25*(JRatfL[1]+JRatfL[0]); + JfR_quad = 0.273861278752583*JfR[47]+0.27386127875258304*JfR[46]-0.27386127875258304*JfR[45]-0.15811388300841892*JfR[44]+0.27386127875258304*JfR[43]-0.273861278752583*JfR[42]-0.15811388300841892*JfR[41]+0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]-0.273861278752583*JfR[38]-0.15811388300841892*JfR[37]+0.15811388300841892*JfR[36]-0.27386127875258304*JfR[35]-0.15811388300841894*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*(JfR[31]+JfR[30])-0.41079191812887433*JfR[29]-0.2371708245126284*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.41079191812887433*JfR[25]-0.2371708245126284*JfR[24]+0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]-0.3061862178478971*JfR[21]-0.1767766952966368*JfR[20]+0.41079191812887433*JfR[19]-0.41079191812887433*JfR[18]-0.2371708245126284*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.3061862178478971*JfR[14]-0.1767766952966368*JfR[13]+0.1767766952966368*JfR[12]-0.41079191812887433*JfR[11]-0.2371708245126284*JfR[10]+0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]-0.3061862178478971*JfR[7]-0.1767766952966368*JfR[6]+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]-0.1767766952966368*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[17] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[3].bmag; + Jc_quad = gkdgs[3].Jc; + B3_quad = gkdgs[3].B3; + normcurlbhat_quad = gkdgs[3].normcurlbhat; + bhat_quad[0] = gkdgs[3].bhat.x[0]; + bhat_quad[1] = gkdgs[3].bhat.x[1]; + bhat_quad[2] = gkdgs[3].bhat.x[2]; + area_elem_quad = dgs[3].area_elem; + + + alpha_quad = -(0.6123724356957944*(speedsR[23]+speedsR[22]+speedsR[21]))+0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]+0.3535533905932737*(speedsR[18]+speedsR[17]+speedsR[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.22360679774997894*JRatfL[23])-0.22360679774997896*(JRatfL[22]+JRatfL[21])+0.22360679774997896*JRatfL[20]-0.22360679774997894*JRatfL[19]+0.22360679774997902*(JRatfL[18]+JRatfL[17])+0.22360679774997896*JRatfL[16]+0.33541019662496846*(JRatfL[15]+JRatfL[14]+JRatfL[13])-0.25*JRatfL[12]-0.33541019662496846*JRatfL[11]+0.33541019662496846*JRatfL[10]-0.25*(JRatfL[9]+JRatfL[8])-0.33541019662496846*(JRatfL[7]+JRatfL[6])+0.25*JRatfL[5]-0.25*JRatfL[4]-0.33541019662496846*JRatfL[3]+0.25*(JRatfL[2]+JRatfL[1]+JRatfL[0]); + JfR_quad = 0.273861278752583*JfR[47]+0.27386127875258304*(JfR[46]+JfR[45])-0.15811388300841892*JfR[44]-0.27386127875258304*JfR[43]+0.273861278752583*JfR[42]-0.15811388300841892*(JfR[41]+JfR[40])-0.273861278752583*(JfR[39]+JfR[38])+0.15811388300841892*JfR[37]-0.15811388300841892*JfR[36]-0.27386127875258304*JfR[35]+0.15811388300841894*(JfR[34]+JfR[33])+0.15811388300841892*JfR[32]-0.41079191812887433*(JfR[31]+JfR[30]+JfR[29])+0.2371708245126284*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.41079191812887433*JfR[25]+0.2371708245126284*(JfR[24]+JfR[23])+0.3061862178478971*(JfR[22]+JfR[21])-0.1767766952966368*JfR[20]+0.41079191812887433*(JfR[19]+JfR[18])-0.2371708245126284*JfR[17]-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.3061862178478971*JfR[14]-0.1767766952966368*(JfR[13]+JfR[12])+0.41079191812887433*JfR[11]-0.2371708245126284*(JfR[10]+JfR[9])-0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*JfR[6]-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]+0.1767766952966368*(JfR[2]+JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[18] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsR[23]+speedsR[22]+speedsR[21]))+0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]+0.3535533905932737*(speedsR[18]+speedsR[17]+speedsR[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.2795084971874738*JRatfL[23]+0.2795084971874737*(JRatfL[22]+JRatfL[21])-0.2795084971874737*JRatfL[20]+0.2795084971874738*JRatfL[19]-0.2795084971874738*(JRatfL[18]+JRatfL[17])-0.2795084971874737*JRatfL[16]-0.25*(JRatfL[12]+JRatfL[9]+JRatfL[8])+0.25*JRatfL[5]-0.25*JRatfL[4]+0.25*(JRatfL[2]+JRatfL[1]+JRatfL[0]); + JfR_quad = -(0.34232659844072866*JfR[47])-0.3423265984407287*(JfR[46]+JfR[45])+0.19764235376052366*JfR[44]+0.3423265984407287*JfR[43]-0.34232659844072866*JfR[42]+0.19764235376052364*(JfR[41]+JfR[40])+0.34232659844072866*(JfR[39]+JfR[38])-0.19764235376052364*JfR[37]+0.19764235376052366*JfR[36]+0.3423265984407287*JfR[35]-0.19764235376052366*(JfR[34]+JfR[33])-0.19764235376052364*JfR[32]+0.3061862178478971*(JfR[27]+JfR[22]+JfR[21])-0.1767766952966368*JfR[20]-0.3061862178478971*JfR[16]+0.3061862178478971*JfR[14]-0.1767766952966368*(JfR[13]+JfR[12])-0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*JfR[6]-0.1767766952966368*JfR[5]-0.3061862178478971*JfR[3]+0.1767766952966368*(JfR[2]+JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[19] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsR[23]+speedsR[22]+speedsR[21]))+0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]+0.3535533905932737*(speedsR[18]+speedsR[17]+speedsR[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.22360679774997894*JRatfL[23])-0.22360679774997896*(JRatfL[22]+JRatfL[21])+0.22360679774997896*JRatfL[20]-0.22360679774997894*JRatfL[19]+0.22360679774997902*(JRatfL[18]+JRatfL[17])+0.22360679774997896*JRatfL[16]-0.33541019662496846*(JRatfL[15]+JRatfL[14]+JRatfL[13])-0.25*JRatfL[12]+0.33541019662496846*JRatfL[11]-0.33541019662496846*JRatfL[10]-0.25*(JRatfL[9]+JRatfL[8])+0.33541019662496846*(JRatfL[7]+JRatfL[6])+0.25*JRatfL[5]-0.25*JRatfL[4]+0.33541019662496846*JRatfL[3]+0.25*(JRatfL[2]+JRatfL[1]+JRatfL[0]); + JfR_quad = 0.273861278752583*JfR[47]+0.27386127875258304*(JfR[46]+JfR[45])-0.15811388300841892*JfR[44]-0.27386127875258304*JfR[43]+0.273861278752583*JfR[42]-0.15811388300841892*(JfR[41]+JfR[40])-0.273861278752583*(JfR[39]+JfR[38])+0.15811388300841892*JfR[37]-0.15811388300841892*JfR[36]-0.27386127875258304*JfR[35]+0.15811388300841894*(JfR[34]+JfR[33])+0.15811388300841892*JfR[32]+0.41079191812887433*(JfR[31]+JfR[30]+JfR[29])-0.2371708245126284*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.41079191812887433*JfR[25]-0.2371708245126284*(JfR[24]+JfR[23])+0.3061862178478971*(JfR[22]+JfR[21])-0.1767766952966368*JfR[20]-0.41079191812887433*(JfR[19]+JfR[18])+0.2371708245126284*JfR[17]-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.3061862178478971*JfR[14]-0.1767766952966368*(JfR[13]+JfR[12])-0.41079191812887433*JfR[11]+0.2371708245126284*(JfR[10]+JfR[9])-0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*JfR[6]-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]+0.1767766952966368*(JfR[2]+JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[20] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsR[23]+speedsR[22]+speedsR[21]))+0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]+0.3535533905932737*(speedsR[18]+speedsR[17]+speedsR[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.22360679774997894*JRatfL[23]+0.22360679774997896*(JRatfL[22]+JRatfL[21]+JRatfL[20])+0.22360679774997894*JRatfL[19]+0.22360679774997902*(JRatfL[18]+JRatfL[17])+0.22360679774997896*JRatfL[16]-0.33541019662496846*(JRatfL[15]+JRatfL[14]+JRatfL[13])+0.25*JRatfL[12]-0.33541019662496846*(JRatfL[11]+JRatfL[10])+0.25*(JRatfL[9]+JRatfL[8])-0.33541019662496846*(JRatfL[7]+JRatfL[6])+0.25*(JRatfL[5]+JRatfL[4])-0.33541019662496846*JRatfL[3]+0.25*(JRatfL[2]+JRatfL[1]+JRatfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])-0.27386127875258304*(JfR[46]+JfR[45])+0.15811388300841892*JfR[44]-0.27386127875258304*JfR[43]-0.273861278752583*JfR[42]+0.15811388300841892*(JfR[41]+JfR[40])-0.273861278752583*(JfR[39]+JfR[38])+0.15811388300841892*(JfR[37]+JfR[36])-0.27386127875258304*JfR[35]+0.15811388300841894*(JfR[34]+JfR[33])+0.15811388300841892*JfR[32]+0.41079191812887433*(JfR[31]+JfR[30]+JfR[29])-0.2371708245126284*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*(JfR[26]+JfR[25])-0.2371708245126284*(JfR[24]+JfR[23])-0.3061862178478971*(JfR[22]+JfR[21])+0.1767766952966368*JfR[20]+0.41079191812887433*(JfR[19]+JfR[18])-0.2371708245126284*JfR[17]-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.3061862178478971*JfR[14]+0.1767766952966368*(JfR[13]+JfR[12])+0.41079191812887433*JfR[11]-0.2371708245126284*(JfR[10]+JfR[9])-0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*(JfR[6]+JfR[5])-0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]+0.1767766952966368*(JfR[2]+JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[21] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsR[23]+speedsR[22]+speedsR[21]))+0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]+0.3535533905932737*(speedsR[18]+speedsR[17]+speedsR[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.2795084971874738*JRatfL[23])-0.2795084971874737*(JRatfL[22]+JRatfL[21]+JRatfL[20])-0.2795084971874738*(JRatfL[19]+JRatfL[18]+JRatfL[17])-0.2795084971874737*JRatfL[16]+0.25*(JRatfL[12]+JRatfL[9]+JRatfL[8]+JRatfL[5]+JRatfL[4]+JRatfL[2]+JRatfL[1]+JRatfL[0]); + JfR_quad = 0.34232659844072866*JfR[47]+0.3423265984407287*(JfR[46]+JfR[45])-0.19764235376052366*JfR[44]+0.3423265984407287*JfR[43]+0.34232659844072866*JfR[42]-0.19764235376052364*(JfR[41]+JfR[40])+0.34232659844072866*(JfR[39]+JfR[38])-0.19764235376052364*JfR[37]-0.19764235376052366*JfR[36]+0.3423265984407287*JfR[35]-0.19764235376052366*(JfR[34]+JfR[33])-0.19764235376052364*JfR[32]-0.3061862178478971*(JfR[27]+JfR[22]+JfR[21])+0.1767766952966368*JfR[20]-0.3061862178478971*(JfR[16]+JfR[14])+0.1767766952966368*(JfR[13]+JfR[12])-0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*(JfR[6]+JfR[5])-0.3061862178478971*JfR[3]+0.1767766952966368*(JfR[2]+JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[22] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsR[23]+speedsR[22]+speedsR[21]))+0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]+0.3535533905932737*(speedsR[18]+speedsR[17]+speedsR[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.22360679774997894*JRatfL[23]+0.22360679774997896*(JRatfL[22]+JRatfL[21]+JRatfL[20])+0.22360679774997894*JRatfL[19]+0.22360679774997902*(JRatfL[18]+JRatfL[17])+0.22360679774997896*JRatfL[16]+0.33541019662496846*(JRatfL[15]+JRatfL[14]+JRatfL[13])+0.25*JRatfL[12]+0.33541019662496846*(JRatfL[11]+JRatfL[10])+0.25*(JRatfL[9]+JRatfL[8])+0.33541019662496846*(JRatfL[7]+JRatfL[6])+0.25*(JRatfL[5]+JRatfL[4])+0.33541019662496846*JRatfL[3]+0.25*(JRatfL[2]+JRatfL[1]+JRatfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])-0.27386127875258304*(JfR[46]+JfR[45])+0.15811388300841892*JfR[44]-0.27386127875258304*JfR[43]-0.273861278752583*JfR[42]+0.15811388300841892*(JfR[41]+JfR[40])-0.273861278752583*(JfR[39]+JfR[38])+0.15811388300841892*(JfR[37]+JfR[36])-0.27386127875258304*JfR[35]+0.15811388300841894*(JfR[34]+JfR[33])+0.15811388300841892*JfR[32]-0.41079191812887433*(JfR[31]+JfR[30]+JfR[29])+0.2371708245126284*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*(JfR[26]+JfR[25])+0.2371708245126284*(JfR[24]+JfR[23])-0.3061862178478971*(JfR[22]+JfR[21])+0.1767766952966368*JfR[20]-0.41079191812887433*(JfR[19]+JfR[18])+0.2371708245126284*JfR[17]-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.3061862178478971*JfR[14]+0.1767766952966368*(JfR[13]+JfR[12])-0.41079191812887433*JfR[11]+0.2371708245126284*(JfR[10]+JfR[9])-0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*(JfR[6]+JfR[5])+0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]+0.1767766952966368*(JfR[2]+JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[23] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdz2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfx_1x1v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfx_1x1v_ser_p1.c new file mode 100644 index 0000000000..fe2f216031 --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfx_1x1v_ser_p1.c @@ -0,0 +1,82 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_surfx_1x1v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdvpar2 = 2.0/dxv[1]; + + double *flux_surf_nodal = &flux_surf[0]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.7745966692414834*JfL[5]+0.4472135954999579*JfL[4]-1.1618950038622249*JfL[3]-0.6708203932499369*JfL[2]+0.8660254037844386*JfL[1]+0.5*JfL[0]; + JfR_quad = -(0.7745966692414834*JfR[5])+0.4472135954999579*JfR[4]+1.1618950038622249*JfR[3]-0.6708203932499369*JfR[2]-0.8660254037844386*JfR[1]+0.5*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.9682458365518543*JfL[5])-0.5590169943749475*JfL[4]+0.8660254037844386*JfL[1]+0.5*JfL[0]; + JfR_quad = 0.9682458365518543*JfR[5]-0.5590169943749475*JfR[4]-0.8660254037844386*JfR[1]+0.5*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.7745966692414834*JfL[5]+0.4472135954999579*JfL[4]+1.1618950038622249*JfL[3]+0.6708203932499369*JfL[2]+0.8660254037844386*JfL[1]+0.5*JfL[0]; + JfR_quad = -(0.7745966692414834*JfR[5])+0.4472135954999579*JfR[4]-1.1618950038622249*JfR[3]+0.6708203932499369*JfR[2]-0.8660254037844386*JfR[1]+0.5*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdx2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfx_1x2v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfx_1x2v_ser_p1.c new file mode 100644 index 0000000000..0e7819a72e --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfx_1x2v_ser_p1.c @@ -0,0 +1,109 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_surfx_1x2v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdvpar2 = 2.0/dxv[1]; + + double *flux_surf_nodal = &flux_surf[0]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.5477225575051661*JfL[11])-0.3162277660168379*JfL[10]+0.5477225575051661*JfL[9]+0.3162277660168379*JfL[8]+0.8215838362577489*JfL[7]+0.4743416490252568*JfL[6]-0.6123724356957944*JfL[5]-0.8215838362577489*JfL[4]-0.3535533905932737*JfL[3]-0.4743416490252568*JfL[2]+0.6123724356957944*JfL[1]+0.3535533905932737*JfL[0]; + JfR_quad = 0.5477225575051661*JfR[11]-0.3162277660168379*JfR[10]-0.5477225575051661*JfR[9]+0.3162277660168379*JfR[8]-0.8215838362577489*JfR[7]+0.4743416490252568*JfR[6]+0.6123724356957944*JfR[5]+0.8215838362577489*JfR[4]-0.3535533905932737*JfR[3]-0.4743416490252568*JfR[2]-0.6123724356957944*JfR[1]+0.3535533905932737*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.6846531968814573*JfL[11]+0.39528470752104733*JfL[10]-0.6846531968814574*JfL[9]-0.3952847075210473*JfL[8]-0.6123724356957944*JfL[5]-0.3535533905932737*JfL[3]+0.6123724356957944*JfL[1]+0.3535533905932737*JfL[0]; + JfR_quad = -(0.6846531968814573*JfR[11])+0.39528470752104733*JfR[10]+0.6846531968814574*JfR[9]-0.3952847075210473*JfR[8]+0.6123724356957944*JfR[5]-0.3535533905932737*JfR[3]-0.6123724356957944*JfR[1]+0.3535533905932737*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.5477225575051661*JfL[11])-0.3162277660168379*JfL[10]+0.5477225575051661*JfL[9]+0.3162277660168379*JfL[8]-0.8215838362577489*JfL[7]-0.4743416490252568*JfL[6]-0.6123724356957944*JfL[5]+0.8215838362577489*JfL[4]-0.3535533905932737*JfL[3]+0.4743416490252568*JfL[2]+0.6123724356957944*JfL[1]+0.3535533905932737*JfL[0]; + JfR_quad = 0.5477225575051661*JfR[11]-0.3162277660168379*JfR[10]-0.5477225575051661*JfR[9]+0.3162277660168379*JfR[8]+0.8215838362577489*JfR[7]-0.4743416490252568*JfR[6]+0.6123724356957944*JfR[5]-0.8215838362577489*JfR[4]-0.3535533905932737*JfR[3]+0.4743416490252568*JfR[2]-0.6123724356957944*JfR[1]+0.3535533905932737*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.5477225575051661*JfL[11]+0.3162277660168379*JfL[10]+0.5477225575051661*JfL[9]+0.3162277660168379*JfL[8]-0.8215838362577489*JfL[7]-0.4743416490252568*JfL[6]+0.6123724356957944*JfL[5]-0.8215838362577489*JfL[4]+0.3535533905932737*JfL[3]-0.4743416490252568*JfL[2]+0.6123724356957944*JfL[1]+0.3535533905932737*JfL[0]; + JfR_quad = -(0.5477225575051661*JfR[11])+0.3162277660168379*JfR[10]-0.5477225575051661*JfR[9]+0.3162277660168379*JfR[8]+0.8215838362577489*JfR[7]-0.4743416490252568*JfR[6]-0.6123724356957944*JfR[5]+0.8215838362577489*JfR[4]+0.3535533905932737*JfR[3]-0.4743416490252568*JfR[2]-0.6123724356957944*JfR[1]+0.3535533905932737*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[3] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.6846531968814573*JfL[11])-0.39528470752104733*JfL[10]-0.6846531968814574*JfL[9]-0.3952847075210473*JfL[8]+0.6123724356957944*JfL[5]+0.3535533905932737*JfL[3]+0.6123724356957944*JfL[1]+0.3535533905932737*JfL[0]; + JfR_quad = 0.6846531968814573*JfR[11]-0.39528470752104733*JfR[10]+0.6846531968814574*JfR[9]-0.3952847075210473*JfR[8]-0.6123724356957944*JfR[5]+0.3535533905932737*JfR[3]-0.6123724356957944*JfR[1]+0.3535533905932737*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[4] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.0; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.5477225575051661*JfL[11]+0.3162277660168379*JfL[10]+0.5477225575051661*JfL[9]+0.3162277660168379*JfL[8]+0.8215838362577489*JfL[7]+0.4743416490252568*JfL[6]+0.6123724356957944*JfL[5]+0.8215838362577489*JfL[4]+0.3535533905932737*JfL[3]+0.4743416490252568*JfL[2]+0.6123724356957944*JfL[1]+0.3535533905932737*JfL[0]; + JfR_quad = -(0.5477225575051661*JfR[11])+0.3162277660168379*JfR[10]-0.5477225575051661*JfR[9]+0.3162277660168379*JfR[8]-0.8215838362577489*JfR[7]+0.4743416490252568*JfR[6]-0.6123724356957944*JfR[5]-0.8215838362577489*JfR[4]+0.3535533905932737*JfR[3]+0.4743416490252568*JfR[2]-0.6123724356957944*JfR[1]+0.3535533905932737*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[5] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdx2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfx_2x2v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfx_2x2v_ser_p1.c new file mode 100644 index 0000000000..47f94b9613 --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfx_2x2v_ser_p1.c @@ -0,0 +1,174 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_surfx_2x2v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdz2 = 2.0/dxv[1]; + double rdvpar2 = 2.0/dxv[2]; + + double *flux_surf_nodal = &flux_surf[0]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = 0.8660254037844386*speedsR[3]-0.5*speedsR[2]-0.8660254037844386*speedsR[1]+0.5*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3872983346207417*JfL[23]+0.22360679774997896*JfL[22]-0.38729833462074165*(JfL[21]+JfL[20])-0.22360679774997894*JfL[19]-0.22360679774997902*JfL[18]+0.3872983346207417*JfL[17]+0.22360679774997896*JfL[16]-0.5809475019311124*JfL[15]-0.33541019662496846*JfL[14]+0.5809475019311124*JfL[13]+0.4330127018922193*JfL[12]+0.5809475019311124*JfL[11]+0.33541019662496846*JfL[10]+0.25*JfL[9]-0.4330127018922193*JfL[8]+0.33541019662496846*JfL[7]-0.5809475019311124*JfL[6]-0.4330127018922193*JfL[5]-0.25*JfL[4]-0.33541019662496846*JfL[3]-0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.3872983346207417*JfR[23])+0.22360679774997896*JfR[22]+0.38729833462074165*(JfR[21]+JfR[20])-0.22360679774997894*JfR[19]-0.22360679774997902*JfR[18]-0.3872983346207417*JfR[17]+0.22360679774997896*JfR[16]+0.5809475019311124*JfR[15]-0.33541019662496846*JfR[14]-0.5809475019311124*JfR[13]-0.4330127018922193*JfR[12]-0.5809475019311124*JfR[11]+0.33541019662496846*JfR[10]+0.25*JfR[9]+0.4330127018922193*JfR[8]+0.33541019662496846*JfR[7]+0.5809475019311124*JfR[6]+0.4330127018922193*JfR[5]-0.25*JfR[4]-0.33541019662496846*JfR[3]-0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsR[3]-0.5*speedsR[2]-0.8660254037844386*speedsR[1]+0.5*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.4841229182759271*JfL[23])-0.2795084971874737*JfL[22]+0.4841229182759271*(JfL[21]+JfL[20])+0.2795084971874738*(JfL[19]+JfL[18])-0.4841229182759271*JfL[17]-0.2795084971874737*JfL[16]+0.4330127018922193*JfL[12]+0.25*JfL[9]-0.4330127018922193*(JfL[8]+JfL[5])-0.25*(JfL[4]+JfL[2])+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.4841229182759271*JfR[23]-0.2795084971874737*JfR[22]-0.4841229182759271*(JfR[21]+JfR[20])+0.2795084971874738*(JfR[19]+JfR[18])+0.4841229182759271*JfR[17]-0.2795084971874737*JfR[16]-0.4330127018922193*JfR[12]+0.25*JfR[9]+0.4330127018922193*(JfR[8]+JfR[5])-0.25*(JfR[4]+JfR[2])-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsR[3]-0.5*speedsR[2]-0.8660254037844386*speedsR[1]+0.5*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3872983346207417*JfL[23]+0.22360679774997896*JfL[22]-0.38729833462074165*(JfL[21]+JfL[20])-0.22360679774997894*JfL[19]-0.22360679774997902*JfL[18]+0.3872983346207417*JfL[17]+0.22360679774997896*JfL[16]+0.5809475019311124*JfL[15]+0.33541019662496846*JfL[14]-0.5809475019311124*JfL[13]+0.4330127018922193*JfL[12]-0.5809475019311124*JfL[11]-0.33541019662496846*JfL[10]+0.25*JfL[9]-0.4330127018922193*JfL[8]-0.33541019662496846*JfL[7]+0.5809475019311124*JfL[6]-0.4330127018922193*JfL[5]-0.25*JfL[4]+0.33541019662496846*JfL[3]-0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.3872983346207417*JfR[23])+0.22360679774997896*JfR[22]+0.38729833462074165*(JfR[21]+JfR[20])-0.22360679774997894*JfR[19]-0.22360679774997902*JfR[18]-0.3872983346207417*JfR[17]+0.22360679774997896*JfR[16]-0.5809475019311124*JfR[15]+0.33541019662496846*JfR[14]+0.5809475019311124*JfR[13]-0.4330127018922193*JfR[12]+0.5809475019311124*JfR[11]-0.33541019662496846*JfR[10]+0.25*JfR[9]+0.4330127018922193*JfR[8]-0.33541019662496846*JfR[7]-0.5809475019311124*JfR[6]+0.4330127018922193*JfR[5]-0.25*JfR[4]+0.33541019662496846*JfR[3]-0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsR[3]-0.5*speedsR[2]-0.8660254037844386*speedsR[1]+0.5*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3872983346207417*JfL[23])-0.22360679774997896*JfL[22]+0.38729833462074165*JfL[21]-0.38729833462074165*JfL[20]+0.22360679774997894*JfL[19]-0.22360679774997902*JfL[18]+0.3872983346207417*JfL[17]+0.22360679774997896*JfL[16]+0.5809475019311124*JfL[15]+0.33541019662496846*JfL[14]-0.5809475019311124*JfL[13]-0.4330127018922193*JfL[12]+0.5809475019311124*JfL[11]-0.33541019662496846*JfL[10]-0.25*JfL[9]+0.4330127018922193*JfL[8]+0.33541019662496846*JfL[7]-0.5809475019311124*JfL[6]-0.4330127018922193*JfL[5]+0.25*JfL[4]-0.33541019662496846*JfL[3]-0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.3872983346207417*JfR[23]-0.22360679774997896*JfR[22]-0.38729833462074165*JfR[21]+0.38729833462074165*JfR[20]+0.22360679774997894*JfR[19]-0.22360679774997902*JfR[18]-0.3872983346207417*JfR[17]+0.22360679774997896*JfR[16]-0.5809475019311124*JfR[15]+0.33541019662496846*JfR[14]+0.5809475019311124*JfR[13]+0.4330127018922193*JfR[12]-0.5809475019311124*JfR[11]-0.33541019662496846*JfR[10]-0.25*JfR[9]-0.4330127018922193*JfR[8]+0.33541019662496846*JfR[7]+0.5809475019311124*JfR[6]+0.4330127018922193*JfR[5]+0.25*JfR[4]-0.33541019662496846*JfR[3]-0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[3] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsR[3]-0.5*speedsR[2]-0.8660254037844386*speedsR[1]+0.5*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.4841229182759271*JfL[23]+0.2795084971874737*JfL[22]-0.4841229182759271*JfL[21]+0.4841229182759271*JfL[20]-0.2795084971874738*JfL[19]+0.2795084971874738*JfL[18]-0.4841229182759271*JfL[17]-0.2795084971874737*JfL[16]-0.4330127018922193*JfL[12]-0.25*JfL[9]+0.4330127018922193*JfL[8]-0.4330127018922193*JfL[5]+0.25*JfL[4]-0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.4841229182759271*JfR[23])+0.2795084971874737*JfR[22]+0.4841229182759271*JfR[21]-0.4841229182759271*JfR[20]-0.2795084971874738*JfR[19]+0.2795084971874738*JfR[18]+0.4841229182759271*JfR[17]-0.2795084971874737*JfR[16]+0.4330127018922193*JfR[12]-0.25*JfR[9]-0.4330127018922193*JfR[8]+0.4330127018922193*JfR[5]+0.25*JfR[4]-0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[4] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsR[3]-0.5*speedsR[2]-0.8660254037844386*speedsR[1]+0.5*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3872983346207417*JfL[23])-0.22360679774997896*JfL[22]+0.38729833462074165*JfL[21]-0.38729833462074165*JfL[20]+0.22360679774997894*JfL[19]-0.22360679774997902*JfL[18]+0.3872983346207417*JfL[17]+0.22360679774997896*JfL[16]-0.5809475019311124*JfL[15]-0.33541019662496846*JfL[14]+0.5809475019311124*JfL[13]-0.4330127018922193*JfL[12]-0.5809475019311124*JfL[11]+0.33541019662496846*JfL[10]-0.25*JfL[9]+0.4330127018922193*JfL[8]-0.33541019662496846*JfL[7]+0.5809475019311124*JfL[6]-0.4330127018922193*JfL[5]+0.25*JfL[4]+0.33541019662496846*JfL[3]-0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.3872983346207417*JfR[23]-0.22360679774997896*JfR[22]-0.38729833462074165*JfR[21]+0.38729833462074165*JfR[20]+0.22360679774997894*JfR[19]-0.22360679774997902*JfR[18]-0.3872983346207417*JfR[17]+0.22360679774997896*JfR[16]+0.5809475019311124*JfR[15]-0.33541019662496846*JfR[14]-0.5809475019311124*JfR[13]+0.4330127018922193*JfR[12]+0.5809475019311124*JfR[11]+0.33541019662496846*JfR[10]-0.25*JfR[9]-0.4330127018922193*JfR[8]-0.33541019662496846*JfR[7]-0.5809475019311124*JfR[6]+0.4330127018922193*JfR[5]+0.25*JfR[4]+0.33541019662496846*JfR[3]-0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[5] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[1].bmag; + Jc_quad = gkdgs[1].Jc; + B3_quad = gkdgs[1].B3; + normcurlbhat_quad = gkdgs[1].normcurlbhat; + bhat_quad[0] = gkdgs[1].bhat.x[0]; + bhat_quad[1] = gkdgs[1].bhat.x[1]; + bhat_quad[2] = gkdgs[1].bhat.x[2]; + area_elem_quad = dgs[1].area_elem; + + + alpha_quad = -(0.8660254037844386*speedsR[3])+0.5*speedsR[2]-0.8660254037844386*speedsR[1]+0.5*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3872983346207417*JfL[23])-0.22360679774997896*JfL[22]-0.38729833462074165*JfL[21]+0.38729833462074165*JfL[20]-0.22360679774997894*JfL[19]+0.22360679774997902*JfL[18]+0.3872983346207417*JfL[17]+0.22360679774997896*JfL[16]+0.5809475019311124*JfL[15]+0.33541019662496846*JfL[14]+0.5809475019311124*JfL[13]-0.4330127018922193*JfL[12]-0.5809475019311124*JfL[11]+0.33541019662496846*JfL[10]-0.25*JfL[9]-0.4330127018922193*JfL[8]-0.33541019662496846*JfL[7]-0.5809475019311124*JfL[6]+0.4330127018922193*JfL[5]-0.25*JfL[4]-0.33541019662496846*JfL[3]+0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.3872983346207417*JfR[23]-0.22360679774997896*JfR[22]+0.38729833462074165*JfR[21]-0.38729833462074165*JfR[20]-0.22360679774997894*JfR[19]+0.22360679774997902*JfR[18]-0.3872983346207417*JfR[17]+0.22360679774997896*JfR[16]-0.5809475019311124*JfR[15]+0.33541019662496846*JfR[14]-0.5809475019311124*JfR[13]+0.4330127018922193*JfR[12]+0.5809475019311124*JfR[11]+0.33541019662496846*JfR[10]-0.25*JfR[9]+0.4330127018922193*JfR[8]-0.33541019662496846*JfR[7]+0.5809475019311124*JfR[6]-0.4330127018922193*JfR[5]-0.25*JfR[4]-0.33541019662496846*JfR[3]+0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[6] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsR[3])+0.5*speedsR[2]-0.8660254037844386*speedsR[1]+0.5*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.4841229182759271*JfL[23]+0.2795084971874737*JfL[22]+0.4841229182759271*JfL[21]-0.4841229182759271*JfL[20]+0.2795084971874738*JfL[19]-0.2795084971874738*JfL[18]-0.4841229182759271*JfL[17]-0.2795084971874737*JfL[16]-0.4330127018922193*JfL[12]-0.25*JfL[9]-0.4330127018922193*JfL[8]+0.4330127018922193*JfL[5]-0.25*JfL[4]+0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.4841229182759271*JfR[23])+0.2795084971874737*JfR[22]-0.4841229182759271*JfR[21]+0.4841229182759271*JfR[20]+0.2795084971874738*JfR[19]-0.2795084971874738*JfR[18]+0.4841229182759271*JfR[17]-0.2795084971874737*JfR[16]+0.4330127018922193*JfR[12]-0.25*JfR[9]+0.4330127018922193*JfR[8]-0.4330127018922193*JfR[5]-0.25*JfR[4]+0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[7] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsR[3])+0.5*speedsR[2]-0.8660254037844386*speedsR[1]+0.5*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3872983346207417*JfL[23])-0.22360679774997896*JfL[22]-0.38729833462074165*JfL[21]+0.38729833462074165*JfL[20]-0.22360679774997894*JfL[19]+0.22360679774997902*JfL[18]+0.3872983346207417*JfL[17]+0.22360679774997896*JfL[16]-0.5809475019311124*JfL[15]-0.33541019662496846*JfL[14]-0.5809475019311124*JfL[13]-0.4330127018922193*JfL[12]+0.5809475019311124*JfL[11]-0.33541019662496846*JfL[10]-0.25*JfL[9]-0.4330127018922193*JfL[8]+0.33541019662496846*JfL[7]+0.5809475019311124*JfL[6]+0.4330127018922193*JfL[5]-0.25*JfL[4]+0.33541019662496846*JfL[3]+0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.3872983346207417*JfR[23]-0.22360679774997896*JfR[22]+0.38729833462074165*JfR[21]-0.38729833462074165*JfR[20]-0.22360679774997894*JfR[19]+0.22360679774997902*JfR[18]-0.3872983346207417*JfR[17]+0.22360679774997896*JfR[16]+0.5809475019311124*JfR[15]-0.33541019662496846*JfR[14]+0.5809475019311124*JfR[13]+0.4330127018922193*JfR[12]-0.5809475019311124*JfR[11]-0.33541019662496846*JfR[10]-0.25*JfR[9]+0.4330127018922193*JfR[8]+0.33541019662496846*JfR[7]-0.5809475019311124*JfR[6]-0.4330127018922193*JfR[5]-0.25*JfR[4]+0.33541019662496846*JfR[3]+0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[8] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsR[3])+0.5*speedsR[2]-0.8660254037844386*speedsR[1]+0.5*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3872983346207417*JfL[23]+0.22360679774997896*JfL[22]+0.38729833462074165*(JfL[21]+JfL[20])+0.22360679774997894*JfL[19]+0.22360679774997902*JfL[18]+0.3872983346207417*JfL[17]+0.22360679774997896*JfL[16]-0.5809475019311124*JfL[15]-0.33541019662496846*JfL[14]-0.5809475019311124*JfL[13]+0.4330127018922193*JfL[12]-0.5809475019311124*JfL[11]-0.33541019662496846*JfL[10]+0.25*JfL[9]+0.4330127018922193*JfL[8]-0.33541019662496846*JfL[7]-0.5809475019311124*JfL[6]+0.4330127018922193*JfL[5]+0.25*JfL[4]-0.33541019662496846*JfL[3]+0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.3872983346207417*JfR[23])+0.22360679774997896*JfR[22]-0.38729833462074165*(JfR[21]+JfR[20])+0.22360679774997894*JfR[19]+0.22360679774997902*JfR[18]-0.3872983346207417*JfR[17]+0.22360679774997896*JfR[16]+0.5809475019311124*JfR[15]-0.33541019662496846*JfR[14]+0.5809475019311124*JfR[13]-0.4330127018922193*JfR[12]+0.5809475019311124*JfR[11]-0.33541019662496846*JfR[10]+0.25*JfR[9]-0.4330127018922193*JfR[8]-0.33541019662496846*JfR[7]+0.5809475019311124*JfR[6]-0.4330127018922193*JfR[5]+0.25*JfR[4]-0.33541019662496846*JfR[3]+0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[9] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsR[3])+0.5*speedsR[2]-0.8660254037844386*speedsR[1]+0.5*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.4841229182759271*JfL[23])-0.2795084971874737*JfL[22]-0.4841229182759271*(JfL[21]+JfL[20])-0.2795084971874738*(JfL[19]+JfL[18])-0.4841229182759271*JfL[17]-0.2795084971874737*JfL[16]+0.4330127018922193*JfL[12]+0.25*JfL[9]+0.4330127018922193*(JfL[8]+JfL[5])+0.25*(JfL[4]+JfL[2])+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.4841229182759271*JfR[23]-0.2795084971874737*JfR[22]+0.4841229182759271*(JfR[21]+JfR[20])-0.2795084971874738*(JfR[19]+JfR[18])+0.4841229182759271*JfR[17]-0.2795084971874737*JfR[16]-0.4330127018922193*JfR[12]+0.25*JfR[9]-0.4330127018922193*(JfR[8]+JfR[5])+0.25*(JfR[4]+JfR[2])-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[10] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.8660254037844386*speedsR[3])+0.5*speedsR[2]-0.8660254037844386*speedsR[1]+0.5*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3872983346207417*JfL[23]+0.22360679774997896*JfL[22]+0.38729833462074165*(JfL[21]+JfL[20])+0.22360679774997894*JfL[19]+0.22360679774997902*JfL[18]+0.3872983346207417*JfL[17]+0.22360679774997896*JfL[16]+0.5809475019311124*JfL[15]+0.33541019662496846*JfL[14]+0.5809475019311124*JfL[13]+0.4330127018922193*JfL[12]+0.5809475019311124*JfL[11]+0.33541019662496846*JfL[10]+0.25*JfL[9]+0.4330127018922193*JfL[8]+0.33541019662496846*JfL[7]+0.5809475019311124*JfL[6]+0.4330127018922193*JfL[5]+0.25*JfL[4]+0.33541019662496846*JfL[3]+0.25*JfL[2]+0.4330127018922193*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.3872983346207417*JfR[23])+0.22360679774997896*JfR[22]-0.38729833462074165*(JfR[21]+JfR[20])+0.22360679774997894*JfR[19]+0.22360679774997902*JfR[18]-0.3872983346207417*JfR[17]+0.22360679774997896*JfR[16]-0.5809475019311124*JfR[15]+0.33541019662496846*JfR[14]-0.5809475019311124*JfR[13]-0.4330127018922193*JfR[12]-0.5809475019311124*JfR[11]+0.33541019662496846*JfR[10]+0.25*JfR[9]-0.4330127018922193*JfR[8]+0.33541019662496846*JfR[7]-0.5809475019311124*JfR[6]-0.4330127018922193*JfR[5]+0.25*JfR[4]+0.33541019662496846*JfR[3]+0.25*JfR[2]-0.4330127018922193*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[11] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdx2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfx_3x2v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfx_3x2v_ser_p1.c new file mode 100644 index 0000000000..b93b666547 --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfx_3x2v_ser_p1.c @@ -0,0 +1,303 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_surfx_3x2v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdy2 = 2.0/dxv[1]; + double rdz2 = 2.0/dxv[2]; + double rdvpar2 = 2.0/dxv[3]; + + double *flux_surf_nodal = &flux_surf[0]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = -(0.6123724356957944*speedsR[7])+0.3535533905932737*speedsR[6]+0.6123724356957944*(speedsR[5]+speedsR[4])-0.3535533905932737*(speedsR[3]+speedsR[2])-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.15811388300841892*JfL[46]+0.27386127875258304*(JfL[45]+JfL[44]+JfL[43])+0.15811388300841892*(JfL[42]+JfL[41])-0.273861278752583*JfL[40]+0.15811388300841892*JfL[39]-0.273861278752583*(JfL[38]+JfL[37])-0.15811388300841892*JfL[36]-0.15811388300841894*(JfL[35]+JfL[34])+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]+0.2371708245126284*JfL[30]-0.41079191812887433*(JfL[29]+JfL[28])-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]-0.2371708245126284*(JfL[25]+JfL[24])+0.41079191812887433*JfL[23]-0.1767766952966368*JfL[22]+0.3061862178478971*(JfL[21]+JfL[20])-0.2371708245126284*JfL[19]+0.41079191812887433*(JfL[18]+JfL[17])+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.1767766952966368*(JfL[14]+JfL[13])-0.3061862178478971*JfL[12]+0.2371708245126284*(JfL[11]+JfL[10])-0.41079191812887433*JfL[9]+0.1767766952966368*JfL[8]-0.3061862178478971*(JfL[7]+JfL[6])-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]-0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.15811388300841892*JfR[46]-0.27386127875258304*(JfR[45]+JfR[44]+JfR[43])+0.15811388300841892*(JfR[42]+JfR[41])+0.273861278752583*JfR[40]+0.15811388300841892*JfR[39]+0.273861278752583*(JfR[38]+JfR[37])-0.15811388300841892*JfR[36]-0.15811388300841894*(JfR[35]+JfR[34])-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.2371708245126284*JfR[30]+0.41079191812887433*(JfR[29]+JfR[28])+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.2371708245126284*(JfR[25]+JfR[24])-0.41079191812887433*JfR[23]-0.1767766952966368*JfR[22]-0.3061862178478971*(JfR[21]+JfR[20])-0.2371708245126284*JfR[19]-0.41079191812887433*(JfR[18]+JfR[17])-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.1767766952966368*(JfR[14]+JfR[13])+0.3061862178478971*JfR[12]+0.2371708245126284*(JfR[11]+JfR[10])+0.41079191812887433*JfR[9]+0.1767766952966368*JfR[8]+0.3061862178478971*(JfR[7]+JfR[6])-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[7])+0.3535533905932737*speedsR[6]+0.6123724356957944*(speedsR[5]+speedsR[4])-0.3535533905932737*(speedsR[3]+speedsR[2])-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]+0.19764235376052366*JfL[46]-0.3423265984407287*(JfL[45]+JfL[44]+JfL[43])-0.19764235376052364*(JfL[42]+JfL[41])+0.34232659844072866*JfL[40]-0.19764235376052364*JfL[39]+0.34232659844072866*(JfL[38]+JfL[37])+0.19764235376052366*(JfL[36]+JfL[35]+JfL[34])-0.3423265984407287*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*JfL[27]-0.1767766952966368*JfL[22]+0.3061862178478971*(JfL[21]+JfL[20]+JfL[16])+0.1767766952966368*(JfL[14]+JfL[13])-0.3061862178478971*JfL[12]+0.1767766952966368*JfL[8]-0.3061862178478971*(JfL[7]+JfL[6])-0.1767766952966368*(JfL[5]+JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.34232659844072866*JfR[47])+0.19764235376052366*JfR[46]+0.3423265984407287*(JfR[45]+JfR[44]+JfR[43])-0.19764235376052364*(JfR[42]+JfR[41])-0.34232659844072866*JfR[40]-0.19764235376052364*JfR[39]-0.34232659844072866*(JfR[38]+JfR[37])+0.19764235376052366*(JfR[36]+JfR[35]+JfR[34])+0.3423265984407287*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*JfR[27]-0.1767766952966368*JfR[22]-0.3061862178478971*(JfR[21]+JfR[20]+JfR[16])+0.1767766952966368*(JfR[14]+JfR[13])+0.3061862178478971*JfR[12]+0.1767766952966368*JfR[8]+0.3061862178478971*(JfR[7]+JfR[6])-0.1767766952966368*(JfR[5]+JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[7])+0.3535533905932737*speedsR[6]+0.6123724356957944*(speedsR[5]+speedsR[4])-0.3535533905932737*(speedsR[3]+speedsR[2])-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.15811388300841892*JfL[46]+0.27386127875258304*(JfL[45]+JfL[44]+JfL[43])+0.15811388300841892*(JfL[42]+JfL[41])-0.273861278752583*JfL[40]+0.15811388300841892*JfL[39]-0.273861278752583*(JfL[38]+JfL[37])-0.15811388300841892*JfL[36]-0.15811388300841894*(JfL[35]+JfL[34])+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]-0.2371708245126284*JfL[30]+0.41079191812887433*(JfL[29]+JfL[28])-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]+0.2371708245126284*(JfL[25]+JfL[24])-0.41079191812887433*JfL[23]-0.1767766952966368*JfL[22]+0.3061862178478971*(JfL[21]+JfL[20])+0.2371708245126284*JfL[19]-0.41079191812887433*(JfL[18]+JfL[17])+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.1767766952966368*(JfL[14]+JfL[13])-0.3061862178478971*JfL[12]-0.2371708245126284*(JfL[11]+JfL[10])+0.41079191812887433*JfL[9]+0.1767766952966368*JfL[8]-0.3061862178478971*(JfL[7]+JfL[6])-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]-0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.15811388300841892*JfR[46]-0.27386127875258304*(JfR[45]+JfR[44]+JfR[43])+0.15811388300841892*(JfR[42]+JfR[41])+0.273861278752583*JfR[40]+0.15811388300841892*JfR[39]+0.273861278752583*(JfR[38]+JfR[37])-0.15811388300841892*JfR[36]-0.15811388300841894*(JfR[35]+JfR[34])-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.2371708245126284*JfR[30]-0.41079191812887433*(JfR[29]+JfR[28])+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.2371708245126284*(JfR[25]+JfR[24])+0.41079191812887433*JfR[23]-0.1767766952966368*JfR[22]-0.3061862178478971*(JfR[21]+JfR[20])+0.2371708245126284*JfR[19]+0.41079191812887433*(JfR[18]+JfR[17])-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.1767766952966368*(JfR[14]+JfR[13])+0.3061862178478971*JfR[12]-0.2371708245126284*(JfR[11]+JfR[10])-0.41079191812887433*JfR[9]+0.1767766952966368*JfR[8]+0.3061862178478971*(JfR[7]+JfR[6])-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[7])+0.3535533905932737*speedsR[6]+0.6123724356957944*(speedsR[5]+speedsR[4])-0.3535533905932737*(speedsR[3]+speedsR[2])-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.15811388300841892*JfL[46]-0.27386127875258304*(JfL[45]+JfL[44])+0.27386127875258304*JfL[43]-0.15811388300841892*(JfL[42]+JfL[41])+0.273861278752583*JfL[40]+0.15811388300841892*JfL[39]-0.273861278752583*(JfL[38]+JfL[37])+0.15811388300841892*JfL[36]-0.15811388300841894*(JfL[35]+JfL[34])+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]-0.2371708245126284*JfL[30]+0.41079191812887433*(JfL[29]+JfL[28])+0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.2371708245126284*(JfL[25]+JfL[24])-0.41079191812887433*JfL[23]+0.1767766952966368*JfL[22]-0.3061862178478971*(JfL[21]+JfL[20])-0.2371708245126284*JfL[19]+0.41079191812887433*(JfL[18]+JfL[17])+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.1767766952966368*(JfL[14]+JfL[13])+0.3061862178478971*JfL[12]+0.2371708245126284*(JfL[11]+JfL[10])-0.41079191812887433*JfL[9]+0.1767766952966368*JfL[8]-0.3061862178478971*(JfL[7]+JfL[6])+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]-0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.15811388300841892*JfR[46]+0.27386127875258304*(JfR[45]+JfR[44])-0.27386127875258304*JfR[43]-0.15811388300841892*(JfR[42]+JfR[41])-0.273861278752583*JfR[40]+0.15811388300841892*JfR[39]+0.273861278752583*(JfR[38]+JfR[37])+0.15811388300841892*JfR[36]-0.15811388300841894*(JfR[35]+JfR[34])-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.2371708245126284*JfR[30]-0.41079191812887433*(JfR[29]+JfR[28])-0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]+0.2371708245126284*(JfR[25]+JfR[24])+0.41079191812887433*JfR[23]+0.1767766952966368*JfR[22]+0.3061862178478971*(JfR[21]+JfR[20])-0.2371708245126284*JfR[19]-0.41079191812887433*(JfR[18]+JfR[17])-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.1767766952966368*(JfR[14]+JfR[13])-0.3061862178478971*JfR[12]+0.2371708245126284*(JfR[11]+JfR[10])+0.41079191812887433*JfR[9]+0.1767766952966368*JfR[8]+0.3061862178478971*(JfR[7]+JfR[6])+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[3] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[7])+0.3535533905932737*speedsR[6]+0.6123724356957944*(speedsR[5]+speedsR[4])-0.3535533905932737*(speedsR[3]+speedsR[2])-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])-0.19764235376052366*JfL[46]+0.3423265984407287*(JfL[45]+JfL[44])-0.3423265984407287*JfL[43]+0.19764235376052364*(JfL[42]+JfL[41])-0.34232659844072866*JfL[40]-0.19764235376052364*JfL[39]+0.34232659844072866*(JfL[38]+JfL[37])-0.19764235376052366*JfL[36]+0.19764235376052366*(JfL[35]+JfL[34])-0.3423265984407287*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*JfL[27]+0.1767766952966368*JfL[22]-0.3061862178478971*(JfL[21]+JfL[20])+0.3061862178478971*JfL[16]-0.1767766952966368*(JfL[14]+JfL[13])+0.3061862178478971*JfL[12]+0.1767766952966368*JfL[8]-0.3061862178478971*(JfL[7]+JfL[6])+0.1767766952966368*JfL[5]-0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.34232659844072866*JfR[47]-0.19764235376052366*JfR[46]-0.3423265984407287*(JfR[45]+JfR[44])+0.3423265984407287*JfR[43]+0.19764235376052364*(JfR[42]+JfR[41])+0.34232659844072866*JfR[40]-0.19764235376052364*JfR[39]-0.34232659844072866*(JfR[38]+JfR[37])-0.19764235376052366*JfR[36]+0.19764235376052366*(JfR[35]+JfR[34])+0.3423265984407287*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*JfR[27]+0.1767766952966368*JfR[22]+0.3061862178478971*(JfR[21]+JfR[20])-0.3061862178478971*JfR[16]-0.1767766952966368*(JfR[14]+JfR[13])-0.3061862178478971*JfR[12]+0.1767766952966368*JfR[8]+0.3061862178478971*(JfR[7]+JfR[6])+0.1767766952966368*JfR[5]-0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[4] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[7])+0.3535533905932737*speedsR[6]+0.6123724356957944*(speedsR[5]+speedsR[4])-0.3535533905932737*(speedsR[3]+speedsR[2])-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.15811388300841892*JfL[46]-0.27386127875258304*(JfL[45]+JfL[44])+0.27386127875258304*JfL[43]-0.15811388300841892*(JfL[42]+JfL[41])+0.273861278752583*JfL[40]+0.15811388300841892*JfL[39]-0.273861278752583*(JfL[38]+JfL[37])+0.15811388300841892*JfL[36]-0.15811388300841894*(JfL[35]+JfL[34])+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]+0.2371708245126284*JfL[30]-0.41079191812887433*(JfL[29]+JfL[28])+0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.2371708245126284*(JfL[25]+JfL[24])+0.41079191812887433*JfL[23]+0.1767766952966368*JfL[22]-0.3061862178478971*(JfL[21]+JfL[20])+0.2371708245126284*JfL[19]-0.41079191812887433*(JfL[18]+JfL[17])+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.1767766952966368*(JfL[14]+JfL[13])+0.3061862178478971*JfL[12]-0.2371708245126284*(JfL[11]+JfL[10])+0.41079191812887433*JfL[9]+0.1767766952966368*JfL[8]-0.3061862178478971*(JfL[7]+JfL[6])+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]-0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.15811388300841892*JfR[46]+0.27386127875258304*(JfR[45]+JfR[44])-0.27386127875258304*JfR[43]-0.15811388300841892*(JfR[42]+JfR[41])-0.273861278752583*JfR[40]+0.15811388300841892*JfR[39]+0.273861278752583*(JfR[38]+JfR[37])+0.15811388300841892*JfR[36]-0.15811388300841894*(JfR[35]+JfR[34])-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.2371708245126284*JfR[30]+0.41079191812887433*(JfR[29]+JfR[28])-0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]-0.2371708245126284*(JfR[25]+JfR[24])-0.41079191812887433*JfR[23]+0.1767766952966368*JfR[22]+0.3061862178478971*(JfR[21]+JfR[20])+0.2371708245126284*JfR[19]+0.41079191812887433*(JfR[18]+JfR[17])-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.1767766952966368*(JfR[14]+JfR[13])-0.3061862178478971*JfR[12]-0.2371708245126284*(JfR[11]+JfR[10])-0.41079191812887433*JfR[9]+0.1767766952966368*JfR[8]+0.3061862178478971*(JfR[7]+JfR[6])+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[5] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[1].bmag; + Jc_quad = gkdgs[1].Jc; + B3_quad = gkdgs[1].B3; + normcurlbhat_quad = gkdgs[1].normcurlbhat; + bhat_quad[0] = gkdgs[1].bhat.x[0]; + bhat_quad[1] = gkdgs[1].bhat.x[1]; + bhat_quad[2] = gkdgs[1].bhat.x[2]; + area_elem_quad = dgs[1].area_elem; + + + alpha_quad = 0.6123724356957944*speedsR[7]-0.3535533905932737*speedsR[6]-0.6123724356957944*speedsR[5]+0.6123724356957944*speedsR[4]+0.3535533905932737*speedsR[3]-0.3535533905932737*speedsR[2]-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.15811388300841892*JfL[46]-0.27386127875258304*JfL[45]+0.27386127875258304*JfL[44]-0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]+0.15811388300841892*JfL[41]-0.273861278752583*JfL[40]-0.15811388300841892*JfL[39]+0.273861278752583*JfL[38]-0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]-0.15811388300841894*JfL[34]+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]-0.2371708245126284*JfL[30]+0.41079191812887433*JfL[29]-0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]-0.2371708245126284*JfL[24]+0.41079191812887433*JfL[23]+0.1767766952966368*JfL[22]-0.3061862178478971*JfL[21]+0.3061862178478971*JfL[20]+0.2371708245126284*JfL[19]-0.41079191812887433*JfL[18]+0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]+0.1767766952966368*JfL[13]-0.3061862178478971*JfL[12]-0.2371708245126284*JfL[11]+0.2371708245126284*JfL[10]-0.41079191812887433*JfL[9]-0.1767766952966368*JfL[8]+0.3061862178478971*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]-0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.15811388300841892*JfR[46]+0.27386127875258304*JfR[45]-0.27386127875258304*JfR[44]+0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]+0.15811388300841892*JfR[41]+0.273861278752583*JfR[40]-0.15811388300841892*JfR[39]-0.273861278752583*JfR[38]+0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.15811388300841894*JfR[34]-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.2371708245126284*JfR[30]-0.41079191812887433*JfR[29]+0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]-0.2371708245126284*JfR[24]-0.41079191812887433*JfR[23]+0.1767766952966368*JfR[22]+0.3061862178478971*JfR[21]-0.3061862178478971*JfR[20]+0.2371708245126284*JfR[19]+0.41079191812887433*JfR[18]-0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]+0.1767766952966368*JfR[13]+0.3061862178478971*JfR[12]-0.2371708245126284*JfR[11]+0.2371708245126284*JfR[10]+0.41079191812887433*JfR[9]-0.1767766952966368*JfR[8]-0.3061862178478971*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[6] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[7]-0.3535533905932737*speedsR[6]-0.6123724356957944*speedsR[5]+0.6123724356957944*speedsR[4]+0.3535533905932737*speedsR[3]-0.3535533905932737*speedsR[2]-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])-0.19764235376052366*JfL[46]+0.3423265984407287*JfL[45]-0.3423265984407287*JfL[44]+0.3423265984407287*JfL[43]+0.19764235376052364*JfL[42]-0.19764235376052364*JfL[41]+0.34232659844072866*JfL[40]+0.19764235376052364*JfL[39]-0.34232659844072866*JfL[38]+0.34232659844072866*JfL[37]+0.19764235376052366*JfL[36]-0.19764235376052366*JfL[35]+0.19764235376052366*JfL[34]-0.3423265984407287*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*JfL[27]+0.1767766952966368*JfL[22]-0.3061862178478971*JfL[21]+0.3061862178478971*JfL[20]-0.3061862178478971*JfL[16]-0.1767766952966368*JfL[14]+0.1767766952966368*JfL[13]-0.3061862178478971*JfL[12]-0.1767766952966368*JfL[8]+0.3061862178478971*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.1767766952966368*JfL[3]-0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.34232659844072866*JfR[47]-0.19764235376052366*JfR[46]-0.3423265984407287*JfR[45]+0.3423265984407287*JfR[44]-0.3423265984407287*JfR[43]+0.19764235376052364*JfR[42]-0.19764235376052364*JfR[41]-0.34232659844072866*JfR[40]+0.19764235376052364*JfR[39]+0.34232659844072866*JfR[38]-0.34232659844072866*JfR[37]+0.19764235376052366*JfR[36]-0.19764235376052366*JfR[35]+0.19764235376052366*JfR[34]+0.3423265984407287*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*JfR[27]+0.1767766952966368*JfR[22]+0.3061862178478971*JfR[21]-0.3061862178478971*JfR[20]+0.3061862178478971*JfR[16]-0.1767766952966368*JfR[14]+0.1767766952966368*JfR[13]+0.3061862178478971*JfR[12]-0.1767766952966368*JfR[8]-0.3061862178478971*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.1767766952966368*JfR[3]-0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[7] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[7]-0.3535533905932737*speedsR[6]-0.6123724356957944*speedsR[5]+0.6123724356957944*speedsR[4]+0.3535533905932737*speedsR[3]-0.3535533905932737*speedsR[2]-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.15811388300841892*JfL[46]-0.27386127875258304*JfL[45]+0.27386127875258304*JfL[44]-0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]+0.15811388300841892*JfL[41]-0.273861278752583*JfL[40]-0.15811388300841892*JfL[39]+0.273861278752583*JfL[38]-0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]-0.15811388300841894*JfL[34]+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]+0.2371708245126284*JfL[30]-0.41079191812887433*JfL[29]+0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]+0.2371708245126284*JfL[24]-0.41079191812887433*JfL[23]+0.1767766952966368*JfL[22]-0.3061862178478971*JfL[21]+0.3061862178478971*JfL[20]-0.2371708245126284*JfL[19]+0.41079191812887433*JfL[18]-0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]+0.1767766952966368*JfL[13]-0.3061862178478971*JfL[12]+0.2371708245126284*JfL[11]-0.2371708245126284*JfL[10]+0.41079191812887433*JfL[9]-0.1767766952966368*JfL[8]+0.3061862178478971*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]-0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.15811388300841892*JfR[46]+0.27386127875258304*JfR[45]-0.27386127875258304*JfR[44]+0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]+0.15811388300841892*JfR[41]+0.273861278752583*JfR[40]-0.15811388300841892*JfR[39]-0.273861278752583*JfR[38]+0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.15811388300841894*JfR[34]-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.2371708245126284*JfR[30]+0.41079191812887433*JfR[29]-0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]+0.2371708245126284*JfR[24]+0.41079191812887433*JfR[23]+0.1767766952966368*JfR[22]+0.3061862178478971*JfR[21]-0.3061862178478971*JfR[20]-0.2371708245126284*JfR[19]-0.41079191812887433*JfR[18]+0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]+0.1767766952966368*JfR[13]+0.3061862178478971*JfR[12]+0.2371708245126284*JfR[11]-0.2371708245126284*JfR[10]-0.41079191812887433*JfR[9]-0.1767766952966368*JfR[8]-0.3061862178478971*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[8] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[7]-0.3535533905932737*speedsR[6]-0.6123724356957944*speedsR[5]+0.6123724356957944*speedsR[4]+0.3535533905932737*speedsR[3]-0.3535533905932737*speedsR[2]-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.15811388300841892*JfL[46]+0.27386127875258304*JfL[45]-0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]-0.15811388300841892*JfL[41]+0.273861278752583*JfL[40]-0.15811388300841892*JfL[39]+0.273861278752583*JfL[38]-0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]-0.15811388300841894*JfL[34]+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]+0.2371708245126284*JfL[30]-0.41079191812887433*JfL[29]+0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]+0.2371708245126284*JfL[24]-0.41079191812887433*JfL[23]-0.1767766952966368*JfL[22]+0.3061862178478971*JfL[21]-0.3061862178478971*JfL[20]+0.2371708245126284*JfL[19]-0.41079191812887433*JfL[18]+0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]-0.1767766952966368*JfL[13]+0.3061862178478971*JfL[12]-0.2371708245126284*JfL[11]+0.2371708245126284*JfL[10]-0.41079191812887433*JfL[9]-0.1767766952966368*JfL[8]+0.3061862178478971*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]-0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.15811388300841892*JfR[46]-0.27386127875258304*JfR[45]+0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]-0.15811388300841892*JfR[41]-0.273861278752583*JfR[40]-0.15811388300841892*JfR[39]-0.273861278752583*JfR[38]+0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.15811388300841894*JfR[34]-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.2371708245126284*JfR[30]+0.41079191812887433*JfR[29]-0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]+0.2371708245126284*JfR[24]+0.41079191812887433*JfR[23]-0.1767766952966368*JfR[22]-0.3061862178478971*JfR[21]+0.3061862178478971*JfR[20]+0.2371708245126284*JfR[19]+0.41079191812887433*JfR[18]-0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]-0.1767766952966368*JfR[13]-0.3061862178478971*JfR[12]-0.2371708245126284*JfR[11]+0.2371708245126284*JfR[10]+0.41079191812887433*JfR[9]-0.1767766952966368*JfR[8]-0.3061862178478971*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[9] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[7]-0.3535533905932737*speedsR[6]-0.6123724356957944*speedsR[5]+0.6123724356957944*speedsR[4]+0.3535533905932737*speedsR[3]-0.3535533905932737*speedsR[2]-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]+0.19764235376052366*JfL[46]-0.3423265984407287*JfL[45]+0.3423265984407287*(JfL[44]+JfL[43])-0.19764235376052364*JfL[42]+0.19764235376052364*JfL[41]-0.34232659844072866*JfL[40]+0.19764235376052364*JfL[39]-0.34232659844072866*JfL[38]+0.34232659844072866*JfL[37]-0.19764235376052366*(JfL[36]+JfL[35])+0.19764235376052366*JfL[34]-0.3423265984407287*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*JfL[27]-0.1767766952966368*JfL[22]+0.3061862178478971*JfL[21]-0.3061862178478971*(JfL[20]+JfL[16])+0.1767766952966368*JfL[14]-0.1767766952966368*JfL[13]+0.3061862178478971*JfL[12]-0.1767766952966368*JfL[8]+0.3061862178478971*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*(JfL[5]+JfL[3])-0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.34232659844072866*JfR[47])+0.19764235376052366*JfR[46]+0.3423265984407287*JfR[45]-0.3423265984407287*(JfR[44]+JfR[43])-0.19764235376052364*JfR[42]+0.19764235376052364*JfR[41]+0.34232659844072866*JfR[40]+0.19764235376052364*JfR[39]+0.34232659844072866*JfR[38]-0.34232659844072866*JfR[37]-0.19764235376052366*(JfR[36]+JfR[35])+0.19764235376052366*JfR[34]+0.3423265984407287*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*JfR[27]-0.1767766952966368*JfR[22]-0.3061862178478971*JfR[21]+0.3061862178478971*(JfR[20]+JfR[16])+0.1767766952966368*JfR[14]-0.1767766952966368*JfR[13]-0.3061862178478971*JfR[12]-0.1767766952966368*JfR[8]-0.3061862178478971*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*(JfR[5]+JfR[3])-0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[10] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[7]-0.3535533905932737*speedsR[6]-0.6123724356957944*speedsR[5]+0.6123724356957944*speedsR[4]+0.3535533905932737*speedsR[3]-0.3535533905932737*speedsR[2]-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.15811388300841892*JfL[46]+0.27386127875258304*JfL[45]-0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]-0.15811388300841892*JfL[41]+0.273861278752583*JfL[40]-0.15811388300841892*JfL[39]+0.273861278752583*JfL[38]-0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]-0.15811388300841894*JfL[34]+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]-0.2371708245126284*JfL[30]+0.41079191812887433*JfL[29]-0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]-0.2371708245126284*JfL[24]+0.41079191812887433*JfL[23]-0.1767766952966368*JfL[22]+0.3061862178478971*JfL[21]-0.3061862178478971*JfL[20]-0.2371708245126284*JfL[19]+0.41079191812887433*JfL[18]-0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]-0.1767766952966368*JfL[13]+0.3061862178478971*JfL[12]+0.2371708245126284*JfL[11]-0.2371708245126284*JfL[10]+0.41079191812887433*JfL[9]-0.1767766952966368*JfL[8]+0.3061862178478971*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]-0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.15811388300841892*JfR[46]-0.27386127875258304*JfR[45]+0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]-0.15811388300841892*JfR[41]-0.273861278752583*JfR[40]-0.15811388300841892*JfR[39]-0.273861278752583*JfR[38]+0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.15811388300841894*JfR[34]-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.2371708245126284*JfR[30]-0.41079191812887433*JfR[29]+0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]-0.2371708245126284*JfR[24]-0.41079191812887433*JfR[23]-0.1767766952966368*JfR[22]-0.3061862178478971*JfR[21]+0.3061862178478971*JfR[20]-0.2371708245126284*JfR[19]-0.41079191812887433*JfR[18]+0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]-0.1767766952966368*JfR[13]-0.3061862178478971*JfR[12]+0.2371708245126284*JfR[11]-0.2371708245126284*JfR[10]-0.41079191812887433*JfR[9]-0.1767766952966368*JfR[8]-0.3061862178478971*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[11] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[2].bmag; + Jc_quad = gkdgs[2].Jc; + B3_quad = gkdgs[2].B3; + normcurlbhat_quad = gkdgs[2].normcurlbhat; + bhat_quad[0] = gkdgs[2].bhat.x[0]; + bhat_quad[1] = gkdgs[2].bhat.x[1]; + bhat_quad[2] = gkdgs[2].bhat.x[2]; + area_elem_quad = dgs[2].area_elem; + + + alpha_quad = 0.6123724356957944*speedsR[7]-0.3535533905932737*speedsR[6]+0.6123724356957944*speedsR[5]-0.6123724356957944*speedsR[4]-0.3535533905932737*speedsR[3]+0.3535533905932737*speedsR[2]-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.15811388300841892*JfL[46]+0.27386127875258304*JfL[45]-0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]-0.15811388300841892*JfL[41]-0.273861278752583*JfL[40]-0.15811388300841892*JfL[39]-0.273861278752583*JfL[38]+0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.15811388300841894*JfL[34]+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]-0.2371708245126284*JfL[30]-0.41079191812887433*JfL[29]+0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]+0.2371708245126284*JfL[24]+0.41079191812887433*JfL[23]+0.1767766952966368*JfL[22]+0.3061862178478971*JfL[21]-0.3061862178478971*JfL[20]+0.2371708245126284*JfL[19]+0.41079191812887433*JfL[18]-0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]-0.1767766952966368*JfL[13]-0.3061862178478971*JfL[12]+0.2371708245126284*JfL[11]-0.2371708245126284*JfL[10]-0.41079191812887433*JfL[9]-0.1767766952966368*JfL[8]-0.3061862178478971*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.15811388300841892*JfR[46]-0.27386127875258304*JfR[45]+0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]-0.15811388300841892*JfR[41]+0.273861278752583*JfR[40]-0.15811388300841892*JfR[39]+0.273861278752583*JfR[38]-0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]+0.15811388300841894*JfR[34]-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.2371708245126284*JfR[30]+0.41079191812887433*JfR[29]-0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]+0.2371708245126284*JfR[24]-0.41079191812887433*JfR[23]+0.1767766952966368*JfR[22]-0.3061862178478971*JfR[21]+0.3061862178478971*JfR[20]+0.2371708245126284*JfR[19]-0.41079191812887433*JfR[18]+0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]-0.1767766952966368*JfR[13]+0.3061862178478971*JfR[12]+0.2371708245126284*JfR[11]-0.2371708245126284*JfR[10]+0.41079191812887433*JfR[9]-0.1767766952966368*JfR[8]+0.3061862178478971*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]+0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[12] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[7]-0.3535533905932737*speedsR[6]+0.6123724356957944*speedsR[5]-0.6123724356957944*speedsR[4]-0.3535533905932737*speedsR[3]+0.3535533905932737*speedsR[2]-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])-0.19764235376052366*JfL[46]-0.3423265984407287*JfL[45]+0.3423265984407287*(JfL[44]+JfL[43])-0.19764235376052364*JfL[42]+0.19764235376052364*JfL[41]+0.34232659844072866*JfL[40]+0.19764235376052364*JfL[39]+0.34232659844072866*JfL[38]-0.34232659844072866*JfL[37]+0.19764235376052366*(JfL[36]+JfL[35])-0.19764235376052366*JfL[34]-0.3423265984407287*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*JfL[27]+0.1767766952966368*JfL[22]+0.3061862178478971*JfL[21]-0.3061862178478971*(JfL[20]+JfL[16])+0.1767766952966368*JfL[14]-0.1767766952966368*JfL[13]-0.3061862178478971*JfL[12]-0.1767766952966368*JfL[8]-0.3061862178478971*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*(JfL[5]+JfL[3])+0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.34232659844072866*JfR[47]-0.19764235376052366*JfR[46]+0.3423265984407287*JfR[45]-0.3423265984407287*(JfR[44]+JfR[43])-0.19764235376052364*JfR[42]+0.19764235376052364*JfR[41]-0.34232659844072866*JfR[40]+0.19764235376052364*JfR[39]-0.34232659844072866*JfR[38]+0.34232659844072866*JfR[37]+0.19764235376052366*(JfR[36]+JfR[35])-0.19764235376052366*JfR[34]+0.3423265984407287*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*JfR[27]+0.1767766952966368*JfR[22]-0.3061862178478971*JfR[21]+0.3061862178478971*(JfR[20]+JfR[16])+0.1767766952966368*JfR[14]-0.1767766952966368*JfR[13]+0.3061862178478971*JfR[12]-0.1767766952966368*JfR[8]+0.3061862178478971*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*(JfR[5]+JfR[3])+0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[13] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[7]-0.3535533905932737*speedsR[6]+0.6123724356957944*speedsR[5]-0.6123724356957944*speedsR[4]-0.3535533905932737*speedsR[3]+0.3535533905932737*speedsR[2]-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.15811388300841892*JfL[46]+0.27386127875258304*JfL[45]-0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]-0.15811388300841892*JfL[41]-0.273861278752583*JfL[40]-0.15811388300841892*JfL[39]-0.273861278752583*JfL[38]+0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.15811388300841894*JfL[34]+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]+0.2371708245126284*JfL[30]+0.41079191812887433*JfL[29]-0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]-0.2371708245126284*JfL[24]-0.41079191812887433*JfL[23]+0.1767766952966368*JfL[22]+0.3061862178478971*JfL[21]-0.3061862178478971*JfL[20]-0.2371708245126284*JfL[19]-0.41079191812887433*JfL[18]+0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]-0.1767766952966368*JfL[13]-0.3061862178478971*JfL[12]-0.2371708245126284*JfL[11]+0.2371708245126284*JfL[10]+0.41079191812887433*JfL[9]-0.1767766952966368*JfL[8]-0.3061862178478971*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.15811388300841892*JfR[46]-0.27386127875258304*JfR[45]+0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]-0.15811388300841892*JfR[41]+0.273861278752583*JfR[40]-0.15811388300841892*JfR[39]+0.273861278752583*JfR[38]-0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]+0.15811388300841894*JfR[34]-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.2371708245126284*JfR[30]-0.41079191812887433*JfR[29]+0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]-0.2371708245126284*JfR[24]+0.41079191812887433*JfR[23]+0.1767766952966368*JfR[22]-0.3061862178478971*JfR[21]+0.3061862178478971*JfR[20]-0.2371708245126284*JfR[19]+0.41079191812887433*JfR[18]-0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]-0.1767766952966368*JfR[13]+0.3061862178478971*JfR[12]-0.2371708245126284*JfR[11]+0.2371708245126284*JfR[10]-0.41079191812887433*JfR[9]-0.1767766952966368*JfR[8]+0.3061862178478971*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]+0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[14] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[7]-0.3535533905932737*speedsR[6]+0.6123724356957944*speedsR[5]-0.6123724356957944*speedsR[4]-0.3535533905932737*speedsR[3]+0.3535533905932737*speedsR[2]-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.15811388300841892*JfL[46]-0.27386127875258304*JfL[45]+0.27386127875258304*JfL[44]-0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]+0.15811388300841892*JfL[41]+0.273861278752583*JfL[40]-0.15811388300841892*JfL[39]-0.273861278752583*JfL[38]+0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.15811388300841894*JfL[34]+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]+0.2371708245126284*JfL[30]+0.41079191812887433*JfL[29]-0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]-0.2371708245126284*JfL[24]-0.41079191812887433*JfL[23]-0.1767766952966368*JfL[22]-0.3061862178478971*JfL[21]+0.3061862178478971*JfL[20]+0.2371708245126284*JfL[19]+0.41079191812887433*JfL[18]-0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]+0.1767766952966368*JfL[13]+0.3061862178478971*JfL[12]+0.2371708245126284*JfL[11]-0.2371708245126284*JfL[10]-0.41079191812887433*JfL[9]-0.1767766952966368*JfL[8]-0.3061862178478971*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.15811388300841892*JfR[46]+0.27386127875258304*JfR[45]-0.27386127875258304*JfR[44]+0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]+0.15811388300841892*JfR[41]-0.273861278752583*JfR[40]-0.15811388300841892*JfR[39]+0.273861278752583*JfR[38]-0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]+0.15811388300841894*JfR[34]-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.2371708245126284*JfR[30]-0.41079191812887433*JfR[29]+0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]-0.2371708245126284*JfR[24]+0.41079191812887433*JfR[23]-0.1767766952966368*JfR[22]+0.3061862178478971*JfR[21]-0.3061862178478971*JfR[20]+0.2371708245126284*JfR[19]-0.41079191812887433*JfR[18]+0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]+0.1767766952966368*JfR[13]-0.3061862178478971*JfR[12]+0.2371708245126284*JfR[11]-0.2371708245126284*JfR[10]+0.41079191812887433*JfR[9]-0.1767766952966368*JfR[8]+0.3061862178478971*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]+0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[15] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[7]-0.3535533905932737*speedsR[6]+0.6123724356957944*speedsR[5]-0.6123724356957944*speedsR[4]-0.3535533905932737*speedsR[3]+0.3535533905932737*speedsR[2]-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]+0.19764235376052366*JfL[46]+0.3423265984407287*JfL[45]-0.3423265984407287*JfL[44]+0.3423265984407287*JfL[43]+0.19764235376052364*JfL[42]-0.19764235376052364*JfL[41]-0.34232659844072866*JfL[40]+0.19764235376052364*JfL[39]+0.34232659844072866*JfL[38]-0.34232659844072866*JfL[37]-0.19764235376052366*JfL[36]+0.19764235376052366*JfL[35]-0.19764235376052366*JfL[34]-0.3423265984407287*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*JfL[27]-0.1767766952966368*JfL[22]-0.3061862178478971*JfL[21]+0.3061862178478971*JfL[20]-0.3061862178478971*JfL[16]-0.1767766952966368*JfL[14]+0.1767766952966368*JfL[13]+0.3061862178478971*JfL[12]-0.1767766952966368*JfL[8]-0.3061862178478971*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.1767766952966368*JfL[3]+0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.34232659844072866*JfR[47])+0.19764235376052366*JfR[46]-0.3423265984407287*JfR[45]+0.3423265984407287*JfR[44]-0.3423265984407287*JfR[43]+0.19764235376052364*JfR[42]-0.19764235376052364*JfR[41]+0.34232659844072866*JfR[40]+0.19764235376052364*JfR[39]-0.34232659844072866*JfR[38]+0.34232659844072866*JfR[37]-0.19764235376052366*JfR[36]+0.19764235376052366*JfR[35]-0.19764235376052366*JfR[34]+0.3423265984407287*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*JfR[27]-0.1767766952966368*JfR[22]+0.3061862178478971*JfR[21]-0.3061862178478971*JfR[20]+0.3061862178478971*JfR[16]-0.1767766952966368*JfR[14]+0.1767766952966368*JfR[13]-0.3061862178478971*JfR[12]-0.1767766952966368*JfR[8]+0.3061862178478971*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.1767766952966368*JfR[3]+0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[16] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[7]-0.3535533905932737*speedsR[6]+0.6123724356957944*speedsR[5]-0.6123724356957944*speedsR[4]-0.3535533905932737*speedsR[3]+0.3535533905932737*speedsR[2]-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.15811388300841892*JfL[46]-0.27386127875258304*JfL[45]+0.27386127875258304*JfL[44]-0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]+0.15811388300841892*JfL[41]+0.273861278752583*JfL[40]-0.15811388300841892*JfL[39]-0.273861278752583*JfL[38]+0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.15811388300841894*JfL[34]+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]-0.2371708245126284*JfL[30]-0.41079191812887433*JfL[29]+0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]+0.2371708245126284*JfL[24]+0.41079191812887433*JfL[23]-0.1767766952966368*JfL[22]-0.3061862178478971*JfL[21]+0.3061862178478971*JfL[20]-0.2371708245126284*JfL[19]-0.41079191812887433*JfL[18]+0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]+0.1767766952966368*JfL[13]+0.3061862178478971*JfL[12]-0.2371708245126284*JfL[11]+0.2371708245126284*JfL[10]+0.41079191812887433*JfL[9]-0.1767766952966368*JfL[8]-0.3061862178478971*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.1767766952966368*JfL[2]+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.15811388300841892*JfR[46]+0.27386127875258304*JfR[45]-0.27386127875258304*JfR[44]+0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]+0.15811388300841892*JfR[41]-0.273861278752583*JfR[40]-0.15811388300841892*JfR[39]+0.273861278752583*JfR[38]-0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]+0.15811388300841894*JfR[34]-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.2371708245126284*JfR[30]+0.41079191812887433*JfR[29]-0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]+0.2371708245126284*JfR[24]-0.41079191812887433*JfR[23]-0.1767766952966368*JfR[22]+0.3061862178478971*JfR[21]-0.3061862178478971*JfR[20]-0.2371708245126284*JfR[19]+0.41079191812887433*JfR[18]-0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]+0.1767766952966368*JfR[13]-0.3061862178478971*JfR[12]-0.2371708245126284*JfR[11]+0.2371708245126284*JfR[10]-0.41079191812887433*JfR[9]-0.1767766952966368*JfR[8]+0.3061862178478971*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]+0.1767766952966368*JfR[2]-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[17] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[3].bmag; + Jc_quad = gkdgs[3].Jc; + B3_quad = gkdgs[3].B3; + normcurlbhat_quad = gkdgs[3].normcurlbhat; + bhat_quad[0] = gkdgs[3].bhat.x[0]; + bhat_quad[1] = gkdgs[3].bhat.x[1]; + bhat_quad[2] = gkdgs[3].bhat.x[2]; + area_elem_quad = dgs[3].area_elem; + + + alpha_quad = -(0.6123724356957944*speedsR[7])+0.3535533905932737*speedsR[6]-0.6123724356957944*(speedsR[5]+speedsR[4])+0.3535533905932737*(speedsR[3]+speedsR[2])-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.15811388300841892*JfL[46]-0.27386127875258304*(JfL[45]+JfL[44])+0.27386127875258304*JfL[43]-0.15811388300841892*(JfL[42]+JfL[41])-0.273861278752583*JfL[40]+0.15811388300841892*JfL[39]+0.273861278752583*(JfL[38]+JfL[37])-0.15811388300841892*JfL[36]+0.15811388300841894*(JfL[35]+JfL[34])+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]+0.2371708245126284*JfL[30]+0.41079191812887433*(JfL[29]+JfL[28])-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.2371708245126284*(JfL[25]+JfL[24])+0.41079191812887433*JfL[23]-0.1767766952966368*JfL[22]-0.3061862178478971*(JfL[21]+JfL[20])-0.2371708245126284*JfL[19]-0.41079191812887433*(JfL[18]+JfL[17])+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.1767766952966368*(JfL[14]+JfL[13])-0.3061862178478971*JfL[12]-0.2371708245126284*(JfL[11]+JfL[10])-0.41079191812887433*JfL[9]+0.1767766952966368*JfL[8]+0.3061862178478971*(JfL[7]+JfL[6])-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.15811388300841892*JfR[46]+0.27386127875258304*(JfR[45]+JfR[44])-0.27386127875258304*JfR[43]-0.15811388300841892*(JfR[42]+JfR[41])+0.273861278752583*JfR[40]+0.15811388300841892*JfR[39]-0.273861278752583*(JfR[38]+JfR[37])-0.15811388300841892*JfR[36]+0.15811388300841894*(JfR[35]+JfR[34])-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.2371708245126284*JfR[30]-0.41079191812887433*(JfR[29]+JfR[28])+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]+0.2371708245126284*(JfR[25]+JfR[24])-0.41079191812887433*JfR[23]-0.1767766952966368*JfR[22]+0.3061862178478971*(JfR[21]+JfR[20])-0.2371708245126284*JfR[19]+0.41079191812887433*(JfR[18]+JfR[17])-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.1767766952966368*(JfR[14]+JfR[13])+0.3061862178478971*JfR[12]-0.2371708245126284*(JfR[11]+JfR[10])+0.41079191812887433*JfR[9]+0.1767766952966368*JfR[8]-0.3061862178478971*(JfR[7]+JfR[6])-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]+0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[18] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[7])+0.3535533905932737*speedsR[6]-0.6123724356957944*(speedsR[5]+speedsR[4])+0.3535533905932737*(speedsR[3]+speedsR[2])-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]+0.19764235376052366*JfL[46]+0.3423265984407287*(JfL[45]+JfL[44])-0.3423265984407287*JfL[43]+0.19764235376052364*(JfL[42]+JfL[41])+0.34232659844072866*JfL[40]-0.19764235376052364*JfL[39]-0.34232659844072866*(JfL[38]+JfL[37])+0.19764235376052366*JfL[36]-0.19764235376052366*(JfL[35]+JfL[34])-0.3423265984407287*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*JfL[27]-0.1767766952966368*JfL[22]-0.3061862178478971*(JfL[21]+JfL[20])+0.3061862178478971*JfL[16]-0.1767766952966368*(JfL[14]+JfL[13])-0.3061862178478971*JfL[12]+0.1767766952966368*JfL[8]+0.3061862178478971*(JfL[7]+JfL[6])-0.1767766952966368*JfL[5]+0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.34232659844072866*JfR[47])+0.19764235376052366*JfR[46]-0.3423265984407287*(JfR[45]+JfR[44])+0.3423265984407287*JfR[43]+0.19764235376052364*(JfR[42]+JfR[41])-0.34232659844072866*JfR[40]-0.19764235376052364*JfR[39]+0.34232659844072866*(JfR[38]+JfR[37])+0.19764235376052366*JfR[36]-0.19764235376052366*(JfR[35]+JfR[34])+0.3423265984407287*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*JfR[27]-0.1767766952966368*JfR[22]+0.3061862178478971*(JfR[21]+JfR[20])-0.3061862178478971*JfR[16]-0.1767766952966368*(JfR[14]+JfR[13])+0.3061862178478971*JfR[12]+0.1767766952966368*JfR[8]-0.3061862178478971*(JfR[7]+JfR[6])-0.1767766952966368*JfR[5]+0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[19] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[7])+0.3535533905932737*speedsR[6]-0.6123724356957944*(speedsR[5]+speedsR[4])+0.3535533905932737*(speedsR[3]+speedsR[2])-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.15811388300841892*JfL[46]-0.27386127875258304*(JfL[45]+JfL[44])+0.27386127875258304*JfL[43]-0.15811388300841892*(JfL[42]+JfL[41])-0.273861278752583*JfL[40]+0.15811388300841892*JfL[39]+0.273861278752583*(JfL[38]+JfL[37])-0.15811388300841892*JfL[36]+0.15811388300841894*(JfL[35]+JfL[34])+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]-0.2371708245126284*JfL[30]-0.41079191812887433*(JfL[29]+JfL[28])-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.2371708245126284*(JfL[25]+JfL[24])-0.41079191812887433*JfL[23]-0.1767766952966368*JfL[22]-0.3061862178478971*(JfL[21]+JfL[20])+0.2371708245126284*JfL[19]+0.41079191812887433*(JfL[18]+JfL[17])+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.1767766952966368*(JfL[14]+JfL[13])-0.3061862178478971*JfL[12]+0.2371708245126284*(JfL[11]+JfL[10])+0.41079191812887433*JfL[9]+0.1767766952966368*JfL[8]+0.3061862178478971*(JfL[7]+JfL[6])-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.15811388300841892*JfR[46]+0.27386127875258304*(JfR[45]+JfR[44])-0.27386127875258304*JfR[43]-0.15811388300841892*(JfR[42]+JfR[41])+0.273861278752583*JfR[40]+0.15811388300841892*JfR[39]-0.273861278752583*(JfR[38]+JfR[37])-0.15811388300841892*JfR[36]+0.15811388300841894*(JfR[35]+JfR[34])-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.2371708245126284*JfR[30]+0.41079191812887433*(JfR[29]+JfR[28])+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]-0.2371708245126284*(JfR[25]+JfR[24])+0.41079191812887433*JfR[23]-0.1767766952966368*JfR[22]+0.3061862178478971*(JfR[21]+JfR[20])+0.2371708245126284*JfR[19]-0.41079191812887433*(JfR[18]+JfR[17])-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.1767766952966368*(JfR[14]+JfR[13])+0.3061862178478971*JfR[12]+0.2371708245126284*(JfR[11]+JfR[10])-0.41079191812887433*JfR[9]+0.1767766952966368*JfR[8]-0.3061862178478971*(JfR[7]+JfR[6])-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]+0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[20] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[7])+0.3535533905932737*speedsR[6]-0.6123724356957944*(speedsR[5]+speedsR[4])+0.3535533905932737*(speedsR[3]+speedsR[2])-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.15811388300841892*JfL[46]+0.27386127875258304*(JfL[45]+JfL[44]+JfL[43])+0.15811388300841892*(JfL[42]+JfL[41])+0.273861278752583*JfL[40]+0.15811388300841892*JfL[39]+0.273861278752583*(JfL[38]+JfL[37])+0.15811388300841892*JfL[36]+0.15811388300841894*(JfL[35]+JfL[34])+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]-0.2371708245126284*JfL[30]-0.41079191812887433*(JfL[29]+JfL[28])+0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]-0.2371708245126284*(JfL[25]+JfL[24])-0.41079191812887433*JfL[23]+0.1767766952966368*JfL[22]+0.3061862178478971*(JfL[21]+JfL[20])-0.2371708245126284*JfL[19]-0.41079191812887433*(JfL[18]+JfL[17])+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.1767766952966368*(JfL[14]+JfL[13])+0.3061862178478971*JfL[12]-0.2371708245126284*(JfL[11]+JfL[10])-0.41079191812887433*JfL[9]+0.1767766952966368*JfL[8]+0.3061862178478971*(JfL[7]+JfL[6])+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.15811388300841892*JfR[46]-0.27386127875258304*(JfR[45]+JfR[44]+JfR[43])+0.15811388300841892*(JfR[42]+JfR[41])-0.273861278752583*JfR[40]+0.15811388300841892*JfR[39]-0.273861278752583*(JfR[38]+JfR[37])+0.15811388300841892*JfR[36]+0.15811388300841894*(JfR[35]+JfR[34])-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.2371708245126284*JfR[30]+0.41079191812887433*(JfR[29]+JfR[28])-0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.2371708245126284*(JfR[25]+JfR[24])+0.41079191812887433*JfR[23]+0.1767766952966368*JfR[22]-0.3061862178478971*(JfR[21]+JfR[20])-0.2371708245126284*JfR[19]+0.41079191812887433*(JfR[18]+JfR[17])-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.1767766952966368*(JfR[14]+JfR[13])-0.3061862178478971*JfR[12]-0.2371708245126284*(JfR[11]+JfR[10])+0.41079191812887433*JfR[9]+0.1767766952966368*JfR[8]-0.3061862178478971*(JfR[7]+JfR[6])+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]+0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[21] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[7])+0.3535533905932737*speedsR[6]-0.6123724356957944*(speedsR[5]+speedsR[4])+0.3535533905932737*(speedsR[3]+speedsR[2])-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])-0.19764235376052366*JfL[46]-0.3423265984407287*(JfL[45]+JfL[44]+JfL[43])-0.19764235376052364*(JfL[42]+JfL[41])-0.34232659844072866*JfL[40]-0.19764235376052364*JfL[39]-0.34232659844072866*(JfL[38]+JfL[37])-0.19764235376052366*(JfL[36]+JfL[35]+JfL[34])-0.3423265984407287*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*JfL[27]+0.1767766952966368*JfL[22]+0.3061862178478971*(JfL[21]+JfL[20]+JfL[16])+0.1767766952966368*(JfL[14]+JfL[13])+0.3061862178478971*JfL[12]+0.1767766952966368*JfL[8]+0.3061862178478971*(JfL[7]+JfL[6])+0.1767766952966368*(JfL[5]+JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.34232659844072866*JfR[47]-0.19764235376052366*JfR[46]+0.3423265984407287*(JfR[45]+JfR[44]+JfR[43])-0.19764235376052364*(JfR[42]+JfR[41])+0.34232659844072866*JfR[40]-0.19764235376052364*JfR[39]+0.34232659844072866*(JfR[38]+JfR[37])-0.19764235376052366*(JfR[36]+JfR[35]+JfR[34])+0.3423265984407287*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*JfR[27]+0.1767766952966368*JfR[22]-0.3061862178478971*(JfR[21]+JfR[20]+JfR[16])+0.1767766952966368*(JfR[14]+JfR[13])-0.3061862178478971*JfR[12]+0.1767766952966368*JfR[8]-0.3061862178478971*(JfR[7]+JfR[6])+0.1767766952966368*(JfR[5]+JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[22] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[7])+0.3535533905932737*speedsR[6]-0.6123724356957944*(speedsR[5]+speedsR[4])+0.3535533905932737*(speedsR[3]+speedsR[2])-0.6123724356957944*speedsR[1]+0.3535533905932737*speedsR[0]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.15811388300841892*JfL[46]+0.27386127875258304*(JfL[45]+JfL[44]+JfL[43])+0.15811388300841892*(JfL[42]+JfL[41])+0.273861278752583*JfL[40]+0.15811388300841892*JfL[39]+0.273861278752583*(JfL[38]+JfL[37])+0.15811388300841892*JfL[36]+0.15811388300841894*(JfL[35]+JfL[34])+0.27386127875258304*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]+0.2371708245126284*JfL[30]+0.41079191812887433*(JfL[29]+JfL[28])+0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]+0.2371708245126284*(JfL[25]+JfL[24])+0.41079191812887433*JfL[23]+0.1767766952966368*JfL[22]+0.3061862178478971*(JfL[21]+JfL[20])+0.2371708245126284*JfL[19]+0.41079191812887433*(JfL[18]+JfL[17])+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.1767766952966368*(JfL[14]+JfL[13])+0.3061862178478971*JfL[12]+0.2371708245126284*(JfL[11]+JfL[10])+0.41079191812887433*JfL[9]+0.1767766952966368*JfL[8]+0.3061862178478971*(JfL[7]+JfL[6])+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.1767766952966368*(JfL[3]+JfL[2])+0.3061862178478971*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.15811388300841892*JfR[46]-0.27386127875258304*(JfR[45]+JfR[44]+JfR[43])+0.15811388300841892*(JfR[42]+JfR[41])-0.273861278752583*JfR[40]+0.15811388300841892*JfR[39]-0.273861278752583*(JfR[38]+JfR[37])+0.15811388300841892*JfR[36]+0.15811388300841894*(JfR[35]+JfR[34])-0.27386127875258304*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.2371708245126284*JfR[30]-0.41079191812887433*(JfR[29]+JfR[28])-0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.2371708245126284*(JfR[25]+JfR[24])-0.41079191812887433*JfR[23]+0.1767766952966368*JfR[22]-0.3061862178478971*(JfR[21]+JfR[20])+0.2371708245126284*JfR[19]-0.41079191812887433*(JfR[18]+JfR[17])-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.1767766952966368*(JfR[14]+JfR[13])-0.3061862178478971*JfR[12]+0.2371708245126284*(JfR[11]+JfR[10])-0.41079191812887433*JfR[9]+0.1767766952966368*JfR[8]-0.3061862178478971*(JfR[7]+JfR[6])+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]+0.1767766952966368*(JfR[3]+JfR[2])-0.3061862178478971*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[23] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdx2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfy_2x2v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfy_2x2v_ser_p1.c new file mode 100644 index 0000000000..390dcc7d6c --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfy_2x2v_ser_p1.c @@ -0,0 +1,174 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_surfy_2x2v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdz2 = 2.0/dxv[1]; + double rdvpar2 = 2.0/dxv[2]; + + double *flux_surf_nodal = &flux_surf[12]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = 0.8660254037844386*speedsR[7]-0.8660254037844386*speedsR[6]-0.5*speedsR[5]+0.5*speedsR[4]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3872983346207417*JfL[23]-0.38729833462074165*JfL[22]+0.22360679774997896*JfL[21]-0.38729833462074165*JfL[20]-0.22360679774997894*JfL[19]+0.3872983346207417*JfL[18]-0.22360679774997902*JfL[17]+0.22360679774997896*JfL[16]-0.5809475019311124*JfL[15]+0.5809475019311124*JfL[14]-0.33541019662496846*JfL[13]+0.4330127018922193*JfL[12]+0.5809475019311124*JfL[11]+0.33541019662496846*JfL[10]-0.4330127018922193*JfL[9]+0.25*JfL[8]-0.5809475019311124*JfL[7]+0.33541019662496846*JfL[6]-0.4330127018922193*JfL[5]-0.25*JfL[4]-0.33541019662496846*JfL[3]+0.4330127018922193*JfL[2]-0.25*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.3872983346207417*JfR[23])+0.38729833462074165*JfR[22]+0.22360679774997896*JfR[21]+0.38729833462074165*JfR[20]-0.22360679774997894*JfR[19]-0.3872983346207417*JfR[18]-0.22360679774997902*JfR[17]+0.22360679774997896*JfR[16]+0.5809475019311124*JfR[15]-0.5809475019311124*JfR[14]-0.33541019662496846*JfR[13]-0.4330127018922193*JfR[12]-0.5809475019311124*JfR[11]+0.33541019662496846*JfR[10]+0.4330127018922193*JfR[9]+0.25*JfR[8]+0.5809475019311124*JfR[7]+0.33541019662496846*JfR[6]+0.4330127018922193*JfR[5]-0.25*JfR[4]-0.33541019662496846*JfR[3]-0.4330127018922193*JfR[2]-0.25*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsR[7]-0.8660254037844386*speedsR[6]-0.5*speedsR[5]+0.5*speedsR[4]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.4841229182759271*JfL[23])+0.4841229182759271*JfL[22]-0.2795084971874737*JfL[21]+0.4841229182759271*JfL[20]+0.2795084971874738*JfL[19]-0.4841229182759271*JfL[18]+0.2795084971874738*JfL[17]-0.2795084971874737*JfL[16]+0.4330127018922193*JfL[12]-0.4330127018922193*JfL[9]+0.25*JfL[8]-0.4330127018922193*JfL[5]-0.25*JfL[4]+0.4330127018922193*JfL[2]-0.25*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.4841229182759271*JfR[23]-0.4841229182759271*JfR[22]-0.2795084971874737*JfR[21]-0.4841229182759271*JfR[20]+0.2795084971874738*JfR[19]+0.4841229182759271*JfR[18]+0.2795084971874738*JfR[17]-0.2795084971874737*JfR[16]-0.4330127018922193*JfR[12]+0.4330127018922193*JfR[9]+0.25*JfR[8]+0.4330127018922193*JfR[5]-0.25*JfR[4]-0.4330127018922193*JfR[2]-0.25*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsR[7]-0.8660254037844386*speedsR[6]-0.5*speedsR[5]+0.5*speedsR[4]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3872983346207417*JfL[23]-0.38729833462074165*JfL[22]+0.22360679774997896*JfL[21]-0.38729833462074165*JfL[20]-0.22360679774997894*JfL[19]+0.3872983346207417*JfL[18]-0.22360679774997902*JfL[17]+0.22360679774997896*JfL[16]+0.5809475019311124*JfL[15]-0.5809475019311124*JfL[14]+0.33541019662496846*JfL[13]+0.4330127018922193*JfL[12]-0.5809475019311124*JfL[11]-0.33541019662496846*JfL[10]-0.4330127018922193*JfL[9]+0.25*JfL[8]+0.5809475019311124*JfL[7]-0.33541019662496846*JfL[6]-0.4330127018922193*JfL[5]-0.25*JfL[4]+0.33541019662496846*JfL[3]+0.4330127018922193*JfL[2]-0.25*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.3872983346207417*JfR[23])+0.38729833462074165*JfR[22]+0.22360679774997896*JfR[21]+0.38729833462074165*JfR[20]-0.22360679774997894*JfR[19]-0.3872983346207417*JfR[18]-0.22360679774997902*JfR[17]+0.22360679774997896*JfR[16]-0.5809475019311124*JfR[15]+0.5809475019311124*JfR[14]+0.33541019662496846*JfR[13]-0.4330127018922193*JfR[12]+0.5809475019311124*JfR[11]-0.33541019662496846*JfR[10]+0.4330127018922193*JfR[9]+0.25*JfR[8]-0.5809475019311124*JfR[7]-0.33541019662496846*JfR[6]+0.4330127018922193*JfR[5]-0.25*JfR[4]+0.33541019662496846*JfR[3]-0.4330127018922193*JfR[2]-0.25*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsR[7]-0.8660254037844386*speedsR[6]-0.5*speedsR[5]+0.5*speedsR[4]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3872983346207417*JfL[23])+0.38729833462074165*JfL[22]-0.22360679774997896*JfL[21]-0.38729833462074165*JfL[20]+0.22360679774997894*JfL[19]+0.3872983346207417*JfL[18]-0.22360679774997902*JfL[17]+0.22360679774997896*JfL[16]+0.5809475019311124*JfL[15]-0.5809475019311124*JfL[14]+0.33541019662496846*JfL[13]-0.4330127018922193*JfL[12]+0.5809475019311124*JfL[11]-0.33541019662496846*JfL[10]+0.4330127018922193*JfL[9]-0.25*JfL[8]-0.5809475019311124*JfL[7]+0.33541019662496846*JfL[6]-0.4330127018922193*JfL[5]+0.25*JfL[4]-0.33541019662496846*JfL[3]+0.4330127018922193*JfL[2]-0.25*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.3872983346207417*JfR[23]-0.38729833462074165*JfR[22]-0.22360679774997896*JfR[21]+0.38729833462074165*JfR[20]+0.22360679774997894*JfR[19]-0.3872983346207417*JfR[18]-0.22360679774997902*JfR[17]+0.22360679774997896*JfR[16]-0.5809475019311124*JfR[15]+0.5809475019311124*JfR[14]+0.33541019662496846*JfR[13]+0.4330127018922193*JfR[12]-0.5809475019311124*JfR[11]-0.33541019662496846*JfR[10]-0.4330127018922193*JfR[9]-0.25*JfR[8]+0.5809475019311124*JfR[7]+0.33541019662496846*JfR[6]+0.4330127018922193*JfR[5]+0.25*JfR[4]-0.33541019662496846*JfR[3]-0.4330127018922193*JfR[2]-0.25*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[3] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsR[7]-0.8660254037844386*speedsR[6]-0.5*speedsR[5]+0.5*speedsR[4]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.4841229182759271*JfL[23]-0.4841229182759271*JfL[22]+0.2795084971874737*JfL[21]+0.4841229182759271*JfL[20]-0.2795084971874738*JfL[19]-0.4841229182759271*JfL[18]+0.2795084971874738*JfL[17]-0.2795084971874737*JfL[16]-0.4330127018922193*JfL[12]+0.4330127018922193*JfL[9]-0.25*JfL[8]-0.4330127018922193*JfL[5]+0.25*JfL[4]+0.4330127018922193*JfL[2]-0.25*JfL[1]+0.25*JfL[0]; + JfR_quad = -(0.4841229182759271*JfR[23])+0.4841229182759271*JfR[22]+0.2795084971874737*JfR[21]-0.4841229182759271*JfR[20]-0.2795084971874738*JfR[19]+0.4841229182759271*JfR[18]+0.2795084971874738*JfR[17]-0.2795084971874737*JfR[16]+0.4330127018922193*JfR[12]-0.4330127018922193*JfR[9]-0.25*JfR[8]+0.4330127018922193*JfR[5]+0.25*JfR[4]-0.4330127018922193*JfR[2]-0.25*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[4] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.8660254037844386*speedsR[7]-0.8660254037844386*speedsR[6]-0.5*speedsR[5]+0.5*speedsR[4]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3872983346207417*JfL[23])+0.38729833462074165*JfL[22]-0.22360679774997896*JfL[21]-0.38729833462074165*JfL[20]+0.22360679774997894*JfL[19]+0.3872983346207417*JfL[18]-0.22360679774997902*JfL[17]+0.22360679774997896*JfL[16]-0.5809475019311124*JfL[15]+0.5809475019311124*JfL[14]-0.33541019662496846*JfL[13]-0.4330127018922193*JfL[12]-0.5809475019311124*JfL[11]+0.33541019662496846*JfL[10]+0.4330127018922193*JfL[9]-0.25*JfL[8]+0.5809475019311124*JfL[7]-0.33541019662496846*JfL[6]-0.4330127018922193*JfL[5]+0.25*JfL[4]+0.33541019662496846*JfL[3]+0.4330127018922193*JfL[2]-0.25*JfL[1]+0.25*JfL[0]; + JfR_quad = 0.3872983346207417*JfR[23]-0.38729833462074165*JfR[22]-0.22360679774997896*JfR[21]+0.38729833462074165*JfR[20]+0.22360679774997894*JfR[19]-0.3872983346207417*JfR[18]-0.22360679774997902*JfR[17]+0.22360679774997896*JfR[16]+0.5809475019311124*JfR[15]-0.5809475019311124*JfR[14]-0.33541019662496846*JfR[13]+0.4330127018922193*JfR[12]+0.5809475019311124*JfR[11]+0.33541019662496846*JfR[10]-0.4330127018922193*JfR[9]-0.25*JfR[8]-0.5809475019311124*JfR[7]-0.33541019662496846*JfR[6]+0.4330127018922193*JfR[5]+0.25*JfR[4]+0.33541019662496846*JfR[3]-0.4330127018922193*JfR[2]-0.25*JfR[1]+0.25*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[5] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[1].bmag; + Jc_quad = gkdgs[1].Jc; + B3_quad = gkdgs[1].B3; + normcurlbhat_quad = gkdgs[1].normcurlbhat; + bhat_quad[0] = gkdgs[1].bhat.x[0]; + bhat_quad[1] = gkdgs[1].bhat.x[1]; + bhat_quad[2] = gkdgs[1].bhat.x[2]; + area_elem_quad = dgs[1].area_elem; + + + alpha_quad = 0.5*(speedsR[5]+speedsR[4])-0.8660254037844386*(speedsR[7]+speedsR[6]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3872983346207417*JfL[23])-0.38729833462074165*JfL[22]-0.22360679774997896*JfL[21]+0.38729833462074165*JfL[20]-0.22360679774997894*JfL[19]+0.3872983346207417*JfL[18]+0.22360679774997902*JfL[17]+0.22360679774997896*JfL[16]+0.5809475019311124*(JfL[15]+JfL[14])+0.33541019662496846*JfL[13]-0.4330127018922193*JfL[12]-0.5809475019311124*JfL[11]+0.33541019662496846*JfL[10]-0.4330127018922193*JfL[9]-0.25*JfL[8]-0.5809475019311124*JfL[7]-0.33541019662496846*JfL[6]+0.4330127018922193*JfL[5]-0.25*JfL[4]-0.33541019662496846*JfL[3]+0.4330127018922193*JfL[2]+0.25*(JfL[1]+JfL[0]); + JfR_quad = 0.3872983346207417*JfR[23]+0.38729833462074165*JfR[22]-0.22360679774997896*JfR[21]-0.38729833462074165*JfR[20]-0.22360679774997894*JfR[19]-0.3872983346207417*JfR[18]+0.22360679774997902*JfR[17]+0.22360679774997896*JfR[16]-0.5809475019311124*(JfR[15]+JfR[14])+0.33541019662496846*JfR[13]+0.4330127018922193*JfR[12]+0.5809475019311124*JfR[11]+0.33541019662496846*JfR[10]+0.4330127018922193*JfR[9]-0.25*JfR[8]+0.5809475019311124*JfR[7]-0.33541019662496846*JfR[6]-0.4330127018922193*JfR[5]-0.25*JfR[4]-0.33541019662496846*JfR[3]-0.4330127018922193*JfR[2]+0.25*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[6] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.5*(speedsR[5]+speedsR[4])-0.8660254037844386*(speedsR[7]+speedsR[6]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.4841229182759271*(JfL[23]+JfL[22])+0.2795084971874737*JfL[21]-0.4841229182759271*JfL[20]+0.2795084971874738*JfL[19]-0.4841229182759271*JfL[18]-0.2795084971874738*JfL[17]-0.2795084971874737*JfL[16]-0.4330127018922193*(JfL[12]+JfL[9])-0.25*JfL[8]+0.4330127018922193*JfL[5]-0.25*JfL[4]+0.4330127018922193*JfL[2]+0.25*(JfL[1]+JfL[0]); + JfR_quad = -(0.4841229182759271*(JfR[23]+JfR[22]))+0.2795084971874737*JfR[21]+0.4841229182759271*JfR[20]+0.2795084971874738*JfR[19]+0.4841229182759271*JfR[18]-0.2795084971874738*JfR[17]-0.2795084971874737*JfR[16]+0.4330127018922193*(JfR[12]+JfR[9])-0.25*JfR[8]-0.4330127018922193*JfR[5]-0.25*JfR[4]-0.4330127018922193*JfR[2]+0.25*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[7] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.5*(speedsR[5]+speedsR[4])-0.8660254037844386*(speedsR[7]+speedsR[6]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.3872983346207417*JfL[23])-0.38729833462074165*JfL[22]-0.22360679774997896*JfL[21]+0.38729833462074165*JfL[20]-0.22360679774997894*JfL[19]+0.3872983346207417*JfL[18]+0.22360679774997902*JfL[17]+0.22360679774997896*JfL[16]-0.5809475019311124*(JfL[15]+JfL[14])-0.33541019662496846*JfL[13]-0.4330127018922193*JfL[12]+0.5809475019311124*JfL[11]-0.33541019662496846*JfL[10]-0.4330127018922193*JfL[9]-0.25*JfL[8]+0.5809475019311124*JfL[7]+0.33541019662496846*JfL[6]+0.4330127018922193*JfL[5]-0.25*JfL[4]+0.33541019662496846*JfL[3]+0.4330127018922193*JfL[2]+0.25*(JfL[1]+JfL[0]); + JfR_quad = 0.3872983346207417*JfR[23]+0.38729833462074165*JfR[22]-0.22360679774997896*JfR[21]-0.38729833462074165*JfR[20]-0.22360679774997894*JfR[19]-0.3872983346207417*JfR[18]+0.22360679774997902*JfR[17]+0.22360679774997896*JfR[16]+0.5809475019311124*(JfR[15]+JfR[14])-0.33541019662496846*JfR[13]+0.4330127018922193*JfR[12]-0.5809475019311124*JfR[11]-0.33541019662496846*JfR[10]+0.4330127018922193*JfR[9]-0.25*JfR[8]-0.5809475019311124*JfR[7]+0.33541019662496846*JfR[6]-0.4330127018922193*JfR[5]-0.25*JfR[4]+0.33541019662496846*JfR[3]-0.4330127018922193*JfR[2]+0.25*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[8] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.5*(speedsR[5]+speedsR[4])-0.8660254037844386*(speedsR[7]+speedsR[6]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3872983346207417*JfL[23]+0.38729833462074165*JfL[22]+0.22360679774997896*JfL[21]+0.38729833462074165*JfL[20]+0.22360679774997894*JfL[19]+0.3872983346207417*JfL[18]+0.22360679774997902*JfL[17]+0.22360679774997896*JfL[16]-0.5809475019311124*(JfL[15]+JfL[14])-0.33541019662496846*JfL[13]+0.4330127018922193*JfL[12]-0.5809475019311124*JfL[11]-0.33541019662496846*JfL[10]+0.4330127018922193*JfL[9]+0.25*JfL[8]-0.5809475019311124*JfL[7]-0.33541019662496846*JfL[6]+0.4330127018922193*JfL[5]+0.25*JfL[4]-0.33541019662496846*JfL[3]+0.4330127018922193*JfL[2]+0.25*(JfL[1]+JfL[0]); + JfR_quad = -(0.3872983346207417*JfR[23])-0.38729833462074165*JfR[22]+0.22360679774997896*JfR[21]-0.38729833462074165*JfR[20]+0.22360679774997894*JfR[19]-0.3872983346207417*JfR[18]+0.22360679774997902*JfR[17]+0.22360679774997896*JfR[16]+0.5809475019311124*(JfR[15]+JfR[14])-0.33541019662496846*JfR[13]-0.4330127018922193*JfR[12]+0.5809475019311124*JfR[11]-0.33541019662496846*JfR[10]-0.4330127018922193*JfR[9]+0.25*JfR[8]+0.5809475019311124*JfR[7]-0.33541019662496846*JfR[6]-0.4330127018922193*JfR[5]+0.25*JfR[4]-0.33541019662496846*JfR[3]-0.4330127018922193*JfR[2]+0.25*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[9] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.5*(speedsR[5]+speedsR[4])-0.8660254037844386*(speedsR[7]+speedsR[6]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.4841229182759271*(JfL[23]+JfL[22]))-0.2795084971874737*JfL[21]-0.4841229182759271*JfL[20]-0.2795084971874738*JfL[19]-0.4841229182759271*JfL[18]-0.2795084971874738*JfL[17]-0.2795084971874737*JfL[16]+0.4330127018922193*(JfL[12]+JfL[9])+0.25*JfL[8]+0.4330127018922193*JfL[5]+0.25*JfL[4]+0.4330127018922193*JfL[2]+0.25*(JfL[1]+JfL[0]); + JfR_quad = 0.4841229182759271*(JfR[23]+JfR[22])-0.2795084971874737*JfR[21]+0.4841229182759271*JfR[20]-0.2795084971874738*JfR[19]+0.4841229182759271*JfR[18]-0.2795084971874738*JfR[17]-0.2795084971874737*JfR[16]-0.4330127018922193*(JfR[12]+JfR[9])+0.25*JfR[8]-0.4330127018922193*JfR[5]+0.25*JfR[4]-0.4330127018922193*JfR[2]+0.25*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[10] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.5*(speedsR[5]+speedsR[4])-0.8660254037844386*(speedsR[7]+speedsR[6]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.3872983346207417*JfL[23]+0.38729833462074165*JfL[22]+0.22360679774997896*JfL[21]+0.38729833462074165*JfL[20]+0.22360679774997894*JfL[19]+0.3872983346207417*JfL[18]+0.22360679774997902*JfL[17]+0.22360679774997896*JfL[16]+0.5809475019311124*(JfL[15]+JfL[14])+0.33541019662496846*JfL[13]+0.4330127018922193*JfL[12]+0.5809475019311124*JfL[11]+0.33541019662496846*JfL[10]+0.4330127018922193*JfL[9]+0.25*JfL[8]+0.5809475019311124*JfL[7]+0.33541019662496846*JfL[6]+0.4330127018922193*JfL[5]+0.25*JfL[4]+0.33541019662496846*JfL[3]+0.4330127018922193*JfL[2]+0.25*(JfL[1]+JfL[0]); + JfR_quad = -(0.3872983346207417*JfR[23])-0.38729833462074165*JfR[22]+0.22360679774997896*JfR[21]-0.38729833462074165*JfR[20]+0.22360679774997894*JfR[19]-0.3872983346207417*JfR[18]+0.22360679774997902*JfR[17]+0.22360679774997896*JfR[16]-0.5809475019311124*(JfR[15]+JfR[14])+0.33541019662496846*JfR[13]-0.4330127018922193*JfR[12]-0.5809475019311124*JfR[11]+0.33541019662496846*JfR[10]-0.4330127018922193*JfR[9]+0.25*JfR[8]-0.5809475019311124*JfR[7]+0.33541019662496846*JfR[6]-0.4330127018922193*JfR[5]+0.25*JfR[4]+0.33541019662496846*JfR[3]-0.4330127018922193*JfR[2]+0.25*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[11] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdz2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfy_3x2v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfy_3x2v_ser_p1.c new file mode 100644 index 0000000000..ca646990d9 --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfy_3x2v_ser_p1.c @@ -0,0 +1,303 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_surfy_3x2v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdy2 = 2.0/dxv[1]; + double rdz2 = 2.0/dxv[2]; + double rdvpar2 = 2.0/dxv[3]; + + double *flux_surf_nodal = &flux_surf[24]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = -(0.6123724356957944*speedsR[15])+0.6123724356957944*speedsR[14]+0.3535533905932737*speedsR[13]+0.6123724356957944*speedsR[12]-0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]-0.3535533905932737*speedsR[9]+0.3535533905932737*speedsR[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])+0.27386127875258304*JfL[46]-0.15811388300841892*JfL[45]+0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]-0.273861278752583*JfL[41]+0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]+0.15811388300841892*JfL[38]-0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]-0.41079191812887433*JfL[30]+0.2371708245126284*JfL[29]-0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]+0.41079191812887433*JfL[24]-0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]+0.41079191812887433*JfL[19]-0.2371708245126284*JfL[18]+0.41079191812887433*JfL[17]+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]+0.2371708245126284*JfL[11]-0.41079191812887433*JfL[10]+0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.27386127875258304*JfR[46]-0.15811388300841892*JfR[45]-0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]+0.273861278752583*JfR[41]+0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]+0.15811388300841892*JfR[38]+0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.41079191812887433*JfR[30]+0.2371708245126284*JfR[29]+0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]-0.41079191812887433*JfR[24]-0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]-0.41079191812887433*JfR[19]-0.2371708245126284*JfR[18]-0.41079191812887433*JfR[17]-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]+0.2371708245126284*JfR[11]+0.41079191812887433*JfR[10]+0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[15])+0.6123724356957944*speedsR[14]+0.3535533905932737*speedsR[13]+0.6123724356957944*speedsR[12]-0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]-0.3535533905932737*speedsR[9]+0.3535533905932737*speedsR[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]-0.3423265984407287*JfL[46]+0.19764235376052366*JfL[45]-0.3423265984407287*(JfL[44]+JfL[43])-0.19764235376052364*JfL[42]+0.34232659844072866*JfL[41]-0.19764235376052364*JfL[40]+0.34232659844072866*JfL[39]-0.19764235376052364*JfL[38]+0.34232659844072866*JfL[37]+0.19764235376052366*(JfL[36]+JfL[35])-0.3423265984407287*JfL[34]+0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*JfL[27]+0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]+0.3061862178478971*(JfL[20]+JfL[16])+0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]-0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*(JfL[5]+JfL[3])+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.34232659844072866*JfR[47])+0.3423265984407287*JfR[46]+0.19764235376052366*JfR[45]+0.3423265984407287*(JfR[44]+JfR[43])-0.19764235376052364*JfR[42]-0.34232659844072866*JfR[41]-0.19764235376052364*JfR[40]-0.34232659844072866*JfR[39]-0.19764235376052364*JfR[38]-0.34232659844072866*JfR[37]+0.19764235376052366*(JfR[36]+JfR[35])+0.3423265984407287*JfR[34]+0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*JfR[27]-0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]-0.3061862178478971*(JfR[20]+JfR[16])+0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]+0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*(JfR[5]+JfR[3])-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[15])+0.6123724356957944*speedsR[14]+0.3535533905932737*speedsR[13]+0.6123724356957944*speedsR[12]-0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]-0.3535533905932737*speedsR[9]+0.3535533905932737*speedsR[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])+0.27386127875258304*JfL[46]-0.15811388300841892*JfL[45]+0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]-0.273861278752583*JfL[41]+0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]+0.15811388300841892*JfL[38]-0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]+0.41079191812887433*JfL[30]-0.2371708245126284*JfL[29]+0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]-0.41079191812887433*JfL[24]+0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]-0.41079191812887433*JfL[19]+0.2371708245126284*JfL[18]-0.41079191812887433*JfL[17]+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]-0.2371708245126284*JfL[11]+0.41079191812887433*JfL[10]-0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.27386127875258304*JfR[46]-0.15811388300841892*JfR[45]-0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]+0.273861278752583*JfR[41]+0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]+0.15811388300841892*JfR[38]+0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.41079191812887433*JfR[30]-0.2371708245126284*JfR[29]-0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]+0.41079191812887433*JfR[24]+0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]+0.41079191812887433*JfR[19]+0.2371708245126284*JfR[18]+0.41079191812887433*JfR[17]-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]-0.2371708245126284*JfR[11]-0.41079191812887433*JfR[10]-0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[15])+0.6123724356957944*speedsR[14]+0.3535533905932737*speedsR[13]+0.6123724356957944*speedsR[12]-0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]-0.3535533905932737*speedsR[9]+0.3535533905932737*speedsR[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]-0.27386127875258304*JfL[46]+0.15811388300841892*JfL[45]-0.27386127875258304*JfL[44]+0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]+0.273861278752583*JfL[41]-0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]+0.15811388300841892*JfL[38]-0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]+0.41079191812887433*JfL[30]-0.2371708245126284*JfL[29]+0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]-0.41079191812887433*JfL[24]+0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]+0.41079191812887433*JfL[19]-0.2371708245126284*JfL[18]+0.41079191812887433*JfL[17]+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]+0.2371708245126284*JfL[11]-0.41079191812887433*JfL[10]+0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.27386127875258304*JfR[46]+0.15811388300841892*JfR[45]+0.27386127875258304*JfR[44]-0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]-0.273861278752583*JfR[41]-0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]+0.15811388300841892*JfR[38]+0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.41079191812887433*JfR[30]-0.2371708245126284*JfR[29]-0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]+0.41079191812887433*JfR[24]+0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]-0.41079191812887433*JfR[19]-0.2371708245126284*JfR[18]-0.41079191812887433*JfR[17]-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]+0.2371708245126284*JfR[11]+0.41079191812887433*JfR[10]+0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[3] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[15])+0.6123724356957944*speedsR[14]+0.3535533905932737*speedsR[13]+0.6123724356957944*speedsR[12]-0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]-0.3535533905932737*speedsR[9]+0.3535533905932737*speedsR[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])+0.3423265984407287*JfL[46]-0.19764235376052366*JfL[45]+0.3423265984407287*JfL[44]-0.3423265984407287*JfL[43]+0.19764235376052364*JfL[42]-0.34232659844072866*JfL[41]+0.19764235376052364*JfL[40]+0.34232659844072866*JfL[39]-0.19764235376052364*JfL[38]+0.34232659844072866*JfL[37]-0.19764235376052366*JfL[36]+0.19764235376052366*JfL[35]-0.3423265984407287*JfL[34]+0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*JfL[27]-0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]+0.3061862178478971*JfL[16]-0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]-0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.34232659844072866*JfR[47]-0.3423265984407287*JfR[46]-0.19764235376052366*JfR[45]-0.3423265984407287*JfR[44]+0.3423265984407287*JfR[43]+0.19764235376052364*JfR[42]+0.34232659844072866*JfR[41]+0.19764235376052364*JfR[40]-0.34232659844072866*JfR[39]-0.19764235376052364*JfR[38]-0.34232659844072866*JfR[37]-0.19764235376052366*JfR[36]+0.19764235376052366*JfR[35]+0.3423265984407287*JfR[34]+0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*JfR[27]+0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]-0.3061862178478971*JfR[16]-0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]+0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[4] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[15])+0.6123724356957944*speedsR[14]+0.3535533905932737*speedsR[13]+0.6123724356957944*speedsR[12]-0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]-0.3535533905932737*speedsR[9]+0.3535533905932737*speedsR[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]-0.27386127875258304*JfL[46]+0.15811388300841892*JfL[45]-0.27386127875258304*JfL[44]+0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]+0.273861278752583*JfL[41]-0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]+0.15811388300841892*JfL[38]-0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]-0.41079191812887433*JfL[30]+0.2371708245126284*JfL[29]-0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]+0.41079191812887433*JfL[24]-0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]-0.41079191812887433*JfL[19]+0.2371708245126284*JfL[18]-0.41079191812887433*JfL[17]+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]-0.2371708245126284*JfL[11]+0.41079191812887433*JfL[10]-0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.27386127875258304*JfR[46]+0.15811388300841892*JfR[45]+0.27386127875258304*JfR[44]-0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]-0.273861278752583*JfR[41]-0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]+0.15811388300841892*JfR[38]+0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.41079191812887433*JfR[30]+0.2371708245126284*JfR[29]+0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]-0.41079191812887433*JfR[24]-0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]+0.41079191812887433*JfR[19]+0.2371708245126284*JfR[18]+0.41079191812887433*JfR[17]-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]-0.2371708245126284*JfR[11]-0.41079191812887433*JfR[10]-0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[5] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[1].bmag; + Jc_quad = gkdgs[1].Jc; + B3_quad = gkdgs[1].B3; + normcurlbhat_quad = gkdgs[1].normcurlbhat; + bhat_quad[0] = gkdgs[1].bhat.x[0]; + bhat_quad[1] = gkdgs[1].bhat.x[1]; + bhat_quad[2] = gkdgs[1].bhat.x[2]; + area_elem_quad = dgs[1].area_elem; + + + alpha_quad = 0.6123724356957944*speedsR[15]-0.6123724356957944*speedsR[14]-0.3535533905932737*speedsR[13]+0.6123724356957944*speedsR[12]+0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]-0.3535533905932737*speedsR[9]+0.3535533905932737*speedsR[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]-0.27386127875258304*JfL[46]+0.15811388300841892*JfL[45]+0.27386127875258304*JfL[44]-0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]-0.273861278752583*JfL[41]+0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]-0.15811388300841892*JfL[38]-0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]+0.41079191812887433*JfL[30]-0.2371708245126284*JfL[29]-0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]+0.41079191812887433*JfL[24]-0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]-0.41079191812887433*JfL[19]+0.2371708245126284*JfL[18]+0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]-0.2371708245126284*JfL[11]-0.41079191812887433*JfL[10]+0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.27386127875258304*JfR[46]+0.15811388300841892*JfR[45]-0.27386127875258304*JfR[44]+0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]+0.273861278752583*JfR[41]+0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]-0.15811388300841892*JfR[38]+0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.41079191812887433*JfR[30]-0.2371708245126284*JfR[29]+0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]-0.41079191812887433*JfR[24]-0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]+0.41079191812887433*JfR[19]+0.2371708245126284*JfR[18]-0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]-0.2371708245126284*JfR[11]+0.41079191812887433*JfR[10]+0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[6] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[15]-0.6123724356957944*speedsR[14]-0.3535533905932737*speedsR[13]+0.6123724356957944*speedsR[12]+0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]-0.3535533905932737*speedsR[9]+0.3535533905932737*speedsR[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])+0.3423265984407287*JfL[46]-0.19764235376052366*JfL[45]-0.3423265984407287*JfL[44]+0.3423265984407287*JfL[43]+0.19764235376052364*JfL[42]+0.34232659844072866*JfL[41]-0.19764235376052364*JfL[40]-0.34232659844072866*JfL[39]+0.19764235376052364*JfL[38]+0.34232659844072866*JfL[37]+0.19764235376052366*JfL[36]-0.19764235376052366*JfL[35]-0.3423265984407287*JfL[34]+0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*JfL[27]-0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]-0.3061862178478971*JfL[16]-0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]+0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.34232659844072866*JfR[47]-0.3423265984407287*JfR[46]-0.19764235376052366*JfR[45]+0.3423265984407287*JfR[44]-0.3423265984407287*JfR[43]+0.19764235376052364*JfR[42]-0.34232659844072866*JfR[41]-0.19764235376052364*JfR[40]+0.34232659844072866*JfR[39]+0.19764235376052364*JfR[38]-0.34232659844072866*JfR[37]+0.19764235376052366*JfR[36]-0.19764235376052366*JfR[35]+0.3423265984407287*JfR[34]+0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*JfR[27]+0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]+0.3061862178478971*JfR[16]-0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]-0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[7] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[15]-0.6123724356957944*speedsR[14]-0.3535533905932737*speedsR[13]+0.6123724356957944*speedsR[12]+0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]-0.3535533905932737*speedsR[9]+0.3535533905932737*speedsR[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]-0.27386127875258304*JfL[46]+0.15811388300841892*JfL[45]+0.27386127875258304*JfL[44]-0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]-0.273861278752583*JfL[41]+0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]-0.15811388300841892*JfL[38]-0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]-0.41079191812887433*JfL[30]+0.2371708245126284*JfL[29]+0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]-0.41079191812887433*JfL[24]+0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]+0.41079191812887433*JfL[19]-0.2371708245126284*JfL[18]-0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]+0.2371708245126284*JfL[11]+0.41079191812887433*JfL[10]-0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.27386127875258304*JfR[46]+0.15811388300841892*JfR[45]-0.27386127875258304*JfR[44]+0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]+0.273861278752583*JfR[41]+0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]-0.15811388300841892*JfR[38]+0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.41079191812887433*JfR[30]+0.2371708245126284*JfR[29]-0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]+0.41079191812887433*JfR[24]+0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]-0.41079191812887433*JfR[19]-0.2371708245126284*JfR[18]+0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]+0.2371708245126284*JfR[11]-0.41079191812887433*JfR[10]-0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[8] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[15]-0.6123724356957944*speedsR[14]-0.3535533905932737*speedsR[13]+0.6123724356957944*speedsR[12]+0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]-0.3535533905932737*speedsR[9]+0.3535533905932737*speedsR[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])+0.27386127875258304*JfL[46]-0.15811388300841892*JfL[45]-0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]+0.273861278752583*JfL[41]-0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]-0.15811388300841892*JfL[38]-0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]-0.41079191812887433*JfL[30]+0.2371708245126284*JfL[29]+0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]-0.41079191812887433*JfL[24]+0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]-0.41079191812887433*JfL[19]+0.2371708245126284*JfL[18]+0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]-0.2371708245126284*JfL[11]-0.41079191812887433*JfL[10]+0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.27386127875258304*JfR[46]-0.15811388300841892*JfR[45]+0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]-0.273861278752583*JfR[41]-0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]-0.15811388300841892*JfR[38]+0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.41079191812887433*JfR[30]+0.2371708245126284*JfR[29]-0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]+0.41079191812887433*JfR[24]+0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]+0.41079191812887433*JfR[19]+0.2371708245126284*JfR[18]-0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]-0.2371708245126284*JfR[11]+0.41079191812887433*JfR[10]+0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[9] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[15]-0.6123724356957944*speedsR[14]-0.3535533905932737*speedsR[13]+0.6123724356957944*speedsR[12]+0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]-0.3535533905932737*speedsR[9]+0.3535533905932737*speedsR[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]-0.3423265984407287*JfL[46]+0.19764235376052366*JfL[45]+0.3423265984407287*(JfL[44]+JfL[43])-0.19764235376052364*JfL[42]-0.34232659844072866*JfL[41]+0.19764235376052364*JfL[40]-0.34232659844072866*JfL[39]+0.19764235376052364*JfL[38]+0.34232659844072866*JfL[37]-0.19764235376052366*(JfL[36]+JfL[35])-0.3423265984407287*JfL[34]+0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*JfL[27]+0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]-0.3061862178478971*(JfL[20]+JfL[16])+0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]+0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*(JfL[5]+JfL[3])+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.34232659844072866*JfR[47])+0.3423265984407287*JfR[46]+0.19764235376052366*JfR[45]-0.3423265984407287*(JfR[44]+JfR[43])-0.19764235376052364*JfR[42]+0.34232659844072866*JfR[41]+0.19764235376052364*JfR[40]+0.34232659844072866*JfR[39]+0.19764235376052364*JfR[38]-0.34232659844072866*JfR[37]-0.19764235376052366*(JfR[36]+JfR[35])+0.3423265984407287*JfR[34]+0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*JfR[27]-0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]+0.3061862178478971*(JfR[20]+JfR[16])+0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]-0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*(JfR[5]+JfR[3])-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[10] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[15]-0.6123724356957944*speedsR[14]-0.3535533905932737*speedsR[13]+0.6123724356957944*speedsR[12]+0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]-0.3535533905932737*speedsR[9]+0.3535533905932737*speedsR[8]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])+0.27386127875258304*JfL[46]-0.15811388300841892*JfL[45]-0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]+0.273861278752583*JfL[41]-0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]-0.15811388300841892*JfL[38]-0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]+0.41079191812887433*JfL[30]-0.2371708245126284*JfL[29]-0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]+0.41079191812887433*JfL[24]-0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]+0.41079191812887433*JfL[19]-0.2371708245126284*JfL[18]-0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]+0.2371708245126284*JfL[11]+0.41079191812887433*JfL[10]-0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]-0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.27386127875258304*JfR[46]-0.15811388300841892*JfR[45]+0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]-0.273861278752583*JfR[41]-0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]-0.15811388300841892*JfR[38]+0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.41079191812887433*JfR[30]-0.2371708245126284*JfR[29]+0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]-0.41079191812887433*JfR[24]-0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]-0.41079191812887433*JfR[19]-0.2371708245126284*JfR[18]+0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]+0.2371708245126284*JfR[11]-0.41079191812887433*JfR[10]-0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]+0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[11] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[2].bmag; + Jc_quad = gkdgs[2].Jc; + B3_quad = gkdgs[2].B3; + normcurlbhat_quad = gkdgs[2].normcurlbhat; + bhat_quad[0] = gkdgs[2].bhat.x[0]; + bhat_quad[1] = gkdgs[2].bhat.x[1]; + bhat_quad[2] = gkdgs[2].bhat.x[2]; + area_elem_quad = dgs[2].area_elem; + + + alpha_quad = 0.6123724356957944*(speedsR[15]+speedsR[14])-0.3535533905932737*speedsR[13]-0.6123724356957944*speedsR[12]-0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]+0.3535533905932737*(speedsR[9]+speedsR[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.27386127875258304*JfL[46]+0.15811388300841892*JfL[45]-0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]-0.273861278752583*JfL[41]-0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]-0.15811388300841892*JfL[38]+0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*(JfL[31]+JfL[30])-0.2371708245126284*JfL[29]+0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]+0.41079191812887433*JfL[24]+0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]+0.41079191812887433*JfL[19]+0.2371708245126284*JfL[18]-0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]+0.2371708245126284*JfL[11]-0.41079191812887433*JfL[10]-0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])-0.27386127875258304*JfR[46]+0.15811388300841892*JfR[45]+0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]+0.273861278752583*JfR[41]-0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]-0.15811388300841892*JfR[38]-0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*(JfR[31]+JfR[30])-0.2371708245126284*JfR[29]-0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]-0.41079191812887433*JfR[24]+0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]-0.41079191812887433*JfR[19]+0.2371708245126284*JfR[18]+0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]+0.2371708245126284*JfR[11]+0.41079191812887433*JfR[10]-0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[12] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsR[15]+speedsR[14])-0.3535533905932737*speedsR[13]-0.6123724356957944*speedsR[12]-0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]+0.3535533905932737*(speedsR[9]+speedsR[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])-0.3423265984407287*JfL[46]-0.19764235376052366*JfL[45]+0.3423265984407287*(JfL[44]+JfL[43])-0.19764235376052364*JfL[42]+0.34232659844072866*JfL[41]+0.19764235376052364*JfL[40]+0.34232659844072866*JfL[39]+0.19764235376052364*JfL[38]-0.34232659844072866*JfL[37]+0.19764235376052366*(JfL[36]+JfL[35])-0.3423265984407287*JfL[34]-0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*(JfL[27]+JfL[22])+0.1767766952966368*JfL[21]-0.3061862178478971*(JfL[20]+JfL[16])+0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]-0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*(JfL[5]+JfL[3])+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.34232659844072866*JfR[47]+0.3423265984407287*JfR[46]-0.19764235376052366*JfR[45]-0.3423265984407287*(JfR[44]+JfR[43])-0.19764235376052364*JfR[42]-0.34232659844072866*JfR[41]+0.19764235376052364*JfR[40]-0.34232659844072866*JfR[39]+0.19764235376052364*JfR[38]+0.34232659844072866*JfR[37]+0.19764235376052366*(JfR[36]+JfR[35])+0.3423265984407287*JfR[34]-0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*(JfR[27]+JfR[22])+0.1767766952966368*JfR[21]+0.3061862178478971*(JfR[20]+JfR[16])+0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]+0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*(JfR[5]+JfR[3])-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[13] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsR[15]+speedsR[14])-0.3535533905932737*speedsR[13]-0.6123724356957944*speedsR[12]-0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]+0.3535533905932737*(speedsR[9]+speedsR[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.27386127875258304*JfL[46]+0.15811388300841892*JfL[45]-0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]-0.273861278752583*JfL[41]-0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]-0.15811388300841892*JfL[38]+0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*(JfL[31]+JfL[30])+0.2371708245126284*JfL[29]-0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]-0.41079191812887433*JfL[24]-0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]-0.41079191812887433*JfL[19]-0.2371708245126284*JfL[18]+0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]-0.2371708245126284*JfL[11]+0.41079191812887433*JfL[10]+0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])-0.27386127875258304*JfR[46]+0.15811388300841892*JfR[45]+0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]+0.273861278752583*JfR[41]-0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]-0.15811388300841892*JfR[38]-0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*(JfR[31]+JfR[30])+0.2371708245126284*JfR[29]+0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]+0.41079191812887433*JfR[24]-0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]+0.41079191812887433*JfR[19]-0.2371708245126284*JfR[18]-0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]-0.2371708245126284*JfR[11]-0.41079191812887433*JfR[10]+0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[14] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsR[15]+speedsR[14])-0.3535533905932737*speedsR[13]-0.6123724356957944*speedsR[12]-0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]+0.3535533905932737*(speedsR[9]+speedsR[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.27386127875258304*JfL[46]-0.15811388300841892*JfL[45]+0.27386127875258304*JfL[44]-0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]+0.273861278752583*JfL[41]+0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]-0.15811388300841892*JfL[38]+0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*(JfL[31]+JfL[30])+0.2371708245126284*JfL[29]-0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]-0.41079191812887433*JfL[24]-0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]+0.41079191812887433*JfL[19]+0.2371708245126284*JfL[18]-0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]+0.2371708245126284*JfL[11]-0.41079191812887433*JfL[10]-0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.273861278752583*JfR[47]+0.27386127875258304*JfR[46]-0.15811388300841892*JfR[45]-0.27386127875258304*JfR[44]+0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]-0.273861278752583*JfR[41]+0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]-0.15811388300841892*JfR[38]-0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*(JfR[31]+JfR[30])+0.2371708245126284*JfR[29]+0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]+0.41079191812887433*JfR[24]-0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]-0.41079191812887433*JfR[19]+0.2371708245126284*JfR[18]+0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]+0.2371708245126284*JfR[11]+0.41079191812887433*JfR[10]-0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[15] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsR[15]+speedsR[14])-0.3535533905932737*speedsR[13]-0.6123724356957944*speedsR[12]-0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]+0.3535533905932737*(speedsR[9]+speedsR[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]+0.3423265984407287*JfL[46]+0.19764235376052366*JfL[45]-0.3423265984407287*JfL[44]+0.3423265984407287*JfL[43]+0.19764235376052364*JfL[42]-0.34232659844072866*JfL[41]-0.19764235376052364*JfL[40]+0.34232659844072866*JfL[39]+0.19764235376052364*JfL[38]-0.34232659844072866*JfL[37]-0.19764235376052366*JfL[36]+0.19764235376052366*JfL[35]-0.3423265984407287*JfL[34]-0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*(JfL[27]+JfL[22])-0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]-0.3061862178478971*JfL[16]-0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]-0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.34232659844072866*JfR[47])-0.3423265984407287*JfR[46]+0.19764235376052366*JfR[45]+0.3423265984407287*JfR[44]-0.3423265984407287*JfR[43]+0.19764235376052364*JfR[42]+0.34232659844072866*JfR[41]-0.19764235376052364*JfR[40]-0.34232659844072866*JfR[39]+0.19764235376052364*JfR[38]+0.34232659844072866*JfR[37]-0.19764235376052366*JfR[36]+0.19764235376052366*JfR[35]+0.3423265984407287*JfR[34]-0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*(JfR[27]+JfR[22])-0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]+0.3061862178478971*JfR[16]-0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]+0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[16] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsR[15]+speedsR[14])-0.3535533905932737*speedsR[13]-0.6123724356957944*speedsR[12]-0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]+0.3535533905932737*(speedsR[9]+speedsR[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.27386127875258304*JfL[46]-0.15811388300841892*JfL[45]+0.27386127875258304*JfL[44]-0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]+0.273861278752583*JfL[41]+0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]-0.15811388300841892*JfL[38]+0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]-0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*(JfL[31]+JfL[30])-0.2371708245126284*JfL[29]+0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]+0.41079191812887433*JfL[24]+0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]-0.41079191812887433*JfL[19]-0.2371708245126284*JfL[18]+0.41079191812887433*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]-0.2371708245126284*JfL[11]+0.41079191812887433*JfL[10]+0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]-0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]-0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.273861278752583*JfR[47]+0.27386127875258304*JfR[46]-0.15811388300841892*JfR[45]-0.27386127875258304*JfR[44]+0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]-0.273861278752583*JfR[41]+0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]-0.15811388300841892*JfR[38]-0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]-0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*(JfR[31]+JfR[30])-0.2371708245126284*JfR[29]-0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]-0.41079191812887433*JfR[24]+0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]+0.41079191812887433*JfR[19]-0.2371708245126284*JfR[18]-0.41079191812887433*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]-0.2371708245126284*JfR[11]-0.41079191812887433*JfR[10]+0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]-0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[17] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[3].bmag; + Jc_quad = gkdgs[3].Jc; + B3_quad = gkdgs[3].B3; + normcurlbhat_quad = gkdgs[3].normcurlbhat; + bhat_quad[0] = gkdgs[3].bhat.x[0]; + bhat_quad[1] = gkdgs[3].bhat.x[1]; + bhat_quad[2] = gkdgs[3].bhat.x[2]; + area_elem_quad = dgs[3].area_elem; + + + alpha_quad = -(0.6123724356957944*(speedsR[15]+speedsR[14]))+0.3535533905932737*speedsR[13]-0.6123724356957944*speedsR[12]+0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]+0.3535533905932737*(speedsR[9]+speedsR[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.27386127875258304*JfL[46]-0.15811388300841892*JfL[45]-0.27386127875258304*JfL[44]+0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]-0.273861278752583*JfL[41]-0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]+0.15811388300841892*JfL[38]+0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*(JfL[31]+JfL[30])+0.2371708245126284*JfL[29]+0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]+0.41079191812887433*JfL[24]+0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]-0.41079191812887433*JfL[19]-0.2371708245126284*JfL[18]-0.41079191812887433*JfL[17]+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]-0.2371708245126284*JfL[11]-0.41079191812887433*JfL[10]-0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.273861278752583*JfR[47]+0.27386127875258304*JfR[46]-0.15811388300841892*JfR[45]+0.27386127875258304*JfR[44]-0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]+0.273861278752583*JfR[41]-0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]+0.15811388300841892*JfR[38]-0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*(JfR[31]+JfR[30])+0.2371708245126284*JfR[29]-0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]-0.41079191812887433*JfR[24]+0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]+0.41079191812887433*JfR[19]-0.2371708245126284*JfR[18]+0.41079191812887433*JfR[17]-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]-0.2371708245126284*JfR[11]+0.41079191812887433*JfR[10]-0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[18] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsR[15]+speedsR[14]))+0.3535533905932737*speedsR[13]-0.6123724356957944*speedsR[12]+0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]+0.3535533905932737*(speedsR[9]+speedsR[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]+0.3423265984407287*JfL[46]+0.19764235376052366*JfL[45]+0.3423265984407287*JfL[44]-0.3423265984407287*JfL[43]+0.19764235376052364*JfL[42]+0.34232659844072866*JfL[41]+0.19764235376052364*JfL[40]-0.34232659844072866*JfL[39]-0.19764235376052364*JfL[38]-0.34232659844072866*JfL[37]+0.19764235376052366*JfL[36]-0.19764235376052366*JfL[35]-0.3423265984407287*JfL[34]-0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*(JfL[27]+JfL[22])-0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]+0.3061862178478971*JfL[16]-0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]+0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.34232659844072866*JfR[47])-0.3423265984407287*JfR[46]+0.19764235376052366*JfR[45]-0.3423265984407287*JfR[44]+0.3423265984407287*JfR[43]+0.19764235376052364*JfR[42]-0.34232659844072866*JfR[41]+0.19764235376052364*JfR[40]+0.34232659844072866*JfR[39]-0.19764235376052364*JfR[38]+0.34232659844072866*JfR[37]+0.19764235376052366*JfR[36]-0.19764235376052366*JfR[35]+0.3423265984407287*JfR[34]-0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*(JfR[27]+JfR[22])-0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]-0.3061862178478971*JfR[16]-0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]-0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[19] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsR[15]+speedsR[14]))+0.3535533905932737*speedsR[13]-0.6123724356957944*speedsR[12]+0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]+0.3535533905932737*(speedsR[9]+speedsR[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.27386127875258304*JfL[46]-0.15811388300841892*JfL[45]-0.27386127875258304*JfL[44]+0.27386127875258304*JfL[43]-0.15811388300841892*JfL[42]-0.273861278752583*JfL[41]-0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]+0.15811388300841892*JfL[38]+0.273861278752583*JfL[37]-0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*(JfL[31]+JfL[30])-0.2371708245126284*JfL[29]-0.41079191812887433*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]-0.41079191812887433*JfL[24]-0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]-0.1767766952966368*JfL[21]-0.3061862178478971*JfL[20]+0.41079191812887433*JfL[19]+0.2371708245126284*JfL[18]+0.41079191812887433*JfL[17]+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.1767766952966368*JfL[14]-0.3061862178478971*JfL[13]-0.1767766952966368*JfL[12]+0.2371708245126284*JfL[11]+0.41079191812887433*JfL[10]+0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.273861278752583*JfR[47]+0.27386127875258304*JfR[46]-0.15811388300841892*JfR[45]+0.27386127875258304*JfR[44]-0.27386127875258304*JfR[43]-0.15811388300841892*JfR[42]+0.273861278752583*JfR[41]-0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]+0.15811388300841892*JfR[38]-0.273861278752583*JfR[37]-0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*(JfR[31]+JfR[30])-0.2371708245126284*JfR[29]+0.41079191812887433*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]+0.41079191812887433*JfR[24]-0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]-0.1767766952966368*JfR[21]+0.3061862178478971*JfR[20]-0.41079191812887433*JfR[19]+0.2371708245126284*JfR[18]-0.41079191812887433*JfR[17]-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.1767766952966368*JfR[14]+0.3061862178478971*JfR[13]-0.1767766952966368*JfR[12]+0.2371708245126284*JfR[11]-0.41079191812887433*JfR[10]+0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[20] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsR[15]+speedsR[14]))+0.3535533905932737*speedsR[13]-0.6123724356957944*speedsR[12]+0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]+0.3535533905932737*(speedsR[9]+speedsR[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.27386127875258304*JfL[46]+0.15811388300841892*JfL[45]+0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]+0.273861278752583*JfL[41]+0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]+0.15811388300841892*JfL[38]+0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*(JfL[31]+JfL[30])-0.2371708245126284*JfL[29]-0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]-0.2371708245126284*JfL[25]-0.41079191812887433*JfL[24]-0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]-0.41079191812887433*JfL[19]-0.2371708245126284*JfL[18]-0.41079191812887433*JfL[17]+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]-0.2371708245126284*JfL[11]-0.41079191812887433*JfL[10]-0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])-0.27386127875258304*JfR[46]+0.15811388300841892*JfR[45]-0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]-0.273861278752583*JfR[41]+0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]+0.15811388300841892*JfR[38]-0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*(JfR[31]+JfR[30])-0.2371708245126284*JfR[29]+0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.2371708245126284*JfR[25]+0.41079191812887433*JfR[24]-0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]+0.41079191812887433*JfR[19]-0.2371708245126284*JfR[18]+0.41079191812887433*JfR[17]-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]-0.2371708245126284*JfR[11]+0.41079191812887433*JfR[10]-0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[21] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsR[15]+speedsR[14]))+0.3535533905932737*speedsR[13]-0.6123724356957944*speedsR[12]+0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]+0.3535533905932737*(speedsR[9]+speedsR[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])-0.3423265984407287*JfL[46]-0.19764235376052366*JfL[45]-0.3423265984407287*(JfL[44]+JfL[43])-0.19764235376052364*JfL[42]-0.34232659844072866*JfL[41]-0.19764235376052364*JfL[40]-0.34232659844072866*JfL[39]-0.19764235376052364*JfL[38]-0.34232659844072866*JfL[37]-0.19764235376052366*(JfL[36]+JfL[35])-0.3423265984407287*JfL[34]-0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*(JfL[27]+JfL[22])+0.1767766952966368*JfL[21]+0.3061862178478971*(JfL[20]+JfL[16])+0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]+0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*(JfL[5]+JfL[3])+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.34232659844072866*JfR[47]+0.3423265984407287*JfR[46]-0.19764235376052366*JfR[45]+0.3423265984407287*(JfR[44]+JfR[43])-0.19764235376052364*JfR[42]+0.34232659844072866*JfR[41]-0.19764235376052364*JfR[40]+0.34232659844072866*JfR[39]-0.19764235376052364*JfR[38]+0.34232659844072866*JfR[37]-0.19764235376052366*(JfR[36]+JfR[35])+0.3423265984407287*JfR[34]-0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*(JfR[27]+JfR[22])+0.1767766952966368*JfR[21]-0.3061862178478971*(JfR[20]+JfR[16])+0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]-0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*(JfR[5]+JfR[3])-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[22] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsR[15]+speedsR[14]))+0.3535533905932737*speedsR[13]-0.6123724356957944*speedsR[12]+0.3535533905932737*speedsR[11]-0.6123724356957944*speedsR[10]+0.3535533905932737*(speedsR[9]+speedsR[8]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.27386127875258304*JfL[46]+0.15811388300841892*JfL[45]+0.27386127875258304*(JfL[44]+JfL[43])+0.15811388300841892*JfL[42]+0.273861278752583*JfL[41]+0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]+0.15811388300841892*JfL[38]+0.273861278752583*JfL[37]+0.15811388300841892*JfL[36]+0.15811388300841894*JfL[35]+0.27386127875258304*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*(JfL[31]+JfL[30])+0.2371708245126284*JfL[29]+0.41079191812887433*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]+0.2371708245126284*JfL[25]+0.41079191812887433*JfL[24]+0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]+0.1767766952966368*JfL[21]+0.3061862178478971*JfL[20]+0.41079191812887433*JfL[19]+0.2371708245126284*JfL[18]+0.41079191812887433*JfL[17]+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.1767766952966368*JfL[14]+0.3061862178478971*JfL[13]+0.1767766952966368*JfL[12]+0.2371708245126284*JfL[11]+0.41079191812887433*JfL[10]+0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]+0.1767766952966368*JfL[7]+0.3061862178478971*JfL[6]+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.1767766952966368*JfL[3]+0.3061862178478971*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])-0.27386127875258304*JfR[46]+0.15811388300841892*JfR[45]-0.27386127875258304*(JfR[44]+JfR[43])+0.15811388300841892*JfR[42]-0.273861278752583*JfR[41]+0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]+0.15811388300841892*JfR[38]-0.273861278752583*JfR[37]+0.15811388300841892*JfR[36]+0.15811388300841894*JfR[35]-0.27386127875258304*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*(JfR[31]+JfR[30])+0.2371708245126284*JfR[29]-0.41079191812887433*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.2371708245126284*JfR[25]-0.41079191812887433*JfR[24]+0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]+0.1767766952966368*JfR[21]-0.3061862178478971*JfR[20]-0.41079191812887433*JfR[19]+0.2371708245126284*JfR[18]-0.41079191812887433*JfR[17]-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.1767766952966368*JfR[14]-0.3061862178478971*JfR[13]+0.1767766952966368*JfR[12]+0.2371708245126284*JfR[11]-0.41079191812887433*JfR[10]+0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]+0.1767766952966368*JfR[7]-0.3061862178478971*JfR[6]+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]+0.1767766952966368*JfR[3]-0.3061862178478971*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[23] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdy2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfz_3x2v_ser_p1.c b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfz_3x2v_ser_p1.c new file mode 100644 index 0000000000..159579868d --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfz_3x2v_ser_p1.c @@ -0,0 +1,303 @@ +#include +GKYL_CU_DH double gk_collisionless_passive_flux_surfz_3x2v_ser_p1( + const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, + const double *JfL, const double *JfR, double* GKYL_RESTRICT flux_surf) +{ + // w[NDIM]: cell-center. + // dxv[NDIM]: cell length. + // vmap: velocity space mapping. + // vmapSq: velocity space mapping squared. + // dgs: surface DG geometry. + // gkdgs: gyrokinetic surface DG geometry. + // bmag: bmag represented on the surface. + // jacobgeo_rat_surfL: Ratio of surface conf-space Jacobians in left cell. + // jacobgeo_rat_surfR: Ratio of surface conf-space Jacobians in right cell. + // speedsL: characteristic speeds in left cell. + // speedsR: characteristic speeds in right cell. + // JfL: distribution times total jacobian in left cell. + // JfR: distribution times total jacobian in right cell. + // flux_surf: output surface phase space flux in each direction (cdim + 1 components). + // Note: Each cell owns their *lower* edge surface evaluation. + + double rdx2 = 2.0/dxv[0]; + double rdy2 = 2.0/dxv[1]; + double rdz2 = 2.0/dxv[2]; + double rdvpar2 = 2.0/dxv[3]; + + double *flux_surf_nodal = &flux_surf[48]; + double cfl = 0.0; + double bmag_quad = 0.0; + double Jc_quad = 0.0; + double B3_quad = 0.0; + double normcurlbhat_quad = 0.0; + double area_elem_quad = 0.0; + double bhat_quad[3] = {0.0}; + double alpha_quad = 0.0; + double JfL_quad = 0.0; + double JfR_quad = 0.0; + double Jfavg_quad = 0.0; + double Jfjump_quad = 0.0; + bmag_quad = gkdgs[0].bmag; + Jc_quad = gkdgs[0].Jc; + B3_quad = gkdgs[0].B3; + normcurlbhat_quad = gkdgs[0].normcurlbhat; + bhat_quad[0] = gkdgs[0].bhat.x[0]; + bhat_quad[1] = gkdgs[0].bhat.x[1]; + bhat_quad[2] = gkdgs[0].bhat.x[2]; + area_elem_quad = dgs[0].area_elem; + + + alpha_quad = -(0.6123724356957944*speedsR[23])+0.6123724356957944*(speedsR[22]+speedsR[21])+0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]-0.3535533905932737*(speedsR[18]+speedsR[17])+0.3535533905932737*speedsR[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])+0.27386127875258304*(JfL[46]+JfL[45])-0.15811388300841892*JfL[44]+0.27386127875258304*JfL[43]-0.273861278752583*JfL[42]+0.15811388300841892*(JfL[41]+JfL[40])-0.273861278752583*(JfL[39]+JfL[38])+0.15811388300841892*JfL[37]-0.15811388300841892*JfL[36]+0.27386127875258304*JfL[35]-0.15811388300841894*(JfL[34]+JfL[33])+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]-0.41079191812887433*(JfL[30]+JfL[29])+0.2371708245126284*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.41079191812887433*JfL[25]-0.2371708245126284*(JfL[24]+JfL[23])+0.3061862178478971*(JfL[22]+JfL[21])-0.1767766952966368*JfL[20]+0.41079191812887433*(JfL[19]+JfL[18])-0.2371708245126284*JfL[17]+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.3061862178478971*JfL[14]+0.1767766952966368*(JfL[13]+JfL[12])-0.41079191812887433*JfL[11]+0.2371708245126284*(JfL[10]+JfL[9])-0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*JfL[6]-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]-0.1767766952966368*(JfL[2]+JfL[1])+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.27386127875258304*(JfR[46]+JfR[45])-0.15811388300841892*JfR[44]-0.27386127875258304*JfR[43]+0.273861278752583*JfR[42]+0.15811388300841892*(JfR[41]+JfR[40])+0.273861278752583*(JfR[39]+JfR[38])+0.15811388300841892*JfR[37]-0.15811388300841892*JfR[36]-0.27386127875258304*JfR[35]-0.15811388300841894*(JfR[34]+JfR[33])+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.41079191812887433*(JfR[30]+JfR[29])+0.2371708245126284*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.41079191812887433*JfR[25]-0.2371708245126284*(JfR[24]+JfR[23])-0.3061862178478971*(JfR[22]+JfR[21])-0.1767766952966368*JfR[20]-0.41079191812887433*(JfR[19]+JfR[18])-0.2371708245126284*JfR[17]-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.3061862178478971*JfR[14]+0.1767766952966368*(JfR[13]+JfR[12])+0.41079191812887433*JfR[11]+0.2371708245126284*(JfR[10]+JfR[9])+0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*JfR[6]-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]-0.1767766952966368*(JfR[2]+JfR[1])+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[0] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[23])+0.6123724356957944*(speedsR[22]+speedsR[21])+0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]-0.3535533905932737*(speedsR[18]+speedsR[17])+0.3535533905932737*speedsR[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]-0.3423265984407287*(JfL[46]+JfL[45])+0.19764235376052366*JfL[44]-0.3423265984407287*JfL[43]+0.34232659844072866*JfL[42]-0.19764235376052364*(JfL[41]+JfL[40])+0.34232659844072866*(JfL[39]+JfL[38])-0.19764235376052364*JfL[37]+0.19764235376052366*JfL[36]-0.3423265984407287*JfL[35]+0.19764235376052366*(JfL[34]+JfL[33])-0.19764235376052364*JfL[32]-0.3061862178478971*JfL[27]+0.3061862178478971*(JfL[22]+JfL[21])-0.1767766952966368*JfL[20]+0.3061862178478971*JfL[16]-0.3061862178478971*JfL[14]+0.1767766952966368*(JfL[13]+JfL[12])-0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*JfL[6]-0.1767766952966368*JfL[5]+0.3061862178478971*JfL[3]-0.1767766952966368*(JfL[2]+JfL[1])+0.1767766952966368*JfL[0]; + JfR_quad = -(0.34232659844072866*JfR[47])+0.3423265984407287*(JfR[46]+JfR[45])+0.19764235376052366*JfR[44]+0.3423265984407287*JfR[43]-0.34232659844072866*JfR[42]-0.19764235376052364*(JfR[41]+JfR[40])-0.34232659844072866*(JfR[39]+JfR[38])-0.19764235376052364*JfR[37]+0.19764235376052366*JfR[36]+0.3423265984407287*JfR[35]+0.19764235376052366*(JfR[34]+JfR[33])-0.19764235376052364*JfR[32]+0.3061862178478971*JfR[27]-0.3061862178478971*(JfR[22]+JfR[21])-0.1767766952966368*JfR[20]-0.3061862178478971*JfR[16]+0.3061862178478971*JfR[14]+0.1767766952966368*(JfR[13]+JfR[12])+0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*JfR[6]-0.1767766952966368*JfR[5]-0.3061862178478971*JfR[3]-0.1767766952966368*(JfR[2]+JfR[1])+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[1] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[23])+0.6123724356957944*(speedsR[22]+speedsR[21])+0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]-0.3535533905932737*(speedsR[18]+speedsR[17])+0.3535533905932737*speedsR[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])+0.27386127875258304*(JfL[46]+JfL[45])-0.15811388300841892*JfL[44]+0.27386127875258304*JfL[43]-0.273861278752583*JfL[42]+0.15811388300841892*(JfL[41]+JfL[40])-0.273861278752583*(JfL[39]+JfL[38])+0.15811388300841892*JfL[37]-0.15811388300841892*JfL[36]+0.27386127875258304*JfL[35]-0.15811388300841894*(JfL[34]+JfL[33])+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]+0.41079191812887433*(JfL[30]+JfL[29])-0.2371708245126284*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.41079191812887433*JfL[25]+0.2371708245126284*(JfL[24]+JfL[23])+0.3061862178478971*(JfL[22]+JfL[21])-0.1767766952966368*JfL[20]-0.41079191812887433*(JfL[19]+JfL[18])+0.2371708245126284*JfL[17]+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.3061862178478971*JfL[14]+0.1767766952966368*(JfL[13]+JfL[12])+0.41079191812887433*JfL[11]-0.2371708245126284*(JfL[10]+JfL[9])-0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*JfL[6]-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]-0.1767766952966368*(JfL[2]+JfL[1])+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.27386127875258304*(JfR[46]+JfR[45])-0.15811388300841892*JfR[44]-0.27386127875258304*JfR[43]+0.273861278752583*JfR[42]+0.15811388300841892*(JfR[41]+JfR[40])+0.273861278752583*(JfR[39]+JfR[38])+0.15811388300841892*JfR[37]-0.15811388300841892*JfR[36]-0.27386127875258304*JfR[35]-0.15811388300841894*(JfR[34]+JfR[33])+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.41079191812887433*(JfR[30]+JfR[29])-0.2371708245126284*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.41079191812887433*JfR[25]+0.2371708245126284*(JfR[24]+JfR[23])-0.3061862178478971*(JfR[22]+JfR[21])-0.1767766952966368*JfR[20]+0.41079191812887433*(JfR[19]+JfR[18])+0.2371708245126284*JfR[17]-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.3061862178478971*JfR[14]+0.1767766952966368*(JfR[13]+JfR[12])-0.41079191812887433*JfR[11]-0.2371708245126284*(JfR[10]+JfR[9])+0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*JfR[6]-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]-0.1767766952966368*(JfR[2]+JfR[1])+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[2] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[23])+0.6123724356957944*(speedsR[22]+speedsR[21])+0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]-0.3535533905932737*(speedsR[18]+speedsR[17])+0.3535533905932737*speedsR[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]-0.27386127875258304*(JfL[46]+JfL[45])+0.15811388300841892*JfL[44]+0.27386127875258304*JfL[43]+0.273861278752583*JfL[42]-0.15811388300841892*(JfL[41]+JfL[40])-0.273861278752583*(JfL[39]+JfL[38])+0.15811388300841892*(JfL[37]+JfL[36])+0.27386127875258304*JfL[35]-0.15811388300841894*(JfL[34]+JfL[33])+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]+0.41079191812887433*(JfL[30]+JfL[29])-0.2371708245126284*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*(JfL[26]+JfL[25])+0.2371708245126284*(JfL[24]+JfL[23])-0.3061862178478971*(JfL[22]+JfL[21])+0.1767766952966368*JfL[20]+0.41079191812887433*(JfL[19]+JfL[18])-0.2371708245126284*JfL[17]+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.3061862178478971*JfL[14]-0.1767766952966368*(JfL[13]+JfL[12])-0.41079191812887433*JfL[11]+0.2371708245126284*(JfL[10]+JfL[9])-0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*(JfL[6]+JfL[5])-0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]-0.1767766952966368*(JfL[2]+JfL[1])+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.27386127875258304*(JfR[46]+JfR[45])+0.15811388300841892*JfR[44]-0.27386127875258304*JfR[43]-0.273861278752583*JfR[42]-0.15811388300841892*(JfR[41]+JfR[40])+0.273861278752583*(JfR[39]+JfR[38])+0.15811388300841892*(JfR[37]+JfR[36])-0.27386127875258304*JfR[35]-0.15811388300841894*(JfR[34]+JfR[33])+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.41079191812887433*(JfR[30]+JfR[29])-0.2371708245126284*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*(JfR[26]+JfR[25])+0.2371708245126284*(JfR[24]+JfR[23])+0.3061862178478971*(JfR[22]+JfR[21])+0.1767766952966368*JfR[20]-0.41079191812887433*(JfR[19]+JfR[18])-0.2371708245126284*JfR[17]-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.3061862178478971*JfR[14]-0.1767766952966368*(JfR[13]+JfR[12])+0.41079191812887433*JfR[11]+0.2371708245126284*(JfR[10]+JfR[9])+0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*(JfR[6]+JfR[5])-0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]-0.1767766952966368*(JfR[2]+JfR[1])+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[3] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[23])+0.6123724356957944*(speedsR[22]+speedsR[21])+0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]-0.3535533905932737*(speedsR[18]+speedsR[17])+0.3535533905932737*speedsR[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])+0.3423265984407287*(JfL[46]+JfL[45])-0.19764235376052366*JfL[44]-0.3423265984407287*JfL[43]-0.34232659844072866*JfL[42]+0.19764235376052364*(JfL[41]+JfL[40])+0.34232659844072866*(JfL[39]+JfL[38])-0.19764235376052364*JfL[37]-0.19764235376052366*JfL[36]-0.3423265984407287*JfL[35]+0.19764235376052366*(JfL[34]+JfL[33])-0.19764235376052364*JfL[32]+0.3061862178478971*JfL[27]-0.3061862178478971*(JfL[22]+JfL[21])+0.1767766952966368*JfL[20]+0.3061862178478971*(JfL[16]+JfL[14])-0.1767766952966368*(JfL[13]+JfL[12])-0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*(JfL[6]+JfL[5])+0.3061862178478971*JfL[3]-0.1767766952966368*(JfL[2]+JfL[1])+0.1767766952966368*JfL[0]; + JfR_quad = 0.34232659844072866*JfR[47]-0.3423265984407287*(JfR[46]+JfR[45])-0.19764235376052366*JfR[44]+0.3423265984407287*JfR[43]+0.34232659844072866*JfR[42]+0.19764235376052364*(JfR[41]+JfR[40])-0.34232659844072866*(JfR[39]+JfR[38])-0.19764235376052364*JfR[37]-0.19764235376052366*JfR[36]+0.3423265984407287*JfR[35]+0.19764235376052366*(JfR[34]+JfR[33])-0.19764235376052364*JfR[32]-0.3061862178478971*JfR[27]+0.3061862178478971*(JfR[22]+JfR[21])+0.1767766952966368*JfR[20]-0.3061862178478971*(JfR[16]+JfR[14])-0.1767766952966368*(JfR[13]+JfR[12])+0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*(JfR[6]+JfR[5])-0.3061862178478971*JfR[3]-0.1767766952966368*(JfR[2]+JfR[1])+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[4] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*speedsR[23])+0.6123724356957944*(speedsR[22]+speedsR[21])+0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]-0.3535533905932737*(speedsR[18]+speedsR[17])+0.3535533905932737*speedsR[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]-0.27386127875258304*(JfL[46]+JfL[45])+0.15811388300841892*JfL[44]+0.27386127875258304*JfL[43]+0.273861278752583*JfL[42]-0.15811388300841892*(JfL[41]+JfL[40])-0.273861278752583*(JfL[39]+JfL[38])+0.15811388300841892*(JfL[37]+JfL[36])+0.27386127875258304*JfL[35]-0.15811388300841894*(JfL[34]+JfL[33])+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]-0.41079191812887433*(JfL[30]+JfL[29])+0.2371708245126284*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*(JfL[26]+JfL[25])-0.2371708245126284*(JfL[24]+JfL[23])-0.3061862178478971*(JfL[22]+JfL[21])+0.1767766952966368*JfL[20]-0.41079191812887433*(JfL[19]+JfL[18])+0.2371708245126284*JfL[17]+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.3061862178478971*JfL[14]-0.1767766952966368*(JfL[13]+JfL[12])+0.41079191812887433*JfL[11]-0.2371708245126284*(JfL[10]+JfL[9])-0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*(JfL[6]+JfL[5])+0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]-0.1767766952966368*(JfL[2]+JfL[1])+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.27386127875258304*(JfR[46]+JfR[45])+0.15811388300841892*JfR[44]-0.27386127875258304*JfR[43]-0.273861278752583*JfR[42]-0.15811388300841892*(JfR[41]+JfR[40])+0.273861278752583*(JfR[39]+JfR[38])+0.15811388300841892*(JfR[37]+JfR[36])-0.27386127875258304*JfR[35]-0.15811388300841894*(JfR[34]+JfR[33])+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.41079191812887433*(JfR[30]+JfR[29])+0.2371708245126284*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*(JfR[26]+JfR[25])-0.2371708245126284*(JfR[24]+JfR[23])+0.3061862178478971*(JfR[22]+JfR[21])+0.1767766952966368*JfR[20]+0.41079191812887433*(JfR[19]+JfR[18])+0.2371708245126284*JfR[17]-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.3061862178478971*JfR[14]-0.1767766952966368*(JfR[13]+JfR[12])-0.41079191812887433*JfR[11]-0.2371708245126284*(JfR[10]+JfR[9])+0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*(JfR[6]+JfR[5])+0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]-0.1767766952966368*(JfR[2]+JfR[1])+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[5] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[1].bmag; + Jc_quad = gkdgs[1].Jc; + B3_quad = gkdgs[1].B3; + normcurlbhat_quad = gkdgs[1].normcurlbhat; + bhat_quad[0] = gkdgs[1].bhat.x[0]; + bhat_quad[1] = gkdgs[1].bhat.x[1]; + bhat_quad[2] = gkdgs[1].bhat.x[2]; + area_elem_quad = dgs[1].area_elem; + + + alpha_quad = 0.6123724356957944*speedsR[23]-0.6123724356957944*speedsR[22]+0.6123724356957944*speedsR[21]-0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]+0.3535533905932737*speedsR[18]-0.3535533905932737*speedsR[17]+0.3535533905932737*speedsR[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]-0.27386127875258304*JfL[46]+0.27386127875258304*JfL[45]+0.15811388300841892*JfL[44]-0.27386127875258304*JfL[43]-0.273861278752583*JfL[42]-0.15811388300841892*JfL[41]+0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]-0.273861278752583*JfL[38]-0.15811388300841892*(JfL[37]+JfL[36])+0.27386127875258304*JfL[35]+0.15811388300841894*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]+0.41079191812887433*JfL[30]-0.41079191812887433*JfL[29]-0.2371708245126284*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*(JfL[26]+JfL[25])+0.2371708245126284*JfL[24]-0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]+0.3061862178478971*JfL[21]+0.1767766952966368*JfL[20]-0.41079191812887433*JfL[19]+0.41079191812887433*JfL[18]+0.2371708245126284*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.3061862178478971*JfL[14]-0.1767766952966368*JfL[13]+0.1767766952966368*JfL[12]-0.41079191812887433*JfL[11]-0.2371708245126284*JfL[10]+0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]-0.3061862178478971*JfL[7]-0.1767766952966368*(JfL[6]+JfL[5])-0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]+0.1767766952966368*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.27386127875258304*JfR[46]-0.27386127875258304*JfR[45]+0.15811388300841892*JfR[44]+0.27386127875258304*JfR[43]+0.273861278752583*JfR[42]-0.15811388300841892*JfR[41]+0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]+0.273861278752583*JfR[38]-0.15811388300841892*(JfR[37]+JfR[36])-0.27386127875258304*JfR[35]+0.15811388300841894*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.41079191812887433*JfR[30]+0.41079191812887433*JfR[29]-0.2371708245126284*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*(JfR[26]+JfR[25])+0.2371708245126284*JfR[24]-0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]-0.3061862178478971*JfR[21]+0.1767766952966368*JfR[20]+0.41079191812887433*JfR[19]-0.41079191812887433*JfR[18]+0.2371708245126284*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.3061862178478971*JfR[14]-0.1767766952966368*JfR[13]+0.1767766952966368*JfR[12]+0.41079191812887433*JfR[11]-0.2371708245126284*JfR[10]+0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]+0.3061862178478971*JfR[7]-0.1767766952966368*(JfR[6]+JfR[5])-0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]+0.1767766952966368*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[6] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[23]-0.6123724356957944*speedsR[22]+0.6123724356957944*speedsR[21]-0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]+0.3535533905932737*speedsR[18]-0.3535533905932737*speedsR[17]+0.3535533905932737*speedsR[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])+0.3423265984407287*JfL[46]-0.3423265984407287*JfL[45]-0.19764235376052366*JfL[44]+0.3423265984407287*JfL[43]+0.34232659844072866*JfL[42]+0.19764235376052364*JfL[41]-0.19764235376052364*JfL[40]-0.34232659844072866*JfL[39]+0.34232659844072866*JfL[38]+0.19764235376052364*JfL[37]+0.19764235376052366*JfL[36]-0.3423265984407287*JfL[35]-0.19764235376052366*JfL[34]+0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*JfL[27]-0.3061862178478971*JfL[22]+0.3061862178478971*JfL[21]+0.1767766952966368*JfL[20]-0.3061862178478971*(JfL[16]+JfL[14])-0.1767766952966368*JfL[13]+0.1767766952966368*JfL[12]+0.3061862178478971*JfL[8]-0.3061862178478971*JfL[7]-0.1767766952966368*(JfL[6]+JfL[5])+0.3061862178478971*JfL[3]+0.1767766952966368*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.34232659844072866*JfR[47]-0.3423265984407287*JfR[46]+0.3423265984407287*JfR[45]-0.19764235376052366*JfR[44]-0.3423265984407287*JfR[43]-0.34232659844072866*JfR[42]+0.19764235376052364*JfR[41]-0.19764235376052364*JfR[40]+0.34232659844072866*JfR[39]-0.34232659844072866*JfR[38]+0.19764235376052364*JfR[37]+0.19764235376052366*JfR[36]+0.3423265984407287*JfR[35]-0.19764235376052366*JfR[34]+0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*JfR[27]+0.3061862178478971*JfR[22]-0.3061862178478971*JfR[21]+0.1767766952966368*JfR[20]+0.3061862178478971*(JfR[16]+JfR[14])-0.1767766952966368*JfR[13]+0.1767766952966368*JfR[12]-0.3061862178478971*JfR[8]+0.3061862178478971*JfR[7]-0.1767766952966368*(JfR[6]+JfR[5])-0.3061862178478971*JfR[3]+0.1767766952966368*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[7] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[23]-0.6123724356957944*speedsR[22]+0.6123724356957944*speedsR[21]-0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]+0.3535533905932737*speedsR[18]-0.3535533905932737*speedsR[17]+0.3535533905932737*speedsR[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]-0.27386127875258304*JfL[46]+0.27386127875258304*JfL[45]+0.15811388300841892*JfL[44]-0.27386127875258304*JfL[43]-0.273861278752583*JfL[42]-0.15811388300841892*JfL[41]+0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]-0.273861278752583*JfL[38]-0.15811388300841892*(JfL[37]+JfL[36])+0.27386127875258304*JfL[35]+0.15811388300841894*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]-0.41079191812887433*JfL[30]+0.41079191812887433*JfL[29]+0.2371708245126284*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*(JfL[26]+JfL[25])-0.2371708245126284*JfL[24]+0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]+0.3061862178478971*JfL[21]+0.1767766952966368*JfL[20]+0.41079191812887433*JfL[19]-0.41079191812887433*JfL[18]-0.2371708245126284*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.3061862178478971*JfL[14]-0.1767766952966368*JfL[13]+0.1767766952966368*JfL[12]+0.41079191812887433*JfL[11]+0.2371708245126284*JfL[10]-0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]-0.3061862178478971*JfL[7]-0.1767766952966368*(JfL[6]+JfL[5])+0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]+0.1767766952966368*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.273861278752583*JfR[47])+0.27386127875258304*JfR[46]-0.27386127875258304*JfR[45]+0.15811388300841892*JfR[44]+0.27386127875258304*JfR[43]+0.273861278752583*JfR[42]-0.15811388300841892*JfR[41]+0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]+0.273861278752583*JfR[38]-0.15811388300841892*(JfR[37]+JfR[36])-0.27386127875258304*JfR[35]+0.15811388300841894*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.41079191812887433*JfR[30]-0.41079191812887433*JfR[29]+0.2371708245126284*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*(JfR[26]+JfR[25])-0.2371708245126284*JfR[24]+0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]-0.3061862178478971*JfR[21]+0.1767766952966368*JfR[20]-0.41079191812887433*JfR[19]+0.41079191812887433*JfR[18]-0.2371708245126284*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.3061862178478971*JfR[14]-0.1767766952966368*JfR[13]+0.1767766952966368*JfR[12]-0.41079191812887433*JfR[11]+0.2371708245126284*JfR[10]-0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]+0.3061862178478971*JfR[7]-0.1767766952966368*(JfR[6]+JfR[5])+0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]+0.1767766952966368*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[8] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[23]-0.6123724356957944*speedsR[22]+0.6123724356957944*speedsR[21]-0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]+0.3535533905932737*speedsR[18]-0.3535533905932737*speedsR[17]+0.3535533905932737*speedsR[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])+0.27386127875258304*JfL[46]-0.27386127875258304*JfL[45]-0.15811388300841892*JfL[44]-0.27386127875258304*JfL[43]+0.273861278752583*JfL[42]+0.15811388300841892*JfL[41]-0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]-0.273861278752583*JfL[38]-0.15811388300841892*JfL[37]+0.15811388300841892*JfL[36]+0.27386127875258304*JfL[35]+0.15811388300841894*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*JfL[31]-0.41079191812887433*JfL[30]+0.41079191812887433*JfL[29]+0.2371708245126284*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.41079191812887433*JfL[25]-0.2371708245126284*JfL[24]+0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]-0.3061862178478971*JfL[21]-0.1767766952966368*JfL[20]-0.41079191812887433*JfL[19]+0.41079191812887433*JfL[18]+0.2371708245126284*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.3061862178478971*JfL[14]+0.1767766952966368*JfL[13]-0.1767766952966368*JfL[12]-0.41079191812887433*JfL[11]-0.2371708245126284*JfL[10]+0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]-0.3061862178478971*JfL[7]-0.1767766952966368*JfL[6]+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]+0.1767766952966368*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.27386127875258304*JfR[46]+0.27386127875258304*JfR[45]-0.15811388300841892*JfR[44]+0.27386127875258304*JfR[43]-0.273861278752583*JfR[42]+0.15811388300841892*JfR[41]-0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]+0.273861278752583*JfR[38]-0.15811388300841892*JfR[37]+0.15811388300841892*JfR[36]-0.27386127875258304*JfR[35]+0.15811388300841894*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*JfR[31]+0.41079191812887433*JfR[30]-0.41079191812887433*JfR[29]+0.2371708245126284*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.41079191812887433*JfR[25]-0.2371708245126284*JfR[24]+0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]+0.3061862178478971*JfR[21]-0.1767766952966368*JfR[20]+0.41079191812887433*JfR[19]-0.41079191812887433*JfR[18]+0.2371708245126284*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.3061862178478971*JfR[14]+0.1767766952966368*JfR[13]-0.1767766952966368*JfR[12]+0.41079191812887433*JfR[11]-0.2371708245126284*JfR[10]+0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]+0.3061862178478971*JfR[7]-0.1767766952966368*JfR[6]+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]+0.1767766952966368*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[9] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[23]-0.6123724356957944*speedsR[22]+0.6123724356957944*speedsR[21]-0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]+0.3535533905932737*speedsR[18]-0.3535533905932737*speedsR[17]+0.3535533905932737*speedsR[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]-0.3423265984407287*JfL[46]+0.3423265984407287*JfL[45]+0.19764235376052366*JfL[44]+0.3423265984407287*JfL[43]-0.34232659844072866*JfL[42]-0.19764235376052364*JfL[41]+0.19764235376052364*JfL[40]-0.34232659844072866*JfL[39]+0.34232659844072866*JfL[38]+0.19764235376052364*JfL[37]-0.19764235376052366*JfL[36]-0.3423265984407287*JfL[35]-0.19764235376052366*JfL[34]+0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*JfL[27]+0.3061862178478971*JfL[22]-0.3061862178478971*JfL[21]-0.1767766952966368*JfL[20]-0.3061862178478971*JfL[16]+0.3061862178478971*JfL[14]+0.1767766952966368*JfL[13]-0.1767766952966368*JfL[12]+0.3061862178478971*JfL[8]-0.3061862178478971*JfL[7]-0.1767766952966368*JfL[6]+0.1767766952966368*JfL[5]+0.3061862178478971*JfL[3]+0.1767766952966368*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = -(0.34232659844072866*JfR[47])+0.3423265984407287*JfR[46]-0.3423265984407287*JfR[45]+0.19764235376052366*JfR[44]-0.3423265984407287*JfR[43]+0.34232659844072866*JfR[42]-0.19764235376052364*JfR[41]+0.19764235376052364*JfR[40]+0.34232659844072866*JfR[39]-0.34232659844072866*JfR[38]+0.19764235376052364*JfR[37]-0.19764235376052366*JfR[36]+0.3423265984407287*JfR[35]-0.19764235376052366*JfR[34]+0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*JfR[27]-0.3061862178478971*JfR[22]+0.3061862178478971*JfR[21]-0.1767766952966368*JfR[20]+0.3061862178478971*JfR[16]-0.3061862178478971*JfR[14]+0.1767766952966368*JfR[13]-0.1767766952966368*JfR[12]-0.3061862178478971*JfR[8]+0.3061862178478971*JfR[7]-0.1767766952966368*JfR[6]+0.1767766952966368*JfR[5]-0.3061862178478971*JfR[3]+0.1767766952966368*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[10] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*speedsR[23]-0.6123724356957944*speedsR[22]+0.6123724356957944*speedsR[21]-0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]+0.3535533905932737*speedsR[18]-0.3535533905932737*speedsR[17]+0.3535533905932737*speedsR[16]; + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])+0.27386127875258304*JfL[46]-0.27386127875258304*JfL[45]-0.15811388300841892*JfL[44]-0.27386127875258304*JfL[43]+0.273861278752583*JfL[42]+0.15811388300841892*JfL[41]-0.15811388300841892*JfL[40]+0.273861278752583*JfL[39]-0.273861278752583*JfL[38]-0.15811388300841892*JfL[37]+0.15811388300841892*JfL[36]+0.27386127875258304*JfL[35]+0.15811388300841894*JfL[34]-0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*JfL[31]+0.41079191812887433*JfL[30]-0.41079191812887433*JfL[29]-0.2371708245126284*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.41079191812887433*JfL[25]+0.2371708245126284*JfL[24]-0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]-0.3061862178478971*JfL[21]-0.1767766952966368*JfL[20]+0.41079191812887433*JfL[19]-0.41079191812887433*JfL[18]-0.2371708245126284*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.3061862178478971*JfL[14]+0.1767766952966368*JfL[13]-0.1767766952966368*JfL[12]+0.41079191812887433*JfL[11]+0.2371708245126284*JfL[10]-0.2371708245126284*JfL[9]+0.3061862178478971*JfL[8]-0.3061862178478971*JfL[7]-0.1767766952966368*JfL[6]+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]+0.1767766952966368*JfL[2]-0.1767766952966368*JfL[1]+0.1767766952966368*JfL[0]; + JfR_quad = 0.273861278752583*JfR[47]-0.27386127875258304*JfR[46]+0.27386127875258304*JfR[45]-0.15811388300841892*JfR[44]+0.27386127875258304*JfR[43]-0.273861278752583*JfR[42]+0.15811388300841892*JfR[41]-0.15811388300841892*JfR[40]-0.273861278752583*JfR[39]+0.273861278752583*JfR[38]-0.15811388300841892*JfR[37]+0.15811388300841892*JfR[36]-0.27386127875258304*JfR[35]+0.15811388300841894*JfR[34]-0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*JfR[31]-0.41079191812887433*JfR[30]+0.41079191812887433*JfR[29]-0.2371708245126284*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.41079191812887433*JfR[25]+0.2371708245126284*JfR[24]-0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]+0.3061862178478971*JfR[21]-0.1767766952966368*JfR[20]-0.41079191812887433*JfR[19]+0.41079191812887433*JfR[18]-0.2371708245126284*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.3061862178478971*JfR[14]+0.1767766952966368*JfR[13]-0.1767766952966368*JfR[12]-0.41079191812887433*JfR[11]+0.2371708245126284*JfR[10]-0.2371708245126284*JfR[9]-0.3061862178478971*JfR[8]+0.3061862178478971*JfR[7]-0.1767766952966368*JfR[6]+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]+0.1767766952966368*JfR[2]-0.1767766952966368*JfR[1]+0.1767766952966368*JfR[0]; + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[11] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[2].bmag; + Jc_quad = gkdgs[2].Jc; + B3_quad = gkdgs[2].B3; + normcurlbhat_quad = gkdgs[2].normcurlbhat; + bhat_quad[0] = gkdgs[2].bhat.x[0]; + bhat_quad[1] = gkdgs[2].bhat.x[1]; + bhat_quad[2] = gkdgs[2].bhat.x[2]; + area_elem_quad = dgs[2].area_elem; + + + alpha_quad = 0.6123724356957944*(speedsR[23]+speedsR[22])-0.6123724356957944*speedsR[21]-0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]-0.3535533905932737*speedsR[18]+0.3535533905932737*(speedsR[17]+speedsR[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.27386127875258304*JfL[46]-0.27386127875258304*JfL[45]+0.15811388300841892*JfL[44]-0.27386127875258304*JfL[43]-0.273861278752583*JfL[42]+0.15811388300841892*JfL[41]-0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]+0.273861278752583*JfL[38]-0.15811388300841892*(JfL[37]+JfL[36])+0.27386127875258304*JfL[35]-0.15811388300841894*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*(JfL[31]+JfL[30])+0.41079191812887433*JfL[29]-0.2371708245126284*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*(JfL[26]+JfL[25])-0.2371708245126284*JfL[24]+0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]-0.3061862178478971*JfL[21]+0.1767766952966368*JfL[20]+0.41079191812887433*JfL[19]-0.41079191812887433*JfL[18]+0.2371708245126284*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.3061862178478971*JfL[14]+0.1767766952966368*JfL[13]-0.1767766952966368*JfL[12]-0.41079191812887433*JfL[11]+0.2371708245126284*JfL[10]-0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]+0.3061862178478971*JfL[7]-0.1767766952966368*(JfL[6]+JfL[5])-0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]-0.1767766952966368*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])-0.27386127875258304*JfR[46]+0.27386127875258304*JfR[45]+0.15811388300841892*JfR[44]+0.27386127875258304*JfR[43]+0.273861278752583*JfR[42]+0.15811388300841892*JfR[41]-0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]-0.273861278752583*JfR[38]-0.15811388300841892*(JfR[37]+JfR[36])-0.27386127875258304*JfR[35]-0.15811388300841894*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*(JfR[31]+JfR[30])-0.41079191812887433*JfR[29]-0.2371708245126284*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*(JfR[26]+JfR[25])-0.2371708245126284*JfR[24]+0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]+0.3061862178478971*JfR[21]+0.1767766952966368*JfR[20]-0.41079191812887433*JfR[19]+0.41079191812887433*JfR[18]+0.2371708245126284*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.3061862178478971*JfR[14]+0.1767766952966368*JfR[13]-0.1767766952966368*JfR[12]+0.41079191812887433*JfR[11]+0.2371708245126284*JfR[10]-0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]-0.3061862178478971*JfR[7]-0.1767766952966368*(JfR[6]+JfR[5])-0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]-0.1767766952966368*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[12] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsR[23]+speedsR[22])-0.6123724356957944*speedsR[21]-0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]-0.3535533905932737*speedsR[18]+0.3535533905932737*(speedsR[17]+speedsR[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])-0.3423265984407287*JfL[46]+0.3423265984407287*JfL[45]-0.19764235376052366*JfL[44]+0.3423265984407287*JfL[43]+0.34232659844072866*JfL[42]-0.19764235376052364*JfL[41]+0.19764235376052364*JfL[40]+0.34232659844072866*JfL[39]-0.34232659844072866*JfL[38]+0.19764235376052364*JfL[37]+0.19764235376052366*JfL[36]-0.3423265984407287*JfL[35]+0.19764235376052366*JfL[34]-0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]+0.3061862178478971*(JfL[27]+JfL[22])-0.3061862178478971*JfL[21]+0.1767766952966368*JfL[20]-0.3061862178478971*(JfL[16]+JfL[14])+0.1767766952966368*JfL[13]-0.1767766952966368*JfL[12]-0.3061862178478971*JfL[8]+0.3061862178478971*JfL[7]-0.1767766952966368*(JfL[6]+JfL[5])+0.3061862178478971*JfL[3]-0.1767766952966368*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.34232659844072866*JfR[47]+0.3423265984407287*JfR[46]-0.3423265984407287*JfR[45]-0.19764235376052366*JfR[44]-0.3423265984407287*JfR[43]-0.34232659844072866*JfR[42]-0.19764235376052364*JfR[41]+0.19764235376052364*JfR[40]-0.34232659844072866*JfR[39]+0.34232659844072866*JfR[38]+0.19764235376052364*JfR[37]+0.19764235376052366*JfR[36]+0.3423265984407287*JfR[35]+0.19764235376052366*JfR[34]-0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]-0.3061862178478971*(JfR[27]+JfR[22])+0.3061862178478971*JfR[21]+0.1767766952966368*JfR[20]+0.3061862178478971*(JfR[16]+JfR[14])+0.1767766952966368*JfR[13]-0.1767766952966368*JfR[12]+0.3061862178478971*JfR[8]-0.3061862178478971*JfR[7]-0.1767766952966368*(JfR[6]+JfR[5])-0.3061862178478971*JfR[3]-0.1767766952966368*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[13] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsR[23]+speedsR[22])-0.6123724356957944*speedsR[21]-0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]-0.3535533905932737*speedsR[18]+0.3535533905932737*(speedsR[17]+speedsR[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.27386127875258304*JfL[46]-0.27386127875258304*JfL[45]+0.15811388300841892*JfL[44]-0.27386127875258304*JfL[43]-0.273861278752583*JfL[42]+0.15811388300841892*JfL[41]-0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]+0.273861278752583*JfL[38]-0.15811388300841892*(JfL[37]+JfL[36])+0.27386127875258304*JfL[35]-0.15811388300841894*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*(JfL[31]+JfL[30])-0.41079191812887433*JfL[29]+0.2371708245126284*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*(JfL[26]+JfL[25])+0.2371708245126284*JfL[24]-0.2371708245126284*JfL[23]+0.3061862178478971*JfL[22]-0.3061862178478971*JfL[21]+0.1767766952966368*JfL[20]-0.41079191812887433*JfL[19]+0.41079191812887433*JfL[18]-0.2371708245126284*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.3061862178478971*JfL[14]+0.1767766952966368*JfL[13]-0.1767766952966368*JfL[12]+0.41079191812887433*JfL[11]-0.2371708245126284*JfL[10]+0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]+0.3061862178478971*JfL[7]-0.1767766952966368*(JfL[6]+JfL[5])+0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]-0.1767766952966368*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])-0.27386127875258304*JfR[46]+0.27386127875258304*JfR[45]+0.15811388300841892*JfR[44]+0.27386127875258304*JfR[43]+0.273861278752583*JfR[42]+0.15811388300841892*JfR[41]-0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]-0.273861278752583*JfR[38]-0.15811388300841892*(JfR[37]+JfR[36])-0.27386127875258304*JfR[35]-0.15811388300841894*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*(JfR[31]+JfR[30])+0.41079191812887433*JfR[29]+0.2371708245126284*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*(JfR[26]+JfR[25])+0.2371708245126284*JfR[24]-0.2371708245126284*JfR[23]-0.3061862178478971*JfR[22]+0.3061862178478971*JfR[21]+0.1767766952966368*JfR[20]+0.41079191812887433*JfR[19]-0.41079191812887433*JfR[18]-0.2371708245126284*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.3061862178478971*JfR[14]+0.1767766952966368*JfR[13]-0.1767766952966368*JfR[12]-0.41079191812887433*JfR[11]-0.2371708245126284*JfR[10]+0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]-0.3061862178478971*JfR[7]-0.1767766952966368*(JfR[6]+JfR[5])+0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]-0.1767766952966368*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[14] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsR[23]+speedsR[22])-0.6123724356957944*speedsR[21]-0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]-0.3535533905932737*speedsR[18]+0.3535533905932737*(speedsR[17]+speedsR[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.27386127875258304*JfL[46]+0.27386127875258304*JfL[45]-0.15811388300841892*JfL[44]-0.27386127875258304*JfL[43]+0.273861278752583*JfL[42]-0.15811388300841892*JfL[41]+0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]+0.273861278752583*JfL[38]-0.15811388300841892*JfL[37]+0.15811388300841892*JfL[36]+0.27386127875258304*JfL[35]-0.15811388300841894*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]+0.41079191812887433*(JfL[31]+JfL[30])-0.41079191812887433*JfL[29]+0.2371708245126284*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.41079191812887433*JfL[25]+0.2371708245126284*JfL[24]-0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]+0.3061862178478971*JfL[21]-0.1767766952966368*JfL[20]+0.41079191812887433*JfL[19]-0.41079191812887433*JfL[18]+0.2371708245126284*JfL[17]-0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.3061862178478971*JfL[14]-0.1767766952966368*JfL[13]+0.1767766952966368*JfL[12]-0.41079191812887433*JfL[11]+0.2371708245126284*JfL[10]-0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]+0.3061862178478971*JfL[7]-0.1767766952966368*JfL[6]+0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]-0.1767766952966368*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.273861278752583*JfR[47]+0.27386127875258304*JfR[46]-0.27386127875258304*JfR[45]-0.15811388300841892*JfR[44]+0.27386127875258304*JfR[43]-0.273861278752583*JfR[42]-0.15811388300841892*JfR[41]+0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]-0.273861278752583*JfR[38]-0.15811388300841892*JfR[37]+0.15811388300841892*JfR[36]-0.27386127875258304*JfR[35]-0.15811388300841894*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]-0.41079191812887433*(JfR[31]+JfR[30])+0.41079191812887433*JfR[29]+0.2371708245126284*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.41079191812887433*JfR[25]+0.2371708245126284*JfR[24]-0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]-0.3061862178478971*JfR[21]-0.1767766952966368*JfR[20]-0.41079191812887433*JfR[19]+0.41079191812887433*JfR[18]+0.2371708245126284*JfR[17]+0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.3061862178478971*JfR[14]-0.1767766952966368*JfR[13]+0.1767766952966368*JfR[12]+0.41079191812887433*JfR[11]+0.2371708245126284*JfR[10]-0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]-0.3061862178478971*JfR[7]-0.1767766952966368*JfR[6]+0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]-0.1767766952966368*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[15] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsR[23]+speedsR[22])-0.6123724356957944*speedsR[21]-0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]-0.3535533905932737*speedsR[18]+0.3535533905932737*(speedsR[17]+speedsR[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]+0.3423265984407287*JfL[46]-0.3423265984407287*JfL[45]+0.19764235376052366*JfL[44]+0.3423265984407287*JfL[43]-0.34232659844072866*JfL[42]+0.19764235376052364*JfL[41]-0.19764235376052364*JfL[40]+0.34232659844072866*JfL[39]-0.34232659844072866*JfL[38]+0.19764235376052364*JfL[37]-0.19764235376052366*JfL[36]-0.3423265984407287*JfL[35]+0.19764235376052366*JfL[34]-0.19764235376052366*JfL[33]-0.19764235376052364*JfL[32]-0.3061862178478971*(JfL[27]+JfL[22])+0.3061862178478971*JfL[21]-0.1767766952966368*JfL[20]-0.3061862178478971*JfL[16]+0.3061862178478971*JfL[14]-0.1767766952966368*JfL[13]+0.1767766952966368*JfL[12]-0.3061862178478971*JfL[8]+0.3061862178478971*JfL[7]-0.1767766952966368*JfL[6]+0.1767766952966368*JfL[5]+0.3061862178478971*JfL[3]-0.1767766952966368*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = -(0.34232659844072866*JfR[47])-0.3423265984407287*JfR[46]+0.3423265984407287*JfR[45]+0.19764235376052366*JfR[44]-0.3423265984407287*JfR[43]+0.34232659844072866*JfR[42]+0.19764235376052364*JfR[41]-0.19764235376052364*JfR[40]-0.34232659844072866*JfR[39]+0.34232659844072866*JfR[38]+0.19764235376052364*JfR[37]-0.19764235376052366*JfR[36]+0.3423265984407287*JfR[35]+0.19764235376052366*JfR[34]-0.19764235376052366*JfR[33]-0.19764235376052364*JfR[32]+0.3061862178478971*(JfR[27]+JfR[22])-0.3061862178478971*JfR[21]-0.1767766952966368*JfR[20]+0.3061862178478971*JfR[16]-0.3061862178478971*JfR[14]-0.1767766952966368*JfR[13]+0.1767766952966368*JfR[12]+0.3061862178478971*JfR[8]-0.3061862178478971*JfR[7]-0.1767766952966368*JfR[6]+0.1767766952966368*JfR[5]-0.3061862178478971*JfR[3]-0.1767766952966368*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[16] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = 0.6123724356957944*(speedsR[23]+speedsR[22])-0.6123724356957944*speedsR[21]-0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]-0.3535533905932737*speedsR[18]+0.3535533905932737*(speedsR[17]+speedsR[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.27386127875258304*JfL[46]+0.27386127875258304*JfL[45]-0.15811388300841892*JfL[44]-0.27386127875258304*JfL[43]+0.273861278752583*JfL[42]-0.15811388300841892*JfL[41]+0.15811388300841892*JfL[40]-0.273861278752583*JfL[39]+0.273861278752583*JfL[38]-0.15811388300841892*JfL[37]+0.15811388300841892*JfL[36]+0.27386127875258304*JfL[35]-0.15811388300841894*JfL[34]+0.15811388300841894*JfL[33]+0.15811388300841892*JfL[32]-0.41079191812887433*(JfL[31]+JfL[30])+0.41079191812887433*JfL[29]-0.2371708245126284*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.41079191812887433*JfL[25]-0.2371708245126284*JfL[24]+0.2371708245126284*JfL[23]-0.3061862178478971*JfL[22]+0.3061862178478971*JfL[21]-0.1767766952966368*JfL[20]-0.41079191812887433*JfL[19]+0.41079191812887433*JfL[18]-0.2371708245126284*JfL[17]-0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.3061862178478971*JfL[14]-0.1767766952966368*JfL[13]+0.1767766952966368*JfL[12]+0.41079191812887433*JfL[11]-0.2371708245126284*JfL[10]+0.2371708245126284*JfL[9]-0.3061862178478971*JfL[8]+0.3061862178478971*JfL[7]-0.1767766952966368*JfL[6]+0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]-0.1767766952966368*JfL[2]+0.1767766952966368*(JfL[1]+JfL[0]); + JfR_quad = 0.273861278752583*JfR[47]+0.27386127875258304*JfR[46]-0.27386127875258304*JfR[45]-0.15811388300841892*JfR[44]+0.27386127875258304*JfR[43]-0.273861278752583*JfR[42]-0.15811388300841892*JfR[41]+0.15811388300841892*JfR[40]+0.273861278752583*JfR[39]-0.273861278752583*JfR[38]-0.15811388300841892*JfR[37]+0.15811388300841892*JfR[36]-0.27386127875258304*JfR[35]-0.15811388300841894*JfR[34]+0.15811388300841894*JfR[33]+0.15811388300841892*JfR[32]+0.41079191812887433*(JfR[31]+JfR[30])-0.41079191812887433*JfR[29]-0.2371708245126284*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.41079191812887433*JfR[25]-0.2371708245126284*JfR[24]+0.2371708245126284*JfR[23]+0.3061862178478971*JfR[22]-0.3061862178478971*JfR[21]-0.1767766952966368*JfR[20]+0.41079191812887433*JfR[19]-0.41079191812887433*JfR[18]-0.2371708245126284*JfR[17]+0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.3061862178478971*JfR[14]-0.1767766952966368*JfR[13]+0.1767766952966368*JfR[12]-0.41079191812887433*JfR[11]-0.2371708245126284*JfR[10]+0.2371708245126284*JfR[9]+0.3061862178478971*JfR[8]-0.3061862178478971*JfR[7]-0.1767766952966368*JfR[6]+0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]-0.1767766952966368*JfR[2]+0.1767766952966368*(JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[17] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + bmag_quad = gkdgs[3].bmag; + Jc_quad = gkdgs[3].Jc; + B3_quad = gkdgs[3].B3; + normcurlbhat_quad = gkdgs[3].normcurlbhat; + bhat_quad[0] = gkdgs[3].bhat.x[0]; + bhat_quad[1] = gkdgs[3].bhat.x[1]; + bhat_quad[2] = gkdgs[3].bhat.x[2]; + area_elem_quad = dgs[3].area_elem; + + + alpha_quad = -(0.6123724356957944*(speedsR[23]+speedsR[22]+speedsR[21]))+0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]+0.3535533905932737*(speedsR[18]+speedsR[17]+speedsR[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.27386127875258304*(JfL[46]+JfL[45])-0.15811388300841892*JfL[44]+0.27386127875258304*JfL[43]-0.273861278752583*JfL[42]-0.15811388300841892*(JfL[41]+JfL[40])+0.273861278752583*(JfL[39]+JfL[38])+0.15811388300841892*JfL[37]-0.15811388300841892*JfL[36]+0.27386127875258304*JfL[35]+0.15811388300841894*(JfL[34]+JfL[33])+0.15811388300841892*JfL[32]+0.41079191812887433*(JfL[31]+JfL[30]+JfL[29])+0.2371708245126284*JfL[28]-0.3061862178478971*JfL[27]-0.41079191812887433*JfL[26]+0.41079191812887433*JfL[25]+0.2371708245126284*(JfL[24]+JfL[23])-0.3061862178478971*(JfL[22]+JfL[21])-0.1767766952966368*JfL[20]-0.41079191812887433*(JfL[19]+JfL[18])-0.2371708245126284*JfL[17]+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]-0.3061862178478971*JfL[14]-0.1767766952966368*(JfL[13]+JfL[12])-0.41079191812887433*JfL[11]-0.2371708245126284*(JfL[10]+JfL[9])+0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*JfL[6]-0.1767766952966368*JfL[5]-0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]+0.1767766952966368*(JfL[2]+JfL[1]+JfL[0]); + JfR_quad = 0.273861278752583*JfR[47]+0.27386127875258304*(JfR[46]+JfR[45])-0.15811388300841892*JfR[44]-0.27386127875258304*JfR[43]+0.273861278752583*JfR[42]-0.15811388300841892*(JfR[41]+JfR[40])-0.273861278752583*(JfR[39]+JfR[38])+0.15811388300841892*JfR[37]-0.15811388300841892*JfR[36]-0.27386127875258304*JfR[35]+0.15811388300841894*(JfR[34]+JfR[33])+0.15811388300841892*JfR[32]-0.41079191812887433*(JfR[31]+JfR[30]+JfR[29])+0.2371708245126284*JfR[28]+0.3061862178478971*JfR[27]+0.41079191812887433*JfR[26]-0.41079191812887433*JfR[25]+0.2371708245126284*(JfR[24]+JfR[23])+0.3061862178478971*(JfR[22]+JfR[21])-0.1767766952966368*JfR[20]+0.41079191812887433*(JfR[19]+JfR[18])-0.2371708245126284*JfR[17]-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]+0.3061862178478971*JfR[14]-0.1767766952966368*(JfR[13]+JfR[12])+0.41079191812887433*JfR[11]-0.2371708245126284*(JfR[10]+JfR[9])-0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*JfR[6]-0.1767766952966368*JfR[5]-0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]+0.1767766952966368*(JfR[2]+JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[18] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsR[23]+speedsR[22]+speedsR[21]))+0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]+0.3535533905932737*(speedsR[18]+speedsR[17]+speedsR[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.34232659844072866*JfL[47]+0.3423265984407287*(JfL[46]+JfL[45])+0.19764235376052366*JfL[44]-0.3423265984407287*JfL[43]+0.34232659844072866*JfL[42]+0.19764235376052364*(JfL[41]+JfL[40])-0.34232659844072866*(JfL[39]+JfL[38])-0.19764235376052364*JfL[37]+0.19764235376052366*JfL[36]-0.3423265984407287*JfL[35]-0.19764235376052366*(JfL[34]+JfL[33])-0.19764235376052364*JfL[32]-0.3061862178478971*(JfL[27]+JfL[22]+JfL[21])-0.1767766952966368*JfL[20]+0.3061862178478971*JfL[16]-0.3061862178478971*JfL[14]-0.1767766952966368*(JfL[13]+JfL[12])+0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*JfL[6]-0.1767766952966368*JfL[5]+0.3061862178478971*JfL[3]+0.1767766952966368*(JfL[2]+JfL[1]+JfL[0]); + JfR_quad = -(0.34232659844072866*JfR[47])-0.3423265984407287*(JfR[46]+JfR[45])+0.19764235376052366*JfR[44]+0.3423265984407287*JfR[43]-0.34232659844072866*JfR[42]+0.19764235376052364*(JfR[41]+JfR[40])+0.34232659844072866*(JfR[39]+JfR[38])-0.19764235376052364*JfR[37]+0.19764235376052366*JfR[36]+0.3423265984407287*JfR[35]-0.19764235376052366*(JfR[34]+JfR[33])-0.19764235376052364*JfR[32]+0.3061862178478971*(JfR[27]+JfR[22]+JfR[21])-0.1767766952966368*JfR[20]-0.3061862178478971*JfR[16]+0.3061862178478971*JfR[14]-0.1767766952966368*(JfR[13]+JfR[12])-0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*JfR[6]-0.1767766952966368*JfR[5]-0.3061862178478971*JfR[3]+0.1767766952966368*(JfR[2]+JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[19] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsR[23]+speedsR[22]+speedsR[21]))+0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]+0.3535533905932737*(speedsR[18]+speedsR[17]+speedsR[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.273861278752583*JfL[47])-0.27386127875258304*(JfL[46]+JfL[45])-0.15811388300841892*JfL[44]+0.27386127875258304*JfL[43]-0.273861278752583*JfL[42]-0.15811388300841892*(JfL[41]+JfL[40])+0.273861278752583*(JfL[39]+JfL[38])+0.15811388300841892*JfL[37]-0.15811388300841892*JfL[36]+0.27386127875258304*JfL[35]+0.15811388300841894*(JfL[34]+JfL[33])+0.15811388300841892*JfL[32]-0.41079191812887433*(JfL[31]+JfL[30]+JfL[29])-0.2371708245126284*JfL[28]-0.3061862178478971*JfL[27]+0.41079191812887433*JfL[26]-0.41079191812887433*JfL[25]-0.2371708245126284*(JfL[24]+JfL[23])-0.3061862178478971*(JfL[22]+JfL[21])-0.1767766952966368*JfL[20]+0.41079191812887433*(JfL[19]+JfL[18])+0.2371708245126284*JfL[17]+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]-0.3061862178478971*JfL[14]-0.1767766952966368*(JfL[13]+JfL[12])+0.41079191812887433*JfL[11]+0.2371708245126284*(JfL[10]+JfL[9])+0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*JfL[6]-0.1767766952966368*JfL[5]+0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]+0.1767766952966368*(JfL[2]+JfL[1]+JfL[0]); + JfR_quad = 0.273861278752583*JfR[47]+0.27386127875258304*(JfR[46]+JfR[45])-0.15811388300841892*JfR[44]-0.27386127875258304*JfR[43]+0.273861278752583*JfR[42]-0.15811388300841892*(JfR[41]+JfR[40])-0.273861278752583*(JfR[39]+JfR[38])+0.15811388300841892*JfR[37]-0.15811388300841892*JfR[36]-0.27386127875258304*JfR[35]+0.15811388300841894*(JfR[34]+JfR[33])+0.15811388300841892*JfR[32]+0.41079191812887433*(JfR[31]+JfR[30]+JfR[29])-0.2371708245126284*JfR[28]+0.3061862178478971*JfR[27]-0.41079191812887433*JfR[26]+0.41079191812887433*JfR[25]-0.2371708245126284*(JfR[24]+JfR[23])+0.3061862178478971*(JfR[22]+JfR[21])-0.1767766952966368*JfR[20]-0.41079191812887433*(JfR[19]+JfR[18])+0.2371708245126284*JfR[17]-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]+0.3061862178478971*JfR[14]-0.1767766952966368*(JfR[13]+JfR[12])-0.41079191812887433*JfR[11]+0.2371708245126284*(JfR[10]+JfR[9])-0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*JfR[6]-0.1767766952966368*JfR[5]+0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]+0.1767766952966368*(JfR[2]+JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[20] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsR[23]+speedsR[22]+speedsR[21]))+0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]+0.3535533905932737*(speedsR[18]+speedsR[17]+speedsR[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.27386127875258304*(JfL[46]+JfL[45])+0.15811388300841892*JfL[44]+0.27386127875258304*JfL[43]+0.273861278752583*JfL[42]+0.15811388300841892*(JfL[41]+JfL[40])+0.273861278752583*(JfL[39]+JfL[38])+0.15811388300841892*(JfL[37]+JfL[36])+0.27386127875258304*JfL[35]+0.15811388300841894*(JfL[34]+JfL[33])+0.15811388300841892*JfL[32]-0.41079191812887433*(JfL[31]+JfL[30]+JfL[29])-0.2371708245126284*JfL[28]+0.3061862178478971*JfL[27]-0.41079191812887433*(JfL[26]+JfL[25])-0.2371708245126284*(JfL[24]+JfL[23])+0.3061862178478971*(JfL[22]+JfL[21])+0.1767766952966368*JfL[20]-0.41079191812887433*(JfL[19]+JfL[18])-0.2371708245126284*JfL[17]+0.3061862178478971*JfL[16]-0.2371708245126284*JfL[15]+0.3061862178478971*JfL[14]+0.1767766952966368*(JfL[13]+JfL[12])-0.41079191812887433*JfL[11]-0.2371708245126284*(JfL[10]+JfL[9])+0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*(JfL[6]+JfL[5])-0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]+0.1767766952966368*(JfL[2]+JfL[1]+JfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])-0.27386127875258304*(JfR[46]+JfR[45])+0.15811388300841892*JfR[44]-0.27386127875258304*JfR[43]-0.273861278752583*JfR[42]+0.15811388300841892*(JfR[41]+JfR[40])-0.273861278752583*(JfR[39]+JfR[38])+0.15811388300841892*(JfR[37]+JfR[36])-0.27386127875258304*JfR[35]+0.15811388300841894*(JfR[34]+JfR[33])+0.15811388300841892*JfR[32]+0.41079191812887433*(JfR[31]+JfR[30]+JfR[29])-0.2371708245126284*JfR[28]-0.3061862178478971*JfR[27]+0.41079191812887433*(JfR[26]+JfR[25])-0.2371708245126284*(JfR[24]+JfR[23])-0.3061862178478971*(JfR[22]+JfR[21])+0.1767766952966368*JfR[20]+0.41079191812887433*(JfR[19]+JfR[18])-0.2371708245126284*JfR[17]-0.3061862178478971*JfR[16]-0.2371708245126284*JfR[15]-0.3061862178478971*JfR[14]+0.1767766952966368*(JfR[13]+JfR[12])+0.41079191812887433*JfR[11]-0.2371708245126284*(JfR[10]+JfR[9])-0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*(JfR[6]+JfR[5])-0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]+0.1767766952966368*(JfR[2]+JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[21] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsR[23]+speedsR[22]+speedsR[21]))+0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]+0.3535533905932737*(speedsR[18]+speedsR[17]+speedsR[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = -(0.34232659844072866*JfL[47])-0.3423265984407287*(JfL[46]+JfL[45])-0.19764235376052366*JfL[44]-0.3423265984407287*JfL[43]-0.34232659844072866*JfL[42]-0.19764235376052364*(JfL[41]+JfL[40])-0.34232659844072866*(JfL[39]+JfL[38])-0.19764235376052364*JfL[37]-0.19764235376052366*JfL[36]-0.3423265984407287*JfL[35]-0.19764235376052366*(JfL[34]+JfL[33])-0.19764235376052364*JfL[32]+0.3061862178478971*(JfL[27]+JfL[22]+JfL[21])+0.1767766952966368*JfL[20]+0.3061862178478971*(JfL[16]+JfL[14])+0.1767766952966368*(JfL[13]+JfL[12])+0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*(JfL[6]+JfL[5])+0.3061862178478971*JfL[3]+0.1767766952966368*(JfL[2]+JfL[1]+JfL[0]); + JfR_quad = 0.34232659844072866*JfR[47]+0.3423265984407287*(JfR[46]+JfR[45])-0.19764235376052366*JfR[44]+0.3423265984407287*JfR[43]+0.34232659844072866*JfR[42]-0.19764235376052364*(JfR[41]+JfR[40])+0.34232659844072866*(JfR[39]+JfR[38])-0.19764235376052364*JfR[37]-0.19764235376052366*JfR[36]+0.3423265984407287*JfR[35]-0.19764235376052366*(JfR[34]+JfR[33])-0.19764235376052364*JfR[32]-0.3061862178478971*(JfR[27]+JfR[22]+JfR[21])+0.1767766952966368*JfR[20]-0.3061862178478971*(JfR[16]+JfR[14])+0.1767766952966368*(JfR[13]+JfR[12])-0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*(JfR[6]+JfR[5])-0.3061862178478971*JfR[3]+0.1767766952966368*(JfR[2]+JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[22] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + alpha_quad = -(0.6123724356957944*(speedsR[23]+speedsR[22]+speedsR[21]))+0.3535533905932737*speedsR[20]-0.6123724356957944*speedsR[19]+0.3535533905932737*(speedsR[18]+speedsR[17]+speedsR[16]); + + cfl = fmax(fabs(alpha_quad), fabs(cfl)); + JfL_quad = 0.273861278752583*JfL[47]+0.27386127875258304*(JfL[46]+JfL[45])+0.15811388300841892*JfL[44]+0.27386127875258304*JfL[43]+0.273861278752583*JfL[42]+0.15811388300841892*(JfL[41]+JfL[40])+0.273861278752583*(JfL[39]+JfL[38])+0.15811388300841892*(JfL[37]+JfL[36])+0.27386127875258304*JfL[35]+0.15811388300841894*(JfL[34]+JfL[33])+0.15811388300841892*JfL[32]+0.41079191812887433*(JfL[31]+JfL[30]+JfL[29])+0.2371708245126284*JfL[28]+0.3061862178478971*JfL[27]+0.41079191812887433*(JfL[26]+JfL[25])+0.2371708245126284*(JfL[24]+JfL[23])+0.3061862178478971*(JfL[22]+JfL[21])+0.1767766952966368*JfL[20]+0.41079191812887433*(JfL[19]+JfL[18])+0.2371708245126284*JfL[17]+0.3061862178478971*JfL[16]+0.2371708245126284*JfL[15]+0.3061862178478971*JfL[14]+0.1767766952966368*(JfL[13]+JfL[12])+0.41079191812887433*JfL[11]+0.2371708245126284*(JfL[10]+JfL[9])+0.3061862178478971*(JfL[8]+JfL[7])+0.1767766952966368*(JfL[6]+JfL[5])+0.2371708245126284*JfL[4]+0.3061862178478971*JfL[3]+0.1767766952966368*(JfL[2]+JfL[1]+JfL[0]); + JfR_quad = -(0.273861278752583*JfR[47])-0.27386127875258304*(JfR[46]+JfR[45])+0.15811388300841892*JfR[44]-0.27386127875258304*JfR[43]-0.273861278752583*JfR[42]+0.15811388300841892*(JfR[41]+JfR[40])-0.273861278752583*(JfR[39]+JfR[38])+0.15811388300841892*(JfR[37]+JfR[36])-0.27386127875258304*JfR[35]+0.15811388300841894*(JfR[34]+JfR[33])+0.15811388300841892*JfR[32]-0.41079191812887433*(JfR[31]+JfR[30]+JfR[29])+0.2371708245126284*JfR[28]-0.3061862178478971*JfR[27]-0.41079191812887433*(JfR[26]+JfR[25])+0.2371708245126284*(JfR[24]+JfR[23])-0.3061862178478971*(JfR[22]+JfR[21])+0.1767766952966368*JfR[20]-0.41079191812887433*(JfR[19]+JfR[18])+0.2371708245126284*JfR[17]-0.3061862178478971*JfR[16]+0.2371708245126284*JfR[15]-0.3061862178478971*JfR[14]+0.1767766952966368*(JfR[13]+JfR[12])-0.41079191812887433*JfR[11]+0.2371708245126284*(JfR[10]+JfR[9])-0.3061862178478971*(JfR[8]+JfR[7])+0.1767766952966368*(JfR[6]+JfR[5])+0.2371708245126284*JfR[4]-0.3061862178478971*JfR[3]+0.1767766952966368*(JfR[2]+JfR[1]+JfR[0]); + Jfavg_quad = (JfL_quad + JfR_quad)/2.0; + Jfjump_quad = (JfR_quad - JfL_quad)/2.0; + flux_surf_nodal[23] = alpha_quad*Jfavg_quad - fabs(alpha_quad)*Jfjump_quad; + + + return cfl*1.5*rdz2; + +} diff --git a/gyrokinetic/ker/gk_collisionless_passive_flux/gkyl_gk_collisionless_passive_flux_kernels.h b/gyrokinetic/ker/gk_collisionless_passive_flux/gkyl_gk_collisionless_passive_flux_kernels.h new file mode 100644 index 0000000000..834c18632e --- /dev/null +++ b/gyrokinetic/ker/gk_collisionless_passive_flux/gkyl_gk_collisionless_passive_flux_kernels.h @@ -0,0 +1,239 @@ +#pragma once + +#include +#include +#include +#include + +EXTERN_C_BEG + +GKYL_CU_DH double gk_collisionless_passive_flux_surfx_1x1v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); +GKYL_CU_DH double gk_collisionless_passive_flux_edge_surfx_1x1v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_surfx_1x1v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_edge_surfx_1x1v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); + +GKYL_CU_DH double gk_collisionless_passive_flux_surfx_1x2v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); +GKYL_CU_DH double gk_collisionless_passive_flux_edge_surfx_1x2v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_surfx_1x2v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_edge_surfx_1x2v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); + +GKYL_CU_DH double gk_collisionless_passive_flux_surfx_2x2v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); +GKYL_CU_DH double gk_collisionless_passive_flux_edge_surfx_2x2v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); +GKYL_CU_DH double gk_collisionless_passive_flux_surfy_2x2v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); +GKYL_CU_DH double gk_collisionless_passive_flux_edge_surfy_2x2v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_surfx_2x2v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_edge_surfx_2x2v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_surfy_2x2v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_edge_surfy_2x2v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); + +GKYL_CU_DH double gk_collisionless_passive_flux_surfx_3x2v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); +GKYL_CU_DH double gk_collisionless_passive_flux_edge_surfx_3x2v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); +GKYL_CU_DH double gk_collisionless_passive_flux_surfy_3x2v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); +GKYL_CU_DH double gk_collisionless_passive_flux_edge_surfy_3x2v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); +GKYL_CU_DH double gk_collisionless_passive_flux_surfz_3x2v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); +GKYL_CU_DH double gk_collisionless_passive_flux_edge_surfz_3x2v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_surfx_3x2v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_edge_surfx_3x2v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_surfy_3x2v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_edge_surfy_3x2v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_surfz_3x2v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); +GKYL_CU_DH double gk_collisionless_passive_flux_multib_boundary_edge_surfz_3x2v_ser_p1( + const double *w, const double *dxv, + + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speedsL, const double *speedsR, const double *JfL, const double *JfR, + double* GKYL_RESTRICT flux_surf); + + +EXTERN_C_END diff --git a/gyrokinetic/unit/ctest_bc_twistshift.c b/gyrokinetic/unit/ctest_bc_twistshift.c index 47319fb346..707d48c149 100644 --- a/gyrokinetic/unit/ctest_bc_twistshift.c +++ b/gyrokinetic/unit/ctest_bc_twistshift.c @@ -18,6 +18,8 @@ #include #include #include +#include +#include // Meta-data for IO struct test_bc_twistshift_output_meta { @@ -115,6 +117,7 @@ struct test_bc_twistshift_ctx { double B0; double vt; double mass; + enum gkyl_edge_loc edge; }; void @@ -324,17 +327,17 @@ test_bc_twistshift_3x_fig6_wcells(const int *cells, enum gkyl_edge_loc edge, .shear_dir = 0, // shift varies with x. .edge = edge, .cdim = cdim, - .bcdir_ext_update_r = update_rng, + .bcdir_ext_update_r = &update_rng, .num_ghost = ghost, - .basis = basis, - .grid = grid, + .basis = &basis, + .grid = &grid, .shift_func = shift1_fig6, // .shift_func = shift_fig9, .shift_func_ctx = &proj_ctx, .use_gpu = use_gpu, }; - struct gkyl_bc_twistshift *tsup = gkyl_bc_twistshift_new(&tsinp); + struct gkyl_bc_twistshift *tsup = gkyl_bc_twistshift_inew(&tsinp); // First apply periodicity in z. struct gkyl_array *buff_per = mkarr(use_gpu, basis.num_basis, skin_rng.volume); @@ -391,7 +394,7 @@ test_bc_twistshift_3x_fig6_wcells(const int *cells, enum gkyl_edge_loc edge, gkyl_array_copy_range_to_range(distf, distf, &skin_rng, &ghost_rng); tsinp.shift_func = shift1m_fig6; // tsinp.shift_func = shiftm_fig9; - struct gkyl_bc_twistshift *tsup_m = gkyl_bc_twistshift_new(&tsinp); + struct gkyl_bc_twistshift *tsup_m = gkyl_bc_twistshift_inew(&tsinp); gkyl_bc_twistshift_advance(tsup_m, distf, distf); gkyl_array_copy(distf_ho, distf); @@ -581,17 +584,17 @@ test_bc_twistshift_3x2v_fig6_wcells(const int *cells, enum gkyl_edge_loc edge, .shear_dir = 0, // shift varies with x. .edge = edge, .cdim = cdim, - .bcdir_ext_update_r = update_rng, + .bcdir_ext_update_r = &update_rng, .num_ghost = ghost, - .basis = basis, - .grid = grid, + .basis = &basis, + .grid = &grid, .shift_func = shift1_fig6, // .shift_func = shift_fig9, .shift_func_ctx = &proj_ctx, .use_gpu = use_gpu, }; - struct gkyl_bc_twistshift *tsup = gkyl_bc_twistshift_new(&tsinp); + struct gkyl_bc_twistshift *tsup = gkyl_bc_twistshift_inew(&tsinp); // First apply periodicity in z. struct gkyl_array *buff_per = mkarr(use_gpu, basis.num_basis, skin_rng.volume); @@ -732,7 +735,7 @@ test_bc_twistshift_3x2v_fig6_wcells(const int *cells, enum gkyl_edge_loc edge, gkyl_array_copy_range_to_range(distf, distf, &skin_rng, &ghost_rng); tsinp.shift_func = shift1m_fig6; // tsinp.shift_func = shiftm_fig9; - struct gkyl_bc_twistshift *tsup_m = gkyl_bc_twistshift_new(&tsinp); + struct gkyl_bc_twistshift *tsup_m = gkyl_bc_twistshift_inew(&tsinp); gkyl_bc_twistshift_advance(tsup_m, distf, distf); gkyl_array_copy(distf_ho, distf); @@ -992,16 +995,16 @@ test_bc_twistshift_3x_fig11_wcells(const int *cells, enum gkyl_edge_loc edge, .shear_dir = 0, // shift varies with x. .edge = edge, .cdim = cdim, - .bcdir_ext_update_r = update_rng, + .bcdir_ext_update_r = &update_rng, .num_ghost = ghost, - .basis = basis, - .grid = grid, + .basis = &basis, + .grid = &grid, .shift_func = shift_fig11, .shift_func_ctx = &proj_ctx, .use_gpu = use_gpu, }; - struct gkyl_bc_twistshift *tsup = gkyl_bc_twistshift_new(&tsinp); + struct gkyl_bc_twistshift *tsup = gkyl_bc_twistshift_inew(&tsinp); // First apply periodicity in z. struct gkyl_array *buff_per = mkarr(use_gpu, basis.num_basis, skin_rng.volume); @@ -1181,6 +1184,489 @@ test_bc_twistshift_3x_fig11_wcells(const int *cells, enum gkyl_edge_loc edge, } +void +init_donor_3x_fig14(double t, const double *xn, double* GKYL_RESTRICT fout, void *ctx) +{ + double x = xn[0], y = xn[1], z = xn[2]; + + struct test_bc_twistshift_ctx *pars = ctx; + double Lx[3] = { + pars->upper[0]-pars->lower[0], + pars->upper[1]-pars->lower[1], + pars->upper[2]-pars->lower[2], + }; + + double f_amplitude = 1.0; + double f_floor = 1.0e-10; + + // Cube + double rx2 = pow(x-Lx[0]/2,2); + double ry2 = pow(y-Lx[1]/2,2); + double rz2 = pow(z-Lx[2]/2,2); + + if (rx2 < pow(Lx[0]/4,2) && ry2 < pow(Lx[1]/4,2)) + fout[0] = f_amplitude; + else + fout[0] = f_floor; +} + +void +shift_fig14(double t, const double *xn, double* GKYL_RESTRICT fout, void *ctx) +{ + double x = xn[0]; + + struct test_bc_twistshift_ctx *pars = ctx; + double Lx[3] = { + pars->upper[0]-pars->lower[0], + pars->upper[1]-pars->lower[1], + pars->upper[2]-pars->lower[2], + }; + double dx[3] = { + Lx[0]/pars->cells[0], + Lx[1]/pars->cells[1], + Lx[2]/pars->cells[2], + }; + enum gkyl_edge_loc edge = pars->edge; + + fout[0] = -(x-0.5); + + if (edge == GKYL_UPPER_EDGE) + fout[0] *= -1.0; +} + +void +test_bc_twistshift_3x_fig14_wcells(const int *cells, enum gkyl_edge_loc edge, + int apply_in_half_x, bool check_distf, bool use_gpu, bool write_f) +{ + double vt = 1.0; // Thermal speed. + double mass = 1.0; + double B0 = 1.0; // Magnetic field magnitude. + int bc_dir = 2; // Direction in which to apply TS. + + int poly_order = 1; + const double lower[] = {0.0, 0.0, 0.0}; + const double upper[] = {1.0, 1.0, 1.0}; + int vdim = 0; + int ndim = sizeof(lower)/sizeof(lower[0]); + int cdim = ndim - vdim; + + double lower_conf[cdim], upper_conf[cdim]; + int cells_conf[cdim]; + for (int d=0; d 0) { + // Apply the BC only on the upper half of the domain. + int x_half_len = (update_rng.upper[0] - update_rng.lower[0] + 1)/2; + gkyl_range_shorten_from_below(&update_rng, &update_rng, 0, x_half_len); + } + + // Create the twist-shift updater and shift the donor field. + struct gkyl_bc_twistshift_inp tsinp = { + .bc_dir = bc_dir, + .shift_dir = 1, // y shift. + .shear_dir = 0, // shift varies with x. + .edge = edge, + .cdim = cdim, + .bcdir_ext_update_r = &update_rng, + .num_ghost = ghost, + .basis = &basis, + .grid = &grid, + .shift_func = shift_fig14, + .shift_func_ctx = &proj_ctx, + .use_gpu = use_gpu, + }; + + struct gkyl_bc_twistshift *tsup = gkyl_bc_twistshift_inew(&tsinp); + + // First apply periodicity in z. + struct gkyl_array *buff_per = mkarr(use_gpu, basis.num_basis, skin_rng.volume); + apply_periodic_bc(buff_per, distf, bc_dir, skin_ghost); + + gkyl_bc_twistshift_advance(tsup, distf, distf); + gkyl_array_copy(distf_ho, distf); + + // Write out the target in the extended range. + if (write_f) { + double lower_ext[ndim], upper_ext[ndim]; + int cells_ext[ndim]; + for (int d=0; d 0) { + // Applied the BC only on the upper half of the domain. + int x_half_len = (ghost_rng.upper[0] - ghost_rng.lower[0] + 1)/2; + gkyl_range_shorten_from_below(&check_ghost_rng, &ghost_rng, 0, x_half_len); + gkyl_range_shorten_from_above(&check_other_ghost_rng, &ghost_rng, 0, x_half_len); + } + else + check_ghost_rng = ghost_rng; + + struct gkyl_range_iter iter; + gkyl_range_iter_init(&iter, &check_ghost_rng); + while (gkyl_range_iter_next(&iter)) { + long linidx = gkyl_range_idx(&check_ghost_rng, iter.idx); + double *f_c = gkyl_array_fetch(distf_ho, linidx); + int refidx = (iter.idx[0]-1)*cells[1] + iter.idx[1]-1; + TEST_CHECK( gkyl_compare(f0[refidx], f_c[0], 1e-13) ); + TEST_CHECK( gkyl_compare(f1[refidx], f_c[1], 1e-13) ); + TEST_CHECK( gkyl_compare(f2[refidx], f_c[2], 1e-12) ); + TEST_CHECK( gkyl_compare(f6[refidx], f_c[6], 1e-12) ); + } + + } + + gkyl_array_release(buff_per); + test_bc_twistshift_array_meta_release(mt); + gkyl_bc_twistshift_release(tsup); + gkyl_proj_on_basis_release(projDistf); + gkyl_array_release(distf_ho); + gkyl_array_release(distf); + +} + void test_bc_twistshift_3x2v_fig11_wcells(const int *cells, enum gkyl_edge_loc edge, int apply_in_half_x, bool check_distf, bool use_gpu, bool write_f) @@ -1326,16 +1812,16 @@ test_bc_twistshift_3x2v_fig11_wcells(const int *cells, enum gkyl_edge_loc edge, .shear_dir = 0, // shift varies with x. .edge = edge, .cdim = cdim, - .bcdir_ext_update_r = update_rng, + .bcdir_ext_update_r = &update_rng, .num_ghost = ghost, - .basis = basis, - .grid = grid, + .basis = &basis, + .grid = &grid, .shift_func = shift_fig11, .shift_func_ctx = &proj_ctx, .use_gpu = use_gpu, }; - struct gkyl_bc_twistshift *tsup = gkyl_bc_twistshift_new(&tsinp); + struct gkyl_bc_twistshift *tsup = gkyl_bc_twistshift_inew(&tsinp); // First apply periodicity in z. struct gkyl_array *buff_per = mkarr(use_gpu, basis.num_basis, skin_rng.volume); @@ -1614,6 +2100,1597 @@ test_bc_twistshift_3x2v_fig11_wcells(const int *cells, enum gkyl_edge_loc edge, } +// CBC geometry (see rt_gk_cbc_passive_3x2v_p1.c) + +static double +interp_1x_lut_cbc(double x, double *lut_grid, double *lut_val, int N) +{ + double x_min = lut_grid[0]; + double x_max = lut_grid[N-1]; + if (x <= x_min) return lut_val[0]; + if (x >= x_max) return lut_val[N-1]; + double dx = (x_max - x_min)/(N-1); + int idx = (int)((x - x_min)/dx); + if (idx < 0) idx = 0; + if (idx >= N-1) idx = N-2; + return lut_val[idx] + (lut_val[idx+1] - lut_val[idx])*(x - lut_grid[idx])/(lut_grid[idx+1] - lut_grid[idx]); +} + +struct gk_cbc_app_ctx { + double a_shift, Z_axis, R_axis, R0, a_mid, r0, B0, kappa, delta, q0, Cy, qaxis, qlcfs; + double Lx, Ly, Lz; + double x_min, y_min, z_min, x_max, y_max, z_max; + int psi_lut_size; + double *r_lut; + double *dPsidr_int_lut; +}; + +struct integrand_cbc_ctx { + struct gk_cbc_app_ctx *app_ctx; + double r; + double theta; +}; + +static double r_x_cbc(double x, double r0) { return x + r0; } + +static double qprofile_cbc(double r, double a_mid, double qaxis, double qlcfs) +{ + return 1.0 + 2.78*pow(r/a_mid, 2.8); +} + +static double R_rtheta_cbc(double r, double theta, void *ctx) +{ + struct gk_cbc_app_ctx *app = ctx; + return app->R_axis - app->a_shift*r*r/(2.*app->R_axis) + + r*cos(theta + asin(app->delta)*sin(theta)); +} + +static double dRdr_cbc(double r, double theta, void *ctx) +{ + struct gk_cbc_app_ctx *app = ctx; + return -app->a_shift*r/app->R_axis + cos(theta + asin(app->delta)*sin(theta)); +} + +static double dRdtheta_cbc(double r, double theta, void *ctx) +{ + struct gk_cbc_app_ctx *app = ctx; + return -r*sin(theta + asin(app->delta)*sin(theta))*(1. + asin(app->delta)*cos(theta)); +} + +static double dZdr_cbc(double r, double theta, void *ctx) +{ + struct gk_cbc_app_ctx *app = ctx; + return app->kappa*sin(theta); +} + +static double dZdtheta_cbc(double r, double theta, void *ctx) +{ + struct gk_cbc_app_ctx *app = ctx; + return app->kappa*r*cos(theta); +} + +static double Jr_cbc(double r, double theta, void *ctx) +{ + return R_rtheta_cbc(r, theta, ctx) + *(dRdr_cbc(r, theta, ctx)*dZdtheta_cbc(r, theta, ctx) + - dRdtheta_cbc(r, theta, ctx)*dZdr_cbc(r, theta, ctx)); +} + +static double Bphi_cbc(double R, void *ctx) +{ + struct gk_cbc_app_ctx *app = ctx; + return app->B0*app->R0/R; +} + +static double integrand_JoRsq_cbc(double t, void *int_ctx) +{ + struct integrand_cbc_ctx *inctx = int_ctx; + return Jr_cbc(inctx->r, t, inctx->app_ctx) + / pow(R_rtheta_cbc(inctx->r, t, inctx->app_ctx), 2); +} + +static double intdPsidr_cbc(double r, void *ctx) +{ + struct gk_cbc_app_ctx *app = ctx; + struct integrand_cbc_ctx tmp_ctx = {.app_ctx = app, .r = r}; + struct gkyl_qr_res integral = gkyl_dbl_exp(integrand_JoRsq_cbc, &tmp_ctx, 0., 2.*M_PI, 7, 1e-10); + return integral.res; +} + +static double dPsidr_cbc(double r, double theta, void *ctx) +{ + struct gk_cbc_app_ctx *app = ctx; + double integral_val = interp_1x_lut_cbc(r, app->r_lut, app->dPsidr_int_lut, app->psi_lut_size); + double R = R_rtheta_cbc(r, theta, ctx); + double Bt = Bphi_cbc(R, ctx); + return (R*Bt/(2.*M_PI*qprofile_cbc(r, app->a_mid, app->qaxis, app->qlcfs)))*integral_val; +} + +static double compute_alpha_integral_cbc(double r, double twrap, void *ctx) +{ + struct gk_cbc_app_ctx *app = ctx; + struct integrand_cbc_ctx tmp_ctx = {.app_ctx = app, .r = r}; + struct gkyl_qr_res integral; + if (twrap == 0.0) return 0.0; + if (0. < twrap) { + integral = gkyl_dbl_exp(integrand_JoRsq_cbc, &tmp_ctx, 0., twrap, 7, 1e-10); + return integral.res; + } else { + integral = gkyl_dbl_exp(integrand_JoRsq_cbc, &tmp_ctx, twrap, 0., 7, 1e-10); + return -integral.res; + } +} + +static double alpha_cbc(double r, double theta, double phi, void *ctx) +{ + double twrap = theta; + while (twrap < -M_PI) twrap += 2.*M_PI; + while (twrap > M_PI) twrap -= 2.*M_PI; + double integral_val = compute_alpha_integral_cbc(r, twrap, ctx); + double R = R_rtheta_cbc(r, theta, ctx); + double Bt = Bphi_cbc(R, ctx); + return phi - R*Bt*integral_val/dPsidr_cbc(r, theta, ctx); +} + +void bc_shift_func_lo_cbc(double t, const double *xc, double* GKYL_RESTRICT fout, void *ctx) +{ + struct gk_cbc_app_ctx *app = ctx; + double r = r_x_cbc(xc[0], app->r0); + fout[0] = app->Cy*(alpha_cbc(r, app->z_min, 0.0, ctx) - alpha_cbc(r, app->z_max, 0.0, ctx)); +} + +void bc_shift_func_up_cbc(double t, const double *xc, double* GKYL_RESTRICT fout, void *ctx) +{ + struct gk_cbc_app_ctx *app = ctx; + double r = r_x_cbc(xc[0], app->r0); + fout[0] = -app->Cy*(alpha_cbc(r, app->z_min, 0.0, ctx) - alpha_cbc(r, app->z_max, 0.0, ctx)); +} + +void init_donor_3x_cbc(double t, const double *xn, double* GKYL_RESTRICT fout, void *ctx) +{ + struct gk_cbc_app_ctx *app = ctx; + double x = xn[0], y = xn[1], z = xn[2]; + double sigx = app->Lx/7.0, sigy = app->Ly/7.0, sigz = app->Lz/10.0; + double mux = 0.*app->Lx; + fout[0] = exp(-pow(x-mux,2)/(2.*pow(sigx,2)) - pow(y,2)/(2.*pow(sigy,2)) - pow(z,2)/(2.*pow(sigz,2))); +} + +void +test_bc_twistshift_3x_cbc_wcells(const int *cells, enum gkyl_edge_loc edge, + bool check_distf, bool use_gpu, bool write_f) +{ + int bc_dir = 2; + int poly_order = 1; + + // Physical parameters matching rt_gk_cbc_passive_3x2v_p1.c create_ctx(). + double eV = GKYL_ELEMENTARY_CHARGE; + double mp = GKYL_PROTON_MASS; + double qi = eV; + double mi = mp; // AMU = 1 (hydrogen) + double Te0 = 2000.*eV; + + double R_axis = 1.6714; + double B_axis = 1.54; + double a_mid = 0.604; + double R0 = R_axis + 0.5*a_mid; + double r0 = 0.5*a_mid; + double B0 = B_axis*(R_axis/R0); + double qaxis = 1.2; + double qlcfs = 2.0; + + double c_s = sqrt(Te0/mi); + double omega_ci = fabs(qi*B0/mi); + double rho_s = c_s/omega_ci; + double q0 = qprofile_cbc(r0, a_mid, qaxis, qlcfs); + double Cy = r0/q0; + + double Lx = 150.*rho_s; + double Ly = 150.*rho_s; + Ly = 2.*M_PI*Cy/round(2.*M_PI*Cy/Ly); // adjust to integer toroidal mode number + double Lz = 2.*M_PI - 1e-10; + + // Use a fixed LUT size sufficient for accurate geometry evaluation. + int psi_lut_size = 200; + + struct gk_cbc_app_ctx app_ctx = { + .a_shift = 0.0, .Z_axis = 0.0, + .R_axis = R_axis, .R0 = R0, .a_mid = a_mid, .r0 = r0, + .B0 = B0, .kappa = 1.0, .delta = 0.0, + .q0 = q0, .Cy = Cy, .qaxis = qaxis, .qlcfs = qlcfs, + .Lx = Lx, .Ly = Ly, .Lz = Lz, + .x_min = -Lx/2., .x_max = Lx/2., + .y_min = -Ly/2., .y_max = Ly/2., + .z_min = -Lz/2., .z_max = Lz/2., + .psi_lut_size = psi_lut_size, + }; + + // Populate lookup tables (avoids redundant integration in geometry evaluations). + app_ctx.r_lut = gkyl_malloc(psi_lut_size*sizeof(double)); + app_ctx.dPsidr_int_lut = gkyl_malloc(psi_lut_size*sizeof(double)); + double r_lut_min = 0.0, r_lut_max = 2.0*a_mid; + for (int i=0; its_grid.lower[up->shift_dir_in_ts_grid], up->ts_grid.upper[up->shift_dir_in_ts_grid], false) }; // Shifted test point. int shift_dir_idx_test_pt[1]; -// gkyl_rect_grid_coord_idx(&up->shift_grid, shifted_test_pt, shift_dir_idx_test_pt); - bool pick_lower_arr[] = {pick_lower}; - gkyl_rect_grid_find_cell(&up->shift_grid, shifted_test_pt, pick_lower_arr, (int[]) {-1}, shift_dir_idx_test_pt); + gkyl_rect_grid_find_cell(&up->shift_grid, shifted_test_pt, (bool[]) {pick_lower}, (int[]) {-1}, shift_dir_idx_test_pt); // Get the linear index to the list of donors for this target. long linidx = ts_shift_dir_idx_do_linidx(up->num_do, @@ -257,7 +255,10 @@ ts_find_donors(struct gkyl_bc_twistshift *up) { // Find the donor cells for each target cell in the TS grid. - double delta_frac = 1.e-9; // Distance away from the boundary, as fraction of cell length. + double delta_frac = 1.e-4; // Distance away from the boundary, as fraction of cell length. + // Must be larger than the eps=1e-6 tolerance in is_in_cell (used by + // gkyl_rect_grid_find_cell) so that shifted test points are never + // ambiguously on a cell boundary. int num_test_pt[2] = {10, 10}; // Number of test points taken along each side of the cell. double step_sz[2] = {0.0}; // Size of the step between test points. @@ -326,6 +327,7 @@ ts_find_donors(struct gkyl_bc_twistshift *up) } up->num_do[shear_idx[0]-up->shear_r.lower[0]] = num_do_curr; + } // Copy the donor list to the persistent object and release the buffer. @@ -435,18 +437,17 @@ ts_donor_target_offset(struct gkyl_bc_twistshift *up, const double *xc_do, const struct gkyl_qr_res ts_find_intersect(struct gkyl_bc_twistshift *up, double shiftCoordTar, double shiftCoordDo, - const double *shearDirBounds, const double *shiftDirLimits) + const double *shearDirBounds, const double *shiftDirLimits, int nP_primary) { // Given a y-coordinate of the target cell (yTar), and a y-coordinate - // of the donor cell (yDo), find the x-coordinate of the point where - // the yTar-yShift(x) and y=yDo lines intersect. - // yTar: target cell y coordinate. - // yDo: donor cell y coordinate. - // xBounds: search in the interval [xBounds[1],xBounds[2]]. - // yLims: lower and upper limits of the grid. - // If y-yShift-yDo=0 has no roots, it is possible that y-yShift intersects a periodic - // copy of this domain. Check for such cases by looking for the roots of - // yTar-yShift-(yDo-N*Ly)=0 where Ly is the length of the domain along y and N is an integer. + // of the donor cell (yDo), find the x-coordinate where yTar-yShift(x)=yDo + // for the periodic copy identified by nP_primary, i.e. the root of + // yTar - yShift(x) - (yDo - nP_primary*Ly) = 0 in [shearDirBounds[0], shearDirBounds[1]]. + // Returns status=1 (not found) if no root exists for that specific nP_primary. + // + // nP_primary must be the same for all 4 inter_pts of a donor-target pair: all four + // intersection conditions describe corners of a single physical overlap diamond and + // therefore belong to the same periodic copy of the domain. double tol = 1.e-13; int max_iter = 100; @@ -456,52 +457,11 @@ ts_find_intersect(struct gkyl_bc_twistshift *up, double shiftCoordTar, double sh .shiftCoordTar = shiftCoordTar, .shiftCoordDo = shiftCoordDo, .shiftDirL = shiftDirL, - .periodicCopyIdx = 0, + .periodicCopyIdx = nP_primary, .shift_func = up->shift_func, .shift_func_ctx = up->shift_func_ctx, }; - struct gkyl_qr_res rootfind_res = ts_root_find(ts_shifted_coord_loss_func, &func_ctx, - shearDirBounds, max_iter, tol); - - if (rootfind_res.status == 1) { - // Maybe yTar-ySh intersects y=yDo in a periodic copy of the domain. Find roots of - // yTar-ySh-(yDo-nP*Ly)=0 where Ly is the y-length of the domain and nP is an integer. - - // Evaluate yTar-ySh at some points in [xBounds.lo,xBounds.up] and obtain potential nP's. - int num_steps = 10; - double step_sz = (shearDirBounds[1]-shearDirBounds[0])/num_steps; - int nP[num_steps+1], num_unique_nP = 0; - for (int sI=0; sIshift_func(0.0, (double[]){xp}, &xp_shift, up->shift_func_ctx); - - double ex_shift = xp_shift<0.? ((shiftCoordTar-xp_shift)-shiftDirLimits[0])/shiftDirL - : (shiftDirLimits[1]-(shiftCoordTar-xp_shift))/shiftDirL; - double nP_new = ts_sign(xp_shift)*floor(fabs(ex_shift)); - // If we haven't accounted for this nP, add it to our list. - bool nP_not_found = true; - for (int n=0; nkernels->ylimdg(1.0, xi_b[0], xi_b[1], etalo_xi, etaup_xi, - up->ts_grid.dx[up->shift_dir_in_ts_grid], xs_off, shift_c, mat_do); + if (fabs(xi_b[1] - xi_b[0]) > tol_xi) + up->kernels->ylimdg(1.0, xi_b[0], xi_b[1], etalo_xi, etaup_xi, + up->ts_grid.dx[up->shift_dir_in_ts_grid], xs_off, shift_c, mat_do); // 2) Add the contribution of the right portion. xi_b[0] = ts_p2l(inter_pts[0].value, xc_do[up->shear_dir_in_ts_grid], up->ts_grid.dx[up->shear_dir_in_ts_grid]); @@ -727,8 +688,9 @@ ts_subcellint_sNi_sNii(struct gkyl_bc_twistshift *up, struct ts_val_found *inter ts_nod2mod_proj_1d(up, eta_lims[0], &eta_lims_ctx, xi_b, etalo_xi); ts_nod2mod_proj_1d(up, eta_lims[1], &eta_lims_ctx, xi_b, etaup_xi); - up->kernels->ylimdg(1.0, xi_b[0], xi_b[1], etalo_xi, etaup_xi, - up->ts_grid.dx[up->shift_dir_in_ts_grid], xs_off, shift_c, mat_do); + if (fabs(xi_b[1] - xi_b[0]) > tol_xi) + up->kernels->ylimdg(1.0, xi_b[0], xi_b[1], etalo_xi, etaup_xi, + up->ts_grid.dx[up->shift_dir_in_ts_grid], xs_off, shift_c, mat_do); // 2) Add the contribution of the right portion. xi_b[0] = ts_p2l(inter_pts[3].value, xc_do[up->shear_dir_in_ts_grid], up->ts_grid.dx[up->shear_dir_in_ts_grid]); @@ -930,8 +892,9 @@ ts_subcellint_sv_svi(struct gkyl_bc_twistshift *up, struct ts_val_found *inter_p ts_nod2mod_proj_1d(up, eta_lims[0], &eta_lims_ctx, xi_b, etalo_xi); ts_nod2mod_proj_1d(up, eta_lims[1], &eta_lims_ctx, xi_b, etaup_xi); - up->kernels->ylimdg(1.0, xi_b[0], xi_b[1], etalo_xi, etaup_xi, - up->ts_grid.dx[up->shift_dir_in_ts_grid], xs_off, shift_c, mat_do); + if (fabs(xi_b[1] - xi_b[0]) > tol_xi) + up->kernels->ylimdg(1.0, xi_b[0], xi_b[1], etalo_xi, etaup_xi, + up->ts_grid.dx[up->shift_dir_in_ts_grid], xs_off, shift_c, mat_do); // 2) Add the contribution of the right portion. xi_b[0] = ts_p2l(inter_pts[0].value, xc_do[up->shear_dir_in_ts_grid], up->ts_grid.dx[up->shear_dir_in_ts_grid]); @@ -961,8 +924,9 @@ ts_subcellint_sv_svi(struct gkyl_bc_twistshift *up, struct ts_val_found *inter_p ts_nod2mod_proj_1d(up, eta_lims[0], &eta_lims_ctx, xi_b, etalo_xi); ts_nod2mod_proj_1d(up, eta_lims[1], &eta_lims_ctx, xi_b, etaup_xi); - up->kernels->ylimdg(1.0, xi_b[0], xi_b[1], etalo_xi, etaup_xi, - up->ts_grid.dx[up->shift_dir_in_ts_grid], xs_off, shift_c, mat_do); + if (fabs(xi_b[1] - xi_b[0]) > tol_xi) + up->kernels->ylimdg(1.0, xi_b[0], xi_b[1], etalo_xi, etaup_xi, + up->ts_grid.dx[up->shift_dir_in_ts_grid], xs_off, shift_c, mat_do); // 2) Add the contribution of the right portion. xi_b[0] = ts_p2l(inter_pts[3].value, xc_do[up->shear_dir_in_ts_grid], up->ts_grid.dx[up->shear_dir_in_ts_grid]); @@ -1418,6 +1382,24 @@ ts_calc_mats(struct gkyl_bc_twistshift *up) for (int i=0; ishear_r.lower[0]; i++) linidx_mats_do += up->num_do[i]; + // Check that the shift variation within this x-cell < Ly. + // The algorithm assumes at most one x-intersection per (y-boundary, y-boundary) pair, + // which breaks when |S(x_up) - S(x_lo)| >= Ly. + double x_lo = cellb_tar[cellb_lo(up->shear_dir_in_ts_grid)]; + double x_up = cellb_tar[cellb_up(up->shear_dir_in_ts_grid)]; + double Ly = shift_dir_lims[1] - shift_dir_lims[0]; + double S_lo, S_up, S_c; + up->shift_func(0.0, (double[]){x_lo}, &S_lo, up->shift_func_ctx); + up->shift_func(0.0, (double[]){x_up}, &S_up, up->shift_func_ctx); + up->shift_func(0.0, (double[]){xc_tar[up->shear_dir_in_ts_grid]}, &S_c, up->shift_func_ctx); + + if (fabs(S_up - S_lo) >= Ly) { + fprintf(stderr, "bc_twistshift: shift variation |S(x_up)-S(x_lo)| = %g across a single x-cell" + " exceeds Ly = %g (cell ix=%d). Increase Nx, reduce the shear, or increase Ly.\n", + fabs(S_up - S_lo), Ly, iter.idx[0]); + assert(false); + } + for (int iC=0; iCnum_do[iter.idx[0]-up->shear_r.lower[0]]; iC++){ int idx_do[2]; // Target index. idx_do[up->shift_dir_in_ts_grid] = shift_dir_idx_do_ptr[iC]; @@ -1431,6 +1413,11 @@ ts_calc_mats(struct gkyl_bc_twistshift *up) // Get the matrix we are presently assigning. struct gkyl_mat mat_do = gkyl_nmat_get(matsdo, linidx_mats_do+iC); + // Periodic copy in which to find the target for this donor-target pair: the integer nP such that + // S_c \approx y_tar_c - y_do_c + nP*Ly. All 4 inter_pts must use this same nP so that only + // roots from the physical intersection are accepted (not roots from other periodic copies). + int nP_primary = (int)round((S_c - (xc_tar[up->shift_dir_in_ts_grid] - xc_do[up->shift_dir_in_ts_grid])) / Ly); + // Find the points where y_{j_tar-/+1/2}-yShift intersect the y=y_{j_do-/+1/2} lines. // Also record the number and indices of points found/not found. struct ts_val_found inter_pts[4] = {}; @@ -1442,7 +1429,7 @@ ts_calc_mats(struct gkyl_bc_twistshift *up) double shift_dir_coord_do = cellb_do[2*up->shift_dir_in_ts_grid+j]; struct gkyl_qr_res inter_res = ts_find_intersect(up, shift_dir_coord_tar, shift_dir_coord_do, (double[]) {cellb_tar[cellb_lo(up->shear_dir_in_ts_grid)],cellb_tar[cellb_up(up->shear_dir_in_ts_grid)]}, - shift_dir_lims); + shift_dir_lims, nP_primary); int ip_linc = i*2+j; inter_pts[ip_linc].status = inter_res.status == 0; if (inter_res.status == 0) { @@ -1717,7 +1704,7 @@ gkyl_bc_twistshift_choose_kernels(struct gkyl_basis basis, int cdim, int shift_p } struct gkyl_bc_twistshift* -gkyl_bc_twistshift_new(const struct gkyl_bc_twistshift_inp *inp) +gkyl_bc_twistshift_inew(const struct gkyl_bc_twistshift_inp *inp) { // Allocate space for new updater. @@ -1727,18 +1714,18 @@ gkyl_bc_twistshift_new(const struct gkyl_bc_twistshift_inp *inp) up->shift_dir = inp->shift_dir; up->shear_dir = inp->shear_dir; up->edge = inp->edge; - up->basis = inp->basis; - up->grid = inp->grid; + up->basis = *inp->basis; + up->grid = *inp->grid; up->use_gpu = inp->use_gpu; - up->local_bcdir_ext_r = inp->bcdir_ext_update_r; + up->local_bcdir_ext_r = *inp->bcdir_ext_update_r; // Assume the poly order of the DG shift is the same as that of the field, // unless requested otherwise. - up->shift_poly_order = inp->basis.poly_order; + up->shift_poly_order = inp->basis->poly_order; if (inp->shift_poly_order) up->shift_poly_order = inp->shift_poly_order; - const int ndim = inp->bcdir_ext_update_r.ndim; + const int ndim = inp->bcdir_ext_update_r->ndim; // Check that it is being used for 3D or 5D. Likely only small changes are // needed to make it work in other dimensions. assert(ndim == 3 || ndim == 5); @@ -1748,9 +1735,9 @@ gkyl_bc_twistshift_new(const struct gkyl_bc_twistshift_inp *inp) // Create 1D grid and range in the direction of the shear. gkyl_range_init(&up->shear_r, 1, (int[]) {up->local_bcdir_ext_r.lower[inp->shear_dir]}, (int[]) {up->local_bcdir_ext_r.upper[inp->shear_dir]}); - lo1d[0] = inp->grid.lower[up->shear_dir]; - up1d[0] = inp->grid.upper[up->shear_dir]; - cells1d[0] = inp->grid.cells[up->shear_dir]; + lo1d[0] = inp->grid->lower[up->shear_dir]; + up1d[0] = inp->grid->upper[up->shear_dir]; + cells1d[0] = inp->grid->cells[up->shear_dir]; gkyl_rect_grid_init(&up->shear_grid, 1, lo1d, up1d, cells1d); int idx[] = {up->shear_r.lower[0]}; long linidx = gkyl_range_idx(&up->shear_r, idx); @@ -1758,9 +1745,9 @@ gkyl_bc_twistshift_new(const struct gkyl_bc_twistshift_inp *inp) // Create 1D grid and range in the diretion of the shift. gkyl_range_init(&up->shift_r, 1, (int[]) {up->local_bcdir_ext_r.lower[inp->shift_dir]}, (int[]) {up->local_bcdir_ext_r.upper[inp->shift_dir]}); - lo1d[0] = inp->grid.lower[up->shift_dir]; - up1d[0] = inp->grid.upper[up->shift_dir]; - cells1d[0] = inp->grid.cells[up->shift_dir]; + lo1d[0] = inp->grid->lower[up->shift_dir]; + up1d[0] = inp->grid->upper[up->shift_dir]; + cells1d[0] = inp->grid->cells[up->shift_dir]; gkyl_rect_grid_init(&up->shift_grid, 1, lo1d, up1d, cells1d); // Create 2D grid (and range) the twist-shift takes place in. @@ -1779,9 +1766,9 @@ gkyl_bc_twistshift_new(const struct gkyl_bc_twistshift_inp *inp) } gkyl_range_init(&up->ts_r, 2, (int[]) {up->local_bcdir_ext_r.lower[dimlo], up->local_bcdir_ext_r.lower[dimup]}, (int[]) {up->local_bcdir_ext_r.upper[dimlo], up->local_bcdir_ext_r.upper[dimup]}); - double lo2d[] = {inp->grid.lower[dimlo], inp->grid.lower[dimup]}; - double up2d[] = {inp->grid.upper[dimlo], inp->grid.upper[dimup]}; - int cells2d[] = {inp->grid.cells[dimlo], inp->grid.cells[dimup]}; + double lo2d[] = {inp->grid->lower[dimlo], inp->grid->lower[dimup]}; + double up2d[] = {inp->grid->upper[dimlo], inp->grid->upper[dimup]}; + int cells2d[] = {inp->grid->cells[dimlo], inp->grid->cells[dimup]}; gkyl_rect_grid_init(&up->ts_grid, 2, lo2d, up2d, cells2d); // Project the shift onto the shift basis. @@ -1841,7 +1828,7 @@ gkyl_bc_twistshift_new(const struct gkyl_bc_twistshift_inp *inp) // Choose the kernels that do the subcell and full cell integrals up->kernels = gkyl_malloc(sizeof(struct gkyl_bc_twistshift_kernels)); - gkyl_bc_twistshift_choose_kernels(inp->basis, inp->cdim, up->shift_poly_order, up->kernels); + gkyl_bc_twistshift_choose_kernels(*inp->basis, inp->cdim, up->shift_poly_order, up->kernels); // The BC is applied as a set of matrix-matrix multiplications // f_i = sum_{q}^{N_do(i)} A_q,i B_q,i @@ -1911,6 +1898,31 @@ gkyl_bc_twistshift_new(const struct gkyl_bc_twistshift_inp *inp) return up; } +struct gkyl_bc_twistshift* +gkyl_bc_twistshift_new(int bc_dir, int shift_dir, int shear_dir, + enum gkyl_edge_loc edge, int cdim, const struct gkyl_range *bcdir_ext_update_r, const int *num_ghost, + const struct gkyl_basis *basis, const struct gkyl_rect_grid *grid, evalf_t shift_func, void *shift_func_ctx, + struct gkyl_array *shift_dg, int shift_poly_order, bool use_gpu) +{ + struct gkyl_bc_twistshift_inp inp = { + .bc_dir = bc_dir , + .shift_dir = shift_dir , + .shear_dir = shear_dir , + .edge = edge , + .cdim = cdim , + .bcdir_ext_update_r = bcdir_ext_update_r, + .num_ghost = num_ghost , + .basis = basis , + .grid = grid , + .shift_func = shift_func , + .shift_func_ctx = shift_func_ctx , + .shift_dg = shift_dg , + .use_gpu = use_gpu , + .shift_poly_order = shift_poly_order , + }; + return gkyl_bc_twistshift_inew(&inp); +} + void gkyl_bc_twistshift_advance(struct gkyl_bc_twistshift *up, struct gkyl_array *fdo, struct gkyl_array *ftar) { diff --git a/gyrokinetic/zero/dg_gyrokinetic_passive.c b/gyrokinetic/zero/dg_gyrokinetic_passive.c new file mode 100644 index 0000000000..4e63001d8f --- /dev/null +++ b/gyrokinetic/zero/dg_gyrokinetic_passive.c @@ -0,0 +1,114 @@ +#include "gkyl_dg_eqn.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +void +gkyl_gyrokinetic_passive_free(const struct gkyl_ref_count *ref) +{ + struct gkyl_dg_eqn *base = container_of(ref, struct gkyl_dg_eqn, ref_count); + struct dg_gyrokinetic_passive *gkp = container_of(base, struct dg_gyrokinetic_passive, eqn); + gkyl_gk_geometry_release(gkp->gk_geom); + gkyl_velocity_map_release(gkp->vel_map); + + if (gkyl_dg_eqn_is_cu_dev(base)) { + // free inner on_dev object + struct dg_gyrokinetic_passive *gkp_cu = container_of(base->on_dev, struct dg_gyrokinetic_passive, eqn); + gkyl_cu_free(gkp_cu); + } + + gkyl_free(gkp); +} + +void +gkyl_gyrokinetic_passive_set_auxfields(const struct gkyl_dg_eqn *eqn, + struct gkyl_dg_gyrokinetic_passive_auxfields auxin) +{ +#ifdef GKYL_HAVE_CUDA + if (gkyl_dg_eqn_is_cu_dev(eqn)) { + gkyl_gyrokinetic_passive_set_auxfields_cu(eqn->on_dev, auxin); + return; + } +#endif + struct dg_gyrokinetic_passive *gkp = container_of(eqn, struct dg_gyrokinetic_passive, eqn); + gkp->auxfields.flux_surf = auxin.flux_surf; + gkp->auxfields.speeds = auxin.speeds; +} + +struct gkyl_dg_eqn* +gkyl_dg_gyrokinetic_passive_new(const struct gkyl_basis *cbasis, const struct gkyl_basis *pbasis, + const struct gkyl_range *conf_range, const struct gkyl_range *phase_range, + const double charge, const double mass, + const struct gk_geometry *gk_geom, const struct gkyl_velocity_map *vel_map, + bool use_gpu) +{ +#ifdef GKYL_HAVE_CUDA + if (use_gpu) + return gkyl_dg_gyrokinetic_passive_cu_dev_new(cbasis, pbasis, conf_range, phase_range, + charge, mass, gk_geom, vel_map); +#endif + + struct dg_gyrokinetic_passive *gkp = gkyl_malloc(sizeof(struct dg_gyrokinetic_passive)); + + int cdim = cbasis->ndim; + int pdim = pbasis->ndim; + int vdim = pdim - cdim; + int poly_order = cbasis->poly_order; + + gkp->cdim = cdim; + gkp->pdim = pdim; + + gkp->charge = charge; + gkp->mass = mass; + + gkp->eqn.num_equations = 1; + gkp->eqn.surf_term = surf_passive; + gkp->eqn.boundary_surf_term = boundary_surf_passive; + gkp->eqn.boundary_diag_term = boundary_diag_passive; + + // Volume kernel. + gkp->eqn.vol_term = CK_PASSIVE(ser_passive_vol_kernels, cdim, vdim, poly_order); + + // Conf-space surface and boundary-surface kernels. + if (cdim >= 1) { + gkp->surf[0] = CK_PASSIVE(ser_passive_surf_x_kernels, cdim, vdim, poly_order); + gkp->boundary_surf[0] = CK_PASSIVE(ser_passive_boundary_surf_x_kernels, cdim, vdim, poly_order); + } + if (cdim >= 2) { + gkp->surf[1] = CK_PASSIVE(ser_passive_surf_y_kernels, cdim, vdim, poly_order); + gkp->boundary_surf[1] = CK_PASSIVE(ser_passive_boundary_surf_y_kernels, cdim, vdim, poly_order); + } + if (cdim >= 3) { + gkp->surf[2] = CK_PASSIVE(ser_passive_surf_z_kernels, cdim, vdim, poly_order); + gkp->boundary_surf[2] = CK_PASSIVE(ser_passive_boundary_surf_z_kernels, cdim, vdim, poly_order); + } + + // Ensure non-NULL pointers. + for (int i=0; isurf[i]); + assert(gkp->boundary_surf[i]); + } + + gkp->conf_range = *conf_range; + gkp->phase_range = *phase_range; + + gkp->gk_geom = gkyl_gk_geometry_acquire(gk_geom); + gkp->vel_map = gkyl_velocity_map_acquire(vel_map); + + gkp->auxfields.flux_surf = 0; + gkp->auxfields.speeds = 0; + + gkp->eqn.flags = 0; + GKYL_CLEAR_CU_ALLOC(gkp->eqn.flags); + gkp->eqn.ref_count = gkyl_ref_count_init(gkyl_gyrokinetic_passive_free); + gkp->eqn.on_dev = &gkp->eqn; + + return &gkp->eqn; +} diff --git a/gyrokinetic/zero/dg_gyrokinetic_passive_cu.cu b/gyrokinetic/zero/dg_gyrokinetic_passive_cu.cu new file mode 100644 index 0000000000..8260b272d0 --- /dev/null +++ b/gyrokinetic/zero/dg_gyrokinetic_passive_cu.cu @@ -0,0 +1,134 @@ +/* -*- c++ -*- */ +#include + +extern "C" { +#include +#include +#include +#include +} + +#include + +// CUDA kernel to set pointer to auxiliary fields. +// Required because the equation object lives on the device and its members +// cannot be modified without a __global__ kernel. +__global__ static void +gkyl_gyrokinetic_passive_set_auxfields_cu_kernel(const struct gkyl_dg_eqn *eqn, + const struct gkyl_array *flux_surf, const struct gkyl_array *speeds) +{ + struct dg_gyrokinetic_passive *gkp = container_of(eqn, struct dg_gyrokinetic_passive, eqn); + gkp->auxfields.flux_surf = flux_surf; + gkp->auxfields.speeds = speeds; +} + +// Host-side wrapper for gkyl_gyrokinetic_passive_set_auxfields_cu_kernel. +void +gkyl_gyrokinetic_passive_set_auxfields_cu(const struct gkyl_dg_eqn *eqn, + struct gkyl_dg_gyrokinetic_passive_auxfields auxin) +{ + gkyl_gyrokinetic_passive_set_auxfields_cu_kernel<<<1,1>>>(eqn, + auxin.flux_surf->on_dev, auxin.speeds->on_dev); +} + +// CUDA kernel to set device function pointers and zero auxfields. +// Doing function-pointer work here avoids troublesome cudaMemcpyFromSymbol. +__global__ static void +dg_gyrokinetic_passive_set_cu_dev_ptrs(struct dg_gyrokinetic_passive *gkp, + enum gkyl_basis_type b_type, int cv_index, int cdim, int vdim, int poly_order) +{ + gkp->auxfields.flux_surf = 0; + gkp->auxfields.speeds = 0; + + gkp->eqn.surf_term = surf_passive; + gkp->eqn.boundary_surf_term = boundary_surf_passive; + gkp->eqn.boundary_diag_term = boundary_diag_passive; + + const gkyl_dg_gyrokinetic_passive_vol_kern_list *vol_kernels; + const gkyl_dg_gyrokinetic_passive_surf_kern_list *surf_x_kernels; + const gkyl_dg_gyrokinetic_passive_surf_kern_list *surf_y_kernels; + const gkyl_dg_gyrokinetic_passive_surf_kern_list *surf_z_kernels; + const gkyl_dg_gyrokinetic_passive_boundary_surf_kern_list *boundary_surf_x_kernels; + const gkyl_dg_gyrokinetic_passive_boundary_surf_kern_list *boundary_surf_y_kernels; + const gkyl_dg_gyrokinetic_passive_boundary_surf_kern_list *boundary_surf_z_kernels; + + switch (b_type) { + case GKYL_BASIS_MODAL_SERENDIPITY: + vol_kernels = ser_passive_vol_kernels; + surf_x_kernels = ser_passive_surf_x_kernels; + surf_y_kernels = ser_passive_surf_y_kernels; + surf_z_kernels = ser_passive_surf_z_kernels; + boundary_surf_x_kernels = ser_passive_boundary_surf_x_kernels; + boundary_surf_y_kernels = ser_passive_boundary_surf_y_kernels; + boundary_surf_z_kernels = ser_passive_boundary_surf_z_kernels; + break; + + default: + assert(false); + break; + } + + gkp->eqn.vol_term = vol_kernels[cv_index].kernels[poly_order-1]; + + gkp->surf[0] = surf_x_kernels[cv_index].kernels[poly_order-1]; + gkp->boundary_surf[0] = boundary_surf_x_kernels[cv_index].kernels[poly_order-1]; + if (cdim > 1) { + gkp->surf[1] = surf_y_kernels[cv_index].kernels[poly_order-1]; + gkp->boundary_surf[1] = boundary_surf_y_kernels[cv_index].kernels[poly_order-1]; + } + if (cdim > 2) { + gkp->surf[2] = surf_z_kernels[cv_index].kernels[poly_order-1]; + gkp->boundary_surf[2] = boundary_surf_z_kernels[cv_index].kernels[poly_order-1]; + } +} + +struct gkyl_dg_eqn* +gkyl_dg_gyrokinetic_passive_cu_dev_new(const struct gkyl_basis *cbasis, const struct gkyl_basis *pbasis, + const struct gkyl_range *conf_range, const struct gkyl_range *phase_range, + const double charge, const double mass, + const struct gk_geometry *gk_geom, const struct gkyl_velocity_map *vel_map) +{ + struct dg_gyrokinetic_passive *gkp = (struct dg_gyrokinetic_passive*) gkyl_malloc(sizeof(*gkp)); + + int cdim = cbasis->ndim, pdim = pbasis->ndim, vdim = pdim - cdim; + int poly_order = cbasis->poly_order; + + gkp->cdim = cdim; + gkp->pdim = pdim; + + gkp->charge = charge; + gkp->mass = mass; + + gkp->eqn.num_equations = 1; + + // Acquire on_dev pointers so the memcpy below copies device references. + struct gk_geometry *geom_ho = gkyl_gk_geometry_acquire(gk_geom); + struct gkyl_velocity_map *vel_map_ho = gkyl_velocity_map_acquire(vel_map); + + gkp->gk_geom = geom_ho->on_dev; + gkp->vel_map = vel_map_ho->on_dev; + + gkp->conf_range = *conf_range; + gkp->phase_range = *phase_range; + + gkp->eqn.flags = 0; + GKYL_SET_CU_ALLOC(gkp->eqn.flags); + gkp->eqn.ref_count = gkyl_ref_count_init(gkyl_gyrokinetic_passive_free); + + // Copy host struct to device. + struct dg_gyrokinetic_passive *gkp_cu = + (struct dg_gyrokinetic_passive*) gkyl_cu_malloc(sizeof(struct dg_gyrokinetic_passive)); + gkyl_cu_memcpy(gkp_cu, gkp, sizeof(struct dg_gyrokinetic_passive), GKYL_CU_MEMCPY_H2D); + + dg_gyrokinetic_passive_set_cu_dev_ptrs<<<1,1>>>(gkp_cu, + cbasis->b_type, cv_index_gkp[cdim].vdim[vdim], cdim, vdim, poly_order); + + // Set on_dev pointer to the device struct. + gkp->eqn.on_dev = &gkp_cu->eqn; + + // Restore host-side geometry pointers for the updater. + gkp->gk_geom = geom_ho; + gkp->vel_map = vel_map_ho; + + return &gkp->eqn; +} diff --git a/gyrokinetic/zero/dg_updater_gyrokinetic_passive.c b/gyrokinetic/zero/dg_updater_gyrokinetic_passive.c new file mode 100644 index 0000000000..efdab7a4ff --- /dev/null +++ b/gyrokinetic/zero/dg_updater_gyrokinetic_passive.c @@ -0,0 +1,90 @@ +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +struct gkyl_dg_eqn* +gkyl_dg_updater_gyrokinetic_passive_acquire_eqn(const gkyl_dg_updater_gyrokinetic_passive* up) +{ + return gkyl_dg_eqn_acquire(up->eqn_gyrokinetic_passive); +} + +gkyl_dg_updater_gyrokinetic_passive* +gkyl_dg_updater_gyrokinetic_passive_new(const struct gkyl_rect_grid *grid, + const struct gkyl_basis *cbasis, const struct gkyl_basis *pbasis, + const struct gkyl_range *conf_range, const struct gkyl_range *phase_range, + const bool *is_zero_flux_bc, + const double charge, const double mass, + const struct gk_geometry *gk_geom, + const struct gkyl_velocity_map *vel_map, + void *aux_inp, bool use_gpu) +{ + struct gkyl_dg_updater_gyrokinetic_passive *up = + gkyl_malloc(sizeof(struct gkyl_dg_updater_gyrokinetic_passive)); + + up->use_gpu = use_gpu; + + // Create the passive GK equation object. + up->eqn_gyrokinetic_passive = gkyl_dg_gyrokinetic_passive_new(cbasis, pbasis, conf_range, phase_range, + charge, mass, gk_geom, vel_map, use_gpu); + + // Set auxiliary fields. + struct gkyl_dg_gyrokinetic_passive_auxfields *gkp_inp = aux_inp; + gkyl_gyrokinetic_passive_set_auxfields(up->eqn_gyrokinetic_passive, *gkp_inp); + + int cdim = cbasis->ndim; + int pdim = pbasis->ndim; + + // Update only conf-space directions (no vpar advection for passive type). + int up_dirs[GKYL_MAX_DIM] = {0}; + int num_up_dirs = cdim; + for (int d = 0; d < num_up_dirs; d++) up_dirs[d] = d; + + // Zero-flux flags: conf-space BCs from input. + int zero_flux_flags[2*GKYL_MAX_DIM] = {0}; + for (int d = 0; d < cdim; d++) { + zero_flux_flags[d] = is_zero_flux_bc[d] ? 1 : 0; + zero_flux_flags[d+pdim] = is_zero_flux_bc[d+pdim] ? 1 : 0; + } + for (int d = cdim; d < pdim; d++) + zero_flux_flags[d] = zero_flux_flags[d+pdim] = 1; // zero-flux BCs in vel-space + + up->up_gyrokinetic_passive = gkyl_hyper_dg_new(grid, pbasis, up->eqn_gyrokinetic_passive, + num_up_dirs, up_dirs, zero_flux_flags, 1, up->use_gpu); + + up->gyrokinetic_passive_tm = 0.0; + + return up; +} + +void +gkyl_dg_updater_gyrokinetic_passive_advance(gkyl_dg_updater_gyrokinetic_passive *up, + const struct gkyl_range *update_rng, const struct gkyl_array *fIn, + struct gkyl_array *cflrate, struct gkyl_array *rhs) +{ + struct timespec wst = gkyl_wall_clock(); + gkyl_hyper_dg_advance(up->up_gyrokinetic_passive, update_rng, fIn, cflrate, rhs); + up->gyrokinetic_passive_tm += gkyl_time_diff_now_sec(wst); +} + +struct gkyl_dg_updater_gyrokinetic_passive_tm +gkyl_dg_updater_gyrokinetic_passive_get_tm(const gkyl_dg_updater_gyrokinetic_passive *up) +{ + return (struct gkyl_dg_updater_gyrokinetic_passive_tm) { + .gyrokinetic_passive_tm = up->gyrokinetic_passive_tm, + }; +} + +void +gkyl_dg_updater_gyrokinetic_passive_release(gkyl_dg_updater_gyrokinetic_passive *up) +{ + gkyl_dg_eqn_release(up->eqn_gyrokinetic_passive); + gkyl_hyper_dg_release(up->up_gyrokinetic_passive); + gkyl_free(up); +} diff --git a/gyrokinetic/zero/gk_collisionless_passive_flux.c b/gyrokinetic/zero/gk_collisionless_passive_flux.c new file mode 100644 index 0000000000..d1a022d445 --- /dev/null +++ b/gyrokinetic/zero/gk_collisionless_passive_flux.c @@ -0,0 +1,183 @@ +#include +#include + +#include +#include +#include +#include +#include +#include + +gkyl_gk_collisionless_passive_flux* +gkyl_gk_collisionless_passive_flux_new(const struct gkyl_rect_grid *phase_grid, + const struct gkyl_basis *conf_basis, const struct gkyl_basis *phase_basis, + const struct gkyl_array *passive_speeds, + const double charge, const double mass, + const struct gk_geometry *gk_geom, const struct gkyl_dg_geom *dg_geom, + const struct gkyl_gk_dg_geom *gk_dg_geom, const struct gkyl_velocity_map *vel_map, + const enum gkyl_gyrokinetic_bc_type *bctype_conf, bool use_gpu) +{ +#ifdef GKYL_HAVE_CUDA + if (use_gpu) + return gkyl_gk_collisionless_passive_flux_cu_dev_new(phase_grid, conf_basis, phase_basis, + passive_speeds, charge, mass, gk_geom, dg_geom, gk_dg_geom, vel_map, bctype_conf); +#endif + + gkyl_gk_collisionless_passive_flux *up = gkyl_malloc(sizeof(gkyl_gk_collisionless_passive_flux)); + + up->phase_grid = *phase_grid; + int cdim = conf_basis->ndim; + int pdim = phase_basis->ndim; + int vdim = pdim - cdim; + int poly_order = phase_basis->poly_order; + up->cdim = cdim; + up->pdim = pdim; + + up->charge = charge; + up->mass = mass; + + // Store pointers to the projected passive-speed arrays (not owned here). + up->passive_speeds = passive_speeds; + + up->gk_geom = gkyl_gk_geometry_acquire(gk_geom); + up->dg_geom = gkyl_dg_geom_acquire(dg_geom); + up->gk_dg_geom = gkyl_gk_dg_geom_acquire(gk_dg_geom); + up->vel_map = gkyl_velocity_map_acquire(vel_map); + + // Select kernels for each conf-space direction. + for (int d = 0; d < cdim; d++) { + up->flux_surf[d] = choose_gk_collisionless_passive_flux_surf_conf_kern(d, cdim, vdim, poly_order); + up->flux_surf_edge_lo[d] = choose_gk_collisionless_passive_flux_edge_lo_surf_conf_kern(d, cdim, vdim, poly_order, bctype_conf[d]); + up->flux_surf_edge_up[d] = choose_gk_collisionless_passive_flux_edge_up_surf_conf_kern(d, cdim, vdim, poly_order, bctype_conf[GKYL_MAX_CDIM+d]); + } + + up->flags = 0; + GKYL_CLEAR_CU_ALLOC(up->flags); + up->on_dev = up; // self-reference on host + + return up; +} + +void +gkyl_gk_collisionless_passive_flux_surf(gkyl_gk_collisionless_passive_flux *up, + const struct gkyl_range *conf_range, const struct gkyl_range *phase_range, + const struct gkyl_range *conf_ext_range, const struct gkyl_range *phase_ext_range, + const struct gkyl_array *fin, + struct gkyl_array *flux_surf, struct gkyl_array *cflrate) +{ +#ifdef GKYL_HAVE_CUDA + if (GKYL_IS_CU_ALLOC(up->flags)) { + gkyl_gk_collisionless_passive_flux_surf_cu(up, conf_range, phase_range, + conf_ext_range, phase_ext_range, fin, flux_surf, cflrate); + return; + } +#endif + int pdim = up->pdim; + int cdim = up->cdim; + int idx[GKYL_MAX_DIM], idx_ghost[GKYL_MAX_DIM]; + int idxL[GKYL_MAX_DIM]; + int idx_vel[2]; + double xc[GKYL_MAX_DIM]; + + struct gkyl_range_iter iter; + gkyl_range_iter_init(&iter, phase_range); + while (gkyl_range_iter_next(&iter)) { + gkyl_copy_int_arr(pdim, iter.idx, idx); + + for (int d = cdim; d < pdim; d++) idx_vel[d-cdim] = iter.idx[d]; + + long loc_conf = gkyl_range_idx(conf_range, idx); + long loc_vel = gkyl_range_idx(&up->vel_map->local_vel, idx_vel); + long loc_phase = gkyl_range_idx(phase_range, idx); + + gkyl_rect_grid_cell_center(&up->phase_grid, idx, xc); + + const double *bmag_d = gkyl_array_cfetch(up->gk_geom->geo_corn.bmag, loc_conf); + const double *vmap_d = gkyl_array_cfetch(up->vel_map->vmap, loc_vel); + const double *vmapSq_d = gkyl_array_cfetch(up->vel_map->vmap_sq, loc_vel); + + double *flux_surf_d = gkyl_array_fetch(flux_surf, loc_phase); + double *cflrate_d = gkyl_array_fetch(cflrate, loc_phase); + + for (int dir = 0; dir < cdim; dir++) { + gkyl_copy_int_arr(pdim, idx, idxL); + idxL[dir] = idx[dir] - 1; + long loc_confL = gkyl_range_idx(conf_range, idxL); + long locL = gkyl_range_idx(phase_range, idxL); + const double *fL = gkyl_array_cfetch(fin, locL); + const double *fR = gkyl_array_cfetch(fin, loc_phase); + + const struct gkyl_dg_surf_geom *dgs = gkyl_dg_geom_get_surf(up->dg_geom, dir, idx); + const struct gkyl_gk_dg_surf_geom *gkdgs = gkyl_gk_dg_geom_get_surf(up->gk_dg_geom, dir, idx); + + const double *jacgeo_rat_surfL_d = gkyl_array_cfetch(up->gk_geom->geo_surf[dir].jacobgeo_ratio, loc_confL); + const double *jacgeo_rat_surfR_d = gkyl_array_cfetch(up->gk_geom->geo_surf[dir].jacobgeo_ratio, loc_conf); + + // Fetch passive speed DG coefficients at the left and right conf cells. + const double *speeds_L = gkyl_array_cfetch(up->passive_speeds, loc_confL); + const double *speeds_R = gkyl_array_cfetch(up->passive_speeds, loc_conf); + + if (idx[dir] == phase_range->lower[dir]) { + // Lower domain boundary. + cflrate_d[0] += up->flux_surf_edge_lo[dir](xc, up->phase_grid.dx, + vmap_d, vmapSq_d, up->charge, up->mass, + dgs, gkdgs, bmag_d, jacgeo_rat_surfL_d, jacgeo_rat_surfR_d, + speeds_L, speeds_R, fL, fR, flux_surf_d); + } else { + // Interior lower surface. + cflrate_d[0] += up->flux_surf[dir](xc, up->phase_grid.dx, + vmap_d, vmapSq_d, up->charge, up->mass, + dgs, gkdgs, bmag_d, jacgeo_rat_surfL_d, jacgeo_rat_surfR_d, + speeds_L, speeds_R, fL, fR, flux_surf_d); + } + + // Upper domain boundary: also compute the upper-edge surface expansion + // (stored in the ghost cell) to avoid evaluating geometry in ghost cells. + if (idx[dir] == phase_range->upper[dir]) { + gkyl_copy_int_arr(pdim, idx, idx_ghost); + idx_ghost[dir] += 1; + long loc_conf_ghost = gkyl_range_idx(conf_ext_range, idx_ghost); + long loc_phase_ghost = gkyl_range_idx(phase_ext_range, idx_ghost); + + double *cflrate_ghost_d = gkyl_array_fetch(cflrate, loc_phase_ghost); + const double *f_skin = gkyl_array_cfetch(fin, loc_phase); + const double *f_ghost = gkyl_array_cfetch(fin, loc_phase_ghost); + + const struct gkyl_dg_surf_geom *dgs_ghost = gkyl_dg_geom_get_surf(up->dg_geom, dir, idx_ghost); + const struct gkyl_gk_dg_surf_geom *gkdgs_ghost = gkyl_gk_dg_geom_get_surf(up->gk_dg_geom, dir, idx_ghost); + + const double *jacgeo_rat_surf_skin = gkyl_array_cfetch(up->gk_geom->geo_surf[dir].jacobgeo_ratio, loc_conf); + const double *jacgeo_rat_surf_ghost = gkyl_array_cfetch(up->gk_geom->geo_surf[dir].jacobgeo_ratio, loc_conf_ghost); + + // Passive speeds at the upper edge: right cell is the ghost cell, + // so use the skin-cell speed for both sides (speeds are not defined in ghosts). + const double *speeds_skin = gkyl_array_cfetch(up->passive_speeds, loc_conf); + const double *speeds_ghost = gkyl_array_cfetch(up->passive_speeds, loc_conf_ghost); + + double *flux_surf_ghost_d = gkyl_array_fetch(flux_surf, loc_phase_ghost); + + cflrate_ghost_d[0] += up->flux_surf_edge_up[dir](xc, up->phase_grid.dx, + vmap_d, vmapSq_d, up->charge, up->mass, + dgs_ghost, gkdgs_ghost, bmag_d, + jacgeo_rat_surf_skin, jacgeo_rat_surf_ghost, + speeds_skin, speeds_ghost, + f_skin, f_ghost, flux_surf_ghost_d); + + } + } + // No vpar loop: passive advection has no velocity-space component. + } +} + +void +gkyl_gk_collisionless_passive_flux_release(gkyl_gk_collisionless_passive_flux *up) +{ + gkyl_gk_geometry_release(up->gk_geom); + gkyl_dg_geom_release(up->dg_geom); + gkyl_gk_dg_geom_release(up->gk_dg_geom); + gkyl_velocity_map_release(up->vel_map); + + if (GKYL_IS_CU_ALLOC(up->flags)) + gkyl_cu_free(up->on_dev); + gkyl_free(up); +} diff --git a/gyrokinetic/zero/gk_collisionless_passive_flux_cu.cu b/gyrokinetic/zero/gk_collisionless_passive_flux_cu.cu new file mode 100644 index 0000000000..78b60a340c --- /dev/null +++ b/gyrokinetic/zero/gk_collisionless_passive_flux_cu.cu @@ -0,0 +1,205 @@ +/* -*- c++ -*- */ + +#include +#include +#include + +extern "C" { +#include +#include +#include +#include +#include +#include +} + +__global__ void +gkyl_gk_collisionless_passive_flux_surf_conf_cu_kernel(struct gkyl_gk_collisionless_passive_flux *up, + struct gkyl_range conf_range, struct gkyl_range phase_range, + struct gkyl_range conf_ext_range, struct gkyl_range phase_ext_range, + const struct gkyl_array *fin, + struct gkyl_array *flux_surf, struct gkyl_array *cflrate) +{ + int pdim = up->pdim; + int cdim = up->cdim; + int idx[GKYL_MAX_DIM], idx_ghost[GKYL_MAX_DIM], idx_vel[2]; + int idxL[GKYL_MAX_DIM]; + double xc[GKYL_MAX_DIM]; + + for (unsigned long linc1 = threadIdx.x + blockIdx.x*blockDim.x; + linc1 < phase_range.volume; + linc1 += gridDim.x*blockDim.x) + { + gkyl_sub_range_inv_idx(&phase_range, linc1, idx); + gkyl_rect_grid_cell_center(&up->phase_grid, idx, xc); + + for (int d = cdim; d < pdim; d++) idx_vel[d-cdim] = idx[d]; + + long loc_conf = gkyl_range_idx(&conf_range, idx); + long loc_vel = gkyl_range_idx(&up->vel_map->local_vel, idx_vel); + long loc_phase = gkyl_range_idx(&phase_range, idx); + + const double *bmag_d = (const double*) gkyl_array_cfetch(up->gk_geom->geo_corn.bmag, loc_conf); + const double *vmap_d = (const double*) gkyl_array_cfetch(up->vel_map->vmap, loc_vel); + const double *vmapSq_d = (const double*) gkyl_array_cfetch(up->vel_map->vmap_sq, loc_vel); + + double *flux_surf_d = (double*) gkyl_array_fetch(flux_surf, loc_phase); + double *cflrate_d = (double*) gkyl_array_fetch(cflrate, loc_phase); + + for (int dir = 0; dir < cdim; dir++) { + gkyl_copy_int_arr(pdim, idx, idxL); + idxL[dir] = idx[dir] - 1; + long loc_confL = gkyl_range_idx(&conf_range, idxL); + long locL = gkyl_range_idx(&phase_range, idxL); + const double *fL = (const double*) gkyl_array_cfetch(fin, locL); + const double *fR = (const double*) gkyl_array_cfetch(fin, loc_phase); + + const struct gkyl_dg_surf_geom *dgs = gkyl_dg_geom_get_surf(up->dg_geom, dir, idx); + const struct gkyl_gk_dg_surf_geom *gkdgs = gkyl_gk_dg_geom_get_surf(up->gk_dg_geom, dir, idx); + + const double *jacgeo_rat_surfL_d = (const double*) gkyl_array_cfetch(up->gk_geom->geo_surf[dir].jacobgeo_ratio, loc_confL); + const double *jacgeo_rat_surfR_d = (const double*) gkyl_array_cfetch(up->gk_geom->geo_surf[dir].jacobgeo_ratio, loc_conf); + + const double *speeds_L = (const double*) gkyl_array_cfetch(up->passive_speeds, loc_confL); + const double *speeds_R = (const double*) gkyl_array_cfetch(up->passive_speeds, loc_conf); + + if (idx[dir] == phase_range.lower[dir]) { + // Lower domain/block boundary. + cflrate_d[0] += up->flux_surf_edge_lo[dir](xc, up->phase_grid.dx, + vmap_d, vmapSq_d, up->charge, up->mass, + dgs, gkdgs, bmag_d, jacgeo_rat_surfL_d, jacgeo_rat_surfR_d, + speeds_L, speeds_R, fL, fR, flux_surf_d); + } else { + // Interior, lower cell surface. + cflrate_d[0] += up->flux_surf[dir](xc, up->phase_grid.dx, + vmap_d, vmapSq_d, up->charge, up->mass, + dgs, gkdgs, bmag_d, jacgeo_rat_surfL_d, jacgeo_rat_surfR_d, + speeds_L, speeds_R, fL, fR, flux_surf_d); + } + + // Upper domain boundary: compute the upper-edge surface expansion stored + // in the ghost cell so we avoid reading geometry from ghost cells. + if (idx[dir] == phase_range.upper[dir]) { + gkyl_copy_int_arr(pdim, idx, idx_ghost); + idx_ghost[dir] = idx_ghost[dir] + 1; + long loc_conf_ghost = gkyl_range_idx(&conf_ext_range, idx_ghost); + long loc_phase_ghost = gkyl_range_idx(&phase_ext_range, idx_ghost); + + double *cflrate_ghost_d = (double*) gkyl_array_fetch(cflrate, loc_phase_ghost); + const double *f_skin = (const double*) gkyl_array_cfetch(fin, loc_phase); + const double *f_ghost = (const double*) gkyl_array_cfetch(fin, loc_phase_ghost); + + const struct gkyl_dg_surf_geom *dgs_ghost = gkyl_dg_geom_get_surf(up->dg_geom, dir, idx_ghost); + const struct gkyl_gk_dg_surf_geom *gkdgs_ghost = gkyl_gk_dg_geom_get_surf(up->gk_dg_geom, dir, idx_ghost); + + const double *jacgeo_rat_surf_skin = (const double*) gkyl_array_cfetch(up->gk_geom->geo_surf[dir].jacobgeo_ratio, loc_conf); + const double *jacgeo_rat_surf_ghost = (const double*) gkyl_array_cfetch(up->gk_geom->geo_surf[dir].jacobgeo_ratio, loc_conf_ghost); + + const double *speeds_skin = (const double*) gkyl_array_cfetch(up->passive_speeds, loc_conf); + const double *speeds_ghost = (const double*) gkyl_array_cfetch(up->passive_speeds, loc_conf_ghost); + + double *flux_surf_ghost_d = (double*) gkyl_array_fetch(flux_surf, loc_phase_ghost); + + cflrate_ghost_d[0] += up->flux_surf_edge_up[dir](xc, up->phase_grid.dx, + vmap_d, vmapSq_d, up->charge, up->mass, + dgs_ghost, gkdgs_ghost, bmag_d, + jacgeo_rat_surf_skin, jacgeo_rat_surf_ghost, + speeds_skin, speeds_ghost, + f_skin, f_ghost, flux_surf_ghost_d); + } + } + // No vpar loop: passive advection is conf-space only. + } +} + +// Host-side wrapper for the passive surface flux kernel. +void +gkyl_gk_collisionless_passive_flux_surf_cu(gkyl_gk_collisionless_passive_flux *up, + const struct gkyl_range *conf_range, const struct gkyl_range *phase_range, + const struct gkyl_range *conf_ext_range, const struct gkyl_range *phase_ext_range, + const struct gkyl_array *fin, + struct gkyl_array *flux_surf, struct gkyl_array *cflrate) +{ + gkyl_gk_collisionless_passive_flux_surf_conf_cu_kernel<<volume, GKYL_DEFAULT_NUM_THREADS>>>( + up->on_dev, *conf_range, *phase_range, *conf_ext_range, *phase_ext_range, + fin->on_dev, flux_surf->on_dev, cflrate->on_dev); +} + +// CUDA kernel to set device function pointers. +// Doing function-pointer work here avoids troublesome cudaMemcpyFromSymbol. +__global__ static void +gk_collisionless_passive_flux_set_cu_dev_ptrs(struct gkyl_gk_collisionless_passive_flux *up, + int cdim, int vdim, int poly_order, const enum gkyl_gyrokinetic_bc_type *bctype_conf) +{ + for (int d = 0; d < cdim; d++) { + up->flux_surf[d] = choose_gk_collisionless_passive_flux_surf_conf_kern(d, cdim, vdim, poly_order); + up->flux_surf_edge_lo[d] = choose_gk_collisionless_passive_flux_edge_lo_surf_conf_kern(d, cdim, vdim, poly_order, bctype_conf[d]); + up->flux_surf_edge_up[d] = choose_gk_collisionless_passive_flux_edge_up_surf_conf_kern(d, cdim, vdim, poly_order, bctype_conf[GKYL_MAX_CDIM+d]); + } +} + +gkyl_gk_collisionless_passive_flux* +gkyl_gk_collisionless_passive_flux_cu_dev_new(const struct gkyl_rect_grid *phase_grid, + const struct gkyl_basis *conf_basis, const struct gkyl_basis *phase_basis, + const struct gkyl_array *passive_speeds, + const double charge, const double mass, + const struct gk_geometry *gk_geom, const struct gkyl_dg_geom *dg_geom, + const struct gkyl_gk_dg_geom *gk_dg_geom, const struct gkyl_velocity_map *vel_map, + const enum gkyl_gyrokinetic_bc_type *bctype_conf) +{ + gkyl_gk_collisionless_passive_flux *up = + (gkyl_gk_collisionless_passive_flux*) gkyl_malloc(sizeof(*up)); + + up->phase_grid = *phase_grid; + int cdim = conf_basis->ndim; + int pdim = phase_basis->ndim; + int vdim = pdim - cdim; + int poly_order = phase_basis->poly_order; + up->cdim = cdim; + up->pdim = pdim; + + up->charge = charge; + up->mass = mass; + + // Store on_dev pointers so the memcpy below carries device-side array references. + up->passive_speeds = passive_speeds->on_dev; + + // Acquire geometry/vel_map and use their on_dev pointers for the device copy. + struct gk_geometry *geom_ho = gkyl_gk_geometry_acquire(gk_geom); + struct gkyl_dg_geom *dg_geom_ho = gkyl_dg_geom_acquire(dg_geom); + struct gkyl_gk_dg_geom *gk_dg_geom_ho = gkyl_gk_dg_geom_acquire(gk_dg_geom); + struct gkyl_velocity_map *vel_map_ho = gkyl_velocity_map_acquire(vel_map); + + up->gk_geom = geom_ho->on_dev; + up->dg_geom = dg_geom_ho->on_dev; + up->gk_dg_geom = gk_dg_geom_ho->on_dev; + up->vel_map = vel_map_ho->on_dev; + + up->flags = 0; + GKYL_SET_CU_ALLOC(up->flags); + + // Temporarily copy array of BCs to device for kernel selection. + enum gkyl_gyrokinetic_bc_type *bctype_conf_dev = (enum gkyl_gyrokinetic_bc_type *) gkyl_cu_malloc(2*GKYL_MAX_CDIM*sizeof(enum gkyl_gyrokinetic_bc_type)); + gkyl_cu_memcpy(bctype_conf_dev, bctype_conf, 2*GKYL_MAX_CDIM*sizeof(enum gkyl_gyrokinetic_bc_type), GKYL_CU_MEMCPY_H2D); + + // Copy host struct to device and select kernels. + struct gkyl_gk_collisionless_passive_flux *up_cu = + (struct gkyl_gk_collisionless_passive_flux*) gkyl_cu_malloc(sizeof(*up_cu)); + gkyl_cu_memcpy(up_cu, up, sizeof(*up), GKYL_CU_MEMCPY_H2D); + + gk_collisionless_passive_flux_set_cu_dev_ptrs<<<1,1>>>(up_cu, cdim, vdim, poly_order, bctype_conf_dev); + + gkyl_cu_free(bctype_conf_dev); + + up->on_dev = up_cu; + + // Restore host-side pointers for the host updater. + up->passive_speeds = passive_speeds; + + up->gk_geom = geom_ho; + up->dg_geom = dg_geom_ho; + up->gk_dg_geom = gk_dg_geom_ho; + up->vel_map = vel_map_ho; + + return up; +} diff --git a/gyrokinetic/zero/gkyl_bc_twistshift.h b/gyrokinetic/zero/gkyl_bc_twistshift.h index 54b5871c02..cb6ccec89d 100644 --- a/gyrokinetic/zero/gkyl_bc_twistshift.h +++ b/gyrokinetic/zero/gkyl_bc_twistshift.h @@ -16,10 +16,10 @@ struct gkyl_bc_twistshift_inp { int shear_dir; // Direction in which the shift varies (shear). enum gkyl_edge_loc edge; // Edge of to apply this BC at (lower/upper). int cdim; // Configuration space dimensions. - struct gkyl_range bcdir_ext_update_r; // Local range where to apply BC, extended in bc_dir. + const struct gkyl_range *bcdir_ext_update_r; // Local range where to apply BC, extended in bc_dir. const int *num_ghost; // Number of ghost cells in each direction. - struct gkyl_basis basis; // Basis of the field shifted. - struct gkyl_rect_grid grid; // Grid the field shifted is defined on. + const struct gkyl_basis *basis; // Basis of the field shifted. + const struct gkyl_rect_grid *grid; // Grid the field shifted is defined on. evalf_t shift_func; // Function defining the shift. void *shift_func_ctx; // Context for shift_func. struct gkyl_array *shift_dg; // Discretized shift. @@ -34,8 +34,32 @@ struct gkyl_bc_twistshift_inp { * @param inp bc_twistshift_inp struct containing the inputs to the updater. * @return New updater pointer. */ -struct gkyl_bc_twistshift* gkyl_bc_twistshift_new(const struct gkyl_bc_twistshift_inp *inp); +struct gkyl_bc_twistshift* gkyl_bc_twistshift_inew(const struct gkyl_bc_twistshift_inp *inp); +/** + * Create a new updater to apply twist-shift BCs, passing each argument separately. + * + * @param bc_dir Direction in which to apply this BC. + * @param shift_dir Direction of the shift. + * @param shear_dir Direction in which the shift varies (shear). + * @param edge Edge of to apply this BC at (lower/upper). + * @param cdim Configuration space dimensions. + * @param bcdir_ext_update_r Local range where to apply BC, extended in bc_dir. + * @param num_ghost Number of ghost cells in each direction. + * @param basis Basis of the field shifted. + * @param grid Grid the field shifted is defined on. + * @param shift_func Function defining the shift. + * @param shift_func_ctx Context for shift_func. + * @param shift_dg Discretized shift. + * @param shift_poly_order Basis order for the DG representation of the shift (optional). + * @param use_gpu Whether to apply the BC using the GPU. + * @return New updater pointer. + */ +struct gkyl_bc_twistshift* gkyl_bc_twistshift_new(int bc_dir, int shift_dir, int shear_dir, + enum gkyl_edge_loc edge, int cdim, const struct gkyl_range *bcdir_ext_update_r, const int *num_ghost, + const struct gkyl_basis *basis, const struct gkyl_rect_grid *grid, evalf_t shift_func, void *shift_func_ctx, + struct gkyl_array *shift_dg, int shift_poly_order, bool use_gpu); + /** * Apply the twist-shift. It assumes that periodicity along bc_dir has been * applied to the donor field. Can be used in-place. diff --git a/gyrokinetic/zero/gkyl_dg_gyrokinetic_passive.h b/gyrokinetic/zero/gkyl_dg_gyrokinetic_passive.h new file mode 100644 index 0000000000..2b119877c0 --- /dev/null +++ b/gyrokinetic/zero/gkyl_dg_gyrokinetic_passive.h @@ -0,0 +1,49 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +// Auxiliary fields for the passive gyrokinetic DG equation. +struct gkyl_dg_gyrokinetic_passive_auxfields { + const struct gkyl_array *flux_surf; // Surface expansion of the passive phase-space flux. + const struct gkyl_array *speeds; // Conf-space passive advection speeds (all directions packed). +}; + +/** + * Create a new passive gyrokinetic equation object. + * + * The passive equation advects f in conf-space only, using a pre-computed + * surface expansion of the passive phase-space flux (flux_surf). No phi or + * electromagnetic fields are involved. + * + * @param cbasis Configuration space basis functions. + * @param pbasis Phase-space basis functions. + * @param conf_range Configuration space range (for indexing aux fields). + * @param phase_range Phase space range (for indexing flux_surf). + * @param charge Species charge. + * @param mass Species mass. + * @param gk_geom Geometry struct. + * @param vel_map Velocity space mapping object. + * @param use_gpu Boolean to determine if equation object is on device. + * @return Pointer to passive gyrokinetic equation object. + */ +struct gkyl_dg_eqn* +gkyl_dg_gyrokinetic_passive_new(const struct gkyl_basis *cbasis, const struct gkyl_basis *pbasis, + const struct gkyl_range *conf_range, const struct gkyl_range *phase_range, + const double charge, const double mass, + const struct gk_geometry *gk_geom, const struct gkyl_velocity_map *vel_map, + bool use_gpu); + +/** + * Set the auxiliary fields for the passive gyrokinetic equation. + * + * @param eqn Equation pointer. + * @param auxfields Pointer to struct of aux fields. + */ +void gkyl_gyrokinetic_passive_set_auxfields(const struct gkyl_dg_eqn *eqn, + struct gkyl_dg_gyrokinetic_passive_auxfields auxin); diff --git a/gyrokinetic/zero/gkyl_dg_gyrokinetic_passive_priv.h b/gyrokinetic/zero/gkyl_dg_gyrokinetic_passive_priv.h new file mode 100644 index 0000000000..7d18d7de27 --- /dev/null +++ b/gyrokinetic/zero/gkyl_dg_gyrokinetic_passive_priv.h @@ -0,0 +1,336 @@ +// Private header, not for direct use in user code. +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +typedef double (*dg_gyrokinetic_passive_surf_t)(const double *w, const double *dxv, + const double *vmap_prime_l, const double *vmap_prime_c, const double *vmap_prime_r, + const double *flux_surf_l, const double *flux_surf_r, double *GKYL_RESTRICT out); + +typedef double (*dg_gyrokinetic_passive_boundary_surf_t)(const double *w, const double *dxv, + const double *vmap_prime_edge, const double *vmap_prime_skin, + const double *flux_surf_edge, const double *flux_surf_skin, + const int edge, double *GKYL_RESTRICT out); + +// The cv_index_gkp[cd].vdim[vd] maps (cdim, vdim) to a kernel-list index. +static struct { int vdim[3]; } cv_index_gkp[] = { + {-1, -1, -1}, // 0x makes no sense. + {-1, 0, 1}, // 1x kernel indices. + {-1, -1, 2}, // 2x kernel indices. + {-1, -1, 3}, // 3x kernel indices. +}; + +// For use in kernel tables. +typedef struct { vol_termf_t kernels[3]; } gkyl_dg_gyrokinetic_passive_vol_kern_list; +typedef struct { dg_gyrokinetic_passive_surf_t kernels[3]; } gkyl_dg_gyrokinetic_passive_surf_kern_list; +typedef struct { dg_gyrokinetic_passive_boundary_surf_t kernels[3]; } gkyl_dg_gyrokinetic_passive_boundary_surf_kern_list; + +// Private equation struct. +struct dg_gyrokinetic_passive { + struct gkyl_dg_eqn eqn; // Base object (must be first). + int cdim; // Config-space dimensions. + int pdim; // Phase-space dimensions. + dg_gyrokinetic_passive_surf_t surf[GKYL_MAX_CDIM]; // Conf-space surface kernels. + dg_gyrokinetic_passive_boundary_surf_t boundary_surf[GKYL_MAX_CDIM]; + struct gkyl_range conf_range; // Configuration space range. + struct gkyl_range phase_range; // Phase space range. + double charge, mass; + const struct gk_geometry *gk_geom; + const struct gkyl_velocity_map *vel_map; + struct gkyl_dg_gyrokinetic_passive_auxfields auxfields; +}; + +// +// Volume kernel wrappers — these are called by hyper_dg via the vol_term +// function pointer in gkyl_dg_eqn. +// + +GKYL_CU_DH +static double +kernel_dg_gyrokinetic_passive_vol_1x1v_ser_p1(const struct gkyl_dg_eqn *eqn, + const double *xc, const double *dx, const int *idx, + const double *qIn, double *GKYL_RESTRICT qRhsOut) +{ + struct dg_gyrokinetic_passive *gkp = container_of(eqn, struct dg_gyrokinetic_passive, eqn); + + int vel_idx[2]; + for (int d = gkp->cdim; d < gkp->pdim; d++) vel_idx[d-gkp->cdim] = idx[d]; + + long cidx = gkyl_range_idx(&gkp->conf_range, idx); + long vidx = gkyl_range_idx(&gkp->vel_map->local_vel, vel_idx); + + return dg_gyrokinetic_passive_vol_1x1v_ser_p1(xc, dx, + (const double*) gkyl_array_cfetch(gkp->vel_map->vmap, vidx), + (const double*) gkyl_array_cfetch(gkp->vel_map->vmap_sq, vidx), + gkp->charge, gkp->mass, + (const double*) gkyl_array_cfetch(gkp->gk_geom->geo_corn.bmag, cidx), + (const double*) gkyl_array_cfetch(gkp->auxfields.speeds, cidx), + (const double*) gkyl_array_cfetch(gkp->gk_geom->geo_int.dualcurlbhatoverB, cidx), + (const double*) gkyl_array_cfetch(gkp->gk_geom->geo_int.rtg33inv, cidx), + (const double*) gkyl_array_cfetch(gkp->gk_geom->geo_int.bioverJB, cidx), + qIn, qRhsOut); +} + +GKYL_CU_DH +static double +kernel_dg_gyrokinetic_passive_vol_1x2v_ser_p1(const struct gkyl_dg_eqn *eqn, + const double *xc, const double *dx, const int *idx, + const double *qIn, double *GKYL_RESTRICT qRhsOut) +{ + struct dg_gyrokinetic_passive *gkp = container_of(eqn, struct dg_gyrokinetic_passive, eqn); + + int vel_idx[2]; + for (int d = gkp->cdim; d < gkp->pdim; d++) vel_idx[d-gkp->cdim] = idx[d]; + + long cidx = gkyl_range_idx(&gkp->conf_range, idx); + long vidx = gkyl_range_idx(&gkp->vel_map->local_vel, vel_idx); + + return dg_gyrokinetic_passive_vol_1x2v_ser_p1(xc, dx, + (const double*) gkyl_array_cfetch(gkp->vel_map->vmap, vidx), + (const double*) gkyl_array_cfetch(gkp->vel_map->vmap_sq, vidx), + gkp->charge, gkp->mass, + (const double*) gkyl_array_cfetch(gkp->gk_geom->geo_corn.bmag, cidx), + (const double*) gkyl_array_cfetch(gkp->auxfields.speeds, cidx), + (const double*) gkyl_array_cfetch(gkp->gk_geom->geo_int.dualcurlbhatoverB, cidx), + (const double*) gkyl_array_cfetch(gkp->gk_geom->geo_int.rtg33inv, cidx), + (const double*) gkyl_array_cfetch(gkp->gk_geom->geo_int.bioverJB, cidx), + qIn, qRhsOut); +} + +GKYL_CU_DH +static double +kernel_dg_gyrokinetic_passive_vol_2x2v_ser_p1(const struct gkyl_dg_eqn *eqn, + const double *xc, const double *dx, const int *idx, + const double *qIn, double *GKYL_RESTRICT qRhsOut) +{ + struct dg_gyrokinetic_passive *gkp = container_of(eqn, struct dg_gyrokinetic_passive, eqn); + + int vel_idx[2]; + for (int d = gkp->cdim; d < gkp->pdim; d++) vel_idx[d-gkp->cdim] = idx[d]; + + long cidx = gkyl_range_idx(&gkp->conf_range, idx); + long vidx = gkyl_range_idx(&gkp->vel_map->local_vel, vel_idx); + + return dg_gyrokinetic_passive_vol_2x2v_ser_p1(xc, dx, + (const double*) gkyl_array_cfetch(gkp->vel_map->vmap, vidx), + (const double*) gkyl_array_cfetch(gkp->vel_map->vmap_sq, vidx), + gkp->charge, gkp->mass, + (const double*) gkyl_array_cfetch(gkp->gk_geom->geo_corn.bmag, cidx), + (const double*) gkyl_array_cfetch(gkp->auxfields.speeds, cidx), + (const double*) gkyl_array_cfetch(gkp->gk_geom->geo_int.dualcurlbhatoverB, cidx), + (const double*) gkyl_array_cfetch(gkp->gk_geom->geo_int.rtg33inv, cidx), + (const double*) gkyl_array_cfetch(gkp->gk_geom->geo_int.bioverJB, cidx), + qIn, qRhsOut); +} + +GKYL_CU_DH +static double +kernel_dg_gyrokinetic_passive_vol_3x2v_ser_p1(const struct gkyl_dg_eqn *eqn, + const double *xc, const double *dx, const int *idx, + const double *qIn, double *GKYL_RESTRICT qRhsOut) +{ + struct dg_gyrokinetic_passive *gkp = container_of(eqn, struct dg_gyrokinetic_passive, eqn); + + int vel_idx[2]; + for (int d = gkp->cdim; d < gkp->pdim; d++) vel_idx[d-gkp->cdim] = idx[d]; + + long cidx = gkyl_range_idx(&gkp->conf_range, idx); + long vidx = gkyl_range_idx(&gkp->vel_map->local_vel, vel_idx); + + return dg_gyrokinetic_passive_vol_3x2v_ser_p1(xc, dx, + (const double*) gkyl_array_cfetch(gkp->vel_map->vmap, vidx), + (const double*) gkyl_array_cfetch(gkp->vel_map->vmap_sq, vidx), + gkp->charge, gkp->mass, + (const double*) gkyl_array_cfetch(gkp->gk_geom->geo_corn.bmag, cidx), + (const double*) gkyl_array_cfetch(gkp->auxfields.speeds, cidx), + (const double*) gkyl_array_cfetch(gkp->gk_geom->geo_int.dualcurlbhatoverB, cidx), + (const double*) gkyl_array_cfetch(gkp->gk_geom->geo_int.rtg33inv, cidx), + (const double*) gkyl_array_cfetch(gkp->gk_geom->geo_int.bioverJB, cidx), + qIn, qRhsOut); +} + +// Volume kernel list. +GKYL_CU_D +static const gkyl_dg_gyrokinetic_passive_vol_kern_list ser_passive_vol_kernels[] = { + { kernel_dg_gyrokinetic_passive_vol_1x1v_ser_p1, NULL }, + { kernel_dg_gyrokinetic_passive_vol_1x2v_ser_p1, NULL }, + { kernel_dg_gyrokinetic_passive_vol_2x2v_ser_p1, NULL }, + { kernel_dg_gyrokinetic_passive_vol_3x2v_ser_p1, NULL }, +}; + +// +// Surface kernel lists — conf-space directions only. +// + +// x-direction +GKYL_CU_D +static const gkyl_dg_gyrokinetic_passive_surf_kern_list ser_passive_surf_x_kernels[] = { + { dg_gyrokinetic_passive_surfx_1x1v_ser_p1, NULL }, + { dg_gyrokinetic_passive_surfx_1x2v_ser_p1, NULL }, + { dg_gyrokinetic_passive_surfx_2x2v_ser_p1, NULL }, + { dg_gyrokinetic_passive_surfx_3x2v_ser_p1, NULL }, +}; + +// y-direction +GKYL_CU_D +static const gkyl_dg_gyrokinetic_passive_surf_kern_list ser_passive_surf_y_kernels[] = { + { NULL, NULL }, + { NULL, NULL }, + { dg_gyrokinetic_passive_surfy_2x2v_ser_p1, NULL }, + { dg_gyrokinetic_passive_surfy_3x2v_ser_p1, NULL }, +}; + +// z-direction +GKYL_CU_D +static const gkyl_dg_gyrokinetic_passive_surf_kern_list ser_passive_surf_z_kernels[] = { + { NULL, NULL }, + { NULL, NULL }, + { NULL, NULL }, + { dg_gyrokinetic_passive_surfz_3x2v_ser_p1, NULL }, +}; + +// +// Boundary-surface kernel lists. +// + +// x-direction +GKYL_CU_D +static const gkyl_dg_gyrokinetic_passive_boundary_surf_kern_list ser_passive_boundary_surf_x_kernels[] = { + { dg_gyrokinetic_passive_boundary_surfx_1x1v_ser_p1, NULL }, + { dg_gyrokinetic_passive_boundary_surfx_1x2v_ser_p1, NULL }, + { dg_gyrokinetic_passive_boundary_surfx_2x2v_ser_p1, NULL }, + { dg_gyrokinetic_passive_boundary_surfx_3x2v_ser_p1, NULL }, +}; + +// y-direction +GKYL_CU_D +static const gkyl_dg_gyrokinetic_passive_boundary_surf_kern_list ser_passive_boundary_surf_y_kernels[] = { + { NULL, NULL }, + { NULL, NULL }, + { dg_gyrokinetic_passive_boundary_surfy_2x2v_ser_p1, NULL }, + { dg_gyrokinetic_passive_boundary_surfy_3x2v_ser_p1, NULL }, +}; + +// z-direction +GKYL_CU_D +static const gkyl_dg_gyrokinetic_passive_boundary_surf_kern_list ser_passive_boundary_surf_z_kernels[] = { + { NULL, NULL }, + { NULL, NULL }, + { NULL, NULL }, + { dg_gyrokinetic_passive_boundary_surfz_3x2v_ser_p1, NULL }, +}; + +// Macro to select a kernel from a list. +#define CK_PASSIVE(lst,cdim,vd,poly_order) lst[cv_index_gkp[cdim].vdim[vd]].kernels[poly_order-1] + +/** + * Free passive gyrokinetic equation object. + */ +void gkyl_gyrokinetic_passive_free(const struct gkyl_ref_count *ref); + +// Surface dispatch: called by hyper_dg for each surface. +GKYL_CU_D +static double +surf_passive(const struct gkyl_dg_eqn *eqn, + int dir, + const double *xcL, const double *xcC, const double *xcR, + const double *dxL, const double *dxC, const double *dxR, + const int *idxL, const int *idxC, const int *idxR, + const double *qInL, const double *qInC, const double *qInR, + double *GKYL_RESTRICT qRhsOut) +{ + struct dg_gyrokinetic_passive *gkp = container_of(eqn, struct dg_gyrokinetic_passive, eqn); + + // Only update conf-space directions (dir < cdim). + if (dir < gkp->cdim) { + int vel_idxL[2], vel_idxC[2], vel_idxR[2]; + for (int d = gkp->cdim; d < gkp->pdim; d++) { + vel_idxL[d-gkp->cdim] = idxL[d]; + vel_idxC[d-gkp->cdim] = idxC[d]; + vel_idxR[d-gkp->cdim] = idxR[d]; + } + long vidxL = gkyl_range_idx(&gkp->vel_map->local_vel, vel_idxL); + long vidxC = gkyl_range_idx(&gkp->vel_map->local_vel, vel_idxC); + long vidxR = gkyl_range_idx(&gkp->vel_map->local_vel, vel_idxR); + + long pidxC = gkyl_range_idx(&gkp->phase_range, idxC); + long pidxR = gkyl_range_idx(&gkp->phase_range, idxR); + + return gkp->surf[dir](xcC, dxC, + (const double*) gkyl_array_cfetch(gkp->vel_map->vmap_prime, vidxL), + (const double*) gkyl_array_cfetch(gkp->vel_map->vmap_prime, vidxC), + (const double*) gkyl_array_cfetch(gkp->vel_map->vmap_prime, vidxR), + (const double*) gkyl_array_cfetch(gkp->auxfields.flux_surf, pidxC), + (const double*) gkyl_array_cfetch(gkp->auxfields.flux_surf, pidxR), + qRhsOut); + } + return 0.0; +} + +// Boundary-surface dispatch. +GKYL_CU_D +static double +boundary_surf_passive(const struct gkyl_dg_eqn *eqn, + int dir, + const double *xcEdge, const double *xcSkin, + const double *dxEdge, const double *dxSkin, + const int *idxEdge, const int *idxSkin, const int edge, + const double *qInEdge, const double *qInSkin, + double *GKYL_RESTRICT qRhsOut) +{ + struct dg_gyrokinetic_passive *gkp = container_of(eqn, struct dg_gyrokinetic_passive, eqn); + + if (dir < gkp->cdim) { + int vel_idxEdge[2], vel_idxSkin[2]; + for (int d = gkp->cdim; d < gkp->pdim; d++) { + vel_idxEdge[d-gkp->cdim] = idxEdge[d]; + vel_idxSkin[d-gkp->cdim] = idxSkin[d]; + } + long vidxEdge = gkyl_range_idx(&gkp->vel_map->local_vel, vel_idxEdge); + long vidxSkin = gkyl_range_idx(&gkp->vel_map->local_vel, vel_idxSkin); + + long pidxEdge = gkyl_range_idx(&gkp->phase_range, idxEdge); + long pidxSkin = gkyl_range_idx(&gkp->phase_range, idxSkin); + + return gkp->boundary_surf[dir](xcSkin, dxSkin, + (const double *) gkyl_array_cfetch(gkp->vel_map->vmap_prime, vidxEdge), + (const double *) gkyl_array_cfetch(gkp->vel_map->vmap_prime, vidxSkin), + (const double *) gkyl_array_cfetch(gkp->auxfields.flux_surf, pidxEdge), + (const double *) gkyl_array_cfetch(gkp->auxfields.flux_surf, pidxSkin), + edge, qRhsOut); + } + return 0.0; +} + +// boundary_diag mirrors boundary_surf. +GKYL_CU_D +static double +boundary_diag_passive(const struct gkyl_dg_eqn *eqn, + int dir, + const double *xcEdge, const double *xcSkin, + const double *dxEdge, const double *dxSkin, + const int *idxEdge, const int *idxSkin, const int edge, + const double *qInEdge, const double *qInSkin, + double *GKYL_RESTRICT qRhsOut) +{ + return boundary_surf_passive(eqn, dir, xcEdge, xcSkin, dxEdge, dxSkin, + idxEdge, idxSkin, edge, qInEdge, qInSkin, qRhsOut); +} + +#ifdef GKYL_HAVE_CUDA +// GPU-only functions (defined in dg_gyrokinetic_passive_cu.cu). +struct gkyl_dg_eqn* gkyl_dg_gyrokinetic_passive_cu_dev_new(const struct gkyl_basis *cbasis, + const struct gkyl_basis *pbasis, const struct gkyl_range *conf_range, + const struct gkyl_range *phase_range, const double charge, const double mass, + const struct gk_geometry *gk_geom, const struct gkyl_velocity_map *vel_map); + +void gkyl_gyrokinetic_passive_set_auxfields_cu(const struct gkyl_dg_eqn *eqn, + struct gkyl_dg_gyrokinetic_passive_auxfields auxin); +#endif diff --git a/gyrokinetic/zero/gkyl_dg_updater_gyrokinetic_passive.h b/gyrokinetic/zero/gkyl_dg_updater_gyrokinetic_passive.h new file mode 100644 index 0000000000..474ba83199 --- /dev/null +++ b/gyrokinetic/zero/gkyl_dg_updater_gyrokinetic_passive.h @@ -0,0 +1,85 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +// Fully separate type from gkyl_dg_updater_gyrokinetic. +typedef struct gkyl_dg_updater_gyrokinetic_passive gkyl_dg_updater_gyrokinetic_passive; + +// Timer struct. +struct gkyl_dg_updater_gyrokinetic_passive_tm { + double gyrokinetic_passive_tm; +}; + +/** + * Create a new updater to advance the passive gyrokinetic equation using + * hyper_dg. Only conf-space directions are updated; no vpar surface kernel + * is used. + * + * @param grid Phase space grid. + * @param cbasis Configuration space basis functions. + * @param pbasis Phase-space basis functions. + * @param conf_range Configuration space range. + * @param phase_range Phase space range. + * @param is_zero_flux_bc[2*GKYL_MAX_DIM] True for zero-flux boundaries. + * @param charge Species charge. + * @param mass Species mass. + * @param gk_geom Geometry struct. + * @param vel_map Velocity space mapping object. + * @param aux_inp Void pointer to gkyl_dg_gyrokinetic_passive_auxfields. + * @param use_gpu Boolean to determine if on device. + * @return Pointer to new updater object. + */ +gkyl_dg_updater_gyrokinetic_passive* +gkyl_dg_updater_gyrokinetic_passive_new(const struct gkyl_rect_grid *grid, + const struct gkyl_basis *cbasis, const struct gkyl_basis *pbasis, + const struct gkyl_range *conf_range, const struct gkyl_range *phase_range, + const bool *is_zero_flux_bc, + const double charge, const double mass, + const struct gk_geometry *gk_geom, + const struct gkyl_velocity_map *vel_map, + void *aux_inp, bool use_gpu); + +/** + * Acquire passive gyrokinetic equation object. + * + * @param up Passyive gyrokinetic updater object. + * + * @return Passive gyrokinetic equation object. + */ +struct gkyl_dg_eqn* +gkyl_dg_updater_gyrokinetic_passive_acquire_eqn(const gkyl_dg_updater_gyrokinetic_passive* up); + +/** + * Compute the RHS DG update. + * + * @param up Passive gyrokinetic updater object. + * @param update_rng Range on which to compute. + * @param fIn Input distribution function. + * @param cflrate CFL rate array (units of 1/[T]). + * @param rhs RHS output. + */ +void gkyl_dg_updater_gyrokinetic_passive_advance(gkyl_dg_updater_gyrokinetic_passive *up, + const struct gkyl_range *update_rng, const struct gkyl_array *fIn, + struct gkyl_array *cflrate, struct gkyl_array *rhs); + +/** + * Return total time spent in the passive gyrokinetic equation. + * + * @param up Updater object. + * @return Timers. + */ +struct gkyl_dg_updater_gyrokinetic_passive_tm +gkyl_dg_updater_gyrokinetic_passive_get_tm(const gkyl_dg_updater_gyrokinetic_passive *up); + +/** + * Delete updater. + * + * @param up Updater to delete. + */ +void gkyl_dg_updater_gyrokinetic_passive_release(gkyl_dg_updater_gyrokinetic_passive *up); diff --git a/gyrokinetic/zero/gkyl_dg_updater_gyrokinetic_passive_priv.h b/gyrokinetic/zero/gkyl_dg_updater_gyrokinetic_passive_priv.h new file mode 100644 index 0000000000..1c28cb82a7 --- /dev/null +++ b/gyrokinetic/zero/gkyl_dg_updater_gyrokinetic_passive_priv.h @@ -0,0 +1,12 @@ +#pragma once + +#include +#include +#include + +struct gkyl_dg_updater_gyrokinetic_passive { + bool use_gpu; + struct gkyl_dg_eqn *eqn_gyrokinetic_passive; // Passive GK equation object. + struct gkyl_hyper_dg *up_gyrokinetic_passive; // hyper_dg solver (conf-space only). + double gyrokinetic_passive_tm; // Total time in advance calls. +}; diff --git a/gyrokinetic/zero/gkyl_gk_collisionless_passive_flux.h b/gyrokinetic/zero/gkyl_gk_collisionless_passive_flux.h new file mode 100644 index 0000000000..d4ccbf9cca --- /dev/null +++ b/gyrokinetic/zero/gkyl_gk_collisionless_passive_flux.h @@ -0,0 +1,69 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Object type. +typedef struct gkyl_gk_collisionless_passive_flux gkyl_gk_collisionless_passive_flux; + +/** + * Create new updater to compute the surface expansion of the phase-space + * flux for passive (prescribed) conf-space advection. + * + * @param phase_grid Phase space grid. + * @param conf_basis Configuration space basis functions. + * @param phase_basis Phase space basis functions. + * @param passive_speeds Conf-space advection speeds. + * @param charge Species charge. + * @param mass Species mass. + * @param gk_geom Gyrokinetic geometry object. + * @param dg_geom DG geometry object. + * @param gk_dg_geom GK DG geometry object. + * @param vel_map Velocity space mapping object. + * @param bctype_conf Type of conf-space BCs (for choosing edge kernels). + * @param use_gpu Whether to allocate on GPU. + * @return New updater pointer. + */ +gkyl_gk_collisionless_passive_flux* +gkyl_gk_collisionless_passive_flux_new(const struct gkyl_rect_grid *phase_grid, + const struct gkyl_basis *conf_basis, const struct gkyl_basis *phase_basis, + const struct gkyl_array *passive_speeds, + const double charge, const double mass, + const struct gk_geometry *gk_geom, const struct gkyl_dg_geom *dg_geom, + const struct gkyl_gk_dg_geom *gk_dg_geom, const struct gkyl_velocity_map *vel_map, + const enum gkyl_gyrokinetic_bc_type *bctype_conf, bool use_gpu); + +/** + * Compute the surface expansion of the passive phase-space flux. + * + * Each cell stores the *lower* surface expansion. + * + * @param up Updater. + * @param conf_range Configuration space range (local only; geometry defined here). + * @param phase_range Phase space range. + * @param conf_ext_range Extended configuration space range. + * @param phase_ext_range Extended phase space range. + * @param fin Distribution function. + * @param flux_surf Output surface expansion (lower edge in each direction). + * @param cflrate Output CFL rate. + */ +void gkyl_gk_collisionless_passive_flux_surf(gkyl_gk_collisionless_passive_flux *up, + const struct gkyl_range *conf_range, const struct gkyl_range *phase_range, + const struct gkyl_range *conf_ext_range, const struct gkyl_range *phase_ext_range, + const struct gkyl_array *fin, + struct gkyl_array *flux_surf, struct gkyl_array *cflrate); + +/** + * Delete pointer to passive flux updater. + * + * @param up Updater to delete. + */ +void gkyl_gk_collisionless_passive_flux_release(gkyl_gk_collisionless_passive_flux *up); diff --git a/gyrokinetic/zero/gkyl_gk_collisionless_passive_flux_priv.h b/gyrokinetic/zero/gkyl_gk_collisionless_passive_flux_priv.h new file mode 100644 index 0000000000..869a28e5a0 --- /dev/null +++ b/gyrokinetic/zero/gkyl_gk_collisionless_passive_flux_priv.h @@ -0,0 +1,256 @@ +// Private header: not for direct use +#pragma once + +#include + +#include +#include +#include +#include +#include +#include + +typedef double (*gk_collisionless_passive_flux_surf_t)(const double *w, const double *dxv, + const double *vmap, const double *vmapSq, const double q_, const double m_, + const struct gkyl_dg_surf_geom *dgs, const struct gkyl_gk_dg_surf_geom *gkdgs, + const double *bmag, const double *jacobgeo_rat_surfL, const double *jacobgeo_rat_surfR, + const double *speeds_L, const double *speeds_R, + const double *JfL, const double *JfR, double *GKYL_RESTRICT flux_surf); + +// The cv_index[cd].vdim[vd] is used to index the various lists of kernels below. +GKYL_CU_D +static struct { int vdim[3]; } cv_index_passive[] = { + {-1, -1, -1}, // 0x makes no sense. + {-1, 0, 1}, // 1x kernel indices. + {-1, -1, 2}, // 2x kernel indices. + {-1, -1, 3}, // 3x kernel indices. +}; + +// For use in kernel tables. +typedef struct { gk_collisionless_passive_flux_surf_t kernels[3]; } gkyl_gk_collisionless_passive_flux_surf_kern_list; + +struct gkyl_gk_collisionless_passive_flux { + struct gkyl_rect_grid phase_grid; // Phase space grid for cell spacing and cell center. + int cdim; // Configuration space dimensionality. + int pdim; // Phase space dimensionality. + double charge, mass; + // Pointers to projected conf-space passive-speed arrays (NOT owned by this struct). + const struct gkyl_array *passive_speeds; + const struct gk_geometry *gk_geom; // Pointer to geometry struct. + const struct gkyl_dg_geom *dg_geom; // Pointer to vol DG geometry struct. + const struct gkyl_gk_dg_geom *gk_dg_geom; // Pointer to GK DG geometry struct. + const struct gkyl_velocity_map *vel_map; // Velocity space mapping object. + // Kernels for interior, lower-edge, and upper-edge surfaces in each conf direction. + gk_collisionless_passive_flux_surf_t flux_surf[GKYL_MAX_CDIM]; + gk_collisionless_passive_flux_surf_t flux_surf_edge_lo[GKYL_MAX_CDIM]; + gk_collisionless_passive_flux_surf_t flux_surf_edge_up[GKYL_MAX_CDIM]; + // No vpar kernel — passive advection is conf-space only. + uint32_t flags; + struct gkyl_gk_collisionless_passive_flux *on_dev; // pointer to itself or device data +}; + +// +// Serendipity surface kernels — x-direction (interior) +// +GKYL_CU_D +static const gkyl_gk_collisionless_passive_flux_surf_kern_list ser_gk_collisionless_passive_flux_surfx_kernels[] = { + { NULL, gk_collisionless_passive_flux_surfx_1x1v_ser_p1, NULL }, // 0: 1x1v + { NULL, gk_collisionless_passive_flux_surfx_1x2v_ser_p1, NULL }, // 1: 1x2v + { NULL, gk_collisionless_passive_flux_surfx_2x2v_ser_p1, NULL }, // 2: 2x2v + { NULL, gk_collisionless_passive_flux_surfx_3x2v_ser_p1, NULL }, // 3: 3x2v +}; + +// x-direction edge (lower boundary) +GKYL_CU_D +static const gkyl_gk_collisionless_passive_flux_surf_kern_list ser_gk_collisionless_passive_flux_edge_surfx_kernels[] = { + { NULL, gk_collisionless_passive_flux_edge_surfx_1x1v_ser_p1, NULL }, // 0 + { NULL, gk_collisionless_passive_flux_edge_surfx_1x2v_ser_p1, NULL }, // 1 + { NULL, gk_collisionless_passive_flux_edge_surfx_2x2v_ser_p1, NULL }, // 2 + { NULL, gk_collisionless_passive_flux_edge_surfx_3x2v_ser_p1, NULL }, // 3 +}; + +// +// y-direction (interior) +// +GKYL_CU_D +static const gkyl_gk_collisionless_passive_flux_surf_kern_list ser_gk_collisionless_passive_flux_surfy_kernels[] = { + { NULL, NULL, NULL }, // 0: 1x — no y + { NULL, NULL, NULL }, // 1: 1x — no y + { NULL, gk_collisionless_passive_flux_surfy_2x2v_ser_p1, NULL }, // 2: 2x2v + { NULL, gk_collisionless_passive_flux_surfy_3x2v_ser_p1, NULL }, // 3: 3x2v +}; + +// y-direction edge +GKYL_CU_D +static const gkyl_gk_collisionless_passive_flux_surf_kern_list ser_gk_collisionless_passive_flux_edge_surfy_kernels[] = { + { NULL, NULL, NULL }, // 0 + { NULL, NULL, NULL }, // 1 + { NULL, gk_collisionless_passive_flux_edge_surfy_2x2v_ser_p1, NULL }, // 2 + { NULL, gk_collisionless_passive_flux_edge_surfy_3x2v_ser_p1, NULL }, // 3 +}; + +// +// z-direction (interior) +// +GKYL_CU_D +static const gkyl_gk_collisionless_passive_flux_surf_kern_list ser_gk_collisionless_passive_flux_surfz_kernels[] = { + { NULL, NULL, NULL }, // 0 + { NULL, NULL, NULL }, // 1 + { NULL, NULL, NULL }, // 2 + { NULL, gk_collisionless_passive_flux_surfz_3x2v_ser_p1, NULL }, // 3: 3x2v +}; + +// z-direction edge +GKYL_CU_D +static const gkyl_gk_collisionless_passive_flux_surf_kern_list ser_gk_collisionless_passive_flux_edge_surfz_kernels[] = { + { NULL, NULL, NULL }, // 0 + { NULL, NULL, NULL }, // 1 + { NULL, NULL, NULL }, // 2 + { NULL, gk_collisionless_passive_flux_edge_surfz_3x2v_ser_p1, NULL }, // 3 +}; + +// +// Kernels used at multiblock boundaries. +// + +// Gyrokinetic phase space flux alpha surface expansions in x (Serendipity kernels) +GKYL_CU_D +static const gkyl_gk_collisionless_passive_flux_surf_kern_list ser_gk_collisionless_passive_flux_multib_boundary_surfx_kernels[] = { + { NULL, gk_collisionless_passive_flux_multib_boundary_surfx_1x1v_ser_p1, NULL }, // 0 + { NULL, gk_collisionless_passive_flux_multib_boundary_surfx_1x2v_ser_p1, NULL }, // 1 + { NULL, gk_collisionless_passive_flux_multib_boundary_surfx_2x2v_ser_p1, NULL }, // 2 + { NULL, gk_collisionless_passive_flux_multib_boundary_surfx_3x2v_ser_p1, NULL }, // 3 +}; + +// Gyrokinetic phase space flux alpha edge surface expansions in x (Serendipity kernels) +GKYL_CU_D +static const gkyl_gk_collisionless_passive_flux_surf_kern_list ser_gk_collisionless_passive_flux_multib_boundary_edge_surfx_kernels[] = { + { NULL, gk_collisionless_passive_flux_multib_boundary_edge_surfx_1x1v_ser_p1, NULL }, // 0 + { NULL, gk_collisionless_passive_flux_multib_boundary_edge_surfx_1x2v_ser_p1, NULL }, // 1 + { NULL, gk_collisionless_passive_flux_multib_boundary_edge_surfx_2x2v_ser_p1, NULL }, // 2 + { NULL, gk_collisionless_passive_flux_multib_boundary_edge_surfx_3x2v_ser_p1, NULL }, // 3 +}; + +// Gyrokinetic phase space flux flux surface expansions in y (Serendipity kernels) +GKYL_CU_D +static const gkyl_gk_collisionless_passive_flux_surf_kern_list ser_gk_collisionless_passive_flux_multib_boundary_surfy_kernels[] = { + { NULL, NULL, NULL }, // 0 + { NULL, NULL, NULL }, // 1 + { NULL, gk_collisionless_passive_flux_multib_boundary_surfy_2x2v_ser_p1, NULL }, // 2 + { NULL, gk_collisionless_passive_flux_multib_boundary_surfy_3x2v_ser_p1, NULL }, // 3 +}; + +// Gyrokinetic phase space flux flux edge surface expansions in y (Serendipity kernels) +GKYL_CU_D +static const gkyl_gk_collisionless_passive_flux_surf_kern_list ser_gk_collisionless_passive_flux_multib_boundary_edge_surfy_kernels[] = { + { NULL, NULL, NULL }, // 0 + { NULL, NULL, NULL }, // 1 + { NULL, gk_collisionless_passive_flux_multib_boundary_edge_surfy_2x2v_ser_p1, NULL }, // 2 + { NULL, gk_collisionless_passive_flux_multib_boundary_edge_surfy_3x2v_ser_p1, NULL }, // 3 +}; + +// Gyrokinetic phase space flux flux surface expansions in z (Serendipity kernels) +GKYL_CU_D +static const gkyl_gk_collisionless_passive_flux_surf_kern_list ser_gk_collisionless_passive_flux_multib_boundary_surfz_kernels[] = { + { NULL, NULL, NULL }, // 0 + { NULL, NULL, NULL }, // 1 + { NULL, NULL, NULL }, // 2 + { NULL, gk_collisionless_passive_flux_multib_boundary_surfz_3x2v_ser_p1, NULL }, // 3 +}; + +// Gyrokinetic phase space flux flux edge surface expansions in z (Serendipity kernels) +GKYL_CU_D +static const gkyl_gk_collisionless_passive_flux_surf_kern_list ser_gk_collisionless_passive_flux_multib_boundary_edge_surfz_kernels[] = { + { NULL, NULL, NULL }, // 0 + { NULL, NULL, NULL }, // 1 + { NULL, NULL, NULL }, // 2 + { NULL, gk_collisionless_passive_flux_multib_boundary_edge_surfz_3x2v_ser_p1, NULL }, // 3 +}; + +// Helper: choose interior conf-surface kernel for a given direction. +GKYL_CU_D +static gk_collisionless_passive_flux_surf_t +choose_gk_collisionless_passive_flux_surf_conf_kern(int dir, int cdim, int vdim, int poly_order) +{ + if (dir == 0) + return ser_gk_collisionless_passive_flux_surfx_kernels[cv_index_passive[cdim].vdim[vdim]].kernels[poly_order]; + else if (dir == 1) + return ser_gk_collisionless_passive_flux_surfy_kernels[cv_index_passive[cdim].vdim[vdim]].kernels[poly_order]; + else if (dir == 2) + return ser_gk_collisionless_passive_flux_surfz_kernels[cv_index_passive[cdim].vdim[vdim]].kernels[poly_order]; + + return NULL; +} + +// Helper: choose lower-edge conf-surface kernel for a given direction. +GKYL_CU_D +static gk_collisionless_passive_flux_surf_t +choose_gk_collisionless_passive_flux_edge_lo_surf_conf_kern(int dir, int cdim, int vdim, int poly_order, enum gkyl_gyrokinetic_bc_type bc) +{ + if (bc == GKYL_BC_GK_SKIP) { + if (dir == 0) + return ser_gk_collisionless_passive_flux_multib_boundary_surfx_kernels[cv_index_passive[cdim].vdim[vdim]].kernels[poly_order]; + else if (dir == 1) + return ser_gk_collisionless_passive_flux_multib_boundary_surfy_kernels[cv_index_passive[cdim].vdim[vdim]].kernels[poly_order]; + else if (dir == 2) + return ser_gk_collisionless_passive_flux_multib_boundary_surfz_kernels[cv_index_passive[cdim].vdim[vdim]].kernels[poly_order]; + else + return NULL; + } + else { + if (dir == 0) + return ser_gk_collisionless_passive_flux_surfx_kernels[cv_index_passive[cdim].vdim[vdim]].kernels[poly_order]; + else if (dir == 1) + return ser_gk_collisionless_passive_flux_surfy_kernels[cv_index_passive[cdim].vdim[vdim]].kernels[poly_order]; + else if (dir == 2) + return ser_gk_collisionless_passive_flux_surfz_kernels[cv_index_passive[cdim].vdim[vdim]].kernels[poly_order]; + else + return NULL; + } + + return NULL; +} + +// Helper: choose upper-edge conf-surface kernel for a given direction. +GKYL_CU_D +static gk_collisionless_passive_flux_surf_t +choose_gk_collisionless_passive_flux_edge_up_surf_conf_kern(int dir, int cdim, int vdim, int poly_order, enum gkyl_gyrokinetic_bc_type bc) +{ + if (bc == GKYL_BC_GK_SKIP) { + if (dir == 0) + return ser_gk_collisionless_passive_flux_multib_boundary_edge_surfx_kernels[cv_index_passive[cdim].vdim[vdim]].kernels[poly_order]; + else if (dir == 1) + return ser_gk_collisionless_passive_flux_multib_boundary_edge_surfy_kernels[cv_index_passive[cdim].vdim[vdim]].kernels[poly_order]; + else if (dir == 2) + return ser_gk_collisionless_passive_flux_multib_boundary_edge_surfz_kernels[cv_index_passive[cdim].vdim[vdim]].kernels[poly_order]; + else + return NULL; + } + else { + if (dir == 0) + return ser_gk_collisionless_passive_flux_edge_surfx_kernels[cv_index_passive[cdim].vdim[vdim]].kernels[poly_order]; + else if (dir == 1) + return ser_gk_collisionless_passive_flux_edge_surfy_kernels[cv_index_passive[cdim].vdim[vdim]].kernels[poly_order]; + else if (dir == 2) + return ser_gk_collisionless_passive_flux_edge_surfz_kernels[cv_index_passive[cdim].vdim[vdim]].kernels[poly_order]; + return NULL; + } + + return NULL; +} + +// GPU-only functions (defined in gk_collisionless_passive_flux_cu.cu). +gkyl_gk_collisionless_passive_flux* +gkyl_gk_collisionless_passive_flux_cu_dev_new(const struct gkyl_rect_grid *phase_grid, + const struct gkyl_basis *conf_basis, const struct gkyl_basis *phase_basis, + const struct gkyl_array *passive_speeds, + const double charge, const double mass, + const struct gk_geometry *gk_geom, const struct gkyl_dg_geom *dg_geom, + const struct gkyl_gk_dg_geom *gk_dg_geom, const struct gkyl_velocity_map *vel_map, + const enum gkyl_gyrokinetic_bc_type *bctype_conf); + +void gkyl_gk_collisionless_passive_flux_surf_cu(gkyl_gk_collisionless_passive_flux *up, + const struct gkyl_range *conf_range, const struct gkyl_range *phase_range, + const struct gkyl_range *conf_ext_range, const struct gkyl_range *phase_ext_range, + const struct gkyl_array *fin, + struct gkyl_array *flux_surf, struct gkyl_array *cflrate); diff --git a/machines/configure.perlmutter.cpu.sh b/machines/configure.perlmutter.cpu.sh index f3f1091020..5dd56dc31c 100755 --- a/machines/configure.perlmutter.cpu.sh +++ b/machines/configure.perlmutter.cpu.sh @@ -1,9 +1,14 @@ module unload darshan +module unload craype-accel-nvidia +module unload nccl +module unload cudatoolkit +module unload gpu module load cray-mpich/9.0.1 module load cray-libsci/25.09.0 +module load craype-accel-host : "${PREFIX:=$HOME/gkylsoft}" -./configure CC=cc --prefix=$PREFIX --lapack-lib-name=sci_gnu --lapack-inc=$CRAY_LIBSCI_PREFIX/include --lapack-lib=$CRAY_LIBSCI_PREFIX/lib --use-mpi=yes --mpi-inc=$CRAY_MPICH_DIR/include --mpi-lib=$CRAY_MPICH_DIR/lib --use-lua=yes; +./configure CC=cc --prefix=$PREFIX --lapack-lib-name=sci_gnu_mpi --lapack-inc=$CRAY_LIBSCI_PREFIX/include --lapack-lib=$CRAY_LIBSCI_PREFIX/lib --use-mpi=yes --mpi-inc=$CRAY_MPICH_DIR/include --mpi-lib=$CRAY_MPICH_DIR/lib --use-lua=yes; diff --git a/machines/mkdeps.perlmutter.cpu.sh b/machines/mkdeps.perlmutter.cpu.sh index 9e785751b9..103dc55abb 100755 --- a/machines/mkdeps.perlmutter.cpu.sh +++ b/machines/mkdeps.perlmutter.cpu.sh @@ -1,6 +1,11 @@ module unload darshan +module unload craype-accel-nvidia +module unload nccl +module unload cudatoolkit +module unload gpu module load cray-mpich/9.0.1 module load cray-libsci/25.09.0 +module load craype-accel-host : "${PREFIX:=$HOME/gkylsoft}"