www.mooseframework.org
DomainIntegralAction.C
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 // MOOSE includes
11 #include "DomainIntegralAction.h"
12 #include "Factory.h"
13 #include "FEProblem.h"
14 #include "Parser.h"
15 #include "CrackFrontDefinition.h"
16 #include "MooseMesh.h"
17 
18 #include "libmesh/string_to_enum.h"
19 
20 registerMooseAction("TensorMechanicsApp", DomainIntegralAction, "add_user_object");
21 
22 registerMooseAction("TensorMechanicsApp", DomainIntegralAction, "add_aux_variable");
23 
24 registerMooseAction("TensorMechanicsApp", DomainIntegralAction, "add_aux_kernel");
25 
26 registerMooseAction("TensorMechanicsApp", DomainIntegralAction, "add_postprocessor");
27 
28 registerMooseAction("TensorMechanicsApp", DomainIntegralAction, "add_material");
29 
31 
32 InputParameters
34 {
35  InputParameters params = Action::validParams();
37  MultiMooseEnum integral_vec("JIntegral InteractionIntegralKI InteractionIntegralKII "
38  "InteractionIntegralKIII InteractionIntegralT");
39  params.addClassDescription(
40  "Creates the MOOSE objects needed to compute fraction domain integrals");
41  params.addRequiredParam<MultiMooseEnum>("integrals",
42  integral_vec,
43  "Domain integrals to calculate. Choices are: " +
44  integral_vec.getRawNames());
45  params.addParam<std::vector<BoundaryName>>(
46  "boundary", "The list of boundary IDs from the mesh where this boundary condition applies");
47  params.addParam<std::vector<Point>>("crack_front_points", "Set of points to define crack front");
48  params.addParam<std::string>(
49  "order", "FIRST", "Specifies the order of the FE shape function to use for q AuxVariables");
50  params.addParam<std::string>(
51  "family", "LAGRANGE", "Specifies the family of FE shape functions to use for q AuxVariables");
52  params.addParam<std::vector<Real>>("radius_inner", "Inner radius for volume integral domain");
53  params.addParam<std::vector<Real>>("radius_outer", "Outer radius for volume integral domain");
54  params.addParam<unsigned int>("ring_first",
55  "The first ring of elements for volume integral domain");
56  params.addParam<unsigned int>("ring_last",
57  "The last ring of elements for volume integral domain");
58  params.addParam<std::vector<VariableName>>(
59  "output_variable", "Variable values to be reported along the crack front");
60  params.addParam<bool>(
61  "convert_J_to_K", false, "Convert J-integral to stress intensity factor K.");
62  params.addParam<Real>("poissons_ratio", "Poisson's ratio");
63  params.addParam<Real>("youngs_modulus", "Young's modulus");
64  params.addParam<std::vector<SubdomainName>>("block", "The block ids where integrals are defined");
65 
66  params.addParam<std::vector<VariableName>>(
67  "displacements",
68  "The displacements appropriate for the simulation geometry and coordinate system");
69  params.addParam<VariableName>("disp_x", "The x displacement");
70  params.addParam<VariableName>("disp_y", "The y displacement");
71  params.addParam<VariableName>("disp_z", "The z displacement");
72  params.addParam<VariableName>("temperature", "", "The temperature");
73  MooseEnum position_type("Angle Distance", "Distance");
74  params.addParam<MooseEnum>(
75  "position_type",
76  position_type,
77  "The method used to calculate position along crack front. Options are: " +
78  position_type.getRawNames());
79  MooseEnum q_function_type("Geometry Topology", "Geometry");
80  params.addParam<MooseEnum>("q_function_type",
81  q_function_type,
82  "The method used to define the integration domain. Options are: " +
83  q_function_type.getRawNames());
84  params.addParam<bool>(
85  "equivalent_k",
86  false,
87  "Calculate an equivalent K from KI, KII and KIII, assuming self-similar crack growth.");
88  params.addParam<bool>("output_q", true, "Output q");
89  params.addParam<bool>("solid_mechanics",
90  false,
91  "Set to true if the solid_mechanics system is "
92  "used.");
93  params.addRequiredParam<bool>(
94  "incremental", "Flag to indicate whether an incremental or total model is being used.");
95  params.addParam<std::vector<MaterialPropertyName>>(
96  "eigenstrain_names", "List of eigenstrains applied in the strain calculation");
97  return params;
98 }
99 
100 DomainIntegralAction::DomainIntegralAction(const InputParameters & params)
101  : Action(params),
102  _boundary_names(getParam<std::vector<BoundaryName>>("boundary")),
103  _closed_loop(getParam<bool>("closed_loop")),
104  _use_crack_front_points_provider(false),
105  _order(getParam<std::string>("order")),
106  _family(getParam<std::string>("family")),
107  _direction_method_moose_enum(getParam<MooseEnum>("crack_direction_method")),
108  _end_direction_method_moose_enum(getParam<MooseEnum>("crack_end_direction_method")),
109  _have_crack_direction_vector(false),
110  _have_crack_direction_vector_end_1(false),
111  _have_crack_direction_vector_end_2(false),
112  _treat_as_2d(getParam<bool>("2d")),
113  _axis_2d(getParam<unsigned int>("axis_2d")),
114  _convert_J_to_K(false),
115  _has_symmetry_plane(isParamValid("symmetry_plane")),
116  _symmetry_plane(_has_symmetry_plane ? getParam<unsigned int>("symmetry_plane")
117  : std::numeric_limits<unsigned int>::max()),
118  _position_type(getParam<MooseEnum>("position_type")),
119  _q_function_type(getParam<MooseEnum>("q_function_type")),
120  _get_equivalent_k(getParam<bool>("equivalent_k")),
121  _use_displaced_mesh(false),
122  _output_q(getParam<bool>("output_q")),
123  _solid_mechanics(getParam<bool>("solid_mechanics")),
124  _incremental(getParam<bool>("incremental"))
125 {
126  if (_q_function_type == GEOMETRY)
127  {
128  if (isParamValid("radius_inner") && isParamValid("radius_outer"))
129  {
130  _radius_inner = getParam<std::vector<Real>>("radius_inner");
131  _radius_outer = getParam<std::vector<Real>>("radius_outer");
132  }
133  else
134  mooseError("DomainIntegral error: must set radius_inner and radius_outer.");
135  for (unsigned int i = 0; i < _radius_inner.size(); ++i)
136  _ring_vec.push_back(i + 1);
137  }
138  else if (_q_function_type == TOPOLOGY)
139  {
140  if (isParamValid("ring_first") && isParamValid("ring_last"))
141  {
142  _ring_first = getParam<unsigned int>("ring_first");
143  _ring_last = getParam<unsigned int>("ring_last");
144  }
145  else
146  mooseError(
147  "DomainIntegral error: must set ring_first and ring_last if q_function_type = Topology.");
148  for (unsigned int i = _ring_first; i <= _ring_last; ++i)
149  _ring_vec.push_back(i);
150  }
151  else
152  mooseError("DomainIntegral error: invalid q_function_type.");
153 
154  if (isParamValid("crack_front_points"))
155  _crack_front_points = getParam<std::vector<Point>>("crack_front_points");
156 
157  if (isParamValid("crack_front_points_provider"))
158  {
159  if (!isParamValid("number_points_from_provider"))
160  mooseError("DomainIntegral error: when crack_front_points_provider is used, the "
161  "number_points_from_provider must be "
162  "provided.");
164  _crack_front_points_provider = getParam<UserObjectName>("crack_front_points_provider");
165  }
166  else if (isParamValid("number_points_from_provider"))
167  mooseError("DomainIntegral error: number_points_from_provider is provided but "
168  "crack_front_points_provider cannot "
169  "be found.");
170  if (isParamValid("crack_direction_vector"))
171  {
172  _crack_direction_vector = getParam<RealVectorValue>("crack_direction_vector");
174  }
175  if (isParamValid("crack_direction_vector_end_1"))
176  {
177  _crack_direction_vector_end_1 = getParam<RealVectorValue>("crack_direction_vector_end_1");
179  }
180  if (isParamValid("crack_direction_vector_end_2"))
181  {
182  _crack_direction_vector_end_2 = getParam<RealVectorValue>("crack_direction_vector_end_2");
184  }
185  if (isParamValid("crack_mouth_boundary"))
186  _crack_mouth_boundary_names = getParam<std::vector<BoundaryName>>("crack_mouth_boundary");
187  if (isParamValid("intersecting_boundary"))
188  _intersecting_boundary_names = getParam<std::vector<BoundaryName>>("intersecting_boundary");
189  if (_radius_inner.size() != _radius_outer.size())
190  mooseError("Number of entries in 'radius_inner' and 'radius_outer' must match.");
191 
192  bool youngs_modulus_set(false);
193  bool poissons_ratio_set(false);
194  MultiMooseEnum integral_moose_enums = getParam<MultiMooseEnum>("integrals");
195  if (integral_moose_enums.size() == 0)
196  mooseError("Must specify at least one domain integral to perform.");
197  for (unsigned int i = 0; i < integral_moose_enums.size(); ++i)
198  {
199  if (integral_moose_enums[i] != "JIntegral")
200  {
201  // Check that parameters required for interaction integrals are defined
202  if (isParamValid("displacements"))
203  {
204  _displacements = getParam<std::vector<VariableName>>("displacements");
205 
206  if (_displacements.size() < 2)
207  mooseError(
208  "DomainIntegral error: The size of the displacements vector should atleast be 2.");
209  }
210  else
211  {
212  if (isParamValid("disp_x") || isParamValid("disp_y") || isParamValid("disp_z"))
213  mooseDeprecated("DomainIntegral Warning: disp_x, disp_y and disp_z are deprecated. "
214  "Please specify displacements using the `dispalcements` parameter.");
215 
216  if (!isParamValid("disp_x") || !isParamValid("disp_y"))
217  mooseError(
218  "DomainIntegral error: Specify displacements using the `displacements` parameter.");
219  else
220  {
221  _displacements.clear();
222  _displacements.push_back(getParam<VariableName>("disp_x"));
223  _displacements.push_back(getParam<VariableName>("disp_y"));
224  if (isParamValid("disp_z"))
225  _displacements.push_back(getParam<VariableName>("disp_z"));
226  }
227  }
228 
229  if (!(isParamValid("poissons_ratio")) || !(isParamValid("youngs_modulus")))
230  mooseError(
231  "DomainIntegral error: must set Poisson's ratio and Young's modulus for integral: ",
232  integral_moose_enums[i]);
233 
234  if (!(isParamValid("block")))
235  mooseError("DomainIntegral error: must set block ID or name for integral: ",
236  integral_moose_enums[i]);
237 
238  _poissons_ratio = getParam<Real>("poissons_ratio");
239  poissons_ratio_set = true;
240  _youngs_modulus = getParam<Real>("youngs_modulus");
241  youngs_modulus_set = true;
242  _blocks = getParam<std::vector<SubdomainName>>("block");
243  }
244 
245  _integrals.insert(INTEGRAL(int(integral_moose_enums.get(i))));
246  }
247 
248  if (isParamValid("temperature"))
249  _temp = getParam<VariableName>("temperature");
250 
251  if (_temp != "" && !isParamValid("eigenstrain_names") && !_solid_mechanics)
252  mooseError(
253  "DomainIntegral error: must provide `eigenstrain_names` when temperature is coupled.");
254 
256  _integrals.count(INTERACTION_INTEGRAL_KII) == 0 ||
258  mooseError("DomainIntegral error: must calculate KI, KII and KIII to get equivalent K.");
259 
260  if (isParamValid("output_variable"))
261  {
262  _output_variables = getParam<std::vector<VariableName>>("output_variable");
263  if (_crack_front_points.size() > 0)
264  mooseError("'output_variables' not yet supported with 'crack_front_points'");
265  }
266 
267  if (isParamValid("convert_J_to_K"))
268  _convert_J_to_K = getParam<bool>("convert_J_to_K");
269  if (_convert_J_to_K)
270  {
271  if (!isParamValid("youngs_modulus") || !isParamValid("poissons_ratio"))
272  mooseError("DomainIntegral error: must set Young's modulus and Poisson's ratio for "
273  "J-integral if convert_J_to_K = true.");
274  if (!youngs_modulus_set)
275  _youngs_modulus = getParam<Real>("youngs_modulus");
276  if (!poissons_ratio_set)
277  _poissons_ratio = getParam<Real>("poissons_ratio");
278  }
279 }
280 
282 
283 void
285 {
286  const std::string uo_name("crackFrontDefinition");
287  const std::string ak_base_name("q");
288  const std::string av_base_name("q");
289  const unsigned int num_crack_front_points = calcNumCrackFrontPoints();
290  const std::string aux_stress_base_name("aux_stress");
291  const std::string aux_grad_disp_base_name("aux_grad_disp");
292 
293  if (_current_task == "add_user_object")
294  {
295  const std::string uo_type_name("CrackFrontDefinition");
296 
297  InputParameters params = _factory.getValidParams(uo_type_name);
298  params.set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL, EXEC_TIMESTEP_END};
299  params.set<MooseEnum>("crack_direction_method") = _direction_method_moose_enum;
300  params.set<MooseEnum>("crack_end_direction_method") = _end_direction_method_moose_enum;
302  params.set<RealVectorValue>("crack_direction_vector") = _crack_direction_vector;
304  params.set<RealVectorValue>("crack_direction_vector_end_1") = _crack_direction_vector_end_1;
306  params.set<RealVectorValue>("crack_direction_vector_end_2") = _crack_direction_vector_end_2;
307  if (_crack_mouth_boundary_names.size() != 0)
308  params.set<std::vector<BoundaryName>>("crack_mouth_boundary") = _crack_mouth_boundary_names;
309  if (_intersecting_boundary_names.size() != 0)
310  params.set<std::vector<BoundaryName>>("intersecting_boundary") = _intersecting_boundary_names;
311  params.set<bool>("2d") = _treat_as_2d;
312  params.set<unsigned int>("axis_2d") = _axis_2d;
314  params.set<unsigned int>("symmetry_plane") = _symmetry_plane;
315  if (_boundary_names.size() != 0)
316  params.set<std::vector<BoundaryName>>("boundary") = _boundary_names;
317  if (_crack_front_points.size() != 0)
318  params.set<std::vector<Point>>("crack_front_points") = _crack_front_points;
320  params.applyParameters(parameters(),
321  {"crack_front_points_provider, number_points_from_provider"});
322  if (_closed_loop)
323  params.set<bool>("closed_loop") = _closed_loop;
324  params.set<bool>("use_displaced_mesh") = _use_displaced_mesh;
325  if (_integrals.count(INTERACTION_INTEGRAL_T) != 0)
326  {
327  params.set<VariableName>("disp_x") = _displacements[0];
328  params.set<VariableName>("disp_y") = _displacements[1];
329  if (_displacements.size() == 3)
330  params.set<VariableName>("disp_z") = _displacements[2];
331  params.set<bool>("t_stress") = true;
332  }
333 
334  unsigned int nrings = 0;
335  if (_q_function_type == TOPOLOGY)
336  {
337  params.set<bool>("q_function_rings") = true;
338  params.set<unsigned int>("last_ring") = _ring_last;
339  params.set<unsigned int>("first_ring") = _ring_first;
340  nrings = _ring_last - _ring_first + 1;
341  }
342  else if (_q_function_type == GEOMETRY)
343  {
344  params.set<std::vector<Real>>("j_integral_radius_inner") = _radius_inner;
345  params.set<std::vector<Real>>("j_integral_radius_outer") = _radius_outer;
346  nrings = _ring_vec.size();
347  }
348 
349  params.set<unsigned int>("nrings") = nrings;
350  params.set<MooseEnum>("q_function_type") = _q_function_type;
351 
352  _problem->addUserObject(uo_type_name, uo_name, params);
353  }
354  else if (_current_task == "add_aux_variable" && _output_q)
355  {
356  for (unsigned int ring_index = 0; ring_index < _ring_vec.size(); ++ring_index)
357  {
358  std::string aux_var_type;
359  if (_family == "LAGRANGE")
360  aux_var_type = "MooseVariable";
361  else if (_family == "MONOMIAL")
362  aux_var_type = "MooseVariableConstMonomial";
363  else if (_family == "SCALAR")
364  aux_var_type = "MooseVariableScalar";
365  else
366  mooseError("Unsupported finite element family in, " + name() +
367  ". Please use LAGRANGE, MONOMIAL, or SCALAR");
368 
369  auto params = _factory.getValidParams(aux_var_type);
370  params.set<MooseEnum>("order") = _order;
371  params.set<MooseEnum>("family") = _family;
372 
373  if (_treat_as_2d)
374  {
375  std::ostringstream av_name_stream;
376  av_name_stream << av_base_name << "_" << _ring_vec[ring_index];
377  _problem->addAuxVariable(aux_var_type, av_name_stream.str(), params);
378  }
379  else
380  {
381  for (unsigned int cfp_index = 0; cfp_index < num_crack_front_points; ++cfp_index)
382  {
383  std::ostringstream av_name_stream;
384  av_name_stream << av_base_name << "_" << cfp_index + 1 << "_" << _ring_vec[ring_index];
385  _problem->addAuxVariable(aux_var_type, av_name_stream.str(), params);
386  }
387  }
388  }
389  }
390 
391  else if (_current_task == "add_aux_kernel" && _output_q)
392  {
393  std::string ak_type_name;
394  unsigned int nrings = 0;
395  if (_q_function_type == GEOMETRY)
396  {
397  ak_type_name = "DomainIntegralQFunction";
398  nrings = _ring_vec.size();
399  }
400  else if (_q_function_type == TOPOLOGY)
401  {
402  ak_type_name = "DomainIntegralTopologicalQFunction";
403  nrings = _ring_last - _ring_first + 1;
404  }
405 
406  InputParameters params = _factory.getValidParams(ak_type_name);
407  params.set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL, EXEC_TIMESTEP_END};
408  params.set<UserObjectName>("crack_front_definition") = uo_name;
409  params.set<bool>("use_displaced_mesh") = _use_displaced_mesh;
410 
411  for (unsigned int ring_index = 0; ring_index < nrings; ++ring_index)
412  {
413  if (_q_function_type == GEOMETRY)
414  {
415  params.set<Real>("j_integral_radius_inner") = _radius_inner[ring_index];
416  params.set<Real>("j_integral_radius_outer") = _radius_outer[ring_index];
417  }
418  else if (_q_function_type == TOPOLOGY)
419  {
420  params.set<unsigned int>("ring_index") = _ring_first + ring_index;
421  }
422 
423  if (_treat_as_2d)
424  {
425  std::ostringstream ak_name_stream;
426  ak_name_stream << ak_base_name << "_" << _ring_vec[ring_index];
427  std::ostringstream av_name_stream;
428  av_name_stream << av_base_name << "_" << _ring_vec[ring_index];
429  params.set<AuxVariableName>("variable") = av_name_stream.str();
430  _problem->addAuxKernel(ak_type_name, ak_name_stream.str(), params);
431  }
432  else
433  {
434  for (unsigned int cfp_index = 0; cfp_index < num_crack_front_points; ++cfp_index)
435  {
436  std::ostringstream ak_name_stream;
437  ak_name_stream << ak_base_name << "_" << cfp_index + 1 << "_" << _ring_vec[ring_index];
438  std::ostringstream av_name_stream;
439  av_name_stream << av_base_name << "_" << cfp_index + 1 << "_" << _ring_vec[ring_index];
440  params.set<AuxVariableName>("variable") = av_name_stream.str();
441  params.set<unsigned int>("crack_front_point_index") = cfp_index;
442  _problem->addAuxKernel(ak_type_name, ak_name_stream.str(), params);
443  }
444  }
445  }
446  }
447 
448  else if (_current_task == "add_postprocessor")
449  {
450  if (_integrals.count(J_INTEGRAL) != 0)
451  {
452  std::string pp_base_name;
453  if (_convert_J_to_K)
454  pp_base_name = "K";
455  else
456  pp_base_name = "J";
457  const std::string pp_type_name("JIntegral");
458  InputParameters params = _factory.getValidParams(pp_type_name);
459  params.set<ExecFlagEnum>("execute_on") = EXEC_TIMESTEP_END;
460  params.set<UserObjectName>("crack_front_definition") = uo_name;
461  params.set<bool>("convert_J_to_K") = _convert_J_to_K;
462  if (_convert_J_to_K)
463  {
464  params.set<Real>("youngs_modulus") = _youngs_modulus;
465  params.set<Real>("poissons_ratio") = _poissons_ratio;
466  }
468  params.set<unsigned int>("symmetry_plane") = _symmetry_plane;
469  params.set<bool>("use_displaced_mesh") = _use_displaced_mesh;
470  for (unsigned int ring_index = 0; ring_index < _ring_vec.size(); ++ring_index)
471  {
472  params.set<unsigned int>("ring_index") = _ring_vec[ring_index];
473  if (_q_function_type == TOPOLOGY)
474  params.set<unsigned int>("ring_first") = _ring_first;
475  params.set<MooseEnum>("q_function_type") = _q_function_type;
476 
477  if (_treat_as_2d)
478  {
479  std::ostringstream av_name_stream;
480  av_name_stream << av_base_name << "_" << _ring_vec[ring_index];
481  std::ostringstream pp_name_stream;
482  pp_name_stream << pp_base_name << "_" << _ring_vec[ring_index];
483  _problem->addPostprocessor(pp_type_name, pp_name_stream.str(), params);
484  }
485  else
486  {
487  for (unsigned int cfp_index = 0; cfp_index < num_crack_front_points; ++cfp_index)
488  {
489  std::ostringstream av_name_stream;
490  av_name_stream << av_base_name << "_" << cfp_index + 1 << "_" << _ring_vec[ring_index];
491  std::ostringstream pp_name_stream;
492  pp_name_stream << pp_base_name << "_" << cfp_index + 1 << "_" << _ring_vec[ring_index];
493  params.set<unsigned int>("crack_front_point_index") = cfp_index;
494  _problem->addPostprocessor(pp_type_name, pp_name_stream.str(), params);
495  }
496  }
497  }
498  }
499  if (_integrals.count(INTERACTION_INTEGRAL_KI) != 0 ||
500  _integrals.count(INTERACTION_INTEGRAL_KII) != 0 ||
503  {
504 
507  mooseError("In DomainIntegral, symmetry_plane option cannot be used with mode-II or "
508  "mode-III interaction integral");
509 
510  const std::string pp_base_name("II");
511  std::string pp_type_name("InteractionIntegral");
512 
513  if (_solid_mechanics)
514  pp_type_name = "InteractionIntegralSM";
515 
516  InputParameters params = _factory.getValidParams(pp_type_name);
517  params.set<ExecFlagEnum>("execute_on") = EXEC_TIMESTEP_END;
518  params.set<UserObjectName>("crack_front_definition") = uo_name;
519  params.set<bool>("use_displaced_mesh") = _use_displaced_mesh;
521  params.set<unsigned int>("symmetry_plane") = _symmetry_plane;
522  params.set<Real>("poissons_ratio") = _poissons_ratio;
523  params.set<Real>("youngs_modulus") = _youngs_modulus;
524  params.set<std::vector<VariableName>>("displacements") = _displacements;
525  if (_temp != "")
526  params.set<std::vector<VariableName>>("temperature") = {_temp};
528  params.set<unsigned int>("symmetry_plane") = _symmetry_plane;
529 
530  for (std::set<INTEGRAL>::iterator sit = _integrals.begin(); sit != _integrals.end(); ++sit)
531  {
532  std::string pp_base_name;
533  std::string aux_mode_name;
534  switch (*sit)
535  {
536  case J_INTEGRAL:
537  continue;
538 
540  pp_base_name = "II_KI";
541  aux_mode_name = "_I_";
542  params.set<Real>("K_factor") =
543  0.5 * _youngs_modulus / (1.0 - std::pow(_poissons_ratio, 2.0));
544  params.set<MooseEnum>("sif_mode") = "KI";
545  break;
546 
548  pp_base_name = "II_KII";
549  aux_mode_name = "_II_";
550  params.set<Real>("K_factor") =
551  0.5 * _youngs_modulus / (1.0 - std::pow(_poissons_ratio, 2.0));
552  params.set<MooseEnum>("sif_mode") = "KII";
553  break;
554 
556  pp_base_name = "II_KIII";
557  aux_mode_name = "_III_";
558  params.set<Real>("K_factor") = 0.5 * _youngs_modulus / (1.0 + _poissons_ratio);
559  params.set<MooseEnum>("sif_mode") = "KIII";
560  break;
561 
563  pp_base_name = "II_T";
564  aux_mode_name = "_T_";
565  params.set<Real>("K_factor") = _youngs_modulus / (1 - std::pow(_poissons_ratio, 2));
566  params.set<MooseEnum>("sif_mode") = "T";
567  break;
568  }
569 
570  for (unsigned int ring_index = 0; ring_index < _ring_vec.size(); ++ring_index)
571  {
572  params.set<unsigned int>("ring_index") = _ring_vec[ring_index];
573  params.set<unsigned int>("ring_first") = _ring_first;
574  params.set<MooseEnum>("q_function_type") = _q_function_type;
575 
576  if (_treat_as_2d)
577  {
578  std::ostringstream av_name_stream;
579  av_name_stream << av_base_name << "_" << _ring_vec[ring_index];
580  std::ostringstream pp_name_stream;
581  pp_name_stream << pp_base_name << "_" << _ring_vec[ring_index];
582 
583  _problem->addPostprocessor(pp_type_name, pp_name_stream.str(), params);
584  }
585  else
586  {
587  for (unsigned int cfp_index = 0; cfp_index < num_crack_front_points; ++cfp_index)
588  {
589  std::ostringstream av_name_stream;
590  av_name_stream << av_base_name << "_" << cfp_index + 1 << "_"
591  << _ring_vec[ring_index];
592  std::ostringstream pp_name_stream;
593  pp_name_stream << pp_base_name << "_" << cfp_index + 1 << "_"
594  << _ring_vec[ring_index];
595  std::ostringstream cfn_index_stream;
596  cfn_index_stream << cfp_index + 1;
597 
598  params.set<unsigned int>("crack_front_point_index") = cfp_index;
599  _problem->addPostprocessor(pp_type_name, pp_name_stream.str(), params);
600  }
601  }
602  }
603  }
604  }
605  for (unsigned int i = 0; i < _output_variables.size(); ++i)
606  {
607  const std::string ov_base_name(_output_variables[i]);
608  const std::string pp_type_name("CrackFrontData");
609  InputParameters params = _factory.getValidParams(pp_type_name);
610  params.set<ExecFlagEnum>("execute_on") = EXEC_TIMESTEP_END;
611  params.set<UserObjectName>("crack_front_definition") = uo_name;
612  if (_treat_as_2d)
613  {
614  std::ostringstream pp_name_stream;
615  pp_name_stream << ov_base_name << "_crack";
616  params.set<VariableName>("variable") = _output_variables[i];
617  _problem->addPostprocessor(pp_type_name, pp_name_stream.str(), params);
618  }
619  else
620  {
621  for (unsigned int cfp_index = 0; cfp_index < num_crack_front_points; ++cfp_index)
622  {
623  std::ostringstream pp_name_stream;
624  pp_name_stream << ov_base_name << "_crack_" << cfp_index + 1;
625  params.set<VariableName>("variable") = _output_variables[i];
626  params.set<unsigned int>("crack_front_point_index") = cfp_index;
627  _problem->addPostprocessor(pp_type_name, pp_name_stream.str(), params);
628  }
629  }
630  }
631  if (_get_equivalent_k)
632  {
633  std::string pp_base_name("Keq");
634  const std::string pp_type_name("MixedModeEquivalentK");
635  InputParameters params = _factory.getValidParams(pp_type_name);
636  params.set<ExecFlagEnum>("execute_on") = EXEC_TIMESTEP_END;
637  params.set<Real>("poissons_ratio") = _poissons_ratio;
638  for (unsigned int ring_index = 0; ring_index < _ring_vec.size(); ++ring_index)
639  {
640  if (_treat_as_2d)
641  {
642  std::ostringstream ki_name_stream;
643  ki_name_stream << "II_KI_" << _ring_vec[ring_index];
644  std::ostringstream kii_name_stream;
645  kii_name_stream << "II_KII_" << _ring_vec[ring_index];
646  std::ostringstream kiii_name_stream;
647  kiii_name_stream << "II_KIII_" << _ring_vec[ring_index];
648  params.set<PostprocessorName>("KI_name") = ki_name_stream.str();
649  params.set<PostprocessorName>("KII_name") = kii_name_stream.str();
650  params.set<PostprocessorName>("KIII_name") = kiii_name_stream.str();
651  std::ostringstream pp_name_stream;
652  pp_name_stream << pp_base_name << "_" << _ring_vec[ring_index];
653  _problem->addPostprocessor(pp_type_name, pp_name_stream.str(), params);
654  }
655  else
656  {
657  for (unsigned int cfp_index = 0; cfp_index < num_crack_front_points; ++cfp_index)
658  {
659  std::ostringstream ki_name_stream;
660  ki_name_stream << "II_KI_" << cfp_index + 1 << "_" << _ring_vec[ring_index];
661  std::ostringstream kii_name_stream;
662  kii_name_stream << "II_KII_" << cfp_index + 1 << "_" << _ring_vec[ring_index];
663  std::ostringstream kiii_name_stream;
664  kiii_name_stream << "II_KIII_" << cfp_index + 1 << "_" << _ring_vec[ring_index];
665  params.set<PostprocessorName>("KI_name") = ki_name_stream.str();
666  params.set<PostprocessorName>("KII_name") = kii_name_stream.str();
667  params.set<PostprocessorName>("KIII_name") = kiii_name_stream.str();
668  std::ostringstream pp_name_stream;
669  pp_name_stream << pp_base_name << "_" << cfp_index + 1 << "_" << _ring_vec[ring_index];
670  params.set<unsigned int>("crack_front_point_index") = cfp_index;
671  _problem->addPostprocessor(pp_type_name, pp_name_stream.str(), params);
672  }
673  }
674  }
675  }
676  }
677 
678  else if (_current_task == "add_vector_postprocessor")
679  {
680  if (!_treat_as_2d)
681  {
682  for (std::set<INTEGRAL>::iterator sit = _integrals.begin(); sit != _integrals.end(); ++sit)
683  {
684  std::string pp_base_name;
685  switch (*sit)
686  {
687  case J_INTEGRAL:
688  if (_convert_J_to_K)
689  pp_base_name = "K";
690  else
691  pp_base_name = "J";
692  break;
694  pp_base_name = "II_KI";
695  break;
697  pp_base_name = "II_KII";
698  break;
700  pp_base_name = "II_KIII";
701  break;
703  pp_base_name = "II_T";
704  break;
705  }
706  const std::string vpp_type_name("CrackDataSampler");
707  InputParameters params = _factory.getValidParams(vpp_type_name);
708  params.set<ExecFlagEnum>("execute_on") = EXEC_TIMESTEP_END;
709  params.set<UserObjectName>("crack_front_definition") = uo_name;
710  params.set<MooseEnum>("sort_by") = "id";
711  params.set<MooseEnum>("position_type") = _position_type;
712  for (unsigned int ring_index = 0; ring_index < _ring_vec.size(); ++ring_index)
713  {
714  std::vector<PostprocessorName> postprocessor_names;
715  std::ostringstream vpp_name_stream;
716  vpp_name_stream << pp_base_name << "_" << _ring_vec[ring_index];
717  for (unsigned int cfp_index = 0; cfp_index < num_crack_front_points; ++cfp_index)
718  {
719  std::ostringstream pp_name_stream;
720  pp_name_stream << pp_base_name << "_" << cfp_index + 1 << "_" << _ring_vec[ring_index];
721  postprocessor_names.push_back(pp_name_stream.str());
722  }
723  params.set<std::vector<PostprocessorName>>("postprocessors") = postprocessor_names;
724  _problem->addVectorPostprocessor(vpp_type_name, vpp_name_stream.str(), params);
725  }
726  }
727 
728  for (unsigned int i = 0; i < _output_variables.size(); ++i)
729  {
730  const std::string vpp_type_name("VectorOfPostprocessors");
731  InputParameters params = _factory.getValidParams(vpp_type_name);
732  params.set<ExecFlagEnum>("execute_on") = EXEC_TIMESTEP_END;
733  std::ostringstream vpp_name_stream;
734  vpp_name_stream << _output_variables[i] << "_crack";
735  std::vector<PostprocessorName> postprocessor_names;
736  for (unsigned int cfp_index = 0; cfp_index < num_crack_front_points; ++cfp_index)
737  {
738  std::ostringstream pp_name_stream;
739  pp_name_stream << vpp_name_stream.str() << "_" << cfp_index + 1;
740  postprocessor_names.push_back(pp_name_stream.str());
741  }
742  params.set<std::vector<PostprocessorName>>("postprocessors") = postprocessor_names;
743  _problem->addVectorPostprocessor(vpp_type_name, vpp_name_stream.str(), params);
744  }
745  }
747  {
748  std::string pp_base_name("Keq");
749  const std::string vpp_type_name("CrackDataSampler");
750  InputParameters params = _factory.getValidParams(vpp_type_name);
751  params.set<ExecFlagEnum>("execute_on") = EXEC_TIMESTEP_END;
752  params.set<UserObjectName>("crack_front_definition") = uo_name;
753  params.set<MooseEnum>("sort_by") = "id";
754  params.set<MooseEnum>("position_type") = _position_type;
755  for (unsigned int ring_index = 0; ring_index < _ring_vec.size(); ++ring_index)
756  {
757  std::vector<PostprocessorName> postprocessor_names;
758  std::ostringstream vpp_name_stream;
759  vpp_name_stream << pp_base_name << "_" << _ring_vec[ring_index];
760  for (unsigned int cfp_index = 0; cfp_index < num_crack_front_points; ++cfp_index)
761  {
762  std::ostringstream pp_name_stream;
763  pp_name_stream << pp_base_name << "_" << cfp_index + 1 << "_" << _ring_vec[ring_index];
764  postprocessor_names.push_back(pp_name_stream.str());
765  }
766  params.set<std::vector<PostprocessorName>>("postprocessors") = postprocessor_names;
767  _problem->addVectorPostprocessor(vpp_type_name, vpp_name_stream.str(), params);
768  }
769  }
770  }
771 
772  else if (_current_task == "add_material")
773  {
774  if (_temp != "" && !_solid_mechanics)
775  {
776  std::string mater_name;
777  const std::string mater_type_name("ThermalFractureIntegral");
778  mater_name = "ThermalFractureIntegral";
779 
780  InputParameters params = _factory.getValidParams(mater_type_name);
781  params.set<std::vector<MaterialPropertyName>>("eigenstrain_names") =
782  getParam<std::vector<MaterialPropertyName>>("eigenstrain_names");
783  params.set<std::vector<VariableName>>("temperature") = {_temp};
784  params.set<std::vector<SubdomainName>>("block") = {_blocks};
785  _problem->addMaterial(mater_type_name, mater_name, params);
786  }
787  MultiMooseEnum integral_moose_enums = getParam<MultiMooseEnum>("integrals");
788  bool have_j_integral = false;
789  for (auto ime : integral_moose_enums)
790  {
791  if (ime == "JIntegral")
792  have_j_integral = true;
793  }
794  if (have_j_integral && !_solid_mechanics)
795  {
796  std::string mater_name;
797  const std::string mater_type_name("StrainEnergyDensity");
798  mater_name = "StrainEnergyDensity";
799 
800  InputParameters params = _factory.getValidParams(mater_type_name);
801  _incremental = getParam<bool>("incremental");
802  params.set<bool>("incremental") = _incremental;
803  params.set<std::vector<SubdomainName>>("block") = {_blocks};
804  _problem->addMaterial(mater_type_name, mater_name, params);
805 
806  std::string mater_name2;
807  const std::string mater_type_name2("EshelbyTensor");
808  mater_name2 = "EshelbyTensor";
809 
810  InputParameters params2 = _factory.getValidParams(mater_type_name2);
811  _displacements = getParam<std::vector<VariableName>>("displacements");
812  params2.set<std::vector<VariableName>>("displacements") = _displacements;
813  params2.set<std::vector<SubdomainName>>("block") = {_blocks};
814  if (_temp != "")
815  {
816  params2.set<std::vector<VariableName>>("temperature") = {_temp};
817  }
818  _problem->addMaterial(mater_type_name2, mater_name2, params2);
819  }
820  }
821 }
822 
823 unsigned int
825 {
826  unsigned int num_points = 0;
827  if (_boundary_names.size() != 0)
828  {
829  std::vector<BoundaryID> bids = _mesh->getBoundaryIDs(_boundary_names, true);
830  std::set<unsigned int> nodes;
831 
832  ConstBndNodeRange & bnd_nodes = *_mesh->getBoundaryNodeRange();
833  for (ConstBndNodeRange::const_iterator nd = bnd_nodes.begin(); nd != bnd_nodes.end(); ++nd)
834  {
835  const BndNode * bnode = *nd;
836  BoundaryID boundary_id = bnode->_bnd_id;
837 
838  for (unsigned int ibid = 0; ibid < bids.size(); ++ibid)
839  {
840  if (boundary_id == bids[ibid])
841  {
842  nodes.insert(bnode->_node->id());
843  break;
844  }
845  }
846  }
847  num_points = nodes.size();
848  }
849  else if (_crack_front_points.size() != 0)
850  num_points = _crack_front_points.size();
852  num_points = getParam<unsigned int>("number_points_from_provider");
853  else
854  mooseError("Must define either 'boundary' or 'crack_front_points'");
855  return num_points;
856 }
DomainIntegralAction::_closed_loop
bool _closed_loop
Definition: DomainIntegralAction.h:56
DomainIntegralAction::_crack_front_points_provider
UserObjectName _crack_front_points_provider
Definition: DomainIntegralAction.h:57
addCrackFrontDefinitionParams
void addCrackFrontDefinitionParams(InputParameters &params)
Definition: CrackFrontDefinition.C:38
DomainIntegralAction::INTERACTION_INTEGRAL_T
Definition: DomainIntegralAction.h:42
DomainIntegralAction::_output_q
bool _output_q
Definition: DomainIntegralAction.h:90
DomainIntegralAction::calcNumCrackFrontPoints
unsigned int calcNumCrackFrontPoints()
Definition: DomainIntegralAction.C:824
DomainIntegralAction::_ring_first
unsigned int _ring_first
Definition: DomainIntegralAction.h:75
DomainIntegralAction::INTERACTION_INTEGRAL_KI
Definition: DomainIntegralAction.h:39
DomainIntegralAction::_family
const std::string _family
Definition: DomainIntegralAction.h:60
DomainIntegralAction::INTEGRAL
INTEGRAL
Definition: DomainIntegralAction.h:36
registerMooseAction
registerMooseAction("TensorMechanicsApp", DomainIntegralAction, "add_user_object")
DomainIntegralAction::_crack_direction_vector_end_2
RealVectorValue _crack_direction_vector_end_2
Definition: DomainIntegralAction.h:68
pow
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
Definition: ExpressionBuilder.h:673
DomainIntegralAction::_crack_direction_vector_end_1
RealVectorValue _crack_direction_vector_end_1
Definition: DomainIntegralAction.h:66
DomainIntegralAction::_end_direction_method_moose_enum
MooseEnum _end_direction_method_moose_enum
Definition: DomainIntegralAction.h:62
DomainIntegralAction::TOPOLOGY
Definition: DomainIntegralAction.h:48
DomainIntegralAction::_displacements
std::vector< VariableName > _displacements
Definition: DomainIntegralAction.h:81
DomainIntegralAction::DomainIntegralAction
DomainIntegralAction(const InputParameters &params)
Definition: DomainIntegralAction.C:100
DomainIntegralAction::_treat_as_2d
bool _treat_as_2d
Definition: DomainIntegralAction.h:71
DomainIntegralAction::_crack_mouth_boundary_names
std::vector< BoundaryName > _crack_mouth_boundary_names
Definition: DomainIntegralAction.h:69
DomainIntegralAction::_output_variables
std::vector< VariableName > _output_variables
Definition: DomainIntegralAction.h:77
DomainIntegralAction::GEOMETRY
Definition: DomainIntegralAction.h:47
DomainIntegralAction::_integrals
std::set< INTEGRAL > _integrals
Definition: DomainIntegralAction.h:53
DomainIntegralAction.h
DomainIntegralAction::_crack_direction_vector
RealVectorValue _crack_direction_vector
Definition: DomainIntegralAction.h:64
DomainIntegralAction::_ring_vec
std::vector< unsigned int > _ring_vec
Definition: DomainIntegralAction.h:91
DomainIntegralAction::_symmetry_plane
unsigned int _symmetry_plane
Definition: DomainIntegralAction.h:85
DomainIntegralAction::_direction_method_moose_enum
MooseEnum _direction_method_moose_enum
Definition: DomainIntegralAction.h:61
CrackFrontDefinition.h
DomainIntegralAction::_order
const std::string _order
Definition: DomainIntegralAction.h:59
DomainIntegralAction::J_INTEGRAL
Definition: DomainIntegralAction.h:38
DomainIntegralAction::_poissons_ratio
Real _poissons_ratio
Definition: DomainIntegralAction.h:78
DomainIntegralAction::act
virtual void act()
Definition: DomainIntegralAction.C:284
DomainIntegralAction::_radius_inner
std::vector< Real > _radius_inner
Definition: DomainIntegralAction.h:73
DomainIntegralAction::_youngs_modulus
Real _youngs_modulus
Definition: DomainIntegralAction.h:79
DomainIntegralAction::INTERACTION_INTEGRAL_KII
Definition: DomainIntegralAction.h:40
DomainIntegralAction::_intersecting_boundary_names
std::vector< BoundaryName > _intersecting_boundary_names
Definition: DomainIntegralAction.h:70
DomainIntegralAction::_use_crack_front_points_provider
bool _use_crack_front_points_provider
Definition: DomainIntegralAction.h:58
DomainIntegralAction::_blocks
std::vector< SubdomainName > _blocks
Definition: DomainIntegralAction.h:80
validParams
InputParameters validParams()
name
const std::string name
Definition: Setup.h:21
DomainIntegralAction::_q_function_type
MooseEnum _q_function_type
Definition: DomainIntegralAction.h:87
DomainIntegralAction::_incremental
bool _incremental
Definition: DomainIntegralAction.h:93
DomainIntegralAction::_use_displaced_mesh
bool _use_displaced_mesh
Definition: DomainIntegralAction.h:89
DomainIntegralAction::_convert_J_to_K
bool _convert_J_to_K
Definition: DomainIntegralAction.h:83
DomainIntegralAction::_get_equivalent_k
bool _get_equivalent_k
Definition: DomainIntegralAction.h:88
DomainIntegralAction::_have_crack_direction_vector_end_2
bool _have_crack_direction_vector_end_2
Definition: DomainIntegralAction.h:67
DomainIntegralAction::_have_crack_direction_vector
bool _have_crack_direction_vector
Definition: DomainIntegralAction.h:63
DomainIntegralAction::INTERACTION_INTEGRAL_KIII
Definition: DomainIntegralAction.h:41
DomainIntegralAction
Definition: DomainIntegralAction.h:24
DomainIntegralAction::_radius_outer
std::vector< Real > _radius_outer
Definition: DomainIntegralAction.h:74
DomainIntegralAction::_has_symmetry_plane
bool _has_symmetry_plane
Definition: DomainIntegralAction.h:84
DomainIntegralAction::_position_type
MooseEnum _position_type
Definition: DomainIntegralAction.h:86
DomainIntegralAction::_temp
VariableName _temp
Definition: DomainIntegralAction.h:82
DomainIntegralAction::_boundary_names
const std::vector< BoundaryName > & _boundary_names
Definition: DomainIntegralAction.h:54
defineLegacyParams
defineLegacyParams(DomainIntegralAction)
DomainIntegralAction::~DomainIntegralAction
~DomainIntegralAction()
Definition: DomainIntegralAction.C:281
DomainIntegralAction::_have_crack_direction_vector_end_1
bool _have_crack_direction_vector_end_1
Definition: DomainIntegralAction.h:65
DomainIntegralAction::_crack_front_points
std::vector< Point > _crack_front_points
Definition: DomainIntegralAction.h:55
DomainIntegralAction::_ring_last
unsigned int _ring_last
Definition: DomainIntegralAction.h:76
DomainIntegralAction::validParams
static InputParameters validParams()
Definition: DomainIntegralAction.C:33
DomainIntegralAction::_axis_2d
unsigned int _axis_2d
Definition: DomainIntegralAction.h:72
DomainIntegralAction::_solid_mechanics
bool _solid_mechanics
Definition: DomainIntegralAction.h:92