www.mooseframework.org
Public Member Functions | Static Public Member Functions | Private Attributes | Friends | List of all members
SymmTensor Class Reference

#include <SymmTensor.h>

Public Member Functions

 SymmTensor ()
 
 SymmTensor (Real init)
 
 SymmTensor (Real xx, Real yy, Real zz, Real xy, Real yz, Real zx)
 
 SymmTensor (const ColumnMajorMatrix &cmm)
 
 SymmTensor (const std::vector< Real > &init_list)
 
void fillFromInputVector (const std::vector< Real > &input)
 
Real rowDot (const unsigned int r, const libMesh::TypeVector< Real > &v) const
 
Real trace () const
 
Real component (unsigned int i) const
 
Real xx () const
 
Real yy () const
 
Real zz () const
 
Real xy () const
 
Real yz () const
 
Real zx () const
 
Real yx () const
 
Real zy () const
 
Real xz () const
 
Real & xx ()
 
Real & yy ()
 
Real & zz ()
 
Real & xy ()
 
Real & yz ()
 
Real & zx ()
 
Real & yx ()
 
Real & zy ()
 
Real & xz ()
 
Real & operator() (const unsigned i, const unsigned j)
 
Real operator() (const unsigned i, const unsigned j) const
 
Real doubleContraction (const SymmTensor &rhs) const
 
void xx (Real xx)
 
void yy (Real yy)
 
void zz (Real zz)
 
void xy (Real xy)
 
void yz (Real yz)
 
void zx (Real zx)
 
void yx (Real yx)
 
void zy (Real zy)
 
void xz (Real xz)
 
void zero ()
 
void identity ()
 
void addDiag (Real value)
 
bool operator== (const SymmTensor &rhs) const
 
bool operator!= (const SymmTensor &rhs) const
 
SymmTensoroperator+= (const SymmTensor &t)
 
SymmTensoroperator-= (const SymmTensor &t)
 
SymmTensor operator+ (const SymmTensor &t) const
 
SymmTensor operator* (Real t) const
 
Point operator* (const Point &p) const
 
SymmTensor operator- (const SymmTensor &t) const
 
SymmTensoroperator+= (const ColumnMajorMatrix &cmm)
 
SymmTensoroperator-= (const ColumnMajorMatrix &cmm)
 
SymmTensoroperator= (const ColumnMajorMatrix &cmm)
 
SymmTensoroperator= (Real val)
 
SymmTensoroperator*= (Real val)
 
ColumnMajorMatrix columnMajorMatrix () const
 

Static Public Member Functions

static void initRandom ()
 
static SymmTensor genRandomSymmTensor (Real scalefactor)
 

Private Attributes

Real _xx
 
Real _yy
 
Real _zz
 
Real _xy
 
Real _yz
 
Real _zx
 

Friends

std::ostream & operator<< (std::ostream &stream, const SymmTensor &obj)
 

Detailed Description

Definition at line 19 of file SymmTensor.h.

Constructor & Destructor Documentation

SymmTensor::SymmTensor ( )
inline

Definition at line 22 of file SymmTensor.h.

22 : _xx(0), _yy(0), _zz(0), _xy(0), _yz(0), _zx(0) {}
SymmTensor::SymmTensor ( Real  init)
inlineexplicit

Definition at line 23 of file SymmTensor.h.

23  : _xx(init), _yy(init), _zz(init), _xy(init), _yz(init), _zx(init)
24  {
25  }
SymmTensor::SymmTensor ( Real  xx,
Real  yy,
Real  zz,
Real  xy,
Real  yz,
Real  zx 
)
inline

Definition at line 26 of file SymmTensor.h.

27  : _xx(xx), _yy(yy), _zz(zz), _xy(xy), _yz(yz), _zx(zx)
28  {
29  }
Real yy() const
Definition: SymmTensor.h:130
Real xx() const
Definition: SymmTensor.h:129
Real zz() const
Definition: SymmTensor.h:131
Real xy() const
Definition: SymmTensor.h:132
Real yz() const
Definition: SymmTensor.h:133
Real zx() const
Definition: SymmTensor.h:134
SymmTensor::SymmTensor ( const ColumnMajorMatrix &  cmm)
inlineexplicit

Definition at line 30 of file SymmTensor.h.

