240 int numProcsCoarseSolve){
244 using Teuchos::ScalarTraits;
247 TEUCHOS_TEST_FOR_EXCEPTION(!(M>=1),std::logic_error,
"H/h is to small.");
248 TEUCHOS_TEST_FOR_EXCEPTION(this->comm_.is_null(),std::runtime_error,
"comm_ is null.");
250 bool verbose (this->comm_->getRank() == 0);
252 setRankRange( numProcsCoarseSolve );
255 std::cout << std::endl;
258 int rank = this->comm_->getRank();
259 int size = this->comm_->getSize() - numProcsCoarseSolve;
267 vec2D_int_ptr_Type elementsVec;
268 vec_int_ptr_Type elementFlag;
270 if (FEType ==
"P0") {
271 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"implement P0.");
273 else if (FEType ==
"P1") {
274 nmbPoints_oneDir = N * (M+1) - (N-1);
275 nmbPoints = (M+1)*(M+1);
277 else if(FEType ==
"P2"){
278 nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1);
279 nmbPoints = (2*(M+1)-1)*(2*(M+1)-1);
282 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Wrong FE-Type, either P1 or P2.");
285 this->FEType_ = FEType;
287 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
289 this->numElementsGlob_ = 2*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1);
297 nmbElements = 2*(M)*(M);
301 if (FEType ==
"P1") {
303 std::cout <<
"-- H:"<<H <<
" h:" <<h <<
" --" << std::endl;
306 std::cout <<
"-- Building P1 Points Repeated ... " << std::endl;
309 this->pointsRep_.reset(
new vec2D_dbl_Type(nmbPoints,std::vector<double>(2,0.0)));
310 this->bcFlagRep_.reset(
new vec_int_Type (nmbPoints,0));
311 elementsVec = Teuchos::rcp(
new vec2D_int_Type(nmbElements,std::vector<int>(3,-1)));
312 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
315 int offset_x = (rank % N);
318 if ((rank % (N*N))>=N) {
319 offset_y = (int) (rank % (N*N))/(N);
322 for (
int s=0; s < M+1; s++) {
323 for (
int r=0; r < M+1; r++) {
324 (*this->pointsRep_)[counter][0] = r*h + offset_x * H;
325 if ((*this->pointsRep_)[counter][0]<100*ScalarTraits<SC>::eps() && (*this->pointsRep_)[counter][0]>-100*ScalarTraits<SC>::eps()) { (*this->pointsRep_)[counter][0]=0.0;}
326 (*this->pointsRep_)[counter][1] = s*h + offset_y * H;
327 if ((*this->pointsRep_)[counter][1]<100*ScalarTraits<SC>::eps() && (*this->pointsRep_)[counter][1]>-100*ScalarTraits<SC>::eps()) {(*this->pointsRep_)[counter][1]=0.0;}
328 pointsRepGlobMapping[counter] = r + s*nmbPoints_oneDir + offset_x*(M) + offset_y*(nmbPoints_oneDir)*M;
329 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-100*ScalarTraits<SC>::eps()) || (*this->pointsRep_)[counter][0] < (coorRec[0]+100*ScalarTraits<SC>::eps()) ||
330 (*this->pointsRep_)[counter][1] > (coorRec[1]+height-100*ScalarTraits<SC>::eps()) || (*this->pointsRep_)[counter][1] < (coorRec[1]+100*ScalarTraits<SC>::eps())) {
332 (*this->bcFlagRep_)[counter] = 1;
339 std::cout <<
" done! --" << std::endl;
343 std::cout <<
"-- Building P1 Repeated and Unique Map ... " << std::flush;
346 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
348 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
351 std::cout <<
" done! --" << std::endl;
355 std::cout <<
"-- Building P1 Unique Points ... " << std::flush;
358 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(2,0.0)));
359 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
361 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
363 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
365 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
366 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
367 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
370 std::cout <<
" done! --" << std::endl;
375 std::cout <<
"-- Building P1 Elements ... " << std::flush;
377 vec_int_ptr_Type elementFlag = Teuchos::rcp(
new vec_int_Type( elementsVec->size(),0 ) );
381 for (
int s=0; s < M; s++) {
382 for (
int r=0; r < M; r++) {
384 (*elementsVec)[counter][0] = r+1 + (M+1) * s;
385 (*elementsVec)[counter][1] = r + (M+1) * s ;
386 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1);
387 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.;
388 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.;
389 if ( x_ref>=0.3 && x_ref<=0.7) {
391 elementFlag->at(counter) = 1;
397 (*elementsVec)[counter][0] = r + (M+1) * (s+1);
398 (*elementsVec)[counter][1] = r + (M+1) * (s);
399 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1);
401 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.;
402 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.;
403 if ( x_ref>=0.3 && x_ref<=0.7) {
405 elementFlag->at(counter) = 1;
414 std::cout <<
" done! --" << std::endl;
421 else if(FEType ==
"P2"){
423 std::cout <<
"-- H:"<<H <<
" h:" <<h <<
" --" << std::endl;
426 std::cout <<
"-- Building P2 Points Repeated ... " << std::flush;
429 this->pointsRep_.reset(
new vec2D_dbl_Type(nmbPoints, vec_dbl_Type(2,0.0)));
430 this->bcFlagRep_.reset(
new vec_int_Type (nmbPoints,0));
431 elementsVec = Teuchos::rcp(
new vec2D_int_Type(nmbElements, vec_int_Type(6,-1)));
432 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
435 int offset_x = (rank % N);
438 if ((rank % (N*N))>=N) {
439 offset_y = (int) (rank % (N*N))/(N);
444 for (
int s=0; s < 2*(M+1)-1; s++) {
445 for (
int r=0; r < 2*(M+1)-1; r++) {
447 if (s%2==0 && r%2==0) {
452 (*this->pointsRep_)[counter][0] = r*h/2.0 + offset_x * H;
453 if ((*this->pointsRep_)[counter][0]<100*ScalarTraits<SC>::eps() && (*this->pointsRep_)[counter][0]>-100*ScalarTraits<SC>::eps()) (*this->pointsRep_)[counter][0]=0.0;
454 (*this->pointsRep_)[counter][1] = s*h/2.0 + offset_y * H;
455 if ((*this->pointsRep_)[counter][1]<100*ScalarTraits<SC>::eps() && (*this->pointsRep_)[counter][1]>-100*ScalarTraits<SC>::eps()) (*this->pointsRep_)[counter][1]=0.0;
457 pointsRepGlobMapping[counter] = r + s*nmbPoints_oneDir + offset_x*(2*(M+1)-2) + offset_y*(nmbPoints_oneDir)*(2*(M+1)-2) ;
459 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-100*ScalarTraits<SC>::eps()) || (*this->pointsRep_)[counter][0] < (coorRec[0]+100*ScalarTraits<SC>::eps()) ||
460 (*this->pointsRep_)[counter][1] > (coorRec[1]+height-100*ScalarTraits<SC>::eps()) || (*this->pointsRep_)[counter][1] < (coorRec[1]+100*ScalarTraits<SC>::eps())){
461 (*this->bcFlagRep_)[counter] = 1;
469 std::cout <<
" done! --" << std::endl;
472 std::cout <<
"-- Building P2 Repeated and Unique Map ... " << std::flush;
474 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
476 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
479 std::cout <<
" done! --" << std::endl;
483 std::cout <<
"-- Building P2 Unique Points ... " << std::flush;
486 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(2,0.0)));
487 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
490 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
492 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
494 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
495 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
496 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
500 std::cout <<
" done! --" << std::endl;
514 std::cout <<
"-- Building P2 Elements ... " << std::flush;
518 vec_int_ptr_Type elementFlag = Teuchos::rcp(
new vec_int_Type( elementsVec->size(),0 ) );
522 for (
int s=0; s < M; s++) {
523 for (
int r=0; r < M; r++) {
525 (*elementsVec)[counter][0] = 2*(r+1) + 2*P2M * (s) ;
526 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) ;
527 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) ;
529 (*elementsVec)[counter][3] = 2*(r) +1 + 2*P2M * (s) ;
530 (*elementsVec)[counter][4] = 2*(r) +1 + 2*P2M * (s) +P2M ;
531 (*elementsVec)[counter][5] = 2*(r+1) + 2*P2M * (s) +P2M ;
533 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.;
534 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.;
535 if ( x_ref>=0.3 && x_ref<=0.7) {
537 elementFlag->at(counter) = 1;
543 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s+1) ;
544 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) ;
545 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) ;
547 (*elementsVec)[counter][3] = 2*(r) + 2*P2M * (s) +P2M ;
548 (*elementsVec)[counter][4] = 2*(r) +1 + 2*P2M * (s) +P2M ;
549 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s+1) ;
551 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.;
552 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.;
553 if ( x_ref>=0.3 && x_ref<=0.7) {
555 elementFlag->at(counter) = 1;
567 std::cout <<
" done! --" << std::endl;
570 buildElementsClass(elementsVec, elementFlag);
578 int numProcsCoarseSolve){
582 using Teuchos::ScalarTraits;
584 TEUCHOS_TEST_FOR_EXCEPTION(!(M>=1),std::logic_error,
"H/h is to small.");
585 TEUCHOS_TEST_FOR_EXCEPTION(this->comm_.is_null(),std::runtime_error,
"comm_ is null.");
587 bool verbose (this->comm_->getRank() == 0);
589 setRankRange( numProcsCoarseSolve );
592 std::cout << std::endl;
595 SC eps = ScalarTraits<SC>::eps();
597 int rank = this->comm_->getRank();
598 int size = this->comm_->getSize() - numProcsCoarseSolve;
607 if (FEType ==
"P0") {
608 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"implement P0.");
610 else if (FEType ==
"P1") {
611 nmbPoints_oneDir = N * (M+1) - (N-1);
612 nmbPoints = (M+1)*(M+1)*(M+1);
614 else if (FEType ==
"P2"){
615 nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1);
616 nmbPoints = (2*(M+1)-1)*(2*(M+1)-1)*(2*(M+1)-1);
618 else if (FEType ==
"P2-CR"){
619 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"P2-CR might not work properly.");
620 nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1);
621 nmbPoints = (2*(M+1)-1)*(2*(M+1)-1)*(2*(M+1)-1);
623 else if (FEType ==
"P1-disc" || FEType ==
"P1-disc-global"){
626 else if (FEType ==
"Q1"){
629 else if (FEType ==
"Q2"){
632 else if (FEType ==
"Q2-20"){
636 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.");
638 this->FEType_ = FEType;
640 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
642 this->numElementsGlob_ = 6*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1);
650 nmbElements = 6*M*M*M;
652 vec2D_int_ptr_Type elementsVec;
653 vec_int_ptr_Type elementFlag;
655 if (FEType ==
"P1") {
657 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
658 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
659 elementsVec = Teuchos::rcp(
new vec2D_int_Type( nmbElements, vec_int_Type(4, -1) ));
660 elementFlag = Teuchos::rcp(
new vec_int_Type( elementsVec->size(),0 ) );
661 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
664 int offset_x = (rank % N);
668 if ((rank % (N*N))>=N) {
669 offset_y = (int) (rank % (N*N))/(N);
672 if ((rank % (N*N*N))>=N*N ) {
673 offset_z = (int) (rank % (N*N*N))/(N*(N));
676 for (
int t=0; t < M+1; t++) {
677 for (
int s=0; s < M+1; s++) {
678 for (
int r=0; r < M+1; r++) {
679 (*this->pointsRep_)[counter][0] = r*h + offset_x * H;
680 if ((*this->pointsRep_)[counter][0]<eps && (*this->pointsRep_)[counter][0]>-eps) (*this->pointsRep_)[counter][0]=0.0;
682 (*this->pointsRep_)[counter][1] = s*h + offset_y * H;
683 if ((*this->pointsRep_)[counter][1]<eps && (*this->pointsRep_)[counter][1]>-eps) (*this->pointsRep_)[counter][1]=0.0;
685 (*this->pointsRep_)[counter][2] = t*h + offset_z * H;
686 if ((*this->pointsRep_)[counter][2]<eps && (*this->pointsRep_)[counter][2]>-eps) (*this->pointsRep_)[counter][2]=0.0;
688 pointsRepGlobMapping[counter] = r + s*nmbPoints_oneDir + t*nmbPoints_oneDir*nmbPoints_oneDir \
689 + offset_x*(M) + offset_y*(nmbPoints_oneDir)*M + offset_z*(nmbPoints_oneDir)*(nmbPoints_oneDir)*M ;
691 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[counter][0] < (coorRec[0]+eps) ||
692 (*this->pointsRep_)[counter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[counter][1] < (coorRec[1]+eps) ||
693 (*this->pointsRep_)[counter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[counter][2] < (coorRec[2]+eps) ) {
695 (*this->bcFlagRep_)[counter] = 1;
703 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
705 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
707 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(3,0.0)));
708 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
710 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
712 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
714 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
715 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
716 (*this->pointsUni_)[i][2] = (*this->pointsRep_)[index][2];
717 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
721 for (
int t=0; t < M; t++) {
722 for (
int s=0; s < M; s++) {
723 for (
int r=0; r < M; r++) {
724 (*elementsVec)[counter][0] = r+1 + (M+1) * s + (M+1)*(M+1) * t ;
725 (*elementsVec)[counter][1] = r + (M+1) * s + (M+1)*(M+1) * t ;
726 (*elementsVec)[counter][2] = r+1 + (M+1) * s + (M+1)*(M+1) * (t+1) ;
727 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
729 (*elementsVec)[counter][0] = r + (M+1) * s + (M+1)*(M+1) * (t+1) ;
730 (*elementsVec)[counter][1] = r + (M+1) * s + (M+1)*(M+1) * t ;
731 (*elementsVec)[counter][2] = r+1 + (M+1) * s + (M+1)*(M+1) * (t+1) ;
732 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
734 (*elementsVec)[counter][0] = r+1 + (M+1) * s + (M+1)*(M+1) * t ;
735 (*elementsVec)[counter][1] = r + (M+1) * s + (M+1)*(M+1) * t ;
736 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * t ;
737 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
739 (*elementsVec)[counter][0] = r + (M+1) * s + (M+1)*(M+1) * t ;
740 (*elementsVec)[counter][1] = r + (M+1) * (s+1) + (M+1)*(M+1) * t ;
741 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * t ;
742 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
744 (*elementsVec)[counter][0] = r + (M+1) * s + (M+1)*(M+1) * t ;
745 (*elementsVec)[counter][1] = r + (M+1) * (s+1) + (M+1)*(M+1) * t ;
746 (*elementsVec)[counter][2] = r + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
747 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
749 (*elementsVec)[counter][0] = r + (M+1) * s + (M+1)*(M+1) * t ;
750 (*elementsVec)[counter][1] = r + (M+1) * s + (M+1)*(M+1) * (t+1) ;
751 (*elementsVec)[counter][2] = r + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
752 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
757 buildElementsClass(elementsVec, elementFlag);
760 else if(FEType ==
"P2"){
762 this->pointsRep_.reset(
new vec2D_dbl_Type(nmbPoints, vec_dbl_Type(3, 0.0)));
763 this->bcFlagRep_.reset(
new vec_int_Type (nmbPoints, 0));
764 elementsVec = Teuchos::rcp(
new vec2D_int_Type(nmbElements, vec_int_Type(10, -1)));
765 elementFlag = Teuchos::rcp(
new vec_int_Type( elementsVec->size(),0 ) );
766 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
769 int offset_x = (rank % N);
773 if ((rank % (N*N))>=N) {
774 offset_y = (int) (rank % (N*N))/(N);
777 if ((rank % (N*N*N))>=N*N ) {
778 offset_z = (int) (rank % (N*N*N))/(N*(N));
784 for (
int t=0; t < 2*(M+1)-1; t++) {
785 for (
int s=0; s < 2*(M+1)-1; s++) {
786 for (
int r=0; r < 2*(M+1)-1; r++) {
788 if (s%2==0 && r%2==0 && t%2==0) {
794 (*this->pointsRep_)[counter][0] = r*h/2.0 + offset_x * H;
795 if ((*this->pointsRep_)[counter][0]<eps && (*this->pointsRep_)[counter][0]>-eps) (*this->pointsRep_)[counter][0]=0.0;
796 (*this->pointsRep_)[counter][1] = s*h/2.0 + offset_y * H;
797 if ((*this->pointsRep_)[counter][1]<eps && (*this->pointsRep_)[counter][1]>-eps) (*this->pointsRep_)[counter][1]=0.0;
798 (*this->pointsRep_)[counter][2] = t*h/2.0 + offset_z * H;
799 if ((*this->pointsRep_)[counter][2]<eps && (*this->pointsRep_)[counter][2]>-eps) (*this->pointsRep_)[counter][2]=0.0;
801 pointsRepGlobMapping[counter] = r + s*nmbPoints_oneDir + t*nmbPoints_oneDir*nmbPoints_oneDir \
802 + offset_x*(2*(M+1)-2) + offset_y*(nmbPoints_oneDir)*(2*(M+1)-2) + offset_z*(nmbPoints_oneDir)*(nmbPoints_oneDir)*(2*(M+1)-2) ;
804 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[counter][0] < (coorRec[0]+eps) ||
805 (*this->pointsRep_)[counter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[counter][1] < (coorRec[1]+eps) ||
806 (*this->pointsRep_)[counter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[counter][2] < (coorRec[2]+eps) ) {
807 (*this->bcFlagRep_)[counter] = 1;
816 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
818 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
820 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(3,0.0)));
821 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
823 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
824 (*this->pointsUni_)[i][0] = (this->mapUnique_->getGlobalElement(i) % nmbPoints_oneDir) * h/2;
825 if ((*this->pointsUni_)[i][0]<eps && (*this->pointsUni_)[i][0]>-eps) (*this->pointsUni_)[i][0]=0.0;
827 (*this->pointsUni_)[i][1] = ((
int) ((this->mapUnique_->getGlobalElement(i) % (nmbPoints_oneDir*nmbPoints_oneDir)) / nmbPoints_oneDir) + eps) *h/2;
828 if ((*this->pointsUni_)[i][1]<eps && (*this->pointsUni_)[i][1]>-eps) (*this->pointsUni_)[i][1]=0.0;
830 (*this->pointsUni_)[i][2] = ((
int)(this->mapUnique_->getGlobalElement(i) / (nmbPoints_oneDir*nmbPoints_oneDir) + eps)) * h/2;
831 if ((*this->pointsUni_)[i][2]<eps && (*this->pointsUni_)[i][2]>-eps) (*this->pointsUni_)[i][2]=0.0;
833 if ((*this->pointsUni_)[i][0] > (coorRec[0]+length-eps) || (*this->pointsUni_)[i][0] < (coorRec[0]+eps) ||
834 (*this->pointsUni_)[i][1] > (coorRec[1]+width-eps) || (*this->pointsUni_)[i][1] < (coorRec[1]+eps) ||
835 (*this->pointsUni_)[i][2] > (coorRec[2]+height-eps) || (*this->pointsUni_)[i][2] < (coorRec[2]+eps) ) {
836 (*this->bcFlagUni_)[i] = 1;
854 for (
int t=0; t < M; t++) {
855 for (
int s=0; s < M; s++) {
856 for (
int r=0; r < M; r++) {
858 (*elementsVec)[counter][0] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
859 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
860 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
861 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
863 (*elementsVec)[counter][4] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) ;
864 (*elementsVec)[counter][6] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M;
865 (*elementsVec)[counter][7] = 2*(r+1) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M;
866 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M;
867 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M;
868 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t+1);
872 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
873 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
874 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
875 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
877 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M ;
878 (*elementsVec)[counter][6] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
879 (*elementsVec)[counter][7] = 2*(r) +1 + 2*P2M * (s)+P2M + 2*P2M*P2M * (t+1) ;
880 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M ;
881 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) +P2M*P2M ;
882 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t+1);
886 (*elementsVec)[counter][0] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
887 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
888 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
889 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
891 (*elementsVec)[counter][4] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) ;
892 (*elementsVec)[counter][6] = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) ;
893 (*elementsVec)[counter][7] = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) +P2M*P2M ;
894 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) ;
895 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) +P2M*P2M ;
896 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
900 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
901 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
902 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
903 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
905 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) ;
906 (*elementsVec)[counter][6] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) ;
907 (*elementsVec)[counter][7] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
908 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s+1) + 2*P2M*P2M * (t);
909 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
910 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
914 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
915 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
916 (*elementsVec)[counter][2] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
917 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
919 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) ;
920 (*elementsVec)[counter][6] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
921 (*elementsVec)[counter][7] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
922 (*elementsVec)[counter][5] = 2*(r) + 2*P2M*(s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
923 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M*(s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
924 (*elementsVec)[counter][9] = 2*(r) +1 + 2*P2M*(s+1) + 2*P2M*P2M * (t+1) ;
928 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
929 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
930 (*elementsVec)[counter][2] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
931 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
933 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M ;
934 (*elementsVec)[counter][6] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
935 (*elementsVec)[counter][7] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
936 (*elementsVec)[counter][5] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t+1) ;
937 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t+1) ;
938 (*elementsVec)[counter][9] = 2*(r) +1 + 2*P2M*(s+1) + 2*P2M*P2M * (t+1) ;
945 buildElementsClass(elementsVec, elementFlag);
947 else if(FEType ==
"P1-disc" || FEType ==
"P1-disc-global")
949 else if(FEType ==
"Q1"){
952 else if(FEType ==
"Q2"){
955 else if(FEType ==
"Q2-20"){
966 int numProcsCoarseSolve){
970 using Teuchos::ScalarTraits;
973 bool verbose (this->comm_->getRank() == 0);
975 setRankRange( numProcsCoarseSolve );
978 std::cout << std::endl;
980 SC eps = ScalarTraits<SC>::eps();
982 int rank = this->comm_->getRank();
983 int size = this->comm_->getSize() - numProcsCoarseSolve;
991 LO nmbPoints = 4*M*M*M;
994 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
996 this->numElementsGlob_ = (nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1);
1004 nmbElements = M*M*M;
1009 int offset_x = (rank % N);
1013 if ((rank % (N*N))>=N) {
1014 offset_y = (int) (rank % (N*N))/(N);
1017 if ((rank % (N*N*N))>=N*N ) {
1018 offset_z = (int) (rank % (N*N*N))/(N*(N));
1022 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
1023 this->pointsUni_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
1024 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
1025 this->bcFlagUni_.reset(
new std::vector<int> (nmbPoints,0));
1026 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
1030 std::cout <<
"-- Building P1-disc Points and Elements according to Q2 ... " << std::flush;
1032 vec2D_int_ptr_Type elementsVec = Teuchos::rcp(
new vec2D_int_Type(nmbElements, vec_int_Type(4, -1)));
1036 GO globalCounterPoints = rank * nmbPoints;
1037 for (
int t=0; t < M; t++) {
1038 for (
int s=0; s < M; s++) {
1039 for (
int r=0; r < M; r++) {
1042 (*this->pointsRep_)[pCounter][0] = r*h + offset_x * H;
1043 (*this->pointsRep_)[pCounter][1] = s*h + offset_y * H;
1044 (*this->pointsRep_)[pCounter][2] = t*h + offset_z * H;
1045 if ((*this->pointsRep_)[pCounter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[pCounter][0] < (coorRec[0]+eps) ||
1046 (*this->pointsRep_)[pCounter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[pCounter][1] < (coorRec[1]+eps) ||
1047 (*this->pointsRep_)[pCounter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[pCounter][2] < (coorRec[2]+eps) ) {
1049 (*this->bcFlagRep_)[counter] = 1;
1052 (*this->pointsUni_)[pCounter][0] = (*this->pointsRep_)[pCounter][0];
1053 (*this->pointsUni_)[pCounter][1] = (*this->pointsRep_)[pCounter][1];
1054 (*this->pointsUni_)[pCounter][2] = (*this->pointsRep_)[pCounter][2];
1056 (*this->bcFlagUni_)[pCounter] = (*this->bcFlagRep_)[pCounter];
1058 (*elementsVec)[counter][0] = pCounter;
1059 pointsRepGlobMapping[pCounter] = globalCounterPoints;
1060 globalCounterPoints++;
1064 (*this->pointsRep_)[pCounter][0] = (r+1)*h + offset_x * H;
1065 (*this->pointsRep_)[pCounter][1] = s*h + offset_y * H;
1066 (*this->pointsRep_)[pCounter][2] = t*h + offset_z * H;
1067 if ((*this->pointsRep_)[pCounter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[pCounter][0] < (coorRec[0]+eps) ||
1068 (*this->pointsRep_)[pCounter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[pCounter][1] < (coorRec[1]+eps) ||
1069 (*this->pointsRep_)[pCounter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[pCounter][2] < (coorRec[2]+eps) ) {
1071 (*this->bcFlagRep_)[counter] = 1;
1074 (*this->pointsUni_)[pCounter][0] = (*this->pointsRep_)[pCounter][0];
1075 (*this->pointsUni_)[pCounter][1] = (*this->pointsRep_)[pCounter][1];
1076 (*this->pointsUni_)[pCounter][2] = (*this->pointsRep_)[pCounter][2];
1078 (*this->bcFlagUni_)[pCounter] = (*this->bcFlagRep_)[pCounter];
1080 (*elementsVec)[counter][1] = pCounter;
1081 pointsRepGlobMapping[pCounter] = globalCounterPoints;
1082 globalCounterPoints++;
1085 (*this->pointsRep_)[pCounter][0] = r*h + offset_x * H;
1086 (*this->pointsRep_)[pCounter][1] = (s+1)*h + offset_y * H;
1087 (*this->pointsRep_)[pCounter][2] = t*h + offset_z * H;
1088 if ((*this->pointsRep_)[pCounter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[pCounter][0] < (coorRec[0]+eps) ||
1089 (*this->pointsRep_)[pCounter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[pCounter][1] < (coorRec[1]+eps) ||
1090 (*this->pointsRep_)[pCounter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[pCounter][2] < (coorRec[2]+eps) ) {
1092 (*this->bcFlagRep_)[counter] = 1;
1095 (*this->pointsUni_)[pCounter][0] = (*this->pointsRep_)[pCounter][0];
1096 (*this->pointsUni_)[pCounter][1] = (*this->pointsRep_)[pCounter][1];
1097 (*this->pointsUni_)[pCounter][2] = (*this->pointsRep_)[pCounter][2];
1099 (*this->bcFlagUni_)[pCounter] = (*this->bcFlagRep_)[pCounter];
1101 (*elementsVec)[counter][2] = pCounter;
1102 pointsRepGlobMapping[pCounter] = globalCounterPoints;
1103 globalCounterPoints++;
1107 (*this->pointsRep_)[pCounter][0] = r*h + offset_x * H;
1108 (*this->pointsRep_)[pCounter][1] = s*h + offset_y * H;
1109 (*this->pointsRep_)[pCounter][2] = (t+1)*h + offset_z * H;
1110 if ((*this->pointsRep_)[pCounter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[pCounter][0] < (coorRec[0]+eps) ||
1111 (*this->pointsRep_)[pCounter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[pCounter][1] < (coorRec[1]+eps) ||
1112 (*this->pointsRep_)[pCounter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[pCounter][2] < (coorRec[2]+eps) ) {
1114 (*this->bcFlagRep_)[counter] = 1;
1117 (*this->pointsUni_)[pCounter][0] = (*this->pointsRep_)[pCounter][0];
1118 (*this->pointsUni_)[pCounter][1] = (*this->pointsRep_)[pCounter][1];
1119 (*this->pointsUni_)[pCounter][2] = (*this->pointsRep_)[pCounter][2];
1121 (*this->bcFlagUni_)[pCounter] = (*this->bcFlagRep_)[pCounter];
1123 (*elementsVec)[counter][3] = pCounter;
1124 pointsRepGlobMapping[pCounter] = globalCounterPoints;
1125 globalCounterPoints++;
1132 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
1134 this->mapUnique_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
1136 buildElementsClass(elementsVec);
1139 std::cout <<
"done!" << std::endl;
1269 int numProcsCoarseSolve)
1274 using Teuchos::ScalarTraits;
1276 bool verbose (this->comm_->getRank() == 0);
1279 std::cout << std::endl;
1281 setRankRange( numProcsCoarseSolve );
1283 SC eps = ScalarTraits<SC>::eps();
1285 int rank = this->comm_->getRank();
1286 int size = this->comm_->getSize() - numProcsCoarseSolve;
1288 SC h = length/(M*N);
1293 LO nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1);
1294 LO nmbPoints = (2*(M+1)-1)*(2*(M+1)-1)*(2*(M+1)-1);
1296 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
1298 this->numElementsGlob_ = (nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1);
1306 nmbElements = M*M*M;
1309 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
1310 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
1311 vec2D_int_ptr_Type elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements,std::vector<int>(27,-1)));
1312 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
1315 int offset_x = (rank % N);
1319 if ((rank % (N*N))>=N) {
1320 offset_y = (int) (rank % (N*N))/(N);
1323 if ((rank % (N*N*N))>=N*N ) {
1324 offset_z = (int) (rank % (N*N*N))/(N*(N));
1330 for (
int t=0; t < 2*(M+1)-1; t++) {
1331 for (
int s=0; s < 2*(M+1)-1; s++) {
1332 for (
int r=0; r < 2*(M+1)-1; r++) {
1334 if (s%2==0 && r%2==0 && t%2==0) {
1340 (*this->pointsRep_)[counter][0] = r*h/2.0 + offset_x * H;
1341 if ((*this->pointsRep_)[counter][0]<eps && (*this->pointsRep_)[counter][0]>-eps) (*this->pointsRep_)[counter][0]=0.0;
1342 (*this->pointsRep_)[counter][1] = s*h/2.0 + offset_y * H;
1343 if ((*this->pointsRep_)[counter][1]<eps && (*this->pointsRep_)[counter][1]>-eps) (*this->pointsRep_)[counter][1]=0.0;
1344 (*this->pointsRep_)[counter][2] = t*h/2.0 + offset_z * H;
1345 if ((*this->pointsRep_)[counter][2]<eps && (*this->pointsRep_)[counter][2]>-eps) (*this->pointsRep_)[counter][2]=0.0;
1347 pointsRepGlobMapping[counter] = r + s*nmbPoints_oneDir + t*nmbPoints_oneDir*nmbPoints_oneDir \
1348 + offset_x*(2*(M+1)-2) + offset_y*(nmbPoints_oneDir)*(2*(M+1)-2) + offset_z*(nmbPoints_oneDir)*(nmbPoints_oneDir)*(2*(M+1)-2) ;
1350 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[counter][0] < (coorRec[0]+eps) ||
1351 (*this->pointsRep_)[counter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[counter][1] < (coorRec[1]+eps) ||
1352 (*this->pointsRep_)[counter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[counter][2] < (coorRec[2]+eps) ) {
1353 (*this->bcFlagRep_)[counter] = 1;
1362 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
1364 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
1366 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(3,0.0)));
1367 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
1369 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
1370 (*this->pointsUni_)[i][0] = (this->mapUnique_->getGlobalElement(i) % nmbPoints_oneDir) * h/2;
1371 if ((*this->pointsUni_)[i][0]<eps && (*this->pointsUni_)[i][0]>-eps) (*this->pointsUni_)[i][0]=0.0;
1373 (*this->pointsUni_)[i][1] = ((
int) ((this->mapUnique_->getGlobalElement(i) % (nmbPoints_oneDir*nmbPoints_oneDir)) / nmbPoints_oneDir) + eps) *h/2;
1374 if ((*this->pointsUni_)[i][1]<eps && (*this->pointsUni_)[i][1]>-eps) (*this->pointsUni_)[i][1]=0.0;
1376 (*this->pointsUni_)[i][2] = ((
int)(this->mapUnique_->getGlobalElement(i) / (nmbPoints_oneDir*nmbPoints_oneDir) + eps)) * h/2;
1377 if ((*this->pointsUni_)[i][2]<eps && (*this->pointsUni_)[i][2]>-eps) (*this->pointsUni_)[i][2]=0.0;
1379 if ((*this->pointsUni_)[i][0] > (coorRec[0]+length-eps) || (*this->pointsUni_)[i][0] < (coorRec[0]+eps) ||
1380 (*this->pointsUni_)[i][1] > (coorRec[1]+width-eps) || (*this->pointsUni_)[i][1] < (coorRec[1]+eps) ||
1381 (*this->pointsUni_)[i][2] > (coorRec[2]+height-eps) || (*this->pointsUni_)[i][2] < (coorRec[2]+eps) ) {
1382 (*this->bcFlagUni_)[i] = 1;
1387 int P2M = 2*(M+1)-1;
1390 for (
int t=0; t < M; t++) {
1391 for (
int s=0; s < M; s++) {
1392 for (
int r=0; r < M; r++) {
1394 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
1395 (*elementsVec)[counter][1] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
1396 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
1397 (*elementsVec)[counter][3] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
1399 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
1400 (*elementsVec)[counter][5] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
1401 (*elementsVec)[counter][6] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
1402 (*elementsVec)[counter][7] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
1404 (*elementsVec)[counter][8] = 2*(r)+1 + 2*P2M * (s) + 2*P2M*P2M * (t) ;
1405 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) ;
1406 (*elementsVec)[counter][10] = 2*(r)+1 + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
1407 (*elementsVec)[counter][11] = 2*(r) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) ;
1409 (*elementsVec)[counter][12] = 2*(r)+1 + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
1410 (*elementsVec)[counter][13] = 2*(r+1) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t+1) ;
1411 (*elementsVec)[counter][14] = 2*(r)+1 + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
1412 (*elementsVec)[counter][15] = 2*(r) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t+1) ;
1414 (*elementsVec)[counter][16] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) + P2M*P2M;
1415 (*elementsVec)[counter][17] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) + P2M*P2M;
1416 (*elementsVec)[counter][18] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) + P2M*P2M;
1417 (*elementsVec)[counter][19] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) + P2M*P2M;
1419 (*elementsVec)[counter][20] = 2*(r)+1 + 2*P2M * (s) + 2*P2M*P2M * (t) + P2M*P2M;
1420 (*elementsVec)[counter][21] = 2*(r+1) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) + P2M*P2M;
1421 (*elementsVec)[counter][22] = 2*(r)+1 + 2*P2M * (s+1) + 2*P2M*P2M * (t) + P2M*P2M;
1422 (*elementsVec)[counter][23] = 2*(r) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) + P2M*P2M;
1424 (*elementsVec)[counter][24] = 2*(r)+1 + 2*P2M * (s) + P2M + 2*P2M*P2M * (t);
1425 (*elementsVec)[counter][25] = 2*(r)+1 + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) + P2M*P2M;
1426 (*elementsVec)[counter][26] = 2*(r)+1 + 2*P2M * (s) + P2M + 2*P2M*P2M * (t+1);
1432 buildElementsClass(elementsVec);
1479 int numProcsCoarseSolve)
1484 using Teuchos::ScalarTraits;
1486 bool verbose (this->comm_->getRank() == 0);
1488 setRankRange( numProcsCoarseSolve );
1491 std::cout << std::endl;
1493 std::cout <<
"WARNING! Not working properly in parallel - fix global indexing." << std::endl;
1495 SC eps = ScalarTraits<SC>::eps();
1497 int rank = this->comm_->getRank();
1498 int size = this->comm_->getSize() - numProcsCoarseSolve;
1500 SC h = length/(M*N);
1505 LO nmbPoints_oneDirFull = N * (2*(M+1)-1) - (N-1);
1506 LO nmbPoints_oneDirMid = N * (M+1) - (N-1);
1508 LO nmbPoints = ( (M+1) * (2*(M+1)-1) + M * (M+1) ) * (M+1) +
1509 ( (M+1) * (M+1) ) * M;
1511 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
1513 this->numElementsGlob_ = (nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1);
1521 nmbElements = M*M*M;
1524 this->pointsRep_.reset(
new std::vector<std::vector<double> >(0));
1525 this->bcFlagRep_.reset(
new std::vector<int> (0));
1526 vec2D_int_ptr_Type elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements, std::vector<int>(20,-1)));
1527 Teuchos::Array<GO> pointsRepGlobMapping(0);
1530 int offset_x = (rank % N);
1534 if ((rank % (N*N))>=N) {
1535 offset_y = (int) (rank % (N*N))/(N);
1538 if ((rank % (N*N*N))>=N*N ) {
1539 offset_z = (int) (rank % (N*N*N))/(N*(N));
1542 for (
int t=0; t < 2*(M+1)-1; t++) {
1543 for (
int s=0; s < 2*(M+1)-1; s++) {
1545 for (
int r=0; r < 2*(M+1)-1; r++) {
1546 GO index = globalID_Q2_20Cube( r, s, t, rr, offset_x, offset_y, offset_z, M, N,
1547 nmbPoints_oneDirFull, nmbPoints_oneDirMid );
1550 std::vector<double> p(3,0.0);
1551 p[0] = r*h/2.0 + offset_x * H;
1552 p[1] = s*h/2.0 + offset_y * H;
1553 p[2] = t*h/2.0 + offset_z * H;
1554 this->pointsRep_->push_back(p);
1555 pointsRepGlobMapping.push_back( index );
1557 if (p[0] > (coorRec[0]+length-eps) || p[0] < (coorRec[0]+eps) ||
1558 p[1] > (coorRec[1]+width-eps) || p[1] < (coorRec[1]+eps) ||
1559 p[2] > (coorRec[2]+height-eps) || p[2] < (coorRec[2]+eps) )
1560 this->bcFlagRep_->push_back(1);
1562 this->bcFlagRep_->push_back(0);
1569 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
1571 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
1573 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(3,0.0)));
1574 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
1576 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
1578 LO index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
1580 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
1581 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
1582 (*this->pointsUni_)[i][2] = (*this->pointsRep_)[index][2];
1583 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
1586 int P2M = 2*(M+1)-1;
1589 for (
int t=0; t < M; t++) {
1590 for (
int s=0; s < M; s++) {
1591 for (
int r=0; r < M; r++) {
1593 (*elementsVec)[counter][0] = 2*(r) + (P2M+P1M) * (s) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) ;
1594 (*elementsVec)[counter][1] = 2*(r+1) + (P2M+P1M) * (s) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) ;
1595 (*elementsVec)[counter][2] = 2*(r+1) + (P2M+P1M) * (s+1) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) ;
1596 (*elementsVec)[counter][3] = 2*(r) + (P2M+P1M) * (s+1) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) ;
1598 (*elementsVec)[counter][4] = 2*(r) + (P2M+P1M) * (s) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t+1) ;
1599 (*elementsVec)[counter][5] = 2*(r+1) + (P2M+P1M) * (s) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t+1) ;
1600 (*elementsVec)[counter][6] = 2*(r+1) + (P2M+P1M) * (s+1) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t+1) ;
1601 (*elementsVec)[counter][7] = 2*(r) + (P2M+P1M) * (s+1) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t+1) ;
1603 (*elementsVec)[counter][8] = 2*(r)+1 + (P2M+P1M) * (s) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) ;
1604 (*elementsVec)[counter][9] = (r+1) + (P2M+P1M) * (s) + P2M + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) ;
1605 (*elementsVec)[counter][10] = 2*(r)+1 + (P2M+P1M) * (s+1) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) ;
1606 (*elementsVec)[counter][11] = r + (P2M+P1M) * (s) + P2M + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) ;
1608 (*elementsVec)[counter][12] = 2*(r)+1 + (P2M+P1M) * (s) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t+1) ;
1609 (*elementsVec)[counter][13] = (r+1) + (P2M+P1M) * (s) + P2M + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t+1) ;
1610 (*elementsVec)[counter][14] = 2*(r)+1 + (P2M+P1M) * (s+1) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t+1) ;
1611 (*elementsVec)[counter][15] = r + (P2M+P1M) * (s) + P2M + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t+1) ;
1613 (*elementsVec)[counter][16] = (r) + (P1M) * (s) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) + P2M*(M+1)+P1M*M;
1614 (*elementsVec)[counter][17] = (r+1) + (P1M) * (s) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) + P2M*(M+1)+P1M*M;
1615 (*elementsVec)[counter][18] = (r+1) + (P1M) * (s+1) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) + P2M*(M+1)+P1M*M;
1616 (*elementsVec)[counter][19] = r + (P1M) * (s+1) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) + P2M*(M+1)+P1M*M;
1629 int numProcsCoarseSolve){
1633 using Teuchos::ScalarTraits;
1635 typedef ScalarTraits<SC> ST;
1638 bool verbose (this->comm_->getRank() == 0);
1640 setRankRange( numProcsCoarseSolve );
1642 int rank = this->comm_->getRank();
1643 int size = this->comm_->getSize() - numProcsCoarseSolve;
1645 int bfs_multiplier = (int) 2*(length)-1;
1647 int nmbSubdomainsSquares = size / bfs_multiplier;
1648 int nmbSubdomainsSquares_OneDir = (std::pow(nmbSubdomainsSquares,1./3.) + 100*eps);
1650 SC h = ST::one()/(M*N);
1653 LO nmbPoints_oneDir = N * (M+1) - (N-1);
1654 LO nmbPoints = (M+1)*(M+1)*(M+1);
1658 LO nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1) ;
1662 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
1663 this->numElementsGlob_ = (nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1) * bfs_multiplier;
1671 nmbElements = M*M*M;
1674 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
1675 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,10));
1676 vec2D_int_ptr_Type elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements, std::vector<int>(27,-1)));
1677 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
1679 int whichSquareSet = (int)rank / nmbSubdomainsSquares;
1681 int offset_Squares_x = (int) (whichSquareSet+1) / 2;
1682 int offset_Squares_y = 0;
1683 int offset_Squares_z = ((whichSquareSet+1) % 2);
1686 int offset_x = ((rank - nmbSubdomainsSquares*whichSquareSet) % N);
1689 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))>=N) {
1690 offset_y = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))/(N);
1693 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))>=N*N ) {
1694 offset_z = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))/(N*(N));
1697 for (
int t=0; t < M+1; t++) {
1698 for (
int s=0; s < M+1; s++) {
1699 for (
int r=0; r < M+1; r++) {
1701 (*this->pointsRep_)[counter][0] = coorRec[0] + r*h + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
1703 (*this->pointsRep_)[counter][1] = coorRec[1] + s*h + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
1705 (*this->pointsRep_)[counter][2] = coorRec[2] + t*h + offset_z * H + offset_Squares_z * H * nmbSubdomainsSquares_OneDir;
1707 pointsRepGlobMapping[counter] = r
1708 + s*(nmbPoints_oneDir_allSubdomain);
1709 if (offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
1710 pointsRepGlobMapping[counter] -= s*(nmbPoints_oneDir-1);
1712 else if(offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=M){
1713 pointsRepGlobMapping[counter] -= s*(nmbPoints_oneDir-1);
1716 pointsRepGlobMapping[counter] += t*nmbPoints_oneDir_allSubdomain*nmbPoints_oneDir;
1717 if (offset_Squares_x > 0 && offset_Squares_z == 0 ) {
1718 pointsRepGlobMapping[counter] -= t*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
1721 pointsRepGlobMapping[counter] += offset_x*(M)
1722 + offset_y*( nmbPoints_oneDir_allSubdomain * M );
1723 if (offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
1724 pointsRepGlobMapping[counter] -= offset_y*M*(nmbPoints_oneDir-1);
1726 else if(offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=M){
1727 pointsRepGlobMapping[counter] -= offset_y*M*(nmbPoints_oneDir-1);
1730 pointsRepGlobMapping[counter] += offset_z * M * nmbPoints_oneDir_allSubdomain * nmbPoints_oneDir;
1731 if (offset_Squares_x > 0 && offset_Squares_z == 0 ) {
1732 pointsRepGlobMapping[counter] -= offset_z*M*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
1735 pointsRepGlobMapping[counter] += offset_Squares_x * M * nmbSubdomainsSquares_OneDir;
1736 if (offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
1737 pointsRepGlobMapping[counter] -= M * nmbSubdomainsSquares_OneDir;
1739 else if(offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=M){
1740 pointsRepGlobMapping[counter] -= M * nmbSubdomainsSquares_OneDir;
1743 pointsRepGlobMapping[counter] += offset_Squares_z * nmbPoints_oneDir_allSubdomain * ((M) * nmbSubdomainsSquares_OneDir+1) * M * nmbSubdomainsSquares_OneDir;
1744 if (offset_Squares_z > 0 ) {
1745 pointsRepGlobMapping[counter] -= (nmbPoints_oneDir-1)*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
1752 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
1754 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
1757 std::cout <<
"-- Building Q2 Unique Points ... " << std::flush;
1759 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(3,0.0)));
1760 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),10));
1763 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
1765 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
1767 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
1768 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
1769 (*this->pointsUni_)[i][2] = (*this->pointsRep_)[index][2];
1770 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
1774 std::cout <<
" done! --" << std::endl;
1779 for (
int t=0; t < M; t++) {
1780 for (
int s=0; s < M; s++) {
1781 for (
int r=0; r < M; r++) {
1783 (*elementsVec)[counter][0] = r + (M+1) * (s) + (M+1)*(M+1) * t ;
1784 (*elementsVec)[counter][1] = r + 1 + (M+1) * (s) + (M+1)*(M+1) * t ;
1785 (*elementsVec)[counter][2] = r + 1 + (M+1) * (s+1) + (M+1)*(M+1) * t ;
1786 (*elementsVec)[counter][3] = r + (M+1) * (s+1) + (M+1)*(M+1) * t ;
1788 (*elementsVec)[counter][4] = r + (M+1) * (s) + (M+1)*(M+1) * (t+1) ;
1789 (*elementsVec)[counter][5] = r + 1 + (M+1) * (s) + (M+1)*(M+1) * (t+1) ;
1790 (*elementsVec)[counter][6] = r + 1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
1791 (*elementsVec)[counter][7] = r + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
1799 buildElementsClass(elementsVec);
1805 int numProcsCoarseSolve){
1809 using Teuchos::ScalarTraits;
1811 typedef ScalarTraits<SC> ST;
1814 bool verbose (this->comm_->getRank() == 0);
1816 setRankRange( numProcsCoarseSolve );
1818 int rank = this->comm_->getRank();
1819 int size = this->comm_->getSize() - numProcsCoarseSolve;
1821 int bfs_multiplier = (int) 2*(length)-1;
1823 int nmbSubdomainsSquares = size / bfs_multiplier;
1824 int nmbSubdomainsSquares_OneDir = (std::pow(nmbSubdomainsSquares,1./3.) + 100*eps);
1826 SC h = ST::one()/(M*N);
1830 LO nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1);
1831 LO nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1) ;
1832 LO nmbPoints = (2*(M+1)-1)*(2*(M+1)-1)*(2*(M+1)-1);
1835 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
1836 this->numElementsGlob_ = (nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1) * bfs_multiplier;
1844 nmbElements = M*M*M;
1847 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
1848 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
1849 vec2D_int_ptr_Type elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements, std::vector<int>(27,-1)));
1850 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
1852 int whichSquareSet = (int)rank / nmbSubdomainsSquares;
1854 int offset_Squares_x = (int) (whichSquareSet+1) / 2;
1855 int offset_Squares_y = 0;
1856 int offset_Squares_z = ((whichSquareSet+1) % 2);
1859 int offset_x = ((rank - nmbSubdomainsSquares*whichSquareSet) % N);
1862 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))>=N) {
1863 offset_y = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))/(N);
1866 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))>=N*N ) {
1867 offset_z = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))/(N*(N));
1870 for (
int t=0; t < 2*(M+1)-1; t++) {
1871 for (
int s=0; s < 2*(M+1)-1; s++) {
1872 for (
int r=0; r < 2*(M+1)-1; r++) {
1874 (*this->pointsRep_)[counter][0] = coorRec[0] + r*h/2. + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
1876 (*this->pointsRep_)[counter][1] = coorRec[1] + s*h/2. + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
1878 (*this->pointsRep_)[counter][2] = coorRec[2] + t*h/2. + offset_z * H + offset_Squares_z * H * nmbSubdomainsSquares_OneDir;
1880 pointsRepGlobMapping[counter] = r
1881 + s*(nmbPoints_oneDir_allSubdomain);
1882 if (offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
1883 pointsRepGlobMapping[counter] -= s*(nmbPoints_oneDir-1);
1885 else if(offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=2*M){
1886 pointsRepGlobMapping[counter] -= s*(nmbPoints_oneDir-1);
1889 pointsRepGlobMapping[counter] += t*nmbPoints_oneDir_allSubdomain*nmbPoints_oneDir;
1890 if (offset_Squares_x > 0 && offset_Squares_z == 0 ) {
1891 pointsRepGlobMapping[counter] -= t*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
1894 pointsRepGlobMapping[counter] += offset_x*(2*M)
1895 + offset_y*( nmbPoints_oneDir_allSubdomain * 2*M );
1896 if (offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
1897 pointsRepGlobMapping[counter] -= offset_y*2*M*(nmbPoints_oneDir-1);
1899 else if(offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=2*M){
1900 pointsRepGlobMapping[counter] -= offset_y*2*M*(nmbPoints_oneDir-1);
1903 pointsRepGlobMapping[counter] += offset_z * 2*M * nmbPoints_oneDir_allSubdomain * nmbPoints_oneDir;
1904 if (offset_Squares_x > 0 && offset_Squares_z == 0 ) {
1905 pointsRepGlobMapping[counter] -= offset_z*2*M*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
1908 pointsRepGlobMapping[counter] += offset_Squares_x * 2*M * nmbSubdomainsSquares_OneDir;
1909 if (offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
1910 pointsRepGlobMapping[counter] -= 2*M * nmbSubdomainsSquares_OneDir;
1912 else if(offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=2*M){
1913 pointsRepGlobMapping[counter] -= 2*M * nmbSubdomainsSquares_OneDir;
1916 pointsRepGlobMapping[counter] += offset_Squares_z * nmbPoints_oneDir_allSubdomain * ((2*M) * nmbSubdomainsSquares_OneDir+1) * 2*M * nmbSubdomainsSquares_OneDir;
1917 if (offset_Squares_z > 0 ) {
1918 pointsRepGlobMapping[counter] -= (nmbPoints_oneDir-1)*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
1925 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
1927 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
1930 std::cout <<
"-- Building Q2 Unique Points ... " << std::flush;
1932 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(3,0.0)));
1933 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
1936 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
1938 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
1940 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
1941 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
1942 (*this->pointsUni_)[i][2] = (*this->pointsRep_)[index][2];
1943 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
1947 std::cout <<
" done! --" << std::endl;
1949 int P2M = 2*(M+1)-1;
1952 for (
int t=0; t < M; t++) {
1953 for (
int s=0; s < M; s++) {
1954 for (
int r=0; r < M; r++) {
1956 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
1957 (*elementsVec)[counter][1] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
1958 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
1959 (*elementsVec)[counter][3] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
1961 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
1962 (*elementsVec)[counter][5] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
1963 (*elementsVec)[counter][6] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
1964 (*elementsVec)[counter][7] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
1966 (*elementsVec)[counter][8] = 2*(r)+1 + 2*P2M * (s) + 2*P2M*P2M * (t) ;
1967 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) ;
1968 (*elementsVec)[counter][10] = 2*(r)+1 + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
1969 (*elementsVec)[counter][11] = 2*(r) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) ;
1971 (*elementsVec)[counter][12] = 2*(r)+1 + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
1972 (*elementsVec)[counter][13] = 2*(r+1) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t+1) ;
1973 (*elementsVec)[counter][14] = 2*(r)+1 + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
1974 (*elementsVec)[counter][15] = 2*(r) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t+1) ;
1976 (*elementsVec)[counter][16] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) + P2M*P2M;
1977 (*elementsVec)[counter][17] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) + P2M*P2M;
1978 (*elementsVec)[counter][18] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) + P2M*P2M;
1979 (*elementsVec)[counter][19] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) + P2M*P2M;
1981 (*elementsVec)[counter][20] = 2*(r)+1 + 2*P2M * (s) + 2*P2M*P2M * (t) + P2M*P2M;
1982 (*elementsVec)[counter][21] = 2*(r+1) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) + P2M*P2M;
1983 (*elementsVec)[counter][22] = 2*(r)+1 + 2*P2M * (s+1) + 2*P2M*P2M * (t) + P2M*P2M;
1984 (*elementsVec)[counter][23] = 2*(r) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) + P2M*P2M;
1986 (*elementsVec)[counter][24] = 2*(r)+1 + 2*P2M * (s) + P2M + 2*P2M*P2M * (t);
1987 (*elementsVec)[counter][25] = 2*(r)+1 + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) + P2M*P2M;
1988 (*elementsVec)[counter][26] = 2*(r)+1 + 2*P2M * (s) + P2M + 2*P2M*P2M * (t+1);
1995 buildElementsClass(elementsVec);
2002 int numProcsCoarseSolve) {
2007 using Teuchos::ScalarTraits;
2009 TEUCHOS_TEST_FOR_EXCEPTION(!(M>=1),std::logic_error,
"H/h is to small.");
2010 TEUCHOS_TEST_FOR_EXCEPTION(this->comm_.is_null(),std::runtime_error,
"comm_ is null.");
2012 SC eps = ScalarTraits<SC>::eps();
2014 bool verbose (this->comm_->getRank() == 0);
2016 setRankRange( numProcsCoarseSolve );
2018 int rank = this->comm_->getRank();
2019 int size = this->comm_->getSize() - numProcsCoarseSolve;
2021 int bfs_multiplier = (int) 2*(length)-1;
2023 int nmbSubdomainsSquares = size / bfs_multiplier;
2024 int nmbSubdomainsSquares_OneDir = (std::pow(nmbSubdomainsSquares,1/2.) + 100*eps);
2026 vec2D_int_ptr_Type elementsVec;
2031 double h = 1./(M*N);
2033 GO nmbPoints_oneDir;
2034 GO nmbPoints_oneDir_allSubdomain;
2035 if (FEType ==
"P0") {
2036 nmbPoints_oneDir = N * (M+1) - (N-1) ;
2037 nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1) ;
2038 nmbPoints = (M+1)*(M+1) ;
2040 else if (FEType ==
"P1") {
2041 nmbPoints_oneDir = N * (M+1) - (N-1) ;
2042 nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1) ;
2043 nmbPoints = (M+1)*(M+1) ;
2045 else if(FEType ==
"P2"){
2046 nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1) ;
2047 nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1) ;
2048 nmbPoints = (2*(M+1)-1)*(2*(M+1)-1) ;
2051 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Wrong FE-Type, either P1 or P2.");
2054 this->FEType_ = FEType;
2056 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
2058 this->numElementsGlob_ = 2*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1) * bfs_multiplier;
2066 nmbElements = 2*(M)*(M);
2070 if (FEType ==
"P0") {
2072 std::cout <<
"-- H:"<<H <<
" h:" <<h <<
" --" << std::endl;
2075 std::cout <<
"-- Building P0 Points Repeated ... " << std::endl;
2077 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(2,0.0)));
2078 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
2079 elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements, std::vector<int>(3,-1)));
2081 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
2083 int whichSquareSet = (int)rank / nmbSubdomainsSquares;
2085 int offset_Squares_x = (int) (whichSquareSet+1) / 2;
2086 int offset_Squares_y = ((whichSquareSet+1) % 2);
2088 int offset_x = ((rank - nmbSubdomainsSquares*whichSquareSet) % N);
2091 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))>=N) {
2092 offset_y = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))/(N);
2095 for (
int s=0; s < M+1; s++) {
2096 for (
int r=0; r < M+1; r++) {
2097 (*this->pointsRep_)[counter][0] = coorRec[0] + r*h + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
2098 (*this->pointsRep_)[counter][1] = coorRec[1] + s*h + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
2099 pointsRepGlobMapping[counter] = r + s*(nmbPoints_oneDir_allSubdomain - (1-offset_Squares_y)*(nmbPoints_oneDir-1))
2101 + offset_y*((nmbPoints_oneDir_allSubdomain) - (1-offset_Squares_y)*(nmbPoints_oneDir-1)) *M
2102 + offset_Squares_x * M * nmbSubdomainsSquares_OneDir
2103 + offset_Squares_y * (nmbPoints_oneDir_allSubdomain * M * nmbSubdomainsSquares_OneDir
2104 - (nmbPoints_oneDir-1)*(nmbPoints_oneDir-1));
2106 if (offset_Squares_x>0 && offset_Squares_y==0 ) {
2107 pointsRepGlobMapping[counter] -= nmbPoints_oneDir-1;
2109 if (offset_Squares_x>0 && offset_Squares_y==0 && offset_y+1==nmbSubdomainsSquares_OneDir && s==M) {
2110 pointsRepGlobMapping[counter] += nmbPoints_oneDir-1;
2112 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[counter][0] < (coorRec[0]+eps) ||
2113 (*this->pointsRep_)[counter][1] > (coorRec[1]+height-eps) || (*this->pointsRep_)[counter][1] < (coorRec[1]+eps)) {
2114 (*this->bcFlagRep_)[counter] = 1;
2122 std::cout <<
" done! --" << std::endl;
2126 std::cout <<
"-- Building P0 Repeated and Unique Map ... " << std::flush;
2131 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
2133 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
2135 std::cout <<
" done! --" << std::endl;
2139 std::cout <<
"-- Building P0 Unique Points ... " << std::flush;
2142 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(), std::vector<double>(2,0.0)));
2143 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
2145 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
2147 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
2149 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
2150 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
2151 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
2155 std::cout <<
" done! --" << std::endl;
2160 std::cout <<
"-- Building P0 Elements ... " << std::flush;
2164 for (
int s=0; s < M; s++) {
2165 for (
int r=0; r < M; r++) {
2166 (*elementsVec)[counter][0] = r+1 + (M+1) * s;
2167 (*elementsVec)[counter][1] = r + (M+1) * s ;
2168 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1);
2170 (*elementsVec)[counter][0] = r + (M+1) * (s+1);
2171 (*elementsVec)[counter][1] = r + (M+1) * (s);
2172 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1);
2178 std::cout <<
" done! --" << std::endl;
2183 else if (FEType ==
"P1") {
2185 std::cout <<
"-- H:"<<H <<
" h:" <<h <<
" --" << std::endl;
2188 std::cout <<
"-- Building P1 Points Repeated ... " << std::endl;
2191 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(2,0.0)));
2192 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
2193 elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements,std::vector<int>(3,-1)));
2195 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
2197 int whichSquareSet = (int)rank / nmbSubdomainsSquares;
2199 int offset_Squares_x = (int) (whichSquareSet+1) / 2;
2200 int offset_Squares_y = ((whichSquareSet+1) % 2);
2202 int offset_x = ((rank - nmbSubdomainsSquares*whichSquareSet) % N);
2205 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))>=N) {
2206 offset_y = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))/(N);
2209 for (
int s=0; s < M+1; s++) {
2210 for (
int r=0; r < M+1; r++) {
2211 (*this->pointsRep_)[counter][0] = coorRec[0] + r*h + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
2212 (*this->pointsRep_)[counter][1] = coorRec[1] + s*h + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
2213 pointsRepGlobMapping[counter] = r + s*(nmbPoints_oneDir_allSubdomain - (1-offset_Squares_y)*(nmbPoints_oneDir-1))
2215 + offset_y*((nmbPoints_oneDir_allSubdomain) - (1-offset_Squares_y)*(nmbPoints_oneDir-1)) *M
2216 + offset_Squares_x * M * nmbSubdomainsSquares_OneDir
2217 + offset_Squares_y * (nmbPoints_oneDir_allSubdomain * M * nmbSubdomainsSquares_OneDir
2218 - (nmbPoints_oneDir-1)*(nmbPoints_oneDir-1));
2220 if (offset_Squares_x>0 && offset_Squares_y==0 ) {
2221 pointsRepGlobMapping[counter] -= nmbPoints_oneDir-1;
2223 if (offset_Squares_x>0 && offset_Squares_y==0 && offset_y+1==nmbSubdomainsSquares_OneDir && s==M) {
2224 pointsRepGlobMapping[counter] += nmbPoints_oneDir-1;
2226 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[counter][0] < (coorRec[0]+eps) ||
2227 (*this->pointsRep_)[counter][1] > (coorRec[1]+height-eps) || (*this->pointsRep_)[counter][1] < (coorRec[1]+eps)) {
2228 (*this->bcFlagRep_)[counter] = 1;
2236 std::cout <<
" done! --" << std::endl;
2240 std::cout <<
"-- Building P1 Repeated and Unique Map ... " << std::flush;
2246 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
2248 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
2251 std::cout <<
" done! --" << std::endl;
2255 std::cout <<
"-- Building P1 Unique Points ... " << std::flush;
2258 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(), std::vector<double>(2,0.0)));
2259 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
2261 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
2263 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
2265 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
2266 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
2267 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
2271 std::cout <<
" done! --" << std::endl;
2276 std::cout <<
"-- Building P1 Elements ... " << std::flush;
2280 for (
int s=0; s < M; s++) {
2281 for (
int r=0; r < M; r++) {
2282 (*elementsVec)[counter][0] = r+1 + (M+1) * s;
2283 (*elementsVec)[counter][1] = r + (M+1) * s ;
2284 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1);
2286 (*elementsVec)[counter][0] = r + (M+1) * (s+1);
2287 (*elementsVec)[counter][1] = r + (M+1) * (s);
2288 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1);
2294 std::cout <<
" done! --" << std::endl;
2299 else if(FEType ==
"P2"){
2301 std::cout <<
"-- H:"<<H <<
" h:" <<h <<
" --" << std::endl;
2304 std::cout <<
"-- Building P2 Points Repeated ... " << std::flush;
2307 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(2,0.0)));
2308 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
2309 elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements,std::vector<int>(6,-1)));
2310 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
2312 int whichSquareSet = (int)rank / nmbSubdomainsSquares;
2314 int offset_Squares_x = (int) (whichSquareSet+1) / 2;
2315 int offset_Squares_y = ((whichSquareSet+1) % 2);
2318 int offset_x = ((rank - nmbSubdomainsSquares*whichSquareSet) % N);
2322 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))>=N) {
2323 offset_y = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))/(N);
2331 for (
int s=0; s < 2*(M+1)-1; s++) {
2332 for (
int r=0; r < 2*(M+1)-1; r++) {
2334 if (s%2==0 && r%2==0) {
2339 (*this->pointsRep_)[counter][0] = coorRec[0] + r*h/2. + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
2340 (*this->pointsRep_)[counter][1] = coorRec[1] + s*h/2. + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
2341 pointsRepGlobMapping[counter] = r + s*(nmbPoints_oneDir_allSubdomain - (1-offset_Squares_y)*(nmbPoints_oneDir-1))
2342 + offset_x*(2*(M+1)-2)
2343 + offset_y*((nmbPoints_oneDir_allSubdomain) - (1-offset_Squares_y)*(nmbPoints_oneDir-1)) * (2*(M+1)-2)
2344 + offset_Squares_x * (2*(M+1)-2) * nmbSubdomainsSquares_OneDir
2345 + offset_Squares_y * (nmbPoints_oneDir_allSubdomain * 2*M * nmbSubdomainsSquares_OneDir
2346 - (nmbPoints_oneDir-1)*(nmbPoints_oneDir-1));
2348 if (offset_Squares_x>0 && offset_Squares_y==0 ) {
2349 pointsRepGlobMapping[counter] -= nmbPoints_oneDir-1;
2351 if (offset_Squares_x>0 && offset_Squares_y==0 && offset_y+1==nmbSubdomainsSquares_OneDir && s==2*M) {
2352 pointsRepGlobMapping[counter] += nmbPoints_oneDir-1;
2354 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[counter][0] < (coorRec[0]+eps) ||
2355 (*this->pointsRep_)[counter][1] > (coorRec[1]+height-eps) || (*this->pointsRep_)[counter][1] < (coorRec[1]+eps)) {
2356 (*this->bcFlagRep_)[counter] = 1;
2364 std::cout <<
" done! --" << std::endl;
2370 std::cout <<
"-- Building P2 Repeated and Unique Map ... " << std::flush;
2374 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
2376 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
2380 std::cout <<
" done! --" << std::endl;
2384 std::cout <<
"-- Building P2 Unique Points ... " << std::flush;
2387 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(2,0.0)));
2388 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
2391 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
2393 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
2395 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
2396 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
2397 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
2401 std::cout <<
" done! --" << std::endl;
2415 std::cout <<
"-- Building P2 Elements ... " << std::flush;
2418 int P2M = 2*(M+1)-1;
2422 for (
int s=0; s < M; s++) {
2423 for (
int r=0; r < M; r++) {
2425 (*elementsVec)[counter][0] = 2*(r+1) + 2*P2M * (s) ;
2426 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) ;
2427 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) ;
2429 (*elementsVec)[counter][3] = 2*(r) +1 + 2*P2M * (s) ;
2430 (*elementsVec)[counter][4] = 2*(r) +1 + 2*P2M * (s) +P2M ;
2431 (*elementsVec)[counter][5] = 2*(r+1) + 2*P2M * (s) +P2M ;
2435 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s+1) ;
2436 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) ;
2437 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) ;
2439 (*elementsVec)[counter][3] = 2*(r) + 2*P2M * (s) +P2M ;
2440 (*elementsVec)[counter][4] = 2*(r) +1 + 2*P2M * (s) +P2M ;
2441 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s+1) ;
2449 std::cout <<
" done! --" << std::endl;
2452 buildElementsClass(elementsVec);
2459 int numProcsCoarseSolve){
2463 using Teuchos::ScalarTraits;
2465 TEUCHOS_TEST_FOR_EXCEPTION(!(M>=1),std::logic_error,
"H/h is to small.");
2466 TEUCHOS_TEST_FOR_EXCEPTION(this->comm_.is_null(),std::runtime_error,
"comm_ is null.");
2468 typedef ScalarTraits<SC> ST;
2471 bool verbose (this->comm_->getRank() == 0);
2473 setRankRange( numProcsCoarseSolve );
2475 int rank = this->comm_->getRank();
2476 int size = this->comm_->getSize() - numProcsCoarseSolve;
2478 int bfs_multiplier = (int) 2*(length)-1;
2480 int nmbSubdomainsSquares = size / bfs_multiplier;
2481 int nmbSubdomainsSquares_OneDir = (std::pow(nmbSubdomainsSquares,1./3.) + 100*eps);
2483 SC h = ST::one()/(M*N);
2489 GO nmbPoints_oneDir;
2490 GO nmbPoints_oneDir_allSubdomain;
2492 if (FEType ==
"P0") {
2493 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"implement P0.");
2495 else if (FEType ==
"P1") {
2496 nmbPoints_oneDir = N * (M+1) - (N-1);
2497 nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1);
2498 nmbPoints = (M+1)*(M+1)*(M+1);
2500 else if(FEType ==
"P2"){
2501 nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1);
2502 nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1) ;
2503 nmbPoints = (2*(M+1)-1)*(2*(M+1)-1)*(2*(M+1)-1);
2505 else if(FEType ==
"P2-CR"){
2506 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"P2-CR might not work properly.");
2507 nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1);
2508 nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1) ;
2509 nmbPoints = (2*(M+1)-1)*(2*(M+1)-1)*(2*(M+1)-1);
2511 else if(FEType ==
"P1-disc" || FEType ==
"P1-disc-global"){
2512 nmbPoints_oneDir = N * (M+1) - (N-1);
2513 nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1);
2514 nmbPoints = (M+1)*(M+1)*(M+1);
2516 else if(FEType ==
"Q1"){
2519 else if(FEType ==
"Q2"){
2523 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Wrong FE-Type, only P1,P1-disc, P1-disc-global, P2, or P2-CR.");
2525 this->FEType_ = FEType;
2527 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
2528 this->numElementsGlob_ = 6*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1) * bfs_multiplier;
2536 nmbElements = 6*M*M*M;
2540 if (FEType ==
"P1") {
2542 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
2543 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
2544 vec2D_int_ptr_Type elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements,std::vector<int>(4,-1)));
2546 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
2548 int whichSquareSet = (int)rank / nmbSubdomainsSquares;
2550 int offset_Squares_x = (int) (whichSquareSet+1) / 2;
2551 int offset_Squares_y = 0;
2552 int offset_Squares_z = ((whichSquareSet+1) % 2);
2555 int offset_x = ((rank - nmbSubdomainsSquares*whichSquareSet) % N);
2558 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))>=N)
2559 offset_y = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))/(N);
2560 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))>=N*N )
2561 offset_z = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))/(N*(N));
2563 for (
int t=0; t < M+1; t++) {
2564 for (
int s=0; s < M+1; s++) {
2565 for (
int r=0; r < M+1; r++) {
2566 (*this->pointsRep_)[counter][0] = coorRec[0] + r*h + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
2568 (*this->pointsRep_)[counter][1] = coorRec[1] + s*h + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
2570 (*this->pointsRep_)[counter][2] = coorRec[2] + t*h + offset_z * H + offset_Squares_z * H * nmbSubdomainsSquares_OneDir;
2572 pointsRepGlobMapping[counter] = r
2573 + s*(nmbPoints_oneDir_allSubdomain);
2574 if (offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
2575 pointsRepGlobMapping[counter] -= s*(nmbPoints_oneDir-1);
2577 else if(offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=M){
2578 pointsRepGlobMapping[counter] -= s*(nmbPoints_oneDir-1);
2581 pointsRepGlobMapping[counter] += t*nmbPoints_oneDir_allSubdomain*nmbPoints_oneDir;
2582 if (offset_Squares_x > 0 && offset_Squares_z == 0 ) {
2583 pointsRepGlobMapping[counter] -= t*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
2586 pointsRepGlobMapping[counter] += offset_x*(M)
2587 + offset_y*( nmbPoints_oneDir_allSubdomain * M );
2588 if (offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
2589 pointsRepGlobMapping[counter] -= offset_y*M*(nmbPoints_oneDir-1);
2591 else if(offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=M){
2592 pointsRepGlobMapping[counter] -= offset_y*M*(nmbPoints_oneDir-1);
2595 pointsRepGlobMapping[counter] += offset_z * M * nmbPoints_oneDir_allSubdomain * nmbPoints_oneDir;
2596 if (offset_Squares_x > 0 && offset_Squares_z == 0 ) {
2597 pointsRepGlobMapping[counter] -= offset_z*M*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
2600 pointsRepGlobMapping[counter] += offset_Squares_x * M * nmbSubdomainsSquares_OneDir;
2601 if (offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
2602 pointsRepGlobMapping[counter] -= M * nmbSubdomainsSquares_OneDir;
2604 else if(offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=M){
2605 pointsRepGlobMapping[counter] -= M * nmbSubdomainsSquares_OneDir;
2608 pointsRepGlobMapping[counter] += offset_Squares_z * nmbPoints_oneDir_allSubdomain * ((M) * nmbSubdomainsSquares_OneDir+1) * M * nmbSubdomainsSquares_OneDir;
2609 if (offset_Squares_z > 0 ) {
2610 pointsRepGlobMapping[counter] -= (nmbPoints_oneDir-1)*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
2618 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
2620 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
2623 std::cout <<
"-- Building P1 Unique Points ... " << std::flush;
2626 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(), std::vector<double>(3,0.0)));
2627 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
2630 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
2631 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
2632 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
2633 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
2634 (*this->pointsUni_)[i][2] = (*this->pointsRep_)[index][2];
2635 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
2639 std::cout <<
" done! --" << std::endl;
2644 std::cout <<
"-- Building P1 Elements ... " << std::flush;
2647 for (
int t=0; t < M; t++) {
2648 for (
int s=0; s < M; s++) {
2649 for (
int r=0; r < M; r++) {
2650 (*elementsVec)[counter][0] = r+1 + (M+1) * s + (M+1)*(M+1) * t ;
2651 (*elementsVec)[counter][1] = r + (M+1) * s + (M+1)*(M+1) * t ;
2652 (*elementsVec)[counter][2] = r+1 + (M+1) * s + (M+1)*(M+1) * (t+1) ;
2653 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
2655 (*elementsVec)[counter][0] = r + (M+1) * s + (M+1)*(M+1) * (t+1) ;
2656 (*elementsVec)[counter][1] = r + (M+1) * s + (M+1)*(M+1) * t ;
2657 (*elementsVec)[counter][2] = r+1 + (M+1) * s + (M+1)*(M+1) * (t+1) ;
2658 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
2660 (*elementsVec)[counter][0] = r+1 + (M+1) * s + (M+1)*(M+1) * t ;
2661 (*elementsVec)[counter][1] = r + (M+1) * s + (M+1)*(M+1) * t ;
2662 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * t ;
2663 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
2665 (*elementsVec)[counter][0] = r + (M+1) * s + (M+1)*(M+1) * t ;
2666 (*elementsVec)[counter][1] = r + (M+1) * (s+1) + (M+1)*(M+1) * t ;
2667 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * t ;
2668 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
2670 (*elementsVec)[counter][0] = r + (M+1) * s + (M+1)*(M+1) * t ;
2671 (*elementsVec)[counter][1] = r + (M+1) * (s+1) + (M+1)*(M+1) * t ;
2672 (*elementsVec)[counter][2] = r + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
2673 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
2675 (*elementsVec)[counter][0] = r + (M+1) * s + (M+1)*(M+1) * t ;
2676 (*elementsVec)[counter][1] = r + (M+1) * s + (M+1)*(M+1) * (t+1) ;
2677 (*elementsVec)[counter][2] = r + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
2678 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
2684 std::cout <<
" done! --" << std::endl;
2686 buildElementsClass(elementsVec);
2688 else if(FEType ==
"P1-disc" || FEType ==
"P1-disc-global")
2690 else if(FEType ==
"P2"){
2692 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
2693 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
2694 vec2D_int_ptr_Type elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements,std::vector<int>(10,-1)));
2695 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
2697 int whichSquareSet = (int)rank / nmbSubdomainsSquares;
2699 int offset_Squares_x = (int) (whichSquareSet+1) / 2;
2700 int offset_Squares_y = 0;
2701 int offset_Squares_z = ((whichSquareSet+1) % 2);
2704 int offset_x = ((rank - nmbSubdomainsSquares*whichSquareSet) % N);
2707 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))>=N) {
2708 offset_y = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))/(N);
2711 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))>=N*N ) {
2712 offset_z = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))/(N*(N));
2719 for (
int t=0; t < 2*(M+1)-1; t++) {
2720 for (
int s=0; s < 2*(M+1)-1; s++) {
2721 for (
int r=0; r < 2*(M+1)-1; r++) {
2723 if (s%2==0 && r%2==0 && t%2==0) {
2729 (*this->pointsRep_)[counter][0] = coorRec[0] + r*h/2. + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
2731 (*this->pointsRep_)[counter][1] = coorRec[1] + s*h/2. + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
2733 (*this->pointsRep_)[counter][2] = coorRec[2] + t*h/2. + offset_z * H + offset_Squares_z * H * nmbSubdomainsSquares_OneDir;
2735 pointsRepGlobMapping[counter] = r
2736 + s*(nmbPoints_oneDir_allSubdomain);
2737 if (offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
2738 pointsRepGlobMapping[counter] -= s*(nmbPoints_oneDir-1);
2740 else if(offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=2*M){
2741 pointsRepGlobMapping[counter] -= s*(nmbPoints_oneDir-1);
2744 pointsRepGlobMapping[counter] += t*nmbPoints_oneDir_allSubdomain*nmbPoints_oneDir;
2745 if (offset_Squares_x > 0 && offset_Squares_z == 0 ) {
2746 pointsRepGlobMapping[counter] -= t*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
2749 pointsRepGlobMapping[counter] += offset_x*(2*M)
2750 + offset_y*( nmbPoints_oneDir_allSubdomain * 2*M );
2751 if (offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
2752 pointsRepGlobMapping[counter] -= offset_y*2*M*(nmbPoints_oneDir-1);
2754 else if(offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=2*M){
2755 pointsRepGlobMapping[counter] -= offset_y*2*M*(nmbPoints_oneDir-1);
2758 pointsRepGlobMapping[counter] += offset_z * 2*M * nmbPoints_oneDir_allSubdomain * nmbPoints_oneDir;
2759 if (offset_Squares_x > 0 && offset_Squares_z == 0 ) {
2760 pointsRepGlobMapping[counter] -= offset_z*2*M*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
2763 pointsRepGlobMapping[counter] += offset_Squares_x * 2*M * nmbSubdomainsSquares_OneDir;
2764 if (offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
2765 pointsRepGlobMapping[counter] -= 2*M * nmbSubdomainsSquares_OneDir;
2767 else if(offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=2*M){
2768 pointsRepGlobMapping[counter] -= 2*M * nmbSubdomainsSquares_OneDir;
2771 pointsRepGlobMapping[counter] += offset_Squares_z * nmbPoints_oneDir_allSubdomain * ((2*M) * nmbSubdomainsSquares_OneDir+1) * 2*M * nmbSubdomainsSquares_OneDir;
2772 if (offset_Squares_z > 0 ) {
2773 pointsRepGlobMapping[counter] -= (nmbPoints_oneDir-1)*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
2780 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
2782 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
2785 std::cout <<
"-- Building P2 Unique Points ... " << std::flush;
2788 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(3,0.0)));
2789 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
2792 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
2794 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
2796 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
2797 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
2798 (*this->pointsUni_)[i][2] = (*this->pointsRep_)[index][2];
2799 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
2803 std::cout <<
" done! --" << std::endl;
2816 int P2M = 2*(M+1)-1;
2819 for (
int t=0; t < M; t++) {
2820 for (
int s=0; s < M; s++) {
2821 for (
int r=0; r < M; r++) {
2823 (*elementsVec)[counter][0] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2824 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2825 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
2826 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
2828 (*elementsVec)[counter][4] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2829 (*elementsVec)[counter][6] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M;
2830 (*elementsVec)[counter][7] = 2*(r+1) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M;
2831 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M;
2832 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M;
2833 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t+1);
2837 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
2838 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2839 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
2840 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
2842 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M ;
2843 (*elementsVec)[counter][6] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
2844 (*elementsVec)[counter][7] = 2*(r) +1 + 2*P2M * (s)+P2M + 2*P2M*P2M * (t+1) ;
2845 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M ;
2846 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) +P2M*P2M ;
2847 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t+1);
2851 (*elementsVec)[counter][0] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2852 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2853 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
2854 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
2856 (*elementsVec)[counter][4] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2857 (*elementsVec)[counter][6] = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) ;
2858 (*elementsVec)[counter][7] = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) +P2M*P2M ;
2859 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) ;
2860 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) +P2M*P2M ;
2861 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
2865 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2866 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
2867 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
2868 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
2870 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) ;
2871 (*elementsVec)[counter][6] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) ;
2872 (*elementsVec)[counter][7] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
2873 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s+1) + 2*P2M*P2M * (t);
2874 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
2875 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
2879 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2880 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
2881 (*elementsVec)[counter][2] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
2882 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
2884 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) ;
2885 (*elementsVec)[counter][6] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
2886 (*elementsVec)[counter][7] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
2887 (*elementsVec)[counter][5] = 2*(r) + 2*P2M*(s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
2888 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M*(s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
2889 (*elementsVec)[counter][9] = 2*(r) +1 + 2*P2M*(s+1) + 2*P2M*P2M * (t+1) ;
2893 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2894 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
2895 (*elementsVec)[counter][2] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
2896 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
2898 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M ;
2899 (*elementsVec)[counter][6] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
2900 (*elementsVec)[counter][7] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
2901 (*elementsVec)[counter][5] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t+1) ;
2902 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t+1) ;
2903 (*elementsVec)[counter][9] = 2*(r) +1 + 2*P2M*(s+1) + 2*P2M*P2M * (t+1) ;
2910 buildElementsClass(elementsVec);
2912 else if(FEType ==
"Q1")
2914 else if(FEType ==
"Q2")
2922 int numProcsCoarseSolve){
2929 using Teuchos::ScalarTraits;
2930 typedef ScalarTraits<SC> ST;
2932 bool verbose (this->comm_->getRank() == 0);
2934 setRankRange( numProcsCoarseSolve );
2937 std::cout << std::endl;
2939 SC eps = ScalarTraits<SC>::eps();
2941 int rank = this->comm_->getRank();
2942 int size = this->comm_->getSize() - numProcsCoarseSolve;
2945 int bfs_multiplier = (int) 2*(length)-1;
2947 int nmbSubdomainsSquares = size / bfs_multiplier;
2948 int nmbSubdomainsSquares_OneDir = (std::pow(nmbSubdomainsSquares,1./3.) + 100*eps);
2950 SC h = ST::one()/(M*N);
2953 LO nmbElements = M*M*M;
2954 LO nmbPoints = 4*M*M*M;
2963 this->numElementsGlob_ = nmbElements * size;
2965 int whichSquareSet = (int)rank / nmbSubdomainsSquares;
2967 int offset_Squares_x = (int) (whichSquareSet+1) / 2;
2968 int offset_Squares_y = 0;
2969 int offset_Squares_z = ((whichSquareSet+1) % 2);
2972 int offset_x = ((rank - nmbSubdomainsSquares*whichSquareSet) % N);
2975 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))>=N)
2976 offset_y = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))/(N);
2978 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))>=N*N )
2979 offset_z = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))/(N*(N));
2982 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
2983 this->pointsUni_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
2984 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
2985 this->bcFlagUni_.reset(
new std::vector<int> (nmbPoints,0));
2986 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
2989 std::cout <<
"-- Building P1-disc Points and Elements according to Q2 ... " << std::flush;
2991 vec2D_int_ptr_Type elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements,std::vector<int>(4,-1)));
2995 GO globalCounterPoints = rank * nmbPoints;
2996 for (
int t=0; t < M; t++) {
2997 for (
int s=0; s < M; s++) {
2998 for (
int r=0; r < M; r++) {
3001 (*this->pointsRep_)[pCounter][0] = coorRec[0] + r*h + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
3002 (*this->pointsRep_)[pCounter][1] = coorRec[1] + s*h + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
3003 (*this->pointsRep_)[pCounter][2] = coorRec[2] + t*h + offset_z * H + offset_Squares_z * H * nmbSubdomainsSquares_OneDir;
3005 if ((*this->pointsRep_)[pCounter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[pCounter][0] < (coorRec[0]+eps) ||
3006 (*this->pointsRep_)[pCounter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[pCounter][1] < (coorRec[1]+eps) ||
3007 (*this->pointsRep_)[pCounter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[pCounter][2] < (coorRec[2]+eps) ) {
3009 (*this->bcFlagRep_)[counter] = 1;
3012 (*this->pointsUni_)[pCounter][0] = (*this->pointsRep_)[pCounter][0];
3013 (*this->pointsUni_)[pCounter][1] = (*this->pointsRep_)[pCounter][1];
3014 (*this->pointsUni_)[pCounter][2] = (*this->pointsRep_)[pCounter][2];
3016 (*this->bcFlagUni_)[pCounter] = (*this->bcFlagRep_)[pCounter];
3018 (*elementsVec)[counter][0] = pCounter;
3019 pointsRepGlobMapping[pCounter] = globalCounterPoints;
3020 globalCounterPoints++;
3024 (*this->pointsRep_)[pCounter][0] = coorRec[0] + (r+1)*h + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
3025 (*this->pointsRep_)[pCounter][1] = coorRec[1] + s*h + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
3026 (*this->pointsRep_)[pCounter][2] = coorRec[2] + t*h + offset_z * H + offset_Squares_z * H * nmbSubdomainsSquares_OneDir;
3027 if ((*this->pointsRep_)[pCounter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[pCounter][0] < (coorRec[0]+eps) ||
3028 (*this->pointsRep_)[pCounter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[pCounter][1] < (coorRec[1]+eps) ||
3029 (*this->pointsRep_)[pCounter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[pCounter][2] < (coorRec[2]+eps) ) {
3031 (*this->bcFlagRep_)[counter] = 1;
3034 (*this->pointsUni_)[pCounter][0] = (*this->pointsRep_)[pCounter][0];
3035 (*this->pointsUni_)[pCounter][1] = (*this->pointsRep_)[pCounter][1];
3036 (*this->pointsUni_)[pCounter][2] = (*this->pointsRep_)[pCounter][2];
3038 (*this->bcFlagUni_)[pCounter] = (*this->bcFlagRep_)[pCounter];
3040 (*elementsVec)[counter][1] = pCounter;
3041 pointsRepGlobMapping[pCounter] = globalCounterPoints;
3042 globalCounterPoints++;
3045 (*this->pointsRep_)[pCounter][0] = coorRec[0] + r*h + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
3046 (*this->pointsRep_)[pCounter][1] = coorRec[1] + (s+1)*h + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
3047 (*this->pointsRep_)[pCounter][2] = coorRec[2] + t*h + offset_z * H + offset_Squares_z * H * nmbSubdomainsSquares_OneDir;
3048 if ((*this->pointsRep_)[pCounter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[pCounter][0] < (coorRec[0]+eps) ||
3049 (*this->pointsRep_)[pCounter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[pCounter][1] < (coorRec[1]+eps) ||
3050 (*this->pointsRep_)[pCounter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[pCounter][2] < (coorRec[2]+eps) ) {
3052 (*this->bcFlagRep_)[counter] = 1;
3055 (*this->pointsUni_)[pCounter][0] = (*this->pointsRep_)[pCounter][0];
3056 (*this->pointsUni_)[pCounter][1] = (*this->pointsRep_)[pCounter][1];
3057 (*this->pointsUni_)[pCounter][2] = (*this->pointsRep_)[pCounter][2];
3059 (*this->bcFlagUni_)[pCounter] = (*this->bcFlagRep_)[pCounter];
3061 (*elementsVec)[counter][2] = pCounter;
3062 pointsRepGlobMapping[pCounter] = globalCounterPoints;
3063 globalCounterPoints++;
3067 (*this->pointsRep_)[pCounter][0] = coorRec[0] + r*h + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
3068 (*this->pointsRep_)[pCounter][1] = coorRec[1] + s*h + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
3069 (*this->pointsRep_)[pCounter][2] = coorRec[2] + (t+1)*h + offset_z * H + offset_Squares_z * H * nmbSubdomainsSquares_OneDir;
3070 if ((*this->pointsRep_)[pCounter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[pCounter][0] < (coorRec[0]+eps) ||
3071 (*this->pointsRep_)[pCounter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[pCounter][1] < (coorRec[1]+eps) ||
3072 (*this->pointsRep_)[pCounter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[pCounter][2] < (coorRec[2]+eps) ) {
3074 (*this->bcFlagRep_)[counter] = 1;
3077 (*this->pointsUni_)[pCounter][0] = (*this->pointsRep_)[pCounter][0];
3078 (*this->pointsUni_)[pCounter][1] = (*this->pointsRep_)[pCounter][1];
3079 (*this->pointsUni_)[pCounter][2] = (*this->pointsRep_)[pCounter][2];
3081 (*this->bcFlagUni_)[pCounter] = (*this->bcFlagRep_)[pCounter];
3083 (*elementsVec)[counter][3] = pCounter;
3084 pointsRepGlobMapping[pCounter] = globalCounterPoints;
3085 globalCounterPoints++;
3092 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
3094 this->mapUnique_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
3096 buildElementsClass(elementsVec);
3099 std::cout <<
"done!" << std::endl;
3107 switch (this->dim_) {
3109 switch (flagsOption) {
3113 for (
int i=0; i<this->pointsUni_->size(); i++) {
3114 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)) {
3115 this->bcFlagUni_->at(i) = 3;
3117 if (this->pointsUni_->at(i).at(0) < (coorRec[0] +tol)) {
3118 this->bcFlagUni_->at(i) = 2;
3120 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) && this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) ) {
3121 this->bcFlagUni_->at(i) = 1;
3123 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) && this->pointsUni_->at(i).at(1) > (coorRec[1] + height - tol) ) {
3124 this->bcFlagUni_->at(i) = 1;
3127 for (
int i=0; i<this->pointsRep_->size(); i++) {
3128 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)) {
3129 this->bcFlagRep_->at(i) = 3;
3131 if (this->pointsRep_->at(i).at(0) < (coorRec[0] +tol)) {
3132 this->bcFlagRep_->at(i) = 2;
3134 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) && this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) ) {
3135 this->bcFlagRep_->at(i) = 1;
3137 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) && this->pointsRep_->at(i).at(1) > (coorRec[1] + height - tol) ) {
3138 this->bcFlagRep_->at(i) = 1;
3143 for (
int i=0; i<this->pointsUni_->size(); i++) {
3144 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)) {
3145 this->bcFlagUni_->at(i) = 2;
3147 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)) {
3148 this->bcFlagUni_->at(i) = 1;
3150 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)) {
3151 this->bcFlagUni_->at(i) = 1;
3153 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)) {
3154 this->bcFlagUni_->at(i) = 1;
3156 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)) {
3157 this->bcFlagUni_->at(i) = 3;
3160 for (
int i=0; i<this->pointsRep_->size(); i++) {
3161 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)) {
3162 this->bcFlagRep_->at(i) = 2;
3164 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)) {
3165 this->bcFlagRep_->at(i) = 1;
3167 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)) {
3168 this->bcFlagRep_->at(i) = 1;
3170 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)) {
3171 this->bcFlagRep_->at(i) = 1;
3173 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)) {
3174 this->bcFlagRep_->at(i) = 3;
3179 for (
int i=0; i<this->pointsUni_->size(); i++) {
3180 if (this->pointsUni_->at(i).at(0) < (coorRec[0] +tol)) {
3181 this->bcFlagUni_->at(i) = 2;
3183 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) && this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) ) {
3184 this->bcFlagUni_->at(i) = 1;
3186 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) && this->pointsUni_->at(i).at(1) > (coorRec[1] + height - tol) ) {
3187 this->bcFlagUni_->at(i) = 4;
3189 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)) {
3190 this->bcFlagUni_->at(i) = 3;
3193 for (
int i=0; i<this->pointsRep_->size(); i++) {
3194 if (this->pointsRep_->at(i).at(0) < (coorRec[0] +tol)) {
3195 this->bcFlagRep_->at(i) = 2;
3197 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) && this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) ) {
3198 this->bcFlagRep_->at(i) = 1;
3200 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) && this->pointsRep_->at(i).at(1) > (coorRec[1] + height - tol) ) {
3201 this->bcFlagRep_->at(i) = 4;
3203 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)) {
3204 this->bcFlagRep_->at(i) = 3;
3209 if (FEType ==
"P2") {
3210 this->bcFlagUni_->at(0) = 1;
3211 this->bcFlagUni_->at(1) = 2;
3212 this->bcFlagUni_->at(2) = 2;
3213 this->bcFlagUni_->at(3) = 2;
3214 this->bcFlagUni_->at(4) = 4;
3215 this->bcFlagUni_->at(5) = 3;
3216 this->bcFlagUni_->at(6) = 0;
3217 this->bcFlagUni_->at(7) = 0;
3218 this->bcFlagUni_->at(8) = 0;
3219 this->bcFlagUni_->at(9) = 5;
3220 this->bcFlagUni_->at(10) = 1;
3221 this->bcFlagUni_->at(11) = 2;
3222 this->bcFlagUni_->at(12) = 2;
3223 this->bcFlagUni_->at(13) = 2;
3224 this->bcFlagUni_->at(14) = 4;
3226 this->bcFlagRep_->at(0) = 1;
3227 this->bcFlagRep_->at(1) = 2;
3228 this->bcFlagRep_->at(2) = 2;
3229 this->bcFlagRep_->at(3) = 2;
3230 this->bcFlagRep_->at(4) = 4;
3231 this->bcFlagRep_->at(5) = 3;
3232 this->bcFlagRep_->at(6) = 0;
3233 this->bcFlagRep_->at(7) = 0;
3234 this->bcFlagRep_->at(8) = 0;
3235 this->bcFlagRep_->at(9) = 5;
3236 this->bcFlagRep_->at(10) = 1;
3237 this->bcFlagRep_->at(11) = 2;
3238 this->bcFlagRep_->at(12) = 2;
3239 this->bcFlagRep_->at(13) = 2;
3240 this->bcFlagRep_->at(14) = 4;
3241 }
else if(FEType==
"P1") {
3242 this->bcFlagUni_->at(0) = 1;
3243 this->bcFlagUni_->at(1) = 1;
3244 this->bcFlagUni_->at(2) = 1;
3245 this->bcFlagUni_->at(3) = 2;
3246 this->bcFlagUni_->at(4) = 2;
3247 this->bcFlagUni_->at(5) = 1;
3249 this->bcFlagRep_->at(0) = 1;
3250 this->bcFlagRep_->at(1) = 1;
3251 this->bcFlagRep_->at(2) = 1;
3252 this->bcFlagRep_->at(3) = 2;
3253 this->bcFlagRep_->at(4) = 2;
3254 this->bcFlagRep_->at(5) = 1;
3258 for (
int i=0; i<this->pointsUni_->size(); i++) {
3259 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) && this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) ) {
3260 this->bcFlagUni_->at(i) = 1;
3262 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)) {
3263 this->bcFlagUni_->at(i) = 1;
3265 if (this->pointsUni_->at(i).at(0) < (coorRec[0] +tol)) {
3266 this->bcFlagUni_->at(i) = 1;
3268 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) && this->pointsUni_->at(i).at(1) > (coorRec[1] + height - tol) ) {
3269 this->bcFlagUni_->at(i) = 2;
3271 if (this->pointsUni_->at(i).at(0) < (coorRec[0] +tol) && this->pointsUni_->at(i).at(1) < (coorRec[1] +tol)) {
3272 this->bcFlagUni_->at(i) = 3;
3275 for (
int i=0; i<this->pointsRep_->size(); i++) {
3276 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) && this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) ) {
3277 this->bcFlagRep_->at(i) = 1;
3279 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)) {
3280 this->bcFlagRep_->at(i) = 1;
3282 if (this->pointsRep_->at(i).at(0) < (coorRec[0] +tol)) {
3283 this->bcFlagRep_->at(i) = 1;
3285 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) && this->pointsRep_->at(i).at(1) > (coorRec[1] + height - tol) ) {
3286 this->bcFlagRep_->at(i) = 2;
3288 if (this->pointsRep_->at(i).at(0) < (coorRec[0] +tol) && this->pointsRep_->at(i).at(1) < (coorRec[1] +tol)) {
3289 this->bcFlagRep_->at(i) = 3;
3298 switch (flagsOption) {
3302 for (
int i=0; i<this->pointsUni_->size(); i++) {
3303 if (this->pointsUni_->at(i).at(0) < (coorRec[0] + tol) ) {
3304 this->bcFlagUni_->at(i) = 2;
3307 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + length - tol) &&
3308 this->pointsUni_->at(i).at(1) > (coorRec[1] + tol) &&
3309 this->pointsUni_->at(i).at(1) < (coorRec[1] + width - tol)&&
3310 this->pointsUni_->at(i).at(2) > (coorRec[2] + tol) &&
3311 this->pointsUni_->at(i).at(2) < (coorRec[2] + height - tol)) {
3312 this->bcFlagUni_->at(i) = 3;
3315 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) &&
3316 this->pointsUni_->at(i).at(2) < (coorRec[2] + tol) ) {
3317 this->bcFlagUni_->at(i) = 1;
3320 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) &&
3321 this->pointsUni_->at(i).at(2) > (coorRec[2] + height - tol) ) {
3322 this->bcFlagUni_->at(i) = 1;
3325 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) &&
3326 this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) ) {
3327 this->bcFlagUni_->at(i) = 1;
3330 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) &&
3331 this->pointsUni_->at(i).at(1) > (coorRec[1] + width - tol) ) {
3332 this->bcFlagUni_->at(i) = 1;
3335 for (
int i=0; i<this->pointsUni_->size(); i++) {
3336 if (this->pointsRep_->at(i).at(0) < (coorRec[0] + tol) ) {
3337 this->bcFlagRep_->at(i) = 2;
3340 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + length - tol) &&
3341 this->pointsRep_->at(i).at(1) > (coorRec[1] + tol) &&
3342 this->pointsRep_->at(i).at(1) < (coorRec[1] + width - tol)&&
3343 this->pointsRep_->at(i).at(2) > (coorRec[2] + tol) &&
3344 this->pointsRep_->at(i).at(2) < (coorRec[2] + height - tol)) {
3345 this->bcFlagRep_->at(i) = 3;
3348 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) &&
3349 this->pointsRep_->at(i).at(2) < (coorRec[2] + tol) ) {
3350 this->bcFlagRep_->at(i) = 1;
3353 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) &&
3354 this->pointsRep_->at(i).at(2) > (coorRec[2] + height - tol) ) {
3355 this->bcFlagRep_->at(i) = 1;
3358 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) &&
3359 this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) ) {
3360 this->bcFlagRep_->at(i) = 1;
3363 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) &&
3364 this->pointsRep_->at(i).at(1) > (coorRec[1] + width - tol) ) {
3365 this->bcFlagRep_->at(i) = 1;
3370 for (
int i=0; i<this->pointsUni_->size(); i++) {
3371 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)
3372 && this->pointsUni_->at(i).at(2) > (coorRec[2]+1. -tol) && this->pointsUni_->at(i).at(1) < (coorRec[2]+ height +tol)) {
3373 this->bcFlagUni_->at(i) = 2;
3376 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)) {
3377 this->bcFlagUni_->at(i) = 1;
3380 if (this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) || this->pointsUni_->at(i).at(1) > (coorRec[1]+width - tol)) {
3381 this->bcFlagUni_->at(i) = 1;
3384 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)) {
3385 this->bcFlagUni_->at(i) = 1;
3387 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)
3388 && this->pointsUni_->at(i).at(2) > (coorRec[2] + tol) && this->pointsUni_->at(i).at(2) < (coorRec[2] + height - tol)) {
3389 this->bcFlagUni_->at(i) = 3;
3392 for (
int i=0; i<this->pointsRep_->size(); i++) {
3393 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)
3394 && this->pointsRep_->at(i).at(2) > (coorRec[2]+1. -tol) && this->pointsRep_->at(i).at(1) < (coorRec[2]+ height +tol)) {
3395 this->bcFlagRep_->at(i) = 2;
3398 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)) {
3399 this->bcFlagRep_->at(i) = 1;
3402 if (this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) || this->pointsRep_->at(i).at(1) > (coorRec[1]+width - tol)) {
3403 this->bcFlagRep_->at(i) = 1;
3406 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)) {
3407 this->bcFlagRep_->at(i) = 1;
3409 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)
3410 && this->pointsRep_->at(i).at(2) > (coorRec[2] + tol) && this->pointsRep_->at(i).at(2) < (coorRec[2] + height - tol)) {
3411 this->bcFlagRep_->at(i) = 3;
3416 for (
int i=0; i<this->pointsUni_->size(); i++) {
3418 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + tol) &&
3419 this->pointsUni_->at(i).at(2) > (coorRec[2] + height - tol) ) {
3420 this->bcFlagUni_->at(i) = 4;
3423 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + tol) &&
3424 this->pointsUni_->at(i).at(1) > (coorRec[1] + width - tol) ) {
3425 this->bcFlagUni_->at(i) = 5;
3428 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + length - tol) &&
3429 this->pointsUni_->at(i).at(1) > (coorRec[1] + tol) &&
3430 this->pointsUni_->at(i).at(1) < (coorRec[1] + width - tol)&&
3431 this->pointsUni_->at(i).at(2) > (coorRec[2] + tol) &&
3432 this->pointsUni_->at(i).at(2) < (coorRec[2] + height - tol)) {
3433 this->bcFlagUni_->at(i) = 6;
3436 if (this->pointsUni_->at(i).at(0) < (coorRec[0] + tol) ) {
3437 this->bcFlagUni_->at(i) = 1;
3440 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + tol) &&
3441 this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) ) {
3442 this->bcFlagUni_->at(i) = 2;
3445 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + tol) &&
3446 this->pointsUni_->at(i).at(2) < (coorRec[2] + tol) ) {
3447 this->bcFlagUni_->at(i) = 3;
3451 if (this->pointsUni_->at(i).at(0) < (coorRec[0] + tol) &&
3452 this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) )
3453 this->bcFlagUni_->at(i) = 7;
3456 if (this->pointsUni_->at(i).at(0) < (coorRec[0] + tol) &&
3457 this->pointsUni_->at(i).at(2) < (coorRec[2] + tol) )
3458 this->bcFlagUni_->at(i) = 9;
3461 if (this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) &&
3462 this->pointsUni_->at(i).at(2) < (coorRec[2] + tol) )
3463 this->bcFlagUni_->at(i) = 8;
3466 if (this->pointsUni_->at(i).at(0) < (coorRec[0] + tol) &&
3467 this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) &&
3468 this->pointsUni_->at(i).at(2) < (coorRec[2] + tol) )
3469 this->bcFlagUni_->at(i) = 0;
3472 for (
int i=0; i<this->pointsRep_->size(); i++) {
3475 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + tol) &&
3476 this->pointsRep_->at(i).at(2) > (coorRec[2] + height - tol) ) {
3477 this->bcFlagRep_->at(i) = 4;
3481 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + tol) &&
3482 this->pointsRep_->at(i).at(1) > (coorRec[1] + width - tol) ) {
3483 this->bcFlagRep_->at(i) = 5;
3486 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + length - tol) &&
3487 this->pointsRep_->at(i).at(1) > (coorRec[1] + tol) &&
3488 this->pointsRep_->at(i).at(1) < (coorRec[1] + width - tol)&&
3489 this->pointsRep_->at(i).at(2) > (coorRec[2] + tol) &&
3490 this->pointsRep_->at(i).at(2) < (coorRec[2] + height - tol)) {
3491 this->bcFlagRep_->at(i) = 6;
3494 if (this->pointsRep_->at(i).at(0) < (coorRec[0] + tol) ) {
3495 this->bcFlagRep_->at(i) = 1;
3498 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + tol) &&
3499 this->pointsRep_->at(i).at(2) < (coorRec[2] + tol) ) {
3500 this->bcFlagRep_->at(i) = 3;
3503 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + tol) &&
3504 this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) ) {
3505 this->bcFlagRep_->at(i) = 2;
3508 if (this->pointsRep_->at(i).at(0) < (coorRec[0] + tol) &&
3509 this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) )
3510 this->bcFlagRep_->at(i) = 7;
3513 if (this->pointsRep_->at(i).at(0) < (coorRec[0] + tol) &&
3514 this->pointsRep_->at(i).at(2) < (coorRec[2] + tol) )
3515 this->bcFlagRep_->at(i) = 9;
3518 if (this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) &&
3519 this->pointsRep_->at(i).at(2) < (coorRec[2] + tol) )
3520 this->bcFlagRep_->at(i) = 8;
3522 if (this->pointsRep_->at(i).at(0) < (coorRec[0] + tol) &&
3523 this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) &&
3524 this->pointsRep_->at(i).at(2) < (coorRec[2] + tol) )
3525 this->bcFlagRep_->at(i) = 0;
3530 for (
int i=0; i<this->pointsUni_->size(); i++) {
3532 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + tol) &&
3533 this->pointsUni_->at(i).at(2) < (coorRec[2] + tol) ) {
3534 this->bcFlagUni_->at(i) = 4;
3537 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + tol) &&
3538 this->pointsUni_->at(i).at(2) > (coorRec[2] + height - tol) ) {
3539 this->bcFlagUni_->at(i) = 5;
3541 if (this->pointsUni_->at(i).at(0) < (coorRec[0] + tol) ) {
3542 this->bcFlagUni_->at(i) = 6;
3545 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + tol) &&
3546 this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) ) {
3547 this->bcFlagUni_->at(i) = 6;
3550 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + tol) &&
3551 this->pointsUni_->at(i).at(1) > (coorRec[1] + width - tol) ) {
3552 this->bcFlagUni_->at(i) = 6;
3555 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + length - tol) &&
3556 this->pointsUni_->at(i).at(1) > (coorRec[1] + tol) &&
3557 this->pointsUni_->at(i).at(1) < (coorRec[1] + width - tol)&&
3558 this->pointsUni_->at(i).at(2) > (coorRec[2] - tol) &&
3559 this->pointsUni_->at(i).at(2) < (coorRec[2] + height + tol)) {
3560 this->bcFlagUni_->at(i) = 6;
3563 for (
int i=0; i<this->pointsUni_->size(); i++) {
3566 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + tol) &&
3567 this->pointsRep_->at(i).at(2) < (coorRec[2] + tol) ) {
3568 this->bcFlagRep_->at(i) = 4;
3570 if (this->pointsRep_->at(i).at(0) < (coorRec[0] + tol) ) {
3571 this->bcFlagRep_->at(i) = 6;
3574 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + tol) &&
3575 this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) ) {
3576 this->bcFlagRep_->at(i) = 6;
3579 if (this->pointsRep_->at(i).at(0) >= (coorRec[0] + tol) &&
3580 this->pointsRep_->at(i).at(1) > (coorRec[1] + width - tol) ) {
3581 this->bcFlagRep_->at(i) = 6;
3584 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + length - tol) &&
3585 this->pointsRep_->at(i).at(1) > (coorRec[1] + tol) &&
3586 this->pointsRep_->at(i).at(1) < (coorRec[1] + width - tol)&&
3587 this->pointsRep_->at(i).at(2) > (coorRec[2] - tol) &&
3588 this->pointsRep_->at(i).at(2) < (coorRec[2] + height + tol)) {
3589 this->bcFlagRep_->at(i) = 6;
3592 if (this->pointsRep_->at(i).at(2) > (coorRec[2] + height - tol) ) {
3593 this->bcFlagRep_->at(i) = 5;
3598 for (
int i=0; i<this->pointsUni_->size(); i++) {
3599 if (this->pointsUni_->at(i).at(0) < (coorRec[0] + tol) ) {
3600 this->bcFlagUni_->at(i) = 1;
3603 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) &&
3604 this->pointsUni_->at(i).at(2) < (coorRec[2] + tol) ) {
3605 this->bcFlagUni_->at(i) = 1;
3608 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) &&
3609 this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) ) {
3610 this->bcFlagUni_->at(i) = 1;
3613 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) &&
3614 this->pointsUni_->at(i).at(1) > (coorRec[1] + width - tol) ) {
3615 this->bcFlagUni_->at(i) = 1;
3618 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + length - tol) &&
3619 this->pointsUni_->at(i).at(1) > (coorRec[1] + tol) &&
3620 this->pointsUni_->at(i).at(1) < (coorRec[1] + width - tol)&&
3621 this->pointsUni_->at(i).at(2) > (coorRec[2] + tol) &&
3622 this->pointsUni_->at(i).at(2) < (coorRec[2] + height - tol)) {
3623 this->bcFlagUni_->at(i) = 1;
3626 if (this->pointsUni_->at(i).at(2) > (coorRec[2] + height - tol) ) {
3627 this->bcFlagUni_->at(i) = 2;
3629 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)) {
3630 this->bcFlagUni_->at(i) = 3;
3633 for (
int i=0; i<this->pointsUni_->size(); i++) {
3634 if (this->pointsRep_->at(i).at(0) < (coorRec[0] - tol) ) {
3635 this->bcFlagRep_->at(i) = 1;
3638 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) &&
3639 this->pointsRep_->at(i).at(2) < (coorRec[2] + tol) ) {
3640 this->bcFlagRep_->at(i) = 1;
3643 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) &&
3644 this->pointsRep_->at(i).at(2) > (coorRec[2] + height - tol) ) {
3645 this->bcFlagRep_->at(i) = 2;
3648 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) &&
3649 this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) ) {
3650 this->bcFlagRep_->at(i) = 1;
3653 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) &&
3654 this->pointsRep_->at(i).at(1) > (coorRec[1] + width - tol) ) {
3655 this->bcFlagRep_->at(i) = 1;
3658 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + length - tol) &&
3659 this->pointsRep_->at(i).at(1) > (coorRec[1] + tol) &&
3660 this->pointsRep_->at(i).at(1) < (coorRec[1] + width - tol)&&
3661 this->pointsRep_->at(i).at(2) > (coorRec[2] + tol) &&
3662 this->pointsRep_->at(i).at(2) < (coorRec[2] + height - tol)) {
3663 this->bcFlagRep_->at(i) = 1;
3665 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)) {
3666 this->bcFlagRep_->at(i) = 3;
3684 int numProcsCoarseSolve){
3688 using Teuchos::ScalarTraits;
3690 TEUCHOS_TEST_FOR_EXCEPTION(!(M>=1),std::logic_error,
"H/h is to small.");
3691 TEUCHOS_TEST_FOR_EXCEPTION(this->comm_.is_null(),std::runtime_error,
"comm_ is null.");
3693 bool verbose (this->comm_->getRank() == 0);
3696 std::cout <<
"-- Building structured 3D Mesh --" << std::endl;
3699 setRankRange( numProcsCoarseSolve );
3701 SC eps = ScalarTraits<SC>::eps();
3703 int rank = this->comm_->getRank();
3704 int size = this->comm_->getSize() - numProcsCoarseSolve;
3706 SC h = length/(M*N);
3710 std::cout <<
"-- H:"<<H <<
" h:" <<h <<
" --" << std::endl;
3711 std::cout <<
"-- N:"<<N <<
" M:" <<M <<
" --" << std::endl;
3714 LO nmbPoints_oneDir;
3718 if (FEType ==
"P2"){
3719 nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1);
3720 nmbPoints = (2*(M+1)-1)*(2*(M+1)-1)*(2*(M+1)-1) - M*M*M;
3723 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Wrong FE-Type, 5 element subcube devision only available with P2 discretization.");
3728 std::cout <<
"-- Number of Points in one direction: " << nmbPoints_oneDir <<
" || Number of Points " << nmbPoints <<
" --" << std::endl;
3730 this->FEType_ = FEType;
3732 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
3734 this->numElementsGlob_ = 5*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1);
3742 nmbElements = 5*M*M*M;
3744 vec2D_int_ptr_Type elementsVec;
3745 vec_int_ptr_Type elementFlag;
3748 this->pointsRep_.reset(
new vec2D_dbl_Type(nmbPoints, vec_dbl_Type(3, 0.0)));
3749 this->bcFlagRep_.reset(
new vec_int_Type (nmbPoints, 10));
3750 elementsVec = Teuchos::rcp(
new vec2D_int_Type(nmbElements, vec_int_Type(10, -1)));
3751 elementFlag = Teuchos::rcp(
new vec_int_Type( elementsVec->size(),0 ) );
3752 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
3755 int offset_x = (rank % N);
3759 if ((rank % (N*N))>=N) {
3760 offset_y = (int) (rank % (N*N))/(N);
3763 if ((rank % (N*N*N))>=N*N ) {
3764 offset_z = (int) (rank % (N*N*N))/(N*(N));
3768 std::cout <<
"-- Building P2 Points Repeated ... " << std::endl;
3770 std::cout <<
" Offsets on Rank " << rank <<
" || x=" << offset_x <<
" y=" << offset_y <<
" z=" << offset_z << std::endl;
3771 this->comm_->barrier();
3779 for (
int t=0; t < 2*(M+1)-1; t++) {
3780 for (
int s=0; s < 2*(M+1)-1; s++) {
3781 for (
int r=0; r < 2*(M+1)-1; r++) {
3784 if (s%2==0 && r%2==0 && t%2==0) {
3791 (*this->pointsRep_)[counter][0] = r*h/2.0 + offset_x * H;
3792 if ((*this->pointsRep_)[counter][0]<eps && (*this->pointsRep_)[counter][0]>-eps) (*this->pointsRep_)[counter][0]=0.0;
3793 (*this->pointsRep_)[counter][1] = s*h/2.0 + offset_y * H;
3794 if ((*this->pointsRep_)[counter][1]<eps && (*this->pointsRep_)[counter][1]>-eps) (*this->pointsRep_)[counter][1]=0.0;
3795 (*this->pointsRep_)[counter][2] = t*h/2.0 + offset_z * H;
3796 if ((*this->pointsRep_)[counter][2]<eps && (*this->pointsRep_)[counter][2]>-eps) (*this->pointsRep_)[counter][2]=0.0;
3800 if(s%2 == 1 && t%2 == 1 && r%2==0)
3801 offset = M*offset_x +N*M*M*offset_y + N*M*(s-1)/2;
3803 if(s%2 == 0 && t%2==1 ){
3804 offset += M*M*N*offset_y + s/2*M*N;
3808 offset += M*M*N*N * t/2;
3810 offset += M*M*N*N * (t-1)/2;
3813 pointsRepGlobMapping[counter] = r + s*nmbPoints_oneDir + t*nmbPoints_oneDir*nmbPoints_oneDir \
3814 + offset_x*(2*(M+1)-2) + offset_y*(nmbPoints_oneDir)*(2*(M+1)-2) + offset_z*(nmbPoints_oneDir)*(nmbPoints_oneDir)*(2*(M+1)-2) \
3815 -offset_z*(N*N*M*M*M)-nodeSkip-offset;
3817 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[counter][0] < (coorRec[0]+eps) ||
3818 (*this->pointsRep_)[counter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[counter][1] < (coorRec[1]+eps) ||
3819 (*this->pointsRep_)[counter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[counter][2] < (coorRec[2]+eps) ) {
3820 (*this->bcFlagRep_)[counter] = 1;
3823 if (s%2==1 && r%2==1 && t%2==1) {
3836 int P2M = 2*(M+1)-1;
3838 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
3841 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
3843 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(3,0.0)));
3844 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),10));
3847 std::cout <<
"-- Building P2 Points Unique ... " << std::endl;
3850 std::cout <<
"-- Number of repeated points per proc: " << this->mapRepeated_->getNodeNumElements() <<
" ... " << std::endl;
3853 this->comm_->barrier();
3856 this->pointsUni_.reset(
new std::vector<std::vector<double> >( this->mapUnique_->getNodeNumElements(), std::vector<double>(this->dim_,-1. ) ) );
3857 this->bcFlagUni_.reset(
new std::vector<int> ( this->mapUnique_->getNodeNumElements(), 0 ) );
3858 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
3859 GO gid = this->mapUnique_->getGlobalElement( i );
3860 LO
id = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement( i ) );
3861 this->pointsUni_->at(i) = this->pointsRep_->at(
id);
3862 this->bcFlagUni_->at(i) = this->bcFlagRep_->at(
id);
3865 this->comm_->barrier();
3883 std::cout <<
"-- ElementsList ... " << std::endl;
3884 std::cout <<
"-- P2M =" << P2M << std::endl;
3890 for (
int t=0; t < M; t++) {
3891 for (
int s=0; s < M; s++) {
3892 for (
int r=0; r < M; r++) {
3896 int n_0 = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) -t*M*M;
3897 int n_1 = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) -t*M*M;
3898 int n_2 = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) -t*M*M ;
3900 int n_3 = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) -t*M*M;
3901 int n_4 = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) -t*M*M;
3902 int n_5 = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) -t*M*M ;
3904 int n_6 = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) -t*M*M;
3905 int n_7 = 2*(r) +1 + 2*P2M * (s+1) + 2*P2M*P2M * (t) -t*M*M ;
3906 int n_8 = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) -t*M*M;
3909 int n_9 = 2*(r) + 2*P2M * (s) +2*P2M*P2M * (t) +P2M*P2M -s*M -t*M*M;
3910 int n_10 = 2*(r) +1 + 2*P2M * (s) +2*P2M*P2M * (t) +P2M*P2M -s*M -t*M*M;
3911 int n_11 = 2*(r+1) + 2*P2M * (s) +2*P2M*P2M * (t) +P2M*P2M -s*M -t*M*M;
3913 int n_12 = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M -s*M -r -t*M*M;
3915 int n_14 = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) +P2M*P2M -s*M -(r+1) -t*M*M ;
3917 int n_15 = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M -(s+1)*M -t*M*M ;
3918 int n_16 = 2*(r) +1 + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M -(s+1)*M -t*M*M;
3919 int n_17 = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M -(s+1)*M -t*M*M;
3922 int n_18 = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3923 int n_19 = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3924 int n_20 = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3926 int n_21 = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3927 int n_22 = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3928 int n_23 = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3930 int n_24 = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3931 int n_25 = 2*(r) +1 + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3932 int n_26 = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3936 if(((r+M*offset_x)+(s+M*offset_y)+(t+M*offset_z))%2==0){
3937 (*elementsVec)[counter] = {n_2, n_8, n_6, n_26, n_5, n_7, n_4, n_14, n_17, n_16};
3939 (*elementsVec)[counter] = {n_2, n_6, n_0, n_18, n_4, n_3, n_1, n_10, n_12, n_9};
3941 (*elementsVec)[counter] = {n_2, n_18, n_20, n_26, n_10, n_19, n_11, n_14, n_22, n_23};
3943 (*elementsVec)[counter] = {n_6, n_24, n_18, n_26, n_15, n_21, n_12, n_16, n_25, n_22};
3945 (*elementsVec)[counter] = {n_2, n_26, n_6, n_18, n_14, n_16, n_4, n_10, n_22, n_12};
3949 (*elementsVec)[counter] = {n_0, n_24, n_18, n_20, n_12, n_21, n_9, n_10, n_22, n_19};
3951 (*elementsVec)[counter] = {n_2, n_8, n_0, n_20, n_5, n_4, n_1, n_11, n_14, n_10};
3953 (*elementsVec)[counter] = {n_8, n_6, n_0, n_24, n_7, n_3, n_4, n_16, n_15, n_12};
3955 (*elementsVec)[counter] = {n_8, n_24, n_20, n_26, n_16, n_22, n_14, n_17, n_25, n_23};
3957 (*elementsVec)[counter] = {n_8, n_20, n_24, n_0, n_14, n_22, n_16, n_4, n_10, n_12};
3968 std::cout <<
"... done !" << std::endl;
3970 buildElementsClass(elementsVec, elementFlag);
3977 int numNodesTriangle;
3979 switch (this->dim_) {
3984 switch (flagsOption) {
3992 else if(FEType==
"P2")
3998 for(
int T =0; T< this->elementsC_->numberElements(); T++){
4000 vec_int_Type nodeList = this->elementsC_->getElement(T).getVectorNodeList();
4002 vec2D_LO_Type surfaceElements_vec(4,vec_LO_Type(numNodesTriangle));
4014 surfaceElements_vec[0] = {nodeList[1],nodeList[0],nodeList[2]};
4015 surfaceElements_vec[1] = {nodeList[0],nodeList[3],nodeList[2]};
4016 surfaceElements_vec[2] = {nodeList[1],nodeList[2],nodeList[3]};
4017 surfaceElements_vec[3] = {nodeList[1],nodeList[0],nodeList[3]};
4019 else if(FEType==
"P2"){
4020 surfaceElements_vec[0] = {nodeList[1],nodeList[0],nodeList[2],nodeList[4],nodeList[6],nodeList[5]};
4021 surfaceElements_vec[1] = {nodeList[0],nodeList[3],nodeList[2],nodeList[7],nodeList[9],nodeList[6]};
4022 surfaceElements_vec[2] = {nodeList[1],nodeList[2],nodeList[3],nodeList[5],nodeList[9],nodeList[8]};
4023 surfaceElements_vec[3] = {nodeList[1],nodeList[0],nodeList[3],nodeList[4],nodeList[7],nodeList[8]};
4026 for (
int i=0; i<4; i++) {
4028 vec_dbl_Type p1(3),p2(3),v_E(3);
4029 p1[0] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(0) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(0);
4030 p1[1] =this->pointsRep_->at(surfaceElements_vec[i][0]).at(1) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(1);
4031 p1[2] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(2) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(2);
4033 p2[0] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(0) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(0);
4034 p2[1] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(1) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(1);
4035 p2[2] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(2) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(2);
4037 v_E[0] = p1[1]*p2[2] - p1[2]*p2[1];
4038 v_E[1] = p1[2]*p2[0] - p1[0]*p2[2];
4039 v_E[2] = p1[0]*p2[1] - p1[1]*p2[0];
4042 vec_dbl_Type midpoint(3);
4045 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.;
4046 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.;
4047 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.;
4051 if (midpoint.at(0) < (coorRec[0] + tol) ) {
4054 flipSurface(surfaceElements_vec[i]);
4057 p1[0] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(0) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(0);
4058 p1[1] =this->pointsRep_->at(surfaceElements_vec[i][0]).at(1) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(1);
4059 p1[2] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(2) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(2);
4061 p2[0] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(0) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(0);
4062 p2[1] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(1) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(1);
4063 p2[2] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(2) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(2);
4065 v_E[0] = p1[1]*p2[2] - p1[2]*p2[1];
4066 v_E[1] = p1[2]*p2[0] - p1[0]*p2[2];
4067 v_E[2] = p1[0]*p2[1] - p1[1]*p2[0];
4071 if ( !this->elementsC_->getElement(T).subElementsInitialized() )
4072 this->elementsC_->getElement(T).initializeSubElements(
"P2", 2 );
4074 this->elementsC_->getElement(T).addSubElement( feSurface );
4081 int numNodesTriangle;
4084 else if(FEType==
"P2")
4087 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"For flag option and discretization no surfaces are available");
4090 for(
int T =0; T< this->elementsC_->numberElements(); T++){
4092 vec_int_Type nodeList = this->elementsC_->getElement(T).getVectorNodeList();
4094 vec2D_LO_Type surfaceElements_vec(4,vec_LO_Type(numNodesTriangle));
4106 surfaceElements_vec[0] = {nodeList[1],nodeList[0],nodeList[2]};
4107 surfaceElements_vec[1] = {nodeList[0],nodeList[3],nodeList[2]};
4108 surfaceElements_vec[2] = {nodeList[1],nodeList[2],nodeList[3]};
4109 surfaceElements_vec[3] = {nodeList[1],nodeList[0],nodeList[3]};
4111 else if(FEType==
"P2"){
4112 surfaceElements_vec[0] = {nodeList[1],nodeList[0],nodeList[2],nodeList[4],nodeList[6],nodeList[5]};
4113 surfaceElements_vec[1] = {nodeList[0],nodeList[3],nodeList[2],nodeList[7],nodeList[9],nodeList[6]};
4114 surfaceElements_vec[2] = {nodeList[1],nodeList[2],nodeList[3],nodeList[5],nodeList[9],nodeList[8]};
4115 surfaceElements_vec[3] = {nodeList[1],nodeList[0],nodeList[3],nodeList[4],nodeList[7],nodeList[8]};
4118 for (
int i=0; i<4; i++) {
4120 vec_dbl_Type p1(3),p2(3),v_E(3);
4121 p1[0] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(0) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(0);
4122 p1[1] =this->pointsRep_->at(surfaceElements_vec[i][0]).at(1) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(1);
4123 p1[2] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(2) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(2);
4125 p2[0] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(0) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(0);
4126 p2[1] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(1) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(1);
4127 p2[2] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(2) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(2);
4129 v_E[0] = p1[1]*p2[2] - p1[2]*p2[1];
4130 v_E[1] = p1[2]*p2[0] - p1[0]*p2[2];
4131 v_E[2] = p1[0]*p2[1] - p1[1]*p2[0];
4134 vec_dbl_Type midpoint(3);
4137 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.;
4138 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.;
4139 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.;
4143 if (midpoint.at(0) < (coorRec[0] + tol) ) {
4146 flipSurface(surfaceElements_vec[i]);
4149 if (midpoint.at(0) > (coorRec[0] + tol) &&
4150 midpoint.at(2) < (coorRec[2] + tol) ) {
4153 flipSurface(surfaceElements_vec[i]);
4156 if (midpoint.at(0) > (coorRec[0] + tol) &&
4157 midpoint.at(2) > (coorRec[2] + height - tol) ) {
4159 flipSurface(surfaceElements_vec[i]);
4163 if (midpoint.at(0) > (coorRec[0] + tol) &&
4164 midpoint.at(1) < (coorRec[1] + tol) ) {
4166 flipSurface(surfaceElements_vec[i]);
4170 if (midpoint.at(0) > (coorRec[0] + tol) &&
4171 midpoint.at(1) > (coorRec[1] + width - tol) ) {
4173 flipSurface(surfaceElements_vec[i]);
4177 if (midpoint.at(0) > (coorRec[0] + length - tol) &&
4178 midpoint.at(1) > (coorRec[1] + tol) &&
4179 midpoint.at(1) < (coorRec[1] + width - tol)&&
4180 midpoint.at(2) > (coorRec[2] + tol) &&
4181 midpoint.at(2) < (coorRec[2] + height - tol)) {
4183 flipSurface(surfaceElements_vec[i]);
4186 p1[0] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(0) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(0);
4187 p1[1] =this->pointsRep_->at(surfaceElements_vec[i][0]).at(1) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(1);
4188 p1[2] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(2) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(2);
4190 p2[0] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(0) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(0);
4191 p2[1] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(1) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(1);
4192 p2[2] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(2) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(2);
4194 v_E[0] = p1[1]*p2[2] - p1[2]*p2[1];
4195 v_E[1] = p1[2]*p2[0] - p1[0]*p2[2];
4196 v_E[2] = p1[0]*p2[1] - p1[1]*p2[0];
4200 if ( !this->elementsC_->getElement(T).subElementsInitialized() )
4201 this->elementsC_->getElement(T).initializeSubElements(
"P2", 2 );
4203 this->elementsC_->getElement(T).addSubElement( feSurface );