!
!     module m_intersection_data_6
!
      module m_intersection_data_6
!
!      Written by H. Matsui on june, 2006
!
      use m_precision
!
      implicit none
!
!
!   3 nodes which have differrent sign on 1 edge and connected diagonal
!      (seven corners ... 5 triangles)
!
!     flag = 1: c-c_ref >= 0
!     flag = 1: c-c_ref < 0
!
      integer(kind = kint), parameter, private :: nnod_tri = 3
      integer(kind = kint), parameter, private :: nnod_sep = 7
!
      integer(kind = kint), parameter :: nkind_etype_6 = 24
      integer(kind = kint), parameter :: num_patch_6 =   5
      integer(kind = kint), parameter :: itri_2_patch_6(15)             &
     &     = (/6, 7, 5,   5, 7, 1,   5, 1, 4,   4, 1, 2,   4, 2, 3/)
!
!       12345678: boundary...7 of 12; seven corners
!                 (6-7-5), (5-7-1), (5-1-4), (4-1-2), (4-2-3)
! 131:  11000001: 7-8, 4-8, 4-1, 2-3, 2-6, 1-5, 8-5: 7-12-4-2-10- 9-8
!                   9-8-10, 10-8-7, 10-7-2, 2-7-12, 2-12-4
!  22:  01101000: 8-5, 1-5, 1-2, 3-4, 3-7, 2-6, 5-6: 8- 9-1-3-11-10-5
!                  10-5-11, 11-5-8, 11-8-3, 3-8- 9, 3- 9-1
!  44:  00110100: 5-6, 2-6, 2-3, 4-1, 4-8, 3-7, 6-7: 5-10-2-4-12-11-6
!                  11-6-12, 12-6-5, 12-5-4, 4-5-10, 4-10-2
!  73:  10010010: 6-7, 3-7, 3-4, 1-2, 1-5, 4-8, 7-8: 6-11-3-1- 9-12-7
!                  12-7- 9,  9-7-6,  9-6-1, 1-6-11, 1-11-3
!
!  56:  00011100: 3-4, 4-1, 1-5, 2-6, 6-7, 8-5, 4-8: 3-4- 9-10-6-8-12
!                  8-12-6, 6-12-3, 6-3-10, 10-3-4, 10-4- 9
!  97:  10000110: 4-1, 1-2, 2-6, 3-7, 7-8, 5-6, 1-5: 4-1-10-11-7-5- 9
!                  5- 9-7, 7- 9-4, 7-4-11, 11-4-1, 11-1-10
! 194:  01000011: 1-2, 2-3, 3-7, 4-8, 8-5, 6-7, 2-6: 1-2-11-12-8-6-10
!                  6-10-8, 8-10-1, 8-1-12, 12-1-2, 12-2-11
! 148:  00101001: 2-3, 3-4, 4-8, 1-5, 5-6, 7-8, 3-7: 2-3-12- 9-5-7-11
!                  7-11-5, 5-11-2, 5-2- 9,  9-2-3,  9-3-12
!
!  21:  10101000: 3-7, 2-3, 1-2, 5-6, 8-5, 4-1, 3-4; 11-2-1-5-8-4-3
!                 4-3-8, 8-3-11, 8-11-5, 5-11-2, 5-2-1
!  42:  01010100: 4-8, 3-4, 2-3, 6-7, 5-6, 1-2, 4-1: 12-3-2-6-5-1-4
!                  1-4-5, 5-4-12, 5-12-6, 6-12-3, 6-3-2
!  69:  10100010: 1-5, 4-1, 3-4, 7-8, 6-7, 2-3, 1-2:  9-4-3-7-6-2-1
!                  2-1-6, 6-1- 9, 6- 9-7, 7- 9-4, 7-4-3
! 138:  01010001: 2-6, 1-2, 4-1, 8-5, 7-8, 3-4, 2-3: 10-1-4-8-7-3-2
!                  3-2-7, 7-2-10, 7-10-8, 8-10-1, 8-1-4
!
!  67:  11000010: 7-8, 6-7, 2-6, 1-5, 4-1, 2-3, 3-7: 7-6-10- 9-4-2-11
!                  2-11-4, 4-11-7, 4-7- 9,  9-7-6,  9-6-10
! 134:  01100001: 8-5, 7-8, 3-7, 2-6, 1-2, 3-4, 4-8: 8-7-11-10-1-3-12
!                  3-12-1, 1-12-8, 1-8-10, 10-8-7, 10-7-11
!  28:  00111000: 5-6, 8-5, 4-8, 3-7, 2-3, 4-1, 1-5: 5-8-12-11-2-4- 9
!                  4- 9-2, 2- 9-5, 2-5-11, 11-5-8, 11-8-12
!  41:  10010100: 6-7, 5-6, 1-5, 4-8, 3-4, 1-2, 2-6: 6-5- 9-12-3-1-10
!                  1-10-3, 3-10-6, 3-6-12, 12-6-5, 12-5- 9
!
!  52:  00101100: 3-4, 3-7, 6-7, 8-5, 1-5, 2-6, 2-3: 3-11-6-8- 9-10-2
!                  10-2- 9,  9-2-3,  9-3-8, 8-3-11, 8-11-6
! 104:  00010110: 4-1, 4-8, 7-8, 5-6, 2-6, 3-7, 3-4: 4-12-7-5-10-11-3
!                  11-3-10, 10-3-4, 10-4-5, 5-4-12, 5-12-7
! 193:  10000011: 1-2, 1-5, 8-5, 6-7, 3-7, 4-8, 4-1: 1- 9-8-6-11-12-4
!                  12-4-11, 11-4-1, 11-1-6, 6-1- 9, 6- 9-8
! 146:  01001001: 2-3, 2-6, 5-6, 7-8, 4-8, 1-5, 1-2: 2-10-5-7-12- 9-1
!                   9-1-12, 12-1-2, 12-2-7, 7-2-10, 7-10-5
!
!  81:  10001010: 3-7, 7-8, 8-5, 4-1, 1-2, 5-6, 6-7: 11-7-8-4-1-5-6
!                  5-6-1, 1-6-11, 1-11-4, 4-11-7, 4-7-8
! 162:  01000101: 4-8, 8-5, 5-6, 1-2, 2-3, 6-7, 7-8: 12-8-5-1-2-6-7
!                  6-7-2, 2-7-12, 2-12-1, 1-12-8, 1-8-5
!  84:  00101010: 1-5, 5-6, 6-7, 2-3, 3-4, 7-8, 8-5:  9-5-6-2-3-7-8
!                  7-8-3, 3-8- 9, 3- 9-2, 2- 9-5, 2-5-6
! 168:  00010101: 2-6, 6-7, 7-8, 3-4, 4-1, 8-5, 5-6: 10-6-7-3-4-8-5
!                  8-5-4, 4-5-10, 4-10-3, 3-10-6, 3-6-7
!
!
!
!
!       12345678: boundary...7 of 12; seven corners
!                 (6-7-5), (5-7-1), (5-1-4), (4-1-2), (4-2-3)
! 124:  00111110: 7-8, 8-5, 1-5, 2-6, 2-3, 4-1, 4-8: 7-8- 9-10-2-4-12
!                  4-12-2, 2-12-7, 2-7-10, 10-7-8, 10-8- 9
! 233:  10010111: 8-5, 5-6, 2-6, 3-7, 3-4, 1-2, 1-5: 8-5-10-11-3-1- 9
!                  1- 9-3, 3- 9-8, 3-8-11, 11-8-5, 11-5-10
! 211:  11001011: 5-6, 6-7, 3-7, 4-8, 4-1, 2-3, 2-6: 5-6-11-12-4-2-10
!                  2-10-4, 4-10-5, 4-5-12, 12-5-6, 12-6-11
! 182:  01101101: 6-7, 7-8, 4-8, 1-5, 1-2, 3-4, 3-7: 6-7-12- 9-1-3-11
!                  3-11-1, 1-11-6, 1-6- 9,  9-6-7,  9-7-12
!
! 199:  11100011: 3-4, 4-8, 8-5, 6-7, 2-6, 1-5, 4-1: 3-12-8-6-10- 9-4
!                   9-4-10, 10-4-3, 10-3-6, 6-3-12, 6-12-8
! 158:  01111001: 4-1, 1-5, 5-6, 7-8, 3-7, 2-6, 1-2: 4- 9-5-7-11-10-1
!                  10-1-11, 11-1-4, 11-4-7, 7-4- 9, 7- 9-5
!  61:  10111100: 1-2, 2-6, 6-7, 8-5, 4-8, 3-7, 2-3: 1-10-6-8-12-11-2
!                  11-2-12, 12-2-1, 12-1-8, 8-1-10, 8-10-6
! 107:  11010110: 2-3, 3-7, 7-8, 5-6, 1-5, 4-8, 3-4: 2-11-7-5- 9-12-3
!                  12-3- 9,  9-3-2,  9-2-5, 5-2-11, 5-11-7
!
! 234:  01010111: 3-7, 3-4, 4-1, 8-5, 5-6, 1-2, 2-3: 11-3-4-8-5-1-2
!                  1-2-5, 5-2-11, 5-11-8, 8-11-3, 8-3-4
! 213:  10101011: 4-8, 4-1, 1-2, 5-6, 6-7, 2-3, 3-4: 12-4-1-5-6-2-3
!                  2-3-6, 6-3-12, 6-12-5, 5-12-4, 5-4-1
! 186:  01011101: 1-5, 1-2, 2-3, 6-7, 7-8, 3-4, 4-1:  9-1-2-6-7-3-4
!                  3-4-7, 7-4- 9, 7- 9-6, 6- 9-1, 6-1-2
! 117:  10101110: 2-6, 2-3, 3-4, 7-8, 8-5, 4-1, 1-2: 10-2-3-7-8-4-1
!                  4-1-8, 8-1-10, 8-10-7, 7-10-2, 7-2-3
!
! 188:  00111101: 7-8, 3-7, 2-3, 4-1, 1-5, 2-6, 6-7: 7-11-2-4- 9-10-6
!                  10-6- 9,  9-6-7,  9-7-4, 4-7-11, 4-11-2
! 121:  10011110: 8-5, 4-8, 3-4, 1-2, 2-6, 3-7, 7-8: 8-12-3-1-10-11-7
!                  11-7-10, 10-7-8, 10-8-1, 1-8-12, 1-12-3
! 227:  11000111: 5-6, 1-5, 4-1, 2-3, 3-7, 4-8, 8-5: 5- 9-4-2-11-12-8
!                  12-8-11, 11-8-5, 11-5-2, 2-5- 9, 2- 9-4
! 214:  01101011: 6-7, 2-6, 1-2, 3-4, 4-8, 1-5, 5-6: 6-10-1-3-12- 9-5
!                   9-5-12, 12-5-6, 12-6-3, 3-6-10, 3-10-1
!
! 203:  11010011: 3-4, 2-3, 2-6, 1-5, 8-5, 6-7, 3-7: 3-2-10- 9-8-6-11
!                  6-11-8, 8-11-3, 8-3- 9,  9-3-2,  9-2-10
! 151:  11101001: 4-1, 3-4, 3-7, 2-6, 5-6, 7-8, 4-8: 4-3-11-10-5-7-12
!                  7-12-5, 5-12-4, 5-4-10, 10-4-3, 10-3-11
!  62:  01111100: 1-2, 4-1, 4-8, 3-7, 6-7, 8-5, 1-5: 1-4-12-11-6-8- 9
!                  8- 9-6, 6- 9-1, 6-1-11, 11-1-4, 11-4-12
! 109:  10110110: 2-3, 1-2, 1-5, 4-8, 7-8, 5-6, 2-6: 2-1- 9-12-7-5-10
!                  5-10-7, 7-10-2, 7-2-12, 12-2-1, 12-1- 9

