source: CIVL/examples/mpi-omp/AMG2013/parcsr_ls/par_stats.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: 29.6 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#include "par_amg.h"
18
19/*****************************************************************************
20 *
21 * Routine for getting matrix statistics from setup
22 *
23 *****************************************************************************/
24
25
26int
27hypre_BoomerAMGSetupStats( void *amg_vdata,
28 hypre_ParCSRMatrix *A )
29{
30 MPI_Comm comm = hypre_ParCSRMatrixComm(A);
31
32 hypre_ParAMGData *amg_data = amg_vdata;
33
34 /*hypre_SeqAMGData *seq_data = hypre_ParAMGDataSeqData(amg_data);*/
35
36 /* Data Structure variables */
37
38 hypre_ParCSRMatrix **A_array;
39 hypre_ParCSRMatrix **P_array;
40
41 hypre_CSRMatrix *A_diag;
42 double *A_diag_data;
43 int *A_diag_i;
44
45 hypre_CSRMatrix *A_offd;
46 double *A_offd_data;
47 int *A_offd_i;
48
49 hypre_CSRMatrix *P_diag;
50 double *P_diag_data;
51 int *P_diag_i;
52
53 hypre_CSRMatrix *P_offd;
54 double *P_offd_data;
55 int *P_offd_i;
56
57
58 int numrows;
59
60 HYPRE_BigInt *row_starts;
61
62
63 int num_levels;
64 int coarsen_type;
65 int interp_type;
66 int measure_type;
67 double global_nonzeros;
68
69 double *send_buff;
70 double *gather_buff;
71
72 /* Local variables */
73
74 int level;
75 int j;
76 HYPRE_BigInt fine_size;
77
78 int min_entries;
79 int max_entries;
80
81 int num_procs,my_id, num_threads;
82
83
84 double min_rowsum;
85 double max_rowsum;
86 double sparse;
87
88
89 int i;
90
91
92 HYPRE_BigInt coarse_size;
93 int entries;
94
95 double avg_entries;
96 double rowsum;
97
98 double min_weight;
99 double max_weight;
100
101 int global_min_e;
102 int global_max_e;
103 double global_min_rsum;
104 double global_max_rsum;
105 double global_min_wt;
106 double global_max_wt;
107
108 double *num_coeffs;
109 double *num_variables;
110 double total_variables;
111 double operat_cmplxty;
112 double grid_cmplxty;
113
114 /* amg solve params */
115 int max_iter;
116 int cycle_type;
117 int *num_grid_sweeps;
118 int *grid_relax_type;
119 int relax_order;
120 int **grid_relax_points;
121 double *relax_weight;
122 double *omega;
123 double tol;
124
125
126 int one = 1;
127 int minus_one = -1;
128 int zero = 0;
129 int smooth_type;
130 int smooth_num_levels;
131 int agg_num_levels;
132 /*int seq_cg = 0;*/
133
134 /*if (seq_data)
135 seq_cg = 1;*/
136
137
138 MPI_Comm_size(comm, &num_procs);
139 MPI_Comm_rank(comm,&my_id);
140 num_threads = hypre_NumThreads();
141
142 if (my_id == 0)
143 printf("\nNumber of MPI processes: %d , Number of OpenMP threads: %d\n", num_procs, num_threads);
144 A_array = hypre_ParAMGDataAArray(amg_data);
145 P_array = hypre_ParAMGDataPArray(amg_data);
146 num_levels = hypre_ParAMGDataNumLevels(amg_data);
147 coarsen_type = hypre_ParAMGDataCoarsenType(amg_data);
148 interp_type = hypre_ParAMGDataInterpType(amg_data);
149 measure_type = hypre_ParAMGDataMeasureType(amg_data);
150 smooth_type = hypre_ParAMGDataSmoothType(amg_data);
151 smooth_num_levels = hypre_ParAMGDataSmoothNumLevels(amg_data);
152 agg_num_levels = hypre_ParAMGDataAggNumLevels(amg_data);
153
154
155 /*----------------------------------------------------------
156 * Get the amg_data data
157 *----------------------------------------------------------*/
158
159 num_levels = hypre_ParAMGDataNumLevels(amg_data);
160 max_iter = hypre_ParAMGDataMaxIter(amg_data);
161 cycle_type = hypre_ParAMGDataCycleType(amg_data);
162 num_grid_sweeps = hypre_ParAMGDataNumGridSweeps(amg_data);
163 grid_relax_type = hypre_ParAMGDataGridRelaxType(amg_data);
164 grid_relax_points = hypre_ParAMGDataGridRelaxPoints(amg_data);
165 relax_weight = hypre_ParAMGDataRelaxWeight(amg_data);
166 relax_order = hypre_ParAMGDataRelaxOrder(amg_data);
167 omega = hypre_ParAMGDataOmega(amg_data);
168 tol = hypre_ParAMGDataTol(amg_data);
169
170 /*block_mode = hypre_ParAMGDataBlockMode(amg_data);*/
171
172 send_buff = hypre_CTAlloc(double, 6);
173#ifdef HYPRE_NO_GLOBAL_PARTITION
174 gather_buff = hypre_CTAlloc(double,6);
175#else
176 gather_buff = hypre_CTAlloc(double,6*num_procs);
177#endif
178
179 if (my_id==0)
180 {
181 printf("\nBoomerAMG SETUP PARAMETERS:\n\n");
182 printf(" Max levels = %d\n",hypre_ParAMGDataMaxLevels(amg_data));
183 printf(" Num levels = %d\n\n",num_levels);
184 printf(" Strength Threshold = %f\n",
185 hypre_ParAMGDataStrongThreshold(amg_data));
186 printf(" Interpolation Truncation Factor = %f\n",
187 hypre_ParAMGDataTruncFactor(amg_data));
188 printf(" Maximum Row Sum Threshold for Dependency Weakening = %f\n\n",
189 hypre_ParAMGDataMaxRowSum(amg_data));
190
191 if (coarsen_type == 0)
192 {
193 printf(" Coarsening Type = Cleary-Luby-Jones-Plassman\n");
194 }
195 else if (abs(coarsen_type) == 1)
196 {
197 printf(" Coarsening Type = Ruge\n");
198 }
199 else if (abs(coarsen_type) == 2)
200 {
201 printf(" Coarsening Type = Ruge2B\n");
202 }
203 else if (abs(coarsen_type) == 3)
204 {
205 printf(" Coarsening Type = Ruge3\n");
206 }
207 else if (abs(coarsen_type) == 4)
208 {
209 printf(" Coarsening Type = Ruge 3c \n");
210 }
211 else if (abs(coarsen_type) == 5)
212 {
213 printf(" Coarsening Type = Ruge relax special points \n");
214 }
215 else if (abs(coarsen_type) == 6)
216 {
217 printf(" Coarsening Type = Falgout-CLJP \n");
218 }
219 else if (abs(coarsen_type) == 8)
220 {
221 printf(" Coarsening Type = PMIS \n");
222 }
223 else if (abs(coarsen_type) == 10)
224 {
225 printf(" Coarsening Type = HMIS \n");
226 }
227 else if (abs(coarsen_type) == 11)
228 {
229 printf(" Coarsening Type = Ruge 1st pass only \n");
230 }
231 else if (abs(coarsen_type) == 9)
232 {
233 printf(" Coarsening Type = PMIS fixed random \n");
234 }
235 else if (abs(coarsen_type) == 7)
236 {
237 printf(" Coarsening Type = CLJP, fixed random \n");
238 }
239 if (coarsen_type > 0)
240 {
241 printf(" Hybrid Coarsening (switch to CLJP when coarsening slows)\n");
242 }
243
244
245 if (coarsen_type)
246 printf(" measures are determined %s\n\n",
247 (measure_type ? "globally" : "locally"));
248
249 if (agg_num_levels)
250 printf(" no. of levels of aggressive coarsening: %d\n\n", agg_num_levels);
251
252#ifdef HYPRE_NO_GLOBAL_PARTITION
253 printf( "\n No global partition option chosen.\n\n");
254#endif
255
256 if (interp_type == 0)
257 {
258 printf(" Interpolation = modified classical interpolation\n");
259 }
260 else if (interp_type == 1)
261 {
262 printf(" Interpolation = LS interpolation \n");
263 }
264 else if (interp_type == 2)
265 {
266 printf(" Interpolation = modified classical interpolation for hyperbolic PDEs\n");
267 }
268 else if (interp_type == 3)
269 {
270 printf(" Interpolation = direct interpolation with separation of weights\n");
271 }
272 else if (interp_type == 4)
273 {
274 printf(" Interpolation = multipass interpolation\n");
275 }
276 else if (interp_type == 5)
277 {
278 printf(" Interpolation = multipass interpolation with separation of weights\n");
279 }
280 else if (interp_type == 6)
281 {
282 printf(" Interpolation = extended+i interpolation\n");
283 }
284 else if (interp_type == 7)
285 {
286 printf(" Interpolation = extended+i interpolation (only when needed)\n");
287 }
288 else if (interp_type == 8)
289 {
290 printf(" Interpolation = standard interpolation\n");
291 }
292 else if (interp_type == 9)
293 {
294 printf(" Interpolation = standard interpolation with separation of weights\n");
295 }
296 else if (interp_type == 12)
297 {
298 printf(" FF interpolation \n");
299 }
300 else if (interp_type == 13)
301 {
302 printf(" FF1 interpolation \n");
303 }
304
305 {
306 printf( "\nOperator Matrix Information:\n\n");
307 }
308#if HYPRE_LONG_LONG
309 printf(" nonzero entries p");
310 printf("er row row sums\n");
311 printf("lev rows entries sparse min max ");
312 printf("avg min max\n");
313 printf("=======================================");
314 printf("==================================\n");
315#else
316 printf(" nonzero entries p");
317 printf("er row row sums\n");
318 printf("lev rows entries sparse min max ");
319 printf("avg min max\n");
320 printf("=======================================");
321 printf("============================\n");
322#endif
323 }
324
325 /*-----------------------------------------------------
326 * Enter Statistics Loop
327 *-----------------------------------------------------*/
328
329 num_coeffs = hypre_CTAlloc(double,num_levels);
330
331 num_variables = hypre_CTAlloc(double,num_levels);
332
333 for (level = 0; level < num_levels; level++)
334 {
335
336 {
337 A_diag = hypre_ParCSRMatrixDiag(A_array[level]);
338 A_diag_data = hypre_CSRMatrixData(A_diag);
339 A_diag_i = hypre_CSRMatrixI(A_diag);
340
341 A_offd = hypre_ParCSRMatrixOffd(A_array[level]);
342 A_offd_data = hypre_CSRMatrixData(A_offd);
343 A_offd_i = hypre_CSRMatrixI(A_offd);
344
345 row_starts = hypre_ParCSRMatrixRowStarts(A_array[level]);
346
347 fine_size = hypre_ParCSRMatrixGlobalNumRows(A_array[level]);
348 global_nonzeros = hypre_ParCSRMatrixDNumNonzeros(A_array[level]);
349 num_coeffs[level] = global_nonzeros;
350 num_variables[level] = (double) fine_size;
351
352 sparse = global_nonzeros /((double) fine_size * (double) fine_size);
353
354 min_entries = 0;
355 max_entries = 0;
356 min_rowsum = 0.0;
357 max_rowsum = 0.0;
358
359 if (hypre_CSRMatrixNumRows(A_diag))
360 {
361 min_entries = (A_diag_i[1]-A_diag_i[0])+(A_offd_i[1]-A_offd_i[0]);
362 for (j = A_diag_i[0]; j < A_diag_i[1]; j++)
363 min_rowsum += A_diag_data[j];
364 for (j = A_offd_i[0]; j < A_offd_i[1]; j++)
365 min_rowsum += A_offd_data[j];
366
367 max_rowsum = min_rowsum;
368
369 for (j = 0; j < hypre_CSRMatrixNumRows(A_diag); j++)
370 {
371 entries = (A_diag_i[j+1]-A_diag_i[j])+(A_offd_i[j+1]-A_offd_i[j]);
372 min_entries = hypre_min(entries, min_entries);
373 max_entries = hypre_max(entries, max_entries);
374
375 rowsum = 0.0;
376 for (i = A_diag_i[j]; i < A_diag_i[j+1]; i++)
377 rowsum += A_diag_data[i];
378
379 for (i = A_offd_i[j]; i < A_offd_i[j+1]; i++)
380 rowsum += A_offd_data[i];
381
382 min_rowsum = hypre_min(rowsum, min_rowsum);
383 max_rowsum = hypre_max(rowsum, max_rowsum);
384 }
385 }
386 avg_entries = global_nonzeros / ((double) fine_size);
387 }
388
389#ifdef HYPRE_NO_GLOBAL_PARTITION
390
391 numrows = (int)(row_starts[1]-row_starts[0]);
392 if (!numrows) /* if we don't have any rows, then don't have this count toward
393 min row sum or min num entries */
394 {
395 min_entries = 1000000;
396 min_rowsum = 1.0e7;
397 }
398
399 send_buff[0] = - (double) min_entries;
400 send_buff[1] = (double) max_entries;
401 send_buff[2] = - min_rowsum;
402 send_buff[3] = max_rowsum;
403
404 MPI_Reduce(send_buff, gather_buff, 4, MPI_DOUBLE, MPI_MAX, 0, comm);
405
406 if (my_id ==0)
407 {
408 global_min_e = - gather_buff[0];
409 global_max_e = gather_buff[1];
410 global_min_rsum = - gather_buff[2];
411 global_max_rsum = gather_buff[3];
412#ifdef HYPRE_LONG_LONG
413 printf( "%2d %12lld %8.0f %0.3f %4d %4d",
414 level, fine_size, global_nonzeros, sparse, global_min_e,
415 global_max_e);
416#else
417 printf( "%2d %7d %8.0f %0.3f %4d %4d",
418 level, fine_size, global_nonzeros, sparse, global_min_e,
419 global_max_e);
420#endif
421 printf(" %4.1f %10.3e %10.3e\n", avg_entries,
422 global_min_rsum, global_max_rsum);
423 }
424
425#else
426
427 send_buff[0] = (double) min_entries;
428 send_buff[1] = (double) max_entries;
429 send_buff[2] = min_rowsum;
430 send_buff[3] = max_rowsum;
431
432 MPI_Gather(send_buff,4,MPI_DOUBLE,gather_buff,4,MPI_DOUBLE,0,comm);
433
434 if (my_id == 0)
435 {
436 global_min_e = 1000000;
437 global_max_e = 0;
438 global_min_rsum = 1.0e7;
439 global_max_rsum = 0.0;
440 for (j = 0; j < num_procs; j++)
441 {
442 numrows = row_starts[j+1]-row_starts[j];
443 if (numrows)
444 {
445 global_min_e = hypre_min(global_min_e, (int) gather_buff[j*4]);
446 global_min_rsum = hypre_min(global_min_rsum, gather_buff[j*4 +2]);
447 }
448 global_max_e = hypre_max(global_max_e, (int) gather_buff[j*4 +1]);
449 global_max_rsum = hypre_max(global_max_rsum, gather_buff[j*4 +3]);
450 }
451
452#ifdef HYPRE_LONG_LONG
453 printf( "%2d %12lld %8.0f %0.3f %4d %4d",
454 level, fine_size, global_nonzeros, sparse, global_min_e,
455 global_max_e);
456#else
457 printf( "%2d %7d %8.0f %0.3f %4d %4d",
458 level, fine_size, global_nonzeros, sparse, global_min_e,
459 global_max_e);
460#endif
461 printf(" %4.1f %10.3e %10.3e\n", avg_entries,
462 global_min_rsum, global_max_rsum);
463 }
464
465#endif
466
467
468 }
469
470
471 if (my_id == 0)
472 {
473 {
474 printf( "\n\nInterpolation Matrix Information:\n\n");
475 }
476#if HYPRE_LONG_LONG
477 printf(" entries/row min max");
478 printf(" row sums\n");
479 printf("lev rows x cols min max ");
480 printf(" weight weight min max \n");
481 printf("=======================================");
482 printf("======================================\n");
483#else
484 printf(" entries/row min max");
485 printf(" row sums\n");
486 printf("lev rows cols min max ");
487 printf(" weight weight min max \n");
488 printf("=======================================");
489 printf("==========================\n");
490#endif
491 }
492
493 /*-----------------------------------------------------
494 * Enter Statistics Loop
495 *-----------------------------------------------------*/
496
497
498 for (level = 0; level < num_levels-1; level++)
499 {
500
501 {
502 P_diag = hypre_ParCSRMatrixDiag(P_array[level]);
503 P_diag_data = hypre_CSRMatrixData(P_diag);
504 P_diag_i = hypre_CSRMatrixI(P_diag);
505
506 P_offd = hypre_ParCSRMatrixOffd(P_array[level]);
507 P_offd_data = hypre_CSRMatrixData(P_offd);
508 P_offd_i = hypre_CSRMatrixI(P_offd);
509
510 row_starts = hypre_ParCSRMatrixRowStarts(P_array[level]);
511
512 fine_size = hypre_ParCSRMatrixGlobalNumRows(P_array[level]);
513 coarse_size = hypre_ParCSRMatrixGlobalNumCols(P_array[level]);
514 global_nonzeros = hypre_ParCSRMatrixNumNonzeros(P_array[level]);
515
516 min_weight = 1.0;
517 max_weight = 0.0;
518 max_rowsum = 0.0;
519 min_rowsum = 0.0;
520 min_entries = 0;
521 max_entries = 0;
522
523 if (hypre_CSRMatrixNumRows(P_diag))
524 {
525 if (hypre_CSRMatrixNumCols(P_diag)) min_weight = P_diag_data[0];
526 for (j = P_diag_i[0]; j < P_diag_i[1]; j++)
527 {
528 min_weight = hypre_min(min_weight, P_diag_data[j]);
529 if (P_diag_data[j] != 1.0)
530 max_weight = hypre_max(max_weight, P_diag_data[j]);
531 min_rowsum += P_diag_data[j];
532 }
533 for (j = P_offd_i[0]; j < P_offd_i[1]; j++)
534 {
535 min_weight = hypre_min(min_weight, P_offd_data[j]);
536 if (P_offd_data[j] != 1.0)
537 max_weight = hypre_max(max_weight, P_offd_data[j]);
538 min_rowsum += P_offd_data[j];
539 }
540
541 max_rowsum = min_rowsum;
542
543 min_entries = (P_diag_i[1]-P_diag_i[0])+(P_offd_i[1]-P_offd_i[0]);
544 max_entries = 0;
545
546 for (j = 0; j < hypre_CSRMatrixNumRows(P_diag); j++)
547 {
548 entries = (P_diag_i[j+1]-P_diag_i[j])+(P_offd_i[j+1]-P_offd_i[j]);
549 min_entries = hypre_min(entries, min_entries);
550 max_entries = hypre_max(entries, max_entries);
551
552 rowsum = 0.0;
553 for (i = P_diag_i[j]; i < P_diag_i[j+1]; i++)
554 {
555 min_weight = hypre_min(min_weight, P_diag_data[i]);
556 if (P_diag_data[i] != 1.0)
557 max_weight = hypre_max(max_weight, P_diag_data[i]);
558 rowsum += P_diag_data[i];
559 }
560
561 for (i = P_offd_i[j]; i < P_offd_i[j+1]; i++)
562 {
563 min_weight = hypre_min(min_weight, P_offd_data[i]);
564 if (P_offd_data[i] != 1.0)
565 max_weight = hypre_max(max_weight, P_offd_data[i]);
566 rowsum += P_offd_data[i];
567 }
568
569 min_rowsum = hypre_min(rowsum, min_rowsum);
570 max_rowsum = hypre_max(rowsum, max_rowsum);
571 }
572
573 }
574 avg_entries = ((double) global_nonzeros) / ((double) fine_size);
575 }
576
577#ifdef HYPRE_NO_GLOBAL_PARTITION
578
579 numrows = (int)(row_starts[1]-row_starts[0]);
580 if (!numrows) /* if we don't have any rows, then don't have this count toward
581 min row sum or min num entries */
582 {
583 min_entries = 1000000;
584 min_rowsum = 1.0e7;
585 min_weight = 1.0e7;
586 }
587
588 send_buff[0] = - (double) min_entries;
589 send_buff[1] = (double) max_entries;
590 send_buff[2] = - min_rowsum;
591 send_buff[3] = max_rowsum;
592 send_buff[4] = - min_weight;
593 send_buff[5] = max_weight;
594
595 MPI_Reduce(send_buff, gather_buff, 6, MPI_DOUBLE, MPI_MAX, 0, comm);
596
597 if (my_id == 0)
598 {
599 global_min_e = - gather_buff[0];
600 global_max_e = gather_buff[1];
601 global_min_rsum = -gather_buff[2];
602 global_max_rsum = gather_buff[3];
603 global_min_wt = -gather_buff[4];
604 global_max_wt = gather_buff[5];
605
606#ifdef HYPRE_LONG_LONG
607 printf( "%2d %12lld x %-12lld %3d %3d",
608 level, fine_size, coarse_size, global_min_e, global_max_e);
609#else
610 printf( "%2d %5d x %-5d %3d %3d",
611 level, fine_size, coarse_size, global_min_e, global_max_e);
612#endif
613 printf(" %10.3e %9.3e %9.3e %9.3e\n",
614 global_min_wt, global_max_wt,
615 global_min_rsum, global_max_rsum);
616 }
617
618
619#else
620
621 send_buff[0] = (double) min_entries;
622 send_buff[1] = (double) max_entries;
623 send_buff[2] = min_rowsum;
624 send_buff[3] = max_rowsum;
625 send_buff[4] = min_weight;
626 send_buff[5] = max_weight;
627
628 MPI_Gather(send_buff,6,MPI_DOUBLE,gather_buff,6,MPI_DOUBLE,0,comm);
629
630 if (my_id == 0)
631 {
632 global_min_e = 1000000;
633 global_max_e = 0;
634 global_min_rsum = 1.0e7;
635 global_max_rsum = 0.0;
636 global_min_wt = 1.0e7;
637 global_max_wt = 0.0;
638
639 for (j = 0; j < num_procs; j++)
640 {
641 numrows = row_starts[j+1] - row_starts[j];
642 if (numrows)
643 {
644 global_min_e = hypre_min(global_min_e, (int) gather_buff[j*6]);
645 global_min_rsum = hypre_min(global_min_rsum, gather_buff[j*6+2]);
646 global_min_wt = hypre_min(global_min_wt, gather_buff[j*6+4]);
647 }
648 global_max_e = hypre_max(global_max_e, (int) gather_buff[j*6+1]);
649 global_max_rsum = hypre_max(global_max_rsum, gather_buff[j*6+3]);
650 global_max_wt = hypre_max(global_max_wt, gather_buff[j*6+5]);
651 }
652
653#ifdef HYPRE_LONG_LONG
654 printf( "%2d %12lld x %-12lld %3d %3d",
655 level, fine_size, coarse_size, global_min_e, global_max_e);
656#else
657 printf( "%2d %5d x %-5d %3d %3d",
658 level, fine_size, coarse_size, global_min_e, global_max_e);
659#endif
660 printf(" %10.3e %9.3e %9.3e %9.3e\n",
661 global_min_wt, global_max_wt,
662 global_min_rsum, global_max_rsum);
663 }
664
665#endif
666
667 }
668
669
670 total_variables = 0;
671 operat_cmplxty = 0;
672 for (j=0;j<hypre_ParAMGDataNumLevels(amg_data);j++)
673 {
674 operat_cmplxty += num_coeffs[j] / num_coeffs[0];
675 total_variables += num_variables[j];
676 }
677 if (num_variables[0] != 0)
678 grid_cmplxty = total_variables / num_variables[0];
679
680 if (my_id == 0 )
681 {
682 printf("\n\n Complexity: grid = %f\n",grid_cmplxty);
683 printf(" operator = %f\n",operat_cmplxty);
684 }
685
686 if (my_id == 0) printf("\n\n");
687
688 if (my_id == 0)
689 {
690 printf("\n\nBoomerAMG SOLVER PARAMETERS:\n\n");
691 printf( " Maximum number of cycles: %d \n",max_iter);
692 printf( " Stopping Tolerance: %e \n",tol);
693 printf( " Cycle type (1 = V, 2 = W, etc.): %d\n\n", cycle_type);
694 printf( " Relaxation Parameters:\n");
695 printf( " Visiting Grid: down up coarse\n");
696 printf( " Number of partial sweeps: %4d %2d %4d \n",
697 num_grid_sweeps[1],
698 num_grid_sweeps[2],num_grid_sweeps[3]);
699 printf( " Type 0=Jac, 3=hGS, 6=hSGS, 9=GE: %4d %2d %4d \n",
700 grid_relax_type[1],
701 grid_relax_type[2],grid_relax_type[3]);
702#if 1 /* TO DO: may not want this to print if CG in the coarse grid */
703 printf( " Point types, partial sweeps (1=C, -1=F):\n");
704 if (grid_relax_points)
705 {
706 printf( " Pre-CG relaxation (down):");
707 for (j = 0; j < num_grid_sweeps[1]; j++)
708 printf(" %2d", grid_relax_points[1][j]);
709 printf( "\n");
710 printf( " Post-CG relaxation (up):");
711 for (j = 0; j < num_grid_sweeps[2]; j++)
712 printf(" %2d", grid_relax_points[2][j]);
713 printf( "\n");
714 printf( " Coarsest grid:");
715 for (j = 0; j < num_grid_sweeps[3]; j++)
716 printf(" %2d", grid_relax_points[3][j]);
717 printf( "\n\n");
718 }
719 else if (relax_order == 1)
720 {
721 printf( " Pre-CG relaxation (down):");
722 for (j = 0; j < num_grid_sweeps[1]; j++)
723 printf(" %2d %2d", one, minus_one);
724 printf( "\n");
725 printf( " Post-CG relaxation (up):");
726 for (j = 0; j < num_grid_sweeps[2]; j++)
727 printf(" %2d %2d", minus_one, one);
728 printf( "\n");
729 printf( " Coarsest grid:");
730 for (j = 0; j < num_grid_sweeps[3]; j++)
731 printf(" %2d", zero);
732 printf( "\n\n");
733 }
734 else
735 {
736 printf( " Pre-CG relaxation (down):");
737 for (j = 0; j < num_grid_sweeps[1]; j++)
738 printf(" %2d", zero);
739 printf( "\n");
740 printf( " Post-CG relaxation (up):");
741 for (j = 0; j < num_grid_sweeps[2]; j++)
742 printf(" %2d", zero);
743 printf( "\n");
744 printf( " Coarsest grid:");
745 for (j = 0; j < num_grid_sweeps[3]; j++)
746 printf(" %2d", zero);
747 printf( "\n\n");
748 }
749#endif
750 if (smooth_type == 6)
751 for (j=0; j < smooth_num_levels; j++)
752 printf( " Schwarz Relaxation Weight %f level %d\n",
753 hypre_ParAMGDataSchwarzRlxWeight(amg_data),j);
754 for (j=0; j < num_levels; j++)
755 if (relax_weight[j] != 1)
756 printf( " Relaxation Weight %f level %d\n",relax_weight[j],j);
757 for (j=0; j < num_levels; j++)
758 if (omega[j] != 1)
759 printf( " Outer relaxation weight %f level %d\n",omega[j],j);
760 }
761
762
763 /*if (seq_cg)
764 {
765 hypre_seqAMGSetupStats(amg_data,num_coeffs[0],num_variables[0],
766 operat_cmplxty, grid_cmplxty );
767 }*/
768
769
770
771
772
773 hypre_TFree(num_coeffs);
774 hypre_TFree(num_variables);
775 hypre_TFree(send_buff);
776 hypre_TFree(gather_buff);
777
778 return(0);
779}
780
781
782
783
784/*---------------------------------------------------------------
785 * hypre_BoomerAMGWriteSolverParams
786 *---------------------------------------------------------------*/
787
788
789int hypre_BoomerAMGWriteSolverParams(data)
790void *data;
791
792{
793 hypre_ParAMGData *amg_data = data;
794
795 /* amg solve params */
796 int num_levels;
797 int max_iter;
798 int cycle_type;
799 int *num_grid_sweeps;
800 int *grid_relax_type;
801 int **grid_relax_points;
802 int relax_order;
803 double *relax_weight;
804 double *omega;
805 double tol;
806 int smooth_type;
807 int smooth_num_levels;
808 /* amg output params */
809 int amg_print_level;
810
811 int j;
812 int one = 1;
813 int minus_one = -1;
814 int zero = 0;
815
816
817 /*----------------------------------------------------------
818 * Get the amg_data data
819 *----------------------------------------------------------*/
820
821 num_levels = hypre_ParAMGDataNumLevels(amg_data);
822 max_iter = hypre_ParAMGDataMaxIter(amg_data);
823 cycle_type = hypre_ParAMGDataCycleType(amg_data);
824 num_grid_sweeps = hypre_ParAMGDataNumGridSweeps(amg_data);
825 grid_relax_type = hypre_ParAMGDataGridRelaxType(amg_data);
826 grid_relax_points = hypre_ParAMGDataGridRelaxPoints(amg_data);
827 relax_order = hypre_ParAMGDataRelaxOrder(amg_data);
828 relax_weight = hypre_ParAMGDataRelaxWeight(amg_data);
829 omega = hypre_ParAMGDataOmega(amg_data);
830 smooth_type = hypre_ParAMGDataSmoothType(amg_data);
831 smooth_num_levels = hypre_ParAMGDataSmoothNumLevels(amg_data);
832 tol = hypre_ParAMGDataTol(amg_data);
833
834 amg_print_level = hypre_ParAMGDataPrintLevel(amg_data);
835
836 /*----------------------------------------------------------
837 * AMG info
838 *----------------------------------------------------------*/
839
840 if (amg_print_level == 1 || amg_print_level == 3)
841 {
842 printf("\n\nBoomerAMG SOLVER PARAMETERS:\n\n");
843 printf( " Maximum number of cycles: %d \n",max_iter);
844 printf( " Stopping Tolerance: %e \n",tol);
845 printf( " Cycle type (1 = V, 2 = W, etc.): %d\n\n", cycle_type);
846 printf( " Relaxation Parameters:\n");
847 printf( " Visiting Grid: down up coarse\n");
848 printf( " Visiting Grid: down up coarse\n");
849 printf( " Number of partial sweeps: %4d %2d %4d \n",
850 num_grid_sweeps[1],
851 num_grid_sweeps[2],num_grid_sweeps[3]);
852 printf( " Type 0=Jac, 3=hGS, 6=hSGS, 9=GE: %4d %2d %4d \n",
853 grid_relax_type[1],
854 grid_relax_type[2],grid_relax_type[3]);
855 printf( " Point types, partial sweeps (1=C, -1=F):\n");
856 if (grid_relax_points)
857 {
858 printf( " Pre-CG relaxation (down):");
859 for (j = 0; j < num_grid_sweeps[1]; j++)
860 printf(" %2d", grid_relax_points[1][j]);
861 printf( "\n");
862 printf( " Post-CG relaxation (up):");
863 for (j = 0; j < num_grid_sweeps[2]; j++)
864 printf(" %2d", grid_relax_points[2][j]);
865 printf( "\n");
866 printf( " Coarsest grid:");
867 for (j = 0; j < num_grid_sweeps[3]; j++)
868 printf(" %2d", grid_relax_points[3][j]);
869 printf( "\n\n");
870 }
871 else if (relax_order == 1)
872 {
873 printf( " Pre-CG relaxation (down):");
874 for (j = 0; j < num_grid_sweeps[1]; j++)
875 printf(" %2d %2d", one, minus_one);
876 printf( "\n");
877 printf( " Post-CG relaxation (up):");
878 for (j = 0; j < num_grid_sweeps[2]; j++)
879 printf(" %2d %2d", minus_one, one);
880 printf( "\n");
881 printf( " Coarsest grid:");
882 for (j = 0; j < num_grid_sweeps[3]; j++)
883 printf(" %2d", zero);
884 printf( "\n\n");
885 }
886 else
887 {
888 printf( " Pre-CG relaxation (down):");
889 for (j = 0; j < num_grid_sweeps[1]; j++)
890 printf(" %2d", zero);
891 printf( "\n");
892 printf( " Post-CG relaxation (up):");
893 for (j = 0; j < num_grid_sweeps[2]; j++)
894 printf(" %2d", zero);
895 printf( "\n");
896 printf( " Coarsest grid:");
897 for (j = 0; j < num_grid_sweeps[3]; j++)
898 printf(" %2d", zero);
899 printf( "\n\n");
900 }
901 if (smooth_type == 6)
902 for (j=0; j < smooth_num_levels; j++)
903 printf( " Schwarz Relaxation Weight %f level %d\n",
904 hypre_ParAMGDataSchwarzRlxWeight(amg_data),j);
905 for (j=0; j < num_levels; j++)
906 if (relax_weight[j] != 1)
907 printf( " Relaxation Weight %f level %d\n",relax_weight[j],j);
908 for (j=0; j < num_levels; j++)
909 if (omega[j] != 1)
910 printf( " Outer relaxation weight %f level %d\n",omega[j],j);
911
912 printf( " Output flag (print_level): %d \n", amg_print_level);
913 }
914
915 return 0;
916}
Note: See TracBrowser for help on using the repository browser.