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

Data Types

type  gwfgwfconnectiontype
 Connecting a GWF model to other models in space, implements NumericalExchangeType so the solution can used this object to determine the coefficients for the coupling between two adjacent models. More...
 

Functions/Subroutines

subroutine gwfgwfconnection_ctor (this, model, gwfEx)
 Basic construction of the connection. More...
 
subroutine gwfgwfcon_df (this)
 Define the connection. More...
 
subroutine cfg_dist_vars (this)
 Configure distributed variables for this interface model. More...
 
subroutine setgridextent (this)
 Set the required size of the interface grid from. More...
 
subroutine allocatescalars (this)
 allocation of scalars in the connection More...
 
subroutine gwfgwfcon_ar (this)
 Allocate and read the connection. More...
 
subroutine gwfgwfcon_rp (this)
 Read time varying data when required. More...
 
subroutine gwfgwfcon_ad (this)
 Advance this connection. More...
 
subroutine gwfgwfcon_cf (this, kiter)
 
subroutine gwfgwfcon_fc (this, kiter, matrix_sln, rhs_sln, inwtflag)
 Write the calculated coefficients into the global. More...
 
subroutine validateconnection (this)
 Validate this connection This is called before proceeding to construct the interface model. More...
 
subroutine validategwfexchange (this)
 Validate the exchange, intercepting those cases where two models have to be connected with an interface model, where the individual configurations don't allow this. More...
 
subroutine gwfgwfcon_da (this)
 Deallocate all resources. More...
 
subroutine gwfgwfcon_cq (this, icnvg, isuppress_output, isolnid)
 Calculate intra-cell flows The calculation will be dispatched to the interface model, and then mapped back to real-world cell ids. More...
 
subroutine setflowtoexchange (this)
 Set the flows (flowja from interface model) to the. More...
 
subroutine setflowtomodel (this)
 Set the flows (flowja from the interface model) to. More...
 
subroutine setnpfedgeprops (this)
 Set flowja as edge properties in the model,. More...
 
subroutine gwfgwfcon_bd (this, icnvg, isuppress_output, isolnid)
 Calculate the budget terms for this connection, this is dispatched to the GWF-GWF exchange. More...
 
