18 logical,
save :: firstcollapse=.true.
21 if (firstcollapse)
then
36 integer,
intent(in) :: dir
38 integer :: jgrid, igrid, Morton_no
39 double precision,
dimension(0:nw+nwauxio) :: normconv
41 if(.not.
slab)
call mpistop(
"collapse only for slab cartesian cases")
56 call mpi_reduce(mpi_in_place,collapseddata,
size(collapseddata),mpi_double_precision,mpi_sum,0,
icomm,
ierrmpi)
58 call mpi_reduce(collapseddata,collapseddata,
size(collapseddata),mpi_double_precision,mpi_sum,0,
icomm,
ierrmpi)
69 call mpistop(
"Unknown filetype for collapsed views")
72 call mpistop(
"sorry, 1D collapsed output routine not yet implemented (should be easy)...")
79 deallocate(collapseddata)
86 integer,
intent(in) :: dir
87 double precision,
dimension(0:nw+nwauxio),
intent(in):: normconv
88 character(len=1024) :: filename, outfilehead, line
91 character(len=name_len) :: wnamei(1:nw+nwauxio),xandwnamei(1:ndim+nw+nwauxio)
92 integer,
dimension(ndim) :: myshape
95 double precision :: dxdim^DM, xdim^LIM^DM
107 xdim^lim1=
xprob^lim2;
108 xdim^lim2=
xprob^lim3;
112 xdim^lim1=
xprob^lim1;
113 xdim^lim2=
xprob^lim3;
117 xdim^lim1=
xprob^lim1;
118 xdim^lim2=
xprob^lim2;
122 xdim^lim1=
xprob^lim2;
123 xdim^lim2=
xprob^lim3;
124 call mpistop(
"slice direction not clear in output_collapsed_csv")
131 xdim^lim1=
xprob^lim2;
134 xdim^lim1=
xprob^lim1;
137 xdim^lim1=
xprob^lim2;
138 call mpistop(
"slice direction not clear in output_collapsed_csv")
143 if(.not.fileopen)
then
145 write(filename,
"(a,i1.1,a,i1.1,a,i4.4,a)") trim(
base_filename) //
'_d', &
147 open(
unitcollapse,file=filename,status=
'unknown',form=
'formatted')
152 do iw=1,ndim+nw+nwauxio-1
153 if (iw .eq. dir) cycle
154 line = trim(line)//trim(xandwnamei(iw))//
', '
156 line = trim(line)//trim(xandwnamei(ndim+nw+nwauxio))
158 myshape = shape(collapseddata)
160 {^dm&
do ix^dmb = 1,myshape(^dmb)\}
163 {^dm& dxdim^dm*dble(ix^dm)+xdimmin^dm}, &
164 (collapseddata(ix^dm,iw)*normconv(iw),iw=1,nw+nwauxio)
175 integer,
intent(in) :: dir
176 double precision,
dimension(0:nw+nwauxio),
intent(in):: normconv
177 character(len=1024) :: filename, outfilehead, line
180 character(len=name_len) :: wnamei(1:nw+nwauxio),xandwnamei(1:ndim+nw+nwauxio)
181 integer,
dimension(ndim) :: myshape
184 double precision :: dxdim^DM, xdim^LIM^DM
186 double precision :: origin(1:3), spacing(1:3)
187 integer :: wholeExtent(1:6), size_single, length, size_length
201 xdim^lim1=
xprob^lim2;
202 xdim^lim2=
xprob^lim3;
206 xdim^lim1=
xprob^lim1;
207 xdim^lim2=
xprob^lim3;
211 xdim^lim1=
xprob^lim1;
212 xdim^lim2=
xprob^lim2;
216 xdim^lim1=
xprob^lim2;
217 xdim^lim2=
xprob^lim3;
218 call mpistop(
"slice direction not clear in output_collapsed_vti")
225 xdim^lim1=
xprob^lim2;
228 xdim^lim1=
xprob^lim1;
231 xdim^lim1=
xprob^lim2;
232 call mpistop(
"slice direction not clear in output_collapsed_vti")
239 myshape = shape(collapseddata)
244 length = ^dm&myshape(^dm)*
245 length = length*size_single
246 {^dm&wholeextent(^dm*2)=myshape(^dm); }
247 {^dm&spacing(^dm) = dxdim^dm; }
248 {^dm&origin(^
d) = xdimmin^dm; }
252 if(.not.fileopen)
then
254 write(filename,
"(a,i1.1,a,i1.1,a,i4.4,a)") trim(
base_filename)//
'_d',dir,&
256 open(
unitcollapse,file=filename,status=
'unknown',form=
'formatted')
263 write(
unitcollapse,
'(a)',advance=
'no')
'<VTKFile type="ImageData"'
265 write(
unitcollapse,
'(a)')
' version="0.1" byte_order="LittleEndian">'
267 write(
unitcollapse,
'(a)')
' version="0.1" byte_order="BigEndian">'
270 write(
unitcollapse,
'(a,3(1pe14.6),a,6(i10),a,3(1pe14.6),a)')
' <ImageData Origin="',&
271 origin,
'" WholeExtent="',wholeextent,
'" Spacing="',spacing,
'">'
273 write(
unitcollapse,
'(2a)')
'<DataArray type="Float32" Name="TIME" ',&
274 'NumberOfTuples="1" format="ascii">'
281 '<Piece Extent="',wholeextent,
'">'
289 '<DataArray type="Float32" Name="',trim(wnamei(iw)),&
290 '" format="appended" offset="',offset,
'"/>'
291 offset = offset + length + size_length
297 write(
unitcollapse,
'(a)')
'<AppendedData encoding="raw">'
300 open(
unitcollapse,file=filename,access=
'stream',form=
'unformatted',position=
'append')
310 write(
unitcollapse) real(collapseddata(iw)*normconv(iw))
313 write(
unitcollapse) (real(collapseddata(ix1,iw)*normconv(iw)),ix1=1,myshape(1))
316 write(
unitcollapse) ((real(collapseddata(ix1,ix2,iw)*normconv(iw)),ix1=1,&
317 myshape(1)),ix2=1,myshape(2))
322 open(
unitcollapse,file=filename,status=
'unknown',form=
'formatted',position=
'append')
333 integer,
intent(in) :: dir
339 nx^d=ixmhi^d-ixmlo^d+1;
344 allocate(collapseddata(&
347 allocate(collapseddata(&
350 allocate(collapseddata(&
353 call mpistop(
"slice direction not clear in allocate_collapsed")
359 allocate(collapseddata(&
362 allocate(collapseddata(&
365 call mpistop(
"slice direction not clear in allocate_collapsed")
369 allocate(collapseddata(nw+
nwauxio))
378 integer,
intent(in) :: igrid, jgrid, dir
382 integer :: ig^D, level, ig^Dtargetmin, ig^Dtargetmax
383 integer :: ix^Dtarget^LIM, idim^Dtarget^LIM
384 integer :: ixMdim^LLIM^D, ix^Dorig, ix^D
390 {^d& ig^d = tree%node%ig^d; }
391 level = tree%node%level
393 nx^d=ixmhi^d-ixmlo^d+1;
398 ig^dtargetmin = int(dble(ig^d-1)/2.0d0**(level-
collapselevel))+1
399 ig^dtargetmax = ig^dtargetmin
407 ix^dtargetmin = nx^d*(ig^dtargetmin-1)+1
408 ix^dtargetmax = nx^d*ig^dtargetmax
416 idim1target^lim=ix2target^lim;
417 idim2target^lim=ix3target^lim;
418 ixmdim^llim1=
ixm^llim2;
419 ixmdim^llim2=
ixm^llim3;
423 idim1target^lim=ix1target^lim;
424 idim2target^lim=ix3target^lim;
425 ixmdim^llim1=
ixm^llim1;
426 ixmdim^llim2=
ixm^llim3;
430 idim1target^lim=ix1target^lim;
431 idim2target^lim=ix2target^lim;
432 ixmdim^llim1=
ixm^llim1;
433 ixmdim^llim2=
ixm^llim2;
435 call mpistop(
"slice direction not clear in integrate_subnode")
439 do ix1orig = ixmdimlo1,ixmdimhi1
440 do ix2orig = ixmdimlo2,ixmdimhi2
442 collapseddata(ix1,ix2,1:nw+
nwauxio) = collapseddata(ix1,ix2,1:nw+
nwauxio) &
448 do ix^dm = idim^dmtargetmin,idim^dmtargetmax\}
450 collapseddata(ix1,ix2,1:nw+
nwauxio) = collapseddata(ix1,ix2,1:nw+
nwauxio) + ps_sub(jgrid)%w(ix1orig,ix2orig,1:nw+
nwauxio)
458 idim1target^lim=ix2target^lim;
459 ixmdim^llim1=
ixm^llim2;
462 idim1target^lim=ix1target^lim;
463 ixmdim^llim1=
ixm^llim1;
465 call mpistop(
"slice direction not clear in integrate_subnode")
469 do ix1orig = ixmdimlo1,ixmdimhi1
471 collapseddata(ix1,1:nw+
nwauxio) = collapseddata(ix1,1:nw+
nwauxio) &
476 do ix^dm = idim^dmtargetmin,idim^dmtargetmax\}
478 collapseddata(ix1,1:nw+
nwauxio) = collapseddata(ix1,1:nw+
nwauxio) + ps_sub(jgrid)%w(ix1orig,1:nw+
nwauxio)
494 integer,
intent(in) :: igrid, jgrid, dir
495 double precision,
dimension(0:nw+nwauxio),
intent(out) :: normconv
498 double precision :: dx^D
499 double precision,
dimension(ixMlo^D-1:ixMhi^D,ndim) :: xC_TMP, xC
500 double precision,
dimension(ixMlo^D:ixMhi^D,ndim) :: xCC_TMP, xCC
501 double precision,
dimension(ixMlo^D-1:ixMhi^D,nw+nwauxio) :: wC_TMP
502 double precision,
dimension(ixMlo^D:ixMhi^D,nw+nwauxio) :: wCC_TMP
503 integer :: ixC^L, ixCC^L
517 ps_sub(jgrid)%w(ixmlo2:ixmhi2,ixmlo3:ixmhi3,1:nw+
nwauxio) = &
518 ps_sub(jgrid)%w(ixmlo2:ixmhi2,ixmlo3:ixmhi3,1:nw+
nwauxio) &
519 + wcc_tmp(ix,ixmlo2:ixmhi2,ixmlo3:ixmhi3,1:nw+
nwauxio) * dx1
524 ps_sub(jgrid)%w(ixmlo2:ixmhi2,ixmlo3:ixmhi3,iw) = &
525 ps_sub(jgrid)%w(ixmlo2:ixmhi2,ixmlo3:ixmhi3,iw) &
526 + wcc_tmp(ix,ixmlo2:ixmhi2,ixmlo3:ixmhi3,iw) * &
527 ps(igrid)%dx(ix,ixmlo2:ixmhi2,ixmlo3:ixmhi3,1)
531 ps_sub(jgrid)%x(ixmlo2:ixmhi2,ixmlo3:ixmhi3,1:
ndim) = &
532 ps(igrid)%x(ixmlo1,ixmlo2:ixmhi2,ixmlo3:ixmhi3,1:
ndim)
536 ps_sub(jgrid)%w(ixmlo1:ixmhi1,ixmlo3:ixmhi3,1:nw+
nwauxio) = &
537 ps_sub(jgrid)%w(ixmlo1:ixmhi1,ixmlo3:ixmhi3,1:nw+
nwauxio) &
538 + wcc_tmp(ixmlo1:ixmhi1,ix,ixmlo3:ixmhi3,1:nw+
nwauxio) * dx2
543 ps_sub(jgrid)%w(ixmlo1:ixmhi1,ixmlo3:ixmhi3,iw) = &
544 ps_sub(jgrid)%w(ixmlo1:ixmhi1,ixmlo3:ixmhi3,iw) &
545 + wcc_tmp(ixmlo1:ixmhi1,ix,ixmlo3:ixmhi3,iw) * &
546 ps(igrid)%dx(ixmlo1:ixmhi1,ix,ixmlo3:ixmhi3,2)
550 ps_sub(jgrid)%x(ixmlo1:ixmhi1,ixmlo3:ixmhi3,1:
ndim) = &
551 ps(igrid)%x(ixmlo1:ixmhi1,ixmlo2,ixmlo3:ixmhi3,1:
ndim)
555 ps_sub(jgrid)%w(ixmlo1:ixmhi1,ixmlo2:ixmhi2,1:nw+
nwauxio) = &
556 ps_sub(jgrid)%w(ixmlo1:ixmhi1,ixmlo2:ixmhi2,1:nw+
nwauxio) &
557 + wcc_tmp(ixmlo1:ixmhi1,ixmlo2:ixmhi2,ix,1:nw+
nwauxio) * dx3
562 ps_sub(jgrid)%w(ixmlo1:ixmhi1,ixmlo2:ixmhi2,iw) = &
563 ps_sub(jgrid)%w(ixmlo1:ixmhi1,ixmlo2:ixmhi2,iw) &
564 + wcc_tmp(ixmlo1:ixmhi1,ixmlo2:ixmhi2,ix,iw) * &
565 ps(igrid)%dx(ixmlo1:ixmhi1,ixmlo2:ixmhi2,ix,3)
569 ps_sub(jgrid)%x(ixmlo1:ixmhi1,ixmlo2:ixmhi2,1:
ndim) = &
570 ps(igrid)%x(ixmlo1:ixmhi1,ixmlo2:ixmhi2,ixmlo3,1:
ndim)
572 print*,
'subnode, dir: ', dir
573 call mpistop(
"slice direction not clear in collapse_subnode")
581 ps_sub(jgrid)%w(ixmlo2:ixmhi2,1:nw+
nwauxio) = &
582 ps_sub(jgrid)%w(ixmlo2:ixmhi2,1:nw+
nwauxio) &
583 + wcc_tmp(ix,ixmlo2:ixmhi2,1:nw+
nwauxio) * dx1
588 ps_sub(jgrid)%w(ixmlo2:ixmhi2,iw) = &
589 ps_sub(jgrid)%w(ixmlo2:ixmhi2,iw) &
590 + wcc_tmp(ix,ixmlo2:ixmhi2,iw) * &
591 ps(igrid)%dx(ix,ixmlo2:ixmhi2,1)
595 ps_sub(jgrid)%x(ixmlo2:ixmhi2,1:
ndim) = &
596 ps(igrid)%x(ixmlo1,ixmlo2:ixmhi2,1:
ndim)
600 ps_sub(jgrid)%w(ixmlo1:ixmhi1,1:nw+
nwauxio) = &
601 ps_sub(jgrid)%w(ixmlo1:ixmhi1,1:nw+
nwauxio) &
602 + wcc_tmp(ixmlo1:ixmhi1,ix,1:nw+
nwauxio) * dx2
607 ps_sub(jgrid)%w(ixmlo1:ixmhi1,iw) = &
608 ps_sub(jgrid)%w(ixmlo1:ixmhi1,iw) &
609 + wcc_tmp(ixmlo1:ixmhi1,ix,iw) * &
610 ps(igrid)%dx(ixmlo1:ixmhi1,ix,2)
614 ps_sub(jgrid)%x(ixmlo1:ixmhi1,1:
ndim) = &
615 ps(igrid)%x(ixmlo1:ixmhi1,ixmlo2,1:
ndim)
617 call mpistop(
"slice direction not clear in collapse_subnode")
628 ps_sub(jgrid)%w(iw) = ps_sub(jgrid)%w(iw) + wcc_tmp(ix,iw) * ps(igrid)%dx(ix,1)
632 ps_sub(jgrid)%x(1:
ndim) = ps(igrid)%x(ixmlo1,1:
ndim)
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
Collapses D-dimensional output to D-1 view by line-of-sight integration.
subroutine collapse_subnode(igrid, jgrid, dir, normconv)
subroutine output_collapsed_csv(dir, normconv)
subroutine allocate_collapsed(dir)
subroutine put_collapse(dir)
subroutine output_collapsed_vti(dir, normconv)
subroutine write_collapsed
subroutine integrate_subnode(igrid, jgrid, dir)
Module with basic grid data structures.
integer, dimension(:), allocatable, save sfc_to_igrid
Go from a Morton number to an igrid index (for a single processor)
integer, dimension(:), allocatable, save morton_start
First Morton number per processor.
integer, dimension(:), allocatable, save morton_stop
Last Morton number per processor.
type(tree_node_ptr), dimension(:,:), allocatable, save igrid_to_node
Array to go from an [igrid, ipe] index to a node pointer.
This module contains definitions of global parameters and variables and some generic functions/subrou...
integer, parameter unitslice
double precision global_time
The global simulation time.
double precision xprob
minimum and maximum domain boundaries for each dimension
integer, parameter ndim
Number of spatial dimensions for grid variables.
double precision time_convert_factor
Conversion factor for time unit.
integer icomm
The MPI communicator.
integer, dimension(:), allocatable ng
number of grid blocks in domain per dimension, in array over levels
integer mype
The rank of the current MPI task.
logical, dimension(ndim) collapse
If collapse(DIM) is true, generate output integrated over DIM.
integer, dimension(:), allocatable, parameter d
integer ixm
the mesh range (within a block with ghost cells)
integer ierrmpi
A global MPI error return code.
character(len=std_len) collapse_type
logical slab
Cartesian geometry or not.
integer nwauxio
Number of auxiliary variables that are only included in output.
logical, dimension(:), allocatable w_write
double precision, dimension(:,:), allocatable rnode
Corner coordinates.
integer, parameter unitcollapse
double precision, dimension(:,:), allocatable dx
integer nghostcells
Number of ghost cells surrounding a grid.
integer collapselevel
The level at which to produce line-integrated / collapsed output.
logical slab_uniform
uniform Cartesian geometry or not (stretched Cartesian)
character(len=std_len) base_filename
Base file name for simulation output, which will be followed by a number.
This module defines the procedures of a physics module. It contains function pointers for the various...
procedure(sub_convert), pointer phys_to_primitive
Writes D-1 slice, can do so in various formats, depending on slice_type.
subroutine alloc_subnode(jgrid, dir, nwexpand)
subroutine dealloc_subnode(jgrid)
Module with all the methods that users can customize in AMRVAC.
procedure(aux_output), pointer usr_aux_output