Skip to content

Commit

Permalink
Revert "output fc_plane"
Browse files Browse the repository at this point in the history
This reverts commit 3994ca8.

We can now use the python tools to output data on a uniform grid (and the field vector
can then be computed from the potential)
  • Loading branch information
Jannis Teunissen committed Jun 3, 2024
1 parent d9e1c38 commit d604579
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 236 deletions.
92 changes: 0 additions & 92 deletions afivo/src/m_af_output.f90
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ end subroutine subr_other_data
public :: af_write_numpy
#if NDIM > 1
public :: af_write_plane
public :: af_write_fc_plane
#endif
public :: af_write_silo
public :: af_write_line
Expand Down Expand Up @@ -550,97 +549,6 @@ subroutine af_write_plane(tree, filename, ivs, r_min, r_max, n_pixels)
end do
close(my_unit)
end subroutine af_write_plane

!> Write data in a plane (2D) to a VTK ASCII file. In 3D, r_min and r_max
!> should have one identical coordinate (i.e., they differ in two
!> coordinates).
subroutine af_write_fc_plane(tree, filename, iv, r_min, r_max, n_pixels)
use m_af_interp, only: af_interp1_fc
type(af_t), intent(in) :: tree !< Tree to write out
character(len=*), intent(in) :: filename !< Filename for the vtk file
integer, intent(in) :: iv !< Variables to write
real(dp), intent(in) :: r_min(NDIM) !< Minimum coordinate of plane
real(dp), intent(in) :: r_max(NDIM) !< Maximum coordinate of plane
integer, intent(in) :: n_pixels(2) !< Number of pixels in the plane

integer, parameter :: my_unit = 100
character(len=100) :: fmt_string
character(len=400) :: fname
integer :: i, j, n_cc, dim_unused, n_points(3)
real(dp) :: r(NDIM), dvec(3)
real(dp) :: v1(NDIM), v2(NDIM)
real(dp), allocatable :: pixel_data(:, :, :)
logical :: success

#if NDIM == 2
n_cc = 2
dvec(1:2) = r_max(1:2) - r_min(1:2)
dvec(3) = 0
dim_unused = 3
n_points = [n_pixels(1), n_pixels(2), 1]
v1 = [dvec(1), 0.0_dp] / (n_pixels(1) - 1)
v2 = [0.0_dp, dvec(2)] / (n_pixels(2) - 1)
#elif NDIM == 3
n_cc = 3
dvec = r_max - r_min
dim_unused = minloc(abs(dvec), 1)

select case (dim_unused)
case (1)
v1 = [0.0_dp, dvec(2), 0.0_dp] / (n_pixels(1) - 1)
v2 = [0.0_dp, 0.0_dp, dvec(3)] / (n_pixels(2) - 1)
n_points = [1, n_pixels(1), n_pixels(2)]
case (2)
v1 = [dvec(1), 0.0_dp, 0.0_dp] / (n_pixels(1) - 1)
v2 = [0.0_dp, 0.0_dp, dvec(3)] / (n_pixels(2) - 1)
n_points = [n_pixels(1), 1, n_pixels(2)]
case (3)
v1 = [dvec(1), 0.0_dp, 0.0_dp] / (n_pixels(1) - 1)
v2 = [0.0_dp, dvec(2), 0.0_dp] / (n_pixels(2) - 1)
n_points = [n_pixels(1), n_pixels(2), 1]
end select
#endif

allocate(pixel_data(n_cc, n_pixels(1), n_pixels(2)))

!$omp parallel do private(i, r)
do j = 1, n_pixels(2)
do i = 1, n_pixels(1)
r = r_min + (i-1) * v1 + (j-1) * v2
pixel_data(:, i, j) = af_interp1_fc(tree, r, iv, success)
if (.not. success) error stop "af_write_fc_plane: interpolation error"
end do
end do
!$omp end parallel do

! Construct format string. Write one row at a time
write(fmt_string, '(A,I0,A)') '(', n_pixels(1), 'E20.8)'

! Construct file name
fname = trim(filename) // ".vtk"

