www.mooseframework.org
CrackFrontDefinition.h
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 
10 #pragma once
11 
12 #include "GeneralUserObject.h"
14 #include "BoundaryRestrictable.h"
15 #include <set>
16 #include "ADRankTwoTensorForward.h"
17 
18 class AuxiliarySystem;
19 
20 // libMesh forward declarations
21 namespace libMesh
22 {
23 class QBase;
24 }
25 
26 // fixme lynn this needs to be removed from the globalname space in a seperate commit
32 {
33 public:
35 
37  virtual ~CrackFrontDefinition();
38 
39  virtual void initialSetup() override;
40  virtual void initialize() override;
41  virtual void finalize() override;
42  virtual void execute() override;
43 
48  void updateNumberOfCrackFrontPoints(const std::size_t num_points);
49 
55  const Node * getCrackFrontNodePtr(const std::size_t node_index) const;
56 
62  const Point * getCrackFrontPoint(const std::size_t point_index) const;
63 
69  const RealVectorValue & getCrackFrontTangent(const std::size_t point_index) const;
70 
76  Real getCrackFrontForwardSegmentLength(const std::size_t point_index) const;
77 
83  Real getCrackFrontBackwardSegmentLength(const std::size_t point_index) const;
84 
90  const RealVectorValue & getCrackDirection(const std::size_t point_index) const;
91 
98  Real getDistanceAlongFront(const std::size_t point_index) const;
99 
104  bool hasAngleAlongFront() const;
105 
112  Real getAngleAlongFront(const std::size_t point_index) const;
113 
118  std::size_t getNumCrackFrontPoints() const;
119 
124  bool treatAs2D() const { return _treat_as_2d; }
125 
130  bool usingMeshCutter() const { return _use_mesh_cutter; }
131 
140  const std::size_t point_index) const;
149  const std::size_t point_index) const;
150 
158  const std::size_t point_index) const;
159 
168  void calculateRThetaToCrackFront(const Point qp,
169  const std::size_t point_index,
170  Real & r,
171  Real & theta) const;
172 
182  std::size_t calculateRThetaToCrackFront(const Point qp, Real & r, Real & theta) const;
183 
190  bool isNodeOnIntersectingBoundary(const Node * const node) const;
191 
198  bool isPointWithIndexOnIntersectingBoundary(const std::size_t point_index) const;
199 
205  Real getCrackFrontTangentialStrain(const std::size_t node_index) const;
206 
211  bool hasCrackFrontNodes() const
212  {
214  }
215 
224  bool isNodeInRing(const std::size_t ring_index,
225  const dof_id_type connected_node_id,
226  const std::size_t node_index) const;
227 
235  Real DomainIntegralQFunction(std::size_t crack_front_point_index,
236  std::size_t ring_index,
237  const Node * const current_node) const;
238 
246  Real DomainIntegralTopologicalQFunction(std::size_t crack_front_point_index,
247  std::size_t ring_index,
248  const Node * const current_node) const;
249 
253  void isCutterModified(const bool is_cutter_modified);
254 
255 protected:
257  const enum class DIRECTION_METHOD {
259  CRACK_MOUTH,
262 
265  const enum class END_DIRECTION_METHOD {
270 
273  {
277  };
278 
281  {
285 
291  static const Real _tol;
292 
294  std::vector<dof_id_type> _ordered_crack_front_nodes;
296  std::vector<Point> _crack_front_points;
298  std::vector<RealVectorValue> _tangent_directions;
300  std::vector<RealVectorValue> _crack_directions;
302  std::vector<std::pair<Real, Real>> _segment_lengths;
304  std::vector<Real> _distances_along_front;
306  std::vector<Real> _angles_along_front;
308  std::vector<Real> _strain_along_front;
310  std::vector<RankTwoTensor> _rot_matrix;
324  std::vector<BoundaryName> _crack_mouth_boundary_names;
326  std::vector<BoundaryID> _crack_mouth_boundary_ids;
328  std::vector<BoundaryName> _intersecting_boundary_names;
330  std::vector<BoundaryID> _intersecting_boundary_ids;
336  std::vector<RealVectorValue> _crack_plane_normals;
346  unsigned int _axis_2d;
350  unsigned int _symmetry_plane;
353  std::string _disp_x_var_name;
354  std::string _disp_y_var_name;
355  std::string _disp_z_var_name;
358  bool _t_stress;
362  std::size_t _last_ring;
364  std::size_t _first_ring;
368  std::map<std::pair<dof_id_type, std::size_t>, std::set<dof_id_type>>
376  std::vector<Real> _j_integral_radius_inner;
378  std::vector<Real> _j_integral_radius_outer;
384 
389  void getCrackFrontNodes(std::set<dof_id_type> & nodes);
390 
396  void orderCrackFrontNodes(std::set<dof_id_type> & nodes);
397 
405  void orderEndNodes(std::vector<dof_id_type> & end_nodes);
406 
417  void
418  pickLoopCrackEndNodes(std::vector<dof_id_type> & end_nodes,
419  std::set<dof_id_type> & nodes,
420  std::map<dof_id_type, std::vector<dof_id_type>> & node_to_line_elem_map,
421  std::vector<std::vector<dof_id_type>> & line_elems);
431  dof_id_type maxNodeCoor(std::vector<Node *> & nodes, unsigned int dir0 = 0);
432 
438 
444 
452  RealVectorValue calculateCrackFrontDirection(const Point & crack_front_point,
453  const RealVectorValue & tangent_direction,
454  const CRACK_NODE_TYPE ntype,
455  const std::size_t crack_front_point_index = 0) const;
456 
462 
467  void createQFunctionRings();
468 
481  void addNodesToQFunctionRing(std::set<dof_id_type> & nodes_new_ring,
482  const std::set<dof_id_type> & nodes_old_ring,
483  const std::set<dof_id_type> & nodes_all_rings,
484  const std::set<dof_id_type> & nodes_neighbor1,
485  const std::set<dof_id_type> & nodes_neighbor2,
486  std::vector<std::vector<const Elem *>> & nodes_to_elem_map);
487 
496  void projectToFrontAtPoint(Real & dist_to_front,
497  Real & dist_along_tangent,
498  std::size_t crack_front_point_index,
499  const Node * const current_node) const;
500 };
void calculateTangentialStrainAlongFront()
Compute the strain in the direction tangent to the crack at all points on the crack front...
void isCutterModified(const bool is_cutter_modified)
Set the value of _is_cutter_modified.
unsigned int _axis_2d
Out of plane axis when crack is treated as 2D.
void getCrackFrontNodes(std::set< dof_id_type > &nodes)
Get the set of all crack front nodes.
std::vector< BoundaryID > _intersecting_boundary_ids
IDs of boundaries that intersect crack at its ends.
bool isNodeOnIntersectingBoundary(const Node *const node) const
Determine whether a given node is on one of the boundaries that intersects an end of the crack front...
RealVectorValue calculateCrackFrontDirection(const Point &crack_front_point, const RealVectorValue &tangent_direction, const CRACK_NODE_TYPE ntype, const std::size_t crack_front_point_index=0) const
Compute the direction of crack extension for a given point on the crack front.
Real _overall_length
Overall length of the crack.
const RealVectorValue & getCrackFrontTangent(const std::size_t point_index) const
Get the vector tangent to the crack front at a specified position.
CrackFrontDefinition(const InputParameters &parameters)
std::vector< Point > _crack_front_points
Vector of points along the crack front.
void updateDataForCrackDirection()
Update the data structures used to determine the crack front direction vectors such as crack mouth co...
bool _has_symmetry_plane
Whether the crack plane is also a symmetry plane in the model.
virtual void execute() override
const Node * getCrackFrontNodePtr(const std::size_t node_index) const
Get the node pointer for a specified node on the crack front.
void addCrackFrontDefinitionParams(InputParameters &params)
std::size_t _first_ring
Numer of elements from crack tip to first topological ring.
void updateCrackFrontGeometry()
Update the data structures defining the crack front geometry such as the ordered crack front nodes/po...
Real getCrackFrontBackwardSegmentLength(const std::size_t point_index) const
Get the length of the line segment on the crack front behind the specified position.
enum CrackFrontDefinition::END_DIRECTION_METHOD _end_direction_method
CRACK_GEOM_DEFINITION
Enum used to define whether the crack front is defined using nodes or points.
std::vector< Real > _distances_along_front
Vector of distances along the crack front.
RealVectorValue _crack_direction_vector_end_2
Fixed vector optionally used to define crack extension direction at end 2 of crack front...
bool _use_mesh_cutter
Whether to describe the crack as a mesh cutter.
std::map< std::pair< dof_id_type, std::size_t >, std::set< dof_id_type > > _crack_front_node_to_node_map
Data structure used to store information about topological rings Key is a pair of the crack front nod...
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...
bool isNodeInRing(const std::size_t ring_index, const dof_id_type connected_node_id, const std::size_t node_index) const
Determine whether a node is contained within a specified volume integral element ring for a given nod...
void addNodesToQFunctionRing(std::set< dof_id_type > &nodes_new_ring, const std::set< dof_id_type > &nodes_old_ring, const std::set< dof_id_type > &nodes_all_rings, const std::set< dof_id_type > &nodes_neighbor1, const std::set< dof_id_type > &nodes_neighbor2, std::vector< std::vector< const Elem *>> &nodes_to_elem_map)
Find nodes that are connected through elements to the nodes in the previous node ring.
bool _q_function_rings
Whether topological rings are used to define the q functions.
const CrackFrontPointsProvider * _crack_front_points_provider
Pointer to a CrackFrontPointsProvider object optionally used to define the crack front points...
bool hasAngleAlongFront() const
Whether the distance along the crack front is available as an angle.
Real DomainIntegralQFunction(std::size_t crack_front_point_index, std::size_t ring_index, const Node *const current_node) const
Compute the q function for the case where it is defined geometrically.
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...
AuxiliarySystem & _aux
Reference to the auxiliary system.
std::vector< BoundaryID > _crack_mouth_boundary_ids
IDs of boundaries used to define location of crack mouth.
Real DomainIntegralTopologicalQFunction(std::size_t crack_front_point_index, std::size_t ring_index, const Node *const current_node) const
Compute the q function for the case where it is defined through element connectivity.
bool hasCrackFrontNodes() const
Determine whether the crack front was defined using nodes.
bool isPointWithIndexOnIntersectingBoundary(const std::size_t point_index) const
Determine whether a given crack front point is on one of the boundaries that intersects an end of the...
std::vector< RealVectorValue > _crack_plane_normals
Vector normals to a nonplanar crack described by the cutter mesh when _use_mesh_cutter = true...
void updateNumberOfCrackFrontPoints(const std::size_t num_points)
Change the number of crack front nodes.
void pickLoopCrackEndNodes(std::vector< dof_id_type > &end_nodes, std::set< dof_id_type > &nodes, std::map< dof_id_type, std::vector< dof_id_type >> &node_to_line_elem_map, std::vector< std::vector< dof_id_type >> &line_elems)
For the case of a crack that is a complete loop, determine which of the nodes should be the start and...
static const Real _tol
Tolerance used in geometric calculations.
std::vector< RankTwoTensor > _rot_matrix
Vector of rotation matrices along the crack front.
RealVectorValue rotateFromCrackFrontCoordsToGlobal(const RealVectorValue vector, const std::size_t point_index) const
Rotate a vector from crack front cartesian coordinate to global cartesian coordinate.
enum CrackFrontDefinition::CRACK_GEOM_DEFINITION _geom_definition_method
Class used in fracture integrals to define geometric characteristics of the crack front...
std::size_t getNumCrackFrontPoints() const
Get the number of points defining the crack front as a set of line segments.
void orderCrackFrontNodes(std::set< dof_id_type > &nodes)
Arrange the crack front nodes by their position along the crack front, and put them in the _ordered_c...
dof_id_type maxNodeCoor(std::vector< Node *> &nodes, unsigned int dir0=0)
Find the node with the maximum value of its coordinate.
CRACK_NODE_TYPE
Enum used to define the type of the nodes on the crack front (end or middle)
bool _closed_loop
Whether the crack forms a closed loop.
const Point * getCrackFrontPoint(const std::size_t point_index) const
Get a Point object for a specified point on the crack front.
void calculateRThetaToCrackFront(const Point qp, const std::size_t point_index, Real &r, Real &theta) const
Calculate r and theta of a point in the crack front polar coordinates for a given crack point index...
bool _is_cutter_modified
Indicator that shows if the cutter mesh is modified or not in the calculation step.
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...
Base class for crack front points provider.
virtual void initialSetup() override
std::vector< Real > _strain_along_front
Vector of tangential strain along the crack front.
std::vector< RealVectorValue > _crack_directions
Vector of crack extension directions along the crack front.
std::vector< bool > _is_point_on_intersecting_boundary
Vector of bools indicating whether individual crack front points are on an intersecting boundary...
const RealVectorValue & getCrackDirection(const std::size_t point_index) const
Get the unit vector of the crack extension direction at the specified position.
RealVectorValue _crack_direction_vector
Fixed vector optionally used to define crack extension direction.
DIRECTION_METHOD
Enum used to define the method for computing the crack extension direction.
RealVectorValue _crack_plane_normal
Vector normal to the crack plane of a planar crack.
std::vector< BoundaryName > _crack_mouth_boundary_names
Names of boundaries used to define location of crack mouth.
MooseMesh & _mesh
Reference to the mesh.
void orderEndNodes(std::vector< dof_id_type > &end_nodes)
Determine which of the end nodes should be the starting point of the crack front. ...
void projectToFrontAtPoint(Real &dist_to_front, Real &dist_along_tangent, std::size_t crack_front_point_index, const Node *const current_node) const
Project a point to a specified point along the crack front and compute the projected normal and tange...
void createQFunctionRings()
Create the data defining the rings used to define the q function when the topological option is used ...
std::vector< Real > _j_integral_radius_outer
Vector of outer radii of the rings used for geometric q functions.
unsigned int _symmetry_plane
Which plane is the symmetry plane.
END_DIRECTION_METHOD
Enum used to define the method for computing the crack extension direction at the ends of the crack...
std::string _disp_x_var_name
Names of the x, y, and z displacement variables.
std::size_t _num_points_from_provider
Number of points coming from the CrackFrontPointsProvider.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< RealVectorValue > _tangent_directions
Vector of tangent directions along the crack front.
static InputParameters validParams()
Real getAngleAlongFront(const std::size_t point_index) const
Get the angle along the crack front from the beginning of the crack to the specified position...
std::vector< dof_id_type > _ordered_crack_front_nodes
Crack front nodes ordered from the start to end of the crack front.
std::vector< BoundaryName > _intersecting_boundary_names
Names of boundaries that intersect crack at its ends.
Real getCrackFrontTangentialStrain(const std::size_t node_index) const
Get the strain in the direction tangent to the crack front at a given point.
const InputParameters & parameters() const
Real getCrackFrontForwardSegmentLength(const std::size_t point_index) const
Get the length of the line segment on the crack front ahead of the specified position.
MooseEnum _q_function_type
Method used to define the q function.
bool _t_stress
Whether the T-stress is being computed.
virtual void initialize() override
RealVectorValue _crack_tangent_vector_end_2
Fixed vector optionally used to define crack tangent direction at end 2 of crack front.
bool usingMeshCutter() const
Is the crack defined by a mesh cutter object.
std::size_t _last_ring
Numer of elements from crack tip to last topological ring.
std::vector< Real > _angles_along_front
Vector of angles along the crack front.
std::vector< std::pair< Real, Real > > _segment_lengths
Vector of segment lengths along the crack front.
virtual void finalize() override
RealVectorValue _crack_tangent_vector_end_1
Fixed vector optionally used to define crack tangent direction at end 1 of crack front.
bool _treat_as_2d
Whether to treat the model as 2D for computation of fracture integrals.
RealVectorValue _crack_direction_vector_end_1
Fixed vector optionally used to define crack extension direction at end 1 of crack front...
bool treatAs2D() const
Whether the fracture computations are treated as 2D for the model.
std::vector< Real > _j_integral_radius_inner
Vector of inner radii of the rings used for geometric q functions.
uint8_t dof_id_type
RealVectorValue _crack_mouth_coordinates
Coordinates of crack mouth.
enum CrackFrontDefinition::DIRECTION_METHOD _direction_method