MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
GwtInterfaceModel.f90
Go to the documentation of this file.
2  use kindmodule, only: i4b, dp
3  use constantsmodule, only: done
9  use tspfmimodule, only: fmi_cr, tspfmitype
10  use tspadvmodule, only: adv_cr, tspadvtype
12  use gwtdspmodule, only: dsp_cr, gwtdsptype
14  use gwtmstmodule, only: mst_cr
15  use tspobsmodule, only: tsp_obs_cr
17 
18  implicit none
19  private
20 
21  !> The GWT Interface Model is a utility to calculate the solution's exchange
22  !! coefficients from the interface between a GWT model and its GWT neighbors.
23  !! The interface model itself will not be part of the solution, it is not
24  !! being solved.
25  !<
26  type, public, extends(gwtmodeltype) :: gwtinterfacemodeltype
27 
28  integer(i4B), pointer :: iadvscheme => null() !< the advection scheme: 0 = up, 1 = central, 2 = tvd
29  integer(i4B), pointer :: ixt3d => null() !< xt3d setting: 0 = off, 1 = lhs, 2 = rhs
30  real(dp), pointer :: ieqnsclfac => null() !< governing eqn scaling factor: 1: GWT, >1: GWE
31 
32  class(gridconnectiontype), pointer :: gridconnection => null() !< The grid connection class will provide the interface grid
33  class(gwtmodeltype), private, pointer :: owner => null() !< the real GWT model for which the exchange coefficients
34  !! are calculated with this interface model
35 
36  contains
37  procedure, pass(this) :: gwtifmod_cr
38  procedure :: model_df => gwtifmod_df
39  procedure :: model_ar => gwtifmod_ar
40  procedure :: model_da => gwtifmod_da
41  procedure, public :: allocate_fmi
42  procedure :: allocate_scalars
43  end type gwtinterfacemodeltype
44 
45 contains
46 
47  !> @brief Create the interface model, analogously to what
48  !< happens in gwt_cr
49  subroutine gwtifmod_cr(this, name, iout, gridConn)
50  ! -- dummy
51  class(gwtinterfacemodeltype) :: this !< the GWT interface model
52  character(len=*), intent(in) :: name !< the interface model's name
53  integer(I4B), intent(in) :: iout !< the output unit
54  class(gridconnectiontype), pointer, intent(in) :: gridConn !< the grid connection data for creating a DISU
55  ! local
56  class(*), pointer :: modelPtr
57  integer(I4B), target :: inobs
58  integer(I4B) :: adv_unit, dsp_unit
59  !
60  this%memoryPath = create_mem_path(name)
61  call this%allocate_scalars(name)
62  !
63  ! defaults
64  this%iAdvScheme = 0
65  this%ixt3d = 0
66  this%ieqnsclfac = done
67  !
68  this%iout = iout
69  this%gridConnection => gridconn
70  modelptr => gridconn%model
71  this%owner => castasgwtmodel(modelptr)
72  !
73  inobs = 0
74  adv_unit = 0
75  dsp_unit = 0
76  if (this%owner%inadv > 0) then
77  this%inadv = huge(1_i4b)
78  adv_unit = huge(1_i4b)
79  end if
80  if (this%owner%indsp > 0) then
81  this%indsp = huge(1_i4b)
82  dsp_unit = huge(1_i4b)
83  end if
84  !
85  ! create dis and packages
86  call disu_cr(this%dis, this%name, '', -1, this%iout)
87  call fmi_cr(this%fmi, this%name, 0, this%iout, this%ieqnsclfac, &
88  this%depvartype)
89  call adv_cr(this%adv, this%name, adv_unit, this%iout, this%fmi, &
90  this%ieqnsclfac)
91  call dsp_cr(this%dsp, this%name, '', -dsp_unit, this%iout, this%fmi)
92  call tsp_obs_cr(this%obs, inobs)
93  !
94  ! -- Return
95  return
96  end subroutine gwtifmod_cr
97 
98  !> @brief Allocate scalars associated with the interface model object
99  !<
100  subroutine allocate_scalars(this, modelname)
101  ! -- dummy
102  class(gwtinterfacemodeltype) :: this !< the GWT interface model
103  character(len=*), intent(in) :: modelname !< the model name
104  !
105  call this%GwtModelType%allocate_scalars(modelname)
106  !
107  call mem_allocate(this%iAdvScheme, 'ADVSCHEME', this%memoryPath)
108  call mem_allocate(this%ixt3d, 'IXT3D', this%memoryPath)
109  call mem_allocate(this%ieqnsclfac, 'IEQNSCLFAC', this%memoryPath)
110  !
111  ! -- Return
112  return
113  end subroutine allocate_scalars
114 
115  !> @brief Allocate a Flow Model Interface (FMI) object for the interface model
116  !<
117  subroutine allocate_fmi(this)
118  ! -- dummy
119  class(gwtinterfacemodeltype) :: this !< the GWT interface model
120  !
121  call mem_allocate(this%fmi%gwfflowja, this%nja, 'GWFFLOWJA', &
122  this%fmi%memoryPath)
123  call mem_allocate(this%fmi%gwfhead, this%neq, 'GWFHEAD', &
124  this%fmi%memoryPath)
125  call mem_allocate(this%fmi%gwfsat, this%neq, 'GWFSAT', &
126  this%fmi%memoryPath)
127  call mem_allocate(this%fmi%gwfspdis, 3, this%neq, 'GWFSPDIS', &
128  this%fmi%memoryPath)
129  !
130  ! -- Return
131  return
132  end subroutine allocate_fmi
133 
134  !> @brief Define the GWT interface model
135  !<
136  subroutine gwtifmod_df(this)
137  ! -- dummy
138  class(gwtinterfacemodeltype) :: this !< the GWT interface model
139  ! -- local
140  class(*), pointer :: disPtr
141  type(tspadvoptionstype) :: adv_options
142  type(gwtdspoptionstype) :: dsp_options
143  !
144  this%moffset = 0
145  adv_options%iAdvScheme = this%iAdvScheme
146  dsp_options%ixt3d = this%ixt3d
147  !
148  ! define DISU
149  disptr => this%dis
150  call this%gridConnection%getDiscretization(castasdisutype(disptr))
151  call this%fmi%fmi_df(this%dis, 1)
152  !
153  if (this%inadv > 0) then
154  call this%adv%adv_df(adv_options)
155  end if
156  if (this%indsp > 0) then
157  this%dsp%idiffc = this%owner%dsp%idiffc
158  this%dsp%idisp = this%owner%dsp%idisp
159  call this%dsp%dsp_df(this%dis, dsp_options)
160  if (this%dsp%idiffc > 0) then
161  call mem_reallocate(this%dsp%diffc, this%dis%nodes, 'DIFFC', &
162  trim(this%dsp%memoryPath))
163  end if
164  if (this%dsp%idisp > 0) then
165  call mem_reallocate(this%dsp%alh, this%dis%nodes, 'ALH', &
166  trim(this%dsp%memoryPath))
167  call mem_reallocate(this%dsp%alv, this%dis%nodes, 'ALV', &
168  trim(this%dsp%memoryPath))
169  call mem_reallocate(this%dsp%ath1, this%dis%nodes, 'ATH1', &
170  trim(this%dsp%memoryPath))
171  call mem_reallocate(this%dsp%ath2, this%dis%nodes, 'ATH2', &
172  trim(this%dsp%memoryPath))
173  call mem_reallocate(this%dsp%atv, this%dis%nodes, 'ATV', &
174  trim(this%dsp%memoryPath))
175  end if
176  allocate (this%mst)
177  call mem_allocate(this%mst%thetam, this%dis%nodes, &
178  'THETAM', create_mem_path(this%name, 'MST'))
179  end if
180  !
181  ! assign or point model members to dis members
182  this%neq = this%dis%nodes
183  this%nja = this%dis%nja
184  this%ia => this%dis%con%ia
185  this%ja => this%dis%con%ja
186  !
187  ! allocate model arrays, now that neq and nja are assigned
188  call this%allocate_arrays()
189  !
190  ! -- Return
191  return
192  end subroutine gwtifmod_df
193 
194  !> @brief Override allocate and read the GWT interface model and its packages
195  !! so that we can create stuff from memory instead of input files
196  !<
197  subroutine gwtifmod_ar(this)
198  ! -- dummy
199  class(gwtinterfacemodeltype) :: this !< the GWT interface model
200  !
201  call this%fmi%fmi_ar(this%ibound)
202  if (this%inadv > 0) then
203  call this%adv%adv_ar(this%dis, this%ibound)
204  end if
205  if (this%indsp > 0) then
206  call this%dsp%dsp_ar(this%ibound, this%mst%thetam)
207  end if
208  !
209  ! -- Return
210  return
211  end subroutine gwtifmod_ar
212 
213  !> @brief Clean up resources
214  !<
215  subroutine gwtifmod_da(this)
216  ! -- dummy
217  class(gwtinterfacemodeltype) :: this !< the GWT interface model
218  !
219 
220  ! this
221  call mem_deallocate(this%iAdvScheme)
222  call mem_deallocate(this%ixt3d)
223  call mem_deallocate(this%ieqnsclfac)
224  !
225  ! gwt packages
226  call this%dis%dis_da()
227  call this%fmi%fmi_da()
228  call this%adv%adv_da()
229  call this%dsp%dsp_da()
230  !
231  deallocate (this%dis)
232  deallocate (this%fmi)
233  deallocate (this%adv)
234  deallocate (this%dsp)
235  !
236  if (associated(this%mst)) then
237  call mem_deallocate(this%mst%thetam)
238  deallocate (this%mst)
239  end if
240  !
241  ! gwt scalars
242  call mem_deallocate(this%inic)
243  call mem_deallocate(this%infmi)
244  call mem_deallocate(this%inadv)
245  call mem_deallocate(this%indsp)
246  call mem_deallocate(this%inssm)
247  call mem_deallocate(this%inmst)
248  call mem_deallocate(this%inmvt)
249  call mem_deallocate(this%inoc)
250  call mem_deallocate(this%inobs)
251  call mem_deallocate(this%eqnsclfac)
252  !
253  ! base
254  call this%NumericalModelType%model_da()
255  !
256  ! -- Return
257  return
258  end subroutine gwtifmod_da
259 
260 end module gwtinterfacemodelmodule
This module contains simulation constants.
Definition: Constants.f90:9
real(dp), parameter done
real constant 1
Definition: Constants.f90:75
subroutine, public disu_cr(dis, name_model, input_mempath, inunit, iout)
Create a new unstructured discretization object.
Definition: Disu.f90:127
class(disutype) function, pointer, public castasdisutype(dis)
Cast base to DISU.
Definition: Disu.f90:1592
Refactoring issues towards parallel:
subroutine, public dsp_cr(dspobj, name_model, input_mempath, inunit, iout, fmi)
Create a DSP object.
Definition: gwt-dsp.f90:78
subroutine allocate_scalars(this, modelname)
Allocate scalars associated with the interface model object.
subroutine gwtifmod_ar(this)
Override allocate and read the GWT interface model and its packages so that we can create stuff from ...
subroutine gwtifmod_da(this)
Clean up resources.
subroutine gwtifmod_df(this)
Define the GWT interface model.
subroutine gwtifmod_cr(this, name, iout, gridConn)
Create the interface model, analogously to what.
subroutine allocate_fmi(this)
Allocate a Flow Model Interface (FMI) object for the interface model.
Definition: gwt.f90:8
class(gwtmodeltype) function, pointer, public castasgwtmodel(model)
Cast to GwtModelType.
Definition: gwt.f90:841
– @ brief Mobile Storage and Transfer (MST) Module
Definition: gwt-mst.f90:10
subroutine, public mst_cr(mstobj, name_model, inunit, iout, fmi)
@ brief Create a new package object
Definition: gwt-mst.f90:98
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, public adv_cr(advobj, name_model, inunit, iout, fmi, eqnsclfac)
@ brief Create a new ADV object
Definition: tsp-adv.f90:47
subroutine, public fmi_cr(fmiobj, name_model, inunit, iout, eqnsclfac, depvartype)
Create a new FMI object.
Definition: tsp-fmi.f90:75
subroutine, public tsp_obs_cr(obs, inobs)
Create a new TspObsType object.
Definition: tsp-obs.f90:42
This class is used to construct the connections object for the interface model's spatial discretizati...
data structure (and helpers) for passing dsp option data
The GWT Interface Model is a utility to calculate the solution's exchange coefficients from the inter...