25 logical,
save :: INITIALIZED = .false.
26 integer,
save :: SymType = 0
41 integer(kind=kint),
save :: PREV_SIG(4) = -1
42 integer(kind=8),
save :: PREV_HASH = 0
43 integer(kind=kint),
save :: PREV_BRANCH = 0
45 integer,
parameter :: DEBUG = 0
46 logical,
parameter :: DEBUG_VECTOR = .false.
47 logical,
parameter :: DEBUG_MATRIX = .false.
55 logical,
intent(in) :: is_sym
63 prev_sig = -1; prev_hash = 0; prev_branch = 0
78 type(hecmwst_ebc),
intent(inout) :: hecebc
79 integer(kind=kint),
intent(out) :: istat
81 logical,
intent(in) :: is_contact_active
83 integer(kind=kint) :: solver_type, method_org
84 integer(kind=kint) :: is_contact
85 integer(kind=kint) :: myrank
92 if (is_contact_active) is_contact = 1
95 if (is_contact == 0)
then
96 if ((debug >= 1 .and. myrank==0) .or. debug >= 2)
write(0,*)
'DEBUG: no contact'
100 if (prev_branch /= 1) hecmat%Iarray(98) = 1
103 if (solver_type == 1 .and. symtype == 1)
then
109 call solve_with_mpc(hecmesh, hecmat, hecebc)
110 if (solver_type == 1 .and. symtype == 1)
then
115 if ((debug >= 1 .and. myrank==0) .or. debug >= 2)
write(0,*)
'DEBUG: with contact'
118 if (prev_branch /= 2) then; prev_sig = -1; prev_hash = 0;
end if
120 call solve_eliminate(hecmesh, hecmat, heclagmat, conmat, hecebc)
126 subroutine solve_with_mpc(hecMESH, hecMAT, hecEBC)
129 type(hecmwst_ebc),
intent(inout) :: hecebc
133 integer(kind=kint) :: method
134 logical :: fg_cg, fg_amg
147 hecmatmpc%Iarray(97:98) = 1
148 hecmatmpc%X(:) = 0.d0
154 end subroutine solve_with_mpc
160 subroutine notify_structure_change(hecMESH, hecTKT)
163 integer(kind=kint) :: sig(4), changed
165 sig = (/ hectkt%N, hectkt%NP, hectkt%NPL, hectkt%NPU /)
166 h = pattern_hash(hectkt)
168 if (any(sig /= prev_sig) .or. h /= prev_hash) changed = 1
170 if (changed /= 0) hectkt%Iarray(98) = 1
171 prev_sig = sig; prev_hash = h
172 end subroutine notify_structure_change
176 function pattern_hash(hecMAT)
result(h)
179 integer(kind=kint) :: i
182 h = ieor(ishftc(h, 5), int(hecmat%indexL(i), 8))
183 h = ieor(ishftc(h, 7), int(hecmat%indexU(i), 8))
186 h = ieor(ishftc(h, 5), int(hecmat%itemL(i), 8))
189 h = ieor(ishftc(h, 7), int(hecmat%itemU(i), 8))
191 end function pattern_hash
195 subroutine solve_eliminate(hecMESH,hecMAT,hecLagMAT,conMAT,hecEBC)
200 type(hecmwst_ebc),
intent(inout) :: hecebc
205 integer(kind=kint),
allocatable :: slaves4lag(:)
206 real(kind=
kreal),
allocatable :: bls_inv(:)
207 real(kind=
kreal),
allocatable :: bus_inv(:)
208 type(hecmwst_local_matrix) :: tmat
209 type(hecmwst_local_matrix) :: ttmat
210 integer(kind=kint),
allocatable :: slaves(:)
211 type(hecmwst_contact_comm) :: concomm
212 type(hecmwst_local_matrix) :: kmat
213 real(kind=
kreal),
allocatable :: btot(:)
215 integer(kind=kint) :: ndof
216 integer(kind=kint) :: myrank
217 real(kind=
kreal) :: t0, t1, t2
221 if ((debug >= 1 .and. myrank==0) .or. debug >= 2)
write(0,*)
'DEBUG: solve_eliminate start'
225 if (debug >= 2)
write(0,*)
' DEBUG2[',myrank,
']: num_lagrange',heclagmat%num_lagrange
227 call copy_mesh(hecmesh, hecmeshtmp)
229 allocate(slaves4lag(heclagmat%num_lagrange), bls_inv(heclagmat%num_lagrange), &
230 bus_inv(heclagmat%num_lagrange))
233 call make_transformation_matrices(hecmesh, hecmeshtmp, hecmat, heclagmat, &
234 slaves4lag, bls_inv, bus_inv, slaves, tmat, ttmat)
236 if ((debug >= 1 .and. myrank==0) .or. debug >= 2)
write(0,*)
'DEBUG: made trans matrices', t2-t1
239 call make_contact_comm_table(hecmesh, hecmat, heclagmat, concomm)
241 if (debug >= 2)
write(0,*)
' DEBUG2: make contact comm_table done',
hecmw_wtime()-t1
244 allocate(btot(hecmat%NP*ndof+heclagmat%num_lagrange))
245 call assemble_equation(hecmesh, hecmeshtmp, hecmat, conmat, heclagmat%num_lagrange, &
248 if ((debug >= 1 .and. myrank==0) .or. debug >= 2)
write(0,*)
'DEBUG: assembled equation ', t2-t1
251 if (kmat%nc /= ttmat%nc)
then
252 if (debug >= 2)
write(0,*)
' DEBUG2[',myrank,
']: node migrated with Kmat',kmat%nc-ttmat%nc
259 call convert_equation(hecmeshtmp, hecmat, kmat, tmat, ttmat, btot, slaves, &
260 slaves4lag, bls_inv, concomm, hectkt)
262 if ((debug >= 1 .and. myrank==0) .or. debug >= 2)
write(0,*)
'DEBUG: converted equation ', t2-t1
266 call notify_structure_change(hecmesh, hectkt)
271 hectkt%symmetric = (symtype == 1)
274 call solve_with_mpc(hecmeshtmp, hectkt, hecebc)
279 if (debug_vector)
call debug_write_vector(hectkt%X,
'Solution(converted)',
'hecTKT%X', ndof, hectkt%N)
281 if ((debug >= 1 .and. myrank==0) .or. debug >= 2)
write(0,*)
'DEBUG: linear solver done ', t2-t1
284 call recover_solution(hecmeshtmp, hecmat, hectkt, tmat, kmat, btot, &
285 slaves4lag, bls_inv, bus_inv, concomm, slaves)
287 if ((debug >= 1 .and. myrank==0) .or. debug >= 2)
write(0,*)
'DEBUG: recovered solution ', t2-t1
289 if (debug >= 1)
call check_solution(hecmesh, hecmeshtmp, hecmat, hectkt, heclagmat, kmat, btot, &
291 if (debug >= 2)
call check_solution2(hecmesh, hecmat, conmat, heclagmat, concomm, slaves)
298 call free_mesh(hecmeshtmp)
299 deallocate(slaves4lag)
301 if ((debug >= 1 .and. myrank==0) .or. debug >= 2)
write(0,*)
'DEBUG: solve_eliminate end', t2-t0
302 end subroutine solve_eliminate
306 subroutine copy_mesh(src, dst)
311 dst%MPI_COMM = src%MPI_COMM
312 dst%PETOT = src%PETOT
313 dst%PEsmpTOT = src%PEsmpTOT
314 dst%my_rank = src%my_rank
315 dst%n_subdomain = src%n_subdomain
316 dst%n_node = src%n_node
317 dst%nn_internal = src%nn_internal
318 dst%n_elem = src%n_elem
319 dst%ne_internal = src%ne_internal
320 dst%n_elem_type = src%n_elem_type
321 dst%n_dof = src%n_dof
322 dst%n_neighbor_pe = src%n_neighbor_pe
323 if (src%n_neighbor_pe > 0)
then
324 allocate(dst%neighbor_pe(dst%n_neighbor_pe))
325 dst%neighbor_pe(:) = src%neighbor_pe(:)
326 allocate(dst%import_index(0:dst%n_neighbor_pe))
327 dst%import_index(:)= src%import_index(:)
328 allocate(dst%export_index(0:dst%n_neighbor_pe))
329 dst%export_index(:)= src%export_index(:)
330 allocate(dst%import_item(dst%import_index(dst%n_neighbor_pe)))
331 dst%import_item(1:dst%import_index(dst%n_neighbor_pe)) = src%import_item(1:dst%import_index(dst%n_neighbor_pe))
332 allocate(dst%export_item(dst%export_index(dst%n_neighbor_pe)))
333 dst%export_item(1:dst%export_index(dst%n_neighbor_pe)) = src%export_item(1:dst%export_index(dst%n_neighbor_pe))
335 dst%neighbor_pe => null()
336 dst%import_index => null()
337 dst%export_index => null()
338 dst%import_item => null()
339 dst%export_item => null()
341 allocate(dst%global_node_ID(dst%n_node))
342 dst%global_node_ID(1:dst%n_node) = src%global_node_ID(1:dst%n_node)
343 allocate(dst%node_ID(2*dst%n_node))
344 dst%node_ID(1:2*dst%n_node) = src%node_ID(1:2*dst%n_node)
345 allocate(dst%elem_type_item(dst%n_elem_type))
346 dst%elem_type_item(:) = src%elem_type_item(:)
348 dst%mpc%n_mpc = src%mpc%n_mpc
349 dst%mpc%mpc_index => src%mpc%mpc_index
350 dst%mpc%mpc_item => src%mpc%mpc_item
351 dst%mpc%mpc_dof => src%mpc%mpc_dof
352 dst%mpc%mpc_val => src%mpc%mpc_val
353 dst%mpc%mpc_const => src%mpc%mpc_const
355 dst%node_group%n_grp = src%node_group%n_grp
356 dst%node_group%n_bc = src%node_group%n_bc
357 dst%node_group%grp_name => src%node_group%grp_name
358 dst%node_group%grp_index => src%node_group%grp_index
359 dst%node_group%grp_item => src%node_group%grp_item
360 dst%node_group%bc_grp_ID => src%node_group%bc_grp_ID
361 dst%node_group%bc_grp_type => src%node_group%bc_grp_type
362 dst%node_group%bc_grp_index => src%node_group%bc_grp_index
363 dst%node_group%bc_grp_dof => src%node_group%bc_grp_dof
364 dst%node_group%bc_grp_val => src%node_group%bc_grp_val
367 end subroutine copy_mesh
371 subroutine free_mesh(hecMESH)
374 if (hecmesh%n_neighbor_pe > 0)
then
375 deallocate(hecmesh%neighbor_pe)
376 deallocate(hecmesh%import_index)
377 deallocate(hecmesh%export_index)
378 deallocate(hecmesh%import_item)
379 deallocate(hecmesh%export_item)
380 deallocate(hecmesh%global_node_ID)
382 deallocate(hecmesh%node_ID)
383 deallocate(hecmesh%elem_type_item)
385 end subroutine free_mesh
389 subroutine make_transformation_matrices(hecMESH, hecMESHtmp, hecMAT, hecLagMAT, &
390 slaves4lag, BLs_inv, BUs_inv, slaves, Tmat, Ttmat)
395 integer(kind=kint),
intent(out) :: slaves4lag(:)
396 real(kind=
kreal),
intent(out) :: bls_inv(:)
397 real(kind=
kreal),
intent(out) :: bus_inv(:)
398 integer(kind=kint),
allocatable,
intent(out) :: slaves(:)
399 type(hecmwst_local_matrix),
intent(out) :: tmat
400 type(hecmwst_local_matrix),
intent(out) :: ttmat
402 integer(kind=kint) :: myrank, n
408 call choose_slaves(hecmat, heclagmat, n, slaves4lag)
409 if (debug >= 2)
write(0,*)
' DEBUG2[',myrank,
']: slave DOFs chosen'
411 call make_bls_inv(heclagmat, hecmat%NDOF, slaves4lag, bls_inv)
412 call make_bus_inv(heclagmat, hecmat%NDOF, slaves4lag, bus_inv)
414 call add_c_to_tmat(hecmat, heclagmat, n, slaves4lag, bls_inv, tmat)
415 if (debug_matrix)
call debug_write_matrix(tmat,
'Tmat (local, C only)')
416 if (debug >= 2)
write(0,*)
' DEBUG2[',myrank,
']: add C to Tmat done'
418 call add_ct_to_ttmat(hecmat, heclagmat, n, slaves4lag, bus_inv, ttmat)
419 if (debug_matrix)
call debug_write_matrix(ttmat,
'Ttmat (local, Ct only)')
420 if (debug >= 2)
write(0,*)
' DEBUG2[',myrank,
']: add Ct to Tt done'
426 write(0,*)
' DEBUG2[',myrank,
']: assemble T done'
427 if (tmat%nc /= hecmesh%n_node)
write(0,*)
' DEBUG2[',myrank,
']: node migrated with T',tmat%nc-hecmesh%n_node
429 if (debug_matrix)
call debug_write_matrix(tmat,
'Tmat (assembled, C only)')
434 write(0,*)
' DEBUG2[',myrank,
']: assemble Tt done'
435 if (ttmat%nc /= tmat%nc)
write(0,*)
' DEBUG2[',myrank,
']: node migrated with Ttmat',ttmat%nc-tmat%nc
438 if (debug_matrix)
call debug_write_matrix(ttmat,
'Ttmat (assembled, Ct only)')
442 call make_slave_list(hecmeshtmp, tmat%ndof, slaves4lag, slaves)
443 call add_ip_to_tmat(tmat, slaves)
444 if (debug_matrix)
call debug_write_matrix(tmat,
'Tmat (final)')
445 call add_ip_to_tmat(ttmat, slaves)
446 if (debug_matrix)
call debug_write_matrix(ttmat,
'Ttmat (final)')
447 if (debug >= 2)
write(0,*)
' DEBUG2[',myrank,
']: place 1 on diag of T and Tt done'
448 end subroutine make_transformation_matrices
452 subroutine choose_slaves(hecMAT, hecLagMAT, n, slaves4lag)
455 integer(kind=kint),
intent(in) :: n
456 integer(kind=kint),
intent(out) :: slaves4lag(:)
458 integer(kind=kint) :: ndof, i, j, idof, jdof, l, ls, le, idx, imax, iwmin
459 real(kind=
kreal) :: val, vmax
460 integer(kind=kint),
allocatable :: mark_slave4lag(:)
461 integer(kind=kint),
allocatable :: iw1l(:), iw1u(:)
462 integer(kind=kint) :: n_slave_in, n_slave_out, ilag
463 integer(kind=kint) :: myrank
468 allocate(mark_slave4lag(n*ndof), source=0)
471 if (heclagmat%num_lagrange == 0)
return
473 allocate(iw1l(n*ndof))
474 allocate(iw1u(n*ndof))
480 do i=1,heclagmat%num_lagrange
481 ls=heclagmat%indexL_lagrange(i-1)+1
482 le=heclagmat%indexL_lagrange(i)
484 j=heclagmat%itemL_lagrange(l)
487 iw1l(idx)=iw1l(idx)+1
493 ls=heclagmat%indexU_lagrange(i-1)+1
494 le=heclagmat%indexU_lagrange(i)
496 j=heclagmat%itemU_lagrange(l)
499 iw1u(idx)=iw1u(idx)+1
511 do i=1,heclagmat%num_lagrange
512 ls=heclagmat%indexL_lagrange(i-1)+1
513 le=heclagmat%indexL_lagrange(i)
518 j=heclagmat%itemL_lagrange(l)
521 val=heclagmat%AL_lagrange((l-1)*ndof+jdof)
522 if (iw1l(idx) < iwmin .and. iw1u(idx) < iwmin)
then
523 iwmin = min(iw1l(idx),iw1u(idx))
526 if (iw1l(idx) == iwmin .and. iw1u(idx) == iwmin)
then
527 if (abs(val) > abs(vmax))
then
534 if (imax == -1) stop
"ERROR: iterative solver for contact failed"
535 mark_slave4lag(imax)=i
547 do ilag=1,heclagmat%num_lagrange
549 if (0 < i .and. i <= hecmat%N*ndof)
then
550 n_slave_in = n_slave_in + 1
551 elseif (hecmat%N*ndof < i .and. i <= hecmat%NP*ndof)
then
552 n_slave_out = n_slave_out + 1
555 write(0,*)
' DEBUG2[',myrank,
']: n_slave(in,out,tot)',n_slave_in,n_slave_out,heclagmat%num_lagrange
558 deallocate(mark_slave4lag)
559 deallocate(iw1l, iw1u)
560 end subroutine choose_slaves
564 subroutine make_bls_inv(hecLagMAT, ndof, slaves4lag, BLs_inv)
566 integer(kind=kint),
intent(in) :: ndof
567 integer(kind=kint),
intent(in) :: slaves4lag(:)
568 real(kind=
kreal),
intent(out) :: bls_inv(:)
570 integer(kind=kint) :: ilag, ls, le, l, j, jdof, idx
572 if (heclagmat%num_lagrange == 0)
return
575 do ilag=1,heclagmat%num_lagrange
576 ls=heclagmat%indexL_lagrange(ilag-1)+1
577 le=heclagmat%indexL_lagrange(ilag)
579 j=heclagmat%itemL_lagrange(l)
582 if (idx==slaves4lag(ilag))
then
583 bls_inv(ilag) = 1.0d0/heclagmat%AL_lagrange((l-1)*ndof+jdof)
590 end subroutine make_bls_inv
594 subroutine make_bus_inv(hecLagMAT, ndof, slaves4lag, BUs_inv)
596 integer(kind=kint),
intent(in) :: ndof
597 integer(kind=kint),
intent(in) :: slaves4lag(:)
598 real(kind=
kreal),
intent(out) :: bus_inv(:)
600 integer(kind=kint) :: ilag, i, idof, js, je, j, k
602 if (heclagmat%num_lagrange == 0)
return
605 do ilag=1,
size(slaves4lag)
606 i=(slaves4lag(ilag)+ndof-1)/ndof
607 idof=slaves4lag(ilag)-(i-1)*ndof
608 js=heclagmat%indexU_lagrange(i-1)+1
609 je=heclagmat%indexU_lagrange(i)
611 k=heclagmat%itemU_lagrange(j)
613 bus_inv(ilag) = 1.0d0/heclagmat%AU_lagrange((j-1)*ndof+idof)
619 end subroutine make_bus_inv
623 subroutine add_c_to_tmat(hecMAT, hecLagMAT, n, slaves4lag, BLs_inv, Tmat)
626 integer(kind=kint),
intent(in) :: n
627 integer(kind=kint),
intent(in) :: slaves4lag(:)
628 real(kind=
kreal),
intent(in) :: bls_inv(:)
629 type(hecmwst_local_matrix),
intent(out) :: tmat
631 type(hecmwst_local_matrix) :: tmat11
632 integer(kind=kint),
allocatable :: nz_cnt(:)
633 integer(kind=kint) :: ndof, i, ilag, l, js, je, j, k, jdof, kk, jj
634 real(kind=
kreal) :: factor
639 tmat11%nnz=heclagmat%numL_lagrange*ndof-heclagmat%num_lagrange
642 allocate(tmat11%index(0:tmat11%nr))
643 allocate(tmat11%item(tmat11%nnz), tmat11%A(tmat11%nnz))
644 allocate(nz_cnt(tmat11%nr), source=0)
646 do ilag=1,
size(slaves4lag)
647 nz_cnt(slaves4lag(ilag))=ndof*(heclagmat%indexL_lagrange(ilag)-heclagmat%indexL_lagrange(ilag-1))-1
651 tmat11%index(i)=tmat11%index(i-1)+nz_cnt(i)
654 if (tmat11%nnz /= tmat11%index(tmat11%nr))
then
655 write(0,*) tmat11%nnz, tmat11%index(tmat11%nr)
656 tmat11%nnz = tmat11%index(tmat11%nr)
660 do ilag=1,
size(slaves4lag)
662 l=tmat11%index(i-1)+1
663 js=heclagmat%indexL_lagrange(ilag-1)+1
664 je=heclagmat%indexL_lagrange(ilag)
665 factor=-bls_inv(ilag)
667 k=heclagmat%itemL_lagrange(j)
673 tmat11%A(l)=heclagmat%AL_lagrange(jj)*factor
677 if (l /= tmat11%index(i)+1)
then
678 write(0,*) l, tmat11%index(i)+1
679 stop
'ERROR: Tmat11%index wrong'
686 end subroutine add_c_to_tmat
690 subroutine add_ct_to_ttmat(hecMAT, hecLagMAT, n, slaves4lag, BUs_inv, Ttmat)
693 integer(kind=kint),
intent(in) :: n
694 integer(kind=kint),
intent(in) :: slaves4lag(:)
695 real(kind=
kreal),
intent(in) :: bus_inv(:)
696 type(hecmwst_local_matrix),
intent(out) :: ttmat
698 type(hecmwst_local_matrix) :: ttmat11
699 integer(kind=kint),
allocatable :: nz_cnt(:)
700 integer(kind=kint) :: ndof, i, idof, idx, ilag, l, js, je, j, k
704 ttmat11%nc=ttmat11%nr
705 ttmat11%nnz=heclagmat%numU_lagrange*ndof-heclagmat%num_lagrange
708 allocate(ttmat11%index(0:ttmat11%nr))
709 allocate(ttmat11%item(ttmat11%nnz), ttmat11%A(ttmat11%nnz))
710 allocate(nz_cnt(ttmat11%nr), source=0)
712 if (heclagmat%num_lagrange > 0)
then
716 nz_cnt(idx)=heclagmat%indexU_lagrange(i)-heclagmat%indexU_lagrange(i-1)
719 do ilag=1,
size(slaves4lag)
720 nz_cnt(slaves4lag(ilag))=0
725 ttmat11%index(i)=ttmat11%index(i-1)+nz_cnt(i)
727 if (ttmat11%nnz /= ttmat11%index(ttmat11%nr))
then
728 write(0,*) ttmat11%nnz, ttmat11%index(ttmat11%nr)
730 ttmat11%nnz = ttmat11%index(ttmat11%nr)
736 l=ttmat11%index(idx-1)+1
737 if (nz_cnt(idx) > 0)
then
739 js=heclagmat%indexU_lagrange(i-1)+1
740 je=heclagmat%indexU_lagrange(i)
742 k=heclagmat%itemU_lagrange(j)
743 ttmat11%item(l)=slaves4lag(k)
744 ttmat11%A(l)=-heclagmat%AU_lagrange((j-1)*ndof+idof)*bus_inv(k)
748 if (l /= ttmat11%index(idx)+1)
then
749 write(0,*) l, ttmat11%index(idx)+1
750 stop
'ERROR: Ttmat11%index wrong'
759 end subroutine add_ct_to_ttmat
763 subroutine make_slave_list(hecMESHtmp, ndof, slaves4lag, slaves)
765 integer(kind=kint),
intent(in) :: ndof
766 integer(kind=kint),
intent(in) :: slaves4lag(:)
767 integer(kind=kint),
allocatable,
intent(out) :: slaves(:)
769 integer(kind=kint),
allocatable :: mark_slave(:)
770 integer(kind=kint) :: n_slave
771 integer(kind=kint) :: ilag, i
772 integer(kind=kint) :: myrank
775 allocate(mark_slave(hecmeshtmp%n_node*ndof), source=0)
776 do ilag=1,
size(slaves4lag)
777 mark_slave(slaves4lag(ilag))=1
781 do i = 1, hecmeshtmp%nn_internal * ndof
782 if (mark_slave(i) /= 0) n_slave = n_slave + 1
784 if (debug >= 2)
write(0,*)
' DEBUG2[',myrank,
']: n_slave',n_slave
785 allocate(slaves(n_slave))
787 do i = 1, hecmeshtmp%nn_internal * ndof
788 if (mark_slave(i) /= 0)
then
789 n_slave = n_slave + 1
793 if (debug >= 3)
write(0,*)
' DEBUG3[',myrank,
']: slaves',slaves(:)
794 deallocate(mark_slave)
795 end subroutine make_slave_list
799 subroutine add_ip_to_tmat(Tmat, slaves)
800 type(hecmwst_local_matrix),
intent(inout) :: tmat
801 integer(kind=kint),
intent(in) :: slaves(:)
803 type(hecmwst_local_matrix) :: imat, wmat
804 integer(kind=kint) :: ndof, ndof2, i, irow, idof
813 allocate(imat%index(0:imat%nr))
814 allocate(imat%item(imat%nnz))
820 allocate(imat%A(ndof2 * imat%nnz))
824 imat%A(ndof2*(irow-1)+ndof*(idof-1)+idof) = 1.0d0
827 do i = 1,
size(slaves)
828 irow = (slaves(i)+ndof-1)/ndof
829 idof = slaves(i)-ndof*(irow-1)
830 imat%A(ndof2*(irow-1)+ndof*(idof-1)+idof) = 0.0d0
838 tmat%ndof = wmat%ndof
839 tmat%index => wmat%index
840 tmat%item => wmat%item
842 end subroutine add_ip_to_tmat
846 subroutine make_contact_comm_table(hecMESH, hecMAT, hecLagMAT, conCOMM)
850 type(hecmwst_contact_comm),
intent(out) :: concomm
852 integer(kind=kint) :: n_contact_dof
853 integer(kind=kint),
allocatable :: contact_dofs(:)
856 call make_contact_dof_list(hecmat, heclagmat, n_contact_dof, contact_dofs)
860 end subroutine make_contact_comm_table
864 subroutine make_contact_dof_list(hecMAT, hecLagMAT, n_contact_dof, contact_dofs)
867 integer(kind=kint),
intent(out) :: n_contact_dof
868 integer(kind=kint),
allocatable,
intent(out) :: contact_dofs(:)
870 integer(kind=kint) :: ndof, icnt, ilag, ls, le, l, jnode, k, inode, idof, i
871 integer(kind=kint),
allocatable :: iw(:)
873 integer(kind=kint) :: myrank
875 if (heclagmat%num_lagrange == 0)
then
881 allocate(iw(hecmat%NP))
883 do ilag = 1, heclagmat%num_lagrange
884 ls = heclagmat%indexL_lagrange(ilag-1)+1
885 le = heclagmat%indexL_lagrange(ilag)
886 lloop1:
do l = ls, le
887 jnode = heclagmat%itemL_lagrange(l)
889 if (iw(k) == jnode) cycle lloop1
896 do inode = 1, hecmat%NP
897 ls = heclagmat%indexU_lagrange(inode-1)+1
898 le = heclagmat%indexU_lagrange(inode)
902 if (iw(k) == inode) found = .true.
904 if (.not. found)
then
910 call quick_sort(iw, 1, icnt)
911 allocate(contact_dofs(icnt*ndof))
914 contact_dofs((i-1)*ndof+idof) = (iw(i)-1)*ndof+idof
917 n_contact_dof = icnt*ndof
920 if (debug >= 2)
write(0,*)
' DEBUG2[',myrank,
']: n_contact_dof',n_contact_dof
921 if (debug >= 3)
write(0,*)
' DEBUG3[',myrank,
']: contact_dofs',contact_dofs(:)
922 end subroutine make_contact_dof_list
926 recursive subroutine quick_sort(array, id1, id2)
927 integer(kind=kint),
intent(inout) :: array(:)
928 integer(kind=kint),
intent(in) :: id1, id2
930 integer(kind=kint) :: pivot, center, left, right, tmp
932 if (id1 >= id2)
return
933 center = (id1 + id2) / 2
934 pivot = array(center)
938 do while (array(left) < pivot)
941 do while (pivot < array(right))
944 if (left >= right)
exit
946 array(left) = array(right)
951 if (id1 < left-1)
call quick_sort(array, id1, left-1)
952 if (right+1 < id2)
call quick_sort(array, right+1, id2)
954 end subroutine quick_sort
958 subroutine assemble_equation(hecMESH, hecMESHtmp, hecMAT, conMAT, num_lagrange, &
964 integer(kind=kint),
intent(in) :: num_lagrange
965 integer(kind=kint),
intent(in) :: slaves(:)
967 type(hecmwst_local_matrix),
intent(out) :: kmat
968 real(kind=
kreal),
intent(out) :: btot(:)
970 integer(kind=kint) :: myrank
974 call assemble_matrix(hecmesh, hecmeshtmp, hecmat, conmat, num_lagrange, kmat)
975 if (debug >= 2)
write(0,*)
' DEBUG2[',myrank,
']: assemble matrix done'
977 call assemble_rhs(hecmesh, hecmat, conmat, num_lagrange, slaves, btot)
978 if (debug >= 2)
write(0,*)
' DEBUG2[',myrank,
']: assemble rhs done'
980 end subroutine assemble_equation
984 subroutine assemble_matrix(hecMESH, hecMESHtmp, hecMAT, conMAT, num_lagrange, Kmat)
989 integer(kind=kint),
intent(in) :: num_lagrange
990 type(hecmwst_local_matrix),
intent(out) :: kmat
992 integer(kind=kint) :: myrank
998 if (debug_matrix)
call debug_write_matrix(kmat,
'Kmat (conMAT local)')
1003 if (debug_matrix)
call debug_write_matrix(kmat,
'Kmat (conMAT assembled)')
1004 if (debug >= 3)
write(0,*)
' DEBUG3[',myrank,
']: assemble K (conMAT) done'
1009 if (debug_matrix)
call debug_write_matrix(kmat,
'Kmat (hecMAT added)')
1010 if (debug >= 3)
write(0,*)
' DEBUG3[',myrank,
']: add hecMAT to K done'
1011 end subroutine assemble_matrix
1015 subroutine assemble_rhs(hecMESH, hecMAT, conMAT, num_lagrange, slaves, Btot)
1019 integer(kind=kint),
intent(in) :: num_lagrange
1020 integer(kind=kint),
intent(in) :: slaves(:)
1022 real(kind=
kreal),
intent(out) :: btot(:)
1024 integer(kind=kint) :: ndof, nndof, npndof, i, myrank
1029 npndof = hecmat%NP*ndof
1030 nndof = hecmat%N *ndof
1032 if (debug_vector)
call debug_write_vector(hecmat%B,
'RHS(hecMAT)',
'hecMAT%B', ndof, hecmat%N, &
1033 hecmat%NP, .false., num_lagrange, slaves)
1034 if (debug_vector)
call debug_write_vector(conmat%B,
'RHS(conMAT)',
'conMAT%B', ndof, conmat%N, &
1035 conmat%NP, .true., num_lagrange, slaves)
1037 do i=1,npndof+num_lagrange
1038 btot(i) = conmat%B(i)
1044 if (debug_vector)
call debug_write_vector(btot,
'RHS(conMAT assembled)',
'Btot', ndof, conmat%N, &
1045 conmat%NP, .false., num_lagrange, slaves)
1046 if (debug >= 3)
write(0,*)
' DEBUG3[',myrank,
']: assemble RHS (conMAT%B) done'
1051 btot(i)=btot(i)+hecmat%B(i)
1053 if (debug_vector)
call debug_write_vector(btot,
'RHS(total)',
'Btot', ndof, conmat%N, &
1054 conmat%NP, .false., num_lagrange, slaves)
1055 if (debug >= 3)
write(0,*)
' DEBUG3[',myrank,
']: add hecMAT%B to RHS done'
1056 end subroutine assemble_rhs
1060 subroutine convert_equation(hecMESHtmp, hecMAT, Kmat, Tmat, Ttmat, Btot, slaves, &
1061 slaves4lag, BLs_inv, conCOMM, hecTKT)
1064 type(hecmwst_local_matrix),
intent(inout) :: kmat
1065 type(hecmwst_local_matrix),
intent(inout) :: tmat
1066 type(hecmwst_local_matrix),
intent(in) :: ttmat
1067 real(kind=
kreal),
intent(in) :: btot(:)
1068 integer(kind=kint),
intent(in) :: slaves(:)
1069 integer(kind=kint),
intent(in) :: slaves4lag(:)
1070 real(kind=
kreal),
intent(in) :: bls_inv(:)
1071 type(hecmwst_contact_comm),
intent(in) :: concomm
1074 integer(kind=kint) :: myrank
1078 call convert_matrix(hecmeshtmp, hecmat, ttmat, kmat, tmat, slaves, hectkt)
1079 if (debug >= 2)
write(0,*)
' DEBUG2[',myrank,
']: converted matrix'
1081 call convert_rhs(hecmeshtmp, hecmat, hectkt, ttmat, kmat, &
1082 slaves4lag, bls_inv, btot, concomm)
1083 if (debug >= 2)
write(0,*)
' DEBUG2[',myrank,
']: converted RHS'
1084 end subroutine convert_equation
1088 subroutine convert_matrix(hecMESHtmp, hecMAT, Ttmat, Kmat, Tmat, slaves, hecTKT)
1091 type(hecmwst_local_matrix),
intent(in) :: ttmat
1092 type(hecmwst_local_matrix),
intent(inout) :: kmat
1093 type(hecmwst_local_matrix),
intent(inout) :: tmat
1094 integer(kind=kint),
intent(in) :: slaves(:)
1097 type(hecmwst_local_matrix) :: ttkmat, ttktmat
1098 integer(kind=kint) :: myrank
1104 if (debug_matrix)
call debug_write_matrix(ttkmat,
'TtKmat')
1105 if (debug >= 3)
write(0,*)
' DEBUG3[',myrank,
']: multiply Tt and K done'
1109 if (debug_matrix)
call debug_write_matrix(ttktmat,
'TtKTmat')
1110 if (debug >= 3)
write(0,*)
' DEBUG3[',myrank,
']: multiply TtK and T done'
1115 call place_one_on_diag_of_slave_dof(ttktmat, slaves)
1116 if (debug_matrix)
call debug_write_matrix(ttktmat,
'TtKTmat (place 1.0 on slave diag)')
1120 if (debug >= 3)
write(0,*)
' DEBUG3[',myrank,
']: convert TtKT to hecTKT done'
1122 end subroutine convert_matrix
1126 subroutine place_one_on_diag_of_slave_dof(TtKTmat, slaves)
1127 type(hecmwst_local_matrix),
intent(inout) :: ttktmat
1128 integer(kind=kint),
intent(in) :: slaves(:)
1130 integer(kind=kint) :: ndof, ndof2, i, irow, idof, js, je, j, jcol
1134 do i = 1,
size(slaves)
1135 irow = (slaves(i)+ndof-1)/ndof
1136 idof = slaves(i)-ndof*(irow-1)
1137 js = ttktmat%index(irow-1)+1
1138 je = ttktmat%index(irow)
1140 jcol = ttktmat%item(j)
1141 if (irow /= jcol) cycle
1142 if (abs(ttktmat%A(ndof2*(j-1)+ndof*(idof-1)+idof)) > tiny(0.0d0)) &
1143 stop
'ERROR: nonzero diag on slave dof of TtKTmat'
1144 ttktmat%A(ndof2*(j-1)+ndof*(idof-1)+idof) = 1.0d0
1147 end subroutine place_one_on_diag_of_slave_dof
1151 subroutine convert_rhs(hecMESHtmp, hecMAT, hecTKT, Ttmat, Kmat, &
1152 slaves4lag, BLs_inv, Btot, conCOMM)
1156 type(hecmwst_local_matrix),
intent(in) :: ttmat
1157 type(hecmwst_local_matrix),
intent(in) :: kmat
1158 integer(kind=kint),
intent(in) :: slaves4lag(:)
1159 real(kind=
kreal),
intent(in) :: bls_inv(:)
1160 real(kind=
kreal),
target,
intent(in) :: btot(:)
1161 type(hecmwst_contact_comm),
intent(in) :: concomm
1163 real(kind=
kreal),
allocatable :: btmp(:)
1164 real(kind=
kreal),
pointer :: blag(:)
1165 integer(kind=kint) :: ndof, npndof, nndof, npndof_new, num_lagrange, i
1172 npndof = hecmat%NP*ndof
1173 nndof = hecmat%N *ndof
1174 npndof_new = hectkt%NP*ndof
1175 num_lagrange =
size(slaves4lag)
1177 allocate(hectkt%B(npndof_new), source=0.d0)
1178 allocate(hectkt%X(npndof_new), source=0.d0)
1179 allocate(btmp(npndof_new))
1184 blag => btot(npndof+1:npndof+num_lagrange)
1185 hectkt%B(slaves4lag(:))=-bls_inv(:)*blag(:)
1193 btmp(i)=btot(i)+btmp(i)
1200 if (debug_vector)
call debug_write_vector(hectkt%B,
'RHS(converted)',
'hecTKT%B', ndof, hectkt%N)
1201 end subroutine convert_rhs
1205 subroutine recover_solution(hecMESHtmp, hecMAT, hecTKT, Tmat, Kmat, Btot, &
1206 slaves4lag, BLs_inv, BUs_inv, conCOMM, slaves)
1211 type(hecmwst_local_matrix),
intent(in) :: tmat
1212 type(hecmwst_local_matrix),
intent(in) :: kmat
1213 real(kind=
kreal),
intent(in) :: btot(:)
1214 integer(kind=kint),
intent(in) :: slaves4lag(:)
1215 real(kind=
kreal),
intent(in) :: bls_inv(:)
1216 real(kind=
kreal),
intent(in) :: bus_inv(:)
1217 type(hecmwst_contact_comm),
intent(in) :: concomm
1218 integer(kind=kint),
intent(in) :: slaves(:)
1220 integer(kind=kint) :: myrank
1224 hecmat%Iarray=hectkt%Iarray
1225 hecmat%Rarray=hectkt%Rarray
1227 call comp_x_slave(hecmeshtmp, hecmat, hectkt, tmat, btot, &
1228 slaves4lag, bls_inv, concomm, slaves)
1229 if (debug >= 2)
write(0,*)
' DEBUG2[',myrank,
']: recovered slave disp'
1231 call comp_lag(hecmeshtmp, hecmat, hectkt, kmat, btot, &
1232 slaves4lag, bus_inv, concomm, slaves)
1233 if (debug >= 2)
write(0,*)
' DEBUG2[',myrank,
']: recovered lag'
1235 if (debug_vector)
call debug_write_vector(hecmat%X,
'Solution(original)',
'hecMAT%X', hecmat%NDOF, hecmat%N, &
1236 hecmat%NP, .false.,
size(slaves4lag), slaves)
1237 end subroutine recover_solution
1241 subroutine comp_x_slave(hecMESHtmp, hecMAT, hecTKT, Tmat, Btot, &
1242 slaves4lag, BLs_inv, conCOMM, slaves)
1247 type(hecmwst_local_matrix),
intent(in) :: tmat
1248 real(kind=
kreal),
target,
intent(in) :: btot(:)
1249 integer(kind=kint),
intent(in) :: slaves4lag(:)
1250 real(kind=
kreal),
intent(in) :: bls_inv(:)
1251 type(hecmwst_contact_comm),
intent(in) :: concomm
1252 integer(kind=kint),
intent(in) :: slaves(:)
1254 integer(kind=kint) :: ndof, ndof2, npndof, nndof, num_lagrange
1255 real(kind=
kreal),
allocatable :: xtmp(:)
1256 real(kind=
kreal),
pointer :: blag(:)
1260 npndof = hecmat%NP * ndof
1261 nndof = hecmat%N * ndof
1262 num_lagrange =
size(slaves4lag)
1271 allocate(xtmp(npndof), source=0.0d0)
1272 blag => btot(npndof+1:npndof+num_lagrange)
1273 xtmp(slaves4lag(:)) = -bls_inv(:) * blag(:)
1280 hecmat%X(slaves(:)) = hecmat%X(slaves(:)) - xtmp(slaves(:))
1282 end subroutine comp_x_slave
1286 subroutine comp_lag(hecMESHtmp, hecMAT, hecTKT, Kmat, Btot, &
1287 slaves4lag, BUs_inv, conCOMM, slaves)
1292 type(hecmwst_local_matrix),
intent(in) :: kmat
1293 real(kind=
kreal),
intent(in) :: btot(:)
1294 integer(kind=kint),
intent(in) :: slaves4lag(:)
1295 real(kind=
kreal),
intent(in) :: bus_inv(:)
1296 type(hecmwst_contact_comm),
intent(in) :: concomm
1297 integer(kind=kint),
intent(in) :: slaves(:)
1299 integer(kind=kint) :: ndof, npndof, nndof, npndof_new, num_lagrange
1300 real(kind=
kreal),
allocatable :: btmp(:)
1301 real(kind=
kreal),
pointer :: xlag(:)
1304 npndof = hecmat%NP * ndof
1305 nndof = hecmat%N * ndof
1306 npndof_new = hectkt%NP * ndof
1307 num_lagrange =
size(slaves4lag)
1313 hectkt%X(1:nndof) = hecmat%X(1:nndof)
1315 allocate(btmp(npndof))
1319 btmp(slaves(:)) = btot(slaves(:)) - btmp(slaves(:))
1326 xlag => hecmat%X(npndof+1:npndof+num_lagrange)
1327 xlag(:)=bus_inv(:)*btmp(slaves4lag(:))
1329 end subroutine comp_lag
1333 subroutine check_solution(hecMESH, hecMESHtmp, hecMAT, hecTKT, hecLagMAT, Kmat, Btot, &
1340 type(hecmwst_local_matrix),
intent(in) :: kmat
1341 real(kind=
kreal),
target,
intent(in) :: btot(:)
1342 type(hecmwst_contact_comm),
intent(in) :: concomm
1343 integer(kind=kint),
intent(in) :: slaves(:)
1345 integer(kind=kint) :: ndof, nndof, npndof, num_lagrange, i, ls, le, l, j, idof, jdof
1346 real(kind=
kreal),
allocatable,
target :: r(:)
1347 real(kind=
kreal),
allocatable :: btmp(:)
1348 real(kind=
kreal),
pointer :: rlag(:), blag(:), xlag(:)
1349 real(kind=
kreal) :: rnrm2, rlagnrm2
1350 real(kind=
kreal) :: bnrm2, blagnrm2
1351 integer(kind=kint) :: myrank
1355 nndof = hecmat%N * ndof
1356 npndof = hecmat%NP * ndof
1357 num_lagrange = heclagmat%num_lagrange
1359 allocate(r(npndof + num_lagrange), source=0.0d0)
1360 allocate(btmp(npndof))
1362 rlag => r(npndof+1:npndof+num_lagrange)
1363 blag => btot(npndof+1:npndof+num_lagrange)
1364 xlag => hecmat%X(npndof+1:npndof+num_lagrange)
1371 hectkt%X(i) = hecmat%X(i)
1376 r(i) = btot(i) - btmp(i)
1381 if (heclagmat%num_lagrange > 0)
then
1383 ls = heclagmat%indexU_lagrange(i-1)+1
1384 le = heclagmat%indexU_lagrange(i)
1386 j = heclagmat%itemU_lagrange(l)
1388 btmp(ndof*(i-1)+idof) = btmp(ndof*(i-1)+idof) + heclagmat%AU_lagrange(ndof*(l-1)+idof) * xlag(j)
1396 r(i) = r(i) - btmp(i)
1401 do i = 1, num_lagrange
1403 ls = heclagmat%indexL_lagrange(i-1)+1
1404 le = heclagmat%indexL_lagrange(i)
1406 j = heclagmat%itemL_lagrange(l)
1408 rlag(i) = rlag(i) - heclagmat%AL_lagrange(ndof*(l-1)+jdof) * hecmat%X(ndof*(j-1)+jdof)
1414 if (debug_vector)
call debug_write_vector(r,
'Residual',
'R', ndof, hecmat%N, &
1415 hecmat%NP, .false., heclagmat%num_lagrange, slaves)
1419 rlagnrm2 = dot_product(rlag, rlag)
1421 blagnrm2 = dot_product(blag, blag)
1424 if (myrank == 0)
then
1425 write(0,*)
'INFO: resid(x,lag,tot)',sqrt(rnrm2),sqrt(rlagnrm2),sqrt(rnrm2+rlagnrm2)
1426 write(0,*)
'INFO: rhs (x,lag,tot)',sqrt(bnrm2),sqrt(blagnrm2),sqrt(bnrm2+blagnrm2)
1428 end subroutine check_solution
1432 subroutine check_solution2(hecMESH, hecMAT, conMAT, hecLagMAT, conCOMM, slaves)
1438 type(hecmwst_contact_comm),
intent(in) :: concomm
1439 integer(kind=kint),
intent(in) :: slaves(:)
1441 integer(kind=kint) :: ndof, ndof2, nndof, npndof, num_lagrange
1442 integer(kind=kint) :: i, idof, j, jdof, ls, le, l
1443 integer(kind=kint) :: irow, js, je, jcol
1444 real(kind=
kreal),
allocatable,
target :: r(:)
1445 real(kind=
kreal),
allocatable :: r_con(:)
1446 real(kind=
kreal),
pointer :: rlag(:), blag(:), xlag(:)
1447 real(kind=
kreal) :: rnrm2, rlagnrm2
1448 integer(kind=kint) :: myrank
1453 nndof = hecmat%N * ndof
1454 npndof = hecmat%NP * ndof
1455 num_lagrange = heclagmat%num_lagrange
1457 allocate(r(npndof + num_lagrange))
1459 allocate(r_con(npndof))
1462 rlag => r(npndof+1:npndof+num_lagrange)
1463 blag => conmat%B(npndof+1:npndof+num_lagrange)
1464 xlag => hecmat%X(npndof+1:npndof+num_lagrange)
1478 if (debug_vector)
call debug_write_vector(r,
'Residual(original)',
'R', ndof, hecmat%N, &
1479 hecmat%NP, .false., num_lagrange, slaves)
1486 r_con(i) = conmat%B(i)
1488 do irow = 1,hecmat%NP
1490 js = conmat%indexL(irow-1)+1
1491 je = conmat%indexL(irow)
1493 jcol = conmat%itemL(j)
1495 i = ndof*(irow-1)+idof
1497 r_con(i) = r_con(i) - conmat%AL(ndof2*(j-1)+ndof*(idof-1)+jdof) * hecmat%X(ndof*(jcol-1)+jdof)
1503 i = ndof*(irow-1)+idof
1505 r_con(i) = r_con(i) - conmat%D(ndof2*(irow-1)+ndof*(idof-1)+jdof) * hecmat%X(ndof*(irow-1)+jdof)
1509 js = conmat%indexU(irow-1)+1
1510 je = conmat%indexU(irow)
1512 jcol = conmat%itemU(j)
1514 i = ndof*(irow-1)+idof
1516 r_con(i) = r_con(i) - conmat%AU(ndof2*(j-1)+ndof*(idof-1)+jdof) * hecmat%X(ndof*(jcol-1)+jdof)
1523 if (num_lagrange > 0)
then
1525 ls = heclagmat%indexU_lagrange(i-1)+1
1526 le = heclagmat%indexU_lagrange(i)
1528 j = heclagmat%itemU_lagrange(l)
1530 r_con(ndof*(i-1)+idof) = r_con(ndof*(i-1)+idof) - heclagmat%AU_lagrange(ndof*(l-1)+idof) * xlag(j)
1536 if (debug_vector)
call debug_write_vector(r,
'Residual(contact,local)',
'R_con', ndof, hecmat%N, &
1537 hecmat%NP, .true., num_lagrange, slaves)
1542 if (debug_vector)
call debug_write_vector(r,
'Residual(contact,assembled)',
'R_con', ndof, hecmat%N, &
1543 hecmat%NP, .false., num_lagrange, slaves)
1547 r(i) = r(i) + r_con(i)
1550 if (debug_vector)
call debug_write_vector(r,
'Residual(total)',
'R', ndof, hecmat%N, &
1551 hecmat%NP, .false., num_lagrange, slaves)
1555 do i = 1, num_lagrange
1557 ls = heclagmat%indexL_lagrange(i-1)+1
1558 le = heclagmat%indexL_lagrange(i)
1560 j = heclagmat%itemL_lagrange(l)
1562 rlag(i) = rlag(i) - heclagmat%AL_lagrange(ndof*(l-1)+jdof) * hecmat%X(ndof*(j-1)+jdof)
1567 if (debug_vector)
then
1568 write(1000+myrank,*)
'Residual(lagrange)-----------------------------------------------------'
1569 if (num_lagrange > 0)
then
1570 write(1000+myrank,*)
'R(lag):',npndof+1,
'-',npndof+num_lagrange
1571 write(1000+myrank,*) r(npndof+1:npndof+num_lagrange)
1576 rlagnrm2 = dot_product(rlag, rlag)
1579 if (myrank == 0)
write(0,*)
'INFO: resid(x,lag,tot)',sqrt(rnrm2),sqrt(rlagnrm2),sqrt(rnrm2+rlagnrm2)
1580 end subroutine check_solution2
1584 subroutine debug_write_matrix(Mat, label)
1585 type(hecmwst_local_matrix),
intent(in) :: mat
1586 character(len=*),
intent(in) :: label
1588 integer(kind=kint) :: myrank
1591 write(1000+myrank,*) trim(label),
'============================================================'
1593 end subroutine debug_write_matrix
1597 subroutine debug_write_vector(Vec, label, name, ndof, N, &
1598 NP, write_ext, num_lagrange, slaves)
1599 real(kind=
kreal),
intent(in) :: vec(:)
1600 character(len=*),
intent(in) :: label
1601 character(len=*),
intent(in) :: name
1602 integer(kind=kint),
intent(in) :: ndof
1603 integer(kind=kint),
intent(in) :: n
1604 integer(kind=kint),
intent(in),
optional :: np
1605 logical,
intent(in),
optional :: write_ext
1606 integer(kind=kint),
intent(in),
optional :: num_lagrange
1607 integer(kind=kint),
intent(in),
optional :: slaves(:)
1609 integer(kind=kint) :: myrank
1612 write(1000+myrank,*) trim(label),
'------------------------------------------------------------'
1613 write(1000+myrank,*)
'size of ',trim(name),
size(vec)
1614 write(1000+myrank,*) trim(name),
': 1-',n*ndof
1615 write(1000+myrank,*) vec(1:n*ndof)
1616 if (
present(write_ext) .and.
present(np))
then
1618 write(1000+myrank,*) trim(name),
'(external): ',n*ndof+1,
'-',np*ndof
1619 write(1000+myrank,*) vec(n*ndof+1:np*ndof)
1622 if (
present(num_lagrange) .and.
present(np))
then
1623 if (num_lagrange > 0)
then
1624 write(1000+myrank,*) trim(name),
'(lag):',np*ndof+1,
'-',np*ndof+num_lagrange
1625 write(1000+myrank,*) vec(np*ndof+1:np*ndof+num_lagrange)
1628 if (
present(slaves))
then
1629 if (
size(slaves) > 0)
then
1630 write(1000+myrank,*) trim(name),
'(slave):',slaves(:)
1631 write(1000+myrank,*) vec(slaves(:))
1634 end subroutine debug_write_vector
Essential boundary conditions kept as per-DOF marks and values so that they can be imposed on the mat...
subroutine, public hecmw_ebc_apply(hecMESH, hecMAT, hecEBC, conMAT)
subroutine, public hecmw_localmat_init_with_hecmat(BKmat, hecMAT, num_lagrange)
subroutine, public hecmw_localmat_free(Tmat)
subroutine, public hecmw_localmat_add(Amat, Bmat, Cmat)
subroutine, public hecmw_localmat_multmat(BKmat, BTmat, hecMESH, BKTmat)
subroutine, public hecmw_localmat_mulvec(BTmat, V, TV)
subroutine, public hecmw_localmat_write(Tmat, iunit)
subroutine, public hecmw_localmat_blocking(Tmat, ndof, BTmat)
subroutine, public hecmw_localmat_make_hecmat(hecMAT, BTtKTmat, hecTKT)
subroutine, public hecmw_localmat_assemble(BTmat, hecMESH, hecMESHnew)
subroutine, public hecmw_localmat_add_hecmat(BKmat, hecMAT)
integer(kind=kint) function, public hecmw_mat_get_solver_type(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_flag_diverged(hecMAT)
subroutine, public hecmw_mat_init(hecMAT)
subroutine, public hecmw_mat_finalize(hecMAT)
subroutine, public hecmw_mat_set_flag_diverged(hecMAT, flag_diverged)
subroutine, public hecmw_mat_set_flag_converged(hecMAT, flag_converged)
integer(kind=kint) function, public hecmw_mat_get_flag_converged(hecMAT)
subroutine, public hecmw_mat_set_method(hecMAT, method)
integer(kind=kint) function, public hecmw_mat_get_method(hecMAT)
integer(kind=kint) function, public hecmw_mat_get_precond(hecMAT)
subroutine, public hecmw_mat_set_precond(hecMAT, precond)
subroutine, public hecmw_mpc_tback_sol(hecMESH, hecMAT, hecMATmpc)
subroutine, public hecmw_mpc_mat_init(hecMESH, hecMAT, hecMESHmpc, hecMATmpc, conMAT, conMATmpc)
subroutine, public hecmw_mpc_mat_ass(hecMESH, hecMAT, hecMESHmpc, hecMATmpc, conMAT, conMATmpc, hecLagMAT)
subroutine, public hecmw_mpc_mat_finalize(hecMESH, hecMAT, hecMESHmpc, hecMATmpc, conMATmpc)
subroutine, public hecmw_mpc_trans_rhs(hecMESH, hecMAT, hecMATmpc)
subroutine, public hecmw_matresid(hecMESH, hecMAT, X, B, R, COMMtime)
subroutine hecmw_innerproduct_r(hecMESH, ndof, X, Y, sum, COMMtime)
subroutine hecmw_solve(hecMESH, hecMAT)
integer(kind=kint), parameter hecmw_sum
integer(kind=kint) function hecmw_comm_get_size()
integer(kind=kint), parameter hecmw_max
integer(kind=4), parameter kreal
integer(kind=kint) function hecmw_comm_get_rank()
real(kind=kreal) function hecmw_wtime()
subroutine hecmw_assemble_r(hecMESH, val, n, m)
subroutine hecmw_update_r(hecMESH, val, n, m)
subroutine hecmw_allreduce_i1(hecMESH, s, ntag)
subroutine hecmw_assemble_i(hecMESH, val, n, m)
subroutine hecmw_allreduce_r1(hecMESH, s, ntag)
Structure for Lagrange multiplier-related part of stiffness matrix (Lagrange multiplier-related matri...