466
469
470 class(ConnectionsType) :: this
471 character(len=*), intent(in) :: name_model
472 integer(I4B), intent(in) :: nodes
473 integer(I4B), intent(in) :: ncol
474 integer(I4B), intent(in) :: nrow
475 integer(I4B), intent(in) :: nlay
476 integer(I4B), intent(in) :: nrsize
477 real(DP), dimension(ncol), intent(in) :: delr
478 real(DP), dimension(nrow), intent(in) :: delc
479 real(DP), dimension(nodes), intent(in) :: top
480 real(DP), dimension(nodes), intent(in) :: bot
481 integer(I4B), dimension(:), target, intent(in) :: nodereduced
482 integer(I4B), dimension(:), intent(in) :: nodeuser
483
484 integer(I4B), dimension(:, :, :), pointer :: nrdcd_ptr => null()
485 integer(I4B), dimension(:), allocatable :: rowmaxnnz
486 type(sparsematrix) :: sparse
487 integer(I4B) :: i, j, k, kk, ierror, isympos, nodesuser
488 integer(I4B) :: nr, mr
489
490
491 call this%allocate_scalars(name_model)
492
493
494 this%nodes = nodes
495 this%ianglex = 1
496
497
498 allocate (rowmaxnnz(this%nodes))
499 do i = 1, this%nodes
500 rowmaxnnz(i) = 6
501 end do
502 call sparse%init(this%nodes, this%nodes, rowmaxnnz)
503
504
505 if (nrsize /= 0) then
506 nrdcd_ptr(1:ncol, 1:nrow, 1:nlay) => nodereduced
507 end if
508
509
510 do k = 1, nlay
511 do i = 1, nrow
512 do j = 1, ncol
513
514
515
516 if (nrsize == 0) then
517 nr = get_node(k, i, j, nlay, nrow, ncol)
518 else
519 nr = nrdcd_ptr(j, i, k)
520 end if
521 if (nr <= 0) cycle
522
523
524 call sparse%addconnection(nr, nr, 1)
525
526
527 if (k > 1) then
528 do kk = k - 1, 1, -1
529 if (nrsize == 0) then
530 mr = get_node(kk, i, j, nlay, nrow, ncol)
531 else
532 mr = nrdcd_ptr(j, i, kk)
533 end if
534 if (mr >= 0) exit
535 end do
536 if (mr > 0) then
537 call sparse%addconnection(nr, mr, 1)
538 end if
539 end if
540
541
542 if (i > 1) then
543 if (nrsize == 0) then
544 mr = get_node(k, i - 1, j, nlay, nrow, ncol)
545 else
546 mr = nrdcd_ptr(j, i - 1, k)
547 end if
548 if (mr > 0) then
549 call sparse%addconnection(nr, mr, 1)
550 end if
551 end if
552
553
554 if (j > 1) then
555 if (nrsize == 0) then
556 mr = get_node(k, i, j - 1, nlay, nrow, ncol)
557 else
558 mr = nrdcd_ptr(j - 1, i, k)
559 end if
560 if (mr > 0) then
561 call sparse%addconnection(nr, mr, 1)
562 end if
563 end if
564
565
566 if (j < ncol) then
567 if (nrsize == 0) then
568 mr = get_node(k, i, j + 1, nlay, nrow, ncol)
569 else
570 mr = nrdcd_ptr(j + 1, i, k)
571 end if
572 if (mr > 0) then
573 call sparse%addconnection(nr, mr, 1)
574 end if
575 end if
576
577
578 if (i < nrow) then
579 if (nrsize == 0) then
580 mr = get_node(k, i + 1, j, nlay, nrow, ncol)
581 else
582 mr = nrdcd_ptr(j, i + 1, k)
583 end if
584 if (mr > 0) then
585 call sparse%addconnection(nr, mr, 1)
586 end if
587 end if
588
589
590 if (k < nlay) then
591 do kk = k + 1, nlay
592 if (nrsize == 0) then
593 mr = get_node(kk, i, j, nlay, nrow, ncol)
594 else
595 mr = nrdcd_ptr(j, i, kk)
596 end if
597 if (mr >= 0) exit
598 end do
599 if (mr > 0) then
600 call sparse%addconnection(nr, mr, 1)
601 end if
602 end if
603 end do
604 end do
605 end do
606 this%nja = sparse%nnz
607 this%njas = (this%nja - this%nodes) / 2
608
609
610 call this%allocate_arrays()
611
612
613 call sparse%filliaja(this%ia, this%ja, ierror)
614 call sparse%destroy()
615
616
617 call fillisym(this%nodes, this%nja, this%ia, this%ja, this%isym)
618 call filljas(this%nodes, this%nja, this%ia, this%ja, this%isym, this%jas)
619
620
621 isympos = 1
622 do k = 1, nlay
623 do i = 1, nrow
624 do j = 1, ncol
625
626
627 if (nrsize == 0) then
628 nr = get_node(k, i, j, nlay, nrow, ncol)
629 else
630 nr = nrdcd_ptr(j, i, k)
631 end if
632 if (nr <= 0) cycle
633
634
635 if (j < ncol) then
636 if (nrsize == 0) then
637 mr = get_node(k, i, j + 1, nlay, nrow, ncol)
638 else
639 mr = nrdcd_ptr(j + 1, i, k)
640 end if
641 if (mr > 0) then
642 this%ihc(isympos) = 1
643 this%cl1(isympos) =
dhalf * delr(j)
644 this%cl2(isympos) =
dhalf * delr(j + 1)
645 this%hwva(isympos) = delc(i)
646 this%anglex(isympos) =
dzero
647 isympos = isympos + 1
648 end if
649 end if
650
651
652 if (i < nrow) then
653 if (nrsize == 0) then
654 mr = get_node(k, i + 1, j, nlay, nrow, ncol)
655 else
656 mr = nrdcd_ptr(j, i + 1, k)
657 end if
658 if (mr > 0) then
659 this%ihc(isympos) = 1
660 this%cl1(isympos) =
dhalf * delc(i)
661 this%cl2(isympos) =
dhalf * delc(i + 1)
662 this%hwva(isympos) = delr(j)
664 isympos = isympos + 1
665 end if
666 end if
667
668
669 if (k < nlay) then
670 do kk = k + 1, nlay
671 if (nrsize == 0) then
672 mr = get_node(kk, i, j, nlay, nrow, ncol)
673 else
674 mr = nrdcd_ptr(j, i, kk)
675 end if
676 if (mr >= 0) exit
677 end do
678 if (mr > 0) then
679 this%ihc(isympos) = 0
680 this%cl1(isympos) =
dhalf * (top(nr) - bot(nr))
681 this%cl2(isympos) =
dhalf * (top(mr) - bot(mr))
682 this%hwva(isympos) = delr(j) * delc(i)
683 this%anglex(isympos) =
dzero
684 isympos = isympos + 1
685 end if
686 end if
687 end do
688 end do
689 end do
690
691
692 deallocate (rowmaxnnz)
693
694
695
696 nodesuser = nlay * nrow * ncol
697 call this%iajausr(nrsize, nodesuser, nodereduced, nodeuser)
real(dp), parameter dpi
real constant
real(dp), parameter dzero
real constant zero
real(dp), parameter dtwo
real constant 2
real(dp), parameter dthree
real constant 3