! 174:  01110101: 3-7, 6-7, 5-6, 1-2, 4-1, 8-5, 7-8: 11-6-5-1-4-8-7
!                  8-7-4, 4-7-11, 4-11-1, 1-11-6, 1-6-5
!  93:  10111010: 4-8, 7-8, 6-7, 2-3, 1-2, 5-6, 8-5: 12-7-6-2-1-5-8
!                  5-8-1, 1-8-12, 1-12-2, 2-12-7, 2-7-6
! 171:  11010101: 1-5, 8-5, 7-8, 3-4, 2-3, 6-7, 5-6:  9-8-7-3-2-6-5
!                  6-5-2, 2-5- 9, 2- 9-3, 3- 9-8, 3-8-7
!  87:  11101010: 2-6, 5-6, 8-5, 4-1, 3-4, 7-8, 6-7: 10-5-8-4-3-7-6
!                  7-6-3, 3-6-10, 3-10-4, 4-10-5, 4-5-8
!
      integer(kind = kint), parameter                                   &
     &   :: iflag_psf_etype_6p(nkind_etype_6)                           &
     &     = (/131,  22,  44,  73,    56,  97, 194, 148,                &
     &          21,  42,  69, 138,    67, 134,  28,  41,                &
     &          52, 104, 193, 146,    81, 162,  84, 168/)
      integer(kind = kint), parameter                                   &
     &   :: iflag_psf_etype_6n(nkind_etype_6)                           &
     &     = (/124, 233, 211, 182,   199, 158,  61, 107,                &
     &         234, 213, 186, 117,   188, 121, 227, 214,                &
     &         203, 151,  62, 109,   174,  93, 171,  87/)
