xc
BJtensor.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 // $Revision: 1.4 $
30 // $Date: 2005/10/21 22:02:39 $
31 // $Source: /usr/local/cvs/OpenSees/SRC/nDarray/BJtensor.h,v $
32 
33 //#############################################################################
34 // #
35 // #
36 // /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/~~\ #
37 // | |____| #
38 // | | #
39 // | | #
40 // | | #
41 // | | #
42 // | B A S E C L A S S E S | #
43 // | | #
44 // | | #
45 // | | #
46 // | | #
47 // | C + + H E A D E R | #
48 // | | #
49 // | | #
50 // | | #
51 // | | #
52 // /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/ | #
53 // \_________________________________________\__/ #
54 // #
55 // #
56 //#############################################################################
57 //#############################################################################
59 //################################################################################
60 //# COPYRIGHT (C): :-)) #
61 //# PROJECT: Object Oriented Finite Element Program #
62 //# PURPOSE: #
63 //# CLASS: BJtensor #
64 //# #
65 //# VERSION: #
66 //# LANGUAGE: C++.ver >= 2.0 ( Borland C++ ver=3.10, SUN C++ ver=2.1 ) #
67 //# TARGET OS: DOS || UNIX || . . . #
68 //# DESIGNER(S): Boris Jeremic #
69 //# PROGRAMMER(S): Boris Jeremic #
70 //# #
71 //# #
72 //# DATE: May 28. - July __ '93 #
73 //# UPDATE HISTORY: july 8. '93. BJtensor02 - BJtensor multiplication #
74 //# inner and outer products #
75 //# august 17-19 '93 fixed default constructor that wasted #
76 //# memory ### #
77 //# october 11 '93 added transpose0110, transpose0101, #
78 //# transpose0111 so the creation of #
79 //# isotropic BJtensor is much easier and #
80 //# understandable! #
81 //# january 06 '93 added BJtensor2BJmatrix_1, BJtensor2BJmatrix_2 #
82 //# BJtensor2BJmatrix_3, inverse_1, inverse_2, #
83 //# inverse_3 #
84 //# january 20 '93 added inverse TRUE ONE #
85 //# August 22-29 '94 choped to separate files and worked on#
86 //# const and & issues #
87 //# August 30-31 '94 added use_def_dim to full the CC #
88 //# resolved problem with temoraries for #
89 //# operators + and - ( +=, -= ) #
90 //# Oktobar 15 '96 added trasposeoverbar trasposeunderbar#
91 //# ( the same as transpose0110 and #
92 //# transpose0101) but just to make it #
93 //# easier to work with Runesson's notation#
94 //# 28June2004 added val4 for efficiency still #
95 //# to be worked on #
96 //# #
97 //# #
98 //#############################################################################
99 //*/
100 
101 #ifndef BJTENSOR_HH
102 #define BJTENSOR_HH
103 
104 
105 #include "utility/matrix/nDarray/nDarray.h"
106 #include "tmpl_operators.h"
107 
108 namespace XC {
112 class BJtensor: public nDarray
113  {
114  friend class stressstraintensor;
115  friend class stresstensor;
116  friend class straintensor;
117 // private:
118  public:
119  mutable std::string indices1;
120  mutable std::string indices2; // they should be checked for matching and
121  // then operator will be identified
122  public: // just send appropriate arguments to the base constructor
123  BJtensor(int rank_of_BJtensor=1,const double &initval=0); // default constructor
124  BJtensor(const std::vector<int> &pdim, const double *values);
125  BJtensor(const std::vector<int> &pdim, const std::vector<double> &values);
126  BJtensor(const std::vector<int> &pdim, const boost::python::list &l);
127  BJtensor(const boost::python::list &, const boost::python::list &);
128  BJtensor(const std::vector<int> &pdim,const double &initvalue);
129  BJtensor(const std::string &flag, const std::vector<int> &pdim); // create a unit nDarray
130  BJtensor(const std::string &flag); //this one used to send "NO" message
131  BJtensor(const BJtensor &x); // instead of: "BJtensor(nDarray & x):" :-)
132  explicit BJtensor(const nDarray &x);
133 
134  //~BJtensor( );
135 
136  BJtensor &operator=(const BJtensor & rval); // BJtensor assignment
137  BJtensor &operator+=(const BJtensor & rval); // BJtensor addition
138  BJtensor &operator-=(const BJtensor & rval); // BJtensor subtraction
139 
140  BJtensor &operator*=(const double &rval); // Added Zhao Oct2005
141  BJtensor operator*(const double &rval) const; // scalar multiplication, Added const Zhao Oct2005
142  BJtensor operator*(const BJtensor &rval) const; // inner/outer product
143  BJtensor operator/(const BJtensor &rval) const; // BJtensor division rval MUST BE BJtensor of
144  // order 0 ( i.e. scalar in BJtensor form )
145 
146  BJtensor transpose0110( ) const; // transpose ijkl -->> ikjl
147  BJtensor transposeoverbar( ) const; // transpose ijkl -->> ikjl
148  BJtensor transpose0101( ) const; // transpose ijkl -->> ilkj
149  BJtensor transpose0111( ) const; // transpose ijkl -->> iljk
150  BJtensor transposeunderbar( ) const; // transpose ijkl -->> iljk
151  BJtensor transpose1100( ) const; // transpose ijkl -->> jikl First minor symm
152  BJtensor transpose0011( ) const; // transpose ijkl -->> ijlk Second minor symm
153  BJtensor transpose1001( ) const; // transpose ijkl -->> ljki
154  BJtensor transpose11( ) const; // transpose ij -->> ji
155 
156  BJtensor symmetrize11( ) const; // symmetrize with respect to ij
157  double determinant(void) const; // determinant of a BJtensor
158  BJmatrix BJtensor2BJmatrix_1(void) const;// convert BJtensor of even order to BJmatrix
159  // to be used in inversion process
160  // I_ijkl scheme
161  BJmatrix BJtensor2BJmatrix_2(void) const;// convert BJtensor of even order to BJmatrix
162  // to be used in inversion process
163  // I_ikjl scheme
164  BJmatrix BJtensor2BJmatrix_3(void) const;// convert BJtensor of even order to BJmatrix
165  // to be used in inversion process
166  // I_iljk scheme
167  BJtensor inverse(void) const; // inverse of a BJtensor
168  // I_ikjl scheme TRUE ONE ____
169  // |
170  BJtensor inverse_2(void) const; // inverse of a BJtensor <--|
171  // I_ikjl scheme
172  inline const double &operator()(int first) const
173  { return nDarray::operator()(first); }
174 
175  inline double &operator()(int first)
176  { return nDarray::operator()(first); }
177 
178  inline const double &operator()(int first, int second) const
179  { return nDarray::operator()(first, second); }
180 
181  inline double &operator()(int first, int second)
182  { return nDarray::operator()(first, second); }
183 
184  inline const double &operator()(int first, int second, int third) const
185  { return nDarray::operator()(first, second, third); }
186 
187  inline double &operator()(int first, int second, int third)
188  { return nDarray::operator()(first, second, third); }
189 
190  inline const double &operator()(int first, int second, int third, int fourth) const
191  { return nDarray::operator()(first, second, third, fourth); }
192 
193  inline double &operator()(int first, int second, int third, int fourth)
194  { return nDarray::operator()(first, second, third, fourth); }
195 
196  const BJtensor &operator()(const std::string &) const;
197 
198  void null_indices(void) const;
199  const std::string &f_indices1(void) const;
200  const std::string &f_indices2(void) const;
201 
202  private:
203 //K int BJtensor::contracted_ind(const std::string &, const std::string &, int *, int *, int , int );
204 //K int BJtensor::uncontracted_ind(int *, int *, int);
205  int contracted_ind(const std::string &,const std::string &, std::vector<int> &, std::vector<int> &, int , int ) const;
206  int uncontracted_ind(std::vector<int> &, std::vector<int> &, int) const;
207  };
208 
209 template BJtensor operator*(const double & , const BJtensor & );
210 template BJtensor operator+(const BJtensor & , const BJtensor & );
211 template BJtensor operator-(const BJtensor & , const BJtensor & );
212 
213 } // end of XC namespace
214 
215 #endif
216 
217 
218 
nDarray operator-()
unary minus
Definition: nDarray.cpp:798
BJtensor & operator-=(const BJtensor &rval)
Subtraction.
Definition: BJtensor.cpp:178
Base class for strain and stress tensors.
Definition: stress_strain_tensor.h:42
BJtensor transposeunderbar() const
Definition: BJtensor.cpp:725
Stress tensor.
Definition: stresst.h:70
BJtensor & operator*=(const double &rval)
Scalar multiplication. Optimized by Zhao Oct2005.
Definition: BJtensor.cpp:220
std::string indices1
character array of indices
Definition: BJtensor.h:119
BJtensor transpose0110() const
Definition: BJtensor.cpp:647
BJtensor transpose1001() const
Definition: BJtensor.cpp:785
BJtensor transpose1100() const
Definition: BJtensor.cpp:745
Boris Jeremic tensor class.
Definition: BJtensor.h:112
BJtensor transpose11() const
Definition: BJtensor.cpp:808
BJtensor transpose0101() const
Definition: BJtensor.cpp:686
BJtensor & operator+=(const BJtensor &rval)
Addition.
Definition: BJtensor.cpp:171
n-dimensional array.
Definition: nDarray.h:242
BJtensor transposeoverbar() const
Definition: BJtensor.cpp:667
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
Boris Jeremic matrix class.
Definition: BJmatrix.h:104
BJtensor transpose0111() const
Definition: BJtensor.cpp:706
nDarray operator+(const double &rval)
scalar addition
Definition: nDarray.cpp:730
BJtensor(int rank_of_BJtensor=1, const double &initval=0)
Default constructor.
Definition: BJtensor.cpp:106
BJtensor transpose0011() const
Definition: BJtensor.cpp:765
BJtensor symmetrize11() const
Definition: BJtensor.cpp:826
Strain tensor.
Definition: straint.h:68