field.F90       coverage:  100.00 %func     66.18 %block


     1) module Field_module
     2) 
     3) ! IMPORTANT NOTE: This module can have no dependencies on other modules!!!
     4)  
     5)   use PFLOTRAN_Constants_module
     6) 
     7)   implicit none
     8) 
     9)   private
    10) 
    11) #include "petsc/finclude/petscsys.h"
    12) #include "petsc/finclude/petscvec.h"
    13) #include "petsc/finclude/petscvec.h90"
    14) 
    15)   type, public :: field_type 
    16)     
    17)     !get material id
    18)     ! 1 degree of freedom
    19)     Vec :: porosity0
    20)     Vec :: porosity_base_store
    21)     Vec :: porosity_t
    22)     Vec :: porosity_tpdt
    23)     Vec :: tortuosity0
    24)     Vec :: ithrm_loc
    25)     Vec :: icap_loc
    26)     Vec :: iphas_loc, iphas_old_loc
    27) 
    28)     Vec :: perm0_xx, perm0_yy, perm0_zz
    29)     !geh: required for higher order, but not supported at this time.
    30) !    Vec :: perm0_xz, perm0_xy, perm0_yz
    31)     
    32)     Vec :: work, work_loc
    33) 
    34)     Vec :: volume0
    35)     Vec :: compressibility0
    36)     
    37)     ! residual vectors
    38)     Vec :: flow_r          
    39)     Vec :: tran_r
    40)     
    41)     ! Solution vectors (yy = previous solution, xx = current iterate)
    42)     Vec :: flow_xx, flow_xx_loc, flow_dxx, flow_yy, flow_accum, flow_accum2
    43)     Vec :: tran_xx, tran_xx_loc, tran_dxx, tran_yy, tran_accum
    44) 
    45)     ! vectors for operator splitting
    46)     Vec :: tran_rhs
    47)     Vec :: tran_rhs_coef
    48)     
    49)     Vec :: tran_log_xx, tran_work_loc
    50)     
    51)     ! mass transfer
    52)     Vec :: flow_mass_transfer
    53)     Vec :: tran_mass_transfer
    54)     
    55)     Vec :: flow_ts_mass_balance, flow_total_mass_balance
    56)     Vec :: tran_ts_mass_balance, tran_total_mass_balance
    57) 
    58)     ! vector that holds the second layer of ghost cells for tvd
    59)     Vec :: tvd_ghosts
    60) 
    61)     ! vectors to save temporally average quantities
    62)     Vec, pointer :: avg_vars_vec(:)
    63)     PetscInt :: nvars
    64) 
    65)     ! vectors to save temporally average flowrates
    66)     Vec :: flowrate_inst
    67)     Vec :: flowrate_aveg
    68) 
    69)     ! vectors to save velocity at face
    70)     Vec :: vx_face_inst
    71)     Vec :: vy_face_inst
    72)     Vec :: vz_face_inst
    73) 
    74)     Vec, pointer :: max_change_vecs(:)
    75) 
    76)   end type field_type
    77) 
    78)   public :: FieldCreate, &
    79)             FieldDestroy
    80) 
    81) contains
    82) 
    83) ! ************************************************************************** !
    84) 
    85) function FieldCreate()
    86)   ! 
    87)   ! Allocates and initializes a new Field object
    88)   ! 
    89)   ! Author: Glenn Hammond
    90)   ! Date: 10/25/07
    91)   ! 
    92) 
    93)   implicit none
    94)   
    95)   type(field_type), pointer :: FieldCreate
    96)   
    97)   type(field_type), pointer :: field
    98)   
    99)   allocate(field)
   100)   
   101)   ! nullify PetscVecs
   102)   field%porosity0 = 0
   103)   field%porosity_base_store = 0
   104)   field%porosity_t = 0
   105)   field%porosity_tpdt = 0
   106)   field%tortuosity0 = 0
   107)   field%ithrm_loc = 0
   108)   field%icap_loc = 0
   109)   field%iphas_loc = 0
   110)   field%iphas_old_loc = 0
   111) 
   112)   field%perm0_xx = 0
   113)   field%perm0_yy = 0
   114)   field%perm0_zz = 0
   115)   
   116)   field%work = 0
   117)   field%work_loc = 0
   118) 
   119)   field%volume0 = 0
   120)   field%compressibility0 = 0
   121)   
   122)   field%flow_r = 0
   123)   field%flow_xx = 0
   124)   field%flow_xx_loc = 0
   125)   field%flow_dxx = 0
   126)   field%flow_yy = 0
   127)   field%flow_accum = 0
   128)   field%flow_accum2 = 0
   129) 
   130)   field%tran_r = 0
   131)   field%tran_log_xx = 0
   132)   field%tran_xx = 0
   133)   field%tran_xx_loc = 0
   134)   field%tran_dxx = 0
   135)   field%tran_yy = 0
   136)   field%tran_accum = 0
   137)   field%tran_work_loc = 0
   138) 
   139)   field%tvd_ghosts = 0
   140) 
   141)   field%tran_rhs = 0
   142)   field%tran_rhs_coef = 0
   143)   
   144)   field%flow_mass_transfer = 0
   145)   field%tran_mass_transfer = 0
   146)   
   147)   field%flow_ts_mass_balance = 0
   148)   field%flow_total_mass_balance = 0
   149)   field%tran_ts_mass_balance = 0
   150)   field%tran_total_mass_balance = 0
   151) 
   152)   nullify(field%avg_vars_vec)
   153)   field%nvars = 0
   154) 
   155)   field%flowrate_inst = 0
   156)   field%flowrate_aveg = 0
   157) 
   158)   field%vx_face_inst = 0
   159)   field%vy_face_inst = 0
   160)   field%vz_face_inst = 0
   161) 
   162)   nullify(field%max_change_vecs)
   163) 
   164)   FieldCreate => field
   165)   
   166) end function FieldCreate
   167) 
   168) ! ************************************************************************** !
   169) 
   170) subroutine FieldDestroy(field)
   171)   ! 
   172)   ! Deallocates a field object
   173)   ! 
   174)   ! Author: Glenn Hammond
   175)   ! Date: 11/15/07
   176)   ! 
   177) 
   178)   implicit none
   179)   
   180)   type(field_type), pointer :: field
   181)   
   182)   PetscErrorCode :: ierr
   183)   PetscInt :: ivar
   184)   PetscInt :: num_vecs
   185) 
   186)   if (.not.associated(field)) return
   187) 
   188)   ! Destroy PetscVecs
   189)   if (field%porosity0 /= 0) then
   190)     call VecDestroy(field%porosity0,ierr);CHKERRQ(ierr)
   191)   endif
   192)   if (field%porosity_base_store /= 0) then
   193)     call VecDestroy(field%porosity_base_store,ierr);CHKERRQ(ierr)
   194)   endif
   195)   if (field%porosity_t /= 0) then
   196)     call VecDestroy(field%porosity_t,ierr);CHKERRQ(ierr)
   197)   endif
   198)   if (field%porosity_tpdt /= 0) then
   199)     call VecDestroy(field%porosity_tpdt,ierr);CHKERRQ(ierr)
   200)   endif
   201)   if (field%tortuosity0 /= 0) then
   202)     call VecDestroy(field%tortuosity0,ierr);CHKERRQ(ierr)
   203)   endif
   204)   if (field%ithrm_loc /= 0) then
   205)     call VecDestroy(field%ithrm_loc,ierr);CHKERRQ(ierr)
   206)   endif
   207)   if (field%icap_loc /= 0) then
   208)     call VecDestroy(field%icap_loc,ierr);CHKERRQ(ierr)
   209)   endif
   210)   if (field%iphas_loc /= 0) then
   211)     call VecDestroy(field%iphas_loc,ierr);CHKERRQ(ierr)
   212)   endif
   213)   if (field%iphas_old_loc /= 0) then
   214)     call VecDestroy(field%iphas_old_loc,ierr);CHKERRQ(ierr)
   215)   endif
   216) 
   217)   if (field%perm0_xx /= 0) then
   218)     call VecDestroy(field%perm0_xx,ierr);CHKERRQ(ierr)
   219)   endif
   220)   if (field%perm0_yy /= 0) then
   221)     call VecDestroy(field%perm0_yy,ierr);CHKERRQ(ierr)
   222)   endif
   223)   if (field%perm0_zz /= 0) then
   224)     call VecDestroy(field%perm0_zz,ierr);CHKERRQ(ierr)
   225)   endif
   226)   
   227)   if (field%work /= 0) then
   228)     call VecDestroy(field%work,ierr);CHKERRQ(ierr)
   229)   endif
   230)   if (field%work_loc /= 0) then
   231)     call VecDestroy(field%work_loc,ierr);CHKERRQ(ierr)
   232)   endif
   233) 
   234)   if (field%volume0 /= 0) then
   235)     call VecDestroy(field%volume0,ierr);CHKERRQ(ierr)
   236)   endif
   237) 
   238)   if (field%compressibility0 /= 0) then
   239)     call VecDestroy(field%compressibility0,ierr);CHKERRQ(ierr)
   240)   endif
   241)  
   242)   if (field%flow_r /= 0) then
   243)     call VecDestroy(field%flow_r,ierr);CHKERRQ(ierr)
   244)   endif
   245)   if (field%flow_xx /= 0) then
   246)     call VecDestroy(field%flow_xx,ierr);CHKERRQ(ierr)
   247)   endif
   248)   if (field%flow_xx_loc /= 0) then
   249)     call VecDestroy(field%flow_xx_loc,ierr);CHKERRQ(ierr)
   250)   endif
   251)   if (field%flow_dxx /= 0) then
   252)     call VecDestroy(field%flow_dxx,ierr);CHKERRQ(ierr)
   253)   endif
   254)   if (field%flow_yy /= 0) then
   255)     call VecDestroy(field%flow_yy,ierr);CHKERRQ(ierr)
   256)   endif
   257)   if (field%flow_accum /= 0) then
   258)     call VecDestroy(field%flow_accum,ierr);CHKERRQ(ierr)
   259)   endif
   260)   if (field%flow_accum2 /= 0) then
   261)     call VecDestroy(field%flow_accum2,ierr);CHKERRQ(ierr)
   262)   endif
   263)   
   264)   if (field%tran_r /= 0) then
   265)     call VecDestroy(field%tran_r,ierr);CHKERRQ(ierr)
   266)   endif
   267)   if (field%tran_log_xx /= 0) then
   268)     call VecDestroy(field%tran_log_xx,ierr);CHKERRQ(ierr)
   269)   endif
   270)   if (field%tran_xx /= 0) then
   271)     call VecDestroy(field%tran_xx,ierr);CHKERRQ(ierr)
   272)   endif
   273)   if (field%tran_xx_loc /= 0) then
   274)     call VecDestroy(field%tran_xx_loc,ierr);CHKERRQ(ierr)
   275)   endif
   276)   if (field%tran_dxx /= 0) then
   277)     call VecDestroy(field%tran_dxx,ierr);CHKERRQ(ierr)
   278)   endif
   279)   if (field%tran_yy /= 0) then
   280)     call VecDestroy(field%tran_yy,ierr);CHKERRQ(ierr)
   281)   endif
   282)   if (field%tran_accum /= 0) then
   283)     call VecDestroy(field%tran_accum,ierr);CHKERRQ(ierr)
   284)   endif
   285)   if (field%tran_work_loc /= 0) then
   286)     call VecDestroy(field%tran_work_loc,ierr);CHKERRQ(ierr)
   287)   endif
   288)   
   289)   if (field%tran_rhs /= 0) then
   290)     call VecDestroy(field%tran_rhs,ierr);CHKERRQ(ierr)
   291)   endif
   292)   if (field%tran_rhs_coef /= 0) then
   293)     call VecDestroy(field%tran_rhs_coef,ierr);CHKERRQ(ierr)
   294)   endif
   295) 
   296)   if (field%flow_mass_transfer /= 0) then
   297)     call VecDestroy(field%flow_mass_transfer,ierr);CHKERRQ(ierr)
   298)   endif
   299)   if (field%tran_mass_transfer /= 0) then
   300)     call VecDestroy(field%tran_mass_transfer,ierr);CHKERRQ(ierr)
   301)   endif
   302) 
   303)   if (field%flow_ts_mass_balance /= 0) then
   304)     call VecDestroy(field%flow_ts_mass_balance,ierr);CHKERRQ(ierr)
   305)   endif
   306)   if (field%flow_total_mass_balance /= 0) then
   307)     call VecDestroy(field%flow_total_mass_balance,ierr);CHKERRQ(ierr)
   308)   endif
   309)   if (field%tran_ts_mass_balance /= 0) then
   310)     call VecDestroy(field%tran_ts_mass_balance,ierr);CHKERRQ(ierr)
   311)   endif
   312)   if (field%tran_total_mass_balance /= 0) then
   313)     call VecDestroy(field%tran_total_mass_balance,ierr);CHKERRQ(ierr)
   314)   endif
   315)     
   316)   if (field%tvd_ghosts /= 0) then
   317)     call VecDestroy(field%tvd_ghosts,ierr);CHKERRQ(ierr)
   318)   endif
   319) 
   320)   do ivar = 1,field%nvars
   321)     call VecDestroy(field%avg_vars_vec(ivar),ierr);CHKERRQ(ierr)
   322)   enddo
   323) 
   324)   if (field%flowrate_inst/=0) then
   325)     call VecDestroy(field%flowrate_inst,ierr);CHKERRQ(ierr)
   326)   endif
   327)   if (field%flowrate_aveg/=0) then
   328)     call VecDestroy(field%flowrate_aveg,ierr);CHKERRQ(ierr)
   329)   endif
   330) 
   331)   if (field%vx_face_inst/=0) then
   332)     call VecDestroy(field%vx_face_inst,ierr);CHKERRQ(ierr)
   333)   endif
   334)   if (field%vy_face_inst/=0) then
   335)     call VecDestroy(field%vy_face_inst,ierr);CHKERRQ(ierr)
   336)   endif
   337)   if (field%vz_face_inst/=0) then
   338)     call VecDestroy(field%vz_face_inst,ierr);CHKERRQ(ierr)
   339)   endif
   340) 
   341)   if (associated(field%max_change_vecs)) then
   342)     !geh: kludge as the compiler returns i4 in 64-bit
   343)     num_vecs = size(field%max_change_vecs)
   344)     call VecDestroyVecsF90(num_vecs,field%max_change_vecs,ierr);CHKERRQ(ierr)
   345)   endif
   346) 
   347)   deallocate(field)
   348)   nullify(field)
   349)   
   350) end subroutine FieldDestroy
   351) 
   352) end module Field_module

generated by
Intel(R) C++/Fortran Compiler code-coverage tool
Web-Page Owner: Nobody