Skip to content

Commit 92efd68

Browse files
mjrenomjreno
authored andcommitted
rotate mesh x and y coordinates
1 parent 1a23648 commit 92efd68

File tree

2 files changed

+69
-20
lines changed

2 files changed

+69
-20
lines changed

src/Utilities/Export/DisNCMesh.f90

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -457,12 +457,13 @@ end subroutine define_dim
457457
!> @brief netcdf export add mesh information
458458
!<
459459
subroutine add_mesh_data(this)
460+
use BaseDisModule, only: dis_transform_xy
460461
class(Mesh2dDisExportType), intent(inout) :: this
461462
integer(I4B) :: cnt, maxvert, m
462463
integer(I4B), dimension(:), allocatable :: verts
463464
real(DP), dimension(:), allocatable :: bnds
464465
integer(I4B) :: i, j
465-
real(DP) :: x, y
466+
real(DP) :: x, y, x_transform, y_transform
466467
real(DP), dimension(:), allocatable :: node_x, node_y
467468
real(DP), dimension(:), allocatable :: cell_x, cell_y
468469

@@ -485,13 +486,18 @@ subroutine add_mesh_data(this)
485486
cnt = 0
486487
node_x = NF90_FILL_DOUBLE
487488
node_y = NF90_FILL_DOUBLE
488-
y = this%dis%yorigin + sum(this%dis%delc)
489+
y = sum(this%dis%delc)
489490
do j = this%dis%nrow, 0, -1
490-
x = this%dis%xorigin
491+
x = 0
491492
do i = this%dis%ncol, 0, -1
492493
cnt = cnt + 1
493-
node_x(cnt) = x
494-
node_y(cnt) = y
494+
call dis_transform_xy(x, y, &
495+
this%dis%xorigin, &
496+
this%dis%yorigin, &
497+
this%dis%angrot, &
498+
x_transform, y_transform)
499+
node_x(cnt) = x_transform
500+
node_y(cnt) = y_transform
495501
if (i > 0) x = x + this%dis%delr(i)
496502
end do
497503
if (j > 0) y = y - this%dis%delc(j)
@@ -508,11 +514,16 @@ subroutine add_mesh_data(this)
508514
cell_x = NF90_FILL_DOUBLE
509515
cell_y = NF90_FILL_DOUBLE
510516
do j = 1, this%dis%nrow
511-
y = this%dis%celly(j) + this%dis%yorigin
517+
y = this%dis%celly(j)
512518
do i = 1, this%dis%ncol
513-
x = this%dis%cellx(i) + this%dis%xorigin
514-
cell_x(cnt) = x
515-
cell_y(cnt) = y
519+
x = this%dis%cellx(i)
520+
call dis_transform_xy(x, y, &
521+
this%dis%xorigin, &
522+
this%dis%yorigin, &
523+
this%dis%angrot, &
524+
x_transform, y_transform)
525+
cell_x(cnt) = x_transform
526+
cell_y(cnt) = y_transform
516527
cnt = cnt + 1
517528
end do
518529
end do

src/Utilities/Export/DisvNCMesh.f90

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ end subroutine define_dim
434434
!> @brief netcdf export add mesh information
435435
!<
436436
subroutine add_mesh_data(this)
437+
use BaseDisModule, only: dis_transform_xy
437438
class(Mesh2dDisvExportType), intent(inout) :: this
438439
integer(I4B), dimension(:), contiguous, pointer :: icell2d => null()
439440
integer(I4B), dimension(:), contiguous, pointer :: ncvert => null()
@@ -442,6 +443,11 @@ subroutine add_mesh_data(this)
442443
real(DP), dimension(:), contiguous, pointer :: cell_y => null()
443444
real(DP), dimension(:), contiguous, pointer :: vert_x => null()
444445
real(DP), dimension(:), contiguous, pointer :: vert_y => null()
446+
real(DP), dimension(:), contiguous, pointer :: cell_xt => null()
447+
real(DP), dimension(:), contiguous, pointer :: cell_yt => null()
448+
real(DP), dimension(:), contiguous, pointer :: vert_xt => null()
449+
real(DP), dimension(:), contiguous, pointer :: vert_yt => null()
450+
real(DP) :: x_transform, y_transform
445451
integer(I4B) :: n, m, idx, cnt, iv, maxvert
446452
integer(I4B), dimension(:), allocatable :: verts
447453
real(DP), dimension(:), allocatable :: bnds
@@ -456,28 +462,56 @@ subroutine add_mesh_data(this)
456462
call mem_setptr(vert_x, 'XV', this%dis_mempath)
457463
call mem_setptr(vert_y, 'YV', this%dis_mempath)
458464