!
!
      integer(kind = kint), parameter                                   &
     &        :: iedge_sep_6p(nnod_sep, nkind_etype_6)                  &
     &      = reshape(                                                  &
     &       (/ 7,12, 4, 2,10, 9, 8,    8, 9, 1, 3,11,10, 5,            &
     &          5,10, 2, 4,12,11, 6,    6,11, 3, 1, 9,12, 7,            &
     &          3, 4, 9,10, 6, 8,12,    4, 1,10,11, 7, 5, 9,            &
     &          1, 2,11,12, 8, 6,10,    2, 3,12, 9, 5, 7,11,            &
     &         11, 2, 1, 5, 8, 4, 3,   12, 3, 2, 6, 5, 1, 4,            &
     &          9, 4, 3, 7, 6, 2, 1,   10, 1, 4, 8, 7, 3, 2,            &
     &          7, 6,10, 9, 4, 2,11,    8, 7,11,10, 1, 3,12,            &
     &          5, 8,12,11, 2, 4, 9,    6, 5, 9,12, 3, 1,10,            &
     &          3,11, 6, 8, 9,10, 2,    4,12, 7, 5,10,11, 3,            &
     &          1, 9, 8, 6,11,12, 4,    2,10, 5, 7,12, 9, 1,            &
     &         11, 7, 8, 4, 1, 5, 6,   12, 8, 5, 1, 2, 6, 7,            &
     &          9, 5, 6, 2, 3, 7, 8,   10, 6, 7, 3, 4, 8, 5/),          &
     &       shape=(/nnod_sep, nkind_etype_6/) )
