LCOV - code coverage report
Current view: top level - src/ics - IsolatedBoundingBoxIC.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 "IsolatedBoundingBoxIC.h"
      11             : #include "MooseMesh.h"
      12             : 
      13             : registerMooseObject("PhaseFieldApp", IsolatedBoundingBoxIC);
      14             : 
      15             : InputParameters
      16          51 : IsolatedBoundingBoxIC::validParams()
      17             : {
      18          51 :   InputParameters params = SmoothMultiBoundingBoxBaseIC::validParams();
      19          51 :   params.addClassDescription(
      20             :       "Specify variable values inside and outside a list of isolated boxes shaped "
      21             :       "axis-aligned regions defined by pairs of opposing corners");
      22         102 :   params.addParam<Real>("outside", 0.0, "The value of the variable outside the boxes");
      23          51 :   return params;
      24           0 : }
      25             : 
      26          27 : IsolatedBoundingBoxIC::IsolatedBoundingBoxIC(const InputParameters & parameters)
      27          54 :   : SmoothMultiBoundingBoxBaseIC(parameters), _outside(getParam<Real>("outside"))
      28             : {
      29          27 : }
      30             : 
      31             : Real
      32       50516 : IsolatedBoundingBoxIC::value(const Point & p)
      33             : {
      34       50516 :   Real value = SmoothMultiBoundingBoxBaseIC::value(p);
      35             : 
      36       50516 :   if (_int_width != 0.0)
      37             :   {
      38      192456 :     for (unsigned int b = 0; b < _nbox; ++b)
      39             :     {
      40      180111 :       for (unsigned int i = 0; i < _dim; ++i)
      41             :       {
      42      178959 :         if (_c1[b](i) < _c2[b](i) && p(i) >= _c1[b](i) - _int_width &&
      43      108331 :             p(i) <= _c2[b](i) + _int_width)
      44             :         {
      45       35771 :           if (i != _dim - 1)
      46       34616 :             continue;
      47        2307 :           for (unsigned int n = b + 1; n < _nbox; ++n)
      48             :           {
      49        4614 :             for (unsigned int j = 0; j < _dim; ++j)
      50             :             {
      51        3462 :               if (p(j) >= _c1[n](j) - _int_width && p(j) <= _c2[n](j) + _int_width)
      52           3 :                 mooseError("Partially overlapping boxes are not allowed. Note that this "
      53             :                            "includes the overlapping diffused interfaces. For nested boxes, "
      54             :                            "use NestedBoundingBoxIC.C.");
      55             :             }
      56             :           }
      57             :           Real f_in = 1.0;
      58        4608 :           for (unsigned int j = 0; j < _dim; ++j)
      59        3456 :             f_in *= 0.5 * (std::tanh(2.0 * libMesh::pi * (p(j) - _c1[b](j)) / _int_width) -
      60        3456 :                            std::tanh(2.0 * libMesh::pi * (p(j) - _c2[b](j)) / _int_width));
      61        1152 :           value = _outside + (_inside[b] - _outside) * f_in;
      62             :         }
      63      143188 :         else if (_c1[b](i) >= _c2[b](i))
      64           0 :           mooseError("The coordinates of the smaller_coordinate_corners are equal to or larger "
      65             :                      "than that of "
      66             :                      "the larger_coordinate_corners.");
      67             :         else
      68             :           break;
      69             :       }
      70             :     }
      71             :   }
      72       50513 :   return value;
      73             : }

Generated by: LCOV version 1.14