LCOV - code coverage report
Current view: top level - src/ics - Tricrystal2CircleGrainsIC.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 27 29 93.1 %
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 "Tricrystal2CircleGrainsIC.h"
      11             : #include "MooseRandom.h"
      12             : #include "MooseMesh.h"
      13             : #include "FEProblemBase.h"
      14             : 
      15             : registerMooseObject("PhaseFieldApp", Tricrystal2CircleGrainsIC);
      16             : 
      17             : InputParameters
      18         102 : Tricrystal2CircleGrainsIC::validParams()
      19             : {
      20         102 :   InputParameters params = InitialCondition::validParams();
      21         102 :   params.addClassDescription("Tricrystal with two circles/bubbles");
      22         204 :   params.addRequiredParam<unsigned int>("op_num", "Number of grain order parameters");
      23         204 :   params.addRequiredParam<unsigned int>("op_index", "Index for the current grain order parameter");
      24         102 :   return params;
      25           0 : }
      26             : 
      27          54 : Tricrystal2CircleGrainsIC::Tricrystal2CircleGrainsIC(const InputParameters & parameters)
      28             :   : InitialCondition(parameters),
      29         108 :     _mesh(_fe_problem.mesh()),
      30         108 :     _op_num(getParam<unsigned int>("op_num")),
      31         162 :     _op_index(getParam<unsigned int>("op_index"))
      32             : {
      33          54 :   if (_op_num != 3)
      34           0 :     paramError("op_num", "Tricrystal ICs must have op_num = 3");
      35             : 
      36             :   // Set up domain bounds with mesh tools
      37         216 :   for (const auto i : make_range(Moose::dim))
      38             :   {
      39         162 :     _bottom_left(i) = _mesh.getMinInDimension(i);
      40         162 :     _top_right(i) = _mesh.getMaxInDimension(i);
      41             :   }
      42          54 :   _range = _top_right - _bottom_left;
      43          54 : }
      44             : 
      45             : Real
      46      131160 : Tricrystal2CircleGrainsIC::value(const Point & p)
      47             : {
      48             :   Point grain_center_left;
      49      131160 :   grain_center_left(0) = _bottom_left(0) + _range(0) / 4.0;
      50      131160 :   grain_center_left(1) = _bottom_left(1) + _range(1) / 2.0;
      51      131160 :   grain_center_left(2) = _bottom_left(2) + _range(2) / 2.0;
      52             : 
      53             :   Point grain_center_right;
      54      131160 :   grain_center_right(0) = _bottom_left(0) + _range(0) * 3.0 / 4.0;
      55             :   grain_center_right(1) = _bottom_left(1) + _range(1) / 2.0;
      56             :   grain_center_right(2) = _bottom_left(2) + _range(2) / 2.0;
      57             : 
      58      131160 :   Real radius = _range(0) / 5.0;
      59      131160 :   Real dist_left = (p - grain_center_left).norm();
      60      131160 :   Real dist_right = (p - grain_center_right).norm();
      61             : 
      62      131160 :   if ((dist_left <= radius && _op_index == 1) || (dist_right <= radius && _op_index == 2) ||
      63       94200 :       (dist_left > radius && dist_right > radius && _op_index == 0))
      64             :     return 1.0;
      65             :   else
      66       87440 :     return 0.0;
      67             : }

Generated by: LCOV version 1.14