166 character(len=*),
intent(in) :: files(:)
168 do n = 1,
size(files)
169 open(
unitpar, file=trim(files(n)), status=
"old")
170 read(
unitpar, rt_list,
end=222)
184 double precision :: dlo(
ndim), dhi(
ndim), hi_req
189 call mpistop(
"rt_sc_setup: uniform Cartesian only (no stretched grids)")
232 if(
band_nbv(ib) < 1)
call mpistop(
"rt_sc_setup: band thinner than one block along updim")
236 write(*,
'(a,i2,a,es13.6,a,es13.6,a,i0,a,i0,a)') &
237 ' rt_sc_setup: band ', ib,
' top snapped ', hi_req*
unit_length, &
244 select case(trim(rt_sc_opacity))
246 call read_opacity_table()
247 rt_sc_chib => rt_sc_chib_rosseland
249 rt_sc_chib => rt_sc_chib_kramers
252 call mpistop(
"rt_sc_setup: rt_sc_opacity='usr' but usr_rt_sc_chiB not set in mod_usr.t")
255 call mpistop(
"rt_sc_setup: unknown rt_sc_opacity (Rosseland, Kramers or usr)")
262 if(
mype==0 .and. .not.bc_h_periodic) print *, &
267 rt_sc_polar_axis =
updim
272 " nband=",
rt_sc_nband,
" opacity=",trim(rt_sc_opacity)
278 allocate(
mu_h(rt_sc_nray),
mu_v(rt_sc_nray))
287 pure subroutine hv(ih, iv, i1, i2)
288 integer,
intent(in) :: ih, iv
289 integer,
intent(out) :: i1, i2
290 i1 =
eh(1)*ih +
ev(1)*iv
291 i2 =
eh(2)*ih +
ev(2)*iv
311 integer :: iigrid, igrid
313 do iigrid=1,igridstail; igrid=igrids(iigrid)
315 if(
allocated(
ps_rt(igrid)%w))
then
318 if(.not.
allocated(
ps_rt(igrid)%w))
allocate(
ps_rt(igrid)%w(ixg^t,1:nw))
321 ps_rt(igrid)%w = 0.0d0
322 ps_rt(igrid)%igrid = igrid
326 ps_rt(igrid)%x => ps(igrid)%x
327 ps_rt(igrid)%dvolume => ps(igrid)%dvolume
328 ps_rt(igrid)%is_physical_boundary=> ps(igrid)%is_physical_boundary
335 integer,
intent(in) :: dnxv, nray
353 integer,
intent(in) :: dnxv, nray
355 call mpi_allreduce(mpi_in_place,
rt_sc_seaml_cur, dnxv*nray, mpi_double_precision, mpi_sum,
icomm, ierr)
356 call mpi_allreduce(mpi_in_place,
rt_sc_seamr_cur, dnxv*nray, mpi_double_precision, mpi_sum,
icomm, ierr)
364 integer,
intent(in) :: n1, n2, comm
365 double precision,
intent(inout) :: a(n1,n2)
366 integer :: j0, j1, nc, ierr
368 nc = max(1, 131072/max(n1,1))
371 j1 = min(j0+nc-1, n2)
372 call mpi_allreduce(mpi_in_place, a(1,j0), n1*(j1-j0+1), mpi_double_precision, mpi_sum, comm, ierr)
subroutine, public mpistop(message)
Exit MPI-AMRVAC with an error message.
Module with geometry-related routines (e.g., divergence, curl).
integer, parameter cartesian
This module contains definitions of global parameters and variables and some generic functions/subrou...
integer ixghi
Upper index of grid block arrays.
integer domain_nx
number of cells for each dimension in level-one mesh
integer, parameter unitpar
file handle for IO
double precision unit_pressure
Physical scaling factor for pressure.
integer, parameter ndim
Number of spatial dimensions for grid variables.
double precision unit_length
Physical scaling factor for length.
integer icomm
The MPI communicator.
integer mype
The rank of the current MPI task.
integer block_nx
number of cells for each dimension in grid block excluding ghostcells
integer, parameter plevel_
double precision, dimension(:), allocatable, parameter d
logical, dimension(ndim) periodb
True for dimensions with periodic boundaries.
integer refine_max_level
Maximal number of AMR levels.
integer max_blocks
The maximum number of grid blocks in a processor.
integer, dimension(:,:), allocatable node
integer, parameter ixglo
Lower index of grid block arrays (always 1).
Transport kernel of the short-characteristics (SC) radiative transfer.
subroutine rt_sc_init()
Build the quadrature into mux, muy, muz and wmu as full 3D cosines, according to rt_sc_quad.
integer, public rt_sc_ndir
Azimuthal directions and polar nodes of the GL set, with nmu one of 2, 4, 6 or 8.
double precision, public rt_sc_blend_k
Weight of the heating blend, w = exp(-blend_k tau), and the scale of the taper tau^2/(tau^2 + tau_min...
character(len=16), public rt_sc_quad
The angular quadrature, either 'GL' (Gauss-Legendre polar nodes times equally spaced azimuths) or 'Ca...
double precision, public rt_sc_tau_min
integer, public rt_sc_nmu
Opacity and Planck source of the short-characteristics (SC) radiative transfer.
double precision, public rt_sc_dtcap
double precision, public rt_sc_dp_tr
double precision, public rt_sc_tcap
The built-in opacities keep the SC transfer on where the gas is cool (T < Tcap) or dense (p > p_TR),...
character(len=std_len), public rt_sc_kappa_table
The Rosseland table file, read in rt_sc_setup when the table model is chosen.
double precision, public rt_sc_p_tr
character(len=10), public rt_sc_opacity
The opacity model, either 'Rosseland' (the table), 'Kramers' (the analytic fit) or 'usr',...
Parameters, resolved state and lifecycle of the short-characteristics (SC) radiative transfer,...
integer i_isw
First column of the ray intensity in ps_rt, and -1 until reserved. It is the only field getbc exchang...
subroutine rt_sc_alloc_state()
Allocate ps_rt(igrid)w on every active block and zero it, sharing the geometry of ps,...
double precision, dimension(:), allocatable mu_h
Ray cosines along the RT grid axes (hdim, updim). They are (mux, muy) for updim = 2 and the swapped p...
integer, public rt_sc_nband
double precision, dimension(:,:,:), allocatable rtw_bb
subroutine rt_sc_seam_finalize(dnxv, nray)
Sum the seam edges of this solve over the ranks, where each edge has a single owner,...
double precision, dimension(:), allocatable mu_v
integer, dimension(rt_sc_maxband) band_nv
integer rt_node_comm
Node-local communicator for the moment reduction of the gather. The ranks reach that reduction far ou...
logical, public rt_sc_distributed
The distributed KBA wavefront. Each rank sweeps only its own band blocks, one diagonal at a time,...
double precision, dimension(:,:), allocatable rt_sc_seaml_prev
integer, public rt_sc_amr_level
The AMR level the RT runs on. The bands are held at this level so that the RT sees a uniform grid,...
logical rt_sc_seam_warned
double precision, public rt_wt_swp
double precision, public rt_sc_ftau1
Horizontal mean of the flux on the tau = rt_sc_tau_emergent surface, from rt_sc_emergent_tau1....
integer, public rt_nsolve
double precision, public rt_wt_wave
character(len=10), public rt_sc_bc_hmax
integer, dimension(2) eh
Unit steps of hdim and updim in block index space and the block index ranges along them,...
logical, public rt_sc_active
True when the physics module has switched the RT on, with hd_radiative_transfer or mhd_radiative_tran...
integer, dimension(rt_sc_maxband) band_nbv
logical, public rt_sc_flux_blend
rt_sc_flux_blend blends the thin heating c chi (J - B) with the thick -div F. rt_sc_cfl limits the he...
integer rg_nh
The RT grid on rt_sc_amr_level along (hdim, updim): cells across the domain, cells per block,...
double precision, dimension(rt_sc_maxband), public rt_sc_band_min
double precision, dimension(:,:,:), allocatable rtw_fx
double precision, dimension(:,:), allocatable rt_sc_seamr_cur
logical rt_sc_seam_on
The periodic seam of the single-pass KBA. A ray crossing the seam takes as its inflow the outflow at ...
subroutine, public rt_sc_reserve_slots()
Reserve the wavefront intensity slots in ps_rt, four in all, one per sweep corner,...
integer, dimension(:), allocatable wv_ig
double precision, dimension(rt_sc_maxband), public rt_sc_band_max
subroutine, public rt_sc_setup()
Check the geometry, convert the parameters to code units, resolve the bands and the boundary conditio...
double precision, public rt_sc_fi_thresh
Not read by the RT itself. The user files set it from eoseint_rho_FI_threshold for their own SC sourc...
subroutine rt_allreduce_chunk(a, n1, n2, comm)
In-place sum allreduce of a 2D array in chunks of whole columns of about 1 MB.
double precision, public rt_wt_red
integer nisw
Number of intensity slots, one for the ray-by-ray wave and up to four when pipelined.
integer, dimension(:), allocatable wv_bi
integer rt_lead_comm
Communicator of one leader rank per node. The field gather sums within each node, then over the leade...
double precision, public rt_sc_cfl
integer, public rt_sc_updim
Axis of the stratification, 1 for x and 2 for y. The default of -1 takes the last axis.
subroutine rt_sc_seam_alloc(dnxv, nray)
Allocate the seam buffers once, or again when the row or ray count changes, and zero the buffers writ...
character(len=10), dimension(rt_sc_maxband), public rt_sc_bc_min
character(len=10), public rt_sc_bc_hmin
Incoming intensity at the horizontal edges where they are not periodic, 'open' for I = 0 or 'thermal'...
double precision, dimension(:,:,:), allocatable rtw_chib
Block chi and B including the ghosts, rebuilt every solve, and the block horizontal flux Fx for the -...
pure subroutine hv(ih, iv, i1, i2)
Block indices (i1, i2) of the cell at position ih along hdim and iv along updim.
double precision, public rt_wt_gath
Cumulative wall time of the field gather, the sweep, the moment reduction and the scatter,...
type(state), dimension(:), allocatable, target ps_rt
The RT intensity state. It is kept out of the hydro w so that it skips the stage copies,...
subroutine rt_sc_axis_cosines()
Map the quadrature onto the RT grid axes (hdim, updim). Called after rt_sc_init.
double precision, public rt_wt_scat
integer, public i_qrad
Extra-variable indices of the heating Q, the vertical flux F and the emergent intensity Iout,...
logical, public rt_sc_pipeline
The pipelined KBA. The four sweep corners run at once, each with its own intensity slot,...
double precision, public rt_sc_blend_dt
double precision, dimension(:,:), allocatable rt_sc_seamr_prev
integer, parameter rt_sc_maxband
The RT bands along updim, of which a bar with a photosphere at each end needs two....
integer wv_nblk
The band blocks of this rank with their block position (bi, bj), the block rows of the current band a...
double precision, dimension(rt_sc_maxband) band_lo_c
integer, dimension(:), allocatable wv_bj
double precision, public rt_sc_tau_emergent
character(len=10), dimension(rt_sc_maxband), public rt_sc_bc_max
logical, public rt_sc_debug
Prints the cumulative RT timing every 10 solves.
subroutine, public rt_sc_params_read(files)
Read &rt_list from each parameter file. The values stay physical until rt_sc_setup,...
double precision, dimension(rt_sc_maxband) band_hi_c
logical, public rt_sc_valpipe
For validation, runs the ray-by-ray and pipelined waves on the same state and prints max|dQ|.
double precision, dimension(:,:), allocatable rt_sc_seaml_cur
double precision, public rt_sc_blend_t0
Centre and half-width in K of the temperature gate in rt_sc_thin_weight, which divides the radiative ...
Module with all the methods that users can customize in AMRVAC.
procedure(sub_rt_sc_chib), pointer usr_rt_sc_chib
opacity and Planck source for the SC RT when rt_sc_opacity = 'usr'