MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
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.
subroutine allocate_scalars (this)
 Allocate scalar variables for this connection.
subroutine gwtgwtcon_df (this)
 define the GWT-GWT connection
subroutine cfg_dist_vars (this)
 Configure distributed variables for this interface model.
subroutine allocate_arrays (this)
 Allocate array variables for this connection.
subroutine setgridextent (this)
 Set required extent of the interface grid from.
subroutine gwtgwtcon_ar (this)
 allocate and read/set the connection's data structures
subroutine validateconnection (this)
 validate this connection prior to constructing
subroutine gwtgwtcon_rp (this)
subroutine gwtgwtcon_ad (this)
 Advance this connection.
subroutine gwtgwtcon_cf (this, kiter)
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.
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.

Function/Subroutine Documentation

◆ allocate_arrays()

Parameters
thisthe connection

Definition at line 242 of file GwtGwtConnection.f90.

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

◆ allocate_scalars()

Parameters
thisthe connection

Definition at line 140 of file GwtGwtConnection.f90.

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

◆ 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 528 of file GwtGwtConnection.f90.

529 implicit none
530 class(*), pointer, intent(inout) :: obj !< object to be cast
531 class(GwtGwtConnectionType), pointer :: res !< the GwtGwtConnection
532
533 res => null()
534 if (.not. associated(obj)) return
535
536 select type (obj)
537 class is (gwtgwtconnectiontype)
538 res => obj
539 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 208 of file GwtGwtConnection.f90.

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

◆ gwtgwtcon_ad()

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

Definition at line 366 of file GwtGwtConnection.f90.

367 class(GwtGwtConnectionType) :: this !< this connection
368
369 ! recalculate dispersion ellipse
370 if (this%gwtInterfaceModel%indsp > 0) call this%gwtInterfaceModel%dsp%dsp_ad()
371
372 if (this%owns_exchange) then
373 call this%gwtExchange%exg_ad()
374 end if
375

◆ gwtgwtcon_ar()

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

Definition at line 284 of file GwtGwtConnection.f90.

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

◆ 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 )
private
Parameters
thisthe connection
[in,out]icnvgconvergence flag
[in]isuppress_outputsuppress output when =1
[in]isolnidsolution id

Definition at line 467 of file GwtGwtConnection.f90.

469 class(GwtGwtConnectionType) :: this !< the connection
470 integer(I4B), intent(inout) :: icnvg !< convergence flag
471 integer(I4B), intent(in) :: isuppress_output !< suppress output when =1
472 integer(I4B), intent(in) :: isolnid !< solution id
473
474 ! call exchange budget routine, also calls bd
475 ! for movers.
476 if (this%owns_exchange) then
477 call this%gwtExchange%exg_bd(icnvg, isuppress_output, isolnid)
478 end if
479
This module contains the BudgetModule.
Definition Budget.f90:20
subroutine, public rate_accumulator(flow, rin, rout)
Rate accumulator subroutine.
Definition Budget.f90:634
Here is the call graph for this function:

◆ gwtgwtcon_cf()

subroutine gwtgwtconnectionmodule::gwtgwtcon_cf ( class(gwtgwtconnectiontype) this,
integer(i4b), intent(in) kiter )
private
Parameters
thisthis connection
[in]kiterthe iteration counter

Definition at line 378 of file GwtGwtConnection.f90.

379 class(GwtGwtConnectionType) :: this !< this connection
380 integer(I4B), intent(in) :: kiter !< the iteration counter
381 ! local
382 real(DP), dimension(:), pointer, contiguous :: x_m1, x_m2
383
384 call this%SpatialModelConnectionType%spatialcon_cf(kiter)
385
386 ! CF the movers in the exchange
387 if (this%owns_exchange) then
388 if (this%gwtExchange%inmvt > 0) then
389 x_m1 => null()
390 x_m2 => null()
391 if (associated(this%gwtExchange%gwtmodel1)) then
392 x_m1 => this%gwtExchange%gwtmodel1%x
393 end if
394 if (associated(this%gwtExchange%gwtmodel2)) then
395 x_m2 => this%gwtExchange%gwtmodel2%x
396 end if
397 call this%gwtExchange%mvt%xmvt_cf(x_m1, x_m2)
398 end if
399 end if
400

◆ 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 432 of file GwtGwtConnection.f90.

