From 771c19a046bd73b7764754df919381fe5a6c83be Mon Sep 17 00:00:00 2001 From: manauref Date: Fri, 3 Jul 2026 15:30:59 -0700 Subject: [PATCH 01/19] Add a new GK equation object to do passive advection, with a velocity given in the input file. Add sample regression test (gkylcas 16cfe76398a327fa8617ed162509585f0c6c6f47). --- core/zero/gkyl_eqn_type.h | 1 + gyrokinetic/Makefile-gyrokinetic | 8 + gyrokinetic/apps/gk_species_collisionless.c | 176 +++++++-- gyrokinetic/apps/gkyl_gyrokinetic.h | 4 + gyrokinetic/apps/gkyl_gyrokinetic_priv.h | 15 +- gyrokinetic/creg/rt_gk_passive_3x2v_p1.c | 335 +++++++++++++++++ ...netic_passive_boundary_surfx_1x1v_ser_p1.c | 52 +++ ...netic_passive_boundary_surfx_1x2v_ser_p1.c | 70 ++++ ...netic_passive_boundary_surfx_2x2v_ser_p1.c | 106 ++++++ ...netic_passive_boundary_surfx_3x2v_ser_p1.c | 178 ++++++++++ ...netic_passive_boundary_surfy_2x2v_ser_p1.c | 106 ++++++ ...netic_passive_boundary_surfy_3x2v_ser_p1.c | 178 ++++++++++ ...netic_passive_boundary_surfz_3x2v_ser_p1.c | 178 ++++++++++ ...dg_gyrokinetic_passive_surfx_1x1v_ser_p1.c | 38 ++ ...dg_gyrokinetic_passive_surfx_1x2v_ser_p1.c | 50 +++ ...dg_gyrokinetic_passive_surfx_2x2v_ser_p1.c | 74 ++++ ...dg_gyrokinetic_passive_surfx_3x2v_ser_p1.c | 122 +++++++ ...dg_gyrokinetic_passive_surfy_2x2v_ser_p1.c | 74 ++++ ...dg_gyrokinetic_passive_surfy_3x2v_ser_p1.c | 122 +++++++ ...dg_gyrokinetic_passive_surfz_3x2v_ser_p1.c | 122 +++++++ .../dg_gyrokinetic_passive_vol_1x1v_ser_p1.c | 41 +++ .../dg_gyrokinetic_passive_vol_1x2v_ser_p1.c | 45 +++ .../dg_gyrokinetic_passive_vol_2x2v_ser_p1.c | 74 ++++ .../dg_gyrokinetic_passive_vol_3x2v_ser_p1.c | 143 ++++++++ .../gkyl_dg_gyrokinetic_passive_kernels.h | 91 +++++ ...less_passive_flux_edge_surfx_1x1v_ser_p1.c | 82 +++++ ...less_passive_flux_edge_surfx_1x2v_ser_p1.c | 109 ++++++ ...less_passive_flux_edge_surfx_2x2v_ser_p1.c | 174 +++++++++ ...less_passive_flux_edge_surfx_3x2v_ser_p1.c | 303 ++++++++++++++++ ...less_passive_flux_edge_surfy_2x2v_ser_p1.c | 174 +++++++++ ...less_passive_flux_edge_surfy_3x2v_ser_p1.c | 303 ++++++++++++++++ ...less_passive_flux_edge_surfz_3x2v_ser_p1.c | 303 ++++++++++++++++ ...x_multib_boundary_edge_surfx_1x1v_ser_p1.c | 84 +++++ ...x_multib_boundary_edge_surfx_1x2v_ser_p1.c | 111 ++++++ ...x_multib_boundary_edge_surfx_2x2v_ser_p1.c | 188 ++++++++++ ...x_multib_boundary_edge_surfx_3x2v_ser_p1.c | 329 +++++++++++++++++ ...x_multib_boundary_edge_surfy_2x2v_ser_p1.c | 188 ++++++++++ ...x_multib_boundary_edge_surfy_3x2v_ser_p1.c | 329 +++++++++++++++++ ...x_multib_boundary_edge_surfz_3x2v_ser_p1.c | 329 +++++++++++++++++ ...e_flux_multib_boundary_surfx_1x1v_ser_p1.c | 84 +++++ ...e_flux_multib_boundary_surfx_1x2v_ser_p1.c | 111 ++++++ ...e_flux_multib_boundary_surfx_2x2v_ser_p1.c | 188 ++++++++++ ...e_flux_multib_boundary_surfx_3x2v_ser_p1.c | 329 +++++++++++++++++ ...e_flux_multib_boundary_surfy_2x2v_ser_p1.c | 188 ++++++++++ ...e_flux_multib_boundary_surfy_3x2v_ser_p1.c | 329 +++++++++++++++++ ...e_flux_multib_boundary_surfz_3x2v_ser_p1.c | 329 +++++++++++++++++ ...isionless_passive_flux_surfx_1x1v_ser_p1.c | 82 +++++ ...isionless_passive_flux_surfx_1x2v_ser_p1.c | 109 ++++++ ...isionless_passive_flux_surfx_2x2v_ser_p1.c | 174 +++++++++ ...isionless_passive_flux_surfx_3x2v_ser_p1.c | 303 ++++++++++++++++ ...isionless_passive_flux_surfy_2x2v_ser_p1.c | 174 +++++++++ ...isionless_passive_flux_surfy_3x2v_ser_p1.c | 303 ++++++++++++++++ ...isionless_passive_flux_surfz_3x2v_ser_p1.c | 303 ++++++++++++++++ ...yl_gk_collisionless_passive_flux_kernels.h | 239 +++++++++++++ gyrokinetic/zero/dg_gyrokinetic_passive.c | 114 ++++++ gyrokinetic/zero/dg_gyrokinetic_passive_cu.cu | 134 +++++++ .../zero/dg_updater_gyrokinetic_passive.c | 90 +++++ .../zero/gk_collisionless_passive_flux.c | 183 ++++++++++ .../zero/gk_collisionless_passive_flux_cu.cu | 199 +++++++++++ .../zero/gkyl_dg_gyrokinetic_passive.h | 49 +++ .../zero/gkyl_dg_gyrokinetic_passive_priv.h | 336 ++++++++++++++++++ .../gkyl_dg_updater_gyrokinetic_passive.h | 75 ++++ ...gkyl_dg_updater_gyrokinetic_passive_priv.h | 12 + .../zero/gkyl_gk_collisionless_passive_flux.h | 69 ++++ .../gkyl_gk_collisionless_passive_flux_priv.h | 163 +++++++++ 65 files changed, 10039 insertions(+), 39 deletions(-) create mode 100644 gyrokinetic/creg/rt_gk_passive_3x2v_p1.c create mode 100644 gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfx_1x1v_ser_p1.c create mode 100644 gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfx_1x2v_ser_p1.c create mode 100644 gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfx_2x2v_ser_p1.c create mode 100644 gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfx_3x2v_ser_p1.c create mode 100644 gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfy_2x2v_ser_p1.c create mode 100644 gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfy_3x2v_ser_p1.c create mode 100644 gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_boundary_surfz_3x2v_ser_p1.c create mode 100644 gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfx_1x1v_ser_p1.c create mode 100644 gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfx_1x2v_ser_p1.c create mode 100644 gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfx_2x2v_ser_p1.c create mode 100644 gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfx_3x2v_ser_p1.c create mode 100644 gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfy_2x2v_ser_p1.c create mode 100644 gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfy_3x2v_ser_p1.c create mode 100644 gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_surfz_3x2v_ser_p1.c create mode 100644 gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_vol_1x1v_ser_p1.c create mode 100644 gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_vol_1x2v_ser_p1.c create mode 100644 gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_vol_2x2v_ser_p1.c create mode 100644 gyrokinetic/ker/dg_gyrokinetic_passive/dg_gyrokinetic_passive_vol_3x2v_ser_p1.c create mode 100644 gyrokinetic/ker/dg_gyrokinetic_passive/gkyl_dg_gyrokinetic_passive_kernels.h create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfx_1x1v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfx_1x2v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfx_2x2v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfx_3x2v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfy_2x2v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfy_3x2v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_edge_surfz_3x2v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfx_1x1v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfx_1x2v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfx_2x2v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfx_3x2v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfy_2x2v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfy_3x2v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_edge_surfz_3x2v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfx_1x1v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfx_1x2v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfx_2x2v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfx_3x2v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfy_2x2v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfy_3x2v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_multib_boundary_surfz_3x2v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfx_1x1v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfx_1x2v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfx_2x2v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfx_3x2v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfy_2x2v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfy_3x2v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gk_collisionless_passive_flux_surfz_3x2v_ser_p1.c create mode 100644 gyrokinetic/ker/gk_collisionless_passive_flux/gkyl_gk_collisionless_passive_flux_kernels.h create mode 100644 gyrokinetic/zero/dg_gyrokinetic_passive.c create mode 100644 gyrokinetic/zero/dg_gyrokinetic_passive_cu.cu create mode 100644 gyrokinetic/zero/dg_updater_gyrokinetic_passive.c create mode 100644 gyrokinetic/zero/gk_collisionless_passive_flux.c create mode 100644 gyrokinetic/zero/gk_collisionless_passive_flux_cu.cu create mode 100644 gyrokinetic/zero/gkyl_dg_gyrokinetic_passive.h create mode 100644 gyrokinetic/zero/gkyl_dg_gyrokinetic_passive_priv.h create mode 100644 gyrokinetic/zero/gkyl_dg_updater_gyrokinetic_passive.h create mode 100644 gyrokinetic/zero/gkyl_dg_updater_gyrokinetic_passive_priv.h create mode 100644 gyrokinetic/zero/gkyl_gk_collisionless_passive_flux.h create mode 100644 gyrokinetic/zero/gkyl_gk_collisionless_passive_flux_priv.h 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/gyrokinetic/Makefile-gyrokinetic b/gyrokinetic/Makefile-gyrokinetic index ccf1c33622..f93b6fe7f3 100644 --- a/gyrokinetic/Makefile-gyrokinetic +++ b/gyrokinetic/Makefile-gyrokinetic @@ -143,6 +143,14 @@ ifdef USING_NVCC $(MKDIR_P) $(dir $@) $(CC) $(CFLAGS) $(NVCC_FLAGS) $(INCS) -c $< -o $@ +../$(BUILD_DIR)/gyrokinetic/$(KERNELS_DIR)/dg_gyrokinetic_passive/%.c.o : $(KERNELS_DIR)/dg_gyrokinetic_passive/%.c + $(MKDIR_P) $(dir $@) + $(CC) $(CFLAGS) $(NVCC_FLAGS) $(INCS) -c $< -o $@ + +../$(BUILD_DIR)/gyrokinetic/$(KERNELS_DIR)/gk_collisionless_passive_flux/%.c.o : $(KERNELS_DIR)/gk_collisionless_passive_flux/%.c + $(MKDIR_P) $(dir $@) + $(CC) $(CFLAGS) $(NVCC_FLAGS) $(INCS) -c $< -o $@ + ../$(BUILD_DIR)/gyrokinetic/$(KERNELS_DIR)/bc_sheath_gyrokinetic/%.c.o : $(KERNELS_DIR)/bc_sheath_gyrokinetic/%.c $(MKDIR_P) $(dir $@) $(CC) $(CFLAGS) $(NVCC_FLAGS) $(INCS) -c $< -o $@ diff --git a/gyrokinetic/apps/gk_species_collisionless.c b/gyrokinetic/apps/gk_species_collisionless.c index b6520b51a4..1e6ce12d05 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,69 @@ 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); + + 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 +216,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 +232,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 +239,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 +280,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 +314,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/creg/rt_gk_passive_3x2v_p1.c b/gyrokinetic/creg/rt_gk_passive_3x2v_p1.c new file mode 100644 index 0000000000..1b6e2833f2 --- /dev/null +++ b/gyrokinetic/creg/rt_gk_passive_3x2v_p1.c @@ -0,0 +1,335 @@ +#include +#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 = 0.50; // CFL coefficient. + + double t_end = 100.; // Final simulation time. + int num_frames = 100; // 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) +{ + 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]; + + 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 +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/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..a6df0ceff9 --- /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); + up->flux_surf_edge_up[d] = choose_gk_collisionless_passive_flux_edge_up_surf_conf_kern(d, cdim, vdim, poly_order); + } + + 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..f5a350ff6a --- /dev/null +++ b/gyrokinetic/zero/gk_collisionless_passive_flux_cu.cu @@ -0,0 +1,199 @@ +/* -*- 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) +{ + 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); + up->flux_surf_edge_up[d] = choose_gk_collisionless_passive_flux_edge_up_surf_conf_kern(d, cdim, vdim, poly_order); + } +} + +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); + + // 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); + + 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_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..d492d4087c --- /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, + gkyl_array_cfetch(gkp->vel_map->vmap, vidx), + gkyl_array_cfetch(gkp->vel_map->vmap_sq, vidx), + gkp->charge, gkp->mass, + gkyl_array_cfetch(gkp->gk_geom->geo_corn.bmag, cidx), + 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, + gkyl_array_cfetch(gkp->vel_map->vmap, vidx), + gkyl_array_cfetch(gkp->vel_map->vmap_sq, vidx), + gkp->charge, gkp->mass, + gkyl_array_cfetch(gkp->gk_geom->geo_corn.bmag, cidx), + 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, + gkyl_array_cfetch(gkp->vel_map->vmap, vidx), + gkyl_array_cfetch(gkp->vel_map->vmap_sq, vidx), + gkp->charge, gkp->mass, + gkyl_array_cfetch(gkp->gk_geom->geo_corn.bmag, cidx), + 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, + gkyl_array_cfetch(gkp->vel_map->vmap, vidx), + gkyl_array_cfetch(gkp->vel_map->vmap_sq, vidx), + gkp->charge, gkp->mass, + gkyl_array_cfetch(gkp->gk_geom->geo_corn.bmag, cidx), + 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, + gkyl_array_cfetch(gkp->vel_map->vmap_prime, vidxL), + gkyl_array_cfetch(gkp->vel_map->vmap_prime, vidxC), + gkyl_array_cfetch(gkp->vel_map->vmap_prime, vidxR), + gkyl_array_cfetch(gkp->auxfields.flux_surf, pidxC), + 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, + gkyl_array_cfetch(gkp->vel_map->vmap_prime, vidxEdge), + gkyl_array_cfetch(gkp->vel_map->vmap_prime, vidxSkin), + gkyl_array_cfetch(gkp->auxfields.flux_surf, pidxEdge), + 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..7a500323ea --- /dev/null +++ b/gyrokinetic/zero/gkyl_dg_updater_gyrokinetic_passive.h @@ -0,0 +1,75 @@ +#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); + +/** + * 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..79ace08dce --- /dev/null +++ b/gyrokinetic/zero/gkyl_gk_collisionless_passive_flux_priv.h @@ -0,0 +1,163 @@ +// 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 +}; + +// 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) +{ + 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; +} + +// 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) +{ + // Upper-edge kernels use the same list as lower-edge kernels. + return choose_gk_collisionless_passive_flux_edge_lo_surf_conf_kern(dir, cdim, vdim, poly_order); +} + +// 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); From 1056915cb36184f0b4c7cfb459e8603906b94245 Mon Sep 17 00:00:00 2001 From: manauref Date: Fri, 3 Jul 2026 15:48:46 -0700 Subject: [PATCH 02/19] Change field_id in rt_gk_passive so that the omega_H dt doesn't show up. We should make it so that omega_H is only computed if the field evolves. Passive eqn object is clearly not ready as the result is not as expected. --- gyrokinetic/creg/rt_gk_passive_3x2v_p1.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/gyrokinetic/creg/rt_gk_passive_3x2v_p1.c b/gyrokinetic/creg/rt_gk_passive_3x2v_p1.c index 1b6e2833f2..38ecbb4a47 100644 --- a/gyrokinetic/creg/rt_gk_passive_3x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_passive_3x2v_p1.c @@ -81,7 +81,7 @@ create_ctx(void) 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 = 0.50; // CFL coefficient. + double cfl_frac = 1.0; // CFL coefficient. double t_end = 100.; // Final simulation time. int num_frames = 100; // Number of output frames. @@ -258,12 +258,7 @@ main(int argc, char **argv) // Field. struct gkyl_gyrokinetic_field field = { - .poisson_bcs = { - { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_FIELD_DIRICHLET, .value = {0.0} }, - { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_FIELD_DIRICHLET, .value = {0.0} }, - { .dir = 1, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_FIELD_PERIODIC }, - { .dir = 1, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_FIELD_PERIODIC }, - }, + .gkfield_id = GKYL_GK_FIELD_BOLTZMANN, .zero_init_field = true, .is_static = true, }; @@ -320,6 +315,10 @@ main(int argc, char **argv) .restart_frame = app_args.restart_frame, .num_steps = app_args.num_steps, }, +// .print_verbosity = { +// .enabled = true, +// .disable_timings = true, +// }, }; gkyl_gyrokinetic_run_simulation(&run_inp); From 9aff9871ef4bf4029429b52984e08bde9c9ca384 Mon Sep 17 00:00:00 2001 From: manauref Date: Sat, 4 Jul 2026 15:37:18 -0700 Subject: [PATCH 03/19] Sync advection speeds so that parallel runs come out correctly. Add 2x2v passive advection reg test. Tried using TS BCs in passive advection but I think there's a memory bug, need to switch to cluster with valgrind. --- gyrokinetic/apps/gk_species_collisionless.c | 6 + gyrokinetic/creg/rt_gk_passive_2x2v_p1.c | 324 ++++++++++++++++++++ gyrokinetic/creg/rt_gk_passive_3x2v_p1.c | 42 ++- gyrokinetic/creg/rt_gk_tcv_core_3x2v_p1.c | 4 +- 4 files changed, 363 insertions(+), 13 deletions(-) create mode 100644 gyrokinetic/creg/rt_gk_passive_2x2v_p1.c diff --git a/gyrokinetic/apps/gk_species_collisionless.c b/gyrokinetic/apps/gk_species_collisionless.c index 1e6ce12d05..10fffe3592 100644 --- a/gyrokinetic/apps/gk_species_collisionless.c +++ b/gyrokinetic/apps/gk_species_collisionless.c @@ -155,6 +155,12 @@ gk_species_collisionless_init_passive(struct gkyl_gyrokinetic_app *app, struct g 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); diff --git a/gyrokinetic/creg/rt_gk_passive_2x2v_p1.c b/gyrokinetic/creg/rt_gk_passive_2x2v_p1.c new file mode 100644 index 0000000000..765f03ca94 --- /dev/null +++ b/gyrokinetic/creg/rt_gk_passive_2x2v_p1.c @@ -0,0 +1,324 @@ +#include +#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; dB0; // zc are computational coords. @@ -187,6 +188,21 @@ bfield_func(double t, const double* GKYL_RESTRICT zc, double* GKYL_RESTRICT fout 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) { @@ -235,10 +251,10 @@ main(int argc, char **argv) .write_diagnostics = true, }, -// .bcs = { -// { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_TWISTSHIFT, }, -// { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_TWISTSHIFT, }, -// }, + .bcs = { + { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_TWISTSHIFT, }, + { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_TWISTSHIFT, }, + }, .num_diag_moments = 3, .diag_moments = { GKYL_F_MOMENT_M0, GKYL_F_MOMENT_M1, GKYL_F_MOMENT_M2, }, @@ -281,11 +297,15 @@ main(int argc, char **argv) .mapc2p = mapc2p, .c2p_ctx = &ctx, .bfield_func = bfield_func, - .bfield_ctx = &ctx + .bfield_ctx = &ctx, + .parallel_lower_bc_shift_func = bc_shift_func_lo, + .parallel_upper_bc_shift_func = bc_shift_func_up, + .parallel_lower_bc_shift_ctx = &ctx, + .parallel_upper_bc_shift_ctx = &ctx, }, - .num_periodic_dir = 2, - .periodic_dirs = { 1, 2 }, + .num_periodic_dir = 1, + .periodic_dirs = { 1, }, .num_species = 1, .species = { elc, }, diff --git a/gyrokinetic/creg/rt_gk_tcv_core_3x2v_p1.c b/gyrokinetic/creg/rt_gk_tcv_core_3x2v_p1.c index 52170f5891..07483e639a 100644 --- a/gyrokinetic/creg/rt_gk_tcv_core_3x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_tcv_core_3x2v_p1.c @@ -713,8 +713,8 @@ main(int argc, char **argv) .bcs = { { .dir = 0, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB, }, { .dir = 0, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_ABSORB, }, - { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_TWISTSHIFT, .aux_profile = bc_shift_func_lo, .aux_ctx = &ctx, }, - { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_TWISTSHIFT, .aux_profile = bc_shift_func_up, .aux_ctx = &ctx, }, + { .dir = 2, .edge = GKYL_LOWER_EDGE, .type = GKYL_BC_GK_SPECIES_TWISTSHIFT, }, + { .dir = 2, .edge = GKYL_UPPER_EDGE, .type = GKYL_BC_GK_SPECIES_TWISTSHIFT, }, }, .num_diag_moments = 9, .diag_moments = {GKYL_F_MOMENT_HAMILTONIAN, GKYL_F_MOMENT_BIMAXWELLIAN, From b3601fdbfe480264787c5cf6ddde4e1b8529ec1b Mon Sep 17 00:00:00 2001 From: manauref Date: Mon, 6 Jul 2026 00:38:20 -0700 Subject: [PATCH 04/19] I think the changes to rect_grid_find_cell in a recent PR might've broken its use in bc_twistshift. Also, I think there was a bug in find_cell all along, though I don't know if it was ever triggered. Fix this bug, and adjust a tolerance in twistshift to make it work with the recently added epsilon in rect_grid_find_cell. Unit tests pass. There's still an issue with passive advection using TS BCs because the solution quickly becomes NaNs. --- core/zero/gkyl_rect_grid.h | 3 +-- core/zero/rect_grid.c | 3 +-- gyrokinetic/creg/rt_gk_passive_3x2v_p1.c | 2 ++ gyrokinetic/zero/bc_twistshift.c | 9 +++++---- 4 files changed, 9 insertions(+), 8 deletions(-) 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; 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. From fa5ca03c7869ef0123d3dea5126a411d6ebdc29c Mon Sep 17 00:00:00 2001 From: manauref Date: Mon, 6 Jul 2026 11:58:50 -0700 Subject: [PATCH 05/19] Add TS BC unit test corresponding to figure 14 of the paper. Seems to show that the shift at the lower boundary is OK, but the shift at the upper boundary (which -1 times the lower shift) produces NaNs. --- gyrokinetic/unit/ctest_bc_twistshift.c | 323 +++++++++++++++++++++++++ 1 file changed, 323 insertions(+) diff --git a/gyrokinetic/unit/ctest_bc_twistshift.c b/gyrokinetic/unit/ctest_bc_twistshift.c index 47319fb346..9ad353cc94 100644 --- a/gyrokinetic/unit/ctest_bc_twistshift.c +++ b/gyrokinetic/unit/ctest_bc_twistshift.c @@ -115,6 +115,7 @@ struct test_bc_twistshift_ctx { double B0; double vt; double mass; + enum gkyl_edge_loc edge; }; void @@ -1181,6 +1182,293 @@ 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_new(&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) ); +// } +// +// if (apply_in_half_x != 0) { +// // Check that the other half is untouched. +// int skin_idx[GKYL_MAX_DIM]; +// gkyl_range_iter_init(&iter, &check_other_ghost_rng); +// while (gkyl_range_iter_next(&iter)) { +// long linidx = gkyl_range_idx(&check_other_ghost_rng, iter.idx); +// double *f_c = gkyl_array_fetch(distf_ho, linidx); +// +// for (int d=0; dncomp; k++) +// TEST_CHECK( gkyl_compare(fskin_c[k], f_c[k], 1e-15) ); +// } +// } + } + + 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) @@ -1663,6 +1951,37 @@ test_bc_twistshift_3x_fig11(bool use_gpu) test_bc_twistshift_3x_fig11_wcells(cells2, edgelo, 1, false, use_gpu, false); } +void +test_bc_twistshift_3x_fig14(bool use_gpu) +{ + const int cells0[] = {8 , 8 , 4}; + const int cells1[] = {16, 16, 4}; + const int cells2[] = {32, 32, 4}; + const int cells3[] = {64, 32, 4}; + + enum gkyl_edge_loc edgelo = GKYL_LOWER_EDGE; // Lower edge. +// test_bc_twistshift_3x_fig14_wcells(cells0, edgelo, 0, true, use_gpu, true); +// test_bc_twistshift_3x_fig14_wcells(cells1, edgelo, 0, false, use_gpu, true); +// test_bc_twistshift_3x_fig14_wcells(cells2, edgelo, 0, false, use_gpu, false); +// test_bc_twistshift_3x_fig14_wcells(cells3, edgelo, 0, false, use_gpu, true); +// + enum gkyl_edge_loc edgeup = GKYL_UPPER_EDGE; // Upper edge. +// test_bc_twistshift_3x_fig14_wcells(cells0, edgeup, 0, true, use_gpu, false); + test_bc_twistshift_3x_fig14_wcells(cells1, edgeup, 0, false, use_gpu, true); +// test_bc_twistshift_3x_fig14_wcells(cells2, edgeup, 0, false, use_gpu, false); +// test_bc_twistshift_3x_fig14_wcells(cells3, edgeup, 0, false, use_gpu, true); +// +// // Apply the TS BC on the lower half of the x domain. +// test_bc_twistshift_3x_fig14_wcells(cells0, edgelo, -1, true, use_gpu, false); +// test_bc_twistshift_3x_fig14_wcells(cells1, edgelo, -1, false, use_gpu, false); +// test_bc_twistshift_3x_fig14_wcells(cells2, edgelo, -1, false, use_gpu, false); +// +// // Apply the TS BC on the upper half of the x domain. +// test_bc_twistshift_3x_fig14_wcells(cells0, edgelo, 1, true, use_gpu, false); +// test_bc_twistshift_3x_fig14_wcells(cells1, edgelo, 1, false, use_gpu, false); +// test_bc_twistshift_3x_fig14_wcells(cells2, edgelo, 1, false, use_gpu, false); +} + void test_bc_twistshift_3x2v_fig11(bool use_gpu) { @@ -1696,6 +2015,7 @@ test_bc_twistshift_3x2v_fig11(bool use_gpu) void test_bc_twistshift_3x_fig6_ho(){ test_bc_twistshift_3x_fig6(false); } void test_bc_twistshift_3x_fig11_ho(){ test_bc_twistshift_3x_fig11(false); } +void test_bc_twistshift_3x_fig14_ho(){ test_bc_twistshift_3x_fig14(false); } void test_bc_twistshift_3x2v_fig6_ho(){ test_bc_twistshift_3x2v_fig6(false); } void test_bc_twistshift_3x2v_fig11_ho(){ test_bc_twistshift_3x2v_fig11(false); } @@ -1706,16 +2026,19 @@ void test_bc_twistshift_3x_fig11_dev(){ test_bc_twistshift_3x_fig11(true); } void test_bc_twistshift_3x2v_fig6_dev(){ test_bc_twistshift_3x2v_fig6(true); } void test_bc_twistshift_3x2v_fig11_dev(){ test_bc_twistshift_3x2v_fig11(true); } +void test_bc_twistshift_3x_fig14_dev(){ test_bc_twistshift_3x_fig14(true); } #endif TEST_LIST = { { "test_bc_twistshift_3x_fig6_ho", test_bc_twistshift_3x_fig6_ho }, { "test_bc_twistshift_3x_fig11_ho", test_bc_twistshift_3x_fig11_ho }, + { "test_bc_twistshift_3x_fig14_ho", test_bc_twistshift_3x_fig14_ho }, { "test_bc_twistshift_3x2v_fig6_ho", test_bc_twistshift_3x2v_fig6_ho }, { "test_bc_twistshift_3x2v_fig11_ho", test_bc_twistshift_3x2v_fig11_ho }, #ifdef GKYL_HAVE_CUDA { "test_bc_twistshift_3x_fig6_dev", test_bc_twistshift_3x_fig6_dev }, { "test_bc_twistshift_3x_fig11_dev", test_bc_twistshift_3x_fig11_dev }, + { "test_bc_twistshift_3x_fig14_dev", test_bc_twistshift_3x_fig14_dev }, { "test_bc_twistshift_3x2v_fig6_dev", test_bc_twistshift_3x2v_fig6_dev }, { "test_bc_twistshift_3x2v_fig11_dev", test_bc_twistshift_3x2v_fig11_dev }, #endif From 965ca1ac4f877d9b0d740b28d2b9bc2550dfe747 Mon Sep 17 00:00:00 2001 From: manauref Date: Mon, 6 Jul 2026 22:53:27 -0700 Subject: [PATCH 06/19] Protect against integrating over zero-volume regions in some sub-cell integrals of bc_twistshift, it was causing NaNs in the fig14 scenario. Fix boundary kernel selection in gk_collisionless_passive_flux. Now the passive advection test with TS BCs looks as expected. --- gyrokinetic/creg/rt_gk_passive_3x2v_p1.c | 6 +- gyrokinetic/unit/ctest_bc_twistshift.c | 322 ++++++++++++++---- gyrokinetic/zero/bc_twistshift.c | 20 +- .../zero/gk_collisionless_passive_flux.c | 6 +- .../gkyl_gk_collisionless_passive_flux_priv.h | 113 +++++- 5 files changed, 375 insertions(+), 92 deletions(-) diff --git a/gyrokinetic/creg/rt_gk_passive_3x2v_p1.c b/gyrokinetic/creg/rt_gk_passive_3x2v_p1.c index 52ad008770..09898d885a 100644 --- a/gyrokinetic/creg/rt_gk_passive_3x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_passive_3x2v_p1.c @@ -83,8 +83,8 @@ create_ctx(void) int poly_order = 1; // Polynomial order. double cfl_frac = 1.0; // CFL coefficient. - double t_end = 4.; // Final simulation time. - int num_frames = 100; // Number of output frames. + 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. @@ -194,7 +194,7 @@ void bc_shift_func_lo(double t, const double *xc, double* GKYL_RESTRICT fout, vo struct gk_app_ctx *app = ctx; - fout[0] = x-0.5; + fout[0] = -(x-0.5); } void bc_shift_func_up(double t, const double *xc, double* GKYL_RESTRICT fout, void *ctx) diff --git a/gyrokinetic/unit/ctest_bc_twistshift.c b/gyrokinetic/unit/ctest_bc_twistshift.c index 9ad353cc94..fd4b348d38 100644 --- a/gyrokinetic/unit/ctest_bc_twistshift.c +++ b/gyrokinetic/unit/ctest_bc_twistshift.c @@ -1226,7 +1226,7 @@ shift_fig14(double t, const double *xn, double* GKYL_RESTRICT fout, void *ctx) }; enum gkyl_edge_loc edge = pars->edge; - fout[0] = x-0.5; + fout[0] = -(x-0.5); if (edge == GKYL_UPPER_EDGE) fout[0] *= -1.0; @@ -1395,18 +1395,236 @@ test_bc_twistshift_3x_fig14_wcells(const int *cells, enum gkyl_edge_loc edge, if (check_distf) { // Check 0th, 1st, 2nd and 6th DG coeffs. - const double f0[] = - { - }; - const double f1[] = - { - }; - const double f2[] = - { - }; - const double f6[] = - { - }; + double f0[64], f1[64], f2[64], f6[64]; + + if (edge == GKYL_UPPER_EDGE) { + const double f0m[] = + { + 2.8284271247461891e-10, 2.8284271247461891e-10, + 2.8284271247461891e-10, 2.8284271247461891e-10, 2.8284271247461891e-10, + 2.8284271247461891e-10, 2.8284271247461891e-10, 2.8284271247461891e-10, + 2.8284271247461891e-10, 2.8284271247461891e-10, + 2.8284271247461891e-10, 2.8284271247461891e-10, 2.8284271247461891e-10, + 2.8284271247461891e-10, 2.8284271247461891e-10, 2.8284271247461891e-10, + 1.4142135625145160e+00, 2.8284271247461894e+00, + 2.8284271247461894e+00, 2.8284271247461894e+00, 1.4142135625145160e+00, + 2.8284271247461891e-10, 2.8284271247461891e-10, 2.8284271247461891e-10, + 2.8284271247461891e-10, 1.4142135625145160e+00, + 2.8284271247461894e+00, 2.8284271247461894e+00, 2.8284271247461894e+00, + 1.4142135625145160e+00, 2.8284271247461891e-10, 2.8284271247461891e-10, + 2.8284271247461891e-10, 2.8284271247461891e-10, + 1.4142135625145160e+00, 2.8284271247461894e+00, 2.8284271247461894e+00, + 2.8284271247461894e+00, 1.4142135625145160e+00, 2.8284271247461891e-10, + 2.8284271247461891e-10, 2.8284271247461891e-10, + 2.8284271247461891e-10, 1.4142135625145160e+00, 2.8284271247461894e+00, + 2.8284271247461894e+00, 2.8284271247461894e+00, 1.4142135625145160e+00, + 2.8284271247461891e-10, 2.8284271247461891e-10, + 2.8284271247461891e-10, 2.8284271247461891e-10, 2.8284271247461891e-10, + 2.8284271247461891e-10, 2.8284271247461891e-10, 2.8284271247461891e-10, + 2.8284271247461891e-10, 2.8284271247461891e-10, + 2.8284271247461891e-10, 2.8284271247461891e-10, 2.8284271247461891e-10, + 2.8284271247461891e-10, 2.8284271247461891e-10, 2.8284271247461891e-10, + }; + const double f1m[] = + { + -2.5849394142282115e-26, -2.5849394142282115e-26, -2.5849394142282115e-26, + -2.5849394142282115e-26, -2.5849394142282115e-26, -2.5849394142282115e-26, + -2.5849394142282115e-26, -2.5849394142282115e-26, + -2.5849394142282115e-26, -2.5849394142282115e-26, -2.5849394142282115e-26, + -2.5849394142282115e-26, -2.5849394142282115e-26, -2.5849394142282115e-26, + -2.5849394142282115e-26, -2.5849394142282115e-26, + -8.1649658084607613e-01, 0.0000000000000000e+00, 0.0000000000000000e+00, + 0.0000000000000000e+00, 8.1649658084607613e-01, -2.5849394142282115e-26, + -2.5849394142282115e-26, -2.5849394142282115e-26, + -2.5849394142282115e-26, -8.1649658084607613e-01, 0.0000000000000000e+00, + 0.0000000000000000e+00, 0.0000000000000000e+00, 8.1649658084607613e-01, + -2.5849394142282115e-26, -2.5849394142282115e-26, + -2.5849394142282115e-26, -2.5849394142282115e-26, -8.1649658084607613e-01, + 0.0000000000000000e+00, 0.0000000000000000e+00, 0.0000000000000000e+00, + 8.1649658084607613e-01, -2.5849394142282115e-26, + -2.5849394142282115e-26, -2.5849394142282115e-26, -2.5849394142282115e-26, + -8.1649658084607613e-01, 0.0000000000000000e+00, 0.0000000000000000e+00, + 0.0000000000000000e+00, 8.1649658084607613e-01, + -2.5849394142282115e-26, -2.5849394142282115e-26, -2.5849394142282115e-26, + -2.5849394142282115e-26, -2.5849394142282115e-26, -2.5849394142282115e-26, + -2.5849394142282115e-26, -2.5849394142282115e-26, + -2.5849394142282115e-26, -2.5849394142282115e-26, -2.5849394142282115e-26, + -2.5849394142282115e-26, -2.5849394142282115e-26, -2.5849394142282115e-26, + -2.5849394142282115e-26, -2.5849394142282115e-26, + }; + const double f2m[] = + { + -5.2991257991678335e-25, -5.2991257991678335e-25, -5.2991257991678335e-25, + -5.2991257991678335e-25, -5.2991257991678335e-25, -5.2991257991678335e-25, + -5.2991257991678335e-25, -5.2991257991678335e-25, + -3.4896682092080855e-25, -3.4896682092080855e-25, -3.4896682092080855e-25, + -3.4896682092080855e-25, -3.4896682092080855e-25, -3.4896682092080855e-25, + -3.4896682092080855e-25, -3.4896682092080855e-25, + 8.1649658084607457e-01, -2.5535129566378600e-15, -2.5535129566378600e-15, + -2.5535129566378600e-15, -8.1649658084607712e-01, -2.5849394142282115e-25, + -2.5849394142282115e-25, -2.5849394142282115e-25, + -6.4623485355705287e-26, 8.1649658084607535e-01, -6.6613381477509392e-16, + -6.6613381477509392e-16, -6.6613381477509392e-16, -8.1649658084607601e-01, + -6.4623485355705287e-26, -6.4623485355705287e-26, + 6.4623485355705287e-26, 6.4623485355705287e-26, 8.1649658084607601e-01, + 6.6613381477509392e-16, 6.6613381477509392e-16, 6.6613381477509392e-16, + -8.1649658084607535e-01, 6.4623485355705287e-26, + 2.5849394142282115e-25, 2.5849394142282115e-25, 2.5849394142282115e-25, + 8.1649658084607712e-01, 2.5535129566378600e-15, 2.5535129566378600e-15, + 2.5535129566378600e-15, -8.1649658084607457e-01, + 5.2991257991678335e-25, 5.2991257991678335e-25, 5.2991257991678335e-25, + 5.2991257991678335e-25, 5.2991257991678335e-25, 5.2991257991678335e-25, + 5.2991257991678335e-25, 5.2991257991678335e-25, + 5.2991257991678335e-25, 5.2991257991678335e-25, 5.2991257991678335e-25, + 5.2991257991678335e-25, 5.2991257991678335e-25, 5.2991257991678335e-25, + 5.2991257991678335e-25, 5.2991257991678335e-25, + }; + const double f6m[] = + { + 1.2712579668354740e-41, 1.2712579668354740e-41, 1.2712579668354740e-41, + 1.2712579668354740e-41, 1.2712579668354740e-41, 1.2712579668354740e-41, + 1.2712579668354740e-41, 1.2712579668354740e-41, + -3.1389085600875902e-43, -3.1389085600875902e-43, -3.1389085600875902e-43, + -3.1389085600875902e-43, -3.1389085600875902e-43, -3.1389085600875902e-43, + -3.1389085600875902e-43, -3.1389085600875902e-43, + -1.1538233466087235e-28, 0.0000000000000000e+00, 0.0000000000000000e+00, + 0.0000000000000000e+00, 1.1538233466087551e-28, 3.1613293355167873e-42, + 3.1613293355167873e-42, 3.1613293355167873e-42, + 3.2061708863751815e-42, -1.1538233466087102e-28, 0.0000000000000000e+00, + 0.0000000000000000e+00, 0.0000000000000000e+00, 1.1538233466087423e-28, + 3.2061708863751815e-42, 3.2061708863751815e-42, + 1.9730282377693424e-42, 1.9730282377693424e-42, -1.1538233466087044e-28, + 0.0000000000000000e+00, 0.0000000000000000e+00, 0.0000000000000000e+00, + 1.1538233466087241e-28, 1.9730282377693424e-42, + 9.8651411888467122e-43, 9.8651411888467122e-43, 9.8651411888467122e-43, + -1.1538233466086849e-28, 0.0000000000000000e+00, 0.0000000000000000e+00, + 0.0000000000000000e+00, 1.1538233466086948e-28, + 1.9057659114817512e-42, 1.9057659114817512e-42, 1.9057659114817512e-42, + 1.9057659114817512e-42, 1.9057659114817512e-42, 1.9057659114817512e-42, + 1.9057659114817512e-42, 1.9057659114817512e-42, + -1.5470335046145980e-42, -1.5470335046145980e-42, -1.5470335046145980e-42, + -1.5470335046145980e-42, -1.5470335046145980e-42, -1.5470335046145980e-42, + -1.5470335046145980e-42, -1.5470335046145980e-42, + }; + int nvals = sizeof(f0m)/sizeof(f0m[0]); + for (int i=0; incomp; k++) -// TEST_CHECK( gkyl_compare(fskin_c[k], f_c[k], 1e-15) ); -// } -// } + 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); @@ -1929,7 +2125,7 @@ test_bc_twistshift_3x_fig11(bool use_gpu) const int cells3[] = {80, 40, 4}; enum gkyl_edge_loc edgelo = GKYL_LOWER_EDGE; // Lower edge. - test_bc_twistshift_3x_fig11_wcells(cells0, edgelo, 0, true, use_gpu, true); + test_bc_twistshift_3x_fig11_wcells(cells0, edgelo, 0, true, use_gpu, false); test_bc_twistshift_3x_fig11_wcells(cells1, edgelo, 0, false, use_gpu, false); test_bc_twistshift_3x_fig11_wcells(cells2, edgelo, 0, false, use_gpu, false); test_bc_twistshift_3x_fig11_wcells(cells3, edgelo, 0, false, use_gpu, true); @@ -1938,7 +2134,7 @@ test_bc_twistshift_3x_fig11(bool use_gpu) test_bc_twistshift_3x_fig11_wcells(cells0, edgeup, 0, true, use_gpu, false); test_bc_twistshift_3x_fig11_wcells(cells1, edgeup, 0, false, use_gpu, false); test_bc_twistshift_3x_fig11_wcells(cells2, edgeup, 0, false, use_gpu, false); - test_bc_twistshift_3x_fig11_wcells(cells3, edgeup, 0, false, use_gpu, true); + test_bc_twistshift_3x_fig11_wcells(cells3, edgeup, 0, false, use_gpu, false); // Apply the TS BC on the lower half of the x domain. test_bc_twistshift_3x_fig11_wcells(cells0, edgelo, -1, true, use_gpu, false); @@ -1960,26 +2156,16 @@ test_bc_twistshift_3x_fig14(bool use_gpu) const int cells3[] = {64, 32, 4}; enum gkyl_edge_loc edgelo = GKYL_LOWER_EDGE; // Lower edge. -// test_bc_twistshift_3x_fig14_wcells(cells0, edgelo, 0, true, use_gpu, true); -// test_bc_twistshift_3x_fig14_wcells(cells1, edgelo, 0, false, use_gpu, true); -// test_bc_twistshift_3x_fig14_wcells(cells2, edgelo, 0, false, use_gpu, false); -// test_bc_twistshift_3x_fig14_wcells(cells3, edgelo, 0, false, use_gpu, true); -// + test_bc_twistshift_3x_fig14_wcells(cells0, edgelo, 0, true, use_gpu, false); + test_bc_twistshift_3x_fig14_wcells(cells1, edgelo, 0, false, use_gpu, false); + test_bc_twistshift_3x_fig14_wcells(cells2, edgelo, 0, false, use_gpu, false); + test_bc_twistshift_3x_fig14_wcells(cells3, edgelo, 0, false, use_gpu, false); + enum gkyl_edge_loc edgeup = GKYL_UPPER_EDGE; // Upper edge. -// test_bc_twistshift_3x_fig14_wcells(cells0, edgeup, 0, true, use_gpu, false); - test_bc_twistshift_3x_fig14_wcells(cells1, edgeup, 0, false, use_gpu, true); -// test_bc_twistshift_3x_fig14_wcells(cells2, edgeup, 0, false, use_gpu, false); -// test_bc_twistshift_3x_fig14_wcells(cells3, edgeup, 0, false, use_gpu, true); -// -// // Apply the TS BC on the lower half of the x domain. -// test_bc_twistshift_3x_fig14_wcells(cells0, edgelo, -1, true, use_gpu, false); -// test_bc_twistshift_3x_fig14_wcells(cells1, edgelo, -1, false, use_gpu, false); -// test_bc_twistshift_3x_fig14_wcells(cells2, edgelo, -1, false, use_gpu, false); -// -// // Apply the TS BC on the upper half of the x domain. -// test_bc_twistshift_3x_fig14_wcells(cells0, edgelo, 1, true, use_gpu, false); -// test_bc_twistshift_3x_fig14_wcells(cells1, edgelo, 1, false, use_gpu, false); -// test_bc_twistshift_3x_fig14_wcells(cells2, edgelo, 1, false, use_gpu, false); + test_bc_twistshift_3x_fig14_wcells(cells0, edgeup, 0, true, use_gpu, false); + test_bc_twistshift_3x_fig14_wcells(cells1, edgeup, 0, false, use_gpu, false); + test_bc_twistshift_3x_fig14_wcells(cells2, edgeup, 0, false, use_gpu, false); + test_bc_twistshift_3x_fig14_wcells(cells3, edgeup, 0, false, use_gpu, false); } void diff --git a/gyrokinetic/zero/bc_twistshift.c b/gyrokinetic/zero/bc_twistshift.c index 0be008081c..614829d8dc 100644 --- a/gyrokinetic/zero/bc_twistshift.c +++ b/gyrokinetic/zero/bc_twistshift.c @@ -697,8 +697,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[0].value, xc_do[up->shear_dir_in_ts_grid], up->ts_grid.dx[up->shear_dir_in_ts_grid]); @@ -728,8 +729,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]); @@ -931,8 +933,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]); @@ -962,8 +965,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]); diff --git a/gyrokinetic/zero/gk_collisionless_passive_flux.c b/gyrokinetic/zero/gk_collisionless_passive_flux.c index a6df0ceff9..d1a022d445 100644 --- a/gyrokinetic/zero/gk_collisionless_passive_flux.c +++ b/gyrokinetic/zero/gk_collisionless_passive_flux.c @@ -46,9 +46,9 @@ gkyl_gk_collisionless_passive_flux_new(const struct gkyl_rect_grid *phase_grid, // 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); - up->flux_surf_edge_up[d] = choose_gk_collisionless_passive_flux_edge_up_surf_conf_kern(d, cdim, vdim, poly_order); + 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; diff --git a/gyrokinetic/zero/gkyl_gk_collisionless_passive_flux_priv.h b/gyrokinetic/zero/gkyl_gk_collisionless_passive_flux_priv.h index 79ace08dce..869a28e5a0 100644 --- a/gyrokinetic/zero/gkyl_gk_collisionless_passive_flux_priv.h +++ b/gyrokinetic/zero/gkyl_gk_collisionless_passive_flux_priv.h @@ -109,6 +109,64 @@ static const gkyl_gk_collisionless_passive_flux_surf_kern_list ser_gk_collisionl { 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 @@ -120,30 +178,65 @@ choose_gk_collisionless_passive_flux_surf_conf_kern(int dir, int cdim, int vdim, 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) +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 (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]; + 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) +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) { - // Upper-edge kernels use the same list as lower-edge kernels. - return choose_gk_collisionless_passive_flux_edge_lo_surf_conf_kern(dir, cdim, vdim, poly_order); + 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). From 5af001fe1e60e17c53160be7d143071cf4651ba3 Mon Sep 17 00:00:00 2001 From: manauref Date: Tue, 7 Jul 2026 12:26:53 -0700 Subject: [PATCH 07/19] Add passive advection CBC test. Works fine with constant q, but the quadratic q has issues near the upper radial boundary. We'll examine this in a unit test setting, and try it with TCV geo. --- gyrokinetic/apps/gk_species_bflux.c | 5 +- gyrokinetic/creg/rt_gk_cbc_passive_3x2v_p1.c | 665 ++++++++++++++++++ .../gkyl_dg_updater_gyrokinetic_passive.h | 10 + 3 files changed, 679 insertions(+), 1 deletion(-) create mode 100644 gyrokinetic/creg/rt_gk_cbc_passive_3x2v_p1.c 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/creg/rt_gk_cbc_passive_3x2v_p1.c b/gyrokinetic/creg/rt_gk_cbc_passive_3x2v_p1.c new file mode 100644 index 0000000000..5df7feaade --- /dev/null +++ b/gyrokinetic/creg/rt_gk_cbc_passive_3x2v_p1.c @@ -0,0 +1,665 @@ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef GKYL_HAVE_MPI +#include +#include +#ifdef GKYL_HAVE_NCCL +#include +#endif +#endif + +#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 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.; + // 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 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 = 16; + 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 = 1.00; + int num_frames = 1; + 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 Date: Tue, 7 Jul 2026 13:50:01 -0700 Subject: [PATCH 08/19] Add a TS BC unit test with the same setup as the CBC reg test. We may delete or simplify this in the future, but it already reproduces the checkerboard pattern seen in the simulation. --- gyrokinetic/unit/ctest_bc_twistshift.c | 354 +++++++++++++++++++++++++ 1 file changed, 354 insertions(+) diff --git a/gyrokinetic/unit/ctest_bc_twistshift.c b/gyrokinetic/unit/ctest_bc_twistshift.c index fd4b348d38..939881dbe1 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 { @@ -2098,6 +2100,356 @@ 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; + fout[0] = exp(-x*x/(2.*sigx*sigx) - y*y/(2.*sigy*sigy) - z*z/(2.*sigz*sigz)); +} + +void +test_bc_twistshift_3x_cbc_wcells(const int *cells, enum gkyl_edge_loc edge, + 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; i Date: Wed, 8 Jul 2026 22:25:17 -0700 Subject: [PATCH 09/19] Add an assert in twistshift BC updater that errors out of the change in the shift across a single cell is equal or greater to the length of the domain along y. I tried to add support for this sort of scenario but didn't succeed. I'll try again in the future. For now we must increase resolution along y, reduce shear or increase Ly so this doesn't happen. Add accepted results to CBC unit test. --- gyrokinetic/unit/ctest_bc_twistshift.c | 1242 +++++++++++++++++++++++- gyrokinetic/zero/bc_twistshift.c | 16 + 2 files changed, 1255 insertions(+), 3 deletions(-) diff --git a/gyrokinetic/unit/ctest_bc_twistshift.c b/gyrokinetic/unit/ctest_bc_twistshift.c index 939881dbe1..c5de3d0215 100644 --- a/gyrokinetic/unit/ctest_bc_twistshift.c +++ b/gyrokinetic/unit/ctest_bc_twistshift.c @@ -2430,6 +2430,1242 @@ test_bc_twistshift_3x_cbc_wcells(const int *cells, enum gkyl_edge_loc edge, "ctest_bc_twistshift_3x_cbc_tar.gkyl"); } + // Check 4 x=const lines, and 4 y=const lines. + int idx0_ref[] = {4,12,19,28}; + int idx1_ref[] = {2,7,10,13}; + int num_ref0 = sizeof(idx0_ref)/sizeof(idx0_ref[0]); + int num_ref1 = sizeof(idx1_ref)/sizeof(idx1_ref[0]); + double f0[num_ref0*cells[1]*basis.num_basis]; + double f1[num_ref1*cells[0]*basis.num_basis]; + if (edge == GKYL_LOWER_EDGE) { + const double f0m[] = + { + // idx[0] = 4; + 1.4147068739149354e-06, 3.9678563980892827e-07, -5.3677388121514690e-07, + -1.4021443738919494e-06, -2.1663045016556100e-07, -3.9326221053808132e-07, + 5.3200736596068834e-07, 2.1470678662411421e-07, + 2.2073750885337050e-06, 5.4194161567241438e-08, 7.7188487204183924e-07, + -2.1877737491242868e-06, 2.2856919929920019e-08, -5.3712921129036553e-08, + -7.6503058731221621e-07, -2.2653952048417829e-08, + 8.0151330159023854e-06, 3.5840433095651838e-07, 2.4919021860714378e-06, + -7.9439591843807564e-06, 1.4691992411677311e-07, -3.5522172507617932e-07, + -2.4697742655481038e-06, -1.4561528526605157e-07, + 2.4056337321823511e-05, 1.5575127200312389e-06, 6.4725989939125481e-06, + -2.3842718696134587e-05, 5.6131534500851025e-07, -1.5436821138880369e-06, + -6.4151227587227262e-06, -5.5633090323856011e-07, + 5.9715709406034343e-05, 5.0593586542458534e-06, 1.3398359967595644e-05, + -5.9185438001676253e-05, 1.5246943425719446e-06, -5.0144318963554509e-06, + -1.3279383449912431e-05, -1.5111551613699758e-06, + 1.2266163264877539e-04, 1.2843394764617348e-05, 2.1715606284302345e-05, + -1.2157240576270994e-04, 3.0737503418026385e-06, -1.2729346299878336e-05, + -2.1522773189704626e-05, -3.0464556495582395e-06, + 2.0858381754799334e-04, 2.6012564754977512e-05, 2.6550477975637763e-05, + -2.0673160755237084e-04, 4.5938737655600021e-06, -2.5781574963835826e-05, + -2.6314711551985457e-05, -4.5530804815592547e-06, + 2.9374366736149827e-04, 4.2514292127503834e-05, 2.2141578694173991e-05, + -2.9113524373960048e-04, 4.8573878417790354e-06, -4.2136768128945044e-05, + -2.1944962993788802e-05, -4.8142545708526606e-06, + 3.4269905278866652e-04, 5.6458355498447365e-05, 7.3950701740712856e-06, + -3.3965590870142440e-04, 2.9844920494078483e-06, -5.5957009173406751e-05, + -7.3294024580625872e-06, -2.9579899646787672e-06, + 3.3130814623591096e-04, 6.1194737241075030e-05, -1.1197518621951395e-05, + -3.2836615261769482e-04, -4.4059942666451672e-07, -6.0651332170970138e-05, + 1.1098085424488793e-05, 4.3668693397105754e-07, + 2.6547493073777388e-04, 5.4303954632758055e-05, -2.4003510429959307e-05, + -2.6311753155848911e-04, -3.5659721755455483e-06, -5.3821739239660803e-05, + 2.3790360903447407e-05, 3.5343065871729570e-06, + 1.7634549859606930e-04, 3.9539852198925795e-05, -2.6084796724879738e-05, + -1.7477956266190929e-04, -4.8370620921015304e-06, -3.9188741022952437e-05, + 2.5853165518798813e-05, 4.7941093124383771e-06, + 9.7120871429426495e-05, 2.3660577068010910e-05, -1.9999449126191993e-05, + -9.6258444751461542e-05, -4.1887526472941376e-06, -2.3450472766235517e-05, + 1.9821855389468108e-05, 4.1515568110413017e-06, + 4.4351391469818973e-05, 1.1650043122384966e-05, -1.1710592695891665e-05, + -4.3957554155084504e-05, -2.6752574970654273e-06, -1.1546591538391639e-05, + 1.1606603435837950e-05, 2.6515013939545564e-06, + 1.6794598764719960e-05, 4.7243461185578233e-06, -5.4058549896015648e-06, + -1.6645463879424616e-05, -1.3229289098014698e-06, -4.6823942490099374e-06, + 5.3578513680151396e-06, 1.3111813918058868e-06, + 5.2735603406759165e-06, 1.5789778675299268e-06, -1.9989826780664712e-06, + -5.2267314864994830e-06, -5.1808733150377238e-07, -1.5649566523489707e-06, + 1.9812318489709252e-06, 5.1348675152926985e-07, + // idx[0] = 12; + 8.5771895799448463e-03, 3.1197886695786712e-04, 1.2589091675382295e-04, + -8.5010247246790835e-03, 2.3881143669295742e-04, -3.0920851601408221e-04, + -1.2477301404636147e-04, -2.3669080751226941e-04, + 8.2661626046304885e-03, 1.0720660909669306e-03, -3.0982027320798947e-04, + -8.1927596475759902e-03, 1.8255117221452561e-04, -1.0625462175989969e-03, + 3.0706909042867208e-04, -1.8093013032420406e-04, + 6.6575398175439011e-03, 1.4760068941306471e-03, -5.9457869281011441e-04, + -6.5984213205230440e-03, 4.2899447104076090e-05, -1.4629000541319605e-03, + 5.8929887479281385e-04, -4.2518502955738542e-05, + 4.4799350811575711e-03, 1.3955105208072918e-03, -6.3033616055554532e-04, + -4.4401535648606475e-03, -8.3328432799330363e-05, -1.3831184830834593e-03, + 6.2473881867683195e-04, 8.2588482030546096e-05, + 2.5178444512609479e-03, 1.0028214075435281e-03, -4.8235931958416503e-04, + -2.4954861652017948e-03, -1.3193983394577959e-04, -9.9391642221575223e-04, + 4.7807600190536255e-04, 1.3076821726847499e-04, + 1.1813969572080783e-03, 5.6871985765870141e-04, -2.8575381884705388e-04, + -1.1709062332455860e-03, -1.1130086733193673e-04, -5.6366966432420582e-04, + 2.8321634453203873e-04, 1.1031252326278932e-04, + 4.6254048415618595e-04, 2.5918239859045285e-04, -1.3487188316997178e-04, + -4.5843315637685304e-04, -6.6255494613212145e-05, -2.5688087666510880e-04, + 1.3367423009662933e-04, 6.5667150364697886e-05, + 1.5102266511218463e-04, 9.5873653213552430e-05, -5.1458764419249627e-05, + -1.4968159420277919e-04, -3.0014361827430350e-05, -9.5022301747813123e-05, + 5.1001814120131696e-05, 2.9747836352719439e-05, + 4.9288640555562537e-05, 1.9197719093399958e-05, -9.3898074536993173e-06, + -4.8850960807531967e-05, -1.7734142076995751e-05, -1.9027244664386457e-05, + 9.3064266074420962e-06, 1.7576664111519137e-05, + 7.4312889120419612e-05, -3.9559856706301425e-05, 2.5345644730922928e-05, + -7.3652995761239122e-05, -1.7079041586904331e-05, 3.9208567891674429e-05, + -2.5120577143858990e-05, 1.6927380868854436e-05, + 2.4668363462348900e-04, -1.2316540125222137e-04, 8.0544516023109083e-05, + -2.4449310086503489e-04, -3.4617348824034278e-05, 1.2207170093550459e-04, + -7.9829286244383513e-05, 3.4309949140455846e-05, + 6.9889469196789068e-04, -2.9144378275440763e-04, 1.9257347432050185e-04, + -6.9268855503182346e-04, -6.3595836624040557e-05, 2.8885578195009997e-04, + -1.9086343507478647e-04, 6.3031109956076864e-05, + 1.6531830617114835e-03, -5.4719482372872844e-04, 3.7015196128372313e-04, + -1.6385029094950184e-03, -8.0981230730739408e-05, 5.4233577121939294e-04, + -3.6686503725170299e-04, 8.0262122955358892e-05, + 3.2662572681362470e-03, -7.8998871116982131e-04, 5.6119422549585842e-04, + -3.2372531275876876e-03, -5.0252394101103727e-05, 7.8297366559026060e-04, + -5.5621085925887826e-04, 4.9806156287680392e-05, + 5.3918935380395400e-03, -8.1066940565628718e-04, 6.4417804850085126e-04, + -5.3440138931855393e-03, 4.8296611837007029e-05, 8.0347071692792157e-04, + -6.3845779160642867e-04, -4.7867741235965884e-05, + 7.4385809600035612e-03, -4.2620301983017786e-04, 4.9868993294226453e-04, + -7.3725268711996870e-03, 1.7454031661297211e-04, 4.2241836624211989e-04, + -4.9426160053675874e-04, -1.7299041057102665e-04, + // idx[0] = 19; + 5.9328259833403554e-03, -3.1592831855465128e-03, 7.6447171990722429e-04, + -5.8801428954679998e-03, -1.4953722986179549e-04, 3.1312289675153120e-03, + -7.5768326346017955e-04, 1.4820934951554569e-04, + 8.5438428607558271e-03, -3.1770890503348324e-03, 7.1469750720538211e-04, + -8.4679741220696197e-03, 1.4653149000103094e-04, 3.1488767174453983e-03, + -7.0835104235372770e-04, -1.4523030041861771e-04, + 1.0538391888353600e-02, -2.0861147480127065e-03, 4.1035235387437105e-04, + -1.0444811691083959e-02, 4.6474412137475823e-04, 2.0675901921113566e-03, + -4.0670845311299757e-04, -4.6061722544804464e-04, + 1.1157187397402466e-02, -1.8349902862187803e-04, -6.0616833961046518e-05, + -1.1058112338448058e-02, 5.9620026364067165e-04, 1.8186956983166154e-04, + 6.0078560632437436e-05, -5.9090604618560014e-04, + 1.0147502273615180e-02, 1.6812950536897128e-03, -5.0484232418422572e-04, + -1.0057393149318094e-02, 4.4927500173386789e-04, -1.6663652689123390e-03, + 5.0035935896640773e-04, -4.4528547052872841e-04, + 7.9236576295588657e-03, 2.7048082887694913e-03, -7.4744339840908337e-04, + -7.8532960931947931e-03, 1.3680114431872893e-04, -2.6807897766548158e-03, + 7.4080615228917822e-04, -1.3558635953868966e-04, + 5.3016792692569753e-03, 2.6754726903120800e-03, -7.3909622093523025e-04, + -5.2546007209230755e-03, -1.3556652552418726e-04, -2.6517146762999374e-03, + 7.3253309717886256e-04, 1.3436270407437602e-04, + 3.0306885085190482e-03, 1.9748354796544215e-03, -5.6082860635096269e-04, + -3.0037762024011216e-03, -2.4639127781911607e-04, -1.9572990760248136e-03, + 5.5584848678691585e-04, 2.4420334016903554e-04, + 1.4749219675761626e-03, 1.1511708985332415e-03, -3.4089330270875329e-04, + -1.4618247616508787e-03, -2.1626062462552680e-04, -1.1409485798989471e-03, + 3.3786619355838658e-04, 2.1434024510951370e-04, + 6.0905145791109792e-04, 5.4222206411941223e-04, -1.6846528502586244e-04, + -6.0364312273221052e-04, -1.3353062399760682e-04, -5.3740716937438729e-04, + 1.6696932484779869e-04, 1.3234488121373442e-04, + 2.2538939529024053e-04, 1.9086017837583374e-04, -6.0622757673647777e-05, + -2.2338795291675510e-04, -7.2883062312480561e-05, -1.8916535308061312e-04, + 6.0084431742876553e-05, 7.2235865717300326e-05, + 1.3692552150240545e-04, -2.3628334870109308e-05, 6.7351766555555647e-06, + -1.3570963226150479e-04, -5.5072031551531791e-05, 2.3418516876840159e-05, + -6.6753687487373170e-06, 5.4582995688068806e-05, + 2.8180957439635708e-04, -2.6245954825184062e-04, 7.9675931947141405e-05, + -2.7930712470157688e-04, -8.6112162611911449e-05, 2.6012892546224296e-04, + -7.8968415135444934e-05, 8.5347492513293869e-05, + 7.5858237184660477e-04, -6.8983776721580120e-04, 2.0188206214679155e-04, + -7.5184621240645996e-04, -1.6201786760816690e-04, 6.8371205515042964e-04, + -2.0008936327954054e-04, 1.6057916005462314e-04, + 1.7743608964103581e-03, -1.4228383602125523e-03, 3.9110700695125220e-04, + -1.7586046933318674e-03, -2.5501449371089001e-04, 1.4102036531488829e-03, + -3.8763400355075369e-04, 2.5274998249505106e-04, + 3.5176447536171256e-03, -2.3790827021664207e-03, 6.1388697056463453e-04, + -3.4864083094370796e-03, -2.8116612144449217e-04, 2.3579566109232604e-03, + -6.0843569636499231e-04, 2.7866938556779779e-04, + // idx[0 = 28; + 3.9008280658611207e-04, -2.5603798505596852e-04, 1.8683093211897101e-05, + -3.8661889801461870e-04, 1.1175426823790703e-05, 2.5376438530717388e-04, + -1.8517188625419492e-05, -1.1076189799980769e-05, + 4.3680260689641130e-04, -1.8748123385802201e-04, 8.0091734113950957e-06, + -4.3292382970210014e-04, 2.7606287551937715e-05, 1.8581641335839929e-04, + -7.9380525007527933e-06, -2.7361145611652907e-05, + 4.4457679107663103e-04, -7.5578664486840552e-05, -3.4115616360440883e-06, + -4.4062897965993530e-04, 3.5399985354932533e-05, 7.4907531129210281e-05, + 3.3812672026731489e-06, -3.5085635912631181e-05, + 4.1504347649095089e-04, 4.2960315696147049e-05, -1.3312487632414327e-05, + -4.1135791888244848e-04, 3.1477256709139010e-05, -4.2578831038885959e-05, + 1.3194273655178598e-05, -3.1197740828200509e-05, + 3.5577914498131479e-04, 1.3094475217078906e-04, -2.0440326610361184e-05, + -3.5261985057240502e-04, 1.8525522986963621e-05, -1.2978197175140562e-04, + 2.0258817911812268e-05, -1.8361017613277599e-05, + 2.7796534980573800e-04, 1.6786465218620076e-04, -2.3905953966682069e-05, + -2.7549703656169430e-04, 2.9974039875550468e-06, -1.6637402558656323e-04, + 2.3693670734873877e-05, -2.9707872457006951e-06, + 1.9535178824326644e-04, 1.5650334125842896e-04, -2.3209649131201253e-05, + -1.9361707776044740e-04, -8.6672787668020905e-06, -1.5511360232069719e-04, + 2.3003549038581116e-05, 8.5903139257351561e-06, + 1.2172339077131273e-04, 1.1660274450623213e-04, -1.8887207777222881e-05, + -1.2064249540877665e-04, -1.3462333943164936e-05, -1.1556732013136769e-04, + 1.8719490667402875e-05, 1.3342789340965859e-05, + 6.7058946442705194e-05, 7.0433021024861683e-05, -1.2563048496751787e-05, + -6.6463467597043934e-05, -1.2699023524379705e-05, -6.9807580628297237e-05, + 1.2451489487645912e-05, 1.2586257066353350e-05, + 3.4938222906600265e-05, 3.1273776945169202e-05, -6.0324138429606134e-06, + -3.4627973883173486e-05, -1.0006175581767381e-05, -3.0996067950580566e-05, + 5.9788464217243402e-06, 9.9173214288020404e-06, + 2.4837446165027290e-05, -9.6145358765583846e-07, 1.9699547938565060e-07, + -2.4616891346377383e-05, -9.0936978967278239e-06, 9.5291594573175467e-07, + -1.9524617303820833e-07, 9.0129464830299899e-06, + 3.6725180241487430e-05, -3.6057780516486035e-05, 6.7954495238266452e-06, + -3.6399063159472330e-05, -1.1694827060907848e-05, 3.5737589898260177e-05, + -6.7351063980715334e-06, 1.1590977798611619e-05, + 7.3131479750304169e-05, -8.5125203228748116e-05, 1.4329502961988946e-05, + -7.2482077225311949e-05, -1.6767541211874010e-05, 8.4369297261769594e-05, + -1.4202257958371192e-05, 1.6618646595792397e-05, + 1.3604357772040060e-04, -1.5068140809657870e-04, 2.1787568445735812e-05, + -1.3483552007980250e-04, -2.0478489031778651e-05, 1.4934336752606917e-04, + -2.1594096332079554e-05, 2.0296641453544639e-05, + 2.2070902006211332e-04, -2.1925837439635583e-04, 2.6427797458379611e-05, + -2.1874913909968418e-04, -1.7877051979819007e-05, 2.1731137506795665e-04, + -2.6193120429307424e-05, 1.7718304984205783e-05, + 3.1225316368462653e-04, -2.6354343092504682e-04, 2.5533068602001434e-05, + -3.0948037700471862e-04, -6.4354644170033844e-06, 2.6120318333164132e-04, + -2.5306336703815414e-05, 6.3783179343098985e-06, + }; + + const double f1m[] = + { + // idx[1] = 2; + 7.5742778736170694e-07, 1.3311910271755548e-07, 2.8478156167525587e-07, + -7.5070188055260917e-07, 5.4750238065324756e-08, -1.3193701421442880e-07, + -2.8225272093725106e-07, -5.4264059705951382e-08, + 1.2925859849765668e-06, 1.7301030138070181e-07, 5.1100320791830013e-07, + -1.2811079100725808e-06, 7.3239351158981957e-08, -1.7147398176909403e-07, + -5.0646553447542282e-07, -7.2588990743278259e-08, + 1.8635824605983989e-06, 1.4918689410169481e-07, 7.1992200307670070e-07, + -1.8470339761485296e-06, 3.9576065168750808e-08, -1.4786212471296968e-07, + -7.1352914505999257e-07, -3.9224632424088840e-08, + 2.2073750885337050e-06, 5.4194161567241438e-08, 7.7188487204183924e-07, + -2.1877737491242868e-06, 2.2856919929920019e-08, -5.3712921129036553e-08, + -7.6503058731221621e-07, -2.2653952048417829e-08, + 2.3371245739281695e-06, 7.7901820168274067e-08, 7.1291202449929213e-07, + -2.3163710679863721e-06, -2.4448859078376102e-07, -7.7210057347509279e-08, + -7.0658141461162307e-07, 2.4231754886407241e-07, + 4.4362078536198185e-06, 1.4349007654002696e-06, -1.4918804712085053e-06, + -4.3968146321047141e-06, -7.9055943126041467e-07, -1.4221589450057450e-06, + 1.4786326749339418e-06, 7.8353931772558917e-07, + 1.8432855790288429e-05, 7.7265468592736174e-06, -7.0218535854514018e-06, + -1.8269173294953980e-05, -3.1418179249565271e-06, -7.6579356530322741e-06, + 6.9595000071553346e-06, 3.1139187972416376e-06, + 8.2880124644381316e-05, 3.4710110035730186e-05, -2.7056128318655973e-05, + -8.2144154821269593e-05, -1.1646701134768506e-05, -3.4401886638953268e-05, + 2.6815871754634015e-05, 1.1543279227396033e-05, + 3.6130932397451928e-04, 1.4417479842687968e-04, -9.7273919862532121e-05, + -3.5810092195539682e-04, -3.5891598669338311e-05, -1.4289453610402862e-04, + 9.6410134124976947e-05, 3.5572883734518748e-05, + 1.3866911075139233e-03, 4.8934908019720340e-04, -2.7681619210264059e-04, + -1.3743773855753208e-03, -7.3086254588880316e-05, -4.8500369392349860e-04, + 2.7435808330019372e-04, 7.2437253660220146e-05, + 4.1402065573272135e-03, 1.1066127780317765e-03, -5.1267688697286180e-04, + -4.1034418070240936e-03, -3.9937840842209967e-05, -1.0967861324518405e-03, + 5.0812435137475719e-04, 3.9583195554377857e-05, + 8.2661626046304885e-03, 1.0720660909669306e-03, -3.0982027320798947e-04, + -8.1927596475759902e-03, 1.8255117221452561e-04, -1.0625462175989969e-03, + 3.0706909042867208e-04, -1.8093013032420406e-04, + 9.2071430199458723e-03, -6.7468017399297192e-04, 5.5519252734112100e-04, + -9.1253842213336704e-03, 2.3350197769444222e-04, 6.6868906031594807e-04, + -5.5026245577217254e-04, -2.3142849614555009e-04, + 4.6562742627774770e-03, -1.5981825134639602e-03, 7.7093816367743357e-04, + -4.6149268666407072e-03, -1.2283002048105933e-04, 1.5839907623441212e-03, + -7.6409228565316330e-04, 1.2173929832259107e-04, + 8.4265128323255962e-04, -5.4995291705314407e-04, 2.3627440955229246e-04, + -8.3516859762456210e-04, -1.3174780227490776e-04, 5.4506937286423181e-04, + -2.3417630899862953e-04, 1.3057789082567117e-04, + 1.1584483866390634e-04, 4.3858963858025124e-05, -1.6873108923363265e-05, + -1.1481614444094632e-04, -4.5483891179512325e-05, -4.3469499266713828e-05, + 1.6723276873243230e-05, 4.5079997345020027e-05, + 1.9929185999929553e-03, 1.3468353897936520e-03, -4.5601060935764076e-04, + -1.9752216194948409e-03, -2.4418116907755306e-04, -1.3348755838951906e-03, + 4.5196126641871491e-04, 2.4201285704153328e-04, + 1.0151660891080034e-02, 2.5306058282125780e-03, -7.5599768765263124e-04, + -1.0061514838545050e-02, 2.8830814950722705e-04, -2.5081342220012394e-03, + 7.4928448003087715e-04, -2.8574799291111936e-04, + 8.5438428607558271e-03, -3.1770890503348324e-03, 7.1469750720538211e-04, + -8.4679741220696197e-03, 1.4653149000103094e-04, 3.1488767174453983e-03, + -7.0835104235372770e-04, -1.4523030041861771e-04, + 8.3058989180792564e-04, -7.7938148858281266e-04, 2.0964975534781903e-04, + -8.2321431052863629e-04, -1.7368462202414916e-04, 7.7246063441240638e-04, + -2.0778807989763350e-04, 1.7214231449147081e-04, + 4.8784698194571816e-04, 4.6603525819394176e-04, -1.2686455710601843e-04, + -4.8351493420147626e-04, -1.1084020143927416e-04, -4.6189689706081717e-04, + 1.2573800853899969e-04, 1.0985594805166225e-04, + 4.8781825809830056e-03, 1.3781496758297101e-03, -3.2928825061722268e-04, + -4.8348646541985386e-03, 2.0371545823830872e-04, -1.3659118012187121e-03, + 3.2636419353358076e-04, -2.0190647893949512e-04, + 2.3680721830718235e-03, -1.7400576716845835e-03, 2.7950593809702203e-04, + -2.3470438644831479e-03, -9.5410574014160988e-05, 1.7246060788892212e-03, + -2.7702394453460178e-04, 9.4563334659955370e-05, + 8.9363290665012504e-05, 3.9704854712887134e-05, -9.8017374005482072e-06, + -8.8569750772238336e-05, -3.3694653872763937e-05, -3.9352278325905277e-05, + 9.7146986446121813e-06, 3.3395447657076489e-05, + 1.5558629382148325e-03, 5.9445795666029032e-04, -1.1056083435049752e-04, + -1.5420469820210249e-03, 6.1304104070216740e-05, -5.8917921077172083e-04, + 1.0957906172347555e-04, -6.0759727830169152e-05, + 5.8935835734624678e-04, -5.5038435706920711e-04, 7.6629057291863393e-05, + -5.8412489554986733e-04, -4.8460576140248553e-05, 5.4549698172253944e-04, + -7.5948596518158015e-05, 4.8030249547439203e-05, + 1.2304561996882203e-04, 1.2696504265504160e-04, -2.3555535292118696e-05, + -1.2195298330168754e-04, -2.1706603802157628e-05, -1.2583760178323854e-04, + 2.3346363754109702e-05, 2.1513850648983980e-05, + 4.3680260689641130e-04, -1.8748123385802201e-04, 8.0091734113950957e-06, + -4.3292382970210014e-04, 2.7606287551937715e-05, 1.8581641335839929e-04, + -7.9380525007527933e-06, -2.7361145611652907e-05, + 1.6405328706551727e-05, 2.9047681450652957e-06, -5.1336046316489495e-07, + -1.6259650512677665e-05, -5.7121417723553899e-06, -2.8789740031395043e-06, + 5.0880185745708351e-07, 5.6614183451425587e-06, + 1.2525989018365017e-04, -1.7226749700817432e-05, -1.8059029379932504e-06, + -1.2414759094885763e-04, 1.0448806188093158e-05, 1.7073777344845486e-05, + 1.7898666437485847e-06, -1.0356021505698249e-05, + 6.1342326303602334e-06, -1.4359128614618401e-06, 2.5224463428445020e-07, + -6.0797610652743509e-06, -2.0408390187520330e-06, 1.4231620537236963e-06, + -2.5000471923036756e-07, 2.0227165082216116e-06, + 2.9913061136183802e-05, -9.4004861242035489e-06, -2.0777664618398835e-07, + -2.9647435204664162e-05, 2.4116686151255107e-06, 9.3170104520845704e-06, + 2.0593160381472413e-07, -2.3902531632099425e-06, + // idx[1] = 7; + 3.6490020128125056e-05, 7.3675063786135985e-06, 3.2021281911722955e-06, + -3.6165991251789855e-05, 6.9414808136517716e-07, -7.3020834272183321e-06, + -3.1736935124293500e-06, -6.8798409400575064e-07, + 7.1180658041772527e-05, 1.2900664940831104e-05, 6.7559365584194971e-06, + -7.0548578679769132e-05, 1.4100360605950567e-06, -1.2786107920854779e-05, + -6.6959443050874898e-06, -1.3975150370740391e-06, + 1.2807110995553272e-04, 2.0058649867687919e-05, 1.3810778814974065e-05, + -1.2693384728195296e-04, 2.7419450947357848e-06, -1.9880530432439409e-05, + -1.3688140046208898e-05, -2.7175968103308825e-06, + 2.0858381754799334e-04, 2.6012564754977512e-05, 2.6550477975637763e-05, + -2.0673160755237084e-04, 4.5938737655600021e-06, -2.5781574963835826e-05, + -2.6314711551985457e-05, -4.5530804815592547e-06, + 2.9871110310366976e-04, 2.5205913165246249e-05, 4.5389429729345988e-05, + -2.9605856899303685e-04, 5.9426328345686276e-06, -2.4982086384903065e-05, + -4.4986374706053220e-05, -5.8898626625298949e-06, + 3.6469434674854203e-04, 1.1237385446411157e-05, 6.5265128683803013e-05, + -3.6145588595932354e-04, 6.3539671552325690e-06, -1.1137598234281373e-05, + -6.4685578816824895e-05, -6.2975443626347055e-06, + 3.5893595493224776e-04, -1.4493122690417841e-05, 7.7817247724840170e-05, + -3.5574862826746054e-04, -1.6084567762455801e-06, 1.4364424754832286e-05, + -7.7126235901573401e-05, 1.5941737903768229e-06, + 2.6694095601170693e-04, -3.6280004828175835e-05, 7.0464806864678920e-05, + -2.6457053862852633e-04, -7.8696688227856493e-06, 3.5957840873301803e-05, + -6.9839084212036697e-05, 7.7997867033233192e-06, + 1.3743518008194365e-04, -3.5616161618941028e-05, 4.3245713680199841e-05, + -1.3621476510780793e-04, -1.0173131963280475e-05, 3.5299892546240166e-05, + -4.2861694708412319e-05, 1.0082795249096795e-05, + 4.4281012350574053e-05, -1.7888520118666143e-05, 1.6654315330488873e-05, + -4.3887799997592024e-05, -6.9220705758281906e-06, 1.7729671286766401e-05, + -1.6506426152469179e-05, 6.8606030638146820e-06, + 5.1438549738468361e-05, 2.9665824357334224e-05, -1.7900189835034524e-05, + -5.0981778944329460e-05, -1.3973723052800237e-05, -2.9402393871455844e-05, + 1.7741237376853713e-05, 1.3849637350377501e-05, + 4.6254048415618595e-04, 2.5918239859045285e-04, -1.3487188316997178e-04, + -4.5843315637685304e-04, -6.6255494613212145e-05, -2.5688087666510880e-04, + 1.3367423009662933e-04, 6.5667150364697886e-05, + 2.8294587601195142e-03, 1.2375254640891553e-03, -5.5518378989416852e-04, + -2.8043333603674971e-03, -1.6372300936094285e-04, -1.2265363228347245e-03, + 5.5025379591314930e-04, 1.6226916026556920e-04, + 9.1957619553724914e-03, 2.1739429633878338e-03, -7.9765225550990928e-04, + -9.1141042198332155e-03, 1.2436740398928127e-04, -2.1546384989570115e-03, + 7.9056915818215777e-04, -1.2326302997069018e-04, + 1.2500828315738250e-02, -7.8508011247857622e-04, 3.9877045177863924e-04, + -1.2389821817572859e-02, 4.5450998846944439e-04, 7.7810865491877395e-04, + -3.9522939751361548e-04, -4.5047397094109647e-04, + 5.4790816862939698e-03, -2.4387569363537110e-03, 8.7033830325395343e-04, + -5.4304278166626349e-03, -1.8988685124202967e-04, 2.4171009420032915e-03, + -8.6260975880687917e-04, 1.8820066902500816e-04, + 5.7215777750936191e-04, -4.7524252007978156e-04, 1.6913878684932706e-04, + -5.6707705568235730e-04, -1.2685880911773650e-04, 4.7102239909252376e-04, + -1.6763684602125821e-04, 1.2573231159245944e-04, + 3.7427031371474147e-04, 3.3208117201649374e-04, -1.1114484687920846e-04, + -3.7094681899556108e-04, -9.6463580458152723e-05, -3.2913231398235833e-04, + 1.1015788826098180e-04, 9.5606990478937183e-05, + 5.3016792692569753e-03, 2.6754726903120800e-03, -7.3909622093523025e-04, + -5.2546007209230755e-03, -1.3556652552418726e-04, -2.6517146762999374e-03, + 7.3253309717886256e-04, 1.3436270407437602e-04, + 9.1961936544017377e-03, -1.7368826364828015e-03, 2.6809009052315561e-04, + -9.1145320854046884e-03, 4.6206186478466938e-04, 1.7214592377822946e-03, + -2.6570946890431846e-04, -4.5795878711253288e-04, + 1.4411213884148821e-03, -1.2810931792856962e-03, 2.9718607020727523e-04, + -1.4283243293145838e-03, -2.1624336633437261e-04, 1.2697171597080945e-03, + -2.9454707828417920e-04, 2.1432314007080162e-04, + 2.5492665841420049e-04, 2.4888323947485475e-04, -6.6278567407764414e-05, + -2.5266292716977256e-04, -7.1894578026374012e-05, -2.4667317337616422e-04, + 6.5690018274416786e-05, 7.1256159103866377e-05, + 3.4578494082033329e-03, 1.1303046461231612e-03, -2.4223248931279460e-04, + -3.4271439425899311e-03, 1.3900706598040616e-04, -1.1202676183793079e-03, + 2.4008148141944991e-04, -1.3777269276728850e-04, + 1.5781234722698873e-03, -1.2618335200807974e-03, 1.9187865723673255e-04, + -1.5641098440602476e-03, -8.2967902797417424e-05, 1.2506285249561514e-03, + -1.9017478791907218e-04, 8.2231153510326405e-05, + 9.6977901902638771e-05, 8.6316756686137636e-05, -1.9677860154625181e-05, + -9.6116744784267204e-05, -3.0120448337378890e-05, -8.5550269806171510e-05, + 1.9503122105914992e-05, 2.9852980821734779e-05, + 1.1828731451272068e-03, 1.7396447751082659e-04, -4.5145997322396552e-05, + -1.1723693127172260e-03, 8.1902648560030431e-05, -1.7241968488061835e-04, + 4.4745103962183452e-05, -8.1175358657514666e-05, + 1.8720681143410243e-04, -2.0805519933339648e-04, 3.3414378701706986e-05, + -1.8554442778678481e-04, -3.2611926466637799e-05, 2.0620768343126807e-04, + -3.3117661310317896e-05, 3.2322334796065803e-05, + 1.9535178824326644e-04, 1.5650334125842896e-04, -2.3209649131201253e-05, + -1.9361707776044740e-04, -8.6672787668020905e-06, -1.5511360232069719e-04, + 2.3003549038581116e-05, 8.5903139257351561e-06, + 1.6951067600112064e-04, -1.5119863365618911e-04, 1.3863877085517486e-05, + -1.6800543282288719e-04, -4.5044095319840138e-06, 1.4985600015818046e-04, + -1.3740766807751243e-05, 4.4644106842421568e-06, + 3.6276567298503932e-05, 3.6027257115504254e-05, -5.2295393006259026e-06, + -3.5954433868657664e-05, -3.9956008741697106e-06, -3.5707337542985894e-05, + 5.1831013502662508e-06, 3.9601202124163002e-06, + 5.1575023302046883e-05, -4.4579128212970346e-05, 2.9869584382288155e-06, + -5.1117040632022465e-05, -3.2845211397064798e-09, 4.4183268611574349e-05, + -2.9604344521361577e-06, 3.2553548172312432e-09, + 1.2401275268881665e-05, 1.1336295347525180e-05, -1.3473909962905102e-06, + -1.2291152794945234e-05, -6.9063884391199019e-07, -1.1235629822256499e-05, + 1.3354262566444594e-06, 6.8450601834049220e-07, + // idx[1] = 10; + 3.9161987831707695e-05, 8.5585033279271904e-06, -3.0940904155168843e-06, + -3.8814232065402164e-05, -6.2790787320485707e-07, -8.4825044052978823e-06, + 3.0666151048127765e-06, 6.2233209435129094e-07, + 8.2966973231524862e-05, 1.7351396003363992e-05, -5.8734092978937982e-06, + -8.2230232198915169e-05, -9.6285893253993122e-07, -1.7197316796773389e-05, + 5.8212538261135436e-06, 9.5430881124964793e-07, + 1.6948528988022327e-04, 3.3617119358933897e-05, -9.1922219423833112e-06, + -1.6798027212900247e-04, -8.7142547168146892e-07, -3.3318601644412122e-05, + 9.1105956419166347e-06, 8.6368727325331598e-07, + 3.3130814623591096e-04, 6.1194737241075030e-05, -1.1197518621951395e-05, + -3.2836615261769482e-04, -4.4059942666451672e-07, -6.0651332170970138e-05, + 1.1098085424488793e-05, 4.3668693397105754e-07, + 6.0949868976399927e-04, 1.0001588819084043e-04, -9.8223350700820744e-06, + -6.0408638319692828e-04, 3.3693722410871172e-06, -9.9127753962567809e-05, + 9.7351134082531126e-06, -3.3394524466501626e-06, + 1.0226479509198823e-03, 1.3603218361846981e-04, 2.0902400504249218e-05, + -1.0135669072465832e-03, 1.1408417045058132e-05, -1.3482422715671544e-04, + -2.0716788621210686e-05, -1.1307111084061294e-05, + 1.4988806244302360e-03, 1.3106170460485647e-04, 8.5695676969146863e-05, + -1.4855706672751183e-03, 3.0453476425095055e-05, -1.2989788565587895e-04, + -8.4934705234475415e-05, -3.0183051642870378e-05, + 1.8030298257953226e-03, 3.5581460837069158e-05, 1.8651702121554774e-04, + -1.7870190445899432e-03, 3.0633437103590942e-05, -3.5265499904931722e-05, + -1.8486076285806655e-04, -3.0361414282882376e-05, + 1.6413216149696490e-03, -1.2558118114409131e-04, 2.6036761791834394e-04, + -1.6267467915868207e-03, 5.4223079993272169e-06, 1.2446602886760324e-04, + -2.5805557132664797e-04, -5.3741582761426463e-06, + 1.0189032686435122e-03, -2.1096043183989262e-04, 2.2864831174272861e-04, + -1.0098554774920258e-03, -2.7657765772399670e-05, 2.0908711767234067e-04, + -2.2661793041463409e-04, 2.7412166709047420e-05, + 3.7915828230823104e-04, -1.4271127978161287e-04, 1.1053775807032913e-04, + -3.7579138276314626e-04, -3.4225960821842870e-05, 1.4144401340396710e-04, + -1.0955619035909259e-04, 3.3922036636883500e-05, + 7.4312889120419612e-05, -3.9559856706301425e-05, 2.5345644730922928e-05, + -7.3652995761239122e-05, -1.7079041586904331e-05, 3.9208567891674429e-05, + -2.5120577143858990e-05, 1.6927380868854436e-05, + 1.6452199128976365e-04, 1.1354492403363452e-04, -5.6206288820240358e-05, + -1.6306104728965439e-04, -3.6099553950468539e-05, -1.1253665289486835e-04, + 5.5707180830016014e-05, 3.5778992387013618e-05, + 1.7045525792129491e-03, 9.4638345870692170e-04, -4.0697719285162913e-04, + -1.6894162692038758e-03, -1.8078271052518686e-04, -9.3797963849442858e-04, + 4.0336326328867662e-04, 1.7917737245339021e-04, + 8.0791678878996270e-03, 2.6080011965470560e-03, -9.4517642723761621e-04, + -8.0074254311060314e-03, -2.5821417318396076e-05, -2.5848423247725079e-03, + 9.3678332538179568e-04, 2.5592124903382838e-05, + 1.3356481058149027e-02, -4.3293862331198287e-04, 1.8456831679649629e-04, + -1.3237876422309745e-02, 5.5117088081287893e-04, 4.2909415802691651e-04, + -1.8292936280061883e-04, -5.4627652118930487e-04, + 5.8131600430988816e-03, -2.8057188210851192e-03, 8.7511944457956429e-04, + -5.7615395805694532e-03, -1.9564030185424144e-04, 2.7808042303636960e-03, + -8.6734844392539828e-04, 1.9390302939034247e-04, + 4.7634326079316490e-04, -4.2920915428436507e-04, 1.4088268702259574e-04, + -4.7211336530385859e-04, -1.1855725319576432e-04, 4.2539780642850714e-04, + -1.3963165842324922e-04, 1.1750447291777259e-04, + 6.0905145791109792e-04, 5.4222206411941223e-04, -1.6846528502586244e-04, + -6.0364312273221052e-04, -1.3353062399760682e-04, -5.3740716937438729e-04, + 1.6696932484779869e-04, 1.3234488121373442e-04, + 6.4242974589046788e-03, 2.4764802964899425e-03, -6.3518193397605228e-04, + -6.3672501380333084e-03, 8.6162573411431977e-05, -2.4544893212884956e-03, + 6.2954156196167702e-04, -8.5397455668371819e-05, + 6.1192473190725665e-03, -2.6624998539887439e-03, 4.5719660344097069e-04, + -6.0649088225232604e-03, 1.3024981958765076e-04, 2.6388570378735065e-03, + -4.5313672895591774e-04, -1.2909321012194870e-04, + 3.6469519543160195e-04, -3.8363095857578205e-04, 9.4090664425705537e-05, + -3.6145672710613606e-04, -9.7469050278117320e-05, 3.8022434197216746e-04, + -9.3255145778128976e-05, 9.6603531795853362e-05, + 9.1178047998912944e-04, 7.8751323767825218e-04, -1.7362275060965260e-04, + -9.0368393185465677e-04, -1.1501287471381066e-04, -7.8052017413353532e-04, + 1.7208099249089212e-04, 1.1399156827367334e-04, + 3.0428994134042361e-03, -6.0542157405542502e-04, 2.7297328115256485e-05, + -3.0158786752883249e-03, 2.0376965733463401e-04, 6.0004547199624656e-04, + -2.7054929713581609e-05, -2.0196019675156203e-04, + 2.4486683302324625e-04, -2.7365088383468991e-04, 5.4183415554686730e-05, + -2.4269243233841011e-04, -5.7765593385108655e-05, 2.7122088275259283e-04, + -5.3702270540336453e-05, 5.7252638877281821e-05, + 4.8684120652024070e-04, 3.9028286351598836e-04, -6.7232236617729949e-05, + -4.8251808999280312e-04, -3.0667260128958450e-05, -3.8681717845267713e-04, + 6.6635218967198297e-05, 3.0394936962104197e-05, + 6.3412598830576885e-04, -4.3372366375867428e-04, 3.8776407472195745e-05, + -6.2849499301653115e-04, 9.5143346917004076e-06, 4.2987222736827919e-04, + -3.8432075633040440e-05, -9.4298480521095317e-06, + 3.4938222906600265e-05, 3.1273776945169202e-05, -6.0324138429606134e-06, + -3.4627973883173486e-05, -1.0006175581767381e-05, -3.0996067950580566e-05, + 5.9788464217243402e-06, 9.9173214288020404e-06, + 2.4392083227262561e-04, -5.6676719861445976e-05, -1.1626687511739263e-06, + -2.4175483200958038e-04, 1.9445449116214847e-05, 5.6173434475836838e-05, + 1.1523443323966798e-06, -1.9272774861587520e-05, + 1.0411319188242270e-05, -3.0681569078749306e-06, 5.5818318184871959e-07, + -1.0318867387835262e-05, -3.5693133209656941e-06, 3.0409118849402196e-06, + -5.5322655347283574e-07, 3.5376180634509055e-06, + 6.2185931257129924e-05, -1.0179624868692854e-05, -8.9508031605887850e-07, + -6.1633724452136285e-05, 5.2188375294843555e-06, 1.0089230497954375e-05, + 8.8713206423484730e-07, -5.1724946101185369e-06, + 3.4821562995004312e-06, 1.0893657152118253e-06, -1.5562699790180428e-07, + -3.4512349903592222e-06, -1.0573421757721680e-06, -1.0796922223669664e-06, + 1.5424504083298160e-07, 1.0479530497614316e-06, + // idx[1] = 13; + 7.6939600011633745e-06, 1.8061169092499393e-06, -1.7409386096072833e-06, + -7.6256381639873142e-06, -3.8744241924183407e-07, -1.7900787149551884e-06, + 1.7254791941435799e-06, 3.8400195712888607e-07, + 1.7708033426125268e-05, 4.1983811964132660e-06, -3.8745042608883230e-06, + -1.7550787303677916e-05, -8.9714935127936357e-07, -4.1610998593045459e-06, + 3.8400989287563202e-06, 8.8918272656446436e-07, + 4.1224027239434575e-05, 9.9239799414819331e-06, -8.9605036911705433e-06, + -4.0857960704598385e-05, -2.1501854097138079e-06, -9.8358556801655410e-06, + 8.8809350328839017e-06, 2.1310919107303748e-06, + 9.7120871429426495e-05, 2.3660577068010910e-05, -1.9999449126191993e-05, + -9.6258444751461542e-05, -4.1887526472941376e-06, -2.3450472766235517e-05, + 1.9821855389468108e-05, 4.1515568110413017e-06, + 2.2966717127649675e-04, 5.5667830351288630e-05, -3.9586034209482798e-05, + -2.2762774254561342e-04, -7.9335419238213086e-06, -5.5173503835342345e-05, + 3.9234512940422766e-05, 7.8630926156020119e-06, + 5.3200292659768048e-04, 1.2461168529569132e-04, -7.7661558932109947e-05, + -5.2727877709304340e-04, -1.3162232392700854e-05, -1.2350514207585148e-04, + 7.6971929614645792e-05, 1.3045352671689596e-05, + 1.1666581574647169e-03, 2.4674867349924984e-04, -1.2191453257652898e-04, + -1.1562983130331923e-03, -1.1089595832661965e-05, -2.4455756220003919e-04, + 1.2083193988787077e-04, 1.0991120982167166e-05, + 2.2887686678893923e-03, 3.9334003412439531e-04, -1.3148940639503572e-04, + -2.2684445590770812e-03, 1.6659921237230303e-05, -3.8984720159573514e-04, + 1.3032178948349212e-04, -1.6511982279143148e-05, + 3.7173943219990105e-03, 3.9400146321998456e-04, -3.1956132370684377e-06, + -3.6843841153501047e-03, 7.3337556977308329e-05, -3.9050275724631495e-04, + 3.1672364106713046e-06, -7.2686324500672754e-05, + 4.5199940871419554e-03, 2.1470803254982653e-05, 2.8930333733463666e-04, + -4.4798568496190452e-03, 9.9813558392372950e-05, -2.1280143994497898e-05, + -2.8673434353886968e-04, -9.8927220838835293e-05, + 3.6305853350697154e-03, -5.0640172967673838e-04, 5.0404713216872657e-04, + -3.5983459862715781e-03, 1.2471040562830394e-05, 5.0190491704508729e-04, + -4.9957122820147365e-04, -1.2360298577867939e-05, + 1.6531830617114835e-03, -5.4719482372872844e-04, 3.7015196128372313e-04, + -1.6385029094950184e-03, -8.0981230730739408e-05, 5.4233577121939294e-04, + -3.6686503725170299e-04, 8.0262122955358892e-05, + 3.5645930339666049e-04, -2.0018386894217195e-04, 1.1080594537964248e-04, + -3.5329396922766608e-04, -5.1667624794085499e-05, 1.9840624991411976e-04, + -1.0982199618349089e-04, 5.1208819829162221e-05, + 8.1645729682003766e-05, 3.1518177127831518e-05, -1.4204895571968811e-05, + -8.0920721201505936e-05, -3.1610417461887078e-05, -3.1238297876381250e-05, + 1.4078757073429143e-05, 3.1329719122596009e-05, + 1.1112012333347322e-03, 7.2994071394047412e-04, -2.9209530026815726e-04, + -1.1013338425863719e-03, -1.6061672159759519e-04, -7.2345889045835620e-04, + 2.8950151403300714e-04, 1.5919045612453774e-04, + 7.2402254655031450e-03, 2.7989480758611120e-03, -9.5793435231481981e-04, + -7.1759327598876661e-03, -9.4784436742230806e-05, -2.7740936088929561e-03, + 9.4942796095922244e-04, 9.3942757444060668e-05, + 1.3241006243061246e-02, -4.8348417204651956e-04, 1.1607405154312268e-04, + -1.3123427015660947e-02, 6.0299863597544526e-04, 4.7919086575499135e-04, + -1.1504332192551400e-04, -5.9764404944025846e-04, + 5.0513947154027950e-03, -2.8225427733082589e-03, 7.8810546751066060e-04, + -5.0065386767431741e-03, -2.3600245213992220e-04, 2.7974787870448429e-03, + -7.8110714500564547e-04, 2.3390676654943019e-04, + 2.8180957439635708e-04, -2.6245954825184062e-04, 7.9675931947141405e-05, + -2.7930712470157688e-04, -8.6112162611911449e-05, 2.6012892546224296e-04, + -7.8968415135444934e-05, 8.5347492513293869e-05, + 1.1583383425450176e-03, 9.6723264576604215e-04, -2.6977156771823926e-04, + -1.1480523774994257e-03, -1.8655819799415997e-04, -9.5864368620225400e-04, + 2.6737601469722168e-04, 1.8490157398970858e-04, + 6.9931044556163944e-03, 1.2000797468667162e-03, -3.3704778425109526e-04, + -6.9310061676217134e-03, 3.5590508141603505e-04, -1.1894231210132782e-03, + 3.3405482304091577e-04, -3.5274466870022149e-04, + 2.8733758677926490e-03, -2.0671103848013198e-03, 3.8129908297979245e-04, + -2.8478604871362296e-03, -1.4871125794984149e-04, 2.0487545863420113e-03, + -3.7791317327155554e-04, 1.4739071217752654e-04, + 1.0322441124946468e-04, 1.8476743202895802e-05, -4.8168812615710036e-06, + -1.0230778555646471e-04, -4.0962290464139684e-05, -1.8312670990347120e-05, + 4.7741076862990093e-06, 4.0598548133918808e-05, + 1.9582591910971363e-03, 9.7865979301640601e-04, -1.8723018386836629e-04, + -1.9408699837731539e-03, 2.3128246186437582e-05, -9.6996936116868198e-04, + 1.8556759267543521e-04, -2.2922868946384473e-05, + 1.2887036948865914e-03, -9.7941769109876069e-04, 1.2664939140072734e-04, + -1.2772600944523657e-03, -3.3426030714455137e-05, 9.7072052916804066e-04, + -1.2552475349041602e-04, 3.3129209853991952e-05, + 6.9313334777440611e-05, 5.9715287673186426e-05, -1.2957096051869759e-05, + -6.8697837117967728e-05, -2.1501206316811928e-05, -5.9185020013787079e-05, + 1.2842037927497324e-05, 2.1310277079222445e-05, + 7.4156655404620110e-04, 3.4961769651018976e-05, -2.0021392848953567e-05, + -7.3498149390121789e-04, 5.6888820265120965e-05, -3.4651311534116488e-05, + 1.9843604253476427e-05, -5.6383651442472562e-05, + 7.3131479750304169e-05, -8.5125203228748116e-05, 1.4329502961988946e-05, + -7.2482077225311949e-05, -1.6767541211874010e-05, 8.4369297261769594e-05, + -1.4202257958371192e-05, 1.6618646595792397e-05, + 1.6327041844856342e-04, 9.2190327694195343e-05, -1.2311099334815660e-05, + -1.6182058832945399e-04, 3.8034733974803152e-06, -9.1371683906473801e-05, + 1.2201777616989676e-05, -3.7696988145442397e-06, + 5.1551691384217321e-05, -5.7564660526755213e-05, 7.0153713767409422e-06, + -5.1093915900023176e-05, -6.4107510814895152e-06, 5.7053490288931074e-05, + -6.9530753600136905e-06, 6.3538240515206069e-06, + 4.0328806418053059e-05, 2.5609342610977449e-05, -2.9607290538332087e-06, + -3.9970689382718532e-05, 7.0182568368235099e-07, -2.5381933404822421e-05, + 2.9344379828752321e-06, -6.9559351974086134e-07, + 1.1170036525578136e-05, -1.3138092309676044e-05, 1.5550589860992071e-06, + -1.1070847367246694e-05, -1.6709719218995304e-06, 1.3021426950946600e-05, + -1.5412501689450531e-06, 1.6561338058245150e-06, + }; + + int nvals0 = sizeof(f0m)/sizeof(f0m[0]); + int nvals1 = sizeof(f1m)/sizeof(f1m[0]); + 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; + 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); + 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]; From f4a91221089ba7b6bcefbc839db7a816941b4d7c Mon Sep 17 00:00:00 2001 From: manauref Date: Thu, 9 Jul 2026 12:57:40 -0700 Subject: [PATCH 10/19] Change the way we look for shifted cells in periodic copies along y in TS BC updater. The previous approach looked in periodic copies of the domain independently for each point, but this could give different periodic copies for 2-4 points that are meant to define a subcell integral, leading to error. So now we look for the correct periodic copy only once (for a given donor-target pair) and pass that to be used for looking for intersections. This fixes some checkerboarding seen in the CBC geo with Nx cells. All other unit tests continue to pass (I had to generate new cbc accepted results, but I confirmed visually that for Nx=32 the difference was machine precision. --- gyrokinetic/creg/rt_gk_cbc_passive_3x2v_p1.c | 4 +- gyrokinetic/unit/ctest_bc_twistshift.c | 2467 +++++++++--------- gyrokinetic/zero/bc_twistshift.c | 76 +- 3 files changed, 1258 insertions(+), 1289 deletions(-) diff --git a/gyrokinetic/creg/rt_gk_cbc_passive_3x2v_p1.c b/gyrokinetic/creg/rt_gk_cbc_passive_3x2v_p1.c index 5df7feaade..f5f939c582 100644 --- a/gyrokinetic/creg/rt_gk_cbc_passive_3x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_cbc_passive_3x2v_p1.c @@ -420,7 +420,7 @@ struct gk_app_ctx create_ctx(void) double inv_asp_ratio = a_mid/R0; // Grid parameters - int Nx = 16; + int Nx = 32; int Ny = 16; int Nz = 16; int Nvpar = 2; @@ -433,7 +433,7 @@ struct gk_app_ctx create_ctx(void) double vpar_max_elc = 4.*vte; double mu_max_elc = 7*Te0/B0; - double t_end = 1.00; + double t_end = 1.0; int num_frames = 1; double write_phase_freq = 1.0; int int_diag_calc_num = num_frames*100; diff --git a/gyrokinetic/unit/ctest_bc_twistshift.c b/gyrokinetic/unit/ctest_bc_twistshift.c index c5de3d0215..d849b022b9 100644 --- a/gyrokinetic/unit/ctest_bc_twistshift.c +++ b/gyrokinetic/unit/ctest_bc_twistshift.c @@ -2251,12 +2251,13 @@ void init_donor_3x_cbc(double t, const double *xn, double* GKYL_RESTRICT fout, v 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; - fout[0] = exp(-x*x/(2.*sigx*sigx) - y*y/(2.*sigy*sigy) - z*z/(2.*sigz*sigz)); + 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 use_gpu, bool write_f) + bool check_distf, bool use_gpu, bool write_f) { int bc_dir = 2; int poly_order = 1; @@ -2430,1236 +2431,1238 @@ test_bc_twistshift_3x_cbc_wcells(const int *cells, enum gkyl_edge_loc edge, "ctest_bc_twistshift_3x_cbc_tar.gkyl"); } - // Check 4 x=const lines, and 4 y=const lines. - int idx0_ref[] = {4,12,19,28}; - int idx1_ref[] = {2,7,10,13}; - int num_ref0 = sizeof(idx0_ref)/sizeof(idx0_ref[0]); - int num_ref1 = sizeof(idx1_ref)/sizeof(idx1_ref[0]); - double f0[num_ref0*cells[1]*basis.num_basis]; - double f1[num_ref1*cells[0]*basis.num_basis]; - if (edge == GKYL_LOWER_EDGE) { - const double f0m[] = - { - // idx[0] = 4; - 1.4147068739149354e-06, 3.9678563980892827e-07, -5.3677388121514690e-07, - -1.4021443738919494e-06, -2.1663045016556100e-07, -3.9326221053808132e-07, - 5.3200736596068834e-07, 2.1470678662411421e-07, - 2.2073750885337050e-06, 5.4194161567241438e-08, 7.7188487204183924e-07, - -2.1877737491242868e-06, 2.2856919929920019e-08, -5.3712921129036553e-08, - -7.6503058731221621e-07, -2.2653952048417829e-08, - 8.0151330159023854e-06, 3.5840433095651838e-07, 2.4919021860714378e-06, - -7.9439591843807564e-06, 1.4691992411677311e-07, -3.5522172507617932e-07, - -2.4697742655481038e-06, -1.4561528526605157e-07, - 2.4056337321823511e-05, 1.5575127200312389e-06, 6.4725989939125481e-06, - -2.3842718696134587e-05, 5.6131534500851025e-07, -1.5436821138880369e-06, - -6.4151227587227262e-06, -5.5633090323856011e-07, - 5.9715709406034343e-05, 5.0593586542458534e-06, 1.3398359967595644e-05, - -5.9185438001676253e-05, 1.5246943425719446e-06, -5.0144318963554509e-06, - -1.3279383449912431e-05, -1.5111551613699758e-06, - 1.2266163264877539e-04, 1.2843394764617348e-05, 2.1715606284302345e-05, - -1.2157240576270994e-04, 3.0737503418026385e-06, -1.2729346299878336e-05, - -2.1522773189704626e-05, -3.0464556495582395e-06, - 2.0858381754799334e-04, 2.6012564754977512e-05, 2.6550477975637763e-05, - -2.0673160755237084e-04, 4.5938737655600021e-06, -2.5781574963835826e-05, - -2.6314711551985457e-05, -4.5530804815592547e-06, - 2.9374366736149827e-04, 4.2514292127503834e-05, 2.2141578694173991e-05, - -2.9113524373960048e-04, 4.8573878417790354e-06, -4.2136768128945044e-05, - -2.1944962993788802e-05, -4.8142545708526606e-06, - 3.4269905278866652e-04, 5.6458355498447365e-05, 7.3950701740712856e-06, - -3.3965590870142440e-04, 2.9844920494078483e-06, -5.5957009173406751e-05, - -7.3294024580625872e-06, -2.9579899646787672e-06, - 3.3130814623591096e-04, 6.1194737241075030e-05, -1.1197518621951395e-05, - -3.2836615261769482e-04, -4.4059942666451672e-07, -6.0651332170970138e-05, - 1.1098085424488793e-05, 4.3668693397105754e-07, - 2.6547493073777388e-04, 5.4303954632758055e-05, -2.4003510429959307e-05, - -2.6311753155848911e-04, -3.5659721755455483e-06, -5.3821739239660803e-05, - 2.3790360903447407e-05, 3.5343065871729570e-06, - 1.7634549859606930e-04, 3.9539852198925795e-05, -2.6084796724879738e-05, - -1.7477956266190929e-04, -4.8370620921015304e-06, -3.9188741022952437e-05, - 2.5853165518798813e-05, 4.7941093124383771e-06, - 9.7120871429426495e-05, 2.3660577068010910e-05, -1.9999449126191993e-05, - -9.6258444751461542e-05, -4.1887526472941376e-06, -2.3450472766235517e-05, - 1.9821855389468108e-05, 4.1515568110413017e-06, - 4.4351391469818973e-05, 1.1650043122384966e-05, -1.1710592695891665e-05, - -4.3957554155084504e-05, -2.6752574970654273e-06, -1.1546591538391639e-05, - 1.1606603435837950e-05, 2.6515013939545564e-06, - 1.6794598764719960e-05, 4.7243461185578233e-06, -5.4058549896015648e-06, - -1.6645463879424616e-05, -1.3229289098014698e-06, -4.6823942490099374e-06, - 5.3578513680151396e-06, 1.3111813918058868e-06, - 5.2735603406759165e-06, 1.5789778675299268e-06, -1.9989826780664712e-06, - -5.2267314864994830e-06, -5.1808733150377238e-07, -1.5649566523489707e-06, - 1.9812318489709252e-06, 5.1348675152926985e-07, - // idx[0] = 12; - 8.5771895799448463e-03, 3.1197886695786712e-04, 1.2589091675382295e-04, - -8.5010247246790835e-03, 2.3881143669295742e-04, -3.0920851601408221e-04, - -1.2477301404636147e-04, -2.3669080751226941e-04, - 8.2661626046304885e-03, 1.0720660909669306e-03, -3.0982027320798947e-04, - -8.1927596475759902e-03, 1.8255117221452561e-04, -1.0625462175989969e-03, - 3.0706909042867208e-04, -1.8093013032420406e-04, - 6.6575398175439011e-03, 1.4760068941306471e-03, -5.9457869281011441e-04, - -6.5984213205230440e-03, 4.2899447104076090e-05, -1.4629000541319605e-03, - 5.8929887479281385e-04, -4.2518502955738542e-05, - 4.4799350811575711e-03, 1.3955105208072918e-03, -6.3033616055554532e-04, - -4.4401535648606475e-03, -8.3328432799330363e-05, -1.3831184830834593e-03, - 6.2473881867683195e-04, 8.2588482030546096e-05, - 2.5178444512609479e-03, 1.0028214075435281e-03, -4.8235931958416503e-04, - -2.4954861652017948e-03, -1.3193983394577959e-04, -9.9391642221575223e-04, - 4.7807600190536255e-04, 1.3076821726847499e-04, - 1.1813969572080783e-03, 5.6871985765870141e-04, -2.8575381884705388e-04, - -1.1709062332455860e-03, -1.1130086733193673e-04, -5.6366966432420582e-04, - 2.8321634453203873e-04, 1.1031252326278932e-04, - 4.6254048415618595e-04, 2.5918239859045285e-04, -1.3487188316997178e-04, - -4.5843315637685304e-04, -6.6255494613212145e-05, -2.5688087666510880e-04, - 1.3367423009662933e-04, 6.5667150364697886e-05, - 1.5102266511218463e-04, 9.5873653213552430e-05, -5.1458764419249627e-05, - -1.4968159420277919e-04, -3.0014361827430350e-05, -9.5022301747813123e-05, - 5.1001814120131696e-05, 2.9747836352719439e-05, - 4.9288640555562537e-05, 1.9197719093399958e-05, -9.3898074536993173e-06, - -4.8850960807531967e-05, -1.7734142076995751e-05, -1.9027244664386457e-05, - 9.3064266074420962e-06, 1.7576664111519137e-05, - 7.4312889120419612e-05, -3.9559856706301425e-05, 2.5345644730922928e-05, - -7.3652995761239122e-05, -1.7079041586904331e-05, 3.9208567891674429e-05, - -2.5120577143858990e-05, 1.6927380868854436e-05, - 2.4668363462348900e-04, -1.2316540125222137e-04, 8.0544516023109083e-05, - -2.4449310086503489e-04, -3.4617348824034278e-05, 1.2207170093550459e-04, - -7.9829286244383513e-05, 3.4309949140455846e-05, - 6.9889469196789068e-04, -2.9144378275440763e-04, 1.9257347432050185e-04, - -6.9268855503182346e-04, -6.3595836624040557e-05, 2.8885578195009997e-04, - -1.9086343507478647e-04, 6.3031109956076864e-05, - 1.6531830617114835e-03, -5.4719482372872844e-04, 3.7015196128372313e-04, - -1.6385029094950184e-03, -8.0981230730739408e-05, 5.4233577121939294e-04, - -3.6686503725170299e-04, 8.0262122955358892e-05, - 3.2662572681362470e-03, -7.8998871116982131e-04, 5.6119422549585842e-04, - -3.2372531275876876e-03, -5.0252394101103727e-05, 7.8297366559026060e-04, - -5.5621085925887826e-04, 4.9806156287680392e-05, - 5.3918935380395400e-03, -8.1066940565628718e-04, 6.4417804850085126e-04, - -5.3440138931855393e-03, 4.8296611837007029e-05, 8.0347071692792157e-04, - -6.3845779160642867e-04, -4.7867741235965884e-05, - 7.4385809600035612e-03, -4.2620301983017786e-04, 4.9868993294226453e-04, - -7.3725268711996870e-03, 1.7454031661297211e-04, 4.2241836624211989e-04, - -4.9426160053675874e-04, -1.7299041057102665e-04, - // idx[0] = 19; - 5.9328259833403554e-03, -3.1592831855465128e-03, 7.6447171990722429e-04, - -5.8801428954679998e-03, -1.4953722986179549e-04, 3.1312289675153120e-03, - -7.5768326346017955e-04, 1.4820934951554569e-04, - 8.5438428607558271e-03, -3.1770890503348324e-03, 7.1469750720538211e-04, - -8.4679741220696197e-03, 1.4653149000103094e-04, 3.1488767174453983e-03, - -7.0835104235372770e-04, -1.4523030041861771e-04, - 1.0538391888353600e-02, -2.0861147480127065e-03, 4.1035235387437105e-04, - -1.0444811691083959e-02, 4.6474412137475823e-04, 2.0675901921113566e-03, - -4.0670845311299757e-04, -4.6061722544804464e-04, - 1.1157187397402466e-02, -1.8349902862187803e-04, -6.0616833961046518e-05, - -1.1058112338448058e-02, 5.9620026364067165e-04, 1.8186956983166154e-04, - 6.0078560632437436e-05, -5.9090604618560014e-04, - 1.0147502273615180e-02, 1.6812950536897128e-03, -5.0484232418422572e-04, - -1.0057393149318094e-02, 4.4927500173386789e-04, -1.6663652689123390e-03, - 5.0035935896640773e-04, -4.4528547052872841e-04, - 7.9236576295588657e-03, 2.7048082887694913e-03, -7.4744339840908337e-04, - -7.8532960931947931e-03, 1.3680114431872893e-04, -2.6807897766548158e-03, - 7.4080615228917822e-04, -1.3558635953868966e-04, - 5.3016792692569753e-03, 2.6754726903120800e-03, -7.3909622093523025e-04, - -5.2546007209230755e-03, -1.3556652552418726e-04, -2.6517146762999374e-03, - 7.3253309717886256e-04, 1.3436270407437602e-04, - 3.0306885085190482e-03, 1.9748354796544215e-03, -5.6082860635096269e-04, - -3.0037762024011216e-03, -2.4639127781911607e-04, -1.9572990760248136e-03, - 5.5584848678691585e-04, 2.4420334016903554e-04, - 1.4749219675761626e-03, 1.1511708985332415e-03, -3.4089330270875329e-04, - -1.4618247616508787e-03, -2.1626062462552680e-04, -1.1409485798989471e-03, - 3.3786619355838658e-04, 2.1434024510951370e-04, - 6.0905145791109792e-04, 5.4222206411941223e-04, -1.6846528502586244e-04, - -6.0364312273221052e-04, -1.3353062399760682e-04, -5.3740716937438729e-04, - 1.6696932484779869e-04, 1.3234488121373442e-04, - 2.2538939529024053e-04, 1.9086017837583374e-04, -6.0622757673647777e-05, - -2.2338795291675510e-04, -7.2883062312480561e-05, -1.8916535308061312e-04, - 6.0084431742876553e-05, 7.2235865717300326e-05, - 1.3692552150240545e-04, -2.3628334870109308e-05, 6.7351766555555647e-06, - -1.3570963226150479e-04, -5.5072031551531791e-05, 2.3418516876840159e-05, - -6.6753687487373170e-06, 5.4582995688068806e-05, - 2.8180957439635708e-04, -2.6245954825184062e-04, 7.9675931947141405e-05, - -2.7930712470157688e-04, -8.6112162611911449e-05, 2.6012892546224296e-04, - -7.8968415135444934e-05, 8.5347492513293869e-05, - 7.5858237184660477e-04, -6.8983776721580120e-04, 2.0188206214679155e-04, - -7.5184621240645996e-04, -1.6201786760816690e-04, 6.8371205515042964e-04, - -2.0008936327954054e-04, 1.6057916005462314e-04, - 1.7743608964103581e-03, -1.4228383602125523e-03, 3.9110700695125220e-04, - -1.7586046933318674e-03, -2.5501449371089001e-04, 1.4102036531488829e-03, - -3.8763400355075369e-04, 2.5274998249505106e-04, - 3.5176447536171256e-03, -2.3790827021664207e-03, 6.1388697056463453e-04, - -3.4864083094370796e-03, -2.8116612144449217e-04, 2.3579566109232604e-03, - -6.0843569636499231e-04, 2.7866938556779779e-04, - // idx[0 = 28; - 3.9008280658611207e-04, -2.5603798505596852e-04, 1.8683093211897101e-05, - -3.8661889801461870e-04, 1.1175426823790703e-05, 2.5376438530717388e-04, - -1.8517188625419492e-05, -1.1076189799980769e-05, - 4.3680260689641130e-04, -1.8748123385802201e-04, 8.0091734113950957e-06, - -4.3292382970210014e-04, 2.7606287551937715e-05, 1.8581641335839929e-04, - -7.9380525007527933e-06, -2.7361145611652907e-05, - 4.4457679107663103e-04, -7.5578664486840552e-05, -3.4115616360440883e-06, - -4.4062897965993530e-04, 3.5399985354932533e-05, 7.4907531129210281e-05, - 3.3812672026731489e-06, -3.5085635912631181e-05, - 4.1504347649095089e-04, 4.2960315696147049e-05, -1.3312487632414327e-05, - -4.1135791888244848e-04, 3.1477256709139010e-05, -4.2578831038885959e-05, - 1.3194273655178598e-05, -3.1197740828200509e-05, - 3.5577914498131479e-04, 1.3094475217078906e-04, -2.0440326610361184e-05, - -3.5261985057240502e-04, 1.8525522986963621e-05, -1.2978197175140562e-04, - 2.0258817911812268e-05, -1.8361017613277599e-05, - 2.7796534980573800e-04, 1.6786465218620076e-04, -2.3905953966682069e-05, - -2.7549703656169430e-04, 2.9974039875550468e-06, -1.6637402558656323e-04, - 2.3693670734873877e-05, -2.9707872457006951e-06, - 1.9535178824326644e-04, 1.5650334125842896e-04, -2.3209649131201253e-05, - -1.9361707776044740e-04, -8.6672787668020905e-06, -1.5511360232069719e-04, - 2.3003549038581116e-05, 8.5903139257351561e-06, - 1.2172339077131273e-04, 1.1660274450623213e-04, -1.8887207777222881e-05, - -1.2064249540877665e-04, -1.3462333943164936e-05, -1.1556732013136769e-04, - 1.8719490667402875e-05, 1.3342789340965859e-05, - 6.7058946442705194e-05, 7.0433021024861683e-05, -1.2563048496751787e-05, - -6.6463467597043934e-05, -1.2699023524379705e-05, -6.9807580628297237e-05, - 1.2451489487645912e-05, 1.2586257066353350e-05, - 3.4938222906600265e-05, 3.1273776945169202e-05, -6.0324138429606134e-06, - -3.4627973883173486e-05, -1.0006175581767381e-05, -3.0996067950580566e-05, - 5.9788464217243402e-06, 9.9173214288020404e-06, - 2.4837446165027290e-05, -9.6145358765583846e-07, 1.9699547938565060e-07, - -2.4616891346377383e-05, -9.0936978967278239e-06, 9.5291594573175467e-07, - -1.9524617303820833e-07, 9.0129464830299899e-06, - 3.6725180241487430e-05, -3.6057780516486035e-05, 6.7954495238266452e-06, - -3.6399063159472330e-05, -1.1694827060907848e-05, 3.5737589898260177e-05, - -6.7351063980715334e-06, 1.1590977798611619e-05, - 7.3131479750304169e-05, -8.5125203228748116e-05, 1.4329502961988946e-05, - -7.2482077225311949e-05, -1.6767541211874010e-05, 8.4369297261769594e-05, - -1.4202257958371192e-05, 1.6618646595792397e-05, - 1.3604357772040060e-04, -1.5068140809657870e-04, 2.1787568445735812e-05, - -1.3483552007980250e-04, -2.0478489031778651e-05, 1.4934336752606917e-04, - -2.1594096332079554e-05, 2.0296641453544639e-05, - 2.2070902006211332e-04, -2.1925837439635583e-04, 2.6427797458379611e-05, - -2.1874913909968418e-04, -1.7877051979819007e-05, 2.1731137506795665e-04, - -2.6193120429307424e-05, 1.7718304984205783e-05, - 3.1225316368462653e-04, -2.6354343092504682e-04, 2.5533068602001434e-05, - -3.0948037700471862e-04, -6.4354644170033844e-06, 2.6120318333164132e-04, - -2.5306336703815414e-05, 6.3783179343098985e-06, - }; - - const double f1m[] = - { - // idx[1] = 2; - 7.5742778736170694e-07, 1.3311910271755548e-07, 2.8478156167525587e-07, - -7.5070188055260917e-07, 5.4750238065324756e-08, -1.3193701421442880e-07, - -2.8225272093725106e-07, -5.4264059705951382e-08, - 1.2925859849765668e-06, 1.7301030138070181e-07, 5.1100320791830013e-07, - -1.2811079100725808e-06, 7.3239351158981957e-08, -1.7147398176909403e-07, - -5.0646553447542282e-07, -7.2588990743278259e-08, - 1.8635824605983989e-06, 1.4918689410169481e-07, 7.1992200307670070e-07, - -1.8470339761485296e-06, 3.9576065168750808e-08, -1.4786212471296968e-07, - -7.1352914505999257e-07, -3.9224632424088840e-08, - 2.2073750885337050e-06, 5.4194161567241438e-08, 7.7188487204183924e-07, - -2.1877737491242868e-06, 2.2856919929920019e-08, -5.3712921129036553e-08, - -7.6503058731221621e-07, -2.2653952048417829e-08, - 2.3371245739281695e-06, 7.7901820168274067e-08, 7.1291202449929213e-07, - -2.3163710679863721e-06, -2.4448859078376102e-07, -7.7210057347509279e-08, - -7.0658141461162307e-07, 2.4231754886407241e-07, - 4.4362078536198185e-06, 1.4349007654002696e-06, -1.4918804712085053e-06, - -4.3968146321047141e-06, -7.9055943126041467e-07, -1.4221589450057450e-06, - 1.4786326749339418e-06, 7.8353931772558917e-07, - 1.8432855790288429e-05, 7.7265468592736174e-06, -7.0218535854514018e-06, - -1.8269173294953980e-05, -3.1418179249565271e-06, -7.6579356530322741e-06, - 6.9595000071553346e-06, 3.1139187972416376e-06, - 8.2880124644381316e-05, 3.4710110035730186e-05, -2.7056128318655973e-05, - -8.2144154821269593e-05, -1.1646701134768506e-05, -3.4401886638953268e-05, - 2.6815871754634015e-05, 1.1543279227396033e-05, - 3.6130932397451928e-04, 1.4417479842687968e-04, -9.7273919862532121e-05, - -3.5810092195539682e-04, -3.5891598669338311e-05, -1.4289453610402862e-04, - 9.6410134124976947e-05, 3.5572883734518748e-05, - 1.3866911075139233e-03, 4.8934908019720340e-04, -2.7681619210264059e-04, - -1.3743773855753208e-03, -7.3086254588880316e-05, -4.8500369392349860e-04, - 2.7435808330019372e-04, 7.2437253660220146e-05, - 4.1402065573272135e-03, 1.1066127780317765e-03, -5.1267688697286180e-04, - -4.1034418070240936e-03, -3.9937840842209967e-05, -1.0967861324518405e-03, - 5.0812435137475719e-04, 3.9583195554377857e-05, - 8.2661626046304885e-03, 1.0720660909669306e-03, -3.0982027320798947e-04, - -8.1927596475759902e-03, 1.8255117221452561e-04, -1.0625462175989969e-03, - 3.0706909042867208e-04, -1.8093013032420406e-04, - 9.2071430199458723e-03, -6.7468017399297192e-04, 5.5519252734112100e-04, - -9.1253842213336704e-03, 2.3350197769444222e-04, 6.6868906031594807e-04, - -5.5026245577217254e-04, -2.3142849614555009e-04, - 4.6562742627774770e-03, -1.5981825134639602e-03, 7.7093816367743357e-04, - -4.6149268666407072e-03, -1.2283002048105933e-04, 1.5839907623441212e-03, - -7.6409228565316330e-04, 1.2173929832259107e-04, - 8.4265128323255962e-04, -5.4995291705314407e-04, 2.3627440955229246e-04, - -8.3516859762456210e-04, -1.3174780227490776e-04, 5.4506937286423181e-04, - -2.3417630899862953e-04, 1.3057789082567117e-04, - 1.1584483866390634e-04, 4.3858963858025124e-05, -1.6873108923363265e-05, - -1.1481614444094632e-04, -4.5483891179512325e-05, -4.3469499266713828e-05, - 1.6723276873243230e-05, 4.5079997345020027e-05, - 1.9929185999929553e-03, 1.3468353897936520e-03, -4.5601060935764076e-04, - -1.9752216194948409e-03, -2.4418116907755306e-04, -1.3348755838951906e-03, - 4.5196126641871491e-04, 2.4201285704153328e-04, - 1.0151660891080034e-02, 2.5306058282125780e-03, -7.5599768765263124e-04, - -1.0061514838545050e-02, 2.8830814950722705e-04, -2.5081342220012394e-03, - 7.4928448003087715e-04, -2.8574799291111936e-04, - 8.5438428607558271e-03, -3.1770890503348324e-03, 7.1469750720538211e-04, - -8.4679741220696197e-03, 1.4653149000103094e-04, 3.1488767174453983e-03, - -7.0835104235372770e-04, -1.4523030041861771e-04, - 8.3058989180792564e-04, -7.7938148858281266e-04, 2.0964975534781903e-04, - -8.2321431052863629e-04, -1.7368462202414916e-04, 7.7246063441240638e-04, - -2.0778807989763350e-04, 1.7214231449147081e-04, - 4.8784698194571816e-04, 4.6603525819394176e-04, -1.2686455710601843e-04, - -4.8351493420147626e-04, -1.1084020143927416e-04, -4.6189689706081717e-04, - 1.2573800853899969e-04, 1.0985594805166225e-04, - 4.8781825809830056e-03, 1.3781496758297101e-03, -3.2928825061722268e-04, - -4.8348646541985386e-03, 2.0371545823830872e-04, -1.3659118012187121e-03, - 3.2636419353358076e-04, -2.0190647893949512e-04, - 2.3680721830718235e-03, -1.7400576716845835e-03, 2.7950593809702203e-04, - -2.3470438644831479e-03, -9.5410574014160988e-05, 1.7246060788892212e-03, - -2.7702394453460178e-04, 9.4563334659955370e-05, - 8.9363290665012504e-05, 3.9704854712887134e-05, -9.8017374005482072e-06, - -8.8569750772238336e-05, -3.3694653872763937e-05, -3.9352278325905277e-05, - 9.7146986446121813e-06, 3.3395447657076489e-05, - 1.5558629382148325e-03, 5.9445795666029032e-04, -1.1056083435049752e-04, - -1.5420469820210249e-03, 6.1304104070216740e-05, -5.8917921077172083e-04, - 1.0957906172347555e-04, -6.0759727830169152e-05, - 5.8935835734624678e-04, -5.5038435706920711e-04, 7.6629057291863393e-05, - -5.8412489554986733e-04, -4.8460576140248553e-05, 5.4549698172253944e-04, - -7.5948596518158015e-05, 4.8030249547439203e-05, - 1.2304561996882203e-04, 1.2696504265504160e-04, -2.3555535292118696e-05, - -1.2195298330168754e-04, -2.1706603802157628e-05, -1.2583760178323854e-04, - 2.3346363754109702e-05, 2.1513850648983980e-05, - 4.3680260689641130e-04, -1.8748123385802201e-04, 8.0091734113950957e-06, - -4.3292382970210014e-04, 2.7606287551937715e-05, 1.8581641335839929e-04, - -7.9380525007527933e-06, -2.7361145611652907e-05, - 1.6405328706551727e-05, 2.9047681450652957e-06, -5.1336046316489495e-07, - -1.6259650512677665e-05, -5.7121417723553899e-06, -2.8789740031395043e-06, - 5.0880185745708351e-07, 5.6614183451425587e-06, - 1.2525989018365017e-04, -1.7226749700817432e-05, -1.8059029379932504e-06, - -1.2414759094885763e-04, 1.0448806188093158e-05, 1.7073777344845486e-05, - 1.7898666437485847e-06, -1.0356021505698249e-05, - 6.1342326303602334e-06, -1.4359128614618401e-06, 2.5224463428445020e-07, - -6.0797610652743509e-06, -2.0408390187520330e-06, 1.4231620537236963e-06, - -2.5000471923036756e-07, 2.0227165082216116e-06, - 2.9913061136183802e-05, -9.4004861242035489e-06, -2.0777664618398835e-07, - -2.9647435204664162e-05, 2.4116686151255107e-06, 9.3170104520845704e-06, - 2.0593160381472413e-07, -2.3902531632099425e-06, - // idx[1] = 7; - 3.6490020128125056e-05, 7.3675063786135985e-06, 3.2021281911722955e-06, - -3.6165991251789855e-05, 6.9414808136517716e-07, -7.3020834272183321e-06, - -3.1736935124293500e-06, -6.8798409400575064e-07, - 7.1180658041772527e-05, 1.2900664940831104e-05, 6.7559365584194971e-06, - -7.0548578679769132e-05, 1.4100360605950567e-06, -1.2786107920854779e-05, - -6.6959443050874898e-06, -1.3975150370740391e-06, - 1.2807110995553272e-04, 2.0058649867687919e-05, 1.3810778814974065e-05, - -1.2693384728195296e-04, 2.7419450947357848e-06, -1.9880530432439409e-05, - -1.3688140046208898e-05, -2.7175968103308825e-06, - 2.0858381754799334e-04, 2.6012564754977512e-05, 2.6550477975637763e-05, - -2.0673160755237084e-04, 4.5938737655600021e-06, -2.5781574963835826e-05, - -2.6314711551985457e-05, -4.5530804815592547e-06, - 2.9871110310366976e-04, 2.5205913165246249e-05, 4.5389429729345988e-05, - -2.9605856899303685e-04, 5.9426328345686276e-06, -2.4982086384903065e-05, - -4.4986374706053220e-05, -5.8898626625298949e-06, - 3.6469434674854203e-04, 1.1237385446411157e-05, 6.5265128683803013e-05, - -3.6145588595932354e-04, 6.3539671552325690e-06, -1.1137598234281373e-05, - -6.4685578816824895e-05, -6.2975443626347055e-06, - 3.5893595493224776e-04, -1.4493122690417841e-05, 7.7817247724840170e-05, - -3.5574862826746054e-04, -1.6084567762455801e-06, 1.4364424754832286e-05, - -7.7126235901573401e-05, 1.5941737903768229e-06, - 2.6694095601170693e-04, -3.6280004828175835e-05, 7.0464806864678920e-05, - -2.6457053862852633e-04, -7.8696688227856493e-06, 3.5957840873301803e-05, - -6.9839084212036697e-05, 7.7997867033233192e-06, - 1.3743518008194365e-04, -3.5616161618941028e-05, 4.3245713680199841e-05, - -1.3621476510780793e-04, -1.0173131963280475e-05, 3.5299892546240166e-05, - -4.2861694708412319e-05, 1.0082795249096795e-05, - 4.4281012350574053e-05, -1.7888520118666143e-05, 1.6654315330488873e-05, - -4.3887799997592024e-05, -6.9220705758281906e-06, 1.7729671286766401e-05, - -1.6506426152469179e-05, 6.8606030638146820e-06, - 5.1438549738468361e-05, 2.9665824357334224e-05, -1.7900189835034524e-05, - -5.0981778944329460e-05, -1.3973723052800237e-05, -2.9402393871455844e-05, - 1.7741237376853713e-05, 1.3849637350377501e-05, - 4.6254048415618595e-04, 2.5918239859045285e-04, -1.3487188316997178e-04, - -4.5843315637685304e-04, -6.6255494613212145e-05, -2.5688087666510880e-04, - 1.3367423009662933e-04, 6.5667150364697886e-05, - 2.8294587601195142e-03, 1.2375254640891553e-03, -5.5518378989416852e-04, - -2.8043333603674971e-03, -1.6372300936094285e-04, -1.2265363228347245e-03, - 5.5025379591314930e-04, 1.6226916026556920e-04, - 9.1957619553724914e-03, 2.1739429633878338e-03, -7.9765225550990928e-04, - -9.1141042198332155e-03, 1.2436740398928127e-04, -2.1546384989570115e-03, - 7.9056915818215777e-04, -1.2326302997069018e-04, - 1.2500828315738250e-02, -7.8508011247857622e-04, 3.9877045177863924e-04, - -1.2389821817572859e-02, 4.5450998846944439e-04, 7.7810865491877395e-04, - -3.9522939751361548e-04, -4.5047397094109647e-04, - 5.4790816862939698e-03, -2.4387569363537110e-03, 8.7033830325395343e-04, - -5.4304278166626349e-03, -1.8988685124202967e-04, 2.4171009420032915e-03, - -8.6260975880687917e-04, 1.8820066902500816e-04, - 5.7215777750936191e-04, -4.7524252007978156e-04, 1.6913878684932706e-04, - -5.6707705568235730e-04, -1.2685880911773650e-04, 4.7102239909252376e-04, - -1.6763684602125821e-04, 1.2573231159245944e-04, - 3.7427031371474147e-04, 3.3208117201649374e-04, -1.1114484687920846e-04, - -3.7094681899556108e-04, -9.6463580458152723e-05, -3.2913231398235833e-04, - 1.1015788826098180e-04, 9.5606990478937183e-05, - 5.3016792692569753e-03, 2.6754726903120800e-03, -7.3909622093523025e-04, - -5.2546007209230755e-03, -1.3556652552418726e-04, -2.6517146762999374e-03, - 7.3253309717886256e-04, 1.3436270407437602e-04, - 9.1961936544017377e-03, -1.7368826364828015e-03, 2.6809009052315561e-04, - -9.1145320854046884e-03, 4.6206186478466938e-04, 1.7214592377822946e-03, - -2.6570946890431846e-04, -4.5795878711253288e-04, - 1.4411213884148821e-03, -1.2810931792856962e-03, 2.9718607020727523e-04, - -1.4283243293145838e-03, -2.1624336633437261e-04, 1.2697171597080945e-03, - -2.9454707828417920e-04, 2.1432314007080162e-04, - 2.5492665841420049e-04, 2.4888323947485475e-04, -6.6278567407764414e-05, - -2.5266292716977256e-04, -7.1894578026374012e-05, -2.4667317337616422e-04, - 6.5690018274416786e-05, 7.1256159103866377e-05, - 3.4578494082033329e-03, 1.1303046461231612e-03, -2.4223248931279460e-04, - -3.4271439425899311e-03, 1.3900706598040616e-04, -1.1202676183793079e-03, - 2.4008148141944991e-04, -1.3777269276728850e-04, - 1.5781234722698873e-03, -1.2618335200807974e-03, 1.9187865723673255e-04, - -1.5641098440602476e-03, -8.2967902797417424e-05, 1.2506285249561514e-03, - -1.9017478791907218e-04, 8.2231153510326405e-05, - 9.6977901902638771e-05, 8.6316756686137636e-05, -1.9677860154625181e-05, - -9.6116744784267204e-05, -3.0120448337378890e-05, -8.5550269806171510e-05, - 1.9503122105914992e-05, 2.9852980821734779e-05, - 1.1828731451272068e-03, 1.7396447751082659e-04, -4.5145997322396552e-05, - -1.1723693127172260e-03, 8.1902648560030431e-05, -1.7241968488061835e-04, - 4.4745103962183452e-05, -8.1175358657514666e-05, - 1.8720681143410243e-04, -2.0805519933339648e-04, 3.3414378701706986e-05, - -1.8554442778678481e-04, -3.2611926466637799e-05, 2.0620768343126807e-04, - -3.3117661310317896e-05, 3.2322334796065803e-05, - 1.9535178824326644e-04, 1.5650334125842896e-04, -2.3209649131201253e-05, - -1.9361707776044740e-04, -8.6672787668020905e-06, -1.5511360232069719e-04, - 2.3003549038581116e-05, 8.5903139257351561e-06, - 1.6951067600112064e-04, -1.5119863365618911e-04, 1.3863877085517486e-05, - -1.6800543282288719e-04, -4.5044095319840138e-06, 1.4985600015818046e-04, - -1.3740766807751243e-05, 4.4644106842421568e-06, - 3.6276567298503932e-05, 3.6027257115504254e-05, -5.2295393006259026e-06, - -3.5954433868657664e-05, -3.9956008741697106e-06, -3.5707337542985894e-05, - 5.1831013502662508e-06, 3.9601202124163002e-06, - 5.1575023302046883e-05, -4.4579128212970346e-05, 2.9869584382288155e-06, - -5.1117040632022465e-05, -3.2845211397064798e-09, 4.4183268611574349e-05, - -2.9604344521361577e-06, 3.2553548172312432e-09, - 1.2401275268881665e-05, 1.1336295347525180e-05, -1.3473909962905102e-06, - -1.2291152794945234e-05, -6.9063884391199019e-07, -1.1235629822256499e-05, - 1.3354262566444594e-06, 6.8450601834049220e-07, - // idx[1] = 10; - 3.9161987831707695e-05, 8.5585033279271904e-06, -3.0940904155168843e-06, - -3.8814232065402164e-05, -6.2790787320485707e-07, -8.4825044052978823e-06, - 3.0666151048127765e-06, 6.2233209435129094e-07, - 8.2966973231524862e-05, 1.7351396003363992e-05, -5.8734092978937982e-06, - -8.2230232198915169e-05, -9.6285893253993122e-07, -1.7197316796773389e-05, - 5.8212538261135436e-06, 9.5430881124964793e-07, - 1.6948528988022327e-04, 3.3617119358933897e-05, -9.1922219423833112e-06, - -1.6798027212900247e-04, -8.7142547168146892e-07, -3.3318601644412122e-05, - 9.1105956419166347e-06, 8.6368727325331598e-07, - 3.3130814623591096e-04, 6.1194737241075030e-05, -1.1197518621951395e-05, - -3.2836615261769482e-04, -4.4059942666451672e-07, -6.0651332170970138e-05, - 1.1098085424488793e-05, 4.3668693397105754e-07, - 6.0949868976399927e-04, 1.0001588819084043e-04, -9.8223350700820744e-06, - -6.0408638319692828e-04, 3.3693722410871172e-06, -9.9127753962567809e-05, - 9.7351134082531126e-06, -3.3394524466501626e-06, - 1.0226479509198823e-03, 1.3603218361846981e-04, 2.0902400504249218e-05, - -1.0135669072465832e-03, 1.1408417045058132e-05, -1.3482422715671544e-04, - -2.0716788621210686e-05, -1.1307111084061294e-05, - 1.4988806244302360e-03, 1.3106170460485647e-04, 8.5695676969146863e-05, - -1.4855706672751183e-03, 3.0453476425095055e-05, -1.2989788565587895e-04, - -8.4934705234475415e-05, -3.0183051642870378e-05, - 1.8030298257953226e-03, 3.5581460837069158e-05, 1.8651702121554774e-04, - -1.7870190445899432e-03, 3.0633437103590942e-05, -3.5265499904931722e-05, - -1.8486076285806655e-04, -3.0361414282882376e-05, - 1.6413216149696490e-03, -1.2558118114409131e-04, 2.6036761791834394e-04, - -1.6267467915868207e-03, 5.4223079993272169e-06, 1.2446602886760324e-04, - -2.5805557132664797e-04, -5.3741582761426463e-06, - 1.0189032686435122e-03, -2.1096043183989262e-04, 2.2864831174272861e-04, - -1.0098554774920258e-03, -2.7657765772399670e-05, 2.0908711767234067e-04, - -2.2661793041463409e-04, 2.7412166709047420e-05, - 3.7915828230823104e-04, -1.4271127978161287e-04, 1.1053775807032913e-04, - -3.7579138276314626e-04, -3.4225960821842870e-05, 1.4144401340396710e-04, - -1.0955619035909259e-04, 3.3922036636883500e-05, - 7.4312889120419612e-05, -3.9559856706301425e-05, 2.5345644730922928e-05, - -7.3652995761239122e-05, -1.7079041586904331e-05, 3.9208567891674429e-05, - -2.5120577143858990e-05, 1.6927380868854436e-05, - 1.6452199128976365e-04, 1.1354492403363452e-04, -5.6206288820240358e-05, - -1.6306104728965439e-04, -3.6099553950468539e-05, -1.1253665289486835e-04, - 5.5707180830016014e-05, 3.5778992387013618e-05, - 1.7045525792129491e-03, 9.4638345870692170e-04, -4.0697719285162913e-04, - -1.6894162692038758e-03, -1.8078271052518686e-04, -9.3797963849442858e-04, - 4.0336326328867662e-04, 1.7917737245339021e-04, - 8.0791678878996270e-03, 2.6080011965470560e-03, -9.4517642723761621e-04, - -8.0074254311060314e-03, -2.5821417318396076e-05, -2.5848423247725079e-03, - 9.3678332538179568e-04, 2.5592124903382838e-05, - 1.3356481058149027e-02, -4.3293862331198287e-04, 1.8456831679649629e-04, - -1.3237876422309745e-02, 5.5117088081287893e-04, 4.2909415802691651e-04, - -1.8292936280061883e-04, -5.4627652118930487e-04, - 5.8131600430988816e-03, -2.8057188210851192e-03, 8.7511944457956429e-04, - -5.7615395805694532e-03, -1.9564030185424144e-04, 2.7808042303636960e-03, - -8.6734844392539828e-04, 1.9390302939034247e-04, - 4.7634326079316490e-04, -4.2920915428436507e-04, 1.4088268702259574e-04, - -4.7211336530385859e-04, -1.1855725319576432e-04, 4.2539780642850714e-04, - -1.3963165842324922e-04, 1.1750447291777259e-04, - 6.0905145791109792e-04, 5.4222206411941223e-04, -1.6846528502586244e-04, - -6.0364312273221052e-04, -1.3353062399760682e-04, -5.3740716937438729e-04, - 1.6696932484779869e-04, 1.3234488121373442e-04, - 6.4242974589046788e-03, 2.4764802964899425e-03, -6.3518193397605228e-04, - -6.3672501380333084e-03, 8.6162573411431977e-05, -2.4544893212884956e-03, - 6.2954156196167702e-04, -8.5397455668371819e-05, - 6.1192473190725665e-03, -2.6624998539887439e-03, 4.5719660344097069e-04, - -6.0649088225232604e-03, 1.3024981958765076e-04, 2.6388570378735065e-03, - -4.5313672895591774e-04, -1.2909321012194870e-04, - 3.6469519543160195e-04, -3.8363095857578205e-04, 9.4090664425705537e-05, - -3.6145672710613606e-04, -9.7469050278117320e-05, 3.8022434197216746e-04, - -9.3255145778128976e-05, 9.6603531795853362e-05, - 9.1178047998912944e-04, 7.8751323767825218e-04, -1.7362275060965260e-04, - -9.0368393185465677e-04, -1.1501287471381066e-04, -7.8052017413353532e-04, - 1.7208099249089212e-04, 1.1399156827367334e-04, - 3.0428994134042361e-03, -6.0542157405542502e-04, 2.7297328115256485e-05, - -3.0158786752883249e-03, 2.0376965733463401e-04, 6.0004547199624656e-04, - -2.7054929713581609e-05, -2.0196019675156203e-04, - 2.4486683302324625e-04, -2.7365088383468991e-04, 5.4183415554686730e-05, - -2.4269243233841011e-04, -5.7765593385108655e-05, 2.7122088275259283e-04, - -5.3702270540336453e-05, 5.7252638877281821e-05, - 4.8684120652024070e-04, 3.9028286351598836e-04, -6.7232236617729949e-05, - -4.8251808999280312e-04, -3.0667260128958450e-05, -3.8681717845267713e-04, - 6.6635218967198297e-05, 3.0394936962104197e-05, - 6.3412598830576885e-04, -4.3372366375867428e-04, 3.8776407472195745e-05, - -6.2849499301653115e-04, 9.5143346917004076e-06, 4.2987222736827919e-04, - -3.8432075633040440e-05, -9.4298480521095317e-06, - 3.4938222906600265e-05, 3.1273776945169202e-05, -6.0324138429606134e-06, - -3.4627973883173486e-05, -1.0006175581767381e-05, -3.0996067950580566e-05, - 5.9788464217243402e-06, 9.9173214288020404e-06, - 2.4392083227262561e-04, -5.6676719861445976e-05, -1.1626687511739263e-06, - -2.4175483200958038e-04, 1.9445449116214847e-05, 5.6173434475836838e-05, - 1.1523443323966798e-06, -1.9272774861587520e-05, - 1.0411319188242270e-05, -3.0681569078749306e-06, 5.5818318184871959e-07, - -1.0318867387835262e-05, -3.5693133209656941e-06, 3.0409118849402196e-06, - -5.5322655347283574e-07, 3.5376180634509055e-06, - 6.2185931257129924e-05, -1.0179624868692854e-05, -8.9508031605887850e-07, - -6.1633724452136285e-05, 5.2188375294843555e-06, 1.0089230497954375e-05, - 8.8713206423484730e-07, -5.1724946101185369e-06, - 3.4821562995004312e-06, 1.0893657152118253e-06, -1.5562699790180428e-07, - -3.4512349903592222e-06, -1.0573421757721680e-06, -1.0796922223669664e-06, - 1.5424504083298160e-07, 1.0479530497614316e-06, - // idx[1] = 13; - 7.6939600011633745e-06, 1.8061169092499393e-06, -1.7409386096072833e-06, - -7.6256381639873142e-06, -3.8744241924183407e-07, -1.7900787149551884e-06, - 1.7254791941435799e-06, 3.8400195712888607e-07, - 1.7708033426125268e-05, 4.1983811964132660e-06, -3.8745042608883230e-06, - -1.7550787303677916e-05, -8.9714935127936357e-07, -4.1610998593045459e-06, - 3.8400989287563202e-06, 8.8918272656446436e-07, - 4.1224027239434575e-05, 9.9239799414819331e-06, -8.9605036911705433e-06, - -4.0857960704598385e-05, -2.1501854097138079e-06, -9.8358556801655410e-06, - 8.8809350328839017e-06, 2.1310919107303748e-06, - 9.7120871429426495e-05, 2.3660577068010910e-05, -1.9999449126191993e-05, - -9.6258444751461542e-05, -4.1887526472941376e-06, -2.3450472766235517e-05, - 1.9821855389468108e-05, 4.1515568110413017e-06, - 2.2966717127649675e-04, 5.5667830351288630e-05, -3.9586034209482798e-05, - -2.2762774254561342e-04, -7.9335419238213086e-06, -5.5173503835342345e-05, - 3.9234512940422766e-05, 7.8630926156020119e-06, - 5.3200292659768048e-04, 1.2461168529569132e-04, -7.7661558932109947e-05, - -5.2727877709304340e-04, -1.3162232392700854e-05, -1.2350514207585148e-04, - 7.6971929614645792e-05, 1.3045352671689596e-05, - 1.1666581574647169e-03, 2.4674867349924984e-04, -1.2191453257652898e-04, - -1.1562983130331923e-03, -1.1089595832661965e-05, -2.4455756220003919e-04, - 1.2083193988787077e-04, 1.0991120982167166e-05, - 2.2887686678893923e-03, 3.9334003412439531e-04, -1.3148940639503572e-04, - -2.2684445590770812e-03, 1.6659921237230303e-05, -3.8984720159573514e-04, - 1.3032178948349212e-04, -1.6511982279143148e-05, - 3.7173943219990105e-03, 3.9400146321998456e-04, -3.1956132370684377e-06, - -3.6843841153501047e-03, 7.3337556977308329e-05, -3.9050275724631495e-04, - 3.1672364106713046e-06, -7.2686324500672754e-05, - 4.5199940871419554e-03, 2.1470803254982653e-05, 2.8930333733463666e-04, - -4.4798568496190452e-03, 9.9813558392372950e-05, -2.1280143994497898e-05, - -2.8673434353886968e-04, -9.8927220838835293e-05, - 3.6305853350697154e-03, -5.0640172967673838e-04, 5.0404713216872657e-04, - -3.5983459862715781e-03, 1.2471040562830394e-05, 5.0190491704508729e-04, - -4.9957122820147365e-04, -1.2360298577867939e-05, - 1.6531830617114835e-03, -5.4719482372872844e-04, 3.7015196128372313e-04, - -1.6385029094950184e-03, -8.0981230730739408e-05, 5.4233577121939294e-04, - -3.6686503725170299e-04, 8.0262122955358892e-05, - 3.5645930339666049e-04, -2.0018386894217195e-04, 1.1080594537964248e-04, - -3.5329396922766608e-04, -5.1667624794085499e-05, 1.9840624991411976e-04, - -1.0982199618349089e-04, 5.1208819829162221e-05, - 8.1645729682003766e-05, 3.1518177127831518e-05, -1.4204895571968811e-05, - -8.0920721201505936e-05, -3.1610417461887078e-05, -3.1238297876381250e-05, - 1.4078757073429143e-05, 3.1329719122596009e-05, - 1.1112012333347322e-03, 7.2994071394047412e-04, -2.9209530026815726e-04, - -1.1013338425863719e-03, -1.6061672159759519e-04, -7.2345889045835620e-04, - 2.8950151403300714e-04, 1.5919045612453774e-04, - 7.2402254655031450e-03, 2.7989480758611120e-03, -9.5793435231481981e-04, - -7.1759327598876661e-03, -9.4784436742230806e-05, -2.7740936088929561e-03, - 9.4942796095922244e-04, 9.3942757444060668e-05, - 1.3241006243061246e-02, -4.8348417204651956e-04, 1.1607405154312268e-04, - -1.3123427015660947e-02, 6.0299863597544526e-04, 4.7919086575499135e-04, - -1.1504332192551400e-04, -5.9764404944025846e-04, - 5.0513947154027950e-03, -2.8225427733082589e-03, 7.8810546751066060e-04, - -5.0065386767431741e-03, -2.3600245213992220e-04, 2.7974787870448429e-03, - -7.8110714500564547e-04, 2.3390676654943019e-04, - 2.8180957439635708e-04, -2.6245954825184062e-04, 7.9675931947141405e-05, - -2.7930712470157688e-04, -8.6112162611911449e-05, 2.6012892546224296e-04, - -7.8968415135444934e-05, 8.5347492513293869e-05, - 1.1583383425450176e-03, 9.6723264576604215e-04, -2.6977156771823926e-04, - -1.1480523774994257e-03, -1.8655819799415997e-04, -9.5864368620225400e-04, - 2.6737601469722168e-04, 1.8490157398970858e-04, - 6.9931044556163944e-03, 1.2000797468667162e-03, -3.3704778425109526e-04, - -6.9310061676217134e-03, 3.5590508141603505e-04, -1.1894231210132782e-03, - 3.3405482304091577e-04, -3.5274466870022149e-04, - 2.8733758677926490e-03, -2.0671103848013198e-03, 3.8129908297979245e-04, - -2.8478604871362296e-03, -1.4871125794984149e-04, 2.0487545863420113e-03, - -3.7791317327155554e-04, 1.4739071217752654e-04, - 1.0322441124946468e-04, 1.8476743202895802e-05, -4.8168812615710036e-06, - -1.0230778555646471e-04, -4.0962290464139684e-05, -1.8312670990347120e-05, - 4.7741076862990093e-06, 4.0598548133918808e-05, - 1.9582591910971363e-03, 9.7865979301640601e-04, -1.8723018386836629e-04, - -1.9408699837731539e-03, 2.3128246186437582e-05, -9.6996936116868198e-04, - 1.8556759267543521e-04, -2.2922868946384473e-05, - 1.2887036948865914e-03, -9.7941769109876069e-04, 1.2664939140072734e-04, - -1.2772600944523657e-03, -3.3426030714455137e-05, 9.7072052916804066e-04, - -1.2552475349041602e-04, 3.3129209853991952e-05, - 6.9313334777440611e-05, 5.9715287673186426e-05, -1.2957096051869759e-05, - -6.8697837117967728e-05, -2.1501206316811928e-05, -5.9185020013787079e-05, - 1.2842037927497324e-05, 2.1310277079222445e-05, - 7.4156655404620110e-04, 3.4961769651018976e-05, -2.0021392848953567e-05, - -7.3498149390121789e-04, 5.6888820265120965e-05, -3.4651311534116488e-05, - 1.9843604253476427e-05, -5.6383651442472562e-05, - 7.3131479750304169e-05, -8.5125203228748116e-05, 1.4329502961988946e-05, - -7.2482077225311949e-05, -1.6767541211874010e-05, 8.4369297261769594e-05, - -1.4202257958371192e-05, 1.6618646595792397e-05, - 1.6327041844856342e-04, 9.2190327694195343e-05, -1.2311099334815660e-05, - -1.6182058832945399e-04, 3.8034733974803152e-06, -9.1371683906473801e-05, - 1.2201777616989676e-05, -3.7696988145442397e-06, - 5.1551691384217321e-05, -5.7564660526755213e-05, 7.0153713767409422e-06, - -5.1093915900023176e-05, -6.4107510814895152e-06, 5.7053490288931074e-05, - -6.9530753600136905e-06, 6.3538240515206069e-06, - 4.0328806418053059e-05, 2.5609342610977449e-05, -2.9607290538332087e-06, - -3.9970689382718532e-05, 7.0182568368235099e-07, -2.5381933404822421e-05, - 2.9344379828752321e-06, -6.9559351974086134e-07, - 1.1170036525578136e-05, -1.3138092309676044e-05, 1.5550589860992071e-06, - -1.1070847367246694e-05, -1.6709719218995304e-06, 1.3021426950946600e-05, - -1.5412501689450531e-06, 1.6561338058245150e-06, - }; - - int nvals0 = sizeof(f0m)/sizeof(f0m[0]); - int nvals1 = sizeof(f1m)/sizeof(f1m[0]); - for (int i=0; inum_do[shear_idx[0]-up->shear_r.lower[0]] = num_do_curr; + } // Copy the donor list to the persistent object and release the buffer. @@ -436,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; @@ -457,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; nshear_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; + 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", @@ -1452,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] = {}; @@ -1463,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) { From c289cd3445e4c51d176f0e862f3f07672e6d1881 Mon Sep 17 00:00:00 2001 From: manauref Date: Thu, 9 Jul 2026 14:31:14 -0700 Subject: [PATCH 11/19] Fix y extents in CBC input files so the wedge number is indeed an integer. This explains a mysterious shift we were seeing when structures crossed the IMP. --- gyrokinetic/creg/rt_gk_cbc_2x2v_p1.c | 117 ++++++++--------- gyrokinetic/creg/rt_gk_cbc_3x2v_p1.c | 127 +++++++++---------- gyrokinetic/creg/rt_gk_cbc_passive_3x2v_p1.c | 33 ++--- 3 files changed, 125 insertions(+), 152 deletions(-) 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 index f5f939c582..c4a5f0e69d 100644 --- a/gyrokinetic/creg/rt_gk_cbc_passive_3x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_cbc_passive_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 @@ -394,19 +384,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; + 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 @@ -433,8 +424,8 @@ struct gk_app_ctx create_ctx(void) double vpar_max_elc = 4.*vte; double mu_max_elc = 7*Te0/B0; - double t_end = 1.0; - int num_frames = 1; + 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. From ae49bfd650904ed956ecbfc73db8ca4838d10f13 Mon Sep 17 00:00:00 2001 From: Manaure Francisquez Date: Fri, 10 Jul 2026 12:33:26 -0700 Subject: [PATCH 12/19] Fix kernel selection in device code, and add some missing casts. --- .../zero/gk_collisionless_passive_flux_cu.cu | 14 ++++-- .../zero/gkyl_dg_gyrokinetic_passive_priv.h | 50 +++++++++---------- 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/gyrokinetic/zero/gk_collisionless_passive_flux_cu.cu b/gyrokinetic/zero/gk_collisionless_passive_flux_cu.cu index f5a350ff6a..78b60a340c 100644 --- a/gyrokinetic/zero/gk_collisionless_passive_flux_cu.cu +++ b/gyrokinetic/zero/gk_collisionless_passive_flux_cu.cu @@ -129,12 +129,12 @@ gkyl_gk_collisionless_passive_flux_surf_cu(gkyl_gk_collisionless_passive_flux *u // 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) + 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); - up->flux_surf_edge_up[d] = choose_gk_collisionless_passive_flux_edge_up_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]); } } @@ -178,12 +178,18 @@ gkyl_gk_collisionless_passive_flux_cu_dev_new(const struct gkyl_rect_grid *phase 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); + 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; diff --git a/gyrokinetic/zero/gkyl_dg_gyrokinetic_passive_priv.h b/gyrokinetic/zero/gkyl_dg_gyrokinetic_passive_priv.h index d492d4087c..7d18d7de27 100644 --- a/gyrokinetic/zero/gkyl_dg_gyrokinetic_passive_priv.h +++ b/gyrokinetic/zero/gkyl_dg_gyrokinetic_passive_priv.h @@ -67,11 +67,11 @@ kernel_dg_gyrokinetic_passive_vol_1x1v_ser_p1(const struct gkyl_dg_eqn *eqn, long vidx = gkyl_range_idx(&gkp->vel_map->local_vel, vel_idx); return dg_gyrokinetic_passive_vol_1x1v_ser_p1(xc, dx, - gkyl_array_cfetch(gkp->vel_map->vmap, vidx), - gkyl_array_cfetch(gkp->vel_map->vmap_sq, vidx), + (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, - gkyl_array_cfetch(gkp->gk_geom->geo_corn.bmag, cidx), - gkyl_array_cfetch(gkp->auxfields.speeds, cidx), + (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), @@ -93,11 +93,11 @@ kernel_dg_gyrokinetic_passive_vol_1x2v_ser_p1(const struct gkyl_dg_eqn *eqn, long vidx = gkyl_range_idx(&gkp->vel_map->local_vel, vel_idx); return dg_gyrokinetic_passive_vol_1x2v_ser_p1(xc, dx, - gkyl_array_cfetch(gkp->vel_map->vmap, vidx), - gkyl_array_cfetch(gkp->vel_map->vmap_sq, vidx), + (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, - gkyl_array_cfetch(gkp->gk_geom->geo_corn.bmag, cidx), - gkyl_array_cfetch(gkp->auxfields.speeds, cidx), + (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), @@ -119,11 +119,11 @@ kernel_dg_gyrokinetic_passive_vol_2x2v_ser_p1(const struct gkyl_dg_eqn *eqn, long vidx = gkyl_range_idx(&gkp->vel_map->local_vel, vel_idx); return dg_gyrokinetic_passive_vol_2x2v_ser_p1(xc, dx, - gkyl_array_cfetch(gkp->vel_map->vmap, vidx), - gkyl_array_cfetch(gkp->vel_map->vmap_sq, vidx), + (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, - gkyl_array_cfetch(gkp->gk_geom->geo_corn.bmag, cidx), - gkyl_array_cfetch(gkp->auxfields.speeds, cidx), + (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), @@ -145,11 +145,11 @@ kernel_dg_gyrokinetic_passive_vol_3x2v_ser_p1(const struct gkyl_dg_eqn *eqn, long vidx = gkyl_range_idx(&gkp->vel_map->local_vel, vel_idx); return dg_gyrokinetic_passive_vol_3x2v_ser_p1(xc, dx, - gkyl_array_cfetch(gkp->vel_map->vmap, vidx), - gkyl_array_cfetch(gkp->vel_map->vmap_sq, vidx), + (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, - gkyl_array_cfetch(gkp->gk_geom->geo_corn.bmag, cidx), - gkyl_array_cfetch(gkp->auxfields.speeds, cidx), + (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), @@ -264,11 +264,11 @@ surf_passive(const struct gkyl_dg_eqn *eqn, long pidxR = gkyl_range_idx(&gkp->phase_range, idxR); return gkp->surf[dir](xcC, dxC, - gkyl_array_cfetch(gkp->vel_map->vmap_prime, vidxL), - gkyl_array_cfetch(gkp->vel_map->vmap_prime, vidxC), - gkyl_array_cfetch(gkp->vel_map->vmap_prime, vidxR), - gkyl_array_cfetch(gkp->auxfields.flux_surf, pidxC), - gkyl_array_cfetch(gkp->auxfields.flux_surf, pidxR), + (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; @@ -300,10 +300,10 @@ boundary_surf_passive(const struct gkyl_dg_eqn *eqn, long pidxSkin = gkyl_range_idx(&gkp->phase_range, idxSkin); return gkp->boundary_surf[dir](xcSkin, dxSkin, - gkyl_array_cfetch(gkp->vel_map->vmap_prime, vidxEdge), - gkyl_array_cfetch(gkp->vel_map->vmap_prime, vidxSkin), - gkyl_array_cfetch(gkp->auxfields.flux_surf, pidxEdge), - gkyl_array_cfetch(gkp->auxfields.flux_surf, pidxSkin), + (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; From b6cac760ac49f4c46b6a701f8b5f88270412ee67 Mon Sep 17 00:00:00 2001 From: manauref Date: Fri, 10 Jul 2026 13:29:49 -0700 Subject: [PATCH 13/19] Add device CBC unit test. Add bc_twistshift_new method, instead of inew, so we can call it from python. --- gyrokinetic/apps/gk_field_2x3x.c | 6 +++--- gyrokinetic/apps/gk_species.c | 8 ++++---- gyrokinetic/apps/gyrokinetic.c | 2 +- gyrokinetic/unit/ctest_bc_twistshift.c | 20 ++++++++++--------- gyrokinetic/zero/bc_twistshift.c | 27 +++++++++++++++++++++++++- gyrokinetic/zero/gkyl_bc_twistshift.h | 26 ++++++++++++++++++++++++- 6 files changed, 70 insertions(+), 19 deletions(-) diff --git a/gyrokinetic/apps/gk_field_2x3x.c b/gyrokinetic/apps/gk_field_2x3x.c index f64b5c7f15..0a8e5a6290 100644 --- a/gyrokinetic/apps/gk_field_2x3x.c +++ b/gyrokinetic/apps/gk_field_2x3x.c @@ -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 = { @@ -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); @@ -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..da8f5a8695 100644 --- a/gyrokinetic/apps/gk_species.c +++ b/gyrokinetic/apps/gk_species.c @@ -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) || @@ -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) || @@ -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, @@ -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/gyrokinetic.c b/gyrokinetic/apps/gyrokinetic.c index 4b907cb034..fcc86df276 100644 --- a/gyrokinetic/apps/gyrokinetic.c +++ b/gyrokinetic/apps/gyrokinetic.c @@ -1258,7 +1258,7 @@ gyrokinetic_app_write_ts_shift_mapc2p(struct gkyl_gyrokinetic_app *app) .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, diff --git a/gyrokinetic/unit/ctest_bc_twistshift.c b/gyrokinetic/unit/ctest_bc_twistshift.c index d849b022b9..ceecc08e82 100644 --- a/gyrokinetic/unit/ctest_bc_twistshift.c +++ b/gyrokinetic/unit/ctest_bc_twistshift.c @@ -337,7 +337,7 @@ test_bc_twistshift_3x_fig6_wcells(const int *cells, enum gkyl_edge_loc edge, .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); @@ -394,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); @@ -594,7 +594,7 @@ test_bc_twistshift_3x2v_fig6_wcells(const int *cells, enum gkyl_edge_loc edge, .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); @@ -735,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); @@ -1004,7 +1004,7 @@ test_bc_twistshift_3x_fig11_wcells(const int *cells, enum gkyl_edge_loc edge, .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); @@ -1371,7 +1371,7 @@ test_bc_twistshift_3x_fig14_wcells(const int *cells, enum gkyl_edge_loc edge, .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); @@ -1821,7 +1821,7 @@ test_bc_twistshift_3x2v_fig11_wcells(const int *cells, enum gkyl_edge_loc edge, .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); @@ -2408,7 +2408,7 @@ test_bc_twistshift_3x_cbc_wcells(const int *cells, enum gkyl_edge_loc edge, .use_gpu = use_gpu, }; - struct gkyl_bc_twistshift *tsup = gkyl_bc_twistshift_new(&tsinp); + struct gkyl_bc_twistshift *tsup = gkyl_bc_twistshift_inew(&tsinp); struct gkyl_array *buff_per = mkarr(use_gpu, basis.num_basis, skin_rng.volume); apply_periodic_bc(buff_per, distf, bc_dir, skin_ghost); @@ -3801,10 +3801,11 @@ void test_bc_twistshift_3x2v_fig11_ho(){ test_bc_twistshift_3x2v_fig11(false); } #ifdef GKYL_HAVE_CUDA void test_bc_twistshift_3x_fig6_dev(){ test_bc_twistshift_3x_fig6(true); } void test_bc_twistshift_3x_fig11_dev(){ test_bc_twistshift_3x_fig11(true); } +void test_bc_twistshift_3x_fig14_dev(){ test_bc_twistshift_3x_fig14(true); } +void test_bc_twistshift_3x_cbc_dev(){ test_bc_twistshift_3x_cbc(true); } void test_bc_twistshift_3x2v_fig6_dev(){ test_bc_twistshift_3x2v_fig6(true); } void test_bc_twistshift_3x2v_fig11_dev(){ test_bc_twistshift_3x2v_fig11(true); } -void test_bc_twistshift_3x_fig14_dev(){ test_bc_twistshift_3x_fig14(true); } #endif TEST_LIST = { @@ -3818,6 +3819,7 @@ TEST_LIST = { { "test_bc_twistshift_3x_fig6_dev", test_bc_twistshift_3x_fig6_dev }, { "test_bc_twistshift_3x_fig11_dev", test_bc_twistshift_3x_fig11_dev }, { "test_bc_twistshift_3x_fig14_dev", test_bc_twistshift_3x_fig14_dev }, + { "test_bc_twistshift_3x_cbc_dev", test_bc_twistshift_3x_cbc_dev }, { "test_bc_twistshift_3x2v_fig6_dev", test_bc_twistshift_3x2v_fig6_dev }, { "test_bc_twistshift_3x2v_fig11_dev", test_bc_twistshift_3x2v_fig11_dev }, #endif diff --git a/gyrokinetic/zero/bc_twistshift.c b/gyrokinetic/zero/bc_twistshift.c index 92495ed10d..aeac67612e 100644 --- a/gyrokinetic/zero/bc_twistshift.c +++ b/gyrokinetic/zero/bc_twistshift.c @@ -1704,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. @@ -1898,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, struct gkyl_range bcdir_ext_update_r, const int *num_ghost, + struct gkyl_basis basis, 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/gkyl_bc_twistshift.h b/gyrokinetic/zero/gkyl_bc_twistshift.h index 54b5871c02..4491c9fb24 100644 --- a/gyrokinetic/zero/gkyl_bc_twistshift.h +++ b/gyrokinetic/zero/gkyl_bc_twistshift.h @@ -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, struct gkyl_range bcdir_ext_update_r, const int *num_ghost, + struct gkyl_basis basis, 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. From ce4c1287a38415c1c06cd65e519368d8b95d9287 Mon Sep 17 00:00:00 2001 From: manauref Date: Fri, 10 Jul 2026 16:30:03 -0700 Subject: [PATCH 14/19] Change signature of bc_twistshift_new so that structs are passed by address, this makes it easier to call it from python. Rename num_cell_ variables in tcv reg tests so that they use Nx like all other reg tests (makes it easier to automate changes to them). --- gyrokinetic/apps/gk_field_2x3x.c | 18 +++++----- gyrokinetic/apps/gk_species.c | 24 ++++++------- gyrokinetic/apps/gyrokinetic.c | 6 ++-- gyrokinetic/creg/rt_gk_tcv_core_3x2v_p1.c | 24 ++++++------- .../creg/rt_gk_tcv_iwl_adapt_source_2x2v_p1.c | 28 +++++++-------- .../creg/rt_gk_tcv_iwl_adapt_source_3x2v_p1.c | 32 ++++++++--------- gyrokinetic/unit/ctest_bc_twistshift.c | 36 +++++++++---------- gyrokinetic/zero/bc_twistshift.c | 34 +++++++++--------- gyrokinetic/zero/gkyl_bc_twistshift.h | 10 +++--- 9 files changed, 106 insertions(+), 106 deletions(-) diff --git a/gyrokinetic/apps/gk_field_2x3x.c b/gyrokinetic/apps/gk_field_2x3x.c index 0a8e5a6290..b8cb19dcf0 100644 --- a/gyrokinetic/apps/gk_field_2x3x.c +++ b/gyrokinetic/apps/gk_field_2x3x.c @@ -259,10 +259,10 @@ gk_field_2x3x_add_TS_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, + .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) @@ -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) @@ -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) diff --git a/gyrokinetic/apps/gk_species.c b/gyrokinetic/apps/gk_species.c index da8f5a8695..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) @@ -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) @@ -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) @@ -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) diff --git a/gyrokinetic/apps/gyrokinetic.c b/gyrokinetic/apps/gyrokinetic.c index fcc86df276..1be8077195 100644 --- a/gyrokinetic/apps/gyrokinetic.c +++ b/gyrokinetic/apps/gyrokinetic.c @@ -1250,10 +1250,10 @@ 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, diff --git a/gyrokinetic/creg/rt_gk_tcv_core_3x2v_p1.c b/gyrokinetic/creg/rt_gk_tcv_core_3x2v_p1.c index 07483e639a..f9ca5a4bb4 100644 --- a/gyrokinetic/creg/rt_gk_tcv_core_3x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_tcv_core_3x2v_p1.c @@ -29,7 +29,7 @@ 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 @@ -454,11 +454,11 @@ struct gk_app_ctx create_ctx(void) double sigma_srcCORE[3] = {0.03*Lx, 0.0, Lz/6}; // the electron source will be at +Lz/2. double floor_srcCORE = 1e-10; // Grid parameters - int num_cell_x = 8; - int num_cell_y = 4; - int num_cell_z = 8; - int num_cell_vpar = 12; - int num_cell_mu = 8; + int Nx = 8; + int Ny = 4; + int Nz = 8; + int Nvpar = 12; + int Nmu = 8; int poly_order = 1; // Velocity box dimensions double vpar_max_elc = 6.*vte; @@ -505,12 +505,12 @@ struct gk_app_ctx create_ctx(void) .sigma_srcCORE = {sigma_srcCORE[0], sigma_srcCORE[1], sigma_srcCORE[2]}, .energy_srcCORE = energy_srcCORE, .particle_srcCORE = particle_srcCORE, .floor_srcCORE = floor_srcCORE, - .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, diff --git a/gyrokinetic/creg/rt_gk_tcv_iwl_adapt_source_2x2v_p1.c b/gyrokinetic/creg/rt_gk_tcv_iwl_adapt_source_2x2v_p1.c index 2e0ee0094a..3a21a53602 100644 --- a/gyrokinetic/creg/rt_gk_tcv_iwl_adapt_source_2x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_tcv_iwl_adapt_source_2x2v_p1.c @@ -35,11 +35,11 @@ struct gk_app_ctx { // Grid parameters double Lx, Lz; double x_min, x_max, z_min, z_max; - int num_cell_x, num_cell_z, num_cell_vpar, num_cell_mu; + 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 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; }; @@ -406,17 +406,17 @@ struct gk_app_ctx create_ctx(void) double floor_srcRECY = 1e-10; // Grid parameters - int num_cell_x = 9; // The LCFS is positionned at 1/3 of the domain -> 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..2258320a44 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 = 9; // (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 = 8; // (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/unit/ctest_bc_twistshift.c b/gyrokinetic/unit/ctest_bc_twistshift.c index ceecc08e82..a0aa50d7b8 100644 --- a/gyrokinetic/unit/ctest_bc_twistshift.c +++ b/gyrokinetic/unit/ctest_bc_twistshift.c @@ -327,10 +327,10 @@ 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, @@ -584,10 +584,10 @@ 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, @@ -995,10 +995,10 @@ 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, @@ -1362,10 +1362,10 @@ test_bc_twistshift_3x_fig14_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_fig14, .shift_func_ctx = &proj_ctx, .use_gpu = use_gpu, @@ -1812,10 +1812,10 @@ 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, @@ -2399,10 +2399,10 @@ test_bc_twistshift_3x_cbc_wcells(const int *cells, enum gkyl_edge_loc edge, .shear_dir = 0, .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 = (edge == GKYL_LOWER_EDGE) ? bc_shift_func_lo_cbc : bc_shift_func_up_cbc, .shift_func_ctx = &app_ctx, .use_gpu = use_gpu, diff --git a/gyrokinetic/zero/bc_twistshift.c b/gyrokinetic/zero/bc_twistshift.c index aeac67612e..bf65db7ccb 100644 --- a/gyrokinetic/zero/bc_twistshift.c +++ b/gyrokinetic/zero/bc_twistshift.c @@ -1714,18 +1714,18 @@ gkyl_bc_twistshift_inew(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); @@ -1735,9 +1735,9 @@ gkyl_bc_twistshift_inew(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); @@ -1745,9 +1745,9 @@ gkyl_bc_twistshift_inew(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. @@ -1766,9 +1766,9 @@ gkyl_bc_twistshift_inew(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. @@ -1828,7 +1828,7 @@ gkyl_bc_twistshift_inew(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 @@ -1900,8 +1900,8 @@ gkyl_bc_twistshift_inew(const struct gkyl_bc_twistshift_inp *inp) struct gkyl_bc_twistshift* gkyl_bc_twistshift_new(int bc_dir, int shift_dir, int shear_dir, - enum gkyl_edge_loc edge, int cdim, struct gkyl_range bcdir_ext_update_r, const int *num_ghost, - struct gkyl_basis basis, struct gkyl_rect_grid grid, evalf_t shift_func, void *shift_func_ctx, + 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 = { diff --git a/gyrokinetic/zero/gkyl_bc_twistshift.h b/gyrokinetic/zero/gkyl_bc_twistshift.h index 4491c9fb24..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. @@ -56,8 +56,8 @@ struct gkyl_bc_twistshift* gkyl_bc_twistshift_inew(const struct gkyl_bc_twistshi * @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, struct gkyl_range bcdir_ext_update_r, const int *num_ghost, - struct gkyl_basis basis, struct gkyl_rect_grid grid, evalf_t shift_func, void *shift_func_ctx, + 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); /** From 4ebcbc886f96f61fc2188c78b94c6041148e31e0 Mon Sep 17 00:00:00 2001 From: Manaure Francisquez Date: Tue, 4 Aug 2026 15:56:29 -0700 Subject: [PATCH 15/19] Increase resolution in d3d_iwl and tcv_iwl tests so they run (they can't run at too low a res because of constraints on TS BCs. Increase tolerance in unit test to 1e-8 so it passes on Perlmutter. --- gyrokinetic/creg/rt_gk_d3d_iwl_3x2v_p1.c | 2 +- gyrokinetic/creg/rt_gk_tcv_iwl_adapt_source_3x2v_p1.c | 2 +- gyrokinetic/unit/ctest_bc_twistshift.c | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gyrokinetic/creg/rt_gk_d3d_iwl_3x2v_p1.c b/gyrokinetic/creg/rt_gk_d3d_iwl_3x2v_p1.c index 5ac1995229..84856f4112 100644 --- a/gyrokinetic/creg/rt_gk_d3d_iwl_3x2v_p1.c +++ b/gyrokinetic/creg/rt_gk_d3d_iwl_3x2v_p1.c @@ -538,7 +538,7 @@ create_ctx(void) double floor_src = 1e-2; // Grid parameters - int Nx = 8; + int Nx = 32; int Ny = 4; int Nz = 8; int Nvpar = 8; 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 2258320a44..98471eaa2d 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 @@ -439,7 +439,7 @@ 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 Nx = 9; // (24) The LCFS is positionned at 1/3 of the domain -> the resolution must be divisible by 3. + 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) diff --git a/gyrokinetic/unit/ctest_bc_twistshift.c b/gyrokinetic/unit/ctest_bc_twistshift.c index a0aa50d7b8..7e5e55f5a6 100644 --- a/gyrokinetic/unit/ctest_bc_twistshift.c +++ b/gyrokinetic/unit/ctest_bc_twistshift.c @@ -3651,7 +3651,8 @@ test_bc_twistshift_3x_cbc_wcells(const int *cells, enum gkyl_edge_loc edge, double *f_c = gkyl_array_fetch(distf_ho, linidx); int refidx = iter.idx[1]-1; for (int k=0; k Date: Tue, 4 Aug 2026 15:58:42 -0700 Subject: [PATCH 16/19] Increase another tolerance to 1e-9 in TS BC unit test so it passes on Perlmutter CPU. --- gyrokinetic/unit/ctest_bc_twistshift.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gyrokinetic/unit/ctest_bc_twistshift.c b/gyrokinetic/unit/ctest_bc_twistshift.c index 7e5e55f5a6..707d48c149 100644 --- a/gyrokinetic/unit/ctest_bc_twistshift.c +++ b/gyrokinetic/unit/ctest_bc_twistshift.c @@ -3651,7 +3651,7 @@ test_bc_twistshift_3x_cbc_wcells(const int *cells, enum gkyl_edge_loc edge, double *f_c = gkyl_array_fetch(distf_ho, linidx); int refidx = iter.idx[1]-1; for (int k=0; k Date: Tue, 4 Aug 2026 17:10:06 -0700 Subject: [PATCH 17/19] Fix mem leak in GK app where an array was not released at program's end. --- gyrokinetic/apps/gyrokinetic.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gyrokinetic/apps/gyrokinetic.c b/gyrokinetic/apps/gyrokinetic.c index 61e4203ec2..9d0298ed50 100644 --- a/gyrokinetic/apps/gyrokinetic.c +++ b/gyrokinetic/apps/gyrokinetic.c @@ -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); From 520e8b7c6a31f7d0b927d2c1760b27d27367e21b Mon Sep 17 00:00:00 2001 From: Manaure Francisquez Date: Tue, 4 Aug 2026 17:12:01 -0700 Subject: [PATCH 18/19] Update perlmutter CPU machine files to remove all possibility of GPU compilers/libraries being used/linked. --- machines/configure.perlmutter.cpu.sh | 7 ++++++- machines/mkdeps.perlmutter.cpu.sh | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) 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}" From 2e9eba02e67c98f4050e9b56eb19ccb37010f9fe Mon Sep 17 00:00:00 2001 From: Manaure Francisquez Date: Tue, 4 Aug 2026 17:18:17 -0700 Subject: [PATCH 19/19] Reduce Nmu in TCV iwl test to reduce runtime. --- gyrokinetic/creg/rt_gk_tcv_iwl_adapt_source_3x2v_p1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 98471eaa2d..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 @@ -443,7 +443,7 @@ struct gk_app_ctx create_ctx(void) int Ny = 4; // (16) int Nz = 8; // (12) int Nvpar = 8; // (12) - int Nmu = 8; // (8) + int Nmu = 4; // (8) int poly_order = 1; // Velocity box dimensions double vpar_max_elc = 5.*vte;