11 #include "EpetraExt_BlockMultiVector.h"
22 label(
"Stokhos Mean-Based Preconditioner"),
25 epetraCijk(epetraCijk_),
29 prec_factory(prec_factory_),
48 "Error! setupPreconditioner() cannot be called when " <<
49 "prec_factory is null!" << std::endl);
53 mean_prec = prec_factory->compute(sg_poly->
getCoeffPtr(0));
54 label = std::string(
"Stokhos Mean-Based Preconditioner:\n") +
55 std::string(
" ***** ") +
56 std::string(mean_prec->Label());
57 num_blocks = sg_basis()->size();
64 useTranspose = UseTheTranspose;
65 mean_prec->SetUseTranspose(useTranspose);
74 int myBlockRows = epetraCijk->numMyRows();
76 if (!use_block_apply) {
77 EpetraExt::BlockMultiVector sg_input(
View, *base_map, Input);
78 EpetraExt::BlockMultiVector sg_result(
View, *base_map, Result);
79 for (
int i=0; i<myBlockRows; i++) {
80 mean_prec->Apply(*(sg_input.GetBlock(i)), *(sg_result.GetBlock(i)));
85 int m = Input.NumVectors();
87 View, *base_map, Input.Values(), base_map->NumMyElements(),
90 View, *base_map, Result.Values(), base_map->NumMyElements(),
92 mean_prec->Apply(input_block, result_block);
102 int myBlockRows = epetraCijk->numMyRows();
104 if (!use_block_apply) {
105 EpetraExt::BlockMultiVector sg_input(
View, *base_map, Input);
106 EpetraExt::BlockMultiVector sg_result(
View, *base_map, Result);
107 for (
int i=0; i<myBlockRows; i++) {
108 mean_prec->ApplyInverse(*(sg_input.GetBlock(i)),
109 *(sg_result.GetBlock(i)));
114 int m = Input.NumVectors();
116 View, *base_map, Input.Values(), base_map->NumMyElements(),
119 View, *base_map, Result.Values(), base_map->NumMyElements(),
121 mean_prec->ApplyInverse(input_block, result_block);
131 return mean_prec->NormInf();
139 return const_cast<char*
>(label.c_str());
virtual const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this matrix operator. ...
virtual bool UseTranspose() const
Returns the current UseTranspose setting.
MeanBasedPreconditioner(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.
T & get(ParameterList &l, const std::string &name)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual void setupPreconditioner(const Teuchos::RCP< Stokhos::SGOperator > &sg_op, const Epetra_Vector &x)
Setup preconditioner.
virtual const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this matrix operator.
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 ...
bool use_block_apply
Flag indicating whether to use apply all vectors simultaneously.
virtual Teuchos::RCP< Stokhos::EpetraOperatorOrthogPoly > getSGPolynomial()=0
Get SG polynomial.
virtual const Epetra_Comm & Comm() const
Returns a reference to the Epetra_Comm communicator associated with this operator.
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 ...
Teuchos::RCP< coeff_type > getCoeffPtr(ordinal_type i)
Return ref-count pointer to coefficient i.
virtual int SetUseTranspose(bool UseTranspose)
Set to true if the transpose of the operator is requested.
virtual bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
virtual double NormInf() const
Returns an approximate infinity norm of the operator matrix.
virtual ~MeanBasedPreconditioner()
Destructor.
virtual const char * Label() const
Returns a character string describing the operator.