MODFLOW 6  version 6.6.0.dev0
USGS Modular Hydrologic Model
gwtgwtconnectionmodule Module Reference

Data Types

type  gwtgwtconnectiontype
 Connects a GWT model to other GWT models in space. Derives from NumericalExchangeType so the solution can use it to fetch the coefficients for this connection. More...
 

Functions/Subroutines

subroutine gwtgwtconnection_ctor (this, model, gwtEx)
 Basic construction of the connection. More...
 
subroutine allocate_scalars (this)
 Allocate scalar variables for this connection. More...
 
subroutine gwtgwtcon_df (this)
 define the GWT-GWT connection More...
 
subroutine cfg_dist_vars (this)
 Configure distributed variables for this interface model. More...
 
subroutine allocate_arrays (this)
 Allocate array variables for this connection. More...
 
subroutine setgridextent (this)
 Set required extent of the interface grid from. More...
 
subroutine gwtgwtcon_ar (this)
 allocate and read/set the connection's data structures More...
 
subroutine validateconnection (this)
 validate this connection prior to constructing More...
 
subroutine gwtgwtcon_rp (this)
 
subroutine gwtgwtcon_ad (this)
 Advance this connection. More...
 
subroutine gwtgwtcon_fc (this, kiter, matrix_sln, rhs_sln, inwtflag)
 
subroutine gwtgwtcon_cq (this, icnvg, isuppress_output, isolnid)
 
subroutine setflowtoexchange (this)
 Set the flows (flowja from interface model) to the. More...
 
subroutine gwtgwtcon_bd (this, icnvg, isuppress_output, isolnid)
 
subroutine gwtgwtcon_ot (this)
 
subroutine gwtgwtcon_da (this)
 
class(gwtgwtconnectiontype) function, pointer, public castasgwtgwtconnection (obj)
 Cast to GwtGwtConnectionType. More...
 

Function/Subroutine Documentation

◆ allocate_arrays()

