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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3449 - (show annotations)
Fri Jan 21 05:48:15 2011 UTC (10 years, 1 month ago) by gross
File MIME type: text/plain
File size: 4908 byte(s)
compile problem in AMG fixed.
1
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 /* Paso: AMG sets-up */
18
19 /**************************************************************/
20
21 /* Author: Lutz Gross, l.gross@uq.edu.au */
22
23 /**************************************************************/
24
25 #include "Paso.h"
26 #include "Preconditioner.h"
27
28 /***********************************************************************************/
29
30 /* free space */
31
32 void Paso_Preconditioner_AMG_Root_free(Paso_Preconditioner_AMG_Root* in) {
33 if (in!=NULL) {
34 Paso_Preconditioner_AMG_free(in->amg);
35 Paso_Preconditioner_LocalAMG_free(in->localamg);
36 Paso_Preconditioner_Smoother_free(in->amgsubstitute);
37 MEMFREE(in);
38 }
39 }
40
41 Paso_Preconditioner_AMG_Root* Paso_Preconditioner_AMG_Root_alloc(Paso_SystemMatrix* A,Paso_Options* options) {
42
43 Paso_Preconditioner_AMG_Root* prec=MEMALLOC(1,Paso_Preconditioner_AMG_Root);
44
45 if (! Esys_checkPtr(prec)) {
46
47 prec->amg=NULL;
48 prec->localamg=NULL;
49 prec->amgsubstitute=NULL;
50 prec->is_local=( A->mpi_info->size == 1 ) | options->use_local_preconditioner;
51 prec->is_local=TRUE;
52
53 if (prec->is_local) {
54 prec->localamg=Paso_Preconditioner_LocalAMG_alloc(A->mainBlock,1,options);
55 Esys_MPIInfo_noError(A->mpi_info);
56 } else {
57 prec->amg=Paso_Preconditioner_AMG_alloc(A,1,options);
58 }
59 if ( Esys_noError() ) {
60 if (options->verbose) {
61 if ( (prec->localamg != NULL) || ( prec->amg != NULL) ) {
62 printf("Paso_Preconditioner_AMG_Root: Smoother is ");
63 if (options->smoother == PASO_JACOBI) {
64 printf("Jacobi");
65 } else {
66 printf("Gauss-Seidel");
67 }
68 printf(" with %d/%d pre/post sweeps",options->pre_sweeps, options->post_sweeps);
69 if (options->interpolation_method == PASO_CLASSIC_INTERPOLATION) {
70 printf( " and classical interpolation.\n");
71 } else if (options->interpolation_method == PASO_CLASSIC_INTERPOLATION_WITH_FF_COUPLING) {
72 printf( " and classical interpolation with enforced FF coupling.\n");
73 } else {
74 printf( " and direct interpolation.\n");
75 }
76 } else {
77 printf("Paso_Preconditioner_AMG_Root: no coarsening constructed.\n");
78 }
79 }
80
81 if (prec->localamg != NULL) {
82 options->num_level=Paso_Preconditioner_LocalAMG_getMaxLevel(prec->localamg);
83 options->coarse_level_sparsity=Paso_Preconditioner_LocalAMG_getCoarseLevelSparsity(prec->localamg);
84 options->num_coarse_unknowns=Paso_Preconditioner_LocalAMG_getNumCoarseUnknwons(prec->localamg);
85 } else if ( prec->amg != NULL) {
86 options->num_level=Paso_Preconditioner_AMG_getMaxLevel(prec->amg);
87 options->coarse_level_sparsity=Paso_Preconditioner_AMG_getCoarseLevelSparsity(prec->amg);
88 options->num_coarse_unknowns=Paso_Preconditioner_AMG_getNumCoarseUnknwons(prec->amg);
89 } else {
90 prec->sweeps=options->sweeps;
91 prec->amgsubstitute=Paso_Preconditioner_Smoother_alloc(A, (options->smoother == PASO_JACOBI), prec->is_local, options->verbose);
92 options->num_level=0;
93 if (options->verbose) {
94 if (options->smoother == PASO_JACOBI) {
95 printf("Paso_Preconditioner: Jacobi(%d) preconditioner is used.\n",prec->sweeps);
96 } else {
97 printf("Paso_Preconditioner: Gauss-Seidel(%d) preconditioner is used.\n",prec->sweeps);
98 }
99 }
100 }
101 }
102 }
103 if (! Esys_noError() ){
104 Paso_Preconditioner_AMG_Root_free(prec);
105 return NULL;
106 } else {
107 return prec;
108 }
109 }
110
111 /* applies the preconditioner */
112 /* has to be called within a parallel reqion */
113 /* barrier synchronization is performed before the evaluation to make sure that the input vector is available */
114 void Paso_Preconditioner_AMG_Root_solve(Paso_SystemMatrix* A, Paso_Preconditioner_AMG_Root* prec, double* x,double* b)
115 {
116 if (prec->localamg != NULL) {
117 Paso_Preconditioner_LocalAMG_solve(A->mainBlock, prec->localamg,x,b);
118 } else if ( prec->amg != NULL) {
119 Paso_Preconditioner_AMG_solve(A, prec->amg,x,b);
120 } else {
121 Paso_Preconditioner_Smoother_solve(A, prec->amgsubstitute,x,b,prec->sweeps,FALSE);
122 }
123 }

  ViewVC Help
Powered by ViewVC 1.1.26