www.mooseframework.org
XFEMMaterialTensorMarkerUserObject.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
9 
10 #include "libmesh/quadrature.h"
11 
12 template <>
13 InputParameters
15 {
16  InputParameters params = validParams<XFEMMarkerUserObject>();
18  params.addRequiredParam<std::string>("tensor", "The material tensor name.");
19  params.addRequiredParam<Real>("threshold", "The threshold for crack growth.");
20  params.addRequiredParam<bool>(
21  "average", "Should the tensor quantity be averaged over the quadruature points?");
22  params.addParam<Real>(
23  "random_range", 0.0, "Range of a uniform random distribution for the threshold");
24  return params;
25 }
26 
28  const InputParameters & parameters)
29  : XFEMMarkerUserObject(parameters),
30  _material_tensor_calculator(parameters),
31  _tensor(getMaterialProperty<SymmTensor>(getParam<std::string>("tensor"))),
32  _threshold(getParam<Real>("threshold")),
33  _average(getParam<bool>("average")),
34  _random_range(getParam<Real>("random_range"))
35 {
36  setRandomResetFrequency(EXEC_INITIAL);
37 }
38 
39 bool
41 {
42  bool does_it_crack = false;
43  unsigned int numqp = _qrule->n_points();
44 
45  Real rnd_mult = (1.0 - _random_range / 2.0) + _random_range * getRandomReal();
46 
47  if (_average)
48  {
49  SymmTensor average_tensor;
50  for (unsigned int qp = 0; qp < numqp; ++qp)
51  {
52  average_tensor += _tensor[qp];
53  }
54  average_tensor *= 1.0 / (Real)numqp;
55  Real tensor_quantity =
56  _material_tensor_calculator.getTensorQuantity(average_tensor, _q_point[0], direction);
57  if (tensor_quantity > _threshold * rnd_mult)
58  does_it_crack = true;
59  }
60  else
61  {
62  unsigned int max_index = 999999;
63  std::vector<Real> tensor_quantities;
64  tensor_quantities.reserve(numqp);
65  Real max_quantity = 0;
66  std::vector<RealVectorValue> directions;
67  directions.resize(numqp);
68  for (unsigned int qp = 0; qp < numqp; ++qp)
69  {
70  tensor_quantities[qp] =
71  _material_tensor_calculator.getTensorQuantity(_tensor[qp], _q_point[qp], directions[qp]);
72  if (directions[qp](0) == 0 && directions[qp](1) == 0 && directions[qp](2) == 0)
73  {
74  mooseError("Direction has zero length in XFEMMaterialTensorMarkerUserObject");
75  }
76  if (tensor_quantities[qp] > max_quantity)
77  {
78  max_quantity = tensor_quantities[qp];
79  max_index = qp;
80  }
81  }
82  if (max_quantity > _threshold * rnd_mult)
83  {
84  does_it_crack = true;
85  direction = directions[max_index];
86  }
87  }
88 
89  return does_it_crack;
90 }
InputParameters validParams< MaterialTensorCalculator >()
Real getTensorQuantity(const SymmTensor &tensor, const Point &curr_point, RealVectorValue &direction)
XFEMMaterialTensorMarkerUserObject(const InputParameters &parameters)
Coupled auxiliary value.
virtual bool doesElementCrack(RealVectorValue &direction)
const MaterialProperty< SymmTensor > & _tensor
InputParameters validParams< XFEMMaterialTensorMarkerUserObject >()
InputParameters validParams< XFEMMarkerUserObject >()