subroutine gwtgwtconnectionmodule::allocate_arrays ( class(gwtgwtconnectiontype this)
private
Parameters
thisthe connection

Definition at line 240 of file GwtGwtConnection.f90.

241  class(GwtGwtConnectionType) :: this !< the connection
242 
243  call mem_allocate(this%exgflowjaGwt, this%ig_builder%nrOfBoundaryCells, &
244  'EXGFLOWJAGWT', this%memoryPath)
245 

◆ allocate_scalars()

subroutine gwtgwtconnectionmodule::allocate_scalars ( class(gwtgwtconnectiontype this)
Parameters
thisthe connection

Definition at line 138 of file GwtGwtConnection.f90.

139  class(GwtGwtConnectionType) :: this !< the connection
140 
141  call mem_allocate(this%iIfaceAdvScheme, 'IADVSCHEME', this%memoryPath)
142  call mem_allocate(this%iIfaceXt3d, 'IXT3D', this%memoryPath)
143  call mem_allocate(this%exgflowSign, 'EXGFLOWSIGN', this%memoryPath)
144 

◆ castasgwtgwtconnection()

class(gwtgwtconnectiontype) function, pointer, public gwtgwtconnectionmodule::castasgwtgwtconnection ( class(*), intent(inout), pointer  obj)
Parameters
[in,out]objobject to be cast
Returns
the GwtGwtConnection

Definition at line 491 of file GwtGwtConnection.f90.

492  implicit none
493  class(*), pointer, intent(inout) :: obj !< object to be cast
494  class(GwtGwtConnectionType), pointer :: res !< the GwtGwtConnection
495 
496  res => null()
497  if (.not. associated(obj)) return
498 
499  select type (obj)
500  class is (gwtgwtconnectiontype)
501  res => obj
502  end select
Here is the caller graph for this function:

◆ cfg_dist_vars()

subroutine gwtgwtconnectionmodule::cfg_dist_vars ( class(gwtgwtconnectiontype this)
private
Parameters
thisthe connection

Definition at line 206 of file GwtGwtConnection.f90.

207  class(GwtGwtConnectionType) :: this !< the connection
208 
209  call this%cfg_dv('X', '', sync_nds, &
210  (/stg_bfr_con_ar, stg_bfr_exg_ad, stg_bfr_exg_cf/))
211  call this%cfg_dv('IBOUND', '', sync_nds, (/stg_bfr_con_ar/))
212  call this%cfg_dv('TOP', 'DIS', sync_nds, (/stg_bfr_con_ar/))
213  call this%cfg_dv('BOT', 'DIS', sync_nds, (/stg_bfr_con_ar/))
214  call this%cfg_dv('AREA', 'DIS', sync_nds, (/stg_bfr_con_ar/))
215  if (this%gwtInterfaceModel%dsp%idiffc > 0) then
216  call this%cfg_dv('DIFFC', 'DSP', sync_nds, (/stg_bfr_con_ar/))
217  end if
218  if (this%gwtInterfaceModel%dsp%idisp > 0) then
219  call this%cfg_dv('ALH', 'DSP', sync_nds, (/stg_bfr_con_ar/))
220  call this%cfg_dv('ALV', 'DSP', sync_nds, (/stg_bfr_con_ar/))
221  call this%cfg_dv('ATH1', 'DSP', sync_nds, (/stg_bfr_con_ar/))
222  call this%cfg_dv('ATH2', 'DSP', sync_nds, (/stg_bfr_con_ar/))
223  call this%cfg_dv('ATV', 'DSP', sync_nds, (/stg_bfr_con_ar/))
224  end if
225  call this%cfg_dv('GWFHEAD', 'FMI', sync_nds, (/stg_bfr_exg_ad/))
226  call this%cfg_dv('GWFSAT', 'FMI', sync_nds, (/stg_bfr_exg_ad/))
227  call this%cfg_dv('GWFSPDIS', 'FMI', sync_nds, (/stg_bfr_exg_ad/))
228  call this%cfg_dv('GWFFLOWJA', 'FMI', sync_con, (/stg_bfr_exg_ad/))
229  call this%cfg_dv('GWFFLOWJA', 'FMI', sync_exg, (/stg_bfr_exg_ad/), &
230  exg_var_name='GWFSIMVALS')
231  ! fill thetam from mst packages, needed for dsp
232  if (this%gwtModel%indsp > 0 .and. this%gwtModel%inmst > 0) then
233  call this%cfg_dv('THETAM', 'MST', sync_nds, (/stg_aft_con_ar/))
234  end if
235 

◆ gwtgwtcon_ad()

subroutine gwtgwtconnectionmodule::gwtgwtcon_ad ( class(gwtgwtconnectiontype this)
private
Parameters
thisthis connection

Definition at line 362 of file GwtGwtConnection.f90.

363  class(GwtGwtConnectionType) :: this !< this connection
364 
365  ! recalculate dispersion ellipse
366  if (this%gwtInterfaceModel%indsp > 0) call this%gwtInterfaceModel%dsp%dsp_ad()
367 
368  if (this%owns_exchange) then
369  call this%gwtExchange%exg_ad()
370  end if
371 

◆ gwtgwtcon_ar()

subroutine gwtgwtconnectionmodule::gwtgwtcon_ar ( class(gwtgwtconnectiontype this)
private
Parameters
thisthe connection

Definition at line 280 of file GwtGwtConnection.f90.

281  class(GwtGwtConnectionType) :: this !< the connection
282 
283  ! check if we can construct an interface model
284  ! NB: only makes sense after the models' allocate&read have been
285  ! called, which is why we do it here
286  call this%validateConnection()
287 
288  ! allocate and read base
289  call this%spatialcon_ar()
290 
291  ! ... and now the interface model
292  call this%gwtInterfaceModel%model_ar()
293 
294  ! AR the movers and obs through the exchange
295  if (this%owns_exchange) then
296  !cdl implement this when MVT is ready
297  !cdl if (this%gwtExchange%inmvt > 0) then
298  !cdl call this%gwtExchange%mvt%mvt_ar()
299  !cdl end if
300  if (this%gwtExchange%inobs > 0) then
301  call this%gwtExchange%obs%obs_ar()
302  end if
303  end if
304 

◆ gwtgwtcon_bd()

subroutine gwtgwtconnectionmodule::gwtgwtcon_bd ( class(gwtgwtconnectiontype this,
integer(i4b), intent(inout)  icnvg,
integer(i4b), intent(in)  isuppress_output,
integer(i4b), intent(in)  isolnid 
)
Parameters
thisthe connection
[in,out]icnvgconvergence flag
[in]isuppress_outputsuppress output when =1
[in]isolnidsolution id

Definition at line 430 of file GwtGwtConnection.f90.

431  use budgetmodule, only: rate_accumulator
432  class(GwtGwtConnectionType) :: this !< the connection
433  integer(I4B), intent(inout) :: icnvg !< convergence flag
434  integer(I4B), intent(in) :: isuppress_output !< suppress output when =1
435  integer(I4B), intent(in) :: isolnid !< solution id
436 
437  ! call exchange budget routine, also calls bd
438  ! for movers.
439  if (this%owns_exchange) then
440  call this%gwtExchange%exg_bd(icnvg, isuppress_output, isolnid)
441  end if
442 
This module contains the BudgetModule.
Definition: Budget.f90:20
subroutine, public rate_accumulator(flow, rin, rout)
@ brief Rate accumulator subroutine
Definition: Budget.f90:632
Here is the call graph for this function:

◆ gwtgwtcon_cq()

subroutine gwtgwtconnectionmodule::gwtgwtcon_cq ( class(gwtgwtconnectiontype this,
integer(i4b), intent(inout)  icnvg,
integer(i4b), intent(in)  isuppress_output,
integer(i4b), intent(in)  isolnid 
)
private
Parameters
thisthe connection
[in,out]icnvgconvergence flag
[in]isuppress_outputsuppress output when =1
[in]isolnidsolution id

Definition at line 395 of file GwtGwtConnection.f90.

396  class(GwtGwtConnectionType) :: this !< the connection
397  integer(I4B), intent(inout) :: icnvg !< convergence flag
398  integer(I4B), intent(in) :: isuppress_output !< suppress output when =1
399  integer(I4B), intent(in) :: isolnid !< solution id
400 
401  call this%gwtInterfaceModel%model_cq(icnvg, isuppress_output)
402  call this%setFlowToExchange()
403 

◆ gwtgwtcon_da()

subroutine gwtgwtconnectionmodule::gwtgwtcon_da ( class(gwtgwtconnectiontype this)
private
Parameters
thisthe connection

Definition at line 457 of file GwtGwtConnection.f90.

458  class(GwtGwtConnectionType) :: this !< the connection
459  ! local
460  logical(LGP) :: isOpen
461 
462  ! scalars
463  call mem_deallocate(this%iIfaceAdvScheme)
464  call mem_deallocate(this%iIfaceXt3d)
465  call mem_deallocate(this%exgflowSign)
466 
467  ! arrays
468  call mem_deallocate(this%exgflowjaGwt)
469 
470  ! interface model
471  call this%gwtInterfaceModel%model_da()
472  deallocate (this%gwtInterfaceModel)
473 
474  ! dealloc base
475  call this%spatialcon_da()
476 
477  inquire (this%iout, opened=isopen)
478  if (isopen) then
479  close (this%iout)
480  end if
481 
482  ! we need to deallocate the exchange we own:
483  if (this%owns_exchange) then
484  call this%gwtExchange%exg_da()
485  end if
486 

◆ gwtgwtcon_df()

subroutine gwtgwtconnectionmodule::gwtgwtcon_df ( class(gwtgwtconnectiontype this)
private
Parameters
thisthe connection

Definition at line 149 of file GwtGwtConnection.f90.

150  class(GwtGwtConnectionType) :: this !< the connection
151  ! local
152  character(len=LENCOMPONENTNAME) :: imName
153 
154  ! determine advection scheme (the GWT-GWT exchange
155  ! has been read at this point)
156  this%iIfaceAdvScheme = this%gwtExchange%iAdvScheme
157  !
158  ! determine xt3d setting on interface
159  this%iIfaceXt3d = this%gwtExchange%ixt3d
160 
161  ! turn off when off in the owning model
162  if (this%gwtModel%indsp > 0) then
163  this%iIfaceXt3d = this%gwtModel%dsp%ixt3d
164  end if
165 
166  ! determine the required size of the interface model grid
167  call this%setGridExtent()
168 
169  ! now set up the GridConnection
170  call this%spatialcon_df()
171 
172  ! we have to 'catch up' and create the interface model
173  ! here, then the remainder of this routine will be define
174  if (this%prim_exchange%v_model1 == this%owner) then
175  write (imname, '(a,i0)') 'GWTIM1_', this%gwtExchange%id
176  else
177  write (imname, '(a,i0)') 'GWTIM2_', this%gwtExchange%id
178  end if
179  call this%gwtInterfaceModel%gwtifmod_cr(imname, &
180  this%iout, &
181  this%ig_builder)
182  call this%gwtInterfaceModel%set_idsoln(this%gwtModel%idsoln)
183  this%gwtInterfaceModel%iAdvScheme = this%iIfaceAdvScheme
184  this%gwtInterfaceModel%ixt3d = this%iIfaceXt3d
185  call this%gwtInterfaceModel%model_df()
186 
187  call this%cfg_dist_vars()
188 
189  call this%allocate_arrays()
190  call this%gwtInterfaceModel%allocate_fmi()
191 
192  ! connect X, RHS, IBOUND, and flowja
193  call this%spatialcon_setmodelptrs()
194 
195  ! connect pointers (used by BUY)
196  this%conc => this%gwtInterfaceModel%x
197  this%icbound => this%gwtInterfaceModel%ibound
198 
199  ! add connections from the interface model to solution matrix
200  call this%spatialcon_connect()
201 

◆ gwtgwtcon_fc()

subroutine gwtgwtconnectionmodule::gwtgwtcon_fc ( class(gwtgwtconnectiontype this,
integer(i4b), intent(in)  kiter,
class(matrixbasetype), pointer  matrix_sln,
real(dp), dimension(:), intent(inout)  rhs_sln,
integer(i4b), intent(in), optional  inwtflag 
)
private
Parameters
thisthe connection
[in]kiterthe iteration counter
matrix_slnthe system matrix
[in,out]rhs_slnglobal right-hand-side
[in]inwtflagnewton-raphson flag

Definition at line 374 of file GwtGwtConnection.f90.

375  class(GwtGwtConnectionType) :: this !< the connection
376  integer(I4B), intent(in) :: kiter !< the iteration counter
377  class(MatrixBaseType), pointer :: matrix_sln !< the system matrix
378  real(DP), dimension(:), intent(inout) :: rhs_sln !< global right-hand-side
379  integer(I4B), optional, intent(in) :: inwtflag !< newton-raphson flag
380  !
381 
382  call this%SpatialModelConnectionType%spatialcon_fc( &
383  kiter, matrix_sln, rhs_sln, inwtflag)
384  !
385  ! FC the movers through the exchange
386  if (this%owns_exchange) then
387  if (this%gwtExchange%inmvt > 0) then
388  call this%gwtExchange%mvt%mvt_fc(this%gwtExchange%gwtmodel1%x, &
389  this%gwtExchange%gwtmodel2%x)
390  end if
391  end if
392 

◆ gwtgwtcon_ot()

subroutine gwtgwtconnectionmodule::gwtgwtcon_ot ( class(gwtgwtconnectiontype this)
Parameters
thisthe connection

Definition at line 445 of file GwtGwtConnection.f90.

446  class(GwtGwtConnectionType) :: this !< the connection
447 
448  ! Call exg_ot() here as it handles all output processing
449  ! based on gwtExchange%simvals(:), which was correctly
450  ! filled from gwtgwtcon
451  if (this%owns_exchange) then
452  call this%gwtExchange%exg_ot()
453  end if
454 

◆ gwtgwtcon_rp()

subroutine gwtgwtconnectionmodule::gwtgwtcon_rp ( class(gwtgwtconnectiontype this)
Parameters
thisthe connection

Definition at line 350 of file GwtGwtConnection.f90.

351  class(GwtGwtConnectionType) :: this !< the connection
352 
353  ! Call exchange rp routines
354  if (this%owns_exchange) then
355  call this%gwtExchange%exg_rp()
356  end if
357 

◆ gwtgwtconnection_ctor()

subroutine gwtgwtconnectionmodule::gwtgwtconnection_ctor ( class(gwtgwtconnectiontype this,
class(numericalmodeltype), pointer  model,
class(disconnexchangetype), pointer  gwtEx 
)
Parameters
thisthe connection
modelthe model owning this connection, this must be a GwtModelType
gwtexthe GWT-GWT exchange the interface model is created for

Definition at line 82 of file GwtGwtConnection.f90.

83  use inputoutputmodule, only: openfile
84  class(GwtGwtConnectionType) :: this !< the connection
85  class(NumericalModelType), pointer :: model !< the model owning this connection,
86  !! this must be a GwtModelType
87  class(DisConnExchangeType), pointer :: gwtEx !< the GWT-GWT exchange the interface model is created for
88  ! local
89  character(len=LINELENGTH) :: fname
90  character(len=LENCOMPONENTNAME) :: name
91  class(*), pointer :: objPtr
92  logical(LGP) :: write_ifmodel_listfile = .false.
93 
94  objptr => model
95  this%gwtModel => castasgwtmodel(objptr)
96  objptr => gwtex
97  this%gwtExchange => castasgwtexchange(objptr)
98 
99  if (gwtex%v_model1%is_local .and. gwtex%v_model2%is_local) then
100  this%owns_exchange = associated(model, gwtex%model1)
101  else
102  this%owns_exchange = .true.
103  end if
104 
105  if (gwtex%v_model1 == model) then
106  write (name, '(a,i0)') 'GWTCON1_', gwtex%id
107  else
108  write (name, '(a,i0)') 'GWTCON2_', gwtex%id
109  end if
110 
111  ! .lst file for interface model
112  if (write_ifmodel_listfile) then
113  fname = trim(name)//'.im.lst'
114  call openfile(this%iout, 0, fname, 'LIST', filstat_opt='REPLACE')
115  write (this%iout, '(4a)') 'Creating GWT-GWT connection for model ', &
116  trim(this%gwtModel%name), 'from exchange ', &
117  trim(gwtex%name)
118  end if
119 
120  ! first call base constructor
121  call this%SpatialModelConnectionType%spatialConnection_ctor(model, &
122  gwtex, &
123  name)
124 
125  call this%allocate_scalars()
126  this%typename = 'GWT-GWT'
127  this%iIfaceAdvScheme = 0
128  this%iIfaceXt3d = 0
129  this%exgflowSign = 1
130 
131  allocate (this%gwtInterfaceModel)
132  this%interface_model => this%gwtInterfaceModel
133 
subroutine, public openfile(iu, iout, fname, ftype, fmtarg_opt, accarg_opt, filstat_opt, mode_opt)
Open a file.
Definition: InputOutput.f90:30
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setflowtoexchange()

subroutine gwtgwtconnectionmodule::setflowtoexchange ( class(gwtgwtconnectiontype this)
private
Parameters
thisthis connection

Definition at line 408 of file GwtGwtConnection.f90.

409  use indexmapmodule
410  class(GwtGwtConnectionType) :: this !< this connection
411  ! local
412  integer(I4B) :: i
413  class(GwtExchangeType), pointer :: gwtEx
414  type(IndexMapSgnType), pointer :: map
415 
416  if (this%owns_exchange) then
417  gwtex => this%gwtExchange
418  map => this%interface_map%exchange_maps(this%interface_map%prim_exg_idx)
419 
420  ! use (half of) the exchange map in reverse:
421  do i = 1, size(map%src_idx)
422  if (map%sign(i) < 0) cycle ! simvals is defined from exg%m1 => exg%m2
423  gwtex%simvals(map%src_idx(i)) = &
424  this%gwtInterfaceModel%flowja(map%tgt_idx(i))
425  end do
426  end if
427 

◆ setgridextent()

subroutine gwtgwtconnectionmodule::setgridextent ( class(gwtgwtconnectiontype this)
private
Parameters
thisthe connection

Definition at line 250 of file GwtGwtConnection.f90.

251  class(GwtGwtConnectionType) :: this !< the connection
252  ! local
253  logical(LGP) :: hasAdv, hasDsp
254 
255  hasadv = this%gwtModel%inadv > 0
256  hasdsp = this%gwtModel%indsp > 0
257 
258  if (hasadv) then
259  if (this%iIfaceAdvScheme == 2) then
260  this%exg_stencil_depth = 2
261  if (this%gwtModel%adv%iadvwt == 2) then
262  this%int_stencil_depth = 2
263  end if
264  end if
265  end if
266 
267  if (hasdsp) then
268  if (this%iIfaceXt3d > 0) then
269  this%exg_stencil_depth = 2
270  if (this%gwtModel%dsp%ixt3d > 0) then
271  this%int_stencil_depth = 2
272  end if
273  end if
274  end if
275 

◆ validateconnection()

subroutine gwtgwtconnectionmodule::validateconnection ( class(gwtgwtconnectiontype this)
private
Parameters
thisthis connection

Definition at line 309 of file GwtGwtConnection.f90.

310  use simvariablesmodule, only: errmsg
312  class(GwtGwtConnectionType) :: this !< this connection
313 
314  ! base validation, the spatial/geometry part
315  call this%SpatialModelConnectionType%validateConnection()
316 
317  ! we cannot validate this (yet) in parallel mode
318  if (.not. this%gwtExchange%v_model1%is_local) return
319  if (.not. this%gwtExchange%v_model2%is_local) return
320 
321  ! GWT related matters
322  if ((this%gwtExchange%gwtmodel1%inadv > 0 .and. &
323  this%gwtExchange%gwtmodel2%inadv == 0) .or. &
324  (this%gwtExchange%gwtmodel2%inadv > 0 .and. &
325  this%gwtExchange%gwtmodel1%inadv == 0)) then
326  write (errmsg, '(a,a,a)') 'Cannot connect GWT models in exchange ', &
327  trim(this%gwtExchange%name), ' because one model is configured with ADV &
328  &and the other one is not'
329  call store_error(errmsg)
330  end if
331 
332  if ((this%gwtExchange%gwtmodel1%indsp > 0 .and. &
333  this%gwtExchange%gwtmodel2%indsp == 0) .or. &
334  (this%gwtExchange%gwtmodel2%indsp > 0 .and. &
335  this%gwtExchange%gwtmodel1%indsp == 0)) then
336  write (errmsg, '(a,a,a)') 'Cannot connect GWT models in exchange ', &
337  trim(this%gwtExchange%name), ' because one model is configured with DSP &
338  &and the other one is not'
339  call store_error(errmsg)
340  end if
341 
342  ! abort on errors
343  if (count_errors() > 0) then
344  write (errmsg, '(a)') 'Errors occurred while processing exchange(s)'
345  call ustop()
346  end if
347 
This module contains simulation methods.
Definition: Sim.f90:10
subroutine, public store_error(msg, terminate)
Store an error message.
Definition: Sim.f90:92
integer(i4b) function, public count_errors()
Return number of errors.
Definition: Sim.f90:59
This module contains simulation variables.
Definition: SimVariables.f90:9
character(len=maxcharlen) errmsg
error message string
Here is the call graph for this function: