55 label(
"Stokhos Approximate Jacobi Preconditioner"),
58 epetraCijk(epetraCijk_),
61 prec_factory(prec_factory_),
69 num_iter = params_->
get(
"Number of Jacobi Iterations", 2);
73 sgOpParams->
set(
"Include Mean",
false);
74 if (!sgOpParams->
isParameter(
"Only Use Linear Terms"))
75 sgOpParams->
set(
"Only Use Linear Terms",
true);
81 if (sgOpParams->
get<
bool>(
"Only Use Linear Terms") &&
106 mean_prec = prec_factory->compute(sg_poly->getCoeffPtr(0));
107 label = std::string(
"Stokhos Approximate Jacobi Preconditioner:\n") +
108 std::string(
" ***** ") +
109 std::string(mean_prec->Label());
110 mat_free_op->setupOperator(sg_poly);
117 useTranspose = UseTranspose;
118 sg_op->SetUseTranspose(UseTranspose);
119 mat_free_op->SetUseTranspose(UseTranspose);
120 mean_prec->SetUseTranspose(UseTranspose);
129 return sg_op->Apply(Input, Result);
136 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR
143 bool made_copy =
false;
144 if (Input.Values() == Result.Values()) {
149 int m = input->NumVectors();
150 if (rhs_block ==
Teuchos::null || rhs_block->NumVectors() != m)
152 Teuchos::rcp(
new EpetraExt::BlockMultiVector(*base_map, *sg_map, m));
155 EpetraExt::BlockMultiVector input_block(
View, *base_map, *input);
156 EpetraExt::BlockMultiVector result_block(
View, *base_map, Result);
158 int myBlockRows = epetraCijk->numMyRows();
159 result_block.PutScalar(0.0);
160 for (
int iter=0; iter<num_iter; iter++) {
164 rhs_block->Update(1.0, input_block, 0.0);
166 mat_free_op->Apply(result_block, *rhs_block);
167 rhs_block->Update(1.0, input_block, -1.0);
171 for(
int i=0; i<myBlockRows; i++) {
172 #ifdef STOKHOS_TEUCHOS_TIME_MONITOR
175 mean_prec->ApplyInverse(*(rhs_block->GetBlock(i)),
176 *(result_block.GetBlock(i)));
191 return sg_op->NormInf();
199 return const_cast<char*
>(label.c_str());
213 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.
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
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.
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.