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 30 : NestedBoundingBoxIC::validParams() 17 : { 18 30 : InputParameters params = SmoothMultiBoundingBoxBaseIC::validParams(); 19 30 : params.addClassDescription("Specify variable values inside a list of nested boxes shaped " 20 : "axis-aligned regions defined by pairs of opposing corners"); 21 60 : params.addParam<Real>("outside", 0.0, "The value of the variable outside the largest boxes"); 22 30 : return params; 23 0 : } 24 : 25 16 : NestedBoundingBoxIC::NestedBoundingBoxIC(const InputParameters & parameters) 26 32 : : SmoothMultiBoundingBoxBaseIC(parameters), _outside(getParam<Real>("outside")) 27 : { 28 16 : } 29 : 30 : Real 31 42000 : NestedBoundingBoxIC::value(const Point & p) 32 : { 33 42000 : Real value = SmoothMultiBoundingBoxBaseIC::value(p); 34 : 35 42000 : if (_int_width != 0.0) 36 : { 37 135840 : for (unsigned int b = 0; b < _nbox; ++b) 38 : { 39 226080 : for (unsigned int i = 0; i < _dim; ++i) 40 : { 41 226080 : if (_c1[b](i) < _c2[b](i) && p(i) >= _c1[b](i) - _int_width && 42 174520 : p(i) <= _c2[b](i) + _int_width) 43 : { 44 132240 : if (i != _dim - 1) 45 : continue; 46 : Real f_in = 1.0; 47 93120 : for (unsigned int j = 0; j < _dim; ++j) 48 69640 : f_in *= 0.5 * (std::tanh(2.0 * libMesh::pi * (p(j) - _c1[b](j)) / _int_width) - 49 69640 : std::tanh(2.0 * libMesh::pi * (p(j) - _c2[b](j)) / _int_width)); 50 23480 : if (b == _nbox - 1) 51 15800 : value = _outside + (_inside[b] - _outside) * f_in; 52 : else 53 7680 : value = _inside[b + 1] + (_inside[b] - _inside[b + 1]) * f_in; 54 23480 : goto label; 55 : } 56 93840 : 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 42000 : return value; 67 : }