• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

MOR_ReducedBasisFactory.cpp

Go to the documentation of this file.
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 #include "MOR_ReducedBasisFactory.hpp"
00007 
00008 #include "MOR_EpetraUtils.hpp"
00009 
00010 #include "Teuchos_Ptr.hpp"
00011 #include "Teuchos_TestForException.hpp"
00012 
00013 namespace MOR {
00014 
00015 namespace Detail {
00016 
00017 ReducedBasisElements
00018 preprocessedOrigin(const ReducedBasisElements &source, const Teuchos::RCP<Teuchos::ParameterList> &params)
00019 {
00020   const std::string type = params->get("Origin", "Default");
00021 
00022   if (type == "Default") {
00023     return source;
00024   } else if (type == "Zero") {
00025     return ReducedBasisElements(source.basis);
00026   } else if (type == "First Basis Vector") {
00027     return ReducedBasisElements(nonConstHeadView(source.basis), nonConstTailView(source.basis));
00028   }
00029 
00030   TEUCHOS_TEST_FOR_EXCEPTION(
00031       true,
00032       std::invalid_argument,
00033       type << " is not a valid origin type."
00034       );
00035   return source; // Should not be reached
00036 }
00037 
00038 } // namespace Detail
00039 
00040 ReducedBasisFactory::ReducedBasisFactory()
00041 {
00042   // Nothing to do
00043 }
00044 
00045 ReducedBasisElements
00046 ReducedBasisFactory::create(const Teuchos::RCP<Teuchos::ParameterList> &params)
00047 {
00048   const Teuchos::Ptr<std::string> sourceId(params->getPtr<std::string>("Basis Source Type"));
00049 
00050   TEUCHOS_TEST_FOR_EXCEPTION(
00051       Teuchos::is_null(sourceId),
00052       std::invalid_argument,
00053       "Must provide a basis source."
00054       );
00055 
00056   const BasisSourceMap::const_iterator it = sources_.find(*sourceId);
00057 
00058   TEUCHOS_TEST_FOR_EXCEPTION(
00059       it == sources_.end(),
00060       std::invalid_argument,
00061       sourceId << " is not a valid basis source."
00062       );
00063 
00064   return Detail::preprocessedOrigin((*it->second)(params), params);
00065 }
00066 
00067 void
00068 ReducedBasisFactory::extend(const std::string &id, const Teuchos::RCP<ReducedBasisSource> &source)
00069 {
00070   sources_[id] = source;
00071 }
00072 
00073 } // namespace MOR

Generated on Wed Mar 26 2014 18:36:40 for Albany: a Trilinos-based PDE code by  doxygen 1.7.1