00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #include "Teko_LU2x2InverseOp.hpp"
00048
00049 #include "Thyra_DefaultProductVectorSpace.hpp"
00050 #include "Thyra_ProductMultiVectorBase.hpp"
00051 #include "Thyra_DefaultMultipliedLinearOp.hpp"
00052 #include "Thyra_MultiVectorStdOps.hpp"
00053
00054 using namespace Thyra;
00055 using Teuchos::RCP;
00056 using Teuchos::ArrayRCP;
00057 using Teuchos::dyn_cast;
00058
00059 namespace Teko {
00060
00061
00063 LU2x2InverseOp::LU2x2InverseOp(const BlockedLinearOp & A,
00064 const LinearOp & invA00,
00065 const LinearOp & invS)
00066 : A_(A), hatInvA00_(invA00), tildeInvA00_(invA00), invS_(invS),
00067 A10_(A->getBlock(1,0)), A01_(A->getBlock(0,1))
00068 {
00069 using Teuchos::tuple;
00070 using Thyra::productVectorSpace;
00071
00072
00073 productRange_ = productVectorSpace<double>(tuple(hatInvA00_->range(), invS_->range())());
00074
00075
00076 productDomain_ = productVectorSpace<double>(tuple(hatInvA00_->domain(), invS_->domain())());
00077 }
00078
00090 LU2x2InverseOp::LU2x2InverseOp(const BlockedLinearOp & A,
00091 const LinearOp & hatInvA00,
00092 const LinearOp & tildeInvA00,
00093 const LinearOp & invS)
00094 : A_(A), hatInvA00_(hatInvA00), tildeInvA00_(tildeInvA00), invS_(invS),
00095 A10_(A->getBlock(1,0)), A01_(A->getBlock(0,1))
00096 {
00097 using Teuchos::tuple;
00098 using Thyra::productVectorSpace;
00099
00100
00101 productRange_ = productVectorSpace<double>(tuple(hatInvA00_->range(), invS_->range())());
00102
00103
00104 productDomain_ = productVectorSpace<double>(tuple(hatInvA00_->domain(), invS_->domain()));
00105 }
00106
00107 void LU2x2InverseOp::implicitApply(const BlockedMultiVector & x, BlockedMultiVector & y,
00108 const double alpha, const double beta) const
00109 {
00110
00111 MultiVector f = getBlock(0,x);
00112 MultiVector g = getBlock(1,x);
00113
00114
00115 MultiVector ps = deepcopy(g);
00116
00117
00118 MultiVector u = getBlock(0,y);
00119 MultiVector p = getBlock(1,y);
00120
00121
00122 MultiVector uc,pc;
00123 if(beta!=0) {
00124
00125 uc = deepcopy(u);
00126 pc = deepcopy(p);
00127 } else {
00128
00129
00130
00131
00132 uc = u;
00133 pc = p;
00134 }
00135
00136
00137 LinearOp invA00_A01 = Thyra::multiply(tildeInvA00_,A01_);
00138
00139
00140 applyOp(hatInvA00_, f, uc);
00141 applyOp(A10_, uc, ps, -1.0, 1.0);
00142 applyOp(invS_, ps, pc, -1.0);
00143 applyOp(invA00_A01, pc, uc, -1.0, 1.0);
00144
00145
00146 if(beta!=0) {
00147 update(alpha,uc,beta,u);
00148 update(alpha,pc,beta,p);
00149 }
00150 else if(alpha!=1.0) {
00151 scale(alpha,u);
00152 scale(alpha,p);
00153 }
00154 }
00155
00156 void LU2x2InverseOp::describe(Teuchos::FancyOStream & out_arg,
00157 const Teuchos::EVerbosityLevel verbLevel) const
00158 {
00159 using Teuchos::OSTab;
00160
00161 RCP<Teuchos::FancyOStream> out = rcp(&out_arg,false);
00162 OSTab tab(out);
00163 switch(verbLevel) {
00164 case Teuchos::VERB_DEFAULT:
00165 case Teuchos::VERB_LOW:
00166 *out << this->description() << std::endl;
00167 break;
00168 case Teuchos::VERB_MEDIUM:
00169 case Teuchos::VERB_HIGH:
00170 case Teuchos::VERB_EXTREME:
00171 {
00172 *out << Teuchos::Describable::description() << "{"
00173 << "rangeDim=" << this->range()->dim()
00174 << ",domainDim=" << this->domain()->dim()
00175 << "}\n";
00176 {
00177 OSTab tab(out);
00178 *out << "[invS]:\n";
00179 *out << Teuchos::describe(*invS_,verbLevel);
00180
00181 *out << "[hatInvA00]:\n";
00182 *out << Teuchos::describe(*hatInvA00_,verbLevel);
00183
00184 *out << "[tildeInvA00]:\n";
00185 *out << Teuchos::describe(*tildeInvA00_,verbLevel);
00186
00187 *out << "[A_10]:\n";
00188 *out << Teuchos::describe(*A10_,verbLevel);
00189
00190 *out << "[A_01]:\n";
00191 *out << Teuchos::describe(*A01_,verbLevel);
00192 }
00193 break;
00194 }
00195 default:
00196 TEUCHOS_TEST_FOR_EXCEPT(true);
00197 }
00198 }
00199
00200 }