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

#include <XFEMMaterialTensorMarkerUserObject.h>

Inheritance diagram for XFEMMaterialTensorMarkerUserObject:
[legend]

Public Member Functions

 XFEMMaterialTensorMarkerUserObject (const InputParameters &parameters)
 
virtual ~XFEMMaterialTensorMarkerUserObject ()
 
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)
 Determine whether the current element should be cut by a new crack. More...
 

Protected Attributes

MaterialTensorCalculator _material_tensor_calculator
 
const MaterialProperty< SymmTensor > & _tensor
 
Real _threshold
 
bool _average
 
Real _random_range
 

Detailed Description

Definition at line 21 of file XFEMMaterialTensorMarkerUserObject.h.

Constructor & Destructor Documentation

◆ XFEMMaterialTensorMarkerUserObject()

XFEMMaterialTensorMarkerUserObject::XFEMMaterialTensorMarkerUserObject ( const InputParameters &  parameters)

Definition at line 31 of file XFEMMaterialTensorMarkerUserObject.C.

33  : XFEMMaterialStateMarkerBase(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"))
39 {
40  setRandomResetFrequency(EXEC_INITIAL);
41 }
XFEMMaterialStateMarkerBase(const InputParameters &parameters)
Factory constructor, takes parameters so that all derived classes can be built using the same constru...
const MaterialProperty< SymmTensor > & _tensor

◆ ~XFEMMaterialTensorMarkerUserObject()

virtual XFEMMaterialTensorMarkerUserObject::~XFEMMaterialTensorMarkerUserObject ( )
inlinevirtual

Definition at line 25 of file XFEMMaterialTensorMarkerUserObject.h.

25 {}

Member Function Documentation

◆ doesElementCrack()

bool XFEMMaterialTensorMarkerUserObject::doesElementCrack ( RealVectorValue &  direction)
protectedvirtual

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 44 of file XFEMMaterialTensorMarkerUserObject.C.

45 {
46  bool does_it_crack = false;
47  unsigned int numqp = _qrule->n_points();
48 
49  Real rnd_mult = (1.0 - _random_range / 2.0) + _random_range * getRandomReal();
50 
51  if (_average)
52  {
53  SymmTensor average_tensor;
54  for (unsigned int qp = 0; qp < numqp; ++qp)
55  {
56  average_tensor += _tensor[qp];
57  }
58  average_tensor *= 1.0 / (Real)numqp;
59  Real tensor_quantity =
60  _material_tensor_calculator.getTensorQuantity(average_tensor, _q_point[0], direction);
61  if (tensor_quantity > _threshold * rnd_mult)
62  does_it_crack = true;
63  }
64  else
65  {
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)
73  {
74  tensor_quantities[qp] =
75  _material_tensor_calculator.getTensorQuantity(_tensor[qp], _q_point[qp], directions[qp]);
76  if (directions[qp](0) == 0 && directions[qp](1) == 0 && directions[qp](2) == 0)
77  {
78  mooseError("Direction has zero length in XFEMMaterialTensorMarkerUserObject");
79  }
80  if (tensor_quantities[qp] > max_quantity)
81  {
82  max_quantity = tensor_quantities[qp];
83  max_index = qp;
84  }
85  }
86  if (max_quantity > _threshold * rnd_mult)
87  {
88  does_it_crack = true;
89  direction = directions[max_index];
90  }
91  }
92 
93  return does_it_crack;
94 }
Real getTensorQuantity(const SymmTensor &tensor, const Point &curr_point, RealVectorValue &direction)
const MaterialProperty< SymmTensor > & _tensor

◆ 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 XFEMMaterialTensorMarkerUserObject::_average
protected

Definition at line 31 of file XFEMMaterialTensorMarkerUserObject.h.

Referenced by doesElementCrack().

◆ _material_tensor_calculator

MaterialTensorCalculator XFEMMaterialTensorMarkerUserObject::_material_tensor_calculator
protected

Definition at line 28 of file XFEMMaterialTensorMarkerUserObject.h.

Referenced by doesElementCrack().

◆ _random_range

Real XFEMMaterialTensorMarkerUserObject::_random_range
protected

Definition at line 32 of file XFEMMaterialTensorMarkerUserObject.h.

Referenced by doesElementCrack().

◆ _tensor

const MaterialProperty<SymmTensor>& XFEMMaterialTensorMarkerUserObject::_tensor
protected

Definition at line 29 of file XFEMMaterialTensorMarkerUserObject.h.

Referenced by doesElementCrack().

◆ _threshold

Real XFEMMaterialTensorMarkerUserObject::_threshold
protected

Definition at line 30 of file XFEMMaterialTensorMarkerUserObject.h.

Referenced by doesElementCrack().


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