Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/bnorml.f90
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,20 @@ end subroutine bnorml

! Complete an odd field under (theta,zeta) -> (-theta,-zeta).
! The theta=0 column maps to itself, without advancing the toroidal row.
! For Nz=1, bnorml evaluates only theta indices 0..(Nt+1)/2 of the single row.
subroutine mirror_normal_field(Nt, Nz, Nzwithsym, field)
implicit none
integer, intent(in) :: Nt, Nz, Nzwithsym
real, intent(inout) :: field(Nt*Nz)
integer :: jj, kk, source, target

if (Nz.eq.1) then
do jj = (Nt+1)/2 + 1, Nt-1
field(1+jj) = -field(1+Nt-jj)
enddo
return
endif

do kk = 1, Nz-Nzwithsym
do jj = 0, Nt-1
source = 1 + jj + kk*Nt
Expand Down
9 changes: 7 additions & 2 deletions tests/virtual_casing_symmetry.f90
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ program test_virtual_casing_symmetry
enddo
enddo
Nzwithsym = min(Nz, (Nz+3)/2)
field = 0.0
field(1:Nt*Nzwithsym) = expected(1:Nt*Nzwithsym)
! Poison every sample that bnorml does not evaluate.
field = huge(1.0)
if (Nz.eq.1) then
field(1:(Nt+1)/2+1) = expected(1:(Nt+1)/2+1)
else
field(1:Nt*Nzwithsym) = expected(1:Nt*Nzwithsym)
endif
call mirror_normal_field(Nt, Nz, Nzwithsym, field)
if (maxval(abs(field-expected)).gt.2.e-14) error stop 'periodic symmetry mismatch'
deallocate(expected, field)
Expand Down
Loading