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)
483 if (
associated(heclagmat%D_lagrange))
then
484 spmat%A(m) = heclagmat%D_lagrange(i)
494 stop
"ERROR: sparse_matrix_contact_set_a"
495 if (m-1 /= spmat%NZ) stop
"ERROR: sparse_matrix_contact_set_a"
499 type(sparse_matrix),
intent(inout) :: spmat
503 integer(kind=kint) :: ndof, ndof2
504 integer(kind=kint) :: m, i, idof, i0, ii, ls, le, l, j, j0, jdof, jdofs
505 integer(kind=kint) :: offset_l, offset_d, offset_u
509 write(*,*)
'spMAT%type must be SPARSE_MATRIX_TYPE_COO, only for mumps'
513 ndof=hecmat%NDOF; ndof2=ndof*ndof
517 if(i <= hecmat%N)
then
518 i0=spmat%offset+ndof*(i-1)
523 ls=hecmat%indexL(i-1)+1
527 if (j > hecmat%N) stop
'j > hecMAT%N'
528 j0=spmat%offset+ndof*(j-1)
529 offset_l=ndof2*(l-1)+ndof*(idof-1)
532 stop
"ERROR: sparse_matrix_contact_set_a"
533 if (spmat%JCN(m)/=j0+jdof) &
534 stop
"ERROR: sparse_matrix_contact_set_a"
535 spmat%A(m)=hecmat%AL(offset_l+jdof) + conmat%AL(offset_l+jdof)
542 offset_d=ndof2*(i-1)+ndof*(idof-1)
546 stop
"ERROR: sparse_matrix_contact_set_a"
547 if (spmat%JCN(m)/=i0+jdof) &
548 stop
"ERROR: sparse_matrix_contact_set_a"
550 spmat%A(m)=hecmat%D(offset_d+jdof) + conmat%D(offset_d+jdof)
555 ls=hecmat%indexU(i-1)+1
559 if (j <= hecmat%N)
then
560 j0=spmat%offset+ndof*(j-1)
562 j0=spmat%conv_ext(ndof*(j-hecmat%N))-ndof
565 offset_u=ndof2*(l-1)+ndof*(idof-1)
568 stop
"ERROR: sparse_matrix_contact_set_a"
569 if (spmat%JCN(m)/=j0+jdof) &
570 stop
"ERROR: sparse_matrix_contact_set_a"
571 spmat%A(m)=hecmat%AU(offset_u+jdof) + conmat%AU(offset_u+jdof)
577 if (heclagmat%num_lagrange > 0)
then
578 j0=spmat%offset+ndof*hecmat%N
579 ls=heclagmat%indexU_lagrange(i-1)+1
580 le=heclagmat%indexU_lagrange(i)
583 stop
"ERROR: sparse_matrix_contact_set_a"
584 if (spmat%JCN(m)/=j0+heclagmat%itemU_lagrange(l)) &
585 stop
"ERROR: sparse_matrix_contact_set_a"
586 spmat%A(m)=heclagmat%AU_lagrange((l-1)*ndof+idof)
594 i0 = spmat%conv_ext(ndof*(i-hecmat%N))-ndof
598 ls=hecmat%indexL(i-1)+1
602 if (j <= hecmat%N)
then
603 j0=spmat%offset+ndof*(j-1)
605 j0=spmat%conv_ext(ndof*(j-hecmat%N))-ndof
608 offset_l=ndof2*(l-1)+ndof*(idof-1)
613 stop
"ERROR: sparse_matrix_contact_set_a"
614 if (spmat%JCN(m)/=j0+jdof) &
615 stop
"ERROR: sparse_matrix_contact_set_a"
616 spmat%A(m) = conmat%AL(offset_l+jdof)
623 offset_d=ndof2*(i-1)+ndof*(idof-1)
627 stop
"ERROR: sparse_matrix_contact_set_a"
628 if (spmat%JCN(m)/=i0+jdof) &
629 stop
"ERROR: sparse_matrix_contact_set_a"
632 spmat%A(m) = conmat%D(offset_d+jdof)
638 ls=hecmat%indexU(i-1)+1
642 if (j <= hecmat%N)
then
643 j0=spmat%offset+ndof*(j-1)
645 j0=spmat%conv_ext(ndof*(j-hecmat%N))-ndof
648 offset_u=ndof2*(l-1)+ndof*(idof-1)
651 stop
"ERROR: sparse_matrix_contact_set_a"
652 if (spmat%JCN(m)/=j0+jdof) stop
"ERROR: sparse_matrix_contact_set_a"
653 spmat%A(m) = conmat%AU(offset_u+jdof)
660 if (heclagmat%num_lagrange > 0)
then
661 j0=spmat%offset+ndof*hecmat%N
662 ls=heclagmat%indexU_lagrange(i-1)+1
663 le=heclagmat%indexU_lagrange(i)
669 stop
"ERROR: sparse_matrix_contact_set_a"
670 if (spmat%JCN(m)/=j0+heclagmat%itemU_lagrange(l)) &
671 stop
"ERROR: sparse_matrix_contact_set_a"
672 spmat%A(m)=heclagmat%AU_lagrange((l-1)*ndof+idof)
683 if (heclagmat%num_lagrange > 0)
then
684 i0=spmat%offset+ndof*hecmat%N
685 do i=1,heclagmat%num_lagrange
687 ls=heclagmat%indexL_lagrange(i-1)+1
688 le=heclagmat%indexL_lagrange(i)
690 j=heclagmat%itemL_lagrange(l)
691 if (j <= hecmat%N)
then
692 j0=spmat%offset+ndof*(j-1)
694 j0=spmat%conv_ext(ndof*(j-hecmat%N))-ndof
699 stop
"ERROR: sparse_matrix_contact_set_a"
700 if (spmat%JCN(m)/=j0+jdof) &
701 stop
"ERROR: sparse_matrix_contact_set_a"
702 spmat%A(m)=heclagmat%AL_lagrange((l-1)*ndof+jdof)
711 if(spmat%IRN(ii+1-spmat%offset)/=m) &
712 stop
"ERROR: sparse_matrix_contact_set_a"
714 if (m-1 /= spmat%NZ)
then
716 write(*,*)
'm-1 = ',m-1,
', NZ=',spmat%NZ,
',num_lagrange=',heclagmat%num_lagrange
723 type (sparse_matrix),
intent(inout) :: spmat
726 integer :: nndof,npndof,ierr,i
727 allocate(spmat%rhs(spmat%N_loc), stat=ierr)
729 write(*,*)
" Allocation error, spMAT%rhs"
732 nndof=hecmat%N*hecmat%ndof
733 npndof=hecmat%NP*hecmat%ndof
735 spmat%rhs(i) = hecmat%b(i)
738 if (heclagmat%num_lagrange > 0)
then
739 do i=1,heclagmat%num_lagrange
740 spmat%rhs(nndof+i) = hecmat%b(npndof+i)
747 type (sparse_matrix),
intent(inout) :: spmat
751 integer :: nndof,npndof,ierr,ndof,i,i0,j
752 real(kind=
kreal),
allocatable :: rhs_con(:), rhs_con_sum(:)
755 allocate(rhs_con(spmat%N),stat=ierr)
758 do i= hecmat%N+1,hecmat%NP
759 i0=spmat%conv_ext(ndof*(i-hecmat%N))-ndof
760 if((i0 < 0.or.i0 > spmat%N))
then
762 if(conmat%b((i-1)*ndof+j) /= 0.0d0)
then
768 if(i0 > spmat%N - ndof)
then
772 if(conmat%b((i-1)*ndof+j) /= 0.0d0)
then
773 rhs_con(i0+j) = conmat%b((i-1)*ndof+j)
778 allocate(rhs_con_sum(spmat%N))
782 allocate(spmat%rhs(spmat%N_loc), stat=ierr)
784 write(*,*)
" Allocation error, spMAT%rhs"
787 nndof=hecmat%N*hecmat%ndof
788 npndof=hecmat%NP*hecmat%ndof
790 spmat%rhs(i) = rhs_con_sum(spmat%offset+i) + hecmat%b(i) + conmat%b(i)
792 deallocate(rhs_con_sum)
793 if (heclagmat%num_lagrange > 0)
then
794 do i=1,heclagmat%num_lagrange
795 spmat%rhs(nndof+i) = conmat%b(npndof+i)
802 type (sparse_matrix),
intent(inout) :: spmat
805 integer :: nndof,npndof,i
806 nndof=hecmat%N*hecmat%ndof
807 npndof=hecmat%NP*hecmat%ndof
809 hecmat%x(i) = spmat%rhs(i)
812 if (heclagmat%num_lagrange > 0)
then
813 do i=1,heclagmat%num_lagrange
814 hecmat%x(npndof+i) = spmat%rhs(nndof+i)
817 deallocate(spmat%rhs)
integer(kind=kint), parameter hecmw_sum
integer(kind=kint) function hecmw_comm_get_size()
integer(kind=kint) function hecmw_comm_get_comm()
integer(kind=4), parameter kreal
integer(kind=kint) function hecmw_comm_get_rank()
subroutine hecmw_abort(comm)
subroutine hecmw_allreduce_i1(hecMESH, s, ntag)
subroutine hecmw_allreduce_dp(val, VALM, n, hec_op, comm)
This module provides conversion routines between HEC data structure and DOF based sparse matrix struc...
subroutine, public sparse_matrix_hec_set_conv_ext(spMAT, hecMESH, ndof)
This module provides DOF based sparse matrix data structure (CSR and COO)
subroutine, public sparse_matrix_init(spMAT, N_loc, NZ)
logical function, public sparse_matrix_is_sym(spMAT)
integer(kind=kint), parameter, public sparse_matrix_type_coo
integer(kind=kint), parameter, public sparse_matrix_type_csr
Structure for Lagrange multiplier-related part of stiffness matrix (Lagrange multiplier-related matri...