Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 50 additions & 35 deletions core/zero/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,46 +514,61 @@ gkyl_msgpack_create_union(int numlist_union, int *nvals_union, const struct gkyl
mpack_writer_t writer;
mpack_writer_init_growable(&writer, &mdata->meta, &mdata->meta_sz);

mpack_build_map(&writer);
int nvals_tot = 0;
for (int j=0; j<numlist_union; ++j)
nvals_tot += nvals_union[j];

for (int j=0; j<numlist_union; ++j) {
const struct gkyl_msgpack_map_elem *flat[nvals_tot];
int fidx = 0;
for (int j=0; j<numlist_union; ++j)
for (int i=0; i<nvals_union[j]; ++i)
flat[fidx++] = &elist_union[j][i];

int nvals = nvals_union[j];
const struct gkyl_msgpack_map_elem *elist = elist_union[j];
mpack_build_map(&writer);

for (int i=0; i<nvals; ++i) {
mpack_write_cstr(&writer, elist[i].key);

switch (elist[i].elem_type) {
case GKYL_MP_BOOL:
mpack_write_bool(&writer, elist[i].bval);
break;

case GKYL_MP_UNSIGNED_INT:
mpack_write_u64(&writer, elist[i].uval);
break;

case GKYL_MP_INT:
mpack_write_i64(&writer, elist[i].ival);
break;

case GKYL_MP_FLOAT:
mpack_write_float(&writer, elist[i].fval);
break;

case GKYL_MP_DOUBLE:
mpack_write_double(&writer, elist[i].dval);
break;

case GKYL_MP_STRING:
mpack_write_cstr(&writer, elist[i].cval);
break;

default:
assert(false); // NYI.
break;
for (int k=0; k<nvals_tot; ++k) {
bool overridden = false;
for (int m=k+1; m<nvals_tot; ++m) {
if (strcmp(flat[k]->key, flat[m]->key) == 0) {
overridden = true;
break;
}
}
if (overridden)
continue;

const struct gkyl_msgpack_map_elem *elem = flat[k];
mpack_write_cstr(&writer, elem->key);

switch (elem->elem_type) {
case GKYL_MP_BOOL:
mpack_write_bool(&writer, elem->bval);
break;

case GKYL_MP_UNSIGNED_INT:
mpack_write_u64(&writer, elem->uval);
break;

case GKYL_MP_INT:
mpack_write_i64(&writer, elem->ival);
break;

case GKYL_MP_FLOAT:
mpack_write_float(&writer, elem->fval);
break;

case GKYL_MP_DOUBLE:
mpack_write_double(&writer, elem->dval);
break;

case GKYL_MP_STRING:
mpack_write_cstr(&writer, elem->cval);
break;

default:
assert(false); // NYI.
break;
}
}

mpack_complete_map(&writer);
Expand Down
4 changes: 2 additions & 2 deletions gyrokinetic/creg/rt_gk_wham_1xIC_2x2v_p1.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ int main(int argc, char **argv)
.init_from_file = {
.type = GKYL_IC_IMPORT_F,
.file_name = "gk_wham_1x2v_p1-elc_0.gkyl",
// .jacobtot_inv_file_name = "gk_wham_1x2v_p1-jacobtot_inv.gkyl",
.jacobtot_inv_file_name = "gk_wham_1x2v_p1-geo_int_jacobtot_inv.gkyl",
},

.mapc2p = {
Expand Down Expand Up @@ -887,7 +887,7 @@ int main(int argc, char **argv)
.init_from_file = {
.type = GKYL_IC_IMPORT_F,
.file_name = "gk_wham_1x2v_p1-ion_0.gkyl",
.jacobtot_inv_file_name = "gk_wham_1x2v_p1-jacobtot_inv.gkyl",
.jacobtot_inv_file_name = "gk_wham_1x2v_p1-geo_int_jacobtot_inv.gkyl",
},

.scale_with_polarization = true,
Expand Down
Loading