LCOV - code coverage report
Current view: top level - src/ics - NestedBoundingBoxIC.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #31405 (292dce) with base fef103 Lines: 25 28 89.3 %
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 "NestedBoundingBoxIC.h"
      11             : #include "MooseMesh.h"
      12             : 
      13             : registerMooseObject("PhaseFieldApp", NestedBoundingBoxIC);
      14             : 
      15             : InputParameters
      16          46 : NestedBoundingBoxIC::validParams()
      17             : {
      18          46 :   InputParameters params = SmoothMultiBoundingBoxBaseIC::validParams();
      19          46 :   params.addClassDescription("Specify variable values inside a list of nested boxes shaped "
      20             :                              "axis-aligned regions defined by pairs of opposing corners");
      21          92 :   params.addParam<Real>("outside", 0.0, "The value of the variable outside the largest boxes");
      22          46 :   return params;
      23           0 : }
      24             : 
      25          24 : NestedBoundingBoxIC::NestedBoundingBoxIC(const InputParameters & parameters)
      26          48 :   : SmoothMultiBoundingBoxBaseIC(parameters), _outside(getParam<Real>("outside"))
      27             : {
      28          24 : }
      29             : 
      30             : Real
      31       50400 : NestedBoundingBoxIC::value(const Point & p)
      32             : {
      33       50400 :   Real value = SmoothMultiBoundingBoxBaseIC::value(p);
      34             : 
      35       50400 :   if (_int_width != 0.0)
      36             :   {
      37      163008 :     for (unsigned int b = 0; b < _nbox; ++b)
      38             :     {
      39      271296 :       for (unsigned int i = 0; i < _dim; ++i)
      40             :       {
      41      271296 :         if (_c1[b](i) < _c2[b](i) && p(i) >= _c1[b](i) - _int_width &&
      42      209424 :             p(i) <= _c2[b](i) + _int_width)
      43             :         {
      44      158688 :           if (i != _dim - 1)
      45             :             continue;
      46             :           Real f_in = 1.0;
      47      111744 :           for (unsigned int j = 0; j < _dim; ++j)
      48       83568 :             f_in *= 0.5 * (std::tanh(2.0 * libMesh::pi * (p(j) - _c1[b](j)) / _int_width) -
      49       83568 :                            std::tanh(2.0 * libMesh::pi * (p(j) - _c2[b](j)) / _int_width));
      50       28176 :           if (b == _nbox - 1)
      51       18960 :             value = _outside + (_inside[b] - _outside) * f_in;
      52             :           else
      53        9216 :             value = _inside[b + 1] + (_inside[b] - _inside[b + 1]) * f_in;
      54       28176 :           goto label;
      55             :         }
      56      112608 :         else if (_c1[b](i) >= _c2[b](i))
      57           0 :           mooseError("The coordinates of the smaller_coordinate_corners are equal to or larger "
      58             :                      "than that of "
      59             :                      "the larger_coordinate_corners.");
      60             :         else
      61             :           break;
      62             :       }
      63             :     }
      64             :   }
      65           0 : label:
      66       50400 :   return value;
      67             : }

Generated by: LCOV version 1.14