open(my_unit, file=trim(fname), action="write")
write(my_unit, '(A)') "# vtk DataFile Version 2.0"
write(my_unit, '(A)') trim(filename)
write(my_unit, '(A)') "ASCII"
write(my_unit, '(A)') "DATASET STRUCTURED_POINTS"
write(my_unit, '(A,3I10)') "DIMENSIONS ", n_points
#if NDIM == 2
write(my_unit, '(A,3E20.8)') "ORIGIN ", [r_min(1), r_min(2), 0.0_dp]
write(my_unit, '(A,3E20.8)') "SPACING ", &
[v1(1) + v2(1), v1(2) + v2(2), 0.0_dp]
#elif NDIM == 3
write(my_unit, '(A,3E20.8)') "ORIGIN ", r_min
write(my_unit, '(A,3E20.8)') "SPACING ", v1 + v2
#endif
write(my_unit, '(A,2I0)') "POINT_DATA ", product(n_points)
do i = 1, n_cc
write(my_unit, '(A)') "SCALARS "
write(my_unit, '(A)') "LOOKUP_TABLE default"
write(my_unit, trim(fmt_string)) pixel_data(i, :, :)
end do
close(my_unit)
end subroutine af_write_fc_plane
#endif

!> Write the cell centered data of a tree to a vtk unstructured file. Only the
Expand Down
101 changes: 0 additions & 101 deletions programs/comparison_air_2d/standard_outfc.cfg

This file was deleted.

43 changes: 0 additions & 43 deletions src/m_output.f90
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,6 @@ module m_output
! Relative position of plane maximum coordinate
real(dp), public, protected :: plane_rmax(NDIM) = 1.0_dp

! Write uniform output in a plane
logical, public, protected :: fc_plane_write = .false.

! Which variable to include in plane
integer, allocatable, public, protected :: fc_plane_ivar

! Use this many points for plane data
integer, public, protected :: fc_plane_npixels(2) = [64, 64]

! Relative position of plane minimum coordinate
real(dp), public, protected :: fc_plane_rmin(NDIM) = 0.0_dp

! Relative position of plane maximum coordinate
real(dp), public, protected :: fc_plane_rmax(NDIM) = 1.0_dp

! Output electric field maxima and their locations
logical, public, protected :: field_maxima_write = .false.

Expand Down Expand Up @@ -144,7 +129,6 @@ subroutine output_initialize(tree, cfg)
type(af_t), intent(inout) :: tree
type(CFG_t), intent(inout) :: cfg
character(len=name_len), allocatable :: varname(:)
character(len=name_len) :: fc_varname
character(len=af_nlen) :: empty_names(0)
integer :: n, i
character(len=string_len) :: td_file
Expand Down Expand Up @@ -234,8 +218,6 @@ subroutine output_initialize(tree, cfg)

call CFG_add_get(cfg, "plane%write", plane_write, &
"Write uniform output in a plane")
call CFG_add_get(cfg, "fc_plane%write", fc_plane_write, &
"Write uniform fc output in a plane")

if (plane_write) then
call CFG_add(cfg, "plane%varname", ["e"], &
Expand All @@ -259,22 +241,6 @@ subroutine output_initialize(tree, cfg)
"Relative position of plane maximum coordinate")
end if

if (fc_plane_write) then
call CFG_add(cfg, "fc_plane%varname", ["field"], &
"Names of variable to write in a plane", dynamic_size=.true.)
call CFG_get(cfg, "fc_plane%varname", fc_varname)

fc_plane_ivar = af_find_fc_variable(tree, trim(fc_varname))

call CFG_add_get(cfg, "fc_plane%npixels", fc_plane_npixels, &
"Use this many pixels for plane data")
call CFG_add_get(cfg, "fc_plane%rmin", fc_plane_rmin(1:NDIM), &
"Relative position of plane minimum coordinate")
call CFG_add_get(cfg, "fc_plane%rmax", fc_plane_rmax(1:NDIM), &
"Relative position of plane maximum coordinate")
end if


call CFG_add_get(cfg, "field_maxima%write", field_maxima_write, &
"Output electric field maxima and their locations")
call CFG_add_get(cfg, "field_maxima%threshold", field_maxima_threshold, &
Expand Down Expand Up @@ -420,15 +386,6 @@ end subroutine write_sim_data
plane_rmax * ST_domain_len + ST_domain_origin, &
plane_npixels)
end if

if (fc_plane_write) then
write(fname, "(A,I6.6)") trim(output_name) // &
"_fc_plane_", output_cnt
call af_write_fc_plane(tree, fname, fc_plane_ivar, &
fc_plane_rmin * ST_domain_len + ST_domain_origin, &
fc_plane_rmax * ST_domain_len + ST_domain_origin, &
fc_plane_npixels)
end if
#endif

if (lineout_write) then
Expand Down

0 comments on commit d604579

Please sign in to comment.