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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4934 - (show annotations)
Tue May 13 00:28:11 2014 UTC (5 years, 4 months ago) by jfenwick
File size: 5454 byte(s)
This commit is brought to you by the number 4934 and the tool "meld".
Merge of partially complete split world code from branch.



1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2014 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16
17
18 /****************************************************************************/
19
20 /* Paso: AMG set-ups */
21
22 /****************************************************************************/
23
24 /* Author: Lutz Gross, l.gross@uq.edu.au */
25
26 /****************************************************************************/
27
28 #include "Paso.h"
29 #include "Preconditioner.h"
30 #include "BOOMERAMG.h"
31
32 namespace paso {
33
34 void Preconditioner_AMG_Root_free(Preconditioner_AMG_Root* in)
35 {
36 if (in) {
37 Preconditioner_AMG_free(in->amg);
38 Preconditioner_LocalAMG_free(in->localamg);
39 Preconditioner_BoomerAMG_free(in->boomeramg);
40 Preconditioner_Smoother_free(in->amgsubstitute);
41 delete in;
42 }
43 }
44
45 Preconditioner_AMG_Root* Preconditioner_AMG_Root_alloc(SystemMatrix_ptr A,
46 Options* options)
47 {
48 Preconditioner_AMG_Root* prec=new Preconditioner_AMG_Root;
49 prec->amg = NULL;
50 prec->localamg = NULL;
51 prec->amgsubstitute = NULL;
52 prec->boomeramg = NULL;
53 if (options->preconditioner == PASO_BOOMERAMG) {
54 prec->boomeramg = Preconditioner_BoomerAMG_alloc(A,options);
55 } else {
56 prec->is_local = (A->mpi_info->size == 1) || options->use_local_preconditioner;
57 if (prec->is_local) {
58 prec->localamg = Preconditioner_LocalAMG_alloc(A->mainBlock, 1, options);
59 Esys_MPIInfo_noError(A->mpi_info);
60 } else {
61 prec->amg = Preconditioner_AMG_alloc(A, 1, options);
62 }
63 }
64 if (Esys_noError()) {
65 if (options->verbose) {
66 if (prec->localamg || prec->amg || prec->boomeramg) {
67 printf("Preconditioner_AMG_Root: Smoother is ");
68 if (options->smoother == PASO_JACOBI) {
69 printf("Jacobi");
70 } else {
71 printf("Gauss-Seidel");
72 }
73 printf(" with %d/%d pre/post sweeps",options->pre_sweeps, options->post_sweeps);
74 if (options->interpolation_method == PASO_CLASSIC_INTERPOLATION) {
75 printf( " and classical interpolation.\n");
76 } else if (options->interpolation_method == PASO_CLASSIC_INTERPOLATION_WITH_FF_COUPLING) {
77 printf( " and classical interpolation with enforced FF coupling.\n");
78 } else {
79 printf( " and direct interpolation.\n");
80 }
81 } else {
82 printf("Preconditioner_AMG_Root: no coarsening constructed.\n");
83 }
84 } // verbose?
85
86
87 if (prec->localamg != NULL) {
88 options->num_level=Preconditioner_LocalAMG_getMaxLevel(prec->localamg);
89 options->coarse_level_sparsity=Preconditioner_LocalAMG_getCoarseLevelSparsity(prec->localamg);
90 options->num_coarse_unknowns=Preconditioner_LocalAMG_getNumCoarseUnknowns(prec->localamg);
91 } else if (prec->amg != NULL) {
92 options->num_level=Preconditioner_AMG_getMaxLevel(prec->amg);
93 options->coarse_level_sparsity=Preconditioner_AMG_getCoarseLevelSparsity(prec->amg);
94 options->num_coarse_unknowns=Preconditioner_AMG_getNumCoarseUnknowns(prec->amg);
95 } else if (prec->boomeramg == NULL) {
96 prec->sweeps=options->sweeps;
97 prec->amgsubstitute=Preconditioner_Smoother_alloc(A, (options->smoother == PASO_JACOBI), prec->is_local, options->verbose);
98 options->num_level=0;
99 if (options->verbose) {
100 if (options->smoother == PASO_JACOBI) {
101 printf("Preconditioner: Jacobi(%d) preconditioner is used.\n",prec->sweeps);
102 } else {
103 printf("Preconditioner: Gauss-Seidel(%d) preconditioner is used.\n",prec->sweeps);
104 }
105 }
106 }
107 }
108 if (!Esys_noError() ){
109 Preconditioner_AMG_Root_free(prec);
110 return NULL;
111 } else {
112 return prec;
113 }
114 }
115
116 /* Applies the preconditioner. */
117 /* Has to be called within a parallel region. */
118 /* Barrier synchronization is performed before the evaluation to make sure that the input vector is available */
119 void Preconditioner_AMG_Root_solve(SystemMatrix_ptr A,
120 Preconditioner_AMG_Root* prec,
121 double* x, double* b)
122 {
123 if (prec->localamg != NULL) {
124 Preconditioner_LocalAMG_solve(A->mainBlock, prec->localamg, x, b);
125 } else if ( prec->amg != NULL) {
126 Preconditioner_AMG_solve(A, prec->amg,x,b);
127 } else if ( prec->boomeramg != NULL) {
128 Preconditioner_BoomerAMG_solve(A, prec->boomeramg, x, b);
129 } else {
130 Preconditioner_Smoother_solve(A, prec->amgsubstitute, x, b,
131 prec->sweeps, false);
132 }
133 }
134
135 } // namespace paso
136

Properties

Name Value
svn:mergeinfo /branches/amg_from_3530/paso/src/AMG_Root.cpp:3531-3826 /branches/lapack2681/paso/src/AMG_Root.cpp:2682-2741 /branches/pasowrap/paso/src/AMG_Root.cpp:3661-3674 /branches/py3_attempt2/paso/src/AMG_Root.cpp:3871-3891 /branches/restext/paso/src/AMG_Root.cpp:2610-2624 /branches/ripleygmg_from_3668/paso/src/AMG_Root.cpp:3669-3791 /branches/stage3.0/paso/src/AMG_Root.cpp:2569-2590 /branches/symbolic_from_3470/paso/src/AMG_Root.cpp:3471-3974 /branches/symbolic_from_3470/ripley/test/python/paso/src/AMG_Root.cpp:3517-3974 /release/3.0/paso/src/AMG_Root.cpp:2591-2601 /trunk/paso/src/AMG_Root.cpp:4257-4344 /trunk/ripley/test/python/paso/src/AMG_Root.cpp:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26