LCOV - code coverage report
Current view: top level - src/auxkernels - SolutionAuxMisorientationBoundary.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 21 26 80.8 %
Date: 2025-09-04 07:55:36 Functions: 3 3 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 "MooseError.h"
      11             : #include "SolutionAuxMisorientationBoundary.h"
      12             : #include "SolutionUserObject.h"
      13             : #include "BndsCalculator.h"
      14             : 
      15             : registerMooseObject("PhaseFieldApp", SolutionAuxMisorientationBoundary);
      16             : 
      17             : InputParameters
      18          22 : SolutionAuxMisorientationBoundary::validParams()
      19             : {
      20          22 :   InputParameters params = SolutionAux::validParams();
      21          22 :   params.addClassDescription(
      22             :       "Calculate location of grain boundaries by using information from a SolutionUserObject.");
      23          44 :   params.addRequiredCoupledVarWithAutoBuild(
      24             :       "v", "var_name_base", "op_num", "Array of coupled variables");
      25          44 :   params.addRequiredParam<Real>("gb_type_order",
      26             :                                 "The grain boundary type to calculate bnds parameter");
      27          22 :   return params;
      28           0 : }
      29             : 
      30          12 : SolutionAuxMisorientationBoundary::SolutionAuxMisorientationBoundary(
      31          12 :     const InputParameters & parameters)
      32             :   : SolutionAux(parameters),
      33          12 :     _gb_type_order(getParam<Real>("gb_type_order")),
      34          12 :     _op_num(coupledComponents("v")),
      35          24 :     _vals(coupledValues("v"))
      36             : {
      37          12 : }
      38             : 
      39             : Real
      40        1936 : SolutionAuxMisorientationBoundary::computeValue()
      41             : {
      42             :   // The value to output
      43             :   Real output_gb_type;
      44             : 
      45             :   // _direct=true, extract the values using the dof
      46        1936 :   if (_direct)
      47             :   {
      48           0 :     if (isNodal())
      49           0 :       output_gb_type = _solution_object.directValue(_current_node, _var_name);
      50             :     else
      51           0 :       output_gb_type = _solution_object.directValue(_current_elem, _var_name);
      52             :   }
      53             :   // _direct=false, extract the values using time and point
      54             :   else
      55             :   {
      56        1936 :     if (isNodal())
      57        1936 :       output_gb_type = _solution_object.pointValue(_t, *_current_node, _var_name);
      58             :     else
      59           0 :       output_gb_type = _solution_object.pointValue(_t, _current_elem->vertex_average(), _var_name);
      60             :   }
      61             : 
      62             :   // generate different GB boundary parameters
      63        1936 :   auto gb_type_shift = abs(output_gb_type - _gb_type_order);
      64        1936 :   if (abs(output_gb_type - 0) < 1e-3)
      65             :     return 1.0;
      66        1936 :   else if (gb_type_shift < 1e-3)
      67         792 :     return BndsCalculator::computeBndsVariable(_vals, _qp);
      68             :   else
      69        1144 :     return gb_type_shift + (1 - gb_type_shift) * BndsCalculator::computeBndsVariable(_vals, _qp);
      70             : }

Generated by: LCOV version 1.14