Wiki

Clone wiki

pflotran / Depreciated / Documentation / CodeDevelopment / MINC

Description of an example MINC problem

! num of representative element volume (REV) [or number of primary continua] = N (or nmax)
! num of secondary continua per REV = K
! num of secondary continua nodes for each secondary continua = M
!
! Total DOFs = N*K*M + M
!
! Assume N = 2, K = 3, M = 2 
!
! option%nflowdof = N*K*M + M = 14
!
!
!
! call VecGetArrayF90(field%flow_xx_loc,xx_loc_p, ierr);CHKERRQ(ierr)
!
! xx_loc_p(1) : DOF for 1st Primary continua
! xx_loc_p(2) : DOF for 1st node of 1st secondary continua within 1st Primary continua
! xx_loc_p(3) : DOF for 2nd node of 1st secondary continua within 1st Primary continua
! xx_loc_p(4) : DOF for 1st node of 2nd secondary continua within 1st Primary continua
! xx_loc_p(5) : DOF for 2nd node of 2nd secondary continua within 1st Primary continua
! xx_loc_p(6) : DOF for 1st node of 3rd secondary continua within 1st Primary continua
! xx_loc_p(7) : DOF for 1st node of 3rd secondary continua within 1st Primary continua
! xx_loc_p(8) : DOF for 2nd Primary continua
! xx_loc_p(9) : DOF for 1st node of 1st secondary continua within 2nd Primary continua
! xx_loc_p(10) : DOF for 2nd node of 1st secondary continua within 2nd Primary continua
! xx_loc_p(11) : DOF for 1st node of 2nd secondary continua within 2nd Primary continua
! xx_loc_p(12) : DOF for 2nd node of 2nd secondary continua within 2nd Primary continua
! xx_loc_p(13) : DOF for 1st node of 3rd secondary continua within 2nd Primary continua
! xx_loc_p(14) : DOF for 1st node of 3rd secondary continua within 2nd Primary continua
!
! call VecRestoreArrayF90(field%flow_xx_loc,xx_loc_p, ierr);CHKERRQ(ierr)

!
! An example of a DCCM could be the following :
!
! Primary                Secondary
! continua               continua
!
!               | -------- 3 -------- 2
!               | 
!    1 -------- | -------- 5 -------- 4
!    |          | 
!    |          | -------- 7 -------- 6
!    |                     |          |
!    |                     |          |
!    |                     |          |
!    |          | -------- 10 -------- 9
!    |          | 
!    8 -------- | -------- 12 -------- 11
!               | 
!               | -------- 14 -------- 13
!

Possible modifications of auxvars

!
! auxvar development option-1a: Extend the sizes of auxvars AND 
! keep the mapping of indices between PETSc Vectors and auxvars the same
!
subroutine RichardsSetupPatch()

  ! OLDER code
  !allocate(rich_auxvars(grid%ngmax))
  ! NEW code
  allocate(rich_auxvars(option%nflowdof))

! rich_auxvars(1) : DOF for 1st Primary continua
! rich_auxvars(2) : DOF for 1st node of 1st secondary continua within 1st Primary continua
! rich_auxvars(3) : DOF for 2nd node of 1st secondary continua within 1st Primary continua
! rich_auxvars(4) : DOF for 1st node of 2nd secondary continua within 1st Primary continua
! rich_auxvars(5) : DOF for 2nd node of 2nd secondary continua within 1st Primary continua
! rich_auxvars(6) : DOF for 1st node of 3rd secondary continua within 1st Primary continua
! rich_auxvars(7) : DOF for 1st node of 3rd secondary continua within 1st Primary continua
! rich_auxvars(8) : DOF for 2nd Primary continua
! rich_auxvars(9) : DOF for 1st node of 1st secondary continua within 2nd Primary continua
! rich_auxvars(10) : DOF for 2nd node of 1st secondary continua within 2nd Primary continua
! rich_auxvars(11) : DOF for 1st node of 2nd secondary continua within 2nd Primary continua
! rich_auxvars(12) : DOF for 2nd node of 2nd secondary continua within 2nd Primary continua
! rich_auxvars(13) : DOF for 1st node of 3rd secondary continua within 2nd Primary continua
! rich_auxvars(14) : DOF for 1st node of 3rd secondary continua within 2nd Primary continua

