Skip to content

Commit

Permalink
add reordering to/from DIR_C
Browse files Browse the repository at this point in the history
  • Loading branch information
Nanoseb committed Jun 24, 2024
1 parent 72ab681 commit de2eba6
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 22 deletions.
48 changes: 47 additions & 1 deletion src/common.f90
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,53 @@ module m_common

contains

integer function get_rdr_from_dirs(dir_from, dir_to) result(rdr_dir)
pure subroutine get_dirs_from_rdr(dir_from, dir_to, rdr_dir)
integer, intent(out) :: dir_from, dir_to
integer, intent(in) :: rdr_dir

select case (rdr_dir)
case (RDR_X2Y)
dir_from = DIR_X
dir_to = DIR_Y
case (RDR_X2Z)
dir_from = DIR_X
dir_to = DIR_Z
case (RDR_Y2X)
dir_from = DIR_Y
dir_to = DIR_X
case (RDR_Y2Z)
dir_from = DIR_Y
dir_to = DIR_Z
case (RDR_Z2X)
dir_from = DIR_Z
dir_to = DIR_X
case (RDR_Z2Y)
dir_from = DIR_Z
dir_to = DIR_Y
case (RDR_C2X)
dir_from = DIR_C
dir_to = DIR_X
case (RDR_C2Y)
dir_from = DIR_C
dir_to = DIR_Y
case (RDR_C2Z)
dir_from = DIR_C
dir_to = DIR_Z
case (RDR_X2C)
dir_from = DIR_X
dir_to = DIR_C
case (RDR_Y2C)
dir_from = DIR_Y
dir_to = DIR_C
case (RDR_Z2C)
dir_from = DIR_Z
dir_to = DIR_C
end select


end subroutine

pure integer function get_rdr_from_dirs(dir_from, dir_to) result(rdr_dir)
!! Returns RDR_?2? value based on two direction inputs
integer, intent(in) :: dir_from, dir_to

Expand Down
31 changes: 10 additions & 21 deletions src/ordering.f90
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module m_ordering

use m_common, only: dp, DIR_X, DIR_Y, DIR_Z, DIR_C, &
use m_common, only: dp, get_dirs_from_rdr, DIR_X, DIR_Y, DIR_Z, DIR_C, &
RDR_X2Y, RDR_X2Z, RDR_Y2X, RDR_Y2Z, RDR_Z2X, RDR_Z2Y

use m_mesh, only: mesh_t
Expand Down Expand Up @@ -33,6 +33,10 @@ pure subroutine get_index_ijk(i, j, k, dir_i, dir_j, dir_k, dir, &
i = mod(dir_k - 1, nx_padded/SZ)*SZ + dir_i
j = 1 + (dir_k - 1)/(nx_padded/SZ)
k = dir_j
case (DIR_C)
i = dir_i
j = dir_j
k = dir_k
end select

end subroutine get_index_ijk
Expand All @@ -58,6 +62,10 @@ pure subroutine get_index_dir(dir_i, dir_j, dir_k, i, j, k, dir, &
dir_i = mod(i - 1, SZ) + 1
dir_j = k
dir_k = (nx_padded/SZ)*(j - 1) + 1 + (i - 1)/SZ
case (DIR_C)
dir_i = i
dir_j = j
dir_k = k
end select

end subroutine get_index_dir
Expand All @@ -74,26 +82,7 @@ pure subroutine get_index_reordering(out_i, out_j, out_k, in_i, in_j, in_k, &
integer :: dir_in, dir_out
integer, dimension(3) :: dims_padded

select case (reorder_dir)
case (RDR_X2Y)
dir_in = DIR_X
dir_out = DIR_Y
case (RDR_X2Z)
dir_in = DIR_X
dir_out = DIR_Z
case (RDR_Y2X)
dir_in = DIR_Y
dir_out = DIR_X
case (RDR_Y2Z)
dir_in = DIR_Y
dir_out = DIR_Z
case (RDR_Z2X)
dir_in = DIR_Z
dir_out = DIR_X
case (RDR_Z2Y)
dir_in = DIR_Z
dir_out = DIR_Y
end select
call get_dirs_from_rdr(dir_in, dir_out, reorder_dir)

dims_padded = mesh%get_padded_dims(DIR_C)
call get_index_ijk(i, j, k, in_i, in_j, in_k, dir_in, mesh%get_sz(), &
Expand Down

0 comments on commit de2eba6

Please sign in to comment.