338 type(
gs_t),
target,
intent(inout) :: gs
339 type(
mesh_t),
pointer :: msh
341 type(
stack_i4_t),
target :: local_dof, dof_local, shared_dof, dof_shared
342 type(
stack_i4_t),
target :: local_face_dof, face_dof_local
343 type(
stack_i4_t),
target :: shared_face_dof, face_dof_shared
344 integer :: i, j, k, l, lx, ly, lz, max_id, max_sid, id, lid, dm_size
350 sdm => gs%shared_dofs
355 dm_size =
dofmap%size()/lx
357 call dm%init(dm_size, i)
360 call sdm%init(
dofmap%size(), i)
363 call local_dof%init()
364 call dof_local%init()
366 call local_face_dof%init()
367 call face_dof_local%init()
369 call shared_dof%init()
370 call dof_shared%init()
372 call shared_face_dof%init()
373 call face_dof_shared%init()
383 if (
dofmap%shared_dof(1, 1, 1, i))
then
385 call shared_dof%push(id)
386 call dof_shared%push(lid)
389 call local_dof%push(id)
390 call dof_local%push(lid)
394 if (
dofmap%shared_dof(lx, 1, 1, i))
then
396 call shared_dof%push(id)
397 call dof_shared%push(lid)
400 call local_dof%push(id)
401 call dof_local%push(lid)
405 if (
dofmap%shared_dof(1, ly, 1, i))
then
407 call shared_dof%push(id)
408 call dof_shared%push(lid)
411 call local_dof%push(id)
412 call dof_local%push(lid)
416 if (
dofmap%shared_dof(lx, ly, 1, i))
then
418 call shared_dof%push(id)
419 call dof_shared%push(lid)
422 call local_dof%push(id)
423 call dof_local%push(lid)
427 if (
dofmap%shared_dof(1, 1, lz, i))
then
429 call shared_dof%push(id)
430 call dof_shared%push(lid)
433 call local_dof%push(id)
434 call dof_local%push(lid)
438 if (
dofmap%shared_dof(lx, 1, lz, i))
then
440 call shared_dof%push(id)
441 call dof_shared%push(lid)
444 call local_dof%push(id)
445 call dof_local%push(lid)
449 if (
dofmap%shared_dof(1, ly, lz, i))
then
451 call shared_dof%push(id)
452 call dof_shared%push(lid)
455 call local_dof%push(id)
456 call dof_local%push(lid)
460 if (
dofmap%shared_dof(lx, ly, lz, i))
then
462 call shared_dof%push(id)
463 call dof_shared%push(lid)
466 call local_dof%push(id)
467 call dof_local%push(lid)
484 if (
dofmap%shared_dof(2, 1, 1, i))
then
487 call shared_dof%push(id)
489 call dof_shared%push(id)
494 call local_dof%push(id)
496 call dof_local%push(id)
499 if (
dofmap%shared_dof(2, 1, lz, i))
then
502 call shared_dof%push(id)
504 call dof_shared%push(id)
509 call local_dof%push(id)
511 call dof_local%push(id)
515 if (
dofmap%shared_dof(2, ly, 1, i))
then
518 call shared_dof%push(id)
520 call dof_shared%push(id)
526 call local_dof%push(id)
528 call dof_local%push(id)
531 if (
dofmap%shared_dof(2, ly, lz, i))
then
534 call shared_dof%push(id)
536 call dof_shared%push(id)
541 call local_dof%push(id)
543 call dof_local%push(id)
550 if (
dofmap%shared_dof(1, 2, 1, i))
then
553 call shared_dof%push(id)
555 call dof_shared%push(id)
560 call local_dof%push(id)
562 call dof_local%push(id)
565 if (
dofmap%shared_dof(1, 2, lz, i))
then
568 call shared_dof%push(id)
570 call dof_shared%push(id)
575 call local_dof%push(id)
577 call dof_local%push(id)
581 if (
dofmap%shared_dof(lx, 2, 1, i))
then
584 call shared_dof%push(id)
586 call dof_shared%push(id)
591 call local_dof%push(id)
593 call dof_local%push(id)
596 if (
dofmap%shared_dof(lx, 2, lz, i))
then
599 call shared_dof%push(id)
601 call dof_shared%push(id)
606 call local_dof%push(id)
608 call dof_local%push(id)
614 if (
dofmap%shared_dof(1, 1, 2, i))
then
617 call shared_dof%push(id)
619 call dof_shared%push(id)
624 call local_dof%push(id)
626 call dof_local%push(id)
630 if (
dofmap%shared_dof(lx, 1, 2, i))
then
633 call shared_dof%push(id)
635 call dof_shared%push(id)
640 call local_dof%push(id)
642 call dof_local%push(id)
646 if (
dofmap%shared_dof(1, ly, 2, i))
then
649 call shared_dof%push(id)
651 call dof_shared%push(id)
656 call local_dof%push(id)
658 call dof_local%push(id)
662 if (
dofmap%shared_dof(lx, ly, 2, i))
then
665 call shared_dof%push(id)
667 call dof_shared%push(id)
672 call local_dof%push(id)
674 call dof_local%push(id)
692 if (msh%facet_neigh(3, i) .ne. 0)
then
693 if (
dofmap%shared_dof(2, 1, 1, i))
then
696 call shared_face_dof%push(id)
698 call face_dof_shared%push(id)
703 call local_face_dof%push(id)
705 call face_dof_local%push(id)
710 if (msh%facet_neigh(4, i) .ne. 0)
then
711 if (
dofmap%shared_dof(2, ly, 1, i))
then
714 call shared_face_dof%push(id)
716 call face_dof_shared%push(id)
722 call local_face_dof%push(id)
724 call face_dof_local%push(id)
732 if (msh%facet_neigh(1, i) .ne. 0)
then
733 if (
dofmap%shared_dof(1, 2, 1, i))
then
736 call shared_face_dof%push(id)
738 call face_dof_shared%push(id)
743 call local_face_dof%push(id)
745 call face_dof_local%push(id)
750 if (msh%facet_neigh(2, i) .ne. 0)
then
751 if (
dofmap%shared_dof(lx, 2, 1, i))
then
754 call shared_face_dof%push(id)
756 call face_dof_shared%push(id)
761 call local_face_dof%push(id)
763 call face_dof_local%push(id)
772 if (msh%facet_neigh(1, i) .ne. 0)
then
773 if (
dofmap%shared_dof(1, 2, 2, i))
then
777 call shared_face_dof%push(id)
779 call face_dof_shared%push(id)
786 call local_face_dof%push(id)
788 call face_dof_local%push(id)
794 if (msh%facet_neigh(2, i) .ne. 0)
then
795 if (
dofmap%shared_dof(lx, 2, 2, i))
then
799 call shared_face_dof%push(id)
801 call face_dof_shared%push(id)
808 call local_face_dof%push(id)
810 call face_dof_local%push(id)
817 if (msh%facet_neigh(3, i) .ne. 0)
then
818 if (
dofmap%shared_dof(2, 1, 2, i))
then
822 call shared_face_dof%push(id)
824 call face_dof_shared%push(id)
831 call local_face_dof%push(id)
833 call face_dof_local%push(id)
839 if (msh%facet_neigh(4, i) .ne. 0)
then
840 if (
dofmap%shared_dof(2, ly, 2, i))
then
844 call shared_face_dof%push(id)
846 call face_dof_shared%push(id)
853 call local_face_dof%push(id)
855 call face_dof_local%push(id)
862 if (msh%facet_neigh(5, i) .ne. 0)
then
863 if (
dofmap%shared_dof(2, 2, 1, i))
then
867 call shared_face_dof%push(id)
869 call face_dof_shared%push(id)
876 call local_face_dof%push(id)
878 call face_dof_local%push(id)
884 if (msh%facet_neigh(6, i) .ne. 0)
then
885 if (
dofmap%shared_dof(2, 2, lz, i))
then
889 call shared_face_dof%push(id)
891 call face_dof_shared%push(id)
898 call local_face_dof%push(id)
900 call face_dof_local%push(id)
911 gs%nlocal = local_dof%size() + local_face_dof%size()
912 gs%local_facet_offset = local_dof%size() + 1
915 allocate(gs%local_dof_gs(gs%nlocal))
922 select type(dof_array => local_dof%data)
926 gs%local_dof_gs(i) = dof_array(i)
929 call local_dof%free()
936 select type(dof_array => local_face_dof%data)
938 do i = 1, local_face_dof%size()
939 gs%local_dof_gs(i + j) = dof_array(i)
942 call local_face_dof%free()
945 allocate(gs%local_gs_dof(gs%nlocal))
952 select type(dof_array => dof_local%data)
956 gs%local_gs_dof(i) = dof_array(i)
959 call dof_local%free()
964 select type(dof_array => face_dof_local%data)
966 do i = 1, face_dof_local%size()
967 gs%local_gs_dof(i+j) = dof_array(i)
970 call face_dof_local%free()
973 gs%nlocal, 1, gs%nlocal)
976 gs%nlocal_blks, gs%nlocal, gs%local_facet_offset)
979 allocate(gs%local_gs(gs%nlocal))
981 gs%nshared = shared_dof%size() + shared_face_dof%size()
982 gs%shared_facet_offset = shared_dof%size() + 1
985 allocate(gs%shared_dof_gs(gs%nshared))
992 select type(dof_array => shared_dof%data)
994 j = shared_dof%size()
996 gs%shared_dof_gs(i) = dof_array(i)
999 call shared_dof%free()
1006 select type(dof_array => shared_face_dof%data)
1008 do i = 1, shared_face_dof%size()
1009 gs%shared_dof_gs(i + j) = dof_array(i)
1012 call shared_face_dof%free()
1015 allocate(gs%shared_gs_dof(gs%nshared))
1022 select type(dof_array => dof_shared%data)
1024 j = dof_shared%size()
1026 gs%shared_gs_dof(i) = dof_array(i)
1029 call dof_shared%free()
1034 select type(dof_array => face_dof_shared%data)
1036 do i = 1, face_dof_shared%size()
1037 gs%shared_gs_dof(i + j) = dof_array(i)
1040 call face_dof_shared%free()
1043 allocate(gs%shared_gs(gs%nshared))
1045 if (gs%nshared .gt. 0)
then
1047 gs%nshared, 1, gs%nshared)
1049 call gs_find_blks(gs%shared_dof_gs, gs%shared_blk_len, &
1050 gs%nshared_blks, gs%nshared, gs%shared_facet_offset)
1058 integer(kind=i8),
intent(inout) :: dof
1059 integer,
intent(inout) :: max_id
1062 if (map_%get(dof, id) .gt. 0)
then
1064 call map_%set(dof, max_id)
1072 integer,
intent(inout) :: n
1073 integer,
dimension(n),
intent(inout) :: dg
1074 integer,
dimension(n),
intent(inout) :: gd
1076 integer :: tmp, i, j, pivot
1080 pivot = dg((lo + hi) / 2)
1084 if (dg(i) .ge. pivot)
exit
1089 if (dg(j) .le. pivot)
exit
1100 else if (i .eq. j)
then
1114 integer,
intent(in) :: n
1115 integer,
intent(in) :: m
1116 integer,
dimension(n),
intent(inout) :: dg
1117 integer,
allocatable,
intent(inout) :: blk_len(:)
1118 integer,
intent(inout) :: nblks
1120 integer :: id, count
1129 do while ( j+1 .le. n .and. dg(j+1) .eq. id)
1133 call blks%push(count)
1137 select type(blk_array => blks%data)
1140 allocate(blk_len(nblks))
1142 blk_len(i) = blk_array(i)