profmatr.h

Go to the documentation of this file.
00001 //#############################################################################
00002 //                                                                            #
00003 //                                                                            #
00004 //             /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/~~\                #
00005 //            |                                          |____|               #
00006 //            |                                          |                    #
00007 //            |                                          |                    #
00008 //            |                                          |                    #
00009 //            |                                          |                    #
00010 //            |        B A S E   C L A S S E S           |                    #
00011 //            |                                          |                    #
00012 //            |                                          |                    #
00013 //            |                                          |                    #
00014 //            |                                          |                    #
00015 //            |          C + +     H E A D E R           |                    #
00016 //            |                                          |                    #
00017 //            |                                          |                    #
00018 //            |                                          |                    #
00019 //            |                                          |                    #
00020 //         /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/   |                    #
00021 //         \_________________________________________\__/                     #
00022 //                                                                            #
00023 //                                                                            #
00024 //##############################################################################
00025 //# COPYRIGHT (C):     :-))                                                    #
00026 //# PROJECT:           Object Oriented Finite Element Program                  #
00027 //# PURPOSE:                                                                   #
00028 //# CLASS:             profilematrix                                               #
00029 //#                                                                            #
00030 //# VERSION:                                                                   #
00031 //# LANGUAGE:          C++.ver >= 2.0 ( Borland C++ ver=3.10, SUN C++ ver=2.1 )#
00032 //# TARGET OS:         DOS || UNIX || . . .                                    #
00033 //# PROGRAMMER(S):     Boris Jeremic                                           #
00034 //#                                                                            #
00035 //#                                                                            #
00036 //# DATE:              September 13 '94 Unsymmetric Solver -> profile solver   #
00037 //#                                     ( see FEM4ed by O.Z. and R.T.)         #
00038 //#                                                                            #
00039 //# UPDATE HISTORY:    September 27 '94 profile solver for symmetric and       #
00040 //#                                     Nonsymmetric systems works!            #
00041 //#                                     (from FEM4ed by O.Z. and R.T.)         #
00042 //#                                                                            #
00043 //#                                                                            #
00044 //##############################################################################
00045 // Profile Sparse Matrix Class
00046 // this one is based on Zienkiewicz's and Taylor's book!
00047 
00048 #ifndef PROFMATR_HH
00049 #define PROFMATR_HH
00050 
00051 #include <basics.h>
00052 
00053 #include <BJvector.h>
00054 
00055 //tempout#include <femdata.h>
00056 //tempout#include <brick3d.h>
00057 //tempout#include <node.h>
00058 //tempout#include <stifmat.h>
00059 
00060 
00061 
00062 class profilematrix_rep
00063   {
00064     public:
00065       friend class profilematrix;
00066     private:
00067       double *al;   // lower triangular part of matrix
00068       double *au;   // upper triangular part of matrix
00069       double *ad;   // diagonals of triangular of matrix
00070       //double max_element;   // max ele. of  matrix
00071       //double min_element;   // min ele. of  matrix
00072 
00073       int *jp;      // pointers to bottom of columns of al and au arrays
00074       
00075       int * columnheight;    // pointers to the height of each column may be replaced by jp __Zhaohui
00076 
00077       int neq;      // dimension of a system ( as square matrix )
00078 
00079       int total_numb; // total nubmer of elements in al and/or au
00080 
00081       char flag;    // if flag=='S' symmetric; if flag=='N' NON(un)symmetric
00082 
00083       int n;        // reference count
00084 
00085     public:
00086 // overloading operator new and delete in profilematrix_rep class  ########
00087       void * operator new(size_t s); // see C++ reference manual by
00088       void operator delete(void *);  // by ELLIS and STROUSTRUP page 283.
00089                                    // and ECKEL page 529.
00090   };
00091 
00092 
00093 class profilematrix
00094   {
00095     private:
00096       profilematrix_rep * pc_profilematrix_rep;
00097     public:
00098 // I don't need default constructor, this is not a very common data type!!!!!!!!!!!
00099 //      profilematrix(int matrix_order=1, double init_value=0.0 ); // default constructor
00100 // this constructor just for testing purposes!
00101       
00102 //tempout      profilematrix(FEModelData & FEMD, 
00103 //tempout                         Brick3D * b3d, 
00104 //tempout                        Node *  node);
00105 
00106       profilematrix(int matrix_order,
00107                     int *jp_init,
00108                     char flag_init,
00109                     double *au_init_val,
00110                     double *al_init_val,
00111                     double *ad_init_val);
00112 // The real constructor. This one will be initialized to the original size
00113 // with the init_val values and then in stiffness matrix class those
00114 // default inti_val values will be altered ( to the right stiffness ).
00115       profilematrix(int matrix_order,
00116                     int *jp_init,
00117                     char flag_init,
00118                     double au_init_val,
00119                     double al_init_val,
00120                     double ad_init_val);
00121 //      skymatrix(char *flag, int dimension ); // create an ident skymatrix
00122       profilematrix(const profilematrix & x); // copy-initializer
00123       ~profilematrix();
00124 
00125 
00126       int dimension_of_profile_M(void ) const; // dimension of profile matrix
00127       int *get_jp(void) const; // get pointer to array of
00128                               // Locations of Diagonals
00129       profilematrix  &operator=(const profilematrix & rval); // profilematrix assignment
00130 
00131 //....// This is from JOOP May/June 1990 after ARKoenig
00132       profilematrix& operator +=( const profilematrix & ); // profilematrix addition
00133       friend profilematrix operator+(const profilematrix & , const profilematrix & ); // profilematrix addition
00134 //....// This is from JOOP May/June 1990 after ARKoenig
00135       profilematrix& operator -=( const profilematrix & ); // profilematrix subtraction
00136       friend profilematrix operator-(const profilematrix & , const profilematrix & ); // profilematrix subtraction
00137 
00138       profilematrix operator+( double   rval);  // scalar addition
00139       profilematrix operator-( double   rval);  // scalar subtraction
00140       profilematrix operator*( double   rval);  // scalar multiplication
00141       double  *     operator*( BJvector  &arg);  // profile multiplied by vector__Zhaohui 
00142 
00143 //......    nDarray deep_copy( ); // make an image
00144 
00145 //      int operator==( profilematrix & rval);  // profilematrix comparisson
00146 //                                             // returns 1 if they are same
00147 //                                             // returns 0 if they are not
00148 
00149       double & val(int row,  int col); // element selection;
00150       double cval(int row,  int col) const; // element selection;
00151 // can be used to read or write an element.
00152       double mmin( ); // find minimum element in the skymatrix
00153       double mmax( ); // find maximum element in the skymatrix
00154       double mean( );  // average all the elements of the skymatrix
00155       double get_max(void);        // get max element
00156       //double get_min(void);        // get max element
00157       //void  set_mm(void);        // set max and min element
00158 
00159      //Zhaohui  added to set the max-element in diagonal of eqn_no_shake!
00160      void  set_penalty_element(int *eqn_no_shake, int no_of_shake, double max_element);
00161 
00162       void lower_print(char *msg = ""); // print lower part of
00163                                         // skymatrix with a message
00164       void upper_print(char *msg = ""); // print upper part of
00165                                         // skymatrix with a message
00166 
00167 //      void profile_init( FEModelData      & FEMD);            // initialize profile
00168 // This sub has been merged with initializor No.1                    //Zhaohui added   
00169 
00170       void profile_jp_print( );         // print jp vector
00171                                         //Zhaohui added  
00172 
00173       void profile_ad_print( void );
00174       void profile_al_print( );         // print al vector
00175                                         //Zhaohui added  
00176 
00177       void full_print(char *msg =  ""); // print sky matrix
00178                                         // as a full matrix with a message
00179 
00180 //tempout      profilematrix & AssembleBricksInProfMatrix(stiffness_matrix & Ke,
00181 //tempout                                            Brick3D          * b3d,
00182 //tempout                                            Node             * node,
00183 //tempout                                                                FEModelData      & FEMD,
00184 //tempout                                            float              scale // used to add damping matrix C to Kbar Zhaohui 
00185 //tempout                                          );
00186 //tempout
00187 
00188     private:
00189       void error(char *msg1, char *msg2 = "") const; // private function
00190 // this one is the same as mval except that it is more convinient
00191 // to overload operator (row,col).
00192       double & operator( )(int , int ) const;
00193       double & mval(int , int ) const;
00194 // full_val inline function allows you to treat profilematrix as if it is full
00195 // float matrix. The function will calculate position inside sky matrix
00196 // and return appropriate number if row and col are bellow skyline or
00197 // return zero (0) if row and col are above sky line
00198       double full_val (int , int ) const;
00199 
00200   private:
00201 //..    double* data(void) const;
00202 //..    void set_data_pointer(double* );
00203 //    int rank(void) const;
00204 //    void rank(int );
00205     long int total_number(void) const ;
00206     void total_number(int );
00207 //    int* dim(void) const ;
00208 //    int& get_dim_pointer(void) const ;
00209 //    void set_dim_pointer(int* );
00210 //    int dim(int which) const;
00211     int reference_count(int );
00212     void set_reference_count(int );
00213 
00214 // profile solvers  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
00215 
00216   public:
00217 //    void datri(); // triangular decomposition of profile symmetric/unsymmetric matrix!
00218     profilematrix & datri(void); // triangular decomposition of profile symmetric/unsymmetric matrix!
00219     double * dasol(double *); // backsubstitution of profile symmetric/unsymmetric matrix!
00220     double datest(double* , int );
00221     double dot(double* , double* , int );
00222     void dredu(double* , double* , double* , int , char , double* );
00223     void saxpb(double* , double* , double , int , double* );
00224 
00225 
00226 
00227   };
00228 
00229 #endif 

Generated on Mon Oct 23 15:05:28 2006 for OpenSees by doxygen 1.5.0