FEI  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fei_LinearSystem.cpp
1 /*--------------------------------------------------------------------*/
2 /* Copyright 2005 Sandia Corporation. */
3 /* Under the terms of Contract DE-AC04-94AL85000, there is a */
4 /* non-exclusive license for use of this work by or on behalf */
5 /* of the U.S. Government. Export of this program may require */
6 /* a license from the United States Government. */
7 /*--------------------------------------------------------------------*/
8 
9 #include <fei_macros.hpp>
10 
11 #include <fei_MatrixGraph.hpp>
12 #include <fei_LinearSystem.hpp>
13 #include <snl_fei_LinearSystem_General.hpp>
14 #include <snl_fei_Utils.hpp>
15 
16 //----------------------------------------------------------------------------
18  : matrix_(),
19  soln_(),
20  rhs_(),
21  matrixGraph_(matrixGraph),
22  dbcManager_(NULL)
23 {
24 }
25 
26 //----------------------------------------------------------------------------
28 {
29  delete dbcManager_;
30 
31  for(unsigned i=0; i<attributeNames_.size(); ++i) {
32  delete [] attributeNames_[i];
33  }
34 }
35 
36 //----------------------------------------------------------------------------
38 fei::LinearSystem::Factory::createLinearSystem(fei::SharedPtr<fei::MatrixGraph>& matrixGraph)
39 {
41  linsys(new snl_fei::LinearSystem_General(matrixGraph));
42 
43  return(linsys);
44 }
45 
46 //----------------------------------------------------------------------------
48 {
49  matrix_ = matrix;
50 }
51 
52 //----------------------------------------------------------------------------
53 int fei::LinearSystem::putAttribute(const char* name,
54  void* attribute)
55 {
56  snl_fei::storeNamedAttribute(name, attribute,
57  attributeNames_, attributes_);
58  return(0);
59 }
60 
61 //----------------------------------------------------------------------------
62 int fei::LinearSystem::getAttribute(const char* name,
63  void*& attribute)
64 {
65  attribute = snl_fei::retrieveNamedAttribute(name, attributeNames_, attributes_);
66  return(attribute==NULL ? -1 : 0);
67 }
68 
69 //----------------------------------------------------------------------------
71  const int* IDs,
72  int idType,
73  int fieldID,
74  int offsetIntoField,
75  const double* prescribedValues)
76 {
77  if (dbcManager_ == NULL) {
78  dbcManager_ = new fei::DirichletBCManager(matrixGraph_->getRowSpace());
79  }
80 
81  try {
82  dbcManager_->addBCRecords(numIDs, idType, fieldID, offsetIntoField,
83  IDs, prescribedValues);
84  }
85  catch(std::runtime_error& exc) {
86  fei::console_out() << exc.what()<<FEI_ENDL;
87  return(-1);
88  }
89 
90  return(0);
91 }
92 
93 //----------------------------------------------------------------------------
95  const int* IDs,
96  int idType,
97  int fieldID,
98  const int* offsetsIntoField,
99  const double* prescribedValues)
100 {
101  if (dbcManager_ == NULL) {
102  dbcManager_ = new fei::DirichletBCManager(matrixGraph_->getRowSpace());
103  }
104 
105  try {
106  dbcManager_->addBCRecords(numIDs, idType, fieldID, IDs, offsetsIntoField,
107  prescribedValues);
108  }
109  catch(std::runtime_error& exc) {
110  fei::console_out() << exc.what()<<FEI_ENDL;
111  return(-1);
112  }
113 
114  return(0);
115 }
116 
virtual void setMatrix(fei::SharedPtr< fei::Matrix > &matrix)
virtual int loadEssentialBCs(int numIDs, const int *IDs, int idType, int fieldID, int offsetIntoField, const double *prescribedValues)
std::ostream & console_out()
virtual int putAttribute(const char *name, void *attribute)
virtual int getAttribute(const char *name, void *&attribute)
LinearSystem(fei::SharedPtr< fei::MatrixGraph > &matrixGraph)