29 integer(I4B),
pointer :: iadvwt => null()
30 real(dp),
pointer :: ats_percel => null()
31 integer(I4B),
dimension(:),
pointer,
contiguous :: ibound => null()
33 real(dp),
pointer :: eqnsclfac => null()
57 subroutine adv_cr(advobj, name_model, input_mempath, inunit, iout, fmi, &
61 character(len=*),
intent(in) :: name_model
62 character(len=*),
intent(in) :: input_mempath
63 integer(I4B),
intent(in) :: inunit
64 integer(I4B),
intent(in) :: iout
66 real(dp),
intent(in),
pointer :: eqnsclfac
72 call advobj%set_names(1, name_model,
'ADV',
'ADV', input_mempath)
75 call advobj%allocate_scalars()
78 advobj%inunit = inunit
81 advobj%eqnsclfac => eqnsclfac
93 character(len=*),
parameter :: fmtadv = &
94 "(1x,/1x,'ADV -- ADVECTION PACKAGE, VERSION 1, 8/25/2017', &
95 &' INPUT READ FROM MEMPATH: ', A, //)"
98 if (.not.
present(adv_options))
then
101 write (this%iout, fmtadv) this%input_mempath
104 call this%source_options()
108 this%iadvwt = adv_options%iAdvScheme
122 integer(I4B),
dimension(:),
pointer,
contiguous,
intent(in) :: ibound
124 integer(I4B) :: iadvwt_value
128 this%ibound => ibound
131 iadvwt_value = this%iadvwt
132 select case (iadvwt_value)
134 this%face_interpolation = &
137 this%face_interpolation = &
140 this%face_interpolation = &
145 this%face_interpolation = &
148 call store_error(
"Unknown advection scheme", terminate=.true.)
156 subroutine adv_dt(this, dtmax, msg, thetam)
159 real(DP),
intent(out) :: dtmax
160 character(len=*),
intent(inout) :: msg
161 real(DP),
dimension(:),
intent(in) :: thetam
166 integer(I4B) :: nrmax
167 character(len=LINELENGTH) :: cellstr
170 real(DP) :: flowsumpos
171 real(DP) :: flowsumneg
173 real(DP) :: cell_volume
180 if (this%ats_percel ==
dnodata)
then
186 do n = 1, this%dis%nodes
187 if (this%ibound(n) == 0) cycle
190 do ipos = this%dis%con%ia(n) + 1, this%dis%con%ia(n + 1) - 1
191 if (this%dis%con%mask(ipos) == 0) cycle
192 m = this%dis%con%ja(ipos)
193 if (this%ibound(m) == 0) cycle
194 flownm = this%fmi%gwfflowja(ipos)
195 if (flownm <
dzero)
then
196 flowsumneg = flowsumneg - flownm
198 flowsumpos = flowsumpos + flownm
201 flowmax = max(flowsumneg, flowsumpos)
202 if (flowmax <
dprec) cycle
203 cell_volume = this%dis%get_cell_volume(n, this%dis%top(n))
204 dt = cell_volume * this%fmi%gwfsat(n) * thetam(n) / flowmax
205 dt = dt * this%ats_percel
212 call this%dis%noder_to_string(nrmax, cellstr)
213 write (msg, *) adjustl(trim(this%memoryPath))//
'-'//trim(cellstr)
221 subroutine adv_fc(this, nodes, matrix_sln, idxglo, cnew, rhs)
225 integer(I4B),
intent(in) :: nodes
227 integer(I4B),
intent(in),
dimension(:) :: idxglo
228 real(DP),
intent(in),
dimension(:),
target :: cnew
229 real(DP),
dimension(:),
intent(inout) :: rhs
231 integer(I4B) :: n, m, idiag, ipos
236 call this%face_interpolation%set_field(cnew)
238 if (this%ibound(n) == 0) cycle
239 idiag = this%dis%con%ia(n)
240 do ipos = this%dis%con%ia(n) + 1, this%dis%con%ia(n + 1) - 1
241 m = this%dis%con%ja(ipos)
242 if (this%ibound(m) == 0) cycle
243 if (this%dis%con%mask(ipos) == 0) cycle
245 qnm = this%fmi%gwfflowja(ipos) * this%eqnsclfac
246 coefficients = this%face_interpolation%compute(n, m, ipos)
248 call matrix_sln%add_value_pos(idxglo(idiag), qnm * coefficients%c_n)
249 call matrix_sln%add_value_pos(idxglo(ipos), qnm * coefficients%c_m)
250 rhs(n) = rhs(n) + qnm * coefficients%rhs
261 real(DP),
intent(in),
dimension(:),
target :: cnew
262 real(DP),
intent(inout),
dimension(:) :: flowja
264 integer(I4B) :: nodes
265 integer(I4B) :: n, m, ipos
271 nodes = this%dis%nodes
273 call this%face_interpolation%set_field(cnew)
275 if (this%ibound(n) == 0) cycle
276 do ipos = this%dis%con%ia(n) + 1, this%dis%con%ia(n + 1) - 1
277 m = this%dis%con%ja(ipos)
278 if (this%ibound(m) == 0) cycle
279 qnm = this%fmi%gwfflowja(ipos) * this%eqnsclfac
281 coefficients = this%face_interpolation%compute(n, m, ipos)
282 flowja(ipos) = flowja(ipos) &
283 + qnm * coefficients%c_n * cnew(n) &
284 + qnm * coefficients%c_m * cnew(m) &
285 - qnm * coefficients%rhs
300 if (this%inunit > 0)
then
304 this%ibound => null()
311 call this%NumericalPackageType%da()
325 call this%NumericalPackageType%allocate_scalars()
328 call mem_allocate(this%iadvwt,
'IADVWT', this%memoryPath)
329 call mem_allocate(this%ats_percel,
'ATS_PERCEL', this%memoryPath)
351 character(len=LENVARNAME),
dimension(4) :: scheme = &
352 &[character(len=LENVARNAME) ::
'UPSTREAM',
'CENTRAL',
'TVD',
'UTVD']
353 logical(lgp) :: found_scheme, found_atspercel
355 character(len=*),
parameter :: fmtiadvwt = &
356 &
"(4x,'ADVECTION WEIGHTING SCHEME HAS BEEN SET TO: ', a)"
359 call mem_set_value(this%iadvwt,
'SCHEME', this%input_mempath, &
360 scheme, found_scheme)
361 call mem_set_value(this%ats_percel,
'ATS_PERCEL', this%input_mempath, &
364 if (found_scheme)
then
366 if (this%iadvwt == 0)
then
367 write (
errmsg,
'(a, a)') &
368 'Unknown scheme, must be "UPSTREAM", "CENTRAL", "TVD" or "UTVD"'
373 this%iadvwt = this%iadvwt - 1
377 if (found_atspercel)
then
378 if (this%ats_percel == dzero) this%ats_percel = dnodata
382 write (this%iout,
'(1x,a)')
'PROCESSING ADVECTION OPTIONS'
383 if (found_scheme)
then
384 write (this%iout, fmtiadvwt) trim(scheme(this%iadvwt + 1))
386 if (found_atspercel)
then
387 write (this%iout,
'(4x,a,1pg15.6)') &
388 'User-specified fractional cell distance for adaptive time &
389 &steps: ', this%ats_percel
391 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.
Decorator that adds caching to any gradient computation implementation.
Abstract interface for cell-based gradient computation.
Weighted least-squares gradient method for structured and unstructured grids.
Total Variation Diminishing (TVD) interpolation scheme.