MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
gwegweconnectionmodule Module Reference

Data Types

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

Functions/Subroutines

subroutine gwegweconnection_ctor (this, model, gweEx)
 Basic construction of the connection. More...
 
subroutine allocate_scalars (this)
 Allocate scalar variables for this connection. More...
 
subroutine gwegwecon_df (this)
 define the GWE-GWE 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 gwegwecon_ar (this)
 allocate and read/set the connection's data structures More...
 
subroutine validateconnection (this)
 validate this connection prior to constructing More...
 
subroutine gwegwecon_rp (this)
 
subroutine gwegwecon_ad (this)
 Advance this connection. More...
 
subroutine gwegwecon_fc (this, kiter, matrix_sln, rhs_sln, inwtflag)
 
subroutine gwegwecon_cq (this, icnvg, isuppress_output, isolnid)
 
subroutine setflowtoexchange (this)
 Set the flows (flowja from interface model) to the. More...
 
subroutine gwegwecon_bd (this, icnvg, isuppress_output, isolnid)
 
subroutine gwegwecon_ot (this)
 
subroutine gwegwecon_da (this)
 
class(gwegweconnectiontype) function, pointer, public castasgwegweconnection (obj)
 Cast to GweGweConnectionType. More...
 

Function/Subroutine Documentation

◆ allocate_arrays()

