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

MOR_DefaultSampleDofListProviders.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 
00007 #include "MOR_DefaultSampleDofListProviders.hpp"
00008 
00009 #include "MOR_EpetraUtils.hpp"
00010 
00011 #include "Epetra_BlockMap.h"
00012 
00013 #include "Teuchos_Array.hpp"
00014 #include "Teuchos_XMLParameterListHelpers.hpp"
00015 
00016 namespace MOR {
00017 
00018 AllSampleDofListProvider::AllSampleDofListProvider(const Teuchos::RCP<const Epetra_BlockMap> &map) :
00019   map_(map)
00020 {
00021   // Nothing to do
00022 }
00023 
00024 Teuchos::Array<int>
00025 AllSampleDofListProvider::operator()(const Teuchos::RCP<Teuchos::ParameterList> &/*params*/)
00026 {
00027   Teuchos::Array<int> result;
00028   const int entryCount = map_->NumMyElements();
00029   result.reserve(entryCount);
00030   for (int i = 0; i < entryCount; ++i) {
00031     result.push_back(i);
00032   }
00033   return result;
00034 }
00035 
00036 namespace { // anonymous
00037 
00038 inline
00039 Teuchos::Array<int>
00040 getDofListFromParam(const Teuchos::ParameterList &params)
00041 {
00042   return Teuchos::getParameter<Teuchos::Array<int> >(params, "Sample Dof List");
00043 }
00044 
00045 } // end anonymous namespace
00046 
00047 InlineSampleDofListProvider::InlineSampleDofListProvider(const Teuchos::RCP<const Epetra_BlockMap> &map) :
00048   map_(map)
00049 {
00050   // Nothing to do
00051 }
00052 
00053 Teuchos::Array<int>
00054 InlineSampleDofListProvider::operator()(const Teuchos::RCP<Teuchos::ParameterList> &params)
00055 {
00056   return getMyLIDs(*map_, getDofListFromParam(*params));
00057 }
00058 
00059 XMLFileSampleDofListProvider::XMLFileSampleDofListProvider(const Teuchos::RCP<const Epetra_BlockMap> &map) :
00060   map_(map)
00061 {
00062   // Nothing to do
00063 }
00064 
00065 Teuchos::Array<int>
00066 XMLFileSampleDofListProvider::operator()(const Teuchos::RCP<Teuchos::ParameterList> &params)
00067 {
00068   const std::string path = Teuchos::getParameter<std::string>(*params, "Sample Dof Input File Name");
00069   const Teuchos::RCP<const Teuchos::ParameterList> sampleDofsParams = Teuchos::getParametersFromXmlFile(path);
00070   return getMyLIDs(*map_, getDofListFromParam(*sampleDofsParams));
00071 }
00072 
00073 Teuchos::RCP<SampleDofListFactory> defaultSampleDofListFactoryNew(const Teuchos::RCP<const Epetra_BlockMap> &map)
00074 {
00075   const Teuchos::RCP<SampleDofListFactory> result(new SampleDofListFactory);
00076 
00077   result->extend("All", Teuchos::rcp(new AllSampleDofListProvider(map)));
00078   result->extend("Inline", Teuchos::rcp(new InlineSampleDofListProvider(map)));
00079   result->extend("File", Teuchos::rcp(new XMLFileSampleDofListProvider(map)));
00080 
00081   return result;
00082 }
00083 
00084 } // namespace MOR

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