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
94 character(len=LINELENGTH) :: fname
95 character(len=LENCOMPONENTNAME) :: name
96 class(*),
pointer :: objPtr
97 logical(LGP) :: write_ifmodel_listfile = .false.
104 if (gweex%v_model1%is_local .and. gweex%v_model2%is_local)
then
105 this%owns_exchange =
associated(model, gweex%model1)
107 this%owns_exchange = .true.
110 if (gweex%v_model1 == model)
then
111 write (name,
'(a,i0)')
'GWECON1_', gweex%id
113 write (name,
'(a,i0)')
'GWECON2_', gweex%id
117 if (write_ifmodel_listfile)
then
118 fname = trim(name)//
'.im.lst'
119 call openfile(this%iout, 0, fname,
'LIST', filstat_opt=
'REPLACE')
120 write (this%iout,
'(4a)')
'Creating GWE-GWE connection for model ', &
121 trim(this%gweModel%name),
'from exchange ', &
126 call this%SpatialModelConnectionType%spatialConnection_ctor(model, &
130 call this%allocate_scalars()
131 this%typename =
'GWE-GWE'
132 this%iIfaceAdvScheme = 0
136 allocate (this%gweInterfaceModel)
137 this%interface_model => this%gweInterfaceModel
147 call mem_allocate(this%iIfaceAdvScheme,
'IADVSCHEME', this%memoryPath)
148 call mem_allocate(this%iIfaceXt3d,
'IXT3D', this%memoryPath)
149 call mem_allocate(this%exgflowSign,
'EXGFLOWSIGN', this%memoryPath)
159 character(len=LENCOMPONENTNAME) :: imName
163 this%iIfaceAdvScheme = this%gweExchange%iAdvScheme
166 this%iIfaceXt3d = this%gweExchange%ixt3d
169 if (this%gweModel%incnd > 0)
then
170 this%iIfaceXt3d = this%gweModel%cnd%ixt3d
174 call this%setGridExtent()
177 call this%spatialcon_df()
181 if (this%prim_exchange%v_model1 == this%owner)
then
182 write (imname,
'(a,i0)')
'GWEIM1_', this%gweExchange%id
184 write (imname,
'(a,i0)')
'GWEIM2_', this%gweExchange%id
186 call this%gweInterfaceModel%gweifmod_cr(imname, &
189 call this%gweInterfaceModel%set_idsoln(this%gweModel%idsoln)
190 this%gweInterfaceModel%iAdvScheme = this%iIfaceAdvScheme
191 this%gweInterfaceModel%ixt3d = this%iIfaceXt3d
192 call this%gweInterfaceModel%model_df()
194 call this%cfg_dist_vars()
196 call this%allocate_arrays()
197 call this%gweInterfaceModel%allocate_fmi()
200 call this%spatialcon_setmodelptrs()
203 this%conc => this%gweInterfaceModel%x
204 this%icbound => this%gweInterfaceModel%ibound
207 call this%spatialcon_connect()
217 call this%cfg_dv(
'X',
'',
sync_nds, &
224 if (this%gweInterfaceModel%cnd%idisp > 0)
then
238 exg_var_name=
'GWFSIMVALS')
240 if (this%gweModel%incnd > 0 .and. this%gweModel%inest > 0)
then
251 call mem_allocate(this%exgflowjaGwe, this%ig_builder%nrOfBoundaryCells, &
252 'EXGFLOWJAGWT', this%memoryPath)
262 logical(LGP) :: hasAdv, hasCnd
264 hasadv = this%gweModel%inadv > 0
265 hascnd = this%gweModel%incnd > 0
270 this%exg_stencil_depth = 2
273 this%int_stencil_depth = 2
279 if (this%iIfaceXt3d > 0)
then
280 this%exg_stencil_depth = 2
281 if (this%gweModel%cnd%ixt3d > 0)
then
282 this%int_stencil_depth = 2
297 call this%validateConnection()
300 call this%spatialcon_ar()
303 call this%gweInterfaceModel%model_ar()
306 if (this%gweModel%inest > 0)
then
307 this%gweInterfaceModel%gwecommon%gwecpw => this%gweModel%gwecommon%gwecpw
308 this%gweInterfaceModel%gwecommon%gwerhow => this%gweModel%gwecommon%gwerhow
313 if (this%gweModel%incnd > 0)
then
314 this%gweInterfaceModel%ieqnsclfac = this%gweModel%cnd%eqnsclfac
318 if (this%owns_exchange)
then
323 if (this%gweExchange%inobs > 0)
then
324 call this%gweExchange%obs%obs_ar()
338 call this%SpatialModelConnectionType%validateConnection()
341 if (.not. this%gweExchange%v_model1%is_local)
return
342 if (.not. this%gweExchange%v_model2%is_local)
return
345 call this%validateGweExchange()
348 if ((this%gweExchange%gwemodel1%inadv > 0 .and. &
349 this%gweExchange%gwemodel2%inadv == 0) .or. &
350 (this%gweExchange%gwemodel2%inadv > 0 .and. &
351 this%gweExchange%gwemodel1%inadv == 0))
then
352 write (
errmsg,
'(1x,a,a,a)')
'Cannot connect GWE models in exchange ', &
353 trim(this%gweExchange%name),
' because one model is configured with ADV &
354 &and the other one is not'
358 if ((this%gweExchange%gwemodel1%incnd > 0 .and. &
359 this%gweExchange%gwemodel2%incnd == 0) .or. &
360 (this%gweExchange%gwemodel2%incnd > 0 .and. &
361 this%gweExchange%gwemodel1%incnd == 0))
then
362 write (
errmsg,
'(1x,a,a,a)')
'Cannot connect GWE models in exchange ', &
363 trim(this%gweExchange%name),
' because one model is configured with CND &
364 &and the other one is not'
370 write (
errmsg,
'(a)')
'Errors occurred while processing exchange(s)'
381 if (this%owns_exchange)
then
382 call this%gweExchange%exg_rp()
394 if (this%gweInterfaceModel%incnd > 0)
call this%gweInterfaceModel%cnd%cnd_ad()
396 if (this%owns_exchange)
then
397 call this%gweExchange%exg_ad()
404 integer(I4B),
intent(in) :: kiter
406 real(DP),
dimension(:),
pointer,
contiguous :: x_m1, x_m2
408 call this%SpatialModelConnectionType%spatialcon_cf(kiter)
411 if (this%owns_exchange)
then
412 if (this%gweExchange%inmvt > 0)
then
415 if (
associated(this%gweExchange%gwemodel1))
then
416 x_m1 => this%gweExchange%gwemodel1%x
418 if (
associated(this%gweExchange%gwemodel2))
then
419 x_m2 => this%gweExchange%gwemodel2%x
421 call this%gweExchange%mvt%xmvt_cf(x_m1, x_m2)
430 integer(I4B),
intent(in) :: kiter
432 real(DP),
dimension(:),
intent(inout) :: rhs_sln
433 integer(I4B),
optional,
intent(in) :: inwtflag
435 real(DP),
dimension(:),
pointer,
contiguous :: x_m1, x_m2
437 call this%SpatialModelConnectionType%spatialcon_fc( &
438 kiter, matrix_sln, rhs_sln, inwtflag)
441 if (this%owns_exchange)
then
442 if (this%gweExchange%inmvt > 0)
then
445 if (
associated(this%gweExchange%gwemodel1))
then
446 x_m1 => this%gweExchange%gwemodel1%x
448 if (
associated(this%gweExchange%gwemodel2))
then
449 x_m2 => this%gweExchange%gwemodel2%x
451 call this%gweExchange%mvt%mvt_fc(x_m1, x_m2)
460 integer(I4B),
intent(inout) :: icnvg
461 integer(I4B),
intent(in) :: isuppress_output
462 integer(I4B),
intent(in) :: isolnid
464 call this%gweInterfaceModel%model_cq(icnvg, isuppress_output)
465 call this%setFlowToExchange()
481 if (this%owns_exchange)
then
482 gweex => this%gweExchange
483 map => this%interface_map%exchange_maps(this%interface_map%prim_exg_idx)
486 do i = 1,
size(map%src_idx)
487 if (map%sign(i) < 0) cycle
488 gweex%simvals(map%src_idx(i)) = &
489 this%gweInterfaceModel%flowja(map%tgt_idx(i))
500 integer(I4B),
intent(inout) :: icnvg
501 integer(I4B),
intent(in) :: isuppress_output
502 integer(I4B),
intent(in) :: isolnid
506 if (this%owns_exchange)
then
507 call this%gweExchange%exg_bd(icnvg, isuppress_output, isolnid)
519 if (this%owns_exchange)
then
520 call this%gweExchange%exg_ot()
542 class(*),
pointer :: modelPtr
546 logical(LGP) :: compatible
548 gweex => this%gweExchange
551 if (.not. gweex%v_model1%is_local)
return
552 if (.not. gweex%v_model2%is_local)
return
554 modelptr => this%gweExchange%model1
556 modelptr => this%gweExchange%model2
560 if ((gwemodel1%inest > 0 .and. gwemodel2%inest == 0) .or. &
561 (gwemodel1%inest == 0 .and. gwemodel2%inest > 0))
then
562 write (
errmsg,
'(2a)')
'Energy Storage and Transfer package should '// &
563 'be enabled/disabled simultaneously in models connected with the '// &
564 'interface model for exchange ', &
570 if ((gwemodel1%cnd%ixt3d > 0 .and. gwemodel2%cnd%ixt3d == 0) .or. &
571 (gwemodel1%cnd%ixt3d == 0 .and. gwemodel2%cnd%ixt3d > 0))
then
572 write (
errmsg,
'(2a)')
'Use of XT3D to calculate conduction should '// &
573 'be the same in both models, either both use XT3D or neither for '// &
574 ' exchange '//trim(gweex%name)
580 est1 => gwemodel1%est
581 est2 => gwemodel2%est
582 if (est1%rhow /= est2%rhow) compatible = .false.
583 if (est1%cpw /= est2%cpw) compatible = .false.
590 if (.not. compatible)
then
591 write (
errmsg,
'(6a)')
'Energy storage and transfer (EST) packages ', &
592 'in model '//trim(gweex%model1%name),
' and ', &
593 trim(gweex%model2%name), &
594 ' should be equivalent to construct an '// &
595 ' interface model for exchange ', &
608 logical(LGP) :: isOpen
619 call this%gweInterfaceModel%model_da()
620 deallocate (this%gweInterfaceModel)
623 call this%spatialcon_da()
625 inquire (this%iout, opened=isopen)
631 if (this%owns_exchange)
then
632 call this%gweExchange%exg_da()
642 class(*),
pointer,
intent(inout) :: obj
647 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 gwegwecon_cf(this, kiter)
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....