Line data Source code
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 : 10 : #include "GrainBoundaryArea.h" 11 : #include "MooseUtils.h" 12 : 13 : registerMooseObject("PhaseFieldApp", GrainBoundaryArea); 14 : 15 : InputParameters 16 46 : GrainBoundaryArea::validParams() 17 : { 18 46 : InputParameters params = ElementIntegralPostprocessor::validParams(); 19 46 : params.addClassDescription("Calculate total grain boundary length in 2D and area in 3D"); 20 92 : params.addRequiredCoupledVarWithAutoBuild( 21 : "v", "var_name_base", "op_num", "Array of coupled variables"); 22 92 : params.addParam<Real>("grains_per_side", 23 92 : 2.0, 24 : "Number of order parameters contacting a boundary " 25 : "(should be 2.0 in polycrystals and 1.0 for " 26 : "dispersed particles)"); 27 92 : params.addParam<Real>("op_range", 28 92 : 1.0, 29 : "Range over which order parameters change across an " 30 : "interface. By default order parameters are assumed to " 31 : "vary from 0 to 1"); 32 46 : return params; 33 0 : } 34 : 35 24 : GrainBoundaryArea::GrainBoundaryArea(const InputParameters & parameters) 36 : : ElementIntegralPostprocessor(parameters), 37 24 : _op_num(coupledComponents("v")), 38 24 : _grads(_op_num), 39 96 : _factor(getParam<Real>("grains_per_side") * getParam<Real>("op_range")) 40 : { 41 : // make sure user input is valid 42 24 : if (MooseUtils::absoluteFuzzyEqual(_factor, 0.0)) 43 0 : mooseError("Neither grains_per_side nor op_range may be zero."); 44 : 45 : // Loop over variables (ops) 46 60 : for (MooseIndex(_op_num) op_index = 0; op_index < _op_num; ++op_index) 47 36 : _grads[op_index] = &coupledGradient("v", op_index); 48 24 : } 49 : 50 : Real 51 480000 : GrainBoundaryArea::computeQpIntegral() 52 : { 53 : Real grad_sum = 0.0; 54 1200000 : for (auto grad : _grads) 55 720000 : grad_sum += (*grad)[_qp].norm(); 56 480000 : return grad_sum; 57 : } 58 : 59 : Real 60 16 : GrainBoundaryArea::getValue() const 61 : { 62 16 : return ElementIntegralPostprocessor::getValue() / _factor; 63 : }