Skip to content

Commit

Permalink
refactor(tsp): Elevate ADV to generalized transport class (MODFLOW-US…
Browse files Browse the repository at this point in the history
…GS#1391)

* refactor(tsp): Elevate ADV to generalized transport class

* Fix some _da() routines
  • Loading branch information
emorway-usgs authored Oct 11, 2023
1 parent c50ec80 commit 2c78169
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 138 deletions.
6 changes: 3 additions & 3 deletions make/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,9 @@ $(OBJDIR)/gwf3drn8.o \
$(OBJDIR)/IndexMap.o \
$(OBJDIR)/VirtualModel.o \
$(OBJDIR)/BaseExchange.o \
$(OBJDIR)/UzfCellGroup.o \
$(OBJDIR)/tsp1fmi1.o \
$(OBJDIR)/TspAdvOptions.o \
$(OBJDIR)/UzfCellGroup.o \
$(OBJDIR)/OutputControlData.o \
$(OBJDIR)/gwf3ic8.o \
$(OBJDIR)/Xt3dInterface.o \
Expand All @@ -220,6 +221,7 @@ $(OBJDIR)/ImsLinearSettings.o \
$(OBJDIR)/ConvergenceSummary.o \
$(OBJDIR)/CellWithNbrs.o \
$(OBJDIR)/NumericalExchange.o \
$(OBJDIR)/tsp1adv1.o \
$(OBJDIR)/gwf3disv8.o \
$(OBJDIR)/gwf3disu8.o \
$(OBJDIR)/gwf3dis8.o \
Expand All @@ -231,7 +233,6 @@ $(OBJDIR)/gwt1ic1.o \
$(OBJDIR)/gwt1mst1.o \
$(OBJDIR)/GwtDspOptions.o \
$(OBJDIR)/gwf3npf8.o \
$(OBJDIR)/GwtAdvOptions.o \
$(OBJDIR)/gwf3tvs8.o \
$(OBJDIR)/GwfStorageUtils.o \
$(OBJDIR)/Mover.o \
Expand Down Expand Up @@ -259,7 +260,6 @@ $(OBJDIR)/gwt1lkt1.o \
$(OBJDIR)/gwt1ist1.o \
$(OBJDIR)/gwt1dsp1.o \
$(OBJDIR)/gwt1cnc1.o \
$(OBJDIR)/gwt1adv1.o \
$(OBJDIR)/gwf3api8.o \
$(OBJDIR)/gwf3wel8.o \
$(OBJDIR)/gwf3rch8.o \
Expand Down
4 changes: 2 additions & 2 deletions msvs/mf6core.vfproj
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@
<File RelativePath="..\src\Model\GroundWaterFlow\gwf3wel8idm.f90"/></Filter>
<Filter Name="GroundWaterTransport">
<File RelativePath="..\src\Model\GroundWaterTransport\gwt1.f90"/>
<File RelativePath="..\src\Model\GroundWaterTransport\gwt1adv1.f90"/>
<File RelativePath="..\src\Model\GroundWaterTransport\gwt1apt1.f90"/>
<File RelativePath="..\src\Model\GroundWaterTransport\gwt1cnc1.f90"/>
<File RelativePath="..\src\Model\GroundWaterTransport\gwt1dis1idm.f90"/>
Expand Down Expand Up @@ -196,18 +195,19 @@
<File RelativePath="..\src\Model\ModelUtilities\GwfNpfOptions.f90"/>
<File RelativePath="..\src\Model\ModelUtilities\GwfStorageUtils.f90"/>
<File RelativePath="..\src\Model\ModelUtilities\GwfVscInputData.f90"/>
<File RelativePath="..\src\Model\ModelUtilities\GwtAdvOptions.f90"/>
<File RelativePath="..\src\Model\ModelUtilities\GwtDspOptions.f90"/>
<File RelativePath="..\src\Model\ModelUtilities\GwtSpc.f90"/>
<File RelativePath="..\src\Model\ModelUtilities\Mover.f90"/>
<File RelativePath="..\src\Model\ModelUtilities\PackageMover.f90"/>
<File RelativePath="..\src\Model\ModelUtilities\SfrCrossSectionManager.f90"/>
<File RelativePath="..\src\Model\ModelUtilities\SfrCrossSectionUtils.f90"/>
<File RelativePath="..\src\Model\ModelUtilities\TspAdvOptions.f90"/>
<File RelativePath="..\src\Model\ModelUtilities\UzfCellGroup.f90"/>
<File RelativePath="..\src\Model\ModelUtilities\Xt3dAlgorithm.f90"/>
<File RelativePath="..\src\Model\ModelUtilities\Xt3dInterface.f90"/></Filter>
<Filter Name="TransportModel">
<File RelativePath="..\src\Model\TransportModel\tsp1.f90"/>
<File RelativePath="..\src\Model\TransportModel\tsp1adv1.f90"/>
<File RelativePath="..\src\Model\TransportModel\tsp1fmi1.f90"/></Filter>
<File RelativePath="..\src\Model\BaseModel.f90"/>
<File RelativePath="..\src\Model\ExplicitModel.f90"/>
Expand Down
6 changes: 3 additions & 3 deletions src/Model/Connection/GwtInterfaceModel.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module GwtInterfaceModelModule
use GwtModule, only: GwtModelType, CastAsGwtModel
use GwfDisuModule, only: disu_cr, CastAsDisuType
use TspFmiModule, only: fmi_cr, TspFmiType
use GwtAdvModule, only: adv_cr, GwtAdvType
use GwtAdvOptionsModule, only: GwtAdvOptionsType
use TspAdvModule, only: adv_cr, TspAdvType
use TspAdvOptionsModule, only: TspAdvOptionsType
use GwtDspModule, only: dsp_cr, GwtDspType
use GwtDspOptionsModule, only: GwtDspOptionsType
use GwtMstModule, only: mst_cr
Expand Down Expand Up @@ -123,7 +123,7 @@ subroutine gwtifmod_df(this)
class(GwtInterfaceModelType) :: this !< the GWT interface model
! local
class(*), pointer :: disPtr
type(GwtAdvOptionsType) :: adv_options
type(TspAdvOptionsType) :: adv_options
type(GwtDspOptionsType) :: dsp_options

this%moffset = 0
Expand Down
37 changes: 14 additions & 23 deletions src/Model/GroundWaterTransport/gwt1.f90
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module GwtModule
use BndModule, only: BndType, AddBndToList, GetBndFromList
use GwtIcModule, only: GwtIcType
use TspFmiModule, only: TspFmiType
use GwtAdvModule, only: GwtAdvType
use GwtDspModule, only: GwtDspType
use GwtSsmModule, only: GwtSsmType
use GwtMvtModule, only: GwtMvtType
Expand All @@ -41,7 +40,6 @@ module GwtModule

type(GwtIcType), pointer :: ic => null() ! initial conditions package
type(GwtMstType), pointer :: mst => null() ! mass storage and transfer package
type(GwtAdvType), pointer :: adv => null() ! advection package
type(GwtDspType), pointer :: dsp => null() ! dispersion package
type(GwtSsmType), pointer :: ssm => null() ! source sink mixing package
type(GwtMvtType), pointer :: mvt => null() ! mover transport package
Expand All @@ -50,7 +48,6 @@ module GwtModule
integer(I4B), pointer :: inic => null() ! unit number IC
integer(I4B), pointer :: inmvt => null() ! unit number MVT
integer(I4B), pointer :: inmst => null() ! unit number MST
integer(I4B), pointer :: inadv => null() ! unit number ADV
integer(I4B), pointer :: indsp => null() ! DSP enabled flag
integer(I4B), pointer :: inssm => null() ! unit number SSM
integer(I4B), pointer :: inoc => null() ! unit number OC
Expand Down Expand Up @@ -88,6 +85,7 @@ module GwtModule
contains

!> @brief Create a new groundwater transport model object
!<
subroutine gwt_cr(filename, id, modelname)
! -- modules
use ListsModule, only: basemodellist
Expand Down Expand Up @@ -156,7 +154,7 @@ subroutine gwt_cr(filename, id, modelname)
! -- create model packages
call this%create_packages(indis)
!
! -- return
! -- Return
return
end subroutine gwt_cr

Expand Down Expand Up @@ -214,7 +212,7 @@ subroutine gwt_df(this)
! -- Store information needed for observations
call this%obs%obs_df(this%iout, this%name, 'GWT', this%dis)
!
! -- return
! -- Return
return
end subroutine gwt_df

Expand All @@ -241,11 +239,12 @@ subroutine gwt_ac(this, sparse)
call packobj%bnd_ac(this%moffset, sparse)
end do
!
! -- return
! -- Return
return
end subroutine gwt_ac

!> @brief Map connection positions in numerical solution coefficient matrix.
!<
subroutine gwt_mc(this, matrix_sln)
! -- dummy
class(GwtModelType) :: this
Expand All @@ -265,15 +264,14 @@ subroutine gwt_mc(this, matrix_sln)
call packobj%bnd_mc(this%moffset, matrix_sln)
end do
!
! -- return
! -- Return
return
end subroutine gwt_mc

!> @brief Allocate and Read
!
! (1) allocates and reads packages part of this model,
! (2) allocates memory for arrays part of this model object
!
!<
subroutine gwt_ar(this)
! -- modules
Expand Down Expand Up @@ -319,7 +317,7 @@ subroutine gwt_ar(this)
call packobj%bnd_ar()
end do
!
! -- return
! -- Return
return
end subroutine gwt_ar

Expand Down Expand Up @@ -405,7 +403,7 @@ subroutine gwt_ad(this)
! -- Push simulated values to preceding time/subtime step
call this%obs%obs_ad()
!
! -- return
! -- Return
return
end subroutine gwt_ad

Expand All @@ -425,7 +423,7 @@ subroutine gwt_cf(this, kiter)
call packobj%bnd_cf()
end do
!
! -- return
! -- Return
return
end subroutine gwt_cf

Expand Down Expand Up @@ -469,7 +467,7 @@ subroutine gwt_fc(this, kiter, matrix_sln, inwtflag)
call packobj%bnd_fc(this%rhs, this%ia, this%idxglo, matrix_sln)
end do
!
! -- return
! -- Return
return
end subroutine gwt_fc

Expand Down Expand Up @@ -499,7 +497,7 @@ subroutine gwt_cc(this, innertot, kiter, iend, icnvgmod, cpak, ipak, dpak)
! call packobj%bnd_cc(iend, icnvg, hclose, rclose)
! enddo
!
! -- return
! -- Return
return
end subroutine gwt_cc

Expand Down Expand Up @@ -554,7 +552,6 @@ end subroutine gwt_cq
!
! (1) Calculate intercell flows (flowja)
! (2) Calculate package contributions to model budget
!
!<
subroutine gwt_bd(this, icnvg, isuppress_output)
use ConstantsModule, only: DZERO
Expand Down Expand Up @@ -835,10 +832,11 @@ subroutine gwt_da(this)
! -- Internal flow packages deallocate
call this%dis%dis_da()
call this%ic%ic_da()
call this%fmi%fmi_da()
call this%adv%adv_da()
call this%dsp%dsp_da()
call this%ssm%ssm_da()
call this%mst%mst_da()
call this%adv%adv_da()
call this%mvt%mvt_da()
call this%budget%budget_da()
call this%oc%oc_da()
Expand All @@ -865,7 +863,6 @@ subroutine gwt_da(this)
!
! -- Scalars
call mem_deallocate(this%inic)
call mem_deallocate(this%inadv)
call mem_deallocate(this%indsp)
call mem_deallocate(this%inssm)
call mem_deallocate(this%inmst)
Expand Down Expand Up @@ -954,7 +951,6 @@ subroutine allocate_scalars(this, modelname)
!
! -- allocate members that are part of model class
call mem_allocate(this%inic, 'INIC', this%memoryPath)
call mem_allocate(this%inadv, 'INADV', this%memoryPath)
call mem_allocate(this%inmvt, 'INMVT', this%memoryPath)
call mem_allocate(this%inmst, 'INMST', this%memoryPath)
call mem_allocate(this%indsp, 'INDSP', this%memoryPath)
Expand All @@ -963,7 +959,6 @@ subroutine allocate_scalars(this, modelname)
call mem_allocate(this%inobs, 'INOBS', this%memoryPath)
!
this%inic = 0
this%inadv = 0
this%inmvt = 0
this%inmst = 0
this%indsp = 0
Expand Down Expand Up @@ -1050,6 +1045,7 @@ subroutine package_create(this, filtyp, ipakid, ipaknum, pakname, inunit, &
end subroutine package_create

!> @brief Cast to GwtModelType
!<
function CastAsGwtModel(model) result(gwtmodel)
class(*), pointer :: model !< The object to be cast
class(GwtModelType), pointer :: gwtmodel !< The GWT model
Expand Down Expand Up @@ -1133,7 +1129,6 @@ subroutine create_gwt_packages(this, indis)
use SimVariablesModule, only: idm_context
use GwtIcModule, only: ic_cr
use GwtMstModule, only: mst_cr
use GwtAdvModule, only: adv_cr
use GwtDspModule, only: dsp_cr
use GwtSsmModule, only: ssm_cr
use GwtMvtModule, only: mvt_cr
Expand Down Expand Up @@ -1185,8 +1180,6 @@ subroutine create_gwt_packages(this, indis)
this%inmvt = inunit
case ('MST6')
this%inmst = inunit
case ('ADV6')
this%inadv = inunit
case ('DSP6')
this%indsp = 1
mempathdsp = mempath
Expand All @@ -1208,8 +1201,6 @@ subroutine create_gwt_packages(this, indis)
! -- Create packages that are tied directly to model
call ic_cr(this%ic, this%name, this%inic, this%iout, this%dis)
call mst_cr(this%mst, this%name, this%inmst, this%iout, this%fmi)
call adv_cr(this%adv, this%name, this%inadv, this%iout, this%fmi, &
this%eqnsclfac)
call dsp_cr(this%dsp, this%name, mempathdsp, this%indsp, this%iout, &
this%fmi)
call ssm_cr(this%ssm, this%name, this%inssm, this%iout, this%fmi)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module GwtAdvOptionsModule
module TspAdvOptionsModule
use KindModule, only: I4B
implicit none
private

type, public :: GwtAdvOptionsType
type, public :: TspAdvOptionsType
integer(I4B) :: iAdvScheme !< the advection scheme: 0 = up, 1 = central, 2 = TVD
end type GwtAdvOptionsType
end type TspAdvOptionsType

end module GwtAdvOptionsModule
end module TspAdvOptionsModule
21 changes: 14 additions & 7 deletions src/Model/TransportModel/tsp1.f90
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module TransportModelModule
use SimVariablesModule, only: errmsg
use NumericalModelModule, only: NumericalModelType
use TspFmiModule, only: TspFmiType
use TspAdvModule, only: TspAdvType
use BudgetModule, only: BudgetType
use MatrixBaseModule

Expand All @@ -24,8 +25,10 @@ module TransportModelModule
type, extends(NumericalModelType) :: TransportModelType

type(TspFmiType), pointer :: fmi => null() ! flow model interface
type(TspAdvType), pointer :: adv => null() !< advection package
type(BudgetType), pointer :: budget => null() !< budget object
integer(I4B), pointer :: infmi => null() ! unit number FMI
integer(I4B), pointer :: inadv => null() !< unit number ADV
real(DP), pointer :: eqnsclfac => null() !< constant factor by which all terms in the model's governing equation are scaled (divided) for formulation and solution
! Labels that will be defined
character(len=LENVARNAME) :: tsptype = '' !< "solute" or "heat"
Expand Down Expand Up @@ -277,9 +280,11 @@ subroutine allocate_tsp_scalars(this, modelname)
!
! -- allocate members that are part of model class
call mem_allocate(this%infmi, 'INFMI', this%memoryPath)
call mem_allocate(this%inadv, 'INADV', this%memoryPath)
call mem_allocate(this%eqnsclfac, 'EQNSCLFAC', this%memoryPath)
!
this%infmi = 0
this%inadv = 0
this%eqnsclfac = DZERO
!
! -- Return
Expand Down Expand Up @@ -326,14 +331,9 @@ subroutine tsp_da(this)
class(TransportModelType) :: this
! -- local
!
! -- Internal flow packages deallocate
call this%fmi%fmi_da()
!
! -- Internal package objects
deallocate (this%fmi)
!
! -- Scalars
call mem_deallocate(this%infmi)
call mem_deallocate(this%inadv)
call mem_deallocate(this%eqnsclfac)
!
! -- Return
Expand Down Expand Up @@ -384,6 +384,8 @@ subroutine ftype_check(this, indis, inmst, inic)
return
end subroutine ftype_check

!> @brief Create listing output file
!<
subroutine create_lstfile(this, lst_fname, model_fname, defined)
! -- modules
use KindModule, only: LGP
Expand Down Expand Up @@ -432,7 +434,7 @@ subroutine create_lstfile(this, lst_fname, model_fname, defined)
return
end subroutine create_lstfile

!> @brief Write model namfile options to list file
!> @brief Write model name file options to list file
!<
subroutine log_namfile_options(this, found)
use GwfNamInputModule, only: GwfNamParamFoundType
Expand Down Expand Up @@ -486,6 +488,7 @@ subroutine create_tsp_packages(this, indis)
use GwfDisvModule, only: disv_cr
use GwfDisuModule, only: disu_cr
use TspFmiModule, only: fmi_cr
use TspAdvModule, only: adv_cr
! -- dummy
class(TransportModelType) :: this
integer(I4B), intent(inout) :: indis ! DIS enabled flag
Expand Down Expand Up @@ -538,12 +541,16 @@ subroutine create_tsp_packages(this, indis)
call disu_cr(this%dis, this%name, mempath, indis, this%iout)
case ('FMI6')
this%infmi = inunit
case ('ADV6')
this%inadv = inunit
end select
end do
!
! -- Create packages that are tied directly to model
call fmi_cr(this%fmi, this%name, this%infmi, this%iout, this%eqnsclfac, &
this%depvartype)
call adv_cr(this%adv, this%name, this%inadv, this%iout, this%fmi, &
this%eqnsclfac)
!
! -- Return
return
Expand Down
Loading

0 comments on commit 2c78169

Please sign in to comment.