MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_ShiftedLaplacian_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // MueLu: A package for multigrid based preconditioning
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jeremie Gaidamour (jngaida@sandia.gov)
40 // Jonathan Hu (jhu@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef MUELU_SHIFTEDLAPLACIAN_DECL_HPP
47 #define MUELU_SHIFTEDLAPLACIAN_DECL_HPP
48 
49 // Xpetra
50 #include <Xpetra_Matrix_fwd.hpp>
53 #include <Xpetra_TpetraMultiVector.hpp>
54 
55 // MueLu
56 #include "MueLu.hpp"
57 #include "MueLu_ConfigDefs.hpp"
58 
59 #if defined(HAVE_MUELU_IFPACK2)
60 
61 #include <MueLu_BaseClass.hpp>
68 #include <MueLu_Hierarchy_fwd.hpp>
70 #include <MueLu_PFactory_fwd.hpp>
71 #include <MueLu_PgPFactory_fwd.hpp>
72 #include <MueLu_RAPFactory_fwd.hpp>
74 #include <MueLu_SaPFactory_fwd.hpp>
76 #include <MueLu_ShiftedLaplacianOperator.hpp>
82 #include <MueLu_Utilities_fwd.hpp>
83 
84 // Belos
85 #ifdef HAVE_MUELU_TPETRA_INST_INT_INT
86 #include <BelosConfigDefs.hpp>
87 #include <BelosLinearProblem.hpp>
88 #include <BelosSolverFactory.hpp>
89 #include <BelosTpetraAdapter.hpp>
90 #endif
91 
92 namespace MueLu {
93 
103 template <class Scalar = DefaultScalar,
106  class Node = DefaultNode>
107 class ShiftedLaplacian : public BaseClass {
108 #undef MUELU_SHIFTEDLAPLACIAN_SHORT
109 #include "MueLu_UseShortNames.hpp"
110 
114 #ifdef HAVE_MUELU_TPETRA_INST_INT_INT
115  typedef Belos::LinearProblem<SC, TMV, OP> LinearProblem;
116  typedef Belos::SolverManager<SC, TMV, OP> SolverManager;
117  typedef Belos::SolverFactory<SC, TMV, OP> SolverFactory;
118 #endif
119 
120  public:
121  /*
122  FIXME 26-June-2015 JJH: This contructor is setting numerous defaults. However, they don't match the defaults
123  FIXME int the method setParameters(). There also isn't any parameter validation that I can see.
124  */
125 
128  : numPDEs_(1)
129  , Smoother_("schwarz")
130  , Aggregation_("uncoupled")
131  , Nullspace_("constant")
132  , numLevels_(5)
133  , coarseGridSize_(100)
134  , omega_(2.0 * M_PI)
135  , iters_(500)
136  , blksize_(1)
137  , tol_(1.0e-4)
138  , nsweeps_(5)
139  , ncycles_(1)
140  , cycles_(8)
141  , subiters_(10)
142  , option_(1)
143  , nproblems_(0)
144  , solverType_(1)
145  , restart_size_(100)
146  , recycle_size_(25)
147  , smoother_sweeps_(4)
148  , smoother_damping_((SC)1.0)
149  , krylov_type_(1)
150  , krylov_iterations_(5)
152  , ilu_leveloffill_(5.0)
153  , ilu_abs_thresh_(0.0)
154  , ilu_rel_thresh_(1.0)
155  , ilu_diagpivotthresh_(0.1)
156  , ilu_drop_tol_(0.01)
157  , ilu_fill_tol_(0.01)
158  , ilu_relax_val_(1.0)
159  , ilu_rowperm_("LargeDiag")
160  , ilu_colperm_("COLAMD")
161  , ilu_drop_rule_("DROP_BASIC")
162  , ilu_normtype_("INF_NORM")
163  , ilu_milutype_("SILU")
164  , schwarz_overlap_(0)
165  , schwarz_usereorder_(true)
166  , schwarz_combinemode_(Tpetra::ADD)
167  , schwarz_ordermethod_("rcm")
168  , GridTransfersExist_(false)
169  , isSymmetric_(true) {}
170 
171  // Destructor
172  virtual ~ShiftedLaplacian();
173 
174  // Parameters
176 
177  // Set matrices
178  void setProblemMatrix(RCP<Matrix>& A);
182  void setstiff(RCP<Matrix>& K);
184  void setmass(RCP<Matrix>& M);
186  void setcoords(RCP<MultiVector>& Coords);
187  void setNullSpace(RCP<MultiVector> NullSpace);
188  void setLevelShifts(std::vector<Scalar> levelshifts);
189 
190  // initialize: set parameters and factories, construct
191  // prolongation and restriction matrices
192  void initialize();
193  // setupFastRAP: setup hierarchy with
194  // prolongators of the stiffness matrix
195  // constant complex shifts
196  void setupFastRAP();
197  // setupSlowRAP: setup hierarchy with
198  // prolongators of the stiffness matrix
199  // variable complex shifts
200  void setupSlowRAP();
201  // setupNormalRAP: setup hierarchy with
202  // prolongators of the preconditioning matrix
203  void setupNormalRAP();
204  // setupSolver: initialize Belos solver
205  void setupSolver();
206  // resetLinearProblem: for multiple frequencies;
207  // reset the Belos operator if the frequency changes
208  void resetLinearProblem();
209 
210  // Solve phase
211  int solve(const RCP<TMV> B, RCP<TMV>& X);
212  void multigrid_apply(const RCP<MultiVector> B,
213  RCP<MultiVector>& X);
216  int GetIterations();
218 
220 
221  private:
222  // Problem options
223  // numPDEs_ -> number of DOFs at each node
224  int numPDEs_;
225 
226  // Multigrid options
227  // numLevels_ -> number of Multigrid levels
228  // coarseGridSize_ -> size of coarsest grid (if current level has less DOFs, stop coarsening)
231 
232  // Shifted Laplacian/Helmholtz parameters
233  double omega_;
234  std::vector<SC> levelshifts_;
235 
236  // Krylov solver inputs
237  // iters -> max number of iterations
238  // tol -> residual tolerance
240  double tol_;
244 
245  // Smoother parameters
257  std::string schwarz_ordermethod_;
258 
259  // flags for setup
262 
263  // Xpetra matrices
264  // K_ -> stiffness matrix
265  // M_ -> mass matrix
266  // A_ -> Problem matrix
267  // P_ -> Preconditioning matrix
270 
271  // Multigrid Hierarchy
273 
274  // Factories and prototypes
289  std::string precType_;
291 
292  // Operator and Preconditioner
295 
296 #ifdef HAVE_MUELU_TPETRA_INST_INT_INT
297  // Belos Linear Problem and Solver
298  RCP<LinearProblem> LinearProblem_;
299  RCP<SolverManager> SolverManager_;
300  RCP<SolverFactory> SolverFactory_;
301  RCP<Teuchos::ParameterList> BelosList_;
302 #endif
303 };
304 
305 } // namespace MueLu
306 
307 #define MUELU_SHIFTEDLAPLACIAN_SHORT
308 
309 #endif // if defined(HAVE_MUELU_IFPACK2) and defined(HAVE_MUELU_TPETRA)
310 
311 #endif // MUELU_SHIFTEDLAPLACIAN_DECL_HPP
RCP< SmootherFactory > coarsestSmooFact_
MueLu::DefaultLocalOrdinal LocalOrdinal
Tpetra::MultiVector< SC, LO, GO, NO > TMV
Tpetra::KokkosClassic::DefaultNode::DefaultNodeType DefaultNode
void multigrid_apply(const RCP< MultiVector > B, RCP< MultiVector > &X)
RCP< CoarseMapFactory > CoarseMapfact_
RCP< CoalesceDropFactory > Dropfact_
MueLu::DefaultNode Node
void setParameters(Teuchos::RCP< Teuchos::ParameterList > paramList)
Tpetra::Operator< SC, LO, GO, NO > OP
Teuchos::ScalarTraits< Scalar >::magnitudeType GetResidual()
RCP< SmootherPrototype > smooProto_
MueLu::DefaultScalar Scalar
Tpetra::Details::DefaultTypes::scalar_type DefaultScalar
MueLu::DefaultGlobalOrdinal GlobalOrdinal
void setLevelShifts(std::vector< Scalar > levelshifts)
Tpetra::Vector< SC, LO, GO, NO > TVEC
Teuchos::ParameterList coarsestSmooList_
void setcoords(RCP< MultiVector > &Coords)
RCP< UncoupledAggregationFactory > UCaggfact_
int solve(const RCP< TMV > B, RCP< TMV > &X)
Base class for MueLu classes.
RCP< SmootherPrototype > coarsestSmooProto_
void setProblemMatrix(RCP< Matrix > &A)
Scalar SC
RCP< Tpetra::CrsMatrix< SC, LO, GO, NO > > TpetraA_
RCP< TentativePFactory > TentPfact_
Shifted Laplacian Helmholtz solver.
RCP< MueLu::ShiftedLaplacianOperator< SC, LO, GO, NO > > MueLuOp_
RCP< AmalgamationFactory > Amalgfact_
void setNullSpace(RCP< MultiVector > NullSpace)
void setPreconditioningMatrix(RCP< Matrix > &P)