xc
profmatr.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // XC program; finite element analysis code
4 // for structural analysis and design.
5 //
6 // Copyright (C) Luis C. Pérez Tato
7 //
8 // This program derives from OpenSees <http://opensees.berkeley.edu>
9 // developed by the «Pacific earthquake engineering research center».
10 //
11 // Except for the restrictions that may arise from the copyright
12 // of the original program (see copyright_opensees.txt)
13 // XC is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation, either version 3 of the License, or
16 // (at your option) any later version.
17 //
18 // This software is distributed in the hope that it will be useful, but
19 // WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program.
26 // If not, see <http://www.gnu.org/licenses/>.
27 //----------------------------------------------------------------------------
28 //#############################################################################
29 // #
30 // #
31 // /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/~~\ #
32 // | |____| #
33 // | | #
34 // | | #
35 // | | #
36 // | | #
37 // | B A S E C L A S S E S | #
38 // | | #
39 // | | #
40 // | | #
41 // | | #
42 // | C + + H E A D E R | #
43 // | | #
44 // | | #
45 // | | #
46 // | | #
47 // /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/ | #
48 // \_________________________________________\__/ #
49 // #
50 // #
51 //##############################################################################
52 //# COPYRIGHT (C): :-)) #
53 //# PROJECT: Object Oriented Finite Element Program #
54 //# PURPOSE: #
55 //# CLASS: profilematrix #
56 //# #
57 //# VERSION: #
58 //# LANGUAGE: C++.ver >= 2.0 ( Borland C++ ver=3.10, SUN C++ ver=2.1 )#
59 //# TARGET OS: DOS || UNIX || . . . #
60 //# PROGRAMMER(S): Boris Jeremic #
61 //# #
62 //# #
63 //# DATE: September 13 '94 Unsymmetric Solver -> profile solver #
64 //# ( see FEM4ed by O.Z. and R.T.) #
65 //# #
66 //# UPDATE HISTORY: September 27 '94 profile solver for symmetric and #
67 //# Nonsymmetric systems works! #
68 //# (from FEM4ed by O.Z. and R.T.) #
69 //# #
70 //# #
71 //##############################################################################
72 // Profile Sparse Matrix Class
73 // this one is based on Zienkiewicz's and Taylor's book!
74 
75 #ifndef PROFMATR_HH
76 #define PROFMATR_HH
77 
78 //tempout#include <femdata.h>
79 //tempout#include <brick3d.h>
80 //tempout#include <node.h>
81 //tempout#include <stifmat.h>
82 
83 #include <algorithm>
84 #include <string>
85 
86 namespace XC {
87  class BJvector;
88 
90  {
91  public:
92  friend class profilematrix;
93  private:
94  double *al; // lower triangular part of matrix
95  double *au; // upper triangular part of matrix
96  double *ad; // diagonals of triangular of matrix
97  //double max_element; // max ele. of matrix
98  //double min_element; // min ele. of matrix
99 
100  int *jp; // pointers to bottom of columns of al and au arrays
101 
102  int * columnheight; // pointers to the height of each column may be replaced by jp __Zhaohui
103 
104  int neq; // dimension of a system ( as square matrix )
105 
106  int total_numb; // total number of elements in al and/or au
107 
108  char flag; // if flag=='S' symmetric; if flag=='N' NON(un)symmetric
109 
110  int n; // reference count
111 
112  public:
113 // overloading operator new and delete in profilematrix_rep class ########
114  void * operator new(size_t s); // see C++ reference manual by
115  void operator delete(void *); // by ELLIS and STROUSTRUP page 283.
116  // and ECKEL page 529.
117  };
118 
120  {
121  private:
122  profilematrix_rep * pc_profilematrix_rep;
123  public:
124 // I don't need default constructor, this is not a very common data type!!!!!!!!!!!
125 // profilematrix(int matrix_order=1, double init_value=0.0 ); // default constructor
126 // this constructor just for testing purposes!
127 
128 //tempout profilematrix(FEModelData & FEMD,
129 //tempout Brick3D * b3d,
130 //tempout Node * node);
131 
132  profilematrix(int matrix_order,
133  int *jp_init,
134  char flag_init,
135  double *au_init_val,
136  double *al_init_val,
137  double *ad_init_val);
138 // The real constructor. This one will be initialized to the original size
139 // with the init_val values and then in stiffness matrix class those
140 // default inti_val values will be altered ( to the right stiffness ).
141  profilematrix(int matrix_order,
142  int *jp_init,
143  char flag_init,
144  double au_init_val,
145  double al_init_val,
146  double ad_init_val);
147 // skymatrix(char *flag, int dimension ); // create an ident skymatrix
148  profilematrix(const profilematrix & x); // copy-initializer
149  ~profilematrix();
150 
151 
152  int dimension_of_profile_M(void ) const; // dimension of profile matrix
153  int *get_jp(void) const; // get pointer to array of
154  // Locations of Diagonals
155  profilematrix &operator=(const profilematrix &rval); // profilematrix assignment
156 
157 //....// This is from JOOP May/June 1990 after ARKoenig
158  profilematrix& operator +=(const profilematrix & ); // profilematrix addition
159  friend profilematrix operator+(const profilematrix & , const profilematrix & ); // profilematrix addition
160 //....// This is from JOOP May/June 1990 after ARKoenig
161  profilematrix& operator -=(const profilematrix & ); // profilematrix subtraction
162  friend profilematrix operator-(const profilematrix & , const profilematrix & ); // profilematrix subtraction
163 
164  profilematrix operator+(const double &rval); // scalar addition
165  profilematrix operator-(const double &rval); // scalar subtraction
166  profilematrix operator*(const double &rval); // scalar multiplication
167  double * operator*(const BJvector &arg); // profile multiplied by vector__Zhaohui
168 
169 
170 // int operator==( profilematrix & rval); // profilematrix comparison
171 // // returns 1 if they are same
172 // // returns 0 if they are not
173 
174  double & val(int row, int col); // element selection;
175  double cval(int row, int col) const; // element selection;
176 // can be used to read or write an element.
177  double mmin( ); // find minimum element in the skymatrix
178  double mmax( ); // find maximum element in the skymatrix
179  double mean( ); // average all the elements of the skymatrix
180  double get_max(void); // get max element
181  //double get_min(void); // get max element
182  //void set_mm(void); // set max and min element
183 
184  //Zhaohui added to set the max-element in diagonal of eqn_no_shake!
185  void set_penalty_element(int *eqn_no_shake, int no_of_shake, double max_element);
186 
187  //void lower_print(const std::string &msg= ""); // print lower part of
188  // skymatrix with a message
189  //void upper_print(const std::string &msg= ""); // print upper part of
190  // skymatrix with a message
191 
192 // void profile_init( FEModelData & FEMD); // initialize profile
193 // This sub has been merged with initializor No.1 //Zhaohui added
194 
195  void profile_jp_print( ); // print jp vector
196  //Zhaohui added
197 
198  void profile_ad_print( void );
199  void profile_al_print( ); // print al vector
200  //Zhaohui added
201 
202  void full_print(const std::string &msg= ""); // print sky matrix
203  // as a full matrix with a message
204 
205 //tempout profilematrix & AssembleBricksInProfMatrix(stiffness_matrix & Ke,
206 //tempout Brick3D * b3d,
207 //tempout Node * node,
208 //tempout FEModelData & FEMD,
209 //tempout float scale // used to add damping matrix C to Kbar Zhaohui
210 //tempout );
211 //tempout
212 
213  private:
214  void error(const std::string &msg1,const std::string &msg2= "") const;
215 // this one is the same as mval except that it is more convenient
216 // to overload operator (row,col).
217  double &operator( )(int , int ) const;
218  double & mval(int , int ) const;
219 // full_val inline function allows you to treat profilematrix as if it is full
220 // float matrix. The function will calculate position inside sky matrix
221 // and return appropriate number if row and col are below skyline or
222 // return zero (0) if row and col are above sky line
223  double full_val (int , int ) const;
224 
225  private:
226 // int rank(void) const;
227 // void rank(int );
228  long int total_number(void) const ;
229  void total_number(int );
230 // int* dim(void) const ;
231 // int& get_dim_pointer(void) const ;
232 // int dim(int which) const;
233  int reference_count(int );
234  void set_reference_count(int );
235 
236 // profile solvers !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
237 
238  public:
239 // void datri(); // triangular decomposition of profile symmetric/unsymmetric matrix!
240  profilematrix & datri(void); // triangular decomposition of profile symmetric/unsymmetric matrix!
241  double * dasol(double *); // backsubstitution of profile symmetric/unsymmetric matrix!
242  double datest(double* , int );
243  double dot(double* , double* , int );
244  void dredu(double* , double* , double* , int , char , double* );
245  void saxpb(double* , double* , double , int , double* );
246 
247 
248 
249  };
252 
253 } // end of XC namespace
254 
255 #endif
Definition: profmatr.h:119
Definition: profmatr.h:89
FiberSet operator+(const FiberSet &, const FiberSet &)
Return the union of both containers.
Definition: FiberSet.cc:65
Boris Jeremic vector class.
Definition: BJvector.h:102
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
FiberSet operator-(const FiberSet &, const FiberSet &)
Return the fibers in a that are not in b.
Definition: FiberSet.cc:73