31  : _xx(cmm.numEntries() == 9 ? cmm.rawData()[0] : 0),
32  _yy(cmm.numEntries() == 9 ? cmm.rawData()[4] : 0),
33  _zz(cmm.numEntries() == 9 ? cmm.rawData()[8] : 0),
34  _xy(cmm.numEntries() == 9 ? cmm.rawData()[1] : 0),
35  _yz(cmm.numEntries() == 9 ? cmm.rawData()[5] : 0),
36  _zx(cmm.numEntries() == 9 ? cmm.rawData()[2] : 0)
37  {
38  if (cmm.numEntries() != 9)
39  {
40  mooseError("Cannot create SymmTensor from ColumnMajorMatrix. Wrong number of entries.");
41  }
42  }
SymmTensor::SymmTensor ( const std::vector< Real > &  init_list)
inlineexplicit

Definition at line 44 of file SymmTensor.h.

45  : _xx(init_list[0]),
46  _yy(init_list[1]),
47  _zz(init_list[2]),
48  _xy(init_list[3]),
49  _yz(init_list[4]),
50  _zx(init_list[5])
51  {
52  // test the length to make sure it's 6 long
53  if (init_list.size() != 6)
54  {
55  mooseError("SymmTensor initialization error: please enter a vector with 6 entries.");
56  }
57  }

Member Function Documentation

void SymmTensor::addDiag ( Real  value)
inline
ColumnMajorMatrix SymmTensor::columnMajorMatrix ( ) const
inline

Definition at line 423 of file SymmTensor.h.

Referenced by MaterialTensorCalculatorTools::calcPrincipalValues(), and RateDepSmearIsoCrackModel::initVariables().

424  {
425  ColumnMajorMatrix cmm(3, 3);
426  cmm(0, 0) = _xx;
427  cmm(1, 0) = _xy;
428  cmm(2, 0) = _zx;
429  cmm(0, 1) = _xy;
430  cmm(1, 1) = _yy;
431  cmm(2, 1) = _yz;
432  cmm(0, 2) = _zx;
433  cmm(1, 2) = _yz;
434  cmm(2, 2) = _zz;
435  return cmm;
436  }
Real SymmTensor::component ( unsigned int  i) const
inline

Definition at line 97 of file SymmTensor.h.

Referenced by MaterialTensorCalculatorTools::component(), AbaqusCreepMaterial::computeStress(), and AbaqusUmatMaterial::computeStress().

98  {
99  if (0 == i)
100  {
101  return _xx;
102  }
103  else if (1 == i)
104  {
105  return _yy;
106  }
107  else if (2 == i)
108  {
109  return _zz;
110  }
111  else if (3 == i)
112  {
113  return _xy;
114  }
115  else if (4 == i)
116  {
117  return _yz;
118  }
119  else if (5 == i)
120  {
121  return _zx;
122  }
123  else
124  {
125  mooseError("Invalid entry requested for SymmTensor");
126  }
127  return 0;
128  }
Real SymmTensor::doubleContraction ( const SymmTensor rhs) const
inline
void SymmTensor::fillFromInputVector ( const std::vector< Real > &  input)
inline

Definition at line 59 of file SymmTensor.h.

60  {
61  if (input.size() != 6)
62  {
63  mooseError("SymmTensor error. Input vector must have six entries.");
64  }
65  _xx = input[0];
66  _yy = input[1];
67  _zz = input[2];
68  _xy = input[3];
69  _yz = input[4];
70  _zx = input[5];
71  }
static SymmTensor SymmTensor::genRandomSymmTensor ( Real  scalefactor)
inlinestatic

Definition at line 447 of file SymmTensor.h.

Referenced by RateDepSmearCrackModel::computeStress().

448  {
449 
450  SymmTensor tensor;
451 
452  tensor.xx() = (MooseRandom::rand() + 1.0) * scalefactor;
453  tensor.yy() = (MooseRandom::rand() + 1.0) * scalefactor;
454  tensor.zz() = (MooseRandom::rand() + 1.0) * scalefactor;
455  tensor.xy() = (MooseRandom::rand() + 1.0) * scalefactor;
456  tensor.yz() = (MooseRandom::rand() + 1.0) * scalefactor;
457  tensor.zx() = (MooseRandom::rand() + 1.0) * scalefactor;
458 
459  return tensor;
460  }
Real yy() const
Definition: SymmTensor.h:130
Real xx() const
Definition: SymmTensor.h:129
Real zz() const
Definition: SymmTensor.h:131
Real xy() const
Definition: SymmTensor.h:132
Real yz() const
Definition: SymmTensor.h:133
Real zx() const
Definition: SymmTensor.h:134
void SymmTensor::identity ( )
inline

Definition at line 274 of file SymmTensor.h.

275  {
276  _xx = _yy = _zz = 1;
277  _xy = _yz = _zx = 0;
278  }
static void SymmTensor::initRandom ( )
inlinestatic

Definition at line 440 of file SymmTensor.h.

Referenced by RateDepSmearCrackModel::RateDepSmearCrackModel().

441  {
442 
443  unsigned int randinit = 2000;
444  MooseRandom::seed(randinit);
445  }
bool SymmTensor::operator!= ( const SymmTensor rhs) const
inline

Definition at line 290 of file SymmTensor.h.

290 { return !operator==(rhs); }
bool operator==(const SymmTensor &rhs) const
Definition: SymmTensor.h:285
Real& SymmTensor::operator() ( const unsigned  i,
const unsigned  j 
)
inline

Definition at line 147 of file SymmTensor.h.

148  {
149  Real * rVal(NULL);
150  if (0 == i)
151  {
152  if (0 == j)
153  {
154  rVal = &_xx;
155  }
156  else if (1 == j)
157  {
158  rVal = &_xy;
159  }
160  else if (2 == j)
161  {
162  rVal = &_zx;
163  }
164  }
165  else if (1 == i)
166  {
167  if (0 == j)
168  {
169  rVal = &_xy;
170  }
171  else if (1 == j)
172  {
173  rVal = &_yy;
174  }
175  else if (2 == j)
176  {
177  rVal = &_yz;
178  }
179  }
180  else if (2 == i)
181  {
182  if (0 == j)
183  {
184  rVal = &_zx;
185  }
186  else if (1 == j)
187  {
188  rVal = &_yz;
189  }
190  else if (2 == j)
191  {
192  rVal = &_zz;
193  }
194  }
195  if (!rVal)
196  {
197  mooseError("Index must be 0, 1, or 2");
198  }
199  return *rVal;
200  }
Real SymmTensor::operator() ( const unsigned  i,
const unsigned  j 
) const
inline

Definition at line 202 of file SymmTensor.h.

203  {
204  const Real * rVal(NULL);
205  if (0 == i)
206  {
207  if (0 == j)
208  {
209  rVal = &_xx;
210  }
211  else if (1 == j)
212  {
213  rVal = &_xy;
214  }
215  else if (2 == j)
216  {
217  rVal = &_zx;
218  }
219  }
220  else if (1 == i)
221  {
222  if (0 == j)
223  {
224  rVal = &_xy;
225  }
226  else if (1 == j)
227  {
228  rVal = &_yy;
229  }
230  else if (2 == j)
231  {
232  rVal = &_yz;
233  }
234  }
235  else if (2 == i)
236  {
237  if (0 == j)
238  {
239  rVal = &_zx;
240  }
241  else if (1 == j)
242  {
243  rVal = &_yz;
244  }
245  else if (2 == j)
246  {
247  rVal = &_zz;
248  }
249  }
250  if (!rVal)
251  {
252  mooseError("Index must be 0, 1, or 2");
253  }
254  return *rVal;
255  }
SymmTensor SymmTensor::operator* ( Real  t) const
inline

Definition at line 326 of file SymmTensor.h.

327  {
328  SymmTensor r_val;
329 
330  r_val._xx = _xx * t;
331  r_val._yy = _yy * t;
332  r_val._zz = _zz * t;
333  r_val._xy = _xy * t;
334  r_val._yz = _yz * t;
335  r_val._zx = _zx * t;
336  return r_val;
337  }
Point SymmTensor::operator* ( const Point &  p) const
inline

Definition at line 339 of file SymmTensor.h.

340  {
341  return Point(_xx * p(0) + _xy * p(1) + _zx * p(2),
342  _xy * p(0) + _yy * p(1) + _yz * p(2),
343  _zx * p(0) + _yz * p(1) + _zz * p(2));
344  }
SymmTensor& SymmTensor::operator*= ( Real  val)
inline

Definition at line 412 of file SymmTensor.h.

413  {
414  _xx *= val;
415  _xy *= val;
416  _zx *= val;
417  _yy *= val;
418  _yz *= val;
419  _zz *= val;
420  return *this;
421  }
SymmTensor SymmTensor::operator+ ( const SymmTensor t) const
inline

Definition at line 314 of file SymmTensor.h.

315  {
316  SymmTensor r_val;
317  r_val._xx = _xx + t._xx;
318  r_val._yy = _yy + t._yy;
319  r_val._zz = _zz + t._zz;
320  r_val._xy = _xy + t._xy;
321  r_val._yz = _yz + t._yz;
322  r_val._zx = _zx + t._zx;
323  return r_val;
324  }
SymmTensor& SymmTensor::operator+= ( const SymmTensor t)
inline

Definition at line 292 of file SymmTensor.h.

293  {
294  _xx += t._xx;
295  _yy += t._yy;
296  _zz += t._zz;
297  _xy += t._xy;
298  _yz += t._yz;
299  _zx += t._zx;
300  return *this;
301  }
SymmTensor& SymmTensor::operator+= ( const ColumnMajorMatrix &  cmm)
inline

Definition at line 358 of file SymmTensor.h.

359  {
360  mooseAssert(cmm.numEntries() == 9,
361  "Cannot add ColumnMajorMatrix to SymmTensor. Wrong number of entries.");
362  const Real * data = cmm.rawData();
363  _xx += data[0];
364  _xy += data[1];
365  _zx += data[2];
366  _yy += data[4];
367  _yz += data[5];
368  _zz += data[8];
369  return *this;
370  }
SymmTensor SymmTensor::operator- ( const SymmTensor t) const
inline

Definition at line 346 of file SymmTensor.h.

347  {
348  SymmTensor r_val;
349  r_val._xx = _xx - t._xx;
350  r_val._yy = _yy - t._yy;
351  r_val._zz = _zz - t._zz;
352  r_val._xy = _xy - t._xy;
353  r_val._yz = _yz - t._yz;
354  r_val._zx = _zx - t._zx;
355  return r_val;
356  }
SymmTensor& SymmTensor::operator-= ( const SymmTensor t)
inline

Definition at line 303 of file SymmTensor.h.

304  {
305  _xx -= t._xx;
306  _yy -= t._yy;
307  _zz -= t._zz;
308  _xy -= t._xy;
309  _yz -= t._yz;
310  _zx -= t._zx;
311  return *this;
312  }
SymmTensor& SymmTensor::operator-= ( const ColumnMajorMatrix &  cmm)
inline

Definition at line 372 of file SymmTensor.h.

373  {
374  mooseAssert(cmm.numEntries() == 9,
375  "Cannot add ColumnMajorMatrix to SymmTensor. Wrong number of entries.");
376  const Real * data = cmm.rawData();
377 
378  _xx -= data[0];
379  _xy -= data[1];
380  _zx -= data[2];
381  _yy -= data[4];
382  _yz -= data[5];
383  _zz -= data[8];
384  return *this;
385  }
SymmTensor& SymmTensor::operator= ( const ColumnMajorMatrix &  cmm)
inline

Definition at line 387 of file SymmTensor.h.

388  {
389  mooseAssert(cmm.numEntries() == 9,
390  "Cannot set SymmTensor to ColumnMajorMatrix. Wrong number of entries.");
391  const Real * data = cmm.rawData();
392  _xx = data[0];
393  _xy = data[1];
394  _zx = data[2];
395  _yy = data[4];
396  _yz = data[5];
397  _zz = data[8];
398  return *this;
399  }
SymmTensor& SymmTensor::operator= ( Real  val)
inline

Definition at line 401 of file SymmTensor.h.

402  {
403  _xx = val;
404  _xy = val;
405  _zx = val;
406  _yy = val;
407  _yz = val;
408  _zz = val;
409  return *this;
410  }
bool SymmTensor::operator== ( const SymmTensor rhs) const
inline

Definition at line 285 of file SymmTensor.h.

Referenced by operator!=().

286  {
287  return _xx == rhs._xx && _yy == rhs._yy && _zz == rhs._zz && _xy == rhs._xy && _yz == rhs._yz &&
288  _zx == rhs._zx;
289  }
Real SymmTensor::rowDot ( const unsigned int  r,
const libMesh::TypeVector< Real > &  v 
) const
inline

Definition at line 73 of file SymmTensor.h.

74  {
75  mooseAssert(LIBMESH_DIM == 3, "Incompatible sizes");
76  if (0 == r)
77  {
78  return _xx * v(0) + _xy * v(1) + _zx * v(2);
79  }
80  else if (1 == r)
81  {
82  return _xy * v(0) + _yy * v(1) + _yz * v(2);
83  }
84  else if (2 == r)
85  {
86  return _zx * v(0) + _yz * v(1) + _zz * v(2);
87  }
88  else
89  {
90  mooseError("Incorrect row");
91  }
92  return 0;
93  }
Real SymmTensor::trace ( ) const
inline
Real SymmTensor::xx ( ) const
inline
Real& SymmTensor::xx ( )
inline

Definition at line 138 of file SymmTensor.h.

138 { return _xx; }
void SymmTensor::xx ( Real  xx)
inline

Definition at line 263 of file SymmTensor.h.

Referenced by xx().

