source: CIVL/examples/mpi-omp/AMG2013/parcsr_ls/par_laplace_27pt.c

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 52.9 KB
Line 
1/*BHEADER**********************************************************************
2 * Copyright (c) 2008, Lawrence Livermore National Security, LLC.
3 * Produced at the Lawrence Livermore National Laboratory.
4 * This file is part of HYPRE. See file COPYRIGHT for details.
5 *
6 * HYPRE is free software; you can redistribute it and/or modify it under the
7 * terms of the GNU Lesser General Public License (as published by the Free
8 * Software Foundation) version 2.1 dated February 1999.
9 *
10 * $Revision: 2.4 $
11 ***********************************************************************EHEADER*/
12
13
14
15
16#include "headers.h"
17
18/*--------------------------------------------------------------------------
19 * hypre_GenerateLaplacian27pt
20 *--------------------------------------------------------------------------*/
21
22HYPRE_ParCSRMatrix
23GenerateLaplacian27pt(MPI_Comm comm,
24 HYPRE_BigInt nx,
25 HYPRE_BigInt ny,
26 HYPRE_BigInt nz,
27 int P,
28 int Q,
29 int R,
30 int p,
31 int q,
32 int r,
33 double *value,
34 HYPRE_ParVector *rhs_ptr,
35 HYPRE_ParVector *x_ptr)
36{
37 hypre_ParCSRMatrix *A;
38 hypre_CSRMatrix *diag;
39 hypre_CSRMatrix *offd;
40 hypre_ParVector *par_rhs;
41 hypre_ParVector *par_x;
42 hypre_Vector *rhs;
43 hypre_Vector *x;
44 double *rhs_data;
45 double *x_data;
46
47 int *diag_i;
48 int *diag_j;
49 double *diag_data;
50
51 int *offd_i;
52 int *offd_j = NULL;
53 double *offd_data = NULL;
54
55 HYPRE_BigInt *global_part;
56 HYPRE_BigInt *global_part_rhs;
57 HYPRE_BigInt *global_part_x;
58 int ix, iy, iz;
59 int cnt, o_cnt;
60 int local_num_rows;
61 HYPRE_BigInt *col_map_offd;
62 HYPRE_BigInt *work;
63 int row_index;
64 int i;
65 int ip, iq, ir;
66
67 int nx_local, ny_local, nz_local;
68 int num_cols_offd;
69 int nxy;
70 HYPRE_BigInt grid_size;
71
72 HYPRE_BigInt *nx_part;
73 HYPRE_BigInt *ny_part;
74 HYPRE_BigInt *nz_part;
75
76 int num_procs, my_id;
77 int P_busy, Q_busy, R_busy;
78
79#ifdef HYPRE_NO_GLOBAL_PARTITION
80 MPI_Comm_size(comm,&num_procs);
81 MPI_Comm_rank(comm,&my_id);
82
83 hypre_GenerateLocalPartitioning(nx,P,p,&nx_part);
84 hypre_GenerateLocalPartitioning(ny,Q,q,&ny_part);
85 hypre_GenerateLocalPartitioning(nz,R,r,&nz_part);
86
87 nx_local = (int)(nx_part[1] - nx_part[0]);
88 ny_local = (int)(ny_part[1] - ny_part[0]);
89 nz_local = (int)(nz_part[1] - nz_part[0]);
90
91 local_num_rows = nx_local*ny_local*nz_local;
92
93 global_part = hypre_CTAlloc(HYPRE_BigInt,2);
94 global_part_rhs = hypre_CTAlloc(HYPRE_BigInt,2);
95 global_part_x = hypre_CTAlloc(HYPRE_BigInt,2);
96
97 global_part[0] = (HYPRE_BigInt)my_id*(HYPRE_BigInt)local_num_rows;
98 global_part[1] = global_part[0]+(HYPRE_BigInt)local_num_rows;
99 global_part_rhs[0] = global_part[0];
100 global_part_rhs[1] = global_part[1];
101 global_part_x[0] = global_part[0];
102 global_part_x[1] = global_part[1];
103
104 ip = p;
105 iq = q;
106 ir = r;
107#else
108 int nx_size, ny_size, nz_size;
109 MPI_Comm_size(comm,&num_procs);
110 MPI_Comm_rank(comm,&my_id);
111
112 hypre_GeneratePartitioning(nx,P,&nx_part);
113 hypre_GeneratePartitioning(ny,Q,&ny_part);
114 hypre_GeneratePartitioning(nz,R,&nz_part);
115
116 global_part = hypre_CTAlloc(HYPRE_BigInt,P*Q*R+1);
117 global_part_rhs = hypre_CTAlloc(HYPRE_BigInt,P*Q*R+1);
118 global_part_x = hypre_CTAlloc(HYPRE_BigInt,P*Q*R+1);
119
120 global_part[0] = 0;
121 global_part_rhs[0] = 0;
122 global_part_x[0] = 0;
123 cnt = 1;
124 for (iz = 0; iz < R; iz++)
125 {
126 nz_size = (int)(nz_part[iz+1]-nz_part[iz]);
127 for (iy = 0; iy < Q; iy++)
128 {
129 ny_size = (int)(ny_part[iy+1]-ny_part[iy]);
130 for (ix = 0; ix < P; ix++)
131 {
132 nx_size = (int)(nx_part[ix+1] - nx_part[ix]);
133 global_part[cnt] = global_part[cnt-1];
134 global_part[cnt] += (HYPRE_BigInt)(nx_size*ny_size*nz_size);
135 global_part_rhs[cnt] = global_part[cnt];
136 global_part_x[cnt] = global_part[cnt];
137 cnt++;
138 }
139 }
140 }
141
142 nx_local = (int)(nx_part[p+1] - nx_part[p]);
143 ny_local = (int)(ny_part[q+1] - ny_part[q]);
144 nz_local = (int)(nz_part[r+1] - nz_part[r]);
145
146 local_num_rows = nx_local*ny_local*nz_local;
147
148 ip = p;
149 iq = q;
150 ir = r;
151
152#endif
153
154 grid_size = nx*ny*nz;
155
156 diag_i = hypre_CTAlloc(int, local_num_rows+1);
157 offd_i = hypre_CTAlloc(int, local_num_rows+1);
158 rhs_data = hypre_CTAlloc(double, local_num_rows);
159 x_data = hypre_CTAlloc(double, local_num_rows);
160
161 for (i=0; i < local_num_rows; i++)
162 {
163 rhs_data[i] = 1.0;
164 x_data[i] = 0.0;
165 }
166
167 P_busy = hypre_min(nx,P);
168 Q_busy = hypre_min(ny,Q);
169 R_busy = hypre_min(nz,R);
170
171 num_cols_offd = 0;
172 if (p) num_cols_offd += ny_local*nz_local;
173 if (p < P_busy-1) num_cols_offd += ny_local*nz_local;
174 if (q) num_cols_offd += nx_local*nz_local;
175 if (q < Q_busy-1) num_cols_offd += nx_local*nz_local;
176 if (r) num_cols_offd += nx_local*ny_local;
177 if (r < R_busy-1) num_cols_offd += nx_local*ny_local;
178 if (p && q) num_cols_offd += nz_local;
179 if (p && q < Q_busy-1 ) num_cols_offd += nz_local;
180 if (p < P_busy-1 && q ) num_cols_offd += nz_local;
181 if (p < P_busy-1 && q < Q_busy-1 ) num_cols_offd += nz_local;
182 if (p && r) num_cols_offd += ny_local;
183 if (p && r < R_busy-1 ) num_cols_offd += ny_local;
184 if (p < P_busy-1 && r ) num_cols_offd += ny_local;
185 if (p < P_busy-1 && r < R_busy-1 ) num_cols_offd += ny_local;
186 if (q && r) num_cols_offd += nx_local;
187 if (q && r < R_busy-1 ) num_cols_offd += nx_local;
188 if (q < Q_busy-1 && r ) num_cols_offd += nx_local;
189 if (q < Q_busy-1 && r < R_busy-1 ) num_cols_offd += nx_local;
190 if (p && q && r) num_cols_offd++;
191 if (p && q && r < R_busy-1) num_cols_offd++;
192 if (p && q < Q_busy-1 && r) num_cols_offd++;
193 if (p && q < Q_busy-1 && r < R_busy-1) num_cols_offd++;
194 if (p < P_busy-1 && q && r) num_cols_offd++;
195 if (p < P_busy-1 && q && r < R_busy-1 ) num_cols_offd++;
196 if (p < P_busy-1 && q < Q_busy-1 && r ) num_cols_offd++;
197 if (p < P_busy-1 && q < Q_busy-1 && r < R_busy-1) num_cols_offd++;
198
199 if (!local_num_rows) num_cols_offd = 0;
200
201 col_map_offd = hypre_CTAlloc(HYPRE_BigInt, num_cols_offd);
202
203 cnt = 0;
204 o_cnt = 0;
205 diag_i[0] = 0;
206 offd_i[0] = 0;
207 for (iz = 0; iz < nz_local; iz++)
208 {
209 for (iy = 0; iy < ny_local; iy++)
210 {
211 for (ix = 0; ix < nx_local; ix++)
212 {
213 cnt++;
214 o_cnt++;
215 diag_i[cnt] = diag_i[cnt-1];
216 offd_i[o_cnt] = offd_i[o_cnt-1];
217 diag_i[cnt]++;
218 if (iz > 0)
219 {
220 diag_i[cnt]++;
221 if (iy > 0)
222 {
223 diag_i[cnt]++;
224 if (ix > 0)
225 {
226 diag_i[cnt]++;
227 }
228 else
229 {
230 if (ip)
231 offd_i[o_cnt]++;
232 }
233 if (ix < nx_local-1)
234 {
235 diag_i[cnt]++;
236 }
237 else
238 {
239 if (ip+1 < P)
240 offd_i[o_cnt]++;
241 }
242 }
243 else
244 {
245 if (iq)
246 {
247 offd_i[o_cnt]++;
248 if (ix > 0)
249 {
250 offd_i[o_cnt]++;
251 }
252 else if (ip)
253 {
254 offd_i[o_cnt]++;
255 }
256 if (ix < nx_local-1)
257 {
258 offd_i[o_cnt]++;
259 }
260 else if (ip < P-1)
261 {
262 offd_i[o_cnt]++;
263 }
264 }
265 }
266 if (ix > 0)
267 diag_i[cnt]++;
268 else
269 {
270 if (ip)
271 {
272 offd_i[o_cnt]++;
273 }
274 }
275 if (ix+1 < nx_local)
276 diag_i[cnt]++;
277 else
278 {
279 if (ip+1 < P)
280 {
281 offd_i[o_cnt]++;
282 }
283 }
284 if (iy+1 < ny_local)
285 {
286 diag_i[cnt]++;
287 if (ix > 0)
288 {
289 diag_i[cnt]++;
290 }
291 else
292 {
293 if (ip)
294 offd_i[o_cnt]++;
295 }
296 if (ix < nx_local-1)
297 {
298 diag_i[cnt]++;
299 }
300 else
301 {
302 if (ip+1 < P)
303 offd_i[o_cnt]++;
304 }
305 }
306 else
307 {
308 if (iq+1 < Q)
309 {
310 offd_i[o_cnt]++;
311 if (ix > 0)
312 {
313 offd_i[o_cnt]++;
314 }
315 else if (ip)
316 {
317 offd_i[o_cnt]++;
318 }
319 if (ix < nx_local-1)
320 {
321 offd_i[o_cnt]++;
322 }
323 else if (ip < P-1)
324 {
325 offd_i[o_cnt]++;
326 }
327 }
328 }
329 }
330 else
331 {
332 if (ir)
333 {
334 offd_i[o_cnt]++;
335 if (iy > 0)
336 {
337 offd_i[o_cnt]++;
338 if (ix > 0)
339 {
340 offd_i[o_cnt]++;
341 }
342 else
343 {
344 if (ip)
345 offd_i[o_cnt]++;
346 }
347 if (ix < nx_local-1)
348 {
349 offd_i[o_cnt]++;
350 }
351 else
352 {
353 if (ip+1 < P)
354 offd_i[o_cnt]++;
355 }
356 }
357 else
358 {
359 if (iq)
360 {
361 offd_i[o_cnt]++;
362 if (ix > 0)
363 {
364 offd_i[o_cnt]++;
365 }
366 else if (ip)
367 {
368 offd_i[o_cnt]++;
369 }
370 if (ix < nx_local-1)
371 {
372 offd_i[o_cnt]++;
373 }
374 else if (ip < P-1)
375 {
376 offd_i[o_cnt]++;
377 }
378 }
379 }
380 if (ix > 0)
381 offd_i[o_cnt]++;
382 else
383 {
384 if (ip)
385 {
386 offd_i[o_cnt]++;
387 }
388 }
389 if (ix+1 < nx_local)
390 offd_i[o_cnt]++;
391 else
392 {
393 if (ip+1 < P)
394 {
395 offd_i[o_cnt]++;
396 }
397 }
398 if (iy+1 < ny_local)
399 {
400 offd_i[o_cnt]++;
401 if (ix > 0)
402 {
403 offd_i[o_cnt]++;
404 }
405 else
406 {
407 if (ip)
408 offd_i[o_cnt]++;
409 }
410 if (ix < nx_local-1)
411 {
412 offd_i[o_cnt]++;
413 }
414 else
415 {
416 if (ip+1 < P)
417 offd_i[o_cnt]++;
418 }
419 }
420 else
421 {
422 if (iq+1 < Q)
423 {
424 offd_i[o_cnt]++;
425 if (ix > 0)
426 {
427 offd_i[o_cnt]++;
428 }
429 else if (ip)
430 {
431 offd_i[o_cnt]++;
432 }
433 if (ix < nx_local-1)
434 {
435 offd_i[o_cnt]++;
436 }
437 else if (ip < P-1)
438 {
439 offd_i[o_cnt]++;
440 }
441 }
442 }
443 }
444 }
445 if (iy > 0)
446 {
447 diag_i[cnt]++;
448 if (ix > 0)
449 {
450 diag_i[cnt]++;
451 }
452 else
453 {
454 if (ip)
455 offd_i[o_cnt]++;
456 }
457 if (ix < nx_local-1)
458 {
459 diag_i[cnt]++;
460 }
461 else
462 {
463 if (ip+1 < P)
464 offd_i[o_cnt]++;
465 }
466 }
467 else
468 {
469 if (iq)
470 {
471 offd_i[o_cnt]++;
472 if (ix > 0)
473 {
474 offd_i[o_cnt]++;
475 }
476 else if (ip)
477 {
478 offd_i[o_cnt]++;
479 }
480 if (ix < nx_local-1)
481 {
482 offd_i[o_cnt]++;
483 }
484 else if (ip < P-1)
485 {
486 offd_i[o_cnt]++;
487 }
488 }
489 }
490 if (ix > 0)
491 diag_i[cnt]++;
492 else
493 {
494 if (ip)
495 {
496 offd_i[o_cnt]++;
497 }
498 }
499 if (ix+1 < nx_local)
500 diag_i[cnt]++;
501 else
502 {
503 if (ip+1 < P)
504 {
505 offd_i[o_cnt]++;
506 }
507 }
508 if (iy+1 < ny_local)
509 {
510 diag_i[cnt]++;
511 if (ix > 0)
512 {
513 diag_i[cnt]++;
514 }
515 else
516 {
517 if (ip)
518 offd_i[o_cnt]++;
519 }
520 if (ix < nx_local-1)
521 {
522 diag_i[cnt]++;
523 }
524 else
525 {
526 if (ip+1 < P)
527 offd_i[o_cnt]++;
528 }
529 }
530 else
531 {
532 if (iq+1 < Q)
533 {
534 offd_i[o_cnt]++;
535 if (ix > 0)
536 {
537 offd_i[o_cnt]++;
538 }
539 else if (ip)
540 {
541 offd_i[o_cnt]++;
542 }
543 if (ix < nx_local-1)
544 {
545 offd_i[o_cnt]++;
546 }
547 else if (ip < P-1)
548 {
549 offd_i[o_cnt]++;
550 }
551 }
552 }
553 if (iz+1 < nz_local)
554 {
555 diag_i[cnt]++;
556 if (iy > 0)
557 {
558 diag_i[cnt]++;
559 if (ix > 0)
560 {
561 diag_i[cnt]++;
562 }
563 else
564 {
565 if (ip)
566 offd_i[o_cnt]++;
567 }
568 if (ix < nx_local-1)
569 {
570 diag_i[cnt]++;
571 }
572 else
573 {
574 if (ip+1 < P)
575 offd_i[o_cnt]++;
576 }
577 }
578 else
579 {
580 if (iq)
581 {
582 offd_i[o_cnt]++;
583 if (ix > 0)
584 {
585 offd_i[o_cnt]++;
586 }
587 else if (ip)
588 {
589 offd_i[o_cnt]++;
590 }
591 if (ix < nx_local-1)
592 {
593 offd_i[o_cnt]++;
594 }
595 else if (ip < P-1)
596 {
597 offd_i[o_cnt]++;
598 }
599 }
600 }
601 if (ix > 0)
602 diag_i[cnt]++;
603 else
604 {
605 if (ip)
606 {
607 offd_i[o_cnt]++;
608 }
609 }
610 if (ix+1 < nx_local)
611 diag_i[cnt]++;
612 else
613 {
614 if (ip+1 < P)
615 {
616 offd_i[o_cnt]++;
617 }
618 }
619 if (iy+1 < ny_local)
620 {
621 diag_i[cnt]++;
622 if (ix > 0)
623 {
624 diag_i[cnt]++;
625 }
626 else
627 {
628 if (ip)
629 offd_i[o_cnt]++;
630 }
631 if (ix < nx_local-1)
632 {
633 diag_i[cnt]++;
634 }
635 else
636 {
637 if (ip+1 < P)
638 offd_i[o_cnt]++;
639 }
640 }
641 else
642 {
643 if (iq+1 < Q)
644 {
645 offd_i[o_cnt]++;
646 if (ix > 0)
647 {
648 offd_i[o_cnt]++;
649 }
650 else if (ip)
651 {
652 offd_i[o_cnt]++;
653 }
654 if (ix < nx_local-1)
655 {
656 offd_i[o_cnt]++;
657 }
658 else if (ip < P-1)
659 {
660 offd_i[o_cnt]++;
661 }
662 }
663 }
664 }
665 else
666 {
667 if (ir+1 < R)
668 {
669 offd_i[o_cnt]++;
670 if (iy > 0)
671 {
672 offd_i[o_cnt]++;
673 if (ix > 0)
674 {
675 offd_i[o_cnt]++;
676 }
677 else
678 {
679 if (ip)
680 offd_i[o_cnt]++;
681 }
682 if (ix < nx_local-1)
683 {
684 offd_i[o_cnt]++;
685 }
686 else
687 {
688 if (ip+1 < P)
689 offd_i[o_cnt]++;
690 }
691 }
692 else
693 {
694 if (iq)
695 {
696 offd_i[o_cnt]++;
697 if (ix > 0)
698 {
699 offd_i[o_cnt]++;
700 }
701 else if (ip)
702 {
703 offd_i[o_cnt]++;
704 }
705 if (ix < nx_local-1)
706 {
707 offd_i[o_cnt]++;
708 }
709 else if (ip < P-1)
710 {
711 offd_i[o_cnt]++;
712 }
713 }
714 }
715 if (ix > 0)
716 offd_i[o_cnt]++;
717 else
718 {
719 if (ip)
720 {
721 offd_i[o_cnt]++;
722 }
723 }
724 if (ix+1 < nx_local)
725 offd_i[o_cnt]++;
726 else
727 {
728 if (ip+1 < P)
729 {
730 offd_i[o_cnt]++;
731 }
732 }
733 if (iy+1 < ny_local)
734 {
735 offd_i[o_cnt]++;
736 if (ix > 0)
737 {
738 offd_i[o_cnt]++;
739 }
740 else
741 {
742 if (ip)
743 offd_i[o_cnt]++;
744 }
745 if (ix < nx_local-1)
746 {
747 offd_i[o_cnt]++;
748 }
749 else
750 {
751 if (ip+1 < P)
752 offd_i[o_cnt]++;
753 }
754 }
755 else
756 {
757 if (iq+1 < Q)
758 {
759 offd_i[o_cnt]++;
760 if (ix > 0)
761 {
762 offd_i[o_cnt]++;
763 }
764 else if (ip)
765 {
766 offd_i[o_cnt]++;
767 }
768 if (ix < nx_local-1)
769 {
770 offd_i[o_cnt]++;
771 }
772 else if (ip < P-1)
773 {
774 offd_i[o_cnt]++;
775 }
776 }
777 }
778 }
779 }
780 }
781 }
782 }
783
784 diag_j = hypre_CTAlloc(int, diag_i[local_num_rows]);
785 diag_data = hypre_CTAlloc(double, diag_i[local_num_rows]);
786
787 if (num_procs > 1)
788 {
789 work = hypre_CTAlloc(HYPRE_BigInt, offd_i[local_num_rows]);
790 offd_j = hypre_CTAlloc(int, offd_i[local_num_rows]);
791 offd_data = hypre_CTAlloc(double, offd_i[local_num_rows]);
792 }
793
794 nxy = nx_local*ny_local;
795 row_index = 0;
796 cnt = 0;
797 o_cnt = 0;
798 for (iz = 0; iz < nz_local; iz++)
799 {
800 for (iy = 0; iy < ny_local; iy++)
801 {
802 for (ix = 0; ix < nx_local; ix++)
803 {
804 diag_j[cnt] = row_index;
805 diag_data[cnt++] = value[0];
806 if (iz > 0)
807 {
808 if (iy > 0)
809 {
810 if (ix > 0)
811 {
812 diag_j[cnt] = row_index-nxy-nx_local-1;
813 diag_data[cnt++] = value[1];
814 }
815 else
816 {
817 if (ip)
818 {
819 hypre_map(ix-1,iy-1,iz-1,p-1,q,r,P,Q,R,
820 nx_part,ny_part,nz_part,global_part,
821 &work[o_cnt]);
822 offd_data[o_cnt++] = value[1];
823 }
824 }
825 diag_j[cnt] = row_index-nxy-nx_local;
826 diag_data[cnt++] = value[1];
827 if (ix < nx_local-1)
828 {
829 diag_j[cnt] = row_index-nxy-nx_local+1;
830 diag_data[cnt++] = value[1];
831 }
832 else
833 {
834 if (ip+1 < P)
835 {
836 hypre_map(ix+1,iy-1,iz-1,p+1,q,r,P,Q,R,
837 nx_part,ny_part,nz_part,global_part,
838 &work[o_cnt]);
839 offd_data[o_cnt++] = value[1];
840 }
841 }
842 }
843 else
844 {
845 if (iq)
846 {
847 if (ix > 0)
848 {
849 hypre_map(ix-1,iy-1,iz-1,p,q-1,r,P,Q,R,
850 nx_part,ny_part,nz_part,global_part,
851 &work[o_cnt]);
852 offd_data[o_cnt++] = value[1];
853 }
854 else if (ip)
855 {
856 hypre_map(ix-1,iy-1,iz-1,p-1,q-1,r,P,Q,R,
857 nx_part,ny_part,nz_part,global_part,
858 &work[o_cnt]);
859 offd_data[o_cnt++] = value[1];
860 }
861 hypre_map(ix,iy-1,iz-1,p,q-1,r,P,Q,R,
862 nx_part,ny_part,nz_part,global_part,
863 &work[o_cnt]);
864 offd_data[o_cnt++] = value[1];
865 if (ix < nx_local-1)
866 {
867 hypre_map(ix+1,iy-1,iz-1,p,q-1,r,P,Q,R,
868 nx_part,ny_part,nz_part,global_part,
869 &work[o_cnt]);
870 offd_data[o_cnt++] = value[1];
871 }
872 else if (ip < P-1)
873 {
874 hypre_map(ix+1,iy-1,iz-1,p+1,q-1,r,P,Q,R,
875 nx_part,ny_part,nz_part,global_part,
876 &work[o_cnt]);
877 offd_data[o_cnt++] = value[1];
878 }
879 }
880 }
881 if (ix > 0)
882 {
883 diag_j[cnt] = row_index-nxy-1;
884 diag_data[cnt++] = value[1];
885 }
886 else
887 {
888 if (ip)
889 {
890 hypre_map(ix-1,iy,iz-1,p-1,q,r,P,Q,R,
891 nx_part,ny_part,nz_part,global_part,
892 &work[o_cnt]);
893 offd_data[o_cnt++] = value[1];
894 }
895 }
896 diag_j[cnt] = row_index-nxy;
897 diag_data[cnt++] = value[1];
898 if (ix+1 < nx_local)
899 {
900 diag_j[cnt] = row_index-nxy+1;
901 diag_data[cnt++] = value[1];
902 }
903 else
904 {
905 if (ip+1 < P)
906 {
907 hypre_map(ix+1,iy,iz-1,p+1,q,r,P,Q,R,
908 nx_part,ny_part,nz_part,global_part,
909 &work[o_cnt]);
910 offd_data[o_cnt++] = value[1];
911 }
912 }
913 if (iy+1 < ny_local)
914 {
915 if (ix > 0)
916 {
917 diag_j[cnt] = row_index-nxy+nx_local-1;
918 diag_data[cnt++] = value[1];
919 }
920 else
921 {
922 if (ip)
923 {
924 hypre_map(ix-1,iy+1,iz-1,p-1,q,r,P,Q,R,
925 nx_part,ny_part,nz_part,global_part,
926 &work[o_cnt]);
927 offd_data[o_cnt++] = value[1];
928 }
929 }
930 diag_j[cnt] = row_index-nxy+nx_local;
931 diag_data[cnt++] = value[1];
932 if (ix < nx_local-1)
933 {
934 diag_j[cnt] = row_index-nxy+nx_local+1;
935 diag_data[cnt++] = value[1];
936 }
937 else
938 {
939 if (ip+1 < P)
940 {
941 hypre_map(ix+1,iy+1,iz-1,p+1,q,r,P,Q,R,
942 nx_part,ny_part,nz_part,global_part,
943 &work[o_cnt]);
944 offd_data[o_cnt++] = value[1];
945 }
946 }
947 }
948 else
949 {
950 if (iq+1 < Q)
951 {
952 if (ix > 0)
953 {
954 hypre_map(ix-1,iy+1,iz-1,p,q+1,r,P,Q,R,
955 nx_part,ny_part,nz_part,global_part,
956 &work[o_cnt]);
957 offd_data[o_cnt++] = value[1];
958 }
959 else if (ip)
960 {
961 hypre_map(ix-1,iy+1,iz-1,p-1,q+1,r,P,Q,R,
962 nx_part,ny_part,nz_part,global_part,
963 &work[o_cnt]);
964 offd_data[o_cnt++] = value[1];
965 }
966 hypre_map(ix,iy+1,iz-1,p,q+1,r,P,Q,R,
967 nx_part,ny_part,nz_part,global_part,
968 &work[o_cnt]);
969 offd_data[o_cnt++] = value[1];
970 if (ix < nx_local-1)
971 {
972 hypre_map(ix+1,iy+1,iz-1,p,q+1,r,P,Q,R,
973 nx_part,ny_part,nz_part,global_part,
974 &work[o_cnt]);
975 offd_data[o_cnt++] = value[1];
976 }
977 else if (ip < P-1)
978 {
979 hypre_map(ix+1,iy+1,iz-1,p+1,q+1,r,P,Q,R,
980 nx_part,ny_part,nz_part,global_part,
981 &work[o_cnt]);
982 offd_data[o_cnt++] = value[1];
983 }
984 }
985 }
986 }
987 else
988 {
989 if (ir)
990 {
991 if (iy > 0)
992 {
993 if (ix > 0)
994 {
995 hypre_map(ix-1,iy-1,iz-1,p,q,r-1,P,Q,R,
996 nx_part,ny_part,nz_part,global_part,
997 &work[o_cnt]);
998 offd_data[o_cnt++] = value[1];
999 }
1000 else
1001 {
1002 if (ip)
1003 {
1004 hypre_map(ix-1,iy-1,iz-1,p-1,q,r-1,P,Q,R,
1005 nx_part,ny_part,nz_part,global_part,
1006 &work[o_cnt]);
1007 offd_data[o_cnt++] = value[1];
1008 }
1009 }
1010 hypre_map(ix,iy-1,iz-1,p,q,r-1,P,Q,R,
1011 nx_part,ny_part,nz_part,global_part,
1012 &work[o_cnt]);
1013 offd_data[o_cnt++] = value[1];
1014 if (ix < nx_local-1)
1015 {
1016 hypre_map(ix+1,iy-1,iz-1,p,q,r-1,P,Q,R,
1017 nx_part,ny_part,nz_part,global_part,
1018 &work[o_cnt]);
1019 offd_data[o_cnt++] = value[1];
1020 }
1021 else
1022 {
1023 if (ip+1 < P)
1024 {
1025 hypre_map(ix+1,iy-1,iz-1,p+1,q,r-1,P,Q,R,
1026 nx_part,ny_part,nz_part,global_part,
1027 &work[o_cnt]);
1028 offd_data[o_cnt++] = value[1];
1029 }
1030 }
1031 }
1032 else
1033 {
1034 if (iq)
1035 {
1036 if (ix > 0)
1037 {
1038 hypre_map(ix-1,iy-1,iz-1,p,q-1,r-1,P,Q,R,
1039 nx_part,ny_part,nz_part,global_part,
1040 &work[o_cnt]);
1041 offd_data[o_cnt++] = value[1];
1042 }
1043 else if (ip)
1044 {
1045 hypre_map(ix-1,iy-1,iz-1,p-1,q-1,r-1,P,Q,R,
1046 nx_part,ny_part,nz_part,global_part,
1047 &work[o_cnt]);
1048 offd_data[o_cnt++] = value[1];
1049 }
1050 hypre_map(ix,iy-1,iz-1,p,q-1,r-1,P,Q,R,
1051 nx_part,ny_part,nz_part,global_part,
1052 &work[o_cnt]);
1053 offd_data[o_cnt++] = value[1];
1054 if (ix < nx_local-1)
1055 {
1056 hypre_map(ix+1,iy-1,iz-1,p,q-1,r-1,P,Q,R,
1057 nx_part,ny_part,nz_part,global_part,
1058 &work[o_cnt]);
1059 offd_data[o_cnt++] = value[1];
1060 }
1061 else if (ip < P-1)
1062 {
1063 hypre_map(ix+1,iy-1,iz-1,p+1,q-1,r-1,P,Q,R,
1064 nx_part,ny_part,nz_part,global_part,
1065 &work[o_cnt]);
1066 offd_data[o_cnt++] = value[1];
1067 }
1068 }
1069 }
1070 if (ix > 0)
1071 {
1072 hypre_map(ix-1,iy,iz-1,p,q,r-1,P,Q,R,
1073 nx_part,ny_part,nz_part,global_part,
1074 &work[o_cnt]);
1075 offd_data[o_cnt++] = value[1];
1076 }
1077 else
1078 {
1079 if (ip)
1080 {
1081 hypre_map(ix-1,iy,iz-1,p-1,q,r-1,P,Q,R,
1082 nx_part,ny_part,nz_part,global_part,
1083 &work[o_cnt]);
1084 offd_data[o_cnt++] = value[1];
1085 }
1086 }
1087 hypre_map(ix,iy,iz-1,p,q,r-1,P,Q,R,
1088 nx_part,ny_part,nz_part,global_part,
1089 &work[o_cnt]);
1090 offd_data[o_cnt++] = value[1];
1091 if (ix+1 < nx_local)
1092 {
1093 hypre_map(ix+1,iy,iz-1,p,q,r-1,P,Q,R,
1094 nx_part,ny_part,nz_part,global_part,
1095 &work[o_cnt]);
1096 offd_data[o_cnt++] = value[1];
1097 }
1098 else
1099 {
1100 if (ip+1 < P)
1101 {
1102 hypre_map(ix+1,iy,iz-1,p+1,q,r-1,P,Q,R,
1103 nx_part,ny_part,nz_part,global_part,
1104 &work[o_cnt]);
1105 offd_data[o_cnt++] = value[1];
1106 }
1107 }
1108 if (iy+1 < ny_local)
1109 {
1110 if (ix > 0)
1111 {
1112 hypre_map(ix-1,iy+1,iz-1,p,q,r-1,P,Q,R,
1113 nx_part,ny_part,nz_part,global_part,
1114 &work[o_cnt]);
1115 offd_data[o_cnt++] = value[1];
1116 }
1117 else
1118 {
1119 if (ip)
1120 {
1121 hypre_map(ix-1,iy+1,iz-1,p-1,q,r-1,P,Q,R,
1122 nx_part,ny_part,nz_part,global_part,
1123 &work[o_cnt]);
1124 offd_data[o_cnt++] = value[1];
1125 }
1126 }
1127 hypre_map(ix,iy+1,iz-1,p,q,r-1,P,Q,R,
1128 nx_part,ny_part,nz_part,global_part,
1129 &work[o_cnt]);
1130 offd_data[o_cnt++] = value[1];
1131 if (ix < nx_local-1)
1132 {
1133 hypre_map(ix+1,iy+1,iz-1,p,q,r-1,P,Q,R,
1134 nx_part,ny_part,nz_part,global_part,
1135 &work[o_cnt]);
1136 offd_data[o_cnt++] = value[1];
1137 }
1138 else
1139 {
1140 if (ip+1 < P)
1141 {
1142 hypre_map(ix+1,iy+1,iz-1,p+1,q,r-1,P,Q,R,
1143 nx_part,ny_part,nz_part,global_part,
1144 &work[o_cnt]);
1145 offd_data[o_cnt++] = value[1];
1146 }
1147 }
1148 }
1149 else
1150 {
1151 if (iq+1 < Q)
1152 {
1153 if (ix > 0)
1154 {
1155 hypre_map(ix-1,iy+1,iz-1,p,q+1,r-1,P,Q,R,
1156 nx_part,ny_part,nz_part,global_part,
1157 &work[o_cnt]);
1158 offd_data[o_cnt++] = value[1];
1159 }
1160 else if (ip)
1161 {
1162 hypre_map(ix-1,iy+1,iz-1,p-1,q+1,r-1,P,Q,R,
1163 nx_part,ny_part,nz_part,global_part,
1164 &work[o_cnt]);
1165 offd_data[o_cnt++] = value[1];
1166 }
1167 hypre_map(ix,iy+1,iz-1,p,q+1,r-1,P,Q,R,
1168 nx_part,ny_part,nz_part,global_part,
1169 &work[o_cnt]);
1170 offd_data[o_cnt++] = value[1];
1171 if (ix < nx_local-1)
1172 {
1173 hypre_map(ix+1,iy+1,iz-1,p,q+1,r-1,P,Q,R,
1174 nx_part,ny_part,nz_part,global_part,
1175 &work[o_cnt]);
1176 offd_data[o_cnt++] = value[1];
1177 }
1178 else if (ip < P-1)
1179 {
1180 hypre_map(ix+1,iy+1,iz-1,p+1,q+1,r-1,P,Q,R,
1181 nx_part,ny_part,nz_part,global_part,
1182 &work[o_cnt]);
1183 offd_data[o_cnt++] = value[1];
1184 }
1185 }
1186 }
1187 }
1188 }
1189 if (iy > 0)
1190 {
1191 if (ix > 0)
1192 {
1193 diag_j[cnt] = row_index-nx_local-1;
1194 diag_data[cnt++] = value[1];
1195 }
1196 else
1197 {
1198 if (ip)
1199 {
1200 hypre_map(ix-1,iy-1,iz,p-1,q,r,P,Q,R,
1201 nx_part,ny_part,nz_part,global_part,
1202 &work[o_cnt]);
1203 offd_data[o_cnt++] = value[1];
1204 }
1205 }
1206 diag_j[cnt] = row_index-nx_local;
1207 diag_data[cnt++] = value[1];
1208 if (ix < nx_local-1)
1209 {
1210 diag_j[cnt] = row_index-nx_local+1;
1211 diag_data[cnt++] = value[1];
1212 }
1213 else
1214 {
1215 if (ip+1 < P)
1216 {
1217 hypre_map(ix+1,iy-1,iz,p+1,q,r,P,Q,R,
1218 nx_part,ny_part,nz_part,global_part,
1219 &work[o_cnt]);
1220 offd_data[o_cnt++] = value[1];
1221 }
1222 }
1223 }
1224 else
1225 {
1226 if (iq)
1227 {
1228 if (ix > 0)
1229 {
1230 hypre_map(ix-1,iy-1,iz,p,q-1,r,P,Q,R,
1231 nx_part,ny_part,nz_part,global_part,
1232 &work[o_cnt]);
1233 offd_data[o_cnt++] = value[1];
1234 }
1235 else if (ip)
1236 {
1237 hypre_map(ix-1,iy-1,iz,p-1,q-1,r,P,Q,R,
1238 nx_part,ny_part,nz_part,global_part,
1239 &work[o_cnt]);
1240 offd_data[o_cnt++] = value[1];
1241 }
1242 hypre_map(ix,iy-1,iz,p,q-1,r,P,Q,R,
1243 nx_part,ny_part,nz_part,global_part,
1244 &work[o_cnt]);
1245 offd_data[o_cnt++] = value[1];
1246 if (ix < nx_local-1)
1247 {
1248 hypre_map(ix+1,iy-1,iz,p,q-1,r,P,Q,R,
1249 nx_part,ny_part,nz_part,global_part,
1250 &work[o_cnt]);
1251 offd_data[o_cnt++] = value[1];
1252 }
1253 else if (ip < P-1)
1254 {
1255 hypre_map(ix+1,iy-1,iz,p+1,q-1,r,P,Q,R,
1256 nx_part,ny_part,nz_part,global_part,
1257 &work[o_cnt]);
1258 offd_data[o_cnt++] = value[1];
1259 }
1260 }
1261 }
1262 if (ix > 0)
1263 {
1264 diag_j[cnt] = row_index-1;
1265 diag_data[cnt++] = value[1];
1266 }
1267 else
1268 {
1269 if (ip)
1270 {
1271 hypre_map(ix-1,iy,iz,p-1,q,r,P,Q,R,
1272 nx_part,ny_part,nz_part,global_part,
1273 &work[o_cnt]);
1274 offd_data[o_cnt++] = value[1];
1275 }
1276 }
1277 if (ix+1 < nx_local)
1278 {
1279 diag_j[cnt] = row_index+1;
1280 diag_data[cnt++] = value[1];
1281 }
1282 else
1283 {
1284 if (ip+1 < P)
1285 {
1286 hypre_map(ix+1,iy,iz,p+1,q,r,P,Q,R,
1287 nx_part,ny_part,nz_part,global_part,
1288 &work[o_cnt]);
1289 offd_data[o_cnt++] = value[1];
1290 }
1291 }
1292 if (iy+1 < ny_local)
1293 {
1294 if (ix > 0)
1295 {
1296 diag_j[cnt] = row_index+nx_local-1;
1297 diag_data[cnt++] = value[1];
1298 }
1299 else
1300 {
1301 if (ip)
1302 {
1303 hypre_map(ix-1,iy+1,iz,p-1,q,r,P,Q,R,
1304 nx_part,ny_part,nz_part,global_part,
1305 &work[o_cnt]);
1306 offd_data[o_cnt++] = value[1];
1307 }
1308 }
1309 diag_j[cnt] = row_index+nx_local;
1310 diag_data[cnt++] = value[1];
1311 if (ix < nx_local-1)
1312 {
1313 diag_j[cnt] = row_index+nx_local+1;
1314 diag_data[cnt++] = value[1];
1315 }
1316 else
1317 {
1318 if (ip+1 < P)
1319 {
1320 hypre_map(ix+1,iy+1,iz,p+1,q,r,P,Q,R,
1321 nx_part,ny_part,nz_part,global_part,
1322 &work[o_cnt]);
1323 offd_data[o_cnt++] = value[1];
1324 }
1325 }
1326 }
1327 else
1328 {
1329 if (iq+1 < Q)
1330 {
1331 if (ix > 0)
1332 {
1333 hypre_map(ix-1,iy+1,iz,p,q+1,r,P,Q,R,
1334 nx_part,ny_part,nz_part,global_part,
1335 &work[o_cnt]);
1336 offd_data[o_cnt++] = value[1];
1337 }
1338 else if (ip)
1339 {
1340 hypre_map(ix-1,iy+1,iz,p-1,q+1,r,P,Q,R,
1341 nx_part,ny_part,nz_part,global_part,
1342 &work[o_cnt]);
1343 offd_data[o_cnt++] = value[1];
1344 }
1345 hypre_map(ix,iy+1,iz,p,q+1,r,P,Q,R,
1346 nx_part,ny_part,nz_part,global_part,
1347 &work[o_cnt]);
1348 offd_data[o_cnt++] = value[1];
1349 if (ix < nx_local-1)
1350 {
1351 hypre_map(ix+1,iy+1,iz,p,q+1,r,P,Q,R,
1352 nx_part,ny_part,nz_part,global_part,
1353 &work[o_cnt]);
1354 offd_data[o_cnt++] = value[1];
1355 }
1356 else if (ip < P-1)
1357 {
1358 hypre_map(ix+1,iy+1,iz,p+1,q+1,r,P,Q,R,
1359 nx_part,ny_part,nz_part,global_part,
1360 &work[o_cnt]);
1361 offd_data[o_cnt++] = value[1];
1362 }
1363 }
1364 }
1365 if (iz+1 < nz_local)
1366 {
1367 if (iy > 0)
1368 {
1369 if (ix > 0)
1370 {
1371 diag_j[cnt] = row_index+nxy-nx_local-1;
1372 diag_data[cnt++] = value[1];
1373 }
1374 else
1375 {
1376 if (ip)
1377 {
1378 hypre_map(ix-1,iy-1,iz+1,p-1,q,r,P,Q,R,
1379 nx_part,ny_part,nz_part,global_part,
1380 &work[o_cnt]);
1381 offd_data[o_cnt++] = value[1];
1382 }
1383 }
1384 diag_j[cnt] = row_index+nxy-nx_local;
1385 diag_data[cnt++] = value[1];
1386 if (ix < nx_local-1)
1387 {
1388 diag_j[cnt] = row_index+nxy-nx_local+1;
1389 diag_data[cnt++] = value[1];
1390 }
1391 else
1392 {
1393 if (ip+1 < P)
1394 {
1395 hypre_map(ix+1,iy-1,iz+1,p+1,q,r,P,Q,R,
1396 nx_part,ny_part,nz_part,global_part,
1397 &work[o_cnt]);
1398 offd_data[o_cnt++] = value[1];
1399 }
1400 }
1401 }
1402 else
1403 {
1404 if (iq)
1405 {
1406 if (ix > 0)
1407 {
1408 hypre_map(ix-1,iy-1,iz+1,p,q-1,r,P,Q,R,
1409 nx_part,ny_part,nz_part,global_part,
1410 &work[o_cnt]);
1411 offd_data[o_cnt++] = value[1];
1412 }
1413 else if (ip)
1414 {
1415 hypre_map(ix-1,iy-1,iz+1,p-1,q-1,r,P,Q,R,
1416 nx_part,ny_part,nz_part,global_part,
1417 &work[o_cnt]);
1418 offd_data[o_cnt++] = value[1];
1419 }
1420 hypre_map(ix,iy-1,iz+1,p,q-1,r,P,Q,R,
1421 nx_part,ny_part,nz_part,global_part,
1422 &work[o_cnt]);
1423 offd_data[o_cnt++] = value[1];
1424 if (ix < nx_local-1)
1425 {
1426 hypre_map(ix+1,iy-1,iz+1,p,q-1,r,P,Q,R,
1427 nx_part,ny_part,nz_part,global_part,
1428 &work[o_cnt]);
1429 offd_data[o_cnt++] = value[1];
1430 }
1431 else if (ip < P-1)
1432 {
1433 hypre_map(ix+1,iy-1,iz+1,p+1,q-1,r,P,Q,R,
1434 nx_part,ny_part,nz_part,global_part,
1435 &work[o_cnt]);
1436 offd_data[o_cnt++] = value[1];
1437 }
1438 }
1439 }
1440 if (ix > 0)
1441 {
1442 diag_j[cnt] = row_index+nxy-1;
1443 diag_data[cnt++] = value[1];
1444 }
1445 else
1446 {
1447 if (ip)
1448 {
1449 hypre_map(ix-1,iy,iz+1,p-1,q,r,P,Q,R,
1450 nx_part,ny_part,nz_part,global_part,
1451 &work[o_cnt]);
1452 offd_data[o_cnt++] = value[1];
1453 }
1454 }
1455 diag_j[cnt] = row_index+nxy;
1456 diag_data[cnt++] = value[1];
1457 if (ix+1 < nx_local)
1458 {
1459 diag_j[cnt] = row_index+nxy+1;
1460 diag_data[cnt++] = value[1];
1461 }
1462 else
1463 {
1464 if (ip+1 < P)
1465 {
1466 hypre_map(ix+1,iy,iz+1,p+1,q,r,P,Q,R,
1467 nx_part,ny_part,nz_part,global_part,
1468 &work[o_cnt]);
1469 offd_data[o_cnt++] = value[1];
1470 }
1471 }
1472 if (iy+1 < ny_local)
1473 {
1474 if (ix > 0)
1475 {
1476 diag_j[cnt] = row_index+nxy+nx_local-1;
1477 diag_data[cnt++] = value[1];
1478 }
1479 else
1480 {
1481 if (ip)
1482 {
1483 hypre_map(ix-1,iy+1,iz+1,p-1,q,r,P,Q,R,
1484 nx_part,ny_part,nz_part,global_part,
1485 &work[o_cnt]);
1486 offd_data[o_cnt++] = value[1];
1487 }
1488 }
1489 diag_j[cnt] = row_index+nxy+nx_local;
1490 diag_data[cnt++] = value[1];
1491 if (ix < nx_local-1)
1492 {
1493 diag_j[cnt] = row_index+nxy+nx_local+1;
1494 diag_data[cnt++] = value[1];
1495 }
1496 else
1497 {
1498 if (ip+1 < P)
1499 {
1500 hypre_map(ix+1,iy+1,iz+1,p+1,q,r,P,Q,R,
1501 nx_part,ny_part,nz_part,global_part,
1502 &work[o_cnt]);
1503 offd_data[o_cnt++] = value[1];
1504 }
1505 }
1506 }
1507 else
1508 {
1509 if (iq+1 < Q)
1510 {
1511 if (ix > 0)
1512 {
1513 hypre_map(ix-1,iy+1,iz+1,p,q+1,r,P,Q,R,
1514 nx_part,ny_part,nz_part,global_part,
1515 &work[o_cnt]);
1516 offd_data[o_cnt++] = value[1];
1517 }
1518 else if (ip)
1519 {
1520 hypre_map(ix-1,iy+1,iz+1,p-1,q+1,r,P,Q,R,
1521 nx_part,ny_part,nz_part,global_part,
1522 &work[o_cnt]);
1523 offd_data[o_cnt++] = value[1];
1524 }
1525 hypre_map(ix,iy+1,iz+1,p,q+1,r,P,Q,R,
1526 nx_part,ny_part,nz_part,global_part,
1527 &work[o_cnt]);
1528 offd_data[o_cnt++] = value[1];
1529 if (ix < nx_local-1)
1530 {
1531 hypre_map(ix+1,iy+1,iz+1,p,q+1,r,P,Q,R,
1532 nx_part,ny_part,nz_part,global_part,
1533 &work[o_cnt]);
1534 offd_data[o_cnt++] = value[1];
1535 }
1536 else if (ip < P-1)
1537 {
1538 hypre_map(ix+1,iy+1,iz+1,p+1,q+1,r,P,Q,R,
1539 nx_part,ny_part,nz_part,global_part,
1540 &work[o_cnt]);
1541 offd_data[o_cnt++] = value[1];
1542 }
1543 }
1544 }
1545 }
1546 else
1547 {
1548 if (ir+1 < R)
1549 {
1550 if (iy > 0)
1551 {
1552 if (ix > 0)
1553 {
1554 hypre_map(ix-1,iy-1,iz+1,p,q,r+1,P,Q,R,
1555 nx_part,ny_part,nz_part,global_part,
1556 &work[o_cnt]);
1557 offd_data[o_cnt++] = value[1];
1558 }
1559 else
1560 {
1561 if (ip)
1562 {
1563 hypre_map(ix-1,iy-1,iz+1,p-1,q,r+1,P,Q,R,
1564 nx_part,ny_part,nz_part,global_part,
1565 &work[o_cnt]);
1566 offd_data[o_cnt++] = value[1];
1567 }
1568 }
1569 hypre_map(ix,iy-1,iz+1,p,q,r+1,P,Q,R,
1570 nx_part,ny_part,nz_part,global_part,
1571 &work[o_cnt]);
1572 offd_data[o_cnt++] = value[1];
1573 if (ix < nx_local-1)
1574 {
1575 hypre_map(ix+1,iy-1,iz+1,p,q,r+1,P,Q,R,
1576 nx_part,ny_part,nz_part,global_part,
1577 &work[o_cnt]);
1578 offd_data[o_cnt++] = value[1];
1579 }
1580 else
1581 {
1582 if (ip+1 < P)
1583 {
1584 hypre_map(ix+1,iy-1,iz+1,p+1,q,r+1,P,Q,R,
1585 nx_part,ny_part,nz_part,global_part,
1586 &work[o_cnt]);
1587 offd_data[o_cnt++] = value[1];
1588 }
1589 }
1590 }
1591 else
1592 {
1593 if (iq)
1594 {
1595 if (ix > 0)
1596 {
1597 hypre_map(ix-1,iy-1,iz+1,p,q-1,r+1,P,Q,R,
1598 nx_part,ny_part,nz_part,global_part,
1599 &work[o_cnt]);
1600 offd_data[o_cnt++] = value[1];
1601 }
1602 else if (ip)
1603 {
1604 hypre_map(ix-1,iy-1,iz+1,p-1,q-1,r+1,P,Q,R,
1605 nx_part,ny_part,nz_part,global_part,
1606 &work[o_cnt]);
1607 offd_data[o_cnt++] = value[1];
1608 }
1609 hypre_map(ix,iy-1,iz+1,p,q-1,r+1,P,Q,R,
1610 nx_part,ny_part,nz_part,global_part,
1611 &work[o_cnt]);
1612 offd_data[o_cnt++] = value[1];
1613 if (ix < nx_local-1)
1614 {
1615 hypre_map(ix+1,iy-1,iz+1,p,q-1,r+1,P,Q,R,
1616 nx_part,ny_part,nz_part,global_part,
1617 &work[o_cnt]);
1618 offd_data[o_cnt++] = value[1];
1619 }
1620 else if (ip < P-1)
1621 {
1622 hypre_map(ix+1,iy-1,iz+1,p+1,q-1,r+1,P,Q,R,
1623 nx_part,ny_part,nz_part,global_part,
1624 &work[o_cnt]);
1625 offd_data[o_cnt++] = value[1];
1626 }
1627 }
1628 }
1629 if (ix > 0)
1630 {
1631 hypre_map(ix-1,iy,iz+1,p,q,r+1,P,Q,R,
1632 nx_part,ny_part,nz_part,global_part,
1633 &work[o_cnt]);
1634 offd_data[o_cnt++] = value[1];
1635 }
1636 else
1637 {
1638 if (ip)
1639 {
1640 hypre_map(ix-1,iy,iz+1,p-1,q,r+1,P,Q,R,
1641 nx_part,ny_part,nz_part,global_part,
1642 &work[o_cnt]);
1643 offd_data[o_cnt++] = value[1];
1644 }
1645 }
1646 hypre_map(ix,iy,iz+1,p,q,r+1,P,Q,R,
1647 nx_part,ny_part,nz_part,global_part,
1648 &work[o_cnt]);
1649 offd_data[o_cnt++] = value[1];
1650 if (ix+1 < nx_local)
1651 {
1652 hypre_map(ix+1,iy,iz+1,p,q,r+1,P,Q,R,
1653 nx_part,ny_part,nz_part,global_part,
1654 &work[o_cnt]);
1655 offd_data[o_cnt++] = value[1];
1656 }
1657 else
1658 {
1659 if (ip+1 < P)
1660 {
1661 hypre_map(ix+1,iy,iz+1,p+1,q,r+1,P,Q,R,
1662 nx_part,ny_part,nz_part,global_part,
1663 &work[o_cnt]);
1664 offd_data[o_cnt++] = value[1];
1665 }
1666 }
1667 if (iy+1 < ny_local)
1668 {
1669 if (ix > 0)
1670 {
1671 hypre_map(ix-1,iy+1,iz+1,p,q,r+1,P,Q,R,
1672 nx_part,ny_part,nz_part,global_part,
1673 &work[o_cnt]);
1674 offd_data[o_cnt++] = value[1];
1675 }
1676 else
1677 {
1678 if (ip)
1679 {
1680 hypre_map(ix-1,iy+1,iz+1,p-1,q,r+1,P,Q,R,
1681 nx_part,ny_part,nz_part,global_part,
1682 &work[o_cnt]);
1683 offd_data[o_cnt++] = value[1];
1684 }
1685 }
1686 hypre_map(ix,iy+1,iz+1,p,q,r+1,P,Q,R,
1687 nx_part,ny_part,nz_part,global_part,
1688 &work[o_cnt]);
1689 offd_data[o_cnt++] = value[1];
1690 if (ix < nx_local-1)
1691 {
1692 hypre_map(ix+1,iy+1,iz+1,p,q,r+1,P,Q,R,
1693 nx_part,ny_part,nz_part,global_part,
1694 &work[o_cnt]);
1695 offd_data[o_cnt++] = value[1];
1696 }
1697 else
1698 {
1699 if (ip+1 < P)
1700 {
1701 hypre_map(ix+1,iy+1,iz+1,p+1,q,r+1,P,Q,R,
1702 nx_part,ny_part,nz_part,global_part,
1703 &work[o_cnt]);
1704 offd_data[o_cnt++] = value[1];
1705 }
1706 }
1707 }
1708 else
1709 {
1710 if (iq+1 < Q)
1711 {
1712 if (ix > 0)
1713 {
1714 hypre_map(ix-1,iy+1,iz+1,p,q+1,r+1,P,Q,R,
1715 nx_part,ny_part,nz_part,global_part,
1716 &work[o_cnt]);
1717 offd_data[o_cnt++] = value[1];
1718 }
1719 else if (ip)
1720 {
1721 hypre_map(ix-1,iy+1,iz+1,p-1,q+1,r+1,P,Q,R,
1722 nx_part,ny_part,nz_part,global_part,
1723 &work[o_cnt]);
1724 offd_data[o_cnt++] = value[1];
1725 }
1726 hypre_map(ix,iy+1,iz+1,p,q+1,r+1,P,Q,R,
1727 nx_part,ny_part,nz_part,global_part,
1728 &work[o_cnt]);
1729 offd_data[o_cnt++] = value[1];
1730 if (ix < nx_local-1)
1731 {
1732 hypre_map(ix+1,iy+1,iz+1,p,q+1,r+1,P,Q,R,
1733 nx_part,ny_part,nz_part,global_part,
1734 &work[o_cnt]);
1735 offd_data[o_cnt++] = value[1];
1736 }
1737 else if (ip < P-1)
1738 {
1739 hypre_map(ix+1,iy+1,iz+1,p+1,q+1,r+1,P,Q,R,
1740 nx_part,ny_part,nz_part,global_part,
1741 &work[o_cnt]);
1742 offd_data[o_cnt++] = value[1];
1743 }
1744 }
1745 }
1746 }
1747 }
1748 row_index++;
1749 }
1750 }
1751 }
1752
1753 if (num_procs > 1)
1754 {
1755 HYPRE_BigInt *tmp_work;
1756
1757 tmp_work = hypre_CTAlloc(HYPRE_BigInt, o_cnt);
1758
1759 for (i=0; i < o_cnt; i++)
1760 tmp_work[i] = work[i];
1761
1762 hypre_BigQsort0(tmp_work, 0, o_cnt-1);
1763
1764 col_map_offd[0] = tmp_work[0];
1765 cnt = 0;
1766 for (i=0; i < o_cnt; i++)
1767 {
1768 if (tmp_work[i] > col_map_offd[cnt])
1769 {
1770 cnt++;
1771 col_map_offd[cnt] = tmp_work[i];
1772 }
1773 }
1774 hypre_TFree(tmp_work);
1775
1776 for (i=0; i < o_cnt; i++)
1777 {
1778 offd_j[i] = hypre_BigBinarySearch(col_map_offd,work[i],num_cols_offd);
1779 }
1780
1781 hypre_TFree(work);
1782 }
1783
1784 par_rhs = hypre_ParVectorCreate(comm, grid_size, global_part_rhs);
1785 rhs = hypre_ParVectorLocalVector(par_rhs);
1786 hypre_VectorData(rhs) = rhs_data;
1787
1788 par_x = hypre_ParVectorCreate(comm, grid_size, global_part_x);
1789 x = hypre_ParVectorLocalVector(par_x);
1790 hypre_VectorData(x) = x_data;
1791
1792 A = hypre_ParCSRMatrixCreate(comm, grid_size, grid_size,
1793 global_part, global_part, num_cols_offd,
1794 diag_i[local_num_rows],
1795 offd_i[local_num_rows]);
1796
1797 hypre_ParCSRMatrixColMapOffd(A) = col_map_offd;
1798
1799 diag = hypre_ParCSRMatrixDiag(A);
1800 hypre_CSRMatrixI(diag) = diag_i;
1801 hypre_CSRMatrixJ(diag) = diag_j;
1802 hypre_CSRMatrixData(diag) = diag_data;
1803
1804 offd = hypre_ParCSRMatrixOffd(A);
1805 hypre_CSRMatrixI(offd) = offd_i;
1806 if (num_cols_offd)
1807 {
1808 hypre_CSRMatrixJ(offd) = offd_j;
1809 hypre_CSRMatrixData(offd) = offd_data;
1810 }
1811
1812 hypre_TFree(nx_part);
1813 hypre_TFree(ny_part);
1814 hypre_TFree(nz_part);
1815
1816 *rhs_ptr = (HYPRE_ParVector) par_rhs;
1817 *x_ptr = (HYPRE_ParVector) par_x;
1818
1819 return (HYPRE_ParCSRMatrix) A;
1820}
Note: See TracBrowser for help on using the repository browser.