MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
GwfInterfaceModel.f90
Go to the documentation of this file.
2 use kindmodule, only: i4b, dp
3 use constantsmodule, only: dzero
8 use xt3dmodule, only: xt3d_cr
9 use gwfbuymodule, only: buy_cr
12 use disumodule
13 use gwfnpfmodule
16 use gwfocmodule
17 implicit none
18 private
19
20 !> The GWF Interface Model is a utility to calculate the solution's
21 !! exchange coefficients from the interface between a GWF model and
22 !! its GWF neighbors. The interface model itself will not be part
23 !! of the solution, it is not being solved.
24 !! Patching (a part of the) discretizations of two GWF models in a
25 !! general way, e.g. DIS+DIS with refinement, requires the resulting
26 !< discretization to be of type DISU.
27 type, public, extends(gwfmodeltype) :: gwfinterfacemodeltype
28 class(gridconnectiontype), pointer :: gridconnection => null() !< The grid connection class will provide the interface grid
29 class(gwfmodeltype), private, pointer :: owner => null() !< the real GWF model for which the exchange coefficients
30 !! are calculated with this interface model
31 contains
32 procedure, pass(this) :: gwfifm_cr
33 procedure :: model_df => gwfifm_df
34 procedure :: model_ar => gwfifm_ar
35 procedure :: model_da => gwfifm_da
36
37 ! private
38 procedure, private, pass(this) :: setnpfoptions
39 procedure, private, pass(this) :: setbuydata
40 end type
41
42contains
43
44 !> @brief set up the interface model, analogously to what
45 !< happens in gwf_cr
46 subroutine gwfifm_cr(this, name, iout, gridConn)
47 class(gwfinterfacemodeltype) :: this !< the GWF interface model
48 character(len=*), intent(in) :: name !< the interface model's name
49 integer(I4B), intent(in) :: iout !< the output unit
50 class(gridconnectiontype), pointer, intent(in) :: gridConn !< the grid connection for creating a DISU
51 ! local
52 class(*), pointer :: modPtr
53
54 this%memoryPath = create_mem_path(name)
55 call this%allocate_scalars(name)
56
57 this%iout = iout
58
59 this%gridConnection => gridconn
60 modptr => this%gridConnection%model
61 this%owner => castasgwfmodel(modptr)
62
63 this%innpf = huge(1_i4b)
64 this%inewton = this%owner%inewton
65 this%inewtonur = this%owner%inewtonur
66
67 if (this%owner%inbuy > 0) then
68 this%inbuy = huge(1_i4b)
69 end if
70
71 ! create discretization and packages
72 call disu_cr(this%dis, this%name, '', -1, this%iout)
73 call npf_cr(this%npf, this%name, '', -this%innpf, this%iout)
74 call xt3d_cr(this%xt3d, this%name, -this%innpf, this%iout)
75 call buy_cr(this%buy, this%name, '', this%inbuy, this%iout)
76
77 end subroutine gwfifm_cr
78
79 !> @brief Define, mostly DISU and the NPF package
80 !< for this interface model
81 subroutine gwfifm_df(this)
82 class(gwfinterfacemodeltype) :: this !< the GWF interface model
83 ! local
84 type(gwfnpfoptionstype) :: npfOptions
85 type(gwfbuyinputdatatype) :: buyData
86 class(*), pointer :: disPtr
87
88 this%moffset = 0
89
90 ! define DISU
91 disptr => this%dis
92 call this%gridConnection%getDiscretization(castasdisutype(disptr))
93
94 ! define NPF package
95 call npfoptions%construct()
96 call this%setNpfOptions(npfoptions)
97 call this%npf%npf_df(this%dis, this%xt3d, 0, 0, npfoptions)
98 call npfoptions%destroy()
99
100 ! define BUY package
101 if (this%inbuy > 0) then
102 call buydata%construct(this%owner%buy%nrhospecies)
103 call this%setBuyData(buydata)
104 call this%buy%buy_df(this%dis, buydata)
105 call buydata%destruct()
106 end if
107
108 this%neq = this%dis%nodes
109 this%nja = this%dis%nja
110 this%ia => this%dis%con%ia
111 this%ja => this%dis%con%ja
112
113 call this%allocate_arrays()
114
115 end subroutine gwfifm_df
116
117 !> @brief allocate and read the packages
118 !<
119 subroutine gwfifm_ar(this)
120 class(gwfinterfacemodeltype) :: this !< the GWF interface model
121
122 call this%npf%npf_ar(this%ic, this%vsc, this%ibound, this%x)
123 if (this%inbuy > 0) call this%buy%buy_ar(this%npf, this%ibound)
124
125 end subroutine gwfifm_ar
126
127 !> @brief Clean up
128 !<
129 subroutine gwfifm_da(this)
131 class(gwfinterfacemodeltype) :: this !< the GWF interface model
132
133 ! -- Internal flow packages deallocate
134 call this%dis%dis_da()
135 call this%npf%npf_da()
136 call this%xt3d%xt3d_da()
137 call this%buy%buy_da()
138 !
139 ! -- Internal package objects
140 deallocate (this%dis)
141 deallocate (this%npf)
142 deallocate (this%xt3d)
143 !
144 ! -- Scalars
145 call mem_deallocate(this%inic)
146 call mem_deallocate(this%inoc)
147 call mem_deallocate(this%inobs)
148 call mem_deallocate(this%innpf)
149 call mem_deallocate(this%inbuy)
150 call mem_deallocate(this%invsc)
151 call mem_deallocate(this%insto)
152 call mem_deallocate(this%incsub)
153 call mem_deallocate(this%inmvr)
154 call mem_deallocate(this%inhfb)
155 call mem_deallocate(this%ingnc)
156 call mem_deallocate(this%iss)
157 call mem_deallocate(this%inewtonur)
158 !
159 ! -- NumericalModelType
160 call this%NumericalModelType%model_da()
161
162 end subroutine
163
164 !> @brief Copy NPF options from the model owning
165 !! the interface to the data structure
166 !<
167 subroutine setnpfoptions(this, npfOptions)
168 class(gwfinterfacemodeltype) :: this !< the GWF interface model
169 type(gwfnpfoptionstype) :: npfOptions !< the options data to be filled
170
171 ! for now, assuming full homogeneity, so just take
172 ! the options from the owning model's npf package
173 npfoptions%ithickstrt = this%owner%npf%ithickstrt
174 npfoptions%iperched = this%owner%npf%iperched
175 npfoptions%ivarcv = this%owner%npf%ivarcv
176 npfoptions%idewatcv = this%owner%npf%idewatcv
177 npfoptions%irewet = this%owner%npf%irewet
178 npfoptions%wetfct = this%owner%npf%wetfct
179 npfoptions%iwetit = this%owner%npf%iwetit
180 npfoptions%ihdwet = this%owner%npf%ihdwet
181 npfoptions%ihighcellsat = this%owner%npf%ihighcellsat
182
183 end subroutine setnpfoptions
184
185 !> @brief Sets the BUY input data from the models that
186 !! make up this interface. We adopt everything from the
187 !! owning model, but during validation it should be
188 !< checked that the models are compatible.
189 subroutine setbuydata(this, buyData)
190 class(gwfinterfacemodeltype) :: this !< the interface model
191 type(gwfbuyinputdatatype) :: buyData !< the data for the buoyancy package
192 ! local
193 integer(I4B) :: i
194
195 buydata%denseref = this%owner%buy%denseref
196 buydata%iform = this%owner%buy%iform
197 buydata%nrhospecies = this%owner%buy%nrhospecies
198
199 do i = 1, buydata%nrhospecies
200 buydata%drhodc(i) = this%owner%buy%drhodc(i)
201 buydata%crhoref(i) = this%owner%buy%crhoref(i)
202 buydata%cmodelname(i) = this%owner%buy%cmodelname(i)
203 buydata%cauxspeciesname(i) = this%owner%buy%cauxspeciesname(i)
204 end do
205
206 end subroutine setbuydata
207
This module contains simulation constants.
Definition Constants.f90:9
real(dp), parameter dzero
real constant zero
Definition Constants.f90:65
subroutine, public disu_cr(dis, name_model, input_mempath, inunit, iout)
Create a new unstructured discretization object.
Definition Disu.f90:135
class(disutype) function, pointer, public castasdisutype(dis)
Definition Disu.f90:2016
Refactoring issues towards parallel:
subroutine, public buy_cr(buyobj, name_model, input_mempath, inunit, iout)
Create a new BUY object.
Definition gwf-buy.f90:104
subroutine gwfifm_ar(this)
allocate and read the packages
subroutine gwfifm_df(this)
Define, mostly DISU and the NPF package.
subroutine setnpfoptions(this, npfoptions)
Copy NPF options from the model owning the interface to the data structure.
subroutine gwfifm_cr(this, name, iout, gridconn)
set up the interface model, analogously to what
subroutine gwfifm_da(this)
Clean up.
subroutine setbuydata(this, buydata)
Sets the BUY input data from the models that make up this interface. We adopt everything from the own...
class(gwfmodeltype) function, pointer, public castasgwfmodel(model)
Cast to GWF model.
Definition gwf.f90:1368
subroutine, public npf_cr(npfobj, name_model, input_mempath, inunit, iout)
Create a new NPF object. Pass a inunit value of 0 if npf data will initialized from memory.
Definition gwf-npf.f90:189
This module defines variable data types.
Definition kind.f90:8
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
subroutine model_df(this)
subroutine model_ar(this)
subroutine model_da(this)
subroutine, public xt3d_cr(xt3dobj, name_model, inunit, iout, ldispopt)
Create a new xt3d object.
This class is used to construct the connections object for the interface model's spatial discretizati...
Data structure to transfer input configuration to the.
The GWF Interface Model is a utility to calculate the solution's exchange coefficients from the inter...
Data structure and helper methods for passing NPF options into npf_df, as an alternative to reading t...