https://mooseframework.inl.gov
Loading...
Searching...
No Matches
XFEMRankTwoTensorMarkerUserObject.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
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
22{
25 "Mark elements to be cut by XFEM based on a scalar extracted from a RankTwoTensor");
26 params.addParam<MooseEnum>(
27 "scalar_type",
29 "Scalar quantity to be computed from tensor and used as a failure criterion");
30 params.addRequiredParam<std::string>("tensor", "The material tensor name.");
31 params.addRequiredCoupledVar("threshold", "The threshold for crack growth.");
32 params.addRequiredParam<bool>(
33 "average", "Should the tensor quantity be averaged over the quadrature points?");
34 params.addParam<Point>(
35 "point1",
36 Point(0, 0, 0),
37 "Start point for axis used to calculate some cylindrical material tensor quantities");
38 params.addParam<Point>(
39 "point2",
40 Point(0, 1, 0),
41 "End point for axis used to calculate some cylindrical material tensor quantities");
42 return params;
43}
44
46 const InputParameters & parameters)
47 : XFEMMaterialStateMarkerBase(parameters),
48 _tensor(getMaterialProperty<RankTwoTensor>(getParam<std::string>("tensor"))),
49 _scalar_type(getParam<MooseEnum>("scalar_type")),
50 _point1(parameters.get<Point>("point1")),
51 _point2(parameters.get<Point>("point2")),
52 _threshold(coupledValue("threshold")),
53 _average(getParam<bool>("average")),
54 _JxW(_assembly.JxW()),
55 _coord(_assembly.coordTransformation())
56{
57}
58
59bool
61{
62 bool does_it_crack = false;
63 unsigned int numqp = _qrule->n_points();
64 Point zero; // Used for checking whether direction is zero
65
66 if (_average)
67 {
68 Real average_threshold = 0.0;
69 RankTwoTensor average_tensor;
70 Point average_point;
71 for (unsigned int qp = 0; qp < numqp; ++qp)
72 {
73 if (_threshold[qp] <= 0.0)
74 mooseError("Threshold must be strictly positive in XFEMRankTwoTensorMarkerUserObject");
75 average_threshold += _JxW[qp] * _coord[qp] * _threshold[qp];
76 average_tensor += _JxW[qp] * _coord[qp] * _tensor[qp];
77 average_point += _JxW[qp] * _coord[qp] * _q_point[qp];
78 }
79 Point point_dir;
80 Real tensor_quantity = RankTwoScalarTools::getQuantity(
81 average_tensor, _scalar_type, _point1, _point2, average_point, point_dir);
82 if (point_dir.absolute_fuzzy_equals(zero))
83 mooseError("Direction has zero length in XFEMRankTwoTensorMarkerUserObject");
84 direction = point_dir;
85 if (tensor_quantity > average_threshold)
86 does_it_crack = true;
87 }
88 else
89 {
90 unsigned int max_index = std::numeric_limits<unsigned int>::max();
91 Real max_ratio = 0.0;
92 std::vector<Point> directions(numqp);
93 for (unsigned int qp = 0; qp < numqp; ++qp)
94 {
95 if (_threshold[qp] <= 0.0)
96 mooseError("Threshold must be strictly positive in XFEMRankTwoTensorMarkerUserObject");
97 const Real tensor_quantity = RankTwoScalarTools::getQuantity(
98 _tensor[qp], _scalar_type, _point1, _point2, _q_point[qp], directions[qp]);
99 if (directions[qp].absolute_fuzzy_equals(zero))
100 mooseError("Direction has zero length in XFEMRankTwoTensorMarkerUserObject");
101 Real ratio = tensor_quantity / _threshold[qp];
102 if (ratio > max_ratio)
103 {
104 max_ratio = ratio;
105 max_index = qp;
106 }
107 }
108 if (max_ratio > 1.0)
109 {
110 if (max_index == std::numeric_limits<unsigned int>::max())
111 mooseError("max_index out of bounds in XFEMRankTwoTensorMarkerUserObject");
112 does_it_crack = true;
113 direction = directions[max_index];
114 }
115 }
116
117 return does_it_crack;
118}
registerMooseObject("XFEMApp", XFEMRankTwoTensorMarkerUserObject)
const QBase *const & _qrule
const MooseArray< Point > & _q_point
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void mooseError(Args &&... args) const
static InputParameters validParams()
Factory constructor, takes parameters so that all derived classes can be built using the same constru...
const VariableValue & _threshold
Threshold value of the scalar.
const MooseArray< Real > & _JxW
Transformed Jacobian weights.
const Point _point1
Points used to define an axis of rotation for some scalar quantities.
XFEMRankTwoTensorMarkerUserObject(const InputParameters &parameters)
bool _average
Whether to average the value for all quadrature points in an element.
MooseEnum _scalar_type
The type of scalar to be extracted from the tensor.
const MaterialProperty< RankTwoTensor > & _tensor
The tensor from which the scalar quantity used as a marking criterion is extracted.
virtual bool doesElementCrack(RealVectorValue &direction) override
Determine whether the current element should be cut by a new crack.
MooseEnum scalarOptions()
This enum is left for legacy calls.
T getQuantity(const RankTwoTensorTempl< T > &tensor, const MooseEnum &scalar_type, const Point &point1, const Point &point2, const Point &curr_point, Point &direction)