28 integer(I4B),
pointer :: iadvwt => null()
29 real(dp),
pointer :: ats_percel => null()
30 integer(I4B),
dimension(:),
pointer,
contiguous :: ibound => null()
32 real(dp),
pointer :: eqnsclfac => null()
56 subroutine adv_cr(advobj, name_model, input_mempath, inunit, iout, fmi, &
60 character(len=*),
intent(in) :: name_model
61 character(len=*),
intent(in) :: input_mempath
62 integer(I4B),
intent(in) :: inunit
63 integer(I4B),
intent(in) :: iout
65 real(dp),
intent(in),
pointer :: eqnsclfac
71 call advobj%set_names(1, name_model,
'ADV',
'ADV', input_mempath)
74 call advobj%allocate_scalars()
77 advobj%inunit = inunit
80 advobj%eqnsclfac => eqnsclfac
92 character(len=*),
parameter :: fmtadv = &
93 "(1x,/1x,'ADV -- ADVECTION PACKAGE, VERSION 1, 8/25/2017', &
94 &' INPUT READ FROM MEMPATH: ', A, //)"
97 if (.not.
present(adv_options))
then
100 write (this%iout, fmtadv) this%input_mempath
103 call this%source_options()
107 this%iadvwt = adv_options%iAdvScheme
121 integer(I4B),
dimension(:),
pointer,
contiguous,
intent(in) :: ibound
123 integer(I4B) :: iadvwt_value
127 this%ibound => ibound
130 iadvwt_value = this%iadvwt
131 select case (iadvwt_value)
133 this%face_interpolation = &
136 this%face_interpolation = &
139 this%face_interpolation = &
143 this%face_interpolation = &
146 call store_error(
"Unknown advection scheme", terminate=.true.)
154 subroutine adv_dt(this, dtmax, msg, thetam)
157 real(DP),
intent(out) :: dtmax
158 character(len=*),
intent(inout) :: msg
159 real(DP),
dimension(:),
intent(in) :: thetam
164 integer(I4B) :: nrmax
165 character(len=LINELENGTH) :: cellstr
168 real(DP) :: flowsumpos
169 real(DP) :: flowsumneg
171 real(DP) :: cell_volume
178 if (this%ats_percel ==
dnodata)
then
184 do n = 1, this%dis%nodes
185 if (this%ibound(n) == 0) cycle
188 do ipos = this%dis%con%ia(n) + 1, this%dis%con%ia(n + 1) - 1
189 if (this%dis%con%mask(ipos) == 0) cycle
190 m = this%dis%con%ja(ipos)
191 if (this%ibound(m) == 0) cycle
192 flownm = this%fmi%gwfflowja(ipos)
193 if (flownm <
dzero)
then
194 flowsumneg = flowsumneg - flownm
196 flowsumpos = flowsumpos + flownm
199 flowmax = max(flowsumneg, flowsumpos)
200 if (flowmax <
dprec) cycle
201 cell_volume = this%dis%get_cell_volume(n, this%dis%top(n))
202 dt = cell_volume * this%fmi%gwfsat(n) * thetam(n) / flowmax
203 dt = dt * this%ats_percel
210 call this%dis%noder_to_string(nrmax, cellstr)
211 write (msg, *) adjustl(trim(this%memoryPath))//
'-'//trim(cellstr)
219 subroutine adv_fc(this, nodes, matrix_sln, idxglo, cnew, rhs)
223 integer(I4B),
intent(in) :: nodes
225 integer(I4B),
intent(in),
dimension(:) :: idxglo
226 real(DP),
intent(in),
dimension(:) :: cnew
227 real(DP),
dimension(:),
intent(inout) :: rhs
229 integer(I4B) :: n, m, idiag, ipos
235 if (this%ibound(n) == 0) cycle
236 idiag = this%dis%con%ia(n)
237 do ipos = this%dis%con%ia(n) + 1, this%dis%con%ia(n + 1) - 1
238 m = this%dis%con%ja(ipos)
239 if (this%ibound(m) == 0) cycle
240 if (this%dis%con%mask(ipos) == 0) cycle
242 qnm = this%fmi%gwfflowja(ipos) * this%eqnsclfac
243 coefficients = this%face_interpolation%compute(n, m, ipos, cnew)
245 call matrix_sln%add_value_pos(idxglo(idiag), qnm * coefficients%c_n)
246 call matrix_sln%add_value_pos(idxglo(ipos), qnm * coefficients%c_m)
247 rhs(n) = rhs(n) + qnm * coefficients%rhs
258 real(DP),
intent(in),
dimension(:) :: cnew
259 real(DP),
intent(inout),
dimension(:) :: flowja
261 integer(I4B) :: nodes
262 integer(I4B) :: n, m, ipos
268 nodes = this%dis%nodes
271 if (this%ibound(n) == 0) cycle
272 do ipos = this%dis%con%ia(n) + 1, this%dis%con%ia(n + 1) - 1
273 m = this%dis%con%ja(ipos)
274 if (this%ibound(m) == 0) cycle
275 qnm = this%fmi%gwfflowja(ipos) * this%eqnsclfac
277 coefficients = this%face_interpolation%compute(n, m, ipos, cnew)
278 flowja(ipos) = flowja(ipos) &
279 + qnm * coefficients%c_n * cnew(n) &
280 + qnm * coefficients%c_m * cnew(m) &
281 - qnm * coefficients%rhs
296 if (this%inunit > 0)
then
300 this%ibound => null()
307 call this%NumericalPackageType%da()
321 call this%NumericalPackageType%allocate_scalars()
324 call mem_allocate(this%iadvwt,
'IADVWT', this%memoryPath)
325 call mem_allocate(this%ats_percel,
'ATS_PERCEL', this%memoryPath)
347 character(len=LENVARNAME),
dimension(4) :: scheme = &
348 &[character(len=LENVARNAME) ::
'UPSTREAM',
'CENTRAL',
'TVD',
'UTVD']
349 logical(lgp) :: found_scheme, found_atspercel
351 character(len=*),
parameter :: fmtiadvwt = &
352 &
"(4x,'ADVECTION WEIGHTING SCHEME HAS BEEN SET TO: ', a)"
355 call mem_set_value(this%iadvwt,
'SCHEME', this%input_mempath, &
356 scheme, found_scheme)
357 call mem_set_value(this%ats_percel,
'ATS_PERCEL', this%input_mempath, &
360 if (found_scheme)
then
362 if (this%iadvwt == 0)
then
363 write (
errmsg,
'(a, a)') &
364 'Unknown scheme, must be "UPSTREAM", "CENTRAL", "TVD" or "UTVD"'
369 this%iadvwt = this%iadvwt - 1
372 if (found_atspercel)
then
373 if (this%ats_percel == dzero) this%ats_percel = dnodata
377 write (this%iout,
'(1x,a)')
'PROCESSING ADVECTION OPTIONS'
378 if (found_scheme)
then
379 write (this%iout, fmtiadvwt) trim(scheme(this%iadvwt + 1))
381 if (found_atspercel)
then
382 write (this%iout,
'(4x,a,1pg15.6)') &
383 'User-specified fractional cell distance for adaptive time &
384 &steps: ', this%ats_percel
386 write (this%iout,
'(1x,a)')
'END OF ADVECTION OPTIONS'
integer(i4b), parameter adv_scheme_tvd
integer(i4b), parameter adv_scheme_upstream
integer(i4b), parameter adv_scheme_utvd
integer(i4b), parameter adv_scheme_central
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
real(dp), parameter dnodata
real no data constant
integer(i4b), parameter lenvarname
maximum length of a variable name
real(dp), parameter dzero
real constant zero
real(dp), parameter dprec
real constant machine precision
real(dp), parameter done
real constant 1
This module defines variable data types.
This module contains the base numerical package type.
This module contains simulation methods.
subroutine, public store_error(msg, terminate)
Store an error message.
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
subroutine, public adv_cr(advobj, name_model, input_mempath, inunit, iout, fmi, eqnsclfac)
@ brief Create a new ADV object
subroutine source_options(this)
Source input options.
subroutine adv_df(this, adv_options)
Define ADV object.
subroutine adv_fc(this, nodes, matrix_sln, idxglo, cnew, rhs)
Fill coefficient method for ADV package.
subroutine adv_cq(this, cnew, flowja)
Calculate advection contribution to flowja.
subroutine adv_da(this)
Deallocate memory.
subroutine adv_ar(this, dis, ibound)
Allocate and read method for package.
subroutine adv_dt(this, dtmax, msg, thetam)
Calculate maximum time step length.
subroutine allocate_scalars(this)
Allocate scalars specific to the streamflow energy transport (SFE) package.
Abstract interface for cell-based gradient computation.
Weighted least-squares gradient method for structured and unstructured grids.
Total Variation Diminishing (TVD) interpolation scheme.