www.mooseframework.org
XFEMRankTwoTensorMarkerUserObject.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 #include "RankTwoTensor.h"
12 #include "RankTwoScalarTools.h"
13 #include "Assembly.h"
14 #include <limits>
15 
16 template <>
17 InputParameters
19 {
20  InputParameters params = validParams<XFEMMarkerUserObject>();
21  params.addClassDescription(
22  "Mark elements to be cut by XFEM based on a scalar extracted from a RankTwoTensor");
23  params.addParam<MooseEnum>(
24  "scalar_type",
26  "Scalar quantity to be computed from tensor and used as a failure criterion");
27  params.addRequiredParam<std::string>("tensor", "The material tensor name.");
28  params.addRequiredCoupledVar("threshold", "The threshold for crack growth.");
29  params.addRequiredParam<bool>(
30  "average", "Should the tensor quantity be averaged over the quadrature points?");
31  params.addParam<Point>(
32  "point1",
33  Point(0, 0, 0),
34  "Start point for axis used to calculate some cylindrical material tensor quantities");
35  params.addParam<Point>(
36  "point2",
37  Point(0, 1, 0),
38  "End point for axis used to calculate some cylindrical material tensor quantities");
39  return params;
40 }
41 
43  const InputParameters & parameters)
44  : XFEMMarkerUserObject(parameters),
45  _tensor(getMaterialProperty<RankTwoTensor>(getParam<std::string>("tensor"))),
46  _scalar_type(getParam<MooseEnum>("scalar_type")),
47  _point1(parameters.get<Point>("point1")),
48  _point2(parameters.get<Point>("point2")),
49  _threshold(coupledValue("threshold")),
50  _average(getParam<bool>("average")),
51  _JxW(_assembly.JxW()),
52  _coord(_assembly.coordTransformation())
53 {
54 }
55 
56 bool
58 {
59  bool does_it_crack = false;
60  unsigned int numqp = _qrule->n_points();
61  Point zero; // Used for checking whether direction is zero
62 
63  if (_average)
64  {
65  Real average_threshold = 0.0;
66  RankTwoTensor average_tensor;
67  Point average_point;
68  for (unsigned int qp = 0; qp < numqp; ++qp)
69  {
70  if (_threshold[qp] <= 0.0)
71  mooseError("Threshold must be strictly positive in XFEMRankTwoTensorMarkerUserObject");
72  average_threshold += _JxW[qp] * _coord[qp] * _threshold[qp];
73  average_tensor += _JxW[qp] * _coord[qp] * _tensor[qp];
74  average_point += _JxW[qp] * _coord[qp] * _q_point[qp];
75  }
76  Point point_dir;
77  Real tensor_quantity = RankTwoScalarTools::getQuantity(
78  average_tensor, _scalar_type, _point1, _point2, average_point, point_dir);
79  if (point_dir.absolute_fuzzy_equals(zero))
80  mooseError("Direction has zero length in XFEMRankTwoTensorMarkerUserObject");
81  direction = point_dir;
82  if (tensor_quantity > average_threshold)
83  does_it_crack = true;
84  }
85  else
86  {
87  unsigned int max_index = std::numeric_limits<unsigned int>::max();
88  Real max_ratio = 0.0;
89  std::vector<Point> directions(numqp);
90  for (unsigned int qp = 0; qp < numqp; ++qp)
91  {
92  if (_threshold[qp] <= 0.0)
93  mooseError("Threshold must be strictly positive in XFEMRankTwoTensorMarkerUserObject");
94  const Real tensor_quantity = RankTwoScalarTools::getQuantity(
95  _tensor[qp], _scalar_type, _point1, _point2, _q_point[qp], directions[qp]);
96  if (directions[qp].absolute_fuzzy_equals(zero))
97  mooseError("Direction has zero length in XFEMRankTwoTensorMarkerUserObject");
98  Real ratio = tensor_quantity / _threshold[qp];
99  if (ratio > max_ratio)
100  {
101  max_ratio = ratio;
102  max_index = qp;
103  }
104  }
105  if (max_ratio > 1.0)
106  {
107  if (max_index == std::numeric_limits<unsigned int>::max())
108  mooseError("max_index out of bounds in XFEMRankTwoTensorMarkerUserObject");
109  does_it_crack = true;
110  direction = directions[max_index];
111  }
112  }
113 
114  return does_it_crack;
115 }
const MaterialProperty< RankTwoTensor > & _tensor
The tensor from which the scalar quantity used as a marking criterion is extracted.
const Point _point1
Points used to define an axis of rotation for some scalar quantities.
const VariableValue & _threshold
Threshold value of the scalar.
virtual bool doesElementCrack(RealVectorValue &direction) override
XFEMRankTwoTensorMarkerUserObject(const InputParameters &parameters)
InputParameters validParams< XFEMRankTwoTensorMarkerUserObject >()
MooseEnum _scalar_type
The type of scalar to be extracted from the tensor.
Coupled auxiliary value.
Real getQuantity(const RankTwoTensor &tensor, const MooseEnum scalar_type, const Point &point1, const Point &point2, const Point &curr_point, Point &direction)
const MooseArray< Real > & _JxW
Transformed Jacobian weights.
InputParameters validParams< XFEMMarkerUserObject >()
bool _average
Whether to average the value for all quadrature points in an element.