end subroutine RichardsSetupPatch
!
! auxvar development option-1b: Extend the sizes of auxvars AND 
! use different mapping of indices between PETSc Vectors and auxvars
!
subroutine RichardsSetupPatch()

  ! OLDER code
  !allocate(rich_auxvars(grid%ngmax))
  ! NEW code
  allocate(rich_auxvars(option%nflowdof))

! rich_auxvars(1)  = xx_loc_p(1) : DOF for 1st Primary continua
! rich_auxvars(2)  = xx_loc_p(8) : DOF for 2nd Primary continua
! rich_auxvars(3)  = xx_loc_p(2) : DOF for 1st node of 1st secondary continua within 1st Primary continua
! rich_auxvars(4)  = xx_loc_p(3) : DOF for 2nd node of 1st secondary continua within 1st Primary continua
! rich_auxvars(5)  = xx_loc_p(4) : DOF for 1st node of 2nd secondary continua within 1st Primary continua
! rich_auxvars(6)  = xx_loc_p(5) : DOF for 2nd node of 2nd secondary continua within 1st Primary continua
! rich_auxvars(7)  = xx_loc_p(6) : DOF for 1st node of 3rd secondary continua within 1st Primary continua
! rich_auxvars(8)  = xx_loc_p(7)  DOF for 1st node of 3rd secondary continua within 1st Primary continua
! rich_auxvars(9)  = xx_loc_p(9) : DOF for 1st node of 1st secondary continua within 2nd Primary continua
! rich_auxvars(10)  = xx_loc_p(10) : DOF for 2nd node of 1st secondary continua within 2nd Primary continua
! rich_auxvars(11)  = xx_loc_p(11) : DOF for 1st node of 2nd secondary continua within 2nd Primary continua
! rich_auxvars(12)  = xx_loc_p(12) : DOF for 2nd node of 2nd secondary continua within 2nd Primary continua
! rich_auxvars(13)  = xx_loc_p(13) : DOF for 1st node of 3rd secondary continua within 2nd Primary continua
! rich_auxvars(14)  = xx_loc_p(14) : DOF for 1st node of 3rd secondary continua within 2nd Primary continua

end subroutine RichardsSetupPatch
!
! auxvar development option-2: Use different auxvars for primary and secondary continua
!
subroutine RichardsSetupPatch()

  ! OLDER code
  !allocate(rich_auxvars(grid%ngmax))
  ! NEW code
  allocate(rich_auxvars(grid%ngmax))
  allocate(sec_rich_auxvars(option%nflowdof))

! rich_auxvars(1)  = xx_loc_p(1) : DOF for 1st Primary continua
! rich_auxvars(2)  = xx_loc_p(8) : DOF for 2nd Primary continua

! sec_rich_auxvars(1)  = xx_loc_p(2) : DOF for 1st node of 1st secondary continua within 1st Primary continua
! sec_rich_auxvars(2)  = xx_loc_p(3) : DOF for 2nd node of 1st secondary continua within 1st Primary continua
! sec_rich_auxvars(3)  = xx_loc_p(4) : DOF for 1st node of 2nd secondary continua within 1st Primary continua
! sec_rich_auxvars(4)  = xx_loc_p(5) : DOF for 2nd node of 2nd secondary continua within 1st Primary continua
! sec_rich_auxvars(5)  = xx_loc_p(6) : DOF for 1st node of 3rd secondary continua within 1st Primary continua
! sec_rich_auxvars(6)  = xx_loc_p(7) : DOF for 1st node of 3rd secondary continua within 1st Primary continua
! sec_rich_auxvars(7)  = xx_loc_p(9) : DOF for 1st node of 1st secondary continua within 2nd Primary continua
! sec_rich_auxvars(8)  = xx_loc_p(10) : DOF for 2nd node of 1st secondary continua within 2nd Primary continua
! sec_rich_auxvars(9)  = xx_loc_p(11) : DOF for 1st node of 2nd secondary continua within 2nd Primary continua
! sec_rich_auxvars(10)  = xx_loc_p(12) : DOF for 2nd node of 2nd secondary continua within 2nd Primary continua
! sec_rich_auxvars(11)  = xx_loc_p(13) : DOF for 1st node of 3rd secondary continua within 2nd Primary continua
! sec_rich_auxvars(12)  = xx_loc_p(14) : DOF for 1st node of 3rd secondary continua within 2nd Primary continua

