Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_SGPreconditionerFactory.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #include "Stokhos_ConfigDefs.h"
20 #include "Teuchos_Assert.hpp"
21 
24  params(params_)
25 {
26  prec_method = params->get("Preconditioner Method", "Mean-based");
27 }
28 
29 bool
32 {
33  return prec_method != "None";
34 }
35 
39  const Teuchos::RCP<const Stokhos::OrthogPolyBasis<int,double> >& sg_basis,
41  const Teuchos::RCP<const Epetra_Map>& base_map,
42  const Teuchos::RCP<const Epetra_Map>& sg_map)
43 {
45 
46  if (prec_method == "Mean-based") {
48  buildMeanPreconditionerFactory();
50  sg_comm, sg_basis, epetraCijk,
51  base_map, sg_map, prec_factory,
52  params));
53  }
54  else if (prec_method == "Approximate Gauss-Seidel") {
56  buildMeanPreconditionerFactory();
58  sg_comm, sg_basis, epetraCijk,
59  base_map, sg_map, prec_factory,
60  params));
61  }
62  else if (prec_method == "Approximate Jacobi") {
64  buildMeanPreconditionerFactory();
66  sg_comm, sg_basis, epetraCijk,
67  base_map, sg_map, prec_factory,
68  params));
69  }
70  else if (prec_method == "Approximate Schur Complement") {
72  buildMeanPreconditionerFactory();
74  sg_comm, sg_basis, epetraCijk,
75  base_map, sg_map, prec_factory,
76  params));
77  }
78 #ifdef HAVE_STOKHOS_NOX
79  else if (prec_method == "Gauss-Seidel") {
81  params->get< Teuchos::RCP<NOX::Epetra::LinearSystem> >("Deterministic Solver");
82  sg_prec = Teuchos::rcp(new Stokhos::GaussSeidelPreconditioner(
83  sg_comm, sg_basis, epetraCijk,
84  base_map, sg_map, det_solver,
85  params));
86  }
87 #endif
88  else if (prec_method == "Kronecker Product") {
90  buildMeanPreconditionerFactory();
91  std::string G_prec_name =
92  params->get("G Preconditioner Type", "Ifpack");
94  Teuchos::rcp(&(params->sublist("G Preconditioner Parameters")),false);
97  G_prec_params));
99  sg_comm, sg_basis, epetraCijk, base_map, sg_map,
100  mean_prec_factory, G_prec_factory, params));
101  }
102  else if (prec_method == "Fully Assembled") {
103  std::string prec_name =
104  params->get("Fully Assembled Preconditioner Type", "Ifpack");
106  Teuchos::rcp(&(params->sublist("Fully Assembled Preconditioner Parameters")),false);
108  Teuchos::rcp(new Stokhos::PreconditionerFactory(prec_name, prec_params));
110  prec_factory, params));
111  }
112  else if (prec_method == "None")
113  sg_prec = Teuchos::null;
114  else
115  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
116  "Error! Unknown preconditioner method " << prec_method
117  << "." << std::endl);
118 
119  return sg_prec;
120 }
121 
125 {
126  std::string prec_name =
127  params->get("Mean Preconditioner Type", "Ifpack");
129  Teuchos::rcp(&params->sublist("Mean Preconditioner Parameters"),false);
130  return Teuchos::rcp(new Stokhos::PreconditionerFactory(prec_name,
131  precParams));
132 }
A stochastic preconditioner based on applying one iteration of approximate Gauss-Seidel.
A stochastic preconditioner based on applying two iterations of approximate Jacobi.
T & get(ParameterList &l, const std::string &name)
A stochastic preconditioner based on applying the inverse of the mean.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
T * get() const
A stochastic preconditioner based on applying a preconditioner to the fully assembled operator...
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual bool isPrecSupported() const
Return whether a preconditioner will be supported.
SGPreconditionerFactory(const Teuchos::RCP< Teuchos::ParameterList > &params)
Constructor.
virtual Teuchos::RCP< Stokhos::SGPreconditioner > build(const Teuchos::RCP< const EpetraExt::MultiComm > &sg_comm, const Teuchos::RCP< const Stokhos::OrthogPolyBasis< int, double > > &sg_basis, const Teuchos::RCP< const Stokhos::EpetraSparse3Tensor > &epetraCijk, const Teuchos::RCP< const Epetra_Map > &base_map, const Teuchos::RCP< const Epetra_Map > &sg_map)
Build preconditioner operator.
Teuchos::RCP< Teuchos::ParameterList > params
Preconditioner parameters.
Teuchos::RCP< Stokhos::AbstractPreconditionerFactory > buildMeanPreconditionerFactory()
Build preconditioner factory for mean.
An class for building preconditioners.
std::string prec_method
Preconditioner method.
A stochastic preconditioner based on applying the approximate Schur complement preconditioner as defi...
An Epetra operator representing applying the mean in a block stochastic Galerkin expansion.