https://mooseframework.inl.gov
Loading...
Searching...
No Matches
CrackFrontNonlocalMaterialBase.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
12
15{
17 params.addRequiredParam<UserObjectName>("crack_front_definition",
18 "The CrackFrontDefinition user object name");
19 params.addRequiredParam<Real>(
20 "box_length", "Dimension of property-averaging box in direction of crack extension.");
21 params.addRequiredParam<Real>(
22 "box_height", "Dimension of property-averaging box in direction normal to crack.");
23 params.addParam<Real>("box_width", 1.0, "Distance tangent to front of crack front.");
24 params.addParam<std::string>("base_name",
25 "Optional parameter that allows the user to define "
26 "multiple mechanics material systems on the same "
27 "block, i.e. for multiple phases");
28 params.set<bool>("use_displaced_mesh") = false;
29 params.set<ExecFlagEnum>("execute_on") = {EXEC_TIMESTEP_BEGIN};
30 params.addClassDescription("Computes the average material property at a crack front.");
31 return params;
32}
33
35 const std::string & property_name)
36 : ElementVectorPostprocessor(parameters),
37 _property_name(property_name),
38 _box_length(getParam<Real>("box_length")),
39 _box_width(getParam<Real>("box_width")),
40 _box_height(getParam<Real>("box_height")),
41 _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
42 _x(declareVector("x")),
43 _y(declareVector("y")),
44 _z(declareVector("z")),
45 _position(declareVector("id")),
46 // get the property name instead of materialname
47 _avg_crack_tip_scalar(declareVector("crack_tip_" + _base_name + _property_name))
48{
49 if (_mesh.dimension() == 3 && !isParamSetByUser("box_width"))
50 paramError("box_width", "Must define box_width in 3D problems.");
51 // add user object dependencies by name (the UOs do not need to exist yet for this)
52 _depend_uo.insert(getParam<UserObjectName>("crack_front_definition"));
53}
54
55void
57{
58 const auto uo_name = getParam<UserObjectName>("crack_front_definition");
60 &(getUserObjectByName<CrackFrontDefinition>(uo_name, /*is_dependency = */ false));
61}
62
63void
65{
66 std::size_t num_pts = _crack_front_definition->getNumCrackFrontPoints();
67
68 _volume.assign(num_pts, 0.0);
69 _x.assign(num_pts, 0.0);
70 _y.assign(num_pts, 0.0);
71 _z.assign(num_pts, 0.0);
72 _position.assign(num_pts, 0.0);
73 _avg_crack_tip_scalar.assign(num_pts, 0.0);
74}
75
76void
78{
79 // icfp crack front point index
80 for (const auto icfp : index_range(_avg_crack_tip_scalar))
81 {
82 Point crack_front_normal = _crack_front_definition->getCrackFrontNormal(icfp);
83 for (unsigned int qp = 0; qp < _qrule->n_points(); qp++)
84 {
85 Real q = BoxWeightingFunction(icfp, _q_point[qp]);
86 if (q == 0)
87 continue;
88
89 Real scalar = getQPCrackFrontScalar(qp, crack_front_normal);
90 _avg_crack_tip_scalar[icfp] += _JxW[qp] * _coord[qp] * scalar * q;
91 _volume[icfp] += _JxW[qp] * _coord[qp] * q;
92 }
93 }
94}
95
96void
98{
101 for (const auto icfp : index_range(_avg_crack_tip_scalar))
102 {
103 if (_volume[icfp] != 0)
105 else
106 _avg_crack_tip_scalar[icfp] = 0;
107
108 const auto cfp = _crack_front_definition->getCrackFrontPoint(icfp);
109 _x[icfp] = (*cfp)(0);
110 _y[icfp] = (*cfp)(1);
111 _z[icfp] = (*cfp)(2);
113 }
114}
115
116void
118{
119 const auto & uo = static_cast<const CrackFrontNonlocalMaterialBase &>(y);
120 for (const auto i : index_range(_avg_crack_tip_scalar))
121 {
122 _volume[i] += uo._volume[i];
123 _avg_crack_tip_scalar[i] += uo._avg_crack_tip_scalar[i];
124 }
125}
126
127Real
129 const Point & qp_coord) const
130{
131 const Point * cf_pt = _crack_front_definition->getCrackFrontPoint(crack_front_point_index);
132 RealVectorValue crack_node_to_current_node = qp_coord - *cf_pt;
133
134 // crackfront coordinates are:
135 // crack_node_to_current_node_rot[0]= crack direction
136 // crack_node_to_current_node_rot[1]= normal to crack face
137 // crack_node_to_current_node_rot[2]= tangent to crack face along crack front (not used in 2D)
138 RealVectorValue crack_node_to_current_node_rot =
139 _crack_front_definition->rotateToCrackFrontCoords(crack_node_to_current_node,
140 crack_front_point_index);
141 if ((crack_node_to_current_node_rot(0) > 0) &&
142 (crack_node_to_current_node_rot(0) <= _box_length) &&
143 (std::abs(crack_node_to_current_node_rot(1)) <= _box_height / 2) &&
144 (std::abs(crack_node_to_current_node_rot(2)) <= _box_width / 2))
145 return 1.0;
146
147 return 0.0;
148}
const std::vector< double > y
const ExecFlagType EXEC_TIMESTEP_BEGIN
const Point * getCrackFrontPoint(const std::size_t point_index) const
Get a Point object for a specified point on the crack front.
const RealVectorValue & getCrackFrontNormal(const std::size_t point_index) const
Get the vector normal to the crack front at a specified position.
Real getDistanceAlongFront(const std::size_t point_index) const
Get the distance along the crack front from the beginning of the crack to the specified position.
std::size_t getNumCrackFrontPoints() const
Get the number of points defining the crack front as a set of line segments.
RealVectorValue rotateToCrackFrontCoords(const RealVectorValue vector, const std::size_t point_index) const
Rotate a vector in the global coordinate coordinate system to the crack front local coordinate system...
Computes the average material property in regions near points provided by the crack_front_definition ...
CrackFrontNonlocalMaterialBase(const InputParameters &parameters, const std::string &property_name)
VectorPostprocessorValue & _x
Vectors computed by this VectorPostprocessor: x,y,z coordinates, and position of nodes along crack fr...
VectorPostprocessorValue & _avg_crack_tip_scalar
Real BoxWeightingFunction(std::size_t crack_front_point_index, const Point &qp_coord) const
Determine whether a point is located within a specified crack front oriented box.
const CrackFrontDefinition * _crack_front_definition
used to transform local coordinates to crack front coordinates
virtual Real getQPCrackFrontScalar(const unsigned int qp, const Point crack_face_normal) const =0
Determine whether a point is located within a specified crack front oriented box.
virtual void threadJoin(const UserObject &y) override
Real _box_length
dimensions of the box in front of the crack tip that the stress is averaged over The box is centered ...
const QBase *const & _qrule
const MooseArray< Real > & _coord
const MooseArray< Real > & _JxW
const MooseArray< Point > & _q_point
static InputParameters validParams()
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)
T & set(const std::string &name, bool quiet_mode=false)
void paramError(const std::string &param, Args... args) const
bool isParamSetByUser(const std::string &name) const
virtual unsigned int dimension() const
std::set< std::string > _depend_uo