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 65 : SmoothMultiBoundingBoxBaseIC::validParams() 16 : { 17 65 : InputParameters params = InitialCondition::validParams(); 18 130 : params.addRequiredParam<Real>("outside", "Outside value"); 19 130 : 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 130 : 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 130 : params.addRequiredParam<Real>("int_width", "The value of the interfacial width between boxes"); 30 130 : 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 65 : return params; 35 0 : } 36 : 37 35 : SmoothMultiBoundingBoxBaseIC::SmoothMultiBoundingBoxBaseIC(const InputParameters & parameters) 38 : : InitialCondition(parameters), 39 35 : _outside(getParam<Real>("outside")), 40 70 : _c1(getParam<std::vector<Point>>("smaller_coordinate_corners")), 41 105 : _c2(getParam<std::vector<Point>>("larger_coordinate_corners")), 42 35 : _nbox(_c1.size()), 43 70 : _int_width(getParam<Real>("int_width")), 44 35 : _dim(_fe_problem.mesh().dimension()), 45 105 : _inside(getParam<std::vector<Real>>("inside")) 46 : { 47 35 : } 48 : 49 : Real 50 84116 : SmoothMultiBoundingBoxBaseIC::value(const Point & p) 51 : { 52 84116 : Real value = _outside; 53 : 54 : // if "inside" vector only has size 1, all the boxes have the same inside value 55 84116 : if (_inside.size() == 1) 56 : { 57 0 : _inside.assign(_nbox, _inside[0]); 58 : } 59 : 60 : // make sure inputs are the same length 61 84116 : if (_c2.size() != _nbox || _inside.size() != _nbox) 62 0 : paramError("vector inputs must all be the same size"); 63 : 64 84116 : if (_int_width < 0.0) 65 0 : paramError("'int_width' should be non-negative"); 66 : 67 84116 : if (_int_width == 0.0) 68 : { 69 8000 : for (unsigned int b = 0; b < _nbox; ++b) 70 : { 71 7600 : for (unsigned int i = 0; i < _dim; ++i) 72 7600 : if (_c1[b](i) < _c2[b](i) && p(i) >= _c1[b](i) && p(i) <= _c2[b](i)) 73 : { 74 1920 : if (i != _dim - 1) 75 : continue; 76 320 : value = _inside[b]; 77 320 : break; 78 : } 79 : else 80 : break; 81 : } 82 : } 83 84116 : return value; 84 : }