23 label(
"Stokhos Approximate Jacobi Preconditioner"),
26 epetraCijk(epetraCijk_),
29 prec_factory(prec_factory_),
37 num_iter = params_->
get(
"Number of Jacobi Iterations", 2);
41 sgOpParams->
set(
"Include Mean",
false);
42 if (!sgOpParams->
isParameter(
"Only Use Linear Terms"))
43 sgOpParams->
set(
"Only Use Linear Terms",
true);
49 if (sgOpParams->
get<
bool>(
"Only Use Linear Terms") &&
74 mean_prec = prec_factory->compute(sg_poly->getCoeffPtr(0));
75 label = std::string(
"Stokhos Approximate Jacobi Preconditioner:\n") +
76 std::string(
" ***** ") +
77 std::string(mean_prec->Label());
78 mat_free_op->setupOperator(sg_poly);
85 useTranspose = UseTranspose;
86 sg_op->SetUseTranspose(UseTranspose);
87 mat_free_op->SetUseTranspose(UseTranspose);
88 mean_prec->SetUseTranspose(UseTranspose);
97 return sg_op->Apply(Input, Result);
104 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR
111 bool made_copy =
false;
112 if (Input.Values() == Result.Values()) {
117 int m = input->NumVectors();
118 if (rhs_block ==
Teuchos::null || rhs_block->NumVectors() != m)
120 Teuchos::rcp(
new EpetraExt::BlockMultiVector(*base_map, *sg_map, m));
123 EpetraExt::BlockMultiVector input_block(
View, *base_map, *input);
124 EpetraExt::BlockMultiVector result_block(
View, *base_map, Result);
126 int myBlockRows = epetraCijk->numMyRows();
127 result_block.PutScalar(0.0);
128 for (
int iter=0; iter<num_iter; iter++) {
132 rhs_block->Update(1.0, input_block, 0.0);
134 mat_free_op->Apply(result_block, *rhs_block);
135 rhs_block->Update(1.0, input_block, -1.0);
139 for(
int i=0; i<myBlockRows; i++) {
140 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR
143 mean_prec->ApplyInverse(*(rhs_block->GetBlock(i)),
144 *(result_block.GetBlock(i)));
159 return sg_op->NormInf();
167 return const_cast<char*
>(label.c_str());
181 return sg_op->HasNormInf();
virtual const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this matrix operator. ...
#define TEUCHOS_FUNC_TIME_MONITOR(FUNCNAME)
virtual const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this matrix operator.
Teuchos::RCP< const EpetraExt::MultiComm > sg_comm
Stores SG parallel communicator.
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of the inverse of the operator applied to a Epetra_MultiVector Input in Result as ...
T & get(ParameterList &l, const std::string &name)
Teuchos::RCP< const Epetra_Map > sg_map
Stores SG map.
virtual const Epetra_Comm & Comm() const
Returns a reference to the Epetra_Comm communicator associated with this operator.
virtual ~ApproxJacobiPreconditioner()
Destructor.
Teuchos::RCP< const Stokhos::EpetraSparse3Tensor > epetraCijk
Stores Epetra Cijk tensor.
RCP< ParameterList > sublist(const RCP< ParameterList > ¶mList, const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
Teuchos::RCP< const Epetra_Map > base_map
Stores base map.
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Teuchos::RCP< Stokhos::SGOperator > mat_free_op
SG operator to implement SG mat-vec.
virtual ordinal_type dimension() const =0
Return dimension of basis.
int num_iter
Number of Jacobi iterations.
bool isParameter(const std::string &name) const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual Teuchos::RCP< Stokhos::SGOperator > 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 > &domain_base_map, const Teuchos::RCP< const Epetra_Map > &range_base_map, const Teuchos::RCP< const Epetra_Map > &domain_sg_map, const Teuchos::RCP< const Epetra_Map > &range_sg_map)
Build preconditioner operator.
virtual Teuchos::RCP< Stokhos::EpetraOperatorOrthogPoly > getSGPolynomial()=0
Get SG polynomial.
virtual int SetUseTranspose(bool UseTranspose)
Set to true if the transpose of the operator is requested.
virtual void setupPreconditioner(const Teuchos::RCP< Stokhos::SGOperator > &sg_op, const Epetra_Vector &x)
Setup preconditioner.
virtual bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
Teuchos::RCP< const Stokhos::OrthogPolyBasis< int, double > > sg_basis
Stochastic Galerking basis.
ApproxJacobiPreconditioner(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, const Teuchos::RCP< Stokhos::AbstractPreconditionerFactory > &prec_factory, const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Constructor.
Factory for generating stochastic Galerkin preconditioners.
virtual int Apply(const Epetra_MultiVector &Input, Epetra_MultiVector &Result) const
Returns the result of a Epetra_Operator applied to a Epetra_MultiVector Input in Result as described ...
virtual bool UseTranspose() const
Returns the current UseTranspose setting.
virtual const char * Label() const
Returns a character string describing the operator.
virtual double NormInf() const
Returns an approximate infinity norm of the operator matrix.