125 typedef Teuchos::SerialDenseMatrix<GO,GO> SerialDenseMatrixType;
145 RCP<Teuchos::SerialDenseMatrix<GO,GO> > coarseElementVDOFs,
149 coarseLevel.
Get(
"VElementList",coarseElementVDOFs,coarseLevel.
GetFactoryManager()->GetFactory(
"VElementList").get());
150 coarseLevel.
Get(
"PElementList",coarseElementPDOFs,coarseLevel.
GetFactoryManager()->GetFactory(
"PElementList").get());
151 coarseLevel.
Get(
"MElementList",coarseElementMDOFs,coarseLevel.
GetFactoryManager()->GetFactory(
"MElementList").get());
156 GO totalFineElements = fineElementMDOFs->numRows();
157 LO nFineElements = (int) sqrt(totalFineElements);
158 GO totalCoarseElements = coarseElementMDOFs->numRows();
159 LO nCoarseElements = (int) sqrt(totalCoarseElements);
162 GO nM = (2*nCoarseElements+1)*(2*nCoarseElements+1);
164 GO nP = (nCoarseElements+1)*(nCoarseElements+1);
173 RCP<const Map> rowMapforPV = fineA00->getRowMap();
174 RCP<const Map> rowMapforPP = fineA10->getRowMap();
175 RCP<const Map> rowMapforPM = fineA20->getRowMap();
177 GO fNV = rowMapforPV->getGlobalNumElements();
178 GO fNP = rowMapforPP->getGlobalNumElements();
179 GO fNM = rowMapforPM->getGlobalNumElements();
182 RCP<const Teuchos::Comm<int> > comm = rowMapforPV->getComm();
186 RCP<const Map> rowMapforP = FineA->getRowMap();
189 RCP<const Map> colMapforPV = Xpetra::MapFactory<LO,GO>::createUniformContigMap(Xpetra::UseTpetra,nV,comm);
190 RCP<const Map> colMapforPP = Xpetra::MapFactory<LO,GO>::createUniformContigMap(Xpetra::UseTpetra,nP,comm);
191 RCP<const Map> colMapforPM = Xpetra::MapFactory<LO,GO>::createUniformContigMap(Xpetra::UseTpetra,nM,comm);
196 size_t maxEntriesPerRowV = 9,
197 maxEntriesPerRowP = 4,
198 maxEntriesPerRowM = 9;
200 RCP<Matrix> P = rcp(
new CrsMatrixWrap(rowMapforP ,maxEntriesPerRowV));
201 RCP<Matrix> PV = rcp(
new CrsMatrixWrap(rowMapforPV,maxEntriesPerRowV));
202 RCP<Matrix> PP = rcp(
new CrsMatrixWrap(rowMapforPP,maxEntriesPerRowP));
203 RCP<Matrix> PM = rcp(
new CrsMatrixWrap(rowMapforPM,maxEntriesPerRowM));
255 Teuchos::ArrayRCP<GO> colPtrV(maxEntriesPerRowV,0);
256 Teuchos::ArrayRCP<GO> colPtrM(maxEntriesPerRowM,0);
257 Teuchos::ArrayRCP<SC> valPtrM(maxEntriesPerRowM,0.);
259 Teuchos::ArrayRCP<GO> colPtrP(maxEntriesPerRowP,0);
260 Teuchos::ArrayRCP<SC> valPtrP(maxEntriesPerRowP,0.);
263 GO fineElement[4] = {0,1,nFineElements,nFineElements+1};
268 for ( GO coarseElement=0; coarseElement<totalCoarseElements; coarseElement++)
278 if (coarseElement < nCoarseElements)
282 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,0);
284 colPtrM[1] = (*coarseElementMDOFs)(coarseElement,1);
286 colPtrM[2] = (*coarseElementMDOFs)(coarseElement,4);
290 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[0],4),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
292 colPtrV[0] = 2*colPtrM[0];
293 colPtrV[1] = 2*colPtrM[1];
294 colPtrV[2] = 2*colPtrM[2];
296 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[0],8),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
298 colPtrV[0] = 2*colPtrM[0]+1;
299 colPtrV[1] = 2*colPtrM[1]+1;
300 colPtrV[2] = 2*colPtrM[2]+1;
302 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[0],9),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
305 colPtrP[0] = (*coarseElementPDOFs)(coarseElement,0);
307 colPtrP[1] = (*coarseElementPDOFs)(coarseElement,1);
311 PP->insertGlobalValues((*fineElementPDOFs)(fineElement[0],1),colPtrP.view(0,nnz),valPtrP.view(0,nnz));
314 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,4);
318 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[0],1),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
320 colPtrV[0] = 2*colPtrM[0];
322 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[0],2),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
324 colPtrV[0] = 2*colPtrM[0]+1;
326 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[0],3),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
329 colPtrP[0] = (*coarseElementPDOFs)(coarseElement,1);
333 PP->insertGlobalValues((*fineElementPDOFs)(fineElement[1],1),colPtrP.view(0,nnz),valPtrP.view(0,nnz));
337 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,0);
339 colPtrM[1] = (*coarseElementMDOFs)(coarseElement,1);
341 colPtrM[2] = (*coarseElementMDOFs)(coarseElement,4);
345 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[1],4),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
347 colPtrV[0] = 2*colPtrM[0];
348 colPtrV[1] = 2*colPtrM[1];
349 colPtrV[2] = 2*colPtrM[2];
351 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[1],8),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
353 colPtrV[0] = 2*colPtrM[0]+1;
354 colPtrV[1] = 2*colPtrM[1]+1;
355 colPtrV[2] = 2*colPtrM[2]+1;
357 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[1],9),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
361 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,1);
365 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[1],1),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
367 colPtrV[0] = 2*colPtrM[0];
369 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[1],2),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
371 colPtrV[0] = 2*colPtrM[0]+1;
373 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[1],3),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
376 if (coarseElement == 0)
381 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,0);
385 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[0],0),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
387 colPtrV[0] = 2*colPtrM[0];
389 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[0],0),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
391 colPtrV[0] = 2*colPtrM[0]+1;
393 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[0],1),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
396 colPtrP[0] = (*coarseElementPDOFs)(coarseElement,0);
400 PP->insertGlobalValues((*fineElementPDOFs)(fineElement[0],0),colPtrP.view(0,nnz),valPtrP.view(0,nnz));
406 if (coarseElement % (nCoarseElements) == 0)
410 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,0);
412 colPtrM[1] = (*coarseElementMDOFs)(coarseElement,3);
414 colPtrM[2] = (*coarseElementMDOFs)(coarseElement,7);
418 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[0],7),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
420 colPtrV[0] = 2*colPtrM[0];
421 colPtrV[1] = 2*colPtrM[1];
422 colPtrV[2] = 2*colPtrM[2];
424 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[0],14),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
426 colPtrV[0] = 2*colPtrM[0]+1;
427 colPtrV[1] = 2*colPtrM[1]+1;
428 colPtrV[2] = 2*colPtrM[2]+1;
430 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[0],15),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
433 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,7);
437 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[0],3),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
439 colPtrV[0] = 2*colPtrM[0];
441 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[0],6),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
443 colPtrV[0] = 2*colPtrM[0]+1;
445 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[0],7),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
448 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,0);
450 colPtrM[1] = (*coarseElementMDOFs)(coarseElement,3);
452 colPtrM[2] = (*coarseElementMDOFs)(coarseElement,7);
456 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[2],7),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
458 colPtrV[0] = 2*colPtrM[0];
459 colPtrV[1] = 2*colPtrM[1];
460 colPtrV[2] = 2*colPtrM[2];
462 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[2],14),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
464 colPtrV[0] = 2*colPtrM[0]+1;
465 colPtrV[1] = 2*colPtrM[1]+1;
466 colPtrV[2] = 2*colPtrM[2]+1;
468 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[2],15),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
472 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,3);
476 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[2],3),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
478 colPtrV[0] = 2*colPtrM[0];
480 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[2],6),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
482 colPtrV[0] = 2*colPtrM[0]+1;
484 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[2],7),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
489 colPtrP[0] = (*coarseElementPDOFs)(coarseElement,0);
491 colPtrP[1] = (*coarseElementPDOFs)(coarseElement,3);
495 PP->insertGlobalValues((*fineElementPDOFs)(fineElement[0],3),colPtrP.view(0,nnz),valPtrP.view(0,nnz));
498 colPtrP[0] = (*coarseElementPDOFs)(coarseElement,3);
502 PP->insertGlobalValues((*fineElementPDOFs)(fineElement[2],3),colPtrP.view(0,nnz),valPtrP.view(0,nnz));
509 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,8);
513 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[3],0),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
515 colPtrV[0] = 2*colPtrM[0];
517 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[3],0),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
519 colPtrV[0] = 2*colPtrM[0]+1;
521 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[3],1),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
524 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,5);
528 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[3],1),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
530 colPtrV[0] = 2*colPtrM[0];
532 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[3],2),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
534 colPtrV[0] = 2*colPtrM[0]+1;
536 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[3],3),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
539 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,2);
543 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[3],2),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
545 colPtrV[0] = 2*colPtrM[0];
547 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[3],4),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
549 colPtrV[0] = 2*colPtrM[0]+1;
551 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[3],5),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
554 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,6);
558 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[3],3),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
560 colPtrV[0] = 2*colPtrM[0];
562 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[3],6),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
564 colPtrV[0] = 2*colPtrM[0]+1;
566 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[3],7),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
569 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,4);
571 colPtrM[1] = (*coarseElementMDOFs)(coarseElement,6);
573 colPtrM[2] = (*coarseElementMDOFs)(coarseElement,8);
577 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[0],5),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
579 colPtrV[0] = 2*colPtrM[0];
580 colPtrV[1] = 2*colPtrM[1];
581 colPtrV[2] = 2*colPtrM[2];
583 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[0],10),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
585 colPtrV[0] = 2*colPtrM[0]+1;
586 colPtrV[1] = 2*colPtrM[1]+1;
587 colPtrV[2] = 2*colPtrM[2]+1;
589 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[0],11),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
593 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,5);
595 colPtrM[1] = (*coarseElementMDOFs)(coarseElement,7);
597 colPtrM[2] = (*coarseElementMDOFs)(coarseElement,8);
601 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[0],6),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
603 colPtrV[0] = 2*colPtrM[0];
604 colPtrV[1] = 2*colPtrM[1];
605 colPtrV[2] = 2*colPtrM[2];
607 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[0],12),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
609 colPtrV[0] = 2*colPtrM[0]+1;
610 colPtrV[1] = 2*colPtrM[1]+1;
611 colPtrV[2] = 2*colPtrM[2]+1;
613 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[0],13),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
617 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,1);
619 colPtrM[1] = (*coarseElementMDOFs)(coarseElement,2);
621 colPtrM[2] = (*coarseElementMDOFs)(coarseElement,5);
625 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[1],5),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
627 colPtrV[0] = 2*colPtrM[0];
628 colPtrV[1] = 2*colPtrM[1];
629 colPtrV[2] = 2*colPtrM[2];
631 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[1],10),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
633 colPtrV[0] = 2*colPtrM[0]+1;
634 colPtrV[1] = 2*colPtrM[1]+1;
635 colPtrV[2] = 2*colPtrM[2]+1;
637 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[1],11),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
641 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,5);
643 colPtrM[1] = (*coarseElementMDOFs)(coarseElement,7);
645 colPtrM[2] = (*coarseElementMDOFs)(coarseElement,8);
649 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[1],6),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
651 colPtrV[0] = 2*colPtrM[0];
652 colPtrV[1] = 2*colPtrM[1];
653 colPtrV[2] = 2*colPtrM[2];
655 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[1],12),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
657 colPtrV[0] = 2*colPtrM[0]+1;
658 colPtrV[1] = 2*colPtrM[1]+1;
659 colPtrV[2] = 2*colPtrM[2]+1;
661 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[1],13),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
665 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,4);
667 colPtrM[1] = (*coarseElementMDOFs)(coarseElement,6);
669 colPtrM[2] = (*coarseElementMDOFs)(coarseElement,8);
673 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[2],5),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
675 colPtrV[0] = 2*colPtrM[0];
676 colPtrV[1] = 2*colPtrM[1];
677 colPtrV[2] = 2*colPtrM[2];
679 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[2],10),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
681 colPtrV[0] = 2*colPtrM[0]+1;
682 colPtrV[1] = 2*colPtrM[1]+1;
683 colPtrV[2] = 2*colPtrM[2]+1;
685 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[2],11),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
689 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,2);
691 colPtrM[1] = (*coarseElementMDOFs)(coarseElement,3);
693 colPtrM[2] = (*coarseElementMDOFs)(coarseElement,6);
697 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[2],6),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
699 colPtrV[0] = 2*colPtrM[0];
700 colPtrV[1] = 2*colPtrM[1];
701 colPtrV[2] = 2*colPtrM[2];
703 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[2],12),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
705 colPtrV[0] = 2*colPtrM[0]+1;
706 colPtrV[1] = 2*colPtrM[1]+1;
707 colPtrV[2] = 2*colPtrM[2]+1;
709 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[2],13),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
713 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,1);
715 colPtrM[1] = (*coarseElementMDOFs)(coarseElement,2);
717 colPtrM[2] = (*coarseElementMDOFs)(coarseElement,5);
721 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[3],5),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
723 colPtrV[0] = 2*colPtrM[0];
724 colPtrV[1] = 2*colPtrM[1];
725 colPtrV[2] = 2*colPtrM[2];
727 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[3],10),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
729 colPtrV[0] = 2*colPtrM[0]+1;
730 colPtrV[1] = 2*colPtrM[1]+1;
731 colPtrV[2] = 2*colPtrM[2]+1;
734 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[3],11),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
737 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,2);
739 colPtrM[1] = (*coarseElementMDOFs)(coarseElement,3);
741 colPtrM[2] = (*coarseElementMDOFs)(coarseElement,6);
745 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[3],6),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
747 colPtrV[0] = 2*colPtrM[0];
748 colPtrV[1] = 2*colPtrM[1];
749 colPtrV[2] = 2*colPtrM[2];
751 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[3],12),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
753 colPtrV[0] = 2*colPtrM[0]+1;
754 colPtrV[1] = 2*colPtrM[1]+1;
755 colPtrV[2] = 2*colPtrM[2]+1;
757 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[3],13),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
761 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,0);
762 valPtrM[0] = 0.140625;
763 colPtrM[1] = (*coarseElementMDOFs)(coarseElement,1);
764 valPtrM[1] = -0.046875;
765 colPtrM[2] = (*coarseElementMDOFs)(coarseElement,2);
766 valPtrM[2] = 0.015625;
767 colPtrM[3] = (*coarseElementMDOFs)(coarseElement,3);
768 valPtrM[3] = -0.046875;
769 colPtrM[4] = (*coarseElementMDOFs)(coarseElement,4);
770 valPtrM[4] = 0.28125;
771 colPtrM[5] = (*coarseElementMDOFs)(coarseElement,5);
772 valPtrM[5] = -0.09375;
773 colPtrM[6] = (*coarseElementMDOFs)(coarseElement,6);
774 valPtrM[6] = -0.09375;
775 colPtrM[7] = (*coarseElementMDOFs)(coarseElement,7);
776 valPtrM[7] = 0.28125;
777 colPtrM[8] = (*coarseElementMDOFs)(coarseElement,8);
781 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[0],8),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
783 colPtrV[0] = 2*colPtrM[0];
784 colPtrV[1] = 2*colPtrM[1];
785 colPtrV[2] = 2*colPtrM[2];
786 colPtrV[3] = 2*colPtrM[3];
787 colPtrV[4] = 2*colPtrM[4];
788 colPtrV[5] = 2*colPtrM[5];
789 colPtrV[6] = 2*colPtrM[6];
790 colPtrV[7] = 2*colPtrM[7];
791 colPtrV[8] = 2*colPtrM[8];
793 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[0],16),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
795 colPtrV[0] = 2*colPtrM[0]+1;
796 colPtrV[1] = 2*colPtrM[1]+1;
797 colPtrV[2] = 2*colPtrM[2]+1;
798 colPtrV[3] = 2*colPtrM[3]+1;
799 colPtrV[4] = 2*colPtrM[4]+1;
800 colPtrV[5] = 2*colPtrM[5]+1;
801 colPtrV[6] = 2*colPtrM[6]+1;
802 colPtrV[7] = 2*colPtrM[7]+1;
803 colPtrV[8] = 2*colPtrM[8]+1;
805 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[0],17),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
808 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,0);
809 valPtrM[0] = -0.046875;
810 colPtrM[1] = (*coarseElementMDOFs)(coarseElement,1);
811 valPtrM[1] = 0.140625;
812 colPtrM[2] = (*coarseElementMDOFs)(coarseElement,2);
813 valPtrM[2] = -0.046875;
814 colPtrM[3] = (*coarseElementMDOFs)(coarseElement,3);
815 valPtrM[3] = 0.015625;
816 colPtrM[4] = (*coarseElementMDOFs)(coarseElement,4);
817 valPtrM[4] = 0.28125;
818 colPtrM[5] = (*coarseElementMDOFs)(coarseElement,5);
819 valPtrM[5] = 0.28125;
820 colPtrM[6] = (*coarseElementMDOFs)(coarseElement,6);
821 valPtrM[6] = -0.09375;
822 colPtrM[7] = (*coarseElementMDOFs)(coarseElement,7);
823 valPtrM[7] = -0.09375;
824 colPtrM[8] = (*coarseElementMDOFs)(coarseElement,8);
828 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[1],8),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
830 colPtrV[0] = 2*colPtrM[0];
831 colPtrV[1] = 2*colPtrM[1];
832 colPtrV[2] = 2*colPtrM[2];
833 colPtrV[3] = 2*colPtrM[3];
834 colPtrV[4] = 2*colPtrM[4];
835 colPtrV[5] = 2*colPtrM[5];
836 colPtrV[6] = 2*colPtrM[6];
837 colPtrV[7] = 2*colPtrM[7];
838 colPtrV[8] = 2*colPtrM[8];
840 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[1],16),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
842 colPtrV[0] = 2*colPtrM[0]+1;
843 colPtrV[1] = 2*colPtrM[1]+1;
844 colPtrV[2] = 2*colPtrM[2]+1;
845 colPtrV[3] = 2*colPtrM[3]+1;
846 colPtrV[4] = 2*colPtrM[4]+1;
847 colPtrV[5] = 2*colPtrM[5]+1;
848 colPtrV[6] = 2*colPtrM[6]+1;
849 colPtrV[7] = 2*colPtrM[7]+1;
850 colPtrV[8] = 2*colPtrM[8]+1;
852 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[1],17),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
855 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,0);
856 valPtrM[0] = -0.046875;
857 colPtrM[1] = (*coarseElementMDOFs)(coarseElement,1);
858 valPtrM[1] = 0.015625;
859 colPtrM[2] = (*coarseElementMDOFs)(coarseElement,2);
860 valPtrM[2] = -0.046875;
861 colPtrM[3] = (*coarseElementMDOFs)(coarseElement,3);
862 valPtrM[3] = 0.140625;
863 colPtrM[4] = (*coarseElementMDOFs)(coarseElement,4);
864 valPtrM[4] = -0.09375;
865 colPtrM[5] = (*coarseElementMDOFs)(coarseElement,5);
866 valPtrM[5] = -0.09375;
867 colPtrM[6] = (*coarseElementMDOFs)(coarseElement,6);
868 valPtrM[6] = 0.28125;
869 colPtrM[7] = (*coarseElementMDOFs)(coarseElement,7);
870 valPtrM[7] = 0.28125;
871 colPtrM[8] = (*coarseElementMDOFs)(coarseElement,8);
875 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[2],8),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
877 colPtrV[0] = 2*colPtrM[0];
878 colPtrV[1] = 2*colPtrM[1];
879 colPtrV[2] = 2*colPtrM[2];
880 colPtrV[3] = 2*colPtrM[3];
881 colPtrV[4] = 2*colPtrM[4];
882 colPtrV[5] = 2*colPtrM[5];
883 colPtrV[6] = 2*colPtrM[6];
884 colPtrV[7] = 2*colPtrM[7];
885 colPtrV[8] = 2*colPtrM[8];
887 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[2],16),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
889 colPtrV[0] = 2*colPtrM[0]+1;
890 colPtrV[1] = 2*colPtrM[1]+1;
891 colPtrV[2] = 2*colPtrM[2]+1;
892 colPtrV[3] = 2*colPtrM[3]+1;
893 colPtrV[4] = 2*colPtrM[4]+1;
894 colPtrV[5] = 2*colPtrM[5]+1;
895 colPtrV[6] = 2*colPtrM[6]+1;
896 colPtrV[7] = 2*colPtrM[7]+1;
897 colPtrV[8] = 2*colPtrM[8]+1;
899 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[2],17),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
902 colPtrM[0] = (*coarseElementMDOFs)(coarseElement,0);
903 valPtrM[0] = 0.015625;
904 colPtrM[1] = (*coarseElementMDOFs)(coarseElement,1);
905 valPtrM[1] = -0.046875;
906 colPtrM[2] = (*coarseElementMDOFs)(coarseElement,2);
907 valPtrM[2] = 0.140625;
908 colPtrM[3] = (*coarseElementMDOFs)(coarseElement,3);
909 valPtrM[3] = -0.046875;
910 colPtrM[4] = (*coarseElementMDOFs)(coarseElement,4);
911 valPtrM[4] = -0.09375;
912 colPtrM[5] = (*coarseElementMDOFs)(coarseElement,5);
913 valPtrM[5] = 0.28125;
914 colPtrM[6] = (*coarseElementMDOFs)(coarseElement,6);
915 valPtrM[6] = 0.28125;
916 colPtrM[7] = (*coarseElementMDOFs)(coarseElement,7);
917 valPtrM[7] = -0.09375;
918 colPtrM[8] = (*coarseElementMDOFs)(coarseElement,8);
922 PM->insertGlobalValues((*fineElementMDOFs)(fineElement[3],8),colPtrM.view(0,nnz),valPtrM.view(0,nnz));
924 colPtrV[0] = 2*colPtrM[0];
925 colPtrV[1] = 2*colPtrM[1];
926 colPtrV[2] = 2*colPtrM[2];
927 colPtrV[3] = 2*colPtrM[3];
928 colPtrV[4] = 2*colPtrM[4];
929 colPtrV[5] = 2*colPtrM[5];
930 colPtrV[6] = 2*colPtrM[6];
931 colPtrV[7] = 2*colPtrM[7];
932 colPtrV[8] = 2*colPtrM[8];
934 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[3],16),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
936 colPtrV[0] = 2*colPtrM[0]+1;
937 colPtrV[1] = 2*colPtrM[1]+1;
938 colPtrV[2] = 2*colPtrM[2]+1;
939 colPtrV[3] = 2*colPtrM[3]+1;
940 colPtrV[4] = 2*colPtrM[4]+1;
941 colPtrV[5] = 2*colPtrM[5]+1;
942 colPtrV[6] = 2*colPtrM[6]+1;
943 colPtrV[7] = 2*colPtrM[7]+1;
944 colPtrV[8] = 2*colPtrM[8]+1;
946 PV->insertGlobalValues((*fineElementVDOFs)(fineElement[3],17),colPtrV.view(0,nnz),valPtrM.view(0,nnz));
950 colPtrP[0] = (*coarseElementPDOFs)(coarseElement,0);
952 colPtrP[1] = (*coarseElementPDOFs)(coarseElement,1);
954 colPtrP[2] = (*coarseElementPDOFs)(coarseElement,2);
956 colPtrP[3] = (*coarseElementPDOFs)(coarseElement,3);
960 PP->insertGlobalValues((*fineElementPDOFs)(fineElement[0],2),colPtrP.view(0,nnz),valPtrP.view(0,nnz));
963 colPtrP[0] = (*coarseElementPDOFs)(coarseElement,1);
965 colPtrP[1] = (*coarseElementPDOFs)(coarseElement,2);
969 PP->insertGlobalValues((*fineElementPDOFs)(fineElement[1],2),colPtrP.view(0,nnz),valPtrP.view(0,nnz));
972 colPtrP[0] = (*coarseElementPDOFs)(coarseElement,2);
976 PP->insertGlobalValues((*fineElementPDOFs)(fineElement[3],2),colPtrP.view(0,nnz),valPtrP.view(0,nnz));
979 colPtrP[0] = (*coarseElementPDOFs)(coarseElement,2);
981 colPtrP[1] = (*coarseElementPDOFs)(coarseElement,3);
985 PP->insertGlobalValues((*fineElementPDOFs)(fineElement[3],3),colPtrP.view(0,nnz),valPtrP.view(0,nnz));
989 if ((coarseElement+1) % (nCoarseElements) == 0)
991 fineElement[0] = fineElement[3]+1;
992 fineElement[1] = fineElement[0]+1;
993 fineElement[2] = fineElement[0]+nFineElements;
994 fineElement[3] = fineElement[2]+1;
998 fineElement[0] = fineElement[1]+1;
999 fineElement[1] = fineElement[0]+1;
1000 fineElement[2] = fineElement[3]+1;
1001 fineElement[3] = fineElement[2]+1;
1008 for (GO VRow = 0; VRow < fNV; VRow++)
1010 Teuchos::ArrayView<const LO> colPtr;
1011 Teuchos::ArrayView<const SC> valPtr;
1013 PV->getGlobalRowView(VRow,colPtr,valPtr);
1016 P->insertGlobalValues(VRow,colPtr,valPtr);
1021 for (GO PRow = 0; PRow < fNP; PRow++)
1023 Teuchos::ArrayView<const LO> colPtr;
1024 Teuchos::ArrayView<const SC> valPtr;
1027 PP->getGlobalRowView(PRow,colPtr,valPtr);
1029 Teuchos::ArrayRCP<LO> newColPtr(colPtr.size(),nV);
1030 for (LO jj=0; jj<colPtr.size(); jj++)
1032 newColPtr[jj] += colPtr[jj];
1036 P->insertGlobalValues(PRow+fNV,newColPtr.view(0,colPtr.size()),valPtr);
1041 for (GO MRow = 0; MRow < fNM; MRow++)
1043 Teuchos::ArrayView<const LO> colPtr;
1044 Teuchos::ArrayView<const SC> valPtr;
1047 PM->getGlobalRowView(MRow,colPtr,valPtr);
1049 Teuchos::ArrayRCP<LO> newColPtr(colPtr.size(),nV+nP);
1050 for (LO jj=0; jj<colPtr.size(); jj++)
1052 newColPtr[jj] += colPtr[jj];
1056 P->insertGlobalValues(MRow+fNV+fNP,newColPtr.view(0,colPtr.size()),valPtr);
1067 PV->fillComplete(colMapforPV,rowMapforPV);
1068 PP->fillComplete(colMapforPP,rowMapforPP);
1069 PM->fillComplete(colMapforPM,rowMapforPM);
1073 Set(coarseLevel,
"PV",PV);
1074 Set(coarseLevel,
"PP",PP);
1075 Set(coarseLevel,
"PM",PM);
1076 Set(coarseLevel,
"P" ,P );
1078 Set(coarseLevel,
"NV",nV);
1079 Set(coarseLevel,
"NP",nP);
1080 Set(coarseLevel,
"NM",nM);