LCOV - code coverage report
Current view: top level - src/postprocessors - GrainBoundaryArea.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #32971 (54bef8) with base c6cf66 Lines: 23 25 92.0 %
Date: 2026-05-29 20:38:39 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          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          30 : GrainBoundaryArea::validParams()
      17             : {
      18          30 :   InputParameters params = ElementIntegralPostprocessor::validParams();
      19          30 :   params.addClassDescription("Calculate total grain boundary length in 2D and area in 3D");
      20          60 :   params.addRequiredCoupledVarWithAutoBuild(
      21             :       "v", "var_name_base", "op_num", "Array of coupled variables");
      22          60 :   params.addParam<Real>("grains_per_side",
      23          60 :                         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          60 :   params.addParam<Real>("op_range",
      28          60 :                         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          30 :   return params;
      33           0 : }
      34             : 
      35          16 : GrainBoundaryArea::GrainBoundaryArea(const InputParameters & parameters)
      36             :   : ElementIntegralPostprocessor(parameters),
      37          16 :     _op_num(coupledComponents("v")),
      38          16 :     _grads(_op_num),
      39          64 :     _factor(getParam<Real>("grains_per_side") * getParam<Real>("op_range"))
      40             : {
      41             :   // make sure user input is valid
      42          16 :   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          40 :   for (MooseIndex(_op_num) op_index = 0; op_index < _op_num; ++op_index)
      47          24 :     _grads[op_index] = &coupledGradient("v", op_index);
      48          16 : }
      49             : 
      50             : Real
      51      400000 : GrainBoundaryArea::computeQpIntegral()
      52             : {
      53             :   Real grad_sum = 0.0;
      54     1000000 :   for (auto grad : _grads)
      55      600000 :     grad_sum += (*grad)[_qp].norm();
      56      400000 :   return grad_sum;
      57             : }
      58             : 
      59             : Real
      60          12 : GrainBoundaryArea::getValue() const
      61             : {
      62          12 :   return ElementIntegralPostprocessor::getValue() / _factor;
      63             : }

Generated by: LCOV version 1.14