subroutine gwfgwfcon_ot (this)
 Write output for exchange (and calls. More...
 
class(gwfgwfconnectiontype) function, pointer, public castasgwfgwfconnection (obj)
 Cast to GwfGwfConnectionType. More...
 

Function/Subroutine Documentation

◆ allocatescalars()

subroutine gwfgwfconnectionmodule::allocatescalars ( class(gwfgwfconnectiontype this)
private
Parameters
thisthe connection

Definition at line 253 of file GwfGwfConnection.f90.

255  class(GwfGwfConnectionType) :: this !< the connection
256  ! local
257 
258  call mem_allocate(this%iXt3dOnExchange, 'IXT3DEXG', this%memoryPath)
259 

◆ castasgwfgwfconnection()

class(gwfgwfconnectiontype) function, pointer, public gwfgwfconnectionmodule::castasgwfgwfconnection ( class(*), intent(inout), pointer  obj)
Parameters
[in,out]objobject to be cast
Returns
the GwfGwfConnection

Definition at line 711 of file GwfGwfConnection.f90.

712  implicit none
713  class(*), pointer, intent(inout) :: obj !< object to be cast
714  class(GwfGwfConnectionType), pointer :: res !< the GwfGwfConnection
715 
716  res => null()
717  if (.not. associated(obj)) return
718 
719  select type (obj)
720  class is (gwfgwfconnectiontype)
721  res => obj
722  end select
Here is the caller graph for this function:

◆ cfg_dist_vars()

subroutine gwfgwfconnectionmodule::cfg_dist_vars ( class(gwfgwfconnectiontype this)
private
Parameters
thisthe connection

Definition at line 202 of file GwfGwfConnection.f90.

203  class(GwfGwfConnectionType) :: this !< the connection
204 
205  call this%cfg_dv('X', '', sync_nds, &
206  (/stg_bfr_con_ar, stg_bfr_exg_ad, stg_bfr_exg_cf/))
207  call this%cfg_dv('IBOUND', '', sync_nds, &
208  (/stg_bfr_con_ar, stg_bfr_exg_ad, stg_bfr_exg_cf/))
209  call this%cfg_dv('XOLD', '', sync_nds, (/stg_bfr_exg_ad, stg_bfr_exg_cf/))
210  call this%cfg_dv('ICELLTYPE', 'NPF', sync_nds, (/stg_bfr_con_ar/))
211  call this%cfg_dv('K11', 'NPF', sync_nds, (/stg_bfr_con_ar/))
212  call this%cfg_dv('K22', 'NPF', sync_nds, (/stg_bfr_con_ar/))
213  call this%cfg_dv('K33', 'NPF', sync_nds, (/stg_bfr_con_ar/))
214  if (this%gwfInterfaceModel%npf%iangle1 == 1) then
215  call this%cfg_dv('ANGLE1', 'NPF', sync_nds, (/stg_bfr_con_ar/))
216  end if
217  if (this%gwfInterfaceModel%npf%iangle2 == 1) then
218  call this%cfg_dv('ANGLE2', 'NPF', sync_nds, (/stg_bfr_con_ar/))
219  end if
220  if (this%gwfInterfaceModel%npf%iangle3 == 1) then
221  call this%cfg_dv('ANGLE3', 'NPF', sync_nds, (/stg_bfr_con_ar/))
222  end if
223  if (this%gwfInterfaceModel%npf%iwetdry == 1) then
224  call this%cfg_dv('WETDRY', 'NPF', sync_nds, (/stg_bfr_con_ar/))
225  end if
226  call this%cfg_dv('TOP', 'DIS', sync_nds, (/stg_bfr_con_ar/))
227  call this%cfg_dv('BOT', 'DIS', sync_nds, (/stg_bfr_con_ar/))
228  call this%cfg_dv('AREA', 'DIS', sync_nds, (/stg_bfr_con_ar/))
229  if (this%gwfInterfaceModel%inbuy > 0) then
230  call this%cfg_dv('DENSE', 'BUY', sync_nds, (/stg_bfr_exg_cf/))
231  end if
232 

◆ gwfgwfcon_ad()

subroutine gwfgwfconnectionmodule::gwfgwfcon_ad ( class(gwfgwfconnectiontype this)
private
Parameters
thisthis connection

Definition at line 305 of file GwfGwfConnection.f90.

306  class(GwfGwfConnectionType) :: this !< this connection
307 
308  ! this triggers the BUY density calculation
309  !if (this%gwfInterfaceModel%inbuy > 0) call this%gwfInterfaceModel%buy%buy_ad()
310 
311  if (this%owns_exchange) then
312  call this%gwfExchange%exg_ad()
313  end if
314 

◆ gwfgwfcon_ar()

subroutine gwfgwfconnectionmodule::gwfgwfcon_ar ( class(gwfgwfconnectiontype this)
Parameters
thisthis connection

Definition at line 264 of file GwfGwfConnection.f90.

266  class(GwfGwfConnectionType) :: this !< this connection
267  ! local
268 
269  ! check if we can construct an interface model
270  ! NB: only makes sense after the models' allocate&read have been
271  ! called, which is why we do it here
272  call this%validateConnection()
273 
274  ! allocate and read base
275  call this%spatialcon_ar()
276 
277  ! ... and now the interface model
278  call this%gwfInterfaceModel%model_ar()
279 
280  ! AR the movers and obs through the exchange
281  if (this%owns_exchange) then
282  if (this%gwfExchange%inmvr > 0) then
283  call this%gwfExchange%mvr%mvr_ar()
284  end if
285  if (this%gwfExchange%inobs > 0) then
286  call this%gwfExchange%obs%obs_ar()
287  end if
288  end if
289 
Refactoring issues towards parallel:
This class is used to construct the connections object for the interface model's spatial discretizati...

◆ gwfgwfcon_bd()

subroutine gwfgwfconnectionmodule::gwfgwfcon_bd ( class(gwfgwfconnectiontype this,
integer(i4b), intent(inout)  icnvg,
integer(i4b), intent(in)  isuppress_output,
integer(i4b), intent(in)  isolnid 
)
private
Parameters
thisthis connection
[in,out]icnvgconvergence flag
[in]isuppress_outputsuppress output when =1
[in]isolnidsolution id

Definition at line 679 of file GwfGwfConnection.f90.

680  class(GwfGwfConnectionType) :: this !< this connection
681  integer(I4B), intent(inout) :: icnvg !< convergence flag
682  integer(I4B), intent(in) :: isuppress_output !< suppress output when =1
683  integer(I4B), intent(in) :: isolnid !< solution id
684  ! local
685 
686  ! call exchange budget routine, also calls bd
687  ! for movers.
688  if (this%owns_exchange) then
689  call this%gwfExchange%exg_bd(icnvg, isuppress_output, isolnid)
690  end if
691 

◆ gwfgwfcon_cf()

subroutine gwfgwfconnectionmodule::gwfgwfcon_cf ( class(gwfgwfconnectiontype this,
integer(i4b), intent(in)  kiter 
)
private
Parameters
thisthis connection
[in]kiterthe iteration counter

Definition at line 317 of file GwfGwfConnection.f90.

318  class(GwfGwfConnectionType) :: this !< this connection
319  integer(I4B), intent(in) :: kiter !< the iteration counter
320 
321  call this%SpatialModelConnectionType%spatialcon_cf(kiter)
322 
323  ! CF the movers through the exchange
324  if (this%owns_exchange) then
325  if (this%gwfExchange%inmvr > 0) then
326  call this%gwfExchange%mvr%xmvr_cf()
327  end if
328  end if
329 

◆ gwfgwfcon_cq()

subroutine gwfgwfconnectionmodule::gwfgwfcon_cq ( class(gwfgwfconnectiontype this,
integer(i4b), intent(inout)  icnvg,
integer(i4b), intent(in)  isuppress_output,
integer(i4b), intent(in)  isolnid 
)
Parameters
thisthis connection
[in,out]icnvgconvergence flag
[in]isuppress_outputsuppress output when =1
[in]isolnidsolution id

Definition at line 497 of file GwfGwfConnection.f90.

498  class(GwfGwfConnectionType) :: this !< this connection
499  integer(I4B), intent(inout) :: icnvg !< convergence flag
500  integer(I4B), intent(in) :: isuppress_output !< suppress output when =1
501  integer(I4B), intent(in) :: isolnid !< solution id
502 
503  call this%gwfInterfaceModel%model_cq(icnvg, isuppress_output)
504 
505  call this%setFlowToExchange()
506 
507  call this%setFlowToModel()
508 
509  !cdl Could we allow GwfExchange to do this instead, using
510  ! simvals?
511  ! if needed, we add the edge properties to the model's NPF
512  ! package for its spdis calculation:
513  if (this%gwfModel%npf%icalcspdis == 1) then
514  call this%setNpfEdgeProps()
515  end if
516 
517  ! Add exchange flows to each model flowja diagonal. This used
518  ! to be done in setNpfEdgeProps, but there was a sign issue
519  ! and flowja was only updated if icalcspdis was 1 (it should
520  ! always be updated.
521  if (this%owns_exchange) then
522  call this%gwfExchange%gwf_gwf_add_to_flowja()
523  end if
524 

◆ gwfgwfcon_da()

subroutine gwfgwfconnectionmodule::gwfgwfcon_da ( class(gwfgwfconnectiontype this)
Parameters
thisthis connection

Definition at line 467 of file GwfGwfConnection.f90.

468  use kindmodule, only: lgp
469  class(GwfGwfConnectionType) :: this !< this connection
470  ! local
471  logical(LGP) :: isOpen
472 
473  ! scalars
474  call mem_deallocate(this%iXt3dOnExchange)
475 
476  call this%gwfInterfaceModel%model_da()
477  deallocate (this%gwfInterfaceModel)
478 
479  call this%spatialcon_da()
480 
481  inquire (this%iout, opened=isopen)
482  if (isopen) then
483  close (this%iout)
484  end if
485 
486  ! we need to deallocate the baseexchange we own:
487  if (this%owns_exchange) then
488  call this%gwfExchange%exg_da()
489  end if
490 
This module defines variable data types.
Definition: kind.f90:8

◆ gwfgwfcon_df()

subroutine gwfgwfconnectionmodule::gwfgwfcon_df ( class(gwfgwfconnectiontype this)

This sets up the GridConnection (for creating the interface grid), creates and defines the interface

Parameters
thisthis connection

Definition at line 142 of file GwfGwfConnection.f90.

143  class(GwfGwfConnectionType) :: this !< this connection
144  ! local
145  character(len=LENCOMPONENTNAME) :: imName !< the interface model's name
146  integer(I4B) :: i
147 
148  ! this sets up the GridConnection
149  call this%spatialcon_df()
150 
151  ! Now grid conn is defined, we create the interface model
152  ! here, and the remainder of this routine is define.
153  ! we basically follow the logic that is present in sln_df()
154  if (this%prim_exchange%v_model1 == this%owner) then
155  write (imname, '(a,i0)') 'GWFIM1_', this%gwfExchange%id
156  else
157  write (imname, '(a,i0)') 'GWFIM2_', this%gwfExchange%id
158  end if
159  call this%gwfInterfaceModel%gwfifm_cr(imname, this%iout, this%ig_builder)
160  call this%gwfInterfaceModel%set_idsoln(this%gwfModel%idsoln)
161  this%gwfInterfaceModel%npf%satomega = this%gwfModel%npf%satomega
162  this%gwfInterfaceModel%npf%ixt3d = this%iXt3dOnExchange
163  call this%gwfInterfaceModel%model_df()
164 
165  ! Take these settings from the owning model
166  this%gwfInterfaceModel%npf%ik22 = this%gwfModel%npf%ik22
167  this%gwfInterfaceModel%npf%ik33 = this%gwfModel%npf%ik33
168  this%gwfInterfaceModel%npf%iwetdry = this%gwfModel%npf%iwetdry
169  this%gwfInterfaceModel%npf%iangle1 = this%gwfModel%npf%iangle1
170  this%gwfInterfaceModel%npf%iangle2 = this%gwfModel%npf%iangle2
171  this%gwfInterfaceModel%npf%iangle3 = this%gwfModel%npf%iangle3
172 
173  call this%cfg_dist_vars()
174 
175  if (this%gwfInterfaceModel%npf%ixt3d > 0) then
176  this%gwfInterfaceModel%npf%iangle1 = 1
177  this%gwfInterfaceModel%npf%iangle2 = 1
178  this%gwfInterfaceModel%npf%iangle3 = 1
179  end if
180 
181  ! set defaults
182  do i = 1, size(this%gwfInterfaceModel%npf%angle1)
183  this%gwfInterfaceModel%npf%angle1 = 0.0_dp
184  end do
185  do i = 1, size(this%gwfInterfaceModel%npf%angle2)
186  this%gwfInterfaceModel%npf%angle2 = 0.0_dp
187  end do
188  do i = 1, size(this%gwfInterfaceModel%npf%angle3)
189  this%gwfInterfaceModel%npf%angle3 = 0.0_dp
190  end do
191 
192  ! point X, RHS, IBOUND to connection
193  call this%spatialcon_setmodelptrs()
194 
195  ! connect interface model to spatial connection
196  call this%spatialcon_connect()
197 

◆ gwfgwfcon_fc()

subroutine gwfgwfconnectionmodule::gwfgwfcon_fc ( class(gwfgwfconnectiontype 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
thisthis connection
[in]kiterthe iteration counter
matrix_slnglobal system matrix coefficients
[in,out]rhs_slnglobal right-hand-side
[in]inwtflagnewton-raphson flag

Definition at line 334 of file GwfGwfConnection.f90.

335  class(GwfGwfConnectionType) :: this !< this connection
336  integer(I4B), intent(in) :: kiter !< the iteration counter
337  class(MatrixBaseType), pointer :: matrix_sln !< global system matrix coefficients
338  real(DP), dimension(:), intent(inout) :: rhs_sln !< global right-hand-side
339  integer(I4B), optional, intent(in) :: inwtflag !< newton-raphson flag
340  ! local
341 
342  call this%SpatialModelConnectionType%spatialcon_fc( &
343  kiter, matrix_sln, rhs_sln, inwtflag)
344 
345  ! FC the movers through the exchange; we cannot call
346  ! exg_fc() directly because it calculates matrix terms
347  if (this%owns_exchange) then
348  if (this%gwfExchange%inmvr > 0) then
349  call this%gwfExchange%mvr%mvr_fc()
350  end if
351  end if
352 

◆ gwfgwfcon_ot()

subroutine gwfgwfconnectionmodule::gwfgwfcon_ot ( class(gwfgwfconnectiontype this)
private
Parameters
thisthis connection

Definition at line 696 of file GwfGwfConnection.f90.

697  class(GwfGwfConnectionType) :: this !< this connection
698  ! local
699 
700  ! Call exg_ot() here as it handles all output processing
701  ! based on gwfExchange%simvals(:), which was correctly
702  ! filled from gwfgwfcon
703  if (this%owns_exchange) then
704  call this%gwfExchange%exg_ot()
705  end if
706 

◆ gwfgwfcon_rp()

subroutine gwfgwfconnectionmodule::gwfgwfcon_rp ( class(gwfgwfconnectiontype this)
Parameters
thisthis connection

Definition at line 294 of file GwfGwfConnection.f90.

295  class(GwfGwfConnectionType) :: this !< this connection
296 
297  ! Call exchange rp routines
298  if (this%owns_exchange) then
299  call this%gwfExchange%exg_rp()
300  end if

◆ gwfgwfconnection_ctor()

subroutine gwfgwfconnectionmodule::gwfgwfconnection_ctor ( class(gwfgwfconnectiontype this,
class(numericalmodeltype), pointer  model,
class(disconnexchangetype), pointer  gwfEx 
)
Parameters
thisthe connection
modelthe model owning this connection, this must of course be a GwfModelType
gwfexthe exchange the interface model is created for

Definition at line 81 of file GwfGwfConnection.f90.

83  use inputoutputmodule, only: openfile
84  class(GwfGwfConnectionType) :: this !< the connection
85  class(NumericalModelType), pointer :: model !< the model owning this connection,
86  !! this must of course be a GwfModelType
87  class(DisConnExchangeType), pointer :: gwfEx !< the 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%gwfModel => castasgwfmodel(objptr)
96  objptr => gwfex
97  this%gwfExchange => castasgwfexchange(objptr)
98 
99  if (gwfex%v_model1%is_local .and. gwfex%v_model2%is_local) then
100  this%owns_exchange = (gwfex%v_model1 == model)
101  else
102  this%owns_exchange = .true.
103  end if
104 
105  if (gwfex%v_model1 == model) then
106  write (name, '(a,i0)') 'GWFCON1_', gwfex%id
107  else
108  write (name, '(a,i0)') 'GWFCON2_', gwfex%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 GWF-GWF connection for model ', &
116  trim(this%gwfModel%name), ' from exchange ', &
117  trim(gwfex%name)
118  end if
119 
120  ! first call base constructor
121  call this%SpatialModelConnectionType%spatialConnection_ctor(model, &
122  gwfex, &
123  name)
124 
125  call this%allocateScalars()
126 
127  this%typename = 'GWF-GWF'
128 
129  ! determine the required size of the interface grid
130  call this%setGridExtent()
131 
132  allocate (this%gwfInterfaceModel)
133  this%interface_model => this%gwfInterfaceModel
134 
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 gwfgwfconnectionmodule::setflowtoexchange ( class(gwfgwfconnectiontype this)
private
Parameters
thisthis connection

Definition at line 529 of file GwfGwfConnection.f90.

530  use indexmapmodule
531  class(GwfGwfConnectionType) :: this !< this connection
532  ! local
533  integer(I4B) :: i
534  class(GwfExchangeType), pointer :: gwfEx
535  type(IndexMapSgnType), pointer :: map
536 
537  if (this%owns_exchange) then
538  gwfex => this%gwfExchange
539  map => this%interface_map%exchange_maps(this%interface_map%prim_exg_idx)
540 
541  ! use (half of) the exchange map in reverse:
542  do i = 1, size(map%src_idx)
543  if (map%sign(i) < 0) cycle ! simvals is defined from exg%m1 => exg%m2
544  gwfex%simvals(map%src_idx(i)) = &
545  this%gwfInterfaceModel%flowja(map%tgt_idx(i))
546  end do
547  end if
548 

◆ setflowtomodel()

subroutine gwfgwfconnectionmodule::setflowtomodel ( class(gwfgwfconnectiontype this)
Parameters
thisthis connection

Definition at line 553 of file GwfGwfConnection.f90.

554  class(GwfGwfConnectionType) :: this !< this connection
555  ! local
556  integer(I4B) :: n, m, ipos, iposLoc
557  integer(I4B) :: nLoc, mLoc
558  type(ConnectionsType), pointer :: imCon !< interface model connections
559  type(GlobalCellType), dimension(:), pointer :: toGlobal !< map interface index to global cell
560 
561  ! for readability
562  imcon => this%gwfInterfaceModel%dis%con
563  toglobal => this%ig_builder%idxToGlobal
564 
565  do n = 1, this%neq
566  if (.not. toglobal(n)%v_model == this%owner) then
567  ! only add flows to own model
568  cycle
569  end if
570 
571  nloc = toglobal(n)%index
572 
573  do ipos = imcon%ia(n) + 1, imcon%ia(n + 1) - 1
574  if (imcon%mask(ipos) < 1) cycle ! skip this connection, it's masked so not determined by us
575 
576  m = imcon%ja(ipos)
577  mloc = toglobal(m)%index
578  if (toglobal(m)%v_model == this%owner) then
579 
580  ! internal, need to set flowja for n-m
581  iposloc = getcsrindex(nloc, mloc, this%gwfModel%ia, this%gwfModel%ja)
582 
583  ! update flowja with correct value
584  this%gwfModel%flowja(iposloc) = this%gwfInterfaceModel%flowja(ipos)
585 
586  end if
587  end do
588  end do
589 
Here is the call graph for this function:

◆ setgridextent()

subroutine gwfgwfconnectionmodule::setgridextent ( class(gwfgwfconnectiontype this)
private
Parameters
thisthe connection

Definition at line 237 of file GwfGwfConnection.f90.

238  class(GwfGwfConnectionType) :: this !< the connection
239  ! local
240 
241  this%iXt3dOnExchange = this%gwfExchange%ixt3d
242  if (this%iXt3dOnExchange > 0) then
243  this%exg_stencil_depth = 2
244  if (this%gwfModel%npf%ixt3d > 0) then
245  this%int_stencil_depth = 2
246  end if
247  end if
248 

◆ setnpfedgeprops()

subroutine gwfgwfconnectionmodule::setnpfedgeprops ( class(gwfgwfconnectiontype this)
private
Parameters
thisthis connection

Definition at line 594 of file GwfGwfConnection.f90.

595  class(GwfGwfConnectionType) :: this !< this connection
596  ! local
597  integer(I4B) :: n, m, ipos, isym
598  integer(I4B) :: nLoc, mLoc
599  integer(I4B) :: ihc
600  real(DP) :: rrate
601  real(DP) :: area
602  real(DP) :: satThick
603  real(DP) :: nx, ny, nz
604  real(DP) :: cx, cy, cz
605  real(DP) :: conLen
606  real(DP) :: dist
607  real(DP) :: cl
608  logical :: nozee
609  type(ConnectionsType), pointer :: imCon !< interface model connections
610  class(GwfNpfType), pointer :: imNpf !< interface model npf package
611  class(DisBaseType), pointer :: imDis !< interface model discretization
612  type(GlobalCellType), dimension(:), pointer :: toGlobal !< map interface index to global cell
613 
614  ! for readability
615  imdis => this%gwfInterfaceModel%dis
616  imcon => this%gwfInterfaceModel%dis%con
617  imnpf => this%gwfInterfaceModel%npf
618  toglobal => this%ig_builder%idxToGlobal
619 
620  nozee = .false.
621  if (imnpf%ixt3d > 0) then
622  nozee = imnpf%xt3d%nozee
623  end if
624 
625  ! loop over flowja in the interface model and set edge properties
626  ! for flows crossing the boundary, and set flowja for internal
627  ! flows affected by the connection.
628  do n = 1, this%neq
629  if (.not. toglobal(n)%v_model == this%owner) then
630  ! only add flows to own model
631  cycle
632  end if
633 
634  nloc = toglobal(n)%index
635 
636  do ipos = imcon%ia(n) + 1, imcon%ia(n + 1) - 1
637  if (imcon%mask(ipos) < 1) then
638  ! skip this connection, it's masked so not determined by us
639  cycle
640  end if
641 
642  m = imcon%ja(ipos)
643  mloc = toglobal(m)%index
644 
645  if (.not. toglobal(m)%v_model == this%owner) then
646  ! boundary connection, set edge properties
647  isym = imcon%jas(ipos)
648  ihc = imcon%ihc(isym)
649  area = imcon%hwva(isym)
650  satthick = imnpf%calcSatThickness(n, m, ihc)
651  rrate = this%gwfInterfaceModel%flowja(ipos)
652 
653  call imdis%connection_normal(n, m, ihc, nx, ny, nz, ipos)
654  call imdis%connection_vector(n, m, nozee, imnpf%sat(n), imnpf%sat(m), &
655  ihc, cx, cy, cz, conlen)
656 
657  if (ihc == 0) then
658  ! check if n is below m
659  if (nz > 0) rrate = -rrate
660  else
661  area = area * satthick
662  end if
663 
664  cl = imcon%cl1(isym)
665  if (m < n) then
666  cl = imcon%cl2(isym)
667  end if
668  dist = conlen * cl / (imcon%cl1(isym) + imcon%cl2(isym))
669  call this%gwfModel%npf%set_edge_properties(nloc, ihc, rrate, area, &
670  nx, ny, dist)
671  end if
672  end do
673  end do
674 

◆ validateconnection()

subroutine gwfgwfconnectionmodule::validateconnection ( class(gwfgwfconnectiontype this)
private
Parameters
thisthis connection

Definition at line 359 of file GwfGwfConnection.f90.

360  use simvariablesmodule, only: errmsg
361  use simmodule, only: count_errors
362  class(GwfGwfConnectionType) :: this !< this connection
363  ! local
364 
365  ! base validation (geometry/spatial)
366  call this%SpatialModelConnectionType%validateConnection()
367  call this%validateGwfExchange()
368 
369  ! abort on errors
370  if (count_errors() > 0) then
371  write (errmsg, '(a)') 'Errors occurred while processing exchange(s)'
372  call ustop()
373  end if
374 
This module contains simulation methods.
Definition: Sim.f90:10
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:

◆ validategwfexchange()

subroutine gwfgwfconnectionmodule::validategwfexchange ( class(gwfgwfconnectiontype this)

Stops with error message on config mismatch

Parameters
thisthis connection

Definition at line 383 of file GwfGwfConnection.f90.

385  use simmodule, only: store_error
386  use gwfnpfmodule, only: gwfnpftype
387  class(GwfGwfConnectionType) :: this !< this connection
388  ! local
389  class(GwfExchangeType), pointer :: gwfEx
390  class(*), pointer :: modelPtr
391  class(GwfModelType), pointer :: gwfModel1
392  class(GwfModelType), pointer :: gwfModel2
393  type(GwfBuyType), pointer :: buy1, buy2
394  logical(LGP) :: compatible
395 
396  gwfex => this%gwfExchange
397 
398  ! GNC not allowed
399  if (gwfex%ingnc /= 0 .and. gwfex%ixt3d /= 0) then
400  write (errmsg, '(2a)') 'Ghost node correction not supported '// &
401  'combined with XT3D for exchange ', trim(gwfex%name)
402  call store_error(errmsg)
403  end if
404  if (gwfex%ingnc /= 0 .and. simulation_mode == 'PARALLEL') then
405  write (errmsg, '(2a)') 'Ghost node correction not supported '// &
406  'in parallel run for exchange ', trim(gwfex%name)
407  call store_error(errmsg)
408  end if
409 
410  ! we cannot validate the remainder (yet) in parallel mode
411  if (.not. gwfex%v_model1%is_local) return
412  if (.not. gwfex%v_model2%is_local) return
413 
414  modelptr => this%gwfExchange%model1
415  gwfmodel1 => castasgwfmodel(modelptr)
416  modelptr => this%gwfExchange%model2
417  gwfmodel2 => castasgwfmodel(modelptr)
418 
419  if ((gwfmodel1%inbuy > 0 .and. gwfmodel2%inbuy == 0) .or. &
420  (gwfmodel1%inbuy == 0 .and. gwfmodel2%inbuy > 0)) then
421  write (errmsg, '(2a)') 'Buoyancy package should be enabled/disabled '// &
422  'simultaneously in models connected with the '// &
423  'interface model for exchange ', &
424  trim(gwfex%name)
425  call store_error(errmsg)
426 
427  end if
428 
429  if (gwfmodel1%inbuy > 0 .and. gwfmodel2%inbuy > 0) then
430  ! does not work with XT3D
431  if (this%iXt3dOnExchange > 0) then
432  write (errmsg, '(2a)') 'Connecting models with BUY package not '// &
433  'allowed with XT3D enabled on exchange ', &
434  trim(gwfex%name)
435  call store_error(errmsg)
436  end if
437 
438  ! check compatibility of buoyancy
439  compatible = .true.
440  buy1 => gwfmodel1%buy
441  buy2 => gwfmodel2%buy
442  if (buy1%iform /= buy2%iform) compatible = .false.
443  if (buy1%denseref /= buy2%denseref) compatible = .false.
444  if (buy1%nrhospecies /= buy2%nrhospecies) compatible = .false.
445  if (.not. all(buy1%drhodc == buy2%drhodc)) compatible = .false.
446  if (.not. all(buy1%crhoref == buy2%crhoref)) compatible = .false.
447  if (.not. all(buy1%cauxspeciesname == buy2%cauxspeciesname)) then
448  compatible = .false.
449  end if
450 
451  if (.not. compatible) then
452  write (errmsg, '(6a)') 'Buoyancy packages in model ', &
453  trim(gwfex%model1%name), ' and ', &
454  trim(gwfex%model2%name), &
455  ' should be equivalent to construct an '// &
456  ' interface model for exchange ', &
457  trim(gwfex%name)
458  call store_error(errmsg)
459  end if
460 
461  end if
462 
subroutine, public store_error(msg, terminate)
Store an error message.
Definition: Sim.f90:92
character(len=linelength) simulation_mode
Here is the call graph for this function: