better to use global grid dimensions
also checking early allocation of Temperature field
This commit is contained in:
parent
3fbf1459d5
commit
1ad537b60c
|
@ -40,7 +40,6 @@ module grid_thermal_spectral
|
|||
! PETSc data
|
||||
SNES :: thermal_snes
|
||||
Vec :: solution_vec
|
||||
PetscInt :: xstart, xend, ystart, yend, zstart, zend
|
||||
real(pReal), dimension(:,:,:), allocatable :: &
|
||||
T_current, & !< field of current temperature
|
||||
T_lastInc, & !< field of previous temperature
|
||||
|
@ -100,6 +99,18 @@ subroutine grid_thermal_spectral_init(T_0)
|
|||
call PetscOptionsInsertString(PETSC_NULL_OPTIONS,num_grid%get_asString('petsc_options',defaultVal=''),err_PETSc)
|
||||
CHKERRQ(err_PETSc)
|
||||
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
! init fields
|
||||
allocate(T_current(grid(1),grid(2),grid3), source=T_0)
|
||||
allocate(T_lastInc(grid(1),grid(2),grid3), source=T_0)
|
||||
allocate(T_stagInc(grid(1),grid(2),grid3), source=T_0)
|
||||
|
||||
ce = 0
|
||||
do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1)
|
||||
ce = ce + 1
|
||||
call homogenization_thermal_setField(T_0,0.0_pReal,ce)
|
||||
end do; end do; end do
|
||||
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
! initialize solver specific parts of PETSc
|
||||
call SNESCreate(PETSC_COMM_WORLD,thermal_snes,err_PETSc); CHKERRQ(err_PETSc)
|
||||
|
@ -127,28 +138,9 @@ subroutine grid_thermal_spectral_init(T_0)
|
|||
call SNESSetFromOptions(thermal_snes,err_PETSc); CHKERRQ(err_PETSc) ! pull it all together with additional CLI arguments
|
||||
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
! init fields
|
||||
call DMDAGetCorners(thermal_grid,xstart,ystart,zstart,xend,yend,zend,err_PETSc)
|
||||
CHKERRQ(err_PETSc)
|
||||
xend = xstart + xend - 1
|
||||
yend = ystart + yend - 1
|
||||
zend = zstart + zend - 1
|
||||
allocate(T_current(grid(1),grid(2),grid3), source=0.0_pReal)
|
||||
allocate(T_lastInc(grid(1),grid(2),grid3), source=0.0_pReal)
|
||||
allocate(T_stagInc(grid(1),grid(2),grid3), source=0.0_pReal)
|
||||
|
||||
ce = 0
|
||||
do k = 1, grid3; do j = 1, grid(2); do i = 1,grid(1)
|
||||
ce = ce + 1
|
||||
T_current(i,j,k) = T_0
|
||||
T_lastInc(i,j,k) = T_current(i,j,k)
|
||||
T_stagInc(i,j,k) = T_current(i,j,k)
|
||||
call homogenization_thermal_setField(T_0,0.0_pReal,ce)
|
||||
end do; end do; end do
|
||||
|
||||
call DMDAVecGetArrayF90(thermal_grid,solution_vec,T_PETSc,err_PETSc)
|
||||
CHKERRQ(err_PETSc)
|
||||
T_PETSc(xstart:xend,ystart:yend,zstart:zend) = T_current
|
||||
T_PETSc = T_current
|
||||
call DMDAVecRestoreArrayF90(thermal_grid,solution_vec,T_PETSc,err_PETSc)
|
||||
CHKERRQ(err_PETSc)
|
||||
|
||||
|
@ -239,7 +231,7 @@ subroutine grid_thermal_spectral_forward(cutBack)
|
|||
CHKERRQ(err_PETSc)
|
||||
call DMDAVecGetArrayF90(dm_local,solution_vec,x_scal,err_PETSc) !< get the data out of PETSc to work with
|
||||
CHKERRQ(err_PETSc)
|
||||
x_scal(xstart:xend,ystart:yend,zstart:zend) = T_current
|
||||
x_scal = T_current
|
||||
call DMDAVecRestoreArrayF90(dm_local,solution_vec,x_scal,err_PETSc)
|
||||
CHKERRQ(err_PETSc)
|
||||
ce = 0
|
||||
|
|
Loading…
Reference in New Issue