LCOV - code coverage report
Current view: top level - src/ics - ThumbIC.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #32971 (54bef8) with base c6cf66 Lines: 29 30 96.7 %
Date: 2026-05-29 20:38:39 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 "ThumbIC.h"
      11             : 
      12             : registerMooseObject("PhaseFieldApp", ThumbIC);
      13             : 
      14             : InputParameters
      15          30 : ThumbIC::validParams()
      16             : {
      17          30 :   InputParameters params = InitialCondition::validParams();
      18          30 :   params.addClassDescription("Thumb shaped bicrystal for grain boundary mobility tests");
      19          60 :   params.addRequiredParam<Real>("xcoord", "The x coordinate of the circle center");
      20          60 :   params.addRequiredParam<Real>("width", "The y coordinate of the circle center");
      21          60 :   params.addRequiredParam<Real>("height", "The z coordinate of the circle center");
      22          60 :   params.addRequiredParam<Real>("invalue", "The variable value inside the circle");
      23          60 :   params.addRequiredParam<Real>("outvalue", "The variable value outside the circle");
      24          30 :   return params;
      25           0 : }
      26             : 
      27          16 : ThumbIC::ThumbIC(const InputParameters & parameters)
      28             :   : InitialCondition(parameters),
      29          16 :     _xcoord(parameters.get<Real>("xcoord")),
      30          16 :     _width(parameters.get<Real>("width")),
      31          16 :     _height(parameters.get<Real>("height")),
      32          16 :     _invalue(parameters.get<Real>("invalue")),
      33          32 :     _outvalue(parameters.get<Real>("outvalue"))
      34             : {
      35          16 : }
      36             : 
      37             : Real
      38      107040 : ThumbIC::value(const Point & p)
      39             : {
      40             :   Real value = 0.0;
      41             : 
      42      107040 :   if (p(1) > _height)
      43             :   {
      44             :     Real rad = 0.0;
      45       40560 :     Point center(_xcoord, _height, 0.0);
      46      121680 :     for (unsigned int i = 0; i < 2; ++i)
      47       81120 :       rad += (p(i) - center(i)) * (p(i) - center(i));
      48             : 
      49       40560 :     rad = sqrt(rad);
      50             : 
      51       40560 :     if (rad <= _width / 2.0)
      52        8160 :       value = _invalue;
      53             :     else
      54       32400 :       value = _outvalue;
      55             :   }
      56             :   else
      57             :   {
      58       66480 :     if (p(0) > _xcoord - _width / 2.0 && p(0) < _xcoord + _width / 2.0)
      59       25140 :       value = _invalue;
      60             :     else
      61       41340 :       value = _outvalue;
      62             :   }
      63             : 
      64      107040 :   return value;
      65             : }

Generated by: LCOV version 1.14