subroutine gwegweconnectionmodule::allocate_arrays ( class(gwegweconnectiontype this)
private
Parameters
thisthe connection

Definition at line 245 of file GweGweConnection.f90.

246  class(GweGweConnectionType) :: this !< the connection
247 
248  call mem_allocate(this%exgflowjaGwe, this%ig_builder%nrOfBoundaryCells, &
249  'EXGFLOWJAGWT', this%memoryPath)
250 

◆ allocate_scalars()

subroutine gwegweconnectionmodule::allocate_scalars ( class(gwegweconnectiontype this)
Parameters
thisthe connection

Definition at line 140 of file GweGweConnection.f90.

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

◆ castasgwegweconnection()

class(gwegweconnectiontype) function, pointer, public gwegweconnectionmodule::castasgwegweconnection ( class(*), intent(inout), pointer  obj)
Parameters
[in,out]objobject to be cast
Returns
the GweGweConnection

Definition at line 518 of file GweGweConnection.f90.

519  implicit none
520  ! -- dummy
521  class(*), pointer, intent(inout) :: obj !< object to be cast
522  ! -- return
523  class(GweGweConnectionType), pointer :: res !< the GweGweConnection
524  !
525  res => null()
526  if (.not. associated(obj)) return
527  !
528  select type (obj)
529  class is (gwegweconnectiontype)
530  res => obj
531  end select
532  !
Here is the caller graph for this function:

◆ cfg_dist_vars()

subroutine gwegweconnectionmodule::cfg_dist_vars ( class(gwegweconnectiontype this)
private
Parameters
thisthe connection

Definition at line 210 of file GweGweConnection.f90.

211  ! -- dummy
212  class(GweGweConnectionType) :: this !< the connection
213  !
214  call this%cfg_dv('X', '', sync_nds, &
215  (/stg_bfr_con_ar, stg_bfr_exg_ad, stg_bfr_exg_cf/))
216  call this%cfg_dv('IBOUND', '', sync_nds, (/stg_bfr_con_ar/))
217  call this%cfg_dv('TOP', 'DIS', sync_nds, (/stg_bfr_con_ar/))
218  call this%cfg_dv('BOT', 'DIS', sync_nds, (/stg_bfr_con_ar/))
219  call this%cfg_dv('AREA', 'DIS', sync_nds, (/stg_bfr_con_ar/))
220  !
221  if (this%gweInterfaceModel%cnd%idisp > 0) then
222  call this%cfg_dv('ALH', 'CND', sync_nds, (/stg_bfr_con_ar/))
223  call this%cfg_dv('ALV', 'CND', sync_nds, (/stg_bfr_con_ar/))
224  call this%cfg_dv('ATH1', 'CND', sync_nds, (/stg_bfr_con_ar/))
225  call this%cfg_dv('ATH2', 'CND', sync_nds, (/stg_bfr_con_ar/))
226  call this%cfg_dv('ATV', 'CND', sync_nds, (/stg_bfr_con_ar/))
227  call this%cfg_dv('KTW', 'CND', sync_nds, (/stg_bfr_con_ar/))
228  call this%cfg_dv('KTS', 'CND', sync_nds, (/stg_bfr_con_ar/))
229  end if
230  call this%cfg_dv('GWFHEAD', 'FMI', sync_nds, (/stg_bfr_exg_ad/))
231  call this%cfg_dv('GWFSAT', 'FMI', sync_nds, (/stg_bfr_exg_ad/))
232  call this%cfg_dv('GWFSPDIS', 'FMI', sync_nds, (/stg_bfr_exg_ad/))
233  call this%cfg_dv('GWFFLOWJA', 'FMI', sync_con, (/stg_bfr_exg_ad/))
234  call this%cfg_dv('GWFFLOWJA', 'FMI', sync_exg, (/stg_bfr_exg_ad/), &
235  exg_var_name='GWFSIMVALS')
236  ! -- Fill porosity from est packages, needed for cnd
237  if (this%gweModel%incnd > 0 .and. this%gweModel%inest > 0) then
238  call this%cfg_dv('POROSITY', 'EST', sync_nds, (/stg_aft_con_ar/))
239  end if
240  !

◆ gwegwecon_ad()

subroutine gwegweconnectionmodule::gwegwecon_ad ( class(gwegweconnectiontype this)
private
Parameters
thisthis connection

Definition at line 381 of file GweGweConnection.f90.

382  !
383  class(GweGweConnectionType) :: this !< this connection
384  !
385  ! -- Recalculate conduction ellipse
386  if (this%gweInterfaceModel%incnd > 0) call this%gweInterfaceModel%cnd%cnd_ad()
387  !
388  if (this%owns_exchange) then
389  call this%gweExchange%exg_ad()
390  end if
391  !

◆ gwegwecon_ar()

subroutine gwegweconnectionmodule::gwegwecon_ar ( class(gwegweconnectiontype this)
private
Parameters
thisthe connection

Definition at line 286 of file GweGweConnection.f90.

287  class(GweGweConnectionType) :: this !< the connection
288 
289  ! check if we can construct an interface model
290  ! NB: only makes sense after the models' allocate&read have been
291  ! called, which is why we do it here
292  call this%validateConnection()
293 
294  ! -- Allocate and read base
295  call this%spatialcon_ar()
296 
297  ! ... and now the interface model
298  call this%gweInterfaceModel%model_ar()
299 
300  ! -- Set a pointer in the interface model to the gwecommon data
301  if (this%gweModel%inest > 0) then
302  this%gweInterfaceModel%gwecommon%gwecpw = this%gweModel%gwecommon%gwecpw
303  this%gweInterfaceModel%gwecommon%gwerhow = this%gweModel%gwecommon%gwerhow
304  end if
305 
306  !-- Set the equation scaling factor in the interface model to that of
307  ! underlying GWE model
308  if (this%gweModel%incnd > 0) then
309  this%gweInterfaceModel%ieqnsclfac = this%gweModel%cnd%eqnsclfac
310  end if
311 
312  ! -- AR the movers and obs through the exchange
313  if (this%owns_exchange) then
314  !cdl implement this when MVT is ready
315  !cdl if (this%gweExchange%inmvt > 0) then
316  !cdl call this%gweExchange%mvt%mvt_ar()
317  !cdl end if
318  if (this%gweExchange%inobs > 0) then
319  call this%gweExchange%obs%obs_ar()
320  end if
321  end if
322 

◆ gwegwecon_bd()

subroutine gwegweconnectionmodule::gwegwecon_bd ( class(gwegweconnectiontype 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 453 of file GweGweConnection.f90.

454  ! -- modules
455  use budgetmodule, only: rate_accumulator
456  ! -- dummy
457  class(GweGweConnectionType) :: this !< the connection
458  integer(I4B), intent(inout) :: icnvg !< convergence flag
459  integer(I4B), intent(in) :: isuppress_output !< suppress output when =1
460  integer(I4B), intent(in) :: isolnid !< solution id
461  !
462  ! -- Call exchange budget routine, also calls bd
463  ! for movers.
464  if (this%owns_exchange) then
465  call this%gweExchange%exg_bd(icnvg, isuppress_output, isolnid)
466  end if
467  !
This module contains the BudgetModule.
Definition: Budget.f90:20
subroutine, public rate_accumulator(flow, rin, rout)
@ brief Rate accumulator subroutine
Definition: Budget.f90:664
Here is the call graph for this function:

◆ gwegwecon_cq()

subroutine gwegweconnectionmodule::gwegwecon_cq ( class(gwegweconnectiontype 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 415 of file GweGweConnection.f90.

416  ! -- dummy
417  class(GweGweConnectionType) :: this !< the connection
418  integer(I4B), intent(inout) :: icnvg !< convergence flag
419  integer(I4B), intent(in) :: isuppress_output !< suppress output when =1
420  integer(I4B), intent(in) :: isolnid !< solution id
421  !
422  call this%gweInterfaceModel%model_cq(icnvg, isuppress_output)
423  call this%setFlowToExchange()
424  !

◆ gwegwecon_da()

subroutine gwegweconnectionmodule::gwegwecon_da ( class(gwegweconnectiontype this)
private
Parameters
thisthe connection

Definition at line 483 of file GweGweConnection.f90.

484  ! -- dummy
485  class(GweGweConnectionType) :: this !< the connection
486  ! -- local
487  logical(LGP) :: isOpen
488  !
489  ! -- Scalars
490  call mem_deallocate(this%iIfaceAdvScheme)
491  call mem_deallocate(this%iIfaceXt3d)
492  call mem_deallocate(this%exgflowSign)
493  !
494  ! -- Arrays
495  call mem_deallocate(this%exgflowjaGwe)
496  !
497  ! -- Interface model
498  call this%gweInterfaceModel%model_da()
499  deallocate (this%gweInterfaceModel)
500  !
501  ! -- Dealloc base
502  call this%spatialcon_da()
503  !
504  inquire (this%iout, opened=isopen)
505  if (isopen) then
506  close (this%iout)
507  end if
508  !
509  ! -- We need to deallocate the exchange we own:
510  if (this%owns_exchange) then
511  call this%gweExchange%exg_da()
512  end if
513  !

◆ gwegwecon_df()

subroutine gwegweconnectionmodule::gwegwecon_df ( class(gwegweconnectiontype this)
private
Parameters
thisthe connection

Definition at line 152 of file GweGweConnection.f90.

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

◆ gwegwecon_fc()

subroutine gwegweconnectionmodule::gwegwecon_fc ( class(gwegweconnectiontype 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 394 of file GweGweConnection.f90.

395  ! -- dummy
396  class(GweGweConnectionType) :: this !< the connection
397  integer(I4B), intent(in) :: kiter !< the iteration counter
398  class(MatrixBaseType), pointer :: matrix_sln !< the system matrix
399  real(DP), dimension(:), intent(inout) :: rhs_sln !< global right-hand-side
400  integer(I4B), optional, intent(in) :: inwtflag !< newton-raphson flag
401  !
402  call this%SpatialModelConnectionType%spatialcon_fc( &
403  kiter, matrix_sln, rhs_sln, inwtflag)
404  !
405  ! FC the movers through the exchange
406  if (this%owns_exchange) then
407  if (this%gweExchange%inmvt > 0) then
408  call this%gweExchange%mvt%mvt_fc(this%gweExchange%gwemodel1%x, &
409  this%gweExchange%gwemodel2%x)
410  end if
411  end if
412  !

◆ gwegwecon_ot()

subroutine gwegweconnectionmodule::gwegwecon_ot ( class(gwegweconnectiontype this)
Parameters
thisthe connection

Definition at line 470 of file GweGweConnection.f90.

471  ! -- dummy
472  class(GweGweConnectionType) :: this !< the connection
473  !
474  ! -- Call exg_ot() here as it handles all output processing
475  ! based on gweExchange%simvals(:), which was correctly
476  ! filled from gwegwecon
477  if (this%owns_exchange) then
478  call this%gweExchange%exg_ot()
479  end if
480  !

◆ gwegwecon_rp()

subroutine gwegweconnectionmodule::gwegwecon_rp ( class(gwegweconnectiontype this)
Parameters
thisthe connection

Definition at line 368 of file GweGweConnection.f90.

369  ! -- dummy
370  class(GweGweConnectionType) :: this !< the connection
371  !
372  ! Call exchange rp routines
373  if (this%owns_exchange) then
374  call this%gweExchange%exg_rp()
375  end if
376  !

◆ gwegweconnection_ctor()

subroutine gwegweconnectionmodule::gwegweconnection_ctor ( class(gwegweconnectiontype this,
class(numericalmodeltype), pointer  model,
class(disconnexchangetype), pointer  gweEx 
)
Parameters
thisthe connection
modelthe model owning this connection, this must be a GweModelType
gweexthe GWE-GWE exchange the interface model is created for

Definition at line 82 of file GweGweConnection.f90.

83  ! -- modules
84  use inputoutputmodule, only: openfile
85  ! -- dummy
86  class(GweGweConnectionType) :: this !< the connection
87  class(NumericalModelType), pointer :: model !< the model owning this connection,
88  !! this must be a GweModelType
89  class(DisConnExchangeType), pointer :: gweEx !< the GWE-GWE 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%gweModel => castasgwemodel(objptr)
98  objptr => gweex
99  this%gweExchange => castasgweexchange(objptr)
100  !
101  if (gweex%v_model1%is_local .and. gweex%v_model2%is_local) then
102  this%owns_exchange = associated(model, gweex%model1)
103  else
104  this%owns_exchange = .true.
105  end if
106  !
107  if (gweex%v_model1 == model) then
108  write (name, '(a,i0)') 'GWECON1_', gweex%id
109  else
110  write (name, '(a,i0)') 'GWECON2_', gweex%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 GWE-GWE connection for model ', &
118  trim(this%gweModel%name), 'from exchange ', &
119  trim(gweex%name)
120  end if
121  !
122  ! -- First call base constructor
123  call this%SpatialModelConnectionType%spatialConnection_ctor(model, &
124  gweex, &
125  name)
126  !
127  call this%allocate_scalars()
128  this%typename = 'GWE-GWE'
129  this%iIfaceAdvScheme = 0
130  this%iIfaceXt3d = 0
131  this%exgflowSign = 1
132  !
133  allocate (this%gweInterfaceModel)
134  this%interface_model => this%gweInterfaceModel
135  !
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 gwegweconnectionmodule::setflowtoexchange ( class(gwegweconnectiontype this)
private
Parameters
thisthis connection

Definition at line 429 of file GweGweConnection.f90.

430  ! -- modules
431  use indexmapmodule
432  ! -- dummy
433  class(GweGweConnectionType) :: this !< this connection
434  ! -- local
435  integer(I4B) :: i
436  class(GweExchangeType), pointer :: gweEx
437  type(IndexMapSgnType), pointer :: map
438  !
439  if (this%owns_exchange) then
440  gweex => this%gweExchange
441  map => this%interface_map%exchange_maps(this%interface_map%prim_exg_idx)
442  !
443  ! -- Use (half of) the exchange map in reverse:
444  do i = 1, size(map%src_idx)
445  if (map%sign(i) < 0) cycle ! simvals is defined from exg%m1 => exg%m2
446  gweex%simvals(map%src_idx(i)) = &
447  this%gweInterfaceModel%flowja(map%tgt_idx(i))
448  end do
449  end if
450  !

◆ setgridextent()

subroutine gwegweconnectionmodule::setgridextent ( class(gwegweconnectiontype this)
private
Parameters
thisthe connection

Definition at line 255 of file GweGweConnection.f90.

256  ! -- dummy
257  class(GweGweConnectionType) :: this !< the connection
258  ! -- local
259  logical(LGP) :: hasAdv, hasCnd
260  !
261  hasadv = this%gweModel%inadv > 0
262  hascnd = this%gweModel%incnd > 0
263  !
264  if (hasadv) then
265  if (this%iIfaceAdvScheme == 2) then
266  this%exg_stencil_depth = 2
267  if (this%gweModel%adv%iadvwt == 2) then
268  this%int_stencil_depth = 2
269  end if
270  end if
271  end if
272  !
273  if (hascnd) then
274  if (this%iIfaceXt3d > 0) then
275  this%exg_stencil_depth = 2
276  if (this%gweModel%cnd%ixt3d > 0) then
277  this%int_stencil_depth = 2
278  end if
279  end if
280  end if
281  !

◆ validateconnection()

subroutine gwegweconnectionmodule::validateconnection ( class(gwegweconnectiontype this)
private
Parameters
thisthis connection

Definition at line 327 of file GweGweConnection.f90.

328  use simvariablesmodule, only: errmsg
330  class(GweGweConnectionType) :: this !< this connection
331 
332  ! -- Base validation, the spatial/geometry part
333  call this%SpatialModelConnectionType%validateConnection()
334 
335  ! -- We cannot validate this (yet) in parallel mode
336  if (.not. this%gweExchange%v_model1%is_local) return
337  if (.not. this%gweExchange%v_model2%is_local) return
338 
339  ! -- GWE related matters
340  if ((this%gweExchange%gwemodel1%inadv > 0 .and. &
341  this%gweExchange%gwemodel2%inadv == 0) .or. &
342  (this%gweExchange%gwemodel2%inadv > 0 .and. &
343  this%gweExchange%gwemodel1%inadv == 0)) then
344  write (errmsg, '(1x,a,a,a)') 'Cannot connect GWE models in exchange ', &
345  trim(this%gweExchange%name), ' because one model is configured with ADV &
346  &and the other one is not'
347  call store_error(errmsg)
348  end if
349  !
350  if ((this%gweExchange%gwemodel1%incnd > 0 .and. &
351  this%gweExchange%gwemodel2%incnd == 0) .or. &
352  (this%gweExchange%gwemodel2%incnd > 0 .and. &
353  this%gweExchange%gwemodel1%incnd == 0)) then
354  write (errmsg, '(1x,a,a,a)') 'Cannot connect GWE models in exchange ', &
355  trim(this%gweExchange%name), ' because one model is configured with CND &
356  &and the other one is not'
357  call store_error(errmsg)
358  end if
359  !
360  ! Abort on errors
361  if (count_errors() > 0) then
362  write (errmsg, '(a)') 'Errors occurred while processing exchange(s)'
363  call ustop()
364  end if
365  !
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: