www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
XFEMRankTwoTensorMarkerUserObject Class Reference

#include <XFEMRankTwoTensorMarkerUserObject.h>

Inheritance diagram for XFEMRankTwoTensorMarkerUserObject:
[legend]

Public Member Functions

 XFEMRankTwoTensorMarkerUserObject (const InputParameters &parameters)
 
virtual ~XFEMRankTwoTensorMarkerUserObject ()
 
virtual void initialize () override
 
virtual void execute () override
 
virtual void threadJoin (const UserObject &y) override
 
virtual void finalize () override
 

Protected Member Functions

virtual bool doesElementCrack (RealVectorValue &direction) override
 Determine whether the current element should be cut by a new crack. More...
 

Protected Attributes

const MaterialProperty< RankTwoTensor > & _tensor
 The tensor from which the scalar quantity used as a marking criterion is extracted. More...
 
MooseEnum _scalar_type
 The type of scalar to be extracted from the tensor. More...
 
const Point _point1
 Points used to define an axis of rotation for some scalar quantities. More...
 
const Point _point2
 
const VariableValue & _threshold
 Threshold value of the scalar. More...
 
bool _average
 Whether to average the value for all quadrature points in an element. More...
 
const MooseArray< Real > & _JxW
 Transformed Jacobian weights. More...
 
const MooseArray< Real > & _coord
 

Detailed Description

Definition at line 21 of file XFEMRankTwoTensorMarkerUserObject.h.

Constructor & Destructor Documentation

◆ XFEMRankTwoTensorMarkerUserObject()

XFEMRankTwoTensorMarkerUserObject::XFEMRankTwoTensorMarkerUserObject ( const InputParameters &  parameters)

Definition at line 46 of file XFEMRankTwoTensorMarkerUserObject.C.

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 }
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.
MooseEnum _scalar_type
The type of scalar to be extracted from the tensor.
XFEMMaterialStateMarkerBase(const InputParameters &parameters)
Factory constructor, takes parameters so that all derived classes can be built using the same constru...
const MooseArray< Real > & _JxW
Transformed Jacobian weights.
bool _average
Whether to average the value for all quadrature points in an element.

◆ ~XFEMRankTwoTensorMarkerUserObject()

virtual XFEMRankTwoTensorMarkerUserObject::~XFEMRankTwoTensorMarkerUserObject ( )
inlinevirtual

Definition at line 25 of file XFEMRankTwoTensorMarkerUserObject.h.

25 {}

Member Function Documentation

◆ doesElementCrack()

bool XFEMRankTwoTensorMarkerUserObject::doesElementCrack ( RealVectorValue &  direction)
overrideprotectedvirtual

Determine whether the current element should be cut by a new crack.

Parameters
directionNormal direction of crack if it is cracked
Returns
bool true if element cracks

Reimplemented from XFEMMaterialStateMarkerBase.

Definition at line 61 of file XFEMRankTwoTensorMarkerUserObject.C.

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 }
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.
MooseEnum _scalar_type
The type of scalar to be extracted from the tensor.
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.
bool _average
Whether to average the value for all quadrature points in an element.

◆ execute()

void XFEMMaterialStateMarkerBase::execute ( )
overridevirtualinherited

Definition at line 62 of file XFEMMaterialStateMarkerBase.C.

63 {
64  RealVectorValue direction;
65  bool isCut = _xfem->isElemCut(_current_elem);
66  bool isCTE = _xfem->isElemAtCrackTip(_current_elem);
67  bool isOnBoundary = false;
68  unsigned int boundarySide = 99999;
69  unsigned int _current_eid = _current_elem->id();
70  std::map<unsigned int, RealVectorValue>::iterator mit;
71  mit = _marked_elems.find(_current_eid);
72 
73  for (unsigned int i = 0; i < _initiation_boundary_ids.size(); ++i)
74  {
75  if (_mesh.isBoundaryElem(_current_eid, _initiation_boundary_ids[i]))
76  {
77  isOnBoundary = true;
78  boundarySide = _mesh.sideWithBoundaryID(_current_elem, _initiation_boundary_ids[i]);
79  }
80  }
81 
82  if (isCTE && doesElementCrack(direction))
83  {
84  if (mit != _marked_elems.end())
85  {
86  mooseError("ERROR: element ", _current_eid, " already marked for crack growth.");
87  }
88  _marked_elems[_current_eid] = direction;
89  }
90  else if (isOnBoundary && doesElementCrack(direction))
91  {
92  if (mit != _marked_elems.end())
93  {
94  mooseError("ERROR: element ", _current_eid, " already marked for crack growth.");
95  }
96  _marked_elems[_current_eid] = direction;
97  _marked_elem_sides[_current_eid] = boundarySide;
98  }
99  else if (isCut && _secondary_cracks && doesElementCrack(direction))
100  {
101  if (mit != _marked_elems.end())
102  {
103  mooseError("ERROR: element ", _current_eid, " already marked for crack growth.");
104  }
105  _marked_elems[_current_eid] = direction;
106  _marked_frags.insert(_current_eid);
107  }
108 }
std::map< unsigned int, unsigned int > _marked_elem_sides
std::vector< BoundaryID > _initiation_boundary_ids
std::set< unsigned int > _marked_frags
std::map< unsigned int, RealVectorValue > _marked_elems
virtual bool doesElementCrack(RealVectorValue &direction)
Determine whether the current element should be cut by a new crack.

◆ finalize()

void XFEMMaterialStateMarkerBase::finalize ( )
overridevirtualinherited

Definition at line 138 of file XFEMMaterialStateMarkerBase.C.

139 {
140  _communicator.set_union(_marked_elems);
141  _communicator.set_union(_marked_frags);
142  _communicator.set_union(_marked_elem_sides);
143 
144  _xfem->clearStateMarkedElems();
145  std::map<unsigned int, RealVectorValue>::iterator mit;
146  for (mit = _marked_elems.begin(); mit != _marked_elems.end(); ++mit)
147  {
148  if (_marked_elem_sides.find(mit->first) != _marked_elem_sides.end())
149  {
150  _xfem->addStateMarkedElem(mit->first, mit->second, _marked_elem_sides[mit->first]);
151  }
152  else if (_marked_frags.find(mit->first) != _marked_frags.end())
153  {
154  _xfem->addStateMarkedFrag(mit->first, mit->second);
155  }
156  else
157  {
158  _xfem->addStateMarkedElem(mit->first, mit->second);
159  }
160  }
161  _marked_elems.clear();
162  _marked_frags.clear();
163  _marked_elem_sides.clear();
164 }
std::map< unsigned int, unsigned int > _marked_elem_sides
std::set< unsigned int > _marked_frags
std::map< unsigned int, RealVectorValue > _marked_elems

◆ initialize()

void XFEMMaterialStateMarkerBase::initialize ( )
overridevirtualinherited

Definition at line 53 of file XFEMMaterialStateMarkerBase.C.

54 {
55  _marked_elems.clear();
57  .clear(); // mark the fragment which has secondary crack growing from the primary crack
58  _marked_elem_sides.clear();
59 }
std::map< unsigned int, unsigned int > _marked_elem_sides
std::set< unsigned int > _marked_frags
std::map< unsigned int, RealVectorValue > _marked_elems

◆ threadJoin()

void XFEMMaterialStateMarkerBase::threadJoin ( const UserObject &  y)
overridevirtualinherited

Definition at line 111 of file XFEMMaterialStateMarkerBase.C.

112 {
113  const XFEMMaterialStateMarkerBase & xmuo = dynamic_cast<const XFEMMaterialStateMarkerBase &>(y);
114 
115  for (std::map<unsigned int, RealVectorValue>::const_iterator mit = xmuo._marked_elems.begin();
116  mit != xmuo._marked_elems.end();
117  ++mit)
118  {
119  _marked_elems[mit->first] = mit->second; // TODO do error checking for duplicates here too
120  }
121 
122  for (std::set<unsigned int>::const_iterator mit = xmuo._marked_frags.begin();
123  mit != xmuo._marked_frags.end();
124  ++mit)
125  {
126  _marked_frags.insert(*mit); // TODO do error checking for duplicates here too
127  }
128 
129  for (std::map<unsigned int, unsigned int>::const_iterator mit = xmuo._marked_elem_sides.begin();
130  mit != xmuo._marked_elem_sides.end();
131  ++mit)
132  {
133  _marked_elem_sides[mit->first] = mit->second; // TODO do error checking for duplicates here too
134  }
135 }
std::map< unsigned int, unsigned int > _marked_elem_sides
std::set< unsigned int > _marked_frags
std::map< unsigned int, RealVectorValue > _marked_elems

Member Data Documentation

◆ _average

bool XFEMRankTwoTensorMarkerUserObject::_average
protected

Whether to average the value for all quadrature points in an element.

Definition at line 42 of file XFEMRankTwoTensorMarkerUserObject.h.

Referenced by doesElementCrack().

◆ _coord

const MooseArray<Real>& XFEMRankTwoTensorMarkerUserObject::_coord
protected

Definition at line 46 of file XFEMRankTwoTensorMarkerUserObject.h.

Referenced by doesElementCrack().

◆ _JxW

const MooseArray<Real>& XFEMRankTwoTensorMarkerUserObject::_JxW
protected

Transformed Jacobian weights.

Definition at line 45 of file XFEMRankTwoTensorMarkerUserObject.h.

Referenced by doesElementCrack().

◆ _point1

const Point XFEMRankTwoTensorMarkerUserObject::_point1
protected

Points used to define an axis of rotation for some scalar quantities.

Definition at line 35 of file XFEMRankTwoTensorMarkerUserObject.h.

Referenced by doesElementCrack().

◆ _point2

const Point XFEMRankTwoTensorMarkerUserObject::_point2
protected

Definition at line 36 of file XFEMRankTwoTensorMarkerUserObject.h.

Referenced by doesElementCrack().

◆ _scalar_type

MooseEnum XFEMRankTwoTensorMarkerUserObject::_scalar_type
protected

The type of scalar to be extracted from the tensor.

Definition at line 32 of file XFEMRankTwoTensorMarkerUserObject.h.

Referenced by doesElementCrack().

◆ _tensor

const MaterialProperty<RankTwoTensor>& XFEMRankTwoTensorMarkerUserObject::_tensor
protected

The tensor from which the scalar quantity used as a marking criterion is extracted.

Definition at line 29 of file XFEMRankTwoTensorMarkerUserObject.h.

Referenced by doesElementCrack().

◆ _threshold

const VariableValue& XFEMRankTwoTensorMarkerUserObject::_threshold
protected

Threshold value of the scalar.

Definition at line 39 of file XFEMRankTwoTensorMarkerUserObject.h.

Referenced by doesElementCrack().


The documentation for this class was generated from the following files: