00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _HINES_MATRIX_H
00011 #define _HINES_MATRIX_H
00012
00013 #ifdef DO_UNIT_TESTS
00014 # define ASSERT( isOK, message ) \
00015 if ( !(isOK) ) { \
00016 cerr << "\nERROR: Assert '" << #isOK << "' failed on line " << __LINE__ << "\nin file " << __FILE__ << ": " << message << endl; \
00017 exit( 1 ); \
00018 } else { \
00019 cout << ""; \
00020 }
00021 #else
00022 # define ASSERT( unused, message ) do {} while ( false )
00023 #endif
00024
00025 struct JunctionStruct
00026 {
00027 JunctionStruct( unsigned int i, unsigned int r ) :
00028 index( i ),
00029 rank( r )
00030 {
00031 ;
00032 }
00033
00034 bool operator< ( const JunctionStruct& other ) const
00035 {
00036 return ( index < other.index );
00037 }
00038
00039 unsigned int index;
00040 unsigned int rank;
00041
00042
00043 };
00044
00045 struct TreeNodeStruct
00046 {
00047 vector< unsigned int > children;
00048 double Ra;
00049 double Rm;
00050 double Cm;
00051 double Em;
00052 double initVm;
00053 };
00054
00055 class HinesMatrix
00056 {
00057 public:
00058 HinesMatrix();
00059
00060 void setup( const vector< TreeNodeStruct >& tree, double dt );
00061
00062 unsigned int getSize() const;
00063 double getA( unsigned int row, unsigned int col ) const;
00064 double getB( unsigned int row ) const;
00065 double getVMid( unsigned int row ) const;
00066
00067 protected:
00068 typedef vector< double >::iterator vdIterator;
00069
00070 unsigned int nCompt_;
00071 double dt_;
00072
00073 vector< JunctionStruct > junction_;
00074 vector< double > HS_;
00079 vector< double > HJ_;
00082 vector< double > HJCopy_;
00083 vector< double > VMid_;
00084
00085 vector< vdIterator > operand_;
00086 vector< vdIterator > backOperand_;
00087 int stage_;
00088
00089
00090 private:
00091 void clear();
00092 void makeJunctions();
00106 void makeMatrix();
00109 void makeOperands();
00110
00111
00112 const vector< TreeNodeStruct > *tree_;
00113
00114 vector< double > Ga_;
00115 vector< vector< unsigned int > > coupled_;
00121 map< unsigned int, vdIterator > operandBase_;
00124 map< unsigned int, unsigned int > groupNumber_;
00127 };
00128
00129 #endif // _HINES_MATRIX_H