/[escript]/trunk/paso/src/AMG_Root.c
ViewVC logotype

Annotation of /trunk/paso/src/AMG_Root.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3642 - (hide annotations)
Thu Oct 27 03:41:51 2011 UTC (7 years, 6 months ago) by caltinay
File MIME type: text/plain
File size: 5372 byte(s)
Assorted spelling/comment fixes in paso.

1 gross 3446
2     /*******************************************************
3     *
4     * Copyright (c) 2003-2010 by University of Queensland
5     * Earth Systems Science Computational Center (ESSCC)
6     * http://www.uq.edu.au/esscc
7     *
8     * Primary Business: Queensland, Australia
9     * Licensed under the Open Software License version 3.0
10     * http://www.opensource.org/licenses/osl-3.0.php
11     *
12     *******************************************************/
13    
14    
15     /**************************************************************/
16    
17 caltinay 3642 /* Paso: AMG set-ups */
18 gross 3446
19     /**************************************************************/
20    
21     /* Author: Lutz Gross, l.gross@uq.edu.au */
22    
23     /**************************************************************/
24    
25     #include "Paso.h"
26     #include "Preconditioner.h"
27 lgao 3508 #include "BOOMERAMG.h"
28 gross 3446
29     /***********************************************************************************/
30    
31     /* free space */
32    
33     void Paso_Preconditioner_AMG_Root_free(Paso_Preconditioner_AMG_Root* in) {
34     if (in!=NULL) {
35     Paso_Preconditioner_AMG_free(in->amg);
36     Paso_Preconditioner_LocalAMG_free(in->localamg);
37 lgao 3508 Paso_Preconditioner_BoomerAMG_free(in->boomeramg);
38 gross 3446 Paso_Preconditioner_Smoother_free(in->amgsubstitute);
39     MEMFREE(in);
40     }
41     }
42    
43     Paso_Preconditioner_AMG_Root* Paso_Preconditioner_AMG_Root_alloc(Paso_SystemMatrix* A,Paso_Options* options) {
44     Paso_Preconditioner_AMG_Root* prec=MEMALLOC(1,Paso_Preconditioner_AMG_Root);
45    
46     if (! Esys_checkPtr(prec)) {
47    
48     prec->amg=NULL;
49     prec->localamg=NULL;
50     prec->amgsubstitute=NULL;
51 lgao 3508 prec->boomeramg=NULL;
52     if (options->preconditioner == PASO_BOOMERAMG){
53     prec->boomeramg = Paso_Preconditioner_BoomerAMG_alloc(A,options);
54     } else {
55     prec->is_local=( A->mpi_info->size == 1 ) | options->use_local_preconditioner;
56     prec->is_local=FALSE;
57     prec->is_local=TRUE;
58 gross 3446
59 lgao 3508 if (prec->is_local) {
60 gross 3446 prec->localamg=Paso_Preconditioner_LocalAMG_alloc(A->mainBlock,1,options);
61     Esys_MPIInfo_noError(A->mpi_info);
62 lgao 3508 } else {
63 gross 3446 prec->amg=Paso_Preconditioner_AMG_alloc(A,1,options);
64 lgao 3508 }
65     }
66 gross 3446 if ( Esys_noError() ) {
67     if (options->verbose) {
68 lgao 3508 if ( (prec->localamg != NULL) || ( prec->amg != NULL) ||
69     (prec->boomeramg != NULL) ) {
70 gross 3446 printf("Paso_Preconditioner_AMG_Root: Smoother is ");
71     if (options->smoother == PASO_JACOBI) {
72     printf("Jacobi");
73     } else {
74     printf("Gauss-Seidel");
75     }
76     printf(" with %d/%d pre/post sweeps",options->pre_sweeps, options->post_sweeps);
77     if (options->interpolation_method == PASO_CLASSIC_INTERPOLATION) {
78     printf( " and classical interpolation.\n");
79     } else if (options->interpolation_method == PASO_CLASSIC_INTERPOLATION_WITH_FF_COUPLING) {
80     printf( " and classical interpolation with enforced FF coupling.\n");
81     } else {
82     printf( " and direct interpolation.\n");
83     }
84     } else {
85     printf("Paso_Preconditioner_AMG_Root: no coarsening constructed.\n");
86     }
87     }
88    
89     if (prec->localamg != NULL) {
90     options->num_level=Paso_Preconditioner_LocalAMG_getMaxLevel(prec->localamg);
91     options->coarse_level_sparsity=Paso_Preconditioner_LocalAMG_getCoarseLevelSparsity(prec->localamg);
92     options->num_coarse_unknowns=Paso_Preconditioner_LocalAMG_getNumCoarseUnknwons(prec->localamg);
93     } else if ( prec->amg != NULL) {
94     options->num_level=Paso_Preconditioner_AMG_getMaxLevel(prec->amg);
95     options->coarse_level_sparsity=Paso_Preconditioner_AMG_getCoarseLevelSparsity(prec->amg);
96     options->num_coarse_unknowns=Paso_Preconditioner_AMG_getNumCoarseUnknwons(prec->amg);
97 lgao 3508 } else if (prec->boomeramg == NULL) {
98 gross 3446 prec->sweeps=options->sweeps;
99     prec->amgsubstitute=Paso_Preconditioner_Smoother_alloc(A, (options->smoother == PASO_JACOBI), prec->is_local, options->verbose);
100     options->num_level=0;
101     if (options->verbose) {
102     if (options->smoother == PASO_JACOBI) {
103     printf("Paso_Preconditioner: Jacobi(%d) preconditioner is used.\n",prec->sweeps);
104     } else {
105     printf("Paso_Preconditioner: Gauss-Seidel(%d) preconditioner is used.\n",prec->sweeps);
106     }
107     }
108     }
109     }
110     }
111     if (! Esys_noError() ){
112     Paso_Preconditioner_AMG_Root_free(prec);
113     return NULL;
114     } else {
115     return prec;
116     }
117     }
118    
119 caltinay 3642 /* Applies the preconditioner. */
120     /* Has to be called within a parallel region. */
121     /* Barrier synchronization is performed before the evaluation to make sure that the input vector is available */
122 gross 3446 void Paso_Preconditioner_AMG_Root_solve(Paso_SystemMatrix* A, Paso_Preconditioner_AMG_Root* prec, double* x,double* b)
123     {
124     if (prec->localamg != NULL) {
125     Paso_Preconditioner_LocalAMG_solve(A->mainBlock, prec->localamg,x,b);
126     } else if ( prec->amg != NULL) {
127     Paso_Preconditioner_AMG_solve(A, prec->amg,x,b);
128 lgao 3508 } else if ( prec->boomeramg != NULL) {
129     Paso_Preconditioner_BoomerAMG_solve(A, prec->boomeramg,x,b);
130 gross 3446 } else {
131     Paso_Preconditioner_Smoother_solve(A, prec->amgsubstitute,x,b,prec->sweeps,FALSE);
132     }
133     }
134 caltinay 3642

  ViewVC Help
Powered by ViewVC 1.1.26