www.mooseframework.org
GrainBoundaryArea.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
8 #include "GrainBoundaryArea.h"
9 #include "MooseUtils.h"
10 
11 template <>
12 InputParameters
14 {
15  InputParameters params = validParams<ElementIntegralPostprocessor>();
16  params.addClassDescription("Calculate total grain boundary length in 2D and area in 3D");
17  params.addRequiredCoupledVarWithAutoBuild(
18  "v", "var_name_base", "op_num", "Array of coupled variables");
19  params.addParam<Real>("grains_per_side",
20  2.0,
21  "Number of order parameters contacting a boundary "
22  "(should be 2.0 in polycrystals and 1.0 for "
23  "dispersed particles)");
24  params.addParam<Real>("op_range",
25  1.0,
26  "Range over which order parameters change across an "
27  "interface. By default order parameters are assumed to "
28  "vary from 0 to 1");
29  return params;
30 }
31 
32 GrainBoundaryArea::GrainBoundaryArea(const InputParameters & parameters)
33  : ElementIntegralPostprocessor(parameters),
34  _op_num(coupledComponents("v")),
35  _grads(_op_num),
36  _factor(getParam<Real>("grains_per_side") * getParam<Real>("op_range"))
37 {
38  // make sure user input is valid
39  if (MooseUtils::absoluteFuzzyEqual(_factor, 0.0))
40  mooseError("Neither grains_per_side nor op_range may be zero.");
41 
42  // Loop over variables (ops)
43  for (auto op_index = decltype(_op_num)(0); op_index < _op_num; ++op_index)
44  _grads[op_index] = &coupledGradient("v", op_index);
45 }
46 
47 Real
49 {
50  Real grad_sum = 0.0;
51  for (auto grad : _grads)
52  grad_sum += (*grad)[_qp].norm();
53  return grad_sum;
54 }
55 
56 Real
58 {
59  return ElementIntegralPostprocessor::getValue() / _factor;
60 }
std::vector< const VariableGradient * > _grads
Order parameters.
const unsigned int _op_num
Number of order parameters.
GrainBoundaryArea(const InputParameters &parameters)
virtual Real getValue() override
const Real _factor
normalization factor, depending on order parameter range and grains per side
virtual Real computeQpIntegral() override
InputParameters validParams< GrainBoundaryArea >()