fei_LinearSystem.cpp

00001 /*--------------------------------------------------------------------*/
00002 /*    Copyright 2005 Sandia Corporation.                              */
00003 /*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
00004 /*    non-exclusive license for use of this work by or on behalf      */
00005 /*    of the U.S. Government.  Export of this program may require     */
00006 /*    a license from the United States Government.                    */
00007 /*--------------------------------------------------------------------*/
00008 
00009 #include <fei_macros.hpp>
00010 
00011 #include <fei_MatrixGraph.hpp>
00012 #include <fei_LinearSystem.hpp>
00013 #include <snl_fei_LinearSystem_General.hpp>
00014 #include <snl_fei_Utils.hpp>
00015 
00016 //----------------------------------------------------------------------------
00017 fei::LinearSystem::LinearSystem(fei::SharedPtr<fei::MatrixGraph>& matrixGraph)
00018  : matrix_(),
00019    soln_(),
00020    rhs_(),
00021    matrixGraph_(matrixGraph),
00022    dbcManager_(NULL)
00023 {
00024 }
00025 
00026 //----------------------------------------------------------------------------
00027 fei::LinearSystem::~LinearSystem()
00028 {
00029   delete dbcManager_;
00030 
00031   for(unsigned i=0; i<attributeNames_.size(); ++i) {
00032     delete [] attributeNames_[i];
00033   }
00034 }
00035 
00036 //----------------------------------------------------------------------------
00037 fei::SharedPtr<fei::LinearSystem>
00038 fei::LinearSystem::Factory::createLinearSystem(fei::SharedPtr<fei::MatrixGraph>& matrixGraph)
00039 {
00040   fei::SharedPtr<fei::LinearSystem>
00041     linsys(new snl_fei::LinearSystem_General(matrixGraph));
00042 
00043   return(linsys);
00044 }
00045 
00046 //----------------------------------------------------------------------------
00047 void fei::LinearSystem::setMatrix(fei::SharedPtr<fei::Matrix>& matrix)
00048 {
00049   matrix_ = matrix;
00050 }
00051 
00052 //----------------------------------------------------------------------------
00053 int fei::LinearSystem::putAttribute(const char* name,
00054                                     void* attribute)
00055 {
00056   snl_fei::storeNamedAttribute(name, attribute,
00057                                attributeNames_, attributes_);
00058   return(0);
00059 }
00060 
00061 //----------------------------------------------------------------------------
00062 int fei::LinearSystem::getAttribute(const char* name,
00063                                     void*& attribute)
00064 {
00065   attribute = snl_fei::retrieveNamedAttribute(name, attributeNames_, attributes_);
00066   return(attribute==NULL ? -1 : 0);
00067 }
00068 
00069 //----------------------------------------------------------------------------
00070 int fei::LinearSystem::loadEssentialBCs(int numIDs,
00071                                  const int* IDs,
00072                                  int idType,
00073                                  int fieldID,
00074                                  int offsetIntoField,
00075                                  const double* prescribedValues)
00076 {
00077   if (dbcManager_ == NULL) {
00078     dbcManager_ = new fei::DirichletBCManager(matrixGraph_->getRowSpace());
00079   }
00080 
00081   try {
00082     dbcManager_->addBCRecords(numIDs, idType, fieldID, offsetIntoField,
00083                               IDs, prescribedValues);
00084   }
00085   catch(std::runtime_error& exc) {
00086     FEI_CERR << exc.what()<<FEI_ENDL;
00087     return(-1);
00088   }
00089 
00090   return(0);
00091 }
00092 
00093 //----------------------------------------------------------------------------
00094 int fei::LinearSystem::loadEssentialBCs(int numIDs,
00095                                  const int* IDs,
00096                                  int idType,
00097                                  int fieldID,
00098                                  const int* offsetsIntoField,
00099                                  const double* prescribedValues)
00100 {
00101   if (dbcManager_ == NULL) {
00102     dbcManager_ = new fei::DirichletBCManager(matrixGraph_->getRowSpace());
00103   }
00104 
00105   try {
00106     dbcManager_->addBCRecords(numIDs, idType, fieldID, IDs, offsetsIntoField,
00107                               prescribedValues);
00108   }
00109   catch(std::runtime_error& exc) {
00110     FEI_CERR << exc.what()<<FEI_ENDL;
00111     return(-1);
00112   }
00113 
00114   return(0);
00115 }
00116 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends
Generated on Wed Apr 13 10:08:23 2011 for FEI by  doxygen 1.6.3