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

Constructor & Destructor Documentation

◆ SymmTensor() [1/5]

SymmTensor::SymmTensor ( )
inline

Definition at line 25 of file SymmTensor.h.

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

◆ SymmTensor() [2/5]

SymmTensor::SymmTensor ( Real  init)
inlineexplicit

Definition at line 26 of file SymmTensor.h.

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

◆ SymmTensor() [3/5]

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

Definition at line 29 of file SymmTensor.h.

30  : _xx(xx), _yy(yy), _zz(zz), _xy(xy), _yz(yz), _zx(zx)
31  {
32  }
Real yz() const
Definition: SymmTensor.h:136
Real zx() const
Definition: SymmTensor.h:137
Real yy() const
Definition: SymmTensor.h:133
Real xx() const
Definition: SymmTensor.h:132
Real xy() const
Definition: SymmTensor.h:135
Real zz() const
Definition: SymmTensor.h:134

◆ SymmTensor() [4/5]

SymmTensor::SymmTensor ( const ColumnMajorMatrix &  cmm)
inlineexplicit

Definition at line 33 of file SymmTensor.h.

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

◆ SymmTensor() [5/5]

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

Definition at line 47 of file SymmTensor.h.

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

Member Function Documentation

◆ addDiag()

void SymmTensor::addDiag ( Real  value)
inline

◆ columnMajorMatrix()

ColumnMajorMatrix SymmTensor::columnMajorMatrix ( ) const
inline

Definition at line 426 of file SymmTensor.h.

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

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

◆ component()

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

Definition at line 100 of file SymmTensor.h.

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

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

◆ doubleContraction()

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

◆ fillFromInputVector()

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

Definition at line 62 of file SymmTensor.h.

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

◆ genRandomSymmTensor()

static SymmTensor SymmTensor::genRandomSymmTensor ( Real  scalefactor)
inlinestatic

Definition at line 450 of file SymmTensor.h.

Referenced by RateDepSmearCrackModel::computeStress().

451  {
452 
453  SymmTensor tensor;
454 
455  tensor.xx() = (MooseRandom::rand() + 1.0) * scalefactor;
456  tensor.yy() = (MooseRandom::rand() + 1.0) * scalefactor;
457  tensor.zz() = (MooseRandom::rand() + 1.0) * scalefactor;
458  tensor.xy() = (MooseRandom::rand() + 1.0) * scalefactor;
459  tensor.yz() = (MooseRandom::rand() + 1.0) * scalefactor;
460  tensor.zx() = (MooseRandom::rand() + 1.0) * scalefactor;
461 
462  return tensor;
463  }
Real yz() const
Definition: SymmTensor.h:136
Real zx() const
Definition: SymmTensor.h:137
Real yy() const
Definition: SymmTensor.h:133
Real xx() const
Definition: SymmTensor.h:132
Real xy() const
Definition: SymmTensor.h:135
Real zz() const
Definition: SymmTensor.h:134

◆ identity()

void SymmTensor::identity ( )
inline

Definition at line 277 of file SymmTensor.h.

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

◆ initRandom()

static void SymmTensor::initRandom ( )
inlinestatic

Definition at line 443 of file SymmTensor.h.

Referenced by RateDepSmearCrackModel::RateDepSmearCrackModel().

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

◆ operator!=()

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

Definition at line 293 of file SymmTensor.h.

293 { return !operator==(rhs); }
bool operator==(const SymmTensor &rhs) const
Definition: SymmTensor.h:288

◆ operator()() [1/2]

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

Definition at line 150 of file SymmTensor.h.

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

◆ operator()() [2/2]

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

Definition at line 205 of file SymmTensor.h.

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

◆ operator*() [1/2]

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

Definition at line 329 of file SymmTensor.h.

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

◆ operator*() [2/2]

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

Definition at line 342 of file SymmTensor.h.

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

◆ operator*=()

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

Definition at line 415 of file SymmTensor.h.

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

◆ operator+()

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

Definition at line 317 of file SymmTensor.h.

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

◆ operator+=() [1/2]

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

Definition at line 295 of file SymmTensor.h.

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

◆ operator+=() [2/2]

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

Definition at line 361 of file SymmTensor.h.

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

◆ operator-()

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

Definition at line 349 of file SymmTensor.h.

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

◆ operator-=() [1/2]

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

Definition at line 306 of file SymmTensor.h.

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

◆ operator-=() [2/2]

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

Definition at line 375 of file SymmTensor.h.

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

◆ operator=() [1/2]

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

Definition at line 390 of file SymmTensor.h.

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

◆ operator=() [2/2]

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

Definition at line 404 of file SymmTensor.h.

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

◆ operator==()

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

Definition at line 288 of file SymmTensor.h.