263 { _xx = xx; }
Real xx() const
Definition: SymmTensor.h:129
Real SymmTensor::xy ( ) const
inline
Real& SymmTensor::xy ( )
inline

Definition at line 141 of file SymmTensor.h.

141 { return _xy; }
void SymmTensor::xy ( Real  xy)
inline

Definition at line 266 of file SymmTensor.h.

Referenced by xy().

266 { _xy = xy; }
Real xy() const
Definition: SymmTensor.h:132
Real SymmTensor::xz ( ) const
inline

Definition at line 137 of file SymmTensor.h.

137 { return _zx; }
Real& SymmTensor::xz ( )
inline

Definition at line 146 of file SymmTensor.h.

146 { return _zx; }
void SymmTensor::xz ( Real  xz)
inline

Definition at line 271 of file SymmTensor.h.

Referenced by xz().

271 { _zx = xz; }
Real xz() const
Definition: SymmTensor.h:137
Real SymmTensor::yx ( ) const
inline

Definition at line 135 of file SymmTensor.h.

135 { return _xy; }
Real& SymmTensor::yx ( )
inline

Definition at line 144 of file SymmTensor.h.

144 { return _xy; }
void SymmTensor::yx ( Real  yx)
inline

Definition at line 269 of file SymmTensor.h.

Referenced by yx().

269 { _xy = yx; }
Real yx() const
Definition: SymmTensor.h:135
Real SymmTensor::yy ( ) const
inline
Real& SymmTensor::yy ( )
inline

Definition at line 139 of file SymmTensor.h.

139 { return _yy; }
void SymmTensor::yy ( Real  yy)
inline

Definition at line 264 of file SymmTensor.h.

Referenced by yy().

264 { _yy = yy; }
Real yy() const
Definition: SymmTensor.h:130
Real SymmTensor::yz ( ) const
inline
Real& SymmTensor::yz ( )
inline

Definition at line 142 of file SymmTensor.h.

142 { return _yz; }
void SymmTensor::yz ( Real  yz)
inline

Definition at line 267 of file SymmTensor.h.

Referenced by yz().

267 { _yz = yz; }
Real yz() const
Definition: SymmTensor.h:133
void SymmTensor::zero ( )
inline

Definition at line 273 of file SymmTensor.h.

Referenced by LinearIsotropicMaterial::computeProperties(), and SolidModel::modifyStrainIncrement().

273 { _xx = _yy = _zz = _xy = _yz = _zx = 0; }
Real SymmTensor::zx ( ) const
inline
Real& SymmTensor::zx ( )
inline

Definition at line 143 of file SymmTensor.h.

143 { return _zx; }
void SymmTensor::zx ( Real  zx)
inline

Definition at line 268 of file SymmTensor.h.

Referenced by zx().

268 { _zx = zx; }
Real zx() const
Definition: SymmTensor.h:134
Real SymmTensor::zy ( ) const
inline

Definition at line 136 of file SymmTensor.h.

136 { return _yz; }
Real& SymmTensor::zy ( )
inline

Definition at line 145 of file SymmTensor.h.

145 { return _yz; }
void SymmTensor::zy ( Real  zy)
inline

Definition at line 270 of file SymmTensor.h.

Referenced by zy().

270 { _yz = zy; }
Real zy() const
Definition: SymmTensor.h:136
Real SymmTensor::zz ( ) const
inline
Real& SymmTensor::zz ( )
inline

Definition at line 140 of file SymmTensor.h.

140 { return _zz; }
void SymmTensor::zz ( Real  zz)
inline

Definition at line 265 of file SymmTensor.h.

Referenced by zz().

265 { _zz = zz; }
Real zz() const
Definition: SymmTensor.h:131

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  stream,
const SymmTensor obj 
)
friend

Definition at line 10 of file SymmTensor.C.

Referenced by columnMajorMatrix().

11 {
12  stream << "SymmTensor:\n"
13  << std::setprecision(6) << std::setw(13) << obj._xx << "\t" << std::setw(13) << obj._xy
14  << "\t" << std::setw(13) << obj._zx << "\n"
15  << "\t\t" << std::setw(13) << obj._yy << "\t" << std::setw(13) << obj._yz << "\n"
16  << "\t\t\t\t" << std::setw(13) << obj._zz << std::endl;
17  return stream;
18 }

Member Data Documentation

Real SymmTensor::_xx
private
Real SymmTensor::_xy
private
Real SymmTensor::_yy
private
Real SymmTensor::_yz
private
Real SymmTensor::_zx
private
Real SymmTensor::_zz
private

The documentation for this class was generated from the following file: