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

AAdapt_AdaptiveModelFactory.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 "AAdapt_AdaptiveModelFactory.hpp"
00007 #include "AAdapt_ThyraAdaptiveModelEvaluator.hpp"
00008 
00009 #include <string>
00010 #include <stdexcept>
00011 
00012 namespace AAdapt {
00013 
00014 using ::Teuchos::RCP;
00015 using ::Teuchos::rcp;
00016 using ::Teuchos::nonnull;
00017 using ::Teuchos::ParameterList;
00018 using ::Teuchos::sublist;
00019 using ::Teuchos::Tuple;
00020 using ::Teuchos::tuple;
00021 
00022 AdaptiveModelFactory::AdaptiveModelFactory(
00023   const RCP<ParameterList>& parentParams) :
00024   params(extractAdaptiveModelParams(parentParams)) {
00025   // Nothing to do
00026 }
00027 
00028 AdaptiveModelFactory::~AdaptiveModelFactory(){
00029    // Prevent circular RCP references by releasing RCP on destruction
00030    thyra_model = Teuchos::null;
00031 #ifdef ALBANY_DEBUG
00032   std::cout << "Calling destructor for Albany_AdaptiveModelFactory" << std::endl;
00033 #endif
00034 }
00035 
00036 RCP<ParameterList> AdaptiveModelFactory::extractAdaptiveModelParams(const RCP<ParameterList>& params_) {
00037 
00038   const Teuchos::RCP<Teuchos::ParameterList>& problemParams =
00039     Teuchos::sublist(params_, "Problem", true);
00040 
00041   if(problemParams->isSublist("Adaptation")) { // If the user has specified adaptation on input, grab the sublist
00042 
00043     return sublist(problemParams, "Adaptation");
00044 
00045   }
00046 
00047   return Teuchos::null;
00048 
00049 }
00050 
00051 Teuchos::RCP<Thyra::ModelEvaluator<double> > 
00052 AdaptiveModelFactory::create(const Teuchos::RCP<EpetraExt::ModelEvaluator>& child,
00053          const Teuchos::RCP<Thyra::LinearOpWithSolveFactoryBase<double> > &W_factory){
00054   Teuchos::RCP<Thyra::ModelEvaluator<double> > result;
00055   if(useAdaptiveModel()) {
00056       result = Teuchos::rcp(new ThyraAdaptiveModelEvaluator(child, W_factory));
00057   }
00058   else {
00059       result = Thyra::epetraModelEvaluator(child, W_factory);
00060   }
00061 
00062   // Keep only a weak pointer as member to avoid circular references
00063 //  thyra_model = result.create_weak();
00064   thyra_model = result;
00065 
00066   return result;
00067 }
00068 
00069 bool AdaptiveModelFactory::useAdaptiveModel() const {
00070 
00071   if(Teuchos::nonnull(params)){
00072 
00073     return true;
00074 
00075   }
00076 
00077   return false;
00078 
00079 }
00080 
00081 } // namespace AAdapt

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