12 #include "libmesh/quadrature.h"
22 params.addRequiredParam<std::string>(
"tensor",
"The material tensor name.");
23 params.addRequiredParam<Real>(
"threshold",
"The threshold for crack growth.");
24 params.addRequiredParam<
bool>(
25 "average",
"Should the tensor quantity be averaged over the quadruature points?");
26 params.addParam<Real>(
27 "random_range", 0.0,
"Range of a uniform random distribution for the threshold");
32 const InputParameters & parameters)
34 _material_tensor_calculator(parameters),
35 _tensor(getMaterialProperty<
SymmTensor>(getParam<std::string>(
"tensor"))),
36 _threshold(getParam<Real>(
"threshold")),
37 _average(getParam<bool>(
"average")),
38 _random_range(getParam<Real>(
"random_range"))
40 setRandomResetFrequency(EXEC_INITIAL);
46 bool does_it_crack =
false;
47 unsigned int numqp = _qrule->n_points();
54 for (
unsigned int qp = 0; qp < numqp; ++qp)
58 average_tensor *= 1.0 / (Real)numqp;
59 Real tensor_quantity =
66 unsigned int max_index = 999999;
67 std::vector<Real> tensor_quantities;
68 tensor_quantities.reserve(numqp);
69 Real max_quantity = 0;
70 std::vector<RealVectorValue> directions;
71 directions.resize(numqp);
72 for (
unsigned int qp = 0; qp < numqp; ++qp)
74 tensor_quantities[qp] =
76 if (directions[qp](0) == 0 && directions[qp](1) == 0 && directions[qp](2) == 0)
78 mooseError(
"Direction has zero length in XFEMMaterialTensorMarkerUserObject");
80 if (tensor_quantities[qp] > max_quantity)
82 max_quantity = tensor_quantities[qp];
89 direction = directions[max_index];