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 "SmoothMultiBoundingBoxBaseIC.h" 11 : #include "MooseMesh.h" 12 : #include "FEProblemBase.h" 13 : 14 : InputParameters 15 97 : SmoothMultiBoundingBoxBaseIC::validParams() 16 : { 17 97 : InputParameters params = InitialCondition::validParams(); 18 194 : params.addRequiredParam<Real>("outside", "Outside value"); 19 194 : params.addRequiredParam<std::vector<Point>>( 20 : "smaller_coordinate_corners", 21 : "For 1D, these are the left points; for 2D, these are the bottom left corners; for 3D, these " 22 : "are the back bottom left corners. The format is (corner1_x corner1_y corner1_z corner2_x " 23 : "corner2_y corner2_z ...)"); 24 194 : params.addRequiredParam<std::vector<Point>>( 25 : "larger_coordinate_corners", 26 : "For 1D, these are the right points; for 2D, these are the top right corners; for 3D, these " 27 : "are the front top right corners. The format is (corner1_x corner1_y corner1_z corner2_x " 28 : "corner2_y corner2_z ...)"); 29 194 : params.addRequiredParam<Real>("int_width", "The value of the interfacial width between boxes"); 30 194 : params.addRequiredParam<std::vector<Real>>("inside", 31 : "The value of the variable inside each box " 32 : "(one value per box or a single value for " 33 : "all boxes)"); 34 97 : return params; 35 0 : } 36 : 37 51 : SmoothMultiBoundingBoxBaseIC::SmoothMultiBoundingBoxBaseIC(const InputParameters & parameters) 38 : : InitialCondition(parameters), 39 51 : _outside(getParam<Real>("outside")), 40 102 : _c1(getParam<std::vector<Point>>("smaller_coordinate_corners")), 41 153 : _c2(getParam<std::vector<Point>>("larger_coordinate_corners")), 42 51 : _nbox(_c1.size()), 43 102 : _int_width(getParam<Real>("int_width")), 44 51 : _dim(_fe_problem.mesh().dimension()), 45 153 : _inside(getParam<std::vector<Real>>("inside")) 46 : { 47 51 : } 48 : 49 : Real 50 100916 : SmoothMultiBoundingBoxBaseIC::value(const Point & p) 51 : { 52 100916 : Real value = _outside; 53 : 54 : // if "inside" vector only has size 1, all the boxes have the same inside value 55 100916 : if (_inside.size() == 1) 56 : { 57 0 : _inside.assign(_nbox, _inside[0]); 58 : } 59 : 60 : // make sure inputs are the same length 61 100916 : if (_c2.size() != _nbox || _inside.size() != _nbox) 62 0 : paramError("vector inputs must all be the same size"); 63 : 64 100916 : if (_int_width < 0.0) 65 0 : paramError("'int_width' should be non-negative"); 66 : 67 100916 : if (_int_width == 0.0) 68 : { 69 9600 : for (unsigned int b = 0; b < _nbox; ++b) 70 : { 71 9120 : for (unsigned int i = 0; i < _dim; ++i) 72 9120 : if (_c1[b](i) < _c2[b](i) && p(i) >= _c1[b](i) && p(i) <= _c2[b](i)) 73 : { 74 2304 : if (i != _dim - 1) 75 : continue; 76 384 : value = _inside[b]; 77 384 : break; 78 : } 79 : else 80 : break; 81 : } 82 : } 83 100916 : return value; 84 : }