43 #include "EpetraExt_BlockMultiVector.h"
47 const Teuchos::RCP<const EpetraExt::MultiComm>& sg_comm_,
49 const Teuchos::RCP<const Stokhos::EpetraSparse3Tensor>& epetraCijk_,
50 const Teuchos::RCP<const Epetra_Map>& base_map_,
51 const Teuchos::RCP<const Epetra_Map>& sg_map_,
52 const Teuchos::RCP<Stokhos::AbstractPreconditionerFactory>& prec_factory_,
53 const Teuchos::RCP<Teuchos::ParameterList>& params_) :
54 label(
"Stokhos Mean-Based Preconditioner"),
57 epetraCijk(epetraCijk_),
61 prec_factory(prec_factory_),
79 TEUCHOS_TEST_FOR_EXCEPTION(prec_factory == Teuchos::null, std::logic_error,
80 "Error! setupPreconditioner() cannot be called when " <<
81 "prec_factory is null!" << std::endl);
83 Teuchos::RCP<Stokhos::EpetraOperatorOrthogPoly > sg_poly =
84 sg_op->getSGPolynomial();
85 mean_prec = prec_factory->compute(sg_poly->getCoeffPtr(0));
86 label = std::string(
"Stokhos Mean-Based Preconditioner:\n") +
87 std::string(
" ***** ") +
88 std::string(mean_prec->Label());
89 num_blocks = sg_basis()->size();
96 useTranspose = UseTheTranspose;
97 mean_prec->SetUseTranspose(useTranspose);
106 int myBlockRows = epetraCijk->numMyRows();
108 if (!use_block_apply) {
109 EpetraExt::BlockMultiVector sg_input(
View, *base_map, Input);
110 EpetraExt::BlockMultiVector sg_result(
View, *base_map, Result);
111 for (
int i=0; i<myBlockRows; i++) {
112 mean_prec->Apply(*(sg_input.GetBlock(i)), *(sg_result.GetBlock(i)));
119 View, *base_map, Input.
Values(), base_map->NumMyElements(),
122 View, *base_map, Result.
Values(), base_map->NumMyElements(),
124 mean_prec->Apply(input_block, result_block);
134 int myBlockRows = epetraCijk->numMyRows();
136 if (!use_block_apply) {
137 EpetraExt::BlockMultiVector sg_input(
View, *base_map, Input);
138 EpetraExt::BlockMultiVector sg_result(
View, *base_map, Result);
139 for (
int i=0; i<myBlockRows; i++) {
140 mean_prec->ApplyInverse(*(sg_input.GetBlock(i)),
141 *(sg_result.GetBlock(i)));
148 View, *base_map, Input.
Values(), base_map->NumMyElements(),
151 View, *base_map, Result.
Values(), base_map->NumMyElements(),
153 mean_prec->ApplyInverse(input_block, result_block);
163 return mean_prec->NormInf();
171 return const_cast<char*
>(label.c_str());