28 type (sparse_matrix),
intent(inout) :: spmat
32 integer(kind=kint) :: ndof, ndof2, n_loc, nl, nu, nz, nn,nlag
33 ndof=hecmat%NDOF; ndof2=ndof*ndof
35 n_loc=hecmat%N*ndof+heclagmat%num_lagrange
38 nz=nn*(ndof2+ndof)/2+nu*ndof2 &
39 +heclagmat%numU_lagrange*ndof
44 +(heclagmat%numL_lagrange+heclagmat%numU_lagrange)*ndof
50 if(heclagmat%num_lagrange > 0) print
'(I3,A,4I10,A,2I10)', &
51 hecmw_comm_get_rank(),
' sparse_matrix_init ',hecmat%N,hecmat%NP,n_loc,nz,
' LAG',heclagmat%num_lagrange,spmat%offset
52 nlag = heclagmat%num_lagrange
55 spmat%timelog = hecmat%Iarray(22)
57 call sparse_matrix_para_contact_set_prof(spmat, hecmat, heclagmat)
59 call sparse_matrix_contact_set_prof(spmat, hecmat, heclagmat)
63 subroutine sparse_matrix_contact_set_prof(spMAT, hecMAT, hecLagMAT)
64 type(sparse_matrix),
intent(inout) :: spmat
67 integer(kind=kint) :: ndof, ndof2
68 integer(kind=kint) :: m, i, idof, i0, ii, ls, le, l, j, j0, jdof, jdofs
71 ndof=hecmat%NDOF; ndof2=ndof*ndof
76 i0=spmat%offset+ndof*(i-1)
81 ls=hecmat%indexL(i-1)+1
86 j0=spmat%offset+ndof*(j-1)
109 ls=hecmat%indexU(i-1)+1
113 if (j <= hecmat%N)
then
114 j0=spmat%offset+ndof*(j-1)
116 j0=spmat%conv_ext(ndof*(j-hecmat%N))-ndof
128 if (heclagmat%num_lagrange > 0)
then
129 j0=spmat%offset+ndof*hecmat%N
130 ls=heclagmat%indexU_lagrange(i-1)+1
131 le=heclagmat%indexU_lagrange(i)
133 j=heclagmat%itemU_lagrange(l)
142 if (heclagmat%num_lagrange > 0)
then
143 i0=spmat%offset+ndof*hecmat%N
144 do i=1,heclagmat%num_lagrange
148 ls=heclagmat%indexL_lagrange(i-1)+1
149 le=heclagmat%indexL_lagrange(i)
151 j=heclagmat%itemL_lagrange(l)
152 j0=spmat%offset+ndof*(j-1)
168 if (m-1 < spmat%NZ) spmat%NZ=m-1
169 if (m-1 /= spmat%NZ)
then
171 write(*,*)
'm-1 = ',m-1,
', NZ=',spmat%NZ,
',num_lagrange=',heclagmat%num_lagrange
174 end subroutine sparse_matrix_contact_set_prof
176 subroutine sparse_matrix_para_contact_set_prof(spMAT, hecMAT, hecLagMAT)
177 type(sparse_matrix),
intent(inout) :: spmat
180 integer(kind=kint) :: ndof, ndof2
181 integer(kind=kint) :: m, i, idof, i0, ii, ls, le, l, j, j0, jdof, jdofs
186 write(*,*)
'spMAT%type must be SPARSE_MATRIX_TYPE_COO, only for mumps'
190 ndof=hecmat%NDOF; ndof2=ndof*ndof
194 if(i <= hecmat%N)
then
196 i0=spmat%offset+ndof*(i-1)
200 ls=hecmat%indexL(i-1)+1
204 j0=spmat%offset+ndof*(j-1)
226 ls=hecmat%indexU(i-1)+1
230 if (j <= hecmat%N)
then
231 j0=spmat%offset+ndof*(j-1)
233 j0=spmat%conv_ext(ndof*(j-hecmat%N))-ndof
246 if (heclagmat%num_lagrange > 0)
then
247 j0=spmat%offset+ndof*hecmat%N
248 ls=heclagmat%indexU_lagrange(i-1)+1
249 le=heclagmat%indexU_lagrange(i)
251 j=heclagmat%itemU_lagrange(l)
261 i0 = spmat%conv_ext(ndof*(i-hecmat%N))-ndof
265 ls=hecmat%indexL(i-1)+1
269 if (j <= hecmat%N)
then
270 j0=spmat%offset+ndof*(j-1)
272 j0=spmat%conv_ext(ndof*(j-hecmat%N))-ndof
296 ls=hecmat%indexU(i-1)+1
300 if (j <= hecmat%N)
then
301 j0=spmat%offset+ndof*(j-1)
303 j0=spmat%conv_ext(ndof*(j-hecmat%N))-ndof
317 if (heclagmat%num_lagrange > 0)
then
318 j0=spmat%offset+ndof*hecmat%N
319 ls=heclagmat%indexU_lagrange(i-1)+1
320 le=heclagmat%indexU_lagrange(i)
325 j=heclagmat%itemU_lagrange(l)
338 if (heclagmat%num_lagrange > 0)
then
339 i0=spmat%offset+ndof*hecmat%N
340 do i=1,heclagmat%num_lagrange
342 ls=heclagmat%indexL_lagrange(i-1)+1
343 le=heclagmat%indexL_lagrange(i)
345 j=heclagmat%itemL_lagrange(l)
346 if (j <= hecmat%N)
then
347 j0=spmat%offset+ndof*(j-1)
349 j0=spmat%conv_ext(ndof*(j-hecmat%N))-ndof
364 if (m-1 /= spmat%NZ)
then
366 write(*,*)
'm-1 = ',m-1,
', NZ=',spmat%NZ,
',num_lagrange=',heclagmat%num_lagrange
369 end subroutine sparse_matrix_para_contact_set_prof
372 type(sparse_matrix),
intent(inout) :: spmat
375 integer(kind=kint) :: ndof, ndof2
376 integer(kind=kint) :: m, i, idof, i0, ii, ls, le, l, j, j0, jdof, jdofs
377 integer(kind=kint) :: offset_l, offset_d, offset_u
378 ndof=hecmat%NDOF; ndof2=ndof*ndof
383 i0=spmat%offset+ndof*(i-1)
386 stop
"ERROR: sparse_matrix_contact_set_a"
389 ls=hecmat%indexL(i-1)+1
394 j0=spmat%offset+ndof*(j-1)
398 offset_l=ndof2*(l-1)+ndof*(idof-1)
401 if( spmat%IRN(m)/=ii ) stop
"ERROR: sparse_matrix_contact_set_a"
403 if (spmat%JCN(m)/=j0+jdof) stop
"ERROR: sparse_matrix_contact_set_a"
404 spmat%A(m)=hecmat%AL(offset_l+jdof)
410 offset_d=ndof2*(i-1)+ndof*(idof-1)
414 if( spmat%IRN(m)/=ii ) stop
"ERROR: sparse_matrix_contact_set_a"
416 if (spmat%JCN(m)/=i0+jdof) stop
"ERROR: sparse_matrix_contact_set_a"
417 spmat%A(m)=hecmat%D(offset_d+jdof)
421 ls=hecmat%indexU(i-1)+1
425 if (j <= hecmat%N)
then
426 j0=spmat%offset+ndof*(j-1)
428 j0=spmat%conv_ext(ndof*(j-hecmat%N))-ndof
431 offset_u=ndof2*(l-1)+ndof*(idof-1)
434 if( spmat%IRN(m)/=ii ) stop
"ERROR: sparse_matrix_contact_set_a"
436 if (spmat%JCN(m)/=j0+jdof) stop
"ERROR: sparse_matrix_contact_set_a"
437 spmat%A(m)=hecmat%AU(offset_u+jdof)
442 if (heclagmat%num_lagrange > 0)
then
443 j0=spmat%offset+ndof*hecmat%N
444 ls=heclagmat%indexU_lagrange(i-1)+1
445 le=heclagmat%indexU_lagrange(i)
448 if( spmat%IRN(m)/=ii ) stop
"ERROR: sparse_matrix_contact_set_a"
450 if (spmat%JCN(m)/=j0+heclagmat%itemU_lagrange(l)) &
451 stop
"ERROR: sparse_matrix_contact_set_a"
452 spmat%A(m)=heclagmat%AU_lagrange((l-1)*ndof+idof)
459 if (heclagmat%num_lagrange > 0)
then
460 i0=spmat%offset+ndof*hecmat%N
461 do i=1,heclagmat%num_lagrange
465 ls=heclagmat%indexL_lagrange(i-1)+1
466 le=heclagmat%indexL_lagrange(i)
468 j=heclagmat%itemL_lagrange(l)
469 j0=spmat%offset+ndof*(j-1)
472 if( spmat%IRN(m)/=ii ) stop
"ERROR: sparse_matrix_contact_set_a"
474 if (spmat%JCN(m)/=j0+jdof) &
475 stop
"ERROR: sparse_matrix_contact_set_a"
476 spmat%A(m)=heclagmat%AL_lagrange((l-1)*ndof+jdof)
490 stop
"ERROR: sparse_matrix_contact_set_a"
491 if (m-1 /= spmat%NZ) stop
"ERROR: sparse_matrix_contact_set_a"
495 type(sparse_matrix),
intent(inout) :: spmat
499 integer(kind=kint) :: ndof, ndof2
500 integer(kind=kint) :: m, i, idof, i0, ii, ls, le, l, j, j0, jdof, jdofs
501 integer(kind=kint) :: offset_l, offset_d, offset_u
505 write(*,*)
'spMAT%type must be SPARSE_MATRIX_TYPE_COO, only for mumps'
509 ndof=hecmat%NDOF; ndof2=ndof*ndof
513 if(i <= hecmat%N)
then
514 i0=spmat%offset+ndof*(i-1)
519 ls=hecmat%indexL(i-1)+1
523 if (j > hecmat%N) stop
'j > hecMAT%N'
524 j0=spmat%offset+ndof*(j-1)
525 offset_l=ndof2*(l-1)+ndof*(idof-1)
528 stop
"ERROR: sparse_matrix_contact_set_a"
529 if (spmat%JCN(m)/=j0+jdof) &
530 stop
"ERROR: sparse_matrix_contact_set_a"
531 spmat%A(m)=hecmat%AL(offset_l+jdof) + conmat%AL(offset_l+jdof)
538 offset_d=ndof2*(i-1)+ndof*(idof-1)
542 stop
"ERROR: sparse_matrix_contact_set_a"
543 if (spmat%JCN(m)/=i0+jdof) &
544 stop
"ERROR: sparse_matrix_contact_set_a"
546 spmat%A(m)=hecmat%D(offset_d+jdof) + conmat%D(offset_d+jdof)
551 ls=hecmat%indexU(i-1)+1
555 if (j <= hecmat%N)
then
556 j0=spmat%offset+ndof*(j-1)
558 j0=spmat%conv_ext(ndof*(j-hecmat%N))-ndof
561 offset_u=ndof2*(l-1)+ndof*(idof-1)
564 stop
"ERROR: sparse_matrix_contact_set_a"
565 if (spmat%JCN(m)/=j0+jdof) &
566 stop
"ERROR: sparse_matrix_contact_set_a"
567 spmat%A(m)=hecmat%AU(offset_u+jdof) + conmat%AU(offset_u+jdof)
573 if (heclagmat%num_lagrange > 0)
then
574 j0=spmat%offset+ndof*hecmat%N
575 ls=heclagmat%indexU_lagrange(i-1)+1
576 le=heclagmat%indexU_lagrange(i)
579 stop
"ERROR: sparse_matrix_contact_set_a"
580 if (spmat%JCN(m)/=j0+heclagmat%itemU_lagrange(l)) &
581 stop
"ERROR: sparse_matrix_contact_set_a"
582 spmat%A(m)=heclagmat%AU_lagrange((l-1)*ndof+idof)
590 i0 = spmat%conv_ext(ndof*(i-hecmat%N))-ndof
594 ls=hecmat%indexL(i-1)+1
598 if (j <= hecmat%N)
then
599 j0=spmat%offset+ndof*(j-1)
601 j0=spmat%conv_ext(ndof*(j-hecmat%N))-ndof
604 offset_l=ndof2*(l-1)+ndof*(idof-1)
609 stop
"ERROR: sparse_matrix_contact_set_a"
610 if (spmat%JCN(m)/=j0+jdof) &
611 stop
"ERROR: sparse_matrix_contact_set_a"
612 spmat%A(m) = conmat%AL(offset_l+jdof)
619 offset_d=ndof2*(i-1)+ndof*(idof-1)
623 stop
"ERROR: sparse_matrix_contact_set_a"
624 if (spmat%JCN(m)/=i0+jdof) &
625 stop
"ERROR: sparse_matrix_contact_set_a"
628 spmat%A(m) = conmat%D(offset_d+jdof)
634 ls=hecmat%indexU(i-1)+1
638 if (j <= hecmat%N)
then
639 j0=spmat%offset+ndof*(j-1)
641 j0=spmat%conv_ext(ndof*(j-hecmat%N))-ndof
644 offset_u=ndof2*(l-1)+ndof*(idof-1)
647 stop
"ERROR: sparse_matrix_contact_set_a"
648 if (spmat%JCN(m)/=j0+jdof) stop
"ERROR: sparse_matrix_contact_set_a"
649 spmat%A(m) = conmat%AU(offset_u+jdof)
656 if (heclagmat%num_lagrange > 0)
then
657 j0=spmat%offset+ndof*hecmat%N
658 ls=heclagmat%indexU_lagrange(i-1)+1
659 le=heclagmat%indexU_lagrange(i)
665 stop
"ERROR: sparse_matrix_contact_set_a"
666 if (spmat%JCN(m)/=j0+heclagmat%itemU_lagrange(l)) &
667 stop
"ERROR: sparse_matrix_contact_set_a"
668 spmat%A(m)=heclagmat%AU_lagrange((l-1)*ndof+idof)
679 if (heclagmat%num_lagrange > 0)
then
680 i0=spmat%offset+ndof*hecmat%N
681 do i=1,heclagmat%num_lagrange
683 ls=heclagmat%indexL_lagrange(i-1)+1
684 le=heclagmat%indexL_lagrange(i)
686 j=heclagmat%itemL_lagrange(l)
687 if (j <= hecmat%N)
then
688 j0=spmat%offset+ndof*(j-1)
690 j0=spmat%conv_ext(ndof*(j-hecmat%N))-ndof
695 stop
"ERROR: sparse_matrix_contact_set_a"
696 if (spmat%JCN(m)/=j0+jdof) &
697 stop
"ERROR: sparse_matrix_contact_set_a"
698 spmat%A(m)=heclagmat%AL_lagrange((l-1)*ndof+jdof)
707 if(spmat%IRN(ii+1-spmat%offset)/=m) &
708 stop
"ERROR: sparse_matrix_contact_set_a"
710 if (m-1 /= spmat%NZ)
then
712 write(*,*)
'm-1 = ',m-1,
', NZ=',spmat%NZ,
',num_lagrange=',heclagmat%num_lagrange
719 type (sparse_matrix),
intent(inout) :: spmat
722 integer :: nndof,npndof,ierr,i
723 allocate(spmat%rhs(spmat%N_loc), stat=ierr)
725 write(*,*)
" Allocation error, spMAT%rhs"
728 nndof=hecmat%N*hecmat%ndof
729 npndof=hecmat%NP*hecmat%ndof
731 spmat%rhs(i) = hecmat%b(i)
734 if (heclagmat%num_lagrange > 0)
then
735 do i=1,heclagmat%num_lagrange
736 spmat%rhs(nndof+i) = hecmat%b(npndof+i)
743 type (sparse_matrix),
intent(inout) :: spmat
747 integer :: nndof,npndof,ierr,ndof,i,i0,j
748 real(kind=
kreal),
allocatable :: rhs_con(:), rhs_con_sum(:)
751 allocate(rhs_con(spmat%N),stat=ierr)
754 do i= hecmat%N+1,hecmat%NP
755 i0=spmat%conv_ext(ndof*(i-hecmat%N))-ndof
756 if((i0 < 0.or.i0 > spmat%N))
then
758 if(conmat%b((i-1)*ndof+j) /= 0.0d0)
then
764 if(i0 > spmat%N - ndof)
then
768 if(conmat%b((i-1)*ndof+j) /= 0.0d0)
then
769 rhs_con(i0+j) = conmat%b((i-1)*ndof+j)
774 allocate(rhs_con_sum(spmat%N))
778 allocate(spmat%rhs(spmat%N_loc), stat=ierr)
780 write(*,*)
" Allocation error, spMAT%rhs"
783 nndof=hecmat%N*hecmat%ndof
784 npndof=hecmat%NP*hecmat%ndof
786 spmat%rhs(i) = rhs_con_sum(spmat%offset+i) + hecmat%b(i) + conmat%b(i)
788 deallocate(rhs_con_sum)
789 if (heclagmat%num_lagrange > 0)
then
790 do i=1,heclagmat%num_lagrange
791 spmat%rhs(nndof+i) = conmat%b(npndof+i)
798 type (sparse_matrix),
intent(inout) :: spmat
801 integer :: nndof,npndof,i
802 nndof=hecmat%N*hecmat%ndof
803 npndof=hecmat%NP*hecmat%ndof
805 hecmat%x(i) = spmat%rhs(i)
808 if (heclagmat%num_lagrange > 0)
then
809 do i=1,heclagmat%num_lagrange
810 hecmat%x(npndof+i) = spmat%rhs(nndof+i)
813 deallocate(spmat%rhs)