Commits

Anonymous committed 0e37905

Updated linkage to reactive transport to include general phase.

Comments (0)

Files changed (7)

src/pflotran/general.F90

          GeneralSetPlotVariables, &
          GeneralCheckUpdatePre, &
          GeneralCheckUpdatePost, &
+         GeneralMapBCAuxvarsToGlobal, &
          GeneralDestroy
 
 contains
 
 ! ************************************************************************** !
 
+subroutine GeneralMapBCAuxvarsToGlobal(realization)
+  ! 
+  ! Deallocates variables associated with Richard
+  ! 
+  ! Author: Glenn Hammond
+  ! Date: 03/09/11
+  ! 
+
+  use Realization_class
+  use Option_module
+  use Patch_module
+  use Coupler_module
+  use Connection_module
+
+  implicit none
+
+  type(realization_type) :: realization
+  
+  type(option_type), pointer :: option
+  type(patch_type), pointer :: patch
+  type(coupler_type), pointer :: boundary_condition
+  type(connection_set_type), pointer :: cur_connection_set
+  type(general_auxvar_type), pointer :: gen_auxvars_bc(:)  
+  type(global_auxvar_type), pointer :: global_auxvars_bc(:)  
+
+  PetscInt :: sum_connection, iconn
+  
+  option => realization%option
+  patch => realization%patch
+
+  if (option%ntrandof == 0) return ! no need to update
+  
+  gen_auxvars_bc => patch%aux%General%auxvars_bc
+  global_auxvars_bc => patch%aux%Global%auxvars_bc
+  
+  boundary_condition => patch%boundary_conditions%first
+  sum_connection = 0    
+  do 
+    if (.not.associated(boundary_condition)) exit
+    cur_connection_set => boundary_condition%connection_set
+    do iconn = 1, cur_connection_set%num_connections
+      sum_connection = sum_connection + 1
+      global_auxvars_bc(sum_connection)%sat = &
+        gen_auxvars_bc(sum_connection)%sat
+      global_auxvars_bc(sum_connection)%den_kg = &
+        gen_auxvars_bc(sum_connection)%den_kg
+      global_auxvars_bc(sum_connection)%temp = &
+        gen_auxvars_bc(sum_connection)%temp
+    enddo
+    boundary_condition => boundary_condition%next
+  enddo
+  
+end subroutine GeneralMapBCAuxvarsToGlobal
+
+! ************************************************************************** !
+
 subroutine GeneralDestroy(realization)
   ! 
   ! Deallocates variables associated with Richard

src/pflotran/global_aux.F90

     PetscReal, pointer :: mass_balance_delta(:,:) ! kmol
     PetscReal, pointer :: reaction_rate(:)
     PetscReal, pointer :: reaction_rate_store(:)
-!   PetscReal, pointer :: reaction_rate_store(:,:)
-    PetscReal, pointer :: dphi(:,:)
-    PetscReal :: scco2_eq_logK ! SC CO2
+    PetscReal, pointer :: dphi(:,:) !geh: why here?
+!geh    PetscReal :: scco2_eq_logK ! SC CO2
   end type global_auxvar_type
   
   type, public :: global_type
   
   auxvar%istate = 0
 
-  allocate(auxvar%pres(option%nphase))
-  auxvar%pres = 0.d0
+  ! nullify everthing to begin with and allocate later
+  nullify(auxvar%pres)
+  nullify(auxvar%temp)
+  nullify(auxvar%sat)
+  nullify(auxvar%den)
+  nullify(auxvar%den_kg)
+  nullify(auxvar%pres_store)
+  nullify(auxvar%temp_store)
+  nullify(auxvar%sat_store)
+  nullify(auxvar%den_store)
+  nullify(auxvar%den_kg_store)
+  nullify(auxvar%fugacoeff)
+  nullify(auxvar%fugacoeff_store)
+  nullify(auxvar%m_nacl)
+  nullify(auxvar%xmass)
+  nullify(auxvar%reaction_rate)
+  nullify(auxvar%reaction_rate_store)
+  nullify(auxvar%mass_balance)
+  nullify(auxvar%mass_balance_delta)
+  nullify(auxvar%dphi)
+
+  if (option%nflowdof > 0) then
+    allocate(auxvar%den(option%nphase))
+    auxvar%den = 0.d0
+    allocate(auxvar%pres(option%nphase))
+    auxvar%pres = 0.d0
+  endif
   allocate(auxvar%temp(ONE_INTEGER))
   auxvar%temp = 0.d0
   allocate(auxvar%sat(option%nphase))
   auxvar%sat = 0.d0
-  allocate(auxvar%den(option%nphase))
-  auxvar%den = 0.d0
   allocate(auxvar%den_kg(option%nphase))
   auxvar%den_kg = 0.d0
-  allocate(auxvar%sat_store(option%nphase,TWO_INTEGER))
-  auxvar%sat_store = 0.d0
-  allocate(auxvar%den_kg_store(option%nphase,TWO_INTEGER))
-  auxvar%den_kg_store = 0.d0
-  allocate(auxvar%dphi(option%nphase,THREE_INTEGER))
-  auxvar%dphi = 0.d0
 