!
      integer(kind = kint), parameter                                   &
     &        :: iedge_sep_6n(nnod_sep, nkind_etype_6)                  &
     &      = reshape(                                                  &
     &       (/ 7, 8, 9,10, 2, 4,12,    8, 5,10,11, 3, 1, 9,            &
     &          5, 6,11,12, 4, 2,10,    6, 7,12, 9, 1, 3,11,            &
     &          3,12, 8, 6,10, 9, 4,    4, 9, 5, 7,11,10, 1,            &
     &          1,10, 6, 8,12,11, 2,    2,11, 7, 5, 9,12, 3,            &
     &         11, 3, 4, 8, 5, 1, 2,   12, 4, 1, 5, 6, 2, 3,            &
     &          9, 1, 2, 6, 7, 3, 4,   10, 2, 3, 7, 8, 4, 1,            &
     &          7,11, 2, 4, 9,10, 6,    8,12, 3, 1,10,11, 7,            &
     &          5, 9, 4, 2,11,12, 8,    6,10, 1, 3,12, 9, 5,            &
     &          3, 2,10, 9, 8, 6,11,    4, 3,11,10, 5, 7,12,            &
     &          1, 4,12,11, 6, 8, 9,    2, 1, 9,12, 7, 5,10,            &
     &         11, 6, 5, 1, 4, 8, 7,   12, 7, 6, 2, 1, 5, 8,            &
     &          9, 8, 7, 3, 2, 6, 5,   10, 5, 8, 4, 3, 7, 6 /),         &
     &       shape=(/nnod_sep, nkind_etype_6/) )
!
!
      integer(kind = kint), parameter                                   &
     &        :: iedge_4_patch_6p(nnod_tri,num_patch_6,nkind_etype_6)   &
     &      = reshape(                                                  &
     &       (/ 9, 8,10,  10, 8, 7,  10, 7, 2,   2, 7,12,   2,12, 4,    &
               10, 5,11,  11, 5, 8,  11, 8, 3,   3, 8, 9,   3, 9, 1,    &
               11, 6,12,  12, 6, 5,  12, 5, 4,   4, 5,10,   4,10, 2,    &
               12, 7, 9,   9, 7, 6,   9, 6, 1,   1, 6,11,   1,11, 3,    &
                8,12, 6,   6,12, 3,   6, 3,10,  10, 3, 4,  10, 4, 9,    &
                5, 9, 7,   7, 9, 4,   7, 4,11,  11, 4, 1,  11, 1,10,    &
                6,10, 8,   8,10, 1,   8, 1,12,  12, 1, 2,  12, 2,11,    &
                7,11, 5,   5,11, 2,   5, 2, 9,   9, 2, 3,   9, 3,12,    &
                4, 3, 8,   8, 3,11,   8,11, 5,   5,11, 2,   5, 2, 1,    &
                1, 4, 5,   5, 4,12,   5,12, 6,   6,12, 3,   6, 3, 2,    &
                2, 1, 6,   6, 1, 9,   6, 9, 7,   7, 9, 4,   7, 4, 3,    &
                3, 2, 7,   7, 2,10,   7,10, 8,   8,10, 1,   8, 1, 4,    &
                2,11, 4,   4,11, 7,   4, 7, 9,   9, 7, 6,   9, 6,10,    &
                3,12, 1,   1,12, 8,   1, 8,10,  10, 8, 7,  10, 7,11,    &
                4, 9, 2,   2, 9, 5,   2, 5,11,  11, 5, 8,  11, 8,12,    &
                1,10, 3,   3,10, 6,   3, 6,12,  12, 6, 5,  12, 5, 9,    &
               10, 2, 9,   9, 2, 3,   9, 3, 8,   8, 3,11,   8,11, 6,    &
               11, 3,10,  10, 3, 4,  10, 4, 5,   5, 4,12,   5,12, 7,    &
               12, 4,11,  11, 4, 1,  11, 1, 6,   6, 1, 9,   6, 9, 8,    &
                9, 1,12,  12, 1, 2,  12, 2, 7,   7, 2,10,   7,10, 5,    &
                5, 6, 1,   1, 6,11,   1,11, 4,   4,11, 7,   4, 7, 8,    &
                6, 7, 2,   2, 7,12,   2,12, 1,   1,12, 8,   1, 8, 5,    &
                7, 8, 3,   3, 8, 9,   3, 9, 2,   2, 9, 5,   2, 5, 6,    &
                8, 5, 4,   4, 5,10,   4,10, 3,   3,10, 6,   3, 6, 7/),  &
     &       shape=(/nnod_tri,num_patch_6,nkind_etype_6/) )
