35 integer(I4B),
pointer :: iifaceadvscheme => null()
37 integer(I4B),
pointer :: iifacext3d => null()
38 integer(I4B),
pointer :: exgflowsign => null()
39 real(dp),
dimension(:),
pointer,
contiguous :: exgflowjagwe => null()
42 real(dp),
dimension(:),
pointer,
contiguous :: gwfflowja => null()
43 real(dp),
dimension(:),
pointer,
contiguous :: gwfsat => null()
44 real(dp),
dimension(:),
pointer,
contiguous :: gwfhead => null()
45 real(dp),
dimension(:, :),
pointer,
contiguous :: gwfspdis => null()
47 real(dp),
dimension(:),
pointer,
contiguous :: conc => null()
48 integer(I4B),
dimension(:),
pointer,
contiguous :: icbound => null()
50 integer(I4B) :: iout = 0
93 character(len=LINELENGTH) :: fname
94 character(len=LENCOMPONENTNAME) :: name
95 class(*),
pointer :: objPtr
96 logical(LGP) :: write_ifmodel_listfile = .false.
103 if (gweex%v_model1%is_local .and. gweex%v_model2%is_local)
then
104 this%owns_exchange =
associated(model, gweex%model1)
106 this%owns_exchange = .true.
109 if (gweex%v_model1 == model)
then
110 write (name,
'(a,i0)')
'GWECON1_', gweex%id
112 write (name,
'(a,i0)')
'GWECON2_', gweex%id
116 if (write_ifmodel_listfile)
then
117 fname = trim(name)//
'.im.lst'
118 call openfile(this%iout, 0, fname,
'LIST', filstat_opt=
'REPLACE')
119 write (this%iout,
'(4a)')
'Creating GWE-GWE connection for model ', &
120 trim(this%gweModel%name),
'from exchange ', &
125 call this%SpatialModelConnectionType%spatialConnection_ctor(model, &
129 call this%allocate_scalars()
130 this%typename =
'GWE-GWE'
131 this%iIfaceAdvScheme = 0
135 allocate (this%gweInterfaceModel)
136 this%interface_model => this%gweInterfaceModel
146 call mem_allocate(this%iIfaceAdvScheme,
'IADVSCHEME', this%memoryPath)
147 call mem_allocate(this%iIfaceXt3d,
'IXT3D', this%memoryPath)
148 call mem_allocate(this%exgflowSign,
'EXGFLOWSIGN', this%memoryPath)
158 character(len=LENCOMPONENTNAME) :: imName
162 this%iIfaceAdvScheme = this%gweExchange%iAdvScheme
165 this%iIfaceXt3d = this%gweExchange%ixt3d
168 if (this%gweModel%incnd > 0)
then
169 this%iIfaceXt3d = this%gweModel%cnd%ixt3d
173 call this%setGridExtent()
176 call this%spatialcon_df()
180 if (this%prim_exchange%v_model1 == this%owner)
then
181 write (imname,
'(a,i0)')
'GWEIM1_', this%gweExchange%id
183 write (imname,
'(a,i0)')
'GWEIM2_', this%gweExchange%id
185 call this%gweInterfaceModel%gweifmod_cr(imname, &
188 call this%gweInterfaceModel%set_idsoln(this%gweModel%idsoln)
189 this%gweInterfaceModel%iAdvScheme = this%iIfaceAdvScheme
190 this%gweInterfaceModel%ixt3d = this%iIfaceXt3d
191 call this%gweInterfaceModel%model_df()
193 call this%cfg_dist_vars()
195 call this%allocate_arrays()
196 call this%gweInterfaceModel%allocate_fmi()
199 call this%spatialcon_setmodelptrs()
202 this%conc => this%gweInterfaceModel%x
203 this%icbound => this%gweInterfaceModel%ibound
206 call this%spatialcon_connect()
216 call this%cfg_dv(
'X',
'',
sync_nds, &
223 if (this%gweInterfaceModel%cnd%idisp > 0)
then
237 exg_var_name=
'GWFSIMVALS')
239 if (this%gweModel%incnd > 0 .and. this%gweModel%inest > 0)
then
250 call mem_allocate(this%exgflowjaGwe, this%ig_builder%nrOfBoundaryCells, &
251 'EXGFLOWJAGWT', this%memoryPath)
261 logical(LGP) :: hasAdv, hasCnd
263 hasadv = this%gweModel%inadv > 0
264 hascnd = this%gweModel%incnd > 0
269 this%exg_stencil_depth = 2
272 this%int_stencil_depth = 2
278 if (this%iIfaceXt3d > 0)
then
279 this%exg_stencil_depth = 2
280 if (this%gweModel%cnd%ixt3d > 0)
then
281 this%int_stencil_depth = 2
296 call this%validateConnection()
299 call this%spatialcon_ar()
302 call this%gweInterfaceModel%model_ar()
305 if (this%gweModel%inest > 0)
then
306 this%gweInterfaceModel%gwecommon%gwecpw => this%gweModel%gwecommon%gwecpw
307 this%gweInterfaceModel%gwecommon%gwerhow => this%gweModel%gwecommon%gwerhow
312 if (this%gweModel%incnd > 0)
then
313 this%gweInterfaceModel%ieqnsclfac = this%gweModel%cnd%eqnsclfac
317 if (this%owns_exchange)
then
322 if (this%gweExchange%inobs > 0)
then
323 call this%gweExchange%obs%obs_ar()
337 call this%SpatialModelConnectionType%validateConnection()
340 if (.not. this%gweExchange%v_model1%is_local)
return
341 if (.not. this%gweExchange%v_model2%is_local)
return
344 call this%validateGweExchange()
347 if ((this%gweExchange%gwemodel1%inadv > 0 .and. &
348 this%gweExchange%gwemodel2%inadv == 0) .or. &
349 (this%gweExchange%gwemodel2%inadv > 0 .and. &
350 this%gweExchange%gwemodel1%inadv == 0))
then
351 write (
errmsg,
'(1x,a,a,a)')
'Cannot connect GWE models in exchange ', &
352 trim(this%gweExchange%name),
' because one model is configured with ADV &
353 &and the other one is not'
357 if ((this%gweExchange%gwemodel1%incnd > 0 .and. &
358 this%gweExchange%gwemodel2%incnd == 0) .or. &
359 (this%gweExchange%gwemodel2%incnd > 0 .and. &
360 this%gweExchange%gwemodel1%incnd == 0))
then
361 write (
errmsg,
'(1x,a,a,a)')
'Cannot connect GWE models in exchange ', &
362 trim(this%gweExchange%name),
' because one model is configured with CND &
363 &and the other one is not'
369 write (
errmsg,
'(a)')
'Errors occurred while processing exchange(s)'
380 if (this%owns_exchange)
then
381 call this%gweExchange%exg_rp()
393 if (this%gweInterfaceModel%incnd > 0)
call this%gweInterfaceModel%cnd%cnd_ad()
395 if (this%owns_exchange)
then
396 call this%gweExchange%exg_ad()
404 integer(I4B),
intent(in) :: kiter
406 real(DP),
dimension(:),
intent(inout) :: rhs_sln
407 integer(I4B),
optional,
intent(in) :: inwtflag
409 call this%SpatialModelConnectionType%spatialcon_fc( &
410 kiter, matrix_sln, rhs_sln, inwtflag)
413 if (this%owns_exchange)
then
414 if (this%gweExchange%inmvt > 0)
then
415 call this%gweExchange%mvt%mvt_fc(this%gweExchange%gwemodel1%x, &
416 this%gweExchange%gwemodel2%x)
425 integer(I4B),
intent(inout) :: icnvg
426 integer(I4B),
intent(in) :: isuppress_output
427 integer(I4B),
intent(in) :: isolnid
429 call this%gweInterfaceModel%model_cq(icnvg, isuppress_output)
430 call this%setFlowToExchange()
446 if (this%owns_exchange)
then
447 gweex => this%gweExchange
448 map => this%interface_map%exchange_maps(this%interface_map%prim_exg_idx)
451 do i = 1,
size(map%src_idx)
452 if (map%sign(i) < 0) cycle
453 gweex%simvals(map%src_idx(i)) = &
454 this%gweInterfaceModel%flowja(map%tgt_idx(i))
465 integer(I4B),
intent(inout) :: icnvg
466 integer(I4B),
intent(in) :: isuppress_output
467 integer(I4B),
intent(in) :: isolnid
471 if (this%owns_exchange)
then
472 call this%gweExchange%exg_bd(icnvg, isuppress_output, isolnid)
484 if (this%owns_exchange)
then
485 call this%gweExchange%exg_ot()
507 class(*),
pointer :: modelPtr
511 logical(LGP) :: compatible
513 gweex => this%gweExchange
516 if (.not. gweex%v_model1%is_local)
return
517 if (.not. gweex%v_model2%is_local)
return
519 modelptr => this%gweExchange%model1
521 modelptr => this%gweExchange%model2
525 if ((gwemodel1%inest > 0 .and. gwemodel2%inest == 0) .or. &
526 (gwemodel1%inest == 0 .and. gwemodel2%inest > 0))
then
527 write (
errmsg,
'(2a)')
'Energy Storage and Transfer package should '// &
528 'be enabled/disabled simultaneously in models connected with the '// &
529 'interface model for exchange ', &
535 if ((gwemodel1%cnd%ixt3d > 0 .and. gwemodel2%cnd%ixt3d == 0) .or. &
536 (gwemodel1%cnd%ixt3d == 0 .and. gwemodel2%cnd%ixt3d > 0))
then
537 write (
errmsg,
'(2a)')
'Use of XT3D to calculate conduction should '// &
538 'be the same in both models, either both use XT3D or neither for '// &
539 ' exchange '//trim(gweex%name)
545 est1 => gwemodel1%est
546 est2 => gwemodel2%est
547 if (est1%rhow /= est2%rhow) compatible = .false.
548 if (est1%cpw /= est2%cpw) compatible = .false.
555 if (.not. compatible)
then
556 write (
errmsg,
'(6a)')
'Energy storage and transfer (EST) packages ', &
557 'in model '//trim(gweex%model1%name),
' and ', &
558 trim(gweex%model2%name), &
559 ' should be equivalent to construct an '// &
560 ' interface model for exchange ', &
573 logical(LGP) :: isOpen
584 call this%gweInterfaceModel%model_da()
585 deallocate (this%gweInterfaceModel)
588 call this%spatialcon_da()
590 inquire (this%iout, opened=isopen)
596 if (this%owns_exchange)
then
597 call this%gweExchange%exg_da()
607 class(*),
pointer,
intent(inout) :: obj
612 if (.not.
associated(obj))
return
integer(i4b), parameter adv_scheme_tvd
integer(i4b), parameter adv_scheme_utvd
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....