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

Main_Analysis.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 <iostream>
00007 
00008 #include "Albany_Utils.hpp"
00009 #include "Albany_SolverFactory.hpp"
00010 #include "Thyra_EpetraModelEvaluator.hpp"
00011 #include "Piro_PerformAnalysis.hpp"
00012 #include "Thyra_VectorBase.hpp"
00013 #include "Teuchos_GlobalMPISession.hpp"
00014 #include "Teuchos_TimeMonitor.hpp"
00015 #include "Teuchos_VerboseObject.hpp"
00016 #include "Teuchos_StandardCatchMacros.hpp"
00017 
00018 
00019 int main(int argc, char *argv[]) {
00020 
00021   int status=0; // 0 = pass, failures are incremented
00022   bool success = true;
00023   Teuchos::GlobalMPISession mpiSession(&argc,&argv);
00024   Teuchos::RCP<Teuchos::FancyOStream> out(Teuchos::VerboseObjectBase::getDefaultOStream());
00025 
00026   // Command-line argument for input file
00027   char * xmlfilename=0;
00028   char defaultfile[20]={"inputAnalysis.xml"};
00029   if(argc>1){
00030     if(!strcmp(argv[1],"--help")){
00031       printf("albanyAnalysis [inputfile.xml]\n");
00032       exit(1);
00033     }
00034     else
00035       xmlfilename=argv[1];
00036   }
00037   else
00038     xmlfilename=defaultfile;
00039 
00040 
00041   try {
00042     Teuchos::RCP<Teuchos::Time> totalTime = 
00043       Teuchos::TimeMonitor::getNewTimer("AlbanyAnalysis: ***Total Time***");
00044     Teuchos::TimeMonitor totalTimer(*totalTime); //start timer
00045 
00046     using namespace std;
00047 
00048     *out << "\nStarting Albany Analysis via Piro!" << std::endl;
00049 
00050     // Construct a ModelEvaluator for your application;
00051   
00052     Teuchos::RCP<Albany::SolverFactory> slvrfctry =
00053       Teuchos::rcp(new Albany::SolverFactory(xmlfilename, Albany_MPI_COMM_WORLD));
00054     Teuchos::RCP<Epetra_Comm> appComm = Albany::createEpetraCommFromMpiComm(Albany_MPI_COMM_WORLD);
00055     Teuchos::RCP<EpetraExt::ModelEvaluator> App = slvrfctry->create(appComm, appComm);
00056 
00057 
00058     Thyra::EpetraModelEvaluator appThyra;
00059     appThyra.initialize(App, Teuchos::null);
00060 
00061     Teuchos::RCP< Thyra::VectorBase<double> > p;
00062 
00063     // If no analysis section set in input file, default to simple "Solve"
00064     std::string analysisPackage = slvrfctry->getAnalysisParameters().get("Analysis Package","Solve");
00065     status = Piro::PerformAnalysis(appThyra, slvrfctry->getAnalysisParameters(), p); 
00066 
00067 //    Dakota::RealVector finalValues = dakota.getFinalSolution().continuous_variables();
00068 //    std::cout << "\nAlbany_Dakota: Final Values from Dakota = " 
00069 //         << setprecision(8) << finalValues << std::endl;
00070 
00071     status =  slvrfctry->checkAnalysisTestResults(0, p);
00072 
00073     // Regression comparisons for Dakota runs only valid on Proc 0.
00074     if (mpiSession.getRank()>0)  status=0;
00075     else *out << "\nNumber of Failed Comparisons: " << status << std::endl;
00076   }
00077   TEUCHOS_STANDARD_CATCH_STATEMENTS(true, std::cerr, success);
00078   if (!success) status+=10000;
00079   
00080   Teuchos::TimeMonitor::summarize(std::cout, false, true, false);
00081   return status;
00082 }

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