433 class(GwtGwtConnectionType) :: this !< the connection
434 integer(I4B), intent(inout) :: icnvg !< convergence flag
435 integer(I4B), intent(in) :: isuppress_output !< suppress output when =1
436 integer(I4B), intent(in) :: isolnid !< solution id
437
438 call this%gwtInterfaceModel%model_cq(icnvg, isuppress_output)
439 call this%setFlowToExchange()
440

◆ gwtgwtcon_da()

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

Definition at line 494 of file GwtGwtConnection.f90.

495 class(GwtGwtConnectionType) :: this !< the connection
496 ! local
497 logical(LGP) :: isOpen
498
499 ! scalars
500 call mem_deallocate(this%iIfaceAdvScheme)
501 call mem_deallocate(this%iIfaceXt3d)
502 call mem_deallocate(this%exgflowSign)
503
504 ! arrays
505 call mem_deallocate(this%exgflowjaGwt)
506
507 ! interface model
508 call this%gwtInterfaceModel%model_da()
509 deallocate (this%gwtInterfaceModel)
510
511 ! dealloc base
512 call this%spatialcon_da()
513
514 inquire (this%iout, opened=isopen)
515 if (isopen) then
516 close (this%iout)
517 end if
518
519 ! we need to deallocate the exchange we own:
520 if (this%owns_exchange) then
521 call this%gwtExchange%exg_da()
522 end if
523

◆ gwtgwtcon_df()

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

Definition at line 151 of file GwtGwtConnection.f90.

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

◆ 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 403 of file GwtGwtConnection.f90.

404 class(GwtGwtConnectionType) :: this !< the connection
405 integer(I4B), intent(in) :: kiter !< the iteration counter
406 class(MatrixBaseType), pointer :: matrix_sln !< the system matrix
407 real(DP), dimension(:), intent(inout) :: rhs_sln !< global right-hand-side
408 integer(I4B), optional, intent(in) :: inwtflag !< newton-raphson flag
409 ! local
410 real(DP), dimension(:), pointer, contiguous :: x_m1, x_m2
411
412 call this%SpatialModelConnectionType%spatialcon_fc( &
413 kiter, matrix_sln, rhs_sln, inwtflag)
414 !
415 ! FC the movers through the exchange
416 if (this%owns_exchange) then
417 if (this%gwtExchange%inmvt > 0) then
418 x_m1 => null()
419 x_m2 => null()
420 if (associated(this%gwtExchange%gwtmodel1)) then
421 x_m1 => this%gwtExchange%gwtmodel1%x
422 end if
423 if (associated(this%gwtExchange%gwtmodel2)) then
424 x_m2 => this%gwtExchange%gwtmodel2%x
425 end if
426 call this%gwtExchange%mvt%mvt_fc(x_m1, x_m2)
427 end if
428 end if
429

◆ gwtgwtcon_ot()

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

Definition at line 482 of file GwtGwtConnection.f90.

483 class(GwtGwtConnectionType) :: this !< the connection
484
485 ! Call exg_ot() here as it handles all output processing
486 ! based on gwtExchange%simvals(:), which was correctly
487 ! filled from gwtgwtcon
488 if (this%owns_exchange) then
489 call this%gwtExchange%exg_ot()
490 end if
491

◆ gwtgwtcon_rp()

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

Definition at line 354 of file GwtGwtConnection.f90.

355 class(GwtGwtConnectionType) :: this !< the connection
356
357 ! Call exchange rp routines
358 if (this%owns_exchange) then
359 call this%gwtExchange%exg_rp()
360 end if
361

◆ 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 84 of file GwtGwtConnection.f90.

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

447 class(GwtGwtConnectionType) :: this !< this connection
448 ! local
449 integer(I4B) :: i
450 class(GwtExchangeType), pointer :: gwtEx
451 type(IndexMapSgnType), pointer :: map
452
453 if (this%owns_exchange) then
454 gwtex => this%gwtExchange
455 map => this%interface_map%exchange_maps(this%interface_map%prim_exg_idx)
456
457 ! use (half of) the exchange map in reverse:
458 do i = 1, size(map%src_idx)
459 if (map%sign(i) < 0) cycle ! simvals is defined from exg%m1 => exg%m2
460 gwtex%simvals(map%src_idx(i)) = &
461 this%gwtInterfaceModel%flowja(map%tgt_idx(i))
462 end do
463 end if
464

◆ setgridextent()

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

Definition at line 252 of file GwtGwtConnection.f90.

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

◆ validateconnection()

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

Definition at line 313 of file GwtGwtConnection.f90.

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