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 21 of file SymmTensor.h.

Constructor & Destructor Documentation

◆ SymmTensor() [1/5]

SymmTensor::SymmTensor ( )
inline

Definition at line 24 of file SymmTensor.h.

24 : _xx(0), _yy(0), _zz(0), _xy(0), _yz(0), _zx(0) {}

◆ SymmTensor() [2/5]

SymmTensor::SymmTensor ( Real  init)
inlineexplicit

Definition at line 25 of file SymmTensor.h.

25  : _xx(init), _yy(init), _zz(init), _xy(init), _yz(init), _zx(init)
26  {
27  }

◆ SymmTensor() [3/5]

SymmTensor::SymmTensor ( Real  xx,
Real  yy,
Real  zz,
Real  xy,
Real  yz,
Real  zx 
)
inline

Definition at line 28 of file SymmTensor.h.

29  : _xx(xx), _yy(yy), _zz(zz), _xy(xy), _yz(yz), _zx(zx)
30  {
31  }

◆ SymmTensor() [4/5]

SymmTensor::SymmTensor ( const ColumnMajorMatrix &  cmm)
inlineexplicit

Definition at line 32 of file SymmTensor.h.

33  : _xx(cmm.numEntries() == 9 ? cmm.rawData()[0] : 0),
34  _yy(cmm.numEntries() == 9 ? cmm.rawData()[4] : 0),
35  _zz(cmm.numEntries() == 9 ? cmm.rawData()[8] : 0),
36  _xy(cmm.numEntries() == 9 ? cmm.rawData()[1] : 0),
37  _yz(cmm.numEntries() == 9 ? cmm.rawData()[5] : 0),
38  _zx(cmm.numEntries() == 9 ? cmm.rawData()[2] : 0)
39  {
40  if (cmm.numEntries() != 9)
41  {
42  mooseError("Cannot create SymmTensor from ColumnMajorMatrix. Wrong number of entries.");
43  }
44  }

◆ SymmTensor() [5/5]

SymmTensor::SymmTensor ( const std::vector< Real > &  init_list)
inlineexplicit

Definition at line 46 of file SymmTensor.h.

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

Member Function Documentation

◆ addDiag()

void SymmTensor::addDiag ( Real  value)
inline

◆ columnMajorMatrix()

ColumnMajorMatrix SymmTensor::columnMajorMatrix ( ) const
inline

Definition at line 425 of file SymmTensor.h.

426  {
427  ColumnMajorMatrix cmm(3, 3);
428  cmm(0, 0) = _xx;
429  cmm(1, 0) = _xy;
430  cmm(2, 0) = _zx;
431  cmm(0, 1) = _xy;
432  cmm(1, 1) = _yy;
433  cmm(2, 1) = _yz;
434  cmm(0, 2) = _zx;
435  cmm(1, 2) = _yz;
436  cmm(2, 2) = _zz;
437  return cmm;
438  }

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

◆ component()

Real SymmTensor::component ( unsigned int  i) const
inline

Definition at line 99 of file SymmTensor.h.

100  {
101  if (0 == i)
102  {
103  return _xx;
104  }
105  else if (1 == i)
106  {
107  return _yy;
108  }
109  else if (2 == i)
110  {
111  return _zz;
112  }
113  else if (3 == i)
114  {
115  return _xy;
116  }
117  else if (4 == i)
118  {
119  return _yz;
120  }
121  else if (5 == i)
122  {
123  return _zx;
124  }
125  else
126  {
127  mooseError("Invalid entry requested for SymmTensor");
128  }
129  return 0;
130  }

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

◆ doubleContraction()

Real SymmTensor::doubleContraction ( const SymmTensor rhs) const
inline

◆ fillFromInputVector()

void SymmTensor::fillFromInputVector ( const std::vector< Real > &  input)
inline

Definition at line 61 of file SymmTensor.h.

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

◆ genRandomSymmTensor()

static SymmTensor SymmTensor::genRandomSymmTensor ( Real  scalefactor)
inlinestatic

Definition at line 449 of file SymmTensor.h.

450  {
451 
452  SymmTensor tensor;
453 
454  tensor.xx() = (MooseRandom::rand() + 1.0) * scalefactor;
455  tensor.yy() = (MooseRandom::rand() + 1.0) * scalefactor;
456  tensor.zz() = (MooseRandom::rand() + 1.0) * scalefactor;
457  tensor.xy() = (MooseRandom::rand() + 1.0) * scalefactor;
458  tensor.yz() = (MooseRandom::rand() + 1.0) * scalefactor;
459  tensor.zx() = (MooseRandom::rand() + 1.0) * scalefactor;
460 
461  return tensor;
462  }

Referenced by RateDepSmearCrackModel::computeStress().

◆ identity()

void SymmTensor::identity ( )
inline

Definition at line 276 of file SymmTensor.h.

277  {
278  _xx = _yy = _zz = 1;
279  _xy = _yz = _zx = 0;
280  }

◆ initRandom()

static void SymmTensor::initRandom ( )
inlinestatic

Definition at line 442 of file SymmTensor.h.

443  {
444 
445  unsigned int randinit = 2000;
446  MooseRandom::seed(randinit);
447  }

Referenced by RateDepSmearCrackModel::RateDepSmearCrackModel().

◆ operator!=()

bool SymmTensor::operator!= ( const SymmTensor rhs) const
inline

Definition at line 292 of file SymmTensor.h.

292 { return !operator==(rhs); }

◆ operator()() [1/2]

Real& SymmTensor::operator() ( const unsigned  i,
const unsigned  j 
)
inline

Definition at line 149 of file SymmTensor.h.

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

◆ operator()() [2/2]

Real SymmTensor::operator() ( const unsigned  i,
const unsigned  j 
) const
inline

Definition at line 204 of file SymmTensor.h.

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

◆ operator*() [1/2]

Point SymmTensor::operator* ( const Point &  p) const
inline

Definition at line 341 of file SymmTensor.h.

342  {
343  return Point(_xx * p(0) + _xy * p(1) + _zx * p(2),
344  _xy * p(0) + _yy * p(1) + _yz * p(2),
345  _zx * p(0) + _yz * p(1) + _zz * p(2));
346  }

◆ operator*() [2/2]

SymmTensor SymmTensor::operator* ( Real  t) const
inline

Definition at line 328 of file SymmTensor.h.

329  {
330  SymmTensor r_val;
331 
332  r_val._xx = _xx * t;
333  r_val._yy = _yy * t;
334  r_val._zz = _zz * t;
335  r_val._xy = _xy * t;
336  r_val._yz = _yz * t;
337  r_val._zx = _zx * t;
338  return r_val;
339  }

◆ operator*=()

SymmTensor& SymmTensor::operator*= ( Real  val)
inline

Definition at line 414 of file SymmTensor.h.

415  {
416  _xx *= val;
417  _xy *= val;
418  _zx *= val;
419  _yy *= val;
420  _yz *= val;
421  _zz *= val;
422  return *this;
423  }

◆ operator+()

SymmTensor SymmTensor::operator+ ( const SymmTensor t) const
inline

Definition at line 316 of file SymmTensor.h.

317  {
318  SymmTensor r_val;
319  r_val._xx = _xx + t._xx;
320  r_val._yy = _yy + t._yy;
321  r_val._zz = _zz + t._zz;
322  r_val._xy = _xy + t._xy;
323  r_val._yz = _yz + t._yz;
324  r_val._zx = _zx + t._zx;
325  return r_val;
326  }

◆ operator+=() [1/2]

SymmTensor& SymmTensor::operator+= ( const ColumnMajorMatrix &  cmm)
inline

Definition at line 360 of file SymmTensor.h.

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

◆ operator+=() [2/2]

SymmTensor& SymmTensor::operator+= ( const SymmTensor t)
inline

Definition at line 294 of file SymmTensor.h.

295  {
296  _xx += t._xx;
297  _yy += t._yy;
298  _zz += t._zz;
299  _xy += t._xy;
300  _yz += t._yz;
301  _zx += t._zx;
302  return *this;
303  }

◆ operator-()

SymmTensor SymmTensor::operator- ( const SymmTensor t) const
inline

Definition at line 348 of file SymmTensor.h.

349  {
350  SymmTensor r_val;
351  r_val._xx = _xx - t._xx;
352  r_val._yy = _yy - t._yy;
353  r_val._zz = _zz - t._zz;
354  r_val._xy = _xy - t._xy;
355  r_val._yz = _yz - t._yz;
356  r_val._zx = _zx - t._zx;
357  return r_val;
358  }

◆ operator-=() [1/2]

SymmTensor& SymmTensor::operator-= ( const ColumnMajorMatrix &  cmm)
inline

Definition at line 374 of file SymmTensor.h.

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

◆ operator-=() [2/2]

SymmTensor& SymmTensor::operator-= ( const SymmTensor t)
inline

Definition at line 305 of file SymmTensor.h.

306  {
307  _xx -= t._xx;
308  _yy -= t._yy;
309  _zz -= t._zz;
310  _xy -= t._xy;
311  _yz -= t._yz;
312  _zx -= t._zx;
313  return *this;
314  }

◆ operator=() [1/2]

SymmTensor& SymmTensor::operator= ( const ColumnMajorMatrix &  cmm)
inline

Definition at line 389 of file SymmTensor.h.

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

◆ operator=() [2/2]

SymmTensor& SymmTensor::operator= ( Real  val)
inline

Definition at line 403 of file SymmTensor.h.

404  {
405  _xx = val;
406  _xy = val;
407  _zx = val;
408  _yy = val;
409  _yz = val;
410  _zz = val;
411  return *this;
412  }

◆ operator==()

bool SymmTensor::operator== ( const SymmTensor rhs) const
inline

Definition at line 287 of file SymmTensor.h.

288  {
289  return _xx == rhs._xx && _yy == rhs._yy && _zz == rhs._zz && _xy == rhs._xy && _yz == rhs._yz &&
290  _zx == rhs._zx;
291  }

Referenced by operator!=().

◆ rowDot()

Real SymmTensor::rowDot ( const unsigned int  r,
const libMesh::TypeVector< Real > &  v 
) const
inline

Definition at line 75 of file SymmTensor.h.

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

◆ trace()

Real SymmTensor::trace ( ) const
inline

◆ xx() [1/3]

Real& SymmTensor::xx ( )
inline

Definition at line 140 of file SymmTensor.h.

140 { return _xx; }

◆ xx() [2/3]

Real SymmTensor::xx ( ) const
inline

◆ xx() [3/3]

void SymmTensor::xx ( Real  xx)
inline

Definition at line 265 of file SymmTensor.h.

265 { _xx = xx; }

Referenced by xx().

◆ xy() [1/3]

Real& SymmTensor::xy ( )
inline

Definition at line 143 of file SymmTensor.h.

143 { return _xy; }

◆ xy() [2/3]

Real SymmTensor::xy ( ) const
inline

◆ xy() [3/3]

void SymmTensor::xy ( Real  xy)
inline

Definition at line 268 of file SymmTensor.h.

268 { _xy = xy; }

Referenced by xy().

◆ xz() [1/3]

Real& SymmTensor::xz ( )
inline

Definition at line 148 of file SymmTensor.h.

148 { return _zx; }

◆ xz() [2/3]

Real SymmTensor::xz ( ) const
inline

Definition at line 139 of file SymmTensor.h.

139 { return _zx; }

◆ xz() [3/3]

void SymmTensor::xz ( Real  xz)
inline

Definition at line 273 of file SymmTensor.h.

273 { _zx = xz; }

Referenced by xz().

◆ yx() [1/3]

Real& SymmTensor::yx ( )
inline

Definition at line 146 of file SymmTensor.h.

146 { return _xy; }

◆ yx() [2/3]

Real SymmTensor::yx ( ) const
inline

Definition at line 137 of file SymmTensor.h.

137 { return _xy; }

◆ yx() [3/3]

void SymmTensor::yx ( Real  yx)
inline

Definition at line 271 of file SymmTensor.h.

271 { _xy = yx; }

Referenced by yx().

◆ yy() [1/3]

Real& SymmTensor::yy ( )
inline

Definition at line 141 of file SymmTensor.h.