Referenced by operator!=().

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

◆ rowDot()

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

Definition at line 76 of file SymmTensor.h.

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

◆ trace()

Real SymmTensor::trace ( ) const
inline

◆ xx() [1/3]

Real SymmTensor::xx ( ) const
inline

◆ xx() [2/3]

Real& SymmTensor::xx ( )
inline

Definition at line 141 of file SymmTensor.h.

141 { return _xx; }

◆ xx() [3/3]

void SymmTensor::xx ( Real  xx)
inline

Definition at line 266 of file SymmTensor.h.

Referenced by xx().

266 { _xx = xx; }
Real xx() const
Definition: SymmTensor.h:132

◆ xy() [1/3]

Real SymmTensor::xy ( ) const
inline

◆ xy() [2/3]

Real& SymmTensor::xy ( )
inline

Definition at line 144 of file SymmTensor.h.

144 { return _xy; }

◆ xy() [3/3]

void SymmTensor::xy ( Real  xy)
inline

Definition at line 269 of file SymmTensor.h.

Referenced by xy().

269 { _xy = xy; }
Real xy() const
Definition: SymmTensor.h:135

◆ xz() [1/3]

Real SymmTensor::xz ( ) const
inline

Definition at line 140 of file SymmTensor.h.

140 { return _zx; }

◆ xz() [2/3]

Real& SymmTensor::xz ( )
inline

Definition at line 149 of file SymmTensor.h.

149 { return _zx; }

◆ xz() [3/3]

void SymmTensor::xz ( Real  xz)
inline

Definition at line 274 of file SymmTensor.h.

Referenced by xz().

274 { _zx = xz; }
Real xz() const
Definition: SymmTensor.h:140

◆ yx() [1/3]

Real SymmTensor::yx ( ) const
inline

Definition at line 138 of file SymmTensor.h.

138 { return _xy; }

◆ yx() [2/3]

Real& SymmTensor::yx ( )
inline

Definition at line 147 of file SymmTensor.h.

147 { return _xy; }

◆ yx() [3/3]

void SymmTensor::yx ( Real  yx)
inline

Definition at line 272 of file SymmTensor.h.

Referenced by yx().

272 { _xy = yx; }
Real yx() const
Definition: SymmTensor.h:138

◆ yy() [1/3]

Real SymmTensor::yy ( ) const
inline

◆ yy() [2/3]

Real& SymmTensor::yy ( )
inline

Definition at line 142 of file SymmTensor.h.

142 { return _yy; }

◆ yy() [3/3]

void SymmTensor::yy ( Real  yy)
inline

Definition at line 267 of file SymmTensor.h.

Referenced by yy().

267 { _yy = yy; }
Real yy() const
Definition: SymmTensor.h:133

◆ yz() [1/3]

Real SymmTensor::yz ( ) const
inline

◆ yz() [2/3]

Real& SymmTensor::yz ( )
inline

Definition at line 145 of file SymmTensor.h.

145 { return _yz; }

◆ yz() [3/3]

void SymmTensor::yz ( Real  yz)
inline

Definition at line 270 of file SymmTensor.h.

Referenced by yz().

270 { _yz = yz; }
Real yz() const
Definition: SymmTensor.h:136

◆ zero()

void SymmTensor::zero ( )
inline

Definition at line 276 of file SymmTensor.h.

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

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

◆ zx() [1/3]

Real SymmTensor::zx ( ) const
inline

◆ zx() [2/3]

Real& SymmTensor::zx ( )
inline

Definition at line 146 of file SymmTensor.h.

146 { return _zx; }

◆ zx() [3/3]

void SymmTensor::zx ( Real  zx)
inline

Definition at line 271 of file SymmTensor.h.

Referenced by zx().

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

◆ zy() [1/3]

Real SymmTensor::zy ( ) const
inline

Definition at line 139 of file SymmTensor.h.

139 { return _yz; }

◆ zy() [2/3]

Real& SymmTensor::zy ( )
inline

Definition at line 148 of file SymmTensor.h.

148 { return _yz; }

◆ zy() [3/3]

void SymmTensor::zy ( Real  zy)
inline

Definition at line 273 of file SymmTensor.h.

Referenced by zy().

273 { _yz = zy; }
Real zy() const
Definition: SymmTensor.h:139

◆ zz() [1/3]

Real SymmTensor::zz ( ) const
inline

◆ zz() [2/3]

Real& SymmTensor::zz ( )
inline

Definition at line 143 of file SymmTensor.h.

143 { return _zz; }

◆ zz() [3/3]

void SymmTensor::zz ( Real  zz)
inline

Definition at line 268 of file SymmTensor.h.

Referenced by zz().

268 { _zz = zz; }
Real zz() const
Definition: SymmTensor.h:134

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: