43 integer(I4B),
pointer :: ixt3donexchange => null()
45 integer(I4B) :: iout = 0
89 character(len=LINELENGTH) :: fname
90 character(len=LENCOMPONENTNAME) :: name
91 class(*),
pointer :: objPtr
92 logical(LGP) :: write_ifmodel_listfile = .false.
99 if (gwfex%v_model1%is_local .and. gwfex%v_model2%is_local)
then
100 this%owns_exchange = (gwfex%v_model1 == model)
102 this%owns_exchange = .true.
105 if (gwfex%v_model1 == model)
then
106 write (name,
'(a,i0)')
'GWFCON1_', gwfex%id
108 write (name,
'(a,i0)')
'GWFCON2_', gwfex%id
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 ', &
121 call this%SpatialModelConnectionType%spatialConnection_ctor(model, &
125 call this%allocateScalars()
127 this%typename =
'GWF-GWF'
130 call this%setGridExtent()
132 allocate (this%gwfInterfaceModel)
133 this%interface_model => this%gwfInterfaceModel
145 character(len=LENCOMPONENTNAME) :: imName
149 call this%spatialcon_df()
154 if (this%prim_exchange%v_model1 == this%owner)
then
155 write (imname,
'(a,i0)')
'GWFIM1_', this%gwfExchange%id
157 write (imname,
'(a,i0)')
'GWFIM2_', this%gwfExchange%id
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()
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
173 call this%cfg_dist_vars()
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
182 do i = 1,
size(this%gwfInterfaceModel%npf%angle1)
183 this%gwfInterfaceModel%npf%angle1 = 0.0_dp
185 do i = 1,
size(this%gwfInterfaceModel%npf%angle2)
186 this%gwfInterfaceModel%npf%angle2 = 0.0_dp
188 do i = 1,
size(this%gwfInterfaceModel%npf%angle3)
189 this%gwfInterfaceModel%npf%angle3 = 0.0_dp
193 call this%spatialcon_setmodelptrs()
196 call this%spatialcon_connect()
205 call this%cfg_dv(
'X',
'',
sync_nds, &
207 call this%cfg_dv(
'IBOUND',
'',
sync_nds, &
214 if (this%gwfInterfaceModel%npf%iangle1 == 1)
then
217 if (this%gwfInterfaceModel%npf%iangle2 == 1)
then
220 if (this%gwfInterfaceModel%npf%iangle3 == 1)
then
223 if (this%gwfInterfaceModel%npf%iwetdry == 1)
then
229 if (this%gwfInterfaceModel%inbuy > 0)
then
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
258 call mem_allocate(this%iXt3dOnExchange,
'IXT3DEXG', this%memoryPath)
272 call this%validateConnection()
275 call this%spatialcon_ar()
278 call this%gwfInterfaceModel%model_ar()
281 if (this%owns_exchange)
then
282 if (this%gwfExchange%inmvr > 0)
then
283 call this%gwfExchange%mvr%mvr_ar()
285 if (this%gwfExchange%inobs > 0)
then
286 call this%gwfExchange%obs%obs_ar()
298 if (this%owns_exchange)
then
299 call this%gwfExchange%exg_rp()
313 if (this%owns_exchange)
then
314 call this%gwfExchange%exg_ad()
321 integer(I4B),
intent(in) :: kiter
323 call this%SpatialModelConnectionType%spatialcon_cf(kiter)
326 if (this%owns_exchange)
then
327 if (this%gwfExchange%inmvr > 0)
then
328 call this%gwfExchange%mvr%xmvr_cf()
338 integer(I4B),
intent(in) :: kiter
340 real(DP),
dimension(:),
intent(inout) :: rhs_sln
341 integer(I4B),
optional,
intent(in) :: inwtflag
344 call this%SpatialModelConnectionType%spatialcon_fc( &
345 kiter, matrix_sln, rhs_sln, inwtflag)
349 if (this%owns_exchange)
then
350 if (this%gwfExchange%inmvr > 0)
then
351 call this%gwfExchange%mvr%mvr_fc()
368 call this%SpatialModelConnectionType%validateConnection()
369 call this%validateGwfExchange()
373 write (
errmsg,
'(a)')
'Errors occurred while processing exchange(s)'
392 class(*),
pointer :: modelPtr
396 logical(LGP) :: compatible
398 gwfex => this%gwfExchange
401 if (gwfex%ingnc /= 0 .and. gwfex%ixt3d /= 0)
then
402 write (
errmsg,
'(2a)')
'Ghost node correction not supported '// &
403 'combined with XT3D for exchange ', trim(gwfex%name)
407 write (
errmsg,
'(2a)')
'Ghost node correction not supported '// &
408 'in parallel run for exchange ', trim(gwfex%name)
413 if (.not. gwfex%v_model1%is_local)
return
414 if (.not. gwfex%v_model2%is_local)
return
416 modelptr => this%gwfExchange%model1
418 modelptr => this%gwfExchange%model2
421 if ((gwfmodel1%inbuy > 0 .and. gwfmodel2%inbuy == 0) .or. &
422 (gwfmodel1%inbuy == 0 .and. gwfmodel2%inbuy > 0))
then
423 write (
errmsg,
'(2a)')
'Buoyancy package should be enabled/disabled '// &
424 'simultaneously in models connected with the '// &
425 'interface model for exchange ', &
431 if (gwfmodel1%inbuy > 0 .and. gwfmodel2%inbuy > 0)
then
433 if (this%iXt3dOnExchange > 0)
then
434 write (
errmsg,
'(2a)')
'Connecting models with BUY package not '// &
435 'allowed with XT3D enabled on exchange ', &
442 buy1 => gwfmodel1%buy
443 buy2 => gwfmodel2%buy
444 if (buy1%iform /= buy2%iform) compatible = .false.
445 if (buy1%denseref /= buy2%denseref) compatible = .false.
446 if (buy1%nrhospecies /= buy2%nrhospecies) compatible = .false.
447 if (.not. all(buy1%drhodc == buy2%drhodc)) compatible = .false.
448 if (.not. all(buy1%crhoref == buy2%crhoref)) compatible = .false.
449 if (.not. all(buy1%cauxspeciesname == buy2%cauxspeciesname))
then
453 if (.not. compatible)
then
454 write (
errmsg,
'(6a)')
'Buoyancy packages in model ', &
455 trim(gwfex%model1%name),
' and ', &
456 trim(gwfex%model2%name), &
457 ' should be equivalent to construct an '// &
458 ' interface model for exchange ', &
473 logical(LGP) :: isOpen
478 call this%gwfInterfaceModel%model_da()
479 deallocate (this%gwfInterfaceModel)
481 call this%spatialcon_da()
483 inquire (this%iout, opened=isopen)
489 if (this%owns_exchange)
then
490 call this%gwfExchange%exg_da()
501 integer(I4B),
intent(inout) :: icnvg
502 integer(I4B),
intent(in) :: isuppress_output
503 integer(I4B),
intent(in) :: isolnid
505 call this%gwfInterfaceModel%model_cq(icnvg, isuppress_output)
507 call this%setFlowToExchange()
509 call this%setFlowToModel()
515 if (this%gwfModel%npf%icalcspdis == 1)
then
516 call this%setNpfEdgeProps()
523 if (this%owns_exchange)
then
524 call this%gwfExchange%gwf_gwf_add_to_flowja()
539 if (this%owns_exchange)
then
540 gwfex => this%gwfExchange
541 map => this%interface_map%exchange_maps(this%interface_map%prim_exg_idx)
544 do i = 1,
size(map%src_idx)
545 if (map%sign(i) < 0) cycle
546 gwfex%simvals(map%src_idx(i)) = &
547 this%gwfInterfaceModel%flowja(map%tgt_idx(i))
558 integer(I4B) :: n, m, ipos, iposLoc
559 integer(I4B) :: nLoc, mLoc
564 imcon => this%gwfInterfaceModel%dis%con
565 toglobal => this%ig_builder%idxToGlobal
568 if (.not. toglobal(n)%v_model == this%owner)
then
573 nloc = toglobal(n)%index
575 do ipos = imcon%ia(n) + 1, imcon%ia(n + 1) - 1
576 if (imcon%mask(ipos) < 1) cycle
579 mloc = toglobal(m)%index
580 if (toglobal(m)%v_model == this%owner)
then
583 iposloc =
getcsrindex(nloc, mloc, this%gwfModel%ia, this%gwfModel%ja)
586 this%gwfModel%flowja(iposloc) = this%gwfInterfaceModel%flowja(ipos)
599 integer(I4B) :: n, m, ipos, isym
600 integer(I4B) :: nLoc, mLoc
605 real(DP) :: nx, ny, nz
606 real(DP) :: cx, cy, cz
617 imdis => this%gwfInterfaceModel%dis
618 imcon => this%gwfInterfaceModel%dis%con
619 imnpf => this%gwfInterfaceModel%npf
620 toglobal => this%ig_builder%idxToGlobal
623 if (imnpf%ixt3d > 0)
then
624 nozee = imnpf%xt3d%nozee
631 if (.not. toglobal(n)%v_model == this%owner)
then
636 nloc = toglobal(n)%index
638 do ipos = imcon%ia(n) + 1, imcon%ia(n + 1) - 1
639 if (imcon%mask(ipos) < 1)
then
645 mloc = toglobal(m)%index
647 if (.not. toglobal(m)%v_model == this%owner)
then
649 isym = imcon%jas(ipos)
650 ihc = imcon%ihc(isym)
651 area = imcon%hwva(isym)
652 satthick = imnpf%calcSatThickness(n, m, ihc)
653 rrate = this%gwfInterfaceModel%flowja(ipos)
655 call imdis%connection_normal(n, m, ihc, nx, ny, nz, ipos)
656 call imdis%connection_vector(n, m, nozee, imnpf%sat(n), imnpf%sat(m), &
657 ihc, cx, cy, cz, conlen)
661 if (nz > 0) rrate = -rrate
663 area = area * satthick
670 dist = conlen * cl / (imcon%cl1(isym) + imcon%cl2(isym))
671 call this%gwfModel%npf%set_edge_properties(nloc, ihc, rrate, area, &
683 integer(I4B),
intent(inout) :: icnvg
684 integer(I4B),
intent(in) :: isuppress_output
685 integer(I4B),
intent(in) :: isolnid
690 if (this%owns_exchange)
then
691 call this%gwfExchange%exg_bd(icnvg, isuppress_output, isolnid)
705 if (this%owns_exchange)
then
706 call this%gwfExchange%exg_ot()
715 class(*),
pointer,
intent(inout) :: obj
719 if (.not.
associated(obj))
return
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
integer(i4b), parameter lencomponentname
maximum length of a component name
integer(i4b), parameter lenvarname
maximum length of a variable name
real(dp), parameter dem6
real constant 1e-6
real(dp), parameter dzero
real constant zero
integer(i4b), parameter lenmempath
maximum length of the memory path
real(dp), parameter done
real constant 1
integer(i4b) function, public getcsrindex(i, j, ia, ja)
Return index for element i,j in CSR storage,.
integer(i4b), parameter, public sync_nds
synchronize over nodes
Refactoring issues towards parallel:
subroutine cfg_dist_vars(this)
Configure distributed variables for this interface model.
subroutine gwfgwfcon_cf(this, kiter)
subroutine gwfgwfcon_ad(this)
Advance this connection.
subroutine setflowtoexchange(this)
Set the flows (flowja from interface model) to the.
subroutine gwfgwfcon_cq(this, icnvg, isuppress_output, isolnid)
Calculate intra-cell flows The calculation will be dispatched to the interface model,...
subroutine gwfgwfcon_bd(this, icnvg, isuppress_output, isolnid)
Calculate the budget terms for this connection, this is dispatched to the GWF-GWF exchange.
class(gwfgwfconnectiontype) function, pointer, public castasgwfgwfconnection(obj)
Cast to GwfGwfConnectionType.
subroutine setnpfedgeprops(this)
Set flowja as edge properties in the model,.
subroutine validategwfexchange(this)
Validate the exchange, intercepting those cases where two models have to be connected with an interfa...
subroutine allocatescalars(this)
allocation of scalars in the connection
subroutine gwfgwfcon_fc(this, kiter, matrix_sln, rhs_sln, inwtflag)
Write the calculated coefficients into the global.
subroutine setgridextent(this)
Set the required size of the interface grid from.
subroutine gwfgwfcon_rp(this)
Read time varying data when required.
subroutine gwfgwfcon_ar(this)
Allocate and read the connection.
subroutine gwfgwfcon_df(this)
Define the connection.
subroutine validateconnection(this)
Validate this connection This is called before proceeding to construct the interface model.
subroutine setflowtomodel(this)
Set the flows (flowja from the interface model) to.
subroutine gwfgwfconnection_ctor(this, model, gwfEx)
Basic construction of the connection.
subroutine gwfgwfcon_ot(this)
Write output for exchange (and calls.
subroutine gwfgwfcon_da(this)
Deallocate all resources.
This module contains the GwfGwfExchangeModule Module.
class(gwfexchangetype) function, pointer, public getgwfexchangefromlist(list, idx)
@ brief Get exchange from list
class(gwfexchangetype) function, pointer, public castasgwfexchange(obj)
@ brief Cast polymorphic object as exchange
class(gwfmodeltype) function, pointer, public castasgwfmodel(model)
Cast to GWF model.
This module defines variable data types.
This module contains simulation methods.
subroutine, public ustop(stopmess, ioutlocal)
Stop the simulation.
subroutine, public store_error(msg, terminate)
Store an error message.
integer(i4b) function, public count_errors()
Return number of errors.
integer(i4b), parameter, public stg_bfr_exg_ad
before exchange advance (per solution)
integer(i4b), parameter, public stg_bfr_exg_cf
before exchange calculate (per solution)
integer(i4b), parameter, public stg_bfr_con_ar
before connection allocate read
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
character(len=linelength) simulation_mode
Data structure to hold a global cell identifier, using a pointer to the model and its local cell.
Exchange based on connection between discretizations of DisBaseType. The data specifies the connectio...
This class is used to construct the connections object for the interface model's spatial discretizati...
Connecting a GWF model to other models in space, implements NumericalExchangeType so the solution can...
Derived type for GwfExchangeType.
The GWF Interface Model is a utility to calculate the solution's exchange coefficients from the inter...
Class to manage spatial connection of a model to one or more models of the same type....