141 { return _yy; }

◆ yy() [2/3]

Real SymmTensor::yy ( ) const
inline

◆ yy() [3/3]

void SymmTensor::yy ( Real  yy)
inline

Definition at line 266 of file SymmTensor.h.

266 { _yy = yy; }

Referenced by yy().

◆ yz() [1/3]

Real& SymmTensor::yz ( )
inline

Definition at line 144 of file SymmTensor.h.

144 { return _yz; }

◆ yz() [2/3]

Real SymmTensor::yz ( ) const
inline

◆ yz() [3/3]

void SymmTensor::yz ( Real  yz)
inline

Definition at line 269 of file SymmTensor.h.

269 { _yz = yz; }

Referenced by yz().

◆ zero()

void SymmTensor::zero ( )
inline

Definition at line 275 of file SymmTensor.h.

275 { _xx = _yy = _zz = _xy = _yz = _zx = 0; }

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

◆ zx() [1/3]

Real& SymmTensor::zx ( )
inline

Definition at line 145 of file SymmTensor.h.

145 { return _zx; }

◆ zx() [2/3]

Real SymmTensor::zx ( ) const
inline

◆ zx() [3/3]

void SymmTensor::zx ( Real  zx)
inline

Definition at line 270 of file SymmTensor.h.

270 { _zx = zx; }

Referenced by zx().

◆ zy() [1/3]

Real& SymmTensor::zy ( )
inline

Definition at line 147 of file SymmTensor.h.

147 { return _yz; }

◆ zy() [2/3]

Real SymmTensor::zy ( ) const
inline

Definition at line 138 of file SymmTensor.h.

138 { return _yz; }

◆ zy() [3/3]

void SymmTensor::zy ( Real  zy)
inline

Definition at line 272 of file SymmTensor.h.

272 { _yz = zy; }

Referenced by zy().

◆ zz() [1/3]

Real& SymmTensor::zz ( )
inline

Definition at line 142 of file SymmTensor.h.

142 { return _zz; }

◆ zz() [2/3]

Real SymmTensor::zz ( ) const
inline

◆ zz() [3/3]

void SymmTensor::zz ( Real  zz)
inline

Definition at line 267 of file SymmTensor.h.

267 { _zz = zz; }

Referenced by zz().

Friends And Related Function Documentation

◆ operator<<

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

Definition at line 13 of file SymmTensor.C.

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

Member Data Documentation

◆ _xx

Real SymmTensor::_xx
private

◆ _xy

Real SymmTensor::_xy
private

◆ _yy

Real SymmTensor::_yy
private

◆ _yz

Real SymmTensor::_yz
private

◆ _zx

Real SymmTensor::_zx
private

◆ _zz

Real SymmTensor::_zz
private

The documentation for this class was generated from the following file:
SymmTensor::xx
Real xx() const
Definition: SymmTensor.h:131
SymmTensor::zx
Real zx() const
Definition: SymmTensor.h:136
SymmTensor::_zz
Real _zz
Definition: SymmTensor.h:467
SymmTensor::_zx
Real _zx
Definition: SymmTensor.h:470
SymmTensor::zz
Real zz() const
Definition: SymmTensor.h:133
SymmTensor::xz
Real xz() const
Definition: SymmTensor.h:139
SymmTensor::zy
Real zy() const
Definition: SymmTensor.h:138
SymmTensor::_yz
Real _yz
Definition: SymmTensor.h:469
SymmTensor::_xy
Real _xy
Definition: SymmTensor.h:468
SymmTensor::xy
Real xy() const
Definition: SymmTensor.h:134
SymmTensor::_xx
Real _xx
Definition: SymmTensor.h:465
SymmTensor::yz
Real yz() const
Definition: SymmTensor.h:135
SymmTensor::yx
Real yx() const
Definition: SymmTensor.h:137
SymmTensor
Definition: SymmTensor.h:21
SymmTensor::operator==
bool operator==(const SymmTensor &rhs) const
Definition: SymmTensor.h:287
SymmTensor::_yy
Real _yy
Definition: SymmTensor.h:466
SymmTensor::yy
Real yy() const
Definition: SymmTensor.h:132