https://mooseframework.inl.gov
MeshCut2DFunctionUserObject.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 #include "CrackFrontDefinition.h"
12 
13 #include "libmesh/string_to_enum.h"
14 #include "MooseMesh.h"
15 #include "MooseEnum.h"
16 #include "libmesh/edge_edge2.h"
17 #include "libmesh/serial_mesh.h"
18 #include "libmesh/mesh_tools.h"
19 #include "Function.h"
20 
22 
25 {
27  params.addClassDescription("Creates a UserObject for a mesh cutter in 2D problems where crack "
28  "growth is specified by functions.");
29  params.addRequiredParam<FunctionName>("growth_direction_x",
30  "Function defining x-component of crack growth direction.");
31  params.addRequiredParam<FunctionName>("growth_direction_y",
32  "Function defining y-component of crack growth direction.");
33  params.addRequiredParam<FunctionName>("growth_rate", "Function defining crack growth rate.");
34  return params;
35 }
36 
38  : MeshCut2DUserObjectBase(parameters),
39  _func_x(&getFunction("growth_direction_x")),
40  _func_y(&getFunction("growth_direction_y")),
41  _growth_function(&getFunction("growth_rate")),
42  _time_of_previous_call_to_UO(std::numeric_limits<Real>::lowest())
43 {
44 }
45 
46 void
48 {
49  // Only call crack growth function if time changed.
51  {
54  growFront();
55  }
57 
58  // always trigger crack_front_definition to be updated
59  _is_mesh_modified = true;
61 }
62 
63 void
65 {
67  Point zero; // Used for checking whether direction is zero
68  for (unsigned int i = 0; i < _original_and_current_front_node_ids.size(); ++i)
69  {
70  // compute growth direction
71  Point dir;
72  Node * this_node = _cutter_mesh->node_ptr(_original_and_current_front_node_ids[i].second);
73  mooseAssert(this_node, "Node is NULL");
74  Point & this_point = *this_node;
75  dir(0) = _func_x->value(_t, this_point);
76  dir(1) = _func_y->value(_t, this_point);
77  dir = dir / dir.norm();
78 
79  // compute growth amount/velocity
80  Point nodal_offset;
81  Real velo = _growth_function->value(_t, Point(0, 0, 0));
82  nodal_offset = dir * velo * _dt;
83  // only increment the crack if the growth is positive
84  if (!nodal_offset.absolute_fuzzy_equals(zero))
86  std::make_pair(_original_and_current_front_node_ids[i].second, nodal_offset));
87  }
88 }
void isCutterModified(const bool is_cutter_modified)
Set the value of _is_cutter_modified.
static InputParameters validParams()
std::unique_ptr< MeshBase > _cutter_mesh
The xfem cutter mesh.
std::vector< std::pair< dof_id_type, dof_id_type > > _original_and_current_front_node_ids
This vector of pairs orders crack tips to make the order used in this class the same as those for the...
const Number zero
void addRequiredParam(const std::string &name, const std::string &doc_string)
MeshCut2DUserObjectBase: (1) reads in a mesh describing the crack surface, (2) Fills xfem cut element...
virtual void findActiveBoundaryGrowth() override
Find growth direction at each active node
MeshCut2DFunctionUserObject: (1) reads in a mesh describing the crack surface, (2) uses the mesh to d...
Real _time_of_previous_call_to_UO
Gets the time of the previous call to this user object.
void addNucleatedCracksToMesh()
Calls into MeshCutNucleation UO to add cracks.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
MeshCut2DFunctionUserObject(const InputParameters &parameters)
bool _is_mesh_modified
Indicator that shows if the cutting mesh is modified or not in this calculation step.
static InputParameters validParams()
registerMooseObject("XFEMApp", MeshCut2DFunctionUserObject)
void addClassDescription(const std::string &doc_string)
void growFront()
grow the cutter mesh
virtual Real value(Real t, const Point &p) const
const Function * _func_x
Parsed functions of front growth.
std::vector< std::pair< dof_id_type, Point > > _active_front_node_growth_vectors
contains the active node ids and their growth vectors
CrackFrontDefinition * _crack_front_definition
user object for communicating between solid_mechanics interaction integrals and xfem cutter mesh ...