284 int numProcsCoarseSolve,
285 std::string underlyingLib){
289 using Teuchos::ScalarTraits;
292 TEUCHOS_TEST_FOR_EXCEPTION(!(M>=1),std::logic_error,
"H/h is to small.");
293 TEUCHOS_TEST_FOR_EXCEPTION(this->comm_.is_null(),std::runtime_error,
"comm_ is null.");
295 bool verbose (this->comm_->getRank() == 0);
297 setRankRange( numProcsCoarseSolve );
300 std::cout << std::endl;
303 int rank = this->comm_->getRank();
304 int size = this->comm_->getSize() - numProcsCoarseSolve;
312 vec2D_int_ptr_Type elementsVec;
313 vec_int_ptr_Type elementFlag;
315 if (FEType ==
"P0") {
316 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"implement P0.");
318 else if (FEType ==
"P1") {
319 nmbPoints_oneDir = N * (M+1) - (N-1);
320 nmbPoints = (M+1)*(M+1);
322 else if(FEType ==
"P2"){
323 nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1);
324 nmbPoints = (2*(M+1)-1)*(2*(M+1)-1);
327 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Wrong FE-Type, either P1 or P2.");
330 this->FEType_ = FEType;
332 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
334 this->numElementsGlob_ = 2*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1);
342 nmbElements = 2*(M)*(M);
346 if (FEType ==
"P1") {
348 std::cout <<
"-- H:"<<H <<
" h:" <<h <<
" --" << std::endl;
351 std::cout <<
"-- Building P1 Points Repeated ... " << std::endl;
354 this->pointsRep_.reset(
new vec2D_dbl_Type(nmbPoints,std::vector<double>(2,0.0)));
355 this->bcFlagRep_.reset(
new vec_int_Type (nmbPoints,0));
356 elementsVec = Teuchos::rcp(
new vec2D_int_Type(nmbElements,std::vector<int>(3,-1)));
357 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
360 int offset_x = (rank % N);
363 if ((rank % (N*N))>=N) {
364 offset_y = (int) (rank % (N*N))/(N);
367 for (
int s=0; s < M+1; s++) {
368 for (
int r=0; r < M+1; r++) {
369 (*this->pointsRep_)[counter][0] = r*h + offset_x * H;
370 if ((*this->pointsRep_)[counter][0]<100*ScalarTraits<SC>::eps() && (*this->pointsRep_)[counter][0]>-100*ScalarTraits<SC>::eps()) { (*this->pointsRep_)[counter][0]=0.0;}
371 (*this->pointsRep_)[counter][1] = s*h + offset_y * H;
372 if ((*this->pointsRep_)[counter][1]<100*ScalarTraits<SC>::eps() && (*this->pointsRep_)[counter][1]>-100*ScalarTraits<SC>::eps()) {(*this->pointsRep_)[counter][1]=0.0;}
373 pointsRepGlobMapping[counter] = r + s*nmbPoints_oneDir + offset_x*(M) + offset_y*(nmbPoints_oneDir)*M;
374 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-100*ScalarTraits<SC>::eps()) || (*this->pointsRep_)[counter][0] < (coorRec[0]+100*ScalarTraits<SC>::eps()) ||
375 (*this->pointsRep_)[counter][1] > (coorRec[1]+height-100*ScalarTraits<SC>::eps()) || (*this->pointsRep_)[counter][1] < (coorRec[1]+100*ScalarTraits<SC>::eps())) {
377 (*this->bcFlagRep_)[counter] = 1;
384 std::cout <<
" done! --" << std::endl;
388 std::cout <<
"-- Building P1 Repeated and Unique Map ... " << std::flush;
391 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
393 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
396 std::cout <<
" done! --" << std::endl;
400 std::cout <<
"-- Building P1 Unique Points ... " << std::flush;
403 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(2,0.0)));
404 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
406 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
408 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
410 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
411 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
412 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
415 std::cout <<
" done! --" << std::endl;
420 std::cout <<
"-- Building P1 Elements ... " << std::flush;
422 vec_int_ptr_Type elementFlag = Teuchos::rcp(
new vec_int_Type( elementsVec->size(),0 ) );
426 for (
int s=0; s < M; s++) {
427 for (
int r=0; r < M; r++) {
429 (*elementsVec)[counter][0] = r+1 + (M+1) * s;
430 (*elementsVec)[counter][1] = r + (M+1) * s ;
431 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1);
432 x_ref = ( this->pointsRep_->at( elementsVec->at(counter).at(0) ).at(0) + this->pointsRep_->at( elementsVec->at(counter).at(1) ).at(0) + this->pointsRep_->at( elementsVec->at(counter).at(2) ).at(0) ) / 3.;
433 y_ref = ( this->pointsRep_->at( elementsVec->at(counter).at(0) ).at(1) + this->pointsRep_->at( elementsVec->at(counter).at(1) ).at(1) + this->pointsRep_->at( elementsVec->at(counter).at(2) ).at(1) ) / 3.;
434 if ( x_ref>=0.3 && x_ref<=0.7) {
436 elementFlag->at(counter) = 1;
442 (*elementsVec)[counter][0] = r + (M+1) * (s+1);
443 (*elementsVec)[counter][1] = r + (M+1) * (s);
444 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1);
446 x_ref = ( this->pointsRep_->at( elementsVec->at(counter).at(0) ).at(0) + this->pointsRep_->at( elementsVec->at(counter).at(1) ).at(0) + this->pointsRep_->at( elementsVec->at(counter).at(2) ).at(0) ) / 3.;
447 y_ref = ( this->pointsRep_->at( elementsVec->at(counter).at(0) ).at(1) + this->pointsRep_->at( elementsVec->at(counter).at(1) ).at(1) + this->pointsRep_->at( elementsVec->at(counter).at(2) ).at(1) ) / 3.;
448 if ( x_ref>=0.3 && x_ref<=0.7) {
450 elementFlag->at(counter) = 1;
459 std::cout <<
" done! --" << std::endl;
466 else if(FEType ==
"P2"){
468 std::cout <<
"-- H:"<<H <<
" h:" <<h <<
" --" << std::endl;
471 std::cout <<
"-- Building P2 Points Repeated ... " << std::flush;
474 this->pointsRep_.reset(
new vec2D_dbl_Type(nmbPoints, vec_dbl_Type(2,0.0)));
475 this->bcFlagRep_.reset(
new vec_int_Type (nmbPoints,0));
476 elementsVec = Teuchos::rcp(
new vec2D_int_Type(nmbElements, vec_int_Type(6,-1)));
477 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
480 int offset_x = (rank % N);
483 if ((rank % (N*N))>=N) {
484 offset_y = (int) (rank % (N*N))/(N);
489 for (
int s=0; s < 2*(M+1)-1; s++) {
490 for (
int r=0; r < 2*(M+1)-1; r++) {
492 if (s%2==0 && r%2==0) {
497 (*this->pointsRep_)[counter][0] = r*h/2.0 + offset_x * H;
498 if ((*this->pointsRep_)[counter][0]<100*ScalarTraits<SC>::eps() && (*this->pointsRep_)[counter][0]>-100*ScalarTraits<SC>::eps()) (*this->pointsRep_)[counter][0]=0.0;
499 (*this->pointsRep_)[counter][1] = s*h/2.0 + offset_y * H;
500 if ((*this->pointsRep_)[counter][1]<100*ScalarTraits<SC>::eps() && (*this->pointsRep_)[counter][1]>-100*ScalarTraits<SC>::eps()) (*this->pointsRep_)[counter][1]=0.0;
502 pointsRepGlobMapping[counter] = r + s*nmbPoints_oneDir + offset_x*(2*(M+1)-2) + offset_y*(nmbPoints_oneDir)*(2*(M+1)-2) ;
504 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-100*ScalarTraits<SC>::eps()) || (*this->pointsRep_)[counter][0] < (coorRec[0]+100*ScalarTraits<SC>::eps()) ||
505 (*this->pointsRep_)[counter][1] > (coorRec[1]+height-100*ScalarTraits<SC>::eps()) || (*this->pointsRep_)[counter][1] < (coorRec[1]+100*ScalarTraits<SC>::eps())){
506 (*this->bcFlagRep_)[counter] = 1;
514 std::cout <<
" done! --" << std::endl;
517 std::cout <<
"-- Building P2 Repeated and Unique Map ... " << std::flush;
519 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
521 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
524 std::cout <<
" done! --" << std::endl;
528 std::cout <<
"-- Building P2 Unique Points ... " << std::flush;
531 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(2,0.0)));
532 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
535 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
537 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
539 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
540 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
541 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
545 std::cout <<
" done! --" << std::endl;
559 std::cout <<
"-- Building P2 Elements ... " << std::flush;
563 vec_int_ptr_Type elementFlag = Teuchos::rcp(
new vec_int_Type( elementsVec->size(),0 ) );
567 for (
int s=0; s < M; s++) {
568 for (
int r=0; r < M; r++) {
570 (*elementsVec)[counter][0] = 2*(r+1) + 2*P2M * (s) ;
571 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) ;
572 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) ;
574 (*elementsVec)[counter][3] = 2*(r) +1 + 2*P2M * (s) ;
575 (*elementsVec)[counter][4] = 2*(r) +1 + 2*P2M * (s) +P2M ;
576 (*elementsVec)[counter][5] = 2*(r+1) + 2*P2M * (s) +P2M ;
578 x_ref = ( this->pointsRep_->at( elementsVec->at(counter).at(0) ).at(0) + this->pointsRep_->at( elementsVec->at(counter).at(1) ).at(0) + this->pointsRep_->at( elementsVec->at(counter).at(2) ).at(0) ) / 3.;
579 y_ref = ( this->pointsRep_->at( elementsVec->at(counter).at(0) ).at(1) + this->pointsRep_->at( elementsVec->at(counter).at(1) ).at(1) + this->pointsRep_->at( elementsVec->at(counter).at(2) ).at(1) ) / 3.;
580 if ( x_ref>=0.3 && x_ref<=0.7) {
582 elementFlag->at(counter) = 1;
588 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s+1) ;
589 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) ;
590 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) ;
592 (*elementsVec)[counter][3] = 2*(r) + 2*P2M * (s) +P2M ;
593 (*elementsVec)[counter][4] = 2*(r) +1 + 2*P2M * (s) +P2M ;
594 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s+1) ;
596 x_ref = ( this->pointsRep_->at( elementsVec->at(counter).at(0) ).at(0) + this->pointsRep_->at( elementsVec->at(counter).at(1) ).at(0) + this->pointsRep_->at( elementsVec->at(counter).at(2) ).at(0) ) / 3.;
597 y_ref = ( this->pointsRep_->at( elementsVec->at(counter).at(0) ).at(1) + this->pointsRep_->at( elementsVec->at(counter).at(1) ).at(1) + this->pointsRep_->at( elementsVec->at(counter).at(2) ).at(1) ) / 3.;
598 if ( x_ref>=0.3 && x_ref<=0.7) {
600 elementFlag->at(counter) = 1;
612 std::cout <<
" done! --" << std::endl;
615 buildElementsClass(elementsVec, elementFlag);
623 int numProcsCoarseSolve,
624 std::string underlyingLib){
628 using Teuchos::ScalarTraits;
630 TEUCHOS_TEST_FOR_EXCEPTION(!(M>=1),std::logic_error,
"H/h is to small.");
631 TEUCHOS_TEST_FOR_EXCEPTION(this->comm_.is_null(),std::runtime_error,
"comm_ is null.");
633 bool verbose (this->comm_->getRank() == 0);
635 setRankRange( numProcsCoarseSolve );
638 std::cout << std::endl;
641 SC eps = ScalarTraits<SC>::eps();
643 int rank = this->comm_->getRank();
644 int size = this->comm_->getSize() - numProcsCoarseSolve;
653 if (FEType ==
"P0") {
654 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"implement P0.");
656 else if (FEType ==
"P1") {
657 nmbPoints_oneDir = N * (M+1) - (N-1);
658 nmbPoints = (M+1)*(M+1)*(M+1);
660 else if (FEType ==
"P2"){
661 nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1);
662 nmbPoints = (2*(M+1)-1)*(2*(M+1)-1)*(2*(M+1)-1);
664 else if (FEType ==
"P2-CR"){
665 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"P2-CR might not work properly.");
666 nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1);
667 nmbPoints = (2*(M+1)-1)*(2*(M+1)-1)*(2*(M+1)-1);
669 else if (FEType ==
"P1-disc" || FEType ==
"P1-disc-global"){
672 else if (FEType ==
"Q1"){
675 else if (FEType ==
"Q2"){
678 else if (FEType ==
"Q2-20"){
682 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Wrong FE-Type, only P1,P1-disc, P1-disc-global, P2, P2-CR, Q1, Q2, Q2-20.");
684 this->FEType_ = FEType;
686 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
688 this->numElementsGlob_ = 6*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1);
696 nmbElements = 6*M*M*M;
698 vec2D_int_ptr_Type elementsVec;
699 vec_int_ptr_Type elementFlag;
701 if (FEType ==
"P1") {
703 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
704 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
705 elementsVec = Teuchos::rcp(
new vec2D_int_Type( nmbElements, vec_int_Type(4, -1) ));
706 elementFlag = Teuchos::rcp(
new vec_int_Type( elementsVec->size(),0 ) );
707 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
710 int offset_x = (rank % N);
714 if ((rank % (N*N))>=N) {
715 offset_y = (int) (rank % (N*N))/(N);
718 if ((rank % (N*N*N))>=N*N ) {
719 offset_z = (int) (rank % (N*N*N))/(N*(N));
722 for (
int t=0; t < M+1; t++) {
723 for (
int s=0; s < M+1; s++) {
724 for (
int r=0; r < M+1; r++) {
725 (*this->pointsRep_)[counter][0] = r*h + offset_x * H;
726 if ((*this->pointsRep_)[counter][0]<eps && (*this->pointsRep_)[counter][0]>-eps) (*this->pointsRep_)[counter][0]=0.0;
728 (*this->pointsRep_)[counter][1] = s*h + offset_y * H;
729 if ((*this->pointsRep_)[counter][1]<eps && (*this->pointsRep_)[counter][1]>-eps) (*this->pointsRep_)[counter][1]=0.0;
731 (*this->pointsRep_)[counter][2] = t*h + offset_z * H;
732 if ((*this->pointsRep_)[counter][2]<eps && (*this->pointsRep_)[counter][2]>-eps) (*this->pointsRep_)[counter][2]=0.0;
734 pointsRepGlobMapping[counter] = r + s*nmbPoints_oneDir + t*nmbPoints_oneDir*nmbPoints_oneDir \
735 + offset_x*(M) + offset_y*(nmbPoints_oneDir)*M + offset_z*(nmbPoints_oneDir)*(nmbPoints_oneDir)*M ;
737 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[counter][0] < (coorRec[0]+eps) ||
738 (*this->pointsRep_)[counter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[counter][1] < (coorRec[1]+eps) ||
739 (*this->pointsRep_)[counter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[counter][2] < (coorRec[2]+eps) ) {
741 (*this->bcFlagRep_)[counter] = 1;
749 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
751 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
753 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(3,0.0)));
754 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
756 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
758 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
760 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
761 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
762 (*this->pointsUni_)[i][2] = (*this->pointsRep_)[index][2];
763 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
767 for (
int t=0; t < M; t++) {
768 for (
int s=0; s < M; s++) {
769 for (
int r=0; r < M; r++) {
770 (*elementsVec)[counter][0] = r+1 + (M+1) * s + (M+1)*(M+1) * t ;
771 (*elementsVec)[counter][1] = r + (M+1) * s + (M+1)*(M+1) * t ;
772 (*elementsVec)[counter][2] = r+1 + (M+1) * s + (M+1)*(M+1) * (t+1) ;
773 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
775 (*elementsVec)[counter][0] = r + (M+1) * s + (M+1)*(M+1) * (t+1) ;
776 (*elementsVec)[counter][1] = r + (M+1) * s + (M+1)*(M+1) * t ;
777 (*elementsVec)[counter][2] = r+1 + (M+1) * s + (M+1)*(M+1) * (t+1) ;
778 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
780 (*elementsVec)[counter][0] = r+1 + (M+1) * s + (M+1)*(M+1) * t ;
781 (*elementsVec)[counter][1] = r + (M+1) * s + (M+1)*(M+1) * t ;
782 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * t ;
783 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
785 (*elementsVec)[counter][0] = r + (M+1) * s + (M+1)*(M+1) * t ;
786 (*elementsVec)[counter][1] = r + (M+1) * (s+1) + (M+1)*(M+1) * t ;
787 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * t ;
788 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
790 (*elementsVec)[counter][0] = r + (M+1) * s + (M+1)*(M+1) * t ;
791 (*elementsVec)[counter][1] = r + (M+1) * (s+1) + (M+1)*(M+1) * t ;
792 (*elementsVec)[counter][2] = r + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
793 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
795 (*elementsVec)[counter][0] = r + (M+1) * s + (M+1)*(M+1) * t ;
796 (*elementsVec)[counter][1] = r + (M+1) * s + (M+1)*(M+1) * (t+1) ;
797 (*elementsVec)[counter][2] = r + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
798 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
803 buildElementsClass(elementsVec, elementFlag);
806 else if(FEType ==
"P2"){
808 this->pointsRep_.reset(
new vec2D_dbl_Type(nmbPoints, vec_dbl_Type(3, 0.0)));
809 this->bcFlagRep_.reset(
new vec_int_Type (nmbPoints, 0));
810 elementsVec = Teuchos::rcp(
new vec2D_int_Type(nmbElements, vec_int_Type(10, -1)));
811 elementFlag = Teuchos::rcp(
new vec_int_Type( elementsVec->size(),0 ) );
812 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
815 int offset_x = (rank % N);
819 if ((rank % (N*N))>=N) {
820 offset_y = (int) (rank % (N*N))/(N);
823 if ((rank % (N*N*N))>=N*N ) {
824 offset_z = (int) (rank % (N*N*N))/(N*(N));
830 for (
int t=0; t < 2*(M+1)-1; t++) {
831 for (
int s=0; s < 2*(M+1)-1; s++) {
832 for (
int r=0; r < 2*(M+1)-1; r++) {
834 if (s%2==0 && r%2==0 && t%2==0) {
840 (*this->pointsRep_)[counter][0] = r*h/2.0 + offset_x * H;
841 if ((*this->pointsRep_)[counter][0]<eps && (*this->pointsRep_)[counter][0]>-eps) (*this->pointsRep_)[counter][0]=0.0;
842 (*this->pointsRep_)[counter][1] = s*h/2.0 + offset_y * H;
843 if ((*this->pointsRep_)[counter][1]<eps && (*this->pointsRep_)[counter][1]>-eps) (*this->pointsRep_)[counter][1]=0.0;
844 (*this->pointsRep_)[counter][2] = t*h/2.0 + offset_z * H;
845 if ((*this->pointsRep_)[counter][2]<eps && (*this->pointsRep_)[counter][2]>-eps) (*this->pointsRep_)[counter][2]=0.0;
847 pointsRepGlobMapping[counter] = r + s*nmbPoints_oneDir + t*nmbPoints_oneDir*nmbPoints_oneDir \
848 + offset_x*(2*(M+1)-2) + offset_y*(nmbPoints_oneDir)*(2*(M+1)-2) + offset_z*(nmbPoints_oneDir)*(nmbPoints_oneDir)*(2*(M+1)-2) ;
850 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[counter][0] < (coorRec[0]+eps) ||
851 (*this->pointsRep_)[counter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[counter][1] < (coorRec[1]+eps) ||
852 (*this->pointsRep_)[counter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[counter][2] < (coorRec[2]+eps) ) {
853 (*this->bcFlagRep_)[counter] = 1;
862 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
864 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
866 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(3,0.0)));
867 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
869 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
870 (*this->pointsUni_)[i][0] = (this->mapUnique_->getGlobalElement(i) % nmbPoints_oneDir) * h/2;
871 if ((*this->pointsUni_)[i][0]<eps && (*this->pointsUni_)[i][0]>-eps) (*this->pointsUni_)[i][0]=0.0;
873 (*this->pointsUni_)[i][1] = ((
int) ((this->mapUnique_->getGlobalElement(i) % (nmbPoints_oneDir*nmbPoints_oneDir)) / nmbPoints_oneDir) + eps) *h/2;
874 if ((*this->pointsUni_)[i][1]<eps && (*this->pointsUni_)[i][1]>-eps) (*this->pointsUni_)[i][1]=0.0;
876 (*this->pointsUni_)[i][2] = ((
int)(this->mapUnique_->getGlobalElement(i) / (nmbPoints_oneDir*nmbPoints_oneDir) + eps)) * h/2;
877 if ((*this->pointsUni_)[i][2]<eps && (*this->pointsUni_)[i][2]>-eps) (*this->pointsUni_)[i][2]=0.0;
879 if ((*this->pointsUni_)[i][0] > (coorRec[0]+length-eps) || (*this->pointsUni_)[i][0] < (coorRec[0]+eps) ||
880 (*this->pointsUni_)[i][1] > (coorRec[1]+width-eps) || (*this->pointsUni_)[i][1] < (coorRec[1]+eps) ||
881 (*this->pointsUni_)[i][2] > (coorRec[2]+height-eps) || (*this->pointsUni_)[i][2] < (coorRec[2]+eps) ) {
882 (*this->bcFlagUni_)[i] = 1;
900 for (
int t=0; t < M; t++) {
901 for (
int s=0; s < M; s++) {
902 for (
int r=0; r < M; r++) {
904 (*elementsVec)[counter][0] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
905 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
906 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
907 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
909 (*elementsVec)[counter][4] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) ;
910 (*elementsVec)[counter][6] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M;
911 (*elementsVec)[counter][7] = 2*(r+1) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M;
912 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M;
913 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M;
914 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t+1);
918 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
919 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
920 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
921 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
923 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M ;
924 (*elementsVec)[counter][6] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
925 (*elementsVec)[counter][7] = 2*(r) +1 + 2*P2M * (s)+P2M + 2*P2M*P2M * (t+1) ;
926 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M ;
927 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) +P2M*P2M ;
928 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t+1);
932 (*elementsVec)[counter][0] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
933 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
934 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
935 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
937 (*elementsVec)[counter][4] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) ;
938 (*elementsVec)[counter][6] = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) ;
939 (*elementsVec)[counter][7] = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) +P2M*P2M ;
940 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) ;
941 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) +P2M*P2M ;
942 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
946 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
947 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
948 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
949 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
951 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) ;
952 (*elementsVec)[counter][6] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) ;
953 (*elementsVec)[counter][7] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
954 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s+1) + 2*P2M*P2M * (t);
955 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
956 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
960 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
961 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
962 (*elementsVec)[counter][2] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
963 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
965 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) ;
966 (*elementsVec)[counter][6] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
967 (*elementsVec)[counter][7] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
968 (*elementsVec)[counter][5] = 2*(r) + 2*P2M*(s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
969 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M*(s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
970 (*elementsVec)[counter][9] = 2*(r) +1 + 2*P2M*(s+1) + 2*P2M*P2M * (t+1) ;
974 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
975 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
976 (*elementsVec)[counter][2] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
977 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
979 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M ;
980 (*elementsVec)[counter][6] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
981 (*elementsVec)[counter][7] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
982 (*elementsVec)[counter][5] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t+1) ;
983 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t+1) ;
984 (*elementsVec)[counter][9] = 2*(r) +1 + 2*P2M*(s+1) + 2*P2M*P2M * (t+1) ;
991 buildElementsClass(elementsVec, elementFlag);
993 else if(FEType ==
"P1-disc" || FEType ==
"P1-disc-global")
995 else if(FEType ==
"Q1"){
998 else if(FEType ==
"Q2"){
1001 else if(FEType ==
"Q2-20"){
1012 int numProcsCoarseSolve,
1013 std::string underlyingLib){
1017 using Teuchos::ScalarTraits;
1020 bool verbose (this->comm_->getRank() == 0);
1022 setRankRange( numProcsCoarseSolve );
1025 std::cout << std::endl;
1027 SC eps = ScalarTraits<SC>::eps();
1029 int rank = this->comm_->getRank();
1030 int size = this->comm_->getSize() - numProcsCoarseSolve;
1032 SC h = length/(M*N);
1035 LO nmbPoints_oneDir;
1038 LO nmbPoints = 4*M*M*M;
1041 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
1043 this->numElementsGlob_ = (nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1);
1051 nmbElements = M*M*M;
1056 int offset_x = (rank % N);
1060 if ((rank % (N*N))>=N) {
1061 offset_y = (int) (rank % (N*N))/(N);
1064 if ((rank % (N*N*N))>=N*N ) {
1065 offset_z = (int) (rank % (N*N*N))/(N*(N));
1069 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
1070 this->pointsUni_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
1071 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
1072 this->bcFlagUni_.reset(
new std::vector<int> (nmbPoints,0));
1073 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
1077 std::cout <<
"-- Building P1-disc Points and Elements according to Q2 ... " << std::flush;
1079 vec2D_int_ptr_Type elementsVec = Teuchos::rcp(
new vec2D_int_Type(nmbElements, vec_int_Type(4, -1)));
1083 GO globalCounterPoints = rank * nmbPoints;
1084 for (
int t=0; t < M; t++) {
1085 for (
int s=0; s < M; s++) {
1086 for (
int r=0; r < M; r++) {
1089 (*this->pointsRep_)[pCounter][0] = r*h + offset_x * H;
1090 (*this->pointsRep_)[pCounter][1] = s*h + offset_y * H;
1091 (*this->pointsRep_)[pCounter][2] = t*h + offset_z * H;
1092 if ((*this->pointsRep_)[pCounter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[pCounter][0] < (coorRec[0]+eps) ||
1093 (*this->pointsRep_)[pCounter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[pCounter][1] < (coorRec[1]+eps) ||
1094 (*this->pointsRep_)[pCounter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[pCounter][2] < (coorRec[2]+eps) ) {
1096 (*this->bcFlagRep_)[counter] = 1;
1099 (*this->pointsUni_)[pCounter][0] = (*this->pointsRep_)[pCounter][0];
1100 (*this->pointsUni_)[pCounter][1] = (*this->pointsRep_)[pCounter][1];
1101 (*this->pointsUni_)[pCounter][2] = (*this->pointsRep_)[pCounter][2];
1103 (*this->bcFlagUni_)[pCounter] = (*this->bcFlagRep_)[pCounter];
1105 (*elementsVec)[counter][0] = pCounter;
1106 pointsRepGlobMapping[pCounter] = globalCounterPoints;
1107 globalCounterPoints++;
1111 (*this->pointsRep_)[pCounter][0] = (r+1)*h + offset_x * H;
1112 (*this->pointsRep_)[pCounter][1] = s*h + offset_y * H;
1113 (*this->pointsRep_)[pCounter][2] = t*h + offset_z * H;
1114 if ((*this->pointsRep_)[pCounter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[pCounter][0] < (coorRec[0]+eps) ||
1115 (*this->pointsRep_)[pCounter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[pCounter][1] < (coorRec[1]+eps) ||
1116 (*this->pointsRep_)[pCounter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[pCounter][2] < (coorRec[2]+eps) ) {
1118 (*this->bcFlagRep_)[counter] = 1;
1121 (*this->pointsUni_)[pCounter][0] = (*this->pointsRep_)[pCounter][0];
1122 (*this->pointsUni_)[pCounter][1] = (*this->pointsRep_)[pCounter][1];
1123 (*this->pointsUni_)[pCounter][2] = (*this->pointsRep_)[pCounter][2];
1125 (*this->bcFlagUni_)[pCounter] = (*this->bcFlagRep_)[pCounter];
1127 (*elementsVec)[counter][1] = pCounter;
1128 pointsRepGlobMapping[pCounter] = globalCounterPoints;
1129 globalCounterPoints++;
1132 (*this->pointsRep_)[pCounter][0] = r*h + offset_x * H;
1133 (*this->pointsRep_)[pCounter][1] = (s+1)*h + offset_y * H;
1134 (*this->pointsRep_)[pCounter][2] = t*h + offset_z * H;
1135 if ((*this->pointsRep_)[pCounter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[pCounter][0] < (coorRec[0]+eps) ||
1136 (*this->pointsRep_)[pCounter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[pCounter][1] < (coorRec[1]+eps) ||
1137 (*this->pointsRep_)[pCounter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[pCounter][2] < (coorRec[2]+eps) ) {
1139 (*this->bcFlagRep_)[counter] = 1;
1142 (*this->pointsUni_)[pCounter][0] = (*this->pointsRep_)[pCounter][0];
1143 (*this->pointsUni_)[pCounter][1] = (*this->pointsRep_)[pCounter][1];
1144 (*this->pointsUni_)[pCounter][2] = (*this->pointsRep_)[pCounter][2];
1146 (*this->bcFlagUni_)[pCounter] = (*this->bcFlagRep_)[pCounter];
1148 (*elementsVec)[counter][2] = pCounter;
1149 pointsRepGlobMapping[pCounter] = globalCounterPoints;
1150 globalCounterPoints++;
1154 (*this->pointsRep_)[pCounter][0] = r*h + offset_x * H;
1155 (*this->pointsRep_)[pCounter][1] = s*h + offset_y * H;
1156 (*this->pointsRep_)[pCounter][2] = (t+1)*h + offset_z * H;
1157 if ((*this->pointsRep_)[pCounter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[pCounter][0] < (coorRec[0]+eps) ||
1158 (*this->pointsRep_)[pCounter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[pCounter][1] < (coorRec[1]+eps) ||
1159 (*this->pointsRep_)[pCounter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[pCounter][2] < (coorRec[2]+eps) ) {
1161 (*this->bcFlagRep_)[counter] = 1;
1164 (*this->pointsUni_)[pCounter][0] = (*this->pointsRep_)[pCounter][0];
1165 (*this->pointsUni_)[pCounter][1] = (*this->pointsRep_)[pCounter][1];
1166 (*this->pointsUni_)[pCounter][2] = (*this->pointsRep_)[pCounter][2];
1168 (*this->bcFlagUni_)[pCounter] = (*this->bcFlagRep_)[pCounter];
1170 (*elementsVec)[counter][3] = pCounter;
1171 pointsRepGlobMapping[pCounter] = globalCounterPoints;
1172 globalCounterPoints++;
1179 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
1181 this->mapUnique_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
1183 buildElementsClass(elementsVec);
1186 std::cout <<
"done!" << std::endl;
1317 int numProcsCoarseSolve,
1318 std::string underlyingLib)
1323 using Teuchos::ScalarTraits;
1325 bool verbose (this->comm_->getRank() == 0);
1328 std::cout << std::endl;
1330 setRankRange( numProcsCoarseSolve );
1332 SC eps = ScalarTraits<SC>::eps();
1334 int rank = this->comm_->getRank();
1335 int size = this->comm_->getSize() - numProcsCoarseSolve;
1337 SC h = length/(M*N);
1342 LO nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1);
1343 LO nmbPoints = (2*(M+1)-1)*(2*(M+1)-1)*(2*(M+1)-1);
1345 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
1347 this->numElementsGlob_ = (nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1);
1355 nmbElements = M*M*M;
1358 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
1359 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
1360 vec2D_int_ptr_Type elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements,std::vector<int>(27,-1)));
1361 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
1364 int offset_x = (rank % N);
1368 if ((rank % (N*N))>=N) {
1369 offset_y = (int) (rank % (N*N))/(N);
1372 if ((rank % (N*N*N))>=N*N ) {
1373 offset_z = (int) (rank % (N*N*N))/(N*(N));
1379 for (
int t=0; t < 2*(M+1)-1; t++) {
1380 for (
int s=0; s < 2*(M+1)-1; s++) {
1381 for (
int r=0; r < 2*(M+1)-1; r++) {
1383 if (s%2==0 && r%2==0 && t%2==0) {
1389 (*this->pointsRep_)[counter][0] = r*h/2.0 + offset_x * H;
1390 if ((*this->pointsRep_)[counter][0]<eps && (*this->pointsRep_)[counter][0]>-eps) (*this->pointsRep_)[counter][0]=0.0;
1391 (*this->pointsRep_)[counter][1] = s*h/2.0 + offset_y * H;
1392 if ((*this->pointsRep_)[counter][1]<eps && (*this->pointsRep_)[counter][1]>-eps) (*this->pointsRep_)[counter][1]=0.0;
1393 (*this->pointsRep_)[counter][2] = t*h/2.0 + offset_z * H;
1394 if ((*this->pointsRep_)[counter][2]<eps && (*this->pointsRep_)[counter][2]>-eps) (*this->pointsRep_)[counter][2]=0.0;
1396 pointsRepGlobMapping[counter] = r + s*nmbPoints_oneDir + t*nmbPoints_oneDir*nmbPoints_oneDir \
1397 + offset_x*(2*(M+1)-2) + offset_y*(nmbPoints_oneDir)*(2*(M+1)-2) + offset_z*(nmbPoints_oneDir)*(nmbPoints_oneDir)*(2*(M+1)-2) ;
1399 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[counter][0] < (coorRec[0]+eps) ||
1400 (*this->pointsRep_)[counter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[counter][1] < (coorRec[1]+eps) ||
1401 (*this->pointsRep_)[counter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[counter][2] < (coorRec[2]+eps) ) {
1402 (*this->bcFlagRep_)[counter] = 1;
1411 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
1413 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
1415 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(3,0.0)));
1416 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
1418 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
1419 (*this->pointsUni_)[i][0] = (this->mapUnique_->getGlobalElement(i) % nmbPoints_oneDir) * h/2;
1420 if ((*this->pointsUni_)[i][0]<eps && (*this->pointsUni_)[i][0]>-eps) (*this->pointsUni_)[i][0]=0.0;
1422 (*this->pointsUni_)[i][1] = ((
int) ((this->mapUnique_->getGlobalElement(i) % (nmbPoints_oneDir*nmbPoints_oneDir)) / nmbPoints_oneDir) + eps) *h/2;
1423 if ((*this->pointsUni_)[i][1]<eps && (*this->pointsUni_)[i][1]>-eps) (*this->pointsUni_)[i][1]=0.0;
1425 (*this->pointsUni_)[i][2] = ((
int)(this->mapUnique_->getGlobalElement(i) / (nmbPoints_oneDir*nmbPoints_oneDir) + eps)) * h/2;
1426 if ((*this->pointsUni_)[i][2]<eps && (*this->pointsUni_)[i][2]>-eps) (*this->pointsUni_)[i][2]=0.0;
1428 if ((*this->pointsUni_)[i][0] > (coorRec[0]+length-eps) || (*this->pointsUni_)[i][0] < (coorRec[0]+eps) ||
1429 (*this->pointsUni_)[i][1] > (coorRec[1]+width-eps) || (*this->pointsUni_)[i][1] < (coorRec[1]+eps) ||
1430 (*this->pointsUni_)[i][2] > (coorRec[2]+height-eps) || (*this->pointsUni_)[i][2] < (coorRec[2]+eps) ) {
1431 (*this->bcFlagUni_)[i] = 1;
1436 int P2M = 2*(M+1)-1;
1439 for (
int t=0; t < M; t++) {
1440 for (
int s=0; s < M; s++) {
1441 for (
int r=0; r < M; r++) {
1443 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
1444 (*elementsVec)[counter][1] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
1445 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
1446 (*elementsVec)[counter][3] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
1448 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
1449 (*elementsVec)[counter][5] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
1450 (*elementsVec)[counter][6] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
1451 (*elementsVec)[counter][7] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
1453 (*elementsVec)[counter][8] = 2*(r)+1 + 2*P2M * (s) + 2*P2M*P2M * (t) ;
1454 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) ;
1455 (*elementsVec)[counter][10] = 2*(r)+1 + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
1456 (*elementsVec)[counter][11] = 2*(r) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) ;
1458 (*elementsVec)[counter][12] = 2*(r)+1 + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
1459 (*elementsVec)[counter][13] = 2*(r+1) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t+1) ;
1460 (*elementsVec)[counter][14] = 2*(r)+1 + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
1461 (*elementsVec)[counter][15] = 2*(r) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t+1) ;
1463 (*elementsVec)[counter][16] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) + P2M*P2M;
1464 (*elementsVec)[counter][17] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) + P2M*P2M;
1465 (*elementsVec)[counter][18] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) + P2M*P2M;
1466 (*elementsVec)[counter][19] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) + P2M*P2M;
1468 (*elementsVec)[counter][20] = 2*(r)+1 + 2*P2M * (s) + 2*P2M*P2M * (t) + P2M*P2M;
1469 (*elementsVec)[counter][21] = 2*(r+1) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) + P2M*P2M;
1470 (*elementsVec)[counter][22] = 2*(r)+1 + 2*P2M * (s+1) + 2*P2M*P2M * (t) + P2M*P2M;
1471 (*elementsVec)[counter][23] = 2*(r) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) + P2M*P2M;
1473 (*elementsVec)[counter][24] = 2*(r)+1 + 2*P2M * (s) + P2M + 2*P2M*P2M * (t);
1474 (*elementsVec)[counter][25] = 2*(r)+1 + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) + P2M*P2M;
1475 (*elementsVec)[counter][26] = 2*(r)+1 + 2*P2M * (s) + P2M + 2*P2M*P2M * (t+1);
1481 buildElementsClass(elementsVec);
1528 int numProcsCoarseSolve,
1529 std::string underlyingLib)
1534 using Teuchos::ScalarTraits;
1536 bool verbose (this->comm_->getRank() == 0);
1538 setRankRange( numProcsCoarseSolve );
1541 std::cout << std::endl;
1543 std::cout <<
"WARNING! Not working properly in parallel - fix global indexing." << std::endl;
1545 SC eps = ScalarTraits<SC>::eps();
1547 int rank = this->comm_->getRank();
1548 int size = this->comm_->getSize() - numProcsCoarseSolve;
1550 SC h = length/(M*N);
1555 LO nmbPoints_oneDirFull = N * (2*(M+1)-1) - (N-1);
1556 LO nmbPoints_oneDirMid = N * (M+1) - (N-1);
1558 LO nmbPoints = ( (M+1) * (2*(M+1)-1) + M * (M+1) ) * (M+1) +
1559 ( (M+1) * (M+1) ) * M;
1561 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
1563 this->numElementsGlob_ = (nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1);
1571 nmbElements = M*M*M;
1574 this->pointsRep_.reset(
new std::vector<std::vector<double> >(0));
1575 this->bcFlagRep_.reset(
new std::vector<int> (0));
1576 vec2D_int_ptr_Type elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements, std::vector<int>(20,-1)));
1577 Teuchos::Array<GO> pointsRepGlobMapping(0);
1580 int offset_x = (rank % N);
1584 if ((rank % (N*N))>=N) {
1585 offset_y = (int) (rank % (N*N))/(N);
1588 if ((rank % (N*N*N))>=N*N ) {
1589 offset_z = (int) (rank % (N*N*N))/(N*(N));
1592 for (
int t=0; t < 2*(M+1)-1; t++) {
1593 for (
int s=0; s < 2*(M+1)-1; s++) {
1595 for (
int r=0; r < 2*(M+1)-1; r++) {
1596 GO index = globalID_Q2_20Cube( r, s, t, rr, offset_x, offset_y, offset_z, M, N,
1597 nmbPoints_oneDirFull, nmbPoints_oneDirMid );
1600 std::vector<double> p(3,0.0);
1601 p[0] = r*h/2.0 + offset_x * H;
1602 p[1] = s*h/2.0 + offset_y * H;
1603 p[2] = t*h/2.0 + offset_z * H;
1604 this->pointsRep_->push_back(p);
1605 pointsRepGlobMapping.push_back( index );
1607 if (p[0] > (coorRec[0]+length-eps) || p[0] < (coorRec[0]+eps) ||
1608 p[1] > (coorRec[1]+width-eps) || p[1] < (coorRec[1]+eps) ||
1609 p[2] > (coorRec[2]+height-eps) || p[2] < (coorRec[2]+eps) )
1610 this->bcFlagRep_->push_back(1);
1612 this->bcFlagRep_->push_back(0);
1619 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
1621 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
1623 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(3,0.0)));
1624 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
1626 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
1628 LO index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
1630 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
1631 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
1632 (*this->pointsUni_)[i][2] = (*this->pointsRep_)[index][2];
1633 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
1636 int P2M = 2*(M+1)-1;
1639 for (
int t=0; t < M; t++) {
1640 for (
int s=0; s < M; s++) {
1641 for (
int r=0; r < M; r++) {
1643 (*elementsVec)[counter][0] = 2*(r) + (P2M+P1M) * (s) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) ;
1644 (*elementsVec)[counter][1] = 2*(r+1) + (P2M+P1M) * (s) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) ;
1645 (*elementsVec)[counter][2] = 2*(r+1) + (P2M+P1M) * (s+1) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) ;
1646 (*elementsVec)[counter][3] = 2*(r) + (P2M+P1M) * (s+1) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) ;
1648 (*elementsVec)[counter][4] = 2*(r) + (P2M+P1M) * (s) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t+1) ;
1649 (*elementsVec)[counter][5] = 2*(r+1) + (P2M+P1M) * (s) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t+1) ;
1650 (*elementsVec)[counter][6] = 2*(r+1) + (P2M+P1M) * (s+1) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t+1) ;
1651 (*elementsVec)[counter][7] = 2*(r) + (P2M+P1M) * (s+1) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t+1) ;
1653 (*elementsVec)[counter][8] = 2*(r)+1 + (P2M+P1M) * (s) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) ;
1654 (*elementsVec)[counter][9] = (r+1) + (P2M+P1M) * (s) + P2M + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) ;
1655 (*elementsVec)[counter][10] = 2*(r)+1 + (P2M+P1M) * (s+1) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) ;
1656 (*elementsVec)[counter][11] = r + (P2M+P1M) * (s) + P2M + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) ;
1658 (*elementsVec)[counter][12] = 2*(r)+1 + (P2M+P1M) * (s) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t+1) ;
1659 (*elementsVec)[counter][13] = (r+1) + (P2M+P1M) * (s) + P2M + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t+1) ;
1660 (*elementsVec)[counter][14] = 2*(r)+1 + (P2M+P1M) * (s+1) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t+1) ;
1661 (*elementsVec)[counter][15] = r + (P2M+P1M) * (s) + P2M + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t+1) ;
1663 (*elementsVec)[counter][16] = (r) + (P1M) * (s) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) + P2M*(M+1)+P1M*M;
1664 (*elementsVec)[counter][17] = (r+1) + (P1M) * (s) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) + P2M*(M+1)+P1M*M;
1665 (*elementsVec)[counter][18] = (r+1) + (P1M) * (s+1) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) + P2M*(M+1)+P1M*M;
1666 (*elementsVec)[counter][19] = r + (P1M) * (s+1) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) + P2M*(M+1)+P1M*M;
1678 int numProcsCoarseSolve,
1679 std::string underlyingLib){
1683 using Teuchos::ScalarTraits;
1685 typedef ScalarTraits<SC> ST;
1688 bool verbose (this->comm_->getRank() == 0);
1690 setRankRange( numProcsCoarseSolve );
1692 int rank = this->comm_->getRank();
1693 int size = this->comm_->getSize() - numProcsCoarseSolve;
1695 int bfs_multiplier = (int) 2*(length)-1;
1697 int nmbSubdomainsSquares = size / bfs_multiplier;
1698 int nmbSubdomainsSquares_OneDir = (std::pow(nmbSubdomainsSquares,1./3.) + 100*eps);
1700 SC h = ST::one()/(M*N);
1704 LO nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1);
1705 LO nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1) ;
1706 LO nmbPoints = (2*(M+1)-1)*(2*(M+1)-1)*(2*(M+1)-1);
1709 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
1710 this->numElementsGlob_ = (nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1) * bfs_multiplier;
1718 nmbElements = M*M*M;
1721 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
1722 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
1723 vec2D_int_ptr_Type elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements, std::vector<int>(27,-1)));
1724 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
1726 int whichSquareSet = (int)rank / nmbSubdomainsSquares;
1728 int offset_Squares_x = (int) (whichSquareSet+1) / 2;
1729 int offset_Squares_y = 0;
1730 int offset_Squares_z = ((whichSquareSet+1) % 2);
1733 int offset_x = ((rank - nmbSubdomainsSquares*whichSquareSet) % N);
1736 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))>=N) {
1737 offset_y = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))/(N);
1740 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))>=N*N ) {
1741 offset_z = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))/(N*(N));
1744 for (
int t=0; t < 2*(M+1)-1; t++) {
1745 for (
int s=0; s < 2*(M+1)-1; s++) {
1746 for (
int r=0; r < 2*(M+1)-1; r++) {
1748 (*this->pointsRep_)[counter][0] = coorRec[0] + r*h/2. + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
1750 (*this->pointsRep_)[counter][1] = coorRec[1] + s*h/2. + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
1752 (*this->pointsRep_)[counter][2] = coorRec[2] + t*h/2. + offset_z * H + offset_Squares_z * H * nmbSubdomainsSquares_OneDir;
1754 pointsRepGlobMapping[counter] = r
1755 + s*(nmbPoints_oneDir_allSubdomain);
1756 if (offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
1757 pointsRepGlobMapping[counter] -= s*(nmbPoints_oneDir-1);
1759 else if(offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=2*M){
1760 pointsRepGlobMapping[counter] -= s*(nmbPoints_oneDir-1);
1763 pointsRepGlobMapping[counter] += t*nmbPoints_oneDir_allSubdomain*nmbPoints_oneDir;
1764 if (offset_Squares_x > 0 && offset_Squares_z == 0 ) {
1765 pointsRepGlobMapping[counter] -= t*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
1768 pointsRepGlobMapping[counter] += offset_x*(2*M)
1769 + offset_y*( nmbPoints_oneDir_allSubdomain * 2*M );
1770 if (offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
1771 pointsRepGlobMapping[counter] -= offset_y*2*M*(nmbPoints_oneDir-1);
1773 else if(offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=2*M){
1774 pointsRepGlobMapping[counter] -= offset_y*2*M*(nmbPoints_oneDir-1);
1777 pointsRepGlobMapping[counter] += offset_z * 2*M * nmbPoints_oneDir_allSubdomain * nmbPoints_oneDir;
1778 if (offset_Squares_x > 0 && offset_Squares_z == 0 ) {
1779 pointsRepGlobMapping[counter] -= offset_z*2*M*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
1782 pointsRepGlobMapping[counter] += offset_Squares_x * 2*M * nmbSubdomainsSquares_OneDir;
1783 if (offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
1784 pointsRepGlobMapping[counter] -= 2*M * nmbSubdomainsSquares_OneDir;
1786 else if(offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=2*M){
1787 pointsRepGlobMapping[counter] -= 2*M * nmbSubdomainsSquares_OneDir;
1790 pointsRepGlobMapping[counter] += offset_Squares_z * nmbPoints_oneDir_allSubdomain * ((2*M) * nmbSubdomainsSquares_OneDir+1) * 2*M * nmbSubdomainsSquares_OneDir;
1791 if (offset_Squares_z > 0 ) {
1792 pointsRepGlobMapping[counter] -= (nmbPoints_oneDir-1)*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
1799 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
1801 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
1804 std::cout <<
"-- Building Q2 Unique Points ... " << std::flush;
1806 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(3,0.0)));
1807 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
1810 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
1812 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
1814 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
1815 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
1816 (*this->pointsUni_)[i][2] = (*this->pointsRep_)[index][2];
1817 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
1821 std::cout <<
" done! --" << std::endl;
1823 int P2M = 2*(M+1)-1;
1826 for (
int t=0; t < M; t++) {
1827 for (
int s=0; s < M; s++) {
1828 for (
int r=0; r < M; r++) {
1830 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
1831 (*elementsVec)[counter][1] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
1832 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
1833 (*elementsVec)[counter][3] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
1835 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
1836 (*elementsVec)[counter][5] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
1837 (*elementsVec)[counter][6] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
1838 (*elementsVec)[counter][7] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
1840 (*elementsVec)[counter][8] = 2*(r)+1 + 2*P2M * (s) + 2*P2M*P2M * (t) ;
1841 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) ;
1842 (*elementsVec)[counter][10] = 2*(r)+1 + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
1843 (*elementsVec)[counter][11] = 2*(r) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) ;
1845 (*elementsVec)[counter][12] = 2*(r)+1 + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
1846 (*elementsVec)[counter][13] = 2*(r+1) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t+1) ;
1847 (*elementsVec)[counter][14] = 2*(r)+1 + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
1848 (*elementsVec)[counter][15] = 2*(r) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t+1) ;
1850 (*elementsVec)[counter][16] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) + P2M*P2M;
1851 (*elementsVec)[counter][17] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) + P2M*P2M;
1852 (*elementsVec)[counter][18] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) + P2M*P2M;
1853 (*elementsVec)[counter][19] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) + P2M*P2M;
1855 (*elementsVec)[counter][20] = 2*(r)+1 + 2*P2M * (s) + 2*P2M*P2M * (t) + P2M*P2M;
1856 (*elementsVec)[counter][21] = 2*(r+1) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) + P2M*P2M;
1857 (*elementsVec)[counter][22] = 2*(r)+1 + 2*P2M * (s+1) + 2*P2M*P2M * (t) + P2M*P2M;
1858 (*elementsVec)[counter][23] = 2*(r) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) + P2M*P2M;
1860 (*elementsVec)[counter][24] = 2*(r)+1 + 2*P2M * (s) + P2M + 2*P2M*P2M * (t);
1861 (*elementsVec)[counter][25] = 2*(r)+1 + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) + P2M*P2M;
1862 (*elementsVec)[counter][26] = 2*(r)+1 + 2*P2M * (s) + P2M + 2*P2M*P2M * (t+1);
1869 buildElementsClass(elementsVec);
1876 int numProcsCoarseSolve,
1877 std::string underlyingLib) {
1882 using Teuchos::ScalarTraits;
1884 TEUCHOS_TEST_FOR_EXCEPTION(!(M>=1),std::logic_error,
"H/h is to small.");
1885 TEUCHOS_TEST_FOR_EXCEPTION(this->comm_.is_null(),std::runtime_error,
"comm_ is null.");
1887 SC eps = ScalarTraits<SC>::eps();
1889 bool verbose (this->comm_->getRank() == 0);
1891 setRankRange( numProcsCoarseSolve );
1893 int rank = this->comm_->getRank();
1894 int size = this->comm_->getSize() - numProcsCoarseSolve;
1896 int bfs_multiplier = (int) 2*(length)-1;
1898 int nmbSubdomainsSquares = size / bfs_multiplier;
1899 int nmbSubdomainsSquares_OneDir = (std::pow(nmbSubdomainsSquares,1/2.) + 100*eps);
1901 vec2D_int_ptr_Type elementsVec;
1906 double h = 1./(M*N);
1908 GO nmbPoints_oneDir;
1909 GO nmbPoints_oneDir_allSubdomain;
1910 if (FEType ==
"P0") {
1911 nmbPoints_oneDir = N * (M+1) - (N-1) ;
1912 nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1) ;
1913 nmbPoints = (M+1)*(M+1) ;
1915 else if (FEType ==
"P1") {
1916 nmbPoints_oneDir = N * (M+1) - (N-1) ;
1917 nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1) ;
1918 nmbPoints = (M+1)*(M+1) ;
1920 else if(FEType ==
"P2"){
1921 nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1) ;
1922 nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1) ;
1923 nmbPoints = (2*(M+1)-1)*(2*(M+1)-1) ;
1926 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Wrong FE-Type, either P1 or P2.");
1929 this->FEType_ = FEType;
1931 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
1933 this->numElementsGlob_ = 2*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1) * bfs_multiplier;
1941 nmbElements = 2*(M)*(M);
1945 if (FEType ==
"P0") {
1947 std::cout <<
"-- H:"<<H <<
" h:" <<h <<
" --" << std::endl;
1950 std::cout <<
"-- Building P0 Points Repeated ... " << std::endl;
1952 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(2,0.0)));
1953 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
1954 elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements, std::vector<int>(3,-1)));
1956 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
1958 int whichSquareSet = (int)rank / nmbSubdomainsSquares;
1960 int offset_Squares_x = (int) (whichSquareSet+1) / 2;
1961 int offset_Squares_y = ((whichSquareSet+1) % 2);
1963 int offset_x = ((rank - nmbSubdomainsSquares*whichSquareSet) % N);
1966 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))>=N) {
1967 offset_y = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))/(N);
1970 for (
int s=0; s < M+1; s++) {
1971 for (
int r=0; r < M+1; r++) {
1972 (*this->pointsRep_)[counter][0] = coorRec[0] + r*h + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
1973 (*this->pointsRep_)[counter][1] = coorRec[1] + s*h + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
1974 pointsRepGlobMapping[counter] = r + s*(nmbPoints_oneDir_allSubdomain - (1-offset_Squares_y)*(nmbPoints_oneDir-1))
1976 + offset_y*((nmbPoints_oneDir_allSubdomain) - (1-offset_Squares_y)*(nmbPoints_oneDir-1)) *M
1977 + offset_Squares_x * M * nmbSubdomainsSquares_OneDir
1978 + offset_Squares_y * (nmbPoints_oneDir_allSubdomain * M * nmbSubdomainsSquares_OneDir
1979 - (nmbPoints_oneDir-1)*(nmbPoints_oneDir-1));
1981 if (offset_Squares_x>0 && offset_Squares_y==0 ) {
1982 pointsRepGlobMapping[counter] -= nmbPoints_oneDir-1;
1984 if (offset_Squares_x>0 && offset_Squares_y==0 && offset_y+1==nmbSubdomainsSquares_OneDir && s==M) {
1985 pointsRepGlobMapping[counter] += nmbPoints_oneDir-1;
1987 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[counter][0] < (coorRec[0]+eps) ||
1988 (*this->pointsRep_)[counter][1] > (coorRec[1]+height-eps) || (*this->pointsRep_)[counter][1] < (coorRec[1]+eps)) {
1989 (*this->bcFlagRep_)[counter] = 1;
1997 std::cout <<
" done! --" << std::endl;
2001 std::cout <<
"-- Building P0 Repeated and Unique Map ... " << std::flush;
2006 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
2008 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
2010 std::cout <<
" done! --" << std::endl;
2014 std::cout <<
"-- Building P0 Unique Points ... " << std::flush;
2017 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(), std::vector<double>(2,0.0)));
2018 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
2020 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
2022 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
2024 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
2025 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
2026 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
2030 std::cout <<
" done! --" << std::endl;
2035 std::cout <<
"-- Building P0 Elements ... " << std::flush;
2039 for (
int s=0; s < M; s++) {
2040 for (
int r=0; r < M; r++) {
2041 (*elementsVec)[counter][0] = r+1 + (M+1) * s;
2042 (*elementsVec)[counter][1] = r + (M+1) * s ;
2043 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1);
2045 (*elementsVec)[counter][0] = r + (M+1) * (s+1);
2046 (*elementsVec)[counter][1] = r + (M+1) * (s);
2047 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1);
2053 std::cout <<
" done! --" << std::endl;
2058 else if (FEType ==
"P1") {
2060 std::cout <<
"-- H:"<<H <<
" h:" <<h <<
" --" << std::endl;
2063 std::cout <<
"-- Building P1 Points Repeated ... " << std::endl;
2066 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(2,0.0)));
2067 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
2068 elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements,std::vector<int>(3,-1)));
2070 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
2072 int whichSquareSet = (int)rank / nmbSubdomainsSquares;
2074 int offset_Squares_x = (int) (whichSquareSet+1) / 2;
2075 int offset_Squares_y = ((whichSquareSet+1) % 2);
2077 int offset_x = ((rank - nmbSubdomainsSquares*whichSquareSet) % N);
2080 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))>=N) {
2081 offset_y = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))/(N);
2084 for (
int s=0; s < M+1; s++) {
2085 for (
int r=0; r < M+1; r++) {
2086 (*this->pointsRep_)[counter][0] = coorRec[0] + r*h + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
2087 (*this->pointsRep_)[counter][1] = coorRec[1] + s*h + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
2088 pointsRepGlobMapping[counter] = r + s*(nmbPoints_oneDir_allSubdomain - (1-offset_Squares_y)*(nmbPoints_oneDir-1))
2090 + offset_y*((nmbPoints_oneDir_allSubdomain) - (1-offset_Squares_y)*(nmbPoints_oneDir-1)) *M
2091 + offset_Squares_x * M * nmbSubdomainsSquares_OneDir
2092 + offset_Squares_y * (nmbPoints_oneDir_allSubdomain * M * nmbSubdomainsSquares_OneDir
2093 - (nmbPoints_oneDir-1)*(nmbPoints_oneDir-1));
2095 if (offset_Squares_x>0 && offset_Squares_y==0 ) {
2096 pointsRepGlobMapping[counter] -= nmbPoints_oneDir-1;
2098 if (offset_Squares_x>0 && offset_Squares_y==0 && offset_y+1==nmbSubdomainsSquares_OneDir && s==M) {
2099 pointsRepGlobMapping[counter] += nmbPoints_oneDir-1;
2101 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[counter][0] < (coorRec[0]+eps) ||
2102 (*this->pointsRep_)[counter][1] > (coorRec[1]+height-eps) || (*this->pointsRep_)[counter][1] < (coorRec[1]+eps)) {
2103 (*this->bcFlagRep_)[counter] = 1;
2111 std::cout <<
" done! --" << std::endl;
2115 std::cout <<
"-- Building P1 Repeated and Unique Map ... " << std::flush;
2121 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
2123 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
2126 std::cout <<
" done! --" << std::endl;
2130 std::cout <<
"-- Building P1 Unique Points ... " << std::flush;
2133 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(), std::vector<double>(2,0.0)));
2134 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
2136 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
2138 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
2140 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
2141 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
2142 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
2146 std::cout <<
" done! --" << std::endl;
2151 std::cout <<
"-- Building P1 Elements ... " << std::flush;
2155 for (
int s=0; s < M; s++) {
2156 for (
int r=0; r < M; r++) {
2157 (*elementsVec)[counter][0] = r+1 + (M+1) * s;
2158 (*elementsVec)[counter][1] = r + (M+1) * s ;
2159 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1);
2161 (*elementsVec)[counter][0] = r + (M+1) * (s+1);
2162 (*elementsVec)[counter][1] = r + (M+1) * (s);
2163 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1);
2169 std::cout <<
" done! --" << std::endl;
2174 else if(FEType ==
"P2"){
2176 std::cout <<
"-- H:"<<H <<
" h:" <<h <<
" --" << std::endl;
2179 std::cout <<
"-- Building P2 Points Repeated ... " << std::flush;
2182 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(2,0.0)));
2183 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
2184 elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements,std::vector<int>(6,-1)));
2185 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
2187 int whichSquareSet = (int)rank / nmbSubdomainsSquares;
2189 int offset_Squares_x = (int) (whichSquareSet+1) / 2;
2190 int offset_Squares_y = ((whichSquareSet+1) % 2);
2193 int offset_x = ((rank - nmbSubdomainsSquares*whichSquareSet) % N);
2197 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))>=N) {
2198 offset_y = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))/(N);
2206 for (
int s=0; s < 2*(M+1)-1; s++) {
2207 for (
int r=0; r < 2*(M+1)-1; r++) {
2209 if (s%2==0 && r%2==0) {
2214 (*this->pointsRep_)[counter][0] = coorRec[0] + r*h/2. + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
2215 (*this->pointsRep_)[counter][1] = coorRec[1] + s*h/2. + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
2216 pointsRepGlobMapping[counter] = r + s*(nmbPoints_oneDir_allSubdomain - (1-offset_Squares_y)*(nmbPoints_oneDir-1))
2217 + offset_x*(2*(M+1)-2)
2218 + offset_y*((nmbPoints_oneDir_allSubdomain) - (1-offset_Squares_y)*(nmbPoints_oneDir-1)) * (2*(M+1)-2)
2219 + offset_Squares_x * (2*(M+1)-2) * nmbSubdomainsSquares_OneDir
2220 + offset_Squares_y * (nmbPoints_oneDir_allSubdomain * 2*M * nmbSubdomainsSquares_OneDir
2221 - (nmbPoints_oneDir-1)*(nmbPoints_oneDir-1));
2223 if (offset_Squares_x>0 && offset_Squares_y==0 ) {
2224 pointsRepGlobMapping[counter] -= nmbPoints_oneDir-1;
2226 if (offset_Squares_x>0 && offset_Squares_y==0 && offset_y+1==nmbSubdomainsSquares_OneDir && s==2*M) {
2227 pointsRepGlobMapping[counter] += nmbPoints_oneDir-1;
2229 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[counter][0] < (coorRec[0]+eps) ||
2230 (*this->pointsRep_)[counter][1] > (coorRec[1]+height-eps) || (*this->pointsRep_)[counter][1] < (coorRec[1]+eps)) {
2231 (*this->bcFlagRep_)[counter] = 1;
2239 std::cout <<
" done! --" << std::endl;
2245 std::cout <<
"-- Building P2 Repeated and Unique Map ... " << std::flush;
2249 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
2251 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
2255 std::cout <<
" done! --" << std::endl;
2259 std::cout <<
"-- Building P2 Unique Points ... " << std::flush;
2262 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(2,0.0)));
2263 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
2266 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
2268 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
2270 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
2271 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
2272 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
2276 std::cout <<
" done! --" << std::endl;
2290 std::cout <<
"-- Building P2 Elements ... " << std::flush;
2293 int P2M = 2*(M+1)-1;
2297 for (
int s=0; s < M; s++) {
2298 for (
int r=0; r < M; r++) {
2300 (*elementsVec)[counter][0] = 2*(r+1) + 2*P2M * (s) ;
2301 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) ;
2302 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) ;
2304 (*elementsVec)[counter][3] = 2*(r) +1 + 2*P2M * (s) ;
2305 (*elementsVec)[counter][4] = 2*(r) +1 + 2*P2M * (s) +P2M ;
2306 (*elementsVec)[counter][5] = 2*(r+1) + 2*P2M * (s) +P2M ;
2310 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s+1) ;
2311 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) ;
2312 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) ;
2314 (*elementsVec)[counter][3] = 2*(r) + 2*P2M * (s) +P2M ;
2315 (*elementsVec)[counter][4] = 2*(r) +1 + 2*P2M * (s) +P2M ;
2316 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s+1) ;
2324 std::cout <<
" done! --" << std::endl;
2327 buildElementsClass(elementsVec);
2334 int numProcsCoarseSolve,
2335 std::string underlyingLib){
2339 using Teuchos::ScalarTraits;
2341 TEUCHOS_TEST_FOR_EXCEPTION(!(M>=1),std::logic_error,
"H/h is to small.");
2342 TEUCHOS_TEST_FOR_EXCEPTION(this->comm_.is_null(),std::runtime_error,
"comm_ is null.");
2344 typedef ScalarTraits<SC> ST;
2347 bool verbose (this->comm_->getRank() == 0);
2349 setRankRange( numProcsCoarseSolve );
2351 int rank = this->comm_->getRank();
2352 int size = this->comm_->getSize() - numProcsCoarseSolve;
2354 int bfs_multiplier = (int) 2*(length)-1;
2356 int nmbSubdomainsSquares = size / bfs_multiplier;
2357 int nmbSubdomainsSquares_OneDir = (std::pow(nmbSubdomainsSquares,1./3.) + 100*eps);
2359 SC h = ST::one()/(M*N);
2365 GO nmbPoints_oneDir;
2366 GO nmbPoints_oneDir_allSubdomain;
2368 if (FEType ==
"P0") {
2369 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"implement P0.");
2371 else if (FEType ==
"P1") {
2372 nmbPoints_oneDir = N * (M+1) - (N-1);
2373 nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1);
2374 nmbPoints = (M+1)*(M+1)*(M+1);
2376 else if(FEType ==
"P2"){
2377 nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1);
2378 nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1) ;
2379 nmbPoints = (2*(M+1)-1)*(2*(M+1)-1)*(2*(M+1)-1);
2381 else if(FEType ==
"P2-CR"){
2382 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"P2-CR might not work properly.");
2383 nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1);
2384 nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1) ;
2385 nmbPoints = (2*(M+1)-1)*(2*(M+1)-1)*(2*(M+1)-1);
2387 else if(FEType ==
"P1-disc" || FEType ==
"P1-disc-global"){
2388 nmbPoints_oneDir = N * (M+1) - (N-1);
2389 nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1);
2390 nmbPoints = (M+1)*(M+1)*(M+1);
2392 else if(FEType ==
"Q2"){
2395 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Wrong FE-Type, only P1,P1-disc, P1-disc-global, P2, or P2-CR.");
2397 this->FEType_ = FEType;
2399 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
2400 this->numElementsGlob_ = 6*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1) * bfs_multiplier;
2408 nmbElements = 6*M*M*M;
2412 if (FEType ==
"P1") {
2414 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
2415 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
2416 vec2D_int_ptr_Type elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements,std::vector<int>(4,-1)));
2418 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
2420 int whichSquareSet = (int)rank / nmbSubdomainsSquares;
2422 int offset_Squares_x = (int) (whichSquareSet+1) / 2;
2423 int offset_Squares_y = 0;
2424 int offset_Squares_z = ((whichSquareSet+1) % 2);
2427 int offset_x = ((rank - nmbSubdomainsSquares*whichSquareSet) % N);
2430 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))>=N)
2431 offset_y = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))/(N);
2432 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))>=N*N )
2433 offset_z = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))/(N*(N));
2435 for (
int t=0; t < M+1; t++) {
2436 for (
int s=0; s < M+1; s++) {
2437 for (
int r=0; r < M+1; r++) {
2438 (*this->pointsRep_)[counter][0] = coorRec[0] + r*h + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
2440 (*this->pointsRep_)[counter][1] = coorRec[1] + s*h + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
2442 (*this->pointsRep_)[counter][2] = coorRec[2] + t*h + offset_z * H + offset_Squares_z * H * nmbSubdomainsSquares_OneDir;
2444 pointsRepGlobMapping[counter] = r
2445 + s*(nmbPoints_oneDir_allSubdomain);
2446 if (offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
2447 pointsRepGlobMapping[counter] -= s*(nmbPoints_oneDir-1);
2449 else if(offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=M){
2450 pointsRepGlobMapping[counter] -= s*(nmbPoints_oneDir-1);
2453 pointsRepGlobMapping[counter] += t*nmbPoints_oneDir_allSubdomain*nmbPoints_oneDir;
2454 if (offset_Squares_x > 0 && offset_Squares_z == 0 ) {
2455 pointsRepGlobMapping[counter] -= t*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
2458 pointsRepGlobMapping[counter] += offset_x*(M)
2459 + offset_y*( nmbPoints_oneDir_allSubdomain * M );
2460 if (offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
2461 pointsRepGlobMapping[counter] -= offset_y*M*(nmbPoints_oneDir-1);
2463 else if(offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=M){
2464 pointsRepGlobMapping[counter] -= offset_y*M*(nmbPoints_oneDir-1);
2467 pointsRepGlobMapping[counter] += offset_z * M * nmbPoints_oneDir_allSubdomain * nmbPoints_oneDir;
2468 if (offset_Squares_x > 0 && offset_Squares_z == 0 ) {
2469 pointsRepGlobMapping[counter] -= offset_z*M*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
2472 pointsRepGlobMapping[counter] += offset_Squares_x * M * nmbSubdomainsSquares_OneDir;
2473 if (offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
2474 pointsRepGlobMapping[counter] -= M * nmbSubdomainsSquares_OneDir;
2476 else if(offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=M){
2477 pointsRepGlobMapping[counter] -= M * nmbSubdomainsSquares_OneDir;
2480 pointsRepGlobMapping[counter] += offset_Squares_z * nmbPoints_oneDir_allSubdomain * ((M) * nmbSubdomainsSquares_OneDir+1) * M * nmbSubdomainsSquares_OneDir;
2481 if (offset_Squares_z > 0 ) {
2482 pointsRepGlobMapping[counter] -= (nmbPoints_oneDir-1)*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
2490 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
2492 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
2495 std::cout <<
"-- Building P1 Unique Points ... " << std::flush;
2498 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(), std::vector<double>(3,0.0)));
2499 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
2502 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
2503 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
2504 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
2505 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
2506 (*this->pointsUni_)[i][2] = (*this->pointsRep_)[index][2];
2507 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
2511 std::cout <<
" done! --" << std::endl;
2516 std::cout <<
"-- Building P1 Elements ... " << std::flush;
2519 for (
int t=0; t < M; t++) {
2520 for (
int s=0; s < M; s++) {
2521 for (
int r=0; r < M; r++) {
2522 (*elementsVec)[counter][0] = r+1 + (M+1) * s + (M+1)*(M+1) * t ;
2523 (*elementsVec)[counter][1] = r + (M+1) * s + (M+1)*(M+1) * t ;
2524 (*elementsVec)[counter][2] = r+1 + (M+1) * s + (M+1)*(M+1) * (t+1) ;
2525 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
2527 (*elementsVec)[counter][0] = r + (M+1) * s + (M+1)*(M+1) * (t+1) ;
2528 (*elementsVec)[counter][1] = r + (M+1) * s + (M+1)*(M+1) * t ;
2529 (*elementsVec)[counter][2] = r+1 + (M+1) * s + (M+1)*(M+1) * (t+1) ;
2530 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
2532 (*elementsVec)[counter][0] = r+1 + (M+1) * s + (M+1)*(M+1) * t ;
2533 (*elementsVec)[counter][1] = r + (M+1) * s + (M+1)*(M+1) * t ;
2534 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * t ;
2535 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
2537 (*elementsVec)[counter][0] = r + (M+1) * s + (M+1)*(M+1) * t ;
2538 (*elementsVec)[counter][1] = r + (M+1) * (s+1) + (M+1)*(M+1) * t ;
2539 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * t ;
2540 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
2542 (*elementsVec)[counter][0] = r + (M+1) * s + (M+1)*(M+1) * t ;
2543 (*elementsVec)[counter][1] = r + (M+1) * (s+1) + (M+1)*(M+1) * t ;
2544 (*elementsVec)[counter][2] = r + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
2545 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
2547 (*elementsVec)[counter][0] = r + (M+1) * s + (M+1)*(M+1) * t ;
2548 (*elementsVec)[counter][1] = r + (M+1) * s + (M+1)*(M+1) * (t+1) ;
2549 (*elementsVec)[counter][2] = r + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
2550 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
2556 std::cout <<
" done! --" << std::endl;
2558 buildElementsClass(elementsVec);
2560 else if(FEType ==
"P1-disc" || FEType ==
"P1-disc-global")
2562 else if(FEType ==
"P2"){
2564 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
2565 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
2566 vec2D_int_ptr_Type elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements,std::vector<int>(10,-1)));
2567 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
2569 int whichSquareSet = (int)rank / nmbSubdomainsSquares;
2571 int offset_Squares_x = (int) (whichSquareSet+1) / 2;
2572 int offset_Squares_y = 0;
2573 int offset_Squares_z = ((whichSquareSet+1) % 2);
2576 int offset_x = ((rank - nmbSubdomainsSquares*whichSquareSet) % N);
2579 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))>=N) {
2580 offset_y = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))/(N);
2583 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))>=N*N ) {
2584 offset_z = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))/(N*(N));
2591 for (
int t=0; t < 2*(M+1)-1; t++) {
2592 for (
int s=0; s < 2*(M+1)-1; s++) {
2593 for (
int r=0; r < 2*(M+1)-1; r++) {
2595 if (s%2==0 && r%2==0 && t%2==0) {
2601 (*this->pointsRep_)[counter][0] = coorRec[0] + r*h/2. + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
2603 (*this->pointsRep_)[counter][1] = coorRec[1] + s*h/2. + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
2605 (*this->pointsRep_)[counter][2] = coorRec[2] + t*h/2. + offset_z * H + offset_Squares_z * H * nmbSubdomainsSquares_OneDir;
2607 pointsRepGlobMapping[counter] = r
2608 + s*(nmbPoints_oneDir_allSubdomain);
2609 if (offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
2610 pointsRepGlobMapping[counter] -= s*(nmbPoints_oneDir-1);
2612 else if(offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=2*M){
2613 pointsRepGlobMapping[counter] -= s*(nmbPoints_oneDir-1);
2616 pointsRepGlobMapping[counter] += t*nmbPoints_oneDir_allSubdomain*nmbPoints_oneDir;
2617 if (offset_Squares_x > 0 && offset_Squares_z == 0 ) {
2618 pointsRepGlobMapping[counter] -= t*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
2621 pointsRepGlobMapping[counter] += offset_x*(2*M)
2622 + offset_y*( nmbPoints_oneDir_allSubdomain * 2*M );
2623 if (offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
2624 pointsRepGlobMapping[counter] -= offset_y*2*M*(nmbPoints_oneDir-1);
2626 else if(offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=2*M){
2627 pointsRepGlobMapping[counter] -= offset_y*2*M*(nmbPoints_oneDir-1);
2630 pointsRepGlobMapping[counter] += offset_z * 2*M * nmbPoints_oneDir_allSubdomain * nmbPoints_oneDir;
2631 if (offset_Squares_x > 0 && offset_Squares_z == 0 ) {
2632 pointsRepGlobMapping[counter] -= offset_z*2*M*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
2635 pointsRepGlobMapping[counter] += offset_Squares_x * 2*M * nmbSubdomainsSquares_OneDir;
2636 if (offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
2637 pointsRepGlobMapping[counter] -= 2*M * nmbSubdomainsSquares_OneDir;
2639 else if(offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=2*M){
2640 pointsRepGlobMapping[counter] -= 2*M * nmbSubdomainsSquares_OneDir;
2643 pointsRepGlobMapping[counter] += offset_Squares_z * nmbPoints_oneDir_allSubdomain * ((2*M) * nmbSubdomainsSquares_OneDir+1) * 2*M * nmbSubdomainsSquares_OneDir;
2644 if (offset_Squares_z > 0 ) {
2645 pointsRepGlobMapping[counter] -= (nmbPoints_oneDir-1)*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
2652 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
2654 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
2657 std::cout <<
"-- Building P2 Unique Points ... " << std::flush;
2660 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(3,0.0)));
2661 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
2664 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
2666 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
2668 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
2669 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
2670 (*this->pointsUni_)[i][2] = (*this->pointsRep_)[index][2];
2671 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
2675 std::cout <<
" done! --" << std::endl;
2688 int P2M = 2*(M+1)-1;
2691 for (
int t=0; t < M; t++) {
2692 for (
int s=0; s < M; s++) {
2693 for (
int r=0; r < M; r++) {
2695 (*elementsVec)[counter][0] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2696 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2697 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
2698 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
2700 (*elementsVec)[counter][4] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2701 (*elementsVec)[counter][6] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M;
2702 (*elementsVec)[counter][7] = 2*(r+1) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M;
2703 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M;
2704 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M;
2705 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t+1);
2709 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
2710 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2711 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
2712 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
2714 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M ;
2715 (*elementsVec)[counter][6] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
2716 (*elementsVec)[counter][7] = 2*(r) +1 + 2*P2M * (s)+P2M + 2*P2M*P2M * (t+1) ;
2717 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M ;
2718 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) +P2M*P2M ;
2719 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t+1);
2723 (*elementsVec)[counter][0] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2724 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2725 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
2726 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
2728 (*elementsVec)[counter][4] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2729 (*elementsVec)[counter][6] = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) ;
2730 (*elementsVec)[counter][7] = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) +P2M*P2M ;
2731 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) ;
2732 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) +P2M*P2M ;
2733 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
2737 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2738 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
2739 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
2740 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
2742 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) ;
2743 (*elementsVec)[counter][6] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) ;
2744 (*elementsVec)[counter][7] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
2745 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s+1) + 2*P2M*P2M * (t);
2746 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
2747 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
2751 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2752 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
2753 (*elementsVec)[counter][2] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
2754 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
2756 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) ;
2757 (*elementsVec)[counter][6] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
2758 (*elementsVec)[counter][7] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
2759 (*elementsVec)[counter][5] = 2*(r) + 2*P2M*(s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
2760 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M*(s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
2761 (*elementsVec)[counter][9] = 2*(r) +1 + 2*P2M*(s+1) + 2*P2M*P2M * (t+1) ;
2765 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2766 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
2767 (*elementsVec)[counter][2] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
2768 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
2770 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M ;
2771 (*elementsVec)[counter][6] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
2772 (*elementsVec)[counter][7] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
2773 (*elementsVec)[counter][5] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t+1) ;
2774 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t+1) ;
2775 (*elementsVec)[counter][9] = 2*(r) +1 + 2*P2M*(s+1) + 2*P2M*P2M * (t+1) ;
2782 buildElementsClass(elementsVec);
2784 else if(FEType ==
"Q2")
2785 build3DQ2BFS( N, MM, numProcsCoarseSolve, underlyingLib );
2792 int numProcsCoarseSolve,
2793 std::string underlyingLib){
2800 using Teuchos::ScalarTraits;
2801 typedef ScalarTraits<SC> ST;
2803 bool verbose (this->comm_->getRank() == 0);
2805 setRankRange( numProcsCoarseSolve );
2808 std::cout << std::endl;
2810 SC eps = ScalarTraits<SC>::eps();
2812 int rank = this->comm_->getRank();
2813 int size = this->comm_->getSize() - numProcsCoarseSolve;
2816 int bfs_multiplier = (int) 2*(length)-1;
2818 int nmbSubdomainsSquares = size / bfs_multiplier;
2819 int nmbSubdomainsSquares_OneDir = (std::pow(nmbSubdomainsSquares,1./3.) + 100*eps);
2821 SC h = ST::one()/(M*N);
2824 LO nmbElements = M*M*M;
2825 LO nmbPoints = 4*M*M*M;
2834 this->numElementsGlob_ = nmbElements * size;
2836 int whichSquareSet = (int)rank / nmbSubdomainsSquares;
2838 int offset_Squares_x = (int) (whichSquareSet+1) / 2;
2839 int offset_Squares_y = 0;
2840 int offset_Squares_z = ((whichSquareSet+1) % 2);
2843 int offset_x = ((rank - nmbSubdomainsSquares*whichSquareSet) % N);
2846 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))>=N)
2847 offset_y = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))/(N);
2849 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))>=N*N )
2850 offset_z = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))/(N*(N));
2853 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
2854 this->pointsUni_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
2855 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
2856 this->bcFlagUni_.reset(
new std::vector<int> (nmbPoints,0));
2857 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
2860 std::cout <<
"-- Building P1-disc Points and Elements according to Q2 ... " << std::flush;
2862 vec2D_int_ptr_Type elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements,std::vector<int>(4,-1)));
2866 GO globalCounterPoints = rank * nmbPoints;
2867 for (
int t=0; t < M; t++) {
2868 for (
int s=0; s < M; s++) {
2869 for (
int r=0; r < M; r++) {
2872 (*this->pointsRep_)[pCounter][0] = coorRec[0] + r*h + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
2873 (*this->pointsRep_)[pCounter][1] = coorRec[1] + s*h + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
2874 (*this->pointsRep_)[pCounter][2] = coorRec[2] + t*h + offset_z * H + offset_Squares_z * H * nmbSubdomainsSquares_OneDir;
2876 if ((*this->pointsRep_)[pCounter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[pCounter][0] < (coorRec[0]+eps) ||
2877 (*this->pointsRep_)[pCounter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[pCounter][1] < (coorRec[1]+eps) ||
2878 (*this->pointsRep_)[pCounter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[pCounter][2] < (coorRec[2]+eps) ) {
2880 (*this->bcFlagRep_)[counter] = 1;
2883 (*this->pointsUni_)[pCounter][0] = (*this->pointsRep_)[pCounter][0];
2884 (*this->pointsUni_)[pCounter][1] = (*this->pointsRep_)[pCounter][1];
2885 (*this->pointsUni_)[pCounter][2] = (*this->pointsRep_)[pCounter][2];
2887 (*this->bcFlagUni_)[pCounter] = (*this->bcFlagRep_)[pCounter];
2889 (*elementsVec)[counter][0] = pCounter;
2890 pointsRepGlobMapping[pCounter] = globalCounterPoints;
2891 globalCounterPoints++;
2895 (*this->pointsRep_)[pCounter][0] = coorRec[0] + (r+1)*h + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
2896 (*this->pointsRep_)[pCounter][1] = coorRec[1] + s*h + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
2897 (*this->pointsRep_)[pCounter][2] = coorRec[2] + t*h + offset_z * H + offset_Squares_z * H * nmbSubdomainsSquares_OneDir;
2898 if ((*this->pointsRep_)[pCounter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[pCounter][0] < (coorRec[0]+eps) ||
2899 (*this->pointsRep_)[pCounter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[pCounter][1] < (coorRec[1]+eps) ||
2900 (*this->pointsRep_)[pCounter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[pCounter][2] < (coorRec[2]+eps) ) {
2902 (*this->bcFlagRep_)[counter] = 1;
2905 (*this->pointsUni_)[pCounter][0] = (*this->pointsRep_)[pCounter][0];
2906 (*this->pointsUni_)[pCounter][1] = (*this->pointsRep_)[pCounter][1];
2907 (*this->pointsUni_)[pCounter][2] = (*this->pointsRep_)[pCounter][2];
2909 (*this->bcFlagUni_)[pCounter] = (*this->bcFlagRep_)[pCounter];
2911 (*elementsVec)[counter][1] = pCounter;
2912 pointsRepGlobMapping[pCounter] = globalCounterPoints;
2913 globalCounterPoints++;
2916 (*this->pointsRep_)[pCounter][0] = coorRec[0] + r*h + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
2917 (*this->pointsRep_)[pCounter][1] = coorRec[1] + (s+1)*h + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
2918 (*this->pointsRep_)[pCounter][2] = coorRec[2] + t*h + offset_z * H + offset_Squares_z * H * nmbSubdomainsSquares_OneDir;
2919 if ((*this->pointsRep_)[pCounter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[pCounter][0] < (coorRec[0]+eps) ||
2920 (*this->pointsRep_)[pCounter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[pCounter][1] < (coorRec[1]+eps) ||
2921 (*this->pointsRep_)[pCounter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[pCounter][2] < (coorRec[2]+eps) ) {
2923 (*this->bcFlagRep_)[counter] = 1;
2926 (*this->pointsUni_)[pCounter][0] = (*this->pointsRep_)[pCounter][0];
2927 (*this->pointsUni_)[pCounter][1] = (*this->pointsRep_)[pCounter][1];
2928 (*this->pointsUni_)[pCounter][2] = (*this->pointsRep_)[pCounter][2];
2930 (*this->bcFlagUni_)[pCounter] = (*this->bcFlagRep_)[pCounter];
2932 (*elementsVec)[counter][2] = pCounter;
2933 pointsRepGlobMapping[pCounter] = globalCounterPoints;
2934 globalCounterPoints++;
2938 (*this->pointsRep_)[pCounter][0] = coorRec[0] + r*h + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
2939 (*this->pointsRep_)[pCounter][1] = coorRec[1] + s*h + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
2940 (*this->pointsRep_)[pCounter][2] = coorRec[2] + (t+1)*h + offset_z * H + offset_Squares_z * H * nmbSubdomainsSquares_OneDir;
2941 if ((*this->pointsRep_)[pCounter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[pCounter][0] < (coorRec[0]+eps) ||
2942 (*this->pointsRep_)[pCounter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[pCounter][1] < (coorRec[1]+eps) ||
2943 (*this->pointsRep_)[pCounter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[pCounter][2] < (coorRec[2]+eps) ) {
2945 (*this->bcFlagRep_)[counter] = 1;
2948 (*this->pointsUni_)[pCounter][0] = (*this->pointsRep_)[pCounter][0];
2949 (*this->pointsUni_)[pCounter][1] = (*this->pointsRep_)[pCounter][1];
2950 (*this->pointsUni_)[pCounter][2] = (*this->pointsRep_)[pCounter][2];
2952 (*this->bcFlagUni_)[pCounter] = (*this->bcFlagRep_)[pCounter];
2954 (*elementsVec)[counter][3] = pCounter;
2955 pointsRepGlobMapping[pCounter] = globalCounterPoints;
2956 globalCounterPoints++;
2963 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
2965 this->mapUnique_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
2967 buildElementsClass(elementsVec);
2970 std::cout <<
"done!" << std::endl;
2978 switch (this->dim_) {
2980 switch (flagsOption) {
2984 for (
int i=0; i<this->pointsUni_->size(); i++) {
2985 if (this->pointsUni_->at(i).at(0) > (coorRec[0]+length - tol) && this->pointsUni_->at(i).at(1) > (coorRec[1] + tol) && this->pointsUni_->at(i).at(1) < (coorRec[1] + height - tol)) {
2986 this->bcFlagUni_->at(i) = 3;
2988 if (this->pointsUni_->at(i).at(0) < (coorRec[0] +tol)) {
2989 this->bcFlagUni_->at(i) = 2;
2991 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) && this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) ) {
2992 this->bcFlagUni_->at(i) = 1;
2994 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) && this->pointsUni_->at(i).at(1) > (coorRec[1] + height - tol) ) {
2995 this->bcFlagUni_->at(i) = 1;
2998 for (
int i=0; i<this->pointsRep_->size(); i++) {
2999 if (this->pointsRep_->at(i).at(0) > (coorRec[0]+length - tol) && this->pointsRep_->at(i).at(1) > (coorRec[1] + tol) && this->pointsRep_->at(i).at(1) < (coorRec[1] + height - tol)) {
3000 this->bcFlagRep_->at(i) = 3;
3002 if (this->pointsRep_->at(i).at(0) < (coorRec[0] +tol)) {
3003 this->bcFlagRep_->at(i) = 2;
3005 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) && this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) ) {
3006 this->bcFlagRep_->at(i) = 1;
3008 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) && this->pointsRep_->at(i).at(1) > (coorRec[1] + height - tol) ) {
3009 this->bcFlagRep_->at(i) = 1;
3014 for (
int i=0; i<this->pointsUni_->size(); i++) {
3015 if (this->pointsUni_->at(i).at(0) < (coorRec[0] +tol) && this->pointsUni_->at(i).at(1) > (coorRec[1]+1. -tol) && this->pointsUni_->at(i).at(1) < (coorRec[1]+ height +tol)) {
3016 this->bcFlagUni_->at(i) = 2;
3018 if (this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) || this->pointsUni_->at(i).at(1) > (coorRec[1]+height - tol) || this->pointsUni_->at(i).at(0) > (coorRec[0]+length - tol)) {
3019 this->bcFlagUni_->at(i) = 1;
3021 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) && this->pointsUni_->at(i).at(0) < (coorRec[0]+1. + tol) && this->pointsUni_->at(i).at(1) > (coorRec[1] + 1. - tol) && this->pointsUni_->at(i).at(1) < (coorRec[1] + 1. + tol)) {
3022 this->bcFlagUni_->at(i) = 1;
3024 if (this->pointsUni_->at(i).at(1) > (coorRec[1] - tol) && this->pointsUni_->at(i).at(1) < (coorRec[1] + 1. + tol) && this->pointsUni_->at(i).at(0) > (coorRec[0] + 1. - tol) && this->pointsUni_->at(i).at(0) < (coorRec[0] + 1. + tol)) {
3025 this->bcFlagUni_->at(i) = 1;
3027 if (this->pointsUni_->at(i).at(0) > (coorRec[0]+length - tol) && this->pointsUni_->at(i).at(1) > (coorRec[1] + tol) && this->pointsUni_->at(i).at(1) < (coorRec[1] + height - tol)) {
3028 this->bcFlagUni_->at(i) = 3;
3031 for (
int i=0; i<this->pointsRep_->size(); i++) {
3032 if (this->pointsRep_->at(i).at(0) < (coorRec[0] +tol) && this->pointsRep_->at(i).at(1) > (coorRec[1]+1. -tol) && this->pointsRep_->at(i).at(1) < (coorRec[1]+ height +tol)) {
3033 this->bcFlagRep_->at(i) = 2;
3035 if (this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) || this->pointsRep_->at(i).at(1) > (coorRec[1]+height - tol) || this->pointsRep_->at(i).at(0) > (coorRec[0]+length - tol)) {
3036 this->bcFlagRep_->at(i) = 1;
3038 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) && this->pointsRep_->at(i).at(0) < (coorRec[0]+1. + tol) && this->pointsRep_->at(i).at(1) > (coorRec[1] + 1. - tol) && this->pointsRep_->at(i).at(1) < (coorRec[1] + 1. + tol)) {
3039 this->bcFlagRep_->at(i) = 1;
3041 if (this->pointsRep_->at(i).at(1) > (coorRec[1] - tol) && this->pointsRep_->at(i).at(1) < (coorRec[1] + 1. + tol) && this->pointsRep_->at(i).at(0) > (coorRec[0] + 1. - tol) && this->pointsRep_->at(i).at(0) < (coorRec[0] + 1. + tol)) {
3042 this->bcFlagRep_->at(i) = 1;
3044 if (this->pointsRep_->at(i).at(0) > (coorRec[0]+length - tol) && this->pointsRep_->at(i).at(1) > (coorRec[1] + tol) && this->pointsRep_->at(i).at(1) < (coorRec[1] + height - tol)) {
3045 this->bcFlagRep_->at(i) = 3;
3050 for (
int i=0; i<this->pointsUni_->size(); i++) {
3051 if (this->pointsUni_->at(i).at(0) < (coorRec[0] +tol)) {
3052 this->bcFlagUni_->at(i) = 2;
3054 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) && this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) ) {
3055 this->bcFlagUni_->at(i) = 1;
3057 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) && this->pointsUni_->at(i).at(1) > (coorRec[1] + height - tol) ) {
3058 this->bcFlagUni_->at(i) = 4;
3060 if (this->pointsUni_->at(i).at(0) > (coorRec[0]+length - tol) && this->pointsUni_->at(i).at(1) > (coorRec[1] + tol) && this->pointsUni_->at(i).at(1) < (coorRec[1] + height - tol)) {
3061 this->bcFlagUni_->at(i) = 3;
3064 for (
int i=0; i<this->pointsRep_->size(); i++) {
3065 if (this->pointsRep_->at(i).at(0) < (coorRec[0] +tol)) {
3066 this->bcFlagRep_->at(i) = 2;
3068 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) && this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) ) {
3069 this->bcFlagRep_->at(i) = 1;
3071 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) && this->pointsRep_->at(i).at(1) > (coorRec[1] + height - tol) ) {
3072 this->bcFlagRep_->at(i) = 4;
3074 if (this->pointsRep_->at(i).at(0) > (coorRec[0]+length - tol) && this->pointsRep_->at(i).at(1) > (coorRec[1] + tol) && this->pointsRep_->at(i).at(1) < (coorRec[1] + height - tol)) {
3075 this->bcFlagRep_->at(i) = 3;
3080 if (FEType ==
"P2") {
3081 this->bcFlagUni_->at(0) = 1;
3082 this->bcFlagUni_->at(1) = 2;
3083 this->bcFlagUni_->at(2) = 2;
3084 this->bcFlagUni_->at(3) = 2;
3085 this->bcFlagUni_->at(4) = 4;
3086 this->bcFlagUni_->at(5) = 3;
3087 this->bcFlagUni_->at(6) = 0;
3088 this->bcFlagUni_->at(7) = 0;
3089 this->bcFlagUni_->at(8) = 0;
3090 this->bcFlagUni_->at(9) = 5;
3091 this->bcFlagUni_->at(10) = 1;
3092 this->bcFlagUni_->at(11) = 2;
3093 this->bcFlagUni_->at(12) = 2;
3094 this->bcFlagUni_->at(13) = 2;
3095 this->bcFlagUni_->at(14) = 4;
3097 this->bcFlagRep_->at(0) = 1;
3098 this->bcFlagRep_->at(1) = 2;
3099 this->bcFlagRep_->at(2) = 2;
3100 this->bcFlagRep_->at(3) = 2;
3101 this->bcFlagRep_->at(4) = 4;
3102 this->bcFlagRep_->at(5) = 3;
3103 this->bcFlagRep_->at(6) = 0;
3104 this->bcFlagRep_->at(7) = 0;
3105 this->bcFlagRep_->at(8) = 0;
3106 this->bcFlagRep_->at(9) = 5;
3107 this->bcFlagRep_->at(10) = 1;
3108 this->bcFlagRep_->at(11) = 2;
3109 this->bcFlagRep_->at(12) = 2;
3110 this->bcFlagRep_->at(13) = 2;
3111 this->bcFlagRep_->at(14) = 4;
3112 }
else if(FEType==
"P1") {
3113 this->bcFlagUni_->at(0) = 1;
3114 this->bcFlagUni_->at(1) = 1;
3115 this->bcFlagUni_->at(2) = 1;
3116 this->bcFlagUni_->at(3) = 2;
3117 this->bcFlagUni_->at(4) = 2;
3118 this->bcFlagUni_->at(5) = 1;
3120 this->bcFlagRep_->at(0) = 1;
3121 this->bcFlagRep_->at(1) = 1;
3122 this->bcFlagRep_->at(2) = 1;
3123 this->bcFlagRep_->at(3) = 2;
3124 this->bcFlagRep_->at(4) = 2;
3125 this->bcFlagRep_->at(5) = 1;
3129 for (
int i=0; i<this->pointsUni_->size(); i++) {
3130 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) && this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) ) {
3131 this->bcFlagUni_->at(i) = 1;
3133 if (this->pointsUni_->at(i).at(0) > (coorRec[0]+length - tol) && this->pointsUni_->at(i).at(1) > (coorRec[1] + tol) && this->pointsUni_->at(i).at(1) < (coorRec[1] + height - tol)) {
3134 this->bcFlagUni_->at(i) = 1;
3136 if (this->pointsUni_->at(i).at(0) < (coorRec[0] +tol)) {
3137 this->bcFlagUni_->at(i) = 1;
3139 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) && this->pointsUni_->at(i).at(1) > (coorRec[1] + height - tol) ) {
3140 this->bcFlagUni_->at(i) = 2;
3142 if (this->pointsUni_->at(i).at(0) < (coorRec[0] +tol) && this->pointsUni_->at(i).at(1) < (coorRec[1] +tol)) {
3143 this->bcFlagUni_->at(i) = 3;
3146 for (
int i=0; i<this->pointsRep_->size(); i++) {
3147 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) && this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) ) {
3148 this->bcFlagRep_->at(i) = 1;
3150 if (this->pointsRep_->at(i).at(0) > (coorRec[0]+length - tol) && this->pointsRep_->at(i).at(1) > (coorRec[1] + tol) && this->pointsRep_->at(i).at(1) < (coorRec[1] + height - tol)) {
3151 this->bcFlagRep_->at(i) = 1;
3153 if (this->pointsRep_->at(i).at(0) < (coorRec[0] +tol)) {
3154 this->bcFlagRep_->at(i) = 1;
3156 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) && this->pointsRep_->at(i).at(1) > (coorRec[1] + height - tol) ) {
3157 this->bcFlagRep_->at(i) = 2;
3159 if (this->pointsRep_->at(i).at(0) < (coorRec[0] +tol) && this->pointsRep_->at(i).at(1) < (coorRec[1] +tol)) {
3160 this->bcFlagRep_->at(i) = 3;
3169 switch (flagsOption) {
3173 for (
int i=0; i<this->pointsUni_->size(); i++) {
3174 if (this->pointsUni_->at(i).at(0) < (coorRec[0] + tol) ) {
3175 this->bcFlagUni_->at(i) = 2;
3178 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + length - tol) &&
3179 this->pointsUni_->at(i).at(1) > (coorRec[1] + tol) &&
3180 this->pointsUni_->at(i).at(1) < (coorRec[1] + width - tol)&&
3181 this->pointsUni_->at(i).at(2) > (coorRec[2] + tol) &&
3182 this->pointsUni_->at(i).at(2) < (coorRec[2] + height - tol)) {
3183 this->bcFlagUni_->at(i) = 3;
3186 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) &&
3187 this->pointsUni_->at(i).at(2) < (coorRec[2] + tol) ) {
3188 this->bcFlagUni_->at(i) = 1;
3191 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) &&
3192 this->pointsUni_->at(i).at(2) > (coorRec[2] + height - tol) ) {
3193 this->bcFlagUni_->at(i) = 1;
3196 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) &&
3197 this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) ) {
3198 this->bcFlagUni_->at(i) = 1;
3201 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) &&
3202 this->pointsUni_->at(i).at(1) > (coorRec[1] + width - tol) ) {
3203 this->bcFlagUni_->at(i) = 1;
3206 for (
int i=0; i<this->pointsUni_->size(); i++) {
3207 if (this->pointsRep_->at(i).at(0) < (coorRec[0] + tol) ) {
3208 this->bcFlagRep_->at(i) = 2;
3211 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + length - tol) &&
3212 this->pointsRep_->at(i).at(1) > (coorRec[1] + tol) &&
3213 this->pointsRep_->at(i).at(1) < (coorRec[1] + width - tol)&&
3214 this->pointsRep_->at(i).at(2) > (coorRec[2] + tol) &&
3215 this->pointsRep_->at(i).at(2) < (coorRec[2] + height - tol)) {
3216 this->bcFlagRep_->at(i) = 3;
3219 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) &&
3220 this->pointsRep_->at(i).at(2) < (coorRec[2] + tol) ) {
3221 this->bcFlagRep_->at(i) = 1;
3224 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) &&
3225 this->pointsRep_->at(i).at(2) > (coorRec[2] + height - tol) ) {
3226 this->bcFlagRep_->at(i) = 1;
3229 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) &&
3230 this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) ) {
3231 this->bcFlagRep_->at(i) = 1;
3234 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) &&
3235 this->pointsRep_->at(i).at(1) > (coorRec[1] + width - tol) ) {
3236 this->bcFlagRep_->at(i) = 1;
3241 for (
int i=0; i<this->pointsUni_->size(); i++) {
3242 if (this->pointsUni_->at(i).at(0) < (coorRec[0] +tol) && this->pointsUni_->at(i).at(1) > (coorRec[1] - tol) && this->pointsUni_->at(i).at(1) < (coorRec[1]+ width +tol)
3243 && this->pointsUni_->at(i).at(2) > (coorRec[2]+1. -tol) && this->pointsUni_->at(i).at(1) < (coorRec[2]+ height +tol)) {
3244 this->bcFlagUni_->at(i) = 2;
3247 if (this->pointsUni_->at(i).at(2) < (coorRec[2] + tol) || (this->pointsUni_->at(i).at(2) < (coorRec[2]+1. + tol) && this->pointsUni_->at(i).at(0) < (coorRec[0]+1. + tol)) || this->pointsUni_->at(i).at(2) > (coorRec[2]+height - tol)) {
3248 this->bcFlagUni_->at(i) = 1;
3251 if (this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) || this->pointsUni_->at(i).at(1) > (coorRec[1]+width - tol)) {
3252 this->bcFlagUni_->at(i) = 1;
3255 if (this->pointsUni_->at(i).at(0) < (coorRec[0]+1. + tol) && this->pointsUni_->at(i).at(0) > (coorRec[0]+1. - tol) && this->pointsUni_->at(i).at(2) < (coorRec[2]+1.+tol)) {
3256 this->bcFlagUni_->at(i) = 1;
3258 if (this->pointsUni_->at(i).at(0) > (coorRec[0]+length - tol) && this->pointsUni_->at(i).at(1) > (coorRec[1] + tol) && this->pointsUni_->at(i).at(1) < (coorRec[1] + width - tol)
3259 && this->pointsUni_->at(i).at(2) > (coorRec[2] + tol) && this->pointsUni_->at(i).at(2) < (coorRec[2] + height - tol)) {
3260 this->bcFlagUni_->at(i) = 3;
3263 for (
int i=0; i<this->pointsRep_->size(); i++) {
3264 if (this->pointsRep_->at(i).at(0) < (coorRec[0] +tol) && this->pointsRep_->at(i).at(1) > (coorRec[1] - tol) && this->pointsRep_->at(i).at(1) < (coorRec[1]+ width +tol)
3265 && this->pointsRep_->at(i).at(2) > (coorRec[2]+1. -tol) && this->pointsRep_->at(i).at(1) < (coorRec[2]+ height +tol)) {
3266 this->bcFlagRep_->at(i) = 2;
3269 if (this->pointsRep_->at(i).at(2) < (coorRec[2] + tol) || (this->pointsRep_->at(i).at(2) < (coorRec[2]+1. + tol) && this->pointsRep_->at(i).at(0) < (coorRec[0]+1. + tol)) || this->pointsRep_->at(i).at(2) > (coorRec[2]+height - tol)) {
3270 this->bcFlagRep_->at(i) = 1;
3273 if (this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) || this->pointsRep_->at(i).at(1) > (coorRec[1]+width - tol)) {
3274 this->bcFlagRep_->at(i) = 1;
3277 if (this->pointsRep_->at(i).at(0) < (coorRec[0]+1. + tol) && this->pointsRep_->at(i).at(0) > (coorRec[0]+1. - tol) && this->pointsRep_->at(i).at(2) < (coorRec[2]+1.+tol)) {
3278 this->bcFlagRep_->at(i) = 1;
3280 if (this->pointsRep_->at(i).at(0) > (coorRec[0]+length - tol) && this->pointsRep_->at(i).at(1) > (coorRec[1] + tol) && this->pointsRep_->at(i).at(1) < (coorRec[1] + width - tol)
3281 && this->pointsRep_->at(i).at(2) > (coorRec[2] + tol) && this->pointsRep_->at(i).at(2) < (coorRec[2] + height - tol)) {
3282 this->bcFlagRep_->at(i) = 3;
3287 for (
int i=0; i<this->pointsUni_->size(); i++) {
3289 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + tol) &&
3290 this->pointsUni_->at(i).at(2) > (coorRec[2] + height - tol) ) {
3291 this->bcFlagUni_->at(i) = 4;
3294 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + tol) &&
3295 this->pointsUni_->at(i).at(1) > (coorRec[1] + width - tol) ) {
3296 this->bcFlagUni_->at(i) = 5;
3299 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + length - tol) &&
3300 this->pointsUni_->at(i).at(1) > (coorRec[1] + tol) &&
3301 this->pointsUni_->at(i).at(1) < (coorRec[1] + width - tol)&&
3302 this->pointsUni_->at(i).at(2) > (coorRec[2] + tol) &&
3303 this->pointsUni_->at(i).at(2) < (coorRec[2] + height - tol)) {
3304 this->bcFlagUni_->at(i) = 6;
3307 if (this->pointsUni_->at(i).at(0) < (coorRec[0] + tol) ) {
3308 this->bcFlagUni_->at(i) = 1;
3311 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + tol) &&
3312 this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) ) {
3313 this->bcFlagUni_->at(i) = 2;
3316 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + tol) &&
3317 this->pointsUni_->at(i).at(2) < (coorRec[2] + tol) ) {
3318 this->bcFlagUni_->at(i) = 3;
3322 if (this->pointsUni_->at(i).at(0) < (coorRec[0] + tol) &&
3323 this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) )
3324 this->bcFlagUni_->at(i) = 7;
3327 if (this->pointsUni_->at(i).at(0) < (coorRec[0] + tol) &&
3328 this->pointsUni_->at(i).at(2) < (coorRec[2] + tol) )
3329 this->bcFlagUni_->at(i) = 9;
3332 if (this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) &&
3333 this->pointsUni_->at(i).at(2) < (coorRec[2] + tol) )
3334 this->bcFlagUni_->at(i) = 8;
3337 if (this->pointsUni_->at(i).at(0) < (coorRec[0] + tol) &&
3338 this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) &&
3339 this->pointsUni_->at(i).at(2) < (coorRec[2] + tol) )
3340 this->bcFlagUni_->at(i) = 0;
3343 for (
int i=0; i<this->pointsRep_->size(); i++) {
3346 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + tol) &&
3347 this->pointsRep_->at(i).at(2) > (coorRec[2] + height - tol) ) {
3348 this->bcFlagRep_->at(i) = 4;
3352 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + tol) &&
3353 this->pointsRep_->at(i).at(1) > (coorRec[1] + width - tol) ) {
3354 this->bcFlagRep_->at(i) = 5;
3357 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + length - tol) &&
3358 this->pointsRep_->at(i).at(1) > (coorRec[1] + tol) &&
3359 this->pointsRep_->at(i).at(1) < (coorRec[1] + width - tol)&&
3360 this->pointsRep_->at(i).at(2) > (coorRec[2] + tol) &&
3361 this->pointsRep_->at(i).at(2) < (coorRec[2] + height - tol)) {
3362 this->bcFlagRep_->at(i) = 6;
3365 if (this->pointsRep_->at(i).at(0) < (coorRec[0] + tol) ) {
3366 this->bcFlagRep_->at(i) = 1;
3369 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + tol) &&
3370 this->pointsRep_->at(i).at(2) < (coorRec[2] + tol) ) {
3371 this->bcFlagRep_->at(i) = 3;
3374 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + tol) &&
3375 this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) ) {
3376 this->bcFlagRep_->at(i) = 2;
3379 if (this->pointsRep_->at(i).at(0) < (coorRec[0] + tol) &&
3380 this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) )
3381 this->bcFlagRep_->at(i) = 7;
3384 if (this->pointsRep_->at(i).at(0) < (coorRec[0] + tol) &&
3385 this->pointsRep_->at(i).at(2) < (coorRec[2] + tol) )
3386 this->bcFlagRep_->at(i) = 9;
3389 if (this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) &&
3390 this->pointsRep_->at(i).at(2) < (coorRec[2] + tol) )
3391 this->bcFlagRep_->at(i) = 8;
3393 if (this->pointsRep_->at(i).at(0) < (coorRec[0] + tol) &&
3394 this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) &&
3395 this->pointsRep_->at(i).at(2) < (coorRec[2] + tol) )
3396 this->bcFlagRep_->at(i) = 0;
3401 for (
int i=0; i<this->pointsUni_->size(); i++) {
3403 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + tol) &&
3404 this->pointsUni_->at(i).at(2) < (coorRec[2] + tol) ) {
3405 this->bcFlagUni_->at(i) = 4;
3408 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + tol) &&
3409 this->pointsUni_->at(i).at(2) > (coorRec[2] + height - tol) ) {
3410 this->bcFlagUni_->at(i) = 5;
3412 if (this->pointsUni_->at(i).at(0) < (coorRec[0] + tol) ) {
3413 this->bcFlagUni_->at(i) = 6;
3416 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + tol) &&
3417 this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) ) {
3418 this->bcFlagUni_->at(i) = 6;
3421 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + tol) &&
3422 this->pointsUni_->at(i).at(1) > (coorRec[1] + width - tol) ) {
3423 this->bcFlagUni_->at(i) = 6;
3426 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + length - tol) &&
3427 this->pointsUni_->at(i).at(1) > (coorRec[1] + tol) &&
3428 this->pointsUni_->at(i).at(1) < (coorRec[1] + width - tol)&&
3429 this->pointsUni_->at(i).at(2) > (coorRec[2] - tol) &&
3430 this->pointsUni_->at(i).at(2) < (coorRec[2] + height + tol)) {
3431 this->bcFlagUni_->at(i) = 6;
3434 for (
int i=0; i<this->pointsUni_->size(); i++) {
3437 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + tol) &&
3438 this->pointsRep_->at(i).at(2) < (coorRec[2] + tol) ) {
3439 this->bcFlagRep_->at(i) = 4;
3441 if (this->pointsRep_->at(i).at(0) < (coorRec[0] + tol) ) {
3442 this->bcFlagRep_->at(i) = 6;
3445 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + tol) &&
3446 this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) ) {
3447 this->bcFlagRep_->at(i) = 6;
3450 if (this->pointsRep_->at(i).at(0) >= (coorRec[0] + tol) &&
3451 this->pointsRep_->at(i).at(1) > (coorRec[1] + width - tol) ) {
3452 this->bcFlagRep_->at(i) = 6;
3455 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + length - tol) &&
3456 this->pointsRep_->at(i).at(1) > (coorRec[1] + tol) &&
3457 this->pointsRep_->at(i).at(1) < (coorRec[1] + width - tol)&&
3458 this->pointsRep_->at(i).at(2) > (coorRec[2] - tol) &&
3459 this->pointsRep_->at(i).at(2) < (coorRec[2] + height + tol)) {
3460 this->bcFlagRep_->at(i) = 6;
3463 if (this->pointsRep_->at(i).at(2) > (coorRec[2] + height - tol) ) {
3464 this->bcFlagRep_->at(i) = 5;
3469 for (
int i=0; i<this->pointsUni_->size(); i++) {
3470 if (this->pointsUni_->at(i).at(0) < (coorRec[0] + tol) ) {
3471 this->bcFlagUni_->at(i) = 1;
3474 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) &&
3475 this->pointsUni_->at(i).at(2) < (coorRec[2] + tol) ) {
3476 this->bcFlagUni_->at(i) = 1;
3479 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) &&
3480 this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) ) {
3481 this->bcFlagUni_->at(i) = 1;
3484 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) &&
3485 this->pointsUni_->at(i).at(1) > (coorRec[1] + width - tol) ) {
3486 this->bcFlagUni_->at(i) = 1;
3489 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + length - tol) &&
3490 this->pointsUni_->at(i).at(1) > (coorRec[1] + tol) &&
3491 this->pointsUni_->at(i).at(1) < (coorRec[1] + width - tol)&&
3492 this->pointsUni_->at(i).at(2) > (coorRec[2] + tol) &&
3493 this->pointsUni_->at(i).at(2) < (coorRec[2] + height - tol)) {
3494 this->bcFlagUni_->at(i) = 1;
3497 if (this->pointsUni_->at(i).at(2) > (coorRec[2] + height - tol) ) {
3498 this->bcFlagUni_->at(i) = 2;
3500 if (this->pointsUni_->at(i).at(0) < (coorRec[0] +tol) && this->pointsUni_->at(i).at(1) < (coorRec[1] +tol) && this->pointsUni_->at(i).at(2) < (coorRec[2] +tol)) {
3501 this->bcFlagUni_->at(i) = 3;
3504 for (
int i=0; i<this->pointsUni_->size(); i++) {
3505 if (this->pointsRep_->at(i).at(0) < (coorRec[0] - tol) ) {
3506 this->bcFlagRep_->at(i) = 1;
3509 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) &&
3510 this->pointsRep_->at(i).at(2) < (coorRec[2] + tol) ) {
3511 this->bcFlagRep_->at(i) = 1;
3514 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) &&
3515 this->pointsRep_->at(i).at(2) > (coorRec[2] + height - tol) ) {
3516 this->bcFlagRep_->at(i) = 2;
3519 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) &&
3520 this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) ) {
3521 this->bcFlagRep_->at(i) = 1;
3524 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) &&
3525 this->pointsRep_->at(i).at(1) > (coorRec[1] + width - tol) ) {
3526 this->bcFlagRep_->at(i) = 1;
3529 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + length - tol) &&
3530 this->pointsRep_->at(i).at(1) > (coorRec[1] + tol) &&
3531 this->pointsRep_->at(i).at(1) < (coorRec[1] + width - tol)&&
3532 this->pointsRep_->at(i).at(2) > (coorRec[2] + tol) &&
3533 this->pointsRep_->at(i).at(2) < (coorRec[2] + height - tol)) {
3534 this->bcFlagRep_->at(i) = 1;
3536 if (this->pointsRep_->at(i).at(0) < (coorRec[0] +tol) && this->pointsRep_->at(i).at(1) < (coorRec[1] +tol) && this->pointsRep_->at(i).at(2) < (coorRec[2] +tol)) {
3537 this->bcFlagRep_->at(i) = 3;
3555 int numProcsCoarseSolve,
3556 std::string underlyingLib){
3560 using Teuchos::ScalarTraits;
3562 TEUCHOS_TEST_FOR_EXCEPTION(!(M>=1),std::logic_error,
"H/h is to small.");
3563 TEUCHOS_TEST_FOR_EXCEPTION(this->comm_.is_null(),std::runtime_error,
"comm_ is null.");
3565 bool verbose (this->comm_->getRank() == 0);
3568 std::cout <<
"-- Building structured 3D Mesh --" << std::endl;
3571 setRankRange( numProcsCoarseSolve );
3573 SC eps = ScalarTraits<SC>::eps();
3575 int rank = this->comm_->getRank();
3576 int size = this->comm_->getSize() - numProcsCoarseSolve;
3578 SC h = length/(M*N);
3582 std::cout <<
"-- H:"<<H <<
" h:" <<h <<
" --" << std::endl;
3583 std::cout <<
"-- N:"<<N <<
" M:" <<M <<
" --" << std::endl;
3586 LO nmbPoints_oneDir;
3590 if (FEType ==
"P2"){
3591 nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1);
3592 nmbPoints = (2*(M+1)-1)*(2*(M+1)-1)*(2*(M+1)-1) - M*M*M;
3595 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Wrong FE-Type, 5 element subcube devision only available with P2 discretization.");
3600 std::cout <<
"-- Number of Points in one direction: " << nmbPoints_oneDir <<
" || Number of Points " << nmbPoints <<
" --" << std::endl;
3602 this->FEType_ = FEType;
3604 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
3606 this->numElementsGlob_ = 5*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1);
3614 nmbElements = 5*M*M*M;
3616 vec2D_int_ptr_Type elementsVec;
3617 vec_int_ptr_Type elementFlag;
3620 this->pointsRep_.reset(
new vec2D_dbl_Type(nmbPoints, vec_dbl_Type(3, 0.0)));
3621 this->bcFlagRep_.reset(
new vec_int_Type (nmbPoints, 10));
3622 elementsVec = Teuchos::rcp(
new vec2D_int_Type(nmbElements, vec_int_Type(10, -1)));
3623 elementFlag = Teuchos::rcp(
new vec_int_Type( elementsVec->size(),0 ) );
3624 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
3627 int offset_x = (rank % N);
3631 if ((rank % (N*N))>=N) {
3632 offset_y = (int) (rank % (N*N))/(N);
3635 if ((rank % (N*N*N))>=N*N ) {
3636 offset_z = (int) (rank % (N*N*N))/(N*(N));
3640 std::cout <<
"-- Building P2 Points Repeated ... " << std::endl;
3642 std::cout <<
" Offsets on Rank " << rank <<
" || x=" << offset_x <<
" y=" << offset_y <<
" z=" << offset_z << std::endl;
3643 this->comm_->barrier();
3651 for (
int t=0; t < 2*(M+1)-1; t++) {
3652 for (
int s=0; s < 2*(M+1)-1; s++) {
3653 for (
int r=0; r < 2*(M+1)-1; r++) {
3656 if (s%2==0 && r%2==0 && t%2==0) {
3663 (*this->pointsRep_)[counter][0] = r*h/2.0 + offset_x * H;
3664 if ((*this->pointsRep_)[counter][0]<eps && (*this->pointsRep_)[counter][0]>-eps) (*this->pointsRep_)[counter][0]=0.0;
3665 (*this->pointsRep_)[counter][1] = s*h/2.0 + offset_y * H;
3666 if ((*this->pointsRep_)[counter][1]<eps && (*this->pointsRep_)[counter][1]>-eps) (*this->pointsRep_)[counter][1]=0.0;
3667 (*this->pointsRep_)[counter][2] = t*h/2.0 + offset_z * H;
3668 if ((*this->pointsRep_)[counter][2]<eps && (*this->pointsRep_)[counter][2]>-eps) (*this->pointsRep_)[counter][2]=0.0;
3672 if(s%2 == 1 && t%2 == 1 && r%2==0)
3673 offset = M*offset_x +N*M*M*offset_y + N*M*(s-1)/2;
3675 if(s%2 == 0 && t%2==1 ){
3676 offset += M*M*N*offset_y + s/2*M*N;
3680 offset += M*M*N*N * t/2;
3682 offset += M*M*N*N * (t-1)/2;
3685 pointsRepGlobMapping[counter] = r + s*nmbPoints_oneDir + t*nmbPoints_oneDir*nmbPoints_oneDir \
3686 + offset_x*(2*(M+1)-2) + offset_y*(nmbPoints_oneDir)*(2*(M+1)-2) + offset_z*(nmbPoints_oneDir)*(nmbPoints_oneDir)*(2*(M+1)-2) \
3687 -offset_z*(N*N*M*M*M)-nodeSkip-offset;
3689 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[counter][0] < (coorRec[0]+eps) ||
3690 (*this->pointsRep_)[counter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[counter][1] < (coorRec[1]+eps) ||
3691 (*this->pointsRep_)[counter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[counter][2] < (coorRec[2]+eps) ) {
3692 (*this->bcFlagRep_)[counter] = 1;
3695 if (s%2==1 && r%2==1 && t%2==1) {
3708 int P2M = 2*(M+1)-1;
3710 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
3713 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
3715 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(3,0.0)));
3716 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),10));
3719 std::cout <<
"-- Building P2 Points Unique ... " << std::endl;
3722 std::cout <<
"-- Number of repeated points per proc: " << this->mapRepeated_->getNodeNumElements() <<
" ... " << std::endl;
3725 this->comm_->barrier();
3728 this->pointsUni_.reset(
new std::vector<std::vector<double> >( this->mapUnique_->getNodeNumElements(), std::vector<double>(this->dim_,-1. ) ) );
3729 this->bcFlagUni_.reset(
new std::vector<int> ( this->mapUnique_->getNodeNumElements(), 0 ) );
3730 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
3731 GO gid = this->mapUnique_->getGlobalElement( i );
3732 LO
id = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement( i ) );
3733 this->pointsUni_->at(i) = this->pointsRep_->at(
id);
3734 this->bcFlagUni_->at(i) = this->bcFlagRep_->at(
id);
3737 this->comm_->barrier();
3755 std::cout <<
"-- ElementsList ... " << std::endl;
3756 std::cout <<
"-- P2M =" << P2M << std::endl;
3762 for (
int t=0; t < M; t++) {
3763 for (
int s=0; s < M; s++) {
3764 for (
int r=0; r < M; r++) {
3768 int n_0 = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) -t*M*M;
3769 int n_1 = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) -t*M*M;
3770 int n_2 = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) -t*M*M ;
3772 int n_3 = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) -t*M*M;
3773 int n_4 = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) -t*M*M;
3774 int n_5 = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) -t*M*M ;
3776 int n_6 = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) -t*M*M;
3777 int n_7 = 2*(r) +1 + 2*P2M * (s+1) + 2*P2M*P2M * (t) -t*M*M ;
3778 int n_8 = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) -t*M*M;
3781 int n_9 = 2*(r) + 2*P2M * (s) +2*P2M*P2M * (t) +P2M*P2M -s*M -t*M*M;
3782 int n_10 = 2*(r) +1 + 2*P2M * (s) +2*P2M*P2M * (t) +P2M*P2M -s*M -t*M*M;
3783 int n_11 = 2*(r+1) + 2*P2M * (s) +2*P2M*P2M * (t) +P2M*P2M -s*M -t*M*M;
3785 int n_12 = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M -s*M -r -t*M*M;
3787 int n_14 = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) +P2M*P2M -s*M -(r+1) -t*M*M ;
3789 int n_15 = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M -(s+1)*M -t*M*M ;
3790 int n_16 = 2*(r) +1 + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M -(s+1)*M -t*M*M;
3791 int n_17 = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M -(s+1)*M -t*M*M;
3794 int n_18 = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3795 int n_19 = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3796 int n_20 = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3798 int n_21 = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3799 int n_22 = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3800 int n_23 = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3802 int n_24 = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3803 int n_25 = 2*(r) +1 + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3804 int n_26 = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3808 if(((r+M*offset_x)+(s+M*offset_y)+(t+M*offset_z))%2==0){
3809 (*elementsVec)[counter] = {n_2, n_8, n_6, n_26, n_5, n_7, n_4, n_14, n_17, n_16};
3811 (*elementsVec)[counter] = {n_2, n_6, n_0, n_18, n_4, n_3, n_1, n_10, n_12, n_9};
3813 (*elementsVec)[counter] = {n_2, n_18, n_20, n_26, n_10, n_19, n_11, n_14, n_22, n_23};
3815 (*elementsVec)[counter] = {n_6, n_24, n_18, n_26, n_15, n_21, n_12, n_16, n_25, n_22};
3817 (*elementsVec)[counter] = {n_2, n_26, n_6, n_18, n_14, n_16, n_4, n_10, n_22, n_12};
3821 (*elementsVec)[counter] = {n_0, n_24, n_18, n_20, n_12, n_21, n_9, n_10, n_22, n_19};
3823 (*elementsVec)[counter] = {n_2, n_8, n_0, n_20, n_5, n_4, n_1, n_11, n_14, n_10};
3825 (*elementsVec)[counter] = {n_8, n_6, n_0, n_24, n_7, n_3, n_4, n_16, n_15, n_12};
3827 (*elementsVec)[counter] = {n_8, n_24, n_20, n_26, n_16, n_22, n_14, n_17, n_25, n_23};
3829 (*elementsVec)[counter] = {n_8, n_20, n_24, n_0, n_14, n_22, n_16, n_4, n_10, n_12};
3840 std::cout <<
"... done !" << std::endl;
3842 buildElementsClass(elementsVec, elementFlag);
3850 switch (this->dim_) {
3855 switch (flagsOption) {
3863 int numNodesTriangle;
3866 else if(FEType==
"P2")
3869 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"For flag option and discretization no surfaces are available");
3872 for(
int T =0; T< this->elementsC_->numberElements(); T++){
3874 vec_int_Type nodeList = this->elementsC_->getElement(T).getVectorNodeList();
3876 vec2D_LO_Type surfaceElements_vec(4,vec_LO_Type(numNodesTriangle));
3888 surfaceElements_vec[0] = {nodeList[1],nodeList[0],nodeList[2]};
3889 surfaceElements_vec[1] = {nodeList[0],nodeList[3],nodeList[2]};
3890 surfaceElements_vec[2] = {nodeList[1],nodeList[2],nodeList[3]};
3891 surfaceElements_vec[3] = {nodeList[1],nodeList[0],nodeList[3]};
3893 else if(FEType==
"P2"){
3894 surfaceElements_vec[0] = {nodeList[1],nodeList[0],nodeList[2],nodeList[4],nodeList[6],nodeList[5]};
3895 surfaceElements_vec[1] = {nodeList[0],nodeList[3],nodeList[2],nodeList[7],nodeList[9],nodeList[6]};
3896 surfaceElements_vec[2] = {nodeList[1],nodeList[2],nodeList[3],nodeList[5],nodeList[9],nodeList[8]};
3897 surfaceElements_vec[3] = {nodeList[1],nodeList[0],nodeList[3],nodeList[4],nodeList[7],nodeList[8]};
3900 for (
int i=0; i<4; i++) {
3902 vec_dbl_Type p1(3),p2(3),v_E(3);
3903 p1[0] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(0) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(0);
3904 p1[1] =this->pointsRep_->at(surfaceElements_vec[i][0]).at(1) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(1);
3905 p1[2] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(2) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(2);
3907 p2[0] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(0) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(0);
3908 p2[1] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(1) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(1);
3909 p2[2] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(2) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(2);
3911 v_E[0] = p1[1]*p2[2] - p1[2]*p2[1];
3912 v_E[1] = p1[2]*p2[0] - p1[0]*p2[2];
3913 v_E[2] = p1[0]*p2[1] - p1[1]*p2[0];
3916 vec_dbl_Type midpoint(3);
3919 midpoint[0] = (this->pointsRep_->at(surfaceElements_vec[i][0]).at(0) + this->pointsRep_->at(surfaceElements_vec[i][1]).at(0) +this->pointsRep_->at(surfaceElements_vec[i][2]).at(0) )/3.;
3920 midpoint[1] = (this->pointsRep_->at(surfaceElements_vec[i][0]).at(1) + this->pointsRep_->at(surfaceElements_vec[i][1]).at(1) +this->pointsRep_->at(surfaceElements_vec[i][2]).at(1) )/3.;
3921 midpoint[2] = (this->pointsRep_->at(surfaceElements_vec[i][0]).at(2) + this->pointsRep_->at(surfaceElements_vec[i][1]).at(2) +this->pointsRep_->at(surfaceElements_vec[i][2]).at(2) )/3.;
3925 if (midpoint.at(0) < (coorRec[0] + tol) ) {
3928 flipSurface(surfaceElements_vec[i]);
3931 if (midpoint.at(0) > (coorRec[0] + tol) &&
3932 midpoint.at(2) < (coorRec[2] + tol) ) {
3935 flipSurface(surfaceElements_vec[i]);
3938 if (midpoint.at(0) > (coorRec[0] + tol) &&
3939 midpoint.at(2) > (coorRec[2] + height - tol) ) {
3941 flipSurface(surfaceElements_vec[i]);
3945 if (midpoint.at(0) > (coorRec[0] + tol) &&
3946 midpoint.at(1) < (coorRec[1] + tol) ) {
3948 flipSurface(surfaceElements_vec[i]);
3952 if (midpoint.at(0) > (coorRec[0] + tol) &&
3953 midpoint.at(1) > (coorRec[1] + width - tol) ) {
3955 flipSurface(surfaceElements_vec[i]);
3959 if (midpoint.at(0) > (coorRec[0] + length - tol) &&
3960 midpoint.at(1) > (coorRec[1] + tol) &&
3961 midpoint.at(1) < (coorRec[1] + width - tol)&&
3962 midpoint.at(2) > (coorRec[2] + tol) &&
3963 midpoint.at(2) < (coorRec[2] + height - tol)) {
3965 flipSurface(surfaceElements_vec[i]);
3968 p1[0] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(0) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(0);
3969 p1[1] =this->pointsRep_->at(surfaceElements_vec[i][0]).at(1) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(1);
3970 p1[2] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(2) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(2);
3972 p2[0] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(0) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(0);
3973 p2[1] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(1) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(1);
3974 p2[2] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(2) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(2);
3976 v_E[0] = p1[1]*p2[2] - p1[2]*p2[1];
3977 v_E[1] = p1[2]*p2[0] - p1[0]*p2[2];
3978 v_E[2] = p1[0]*p2[1] - p1[1]*p2[0];
3982 if ( !this->elementsC_->getElement(T).subElementsInitialized() )
3983 this->elementsC_->getElement(T).initializeSubElements(
"P2", 2 );
3985 this->elementsC_->getElement(T).addSubElement( feSurface );