00001 //*****************************************************************// 00002 // Albany 2.0: Copyright 2012 Sandia Corporation // 00003 // This Software is released under the BSD license detailed // 00004 // in the file "license.txt" in the top-level Albany directory // 00005 //*****************************************************************// 00006 #ifndef MOR_TRUNCATEDUCEDBASISSOURCE_HPP 00007 #define MOR_TRUNCATEDUCEDBASISSOURCE_HPP 00008 00009 #include "MOR_ReducedBasisSource.hpp" 00010 00011 #include "MOR_EpetraMVSource.hpp" 00012 00013 #include "Teuchos_Ptr.hpp" 00014 00015 namespace MOR { 00016 00017 template <typename EpetraMVSourceProvider> 00018 class TruncatedReducedBasisSource : public ReducedBasisSource { 00019 public: 00020 explicit TruncatedReducedBasisSource(const EpetraMVSourceProvider &provider) : 00021 provider_(provider) 00022 {} 00023 00024 virtual ReducedBasisElements operator()(const Teuchos::RCP<Teuchos::ParameterList> ¶ms); 00025 00026 private: 00027 EpetraMVSourceProvider provider_; 00028 }; 00029 00030 template <typename EpetraMVSourceProvider> 00031 ReducedBasisElements 00032 TruncatedReducedBasisSource<EpetraMVSourceProvider>::operator()( 00033 const Teuchos::RCP<Teuchos::ParameterList> ¶ms) 00034 { 00035 const Teuchos::RCP<BasicEpetraMVSource> mvSource = provider_(params); 00036 00037 const Teuchos::Ptr<const int> vectorCountMax(params->getPtr<int>("Basis Size Max")); 00038 if (Teuchos::nonnull(vectorCountMax)) { 00039 return mvSource->truncatedMultiVectorNew(*vectorCountMax); 00040 } else { 00041 return mvSource->multiVectorNew();; 00042 } 00043 } 00044 00045 00046 class EpetraMVSourceInstanceProvider { 00047 public: 00048 /*implicit*/ EpetraMVSourceInstanceProvider( 00049 const Teuchos::RCP<BasicEpetraMVSource> &instance) : 00050 instance_(instance) 00051 {} 00052 00053 Teuchos::RCP<BasicEpetraMVSource> operator()( 00054 const Teuchos::RCP<Teuchos::ParameterList> &/*params*/) 00055 { 00056 return instance_; 00057 } 00058 00059 private: 00060 Teuchos::RCP<BasicEpetraMVSource> instance_; 00061 }; 00062 00063 00064 class DefaultTruncatedReducedBasisSource : 00065 public TruncatedReducedBasisSource<EpetraMVSourceInstanceProvider> { 00066 public: 00067 explicit DefaultTruncatedReducedBasisSource( 00068 const Teuchos::RCP<BasicEpetraMVSource> &instance) : 00069 TruncatedReducedBasisSource<EpetraMVSourceInstanceProvider>(instance) 00070 {} 00071 }; 00072 00073 } // end namepsace Albany 00074 00075 #endif /* MOR_TRUNCATEDUCEDBASISSOURCE_HPP */