197 Build3D(
const int numDimensions,
198 Teuchos::Array<LocalOrdinal>& lFineNodesPerDim,
199 const RCP<Matrix>& A,
203 Teuchos::Array<LocalOrdinal>& lCoarseNodesPerDim)
const {
204 using local_matrix_type =
typename CrsMatrix::local_matrix_type;
205 using local_graph_type =
typename local_matrix_type::staticcrsgraph_type;
206 using row_map_type =
typename local_matrix_type::row_map_type::non_const_type;
207 using entries_type =
typename local_matrix_type::index_type::non_const_type;
208 using values_type =
typename local_matrix_type::values_type::non_const_type;
209 using impl_scalar_type =
typename Kokkos::ArithTraits<Scalar>::val_type;
212 RCP<Teuchos::FancyOStream> out;
213 if(
const char* dbg = std::getenv(
"MUELU_REGIONRFACTORY_DEBUG")) {
214 out = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout));
215 out->setShowAllFrontMatter(
false).setShowProcRank(
true);
217 out = Teuchos::getFancyOStream(rcp(
new Teuchos::oblackholestream()));
221 for(
int dim = 0; dim < numDimensions; ++dim) {
222 lCoarseNodesPerDim[dim] = lFineNodesPerDim[dim] / 3 + 1;
224 *out <<
"lCoarseNodesPerDim " << lCoarseNodesPerDim << std::endl;
227 const LO blkSize = A->GetFixedBlockSize();
228 *out <<
"blkSize " << blkSize << std::endl;
232 const LO numRows = blkSize*lCoarseNodesPerDim[0]*lCoarseNodesPerDim[1]*lCoarseNodesPerDim[2];
233 const LO numCols = blkSize*lFineNodesPerDim[0]*lFineNodesPerDim[1]*lFineNodesPerDim[2];
238 RCP<Map> rowMap = MapFactory::Build(A->getRowMap()->lib(),
239 Teuchos::OrdinalTraits<GO>::invalid(),
241 A->getRowMap()->getIndexBase(),
242 A->getRowMap()->getComm());
244 RCP<Map> coordRowMap = MapFactory::Build(A->getRowMap()->lib(),
245 Teuchos::OrdinalTraits<GO>::invalid(),
246 lCoarseNodesPerDim[0]*lCoarseNodesPerDim[1]*lCoarseNodesPerDim[2],
247 A->getRowMap()->getIndexBase(),
248 A->getRowMap()->getComm());
250 coarseCoordinates = Xpetra::MultiVectorFactory<real_type, LO, GO, NO>::Build(coordRowMap,
254 auto fineCoordsView = fineCoordinates ->getDeviceLocalView(Xpetra::Access::ReadOnly);
255 auto coarseCoordsView = coarseCoordinates->getDeviceLocalView(Xpetra::Access::OverwriteAll);
258 Array<ArrayRCP<const real_type> > fineCoordData(numDimensions);
259 Array<ArrayRCP<real_type> > coarseCoordData(numDimensions);
260 for(
int dim = 0; dim < numDimensions; ++dim) {
261 fineCoordData[dim] = fineCoordinates->getData(dim);
262 coarseCoordData[dim] = coarseCoordinates->getDataNonConst(dim);
269 const LO cornerStencilLength = 27;
270 const LO edgeStencilLength = 45;
271 const LO faceStencilLength = 75;
272 const LO interiorStencilLength = 125;
275 const LO numCorners = 8;
276 const LO numEdges = 4*(lCoarseNodesPerDim[0] - 2)
277 + 4*(lCoarseNodesPerDim[1] - 2)
278 + 4*(lCoarseNodesPerDim[2] - 2);
279 const LO numFaces = 2*(lCoarseNodesPerDim[0] - 2)*(lCoarseNodesPerDim[1] - 2)
280 + 2*(lCoarseNodesPerDim[0] - 2)*(lCoarseNodesPerDim[2] - 2)
281 + 2*(lCoarseNodesPerDim[1] - 2)*(lCoarseNodesPerDim[2] - 2);
282 const LO numInteriors = (lCoarseNodesPerDim[0] - 2)*(lCoarseNodesPerDim[1] - 2)
283 *(lCoarseNodesPerDim[2] - 2);
285 const LO nnz = (numCorners*cornerStencilLength + numEdges*edgeStencilLength
286 + numFaces*faceStencilLength + numInteriors*interiorStencilLength)*blkSize;
291 *out <<
"R statistics:" << std::endl
292 <<
" -numRows= " << numRows << std::endl
293 <<
" -numCols= " << numCols << std::endl
294 <<
" -nnz= " << nnz << std::endl;
296 row_map_type row_map(Kokkos::ViewAllocateWithoutInitializing(
"row_map"), numRows + 1);
297 typename row_map_type::HostMirror row_map_h = Kokkos::create_mirror_view(row_map);
299 entries_type entries(Kokkos::ViewAllocateWithoutInitializing(
"entries"), nnz);
300 typename entries_type::HostMirror entries_h = Kokkos::create_mirror_view(entries);
302 values_type values(Kokkos::ViewAllocateWithoutInitializing(
"values"), nnz);
303 typename values_type::HostMirror values_h = Kokkos::create_mirror_view(values);
308 Array<SC> coeffs({1.0/3.0, 2.0/3.0, 1.0, 2.0/3.0, 1.0/3.0});
313 const LO edgeLineOffset = 2*cornerStencilLength + (lCoarseNodesPerDim[0] - 2)*edgeStencilLength;
314 const LO faceLineOffset = 2*edgeStencilLength + (lCoarseNodesPerDim[0] - 2)*faceStencilLength;
315 const LO interiorLineOffset = 2*faceStencilLength
316 + (lCoarseNodesPerDim[0] - 2)*interiorStencilLength;
318 const LO facePlaneOffset = 2*edgeLineOffset + (lCoarseNodesPerDim[1] - 2)*faceLineOffset;
319 const LO interiorPlaneOffset = 2*faceLineOffset + (lCoarseNodesPerDim[1] - 2)*interiorLineOffset;
326 LO coordRowIdx = 0, rowIdx = 0, coordColumnOffset = 0, columnOffset = 0, entryOffset = 0;
327 for(LO l = 0; l < blkSize; ++l) {
328 for(LO k = 0; k < 3; ++k) {
329 for(LO j = 0; j < 3; ++j) {
330 for(LO i = 0; i < 3; ++i) {
331 entries_h(entryOffset + k*9 + j*3 + i + cornerStencilLength*l) = columnOffset
332 + (k*lFineNodesPerDim[1]*lFineNodesPerDim[0] + j*lFineNodesPerDim[0] + i)*blkSize + l;
333 values_h(entryOffset + k*9 + j*3 + i + cornerStencilLength*l) = coeffs[k + 2]*coeffs[j + 2]*coeffs[i + 2];
338 for(LO l = 0; l < blkSize; ++l) {
339 row_map_h(rowIdx + 1 + l) = entryOffset + cornerStencilLength*(l+1);
341 for(
int dim = 0; dim <numDimensions; ++dim) {
342 coarseCoordData[dim][coordRowIdx] = fineCoordData[dim][coordColumnOffset];
346 coordRowIdx += (lCoarseNodesPerDim[2] - 1)*lCoarseNodesPerDim[1]*lCoarseNodesPerDim[0];
347 rowIdx = coordRowIdx*blkSize;
348 coordColumnOffset += (lFineNodesPerDim[2] - 1)*lFineNodesPerDim[1]*lFineNodesPerDim[0];
349 columnOffset = coordColumnOffset*blkSize;
350 entryOffset += (facePlaneOffset + (lCoarseNodesPerDim[2] - 2)*interiorPlaneOffset)*blkSize;
351 for(LO l = 0; l < blkSize; ++l) {
352 for(LO k = 0; k < 3; ++k) {
353 for(LO j = 0; j < 3; ++j) {
354 for(LO i = 0; i < 3; ++i) {
355 entries_h(entryOffset + k*9 + j*3 + i + cornerStencilLength*l) = columnOffset
356 + ((k - 2)*lFineNodesPerDim[1]*lFineNodesPerDim[0] + j*lFineNodesPerDim[0] + i)*blkSize + l;
357 values_h(entryOffset + k*9 + j*3 + i + cornerStencilLength*l) = coeffs[k]*coeffs[j + 2]*coeffs[i + 2];
362 for(LO l = 0; l < blkSize; ++l) {
363 row_map_h(rowIdx + 1 + l) = entryOffset + cornerStencilLength*(l+1);
365 for(
int dim = 0; dim <numDimensions; ++dim) {
366 coarseCoordData[dim][coordRowIdx] = fineCoordData[dim][coordColumnOffset];
370 coordRowIdx = (lCoarseNodesPerDim[0] - 1);
371 rowIdx = coordRowIdx*blkSize;
372 coordColumnOffset = (lFineNodesPerDim[0] - 1);
373 columnOffset = coordColumnOffset*blkSize;
374 entryOffset = (cornerStencilLength + (lCoarseNodesPerDim[0] - 2)*edgeStencilLength)*blkSize;
375 for(LO l = 0; l < blkSize; ++l) {
376 for(LO k = 0; k < 3; ++k) {
377 for(LO j = 0; j < 3; ++j) {
378 for(LO i = 0; i < 3; ++i) {
379 entries_h(entryOffset + k*9 + j*3 + i + cornerStencilLength*l) = columnOffset
380 + (k*lFineNodesPerDim[1]*lFineNodesPerDim[0]
381 + j*lFineNodesPerDim[0] + (i - 2))*blkSize + l;
382 values_h(entryOffset + k*9 + j*3 + i + cornerStencilLength*l) = coeffs[k + 2]*coeffs[j + 2]*coeffs[i];
387 for(LO l = 0; l < blkSize; ++l) {
388 row_map_h(rowIdx + 1 + l) = entryOffset + cornerStencilLength*(l+1);
390 for(
int dim = 0; dim <numDimensions; ++dim) {
391 coarseCoordData[dim][coordRowIdx] = fineCoordData[dim][coordColumnOffset];
395 coordRowIdx += (lCoarseNodesPerDim[2] - 1)*lCoarseNodesPerDim[1]*lCoarseNodesPerDim[0];
396 rowIdx = coordRowIdx*blkSize;
397 coordColumnOffset += (lFineNodesPerDim[2] - 1)*lFineNodesPerDim[1]*lFineNodesPerDim[0];
398 columnOffset = coordColumnOffset*blkSize;
399 entryOffset += (facePlaneOffset + (lCoarseNodesPerDim[2] - 2)*interiorPlaneOffset)*blkSize;
400 for(LO l = 0; l < blkSize; ++l) {
401 for(LO k = 0; k < 3; ++k) {
402 for(LO j = 0; j < 3; ++j) {
403 for(LO i = 0; i < 3; ++i) {
404 entries_h(entryOffset + k*9 + j*3 + i + cornerStencilLength*l) = columnOffset
405 + ((k - 2)*lFineNodesPerDim[1]*lFineNodesPerDim[0] + j*lFineNodesPerDim[0] + i - 2)*blkSize + l;
406 values_h(entryOffset + k*9 + j*3 + i + cornerStencilLength*l) = coeffs[k]*coeffs[j + 2]*coeffs[i];
411 for(LO l = 0; l < blkSize; ++l) {
412 row_map_h(rowIdx + 1 + l) = entryOffset + cornerStencilLength*(l+1);
414 for(
int dim = 0; dim <numDimensions; ++dim) {
415 coarseCoordData[dim][coordRowIdx] = fineCoordData[dim][coordColumnOffset];
419 coordRowIdx = (lCoarseNodesPerDim[1] - 1)*lCoarseNodesPerDim[0];
420 rowIdx = coordRowIdx*blkSize;
421 coordColumnOffset = (lFineNodesPerDim[1] - 1)*lFineNodesPerDim[0];
422 columnOffset = coordColumnOffset*blkSize;
423 entryOffset = (edgeLineOffset + (lCoarseNodesPerDim[1] - 2)*faceLineOffset)*blkSize;
424 for(LO l = 0; l < blkSize; ++l) {
425 for(LO k = 0; k < 3; ++k) {
426 for(LO j = 0; j < 3; ++j) {
427 for(LO i = 0; i < 3; ++i) {
428 entries_h(entryOffset + k*9 + j*3 + i + cornerStencilLength*l) = columnOffset
429 + (k*lFineNodesPerDim[1]*lFineNodesPerDim[0]
430 + (j - 2)*lFineNodesPerDim[0] + i)*blkSize + l;
431 values_h(entryOffset + k*9 + j*3 + i + cornerStencilLength*l) = coeffs[k + 2]*coeffs[j]*coeffs[i + 2];
436 for(LO l = 0; l < blkSize; ++l) {
437 row_map_h(rowIdx + 1 + l) = entryOffset + cornerStencilLength*(l+1);
439 for(
int dim = 0; dim <numDimensions; ++dim) {
440 coarseCoordData[dim][coordRowIdx] = fineCoordData[dim][coordColumnOffset];
444 coordRowIdx += (lCoarseNodesPerDim[2] - 1)*lCoarseNodesPerDim[1]*lCoarseNodesPerDim[0];
445 rowIdx = coordRowIdx*blkSize;
446 coordColumnOffset += (lFineNodesPerDim[2] - 1)*lFineNodesPerDim[1]*lFineNodesPerDim[0];
447 columnOffset = coordColumnOffset*blkSize;
448 entryOffset += (facePlaneOffset + (lCoarseNodesPerDim[2] - 2)*interiorPlaneOffset)*blkSize;
449 for(LO l = 0; l < blkSize; ++l) {
450 for(LO k = 0; k < 3; ++k) {
451 for(LO j = 0; j < 3; ++j) {
452 for(LO i = 0; i < 3; ++i) {
453 entries_h(entryOffset + k*9 + j*3 + i + cornerStencilLength*l) = columnOffset
454 + ((k - 2)*lFineNodesPerDim[1]*lFineNodesPerDim[0] + (j - 2)*lFineNodesPerDim[0] + i)*blkSize + l;
455 values_h(entryOffset + k*9 + j*3 + i + cornerStencilLength*l) = coeffs[k]*coeffs[j]*coeffs[i + 2];
460 for(LO l = 0; l < blkSize; ++l) {
461 row_map_h(rowIdx + 1 + l) = entryOffset + cornerStencilLength*(l+1);
463 for(
int dim = 0; dim <numDimensions; ++dim) {
464 coarseCoordData[dim][coordRowIdx] = fineCoordData[dim][coordColumnOffset];
468 coordRowIdx = (lCoarseNodesPerDim[1]*lCoarseNodesPerDim[0] - 1);
469 rowIdx = coordRowIdx*blkSize;
470 coordColumnOffset = (lFineNodesPerDim[1]*lFineNodesPerDim[0] - 1);
471 columnOffset = coordColumnOffset*blkSize;
472 entryOffset = (edgeLineOffset + (lCoarseNodesPerDim[1] - 2)*faceLineOffset +
473 cornerStencilLength + (lCoarseNodesPerDim[0] - 2)*edgeStencilLength)*blkSize;
474 for(LO l = 0; l < blkSize; ++l) {
475 for(LO k = 0; k < 3; ++k) {
476 for(LO j = 0; j < 3; ++j) {
477 for(LO i = 0; i < 3; ++i) {
478 entries_h(entryOffset + k*9 + j*3 + i + cornerStencilLength*l) = columnOffset
479 + (k*lFineNodesPerDim[1]*lFineNodesPerDim[0]
480 + (j - 2)*lFineNodesPerDim[0] + (i - 2))*blkSize + l;
481 values_h(entryOffset + k*9 + j*3 + i + cornerStencilLength*l) = coeffs[k + 2]*coeffs[j]*coeffs[i];
486 for(LO l = 0; l < blkSize; ++l) {
487 row_map_h(rowIdx + 1 + l) = entryOffset + cornerStencilLength*(l+1);
489 for(
int dim = 0; dim <numDimensions; ++dim) {
490 coarseCoordData[dim][coordRowIdx] = fineCoordData[dim][coordColumnOffset];
494 coordRowIdx += (lCoarseNodesPerDim[2] - 1)*lCoarseNodesPerDim[1]*lCoarseNodesPerDim[0];
495 rowIdx = coordRowIdx*blkSize;
496 coordColumnOffset += (lFineNodesPerDim[2] - 1)*lFineNodesPerDim[1]*lFineNodesPerDim[0];
497 columnOffset = coordColumnOffset*blkSize;
498 entryOffset += (facePlaneOffset + (lCoarseNodesPerDim[2] - 2)*interiorPlaneOffset)*blkSize;
499 for(LO l = 0; l < blkSize; ++l) {
500 for(LO k = 0; k < 3; ++k) {
501 for(LO j = 0; j < 3; ++j) {
502 for(LO i = 0; i < 3; ++i) {
503 entries_h(entryOffset + k*9 + j*3 + i + cornerStencilLength*l) = columnOffset
504 + ((k - 2)*lFineNodesPerDim[1]*lFineNodesPerDim[0] + (j - 2)*lFineNodesPerDim[0] + (i - 2))*blkSize + l;
505 values_h(entryOffset + k*9 + j*3 + i + cornerStencilLength*l) = coeffs[k]*coeffs[j]*coeffs[i];
510 for(LO l = 0; l < blkSize; ++l) {
511 row_map_h(rowIdx + 1 + l) = entryOffset + cornerStencilLength*(l+1);
513 for(
int dim = 0; dim <numDimensions; ++dim) {
514 coarseCoordData[dim][coordRowIdx] = fineCoordData[dim][coordColumnOffset];
519 if(lCoarseNodesPerDim[0] - 2 > 0) {
521 LO coordRowIdx, rowIdx, coordColumnOffset, columnOffset, entryOffset;
522 for(LO edgeIdx = 0; edgeIdx < lCoarseNodesPerDim[0] - 2; ++edgeIdx) {
525 coordRowIdx = (edgeIdx + 1);
526 rowIdx = coordRowIdx*blkSize;
527 coordColumnOffset = (edgeIdx + 1)*3;
528 columnOffset = coordColumnOffset*blkSize;
529 entryOffset = (cornerStencilLength + edgeIdx*edgeStencilLength)*blkSize;
530 for(LO l = 0; l < blkSize; ++l) {
531 for(LO k = 0; k < 3; ++k) {
532 for(LO j = 0; j < 3; ++j) {
533 for(LO i = 0; i < 5; ++i) {
534 entries_h(entryOffset + k*15 + j*5 + i + edgeStencilLength*l) = columnOffset
535 + (k*lFineNodesPerDim[1]*lFineNodesPerDim[0] + j*lFineNodesPerDim[0] + i - 2)*blkSize + l;
536 values_h(entryOffset + k*15 + j*5 + i + edgeStencilLength*l) = coeffs[k + 2]*coeffs[j + 2]*coeffs[i];
541 for(LO l = 0; l < blkSize; ++l) {
542 row_map_h(rowIdx + 1 + l) = entryOffset + edgeStencilLength*(l+1);
544 for(
int dim = 0; dim <numDimensions; ++dim) {
545 coarseCoordData[dim][coordRowIdx] = fineCoordData[dim][coordColumnOffset];
549 coordRowIdx = ((lCoarseNodesPerDim[1] - 1)*lCoarseNodesPerDim[0] + edgeIdx + 1);
550 rowIdx = coordRowIdx*blkSize;
551 coordColumnOffset = ((lFineNodesPerDim[1] - 1)*lFineNodesPerDim[0] + (edgeIdx + 1)*3);
552 columnOffset = coordColumnOffset*blkSize;
553 entryOffset = (edgeLineOffset + (lCoarseNodesPerDim[1] - 2)*faceLineOffset
554 + cornerStencilLength + edgeIdx*edgeStencilLength)*blkSize;
555 for(LO l = 0; l < blkSize; ++l) {
556 for(LO k = 0; k < 3; ++k) {
557 for(LO j = 0; j < 3; ++j) {
558 for(LO i = 0; i < 5; ++i) {
559 entries_h(entryOffset + k*15 + j*5 + i + edgeStencilLength*l) = columnOffset
560 + (k*lFineNodesPerDim[1]*lFineNodesPerDim[0] + (j - 2)*lFineNodesPerDim[0] + i - 2)*blkSize + l;
561 values_h(entryOffset + k*15 + j*5 + i + edgeStencilLength*l) = coeffs[k + 2]*coeffs[j]*coeffs[i];
566 for(LO l = 0; l < blkSize; ++l) {
567 row_map_h(rowIdx + 1 + l) = entryOffset + edgeStencilLength*(l+1);
569 for(
int dim = 0; dim <numDimensions; ++dim) {
570 coarseCoordData[dim][coordRowIdx] = fineCoordData[dim][coordColumnOffset];
574 coordRowIdx = ((lCoarseNodesPerDim[2] - 1)*lCoarseNodesPerDim[1]*lCoarseNodesPerDim[0]
576 rowIdx = coordRowIdx*blkSize;
577 coordColumnOffset = ((lFineNodesPerDim[2] - 1)*lFineNodesPerDim[1]*lFineNodesPerDim[0]
579 columnOffset = coordColumnOffset*blkSize;
580 entryOffset = (facePlaneOffset + (lCoarseNodesPerDim[2] - 2)*interiorPlaneOffset
581 + cornerStencilLength + edgeIdx*edgeStencilLength)*blkSize;
582 for(LO l = 0; l < blkSize; ++l) {
583 for(LO k = 0; k < 3; ++k) {
584 for(LO j = 0; j < 3; ++j) {
585 for(LO i = 0; i < 5; ++i) {
586 entries_h(entryOffset + k*15 + j*5 + i + edgeStencilLength*l) = columnOffset
587 + ((k - 2)*lFineNodesPerDim[1]*lFineNodesPerDim[0] + j*lFineNodesPerDim[0] + i - 2)*blkSize + l;
588 values_h(entryOffset + k*15 + j*5 + i + edgeStencilLength*l) = coeffs[k]*coeffs[j + 2]*coeffs[i];
593 for(LO l = 0; l < blkSize; ++l) {
594 row_map_h(rowIdx + 1 + l) = entryOffset + edgeStencilLength*(l+1);
596 for(
int dim = 0; dim <numDimensions; ++dim) {
597 coarseCoordData[dim][coordRowIdx] = fineCoordData[dim][coordColumnOffset];
601 coordRowIdx = ((lCoarseNodesPerDim[2] - 1)*lCoarseNodesPerDim[1]*lCoarseNodesPerDim[0]
602 + (lCoarseNodesPerDim[1] - 1)*lCoarseNodesPerDim[0] + edgeIdx + 1);
603 rowIdx = coordRowIdx*blkSize;
604 coordColumnOffset = ((lFineNodesPerDim[2] - 1)*lFineNodesPerDim[1]*lFineNodesPerDim[0]
605 + (lFineNodesPerDim[1] - 1)*lFineNodesPerDim[0] + (edgeIdx + 1)*3);
606 columnOffset = coordColumnOffset*blkSize;
607 entryOffset = (facePlaneOffset + (lCoarseNodesPerDim[2] - 2)*interiorPlaneOffset
608 + edgeLineOffset + (lCoarseNodesPerDim[1] - 2)*faceLineOffset
609 + cornerStencilLength + edgeIdx*edgeStencilLength)*blkSize;
610 for(LO l = 0; l < blkSize; ++l) {
611 for(LO k = 0; k < 3; ++k) {
612 for(LO j = 0; j < 3; ++j) {
613 for(LO i = 0; i < 5; ++i) {
614 entries_h(entryOffset + k*15 + j*5 + i + edgeStencilLength*l) = columnOffset
615 + ((k - 2)*lFineNodesPerDim[1]*lFineNodesPerDim[0]
616 + (j - 2)*lFineNodesPerDim[0] + i - 2)*blkSize + l;
617 values_h(entryOffset + k*15 + j*5 + i + edgeStencilLength*l) = coeffs[k]*coeffs[j]*coeffs[i];
622 for(LO l = 0; l < blkSize; ++l) {
623 row_map_h(rowIdx + 1 + l) = entryOffset + edgeStencilLength*(l+1);
625 for(
int dim = 0; dim <numDimensions; ++dim) {
626 coarseCoordData[dim][coordRowIdx] = fineCoordData[dim][coordColumnOffset];
632 if(lCoarseNodesPerDim[1] - 2 > 0) {
634 LO coordRowIdx, rowIdx, coordColumnOffset, columnOffset, entryOffset;
635 for(LO edgeIdx = 0; edgeIdx < lCoarseNodesPerDim[1] - 2; ++edgeIdx) {
638 coordRowIdx = (edgeIdx + 1)*lCoarseNodesPerDim[0];
639 rowIdx = coordRowIdx*blkSize;
640 coordColumnOffset = (edgeIdx + 1)*3*lFineNodesPerDim[0];
641 columnOffset = coordColumnOffset*blkSize;
642 entryOffset = (edgeLineOffset + edgeIdx*faceLineOffset)*blkSize;
643 for(LO l = 0; l < blkSize; ++l) {
644 for(LO k = 0; k < 3; ++k) {
645 for(LO j = 0; j < 5; ++j) {
646 for(LO i = 0; i < 3; ++i) {
647 entries_h(entryOffset + k*15 + j*3 + i + edgeStencilLength*l) = columnOffset
648 + (k*lFineNodesPerDim[1]*lFineNodesPerDim[0] + (j - 2)*lFineNodesPerDim[0] + i)*blkSize + l;
649 values_h(entryOffset + k*15 + j*3 + i + edgeStencilLength*l) = coeffs[k + 2]*coeffs[j]*coeffs[i + 2];
654 for(LO l = 0; l < blkSize; ++l) {
655 row_map_h(rowIdx + 1 + l) = entryOffset + edgeStencilLength*(l+1);
657 for(
int dim = 0; dim <numDimensions; ++dim) {
658 coarseCoordData[dim][coordRowIdx] = fineCoordData[dim][coordColumnOffset];
662 coordRowIdx = ((edgeIdx + 1)*lCoarseNodesPerDim[0] + lCoarseNodesPerDim[0] - 1);
663 rowIdx = coordRowIdx*blkSize;
664 coordColumnOffset = ((edgeIdx + 1)*3*lFineNodesPerDim[0] + lFineNodesPerDim[0] - 1);
665 columnOffset = coordColumnOffset*blkSize;
666 entryOffset = (edgeLineOffset + edgeIdx*faceLineOffset
667 + edgeStencilLength + (lCoarseNodesPerDim[0] - 2)*faceStencilLength)*blkSize;
668 for(LO l = 0; l < blkSize; ++l) {
669 for(LO k = 0; k < 3; ++k) {
670 for(LO j = 0; j < 5; ++j) {
671 for(LO i = 0; i < 3; ++i) {
672 entries_h(entryOffset + k*15 + j*3 + i + edgeStencilLength*l) = columnOffset
673 + (k*lFineNodesPerDim[1]*lFineNodesPerDim[0] + (j - 2)*lFineNodesPerDim[0] + i - 2)*blkSize + l;
674 values_h(entryOffset + k*15 + j*3 + i + edgeStencilLength*l) = coeffs[k + 2]*coeffs[j]*coeffs[i];
679 for(LO l = 0; l < blkSize; ++l) {
680 row_map_h(rowIdx + 1 + l) = entryOffset + edgeStencilLength*(l+1);
682 for(
int dim = 0; dim <numDimensions; ++dim) {
683 coarseCoordData[dim][coordRowIdx] = fineCoordData[dim][coordColumnOffset];
687 coordRowIdx = ((lCoarseNodesPerDim[2] - 1)*lCoarseNodesPerDim[1]*lCoarseNodesPerDim[0]
688 + (edgeIdx + 1)*lCoarseNodesPerDim[0]);
689 rowIdx = coordRowIdx*blkSize;
690 coordColumnOffset = ((lFineNodesPerDim[2] - 1)*lFineNodesPerDim[1]*lFineNodesPerDim[0]
691 + (edgeIdx + 1)*3*lFineNodesPerDim[0]);
692 columnOffset = coordColumnOffset*blkSize;
693 entryOffset = (facePlaneOffset + (lCoarseNodesPerDim[2] - 2)*interiorPlaneOffset
694 + edgeLineOffset + edgeIdx*faceLineOffset)*blkSize;
695 for(LO l = 0; l < blkSize; ++l) {
696 for(LO k = 0; k < 3; ++k) {
697 for(LO j = 0; j < 5; ++j) {
698 for(LO i = 0; i < 3; ++i) {
699 entries_h(entryOffset + k*15 + j*3 + i + edgeStencilLength*l) = columnOffset
700 + ((k - 2)*lFineNodesPerDim[1]*lFineNodesPerDim[0] + (j - 2)*lFineNodesPerDim[0] + i)*blkSize + l;
701 values_h(entryOffset + k*15 + j*3 + i + edgeStencilLength*l) = coeffs[k]*coeffs[j]*coeffs[i + 2];
706 for(LO l = 0; l < blkSize; ++l) {
707 row_map_h(rowIdx + 1 + l) = entryOffset + edgeStencilLength*(l+1);
709 for(
int dim = 0; dim <numDimensions; ++dim) {
710 coarseCoordData[dim][coordRowIdx] = fineCoordData[dim][coordColumnOffset];
714 coordRowIdx = ((lCoarseNodesPerDim[2] - 1)*lCoarseNodesPerDim[1]*lCoarseNodesPerDim[0]
715 + (edgeIdx + 1)*lCoarseNodesPerDim[0] + lCoarseNodesPerDim[0] - 1);
716 rowIdx = coordRowIdx*blkSize;
717 coordColumnOffset = ((lFineNodesPerDim[2] - 1)*lFineNodesPerDim[1]*lFineNodesPerDim[0]
718 + (edgeIdx + 1)*3*lFineNodesPerDim[0] + lFineNodesPerDim[0] - 1);
719 columnOffset = coordColumnOffset*blkSize;
720 entryOffset = (facePlaneOffset + (lCoarseNodesPerDim[2] - 2)*interiorPlaneOffset
721 + edgeLineOffset + edgeIdx*faceLineOffset
722 + edgeStencilLength + (lCoarseNodesPerDim[0] - 2)*faceStencilLength)*blkSize;
723 for(LO l = 0; l < blkSize; ++l) {
724 for(LO k = 0; k < 3; ++k) {
725 for(LO j = 0; j < 5; ++j) {
726 for(LO i = 0; i < 3; ++i) {
727 entries_h(entryOffset + k*15 + j*3 + i + edgeStencilLength*l) = columnOffset
728 + ((k - 2)*lFineNodesPerDim[1]*lFineNodesPerDim[0]
729 + (j - 2)*lFineNodesPerDim[0] + i - 2)*blkSize + l;
730 values_h(entryOffset + k*15 + j*3 + i + edgeStencilLength*l) = coeffs[k]*coeffs[j]*coeffs[i];
735 for(LO l = 0; l < blkSize; ++l) {
736 row_map_h(rowIdx + 1 + l) = entryOffset + edgeStencilLength*(l+1);
738 for(
int dim = 0; dim <numDimensions; ++dim) {
739 coarseCoordData[dim][coordRowIdx] = fineCoordData[dim][coordColumnOffset];
745 if(lCoarseNodesPerDim[2] - 2 > 0) {
747 LO coordRowIdx, rowIdx, coordColumnOffset, columnOffset, entryOffset;
748 for(LO edgeIdx = 0; edgeIdx < lCoarseNodesPerDim[2] - 2; ++edgeIdx) {
751 coordRowIdx = (edgeIdx + 1)*lCoarseNodesPerDim[1]*lCoarseNodesPerDim[0];
752 rowIdx = coordRowIdx*blkSize;
753 coordColumnOffset = (edgeIdx + 1)*3*lFineNodesPerDim[1]*lFineNodesPerDim[0];
754 columnOffset = coordColumnOffset*blkSize;
755 entryOffset = (facePlaneOffset + edgeIdx*interiorPlaneOffset)*blkSize;
756 for(LO l = 0; l < blkSize; ++l) {
757 for(LO k = 0; k < 5; ++k) {
758 for(LO j = 0; j < 3; ++j) {
759 for(LO i = 0; i < 3; ++i) {
760 entries_h(entryOffset + k*9 + j*3 + i + edgeStencilLength*l) = columnOffset
761 + ((k - 2)*lFineNodesPerDim[1]*lFineNodesPerDim[0] + j*lFineNodesPerDim[0] + i)*blkSize + l;
762 values_h(entryOffset + k*9 + j*3 + i + edgeStencilLength*l) = coeffs[k]*coeffs[j + 2]*coeffs[i + 2];
767 for(LO l = 0; l < blkSize; ++l) {
768 row_map_h(rowIdx + 1 + l) = entryOffset + edgeStencilLength*(l+1);
770 for(
int dim = 0; dim <numDimensions; ++dim) {
771 coarseCoordData[dim][coordRowIdx] = fineCoordData[dim][coordColumnOffset];
775 coordRowIdx = ((edgeIdx + 1)*lCoarseNodesPerDim[1]*lCoarseNodesPerDim[0]
776 + lCoarseNodesPerDim[0] - 1);
777 rowIdx = coordRowIdx*blkSize;
778 coordColumnOffset = ((edgeIdx + 1)*3*lFineNodesPerDim[1]*lFineNodesPerDim[0]
779 + lFineNodesPerDim[0] - 1);
780 columnOffset = coordColumnOffset*blkSize;
781 entryOffset = (facePlaneOffset + faceLineOffset - edgeStencilLength
782 + edgeIdx*interiorPlaneOffset)*blkSize;
783 for(LO l = 0; l < blkSize; ++l) {
784 for(LO k = 0; k < 5; ++k) {
785 for(LO j = 0; j < 3; ++j) {
786 for(LO i = 0; i < 3; ++i) {
787 entries_h(entryOffset + k*9 + j*3 + i + edgeStencilLength*l) = columnOffset
788 + ((k - 2)*lFineNodesPerDim[1]*lFineNodesPerDim[0] + j*lFineNodesPerDim[0] + i - 2)*blkSize + l;
789 values_h(entryOffset + k*9 + j*3 + i + edgeStencilLength*l) = coeffs[k]*coeffs[j + 2]*coeffs[i];
794 for(LO l = 0; l < blkSize; ++l) {
795 row_map_h(rowIdx + 1 + l) = entryOffset + edgeStencilLength*(l+1);
797 for(
int dim = 0; dim <numDimensions; ++dim) {
798 coarseCoordData[dim][coordRowIdx] = fineCoordData[dim][coordColumnOffset];
802 coordRowIdx = ((edgeIdx + 1)*lCoarseNodesPerDim[1]*lCoarseNodesPerDim[0]
803 + (lCoarseNodesPerDim[1] - 1)*lCoarseNodesPerDim[0]);
804 rowIdx = coordRowIdx*blkSize;
805 coordColumnOffset = ((edgeIdx + 1)*3*lFineNodesPerDim[1]*lFineNodesPerDim[0]
806 + (lFineNodesPerDim[1] - 1)*lFineNodesPerDim[0]);
807 columnOffset = coordColumnOffset*blkSize;
808 entryOffset = (facePlaneOffset + edgeIdx*interiorPlaneOffset + faceLineOffset
809 + (lCoarseNodesPerDim[1] - 2)*interiorLineOffset)*blkSize;
810 for(LO l = 0; l < blkSize; ++l) {
811 for(LO k = 0; k < 5; ++k) {
812 for(LO j = 0; j < 3; ++j) {
813 for(LO i = 0; i < 3; ++i) {
814 entries_h(entryOffset + k*9 + j*3 + i + edgeStencilLength*l) = columnOffset
815 + ((k - 2)*lFineNodesPerDim[1]*lFineNodesPerDim[0] + (j - 2)*lFineNodesPerDim[0] + i)*blkSize + l;
816 values_h(entryOffset + k*9 + j*3 + i + edgeStencilLength*l) = coeffs[k]*coeffs[j]*coeffs[i + 2];
821 for(LO l = 0; l < blkSize; ++l) {
822 row_map_h(rowIdx + 1 + l) = entryOffset + edgeStencilLength*(l+1);
824 for(
int dim = 0; dim <numDimensions; ++dim) {
825 coarseCoordData[dim][coordRowIdx] = fineCoordData[dim][coordColumnOffset];
829 coordRowIdx = ((edgeIdx + 2)*lCoarseNodesPerDim[1]*lCoarseNodesPerDim[0] - 1);
830 rowIdx = coordRowIdx*blkSize;
831 coordColumnOffset = ((edgeIdx + 1)*3*lFineNodesPerDim[1]*lFineNodesPerDim[0]
832 + lFineNodesPerDim[1]*lFineNodesPerDim[0] - 1);
833 columnOffset = coordColumnOffset*blkSize;
834 entryOffset = (facePlaneOffset + (edgeIdx + 1)*interiorPlaneOffset - edgeStencilLength)*blkSize;
835 for(LO l = 0; l < blkSize; ++l) {
836 for(LO k = 0; k < 5; ++k) {
837 for(LO j = 0; j < 3; ++j) {
838 for(LO i = 0; i < 3; ++i) {
839 entries_h(entryOffset + k*9 + j*3 + i + edgeStencilLength*l) = columnOffset
840 + ((k - 2)*lFineNodesPerDim[1]*lFineNodesPerDim[0]
841 + (j - 2)*lFineNodesPerDim[0] + i - 2)*blkSize + l;
842 values_h(entryOffset + k*9 + j*3 + i + edgeStencilLength*l) = coeffs[k]*coeffs[j]*coeffs[i];
847 for(LO l = 0; l < blkSize; ++l) {
848 row_map_h(rowIdx + 1 + l) = entryOffset + edgeStencilLength*(l+1);
850 for(
int dim = 0; dim <numDimensions; ++dim) {
851 coarseCoordData[dim][coordRowIdx] = fineCoordData[dim][coordColumnOffset];
857 Kokkos::deep_copy(row_map, row_map_h);
858 Kokkos::deep_copy(entries, entries_h);
859 Kokkos::deep_copy(values, values_h);
862 LOTupleView lFineNodesPerDim_d(
"lFineNodesPerDim");
863 LOTupleView lCoarseNodesPerDim_d(
"lCoarseNodesPerDim");
865 typename Kokkos::View<LO[3], device_type>::HostMirror lCoarseNodesPerDim_h = Kokkos::create_mirror_view( lCoarseNodesPerDim_d );
866 typename Kokkos::View<LO[3], device_type>::HostMirror lFineNodesPerDim_h = Kokkos::create_mirror_view( lFineNodesPerDim_d );
868 for(
int dim = 0; dim < numDimensions; ++dim) {
869 lCoarseNodesPerDim_h(dim) = lCoarseNodesPerDim[dim];
870 lFineNodesPerDim_h(dim) = lFineNodesPerDim[dim];
873 Kokkos::deep_copy(lCoarseNodesPerDim_d, lCoarseNodesPerDim_h);
874 Kokkos::deep_copy(lFineNodesPerDim_d, lFineNodesPerDim_h);
878 if((lCoarseNodesPerDim[0] - 2 > 0) && (lCoarseNodesPerDim[1] - 2 > 0)) {
880 Kokkos::parallel_for(
"Faces in 0-1 plane region R",
881 Kokkos::RangePolicy<typename device_type::execution_space>(0, (lCoarseNodesPerDim[1]-2)*(lCoarseNodesPerDim[0]-2) ),
882 KOKKOS_LAMBDA(
const LO faceIdx) {
883 LO coordRowIdx, rowIdx, coordColumnOffset, columnOffset, entryOffset;
884 LO gridIdx[3] = {0,0,0};
885 impl_scalar_type coeffs_d[5] = {1.0/3.0, 2.0/3.0, 1.0, 2.0/3.0, 1.0/3.0};
889 for(LO i = 0; i < faceIdx; i++){
891 if(gridIdx[0] == lCoarseNodesPerDim_d(0) - 2) {
898 coordRowIdx = ((gridIdx[1] + 1)*lCoarseNodesPerDim_d(0) + gridIdx[0] + 1);
899 rowIdx = coordRowIdx*blkSize;
900 coordColumnOffset = 3*((gridIdx[1] + 1)*lFineNodesPerDim_d(0) + gridIdx[0] + 1);
901 columnOffset = coordColumnOffset*blkSize;
902 entryOffset = (edgeLineOffset + edgeStencilLength
903 + gridIdx[1]*faceLineOffset + gridIdx[0]*faceStencilLength)*blkSize;
904 for(LO l = 0; l < blkSize; ++l) {
905 for(LO k = 0; k < 3; ++k) {
906 for(LO j = 0; j < 5; ++j) {
907 for(LO i = 0; i < 5; ++i) {
908 entries(entryOffset + k*25 + j*5 + i + faceStencilLength*l) = columnOffset
909 + (k*lFineNodesPerDim_d(1)*lFineNodesPerDim_d(0) + (j - 2)*lFineNodesPerDim_d(0) + i - 2)*blkSize + l;
910 values(entryOffset + k*25 + j*5 + i + faceStencilLength*l) = coeffs_d[k + 2]*coeffs_d[j]*coeffs_d[i];
915 for(LO l = 0; l < blkSize; ++l) {
916 row_map(rowIdx + 1 + l) = entryOffset + faceStencilLength*(l+1);
918 for(
int dim = 0; dim <numDimensions; ++dim) {
919 coarseCoordsView(coordRowIdx,dim) = fineCoordsView(coordColumnOffset, dim);
923 coordRowIdx += (lCoarseNodesPerDim_d(2) - 1)*lCoarseNodesPerDim_d(1)*lCoarseNodesPerDim_d(0);
924 rowIdx = coordRowIdx*blkSize;
925 coordColumnOffset += (lFineNodesPerDim_d(2) - 1)*lFineNodesPerDim_d(1)*lFineNodesPerDim_d(0);
926 columnOffset = coordColumnOffset*blkSize;
927 entryOffset += (facePlaneOffset + (lCoarseNodesPerDim_d(2) - 2)*interiorPlaneOffset)*blkSize;
928 for(LO l = 0; l < blkSize; ++l) {
929 for(LO k = 0; k < 3; ++k) {
930 for(LO j = 0; j < 5; ++j) {
931 for(LO i = 0; i < 5; ++i) {
932 entries(entryOffset + k*25 + j*5 + i + faceStencilLength*l) = columnOffset
933 + ((k - 2)*lFineNodesPerDim_d(1)*lFineNodesPerDim_d(0)
934 + (j - 2)*lFineNodesPerDim_d(0) + i - 2)*blkSize + l;
935 values(entryOffset + k*25 + j*5 + i + faceStencilLength*l) = coeffs_d[k]*coeffs_d[j]*coeffs_d[i];
940 for(LO l = 0; l < blkSize; ++l) {
941 row_map(rowIdx + 1 + l) = entryOffset + faceStencilLength*(l+1);
943 for(
int dim = 0; dim <numDimensions; ++dim) {
944 coarseCoordsView(coordRowIdx,dim) = fineCoordsView(coordColumnOffset, dim);
951 if((lCoarseNodesPerDim[0] - 2 > 0) && (lCoarseNodesPerDim[2] - 2 > 0)) {
953 Kokkos::parallel_for(
"Faces in 0-2 plane region R",
954 Kokkos::RangePolicy<typename device_type::execution_space>(0, (lCoarseNodesPerDim[2]-2)*(lCoarseNodesPerDim[0]-2) ),
955 KOKKOS_LAMBDA(
const LO faceIdx) {
956 LO coordRowIdx, rowIdx, coordColumnOffset, columnOffset, entryOffset;
957 LO gridIdx[3] = {0,0,0};
958 impl_scalar_type coeffs_d[5] = {1.0/3.0, 2.0/3.0, 1.0, 2.0/3.0, 1.0/3.0};
962 for(LO i = 0; i < faceIdx; i++){
964 if(gridIdx[0] == lCoarseNodesPerDim_d(0) - 2) {
971 coordRowIdx = ((gridIdx[2] + 1)*lCoarseNodesPerDim_d(1)*lCoarseNodesPerDim_d(0) + (gridIdx[0] + 1));
972 rowIdx = coordRowIdx*blkSize;
973 coordColumnOffset = ((gridIdx[2] + 1)*lFineNodesPerDim_d(1)*lFineNodesPerDim_d(0)
975 columnOffset = coordColumnOffset*blkSize;
976 entryOffset = (facePlaneOffset + gridIdx[2]*interiorPlaneOffset + edgeStencilLength
977 + gridIdx[0]*faceStencilLength)*blkSize;
978 for(LO l = 0; l < blkSize; ++l) {
979 for(LO k = 0; k < 5; ++k) {
980 for(LO j = 0; j < 3; ++j) {
981 for(LO i = 0; i < 5; ++i) {
982 entries(entryOffset + k*15 + j*5 + i + faceStencilLength*l) = columnOffset
983 + ((k - 2)*lFineNodesPerDim_d(1)*lFineNodesPerDim_d(0) + j*lFineNodesPerDim_d(0) + i - 2)*blkSize + l;
984 values(entryOffset + k*15 + j*5 + i + faceStencilLength*l) = coeffs_d[k]*coeffs_d[j + 2]*coeffs_d[i];
989 for(LO l = 0; l < blkSize; ++l) {
990 row_map(rowIdx + 1 + l) = entryOffset + faceStencilLength*(l+1);
992 for(
int dim = 0; dim <numDimensions; ++dim) {
993 coarseCoordsView(coordRowIdx,dim) = fineCoordsView(coordColumnOffset, dim);
997 coordRowIdx += (lCoarseNodesPerDim_d(1) - 1)*lCoarseNodesPerDim_d(0);
998 rowIdx = coordRowIdx*blkSize;
999 coordColumnOffset += (lFineNodesPerDim_d(1) - 1)*lFineNodesPerDim_d(0);
1000 columnOffset = coordColumnOffset*blkSize;
1001 entryOffset += (faceLineOffset + (lCoarseNodesPerDim_d(1) - 2)*interiorLineOffset)*blkSize;
1002 for(LO l = 0; l < blkSize; ++l) {
1003 for(LO k = 0; k < 5; ++k) {
1004 for(LO j = 0; j < 3; ++j) {
1005 for(LO i = 0; i < 5; ++i) {
1006 entries(entryOffset + k*15 + j*5 + i + faceStencilLength*l) = columnOffset
1007 + ((k - 2)*lFineNodesPerDim_d(1)*lFineNodesPerDim_d(0)
1008 + (j - 2)*lFineNodesPerDim_d(0) + i - 2)*blkSize + l;
1009 values(entryOffset + k*15 + j*5 + i + faceStencilLength*l) = coeffs_d[k]*coeffs_d[j]*coeffs_d[i];
1014 for(LO l = 0; l < blkSize; ++l) {
1015 row_map(rowIdx + 1 + l) = entryOffset + faceStencilLength*(l+1);
1017 for(
int dim = 0; dim <numDimensions; ++dim) {
1018 coarseCoordsView(coordRowIdx,dim) = fineCoordsView(coordColumnOffset, dim);
1025 if((lCoarseNodesPerDim[1] - 2 > 0) && (lCoarseNodesPerDim[2] - 2 > 0)) {
1027 Kokkos::parallel_for(
"Faces in 1-2 plane region R",
1028 Kokkos::RangePolicy<typename device_type::execution_space>(0, (lCoarseNodesPerDim[2]-2)*(lCoarseNodesPerDim[1]-2) ),
1029 KOKKOS_LAMBDA(
const LO faceIdx) {
1030 LO coordRowIdx, rowIdx, coordColumnOffset, columnOffset, entryOffset;
1031 LO gridIdx[3] = {0,0,0};
1032 impl_scalar_type coeffs_d[5] = {1.0/3.0, 2.0/3.0, 1.0, 2.0/3.0, 1.0/3.0};
1036 for(LO i = 0; i < faceIdx; i++){
1038 if(gridIdx[1] == lCoarseNodesPerDim_d(1) - 2) {
1045 coordRowIdx = ((gridIdx[2] + 1)*lCoarseNodesPerDim_d(1)*lCoarseNodesPerDim_d(0)
1046 + (gridIdx[1] + 1)*lCoarseNodesPerDim_d(0));
1047 rowIdx = coordRowIdx*blkSize;
1048 coordColumnOffset = ((gridIdx[2] + 1)*lFineNodesPerDim_d(1)*lFineNodesPerDim_d(0)
1049 + (gridIdx[1] + 1)*lFineNodesPerDim_d(0))*3;
1050 columnOffset = coordColumnOffset*blkSize;
1051 entryOffset = (facePlaneOffset + gridIdx[2]*interiorPlaneOffset + faceLineOffset
1052 + gridIdx[1]*interiorLineOffset)*blkSize;
1053 for(LO l = 0; l < blkSize; ++l) {
1054 for(LO k = 0; k < 5; ++k) {
1055 for(LO j = 0; j < 5; ++j) {
1056 for(LO i = 0; i < 3; ++i) {
1057 entries(entryOffset + k*15 + j*3 + i + faceStencilLength*l) = columnOffset
1058 + ((k - 2)*lFineNodesPerDim_d(1)*lFineNodesPerDim_d(0) + (j - 2)*lFineNodesPerDim_d(0) + i)*blkSize + l;
1059 values(entryOffset + k*15 + j*3 + i + faceStencilLength*l) = coeffs_d[k]*coeffs_d[j]*coeffs_d[i + 2];
1064 for(LO l = 0; l < blkSize; ++l) {
1065 row_map(rowIdx + 1 + l) = entryOffset + faceStencilLength*(l+1);
1067 for(
int dim = 0; dim <numDimensions; ++dim) {
1068 coarseCoordsView(coordRowIdx,dim) = fineCoordsView(coordColumnOffset, dim);
1072 coordRowIdx += (lCoarseNodesPerDim_d(0) - 1);
1073 rowIdx = coordRowIdx*blkSize;
1074 coordColumnOffset += (lFineNodesPerDim_d(0) - 1);
1075 columnOffset = coordColumnOffset*blkSize;
1076 entryOffset += (faceStencilLength + (lCoarseNodesPerDim_d(0) - 2)*interiorStencilLength)*blkSize;
1077 for(LO l = 0; l < blkSize; ++l) {
1078 for(LO k = 0; k < 5; ++k) {
1079 for(LO j = 0; j < 5; ++j) {
1080 for(LO i = 0; i < 3; ++i) {
1081 entries(entryOffset + k*15 + j*3 + i + faceStencilLength*l) = columnOffset
1082 + ((k - 2)*lFineNodesPerDim_d(1)*lFineNodesPerDim_d(0)
1083 + (j - 2)*lFineNodesPerDim_d(0) + i - 2)*blkSize + l;
1084 values(entryOffset + k*15 + j*3 + i + faceStencilLength*l) = coeffs_d[k]*coeffs_d[j]*coeffs_d[i];
1089 for(LO l = 0; l < blkSize; ++l) {
1090 row_map(rowIdx + 1 + l) = entryOffset + faceStencilLength*(l+1);
1092 for(
int dim = 0; dim <numDimensions; ++dim) {
1093 coarseCoordsView(coordRowIdx,dim) = fineCoordsView(coordColumnOffset, dim);
1099 if(numInteriors > 0) {
1105 LO countRowEntries = 0;
1106 Kokkos::View<LO[125]> coordColumnOffsets_d(
"coordColOffset");
1107 auto coordColumnOffsets_h = Kokkos::create_mirror_view( coordColumnOffsets_d );
1109 for(LO k = -2; k < 3; ++k) {
1110 for(LO j = -2; j < 3; ++j) {
1111 for(LO i = -2; i < 3; ++i) {
1112 coordColumnOffsets_h(countRowEntries) = k*lFineNodesPerDim[1]*lFineNodesPerDim[0]
1113 + j*lFineNodesPerDim[0] + i;
1118 Kokkos::deep_copy(coordColumnOffsets_d, coordColumnOffsets_h);
1121 Kokkos::View<impl_scalar_type*> interiorValues_d(
"interiorValues",125);
1122 auto interiorValues_h = Kokkos::create_mirror_view( interiorValues_d );
1123 for(LO k = 0; k < 5; ++k) {
1124 for(LO j = 0; j < 5; ++j) {
1125 for(LO i = 0; i < 5; ++i) {
1126 interiorValues_h(countValues) = coeffs[k]*coeffs[j]*coeffs[i];
1131 Kokkos::deep_copy(interiorValues_d, interiorValues_h);
1133 Kokkos::parallel_for(
"interior idx region R",Kokkos::RangePolicy<typename device_type::execution_space>(0, numInteriors),
1134 KOKKOS_LAMBDA(
const LO interiorIdx) {
1135 LO coordRowIdx, rowIdx, coordColumnOffset, columnOffset, entryOffset;
1137 gridIdx[0] = 0; gridIdx[1] = 0; gridIdx[2] = 0;
1141 for(LO i=0; i<interiorIdx; i++){
1143 if(gridIdx[0] == lCoarseNodesPerDim_d(0) - 2) {
1146 if(gridIdx[1] == lCoarseNodesPerDim_d(1) - 2) {
1153 coordRowIdx = ((gridIdx[2] + 1)*lCoarseNodesPerDim_d(0)*lCoarseNodesPerDim_d(1)
1154 + (gridIdx[1] + 1)*lCoarseNodesPerDim_d(0)
1156 rowIdx = coordRowIdx*blkSize;
1157 coordColumnOffset = ((gridIdx[2] + 1)*3*lFineNodesPerDim_d(1)*lFineNodesPerDim_d(0)
1158 + (gridIdx[1] + 1)*3*lFineNodesPerDim_d(0) + (gridIdx[0] + 1)*3);
1159 columnOffset = coordColumnOffset*blkSize;
1160 entryOffset = (facePlaneOffset + faceLineOffset + faceStencilLength
1161 + gridIdx[2]*interiorPlaneOffset + gridIdx[1]*interiorLineOffset
1162 + gridIdx[0]*interiorStencilLength)*blkSize;
1163 for(LO l = 0; l < blkSize; ++l) {
1164 row_map(rowIdx + 1 + l) = entryOffset + interiorStencilLength*(l+1);
1169 for(LO l = 0; l < blkSize; ++l) {
1170 for(LO entryIdx = 0; entryIdx < interiorStencilLength; ++entryIdx) {
1171 entries(entryOffset + entryIdx + interiorStencilLength*l) = columnOffset + coordColumnOffsets_d(entryIdx)*blkSize + l;
1172 values(entryOffset + entryIdx + interiorStencilLength*l) = interiorValues_d(entryIdx);
1175 for(
int dim = 0; dim <numDimensions; ++dim) {
1176 coarseCoordsView(coordRowIdx,dim) = fineCoordsView(coordColumnOffset, dim);
1183 local_graph_type localGraph(entries, row_map);
1184 local_matrix_type localR(
"R", numCols, values, localGraph);
1186 R = MatrixFactory::Build(localR,