-  auxvar%scco2_eq_logK = 0.d0
-
+  ! need these for reactive transport only if if flow if computed
+  if (option%nflowdof > 0 .and. option%ntrandof > 0) then
+    allocate(auxvar%sat_store(option%nphase,TWO_INTEGER))
+    auxvar%sat_store = 0.d0
+    allocate(auxvar%den_kg_store(option%nphase,TWO_INTEGER))
+    auxvar%den_kg_store = 0.d0
+  endif
+ 
   select case(option%iflowmode)
+    case(RICHARDS_MODE)
+!      if (option%ntrandof > 0) then
+!        allocate(auxvar%den_store(option%nphase,TWO_INTEGER))
+!        auxvar%den_store = 0.d0
+!      endif
     case(IMS_MODE, MPH_MODE, FLASH2_MODE)
       allocate(auxvar%xmass(option%nphase))
       auxvar%xmass = 1.d0
       nullify(auxvar%reaction_rate)
       nullify(auxvar%reaction_rate_store)  
     case (G_MODE)
-      nullify(auxvar%xmass)
-      nullify(auxvar%pres_store)
-      nullify(auxvar%temp_store)
-      nullify(auxvar%fugacoeff)
-      nullify(auxvar%fugacoeff_store)
-      nullify(auxvar%den_store)
-      nullify(auxvar%m_nacl)
-      nullify(auxvar%reaction_rate)
-      nullify(auxvar%reaction_rate_store)  
+      if (option%ntrandof > 0) then
+        allocate(auxvar%pres_store(option%nphase,TWO_INTEGER))
+        auxvar%pres_store = 0.d0
+        allocate(auxvar%temp_store(option%nphase,TWO_INTEGER))
+        auxvar%temp_store = 0.d0
+        allocate(auxvar%den_kg_store(option%nphase,TWO_INTEGER))
+        auxvar%den_kg_store = 0.d0
+      endif
     case default
-      nullify(auxvar%xmass)
-      nullify(auxvar%pres_store)
-      nullify(auxvar%temp_store)
-      nullify(auxvar%fugacoeff)
-      nullify(auxvar%fugacoeff_store)
-      nullify(auxvar%den_store)
-      nullify(auxvar%m_nacl)
-      nullify(auxvar%reaction_rate)
-      nullify(auxvar%reaction_rate_store)
   end select
   
   if (option%iflag /= 0 .and. option%compute_mass_balance_new) then
     auxvar%mass_balance = 0.d0
     allocate(auxvar%mass_balance_delta(option%nflowspec,option%nphase))
     auxvar%mass_balance_delta = 0.d0
-  else
-    nullify(auxvar%mass_balance)
-    nullify(auxvar%mass_balance_delta)
   endif
   
 end subroutine GlobalAuxVarInit

src/pflotran/init.F90

                                  LIQUID_DENSITY)
     else
       call GlobalUpdateAuxVars(realization,TIME_T,0.d0)
+      call GlobalWeightAuxVars(realization,0.d0)
     endif
 
     ! initial concentrations must be assigned after densities are set !!!

src/pflotran/pm_general.F90

   ! Date: 03/14/13
   ! 
 
-  use General_module, only : GeneralUpdateSolution
+  use General_module, only : GeneralUpdateSolution, &
+                             GeneralMapBCAuxvarsToGlobal
 
   implicit none
   
   
   call PMSubsurfaceUpdateSolution(this)
   call GeneralUpdateSolution(this%realization)
+  call GeneralMapBCAuxvarsToGlobal(this%realization)
 
 end subroutine PMGeneralUpdateSolution     
 

src/pflotran/pm_rt.F90

   class(pm_rt_type) :: this
 
   call RTDestroy(this%realization)
+  ! destroyed in realization
+  nullify(this%comm1)
+  call this%commN%Destroy()
+  if (associated(this%commN)) deallocate(this%commN)
+  nullify(this%commN)  
 
 end subroutine PMRTDestroy
   

src/pflotran/pm_subsurface.F90

   
   class(pm_subsurface_type) :: this
   
-  call this%comm1%Destroy()
+  ! destroyed in realization
+  nullify(this%comm1)
   
 end subroutine PMSubsurfaceDestroy
   

src/pflotran/realization_base.F90

   endif
   nullify(realization_base%input)
   realization_base%discretization => DiscretizationCreate()
-  nullify(realization_base%comm1)
+  nullify(realization_base%comm1)  
   realization_base%field => FieldCreate()
   realization_base%debug => DebugCreate()
   realization_base%output_option => OutputOptionCreate()
   
   call DiscretizationDestroy(this%discretization)
   
+  if (associated(this%comm1)) then
+    call this%comm1%Destroy()
+    deallocate(this%comm1)
+  endif
+  nullify(this%comm1)
+  
   call PatchDestroyList(this%patch_list)
   nullify(this%patch)