459-
! initialize max vertices required to define cell
460-
maxvert = maxval(ncvert)
465+
! allocate x, y transform arrays
466+
allocate (cell_xt(size(cell_x)))
467+
allocate (cell_yt(size(cell_y)))
468+
allocate (vert_xt(size(vert_x)))
469+
allocate (vert_yt(size(vert_y)))
461470

462471
! set mesh container variable value to 1
463472
call nf_verify(nf90_put_var(this%ncid, this%var_ids%mesh, 1), &
464473
this%nc_fname)
465474

466-
! allocate temporary arrays
467-
allocate (verts(maxvert))
468-
allocate (bnds(maxvert))
475+
! transform vert x and y
476+
do n = 1, size(vert_x)
477+
call dis_transform_xy(vert_x(n), vert_y(n), &
478+
this%disv%xorigin, &
479+
this%disv%yorigin, &
480+
this%disv%angrot, &
481+
x_transform, y_transform)
482+
vert_xt(n) = x_transform
483+
vert_yt(n) = y_transform
484+
end do
485+
486+
! transform cell x and y
487+
do n = 1, size(cell_x)
488+
call dis_transform_xy(cell_x(n), cell_y(n), &
489+
this%disv%xorigin, &
490+
this%disv%yorigin, &
491+
this%disv%angrot, &
492+
x_transform, y_transform)
493+
cell_xt(n) = x_transform
494+
cell_yt(n) = y_transform
495+
end do
469496

470497
! write node_x and node_y arrays to netcdf file
471498
call nf_verify(nf90_put_var(this%ncid, this%var_ids%mesh_node_x, &
472-
vert_x + this%disv%xorigin), this%nc_fname)
499+
vert_xt), this%nc_fname)
473500
call nf_verify(nf90_put_var(this%ncid, this%var_ids%mesh_node_y, &
474-
vert_y + this%disv%yorigin), this%nc_fname)
501+
vert_yt), this%nc_fname)
475502

476503
! write face_x and face_y arrays to netcdf file
477504
call nf_verify(nf90_put_var(this%ncid, this%var_ids%mesh_face_x, &
478-
cell_x + this%disv%xorigin), this%nc_fname)
505+
cell_xt), this%nc_fname)
479506
call nf_verify(nf90_put_var(this%ncid, this%var_ids%mesh_face_y, &
480-
cell_y + this%disv%yorigin), this%nc_fname)
507+
cell_yt), this%nc_fname)
508+
509+
! initialize max vertices required to define cell
510+
maxvert = maxval(ncvert)
511+
512+
! allocate temporary arrays
513+
allocate (verts(maxvert))
514+
allocate (bnds(maxvert))
481515

482516
! set face nodes array
483517
cnt = 0
@@ -502,7 +536,7 @@ subroutine add_mesh_data(this)
502536
bnds = NF90_FILL_DOUBLE
503537
do m = 1, size(bnds)
504538
if (verts(m) /= NF90_FILL_INT) then
505-
bnds(m) = vert_y(verts(m))
539+
bnds(m) = vert_yt(verts(m))
506540
end if
507541
! write face y bounds array to netcdf file
508542
call nf_verify(nf90_put_var(this%ncid, this%var_ids%mesh_face_ybnds, &
@@ -515,7 +549,7 @@ subroutine add_mesh_data(this)
515549
bnds = NF90_FILL_DOUBLE
516550
do m = 1, size(bnds)
517551
if (verts(m) /= NF90_FILL_INT) then
518-
bnds(m) = vert_x(verts(m))
552+
bnds(m) = vert_xt(verts(m))
519553
end if
520554
! write face x bounds array to netcdf file
521555
call nf_verify(nf90_put_var(this%ncid, this%var_ids%mesh_face_xbnds, &
@@ -528,6 +562,10 @@ subroutine add_mesh_data(this)
528562
! cleanup
529563
deallocate (bnds)
530564
deallocate (verts)
565+
deallocate (cell_xt)
566+
deallocate (cell_yt)
567+
deallocate (vert_xt)
568+
deallocate (vert_yt)
531569
end subroutine add_mesh_data
532570

533571
!> @brief netcdf export 1D integer array

0 commit comments

Comments
 (0)