Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #include "MOR_GaussNewtonOperatorFactory.hpp"
00007
00008 #include "MOR_BasisOps.hpp"
00009
00010 #include "Epetra_Operator.h"
00011 #include "Epetra_Map.h"
00012
00013 namespace MOR {
00014
00015 using ::Teuchos::RCP;
00016
00017 template <typename Derived>
00018 GaussNewtonOperatorFactoryBase<Derived>::GaussNewtonOperatorFactoryBase(const RCP<const Epetra_MultiVector> &reducedBasis) :
00019 reducedBasis_(reducedBasis),
00020 jacobianFactory_(reducedBasis_)
00021 {
00022
00023 }
00024
00025 template <typename Derived>
00026 bool GaussNewtonOperatorFactoryBase<Derived>::fullJacobianRequired(bool residualRequested, bool jacobianRequested) const {
00027 return residualRequested || jacobianRequested;
00028 }
00029
00030 template <typename Derived>
00031 const Epetra_MultiVector &GaussNewtonOperatorFactoryBase<Derived>::leftProjection(
00032 const Epetra_MultiVector &fullVec, Epetra_MultiVector &result) const {
00033 const int err = reduce(*this->getLeftBasis(), fullVec, result);
00034 TEUCHOS_TEST_FOR_EXCEPT(err != 0);
00035 return result;
00036 }
00037
00038 template <typename Derived>
00039 RCP<Epetra_CrsMatrix> GaussNewtonOperatorFactoryBase<Derived>::reducedJacobianNew() {
00040 return jacobianFactory_.reducedMatrixNew();
00041 }
00042
00043 template <typename Derived>
00044 const Epetra_CrsMatrix &GaussNewtonOperatorFactoryBase<Derived>::reducedJacobian(Epetra_CrsMatrix &result) const {
00045 return jacobianFactory_.reducedMatrix(*this->getLeftBasis(), result);
00046 }
00047
00048 template <typename Derived>
00049 void GaussNewtonOperatorFactoryBase<Derived>::fullJacobianIs(const Epetra_Operator &op) {
00050 jacobianFactory_.fullJacobianIs(op);
00051 }
00052
00053 template <typename Derived>
00054 RCP<const Epetra_MultiVector> GaussNewtonOperatorFactoryBase<Derived>::getPremultipliedReducedBasis() const {
00055 return jacobianFactory_.premultipliedRightProjector();
00056 }
00057
00058 template <typename Derived>
00059 RCP<const Epetra_MultiVector> GaussNewtonOperatorFactoryBase<Derived>::getLeftBasis() const {
00060 return static_cast<const Derived *>(this)->leftProjectorBasis();
00061 }
00062
00063 GaussNewtonOperatorFactory::GaussNewtonOperatorFactory(const RCP<const Epetra_MultiVector> &reducedBasis) :
00064 GaussNewtonOperatorFactoryBase<GaussNewtonOperatorFactory>(reducedBasis)
00065 {
00066
00067 }
00068
00069 RCP<const Epetra_MultiVector> GaussNewtonOperatorFactory::leftProjectorBasis() const {
00070 return this->getPremultipliedReducedBasis();
00071 }
00072
00073 GaussNewtonMetricOperatorFactory::GaussNewtonMetricOperatorFactory(
00074 const RCP<const Epetra_MultiVector> &reducedBasis,
00075 const Teuchos::RCP<const Epetra_Operator> &metric) :
00076 GaussNewtonOperatorFactoryBase<GaussNewtonMetricOperatorFactory>(reducedBasis),
00077 metric_(metric),
00078 premultipliedLeftProjector_(new Epetra_MultiVector(metric->OperatorDomainMap(), reducedBasis->NumVectors(), false))
00079 {
00080 this->updatePremultipliedLeftProjector();
00081 }
00082
00083 RCP<const Epetra_MultiVector> GaussNewtonMetricOperatorFactory::leftProjectorBasis() const {
00084 return this->premultipliedLeftProjector_;
00085 }
00086
00087 void GaussNewtonMetricOperatorFactory::fullJacobianIs(const Epetra_Operator &op) {
00088 this->GaussNewtonOperatorFactoryBase<GaussNewtonMetricOperatorFactory>::fullJacobianIs(op);
00089 this->updatePremultipliedLeftProjector();
00090 }
00091
00092 void GaussNewtonMetricOperatorFactory::updatePremultipliedLeftProjector() {
00093 const int err = metric_->Apply(*this->getPremultipliedReducedBasis(), *premultipliedLeftProjector_);
00094 TEUCHOS_TEST_FOR_EXCEPT(err != 0);
00095 }
00096
00097 }