8 subroutine calc_grid(qunit,igrid,xC,xCC,xC_TMP,xCC_TMP,wC_TMP,wCC_TMP,normconv,&
23 integer,
intent(in) :: qunit, igrid
24 double precision,
intent(in),
dimension(ixMlo^D-1:ixMhi^D,ndim) :: xC
25 double precision,
intent(in),
dimension(ixMlo^D:ixMhi^D,ndim) :: xCC
26 integer :: ixC^L,ixCC^L
27 logical,
intent(in) :: first
29 double precision,
dimension(ixMlo^D-1:ixMhi^D,ndim) :: xC_TMP
30 double precision,
dimension(ixMlo^D:ixMhi^D,ndim) :: xCC_TMP
31 double precision,
dimension(ixMlo^D-1:ixMhi^D,nw+nwauxio) :: wC_TMP
32 double precision,
dimension(ixMlo^D:ixMhi^D,nw+nwauxio) :: wCC_TMP
33 double precision,
dimension(0:nw+nwauxio),
intent(out) :: normconv
35 double precision :: ldw(ixG^T), dwC(ixG^T)
36 double precision,
dimension(ixMlo^D-1:ixMhi^D,nw+nwauxio) :: wC
37 double precision,
dimension(ixMlo^D:ixMhi^D,nw+nwauxio) :: wCC
38 double precision,
dimension(ixG^T,1:nw+nwauxio) :: w
39 integer :: nxCC^D,idims,jxC^L,iwe
40 integer :: nx^D, nxC^D, ix^D, ix, iw, level, idir
41 logical,
save :: subfirst=.true.
46 ixcmin^d=ixmlo^d-1; ixcmax^d=ixmhi^d;
47 ixccmin^d=ixmlo^d; ixccmax^d=ixmhi^d;
49 nx^d=ixmhi^d-ixmlo^d+1;
55 w(ixg^t,1:nw)=ps(igrid)%w(ixg^t,1:nw)
65 do ix^d=jxcmin^d,jxcmax^d
66 w(ix^d^d%jxC^s,nw-nwextra+1:nw) = w(jxcmin^d-1^d%jxC^s,nw-nwextra+1:nw)
70 do ix^d=jxcmin^d,jxcmax^d
71 w(ix^d^d%jxC^s,nw-nwextra+1:nw) = w(jxcmax^d+1^d%jxC^s,nw-nwextra+1:nw)
87 call mpistop(
"usr_aux_output not defined")
100 w(ixg^t,iw_e)=w(ixg^t,iw_e)+0.5d0*sum(ps(igrid)%B0(ixg^t,:,0)**2,dim=
ndim+1) &
101 + sum(w(ixg^t,iw_mag(:))*ps(igrid)%B0(ixg^t,:,0),dim=
ndim+1)
103 w(ixg^t,iw_mag(:))=w(ixg^t,iw_mag(:))+ps(igrid)%B0(ixg^t,:,0)
107 wcc(ixcc^s,:)=w(ixcc^s,:)
114 {
do ix^db=ixcmin^db,ixcmax^db\}
115 wc(ix^d,iw)=sum(w(ix^d:ix^d+1,iw))/dble(2**
ndim)
120 {
do ix^db=ixcmin^db,ixcmax^db\}
121 wc(ix^d,iw)=sum(w(ix^d:ix^d+1,iw)*ps(igrid)%dvolume(ix^d:ix^d+1)) &
122 /sum(ps(igrid)%dvolume(ix^d:ix^d+1))
129 xc_tmp(ixc^s,1:ndim) = xc(ixc^s,1:ndim)
130 wc_tmp(ixc^s,1:nw+nwauxio) = wc(ixc^s,1:nw+nwauxio)
131 xcc_tmp(ixcc^s,1:ndim) = xcc(ixcc^s,1:ndim)
132 wcc_tmp(ixcc^s,1:nw+nwauxio) = wcc(ixcc^s,1:nw+nwauxio)
142 if(nwaux>0 .and. mype==0 .and. first.and.subfirst)
then
144 if(convert_type==
'idl'.or.convert_type==
'tecplot' &
145 .or.convert_type==
'vtu'.or.convert_type==
'vtuB') &
146 write(*,*)
'Warning: also averaged auxiliaries within calc_grid'
160 integer :: ix^L, ix^D, idim, iw, ivector, iw0
161 integer,
dimension(nw) :: vectoriw
162 double precision :: x_TEC(ndim), w_TEC(nw+nwauxio)
163 double precision,
dimension(ndim,ndim) :: normal
165 double precision,
dimension(ix^S,ndim) :: xC
166 double precision,
dimension(ix^S,nw+nwauxio) :: wC
168 double precision,
dimension(ix^S,ndim) :: x_TMP
169 double precision,
dimension(ix^S,nw+nwauxio) :: w_TMP
176 vectoriw(iw_vector(ivector)+idim)=iw_vector(ivector)
181 {
do ix^db=ixmin^db,ixmax^db\}
184 x_tec(1:ndim)=xc(ix^d,1:ndim)
185 w_tec(1:nw+nwauxio)=wc(ix^d,1:nw+nwauxio)
192 x_tec(1)=xc(ix^d,1)*cos(xc(ix^d,2))
193 x_tec(2)=xc(ix^d,1)*sin(xc(ix^d,2))
199 x_tec(1)=xc(ix^d,1)*cos(xc(ix^d,phi_))
200 x_tec(2)=xc(ix^d,1)*sin(xc(ix^d,phi_))
201 x_tec(3)=xc(ix^d,z_)}
204 {^ifoned normal(1,1)=one}
209 normal(1,1)=cos(xc(ix^d,2))
210 normal(1,2)=-sin(xc(ix^d,2))
211 normal(2,1)=sin(xc(ix^d,2))
212 normal(2,2)=cos(xc(ix^d,2))
221 normal(1,1)=cos(xc(ix^d,phi_))
222 normal(1,phi_)=-sin(xc(ix^d,phi_))
225 normal(2,1)=sin(xc(ix^d,phi_))
226 normal(2,phi_)=cos(xc(ix^d,phi_))
234 if (iw<=nw) iw0=vectoriw(iw)
235 if (iw0>=0.and.iw<=iw0+ndim.and.iw<=nw)
then
237 w_tec(iw0+idim)={^d&wc(ix^dd,iw0+^d)*normal(idim,^d)+}
239 w_tec(iw)=wc(ix^d,iw)
243 x_tec(1)=xc(ix^d,1){^nooned*sin(xc(ix^d,2))}{^ifthreed*cos(xc(ix^d,3))}
245 x_tec(2)=xc(ix^d,1)*cos(xc(ix^d,2))}
247 x_tec(2)=xc(ix^d,1)*sin(xc(ix^d,2))*sin(xc(ix^d,3))
248 x_tec(3)=xc(ix^d,1)*cos(xc(ix^d,2))}
251 {^ifoned normal(1,1)=one}
253 normal(1,1)=sin(xc(ix^d,2)){^ifthreed*cos(xc(ix^d,3))}
254 normal(1,2)=cos(xc(ix^d,2)){^ifthreed*cos(xc(ix^d,3))
255 normal(1,3)=-sin(xc(ix^d,3))}}
258 normal(2,1)=cos(xc(ix^d,2))
259 normal(2,2)=-sin(xc(ix^d,2))}
261 normal(2,1)=sin(xc(ix^d,2))*sin(xc(ix^d,3))
262 normal(2,2)=cos(xc(ix^d,2))*sin(xc(ix^d,3))
263 normal(2,3)=cos(xc(ix^d,3))
265 normal(3,1)=cos(xc(ix^d,2))
266 normal(3,2)=-sin(xc(ix^d,2))
270 if (iw<=nw) iw0=vectoriw(iw)
271 if (iw0>=0.and.iw<=iw0+ndim.and.iw<=nw)
then
273 w_tec(iw0+idim)={^d&wc(ix^dd,iw0+^d)*normal(idim,^d)+}
275 w_tec(iw)=wc(ix^d,iw)
279 write(*,*)
"No converter for coordinate=",coordinate
281 x_tmp(ix^d,1:ndim)=x_tec(1:ndim)
282 w_tmp(ix^d,1:nw+nwauxio)=w_tec(1:nw+nwauxio)
284 where(dabs(w_tmp(ix^d,1:nw+nwauxio))<smalldouble)
285 w_tmp(ix^d,1:nw+nwauxio)=zero
302 character(len=name_len) :: wnamei(1:nw+nwauxio),xandwnamei(1:ndim+nw+nwauxio)
303 character(len=1024) :: outfilehead
305 integer:: space_position,iw,ind
306 character(len=name_len):: wname
307 character(len=std_len):: aux_variable_names
308 character(len=std_len):: scanstring
310 logical,
save:: first=.true.
315 call mpistop(
"usr_add_aux_names not defined")
323 scanstring=trim(aux_variable_names)
324 wnamei(1:nw)=prim_wnames(1:nw)
326 scanstring=trim(aux_variable_names)
327 wnamei(1:nw)=cons_wnames(1:nw)
330 space_position=index(scanstring,
' ')
331 do iw=nw+1,nw+nwauxio
332 do while (space_position==1)
333 scanstring=scanstring(2:)
334 space_position=index(scanstring,
' ')
336 wname=scanstring(:space_position-1)
337 scanstring=scanstring(space_position+1:)
338 space_position=index(scanstring,
' ')
341 wnamei(iw)=trim(wname)
347 xandwnamei(1)=
"r";{^nooned xandwnamei(2)=
"Theta"};{^ifthreed xandwnamei(3)=
"Phi"}
363 xandwnamei(1)=
"X";{^nooned xandwnamei(2)=
"Y"};{^ifthreed xandwnamei(3)=
"Z"}
366 xandwnamei(ndim+1:ndim+nw+nwauxio)=wnamei(1:nw+nwauxio)
370 write(outfilehead,
'(a)') trim(xandwnamei(1))
374 write(outfilehead,
'(a)')outfilehead(1:len_trim(outfilehead))//
" "//trim(wname)
381 write(outfilehead,
'(a)')outfilehead(1:len_trim(outfilehead))//
" "//trim(wname)
386 do iw=ndim+nw+1,ndim+nw+nwauxio
388 write(outfilehead,
'(a)')outfilehead(1:len_trim(outfilehead))//
" "//trim(wname)
392 if(first.and.
mype==0)
then
393 print*,
'-------------------------------------------------------------------------------'
394 write(
unitterm,*)
'Saving visual data. Coordinate directions and variable names are:'
398 print *,ind,xandwnamei(iw)
403 write(*,*) ind,wnamei(iw-ndim)
406 do iw=ndim+nw+1,ndim+nw+nwauxio
408 print *,ind,wnamei(iw-ndim)
411 print*,
'-------------------------------------------------------------------------------'
421 integer,
intent(in) :: igrid
422 double precision,
intent(out) :: xC(ixMlo^D-1:ixMhi^D,ndim)
423 double precision,
intent(out) :: xCC(ixMlo^D:ixMhi^D,ndim)
425 integer :: ixC^L, idims, level, ix
430 xcc(
ixm^t,:)=ps(igrid)%x(
ixm^t,:)
433 ixcmin^d=ixmlo^d-1; ixcmax^d=ixmhi^d;
436 xc(ixc^s,idims)=ps(igrid)%x(ixc^s,idims)+0.5d0*
dx(idims,level)
440 {
do ix=ixcmin^d,ixcmax^d
441 xc(ix^d%ixC^s,^d)=ps(igrid)%x(ix^d%ixC^s,^d)+0.5d0*ps(igrid)%dx(ix^d%ixC^s,^d)
subroutine mpistop(message)
Exit MPI-AMRVAC with an error message.
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
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 (within a block with 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