MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
GweGweConnection.f90
Go to the documentation of this file.
2 use kindmodule, only: i4b, dp, lgp
5 use simmodule, only: ustop
9 use gwemodule
13 use sparsemodule, only: sparsematrix
20
21 implicit none
22 private
23
25
26 !> Connects a GWE model to other GWE models in space. Derives
27 !! from NumericalExchangeType so the solution can use it to
28 !! fetch the coefficients for this connection.
29 !<
31
32 class(gwemodeltype), pointer :: gwemodel => null() !< the model for which this connection exists
33 class(gweexchangetype), pointer :: gweexchange => null() !< the primary exchange, cast to GWE-GWE
34 class(gweinterfacemodeltype), pointer :: gweinterfacemodel => null() !< the interface model
35 integer(I4B), pointer :: iifaceadvscheme => null() !< the advection scheme at the interface:
36 !! 0 = upstream, 1 = central, 2 = TVD
37 integer(I4B), pointer :: iifacext3d => null() !< XT3D in the interface CND package: 0 = no, 1 = lhs, 2 = rhs
38 integer(I4B), pointer :: exgflowsign => null() !< indicates the flow direction of exgflowja
39 real(dp), dimension(:), pointer, contiguous :: exgflowjagwe => null() !< gwe-flowja at the interface (this is a subset of the GWT
40 !! interface model flowja's)
41
42 real(dp), dimension(:), pointer, contiguous :: gwfflowja => null() !< gwfflowja for the interface model
43 real(dp), dimension(:), pointer, contiguous :: gwfsat => null() !< gwfsat for the interface model
44 real(dp), dimension(:), pointer, contiguous :: gwfhead => null() !< gwfhead for the interface model
45 real(dp), dimension(:, :), pointer, contiguous :: gwfspdis => null() !< gwfspdis for the interface model
46
47 real(dp), dimension(:), pointer, contiguous :: conc => null() !< pointer to concentration array
48 integer(I4B), dimension(:), pointer, contiguous :: icbound => null() !< store pointer to gwe ibound array
49
50 integer(I4B) :: iout = 0 !< the list file for the interface model
51
52 contains
53
54 procedure, pass(this) :: gwegweconnection_ctor
55 generic, public :: construct => gwegweconnection_ctor
56
57 procedure :: exg_ar => gwegwecon_ar
58 procedure :: exg_df => gwegwecon_df
59 procedure :: exg_rp => gwegwecon_rp
60 procedure :: exg_ad => gwegwecon_ad
61 procedure :: exg_cf => gwegwecon_cf
62 procedure :: exg_fc => gwegwecon_fc
63 procedure :: exg_da => gwegwecon_da
64 procedure :: exg_cq => gwegwecon_cq
65 procedure :: exg_bd => gwegwecon_bd
66 procedure :: exg_ot => gwegwecon_ot
67
68 ! overriding 'protected'
69 procedure :: validateconnection
70
71 ! local stuff
72 procedure, private :: allocate_scalars
73 procedure, private :: allocate_arrays
74 procedure, private :: cfg_dist_vars
75 procedure, private :: setgridextent
76 procedure, private :: validategweexchange
77 procedure, private :: setflowtoexchange
78
80
81contains
82
83 !> @brief Basic construction of the connection
84 !<
85 subroutine gwegweconnection_ctor(this, model, gweEx)
86 ! modules
88 ! dummy
89 class(gwegweconnectiontype) :: this !< the connection
90 class(numericalmodeltype), pointer :: model !< the model owning this connection,
91 !! this must be a GweModelType
92 class(disconnexchangetype), pointer :: gweEx !< the GWE-GWE exchange the interface model is created for
93 ! local
94 character(len=LINELENGTH) :: fname
95 character(len=LENCOMPONENTNAME) :: name
96 class(*), pointer :: objPtr
97 logical(LGP) :: write_ifmodel_listfile = .false.
98
99 objptr => model
100 this%gweModel => castasgwemodel(objptr)
101 objptr => gweex
102 this%gweExchange => castasgweexchange(objptr)
103
104 if (gweex%v_model1%is_local .and. gweex%v_model2%is_local) then
105 this%owns_exchange = associated(model, gweex%model1)
106 else
107 this%owns_exchange = .true.
108 end if
109
110 if (gweex%v_model1 == model) then
111 write (name, '(a,i0)') 'GWECON1_', gweex%id
112 else
113 write (name, '(a,i0)') 'GWECON2_', gweex%id
114 end if
115
116 ! .lst file for interface model
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 ', &
122 trim(gweex%name)
123 end if
124
125 ! first call base constructor
126 call this%SpatialModelConnectionType%spatialConnection_ctor(model, &
127 gweex, &
128 name)
129
130 call this%allocate_scalars()
131 this%typename = 'GWE-GWE'
132 this%iIfaceAdvScheme = 0
133 this%iIfaceXt3d = 0
134 this%exgflowSign = 1
135
136 allocate (this%gweInterfaceModel)
137 this%interface_model => this%gweInterfaceModel
138
139 end subroutine gwegweconnection_ctor
140
141 !> @brief Allocate scalar variables for this connection
142 !<
143 subroutine allocate_scalars(this)
144 ! dummy
145 class(gwegweconnectiontype) :: this !< the connection
146
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)
150
151 end subroutine allocate_scalars
152
153 !> @brief define the GWE-GWE connection
154 !<
155 subroutine gwegwecon_df(this)
156 ! dummy
157 class(gwegweconnectiontype) :: this !< the connection
158 ! local
159 character(len=LENCOMPONENTNAME) :: imName
160
161 ! determine advection scheme (the GWE-GWE exchange
162 ! has been read at this point)
163 this%iIfaceAdvScheme = this%gweExchange%iAdvScheme
164
165 ! determine xt3d setting on interface
166 this%iIfaceXt3d = this%gweExchange%ixt3d
167
168 ! turn off when off in the owning model
169 if (this%gweModel%incnd > 0) then
170 this%iIfaceXt3d = this%gweModel%cnd%ixt3d
171 end if
172
173 ! determine the required size of the interface model grid
174 call this%setGridExtent()
175
176 ! now set up the GridConnection
177 call this%spatialcon_df()
178
179 ! we have to 'catch up' and create the interface model
180 ! here, then the remainder of this routine will be define
181 if (this%prim_exchange%v_model1 == this%owner) then
182 write (imname, '(a,i0)') 'GWEIM1_', this%gweExchange%id
183 else
184 write (imname, '(a,i0)') 'GWEIM2_', this%gweExchange%id
185 end if
186 call this%gweInterfaceModel%gweifmod_cr(imname, &
187 this%iout, &
188 this%ig_builder)
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()
193
194 call this%cfg_dist_vars()
195
196 call this%allocate_arrays()
197 call this%gweInterfaceModel%allocate_fmi()
198
199 ! connect X, RHS, IBOUND, and flowja
200 call this%spatialcon_setmodelptrs()
201
202 ! connect pointers (used by BUY)
203 this%conc => this%gweInterfaceModel%x
204 this%icbound => this%gweInterfaceModel%ibound
205
206 ! add connections from the interface model to solution matrix
207 call this%spatialcon_connect()
208
209 end subroutine gwegwecon_df
210
211 !> @brief Configure distributed variables for this interface model
212 !<
213 subroutine cfg_dist_vars(this)
214 ! dummy
215 class(gwegweconnectiontype) :: this !< the connection
216
217 call this%cfg_dv('X', '', sync_nds, &
219 call this%cfg_dv('IBOUND', '', sync_nds, (/stg_bfr_con_ar/))
220 call this%cfg_dv('TOP', 'DIS', sync_nds, (/stg_bfr_con_ar/))
221 call this%cfg_dv('BOT', 'DIS', sync_nds, (/stg_bfr_con_ar/))
222 call this%cfg_dv('AREA', 'DIS', sync_nds, (/stg_bfr_con_ar/))
223
224 if (this%gweInterfaceModel%cnd%idisp > 0) then
225 call this%cfg_dv('ALH', 'CND', sync_nds, (/stg_bfr_con_ar/))
226 call this%cfg_dv('ALV', 'CND', sync_nds, (/stg_bfr_con_ar/))
227 call this%cfg_dv('ATH1', 'CND', sync_nds, (/stg_bfr_con_ar/))
228 call this%cfg_dv('ATH2', 'CND', sync_nds, (/stg_bfr_con_ar/))
229 call this%cfg_dv('ATV', 'CND', sync_nds, (/stg_bfr_con_ar/))
230 call this%cfg_dv('KTW', 'CND', sync_nds, (/stg_bfr_con_ar/))
231 call this%cfg_dv('KTS', 'CND', sync_nds, (/stg_bfr_con_ar/))
232 end if
233 call this%cfg_dv('GWFHEAD', 'FMI', sync_nds, (/stg_bfr_exg_ad/))
234 call this%cfg_dv('GWFSAT', 'FMI', sync_nds, (/stg_bfr_exg_ad/))
235 call this%cfg_dv('GWFSPDIS', 'FMI', sync_nds, (/stg_bfr_exg_ad/))
236 call this%cfg_dv('GWFFLOWJA', 'FMI', sync_con, (/stg_bfr_exg_ad/))
237 call this%cfg_dv('GWFFLOWJA', 'FMI', sync_exg, (/stg_bfr_exg_ad/), &
238 exg_var_name='GWFSIMVALS')
239 ! fill porosity from est packages, needed for cnd
240 if (this%gweModel%incnd > 0 .and. this%gweModel%inest > 0) then
241 call this%cfg_dv('POROSITY', 'EST', sync_nds, (/stg_aft_con_ar/))
242 end if
243
244 end subroutine cfg_dist_vars
245
246 !> @brief Allocate array variables for this connection
247 !<
248 subroutine allocate_arrays(this)
249 class(gwegweconnectiontype) :: this !< the connection
250
251 call mem_allocate(this%exgflowjaGwe, this%ig_builder%nrOfBoundaryCells, &
252 'EXGFLOWJAGWT', this%memoryPath)
253
254 end subroutine allocate_arrays
255
256 !> @brief Set required extent of the interface grid from
257 !< the configuration
258 subroutine setgridextent(this)
259 ! dummy
260 class(gwegweconnectiontype) :: this !< the connection
261 ! local
262 logical(LGP) :: hasAdv, hasCnd
263
264 hasadv = this%gweModel%inadv > 0
265 hascnd = this%gweModel%incnd > 0
266
267 if (hasadv) then
268 if (this%iIfaceAdvScheme == adv_scheme_tvd .or. &
269 this%iIfaceAdvScheme == adv_scheme_utvd) then
270 this%exg_stencil_depth = 2
271 if (this%gweModel%adv%iadvwt == adv_scheme_tvd .or. &
272 this%gweModel%adv%iadvwt == adv_scheme_utvd) then
273 this%int_stencil_depth = 2
274 end if
275 end if
276 end if
277
278 if (hascnd) then
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
283 end if
284 end if
285 end if
286
287 end subroutine setgridextent
288
289 !> @brief allocate and read/set the connection's data structures
290 !<
291 subroutine gwegwecon_ar(this)
292 class(gwegweconnectiontype) :: this !< the connection
293
294 ! check if we can construct an interface model
295 ! NB: only makes sense after the models' allocate&read have been
296 ! called, which is why we do it here
297 call this%validateConnection()
298
299 ! allocate and read base
300 call this%spatialcon_ar()
301
302 ! ... and now the interface model
303 call this%gweInterfaceModel%model_ar()
304
305 ! set a pointer in the interface model to the gwecommon data
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
309 end if
310
311 ! set the equation scaling factor in the interface model to that of
312 ! underlying GWE model
313 if (this%gweModel%incnd > 0) then
314 this%gweInterfaceModel%ieqnsclfac = this%gweModel%cnd%eqnsclfac
315 end if
316
317 ! AR the movers and obs through the exchange
318 if (this%owns_exchange) then
319 !cdl implement this when MVT is ready
320 !cdl if (this%gweExchange%inmvt > 0) then
321 !cdl call this%gweExchange%mvt%mvt_ar()
322 !cdl end if
323 if (this%gweExchange%inobs > 0) then
324 call this%gweExchange%obs%obs_ar()
325 end if
326 end if
327
328 end subroutine gwegwecon_ar
329
330 !> @brief validate this connection prior to constructing
331 !< the interface model
332 subroutine validateconnection(this)
333 use simvariablesmodule, only: errmsg
335 class(gwegweconnectiontype) :: this !< this connection
336
337 ! base validation, the spatial/geometry part
338 call this%SpatialModelConnectionType%validateConnection()
339
340 ! we cannot validate this (yet) in parallel mode
341 if (.not. this%gweExchange%v_model1%is_local) return
342 if (.not. this%gweExchange%v_model2%is_local) return
343
344 ! check specific cross-interface options/values that should be the same
345 call this%validateGweExchange()
346
347 ! GWE related matters
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'
355 call store_error(errmsg)
356 end if
357
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'
365 call store_error(errmsg)
366 end if
367
368 ! abort on errors
369 if (count_errors() > 0) then
370 write (errmsg, '(a)') 'Errors occurred while processing exchange(s)'
371 call ustop(errmsg)
372 end if
373
374 end subroutine validateconnection
375
376 subroutine gwegwecon_rp(this)
377 ! dummy
378 class(gwegweconnectiontype) :: this !< the connection
379
380 ! call exchange rp routines
381 if (this%owns_exchange) then
382 call this%gweExchange%exg_rp()
383 end if
384
385 end subroutine gwegwecon_rp
386
387 !> @brief Advance this connection
388 !<
389 subroutine gwegwecon_ad(this)
390
391 class(gwegweconnectiontype) :: this !< this connection
392
393 ! recalculate conduction ellipse
394 if (this%gweInterfaceModel%incnd > 0) call this%gweInterfaceModel%cnd%cnd_ad()
395
396 if (this%owns_exchange) then
397 call this%gweExchange%exg_ad()
398 end if
399
400 end subroutine gwegwecon_ad
401
402 subroutine gwegwecon_cf(this, kiter)
403 class(gwegweconnectiontype) :: this !< this connection
404 integer(I4B), intent(in) :: kiter !< the iteration counter
405 ! local
406 real(DP), dimension(:), pointer, contiguous :: x_m1, x_m2
407
408 call this%SpatialModelConnectionType%spatialcon_cf(kiter)
409
410 ! CF the movers in the exchange
411 if (this%owns_exchange) then
412 if (this%gweExchange%inmvt > 0) then
413 x_m1 => null()
414 x_m2 => null()
415 if (associated(this%gweExchange%gwemodel1)) then
416 x_m1 => this%gweExchange%gwemodel1%x
417 end if
418 if (associated(this%gweExchange%gwemodel2)) then
419 x_m2 => this%gweExchange%gwemodel2%x
420 end if
421 call this%gweExchange%mvt%xmvt_cf(x_m1, x_m2)
422 end if
423 end if
424
425 end subroutine gwegwecon_cf
426
427 subroutine gwegwecon_fc(this, kiter, matrix_sln, rhs_sln, inwtflag)
428 ! dummy
429 class(gwegweconnectiontype) :: this !< the connection
430 integer(I4B), intent(in) :: kiter !< the iteration counter
431 class(matrixbasetype), pointer :: matrix_sln !< the system matrix
432 real(DP), dimension(:), intent(inout) :: rhs_sln !< global right-hand-side
433 integer(I4B), optional, intent(in) :: inwtflag !< newton-raphson flag
434 ! local
435 real(DP), dimension(:), pointer, contiguous :: x_m1, x_m2
436
437 call this%SpatialModelConnectionType%spatialcon_fc( &
438 kiter, matrix_sln, rhs_sln, inwtflag)
439
440 ! _fc the movers through the exchange
441 if (this%owns_exchange) then
442 if (this%gweExchange%inmvt > 0) then
443 x_m1 => null()
444 x_m2 => null()
445 if (associated(this%gweExchange%gwemodel1)) then
446 x_m1 => this%gweExchange%gwemodel1%x
447 end if
448 if (associated(this%gweExchange%gwemodel2)) then
449 x_m2 => this%gweExchange%gwemodel2%x
450 end if
451 call this%gweExchange%mvt%mvt_fc(x_m1, x_m2)
452 end if
453 end if
454
455 end subroutine gwegwecon_fc
456
457 subroutine gwegwecon_cq(this, icnvg, isuppress_output, isolnid)
458 ! dummy
459 class(gwegweconnectiontype) :: this !< the connection
460 integer(I4B), intent(inout) :: icnvg !< convergence flag
461 integer(I4B), intent(in) :: isuppress_output !< suppress output when =1
462 integer(I4B), intent(in) :: isolnid !< solution id
463
464 call this%gweInterfaceModel%model_cq(icnvg, isuppress_output)
465 call this%setFlowToExchange()
466
467 end subroutine gwegwecon_cq
468
469 !> @brief Set the flows (flowja from interface model) to the
470 !< simvals in the exchange, leaving the budget calcution in there
471 subroutine setflowtoexchange(this)
472 ! modules
474 ! dummy
475 class(gwegweconnectiontype) :: this !< this connection
476 ! local
477 integer(I4B) :: i
478 class(gweexchangetype), pointer :: gweEx
479 type(indexmapsgntype), pointer :: map
480
481 if (this%owns_exchange) then
482 gweex => this%gweExchange
483 map => this%interface_map%exchange_maps(this%interface_map%prim_exg_idx)
484
485 ! use (half of) the exchange map in reverse:
486 do i = 1, size(map%src_idx)
487 if (map%sign(i) < 0) cycle ! simvals is defined from exg%m1 => exg%m2
488 gweex%simvals(map%src_idx(i)) = &
489 this%gweInterfaceModel%flowja(map%tgt_idx(i))
490 end do
491 end if
492
493 end subroutine setflowtoexchange
494
495 subroutine gwegwecon_bd(this, icnvg, isuppress_output, isolnid)
496 ! modules
498 ! dummy
499 class(gwegweconnectiontype) :: this !< the connection
500 integer(I4B), intent(inout) :: icnvg !< convergence flag
501 integer(I4B), intent(in) :: isuppress_output !< suppress output when =1
502 integer(I4B), intent(in) :: isolnid !< solution id
503
504 ! call exchange budget routine, also calls _bd
505 ! for movers.
506 if (this%owns_exchange) then
507 call this%gweExchange%exg_bd(icnvg, isuppress_output, isolnid)
508 end if
509
510 end subroutine gwegwecon_bd
511
512 subroutine gwegwecon_ot(this)
513 ! dummy
514 class(gwegweconnectiontype) :: this !< the connection
515
516 ! call exg_ot() here as it handles all output processing
517 ! based on gweExchange%simvals(:), which was correctly
518 ! filled from gwegwecon
519 if (this%owns_exchange) then
520 call this%gweExchange%exg_ot()
521 end if
522
523 end subroutine gwegwecon_ot
524
525 !> @brief Validate the exchange, intercepting those
526 !! cases where two models have to be connected with an interface
527 !! model, where the individual configurations don't allow this
528 !!
529 !! Stops with error message on config mismatch
530 !<
531 subroutine validategweexchange(this)
532 ! modules
533 use simvariablesmodule, only: errmsg
534 use simmodule, only: store_error
535 use gweestmodule, only: gweesttype
536
537 ! dummy
538 class(gwegweconnectiontype) :: this !< this connection
539
540 ! local
541 class(gweexchangetype), pointer :: gweEx
542 class(*), pointer :: modelPtr
543 class(gwemodeltype), pointer :: gweModel1
544 class(gwemodeltype), pointer :: gweModel2
545 type(gweesttype), pointer :: est1, est2
546 logical(LGP) :: compatible
547
548 gweex => this%gweExchange
549
550 ! we cannot validate the remainder (yet) in parallel mode
551 if (.not. gweex%v_model1%is_local) return
552 if (.not. gweex%v_model2%is_local) return
553
554 modelptr => this%gweExchange%model1
555 gwemodel1 => castasgwemodel(modelptr)
556 modelptr => this%gweExchange%model2
557 gwemodel2 => castasgwemodel(modelptr)
558
559 ! check that EST package usage is the same on both side of the interface
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 ', &
565 trim(gweex%name)
566 call store_error(errmsg)
567 end if
568
569 ! conduction options need to be the same in both model
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)
575 call store_error(errmsg)
576 end if
577
578 ! check compatibility of Energy Storage and Transfer (EST) package
579 compatible = .true.
580 est1 => gwemodel1%est
581 est2 => gwemodel2%est
582 if (est1%rhow /= est2%rhow) compatible = .false.
583 if (est1%cpw /= est2%cpw) compatible = .false.
584 ! if (est1%nrhospecies /= est2%nrhospecies) compatible = .false.
585 ! if (.not. all(buy1%drhodc == buy2%drhodc)) compatible = .false.
586 ! if (.not. all(buy1%crhoref == buy2%crhoref)) compatible = .false.
587 !if (.not. all(buy1%cauxspeciesname == buy2%cauxspeciesname)) then
588 ! compatible = .false.
589 !end if
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 ', &
596 trim(gweex%name)
597 call store_error(errmsg)
598 end if
599
600 end subroutine validategweexchange
601
602 !> @brief Deallocate all resources
603 !<
604 subroutine gwegwecon_da(this)
605 ! dummy
606 class(gwegweconnectiontype) :: this !< the connection
607 ! local
608 logical(LGP) :: isOpen
609
610 ! scalars
611 call mem_deallocate(this%iIfaceAdvScheme)
612 call mem_deallocate(this%iIfaceXt3d)
613 call mem_deallocate(this%exgflowSign)
614
615 ! arrays
616 call mem_deallocate(this%exgflowjaGwe)
617
618 ! interface model
619 call this%gweInterfaceModel%model_da()
620 deallocate (this%gweInterfaceModel)
621
622 ! dealloc base
623 call this%spatialcon_da()
624
625 inquire (this%iout, opened=isopen)
626 if (isopen) then
627 close (this%iout)
628 end if
629
630 ! we need to deallocate the exchange we own:
631 if (this%owns_exchange) then
632 call this%gweExchange%exg_da()
633 end if
634
635 end subroutine gwegwecon_da
636
637 !> @brief Cast to GweGweConnectionType
638 !<
639 function castasgwegweconnection(obj) result(res)
640 implicit none
641 ! dummy
642 class(*), pointer, intent(inout) :: obj !< object to be cast
643 ! return
644 class(gwegweconnectiontype), pointer :: res !< the GweGweConnection
645
646 res => null()
647 if (.not. associated(obj)) return
648
649 select type (obj)
650 class is (gwegweconnectiontype)
651 res => obj
652 end select
653
654 end function castasgwegweconnection
655
656end module
integer(i4b), parameter adv_scheme_tvd
integer(i4b), parameter adv_scheme_utvd
This module contains the BudgetModule.
Definition Budget.f90:20
subroutine, public rate_accumulator(flow, rin, rout)
Rate accumulator subroutine.
Definition Budget.f90:634
This module contains simulation constants.
Definition Constants.f90:9
integer(i4b), parameter linelength
maximum length of a standard line
Definition Constants.f90:45
integer(i4b), parameter lencomponentname
maximum length of a component name
Definition Constants.f90:18
real(dp), parameter dzero
real constant zero
Definition Constants.f90:65
integer(i4b), parameter lenbudtxt
maximum length of a budget component names
Definition Constants.f90:37
integer(i4b) function, public getcsrindex(i, j, ia, ja)
Return index for element i,j in CSR storage,.
Definition CsrUtils.f90:13
subroutine allocate_scalars(this)
Allocate scalars and initialize to defaults.
subroutine allocate_arrays(this)
Allocate array data, using the number of connected nodes nexg.
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
Energy Storage and Transfer (EST) Module.
Definition gwe-est.f90:13
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 gwegweconnection_ctor(this, model, gweex)
Basic construction of the connection.
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 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)
Cast polymorphic object as exchange.
class(gwemodeltype) function, pointer, public castasgwemodel(model)
Cast to GweModelType.
Definition gwe.f90:798
subroutine, public openfile(iu, iout, fname, ftype, fmtarg_opt, accarg_opt, filstat_opt, mode_opt)
Open a file.
This module defines variable data types.
Definition kind.f90:8
This module contains simulation methods.
Definition Sim.f90:10
subroutine, public ustop(stopmess, ioutlocal)
Stop the simulation.
Definition Sim.f90:317
subroutine, public store_error(msg, terminate)
Store an error message.
Definition Sim.f90:94
integer(i4b) function, public count_errors()
Return number of errors.
Definition Sim.f90:60
integer(i4b), parameter, public stg_aft_con_ar
afterr connection allocate read
Definition SimStages.f90:18
integer(i4b), parameter, public stg_bfr_exg_ad
before exchange advance (per solution)
Definition SimStages.f90:21
integer(i4b), parameter, public stg_bfr_exg_cf
before exchange calculate (per solution)
Definition SimStages.f90:22
integer(i4b), parameter, public stg_bfr_con_ar
before connection allocate read
Definition SimStages.f90:17
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...
Energy storage and transfer.
Definition gwe-est.f90:48
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....