end subroutine RichardsSetupPatch

Code modifications to support modified auxvars (incomplete)

! Original code
subroutine RichardsResidualPatch1(snes,xx,r,realization,ierr)

  connection_set_list => grid%internal_connection_set_list
  cur_connection_set => connection_set_list%first
  sum_connection = 0  
  do 

    if (.not.associated(cur_connection_set)) exit
    do iconn = 1, cur_connection_set%num_connections
      sum_connection = sum_connection + 1

      ghosted_id_up = cur_connection_set%id_up(iconn)
      ghosted_id_dn = cur_connection_set%id_dn(iconn)

      ...

      call RichardsFlux(rich_auxvars(ghosted_id_up), &
                        global_auxvars(ghosted_id_up), &
                        material_auxvars(ghosted_id_up), &
                        richards_parameter%sir(1,icap_up), &
                        rich_auxvars(ghosted_id_dn), &
                        global_auxvars(ghosted_id_dn), &
                        material_auxvars(ghosted_id_dn), &
                        richards_parameter%sir(1,icap_dn), &
                        cur_connection_set%area(iconn), &
                        cur_connection_set%dist(:,iconn), &
                        option,v_darcy,Res)
    enddo

    cur_connection_set => cur_connection_set%next
  enddo

subroutine RichardsResidualPatch1
! New code only for "auxvar development option-2"
!
subroutine RichardsResidualPatch3(snes,xx,r,realization,ierr)

  ! Loop over primary-to-secondary connection
  connection_set_list => grid%pri2sec_internal_connection_set_list
  cur_connection_set => connection_set_list%first
  sum_connection = 0  
  do 

    if (.not.associated(cur_connection_set)) exit
    do iconn = 1, cur_connection_set%num_connections
      sum_connection = sum_connection + 1

      ! Upwind cell is a primary continua
      ghosted_id_up = cur_connection_set%id_up(iconn)
      ! Downwind cell is a secondary continua
      ghosted_id_dn = cur_connection_set%id_dn(iconn)

      ...

      call RichardsFluxPri2Sec(rich_auxvars(ghosted_id_up), &
                        global_auxvars(ghosted_id_up), &
                        material_auxvars(ghosted_id_up), &
                        richards_parameter%sir(1,icap_up), &
                        sec_rich_auxvars(ghosted_id_dn), &
                        sec_global_auxvars(ghosted_id_dn), &
                        sec_material_auxvars(ghosted_id_dn), &
                        sec_richards_parameter%sir(1,icap_dn), &
                        cur_connection_set%area(iconn), &
                        cur_connection_set%dist(:,iconn), &
                        option,v_darcy,Res)
    enddo

    cur_connection_set => cur_connection_set%next
  enddo

  ! Loop over secondary-to-secondary connection
  connection_set_list => grid%sec2sec_internal_connection_set_list
  cur_connection_set => connection_set_list%first
  sum_connection = 0  
  do 

    if (.not.associated(cur_connection_set)) exit
    do iconn = 1, cur_connection_set%num_connections
      sum_connection = sum_connection + 1

      ghosted_id_up = cur_connection_set%id_up(iconn)
      ghosted_id_dn = cur_connection_set%id_dn(iconn)

      ...

      call RichardsFluxSec(sec_rich_auxvars(ghosted_id_up), &
                        sec_global_auxvars(ghosted_id_up), &
                        sec_material_auxvars(ghosted_id_up), &
                        sec_richards_parameter%sir(1,icap_up), &
                        sec_rich_auxvars(ghosted_id_dn), &
                        sec_global_auxvars(ghosted_id_dn), &
                        sec_material_auxvars(ghosted_id_dn), &
                        sec_richards_parameter%sir(1,icap_dn), &
                        cur_connection_set%area(iconn), &
                        cur_connection_set%dist(:,iconn), &
                        option,v_darcy,Res)
    enddo

    cur_connection_set => cur_connection_set%next
  enddo

subroutine RichardsResidualPatch3

Updated