/[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 5265 - (show annotations)
Mon Nov 17 04:59:25 2014 UTC (5 years, 4 months ago) by jfenwick
File size: 5707 byte(s)
Adding missing include which clang noticed.
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 <iostream>
29 #include "Paso.h"
30 #include "Preconditioner.h"
31 #include "BOOMERAMG.h"
32
33 namespace paso {
34
35 void Preconditioner_AMG_Root_free(Preconditioner_AMG_Root* in)
36 {
37 if (in) {
38 Preconditioner_AMG_free(in->amg);
39 Preconditioner_LocalAMG_free(in->localamg);
40 Preconditioner_BoomerAMG_free(in->boomeramg);
41 Preconditioner_Smoother_free(in->amgsubstitute);
42 delete in;
43 }
44 }
45
46 Preconditioner_AMG_Root* Preconditioner_AMG_Root_alloc(SystemMatrix_ptr A,
47 Options* options)
48 {
49 Preconditioner_AMG_Root* prec=new Preconditioner_AMG_Root;
50 prec->amg = NULL;
51 prec->localamg = NULL;
52 prec->amgsubstitute = NULL;
53 prec->boomeramg = NULL;
54 if (options->preconditioner == PASO_BOOMERAMG) {
55 prec->boomeramg = Preconditioner_BoomerAMG_alloc(A,options);
56 } else {
57 prec->is_local = (A->mpi_info->size == 1) || options->use_local_preconditioner;
58 if (prec->is_local) {
59 prec->localamg = Preconditioner_LocalAMG_alloc(A->mainBlock, 1, options);
60 Esys_MPIInfo_noError(A->mpi_info);
61 } else {
62 prec->amg = Preconditioner_AMG_alloc(A, 1, options);
63 }
64 }
65 if (Esys_noError()) {
66 if (options->verbose) {
67 if (prec->localamg || prec->amg || prec->boomeramg) {
68 std::cout << "Preconditioner_AMG_Root: Smoother is ";
69 if (options->smoother == PASO_JACOBI) {
70 std::cout << "Jacobi";
71 } else {
72 std::cout << "Gauss-Seidel";
73 }
74 std::cout << " with " << options->pre_sweeps << "/"
75 << options->post_sweeps << " pre/post sweeps";
76 if (options->interpolation_method == PASO_CLASSIC_INTERPOLATION) {
77 std::cout << " and classical interpolation.";
78 } else if (options->interpolation_method == PASO_CLASSIC_INTERPOLATION_WITH_FF_COUPLING) {
79 std::cout << " and classical interpolation with enforced FF coupling.";
80 } else {
81 std::cout << " and direct interpolation.";
82 }
83 std::cout << std::endl;
84 } else {
85 std::cout << "Preconditioner_AMG_Root: no coarsening constructed." << std::endl;
86 }
87 } // verbose?
88
89
90 if (prec->localamg != NULL) {
91 options->num_level=Preconditioner_LocalAMG_getMaxLevel(prec->localamg);
92 options->coarse_level_sparsity=Preconditioner_LocalAMG_getCoarseLevelSparsity(prec->localamg);
93 options->num_coarse_unknowns=Preconditioner_LocalAMG_getNumCoarseUnknowns(prec->localamg);
94 } else if (prec->amg != NULL) {
95 options->num_level=Preconditioner_AMG_getMaxLevel(prec->amg);
96 options->coarse_level_sparsity=Preconditioner_AMG_getCoarseLevelSparsity(prec->amg);
97 options->num_coarse_unknowns=Preconditioner_AMG_getNumCoarseUnknowns(prec->amg);
98 } else if (prec->boomeramg == NULL) {
99 prec->sweeps=options->sweeps;
100 prec->amgsubstitute=Preconditioner_Smoother_alloc(A, (options->smoother == PASO_JACOBI), prec->is_local, options->verbose);
101 options->num_level=0;
102 if (options->verbose) {
103 if (options->smoother == PASO_JACOBI) {
104 std::cout << "Preconditioner: Jacobi(" << prec->sweeps
105 << ") preconditioner is used." << std::endl;
106 } else {
107 std::cout << "Preconditioner: Gauss-Seidel("
108 << prec->sweeps << ") preconditioner is used."
109 << std::endl;
110 }
111 }
112 }
113 }
114 if (!Esys_noError() ){
115 Preconditioner_AMG_Root_free(prec);
116 return NULL;
117 } else {
118 return prec;
119 }
120 }
121
122 /* Applies the preconditioner. */
123 /* Has to be called within a parallel region. */
124 /* Barrier synchronization is performed before the evaluation to make sure that the input vector is available */
125 void Preconditioner_AMG_Root_solve(SystemMatrix_ptr A,
126 Preconditioner_AMG_Root* prec,
127 double* x, double* b)
128 {
129 if (prec->localamg != NULL) {
130 Preconditioner_LocalAMG_solve(A->mainBlock, prec->localamg, x, b);
131 } else if ( prec->amg != NULL) {
132 Preconditioner_AMG_solve(A, prec->amg,x,b);
133 } else if ( prec->boomeramg != NULL) {
134 Preconditioner_BoomerAMG_solve(A, prec->boomeramg, x, b);
135 } else {
136 Preconditioner_Smoother_solve(A, prec->amgsubstitute, x, b,
137 prec->sweeps, false);
138 }
139 }
140
141 } // namespace paso
142

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