@@ -223,7 +223,7 @@ subroutine create_operator(self, n)
223
223
integer :: ierr
224
224
225
225
call MatCreateShell(PETSC_COMM_WORLD, n, n, PETSC_DETERMINE, &
226
- PETSC_DETERMINE, self% ctx, self% Amat, ierr)
226
+ PETSC_DETERMINE, self% ctx, self% Amat, ierr)
227
227
call MatShellSetContext(self% Amat, self% ctx, ierr) ! Is this necessary?
228
228
call MatShellSetOperation(self% Amat, MATOP_MULT, poissmult_petsc, ierr)
229
229
call MatSetUp(self% Amat, ierr)
@@ -297,62 +297,11 @@ subroutine create_preconditioner(self, mesh, n)
297
297
coeffs(7 ) = 1 / dz** 2
298
298
cols(6 ) = cols(1 ) - (dims(1 ) + 2 ) * (dims(2 ) + 2 )
299
299
cols(7 ) = cols(1 ) + (dims(1 ) + 2 ) * (dims(2 ) + 2 )
300
-
301
- ! coeffs = 0
302
- ! cols = -1 ! Set null (simplifies BCs)
303
- ! cols(1) = row
304
-
305
- ! ! d2pdx2
306
- ! coeffs(1) = coeffs(1) - 2 / dx**2
307
- ! coeffs(2) = 1 / dx**2
308
- ! coeffs(3) = 1 / dx**2
309
- ! if (i > 1) then
310
- ! cols(2) = cols(1) - 1
311
- ! else
312
- ! cols(2) = cols(1) + (dims(1) - i)
313
- ! end if
314
- ! if (i < dims(1)) then
315
- ! cols(3) = cols(1) + 1
316
- ! else
317
- ! cols(3) = cols(1) - (dims(1) - 1)
318
- ! end if
319
-
320
- ! ! d2pdy2
321
- ! coeffs(1) = coeffs(1) - 2 / dy**2
322
- ! coeffs(4) = 1 / dy**2
323
- ! coeffs(5) = 1 / dy**2
324
- ! if (j > 1) then
325
- ! cols(4) = cols(1) - dims(1)
326
- ! else
327
- ! cols(4) = cols(1) + (dims(2) - j) * dims(1)
328
- ! end if
329
- ! if (j < dims(2)) then
330
- ! cols(5) = cols(1) + dims(1)
331
- ! else
332
- ! cols(5) = cols(1) - (dims(2) - 1) * dims(1)
333
- ! end if
334
-
335
- ! ! d2pdz2
336
- ! coeffs(1) = coeffs(1) - 2 / dz**2
337
- ! coeffs(6) = 1 / dz**2
338
- ! coeffs(7) = 1 / dz**2
339
- ! if (k > 1) then
340
- ! cols(6) = cols(1) - dims(2) * dims(1)
341
- ! else
342
- ! cols(6) = cols(1) + (dims(3) - k) * dims(2) * dims(1)
343
- ! end if
344
- ! if (k < dims(3)) then
345
- ! cols(7) = cols(1) + dims(2) * dims(1)
346
- ! else
347
- ! cols(7) = cols(1) - (dims(3) - 1) * dims(2) * dims(1)
348
- ! end if
349
300
350
301
! Push to matrix
351
302
! Recall Fortran (1-based) -> C (0-based) indexing
352
303
call MatSetValuesLocal(self% Pmat, 1 , row - 1 , nnb + 1 , cols - 1 , coeffs, &
353
- INSERT_VALUES, ierr)
354
- ! call MatSetValues(self%Pmat, 1, row - 1, nnb + 1, cols - 1, coeffs, &
355
- ! INSERT_VALUES, ierr)
304
+ INSERT_VALUES, ierr)
356
305
357
306
! Advance row counter
358
307
row = row + 1
@@ -480,17 +429,21 @@ subroutine build_neighbour_index_map(idx, mesh, global_start)
480
429
nproc = mesh% par% nproc
481
430
tag = mesh% par% nrank * max (nproc, 6 )
482
431
do d = 1 , 3
483
- ! Recv left and right
432
+ ! ! Recv left and right
433
+ ! Right Recv
484
434
nbtag = mesh% par% pnext(d) * max (nproc, 6 )
485
435
call MPI_IRecv(info(:, 2 , d), 4 , MPI_INTEGER, mesh% par% pnext(d), nbtag + 2 * (d - 1 ) + 1 , &
486
436
MPI_COMM_WORLD, requests(4 * (d - 1 ) + 1 ), ierr)
437
+ ! Left Recv
487
438
nbtag = mesh% par% pprev(d) * max (nproc, 6 )
488
439
call MPI_IRecv(info(:, 1 , d), 4 , MPI_INTEGER, mesh% par% pprev(d), nbtag + 2 * (d - 1 ) + 2 , &
489
440
MPI_COMM_WORLD, requests(4 * (d - 1 ) + 2 ), ierr)
490
441
491
- ! Send left and right
442
+ ! ! Send left and right
443
+ ! Left Send
492
444
call MPI_ISend(myinfo, 4 , MPI_INTEGER, mesh% par% pprev(d), tag + 2 * (d - 1 ) + 1 , &
493
445
MPI_COMM_WORLD, requests(4 * (d - 1 ) + 3 ), ierr)
446
+ ! Right Send
494
447
call MPI_ISend(myinfo, 4 , MPI_INTEGER, mesh% par% pnext(d), tag + 2 * (d - 1 ) + 2 , &
495
448
MPI_COMM_WORLD, requests(4 * (d - 1 ) + 4 ), ierr)
496
449
end do
@@ -521,7 +474,7 @@ subroutine build_neighbour_index_map(idx, mesh, global_start)
521
474
end associate
522
475
523
476
! ! Y halos
524
- ! Left halo
477
+ ! Bottom halo
525
478
associate(offset_down = > info(1 , 1 , 2 ), &
526
479
nx_down = > info(2 , 1 , 2 ), ny_down = > info(3 , 1 , 2 ), nz_down = > info(4 , 1 , 2 ))
527
480
ctr = offset_down + (ny_down - 1 ) * nx_down ! Global starting index -> yend
@@ -534,7 +487,7 @@ subroutine build_neighbour_index_map(idx, mesh, global_start)
534
487
ctr = ctr + (nx_down * ny_down) ! Step in k
535
488
end do
536
489
end associate
537
- ! Right halo
490
+ ! Top halo
538
491
associate(offset_up = > info(1 , 2 , 2 ), &
539
492
nx_up = > info(2 , 2 , 2 ), ny_up = > info(3 , 2 , 2 ), nz_up = > info(4 , 2 , 2 ))
540
493
ctr = offset_up ! Global starting index == ystart
@@ -549,7 +502,7 @@ subroutine build_neighbour_index_map(idx, mesh, global_start)
549
502
end associate
550
503
551
504
! ! Z halos
552
- ! Left halo
505
+ ! Back halo
553
506
associate(offset_back = > info(1 , 1 , 3 ), &
554
507
nx_back = > info(2 , 1 , 3 ), ny_back = > info(3 , 1 , 3 ), nz_back = > info(4 , 1 , 3 ))
555
508
ctr = offset_back + ny_back * nx_back ! Global starting index -> zend
@@ -560,7 +513,7 @@ subroutine build_neighbour_index_map(idx, mesh, global_start)
560
513
end do
561
514
end do
562
515
end associate
563
- ! Right halo
516
+ ! Front halo
564
517
associate(offset_front = > info(1 , 2 , 3 ), &
565
518
nx_front = > info(2 , 2 , 3 ), ny_front = > info(3 , 2 , 3 ), nz_front = > info(4 , 2 , 3 ))
566
519
ctr = offset_front ! Global startin index == zstart
@@ -657,6 +610,8 @@ subroutine poissmult_petsc(M, x, f, ierr)
657
610
658
611
type (mat_ctx_t) :: ctx
659
612
613
+ ierr = 0 ;
614
+
660
615
! XXX: Fixme
661
616
! call MatShellGetContext(M, ctx, ierr)
662
617
! print *, ctx%foo
0 commit comments