34 integer(I4B),
pointer :: iifaceadvscheme => null()
36 integer(I4B),
pointer :: iifacext3d => null()
37 integer(I4B),
pointer :: exgflowsign => null()
38 real(dp),
dimension(:),
pointer,
contiguous :: exgflowjagwe => null()
41 real(dp),
dimension(:),
pointer,
contiguous :: gwfflowja => null()
42 real(dp),
dimension(:),
pointer,
contiguous :: gwfsat => null()
43 real(dp),
dimension(:),
pointer,
contiguous :: gwfhead => null()
44 real(dp),
dimension(:, :),
pointer,
contiguous :: gwfspdis => null()
46 real(dp),
dimension(:),
pointer,
contiguous :: conc => null()
47 integer(I4B),
dimension(:),
pointer,
contiguous :: icbound => null()
49 integer(I4B) :: iout = 0
92 character(len=LINELENGTH) :: fname
93 character(len=LENCOMPONENTNAME) :: name
94 class(*),
pointer :: objPtr
95 logical(LGP) :: write_ifmodel_listfile = .false.
102 if (gweex%v_model1%is_local .and. gweex%v_model2%is_local)
then
103 this%owns_exchange =
associated(model, gweex%model1)
105 this%owns_exchange = .true.
108 if (gweex%v_model1 == model)
then
109 write (name,
'(a,i0)')
'GWECON1_', gweex%id
111 write (name,
'(a,i0)')
'GWECON2_', gweex%id
115 if (write_ifmodel_listfile)
then
116 fname = trim(name)//
'.im.lst'
117 call openfile(this%iout, 0, fname,
'LIST', filstat_opt=
'REPLACE')
118 write (this%iout,
'(4a)')
'Creating GWE-GWE connection for model ', &
119 trim(this%gweModel%name),
'from exchange ', &
124 call this%SpatialModelConnectionType%spatialConnection_ctor(model, &
128 call this%allocate_scalars()
129 this%typename =
'GWE-GWE'
130 this%iIfaceAdvScheme = 0
134 allocate (this%gweInterfaceModel)
135 this%interface_model => this%gweInterfaceModel
145 call mem_allocate(this%iIfaceAdvScheme,
'IADVSCHEME', this%memoryPath)
146 call mem_allocate(this%iIfaceXt3d,
'IXT3D', this%memoryPath)
147 call mem_allocate(this%exgflowSign,
'EXGFLOWSIGN', this%memoryPath)
157 character(len=LENCOMPONENTNAME) :: imName
161 this%iIfaceAdvScheme = this%gweExchange%iAdvScheme
164 this%iIfaceXt3d = this%gweExchange%ixt3d
167 if (this%gweModel%incnd > 0)
then
168 this%iIfaceXt3d = this%gweModel%cnd%ixt3d
172 call this%setGridExtent()
175 call this%spatialcon_df()
179 if (this%prim_exchange%v_model1 == this%owner)
then
180 write (imname,
'(a,i0)')
'GWEIM1_', this%gweExchange%id
182 write (imname,
'(a,i0)')
'GWEIM2_', this%gweExchange%id
184 call this%gweInterfaceModel%gweifmod_cr(imname, &
187 call this%gweInterfaceModel%set_idsoln(this%gweModel%idsoln)
188 this%gweInterfaceModel%iAdvScheme = this%iIfaceAdvScheme
189 this%gweInterfaceModel%ixt3d = this%iIfaceXt3d
190 call this%gweInterfaceModel%model_df()
192 call this%cfg_dist_vars()
194 call this%allocate_arrays()
195 call this%gweInterfaceModel%allocate_fmi()
198 call this%spatialcon_setmodelptrs()
201 this%conc => this%gweInterfaceModel%x
202 this%icbound => this%gweInterfaceModel%ibound
205 call this%spatialcon_connect()
215 call this%cfg_dv(
'X',
'',
sync_nds, &
222 if (this%gweInterfaceModel%cnd%idisp > 0)
then
236 exg_var_name=
'GWFSIMVALS')
238 if (this%gweModel%incnd > 0 .and. this%gweModel%inest > 0)
then
249 call mem_allocate(this%exgflowjaGwe, this%ig_builder%nrOfBoundaryCells, &
250 'EXGFLOWJAGWT', this%memoryPath)
260 logical(LGP) :: hasAdv, hasCnd
262 hasadv = this%gweModel%inadv > 0
263 hascnd = this%gweModel%incnd > 0
266 if (this%iIfaceAdvScheme == 2)
then
267 this%exg_stencil_depth = 2
268 if (this%gweModel%adv%iadvwt == 2)
then
269 this%int_stencil_depth = 2
275 if (this%iIfaceXt3d > 0)
then
276 this%exg_stencil_depth = 2
277 if (this%gweModel%cnd%ixt3d > 0)
then
278 this%int_stencil_depth = 2
293 call this%validateConnection()
296 call this%spatialcon_ar()
299 call this%gweInterfaceModel%model_ar()
302 if (this%gweModel%inest > 0)
then
303 this%gweInterfaceModel%gwecommon%gwecpw => this%gweModel%gwecommon%gwecpw
304 this%gweInterfaceModel%gwecommon%gwerhow => this%gweModel%gwecommon%gwerhow
309 if (this%gweModel%incnd > 0)
then
310 this%gweInterfaceModel%ieqnsclfac = this%gweModel%cnd%eqnsclfac
314 if (this%owns_exchange)
then
319 if (this%gweExchange%inobs > 0)
then
320 call this%gweExchange%obs%obs_ar()
334 call this%SpatialModelConnectionType%validateConnection()
337 if (.not. this%gweExchange%v_model1%is_local)
return
338 if (.not. this%gweExchange%v_model2%is_local)
return
341 call this%validateGweExchange()
344 if ((this%gweExchange%gwemodel1%inadv > 0 .and. &
345 this%gweExchange%gwemodel2%inadv == 0) .or. &
346 (this%gweExchange%gwemodel2%inadv > 0 .and. &
347 this%gweExchange%gwemodel1%inadv == 0))
then
348 write (
errmsg,
'(1x,a,a,a)')
'Cannot connect GWE models in exchange ', &
349 trim(this%gweExchange%name),
' because one model is configured with ADV &
350 &and the other one is not'
354 if ((this%gweExchange%gwemodel1%incnd > 0 .and. &
355 this%gweExchange%gwemodel2%incnd == 0) .or. &
356 (this%gweExchange%gwemodel2%incnd > 0 .and. &
357 this%gweExchange%gwemodel1%incnd == 0))
then
358 write (
errmsg,
'(1x,a,a,a)')
'Cannot connect GWE models in exchange ', &
359 trim(this%gweExchange%name),
' because one model is configured with CND &
360 &and the other one is not'
366 write (
errmsg,
'(a)')
'Errors occurred while processing exchange(s)'
377 if (this%owns_exchange)
then
378 call this%gweExchange%exg_rp()
390 if (this%gweInterfaceModel%incnd > 0)
call this%gweInterfaceModel%cnd%cnd_ad()
392 if (this%owns_exchange)
then
393 call this%gweExchange%exg_ad()
401 integer(I4B),
intent(in) :: kiter
403 real(DP),
dimension(:),
intent(inout) :: rhs_sln
404 integer(I4B),
optional,
intent(in) :: inwtflag
406 call this%SpatialModelConnectionType%spatialcon_fc( &
407 kiter, matrix_sln, rhs_sln, inwtflag)
410 if (this%owns_exchange)
then
411 if (this%gweExchange%inmvt > 0)
then
412 call this%gweExchange%mvt%mvt_fc(this%gweExchange%gwemodel1%x, &
413 this%gweExchange%gwemodel2%x)
422 integer(I4B),
intent(inout) :: icnvg
423 integer(I4B),
intent(in) :: isuppress_output
424 integer(I4B),
intent(in) :: isolnid
426 call this%gweInterfaceModel%model_cq(icnvg, isuppress_output)
427 call this%setFlowToExchange()
443 if (this%owns_exchange)
then
444 gweex => this%gweExchange
445 map => this%interface_map%exchange_maps(this%interface_map%prim_exg_idx)
448 do i = 1,
size(map%src_idx)
449 if (map%sign(i) < 0) cycle
450 gweex%simvals(map%src_idx(i)) = &
451 this%gweInterfaceModel%flowja(map%tgt_idx(i))
462 integer(I4B),
intent(inout) :: icnvg
463 integer(I4B),
intent(in) :: isuppress_output
464 integer(I4B),
intent(in) :: isolnid
468 if (this%owns_exchange)
then
469 call this%gweExchange%exg_bd(icnvg, isuppress_output, isolnid)
481 if (this%owns_exchange)
then
482 call this%gweExchange%exg_ot()
504 class(*),
pointer :: modelPtr
508 logical(LGP) :: compatible
510 gweex => this%gweExchange
513 if (.not. gweex%v_model1%is_local)
return
514 if (.not. gweex%v_model2%is_local)
return
516 modelptr => this%gweExchange%model1
518 modelptr => this%gweExchange%model2
522 if ((gwemodel1%inest > 0 .and. gwemodel2%inest == 0) .or. &
523 (gwemodel1%inest == 0 .and. gwemodel2%inest > 0))
then
524 write (
errmsg,
'(2a)')
'Energy Storage and Transfer package should '// &
525 'be enabled/disabled simultaneously in models connected with the '// &
526 'interface model for exchange ', &
532 if ((gwemodel1%cnd%ixt3d > 0 .and. gwemodel2%cnd%ixt3d == 0) .or. &
533 (gwemodel1%cnd%ixt3d == 0 .and. gwemodel2%cnd%ixt3d > 0))
then
534 write (
errmsg,
'(2a)')
'Use of XT3D to calculate conduction should '// &
535 'be the same in both models, either both use XT3D or neither for '// &
536 ' exchange '//trim(gweex%name)
542 est1 => gwemodel1%est
543 est2 => gwemodel2%est
544 if (est1%rhow /= est2%rhow) compatible = .false.
545 if (est1%cpw /= est2%cpw) compatible = .false.
552 if (.not. compatible)
then
553 write (
errmsg,
'(6a)')
'Energy storage and transfer (EST) packages ', &
554 'in model '//trim(gweex%model1%name),
' and ', &
555 trim(gweex%model2%name), &
556 ' should be equivalent to construct an '// &
557 ' interface model for exchange ', &
570 logical(LGP) :: isOpen
581 call this%gweInterfaceModel%model_da()
582 deallocate (this%gweInterfaceModel)
585 call this%spatialcon_da()
587 inquire (this%iout, opened=isopen)
593 if (this%owns_exchange)
then
594 call this%gweExchange%exg_da()
604 class(*),
pointer,
intent(inout) :: obj
609 if (.not.
associated(obj))
return
This module contains the BudgetModule.
subroutine, public rate_accumulator(flow, rin, rout)
@ brief Rate accumulator subroutine
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
real(dp), parameter dzero
real constant zero
integer(i4b), parameter lenbudtxt
maximum length of a budget component names
integer(i4b) function, public getcsrindex(i, j, ia, ja)
Return index for element i,j in CSR storage,.
subroutine allocate_scalars(this)
Allocate scalars and initialize to defaults.
subroutine allocate_arrays(this)
Allocate array data, using the number of connected nodes.
integer(i4b), parameter, public sync_nds
synchronize over nodes
integer(i4b), parameter, public sync_exg
synchronize as exchange variable
integer(i4b), parameter, public sync_con
synchronize over connections
– @ brief Energy Storage and Transfer (EST) Module
subroutine gwegwecon_fc(this, kiter, matrix_sln, rhs_sln, inwtflag)
subroutine gwegwecon_ot(this)
subroutine gwegwecon_ad(this)
Advance this connection.
subroutine gwegwecon_da(this)
Deallocate all resources.
subroutine setgridextent(this)
Set required extent of the interface grid from.
subroutine gwegwecon_rp(this)
subroutine gwegwecon_bd(this, icnvg, isuppress_output, isolnid)
subroutine gwegwecon_df(this)
define the GWE-GWE connection
class(gwegweconnectiontype) function, pointer, public castasgwegweconnection(obj)
Cast to GweGweConnectionType.
subroutine setflowtoexchange(this)
Set the flows (flowja from interface model) to the.
subroutine gwegwecon_ar(this)
allocate and read/set the connection's data structures
subroutine gwegwecon_cq(this, icnvg, isuppress_output, isolnid)
subroutine validategweexchange(this)
Validate the exchange, intercepting those cases where two models have to be connected with an interfa...
subroutine cfg_dist_vars(this)
Configure distributed variables for this interface model.
subroutine gwegweconnection_ctor(this, model, gweEx)
Basic construction of the connection.
subroutine validateconnection(this)
validate this connection prior to constructing
This module contains the GweGweExchangeModule Module.
class(gweexchangetype) function, pointer, public castasgweexchange(obj)
@ brief Cast polymorphic object as exchange
class(gwemodeltype) function, pointer, public castasgwemodel(model)
Cast to GweModelType.
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_aft_con_ar
afterr connection allocate read
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
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...
@ brief Energy storage and transfer
Connects a GWE model to other GWE models in space. Derives from NumericalExchangeType so the solution...
Derived type for GwtExchangeType.
The GWE 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....