Lines Matching refs:grid

93 PetscErrorCode LandauKokkosCreateMatMaps(P4estVertexMaps maps[], pointInterpolationP4est (*pointMaps)[LANDAU_MAX_Q_FACE], PetscInt Nf[], PetscInt grid)
96 const Kokkos::View<pointInterpolationP4est *[LANDAU_MAX_Q_FACE], Kokkos::LayoutRight, Kokkos::HostSpace, Kokkos::MemoryTraits<Kokkos::Unmanaged>> h_points((pointInterpolationP4est *)pointMaps, maps[grid].num_reduced);
97 const Kokkos::View<LandauIdx *[LANDAU_MAX_SPECIES][LANDAU_MAX_NQND], Kokkos::LayoutRight, Kokkos::HostSpace, Kokkos::MemoryTraits<Kokkos::Unmanaged>> h_gidx((LandauIdx *)maps[grid].gIdx, maps[grid].num_elements);
98 Kokkos::View<pointInterpolationP4est *[LANDAU_MAX_Q_FACE], Kokkos::LayoutRight> *d_points = new Kokkos::View<pointInterpolationP4est *[LANDAU_MAX_Q_FACE], Kokkos::LayoutRight>("points", maps[grid].num_reduced);
99 Kokkos::View<LandauIdx *[LANDAU_MAX_SPECIES][LANDAU_MAX_NQND], Kokkos::LayoutRight> *d_gidx = new Kokkos::View<LandauIdx *[LANDAU_MAX_SPECIES][LANDAU_MAX_NQND], Kokkos::LayoutRight>("gIdx", maps[grid].num_elements);
104 h_maps.num_elements = maps[grid].num_elements;
105 h_maps.num_face = maps[grid].num_face;
106 h_maps.num_reduced = maps[grid].num_reduced;
107 h_maps.deviceType = maps[grid].deviceType;
108 h_maps.numgrids = maps[grid].numgrids;
109 h_maps.Nf = Nf[grid];
111 maps[grid].vp1 = (void *)d_points;
113 maps[grid].vp2 = (void *)d_gidx;
118 maps[grid].d_self = d_maps_k->data();
119 maps[grid].vp3 = (void *)d_maps_k;
126 for (PetscInt grid = 0; grid < num_grids; grid++) {
127 auto a = static_cast<Kokkos::View<pointInterpolationP4est *[LANDAU_MAX_Q_FACE], Kokkos::LayoutRight> *>(maps[grid].vp1);
128 auto b = static_cast<Kokkos::View<LandauIdx *[LANDAU_MAX_SPECIES][LANDAU_MAX_NQND], Kokkos::LayoutRight> *>(maps[grid].vp2);
129 auto c = static_cast<Kokkos::View<P4estVertexMaps *> *>(maps[grid].vp3);
155 for (PetscInt grid = 0; grid < num_grids; grid++) {
156 PetscInt nfloc = a_species_offset[grid + 1] - a_species_offset[grid];
157 elem_offset[grid + 1] = elem_offset[grid] + a_numCells[grid];
158 nip += a_numCells[grid] * Nq;
159 ip_offset[grid + 1] = nip;
160 IPf_sz += Nq * nfloc * a_numCells[grid];
161 ipf_offset[grid + 1] = IPf_sz;
418 // grid offsets - single vertex grid data
460 for (PetscInt grid = 0; grid < num_grids; grid++) {
461 PetscCheck(h_maps[grid].d_self, PETSC_COMM_SELF, PETSC_ERR_PLIB, "GPU assembly but no metadata in container");
462 maps[grid] = h_maps[grid].d_self;
463 nfaces = h_maps[grid].num_face; // nface=0 for CPU assembly
467 for (PetscInt grid = 0; grid < num_grids; grid++) maps[grid] = NULL;
472 for (PetscInt grid = 0; grid < num_grids; grid++) {
473 int Nfloc = a_species_offset[grid + 1] - a_species_offset[grid];
475 if (a_numCells[grid] > num_cells_max) num_cells_max = a_numCells[grid];
476 num_cells_batch += a_numCells[grid]; // we don't have a host element offset here (but in ctx)
495 for (PetscInt grid = 0; grid < num_grids; grid++) {
496 PetscInt nfloc = a_species_offset[grid + 1] - a_species_offset[grid];
497 closure_sz += Nb * nfloc * a_numCells[grid];
516 // find my grid
517 PetscInt grid = 0;
518 while (b_elem_idx >= d_elem_offset[grid + 1]) grid++;
520 const PetscInt loc_nip = d_numCells[grid] * Nq, loc_Nf = d_species_offset[grid + 1] - d_species_offset[grid], loc_elem = b_elem_idx - d_elem_offset[grid];
521 const PetscInt moffset = LAND_MOFFSET(b_id, grid, batch_sz, num_grids, d_mat_offset);
525 const PetscReal *invJe = &d_invJ_k((d_ip_offset[grid] + loc_elem * Nq) * dim * dim);
527 if (!maps[grid]) {
528 coef = &d_vertex_f[b_id * IPf_sz_glb + d_ipf_offset[grid] + loc_elem * Nb * loc_Nf]; // closure and IP indexing are the same
535 LandauIdx idx = maps[grid]->gIdx[loc_elem][f][b];
541 for (int q = 0; q < maps[grid]->num_face; q++) {
542 PetscInt id = maps[grid]->c_maps[idx][q].gid;
543 PetscScalar scale = maps[grid]->c_maps[idx][q].scale;
557 const PetscInt idx = d_ipf_offset[grid] + f * loc_nip + loc_elem * Nq + myQi;
571 } // 'grid' scope
588 // find my grid
589 PetscInt grid = 0;
590 while (b_elem_idx >= d_elem_offset[grid + 1]) grid++;
592 const PetscInt loc_Nf = d_species_offset[grid + 1] - d_species_offset[grid], loc_elem = b_elem_idx - d_elem_offset[grid];
593 const PetscInt moffset = LAND_MOFFSET(b_id, grid, batch_sz, num_grids, d_mat_offset);
594 const PetscInt f_off = d_species_offset[grid];
605 const PetscInt jpidx_glb = d_ip_offset[grid] + loc_elem * Nq + myQi;
623 while (ipidx >= d_ip_offset[grid_r + 1]) grid_r++; // yuck search for grid
628 for (fieldB = 0; fieldB < loc_Nf_r; ++fieldB) { // fieldB is \beta d_lambdas[grid][grid_r]
630 const PetscReal ff1 = d_beta[fieldB + f_off_r] * d_lambdas[LANDAU_MAX_GRIDS * grid + grid_r], ff2 = d_invMass[fieldB + f_off_r] * ff1;
709 d_elem_mats(b_id, grid, loc_elem, fOff) = t;
712 static_cast<void>(landau_mat_assemble(d_coo_vals, t, f, g, Nb, moffset, loc_elem, fieldA, maps[grid], d_coo_elem_offsets, d_coo_elem_fullNb, d_coo_elem_point_offsets, b_elem_idx, b_id * coo_sz_batch));
718 } // scope with 'grid'
740 // find my grid
741 PetscInt grid = 0;
742 while (b_elem_idx >= d_elem_offset[grid + 1]) grid++;
744 const PetscInt loc_Nf = d_species_offset[grid + 1] - d_species_offset[grid], loc_elem = b_elem_idx - d_elem_offset[grid], jpidx_0 = d_ip_offset[grid] + loc_elem * Nq;
748 const PetscInt moffset = LAND_MOFFSET(b_id, grid, batch_sz, num_grids, d_mat_offset);
766 d_elem_mats(b_id, grid, loc_elem, fOff) = t;
769 static_cast<void>(landau_mat_assemble(d_coo_vals, t, f, g, Nb, moffset, loc_elem, fieldA, maps[grid], d_coo_elem_offsets, d_coo_elem_fullNb, d_coo_elem_point_offsets, b_elem_idx, b_id * coo_sz_batch));
774 } // grid
791 for (PetscInt grid = 0; grid < num_grids; grid++) {
794 Mat B = subJ[LAND_PACK_IDX(b_id, grid)];
795 PetscInt moffset = LAND_MOFFSET(b_id, grid, batch_sz, num_grids, a_mat_offset), nloc, nzl, colbuf[1024], row;
799 PetscCall(DMPlexGetHeightStratum(plex[grid], 0, &cStart, &cEnd));
800 PetscCall(DMGetLocalSection(plex[grid], &section));
801 PetscCall(DMGetGlobalSection(plex[grid], &globalSection));
805 const PetscScalar *elMat = &h_elem_mats(b_id, grid, ej - cStart, 0);
806 PetscCall(DMPlexMatSetClosure(plex[grid], section, globalSection, B, ej, elMat, ADD_VALUES));
807 if (grid == 0 && ej == -1) {
808 const PetscInt loc_Nf = a_species_offset[grid + 1] - a_species_offset[grid], totDim = loc_Nf * Nb;
810 PetscPrintf(PETSC_COMM_SELF, "Kokkos Element matrix %d/%d\n", 1, (int)a_numCells[grid]);
830 PetscCall(MatDestroy(&subJ[LAND_PACK_IDX(b_id, grid)]));