!
      integer(kind = kint), parameter                                   &
     &        :: iedge_4_patch_6n(nnod_tri,num_patch_6,nkind_etype_6)   &
     &      = reshape(                                                  &
     &       (/ 4,12, 2,   2,12, 7,   2, 7,10,  10, 7, 8,  10, 8, 9,    &
                1, 9, 3,   3, 9, 8,   3, 8,11,  11, 8, 5,  11, 5,10,    &
                2,10, 4,   4,10, 5,   4, 5,12,  12, 5, 6,  12, 6,11,    &
                3,11, 1,   1,11, 6,   1, 6, 9,   9, 6, 7,   9, 7,12,    &
                9, 4,10,  10, 4, 3,  10, 3, 6,   6, 3,12,   6,12, 8,    &
               10, 1,11,  11, 1, 4,  11, 4, 7,   7, 4, 9,   7, 9, 5,    &
               11, 2,12,  12, 2, 1,  12, 1, 8,   8, 1,10,   8,10, 6,    &
               12, 3, 9,   9, 3, 2,   9, 2, 5,   5, 2,11,   5,11, 7,    &
                1, 2, 5,   5, 2,11,   5,11, 8,   8,11, 3,   8, 3, 4,    &
                2, 3, 6,   6, 3,12,   6,12, 5,   5,12, 4,   5, 4, 1,    &
                3, 4, 7,   7, 4, 9,   7, 9, 6,   6, 9, 1,   6, 1, 2,    &
                4, 1, 8,   8, 1,10,   8,10, 7,   7,10, 2,   7, 2, 3,    &
               10, 6, 9,   9, 6, 7,   9, 7, 4,   4, 7,11,   4,11, 2,    &
               11, 7,10,  10, 7, 8,  10, 8, 1,   1, 8,12,   1,12, 3,    &
               12, 8,11,  11, 8, 5,  11, 5, 2,   2, 5, 9,   2, 9, 4,    &
                9, 5,12,  12, 5, 6,  12, 6, 3,   3, 6,10,   3,10, 1,    &
                6,11, 8,   8,11, 3,   8, 3, 9,   9, 3, 2,   9, 2,10,    &
                7,12, 5,   5,12, 4,   5, 4,10,  10, 4, 3,  10, 3,11,    &
                8, 9, 6,   6, 9, 1,   6, 1,11,  11, 1, 4,  11, 4,12,    &
                5,10, 7,   7,10, 2,   7, 2,12,  12, 2, 1,  12, 1, 9,    &
                8, 7, 4,   4, 7,11,   4,11, 1,   1,11, 6,   1, 6, 5,    &
                5, 8, 1,   1, 8,12,   1,12, 2,   2,12, 7,   2, 7, 6,    &
                6, 5, 2,   2, 5, 9,   2, 9, 3,   3, 9, 8,   3, 8, 7,    &
                7, 6, 3,   3, 6,10,   3,10, 4,   4,10, 5,   4, 5, 8/),  &
     &       shape=(/nnod_tri,num_patch_6,nkind_etype_6/) )
!
!
      end module m_intersection_data_6
