8 subroutine calc_grid(qunit,igrid,xC,xCC,xC_TMP,xCC_TMP,wC_TMP,wCC_TMP,normconv,&
24 integer,
intent(in) :: qunit, igrid
25 double precision,
intent(in),
dimension(ixMlo^D-1:ixMhi^D,ndim) :: xC
26 double precision,
intent(in),
dimension(ixMlo^D:ixMhi^D,ndim) :: xCC
27 integer :: ixC^L,ixCC^L
28 logical,
intent(in) :: first
30 double precision,
dimension(ixMlo^D-1:ixMhi^D,ndim) :: xC_TMP
31 double precision,
dimension(ixMlo^D:ixMhi^D,ndim) :: xCC_TMP
32 double precision,
dimension(ixMlo^D-1:ixMhi^D,nw+nwauxio) :: wC_TMP
33 double precision,
dimension(ixMlo^D:ixMhi^D,nw+nwauxio) :: wCC_TMP
34 double precision,
dimension(0:nw+nwauxio),
intent(out) :: normconv
36 double precision :: ldw(ixG^T), dwC(ixG^T)
37 double precision,
dimension(ixMlo^D-1:ixMhi^D,nw+nwauxio) :: wC
38 double precision,
dimension(ixMlo^D:ixMhi^D,nw+nwauxio) :: wCC
39 double precision,
dimension(ixG^T,1:nw+nwauxio) :: w
40 integer :: nxCC^D,idims,jxC^L,iwe
41 integer :: nx^D, nxC^D, ix^D, ix, iw, level, idir
42 logical,
save :: subfirst=.true.
47 ixcmin^d=ixmlo^d-1; ixcmax^d=ixmhi^d;
48 ixccmin^d=ixmlo^d; ixccmax^d=ixmhi^d;
50 nx^d=ixmhi^d-ixmlo^d+1;
56 w(ixg^t,1:nw)=ps(igrid)%w(ixg^t,1:nw)
66 do ix^d=jxcmin^d,jxcmax^d
67 w(ix^d^d%jxC^s,nw-nwextra+1:nw) = w(jxcmin^d-1^d%jxC^s,nw-nwextra+1:nw)
71 do ix^d=jxcmin^d,jxcmax^d
72 w(ix^d^d%jxC^s,nw-nwextra+1:nw) = w(jxcmax^d+1^d%jxC^s,nw-nwextra+1:nw)
88 call mpistop(
"usr_aux_output not defined")
101 w(ixg^t,iw_e)=w(ixg^t,iw_e)+0.5d0*sum(ps(igrid)%B0(ixg^t,:,0)**2,dim=
ndim+1) &
102 + sum(w(ixg^t,iw_mag(:))*ps(igrid)%B0(ixg^t,:,0),dim=
ndim+1)
104 w(ixg^t,iw_mag(:))=w(ixg^t,iw_mag(:))+ps(igrid)%B0(ixg^t,:,0)
108 wcc(ixcc^s,:)=w(ixcc^s,:)
115 {
do ix^db=ixcmin^db,ixcmax^db\}
116 wc(ix^d,iw)=sum(w(ix^d:ix^d+1,iw))/dble(2**
ndim)
121 {
do ix^db=ixcmin^db,ixcmax^db\}
122 wc(ix^d,iw)=sum(w(ix^d:ix^d+1,iw)*ps(igrid)%dvolume(ix^d:ix^d+1)) &
123 /sum(ps(igrid)%dvolume(ix^d:ix^d+1))
130 xc_tmp(ixc^s,1:ndim) = xc(ixc^s,1:ndim)
131 wc_tmp(ixc^s,1:nw+nwauxio) = wc(ixc^s,1:nw+nwauxio)
132 xcc_tmp(ixcc^s,1:ndim) = xcc(ixcc^s,1:ndim)
133 wcc_tmp(ixcc^s,1:nw+nwauxio) = wcc(ixcc^s,1:nw+nwauxio)
143 if(nwaux>0 .and. mype==0 .and. first.and.subfirst)
then
145 if(convert_type==
'idl'.or.convert_type==
'tecplot' &
146 .or.convert_type==
'vtu'.or.convert_type==
'vtuB') &
147 write(*,*)
'Warning: also averaged auxiliaries within calc_grid'
161 integer :: ix^L, ix^D, idim, iw, ivector, iw0
162 integer,
dimension(nw) :: vectoriw
163 double precision :: x_TEC(ndim), w_TEC(nw+nwauxio)
164 double precision,
dimension(ndim,ndim) :: normal
166 double precision,
dimension(ix^S,ndim) :: xC
167 double precision,
dimension(ix^S,nw+nwauxio) :: wC
169 double precision,
dimension(ix^S,ndim) :: x_TMP
170 double precision,
dimension(ix^S,nw+nwauxio) :: w_TMP
177 vectoriw(iw_vector(ivector)+idim)=iw_vector(ivector)
182 {
do ix^db=ixmin^db,ixmax^db\}
185 x_tec(1:ndim)=xc(ix^d,1:ndim)
186 w_tec(1:nw+nwauxio)=wc(ix^d,1:nw+nwauxio)
193 x_tec(1)=xc(ix^d,1)*cos(xc(ix^d,2))
194 x_tec(2)=xc(ix^d,1)*sin(xc(ix^d,2))
200 x_tec(1)=xc(ix^d,1)*cos(xc(ix^d,phi_))
201 x_tec(2)=xc(ix^d,1)*sin(xc(ix^d,phi_))
202 x_tec(3)=xc(ix^d,z_)}
205 {^ifoned normal(1,1)=one}
210 normal(1,1)=cos(xc(ix^d,2))
211 normal(1,2)=-sin(xc(ix^d,2))
212 normal(2,1)=sin(xc(ix^d,2))
213 normal(2,2)=cos(xc(ix^d,2))
222 normal(1,1)=cos(xc(ix^d,phi_))
223 normal(1,phi_)=-sin(xc(ix^d,phi_))
226 normal(2,1)=sin(xc(ix^d,phi_))
227 normal(2,phi_)=cos(xc(ix^d,phi_))
235 if (iw<=nw) iw0=vectoriw(iw)
236 if (iw0>=0.and.iw<=iw0+ndim.and.iw<=nw)
then
238 w_tec(iw0+idim)={^d&wc(ix^dd,iw0+^d)*normal(idim,^d)+}
240 w_tec(iw)=wc(ix^d,iw)
244 x_tec(1)=xc(ix^d,1){^nooned*sin(xc(ix^d,2))}{^ifthreed*cos(xc(ix^d,3))}
246 x_tec(2)=xc(ix^d,1)*cos(xc(ix^d,2))}
248 x_tec(2)=xc(ix^d,1)*sin(xc(ix^d,2))*sin(xc(ix^d,3))
249 x_tec(3)=xc(ix^d,1)*cos(xc(ix^d,2))}
252 {^ifoned normal(1,1)=one}
254 normal(1,1)=sin(xc(ix^d,2)){^ifthreed*cos(xc(ix^d,3))}
255 normal(1,2)=cos(xc(ix^d,2)){^ifthreed*cos(xc(ix^d,3))
256 normal(1,3)=-sin(xc(ix^d,3))}}
259 normal(2,1)=cos(xc(ix^d,2))
260 normal(2,2)=-sin(xc(ix^d,2))}
262 normal(2,1)=sin(xc(ix^d,2))*sin(xc(ix^d,3))
263 normal(2,2)=cos(xc(ix^d,2))*sin(xc(ix^d,3))
264 normal(2,3)=cos(xc(ix^d,3))
266 normal(3,1)=cos(xc(ix^d,2))
267 normal(3,2)=-sin(xc(ix^d,2))
271 if (iw<=nw) iw0=vectoriw(iw)
272 if (iw0>=0.and.iw<=iw0+ndim.and.iw<=nw)
then
274 w_tec(iw0+idim)={^d&wc(ix^dd,iw0+^d)*normal(idim,^d)+}
276 w_tec(iw)=wc(ix^d,iw)
280 write(*,*)
"No converter for coordinate=",coordinate
282 x_tmp(ix^d,1:ndim)=x_tec(1:ndim)
283 w_tmp(ix^d,1:nw+nwauxio)=w_tec(1:nw+nwauxio)
285 where(dabs(w_tmp(ix^d,1:nw+nwauxio))<smalldouble)
286 w_tmp(ix^d,1:nw+nwauxio)=zero
304 character(len=name_len) :: wnamei(1:nw+nwauxio),xandwnamei(1:ndim+nw+nwauxio)
305 character(len=1024) :: outfilehead
307 integer:: space_position,iw,ind
308 character(len=name_len):: wname
309 character(len=std_len):: aux_variable_names
310 character(len=std_len):: scanstring
312 logical,
save:: first=.true.
317 call mpistop(
"usr_add_aux_names not defined")
325 scanstring=trim(aux_variable_names)
326 wnamei(1:nw)=prim_wnames(1:nw)
328 scanstring=trim(aux_variable_names)
329 wnamei(1:nw)=cons_wnames(1:nw)
332 space_position=index(scanstring,
' ')
333 do iw=nw+1,nw+nwauxio
334 do while (space_position==1)
335 scanstring=scanstring(2:)
336 space_position=index(scanstring,
' ')
338 wname=scanstring(:space_position-1)
339 scanstring=scanstring(space_position+1:)
340 space_position=index(scanstring,
' ')
343 wnamei(iw)=trim(wname)
349 xandwnamei(1)=
"r";{^nooned xandwnamei(2)=
"Theta"};{^ifthreed xandwnamei(3)=
"Phi"}
365 xandwnamei(1)=
"X";{^nooned xandwnamei(2)=
"Y"};{^ifthreed xandwnamei(3)=
"Z"}
368 xandwnamei(ndim+1:ndim+nw+nwauxio)=wnamei(1:nw+nwauxio)
372 write(outfilehead,
'(a)') trim(xandwnamei(1))
376 write(outfilehead,
'(a)')outfilehead(1:len_trim(outfilehead))//
" "//trim(wname)
383 write(outfilehead,
'(a)')outfilehead(1:len_trim(outfilehead))//
" "//trim(wname)
388 do iw=ndim+nw+1,ndim+nw+nwauxio
390 write(outfilehead,
'(a)')outfilehead(1:len_trim(outfilehead))//
" "//trim(wname)
394 if(first.and.
mype==0)
then
395 print*,
'-------------------------------------------------------------------------------'
396 write(
unitterm,*)
'Saving visual data. Coordinate directions and variable names are:'
400 print *,ind,xandwnamei(iw)
405 write(*,*) ind,wnamei(iw-ndim)
408 do iw=ndim+nw+1,ndim+nw+nwauxio
410 print *,ind,wnamei(iw-ndim)
413 print*,
'-------------------------------------------------------------------------------'
423 integer,
intent(in) :: igrid
424 double precision,
intent(out) :: xC(ixMlo^D-1:ixMhi^D,ndim)
425 double precision,
intent(out) :: xCC(ixMlo^D:ixMhi^D,ndim)
427 integer :: ixC^L, idims, level, ix
432 xcc(
ixm^t,:)=ps(igrid)%x(
ixm^t,:)
435 ixcmin^d=ixmlo^d-1; ixcmax^d=ixmhi^d;
438 xc(ixc^s,idims)=ps(igrid)%x(ixc^s,idims)+0.5d0*
dx(idims,level)
442 {
do ix=ixcmin^d,ixcmax^d
443 xc(ix^d%ixC^s,^d)=ps(igrid)%x(ix^d%ixC^s,^d)+0.5d0*ps(igrid)%dx(ix^d%ixC^s,^d)
Handles computations for coordinates and variables in output.
subroutine calc_grid(qunit, igrid, xC, xCC, xC_TMP, xCC_TMP, wC_TMP, wCC_TMP, normconv, ixCL, ixCCL, first)
Compute both corner as well as cell-centered values for output.
subroutine getheadernames(wnamei, xandwnamei, outfilehead)
get all variables names
subroutine calc_x(igrid, xC, xCC)
computes cell corner (xC) and cell center (xCC) coordinates
subroutine to_cartesian(x_TMP, w_TMP, ixL, xC, wC)
convert to cartesian coordinates and vector components
subroutine, public mpistop(message)
Exit MPI-AMRVAC with an error message.
Module with geometry-related routines (e.g., divergence, curl)
integer, parameter spherical
integer, parameter cartesian
integer, parameter cylindrical
integer, parameter cartesian_expansion
integer, parameter cartesian_stretched
This module contains definitions of global parameters and variables and some generic functions/subrou...
double precision, dimension(:), allocatable w_convert_factor
Conversion factors the primitive variables.
type(state), pointer block
Block pointer for using one block and its previous state.
integer ixghi
Upper index of grid block arrays.
double precision global_time
The global simulation time.
logical saveprim
If true, convert from conservative to primitive variables in output.
integer, parameter ndim
Number of spatial dimensions for grid variables.
integer mype
The rank of the current MPI task.
integer, parameter plevel_
double precision length_convert_factor
integer ixm
the mesh range of a physical block without ghost cells
integer nwauxio
Number of auxiliary variables that are only included in output.
integer, parameter unitterm
Unit for standard output.
logical, dimension(:), allocatable w_write
logical b0field
split magnetic field as background B0 field
double precision, dimension(:,:), allocatable rnode
Corner coordinates.
double precision, dimension(:,:), allocatable dx
integer nghostcells
Number of ghost cells surrounding a grid.
logical slab_uniform
uniform Cartesian geometry or not (stretched Cartesian)
integer, dimension(:,:), allocatable node
double precision, dimension(ndim) dxlevel
integer, parameter ixglo
Lower index of grid block arrays (always 1)
Module with slope/flux limiters.
This module defines the procedures of a physics module. It contains function pointers for the various...
procedure(sub_convert), pointer phys_to_primitive
character(len=name_len) physics_type
String describing the physics type of the simulation.
logical phys_energy
Solve energy equation or not.
Module with all the methods that users can customize in AMRVAC.
procedure(aux_output), pointer usr_aux_output
procedure(add_aux_names), pointer usr_add_aux_names