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