241 int numProcsCoarseSolve){
245 using Teuchos::ScalarTraits;
248 TEUCHOS_TEST_FOR_EXCEPTION(!(M>=1),std::logic_error,
"H/h is to small.");
249 TEUCHOS_TEST_FOR_EXCEPTION(this->comm_.is_null(),std::runtime_error,
"comm_ is null.");
251 bool verbose (this->comm_->getRank() == 0);
253 setRankRange( numProcsCoarseSolve );
256 std::cout << std::endl;
259 int rank = this->comm_->getRank();
260 int size = this->comm_->getSize() - numProcsCoarseSolve;
268 vec2D_int_ptr_Type elementsVec;
269 vec_int_ptr_Type elementFlag;
271 if (FEType ==
"P0") {
272 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"implement P0.");
274 else if (FEType ==
"P1") {
275 nmbPoints_oneDir = N * (M+1) - (N-1);
276 nmbPoints = (M+1)*(M+1);
278 else if(FEType ==
"P2"){
279 nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1);
280 nmbPoints = (2*(M+1)-1)*(2*(M+1)-1);
283 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Wrong FE-Type, either P1 or P2.");
286 this->FEType_ = FEType;
288 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
290 this->numElementsGlob_ = 2*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1);
298 nmbElements = 2*(M)*(M);
302 if (FEType ==
"P1") {
304 std::cout <<
"-- H:"<<H <<
" h:" <<h <<
" --" << std::endl;
307 std::cout <<
"-- Building P1 Points Repeated ... " << std::endl;
310 this->pointsRep_.reset(
new vec2D_dbl_Type(nmbPoints,std::vector<double>(2,0.0)));
311 this->bcFlagRep_.reset(
new vec_int_Type (nmbPoints,0));
312 elementsVec = Teuchos::rcp(
new vec2D_int_Type(nmbElements,std::vector<int>(3,-1)));
313 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
316 int offset_x = (rank % N);
319 if ((rank % (N*N))>=N) {
320 offset_y = (int) (rank % (N*N))/(N);
323 for (
int s=0; s < M+1; s++) {
324 for (
int r=0; r < M+1; r++) {
325 (*this->pointsRep_)[counter][0] = r*h + offset_x * H;
326 if ((*this->pointsRep_)[counter][0]<100*ScalarTraits<SC>::eps() && (*this->pointsRep_)[counter][0]>-100*ScalarTraits<SC>::eps()) { (*this->pointsRep_)[counter][0]=0.0;}
327 (*this->pointsRep_)[counter][1] = s*h + offset_y * H;
328 if ((*this->pointsRep_)[counter][1]<100*ScalarTraits<SC>::eps() && (*this->pointsRep_)[counter][1]>-100*ScalarTraits<SC>::eps()) {(*this->pointsRep_)[counter][1]=0.0;}
329 pointsRepGlobMapping[counter] = r + s*nmbPoints_oneDir + offset_x*(M) + offset_y*(nmbPoints_oneDir)*M;
330 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-100*ScalarTraits<SC>::eps()) || (*this->pointsRep_)[counter][0] < (coorRec[0]+100*ScalarTraits<SC>::eps()) ||
331 (*this->pointsRep_)[counter][1] > (coorRec[1]+height-100*ScalarTraits<SC>::eps()) || (*this->pointsRep_)[counter][1] < (coorRec[1]+100*ScalarTraits<SC>::eps())) {
333 (*this->bcFlagRep_)[counter] = 1;
340 std::cout <<
" done! --" << std::endl;
344 std::cout <<
"-- Building P1 Repeated and Unique Map ... " << std::flush;
347 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
349 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
352 std::cout <<
" done! --" << std::endl;
356 std::cout <<
"-- Building P1 Unique Points ... " << std::flush;
359 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(2,0.0)));
360 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
362 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
364 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
366 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
367 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
368 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
371 std::cout <<
" done! --" << std::endl;
376 std::cout <<
"-- Building P1 Elements ... " << std::flush;
378 vec_int_ptr_Type elementFlag = Teuchos::rcp(
new vec_int_Type( elementsVec->size(),0 ) );
382 for (
int s=0; s < M; s++) {
383 for (
int r=0; r < M; r++) {
385 (*elementsVec)[counter][0] = r+1 + (M+1) * s;
386 (*elementsVec)[counter][1] = r + (M+1) * s ;
387 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1);
388 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.;
389 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.;
390 if ( x_ref>=0.3 && x_ref<=0.7) {
392 elementFlag->at(counter) = 1;
398 (*elementsVec)[counter][0] = r + (M+1) * (s+1);
399 (*elementsVec)[counter][1] = r + (M+1) * (s);
400 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1);
402 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.;
403 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.;
404 if ( x_ref>=0.3 && x_ref<=0.7) {
406 elementFlag->at(counter) = 1;
415 std::cout <<
" done! --" << std::endl;
422 else if(FEType ==
"P2"){
424 std::cout <<
"-- H:"<<H <<
" h:" <<h <<
" --" << std::endl;
427 std::cout <<
"-- Building P2 Points Repeated ... " << std::flush;
430 this->pointsRep_.reset(
new vec2D_dbl_Type(nmbPoints, vec_dbl_Type(2,0.0)));
431 this->bcFlagRep_.reset(
new vec_int_Type (nmbPoints,0));
432 elementsVec = Teuchos::rcp(
new vec2D_int_Type(nmbElements, vec_int_Type(6,-1)));
433 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
436 int offset_x = (rank % N);
439 if ((rank % (N*N))>=N) {
440 offset_y = (int) (rank % (N*N))/(N);
445 for (
int s=0; s < 2*(M+1)-1; s++) {
446 for (
int r=0; r < 2*(M+1)-1; r++) {
448 if (s%2==0 && r%2==0) {
453 (*this->pointsRep_)[counter][0] = r*h/2.0 + offset_x * H;
454 if ((*this->pointsRep_)[counter][0]<100*ScalarTraits<SC>::eps() && (*this->pointsRep_)[counter][0]>-100*ScalarTraits<SC>::eps()) (*this->pointsRep_)[counter][0]=0.0;
455 (*this->pointsRep_)[counter][1] = s*h/2.0 + offset_y * H;
456 if ((*this->pointsRep_)[counter][1]<100*ScalarTraits<SC>::eps() && (*this->pointsRep_)[counter][1]>-100*ScalarTraits<SC>::eps()) (*this->pointsRep_)[counter][1]=0.0;
458 pointsRepGlobMapping[counter] = r + s*nmbPoints_oneDir + offset_x*(2*(M+1)-2) + offset_y*(nmbPoints_oneDir)*(2*(M+1)-2) ;
460 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-100*ScalarTraits<SC>::eps()) || (*this->pointsRep_)[counter][0] < (coorRec[0]+100*ScalarTraits<SC>::eps()) ||
461 (*this->pointsRep_)[counter][1] > (coorRec[1]+height-100*ScalarTraits<SC>::eps()) || (*this->pointsRep_)[counter][1] < (coorRec[1]+100*ScalarTraits<SC>::eps())){
462 (*this->bcFlagRep_)[counter] = 1;
470 std::cout <<
" done! --" << std::endl;
473 std::cout <<
"-- Building P2 Repeated and Unique Map ... " << std::flush;
475 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
477 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
480 std::cout <<
" done! --" << std::endl;
484 std::cout <<
"-- Building P2 Unique Points ... " << std::flush;
487 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(2,0.0)));
488 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
491 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
493 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
495 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
496 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
497 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
501 std::cout <<
" done! --" << std::endl;
515 std::cout <<
"-- Building P2 Elements ... " << std::flush;
519 vec_int_ptr_Type elementFlag = Teuchos::rcp(
new vec_int_Type( elementsVec->size(),0 ) );
523 for (
int s=0; s < M; s++) {
524 for (
int r=0; r < M; r++) {
526 (*elementsVec)[counter][0] = 2*(r+1) + 2*P2M * (s) ;
527 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) ;
528 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) ;
530 (*elementsVec)[counter][3] = 2*(r) +1 + 2*P2M * (s) ;
531 (*elementsVec)[counter][4] = 2*(r) +1 + 2*P2M * (s) +P2M ;
532 (*elementsVec)[counter][5] = 2*(r+1) + 2*P2M * (s) +P2M ;
534 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.;
535 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.;
536 if ( x_ref>=0.3 && x_ref<=0.7) {
538 elementFlag->at(counter) = 1;
544 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s+1) ;
545 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) ;
546 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) ;
548 (*elementsVec)[counter][3] = 2*(r) + 2*P2M * (s) +P2M ;
549 (*elementsVec)[counter][4] = 2*(r) +1 + 2*P2M * (s) +P2M ;
550 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s+1) ;
552 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.;
553 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.;
554 if ( x_ref>=0.3 && x_ref<=0.7) {
556 elementFlag->at(counter) = 1;
568 std::cout <<
" done! --" << std::endl;
571 buildElementsClass(elementsVec, elementFlag);
579 int numProcsCoarseSolve){
583 using Teuchos::ScalarTraits;
585 TEUCHOS_TEST_FOR_EXCEPTION(!(M>=1),std::logic_error,
"H/h is to small.");
586 TEUCHOS_TEST_FOR_EXCEPTION(this->comm_.is_null(),std::runtime_error,
"comm_ is null.");
588 bool verbose (this->comm_->getRank() == 0);
590 setRankRange( numProcsCoarseSolve );
593 std::cout << std::endl;
596 SC eps = ScalarTraits<SC>::eps();
598 int rank = this->comm_->getRank();
599 int size = this->comm_->getSize() - numProcsCoarseSolve;
608 if (FEType ==
"P0") {
609 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"implement P0.");
611 else if (FEType ==
"P1") {
612 nmbPoints_oneDir = N * (M+1) - (N-1);
613 nmbPoints = (M+1)*(M+1)*(M+1);
615 else if (FEType ==
"P2"){
616 nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1);
617 nmbPoints = (2*(M+1)-1)*(2*(M+1)-1)*(2*(M+1)-1);
619 else if (FEType ==
"P2-CR"){
620 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"P2-CR might not work properly.");
621 nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1);
622 nmbPoints = (2*(M+1)-1)*(2*(M+1)-1)*(2*(M+1)-1);
624 else if (FEType ==
"P1-disc" || FEType ==
"P1-disc-global"){
627 else if (FEType ==
"Q1"){
630 else if (FEType ==
"Q2"){
633 else if (FEType ==
"Q2-20"){
637 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.");
639 this->FEType_ = FEType;
641 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
643 this->numElementsGlob_ = 6*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1);
651 nmbElements = 6*M*M*M;
653 vec2D_int_ptr_Type elementsVec;
654 vec_int_ptr_Type elementFlag;
656 if (FEType ==
"P1") {
658 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
659 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
660 elementsVec = Teuchos::rcp(
new vec2D_int_Type( nmbElements, vec_int_Type(4, -1) ));
661 elementFlag = Teuchos::rcp(
new vec_int_Type( elementsVec->size(),0 ) );
662 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
665 int offset_x = (rank % N);
669 if ((rank % (N*N))>=N) {
670 offset_y = (int) (rank % (N*N))/(N);
673 if ((rank % (N*N*N))>=N*N ) {
674 offset_z = (int) (rank % (N*N*N))/(N*(N));
677 for (
int t=0; t < M+1; t++) {
678 for (
int s=0; s < M+1; s++) {
679 for (
int r=0; r < M+1; r++) {
680 (*this->pointsRep_)[counter][0] = r*h + offset_x * H;
681 if ((*this->pointsRep_)[counter][0]<eps && (*this->pointsRep_)[counter][0]>-eps) (*this->pointsRep_)[counter][0]=0.0;
683 (*this->pointsRep_)[counter][1] = s*h + offset_y * H;
684 if ((*this->pointsRep_)[counter][1]<eps && (*this->pointsRep_)[counter][1]>-eps) (*this->pointsRep_)[counter][1]=0.0;
686 (*this->pointsRep_)[counter][2] = t*h + offset_z * H;
687 if ((*this->pointsRep_)[counter][2]<eps && (*this->pointsRep_)[counter][2]>-eps) (*this->pointsRep_)[counter][2]=0.0;
689 pointsRepGlobMapping[counter] = r + s*nmbPoints_oneDir + t*nmbPoints_oneDir*nmbPoints_oneDir \
690 + offset_x*(M) + offset_y*(nmbPoints_oneDir)*M + offset_z*(nmbPoints_oneDir)*(nmbPoints_oneDir)*M ;
692 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[counter][0] < (coorRec[0]+eps) ||
693 (*this->pointsRep_)[counter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[counter][1] < (coorRec[1]+eps) ||
694 (*this->pointsRep_)[counter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[counter][2] < (coorRec[2]+eps) ) {
696 (*this->bcFlagRep_)[counter] = 1;
704 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
706 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
708 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(3,0.0)));
709 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
711 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
713 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
715 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
716 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
717 (*this->pointsUni_)[i][2] = (*this->pointsRep_)[index][2];
718 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
722 for (
int t=0; t < M; t++) {
723 for (
int s=0; s < M; s++) {
724 for (
int r=0; r < M; r++) {
725 (*elementsVec)[counter][0] = r+1 + (M+1) * s + (M+1)*(M+1) * t ;
726 (*elementsVec)[counter][1] = r + (M+1) * s + (M+1)*(M+1) * t ;
727 (*elementsVec)[counter][2] = r+1 + (M+1) * s + (M+1)*(M+1) * (t+1) ;
728 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
730 (*elementsVec)[counter][0] = r + (M+1) * s + (M+1)*(M+1) * (t+1) ;
731 (*elementsVec)[counter][1] = r + (M+1) * s + (M+1)*(M+1) * t ;
732 (*elementsVec)[counter][2] = r+1 + (M+1) * s + (M+1)*(M+1) * (t+1) ;
733 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
735 (*elementsVec)[counter][0] = r+1 + (M+1) * s + (M+1)*(M+1) * t ;
736 (*elementsVec)[counter][1] = r + (M+1) * s + (M+1)*(M+1) * t ;
737 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * t ;
738 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
740 (*elementsVec)[counter][0] = r + (M+1) * s + (M+1)*(M+1) * t ;
741 (*elementsVec)[counter][1] = r + (M+1) * (s+1) + (M+1)*(M+1) * t ;
742 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * t ;
743 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
745 (*elementsVec)[counter][0] = r + (M+1) * s + (M+1)*(M+1) * t ;
746 (*elementsVec)[counter][1] = r + (M+1) * (s+1) + (M+1)*(M+1) * t ;
747 (*elementsVec)[counter][2] = r + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
748 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
750 (*elementsVec)[counter][0] = r + (M+1) * s + (M+1)*(M+1) * t ;
751 (*elementsVec)[counter][1] = r + (M+1) * s + (M+1)*(M+1) * (t+1) ;
752 (*elementsVec)[counter][2] = r + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
753 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
758 buildElementsClass(elementsVec, elementFlag);
761 else if(FEType ==
"P2"){
763 this->pointsRep_.reset(
new vec2D_dbl_Type(nmbPoints, vec_dbl_Type(3, 0.0)));
764 this->bcFlagRep_.reset(
new vec_int_Type (nmbPoints, 0));
765 elementsVec = Teuchos::rcp(
new vec2D_int_Type(nmbElements, vec_int_Type(10, -1)));
766 elementFlag = Teuchos::rcp(
new vec_int_Type( elementsVec->size(),0 ) );
767 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
770 int offset_x = (rank % N);
774 if ((rank % (N*N))>=N) {
775 offset_y = (int) (rank % (N*N))/(N);
778 if ((rank % (N*N*N))>=N*N ) {
779 offset_z = (int) (rank % (N*N*N))/(N*(N));
785 for (
int t=0; t < 2*(M+1)-1; t++) {
786 for (
int s=0; s < 2*(M+1)-1; s++) {
787 for (
int r=0; r < 2*(M+1)-1; r++) {
789 if (s%2==0 && r%2==0 && t%2==0) {
795 (*this->pointsRep_)[counter][0] = r*h/2.0 + offset_x * H;
796 if ((*this->pointsRep_)[counter][0]<eps && (*this->pointsRep_)[counter][0]>-eps) (*this->pointsRep_)[counter][0]=0.0;
797 (*this->pointsRep_)[counter][1] = s*h/2.0 + offset_y * H;
798 if ((*this->pointsRep_)[counter][1]<eps && (*this->pointsRep_)[counter][1]>-eps) (*this->pointsRep_)[counter][1]=0.0;
799 (*this->pointsRep_)[counter][2] = t*h/2.0 + offset_z * H;
800 if ((*this->pointsRep_)[counter][2]<eps && (*this->pointsRep_)[counter][2]>-eps) (*this->pointsRep_)[counter][2]=0.0;
802 pointsRepGlobMapping[counter] = r + s*nmbPoints_oneDir + t*nmbPoints_oneDir*nmbPoints_oneDir \
803 + offset_x*(2*(M+1)-2) + offset_y*(nmbPoints_oneDir)*(2*(M+1)-2) + offset_z*(nmbPoints_oneDir)*(nmbPoints_oneDir)*(2*(M+1)-2) ;
805 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[counter][0] < (coorRec[0]+eps) ||
806 (*this->pointsRep_)[counter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[counter][1] < (coorRec[1]+eps) ||
807 (*this->pointsRep_)[counter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[counter][2] < (coorRec[2]+eps) ) {
808 (*this->bcFlagRep_)[counter] = 1;
817 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
819 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
821 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(3,0.0)));
822 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
824 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
825 (*this->pointsUni_)[i][0] = (this->mapUnique_->getGlobalElement(i) % nmbPoints_oneDir) * h/2;
826 if ((*this->pointsUni_)[i][0]<eps && (*this->pointsUni_)[i][0]>-eps) (*this->pointsUni_)[i][0]=0.0;
828 (*this->pointsUni_)[i][1] = ((
int) ((this->mapUnique_->getGlobalElement(i) % (nmbPoints_oneDir*nmbPoints_oneDir)) / nmbPoints_oneDir) + eps) *h/2;
829 if ((*this->pointsUni_)[i][1]<eps && (*this->pointsUni_)[i][1]>-eps) (*this->pointsUni_)[i][1]=0.0;
831 (*this->pointsUni_)[i][2] = ((
int)(this->mapUnique_->getGlobalElement(i) / (nmbPoints_oneDir*nmbPoints_oneDir) + eps)) * h/2;
832 if ((*this->pointsUni_)[i][2]<eps && (*this->pointsUni_)[i][2]>-eps) (*this->pointsUni_)[i][2]=0.0;
834 if ((*this->pointsUni_)[i][0] > (coorRec[0]+length-eps) || (*this->pointsUni_)[i][0] < (coorRec[0]+eps) ||
835 (*this->pointsUni_)[i][1] > (coorRec[1]+width-eps) || (*this->pointsUni_)[i][1] < (coorRec[1]+eps) ||
836 (*this->pointsUni_)[i][2] > (coorRec[2]+height-eps) || (*this->pointsUni_)[i][2] < (coorRec[2]+eps) ) {
837 (*this->bcFlagUni_)[i] = 1;
855 for (
int t=0; t < M; t++) {
856 for (
int s=0; s < M; s++) {
857 for (
int r=0; r < M; r++) {
859 (*elementsVec)[counter][0] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
860 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
861 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
862 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
864 (*elementsVec)[counter][4] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) ;
865 (*elementsVec)[counter][6] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M;
866 (*elementsVec)[counter][7] = 2*(r+1) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M;
867 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M;
868 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M;
869 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t+1);
873 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
874 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
875 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
876 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
878 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M ;
879 (*elementsVec)[counter][6] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
880 (*elementsVec)[counter][7] = 2*(r) +1 + 2*P2M * (s)+P2M + 2*P2M*P2M * (t+1) ;
881 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M ;
882 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) +P2M*P2M ;
883 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t+1);
887 (*elementsVec)[counter][0] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
888 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
889 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
890 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
892 (*elementsVec)[counter][4] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) ;
893 (*elementsVec)[counter][6] = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) ;
894 (*elementsVec)[counter][7] = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) +P2M*P2M ;
895 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) ;
896 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) +P2M*P2M ;
897 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
901 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
902 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
903 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
904 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
906 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) ;
907 (*elementsVec)[counter][6] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) ;
908 (*elementsVec)[counter][7] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
909 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s+1) + 2*P2M*P2M * (t);
910 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
911 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
915 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
916 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
917 (*elementsVec)[counter][2] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
918 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
920 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) ;
921 (*elementsVec)[counter][6] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
922 (*elementsVec)[counter][7] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
923 (*elementsVec)[counter][5] = 2*(r) + 2*P2M*(s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
924 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M*(s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
925 (*elementsVec)[counter][9] = 2*(r) +1 + 2*P2M*(s+1) + 2*P2M*P2M * (t+1) ;
929 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
930 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
931 (*elementsVec)[counter][2] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
932 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
934 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M ;
935 (*elementsVec)[counter][6] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
936 (*elementsVec)[counter][7] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
937 (*elementsVec)[counter][5] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t+1) ;
938 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t+1) ;
939 (*elementsVec)[counter][9] = 2*(r) +1 + 2*P2M*(s+1) + 2*P2M*P2M * (t+1) ;
946 buildElementsClass(elementsVec, elementFlag);
948 else if(FEType ==
"P1-disc" || FEType ==
"P1-disc-global")
950 else if(FEType ==
"Q1"){
953 else if(FEType ==
"Q2"){
956 else if(FEType ==
"Q2-20"){
967 int numProcsCoarseSolve){
971 using Teuchos::ScalarTraits;
974 bool verbose (this->comm_->getRank() == 0);
976 setRankRange( numProcsCoarseSolve );
979 std::cout << std::endl;
981 SC eps = ScalarTraits<SC>::eps();
983 int rank = this->comm_->getRank();
984 int size = this->comm_->getSize() - numProcsCoarseSolve;
992 LO nmbPoints = 4*M*M*M;
995 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
997 this->numElementsGlob_ = (nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1);
1005 nmbElements = M*M*M;
1010 int offset_x = (rank % N);
1014 if ((rank % (N*N))>=N) {
1015 offset_y = (int) (rank % (N*N))/(N);
1018 if ((rank % (N*N*N))>=N*N ) {
1019 offset_z = (int) (rank % (N*N*N))/(N*(N));
1023 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
1024 this->pointsUni_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
1025 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
1026 this->bcFlagUni_.reset(
new std::vector<int> (nmbPoints,0));
1027 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
1031 std::cout <<
"-- Building P1-disc Points and Elements according to Q2 ... " << std::flush;
1033 vec2D_int_ptr_Type elementsVec = Teuchos::rcp(
new vec2D_int_Type(nmbElements, vec_int_Type(4, -1)));
1037 GO globalCounterPoints = rank * nmbPoints;
1038 for (
int t=0; t < M; t++) {
1039 for (
int s=0; s < M; s++) {
1040 for (
int r=0; r < M; r++) {
1043 (*this->pointsRep_)[pCounter][0] = r*h + offset_x * H;
1044 (*this->pointsRep_)[pCounter][1] = s*h + offset_y * H;
1045 (*this->pointsRep_)[pCounter][2] = t*h + offset_z * H;
1046 if ((*this->pointsRep_)[pCounter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[pCounter][0] < (coorRec[0]+eps) ||
1047 (*this->pointsRep_)[pCounter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[pCounter][1] < (coorRec[1]+eps) ||
1048 (*this->pointsRep_)[pCounter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[pCounter][2] < (coorRec[2]+eps) ) {
1050 (*this->bcFlagRep_)[counter] = 1;
1053 (*this->pointsUni_)[pCounter][0] = (*this->pointsRep_)[pCounter][0];
1054 (*this->pointsUni_)[pCounter][1] = (*this->pointsRep_)[pCounter][1];
1055 (*this->pointsUni_)[pCounter][2] = (*this->pointsRep_)[pCounter][2];
1057 (*this->bcFlagUni_)[pCounter] = (*this->bcFlagRep_)[pCounter];
1059 (*elementsVec)[counter][0] = pCounter;
1060 pointsRepGlobMapping[pCounter] = globalCounterPoints;
1061 globalCounterPoints++;
1065 (*this->pointsRep_)[pCounter][0] = (r+1)*h + offset_x * H;
1066 (*this->pointsRep_)[pCounter][1] = s*h + offset_y * H;
1067 (*this->pointsRep_)[pCounter][2] = t*h + offset_z * H;
1068 if ((*this->pointsRep_)[pCounter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[pCounter][0] < (coorRec[0]+eps) ||
1069 (*this->pointsRep_)[pCounter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[pCounter][1] < (coorRec[1]+eps) ||
1070 (*this->pointsRep_)[pCounter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[pCounter][2] < (coorRec[2]+eps) ) {
1072 (*this->bcFlagRep_)[counter] = 1;
1075 (*this->pointsUni_)[pCounter][0] = (*this->pointsRep_)[pCounter][0];
1076 (*this->pointsUni_)[pCounter][1] = (*this->pointsRep_)[pCounter][1];
1077 (*this->pointsUni_)[pCounter][2] = (*this->pointsRep_)[pCounter][2];
1079 (*this->bcFlagUni_)[pCounter] = (*this->bcFlagRep_)[pCounter];
1081 (*elementsVec)[counter][1] = pCounter;
1082 pointsRepGlobMapping[pCounter] = globalCounterPoints;
1083 globalCounterPoints++;
1086 (*this->pointsRep_)[pCounter][0] = r*h + offset_x * H;
1087 (*this->pointsRep_)[pCounter][1] = (s+1)*h + offset_y * H;
1088 (*this->pointsRep_)[pCounter][2] = t*h + offset_z * H;
1089 if ((*this->pointsRep_)[pCounter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[pCounter][0] < (coorRec[0]+eps) ||
1090 (*this->pointsRep_)[pCounter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[pCounter][1] < (coorRec[1]+eps) ||
1091 (*this->pointsRep_)[pCounter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[pCounter][2] < (coorRec[2]+eps) ) {
1093 (*this->bcFlagRep_)[counter] = 1;
1096 (*this->pointsUni_)[pCounter][0] = (*this->pointsRep_)[pCounter][0];
1097 (*this->pointsUni_)[pCounter][1] = (*this->pointsRep_)[pCounter][1];
1098 (*this->pointsUni_)[pCounter][2] = (*this->pointsRep_)[pCounter][2];
1100 (*this->bcFlagUni_)[pCounter] = (*this->bcFlagRep_)[pCounter];
1102 (*elementsVec)[counter][2] = pCounter;
1103 pointsRepGlobMapping[pCounter] = globalCounterPoints;
1104 globalCounterPoints++;
1108 (*this->pointsRep_)[pCounter][0] = r*h + offset_x * H;
1109 (*this->pointsRep_)[pCounter][1] = s*h + offset_y * H;
1110 (*this->pointsRep_)[pCounter][2] = (t+1)*h + offset_z * H;
1111 if ((*this->pointsRep_)[pCounter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[pCounter][0] < (coorRec[0]+eps) ||
1112 (*this->pointsRep_)[pCounter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[pCounter][1] < (coorRec[1]+eps) ||
1113 (*this->pointsRep_)[pCounter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[pCounter][2] < (coorRec[2]+eps) ) {
1115 (*this->bcFlagRep_)[counter] = 1;
1118 (*this->pointsUni_)[pCounter][0] = (*this->pointsRep_)[pCounter][0];
1119 (*this->pointsUni_)[pCounter][1] = (*this->pointsRep_)[pCounter][1];
1120 (*this->pointsUni_)[pCounter][2] = (*this->pointsRep_)[pCounter][2];
1122 (*this->bcFlagUni_)[pCounter] = (*this->bcFlagRep_)[pCounter];
1124 (*elementsVec)[counter][3] = pCounter;
1125 pointsRepGlobMapping[pCounter] = globalCounterPoints;
1126 globalCounterPoints++;
1133 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
1135 this->mapUnique_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
1137 buildElementsClass(elementsVec);
1140 std::cout <<
"done!" << std::endl;
1270 int numProcsCoarseSolve)
1275 using Teuchos::ScalarTraits;
1277 bool verbose (this->comm_->getRank() == 0);
1280 std::cout << std::endl;
1282 setRankRange( numProcsCoarseSolve );
1284 SC eps = ScalarTraits<SC>::eps();
1286 int rank = this->comm_->getRank();
1287 int size = this->comm_->getSize() - numProcsCoarseSolve;
1289 SC h = length/(M*N);
1294 LO nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1);
1295 LO nmbPoints = (2*(M+1)-1)*(2*(M+1)-1)*(2*(M+1)-1);
1297 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
1299 this->numElementsGlob_ = (nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1);
1307 nmbElements = M*M*M;
1310 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
1311 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
1312 vec2D_int_ptr_Type elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements,std::vector<int>(27,-1)));
1313 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
1316 int offset_x = (rank % N);
1320 if ((rank % (N*N))>=N) {
1321 offset_y = (int) (rank % (N*N))/(N);
1324 if ((rank % (N*N*N))>=N*N ) {
1325 offset_z = (int) (rank % (N*N*N))/(N*(N));
1331 for (
int t=0; t < 2*(M+1)-1; t++) {
1332 for (
int s=0; s < 2*(M+1)-1; s++) {
1333 for (
int r=0; r < 2*(M+1)-1; r++) {
1335 if (s%2==0 && r%2==0 && t%2==0) {
1341 (*this->pointsRep_)[counter][0] = r*h/2.0 + offset_x * H;
1342 if ((*this->pointsRep_)[counter][0]<eps && (*this->pointsRep_)[counter][0]>-eps) (*this->pointsRep_)[counter][0]=0.0;
1343 (*this->pointsRep_)[counter][1] = s*h/2.0 + offset_y * H;
1344 if ((*this->pointsRep_)[counter][1]<eps && (*this->pointsRep_)[counter][1]>-eps) (*this->pointsRep_)[counter][1]=0.0;
1345 (*this->pointsRep_)[counter][2] = t*h/2.0 + offset_z * H;
1346 if ((*this->pointsRep_)[counter][2]<eps && (*this->pointsRep_)[counter][2]>-eps) (*this->pointsRep_)[counter][2]=0.0;
1348 pointsRepGlobMapping[counter] = r + s*nmbPoints_oneDir + t*nmbPoints_oneDir*nmbPoints_oneDir \
1349 + offset_x*(2*(M+1)-2) + offset_y*(nmbPoints_oneDir)*(2*(M+1)-2) + offset_z*(nmbPoints_oneDir)*(nmbPoints_oneDir)*(2*(M+1)-2) ;
1351 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[counter][0] < (coorRec[0]+eps) ||
1352 (*this->pointsRep_)[counter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[counter][1] < (coorRec[1]+eps) ||
1353 (*this->pointsRep_)[counter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[counter][2] < (coorRec[2]+eps) ) {
1354 (*this->bcFlagRep_)[counter] = 1;
1363 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
1365 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
1367 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(3,0.0)));
1368 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
1370 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
1371 (*this->pointsUni_)[i][0] = (this->mapUnique_->getGlobalElement(i) % nmbPoints_oneDir) * h/2;
1372 if ((*this->pointsUni_)[i][0]<eps && (*this->pointsUni_)[i][0]>-eps) (*this->pointsUni_)[i][0]=0.0;
1374 (*this->pointsUni_)[i][1] = ((
int) ((this->mapUnique_->getGlobalElement(i) % (nmbPoints_oneDir*nmbPoints_oneDir)) / nmbPoints_oneDir) + eps) *h/2;
1375 if ((*this->pointsUni_)[i][1]<eps && (*this->pointsUni_)[i][1]>-eps) (*this->pointsUni_)[i][1]=0.0;
1377 (*this->pointsUni_)[i][2] = ((
int)(this->mapUnique_->getGlobalElement(i) / (nmbPoints_oneDir*nmbPoints_oneDir) + eps)) * h/2;
1378 if ((*this->pointsUni_)[i][2]<eps && (*this->pointsUni_)[i][2]>-eps) (*this->pointsUni_)[i][2]=0.0;
1380 if ((*this->pointsUni_)[i][0] > (coorRec[0]+length-eps) || (*this->pointsUni_)[i][0] < (coorRec[0]+eps) ||
1381 (*this->pointsUni_)[i][1] > (coorRec[1]+width-eps) || (*this->pointsUni_)[i][1] < (coorRec[1]+eps) ||
1382 (*this->pointsUni_)[i][2] > (coorRec[2]+height-eps) || (*this->pointsUni_)[i][2] < (coorRec[2]+eps) ) {
1383 (*this->bcFlagUni_)[i] = 1;
1388 int P2M = 2*(M+1)-1;
1391 for (
int t=0; t < M; t++) {
1392 for (
int s=0; s < M; s++) {
1393 for (
int r=0; r < M; r++) {
1395 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
1396 (*elementsVec)[counter][1] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
1397 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
1398 (*elementsVec)[counter][3] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
1400 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
1401 (*elementsVec)[counter][5] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
1402 (*elementsVec)[counter][6] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
1403 (*elementsVec)[counter][7] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
1405 (*elementsVec)[counter][8] = 2*(r)+1 + 2*P2M * (s) + 2*P2M*P2M * (t) ;
1406 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) ;
1407 (*elementsVec)[counter][10] = 2*(r)+1 + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
1408 (*elementsVec)[counter][11] = 2*(r) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) ;
1410 (*elementsVec)[counter][12] = 2*(r)+1 + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
1411 (*elementsVec)[counter][13] = 2*(r+1) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t+1) ;
1412 (*elementsVec)[counter][14] = 2*(r)+1 + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
1413 (*elementsVec)[counter][15] = 2*(r) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t+1) ;
1415 (*elementsVec)[counter][16] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) + P2M*P2M;
1416 (*elementsVec)[counter][17] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) + P2M*P2M;
1417 (*elementsVec)[counter][18] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) + P2M*P2M;
1418 (*elementsVec)[counter][19] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) + P2M*P2M;
1420 (*elementsVec)[counter][20] = 2*(r)+1 + 2*P2M * (s) + 2*P2M*P2M * (t) + P2M*P2M;
1421 (*elementsVec)[counter][21] = 2*(r+1) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) + P2M*P2M;
1422 (*elementsVec)[counter][22] = 2*(r)+1 + 2*P2M * (s+1) + 2*P2M*P2M * (t) + P2M*P2M;
1423 (*elementsVec)[counter][23] = 2*(r) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) + P2M*P2M;
1425 (*elementsVec)[counter][24] = 2*(r)+1 + 2*P2M * (s) + P2M + 2*P2M*P2M * (t);
1426 (*elementsVec)[counter][25] = 2*(r)+1 + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) + P2M*P2M;
1427 (*elementsVec)[counter][26] = 2*(r)+1 + 2*P2M * (s) + P2M + 2*P2M*P2M * (t+1);
1433 buildElementsClass(elementsVec);
1480 int numProcsCoarseSolve)
1485 using Teuchos::ScalarTraits;
1487 bool verbose (this->comm_->getRank() == 0);
1489 setRankRange( numProcsCoarseSolve );
1492 std::cout << std::endl;
1494 std::cout <<
"WARNING! Not working properly in parallel - fix global indexing." << std::endl;
1496 SC eps = ScalarTraits<SC>::eps();
1498 int rank = this->comm_->getRank();
1499 int size = this->comm_->getSize() - numProcsCoarseSolve;
1501 SC h = length/(M*N);
1506 LO nmbPoints_oneDirFull = N * (2*(M+1)-1) - (N-1);
1507 LO nmbPoints_oneDirMid = N * (M+1) - (N-1);
1509 LO nmbPoints = ( (M+1) * (2*(M+1)-1) + M * (M+1) ) * (M+1) +
1510 ( (M+1) * (M+1) ) * M;
1512 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
1514 this->numElementsGlob_ = (nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1);
1522 nmbElements = M*M*M;
1525 this->pointsRep_.reset(
new std::vector<std::vector<double> >(0));
1526 this->bcFlagRep_.reset(
new std::vector<int> (0));
1527 vec2D_int_ptr_Type elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements, std::vector<int>(20,-1)));
1528 Teuchos::Array<GO> pointsRepGlobMapping(0);
1531 int offset_x = (rank % N);
1535 if ((rank % (N*N))>=N) {
1536 offset_y = (int) (rank % (N*N))/(N);
1539 if ((rank % (N*N*N))>=N*N ) {
1540 offset_z = (int) (rank % (N*N*N))/(N*(N));
1543 for (
int t=0; t < 2*(M+1)-1; t++) {
1544 for (
int s=0; s < 2*(M+1)-1; s++) {
1546 for (
int r=0; r < 2*(M+1)-1; r++) {
1547 GO index = globalID_Q2_20Cube( r, s, t, rr, offset_x, offset_y, offset_z, M, N,
1548 nmbPoints_oneDirFull, nmbPoints_oneDirMid );
1551 std::vector<double> p(3,0.0);
1552 p[0] = r*h/2.0 + offset_x * H;
1553 p[1] = s*h/2.0 + offset_y * H;
1554 p[2] = t*h/2.0 + offset_z * H;
1555 this->pointsRep_->push_back(p);
1556 pointsRepGlobMapping.push_back( index );
1558 if (p[0] > (coorRec[0]+length-eps) || p[0] < (coorRec[0]+eps) ||
1559 p[1] > (coorRec[1]+width-eps) || p[1] < (coorRec[1]+eps) ||
1560 p[2] > (coorRec[2]+height-eps) || p[2] < (coorRec[2]+eps) )
1561 this->bcFlagRep_->push_back(1);
1563 this->bcFlagRep_->push_back(0);
1570 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
1572 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
1574 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(3,0.0)));
1575 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
1577 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
1579 LO index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
1581 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
1582 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
1583 (*this->pointsUni_)[i][2] = (*this->pointsRep_)[index][2];
1584 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
1587 int P2M = 2*(M+1)-1;
1590 for (
int t=0; t < M; t++) {
1591 for (
int s=0; s < M; s++) {
1592 for (
int r=0; r < M; r++) {
1594 (*elementsVec)[counter][0] = 2*(r) + (P2M+P1M) * (s) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) ;
1595 (*elementsVec)[counter][1] = 2*(r+1) + (P2M+P1M) * (s) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) ;
1596 (*elementsVec)[counter][2] = 2*(r+1) + (P2M+P1M) * (s+1) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) ;
1597 (*elementsVec)[counter][3] = 2*(r) + (P2M+P1M) * (s+1) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) ;
1599 (*elementsVec)[counter][4] = 2*(r) + (P2M+P1M) * (s) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t+1) ;
1600 (*elementsVec)[counter][5] = 2*(r+1) + (P2M+P1M) * (s) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t+1) ;
1601 (*elementsVec)[counter][6] = 2*(r+1) + (P2M+P1M) * (s+1) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t+1) ;
1602 (*elementsVec)[counter][7] = 2*(r) + (P2M+P1M) * (s+1) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t+1) ;
1604 (*elementsVec)[counter][8] = 2*(r)+1 + (P2M+P1M) * (s) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) ;
1605 (*elementsVec)[counter][9] = (r+1) + (P2M+P1M) * (s) + P2M + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) ;
1606 (*elementsVec)[counter][10] = 2*(r)+1 + (P2M+P1M) * (s+1) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) ;
1607 (*elementsVec)[counter][11] = r + (P2M+P1M) * (s) + P2M + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) ;
1609 (*elementsVec)[counter][12] = 2*(r)+1 + (P2M+P1M) * (s) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t+1) ;
1610 (*elementsVec)[counter][13] = (r+1) + (P2M+P1M) * (s) + P2M + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t+1) ;
1611 (*elementsVec)[counter][14] = 2*(r)+1 + (P2M+P1M) * (s+1) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t+1) ;
1612 (*elementsVec)[counter][15] = r + (P2M+P1M) * (s) + P2M + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t+1) ;
1614 (*elementsVec)[counter][16] = (r) + (P1M) * (s) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) + P2M*(M+1)+P1M*M;
1615 (*elementsVec)[counter][17] = (r+1) + (P1M) * (s) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) + P2M*(M+1)+P1M*M;
1616 (*elementsVec)[counter][18] = (r+1) + (P1M) * (s+1) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) + P2M*(M+1)+P1M*M;
1617 (*elementsVec)[counter][19] = r + (P1M) * (s+1) + ( (P2M*(M+1)+P1M*M) + (P1M*P1M) ) * (t) + P2M*(M+1)+P1M*M;
1630 int numProcsCoarseSolve){
1634 using Teuchos::ScalarTraits;
1636 typedef ScalarTraits<SC> ST;
1639 bool verbose (this->comm_->getRank() == 0);
1641 setRankRange( numProcsCoarseSolve );
1643 int rank = this->comm_->getRank();
1644 int size = this->comm_->getSize() - numProcsCoarseSolve;
1646 int bfs_multiplier = (int) 2*(length)-1;
1648 int nmbSubdomainsSquares = size / bfs_multiplier;
1649 int nmbSubdomainsSquares_OneDir = (std::pow(nmbSubdomainsSquares,1./3.) + 100*eps);
1651 SC h = ST::one()/(M*N);
1654 LO nmbPoints_oneDir = N * (M+1) - (N-1);
1655 LO nmbPoints = (M+1)*(M+1)*(M+1);
1659 LO nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1) ;
1663 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
1664 this->numElementsGlob_ = (nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1) * bfs_multiplier;
1672 nmbElements = M*M*M;
1675 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
1676 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,10));
1677 vec2D_int_ptr_Type elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements, std::vector<int>(27,-1)));
1678 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
1680 int whichSquareSet = (int)rank / nmbSubdomainsSquares;
1682 int offset_Squares_x = (int) (whichSquareSet+1) / 2;
1683 int offset_Squares_y = 0;
1684 int offset_Squares_z = ((whichSquareSet+1) % 2);
1687 int offset_x = ((rank - nmbSubdomainsSquares*whichSquareSet) % N);
1690 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))>=N) {
1691 offset_y = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))/(N);
1694 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))>=N*N ) {
1695 offset_z = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))/(N*(N));
1698 for (
int t=0; t < M+1; t++) {
1699 for (
int s=0; s < M+1; s++) {
1700 for (
int r=0; r < M+1; r++) {
1702 (*this->pointsRep_)[counter][0] = coorRec[0] + r*h + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
1704 (*this->pointsRep_)[counter][1] = coorRec[1] + s*h + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
1706 (*this->pointsRep_)[counter][2] = coorRec[2] + t*h + offset_z * H + offset_Squares_z * H * nmbSubdomainsSquares_OneDir;
1708 pointsRepGlobMapping[counter] = r
1709 + s*(nmbPoints_oneDir_allSubdomain);
1710 if (offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
1711 pointsRepGlobMapping[counter] -= s*(nmbPoints_oneDir-1);
1713 else if(offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=M){
1714 pointsRepGlobMapping[counter] -= s*(nmbPoints_oneDir-1);
1717 pointsRepGlobMapping[counter] += t*nmbPoints_oneDir_allSubdomain*nmbPoints_oneDir;
1718 if (offset_Squares_x > 0 && offset_Squares_z == 0 ) {
1719 pointsRepGlobMapping[counter] -= t*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
1722 pointsRepGlobMapping[counter] += offset_x*(M)
1723 + offset_y*( nmbPoints_oneDir_allSubdomain * M );
1724 if (offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
1725 pointsRepGlobMapping[counter] -= offset_y*M*(nmbPoints_oneDir-1);
1727 else if(offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=M){
1728 pointsRepGlobMapping[counter] -= offset_y*M*(nmbPoints_oneDir-1);
1731 pointsRepGlobMapping[counter] += offset_z * M * nmbPoints_oneDir_allSubdomain * nmbPoints_oneDir;
1732 if (offset_Squares_x > 0 && offset_Squares_z == 0 ) {
1733 pointsRepGlobMapping[counter] -= offset_z*M*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
1736 pointsRepGlobMapping[counter] += offset_Squares_x * M * nmbSubdomainsSquares_OneDir;
1737 if (offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
1738 pointsRepGlobMapping[counter] -= M * nmbSubdomainsSquares_OneDir;
1740 else if(offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=M){
1741 pointsRepGlobMapping[counter] -= M * nmbSubdomainsSquares_OneDir;
1744 pointsRepGlobMapping[counter] += offset_Squares_z * nmbPoints_oneDir_allSubdomain * ((M) * nmbSubdomainsSquares_OneDir+1) * M * nmbSubdomainsSquares_OneDir;
1745 if (offset_Squares_z > 0 ) {
1746 pointsRepGlobMapping[counter] -= (nmbPoints_oneDir-1)*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
1753 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
1755 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
1758 std::cout <<
"-- Building Q2 Unique Points ... " << std::flush;
1760 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(3,0.0)));
1761 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),10));
1764 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
1766 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
1768 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
1769 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
1770 (*this->pointsUni_)[i][2] = (*this->pointsRep_)[index][2];
1771 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
1775 std::cout <<
" done! --" << std::endl;
1780 for (
int t=0; t < M; t++) {
1781 for (
int s=0; s < M; s++) {
1782 for (
int r=0; r < M; r++) {
1784 (*elementsVec)[counter][0] = r + (M+1) * (s) + (M+1)*(M+1) * t ;
1785 (*elementsVec)[counter][1] = r + 1 + (M+1) * (s) + (M+1)*(M+1) * t ;
1786 (*elementsVec)[counter][2] = r + 1 + (M+1) * (s+1) + (M+1)*(M+1) * t ;
1787 (*elementsVec)[counter][3] = r + (M+1) * (s+1) + (M+1)*(M+1) * t ;
1789 (*elementsVec)[counter][4] = r + (M+1) * (s) + (M+1)*(M+1) * (t+1) ;
1790 (*elementsVec)[counter][5] = r + 1 + (M+1) * (s) + (M+1)*(M+1) * (t+1) ;
1791 (*elementsVec)[counter][6] = r + 1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
1792 (*elementsVec)[counter][7] = r + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
1800 buildElementsClass(elementsVec);
1806 int numProcsCoarseSolve){
1810 using Teuchos::ScalarTraits;
1812 typedef ScalarTraits<SC> ST;
1815 bool verbose (this->comm_->getRank() == 0);
1817 setRankRange( numProcsCoarseSolve );
1819 int rank = this->comm_->getRank();
1820 int size = this->comm_->getSize() - numProcsCoarseSolve;
1822 int bfs_multiplier = (int) 2*(length)-1;
1824 int nmbSubdomainsSquares = size / bfs_multiplier;
1825 int nmbSubdomainsSquares_OneDir = (std::pow(nmbSubdomainsSquares,1./3.) + 100*eps);
1827 SC h = ST::one()/(M*N);
1831 LO nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1);
1832 LO nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1) ;
1833 LO nmbPoints = (2*(M+1)-1)*(2*(M+1)-1)*(2*(M+1)-1);
1836 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
1837 this->numElementsGlob_ = (nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1) * bfs_multiplier;
1845 nmbElements = M*M*M;
1848 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
1849 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
1850 vec2D_int_ptr_Type elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements, std::vector<int>(27,-1)));
1851 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
1853 int whichSquareSet = (int)rank / nmbSubdomainsSquares;
1855 int offset_Squares_x = (int) (whichSquareSet+1) / 2;
1856 int offset_Squares_y = 0;
1857 int offset_Squares_z = ((whichSquareSet+1) % 2);
1860 int offset_x = ((rank - nmbSubdomainsSquares*whichSquareSet) % N);
1863 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))>=N) {
1864 offset_y = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))/(N);
1867 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))>=N*N ) {
1868 offset_z = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))/(N*(N));
1871 for (
int t=0; t < 2*(M+1)-1; t++) {
1872 for (
int s=0; s < 2*(M+1)-1; s++) {
1873 for (
int r=0; r < 2*(M+1)-1; r++) {
1875 (*this->pointsRep_)[counter][0] = coorRec[0] + r*h/2. + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
1877 (*this->pointsRep_)[counter][1] = coorRec[1] + s*h/2. + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
1879 (*this->pointsRep_)[counter][2] = coorRec[2] + t*h/2. + offset_z * H + offset_Squares_z * H * nmbSubdomainsSquares_OneDir;
1881 pointsRepGlobMapping[counter] = r
1882 + s*(nmbPoints_oneDir_allSubdomain);
1883 if (offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
1884 pointsRepGlobMapping[counter] -= s*(nmbPoints_oneDir-1);
1886 else if(offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=2*M){
1887 pointsRepGlobMapping[counter] -= s*(nmbPoints_oneDir-1);
1890 pointsRepGlobMapping[counter] += t*nmbPoints_oneDir_allSubdomain*nmbPoints_oneDir;
1891 if (offset_Squares_x > 0 && offset_Squares_z == 0 ) {
1892 pointsRepGlobMapping[counter] -= t*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
1895 pointsRepGlobMapping[counter] += offset_x*(2*M)
1896 + offset_y*( nmbPoints_oneDir_allSubdomain * 2*M );
1897 if (offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
1898 pointsRepGlobMapping[counter] -= offset_y*2*M*(nmbPoints_oneDir-1);
1900 else if(offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=2*M){
1901 pointsRepGlobMapping[counter] -= offset_y*2*M*(nmbPoints_oneDir-1);
1904 pointsRepGlobMapping[counter] += offset_z * 2*M * nmbPoints_oneDir_allSubdomain * nmbPoints_oneDir;
1905 if (offset_Squares_x > 0 && offset_Squares_z == 0 ) {
1906 pointsRepGlobMapping[counter] -= offset_z*2*M*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
1909 pointsRepGlobMapping[counter] += offset_Squares_x * 2*M * nmbSubdomainsSquares_OneDir;
1910 if (offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
1911 pointsRepGlobMapping[counter] -= 2*M * nmbSubdomainsSquares_OneDir;
1913 else if(offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=2*M){
1914 pointsRepGlobMapping[counter] -= 2*M * nmbSubdomainsSquares_OneDir;
1917 pointsRepGlobMapping[counter] += offset_Squares_z * nmbPoints_oneDir_allSubdomain * ((2*M) * nmbSubdomainsSquares_OneDir+1) * 2*M * nmbSubdomainsSquares_OneDir;
1918 if (offset_Squares_z > 0 ) {
1919 pointsRepGlobMapping[counter] -= (nmbPoints_oneDir-1)*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
1926 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
1928 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
1931 std::cout <<
"-- Building Q2 Unique Points ... " << std::flush;
1933 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(3,0.0)));
1934 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
1937 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
1939 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
1941 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
1942 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
1943 (*this->pointsUni_)[i][2] = (*this->pointsRep_)[index][2];
1944 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
1948 std::cout <<
" done! --" << std::endl;
1950 int P2M = 2*(M+1)-1;
1953 for (
int t=0; t < M; t++) {
1954 for (
int s=0; s < M; s++) {
1955 for (
int r=0; r < M; r++) {
1957 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
1958 (*elementsVec)[counter][1] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
1959 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
1960 (*elementsVec)[counter][3] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
1962 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
1963 (*elementsVec)[counter][5] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
1964 (*elementsVec)[counter][6] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
1965 (*elementsVec)[counter][7] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
1967 (*elementsVec)[counter][8] = 2*(r)+1 + 2*P2M * (s) + 2*P2M*P2M * (t) ;
1968 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) ;
1969 (*elementsVec)[counter][10] = 2*(r)+1 + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
1970 (*elementsVec)[counter][11] = 2*(r) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) ;
1972 (*elementsVec)[counter][12] = 2*(r)+1 + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
1973 (*elementsVec)[counter][13] = 2*(r+1) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t+1) ;
1974 (*elementsVec)[counter][14] = 2*(r)+1 + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
1975 (*elementsVec)[counter][15] = 2*(r) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t+1) ;
1977 (*elementsVec)[counter][16] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) + P2M*P2M;
1978 (*elementsVec)[counter][17] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) + P2M*P2M;
1979 (*elementsVec)[counter][18] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) + P2M*P2M;
1980 (*elementsVec)[counter][19] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) + P2M*P2M;
1982 (*elementsVec)[counter][20] = 2*(r)+1 + 2*P2M * (s) + 2*P2M*P2M * (t) + P2M*P2M;
1983 (*elementsVec)[counter][21] = 2*(r+1) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) + P2M*P2M;
1984 (*elementsVec)[counter][22] = 2*(r)+1 + 2*P2M * (s+1) + 2*P2M*P2M * (t) + P2M*P2M;
1985 (*elementsVec)[counter][23] = 2*(r) + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) + P2M*P2M;
1987 (*elementsVec)[counter][24] = 2*(r)+1 + 2*P2M * (s) + P2M + 2*P2M*P2M * (t);
1988 (*elementsVec)[counter][25] = 2*(r)+1 + 2*P2M * (s) + P2M + 2*P2M*P2M * (t) + P2M*P2M;
1989 (*elementsVec)[counter][26] = 2*(r)+1 + 2*P2M * (s) + P2M + 2*P2M*P2M * (t+1);
1996 buildElementsClass(elementsVec);
2003 int numProcsCoarseSolve) {
2008 using Teuchos::ScalarTraits;
2010 TEUCHOS_TEST_FOR_EXCEPTION(!(M>=1),std::logic_error,
"H/h is to small.");
2011 TEUCHOS_TEST_FOR_EXCEPTION(this->comm_.is_null(),std::runtime_error,
"comm_ is null.");
2013 SC eps = ScalarTraits<SC>::eps();
2015 bool verbose (this->comm_->getRank() == 0);
2017 setRankRange( numProcsCoarseSolve );
2019 int rank = this->comm_->getRank();
2020 int size = this->comm_->getSize() - numProcsCoarseSolve;
2022 int bfs_multiplier = (int) 2*(length)-1;
2024 int nmbSubdomainsSquares = size / bfs_multiplier;
2025 int nmbSubdomainsSquares_OneDir = (std::pow(nmbSubdomainsSquares,1/2.) + 100*eps);
2027 vec2D_int_ptr_Type elementsVec;
2032 double h = 1./(M*N);
2034 GO nmbPoints_oneDir;
2035 GO nmbPoints_oneDir_allSubdomain;
2036 if (FEType ==
"P0") {
2037 nmbPoints_oneDir = N * (M+1) - (N-1) ;
2038 nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1) ;
2039 nmbPoints = (M+1)*(M+1) ;
2041 else if (FEType ==
"P1") {
2042 nmbPoints_oneDir = N * (M+1) - (N-1) ;
2043 nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1) ;
2044 nmbPoints = (M+1)*(M+1) ;
2046 else if(FEType ==
"P2"){
2047 nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1) ;
2048 nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1) ;
2049 nmbPoints = (2*(M+1)-1)*(2*(M+1)-1) ;
2052 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Wrong FE-Type, either P1 or P2.");
2055 this->FEType_ = FEType;
2057 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
2059 this->numElementsGlob_ = 2*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1) * bfs_multiplier;
2067 nmbElements = 2*(M)*(M);
2071 if (FEType ==
"P0") {
2073 std::cout <<
"-- H:"<<H <<
" h:" <<h <<
" --" << std::endl;
2076 std::cout <<
"-- Building P0 Points Repeated ... " << std::endl;
2078 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(2,0.0)));
2079 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
2080 elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements, std::vector<int>(3,-1)));
2082 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
2084 int whichSquareSet = (int)rank / nmbSubdomainsSquares;
2086 int offset_Squares_x = (int) (whichSquareSet+1) / 2;
2087 int offset_Squares_y = ((whichSquareSet+1) % 2);
2089 int offset_x = ((rank - nmbSubdomainsSquares*whichSquareSet) % N);
2092 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))>=N) {
2093 offset_y = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))/(N);
2096 for (
int s=0; s < M+1; s++) {
2097 for (
int r=0; r < M+1; r++) {
2098 (*this->pointsRep_)[counter][0] = coorRec[0] + r*h + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
2099 (*this->pointsRep_)[counter][1] = coorRec[1] + s*h + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
2100 pointsRepGlobMapping[counter] = r + s*(nmbPoints_oneDir_allSubdomain - (1-offset_Squares_y)*(nmbPoints_oneDir-1))
2102 + offset_y*((nmbPoints_oneDir_allSubdomain) - (1-offset_Squares_y)*(nmbPoints_oneDir-1)) *M
2103 + offset_Squares_x * M * nmbSubdomainsSquares_OneDir
2104 + offset_Squares_y * (nmbPoints_oneDir_allSubdomain * M * nmbSubdomainsSquares_OneDir
2105 - (nmbPoints_oneDir-1)*(nmbPoints_oneDir-1));
2107 if (offset_Squares_x>0 && offset_Squares_y==0 ) {
2108 pointsRepGlobMapping[counter] -= nmbPoints_oneDir-1;
2110 if (offset_Squares_x>0 && offset_Squares_y==0 && offset_y+1==nmbSubdomainsSquares_OneDir && s==M) {
2111 pointsRepGlobMapping[counter] += nmbPoints_oneDir-1;
2113 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[counter][0] < (coorRec[0]+eps) ||
2114 (*this->pointsRep_)[counter][1] > (coorRec[1]+height-eps) || (*this->pointsRep_)[counter][1] < (coorRec[1]+eps)) {
2115 (*this->bcFlagRep_)[counter] = 1;
2123 std::cout <<
" done! --" << std::endl;
2127 std::cout <<
"-- Building P0 Repeated and Unique Map ... " << std::flush;
2132 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
2134 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
2136 std::cout <<
" done! --" << std::endl;
2140 std::cout <<
"-- Building P0 Unique Points ... " << std::flush;
2143 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(), std::vector<double>(2,0.0)));
2144 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
2146 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
2148 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
2150 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
2151 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
2152 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
2156 std::cout <<
" done! --" << std::endl;
2161 std::cout <<
"-- Building P0 Elements ... " << std::flush;
2165 for (
int s=0; s < M; s++) {
2166 for (
int r=0; r < M; r++) {
2167 (*elementsVec)[counter][0] = r+1 + (M+1) * s;
2168 (*elementsVec)[counter][1] = r + (M+1) * s ;
2169 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1);
2171 (*elementsVec)[counter][0] = r + (M+1) * (s+1);
2172 (*elementsVec)[counter][1] = r + (M+1) * (s);
2173 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1);
2179 std::cout <<
" done! --" << std::endl;
2184 else if (FEType ==
"P1") {
2186 std::cout <<
"-- H:"<<H <<
" h:" <<h <<
" --" << std::endl;
2189 std::cout <<
"-- Building P1 Points Repeated ... " << std::endl;
2192 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(2,0.0)));
2193 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
2194 elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements,std::vector<int>(3,-1)));
2196 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
2198 int whichSquareSet = (int)rank / nmbSubdomainsSquares;
2200 int offset_Squares_x = (int) (whichSquareSet+1) / 2;
2201 int offset_Squares_y = ((whichSquareSet+1) % 2);
2203 int offset_x = ((rank - nmbSubdomainsSquares*whichSquareSet) % N);
2206 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))>=N) {
2207 offset_y = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))/(N);
2210 for (
int s=0; s < M+1; s++) {
2211 for (
int r=0; r < M+1; r++) {
2212 (*this->pointsRep_)[counter][0] = coorRec[0] + r*h + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
2213 (*this->pointsRep_)[counter][1] = coorRec[1] + s*h + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
2214 pointsRepGlobMapping[counter] = r + s*(nmbPoints_oneDir_allSubdomain - (1-offset_Squares_y)*(nmbPoints_oneDir-1))
2216 + offset_y*((nmbPoints_oneDir_allSubdomain) - (1-offset_Squares_y)*(nmbPoints_oneDir-1)) *M
2217 + offset_Squares_x * M * nmbSubdomainsSquares_OneDir
2218 + offset_Squares_y * (nmbPoints_oneDir_allSubdomain * M * nmbSubdomainsSquares_OneDir
2219 - (nmbPoints_oneDir-1)*(nmbPoints_oneDir-1));
2221 if (offset_Squares_x>0 && offset_Squares_y==0 ) {
2222 pointsRepGlobMapping[counter] -= nmbPoints_oneDir-1;
2224 if (offset_Squares_x>0 && offset_Squares_y==0 && offset_y+1==nmbSubdomainsSquares_OneDir && s==M) {
2225 pointsRepGlobMapping[counter] += nmbPoints_oneDir-1;
2227 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[counter][0] < (coorRec[0]+eps) ||
2228 (*this->pointsRep_)[counter][1] > (coorRec[1]+height-eps) || (*this->pointsRep_)[counter][1] < (coorRec[1]+eps)) {
2229 (*this->bcFlagRep_)[counter] = 1;
2237 std::cout <<
" done! --" << std::endl;
2241 std::cout <<
"-- Building P1 Repeated and Unique Map ... " << std::flush;
2247 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
2249 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
2252 std::cout <<
" done! --" << std::endl;
2256 std::cout <<
"-- Building P1 Unique Points ... " << std::flush;
2259 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(), std::vector<double>(2,0.0)));
2260 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
2262 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
2264 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
2266 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
2267 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
2268 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
2272 std::cout <<
" done! --" << std::endl;
2277 std::cout <<
"-- Building P1 Elements ... " << std::flush;
2281 for (
int s=0; s < M; s++) {
2282 for (
int r=0; r < M; r++) {
2283 (*elementsVec)[counter][0] = r+1 + (M+1) * s;
2284 (*elementsVec)[counter][1] = r + (M+1) * s ;
2285 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1);
2287 (*elementsVec)[counter][0] = r + (M+1) * (s+1);
2288 (*elementsVec)[counter][1] = r + (M+1) * (s);
2289 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1);
2295 std::cout <<
" done! --" << std::endl;
2300 else if(FEType ==
"P2"){
2302 std::cout <<
"-- H:"<<H <<
" h:" <<h <<
" --" << std::endl;
2305 std::cout <<
"-- Building P2 Points Repeated ... " << std::flush;
2308 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(2,0.0)));
2309 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
2310 elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements,std::vector<int>(6,-1)));
2311 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
2313 int whichSquareSet = (int)rank / nmbSubdomainsSquares;
2315 int offset_Squares_x = (int) (whichSquareSet+1) / 2;
2316 int offset_Squares_y = ((whichSquareSet+1) % 2);
2319 int offset_x = ((rank - nmbSubdomainsSquares*whichSquareSet) % N);
2323 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))>=N) {
2324 offset_y = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))/(N);
2332 for (
int s=0; s < 2*(M+1)-1; s++) {
2333 for (
int r=0; r < 2*(M+1)-1; r++) {
2335 if (s%2==0 && r%2==0) {
2340 (*this->pointsRep_)[counter][0] = coorRec[0] + r*h/2. + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
2341 (*this->pointsRep_)[counter][1] = coorRec[1] + s*h/2. + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
2342 pointsRepGlobMapping[counter] = r + s*(nmbPoints_oneDir_allSubdomain - (1-offset_Squares_y)*(nmbPoints_oneDir-1))
2343 + offset_x*(2*(M+1)-2)
2344 + offset_y*((nmbPoints_oneDir_allSubdomain) - (1-offset_Squares_y)*(nmbPoints_oneDir-1)) * (2*(M+1)-2)
2345 + offset_Squares_x * (2*(M+1)-2) * nmbSubdomainsSquares_OneDir
2346 + offset_Squares_y * (nmbPoints_oneDir_allSubdomain * 2*M * nmbSubdomainsSquares_OneDir
2347 - (nmbPoints_oneDir-1)*(nmbPoints_oneDir-1));
2349 if (offset_Squares_x>0 && offset_Squares_y==0 ) {
2350 pointsRepGlobMapping[counter] -= nmbPoints_oneDir-1;
2352 if (offset_Squares_x>0 && offset_Squares_y==0 && offset_y+1==nmbSubdomainsSquares_OneDir && s==2*M) {
2353 pointsRepGlobMapping[counter] += nmbPoints_oneDir-1;
2355 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[counter][0] < (coorRec[0]+eps) ||
2356 (*this->pointsRep_)[counter][1] > (coorRec[1]+height-eps) || (*this->pointsRep_)[counter][1] < (coorRec[1]+eps)) {
2357 (*this->bcFlagRep_)[counter] = 1;
2365 std::cout <<
" done! --" << std::endl;
2371 std::cout <<
"-- Building P2 Repeated and Unique Map ... " << std::flush;
2375 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
2377 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
2381 std::cout <<
" done! --" << std::endl;
2385 std::cout <<
"-- Building P2 Unique Points ... " << std::flush;
2388 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(2,0.0)));
2389 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
2392 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
2394 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
2396 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
2397 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
2398 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
2402 std::cout <<
" done! --" << std::endl;
2416 std::cout <<
"-- Building P2 Elements ... " << std::flush;
2419 int P2M = 2*(M+1)-1;
2423 for (
int s=0; s < M; s++) {
2424 for (
int r=0; r < M; r++) {
2426 (*elementsVec)[counter][0] = 2*(r+1) + 2*P2M * (s) ;
2427 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) ;
2428 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) ;
2430 (*elementsVec)[counter][3] = 2*(r) +1 + 2*P2M * (s) ;
2431 (*elementsVec)[counter][4] = 2*(r) +1 + 2*P2M * (s) +P2M ;
2432 (*elementsVec)[counter][5] = 2*(r+1) + 2*P2M * (s) +P2M ;
2436 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s+1) ;
2437 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) ;
2438 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) ;
2440 (*elementsVec)[counter][3] = 2*(r) + 2*P2M * (s) +P2M ;
2441 (*elementsVec)[counter][4] = 2*(r) +1 + 2*P2M * (s) +P2M ;
2442 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s+1) ;
2450 std::cout <<
" done! --" << std::endl;
2453 buildElementsClass(elementsVec);
2460 int numProcsCoarseSolve){
2464 using Teuchos::ScalarTraits;
2466 TEUCHOS_TEST_FOR_EXCEPTION(!(M>=1),std::logic_error,
"H/h is to small.");
2467 TEUCHOS_TEST_FOR_EXCEPTION(this->comm_.is_null(),std::runtime_error,
"comm_ is null.");
2469 typedef ScalarTraits<SC> ST;
2472 bool verbose (this->comm_->getRank() == 0);
2474 setRankRange( numProcsCoarseSolve );
2476 int rank = this->comm_->getRank();
2477 int size = this->comm_->getSize() - numProcsCoarseSolve;
2479 int bfs_multiplier = (int) 2*(length)-1;
2481 int nmbSubdomainsSquares = size / bfs_multiplier;
2482 int nmbSubdomainsSquares_OneDir = (std::pow(nmbSubdomainsSquares,1./3.) + 100*eps);
2484 SC h = ST::one()/(M*N);
2490 GO nmbPoints_oneDir;
2491 GO nmbPoints_oneDir_allSubdomain;
2493 if (FEType ==
"P0") {
2494 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"implement P0.");
2496 else if (FEType ==
"P1") {
2497 nmbPoints_oneDir = N * (M+1) - (N-1);
2498 nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1);
2499 nmbPoints = (M+1)*(M+1)*(M+1);
2501 else if(FEType ==
"P2"){
2502 nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1);
2503 nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1) ;
2504 nmbPoints = (2*(M+1)-1)*(2*(M+1)-1)*(2*(M+1)-1);
2506 else if(FEType ==
"P2-CR"){
2507 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"P2-CR might not work properly.");
2508 nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1);
2509 nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1) ;
2510 nmbPoints = (2*(M+1)-1)*(2*(M+1)-1)*(2*(M+1)-1);
2512 else if(FEType ==
"P1-disc" || FEType ==
"P1-disc-global"){
2513 nmbPoints_oneDir = N * (M+1) - (N-1);
2514 nmbPoints_oneDir_allSubdomain = length * nmbPoints_oneDir - (length-1);
2515 nmbPoints = (M+1)*(M+1)*(M+1);
2517 else if(FEType ==
"Q1"){
2520 else if(FEType ==
"Q2"){
2524 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Wrong FE-Type, only P1,P1-disc, P1-disc-global, P2, or P2-CR.");
2526 this->FEType_ = FEType;
2528 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
2529 this->numElementsGlob_ = 6*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1) * bfs_multiplier;
2537 nmbElements = 6*M*M*M;
2541 if (FEType ==
"P1") {
2543 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
2544 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
2545 vec2D_int_ptr_Type elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements,std::vector<int>(4,-1)));
2547 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
2549 int whichSquareSet = (int)rank / nmbSubdomainsSquares;
2551 int offset_Squares_x = (int) (whichSquareSet+1) / 2;
2552 int offset_Squares_y = 0;
2553 int offset_Squares_z = ((whichSquareSet+1) % 2);
2556 int offset_x = ((rank - nmbSubdomainsSquares*whichSquareSet) % N);
2559 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))>=N)
2560 offset_y = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))/(N);
2561 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))>=N*N )
2562 offset_z = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))/(N*(N));
2564 for (
int t=0; t < M+1; t++) {
2565 for (
int s=0; s < M+1; s++) {
2566 for (
int r=0; r < M+1; r++) {
2567 (*this->pointsRep_)[counter][0] = coorRec[0] + r*h + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
2569 (*this->pointsRep_)[counter][1] = coorRec[1] + s*h + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
2571 (*this->pointsRep_)[counter][2] = coorRec[2] + t*h + offset_z * H + offset_Squares_z * H * nmbSubdomainsSquares_OneDir;
2573 pointsRepGlobMapping[counter] = r
2574 + s*(nmbPoints_oneDir_allSubdomain);
2575 if (offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
2576 pointsRepGlobMapping[counter] -= s*(nmbPoints_oneDir-1);
2578 else if(offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=M){
2579 pointsRepGlobMapping[counter] -= s*(nmbPoints_oneDir-1);
2582 pointsRepGlobMapping[counter] += t*nmbPoints_oneDir_allSubdomain*nmbPoints_oneDir;
2583 if (offset_Squares_x > 0 && offset_Squares_z == 0 ) {
2584 pointsRepGlobMapping[counter] -= t*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
2587 pointsRepGlobMapping[counter] += offset_x*(M)
2588 + offset_y*( nmbPoints_oneDir_allSubdomain * M );
2589 if (offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
2590 pointsRepGlobMapping[counter] -= offset_y*M*(nmbPoints_oneDir-1);
2592 else if(offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=M){
2593 pointsRepGlobMapping[counter] -= offset_y*M*(nmbPoints_oneDir-1);
2596 pointsRepGlobMapping[counter] += offset_z * M * nmbPoints_oneDir_allSubdomain * nmbPoints_oneDir;
2597 if (offset_Squares_x > 0 && offset_Squares_z == 0 ) {
2598 pointsRepGlobMapping[counter] -= offset_z*M*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
2601 pointsRepGlobMapping[counter] += offset_Squares_x * M * nmbSubdomainsSquares_OneDir;
2602 if (offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
2603 pointsRepGlobMapping[counter] -= M * nmbSubdomainsSquares_OneDir;
2605 else if(offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=M){
2606 pointsRepGlobMapping[counter] -= M * nmbSubdomainsSquares_OneDir;
2609 pointsRepGlobMapping[counter] += offset_Squares_z * nmbPoints_oneDir_allSubdomain * ((M) * nmbSubdomainsSquares_OneDir+1) * M * nmbSubdomainsSquares_OneDir;
2610 if (offset_Squares_z > 0 ) {
2611 pointsRepGlobMapping[counter] -= (nmbPoints_oneDir-1)*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
2619 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
2621 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
2624 std::cout <<
"-- Building P1 Unique Points ... " << std::flush;
2627 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(), std::vector<double>(3,0.0)));
2628 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
2631 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
2632 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
2633 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
2634 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
2635 (*this->pointsUni_)[i][2] = (*this->pointsRep_)[index][2];
2636 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
2640 std::cout <<
" done! --" << std::endl;
2645 std::cout <<
"-- Building P1 Elements ... " << std::flush;
2648 for (
int t=0; t < M; t++) {
2649 for (
int s=0; s < M; s++) {
2650 for (
int r=0; r < M; r++) {
2651 (*elementsVec)[counter][0] = r+1 + (M+1) * s + (M+1)*(M+1) * t ;
2652 (*elementsVec)[counter][1] = r + (M+1) * s + (M+1)*(M+1) * t ;
2653 (*elementsVec)[counter][2] = r+1 + (M+1) * s + (M+1)*(M+1) * (t+1) ;
2654 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
2656 (*elementsVec)[counter][0] = r + (M+1) * s + (M+1)*(M+1) * (t+1) ;
2657 (*elementsVec)[counter][1] = r + (M+1) * s + (M+1)*(M+1) * t ;
2658 (*elementsVec)[counter][2] = r+1 + (M+1) * s + (M+1)*(M+1) * (t+1) ;
2659 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
2661 (*elementsVec)[counter][0] = r+1 + (M+1) * s + (M+1)*(M+1) * t ;
2662 (*elementsVec)[counter][1] = r + (M+1) * s + (M+1)*(M+1) * t ;
2663 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * t ;
2664 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
2666 (*elementsVec)[counter][0] = r + (M+1) * s + (M+1)*(M+1) * t ;
2667 (*elementsVec)[counter][1] = r + (M+1) * (s+1) + (M+1)*(M+1) * t ;
2668 (*elementsVec)[counter][2] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * t ;
2669 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
2671 (*elementsVec)[counter][0] = r + (M+1) * s + (M+1)*(M+1) * t ;
2672 (*elementsVec)[counter][1] = r + (M+1) * (s+1) + (M+1)*(M+1) * t ;
2673 (*elementsVec)[counter][2] = r + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
2674 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
2676 (*elementsVec)[counter][0] = r + (M+1) * s + (M+1)*(M+1) * t ;
2677 (*elementsVec)[counter][1] = r + (M+1) * s + (M+1)*(M+1) * (t+1) ;
2678 (*elementsVec)[counter][2] = r + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
2679 (*elementsVec)[counter][3] = r+1 + (M+1) * (s+1) + (M+1)*(M+1) * (t+1) ;
2685 std::cout <<
" done! --" << std::endl;
2687 buildElementsClass(elementsVec);
2689 else if(FEType ==
"P1-disc" || FEType ==
"P1-disc-global")
2691 else if(FEType ==
"P2"){
2693 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
2694 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
2695 vec2D_int_ptr_Type elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements,std::vector<int>(10,-1)));
2696 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
2698 int whichSquareSet = (int)rank / nmbSubdomainsSquares;
2700 int offset_Squares_x = (int) (whichSquareSet+1) / 2;
2701 int offset_Squares_y = 0;
2702 int offset_Squares_z = ((whichSquareSet+1) % 2);
2705 int offset_x = ((rank - nmbSubdomainsSquares*whichSquareSet) % N);
2708 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))>=N) {
2709 offset_y = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))/(N);
2712 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))>=N*N ) {
2713 offset_z = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))/(N*(N));
2720 for (
int t=0; t < 2*(M+1)-1; t++) {
2721 for (
int s=0; s < 2*(M+1)-1; s++) {
2722 for (
int r=0; r < 2*(M+1)-1; r++) {
2724 if (s%2==0 && r%2==0 && t%2==0) {
2730 (*this->pointsRep_)[counter][0] = coorRec[0] + r*h/2. + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
2732 (*this->pointsRep_)[counter][1] = coorRec[1] + s*h/2. + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
2734 (*this->pointsRep_)[counter][2] = coorRec[2] + t*h/2. + offset_z * H + offset_Squares_z * H * nmbSubdomainsSquares_OneDir;
2736 pointsRepGlobMapping[counter] = r
2737 + s*(nmbPoints_oneDir_allSubdomain);
2738 if (offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
2739 pointsRepGlobMapping[counter] -= s*(nmbPoints_oneDir-1);
2741 else if(offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=2*M){
2742 pointsRepGlobMapping[counter] -= s*(nmbPoints_oneDir-1);
2745 pointsRepGlobMapping[counter] += t*nmbPoints_oneDir_allSubdomain*nmbPoints_oneDir;
2746 if (offset_Squares_x > 0 && offset_Squares_z == 0 ) {
2747 pointsRepGlobMapping[counter] -= t*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
2750 pointsRepGlobMapping[counter] += offset_x*(2*M)
2751 + offset_y*( nmbPoints_oneDir_allSubdomain * 2*M );
2752 if (offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
2753 pointsRepGlobMapping[counter] -= offset_y*2*M*(nmbPoints_oneDir-1);
2755 else if(offset_Squares_x > 0 && offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=2*M){
2756 pointsRepGlobMapping[counter] -= offset_y*2*M*(nmbPoints_oneDir-1);
2759 pointsRepGlobMapping[counter] += offset_z * 2*M * nmbPoints_oneDir_allSubdomain * nmbPoints_oneDir;
2760 if (offset_Squares_x > 0 && offset_Squares_z == 0 ) {
2761 pointsRepGlobMapping[counter] -= offset_z*2*M*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
2764 pointsRepGlobMapping[counter] += offset_Squares_x * 2*M * nmbSubdomainsSquares_OneDir;
2765 if (offset_Squares_z == 0 && offset_z+1!=nmbSubdomainsSquares_OneDir) {
2766 pointsRepGlobMapping[counter] -= 2*M * nmbSubdomainsSquares_OneDir;
2768 else if(offset_Squares_z == 0 && offset_z+1==nmbSubdomainsSquares_OneDir && t!=2*M){
2769 pointsRepGlobMapping[counter] -= 2*M * nmbSubdomainsSquares_OneDir;
2772 pointsRepGlobMapping[counter] += offset_Squares_z * nmbPoints_oneDir_allSubdomain * ((2*M) * nmbSubdomainsSquares_OneDir+1) * 2*M * nmbSubdomainsSquares_OneDir;
2773 if (offset_Squares_z > 0 ) {
2774 pointsRepGlobMapping[counter] -= (nmbPoints_oneDir-1)*(nmbPoints_oneDir-1)*(nmbPoints_oneDir);
2781 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
2783 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
2786 std::cout <<
"-- Building P2 Unique Points ... " << std::flush;
2789 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(3,0.0)));
2790 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),0));
2793 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
2795 index = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement(i) );
2797 (*this->pointsUni_)[i][0] = (*this->pointsRep_)[index][0];
2798 (*this->pointsUni_)[i][1] = (*this->pointsRep_)[index][1];
2799 (*this->pointsUni_)[i][2] = (*this->pointsRep_)[index][2];
2800 (*this->bcFlagUni_)[i] = (*this->bcFlagRep_)[index];
2804 std::cout <<
" done! --" << std::endl;
2817 int P2M = 2*(M+1)-1;
2820 for (
int t=0; t < M; t++) {
2821 for (
int s=0; s < M; s++) {
2822 for (
int r=0; r < M; r++) {
2824 (*elementsVec)[counter][0] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2825 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2826 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
2827 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
2829 (*elementsVec)[counter][4] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2830 (*elementsVec)[counter][6] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M;
2831 (*elementsVec)[counter][7] = 2*(r+1) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M;
2832 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M;
2833 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M;
2834 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t+1);
2838 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
2839 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2840 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
2841 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
2843 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M ;
2844 (*elementsVec)[counter][6] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
2845 (*elementsVec)[counter][7] = 2*(r) +1 + 2*P2M * (s)+P2M + 2*P2M*P2M * (t+1) ;
2846 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M ;
2847 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) +P2M*P2M ;
2848 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t+1);
2852 (*elementsVec)[counter][0] = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2853 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2854 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
2855 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
2857 (*elementsVec)[counter][4] = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2858 (*elementsVec)[counter][6] = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) ;
2859 (*elementsVec)[counter][7] = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) +P2M*P2M ;
2860 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) ;
2861 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) +P2M*P2M ;
2862 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
2866 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2867 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
2868 (*elementsVec)[counter][2] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
2869 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
2871 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) ;
2872 (*elementsVec)[counter][6] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) ;
2873 (*elementsVec)[counter][7] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
2874 (*elementsVec)[counter][5] = 2*(r) +1 + 2*P2M * (s+1) + 2*P2M*P2M * (t);
2875 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
2876 (*elementsVec)[counter][9] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
2880 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2881 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) ;
2882 (*elementsVec)[counter][2] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
2883 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
2885 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) ;
2886 (*elementsVec)[counter][6] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
2887 (*elementsVec)[counter][7] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
2888 (*elementsVec)[counter][5] = 2*(r) + 2*P2M*(s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
2889 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M*(s+1) + 2*P2M*P2M * (t) +P2M*P2M ;
2890 (*elementsVec)[counter][9] = 2*(r) +1 + 2*P2M*(s+1) + 2*P2M*P2M * (t+1) ;
2894 (*elementsVec)[counter][0] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) ;
2895 (*elementsVec)[counter][1] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t+1) ;
2896 (*elementsVec)[counter][2] = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
2897 (*elementsVec)[counter][3] = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) ;
2899 (*elementsVec)[counter][4] = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) +P2M*P2M ;
2900 (*elementsVec)[counter][6] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
2901 (*elementsVec)[counter][7] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M ;
2902 (*elementsVec)[counter][5] = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t+1) ;
2903 (*elementsVec)[counter][8] = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t+1) ;
2904 (*elementsVec)[counter][9] = 2*(r) +1 + 2*P2M*(s+1) + 2*P2M*P2M * (t+1) ;
2911 buildElementsClass(elementsVec);
2913 else if(FEType ==
"Q1")
2915 else if(FEType ==
"Q2")
2923 int numProcsCoarseSolve){
2930 using Teuchos::ScalarTraits;
2931 typedef ScalarTraits<SC> ST;
2933 bool verbose (this->comm_->getRank() == 0);
2935 setRankRange( numProcsCoarseSolve );
2938 std::cout << std::endl;
2940 SC eps = ScalarTraits<SC>::eps();
2942 int rank = this->comm_->getRank();
2943 int size = this->comm_->getSize() - numProcsCoarseSolve;
2946 int bfs_multiplier = (int) 2*(length)-1;
2948 int nmbSubdomainsSquares = size / bfs_multiplier;
2949 int nmbSubdomainsSquares_OneDir = (std::pow(nmbSubdomainsSquares,1./3.) + 100*eps);
2951 SC h = ST::one()/(M*N);
2954 LO nmbElements = M*M*M;
2955 LO nmbPoints = 4*M*M*M;
2964 this->numElementsGlob_ = nmbElements * size;
2966 int whichSquareSet = (int)rank / nmbSubdomainsSquares;
2968 int offset_Squares_x = (int) (whichSquareSet+1) / 2;
2969 int offset_Squares_y = 0;
2970 int offset_Squares_z = ((whichSquareSet+1) % 2);
2973 int offset_x = ((rank - nmbSubdomainsSquares*whichSquareSet) % N);
2976 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))>=N)
2977 offset_y = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N))/(N);
2979 if (((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))>=N*N )
2980 offset_z = (int) ((rank - nmbSubdomainsSquares*whichSquareSet) % (N*N*N))/(N*(N));
2983 this->pointsRep_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
2984 this->pointsUni_.reset(
new std::vector<std::vector<double> >(nmbPoints,std::vector<double>(3,0.0)));
2985 this->bcFlagRep_.reset(
new std::vector<int> (nmbPoints,0));
2986 this->bcFlagUni_.reset(
new std::vector<int> (nmbPoints,0));
2987 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
2990 std::cout <<
"-- Building P1-disc Points and Elements according to Q2 ... " << std::flush;
2992 vec2D_int_ptr_Type elementsVec = Teuchos::rcp(
new std::vector<std::vector<int> >(nmbElements,std::vector<int>(4,-1)));
2996 GO globalCounterPoints = rank * nmbPoints;
2997 for (
int t=0; t < M; t++) {
2998 for (
int s=0; s < M; s++) {
2999 for (
int r=0; r < M; r++) {
3002 (*this->pointsRep_)[pCounter][0] = coorRec[0] + r*h + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
3003 (*this->pointsRep_)[pCounter][1] = coorRec[1] + s*h + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
3004 (*this->pointsRep_)[pCounter][2] = coorRec[2] + t*h + offset_z * H + offset_Squares_z * H * nmbSubdomainsSquares_OneDir;
3006 if ((*this->pointsRep_)[pCounter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[pCounter][0] < (coorRec[0]+eps) ||
3007 (*this->pointsRep_)[pCounter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[pCounter][1] < (coorRec[1]+eps) ||
3008 (*this->pointsRep_)[pCounter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[pCounter][2] < (coorRec[2]+eps) ) {
3010 (*this->bcFlagRep_)[counter] = 1;
3013 (*this->pointsUni_)[pCounter][0] = (*this->pointsRep_)[pCounter][0];
3014 (*this->pointsUni_)[pCounter][1] = (*this->pointsRep_)[pCounter][1];
3015 (*this->pointsUni_)[pCounter][2] = (*this->pointsRep_)[pCounter][2];
3017 (*this->bcFlagUni_)[pCounter] = (*this->bcFlagRep_)[pCounter];
3019 (*elementsVec)[counter][0] = pCounter;
3020 pointsRepGlobMapping[pCounter] = globalCounterPoints;
3021 globalCounterPoints++;
3025 (*this->pointsRep_)[pCounter][0] = coorRec[0] + (r+1)*h + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
3026 (*this->pointsRep_)[pCounter][1] = coorRec[1] + s*h + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
3027 (*this->pointsRep_)[pCounter][2] = coorRec[2] + t*h + offset_z * H + offset_Squares_z * H * nmbSubdomainsSquares_OneDir;
3028 if ((*this->pointsRep_)[pCounter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[pCounter][0] < (coorRec[0]+eps) ||
3029 (*this->pointsRep_)[pCounter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[pCounter][1] < (coorRec[1]+eps) ||
3030 (*this->pointsRep_)[pCounter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[pCounter][2] < (coorRec[2]+eps) ) {
3032 (*this->bcFlagRep_)[counter] = 1;
3035 (*this->pointsUni_)[pCounter][0] = (*this->pointsRep_)[pCounter][0];
3036 (*this->pointsUni_)[pCounter][1] = (*this->pointsRep_)[pCounter][1];
3037 (*this->pointsUni_)[pCounter][2] = (*this->pointsRep_)[pCounter][2];
3039 (*this->bcFlagUni_)[pCounter] = (*this->bcFlagRep_)[pCounter];
3041 (*elementsVec)[counter][1] = pCounter;
3042 pointsRepGlobMapping[pCounter] = globalCounterPoints;
3043 globalCounterPoints++;
3046 (*this->pointsRep_)[pCounter][0] = coorRec[0] + r*h + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
3047 (*this->pointsRep_)[pCounter][1] = coorRec[1] + (s+1)*h + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
3048 (*this->pointsRep_)[pCounter][2] = coorRec[2] + t*h + offset_z * H + offset_Squares_z * H * nmbSubdomainsSquares_OneDir;
3049 if ((*this->pointsRep_)[pCounter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[pCounter][0] < (coorRec[0]+eps) ||
3050 (*this->pointsRep_)[pCounter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[pCounter][1] < (coorRec[1]+eps) ||
3051 (*this->pointsRep_)[pCounter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[pCounter][2] < (coorRec[2]+eps) ) {
3053 (*this->bcFlagRep_)[counter] = 1;
3056 (*this->pointsUni_)[pCounter][0] = (*this->pointsRep_)[pCounter][0];
3057 (*this->pointsUni_)[pCounter][1] = (*this->pointsRep_)[pCounter][1];
3058 (*this->pointsUni_)[pCounter][2] = (*this->pointsRep_)[pCounter][2];
3060 (*this->bcFlagUni_)[pCounter] = (*this->bcFlagRep_)[pCounter];
3062 (*elementsVec)[counter][2] = pCounter;
3063 pointsRepGlobMapping[pCounter] = globalCounterPoints;
3064 globalCounterPoints++;
3068 (*this->pointsRep_)[pCounter][0] = coorRec[0] + r*h + offset_x * H + offset_Squares_x * H * nmbSubdomainsSquares_OneDir;
3069 (*this->pointsRep_)[pCounter][1] = coorRec[1] + s*h + offset_y * H + offset_Squares_y * H * nmbSubdomainsSquares_OneDir;
3070 (*this->pointsRep_)[pCounter][2] = coorRec[2] + (t+1)*h + offset_z * H + offset_Squares_z * H * nmbSubdomainsSquares_OneDir;
3071 if ((*this->pointsRep_)[pCounter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[pCounter][0] < (coorRec[0]+eps) ||
3072 (*this->pointsRep_)[pCounter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[pCounter][1] < (coorRec[1]+eps) ||
3073 (*this->pointsRep_)[pCounter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[pCounter][2] < (coorRec[2]+eps) ) {
3075 (*this->bcFlagRep_)[counter] = 1;
3078 (*this->pointsUni_)[pCounter][0] = (*this->pointsRep_)[pCounter][0];
3079 (*this->pointsUni_)[pCounter][1] = (*this->pointsRep_)[pCounter][1];
3080 (*this->pointsUni_)[pCounter][2] = (*this->pointsRep_)[pCounter][2];
3082 (*this->bcFlagUni_)[pCounter] = (*this->bcFlagRep_)[pCounter];
3084 (*elementsVec)[counter][3] = pCounter;
3085 pointsRepGlobMapping[pCounter] = globalCounterPoints;
3086 globalCounterPoints++;
3093 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
3095 this->mapUnique_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
3097 buildElementsClass(elementsVec);
3100 std::cout <<
"done!" << std::endl;
3108 switch (this->dim_) {
3110 switch (flagsOption) {
3114 for (
int i=0; i<this->pointsUni_->size(); i++) {
3115 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)) {
3116 this->bcFlagUni_->at(i) = 3;
3118 if (this->pointsUni_->at(i).at(0) < (coorRec[0] +tol)) {
3119 this->bcFlagUni_->at(i) = 2;
3121 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) && this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) ) {
3122 this->bcFlagUni_->at(i) = 1;
3124 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) && this->pointsUni_->at(i).at(1) > (coorRec[1] + height - tol) ) {
3125 this->bcFlagUni_->at(i) = 1;
3128 for (
int i=0; i<this->pointsRep_->size(); i++) {
3129 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)) {
3130 this->bcFlagRep_->at(i) = 3;
3132 if (this->pointsRep_->at(i).at(0) < (coorRec[0] +tol)) {
3133 this->bcFlagRep_->at(i) = 2;
3135 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) && this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) ) {
3136 this->bcFlagRep_->at(i) = 1;
3138 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) && this->pointsRep_->at(i).at(1) > (coorRec[1] + height - tol) ) {
3139 this->bcFlagRep_->at(i) = 1;
3144 for (
int i=0; i<this->pointsUni_->size(); i++) {
3145 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)) {
3146 this->bcFlagUni_->at(i) = 2;
3148 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)) {
3149 this->bcFlagUni_->at(i) = 1;
3151 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)) {
3152 this->bcFlagUni_->at(i) = 1;
3154 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)) {
3155 this->bcFlagUni_->at(i) = 1;
3157 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)) {
3158 this->bcFlagUni_->at(i) = 3;
3161 for (
int i=0; i<this->pointsRep_->size(); i++) {
3162 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)) {
3163 this->bcFlagRep_->at(i) = 2;
3165 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)) {
3166 this->bcFlagRep_->at(i) = 1;
3168 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)) {
3169 this->bcFlagRep_->at(i) = 1;
3171 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)) {
3172 this->bcFlagRep_->at(i) = 1;
3174 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)) {
3175 this->bcFlagRep_->at(i) = 3;
3180 for (
int i=0; i<this->pointsUni_->size(); i++) {
3181 if (this->pointsUni_->at(i).at(0) < (coorRec[0] +tol)) {
3182 this->bcFlagUni_->at(i) = 2;
3184 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) && this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) ) {
3185 this->bcFlagUni_->at(i) = 1;
3187 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) && this->pointsUni_->at(i).at(1) > (coorRec[1] + height - tol) ) {
3188 this->bcFlagUni_->at(i) = 4;
3190 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)) {
3191 this->bcFlagUni_->at(i) = 3;
3194 for (
int i=0; i<this->pointsRep_->size(); i++) {
3195 if (this->pointsRep_->at(i).at(0) < (coorRec[0] +tol)) {
3196 this->bcFlagRep_->at(i) = 2;
3198 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) && this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) ) {
3199 this->bcFlagRep_->at(i) = 1;
3201 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) && this->pointsRep_->at(i).at(1) > (coorRec[1] + height - tol) ) {
3202 this->bcFlagRep_->at(i) = 4;
3204 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)) {
3205 this->bcFlagRep_->at(i) = 3;
3210 if (FEType ==
"P2") {
3211 this->bcFlagUni_->at(0) = 1;
3212 this->bcFlagUni_->at(1) = 2;
3213 this->bcFlagUni_->at(2) = 2;
3214 this->bcFlagUni_->at(3) = 2;
3215 this->bcFlagUni_->at(4) = 4;
3216 this->bcFlagUni_->at(5) = 3;
3217 this->bcFlagUni_->at(6) = 0;
3218 this->bcFlagUni_->at(7) = 0;
3219 this->bcFlagUni_->at(8) = 0;
3220 this->bcFlagUni_->at(9) = 5;
3221 this->bcFlagUni_->at(10) = 1;
3222 this->bcFlagUni_->at(11) = 2;
3223 this->bcFlagUni_->at(12) = 2;
3224 this->bcFlagUni_->at(13) = 2;
3225 this->bcFlagUni_->at(14) = 4;
3227 this->bcFlagRep_->at(0) = 1;
3228 this->bcFlagRep_->at(1) = 2;
3229 this->bcFlagRep_->at(2) = 2;
3230 this->bcFlagRep_->at(3) = 2;
3231 this->bcFlagRep_->at(4) = 4;
3232 this->bcFlagRep_->at(5) = 3;
3233 this->bcFlagRep_->at(6) = 0;
3234 this->bcFlagRep_->at(7) = 0;
3235 this->bcFlagRep_->at(8) = 0;
3236 this->bcFlagRep_->at(9) = 5;
3237 this->bcFlagRep_->at(10) = 1;
3238 this->bcFlagRep_->at(11) = 2;
3239 this->bcFlagRep_->at(12) = 2;
3240 this->bcFlagRep_->at(13) = 2;
3241 this->bcFlagRep_->at(14) = 4;
3242 }
else if(FEType==
"P1") {
3243 this->bcFlagUni_->at(0) = 1;
3244 this->bcFlagUni_->at(1) = 1;
3245 this->bcFlagUni_->at(2) = 1;
3246 this->bcFlagUni_->at(3) = 2;
3247 this->bcFlagUni_->at(4) = 2;
3248 this->bcFlagUni_->at(5) = 1;
3250 this->bcFlagRep_->at(0) = 1;
3251 this->bcFlagRep_->at(1) = 1;
3252 this->bcFlagRep_->at(2) = 1;
3253 this->bcFlagRep_->at(3) = 2;
3254 this->bcFlagRep_->at(4) = 2;
3255 this->bcFlagRep_->at(5) = 1;
3259 for (
int i=0; i<this->pointsUni_->size(); i++) {
3260 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) && this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) ) {
3261 this->bcFlagUni_->at(i) = 1;
3263 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)) {
3264 this->bcFlagUni_->at(i) = 1;
3266 if (this->pointsUni_->at(i).at(0) < (coorRec[0] +tol)) {
3267 this->bcFlagUni_->at(i) = 1;
3269 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) && this->pointsUni_->at(i).at(1) > (coorRec[1] + height - tol) ) {
3270 this->bcFlagUni_->at(i) = 2;
3272 if (this->pointsUni_->at(i).at(0) < (coorRec[0] +tol) && this->pointsUni_->at(i).at(1) < (coorRec[1] +tol)) {
3273 this->bcFlagUni_->at(i) = 3;
3276 for (
int i=0; i<this->pointsRep_->size(); i++) {
3277 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) && this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) ) {
3278 this->bcFlagRep_->at(i) = 1;
3280 if (this->pointsRep_->at(i).at(0) > (coorRec[0]+length - tol) && this->pointsRep_->at(i).at(1) > (coorRec[1] + tol) && this->pointsRep_->at(i).at(1) < (coorRec[1] + height - tol)) {
3281 this->bcFlagRep_->at(i) = 1;
3283 if (this->pointsRep_->at(i).at(0) < (coorRec[0] +tol)) {
3284 this->bcFlagRep_->at(i) = 1;
3286 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) && this->pointsRep_->at(i).at(1) > (coorRec[1] + height - tol) ) {
3287 this->bcFlagRep_->at(i) = 2;
3289 if (this->pointsRep_->at(i).at(0) < (coorRec[0] +tol) && this->pointsRep_->at(i).at(1) < (coorRec[1] +tol)) {
3290 this->bcFlagRep_->at(i) = 3;
3299 switch (flagsOption) {
3303 for (
int i=0; i<this->pointsUni_->size(); i++) {
3304 if (this->pointsUni_->at(i).at(0) < (coorRec[0] + tol) ) {
3305 this->bcFlagUni_->at(i) = 2;
3308 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + length - tol) &&
3309 this->pointsUni_->at(i).at(1) > (coorRec[1] + tol) &&
3310 this->pointsUni_->at(i).at(1) < (coorRec[1] + width - tol)&&
3311 this->pointsUni_->at(i).at(2) > (coorRec[2] + tol) &&
3312 this->pointsUni_->at(i).at(2) < (coorRec[2] + height - tol)) {
3313 this->bcFlagUni_->at(i) = 3;
3316 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) &&
3317 this->pointsUni_->at(i).at(2) < (coorRec[2] + tol) ) {
3318 this->bcFlagUni_->at(i) = 1;
3321 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) &&
3322 this->pointsUni_->at(i).at(2) > (coorRec[2] + height - tol) ) {
3323 this->bcFlagUni_->at(i) = 1;
3326 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) &&
3327 this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) ) {
3328 this->bcFlagUni_->at(i) = 1;
3331 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) &&
3332 this->pointsUni_->at(i).at(1) > (coorRec[1] + width - tol) ) {
3333 this->bcFlagUni_->at(i) = 1;
3336 for (
int i=0; i<this->pointsUni_->size(); i++) {
3337 if (this->pointsRep_->at(i).at(0) < (coorRec[0] + tol) ) {
3338 this->bcFlagRep_->at(i) = 2;
3341 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + length - tol) &&
3342 this->pointsRep_->at(i).at(1) > (coorRec[1] + tol) &&
3343 this->pointsRep_->at(i).at(1) < (coorRec[1] + width - tol)&&
3344 this->pointsRep_->at(i).at(2) > (coorRec[2] + tol) &&
3345 this->pointsRep_->at(i).at(2) < (coorRec[2] + height - tol)) {
3346 this->bcFlagRep_->at(i) = 3;
3349 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) &&
3350 this->pointsRep_->at(i).at(2) < (coorRec[2] + tol) ) {
3351 this->bcFlagRep_->at(i) = 1;
3354 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) &&
3355 this->pointsRep_->at(i).at(2) > (coorRec[2] + height - tol) ) {
3356 this->bcFlagRep_->at(i) = 1;
3359 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) &&
3360 this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) ) {
3361 this->bcFlagRep_->at(i) = 1;
3364 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) &&
3365 this->pointsRep_->at(i).at(1) > (coorRec[1] + width - tol) ) {
3366 this->bcFlagRep_->at(i) = 1;
3371 for (
int i=0; i<this->pointsUni_->size(); i++) {
3372 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)
3373 && this->pointsUni_->at(i).at(2) > (coorRec[2]+1. -tol) && this->pointsUni_->at(i).at(1) < (coorRec[2]+ height +tol)) {
3374 this->bcFlagUni_->at(i) = 2;
3377 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)) {
3378 this->bcFlagUni_->at(i) = 1;
3381 if (this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) || this->pointsUni_->at(i).at(1) > (coorRec[1]+width - tol)) {
3382 this->bcFlagUni_->at(i) = 1;
3385 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)) {
3386 this->bcFlagUni_->at(i) = 1;
3388 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)
3389 && this->pointsUni_->at(i).at(2) > (coorRec[2] + tol) && this->pointsUni_->at(i).at(2) < (coorRec[2] + height - tol)) {
3390 this->bcFlagUni_->at(i) = 3;
3393 for (
int i=0; i<this->pointsRep_->size(); i++) {
3394 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)
3395 && this->pointsRep_->at(i).at(2) > (coorRec[2]+1. -tol) && this->pointsRep_->at(i).at(1) < (coorRec[2]+ height +tol)) {
3396 this->bcFlagRep_->at(i) = 2;
3399 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)) {
3400 this->bcFlagRep_->at(i) = 1;
3403 if (this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) || this->pointsRep_->at(i).at(1) > (coorRec[1]+width - tol)) {
3404 this->bcFlagRep_->at(i) = 1;
3407 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)) {
3408 this->bcFlagRep_->at(i) = 1;
3410 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)
3411 && this->pointsRep_->at(i).at(2) > (coorRec[2] + tol) && this->pointsRep_->at(i).at(2) < (coorRec[2] + height - tol)) {
3412 this->bcFlagRep_->at(i) = 3;
3417 for (
int i=0; i<this->pointsUni_->size(); i++) {
3419 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + tol) &&
3420 this->pointsUni_->at(i).at(2) > (coorRec[2] + height - tol) ) {
3421 this->bcFlagUni_->at(i) = 4;
3424 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + tol) &&
3425 this->pointsUni_->at(i).at(1) > (coorRec[1] + width - tol) ) {
3426 this->bcFlagUni_->at(i) = 5;
3429 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + length - tol) &&
3430 this->pointsUni_->at(i).at(1) > (coorRec[1] + tol) &&
3431 this->pointsUni_->at(i).at(1) < (coorRec[1] + width - tol)&&
3432 this->pointsUni_->at(i).at(2) > (coorRec[2] + tol) &&
3433 this->pointsUni_->at(i).at(2) < (coorRec[2] + height - tol)) {
3434 this->bcFlagUni_->at(i) = 6;
3437 if (this->pointsUni_->at(i).at(0) < (coorRec[0] + tol) ) {
3438 this->bcFlagUni_->at(i) = 1;
3441 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + tol) &&
3442 this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) ) {
3443 this->bcFlagUni_->at(i) = 2;
3446 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + tol) &&
3447 this->pointsUni_->at(i).at(2) < (coorRec[2] + tol) ) {
3448 this->bcFlagUni_->at(i) = 3;
3452 if (this->pointsUni_->at(i).at(0) < (coorRec[0] + tol) &&
3453 this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) )
3454 this->bcFlagUni_->at(i) = 7;
3457 if (this->pointsUni_->at(i).at(0) < (coorRec[0] + tol) &&
3458 this->pointsUni_->at(i).at(2) < (coorRec[2] + tol) )
3459 this->bcFlagUni_->at(i) = 9;
3462 if (this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) &&
3463 this->pointsUni_->at(i).at(2) < (coorRec[2] + tol) )
3464 this->bcFlagUni_->at(i) = 8;
3467 if (this->pointsUni_->at(i).at(0) < (coorRec[0] + tol) &&
3468 this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) &&
3469 this->pointsUni_->at(i).at(2) < (coorRec[2] + tol) )
3470 this->bcFlagUni_->at(i) = 0;
3473 for (
int i=0; i<this->pointsRep_->size(); i++) {
3476 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + tol) &&
3477 this->pointsRep_->at(i).at(2) > (coorRec[2] + height - tol) ) {
3478 this->bcFlagRep_->at(i) = 4;
3482 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + tol) &&
3483 this->pointsRep_->at(i).at(1) > (coorRec[1] + width - tol) ) {
3484 this->bcFlagRep_->at(i) = 5;
3487 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + length - tol) &&
3488 this->pointsRep_->at(i).at(1) > (coorRec[1] + tol) &&
3489 this->pointsRep_->at(i).at(1) < (coorRec[1] + width - tol)&&
3490 this->pointsRep_->at(i).at(2) > (coorRec[2] + tol) &&
3491 this->pointsRep_->at(i).at(2) < (coorRec[2] + height - tol)) {
3492 this->bcFlagRep_->at(i) = 6;
3495 if (this->pointsRep_->at(i).at(0) < (coorRec[0] + tol) ) {
3496 this->bcFlagRep_->at(i) = 1;
3499 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + tol) &&
3500 this->pointsRep_->at(i).at(2) < (coorRec[2] + tol) ) {
3501 this->bcFlagRep_->at(i) = 3;
3504 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + tol) &&
3505 this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) ) {
3506 this->bcFlagRep_->at(i) = 2;
3509 if (this->pointsRep_->at(i).at(0) < (coorRec[0] + tol) &&
3510 this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) )
3511 this->bcFlagRep_->at(i) = 7;
3514 if (this->pointsRep_->at(i).at(0) < (coorRec[0] + tol) &&
3515 this->pointsRep_->at(i).at(2) < (coorRec[2] + tol) )
3516 this->bcFlagRep_->at(i) = 9;
3519 if (this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) &&
3520 this->pointsRep_->at(i).at(2) < (coorRec[2] + tol) )
3521 this->bcFlagRep_->at(i) = 8;
3523 if (this->pointsRep_->at(i).at(0) < (coorRec[0] + tol) &&
3524 this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) &&
3525 this->pointsRep_->at(i).at(2) < (coorRec[2] + tol) )
3526 this->bcFlagRep_->at(i) = 0;
3531 for (
int i=0; i<this->pointsUni_->size(); i++) {
3533 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + tol) &&
3534 this->pointsUni_->at(i).at(2) < (coorRec[2] + tol) ) {
3535 this->bcFlagUni_->at(i) = 4;
3538 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + tol) &&
3539 this->pointsUni_->at(i).at(2) > (coorRec[2] + height - tol) ) {
3540 this->bcFlagUni_->at(i) = 5;
3542 if (this->pointsUni_->at(i).at(0) < (coorRec[0] + tol) ) {
3543 this->bcFlagUni_->at(i) = 6;
3546 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + tol) &&
3547 this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) ) {
3548 this->bcFlagUni_->at(i) = 6;
3551 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + tol) &&
3552 this->pointsUni_->at(i).at(1) > (coorRec[1] + width - tol) ) {
3553 this->bcFlagUni_->at(i) = 6;
3556 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + length - tol) &&
3557 this->pointsUni_->at(i).at(1) > (coorRec[1] + tol) &&
3558 this->pointsUni_->at(i).at(1) < (coorRec[1] + width - tol)&&
3559 this->pointsUni_->at(i).at(2) > (coorRec[2] - tol) &&
3560 this->pointsUni_->at(i).at(2) < (coorRec[2] + height + tol)) {
3561 this->bcFlagUni_->at(i) = 6;
3564 for (
int i=0; i<this->pointsUni_->size(); i++) {
3567 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + tol) &&
3568 this->pointsRep_->at(i).at(2) < (coorRec[2] + tol) ) {
3569 this->bcFlagRep_->at(i) = 4;
3571 if (this->pointsRep_->at(i).at(0) < (coorRec[0] + tol) ) {
3572 this->bcFlagRep_->at(i) = 6;
3575 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + tol) &&
3576 this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) ) {
3577 this->bcFlagRep_->at(i) = 6;
3580 if (this->pointsRep_->at(i).at(0) >= (coorRec[0] + tol) &&
3581 this->pointsRep_->at(i).at(1) > (coorRec[1] + width - tol) ) {
3582 this->bcFlagRep_->at(i) = 6;
3585 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + length - tol) &&
3586 this->pointsRep_->at(i).at(1) > (coorRec[1] + tol) &&
3587 this->pointsRep_->at(i).at(1) < (coorRec[1] + width - tol)&&
3588 this->pointsRep_->at(i).at(2) > (coorRec[2] - tol) &&
3589 this->pointsRep_->at(i).at(2) < (coorRec[2] + height + tol)) {
3590 this->bcFlagRep_->at(i) = 6;
3593 if (this->pointsRep_->at(i).at(2) > (coorRec[2] + height - tol) ) {
3594 this->bcFlagRep_->at(i) = 5;
3599 for (
int i=0; i<this->pointsUni_->size(); i++) {
3600 if (this->pointsUni_->at(i).at(0) < (coorRec[0] + tol) ) {
3601 this->bcFlagUni_->at(i) = 1;
3604 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) &&
3605 this->pointsUni_->at(i).at(2) < (coorRec[2] + tol) ) {
3606 this->bcFlagUni_->at(i) = 1;
3609 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) &&
3610 this->pointsUni_->at(i).at(1) < (coorRec[1] + tol) ) {
3611 this->bcFlagUni_->at(i) = 1;
3614 if (this->pointsUni_->at(i).at(0) > (coorRec[0] - tol) &&
3615 this->pointsUni_->at(i).at(1) > (coorRec[1] + width - tol) ) {
3616 this->bcFlagUni_->at(i) = 1;
3619 if (this->pointsUni_->at(i).at(0) > (coorRec[0] + length - tol) &&
3620 this->pointsUni_->at(i).at(1) > (coorRec[1] + tol) &&
3621 this->pointsUni_->at(i).at(1) < (coorRec[1] + width - tol)&&
3622 this->pointsUni_->at(i).at(2) > (coorRec[2] + tol) &&
3623 this->pointsUni_->at(i).at(2) < (coorRec[2] + height - tol)) {
3624 this->bcFlagUni_->at(i) = 1;
3627 if (this->pointsUni_->at(i).at(2) > (coorRec[2] + height - tol) ) {
3628 this->bcFlagUni_->at(i) = 2;
3630 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)) {
3631 this->bcFlagUni_->at(i) = 3;
3634 for (
int i=0; i<this->pointsUni_->size(); i++) {
3635 if (this->pointsRep_->at(i).at(0) < (coorRec[0] - tol) ) {
3636 this->bcFlagRep_->at(i) = 1;
3639 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) &&
3640 this->pointsRep_->at(i).at(2) < (coorRec[2] + tol) ) {
3641 this->bcFlagRep_->at(i) = 1;
3644 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) &&
3645 this->pointsRep_->at(i).at(2) > (coorRec[2] + height - tol) ) {
3646 this->bcFlagRep_->at(i) = 2;
3649 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) &&
3650 this->pointsRep_->at(i).at(1) < (coorRec[1] + tol) ) {
3651 this->bcFlagRep_->at(i) = 1;
3654 if (this->pointsRep_->at(i).at(0) > (coorRec[0] - tol) &&
3655 this->pointsRep_->at(i).at(1) > (coorRec[1] + width - tol) ) {
3656 this->bcFlagRep_->at(i) = 1;
3659 if (this->pointsRep_->at(i).at(0) > (coorRec[0] + length - tol) &&
3660 this->pointsRep_->at(i).at(1) > (coorRec[1] + tol) &&
3661 this->pointsRep_->at(i).at(1) < (coorRec[1] + width - tol)&&
3662 this->pointsRep_->at(i).at(2) > (coorRec[2] + tol) &&
3663 this->pointsRep_->at(i).at(2) < (coorRec[2] + height - tol)) {
3664 this->bcFlagRep_->at(i) = 1;
3666 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)) {
3667 this->bcFlagRep_->at(i) = 3;
3685 int numProcsCoarseSolve){
3689 using Teuchos::ScalarTraits;
3691 TEUCHOS_TEST_FOR_EXCEPTION(!(M>=1),std::logic_error,
"H/h is to small.");
3692 TEUCHOS_TEST_FOR_EXCEPTION(this->comm_.is_null(),std::runtime_error,
"comm_ is null.");
3694 bool verbose (this->comm_->getRank() == 0);
3697 std::cout <<
"-- Building structured 3D Mesh --" << std::endl;
3700 setRankRange( numProcsCoarseSolve );
3702 SC eps = ScalarTraits<SC>::eps();
3704 int rank = this->comm_->getRank();
3705 int size = this->comm_->getSize() - numProcsCoarseSolve;
3707 SC h = length/(M*N);
3711 std::cout <<
"-- H:"<<H <<
" h:" <<h <<
" --" << std::endl;
3712 std::cout <<
"-- N:"<<N <<
" M:" <<M <<
" --" << std::endl;
3715 LO nmbPoints_oneDir;
3719 if (FEType ==
"P2"){
3720 nmbPoints_oneDir = N * (2*(M+1)-1) - (N-1);
3721 nmbPoints = (2*(M+1)-1)*(2*(M+1)-1)*(2*(M+1)-1) - M*M*M;
3724 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"Wrong FE-Type, 5 element subcube devision only available with P2 discretization.");
3729 std::cout <<
"-- Number of Points in one direction: " << nmbPoints_oneDir <<
" || Number of Points " << nmbPoints <<
" --" << std::endl;
3731 this->FEType_ = FEType;
3733 GO nmbPGlob_oneDir = N * (M+1) - (N-1);
3735 this->numElementsGlob_ = 5*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1)*(nmbPGlob_oneDir-1);
3743 nmbElements = 5*M*M*M;
3745 vec2D_int_ptr_Type elementsVec;
3746 vec_int_ptr_Type elementFlag;
3749 this->pointsRep_.reset(
new vec2D_dbl_Type(nmbPoints, vec_dbl_Type(3, 0.0)));
3750 this->bcFlagRep_.reset(
new vec_int_Type (nmbPoints, 10));
3751 elementsVec = Teuchos::rcp(
new vec2D_int_Type(nmbElements, vec_int_Type(10, -1)));
3752 elementFlag = Teuchos::rcp(
new vec_int_Type( elementsVec->size(),0 ) );
3753 Teuchos::Array<GO> pointsRepGlobMapping(nmbPoints);
3756 int offset_x = (rank % N);
3760 if ((rank % (N*N))>=N) {
3761 offset_y = (int) (rank % (N*N))/(N);
3764 if ((rank % (N*N*N))>=N*N ) {
3765 offset_z = (int) (rank % (N*N*N))/(N*(N));
3769 std::cout <<
"-- Building P2 Points Repeated ... " << std::endl;
3771 std::cout <<
" Offsets on Rank " << rank <<
" || x=" << offset_x <<
" y=" << offset_y <<
" z=" << offset_z << std::endl;
3772 this->comm_->barrier();
3780 for (
int t=0; t < 2*(M+1)-1; t++) {
3781 for (
int s=0; s < 2*(M+1)-1; s++) {
3782 for (
int r=0; r < 2*(M+1)-1; r++) {
3785 if (s%2==0 && r%2==0 && t%2==0) {
3792 (*this->pointsRep_)[counter][0] = r*h/2.0 + offset_x * H;
3793 if ((*this->pointsRep_)[counter][0]<eps && (*this->pointsRep_)[counter][0]>-eps) (*this->pointsRep_)[counter][0]=0.0;
3794 (*this->pointsRep_)[counter][1] = s*h/2.0 + offset_y * H;
3795 if ((*this->pointsRep_)[counter][1]<eps && (*this->pointsRep_)[counter][1]>-eps) (*this->pointsRep_)[counter][1]=0.0;
3796 (*this->pointsRep_)[counter][2] = t*h/2.0 + offset_z * H;
3797 if ((*this->pointsRep_)[counter][2]<eps && (*this->pointsRep_)[counter][2]>-eps) (*this->pointsRep_)[counter][2]=0.0;
3801 if(s%2 == 1 && t%2 == 1 && r%2==0)
3802 offset = M*offset_x +N*M*M*offset_y + N*M*(s-1)/2;
3804 if(s%2 == 0 && t%2==1 ){
3805 offset += M*M*N*offset_y + s/2*M*N;
3809 offset += M*M*N*N * t/2;
3811 offset += M*M*N*N * (t-1)/2;
3814 pointsRepGlobMapping[counter] = r + s*nmbPoints_oneDir + t*nmbPoints_oneDir*nmbPoints_oneDir \
3815 + offset_x*(2*(M+1)-2) + offset_y*(nmbPoints_oneDir)*(2*(M+1)-2) + offset_z*(nmbPoints_oneDir)*(nmbPoints_oneDir)*(2*(M+1)-2) \
3816 -offset_z*(N*N*M*M*M)-nodeSkip-offset;
3818 if ((*this->pointsRep_)[counter][0] > (coorRec[0]+length-eps) || (*this->pointsRep_)[counter][0] < (coorRec[0]+eps) ||
3819 (*this->pointsRep_)[counter][1] > (coorRec[1]+width-eps) || (*this->pointsRep_)[counter][1] < (coorRec[1]+eps) ||
3820 (*this->pointsRep_)[counter][2] > (coorRec[2]+height-eps) || (*this->pointsRep_)[counter][2] < (coorRec[2]+eps) ) {
3821 (*this->bcFlagRep_)[counter] = 1;
3824 if (s%2==1 && r%2==1 && t%2==1) {
3837 int P2M = 2*(M+1)-1;
3839 this->mapRepeated_.reset(
new Map<LO,GO,NO>( (GO) -1, pointsRepGlobMapping(), 0, this->comm_) );
3842 this->mapUnique_ = this->mapRepeated_->buildUniqueMap( numProcsCoarseSolve );
3844 this->pointsUni_.reset(
new std::vector<std::vector<double> >(this->mapUnique_->getNodeNumElements(),std::vector<double>(3,0.0)));
3845 this->bcFlagUni_.reset(
new std::vector<int> (this->mapUnique_->getNodeNumElements(),10));
3848 std::cout <<
"-- Building P2 Points Unique ... " << std::endl;
3851 std::cout <<
"-- Number of repeated points per proc: " << this->mapRepeated_->getNodeNumElements() <<
" ... " << std::endl;
3854 this->comm_->barrier();
3857 this->pointsUni_.reset(
new std::vector<std::vector<double> >( this->mapUnique_->getNodeNumElements(), std::vector<double>(this->dim_,-1. ) ) );
3858 this->bcFlagUni_.reset(
new std::vector<int> ( this->mapUnique_->getNodeNumElements(), 0 ) );
3859 for (
int i=0; i<this->mapUnique_->getNodeNumElements(); i++) {
3860 GO gid = this->mapUnique_->getGlobalElement( i );
3861 LO
id = this->mapRepeated_->getLocalElement( this->mapUnique_->getGlobalElement( i ) );
3862 this->pointsUni_->at(i) = this->pointsRep_->at(
id);
3863 this->bcFlagUni_->at(i) = this->bcFlagRep_->at(
id);
3866 this->comm_->barrier();
3884 std::cout <<
"-- ElementsList ... " << std::endl;
3885 std::cout <<
"-- P2M =" << P2M << std::endl;
3891 for (
int t=0; t < M; t++) {
3892 for (
int s=0; s < M; s++) {
3893 for (
int r=0; r < M; r++) {
3897 int n_0 = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t) -t*M*M;
3898 int n_1 = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t) -t*M*M;
3899 int n_2 = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t) -t*M*M ;
3901 int n_3 = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) -t*M*M;
3902 int n_4 = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) -t*M*M;
3903 int n_5 = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) -t*M*M ;
3905 int n_6 = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) -t*M*M;
3906 int n_7 = 2*(r) +1 + 2*P2M * (s+1) + 2*P2M*P2M * (t) -t*M*M ;
3907 int n_8 = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) -t*M*M;
3910 int n_9 = 2*(r) + 2*P2M * (s) +2*P2M*P2M * (t) +P2M*P2M -s*M -t*M*M;
3911 int n_10 = 2*(r) +1 + 2*P2M * (s) +2*P2M*P2M * (t) +P2M*P2M -s*M -t*M*M;
3912 int n_11 = 2*(r+1) + 2*P2M * (s) +2*P2M*P2M * (t) +P2M*P2M -s*M -t*M*M;
3914 int n_12 = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t) +P2M*P2M -s*M -r -t*M*M;
3916 int n_14 = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t) +P2M*P2M -s*M -(r+1) -t*M*M ;
3918 int n_15 = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M -(s+1)*M -t*M*M ;
3919 int n_16 = 2*(r) +1 + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M -(s+1)*M -t*M*M;
3920 int n_17 = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t) +P2M*P2M -(s+1)*M -t*M*M;
3923 int n_18 = 2*(r) + 2*P2M * (s) + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3924 int n_19 = 2*(r) +1 + 2*P2M * (s) + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3925 int n_20 = 2*(r+1) + 2*P2M * (s) + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3927 int n_21 = 2*(r) + 2*P2M * (s) +P2M + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3928 int n_22 = 2*(r) +1 + 2*P2M * (s) +P2M + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3929 int n_23 = 2*(r+1) + 2*P2M * (s)+P2M + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3931 int n_24 = 2*(r) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3932 int n_25 = 2*(r) +1 + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3933 int n_26 = 2*(r+1) + 2*P2M * (s+1) + 2*P2M*P2M * (t+1) -(t+1)*M*M;
3937 if(((r+M*offset_x)+(s+M*offset_y)+(t+M*offset_z))%2==0){
3938 (*elementsVec)[counter] = {n_2, n_8, n_6, n_26, n_5, n_7, n_4, n_14, n_17, n_16};
3940 (*elementsVec)[counter] = {n_2, n_6, n_0, n_18, n_4, n_3, n_1, n_10, n_12, n_9};
3942 (*elementsVec)[counter] = {n_2, n_18, n_20, n_26, n_10, n_19, n_11, n_14, n_22, n_23};
3944 (*elementsVec)[counter] = {n_6, n_24, n_18, n_26, n_15, n_21, n_12, n_16, n_25, n_22};
3946 (*elementsVec)[counter] = {n_2, n_26, n_6, n_18, n_14, n_16, n_4, n_10, n_22, n_12};
3950 (*elementsVec)[counter] = {n_0, n_24, n_18, n_20, n_12, n_21, n_9, n_10, n_22, n_19};
3952 (*elementsVec)[counter] = {n_2, n_8, n_0, n_20, n_5, n_4, n_1, n_11, n_14, n_10};
3954 (*elementsVec)[counter] = {n_8, n_6, n_0, n_24, n_7, n_3, n_4, n_16, n_15, n_12};
3956 (*elementsVec)[counter] = {n_8, n_24, n_20, n_26, n_16, n_22, n_14, n_17, n_25, n_23};
3958 (*elementsVec)[counter] = {n_8, n_20, n_24, n_0, n_14, n_22, n_16, n_4, n_10, n_12};
3969 std::cout <<
"... done !" << std::endl;
3971 buildElementsClass(elementsVec, elementFlag);
3978 int numNodesTriangle;
3980 switch (this->dim_) {
3985 switch (flagsOption) {
3993 else if(FEType==
"P2")
3999 for(
int T =0; T< this->elementsC_->numberElements(); T++){
4001 vec_int_Type nodeList = this->elementsC_->getElement(T).getVectorNodeList();
4003 vec2D_LO_Type surfaceElements_vec(4,vec_LO_Type(numNodesTriangle));
4015 surfaceElements_vec[0] = {nodeList[1],nodeList[0],nodeList[2]};
4016 surfaceElements_vec[1] = {nodeList[0],nodeList[3],nodeList[2]};
4017 surfaceElements_vec[2] = {nodeList[1],nodeList[2],nodeList[3]};
4018 surfaceElements_vec[3] = {nodeList[1],nodeList[0],nodeList[3]};
4020 else if(FEType==
"P2"){
4021 surfaceElements_vec[0] = {nodeList[1],nodeList[0],nodeList[2],nodeList[4],nodeList[6],nodeList[5]};
4022 surfaceElements_vec[1] = {nodeList[0],nodeList[3],nodeList[2],nodeList[7],nodeList[9],nodeList[6]};
4023 surfaceElements_vec[2] = {nodeList[1],nodeList[2],nodeList[3],nodeList[5],nodeList[9],nodeList[8]};
4024 surfaceElements_vec[3] = {nodeList[1],nodeList[0],nodeList[3],nodeList[4],nodeList[7],nodeList[8]};
4027 for (
int i=0; i<4; i++) {
4029 vec_dbl_Type p1(3),p2(3),v_E(3);
4030 p1[0] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(0) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(0);
4031 p1[1] =this->pointsRep_->at(surfaceElements_vec[i][0]).at(1) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(1);
4032 p1[2] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(2) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(2);
4034 p2[0] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(0) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(0);
4035 p2[1] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(1) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(1);
4036 p2[2] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(2) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(2);
4038 v_E[0] = p1[1]*p2[2] - p1[2]*p2[1];
4039 v_E[1] = p1[2]*p2[0] - p1[0]*p2[2];
4040 v_E[2] = p1[0]*p2[1] - p1[1]*p2[0];
4043 vec_dbl_Type midpoint(3);
4046 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.;
4047 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.;
4048 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.;
4052 if (midpoint.at(0) < (coorRec[0] + tol) ) {
4055 flipSurface(surfaceElements_vec[i]);
4058 p1[0] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(0) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(0);
4059 p1[1] =this->pointsRep_->at(surfaceElements_vec[i][0]).at(1) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(1);
4060 p1[2] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(2) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(2);
4062 p2[0] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(0) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(0);
4063 p2[1] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(1) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(1);
4064 p2[2] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(2) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(2);
4066 v_E[0] = p1[1]*p2[2] - p1[2]*p2[1];
4067 v_E[1] = p1[2]*p2[0] - p1[0]*p2[2];
4068 v_E[2] = p1[0]*p2[1] - p1[1]*p2[0];
4072 if ( !this->elementsC_->getElement(T).subElementsInitialized() )
4073 this->elementsC_->getElement(T).initializeSubElements(
"P2", 2 );
4075 this->elementsC_->getElement(T).addSubElement( feSurface );
4082 int numNodesTriangle;
4085 else if(FEType==
"P2")
4088 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"For flag option and discretization no surfaces are available");
4091 for(
int T =0; T< this->elementsC_->numberElements(); T++){
4093 vec_int_Type nodeList = this->elementsC_->getElement(T).getVectorNodeList();
4095 vec2D_LO_Type surfaceElements_vec(4,vec_LO_Type(numNodesTriangle));
4107 surfaceElements_vec[0] = {nodeList[1],nodeList[0],nodeList[2]};
4108 surfaceElements_vec[1] = {nodeList[0],nodeList[3],nodeList[2]};
4109 surfaceElements_vec[2] = {nodeList[1],nodeList[2],nodeList[3]};
4110 surfaceElements_vec[3] = {nodeList[1],nodeList[0],nodeList[3]};
4112 else if(FEType==
"P2"){
4113 surfaceElements_vec[0] = {nodeList[1],nodeList[0],nodeList[2],nodeList[4],nodeList[6],nodeList[5]};
4114 surfaceElements_vec[1] = {nodeList[0],nodeList[3],nodeList[2],nodeList[7],nodeList[9],nodeList[6]};
4115 surfaceElements_vec[2] = {nodeList[1],nodeList[2],nodeList[3],nodeList[5],nodeList[9],nodeList[8]};
4116 surfaceElements_vec[3] = {nodeList[1],nodeList[0],nodeList[3],nodeList[4],nodeList[7],nodeList[8]};
4119 for (
int i=0; i<4; i++) {
4121 vec_dbl_Type p1(3),p2(3),v_E(3);
4122 p1[0] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(0) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(0);
4123 p1[1] =this->pointsRep_->at(surfaceElements_vec[i][0]).at(1) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(1);
4124 p1[2] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(2) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(2);
4126 p2[0] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(0) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(0);
4127 p2[1] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(1) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(1);
4128 p2[2] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(2) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(2);
4130 v_E[0] = p1[1]*p2[2] - p1[2]*p2[1];
4131 v_E[1] = p1[2]*p2[0] - p1[0]*p2[2];
4132 v_E[2] = p1[0]*p2[1] - p1[1]*p2[0];
4135 vec_dbl_Type midpoint(3);
4138 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.;
4139 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.;
4140 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.;
4144 if (midpoint.at(0) < (coorRec[0] + tol) ) {
4147 flipSurface(surfaceElements_vec[i]);
4150 if (midpoint.at(0) > (coorRec[0] + tol) &&
4151 midpoint.at(2) < (coorRec[2] + tol) ) {
4154 flipSurface(surfaceElements_vec[i]);
4157 if (midpoint.at(0) > (coorRec[0] + tol) &&
4158 midpoint.at(2) > (coorRec[2] + height - tol) ) {
4160 flipSurface(surfaceElements_vec[i]);
4164 if (midpoint.at(0) > (coorRec[0] + tol) &&
4165 midpoint.at(1) < (coorRec[1] + tol) ) {
4167 flipSurface(surfaceElements_vec[i]);
4171 if (midpoint.at(0) > (coorRec[0] + tol) &&
4172 midpoint.at(1) > (coorRec[1] + width - tol) ) {
4174 flipSurface(surfaceElements_vec[i]);
4178 if (midpoint.at(0) > (coorRec[0] + length - tol) &&
4179 midpoint.at(1) > (coorRec[1] + tol) &&
4180 midpoint.at(1) < (coorRec[1] + width - tol)&&
4181 midpoint.at(2) > (coorRec[2] + tol) &&
4182 midpoint.at(2) < (coorRec[2] + height - tol)) {
4184 flipSurface(surfaceElements_vec[i]);
4187 p1[0] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(0) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(0);
4188 p1[1] =this->pointsRep_->at(surfaceElements_vec[i][0]).at(1) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(1);
4189 p1[2] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(2) - this->pointsRep_->at(surfaceElements_vec[i][1]).at(2);
4191 p2[0] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(0) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(0);
4192 p2[1] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(1) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(1);
4193 p2[2] = this->pointsRep_->at(surfaceElements_vec[i][0]).at(2) - this->pointsRep_->at(surfaceElements_vec[i][2]).at(2);
4195 v_E[0] = p1[1]*p2[2] - p1[2]*p2[1];
4196 v_E[1] = p1[2]*p2[0] - p1[0]*p2[2];
4197 v_E[2] = p1[0]*p2[1] - p1[1]*p2[0];
4201 if ( !this->elementsC_->getElement(T).subElementsInitialized() )
4202 this->elementsC_->getElement(T).initializeSubElements(
"P2", 2 );
4204 this->elementsC_->getElement(T).addSubElement( feSurface );